def calculate_annual_eligible_hra_exemption(doc): basic_component = frappe.get_cached_value('Company', doc.company, "basic_component") hra_component = frappe.get_cached_value('Company', doc.company, "hra_component") annual_exemption, monthly_exemption, hra_amount = 0, 0, 0 if hra_component and basic_component: assignment = get_salary_assignment(doc.employee, getdate()) if assignment and frappe.db.exists( "Salary Detail", { "parent": assignment.salary_structure, "salary_component": hra_component, "parentfield": "earnings" }): basic_amount, hra_amount = get_component_amt_from_salary_slip( doc.employee, assignment.salary_structure, basic_component, hra_component) if hra_amount: if doc.monthly_house_rent: annual_exemption = calculate_hra_exemption( assignment.salary_structure, basic_amount, hra_amount, doc.monthly_house_rent, doc.rented_in_metro_city) if annual_exemption > 0: monthly_exemption = annual_exemption / 12 else: annual_exemption = 0 return { "hra_amount": hra_amount, "annual_exemption": annual_exemption, "monthly_exemption": monthly_exemption }
def calculate_annual_eligible_hra_exemption(doc): basic_component, hra_component = frappe.db.get_value('Company', doc.company, ["basic_component", "hra_component"]) if not (basic_component and hra_component): frappe.throw(_("Please mention Basic and HRA component in Company")) annual_exemption, monthly_exemption, hra_amount = 0, 0, 0 if hra_component and basic_component: assignment = get_salary_assignment(doc.employee, nowdate()) if assignment: hra_component_exists = frappe.db.exists("Salary Detail", { "parent": assignment.salary_structure, "salary_component": hra_component, "parentfield": "earnings", "parenttype": "Salary Structure" }) if hra_component_exists: basic_amount, hra_amount = get_component_amt_from_salary_slip(doc.employee, assignment.salary_structure, basic_component, hra_component) if hra_amount: if doc.monthly_house_rent: annual_exemption = calculate_hra_exemption(assignment.salary_structure, basic_amount, hra_amount, doc.monthly_house_rent, doc.rented_in_metro_city) if annual_exemption > 0: monthly_exemption = annual_exemption / 12 else: annual_exemption = 0 elif doc.docstatus == 1: frappe.throw(_("Salary Structure must be submitted before submission of Tax Ememption Declaration")) return frappe._dict({ "hra_amount": hra_amount, "annual_exemption": annual_exemption, "monthly_exemption": monthly_exemption })
def calculate_annual_eligible_hra_exemption(doc): basic_component = frappe.get_cached_value('Company', doc.company, "basic_component") hra_component = frappe.get_cached_value('Company', doc.company, "hra_component") annual_exemption, monthly_exemption, hra_amount = 0, 0, 0 if hra_component and basic_component: assignment = get_salary_assignment(doc.employee, getdate()) if assignment and frappe.db.exists("Salary Detail", { "parent": assignment.salary_structure, "salary_component": hra_component, "parentfield": "earnings"}): basic_amount, hra_amount = get_component_amt_from_salary_slip(doc.employee, assignment.salary_structure, basic_component, hra_component) if hra_amount: if doc.monthly_house_rent: annual_exemption = calculate_hra_exemption(assignment.salary_structure, basic_amount, hra_amount, doc.monthly_house_rent, doc.rented_in_metro_city) if annual_exemption > 0: monthly_exemption = annual_exemption / 12 else: annual_exemption = 0 return {"hra_amount": hra_amount, "annual_exemption": annual_exemption, "monthly_exemption": monthly_exemption}
def calculate_annual_eligible_hra_exemption(doc): basic_component = frappe.get_cached_value('Company', doc.company, "basic_component") hra_component = frappe.get_cached_value('Company', doc.company, "hra_component") if not (basic_component and hra_component): frappe.throw(_("Please mention Basic and HRA component in Company")) annual_exemption, monthly_exemption, hra_amount = 0, 0, 0 if hra_component and basic_component: assignment = get_salary_assignment(doc.employee, nowdate()) if assignment: hra_component_exists = frappe.db.exists("Salary Detail", { "parent": assignment.salary_structure, "salary_component": hra_component, "parentfield": "earnings", "parenttype": "Salary Structure" }) if hra_component_exists: basic_amount, hra_amount = get_component_amt_from_salary_slip(doc.employee, assignment.salary_structure, basic_component, hra_component) if hra_amount: if doc.monthly_house_rent: annual_exemption = calculate_hra_exemption(assignment.salary_structure, basic_amount, hra_amount, doc.monthly_house_rent, doc.rented_in_metro_city) if annual_exemption > 0: monthly_exemption = annual_exemption / 12 else: annual_exemption = 0 elif doc.docstatus == 1: frappe.throw(_("Salary Structure must be submitted before submission of Tax Ememption Declaration")) return frappe._dict({ "hra_amount": hra_amount, "annual_exemption": annual_exemption, "monthly_exemption": monthly_exemption })