blob: 062c2ef5c598b1e7df33ae523f4cc34d33b0d226 [file] [log] [blame]
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2# License: GNU General Public License v3. See license.txt
3
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05304
5import frappe, os, json
Rushabh Mehtaf0569742017-09-13 12:52:30 +05306from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
Sagar Vora4c31fbb2021-04-01 15:32:37 +05307from frappe.custom.doctype.property_setter.property_setter import make_property_setter
Nabin Hait49b41e42019-01-24 17:55:44 +05308from frappe.permissions import add_permission, update_permission_property
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05309from erpnext.regional.india import states
Anuja Pawar4569e522021-01-14 19:24:30 +053010from erpnext.accounts.utils import get_fiscal_year, FiscalYearError
Zarrar7f8024c2018-08-01 17:45:05 +053011from frappe.utils import today
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053012
Ankush Menat494bd9e2022-03-28 18:52:46 +053013
Rushabh Mehta01659272017-06-27 18:05:17 +053014def setup(company=None, patch=True):
Deepesh Gargfea29ae2021-07-12 18:29:52 +053015 # Company independent fixtures should be called only once at the first company setup
Ankush Menat494bd9e2022-03-28 18:52:46 +053016 if patch or frappe.db.count("Company", {"country": "India"}) <= 1:
Deepesh Gargfea29ae2021-07-12 18:29:52 +053017 setup_company_independent_fixtures(patch=patch)
18
Prateeksha Singh39b87652018-11-12 17:19:56 +053019 if not patch:
Prateeksha Singhdabf3492018-11-13 15:56:15 +053020 make_fixtures(company)
Prateeksha Singh39b87652018-11-12 17:19:56 +053021
Ankush Menat494bd9e2022-03-28 18:52:46 +053022
Prateeksha Singh39b87652018-11-12 17:19:56 +053023# TODO: for all countries
Nabin Hait10c61372021-04-13 15:46:01 +053024def setup_company_independent_fixtures(patch=False):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053025 make_custom_fields()
Nabin Hait10c61372021-04-13 15:46:01 +053026 make_property_setters(patch=patch)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053027 add_permissions()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053028 add_custom_roles_for_reports()
Ankush Menat494bd9e2022-03-28 18:52:46 +053029 frappe.enqueue("erpnext.regional.india.setup.add_hsn_sac_codes", now=frappe.flags.in_test)
Anurag Mishra25c35682020-08-18 14:13:54 +053030 create_gratuity_rule()
Nabin Hait852cb642017-07-05 12:58:19 +053031 add_print_formats()
Deepesh Garg204ea102021-04-30 16:35:52 +053032 update_accounts_settings_for_taxes()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053033
Ankush Menat494bd9e2022-03-28 18:52:46 +053034
Nabin Hait1a609312017-07-13 12:16:04 +053035def add_hsn_sac_codes():
Ankush Menat5bb89b02021-06-11 15:57:01 +053036 if frappe.flags.in_test and frappe.flags.created_hsn_codes:
37 return
38
Nabin Hait1a609312017-07-13 12:16:04 +053039 # HSN codes
Ankush Menat494bd9e2022-03-28 18:52:46 +053040 with open(os.path.join(os.path.dirname(__file__), "hsn_code_data.json"), "r") as f:
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053041 hsn_codes = json.loads(f.read())
42
Nabin Hait1a609312017-07-13 12:16:04 +053043 create_hsn_codes(hsn_codes, code_field="hsn_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053044
Nabin Hait1a609312017-07-13 12:16:04 +053045 # SAC Codes
Ankush Menat494bd9e2022-03-28 18:52:46 +053046 with open(os.path.join(os.path.dirname(__file__), "sac_code_data.json"), "r") as f:
Nabin Hait1a609312017-07-13 12:16:04 +053047 sac_codes = json.loads(f.read())
48 create_hsn_codes(sac_codes, code_field="sac_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053049
Ankush Menat5bb89b02021-06-11 15:57:01 +053050 if frappe.flags.in_test:
51 frappe.flags.created_hsn_codes = True
52
Ankush Menat494bd9e2022-03-28 18:52:46 +053053
Nabin Hait1a609312017-07-13 12:16:04 +053054def create_hsn_codes(data, code_field):
55 for d in data:
Ankush Menat494bd9e2022-03-28 18:52:46 +053056 hsn_code = frappe.new_doc("GST HSN Code")
Rushabh Mehtaf702d722017-09-27 15:31:30 +053057 hsn_code.description = d["description"]
58 hsn_code.hsn_code = d[code_field]
59 hsn_code.name = d[code_field]
Ankush Menat9c7df2e2022-02-22 20:53:19 +053060 hsn_code.db_insert(ignore_if_duplicate=True)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053061
Ankush Menat494bd9e2022-03-28 18:52:46 +053062
Rushabh Mehta919a74a2017-06-22 16:37:04 +053063def add_custom_roles_for_reports():
Ankush Menat494bd9e2022-03-28 18:52:46 +053064 for report_name in (
65 "GST Sales Register",
66 "GST Purchase Register",
67 "GST Itemised Sales Register",
68 "GST Itemised Purchase Register",
69 "Eway Bill",
70 "E-Invoice Summary",
71 ):
Rushabh Mehta919a74a2017-06-22 16:37:04 +053072
Ankush Menat494bd9e2022-03-28 18:52:46 +053073 if not frappe.db.get_value("Custom Role", dict(report=report_name)):
74 frappe.get_doc(
75 dict(
76 doctype="Custom Role",
77 report=report_name,
78 roles=[dict(role="Accounts User"), dict(role="Accounts Manager")],
79 )
80 ).insert()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053081
Ankush Menat494bd9e2022-03-28 18:52:46 +053082 for report_name in ("Professional Tax Deductions", "Provident Fund Deductions"):
Anurag Mishra289c8222020-06-19 19:17:57 +053083
Ankush Menat494bd9e2022-03-28 18:52:46 +053084 if not frappe.db.get_value("Custom Role", dict(report=report_name)):
85 frappe.get_doc(
86 dict(
87 doctype="Custom Role",
88 report=report_name,
89 roles=[dict(role="HR User"), dict(role="HR Manager"), dict(role="Employee")],
90 )
91 ).insert()
Anurag Mishra289c8222020-06-19 19:17:57 +053092
Ankush Menat494bd9e2022-03-28 18:52:46 +053093 for report_name in ("HSN-wise-summary of outward supplies", "GSTR-1", "GSTR-2"):
Anurag Mishra54cd1942020-09-03 13:51:26 +053094
Ankush Menat494bd9e2022-03-28 18:52:46 +053095 if not frappe.db.get_value("Custom Role", dict(report=report_name)):
96 frappe.get_doc(
97 dict(
98 doctype="Custom Role",
99 report=report_name,
100 roles=[dict(role="Accounts User"), dict(role="Accounts Manager"), dict(role="Auditor")],
101 )
102 ).insert()
103
Anurag Mishra54cd1942020-09-03 13:51:26 +0530104
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530105def add_permissions():
Ankush Menat494bd9e2022-03-28 18:52:46 +0530106 for doctype in (
107 "GST HSN Code",
108 "GST Settings",
109 "GSTR 3B Report",
110 "Lower Deduction Certificate",
111 "E Invoice Settings",
112 ):
113 add_permission(doctype, "All", 0)
114 for role in ("Accounts Manager", "Accounts User", "System Manager"):
Saqib5e6ce882020-02-03 15:40:35 +0530115 add_permission(doctype, role, 0)
Ankush Menat494bd9e2022-03-28 18:52:46 +0530116 update_permission_property(doctype, role, 0, "write", 1)
117 update_permission_property(doctype, role, 0, "create", 1)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530118
Ankush Menat494bd9e2022-03-28 18:52:46 +0530119 if doctype == "GST HSN Code":
120 for role in ("Item Manager", "Stock Manager"):
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530121 add_permission(doctype, role, 0)
Ankush Menat494bd9e2022-03-28 18:52:46 +0530122 update_permission_property(doctype, role, 0, "write", 1)
123 update_permission_property(doctype, role, 0, "create", 1)
124
Deepesh Garg6c8efde2020-04-04 20:05:17 +0530125
Nabin Hait852cb642017-07-05 12:58:19 +0530126def add_print_formats():
127 frappe.reload_doc("regional", "print_format", "gst_tax_invoice")
Deepesh Gargfe2ced72022-02-25 16:57:59 +0530128 frappe.reload_doc("selling", "print_format", "gst_pos_invoice")
Saqib Ansaric5782b02022-01-27 20:09:56 +0530129 frappe.reload_doc("accounts", "print_format", "GST E-Invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530130
barredterra1521b312021-03-03 12:33:48 +0100131 frappe.db.set_value("Print Format", "GST POS Invoice", "disabled", 0)
132 frappe.db.set_value("Print Format", "GST Tax Invoice", "disabled", 0)
Saqib Ansaric5782b02022-01-27 20:09:56 +0530133 frappe.db.set_value("Print Format", "GST E-Invoice", "disabled", 0)
Nabin Hait852cb642017-07-05 12:58:19 +0530134
Ankush Menat494bd9e2022-03-28 18:52:46 +0530135
Nabin Hait10c61372021-04-13 15:46:01 +0530136def make_property_setters(patch=False):
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530137 # GST rules do not allow for an invoice no. bigger than 16 characters
Ankush Menat494bd9e2022-03-28 18:52:46 +0530138 journal_entry_types = frappe.get_meta("Journal Entry").get_options("voucher_type").split("\n") + [
139 "Reversal Of ITC"
140 ]
141 sales_invoice_series = ["SINV-.YY.-", "SRET-.YY.-", ""] + frappe.get_meta(
142 "Sales Invoice"
143 ).get_options("naming_series").split("\n")
144 purchase_invoice_series = ["PINV-.YY.-", "PRET-.YY.-", ""] + frappe.get_meta(
145 "Purchase Invoice"
146 ).get_options("naming_series").split("\n")
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530147
Nabin Hait10c61372021-04-13 15:46:01 +0530148 if not patch:
Ankush Menat494bd9e2022-03-28 18:52:46 +0530149 make_property_setter(
150 "Sales Invoice", "naming_series", "options", "\n".join(sales_invoice_series), ""
151 )
152 make_property_setter(
153 "Purchase Invoice", "naming_series", "options", "\n".join(purchase_invoice_series), ""
154 )
155 make_property_setter(
156 "Journal Entry", "voucher_type", "options", "\n".join(journal_entry_types), ""
157 )
158
Sagar Vora4c31fbb2021-04-01 15:32:37 +0530159
Rushabh Mehta69fa8082018-07-17 18:22:51 +0530160def make_custom_fields(update=True):
Saqib Ansarif1fcb382021-09-29 19:56:02 +0530161 custom_fields = get_custom_fields()
162 create_custom_fields(custom_fields, update=update)
163
Ankush Menat494bd9e2022-03-28 18:52:46 +0530164
Saqib Ansarif1fcb382021-09-29 19:56:02 +0530165def get_custom_fields():
Ankush Menat494bd9e2022-03-28 18:52:46 +0530166 hsn_sac_field = dict(
167 fieldname="gst_hsn_code",
168 label="HSN/SAC",
169 fieldtype="Data",
170 fetch_from="item_code.gst_hsn_code",
171 insert_after="description",
172 allow_on_submit=1,
173 print_hide=1,
174 fetch_if_empty=1,
175 )
176 nil_rated_exempt = dict(
177 fieldname="is_nil_exempt",
178 label="Is Nil Rated or Exempted",
179 fieldtype="Check",
180 fetch_from="item_code.is_nil_exempt",
181 insert_after="gst_hsn_code",
182 print_hide=1,
183 )
184 is_non_gst = dict(
185 fieldname="is_non_gst",
186 label="Is Non GST",
187 fieldtype="Check",
188 fetch_from="item_code.is_non_gst",
189 insert_after="is_nil_exempt",
190 print_hide=1,
191 )
192 taxable_value = dict(
193 fieldname="taxable_value",
194 label="Taxable Value",
195 fieldtype="Currency",
196 insert_after="base_net_amount",
197 hidden=1,
198 options="Company:company:default_currency",
199 print_hide=1,
200 )
Deepesh Garg22b61602019-03-21 20:47:47 +0530201
202 purchase_invoice_gst_category = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530203 dict(
204 fieldname="gst_section",
205 label="GST Details",
206 fieldtype="Section Break",
207 insert_after="language",
208 print_hide=1,
209 collapsible=1,
210 ),
211 dict(
212 fieldname="gst_category",
213 label="GST Category",
214 fieldtype="Select",
215 insert_after="gst_section",
216 print_hide=1,
217 options="\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders",
218 fetch_from="supplier.gst_category",
219 fetch_if_empty=1,
220 ),
221 dict(
222 fieldname="export_type",
223 label="Export Type",
224 fieldtype="Select",
225 insert_after="gst_category",
226 print_hide=1,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530227 depends_on='eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
Ankush Menat494bd9e2022-03-28 18:52:46 +0530228 options="\nWith Payment of Tax\nWithout Payment of Tax",
229 fetch_from="supplier.export_type",
230 fetch_if_empty=1,
231 ),
Deepesh Garg22b61602019-03-21 20:47:47 +0530232 ]
233
234 sales_invoice_gst_category = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530235 dict(
236 fieldname="gst_section",
237 label="GST Details",
238 fieldtype="Section Break",
239 insert_after="language",
240 print_hide=1,
241 collapsible=1,
242 ),
243 dict(
244 fieldname="gst_category",
245 label="GST Category",
246 fieldtype="Select",
247 insert_after="gst_section",
248 print_hide=1,
249 options="\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders",
250 fetch_from="customer.gst_category",
251 fetch_if_empty=1,
252 length=25,
253 ),
254 dict(
255 fieldname="export_type",
256 label="Export Type",
257 fieldtype="Select",
258 insert_after="gst_category",
259 print_hide=1,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530260 depends_on='eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
Ankush Menat494bd9e2022-03-28 18:52:46 +0530261 options="\nWith Payment of Tax\nWithout Payment of Tax",
262 fetch_from="customer.export_type",
263 fetch_if_empty=1,
264 length=25,
265 ),
Deepesh Garg22b61602019-03-21 20:47:47 +0530266 ]
267
Deepesh Garg29997412021-03-29 19:49:52 +0530268 delivery_note_gst_category = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530269 dict(
270 fieldname="gst_category",
271 label="GST Category",
272 fieldtype="Select",
273 insert_after="gst_vehicle_type",
274 print_hide=1,
275 options="\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders",
276 fetch_from="customer.gst_category",
277 fetch_if_empty=1,
278 ),
Deepesh Garg29997412021-03-29 19:49:52 +0530279 ]
280
Deepesh Garg22b61602019-03-21 20:47:47 +0530281 invoice_gst_fields = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530282 dict(
283 fieldname="invoice_copy",
284 label="Invoice Copy",
285 length=30,
286 fieldtype="Select",
287 insert_after="export_type",
288 print_hide=1,
289 allow_on_submit=1,
290 options="Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier",
291 ),
292 dict(
293 fieldname="reverse_charge",
294 label="Reverse Charge",
295 length=2,
296 fieldtype="Select",
297 insert_after="invoice_copy",
298 print_hide=1,
299 options="Y\nN",
300 default="N",
301 ),
302 dict(
303 fieldname="ecommerce_gstin",
304 label="E-commerce GSTIN",
305 length=15,
306 fieldtype="Data",
307 insert_after="export_type",
308 print_hide=1,
309 ),
310 dict(fieldname="gst_col_break", fieldtype="Column Break", insert_after="ecommerce_gstin"),
311 dict(
312 fieldname="reason_for_issuing_document",
313 label="Reason For Issuing document",
314 fieldtype="Select",
315 insert_after="gst_col_break",
316 print_hide=1,
317 depends_on="eval:doc.is_return==1",
318 length=45,
319 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",
320 ),
Nabin Hait879e1622017-08-21 08:28:55 +0530321 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530322
Nabin Hait879e1622017-08-21 08:28:55 +0530323 purchase_invoice_gst_fields = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530324 dict(
325 fieldname="supplier_gstin",
326 label="Supplier GSTIN",
327 fieldtype="Data",
328 insert_after="supplier_address",
329 fetch_from="supplier_address.gstin",
330 print_hide=1,
331 read_only=1,
332 ),
333 dict(
334 fieldname="company_gstin",
335 label="Company GSTIN",
336 fieldtype="Data",
337 insert_after="shipping_address_display",
338 fetch_from="shipping_address.gstin",
339 print_hide=1,
340 read_only=1,
341 ),
342 dict(
343 fieldname="place_of_supply",
344 label="Place of Supply",
345 fieldtype="Data",
346 insert_after="shipping_address",
347 print_hide=1,
348 read_only=1,
349 ),
350 ]
deepeshgarg007d29ee972019-01-09 17:09:11 +0530351
352 purchase_invoice_itc_fields = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530353 dict(
354 fieldname="eligibility_for_itc",
355 label="Eligibility For ITC",
356 fieldtype="Select",
357 insert_after="reason_for_issuing_document",
358 print_hide=1,
359 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",
360 default="All Other ITC",
361 ),
362 dict(
363 fieldname="itc_integrated_tax",
364 label="Availed ITC Integrated Tax",
365 fieldtype="Currency",
366 insert_after="eligibility_for_itc",
367 options="Company:company:default_currency",
368 print_hide=1,
369 ),
370 dict(
371 fieldname="itc_central_tax",
372 label="Availed ITC Central Tax",
373 fieldtype="Currency",
374 insert_after="itc_integrated_tax",
375 options="Company:company:default_currency",
376 print_hide=1,
377 ),
378 dict(
379 fieldname="itc_state_tax",
380 label="Availed ITC State/UT Tax",
381 fieldtype="Currency",
382 insert_after="itc_central_tax",
383 options="Company:company:default_currency",
384 print_hide=1,
385 ),
386 dict(
387 fieldname="itc_cess_amount",
388 label="Availed ITC Cess",
389 fieldtype="Currency",
390 insert_after="itc_state_tax",
391 options="Company:company:default_currency",
392 print_hide=1,
393 ),
394 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530395
Nabin Hait879e1622017-08-21 08:28:55 +0530396 sales_invoice_gst_fields = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530397 dict(
398 fieldname="billing_address_gstin",
399 label="Billing Address GSTIN",
400 fieldtype="Data",
401 insert_after="customer_address",
402 read_only=1,
403 fetch_from="customer_address.gstin",
404 print_hide=1,
405 length=15,
406 ),
407 dict(
408 fieldname="customer_gstin",
409 label="Customer GSTIN",
410 fieldtype="Data",
411 insert_after="shipping_address_name",
412 fetch_from="shipping_address_name.gstin",
413 print_hide=1,
414 length=15,
415 ),
416 dict(
417 fieldname="place_of_supply",
418 label="Place of Supply",
419 fieldtype="Data",
420 insert_after="customer_gstin",
421 print_hide=1,
422 read_only=1,
423 length=50,
424 ),
425 dict(
426 fieldname="company_gstin",
427 label="Company GSTIN",
428 fieldtype="Data",
429 insert_after="company_address",
430 fetch_from="company_address.gstin",
431 print_hide=1,
432 read_only=1,
433 length=15,
434 ),
435 ]
deepeshgarg007d29ee972019-01-09 17:09:11 +0530436
437 sales_invoice_shipping_fields = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530438 dict(
439 fieldname="port_code",
440 label="Port Code",
441 fieldtype="Data",
442 insert_after="reason_for_issuing_document",
443 print_hide=1,
444 depends_on="eval:doc.gst_category=='Overseas' ",
445 length=15,
446 ),
447 dict(
448 fieldname="shipping_bill_number",
449 label=" Shipping Bill Number",
450 fieldtype="Data",
451 insert_after="port_code",
452 print_hide=1,
453 depends_on="eval:doc.gst_category=='Overseas' ",
454 length=50,
455 ),
456 dict(
457 fieldname="shipping_bill_date",
458 label="Shipping Bill Date",
459 fieldtype="Date",
460 insert_after="shipping_bill_number",
461 print_hide=1,
462 depends_on="eval:doc.gst_category=='Overseas' ",
463 ),
464 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530465
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530466 journal_entry_fields = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530467 dict(
468 fieldname="reversal_type",
469 label="Reversal Type",
470 fieldtype="Select",
471 insert_after="voucher_type",
472 print_hide=1,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530473 options="As per rules 42 & 43 of CGST Rules\nOthers",
474 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
Ankush Menat494bd9e2022-03-28 18:52:46 +0530475 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
476 ),
477 dict(
478 fieldname="company_address",
479 label="Company Address",
480 fieldtype="Link",
481 options="Address",
482 insert_after="reversal_type",
483 print_hide=1,
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530484 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
Ankush Menat494bd9e2022-03-28 18:52:46 +0530485 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
486 ),
487 dict(
488 fieldname="company_gstin",
489 label="Company GSTIN",
490 fieldtype="Data",
491 read_only=1,
492 insert_after="company_address",
493 print_hide=1,
494 fetch_from="company_address.gstin",
495 depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
496 mandatory_depends_on="eval:doc.voucher_type=='Reversal Of ITC'",
497 ),
Deepesh Garg55fe85d2021-05-14 12:17:41 +0530498 ]
499
Shreya Shah4fa600a2018-06-05 11:27:53 +0530500 inter_state_gst_field = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530501 dict(
502 fieldname="is_inter_state",
503 label="Is Inter State",
504 fieldtype="Check",
505 insert_after="disabled",
506 print_hide=1,
507 ),
508 dict(
509 fieldname="is_reverse_charge",
510 label="Is Reverse Charge",
511 fieldtype="Check",
512 insert_after="is_inter_state",
513 print_hide=1,
514 ),
515 dict(
516 fieldname="tax_category_column_break",
517 fieldtype="Column Break",
518 insert_after="is_reverse_charge",
519 ),
520 dict(
521 fieldname="gst_state",
522 label="Source State",
523 fieldtype="Select",
524 options="\n".join(states),
525 insert_after="company",
526 ),
Shreya Shah4fa600a2018-06-05 11:27:53 +0530527 ]
528
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530529 ewaybill_fields = [
530 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530531 "fieldname": "distance",
532 "label": "Distance (in km)",
533 "fieldtype": "Float",
534 "insert_after": "vehicle_no",
535 "print_hide": 1,
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530536 },
537 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530538 "fieldname": "gst_transporter_id",
539 "label": "GST Transporter ID",
540 "fieldtype": "Data",
541 "insert_after": "transporter",
542 "fetch_from": "transporter.gst_transporter_id",
543 "print_hide": 1,
544 "translatable": 0,
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530545 },
546 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530547 "fieldname": "mode_of_transport",
548 "label": "Mode of Transport",
549 "fieldtype": "Select",
550 "options": "\nRoad\nAir\nRail\nShip",
551 "default": "Road",
552 "insert_after": "transporter_name",
553 "print_hide": 1,
554 "translatable": 0,
Nabin Hait34c551d2019-07-03 10:34:31 +0530555 },
556 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530557 "fieldname": "gst_vehicle_type",
558 "label": "GST Vehicle Type",
559 "fieldtype": "Select",
560 "options": "Regular\nOver Dimensional Cargo (ODC)",
561 "depends_on": 'eval:(doc.mode_of_transport === "Road")',
562 "default": "Regular",
563 "insert_after": "lr_date",
564 "print_hide": 1,
565 "translatable": 0,
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530566 },
567 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530568 "fieldname": "ewaybill",
569 "label": "E-Way Bill No.",
570 "fieldtype": "Data",
571 "depends_on": "eval:(doc.docstatus === 1)",
572 "allow_on_submit": 1,
573 "insert_after": "customer_name_in_arabic",
574 "translatable": 0,
575 },
Nabin Hait34c551d2019-07-03 10:34:31 +0530576 ]
577
578 si_ewaybill_fields = [
579 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530580 "fieldname": "transporter_info",
581 "label": "Transporter Info",
582 "fieldtype": "Section Break",
583 "insert_after": "terms",
584 "collapsible": 1,
585 "collapsible_depends_on": "transporter",
586 "print_hide": 1,
Nabin Hait34c551d2019-07-03 10:34:31 +0530587 },
588 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530589 "fieldname": "transporter",
590 "label": "Transporter",
591 "fieldtype": "Link",
592 "insert_after": "transporter_info",
593 "options": "Supplier",
594 "print_hide": 1,
Nabin Hait34c551d2019-07-03 10:34:31 +0530595 },
596 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530597 "fieldname": "gst_transporter_id",
598 "label": "GST Transporter ID",
599 "fieldtype": "Data",
600 "insert_after": "transporter",
601 "fetch_from": "transporter.gst_transporter_id",
602 "print_hide": 1,
603 "translatable": 0,
604 "length": 20,
Nabin Hait34c551d2019-07-03 10:34:31 +0530605 },
606 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530607 "fieldname": "driver",
608 "label": "Driver",
609 "fieldtype": "Link",
610 "insert_after": "gst_transporter_id",
611 "options": "Driver",
612 "print_hide": 1,
Nabin Hait34c551d2019-07-03 10:34:31 +0530613 },
614 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530615 "fieldname": "lr_no",
616 "label": "Transport Receipt No",
617 "fieldtype": "Data",
618 "insert_after": "driver",
619 "print_hide": 1,
620 "translatable": 0,
621 "length": 30,
Nabin Hait34c551d2019-07-03 10:34:31 +0530622 },
623 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530624 "fieldname": "vehicle_no",
625 "label": "Vehicle No",
626 "fieldtype": "Data",
627 "insert_after": "lr_no",
628 "print_hide": 1,
629 "translatable": 0,
630 "length": 10,
Nabin Hait34c551d2019-07-03 10:34:31 +0530631 },
632 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530633 "fieldname": "distance",
634 "label": "Distance (in km)",
635 "fieldtype": "Float",
636 "insert_after": "vehicle_no",
637 "print_hide": 1,
638 },
639 {"fieldname": "transporter_col_break", "fieldtype": "Column Break", "insert_after": "distance"},
640 {
641 "fieldname": "transporter_name",
642 "label": "Transporter Name",
643 "fieldtype": "Small Text",
644 "insert_after": "transporter_col_break",
645 "fetch_from": "transporter.name",
646 "read_only": 1,
647 "print_hide": 1,
648 "translatable": 0,
Nabin Hait34c551d2019-07-03 10:34:31 +0530649 },
650 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530651 "fieldname": "mode_of_transport",
652 "label": "Mode of Transport",
653 "fieldtype": "Select",
654 "options": "\nRoad\nAir\nRail\nShip",
655 "insert_after": "transporter_name",
656 "print_hide": 1,
657 "translatable": 0,
658 "length": 5,
Nabin Hait34c551d2019-07-03 10:34:31 +0530659 },
660 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530661 "fieldname": "driver_name",
662 "label": "Driver Name",
663 "fieldtype": "Small Text",
664 "insert_after": "mode_of_transport",
665 "fetch_from": "driver.full_name",
666 "print_hide": 1,
667 "translatable": 0,
Nabin Hait34c551d2019-07-03 10:34:31 +0530668 },
669 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530670 "fieldname": "lr_date",
671 "label": "Transport Receipt Date",
672 "fieldtype": "Date",
673 "insert_after": "driver_name",
674 "default": "Today",
675 "print_hide": 1,
Nabin Hait34c551d2019-07-03 10:34:31 +0530676 },
677 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530678 "fieldname": "gst_vehicle_type",
679 "label": "GST Vehicle Type",
680 "fieldtype": "Select",
681 "options": "Regular\nOver Dimensional Cargo (ODC)",
682 "depends_on": 'eval:(doc.mode_of_transport === "Road")',
683 "default": "Regular",
684 "insert_after": "lr_date",
685 "print_hide": 1,
686 "translatable": 0,
687 "length": 30,
Nabin Hait34c551d2019-07-03 10:34:31 +0530688 },
689 {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530690 "fieldname": "ewaybill",
691 "label": "E-Way Bill No.",
692 "fieldtype": "Data",
693 "depends_on": "eval:((doc.docstatus === 1 || doc.ewaybill) && doc.eway_bill_cancelled === 0)",
694 "allow_on_submit": 1,
695 "insert_after": "tax_id",
696 "translatable": 0,
697 "length": 20,
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530698 },
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530699 ]
700
Deepesh Garge8a5dc32021-09-02 18:56:04 +0530701 payment_entry_fields = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530702 dict(
703 fieldname="gst_section",
704 label="GST Details",
705 fieldtype="Section Break",
706 insert_after="deductions",
707 print_hide=1,
708 collapsible=1,
709 ),
710 dict(
711 fieldname="company_address",
712 label="Company Address",
713 fieldtype="Link",
714 insert_after="gst_section",
715 print_hide=1,
716 options="Address",
717 ),
718 dict(
719 fieldname="company_gstin",
720 label="Company GSTIN",
721 fieldtype="Data",
722 insert_after="company_address",
723 fetch_from="company_address.gstin",
724 print_hide=1,
725 read_only=1,
726 ),
727 dict(
728 fieldname="place_of_supply",
729 label="Place of Supply",
730 fieldtype="Data",
731 insert_after="company_gstin",
732 print_hide=1,
733 read_only=1,
734 ),
735 dict(fieldname="gst_column_break", fieldtype="Column Break", insert_after="place_of_supply"),
736 dict(
737 fieldname="customer_address",
738 label="Customer Address",
739 fieldtype="Link",
740 insert_after="gst_column_break",
741 print_hide=1,
742 options="Address",
743 depends_on='eval:doc.party_type == "Customer"',
744 ),
745 dict(
746 fieldname="customer_gstin",
747 label="Customer GSTIN",
748 fieldtype="Data",
749 insert_after="customer_address",
750 fetch_from="customer_address.gstin",
751 print_hide=1,
752 read_only=1,
753 ),
Deepesh Garge8a5dc32021-09-02 18:56:04 +0530754 ]
755
Saqib Ansaric5782b02022-01-27 20:09:56 +0530756 si_einvoice_fields = [
Ankush Menat494bd9e2022-03-28 18:52:46 +0530757 dict(
758 fieldname="irn",
759 label="IRN",
760 fieldtype="Data",
761 read_only=1,
762 insert_after="customer",
763 no_copy=1,
764 print_hide=1,
765 depends_on='eval:in_list(["Registered Regular", "SEZ", "Overseas", "Deemed Export"], doc.gst_category) && doc.irn_cancelled === 0',
766 ),
767 dict(
768 fieldname="irn_cancelled",
769 label="IRN Cancelled",
770 fieldtype="Check",
771 no_copy=1,
772 print_hide=1,
773 depends_on="eval: doc.irn",
774 allow_on_submit=1,
775 insert_after="customer",
776 ),
777 dict(
778 fieldname="eway_bill_validity",
779 label="E-Way Bill Validity",
780 fieldtype="Data",
781 no_copy=1,
782 print_hide=1,
783 depends_on="ewaybill",
784 read_only=1,
785 allow_on_submit=1,
786 insert_after="ewaybill",
787 ),
788 dict(
789 fieldname="eway_bill_cancelled",
790 label="E-Way Bill Cancelled",
791 fieldtype="Check",
792 no_copy=1,
793 print_hide=1,
794 depends_on="eval:(doc.eway_bill_cancelled === 1)",
795 read_only=1,
796 allow_on_submit=1,
797 insert_after="customer",
798 ),
799 dict(
800 fieldname="einvoice_section",
801 label="E-Invoice Fields",
802 fieldtype="Section Break",
803 insert_after="gst_vehicle_type",
804 print_hide=1,
805 hidden=1,
806 ),
807 dict(
808 fieldname="ack_no",
809 label="Ack. No.",
810 fieldtype="Data",
811 read_only=1,
812 hidden=1,
813 insert_after="einvoice_section",
814 no_copy=1,
815 print_hide=1,
816 ),
817 dict(
818 fieldname="ack_date",
819 label="Ack. Date",
820 fieldtype="Data",
821 read_only=1,
822 hidden=1,
823 insert_after="ack_no",
824 no_copy=1,
825 print_hide=1,
826 ),
827 dict(
828 fieldname="irn_cancel_date",
829 label="Cancel Date",
830 fieldtype="Data",
831 read_only=1,
832 hidden=1,
833 insert_after="ack_date",
834 no_copy=1,
835 print_hide=1,
836 ),
837 dict(
838 fieldname="signed_einvoice",
839 label="Signed E-Invoice",
840 fieldtype="Code",
841 options="JSON",
842 hidden=1,
843 insert_after="irn_cancel_date",
844 no_copy=1,
845 print_hide=1,
846 read_only=1,
847 ),
848 dict(
849 fieldname="signed_qr_code",
850 label="Signed QRCode",
851 fieldtype="Code",
852 options="JSON",
853 hidden=1,
854 insert_after="signed_einvoice",
855 no_copy=1,
856 print_hide=1,
857 read_only=1,
858 ),
859 dict(
860 fieldname="qrcode_image",
861 label="QRCode",
862 fieldtype="Attach Image",
863 hidden=1,
864 insert_after="signed_qr_code",
865 no_copy=1,
866 print_hide=1,
867 read_only=1,
868 ),
869 dict(
870 fieldname="einvoice_status",
871 label="E-Invoice Status",
872 fieldtype="Select",
873 insert_after="qrcode_image",
874 options="\nPending\nGenerated\nCancelled\nFailed",
875 default=None,
876 hidden=1,
877 no_copy=1,
878 print_hide=1,
879 read_only=1,
880 ),
881 dict(
882 fieldname="failure_description",
883 label="E-Invoice Failure Description",
884 fieldtype="Code",
885 options="JSON",
886 hidden=1,
887 insert_after="einvoice_status",
888 no_copy=1,
889 print_hide=1,
890 read_only=1,
891 ),
Saqib Ansaric5782b02022-01-27 20:09:56 +0530892 ]
893
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530894 custom_fields = {
Ankush Menat494bd9e2022-03-28 18:52:46 +0530895 "Address": [
896 dict(fieldname="gstin", label="Party GSTIN", fieldtype="Data", insert_after="fax"),
897 dict(
898 fieldname="gst_state",
899 label="GST State",
900 fieldtype="Select",
901 options="\n".join(states),
902 insert_after="gstin",
903 ),
904 dict(
905 fieldname="gst_state_number",
906 label="GST State Number",
907 fieldtype="Data",
908 insert_after="gst_state",
909 read_only=1,
910 ),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530911 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +0530912 "Purchase Invoice": purchase_invoice_gst_category
913 + invoice_gst_fields
914 + purchase_invoice_itc_fields
915 + purchase_invoice_gst_fields,
916 "Purchase Order": purchase_invoice_gst_fields,
917 "Purchase Receipt": purchase_invoice_gst_fields,
918 "Sales Invoice": sales_invoice_gst_category
919 + invoice_gst_fields
920 + sales_invoice_shipping_fields
921 + sales_invoice_gst_fields
922 + si_ewaybill_fields
923 + si_einvoice_fields,
924 "POS Invoice": sales_invoice_gst_fields,
925 "Delivery Note": sales_invoice_gst_fields
926 + ewaybill_fields
927 + sales_invoice_shipping_fields
928 + delivery_note_gst_category,
929 "Payment Entry": payment_entry_fields,
930 "Journal Entry": journal_entry_fields,
931 "Sales Order": sales_invoice_gst_fields,
932 "Tax Category": inter_state_gst_field,
Deepesh Garg485f5cf2022-04-02 17:25:29 +0530933 "Quotation": sales_invoice_gst_fields,
Ankush Menat494bd9e2022-03-28 18:52:46 +0530934 "Item": [
935 dict(
936 fieldname="gst_hsn_code",
937 label="HSN/SAC",
938 fieldtype="Link",
939 options="GST HSN Code",
940 insert_after="item_group",
941 ),
942 dict(
943 fieldname="is_nil_exempt",
944 label="Is Nil Rated or Exempted",
945 fieldtype="Check",
946 insert_after="gst_hsn_code",
947 ),
948 dict(
949 fieldname="is_non_gst", label="Is Non GST ", fieldtype="Check", insert_after="is_nil_exempt"
950 ),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530951 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +0530952 "Quotation Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
953 "Supplier Quotation Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
954 "Sales Order Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
955 "Delivery Note Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
956 "Sales Invoice Item": [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
957 "POS Invoice Item": [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
958 "Purchase Order Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
959 "Purchase Receipt Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
960 "Purchase Invoice Item": [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
961 "Material Request Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
962 "Salary Component": [
963 dict(
964 fieldname="component_type",
965 label="Component Type",
966 fieldtype="Select",
967 insert_after="description",
968 options="\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax",
969 depends_on='eval:doc.type == "Deduction"',
Anurag Mishra289c8222020-06-19 19:17:57 +0530970 )
971 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +0530972 "Employee": [
973 dict(
974 fieldname="ifsc_code",
975 label="IFSC Code",
976 fieldtype="Data",
977 insert_after="bank_ac_no",
Anurag Mishra289c8222020-06-19 19:17:57 +0530978 print_hide=1,
Ankush Menat494bd9e2022-03-28 18:52:46 +0530979 depends_on='eval:doc.salary_mode == "Bank"',
Anurag Mishra289c8222020-06-19 19:17:57 +0530980 ),
981 dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530982 fieldname="pan_number",
983 label="PAN Number",
984 fieldtype="Data",
985 insert_after="payroll_cost_center",
986 print_hide=1,
Anurag Mishra289c8222020-06-19 19:17:57 +0530987 ),
988 dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530989 fieldname="micr_code",
990 label="MICR Code",
991 fieldtype="Data",
992 insert_after="ifsc_code",
993 print_hide=1,
994 depends_on='eval:doc.salary_mode == "Bank"',
995 ),
996 dict(
997 fieldname="provident_fund_account",
998 label="Provident Fund Account",
999 fieldtype="Data",
1000 insert_after="pan_number",
1001 ),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +05301002 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +05301003 "Company": [
1004 dict(
1005 fieldname="hra_section",
1006 label="HRA Settings",
1007 fieldtype="Section Break",
1008 insert_after="asset_received_but_not_billed",
1009 collapsible=1,
1010 ),
1011 dict(
1012 fieldname="basic_component",
1013 label="Basic Component",
1014 fieldtype="Link",
1015 options="Salary Component",
1016 insert_after="hra_section",
1017 ),
1018 dict(
1019 fieldname="hra_component",
1020 label="HRA Component",
1021 fieldtype="Link",
1022 options="Salary Component",
1023 insert_after="basic_component",
1024 ),
1025 dict(fieldname="hra_column_break", fieldtype="Column Break", insert_after="hra_component"),
1026 dict(
1027 fieldname="arrear_component",
1028 label="Arrear Component",
1029 fieldtype="Link",
1030 options="Salary Component",
1031 insert_after="hra_column_break",
1032 ),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +05301033 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +05301034 "Employee Tax Exemption Declaration": [
1035 dict(
1036 fieldname="hra_section",
1037 label="HRA Exemption",
1038 fieldtype="Section Break",
1039 insert_after="declarations",
1040 ),
1041 dict(
1042 fieldname="monthly_house_rent",
1043 label="Monthly House Rent",
1044 fieldtype="Currency",
1045 insert_after="hra_section",
1046 ),
1047 dict(
1048 fieldname="rented_in_metro_city",
1049 label="Rented in Metro City",
1050 fieldtype="Check",
1051 insert_after="monthly_house_rent",
1052 depends_on="monthly_house_rent",
1053 ),
1054 dict(
1055 fieldname="salary_structure_hra",
1056 label="HRA as per Salary Structure",
1057 fieldtype="Currency",
1058 insert_after="rented_in_metro_city",
1059 read_only=1,
1060 depends_on="monthly_house_rent",
1061 ),
1062 dict(
1063 fieldname="hra_column_break",
1064 fieldtype="Column Break",
1065 insert_after="salary_structure_hra",
1066 depends_on="monthly_house_rent",
1067 ),
1068 dict(
1069 fieldname="annual_hra_exemption",
1070 label="Annual HRA Exemption",
1071 fieldtype="Currency",
1072 insert_after="hra_column_break",
1073 read_only=1,
1074 depends_on="monthly_house_rent",
1075 ),
1076 dict(
1077 fieldname="monthly_hra_exemption",
1078 label="Monthly HRA Exemption",
1079 fieldtype="Currency",
1080 insert_after="annual_hra_exemption",
1081 read_only=1,
1082 depends_on="monthly_house_rent",
1083 ),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +05301084 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +05301085 "Employee Tax Exemption Proof Submission": [
1086 dict(
1087 fieldname="hra_section",
1088 label="HRA Exemption",
1089 fieldtype="Section Break",
1090 insert_after="tax_exemption_proofs",
1091 ),
1092 dict(
1093 fieldname="house_rent_payment_amount",
1094 label="House Rent Payment Amount",
1095 fieldtype="Currency",
1096 insert_after="hra_section",
1097 ),
1098 dict(
1099 fieldname="rented_in_metro_city",
1100 label="Rented in Metro City",
1101 fieldtype="Check",
1102 insert_after="house_rent_payment_amount",
1103 depends_on="house_rent_payment_amount",
1104 ),
1105 dict(
1106 fieldname="rented_from_date",
1107 label="Rented From Date",
1108 fieldtype="Date",
1109 insert_after="rented_in_metro_city",
1110 depends_on="house_rent_payment_amount",
1111 ),
1112 dict(
1113 fieldname="rented_to_date",
1114 label="Rented To Date",
1115 fieldtype="Date",
1116 insert_after="rented_from_date",
1117 depends_on="house_rent_payment_amount",
1118 ),
1119 dict(
1120 fieldname="hra_column_break",
1121 fieldtype="Column Break",
1122 insert_after="rented_to_date",
1123 depends_on="house_rent_payment_amount",
1124 ),
1125 dict(
1126 fieldname="monthly_house_rent",
1127 label="Monthly House Rent",
1128 fieldtype="Currency",
1129 insert_after="hra_column_break",
1130 read_only=1,
1131 depends_on="house_rent_payment_amount",
1132 ),
1133 dict(
1134 fieldname="monthly_hra_exemption",
1135 label="Monthly Eligible Amount",
1136 fieldtype="Currency",
1137 insert_after="monthly_house_rent",
1138 read_only=1,
1139 depends_on="house_rent_payment_amount",
1140 ),
1141 dict(
1142 fieldname="total_eligible_hra_exemption",
1143 label="Total Eligible HRA Exemption",
1144 fieldtype="Currency",
1145 insert_after="monthly_hra_exemption",
1146 read_only=1,
1147 depends_on="house_rent_payment_amount",
1148 ),
Sagar Vorad92f3ac2018-10-10 14:51:26 +05301149 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +05301150 "Supplier": [
1151 {"fieldname": "pan", "label": "PAN", "fieldtype": "Data", "insert_after": "supplier_type"},
Sagar Vorad92f3ac2018-10-10 14:51:26 +05301152 {
Ankush Menat494bd9e2022-03-28 18:52:46 +05301153 "fieldname": "gst_transporter_id",
1154 "label": "GST Transporter ID",
1155 "fieldtype": "Data",
1156 "insert_after": "pan",
1157 "depends_on": "eval:doc.is_transporter",
Deepesh Garge3ae8d52021-10-20 22:10:21 +05301158 },
1159 {
Ankush Menat494bd9e2022-03-28 18:52:46 +05301160 "fieldname": "gst_category",
1161 "label": "GST Category",
1162 "fieldtype": "Select",
1163 "insert_after": "gst_transporter_id",
1164 "options": "Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders",
1165 "default": "Unregistered",
Deepesh Garg22b61602019-03-21 20:47:47 +05301166 },
1167 {
Ankush Menat494bd9e2022-03-28 18:52:46 +05301168 "fieldname": "export_type",
1169 "label": "Export Type",
1170 "fieldtype": "Select",
1171 "insert_after": "gst_category",
1172 "depends_on": 'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
1173 "options": "\nWith Payment of Tax\nWithout Payment of Tax",
1174 "mandatory_depends_on": 'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
1175 },
1176 ],
1177 "Customer": [
1178 {"fieldname": "pan", "label": "PAN", "fieldtype": "Data", "insert_after": "customer_type"},
1179 {
1180 "fieldname": "gst_category",
1181 "label": "GST Category",
1182 "fieldtype": "Select",
1183 "insert_after": "pan",
1184 "options": "Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders",
1185 "default": "Unregistered",
Deepesh Garg6e2c13f2019-12-10 15:55:05 +05301186 },
1187 {
Ankush Menat494bd9e2022-03-28 18:52:46 +05301188 "fieldname": "export_type",
1189 "label": "Export Type",
1190 "fieldtype": "Select",
1191 "insert_after": "gst_category",
1192 "depends_on": 'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
1193 "options": "\nWith Payment of Tax\nWithout Payment of Tax",
1194 "mandatory_depends_on": 'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
1195 },
1196 ],
1197 "Finance Book": [
1198 {
1199 "fieldname": "for_income_tax",
1200 "label": "For Income Tax",
1201 "fieldtype": "Check",
1202 "insert_after": "finance_book_name",
1203 "description": "If the asset is put to use for less than 180 days, the first Depreciation Rate will be reduced by 50%.",
Deepesh Garg22b61602019-03-21 20:47:47 +05301204 }
1205 ],
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05301206 }
Saqib Ansarif1fcb382021-09-29 19:56:02 +05301207
1208 return custom_fields
Nabin Hait9c421612017-07-20 13:32:01 +05301209
Ankush Menat494bd9e2022-03-28 18:52:46 +05301210
Saurabh2d8a7ee2018-05-11 13:16:16 +05301211def make_fixtures(company=None):
1212 docs = []
Deepesh Garga66184f2021-05-02 12:22:16 +05301213 company = company or frappe.db.get_value("Global Defaults", None, "default_company")
Saurabh2d8a7ee2018-05-11 13:16:16 +05301214
1215 set_salary_components(docs)
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301216 set_tds_account(docs, company)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05301217
1218 for d in docs:
1219 try:
1220 doc = frappe.get_doc(d)
1221 doc.flags.ignore_permissions = True
Ankush Menatcdac2b82022-04-21 20:43:07 +05301222 doc.insert(ignore_if_duplicate=True)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05301223 except frappe.NameError:
Faris Ansariec7b0642019-05-14 16:21:09 +05301224 frappe.clear_messages()
Zarrar7f8024c2018-08-01 17:45:05 +05301225 except frappe.DuplicateEntryError:
Faris Ansariec7b0642019-05-14 16:21:09 +05301226 frappe.clear_messages()
Saurabh2d8a7ee2018-05-11 13:16:16 +05301227
Zarrar7f8024c2018-08-01 17:45:05 +05301228 # create records for Tax Withholding Category
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301229 set_tax_withholding_category(company)
1230
Ankush Menat494bd9e2022-03-28 18:52:46 +05301231
Deepesh Gargb3ed8072021-06-02 13:26:21 +05301232def update_regional_tax_settings(country, company):
Deepesh Garg1bac72b2021-05-02 22:29:48 +05301233 # Will only add default GST accounts if present
Ankush Menat494bd9e2022-03-28 18:52:46 +05301234 input_account_names = ["Input Tax CGST", "Input Tax SGST", "Input Tax IGST"]
1235 output_account_names = ["Output Tax CGST", "Output Tax SGST", "Output Tax IGST"]
1236 rcm_accounts = ["Input Tax CGST RCM", "Input Tax SGST RCM", "Input Tax IGST RCM"]
1237 gst_settings = frappe.get_single("GST Settings")
Deepesh Garg1bac72b2021-05-02 22:29:48 +05301238 existing_account_list = []
1239
Ankush Menat494bd9e2022-03-28 18:52:46 +05301240 for account in gst_settings.get("gst_accounts"):
1241 for key in ["cgst_account", "sgst_account", "igst_account"]:
Deepesh Garg1bac72b2021-05-02 22:29:48 +05301242 existing_account_list.append(account.get(key))
1243
Ankush Menat494bd9e2022-03-28 18:52:46 +05301244 gst_accounts = frappe._dict(
1245 frappe.get_all(
1246 "Account",
1247 {
1248 "company": company,
1249 "account_name": ("in", input_account_names + output_account_names + rcm_accounts),
1250 },
1251 ["account_name", "name"],
1252 as_list=1,
1253 )
1254 )
Deepesh Garg1bac72b2021-05-02 22:29:48 +05301255
Ankush Menat494bd9e2022-03-28 18:52:46 +05301256 add_accounts_in_gst_settings(
1257 company, input_account_names, gst_accounts, existing_account_list, gst_settings
1258 )
1259 add_accounts_in_gst_settings(
1260 company, output_account_names, gst_accounts, existing_account_list, gst_settings
1261 )
1262 add_accounts_in_gst_settings(
1263 company, rcm_accounts, gst_accounts, existing_account_list, gst_settings, is_reverse_charge=1
1264 )
Deepesh Garg1bac72b2021-05-02 22:29:48 +05301265
1266 gst_settings.save()
1267
Ankush Menat494bd9e2022-03-28 18:52:46 +05301268
1269def add_accounts_in_gst_settings(
1270 company, account_names, gst_accounts, existing_account_list, gst_settings, is_reverse_charge=0
1271):
Deepesh Garg48b1a822021-05-29 23:54:51 +05301272 accounts_not_added = 1
1273
1274 for account in account_names:
1275 # Default Account Added does not exists
1276 if not gst_accounts.get(account):
1277 accounts_not_added = 0
1278
1279 # Check if already added in GST Settings
1280 if gst_accounts.get(account) in existing_account_list:
1281 accounts_not_added = 0
1282
1283 if accounts_not_added:
Ankush Menat494bd9e2022-03-28 18:52:46 +05301284 gst_settings.append(
1285 "gst_accounts",
1286 {
1287 "company": company,
1288 "cgst_account": gst_accounts.get(account_names[0]),
1289 "sgst_account": gst_accounts.get(account_names[1]),
1290 "igst_account": gst_accounts.get(account_names[2]),
1291 "is_reverse_charge_account": is_reverse_charge,
1292 },
1293 )
1294
Deepesh Garg48b1a822021-05-29 23:54:51 +05301295
Saurabh2d8a7ee2018-05-11 13:16:16 +05301296def set_salary_components(docs):
Ankush Menat494bd9e2022-03-28 18:52:46 +05301297 docs.extend(
1298 [
1299 {
1300 "doctype": "Salary Component",
1301 "salary_component": "Professional Tax",
1302 "description": "Professional Tax",
1303 "type": "Deduction",
1304 "exempted_from_income_tax": 1,
1305 },
1306 {
1307 "doctype": "Salary Component",
1308 "salary_component": "Provident Fund",
1309 "description": "Provident fund",
1310 "type": "Deduction",
1311 "is_tax_applicable": 1,
1312 },
1313 {
1314 "doctype": "Salary Component",
1315 "salary_component": "House Rent Allowance",
1316 "description": "House Rent Allowance",
1317 "type": "Earning",
1318 "is_tax_applicable": 1,
1319 },
1320 {
1321 "doctype": "Salary Component",
1322 "salary_component": "Basic",
1323 "description": "Basic",
1324 "type": "Earning",
1325 "is_tax_applicable": 1,
1326 },
1327 {
1328 "doctype": "Salary Component",
1329 "salary_component": "Arrear",
1330 "description": "Arrear",
1331 "type": "Earning",
1332 "is_tax_applicable": 1,
1333 },
1334 {
1335 "doctype": "Salary Component",
1336 "salary_component": "Leave Encashment",
1337 "description": "Leave Encashment",
1338 "type": "Earning",
1339 "is_tax_applicable": 1,
1340 },
1341 ]
1342 )
1343
Saurabh2d8a7ee2018-05-11 13:16:16 +05301344
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301345def set_tax_withholding_category(company):
Saurabh2d8a7ee2018-05-11 13:16:16 +05301346 accounts = []
Saqibf8c1c732021-09-26 16:27:56 +05301347 fiscal_year_details = None
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301348 abbr = frappe.get_value("Company", company, "abbr")
Ankush Menat494bd9e2022-03-28 18:52:46 +05301349 tds_account = frappe.get_value("Account", "TDS Payable - {0}".format(abbr), "name")
Saurabh2d8a7ee2018-05-11 13:16:16 +05301350
1351 if company and tds_account:
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301352 accounts = [dict(company=company, account=tds_account)]
Saurabh2d8a7ee2018-05-11 13:16:16 +05301353
Anuja Pawar4569e522021-01-14 19:24:30 +05301354 try:
Subin Tom350ed1a2021-11-19 21:05:25 +05301355 fiscal_year_details = get_fiscal_year(today(), verbose=0)
Anuja Pawar4569e522021-01-14 19:24:30 +05301356 except FiscalYearError:
1357 pass
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301358
Deepesh Gargc53b78e2021-09-14 20:28:48 +05301359 docs = get_tds_details(accounts, fiscal_year_details)
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +05301360
Zarrar7f8024c2018-08-01 17:45:05 +05301361 for d in docs:
Deepesh Garg66a71bd2021-04-21 20:42:20 +05301362 if not frappe.db.exists("Tax Withholding Category", d.get("name")):
Zarrar7f8024c2018-08-01 17:45:05 +05301363 doc = frappe.get_doc(d)
Deepesh Garg204ea102021-04-30 16:35:52 +05301364 doc.flags.ignore_validate = True
Zarrar7f8024c2018-08-01 17:45:05 +05301365 doc.flags.ignore_permissions = True
Nabin Haitafef9c12019-02-12 11:28:20 +05301366 doc.flags.ignore_mandatory = True
Zarrar7f8024c2018-08-01 17:45:05 +05301367 doc.insert()
Deepesh Garg66a71bd2021-04-21 20:42:20 +05301368 else:
Deepesh Gargfea29ae2021-07-12 18:29:52 +05301369 doc = frappe.get_doc("Tax Withholding Category", d.get("name"), for_update=True)
Zarrar963d62b2019-03-23 10:30:12 +05301370
1371 if accounts:
1372 doc.append("accounts", accounts[0])
Zarrar7f8024c2018-08-01 17:45:05 +05301373
Deepesh Gargc53b78e2021-09-14 20:28:48 +05301374 if fiscal_year_details:
Anuja Pawar4569e522021-01-14 19:24:30 +05301375 # if fiscal year don't match with any of the already entered data, append rate row
Ankush Menat494bd9e2022-03-28 18:52:46 +05301376 fy_exist = [
1377 k
1378 for k in doc.get("rates")
1379 if k.get("from_date") <= fiscal_year_details[1] and k.get("to_date") >= fiscal_year_details[2]
1380 ]
Anuja Pawar4569e522021-01-14 19:24:30 +05301381 if not fy_exist:
Ankush Menat494bd9e2022-03-28 18:52:46 +05301382 doc.append("rates", d.get("rates")[0])
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +05301383
Anuja Pawar4569e522021-01-14 19:24:30 +05301384 doc.flags.ignore_permissions = True
Deepesh Garg48b1a822021-05-29 23:54:51 +05301385 doc.flags.ignore_validate = True
Anuja Pawar4569e522021-01-14 19:24:30 +05301386 doc.flags.ignore_mandatory = True
Deepesh Garg204ea102021-04-30 16:35:52 +05301387 doc.flags.ignore_links = True
Zarrar7f8024c2018-08-01 17:45:05 +05301388 doc.save()
Saurabh2d8a7ee2018-05-11 13:16:16 +05301389
Ankush Menat494bd9e2022-03-28 18:52:46 +05301390
Saurabh2d8a7ee2018-05-11 13:16:16 +05301391def set_tds_account(docs, company):
Ankush Menat494bd9e2022-03-28 18:52:46 +05301392 parent_account = frappe.db.get_value(
1393 "Account", filters={"account_name": "Duties and Taxes", "company": company}
1394 )
Nabin Haitf77cd542018-11-20 16:46:25 +05301395 if parent_account:
Ankush Menat494bd9e2022-03-28 18:52:46 +05301396 docs.extend(
1397 [
1398 {
1399 "doctype": "Account",
1400 "account_name": "TDS Payable",
1401 "account_type": "Tax",
1402 "parent_account": parent_account,
1403 "company": company,
1404 }
1405 ]
1406 )
1407
Zarrar7f8024c2018-08-01 17:45:05 +05301408
Deepesh Gargc53b78e2021-09-14 20:28:48 +05301409def get_tds_details(accounts, fiscal_year_details):
Zarrar7f8024c2018-08-01 17:45:05 +05301410 # bootstrap default tax withholding sections
1411 return [
Ankush Menat494bd9e2022-03-28 18:52:46 +05301412 dict(
1413 name="TDS - 194C - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301414 category_name="Payment to Contractors (Single / Aggregate)",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301415 doctype="Tax Withholding Category",
1416 accounts=accounts,
1417 rates=[
1418 {
1419 "from_date": fiscal_year_details[1],
1420 "to_date": fiscal_year_details[2],
1421 "tax_withholding_rate": 2,
1422 "single_threshold": 30000,
1423 "cumulative_threshold": 100000,
1424 }
1425 ],
1426 ),
1427 dict(
1428 name="TDS - 194C - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301429 category_name="Payment to Contractors (Single / Aggregate)",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301430 doctype="Tax Withholding Category",
1431 accounts=accounts,
1432 rates=[
1433 {
1434 "from_date": fiscal_year_details[1],
1435 "to_date": fiscal_year_details[2],
1436 "tax_withholding_rate": 1,
1437 "single_threshold": 30000,
1438 "cumulative_threshold": 100000,
1439 }
1440 ],
1441 ),
1442 dict(
1443 name="TDS - 194C - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301444 category_name="Payment to Contractors (Single / Aggregate)",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301445 doctype="Tax Withholding Category",
1446 accounts=accounts,
1447 rates=[
1448 {
1449 "from_date": fiscal_year_details[1],
1450 "to_date": fiscal_year_details[2],
1451 "tax_withholding_rate": 20,
1452 "single_threshold": 30000,
1453 "cumulative_threshold": 100000,
1454 }
1455 ],
1456 ),
1457 dict(
1458 name="TDS - 194D - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301459 category_name="Insurance Commission",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301460 doctype="Tax Withholding Category",
1461 accounts=accounts,
1462 rates=[
1463 {
1464 "from_date": fiscal_year_details[1],
1465 "to_date": fiscal_year_details[2],
1466 "tax_withholding_rate": 5,
1467 "single_threshold": 15000,
1468 "cumulative_threshold": 0,
1469 }
1470 ],
1471 ),
1472 dict(
1473 name="TDS - 194D - Company Assessee",
Zarrar7f8024c2018-08-01 17:45:05 +05301474 category_name="Insurance Commission",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301475 doctype="Tax Withholding Category",
1476 accounts=accounts,
1477 rates=[
1478 {
1479 "from_date": fiscal_year_details[1],
1480 "to_date": fiscal_year_details[2],
1481 "tax_withholding_rate": 10,
1482 "single_threshold": 15000,
1483 "cumulative_threshold": 0,
1484 }
1485 ],
1486 ),
1487 dict(
1488 name="TDS - 194D - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301489 category_name="Insurance Commission",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301490 doctype="Tax Withholding Category",
1491 accounts=accounts,
1492 rates=[
1493 {
1494 "from_date": fiscal_year_details[1],
1495 "to_date": fiscal_year_details[2],
1496 "tax_withholding_rate": 5,
1497 "single_threshold": 15000,
1498 "cumulative_threshold": 0,
1499 }
1500 ],
1501 ),
1502 dict(
1503 name="TDS - 194D - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301504 category_name="Insurance Commission",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301505 doctype="Tax Withholding Category",
1506 accounts=accounts,
1507 rates=[
1508 {
1509 "from_date": fiscal_year_details[1],
1510 "to_date": fiscal_year_details[2],
1511 "tax_withholding_rate": 20,
1512 "single_threshold": 15000,
1513 "cumulative_threshold": 0,
1514 }
1515 ],
1516 ),
1517 dict(
1518 name="TDS - 194DA - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301519 category_name="Non-exempt payments made under a life insurance policy",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301520 doctype="Tax Withholding Category",
1521 accounts=accounts,
1522 rates=[
1523 {
1524 "from_date": fiscal_year_details[1],
1525 "to_date": fiscal_year_details[2],
1526 "tax_withholding_rate": 1,
1527 "single_threshold": 100000,
1528 "cumulative_threshold": 0,
1529 }
1530 ],
1531 ),
1532 dict(
1533 name="TDS - 194DA - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301534 category_name="Non-exempt payments made under a life insurance policy",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301535 doctype="Tax Withholding Category",
1536 accounts=accounts,
1537 rates=[
1538 {
1539 "from_date": fiscal_year_details[1],
1540 "to_date": fiscal_year_details[2],
1541 "tax_withholding_rate": 1,
1542 "single_threshold": 100000,
1543 "cumulative_threshold": 0,
1544 }
1545 ],
1546 ),
1547 dict(
1548 name="TDS - 194DA - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301549 category_name="Non-exempt payments made under a life insurance policy",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301550 doctype="Tax Withholding Category",
1551 accounts=accounts,
1552 rates=[
1553 {
1554 "from_date": fiscal_year_details[1],
1555 "to_date": fiscal_year_details[2],
1556 "tax_withholding_rate": 20,
1557 "single_threshold": 100000,
1558 "cumulative_threshold": 0,
1559 }
1560 ],
1561 ),
1562 dict(
1563 name="TDS - 194H - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301564 category_name="Commission / Brokerage",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301565 doctype="Tax Withholding Category",
1566 accounts=accounts,
1567 rates=[
1568 {
1569 "from_date": fiscal_year_details[1],
1570 "to_date": fiscal_year_details[2],
1571 "tax_withholding_rate": 5,
1572 "single_threshold": 15000,
1573 "cumulative_threshold": 0,
1574 }
1575 ],
1576 ),
1577 dict(
1578 name="TDS - 194H - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301579 category_name="Commission / Brokerage",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301580 doctype="Tax Withholding Category",
1581 accounts=accounts,
1582 rates=[
1583 {
1584 "from_date": fiscal_year_details[1],
1585 "to_date": fiscal_year_details[2],
1586 "tax_withholding_rate": 5,
1587 "single_threshold": 15000,
1588 "cumulative_threshold": 0,
1589 }
1590 ],
1591 ),
1592 dict(
1593 name="TDS - 194H - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301594 category_name="Commission / Brokerage",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301595 doctype="Tax Withholding Category",
1596 accounts=accounts,
1597 rates=[
1598 {
1599 "from_date": fiscal_year_details[1],
1600 "to_date": fiscal_year_details[2],
1601 "tax_withholding_rate": 20,
1602 "single_threshold": 15000,
1603 "cumulative_threshold": 0,
1604 }
1605 ],
1606 ),
1607 dict(
1608 name="TDS - 194I - Rent - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301609 category_name="Rent",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301610 doctype="Tax Withholding Category",
1611 accounts=accounts,
1612 rates=[
1613 {
1614 "from_date": fiscal_year_details[1],
1615 "to_date": fiscal_year_details[2],
1616 "tax_withholding_rate": 10,
1617 "single_threshold": 180000,
1618 "cumulative_threshold": 0,
1619 }
1620 ],
1621 ),
1622 dict(
1623 name="TDS - 194I - Rent - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301624 category_name="Rent",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301625 doctype="Tax Withholding Category",
1626 accounts=accounts,
1627 rates=[
1628 {
1629 "from_date": fiscal_year_details[1],
1630 "to_date": fiscal_year_details[2],
1631 "tax_withholding_rate": 10,
1632 "single_threshold": 180000,
1633 "cumulative_threshold": 0,
1634 }
1635 ],
1636 ),
1637 dict(
1638 name="TDS - 194I - Rent - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301639 category_name="Rent",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301640 doctype="Tax Withholding Category",
1641 accounts=accounts,
1642 rates=[
1643 {
1644 "from_date": fiscal_year_details[1],
1645 "to_date": fiscal_year_details[2],
1646 "tax_withholding_rate": 20,
1647 "single_threshold": 180000,
1648 "cumulative_threshold": 0,
1649 }
1650 ],
1651 ),
1652 dict(
1653 name="TDS - 194I - Rent/Machinery - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301654 category_name="Rent-Plant / Machinery",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301655 doctype="Tax Withholding Category",
1656 accounts=accounts,
1657 rates=[
1658 {
1659 "from_date": fiscal_year_details[1],
1660 "to_date": fiscal_year_details[2],
1661 "tax_withholding_rate": 2,
1662 "single_threshold": 180000,
1663 "cumulative_threshold": 0,
1664 }
1665 ],
1666 ),
1667 dict(
1668 name="TDS - 194I - Rent/Machinery - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301669 category_name="Rent-Plant / Machinery",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301670 doctype="Tax Withholding Category",
1671 accounts=accounts,
1672 rates=[
1673 {
1674 "from_date": fiscal_year_details[1],
1675 "to_date": fiscal_year_details[2],
1676 "tax_withholding_rate": 2,
1677 "single_threshold": 180000,
1678 "cumulative_threshold": 0,
1679 }
1680 ],
1681 ),
1682 dict(
1683 name="TDS - 194I - Rent/Machinery - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301684 category_name="Rent-Plant / Machinery",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301685 doctype="Tax Withholding Category",
1686 accounts=accounts,
1687 rates=[
1688 {
1689 "from_date": fiscal_year_details[1],
1690 "to_date": fiscal_year_details[2],
1691 "tax_withholding_rate": 20,
1692 "single_threshold": 180000,
1693 "cumulative_threshold": 0,
1694 }
1695 ],
1696 ),
1697 dict(
1698 name="TDS - 194J - Professional Fees - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301699 category_name="Professional Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301700 doctype="Tax Withholding Category",
1701 accounts=accounts,
1702 rates=[
1703 {
1704 "from_date": fiscal_year_details[1],
1705 "to_date": fiscal_year_details[2],
1706 "tax_withholding_rate": 10,
1707 "single_threshold": 30000,
1708 "cumulative_threshold": 0,
1709 }
1710 ],
1711 ),
1712 dict(
1713 name="TDS - 194J - Professional Fees - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301714 category_name="Professional Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301715 doctype="Tax Withholding Category",
1716 accounts=accounts,
1717 rates=[
1718 {
1719 "from_date": fiscal_year_details[1],
1720 "to_date": fiscal_year_details[2],
1721 "tax_withholding_rate": 10,
1722 "single_threshold": 30000,
1723 "cumulative_threshold": 0,
1724 }
1725 ],
1726 ),
1727 dict(
1728 name="TDS - 194J - Professional Fees - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301729 category_name="Professional Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301730 doctype="Tax Withholding Category",
1731 accounts=accounts,
1732 rates=[
1733 {
1734 "from_date": fiscal_year_details[1],
1735 "to_date": fiscal_year_details[2],
1736 "tax_withholding_rate": 20,
1737 "single_threshold": 30000,
1738 "cumulative_threshold": 0,
1739 }
1740 ],
1741 ),
1742 dict(
1743 name="TDS - 194J - Director Fees - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301744 category_name="Director Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301745 doctype="Tax Withholding Category",
1746 accounts=accounts,
1747 rates=[
1748 {
1749 "from_date": fiscal_year_details[1],
1750 "to_date": fiscal_year_details[2],
1751 "tax_withholding_rate": 10,
1752 "single_threshold": 0,
1753 "cumulative_threshold": 0,
1754 }
1755 ],
1756 ),
1757 dict(
1758 name="TDS - 194J - Director Fees - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301759 category_name="Director Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301760 doctype="Tax Withholding Category",
1761 accounts=accounts,
1762 rates=[
1763 {
1764 "from_date": fiscal_year_details[1],
1765 "to_date": fiscal_year_details[2],
1766 "tax_withholding_rate": 10,
1767 "single_threshold": 0,
1768 "cumulative_threshold": 0,
1769 }
1770 ],
1771 ),
1772 dict(
1773 name="TDS - 194J - Director Fees - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301774 category_name="Director Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301775 doctype="Tax Withholding Category",
1776 accounts=accounts,
1777 rates=[
1778 {
1779 "from_date": fiscal_year_details[1],
1780 "to_date": fiscal_year_details[2],
1781 "tax_withholding_rate": 20,
1782 "single_threshold": 0,
1783 "cumulative_threshold": 0,
1784 }
1785 ],
1786 ),
1787 dict(
1788 name="TDS - 194 - Dividends - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301789 category_name="Dividends",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301790 doctype="Tax Withholding Category",
1791 accounts=accounts,
1792 rates=[
1793 {
1794 "from_date": fiscal_year_details[1],
1795 "to_date": fiscal_year_details[2],
1796 "tax_withholding_rate": 10,
1797 "single_threshold": 2500,
1798 "cumulative_threshold": 0,
1799 }
1800 ],
1801 ),
1802 dict(
1803 name="TDS - 194 - Dividends - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301804 category_name="Dividends",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301805 doctype="Tax Withholding Category",
1806 accounts=accounts,
1807 rates=[
1808 {
1809 "from_date": fiscal_year_details[1],
1810 "to_date": fiscal_year_details[2],
1811 "tax_withholding_rate": 10,
1812 "single_threshold": 2500,
1813 "cumulative_threshold": 0,
1814 }
1815 ],
1816 ),
1817 dict(
1818 name="TDS - 194 - Dividends - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301819 category_name="Dividends",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301820 doctype="Tax Withholding Category",
1821 accounts=accounts,
1822 rates=[
1823 {
1824 "from_date": fiscal_year_details[1],
1825 "to_date": fiscal_year_details[2],
1826 "tax_withholding_rate": 20,
1827 "single_threshold": 2500,
1828 "cumulative_threshold": 0,
1829 }
1830 ],
1831 ),
Anurag Mishrae1464a72020-08-17 15:03:32 +05301832 ]
1833
Ankush Menat494bd9e2022-03-28 18:52:46 +05301834
Anurag Mishra25c35682020-08-18 14:13:54 +05301835def create_gratuity_rule():
Anurag Mishrae1464a72020-08-17 15:03:32 +05301836 # Standard Indain Gratuity Rule
Anurag Mishra493eea12020-08-18 15:02:32 +05301837 if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
1838 rule = frappe.new_doc("Gratuity Rule")
1839 rule.name = "Indian Standard Gratuity Rule"
1840 rule.calculate_gratuity_amount_based_on = "Current Slab"
1841 rule.work_experience_calculation_method = "Round Off Work Experience"
1842 rule.minimum_year_for_gratuity = 5
Anurag Mishrae1464a72020-08-17 15:03:32 +05301843
Ankush Menat494bd9e2022-03-28 18:52:46 +05301844 fraction = 15 / 26
1845 rule.append(
1846 "gratuity_rule_slabs",
1847 {"from_year": 0, "to_year": 0, "fraction_of_applicable_earnings": fraction},
1848 )
Anurag Mishrae1464a72020-08-17 15:03:32 +05301849
Anurag Mishra493eea12020-08-18 15:02:32 +05301850 rule.flags.ignore_mandatory = True
Sagar Vora4c31fbb2021-04-01 15:32:37 +05301851 rule.save()
Deepesh Garg204ea102021-04-30 16:35:52 +05301852
Ankush Menat494bd9e2022-03-28 18:52:46 +05301853
Deepesh Garg204ea102021-04-30 16:35:52 +05301854def update_accounts_settings_for_taxes():
Ankush Menat494bd9e2022-03-28 18:52:46 +05301855 if frappe.db.count("Company") == 1:
1856 frappe.db.set_value("Accounts Settings", None, "add_taxes_from_item_tax_template", 0)