package points

func CentsToPoints(cents int64, rate int64) int64 {
    if cents <= 0 || rate <= 0 { return 0 }
    return cents * rate
}

func PointsToCents(points int64, rate int64) int64 {
    if points <= 0 || rate <= 0 { return 0 }
    return points / rate
}

func RefundPointsAmount(pointsAmountCents int64, refundedCents int64, totalPaidCents int64, rate int64) int64 {
    if pointsAmountCents <= 0 || refundedCents <= 0 || totalPaidCents <= 0 || rate <= 0 { return 0 }
    if refundedCents > totalPaidCents { refundedCents = totalPaidCents }
    targetCents := (pointsAmountCents * refundedCents) / totalPaidCents
    return targetCents / 100
}

