Hello Community… I have a customer print format that is currently working well, but i would like to display the customer outstanding balance on the invoice and also print the accumulated customer Loyalty Points on the invoice. I have pulled from the tabSales Invoice the " loyalty_points" Field but it outputs zero. Also the “Outstanding_amount” prints the current invoice amount. See my code for the print format below.
indent preformatted text by 4 spaces
{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
{% if letter_head and not no_letterhead %}
<div class="letter-head">{{ letter_head }}</div>
{% endif %}
{%- if doc.meta.is_submittable and doc.docstatus==0-%}
<div class="alert alert-info text-center">
<h4 style="margin: 0px;">{{ _("PROFORMA") }}</h4></div>
{%- endif -%}
{%- if doc.meta.is_submittable and doc.docstatus==2-%}
<div class="alert alert-danger text-center">
<h4 style="margin: 0px;">{{ _("CANCELLED") }}</h4></div>
{%- endif -%}
{% if max_pages > 1 %}
<p class="text-right">{{ _("Page #{0} of {1}").format(page_num, max_pages) }}</p>
{% endif %} {%- endmacro -%}
{{ add_header(0,1,doc,letter_head, no_letterhead) }}
<table class="table table-bordered">
<tbody>
<tr>
<th width=50%>Customer Details</th>
<th width=50%><b>Invoice#: {{doc.name}} Details </b></th>
</tr>
<tr>
<td>{{ doc.customer }}<br>
{{ doc.address_display or '' }}</td>
<td>INVOICE #: {{doc.name}} <br>
{% set u = frappe.get_doc("User", frappe.user) %}
INVOICE DATE: {{ doc.get_formatted("posting_date") or '' }}<br>
DUE DATE: {{ doc.get_formatted("due_date") or '' }}<br>
PREPARED BY :<b>{{ u.first_name }} {{ u.last_name }}</b><br>
<b>{{frappe.session.user}}</b>
</td>
</tr>
</tbody>
</table>
<table class="table table-bordered">
<tbody>
<tr>
<th>No</th>
<th>Item Code</th>
<th>Description</th>
<th class="text-right">Qty</th>
<th class="text-right">Rate</th>
<th class="text-right">Amount</th>
</tr>
{%- for row in doc.items -%}
<tr>
<td style="width: 3%;">{{ row.idx }}</td>
<td style="width: 20%;">
{{ row.item_code}}
</td>
<td style="width: 37%;">
<div style="border: 0px;">{{ row.description }}</div></td>
<td style="width: 10%; text-align: right;">{{ row.qty }} {{ row.uom or row.stock_uom }}</td>
<td style="width: 15%; text-align: right;">{{
row.get_formatted("rate", doc) }}</td>
<td style="width: 15%; text-align: right;">{{row.get_formatted("amount",doc) }}</td>
</tr>
{%- endfor -%}
<TR>
<TD colspan=4 rowspan=3>
Amount in Words<br>
<B>{{ doc.base_in_words }}</B>
</TD>
<TD WIDTH=15% align=right><B>SUB TOTAL</B></TD>
<TD WIDTH=15% align=right><B>{{ doc.get_formatted("total", doc) }}</B></TD>
</TR>
<TR>
<TD align=right><B>VAT</B></TD>
<TD WIDTH=20% align=right><B>{{ doc.get_formatted("total_taxes_and_charges", doc) }}</B></td>
</tr>
<tr>
<td align=right><b>TOTAL</b></td>
<td WIDTH=15% align=right><B>{{ doc.get_formatted("grand_total", doc) }}</b></td>
</tr>
</tbody>
</table>
<table class="table table-bordered">
<tbody>
<tr>
<th>Sales Person</th>
<th width=25%>Invoice Amount</th>
<th>Total Outstanding</th>
<th>Loyalty Point</th>
</tr>
<tr>
<td>{%- for row in doc.sales_team -%}
{{ row.sales_person }}<br>
{%- endfor -%}</td>
<td>{{ doc.get_formatted("grand_total", doc) }}</td>
<td></td>
<td>{{doc.loyalty_points}} {{doc.loyalty_amount}}{{doc.redeem_loyalty_points}}</td>
</tr>
</tbody>
</table>
<table class="table table-bordered">
<tbody>
<tr>
<th>Terms and Conditions</th>
</tr>
<tr><td>{{ doc.terms or '' }}</td></tr>
</tbody>
</table>