+ const centsRound = (amt) => Math.round(FACTOR_CENTS * amt) / FACTOR_CENTS;
+ const signFixed = (amt
+ ) => (-Math.sign(bookingLine.amount) * amt).toFixed(LEN_INVERSION_DECIMAL);
+ Array.from(balancers).forEach(
+ (balancer, idx) => {
+ let amountInput = TOK_NONE;
+ if (partInverted !== TOK_NONE) {
+ if (idx === balancers.length + IDX_LAST) {
+ amountInput = signFixed(centsRound(leftToInvert));
+ } else {
+ const rounded = centsRound(partInverted);
+ leftToInvert -= rounded;
+ amountInput = signFixed(rounded);
+ }
+ }
+ toReturn.push(
+ newBookingLine(
+ balancer,
+ amountInput,
+ bookingLine.currency,
+ LEN_INDENT_INPUT_BALANCED
+ )
+ );
+ }