Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trailing zeroes in tax amount #4758

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove trailing zeroes in tax amount
NumberToPercentageConverter defaults to a precision of 3, leading to
displays of VAT amount like '21.000%' on the cart's label, which doesn't
look good. Using `precision: nil` will keep the default precision of the
number.
Naokimi committed Dec 2, 2022
commit 5483bc180f08a0ac07ab3f82998b3bfd1cc029e1
2 changes: 1 addition & 1 deletion backend/spec/features/admin/orders/adjustments_spec.rb
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
context "admin managing adjustments" do
it "should display the correct values for existing order adjustments" do
within first('table tr', text: 'Tax') do
expect(column_text(2)).to match(/TaxCategory - \d+ 20\.000%/)
expect(column_text(2)).to match(/TaxCategory - \d+ 20\.0%/)
expect(column_text(3)).to eq("$2.00")
end
end
3 changes: 2 additions & 1 deletion core/app/models/spree/tax_rate.rb
Original file line number Diff line number Diff line change
@@ -118,7 +118,8 @@ def adjustment_label(amount)
def amount_for_adjustment_label
ActiveSupport::NumberHelper::NumberToPercentageConverter.convert(
amount * 100,
locale: I18n.locale
locale: I18n.locale,
precision: nil
)
end

2 changes: 1 addition & 1 deletion core/spec/models/spree/tax_calculator/default_spec.rb
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@
expect(line_item_tax.amount).to eq 1
expect(line_item_tax.included_in_price).to be false
expect(line_item_tax.tax_rate).to eq book_tax_rate
expect(line_item_tax.label).to eq "New York Sales Tax 5.000%"
expect(line_item_tax.label).to eq "New York Sales Tax 5.0%"
end

it "has tax information for the shipments" do