blob: 33f8cb2895b5c5cb50782e425ea0c82111d5a782 [file] [log] [blame]
Sagar Vora12b7e142022-06-24 13:20:46 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2# License: GNU General Public License v3. See license.txt
3
4
5import frappe
6from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
7
8
9def setup(company=None, patch=True):
10 # Company independent fixtures should be called only once at the first company setup
11 if patch or frappe.db.count("Company", {"country": "India"}) <= 1:
12 make_custom_fields()
13 create_gratuity_rule()
14 create_salary_components()
15
16
17def make_custom_fields():
18 create_custom_fields(
19 {
20 "Salary Component": [
21 {
22 "fieldname": "component_type",
23 "label": "Component Type",
24 "fieldtype": "Select",
25 "insert_after": "description",
26 "options": (
27 "\nProvident Fund\nAdditional Provident Fund\nProvident Fund" " Loan\nProfessional Tax"
28 ),
29 "depends_on": 'eval:doc.type == "Deduction"',
30 "translatable": 0,
31 },
32 ],
33 "Employee": [
34 {
35 "fieldname": "ifsc_code",
36 "label": "IFSC Code",
37 "fieldtype": "Data",
38 "insert_after": "bank_ac_no",
39 "print_hide": 1,
40 "depends_on": 'eval:doc.salary_mode == "Bank"',
41 "translatable": 0,
42 },
43 {
44 "fieldname": "pan_number",
45 "label": "PAN Number",
46 "fieldtype": "Data",
47 "insert_after": "payroll_cost_center",
48 "print_hide": 1,
49 "translatable": 0,
50 },
51 {
52 "fieldname": "micr_code",
53 "label": "MICR Code",
54 "fieldtype": "Data",
55 "insert_after": "ifsc_code",
56 "print_hide": 1,
57 "depends_on": 'eval:doc.salary_mode == "Bank"',
58 "translatable": 0,
59 },
60 {
61 "fieldname": "provident_fund_account",
62 "label": "Provident Fund Account",
63 "fieldtype": "Data",
64 "insert_after": "pan_number",
65 "translatable": 0,
66 },
67 ],
68 "Company": [
69 {
70 "fieldname": "hra_section",
71 "label": "HRA Settings",
72 "fieldtype": "Section Break",
73 "insert_after": "asset_received_but_not_billed",
74 "collapsible": 1,
75 },
76 {
77 "fieldname": "basic_component",
78 "label": "Basic Component",
79 "fieldtype": "Link",
80 "options": "Salary Component",
81 "insert_after": "hra_section",
82 },
83 {
84 "fieldname": "hra_component",
85 "label": "HRA Component",
86 "fieldtype": "Link",
87 "options": "Salary Component",
88 "insert_after": "basic_component",
89 },
90 {
91 "fieldname": "hra_column_break",
92 "fieldtype": "Column Break",
93 "insert_after": "hra_component",
94 },
95 {
96 "fieldname": "arrear_component",
97 "label": "Arrear Component",
98 "fieldtype": "Link",
99 "options": "Salary Component",
100 "insert_after": "hra_column_break",
101 },
102 {
103 "fieldname": "non_profit_section",
104 "label": "Non Profit Settings",
105 "fieldtype": "Section Break",
106 "insert_after": "arrear_component",
107 "collapsible": 1,
108 },
109 {
110 "fieldname": "company_80g_number",
111 "label": "80G Number",
112 "fieldtype": "Data",
113 "insert_after": "non_profit_section",
114 "translatable": 0,
115 },
116 {
117 "fieldname": "with_effect_from",
118 "label": "80G With Effect From",
119 "fieldtype": "Date",
120 "insert_after": "company_80g_number",
121 },
122 ],
123 "Employee Tax Exemption Declaration": [
124 {
125 "fieldname": "hra_section",
126 "label": "HRA Exemption",
127 "fieldtype": "Section Break",
128 "insert_after": "declarations",
129 },
130 {
131 "fieldname": "monthly_house_rent",
132 "label": "Monthly House Rent",
133 "fieldtype": "Currency",
134 "insert_after": "hra_section",
135 },
136 {
137 "fieldname": "rented_in_metro_city",
138 "label": "Rented in Metro City",
139 "fieldtype": "Check",
140 "insert_after": "monthly_house_rent",
141 "depends_on": "monthly_house_rent",
142 },
143 {
144 "fieldname": "salary_structure_hra",
145 "label": "HRA as per Salary Structure",
146 "fieldtype": "Currency",
147 "insert_after": "rented_in_metro_city",
148 "read_only": 1,
149 "depends_on": "monthly_house_rent",
150 },
151 {
152 "fieldname": "hra_column_break",
153 "fieldtype": "Column Break",
154 "insert_after": "salary_structure_hra",
155 "depends_on": "monthly_house_rent",
156 },
157 {
158 "fieldname": "annual_hra_exemption",
159 "label": "Annual HRA Exemption",
160 "fieldtype": "Currency",
161 "insert_after": "hra_column_break",
162 "read_only": 1,
163 "depends_on": "monthly_house_rent",
164 },
165 {
166 "fieldname": "monthly_hra_exemption",
167 "label": "Monthly HRA Exemption",
168 "fieldtype": "Currency",
169 "insert_after": "annual_hra_exemption",
170 "read_only": 1,
171 "depends_on": "monthly_house_rent",
172 },
173 ],
174 "Employee Tax Exemption Proof Submission": [
175 {
176 "fieldname": "hra_section",
177 "label": "HRA Exemption",
178 "fieldtype": "Section Break",
179 "insert_after": "tax_exemption_proofs",
180 },
181 {
182 "fieldname": "house_rent_payment_amount",
183 "label": "House Rent Payment Amount",
184 "fieldtype": "Currency",
185 "insert_after": "hra_section",
186 },
187 {
188 "fieldname": "rented_in_metro_city",
189 "label": "Rented in Metro City",
190 "fieldtype": "Check",
191 "insert_after": "house_rent_payment_amount",
192 "depends_on": "house_rent_payment_amount",
193 },
194 {
195 "fieldname": "rented_from_date",
196 "label": "Rented From Date",
197 "fieldtype": "Date",
198 "insert_after": "rented_in_metro_city",
199 "depends_on": "house_rent_payment_amount",
200 },
201 {
202 "fieldname": "rented_to_date",
203 "label": "Rented To Date",
204 "fieldtype": "Date",
205 "insert_after": "rented_from_date",
206 "depends_on": "house_rent_payment_amount",
207 },
208 {
209 "fieldname": "hra_column_break",
210 "fieldtype": "Column Break",
211 "insert_after": "rented_to_date",
212 "depends_on": "house_rent_payment_amount",
213 },
214 {
215 "fieldname": "monthly_house_rent",
216 "label": "Monthly House Rent",
217 "fieldtype": "Currency",
218 "insert_after": "hra_column_break",
219 "read_only": 1,
220 "depends_on": "house_rent_payment_amount",
221 },
222 {
223 "fieldname": "monthly_hra_exemption",
224 "label": "Monthly Eligible Amount",
225 "fieldtype": "Currency",
226 "insert_after": "monthly_house_rent",
227 "read_only": 1,
228 "depends_on": "house_rent_payment_amount",
229 },
230 {
231 "fieldname": "total_eligible_hra_exemption",
232 "label": "Total Eligible HRA Exemption",
233 "fieldtype": "Currency",
234 "insert_after": "monthly_hra_exemption",
235 "read_only": 1,
236 "depends_on": "house_rent_payment_amount",
237 },
238 ],
239 }
240 )
241
242
243def create_gratuity_rule():
244 # Standard Indain Gratuity Rule
245 if frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
246 return
247
248 rule = frappe.new_doc("Gratuity Rule")
249 rule.update(
250 {
251 "name": "Indian Standard Gratuity Rule",
252 "calculate_gratuity_amount_based_on": "Current Slab",
253 "work_experience_calculation_method": "Round Off Work Experience",
254 "minimum_year_for_gratuity": 5,
255 "gratuity_rule_slabs": [
256 {
257 "from_year": 0,
258 "to_year": 0,
259 "fraction_of_applicable_earnings": 15 / 26,
260 }
261 ],
262 }
263 )
264 rule.flags.ignore_mandatory = True
265 rule.save()
266
267
268def create_salary_components():
269 docs = [
270 {
271 "doctype": "Salary Component",
272 "salary_component": "Professional Tax",
273 "description": "Professional Tax",
274 "type": "Deduction",
275 "exempted_from_income_tax": 1,
276 },
277 {
278 "doctype": "Salary Component",
279 "salary_component": "Provident Fund",
280 "description": "Provident fund",
281 "type": "Deduction",
282 "is_tax_applicable": 1,
283 },
284 {
285 "doctype": "Salary Component",
286 "salary_component": "House Rent Allowance",
287 "description": "House Rent Allowance",
288 "type": "Earning",
289 "is_tax_applicable": 1,
290 },
291 {
292 "doctype": "Salary Component",
293 "salary_component": "Basic",
294 "description": "Basic",
295 "type": "Earning",
296 "is_tax_applicable": 1,
297 },
298 {
299 "doctype": "Salary Component",
300 "salary_component": "Arrear",
301 "description": "Arrear",
302 "type": "Earning",
303 "is_tax_applicable": 1,
304 },
305 {
306 "doctype": "Salary Component",
307 "salary_component": "Leave Encashment",
308 "description": "Leave Encashment",
309 "type": "Earning",
310 "is_tax_applicable": 1,
311 },
312 ]
313
314 for d in docs:
315 try:
316 doc = frappe.get_doc(d)
317 doc.flags.ignore_permissions = True
318 doc.insert(ignore_if_duplicate=True)
319
320 except frappe.DuplicateEntryError:
321 frappe.clear_messages()