diff --git a/erpnext/payroll/doctype/salary_slip/salary_slip.py b/erpnext/payroll/doctype/salary_slip/salary_slip.py index 232b5f39a7d..0563541eaa5 100644 --- a/erpnext/payroll/doctype/salary_slip/salary_slip.py +++ b/erpnext/payroll/doctype/salary_slip/salary_slip.py @@ -1063,27 +1063,26 @@ class SalarySlip(TransactionBase): ) exempted_amount = flt(exempted_amount[0][0]) if exempted_amount else 0 - opening_taxable_earning = self.get_opening_for( + opening_taxable_earning = self.get_opening_balance_for( "taxable_earnings_till_date", start_date, end_date ) return (taxable_earnings + opening_taxable_earning) - exempted_amount - def get_opening_for(self, field_to_select, start_date, end_date): - return ( - frappe.db.get_value( - "Salary Structure Assignment", - { - "employee": self.employee, - "salary_structure": self.salary_structure, - "from_date": ["between", [start_date, end_date]], - "docstatus": 1, - }, - field_to_select, - ) - or 0 + def get_opening_balance_for(self, field_to_select, start_date, end_date): + opening_balance = frappe.db.get_all( + "Salary Structure Assignment", + { + "employee": self.employee, + "salary_structure": self.salary_structure, + "from_date": ["between", (start_date, end_date)], + "docstatus": 1, + }, + field_to_select, ) + return opening_balance[0].get(field_to_select) if opening_balance else 0.0 + def get_tax_paid_in_period(self, start_date, end_date, tax_component): # find total_tax_paid, tax paid for benefit, additional_salary total_tax_paid = flt( @@ -1111,7 +1110,9 @@ class SalarySlip(TransactionBase): )[0][0] ) - tax_deducted_till_date = self.get_opening_for("tax_deducted_till_date", start_date, end_date) + tax_deducted_till_date = self.get_opening_balance_for( + "tax_deducted_till_date", start_date, end_date + ) return total_tax_paid + tax_deducted_till_date