blob: a8ff3f8484902bbd5d833bf901532e732311d54c [file] [log] [blame]
Rushabh Mehtab3c8f442017-06-21 17:22:38 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5
6import frappe, os, json
Rushabh Mehtaf0569742017-09-13 12:52:30 +05307from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
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
Zarrar7f8024c2018-08-01 17:45:05 +053010from erpnext.accounts.utils import get_fiscal_year
11from frappe.utils import today
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053012
Rushabh Mehta01659272017-06-27 18:05:17 +053013def setup(company=None, patch=True):
Prateeksha Singhdabf3492018-11-13 15:56:15 +053014 setup_company_independent_fixtures()
Prateeksha Singh39b87652018-11-12 17:19:56 +053015 if not patch:
Prateeksha Singhdabf3492018-11-13 15:56:15 +053016 make_fixtures(company)
Prateeksha Singh39b87652018-11-12 17:19:56 +053017
18# TODO: for all countries
19def setup_company_independent_fixtures():
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053020 make_custom_fields()
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053021 add_permissions()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053022 add_custom_roles_for_reports()
Nabin Haitc3144852017-09-28 18:55:40 +053023 frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes', now=frappe.flags.in_test)
Anurag Mishrae1464a72020-08-17 15:03:32 +053024 create_standard_documents()
Nabin Hait852cb642017-07-05 12:58:19 +053025 add_print_formats()
Rushabh Mehta919a74a2017-06-22 16:37:04 +053026
Nabin Hait1a609312017-07-13 12:16:04 +053027def add_hsn_sac_codes():
28 # HSN codes
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053029 with open(os.path.join(os.path.dirname(__file__), 'hsn_code_data.json'), 'r') as f:
30 hsn_codes = json.loads(f.read())
31
Nabin Hait1a609312017-07-13 12:16:04 +053032 create_hsn_codes(hsn_codes, code_field="hsn_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053033
Nabin Hait1a609312017-07-13 12:16:04 +053034 # SAC Codes
35 with open(os.path.join(os.path.dirname(__file__), 'sac_code_data.json'), 'r') as f:
36 sac_codes = json.loads(f.read())
37 create_hsn_codes(sac_codes, code_field="sac_code")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053038
Nabin Hait1a609312017-07-13 12:16:04 +053039def create_hsn_codes(data, code_field):
40 for d in data:
Rushabh Mehtaf702d722017-09-27 15:31:30 +053041 hsn_code = frappe.new_doc('GST HSN Code')
42 hsn_code.description = d["description"]
43 hsn_code.hsn_code = d[code_field]
44 hsn_code.name = d[code_field]
45 try:
Nabin Hait1a609312017-07-13 12:16:04 +053046 hsn_code.db_insert()
Rushabh Mehtaf702d722017-09-27 15:31:30 +053047 except frappe.DuplicateEntryError:
48 pass
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053049
Rushabh Mehta919a74a2017-06-22 16:37:04 +053050def add_custom_roles_for_reports():
51 for report_name in ('GST Sales Register', 'GST Purchase Register',
rohitwaghchaure8cca61f2018-08-20 17:53:56 +053052 'GST Itemised Sales Register', 'GST Itemised Purchase Register', 'Eway Bill'):
Rushabh Mehta919a74a2017-06-22 16:37:04 +053053
Rushabh Mehta919a74a2017-06-22 16:37:04 +053054 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
55 frappe.get_doc(dict(
56 doctype='Custom Role',
57 report=report_name,
58 roles= [
59 dict(role='Accounts User'),
60 dict(role='Accounts Manager')
61 ]
62 )).insert()
63
Anurag Mishra289c8222020-06-19 19:17:57 +053064 for report_name in ('Professional Tax Deductions', 'Provident Fund Deductions'):
65
66 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
67 frappe.get_doc(dict(
68 doctype='Custom Role',
69 report=report_name,
70 roles= [
71 dict(role='HR User'),
72 dict(role='HR Manager'),
73 dict(role='Employee')
74 ]
75 )).insert()
76
Anurag Mishra54cd1942020-09-03 13:51:26 +053077 for report_name in ('HSN-wise-summary of outward supplies', 'GSTR-1', 'GSTR-2'):
78
79 if not frappe.db.get_value('Custom Role', dict(report=report_name)):
80 frappe.get_doc(dict(
81 doctype='Custom Role',
82 report=report_name,
83 roles= [
84 dict(role='Accounts User'),
85 dict(role='Accounts Manager'),
86 dict(role='Auditor')
87 ]
88 )).insert()
89
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053090def add_permissions():
Deepesh Gargd78cf972020-04-26 20:08:52 +053091 for doctype in ('GST HSN Code', 'GST Settings', 'GSTR 3B Report', 'Lower Deduction Certificate'):
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053092 add_permission(doctype, 'All', 0)
Deepesh Garg6c8efde2020-04-04 20:05:17 +053093 for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
Saqib5e6ce882020-02-03 15:40:35 +053094 add_permission(doctype, role, 0)
95 update_permission_property(doctype, role, 0, 'write', 1)
96 update_permission_property(doctype, role, 0, 'create', 1)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +053097
Deepesh Garg6c8efde2020-04-04 20:05:17 +053098 if doctype == 'GST HSN Code':
99 for role in ('Item Manager', 'Stock Manager'):
100 add_permission(doctype, role, 0)
101 update_permission_property(doctype, role, 0, 'write', 1)
102 update_permission_property(doctype, role, 0, 'create', 1)
103
Nabin Hait852cb642017-07-05 12:58:19 +0530104def add_print_formats():
105 frappe.reload_doc("regional", "print_format", "gst_tax_invoice")
rohitwaghchauree3b5c0f2017-12-16 10:53:53 +0530106 frappe.reload_doc("accounts", "print_format", "gst_pos_invoice")
107
108 frappe.db.sql(""" update `tabPrint Format` set disabled = 0 where
109 name in('GST POS Invoice', 'GST Tax Invoice') """)
Nabin Hait852cb642017-07-05 12:58:19 +0530110
Rushabh Mehta69fa8082018-07-17 18:22:51 +0530111def make_custom_fields(update=True):
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530112 hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
Nabin Haitd34bfa82018-11-13 18:19:58 +0530113 fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description',
Nabin Haitf4af6082019-04-01 11:51:54 +0530114 allow_on_submit=1, print_hide=1, fetch_if_empty=1)
Marica9942acd2020-04-21 13:13:39 +0530115 nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530116 fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code',
117 print_hide=1)
118 is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST',
119 fieldtype='Check', fetch_from='item_code.is_non_gst', insert_after='is_nil_exempt',
120 print_hide=1)
121
122 purchase_invoice_gst_category = [
Nabin Hait879e1622017-08-21 08:28:55 +0530123 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
vishdha109b4082018-01-30 12:11:13 +0530124 insert_after='language', print_hide=1, collapsible=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530125 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530126 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530127 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530128 fetch_from='supplier.gst_category', fetch_if_empty=1),
129 dict(fieldname='export_type', label='Export Type',
130 fieldtype='Select', insert_after='gst_category', print_hide=1,
131 depends_on='eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
132 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='supplier.export_type',
133 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530134 ]
135
136 sales_invoice_gst_category = [
137 dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break',
138 insert_after='language', print_hide=1, collapsible=1),
139 dict(fieldname='gst_category', label='GST Category',
Nabin Hait10dae5d2019-04-01 20:56:51 +0530140 fieldtype='Select', insert_after='gst_section', print_hide=1,
Nabin Hait89b06132019-05-01 14:18:21 +0530141 options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530142 fetch_from='customer.gst_category', fetch_if_empty=1),
143 dict(fieldname='export_type', label='Export Type',
144 fieldtype='Select', insert_after='gst_category', print_hide=1,
145 depends_on='eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
146 options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='customer.export_type',
147 fetch_if_empty=1),
Deepesh Garg22b61602019-03-21 20:47:47 +0530148 ]
149
150 invoice_gst_fields = [
Nabin Hait879e1622017-08-21 08:28:55 +0530151 dict(fieldname='invoice_copy', label='Invoice Copy',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530152 fieldtype='Select', insert_after='export_type', print_hide=1, allow_on_submit=1,
Nabin Hait879e1622017-08-21 08:28:55 +0530153 options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'),
154 dict(fieldname='reverse_charge', label='Reverse Charge',
155 fieldtype='Select', insert_after='invoice_copy', print_hide=1,
156 options='Y\nN', default='N'),
Nabin Hait879e1622017-08-21 08:28:55 +0530157 dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN',
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530158 fieldtype='Data', insert_after='export_type', print_hide=1),
Nabin Haite6d65bc2018-02-14 17:44:06 +0530159 dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='ecommerce_gstin'),
Vishal Dhayagudec463c062018-01-26 11:27:22 +0530160 dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document',
Nabin Haitb02c1092018-02-05 16:09:51 +0530161 fieldtype='Select', insert_after='gst_col_break', print_hide=1,
Nabin Haite6d65bc2018-02-14 17:44:06 +0530162 depends_on='eval:doc.is_return==1',
Nabin Haita8d10b72018-02-12 16:54:13 +0530163 options='\n01-Sales Return\n02-Post Sale Discount\n03-Deficiency in services\n04-Correction in Invoice\n05-Change in POS\n06-Finalization of Provisional assessment\n07-Others')
Nabin Hait879e1622017-08-21 08:28:55 +0530164 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530165
Nabin Hait879e1622017-08-21 08:28:55 +0530166 purchase_invoice_gst_fields = [
167 dict(fieldname='supplier_gstin', label='Supplier GSTIN',
168 fieldtype='Data', insert_after='supplier_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530169 fetch_from='supplier_address.gstin', print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530170 dict(fieldname='company_gstin', label='Company GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530171 fieldtype='Data', insert_after='shipping_address_display',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530172 fetch_from='shipping_address.gstin', print_hide=1, read_only=1),
Nabin Haitb02c1092018-02-05 16:09:51 +0530173 dict(fieldname='place_of_supply', label='Place of Supply',
174 fieldtype='Data', insert_after='shipping_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530175 print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530176 ]
177
178 purchase_invoice_itc_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530179 dict(fieldname='eligibility_for_itc', label='Eligibility For ITC',
180 fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530181 options='Input Service Distributor\nImport Of Service\nImport Of Capital Goods\nIneligible\nAll Other ITC', default="All Other ITC"),
vishdha98e33c32018-01-29 13:57:34 +0530182 dict(fieldname='itc_integrated_tax', label='Availed ITC Integrated Tax',
183 fieldtype='Data', insert_after='eligibility_for_itc', print_hide=1),
184 dict(fieldname='itc_central_tax', label='Availed ITC Central Tax',
185 fieldtype='Data', insert_after='itc_integrated_tax', print_hide=1),
186 dict(fieldname='itc_state_tax', label='Availed ITC State/UT Tax',
187 fieldtype='Data', insert_after='itc_central_tax', print_hide=1),
188 dict(fieldname='itc_cess_amount', label='Availed ITC Cess',
189 fieldtype='Data', insert_after='itc_state_tax', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530190 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530191
Nabin Hait879e1622017-08-21 08:28:55 +0530192 sales_invoice_gst_fields = [
rohitwaghchaure16645802017-09-28 11:05:03 +0530193 dict(fieldname='billing_address_gstin', label='Billing Address GSTIN',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530194 fieldtype='Data', insert_after='customer_address', read_only=1,
Shreya Shah4fa600a2018-06-05 11:27:53 +0530195 fetch_from='customer_address.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530196 dict(fieldname='customer_gstin', label='Customer GSTIN',
Shreya Shah4fa600a2018-06-05 11:27:53 +0530197 fieldtype='Data', insert_after='shipping_address_name',
198 fetch_from='shipping_address_name.gstin', print_hide=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530199 dict(fieldname='place_of_supply', label='Place of Supply',
Nabin Hait619c42b2018-01-10 17:48:03 +0530200 fieldtype='Data', insert_after='customer_gstin',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530201 print_hide=1, read_only=1),
Nabin Hait879e1622017-08-21 08:28:55 +0530202 dict(fieldname='company_gstin', label='Company GSTIN',
203 fieldtype='Data', insert_after='company_address',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530204 fetch_from='company_address.gstin', print_hide=1, read_only=1),
deepeshgarg007d29ee972019-01-09 17:09:11 +0530205 ]
206
207 sales_invoice_shipping_fields = [
vishdha98e33c32018-01-29 13:57:34 +0530208 dict(fieldname='port_code', label='Port Code',
209 fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530210 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530211 dict(fieldname='shipping_bill_number', label=' Shipping Bill Number',
212 fieldtype='Data', insert_after='port_code', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530213 depends_on="eval:doc.gst_category=='Overseas' "),
vishdha98e33c32018-01-29 13:57:34 +0530214 dict(fieldname='shipping_bill_date', label='Shipping Bill Date',
215 fieldtype='Date', insert_after='shipping_bill_number', print_hide=1,
Deepesh Garg22b61602019-03-21 20:47:47 +0530216 depends_on="eval:doc.gst_category=='Overseas' "),
Nabin Hait879e1622017-08-21 08:28:55 +0530217 ]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +0530218
Shreya Shah4fa600a2018-06-05 11:27:53 +0530219 inter_state_gst_field = [
220 dict(fieldname='is_inter_state', label='Is Inter State',
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530221 fieldtype='Check', insert_after='disabled', print_hide=1),
222 dict(fieldname='tax_category_column_break', fieldtype='Column Break',
223 insert_after='is_inter_state'),
224 dict(fieldname='gst_state', label='Source State', fieldtype='Select',
225 options='\n'.join(states), insert_after='company')
Shreya Shah4fa600a2018-06-05 11:27:53 +0530226 ]
227
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530228 ewaybill_fields = [
229 {
230 'fieldname': 'distance',
231 'label': 'Distance (in km)',
232 'fieldtype': 'Float',
233 'insert_after': 'vehicle_no',
234 'print_hide': 1
235 },
236 {
237 'fieldname': 'gst_transporter_id',
238 'label': 'GST Transporter ID',
239 'fieldtype': 'Data',
Nabin Hait34c551d2019-07-03 10:34:31 +0530240 'insert_after': 'transporter',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530241 'fetch_from': 'transporter.gst_transporter_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530242 'print_hide': 1,
243 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530244 },
245 {
246 'fieldname': 'mode_of_transport',
247 'label': 'Mode of Transport',
248 'fieldtype': 'Select',
249 'options': '\nRoad\nAir\nRail\nShip',
250 'default': 'Road',
Nabin Hait34c551d2019-07-03 10:34:31 +0530251 'insert_after': 'transporter_name',
252 'print_hide': 1,
253 'translatable': 0
254 },
255 {
256 'fieldname': 'gst_vehicle_type',
257 'label': 'GST Vehicle Type',
258 'fieldtype': 'Select',
259 'options': 'Regular\nOver Dimensional Cargo (ODC)',
260 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
261 'default': 'Regular',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530262 'insert_after': 'lr_date',
Nabin Hait34c551d2019-07-03 10:34:31 +0530263 'print_hide': 1,
264 'translatable': 0
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530265 },
266 {
267 'fieldname': 'ewaybill',
268 'label': 'E-Way Bill No.',
269 'fieldtype': 'Data',
270 'depends_on': 'eval:(doc.docstatus === 1)',
271 'allow_on_submit': 1,
272 'insert_after': 'customer_name_in_arabic',
273 'translatable': 0,
274 }
Nabin Hait34c551d2019-07-03 10:34:31 +0530275 ]
276
277 si_ewaybill_fields = [
278 {
279 'fieldname': 'transporter_info',
280 'label': 'Transporter Info',
281 'fieldtype': 'Section Break',
282 'insert_after': 'terms',
283 'collapsible': 1,
284 'collapsible_depends_on': 'transporter',
285 'print_hide': 1
286 },
287 {
288 'fieldname': 'transporter',
289 'label': 'Transporter',
290 'fieldtype': 'Link',
291 'insert_after': 'transporter_info',
292 'options': 'Supplier',
293 'print_hide': 1
294 },
295 {
296 'fieldname': 'gst_transporter_id',
297 'label': 'GST Transporter ID',
298 'fieldtype': 'Data',
299 'insert_after': 'transporter',
300 'fetch_from': 'transporter.gst_transporter_id',
301 'print_hide': 1,
302 'translatable': 0
303 },
304 {
305 'fieldname': 'driver',
306 'label': 'Driver',
307 'fieldtype': 'Link',
308 'insert_after': 'gst_transporter_id',
309 'options': 'Driver',
310 'print_hide': 1
311 },
312 {
313 'fieldname': 'lr_no',
314 'label': 'Transport Receipt No',
315 'fieldtype': 'Data',
316 'insert_after': 'driver',
317 'print_hide': 1,
318 'translatable': 0
319 },
320 {
321 'fieldname': 'vehicle_no',
322 'label': 'Vehicle No',
323 'fieldtype': 'Data',
324 'insert_after': 'lr_no',
325 'print_hide': 1,
326 'translatable': 0
327 },
328 {
329 'fieldname': 'distance',
330 'label': 'Distance (in km)',
331 'fieldtype': 'Float',
332 'insert_after': 'vehicle_no',
333 'print_hide': 1
334 },
335 {
336 'fieldname': 'transporter_col_break',
337 'fieldtype': 'Column Break',
338 'insert_after': 'distance'
339 },
340 {
341 'fieldname': 'transporter_name',
342 'label': 'Transporter Name',
343 'fieldtype': 'Data',
344 'insert_after': 'transporter_col_break',
345 'fetch_from': 'transporter.name',
346 'read_only': 1,
347 'print_hide': 1,
348 'translatable': 0
349 },
350 {
351 'fieldname': 'mode_of_transport',
352 'label': 'Mode of Transport',
353 'fieldtype': 'Select',
354 'options': '\nRoad\nAir\nRail\nShip',
355 'default': 'Road',
356 'insert_after': 'transporter_name',
357 'print_hide': 1,
358 'translatable': 0
359 },
360 {
361 'fieldname': 'driver_name',
362 'label': 'Driver Name',
363 'fieldtype': 'Data',
364 'insert_after': 'mode_of_transport',
365 'fetch_from': 'driver.full_name',
366 'print_hide': 1,
367 'translatable': 0
368 },
369 {
370 'fieldname': 'lr_date',
371 'label': 'Transport Receipt Date',
372 'fieldtype': 'Date',
373 'insert_after': 'driver_name',
374 'default': 'Today',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530375 'print_hide': 1
376 },
377 {
378 'fieldname': 'gst_vehicle_type',
379 'label': 'GST Vehicle Type',
380 'fieldtype': 'Select',
Nabin Hait34c551d2019-07-03 10:34:31 +0530381 'options': 'Regular\nOver Dimensional Cargo (ODC)',
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530382 'depends_on': 'eval:(doc.mode_of_transport === "Road")',
Nabin Hait34c551d2019-07-03 10:34:31 +0530383 'default': 'Regular',
384 'insert_after': 'lr_date',
385 'print_hide': 1,
386 'translatable': 0
387 },
388 {
389 'fieldname': 'ewaybill',
Deepesh Garg15ff6a52020-02-18 12:28:41 +0530390 'label': 'E-Way Bill No.',
Nabin Hait34c551d2019-07-03 10:34:31 +0530391 'fieldtype': 'Data',
392 'depends_on': 'eval:(doc.docstatus === 1)',
393 'allow_on_submit': 1,
deepeshgarg007a85db662019-07-14 18:15:19 +0530394 'insert_after': 'tax_id',
Nabin Hait34c551d2019-07-03 10:34:31 +0530395 'translatable': 0
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530396 }
397 ]
398
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530399 custom_fields = {
400 'Address': [
Rushabh Mehta919a74a2017-06-22 16:37:04 +0530401 dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data',
402 insert_after='fax'),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530403 dict(fieldname='gst_state', label='GST State', fieldtype='Select',
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530404 options='\n'.join(states), insert_after='gstin'),
405 dict(fieldname='gst_state_number', label='GST State Number',
Nabin Hait562d9422018-09-07 16:14:44 +0530406 fieldtype='Data', insert_after='gst_state', read_only=1),
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530407 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530408 'Purchase Invoice': purchase_invoice_gst_category + invoice_gst_fields + purchase_invoice_itc_fields + purchase_invoice_gst_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530409 'Purchase Order': purchase_invoice_gst_fields,
410 'Purchase Receipt': purchase_invoice_gst_fields,
Nabin Hait34c551d2019-07-03 10:34:31 +0530411 'Sales Invoice': sales_invoice_gst_category + invoice_gst_fields + sales_invoice_shipping_fields + sales_invoice_gst_fields + si_ewaybill_fields,
412 'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields,
deepeshgarg007d29ee972019-01-09 17:09:11 +0530413 'Sales Order': sales_invoice_gst_fields,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530414 'Tax Category': inter_state_gst_field,
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530415 'Item': [
Nabin Haitf3f0dfe2017-07-06 14:49:34 +0530416 dict(fieldname='gst_hsn_code', label='HSN/SAC',
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530417 fieldtype='Link', options='GST HSN Code', insert_after='item_group'),
Marica9942acd2020-04-21 13:13:39 +0530418 dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted',
Deepesh Garg22b61602019-03-21 20:47:47 +0530419 fieldtype='Check', insert_after='gst_hsn_code'),
420 dict(fieldname='is_non_gst', label='Is Non GST ',
421 fieldtype='Check', insert_after='is_nil_exempt')
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530422 ],
Deepesh Garg22b61602019-03-21 20:47:47 +0530423 'Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
424 'Supplier Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
425 'Sales Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
426 'Delivery Note Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
427 'Sales Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
428 'Purchase Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
429 'Purchase Receipt Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
430 'Purchase Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Himanshu Warekar656d8e42019-04-01 19:38:43 +0530431 'Material Request Item': [hsn_sac_field, nil_rated_exempt, is_non_gst],
Anurag Mishra289c8222020-06-19 19:17:57 +0530432 'Salary Component': [
433 dict(fieldname= 'component_type',
434 label= 'Component Type',
435 fieldtype= 'Select',
436 insert_after= 'description',
437 options= "\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax",
438 depends_on = 'eval:doc.type == "Deduction"'
439 )
440 ],
Pawan Mehtaf4196352018-04-05 14:54:51 +0530441 'Employee': [
Anurag Mishra289c8222020-06-19 19:17:57 +0530442 dict(fieldname='ifsc_code',
443 label='IFSC Code',
444 fieldtype='Data',
445 insert_after='bank_ac_no',
446 print_hide=1,
447 depends_on='eval:doc.salary_mode == "Bank"'
448 ),
449 dict(
450 fieldname = 'pan_number',
451 label = 'PAN Number',
452 fieldtype = 'Data',
453 insert_after = 'payroll_cost_center',
454 print_hide = 1
455 ),
456 dict(
457 fieldname = 'micr_code',
458 label = 'MICR Code',
459 fieldtype = 'Data',
460 insert_after = 'ifsc_code',
461 print_hide = 1,
462 depends_on='eval:doc.salary_mode == "Bank"'
463 ),
464 dict(
465 fieldname = 'provident_fund_account',
466 label = 'Provident Fund Account',
467 fieldtype = 'Data',
468 insert_after = 'pan_number'
469 )
470
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530471 ],
472 'Company': [
473 dict(fieldname='hra_section', label='HRA Settings',
Anurag Mishraa5527222019-06-14 15:25:57 +0530474 fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530475 dict(fieldname='basic_component', label='Basic Component',
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530476 fieldtype='Link', options='Salary Component', insert_after='hra_section'),
Ranjith Kurungadamb1a756c2018-07-01 16:42:38 +0530477 dict(fieldname='hra_component', label='HRA Component',
478 fieldtype='Link', options='Salary Component', insert_after='basic_component'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530479 dict(fieldname='arrear_component', label='Arrear Component',
Mangesh-Khairnar9215de02019-05-06 16:24:10 +0530480 fieldtype='Link', options='Salary Component', insert_after='hra_component'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530481 ],
482 'Employee Tax Exemption Declaration':[
483 dict(fieldname='hra_section', label='HRA Exemption',
484 fieldtype='Section Break', insert_after='declarations'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530485 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530486 fieldtype='Currency', insert_after='hra_section'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530487 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530488 fieldtype='Check', insert_after='monthly_house_rent', depends_on='monthly_house_rent'),
489 dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure',
490 fieldtype='Currency', insert_after='rented_in_metro_city', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530491 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530492 insert_after='salary_structure_hra', depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530493 dict(fieldname='annual_hra_exemption', label='Annual HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530494 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='monthly_house_rent'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530495 dict(fieldname='monthly_hra_exemption', label='Monthly HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530496 fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1, depends_on='monthly_house_rent')
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530497 ],
498 'Employee Tax Exemption Proof Submission': [
499 dict(fieldname='hra_section', label='HRA Exemption',
500 fieldtype='Section Break', insert_after='tax_exemption_proofs'),
501 dict(fieldname='house_rent_payment_amount', label='House Rent Payment Amount',
502 fieldtype='Currency', insert_after='hra_section'),
503 dict(fieldname='rented_in_metro_city', label='Rented in Metro City',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530504 fieldtype='Check', insert_after='house_rent_payment_amount', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530505 dict(fieldname='rented_from_date', label='Rented From Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530506 fieldtype='Date', insert_after='rented_in_metro_city', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530507 dict(fieldname='rented_to_date', label='Rented To Date',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530508 fieldtype='Date', insert_after='rented_from_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530509 dict(fieldname='hra_column_break', fieldtype='Column Break',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530510 insert_after='rented_to_date', depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530511 dict(fieldname='monthly_house_rent', label='Monthly House Rent',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530512 fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530513 dict(fieldname='monthly_hra_exemption', label='Monthly Eligible Amount',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530514 fieldtype='Currency', insert_after='monthly_house_rent', read_only=1, depends_on='house_rent_payment_amount'),
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530515 dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption',
Nabin Hait04e7bf42019-04-25 18:44:10 +0530516 fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1, depends_on='house_rent_payment_amount')
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530517 ],
518 'Supplier': [
519 {
520 'fieldname': 'gst_transporter_id',
521 'label': 'GST Transporter ID',
522 'fieldtype': 'Data',
523 'insert_after': 'supplier_type',
524 'depends_on': 'eval:doc.is_transporter'
Deepesh Garg22b61602019-03-21 20:47:47 +0530525 },
526 {
527 'fieldname': 'gst_category',
528 'label': 'GST Category',
529 'fieldtype': 'Select',
530 'insert_after': 'gst_transporter_id',
531 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders',
532 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530533 },
534 {
535 'fieldname': 'export_type',
536 'label': 'Export Type',
537 'fieldtype': 'Select',
538 'insert_after': 'gst_category',
539 'default': 'Without Payment of Tax',
540 'depends_on':'eval:in_list(["SEZ", "Overseas"], doc.gst_category)',
541 'options': '\nWith Payment of Tax\nWithout Payment of Tax'
Deepesh Garg22b61602019-03-21 20:47:47 +0530542 }
543 ],
544 'Customer': [
545 {
546 'fieldname': 'gst_category',
547 'label': 'GST Category',
548 'fieldtype': 'Select',
549 'insert_after': 'customer_type',
550 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders',
551 'default': 'Unregistered'
Deepesh Garg6e2c13f2019-12-10 15:55:05 +0530552 },
553 {
554 'fieldname': 'export_type',
555 'label': 'Export Type',
556 'fieldtype': 'Select',
557 'insert_after': 'gst_category',
558 'default': 'Without Payment of Tax',
559 'depends_on':'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)',
560 'options': '\nWith Payment of Tax\nWithout Payment of Tax'
Sagar Vorad92f3ac2018-10-10 14:51:26 +0530561 }
Shivam Mishra1d6395c2020-03-30 18:14:44 +0530562 ],
563 "Member": [
564 {
565 'fieldname': 'pan_number',
566 'label': 'PAN Details',
567 'fieldtype': 'Data',
568 'insert_after': 'email'
569 }
Ranjith Kurungadama8e047a2018-06-14 17:56:16 +0530570 ]
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530571 }
Deepesh Garg22b61602019-03-21 20:47:47 +0530572 create_custom_fields(custom_fields, update=update)
Nabin Hait9c421612017-07-20 13:32:01 +0530573
Saurabh2d8a7ee2018-05-11 13:16:16 +0530574def make_fixtures(company=None):
575 docs = []
576 company = company.name if company else frappe.db.get_value("Global Defaults", None, "default_company")
577
578 set_salary_components(docs)
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530579 set_tds_account(docs, company)
Rushabh Mehtab3c8f442017-06-21 17:22:38 +0530580
581 for d in docs:
582 try:
583 doc = frappe.get_doc(d)
584 doc.flags.ignore_permissions = True
585 doc.insert()
586 except frappe.NameError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530587 frappe.clear_messages()
Zarrar7f8024c2018-08-01 17:45:05 +0530588 except frappe.DuplicateEntryError:
Faris Ansariec7b0642019-05-14 16:21:09 +0530589 frappe.clear_messages()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530590
Zarrar7f8024c2018-08-01 17:45:05 +0530591 # create records for Tax Withholding Category
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530592 set_tax_withholding_category(company)
593
Saurabh2d8a7ee2018-05-11 13:16:16 +0530594def set_salary_components(docs):
595 docs.extend([
Nabin Hait58ee6c12020-04-26 17:45:57 +0530596 {'doctype': 'Salary Component', 'salary_component': 'Professional Tax',
597 'description': 'Professional Tax', 'type': 'Deduction', 'exempted_from_income_tax': 1},
598 {'doctype': 'Salary Component', 'salary_component': 'Provident Fund',
599 'description': 'Provident fund', 'type': 'Deduction', 'is_tax_applicable': 1},
600 {'doctype': 'Salary Component', 'salary_component': 'House Rent Allowance',
601 'description': 'House Rent Allowance', 'type': 'Earning', 'is_tax_applicable': 1},
602 {'doctype': 'Salary Component', 'salary_component': 'Basic',
603 'description': 'Basic', 'type': 'Earning', 'is_tax_applicable': 1},
604 {'doctype': 'Salary Component', 'salary_component': 'Arrear',
605 'description': 'Arrear', 'type': 'Earning', 'is_tax_applicable': 1},
606 {'doctype': 'Salary Component', 'salary_component': 'Leave Encashment',
607 'description': 'Leave Encashment', 'type': 'Earning', 'is_tax_applicable': 1}
Saurabh2d8a7ee2018-05-11 13:16:16 +0530608 ])
609
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530610def set_tax_withholding_category(company):
Saurabh2d8a7ee2018-05-11 13:16:16 +0530611 accounts = []
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530612 abbr = frappe.get_value("Company", company, "abbr")
613 tds_account = frappe.get_value("Account", 'TDS Payable - {0}'.format(abbr), 'name')
Saurabh2d8a7ee2018-05-11 13:16:16 +0530614
615 if company and tds_account:
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530616 accounts = [dict(company=company, account=tds_account)]
Saurabh2d8a7ee2018-05-11 13:16:16 +0530617
Nabin Haitafef9c12019-02-12 11:28:20 +0530618 fiscal_year = get_fiscal_year(today(), company=company)[0]
Zarrar7f8024c2018-08-01 17:45:05 +0530619 docs = get_tds_details(accounts, fiscal_year)
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530620
Zarrar7f8024c2018-08-01 17:45:05 +0530621 for d in docs:
622 try:
623 doc = frappe.get_doc(d)
624 doc.flags.ignore_permissions = True
Nabin Haitafef9c12019-02-12 11:28:20 +0530625 doc.flags.ignore_mandatory = True
Zarrar7f8024c2018-08-01 17:45:05 +0530626 doc.insert()
627 except frappe.DuplicateEntryError:
628 doc = frappe.get_doc("Tax Withholding Category", d.get("name"))
Zarrar963d62b2019-03-23 10:30:12 +0530629
630 if accounts:
631 doc.append("accounts", accounts[0])
Zarrar7f8024c2018-08-01 17:45:05 +0530632
633 # if fiscal year don't match with any of the already entered data, append rate row
634 fy_exist = [k for k in doc.get('rates') if k.get('fiscal_year')==fiscal_year]
635 if not fy_exist:
636 doc.append("rates", d.get('rates')[0])
637
638 doc.save()
Saurabh2d8a7ee2018-05-11 13:16:16 +0530639
640def set_tds_account(docs, company):
Ranjith Kurungadame51c1752018-07-24 11:07:28 +0530641 abbr = frappe.get_value("Company", company, "abbr")
Nabin Haitf77cd542018-11-20 16:46:25 +0530642 parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
643 if parent_account:
644 docs.extend([
645 {
646 "doctype": "Account",
647 "account_name": "TDS Payable",
648 "account_type": "Tax",
649 "parent_account": parent_account,
650 "company": company
651 }
652 ])
Zarrar7f8024c2018-08-01 17:45:05 +0530653
654def get_tds_details(accounts, fiscal_year):
655 # bootstrap default tax withholding sections
656 return [
657 dict(name="TDS - 194C - Company",
658 category_name="Payment to Contractors (Single / Aggregate)",
659 doctype="Tax Withholding Category", accounts=accounts,
660 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
661 "single_threshold": 30000, "cumulative_threshold": 100000}]),
662 dict(name="TDS - 194C - Individual",
663 category_name="Payment to Contractors (Single / Aggregate)",
664 doctype="Tax Withholding Category", accounts=accounts,
665 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
666 "single_threshold": 30000, "cumulative_threshold": 100000}]),
667 dict(name="TDS - 194C - No PAN / Invalid PAN",
668 category_name="Payment to Contractors (Single / Aggregate)",
669 doctype="Tax Withholding Category", accounts=accounts,
670 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
671 "single_threshold": 30000, "cumulative_threshold": 100000}]),
672 dict(name="TDS - 194D - Company",
673 category_name="Insurance Commission",
674 doctype="Tax Withholding Category", accounts=accounts,
675 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
676 "single_threshold": 15000, "cumulative_threshold": 0}]),
677 dict(name="TDS - 194D - Company Assessee",
678 category_name="Insurance Commission",
679 doctype="Tax Withholding Category", accounts=accounts,
680 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
681 "single_threshold": 15000, "cumulative_threshold": 0}]),
682 dict(name="TDS - 194D - Individual",
683 category_name="Insurance Commission",
684 doctype="Tax Withholding Category", accounts=accounts,
685 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
686 "single_threshold": 15000, "cumulative_threshold": 0}]),
687 dict(name="TDS - 194D - No PAN / Invalid PAN",
688 category_name="Insurance Commission",
689 doctype="Tax Withholding Category", accounts=accounts,
690 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
691 "single_threshold": 15000, "cumulative_threshold": 0}]),
692 dict(name="TDS - 194DA - Company",
693 category_name="Non-exempt payments made under a life insurance policy",
694 doctype="Tax Withholding Category", accounts=accounts,
695 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
696 "single_threshold": 100000, "cumulative_threshold": 0}]),
697 dict(name="TDS - 194DA - Individual",
698 category_name="Non-exempt payments made under a life insurance policy",
699 doctype="Tax Withholding Category", accounts=accounts,
700 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1,
701 "single_threshold": 100000, "cumulative_threshold": 0}]),
702 dict(name="TDS - 194DA - No PAN / Invalid PAN",
703 category_name="Non-exempt payments made under a life insurance policy",
704 doctype="Tax Withholding Category", accounts=accounts,
705 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
706 "single_threshold": 100000, "cumulative_threshold": 0}]),
707 dict(name="TDS - 194H - Company",
708 category_name="Commission / Brokerage",
709 doctype="Tax Withholding Category", accounts=accounts,
710 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
711 "single_threshold": 15000, "cumulative_threshold": 0}]),
712 dict(name="TDS - 194H - Individual",
713 category_name="Commission / Brokerage",
714 doctype="Tax Withholding Category", accounts=accounts,
715 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5,
716 "single_threshold": 15000, "cumulative_threshold": 0}]),
717 dict(name="TDS - 194H - No PAN / Invalid PAN",
718 category_name="Commission / Brokerage",
719 doctype="Tax Withholding Category", accounts=accounts,
720 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
721 "single_threshold": 15000, "cumulative_threshold": 0}]),
722 dict(name="TDS - 194I - Rent - Company",
723 category_name="Rent",
724 doctype="Tax Withholding Category", accounts=accounts,
725 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
726 "single_threshold": 180000, "cumulative_threshold": 0}]),
727 dict(name="TDS - 194I - Rent - Individual",
728 category_name="Rent",
729 doctype="Tax Withholding Category", accounts=accounts,
730 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
731 "single_threshold": 180000, "cumulative_threshold": 0}]),
732 dict(name="TDS - 194I - Rent - No PAN / Invalid PAN",
733 category_name="Rent",
734 doctype="Tax Withholding Category", accounts=accounts,
735 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
736 "single_threshold": 180000, "cumulative_threshold": 0}]),
737 dict(name="TDS - 194I - Rent/Machinery - Company",
738 category_name="Rent-Plant / Machinery",
739 doctype="Tax Withholding Category", accounts=accounts,
740 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
741 "single_threshold": 180000, "cumulative_threshold": 0}]),
742 dict(name="TDS - 194I - Rent/Machinery - Individual",
743 category_name="Rent-Plant / Machinery",
744 doctype="Tax Withholding Category", accounts=accounts,
745 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2,
746 "single_threshold": 180000, "cumulative_threshold": 0}]),
747 dict(name="TDS - 194I - Rent/Machinery - No PAN / Invalid PAN",
748 category_name="Rent-Plant / Machinery",
749 doctype="Tax Withholding Category", accounts=accounts,
750 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
751 "single_threshold": 180000, "cumulative_threshold": 0}]),
752 dict(name="TDS - 194J - Professional Fees - Company",
753 category_name="Professional Fees",
754 doctype="Tax Withholding Category", accounts=accounts,
755 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
756 "single_threshold": 30000, "cumulative_threshold": 0}]),
757 dict(name="TDS - 194J - Professional Fees - Individual",
758 category_name="Professional Fees",
759 doctype="Tax Withholding Category", accounts=accounts,
760 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
761 "single_threshold": 30000, "cumulative_threshold": 0}]),
762 dict(name="TDS - 194J - Professional Fees - No PAN / Invalid PAN",
763 category_name="Professional Fees",
764 doctype="Tax Withholding Category", accounts=accounts,
765 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
766 "single_threshold": 30000, "cumulative_threshold": 0}]),
767 dict(name="TDS - 194J - Director Fees - Company",
768 category_name="Director Fees",
769 doctype="Tax Withholding Category", accounts=accounts,
770 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
771 "single_threshold": 0, "cumulative_threshold": 0}]),
772 dict(name="TDS - 194J - Director Fees - Individual",
773 category_name="Director Fees",
774 doctype="Tax Withholding Category", accounts=accounts,
775 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
776 "single_threshold": 0, "cumulative_threshold": 0}]),
777 dict(name="TDS - 194J - Director Fees - No PAN / Invalid PAN",
778 category_name="Director Fees",
779 doctype="Tax Withholding Category", accounts=accounts,
780 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
781 "single_threshold": 0, "cumulative_threshold": 0}]),
782 dict(name="TDS - 194 - Dividends - Company",
783 category_name="Dividends",
784 doctype="Tax Withholding Category", accounts=accounts,
785 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
786 "single_threshold": 2500, "cumulative_threshold": 0}]),
787 dict(name="TDS - 194 - Dividends - Individual",
788 category_name="Dividends",
789 doctype="Tax Withholding Category", accounts=accounts,
790 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10,
791 "single_threshold": 2500, "cumulative_threshold": 0}]),
792 dict(name="TDS - 194 - Dividends - No PAN / Invalid PAN",
793 category_name="Dividends",
794 doctype="Tax Withholding Category", accounts=accounts,
795 rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20,
796 "single_threshold": 2500, "cumulative_threshold": 0}])
Anurag Mishrae1464a72020-08-17 15:03:32 +0530797 ]
798
799def create_standard_documents():
800
801 # Standard Indain Gratuity Rule
802
803 rule = frappe.new_doc("Gratuity Rule")
804 rule.name = "Indian Standard Gratuity Rule"
805 rule.calculate_gratuity_amount_based_on = "Current Slab"
806 rule.work_experience_calculation_method = "Round Off Work Experience"
807 rule.minimum_year_for_gratuity = 5
808
809 fraction = 15/26
810 rule.append("gratuity_rule_slabs", {
811 "from_year": 0,
812 "to_year":0,
813 "fraction_of_applicable_earnings": fraction
814 })
815
816 rule.flags.ignore_mandatory = True
817 rule.save()