fix: Add accrual type and penalty field in interest accrual
diff --git a/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py b/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py
index 260fada..bfdc8b4 100644
--- a/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py
+++ b/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py
@@ -74,7 +74,7 @@
if loan_details.status == "Disbursed" and not loan_details.is_term_loan:
process_loan_interest_accrual_for_demand_loans(posting_date=add_days(self.disbursement_date, -1),
- loan=self.against_loan)
+ loan=self.against_loan, accrual_type="Disbursement")
if disbursed_amount > loan_details.loan_amount:
topup_amount = disbursed_amount - loan_details.loan_amount
diff --git a/erpnext/loan_management/doctype/loan_disbursement/test_loan_disbursement.py b/erpnext/loan_management/doctype/loan_disbursement/test_loan_disbursement.py
index 2cb2637..3ade5c5 100644
--- a/erpnext/loan_management/doctype/loan_disbursement/test_loan_disbursement.py
+++ b/erpnext/loan_management/doctype/loan_disbursement/test_loan_disbursement.py
@@ -60,8 +60,7 @@
self.assertRaises(frappe.ValidationError, make_loan_disbursement_entry, loan.name,
500000, first_date)
- repayment_entry = create_repayment_entry(loan.name, self.applicant, add_days(get_last_day(nowdate()), 5),
- "Regular Payment", 611095.89)
+ repayment_entry = create_repayment_entry(loan.name, self.applicant, add_days(get_last_day(nowdate()), 5), 611095.89)
repayment_entry.submit()
loan.reload()
diff --git a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.json b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.json
index 5fc3e8f..a0abc5b 100644
--- a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.json
+++ b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.json
@@ -14,6 +14,7 @@
"column_break_4",
"company",
"posting_date",
+ "accrual_type",
"is_term_loan",
"section_break_7",
"pending_principal_amount",
@@ -22,6 +23,7 @@
"column_break_14",
"interest_amount",
"paid_interest_amount",
+ "penalty_amount",
"section_break_15",
"process_loan_interest_accrual",
"repayment_schedule_name",
@@ -149,12 +151,25 @@
"fieldtype": "Currency",
"label": "Paid Interest Amount",
"options": "Company:company:default_currency"
+ },
+ {
+ "fieldname": "accrual_type",
+ "fieldtype": "Select",
+ "label": "Accrual Type",
+ "options": "Regular\nRepayment\nDisbursement"
+ },
+ {
+ "fieldname": "penalty_amount",
+ "fieldtype": "Currency",
+ "label": "Penalty Amount",
+ "options": "Company:company:default_currency"
}
],
"in_create": 1,
+ "index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
- "modified": "2020-04-16 11:24:23.258404",
+ "modified": "2020-10-10 03:12:58.204501",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Interest Accrual",
diff --git a/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.json b/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.json
index 0ef098f..1e05a42 100644
--- a/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.json
+++ b/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.json
@@ -10,6 +10,7 @@
"loan_type",
"loan",
"process_type",
+ "accrual_type",
"amended_from"
],
"fields": [
@@ -47,11 +48,18 @@
"hidden": 1,
"label": "Process Type",
"read_only": 1
+ },
+ {
+ "fieldname": "accrual_type",
+ "fieldtype": "Select",
+ "label": "Accrual Type",
+ "options": "Regular\nRepayment\nAccrual"
}
],
+ "index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
- "modified": "2020-04-09 22:52:53.911416",
+ "modified": "2020-10-08 12:20:11.124769",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Process Loan Interest Accrual",
diff --git a/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py b/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py
index 0fa9686..1eeb18b 100644
--- a/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py
+++ b/erpnext/loan_management/doctype/process_loan_interest_accrual/process_loan_interest_accrual.py
@@ -20,19 +20,20 @@
if (not self.loan or not loan_doc.is_term_loan) and self.process_type != 'Term Loans':
make_accrual_interest_entry_for_demand_loans(self.posting_date, self.name,
- open_loans = open_loans, loan_type = self.loan_type)
+ open_loans = open_loans, loan_type = self.loan_type, accrual_type=self.accrual_type)
if (not self.loan or loan_doc.is_term_loan) and self.process_type != 'Demand Loans':
make_accrual_interest_entry_for_term_loans(self.posting_date, self.name, term_loan=self.loan,
loan_type=self.loan_type)
-def process_loan_interest_accrual_for_demand_loans(posting_date=None, loan_type=None, loan=None):
+def process_loan_interest_accrual_for_demand_loans(posting_date=None, loan_type=None, loan=None, accrual_type="Regular"):
loan_process = frappe.new_doc('Process Loan Interest Accrual')
loan_process.posting_date = posting_date or nowdate()
loan_process.loan_type = loan_type
loan_process.process_type = 'Demand Loans'
loan_process.loan = loan
+ loan_process.accrual_type = accrual_type
loan_process.submit()