diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index abf7f49605..a663b9b9c8 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -626,7 +626,8 @@ module Spree # @return [BigDecimal] The rate of the voucher if applied to the order def applied_voucher_rate - # As an order can have only one voucher, hence using +take+ because each voucher adjustment will have the same voucher + # As an order can have only one voucher, + # hence using +take+ as each voucher adjustment will have the same voucher return BigDecimal(0) unless (voucher_adjustment = voucher_adjustments.take) voucher = voucher_adjustment.originator diff --git a/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_order.rb b/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_order.rb index 946e891770..bfc5747957 100644 --- a/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_order.rb +++ b/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_order.rb @@ -308,7 +308,8 @@ module Reporting def apply_voucher_on_amount(order, amount) rate = order.applied_voucher_rate - amount + (amount*rate) + result = amount + (amount * rate) + BigDecimal(result.to_s).round(2, BigDecimal::ROUND_HALF_UP) end end end diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 24796dab2b..8049cf4f42 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -1578,7 +1578,9 @@ describe Spree::Order do end context "when order has voucher_percentage_rate adjustment" do - let(:voucher) { create(:voucher_percentage_rate, enterprise: order.distributor, amount: 10) } + let(:voucher) do + create(:voucher_percentage_rate, enterprise: order.distributor, amount: 10) + end it 'returns the BigDecimal 0 value' do actual = order.applied_voucher_rate