Pro-rata component consistency for monthly Salary slip (#14595)

* Pro-rata component consistency for monthly Salary slip

* Resolve merge conflict
This commit is contained in:
Jamsheer 2018-06-20 12:41:32 +05:30 committed by Nabin Hait
parent 05d00397d0
commit a1bb94e59d
3 changed files with 15 additions and 9 deletions

View File

@ -164,7 +164,7 @@ def calculate_lwp(employee, start_date, holidays, working_days):
lwp = cint(leave[0][1]) and (lwp + 0.5) or (lwp + 1)
return lwp
def get_benefit_component_amount(employee, start_date, end_date, struct_row, sal_struct, payment_days, working_days):
def get_benefit_component_amount(employee, start_date, end_date, struct_row, sal_struct, payment_days, working_days, frequency):
# Considering there is only one application for an year
benefit_application_name = frappe.db.sql("""
select name from `tabEmployee Benefit Application`
@ -177,12 +177,16 @@ def get_benefit_component_amount(employee, start_date, end_date, struct_row, sal
'end_date': end_date
})
payroll_period_days = get_payroll_period_days(start_date, end_date, employee)
if payroll_period_days:
depends_on_lwp = frappe.db.get_value("Salary Component", struct_row.salary_component, "depends_on_lwp")
if depends_on_lwp != 1:
payment_days = working_days
payroll_period_days, actual_payroll_days = get_payroll_period_days(start_date, end_date, employee)
depends_on_lwp = frappe.db.get_value("Salary Component", struct_row.salary_component, "depends_on_lwp")
if depends_on_lwp != 1:
payment_days = working_days
if frequency == "Monthly" and actual_payroll_days in range(360, 370):
payment_days = 1
payroll_period_days = 12
if payroll_period_days:
# If there is application for benefit then fetch the amount from the application.
# else Split the max benefits to the pro-rata components with the ratio of thier max_benefit_amount
if benefit_application_name:

View File

@ -61,9 +61,10 @@ def get_payroll_period_days(start_date, end_date, employee):
})
if len(payroll_period_dates) > 0:
working_days = date_diff(getdate(payroll_period_dates[0][1]), getdate(payroll_period_dates[0][0])) + 1
actual_no_of_days = date_diff(getdate(payroll_period_dates[0][1]), getdate(payroll_period_dates[0][0])) + 1
working_days = actual_no_of_days
if not cint(frappe.db.get_value("HR Settings", None, "include_holidays_in_total_working_days")):
holidays = get_holidays_for_employee(employee, getdate(payroll_period_dates[0][0]), getdate(payroll_period_dates[0][1]))
working_days -= len(holidays)
return working_days
return working_days, actual_no_of_days
return False

View File

@ -89,7 +89,8 @@ class SalarySlip(TransactionBase):
def add_employee_flexi_benefits(self, struct_row):
if frappe.db.get_value("Salary Component", struct_row.salary_component, "pay_against_benefit_claim") != 1:
benefit_component_amount = get_benefit_component_amount(self.employee, self.start_date, self.end_date, struct_row, self._salary_structure_doc, self.payment_days, self.total_working_days)
benefit_component_amount = get_benefit_component_amount(self.employee, self.start_date, self.end_date, \
struct_row, self._salary_structure_doc, self.payment_days, self.total_working_days, self.payroll_frequency)
if benefit_component_amount:
self.update_component_row(struct_row, benefit_component_amount, "earnings")
else: