Skip to content

Commit

Permalink
Merge pull request #2595 from bitzesty/cherrypick-percentage-staging
Browse files Browse the repository at this point in the history
[Staging] - fix float issue when calculating percentage of trade
  • Loading branch information
TheDancingClown authored Sep 11, 2023
2 parents 87efa44 + 851dadd commit 2c219c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/frontend/form-validation.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ window.FormValidation =
totalOverseasTradePercentage += parseFloat($(this).val())
else
missingOverseasTradeValue = true
if totalOverseasTradePercentage != 100
if totalOverseasTradePercentage.toFixed(2) != (100).toFixed(2)
@logThis(question, "validateGoodsServicesPercentage", "% of your total overseas trade should add up to 100")
@appendMessage(question, "% of your total overseas trade should add up to 100")
@addErrorClass(question)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def errors

total = 0
question.answers["trade_goods_and_services_explanations"]&.each do |product|
total += product["total_overseas_trade"].to_i
total += product["total_overseas_trade"].to_f.round(2)
end
if total != 100
result[question.key] ||= {}
Expand Down

0 comments on commit 2c219c8

Please sign in to comment.