Try ERPNext Try Frappe Cloud Buy Support Partners Foundation

Print Payment Entry on check with address for mailing

This is a pretty basic need for an accounting system, but most of the forum posts on subject are from 4 or more years ago. Thus, would appear is solved but we have not accomplished.

Objective from payment entry have print format will put information on 3 part check stock as follows:

  • basic check info (already working)
  • supplier billing address in envelope window location (see below issue)
  • detail of paid amount allocation to supplier invoices on second and third page sections

Have created Jinja custom print format and have information from Payment Entry appearing where it should. Cannot get address. Have tried many combinations of filters and even though we can see record in database it is returning nothing. Here is last attempt:

 {% set addressLine1 = frappe.db.get_value('Address', { 'address_title': doc.party_name, 'is_primary_address': 1  }, "address_line1") %}
        {{ addressLine1 or '' }}

As this is not a specific need for us, would be great if could be generated with information above from the convenient Cheque Print Template tool included with check marks to select desired information and number of parts in check stock (1, 2 or 3)

ERPNext: v12.12.1 (version-12)
Frappe Framework: v12.10.2 (version-12)

Finally had some time to work on this and below instructions for printing on three (3) part check paper with address and detail of allocation. Probably not most elegant way, but better than the non-existent alternative provided as standard. Suggestions are welcome.

To accomplish requires 3 steps:
1 - create custom field (we used read only type) in Payment Entry doctype. We called address_display, but can use anything you want as long as matches custom script and custom print format
2 - include in Payment Entry custom script following function which is called on load and on change:

