blob: 5f9d5ed0d61111b30a4c5c2733d15a4c8974b164 [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):
Nabin Hait10c61372021-04-13 15:46:01 +053015 setup_company_independent_fixtures(patch=patch)
Prateeksha Singh39b87652018-11-12 17:19:56 +053016 if not patch:
Prateeksha Singhdabf3492018-11-13 15:56:15 +053017 make_fixtures(company)
Prateeksha Singh39b87652018-11-12 17:19:56 +053018
19# TODO: for all countries
Nabin Hait10c61372021-04-13 15:46:01 +053020def setup_company_independent_fixtures(patch=False):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053021 make_custom_fields()
Nabin Hait10c61372021-04-13 15:46:01 +053022 make_property_setters(patch=patch)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053023 add_permissions()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053024 add_custom_roles_for_reports()
Nabin Haitc3144852017-09-28 18:55:40 +053025 frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes', now=frappe.flags.in_test)
Anurag Mishra25c35682020-08-18 14:13:54 +053026 create_gratuity_rule()
Nabin Hait852cb642017-07-05 12:58:19 +053027 add_print_formats()
Deepesh Garg204ea102021-04-30 16:35:52 +053028 update_accounts_settings_for_taxes()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053029
Nabin Hait1a609312017-07-13 12:16:04 +053030def add_hsn_sac_codes():
Ankush Menat5bb89b02021-06-11 15:57:01 +053031 if frappe.flags.in_test and frappe.flags.created_hsn_codes:
32 return
33
Nabin Hait1a609312017-07-13 12:16:04 +053034 # HSN codes
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053035 with open(os.path.join(os.path.dirname(__file__), 'hsn_code_data.json'), 'r') as f:
36 hsn_codes = json.loads(f.read())
37
Nabin Hait1a609312017-07-13 12:16:04 +053038 create_hsn_codes(hsn_codes, code_field="hsn_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053039
Nabin Hait1a609312017-07-13 12:16:04 +053040 # SAC Codes
41 with open(os.path.join(os.path.dirname(__file__), 'sac_code_data.json'), 'r') as f:
42 sac_codes = json.loads(f.read())
43 create_hsn_codes(sac_codes, code_field="sac_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053044
Ankush Menat5bb89b02021-06-11 15:57:01 +053045 if frappe.flags.in_test:
46 frappe.flags.created_hsn_codes = True
47
Nabin Hait1a609312017-07-13 12:16:04 +053048def create_hsn_codes(data, code_field):
49 for d in data:
Rushabh Mehtaf702d722017-09-27 15:31:30 +053050 hsn_code = frappe.new_doc('GST HSN Code')
51 hsn_code.description = d["description"]
52 hsn_code.hsn_code = d[code_field]
53 hsn_code.name = d[code_field]
54 try:
Nabin Hait1a609312017-07-13 12:16:04 +053055 hsn_code.db_insert()
Rushabh Mehtaf702d722017-09-27 15:31:30 +053056 except frappe.DuplicateEntryError:
57 pass
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053058
Rushabh Mehta919a74a2017-06-22 16:37:04 +053059def add_custom_roles_for_reports():
60 for report_name in ('GST Sales Register', 'GST Purchase Register',
Saqib93203162021-04-12 17:55:46 +053061 'GST Itemised Sales Register', 'GST Itemised Purchase Register', 'Eway Bill', 'E-Invoice Summary'):
Rushabh Mehta919a74a2017-06-22 16:37:04 +053062
Rushabh Mehta919a74a2017-06-22 16:37:04 +053063 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
64 frappe.get_doc(dict(
65 doctype='Custom Role',
66 report=report_name,
67 roles= [
68 dict(role='Accounts User'),
69 dict(role='Accounts Manager')
70 ]
71 )).insert()
72
Anurag Mishra289c8222020-06-19 19:17:57 +053073 for report_name in ('Professional Tax Deductions', 'Provident Fund Deductions'):
74
75 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
76 frappe.get_doc(dict(
77 doctype='Custom Role',
78 report=report_name,
79 roles= [
80 dict(role='HR User'),
81 dict(role='HR Manager'),
82 dict(role='Employee')
83 ]
84 )).insert()
85
Anurag Mishra54cd1942020-09-03 13:51:26 +053086 for report_name in ('HSN-wise-summary of outward supplies', 'GSTR-1', 'GSTR-2'):
87
88 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
89 frappe.get_doc(dict(
90 doctype='Custom Role',
91 report=report_name,
92 roles= [
93 dict(role='Accounts User'),
94 dict(role='Accounts Manager'),
95 dict(role='Auditor')
96 ]
97 )).insert()
98
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053099def add_permissions():
Saqib6d74f5b2020-12-25 10:26:43 +0530100 for doctype in ('GST HSN Code', 'GST Settings', 'GSTR 3B Report', 'Lower Deduction Certificate', 'E Invoice Settings'):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530101 add_permission(doctype, 'All', 0)
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530102 for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
Saqib5e6ce882020-02-03 15:40:35 +0530103 add_permission(doctype, role, 0)
104 update_permission_property(doctype, role, 0, 'write', 1)
105 update_permission_property(doctype, role, 0, 'create', 1)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530106
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530107 if doctype == 'GST HSN Code':
108 for role in ('Item Manager', 'Stock Manager'):
109 add_permission(doctype, role, 0)
110 update_permission_property(doctype, role, 0, 'write', 1)
111 update_permission_property(doctype, role, 0, 'create', 1)
112
Nabin Hait852cb642017-07-05 12:58:19 +0530113def add_print_formats():
114 frappe.reload_doc("regional", "print_format", "gst_tax_invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530115 frappe.reload_doc("accounts", "print_format", "gst_pos_invoice")
Saqib6d74f5b2020-12-25 10:26:43 +0530116 frappe.reload_doc("accounts", "print_format", "GST E-Invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530117
barredterra1521b312021-03-03 12:33:48 +0100118 frappe.db.set_value("Print Format", "GST POS Invoice", "disabled", 0)
119 frappe.db.set_value("Print Format", "GST Tax Invoice", "disabled", 0)
120 frappe.db.set_value("Print Format", "GST E-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']
125
Nabin Hait10c61372021-04-13 15:46:01 +0530126 if not patch:
127 make_property_setter('Sales Invoice', 'naming_series', 'options', 'SINV-.YY.-\nSRET-.YY.-', '')
128 make_property_setter('Purchase Invoice', 'naming_series', 'options', 'PINV-.YY.-\nPRET-.YY.-', '')
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530129 make_property_setter('Journal Entry', 'voucher_type', 'options', '\n'.join(journal_entry_types), '')
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530130
Rushabh Mehta69fa8082018-07-17 18:22:51 +0530131def make_custom_fields(update=True):
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530132 hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
Nabin Haitd34bfa82018-11-13 18:19:58 +0530133 fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description',
Nabin Haitf4af6082019-04-01 11:51:54 +0530134 allow_on_submit=1, print_hide=1, fetch_if_empty=1)
Marica9942acd2020-04-21 13:13:39 +0530135 nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530136 fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code',
137 print_hide=1)
138 is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST',
139 fieldtype='Check', fetch_from='item_code.is_non_gst', insert_after='is_nil_exempt',
140 print_hide=1)
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530141 taxable_value = dict(fieldname='taxable_value', label='Taxable Value',
142 fieldtype='Currency', insert_after='base_net_amount', hidden=1, options="Company:company:default_currency",
143 print_hide=1)
Deepesh Garg22b61602019-03-21 20:47:47 +0530144
145 purchase_invoice_gst_category = [
Nabin Hait879e1622017-08-21 08:28:55 +0530146 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
vishdha109b4082018-01-30 12:11:13 +0530147 insert_after='language', print_hide=1, collapsible=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530148 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530149 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530150 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530151 fetch_from='supplier.gst_category', fetch_if_empty=1),
152 dict(fieldname='export_type', label='Export Type',
153 fieldtype='Select', insert_after='gst_category', print_hide=1,
154 depends_on='eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
155 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='supplier.export_type',
156 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530157 ]
158
159 sales_invoice_gst_category = [
160 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
161 insert_after='language', print_hide=1, collapsible=1),
162 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530163 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530164 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530165 fetch_from='customer.gst_category', fetch_if_empty=1),
166 dict(fieldname='export_type', label='Export Type',
167 fieldtype='Select', insert_after='gst_category', print_hide=1,
168 depends_on='eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
169 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='customer.export_type',
170 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530171 ]
172
Deepesh Garg29997412021-03-29 19:49:52 +0530173 delivery_note_gst_category = [
174 dict(fieldname='gst_category', label='GST Category',
175 fieldtype='Select', insert_after='gst_vehicle_type', print_hide=1,
176 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
177 fetch_from='customer.gst_category', fetch_if_empty=1),
178 ]
179
Deepesh Garg22b61602019-03-21 20:47:47 +0530180 invoice_gst_fields = [
Nabin Hait879e1622017-08-21 08:28:55 +0530181 dict(fieldname='invoice_copy', label='Invoice Copy',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530182 fieldtype='Select', insert_after='export_type', print_hide=1, allow_on_submit=1,
Nabin Hait879e1622017-08-21 08:28:55 +0530183 options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'),
184 dict(fieldname='reverse_charge', label='Reverse Charge',
185 fieldtype='Select', insert_after='invoice_copy', print_hide=1,
186 options='Y\nN', default='N'),
Nabin Hait879e1622017-08-21 08:28:55 +0530187 dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN',
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530188 fieldtype='Data', insert_after='export_type', print_hide=1),
Nabin Haite6d65bc2018-02-14 17:44:06 +0530189 dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='ecommerce_gstin'),
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530190 dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document',
Nabin Haitb02c1092018-02-05 16:09:51 +0530191 fieldtype='Select', insert_after='gst_col_break', print_hide=1,
Nabin Haite6d65bc2018-02-14 17:44:06 +0530192 depends_on='eval:doc.is_return==1',
Nabin Haita8d10b72018-02-12 16:54:13 +0530193 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 +0530194 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530195
Nabin Hait879e1622017-08-21 08:28:55 +0530196 purchase_invoice_gst_fields = [
197 dict(fieldname='supplier_gstin', label='Supplier GSTIN',
198 fieldtype='Data', insert_after='supplier_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530199 fetch_from='supplier_address.gstin', print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530200 dict(fieldname='company_gstin', label='Company GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530201 fieldtype='Data', insert_after='shipping_address_display',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530202 fetch_from='shipping_address.gstin', print_hide=1, read_only=1),
Nabin Haitb02c1092018-02-05 16:09:51 +0530203 dict(fieldname='place_of_supply', label='Place of Supply',
204 fieldtype='Data', insert_after='shipping_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530205 print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530206 ]
207
208 purchase_invoice_itc_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530209 dict(fieldname='eligibility_for_itc', label='Eligibility For ITC',
210 fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530211 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',
212 default="All Other ITC"),
vishdha98e33c32018-01-29 13:57:34 +0530213 dict(fieldname='itc_integrated_tax', label='Availed ITC Integrated Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530214 fieldtype='Currency', insert_after='eligibility_for_itc',
215 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530216 dict(fieldname='itc_central_tax', label='Availed ITC Central Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530217 fieldtype='Currency', insert_after='itc_integrated_tax',
218 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530219 dict(fieldname='itc_state_tax', label='Availed ITC State/UT Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530220 fieldtype='Currency', insert_after='itc_central_tax',
221 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530222 dict(fieldname='itc_cess_amount', label='Availed ITC Cess',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530223 fieldtype='Currency', insert_after='itc_state_tax',
224 options='Company:company:default_currency', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530225 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530226
Nabin Hait879e1622017-08-21 08:28:55 +0530227 sales_invoice_gst_fields = [
rohitwaghchaure16645802017-09-28 11:05:03 +0530228 dict(fieldname='billing_address_gstin', label='Billing Address GSTIN',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530229 fieldtype='Data', insert_after='customer_address', read_only=1,
Shreya Shah4fa600a2018-06-05 11:27:53 +0530230 fetch_from='customer_address.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530231 dict(fieldname='customer_gstin', label='Customer GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530232 fieldtype='Data', insert_after='shipping_address_name',
233 fetch_from='shipping_address_name.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530234 dict(fieldname='place_of_supply', label='Place of Supply',
Nabin Hait619c42b2018-01-10 17:48:03 +0530235 fieldtype='Data', insert_after='customer_gstin',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530236 print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530237 dict(fieldname='company_gstin', label='Company GSTIN',
238 fieldtype='Data', insert_after='company_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530239 fetch_from='company_address.gstin', print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530240 ]
241
242 sales_invoice_shipping_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530243 dict(fieldname='port_code', label='Port Code',
244 fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530245 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530246 dict(fieldname='shipping_bill_number', label=' Shipping Bill Number',
247 fieldtype='Data', insert_after='port_code', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530248 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530249 dict(fieldname='shipping_bill_date', label='Shipping Bill Date',
250 fieldtype='Date', insert_after='shipping_bill_number', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530251 depends_on="eval:doc.gst_category=='Overseas' "),
Nabin Hait879e1622017-08-21 08:28:55 +0530252 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530253
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530254 journal_entry_fields = [
255 dict(fieldname='reversal_type', label='Reversal Type',
256 fieldtype='Select', insert_after='voucher_type', print_hide=1,
257 options="As per rules 42 & 43 of CGST Rules\nOthers",
258 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
259 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
260 dict(fieldname='company_address', label='Company Address',
261 fieldtype='Link', options='Address', insert_after='reversal_type',
262 print_hide=1, depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
263 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
264 dict(fieldname='company_gstin', label='Company GSTIN',
265 fieldtype='Data', read_only=1, insert_after='company_address', print_hide=1,
266 fetch_from='company_address.gstin',
267 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
268 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'")
269 ]
270
Shreya Shah4fa600a2018-06-05 11:27:53 +0530271 inter_state_gst_field = [
272 dict(fieldname='is_inter_state', label='Is Inter State',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530273 fieldtype='Check', insert_after='disabled', print_hide=1),
274 dict(fieldname='tax_category_column_break', fieldtype='Column Break',
275 insert_after='is_inter_state'),
276 dict(fieldname='gst_state', label='Source State', fieldtype='Select',
277 options='\n'.join(states), insert_after='company')
Shreya Shah4fa600a2018-06-05 11:27:53 +0530278 ]
279
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530280 ewaybill_fields = [
281 {
282 'fieldname': 'distance',
283 'label': 'Distance (in km)',
284 'fieldtype': 'Float',
285 'insert_after': 'vehicle_no',
286 'print_hide': 1
287 },
288 {
289 'fieldname': 'gst_transporter_id',
290 'label': 'GST Transporter ID',
291 'fieldtype': 'Data',
Nabin Hait34c551d2019-07-03 10:34:31 +0530292 'insert_after': 'transporter',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530293 'fetch_from': 'transporter.gst_transporter_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530294 'print_hide': 1,
295 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530296 },
297 {
298 'fieldname': 'mode_of_transport',
299 'label': 'Mode of Transport',
300 'fieldtype': 'Select',
301 'options': '\nRoad\nAir\nRail\nShip',
302 'default': 'Road',
Nabin Hait34c551d2019-07-03 10:34:31 +0530303 'insert_after': 'transporter_name',
304 'print_hide': 1,
305 'translatable': 0
306 },
307 {
308 'fieldname': 'gst_vehicle_type',
309 'label': 'GST Vehicle Type',
310 'fieldtype': 'Select',
311 'options': 'Regular\nOver Dimensional Cargo (ODC)',
312 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
313 'default': 'Regular',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530314 'insert_after': 'lr_date',
Nabin Hait34c551d2019-07-03 10:34:31 +0530315 'print_hide': 1,
316 'translatable': 0
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530317 },
318 {
319 'fieldname': 'ewaybill',
320 'label': 'E-Way Bill No.',
321 'fieldtype': 'Data',
322 'depends_on': 'eval:(doc.docstatus === 1)',
323 'allow_on_submit': 1,
324 'insert_after': 'customer_name_in_arabic',
325 'translatable': 0,
Deepesh Garg29997412021-03-29 19:49:52 +0530326 }
Nabin Hait34c551d2019-07-03 10:34:31 +0530327 ]
328
329 si_ewaybill_fields = [
330 {
331 'fieldname': 'transporter_info',
332 'label': 'Transporter Info',
333 'fieldtype': 'Section Break',
334 'insert_after': 'terms',
335 'collapsible': 1,
336 'collapsible_depends_on': 'transporter',
337 'print_hide': 1
338 },
339 {
340 'fieldname': 'transporter',
341 'label': 'Transporter',
342 'fieldtype': 'Link',
343 'insert_after': 'transporter_info',
344 'options': 'Supplier',
345 'print_hide': 1
346 },
347 {
348 'fieldname': 'gst_transporter_id',
349 'label': 'GST Transporter ID',
350 'fieldtype': 'Data',
351 'insert_after': 'transporter',
352 'fetch_from': 'transporter.gst_transporter_id',
353 'print_hide': 1,
354 'translatable': 0
355 },
356 {
357 'fieldname': 'driver',
358 'label': 'Driver',
359 'fieldtype': 'Link',
360 'insert_after': 'gst_transporter_id',
361 'options': 'Driver',
362 'print_hide': 1
363 },
364 {
365 'fieldname': 'lr_no',
366 'label': 'Transport Receipt No',
367 'fieldtype': 'Data',
368 'insert_after': 'driver',
369 'print_hide': 1,
370 'translatable': 0
371 },
372 {
373 'fieldname': 'vehicle_no',
374 'label': 'Vehicle No',
375 'fieldtype': 'Data',
376 'insert_after': 'lr_no',
377 'print_hide': 1,
378 'translatable': 0
379 },
380 {
381 'fieldname': 'distance',
382 'label': 'Distance (in km)',
383 'fieldtype': 'Float',
384 'insert_after': 'vehicle_no',
385 'print_hide': 1
386 },
387 {
388 'fieldname': 'transporter_col_break',
389 'fieldtype': 'Column Break',
390 'insert_after': 'distance'
391 },
392 {
393 'fieldname': 'transporter_name',
394 'label': 'Transporter Name',
395 'fieldtype': 'Data',
396 'insert_after': 'transporter_col_break',
397 'fetch_from': 'transporter.name',
398 'read_only': 1,
399 'print_hide': 1,
400 'translatable': 0
401 },
402 {
403 'fieldname': 'mode_of_transport',
404 'label': 'Mode of Transport',
405 'fieldtype': 'Select',
406 'options': '\nRoad\nAir\nRail\nShip',
Nabin Hait34c551d2019-07-03 10:34:31 +0530407 'insert_after': 'transporter_name',
408 'print_hide': 1,
409 'translatable': 0
410 },
411 {
412 'fieldname': 'driver_name',
413 'label': 'Driver Name',
414 'fieldtype': 'Data',
415 'insert_after': 'mode_of_transport',
416 'fetch_from': 'driver.full_name',
417 'print_hide': 1,
418 'translatable': 0
419 },
420 {
421 'fieldname': 'lr_date',
422 'label': 'Transport Receipt Date',
423 'fieldtype': 'Date',
424 'insert_after': 'driver_name',
425 'default': 'Today',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530426 'print_hide': 1
427 },
428 {
429 'fieldname': 'gst_vehicle_type',
430 'label': 'GST Vehicle Type',
431 'fieldtype': 'Select',
Nabin Hait34c551d2019-07-03 10:34:31 +0530432 'options': 'Regular\nOver Dimensional Cargo (ODC)',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530433 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
Nabin Hait34c551d2019-07-03 10:34:31 +0530434 'default': 'Regular',
435 'insert_after': 'lr_date',
436 'print_hide': 1,
437 'translatable': 0
438 },
439 {
440 'fieldname': 'ewaybill',
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530441 'label': 'E-Way Bill No.',
Nabin Hait34c551d2019-07-03 10:34:31 +0530442 'fieldtype': 'Data',
Saqib6d74f5b2020-12-25 10:26:43 +0530443 'depends_on': 'eval:((doc.docstatus === 1 || doc.ewaybill) && doc.eway_bill_cancelled === 0)',
Nabin Hait34c551d2019-07-03 10:34:31 +0530444 'allow_on_submit': 1,
deepeshgarg007a85db662019-07-14 18:15:19 +0530445 'insert_after': 'tax_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530446 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530447 }
448 ]
449
Saqib6d74f5b2020-12-25 10:26:43 +0530450 si_einvoice_fields = [
451 dict(fieldname='irn', label='IRN', fieldtype='Data', read_only=1, insert_after='customer', no_copy=1, print_hide=1,
452 depends_on='eval:in_list(["Registered Regular", "SEZ", "Overseas", "Deemed Export"], doc.gst_category) && doc.irn_cancelled === 0'),
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530453
Saqib6d74f5b2020-12-25 10:26:43 +0530454 dict(fieldname='irn_cancelled', label='IRN Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
455 depends_on='eval:(doc.irn_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
456
Saqibd502f762021-05-06 16:10:55 +0530457 dict(fieldname='eway_bill_validity', label='E-Way Bill Validity', fieldtype='Data', no_copy=1, print_hide=1,
458 depends_on='ewaybill', read_only=1, allow_on_submit=1, insert_after='ewaybill'),
459
Saqib6d74f5b2020-12-25 10:26:43 +0530460 dict(fieldname='eway_bill_cancelled', label='E-Way Bill Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
461 depends_on='eval:(doc.eway_bill_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
462
Saqib93203162021-04-12 17:55:46 +0530463 dict(fieldname='einvoice_section', label='E-Invoice Fields', fieldtype='Section Break', insert_after='gst_vehicle_type',
464 print_hide=1, hidden=1),
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530465
Saqib93203162021-04-12 17:55:46 +0530466 dict(fieldname='ack_no', label='Ack. No.', fieldtype='Data', read_only=1, hidden=1, insert_after='einvoice_section',
467 no_copy=1, print_hide=1),
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530468
Saqib93203162021-04-12 17:55:46 +0530469 dict(fieldname='ack_date', label='Ack. Date', fieldtype='Data', read_only=1, hidden=1, insert_after='ack_no', no_copy=1, print_hide=1),
Saqib6d74f5b2020-12-25 10:26:43 +0530470
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530471 dict(fieldname='irn_cancel_date', label='Cancel Date', fieldtype='Data', read_only=1, hidden=1, insert_after='ack_date',
Saqib93203162021-04-12 17:55:46 +0530472 no_copy=1, print_hide=1),
Saqib6d74f5b2020-12-25 10:26:43 +0530473
Saqib93203162021-04-12 17:55:46 +0530474 dict(fieldname='signed_einvoice', label='Signed E-Invoice', fieldtype='Code', options='JSON', hidden=1, insert_after='irn_cancel_date',
475 no_copy=1, print_hide=1, read_only=1),
476
477 dict(fieldname='signed_qr_code', label='Signed QRCode', fieldtype='Code', options='JSON', hidden=1, insert_after='signed_einvoice',
478 no_copy=1, print_hide=1, read_only=1),
479
480 dict(fieldname='qrcode_image', label='QRCode', fieldtype='Attach Image', hidden=1, insert_after='signed_qr_code',
481 no_copy=1, print_hide=1, read_only=1),
482
483 dict(fieldname='einvoice_status', label='E-Invoice Status', fieldtype='Select', insert_after='qrcode_image',
484 options='\nPending\nGenerated\nCancelled\nFailed', default=None, hidden=1, no_copy=1, print_hide=1, read_only=1),
485
486 dict(fieldname='failure_description', label='E-Invoice Failure Description', fieldtype='Code', options='JSON',
487 hidden=1, insert_after='einvoice_status', no_copy=1, print_hide=1, read_only=1)
Saqib6d74f5b2020-12-25 10:26:43 +0530488 ]
489
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530490 custom_fields = {
491 'Address': [
Rushabh Mehta919a74a2017-06-22 16:37:04 +0530492 dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data',
493 insert_after='fax'),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530494 dict(fieldname='gst_state', label='GST State', fieldtype='Select',
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530495 options='\n'.join(states), insert_after='gstin'),
496 dict(fieldname='gst_state_number', label='GST State Number',
Nabin Hait562d9422018-09-07 16:14:44 +0530497 fieldtype='Data', insert_after='gst_state', read_only=1),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530498 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530499 'Purchase Invoice': purchase_invoice_gst_category + invoice_gst_fields + purchase_invoice_itc_fields + purchase_invoice_gst_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530500 'Purchase Order': purchase_invoice_gst_fields,
501 'Purchase Receipt': purchase_invoice_gst_fields,
Saqib6d74f5b2020-12-25 10:26:43 +0530502 'Sales Invoice': sales_invoice_gst_category + invoice_gst_fields + sales_invoice_shipping_fields + sales_invoice_gst_fields + si_ewaybill_fields + si_einvoice_fields,
Deepesh Garg29997412021-03-29 19:49:52 +0530503 'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields + delivery_note_gst_category,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530504 'Journal Entry': journal_entry_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530505 'Sales Order': sales_invoice_gst_fields,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530506 'Tax Category': inter_state_gst_field,
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530507 'Item': [
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530508 dict(fieldname='gst_hsn_code', label='HSN/SAC',
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530509 fieldtype='Link', options='GST HSN Code', insert_after='item_group'),
Marica9942acd2020-04-21 13:13:39 +0530510 dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530511 fieldtype='Check', insert_after='gst_hsn_code'),
512 dict(fieldname='is_non_gst', label='Is Non GST ',
513 fieldtype='Check', insert_after='is_nil_exempt')
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530514 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530515 'Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
516 'Supplier Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
517 'Sales Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
518 'Delivery Note Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530519 'Sales Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Deepesh Garg22b61602019-03-21 20:47:47 +0530520 'Purchase Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
521 'Purchase Receipt Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530522 'Purchase Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Himanshu Warekar656d8e42019-04-01 19:38:43 +0530523 'Material Request Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Anurag Mishra289c8222020-06-19 19:17:57 +0530524 'Salary Component': [
525 dict(fieldname= 'component_type',
526 label= 'Component Type',
527 fieldtype= 'Select',
528 insert_after= 'description',
529 options= "\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax",
530 depends_on = 'eval:doc.type == "Deduction"'
531 )
532 ],
Pawan Mehtaf4196352018-04-05 14:54:51 +0530533 'Employee': [
Anurag Mishra289c8222020-06-19 19:17:57 +0530534 dict(fieldname='ifsc_code',
535 label='IFSC Code',
536 fieldtype='Data',
537 insert_after='bank_ac_no',
538 print_hide=1,
539 depends_on='eval:doc.salary_mode == "Bank"'
540 ),
541 dict(
542 fieldname = 'pan_number',
543 label = 'PAN Number',
544 fieldtype = 'Data',
545 insert_after = 'payroll_cost_center',
546 print_hide = 1
547 ),
548 dict(
549 fieldname = 'micr_code',
550 label = 'MICR Code',
551 fieldtype = 'Data',
552 insert_after = 'ifsc_code',
553 print_hide = 1,
554 depends_on='eval:doc.salary_mode == "Bank"'
555 ),
556 dict(
557 fieldname = 'provident_fund_account',
558 label = 'Provident Fund Account',
559 fieldtype = 'Data',
560 insert_after = 'pan_number'
561 )
562
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530563 ],
564 'Company': [
565 dict(fieldname='hra_section', label='HRA Settings',
Anurag Mishraa5527222019-06-14 15:25:57 +0530566 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530567 dict(fieldname='basic_component', label='Basic Component',
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530568 fieldtype='Link', options='Salary Component', insert_after='hra_section'),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530569 dict(fieldname='hra_component', label='HRA Component',
570 fieldtype='Link', options='Salary Component', insert_after='basic_component'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530571 dict(fieldname='arrear_component', label='Arrear Component',
Mangesh-Khairnar9215de02019-05-06 16:24:10 +0530572 fieldtype='Link', options='Salary Component', insert_after='hra_component'),
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530573 dict(fieldname='non_profit_section', label='Non Profit Settings',
574 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
575 dict(fieldname='company_80g_number', label='80G Number',
576 fieldtype='Data', insert_after='non_profit_section'),
577 dict(fieldname='with_effect_from', label='80G With Effect From',
578 fieldtype='Date', insert_after='company_80g_number'),
579 dict(fieldname='pan_details', label='PAN Number',
580 fieldtype='Data', insert_after='with_effect_from')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530581 ],
582 'Employee Tax Exemption Declaration':[
583 dict(fieldname='hra_section', label='HRA Exemption',
584 fieldtype='Section Break', insert_after='declarations'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530585 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530586 fieldtype='Currency', insert_after='hra_section'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530587 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530588 fieldtype='Check', insert_after='monthly_house_rent', depends_on='monthly_house_rent'),
589 dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure',
590 fieldtype='Currency', insert_after='rented_in_metro_city', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530591 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530592 insert_after='salary_structure_hra', depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530593 dict(fieldname='annual_hra_exemption', label='Annual HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530594 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530595 dict(fieldname='monthly_hra_exemption', label='Monthly HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530596 fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1, depends_on='monthly_house_rent')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530597 ],
598 'Employee Tax Exemption Proof Submission': [
599 dict(fieldname='hra_section', label='HRA Exemption',
600 fieldtype='Section Break', insert_after='tax_exemption_proofs'),
601 dict(fieldname='house_rent_payment_amount', label='House Rent Payment Amount',
602 fieldtype='Currency', insert_after='hra_section'),
603 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530604 fieldtype='Check', insert_after='house_rent_payment_amount', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530605 dict(fieldname='rented_from_date', label='Rented From Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530606 fieldtype='Date', insert_after='rented_in_metro_city', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530607 dict(fieldname='rented_to_date', label='Rented To Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530608 fieldtype='Date', insert_after='rented_from_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530609 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530610 insert_after='rented_to_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530611 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530612 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530613 dict(fieldname='monthly_hra_exemption', label='Monthly Eligible Amount',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530614 fieldtype='Currency', insert_after='monthly_house_rent', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530615 dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530616 fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1, depends_on='house_rent_payment_amount')
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530617 ],
618 'Supplier': [
619 {
620 'fieldname': 'gst_transporter_id',
621 'label': 'GST Transporter ID',
622 'fieldtype': 'Data',
623 'insert_after': 'supplier_type',
624 'depends_on': 'eval:doc.is_transporter'
Deepesh Garg22b61602019-03-21 20:47:47 +0530625 },
626 {
627 'fieldname': 'gst_category',
628 'label': 'GST Category',
629 'fieldtype': 'Select',
630 'insert_after': 'gst_transporter_id',
631 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
632 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530633 },
634 {
635 'fieldname': 'export_type',
636 'label': 'Export Type',
637 'fieldtype': 'Select',
638 'insert_after': 'gst_category',
639 'default': 'Without Payment of Tax',
640 'depends_on':'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
641 'options': '\nWith Payment of Tax\nWithout Payment of Tax'
Deepesh Garg22b61602019-03-21 20:47:47 +0530642 }
643 ],
644 'Customer': [
645 {
646 'fieldname': 'gst_category',
647 'label': 'GST Category',
648 'fieldtype': 'Select',
649 'insert_after': 'customer_type',
650 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
651 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530652 },
653 {
654 'fieldname': 'export_type',
655 'label': 'Export Type',
656 'fieldtype': 'Select',
657 'insert_after': 'gst_category',
658 'default': 'Without Payment of Tax',
659 'depends_on':'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
660 'options': '\nWith Payment of Tax\nWithout Payment of Tax'
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530661 }
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530662 ],
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530663 'Member': [
664 {
665 'fieldname': 'pan_number',
666 'label': 'PAN Details',
667 'fieldtype': 'Data',
668 'insert_after': 'email_id'
669 }
670 ],
671 'Donor': [
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530672 {
673 'fieldname': 'pan_number',
674 'label': 'PAN Details',
675 'fieldtype': 'Data',
676 'insert_after': 'email'
677 }
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530678 ]
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530679 }
Deepesh Garg22b61602019-03-21 20:47:47 +0530680 create_custom_fields(custom_fields, update=update)
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 = []
Anuja Pawar4569e522021-01-14 19:24:30 +0530767 fiscal_year = 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:
775 fiscal_year = get_fiscal_year(today(), verbose=0, company=company)[0]
776 except FiscalYearError:
777 pass
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530778
Anuja Pawar4569e522021-01-14 19:24:30 +0530779 docs = get_tds_details(accounts, fiscal_year)
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:
Zarrar7f8024c2018-08-01 17:45:05 +0530789 doc = frappe.get_doc("Tax Withholding Category", d.get("name"))
Zarrar963d62b2019-03-23 10:30:12 +0530790
791 if accounts:
792 doc.append("accounts", accounts[0])
Zarrar7f8024c2018-08-01 17:45:05 +0530793
Anuja Pawar4569e522021-01-14 19:24:30 +0530794 if fiscal_year:
795 # if fiscal year don't match with any of the already entered data, append rate row
796 fy_exist = [k for k in doc.get('rates') if k.get('fiscal_year')==fiscal_year]
797 if not fy_exist:
798 doc.append("rates", d.get('rates')[0])
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530799
Anuja Pawar4569e522021-01-14 19:24:30 +0530800 doc.flags.ignore_permissions = True
Deepesh Garg48b1a822021-05-29 23:54:51 +0530801 doc.flags.ignore_validate = True
Anuja Pawar4569e522021-01-14 19:24:30 +0530802 doc.flags.ignore_mandatory = True
Deepesh Garg204ea102021-04-30 16:35:52 +0530803 doc.flags.ignore_links = True
Zarrar7f8024c2018-08-01 17:45:05 +0530804 doc.save()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530805
806def set_tds_account(docs, company):
Nabin Haitf77cd542018-11-20 16:46:25 +0530807 parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
808 if parent_account:
809 docs.extend([
810 {
811 "doctype": "Account",
812 "account_name": "TDS Payable",
813 "account_type": "Tax",
814 "parent_account": parent_account,
815 "company": company
816 }
817 ])
Zarrar7f8024c2018-08-01 17:45:05 +0530818
819def get_tds_details(accounts, fiscal_year):
820 # bootstrap default tax withholding sections
821 return [
822 dict(name="TDS - 194C - Company",
823 category_name="Payment to Contractors (Single / Aggregate)",
824 doctype="Tax Withholding Category", accounts=accounts,
825 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
826 "single_threshold": 30000, "cumulative_threshold": 100000}]),
827 dict(name="TDS - 194C - Individual",
828 category_name="Payment to Contractors (Single / Aggregate)",
829 doctype="Tax Withholding Category", accounts=accounts,
830 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
831 "single_threshold": 30000, "cumulative_threshold": 100000}]),
832 dict(name="TDS - 194C - No PAN / Invalid PAN",
833 category_name="Payment to Contractors (Single / Aggregate)",
834 doctype="Tax Withholding Category", accounts=accounts,
835 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
836 "single_threshold": 30000, "cumulative_threshold": 100000}]),
837 dict(name="TDS - 194D - Company",
838 category_name="Insurance Commission",
839 doctype="Tax Withholding Category", accounts=accounts,
840 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
841 "single_threshold": 15000, "cumulative_threshold": 0}]),
842 dict(name="TDS - 194D - Company Assessee",
843 category_name="Insurance Commission",
844 doctype="Tax Withholding Category", accounts=accounts,
845 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
846 "single_threshold": 15000, "cumulative_threshold": 0}]),
847 dict(name="TDS - 194D - Individual",
848 category_name="Insurance Commission",
849 doctype="Tax Withholding Category", accounts=accounts,
850 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
851 "single_threshold": 15000, "cumulative_threshold": 0}]),
852 dict(name="TDS - 194D - No PAN / Invalid PAN",
853 category_name="Insurance Commission",
854 doctype="Tax Withholding Category", accounts=accounts,
855 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
856 "single_threshold": 15000, "cumulative_threshold": 0}]),
857 dict(name="TDS - 194DA - Company",
858 category_name="Non-exempt payments made under a life insurance policy",
859 doctype="Tax Withholding Category", accounts=accounts,
860 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
861 "single_threshold": 100000, "cumulative_threshold": 0}]),
862 dict(name="TDS - 194DA - Individual",
863 category_name="Non-exempt payments made under a life insurance policy",
864 doctype="Tax Withholding Category", accounts=accounts,
865 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
866 "single_threshold": 100000, "cumulative_threshold": 0}]),
867 dict(name="TDS - 194DA - No PAN / Invalid PAN",
868 category_name="Non-exempt payments made under a life insurance policy",
869 doctype="Tax Withholding Category", accounts=accounts,
870 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
871 "single_threshold": 100000, "cumulative_threshold": 0}]),
872 dict(name="TDS - 194H - Company",
873 category_name="Commission / Brokerage",
874 doctype="Tax Withholding Category", accounts=accounts,
875 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
876 "single_threshold": 15000, "cumulative_threshold": 0}]),
877 dict(name="TDS - 194H - Individual",
878 category_name="Commission / Brokerage",
879 doctype="Tax Withholding Category", accounts=accounts,
880 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
881 "single_threshold": 15000, "cumulative_threshold": 0}]),
882 dict(name="TDS - 194H - No PAN / Invalid PAN",
883 category_name="Commission / Brokerage",
884 doctype="Tax Withholding Category", accounts=accounts,
885 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
886 "single_threshold": 15000, "cumulative_threshold": 0}]),
887 dict(name="TDS - 194I - Rent - Company",
888 category_name="Rent",
889 doctype="Tax Withholding Category", accounts=accounts,
890 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
891 "single_threshold": 180000, "cumulative_threshold": 0}]),
892 dict(name="TDS - 194I - Rent - Individual",
893 category_name="Rent",
894 doctype="Tax Withholding Category", accounts=accounts,
895 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
896 "single_threshold": 180000, "cumulative_threshold": 0}]),
897 dict(name="TDS - 194I - Rent - No PAN / Invalid PAN",
898 category_name="Rent",
899 doctype="Tax Withholding Category", accounts=accounts,
900 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
901 "single_threshold": 180000, "cumulative_threshold": 0}]),
902 dict(name="TDS - 194I - Rent/Machinery - Company",
903 category_name="Rent-Plant / Machinery",
904 doctype="Tax Withholding Category", accounts=accounts,
905 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
906 "single_threshold": 180000, "cumulative_threshold": 0}]),
907 dict(name="TDS - 194I - Rent/Machinery - Individual",
908 category_name="Rent-Plant / Machinery",
909 doctype="Tax Withholding Category", accounts=accounts,
910 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
911 "single_threshold": 180000, "cumulative_threshold": 0}]),
912 dict(name="TDS - 194I - Rent/Machinery - No PAN / Invalid PAN",
913 category_name="Rent-Plant / Machinery",
914 doctype="Tax Withholding Category", accounts=accounts,
915 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
916 "single_threshold": 180000, "cumulative_threshold": 0}]),
917 dict(name="TDS - 194J - Professional Fees - Company",
918 category_name="Professional Fees",
919 doctype="Tax Withholding Category", accounts=accounts,
920 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
921 "single_threshold": 30000, "cumulative_threshold": 0}]),
922 dict(name="TDS - 194J - Professional Fees - Individual",
923 category_name="Professional Fees",
924 doctype="Tax Withholding Category", accounts=accounts,
925 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
926 "single_threshold": 30000, "cumulative_threshold": 0}]),
927 dict(name="TDS - 194J - Professional Fees - No PAN / Invalid PAN",
928 category_name="Professional Fees",
929 doctype="Tax Withholding Category", accounts=accounts,
930 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
931 "single_threshold": 30000, "cumulative_threshold": 0}]),
932 dict(name="TDS - 194J - Director Fees - Company",
933 category_name="Director Fees",
934 doctype="Tax Withholding Category", accounts=accounts,
935 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
936 "single_threshold": 0, "cumulative_threshold": 0}]),
937 dict(name="TDS - 194J - Director Fees - Individual",
938 category_name="Director Fees",
939 doctype="Tax Withholding Category", accounts=accounts,
940 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
941 "single_threshold": 0, "cumulative_threshold": 0}]),
942 dict(name="TDS - 194J - Director Fees - No PAN / Invalid PAN",
943 category_name="Director Fees",
944 doctype="Tax Withholding Category", accounts=accounts,
945 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
946 "single_threshold": 0, "cumulative_threshold": 0}]),
947 dict(name="TDS - 194 - Dividends - Company",
948 category_name="Dividends",
949 doctype="Tax Withholding Category", accounts=accounts,
950 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
951 "single_threshold": 2500, "cumulative_threshold": 0}]),
952 dict(name="TDS - 194 - Dividends - Individual",
953 category_name="Dividends",
954 doctype="Tax Withholding Category", accounts=accounts,
955 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
956 "single_threshold": 2500, "cumulative_threshold": 0}]),
957 dict(name="TDS - 194 - Dividends - No PAN / Invalid PAN",
958 category_name="Dividends",
959 doctype="Tax Withholding Category", accounts=accounts,
960 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
961 "single_threshold": 2500, "cumulative_threshold": 0}])
Anurag Mishrae1464a72020-08-17 15:03:32 +0530962 ]
963
Anurag Mishra25c35682020-08-18 14:13:54 +0530964def create_gratuity_rule():
Anurag Mishrae1464a72020-08-17 15:03:32 +0530965 # Standard Indain Gratuity Rule
Anurag Mishra493eea12020-08-18 15:02:32 +0530966 if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
967 rule = frappe.new_doc("Gratuity Rule")
968 rule.name = "Indian Standard Gratuity Rule"
969 rule.calculate_gratuity_amount_based_on = "Current Slab"
970 rule.work_experience_calculation_method = "Round Off Work Experience"
971 rule.minimum_year_for_gratuity = 5
Anurag Mishrae1464a72020-08-17 15:03:32 +0530972
Anurag Mishra493eea12020-08-18 15:02:32 +0530973 fraction = 15/26
974 rule.append("gratuity_rule_slabs", {
975 "from_year": 0,
976 "to_year":0,
977 "fraction_of_applicable_earnings": fraction
978 })
Anurag Mishrae1464a72020-08-17 15:03:32 +0530979
Anurag Mishra493eea12020-08-18 15:02:32 +0530980 rule.flags.ignore_mandatory = True
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530981 rule.save()
Deepesh Garg204ea102021-04-30 16:35:52 +0530982
983def update_accounts_settings_for_taxes():
984 if frappe.db.count('Company') == 1:
985 frappe.db.set_value('Accounts Settings', None, "add_taxes_from_item_tax_template", 0)