SPACE = ' '
_INDENT_CHARS = {SPACE, '\t'}
+_SEP_ACCNAME_STEPS = ':'
SEP_COMMENTS = ';'
_PREFIX_INSTRUCTION = '#'
_ACC_MOD_INSTRUCTORS = {'description', 'balancer'}
def path_to_steps(full_path: str) -> Iterator[tuple[str, str]]:
'Split full_path into steps, for each return its path, basename.'
rebuilt_path = ''
- for step_name in full_path.split(':'):
- rebuilt_path += (':' if rebuilt_path else '') + step_name
+ for step_name in full_path.split(_SEP_ACCNAME_STEPS):
+ rebuilt_path += ((_SEP_ACCNAME_STEPS if rebuilt_path else '')
+ + step_name)
yield rebuilt_path, step_name
LEN_EMPTY = 0,
LEN_INDENT_INPUT_BALANCED = 4,
LEN_INDENT_INPUT_DEFAULT = 2,
+ LEN_INDENT_INPUT_MINIMUM = 1,
LEN_INTRO_LINE = 4,
LEN_LEN_INDENT = 1,
LEN_LINE_STEP = 1,
LEN_STEP_INPUT_LEN_INDENT = 1,
LEN_TARGET = 37,
- MINIMUM_INPUT_LEN_INDENT = 1,
+ SEP_ACCNAME_STEPS = ":",
+ TOK_NONE = "None",
accountBalancers = Object.assign(
BALANCERS_DEFAULT,
{{ account_balancers|tojson|safe }}
const newBookingLine = (
account = "",
- amount = "None",
+ amount = TOK_NONE,
currency = "",
lenIndent = LEN_INDENT_INPUT_DEFAULT
) => ({
};
const balance = (bookingLine) => {
- let invertedAmount = "None";
- if (bookingLine.amount !== "None") {
+ let invertedAmount = TOK_NONE;
+ if (bookingLine.amount !== TOK_NONE) {
invertedAmount = `-${bookingLine.amount}`;
const doubleMinus = "--";
if (invertedAmount.startsWith(doubleMinus)) {
}
}
let balancer = "";
- const accNameSteps = bookingLine.account.split(":");
+ const accNameSteps = bookingLine.account.split(SEP_ACCNAME_STEPS);
while (balancer === "") {
- balancer = accountBalancers[accNameSteps.join(":")];
+ balancer = accountBalancers[accNameSteps.join(SEP_ACCNAME_STEPS)];
accNameSteps.pop();
}
return newBookingLine(
LEN_LEN_INDENT
);
indentInput.type = "number";
- indentInput.min = MINIMUM_INPUT_LEN_INDENT;
+ indentInput.min = LEN_INDENT_INPUT_MINIMUM;
indentInput.step = LEN_STEP_INPUT_LEN_INDENT;
const accInput = addTdInput(
"account",
/* not using input[type=number] cuz no minimal step size,
therefore regex test instead */
const amtInputVal =
- bookingLine.amount === "None" ? "" : bookingLine.amount;
+ bookingLine.amount === TOK_NONE ? "" : bookingLine.amount;
const amtInput = addTdInput(
"amount",
amtInputVal,
return;
}
const currency = bookingLine.currency || "€";
- if (bookingLine.amount === "None") {
+ if (bookingLine.amount === TOK_NONE) {
if (sinkAccount === bookingLine.account || !sinkAccount) {
if (!sinkAccount) {
sinkAccount = bookingLine.account;