function AddressDisplay(cur_frm)
{
    frappe.call({
        method: "erpnext.accounts.party.get_party_details",
        args:{'party':cur_frm.doc.party,'party_type':cur_frm.doc.party_type},
        callback: function(ret) {
            if(ret)
            {
                cur_frm.set_value("address_display",ret.message.address_display);
        	}
        }
   });

3 - here is Jinja custom format Print Format, don’t know why copy paste worked this time in maintaining indents:

.print-format {
	padding: 0px;
}
@media screen {
	.print-format {
		padding: 0in;
	}
}
	<span style="top:15.5cm; left:1.5cm;
		border-bottom: solid 0px;border-top:solid 0px; width:14cm;text-align: LEFT; position: absolute;">
        {%- if (doc.total_allocated_amount == paid_amount) -%}
        {%- endif -%}
	</span>
	<span style="top:0.5cm; left:15.9cm;
		position: absolute;">
		{{ frappe.utils.formatdate(doc.reference_date,'yyyy-MMM-dd') or '' }}
	</span>
	<span style="top:1.8cm;left: 1.0cm;
		position: absolute;  min-width: 6cm;">
		{{ doc.party_name }}
	</span>
	<span style="top:4.0cm;left:1.5cm;
		position: absolute;  min-width: 6cm;">
		{{ doc.account_no or '' }}
	</span>
	<span style="top:3.8cm;left: 1.0cm;
		position: absolute;  min-width: 6cm;">
	    {{ doc.party_name }}
	    <br>
		{{ doc.address_display }}
    </span>
	<span style="top:6.2cm;left:0.8cm;position: absolute;  min-width: 6cm;">
		{{ frappe.db.get_value("Supplier", doc.party_name, "pan") or '' }}
	</span>
	<span style="top:2.6cm; left:0.1cm;
		position: absolute; display: block; width: 15.0cm;
		line-height:0.5cm; word-wrap: break-word;">
			{{ frappe.utils.money_in_words(doc.paid_amount) }}
	</span>
	<span style="top:1.8cm;left: 16.2cm;
		position: absolute; min-width: 4cm;">
		{{ "{:,.2f}".format(doc.paid_amount) }}
	</span>
	<span style="top:8.6cm; left:1.0cm;
		position: absolute;">
		PAID TO: 	{{ doc.party_name }}
	</span>
	<span style="top:8.6cm; left:7.0cm;
		position: absolute;">
		CHECK DATE: {{ frappe.utils.formatdate(doc.reference_date,'yyyy-MMM-dd') or '' }}
	</span>
	<span style="top:8.6cm; left:13.0cm;
		position: absolute;">
		CHECK AMOUNT: 	{{ "${:,.2f}".format(doc.paid_amount) }}
	</span>
	<span style="top:9.2cm;left: 1.0cm;
		position: absolute; min-width: 6.5in;">
	    <table style="table-layout:fixed;"><tr>
	        <th style="width:2.0in;text-align:left;">No</th>
	        <th style="width:1.5in;text-align:right;">Total</th>
	        <th style="width:1.5in;text-align:right;">Outstanding</th>
	        <th style="width:1.5in;text-align:right;">Allocated</th></tr>
        {%- for row in doc.references -%}
        <tr>
            <td style="text-align:left;">{{ row.bill_no }}</td>
            <td style="text-align:right;">{{ "${:,.2f}".format(row.total_amount) }}</td>
            <td style="text-align:right;">{{ "${:,.2f}".format(row.outstanding_amount) }}</td>
            <td style="text-align:right;">{{ "${:,.2f}".format(row.allocated_amount) }}</td>
        </tr>
        {%- endfor -%}
        {%- if (doc.difference_amount > 0) -%}
        <tr><td  style="text-align:left;" colspan=3>ADVANCE</td><td style="text-align:right;">{{ "${:,.2f}".format(row.difference_amount) }}</td></tr>
        {%- endif -%}
        {%- for row in doc.deductions -%}
        <tr>
            <td colspan=3 style="text-align:left;">{{ row.account[6:-8] }}</td>
            <td style="text-align:right;">{{ "${:,.2f}".format(row.amount) }}</td>
        </tr>
        {%- endfor -%}
        </table>
	</span>
	<span style="top:17.5cm; left:1.0cm;
		position: absolute;">
		PAID TO: 	{{ doc.party_name }}
	</span>
	<span style="top:17.5cm; left:7.0cm;
		position: absolute;">
		CHECK DATE: {{ frappe.utils.formatdate(doc.reference_date,'yyyy-MMM-dd') or '' }}
	</span>
	<span style="top:17.5cm; left:13.0cm;
		position: absolute;">
		CHECK AMOUNT: 	{{ "${:,.2f}".format(doc.paid_amount) }}
	</span>
	<span style="top:18.1cm;left: 1.0cm;
		position: absolute; min-width: 6.5in;">
	    <table style="table-layout:fixed;"><tr>
	        <th style="width:2.0in;text-align:left;">No</th>
	        <th style="width:1.5in;text-align:right;">Total</th>
	        <th style="width:1.5in;text-align:right;">Outstanding</th>
	        <th style="width:1.5in;text-align:right;">Allocated</th></tr>
        {%- for row in doc.references -%}
        <tr>
            <td style="text-align:left;">{{ row.bill_no }}</td>
            <td style="text-align:right;">{{ "${:,.2f}".format(row.total_amount) }}</td>
            <td style="text-align:right;">{{ "${:,.2f}".format(row.outstanding_amount) }}</td>
            <td style="text-align:right;">{{ "${:,.2f}".format(row.allocated_amount) }}</td>
        </tr>
        {%- endfor -%}
        {%- if (doc.difference_amount > 0) -%}
        <tr><td  style="text-align:left;" colspan=3>ADVANCE</td><td style="text-align:right;">{{ "${:,.2f}".format(row.difference_amount) }}</td></tr>
        {%- endif -%}
        {%- for row in doc.deductions -%}
        <tr>
            <td colspan=3 style="text-align:left;">{{ row.account[6:-8] }}</td>
            <td style="text-align:right;">{{ "${:,.2f}".format(row.amount) }}</td>
        </tr>
        {%- endfor -%}
        </table>
	</span>

Solution is actually not a solution as when frappe generates pdf it pulls data from database not from form on client screen so the displayed address (which is not in db for the payment entry doctype) is not there to put on check.

Ended up going this way, because many hours trying variants of frappe.db.get_value("[doctype]", “[name]”, “fieldname”) to pull address from another doctype (not payment entry) all failed. Looks like back to square 1 and trying again with get_value.

The allocation table for 3 part checks works very well.