Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Wrong CTC in Salary Slip, for case SSA with opening balance #2469

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion hrms/payroll/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,34 @@ def get_taxable_earnings_for_prev_period(self, start_date, end_date, allow_tax_e
return (taxable_earnings + opening_taxable_earning) - exempted_amount, exempted_amount

def get_opening_for(self, field_to_select, start_date, end_date):
return self._salary_structure_assignment.get(field_to_select) or 0
# Only if salary slip is same period as the first salary slip to use opening amount
first_ss = frappe.db.get_value(
"Salary Slip",
{
"employee": self.employee,
"docstatus": 1,
"company": self.company,
},
"name",
order_by="start_date asc",
)
if first_ss:
doc = frappe.get_cached_doc("Salary Slip", first_ss)
if self.payroll_period != doc.payroll_period:
return 0
# Otherwise, find amount from first SSA which has opening balance
ssa_opening = frappe.db.get_value(
"Salary Structure Assignment",
{
"employee": self.employee,
"docstatus": 1,
"company": self.company,
field_to_select: [">", 0],
},
field_to_select,
order_by="from_date asc",
)
return ssa_opening or 0

def get_salary_slip_details(
self,
Expand Down
Loading