+const balance = (bookingLine) => {
+ let invertedAmount = "None";
+ if (bookingLine.amount !== "None") {
+ invertedAmount = `-${bookingLine.amount}`;
+ const doubleMinus = "--";
+ if (invertedAmount.startsWith(doubleMinus)) {
+ invertedAmount = invertedAmount.slice(doubleMinus.length);
+ }
+ }
+ let balancer = "";
+ const accNameSteps = bookingLine.account.split(":");
+ while (balancer === "") {
+ balancer = accountBalancers[accNameSteps.join(":")];
+ accNameSteps.pop();
+ }
+ return newBookingLine(
+ balancer,
+ invertedAmount,
+ bookingLine.currency,
+ LEN_INDENT_INPUT_BALANCED
+ );
+};
+