Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/frappe/lending into proc…
Browse files Browse the repository at this point in the history
…ess_loan_interest_change_develop
  • Loading branch information
deepeshgarg007 committed Nov 30, 2023
2 parents 6620be4 + 216e683 commit 95bc3e2
Show file tree
Hide file tree
Showing 22 changed files with 267 additions and 80 deletions.
24 changes: 24 additions & 0 deletions lending/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,33 @@ def make_property_setter_for_journal_entry():
)


def get_post_install_patches():
return (
"rename_loan_type_to_loan_product",
"generate_loan_repayment_schedule",
"update_loan_types",
"make_loan_type_non_submittable",
"migrate_loan_type_to_loan_product",
"add_loan_product_code_and_rename_loan_name",
"update_penalty_interest_method_in_loan_products",
)


def run_patches(patches):
frappe.flags.in_patch = True

try:
for patch in patches:
frappe.get_attr(f"lending.patches.v15_0.{patch}.execute")()
finally:
frappe.flags.in_patch = False


def after_install():
create_custom_fields(LOAN_CUSTOM_FIELDS, ignore_validate=True)
make_property_setter_for_journal_entry()
print("\nRunning post-install patches to patch existing data...\n")
run_patches(get_post_install_patches())


def before_uninstall():
Expand Down
20 changes: 9 additions & 11 deletions lending/loan_management/doctype/loan/loan.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"status",
"section_break_8",
"loan_product",
"loan_category",
"repayment_schedule_type",
"loan_amount",
"rate_of_interest",
Expand Down Expand Up @@ -54,7 +55,6 @@
"loan_charges_section",
"loan_charges",
"account_info",
"mode_of_payment",
"disbursement_account",
"payment_account",
"column_break_9",
Expand Down Expand Up @@ -212,15 +212,6 @@
"fieldtype": "Section Break",
"label": "Account Info"
},
{
"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
},
{
"fetch_from": "loan_product.payment_account",
"fieldname": "payment_account",
Expand Down Expand Up @@ -538,12 +529,19 @@
"fieldname": "maximum_limit_amount",
"fieldtype": "Currency",
"label": "Maximum Limit Amount"
},
{
"fetch_from": "loan_product.loan_category",
"fieldname": "loan_category",
"fieldtype": "Link",
"label": "Loan Category",
"options": "Loan Category"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-11-29 22:14:16.693558",
"modified": "2023-11-29 19:34:09.691251",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan",
Expand Down
4 changes: 0 additions & 4 deletions lending/loan_management/doctype/loan/test_loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,6 @@ def create_loan_product(
penalty_interest_rate=None,
is_term_loan=1,
grace_period_in_days=None,
mode_of_payment="Cash",
disbursement_account="Disbursement Account - _TC",
payment_account="Payment Account - _TC",
loan_account="Loan Account - _TC",
Expand Down Expand Up @@ -1074,7 +1073,6 @@ def create_loan_product(
"rate_of_interest": rate_of_interest,
"penalty_interest_rate": penalty_interest_rate,
"grace_period_in_days": grace_period_in_days,
"mode_of_payment": mode_of_payment,
"disbursement_account": disbursement_account,
"payment_account": payment_account,
"loan_account": loan_account,
Expand Down Expand Up @@ -1310,7 +1308,6 @@ def create_loan_with_security(
"repayment_method": repayment_method,
"repayment_periods": repayment_periods,
"repayment_start_date": repayment_start_date or nowdate(),
"mode_of_payment": frappe.db.get_value("Mode of Payment", {"type": "Cash"}, "name"),
"payment_account": "Payment Account - _TC",
"loan_account": "Loan Account - _TC",
"interest_income_account": "Interest Income Account - _TC",
Expand All @@ -1336,7 +1333,6 @@ def create_demand_loan(applicant, loan_product, loan_application, posting_date=N
"loan_product": loan_product,
"is_term_loan": 0,
"is_secured_loan": 1,
"mode_of_payment": frappe.db.get_value("Mode of Payment", {"type": "Cash"}, "name"),
"payment_account": "Payment Account - _TC",
"loan_account": "Loan Account - _TC",
"interest_income_account": "Interest Income Account - _TC",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def update_accounts(source_doc, target_doc, source_parent):
account_details = frappe.get_all(
"Loan Product",
fields=[
"mode_of_payment",
"payment_account",
"loan_account",
"interest_income_account",
Expand All @@ -173,7 +172,6 @@ def update_accounts(source_doc, target_doc, source_parent):
if source_doc.is_secured_loan:
target_doc.maximum_loan_amount = 0

target_doc.mode_of_payment = account_details.mode_of_payment
target_doc.payment_account = account_details.payment_account
target_doc.loan_account = account_details.loan_account
target_doc.interest_income_account = account_details.interest_income_account
Expand Down
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("Loan Category", {
// refresh(frm) {

// },
// });
74 changes: 74 additions & 0 deletions lending/loan_management/doctype/loan_category/loan_category.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "field:loan_category_code",
"creation": "2023-11-27 15:32:04.478796",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"loan_category_code",
"loan_category_name",
"disabled"
],
"fields": [
{
"fieldname": "loan_category_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Loan Category Name",
"reqd": 1,
"unique": 1
},
{
"fieldname": "loan_category_code",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Loan Category Code",
"reqd": 1,
"unique": 1
},
{
"default": "0",
"fieldname": "disabled",
"fieldtype": "Check",
"label": "Disabled"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-27 15:35:27.175566",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Category",
"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
},
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Loan Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"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 LoanCategory(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 TestLoanCategory(FrappeTestCase):
pass
10 changes: 1 addition & 9 deletions lending/loan_management/doctype/loan_charges/loan_charges.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"percentage",
"column_break_gisk",
"amount",
"event",
"charge_accounts_section",
"income_account",
"waiver_account",
Expand All @@ -28,13 +27,6 @@
"label": "Charge Type",
"options": "Item"
},
{
"fieldname": "event",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Event",
"options": "\nDisbursement\nRepayment\nRestructure"
},
{
"fieldname": "charge_based_on",
"fieldtype": "Select",
Expand Down Expand Up @@ -102,7 +94,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-10-10 21:57:17.905327",
"modified": "2023-11-29 20:33:10.270293",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Charges",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def setUp(self):
penalty_interest_rate=25,
is_term_loan=1,
grace_period_in_days=5,
mode_of_payment="Cash",
disbursement_account="Disbursement Account - _TC",
payment_account="Payment Account - _TC",
loan_account="Loan Account - _TC",
Expand Down
16 changes: 6 additions & 10 deletions lending/loan_management/doctype/loan_partner/loan_partner.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"fldg_section",
"fldg_trigger_dpd",
"fldg_limit_calculation_component",
"fldg_total_percentage",
"column_break_szii",
"type_of_fldg_applicable",
"fldg_fixed_deposit_percentage",
Expand Down Expand Up @@ -73,10 +72,10 @@
"fieldname": "organization_type",
"fieldtype": "Select",
"label": "Organization Type",
"options": "\nCentralized\nDecentralized"
"options": "\nCentralized\nDecentralized",
"reqd": 1
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "section_break_mpap",
"fieldtype": "Section Break",
"label": "Organization"
Expand All @@ -97,6 +96,7 @@
"read_only": 1
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "primary_address",
"fieldtype": "Link",
"label": "Primary Address",
Expand Down Expand Up @@ -191,11 +191,6 @@
"label": "FLDG Corporate Guarantee Percentage",
"mandatory_depends_on": "eval:doc.type_of_fldg_applicable == \"Corporate Guarantee only\" || doc.type_of_fldg_applicable == \"Both Fixed Deposit and Corporate Guarantee\""
},
{
"fieldname": "fldg_total_percentage",
"fieldtype": "Percent",
"label": "FLDG Total Percentage"
},
{
"fieldname": "misc_section",
"fieldtype": "Section Break",
Expand Down Expand Up @@ -240,7 +235,8 @@
"fieldname": "partial_payment_mechanism",
"fieldtype": "Select",
"label": "Partial Payment Mechanism",
"options": "\nEMI Percentage wise sharing\nComponent wise sharing"
"options": "\nEMI Percentage wise sharing\nComponent wise sharing",
"reqd": 1
},
{
"fieldname": "column_break_xyxj",
Expand All @@ -253,7 +249,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-03 11:30:01.230498",
"modified": "2023-11-09 14:55:36.675654",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Partner",
Expand Down
Loading

0 comments on commit 95bc3e2

Please sign in to comment.