hi @ Denmark_Del_Puso,
here is the code, please help me
{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
{% if letter_head and not no_letterhead %}
{% endif %}
{%- endmacro -%}
{% if not no_letterhead and footer %}
{% else %}
{% endif %}
SALES INVOICE
{% if doc.status == "Draft" -%}
- {{doc.status}}
{%- endif %}
Billing to: {{ doc.customer_name}}
{{ doc.address_display }}GSTIN:{{ doc.billing_address_gstin}}
{% if doc.shipping_address != "" -%}
Shipping to: {{ doc.shipping_address}}
{%- endif %}
Consignee Copy(CC):{{ doc.cc_attached}}
Transportation Fee:{{ doc.transportation_fee}}
Delivery Type:{{ doc.delivery_type}}
Invoice.No : {{doc.name}}
Date :
{{frappe.utils.formatdate(doc.posting_date, 'dd-MM-YYYY')}}
Purchase Order : {{doc.purchase_order}}
Reference:
{{doc.other_reference}}
E-Way Bill(Karnataka) : {{doc.e_way_bill_karnataka}}
E-Way Bill(Customer State):
{{doc.e_way_bill_customer_state}}
<div class="watermark" style="width: 7.8cm; height: 7.8cm; padding: 5px;">
<img src="/private/files/CG1_Watermark_1.png">
</div>
{% if doc.shipping_address is defined %}
{% if 'Karnataka' in doc.shipping_address -%}
{% else %}
{%- endif %}
{% else %}
{% if 'Karnataka' in doc.address_display -%}
{% else %}
{%- endif %}
{% endif %}
{% set cgst_rate = [] -%}
{% set sgst_rate = [] -%}
{% set igst_rate = [] -%}
{% set cgst_account_head = [] -%}
{% set sgst_account_head = [] -%}
{% set igst_account_head = [] -%}
{% set tot_cgst_amount = [] %}
{% set tot_sgst_amount = [] %}
{% set grand_total = {"qty":0.0, "amount":0.0, "discount":0.0, "cgst_amt":0.0, "sgst_amt":0.0, "igst_amt":0.0} %}
{%- for row in doc.taxes -%}
{% if 'CGST' in row.account_head -%}
{% set _ = cgst_account_head.append(row.account_head) %}
{% set _ = cgst_rate.append(row.rate) %}
{%- endif -%}
{% if 'SGST' in row.account_head -%}
{% set _ = sgst_account_head.append(row.account_head) %}
{% set _ = sgst_rate.append(row.rate) %}
{%- endif -%}
{% if 'IGST' in row.account_head -%}
{% set _ = igst_account_head.append(row.account_head) %}
{% set _ = igst_rate.append(row.rate) %}
{%- endif -%}
{%- endfor -%}
{%- for row in doc.items -%}
{% set cgst_amt = [] -%}
{% set sgst_amt = [] -%}
{% set igst_amt = [] -%}
{% set it_cgst_rate = [] -%}
{% set it_sgst_rate = [] -%}
{% set it_igst_rate = [] -%}
{% set rate_found_item = 0 -%}
{%- set item_record = frappe.get_doc(“Item”, row.item_code) -%}
{% for item_tax in item_record.taxes %}
{% if item_tax.tax_type == igst_account_head[0] %}
{% set _ = it_igst_rate.append(item_tax.tax_rate) %}
{% set _ = igst_amt.append(row.amount * it_igst_rate[0] / 100) -%}
{% set rate_found_item = 1 -%}
{% endif %}
{% if item_tax.tax_type == sgst_account_head[0] %}
{% set _ = it_sgst_rate.append(item_tax.tax_rate) %}
{% set _ = sgst_amt.append(row.amount * it_sgst_rate[0] / 100) -%}
{% set rate_found_item = 1 -%}
{% endif %}
{% if item_tax.tax_type == cgst_account_head[0] %}
{% set _ = it_cgst_rate.append(item_tax.tax_rate) %}
{% set _ = cgst_amt.append(row.amount * it_cgst_rate[0] / 100) -%}
{% set rate_found_item = 1 -%}
{% endif %}
{% endfor %}
{% if rate_found_item == 0 %}
{% if cgst_rate[0] -%}
{% set _ = cgst_amt.append((row.amount * cgst_rate[0])/100) -%}
{% set _= it_cgst_rate.append(cgst_rate[0]) -%}
{% set rate_found_inv = 1 -%}
{%- endif -%}
{% if sgst_rate[0] -%}
{% set _ = sgst_amt.append((row.amount * sgst_rate[0])/100) -%}
{% set _= it_sgst_rate.append(sgst_rate[0]) -%}
{%- endif -%}
{% if igst_rate[0] -%}
{% set _ = igst_amt.append((row.amount * igst_rate[0])/100) -%}
{% set _= it_igst_rate.append(igst_rate[0]) -%}
{% set rate_found_inv = 1 -%}
{%- endif -%}
{% endif %}
{% if not it_cgst_rate[0] %}
{% set _ = it_cgst_rate.append(0) %}
{% set _ = cgst_amt.append(0) %}
{% endif %}
{% if not it_sgst_rate[0] %}
{% set _ = it_sgst_rate.append(0) %}
{% set _ = sgst_amt.append(0) %}
{% endif %}
{% if not it_igst_rate[0] %}
{% set _ = it_igst_rate.append(0) %}
{% set _ = igst_amt.append(0) %}
{% endif %}
{% set temp_cgst_amt = grand_total["cgst_amt"] + cgst_amt[0] %}
{% set temp_sgst_amt = grand_total["sgst_amt"] + sgst_amt[0] %}
{% set temp_igst_amt = grand_total["igst_amt"] + igst_amt[0] %}
{% set temp_qty = grand_total["qty"] + row.qty %}
{% set temp_amount = grand_total["amount"] + row.amount %}
{% set check = grand_total.update({"qty": temp_qty, "amount": temp_amount, "cgst_amt":temp_cgst_amt, "sgst_amt":temp_sgst_amt, "igst_amt":temp_igst_amt}) %}
<td style="width: 3%;"><font size = "1">{{ row.idx }}</font></td>
<td style="width: 25%;"><font size = "1">
<b>{{ row.item_code}}</b>
{% if row.item_code != row.item_name -%}
<br>{{ row.item_name}}
{%- endif %}
</font></td>
<td style="width: 7%; text-align: right;"><font size = "1">{{ row.gst_hsn_code }}</font></td>
<td style="width: 5%; text-align: right;"><font size = "1">{{row.weight_in_kg }}</font></td>
<td style="width: 8%; text-align: right;"><font size = "1">{{ row.qty }}<small> {{ row.uom or row.stock_uom }}</small><br>in <small>{{row.no_of_countable_units}} {{row.package_type}}</small> </font></td>
<td style="width: 8%; text-align: right;"><font size = "1">{{
row.get_formatted("price_list_rate", doc) }}</font></td>
<td style="width: 5%; text-align: right; font size = "1""><font size = "1">
{% set discount = ((row.base_price_list_rate*row.discount_percentage)/100)*row.qty %}
₹ {{ “{0:0.2f}”.format(discount) or ‘0’}}
{{row.discount_percentage }}%
</font></td>
<td style="width: 11%; text-align: right;"><font size = "1">{{
row.get_formatted("amount", doc) }}</font></td>
{% if doc.shipping_address is defined %}
{% if 'Karnataka' in doc.shipping_address -%}
<td style="width: 9%; text-align: right;"><font size = "1">{{
"₹ {:,.2f}".format(cgst_amt[0]) }}<br><small>{{
it_cgst_rate[0] }}%</small></font></td>
<td style="width: 9%; text-align: right;"><font size = "1">{{
"₹ {:,.2f}".format(sgst_amt[0]) }}<br><small>{{
it_sgst_rate[0] }}%</small></font></td>
{% else %}
<td style="width: 9%; text-align: right;"><font size = "1">{{
"₹ {:,.2f}".format(igst_amt[0]) }}<br><small>{{
it_igst_rate[0] }}%</small></font></td>
{%- endif %}
{% else %}
{% if 'Karnataka' in doc.address_display -%}
<td style="width: 9%; text-align: right;"><font size = "1">{{
"₹ {:,.2f}".format(cgst_amt[0]) }}<br><small>{{
it_cgst_rate[0] }}%</small></font></td>
<td style="width: 9%; text-align: right;"><font size = "1">{{
"₹ {:,.2f}".format(sgst_amt[0]) }}<br><small>{{
it_sgst_rate[0] }}%</small></font></td>
{% else %}
<td style="width: 9%; text-align: right;"><font size = "1">{{
"₹ {:,.2f}".format(igst_amt[0]) }}<br><small>{{
it_igst_rate[0] }}%</small></font></td>
{%- endif %}
{% endif %}
{%- endfor -%}
Sr. No. |
Product Details |
HSN /SAC |
Weight in Kg |
Qty, Pkg |
Unit Rate |
Discount (%) |
Taxable Amount |
SGST |
CGST |
IGST |
SGST |
CGST |
IGST |
{% if doc.shipping_address is defined %}
{% if ‘Karnataka’ in doc.shipping_address -%}
TOTAL:
<span style="display:inline; margin-left: 6.5%; width: 3.5%; text-align: right; font size = “1"”>{{doc.total_weight}} Kg
<span style="display:inline; margin-left: 3.25%; text-align: left; font size = “1"”>{{doc.total_no_of_countable_units}} item(s)
<span style="display:inline; margin-left:13%; width: 5%; text-align: right; font size = “1"”>{{doc.total_discount}}%
<span style="display:inline; margin-left:3%; width: 11%; text-align: right; font size = “1"”>{{doc.get_formatted(“net_total”)}}
<span style="display:inline; margin-left:2.5%; width: 9%; text-align: right; font size = “1"”>{{“₹ {:,.2f}”.format(grand_total.cgst_amt)}}
<span style="display:inline; margin-left:2%; width: 9%; text-align: right; font size = “1"”>{{“₹ {:,.2f}”.format(grand_total.sgst_amt)}}
{% else %}
TOTAL:
<span style="display:inline; margin-left: 6%; width: 3.5%; text-align: right; font size = “1"”>{{doc.total_weight}} Kg
<span style="display:inline; margin-left: 3.25%; text-align: left; font size = “1"”>{{doc.total_no_of_countable_units}} item(s)
<span style="display:inline; margin-left:15.5%; width: 5%; text-align: right; font size = “1"”>{{doc.total_discount}}%
<span style="display:inline; margin-left:4.5%; width: 11%; text-align: right; font size = “1"”>{{doc.get_formatted(“net_total”)}}
<span style="display:inline; margin-left:3%; width: 9%; text-align: right; font size = “1"”>{{“₹ {:,.2f}”.format(grand_total.igst_amt)}}
{%- endif %}
{% else %}
{% if ‘Karnataka’ in doc.address_display -%}
TOTAL:
<span style="display:inline; margin-left: 6.5%; width: 3.5%; text-align: right; font size = “1"”>{{doc.total_weight}} Kg
<span style="display:inline; margin-left: 3.25%; text-align: left; font size = “1"”>{{doc.total_no_of_countable_units}} item(s)
<span style="display:inline; margin-left:13%; width: 5%; text-align: right; font size = “1"”>{{doc.total_discount}}%
<span style="display:inline; margin-left:3%; width: 11%; text-align: right; font size = “1"”>{{doc.get_formatted(“net_total”)}}
<span style="display:inline; margin-left:2.5%; width: 9%; text-align: right; font size = “1"”>{{“₹ {:,.2f}”.format(grand_total.cgst_amt)}}
<span style="display:inline; margin-left:2%; width: 9%; text-align: right; font size = “1"”>{{“₹ {:,.2f}”.format(grand_total.sgst_amt)}}
{% else %}
TOTAL:
<span style="display:inline; margin-left: 6%; width: 3.5%; text-align: right; font size = “1"”>{{doc.total_weight}} Kg
<span style="display:inline; margin-left: 3.25%; text-align: left; font size = “1"”>{{doc.total_no_of_countable_units}} item(s)
<span style="display:inline; margin-left:15.5%; width: 5%; text-align: right; font size = “1"”>{{doc.total_discount}}%
<span style="display:inline; margin-left:4.5%; width: 11%; text-align: right; font size = “1"”>{{doc.get_formatted(“net_total”)}}
<span style="display:inline; margin-left:3%; width: 9%; text-align: right; font size = “1"”>{{“₹ {:,.2f}”.format(grand_total.igst_amt)}}
{%- endif %}
{% endif %}
In Words:
{{frappe.utils.money_in_words(doc.rounded_total)}}
{% if doc.shipping_address is defined %}
{% if 'Karnataka' in doc.shipping_address -%}
{%- for row in doc.taxes -%}
{% if 'Shipping Charges - CG1' in row.account_head -%}
Shipping Charges
{%- endif %}
{%- endfor -%}
{% else %}
{%- for row in doc.taxes -%}
{% if 'Shipping Charges - CG1' in row.account_head -%}
Shipping Charges
{%- endif %}
{%- endfor -%}
{%- endif %}
{% if doc.discount_amount -%}
Additional Discount&Amount
{%- endif %}
{% else %}
{% if 'Karnataka' in doc.address_display -%}
{%- for row in doc.taxes -%}
{% if 'Shipping Charges - CG1' in row.account_head -%}
Shipping Charges:
{%- endif %}
{%- endfor -%}
{% else %}
{%- for row in doc.taxes -%}
{% if 'Shipping Charges - CG1' in row.account_head -%}
Shipping Charges
{%- endif %}
{%- endfor -%}
{%- endif %}
{% if doc.discount_amount -%}
Additional Discount&Amount
{%- endif %}
{% endif %}
Grand Total<br>
Round Total <br>
<section class="text-right" style="float: right;">
{% if doc.shipping_address is defined %}
{% if ‘Karnataka’ in doc.shipping_address -%}
{%- for row in doc.taxes -%}
{% if ‘Shipping Charges - CG1’ in row.account_head -%}
{{row.get_formatted(“tax_amount”, doc) }}
{%- endif %}
{%- endfor -%}
{% else %}
{%- for row in doc.taxes -%}
{% if ‘Shipping Charges - CG1’ in row.account_head -%}
{{row.get_formatted(“tax_amount”, doc) }}
{%- endif %}
{%- endfor -%}
{%- endif %}
{% if doc.discount_amount -%} {{doc.get_formatted(“additional_discount_percentage”)}}%
{{doc.get_formatted(“discount_amount”)}}
{%- endif %}
{% else %}
{% if ‘Karnataka’ in doc.address_display -%}
{%- for row in doc.taxes -%}
{% if ‘Shipping Charges - CG1’ in row.account_head -%}
{{row.get_formatted(“tax_amount”, doc) }}
{%- endif %}
{%- endfor -%}
{% else %}
{%- for row in doc.taxes -%}
{% if ‘Shipping Charges - CG1’ in row.account_head -%}
{{row.get_formatted(“tax_amount”, doc) }}
{%- endif %}
{%- endfor -%}
{%- endif %}
{% if doc.discount_amount -%}
{{doc.get_formatted(“discount_amount”)}}
{%- endif %}
{% endif %}
{{doc.get_formatted("grand_total")}}<br>
{{doc.get_formatted("rounded_total")}}<br>
<section class="text-right" style="float: right;">
{% if doc.shipping_address is defined %}
{% if ‘Karnataka’ in doc.shipping_address -%}
{%- for row in doc.taxes -%}
{% if ‘Shipping Charges - CG1’ in row.account_head -%}
:
{%- endif %}
{%- endfor -%}
{% else %}
{%- for row in doc.taxes -%}
{% if ‘Shipping Charges - CG1’ in row.account_head -%}
:
{%- endif %}
{%- endfor -%}
{%- endif %}
{% if doc.discount_amount -%}:
{%- endif %}
{% else %}
{% if ‘Karnataka’ in doc.address_display -%}
{%- for row in doc.taxes -%}
{% if ‘Shipping Charges - CG1’ in row.account_head -%}
:
{%- endif %}
{%- endfor -%}
{% else %}
{%- for row in doc.taxes -%}
{% if ‘Shipping Charges - CG1’ in row.account_head -%}
:
{%- endif %}
{%- endfor -%}
{%- endif %}
{% if doc.discount_amount -%}
:
{%- endif %}
{% endif %}
: <br>
: <br>
{{doc.terms}}
{% if not no_letterhead and footer %}
{% else %}
+91-80486-17217; +91-97406-59345; +91-80737-78471; enquiry@cropg1.com; www.cropg1.com
{% endif %}