Skip to content

Commit

Permalink
feat: Add Loan Product doctype.
Browse files Browse the repository at this point in the history
  • Loading branch information
bosue committed Sep 23, 2023
1 parent 14ea3e3 commit aefc736
Show file tree
Hide file tree
Showing 40 changed files with 1,158 additions and 66 deletions.
65 changes: 65 additions & 0 deletions lending/fixtures/amortization_type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[
{
"amortization_type": "None",
"code": "NO",
"docstatus": 0,
"doctype": "Amortization Type",
"modified": "2023-09-23 04:17:52.094010",
"name": "None",
"sort_order": 0
},
{
"amortization_type": "Interest only",
"code": "IN",
"docstatus": 0,
"doctype": "Amortization Type",
"modified": "2023-09-23 04:18:22.039032",
"name": "Interest only",
"sort_order": 1
},
{
"amortization_type": "Progressive annuities towards RV",
"code": "PR",
"docstatus": 0,
"doctype": "Amortization Type",
"modified": "2023-09-23 04:19:09.576844",
"name": "Progressive annuities towards RV",
"sort_order": 2
},
{
"amortization_type": "Progressive annuities towards 0",
"code": "P0",
"docstatus": 0,
"doctype": "Amortization Type",
"modified": "2023-09-23 04:19:29.894895",
"name": "Progressive annuities towards 0",
"sort_order": 3
},
{
"amortization_type": "Linear annuities towards RV",
"code": "LR",
"docstatus": 0,
"doctype": "Amortization Type",
"modified": "2023-09-23 04:21:03.069987",
"name": "Linear annuities towards RV",
"sort_order": 4
},
{
"amortization_type": "Linear annuities towards 0",
"code": "L0",
"docstatus": 0,
"doctype": "Amortization Type",
"modified": "2023-09-23 04:21:20.658786",
"name": "Linear annuities towards 0",
"sort_order": 5
},
{
"amortization_type": "Degressive annuities",
"code": "D0",
"docstatus": 0,
"doctype": "Amortization Type",
"modified": "2023-09-23 04:23:40.268938",
"name": "Degressive annuities",
"sort_order": 6
}
]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt

// frappe.ui.form.on("Amortization Type", {
// refresh(frm) {

