chore: Linting issues and test case fixes

This commit is contained in:
Deepesh Garg
2022-08-30 10:24:31 +05:30
parent e64e812679
commit 8217c6dd9f
4 changed files with 9 additions and 9 deletions

View File

@@ -75,10 +75,8 @@ def term_loan_accrual_pending(date, loan=None):
filters = {"payment_date": ("<=", date), "is_accrued": 0}
if loan:
filters.update({'parent': loan})
filters.update({"parent": loan})
pending_accrual = frappe.db.get_value(
"Repayment Schedule", filters
)
pending_accrual = frappe.db.get_value("Repayment Schedule", filters)
return pending_accrual

View File

@@ -330,13 +330,13 @@ class TestPayrollEntry(FrappeTestCase):
)
salary_slip = frappe.get_doc("Salary Slip", name)
for row in salary_slip.loans:
if row.loan == loan.name:
interest_amount = (280000 * 8.4) / (12 * 100)
principal_amount = loan.monthly_repayment_amount - interest_amount
self.assertEqual(row.interest_amount, interest_amount)
self.assertEqual(row.principal_amount, principal_amount)
self.assertEqual(row.total_payment, interest_amount + principal_amount)
if salary_slip.docstatus == 0:
frappe.delete_doc("Salary Slip", name)

View File

@@ -1379,10 +1379,11 @@ class SalarySlip(TransactionBase):
for loan in self.get_loan_details():
amounts = calculate_amounts(loan.name, self.posting_date, "Regular Payment")
if (amounts["interest_amount"] or amounts["payable_principal_amount"]) \
and (amounts["payable_principal_amount"] + amounts["interest_amount"] > amounts["written_off_amount"]):
if (amounts["interest_amount"] or amounts["payable_principal_amount"]) and (
amounts["payable_principal_amount"] + amounts["interest_amount"]
> amounts["written_off_amount"]
):
print("Ininininin")
if amounts["interest_amount"] > amounts["written_off_amount"]:
amounts["interest_amount"] -= amounts["written_off_amount"]
amounts["written_off_amount"] = 0

View File

@@ -670,9 +670,10 @@ class TestSalarySlip(FrappeTestCase):
ss = make_employee_salary_slip(
"test_loan_repayment_salary_slip@salary.com", "Monthly", "Test Loan Repayment Salary Structure"
)
ss.loans[0].total_payment = 592
ss.submit()
self.assertEqual(ss.total_loan_repayment, 592)
self.assertEqual(
ss.net_pay, (flt(ss.gross_pay) - (flt(ss.total_deduction) + flt(ss.total_loan_repayment)))
)