Skip to content

Commit

Permalink
fix: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh6790 committed Mar 9, 2023
1 parent 563f83f commit 341eab2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions erpnext/payroll/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def get_working_days_details(
)

working_days = date_diff(self.end_date, self.start_date) + 1
working_days_list = [add_days(self.start_date)for i in range(working_days)]
working_days_list = [add_days(self.start_date, i) for i in range(working_days)]

if for_preview:
self.total_working_days = working_days
Expand All @@ -324,7 +324,7 @@ def get_working_days_details(

holidays = self.get_holidays_for_employee(self.start_date, self.end_date)

joining_date, relieving_date = self.get_joining_and_relieving_date()
joining_date, relieving_date = self.get_joining_and_relieving_dates()

if not cint(include_holidays_in_total_working_days):
working_days -= len(holidays)
Expand All @@ -337,10 +337,14 @@ def get_working_days_details(
frappe.throw(_("Please set Payroll based on in Payroll settings"))

if payroll_based_on == "Attendance":
actual_lwp, absent = self.calculate_lwp_ppl_and_absent_days_based_on_attendance(holidays, relieving_date)
actual_lwp, absent = self.calculate_lwp_ppl_and_absent_days_based_on_attendance(
holidays, relieving_date
)
self.absent_days = absent
else:
actual_lwp = self.calculate_lwp_or_ppl_based_on_leave_application(holidays, working_days_list, relieving_date)
actual_lwp = self.calculate_lwp_or_ppl_based_on_leave_application(
holidays, working_days_list, relieving_date
)

if not lwp:
lwp = actual_lwp
Expand Down Expand Up @@ -463,7 +467,10 @@ def get_payment_days(self, joining_date, relieving_date, include_holidays_in_tot
def get_holidays_for_employee(self, 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_list, relieving_date=None):
def calculate_lwp_or_ppl_based_on_leave_application(
self, holidays, working_days_list, relieving_date=None
):

lwp = 0

daily_wages_fraction_for_half_day = (
Expand Down
2 changes: 1 addition & 1 deletion erpnext/payroll/doctype/salary_slip/test_salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,6 @@ def test_salary_slip_generation_against_opening_entries_in_ssa(self):
if deduction.salary_component == "TDS":
self.assertEqual(deduction.amount, rounded(monthly_tax_amount))


@change_settings("Payroll Settings", {"payroll_based_on": "Leave"})
def test_lwp_calculation_based_on_relieving_date(self):
emp_id = make_employee("test_lwp_based_on_relieving_date@salary.com")
Expand Down Expand Up @@ -1158,6 +1157,7 @@ def test_lwp_calculation_based_on_relieving_date(self):

self.assertEqual(ss.payment_days, (days_between_start_and_relieving - len(holidays)))


def get_no_of_days():
no_of_days_in_month = calendar.monthrange(getdate(nowdate()).year, getdate(nowdate()).month)
no_of_holidays_in_month = len(
Expand Down

0 comments on commit 341eab2

Please sign in to comment.