diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 071e72b4fb..22485e95f7 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -1116,7 +1116,7 @@ class TestSalesInvoice(unittest.TestCase): }) si.insert() - tax_breakup_html = '''\n
\n\t\n\t\t\n\n\n\t\t\n\t
Item NameTaxable Amount_Test Account Service Tax - _TC
_Test Item5000.0(10.0%) \u20b9 500.00
\n
''' + tax_breakup_html = '''\n
\n\t\n\t\t\n\n\n\t\t\n\t
Item NameTaxable Amount_Test Account Service Tax - _TC
_Test Item\u20b9 5,000.00(10.0%) \u20b9 500.00
\n
''' self.assertEqual(si.other_charges_calculation, tax_breakup_html) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index b0fe39547f..8c071203e8 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -511,14 +511,15 @@ class calculate_taxes_and_totals(object): def set_item_wise_tax_breakup(self): item_tax = {} tax_accounts = [] + company_currency = erpnext.get_company_currency(self.doc.company) - item_tax, tax_accounts = self.get_item_tax(item_tax, tax_accounts) + item_tax, tax_accounts = self.get_item_tax(item_tax, tax_accounts, company_currency) headings = get_table_column_headings(tax_accounts) distinct_items = self.get_distinct_items() - rows = get_table_rows(distinct_items, item_tax, tax_accounts) + rows = get_table_rows(distinct_items, item_tax, tax_accounts, company_currency) if not rows: self.doc.other_charges_calculation = "" @@ -534,9 +535,7 @@ class calculate_taxes_and_totals(object): "rows": "\n".join(rows) }) - def get_item_tax(self, item_tax, tax_accounts): - company_currency = erpnext.get_company_currency(self.doc.company) - + def get_item_tax(self, item_tax, tax_accounts, company_currency): for tax in self.doc.taxes: tax_amount_precision = tax.precision("tax_amount") tax_rate_precision = tax.precision("rate"); @@ -588,7 +587,7 @@ def get_table_column_headings(tax_accounts): return headings -def get_table_rows(distinct_items, item_tax, tax_accounts): +def get_table_rows(distinct_items, item_tax, tax_accounts, company_currency): rows = [] for item in distinct_items: item_tax_record = item_tax.get(item.item_code or item.item_name) @@ -605,7 +604,7 @@ def get_table_rows(distinct_items, item_tax, tax_accounts): rows.append("{item_name}{taxable_amount}{taxes}".format(**{ "item_name": item.item_name, - "taxable_amount": item.net_amount, + "taxable_amount": fmt_money(item.net_amount, item.precision("net_amount"), company_currency), "taxes": "\n".join(taxes) })) diff --git a/erpnext/docs/assets/img/regional/india/address-template-gstin.png b/erpnext/docs/assets/img/regional/india/address-template-gstin.png index 8740609dd3..5862c5462a 100644 Binary files a/erpnext/docs/assets/img/regional/india/address-template-gstin.png and b/erpnext/docs/assets/img/regional/india/address-template-gstin.png differ diff --git a/erpnext/docs/assets/img/regional/india/sample-gst-tax-invoice.png b/erpnext/docs/assets/img/regional/india/sample-gst-tax-invoice.png index 4f4a9b19ab..cb65724817 100644 Binary files a/erpnext/docs/assets/img/regional/india/sample-gst-tax-invoice.png and b/erpnext/docs/assets/img/regional/india/sample-gst-tax-invoice.png differ diff --git a/erpnext/docs/user/manual/en/regional/india/gst-setup.md b/erpnext/docs/user/manual/en/regional/india/gst-setup.md index 0ba8284bcb..49d75b1939 100644 --- a/erpnext/docs/user/manual/en/regional/india/gst-setup.md +++ b/erpnext/docs/user/manual/en/regional/india/gst-setup.md @@ -16,7 +16,7 @@ Go to the Company master and add the GSTIN to your default address. **Include GSTIN number in the Address Template** -Open Address Template record for India, and add GSTIN number there if not exists. +Open Address Template record for India, add GSTIN number and State Code there if not exists. GST in Company @@ -63,7 +63,7 @@ For **Sales Invoice**, ### 6. Print GST Tax Invoice -To print Tax Invoice as per GSTN guidelines, please select **GST Tax Invoice** print format. This print format includes company address, GSTIN numbers, HSN/SAC Code and item-wise tax breakup. +To print Tax Invoice as per GSTN guidelines, please select **GST Tax Invoice** print format. This print format includes company address, GSTIN numbers, HSN/SAC Code and item-wise tax breakup. And while printing select correct value of Invoice Copy field, to mention whether it is for the Customer, Supplier or Transporter. Sample GST Tax Invoice diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 4f5c238031..13b7299f36 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -411,5 +411,5 @@ erpnext.patches.v8_1.delete_deprecated_reports erpnext.patches.v8_1.setup_gst_india #2017-06-27 execute:frappe.reload_doc('regional', 'doctype', 'gst_hsn_code') erpnext.patches.v8_1.removed_roles_from_gst_report_non_indian_account -erpnext.patches.v8_1.gst_fixes +erpnext.patches.v8_1.gst_fixes #2017-07-06 erpnext.patches.v8_0.update_production_orders diff --git a/erpnext/patches/v8_1/gst_fixes.py b/erpnext/patches/v8_1/gst_fixes.py index 5454f0ff18..1d3a380df0 100644 --- a/erpnext/patches/v8_1/gst_fixes.py +++ b/erpnext/patches/v8_1/gst_fixes.py @@ -1,7 +1,19 @@ import frappe +from frappe.custom.doctype.custom_field.custom_field import create_custom_field +from erpnext.regional.india.setup import update_address_template def execute(): - frappe.db.sql("""update `tabCustom Field` set label = 'HSN/SAC Code' + company = frappe.get_all('Company', filters = {'country': 'India'}) + if not company: + return + + update_existing_custom_fields() + add_custom_fields() + update_address_template() + frappe.reload_doc("regional", "print_format", "gst_tax_invoice") + +def update_existing_custom_fields(): + frappe.db.sql("""update `tabCustom Field` set label = 'HSN/SAC' where fieldname='gst_hsn_code' and label='GST HSN Code' """) @@ -21,7 +33,26 @@ def execute(): where fieldname='gst_hsn_code' and dt in ('Sales Invoice Item', 'Purchase Invoice Item') """) - # reload gst print format for Indian users - company = frappe.get_all('Company', filters = {'country': 'India'}) - if company: - frappe.reload_doc("regional", "print_format", "gst_tax_invoice") \ No newline at end of file +def add_custom_fields(): + hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC', + fieldtype='Data', options='item_code.gst_hsn_code', insert_after='description') + + custom_fields = { + 'Address': [ + dict(fieldname='gst_state_number', label='GST State Number', + fieldtype='Int', insert_after='gst_state'), + ], + 'Sales Invoice': [ + dict(fieldname='invoice_copy', label='Invoice Copy', + fieldtype='Select', insert_after='project', print_hide=1, + options='ORIGINAL FOR RECIPIENT\nDUPLICATE FOR TRANSPORTER\nTRIPLICATE FOR SUPPLIER'), + ], + 'Sales Order Item': [hsn_sac_field], + 'Delivery Note Item': [hsn_sac_field], + 'Purchase Order Item': [hsn_sac_field], + 'Purchase Receipt Item': [hsn_sac_field] + } + + for doctype, fields in custom_fields.items(): + for df in fields: + create_custom_field(doctype, df) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 642ff1b3e9..075b2d0bdf 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -705,7 +705,8 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ if(!item_tax_record) { return null; } return repl("%(item_name)s%(taxable_amount)s%(taxes)s", { item_name: item.item_name, - taxable_amount: item.net_amount, + taxable_amount: format_currency(item.net_amount, + company_currency, precision("net_amount", item)), taxes: $.map(tax_accounts, function(head) { return item_tax_record[head[0]] ? "(" + item_tax_record[head[0]][0] + ") " + item_tax_record[head[0]][1] + "" : diff --git a/erpnext/regional/india/address_template.html b/erpnext/regional/india/address_template.html index 46879ad6b8..1bcc5ad6a9 100644 --- a/erpnext/regional/india/address_template.html +++ b/erpnext/regional/india/address_template.html @@ -1,6 +1,7 @@ {{ address_line1 }}
{% if address_line2 %}{{ address_line2 }}
{% endif -%}{{ city }}
-{% if state %}{{ state }}
{% endif -%} -{% if pincode %}{{ pincode }}
{% endif -%} +{% if gst_state %}{{ gst_state }}{% endif -%}, +{% if gst_state_number %}State Code: {{ gst_state_number }}
{% endif -%} +{% if pincode %}PIN: {{ pincode }}
{% endif -%} {{ country }}
{% if phone %}Phone: {{ phone }}
{% endif -%} {% if fax %}Fax: {{ fax }}
{% endif -%} diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py index 46cfdb805b..f547b825e6 100644 --- a/erpnext/regional/india/setup.py +++ b/erpnext/regional/india/setup.py @@ -74,12 +74,17 @@ def add_print_formats(): frappe.reload_doc("regional", "print_format", "gst_tax_invoice") def make_custom_fields(): + hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC', + fieldtype='Data', options='item_code.gst_hsn_code', insert_after='description') + custom_fields = { 'Address': [ dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data', insert_after='fax'), dict(fieldname='gst_state', label='GST State', fieldtype='Select', - options='\n'.join(states), insert_after='gstin') + options='\n'.join(states), insert_after='gstin'), + dict(fieldname='gst_state_number', label='GST State Number', + fieldtype='Int', insert_after='gst_state'), ], 'Purchase Invoice': [ dict(fieldname='supplier_gstin', label='Supplier GSTIN', @@ -96,21 +101,20 @@ def make_custom_fields(): dict(fieldname='company_gstin', label='Company GSTIN', fieldtype='Data', insert_after='company_address', options='company_address.gstin', print_hide=1), + dict(fieldname='invoice_copy', label='Invoice Copy', + fieldtype='Select', insert_after='project', print_hide=1, + options='ORIGINAL FOR RECIPIENT\nDUPLICATE FOR TRANSPORTER\nTRIPLICATE FOR SUPPLIER') ], 'Item': [ - dict(fieldname='gst_hsn_code', label='HSN/SAC Code', + dict(fieldname='gst_hsn_code', label='HSN/SAC', fieldtype='Link', options='GST HSN Code', insert_after='item_group'), ], - 'Sales Invoice Item': [ - dict(fieldname='gst_hsn_code', label='HSN/SAC Code', - fieldtype='Data', options='item_code.gst_hsn_code', - insert_after='description'), - ], - 'Purchase Invoice Item': [ - dict(fieldname='gst_hsn_code', label='HSN/SAC Code', - fieldtype='Data', options='item_code.gst_hsn_code', - insert_after='description'), - ] + 'Sales Order Item': [hsn_sac_field], + 'Delivery Note Item': [hsn_sac_field], + 'Sales Invoice Item': [hsn_sac_field], + 'Purchase Order Item': [hsn_sac_field], + 'Purchase Receipt Item': [hsn_sac_field], + 'Purchase Invoice Item': [hsn_sac_field] } for doctype, fields in custom_fields.items(): diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index c4acafc944..62de7a9897 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -7,6 +7,7 @@ def validate_gstin_for_india(doc, method): return if doc.gstin: + doc.gstin = doc.gstin.upper() if doc.gstin != "NA": p = re.compile("[0-9]{2}[a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9A-Za-z]{1}[Z]{1}[0-9a-zA-Z]{1}") if not p.match(doc.gstin): @@ -17,6 +18,7 @@ def validate_gstin_for_india(doc, method): doc.gst_state = doc.state if doc.gst_state: - state_number = state_numbers[doc.gst_state] - if state_number != doc.gstin[:2]: - frappe.throw(_("First 2 digits of GSTIN should match with State number {0}").format(state_number)) + doc.gst_state_number = state_numbers[doc.gst_state] + if doc.gst_state_number != doc.gstin[:2]: + frappe.throw(_("First 2 digits of GSTIN should match with State number {0}") + .format(doc.gst_state_number)) \ No newline at end of file diff --git a/erpnext/regional/print_format/gst_tax_invoice/gst_tax_invoice.json b/erpnext/regional/print_format/gst_tax_invoice/gst_tax_invoice.json index b16aadaa8e..8d123368d8 100644 --- a/erpnext/regional/print_format/gst_tax_invoice/gst_tax_invoice.json +++ b/erpnext/regional/print_format/gst_tax_invoice/gst_tax_invoice.json @@ -7,10 +7,10 @@ "docstatus": 0, "doctype": "Print Format", "font": "Default", - "format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"Custom HTML\", \"options\": \"
\\t\\t\\t\\t

Sales Invoice
{{ doc.name }}\\t\\t\\t\\t

\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"company\", \"label\": \"Company\"}, {\"print_hide\": 0, \"fieldname\": \"company_address_display\", \"label\": \"Company Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"posting_date\", \"label\": \"Date\"}, {\"print_hide\": 0, \"fieldname\": \"due_date\", \"label\": \"Payment Due Date\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"options\": \"
\", \"fieldname\": \"_custom_html\", \"fieldtype\": \"HTML\", \"label\": \"Custom HTML\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name\", \"label\": \"Customer Name\"}, {\"print_hide\": 0, \"fieldname\": \"address_display\", \"label\": \"Address\"}, {\"print_hide\": 0, \"fieldname\": \"contact_display\", \"label\": \"Contact\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"shipping_address\", \"label\": \"Shipping Address\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"item_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"200px\"}, {\"print_hide\": 0, \"fieldname\": \"gst_hsn_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"qty\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"uom\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"rate\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"items\", \"label\": \"Items\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"label\": \"Total\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"300px\"}], \"print_hide\": 0, \"fieldname\": \"taxes\", \"label\": \"Sales Taxes and Charges\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"grand_total\", \"label\": \"Grand Total\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\", \"label\": \"Rounded Total\"}, {\"print_hide\": 0, \"fieldname\": \"in_words\", \"label\": \"In Words\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"other_charges_calculation\", \"align\": \"left\", \"label\": \"Item-wise Tax Breakup\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Terms\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"terms\", \"label\": \"Terms and Conditions Details\"}]", + "format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"Custom HTML\", \"options\": \"
\\n\\t

\\n\\t\\tSALES INVOICE
\\n\\t\\t{{ doc.name }}\\n\\t

\\n
\\n

\\n\\t{% if doc.invoice_copy -%}\\n\\t\\t({{ doc.invoice_copy }})\\n\\t{% endif -%}\\n

\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"company\", \"label\": \"Company\"}, {\"print_hide\": 0, \"fieldname\": \"company_address_display\", \"label\": \"Company Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"posting_date\", \"label\": \"Date\"}, {\"print_hide\": 0, \"fieldname\": \"due_date\", \"label\": \"Payment Due Date\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"options\": \"
\", \"fieldname\": \"_custom_html\", \"fieldtype\": \"HTML\", \"label\": \"Custom HTML\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name\", \"label\": \"Customer Name\"}, {\"print_hide\": 0, \"fieldname\": \"address_display\", \"label\": \"Address\"}, {\"print_hide\": 0, \"fieldname\": \"contact_display\", \"label\": \"Contact\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"shipping_address\", \"label\": \"Shipping Address\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"item_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"200px\"}, {\"print_hide\": 0, \"fieldname\": \"gst_hsn_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"qty\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"uom\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"rate\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"items\", \"label\": \"Items\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"label\": \"Total\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"300px\"}], \"print_hide\": 0, \"fieldname\": \"taxes\", \"label\": \"Sales Taxes and Charges\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"grand_total\", \"label\": \"Grand Total\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\", \"label\": \"Rounded Total\"}, {\"print_hide\": 0, \"fieldname\": \"in_words\", \"label\": \"In Words\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"other_charges_calculation\", \"align\": \"left\", \"label\": \"Item-wise Tax Breakup\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Terms\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"terms\", \"label\": \"Terms and Conditions Details\"}]", "idx": 0, "line_breaks": 0, - "modified": "2017-07-04 17:13:44.911156", + "modified": "2017-07-06 13:45:55.033384", "modified_by": "Administrator", "module": "Regional", "name": "GST Tax Invoice",