1
0
Tim Kächele e91e12c7ea Stop reading in all content
Process the shipments month by month instead
2024-12-11 20:13:35 +01:00

19 lines
437 B
Ruby

module PlanetExpressExpress
class DiscountBudget
def initialize(limit_per_month)
@limit_per_month = limit_per_month
end
def limit_discounts(shipments)
available_budget = @limit_per_month
shipments[:all].each do |shipment|
if shipment.discount > available_budget
shipment.discount = available_budget
end
available_budget -= shipment.discount
end
end
end
end