Skip to content

Report parameters

Gil Cleber Barboza edited this page Nov 12, 2026 · 1 revision

Report parameters

Declarative behavior — the document adapts to the data, no rigid bands.

Aggregations

"aggregate": "sum|count|avg|min|max" on a field definition computes totals over sibling rows:

  • group footers (per parent group),
  • tfoot on detail tables,
  • grand summary section.
"total": {"label": "Total", "format_mask": "float", "alignment": "right", "aggregate": "sum"}

Unknown functions raise ValueError. Empty sets render nothing (no zero-noise).

Running balance

"running_balance": "<source field>" fills a cumulative column in row order (bank statements). With opening balance:

"balance": {"label": "Balance", "format_mask": "float", "alignment": "right",
            "running_balance": {"of": "amount", "start": 1000}}

Non-numeric source values count as zero; input rows are never mutated. Invalid specs raise ValueError.

Row filtering — $print_when

Keep only matching rows at that level:

"$print_when": {"field": "status", "not_equals": "cancelled"}

Operators: equals, not_equals, in, not_in, gt, gte, lt, lte, is_null, not_null. Unknown operators raise ValueError.

Sorting — $order_by

"$order_by": [{"field": "date", "direction": "asc"}, {"field": "total", "direction": "desc"}]
"$order_by": "-total"   # shorthand: "field" = asc, "-field" = desc

Null values always sort last. Stable for multiple keys.

Column visibility

"internal_code": {"label": "Code", ..., "visible": False}
"discount": {"label": "Discount", ..., "visible_when": {"field": "discount", "not_equals": 0}}

visible_when supports "scope": "any" (default, hide unless some row matches) or "all".

Page setup — meta.page

"meta": {"page": {"size": "A4", "orientation": "landscape", "margins": {"top": ".4in"}}}

Maps to page.pdf (format, landscape, margin); explicit pdf_options win. Invalid orientation raises ValueError.

Clone this wiki locally