mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
Merge pull request #32690 from frappe/mergify/bp/version-13-hotfix/pr-32424
feat: Repayment schedule types for term loans (backport #32424)
This commit is contained in:
@@ -61,6 +61,10 @@ frappe.ui.form.on('Loan', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
refresh: function (frm) {
|
refresh: function (frm) {
|
||||||
|
if (frm.doc.repayment_schedule_type == "Pro-rated calendar months") {
|
||||||
|
frm.set_df_property("repayment_start_date", "label", "Interest Calculation Start Date");
|
||||||
|
}
|
||||||
|
|
||||||
if (frm.doc.docstatus == 1) {
|
if (frm.doc.docstatus == 1) {
|
||||||
if (["Disbursed", "Partially Disbursed"].includes(frm.doc.status) && (!frm.doc.repay_from_salary)) {
|
if (["Disbursed", "Partially Disbursed"].includes(frm.doc.status) && (!frm.doc.repay_from_salary)) {
|
||||||
frm.add_custom_button(__('Request Loan Closure'), function() {
|
frm.add_custom_button(__('Request Loan Closure'), function() {
|
||||||
@@ -103,6 +107,14 @@ frappe.ui.form.on('Loan', {
|
|||||||
frm.trigger("toggle_fields");
|
frm.trigger("toggle_fields");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
repayment_schedule_type: function(frm) {
|
||||||
|
if (frm.doc.repayment_schedule_type == "Pro-rated calendar months") {
|
||||||
|
frm.set_df_property("repayment_start_date", "label", "Interest Calculation Start Date");
|
||||||
|
} else {
|
||||||
|
frm.set_df_property("repayment_start_date", "label", "Repayment Start Date");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
loan_type: function(frm) {
|
loan_type: function(frm) {
|
||||||
frm.toggle_reqd("repayment_method", frm.doc.is_term_loan);
|
frm.toggle_reqd("repayment_method", frm.doc.is_term_loan);
|
||||||
frm.toggle_display("repayment_method", frm.doc.is_term_loan);
|
frm.toggle_display("repayment_method", frm.doc.is_term_loan);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"manually_update_paid_amount_in_salary_slip",
|
"manually_update_paid_amount_in_salary_slip",
|
||||||
"section_break_8",
|
"section_break_8",
|
||||||
"loan_type",
|
"loan_type",
|
||||||
|
"repayment_schedule_type",
|
||||||
"loan_amount",
|
"loan_amount",
|
||||||
"rate_of_interest",
|
"rate_of_interest",
|
||||||
"is_secured_loan",
|
"is_secured_loan",
|
||||||
@@ -167,7 +168,8 @@
|
|||||||
"depends_on": "is_term_loan",
|
"depends_on": "is_term_loan",
|
||||||
"fieldname": "repayment_start_date",
|
"fieldname": "repayment_start_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "Repayment Start Date"
|
"label": "Repayment Start Date",
|
||||||
|
"mandatory_depends_on": "is_term_loan"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_11",
|
"fieldname": "column_break_11",
|
||||||
@@ -419,12 +421,20 @@
|
|||||||
"fieldname": "manually_update_paid_amount_in_salary_slip",
|
"fieldname": "manually_update_paid_amount_in_salary_slip",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Manually Update Paid Amount in Salary Slip"
|
"label": "Manually Update Paid Amount in Salary Slip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "is_term_loan",
|
||||||
|
"fetch_from": "loan_type.repayment_schedule_type",
|
||||||
|
"fieldname": "repayment_schedule_type",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Repayment Schedule Type",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-09-13 02:05:25.017190",
|
"modified": "2022-11-01 10:36:47.902903",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Loan Management",
|
"module": "Loan Management",
|
||||||
"name": "Loan",
|
"name": "Loan",
|
||||||
|
|||||||
@@ -7,7 +7,16 @@ import math
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import add_months, flt, get_last_day, getdate, now_datetime, nowdate
|
from frappe.utils import (
|
||||||
|
add_days,
|
||||||
|
add_months,
|
||||||
|
date_diff,
|
||||||
|
flt,
|
||||||
|
get_last_day,
|
||||||
|
getdate,
|
||||||
|
now_datetime,
|
||||||
|
nowdate,
|
||||||
|
)
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
@@ -115,30 +124,81 @@ class Loan(AccountsController):
|
|||||||
if not self.repayment_start_date:
|
if not self.repayment_start_date:
|
||||||
frappe.throw(_("Repayment Start Date is mandatory for term loans"))
|
frappe.throw(_("Repayment Start Date is mandatory for term loans"))
|
||||||
|
|
||||||
|
schedule_type_details = frappe.db.get_value(
|
||||||
|
"Loan Type", self.loan_type, ["repayment_schedule_type", "repayment_date_on"], as_dict=1
|
||||||
|
)
|
||||||
|
|
||||||
self.repayment_schedule = []
|
self.repayment_schedule = []
|
||||||
payment_date = self.repayment_start_date
|
payment_date = self.repayment_start_date
|
||||||
balance_amount = self.loan_amount
|
balance_amount = self.loan_amount
|
||||||
while balance_amount > 0:
|
|
||||||
interest_amount = flt(balance_amount * flt(self.rate_of_interest) / (12 * 100))
|
|
||||||
principal_amount = self.monthly_repayment_amount - interest_amount
|
|
||||||
balance_amount = flt(balance_amount + interest_amount - self.monthly_repayment_amount)
|
|
||||||
if balance_amount < 0:
|
|
||||||
principal_amount += balance_amount
|
|
||||||
balance_amount = 0.0
|
|
||||||
|
|
||||||
total_payment = principal_amount + interest_amount
|
while balance_amount > 0:
|
||||||
self.append(
|
interest_amount, principal_amount, balance_amount, total_payment = self.get_amounts(
|
||||||
"repayment_schedule",
|
payment_date,
|
||||||
{
|
balance_amount,
|
||||||
"payment_date": payment_date,
|
schedule_type_details.repayment_schedule_type,
|
||||||
"principal_amount": principal_amount,
|
schedule_type_details.repayment_date_on,
|
||||||
"interest_amount": interest_amount,
|
|
||||||
"total_payment": total_payment,
|
|
||||||
"balance_loan_amount": balance_amount,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
next_payment_date = add_single_month(payment_date)
|
|
||||||
payment_date = next_payment_date
|
if schedule_type_details.repayment_schedule_type == "Pro-rated calendar months":
|
||||||
|
next_payment_date = get_last_day(payment_date)
|
||||||
|
if schedule_type_details.repayment_date_on == "Start of the next month":
|
||||||
|
next_payment_date = add_days(next_payment_date, 1)
|
||||||
|
|
||||||
|
payment_date = next_payment_date
|
||||||
|
|
||||||
|
self.add_repayment_schedule_row(
|
||||||
|
payment_date, principal_amount, interest_amount, total_payment, balance_amount
|
||||||
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
schedule_type_details.repayment_schedule_type == "Monthly as per repayment start date"
|
||||||
|
or schedule_type_details.repayment_date_on == "End of the current month"
|
||||||
|
):
|
||||||
|
next_payment_date = add_single_month(payment_date)
|
||||||
|
payment_date = next_payment_date
|
||||||
|
|
||||||
|
def get_amounts(self, payment_date, balance_amount, schedule_type, repayment_date_on):
|
||||||
|
if schedule_type == "Monthly as per repayment start date":
|
||||||
|
days = 1
|
||||||
|
months = 12
|
||||||
|
else:
|
||||||
|
expected_payment_date = get_last_day(payment_date)
|
||||||
|
if repayment_date_on == "Start of the next month":
|
||||||
|
expected_payment_date = add_days(expected_payment_date, 1)
|
||||||
|
|
||||||
|
if expected_payment_date == payment_date:
|
||||||
|
# using 30 days for calculating interest for all full months
|
||||||
|
days = 30
|
||||||
|
months = 365
|
||||||
|
else:
|
||||||
|
days = date_diff(get_last_day(payment_date), payment_date)
|
||||||
|
months = 365
|
||||||
|
|
||||||
|
interest_amount = flt(balance_amount * flt(self.rate_of_interest) * days / (months * 100))
|
||||||
|
principal_amount = self.monthly_repayment_amount - interest_amount
|
||||||
|
balance_amount = flt(balance_amount + interest_amount - self.monthly_repayment_amount)
|
||||||
|
if balance_amount < 0:
|
||||||
|
principal_amount += balance_amount
|
||||||
|
balance_amount = 0.0
|
||||||
|
|
||||||
|
total_payment = principal_amount + interest_amount
|
||||||
|
|
||||||
|
return interest_amount, principal_amount, balance_amount, total_payment
|
||||||
|
|
||||||
|
def add_repayment_schedule_row(
|
||||||
|
self, payment_date, principal_amount, interest_amount, total_payment, balance_loan_amount
|
||||||
|
):
|
||||||
|
self.append(
|
||||||
|
"repayment_schedule",
|
||||||
|
{
|
||||||
|
"payment_date": payment_date,
|
||||||
|
"principal_amount": principal_amount,
|
||||||
|
"interest_amount": interest_amount,
|
||||||
|
"total_payment": total_payment,
|
||||||
|
"balance_loan_amount": balance_loan_amount,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
def set_repayment_period(self):
|
def set_repayment_period(self):
|
||||||
if self.repayment_method == "Repay Fixed Amount per Period":
|
if self.repayment_method == "Repay Fixed Amount per Period":
|
||||||
|
|||||||
@@ -4,7 +4,16 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import add_days, add_months, add_to_date, date_diff, flt, get_datetime, nowdate
|
from frappe.utils import (
|
||||||
|
add_days,
|
||||||
|
add_months,
|
||||||
|
add_to_date,
|
||||||
|
date_diff,
|
||||||
|
flt,
|
||||||
|
format_date,
|
||||||
|
get_datetime,
|
||||||
|
nowdate,
|
||||||
|
)
|
||||||
|
|
||||||
from erpnext.loan_management.doctype.loan.loan import (
|
from erpnext.loan_management.doctype.loan.loan import (
|
||||||
make_loan_write_off,
|
make_loan_write_off,
|
||||||
@@ -50,6 +59,51 @@ class TestLoan(unittest.TestCase):
|
|||||||
loan_account="Loan Account - _TC",
|
loan_account="Loan Account - _TC",
|
||||||
interest_income_account="Interest Income Account - _TC",
|
interest_income_account="Interest Income Account - _TC",
|
||||||
penalty_income_account="Penalty Income Account - _TC",
|
penalty_income_account="Penalty Income Account - _TC",
|
||||||
|
repayment_schedule_type="Monthly as per repayment start date",
|
||||||
|
)
|
||||||
|
|
||||||
|
create_loan_type(
|
||||||
|
"Term Loan Type 1",
|
||||||
|
12000,
|
||||||
|
7.5,
|
||||||
|
is_term_loan=1,
|
||||||
|
mode_of_payment="Cash",
|
||||||
|
disbursement_account="Disbursement Account - _TC",
|
||||||
|
payment_account="Payment Account - _TC",
|
||||||
|
loan_account="Loan Account - _TC",
|
||||||
|
interest_income_account="Interest Income Account - _TC",
|
||||||
|
penalty_income_account="Penalty Income Account - _TC",
|
||||||
|
repayment_schedule_type="Monthly as per repayment start date",
|
||||||
|
)
|
||||||
|
|
||||||
|
create_loan_type(
|
||||||
|
"Term Loan Type 2",
|
||||||
|
12000,
|
||||||
|
7.5,
|
||||||
|
is_term_loan=1,
|
||||||
|
mode_of_payment="Cash",
|
||||||
|
disbursement_account="Disbursement Account - _TC",
|
||||||
|
payment_account="Payment Account - _TC",
|
||||||
|
loan_account="Loan Account - _TC",
|
||||||
|
interest_income_account="Interest Income Account - _TC",
|
||||||
|
penalty_income_account="Penalty Income Account - _TC",
|
||||||
|
repayment_schedule_type="Pro-rated calendar months",
|
||||||
|
repayment_date_on="Start of the next month",
|
||||||
|
)
|
||||||
|
|
||||||
|
create_loan_type(
|
||||||
|
"Term Loan Type 3",
|
||||||
|
12000,
|
||||||
|
7.5,
|
||||||
|
is_term_loan=1,
|
||||||
|
mode_of_payment="Cash",
|
||||||
|
disbursement_account="Disbursement Account - _TC",
|
||||||
|
payment_account="Payment Account - _TC",
|
||||||
|
loan_account="Loan Account - _TC",
|
||||||
|
interest_income_account="Interest Income Account - _TC",
|
||||||
|
penalty_income_account="Penalty Income Account - _TC",
|
||||||
|
repayment_schedule_type="Pro-rated calendar months",
|
||||||
|
repayment_date_on="End of the current month",
|
||||||
)
|
)
|
||||||
|
|
||||||
create_loan_type(
|
create_loan_type(
|
||||||
@@ -65,6 +119,7 @@ class TestLoan(unittest.TestCase):
|
|||||||
"Loan Account - _TC",
|
"Loan Account - _TC",
|
||||||
"Interest Income Account - _TC",
|
"Interest Income Account - _TC",
|
||||||
"Penalty Income Account - _TC",
|
"Penalty Income Account - _TC",
|
||||||
|
repayment_schedule_type="Monthly as per repayment start date",
|
||||||
)
|
)
|
||||||
|
|
||||||
create_loan_type(
|
create_loan_type(
|
||||||
@@ -912,6 +967,69 @@ class TestLoan(unittest.TestCase):
|
|||||||
amounts = calculate_amounts(loan.name, add_days(last_date, 5))
|
amounts = calculate_amounts(loan.name, add_days(last_date, 5))
|
||||||
self.assertEqual(flt(amounts["pending_principal_amount"], 0), 0)
|
self.assertEqual(flt(amounts["pending_principal_amount"], 0), 0)
|
||||||
|
|
||||||
|
def test_term_loan_schedule_types(self):
|
||||||
|
loan = create_loan(
|
||||||
|
self.applicant1,
|
||||||
|
"Term Loan Type 1",
|
||||||
|
12000,
|
||||||
|
"Repay Over Number of Periods",
|
||||||
|
12,
|
||||||
|
repayment_start_date="2022-10-17",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check for first, second and last installment date
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[0].payment_date, "dd-MM-yyyy"), "17-10-2022"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[1].payment_date, "dd-MM-yyyy"), "17-11-2022"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[-1].payment_date, "dd-MM-yyyy"), "17-09-2023"
|
||||||
|
)
|
||||||
|
|
||||||
|
loan.loan_type = "Term Loan Type 2"
|
||||||
|
loan.save()
|
||||||
|
|
||||||
|
# Check for first, second and last installment date
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[0].payment_date, "dd-MM-yyyy"), "01-11-2022"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[1].payment_date, "dd-MM-yyyy"), "01-12-2022"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[-1].payment_date, "dd-MM-yyyy"), "01-10-2023"
|
||||||
|
)
|
||||||
|
|
||||||
|
loan.loan_type = "Term Loan Type 3"
|
||||||
|
loan.save()
|
||||||
|
|
||||||
|
# Check for first, second and last installment date
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[0].payment_date, "dd-MM-yyyy"), "31-10-2022"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[1].payment_date, "dd-MM-yyyy"), "30-11-2022"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[-1].payment_date, "dd-MM-yyyy"), "30-09-2023"
|
||||||
|
)
|
||||||
|
|
||||||
|
loan.repayment_method = "Repay Fixed Amount per Period"
|
||||||
|
loan.monthly_repayment_amount = 1042
|
||||||
|
loan.save()
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[0].payment_date, "dd-MM-yyyy"), "31-10-2022"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[1].payment_date, "dd-MM-yyyy"), "30-11-2022"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
format_date(loan.get("repayment_schedule")[-1].payment_date, "dd-MM-yyyy"), "30-09-2023"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_loan_scenario_for_penalty(doc):
|
def create_loan_scenario_for_penalty(doc):
|
||||||
pledge = [{"loan_security": "Test Security 1", "qty": 4000.00}]
|
pledge = [{"loan_security": "Test Security 1", "qty": 4000.00}]
|
||||||
@@ -1043,6 +1161,8 @@ def create_loan_type(
|
|||||||
penalty_income_account=None,
|
penalty_income_account=None,
|
||||||
repayment_method=None,
|
repayment_method=None,
|
||||||
repayment_periods=None,
|
repayment_periods=None,
|
||||||
|
repayment_schedule_type=None,
|
||||||
|
repayment_date_on=None,
|
||||||
):
|
):
|
||||||
|
|
||||||
if not frappe.db.exists("Loan Type", loan_name):
|
if not frappe.db.exists("Loan Type", loan_name):
|
||||||
@@ -1052,6 +1172,7 @@ def create_loan_type(
|
|||||||
"company": "_Test Company",
|
"company": "_Test Company",
|
||||||
"loan_name": loan_name,
|
"loan_name": loan_name,
|
||||||
"is_term_loan": is_term_loan,
|
"is_term_loan": is_term_loan,
|
||||||
|
"repayment_schedule_type": "Monthly as per repayment start date",
|
||||||
"maximum_loan_amount": maximum_loan_amount,
|
"maximum_loan_amount": maximum_loan_amount,
|
||||||
"rate_of_interest": rate_of_interest,
|
"rate_of_interest": rate_of_interest,
|
||||||
"penalty_interest_rate": penalty_interest_rate,
|
"penalty_interest_rate": penalty_interest_rate,
|
||||||
@@ -1066,8 +1187,14 @@ def create_loan_type(
|
|||||||
"repayment_periods": repayment_periods,
|
"repayment_periods": repayment_periods,
|
||||||
"write_off_amount": 100,
|
"write_off_amount": 100,
|
||||||
}
|
}
|
||||||
).insert()
|
)
|
||||||
|
|
||||||
|
if loan_type.is_term_loan:
|
||||||
|
loan_type.repayment_schedule_type = repayment_schedule_type
|
||||||
|
if loan_type.repayment_schedule_type != "Monthly as per repayment start date":
|
||||||
|
loan_type.repayment_date_on = repayment_date_on
|
||||||
|
|
||||||
|
loan_type.insert()
|
||||||
loan_type.submit()
|
loan_type.submit()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
"company",
|
"company",
|
||||||
"is_term_loan",
|
"is_term_loan",
|
||||||
"disabled",
|
"disabled",
|
||||||
|
"repayment_schedule_type",
|
||||||
|
"repayment_date_on",
|
||||||
"description",
|
"description",
|
||||||
"account_details_section",
|
"account_details_section",
|
||||||
"mode_of_payment",
|
"mode_of_payment",
|
||||||
@@ -157,12 +159,30 @@
|
|||||||
"label": "Disbursement Account",
|
"label": "Disbursement Account",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "is_term_loan",
|
||||||
|
"description": "The schedule type that will be used for generating the term loan schedules (will affect the payment date and monthly repayment amount)",
|
||||||
|
"fieldname": "repayment_schedule_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Repayment Schedule Type",
|
||||||
|
"mandatory_depends_on": "is_term_loan",
|
||||||
|
"options": "\nMonthly as per repayment start date\nPro-rated calendar months"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.repayment_schedule_type == \"Pro-rated calendar months\"",
|
||||||
|
"description": "Select whether the repayment date should be the end of the current month or start of the upcoming month",
|
||||||
|
"fieldname": "repayment_date_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Repayment Date On",
|
||||||
|
"mandatory_depends_on": "eval:doc.repayment_schedule_type == \"Pro-rated calendar months\"",
|
||||||
|
"options": "\nStart of the next month\nEnd of the current month"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-01-25 16:23:57.009349",
|
"modified": "2022-11-01 17:43:03.954201",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Loan Management",
|
"module": "Loan Management",
|
||||||
"name": "Loan Type",
|
"name": "Loan Type",
|
||||||
|
|||||||
@@ -374,3 +374,4 @@ erpnext.patches.v13_0.reset_corrupt_defaults
|
|||||||
erpnext.patches.v13_0.show_hr_payroll_deprecation_warning
|
erpnext.patches.v13_0.show_hr_payroll_deprecation_warning
|
||||||
erpnext.patches.v13_0.create_accounting_dimensions_for_asset_repair
|
erpnext.patches.v13_0.create_accounting_dimensions_for_asset_repair
|
||||||
execute:frappe.db.set_value("Naming Series", "Naming Series", {"select_doc_for_series": "", "set_options": "", "prefix": "", "current_value": 0, "user_must_always_select": 0})
|
execute:frappe.db.set_value("Naming Series", "Naming Series", {"select_doc_for_series": "", "set_options": "", "prefix": "", "current_value": 0, "user_must_always_select": 0})
|
||||||
|
erpnext.patches.v13_0.update_schedule_type_in_loans
|
||||||
17
erpnext/patches/v13_0/update_schedule_type_in_loans.py
Normal file
17
erpnext/patches/v13_0/update_schedule_type_in_loans.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doc("loan_management", "doctype", "loan")
|
||||||
|
frappe.reload_doc("loan_management", "doctype", "loan_type")
|
||||||
|
|
||||||
|
loan = frappe.qb.DocType("Loan")
|
||||||
|
loan_type = frappe.qb.DocType("Loan Type")
|
||||||
|
|
||||||
|
frappe.qb.update(loan_type).set(
|
||||||
|
loan_type.repayment_schedule_type, "Monthly as per repayment start date"
|
||||||
|
).where(loan_type.is_term_loan == 1).run()
|
||||||
|
|
||||||
|
frappe.qb.update(loan).set(
|
||||||
|
loan.repayment_schedule_type, "Monthly as per repayment start date"
|
||||||
|
).where(loan.is_term_loan == 1).run()
|
||||||
@@ -295,6 +295,7 @@ class TestPayrollEntry(FrappeTestCase):
|
|||||||
loan_account="Loan Account - _TC",
|
loan_account="Loan Account - _TC",
|
||||||
interest_income_account="Interest Income Account - _TC",
|
interest_income_account="Interest Income Account - _TC",
|
||||||
penalty_income_account="Penalty Income Account - _TC",
|
penalty_income_account="Penalty Income Account - _TC",
|
||||||
|
repayment_schedule_type="Monthly as per repayment start date",
|
||||||
)
|
)
|
||||||
|
|
||||||
loan = create_loan(
|
loan = create_loan(
|
||||||
|
|||||||
Reference in New Issue
Block a user