I want to customize Sales Invoice Print Format and put all the calculations that are under the Items table in a table and have. But this table will not have title columns.
How can we do this?
Regards,
I want to customize Sales Invoice Print Format and put all the calculations that are under the Items table in a table and have. But this table will not have title columns.
How can we do this?
Regards,
I am using version 13.19.0.
I want to achieve it using Print Format Builder (if possible).
Regards,
Hi @yogeshvachhani,
You can also make a custom print format using HTML with jinja formatting.
Tax and Grand total set in a table like:
eg.
<table style="width:100%;">
<tbody>
<tr style="text-align:right;">
<td>{{ doc.get_formatted("total") }}</td>
<td>
{%- for dtax in doc.taxes -%}
{% if dtax.tax_amount %}
{% if dtax.account_head == "Output Tax CGST 9%" %}
{{ dtax.get_formatted("tax_amount") }}
{%- endif %}
{% if dtax.account_head == "Output Tax CGST 14%" %}
{{ dtax.get_formatted("tax_amount") }}
{%- endif %}
{%- endif %}
{%- endfor -%}
</td>
<td>
{%- for dtax in doc.taxes -%}
{% if dtax.tax_amount %}
{% if dtax.account_head == "Output Tax SGST 9%" %}
{{ dtax.get_formatted("tax_amount") }}
{%- endif %}
{% if dtax.account_head == "Output Tax SGST 14%" %}
{{ dtax.get_formatted("tax_amount") }}
{%- endif %}
{%- endif %}
{%- endfor -%}
</td>
<td>{{ doc.get_formatted("grand_total") }}</td>
<td>{{ doc.get_formatted("rounded_total") }}</td>
</tr>
</tbody>
</table>
Please set your HTML style and if-condition according to.
More details for Custom Print format: Customize Print Format
Example: Customize Print Format
Check for more format about Jinja: Template Designer Documentation — Jinja Documentation (3.0.x)
Thank You!
@NCP,
Thank you for the sample code.
I inserted a section in the Print Format report then I added Custom HTML field and inserted the code that you provided to see how things work but when I preview the report nothing is coming up.
It is just blank!
Am I missing something here?
Regards,
Hi @yogeshvachhani,
Please check your all condition.
mainly check this type of condition.
account_head name is proper or not.
is total, grand_total, and rounded_total does show or not?
Thanks.
Thank you very much for the hint. I managed to get the required data.
Generally all Invoices are paid almost immediately by Cash or by Bank. In this case how to fetch data regarding payment in Invoice print format?
Regards,
Hi @yogeshvachhani,
Remaining amount print for use {{ doc.outstanding_amount }}
Paid amount print for use {{ doc.rounded_total - doc.outstanding_amount }}
OR {{ doc.grand_total - doc.outstanding_amount }}
And other details get for use some jinja format.
Thanks.
Actually I want to check if payment has been received against the invoice being printed and if printed I want to get the mode of payment and show it in the printed invoice.
Second thing is that now the Invoice is coming up as per what I want. Here is the preview…
But there is one problem here and that is when I click on PDF button to get a PDF ERPNext shows this error message.
Traceback (most recent call last):
File "env/lib/python3.8/site-packages/pdfkit/configuration.py", line 21, in __init__
with open(self.wkhtmltopdf) as f:
FileNotFoundError: [Errno 2] No such file or directory: b''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 68, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 55, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 31, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 68, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/__init__.py", line 1208, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/utils/print_format.py", line 95, in download_pdf
frappe.local.response.filecontent = get_pdf(html)
File "apps/frappe/frappe/utils/pdf.py", line 40, in get_pdf
filedata = pdfkit.from_string(html, False, options=options or {})
File "env/lib/python3.8/site-packages/pdfkit/api.py", line 69, in from_string
r = PDFKit(input, 'string', options=options, toc=toc, cover=cover, css=css,
File "env/lib/python3.8/site-packages/pdfkit/pdfkit.py", line 42, in __init__
self.configuration = (Configuration() if configuration is None
File "env/lib/python3.8/site-packages/pdfkit/configuration.py", line 24, in __init__
raise IOError('No wkhtmltopdf executable found: "%s"\n'
OSError: No wkhtmltopdf executable found: "b''"
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
What must be wrong and how to solve it.
For use server script to get a mode of payment and set in invoice custom field then printing in the invoice.
Check-in whether other doctypes in print pdf are worked or not.
If not worked then install it.
Thanks.