Hello! Is it possible to print customer name in POS apart from the offline_pos_name? If yes, what tag should i use to display it?
Based on the standard POS Print Format, Customer Name is fetched from standard Sales Invoice field i.e. customer_name.
@umair
This is for POS invoice. What i’m using as a template is the Point of Sale print format which is for the offline POS mode.
I tried {{ doc.customer_name }} and it does not work.
Had any success with the customer name?
I tried {{ customer_name }} maintaining the format with the other fields but when I tried to print it gave me a format template error in developer console, Is there a reference for JS print format?
I am sharing my code incase anyone spots an error.
<style>
.print-format table, .print-format tr,
.print-format td, .print-format div, .print-format p {
font-family: Monospace;
line-height: 200%;
vertical-align: middle;
}
@media screen {
.print-format {
width: 4in;
padding: 0.25in;
min-height: 8in;
}
}
</style>
<p class="text-center">
<b>{{ __("Company Name String") }}</b><br>
<small>{{ __("Address String") }}</small><br>
{{ __("Mobile: +AA XXXXX YYYYY") }}<br>
{{ __("GSTN: XXXXXXXXXXXXXXXXX") }}<br>
{{ __("FSSAI: YYYYYYYYYYYYYYYY") }}<br>
</p>
<br>
<p>
<b>{{ __("Receipt No") }}:</b> {{ name }}<br>
<b>{{ __("Customer") }}:</b> {{ customer_name }}<br>
<b>{{ __("Date") }}:</b> {{ dateutil.global_date_format(posting_date) }}<br>
</p>
<table class="table table-condensed cart no-border">
<thead>
<tr>
<th width="50%">{{ __("Item") }}</b></th>
<th width="25%" class="text-right">{{ __("Qty") }}</th>
<th width="25%" class="text-right">{{ __("Amount") }}</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td>{{ item.item_name }}</td>
<td class="text-right">{{ format_number(item.qty, null,precision("difference")) }}</td>
<td class="text-right">{{ format_currency(item.amount, currency) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<table class="table table-condensed no-border">
<tbody>
<tr>
<td class="text-right" style="width: 75%">
<b>{{ __("Total") }}</b>
</td>
<td class="text-right">
{{ format_currency(grand_total, currency) }}
</td>
</tr>
</tbody>
</table>
<hr>
<p class="text-center"><small>{ __("*All prices are inclusive of GST") }}</small></p>
I am still experimenting, if i get it working, I will share my results
Did this worked?
Hi @avaiskhatri , Its been too long I cant remember if it did. In the current version you can create POS print formats with Jinja
I tried calling customer name using this:
{{ frappe.db.get_value(“Customer”, {‘name’: customer }, “customer_name” ) }}
But this is returning: [object Object]
I fixed this issue by adding a line
erpnext/erpnext/accounts/page/pos/pos.js
from this
if(this.si_docs.length) {
this.si_docs.forEach(function (data, i) {
for (var key in data) {
html += frappe.render_template("pos_invoice_list", {
sr: i + 1,
name: key,
customer: data[key].customer,
paid_amount: format_currency(data[key].paid_amount, me.frm.doc.currency),
grand_total: format_currency(data[key].grand_total, me.frm.doc.currency),
data: me.get_doctype_status(data[key])
});
}
});
}
to this
if(this.si_docs.length) {
this.si_docs.forEach(function (data, i) {
for (var key in data) {
html += frappe.render_template("pos_invoice_list", {
sr: i + 1,
name: key,
customer: data[key].customer,
customer_name: data[key].customer_name,
paid_amount: format_currency(data[key].paid_amount, me.frm.doc.currency),
grand_total: format_currency(data[key].grand_total, me.frm.doc.currency),
data: me.get_doctype_status(data[key])
});
}
});
}
in print format:
{{ customer_name }}
Great work!!