{% macro state_badge(state) -%} {{ t({'draft': 'Draft', 'posted': 'Posted', 'cancelled': 'Cancelled', 'proforma': 'Issued', 'converted': 'Converted'}.get(state, state)) }} {%- endmacro %} {% macro pay_badge(ps) -%} {% if ps %}{{ t({'paid': 'Paid', 'partial': 'Partially paid', 'not_paid': 'Not paid'}[ps]) }}{% endif %} {%- endmacro %} {% macro order_badge(state, kind) -%} {% set labels = {'draft': 'Quotation' if kind == 'sale' else 'Draft PO', 'to_approve': 'Waiting Approval', 'confirmed': 'Sales Order' if kind == 'sale' else 'Purchase Order', 'cancelled': 'Cancelled'} %} {{ t(labels.get(state, state)) }} {%- endmacro %} {% macro progress_badge(st) -%} {% if st %}{{ t({'full': 'Fully', 'partial': 'Partially', 'no': 'Nothing yet'}[st]) }}{% endif %} {%- endmacro %} {% macro picking_badge(state) -%} {{ t({'ready': 'Ready', 'done': 'Done', 'cancelled': 'Cancelled'}[state]) }} {%- endmacro %} {% macro list_filters(f, states, extra='') -%}
{{ extra }} {% for k, v in kept_args('q', 's', 'g', 'date_from', 'date_to', 'state', 'payment' if extra else '') %}{% endfor %} {% if f.fields %} {% set fl = [["", t("Any field")]] %}{% for k, l in f.fields %}{% set _ = fl.append([k, t(l)]) %}{% endfor %} {% else %}{% endif %} {% set favs = favorites_here() %}
★ {{ t('Favorites') }}{% if favs %} {{ favs|length }}{% endif %}
{% for fv in favs %} {% else %}

{{ t('No saved searches yet.') }}

{% endfor %}
{% for fv in favs %}{% endfor %} {%- endmacro %} {% macro branch_tag(branches, bid) -%} {% set b = branches.get(bid) %}{{ b.code if b else bid }} {%- endmacro %} {% macro report_filters(f, show_group=True, extra=None) -%}
{% for b in nav_branches %} {% endfor %}
{% if f.need_from %}{% endif %} {% if extra %}{{ extra }}{% endif %} {% if show_group %}{% endif %} {{ export_buttons() }}
{%- endmacro %} {% macro wf_badge(state) -%} {% set cls = {'draft': 'draft', 'submitted': 'warn', 'approved': 'posted', 'done': 'posted', 'rejected': 'cancelled', 'cancelled': 'cancelled', 'sent': 'warn', 'awarded': 'posted', 'running': 'posted', 'closed': 'draft', 'disposed': 'cancelled', 'invited': 'draft', 'quoted': 'posted', 'declined': 'cancelled', 'prospect': 'warn', 'blocked': 'cancelled', 'award_pending': 'warn'} %} {% set lbl = {'draft': 'Draft', 'submitted': 'Waiting Approval', 'approved': 'Approved', 'done': 'Done', 'rejected': 'Rejected', 'cancelled': 'Cancelled', 'sent': 'Sent', 'awarded': 'Awarded', 'running': 'Running', 'closed': 'Fully Depreciated', 'disposed': 'Disposed', 'invited': 'Invited', 'quoted': 'Quoted', 'declined': 'Declined', 'prospect': 'Prospect', 'blocked': 'Blocked', 'award_pending': 'Award waiting approval'} %} {{ t(lbl.get(state, state)) }} {%- endmacro %} {% macro icon(name, cls='ic') -%}{%- endmacro %} {% macro attachments_card(model, rid) -%} {% set files = attachments_for(model, rid) %}

{{ icon('clip') }}{{ t('Attachments') }} {{ files|length or '' }}

{{ t('Supplier bill, receipts, contracts or any supporting document. PDF, images, Word, Excel — up to 15 MB each.') }}
{% if files %} {% endif %} {% if can_write %}
{% elif not files %}

{{ t('No attachments.') }}

{% endif %}
{{ chatter(model, rid) }} {%- endmacro %} {% macro chatter(model, rid) -%} {% set log = chatter_for(model, rid) %}

{{ t('Notes & history') }} {{ log|length or '' }}

