blob: 58654240285b9b74437cf7f866e6d61400120693 [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
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05304
5import frappe, os, json
Rushabh Mehtaf0569742017-09-13 12:52:30 +05306from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
Sagar Vora4c31fbb2021-04-01 15:32:37 +05307from frappe.custom.doctype.property_setter.property_setter import make_property_setter
Nabin Hait49b41e42019-01-24 17:55:44 +05308from frappe.permissions import add_permission, update_permission_property
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05309from erpnext.regional.india import states
Anuja Pawar4569e522021-01-14 19:24:30 +053010from erpnext.accounts.utils import get_fiscal_year, FiscalYearError
Zarrar7f8024c2018-08-01 17:45:05 +053011from frappe.utils import today
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053012
Rushabh Mehta01659272017-06-27 18:05:17 +053013def setup(company=None, patch=True):
Deepesh Gargfea29ae2021-07-12 18:29:52 +053014 # Company independent fixtures should be called only once at the first company setup
Rucha Mahabal88b5bda2021-11-09 16:04:52 +053015 if patch or frappe.db.count('Company', {'country': 'India'}) <=1:
Deepesh Gargfea29ae2021-07-12 18:29:52 +053016 setup_company_independent_fixtures(patch=patch)
17
Prateeksha Singh39b87652018-11-12 17:19:56 +053018 if not patch:
Prateeksha Singhdabf3492018-11-13 15:56:15 +053019 make_fixtures(company)
Prateeksha Singh39b87652018-11-12 17:19:56 +053020
21# TODO: for all countries
Nabin Hait10c61372021-04-13 15:46:01 +053022def setup_company_independent_fixtures(patch=False):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053023 make_custom_fields()
Nabin Hait10c61372021-04-13 15:46:01 +053024 make_property_setters(patch=patch)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053025 add_permissions()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053026 add_custom_roles_for_reports()
Nabin Haitc3144852017-09-28 18:55:40 +053027 frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes', now=frappe.flags.in_test)
Anurag Mishra25c35682020-08-18 14:13:54 +053028 create_gratuity_rule()
Nabin Hait852cb642017-07-05 12:58:19 +053029 add_print_formats()
Deepesh Garg204ea102021-04-30 16:35:52 +053030 update_accounts_settings_for_taxes()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053031
Nabin Hait1a609312017-07-13 12:16:04 +053032def add_hsn_sac_codes():
Ankush Menat5bb89b02021-06-11 15:57:01 +053033 if frappe.flags.in_test and frappe.flags.created_hsn_codes:
34 return
35
Nabin Hait1a609312017-07-13 12:16:04 +053036 # HSN codes
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053037 with open(os.path.join(os.path.dirname(__file__), 'hsn_code_data.json'), 'r') as f:
38 hsn_codes = json.loads(f.read())
39
Nabin Hait1a609312017-07-13 12:16:04 +053040 create_hsn_codes(hsn_codes, code_field="hsn_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053041
Nabin Hait1a609312017-07-13 12:16:04 +053042 # SAC Codes
43 with open(os.path.join(os.path.dirname(__file__), 'sac_code_data.json'), 'r') as f:
44 sac_codes = json.loads(f.read())
45 create_hsn_codes(sac_codes, code_field="sac_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053046
Ankush Menat5bb89b02021-06-11 15:57:01 +053047 if frappe.flags.in_test:
48 frappe.flags.created_hsn_codes = True
49
Nabin Hait1a609312017-07-13 12:16:04 +053050def create_hsn_codes(data, code_field):
51 for d in data:
Rushabh Mehtaf702d722017-09-27 15:31:30 +053052 hsn_code = frappe.new_doc('GST HSN Code')
53 hsn_code.description = d["description"]
54 hsn_code.hsn_code = d[code_field]
55 hsn_code.name = d[code_field]
56 try:
Nabin Hait1a609312017-07-13 12:16:04 +053057 hsn_code.db_insert()
Rushabh Mehtaf702d722017-09-27 15:31:30 +053058 except frappe.DuplicateEntryError:
59 pass
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053060
Rushabh Mehta919a74a2017-06-22 16:37:04 +053061def add_custom_roles_for_reports():
62 for report_name in ('GST Sales Register', 'GST Purchase Register',
Saqibc3359622021-08-20 11:10:46 +053063 'GST Itemised Sales Register', 'GST Itemised Purchase Register', 'Eway Bill'):
Rushabh Mehta919a74a2017-06-22 16:37:04 +053064
Rushabh Mehta919a74a2017-06-22 16:37:04 +053065 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
66 frappe.get_doc(dict(
67 doctype='Custom Role',
68 report=report_name,
69 roles= [
70 dict(role='Accounts User'),
71 dict(role='Accounts Manager')
72 ]
73 )).insert()
74
Anurag Mishra289c8222020-06-19 19:17:57 +053075 for report_name in ('Professional Tax Deductions', 'Provident Fund Deductions'):
76
77 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
78 frappe.get_doc(dict(
79 doctype='Custom Role',
80 report=report_name,
81 roles= [
82 dict(role='HR User'),
83 dict(role='HR Manager'),
84 dict(role='Employee')
85 ]
86 )).insert()
87
Anurag Mishra54cd1942020-09-03 13:51:26 +053088 for report_name in ('HSN-wise-summary of outward supplies', 'GSTR-1', 'GSTR-2'):
89
90 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
91 frappe.get_doc(dict(
92 doctype='Custom Role',
93 report=report_name,
94 roles= [
95 dict(role='Accounts User'),
96 dict(role='Accounts Manager'),
97 dict(role='Auditor')
98 ]
99 )).insert()
100
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530101def add_permissions():
Saqibc3359622021-08-20 11:10:46 +0530102 for doctype in ('GST HSN Code', 'GST Settings', 'GSTR 3B Report', 'Lower Deduction Certificate'):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530103 add_permission(doctype, 'All', 0)
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530104 for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
Saqib5e6ce882020-02-03 15:40:35 +0530105 add_permission(doctype, role, 0)
106 update_permission_property(doctype, role, 0, 'write', 1)
107 update_permission_property(doctype, role, 0, 'create', 1)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530108
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530109 if doctype == 'GST HSN Code':
110 for role in ('Item Manager', 'Stock Manager'):
111 add_permission(doctype, role, 0)
112 update_permission_property(doctype, role, 0, 'write', 1)
113 update_permission_property(doctype, role, 0, 'create', 1)
114
Nabin Hait852cb642017-07-05 12:58:19 +0530115def add_print_formats():
116 frappe.reload_doc("regional", "print_format", "gst_tax_invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530117 frappe.reload_doc("accounts", "print_format", "gst_pos_invoice")
118
barredterra1521b312021-03-03 12:33:48 +0100119 frappe.db.set_value("Print Format", "GST POS Invoice", "disabled", 0)
120 frappe.db.set_value("Print Format", "GST Tax Invoice", "disabled", 0)
Nabin Hait852cb642017-07-05 12:58:19 +0530121
Nabin Hait10c61372021-04-13 15:46:01 +0530122def make_property_setters(patch=False):
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530123 # GST rules do not allow for an invoice no. bigger than 16 characters
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530124 journal_entry_types = frappe.get_meta("Journal Entry").get_options("voucher_type").split("\n") + ['Reversal Of ITC']
Deepesh Garg2b340282021-09-02 22:01:24 +0530125 sales_invoice_series = ['SINV-.YY.-', 'SRET-.YY.-', ''] + frappe.get_meta("Sales Invoice").get_options("naming_series").split("\n")
126 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 +0530127
Nabin Hait10c61372021-04-13 15:46:01 +0530128 if not patch:
Deepesh Garg7be9f8d2021-07-10 20:23:52 +0530129 make_property_setter('Sales Invoice', 'naming_series', 'options', '\n'.join(sales_invoice_series), '')
130 make_property_setter('Purchase Invoice', 'naming_series', 'options', '\n'.join(purchase_invoice_series), '')
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530131 make_property_setter('Journal Entry', 'voucher_type', 'options', '\n'.join(journal_entry_types), '')
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530132
Rushabh Mehta69fa8082018-07-17 18:22:51 +0530133def make_custom_fields(update=True):
Saqib Ansarif1fcb382021-09-29 19:56:02 +0530134 custom_fields = get_custom_fields()
135 create_custom_fields(custom_fields, update=update)
136
137def get_custom_fields():
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530138 hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
Nabin Haitd34bfa82018-11-13 18:19:58 +0530139 fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description',
Nabin Haitf4af6082019-04-01 11:51:54 +0530140 allow_on_submit=1, print_hide=1, fetch_if_empty=1)
Marica9942acd2020-04-21 13:13:39 +0530141 nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530142 fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code',
143 print_hide=1)
144 is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST',
145 fieldtype='Check', fetch_from='item_code.is_non_gst', insert_after='is_nil_exempt',
146 print_hide=1)
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530147 taxable_value = dict(fieldname='taxable_value', label='Taxable Value',
148 fieldtype='Currency', insert_after='base_net_amount', hidden=1, options="Company:company:default_currency",
149 print_hide=1)
Deepesh Garg22b61602019-03-21 20:47:47 +0530150
151 purchase_invoice_gst_category = [
Nabin Hait879e1622017-08-21 08:28:55 +0530152 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
vishdha109b4082018-01-30 12:11:13 +0530153 insert_after='language', print_hide=1, collapsible=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530154 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530155 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530156 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530157 fetch_from='supplier.gst_category', fetch_if_empty=1),
158 dict(fieldname='export_type', label='Export Type',
159 fieldtype='Select', insert_after='gst_category', print_hide=1,
160 depends_on='eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
161 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='supplier.export_type',
162 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530163 ]
164
165 sales_invoice_gst_category = [
166 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
167 insert_after='language', print_hide=1, collapsible=1),
168 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530169 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530170 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530171 fetch_from='customer.gst_category', fetch_if_empty=1, length=25),
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530172 dict(fieldname='export_type', label='Export Type',
173 fieldtype='Select', insert_after='gst_category', print_hide=1,
174 depends_on='eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
175 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='customer.export_type',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530176 fetch_if_empty=1, length=25),
Deepesh Garg22b61602019-03-21 20:47:47 +0530177 ]
178
Deepesh Garg29997412021-03-29 19:49:52 +0530179 delivery_note_gst_category = [
180 dict(fieldname='gst_category', label='GST Category',
181 fieldtype='Select', insert_after='gst_vehicle_type', print_hide=1,
182 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
183 fetch_from='customer.gst_category', fetch_if_empty=1),
184 ]
185
Deepesh Garg22b61602019-03-21 20:47:47 +0530186 invoice_gst_fields = [
Saqib Ansaria7df4222021-09-27 13:56:16 +0530187 dict(fieldname='invoice_copy', label='Invoice Copy', length=30,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530188 fieldtype='Select', insert_after='export_type', print_hide=1, allow_on_submit=1,
Nabin Hait879e1622017-08-21 08:28:55 +0530189 options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'),
Saqib Ansaria7df4222021-09-27 13:56:16 +0530190 dict(fieldname='reverse_charge', label='Reverse Charge', length=2,
Nabin Hait879e1622017-08-21 08:28:55 +0530191 fieldtype='Select', insert_after='invoice_copy', print_hide=1,
192 options='Y\nN', default='N'),
Saqib Ansaria7df4222021-09-27 13:56:16 +0530193 dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN', length=15,
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530194 fieldtype='Data', insert_after='export_type', print_hide=1),
Nabin Haite6d65bc2018-02-14 17:44:06 +0530195 dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='ecommerce_gstin'),
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530196 dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document',
Nabin Haitb02c1092018-02-05 16:09:51 +0530197 fieldtype='Select', insert_after='gst_col_break', print_hide=1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530198 depends_on='eval:doc.is_return==1', length=45,
Nabin Haita8d10b72018-02-12 16:54:13 +0530199 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 +0530200 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530201
Nabin Hait879e1622017-08-21 08:28:55 +0530202 purchase_invoice_gst_fields = [
203 dict(fieldname='supplier_gstin', label='Supplier GSTIN',
204 fieldtype='Data', insert_after='supplier_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530205 fetch_from='supplier_address.gstin', print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530206 dict(fieldname='company_gstin', label='Company GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530207 fieldtype='Data', insert_after='shipping_address_display',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530208 fetch_from='shipping_address.gstin', print_hide=1, read_only=1),
Nabin Haitb02c1092018-02-05 16:09:51 +0530209 dict(fieldname='place_of_supply', label='Place of Supply',
210 fieldtype='Data', insert_after='shipping_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530211 print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530212 ]
213
214 purchase_invoice_itc_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530215 dict(fieldname='eligibility_for_itc', label='Eligibility For ITC',
216 fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530217 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',
218 default="All Other ITC"),
vishdha98e33c32018-01-29 13:57:34 +0530219 dict(fieldname='itc_integrated_tax', label='Availed ITC Integrated Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530220 fieldtype='Currency', insert_after='eligibility_for_itc',
221 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530222 dict(fieldname='itc_central_tax', label='Availed ITC Central Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530223 fieldtype='Currency', insert_after='itc_integrated_tax',
224 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530225 dict(fieldname='itc_state_tax', label='Availed ITC State/UT Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530226 fieldtype='Currency', insert_after='itc_central_tax',
227 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530228 dict(fieldname='itc_cess_amount', label='Availed ITC Cess',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530229 fieldtype='Currency', insert_after='itc_state_tax',
230 options='Company:company:default_currency', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530231 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530232
Nabin Hait879e1622017-08-21 08:28:55 +0530233 sales_invoice_gst_fields = [
rohitwaghchaure16645802017-09-28 11:05:03 +0530234 dict(fieldname='billing_address_gstin', label='Billing Address GSTIN',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530235 fieldtype='Data', insert_after='customer_address', read_only=1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530236 fetch_from='customer_address.gstin', print_hide=1, length=15),
Nabin Hait879e1622017-08-21 08:28:55 +0530237 dict(fieldname='customer_gstin', label='Customer GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530238 fieldtype='Data', insert_after='shipping_address_name',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530239 fetch_from='shipping_address_name.gstin', print_hide=1, length=15),
Nabin Hait879e1622017-08-21 08:28:55 +0530240 dict(fieldname='place_of_supply', label='Place of Supply',
Nabin Hait619c42b2018-01-10 17:48:03 +0530241 fieldtype='Data', insert_after='customer_gstin',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530242 print_hide=1, read_only=1, length=50),
Nabin Hait879e1622017-08-21 08:28:55 +0530243 dict(fieldname='company_gstin', label='Company GSTIN',
244 fieldtype='Data', insert_after='company_address',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530245 fetch_from='company_address.gstin', print_hide=1, read_only=1, length=15),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530246 ]
247
248 sales_invoice_shipping_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530249 dict(fieldname='port_code', label='Port Code',
250 fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530251 depends_on="eval:doc.gst_category=='Overseas' ", length=15),
vishdha98e33c32018-01-29 13:57:34 +0530252 dict(fieldname='shipping_bill_number', label=' Shipping Bill Number',
253 fieldtype='Data', insert_after='port_code', print_hide=1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530254 depends_on="eval:doc.gst_category=='Overseas' ", length=50),
vishdha98e33c32018-01-29 13:57:34 +0530255 dict(fieldname='shipping_bill_date', label='Shipping Bill Date',
256 fieldtype='Date', insert_after='shipping_bill_number', print_hide=1,
Saqib Ansari83cc5972021-09-30 12:37:04 +0530257 depends_on="eval:doc.gst_category=='Overseas' "),
Nabin Hait879e1622017-08-21 08:28:55 +0530258 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530259
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530260 journal_entry_fields = [
261 dict(fieldname='reversal_type', label='Reversal Type',
262 fieldtype='Select', insert_after='voucher_type', print_hide=1,
263 options="As per rules 42 & 43 of CGST Rules\nOthers",
264 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
265 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
266 dict(fieldname='company_address', label='Company Address',
267 fieldtype='Link', options='Address', insert_after='reversal_type',
268 print_hide=1, depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
269 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
270 dict(fieldname='company_gstin', label='Company GSTIN',
271 fieldtype='Data', read_only=1, insert_after='company_address', print_hide=1,
272 fetch_from='company_address.gstin',
273 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
274 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'")
275 ]
276
Shreya Shah4fa600a2018-06-05 11:27:53 +0530277 inter_state_gst_field = [
278 dict(fieldname='is_inter_state', label='Is Inter State',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530279 fieldtype='Check', insert_after='disabled', print_hide=1),
280 dict(fieldname='tax_category_column_break', fieldtype='Column Break',
281 insert_after='is_inter_state'),
282 dict(fieldname='gst_state', label='Source State', fieldtype='Select',
283 options='\n'.join(states), insert_after='company')
Shreya Shah4fa600a2018-06-05 11:27:53 +0530284 ]
285
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530286 ewaybill_fields = [
287 {
288 'fieldname': 'distance',
289 'label': 'Distance (in km)',
290 'fieldtype': 'Float',
291 'insert_after': 'vehicle_no',
292 'print_hide': 1
293 },
294 {
295 'fieldname': 'gst_transporter_id',
296 'label': 'GST Transporter ID',
297 'fieldtype': 'Data',
Nabin Hait34c551d2019-07-03 10:34:31 +0530298 'insert_after': 'transporter',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530299 'fetch_from': 'transporter.gst_transporter_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530300 'print_hide': 1,
301 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530302 },
303 {
304 'fieldname': 'mode_of_transport',
305 'label': 'Mode of Transport',
306 'fieldtype': 'Select',
307 'options': '\nRoad\nAir\nRail\nShip',
308 'default': 'Road',
Nabin Hait34c551d2019-07-03 10:34:31 +0530309 'insert_after': 'transporter_name',
310 'print_hide': 1,
311 'translatable': 0
312 },
313 {
314 'fieldname': 'gst_vehicle_type',
315 'label': 'GST Vehicle Type',
316 'fieldtype': 'Select',
317 'options': 'Regular\nOver Dimensional Cargo (ODC)',
318 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
319 'default': 'Regular',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530320 'insert_after': 'lr_date',
Nabin Hait34c551d2019-07-03 10:34:31 +0530321 'print_hide': 1,
322 'translatable': 0
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530323 },
324 {
325 'fieldname': 'ewaybill',
326 'label': 'E-Way Bill No.',
327 'fieldtype': 'Data',
328 'depends_on': 'eval:(doc.docstatus === 1)',
329 'allow_on_submit': 1,
330 'insert_after': 'customer_name_in_arabic',
331 'translatable': 0,
Deepesh Garg29997412021-03-29 19:49:52 +0530332 }
Nabin Hait34c551d2019-07-03 10:34:31 +0530333 ]
334
335 si_ewaybill_fields = [
336 {
337 'fieldname': 'transporter_info',
338 'label': 'Transporter Info',
339 'fieldtype': 'Section Break',
340 'insert_after': 'terms',
341 'collapsible': 1,
342 'collapsible_depends_on': 'transporter',
343 'print_hide': 1
344 },
345 {
346 'fieldname': 'transporter',
347 'label': 'Transporter',
348 'fieldtype': 'Link',
349 'insert_after': 'transporter_info',
350 'options': 'Supplier',
351 'print_hide': 1
352 },
353 {
354 'fieldname': 'gst_transporter_id',
355 'label': 'GST Transporter ID',
356 'fieldtype': 'Data',
357 'insert_after': 'transporter',
358 'fetch_from': 'transporter.gst_transporter_id',
359 'print_hide': 1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530360 'translatable': 0,
361 'length': 20
Nabin Hait34c551d2019-07-03 10:34:31 +0530362 },
363 {
364 'fieldname': 'driver',
365 'label': 'Driver',
366 'fieldtype': 'Link',
367 'insert_after': 'gst_transporter_id',
368 'options': 'Driver',
369 'print_hide': 1
370 },
371 {
372 'fieldname': 'lr_no',
373 'label': 'Transport Receipt No',
374 'fieldtype': 'Data',
375 'insert_after': 'driver',
376 'print_hide': 1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530377 'translatable': 0,
378 'length': 30
Nabin Hait34c551d2019-07-03 10:34:31 +0530379 },
380 {
381 'fieldname': 'vehicle_no',
382 'label': 'Vehicle No',
383 'fieldtype': 'Data',
384 'insert_after': 'lr_no',
385 'print_hide': 1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530386 'translatable': 0,
387 'length': 10
Nabin Hait34c551d2019-07-03 10:34:31 +0530388 },
389 {
390 'fieldname': 'distance',
391 'label': 'Distance (in km)',
392 'fieldtype': 'Float',
393 'insert_after': 'vehicle_no',
394 'print_hide': 1
395 },
396 {
397 'fieldname': 'transporter_col_break',
398 'fieldtype': 'Column Break',
399 'insert_after': 'distance'
400 },
401 {
402 'fieldname': 'transporter_name',
403 'label': 'Transporter Name',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530404 'fieldtype': 'Small Text',
Nabin Hait34c551d2019-07-03 10:34:31 +0530405 'insert_after': 'transporter_col_break',
406 'fetch_from': 'transporter.name',
407 'read_only': 1,
408 'print_hide': 1,
409 'translatable': 0
410 },
411 {
412 'fieldname': 'mode_of_transport',
413 'label': 'Mode of Transport',
414 'fieldtype': 'Select',
415 'options': '\nRoad\nAir\nRail\nShip',
Nabin Hait34c551d2019-07-03 10:34:31 +0530416 'insert_after': 'transporter_name',
417 'print_hide': 1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530418 'translatable': 0,
419 'length': 5
Nabin Hait34c551d2019-07-03 10:34:31 +0530420 },
421 {
422 'fieldname': 'driver_name',
423 'label': 'Driver Name',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530424 'fieldtype': 'Small Text',
Nabin Hait34c551d2019-07-03 10:34:31 +0530425 'insert_after': 'mode_of_transport',
426 'fetch_from': 'driver.full_name',
427 'print_hide': 1,
428 'translatable': 0
429 },
430 {
431 'fieldname': 'lr_date',
432 'label': 'Transport Receipt Date',
433 'fieldtype': 'Date',
434 'insert_after': 'driver_name',
435 'default': 'Today',
Saqib Ansari83cc5972021-09-30 12:37:04 +0530436 'print_hide': 1
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530437 },
438 {
439 'fieldname': 'gst_vehicle_type',
440 'label': 'GST Vehicle Type',
441 'fieldtype': 'Select',
Nabin Hait34c551d2019-07-03 10:34:31 +0530442 'options': 'Regular\nOver Dimensional Cargo (ODC)',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530443 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
Nabin Hait34c551d2019-07-03 10:34:31 +0530444 'default': 'Regular',
445 'insert_after': 'lr_date',
446 'print_hide': 1,
Saqib Ansaria7df4222021-09-27 13:56:16 +0530447 'translatable': 0,
448 'length': 30
Nabin Hait34c551d2019-07-03 10:34:31 +0530449 },
450 {
451 'fieldname': 'ewaybill',
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530452 'label': 'E-Way Bill No.',
Nabin Hait34c551d2019-07-03 10:34:31 +0530453 'fieldtype': 'Data',
Saqibc3359622021-08-20 11:10:46 +0530454 'depends_on': 'eval:(doc.docstatus === 1)',
Nabin Hait34c551d2019-07-03 10:34:31 +0530455 'allow_on_submit': 1,
deepeshgarg007a85db662019-07-14 18:15:19 +0530456 'insert_after': 'tax_id',
Saqib Ansaria7df4222021-09-27 13:56:16 +0530457 'translatable': 0,
458 'length': 20
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530459 }
460 ]
461
Deepesh Garge8a5dc32021-09-02 18:56:04 +0530462 payment_entry_fields = [
463 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break', insert_after='deductions',
464 print_hide=1, collapsible=1),
465 dict(fieldname='company_address', label='Company Address', fieldtype='Link', insert_after='gst_section',
466 print_hide=1, options='Address'),
467 dict(fieldname='company_gstin', label='Company GSTIN',
468 fieldtype='Data', insert_after='company_address',
469 fetch_from='company_address.gstin', print_hide=1, read_only=1),
470 dict(fieldname='place_of_supply', label='Place of Supply',
471 fieldtype='Data', insert_after='company_gstin',
472 print_hide=1, read_only=1),
473 dict(fieldname='gst_column_break', fieldtype='Column Break',
474 insert_after='place_of_supply'),
475 dict(fieldname='customer_address', label='Customer Address', fieldtype='Link', insert_after='gst_column_break',
476 print_hide=1, options='Address', depends_on = 'eval:doc.party_type == "Customer"'),
477 dict(fieldname='customer_gstin', label='Customer GSTIN',
478 fieldtype='Data', insert_after='customer_address',
479 fetch_from='customer_address.gstin', print_hide=1, read_only=1)
480 ]
481
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530482 custom_fields = {
483 'Address': [
Rushabh Mehta919a74a2017-06-22 16:37:04 +0530484 dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data',
485 insert_after='fax'),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530486 dict(fieldname='gst_state', label='GST State', fieldtype='Select',
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530487 options='\n'.join(states), insert_after='gstin'),
488 dict(fieldname='gst_state_number', label='GST State Number',
Nabin Hait562d9422018-09-07 16:14:44 +0530489 fieldtype='Data', insert_after='gst_state', read_only=1),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530490 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530491 'Purchase Invoice': purchase_invoice_gst_category + invoice_gst_fields + purchase_invoice_itc_fields + purchase_invoice_gst_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530492 'Purchase Order': purchase_invoice_gst_fields,
493 'Purchase Receipt': purchase_invoice_gst_fields,
Saqibc3359622021-08-20 11:10:46 +0530494 '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 +0530495 'POS Invoice': sales_invoice_gst_fields,
Deepesh Garg29997412021-03-29 19:49:52 +0530496 'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields + delivery_note_gst_category,
Deepesh Garg8b644d82021-07-15 15:36:54 +0530497 'Payment Entry': payment_entry_fields,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530498 'Journal Entry': journal_entry_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530499 'Sales Order': sales_invoice_gst_fields,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530500 'Tax Category': inter_state_gst_field,
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530501 'Item': [
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530502 dict(fieldname='gst_hsn_code', label='HSN/SAC',
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530503 fieldtype='Link', options='GST HSN Code', insert_after='item_group'),
Marica9942acd2020-04-21 13:13:39 +0530504 dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530505 fieldtype='Check', insert_after='gst_hsn_code'),
506 dict(fieldname='is_non_gst', label='Is Non GST ',
507 fieldtype='Check', insert_after='is_nil_exempt')
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530508 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530509 'Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
510 'Supplier Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
511 'Sales Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
512 'Delivery Note Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530513 'Sales Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Subin Tomd49346a2021-09-17 10:39:03 +0530514 'POS Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Deepesh Garg22b61602019-03-21 20:47:47 +0530515 'Purchase Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
516 'Purchase Receipt Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530517 'Purchase Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Himanshu Warekar656d8e42019-04-01 19:38:43 +0530518 'Material Request Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Anurag Mishra289c8222020-06-19 19:17:57 +0530519 'Salary Component': [
520 dict(fieldname= 'component_type',
521 label= 'Component Type',
522 fieldtype= 'Select',
523 insert_after= 'description',
524 options= "\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax",
525 depends_on = 'eval:doc.type == "Deduction"'
526 )
527 ],
Pawan Mehtaf4196352018-04-05 14:54:51 +0530528 'Employee': [
Anurag Mishra289c8222020-06-19 19:17:57 +0530529 dict(fieldname='ifsc_code',
530 label='IFSC Code',
531 fieldtype='Data',
532 insert_after='bank_ac_no',
533 print_hide=1,
534 depends_on='eval:doc.salary_mode == "Bank"'
535 ),
536 dict(
537 fieldname = 'pan_number',
538 label = 'PAN Number',
539 fieldtype = 'Data',
540 insert_after = 'payroll_cost_center',
541 print_hide = 1
542 ),
543 dict(
544 fieldname = 'micr_code',
545 label = 'MICR Code',
546 fieldtype = 'Data',
547 insert_after = 'ifsc_code',
548 print_hide = 1,
549 depends_on='eval:doc.salary_mode == "Bank"'
550 ),
551 dict(
552 fieldname = 'provident_fund_account',
553 label = 'Provident Fund Account',
554 fieldtype = 'Data',
555 insert_after = 'pan_number'
556 )
557
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530558 ],
559 'Company': [
560 dict(fieldname='hra_section', label='HRA Settings',
Anurag Mishraa5527222019-06-14 15:25:57 +0530561 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530562 dict(fieldname='basic_component', label='Basic Component',
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530563 fieldtype='Link', options='Salary Component', insert_after='hra_section'),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530564 dict(fieldname='hra_component', label='HRA Component',
565 fieldtype='Link', options='Salary Component', insert_after='basic_component'),
Saqibce129a12021-08-24 17:23:14 +0530566 dict(fieldname='hra_column_break', fieldtype='Column Break', insert_after='hra_component'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530567 dict(fieldname='arrear_component', label='Arrear Component',
Mangesh-Khairnar9215de02019-05-06 16:24:10 +0530568 fieldtype='Link', options='Salary Component', insert_after='hra_component'),
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530569 dict(fieldname='non_profit_section', label='Non Profit Settings',
570 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
571 dict(fieldname='company_80g_number', label='80G Number',
572 fieldtype='Data', insert_after='non_profit_section'),
573 dict(fieldname='with_effect_from', label='80G With Effect From',
574 fieldtype='Date', insert_after='company_80g_number'),
Saqibce129a12021-08-24 17:23:14 +0530575 dict(fieldname='non_profit_column_break', fieldtype='Column Break', insert_after='with_effect_from'),
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530576 dict(fieldname='pan_details', label='PAN Number',
577 fieldtype='Data', insert_after='with_effect_from')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530578 ],
579 'Employee Tax Exemption Declaration':[
580 dict(fieldname='hra_section', label='HRA Exemption',
581 fieldtype='Section Break', insert_after='declarations'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530582 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530583 fieldtype='Currency', insert_after='hra_section'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530584 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530585 fieldtype='Check', insert_after='monthly_house_rent', depends_on='monthly_house_rent'),
586 dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure',
587 fieldtype='Currency', insert_after='rented_in_metro_city', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530588 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530589 insert_after='salary_structure_hra', depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530590 dict(fieldname='annual_hra_exemption', label='Annual HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530591 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530592 dict(fieldname='monthly_hra_exemption', label='Monthly HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530593 fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1, depends_on='monthly_house_rent')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530594 ],
595 'Employee Tax Exemption Proof Submission': [
596 dict(fieldname='hra_section', label='HRA Exemption',
597 fieldtype='Section Break', insert_after='tax_exemption_proofs'),
598 dict(fieldname='house_rent_payment_amount', label='House Rent Payment Amount',
599 fieldtype='Currency', insert_after='hra_section'),
600 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530601 fieldtype='Check', insert_after='house_rent_payment_amount', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530602 dict(fieldname='rented_from_date', label='Rented From Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530603 fieldtype='Date', insert_after='rented_in_metro_city', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530604 dict(fieldname='rented_to_date', label='Rented To Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530605 fieldtype='Date', insert_after='rented_from_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530606 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530607 insert_after='rented_to_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530608 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530609 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530610 dict(fieldname='monthly_hra_exemption', label='Monthly Eligible Amount',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530611 fieldtype='Currency', insert_after='monthly_house_rent', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530612 dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530613 fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1, depends_on='house_rent_payment_amount')
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530614 ],
615 'Supplier': [
616 {
Deepesh Garge3ae8d52021-10-20 22:10:21 +0530617 'fieldname': 'pan',
618 'label': 'PAN',
619 'fieldtype': 'Data',
620 'insert_after': 'supplier_type'
621 },
622 {
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530623 'fieldname': 'gst_transporter_id',
624 'label': 'GST Transporter ID',
625 'fieldtype': 'Data',
Deepesh Garge3ae8d52021-10-20 22:10:21 +0530626 'insert_after': 'pan',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530627 'depends_on': 'eval:doc.is_transporter'
Deepesh Garg22b61602019-03-21 20:47:47 +0530628 },
629 {
630 'fieldname': 'gst_category',
631 'label': 'GST Category',
632 'fieldtype': 'Select',
633 'insert_after': 'gst_transporter_id',
634 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
635 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530636 },
637 {
638 'fieldname': 'export_type',
639 'label': 'Export Type',
640 'fieldtype': 'Select',
641 'insert_after': 'gst_category',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530642 'depends_on':'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
Deepesh Garg3f07bb72021-08-16 13:18:39 +0530643 'options': '\nWith Payment of Tax\nWithout Payment of Tax',
644 'mandatory_depends_on': 'eval:in_list(["SEZ", "Overseas"], doc.gst_category)'
Deepesh Garg22b61602019-03-21 20:47:47 +0530645 }
646 ],
647 'Customer': [
648 {
Deepesh Garge3ae8d52021-10-20 22:10:21 +0530649 'fieldname': 'pan',
650 'label': 'PAN',
651 'fieldtype': 'Data',
652 'insert_after': 'customer_type'
653 },
654 {
Deepesh Garg22b61602019-03-21 20:47:47 +0530655 'fieldname': 'gst_category',
656 'label': 'GST Category',
657 'fieldtype': 'Select',
Deepesh Garge3ae8d52021-10-20 22:10:21 +0530658 'insert_after': 'pan',
Deepesh Garg22b61602019-03-21 20:47:47 +0530659 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
660 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530661 },
662 {
663 'fieldname': 'export_type',
664 'label': 'Export Type',
665 'fieldtype': 'Select',
666 'insert_after': 'gst_category',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530667 'depends_on':'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
Deepesh Garg3f07bb72021-08-16 13:18:39 +0530668 'options': '\nWith Payment of Tax\nWithout Payment of Tax',
669 'mandatory_depends_on': 'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)'
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530670 }
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530671 ],
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530672 'Member': [
673 {
674 'fieldname': 'pan_number',
675 'label': 'PAN Details',
676 'fieldtype': 'Data',
677 'insert_after': 'email_id'
678 }
679 ],
680 'Donor': [
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530681 {
682 'fieldname': 'pan_number',
683 'label': 'PAN Details',
684 'fieldtype': 'Data',
685 'insert_after': 'email'
686 }
Saqib424efd42021-09-28 18:12:02 +0530687 ],
688 'Finance Book': [
689 {
690 'fieldname': 'for_income_tax',
691 'label': 'For Income Tax',
692 'fieldtype': 'Check',
693 'insert_after': 'finance_book_name',
694 'description': 'If the asset is put to use for less than 180 days, the first Depreciation Rate will be reduced by 50%.'
695 }
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530696 ]
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530697 }
Saqib Ansarif1fcb382021-09-29 19:56:02 +0530698
699 return custom_fields
Nabin Hait9c421612017-07-20 13:32:01 +0530700
Saurabh2d8a7ee2018-05-11 13:16:16 +0530701def make_fixtures(company=None):
702 docs = []
Deepesh Garga66184f2021-05-02 12:22:16 +0530703 company = company or frappe.db.get_value("Global Defaults", None, "default_company")
Saurabh2d8a7ee2018-05-11 13:16:16 +0530704
705 set_salary_components(docs)
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530706 set_tds_account(docs, company)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530707
708 for d in docs:
709 try:
710 doc = frappe.get_doc(d)
711 doc.flags.ignore_permissions = True
712 doc.insert()
713 except frappe.NameError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530714 frappe.clear_messages()
Zarrar7f8024c2018-08-01 17:45:05 +0530715 except frappe.DuplicateEntryError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530716 frappe.clear_messages()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530717
Zarrar7f8024c2018-08-01 17:45:05 +0530718 # create records for Tax Withholding Category
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530719 set_tax_withholding_category(company)
720
Deepesh Gargb3ed8072021-06-02 13:26:21 +0530721def update_regional_tax_settings(country, company):
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530722 # Will only add default GST accounts if present
723 input_account_names = ['Input Tax CGST', 'Input Tax SGST', 'Input Tax IGST']
724 output_account_names = ['Output Tax CGST', 'Output Tax SGST', 'Output Tax IGST']
Deepesh Garg48b1a822021-05-29 23:54:51 +0530725 rcm_accounts = ['Input Tax CGST RCM', 'Input Tax SGST RCM', 'Input Tax IGST RCM']
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530726 gst_settings = frappe.get_single('GST Settings')
727 existing_account_list = []
728
729 for account in gst_settings.get('gst_accounts'):
730 for key in ['cgst_account', 'sgst_account', 'igst_account']:
731 existing_account_list.append(account.get(key))
732
733 gst_accounts = frappe._dict(frappe.get_all("Account",
Deepesh Garg48b1a822021-05-29 23:54:51 +0530734 {'company': company, 'account_name': ('in', input_account_names +
735 output_account_names + rcm_accounts)}, ['account_name', 'name'], as_list=1))
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530736
Deepesh Garg48b1a822021-05-29 23:54:51 +0530737 add_accounts_in_gst_settings(company, input_account_names, gst_accounts,
738 existing_account_list, gst_settings)
739 add_accounts_in_gst_settings(company, output_account_names, gst_accounts,
740 existing_account_list, gst_settings)
741 add_accounts_in_gst_settings(company, rcm_accounts, gst_accounts,
742 existing_account_list, gst_settings, is_reverse_charge=1)
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530743
744 gst_settings.save()
745
Deepesh Garg48b1a822021-05-29 23:54:51 +0530746def add_accounts_in_gst_settings(company, account_names, gst_accounts,
747 existing_account_list, gst_settings, is_reverse_charge=0):
748 accounts_not_added = 1
749
750 for account in account_names:
751 # Default Account Added does not exists
752 if not gst_accounts.get(account):
753 accounts_not_added = 0
754
755 # Check if already added in GST Settings
756 if gst_accounts.get(account) in existing_account_list:
757 accounts_not_added = 0
758
759 if accounts_not_added:
760 gst_settings.append('gst_accounts', {
761 'company': company,
762 'cgst_account': gst_accounts.get(account_names[0]),
763 'sgst_account': gst_accounts.get(account_names[1]),
764 'igst_account': gst_accounts.get(account_names[2]),
765 'is_reverse_charge_account': is_reverse_charge
766 })
767
Saurabh2d8a7ee2018-05-11 13:16:16 +0530768def set_salary_components(docs):
769 docs.extend([
Nabin Hait58ee6c12020-04-26 17:45:57 +0530770 {'doctype': 'Salary Component', 'salary_component': 'Professional Tax',
771 'description': 'Professional Tax', 'type': 'Deduction', 'exempted_from_income_tax': 1},
772 {'doctype': 'Salary Component', 'salary_component': 'Provident Fund',
773 'description': 'Provident fund', 'type': 'Deduction', 'is_tax_applicable': 1},
774 {'doctype': 'Salary Component', 'salary_component': 'House Rent Allowance',
775 'description': 'House Rent Allowance', 'type': 'Earning', 'is_tax_applicable': 1},
776 {'doctype': 'Salary Component', 'salary_component': 'Basic',
777 'description': 'Basic', 'type': 'Earning', 'is_tax_applicable': 1},
778 {'doctype': 'Salary Component', 'salary_component': 'Arrear',
779 'description': 'Arrear', 'type': 'Earning', 'is_tax_applicable': 1},
780 {'doctype': 'Salary Component', 'salary_component': 'Leave Encashment',
781 'description': 'Leave Encashment', 'type': 'Earning', 'is_tax_applicable': 1}
Saurabh2d8a7ee2018-05-11 13:16:16 +0530782 ])
783
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530784def set_tax_withholding_category(company):
Saurabh2d8a7ee2018-05-11 13:16:16 +0530785 accounts = []
Saqibf8c1c732021-09-26 16:27:56 +0530786 fiscal_year_details = None
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530787 abbr = frappe.get_value("Company", company, "abbr")
788 tds_account = frappe.get_value("Account", 'TDS Payable - {0}'.format(abbr), 'name')
Saurabh2d8a7ee2018-05-11 13:16:16 +0530789
790 if company and tds_account:
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530791 accounts = [dict(company=company, account=tds_account)]
Saurabh2d8a7ee2018-05-11 13:16:16 +0530792
Anuja Pawar4569e522021-01-14 19:24:30 +0530793 try:
Subin Tom350ed1a2021-11-19 21:05:25 +0530794 fiscal_year_details = get_fiscal_year(today(), verbose=0)
Anuja Pawar4569e522021-01-14 19:24:30 +0530795 except FiscalYearError:
796 pass
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530797
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530798 docs = get_tds_details(accounts, fiscal_year_details)
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530799
Zarrar7f8024c2018-08-01 17:45:05 +0530800 for d in docs:
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530801 if not frappe.db.exists("Tax Withholding Category", d.get("name")):
Zarrar7f8024c2018-08-01 17:45:05 +0530802 doc = frappe.get_doc(d)
Deepesh Garg204ea102021-04-30 16:35:52 +0530803 doc.flags.ignore_validate = True
Zarrar7f8024c2018-08-01 17:45:05 +0530804 doc.flags.ignore_permissions = True
Nabin Haitafef9c12019-02-12 11:28:20 +0530805 doc.flags.ignore_mandatory = True
Zarrar7f8024c2018-08-01 17:45:05 +0530806 doc.insert()
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530807 else:
Deepesh Gargfea29ae2021-07-12 18:29:52 +0530808 doc = frappe.get_doc("Tax Withholding Category", d.get("name"), for_update=True)
Zarrar963d62b2019-03-23 10:30:12 +0530809
810 if accounts:
811 doc.append("accounts", accounts[0])
Zarrar7f8024c2018-08-01 17:45:05 +0530812
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530813 if fiscal_year_details:
Anuja Pawar4569e522021-01-14 19:24:30 +0530814 # if fiscal year don't match with any of the already entered data, append rate row
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530815 fy_exist = [k for k in doc.get('rates') if k.get('from_date') <= fiscal_year_details[1] \
816 and k.get('to_date') >= fiscal_year_details[2]]
Anuja Pawar4569e522021-01-14 19:24:30 +0530817 if not fy_exist:
818 doc.append("rates", d.get('rates')[0])
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530819
Anuja Pawar4569e522021-01-14 19:24:30 +0530820 doc.flags.ignore_permissions = True
Deepesh Garg48b1a822021-05-29 23:54:51 +0530821 doc.flags.ignore_validate = True
Anuja Pawar4569e522021-01-14 19:24:30 +0530822 doc.flags.ignore_mandatory = True
Deepesh Garg204ea102021-04-30 16:35:52 +0530823 doc.flags.ignore_links = True
Zarrar7f8024c2018-08-01 17:45:05 +0530824 doc.save()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530825
826def set_tds_account(docs, company):
Nabin Haitf77cd542018-11-20 16:46:25 +0530827 parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
828 if parent_account:
829 docs.extend([
830 {
831 "doctype": "Account",
832 "account_name": "TDS Payable",
833 "account_type": "Tax",
834 "parent_account": parent_account,
835 "company": company
836 }
837 ])
Zarrar7f8024c2018-08-01 17:45:05 +0530838
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530839def get_tds_details(accounts, fiscal_year_details):
Zarrar7f8024c2018-08-01 17:45:05 +0530840 # bootstrap default tax withholding sections
841 return [
842 dict(name="TDS - 194C - Company",
843 category_name="Payment to Contractors (Single / Aggregate)",
844 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530845 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
846 "tax_withholding_rate": 2, "single_threshold": 30000, "cumulative_threshold": 100000}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530847 dict(name="TDS - 194C - Individual",
848 category_name="Payment to Contractors (Single / Aggregate)",
849 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530850 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
851 "tax_withholding_rate": 1, "single_threshold": 30000, "cumulative_threshold": 100000}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530852 dict(name="TDS - 194C - No PAN / Invalid PAN",
853 category_name="Payment to Contractors (Single / Aggregate)",
854 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530855 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
856 "tax_withholding_rate": 20, "single_threshold": 30000, "cumulative_threshold": 100000}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530857 dict(name="TDS - 194D - Company",
858 category_name="Insurance Commission",
859 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530860 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
861 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530862 dict(name="TDS - 194D - Company Assessee",
863 category_name="Insurance Commission",
864 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530865 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
866 "tax_withholding_rate": 10, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530867 dict(name="TDS - 194D - Individual",
868 category_name="Insurance Commission",
869 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530870 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
871 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530872 dict(name="TDS - 194D - No PAN / Invalid PAN",
873 category_name="Insurance Commission",
874 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530875 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
876 "tax_withholding_rate": 20, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530877 dict(name="TDS - 194DA - Company",
878 category_name="Non-exempt payments made under a life insurance policy",
879 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530880 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
881 "tax_withholding_rate": 1, "single_threshold": 100000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530882 dict(name="TDS - 194DA - Individual",
883 category_name="Non-exempt payments made under a life insurance policy",
884 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530885 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
886 "tax_withholding_rate": 1, "single_threshold": 100000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530887 dict(name="TDS - 194DA - No PAN / Invalid PAN",
888 category_name="Non-exempt payments made under a life insurance policy",
889 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530890 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
891 "tax_withholding_rate": 20, "single_threshold": 100000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530892 dict(name="TDS - 194H - Company",
893 category_name="Commission / Brokerage",
894 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530895 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
896 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530897 dict(name="TDS - 194H - Individual",
898 category_name="Commission / Brokerage",
899 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530900 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
901 "tax_withholding_rate": 5, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530902 dict(name="TDS - 194H - No PAN / Invalid PAN",
903 category_name="Commission / Brokerage",
904 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530905 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
906 "tax_withholding_rate": 20, "single_threshold": 15000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530907 dict(name="TDS - 194I - Rent - Company",
908 category_name="Rent",
909 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530910 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
911 "tax_withholding_rate": 10, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530912 dict(name="TDS - 194I - Rent - Individual",
913 category_name="Rent",
914 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530915 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
916 "tax_withholding_rate": 10, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530917 dict(name="TDS - 194I - Rent - No PAN / Invalid PAN",
918 category_name="Rent",
919 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530920 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
921 "tax_withholding_rate": 20, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530922 dict(name="TDS - 194I - Rent/Machinery - Company",
923 category_name="Rent-Plant / Machinery",
924 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530925 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
926 "tax_withholding_rate": 2, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530927 dict(name="TDS - 194I - Rent/Machinery - Individual",
928 category_name="Rent-Plant / Machinery",
929 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530930 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
931 "tax_withholding_rate": 2, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530932 dict(name="TDS - 194I - Rent/Machinery - No PAN / Invalid PAN",
933 category_name="Rent-Plant / Machinery",
934 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530935 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
936 "tax_withholding_rate": 20, "single_threshold": 180000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530937 dict(name="TDS - 194J - Professional Fees - Company",
938 category_name="Professional Fees",
939 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530940 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
941 "tax_withholding_rate": 10, "single_threshold": 30000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530942 dict(name="TDS - 194J - Professional Fees - Individual",
943 category_name="Professional Fees",
944 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530945 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
946 "tax_withholding_rate": 10, "single_threshold": 30000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530947 dict(name="TDS - 194J - Professional Fees - No PAN / Invalid PAN",
948 category_name="Professional Fees",
949 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530950 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
951 "tax_withholding_rate": 20, "single_threshold": 30000, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530952 dict(name="TDS - 194J - Director Fees - Company",
953 category_name="Director Fees",
954 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530955 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
956 "tax_withholding_rate": 10, "single_threshold": 0, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530957 dict(name="TDS - 194J - Director Fees - Individual",
958 category_name="Director Fees",
959 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530960 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
961 "tax_withholding_rate": 10, "single_threshold": 0, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530962 dict(name="TDS - 194J - Director Fees - No PAN / Invalid PAN",
963 category_name="Director Fees",
964 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530965 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
966 "tax_withholding_rate": 20, "single_threshold": 0, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530967 dict(name="TDS - 194 - Dividends - Company",
968 category_name="Dividends",
969 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530970 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
971 "tax_withholding_rate": 10, "single_threshold": 2500, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530972 dict(name="TDS - 194 - Dividends - Individual",
973 category_name="Dividends",
974 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530975 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
976 "tax_withholding_rate": 10, "single_threshold": 2500, "cumulative_threshold": 0}]),
Zarrar7f8024c2018-08-01 17:45:05 +0530977 dict(name="TDS - 194 - Dividends - No PAN / Invalid PAN",
978 category_name="Dividends",
979 doctype="Tax Withholding Category", accounts=accounts,
Deepesh Gargc53b78e2021-09-14 20:28:48 +0530980 rates=[{"from_date": fiscal_year_details[1], "to_date": fiscal_year_details[2],
981 "tax_withholding_rate": 20, "single_threshold": 2500, "cumulative_threshold": 0}])
Anurag Mishrae1464a72020-08-17 15:03:32 +0530982 ]
983
Anurag Mishra25c35682020-08-18 14:13:54 +0530984def create_gratuity_rule():
Anurag Mishrae1464a72020-08-17 15:03:32 +0530985 # Standard Indain Gratuity Rule
Anurag Mishra493eea12020-08-18 15:02:32 +0530986 if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
987 rule = frappe.new_doc("Gratuity Rule")
988 rule.name = "Indian Standard Gratuity Rule"
989 rule.calculate_gratuity_amount_based_on = "Current Slab"
990 rule.work_experience_calculation_method = "Round Off Work Experience"
991 rule.minimum_year_for_gratuity = 5
Anurag Mishrae1464a72020-08-17 15:03:32 +0530992
Anurag Mishra493eea12020-08-18 15:02:32 +0530993 fraction = 15/26
994 rule.append("gratuity_rule_slabs", {
995 "from_year": 0,
996 "to_year":0,
997 "fraction_of_applicable_earnings": fraction
998 })
Anurag Mishrae1464a72020-08-17 15:03:32 +0530999
Anurag Mishra493eea12020-08-18 15:02:32 +05301000 rule.flags.ignore_mandatory = True
Sagar Vora4c31fbb2021-04-01 15:32:37 +05301001 rule.save()
Deepesh Garg204ea102021-04-30 16:35:52 +05301002
1003def update_accounts_settings_for_taxes():
1004 if frappe.db.count('Company') == 1:
Saqib84c41612021-08-10 16:46:44 +05301005 frappe.db.set_value('Accounts Settings', None, "add_taxes_from_item_tax_template", 0)