blob: 633064cf09475beee64c3a0cc69a518d1d3db813 [file] [log] [blame]
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5
6import frappe, os, json
Rushabh Mehtaf0569742017-09-13 12:52:30 +05307from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
Sagar Vora4c31fbb2021-04-01 15:32:37 +05308from frappe.custom.doctype.property_setter.property_setter import make_property_setter
Nabin Hait49b41e42019-01-24 17:55:44 +05309from frappe.permissions import add_permission, update_permission_property
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053010from erpnext.regional.india import states
Anuja Pawar4569e522021-01-14 19:24:30 +053011from erpnext.accounts.utils import get_fiscal_year, FiscalYearError
Zarrar7f8024c2018-08-01 17:45:05 +053012from frappe.utils import today
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053013
Rushabh Mehta01659272017-06-27 18:05:17 +053014def setup(company=None, patch=True):
Deepesh Gargfea29ae2021-07-12 18:29:52 +053015 # Company independent fixtures should be called only once at the first company setup
16 if frappe.db.count('Company', {'country': 'India'}) <=1:
17 setup_company_independent_fixtures(patch=patch)
18
Prateeksha Singh39b87652018-11-12 17:19:56 +053019 if not patch:
Prateeksha Singhdabf3492018-11-13 15:56:15 +053020 make_fixtures(company)
Prateeksha Singh39b87652018-11-12 17:19:56 +053021
22# TODO: for all countries
Nabin Hait10c61372021-04-13 15:46:01 +053023def setup_company_independent_fixtures(patch=False):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053024 make_custom_fields()
Nabin Hait10c61372021-04-13 15:46:01 +053025 make_property_setters(patch=patch)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053026 add_permissions()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053027 add_custom_roles_for_reports()
Nabin Haitc3144852017-09-28 18:55:40 +053028 frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes', now=frappe.flags.in_test)
Anurag Mishra25c35682020-08-18 14:13:54 +053029 create_gratuity_rule()
Nabin Hait852cb642017-07-05 12:58:19 +053030 add_print_formats()
Deepesh Garg204ea102021-04-30 16:35:52 +053031 update_accounts_settings_for_taxes()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053032
Nabin Hait1a609312017-07-13 12:16:04 +053033def add_hsn_sac_codes():
Ankush Menat5bb89b02021-06-11 15:57:01 +053034 if frappe.flags.in_test and frappe.flags.created_hsn_codes:
35 return
36
Nabin Hait1a609312017-07-13 12:16:04 +053037 # HSN codes
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053038 with open(os.path.join(os.path.dirname(__file__), 'hsn_code_data.json'), 'r') as f:
39 hsn_codes = json.loads(f.read())
40
Nabin Hait1a609312017-07-13 12:16:04 +053041 create_hsn_codes(hsn_codes, code_field="hsn_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053042
Nabin Hait1a609312017-07-13 12:16:04 +053043 # SAC Codes
44 with open(os.path.join(os.path.dirname(__file__), 'sac_code_data.json'), 'r') as f:
45 sac_codes = json.loads(f.read())
46 create_hsn_codes(sac_codes, code_field="sac_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053047
Ankush Menat5bb89b02021-06-11 15:57:01 +053048 if frappe.flags.in_test:
49 frappe.flags.created_hsn_codes = True
50
Nabin Hait1a609312017-07-13 12:16:04 +053051def create_hsn_codes(data, code_field):
52 for d in data:
Rushabh Mehtaf702d722017-09-27 15:31:30 +053053 hsn_code = frappe.new_doc('GST HSN Code')
54 hsn_code.description = d["description"]
55 hsn_code.hsn_code = d[code_field]
56 hsn_code.name = d[code_field]
57 try:
Nabin Hait1a609312017-07-13 12:16:04 +053058 hsn_code.db_insert()
Rushabh Mehtaf702d722017-09-27 15:31:30 +053059 except frappe.DuplicateEntryError:
60 pass
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053061
Rushabh Mehta919a74a2017-06-22 16:37:04 +053062def add_custom_roles_for_reports():
63 for report_name in ('GST Sales Register', 'GST Purchase Register',
Saqibc3359622021-08-20 11:10:46 +053064 'GST Itemised Sales Register', 'GST Itemised Purchase Register', 'Eway Bill'):
Rushabh Mehta919a74a2017-06-22 16:37:04 +053065
Rushabh Mehta919a74a2017-06-22 16:37:04 +053066 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
67 frappe.get_doc(dict(
68 doctype='Custom Role',
69 report=report_name,
70 roles= [
71 dict(role='Accounts User'),
72 dict(role='Accounts Manager')
73 ]
74 )).insert()
75
Anurag Mishra289c8222020-06-19 19:17:57 +053076 for report_name in ('Professional Tax Deductions', 'Provident Fund Deductions'):
77
78 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
79 frappe.get_doc(dict(
80 doctype='Custom Role',
81 report=report_name,
82 roles= [
83 dict(role='HR User'),
84 dict(role='HR Manager'),
85 dict(role='Employee')
86 ]
87 )).insert()
88
Anurag Mishra54cd1942020-09-03 13:51:26 +053089 for report_name in ('HSN-wise-summary of outward supplies', 'GSTR-1', 'GSTR-2'):
90
91 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
92 frappe.get_doc(dict(
93 doctype='Custom Role',
94 report=report_name,
95 roles= [
96 dict(role='Accounts User'),
97 dict(role='Accounts Manager'),
98 dict(role='Auditor')
99 ]
100 )).insert()
101
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530102def add_permissions():
Saqibc3359622021-08-20 11:10:46 +0530103 for doctype in ('GST HSN Code', 'GST Settings', 'GSTR 3B Report', 'Lower Deduction Certificate'):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530104 add_permission(doctype, 'All', 0)
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530105 for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
Saqib5e6ce882020-02-03 15:40:35 +0530106 add_permission(doctype, role, 0)
107 update_permission_property(doctype, role, 0, 'write', 1)
108 update_permission_property(doctype, role, 0, 'create', 1)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530109
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530110 if doctype == 'GST HSN Code':
111 for role in ('Item Manager', 'Stock Manager'):
112 add_permission(doctype, role, 0)
113 update_permission_property(doctype, role, 0, 'write', 1)
114 update_permission_property(doctype, role, 0, 'create', 1)
115
Nabin Hait852cb642017-07-05 12:58:19 +0530116def add_print_formats():
117 frappe.reload_doc("regional", "print_format", "gst_tax_invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530118 frappe.reload_doc("accounts", "print_format", "gst_pos_invoice")
119
barredterra1521b312021-03-03 12:33:48 +0100120 frappe.db.set_value("Print Format", "GST POS Invoice", "disabled", 0)
121 frappe.db.set_value("Print Format", "GST Tax Invoice", "disabled", 0)
Nabin Hait852cb642017-07-05 12:58:19 +0530122
Nabin Hait10c61372021-04-13 15:46:01 +0530123def make_property_setters(patch=False):
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530124 # GST rules do not allow for an invoice no. bigger than 16 characters
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530125 journal_entry_types = frappe.get_meta("Journal Entry").get_options("voucher_type").split("\n") + ['Reversal Of ITC']
Deepesh Garg2b340282021-09-02 22:01:24 +0530126 sales_invoice_series = ['SINV-.YY.-', 'SRET-.YY.-', ''] + frappe.get_meta("Sales Invoice").get_options("naming_series").split("\n")
127 purchase_invoice_series = ['PINV-.YY.-', 'PRET-.YY.-', ''] + frappe.get_meta("Purchase Invoice").get_options("naming_series").split("\n")
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530128
Nabin Hait10c61372021-04-13 15:46:01 +0530129 if not patch:
Deepesh Garg7be9f8d2021-07-10 20:23:52 +0530130 make_property_setter('Sales Invoice', 'naming_series', 'options', '\n'.join(sales_invoice_series), '')
131 make_property_setter('Purchase Invoice', 'naming_series', 'options', '\n'.join(purchase_invoice_series), '')
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530132 make_property_setter('Journal Entry', 'voucher_type', 'options', '\n'.join(journal_entry_types), '')
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530133
Rushabh Mehta69fa8082018-07-17 18:22:51 +0530134def make_custom_fields(update=True):
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530135 hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
Nabin Haitd34bfa82018-11-13 18:19:58 +0530136 fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description',
Nabin Haitf4af6082019-04-01 11:51:54 +0530137 allow_on_submit=1, print_hide=1, fetch_if_empty=1)
Marica9942acd2020-04-21 13:13:39 +0530138 nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530139 fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code',
140 print_hide=1)
141 is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST',
142 fieldtype='Check', fetch_from='item_code.is_non_gst', insert_after='is_nil_exempt',
143 print_hide=1)
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530144 taxable_value = dict(fieldname='taxable_value', label='Taxable Value',
145 fieldtype='Currency', insert_after='base_net_amount', hidden=1, options="Company:company:default_currency",
146 print_hide=1)
Deepesh Garg22b61602019-03-21 20:47:47 +0530147
148 purchase_invoice_gst_category = [
Nabin Hait879e1622017-08-21 08:28:55 +0530149 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
vishdha109b4082018-01-30 12:11:13 +0530150 insert_after='language', print_hide=1, collapsible=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530151 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530152 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530153 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530154 fetch_from='supplier.gst_category', fetch_if_empty=1),
155 dict(fieldname='export_type', label='Export Type',
156 fieldtype='Select', insert_after='gst_category', print_hide=1,
157 depends_on='eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
158 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='supplier.export_type',
159 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530160 ]
161
162 sales_invoice_gst_category = [
163 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
164 insert_after='language', print_hide=1, collapsible=1),
165 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530166 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530167 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530168 fetch_from='customer.gst_category', fetch_if_empty=1),
169 dict(fieldname='export_type', label='Export Type',
170 fieldtype='Select', insert_after='gst_category', print_hide=1,
171 depends_on='eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
172 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='customer.export_type',
173 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530174 ]
175
Deepesh Garg29997412021-03-29 19:49:52 +0530176 delivery_note_gst_category = [
177 dict(fieldname='gst_category', label='GST Category',
178 fieldtype='Select', insert_after='gst_vehicle_type', print_hide=1,
179 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
180 fetch_from='customer.gst_category', fetch_if_empty=1),
181 ]
182
Deepesh Garg22b61602019-03-21 20:47:47 +0530183 invoice_gst_fields = [
Nabin Hait879e1622017-08-21 08:28:55 +0530184 dict(fieldname='invoice_copy', label='Invoice Copy',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530185 fieldtype='Select', insert_after='export_type', print_hide=1, allow_on_submit=1,
Nabin Hait879e1622017-08-21 08:28:55 +0530186 options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'),
187 dict(fieldname='reverse_charge', label='Reverse Charge',
188 fieldtype='Select', insert_after='invoice_copy', print_hide=1,
189 options='Y\nN', default='N'),
Nabin Hait879e1622017-08-21 08:28:55 +0530190 dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN',
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530191 fieldtype='Data', insert_after='export_type', print_hide=1),
Nabin Haite6d65bc2018-02-14 17:44:06 +0530192 dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='ecommerce_gstin'),
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530193 dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document',
Nabin Haitb02c1092018-02-05 16:09:51 +0530194 fieldtype='Select', insert_after='gst_col_break', print_hide=1,
Nabin Haite6d65bc2018-02-14 17:44:06 +0530195 depends_on='eval:doc.is_return==1',
Nabin Haita8d10b72018-02-12 16:54:13 +0530196 options='\n01-Sales Return\n02-Post Sale Discount\n03-Deficiency in services\n04-Correction in Invoice\n05-Change in POS\n06-Finalization of Provisional assessment\n07-Others')
Nabin Hait879e1622017-08-21 08:28:55 +0530197 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530198
Nabin Hait879e1622017-08-21 08:28:55 +0530199 purchase_invoice_gst_fields = [
200 dict(fieldname='supplier_gstin', label='Supplier GSTIN',
201 fieldtype='Data', insert_after='supplier_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530202 fetch_from='supplier_address.gstin', print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530203 dict(fieldname='company_gstin', label='Company GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530204 fieldtype='Data', insert_after='shipping_address_display',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530205 fetch_from='shipping_address.gstin', print_hide=1, read_only=1),
Nabin Haitb02c1092018-02-05 16:09:51 +0530206 dict(fieldname='place_of_supply', label='Place of Supply',
207 fieldtype='Data', insert_after='shipping_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530208 print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530209 ]
210
211 purchase_invoice_itc_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530212 dict(fieldname='eligibility_for_itc', label='Eligibility For ITC',
213 fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530214 options='Input Service Distributor\nImport Of Service\nImport Of Capital Goods\nITC on Reverse Charge\nIneligible As Per Section 17(5)\nIneligible Others\nAll Other ITC',
215 default="All Other ITC"),
vishdha98e33c32018-01-29 13:57:34 +0530216 dict(fieldname='itc_integrated_tax', label='Availed ITC Integrated Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530217 fieldtype='Currency', insert_after='eligibility_for_itc',
218 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530219 dict(fieldname='itc_central_tax', label='Availed ITC Central Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530220 fieldtype='Currency', insert_after='itc_integrated_tax',
221 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530222 dict(fieldname='itc_state_tax', label='Availed ITC State/UT Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530223 fieldtype='Currency', insert_after='itc_central_tax',
224 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530225 dict(fieldname='itc_cess_amount', label='Availed ITC Cess',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530226 fieldtype='Currency', insert_after='itc_state_tax',
227 options='Company:company:default_currency', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530228 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530229
Nabin Hait879e1622017-08-21 08:28:55 +0530230 sales_invoice_gst_fields = [
rohitwaghchaure16645802017-09-28 11:05:03 +0530231 dict(fieldname='billing_address_gstin', label='Billing Address GSTIN',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530232 fieldtype='Data', insert_after='customer_address', read_only=1,
Shreya Shah4fa600a2018-06-05 11:27:53 +0530233 fetch_from='customer_address.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530234 dict(fieldname='customer_gstin', label='Customer GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530235 fieldtype='Data', insert_after='shipping_address_name',
236 fetch_from='shipping_address_name.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530237 dict(fieldname='place_of_supply', label='Place of Supply',
Nabin Hait619c42b2018-01-10 17:48:03 +0530238 fieldtype='Data', insert_after='customer_gstin',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530239 print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530240 dict(fieldname='company_gstin', label='Company GSTIN',
241 fieldtype='Data', insert_after='company_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530242 fetch_from='company_address.gstin', print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530243 ]
244
245 sales_invoice_shipping_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530246 dict(fieldname='port_code', label='Port Code',
247 fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530248 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530249 dict(fieldname='shipping_bill_number', label=' Shipping Bill Number',
250 fieldtype='Data', insert_after='port_code', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530251 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530252 dict(fieldname='shipping_bill_date', label='Shipping Bill Date',
253 fieldtype='Date', insert_after='shipping_bill_number', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530254 depends_on="eval:doc.gst_category=='Overseas' "),
Nabin Hait879e1622017-08-21 08:28:55 +0530255 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530256
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530257 journal_entry_fields = [
258 dict(fieldname='reversal_type', label='Reversal Type',
259 fieldtype='Select', insert_after='voucher_type', print_hide=1,
260 options="As per rules 42 & 43 of CGST Rules\nOthers",
261 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
262 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
263 dict(fieldname='company_address', label='Company Address',
264 fieldtype='Link', options='Address', insert_after='reversal_type',
265 print_hide=1, depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
266 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
267 dict(fieldname='company_gstin', label='Company GSTIN',
268 fieldtype='Data', read_only=1, insert_after='company_address', print_hide=1,
269 fetch_from='company_address.gstin',
270 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
271 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'")
272 ]
273
Shreya Shah4fa600a2018-06-05 11:27:53 +0530274 inter_state_gst_field = [
275 dict(fieldname='is_inter_state', label='Is Inter State',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530276 fieldtype='Check', insert_after='disabled', print_hide=1),
277 dict(fieldname='tax_category_column_break', fieldtype='Column Break',
278 insert_after='is_inter_state'),
279 dict(fieldname='gst_state', label='Source State', fieldtype='Select',
280 options='\n'.join(states), insert_after='company')
Shreya Shah4fa600a2018-06-05 11:27:53 +0530281 ]
282
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530283 ewaybill_fields = [
284 {
285 'fieldname': 'distance',
286 'label': 'Distance (in km)',
287 'fieldtype': 'Float',
288 'insert_after': 'vehicle_no',
289 'print_hide': 1
290 },
291 {
292 'fieldname': 'gst_transporter_id',
293 'label': 'GST Transporter ID',
294 'fieldtype': 'Data',
Nabin Hait34c551d2019-07-03 10:34:31 +0530295 'insert_after': 'transporter',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530296 'fetch_from': 'transporter.gst_transporter_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530297 'print_hide': 1,
298 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530299 },
300 {
301 'fieldname': 'mode_of_transport',
302 'label': 'Mode of Transport',
303 'fieldtype': 'Select',
304 'options': '\nRoad\nAir\nRail\nShip',
305 'default': 'Road',
Nabin Hait34c551d2019-07-03 10:34:31 +0530306 'insert_after': 'transporter_name',
307 'print_hide': 1,
308 'translatable': 0
309 },
310 {
311 'fieldname': 'gst_vehicle_type',
312 'label': 'GST Vehicle Type',
313 'fieldtype': 'Select',
314 'options': 'Regular\nOver Dimensional Cargo (ODC)',
315 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
316 'default': 'Regular',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530317 'insert_after': 'lr_date',
Nabin Hait34c551d2019-07-03 10:34:31 +0530318 'print_hide': 1,
319 'translatable': 0
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530320 },
321 {
322 'fieldname': 'ewaybill',
323 'label': 'E-Way Bill No.',
324 'fieldtype': 'Data',
325 'depends_on': 'eval:(doc.docstatus === 1)',
326 'allow_on_submit': 1,
327 'insert_after': 'customer_name_in_arabic',
328 'translatable': 0,
Deepesh Garg29997412021-03-29 19:49:52 +0530329 }
Nabin Hait34c551d2019-07-03 10:34:31 +0530330 ]
331
332 si_ewaybill_fields = [
333 {
334 'fieldname': 'transporter_info',
335 'label': 'Transporter Info',
336 'fieldtype': 'Section Break',
337 'insert_after': 'terms',
338 'collapsible': 1,
339 'collapsible_depends_on': 'transporter',
340 'print_hide': 1
341 },
342 {
343 'fieldname': 'transporter',
344 'label': 'Transporter',
345 'fieldtype': 'Link',
346 'insert_after': 'transporter_info',
347 'options': 'Supplier',
348 'print_hide': 1
349 },
350 {
351 'fieldname': 'gst_transporter_id',
352 'label': 'GST Transporter ID',
353 'fieldtype': 'Data',
354 'insert_after': 'transporter',
355 'fetch_from': 'transporter.gst_transporter_id',
356 'print_hide': 1,
357 'translatable': 0
358 },
359 {
360 'fieldname': 'driver',
361 'label': 'Driver',
362 'fieldtype': 'Link',
363 'insert_after': 'gst_transporter_id',
364 'options': 'Driver',
365 'print_hide': 1
366 },
367 {
368 'fieldname': 'lr_no',
369 'label': 'Transport Receipt No',
370 'fieldtype': 'Data',
371 'insert_after': 'driver',
372 'print_hide': 1,
373 'translatable': 0
374 },
375 {
376 'fieldname': 'vehicle_no',
377 'label': 'Vehicle No',
378 'fieldtype': 'Data',
379 'insert_after': 'lr_no',
380 'print_hide': 1,
381 'translatable': 0
382 },
383 {
384 'fieldname': 'distance',
385 'label': 'Distance (in km)',
386 'fieldtype': 'Float',
387 'insert_after': 'vehicle_no',
388 'print_hide': 1
389 },
390 {
391 'fieldname': 'transporter_col_break',
392 'fieldtype': 'Column Break',
393 'insert_after': 'distance'
394 },
395 {
396 'fieldname': 'transporter_name',
397 'label': 'Transporter Name',
398 'fieldtype': 'Data',
399 'insert_after': 'transporter_col_break',
400 'fetch_from': 'transporter.name',
401 'read_only': 1,
402 'print_hide': 1,
403 'translatable': 0
404 },
405 {
406 'fieldname': 'mode_of_transport',
407 'label': 'Mode of Transport',
408 'fieldtype': 'Select',
409 'options': '\nRoad\nAir\nRail\nShip',
Nabin Hait34c551d2019-07-03 10:34:31 +0530410 'insert_after': 'transporter_name',
411 'print_hide': 1,
412 'translatable': 0
413 },
414 {
415 'fieldname': 'driver_name',
416 'label': 'Driver Name',
417 'fieldtype': 'Data',
418 'insert_after': 'mode_of_transport',
419 'fetch_from': 'driver.full_name',
420 'print_hide': 1,
421 'translatable': 0
422 },
423 {
424 'fieldname': 'lr_date',
425 'label': 'Transport Receipt Date',
426 'fieldtype': 'Date',
427 'insert_after': 'driver_name',
428 'default': 'Today',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530429 'print_hide': 1
430 },
431 {
432 'fieldname': 'gst_vehicle_type',
433 'label': 'GST Vehicle Type',
434 'fieldtype': 'Select',
Nabin Hait34c551d2019-07-03 10:34:31 +0530435 'options': 'Regular\nOver Dimensional Cargo (ODC)',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530436 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
Nabin Hait34c551d2019-07-03 10:34:31 +0530437 'default': 'Regular',
438 'insert_after': 'lr_date',
439 'print_hide': 1,
440 'translatable': 0
441 },
442 {
443 'fieldname': 'ewaybill',
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530444 'label': 'E-Way Bill No.',
Nabin Hait34c551d2019-07-03 10:34:31 +0530445 'fieldtype': 'Data',
Saqibc3359622021-08-20 11:10:46 +0530446 'depends_on': 'eval:(doc.docstatus === 1)',
Nabin Hait34c551d2019-07-03 10:34:31 +0530447 'allow_on_submit': 1,
deepeshgarg007a85db662019-07-14 18:15:19 +0530448 'insert_after': 'tax_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530449 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530450 }
451 ]
452
Deepesh Garge8a5dc32021-09-02 18:56:04 +0530453 payment_entry_fields = [
454 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break', insert_after='deductions',
455 print_hide=1, collapsible=1),
456 dict(fieldname='company_address', label='Company Address', fieldtype='Link', insert_after='gst_section',
457 print_hide=1, options='Address'),
458 dict(fieldname='company_gstin', label='Company GSTIN',
459 fieldtype='Data', insert_after='company_address',
460 fetch_from='company_address.gstin', print_hide=1, read_only=1),
461 dict(fieldname='place_of_supply', label='Place of Supply',
462 fieldtype='Data', insert_after='company_gstin',
463 print_hide=1, read_only=1),
464 dict(fieldname='gst_column_break', fieldtype='Column Break',
465 insert_after='place_of_supply'),
466 dict(fieldname='customer_address', label='Customer Address', fieldtype='Link', insert_after='gst_column_break',
467 print_hide=1, options='Address', depends_on = 'eval:doc.party_type == "Customer"'),
468 dict(fieldname='customer_gstin', label='Customer GSTIN',
469 fieldtype='Data', insert_after='customer_address',
470 fetch_from='customer_address.gstin', print_hide=1, read_only=1)
471 ]
472
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530473 custom_fields = {
474 'Address': [
Rushabh Mehta919a74a2017-06-22 16:37:04 +0530475 dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data',
476 insert_after='fax'),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530477 dict(fieldname='gst_state', label='GST State', fieldtype='Select',
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530478 options='\n'.join(states), insert_after='gstin'),
479 dict(fieldname='gst_state_number', label='GST State Number',
Nabin Hait562d9422018-09-07 16:14:44 +0530480 fieldtype='Data', insert_after='gst_state', read_only=1),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530481 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530482 'Purchase Invoice': purchase_invoice_gst_category + invoice_gst_fields + purchase_invoice_itc_fields + purchase_invoice_gst_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530483 'Purchase Order': purchase_invoice_gst_fields,
484 'Purchase Receipt': purchase_invoice_gst_fields,
Saqibc3359622021-08-20 11:10:46 +0530485 'Sales Invoice': sales_invoice_gst_category + invoice_gst_fields + sales_invoice_shipping_fields + sales_invoice_gst_fields + si_ewaybill_fields,
Subin Tomd49346a2021-09-17 10:39:03 +0530486 'POS Invoice': sales_invoice_gst_fields,
Deepesh Garg29997412021-03-29 19:49:52 +0530487 'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields + delivery_note_gst_category,
Deepesh Garg8b644d82021-07-15 15:36:54 +0530488 'Payment Entry': payment_entry_fields,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530489 'Journal Entry': journal_entry_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530490 'Sales Order': sales_invoice_gst_fields,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530491 'Tax Category': inter_state_gst_field,
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530492 'Item': [
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530493 dict(fieldname='gst_hsn_code', label='HSN/SAC',
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530494 fieldtype='Link', options='GST HSN Code', insert_after='item_group'),
Marica9942acd2020-04-21 13:13:39 +0530495 dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530496 fieldtype='Check', insert_after='gst_hsn_code'),
497 dict(fieldname='is_non_gst', label='Is Non GST ',
498 fieldtype='Check', insert_after='is_nil_exempt')
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530499 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530500 'Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
501 'Supplier Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
502 'Sales Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
503 'Delivery Note Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530504 'Sales Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Subin Tomd49346a2021-09-17 10:39:03 +0530505 'POS Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Deepesh Garg22b61602019-03-21 20:47:47 +0530506 'Purchase Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
507 'Purchase Receipt Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530508 'Purchase Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Himanshu Warekar656d8e42019-04-01 19:38:43 +0530509 'Material Request Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Anurag Mishra289c8222020-06-19 19:17:57 +0530510 'Salary Component': [
511 dict(fieldname= 'component_type',
512 label= 'Component Type',
513 fieldtype= 'Select',
514 insert_after= 'description',
515 options= "\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax",
516 depends_on = 'eval:doc.type == "Deduction"'
517 )
518 ],
Pawan Mehtaf4196352018-04-05 14:54:51 +0530519 'Employee': [
Anurag Mishra289c8222020-06-19 19:17:57 +0530520 dict(fieldname='ifsc_code',
521 label='IFSC Code',
522 fieldtype='Data',
523 insert_after='bank_ac_no',
524 print_hide=1,
525 depends_on='eval:doc.salary_mode == "Bank"'
526 ),
527 dict(
528 fieldname = 'pan_number',
529 label = 'PAN Number',
530 fieldtype = 'Data',
531 insert_after = 'payroll_cost_center',
532 print_hide = 1
533 ),
534 dict(
535 fieldname = 'micr_code',
536 label = 'MICR Code',
537 fieldtype = 'Data',
538 insert_after = 'ifsc_code',
539 print_hide = 1,
540 depends_on='eval:doc.salary_mode == "Bank"'
541 ),
542 dict(
543 fieldname = 'provident_fund_account',
544 label = 'Provident Fund Account',
545 fieldtype = 'Data',
546 insert_after = 'pan_number'
547 )
548
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530549 ],
550 'Company': [
551 dict(fieldname='hra_section', label='HRA Settings',
Anurag Mishraa5527222019-06-14 15:25:57 +0530552 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530553 dict(fieldname='basic_component', label='Basic Component',
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530554 fieldtype='Link', options='Salary Component', insert_after='hra_section'),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530555 dict(fieldname='hra_component', label='HRA Component',
556 fieldtype='Link', options='Salary Component', insert_after='basic_component'),
Saqibce129a12021-08-24 17:23:14 +0530557 dict(fieldname='hra_column_break', fieldtype='Column Break', insert_after='hra_component'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530558 dict(fieldname='arrear_component', label='Arrear Component',
Mangesh-Khairnar9215de02019-05-06 16:24:10 +0530559 fieldtype='Link', options='Salary Component', insert_after='hra_component'),
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530560 dict(fieldname='non_profit_section', label='Non Profit Settings',
561 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
562 dict(fieldname='company_80g_number', label='80G Number',
563 fieldtype='Data', insert_after='non_profit_section'),
564 dict(fieldname='with_effect_from', label='80G With Effect From',
565 fieldtype='Date', insert_after='company_80g_number'),
Saqibce129a12021-08-24 17:23:14 +0530566 dict(fieldname='non_profit_column_break', fieldtype='Column Break', insert_after='with_effect_from'),
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530567 dict(fieldname='pan_details', label='PAN Number',
568 fieldtype='Data', insert_after='with_effect_from')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530569 ],
570 'Employee Tax Exemption Declaration':[
571 dict(fieldname='hra_section', label='HRA Exemption',
572 fieldtype='Section Break', insert_after='declarations'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530573 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530574 fieldtype='Currency', insert_after='hra_section'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530575 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530576 fieldtype='Check', insert_after='monthly_house_rent', depends_on='monthly_house_rent'),
577 dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure',
578 fieldtype='Currency', insert_after='rented_in_metro_city', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530579 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530580 insert_after='salary_structure_hra', depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530581 dict(fieldname='annual_hra_exemption', label='Annual HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530582 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530583 dict(fieldname='monthly_hra_exemption', label='Monthly HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530584 fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1, depends_on='monthly_house_rent')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530585 ],
586 'Employee Tax Exemption Proof Submission': [
587 dict(fieldname='hra_section', label='HRA Exemption',
588 fieldtype='Section Break', insert_after='tax_exemption_proofs'),
589 dict(fieldname='house_rent_payment_amount', label='House Rent Payment Amount',
590 fieldtype='Currency', insert_after='hra_section'),
591 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530592 fieldtype='Check', insert_after='house_rent_payment_amount', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530593 dict(fieldname='rented_from_date', label='Rented From Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530594 fieldtype='Date', insert_after='rented_in_metro_city', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530595 dict(fieldname='rented_to_date', label='Rented To Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530596 fieldtype='Date', insert_after='rented_from_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530597 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530598 insert_after='rented_to_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530599 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530600 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530601 dict(fieldname='monthly_hra_exemption', label='Monthly Eligible Amount',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530602 fieldtype='Currency', insert_after='monthly_house_rent', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530603 dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530604 fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1, depends_on='house_rent_payment_amount')
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530605 ],
606 'Supplier': [
607 {
608 'fieldname': 'gst_transporter_id',
609 'label': 'GST Transporter ID',
610 'fieldtype': 'Data',
611 'insert_after': 'supplier_type',
612 'depends_on': 'eval:doc.is_transporter'
Deepesh Garg22b61602019-03-21 20:47:47 +0530613 },
614 {
615 'fieldname': 'gst_category',
616 'label': 'GST Category',
617 'fieldtype': 'Select',
618 'insert_after': 'gst_transporter_id',
619 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
620 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530621 },
622 {
623 'fieldname': 'export_type',
624 'label': 'Export Type',
625 'fieldtype': 'Select',
626 'insert_after': 'gst_category',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530627 'depends_on':'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
Deepesh Garg3f07bb72021-08-16 13:18:39 +0530628 'options': '\nWith Payment of Tax\nWithout Payment of Tax',
629 'mandatory_depends_on': 'eval:in_list(["SEZ", "Overseas"], doc.gst_category)'
Deepesh Garg22b61602019-03-21 20:47:47 +0530630 }
631 ],
632 'Customer': [
633 {
634 'fieldname': 'gst_category',
635 'label': 'GST Category',
636 'fieldtype': 'Select',
637 'insert_after': 'customer_type',
638 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
639 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530640 },
641 {
642 'fieldname': 'export_type',
643 'label': 'Export Type',
644 'fieldtype': 'Select',
645 'insert_after': 'gst_category',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530646 'depends_on':'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
Deepesh Garg3f07bb72021-08-16 13:18:39 +0530647 'options': '\nWith Payment of Tax\nWithout Payment of Tax',
648 'mandatory_depends_on': 'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)'
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530649 }
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530650 ],
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530651 'Member': [
652 {
653 'fieldname': 'pan_number',
654 'label': 'PAN Details',
655 'fieldtype': 'Data',
656 'insert_after': 'email_id'
657 }
658 ],
659 'Donor': [
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530660 {
661 'fieldname': 'pan_number',
662 'label': 'PAN Details',
663 'fieldtype': 'Data',
664 'insert_after': 'email'
665 }
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530666 ]
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530667 }
Deepesh Garg22b61602019-03-21 20:47:47 +0530668 create_custom_fields(custom_fields, update=update)
Nabin Hait9c421612017-07-20 13:32:01 +0530669
Saurabh2d8a7ee2018-05-11 13:16:16 +0530670def make_fixtures(company=None):
671 docs = []
Deepesh Garga66184f2021-05-02 12:22:16 +0530672 company = company or frappe.db.get_value("Global Defaults", None, "default_company")
Saurabh2d8a7ee2018-05-11 13:16:16 +0530673
674 set_salary_components(docs)
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530675 set_tds_account(docs, company)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530676
677 for d in docs:
678 try:
679 doc = frappe.get_doc(d)
680 doc.flags.ignore_permissions = True
681 doc.insert()
682 except frappe.NameError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530683 frappe.clear_messages()
Zarrar7f8024c2018-08-01 17:45:05 +0530684 except frappe.DuplicateEntryError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530685 frappe.clear_messages()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530686
Zarrar7f8024c2018-08-01 17:45:05 +0530687 # create records for Tax Withholding Category
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530688 set_tax_withholding_category(company)
689
Deepesh Gargb3ed8072021-06-02 13:26:21 +0530690def update_regional_tax_settings(country, company):
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530691 # Will only add default GST accounts if present
692 input_account_names = ['Input Tax CGST', 'Input Tax SGST', 'Input Tax IGST']
693 output_account_names = ['Output Tax CGST', 'Output Tax SGST', 'Output Tax IGST']
Deepesh Garg48b1a822021-05-29 23:54:51 +0530694 rcm_accounts = ['Input Tax CGST RCM', 'Input Tax SGST RCM', 'Input Tax IGST RCM']
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530695 gst_settings = frappe.get_single('GST Settings')
696 existing_account_list = []
697
698 for account in gst_settings.get('gst_accounts'):
699 for key in ['cgst_account', 'sgst_account', 'igst_account']:
700 existing_account_list.append(account.get(key))
701
702 gst_accounts = frappe._dict(frappe.get_all("Account",
Deepesh Garg48b1a822021-05-29 23:54:51 +0530703 {'company': company, 'account_name': ('in', input_account_names +
704 output_account_names + rcm_accounts)}, ['account_name', 'name'], as_list=1))
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530705
Deepesh Garg48b1a822021-05-29 23:54:51 +0530706 add_accounts_in_gst_settings(company, input_account_names, gst_accounts,
707 existing_account_list, gst_settings)
708 add_accounts_in_gst_settings(company, output_account_names, gst_accounts,
709 existing_account_list, gst_settings)
710 add_accounts_in_gst_settings(company, rcm_accounts, gst_accounts,
711 existing_account_list, gst_settings, is_reverse_charge=1)
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530712
713 gst_settings.save()
714
Deepesh Garg48b1a822021-05-29 23:54:51 +0530715def add_accounts_in_gst_settings(company, account_names, gst_accounts,
716 existing_account_list, gst_settings, is_reverse_charge=0):
717 accounts_not_added = 1
718
719 for account in account_names:
720 # Default Account Added does not exists
721 if not gst_accounts.get(account):
722 accounts_not_added = 0
723
724 # Check if already added in GST Settings
725 if gst_accounts.get(account) in existing_account_list:
726 accounts_not_added = 0
727
728 if accounts_not_added:
729 gst_settings.append('gst_accounts', {
730 'company': company,
731 'cgst_account': gst_accounts.get(account_names[0]),
732 'sgst_account': gst_accounts.get(account_names[1]),
733 'igst_account': gst_accounts.get(account_names[2]),
734 'is_reverse_charge_account': is_reverse_charge
735 })
736
Saurabh2d8a7ee2018-05-11 13:16:16 +0530737def set_salary_components(docs):
738 docs.extend([
Nabin Hait58ee6c12020-04-26 17:45:57 +0530739 {'doctype': 'Salary Component', 'salary_component': 'Professional Tax',
740 'description': 'Professional Tax', 'type': 'Deduction', 'exempted_from_income_tax': 1},
741 {'doctype': 'Salary Component', 'salary_component': 'Provident Fund',
742 'description': 'Provident fund', 'type': 'Deduction', 'is_tax_applicable': 1},
743 {'doctype': 'Salary Component', 'salary_component': 'House Rent Allowance',
744 'description': 'House Rent Allowance', 'type': 'Earning', 'is_tax_applicable': 1},
745 {'doctype': 'Salary Component', 'salary_component': 'Basic',
746 'description': 'Basic', 'type': 'Earning', 'is_tax_applicable': 1},
747 {'doctype': 'Salary Component', 'salary_component': 'Arrear',
748 'description': 'Arrear', 'type': 'Earning', 'is_tax_applicable': 1},
749 {'doctype': 'Salary Component', 'salary_component': 'Leave Encashment',
750 'description': 'Leave Encashment', 'type': 'Earning', 'is_tax_applicable': 1}
Saurabh2d8a7ee2018-05-11 13:16:16 +0530751 ])
752
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530753def set_tax_withholding_category(company):
Saurabh2d8a7ee2018-05-11 13:16:16 +0530754 accounts = []
Saqibf8c1c732021-09-26 16:27:56 +0530755 fiscal_year_details = None
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530756 abbr = frappe.get_value("Company", company, "abbr")
757 tds_account = frappe.get_value("Account", 'TDS Payable - {0}'.format(abbr), 'name')
Saurabh2d8a7ee2018-05-11 13:16:16 +0530758
759 if company and tds_account:
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530760 accounts = [dict(company=company, account=tds_account)]
Saurabh2d8a7ee2018-05-11 13:16:16 +0530761
Anuja Pawar4569e522021-01-14 19:24:30 +0530762 try:
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530763 fiscal_year_details = get_fiscal_year(today(), verbose=0, company=company)
Anuja Pawar4569e522021-01-14 19:24:30 +0530764 except FiscalYearError:
765 pass
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530766
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530767 docs = get_tds_details(accounts, fiscal_year_details)
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530768
Zarrar7f8024c2018-08-01 17:45:05 +0530769 for d in docs:
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530770 if not frappe.db.exists("Tax Withholding Category", d.get("name")):
Zarrar7f8024c2018-08-01 17:45:05 +0530771 doc = frappe.get_doc(d)
Deepesh Garg204ea102021-04-30 16:35:52 +0530772 doc.flags.ignore_validate = True
Zarrar7f8024c2018-08-01 17:45:05 +0530773 doc.flags.ignore_permissions = True
Nabin Haitafef9c12019-02-12 11:28:20 +0530774 doc.flags.ignore_mandatory = True
Zarrar7f8024c2018-08-01 17:45:05 +0530775 doc.insert()
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530776 else:
Deepesh Gargfea29ae2021-07-12 18:29:52 +0530777 doc = frappe.get_doc("Tax Withholding Category", d.get("name"), for_update=True)
Zarrar963d62b2019-03-23 10:30:12 +0530778
779 if accounts:
780 doc.append("accounts", accounts[0])
Zarrar7f8024c2018-08-01 17:45:05 +0530781
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530782 if fiscal_year_details:
Anuja Pawar4569e522021-01-14 19:24:30 +0530783 # if fiscal year don't match with any of the already entered data, append rate row
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530784 fy_exist = [k for k in doc.get('rates') if k.get('from_date') <= fiscal_year_details[1] \
785 and k.get('to_date') >= fiscal_year_details[2]]
Anuja Pawar4569e522021-01-14 19:24:30 +0530786 if not fy_exist:
787 doc.append("rates", d.get('rates')[0])
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530788
Anuja Pawar4569e522021-01-14 19:24:30 +0530789 doc.flags.ignore_permissions = True
Deepesh Garg48b1a822021-05-29 23:54:51 +0530790 doc.flags.ignore_validate = True
Anuja Pawar4569e522021-01-14 19:24:30 +0530791 doc.flags.ignore_mandatory = True
Deepesh Garg204ea102021-04-30 16:35:52 +0530792 doc.flags.ignore_links = True
Zarrar7f8024c2018-08-01 17:45:05 +0530793 doc.save()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530794
795def set_tds_account(docs, company):
Nabin Haitf77cd542018-11-20 16:46:25 +0530796 parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
797 if parent_account:
798 docs.extend([
799 {
800 "doctype": "Account",
801 "account_name": "TDS Payable",
802 "account_type": "Tax",
803 "parent_account": parent_account,
804 "company": company
805 }
806 ])
Zarrar7f8024c2018-08-01 17:45:05 +0530807
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530808def get_tds_details(accounts, fiscal_year_details):
Zarrar7f8024c2018-08-01 17:45:05 +0530809 # bootstrap default tax withholding sections
810 return [
811 dict(name="TDS - 194C - Company",
812 category_name="Payment to Contractors (Single / Aggregate)",
813 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530814 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
815 "tax_withholding_rate": 2, "single_threshold": 30000, "cumulative_threshold": 100000}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530816 dict(name="TDS - 194C - Individual",
817 category_name="Payment to Contractors (Single / Aggregate)",
818 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530819 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
820 "tax_withholding_rate": 1, "single_threshold": 30000, "cumulative_threshold": 100000}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530821 dict(name="TDS - 194C - No PAN / Invalid PAN",
822 category_name="Payment to Contractors (Single / Aggregate)",
823 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530824 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
825 "tax_withholding_rate": 20, "single_threshold": 30000, "cumulative_threshold": 100000}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530826 dict(name="TDS - 194D - Company",
827 category_name="Insurance Commission",
828 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530829 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
830 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530831 dict(name="TDS - 194D - Company Assessee",
832 category_name="Insurance Commission",
833 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530834 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
835 "tax_withholding_rate": 10, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530836 dict(name="TDS - 194D - Individual",
837 category_name="Insurance Commission",
838 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530839 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
840 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530841 dict(name="TDS - 194D - No PAN / Invalid PAN",
842 category_name="Insurance Commission",
843 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530844 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
845 "tax_withholding_rate": 20, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530846 dict(name="TDS - 194DA - Company",
847 category_name="Non-exempt payments made under a life insurance policy",
848 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530849 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
850 "tax_withholding_rate": 1, "single_threshold": 100000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530851 dict(name="TDS - 194DA - Individual",
852 category_name="Non-exempt payments made under a life insurance policy",
853 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530854 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
855 "tax_withholding_rate": 1, "single_threshold": 100000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530856 dict(name="TDS - 194DA - No PAN / Invalid PAN",
857 category_name="Non-exempt payments made under a life insurance policy",
858 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530859 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
860 "tax_withholding_rate": 20, "single_threshold": 100000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530861 dict(name="TDS - 194H - Company",
862 category_name="Commission / Brokerage",
863 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530864 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
865 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530866 dict(name="TDS - 194H - Individual",
867 category_name="Commission / Brokerage",
868 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530869 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
870 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530871 dict(name="TDS - 194H - No PAN / Invalid PAN",
872 category_name="Commission / Brokerage",
873 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530874 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
875 "tax_withholding_rate": 20, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530876 dict(name="TDS - 194I - Rent - Company",
877 category_name="Rent",
878 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530879 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
880 "tax_withholding_rate": 10, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530881 dict(name="TDS - 194I - Rent - Individual",
882 category_name="Rent",
883 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530884 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
885 "tax_withholding_rate": 10, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530886 dict(name="TDS - 194I - Rent - No PAN / Invalid PAN",
887 category_name="Rent",
888 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530889 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
890 "tax_withholding_rate": 20, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530891 dict(name="TDS - 194I - Rent/Machinery - Company",
892 category_name="Rent-Plant / Machinery",
893 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530894 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
895 "tax_withholding_rate": 2, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530896 dict(name="TDS - 194I - Rent/Machinery - Individual",
897 category_name="Rent-Plant / Machinery",
898 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530899 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
900 "tax_withholding_rate": 2, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530901 dict(name="TDS - 194I - Rent/Machinery - No PAN / Invalid PAN",
902 category_name="Rent-Plant / Machinery",
903 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530904 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
905 "tax_withholding_rate": 20, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530906 dict(name="TDS - 194J - Professional Fees - Company",
907 category_name="Professional Fees",
908 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530909 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
910 "tax_withholding_rate": 10, "single_threshold": 30000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530911 dict(name="TDS - 194J - Professional Fees - Individual",
912 category_name="Professional Fees",
913 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530914 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
915 "tax_withholding_rate": 10, "single_threshold": 30000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530916 dict(name="TDS - 194J - Professional Fees - No PAN / Invalid PAN",
917 category_name="Professional Fees",
918 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530919 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
920 "tax_withholding_rate": 20, "single_threshold": 30000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530921 dict(name="TDS - 194J - Director Fees - Company",
922 category_name="Director Fees",
923 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530924 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
925 "tax_withholding_rate": 10, "single_threshold": 0, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530926 dict(name="TDS - 194J - Director Fees - Individual",
927 category_name="Director Fees",
928 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530929 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
930 "tax_withholding_rate": 10, "single_threshold": 0, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530931 dict(name="TDS - 194J - Director Fees - No PAN / Invalid PAN",
932 category_name="Director Fees",
933 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530934 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
935 "tax_withholding_rate": 20, "single_threshold": 0, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530936 dict(name="TDS - 194 - Dividends - Company",
937 category_name="Dividends",
938 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530939 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
940 "tax_withholding_rate": 10, "single_threshold": 2500, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530941 dict(name="TDS - 194 - Dividends - Individual",
942 category_name="Dividends",
943 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530944 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
945 "tax_withholding_rate": 10, "single_threshold": 2500, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530946 dict(name="TDS - 194 - Dividends - No PAN / Invalid PAN",
947 category_name="Dividends",
948 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530949 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
950 "tax_withholding_rate": 20, "single_threshold": 2500, "cumulative_threshold": 0}])
Anurag Mishrae1464a72020-08-17 15:03:32 +0530951 ]
952
Anurag Mishra25c35682020-08-18 14:13:54 +0530953def create_gratuity_rule():
Anurag Mishrae1464a72020-08-17 15:03:32 +0530954 # Standard Indain Gratuity Rule
Anurag Mishra493eea12020-08-18 15:02:32 +0530955 if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
956 rule = frappe.new_doc("Gratuity Rule")
957 rule.name = "Indian Standard Gratuity Rule"
958 rule.calculate_gratuity_amount_based_on = "Current Slab"
959 rule.work_experience_calculation_method = "Round Off Work Experience"
960 rule.minimum_year_for_gratuity = 5
Anurag Mishrae1464a72020-08-17 15:03:32 +0530961
Anurag Mishra493eea12020-08-18 15:02:32 +0530962 fraction = 15/26
963 rule.append("gratuity_rule_slabs", {
964 "from_year": 0,
965 "to_year":0,
966 "fraction_of_applicable_earnings": fraction
967 })
Anurag Mishrae1464a72020-08-17 15:03:32 +0530968
Anurag Mishra493eea12020-08-18 15:02:32 +0530969 rule.flags.ignore_mandatory = True
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530970 rule.save()
Deepesh Garg204ea102021-04-30 16:35:52 +0530971
972def update_accounts_settings_for_taxes():
973 if frappe.db.count('Company') == 1:
Saqib84c41612021-08-10 16:46:44 +0530974 frappe.db.set_value('Accounts Settings', None, "add_taxes_from_item_tax_template", 0)