diff --git a/erpnext/buying/doctype/supplier/regional/india.js b/erpnext/buying/doctype/supplier/regional/india.js new file mode 100644 index 0000000000..bd710e0df7 --- /dev/null +++ b/erpnext/buying/doctype/supplier/regional/india.js @@ -0,0 +1,3 @@ +{% include "erpnext/regional/india/party.js" %} + +erpnext.setup_gst_reminder_button('Supplier'); \ No newline at end of file diff --git a/erpnext/config/accounts.py b/erpnext/config/accounts.py index a17679e116..6d16e9202e 100644 --- a/erpnext/config/accounts.py +++ b/erpnext/config/accounts.py @@ -201,6 +201,10 @@ def get_data(): { "label": _("Goods and Services Tax (GST India)"), "items": [ + { + "type": "doctype", + "name": "GST Settings", + }, { "type": "doctype", "name": "GST HSN Code", diff --git a/erpnext/docs/assets/img/regional/india/gst-reminder-email.png b/erpnext/docs/assets/img/regional/india/gst-reminder-email.png new file mode 100644 index 0000000000..97bcd2488b Binary files /dev/null and b/erpnext/docs/assets/img/regional/india/gst-reminder-email.png differ diff --git a/erpnext/docs/assets/img/regional/india/gst-settings.png b/erpnext/docs/assets/img/regional/india/gst-settings.png new file mode 100644 index 0000000000..c7f59adb96 Binary files /dev/null and b/erpnext/docs/assets/img/regional/india/gst-settings.png differ diff --git a/erpnext/docs/assets/img/regional/india/gstin-portal-update.png b/erpnext/docs/assets/img/regional/india/gstin-portal-update.png new file mode 100644 index 0000000000..28302c875f Binary files /dev/null and b/erpnext/docs/assets/img/regional/india/gstin-portal-update.png differ diff --git a/erpnext/docs/user/manual/en/regional/india/gst-remimders.md b/erpnext/docs/user/manual/en/regional/india/gst-remimders.md new file mode 100644 index 0000000000..58526c4135 --- /dev/null +++ b/erpnext/docs/user/manual/en/regional/india/gst-remimders.md @@ -0,0 +1,21 @@ +# Sending GST Reminders + +You can send email reminders to your Customers and Suppliers so that they can directly add or update their GSTIN numbers + +To send GSTIN Reminders, you can either open the Customer / Supplier record or **GST Settings** + +GST Settings + +Here you can click on the "Send GSTIN Update Reminders" button to send email reminders to all your customers + +### Updating GSTIN + +Your customers will receive an email asking them to update their GSTIN and that email will link them to a portal page: + +GST Portal Page + +Here they can update their GSTIN and it will automatically be added to your customer GSTIN record. + +#### Sample GSTIN Reminder Email + +GST Reminder Email diff --git a/erpnext/docs/user/manual/en/regional/india/gst-setup.md b/erpnext/docs/user/manual/en/regional/india/gst-setup.md new file mode 100644 index 0000000000..48e5066611 --- /dev/null +++ b/erpnext/docs/user/manual/en/regional/india/gst-setup.md @@ -0,0 +1,67 @@ +# GST Features in ERPNext + +### 1. Setting up GSTIN + +GST Law requires that you maintain the GSTIN number for all your suppliers and vendors. In ERPNext, GSTIN is linked to the **Address** + +GST in Customer + +**GST for your Company Address** + +You also need to set the Address for your own Company and your Company's GST Number + +Go to the Company master and add the GSTIN to your default address. + +GST in Company + +### 2. Setting up HSN Codes + +According to the GST Law, your itemised invoices must contain the HSN Code related to that Item. ERPNext comes pre-installed with all 12,000+ HSN Codes so that you can easily select the relevant HSN Code in your Item + +HSN in Item + +### 3. Making Tax Masters + +To setup Billing in GST, you need to create 3 Tax Accounts for the various GST reporting heads CGST - Central GST, SGST - State GST, IGST - Inter-state GST + +Go to your **Chart of Accounts**, under the Duties and Taxes head of your account, create 3 Accounts + +**Note:** Usually the rate in CGST and SGST is half of IGST. For example if most of your items are billed at 18%, then create IGST at 18%, CGST and SGST at 9% each. + +GST in Customer + +### 4. Make Tax Templates + +You will have have to make two tax templates for both your sales and purchase, one for in state sales and other for out of state sales. + +In your **In State GST** template, select 2 accounts, SGST and CGST + +GST in Customer + +In your **Out of State GST** template, select IGST + +### 5. Making GST Ready Invoices + +If you have setup the GSTIN of your Customers and Suppliers, and your tax template, you are ready to go for making GST Ready Invoices! + +For **Sales Invoice**, + +1. Select the correct Customer and Item and the address where the transaction will happen. +2. Check if the GSTIN of your Company and Supplier have been correctly set. +3. Check if the HSN Number has been set in the Item +4. Select the the **In State GST** or **Out of State GST** template that you have created based on the type of transaction +5. Save and Submit the Invoice + +GST Invoice + +### Reports + +ERPNext comes with most of your reports you need to prepare your GST Returns. Go to Accounts > GST India head for the list. + +GST Menus + +You can check the impact of your invoice in the **GST Sales Register** and **GST Itemised Sales Register** + +GST Itemised Sales Register + + diff --git a/erpnext/docs/user/manual/en/regional/india/index.md b/erpnext/docs/user/manual/en/regional/india/index.md index 16422070ca..4207a2f9af 100644 --- a/erpnext/docs/user/manual/en/regional/india/index.md +++ b/erpnext/docs/user/manual/en/regional/india/index.md @@ -2,70 +2,4 @@ As of 2017, India will fall under the new GST (Goods and Services Tax) regime and ERPNext makes it easy for users to track the details of its Supplier and Customers across Invoices and make the required reports. -## GST Features in ERPNext - -### 1. Setting up GSTIN - -GST Law requires that you maintain the GSTIN number for all your suppliers and vendors. In ERPNext, GSTIN is linked to the **Address** - -GST in Customer - -**GST for your Company Address** - -You also need to set the Address for your own Company and your Company's GST Number - -Go to the Company master and add the GSTIN to your default address. - -GST in Company - -### 2. Setting up HSN Codes - -According to the GST Law, your itemised invoices must contain the HSN Code related to that Item. ERPNext comes pre-installed with all 12,000+ HSN Codes so that you can easily select the relevant HSN Code in your Item - -HSN in Item - -### 3. Making Tax Masters - -To setup Billing in GST, you need to create 3 Tax Accounts for the various GST reporting heads CGST - Central GST, SGST - State GST, IGST - Inter-state GST - -Go to your **Chart of Accounts**, under the Duties and Taxes head of your account, create 3 Accounts - -**Note:** Usually the rate in CGST and SGST is half of IGST. For example if most of your items are billed at 18%, then create IGST at 18%, CGST and SGST at 9% each. - -GST in Customer - -### 4. Make Tax Templates - -You will have have to make two tax templates for both your sales and purchase, one for in state sales and other for out of state sales. - -In your **In State GST** template, select 2 accounts, SGST and CGST - -GST in Customer - -In your **Out of State GST** template, select IGST - -### 5. Making GST Ready Invoices - -If you have setup the GSTIN of your Customers and Suppliers, and your tax template, you are ready to go for making GST Ready Invoices! - -For **Sales Invoice**, - -1. Select the correct Customer and Item and the address where the transaction will happen. -2. Check if the GSTIN of your Company and Supplier have been correctly set. -3. Check if the HSN Number has been set in the Item -4. Select the the **In State GST** or **Out of State GST** template that you have created based on the type of transaction -5. Save and Submit the Invoice - -GST Invoice - -### Reports - -ERPNext comes with most of your reports you need to prepare your GST Returns. Go to Accounts > GST India head for the list. - -GST Menus - -You can check the impact of your invoice in the **GST Sales Register** and **GST Itemised Sales Register** - -GST Itemised Sales Register - - +{index} \ No newline at end of file diff --git a/erpnext/docs/user/manual/en/regional/india/index.txt b/erpnext/docs/user/manual/en/regional/india/index.txt new file mode 100644 index 0000000000..8d72c56f43 --- /dev/null +++ b/erpnext/docs/user/manual/en/regional/india/index.txt @@ -0,0 +1,2 @@ +gst-setup +gst-reminders \ No newline at end of file diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 181cfcea9a..706638a20f 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -407,4 +407,4 @@ erpnext.patches.v8_0.create_domain_docs #16-05-2017 erpnext.patches.v8_0.update_sales_cost_in_project erpnext.patches.v8_0.save_system_settings erpnext.patches.v8_1.delete_deprecated_reports -erpnext.patches.v8_1.setup_gst_india +erpnext.patches.v8_1.setup_gst_india #2017-06-27 diff --git a/erpnext/patches/v8_1/setup_gst_india.py b/erpnext/patches/v8_1/setup_gst_india.py index 9e54815a13..d8c87f9a6a 100644 --- a/erpnext/patches/v8_1/setup_gst_india.py +++ b/erpnext/patches/v8_1/setup_gst_india.py @@ -17,9 +17,10 @@ def execute(): def send_gst_update_email(): message = """Hello, -

ERPNext is now GST Ready.

+

ERPNext is now GST Ready!

-

To start making GST Invoices from 1st of July, you just need to create new Tax Accounts, Templates and update your Customer's and Supplier's GST Numbers.

+

To start making GST Invoices from 1st of July, you just need to create new Tax Accounts, +Templates and update your Customer's and Supplier's GST Numbers.

Please refer {gst_document_link} to know more about how to setup and implement GST in ERPNext.

diff --git a/erpnext/regional/doctype/gst_settings/__init__.py b/erpnext/regional/doctype/gst_settings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/regional/doctype/gst_settings/gst_settings.js b/erpnext/regional/doctype/gst_settings/gst_settings.js new file mode 100644 index 0000000000..11301f0232 --- /dev/null +++ b/erpnext/regional/doctype/gst_settings/gst_settings.js @@ -0,0 +1,25 @@ +// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('GST Settings', { + refresh: function(frm) { + frm.add_custom_button('Send GST Update Reminder', () => { + return new Promise((resolve) => { + return frappe.call({ + method: 'erpnext.regional.doctype.gst_settings.gst_settings.send_reminder' + }).always(() => { resolve(); }); + }); + }); + + $(frm.fields_dict.gst_summary.wrapper).empty().html( + ` + + + + + + +
Total Addresses${frm.doc.__onload.data.total_addresses}
Total Addresses with GST${frm.doc.__onload.data.total_addresses_with_gstin}
` + ) + } +}); diff --git a/erpnext/regional/doctype/gst_settings/gst_settings.json b/erpnext/regional/doctype/gst_settings/gst_settings.json new file mode 100644 index 0000000000..b399a5e0c4 --- /dev/null +++ b/erpnext/regional/doctype/gst_settings/gst_settings.json @@ -0,0 +1,101 @@ +{ + "allow_copy": 0, + "allow_guest_to_view": 0, + "allow_import": 0, + "allow_rename": 0, + "beta": 0, + "creation": "2017-06-27 15:09:01.318003", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 1, + "engine": "InnoDB", + "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "gst_summary", + "fieldtype": "HTML", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "GST Summary", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "gstin_email_sent_on", + "fieldtype": "Date", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "GSTIN Email Sent On", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + } + ], + "has_web_view": 0, + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_view": 0, + "in_create": 0, + "is_submittable": 0, + "issingle": 1, + "istable": 0, + "max_attachments": 0, + "modified": "2017-06-27 16:20:21.206397", + "modified_by": "Administrator", + "module": "Regional", + "name": "GST Settings", + "name_case": "", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "read_only": 0, + "read_only_onload": 0, + "show_name_in_global_search": 0, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1, + "track_seen": 0 +} \ No newline at end of file diff --git a/erpnext/regional/doctype/gst_settings/gst_settings.py b/erpnext/regional/doctype/gst_settings/gst_settings.py new file mode 100644 index 0000000000..e8c167d5a4 --- /dev/null +++ b/erpnext/regional/doctype/gst_settings/gst_settings.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe, os +from frappe.utils import get_url, nowdate, date_diff +from frappe.model.document import Document +from frappe.contacts.doctype.contact.contact import get_default_contact + +class EmailMissing(frappe.ValidationError): pass + +class GSTSettings(Document): + def onload(self): + data = frappe._dict() + data.total_addresses = frappe.db.sql('''select count(*) from tabAddress where country = "India"''') + data.total_addresses_with_gstin = frappe.db.sql('''select distinct count(*) + from tabAddress where country = "India" and ifnull(gstin, '')!='' ''') + self.set_onload('data', data) + +@frappe.whitelist() +def send_reminder(): + frappe.has_permission('GST Settings', throw=True) + + last_sent = frappe.db.get_single_value('GST Settings', 'gstin_email_sent_on') + if last_sent and date_diff(nowdate(), last_sent) < 3: + frappe.throw("Please wait 3 days before resending the reminder.") + + frappe.db.set_value('GST Settings', 'GST Settings', 'gstin_email_sent_on', nowdate()) + + # enqueue if large number of customers, suppliser + frappe.enqueue('erpnext.regional.doctype.gst_settings.gst_settings.send_gstin_reminder_to_all_parties') + frappe.msgprint('Email Reminders will be sent to all parties with email contacts') + +def send_gstin_reminder_to_all_parties(): + parties = [] + for address_name in frappe.db.sql('''select name + from tabAddress where country = "India" and ifnull(gstin, '')='' '''): + address = frappe.get_doc('Address', address_name[0]) + for link in address.links: + party = frappe.get_doc(link.link_doctype, link.link_name) + if link.link_doctype in ('Customer', 'Supplier'): + t = (link.link_doctype, link.link_name, address.email_id) + if not t in parties: + parties.append(t) + + sent_to = [] + for party in parties: + # get email from default contact + try: + email_id = _send_gstin_reminder(party[0], party[1], party[2], sent_to) + sent_to.append(email_id) + except EmailMissing: + pass + + +@frappe.whitelist() +def send_gstin_reminder(party_type, party): + '''Send GSTIN reminder to one party (called from Customer, Supplier form)''' + frappe.has_permission(party_type, throw=True) + email = _send_gstin_reminder(party_type ,party) + if email: + frappe.msgprint('Reminder to update GSTIN Sent', title='Reminder sent', indicator='green') + +def _send_gstin_reminder(party_type, party, default_email_id=None, sent_to=None): + '''Send GST Reminder email''' + email_id = frappe.db.get_value('Contact', get_default_contact(party_type, party), 'email_id') + if not email_id: + # get email from address + email_id = default_email_id + + if not email_id: + frappe.throw('Email not found in default contact', exception=EmailMissing) + + if sent_to and email_id in sent_to: + return + + frappe.sendmail( + subject='Please update your GSTIN', + recipients=email_id, + message=''' +

Hello,

+

Please help us send you GST Ready Invoices.

+

+ + Click on the here to update your GSTIN Number in our system + +

+

+ Get your GST Ready ERP system at https://erpnext.com +
+ ERPNext is a free and open source ERP system. +

+ '''.format(os.path.join(get_url(), '/regional/india/update-gstin'), party) + ) + + return email_id + diff --git a/erpnext/regional/india/party.js b/erpnext/regional/india/party.js new file mode 100644 index 0000000000..6b7e85d3cd --- /dev/null +++ b/erpnext/regional/india/party.js @@ -0,0 +1,25 @@ +erpnext.setup_gst_reminder_button = (doctype) => { + frappe.ui.form.on(doctype, { + refresh: (frm) => { + if(!frm.is_new()) { + var missing = false; + frm.doc.__onload.addr_list && frm.doc.__onload.addr_list.forEach((d) => { + if(!d.gstin) missing = true; + }); + if (!missing) return; + + frm.add_custom_button('Send GST Update Reminder', () => { + return new Promise((resolve) => { + return frappe.call({ + method: 'erpnext.regional.doctype.gst_settings.gst_settings.send_gstin_reminder', + args: { + party_type: frm.doc.doctype, + party: frm.doc.name, + } + }).always(() => { resolve(); }); + }); + }); + } + } + }) +}; diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py index 46f0a96f3b..d4f73e56e9 100644 --- a/erpnext/regional/india/setup.py +++ b/erpnext/regional/india/setup.py @@ -64,7 +64,7 @@ def add_custom_roles_for_reports(): )).insert() def add_permissions(): - for doctype in ('GST HSN Code',): + for doctype in ('GST HSN Code', 'GST Settings'): add_permission(doctype, 'Accounts Manager', 0) add_permission(doctype, 'All', 0) diff --git a/erpnext/selling/doctype/customer/regional/india.js b/erpnext/selling/doctype/customer/regional/india.js new file mode 100644 index 0000000000..edb83838b6 --- /dev/null +++ b/erpnext/selling/doctype/customer/regional/india.js @@ -0,0 +1,3 @@ +{% include "erpnext/regional/india/party.js" %} + +erpnext.setup_gst_reminder_button('Customer') \ No newline at end of file diff --git a/erpnext/templates/pages/regional/__init__.py b/erpnext/templates/pages/regional/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/templates/pages/regional/india/__init__.py b/erpnext/templates/pages/regional/india/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/templates/pages/regional/india/update-gstin.html b/erpnext/templates/pages/regional/india/update-gstin.html new file mode 100644 index 0000000000..ab8572552f --- /dev/null +++ b/erpnext/templates/pages/regional/india/update-gstin.html @@ -0,0 +1,37 @@ +{% extends "templates/web.html" %} + +{% block title %}Update GSTIN{% endblock %} + +{% block header %}

Update GSTIN

{% endblock %} + +{% block page_content %} +

{{ party.name }}

+{% if invalid_gstin %} +

+ Invalid GSTIN +

+

+ Edit Again +

+{% elif updated %} +

+ GSTIN Updated +

+

+ Edit Again +

+{% else %} +

Please update your GSTIN for us to issue correct tax invoice

+
+ + {% for address in party.__onload.addr_list %} +
+ {{ address.display }} +

+
+ {% endfor %} +

+
+{% endif %} +{% endblock %} diff --git a/erpnext/templates/pages/regional/india/update_gstin.py b/erpnext/templates/pages/regional/india/update_gstin.py new file mode 100644 index 0000000000..0d4ec37ef7 --- /dev/null +++ b/erpnext/templates/pages/regional/india/update_gstin.py @@ -0,0 +1,40 @@ +import frappe +from frappe import _ + +def get_context(context): + context.no_cache = 1 + party = frappe.form_dict.party + + try: + update_gstin(context) + except frappe.ValidationError: + context.invalid_gstin = 1 + + party_type = 'Customer' + party = frappe.db.get_value('Customer', party) + + if not party: + party_type = 'Supplier' + party = frappe.db.get_value('Supplier', party) + + if not party: + frappe.throw(_("Not Found"), frappe.DoesNotExistError) + + context.party = frappe.get_doc(party_type, party) + context.party.onload() + + +def update_gstin(context): + dirty = False + for key, value in frappe.form_dict.items(): + if key != 'party': + address_name = frappe.get_value('Address', key) + if address_name: + address = frappe.get_doc('Address', address_name) + address.gstin = value + address.save(ignore_permissions=True) + dirty = True + + if dirty: + frappe.db.commit() + context.updated = True