I have made a custom sales invoice format for my company. I have generated an e invoice for one of my sales invoice. I am trying to get the e-invoice details (IRN, Ack No., Ack Date and QR code) on my custom format but I couldn’t these options in the print format builder except for IRN. I want the QR code on my custom print format. How do I do that ? please help.
This code might help you.
To generate QR Code
{% if doc.irn %}
{% set e_invoice_log = frappe.db.get_value("e-Invoice Log", doc.irn, ("signed_qr_code"), as_dict=True) %}
<img src=data:image/png;base64,{{ get_qr_code(e_invoice_log.signed_qr_code, scale=2) }} style= "float: right; width: 175px;" >
{% endif %
to get other fields of E-Invoice
{% if doc.irn %}
{% set e_invoice_log = frappe.db.get_value("e-Invoice Log", doc.irn, ("invoice_data"), as_dict=True) %}
{%- set invoice_data = _dict(json.loads(e_invoice_log.invoice_data)) -%}
{%
set transaction_details = {
"IRN": invoice_data.Irn,
"Ack. No": invoice_data.AckNo,
"Ack. Date": frappe.utils.format_datetime(
invoice_data.AckDt, "dd/MM/yyyy hh:mm:ss"
),
}
%}
{% for key, value in transaction_details.items() %}
<div class="row data-field">
<div class="col-xs-4"><label>{{ key }}</label></div>
<div class="col-xs-8 value">{{ value }}</div>
</div>
{% endfor %}
{% endif %}
Or you can simply use the E invoice print format which is preloaded on another sheet.
2 Likes
Thanks a lot. it works !!!
How can I edit the E-Invoice print format already available? When I try to duplicate it and edit it defaults back to the usual format without the QR code. I just need to add a couple of fields to the item table of the e-invoice print format
If Developer Mode is enabled on your site.
Then you edit the existing E-Invoice print format