From b79acf316c56cd2c2aa13494ae4619020dcace4b Mon Sep 17 00:00:00 2001 From: Neal Chambers Date: Thu, 31 Oct 2024 09:27:17 +0900 Subject: [PATCH] Refactor option_value_value_unit_scaled for correct unit value scaling and update sales tax report spec for clarity --- app/services/variant_units/option_value_namer.rb | 2 +- spec/lib/reports/sales_tax_totals_by_order_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/services/variant_units/option_value_namer.rb b/app/services/variant_units/option_value_namer.rb index fa6cbd4c158..40ca0a23609 100644 --- a/app/services/variant_units/option_value_namer.rb +++ b/app/services/variant_units/option_value_namer.rb @@ -58,7 +58,7 @@ def option_value_value_unit def option_value_value_unit_scaled unit_scale, unit_name = scale_for_unit_value - value = (@nameable.unit_value / unit_scale).to_d.round(2) + value = (@nameable.unit_value.to_d / unit_scale).round(2) [value, unit_name] end diff --git a/spec/lib/reports/sales_tax_totals_by_order_spec.rb b/spec/lib/reports/sales_tax_totals_by_order_spec.rb index 0e6be04375b..603331788a5 100644 --- a/spec/lib/reports/sales_tax_totals_by_order_spec.rb +++ b/spec/lib/reports/sales_tax_totals_by_order_spec.rb @@ -145,7 +145,8 @@ total = report.total_excl_tax(query_row) # discounted order total - discounted order tax - expect(total).to eq((BigDecimal('113.3') - 10) - (BigDecimal('3.3') - BigDecimal('0.29'))) + # (113.3 - 10) - (3.3 - 0.29) + expect(total).to eq 100.29 end end end