blob: fa9f1b7e9ef9deefb8d12db0471716eb6dbe2eba [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():
31 # HSN codes
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053032 with open(os.path.join(os.path.dirname(__file__), 'hsn_code_data.json'), 'r') as f:
33 hsn_codes = json.loads(f.read())
34
Nabin Hait1a609312017-07-13 12:16:04 +053035 create_hsn_codes(hsn_codes, code_field="hsn_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053036
Nabin Hait1a609312017-07-13 12:16:04 +053037 # SAC Codes
38 with open(os.path.join(os.path.dirname(__file__), 'sac_code_data.json'), 'r') as f:
39 sac_codes = json.loads(f.read())
40 create_hsn_codes(sac_codes, code_field="sac_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053041
Nabin Hait1a609312017-07-13 12:16:04 +053042def create_hsn_codes(data, code_field):
43 for d in data:
Rushabh Mehtaf702d722017-09-27 15:31:30 +053044 hsn_code = frappe.new_doc('GST HSN Code')
45 hsn_code.description = d["description"]
46 hsn_code.hsn_code = d[code_field]
47 hsn_code.name = d[code_field]
48 try:
Nabin Hait1a609312017-07-13 12:16:04 +053049 hsn_code.db_insert()
Rushabh Mehtaf702d722017-09-27 15:31:30 +053050 except frappe.DuplicateEntryError:
51 pass
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053052
Rushabh Mehta919a74a2017-06-22 16:37:04 +053053def add_custom_roles_for_reports():
54 for report_name in ('GST Sales Register', 'GST Purchase Register',
Saqib93203162021-04-12 17:55:46 +053055 'GST Itemised Sales Register', 'GST Itemised Purchase Register', 'Eway Bill', 'E-Invoice Summary'):
Rushabh Mehta919a74a2017-06-22 16:37:04 +053056
Rushabh Mehta919a74a2017-06-22 16:37:04 +053057 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
58 frappe.get_doc(dict(
59 doctype='Custom Role',
60 report=report_name,
61 roles= [
62 dict(role='Accounts User'),
63 dict(role='Accounts Manager')
64 ]
65 )).insert()
66
Anurag Mishra289c8222020-06-19 19:17:57 +053067 for report_name in ('Professional Tax Deductions', 'Provident Fund Deductions'):
68
69 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
70 frappe.get_doc(dict(
71 doctype='Custom Role',
72 report=report_name,
73 roles= [
74 dict(role='HR User'),
75 dict(role='HR Manager'),
76 dict(role='Employee')
77 ]
78 )).insert()
79
Anurag Mishra54cd1942020-09-03 13:51:26 +053080 for report_name in ('HSN-wise-summary of outward supplies', 'GSTR-1', 'GSTR-2'):
81
82 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
83 frappe.get_doc(dict(
84 doctype='Custom Role',
85 report=report_name,
86 roles= [
87 dict(role='Accounts User'),
88 dict(role='Accounts Manager'),
89 dict(role='Auditor')
90 ]
91 )).insert()
92
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053093def add_permissions():
Saqib6d74f5b2020-12-25 10:26:43 +053094 for doctype in ('GST HSN Code', 'GST Settings', 'GSTR 3B Report', 'Lower Deduction Certificate', 'E Invoice Settings'):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053095 add_permission(doctype, 'All', 0)
Deepesh Garg6c8efde2020-04-04 20:05:17 +053096 for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
Saqib5e6ce882020-02-03 15:40:35 +053097 add_permission(doctype, role, 0)
98 update_permission_property(doctype, role, 0, 'write', 1)
99 update_permission_property(doctype, role, 0, 'create', 1)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530100
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530101 if doctype == 'GST HSN Code':
102 for role in ('Item Manager', 'Stock Manager'):
103 add_permission(doctype, role, 0)
104 update_permission_property(doctype, role, 0, 'write', 1)
105 update_permission_property(doctype, role, 0, 'create', 1)
106
Nabin Hait852cb642017-07-05 12:58:19 +0530107def add_print_formats():
108 frappe.reload_doc("regional", "print_format", "gst_tax_invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530109 frappe.reload_doc("accounts", "print_format", "gst_pos_invoice")
Saqib6d74f5b2020-12-25 10:26:43 +0530110 frappe.reload_doc("accounts", "print_format", "GST E-Invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530111
barredterra1521b312021-03-03 12:33:48 +0100112 frappe.db.set_value("Print Format", "GST POS Invoice", "disabled", 0)
113 frappe.db.set_value("Print Format", "GST Tax Invoice", "disabled", 0)
114 frappe.db.set_value("Print Format", "GST E-Invoice", "disabled", 0)
Nabin Hait852cb642017-07-05 12:58:19 +0530115
Nabin Hait10c61372021-04-13 15:46:01 +0530116def make_property_setters(patch=False):
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530117 # GST rules do not allow for an invoice no. bigger than 16 characters
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530118 journal_entry_types = frappe.get_meta("Journal Entry").get_options("voucher_type").split("\n") + ['Reversal Of ITC']
119
Nabin Hait10c61372021-04-13 15:46:01 +0530120 if not patch:
121 make_property_setter('Sales Invoice', 'naming_series', 'options', 'SINV-.YY.-\nSRET-.YY.-', '')
122 make_property_setter('Purchase Invoice', 'naming_series', 'options', 'PINV-.YY.-\nPRET-.YY.-', '')
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530123 make_property_setter('Journal Entry', 'voucher_type', 'options', '\n'.join(journal_entry_types), '')
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530124
Rushabh Mehta69fa8082018-07-17 18:22:51 +0530125def make_custom_fields(update=True):
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530126 hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
Nabin Haitd34bfa82018-11-13 18:19:58 +0530127 fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description',
Nabin Haitf4af6082019-04-01 11:51:54 +0530128 allow_on_submit=1, print_hide=1, fetch_if_empty=1)
Marica9942acd2020-04-21 13:13:39 +0530129 nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530130 fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code',
131 print_hide=1)
132 is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST',
133 fieldtype='Check', fetch_from='item_code.is_non_gst', insert_after='is_nil_exempt',
134 print_hide=1)
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530135 taxable_value = dict(fieldname='taxable_value', label='Taxable Value',
136 fieldtype='Currency', insert_after='base_net_amount', hidden=1, options="Company:company:default_currency",
137 print_hide=1)
Deepesh Garg22b61602019-03-21 20:47:47 +0530138
139 purchase_invoice_gst_category = [
Nabin Hait879e1622017-08-21 08:28:55 +0530140 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
vishdha109b4082018-01-30 12:11:13 +0530141 insert_after='language', print_hide=1, collapsible=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530142 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530143 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530144 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530145 fetch_from='supplier.gst_category', fetch_if_empty=1),
146 dict(fieldname='export_type', label='Export Type',
147 fieldtype='Select', insert_after='gst_category', print_hide=1,
148 depends_on='eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
149 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='supplier.export_type',
150 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530151 ]
152
153 sales_invoice_gst_category = [
154 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
155 insert_after='language', print_hide=1, collapsible=1),
156 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530157 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530158 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530159 fetch_from='customer.gst_category', fetch_if_empty=1),
160 dict(fieldname='export_type', label='Export Type',
161 fieldtype='Select', insert_after='gst_category', print_hide=1,
162 depends_on='eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
163 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='customer.export_type',
164 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530165 ]
166
Deepesh Garg29997412021-03-29 19:49:52 +0530167 delivery_note_gst_category = [
168 dict(fieldname='gst_category', label='GST Category',
169 fieldtype='Select', insert_after='gst_vehicle_type', print_hide=1,
170 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
171 fetch_from='customer.gst_category', fetch_if_empty=1),
172 ]
173
Deepesh Garg22b61602019-03-21 20:47:47 +0530174 invoice_gst_fields = [
Nabin Hait879e1622017-08-21 08:28:55 +0530175 dict(fieldname='invoice_copy', label='Invoice Copy',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530176 fieldtype='Select', insert_after='export_type', print_hide=1, allow_on_submit=1,
Nabin Hait879e1622017-08-21 08:28:55 +0530177 options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'),
178 dict(fieldname='reverse_charge', label='Reverse Charge',
179 fieldtype='Select', insert_after='invoice_copy', print_hide=1,
180 options='Y\nN', default='N'),
Nabin Hait879e1622017-08-21 08:28:55 +0530181 dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN',
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530182 fieldtype='Data', insert_after='export_type', print_hide=1),
Nabin Haite6d65bc2018-02-14 17:44:06 +0530183 dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='ecommerce_gstin'),
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530184 dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document',
Nabin Haitb02c1092018-02-05 16:09:51 +0530185 fieldtype='Select', insert_after='gst_col_break', print_hide=1,
Nabin Haite6d65bc2018-02-14 17:44:06 +0530186 depends_on='eval:doc.is_return==1',
Nabin Haita8d10b72018-02-12 16:54:13 +0530187 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 +0530188 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530189
Nabin Hait879e1622017-08-21 08:28:55 +0530190 purchase_invoice_gst_fields = [
191 dict(fieldname='supplier_gstin', label='Supplier GSTIN',
192 fieldtype='Data', insert_after='supplier_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530193 fetch_from='supplier_address.gstin', print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530194 dict(fieldname='company_gstin', label='Company GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530195 fieldtype='Data', insert_after='shipping_address_display',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530196 fetch_from='shipping_address.gstin', print_hide=1, read_only=1),
Nabin Haitb02c1092018-02-05 16:09:51 +0530197 dict(fieldname='place_of_supply', label='Place of Supply',
198 fieldtype='Data', insert_after='shipping_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530199 print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530200 ]
201
202 purchase_invoice_itc_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530203 dict(fieldname='eligibility_for_itc', label='Eligibility For ITC',
204 fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530205 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',
206 default="All Other ITC"),
vishdha98e33c32018-01-29 13:57:34 +0530207 dict(fieldname='itc_integrated_tax', label='Availed ITC Integrated Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530208 fieldtype='Currency', insert_after='eligibility_for_itc',
209 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530210 dict(fieldname='itc_central_tax', label='Availed ITC Central Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530211 fieldtype='Currency', insert_after='itc_integrated_tax',
212 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530213 dict(fieldname='itc_state_tax', label='Availed ITC State/UT Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530214 fieldtype='Currency', insert_after='itc_central_tax',
215 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530216 dict(fieldname='itc_cess_amount', label='Availed ITC Cess',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530217 fieldtype='Currency', insert_after='itc_state_tax',
218 options='Company:company:default_currency', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530219 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530220
Nabin Hait879e1622017-08-21 08:28:55 +0530221 sales_invoice_gst_fields = [
rohitwaghchaure16645802017-09-28 11:05:03 +0530222 dict(fieldname='billing_address_gstin', label='Billing Address GSTIN',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530223 fieldtype='Data', insert_after='customer_address', read_only=1,
Shreya Shah4fa600a2018-06-05 11:27:53 +0530224 fetch_from='customer_address.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530225 dict(fieldname='customer_gstin', label='Customer GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530226 fieldtype='Data', insert_after='shipping_address_name',
227 fetch_from='shipping_address_name.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530228 dict(fieldname='place_of_supply', label='Place of Supply',
Nabin Hait619c42b2018-01-10 17:48:03 +0530229 fieldtype='Data', insert_after='customer_gstin',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530230 print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530231 dict(fieldname='company_gstin', label='Company GSTIN',
232 fieldtype='Data', insert_after='company_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530233 fetch_from='company_address.gstin', print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530234 ]
235
236 sales_invoice_shipping_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530237 dict(fieldname='port_code', label='Port Code',
238 fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530239 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530240 dict(fieldname='shipping_bill_number', label=' Shipping Bill Number',
241 fieldtype='Data', insert_after='port_code', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530242 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530243 dict(fieldname='shipping_bill_date', label='Shipping Bill Date',
244 fieldtype='Date', insert_after='shipping_bill_number', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530245 depends_on="eval:doc.gst_category=='Overseas' "),
Nabin Hait879e1622017-08-21 08:28:55 +0530246 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530247
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530248 journal_entry_fields = [
249 dict(fieldname='reversal_type', label='Reversal Type',
250 fieldtype='Select', insert_after='voucher_type', print_hide=1,
251 options="As per rules 42 & 43 of CGST Rules\nOthers",
252 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
253 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
254 dict(fieldname='company_address', label='Company Address',
255 fieldtype='Link', options='Address', insert_after='reversal_type',
256 print_hide=1, depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
257 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
258 dict(fieldname='company_gstin', label='Company GSTIN',
259 fieldtype='Data', read_only=1, insert_after='company_address', print_hide=1,
260 fetch_from='company_address.gstin',
261 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
262 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'")
263 ]
264
Shreya Shah4fa600a2018-06-05 11:27:53 +0530265 inter_state_gst_field = [
266 dict(fieldname='is_inter_state', label='Is Inter State',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530267 fieldtype='Check', insert_after='disabled', print_hide=1),
268 dict(fieldname='tax_category_column_break', fieldtype='Column Break',
269 insert_after='is_inter_state'),
270 dict(fieldname='gst_state', label='Source State', fieldtype='Select',
271 options='\n'.join(states), insert_after='company')
Shreya Shah4fa600a2018-06-05 11:27:53 +0530272 ]
273
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530274 ewaybill_fields = [
275 {
276 'fieldname': 'distance',
277 'label': 'Distance (in km)',
278 'fieldtype': 'Float',
279 'insert_after': 'vehicle_no',
280 'print_hide': 1
281 },
282 {
283 'fieldname': 'gst_transporter_id',
284 'label': 'GST Transporter ID',
285 'fieldtype': 'Data',
Nabin Hait34c551d2019-07-03 10:34:31 +0530286 'insert_after': 'transporter',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530287 'fetch_from': 'transporter.gst_transporter_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530288 'print_hide': 1,
289 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530290 },
291 {
292 'fieldname': 'mode_of_transport',
293 'label': 'Mode of Transport',
294 'fieldtype': 'Select',
295 'options': '\nRoad\nAir\nRail\nShip',
296 'default': 'Road',
Nabin Hait34c551d2019-07-03 10:34:31 +0530297 'insert_after': 'transporter_name',
298 'print_hide': 1,
299 'translatable': 0
300 },
301 {
302 'fieldname': 'gst_vehicle_type',
303 'label': 'GST Vehicle Type',
304 'fieldtype': 'Select',
305 'options': 'Regular\nOver Dimensional Cargo (ODC)',
306 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
307 'default': 'Regular',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530308 'insert_after': 'lr_date',
Nabin Hait34c551d2019-07-03 10:34:31 +0530309 'print_hide': 1,
310 'translatable': 0
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530311 },
312 {
313 'fieldname': 'ewaybill',
314 'label': 'E-Way Bill No.',
315 'fieldtype': 'Data',
316 'depends_on': 'eval:(doc.docstatus === 1)',
317 'allow_on_submit': 1,
318 'insert_after': 'customer_name_in_arabic',
319 'translatable': 0,
Deepesh Garg29997412021-03-29 19:49:52 +0530320 }
Nabin Hait34c551d2019-07-03 10:34:31 +0530321 ]
322
323 si_ewaybill_fields = [
324 {
325 'fieldname': 'transporter_info',
326 'label': 'Transporter Info',
327 'fieldtype': 'Section Break',
328 'insert_after': 'terms',
329 'collapsible': 1,
330 'collapsible_depends_on': 'transporter',
331 'print_hide': 1
332 },
333 {
334 'fieldname': 'transporter',
335 'label': 'Transporter',
336 'fieldtype': 'Link',
337 'insert_after': 'transporter_info',
338 'options': 'Supplier',
339 'print_hide': 1
340 },
341 {
342 'fieldname': 'gst_transporter_id',
343 'label': 'GST Transporter ID',
344 'fieldtype': 'Data',
345 'insert_after': 'transporter',
346 'fetch_from': 'transporter.gst_transporter_id',
347 'print_hide': 1,
348 'translatable': 0
349 },
350 {
351 'fieldname': 'driver',
352 'label': 'Driver',
353 'fieldtype': 'Link',
354 'insert_after': 'gst_transporter_id',
355 'options': 'Driver',
356 'print_hide': 1
357 },
358 {
359 'fieldname': 'lr_no',
360 'label': 'Transport Receipt No',
361 'fieldtype': 'Data',
362 'insert_after': 'driver',
363 'print_hide': 1,
364 'translatable': 0
365 },
366 {
367 'fieldname': 'vehicle_no',
368 'label': 'Vehicle No',
369 'fieldtype': 'Data',
370 'insert_after': 'lr_no',
371 'print_hide': 1,
372 'translatable': 0
373 },
374 {
375 'fieldname': 'distance',
376 'label': 'Distance (in km)',
377 'fieldtype': 'Float',
378 'insert_after': 'vehicle_no',
379 'print_hide': 1
380 },
381 {
382 'fieldname': 'transporter_col_break',
383 'fieldtype': 'Column Break',
384 'insert_after': 'distance'
385 },
386 {
387 'fieldname': 'transporter_name',
388 'label': 'Transporter Name',
389 'fieldtype': 'Data',
390 'insert_after': 'transporter_col_break',
391 'fetch_from': 'transporter.name',
392 'read_only': 1,
393 'print_hide': 1,
394 'translatable': 0
395 },
396 {
397 'fieldname': 'mode_of_transport',
398 'label': 'Mode of Transport',
399 'fieldtype': 'Select',
400 'options': '\nRoad\nAir\nRail\nShip',
Nabin Hait34c551d2019-07-03 10:34:31 +0530401 'insert_after': 'transporter_name',
402 'print_hide': 1,
403 'translatable': 0
404 },
405 {
406 'fieldname': 'driver_name',
407 'label': 'Driver Name',
408 'fieldtype': 'Data',
409 'insert_after': 'mode_of_transport',
410 'fetch_from': 'driver.full_name',
411 'print_hide': 1,
412 'translatable': 0
413 },
414 {
415 'fieldname': 'lr_date',
416 'label': 'Transport Receipt Date',
417 'fieldtype': 'Date',
418 'insert_after': 'driver_name',
419 'default': 'Today',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530420 'print_hide': 1
421 },
422 {
423 'fieldname': 'gst_vehicle_type',
424 'label': 'GST Vehicle Type',
425 'fieldtype': 'Select',
Nabin Hait34c551d2019-07-03 10:34:31 +0530426 'options': 'Regular\nOver Dimensional Cargo (ODC)',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530427 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
Nabin Hait34c551d2019-07-03 10:34:31 +0530428 'default': 'Regular',
429 'insert_after': 'lr_date',
430 'print_hide': 1,
431 'translatable': 0
432 },
433 {
434 'fieldname': 'ewaybill',
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530435 'label': 'E-Way Bill No.',
Nabin Hait34c551d2019-07-03 10:34:31 +0530436 'fieldtype': 'Data',
Saqib6d74f5b2020-12-25 10:26:43 +0530437 'depends_on': 'eval:((doc.docstatus === 1 || doc.ewaybill) && doc.eway_bill_cancelled === 0)',
Nabin Hait34c551d2019-07-03 10:34:31 +0530438 'allow_on_submit': 1,
deepeshgarg007a85db662019-07-14 18:15:19 +0530439 'insert_after': 'tax_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530440 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530441 }
442 ]
443
Saqib6d74f5b2020-12-25 10:26:43 +0530444 si_einvoice_fields = [
445 dict(fieldname='irn', label='IRN', fieldtype='Data', read_only=1, insert_after='customer', no_copy=1, print_hide=1,
446 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 +0530447
Saqib6d74f5b2020-12-25 10:26:43 +0530448 dict(fieldname='irn_cancelled', label='IRN Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
449 depends_on='eval:(doc.irn_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
450
Saqibd502f762021-05-06 16:10:55 +0530451 dict(fieldname='eway_bill_validity', label='E-Way Bill Validity', fieldtype='Data', no_copy=1, print_hide=1,
452 depends_on='ewaybill', read_only=1, allow_on_submit=1, insert_after='ewaybill'),
453
Saqib6d74f5b2020-12-25 10:26:43 +0530454 dict(fieldname='eway_bill_cancelled', label='E-Way Bill Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
455 depends_on='eval:(doc.eway_bill_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
456
Saqib93203162021-04-12 17:55:46 +0530457 dict(fieldname='einvoice_section', label='E-Invoice Fields', fieldtype='Section Break', insert_after='gst_vehicle_type',
458 print_hide=1, hidden=1),
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530459
Saqib93203162021-04-12 17:55:46 +0530460 dict(fieldname='ack_no', label='Ack. No.', fieldtype='Data', read_only=1, hidden=1, insert_after='einvoice_section',
461 no_copy=1, print_hide=1),
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530462
Saqib93203162021-04-12 17:55:46 +0530463 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 +0530464
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530465 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 +0530466 no_copy=1, print_hide=1),
Saqib6d74f5b2020-12-25 10:26:43 +0530467
Saqib93203162021-04-12 17:55:46 +0530468 dict(fieldname='signed_einvoice', label='Signed E-Invoice', fieldtype='Code', options='JSON', hidden=1, insert_after='irn_cancel_date',
469 no_copy=1, print_hide=1, read_only=1),
470
471 dict(fieldname='signed_qr_code', label='Signed QRCode', fieldtype='Code', options='JSON', hidden=1, insert_after='signed_einvoice',
472 no_copy=1, print_hide=1, read_only=1),
473
474 dict(fieldname='qrcode_image', label='QRCode', fieldtype='Attach Image', hidden=1, insert_after='signed_qr_code',
475 no_copy=1, print_hide=1, read_only=1),
476
477 dict(fieldname='einvoice_status', label='E-Invoice Status', fieldtype='Select', insert_after='qrcode_image',
478 options='\nPending\nGenerated\nCancelled\nFailed', default=None, hidden=1, no_copy=1, print_hide=1, read_only=1),
479
480 dict(fieldname='failure_description', label='E-Invoice Failure Description', fieldtype='Code', options='JSON',
481 hidden=1, insert_after='einvoice_status', no_copy=1, print_hide=1, read_only=1)
Saqib6d74f5b2020-12-25 10:26:43 +0530482 ]
483
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530484 custom_fields = {
485 'Address': [
Rushabh Mehta919a74a2017-06-22 16:37:04 +0530486 dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data',
487 insert_after='fax'),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530488 dict(fieldname='gst_state', label='GST State', fieldtype='Select',
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530489 options='\n'.join(states), insert_after='gstin'),
490 dict(fieldname='gst_state_number', label='GST State Number',
Nabin Hait562d9422018-09-07 16:14:44 +0530491 fieldtype='Data', insert_after='gst_state', read_only=1),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530492 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530493 'Purchase Invoice': purchase_invoice_gst_category + invoice_gst_fields + purchase_invoice_itc_fields + purchase_invoice_gst_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530494 'Purchase Order': purchase_invoice_gst_fields,
495 'Purchase Receipt': purchase_invoice_gst_fields,
Saqib6d74f5b2020-12-25 10:26:43 +0530496 '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 +0530497 'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields + delivery_note_gst_category,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530498 'Journal Entry': journal_entry_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530499 'Sales Order': sales_invoice_gst_fields,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530500 'Tax Category': inter_state_gst_field,
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530501 'Item': [
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530502 dict(fieldname='gst_hsn_code', label='HSN/SAC',
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530503 fieldtype='Link', options='GST HSN Code', insert_after='item_group'),
Marica9942acd2020-04-21 13:13:39 +0530504 dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530505 fieldtype='Check', insert_after='gst_hsn_code'),
506 dict(fieldname='is_non_gst', label='Is Non GST ',
507 fieldtype='Check', insert_after='is_nil_exempt')
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530508 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530509 'Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
510 'Supplier Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
511 'Sales Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
512 'Delivery Note Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530513 'Sales Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Deepesh Garg22b61602019-03-21 20:47:47 +0530514 'Purchase Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
515 'Purchase Receipt Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530516 'Purchase Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Himanshu Warekar656d8e42019-04-01 19:38:43 +0530517 'Material Request Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Anurag Mishra289c8222020-06-19 19:17:57 +0530518 'Salary Component': [
519 dict(fieldname= 'component_type',
520 label= 'Component Type',
521 fieldtype= 'Select',
522 insert_after= 'description',
523 options= "\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax",
524 depends_on = 'eval:doc.type == "Deduction"'
525 )
526 ],
Pawan Mehtaf4196352018-04-05 14:54:51 +0530527 'Employee': [
Anurag Mishra289c8222020-06-19 19:17:57 +0530528 dict(fieldname='ifsc_code',
529 label='IFSC Code',
530 fieldtype='Data',
531 insert_after='bank_ac_no',
532 print_hide=1,
533 depends_on='eval:doc.salary_mode == "Bank"'
534 ),
535 dict(
536 fieldname = 'pan_number',
537 label = 'PAN Number',
538 fieldtype = 'Data',
539 insert_after = 'payroll_cost_center',
540 print_hide = 1
541 ),
542 dict(
543 fieldname = 'micr_code',
544 label = 'MICR Code',
545 fieldtype = 'Data',
546 insert_after = 'ifsc_code',
547 print_hide = 1,
548 depends_on='eval:doc.salary_mode == "Bank"'
549 ),
550 dict(
551 fieldname = 'provident_fund_account',
552 label = 'Provident Fund Account',
553 fieldtype = 'Data',
554 insert_after = 'pan_number'
555 )
556
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530557 ],
558 'Company': [
559 dict(fieldname='hra_section', label='HRA Settings',
Anurag Mishraa5527222019-06-14 15:25:57 +0530560 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530561 dict(fieldname='basic_component', label='Basic Component',
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530562 fieldtype='Link', options='Salary Component', insert_after='hra_section'),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530563 dict(fieldname='hra_component', label='HRA Component',
564 fieldtype='Link', options='Salary Component', insert_after='basic_component'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530565 dict(fieldname='arrear_component', label='Arrear Component',
Mangesh-Khairnar9215de02019-05-06 16:24:10 +0530566 fieldtype='Link', options='Salary Component', insert_after='hra_component'),
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530567 dict(fieldname='non_profit_section', label='Non Profit Settings',
568 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
569 dict(fieldname='company_80g_number', label='80G Number',
570 fieldtype='Data', insert_after='non_profit_section'),
571 dict(fieldname='with_effect_from', label='80G With Effect From',
572 fieldtype='Date', insert_after='company_80g_number'),
573 dict(fieldname='pan_details', label='PAN Number',
574 fieldtype='Data', insert_after='with_effect_from')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530575 ],
576 'Employee Tax Exemption Declaration':[
577 dict(fieldname='hra_section', label='HRA Exemption',
578 fieldtype='Section Break', insert_after='declarations'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530579 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530580 fieldtype='Currency', insert_after='hra_section'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530581 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530582 fieldtype='Check', insert_after='monthly_house_rent', depends_on='monthly_house_rent'),
583 dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure',
584 fieldtype='Currency', insert_after='rented_in_metro_city', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530585 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530586 insert_after='salary_structure_hra', depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530587 dict(fieldname='annual_hra_exemption', label='Annual HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530588 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530589 dict(fieldname='monthly_hra_exemption', label='Monthly HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530590 fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1, depends_on='monthly_house_rent')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530591 ],
592 'Employee Tax Exemption Proof Submission': [
593 dict(fieldname='hra_section', label='HRA Exemption',
594 fieldtype='Section Break', insert_after='tax_exemption_proofs'),
595 dict(fieldname='house_rent_payment_amount', label='House Rent Payment Amount',
596 fieldtype='Currency', insert_after='hra_section'),
597 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530598 fieldtype='Check', insert_after='house_rent_payment_amount', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530599 dict(fieldname='rented_from_date', label='Rented From Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530600 fieldtype='Date', insert_after='rented_in_metro_city', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530601 dict(fieldname='rented_to_date', label='Rented To Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530602 fieldtype='Date', insert_after='rented_from_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530603 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530604 insert_after='rented_to_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530605 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530606 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530607 dict(fieldname='monthly_hra_exemption', label='Monthly Eligible Amount',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530608 fieldtype='Currency', insert_after='monthly_house_rent', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530609 dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530610 fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1, depends_on='house_rent_payment_amount')
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530611 ],
612 'Supplier': [
613 {
614 'fieldname': 'gst_transporter_id',
615 'label': 'GST Transporter ID',
616 'fieldtype': 'Data',
617 'insert_after': 'supplier_type',
618 'depends_on': 'eval:doc.is_transporter'
Deepesh Garg22b61602019-03-21 20:47:47 +0530619 },
620 {
621 'fieldname': 'gst_category',
622 'label': 'GST Category',
623 'fieldtype': 'Select',
624 'insert_after': 'gst_transporter_id',
625 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
626 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530627 },
628 {
629 'fieldname': 'export_type',
630 'label': 'Export Type',
631 'fieldtype': 'Select',
632 'insert_after': 'gst_category',
633 'default': 'Without Payment of Tax',
634 'depends_on':'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
635 'options': '\nWith Payment of Tax\nWithout Payment of Tax'
Deepesh Garg22b61602019-03-21 20:47:47 +0530636 }
637 ],
638 'Customer': [
639 {
640 'fieldname': 'gst_category',
641 'label': 'GST Category',
642 'fieldtype': 'Select',
643 'insert_after': 'customer_type',
644 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
645 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530646 },
647 {
648 'fieldname': 'export_type',
649 'label': 'Export Type',
650 'fieldtype': 'Select',
651 'insert_after': 'gst_category',
652 'default': 'Without Payment of Tax',
653 'depends_on':'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
654 'options': '\nWith Payment of Tax\nWithout Payment of Tax'
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530655 }
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530656 ],
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530657 'Member': [
658 {
659 'fieldname': 'pan_number',
660 'label': 'PAN Details',
661 'fieldtype': 'Data',
662 'insert_after': 'email_id'
663 }
664 ],
665 'Donor': [
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530666 {
667 'fieldname': 'pan_number',
668 'label': 'PAN Details',
669 'fieldtype': 'Data',
670 'insert_after': 'email'
671 }
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530672 ]
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530673 }
Deepesh Garg22b61602019-03-21 20:47:47 +0530674 create_custom_fields(custom_fields, update=update)
Nabin Hait9c421612017-07-20 13:32:01 +0530675
Saurabh2d8a7ee2018-05-11 13:16:16 +0530676def make_fixtures(company=None):
677 docs = []
Deepesh Garga66184f2021-05-02 12:22:16 +0530678 company = company or frappe.db.get_value("Global Defaults", None, "default_company")
Saurabh2d8a7ee2018-05-11 13:16:16 +0530679
680 set_salary_components(docs)
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530681 set_tds_account(docs, company)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530682
683 for d in docs:
684 try:
685 doc = frappe.get_doc(d)
686 doc.flags.ignore_permissions = True
687 doc.insert()
688 except frappe.NameError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530689 frappe.clear_messages()
Zarrar7f8024c2018-08-01 17:45:05 +0530690 except frappe.DuplicateEntryError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530691 frappe.clear_messages()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530692
Zarrar7f8024c2018-08-01 17:45:05 +0530693 # create records for Tax Withholding Category
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530694 set_tax_withholding_category(company)
695
Deepesh Gargb3ed8072021-06-02 13:26:21 +0530696def update_regional_tax_settings(country, company):
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530697 # Will only add default GST accounts if present
698 input_account_names = ['Input Tax CGST', 'Input Tax SGST', 'Input Tax IGST']
699 output_account_names = ['Output Tax CGST', 'Output Tax SGST', 'Output Tax IGST']
Deepesh Garg48b1a822021-05-29 23:54:51 +0530700 rcm_accounts = ['Input Tax CGST RCM', 'Input Tax SGST RCM', 'Input Tax IGST RCM']
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530701 gst_settings = frappe.get_single('GST Settings')
702 existing_account_list = []
703
704 for account in gst_settings.get('gst_accounts'):
705 for key in ['cgst_account', 'sgst_account', 'igst_account']:
706 existing_account_list.append(account.get(key))
707
708 gst_accounts = frappe._dict(frappe.get_all("Account",
Deepesh Garg48b1a822021-05-29 23:54:51 +0530709 {'company': company, 'account_name': ('in', input_account_names +
710 output_account_names + rcm_accounts)}, ['account_name', 'name'], as_list=1))
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530711
Deepesh Garg48b1a822021-05-29 23:54:51 +0530712 add_accounts_in_gst_settings(company, input_account_names, gst_accounts,
713 existing_account_list, gst_settings)
714 add_accounts_in_gst_settings(company, output_account_names, gst_accounts,
715 existing_account_list, gst_settings)
716 add_accounts_in_gst_settings(company, rcm_accounts, gst_accounts,
717 existing_account_list, gst_settings, is_reverse_charge=1)
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530718
719 gst_settings.save()
720
Deepesh Garg48b1a822021-05-29 23:54:51 +0530721def add_accounts_in_gst_settings(company, account_names, gst_accounts,
722 existing_account_list, gst_settings, is_reverse_charge=0):
723 accounts_not_added = 1
724
725 for account in account_names:
726 # Default Account Added does not exists
727 if not gst_accounts.get(account):
728 accounts_not_added = 0
729
730 # Check if already added in GST Settings
731 if gst_accounts.get(account) in existing_account_list:
732 accounts_not_added = 0
733
734 if accounts_not_added:
735 gst_settings.append('gst_accounts', {
736 'company': company,
737 'cgst_account': gst_accounts.get(account_names[0]),
738 'sgst_account': gst_accounts.get(account_names[1]),
739 'igst_account': gst_accounts.get(account_names[2]),
740 'is_reverse_charge_account': is_reverse_charge
741 })
742
Saurabh2d8a7ee2018-05-11 13:16:16 +0530743def set_salary_components(docs):
744 docs.extend([
Nabin Hait58ee6c12020-04-26 17:45:57 +0530745 {'doctype': 'Salary Component', 'salary_component': 'Professional Tax',
746 'description': 'Professional Tax', 'type': 'Deduction', 'exempted_from_income_tax': 1},
747 {'doctype': 'Salary Component', 'salary_component': 'Provident Fund',
748 'description': 'Provident fund', 'type': 'Deduction', 'is_tax_applicable': 1},
749 {'doctype': 'Salary Component', 'salary_component': 'House Rent Allowance',
750 'description': 'House Rent Allowance', 'type': 'Earning', 'is_tax_applicable': 1},
751 {'doctype': 'Salary Component', 'salary_component': 'Basic',
752 'description': 'Basic', 'type': 'Earning', 'is_tax_applicable': 1},
753 {'doctype': 'Salary Component', 'salary_component': 'Arrear',
754 'description': 'Arrear', 'type': 'Earning', 'is_tax_applicable': 1},
755 {'doctype': 'Salary Component', 'salary_component': 'Leave Encashment',
756 'description': 'Leave Encashment', 'type': 'Earning', 'is_tax_applicable': 1}
Saurabh2d8a7ee2018-05-11 13:16:16 +0530757 ])
758
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530759def set_tax_withholding_category(company):
Saurabh2d8a7ee2018-05-11 13:16:16 +0530760 accounts = []
Anuja Pawar4569e522021-01-14 19:24:30 +0530761 fiscal_year = None
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530762 abbr = frappe.get_value("Company", company, "abbr")
763 tds_account = frappe.get_value("Account", 'TDS Payable - {0}'.format(abbr), 'name')
Saurabh2d8a7ee2018-05-11 13:16:16 +0530764
765 if company and tds_account:
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530766 accounts = [dict(company=company, account=tds_account)]
Saurabh2d8a7ee2018-05-11 13:16:16 +0530767
Anuja Pawar4569e522021-01-14 19:24:30 +0530768 try:
769 fiscal_year = get_fiscal_year(today(), verbose=0, company=company)[0]
770 except FiscalYearError:
771 pass
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530772
Anuja Pawar4569e522021-01-14 19:24:30 +0530773 docs = get_tds_details(accounts, fiscal_year)
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530774
Zarrar7f8024c2018-08-01 17:45:05 +0530775 for d in docs:
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530776 if not frappe.db.exists("Tax Withholding Category", d.get("name")):
Zarrar7f8024c2018-08-01 17:45:05 +0530777 doc = frappe.get_doc(d)
Deepesh Garg204ea102021-04-30 16:35:52 +0530778 doc.flags.ignore_validate = True
Zarrar7f8024c2018-08-01 17:45:05 +0530779 doc.flags.ignore_permissions = True
Nabin Haitafef9c12019-02-12 11:28:20 +0530780 doc.flags.ignore_mandatory = True
Zarrar7f8024c2018-08-01 17:45:05 +0530781 doc.insert()
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530782 else:
Zarrar7f8024c2018-08-01 17:45:05 +0530783 doc = frappe.get_doc("Tax Withholding Category", d.get("name"))
Zarrar963d62b2019-03-23 10:30:12 +0530784
785 if accounts:
786 doc.append("accounts", accounts[0])
Zarrar7f8024c2018-08-01 17:45:05 +0530787
Anuja Pawar4569e522021-01-14 19:24:30 +0530788 if fiscal_year:
789 # if fiscal year don't match with any of the already entered data, append rate row
790 fy_exist = [k for k in doc.get('rates') if k.get('fiscal_year')==fiscal_year]
791 if not fy_exist:
792 doc.append("rates", d.get('rates')[0])
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530793
Anuja Pawar4569e522021-01-14 19:24:30 +0530794 doc.flags.ignore_permissions = True
Deepesh Garg48b1a822021-05-29 23:54:51 +0530795 doc.flags.ignore_validate = True
Anuja Pawar4569e522021-01-14 19:24:30 +0530796 doc.flags.ignore_mandatory = True
Deepesh Garg204ea102021-04-30 16:35:52 +0530797 doc.flags.ignore_links = True
Zarrar7f8024c2018-08-01 17:45:05 +0530798 doc.save()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530799
800def set_tds_account(docs, company):
Nabin Haitf77cd542018-11-20 16:46:25 +0530801 parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
802 if parent_account:
803 docs.extend([
804 {
805 "doctype": "Account",
806 "account_name": "TDS Payable",
807 "account_type": "Tax",
808 "parent_account": parent_account,
809 "company": company
810 }
811 ])
Zarrar7f8024c2018-08-01 17:45:05 +0530812
813def get_tds_details(accounts, fiscal_year):
814 # bootstrap default tax withholding sections
815 return [
816 dict(name="TDS - 194C - Company",
817 category_name="Payment to Contractors (Single / Aggregate)",
818 doctype="Tax Withholding Category", accounts=accounts,
819 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
820 "single_threshold": 30000, "cumulative_threshold": 100000}]),
821 dict(name="TDS - 194C - Individual",
822 category_name="Payment to Contractors (Single / Aggregate)",
823 doctype="Tax Withholding Category", accounts=accounts,
824 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
825 "single_threshold": 30000, "cumulative_threshold": 100000}]),
826 dict(name="TDS - 194C - No PAN / Invalid PAN",
827 category_name="Payment to Contractors (Single / Aggregate)",
828 doctype="Tax Withholding Category", accounts=accounts,
829 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
830 "single_threshold": 30000, "cumulative_threshold": 100000}]),
831 dict(name="TDS - 194D - Company",
832 category_name="Insurance Commission",
833 doctype="Tax Withholding Category", accounts=accounts,
834 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
835 "single_threshold": 15000, "cumulative_threshold": 0}]),
836 dict(name="TDS - 194D - Company Assessee",
837 category_name="Insurance Commission",
838 doctype="Tax Withholding Category", accounts=accounts,
839 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
840 "single_threshold": 15000, "cumulative_threshold": 0}]),
841 dict(name="TDS - 194D - Individual",
842 category_name="Insurance Commission",
843 doctype="Tax Withholding Category", accounts=accounts,
844 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
845 "single_threshold": 15000, "cumulative_threshold": 0}]),
846 dict(name="TDS - 194D - No PAN / Invalid PAN",
847 category_name="Insurance Commission",
848 doctype="Tax Withholding Category", accounts=accounts,
849 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
850 "single_threshold": 15000, "cumulative_threshold": 0}]),
851 dict(name="TDS - 194DA - Company",
852 category_name="Non-exempt payments made under a life insurance policy",
853 doctype="Tax Withholding Category", accounts=accounts,
854 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
855 "single_threshold": 100000, "cumulative_threshold": 0}]),
856 dict(name="TDS - 194DA - Individual",
857 category_name="Non-exempt payments made under a life insurance policy",
858 doctype="Tax Withholding Category", accounts=accounts,
859 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
860 "single_threshold": 100000, "cumulative_threshold": 0}]),
861 dict(name="TDS - 194DA - No PAN / Invalid PAN",
862 category_name="Non-exempt payments made under a life insurance policy",
863 doctype="Tax Withholding Category", accounts=accounts,
864 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
865 "single_threshold": 100000, "cumulative_threshold": 0}]),
866 dict(name="TDS - 194H - Company",
867 category_name="Commission / Brokerage",
868 doctype="Tax Withholding Category", accounts=accounts,
869 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
870 "single_threshold": 15000, "cumulative_threshold": 0}]),
871 dict(name="TDS - 194H - Individual",
872 category_name="Commission / Brokerage",
873 doctype="Tax Withholding Category", accounts=accounts,
874 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
875 "single_threshold": 15000, "cumulative_threshold": 0}]),
876 dict(name="TDS - 194H - No PAN / Invalid PAN",
877 category_name="Commission / Brokerage",
878 doctype="Tax Withholding Category", accounts=accounts,
879 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
880 "single_threshold": 15000, "cumulative_threshold": 0}]),
881 dict(name="TDS - 194I - Rent - Company",
882 category_name="Rent",
883 doctype="Tax Withholding Category", accounts=accounts,
884 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
885 "single_threshold": 180000, "cumulative_threshold": 0}]),
886 dict(name="TDS - 194I - Rent - Individual",
887 category_name="Rent",
888 doctype="Tax Withholding Category", accounts=accounts,
889 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
890 "single_threshold": 180000, "cumulative_threshold": 0}]),
891 dict(name="TDS - 194I - Rent - No PAN / Invalid PAN",
892 category_name="Rent",
893 doctype="Tax Withholding Category", accounts=accounts,
894 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
895 "single_threshold": 180000, "cumulative_threshold": 0}]),
896 dict(name="TDS - 194I - Rent/Machinery - Company",
897 category_name="Rent-Plant / Machinery",
898 doctype="Tax Withholding Category", accounts=accounts,
899 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
900 "single_threshold": 180000, "cumulative_threshold": 0}]),
901 dict(name="TDS - 194I - Rent/Machinery - Individual",
902 category_name="Rent-Plant / Machinery",
903 doctype="Tax Withholding Category", accounts=accounts,
904 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
905 "single_threshold": 180000, "cumulative_threshold": 0}]),
906 dict(name="TDS - 194I - Rent/Machinery - No PAN / Invalid PAN",
907 category_name="Rent-Plant / Machinery",
908 doctype="Tax Withholding Category", accounts=accounts,
909 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
910 "single_threshold": 180000, "cumulative_threshold": 0}]),
911 dict(name="TDS - 194J - Professional Fees - Company",
912 category_name="Professional Fees",
913 doctype="Tax Withholding Category", accounts=accounts,
914 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
915 "single_threshold": 30000, "cumulative_threshold": 0}]),
916 dict(name="TDS - 194J - Professional Fees - Individual",
917 category_name="Professional Fees",
918 doctype="Tax Withholding Category", accounts=accounts,
919 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
920 "single_threshold": 30000, "cumulative_threshold": 0}]),
921 dict(name="TDS - 194J - Professional Fees - No PAN / Invalid PAN",
922 category_name="Professional Fees",
923 doctype="Tax Withholding Category", accounts=accounts,
924 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
925 "single_threshold": 30000, "cumulative_threshold": 0}]),
926 dict(name="TDS - 194J - Director Fees - Company",
927 category_name="Director Fees",
928 doctype="Tax Withholding Category", accounts=accounts,
929 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
930 "single_threshold": 0, "cumulative_threshold": 0}]),
931 dict(name="TDS - 194J - Director Fees - Individual",
932 category_name="Director Fees",
933 doctype="Tax Withholding Category", accounts=accounts,
934 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
935 "single_threshold": 0, "cumulative_threshold": 0}]),
936 dict(name="TDS - 194J - Director Fees - No PAN / Invalid PAN",
937 category_name="Director Fees",
938 doctype="Tax Withholding Category", accounts=accounts,
939 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
940 "single_threshold": 0, "cumulative_threshold": 0}]),
941 dict(name="TDS - 194 - Dividends - Company",
942 category_name="Dividends",
943 doctype="Tax Withholding Category", accounts=accounts,
944 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
945 "single_threshold": 2500, "cumulative_threshold": 0}]),
946 dict(name="TDS - 194 - Dividends - Individual",
947 category_name="Dividends",
948 doctype="Tax Withholding Category", accounts=accounts,
949 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
950 "single_threshold": 2500, "cumulative_threshold": 0}]),
951 dict(name="TDS - 194 - Dividends - No PAN / Invalid PAN",
952 category_name="Dividends",
953 doctype="Tax Withholding Category", accounts=accounts,
954 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
955 "single_threshold": 2500, "cumulative_threshold": 0}])
Anurag Mishrae1464a72020-08-17 15:03:32 +0530956 ]
957
Anurag Mishra25c35682020-08-18 14:13:54 +0530958def create_gratuity_rule():
Anurag Mishrae1464a72020-08-17 15:03:32 +0530959 # Standard Indain Gratuity Rule
Anurag Mishra493eea12020-08-18 15:02:32 +0530960 if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
961 rule = frappe.new_doc("Gratuity Rule")
962 rule.name = "Indian Standard Gratuity Rule"
963 rule.calculate_gratuity_amount_based_on = "Current Slab"
964 rule.work_experience_calculation_method = "Round Off Work Experience"
965 rule.minimum_year_for_gratuity = 5
Anurag Mishrae1464a72020-08-17 15:03:32 +0530966
Anurag Mishra493eea12020-08-18 15:02:32 +0530967 fraction = 15/26
968 rule.append("gratuity_rule_slabs", {
969 "from_year": 0,
970 "to_year":0,
971 "fraction_of_applicable_earnings": fraction
972 })
Anurag Mishrae1464a72020-08-17 15:03:32 +0530973
Anurag Mishra493eea12020-08-18 15:02:32 +0530974 rule.flags.ignore_mandatory = True
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530975 rule.save()
Deepesh Garg204ea102021-04-30 16:35:52 +0530976
977def update_accounts_settings_for_taxes():
978 if frappe.db.count('Company') == 1:
979 frappe.db.set_value('Accounts Settings', None, "add_taxes_from_item_tax_template", 0)