{% if can_write %}
{% endif %}
{%- endmacro %} {# cost centre picker on a document header; shown only when cost centres exist #} {% macro cost_centre_field(cost_centres, value, help=None) %} {% if cost_centres %}
{% if help %}
{{ help }}
{% endif %}
{% endif %} {% endmacro %} {# project on a document header; only when the Projects module is licensed. Options follow the branch select #} {% macro project_field(projects, value, help=None) %} {% if has('projects') and projects %}
{% if help %}
{{ help }}
{% endif %}
{% endif %} {% endmacro %} {# vendors to invite: search, add every approved vendor of a category, clear #} {% macro vendor_picker(vendors, selected) %} {% set cats = vendors|map(attribute='vendor_category')|select|unique|sort %}
{% if cats %} {% endif %}
{% for v in vendors %}{% endfor %}
{% endmacro %} {# report filter: all lines, one cost centre, or lines without one (?cc=none) #} {% macro cost_centre_select(cost_centres, cc) %} {% if cost_centres %}{% endif %} {% endmacro %} {# chart of accounts levels on reports; shown once accounts are grouped #} {% macro level_select(level, levels) %} {% if levels and levels > 1 %}{% endif %} {% endmacro %} {# indentation of a report row nested under its groups #} {% macro indent(r) %}{% if r.depth is defined %} style="padding-inline-start: {{ 14 + 20 * (r.depth - 1 + (1 if r.level == 2 else 0)) }}px"{% endif %}{% endmacro %} {# PDF / Excel / CSV / Print buttons inside a GET form; the view answers ?export= (see exports.respond) #} {% macro export_buttons() %} {% endmacro %} {# the same buttons as links, for pages without a filter form #} {% macro export_links() %} {% for v, lbl, ic in (('pdf', 'PDF', 'file'), ('xlsx', 'Excel', 'grid'), ('csv', 'CSV', none), ('print', t('Print'), 'receipt')) %} {% if ic %}{{ icon(ic) }}{% endif %}{{ lbl }} {% endfor %} {% endmacro %} {# PDF and Print for a single document (voucher, payslip...) #} {% macro doc_export() %} {{ icon('file') }}PDF {{ icon('receipt') }}{{ t('Print') }} {% endmacro %} {# approval workflow on a document: the steps with each approver's decision, the history, and the decision form for whoever's turn it is (an administrator may decide in place of the approvers, with a reason) #} {% macro approval_panel(doc_type, doc_id, approve_url, reject_url) %} {% set a = approval_status(doc_type, doc_id) %} {% if a %}

{{ t('Approval') }}

{{ t({'pending': 'Waiting for approval', 'approved': 'Approved', 'rejected': 'Rejected', 'cancelled': 'Withdrawn'}[a.req.state]) }} {% if a.rule %}{{ t('Rule') }}: {{ a.rule.name }}{% endif %}
    {% for s in a.steps %}
  1. {{ s.step.step_no }}
    {{ s.step.name or (t('Step') ~ ' ' ~ s.step.step_no) }} {% if s.role %}{{ nm(s.role) }} · {% endif %}{{ t('all approvers') if s.step.mode == 'all' else (s.step.required ~ ' ' ~ t('of') ~ ' ' ~ (s.tasks|length or '—')) }}
    {% for tk in s.tasks %}{{ tk.full_name or tk.username }}{% if tk.state == 'approved' %} ✓{% elif tk.state == 'rejected' %} ✕{% endif %}{% endfor %}
  2. {% endfor %}
{% if a.can_act or a.can_override %}
{% if not a.can_act %}{% endif %}
{% endif %}
{{ t('History') }} ({{ a.history|length }}) {% for e in a.history %}{% endfor %}
{{ e.at[:16]|replace('T', ' ') }}{{ e.full_name or e.username or t('System') }} {{ t({'submitted': 'Submitted', 'approved_step': 'Approved', 'rejected': 'Rejected', 'approved': 'Fully approved', 'cancelled': 'Withdrawn', 'override_approve': 'Approved in place of the approvers', 'override_reject': 'Rejected in place of the approvers'}.get(e.action, e.action)) }}{% if e.step_no %} · {{ t('Step') }} {{ e.step_no }}{% endif %}{{ e.comment or '' }}
{% endif %} {% endmacro %} {# terms & conditions: pick a standard text (fills the box) and edit it for this document #} {% macro terms_field(doc_type, value, is_new) %} {% set opts = terms_for(doc_type) %}
{% set dflt = (opts|selectattr('is_default')|first) if is_new else none %}
{% endmacro %}