{# Shared reconciliation table helpers. fmt(v) — format one cell: integers with thousands separators, other numbers to 2dp, everything else verbatim (blank for null). render_table(t) — a plain {columns, rows} table rendered with fmt(). drill_table(...) — like render_table, but the cell in `key_col` becomes a link to `link_base?param=` (segment → explorer drill-down, or a key → single-loan link). #} {% macro fmt(v) -%} {%- if v is integer -%}{{ "{:,}".format(v) }}{%- elif v is number -%}{{ "{:,.2f}".format(v) }}{%- else -%}{{ v if v is not none else "" }}{%- endif -%} {%- endmacro %} {% macro render_table(table) %}
{% for c in table.columns %}{% endfor %} {% for row in table.rows %} {% for c in table.columns %}{% endfor %} {% endfor %}
{{ c }}
{{ fmt(row[c]) }}
{% endmacro %} {# `extra_qs` (optional) is appended verbatim to each drill link (e.g. "&hide_immaterial=1"), so a segment drill can carry the page's active toggles into the explorer. Default "" leaves existing callers unchanged. #} {% macro drill_table(table, key_col, link_base, param, extra_qs="") %}
{% for c in table.columns %}{% endfor %} {% for row in table.rows %} {% for c in table.columns %} {% endfor %} {% endfor %}
{{ c }}
{% if c == key_col and row[c] is not none %}{{ fmt(row[c]) }}{% else %}{{ fmt(row[c]) }}{% endif %}
{% endmacro %} {# drill_table2(...) — like drill_table, but the `key_col` cell drills the explorer pre-filtered on TWO dimensions: param_a=row[col_a] and param_b=row[col_b] (e.g. a class×method row narrowing to both its exposure class and its methodology). `extra_qs` behaves as in drill_table. #} {% macro drill_table2(table, key_col, link_base, param_a, col_a, param_b, col_b, extra_qs="") %}
{% for c in table.columns %}{% endfor %} {% for row in table.rows %} {% for c in table.columns %} {% endfor %} {% endfor %}
{{ c }}
{% if c == key_col and row[c] is not none %}{{ fmt(row[c]) }}{% else %}{{ fmt(row[c]) }}{% endif %}
{% endmacro %}