From 4ec5ae8b960fefbe75c57b89cb6f3fc961676b4c Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 10 Oct 2023 19:58:20 +0530 Subject: [PATCH] feat: Loan disbursement charges --- .../loan_disbursement/loan_disbursement.json | 15 +++++- .../loan_disbursement/loan_disbursement.py | 35 ++++++++++++++ .../loan_disbursement_charge/__init__.py | 0 .../loan_disbursement_charge.json | 47 +++++++++++++++++++ .../loan_disbursement_charge.py | 9 ++++ .../doctype/loan_repayment/loan_repayment.py | 2 +- 6 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 lending/loan_management/doctype/loan_disbursement_charge/__init__.py create mode 100644 lending/loan_management/doctype/loan_disbursement_charge/loan_disbursement_charge.json create mode 100644 lending/loan_management/doctype/loan_disbursement_charge/loan_disbursement_charge.py diff --git a/lending/loan_management/doctype/loan_disbursement/loan_disbursement.json b/lending/loan_management/doctype/loan_disbursement/loan_disbursement.json index 141370e8..e2d13870 100644 --- a/lending/loan_management/doctype/loan_disbursement/loan_disbursement.json +++ b/lending/loan_management/doctype/loan_disbursement/loan_disbursement.json @@ -23,6 +23,8 @@ "disbursed_amount", "accounting_dimensions_section", "cost_center", + "charges_section", + "loan_disbursement_charges", "accounting_details", "disbursement_account", "column_break_16", @@ -213,12 +215,23 @@ "label": "Loan Product", "options": "Loan Product", "read_only": 1 + }, + { + "fieldname": "charges_section", + "fieldtype": "Section Break", + "label": "Charges" + }, + { + "fieldname": "loan_disbursement_charges", + "fieldtype": "Table", + "label": "Loan Disbursement Charges", + "options": "Loan Disbursement Charge" } ], "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2023-10-02 22:14:24.804546", + "modified": "2023-10-10 19:19:44.826241", "modified_by": "Administrator", "module": "Loan Management", "name": "Loan Disbursement", diff --git a/lending/loan_management/doctype/loan_disbursement/loan_disbursement.py b/lending/loan_management/doctype/loan_disbursement/loan_disbursement.py index 5161daf5..bcf178d4 100644 --- a/lending/loan_management/doctype/loan_disbursement/loan_disbursement.py +++ b/lending/loan_management/doctype/loan_disbursement/loan_disbursement.py @@ -250,6 +250,41 @@ def make_gl_entries(self, cancel=0, adv_adj=0): ) ) + for charge in self.get("loan_disbursement_charges"): + gle_map.append( + self.get_gl_dict( + { + "account": charge.account, + "against": self.disbursement_account, + "credit": charge.amount, + "credit_in_account_currency": charge.amount, + "against_voucher_type": "Loan", + "against_voucher": self.against_loan, + "remarks": _("Disbursement against loan:") + self.against_loan, + "cost_center": self.cost_center, + "party_type": self.applicant_type, + "party": self.applicant, + "posting_date": self.disbursement_date, + } + ) + ) + + gle_map.append( + self.get_gl_dict( + { + "account": self.disbursement_account, + "against": self.loan_account, + "credit": -1 * charge.amount, + "credit_in_account_currency": -1 * charge.amount, + "against_voucher_type": "Loan", + "against_voucher": self.against_loan, + "remarks": _("Disbursement against loan:") + self.against_loan, + "cost_center": self.cost_center, + "posting_date": self.disbursement_date, + } + ) + ) + if gle_map: make_gl_entries(gle_map, cancel=cancel, adv_adj=adv_adj) diff --git a/lending/loan_management/doctype/loan_disbursement_charge/__init__.py b/lending/loan_management/doctype/loan_disbursement_charge/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lending/loan_management/doctype/loan_disbursement_charge/loan_disbursement_charge.json b/lending/loan_management/doctype/loan_disbursement_charge/loan_disbursement_charge.json new file mode 100644 index 00000000..094e71bc --- /dev/null +++ b/lending/loan_management/doctype/loan_disbursement_charge/loan_disbursement_charge.json @@ -0,0 +1,47 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2023-10-10 19:06:41.545302", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "charge", + "amount", + "account" + ], + "fields": [ + { + "fieldname": "charge", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Charge", + "options": "Item" + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount" + }, + { + "fieldname": "account", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Account", + "options": "Account" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2023-10-10 19:47:07.918342", + "modified_by": "Administrator", + "module": "Loan Management", + "name": "Loan Disbursement Charge", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/lending/loan_management/doctype/loan_disbursement_charge/loan_disbursement_charge.py b/lending/loan_management/doctype/loan_disbursement_charge/loan_disbursement_charge.py new file mode 100644 index 00000000..17d339d3 --- /dev/null +++ b/lending/loan_management/doctype/loan_disbursement_charge/loan_disbursement_charge.py @@ -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 LoanDisbursementCharge(Document): + pass diff --git a/lending/loan_management/doctype/loan_repayment/loan_repayment.py b/lending/loan_management/doctype/loan_repayment/loan_repayment.py index c4450774..9d9a7908 100644 --- a/lending/loan_management/doctype/loan_repayment/loan_repayment.py +++ b/lending/loan_management/doctype/loan_repayment/loan_repayment.py @@ -1245,7 +1245,7 @@ def get_outstanding_invoices(loan, posting_date): "Sales Invoice", filters={ "loan": loan, - "outstanding_amount": (">", 0), + "outstanding_amount": ("!=", 0), "docstatus": 1, "due_date": ("<=", posting_date), },