Files
openfoodnetwork/app/models/enterprise_fee_adjustments.rb
Gaetan Craig-Riou e129ef38c2 Refactor total method to use sum instead of reduce
Plus some extra specs to cover missing scenarios
2024-01-29 14:12:28 +11:00

18 lines
445 B
Ruby

# frozen_string_literal: true
# EnterpriseFeeAdjustments represent a collection of enterprise fee adjustments
#
class EnterpriseFeeAdjustments
def initialize(adjustments)
@adjustments = adjustments
end
def total_additional_tax
@adjustments.sum { |enterprise_fee| enterprise_fee.additional_tax_total.to_f }
end
def total_included_tax
@adjustments.sum { |enterprise_fee| enterprise_fee.included_tax_total.to_f }
end
end