blob: d79ce64fb35cbd74228b11578191f2367bc7635c [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 Garg1bac72b2021-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 Garg204ea102021-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():
32 # HSN codes
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053033 with open(os.path.join(os.path.dirname(__file__), 'hsn_code_data.json'), 'r') as f:
34 hsn_codes = json.loads(f.read())
35
Nabin Hait1a609312017-07-13 12:16:04 +053036 create_hsn_codes(hsn_codes, code_field="hsn_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053037
Nabin Hait1a609312017-07-13 12:16:04 +053038 # SAC Codes
39 with open(os.path.join(os.path.dirname(__file__), 'sac_code_data.json'), 'r') as f:
40 sac_codes = json.loads(f.read())
41 create_hsn_codes(sac_codes, code_field="sac_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053042
Nabin Hait1a609312017-07-13 12:16:04 +053043def create_hsn_codes(data, code_field):
44 for d in data:
Rushabh Mehtaf702d722017-09-27 15:31:30 +053045 hsn_code = frappe.new_doc('GST HSN Code')
46 hsn_code.description = d["description"]
47 hsn_code.hsn_code = d[code_field]
48 hsn_code.name = d[code_field]
49 try:
Nabin Hait1a609312017-07-13 12:16:04 +053050 hsn_code.db_insert()
Rushabh Mehtaf702d722017-09-27 15:31:30 +053051 except frappe.DuplicateEntryError:
52 pass
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053053
Rushabh Mehta919a74a2017-06-22 16:37:04 +053054def add_custom_roles_for_reports():
55 for report_name in ('GST Sales Register', 'GST Purchase Register',
Saqib93203162021-04-12 17:55:46 +053056 'GST Itemised Sales Register', 'GST Itemised Purchase Register', 'Eway Bill', 'E-Invoice Summary'):
Rushabh Mehta919a74a2017-06-22 16:37:04 +053057
Rushabh Mehta919a74a2017-06-22 16:37:04 +053058 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
59 frappe.get_doc(dict(
60 doctype='Custom Role',
61 report=report_name,
62 roles= [
63 dict(role='Accounts User'),
64 dict(role='Accounts Manager')
65 ]
66 )).insert()
67
Anurag Mishra289c8222020-06-19 19:17:57 +053068 for report_name in ('Professional Tax Deductions', 'Provident Fund Deductions'):
69
70 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
71 frappe.get_doc(dict(
72 doctype='Custom Role',
73 report=report_name,
74 roles= [
75 dict(role='HR User'),
76 dict(role='HR Manager'),
77 dict(role='Employee')
78 ]
79 )).insert()
80
Anurag Mishra54cd1942020-09-03 13:51:26 +053081 for report_name in ('HSN-wise-summary of outward supplies', 'GSTR-1', 'GSTR-2'):
82
83 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
84 frappe.get_doc(dict(
85 doctype='Custom Role',
86 report=report_name,
87 roles= [
88 dict(role='Accounts User'),
89 dict(role='Accounts Manager'),
90 dict(role='Auditor')
91 ]
92 )).insert()
93
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053094def add_permissions():
Saqib6d74f5b2020-12-25 10:26:43 +053095 for doctype in ('GST HSN Code', 'GST Settings', 'GSTR 3B Report', 'Lower Deduction Certificate', 'E Invoice Settings'):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053096 add_permission(doctype, 'All', 0)
Deepesh Garg6c8efde2020-04-04 20:05:17 +053097 for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
Saqib5e6ce882020-02-03 15:40:35 +053098 add_permission(doctype, role, 0)
99 update_permission_property(doctype, role, 0, 'write', 1)
100 update_permission_property(doctype, role, 0, 'create', 1)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530101
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530102 if doctype == 'GST HSN Code':
103 for role in ('Item Manager', 'Stock Manager'):
104 add_permission(doctype, role, 0)
105 update_permission_property(doctype, role, 0, 'write', 1)
106 update_permission_property(doctype, role, 0, 'create', 1)
107
Nabin Hait852cb642017-07-05 12:58:19 +0530108def add_print_formats():
109 frappe.reload_doc("regional", "print_format", "gst_tax_invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530110 frappe.reload_doc("accounts", "print_format", "gst_pos_invoice")
Saqib6d74f5b2020-12-25 10:26:43 +0530111 frappe.reload_doc("accounts", "print_format", "GST E-Invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530112
barredterra1521b312021-03-03 12:33:48 +0100113 frappe.db.set_value("Print Format", "GST POS Invoice", "disabled", 0)
114 frappe.db.set_value("Print Format", "GST Tax Invoice", "disabled", 0)
115 frappe.db.set_value("Print Format", "GST E-Invoice", "disabled", 0)
Nabin Hait852cb642017-07-05 12:58:19 +0530116
Nabin Hait10c61372021-04-13 15:46:01 +0530117def make_property_setters(patch=False):
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530118 # GST rules do not allow for an invoice no. bigger than 16 characters
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530119 journal_entry_types = frappe.get_meta("Journal Entry").get_options("voucher_type").split("\n") + ['Reversal Of ITC']
120
Nabin Hait10c61372021-04-13 15:46:01 +0530121 if not patch:
122 make_property_setter('Sales Invoice', 'naming_series', 'options', 'SINV-.YY.-\nSRET-.YY.-', '')
123 make_property_setter('Purchase Invoice', 'naming_series', 'options', 'PINV-.YY.-\nPRET-.YY.-', '')
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530124 make_property_setter('Journal Entry', 'voucher_type', 'options', '\n'.join(journal_entry_types), '')
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530125
Rushabh Mehta69fa8082018-07-17 18:22:51 +0530126def make_custom_fields(update=True):
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530127 hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
Nabin Haitd34bfa82018-11-13 18:19:58 +0530128 fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description',
Nabin Haitf4af6082019-04-01 11:51:54 +0530129 allow_on_submit=1, print_hide=1, fetch_if_empty=1)
Marica9942acd2020-04-21 13:13:39 +0530130 nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530131 fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code',
132 print_hide=1)
133 is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST',
134 fieldtype='Check', fetch_from='item_code.is_non_gst', insert_after='is_nil_exempt',
135 print_hide=1)
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530136 taxable_value = dict(fieldname='taxable_value', label='Taxable Value',
137 fieldtype='Currency', insert_after='base_net_amount', hidden=1, options="Company:company:default_currency",
138 print_hide=1)
Deepesh Garg22b61602019-03-21 20:47:47 +0530139
140 purchase_invoice_gst_category = [
Nabin Hait879e1622017-08-21 08:28:55 +0530141 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
vishdha109b4082018-01-30 12:11:13 +0530142 insert_after='language', print_hide=1, collapsible=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530143 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530144 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530145 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530146 fetch_from='supplier.gst_category', fetch_if_empty=1),
147 dict(fieldname='export_type', label='Export Type',
148 fieldtype='Select', insert_after='gst_category', print_hide=1,
149 depends_on='eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
150 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='supplier.export_type',
151 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530152 ]
153
154 sales_invoice_gst_category = [
155 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
156 insert_after='language', print_hide=1, collapsible=1),
157 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530158 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530159 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530160 fetch_from='customer.gst_category', fetch_if_empty=1),
161 dict(fieldname='export_type', label='Export Type',
162 fieldtype='Select', insert_after='gst_category', print_hide=1,
163 depends_on='eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
164 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='customer.export_type',
165 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530166 ]
167
Deepesh Garg29997412021-03-29 19:49:52 +0530168 delivery_note_gst_category = [
169 dict(fieldname='gst_category', label='GST Category',
170 fieldtype='Select', insert_after='gst_vehicle_type', print_hide=1,
171 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
172 fetch_from='customer.gst_category', fetch_if_empty=1),
173 ]
174
Deepesh Garg22b61602019-03-21 20:47:47 +0530175 invoice_gst_fields = [
Nabin Hait879e1622017-08-21 08:28:55 +0530176 dict(fieldname='invoice_copy', label='Invoice Copy',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530177 fieldtype='Select', insert_after='export_type', print_hide=1, allow_on_submit=1,
Nabin Hait879e1622017-08-21 08:28:55 +0530178 options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'),
179 dict(fieldname='reverse_charge', label='Reverse Charge',
180 fieldtype='Select', insert_after='invoice_copy', print_hide=1,
181 options='Y\nN', default='N'),
Nabin Hait879e1622017-08-21 08:28:55 +0530182 dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN',
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530183 fieldtype='Data', insert_after='export_type', print_hide=1),
Nabin Haite6d65bc2018-02-14 17:44:06 +0530184 dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='ecommerce_gstin'),
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530185 dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document',
Nabin Haitb02c1092018-02-05 16:09:51 +0530186 fieldtype='Select', insert_after='gst_col_break', print_hide=1,
Nabin Haite6d65bc2018-02-14 17:44:06 +0530187 depends_on='eval:doc.is_return==1',
Nabin Haita8d10b72018-02-12 16:54:13 +0530188 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 +0530189 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530190
Nabin Hait879e1622017-08-21 08:28:55 +0530191 purchase_invoice_gst_fields = [
192 dict(fieldname='supplier_gstin', label='Supplier GSTIN',
193 fieldtype='Data', insert_after='supplier_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530194 fetch_from='supplier_address.gstin', print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530195 dict(fieldname='company_gstin', label='Company GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530196 fieldtype='Data', insert_after='shipping_address_display',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530197 fetch_from='shipping_address.gstin', print_hide=1, read_only=1),
Nabin Haitb02c1092018-02-05 16:09:51 +0530198 dict(fieldname='place_of_supply', label='Place of Supply',
199 fieldtype='Data', insert_after='shipping_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530200 print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530201 ]
202
203 purchase_invoice_itc_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530204 dict(fieldname='eligibility_for_itc', label='Eligibility For ITC',
205 fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530206 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',
207 default="All Other ITC"),
vishdha98e33c32018-01-29 13:57:34 +0530208 dict(fieldname='itc_integrated_tax', label='Availed ITC Integrated Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530209 fieldtype='Currency', insert_after='eligibility_for_itc',
210 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530211 dict(fieldname='itc_central_tax', label='Availed ITC Central Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530212 fieldtype='Currency', insert_after='itc_integrated_tax',
213 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530214 dict(fieldname='itc_state_tax', label='Availed ITC State/UT Tax',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530215 fieldtype='Currency', insert_after='itc_central_tax',
216 options='Company:company:default_currency', print_hide=1),
vishdha98e33c32018-01-29 13:57:34 +0530217 dict(fieldname='itc_cess_amount', label='Availed ITC Cess',
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530218 fieldtype='Currency', insert_after='itc_state_tax',
219 options='Company:company:default_currency', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530220 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530221
Nabin Hait879e1622017-08-21 08:28:55 +0530222 sales_invoice_gst_fields = [
rohitwaghchaure16645802017-09-28 11:05:03 +0530223 dict(fieldname='billing_address_gstin', label='Billing Address GSTIN',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530224 fieldtype='Data', insert_after='customer_address', read_only=1,
Shreya Shah4fa600a2018-06-05 11:27:53 +0530225 fetch_from='customer_address.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530226 dict(fieldname='customer_gstin', label='Customer GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530227 fieldtype='Data', insert_after='shipping_address_name',
228 fetch_from='shipping_address_name.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530229 dict(fieldname='place_of_supply', label='Place of Supply',
Nabin Hait619c42b2018-01-10 17:48:03 +0530230 fieldtype='Data', insert_after='customer_gstin',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530231 print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530232 dict(fieldname='company_gstin', label='Company GSTIN',
233 fieldtype='Data', insert_after='company_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530234 fetch_from='company_address.gstin', print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530235 ]
236
237 sales_invoice_shipping_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530238 dict(fieldname='port_code', label='Port Code',
239 fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530240 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530241 dict(fieldname='shipping_bill_number', label=' Shipping Bill Number',
242 fieldtype='Data', insert_after='port_code', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530243 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530244 dict(fieldname='shipping_bill_date', label='Shipping Bill Date',
245 fieldtype='Date', insert_after='shipping_bill_number', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530246 depends_on="eval:doc.gst_category=='Overseas' "),
Nabin Hait879e1622017-08-21 08:28:55 +0530247 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530248
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530249 journal_entry_fields = [
250 dict(fieldname='reversal_type', label='Reversal Type',
251 fieldtype='Select', insert_after='voucher_type', print_hide=1,
252 options="As per rules 42 & 43 of CGST Rules\nOthers",
253 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
254 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
255 dict(fieldname='company_address', label='Company Address',
256 fieldtype='Link', options='Address', insert_after='reversal_type',
257 print_hide=1, depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
258 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'"),
259 dict(fieldname='company_gstin', label='Company GSTIN',
260 fieldtype='Data', read_only=1, insert_after='company_address', print_hide=1,
261 fetch_from='company_address.gstin',
262 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
263 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'")
264 ]
265
Shreya Shah4fa600a2018-06-05 11:27:53 +0530266 inter_state_gst_field = [
267 dict(fieldname='is_inter_state', label='Is Inter State',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530268 fieldtype='Check', insert_after='disabled', print_hide=1),
269 dict(fieldname='tax_category_column_break', fieldtype='Column Break',
270 insert_after='is_inter_state'),
271 dict(fieldname='gst_state', label='Source State', fieldtype='Select',
272 options='\n'.join(states), insert_after='company')
Shreya Shah4fa600a2018-06-05 11:27:53 +0530273 ]
274
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530275 ewaybill_fields = [
276 {
277 'fieldname': 'distance',
278 'label': 'Distance (in km)',
279 'fieldtype': 'Float',
280 'insert_after': 'vehicle_no',
281 'print_hide': 1
282 },
283 {
284 'fieldname': 'gst_transporter_id',
285 'label': 'GST Transporter ID',
286 'fieldtype': 'Data',
Nabin Hait34c551d2019-07-03 10:34:31 +0530287 'insert_after': 'transporter',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530288 'fetch_from': 'transporter.gst_transporter_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530289 'print_hide': 1,
290 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530291 },
292 {
293 'fieldname': 'mode_of_transport',
294 'label': 'Mode of Transport',
295 'fieldtype': 'Select',
296 'options': '\nRoad\nAir\nRail\nShip',
297 'default': 'Road',
Nabin Hait34c551d2019-07-03 10:34:31 +0530298 'insert_after': 'transporter_name',
299 'print_hide': 1,
300 'translatable': 0
301 },
302 {
303 'fieldname': 'gst_vehicle_type',
304 'label': 'GST Vehicle Type',
305 'fieldtype': 'Select',
306 'options': 'Regular\nOver Dimensional Cargo (ODC)',
307 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
308 'default': 'Regular',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530309 'insert_after': 'lr_date',
Nabin Hait34c551d2019-07-03 10:34:31 +0530310 'print_hide': 1,
311 'translatable': 0
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530312 },
313 {
314 'fieldname': 'ewaybill',
315 'label': 'E-Way Bill No.',
316 'fieldtype': 'Data',
317 'depends_on': 'eval:(doc.docstatus === 1)',
318 'allow_on_submit': 1,
319 'insert_after': 'customer_name_in_arabic',
320 'translatable': 0,
Deepesh Garg29997412021-03-29 19:49:52 +0530321 }
Nabin Hait34c551d2019-07-03 10:34:31 +0530322 ]
323
324 si_ewaybill_fields = [
325 {
326 'fieldname': 'transporter_info',
327 'label': 'Transporter Info',
328 'fieldtype': 'Section Break',
329 'insert_after': 'terms',
330 'collapsible': 1,
331 'collapsible_depends_on': 'transporter',
332 'print_hide': 1
333 },
334 {
335 'fieldname': 'transporter',
336 'label': 'Transporter',
337 'fieldtype': 'Link',
338 'insert_after': 'transporter_info',
339 'options': 'Supplier',
340 'print_hide': 1
341 },
342 {
343 'fieldname': 'gst_transporter_id',
344 'label': 'GST Transporter ID',
345 'fieldtype': 'Data',
346 'insert_after': 'transporter',
347 'fetch_from': 'transporter.gst_transporter_id',
348 'print_hide': 1,
349 'translatable': 0
350 },
351 {
352 'fieldname': 'driver',
353 'label': 'Driver',
354 'fieldtype': 'Link',
355 'insert_after': 'gst_transporter_id',
356 'options': 'Driver',
357 'print_hide': 1
358 },
359 {
360 'fieldname': 'lr_no',
361 'label': 'Transport Receipt No',
362 'fieldtype': 'Data',
363 'insert_after': 'driver',
364 'print_hide': 1,
365 'translatable': 0
366 },
367 {
368 'fieldname': 'vehicle_no',
369 'label': 'Vehicle No',
370 'fieldtype': 'Data',
371 'insert_after': 'lr_no',
372 'print_hide': 1,
373 'translatable': 0
374 },
375 {
376 'fieldname': 'distance',
377 'label': 'Distance (in km)',
378 'fieldtype': 'Float',
379 'insert_after': 'vehicle_no',
380 'print_hide': 1
381 },
382 {
383 'fieldname': 'transporter_col_break',
384 'fieldtype': 'Column Break',
385 'insert_after': 'distance'
386 },
387 {
388 'fieldname': 'transporter_name',
389 'label': 'Transporter Name',
390 'fieldtype': 'Data',
391 'insert_after': 'transporter_col_break',
392 'fetch_from': 'transporter.name',
393 'read_only': 1,
394 'print_hide': 1,
395 'translatable': 0
396 },
397 {
398 'fieldname': 'mode_of_transport',
399 'label': 'Mode of Transport',
400 'fieldtype': 'Select',
401 'options': '\nRoad\nAir\nRail\nShip',
Nabin Hait34c551d2019-07-03 10:34:31 +0530402 'insert_after': 'transporter_name',
403 'print_hide': 1,
404 'translatable': 0
405 },
406 {
407 'fieldname': 'driver_name',
408 'label': 'Driver Name',
409 'fieldtype': 'Data',
410 'insert_after': 'mode_of_transport',
411 'fetch_from': 'driver.full_name',
412 'print_hide': 1,
413 'translatable': 0
414 },
415 {
416 'fieldname': 'lr_date',
417 'label': 'Transport Receipt Date',
418 'fieldtype': 'Date',
419 'insert_after': 'driver_name',
420 'default': 'Today',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530421 'print_hide': 1
422 },
423 {
424 'fieldname': 'gst_vehicle_type',
425 'label': 'GST Vehicle Type',
426 'fieldtype': 'Select',
Nabin Hait34c551d2019-07-03 10:34:31 +0530427 'options': 'Regular\nOver Dimensional Cargo (ODC)',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530428 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
Nabin Hait34c551d2019-07-03 10:34:31 +0530429 'default': 'Regular',
430 'insert_after': 'lr_date',
431 'print_hide': 1,
432 'translatable': 0
433 },
434 {
435 'fieldname': 'ewaybill',
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530436 'label': 'E-Way Bill No.',
Nabin Hait34c551d2019-07-03 10:34:31 +0530437 'fieldtype': 'Data',
Saqib6d74f5b2020-12-25 10:26:43 +0530438 'depends_on': 'eval:((doc.docstatus === 1 || doc.ewaybill) && doc.eway_bill_cancelled === 0)',
Nabin Hait34c551d2019-07-03 10:34:31 +0530439 'allow_on_submit': 1,
deepeshgarg007a85db662019-07-14 18:15:19 +0530440 'insert_after': 'tax_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530441 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530442 }
443 ]
444
Saqib6d74f5b2020-12-25 10:26:43 +0530445 si_einvoice_fields = [
446 dict(fieldname='irn', label='IRN', fieldtype='Data', read_only=1, insert_after='customer', no_copy=1, print_hide=1,
447 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 +0530448
Saqib6d74f5b2020-12-25 10:26:43 +0530449 dict(fieldname='irn_cancelled', label='IRN Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
450 depends_on='eval:(doc.irn_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
451
Saqibd502f762021-05-06 16:10:55 +0530452 dict(fieldname='eway_bill_validity', label='E-Way Bill Validity', fieldtype='Data', no_copy=1, print_hide=1,
453 depends_on='ewaybill', read_only=1, allow_on_submit=1, insert_after='ewaybill'),
454
Saqib6d74f5b2020-12-25 10:26:43 +0530455 dict(fieldname='eway_bill_cancelled', label='E-Way Bill Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
456 depends_on='eval:(doc.eway_bill_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
457
Saqib93203162021-04-12 17:55:46 +0530458 dict(fieldname='einvoice_section', label='E-Invoice Fields', fieldtype='Section Break', insert_after='gst_vehicle_type',
459 print_hide=1, hidden=1),
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530460
Saqib93203162021-04-12 17:55:46 +0530461 dict(fieldname='ack_no', label='Ack. No.', fieldtype='Data', read_only=1, hidden=1, insert_after='einvoice_section',
462 no_copy=1, print_hide=1),
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530463
Saqib93203162021-04-12 17:55:46 +0530464 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 +0530465
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530466 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 +0530467 no_copy=1, print_hide=1),
Saqib6d74f5b2020-12-25 10:26:43 +0530468
Saqib93203162021-04-12 17:55:46 +0530469 dict(fieldname='signed_einvoice', label='Signed E-Invoice', fieldtype='Code', options='JSON', hidden=1, insert_after='irn_cancel_date',
470 no_copy=1, print_hide=1, read_only=1),
471
472 dict(fieldname='signed_qr_code', label='Signed QRCode', fieldtype='Code', options='JSON', hidden=1, insert_after='signed_einvoice',
473 no_copy=1, print_hide=1, read_only=1),
474
475 dict(fieldname='qrcode_image', label='QRCode', fieldtype='Attach Image', hidden=1, insert_after='signed_qr_code',
476 no_copy=1, print_hide=1, read_only=1),
477
478 dict(fieldname='einvoice_status', label='E-Invoice Status', fieldtype='Select', insert_after='qrcode_image',
479 options='\nPending\nGenerated\nCancelled\nFailed', default=None, hidden=1, no_copy=1, print_hide=1, read_only=1),
480
481 dict(fieldname='failure_description', label='E-Invoice Failure Description', fieldtype='Code', options='JSON',
482 hidden=1, insert_after='einvoice_status', no_copy=1, print_hide=1, read_only=1)
Saqib6d74f5b2020-12-25 10:26:43 +0530483 ]
484
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530485 custom_fields = {
486 'Address': [
Rushabh Mehta919a74a2017-06-22 16:37:04 +0530487 dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data',
488 insert_after='fax'),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530489 dict(fieldname='gst_state', label='GST State', fieldtype='Select',
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530490 options='\n'.join(states), insert_after='gstin'),
491 dict(fieldname='gst_state_number', label='GST State Number',
Nabin Hait562d9422018-09-07 16:14:44 +0530492 fieldtype='Data', insert_after='gst_state', read_only=1),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530493 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530494 'Purchase Invoice': purchase_invoice_gst_category + invoice_gst_fields + purchase_invoice_itc_fields + purchase_invoice_gst_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530495 'Purchase Order': purchase_invoice_gst_fields,
496 'Purchase Receipt': purchase_invoice_gst_fields,
Saqib6d74f5b2020-12-25 10:26:43 +0530497 '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 +0530498 'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields + delivery_note_gst_category,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530499 'Journal Entry': journal_entry_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530500 'Sales Order': sales_invoice_gst_fields,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530501 'Tax Category': inter_state_gst_field,
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530502 'Item': [
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530503 dict(fieldname='gst_hsn_code', label='HSN/SAC',
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530504 fieldtype='Link', options='GST HSN Code', insert_after='item_group'),
Marica9942acd2020-04-21 13:13:39 +0530505 dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530506 fieldtype='Check', insert_after='gst_hsn_code'),
507 dict(fieldname='is_non_gst', label='Is Non GST ',
508 fieldtype='Check', insert_after='is_nil_exempt')
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530509 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530510 'Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
511 'Supplier Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
512 'Sales Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
513 'Delivery Note Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Gargc36e48a2021-04-12 10:55:43 +0530514 'Sales Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Deepesh Garg22b61602019-03-21 20:47:47 +0530515 'Purchase Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
516 'Purchase Receipt Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530517 'Purchase Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
Himanshu Warekar656d8e42019-04-01 19:38:43 +0530518 'Material Request Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Anurag Mishra289c8222020-06-19 19:17:57 +0530519 'Salary Component': [
520 dict(fieldname= 'component_type',
521 label= 'Component Type',
522 fieldtype= 'Select',
523 insert_after= 'description',
524 options= "\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax",
525 depends_on = 'eval:doc.type == "Deduction"'
526 )
527 ],
Pawan Mehtaf4196352018-04-05 14:54:51 +0530528 'Employee': [
Anurag Mishra289c8222020-06-19 19:17:57 +0530529 dict(fieldname='ifsc_code',
530 label='IFSC Code',
531 fieldtype='Data',
532 insert_after='bank_ac_no',
533 print_hide=1,
534 depends_on='eval:doc.salary_mode == "Bank"'
535 ),
536 dict(
537 fieldname = 'pan_number',
538 label = 'PAN Number',
539 fieldtype = 'Data',
540 insert_after = 'payroll_cost_center',
541 print_hide = 1
542 ),
543 dict(
544 fieldname = 'micr_code',
545 label = 'MICR Code',
546 fieldtype = 'Data',
547 insert_after = 'ifsc_code',
548 print_hide = 1,
549 depends_on='eval:doc.salary_mode == "Bank"'
550 ),
551 dict(
552 fieldname = 'provident_fund_account',
553 label = 'Provident Fund Account',
554 fieldtype = 'Data',
555 insert_after = 'pan_number'
556 )
557
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530558 ],
559 'Company': [
560 dict(fieldname='hra_section', label='HRA Settings',
Anurag Mishraa5527222019-06-14 15:25:57 +0530561 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530562 dict(fieldname='basic_component', label='Basic Component',
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530563 fieldtype='Link', options='Salary Component', insert_after='hra_section'),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530564 dict(fieldname='hra_component', label='HRA Component',
565 fieldtype='Link', options='Salary Component', insert_after='basic_component'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530566 dict(fieldname='arrear_component', label='Arrear Component',
Mangesh-Khairnar9215de02019-05-06 16:24:10 +0530567 fieldtype='Link', options='Salary Component', insert_after='hra_component'),
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530568 dict(fieldname='non_profit_section', label='Non Profit Settings',
569 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
570 dict(fieldname='company_80g_number', label='80G Number',
571 fieldtype='Data', insert_after='non_profit_section'),
572 dict(fieldname='with_effect_from', label='80G With Effect From',
573 fieldtype='Date', insert_after='company_80g_number'),
574 dict(fieldname='pan_details', label='PAN Number',
575 fieldtype='Data', insert_after='with_effect_from')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530576 ],
577 'Employee Tax Exemption Declaration':[
578 dict(fieldname='hra_section', label='HRA Exemption',
579 fieldtype='Section Break', insert_after='declarations'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530580 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530581 fieldtype='Currency', insert_after='hra_section'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530582 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530583 fieldtype='Check', insert_after='monthly_house_rent', depends_on='monthly_house_rent'),
584 dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure',
585 fieldtype='Currency', insert_after='rented_in_metro_city', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530586 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530587 insert_after='salary_structure_hra', depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530588 dict(fieldname='annual_hra_exemption', label='Annual HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530589 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530590 dict(fieldname='monthly_hra_exemption', label='Monthly HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530591 fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1, depends_on='monthly_house_rent')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530592 ],
593 'Employee Tax Exemption Proof Submission': [
594 dict(fieldname='hra_section', label='HRA Exemption',
595 fieldtype='Section Break', insert_after='tax_exemption_proofs'),
596 dict(fieldname='house_rent_payment_amount', label='House Rent Payment Amount',
597 fieldtype='Currency', insert_after='hra_section'),
598 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530599 fieldtype='Check', insert_after='house_rent_payment_amount', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530600 dict(fieldname='rented_from_date', label='Rented From Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530601 fieldtype='Date', insert_after='rented_in_metro_city', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530602 dict(fieldname='rented_to_date', label='Rented To Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530603 fieldtype='Date', insert_after='rented_from_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530604 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530605 insert_after='rented_to_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530606 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530607 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530608 dict(fieldname='monthly_hra_exemption', label='Monthly Eligible Amount',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530609 fieldtype='Currency', insert_after='monthly_house_rent', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530610 dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530611 fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1, depends_on='house_rent_payment_amount')
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530612 ],
613 'Supplier': [
614 {
615 'fieldname': 'gst_transporter_id',
616 'label': 'GST Transporter ID',
617 'fieldtype': 'Data',
618 'insert_after': 'supplier_type',
619 'depends_on': 'eval:doc.is_transporter'
Deepesh Garg22b61602019-03-21 20:47:47 +0530620 },
621 {
622 'fieldname': 'gst_category',
623 'label': 'GST Category',
624 'fieldtype': 'Select',
625 'insert_after': 'gst_transporter_id',
626 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
627 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530628 },
629 {
630 'fieldname': 'export_type',
631 'label': 'Export Type',
632 'fieldtype': 'Select',
633 'insert_after': 'gst_category',
634 'default': 'Without Payment of Tax',
635 'depends_on':'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
636 'options': '\nWith Payment of Tax\nWithout Payment of Tax'
Deepesh Garg22b61602019-03-21 20:47:47 +0530637 }
638 ],
639 'Customer': [
640 {
641 'fieldname': 'gst_category',
642 'label': 'GST Category',
643 'fieldtype': 'Select',
644 'insert_after': 'customer_type',
645 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
646 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530647 },
648 {
649 'fieldname': 'export_type',
650 'label': 'Export Type',
651 'fieldtype': 'Select',
652 'insert_after': 'gst_category',
653 'default': 'Without Payment of Tax',
654 'depends_on':'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
655 'options': '\nWith Payment of Tax\nWithout Payment of Tax'
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530656 }
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530657 ],
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530658 'Member': [
659 {
660 'fieldname': 'pan_number',
661 'label': 'PAN Details',
662 'fieldtype': 'Data',
663 'insert_after': 'email_id'
664 }
665 ],
666 'Donor': [
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530667 {
668 'fieldname': 'pan_number',
669 'label': 'PAN Details',
670 'fieldtype': 'Data',
671 'insert_after': 'email'
672 }
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530673 ]
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530674 }
Deepesh Garg22b61602019-03-21 20:47:47 +0530675 create_custom_fields(custom_fields, update=update)
Nabin Hait9c421612017-07-20 13:32:01 +0530676
Saurabh2d8a7ee2018-05-11 13:16:16 +0530677def make_fixtures(company=None):
678 docs = []
Deepesh Garga66184f2021-05-02 12:22:16 +0530679 company = company or frappe.db.get_value("Global Defaults", None, "default_company")
Saurabh2d8a7ee2018-05-11 13:16:16 +0530680
681 set_salary_components(docs)
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530682 set_tds_account(docs, company)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530683
684 for d in docs:
685 try:
686 doc = frappe.get_doc(d)
687 doc.flags.ignore_permissions = True
688 doc.insert()
689 except frappe.NameError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530690 frappe.clear_messages()
Zarrar7f8024c2018-08-01 17:45:05 +0530691 except frappe.DuplicateEntryError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530692 frappe.clear_messages()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530693
Zarrar7f8024c2018-08-01 17:45:05 +0530694 # create records for Tax Withholding Category
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530695 set_tax_withholding_category(company)
696
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530697def setup_gst_settings(company):
698 # Will only add default GST accounts if present
699 input_account_names = ['Input Tax CGST', 'Input Tax SGST', 'Input Tax IGST']
700 output_account_names = ['Output Tax CGST', 'Output Tax SGST', 'Output Tax IGST']
Deepesh Garg48b1a822021-05-29 23:54:51 +0530701 rcm_accounts = ['Input Tax CGST RCM', 'Input Tax SGST RCM', 'Input Tax IGST RCM']
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530702 gst_settings = frappe.get_single('GST Settings')
703 existing_account_list = []
704
705 for account in gst_settings.get('gst_accounts'):
706 for key in ['cgst_account', 'sgst_account', 'igst_account']:
707 existing_account_list.append(account.get(key))
708
709 gst_accounts = frappe._dict(frappe.get_all("Account",
Deepesh Garg48b1a822021-05-29 23:54:51 +0530710 {'company': company, 'account_name': ('in', input_account_names +
711 output_account_names + rcm_accounts)}, ['account_name', 'name'], as_list=1))
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530712
Deepesh Garg48b1a822021-05-29 23:54:51 +0530713 add_accounts_in_gst_settings(company, input_account_names, gst_accounts,
714 existing_account_list, gst_settings)
715 add_accounts_in_gst_settings(company, output_account_names, gst_accounts,
716 existing_account_list, gst_settings)
717 add_accounts_in_gst_settings(company, rcm_accounts, gst_accounts,
718 existing_account_list, gst_settings, is_reverse_charge=1)
Deepesh Garg1bac72b2021-05-02 22:29:48 +0530719
720 gst_settings.save()
721
Deepesh Garg48b1a822021-05-29 23:54:51 +0530722def add_accounts_in_gst_settings(company, account_names, gst_accounts,
723 existing_account_list, gst_settings, is_reverse_charge=0):
724 accounts_not_added = 1
725
726 for account in account_names:
727 # Default Account Added does not exists
728 if not gst_accounts.get(account):
729 accounts_not_added = 0
730
731 # Check if already added in GST Settings
732 if gst_accounts.get(account) in existing_account_list:
733 accounts_not_added = 0
734
735 if accounts_not_added:
736 gst_settings.append('gst_accounts', {
737 'company': company,
738 'cgst_account': gst_accounts.get(account_names[0]),
739 'sgst_account': gst_accounts.get(account_names[1]),
740 'igst_account': gst_accounts.get(account_names[2]),
741 'is_reverse_charge_account': is_reverse_charge
742 })
743
Saurabh2d8a7ee2018-05-11 13:16:16 +0530744def set_salary_components(docs):
745 docs.extend([
Nabin Hait58ee6c12020-04-26 17:45:57 +0530746 {'doctype': 'Salary Component', 'salary_component': 'Professional Tax',
747 'description': 'Professional Tax', 'type': 'Deduction', 'exempted_from_income_tax': 1},
748 {'doctype': 'Salary Component', 'salary_component': 'Provident Fund',
749 'description': 'Provident fund', 'type': 'Deduction', 'is_tax_applicable': 1},
750 {'doctype': 'Salary Component', 'salary_component': 'House Rent Allowance',
751 'description': 'House Rent Allowance', 'type': 'Earning', 'is_tax_applicable': 1},
752 {'doctype': 'Salary Component', 'salary_component': 'Basic',
753 'description': 'Basic', 'type': 'Earning', 'is_tax_applicable': 1},
754 {'doctype': 'Salary Component', 'salary_component': 'Arrear',
755 'description': 'Arrear', 'type': 'Earning', 'is_tax_applicable': 1},
756 {'doctype': 'Salary Component', 'salary_component': 'Leave Encashment',
757 'description': 'Leave Encashment', 'type': 'Earning', 'is_tax_applicable': 1}
Saurabh2d8a7ee2018-05-11 13:16:16 +0530758 ])
759
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530760def set_tax_withholding_category(company):
Saurabh2d8a7ee2018-05-11 13:16:16 +0530761 accounts = []
Anuja Pawar4569e522021-01-14 19:24:30 +0530762 fiscal_year = None
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530763 abbr = frappe.get_value("Company", company, "abbr")
764 tds_account = frappe.get_value("Account", 'TDS Payable - {0}'.format(abbr), 'name')
Saurabh2d8a7ee2018-05-11 13:16:16 +0530765
766 if company and tds_account:
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530767 accounts = [dict(company=company, account=tds_account)]
Saurabh2d8a7ee2018-05-11 13:16:16 +0530768
Anuja Pawar4569e522021-01-14 19:24:30 +0530769 try:
770 fiscal_year = get_fiscal_year(today(), verbose=0, company=company)[0]
771 except FiscalYearError:
772 pass
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530773
Anuja Pawar4569e522021-01-14 19:24:30 +0530774 docs = get_tds_details(accounts, fiscal_year)
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530775
Zarrar7f8024c2018-08-01 17:45:05 +0530776 for d in docs:
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530777 if not frappe.db.exists("Tax Withholding Category", d.get("name")):
Zarrar7f8024c2018-08-01 17:45:05 +0530778 doc = frappe.get_doc(d)
Deepesh Garg204ea102021-04-30 16:35:52 +0530779 doc.flags.ignore_validate = True
Zarrar7f8024c2018-08-01 17:45:05 +0530780 doc.flags.ignore_permissions = True
Nabin Haitafef9c12019-02-12 11:28:20 +0530781 doc.flags.ignore_mandatory = True
Zarrar7f8024c2018-08-01 17:45:05 +0530782 doc.insert()
Deepesh Garg66a71bd2021-04-21 20:42:20 +0530783 else:
Zarrar7f8024c2018-08-01 17:45:05 +0530784 doc = frappe.get_doc("Tax Withholding Category", d.get("name"))
Zarrar963d62b2019-03-23 10:30:12 +0530785
786 if accounts:
787 doc.append("accounts", accounts[0])
Zarrar7f8024c2018-08-01 17:45:05 +0530788
Anuja Pawar4569e522021-01-14 19:24:30 +0530789 if fiscal_year:
790 # if fiscal year don't match with any of the already entered data, append rate row
791 fy_exist = [k for k in doc.get('rates') if k.get('fiscal_year')==fiscal_year]
792 if not fy_exist:
793 doc.append("rates", d.get('rates')[0])
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +0530794
Anuja Pawar4569e522021-01-14 19:24:30 +0530795 doc.flags.ignore_permissions = True
Deepesh Garg48b1a822021-05-29 23:54:51 +0530796 doc.flags.ignore_validate = True
Anuja Pawar4569e522021-01-14 19:24:30 +0530797 doc.flags.ignore_mandatory = True
Deepesh Garg204ea102021-04-30 16:35:52 +0530798 doc.flags.ignore_links = True
Zarrar7f8024c2018-08-01 17:45:05 +0530799 doc.save()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530800
801def set_tds_account(docs, company):
Nabin Haitf77cd542018-11-20 16:46:25 +0530802 parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
803 if parent_account:
804 docs.extend([
805 {
806 "doctype": "Account",
807 "account_name": "TDS Payable",
808 "account_type": "Tax",
809 "parent_account": parent_account,
810 "company": company
811 }
812 ])
Zarrar7f8024c2018-08-01 17:45:05 +0530813
814def get_tds_details(accounts, fiscal_year):
815 # bootstrap default tax withholding sections
816 return [
817 dict(name="TDS - 194C - Company",
818 category_name="Payment to Contractors (Single / Aggregate)",
819 doctype="Tax Withholding Category", accounts=accounts,
820 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
821 "single_threshold": 30000, "cumulative_threshold": 100000}]),
822 dict(name="TDS - 194C - Individual",
823 category_name="Payment to Contractors (Single / Aggregate)",
824 doctype="Tax Withholding Category", accounts=accounts,
825 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
826 "single_threshold": 30000, "cumulative_threshold": 100000}]),
827 dict(name="TDS - 194C - No PAN / Invalid PAN",
828 category_name="Payment to Contractors (Single / Aggregate)",
829 doctype="Tax Withholding Category", accounts=accounts,
830 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
831 "single_threshold": 30000, "cumulative_threshold": 100000}]),
832 dict(name="TDS - 194D - Company",
833 category_name="Insurance Commission",
834 doctype="Tax Withholding Category", accounts=accounts,
835 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
836 "single_threshold": 15000, "cumulative_threshold": 0}]),
837 dict(name="TDS - 194D - Company Assessee",
838 category_name="Insurance Commission",
839 doctype="Tax Withholding Category", accounts=accounts,
840 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
841 "single_threshold": 15000, "cumulative_threshold": 0}]),
842 dict(name="TDS - 194D - Individual",
843 category_name="Insurance Commission",
844 doctype="Tax Withholding Category", accounts=accounts,
845 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
846 "single_threshold": 15000, "cumulative_threshold": 0}]),
847 dict(name="TDS - 194D - No PAN / Invalid PAN",
848 category_name="Insurance Commission",
849 doctype="Tax Withholding Category", accounts=accounts,
850 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
851 "single_threshold": 15000, "cumulative_threshold": 0}]),
852 dict(name="TDS - 194DA - Company",
853 category_name="Non-exempt payments made under a life insurance policy",
854 doctype="Tax Withholding Category", accounts=accounts,
855 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
856 "single_threshold": 100000, "cumulative_threshold": 0}]),
857 dict(name="TDS - 194DA - Individual",
858 category_name="Non-exempt payments made under a life insurance policy",
859 doctype="Tax Withholding Category", accounts=accounts,
860 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
861 "single_threshold": 100000, "cumulative_threshold": 0}]),
862 dict(name="TDS - 194DA - No PAN / Invalid PAN",
863 category_name="Non-exempt payments made under a life insurance policy",
864 doctype="Tax Withholding Category", accounts=accounts,
865 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
866 "single_threshold": 100000, "cumulative_threshold": 0}]),
867 dict(name="TDS - 194H - Company",
868 category_name="Commission / Brokerage",
869 doctype="Tax Withholding Category", accounts=accounts,
870 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
871 "single_threshold": 15000, "cumulative_threshold": 0}]),
872 dict(name="TDS - 194H - Individual",
873 category_name="Commission / Brokerage",
874 doctype="Tax Withholding Category", accounts=accounts,
875 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
876 "single_threshold": 15000, "cumulative_threshold": 0}]),
877 dict(name="TDS - 194H - No PAN / Invalid PAN",
878 category_name="Commission / Brokerage",
879 doctype="Tax Withholding Category", accounts=accounts,
880 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
881 "single_threshold": 15000, "cumulative_threshold": 0}]),
882 dict(name="TDS - 194I - Rent - Company",
883 category_name="Rent",
884 doctype="Tax Withholding Category", accounts=accounts,
885 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
886 "single_threshold": 180000, "cumulative_threshold": 0}]),
887 dict(name="TDS - 194I - Rent - Individual",
888 category_name="Rent",
889 doctype="Tax Withholding Category", accounts=accounts,
890 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
891 "single_threshold": 180000, "cumulative_threshold": 0}]),
892 dict(name="TDS - 194I - Rent - No PAN / Invalid PAN",
893 category_name="Rent",
894 doctype="Tax Withholding Category", accounts=accounts,
895 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
896 "single_threshold": 180000, "cumulative_threshold": 0}]),
897 dict(name="TDS - 194I - Rent/Machinery - Company",
898 category_name="Rent-Plant / Machinery",
899 doctype="Tax Withholding Category", accounts=accounts,
900 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
901 "single_threshold": 180000, "cumulative_threshold": 0}]),
902 dict(name="TDS - 194I - Rent/Machinery - Individual",
903 category_name="Rent-Plant / Machinery",
904 doctype="Tax Withholding Category", accounts=accounts,
905 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
906 "single_threshold": 180000, "cumulative_threshold": 0}]),
907 dict(name="TDS - 194I - Rent/Machinery - No PAN / Invalid PAN",
908 category_name="Rent-Plant / Machinery",
909 doctype="Tax Withholding Category", accounts=accounts,
910 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
911 "single_threshold": 180000, "cumulative_threshold": 0}]),
912 dict(name="TDS - 194J - Professional Fees - Company",
913 category_name="Professional Fees",
914 doctype="Tax Withholding Category", accounts=accounts,
915 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
916 "single_threshold": 30000, "cumulative_threshold": 0}]),
917 dict(name="TDS - 194J - Professional Fees - Individual",
918 category_name="Professional Fees",
919 doctype="Tax Withholding Category", accounts=accounts,
920 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
921 "single_threshold": 30000, "cumulative_threshold": 0}]),
922 dict(name="TDS - 194J - Professional Fees - No PAN / Invalid PAN",
923 category_name="Professional Fees",
924 doctype="Tax Withholding Category", accounts=accounts,
925 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
926 "single_threshold": 30000, "cumulative_threshold": 0}]),
927 dict(name="TDS - 194J - Director Fees - Company",
928 category_name="Director Fees",
929 doctype="Tax Withholding Category", accounts=accounts,
930 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
931 "single_threshold": 0, "cumulative_threshold": 0}]),
932 dict(name="TDS - 194J - Director Fees - Individual",
933 category_name="Director Fees",
934 doctype="Tax Withholding Category", accounts=accounts,
935 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
936 "single_threshold": 0, "cumulative_threshold": 0}]),
937 dict(name="TDS - 194J - Director Fees - No PAN / Invalid PAN",
938 category_name="Director Fees",
939 doctype="Tax Withholding Category", accounts=accounts,
940 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
941 "single_threshold": 0, "cumulative_threshold": 0}]),
942 dict(name="TDS - 194 - Dividends - Company",
943 category_name="Dividends",
944 doctype="Tax Withholding Category", accounts=accounts,
945 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
946 "single_threshold": 2500, "cumulative_threshold": 0}]),
947 dict(name="TDS - 194 - Dividends - Individual",
948 category_name="Dividends",
949 doctype="Tax Withholding Category", accounts=accounts,
950 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
951 "single_threshold": 2500, "cumulative_threshold": 0}]),
952 dict(name="TDS - 194 - Dividends - No PAN / Invalid PAN",
953 category_name="Dividends",
954 doctype="Tax Withholding Category", accounts=accounts,
955 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
956 "single_threshold": 2500, "cumulative_threshold": 0}])
Anurag Mishrae1464a72020-08-17 15:03:32 +0530957 ]
958
Anurag Mishra25c35682020-08-18 14:13:54 +0530959def create_gratuity_rule():
Anurag Mishrae1464a72020-08-17 15:03:32 +0530960 # Standard Indain Gratuity Rule
Anurag Mishra493eea12020-08-18 15:02:32 +0530961 if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
962 rule = frappe.new_doc("Gratuity Rule")
963 rule.name = "Indian Standard Gratuity Rule"
964 rule.calculate_gratuity_amount_based_on = "Current Slab"
965 rule.work_experience_calculation_method = "Round Off Work Experience"
966 rule.minimum_year_for_gratuity = 5
Anurag Mishrae1464a72020-08-17 15:03:32 +0530967
Anurag Mishra493eea12020-08-18 15:02:32 +0530968 fraction = 15/26
969 rule.append("gratuity_rule_slabs", {
970 "from_year": 0,
971 "to_year":0,
972 "fraction_of_applicable_earnings": fraction
973 })
Anurag Mishrae1464a72020-08-17 15:03:32 +0530974
Anurag Mishra493eea12020-08-18 15:02:32 +0530975 rule.flags.ignore_mandatory = True
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530976 rule.save()
Deepesh Garg204ea102021-04-30 16:35:52 +0530977
978def update_accounts_settings_for_taxes():
979 if frappe.db.count('Company') == 1:
980 frappe.db.set_value('Accounts Settings', None, "add_taxes_from_item_tax_template", 0)