Under Intra State GST i included, SGST, CGST
Under Inter State GST i included, IGST
Using Tax Rule, I applied taxes based on state and I created sales order and generated sales invoice.
Standard Sales Invoice looks like:
What I want:
Here is my Custom Script:
Reference
a) I think tax break up section has the detail about item wise applied tax detail.
In the sales invoice form I created tax_breakup field so that i can use this in custom print format.
frappe.ui.form.on("Sales Invoice", "onload_post_render", function(frm) {
var $table = $(".tax-break-up")
// Converting table into json like object. So that I can parse this in jinja print format template.
var header = [];
var rows = [];
$table.find("thead th").each(function() {
header.push($(this).html());
});
$table.find("tbody tr").each(function() {
var row = {};
$(this).find("td").each(function(i) {
var key = header[i],
value = $(this).html();
row[key] = value;
});
rows.push(row);
});
cur_frm.set_value("tax_breakup", rows); //Here is the problem. I can't set array to tax_breakup
});
I am new to ERPNext. I don’t know whether i am doing it in a right way. Please give me some guidelines.
I somehow displayed item wise tax. I believe there must be some better approach. I don’t find any. But this is not rendered while printing invoice Can somebody guide me in the right direction ?
Here is my code:
<table class="table table-bordered">
<tbody>
<tr>
<th>Sr</th>
<th>Item Name</th>
<th>Description</th>
<th class="text-right">Qty</th>
<th class="text-right">Rate</th>
<th class="text-right">Amount</th>
<th class="text-right">CGST</th>
<th class="text-right">SGST</th>
<th class="text-right">IGST</th>
</tr>
{%- for row in doc.items -%}
<tr>
<td style="width: 3%;">{{ row.idx }}</td>
<td style="width: 20%;">
{{ row.item_name }}
</td>
<td style="width: 20%;">
<div style="border: 0px;">{{ row.description }}</div>
</td>
<td style="width: 10%; text-align: right;">{{ row.qty }} {{ row.uom or row.stock_uom }}</td>
<td style="width: 15%; text-align: right;">{{ row.get_formatted("rate", doc) }}</td>
<td style="width: 10%; text-align: right;">{{ row.get_formatted("amount", doc) }}</td>
<td class="sgst{{loop.index}}">Nil</td>
<td class="cgst{{loop.index}}">Nil</td>
<td class="igst{{loop.index}}">Nil</td>
</tr>
{%- endfor -%}
</tbody>
</table>
<script type="text/javascript">
var $table = $(".tax-break-up"); // as far as i saw tax-break-up is not assigned to any form field.
var sgst_name = "SGST - N" // change according to ur tax type name
var cgst_name = "CGST - N" // change according to ur tax type name
var igst_name = "IGST - N" // change according to ur tax type name
var header = [];
var rows = [];
$table.find("thead th").each(function() {
header.push($(this).html());
});
$table.find("tbody tr").each(function() {
var row = {};
$(this).find("td").each(function(i) {
var key = header[i],
value = $(this).html();
row[key] = value;
});
rows.push(row);
});
$.each(rows, function(key, value) {
if (value.hasOwnProperty(sgst_name)) {
$(".sgst".concat(key + 1)).html('<span>' + value[sgst_name] + '</span>');
}
if (value.hasOwnProperty(cgst_name)) {
$(".cgst".concat(key + 1)).html('<span>' + value[cgst_name] + '</span>');
}
if (value.hasOwnProperty(igst_name)) {
$(".igst".concat(key + 1)).html('<span>' + value[igst_name] + '</span>');
}
});
</script>
You may either create custom print format or else in the existing standard drag and drop form replace item table with custom html and copy, paste above code and reload.
Is this format required for everyone? For me there’s only a single tax rate for all the products. Will I have to show taxes individually for each product?
I have created some code for calculating tax at item level. Here is the link for it. This method checks for the tax rate at item level first, and calculates the tax amount based on that. If the tax rate is not found at item level, it calculates the tax at invoice level. Have added some custom fields on that for state and gstin and HSN code on Sales Invoice. Though, the code is a little long, it works for me. Maybe, ERPNext might come up with some simpler code… Till then, you can check this out.