FormulaNode
ResponseA parsed billing formula: the JSON tree a formula text converts to, and back (parseBillingFormula; the parser is open source as tracken-billing-formula). Nodes: {op: literal, value} (the number as a decimal string, e.g. "2.5"), {op: ref, scope: var|prop|consumption|sys|invoice|line, code}, {op: neg, args: [x]}, {op: add|sub|mul|div, args: [a, b]} (left-associative, * and / bind tighter), {op: call, func: round|min|max, args: [...]} (round(x, digits) takes a whole-number literal as digits; see getBillingFormulaCatalog for the limits), {op: sum_objects, args: [x]} (only in an allocation's total), {op: sum_lines, args: [x]} (only in a formula over a purchase invoice, where invoice. and, inside it, line. references read the invoice). At most 64 levels deep. Comparison nodes lt/le/gt/ge/eq/ne mean < / <= / > / >= / = / <> and return a number, 1 or 0, usable anywhere a number is accepted. Comparisons bind looser than arithmetic. The if call takes condition, then, else; nonzero is true and only the selected branch is evaluated.
Returned in responses. Its enums are open: tolerate values not listed here, which later versions may add.
Attributes
6Node kind. New values may be added: treat a value you do not know as valid, not as an error.
Known values (open: expect new ones) literal, ref, neg, add, sub, mul, div, call, sum_objects, sum_lines, lt, le, gt, ge, eq, ne
For literal, the number as a decimal string (never negative; a minus is a neg node).
For ref, what it refers to. New values may be added: treat a value you do not know as valid, not as an error.
Known values (open: expect new ones) var, prop, consumption, sys, invoice, line
For call, the function. New values may be added: treat a value you do not know as valid, not as an error.
Known values (open: expect new ones) round, min, max, if
Operands.
6 attributes of each item
Node kind. New values may be added: treat a value you do not know as valid, not as an error.
Known values (open: expect new ones) literal, ref, neg, add, sub, mul, div, call, sum_objects, sum_lines, lt, le, gt, ge, eq, ne
For literal, the number as a decimal string (never negative; a minus is a neg node).
For ref, what it refers to. New values may be added: treat a value you do not know as valid, not as an error.
Known values (open: expect new ones) var, prop, consumption, sys, invoice, line
For call, the function. New values may be added: treat a value you do not know as valid, not as an error.
Known values (open: expect new ones) round, min, max, if
Operands.