Billing General Invoices

{% set total_invoices_orig = 0 %} {% set total_invoices_markup = 0 %} {% set total_invoices_profit = 0 %} {% set total_markup = 0 %} {% set total_profit = 0 %} {% for res in billing_invoices %} {% set total_invoices_orig = total_invoices_orig + res['orig_total'] %} {% set total_invoices_markup = total_invoices_markup + res['markup_total'] %} {% set total_invoices_profit = total_invoices_profit + (res['markup_total'] - res['orig_total']) %} {% set total_markup = total_markup + res['markup_total'] %} {% set total_profit = total_profit + (res['markup_total'] - res['orig_total']) %} {% endfor %}
Sales Item Orig ex Vat MA ex Vat Profit ex Vat
{{ res['sales_code'] }} R {{ res['orig_total']|number_format(2, '.', ' ') }} R {{ res['markup_total']|number_format(2, '.', ' ') }} R {{ (res['markup_total'] - res['orig_total'])|number_format(2, '.', ' ') }}
R {{ total_invoices_orig|number_format(2, '.', ' ')}} R {{ total_invoices_markup|number_format(2, '.', ' ') }} R {{ total_invoices_profit|number_format(2, '.', ' ') }}
{% if total_markup != 0 %}

Gross Profit Margin: {{ ((total_profit/total_markup)*100)|number_format(2, '.', ' ') }} %

{% else %}

Gross Profit Margin: CALC ERROR

{% endif %}