mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 15:12:51 +00:00
fix: Employee loan test case and other fixes
This commit is contained in:
@@ -12,9 +12,8 @@ from erpnext.selling.doctype.customer.test_customer import get_customer_dict
|
||||
from erpnext.hr.doctype.salary_structure.test_salary_structure import make_employee
|
||||
from erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual import (process_loan_interest_accrual_for_demand_loans,
|
||||
process_loan_interest_accrual_for_term_loans)
|
||||
from erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual import (make_accrual_interest_entry_for_term_loans, days_in_year)
|
||||
|
||||
from erpnext.loan_management.doctype.loan_security_shortfall.loan_security_shortfall import check_for_ltv_shortfall
|
||||
from erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual import days_in_year
|
||||
from erpnext.loan_management.doctype.process_loan_security_shortfall.process_loan_security_shortfall import create_process_loan_security_shortfall
|
||||
|
||||
class TestLoan(unittest.TestCase):
|
||||
def setUp(self):
|
||||
@@ -298,7 +297,7 @@ class TestLoan(unittest.TestCase):
|
||||
frappe.db.sql(""" UPDATE `tabLoan Security Price` SET loan_security_price = 100
|
||||
where loan_security='Test Security 2'""")
|
||||
|
||||
check_for_ltv_shortfall()
|
||||
create_process_loan_security_shortfall()
|
||||
loan_security_shortfall = frappe.get_doc("Loan Security Shortfall", {"loan": loan.name})
|
||||
self.assertTrue(loan_security_shortfall)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ from frappe.utils import (nowdate, add_days, get_datetime, get_first_day, get_la
|
||||
from erpnext.loan_management.doctype.loan.test_loan import (create_loan_type, create_loan_security_pledge, create_repayment_entry,
|
||||
make_loan_disbursement_entry, create_loan_accounts, create_loan_security_type, create_loan_security, create_demand_loan, create_loan_security_price)
|
||||
from erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual import process_loan_interest_accrual_for_demand_loans
|
||||
from erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual import (make_accrual_interest_entry_for_term_loans, days_in_year)
|
||||
from erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual import days_in_year
|
||||
from erpnext.selling.doctype.customer.test_customer import get_customer_dict
|
||||
|
||||
class TestLoanDisbursement(unittest.TestCase):
|
||||
|
||||
@@ -94,7 +94,7 @@ def calculate_accrual_amount_for_demand_loans(loan, posting_date, process_loan_i
|
||||
'applicant_type': loan.applicant_type,
|
||||
'applicant': loan.applicant,
|
||||
'interest_income_account': loan.interest_income_account,
|
||||
'loan_account': loan.loan_acccount,
|
||||
'loan_account': loan.loan_account,
|
||||
'pending_principal_amount': pending_principal_amount,
|
||||
'interest_amount': payable_interest,
|
||||
'process_loan_interest': process_loan_interest,
|
||||
@@ -137,7 +137,7 @@ def make_accrual_interest_entry_for_term_loans(posting_date, process_loan_intere
|
||||
'applicant_type': loan.applicant_type,
|
||||
'applicant': loan.applicant,
|
||||
'interest_income_account': loan.interest_income_account,
|
||||
'loan_account': loan.loan_acccount,
|
||||
'loan_account': loan.loan_account,
|
||||
'interest_amount': loan.interest_amount,
|
||||
'payable_principal': loan.principal_amount,
|
||||
'process_loan_interest': process_loan_interest,
|
||||
|
||||
@@ -8,7 +8,7 @@ from frappe.utils import (nowdate, add_days, get_datetime, get_first_day, get_la
|
||||
from erpnext.loan_management.doctype.loan.test_loan import (create_loan_type, create_loan_security_pledge, create_loan_security_price,
|
||||
make_loan_disbursement_entry, create_loan_accounts, create_loan_security_type, create_loan_security, create_demand_loan)
|
||||
from erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual import process_loan_interest_accrual_for_demand_loans
|
||||
from erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual import (make_accrual_interest_entry_for_term_loans, days_in_year)
|
||||
from erpnext.loan_management.doctype.loan_interest_accrual.loan_interest_accrual import days_in_years
|
||||
from erpnext.selling.doctype.customer.test_customer import get_customer_dict
|
||||
|
||||
class TestLoanInterestAccrual(unittest.TestCase):
|
||||
|
||||
@@ -210,7 +210,7 @@ class LoanRepayment(AccountsController):
|
||||
)
|
||||
|
||||
if gle_map:
|
||||
make_gl_entries(gle_map, cancel=cancel, adv_adj=adv_adj)
|
||||
make_gl_entries(gle_map, cancel=cancel, adv_adj=adv_adj, merge_entries=False)
|
||||
|
||||
def create_repayment_entry(loan, applicant, company, posting_date, loan_type,
|
||||
payment_type, interest_payable, payable_principal_amount, amount_paid, penalty_amount=None):
|
||||
@@ -223,7 +223,7 @@ def create_repayment_entry(loan, applicant, company, posting_date, loan_type,
|
||||
"posting_date": posting_date,
|
||||
"applicant": applicant,
|
||||
"penalty_amount": penalty_amount,
|
||||
"interets_payable": interest_payable,
|
||||
"interst_payable": interest_payable,
|
||||
"payable_principal_amount": payable_principal_amount,
|
||||
"amount_paid": amount_paid,
|
||||
"loan_type": loan_type
|
||||
@@ -236,7 +236,8 @@ def get_accrued_interest_entries(against_loan):
|
||||
fields=["name", "interest_amount", "posting_date", "payable_principal_amount"],
|
||||
filters = {
|
||||
"loan": against_loan,
|
||||
"is_paid": 0
|
||||
"is_paid": 0,
|
||||
"docstatus": 1
|
||||
}, order_by="posting_date")
|
||||
|
||||
return accrued_interest_entries
|
||||
@@ -272,7 +273,9 @@ def get_amounts(amounts, against_loan, posting_date, payment_type):
|
||||
total_pending_interest += entry.interest_amount
|
||||
payable_principal_amount += entry.payable_principal_amount
|
||||
|
||||
pending_accrual_entries.setdefault(entry.name, entry.interest_amount)
|
||||
pending_accrual_entries.setdefault(entry.name,
|
||||
flt(entry.interest_amount) + flt(entry.payable_principal_amount))
|
||||
|
||||
final_due_date = due_date
|
||||
|
||||
pending_principal_amount = against_loan_doc.total_payment - against_loan_doc.total_principal_paid - against_loan_doc.total_interest_payable
|
||||
|
||||
@@ -37,17 +37,10 @@ def add_security(loan):
|
||||
|
||||
return loan_security_pledge.as_dict()
|
||||
|
||||
def check_for_ltv_shortfall(process_loan_security_shortfall=None):
|
||||
def check_for_ltv_shortfall(process_loan_security_shortfall):
|
||||
|
||||
update_time = get_datetime()
|
||||
|
||||
if not process_loan_security_shortfall:
|
||||
process = frappe.new_doc("Process Loan Security Shortfall")
|
||||
process.update_time = update_time
|
||||
process.submit()
|
||||
|
||||
process_loan_security_shortfall = process.name
|
||||
|
||||
loan_security_price_map = frappe._dict(frappe.get_all("Loan Security Price",
|
||||
fields=["loan_security", "loan_security_price"],
|
||||
filters = {
|
||||
|
||||
@@ -19,3 +19,6 @@ class LoanType(Document):
|
||||
frappe.throw(_("Account {0} does not belong to company {1}").format(frappe.bold(self.get(fieldname)),
|
||||
frappe.bold(self.company)))
|
||||
|
||||
if self.get('loan_account') == self.get('payment_account'):
|
||||
frappe.throw(_('Loan Account and Payment Account cannot be same'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user