blob: 40fa6cd097c439e820a068178683b92a0dcfe6ba [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,
933 "Item": [
934 dict(
935 fieldname="gst_hsn_code",
936 label="HSN/SAC",
937 fieldtype="Link",
938 options="GST HSN Code",
939 insert_after="item_group",
940 ),
941 dict(
942 fieldname="is_nil_exempt",
943 label="Is Nil Rated or Exempted",
944 fieldtype="Check",
945 insert_after="gst_hsn_code",
946 ),
947 dict(
948 fieldname="is_non_gst", label="Is Non GST ", fieldtype="Check", insert_after="is_nil_exempt"
949 ),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530950 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +0530951 "Quotation Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
952 "Supplier Quotation Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
953 "Sales Order Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
954 "Delivery Note Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
955 "Sales Invoice Item": [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
956 "POS Invoice Item": [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
957 "Purchase Order Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
958 "Purchase Receipt Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
959 "Purchase Invoice Item": [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
960 "Material Request Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
961 "Salary Component": [
962 dict(
963 fieldname="component_type",
964 label="Component Type",
965 fieldtype="Select",
966 insert_after="description",
967 options="\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax",
968 depends_on='eval:doc.type == "Deduction"',
Anurag Mishra289c8222020-06-19 19:17:57 +0530969 )
970 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +0530971 "Employee": [
972 dict(
973 fieldname="ifsc_code",
974 label="IFSC Code",
975 fieldtype="Data",
976 insert_after="bank_ac_no",
Anurag Mishra289c8222020-06-19 19:17:57 +0530977 print_hide=1,
Ankush Menat494bd9e2022-03-28 18:52:46 +0530978 depends_on='eval:doc.salary_mode == "Bank"',
Anurag Mishra289c8222020-06-19 19:17:57 +0530979 ),
980 dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530981 fieldname="pan_number",
982 label="PAN Number",
983 fieldtype="Data",
984 insert_after="payroll_cost_center",
985 print_hide=1,
Anurag Mishra289c8222020-06-19 19:17:57 +0530986 ),
987 dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530988 fieldname="micr_code",
989 label="MICR Code",
990 fieldtype="Data",
991 insert_after="ifsc_code",
992 print_hide=1,
993 depends_on='eval:doc.salary_mode == "Bank"',
994 ),
995 dict(
996 fieldname="provident_fund_account",
997 label="Provident Fund Account",
998 fieldtype="Data",
999 insert_after="pan_number",
1000 ),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +05301001 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +05301002 "Company": [
1003 dict(
1004 fieldname="hra_section",
1005 label="HRA Settings",
1006 fieldtype="Section Break",
1007 insert_after="asset_received_but_not_billed",
1008 collapsible=1,
1009 ),
1010 dict(
1011 fieldname="basic_component",
1012 label="Basic Component",
1013 fieldtype="Link",
1014 options="Salary Component",
1015 insert_after="hra_section",
1016 ),
1017 dict(
1018 fieldname="hra_component",
1019 label="HRA Component",
1020 fieldtype="Link",
1021 options="Salary Component",
1022 insert_after="basic_component",
1023 ),
1024 dict(fieldname="hra_column_break", fieldtype="Column Break", insert_after="hra_component"),
1025 dict(
1026 fieldname="arrear_component",
1027 label="Arrear Component",
1028 fieldtype="Link",
1029 options="Salary Component",
1030 insert_after="hra_column_break",
1031 ),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +05301032 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +05301033 "Employee Tax Exemption Declaration": [
1034 dict(
1035 fieldname="hra_section",
1036 label="HRA Exemption",
1037 fieldtype="Section Break",
1038 insert_after="declarations",
1039 ),
1040 dict(
1041 fieldname="monthly_house_rent",
1042 label="Monthly House Rent",
1043 fieldtype="Currency",
1044 insert_after="hra_section",
1045 ),
1046 dict(
1047 fieldname="rented_in_metro_city",
1048 label="Rented in Metro City",
1049 fieldtype="Check",
1050 insert_after="monthly_house_rent",
1051 depends_on="monthly_house_rent",
1052 ),
1053 dict(
1054 fieldname="salary_structure_hra",
1055 label="HRA as per Salary Structure",
1056 fieldtype="Currency",
1057 insert_after="rented_in_metro_city",
1058 read_only=1,
1059 depends_on="monthly_house_rent",
1060 ),
1061 dict(
1062 fieldname="hra_column_break",
1063 fieldtype="Column Break",
1064 insert_after="salary_structure_hra",
1065 depends_on="monthly_house_rent",
1066 ),
1067 dict(
1068 fieldname="annual_hra_exemption",
1069 label="Annual HRA Exemption",
1070 fieldtype="Currency",
1071 insert_after="hra_column_break",
1072 read_only=1,
1073 depends_on="monthly_house_rent",
1074 ),
1075 dict(
1076 fieldname="monthly_hra_exemption",
1077 label="Monthly HRA Exemption",
1078 fieldtype="Currency",
1079 insert_after="annual_hra_exemption",
1080 read_only=1,
1081 depends_on="monthly_house_rent",
1082 ),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +05301083 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +05301084 "Employee Tax Exemption Proof Submission": [
1085 dict(
1086 fieldname="hra_section",
1087 label="HRA Exemption",
1088 fieldtype="Section Break",
1089 insert_after="tax_exemption_proofs",
1090 ),
1091 dict(
1092 fieldname="house_rent_payment_amount",
1093 label="House Rent Payment Amount",
1094 fieldtype="Currency",
1095 insert_after="hra_section",
1096 ),
1097 dict(
1098 fieldname="rented_in_metro_city",
1099 label="Rented in Metro City",
1100 fieldtype="Check",
1101 insert_after="house_rent_payment_amount",
1102 depends_on="house_rent_payment_amount",
1103 ),
1104 dict(
1105 fieldname="rented_from_date",
1106 label="Rented From Date",
1107 fieldtype="Date",
1108 insert_after="rented_in_metro_city",
1109 depends_on="house_rent_payment_amount",
1110 ),
1111 dict(
1112 fieldname="rented_to_date",
1113 label="Rented To Date",
1114 fieldtype="Date",
1115 insert_after="rented_from_date",
1116 depends_on="house_rent_payment_amount",
1117 ),
1118 dict(
1119 fieldname="hra_column_break",
1120 fieldtype="Column Break",
1121 insert_after="rented_to_date",
1122 depends_on="house_rent_payment_amount",
1123 ),
1124 dict(
1125 fieldname="monthly_house_rent",
1126 label="Monthly House Rent",
1127 fieldtype="Currency",
1128 insert_after="hra_column_break",
1129 read_only=1,
1130 depends_on="house_rent_payment_amount",
1131 ),
1132 dict(
1133 fieldname="monthly_hra_exemption",
1134 label="Monthly Eligible Amount",
1135 fieldtype="Currency",
1136 insert_after="monthly_house_rent",
1137 read_only=1,
1138 depends_on="house_rent_payment_amount",
1139 ),
1140 dict(
1141 fieldname="total_eligible_hra_exemption",
1142 label="Total Eligible HRA Exemption",
1143 fieldtype="Currency",
1144 insert_after="monthly_hra_exemption",
1145 read_only=1,
1146 depends_on="house_rent_payment_amount",
1147 ),
Sagar Vorad92f3ac2018-10-10 14:51:26 +05301148 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +05301149 "Supplier": [
1150 {"fieldname": "pan", "label": "PAN", "fieldtype": "Data", "insert_after": "supplier_type"},
Sagar Vorad92f3ac2018-10-10 14:51:26 +05301151 {
Ankush Menat494bd9e2022-03-28 18:52:46 +05301152 "fieldname": "gst_transporter_id",
1153 "label": "GST Transporter ID",
1154 "fieldtype": "Data",
1155 "insert_after": "pan",
1156 "depends_on": "eval:doc.is_transporter",
Deepesh Garge3ae8d52021-10-20 22:10:21 +05301157 },
1158 {
Ankush Menat494bd9e2022-03-28 18:52:46 +05301159 "fieldname": "gst_category",
1160 "label": "GST Category",
1161 "fieldtype": "Select",
1162 "insert_after": "gst_transporter_id",
1163 "options": "Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders",
1164 "default": "Unregistered",
Deepesh Garg22b61602019-03-21 20:47:47 +05301165 },
1166 {
Ankush Menat494bd9e2022-03-28 18:52:46 +05301167 "fieldname": "export_type",
1168 "label": "Export Type",
1169 "fieldtype": "Select",
1170 "insert_after": "gst_category",
1171 "depends_on": 'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
1172 "options": "\nWith Payment of Tax\nWithout Payment of Tax",
1173 "mandatory_depends_on": 'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
1174 },
1175 ],
1176 "Customer": [
1177 {"fieldname": "pan", "label": "PAN", "fieldtype": "Data", "insert_after": "customer_type"},
1178 {
1179 "fieldname": "gst_category",
1180 "label": "GST Category",
1181 "fieldtype": "Select",
1182 "insert_after": "pan",
1183 "options": "Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders",
1184 "default": "Unregistered",
Deepesh Garg6e2c13f2019-12-10 15:55:05 +05301185 },
1186 {
Ankush Menat494bd9e2022-03-28 18:52:46 +05301187 "fieldname": "export_type",
1188 "label": "Export Type",
1189 "fieldtype": "Select",
1190 "insert_after": "gst_category",
1191 "depends_on": 'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
1192 "options": "\nWith Payment of Tax\nWithout Payment of Tax",
1193 "mandatory_depends_on": 'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
1194 },
1195 ],
1196 "Finance Book": [
1197 {
1198 "fieldname": "for_income_tax",
1199 "label": "For Income Tax",
1200 "fieldtype": "Check",
1201 "insert_after": "finance_book_name",
1202 "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 +05301203 }
1204 ],
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05301205 }
Saqib Ansarif1fcb382021-09-29 19:56:02 +05301206
1207 return custom_fields
Nabin Hait9c421612017-07-20 13:32:01 +05301208
Ankush Menat494bd9e2022-03-28 18:52:46 +05301209
Saurabh2d8a7ee2018-05-11 13:16:16 +05301210def make_fixtures(company=None):
1211 docs = []
Deepesh Garga66184f2021-05-02 12:22:16 +05301212 company = company or frappe.db.get_value("Global Defaults", None, "default_company")
Saurabh2d8a7ee2018-05-11 13:16:16 +05301213
1214 set_salary_components(docs)
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301215 set_tds_account(docs, company)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05301216
1217 for d in docs:
1218 try:
1219 doc = frappe.get_doc(d)
1220 doc.flags.ignore_permissions = True
1221 doc.insert()
1222 except frappe.NameError:
Faris Ansariec7b0642019-05-14 16:21:09 +05301223 frappe.clear_messages()
Zarrar7f8024c2018-08-01 17:45:05 +05301224 except frappe.DuplicateEntryError:
Faris Ansariec7b0642019-05-14 16:21:09 +05301225 frappe.clear_messages()
Saurabh2d8a7ee2018-05-11 13:16:16 +05301226
Zarrar7f8024c2018-08-01 17:45:05 +05301227 # create records for Tax Withholding Category
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301228 set_tax_withholding_category(company)
1229
Ankush Menat494bd9e2022-03-28 18:52:46 +05301230
Deepesh Gargb3ed8072021-06-02 13:26:21 +05301231def update_regional_tax_settings(country, company):
Deepesh Garg1bac72b2021-05-02 22:29:48 +05301232 # Will only add default GST accounts if present
Ankush Menat494bd9e2022-03-28 18:52:46 +05301233 input_account_names = ["Input Tax CGST", "Input Tax SGST", "Input Tax IGST"]
1234 output_account_names = ["Output Tax CGST", "Output Tax SGST", "Output Tax IGST"]
1235 rcm_accounts = ["Input Tax CGST RCM", "Input Tax SGST RCM", "Input Tax IGST RCM"]
1236 gst_settings = frappe.get_single("GST Settings")
Deepesh Garg1bac72b2021-05-02 22:29:48 +05301237 existing_account_list = []
1238
Ankush Menat494bd9e2022-03-28 18:52:46 +05301239 for account in gst_settings.get("gst_accounts"):
1240 for key in ["cgst_account", "sgst_account", "igst_account"]:
Deepesh Garg1bac72b2021-05-02 22:29:48 +05301241 existing_account_list.append(account.get(key))
1242
Ankush Menat494bd9e2022-03-28 18:52:46 +05301243 gst_accounts = frappe._dict(
1244 frappe.get_all(
1245 "Account",
1246 {
1247 "company": company,
1248 "account_name": ("in", input_account_names + output_account_names + rcm_accounts),
1249 },
1250 ["account_name", "name"],
1251 as_list=1,
1252 )
1253 )
Deepesh Garg1bac72b2021-05-02 22:29:48 +05301254
Ankush Menat494bd9e2022-03-28 18:52:46 +05301255 add_accounts_in_gst_settings(
1256 company, input_account_names, gst_accounts, existing_account_list, gst_settings
1257 )
1258 add_accounts_in_gst_settings(
1259 company, output_account_names, gst_accounts, existing_account_list, gst_settings
1260 )
1261 add_accounts_in_gst_settings(
1262 company, rcm_accounts, gst_accounts, existing_account_list, gst_settings, is_reverse_charge=1
1263 )
Deepesh Garg1bac72b2021-05-02 22:29:48 +05301264
1265 gst_settings.save()
1266
Ankush Menat494bd9e2022-03-28 18:52:46 +05301267
1268def add_accounts_in_gst_settings(
1269 company, account_names, gst_accounts, existing_account_list, gst_settings, is_reverse_charge=0
1270):
Deepesh Garg48b1a822021-05-29 23:54:51 +05301271 accounts_not_added = 1
1272
1273 for account in account_names:
1274 # Default Account Added does not exists
1275 if not gst_accounts.get(account):
1276 accounts_not_added = 0
1277
1278 # Check if already added in GST Settings
1279 if gst_accounts.get(account) in existing_account_list:
1280 accounts_not_added = 0
1281
1282 if accounts_not_added:
Ankush Menat494bd9e2022-03-28 18:52:46 +05301283 gst_settings.append(
1284 "gst_accounts",
1285 {
1286 "company": company,
1287 "cgst_account": gst_accounts.get(account_names[0]),
1288 "sgst_account": gst_accounts.get(account_names[1]),
1289 "igst_account": gst_accounts.get(account_names[2]),
1290 "is_reverse_charge_account": is_reverse_charge,
1291 },
1292 )
1293
Deepesh Garg48b1a822021-05-29 23:54:51 +05301294
Saurabh2d8a7ee2018-05-11 13:16:16 +05301295def set_salary_components(docs):
Ankush Menat494bd9e2022-03-28 18:52:46 +05301296 docs.extend(
1297 [
1298 {
1299 "doctype": "Salary Component",
1300 "salary_component": "Professional Tax",
1301 "description": "Professional Tax",
1302 "type": "Deduction",
1303 "exempted_from_income_tax": 1,
1304 },
1305 {
1306 "doctype": "Salary Component",
1307 "salary_component": "Provident Fund",
1308 "description": "Provident fund",
1309 "type": "Deduction",
1310 "is_tax_applicable": 1,
1311 },
1312 {
1313 "doctype": "Salary Component",
1314 "salary_component": "House Rent Allowance",
1315 "description": "House Rent Allowance",
1316 "type": "Earning",
1317 "is_tax_applicable": 1,
1318 },
1319 {
1320 "doctype": "Salary Component",
1321 "salary_component": "Basic",
1322 "description": "Basic",
1323 "type": "Earning",
1324 "is_tax_applicable": 1,
1325 },
1326 {
1327 "doctype": "Salary Component",
1328 "salary_component": "Arrear",
1329 "description": "Arrear",
1330 "type": "Earning",
1331 "is_tax_applicable": 1,
1332 },
1333 {
1334 "doctype": "Salary Component",
1335 "salary_component": "Leave Encashment",
1336 "description": "Leave Encashment",
1337 "type": "Earning",
1338 "is_tax_applicable": 1,
1339 },
1340 ]
1341 )
1342
Saurabh2d8a7ee2018-05-11 13:16:16 +05301343
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301344def set_tax_withholding_category(company):
Saurabh2d8a7ee2018-05-11 13:16:16 +05301345 accounts = []
Saqibf8c1c732021-09-26 16:27:56 +05301346 fiscal_year_details = None
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301347 abbr = frappe.get_value("Company", company, "abbr")
Ankush Menat494bd9e2022-03-28 18:52:46 +05301348 tds_account = frappe.get_value("Account", "TDS Payable - {0}".format(abbr), "name")
Saurabh2d8a7ee2018-05-11 13:16:16 +05301349
1350 if company and tds_account:
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301351 accounts = [dict(company=company, account=tds_account)]
Saurabh2d8a7ee2018-05-11 13:16:16 +05301352
Anuja Pawar4569e522021-01-14 19:24:30 +05301353 try:
Subin Tom350ed1a2021-11-19 21:05:25 +05301354 fiscal_year_details = get_fiscal_year(today(), verbose=0)
Anuja Pawar4569e522021-01-14 19:24:30 +05301355 except FiscalYearError:
1356 pass
Ranjith Kurungadame51c1752018-07-24 11:07:28 +05301357
Deepesh Gargc53b78e2021-09-14 20:28:48 +05301358 docs = get_tds_details(accounts, fiscal_year_details)
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +05301359
Zarrar7f8024c2018-08-01 17:45:05 +05301360 for d in docs:
Deepesh Garg66a71bd2021-04-21 20:42:20 +05301361 if not frappe.db.exists("Tax Withholding Category", d.get("name")):
Zarrar7f8024c2018-08-01 17:45:05 +05301362 doc = frappe.get_doc(d)
Deepesh Garg204ea102021-04-30 16:35:52 +05301363 doc.flags.ignore_validate = True
Zarrar7f8024c2018-08-01 17:45:05 +05301364 doc.flags.ignore_permissions = True
Nabin Haitafef9c12019-02-12 11:28:20 +05301365 doc.flags.ignore_mandatory = True
Zarrar7f8024c2018-08-01 17:45:05 +05301366 doc.insert()
Deepesh Garg66a71bd2021-04-21 20:42:20 +05301367 else:
Deepesh Gargfea29ae2021-07-12 18:29:52 +05301368 doc = frappe.get_doc("Tax Withholding Category", d.get("name"), for_update=True)
Zarrar963d62b2019-03-23 10:30:12 +05301369
1370 if accounts:
1371 doc.append("accounts", accounts[0])
Zarrar7f8024c2018-08-01 17:45:05 +05301372
Deepesh Gargc53b78e2021-09-14 20:28:48 +05301373 if fiscal_year_details:
Anuja Pawar4569e522021-01-14 19:24:30 +05301374 # if fiscal year don't match with any of the already entered data, append rate row
Ankush Menat494bd9e2022-03-28 18:52:46 +05301375 fy_exist = [
1376 k
1377 for k in doc.get("rates")
1378 if k.get("from_date") <= fiscal_year_details[1] and k.get("to_date") >= fiscal_year_details[2]
1379 ]
Anuja Pawar4569e522021-01-14 19:24:30 +05301380 if not fy_exist:
Ankush Menat494bd9e2022-03-28 18:52:46 +05301381 doc.append("rates", d.get("rates")[0])
Rucha Mahabalbe2c1fc2021-03-11 13:19:44 +05301382
Anuja Pawar4569e522021-01-14 19:24:30 +05301383 doc.flags.ignore_permissions = True
Deepesh Garg48b1a822021-05-29 23:54:51 +05301384 doc.flags.ignore_validate = True
Anuja Pawar4569e522021-01-14 19:24:30 +05301385 doc.flags.ignore_mandatory = True
Deepesh Garg204ea102021-04-30 16:35:52 +05301386 doc.flags.ignore_links = True
Zarrar7f8024c2018-08-01 17:45:05 +05301387 doc.save()
Saurabh2d8a7ee2018-05-11 13:16:16 +05301388
Ankush Menat494bd9e2022-03-28 18:52:46 +05301389
Saurabh2d8a7ee2018-05-11 13:16:16 +05301390def set_tds_account(docs, company):
Ankush Menat494bd9e2022-03-28 18:52:46 +05301391 parent_account = frappe.db.get_value(
1392 "Account", filters={"account_name": "Duties and Taxes", "company": company}
1393 )
Nabin Haitf77cd542018-11-20 16:46:25 +05301394 if parent_account:
Ankush Menat494bd9e2022-03-28 18:52:46 +05301395 docs.extend(
1396 [
1397 {
1398 "doctype": "Account",
1399 "account_name": "TDS Payable",
1400 "account_type": "Tax",
1401 "parent_account": parent_account,
1402 "company": company,
1403 }
1404 ]
1405 )
1406
Zarrar7f8024c2018-08-01 17:45:05 +05301407
Deepesh Gargc53b78e2021-09-14 20:28:48 +05301408def get_tds_details(accounts, fiscal_year_details):
Zarrar7f8024c2018-08-01 17:45:05 +05301409 # bootstrap default tax withholding sections
1410 return [
Ankush Menat494bd9e2022-03-28 18:52:46 +05301411 dict(
1412 name="TDS - 194C - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301413 category_name="Payment to Contractors (Single / Aggregate)",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301414 doctype="Tax Withholding Category",
1415 accounts=accounts,
1416 rates=[
1417 {
1418 "from_date": fiscal_year_details[1],
1419 "to_date": fiscal_year_details[2],
1420 "tax_withholding_rate": 2,
1421 "single_threshold": 30000,
1422 "cumulative_threshold": 100000,
1423 }
1424 ],
1425 ),
1426 dict(
1427 name="TDS - 194C - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301428 category_name="Payment to Contractors (Single / Aggregate)",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301429 doctype="Tax Withholding Category",
1430 accounts=accounts,
1431 rates=[
1432 {
1433 "from_date": fiscal_year_details[1],
1434 "to_date": fiscal_year_details[2],
1435 "tax_withholding_rate": 1,
1436 "single_threshold": 30000,
1437 "cumulative_threshold": 100000,
1438 }
1439 ],
1440 ),
1441 dict(
1442 name="TDS - 194C - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301443 category_name="Payment to Contractors (Single / Aggregate)",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301444 doctype="Tax Withholding Category",
1445 accounts=accounts,
1446 rates=[
1447 {
1448 "from_date": fiscal_year_details[1],
1449 "to_date": fiscal_year_details[2],
1450 "tax_withholding_rate": 20,
1451 "single_threshold": 30000,
1452 "cumulative_threshold": 100000,
1453 }
1454 ],
1455 ),
1456 dict(
1457 name="TDS - 194D - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301458 category_name="Insurance Commission",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301459 doctype="Tax Withholding Category",
1460 accounts=accounts,
1461 rates=[
1462 {
1463 "from_date": fiscal_year_details[1],
1464 "to_date": fiscal_year_details[2],
1465 "tax_withholding_rate": 5,
1466 "single_threshold": 15000,
1467 "cumulative_threshold": 0,
1468 }
1469 ],
1470 ),
1471 dict(
1472 name="TDS - 194D - Company Assessee",
Zarrar7f8024c2018-08-01 17:45:05 +05301473 category_name="Insurance Commission",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301474 doctype="Tax Withholding Category",
1475 accounts=accounts,
1476 rates=[
1477 {
1478 "from_date": fiscal_year_details[1],
1479 "to_date": fiscal_year_details[2],
1480 "tax_withholding_rate": 10,
1481 "single_threshold": 15000,
1482 "cumulative_threshold": 0,
1483 }
1484 ],
1485 ),
1486 dict(
1487 name="TDS - 194D - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301488 category_name="Insurance Commission",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301489 doctype="Tax Withholding Category",
1490 accounts=accounts,
1491 rates=[
1492 {
1493 "from_date": fiscal_year_details[1],
1494 "to_date": fiscal_year_details[2],
1495 "tax_withholding_rate": 5,
1496 "single_threshold": 15000,
1497 "cumulative_threshold": 0,
1498 }
1499 ],
1500 ),
1501 dict(
1502 name="TDS - 194D - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301503 category_name="Insurance Commission",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301504 doctype="Tax Withholding Category",
1505 accounts=accounts,
1506 rates=[
1507 {
1508 "from_date": fiscal_year_details[1],
1509 "to_date": fiscal_year_details[2],
1510 "tax_withholding_rate": 20,
1511 "single_threshold": 15000,
1512 "cumulative_threshold": 0,
1513 }
1514 ],
1515 ),
1516 dict(
1517 name="TDS - 194DA - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301518 category_name="Non-exempt payments made under a life insurance policy",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301519 doctype="Tax Withholding Category",
1520 accounts=accounts,
1521 rates=[
1522 {
1523 "from_date": fiscal_year_details[1],
1524 "to_date": fiscal_year_details[2],
1525 "tax_withholding_rate": 1,
1526 "single_threshold": 100000,
1527 "cumulative_threshold": 0,
1528 }
1529 ],
1530 ),
1531 dict(
1532 name="TDS - 194DA - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301533 category_name="Non-exempt payments made under a life insurance policy",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301534 doctype="Tax Withholding Category",
1535 accounts=accounts,
1536 rates=[
1537 {
1538 "from_date": fiscal_year_details[1],
1539 "to_date": fiscal_year_details[2],
1540 "tax_withholding_rate": 1,
1541 "single_threshold": 100000,
1542 "cumulative_threshold": 0,
1543 }
1544 ],
1545 ),
1546 dict(
1547 name="TDS - 194DA - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301548 category_name="Non-exempt payments made under a life insurance policy",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301549 doctype="Tax Withholding Category",
1550 accounts=accounts,
1551 rates=[
1552 {
1553 "from_date": fiscal_year_details[1],
1554 "to_date": fiscal_year_details[2],
1555 "tax_withholding_rate": 20,
1556 "single_threshold": 100000,
1557 "cumulative_threshold": 0,
1558 }
1559 ],
1560 ),
1561 dict(
1562 name="TDS - 194H - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301563 category_name="Commission / Brokerage",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301564 doctype="Tax Withholding Category",
1565 accounts=accounts,
1566 rates=[
1567 {
1568 "from_date": fiscal_year_details[1],
1569 "to_date": fiscal_year_details[2],
1570 "tax_withholding_rate": 5,
1571 "single_threshold": 15000,
1572 "cumulative_threshold": 0,
1573 }
1574 ],
1575 ),
1576 dict(
1577 name="TDS - 194H - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301578 category_name="Commission / Brokerage",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301579 doctype="Tax Withholding Category",
1580 accounts=accounts,
1581 rates=[
1582 {
1583 "from_date": fiscal_year_details[1],
1584 "to_date": fiscal_year_details[2],
1585 "tax_withholding_rate": 5,
1586 "single_threshold": 15000,
1587 "cumulative_threshold": 0,
1588 }
1589 ],
1590 ),
1591 dict(
1592 name="TDS - 194H - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301593 category_name="Commission / Brokerage",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301594 doctype="Tax Withholding Category",
1595 accounts=accounts,
1596 rates=[
1597 {
1598 "from_date": fiscal_year_details[1],
1599 "to_date": fiscal_year_details[2],
1600 "tax_withholding_rate": 20,
1601 "single_threshold": 15000,
1602 "cumulative_threshold": 0,
1603 }
1604 ],
1605 ),
1606 dict(
1607 name="TDS - 194I - Rent - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301608 category_name="Rent",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301609 doctype="Tax Withholding Category",
1610 accounts=accounts,
1611 rates=[
1612 {
1613 "from_date": fiscal_year_details[1],
1614 "to_date": fiscal_year_details[2],
1615 "tax_withholding_rate": 10,
1616 "single_threshold": 180000,
1617 "cumulative_threshold": 0,
1618 }
1619 ],
1620 ),
1621 dict(
1622 name="TDS - 194I - Rent - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301623 category_name="Rent",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301624 doctype="Tax Withholding Category",
1625 accounts=accounts,
1626 rates=[
1627 {
1628 "from_date": fiscal_year_details[1],
1629 "to_date": fiscal_year_details[2],
1630 "tax_withholding_rate": 10,
1631 "single_threshold": 180000,
1632 "cumulative_threshold": 0,
1633 }
1634 ],
1635 ),
1636 dict(
1637 name="TDS - 194I - Rent - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301638 category_name="Rent",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301639 doctype="Tax Withholding Category",
1640 accounts=accounts,
1641 rates=[
1642 {
1643 "from_date": fiscal_year_details[1],
1644 "to_date": fiscal_year_details[2],
1645 "tax_withholding_rate": 20,
1646 "single_threshold": 180000,
1647 "cumulative_threshold": 0,
1648 }
1649 ],
1650 ),
1651 dict(
1652 name="TDS - 194I - Rent/Machinery - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301653 category_name="Rent-Plant / Machinery",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301654 doctype="Tax Withholding Category",
1655 accounts=accounts,
1656 rates=[
1657 {
1658 "from_date": fiscal_year_details[1],
1659 "to_date": fiscal_year_details[2],
1660 "tax_withholding_rate": 2,
1661 "single_threshold": 180000,
1662 "cumulative_threshold": 0,
1663 }
1664 ],
1665 ),
1666 dict(
1667 name="TDS - 194I - Rent/Machinery - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301668 category_name="Rent-Plant / Machinery",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301669 doctype="Tax Withholding Category",
1670 accounts=accounts,
1671 rates=[
1672 {
1673 "from_date": fiscal_year_details[1],
1674 "to_date": fiscal_year_details[2],
1675 "tax_withholding_rate": 2,
1676 "single_threshold": 180000,
1677 "cumulative_threshold": 0,
1678 }
1679 ],
1680 ),
1681 dict(
1682 name="TDS - 194I - Rent/Machinery - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301683 category_name="Rent-Plant / Machinery",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301684 doctype="Tax Withholding Category",
1685 accounts=accounts,
1686 rates=[
1687 {
1688 "from_date": fiscal_year_details[1],
1689 "to_date": fiscal_year_details[2],
1690 "tax_withholding_rate": 20,
1691 "single_threshold": 180000,
1692 "cumulative_threshold": 0,
1693 }
1694 ],
1695 ),
1696 dict(
1697 name="TDS - 194J - Professional Fees - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301698 category_name="Professional Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301699 doctype="Tax Withholding Category",
1700 accounts=accounts,
1701 rates=[
1702 {
1703 "from_date": fiscal_year_details[1],
1704 "to_date": fiscal_year_details[2],
1705 "tax_withholding_rate": 10,
1706 "single_threshold": 30000,
1707 "cumulative_threshold": 0,
1708 }
1709 ],
1710 ),
1711 dict(
1712 name="TDS - 194J - Professional Fees - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301713 category_name="Professional Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301714 doctype="Tax Withholding Category",
1715 accounts=accounts,
1716 rates=[
1717 {
1718 "from_date": fiscal_year_details[1],
1719 "to_date": fiscal_year_details[2],
1720 "tax_withholding_rate": 10,
1721 "single_threshold": 30000,
1722 "cumulative_threshold": 0,
1723 }
1724 ],
1725 ),
1726 dict(
1727 name="TDS - 194J - Professional Fees - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301728 category_name="Professional Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301729 doctype="Tax Withholding Category",
1730 accounts=accounts,
1731 rates=[
1732 {
1733 "from_date": fiscal_year_details[1],
1734 "to_date": fiscal_year_details[2],
1735 "tax_withholding_rate": 20,
1736 "single_threshold": 30000,
1737 "cumulative_threshold": 0,
1738 }
1739 ],
1740 ),
1741 dict(
1742 name="TDS - 194J - Director Fees - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301743 category_name="Director Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301744 doctype="Tax Withholding Category",
1745 accounts=accounts,
1746 rates=[
1747 {
1748 "from_date": fiscal_year_details[1],
1749 "to_date": fiscal_year_details[2],
1750 "tax_withholding_rate": 10,
1751 "single_threshold": 0,
1752 "cumulative_threshold": 0,
1753 }
1754 ],
1755 ),
1756 dict(
1757 name="TDS - 194J - Director Fees - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301758 category_name="Director Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301759 doctype="Tax Withholding Category",
1760 accounts=accounts,
1761 rates=[
1762 {
1763 "from_date": fiscal_year_details[1],
1764 "to_date": fiscal_year_details[2],
1765 "tax_withholding_rate": 10,
1766 "single_threshold": 0,
1767 "cumulative_threshold": 0,
1768 }
1769 ],
1770 ),
1771 dict(
1772 name="TDS - 194J - Director Fees - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301773 category_name="Director Fees",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301774 doctype="Tax Withholding Category",
1775 accounts=accounts,
1776 rates=[
1777 {
1778 "from_date": fiscal_year_details[1],
1779 "to_date": fiscal_year_details[2],
1780 "tax_withholding_rate": 20,
1781 "single_threshold": 0,
1782 "cumulative_threshold": 0,
1783 }
1784 ],
1785 ),
1786 dict(
1787 name="TDS - 194 - Dividends - Company",
Zarrar7f8024c2018-08-01 17:45:05 +05301788 category_name="Dividends",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301789 doctype="Tax Withholding Category",
1790 accounts=accounts,
1791 rates=[
1792 {
1793 "from_date": fiscal_year_details[1],
1794 "to_date": fiscal_year_details[2],
1795 "tax_withholding_rate": 10,
1796 "single_threshold": 2500,
1797 "cumulative_threshold": 0,
1798 }
1799 ],
1800 ),
1801 dict(
1802 name="TDS - 194 - Dividends - Individual",
Zarrar7f8024c2018-08-01 17:45:05 +05301803 category_name="Dividends",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301804 doctype="Tax Withholding Category",
1805 accounts=accounts,
1806 rates=[
1807 {
1808 "from_date": fiscal_year_details[1],
1809 "to_date": fiscal_year_details[2],
1810 "tax_withholding_rate": 10,
1811 "single_threshold": 2500,
1812 "cumulative_threshold": 0,
1813 }
1814 ],
1815 ),
1816 dict(
1817 name="TDS - 194 - Dividends - No PAN / Invalid PAN",
Zarrar7f8024c2018-08-01 17:45:05 +05301818 category_name="Dividends",
Ankush Menat494bd9e2022-03-28 18:52:46 +05301819 doctype="Tax Withholding Category",
1820 accounts=accounts,
1821 rates=[
1822 {
1823 "from_date": fiscal_year_details[1],
1824 "to_date": fiscal_year_details[2],
1825 "tax_withholding_rate": 20,
1826 "single_threshold": 2500,
1827 "cumulative_threshold": 0,
1828 }
1829 ],
1830 ),
Anurag Mishrae1464a72020-08-17 15:03:32 +05301831 ]
1832
Ankush Menat494bd9e2022-03-28 18:52:46 +05301833
Anurag Mishra25c35682020-08-18 14:13:54 +05301834def create_gratuity_rule():
Anurag Mishrae1464a72020-08-17 15:03:32 +05301835 # Standard Indain Gratuity Rule
Anurag Mishra493eea12020-08-18 15:02:32 +05301836 if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
1837 rule = frappe.new_doc("Gratuity Rule")
1838 rule.name = "Indian Standard Gratuity Rule"
1839 rule.calculate_gratuity_amount_based_on = "Current Slab"
1840 rule.work_experience_calculation_method = "Round Off Work Experience"
1841 rule.minimum_year_for_gratuity = 5
Anurag Mishrae1464a72020-08-17 15:03:32 +05301842
Ankush Menat494bd9e2022-03-28 18:52:46 +05301843 fraction = 15 / 26
1844 rule.append(
1845 "gratuity_rule_slabs",
1846 {"from_year": 0, "to_year": 0, "fraction_of_applicable_earnings": fraction},
1847 )
Anurag Mishrae1464a72020-08-17 15:03:32 +05301848
Anurag Mishra493eea12020-08-18 15:02:32 +05301849 rule.flags.ignore_mandatory = True
Sagar Vora4c31fbb2021-04-01 15:32:37 +05301850 rule.save()
Deepesh Garg204ea102021-04-30 16:35:52 +05301851
Ankush Menat494bd9e2022-03-28 18:52:46 +05301852
Deepesh Garg204ea102021-04-30 16:35:52 +05301853def update_accounts_settings_for_taxes():
Ankush Menat494bd9e2022-03-28 18:52:46 +05301854 if frappe.db.count("Company") == 1:
1855 frappe.db.set_value("Accounts Settings", None, "add_taxes_from_item_tax_template", 0)