You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src_amount = '2306.56' // USD you need to convert
var ratio = 1.23 ; // exchange ratio USD=>EUR
var src = Money['USD'];
var src_len = src.decimal_digits;
var dst = Money['EUR'];
var dst_len = dst.decimal_digits;
var subunitDifference = src_len - dst_len;
ratio = ratio / Math.pow(10, subunitDifference);
var src_amt = Money.fromDecimal(src_amount, 'USD' , Math.ceil);
var counterValue = src_amt.multiply(ratio, Math.ceil);
var dst_amt = new Money(counterValue.getAmount(), 'EUR');
maybe we could add a CurrencyConverter implementation that would expose a method like this var currencyConverter = new CurrencyConverter(); var target = currencyConverter.convert(source, ratio);
Is there a built-in mechanism for currency conversion arithmetics?
The text was updated successfully, but these errors were encountered: