Skip to content

Commit

Permalink
fix: TypeError in Salary Slip Creation Due to Uninitialized Loans Fie…
Browse files Browse the repository at this point in the history
…ld (backport #1909) (#1922)

* Update salary_slip_loan_utils.py

Fix: builtins.TypeError: 'NoneType' object is not iterable

* Update salary_slip_loan_utils.py

Fix Cannot iterate none type

* chore: fix linter

* Update salary_slip_loan_utils.py

* chore: fix conflicts

---------

Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
(cherry picked from commit 6a28b71)

Co-authored-by: Khaled Bin Amir <khaledbinamir@gmail.com>
  • Loading branch information
mergify[bot] and KhaledBinAmir authored Jun 25, 2024
1 parent 1a92a66 commit 7869b4a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hrms/payroll/doctype/salary_slip/salary_slip_loan_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def set_loan_repayment(doc: "SalarySlip"):
"interest_income_account": loan.interest_income_account,
},
)
if not doc.get("loans"):
doc.set("loans", [])

for payment in doc.get("loans", []):
amounts = calculate_amounts(payment.loan, doc.posting_date, "Regular Payment")
Expand Down Expand Up @@ -102,6 +104,9 @@ def make_loan_repayment_entry(doc: "SalarySlip"):
"Payroll Settings", "process_payroll_accounting_entry_based_on_employee"
)

if not doc.get("loans"):
doc.set("loans", [])

for loan in doc.get("loans", []):
if not loan.total_payment:
continue
Expand All @@ -128,6 +133,9 @@ def make_loan_repayment_entry(doc: "SalarySlip"):

@if_lending_app_installed
def cancel_loan_repayment_entry(doc: "SalarySlip"):
if not doc.get("loans"):
doc.set("loans", [])

for loan in doc.get("loans", []):
if loan.loan_repayment_entry:
repayment_entry = frappe.get_doc("Loan Repayment", loan.loan_repayment_entry)
Expand Down

0 comments on commit 7869b4a

Please sign in to comment.