// },
// });
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "field:amortization_type",
"creation": "2023-09-22 23:59:28.235303",
"default_view": "List",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"amortization_type",
"code",
"column_break_rwej",
"sort_order"
],
"fields": [
{
"bold": 1,
"fieldname": "amortization_type",
"fieldtype": "Data",
"label": "Amortization Type",
"reqd": 1,
"translatable": 1,
"unique": 1
},
{
"fieldname": "column_break_rwej",
"fieldtype": "Column Break"
},
{
"fieldname": "code",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Code",
"reqd": 1,
"unique": 1
},
{
"fieldname": "sort_order",
"fieldtype": "Int",
"in_list_view": 1,
"label": "Sort order",
"non_negative": 1,
"reqd": 1,
"search_index": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-23 04:21:41.579342",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Amortization Type",
"naming_rule": "By fieldname",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "sort_order",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class AmortizationType(Document):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase


class TestAmortizationType(FrappeTestCase):
pass
44 changes: 26 additions & 18 deletions lending/loan_management/doctype/loan/loan.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"actions": [],
"allow_import": 1,
"autoname": "ACC-LOAN-.YYYY.-.#####",
"creation": "2022-01-25 10:30:02.294967",
"creation": "2023-09-23 15:17:22.049362",
"doctype": "DocType",
"document_type": "Document",
"editable_grid": 1,
Expand All @@ -18,21 +18,23 @@
"posting_date",
"status",
"section_break_8",
"loan_product",
"loan_type",
"is_term_loan",
"repayment_schedule_type",
"maximum_loan_amount",
"loan_amount",
"rate_of_interest",
"is_secured_loan",
"disbursement_date",
"closure_date",
"disbursed_amount",
"column_break_11",
"maximum_loan_amount",
"repayment_method",
"repayment_periods",
"monthly_repayment_amount",
"mode_of_payment",
"disbursed_amount",
"closure_date",
"disbursement_date",
"repayment_start_date",
"is_term_loan",
"loan_classification_details_section",
"days_past_due",
"classification_code",
Expand All @@ -44,7 +46,6 @@
"accounting_dimensions_section",
"cost_center",
"account_info",
"mode_of_payment",
"disbursement_account",
"payment_account",
"column_break_9",
Expand Down Expand Up @@ -96,12 +97,13 @@
"options": "Loan Application"
},
{
"fetch_from": "loan_product.loan_type",
"fieldname": "loan_type",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Loan Type",
"options": "Loan Type",
"read_only": 1,
"reqd": 1
},
{
Expand Down Expand Up @@ -149,12 +151,11 @@
"options": "Company:company:default_currency"
},
{
"fetch_from": "loan_type.rate_of_interest",
"fetch_from": "loan_product.interest_rate",
"fieldname": "rate_of_interest",
"fieldtype": "Percent",
"label": "Rate of Interest (%) / Year",
"read_only": 1,
"reqd": 1
"read_only": 1
},
{
"depends_on": "eval:doc.status==\"Disbursed\"",
Expand All @@ -175,6 +176,7 @@
},
{
"depends_on": "is_term_loan",
"fetch_from": ".",
"fieldname": "repayment_method",
"fieldtype": "Select",
"label": "Repayment Method",
Expand Down Expand Up @@ -202,13 +204,11 @@
"label": "Account Info"
},
{
"fetch_from": "loan_type.mode_of_payment",
"fetch_from": "loan_product.mode_of_payment",
"fieldname": "mode_of_payment",
"fieldtype": "Link",
"label": "Mode of Payment",
"options": "Mode of Payment",
"read_only": 1,
"reqd": 1
"options": "Mode of Payment"
},
{
"fetch_from": "loan_type.payment_account",
Expand Down Expand Up @@ -295,7 +295,7 @@
},
{
"default": "0",
"fetch_from": "loan_type.is_term_loan",
"fetch_from": "loan_product.is_term_loan",
"fieldname": "is_term_loan",
"fieldtype": "Check",
"label": "Is Term Loan",
Expand Down Expand Up @@ -328,6 +328,7 @@
},
{
"depends_on": "eval:doc.is_secured_loan",
"fetch_from": "loan_product.maximum_loan_amount",
"fieldname": "maximum_loan_amount",
"fieldtype": "Currency",
"label": "Maximum Loan Amount",
Expand Down Expand Up @@ -404,7 +405,7 @@
},
{
"depends_on": "is_term_loan",
"fetch_from": "loan_type.repayment_schedule_type",
"fetch_from": "loan_product.repayment_schedule_type",
"fieldname": "repayment_schedule_type",
"fieldtype": "Data",
"label": "Repayment Schedule Type",
Expand Down Expand Up @@ -473,12 +474,19 @@
"fieldname": "loan_classification_details_section",
"fieldtype": "Section Break",
"label": "Loan Classification Details"
},
{
"fetch_from": ".loan_product",
"fieldname": "loan_product",
"fieldtype": "Link",
"label": "Loan Product",
"options": "Loan Product"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-09-21 20:41:41.531824",
"modified": "2023-09-23 15:53:10.605800",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan",
Expand Down
2 changes: 1 addition & 1 deletion lending/loan_management/doctype/loan/loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def set_missing_fields(self):
self.posting_date = nowdate()

if self.loan_type and not self.rate_of_interest:
self.rate_of_interest = frappe.db.get_value("Loan Type", self.loan_type, "rate_of_interest")
self.rate_of_interest = frappe.db.get_value("Loan Product", self.loan_type, "interest_rate")

def check_sanctioned_amount_limit(self):
sanctioned_amount_limit = get_sanctioned_amount_limit(
Expand Down

0 comments on commit aefc736

Please sign in to comment.