blob: 93cbcca92d1eff619678560292945b94ffb77e3f [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):
Saqib Ansarif1fcb382021-09-29 19:56:02 +0530135 custom_fields = get_custom_fields()
136 create_custom_fields(custom_fields, update=update)
137
138def get_custom_fields():
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530139 hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
Nabin Haitd34bfa82018-11-13 18:19:58 +0530140 fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description',
Nabin Haitf4af6082019-04-01 11:51:54 +0530141 allow_on_submit=1, print_hide=1, fetch_if_empty=1)
Marica9942acd2020-04-21 13:13:39 +0530142 nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530143 fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code',
144 print_hide=1)
145 is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST',
146 fieldtype='Check', fetch_from='item_code.is_non_gst', insert_after='is_nil_exempt',
147 print_hide=1)
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530148 taxable_value = dict(fieldname='taxable_value', label='Taxable Value',
149 fieldtype='Currency', insert_after='base_net_amount', hidden=1, options="Company:company:default_currency",
150 print_hide=1)
Deepesh Garg22b61602019-03-21 20:47:47 +0530151
152 purchase_invoice_gst_category = [
Nabin Hait879e1622017-08-21 08:28:55 +0530153 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
vishdha109b4082018-01-30 12:11:13 +0530154 insert_after='language', print_hide=1, collapsible=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530155 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530156 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530157 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530158 fetch_from='supplier.gst_category', fetch_if_empty=1),
159 dict(fieldname='export_type', label='Export Type',
160 fieldtype='Select', insert_after='gst_category', print_hide=1,
161 depends_on='eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
162 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='supplier.export_type',
163 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530164 ]
165
166 sales_invoice_gst_category = [
167 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
168 insert_after='language', print_hide=1, collapsible=1),
169 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530170 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530171 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530172 fetch_from='customer.gst_category', fetch_if_empty=1, length=25),
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530173 dict(fieldname='export_type', label='Export Type',
174 fieldtype='Select', insert_after='gst_category', print_hide=1,
175 depends_on='eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
176 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='customer.export_type',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530177 fetch_if_empty=1, length=25),
Deepesh Garg22b61602019-03-21 20:47:47 +0530178 ]
179
Deepesh Garg29997412021-03-29 19:49:52 +0530180 delivery_note_gst_category = [
181 dict(fieldname='gst_category', label='GST Category',
182 fieldtype='Select', insert_after='gst_vehicle_type', print_hide=1,
183 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
184 fetch_from='customer.gst_category', fetch_if_empty=1),
185 ]
186
Deepesh Garg22b61602019-03-21 20:47:47 +0530187 invoice_gst_fields = [
Saqib Ansaria7df4222021-09-27 13:56:16 +0530188 dict(fieldname='invoice_copy', label='Invoice Copy', length=30,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530189 fieldtype='Select', insert_after='export_type', print_hide=1, allow_on_submit=1,
Nabin Hait879e1622017-08-21 08:28:55 +0530190 options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'),
Saqib Ansaria7df4222021-09-27 13:56:16 +0530191 dict(fieldname='reverse_charge', label='Reverse Charge', length=2,
Nabin Hait879e1622017-08-21 08:28:55 +0530192 fieldtype='Select', insert_after='invoice_copy', print_hide=1,
193 options='Y\nN', default='N'),
Saqib Ansaria7df4222021-09-27 13:56:16 +0530194 dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN', length=15,
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530195 fieldtype='Data', insert_after='export_type', print_hide=1),
Nabin Haite6d65bc2018-02-14 17:44:06 +0530196 dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='ecommerce_gstin'),
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530197 dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document',
Nabin Haitb02c1092018-02-05 16:09:51 +0530198 fieldtype='Select', insert_after='gst_col_break', print_hide=1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530199 depends_on='eval:doc.is_return==1', length=45,
Nabin Haita8d10b72018-02-12 16:54:13 +0530200 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 +0530201 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530202
Nabin Hait879e1622017-08-21 08:28:55 +0530203 purchase_invoice_gst_fields = [
204 dict(fieldname='supplier_gstin', label='Supplier GSTIN',
205 fieldtype='Data', insert_after='supplier_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530206 fetch_from='supplier_address.gstin', print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530207 dict(fieldname='company_gstin', label='Company GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530208 fieldtype='Data', insert_after='shipping_address_display',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530209 fetch_from='shipping_address.gstin', print_hide=1, read_only=1),
Nabin Haitb02c1092018-02-05 16:09:51 +0530210 dict(fieldname='place_of_supply', label='Place of Supply',
211 fieldtype='Data', insert_after='shipping_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530212 print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530213 ]
214
215 purchase_invoice_itc_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530216 dict(fieldname='eligibility_for_itc', label='Eligibility For ITC',
217 fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530218 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',
219 default="All Other ITC"),
vishdha98e33c32018-01-29 13:57:34 +0530220 dict(fieldname='itc_integrated_tax', label='Availed ITC Integrated Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530221 fieldtype='Currency', insert_after='eligibility_for_itc',
222 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530223 dict(fieldname='itc_central_tax', label='Availed ITC Central Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530224 fieldtype='Currency', insert_after='itc_integrated_tax',
225 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530226 dict(fieldname='itc_state_tax', label='Availed ITC State/UT Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530227 fieldtype='Currency', insert_after='itc_central_tax',
228 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530229 dict(fieldname='itc_cess_amount', label='Availed ITC Cess',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530230 fieldtype='Currency', insert_after='itc_state_tax',
231 options='Company:company:default_currency', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530232 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530233
Nabin Hait879e1622017-08-21 08:28:55 +0530234 sales_invoice_gst_fields = [
rohitwaghchaure16645802017-09-28 11:05:03 +0530235 dict(fieldname='billing_address_gstin', label='Billing Address GSTIN',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530236 fieldtype='Data', insert_after='customer_address', read_only=1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530237 fetch_from='customer_address.gstin', print_hide=1, length=15),
Nabin Hait879e1622017-08-21 08:28:55 +0530238 dict(fieldname='customer_gstin', label='Customer GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530239 fieldtype='Data', insert_after='shipping_address_name',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530240 fetch_from='shipping_address_name.gstin', print_hide=1, length=15),
Nabin Hait879e1622017-08-21 08:28:55 +0530241 dict(fieldname='place_of_supply', label='Place of Supply',
Nabin Hait619c42b2018-01-10 17:48:03 +0530242 fieldtype='Data', insert_after='customer_gstin',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530243 print_hide=1, read_only=1, length=50),
Nabin Hait879e1622017-08-21 08:28:55 +0530244 dict(fieldname='company_gstin', label='Company GSTIN',
245 fieldtype='Data', insert_after='company_address',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530246 fetch_from='company_address.gstin', print_hide=1, read_only=1, length=15),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530247 ]
248
249 sales_invoice_shipping_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530250 dict(fieldname='port_code', label='Port Code',
251 fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530252 depends_on="eval:doc.gst_category=='Overseas' ", length=15),
vishdha98e33c32018-01-29 13:57:34 +0530253 dict(fieldname='shipping_bill_number', label=' Shipping Bill Number',
254 fieldtype='Data', insert_after='port_code', print_hide=1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530255 depends_on="eval:doc.gst_category=='Overseas' ", length=50),
vishdha98e33c32018-01-29 13:57:34 +0530256 dict(fieldname='shipping_bill_date', label='Shipping Bill Date',
257 fieldtype='Date', insert_after='shipping_bill_number', print_hide=1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530258 depends_on="eval:doc.gst_category=='Overseas' ", length=15),
Nabin Hait879e1622017-08-21 08:28:55 +0530259 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530260
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530261 journal_entry_fields = [
262 dict(fieldname='reversal_type', label='Reversal Type',
263 fieldtype='Select', insert_after='voucher_type', print_hide=1,
264 options="As per rules 42 & 43 of CGST Rules\nOthers",
265 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
266 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
267 dict(fieldname='company_address', label='Company Address',
268 fieldtype='Link', options='Address', insert_after='reversal_type',
269 print_hide=1, depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
270 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
271 dict(fieldname='company_gstin', label='Company GSTIN',
272 fieldtype='Data', read_only=1, insert_after='company_address', print_hide=1,
273 fetch_from='company_address.gstin',
274 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
275 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'")
276 ]
277
Shreya Shah4fa600a2018-06-05 11:27:53 +0530278 inter_state_gst_field = [
279 dict(fieldname='is_inter_state', label='Is Inter State',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530280 fieldtype='Check', insert_after='disabled', print_hide=1),
281 dict(fieldname='tax_category_column_break', fieldtype='Column Break',
282 insert_after='is_inter_state'),
283 dict(fieldname='gst_state', label='Source State', fieldtype='Select',
284 options='\n'.join(states), insert_after='company')
Shreya Shah4fa600a2018-06-05 11:27:53 +0530285 ]
286
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530287 ewaybill_fields = [
288 {
289 'fieldname': 'distance',
290 'label': 'Distance (in km)',
291 'fieldtype': 'Float',
292 'insert_after': 'vehicle_no',
293 'print_hide': 1
294 },
295 {
296 'fieldname': 'gst_transporter_id',
297 'label': 'GST Transporter ID',
298 'fieldtype': 'Data',
Nabin Hait34c551d2019-07-03 10:34:31 +0530299 'insert_after': 'transporter',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530300 'fetch_from': 'transporter.gst_transporter_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530301 'print_hide': 1,
302 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530303 },
304 {
305 'fieldname': 'mode_of_transport',
306 'label': 'Mode of Transport',
307 'fieldtype': 'Select',
308 'options': '\nRoad\nAir\nRail\nShip',
309 'default': 'Road',
Nabin Hait34c551d2019-07-03 10:34:31 +0530310 'insert_after': 'transporter_name',
311 'print_hide': 1,
312 'translatable': 0
313 },
314 {
315 'fieldname': 'gst_vehicle_type',
316 'label': 'GST Vehicle Type',
317 'fieldtype': 'Select',
318 'options': 'Regular\nOver Dimensional Cargo (ODC)',
319 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
320 'default': 'Regular',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530321 'insert_after': 'lr_date',
Nabin Hait34c551d2019-07-03 10:34:31 +0530322 'print_hide': 1,
323 'translatable': 0
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530324 },
325 {
326 'fieldname': 'ewaybill',
327 'label': 'E-Way Bill No.',
328 'fieldtype': 'Data',
329 'depends_on': 'eval:(doc.docstatus === 1)',
330 'allow_on_submit': 1,
331 'insert_after': 'customer_name_in_arabic',
332 'translatable': 0,
Deepesh Garg29997412021-03-29 19:49:52 +0530333 }
Nabin Hait34c551d2019-07-03 10:34:31 +0530334 ]
335
336 si_ewaybill_fields = [
337 {
338 'fieldname': 'transporter_info',
339 'label': 'Transporter Info',
340 'fieldtype': 'Section Break',
341 'insert_after': 'terms',
342 'collapsible': 1,
343 'collapsible_depends_on': 'transporter',
344 'print_hide': 1
345 },
346 {
347 'fieldname': 'transporter',
348 'label': 'Transporter',
349 'fieldtype': 'Link',
350 'insert_after': 'transporter_info',
351 'options': 'Supplier',
352 'print_hide': 1
353 },
354 {
355 'fieldname': 'gst_transporter_id',
356 'label': 'GST Transporter ID',
357 'fieldtype': 'Data',
358 'insert_after': 'transporter',
359 'fetch_from': 'transporter.gst_transporter_id',
360 'print_hide': 1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530361 'translatable': 0,
362 'length': 20
Nabin Hait34c551d2019-07-03 10:34:31 +0530363 },
364 {
365 'fieldname': 'driver',
366 'label': 'Driver',
367 'fieldtype': 'Link',
368 'insert_after': 'gst_transporter_id',
369 'options': 'Driver',
370 'print_hide': 1
371 },
372 {
373 'fieldname': 'lr_no',
374 'label': 'Transport Receipt No',
375 'fieldtype': 'Data',
376 'insert_after': 'driver',
377 'print_hide': 1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530378 'translatable': 0,
379 'length': 30
Nabin Hait34c551d2019-07-03 10:34:31 +0530380 },
381 {
382 'fieldname': 'vehicle_no',
383 'label': 'Vehicle No',
384 'fieldtype': 'Data',
385 'insert_after': 'lr_no',
386 'print_hide': 1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530387 'translatable': 0,
388 'length': 10
Nabin Hait34c551d2019-07-03 10:34:31 +0530389 },
390 {
391 'fieldname': 'distance',
392 'label': 'Distance (in km)',
393 'fieldtype': 'Float',
394 'insert_after': 'vehicle_no',
395 'print_hide': 1
396 },
397 {
398 'fieldname': 'transporter_col_break',
399 'fieldtype': 'Column Break',
400 'insert_after': 'distance'
401 },
402 {
403 'fieldname': 'transporter_name',
404 'label': 'Transporter Name',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530405 'fieldtype': 'Small Text',
Nabin Hait34c551d2019-07-03 10:34:31 +0530406 'insert_after': 'transporter_col_break',
407 'fetch_from': 'transporter.name',
408 'read_only': 1,
409 'print_hide': 1,
410 'translatable': 0
411 },
412 {
413 'fieldname': 'mode_of_transport',
414 'label': 'Mode of Transport',
415 'fieldtype': 'Select',
416 'options': '\nRoad\nAir\nRail\nShip',
Nabin Hait34c551d2019-07-03 10:34:31 +0530417 'insert_after': 'transporter_name',
418 'print_hide': 1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530419 'translatable': 0,
420 'length': 5
Nabin Hait34c551d2019-07-03 10:34:31 +0530421 },
422 {
423 'fieldname': 'driver_name',
424 'label': 'Driver Name',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530425 'fieldtype': 'Small Text',
Nabin Hait34c551d2019-07-03 10:34:31 +0530426 'insert_after': 'mode_of_transport',
427 'fetch_from': 'driver.full_name',
428 'print_hide': 1,
429 'translatable': 0
430 },
431 {
432 'fieldname': 'lr_date',
433 'label': 'Transport Receipt Date',
434 'fieldtype': 'Date',
435 'insert_after': 'driver_name',
436 'default': 'Today',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530437 'print_hide': 1,
438 'length': 10
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530439 },
440 {
441 'fieldname': 'gst_vehicle_type',
442 'label': 'GST Vehicle Type',
443 'fieldtype': 'Select',
Nabin Hait34c551d2019-07-03 10:34:31 +0530444 'options': 'Regular\nOver Dimensional Cargo (ODC)',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530445 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
Nabin Hait34c551d2019-07-03 10:34:31 +0530446 'default': 'Regular',
447 'insert_after': 'lr_date',
448 'print_hide': 1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530449 'translatable': 0,
450 'length': 30
Nabin Hait34c551d2019-07-03 10:34:31 +0530451 },
452 {
453 'fieldname': 'ewaybill',
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530454 'label': 'E-Way Bill No.',
Nabin Hait34c551d2019-07-03 10:34:31 +0530455 'fieldtype': 'Data',
Saqibc3359622021-08-20 11:10:46 +0530456 'depends_on': 'eval:(doc.docstatus === 1)',
Nabin Hait34c551d2019-07-03 10:34:31 +0530457 'allow_on_submit': 1,
deepeshgarg007a85db662019-07-14 18:15:19 +0530458 'insert_after': 'tax_id',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530459 'translatable': 0,
460 'length': 20
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530461 }
462 ]
463
Deepesh Garge8a5dc32021-09-02 18:56:04 +0530464 payment_entry_fields = [
465 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break', insert_after='deductions',
466 print_hide=1, collapsible=1),
467 dict(fieldname='company_address', label='Company Address', fieldtype='Link', insert_after='gst_section',
468 print_hide=1, options='Address'),
469 dict(fieldname='company_gstin', label='Company GSTIN',
470 fieldtype='Data', insert_after='company_address',
471 fetch_from='company_address.gstin', print_hide=1, read_only=1),
472 dict(fieldname='place_of_supply', label='Place of Supply',
473 fieldtype='Data', insert_after='company_gstin',
474 print_hide=1, read_only=1),
475 dict(fieldname='gst_column_break', fieldtype='Column Break',
476 insert_after='place_of_supply'),
477 dict(fieldname='customer_address', label='Customer Address', fieldtype='Link', insert_after='gst_column_break',
478 print_hide=1, options='Address', depends_on = 'eval:doc.party_type == "Customer"'),
479 dict(fieldname='customer_gstin', label='Customer GSTIN',
480 fieldtype='Data', insert_after='customer_address',
481 fetch_from='customer_address.gstin', print_hide=1, read_only=1)
482 ]
483
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530484 custom_fields = {
485 'Address': [
Rushabh Mehta919a74a2017-06-22 16:37:04 +0530486 dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data',
487 insert_after='fax'),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530488 dict(fieldname='gst_state', label='GST State', fieldtype='Select',
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530489 options='\n'.join(states), insert_after='gstin'),
490 dict(fieldname='gst_state_number', label='GST State Number',
Nabin Hait562d9422018-09-07 16:14:44 +0530491 fieldtype='Data', insert_after='gst_state', read_only=1),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530492 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530493 'Purchase Invoice': purchase_invoice_gst_category + invoice_gst_fields + purchase_invoice_itc_fields + purchase_invoice_gst_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530494 'Purchase Order': purchase_invoice_gst_fields,
495 'Purchase Receipt': purchase_invoice_gst_fields,
Saqibc3359622021-08-20 11:10:46 +0530496 '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 +0530497 'POS Invoice': sales_invoice_gst_fields,
Deepesh Garg29997412021-03-29 19:49:52 +0530498 'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields + delivery_note_gst_category,
Deepesh Garg8b644d82021-07-15 15:36:54 +0530499 'Payment Entry': payment_entry_fields,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530500 'Journal Entry': journal_entry_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530501 'Sales Order': sales_invoice_gst_fields,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530502 'Tax Category': inter_state_gst_field,
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530503 'Item': [
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530504 dict(fieldname='gst_hsn_code', label='HSN/SAC',
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530505 fieldtype='Link', options='GST HSN Code', insert_after='item_group'),
Marica9942acd2020-04-21 13:13:39 +0530506 dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530507 fieldtype='Check', insert_after='gst_hsn_code'),
508 dict(fieldname='is_non_gst', label='Is Non GST ',
509 fieldtype='Check', insert_after='is_nil_exempt')
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530510 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530511 'Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
512 'Supplier Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
513 'Sales Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
514 'Delivery Note Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530515 'Sales Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Subin Tomd49346a2021-09-17 10:39:03 +0530516 'POS Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Deepesh Garg22b61602019-03-21 20:47:47 +0530517 'Purchase Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
518 'Purchase Receipt Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530519 'Purchase Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Himanshu Warekar656d8e42019-04-01 19:38:43 +0530520 'Material Request Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Anurag Mishra289c8222020-06-19 19:17:57 +0530521 'Salary Component': [
522 dict(fieldname= 'component_type',
523 label= 'Component Type',
524 fieldtype= 'Select',
525 insert_after= 'description',
526 options= "\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax",
527 depends_on = 'eval:doc.type == "Deduction"'
528 )
529 ],
Pawan Mehtaf4196352018-04-05 14:54:51 +0530530 'Employee': [
Anurag Mishra289c8222020-06-19 19:17:57 +0530531 dict(fieldname='ifsc_code',
532 label='IFSC Code',
533 fieldtype='Data',
534 insert_after='bank_ac_no',
535 print_hide=1,
536 depends_on='eval:doc.salary_mode == "Bank"'
537 ),
538 dict(
539 fieldname = 'pan_number',
540 label = 'PAN Number',
541 fieldtype = 'Data',
542 insert_after = 'payroll_cost_center',
543 print_hide = 1
544 ),
545 dict(
546 fieldname = 'micr_code',
547 label = 'MICR Code',
548 fieldtype = 'Data',
549 insert_after = 'ifsc_code',
550 print_hide = 1,
551 depends_on='eval:doc.salary_mode == "Bank"'
552 ),
553 dict(
554 fieldname = 'provident_fund_account',
555 label = 'Provident Fund Account',
556 fieldtype = 'Data',
557 insert_after = 'pan_number'
558 )
559
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530560 ],
561 'Company': [
562 dict(fieldname='hra_section', label='HRA Settings',
Anurag Mishraa5527222019-06-14 15:25:57 +0530563 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530564 dict(fieldname='basic_component', label='Basic Component',
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530565 fieldtype='Link', options='Salary Component', insert_after='hra_section'),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530566 dict(fieldname='hra_component', label='HRA Component',
567 fieldtype='Link', options='Salary Component', insert_after='basic_component'),
Saqibce129a12021-08-24 17:23:14 +0530568 dict(fieldname='hra_column_break', fieldtype='Column Break', insert_after='hra_component'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530569 dict(fieldname='arrear_component', label='Arrear Component',
Mangesh-Khairnar9215de02019-05-06 16:24:10 +0530570 fieldtype='Link', options='Salary Component', insert_after='hra_component'),
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530571 dict(fieldname='non_profit_section', label='Non Profit Settings',
572 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
573 dict(fieldname='company_80g_number', label='80G Number',
574 fieldtype='Data', insert_after='non_profit_section'),
575 dict(fieldname='with_effect_from', label='80G With Effect From',
576 fieldtype='Date', insert_after='company_80g_number'),
Saqibce129a12021-08-24 17:23:14 +0530577 dict(fieldname='non_profit_column_break', fieldtype='Column Break', insert_after='with_effect_from'),
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530578 dict(fieldname='pan_details', label='PAN Number',
579 fieldtype='Data', insert_after='with_effect_from')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530580 ],
581 'Employee Tax Exemption Declaration':[
582 dict(fieldname='hra_section', label='HRA Exemption',
583 fieldtype='Section Break', insert_after='declarations'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530584 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530585 fieldtype='Currency', insert_after='hra_section'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530586 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530587 fieldtype='Check', insert_after='monthly_house_rent', depends_on='monthly_house_rent'),
588 dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure',
589 fieldtype='Currency', insert_after='rented_in_metro_city', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530590 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530591 insert_after='salary_structure_hra', depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530592 dict(fieldname='annual_hra_exemption', label='Annual HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530593 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530594 dict(fieldname='monthly_hra_exemption', label='Monthly HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530595 fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1, depends_on='monthly_house_rent')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530596 ],
597 'Employee Tax Exemption Proof Submission': [
598 dict(fieldname='hra_section', label='HRA Exemption',
599 fieldtype='Section Break', insert_after='tax_exemption_proofs'),
600 dict(fieldname='house_rent_payment_amount', label='House Rent Payment Amount',
601 fieldtype='Currency', insert_after='hra_section'),
602 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530603 fieldtype='Check', insert_after='house_rent_payment_amount', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530604 dict(fieldname='rented_from_date', label='Rented From Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530605 fieldtype='Date', insert_after='rented_in_metro_city', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530606 dict(fieldname='rented_to_date', label='Rented To Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530607 fieldtype='Date', insert_after='rented_from_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530608 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530609 insert_after='rented_to_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530610 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530611 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530612 dict(fieldname='monthly_hra_exemption', label='Monthly Eligible Amount',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530613 fieldtype='Currency', insert_after='monthly_house_rent', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530614 dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530615 fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1, depends_on='house_rent_payment_amount')
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530616 ],
617 'Supplier': [
618 {
619 'fieldname': 'gst_transporter_id',
620 'label': 'GST Transporter ID',
621 'fieldtype': 'Data',
622 'insert_after': 'supplier_type',
623 'depends_on': 'eval:doc.is_transporter'
Deepesh Garg22b61602019-03-21 20:47:47 +0530624 },
625 {
626 'fieldname': 'gst_category',
627 'label': 'GST Category',
628 'fieldtype': 'Select',
629 'insert_after': 'gst_transporter_id',
630 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
631 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530632 },
633 {
634 'fieldname': 'export_type',
635 'label': 'Export Type',
636 'fieldtype': 'Select',
637 'insert_after': 'gst_category',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530638 'depends_on':'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
Deepesh Garg3f07bb72021-08-16 13:18:39 +0530639 'options': '\nWith Payment of Tax\nWithout Payment of Tax',
640 'mandatory_depends_on': 'eval:in_list(["SEZ", "Overseas"], doc.gst_category)'
Deepesh Garg22b61602019-03-21 20:47:47 +0530641 }
642 ],
643 'Customer': [
644 {
645 'fieldname': 'gst_category',
646 'label': 'GST Category',
647 'fieldtype': 'Select',
648 'insert_after': 'customer_type',
649 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
650 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530651 },
652 {
653 'fieldname': 'export_type',
654 'label': 'Export Type',
655 'fieldtype': 'Select',
656 'insert_after': 'gst_category',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530657 'depends_on':'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
Deepesh Garg3f07bb72021-08-16 13:18:39 +0530658 'options': '\nWith Payment of Tax\nWithout Payment of Tax',
659 'mandatory_depends_on': 'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)'
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530660 }
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530661 ],
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530662 'Member': [
663 {
664 'fieldname': 'pan_number',
665 'label': 'PAN Details',
666 'fieldtype': 'Data',
667 'insert_after': 'email_id'
668 }
669 ],
670 'Donor': [
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530671 {
672 'fieldname': 'pan_number',
673 'label': 'PAN Details',
674 'fieldtype': 'Data',
675 'insert_after': 'email'
676 }
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530677 ]
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530678 }
Saqib Ansarif1fcb382021-09-29 19:56:02 +0530679
680 return custom_fields
Nabin Hait9c421612017-07-20 13:32:01 +0530681
Saurabh2d8a7ee2018-05-11 13:16:16 +0530682def make_fixtures(company=None):
683 docs = []
Deepesh Garga66184f2021-05-02 12:22:16 +0530684 company = company or frappe.db.get_value("Global Defaults", None, "default_company")
Saurabh2d8a7ee2018-05-11 13:16:16 +0530685
686 set_salary_components(docs)
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530687 set_tds_account(docs, company)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530688
689 for d in docs:
690 try:
691 doc = frappe.get_doc(d)
692 doc.flags.ignore_permissions = True
693 doc.insert()
694 except frappe.NameError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530695 frappe.clear_messages()
Zarrar7f8024c2018-08-01 17:45:05 +0530696 except frappe.DuplicateEntryError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530697 frappe.clear_messages()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530698
Zarrar7f8024c2018-08-01 17:45:05 +0530699 # create records for Tax Withholding Category
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530700 set_tax_withholding_category(company)
701
Deepesh Gargb3ed8072021-06-02 13:26:21 +0530702def update_regional_tax_settings(country, company):
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530703 # Will only add default GST accounts if present
704 input_account_names = ['Input Tax CGST', 'Input Tax SGST', 'Input Tax IGST']
705 output_account_names = ['Output Tax CGST', 'Output Tax SGST', 'Output Tax IGST']
Deepesh Garg48b1a822021-05-29 23:54:51 +0530706 rcm_accounts = ['Input Tax CGST RCM', 'Input Tax SGST RCM', 'Input Tax IGST RCM']
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530707 gst_settings = frappe.get_single('GST Settings')
708 existing_account_list = []
709
710 for account in gst_settings.get('gst_accounts'):
711 for key in ['cgst_account', 'sgst_account', 'igst_account']:
712 existing_account_list.append(account.get(key))
713
714 gst_accounts = frappe._dict(frappe.get_all("Account",
Deepesh Garg48b1a822021-05-29 23:54:51 +0530715 {'company': company, 'account_name': ('in', input_account_names +
716 output_account_names + rcm_accounts)}, ['account_name', 'name'], as_list=1))
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530717
Deepesh Garg48b1a822021-05-29 23:54:51 +0530718 add_accounts_in_gst_settings(company, input_account_names, gst_accounts,
719 existing_account_list, gst_settings)
720 add_accounts_in_gst_settings(company, output_account_names, gst_accounts,
721 existing_account_list, gst_settings)
722 add_accounts_in_gst_settings(company, rcm_accounts, gst_accounts,
723 existing_account_list, gst_settings, is_reverse_charge=1)
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530724
725 gst_settings.save()
726
Deepesh Garg48b1a822021-05-29 23:54:51 +0530727def add_accounts_in_gst_settings(company, account_names, gst_accounts,
728 existing_account_list, gst_settings, is_reverse_charge=0):
729 accounts_not_added = 1
730
731 for account in account_names:
732 # Default Account Added does not exists
733 if not gst_accounts.get(account):
734 accounts_not_added = 0
735
736 # Check if already added in GST Settings
737 if gst_accounts.get(account) in existing_account_list:
738 accounts_not_added = 0
739
740 if accounts_not_added:
741 gst_settings.append('gst_accounts', {
742 'company': company,
743 'cgst_account': gst_accounts.get(account_names[0]),
744 'sgst_account': gst_accounts.get(account_names[1]),
745 'igst_account': gst_accounts.get(account_names[2]),
746 'is_reverse_charge_account': is_reverse_charge
747 })
748
Saurabh2d8a7ee2018-05-11 13:16:16 +0530749def set_salary_components(docs):
750 docs.extend([
Nabin Hait58ee6c12020-04-26 17:45:57 +0530751 {'doctype': 'Salary Component', 'salary_component': 'Professional Tax',
752 'description': 'Professional Tax', 'type': 'Deduction', 'exempted_from_income_tax': 1},
753 {'doctype': 'Salary Component', 'salary_component': 'Provident Fund',
754 'description': 'Provident fund', 'type': 'Deduction', 'is_tax_applicable': 1},
755 {'doctype': 'Salary Component', 'salary_component': 'House Rent Allowance',
756 'description': 'House Rent Allowance', 'type': 'Earning', 'is_tax_applicable': 1},
757 {'doctype': 'Salary Component', 'salary_component': 'Basic',
758 'description': 'Basic', 'type': 'Earning', 'is_tax_applicable': 1},
759 {'doctype': 'Salary Component', 'salary_component': 'Arrear',
760 'description': 'Arrear', 'type': 'Earning', 'is_tax_applicable': 1},
761 {'doctype': 'Salary Component', 'salary_component': 'Leave Encashment',
762 'description': 'Leave Encashment', 'type': 'Earning', 'is_tax_applicable': 1}
Saurabh2d8a7ee2018-05-11 13:16:16 +0530763 ])
764
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530765def set_tax_withholding_category(company):
Saurabh2d8a7ee2018-05-11 13:16:16 +0530766 accounts = []
Saqibf8c1c732021-09-26 16:27:56 +0530767 fiscal_year_details = None
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530768 abbr = frappe.get_value("Company", company, "abbr")
769 tds_account = frappe.get_value("Account", 'TDS Payable - {0}'.format(abbr), 'name')
Saurabh2d8a7ee2018-05-11 13:16:16 +0530770
771 if company and tds_account:
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530772 accounts = [dict(company=company, account=tds_account)]
Saurabh2d8a7ee2018-05-11 13:16:16 +0530773
Anuja Pawar4569e522021-01-14 19:24:30 +0530774 try:
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530775 fiscal_year_details = get_fiscal_year(today(), verbose=0, company=company)
Anuja Pawar4569e522021-01-14 19:24:30 +0530776 except FiscalYearError:
777 pass
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530778
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530779 docs = get_tds_details(accounts, fiscal_year_details)
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530780
Zarrar7f8024c2018-08-01 17:45:05 +0530781 for d in docs:
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530782 if not frappe.db.exists("Tax Withholding Category", d.get("name")):
Zarrar7f8024c2018-08-01 17:45:05 +0530783 doc = frappe.get_doc(d)
Deepesh Garg204ea102021-04-30 16:35:52 +0530784 doc.flags.ignore_validate = True
Zarrar7f8024c2018-08-01 17:45:05 +0530785 doc.flags.ignore_permissions = True
Nabin Haitafef9c12019-02-12 11:28:20 +0530786 doc.flags.ignore_mandatory = True
Zarrar7f8024c2018-08-01 17:45:05 +0530787 doc.insert()
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530788 else:
Deepesh Gargfea29ae2021-07-12 18:29:52 +0530789 doc = frappe.get_doc("Tax Withholding Category", d.get("name"), for_update=True)
Zarrar963d62b2019-03-23 10:30:12 +0530790
791 if accounts:
792 doc.append("accounts", accounts[0])
Zarrar7f8024c2018-08-01 17:45:05 +0530793
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530794 if fiscal_year_details:
Anuja Pawar4569e522021-01-14 19:24:30 +0530795 # if fiscal year don't match with any of the already entered data, append rate row
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530796 fy_exist = [k for k in doc.get('rates') if k.get('from_date') <= fiscal_year_details[1] \
797 and k.get('to_date') >= fiscal_year_details[2]]
Anuja Pawar4569e522021-01-14 19:24:30 +0530798 if not fy_exist:
799 doc.append("rates", d.get('rates')[0])
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530800
Anuja Pawar4569e522021-01-14 19:24:30 +0530801 doc.flags.ignore_permissions = True
Deepesh Garg48b1a822021-05-29 23:54:51 +0530802 doc.flags.ignore_validate = True
Anuja Pawar4569e522021-01-14 19:24:30 +0530803 doc.flags.ignore_mandatory = True
Deepesh Garg204ea102021-04-30 16:35:52 +0530804 doc.flags.ignore_links = True
Zarrar7f8024c2018-08-01 17:45:05 +0530805 doc.save()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530806
807def set_tds_account(docs, company):
Nabin Haitf77cd542018-11-20 16:46:25 +0530808 parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
809 if parent_account:
810 docs.extend([
811 {
812 "doctype": "Account",
813 "account_name": "TDS Payable",
814 "account_type": "Tax",
815 "parent_account": parent_account,
816 "company": company
817 }
818 ])
Zarrar7f8024c2018-08-01 17:45:05 +0530819
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530820def get_tds_details(accounts, fiscal_year_details):
Zarrar7f8024c2018-08-01 17:45:05 +0530821 # bootstrap default tax withholding sections
822 return [
823 dict(name="TDS - 194C - Company",
824 category_name="Payment to Contractors (Single / Aggregate)",
825 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530826 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
827 "tax_withholding_rate": 2, "single_threshold": 30000, "cumulative_threshold": 100000}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530828 dict(name="TDS - 194C - Individual",
829 category_name="Payment to Contractors (Single / Aggregate)",
830 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530831 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
832 "tax_withholding_rate": 1, "single_threshold": 30000, "cumulative_threshold": 100000}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530833 dict(name="TDS - 194C - No PAN / Invalid PAN",
834 category_name="Payment to Contractors (Single / Aggregate)",
835 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530836 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
837 "tax_withholding_rate": 20, "single_threshold": 30000, "cumulative_threshold": 100000}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530838 dict(name="TDS - 194D - Company",
839 category_name="Insurance Commission",
840 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530841 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
842 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530843 dict(name="TDS - 194D - Company Assessee",
844 category_name="Insurance Commission",
845 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530846 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
847 "tax_withholding_rate": 10, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530848 dict(name="TDS - 194D - Individual",
849 category_name="Insurance Commission",
850 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530851 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
852 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530853 dict(name="TDS - 194D - No PAN / Invalid PAN",
854 category_name="Insurance Commission",
855 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530856 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
857 "tax_withholding_rate": 20, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530858 dict(name="TDS - 194DA - Company",
859 category_name="Non-exempt payments made under a life insurance policy",
860 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530861 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
862 "tax_withholding_rate": 1, "single_threshold": 100000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530863 dict(name="TDS - 194DA - Individual",
864 category_name="Non-exempt payments made under a life insurance policy",
865 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530866 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
867 "tax_withholding_rate": 1, "single_threshold": 100000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530868 dict(name="TDS - 194DA - No PAN / Invalid PAN",
869 category_name="Non-exempt payments made under a life insurance policy",
870 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530871 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
872 "tax_withholding_rate": 20, "single_threshold": 100000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530873 dict(name="TDS - 194H - Company",
874 category_name="Commission / Brokerage",
875 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530876 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
877 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530878 dict(name="TDS - 194H - Individual",
879 category_name="Commission / Brokerage",
880 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530881 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
882 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530883 dict(name="TDS - 194H - No PAN / Invalid PAN",
884 category_name="Commission / Brokerage",
885 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530886 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
887 "tax_withholding_rate": 20, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530888 dict(name="TDS - 194I - Rent - Company",
889 category_name="Rent",
890 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530891 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
892 "tax_withholding_rate": 10, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530893 dict(name="TDS - 194I - Rent - Individual",
894 category_name="Rent",
895 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530896 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
897 "tax_withholding_rate": 10, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530898 dict(name="TDS - 194I - Rent - No PAN / Invalid PAN",
899 category_name="Rent",
900 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530901 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
902 "tax_withholding_rate": 20, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530903 dict(name="TDS - 194I - Rent/Machinery - Company",
904 category_name="Rent-Plant / Machinery",
905 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530906 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
907 "tax_withholding_rate": 2, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530908 dict(name="TDS - 194I - Rent/Machinery - Individual",
909 category_name="Rent-Plant / Machinery",
910 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530911 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
912 "tax_withholding_rate": 2, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530913 dict(name="TDS - 194I - Rent/Machinery - No PAN / Invalid PAN",
914 category_name="Rent-Plant / Machinery",
915 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530916 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
917 "tax_withholding_rate": 20, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530918 dict(name="TDS - 194J - Professional Fees - Company",
919 category_name="Professional Fees",
920 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530921 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
922 "tax_withholding_rate": 10, "single_threshold": 30000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530923 dict(name="TDS - 194J - Professional Fees - Individual",
924 category_name="Professional Fees",
925 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530926 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
927 "tax_withholding_rate": 10, "single_threshold": 30000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530928 dict(name="TDS - 194J - Professional Fees - No PAN / Invalid PAN",
929 category_name="Professional Fees",
930 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530931 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
932 "tax_withholding_rate": 20, "single_threshold": 30000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530933 dict(name="TDS - 194J - Director Fees - Company",
934 category_name="Director Fees",
935 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530936 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
937 "tax_withholding_rate": 10, "single_threshold": 0, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530938 dict(name="TDS - 194J - Director Fees - Individual",
939 category_name="Director Fees",
940 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530941 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
942 "tax_withholding_rate": 10, "single_threshold": 0, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530943 dict(name="TDS - 194J - Director Fees - No PAN / Invalid PAN",
944 category_name="Director Fees",
945 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530946 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
947 "tax_withholding_rate": 20, "single_threshold": 0, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530948 dict(name="TDS - 194 - Dividends - Company",
949 category_name="Dividends",
950 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530951 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
952 "tax_withholding_rate": 10, "single_threshold": 2500, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530953 dict(name="TDS - 194 - Dividends - Individual",
954 category_name="Dividends",
955 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530956 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
957 "tax_withholding_rate": 10, "single_threshold": 2500, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530958 dict(name="TDS - 194 - Dividends - No PAN / Invalid PAN",
959 category_name="Dividends",
960 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530961 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
962 "tax_withholding_rate": 20, "single_threshold": 2500, "cumulative_threshold": 0}])
Anurag Mishrae1464a72020-08-17 15:03:32 +0530963 ]
964
Anurag Mishra25c35682020-08-18 14:13:54 +0530965def create_gratuity_rule():
Anurag Mishrae1464a72020-08-17 15:03:32 +0530966 # Standard Indain Gratuity Rule
Anurag Mishra493eea12020-08-18 15:02:32 +0530967 if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
968 rule = frappe.new_doc("Gratuity Rule")
969 rule.name = "Indian Standard Gratuity Rule"
970 rule.calculate_gratuity_amount_based_on = "Current Slab"
971 rule.work_experience_calculation_method = "Round Off Work Experience"
972 rule.minimum_year_for_gratuity = 5
Anurag Mishrae1464a72020-08-17 15:03:32 +0530973
Anurag Mishra493eea12020-08-18 15:02:32 +0530974 fraction = 15/26
975 rule.append("gratuity_rule_slabs", {
976 "from_year": 0,
977 "to_year":0,
978 "fraction_of_applicable_earnings": fraction
979 })
Anurag Mishrae1464a72020-08-17 15:03:32 +0530980
Anurag Mishra493eea12020-08-18 15:02:32 +0530981 rule.flags.ignore_mandatory = True
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530982 rule.save()
Deepesh Garg204ea102021-04-30 16:35:52 +0530983
984def update_accounts_settings_for_taxes():
985 if frappe.db.count('Company') == 1:
Saqib84c41612021-08-10 16:46:44 +0530986 frappe.db.set_value('Accounts Settings', None, "add_taxes_from_item_tax_template", 0)