Please tell me how to round off the Rails app's consumption tax decimal point.

Asked 2 years ago, Updated 2 years ago, 46 views

The view has item name, quantity, and unit price.
If the quantity is "1" and the unit price is "485,560", the consumption tax is "38,844.8->38,845"
If the quantity is '-1' and the unit price is '485,560', the consumption tax is '38,844.8->38,844'
The amount of consumption tax will be different.
I'd like to round off the consumption tax to 38,845; what should I do?
Thank you very much for your information.

<p class="pill-left total_fee_wrapper_02"><span class="total_fee_background tax_border_left total_fee_font_size_02">消費税額</span>¥<span class="total_fee total_fee_font_size"><%= number_with_delimiter((BigDecimal(@selling_price_total_07.to_i + @selling_price_total_15.to_i + @selling_price_total_37.to_i + @selling_price_total_52.to_i)*BigDecimal(@tax))).ceil)%></span>/p>

ruby-on-rails ruby

2022-09-30 19:41

1 Answers

Sorry, after changing the "ceil" method to the "round" method, I was able to round it off.

Reference Site
https://www.rubylife.jp/ini/numeric_class/index3.html


2022-09-30 19:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.