11768: add roundoff

- Fix lint issues
This commit is contained in:
Ahmed Ejaz
2023-12-27 15:46:20 +05:00
parent a3592cb14a
commit cb9c2963af
3 changed files with 7 additions and 3 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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