mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-30 06:31:16 +00:00
Fix fractional cents appearing on sales tax report totals
This commit is contained in:
@@ -42,6 +42,10 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
totals.each_pair do |k, v|
|
||||
totals[k] = totals[k].round(2)
|
||||
end
|
||||
|
||||
totals
|
||||
end
|
||||
|
||||
|
||||
@@ -21,6 +21,15 @@ module OpenFoodNetwork
|
||||
totals[:items_total].should == 36
|
||||
end
|
||||
|
||||
context "when floating point math would result in fractional cents" do
|
||||
let(:li1) { double(:line_item, quantity: 1, amount: 0.11) }
|
||||
let(:li2) { double(:line_item, quantity: 2, amount: 0.12) }
|
||||
|
||||
it "rounds to the nearest cent" do
|
||||
totals[:items_total].should == 0.23
|
||||
end
|
||||
end
|
||||
|
||||
it "calculates the taxable total price" do
|
||||
totals[:taxable_total].should == 36
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user