Hi,
When I attempt to print the sales invoice or save it as a PDF, the Item Tax Rate is not displaying correctly, as shown in the attached screenshot. Kindly assist in resolving this issue.
Hi,
When I attempt to print the sales invoice or save it as a PDF, the Item Tax Rate is not displaying correctly, as shown in the attached screenshot. Kindly assist in resolving this issue.
You can customize the print format to display only the applicable tax rate (for example, “GST 18%”) instead of showing all the raw tax data.
Alternatively, you may share your current code, and I will review it and provide clear guidance on the required changes.
This is not the correct field for Item Tax Rate. This field shows Item Tax Template values.
You can use GST Details Fields for the correct tax rate, or you can use the GST Breackup Table.
Hope this helps.
Regards,
Lakshit Jain
How to customize the print format code?
You can review your Print Format in the Print Format DocType. If it has been built using a Jinja template, the code will be visible there, and you can easily customize it as needed.
We have added `GST Tax Invoice` Print format.
Which can be edited from UI.
With a customisable logo, bank details and other company details can be modified from the company doctype.
Kindly share the section where the Item Tax Rate has been added in print format.
Tax rate is shown below directly.
Create a print format like that and then paste this code :
@page { margin-top: 0mm; margin-bottom: 0mm; margin-left: 0mm; margin-right: 0mm; } \* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: Arial, Helvetica, sans-serif; font-size: 8.5pt; line-height: 1.4; color: #000; } .print-format{ margin: 0; padding: 0; width: 100%; } /\* Document Title \*/ .document-title { text-align: center; font-size: 13pt; font-weight: bold; color: #000; padding: 12px; border: 1px solid #808080; border-bottom: none; page-break-after: avoid; } /\* Customer and Invoice Info Section \*/ .info-section { width: 100%; margin-bottom: 0; } .info-table { width: 100%; border-collapse: collapse; border: 1px solid #000; border-bottom: none; page-break-inside: avoid; } .info-table td { padding: 6px 10px; vertical-align: top; font-size: 9pt; line-height: 1.5; } .info-label { font-weight: bold; background-color: transparent; } .info-value { border-right:1px solid #000; text-align: left; } /\* Items Table \*/ .items-table { border-collapse: collapse; margin-bottom: 0; border: 1px solid #000; width: 100%; } .items-table th { background: white !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; border: 1px solid #000; padding: 8px 6px; text-align: left; font-weight: bold; font-size: 9pt; line-height: 1.3; } .items-table td { border: 1px solid #000; padding: 6px 8px; font-size: 8pt; line-height: 1.4; } .items-table tr { page-break-inside: avoid; page-break-after: auto; } .text-center { text-align: center; } .text-right { text-align: right; } .text-left { text-align: left; } .total-td{ padding:0px !important; } /\* Totals Section \*/ .totals-container { width: 100%; page-break-inside: avoid; } .totals-table{ width: 45.5%; float: right; } .totals-table td { border: 1px solid #000; border-top: none; border-right: none; font-size: 8pt; line-height: 1.4; } .totals-label { text-align: left; } .totals-value { text-align: left; width: 21%; } .words-row { float: right; width: 45.5%; border: 1px solid #000; border-top: none !important; border-bottom: none !important; border-right:none !important; padding: 6px 12px; font-size: 8pt; line-height: 1.4; } /\* Tax Breakdown Table \*/ .tax-breakdown { width: 100%; clear: both; page-break-inside: avoid; } .tax-breakdown-table { width: 100%; border-collapse: collapse; } .tax-breakdown-table th { background: white !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; border: 1px solid #000; padding: 6px 5px; text-align: center; font-weight: bold; font-size: 9pt; line-height: 1.3; } .tax-breakdown-table td { border: 1px solid #000; padding: 5px 6px; text-align: center; font-size: 8pt; line-height: 1.3; } .tax-breakdown-table tr { page-break-inside: avoid; page-break-after: auto; } /\* Bank Details Section \*/ .footer-section { width: 100%; border: 1px solid #000; border-right:none; border-top: none; clear: both; page-break-inside: avoid; } .footer-table { width: 100%; border-collapse: collapse; } .footer-table td { padding: 6px 10px; border-right: 1px solid #000; font-size: 9pt; vertical-align: top; line-height: 1.4; } .footer-table tr { page-break-inside: avoid; } .bank-heading { font-weight: bold; background-color: transparent; padding: 5px 10px; } .bank-label { border-right: none !important; font-weight: bold; width: 22%; } .bank-value { width: 38%; } .signature-cell { text-align: center; width: 40%; vertical-align: middle; padding-top: 25px; } .signature-company { font-weight: bold; font-size: 9pt; } .signature-label { font-weight: bold; border-top: 1px solid #000; padding-top: 6px; display: inline-block; min-width: 160px; } /\*Thank You Section \*/ .thank-you { border: 1px solid #000; border-top: none; text-align: center; font-size: 13pt; font-weight: bold; padding: 5px 0; page-break-inside: avoid; } .letter-head-footer { width: 100%; /\*margin-top: 10px;\*/ text-align: center; clear: both; } .letter-head-footer img { max-width: 100%; height: auto; } @media print { html, body { margin: 6px; padding: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; } .letterhead-box { border: 1px solid #808080; border-bottom: none; } }{% if letter_head %}
<div class="letterhead-box">
{{ letter_head }}
</div>
{% endif %}
<!-- Document Title -->
<div class="document-title">
{% if doc.doctype == 'Sales Invoice' and doc.is_return == 0%}
Tax Invoice
{%else%}
Credit Note
{% endif %}
</div>
<table class="info-table">
<tr>
<td class="info-label">Bill To:</td>
<td class="info-value">
<strong>{{ doc.customer_name or doc.customer }}</strong>
</td>
<td class="info-label">Invoice No:</td>
<td class="info-value"><strong>{{ doc.name }}</strong></td>
</tr>
<tr>
<td class="info-label">Attn:</td>
<td class="info-value">{{ doc.customer_name or doc.customer }}</td>
<td class="info-label">Invoice Date:</td>
<td class="info-value">{{ doc.get_formatted("posting_date") }}</td>
</tr>
<tr>
<td class="info-label">Address:</td>
<td class="info-value">
{% if doc.customer_address %}
{% set addr = frappe.db.get_value("Address", doc.customer_address, \["address_line1", "address_line2", "city", "state", "country", "pincode"\], as_dict=1) %}
{% if addr %}
{{ addr.address_line1 or '' }}{% if addr.address_line2 %}, {{ addr.address_line2 }}{% endif %}{% if addr.city %}, {{ addr.city }}{% endif %}{% if addr.state %} {{ addr.state }}{% endif %}{% if addr.country %} {{ addr.country }}{% endif %}{% if addr.pincode %} {{ addr.pincode }}{% endif %}
{% endif %}
{% endif %}
</td>
<td class="info-label">Due Date:</td>
<td class="info-value">{{ doc.get_formatted("due_date") }}</td>
</tr>
<tr>
<td class="info-label">GST No.:</td>
<td class="info-value">{{doc.company_tax_id}}</td>
<td class="info-label">MSME No.:</td>
<td class="info-value">{{doc.company_tax_id}}</td>
</tr>
</table>
<thead>
<tr>
<th style="width: 2%;">S.No.</th>
<th style="width: 35%;">Description</th>
<th style="width: 12%;">HSN/SAC</th>
<th style="width: 6%;">Qty</th>
<th style="width: 13%;">Taxable Amt.</th>
<th style="width: 10%;">Tax Rate</th>
<th style="width: 11%;">Tax Amount</th>
<th style="width: 12%;">Total Amount</th>
</tr>
</thead>
<tbody>
{% for row in doc.items %}
<tr>
<td class="text-left">{{ row.idx }}.</td>
<td class="text-left">{{ row.item_name or row.item_code }}</td>
<td class="text-left">{{ row.gst_hsn_code or '' }}</td>
<td class="text-left">{{ row.qty }}</td>
<td class="text-left">
₹ {{ "{:,.0f}".format(row.taxable_value or 0) }}
</td>
<td class="text-left">
{% set tax_rate = (row.igst_rate or 0) + (row.cgst_rate or 0) + (row.sgst_rate or 0) + (row.cess_rate or 0) + (row.cess_non_advol_rate or 0) %}
{{ "%.1f"|format(tax_rate|abs) }}%
</td>
<td class="text-left">
{% set tax_amount = (row.igst_amount or 0) + (row.cgst_amount or 0) + (row.sgst_amount or 0) + (row.cess_amount or 0) + (row.cess_non_advol_amount or 0) %}
₹ {{ "{:,.0f}".format(tax_amount or 0) }}
</td>
<td class="text-left">₹ {{ "{:,.0f}".format(row.taxable_value + tax_amount or 0) }}</td>
</tr>
{% endfor %}
</tbody>
<tr>
<td style="border: none; padding: 0 !important; margin: 0;">
<div class="totals-container">
<table class="totals-table">
<tr>
<td class="totals-label">Total Taxable Amount</td>
<td class="totals-value">
₹ {{ "{:,.0f}".format(doc.total or 0) }}
</td>
</tr>
{% for tax in doc.taxes %}
{% if tax.tax_amount %}
<tr>
<td class="totals-label">{{ "Total "+tax.description or tax.account_head }}</td>
<td class="totals-value">
₹ {{ "{:,.0f}".format(tax.tax_amount or 0) }}
</td>
</tr>
{% endif %}
{% endfor %}
<tr>
<td class="totals-label">Total Tax Amount</td>
<td class="totals-value">
₹ {{ "{:,.0f}".format(doc.total_taxes_and_charges or 0) }}
</td>
</tr>
<tr>
<td class="totals-label"><strong>Grand Total</strong></td>
<td class="totals-value"><strong>
₹ {{ "{:,.0f}".format(doc.grand_total or 0) }}
</strong></td>
</tr>
</table>
</div>
<!-- Amount in Words -->
<div style="clear: both;">
<div class="words-row">
<strong>Total In Words:</strong> {{ frappe.utils.money_in_words(abs(doc.grand_total), doc.currency) }}.
</div>
</div>
</td>
</tr>
<!-- Tax Breakdown Table (HSN-wise) -->
<div class="tax-breakdown">
<table class="tax-breakdown-table">
<thead>
<tr>
<th rowspan="2" style="width: 10%;">HSN/SAC</th>
<th rowspan="2" style="width: 15%;">Taxable Amt</th>
<th colspan="2" style="width: 15%;">CGST</th>
<th colspan="2" style="width: 15%;">SGST</th>
<th colspan="2" style="width: 15%;">IGST</th>
<th rowspan="2" style="width: 15%;">Total Tax</th>
<th rowspan="2" style="width: 15%;">Total<br/>Amount</th>
</tr>
<tr>
<th style="width: 5%;">Rate</th>
<th style="width: 11%;">Amt</th>
<th style="width: 5%;">Rate</th>
<th style="width: 11%;">Amt</th>
<th style="width: 5%;">Rate</th>
<th style="width: 11%;">Amt</th>
</tr>
</thead>
<tbody>
{% set hsn_dict = {} %}
{# Build HSN-wise summary #}
{% for row in doc.items %}
{% set item = frappe.get_doc("Item", row.item_code)%}
{%set hsn_no = item.gst_hsn_code%}
{% set hsn = hsn_no or 'Not Specified' %}
{% if hsn not in hsn_dict %}
{% set \_ = hsn_dict.update({hsn: {
'amount': 0,
'cgst': 0,
'sgst': 0,
'igst': 0,
'cgst_rate': 0,
'sgst_rate': 0,
'igst_rate': 0,
'total_tax': 0
}}) %}
{% endif %}
{% set \_ = hsn_dict\[hsn\].update({'amount': hsn_dict\[hsn\]\['amount'\] + row.amount}) %}
{% set tax_amount = (row.igst_amount or 0) + (row.cgst_amount or 0 )+ (row.sgst_amount or 0) + (row.cess_amount or 0 )+ (row.cess_non_advol_amount or 0) %}
{% set item_tax_amount = tax_amount %}
{% set \_ = hsn_dict\[hsn\].update({'total_tax': hsn_dict\[hsn\]\['total_tax'\] + item_tax_amount}) %}
{% endfor %}
{# Process tax rows to split CGST/SGST/IGST #}
{% for tax in doc.taxes %}
{% for row in doc.items %}
{% set item = frappe.get_doc("Item", row.item_code)%}
{% set hsn_no = item.gst_hsn_code %}
{% set hsn = hsn_no or 'Not Specified' %}
{% set item_proportion = row.amount / doc.total if doc.total else 0 %}
{% set item_tax_share = tax.tax_amount \* item_proportion %}
{% if 'cgst' in tax.account_head.lower() %}
{% set \_ = hsn_dict\[hsn\].update({
'cgst': hsn_dict\[hsn\]\['cgst'\] + item_tax_share,
'cgst_rate': tax.rate
}) %}
{% elif 'sgst' in tax.account_head.lower() %}
{% set \_ = hsn_dict\[hsn\].update({
'sgst': hsn_dict\[hsn\]\['sgst'\] + item_tax_share,
'sgst_rate': tax.rate
}) %}
{% elif 'igst' in tax.account_head.lower() %}
{% set \_ = hsn_dict\[hsn\].update({
'igst': hsn_dict\[hsn\]\['igst'\] + item_tax_share,
'igst_rate': tax.rate
}) %}
{% endif %}
{% endfor %}
{% endfor %}
{# Display HSN-wise breakdown #}
{% for hsn, values in hsn_dict.items() %}
<tr>
<td class="text-center">{{ hsn }}</td>
<td class="text-right">₹ {{ "{:,.0f}".format(values\['amount'\] or 0) }}</td>
<td class="text-center">{{ "%.1f"|format(values\['cgst_rate'\]) if values\['cgst'\] else "0.0" }}%</td>
<td class="text-right">₹ {{ "{:,.0f}".format(values\['cgst'\] or 0) }}</td>
<td class="text-center">{{ "%.1f"|format(values\['sgst_rate'\]) if values\['sgst'\] else "0.0" }}%</td>
<td class="text-right">₹ {{ "{:,.0f}".format(values\['sgst'\] or 0) }}</td>
<td class="text-center">{{ "%.1f"|format(values\['igst_rate'\]) if values\['igst'\] else "0.0" }}%</td>
<td class="text-right">{{ frappe.format_value(values\['igst'\], {'fieldtype': 'Currency'}) }}</td>
<td class="text-right">{{ frappe.format_value(values\['total_tax'\], {'fieldtype': 'Currency'}) }}</td>
<td class="text-right">{{ frappe.format_value(values\['amount'\] + values\['total_tax'\], {'fieldtype': 'Currency'}) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Bank Details and Signature -->
{% set bank_account = frappe.db.get_value("Bank Account", {"company": doc.company, "is_company_account": 1}, \["bank", "bank_account_no", "iban", "branch_code"\], as_dict=1) %}
{% set company_tax_id = frappe.db.get_value("Company", doc.company, "tax_id") %}
<table class="footer-table">
<tr>
<td colspan="2" class="bank-heading">Bank Details:</td>
<td rowspan="6" class="signature-cell">
<div class="signature-company">For {{ doc.company }}</div>
<div class="signature-image">
<img src="/files/signature.png" alt="Signature" >
</div>
<div class="signature-label">Authorized Signature</div>
</td>
</tr>
<tr>
<td class="bank-label">Company Name:</td>
<td class="bank-value">{{ doc.company }}</td>
</tr>
<tr>
<td class="bank-label">RTGS / NEFT IFSC:</td>
<td class="bank-value">{{ bank_account.branch_code if bank_account else '' }}</td>
</tr>
<tr>
<td class="bank-label">Bank Account No.:</td>
<td class="bank-value">{{ bank_account.bank_account_no if bank_account else '' }}</td>
</tr>
<tr>
<td class="bank-label">SWIFT Code:</td>
{% set bank = frappe.get_doc("Bank",bank_account.bank)%}
<td class="bank-value">{{ bank.swift_number if bank_account else '' }}</td>
</tr>
<tr>
<td class="bank-label">Company's PAN:</td>
<td class="bank-value">{{ company_tax_id or '' }}</td>
</tr>
</table>
<!-- Thank You -->
<div class="thank-you">
Thank You
</div>
{% if letter_head and not no_letterhead %}
<div class="letter-head-footer">
{{ footer }}
</div>
{% endif %}
and save print format , then you can choose “custom print format” in sales invoice