blob: 39705f6e442570286bd7934693a10516ed801c2c [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)
Deepesh Garg0380cca2021-05-02 22:29:48 +053018 setup_gst_settings(company)
Prateeksha Singh39b87652018-11-12 17:19:56 +053019
20# TODO: for all countries
Nabin Hait10c61372021-04-13 15:46:01 +053021def setup_company_independent_fixtures(patch=False):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053022 make_custom_fields()
Nabin Hait10c61372021-04-13 15:46:01 +053023 make_property_setters(patch=patch)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053024 add_permissions()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053025 add_custom_roles_for_reports()
Nabin Haitc3144852017-09-28 18:55:40 +053026 frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes', now=frappe.flags.in_test)
Anurag Mishra25c35682020-08-18 14:13:54 +053027 create_gratuity_rule()
Nabin Hait852cb642017-07-05 12:58:19 +053028 add_print_formats()
Deepesh Garg8fd2d8b2021-04-30 16:35:52 +053029 update_accounts_settings_for_taxes()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053030
Nabin Hait1a609312017-07-13 12:16:04 +053031def add_hsn_sac_codes():
Ankush Menata424c0c2021-06-11 16:49:39 +053032 if frappe.flags.in_test and frappe.flags.created_hsn_codes:
33 return
34
Nabin Hait1a609312017-07-13 12:16:04 +053035 # HSN codes
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053036 with open(os.path.join(os.path.dirname(__file__), 'hsn_code_data.json'), 'r') as f:
37 hsn_codes = json.loads(f.read())
38
Nabin Hait1a609312017-07-13 12:16:04 +053039 create_hsn_codes(hsn_codes, code_field="hsn_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053040
Nabin Hait1a609312017-07-13 12:16:04 +053041 # SAC Codes
42 with open(os.path.join(os.path.dirname(__file__), 'sac_code_data.json'), 'r') as f:
43 sac_codes = json.loads(f.read())
44 create_hsn_codes(sac_codes, code_field="sac_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053045
Ankush Menata424c0c2021-06-11 16:49:39 +053046 if frappe.flags.in_test:
47 frappe.flags.created_hsn_codes = True
48
Nabin Hait1a609312017-07-13 12:16:04 +053049def create_hsn_codes(data, code_field):
50 for d in data:
Rushabh Mehtaf702d722017-09-27 15:31:30 +053051 hsn_code = frappe.new_doc('GST HSN Code')
52 hsn_code.description = d["description"]
53 hsn_code.hsn_code = d[code_field]
54 hsn_code.name = d[code_field]
55 try:
Nabin Hait1a609312017-07-13 12:16:04 +053056 hsn_code.db_insert()
Rushabh Mehtaf702d722017-09-27 15:31:30 +053057 except frappe.DuplicateEntryError:
58 pass
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053059
Rushabh Mehta919a74a2017-06-22 16:37:04 +053060def add_custom_roles_for_reports():
61 for report_name in ('GST Sales Register', 'GST Purchase Register',
Saqib93203162021-04-12 17:55:46 +053062 'GST Itemised Sales Register', 'GST Itemised Purchase Register', 'Eway Bill', 'E-Invoice Summary'):
Rushabh Mehta919a74a2017-06-22 16:37:04 +053063
Rushabh Mehta919a74a2017-06-22 16:37:04 +053064 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
65 frappe.get_doc(dict(
66 doctype='Custom Role',
67 report=report_name,
68 roles= [
69 dict(role='Accounts User'),
70 dict(role='Accounts Manager')
71 ]
72 )).insert()
73
Anurag Mishra289c8222020-06-19 19:17:57 +053074 for report_name in ('Professional Tax Deductions', 'Provident Fund Deductions'):
75
76 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
77 frappe.get_doc(dict(
78 doctype='Custom Role',
79 report=report_name,
80 roles= [
81 dict(role='HR User'),
82 dict(role='HR Manager'),
83 dict(role='Employee')
84 ]
85 )).insert()
86
Anurag Mishra54cd1942020-09-03 13:51:26 +053087 for report_name in ('HSN-wise-summary of outward supplies', 'GSTR-1', 'GSTR-2'):
88
89 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
90 frappe.get_doc(dict(
91 doctype='Custom Role',
92 report=report_name,
93 roles= [
94 dict(role='Accounts User'),
95 dict(role='Accounts Manager'),
96 dict(role='Auditor')
97 ]
98 )).insert()
99
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530100def add_permissions():
Saqib6d74f5b2020-12-25 10:26:43 +0530101 for doctype in ('GST HSN Code', 'GST Settings', 'GSTR 3B Report', 'Lower Deduction Certificate', 'E Invoice Settings'):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530102 add_permission(doctype, 'All', 0)
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530103 for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
Saqib5e6ce882020-02-03 15:40:35 +0530104 add_permission(doctype, role, 0)
105 update_permission_property(doctype, role, 0, 'write', 1)
106 update_permission_property(doctype, role, 0, 'create', 1)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530107
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530108 if doctype == 'GST HSN Code':
109 for role in ('Item Manager', 'Stock Manager'):
110 add_permission(doctype, role, 0)
111 update_permission_property(doctype, role, 0, 'write', 1)
112 update_permission_property(doctype, role, 0, 'create', 1)
113
Nabin Hait852cb642017-07-05 12:58:19 +0530114def add_print_formats():
115 frappe.reload_doc("regional", "print_format", "gst_tax_invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530116 frappe.reload_doc("accounts", "print_format", "gst_pos_invoice")
Saqib6d74f5b2020-12-25 10:26:43 +0530117 frappe.reload_doc("accounts", "print_format", "GST E-Invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530118
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)
121 frappe.db.set_value("Print Format", "GST E-Invoice", "disabled", 0)
Nabin Hait852cb642017-07-05 12:58:19 +0530122
Nabin Hait10c61372021-04-13 15:46:01 +0530123def make_property_setters(patch=False):
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530124 # GST rules do not allow for an invoice no. bigger than 16 characters
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530125 journal_entry_types = frappe.get_meta("Journal Entry").get_options("voucher_type").split("\n") + ['Reversal Of ITC']
126
Nabin Hait10c61372021-04-13 15:46:01 +0530127 if not patch:
128 make_property_setter('Sales Invoice', 'naming_series', 'options', 'SINV-.YY.-\nSRET-.YY.-', '')
129 make_property_setter('Purchase Invoice', 'naming_series', 'options', 'PINV-.YY.-\nPRET-.YY.-', '')
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530130 make_property_setter('Journal Entry', 'voucher_type', 'options', '\n'.join(journal_entry_types), '')
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530131
Rushabh Mehta69fa8082018-07-17 18:22:51 +0530132def make_custom_fields(update=True):
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530133 hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
Nabin Haitd34bfa82018-11-13 18:19:58 +0530134 fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description',
Nabin Haitf4af6082019-04-01 11:51:54 +0530135 allow_on_submit=1, print_hide=1, fetch_if_empty=1)
Marica9942acd2020-04-21 13:13:39 +0530136 nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530137 fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code',
138 print_hide=1)
139 is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST',
140 fieldtype='Check', fetch_from='item_code.is_non_gst', insert_after='is_nil_exempt',
141 print_hide=1)
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530142 taxable_value = dict(fieldname='taxable_value', label='Taxable Value',
143 fieldtype='Currency', insert_after='base_net_amount', hidden=1, options="Company:company:default_currency",
144 print_hide=1)
Deepesh Garg22b61602019-03-21 20:47:47 +0530145
146 purchase_invoice_gst_category = [
Nabin Hait879e1622017-08-21 08:28:55 +0530147 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
vishdha109b4082018-01-30 12:11:13 +0530148 insert_after='language', print_hide=1, collapsible=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530149 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530150 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530151 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530152 fetch_from='supplier.gst_category', fetch_if_empty=1),
153 dict(fieldname='export_type', label='Export Type',
154 fieldtype='Select', insert_after='gst_category', print_hide=1,
155 depends_on='eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
156 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='supplier.export_type',
157 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530158 ]
159
160 sales_invoice_gst_category = [
161 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
162 insert_after='language', print_hide=1, collapsible=1),
163 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530164 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530165 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530166 fetch_from='customer.gst_category', fetch_if_empty=1),
167 dict(fieldname='export_type', label='Export Type',
168 fieldtype='Select', insert_after='gst_category', print_hide=1,
169 depends_on='eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
170 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='customer.export_type',
171 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530172 ]
173
Deepesh Garg29997412021-03-29 19:49:52 +0530174 delivery_note_gst_category = [
175 dict(fieldname='gst_category', label='GST Category',
176 fieldtype='Select', insert_after='gst_vehicle_type', print_hide=1,
177 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
178 fetch_from='customer.gst_category', fetch_if_empty=1),
179 ]
180
Deepesh Garg22b61602019-03-21 20:47:47 +0530181 invoice_gst_fields = [
Nabin Hait879e1622017-08-21 08:28:55 +0530182 dict(fieldname='invoice_copy', label='Invoice Copy',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530183 fieldtype='Select', insert_after='export_type', print_hide=1, allow_on_submit=1,
Nabin Hait879e1622017-08-21 08:28:55 +0530184 options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'),
185 dict(fieldname='reverse_charge', label='Reverse Charge',
186 fieldtype='Select', insert_after='invoice_copy', print_hide=1,
187 options='Y\nN', default='N'),
Nabin Hait879e1622017-08-21 08:28:55 +0530188 dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN',
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530189 fieldtype='Data', insert_after='export_type', print_hide=1),
Nabin Haite6d65bc2018-02-14 17:44:06 +0530190 dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='ecommerce_gstin'),
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530191 dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document',
Nabin Haitb02c1092018-02-05 16:09:51 +0530192 fieldtype='Select', insert_after='gst_col_break', print_hide=1,
Nabin Haite6d65bc2018-02-14 17:44:06 +0530193 depends_on='eval:doc.is_return==1',
Nabin Haita8d10b72018-02-12 16:54:13 +0530194 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 +0530195 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530196
Nabin Hait879e1622017-08-21 08:28:55 +0530197 purchase_invoice_gst_fields = [
198 dict(fieldname='supplier_gstin', label='Supplier GSTIN',
199 fieldtype='Data', insert_after='supplier_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530200 fetch_from='supplier_address.gstin', print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530201 dict(fieldname='company_gstin', label='Company GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530202 fieldtype='Data', insert_after='shipping_address_display',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530203 fetch_from='shipping_address.gstin', print_hide=1, read_only=1),
Nabin Haitb02c1092018-02-05 16:09:51 +0530204 dict(fieldname='place_of_supply', label='Place of Supply',
205 fieldtype='Data', insert_after='shipping_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530206 print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530207 ]
208
209 purchase_invoice_itc_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530210 dict(fieldname='eligibility_for_itc', label='Eligibility For ITC',
211 fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530212 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',
213 default="All Other ITC"),
vishdha98e33c32018-01-29 13:57:34 +0530214 dict(fieldname='itc_integrated_tax', label='Availed ITC Integrated Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530215 fieldtype='Currency', insert_after='eligibility_for_itc',
216 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530217 dict(fieldname='itc_central_tax', label='Availed ITC Central Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530218 fieldtype='Currency', insert_after='itc_integrated_tax',
219 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530220 dict(fieldname='itc_state_tax', label='Availed ITC State/UT Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530221 fieldtype='Currency', insert_after='itc_central_tax',
222 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530223 dict(fieldname='itc_cess_amount', label='Availed ITC Cess',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530224 fieldtype='Currency', insert_after='itc_state_tax',
225 options='Company:company:default_currency', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530226 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530227
Nabin Hait879e1622017-08-21 08:28:55 +0530228 sales_invoice_gst_fields = [
rohitwaghchaure16645802017-09-28 11:05:03 +0530229 dict(fieldname='billing_address_gstin', label='Billing Address GSTIN',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530230 fieldtype='Data', insert_after='customer_address', read_only=1,
Shreya Shah4fa600a2018-06-05 11:27:53 +0530231 fetch_from='customer_address.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530232 dict(fieldname='customer_gstin', label='Customer GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530233 fieldtype='Data', insert_after='shipping_address_name',
234 fetch_from='shipping_address_name.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530235 dict(fieldname='place_of_supply', label='Place of Supply',
Nabin Hait619c42b2018-01-10 17:48:03 +0530236 fieldtype='Data', insert_after='customer_gstin',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530237 print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530238 dict(fieldname='company_gstin', label='Company GSTIN',
239 fieldtype='Data', insert_after='company_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530240 fetch_from='company_address.gstin', print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530241 ]
242
243 sales_invoice_shipping_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530244 dict(fieldname='port_code', label='Port Code',
245 fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530246 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530247 dict(fieldname='shipping_bill_number', label=' Shipping Bill Number',
248 fieldtype='Data', insert_after='port_code', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530249 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530250 dict(fieldname='shipping_bill_date', label='Shipping Bill Date',
251 fieldtype='Date', insert_after='shipping_bill_number', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530252 depends_on="eval:doc.gst_category=='Overseas' "),
Nabin Hait879e1622017-08-21 08:28:55 +0530253 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530254
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530255 journal_entry_fields = [
256 dict(fieldname='reversal_type', label='Reversal Type',
257 fieldtype='Select', insert_after='voucher_type', print_hide=1,
258 options="As per rules 42 & 43 of CGST Rules\nOthers",
259 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
260 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
261 dict(fieldname='company_address', label='Company Address',
262 fieldtype='Link', options='Address', insert_after='reversal_type',
263 print_hide=1, depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
264 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
265 dict(fieldname='company_gstin', label='Company GSTIN',
266 fieldtype='Data', read_only=1, insert_after='company_address', print_hide=1,
267 fetch_from='company_address.gstin',
268 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
269 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'")
270 ]
271
Shreya Shah4fa600a2018-06-05 11:27:53 +0530272 inter_state_gst_field = [
273 dict(fieldname='is_inter_state', label='Is Inter State',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530274 fieldtype='Check', insert_after='disabled', print_hide=1),
275 dict(fieldname='tax_category_column_break', fieldtype='Column Break',
276 insert_after='is_inter_state'),
277 dict(fieldname='gst_state', label='Source State', fieldtype='Select',
278 options='\n'.join(states), insert_after='company')
Shreya Shah4fa600a2018-06-05 11:27:53 +0530279 ]
280
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530281 ewaybill_fields = [
282 {
283 'fieldname': 'distance',
284 'label': 'Distance (in km)',
285 'fieldtype': 'Float',
286 'insert_after': 'vehicle_no',
287 'print_hide': 1
288 },
289 {
290 'fieldname': 'gst_transporter_id',
291 'label': 'GST Transporter ID',
292 'fieldtype': 'Data',
Nabin Hait34c551d2019-07-03 10:34:31 +0530293 'insert_after': 'transporter',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530294 'fetch_from': 'transporter.gst_transporter_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530295 'print_hide': 1,
296 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530297 },
298 {
299 'fieldname': 'mode_of_transport',
300 'label': 'Mode of Transport',
301 'fieldtype': 'Select',
302 'options': '\nRoad\nAir\nRail\nShip',
303 'default': 'Road',
Nabin Hait34c551d2019-07-03 10:34:31 +0530304 'insert_after': 'transporter_name',
305 'print_hide': 1,
306 'translatable': 0
307 },
308 {
309 'fieldname': 'gst_vehicle_type',
310 'label': 'GST Vehicle Type',
311 'fieldtype': 'Select',
312 'options': 'Regular\nOver Dimensional Cargo (ODC)',
313 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
314 'default': 'Regular',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530315 'insert_after': 'lr_date',
Nabin Hait34c551d2019-07-03 10:34:31 +0530316 'print_hide': 1,
317 'translatable': 0
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530318 },
319 {
320 'fieldname': 'ewaybill',
321 'label': 'E-Way Bill No.',
322 'fieldtype': 'Data',
323 'depends_on': 'eval:(doc.docstatus === 1)',
324 'allow_on_submit': 1,
325 'insert_after': 'customer_name_in_arabic',
326 'translatable': 0,
Deepesh Garg29997412021-03-29 19:49:52 +0530327 }
Nabin Hait34c551d2019-07-03 10:34:31 +0530328 ]
329
330 si_ewaybill_fields = [
331 {
332 'fieldname': 'transporter_info',
333 'label': 'Transporter Info',
334 'fieldtype': 'Section Break',
335 'insert_after': 'terms',
336 'collapsible': 1,
337 'collapsible_depends_on': 'transporter',
338 'print_hide': 1
339 },
340 {
341 'fieldname': 'transporter',
342 'label': 'Transporter',
343 'fieldtype': 'Link',
344 'insert_after': 'transporter_info',
345 'options': 'Supplier',
346 'print_hide': 1
347 },
348 {
349 'fieldname': 'gst_transporter_id',
350 'label': 'GST Transporter ID',
351 'fieldtype': 'Data',
352 'insert_after': 'transporter',
353 'fetch_from': 'transporter.gst_transporter_id',
354 'print_hide': 1,
355 'translatable': 0
356 },
357 {
358 'fieldname': 'driver',
359 'label': 'Driver',
360 'fieldtype': 'Link',
361 'insert_after': 'gst_transporter_id',
362 'options': 'Driver',
363 'print_hide': 1
364 },
365 {
366 'fieldname': 'lr_no',
367 'label': 'Transport Receipt No',
368 'fieldtype': 'Data',
369 'insert_after': 'driver',
370 'print_hide': 1,
371 'translatable': 0
372 },
373 {
374 'fieldname': 'vehicle_no',
375 'label': 'Vehicle No',
376 'fieldtype': 'Data',
377 'insert_after': 'lr_no',
378 'print_hide': 1,
379 'translatable': 0
380 },
381 {
382 'fieldname': 'distance',
383 'label': 'Distance (in km)',
384 'fieldtype': 'Float',
385 'insert_after': 'vehicle_no',
386 'print_hide': 1
387 },
388 {
389 'fieldname': 'transporter_col_break',
390 'fieldtype': 'Column Break',
391 'insert_after': 'distance'
392 },
393 {
394 'fieldname': 'transporter_name',
395 'label': 'Transporter Name',
396 'fieldtype': 'Data',
397 'insert_after': 'transporter_col_break',
398 'fetch_from': 'transporter.name',
399 'read_only': 1,
400 'print_hide': 1,
401 'translatable': 0
402 },
403 {
404 'fieldname': 'mode_of_transport',
405 'label': 'Mode of Transport',
406 'fieldtype': 'Select',
407 'options': '\nRoad\nAir\nRail\nShip',
Nabin Hait34c551d2019-07-03 10:34:31 +0530408 'insert_after': 'transporter_name',
409 'print_hide': 1,
410 'translatable': 0
411 },
412 {
413 'fieldname': 'driver_name',
414 'label': 'Driver Name',
415 'fieldtype': 'Data',
416 'insert_after': 'mode_of_transport',
417 'fetch_from': 'driver.full_name',
418 'print_hide': 1,
419 'translatable': 0
420 },
421 {
422 'fieldname': 'lr_date',
423 'label': 'Transport Receipt Date',
424 'fieldtype': 'Date',
425 'insert_after': 'driver_name',
426 'default': 'Today',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530427 'print_hide': 1
428 },
429 {
430 'fieldname': 'gst_vehicle_type',
431 'label': 'GST Vehicle Type',
432 'fieldtype': 'Select',
Nabin Hait34c551d2019-07-03 10:34:31 +0530433 'options': 'Regular\nOver Dimensional Cargo (ODC)',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530434 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
Nabin Hait34c551d2019-07-03 10:34:31 +0530435 'default': 'Regular',
436 'insert_after': 'lr_date',
437 'print_hide': 1,
438 'translatable': 0
439 },
440 {
441 'fieldname': 'ewaybill',
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530442 'label': 'E-Way Bill No.',
Nabin Hait34c551d2019-07-03 10:34:31 +0530443 'fieldtype': 'Data',
Saqib6d74f5b2020-12-25 10:26:43 +0530444 'depends_on': 'eval:((doc.docstatus === 1 || doc.ewaybill) && doc.eway_bill_cancelled === 0)',
Nabin Hait34c551d2019-07-03 10:34:31 +0530445 'allow_on_submit': 1,
deepeshgarg007a85db662019-07-14 18:15:19 +0530446 'insert_after': 'tax_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530447 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530448 }
449 ]
450
Saqib6d74f5b2020-12-25 10:26:43 +0530451 si_einvoice_fields = [
452 dict(fieldname='irn', label='IRN', fieldtype='Data', read_only=1, insert_after='customer', no_copy=1, print_hide=1,
453 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 +0530454
Saqib6d74f5b2020-12-25 10:26:43 +0530455 dict(fieldname='irn_cancelled', label='IRN Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
456 depends_on='eval:(doc.irn_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
457
Saqibd502f762021-05-06 16:10:55 +0530458 dict(fieldname='eway_bill_validity', label='E-Way Bill Validity', fieldtype='Data', no_copy=1, print_hide=1,
459 depends_on='ewaybill', read_only=1, allow_on_submit=1, insert_after='ewaybill'),
460
Saqib6d74f5b2020-12-25 10:26:43 +0530461 dict(fieldname='eway_bill_cancelled', label='E-Way Bill Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
462 depends_on='eval:(doc.eway_bill_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
463
Saqib93203162021-04-12 17:55:46 +0530464 dict(fieldname='einvoice_section', label='E-Invoice Fields', fieldtype='Section Break', insert_after='gst_vehicle_type',
465 print_hide=1, hidden=1),
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530466
Saqib93203162021-04-12 17:55:46 +0530467 dict(fieldname='ack_no', label='Ack. No.', fieldtype='Data', read_only=1, hidden=1, insert_after='einvoice_section',
468 no_copy=1, print_hide=1),
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530469
Saqib93203162021-04-12 17:55:46 +0530470 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 +0530471
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530472 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 +0530473 no_copy=1, print_hide=1),
Saqib6d74f5b2020-12-25 10:26:43 +0530474
Saqib93203162021-04-12 17:55:46 +0530475 dict(fieldname='signed_einvoice', label='Signed E-Invoice', fieldtype='Code', options='JSON', hidden=1, insert_after='irn_cancel_date',
476 no_copy=1, print_hide=1, read_only=1),
477
478 dict(fieldname='signed_qr_code', label='Signed QRCode', fieldtype='Code', options='JSON', hidden=1, insert_after='signed_einvoice',
479 no_copy=1, print_hide=1, read_only=1),
480
481 dict(fieldname='qrcode_image', label='QRCode', fieldtype='Attach Image', hidden=1, insert_after='signed_qr_code',
482 no_copy=1, print_hide=1, read_only=1),
483
484 dict(fieldname='einvoice_status', label='E-Invoice Status', fieldtype='Select', insert_after='qrcode_image',
485 options='\nPending\nGenerated\nCancelled\nFailed', default=None, hidden=1, no_copy=1, print_hide=1, read_only=1),
486
487 dict(fieldname='failure_description', label='E-Invoice Failure Description', fieldtype='Code', options='JSON',
488 hidden=1, insert_after='einvoice_status', no_copy=1, print_hide=1, read_only=1)
Saqib6d74f5b2020-12-25 10:26:43 +0530489 ]
490
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530491 custom_fields = {
492 'Address': [
Rushabh Mehta919a74a2017-06-22 16:37:04 +0530493 dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data',
494 insert_after='fax'),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530495 dict(fieldname='gst_state', label='GST State', fieldtype='Select',
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530496 options='\n'.join(states), insert_after='gstin'),
497 dict(fieldname='gst_state_number', label='GST State Number',
Nabin Hait562d9422018-09-07 16:14:44 +0530498 fieldtype='Data', insert_after='gst_state', read_only=1),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530499 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530500 'Purchase Invoice': purchase_invoice_gst_category + invoice_gst_fields + purchase_invoice_itc_fields + purchase_invoice_gst_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530501 'Purchase Order': purchase_invoice_gst_fields,
502 'Purchase Receipt': purchase_invoice_gst_fields,
Saqib6d74f5b2020-12-25 10:26:43 +0530503 '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 +0530504 'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields + delivery_note_gst_category,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530505 'Journal Entry': journal_entry_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530506 'Sales Order': sales_invoice_gst_fields,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530507 'Tax Category': inter_state_gst_field,
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530508 'Item': [
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530509 dict(fieldname='gst_hsn_code', label='HSN/SAC',
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530510 fieldtype='Link', options='GST HSN Code', insert_after='item_group'),
Marica9942acd2020-04-21 13:13:39 +0530511 dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530512 fieldtype='Check', insert_after='gst_hsn_code'),
513 dict(fieldname='is_non_gst', label='Is Non GST ',
514 fieldtype='Check', insert_after='is_nil_exempt')
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530515 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530516 'Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
517 'Supplier Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
518 'Sales Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
519 'Delivery Note Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530520 'Sales Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Deepesh Garg22b61602019-03-21 20:47:47 +0530521 'Purchase Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
522 'Purchase Receipt Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530523 'Purchase Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Himanshu Warekar656d8e42019-04-01 19:38:43 +0530524 'Material Request Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Anurag Mishra289c8222020-06-19 19:17:57 +0530525 'Salary Component': [
526 dict(fieldname= 'component_type',
527 label= 'Component Type',
528 fieldtype= 'Select',
529 insert_after= 'description',
530 options= "\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax",
531 depends_on = 'eval:doc.type == "Deduction"'
532 )
533 ],
Pawan Mehtaf4196352018-04-05 14:54:51 +0530534 'Employee': [
Anurag Mishra289c8222020-06-19 19:17:57 +0530535 dict(fieldname='ifsc_code',
536 label='IFSC Code',
537 fieldtype='Data',
538 insert_after='bank_ac_no',
539 print_hide=1,
540 depends_on='eval:doc.salary_mode == "Bank"'
541 ),
542 dict(
543 fieldname = 'pan_number',
544 label = 'PAN Number',
545 fieldtype = 'Data',
546 insert_after = 'payroll_cost_center',
547 print_hide = 1
548 ),
549 dict(
550 fieldname = 'micr_code',
551 label = 'MICR Code',
552 fieldtype = 'Data',
553 insert_after = 'ifsc_code',
554 print_hide = 1,
555 depends_on='eval:doc.salary_mode == "Bank"'
556 ),
557 dict(
558 fieldname = 'provident_fund_account',
559 label = 'Provident Fund Account',
560 fieldtype = 'Data',
561 insert_after = 'pan_number'
562 )
563
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530564 ],
565 'Company': [
566 dict(fieldname='hra_section', label='HRA Settings',
Anurag Mishraa5527222019-06-14 15:25:57 +0530567 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530568 dict(fieldname='basic_component', label='Basic Component',
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530569 fieldtype='Link', options='Salary Component', insert_after='hra_section'),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530570 dict(fieldname='hra_component', label='HRA Component',
571 fieldtype='Link', options='Salary Component', insert_after='basic_component'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530572 dict(fieldname='arrear_component', label='Arrear Component',
Mangesh-Khairnar9215de02019-05-06 16:24:10 +0530573 fieldtype='Link', options='Salary Component', insert_after='hra_component'),
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530574 dict(fieldname='non_profit_section', label='Non Profit Settings',
575 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
576 dict(fieldname='company_80g_number', label='80G Number',
577 fieldtype='Data', insert_after='non_profit_section'),
578 dict(fieldname='with_effect_from', label='80G With Effect From',
579 fieldtype='Date', insert_after='company_80g_number'),
580 dict(fieldname='pan_details', label='PAN Number',
581 fieldtype='Data', insert_after='with_effect_from')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530582 ],
583 'Employee Tax Exemption Declaration':[
584 dict(fieldname='hra_section', label='HRA Exemption',
585 fieldtype='Section Break', insert_after='declarations'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530586 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530587 fieldtype='Currency', insert_after='hra_section'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530588 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530589 fieldtype='Check', insert_after='monthly_house_rent', depends_on='monthly_house_rent'),
590 dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure',
591 fieldtype='Currency', insert_after='rented_in_metro_city', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530592 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530593 insert_after='salary_structure_hra', depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530594 dict(fieldname='annual_hra_exemption', label='Annual HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530595 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530596 dict(fieldname='monthly_hra_exemption', label='Monthly HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530597 fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1, depends_on='monthly_house_rent')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530598 ],
599 'Employee Tax Exemption Proof Submission': [
600 dict(fieldname='hra_section', label='HRA Exemption',
601 fieldtype='Section Break', insert_after='tax_exemption_proofs'),
602 dict(fieldname='house_rent_payment_amount', label='House Rent Payment Amount',
603 fieldtype='Currency', insert_after='hra_section'),
604 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530605 fieldtype='Check', insert_after='house_rent_payment_amount', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530606 dict(fieldname='rented_from_date', label='Rented From Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530607 fieldtype='Date', insert_after='rented_in_metro_city', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530608 dict(fieldname='rented_to_date', label='Rented To Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530609 fieldtype='Date', insert_after='rented_from_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530610 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530611 insert_after='rented_to_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530612 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530613 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530614 dict(fieldname='monthly_hra_exemption', label='Monthly Eligible Amount',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530615 fieldtype='Currency', insert_after='monthly_house_rent', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530616 dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530617 fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1, depends_on='house_rent_payment_amount')
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530618 ],
619 'Supplier': [
620 {
621 'fieldname': 'gst_transporter_id',
622 'label': 'GST Transporter ID',
623 'fieldtype': 'Data',
624 'insert_after': 'supplier_type',
625 'depends_on': 'eval:doc.is_transporter'
Deepesh Garg22b61602019-03-21 20:47:47 +0530626 },
627 {
628 'fieldname': 'gst_category',
629 'label': 'GST Category',
630 'fieldtype': 'Select',
631 'insert_after': 'gst_transporter_id',
632 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
633 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530634 },
635 {
636 'fieldname': 'export_type',
637 'label': 'Export Type',
638 'fieldtype': 'Select',
639 'insert_after': 'gst_category',
640 'default': 'Without Payment of Tax',
641 'depends_on':'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
642 'options': '\nWith Payment of Tax\nWithout Payment of Tax'
Deepesh Garg22b61602019-03-21 20:47:47 +0530643 }
644 ],
645 'Customer': [
646 {
647 'fieldname': 'gst_category',
648 'label': 'GST Category',
649 'fieldtype': 'Select',
650 'insert_after': 'customer_type',
651 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
652 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530653 },
654 {
655 'fieldname': 'export_type',
656 'label': 'Export Type',
657 'fieldtype': 'Select',
658 'insert_after': 'gst_category',
659 'default': 'Without Payment of Tax',
660 'depends_on':'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
661 'options': '\nWith Payment of Tax\nWithout Payment of Tax'
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530662 }
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530663 ],
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530664 'Member': [
665 {
666 'fieldname': 'pan_number',
667 'label': 'PAN Details',
668 'fieldtype': 'Data',
669 'insert_after': 'email_id'
670 }
671 ],
672 'Donor': [
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530673 {
674 'fieldname': 'pan_number',
675 'label': 'PAN Details',
676 'fieldtype': 'Data',
677 'insert_after': 'email'
678 }
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530679 ]
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530680 }
Deepesh Garg22b61602019-03-21 20:47:47 +0530681 create_custom_fields(custom_fields, update=update)
Nabin Hait9c421612017-07-20 13:32:01 +0530682
Saurabh2d8a7ee2018-05-11 13:16:16 +0530683def make_fixtures(company=None):
684 docs = []
Deepesh Garg8ed1afd2021-05-02 12:22:16 +0530685 company = company or frappe.db.get_value("Global Defaults", None, "default_company")
Saurabh2d8a7ee2018-05-11 13:16:16 +0530686
687 set_salary_components(docs)
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530688 set_tds_account(docs, company)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530689
690 for d in docs:
691 try:
692 doc = frappe.get_doc(d)
693 doc.flags.ignore_permissions = True
694 doc.insert()
695 except frappe.NameError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530696 frappe.clear_messages()
Zarrar7f8024c2018-08-01 17:45:05 +0530697 except frappe.DuplicateEntryError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530698 frappe.clear_messages()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530699
Zarrar7f8024c2018-08-01 17:45:05 +0530700 # create records for Tax Withholding Category
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530701 set_tax_withholding_category(company)
702
Deepesh Garg0380cca2021-05-02 22:29:48 +0530703def setup_gst_settings(company):
704 # Will only add default GST accounts if present
705 input_account_names = ['Input Tax CGST', 'Input Tax SGST', 'Input Tax IGST']
706 output_account_names = ['Output Tax CGST', 'Output Tax SGST', 'Output Tax IGST']
Deepesh Garga72589c2021-05-29 23:54:51 +0530707 rcm_accounts = ['Input Tax CGST RCM', 'Input Tax SGST RCM', 'Input Tax IGST RCM']
Deepesh Garg0380cca2021-05-02 22:29:48 +0530708 gst_settings = frappe.get_single('GST Settings')
709 existing_account_list = []
710
711 for account in gst_settings.get('gst_accounts'):
712 for key in ['cgst_account', 'sgst_account', 'igst_account']:
713 existing_account_list.append(account.get(key))
714
715 gst_accounts = frappe._dict(frappe.get_all("Account",
Deepesh Garga72589c2021-05-29 23:54:51 +0530716 {'company': company, 'account_name': ('in', input_account_names +
717 output_account_names + rcm_accounts)}, ['account_name', 'name'], as_list=1))
Deepesh Garg0380cca2021-05-02 22:29:48 +0530718
Deepesh Garga72589c2021-05-29 23:54:51 +0530719 add_accounts_in_gst_settings(company, input_account_names, gst_accounts,
720 existing_account_list, gst_settings)
721 add_accounts_in_gst_settings(company, output_account_names, gst_accounts,
722 existing_account_list, gst_settings)
723 add_accounts_in_gst_settings(company, rcm_accounts, gst_accounts,
724 existing_account_list, gst_settings, is_reverse_charge=1)
Deepesh Garg0380cca2021-05-02 22:29:48 +0530725
726 gst_settings.save()
727
Deepesh Garga72589c2021-05-29 23:54:51 +0530728def add_accounts_in_gst_settings(company, account_names, gst_accounts,
729 existing_account_list, gst_settings, is_reverse_charge=0):
730 accounts_not_added = 1
731
732 for account in account_names:
733 # Default Account Added does not exists
734 if not gst_accounts.get(account):
735 accounts_not_added = 0
736
737 # Check if already added in GST Settings
738 if gst_accounts.get(account) in existing_account_list:
739 accounts_not_added = 0
740
741 if accounts_not_added:
742 gst_settings.append('gst_accounts', {
743 'company': company,
744 'cgst_account': gst_accounts.get(account_names[0]),
745 'sgst_account': gst_accounts.get(account_names[1]),
746 'igst_account': gst_accounts.get(account_names[2]),
747 'is_reverse_charge_account': is_reverse_charge
748 })
749
Saurabh2d8a7ee2018-05-11 13:16:16 +0530750def set_salary_components(docs):
751 docs.extend([
Nabin Hait58ee6c12020-04-26 17:45:57 +0530752 {'doctype': 'Salary Component', 'salary_component': 'Professional Tax',
753 'description': 'Professional Tax', 'type': 'Deduction', 'exempted_from_income_tax': 1},
754 {'doctype': 'Salary Component', 'salary_component': 'Provident Fund',
755 'description': 'Provident fund', 'type': 'Deduction', 'is_tax_applicable': 1},
756 {'doctype': 'Salary Component', 'salary_component': 'House Rent Allowance',
757 'description': 'House Rent Allowance', 'type': 'Earning', 'is_tax_applicable': 1},
758 {'doctype': 'Salary Component', 'salary_component': 'Basic',
759 'description': 'Basic', 'type': 'Earning', 'is_tax_applicable': 1},
760 {'doctype': 'Salary Component', 'salary_component': 'Arrear',
761 'description': 'Arrear', 'type': 'Earning', 'is_tax_applicable': 1},
762 {'doctype': 'Salary Component', 'salary_component': 'Leave Encashment',
763 'description': 'Leave Encashment', 'type': 'Earning', 'is_tax_applicable': 1}
Saurabh2d8a7ee2018-05-11 13:16:16 +0530764 ])
765
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530766def set_tax_withholding_category(company):
Saurabh2d8a7ee2018-05-11 13:16:16 +0530767 accounts = []
Anuja Pawar4569e522021-01-14 19:24:30 +0530768 fiscal_year = None
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530769 abbr = frappe.get_value("Company", company, "abbr")
770 tds_account = frappe.get_value("Account", 'TDS Payable - {0}'.format(abbr), 'name')
Saurabh2d8a7ee2018-05-11 13:16:16 +0530771
772 if company and tds_account:
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530773 accounts = [dict(company=company, account=tds_account)]
Saurabh2d8a7ee2018-05-11 13:16:16 +0530774
Anuja Pawar4569e522021-01-14 19:24:30 +0530775 try:
776 fiscal_year = get_fiscal_year(today(), verbose=0, company=company)[0]
777 except FiscalYearError:
778 pass
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530779
Anuja Pawar4569e522021-01-14 19:24:30 +0530780 docs = get_tds_details(accounts, fiscal_year)
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530781
Zarrar7f8024c2018-08-01 17:45:05 +0530782 for d in docs:
Deepesh Garga90e5fd2021-04-21 20:42:20 +0530783 if not frappe.db.exists("Tax Withholding Category", d.get("name")):
Zarrar7f8024c2018-08-01 17:45:05 +0530784 doc = frappe.get_doc(d)
Deepesh Garg8fd2d8b2021-04-30 16:35:52 +0530785 doc.flags.ignore_validate = True
Zarrar7f8024c2018-08-01 17:45:05 +0530786 doc.flags.ignore_permissions = True
Nabin Haitafef9c12019-02-12 11:28:20 +0530787 doc.flags.ignore_mandatory = True
Zarrar7f8024c2018-08-01 17:45:05 +0530788 doc.insert()
Deepesh Garga90e5fd2021-04-21 20:42:20 +0530789 else:
Zarrar7f8024c2018-08-01 17:45:05 +0530790 doc = frappe.get_doc("Tax Withholding Category", d.get("name"))
Zarrar963d62b2019-03-23 10:30:12 +0530791
792 if accounts:
793 doc.append("accounts", accounts[0])
Zarrar7f8024c2018-08-01 17:45:05 +0530794
Anuja Pawar4569e522021-01-14 19:24:30 +0530795 if fiscal_year:
796 # if fiscal year don't match with any of the already entered data, append rate row
797 fy_exist = [k for k in doc.get('rates') if k.get('fiscal_year')==fiscal_year]
798 if not fy_exist:
799 doc.append("rates", d.get('rates')[0])
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530800
Anuja Pawar4569e522021-01-14 19:24:30 +0530801 doc.flags.ignore_permissions = True
Deepesh Garga72589c2021-05-29 23:54:51 +0530802 doc.flags.ignore_validate = True
Anuja Pawar4569e522021-01-14 19:24:30 +0530803 doc.flags.ignore_mandatory = True
Deepesh Garg8fd2d8b2021-04-30 16:35:52 +0530804 doc.flags.ignore_links = True
Zarrar7f8024c2018-08-01 17:45:05 +0530805 doc.save()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530806
807def set_tds_account(docs, company):
Nabin Haitf77cd542018-11-20 16:46:25 +0530808 parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
809 if parent_account:
810 docs.extend([
811 {
812 "doctype": "Account",
813 "account_name": "TDS Payable",
814 "account_type": "Tax",
815 "parent_account": parent_account,
816 "company": company
817 }
818 ])
Zarrar7f8024c2018-08-01 17:45:05 +0530819
820def get_tds_details(accounts, fiscal_year):
821 # bootstrap default tax withholding sections
822 return [
823 dict(name="TDS - 194C - Company",
824 category_name="Payment to Contractors (Single / Aggregate)",
825 doctype="Tax Withholding Category", accounts=accounts,
826 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
827 "single_threshold": 30000, "cumulative_threshold": 100000}]),
828 dict(name="TDS - 194C - Individual",
829 category_name="Payment to Contractors (Single / Aggregate)",
830 doctype="Tax Withholding Category", accounts=accounts,
831 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
832 "single_threshold": 30000, "cumulative_threshold": 100000}]),
833 dict(name="TDS - 194C - No PAN / Invalid PAN",
834 category_name="Payment to Contractors (Single / Aggregate)",
835 doctype="Tax Withholding Category", accounts=accounts,
836 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
837 "single_threshold": 30000, "cumulative_threshold": 100000}]),
838 dict(name="TDS - 194D - Company",
839 category_name="Insurance Commission",
840 doctype="Tax Withholding Category", accounts=accounts,
841 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
842 "single_threshold": 15000, "cumulative_threshold": 0}]),
843 dict(name="TDS - 194D - Company Assessee",
844 category_name="Insurance Commission",
845 doctype="Tax Withholding Category", accounts=accounts,
846 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
847 "single_threshold": 15000, "cumulative_threshold": 0}]),
848 dict(name="TDS - 194D - Individual",
849 category_name="Insurance Commission",
850 doctype="Tax Withholding Category", accounts=accounts,
851 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
852 "single_threshold": 15000, "cumulative_threshold": 0}]),
853 dict(name="TDS - 194D - No PAN / Invalid PAN",
854 category_name="Insurance Commission",
855 doctype="Tax Withholding Category", accounts=accounts,
856 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
857 "single_threshold": 15000, "cumulative_threshold": 0}]),
858 dict(name="TDS - 194DA - Company",
859 category_name="Non-exempt payments made under a life insurance policy",
860 doctype="Tax Withholding Category", accounts=accounts,
861 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
862 "single_threshold": 100000, "cumulative_threshold": 0}]),
863 dict(name="TDS - 194DA - Individual",
864 category_name="Non-exempt payments made under a life insurance policy",
865 doctype="Tax Withholding Category", accounts=accounts,
866 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
867 "single_threshold": 100000, "cumulative_threshold": 0}]),
868 dict(name="TDS - 194DA - No PAN / Invalid PAN",
869 category_name="Non-exempt payments made under a life insurance policy",
870 doctype="Tax Withholding Category", accounts=accounts,
871 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
872 "single_threshold": 100000, "cumulative_threshold": 0}]),
873 dict(name="TDS - 194H - Company",
874 category_name="Commission / Brokerage",
875 doctype="Tax Withholding Category", accounts=accounts,
876 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
877 "single_threshold": 15000, "cumulative_threshold": 0}]),
878 dict(name="TDS - 194H - Individual",
879 category_name="Commission / Brokerage",
880 doctype="Tax Withholding Category", accounts=accounts,
881 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
882 "single_threshold": 15000, "cumulative_threshold": 0}]),
883 dict(name="TDS - 194H - No PAN / Invalid PAN",
884 category_name="Commission / Brokerage",
885 doctype="Tax Withholding Category", accounts=accounts,
886 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
887 "single_threshold": 15000, "cumulative_threshold": 0}]),
888 dict(name="TDS - 194I - Rent - Company",
889 category_name="Rent",
890 doctype="Tax Withholding Category", accounts=accounts,
891 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
892 "single_threshold": 180000, "cumulative_threshold": 0}]),
893 dict(name="TDS - 194I - Rent - Individual",
894 category_name="Rent",
895 doctype="Tax Withholding Category", accounts=accounts,
896 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
897 "single_threshold": 180000, "cumulative_threshold": 0}]),
898 dict(name="TDS - 194I - Rent - No PAN / Invalid PAN",
899 category_name="Rent",
900 doctype="Tax Withholding Category", accounts=accounts,
901 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
902 "single_threshold": 180000, "cumulative_threshold": 0}]),
903 dict(name="TDS - 194I - Rent/Machinery - Company",
904 category_name="Rent-Plant / Machinery",
905 doctype="Tax Withholding Category", accounts=accounts,
906 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
907 "single_threshold": 180000, "cumulative_threshold": 0}]),
908 dict(name="TDS - 194I - Rent/Machinery - Individual",
909 category_name="Rent-Plant / Machinery",
910 doctype="Tax Withholding Category", accounts=accounts,
911 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
912 "single_threshold": 180000, "cumulative_threshold": 0}]),
913 dict(name="TDS - 194I - Rent/Machinery - No PAN / Invalid PAN",
914 category_name="Rent-Plant / Machinery",
915 doctype="Tax Withholding Category", accounts=accounts,
916 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
917 "single_threshold": 180000, "cumulative_threshold": 0}]),
918 dict(name="TDS - 194J - Professional Fees - Company",
919 category_name="Professional Fees",
920 doctype="Tax Withholding Category", accounts=accounts,
921 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
922 "single_threshold": 30000, "cumulative_threshold": 0}]),
923 dict(name="TDS - 194J - Professional Fees - Individual",
924 category_name="Professional Fees",
925 doctype="Tax Withholding Category", accounts=accounts,
926 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
927 "single_threshold": 30000, "cumulative_threshold": 0}]),
928 dict(name="TDS - 194J - Professional Fees - No PAN / Invalid PAN",
929 category_name="Professional Fees",
930 doctype="Tax Withholding Category", accounts=accounts,
931 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
932 "single_threshold": 30000, "cumulative_threshold": 0}]),
933 dict(name="TDS - 194J - Director Fees - Company",
934 category_name="Director Fees",
935 doctype="Tax Withholding Category", accounts=accounts,
936 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
937 "single_threshold": 0, "cumulative_threshold": 0}]),
938 dict(name="TDS - 194J - Director Fees - Individual",
939 category_name="Director Fees",
940 doctype="Tax Withholding Category", accounts=accounts,
941 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
942 "single_threshold": 0, "cumulative_threshold": 0}]),
943 dict(name="TDS - 194J - Director Fees - No PAN / Invalid PAN",
944 category_name="Director Fees",
945 doctype="Tax Withholding Category", accounts=accounts,
946 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
947 "single_threshold": 0, "cumulative_threshold": 0}]),
948 dict(name="TDS - 194 - Dividends - Company",
949 category_name="Dividends",
950 doctype="Tax Withholding Category", accounts=accounts,
951 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
952 "single_threshold": 2500, "cumulative_threshold": 0}]),
953 dict(name="TDS - 194 - Dividends - Individual",
954 category_name="Dividends",
955 doctype="Tax Withholding Category", accounts=accounts,
956 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
957 "single_threshold": 2500, "cumulative_threshold": 0}]),
958 dict(name="TDS - 194 - Dividends - No PAN / Invalid PAN",
959 category_name="Dividends",
960 doctype="Tax Withholding Category", accounts=accounts,
961 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
962 "single_threshold": 2500, "cumulative_threshold": 0}])
Anurag Mishrae1464a72020-08-17 15:03:32 +0530963 ]
964
Anurag Mishra25c35682020-08-18 14:13:54 +0530965def create_gratuity_rule():
Anurag Mishrae1464a72020-08-17 15:03:32 +0530966 # Standard Indain Gratuity Rule
Anurag Mishra493eea12020-08-18 15:02:32 +0530967 if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
968 rule = frappe.new_doc("Gratuity Rule")
969 rule.name = "Indian Standard Gratuity Rule"
970 rule.calculate_gratuity_amount_based_on = "Current Slab"
971 rule.work_experience_calculation_method = "Round Off Work Experience"
972 rule.minimum_year_for_gratuity = 5
Anurag Mishrae1464a72020-08-17 15:03:32 +0530973
Anurag Mishra493eea12020-08-18 15:02:32 +0530974 fraction = 15/26
975 rule.append("gratuity_rule_slabs", {
976 "from_year": 0,
977 "to_year":0,
978 "fraction_of_applicable_earnings": fraction
979 })
Anurag Mishrae1464a72020-08-17 15:03:32 +0530980
Anurag Mishra493eea12020-08-18 15:02:32 +0530981 rule.flags.ignore_mandatory = True
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530982 rule.save()
Deepesh Garg8fd2d8b2021-04-30 16:35:52 +0530983
984def update_accounts_settings_for_taxes():
985 if frappe.db.count('Company') == 1:
986 frappe.db.set_value('Accounts Settings', None, "add_taxes_from_item_tax_template", 0)