{{ _(report.report_name) }}

{% if (filters.customer_name) %} {{ filters.customer_name }} {% else %} {{ filters.customer ~ filters.supplier }} {% endif %}

{% if (filters.tax_id) %} {{ _("Tax Id: ") }}{{ filters.tax_id }} {% endif %}
{{ _(filters.ageing_based_on) }} {{ _("Until") }} {{ frappe.format(filters.report_date, 'Date') }}
{% if(filters.payment_terms) %} {{ _("Payment Terms") }}: {{ filters.payment_terms }} {% endif %}
{% if(filters.credit_limit) %} {{ _("Credit Limit") }}: {{ frappe.utils.fmt_money(filters.credit_limit) }} {% endif %}
{% if(filters.show_future_payments) %} {% set balance_row = data.slice(-1).pop() %} {% for i in report.columns %} {% if i.fieldname == 'age' %} {% set elem = i %} {% endif %} {% endfor %} {% set start = report.columns.findIndex(elem) %} {% set range1 = report.columns[start].label %} {% set range2 = report.columns[start+1].label %} {% set range3 = report.columns[start+2].label %} {% set range4 = report.columns[start+3].label %} {% set range5 = report.columns[start+4].label %} {% set range6 = report.columns[start+5].label %} {% if(balance_row) %}
(Amount in {{ data[0]["currency"] ~ "" }})
{{ _(" ") }} {{ _(range1) }} {{ _(range2) }} {{ _(range3) }} {{ _(range4) }} {{ _(range5) }} {{ _(range6) }} {{ _("Total") }}
{{ _("Total Outstanding") }} {{ format_number(balance_row["age"], null, 2) }} {{ frappe.utils.fmt_money(balance_row["range1"], data[data.length-1]["currency"]) }} {{ frappe.utils.fmt_money(balance_row["range2"], data[data.length-1]["currency"]) }} {{ frappe.utils.fmt_money(balance_row["range3"], data[data.length-1]["currency"]) }} {{ frappe.utils.fmt_money(balance_row["range4"], data[data.length-1]["currency"]) }} {{ frappe.utils.fmt_money(balance_row["range5"], data[data.length-1]["currency"]) }} {{ frappe.utils.fmt_money(flt(balance_row["outstanding"]), data[data.length-1]["currency"]) }}
{{ _("Future Payments") }} {{ frappe.utils.fmt_money(flt(balance_row[("future_amount")]), data[data.length-1]["currency"]) }}
{% endif %} {% endif %} {% if(report.report_name == "Accounts Receivable" or report.report_name == "Accounts Payable") %} {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} {% else %} {% endif %} {% if not(filters.show_future_payments) %} {% endif %} {% if not(filters.show_future_payments) %} {% endif %} {% if(filters.show_future_payments) %} {% if(report.report_name == "Accounts Receivable") %} {% endif %} {% endif %} {% else %} {% endif %} {% for i in range(data|length) %} {% if(report.report_name == "Accounts Receivable" or report.report_name == "Accounts Payable") %} {% if(data[i]["party"]) %} {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} {% endif %} {% if not (filters.show_future_payments) %} {% endif %} {% if not(filters.show_future_payments) %} {% endif %} {% if(filters.show_future_payments) %} {% if(report.report_name == "Accounts Receivable") %} {% endif %} {% endif %} {% else %} {% if not(filters.show_future_payments) %} {% endif %} {% if(report.report_name == "Accounts Receivable" and filters.show_sales_person) %} {% endif %} {% if not(filters.show_future_payments) %} {% endif %} {% if(filters.show_future_payments) %} {% if(report.report_name == "Accounts Receivable") %} {% endif %} {% endif %} {% endif %} {% else %} {% if(data[i]["party"] or " ") %} {% if not(data[i]["is_total_row"]) %} {% else %} {% endif %} {% endif %} {% endif %} {% endfor %}
{{ _("Date") }} {{ _("Age (Days)") }}{{ _("Reference") }} {{ _("Sales Person") }}{{ _("Reference") }} {% if (filters.customer or filters.supplier or filters.customer_name) %} {{ _("Remarks") }} {% else %} {{ _("Party") }} {% endif %} {{ _("Invoiced Amount") }}{{ _("Paid Amount") }} {% if report.report_name == "Accounts Receivable" %} {{ _('Credit Note') }} {% else %} {{ _('Debit Note') }} {% endif %} {{ _("Outstanding Amount") }}{{ _("Customer LPO No.") }}{{ _("Future Payment Ref") }} {{ _("Future Payment Amount") }} {{ _("Remaining Balance") }} {% if (filters.customer or filters.supplier or filters.customer_name) %} {{ _("Remarks")}} {% else %} {{ _("Party") }} {% endif %} {{ _("Total Invoiced Amount") }} {{ _("Total Paid Amount") }} {% if report.report_name == "Accounts Receivable Summary" %} {{ _('Credit Note Amount') }} {% else %} {{ _('Debit Note Amount') }} {% endif %} {{ _("Total Outstanding Amount") }}
{{ (data[i]["posting_date"]) }} {{ data[i]["age"] }} {% if not(filters.show_future_payments) %} {{ data[i]["voucher_type"] }}
{% endif %} {{ data[i]["voucher_no"] }}
{{ data[i]["sales_person"] }} {% if(not(filters.customer or filters.supplier or filters.customer_name)) %} {{ data[i]["party"] }} {% if(data[i]["customer_name"] and data[i]["customer_name"] != data[i]["party"]) %}
{{ data[i]["customer_name"] }} {% elif(data[i]["supplier_name"] != data[i]["party"]) %}
{{ data[i]["supplier_name"] }} {% endif %} {% endif %}
{% if data[i]["remarks"] %} {{ _("Remarks") }}: {{ data[i]["remarks"] }} {% endif %}
{{ frappe.utils.fmt_money(data[i]["invoiced"], currency=data[i]["currency"]) }} {{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }} {{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }} {{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }} {{ data[i]["po_no"] }}{{ data[i]["future_ref"] }} {{ frappe.utils.fmt_money(data[i]["future_amount"], currency=data[i]["currency"]) }} {{ frappe.utils.fmt_money(data[i]["remaining_balance"], currency=data[i]["currency"]) }} {{ _("Total") }} {{ frappe.utils.fmt_money(data[i]["invoiced"], data[i]["currency"]) }} {{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }} {{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }} {{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }} {{ data[i]["po_no"] }}{{ data[i]["future_ref"] }} {{ frappe.utils.fmt_money(data[i]["future_amount"], currency=data[i]["currency"]) }} {{ frappe.utils.fmt_money(data[i]["remaining_balance"], currency=data[i]["currency"]) }} {% if(not(filters.customer | filters.supplier)) %} {{ data[i]["party"] }} {% if(data[i]["customer_name"] and data[i]["customer_name"] != data[i]["party"]) %}
{{ data[i]["customer_name"] }} {% elif(data[i]["supplier_name"] != data[i]["party"]) %}
{{ data[i]["supplier_name"] }} {% endif %} {% endif %}
{{ _("Remarks") }}: {{ data[i]["remarks"] }}
{{ _("Total") }}{{ frappe.utils.fmt_money(data[i]["invoiced"], currency=data[i]["currency"]) }} {{ frappe.utils.fmt_money(data[i]["paid"], currency=data[i]["currency"]) }} {{ frappe.utils.fmt_money(data[i]["credit_note"], currency=data[i]["currency"]) }} {{ frappe.utils.fmt_money(data[i]["outstanding"], currency=data[i]["currency"]) }}
{{ frappe.utils.fmt_money(data|sum(attribute="invoiced"), currency=data[0]["currency"]) }} {{ frappe.utils.fmt_money(data|sum(attribute="paid"), currency=data[0]["currency"]) }} {{ frappe.utils.fmt_money(data|sum(attribute="credit_note"), currency=data[0]["currency"]) }} {{ frappe.utils.fmt_money(data|sum(attribute="outstanding"), currency=data[0]["currency"]) }}

{% if ageing %}

{{ _("Ageing Report based on ") }} {{ ageing.ageing_based_on }} {{ _("up to " ) }} {{ frappe.format(filters.report_date, 'Date')}}

30 Days 60 Days 90 Days 120 Days
{{ frappe.utils.fmt_money(ageing.range1, currency=data[0]["currency"]) }} {{ frappe.utils.fmt_money(ageing.range2, currency=data[0]["currency"]) }} {{ frappe.utils.fmt_money(ageing.range3, currency=data[0]["currency"]) }} {{ frappe.utils.fmt_money(ageing.range4, currency=data[0]["currency"]) }}
{% endif %}

{{ _("Printed On ") }}{{ frappe.utils.now() }}