Hi Everyone I currently have an auto cash sale scr...
# suitescript
k
Hi Everyone I currently have an auto cash sale script that is triggered based on item fulfillment. The script generate a cash sale based on the items being fulfilled while attaching the corresponding discount to them. I have issue where when I do multiple partial fulfillment, my cash sale has a rounding error of 1 cent on the taxes, does anyone have any suggestion on what to do?
e
Use a third-party library like https://mikemcl.github.io/bignumber.js/ or similar for handling all your currency/floating point calculations in order to avoid IEEE rounding
m
Even without floating point issues you can run into rounding errors like this. If total tax for an order is $10 and you try to divide that amount evenly across three items, the sum of the lines will be off by .01. When performing this kind of logic, I usually calculate the sum of the lines and compare it to the original amount and add the difference to the last updated line on the transaction.
k
^