From 44ffdb0c91294c60d170d36d5bafac568c6828f7 Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Tue, 15 Oct 2024 12:01:02 +0530 Subject: [PATCH 1/4] fix: payroll bank entry with the Loan Repayment amount --- .../doctype/payroll_entry/payroll_entry.py | 3 ++ .../payroll_entry/test_payroll_entry.py | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/hrms/payroll/doctype/payroll_entry/payroll_entry.py b/hrms/payroll/doctype/payroll_entry/payroll_entry.py index ad08acb272..208bf33d30 100644 --- a/hrms/payroll/doctype/payroll_entry/payroll_entry.py +++ b/hrms/payroll/doctype/payroll_entry/payroll_entry.py @@ -923,6 +923,8 @@ def make_bank_entry(self, for_withheld_salaries=False): salary_slip_total -= salary_detail.amount + salary_slip_total -= flt(salary_detail.get("total_loan_repayment")) + bank_entry = None if salary_slip_total > 0: remark = "withheld salaries" if for_withheld_salaries else "salaries" @@ -946,6 +948,7 @@ def get_salary_slip_details(self, for_withheld_salaries=False): SalarySlip.employee, SalarySlip.salary_structure, SalarySlip.salary_withholding_cycle, + SalarySlip.total_loan_repayment, SalaryDetail.salary_component, SalaryDetail.amount, SalaryDetail.parentfield, diff --git a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py index 6f148d2ce6..d5fb01b64b 100644 --- a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py +++ b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py @@ -717,6 +717,40 @@ def test_validate_attendance(self): employees = payroll_entry.get_employees_with_unmarked_attendance() self.assertFalse(employees) + @if_lending_app_installed + @change_settings("Payroll Settings", {"process_payroll_accounting_entry_based_on_employee": 0}) + def test_loan_repayment_from_salary(self): + from lending.loan_management.doctype.loan.test_loan import make_loan_disbursement_entry + from lending.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual import ( + process_loan_interest_accrual_for_term_loans, + ) + + frappe.db.delete("Loan") + applicant, branch, currency, payroll_payable_account = setup_lending() + + loan = create_loan_for_employee(applicant) + loan_doc = frappe.get_doc("Loan", loan.name) + loan_doc.repay_from_salary = 1 + loan_doc.save() + + make_loan_disbursement_entry(loan.name, loan.loan_amount, disbursement_date=add_months(nowdate(), -1)) + process_loan_interest_accrual_for_term_loans(posting_date=nowdate()) + + dates = get_start_end_dates("Monthly", nowdate()) + payroll_entry = make_payroll_entry( + company="_Test Company", + start_date=dates.start_date, + payable_account=payroll_payable_account, + currency=currency, + end_date=dates.end_date, + branch=branch, + cost_center="Main - _TC", + payment_account="Cash - _TC", + total_loan_repayment=loan.monthly_repayment_amount + ) + + bank_entry = payroll_entry.make_bank_entry() + submit_bank_entry(payroll_entry.name) def get_payroll_entry(**args): args = frappe._dict(args) From 2be71267f34ef26d9da5cb818ca28f8b2578179a Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Tue, 15 Oct 2024 12:15:52 +0530 Subject: [PATCH 2/4] fix: payroll bank entry with the Loan Repayment amount --- hrms/payroll/doctype/payroll_entry/test_payroll_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py index d5fb01b64b..47306fbcb1 100644 --- a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py +++ b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py @@ -746,7 +746,7 @@ def test_loan_repayment_from_salary(self): branch=branch, cost_center="Main - _TC", payment_account="Cash - _TC", - total_loan_repayment=loan.monthly_repayment_amount + total_loan_repayment=loan.monthly_repayment_amount, ) bank_entry = payroll_entry.make_bank_entry() From e275555eb344d37565860c15217f0ece3fadda59 Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Tue, 15 Oct 2024 12:17:30 +0530 Subject: [PATCH 3/4] fix: payroll bank entry with the Loan Repayment amount --- hrms/payroll/doctype/payroll_entry/test_payroll_entry.py | 1 + 1 file changed, 1 insertion(+) diff --git a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py index 47306fbcb1..0cf3d6294d 100644 --- a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py +++ b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py @@ -752,6 +752,7 @@ def test_loan_repayment_from_salary(self): bank_entry = payroll_entry.make_bank_entry() submit_bank_entry(payroll_entry.name) + def get_payroll_entry(**args): args = frappe._dict(args) From 6d5f9985d5407e108a7626cc8119f700dc4d8626 Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Tue, 15 Oct 2024 12:21:37 +0530 Subject: [PATCH 4/4] fix: payroll bank entry with the Loan Repayment amount --- hrms/payroll/doctype/payroll_entry/test_payroll_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py index 0cf3d6294d..2a5acdaee0 100644 --- a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py +++ b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py @@ -749,7 +749,7 @@ def test_loan_repayment_from_salary(self): total_loan_repayment=loan.monthly_repayment_amount, ) - bank_entry = payroll_entry.make_bank_entry() + payroll_entry.make_bank_entry() submit_bank_entry(payroll_entry.name)