Fix benefits (#14735)

* Employee Benefit Application - fix typo

* Employee Benefits - fix field renamed
This commit is contained in:
Ranjith Kurungadam 2018-06-28 23:02:58 +05:30 committed by Nabin Hait
parent 631cc30a8b
commit 6ceed038e6
4 changed files with 17 additions and 17 deletions

View File

@ -83,7 +83,7 @@ var calculate_all = function(doc) {
} }
} }
doc.total_amount = total_amount; doc.total_amount = total_amount;
doc.remainig_benefits = doc.max_benefits - total_amount; doc.remaining_benefit = doc.max_benefits - total_amount;
doc.pro_rata_dispensed_amount = pro_rata_dispensed_amount; doc.pro_rata_dispensed_amount = pro_rata_dispensed_amount;
refresh_many(['pro_rata_dispensed_amount', 'total_amount','remainig_benefits']); refresh_many(['pro_rata_dispensed_amount', 'total_amount','remaining_benefit']);
}; };

View File

@ -119,7 +119,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fieldname": "remainig_benefits", "fieldname": "remaining_benefit",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
@ -445,7 +445,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-05-25 12:01:01.490375", "modified": "2018-06-28 18:25:01.490375",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Employee Benefit Application", "name": "Employee Benefit Application",

View File

@ -18,7 +18,7 @@ class EmployeeBenefitApplication(Document):
frappe.throw(_("Employee {0} has no maximum benefit amount").format(self.employee)) frappe.throw(_("Employee {0} has no maximum benefit amount").format(self.employee))
self.validate_max_benefit_for_component() self.validate_max_benefit_for_component()
self.validate_prev_benefit_claim() self.validate_prev_benefit_claim()
if self.remainig_benefits > 0: if self.remaining_benefit > 0:
self.validate_remaining_benefit_amount() self.validate_remaining_benefit_amount()
def validate_prev_benefit_claim(self): def validate_prev_benefit_claim(self):
@ -35,7 +35,7 @@ class EmployeeBenefitApplication(Document):
def validate_remaining_benefit_amount(self): def validate_remaining_benefit_amount(self):
# check salary structure earnings have flexi component (sum of max_benefit_amount) # check salary structure earnings have flexi component (sum of max_benefit_amount)
# without pro-rata which satisfy the remainig_benefits # without pro-rata which satisfy the remaining_benefit
# else pro-rata component for the amount # else pro-rata component for the amount
# again comes the same validation and satisfy or throw # again comes the same validation and satisfy or throw
benefit_components = [] benefit_components = []
@ -57,13 +57,13 @@ class EmployeeBenefitApplication(Document):
non_pro_rata_amount += max_benefit_amount non_pro_rata_amount += max_benefit_amount
if pro_rata_amount == 0 and non_pro_rata_amount == 0: if pro_rata_amount == 0 and non_pro_rata_amount == 0:
frappe.throw(_("Please add the remainig benefits {0} to any of the existing component").format(self.remainig_benefits)) frappe.throw(_("Please add the remainig benefits {0} to any of the existing component").format(self.remaining_benefit))
elif non_pro_rata_amount > 0 and non_pro_rata_amount < rounded(self.remainig_benefits): elif non_pro_rata_amount > 0 and non_pro_rata_amount < rounded(self.remaining_benefit):
frappe.throw(_("You can claim only an amount of {0}, the rest amount {1} should be in the application \ frappe.throw(_("You can claim only an amount of {0}, the rest amount {1} should be in the application \
as pro-rata component").format(non_pro_rata_amount, self.remainig_benefits - non_pro_rata_amount)) as pro-rata component").format(non_pro_rata_amount, self.remaining_benefit - non_pro_rata_amount))
elif non_pro_rata_amount == 0: elif non_pro_rata_amount == 0:
frappe.throw(_("Please add the remainig benefits {0} to the application as \ frappe.throw(_("Please add the remainig benefits {0} to the application as \
pro-rata component").format(self.remainig_benefits)) pro-rata component").format(self.remaining_benefit))
def validate_max_benefit_for_component(self): def validate_max_benefit_for_component(self):
if self.employee_benefits: if self.employee_benefits:

View File

@ -128,7 +128,7 @@ def get_total_benefit_dispensed(employee, sal_struct, sal_slip_start_date, payro
) )
if application: if application:
application_obj = frappe.get_doc("Employee Benefit Application", application) application_obj = frappe.get_doc("Employee Benefit Application", application)
pro_rata_amount = application_obj.pro_rata_dispensed_amount + application_obj.max_benefits - application_obj.remainig_benefits pro_rata_amount = application_obj.pro_rata_dispensed_amount + application_obj.max_benefits - application_obj.remaining_benefit
else: else:
pro_rata_amount = get_benefit_pro_rata_ratio_amount(employee, sal_slip_start_date, sal_struct) pro_rata_amount = get_benefit_pro_rata_ratio_amount(employee, sal_slip_start_date, sal_struct)
@ -140,23 +140,23 @@ def get_last_payroll_period_benefits(employee, sal_slip_start_date, sal_slip_end
max_benefits = get_max_benefits(employee, payroll_period.end_date) max_benefits = get_max_benefits(employee, payroll_period.end_date)
if not max_benefits: if not max_benefits:
max_benefits = 0 max_benefits = 0
remainig_benefits = max_benefits - get_total_benefit_dispensed(employee, sal_struct, sal_slip_start_date, payroll_period) remaining_benefit = max_benefits - get_total_benefit_dispensed(employee, sal_struct, sal_slip_start_date, payroll_period)
if remainig_benefits > 0: if remaining_benefit > 0:
have_remaining = True have_remaining = True
# Set the remainig benefits to flexi non pro-rata component in the salary structure # Set the remainig benefits to flexi non pro-rata component in the salary structure
salary_components_array = [] salary_components_array = []
for d in sal_struct.get("earnings"): for d in sal_struct.get("earnings"):
if d.is_flexible_benefit == 1: if d.is_flexible_benefit == 1:
salary_component = frappe.get_doc("Salary Component", d.salary_component) salary_component = frappe.get_doc("Salary Component", d.salary_component)
if salary_component.is_pro_rata_applicable != 1: if salary_component.pay_against_benefit_claim == 1:
claimed_amount = get_benefit_claim_amount(employee, payroll_period.start_date, sal_slip_end_date, d.salary_component) claimed_amount = get_benefit_claim_amount(employee, payroll_period.start_date, sal_slip_end_date, d.salary_component)
amount_fit_to_component = salary_component.max_benefit_amount - claimed_amount amount_fit_to_component = salary_component.max_benefit_amount - claimed_amount
if amount_fit_to_component > 0: if amount_fit_to_component > 0:
if remainig_benefits > amount_fit_to_component: if remaining_benefit > amount_fit_to_component:
amount = amount_fit_to_component amount = amount_fit_to_component
remainig_benefits -= amount_fit_to_component remaining_benefit -= amount_fit_to_component
else: else:
amount = remainig_benefits amount = remaining_benefit
have_remaining = False have_remaining = False
current_claimed_amount = get_benefit_claim_amount(employee, sal_slip_start_date, sal_slip_end_date, d.salary_component) current_claimed_amount = get_benefit_claim_amount(employee, sal_slip_start_date, sal_slip_end_date, d.salary_component)
amount += current_claimed_amount amount += current_claimed_amount