18 lines
pricing/tiers.go
Returns the bulk-discount percentage for a given order quantity.
// Package pricing implements bulk discount tier logic.
package pricing
 
// DiscountTier returns the discount percentage for the given order quantity.
// Parameters: qty — number of units ordered; boundary values receive the higher tier.
// Returns: discount factor as float64 (0.15 = 15%, 0.10 = 10%, 0.05 = 5%, 0.00 = none).
func DiscountTier(qty int) float64 {
	switch {
	case qty > 100:
		return 0.15
	case qty > 50:
		return 0.10
	case qty > 10:
		return 0.05
	default:
		return 0.00
	}
}