mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
11768: add roundoff
- Fix lint issues
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user