Skip to content

Commit

Permalink
fix: show opening balances section if employee joined after payroll p…
Browse files Browse the repository at this point in the history
…eriod
  • Loading branch information
ruchamahabal committed Oct 18, 2024
1 parent 627e391 commit 574176d
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from frappe.model.document import Document
from frappe.utils import cint, flt, get_link_to_form, getdate

from hrms.payroll.doctype.payroll_period.payroll_period import get_payroll_period


class DuplicateAssignment(frappe.ValidationError):
pass
Expand Down Expand Up @@ -150,7 +152,7 @@ def warn_about_missing_opening_entries(self):

@frappe.whitelist()
def are_opening_entries_required(self) -> bool:
if not self.emp_joined_in_the_same_month() and not self.has_existing_salary_slips():
if self.has_emp_joined_after_payroll_period_start() and not self.has_existing_salary_slips():
return True
else:
if not self.docstatus.is_draft() and (
Expand All @@ -167,16 +169,11 @@ def has_existing_salary_slips(self) -> bool:
)
)

def emp_joined_in_the_same_month(self) -> bool:
date_of_joining = frappe.db.get_value("Employee", self.employee, "date_of_joining")
from_date = getdate(self.from_date)
def has_emp_joined_after_payroll_period_start(self) -> bool:
date_of_joining = getdate(frappe.db.get_value("Employee", self.employee, "date_of_joining"))
payroll_period = get_payroll_period(self.from_date, self.from_date, self.company)

if (
self.from_date
and date_of_joining
and date_of_joining.month == from_date.month
and date_of_joining.year == from_date.year
):
if date_of_joining and date_of_joining > payroll_period.start_date:
return True
return False

Expand Down

0 comments on commit 574176d

Please sign in to comment.