mapBraintreeMoneyToCommercetoolsMoney accepts a string amount and number of fraction digits.
It gives the expected output for most of the numbers, but doesn't work correctly for some other numbers.
Example input -
amount = 65.32
fractionDigits = 2
Expected output = 6532
Actual output = 6531.999999999999
I don't have any other number as of now for which I am not getting expected output but it may happen that when expected output is XXXX, the function returns XXXX.00000000001. Hence the new logic should support both the cases i.e. rounding up & down as applicable in that case.
Also, if possible, it will be good to have a unit test just testing this function and mapCommercetoolsMoneyToBraintreeMoney function with an array of combinations of amount and fractionDigits.
mapBraintreeMoneyToCommercetoolsMoney accepts a string amount and number of fraction digits. It gives the expected output for most of the numbers, but doesn't work correctly for some other numbers. Example input - amount = 65.32 fractionDigits = 2 Expected output = 6532 Actual output = 6531.999999999999
I don't have any other number as of now for which I am not getting expected output but it may happen that when expected output is XXXX, the function returns XXXX.00000000001. Hence the new logic should support both the cases i.e. rounding up & down as applicable in that case.
Also, if possible, it will be good to have a unit test just testing this function and mapCommercetoolsMoneyToBraintreeMoney function with an array of combinations of amount and fractionDigits.