fix: minor improvements and tests
This commit is contained in:
parent
f38a653a08
commit
b58590251b
@ -23,6 +23,7 @@
|
||||
"rate_of_interest",
|
||||
"is_secured_loan",
|
||||
"disbursement_date",
|
||||
"closure_date",
|
||||
"disbursed_amount",
|
||||
"column_break_11",
|
||||
"maximum_loan_amount",
|
||||
@ -348,12 +349,18 @@
|
||||
"no_copy": 1,
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "closure_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Closure Date",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2020-11-24 12:27:23.208240",
|
||||
"modified": "2021-04-10 09:28:21.946972",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Loan Management",
|
||||
"name": "Loan",
|
||||
|
@ -523,7 +523,7 @@ class TestLoan(unittest.TestCase):
|
||||
self.assertEqual(flt(repayment_entry.total_interest_paid, 0), flt(interest_amount, 0))
|
||||
|
||||
def test_penalty(self):
|
||||
loan = create_loan_scenario_for_penalty(self)
|
||||
loan, amounts = create_loan_scenario_for_penalty(self)
|
||||
# 30 days - grace period
|
||||
penalty_days = 30 - 4
|
||||
penalty_applicable_amount = flt(amounts['interest_amount']/2)
|
||||
@ -537,7 +537,7 @@ class TestLoan(unittest.TestCase):
|
||||
self.assertEquals(calculated_penalty_amount, penalty_amount)
|
||||
|
||||
def test_penalty_repayment(self):
|
||||
loan = create_loan_scenario_for_penalty(self)
|
||||
loan, dummy = create_loan_scenario_for_penalty(self)
|
||||
amounts = calculate_amounts(loan.name, '2019-11-30 00:00:00')
|
||||
|
||||
first_penalty = 10000
|
||||
@ -670,7 +670,7 @@ def create_loan_scenario_for_penalty(doc):
|
||||
|
||||
repayment_entry.submit()
|
||||
|
||||
return loan
|
||||
return loan, amounts
|
||||
|
||||
def create_loan_accounts():
|
||||
if not frappe.db.exists("Account", "Loans and Advances (Assets) - _TC"):
|
||||
|
@ -20,6 +20,10 @@
|
||||
"cost_center",
|
||||
"customer_details_section",
|
||||
"bank_account",
|
||||
"disbursement_references_section",
|
||||
"reference_date",
|
||||
"column_break_17",
|
||||
"reference_number",
|
||||
"amended_from"
|
||||
],
|
||||
"fields": [
|
||||
@ -126,12 +130,31 @@
|
||||
{
|
||||
"fieldname": "column_break_8",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "disbursement_references_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Disbursement References"
|
||||
},
|
||||
{
|
||||
"fieldname": "reference_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Reference Date"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_17",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "reference_number",
|
||||
"fieldtype": "Data",
|
||||
"label": "Reference Number"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2020-11-06 10:04:30.882322",
|
||||
"modified": "2021-04-10 10:03:41.502210",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Loan Management",
|
||||
"name": "Loan Disbursement",
|
||||
|
@ -239,14 +239,16 @@
|
||||
{
|
||||
"fieldname": "total_penalty_paid",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 1,
|
||||
"label": "Total Penalty Paid",
|
||||
"options": "Company:company:default_currency"
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2021-04-05 13:45:19.137896",
|
||||
"modified": "2021-04-10 10:00:31.859076",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Loan Management",
|
||||
"name": "Loan Repayment",
|
||||
|
@ -227,6 +227,14 @@ class LoanRepayment(AccountsController):
|
||||
gle_map = []
|
||||
loan_details = frappe.get_doc("Loan", self.against_loan)
|
||||
|
||||
if self.shortfall_amount and self.amount_paid > self.shortfall_amount:
|
||||
remarks = _("Shortfall Repayment of {0}.\nRepayment against Loan: {1}").format(self.shortfall_amount,
|
||||
self.against_loan)
|
||||
elif self.shortfall_amount:
|
||||
remarks = _("Shortfall Repayment of {0}").format(self.shortfall_amount)
|
||||
else:
|
||||
remarks = _("Repayment against Loan: ") + self.against_loan
|
||||
|
||||
if self.total_penalty_paid:
|
||||
gle_map.append(
|
||||
self.get_gl_dict({
|
||||
@ -267,7 +275,7 @@ class LoanRepayment(AccountsController):
|
||||
"debit_in_account_currency": self.amount_paid,
|
||||
"against_voucher_type": "Loan",
|
||||
"against_voucher": self.against_loan,
|
||||
"remarks": _("Repayment against Loan: ") + self.against_loan,
|
||||
"remarks": remarks,
|
||||
"cost_center": self.cost_center,
|
||||
"posting_date": getdate(self.posting_date)
|
||||
})
|
||||
@ -283,7 +291,7 @@ class LoanRepayment(AccountsController):
|
||||
"credit_in_account_currency": self.amount_paid,
|
||||
"against_voucher_type": "Loan",
|
||||
"against_voucher": self.against_loan,
|
||||
"remarks": _("Repayment against Loan: ") + self.against_loan,
|
||||
"remarks": remarks,
|
||||
"cost_center": self.cost_center,
|
||||
"posting_date": getdate(self.posting_date)
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import get_datetime, flt
|
||||
from frappe.utils import get_datetime, flt, getdate
|
||||
import json
|
||||
from six import iteritems
|
||||
from erpnext.loan_management.doctype.loan_security_price.loan_security_price import get_loan_security_price
|
||||
@ -113,7 +113,11 @@ class LoanSecurityUnpledge(Document):
|
||||
pledged_qty += qty
|
||||
|
||||
if not pledged_qty:
|
||||
frappe.db.set_value('Loan', self.loan, 'status', 'Closed')
|
||||
frappe.db.set_value('Loan', self.loan,
|
||||
{
|
||||
'status': 'Closed',
|
||||
'closure_date': getdate()
|
||||
})
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_pledged_security_qty(loan):
|
||||
|
Loading…
x
Reference in New Issue
Block a user