fix: LWP calculation
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import math
|
import math
|
||||||
|
|
||||||
@@ -316,6 +315,8 @@ class SalarySlip(TransactionBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
working_days = date_diff(self.end_date, self.start_date) + 1
|
working_days = date_diff(self.end_date, self.start_date) + 1
|
||||||
|
working_days_list = [add_days(self.start_date, i) for i in range(working_days)]
|
||||||
|
|
||||||
if for_preview:
|
if for_preview:
|
||||||
self.total_working_days = working_days
|
self.total_working_days = working_days
|
||||||
self.payment_days = working_days
|
self.payment_days = working_days
|
||||||
@@ -335,7 +336,7 @@ class SalarySlip(TransactionBase):
|
|||||||
actual_lwp, absent = self.calculate_lwp_ppl_and_absent_days_based_on_attendance(holidays)
|
actual_lwp, absent = self.calculate_lwp_ppl_and_absent_days_based_on_attendance(holidays)
|
||||||
self.absent_days = absent
|
self.absent_days = absent
|
||||||
else:
|
else:
|
||||||
actual_lwp = self.calculate_lwp_or_ppl_based_on_leave_application(holidays, working_days)
|
actual_lwp = self.calculate_lwp_or_ppl_based_on_leave_application(holidays, working_days_list)
|
||||||
|
|
||||||
if not lwp:
|
if not lwp:
|
||||||
lwp = actual_lwp
|
lwp = actual_lwp
|
||||||
@@ -458,16 +459,15 @@ class SalarySlip(TransactionBase):
|
|||||||
def get_holidays_for_employee(self, start_date, end_date):
|
def get_holidays_for_employee(self, start_date, end_date):
|
||||||
return get_holiday_dates_for_employee(self.employee, start_date, end_date)
|
return get_holiday_dates_for_employee(self.employee, start_date, end_date)
|
||||||
|
|
||||||
def calculate_lwp_or_ppl_based_on_leave_application(self, holidays, working_days):
|
def calculate_lwp_or_ppl_based_on_leave_application(self, holidays, working_days_list):
|
||||||
lwp = 0
|
lwp = 0
|
||||||
holidays = "','".join(holidays)
|
|
||||||
daily_wages_fraction_for_half_day = (
|
daily_wages_fraction_for_half_day = (
|
||||||
flt(frappe.db.get_value("Payroll Settings", None, "daily_wages_fraction_for_half_day")) or 0.5
|
flt(frappe.db.get_value("Payroll Settings", None, "daily_wages_fraction_for_half_day")) or 0.5
|
||||||
)
|
)
|
||||||
|
|
||||||
for d in range(working_days):
|
for d in working_days_list:
|
||||||
date = add_days(cstr(getdate(self.start_date)), d)
|
leave = get_lwp_or_ppl_for_date(d, self.employee, holidays)
|
||||||
leave = get_lwp_or_ppl_for_date(date, self.employee, holidays)
|
|
||||||
|
|
||||||
if leave:
|
if leave:
|
||||||
equivalent_lwp_count = 0
|
equivalent_lwp_count = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user