From 1bb6ef3356517a510db18e263eec95065ea0a849 Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Wed, 12 Aug 2020 19:34:23 +0530 Subject: [PATCH] fix: Update state code and union territory for Daman and Diu (#22989) Co-authored-by: Rucha Mahabal --- erpnext/patches.txt | 1 + .../update_state_code_for_daman_and_diu.py | 22 +++++++++++++++++++ erpnext/regional/india/__init__.py | 6 ++--- .../regional/india/gst_state_code_data.json | 7 +----- 4 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 erpnext/patches/v12_0/update_state_code_for_daman_and_diu.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 994d6ca5bee..7a95a56d7b1 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -673,3 +673,4 @@ erpnext.patches.v12_0.set_italian_import_supplier_invoice_permissions execute:frappe.reload_doc("HR", "doctype", "Employee Advance") erpnext.patches.v12_0.move_due_advance_amount_to_pending_amount erpnext.patches.v12_0.set_multi_uom_in_rfq +erpnext.patches.v12_0.update_state_code_for_daman_and_diu diff --git a/erpnext/patches/v12_0/update_state_code_for_daman_and_diu.py b/erpnext/patches/v12_0/update_state_code_for_daman_and_diu.py new file mode 100644 index 00000000000..7450e9cd8c0 --- /dev/null +++ b/erpnext/patches/v12_0/update_state_code_for_daman_and_diu.py @@ -0,0 +1,22 @@ +import frappe +from erpnext.regional.india import states + +def execute(): + + company = frappe.get_all('Company', filters = {'country': 'India'}) + if not company: + return + + # Update options in gst_state custom field + gst_state = frappe.get_doc('Custom Field', 'Address-gst_state') + gst_state.options = '\n'.join(states) + gst_state.save() + + # Update gst_state and state code in existing address + frappe.db.sql(""" + UPDATE `tabAddress` + SET + gst_state = 'Dadra and Nagar Haveli and Daman and Diu', + gst_state_number = 26 + WHERE gst_state = 'Daman and Diu' + """) \ No newline at end of file diff --git a/erpnext/regional/india/__init__.py b/erpnext/regional/india/__init__.py index 0ed98b74eef..d6221a80aa2 100644 --- a/erpnext/regional/india/__init__.py +++ b/erpnext/regional/india/__init__.py @@ -10,8 +10,7 @@ states = [ 'Bihar', 'Chandigarh', 'Chhattisgarh', - 'Dadra and Nagar Haveli', - 'Daman and Diu', + 'Dadra and Nagar Haveli and Daman and Diu', 'Delhi', 'Goa', 'Gujarat', @@ -50,8 +49,7 @@ state_numbers = { "Bihar": "10", "Chandigarh": "04", "Chhattisgarh": "22", - "Dadra and Nagar Haveli": "26", - "Daman and Diu": "25", + "Dadra and Nagar Haveli and Daman and Diu": "26", "Delhi": "07", "Goa": "30", "Gujarat": "24", diff --git a/erpnext/regional/india/gst_state_code_data.json b/erpnext/regional/india/gst_state_code_data.json index 6dab81d6688..ff88e0f9d6c 100644 --- a/erpnext/regional/india/gst_state_code_data.json +++ b/erpnext/regional/india/gst_state_code_data.json @@ -134,15 +134,10 @@ "state_code": "DL", "state_name": "Delhi" }, - { - "state_number": "25", - "state_code": "DD", - "state_name": "Daman and Diu" - }, { "state_number": "26", "state_code": "DN", - "state_name": "Dadra and Nagar Haveli" + "state_name": "Dadra and Nagar Haveli and Daman and Diu" }, { "state_number": "22",