From e38a571558023142ccdcf4d15a519b0033df2885 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 23 Feb 2024 18:12:09 +0530 Subject: [PATCH] fix: Loan Reco updates --- lending/loan_management/utils.py | 14 +++++----- .../v15_0/generate_loan_repayment_schedule.py | 16 +++++------ .../dist/js/lending.bundle.2O3MYYF2.js.map | 7 ----- ...2O3MYYF2.js => lending.bundle.H2KPP2TL.js} | 27 ++++++++++++++++++- .../dist/js/lending.bundle.H2KPP2TL.js.map | 7 +++++ 5 files changed, 49 insertions(+), 22 deletions(-) delete mode 100644 lending/public/dist/js/lending.bundle.2O3MYYF2.js.map rename lending/public/dist/js/{lending.bundle.2O3MYYF2.js => lending.bundle.H2KPP2TL.js} (65%) create mode 100644 lending/public/dist/js/lending.bundle.H2KPP2TL.js.map diff --git a/lending/loan_management/utils.py b/lending/loan_management/utils.py index 6e2693e0..89519af8 100644 --- a/lending/loan_management/utils.py +++ b/lending/loan_management/utils.py @@ -120,10 +120,11 @@ def get_ld_matching_query(bank_account, exact_match, transaction): (ref_rank + party_rank + 1).as_("rank"), ConstantColumn("Loan Disbursement").as_("doctype"), loan_disbursement.name, - loan_disbursement.disbursed_amount, - loan_disbursement.reference_number, + (loan_disbursement.disbursed_amount).as_("paid_amount"), + (loan_disbursement.reference_number).as_("reference_no"), loan_disbursement.reference_date, - loan_disbursement.applicant_type, + (loan_disbursement.applicant_type).as_("party_type"), + (loan_disbursement.applicant).as_("party"), loan_disbursement.disbursement_date, ) .where(loan_disbursement.docstatus == 1) @@ -158,10 +159,11 @@ def get_lr_matching_query(bank_account, exact_match, transaction): (ref_rank + party_rank + 1).as_("rank"), ConstantColumn("Loan Repayment").as_("doctype"), loan_repayment.name, - loan_repayment.amount_paid, - loan_repayment.reference_number, + (loan_repayment.amount_paid).as_("paid_amount"), + (loan_repayment.reference_number).as_("reference_no"), loan_repayment.reference_date, - loan_repayment.applicant_type, + (loan_repayment.applicant_type).as_("party_type"), + (loan_repayment.applicant).as_("party"), loan_repayment.posting_date, ) .where(loan_repayment.docstatus == 1) diff --git a/lending/patches/v15_0/generate_loan_repayment_schedule.py b/lending/patches/v15_0/generate_loan_repayment_schedule.py index d6247ced..59dc100d 100644 --- a/lending/patches/v15_0/generate_loan_repayment_schedule.py +++ b/lending/patches/v15_0/generate_loan_repayment_schedule.py @@ -16,18 +16,18 @@ def execute(): return for loan in frappe.get_all("Loan", filters={"is_term_loan": 1, "docstatus": ["!=", 2]}): - loan = frappe.get_cached_doc("Loan", loan.name) + loan_doc = frappe.get_cached_doc("Loan", loan.name) loan_repayment_schedule = frappe.new_doc("Loan Repayment Schedule") loan_repayment_schedule.flags.ignore_validate = True - loan_repayment_schedule.loan = loan.name - loan_repayment_schedule.loan_product = loan.loan_type - loan_repayment_schedule.loan_amount = loan.loan_amount - loan_repayment_schedule.monthly_repayment_amount = loan.monthly_repayment_amount - loan_repayment_schedule.posting_date = loan.posting_date - loan_repayment_schedule.status = get_status(loan.status) + loan_repayment_schedule.loan = loan_doc.name + loan_repayment_schedule.loan_product = frappe.db.get_value("Loan", loan_doc.name, "loan_type") + loan_repayment_schedule.loan_amount = loan_doc.loan_amount + loan_repayment_schedule.monthly_repayment_amount = loan_doc.monthly_repayment_amount + loan_repayment_schedule.posting_date = loan_doc.posting_date + loan_repayment_schedule.status = get_status(loan_doc.status) repayment_schedules = frappe.db.get_all( - "Repayment Schedule", {"parent": loan.name}, "*", order_by="idx" + "Repayment Schedule", {"parent": loan_doc.name}, "*", order_by="idx" ) for rs in repayment_schedules: diff --git a/lending/public/dist/js/lending.bundle.2O3MYYF2.js.map b/lending/public/dist/js/lending.bundle.2O3MYYF2.js.map deleted file mode 100644 index 64a1a70d..00000000 --- a/lending/public/dist/js/lending.bundle.2O3MYYF2.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../../../../../apps/lending/lending/public/js/loan_common.js"], - "sourcesContent": ["// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors\n// For license information, please see license.txt\nfrappe.provide(\"lending.common\");\n\nlending.common = {\n\tsetup_filters: function(doctype) {\n\t\tfrappe.ui.form.on(doctype, {\n\t\t\trefresh: function(frm) {\n\t\t\t\tif (['Loan Disbursement', 'Loan Repayment', 'Loan Interest Accrual', 'Loan Write Off'].includes(frm.doc.doctype)\n\t\t\t\t\t&& frm.doc.docstatus > 0) {\n\t\t\t\t\tcur_frm.add_custom_button(__('Accounting Ledger'), function() {\n\t\t\t\t\t\tfrappe.route_options = {\n\t\t\t\t\t\t\tvoucher_no: frm.doc.name,\n\t\t\t\t\t\t\tfrom_date: frm.doc.posting_date,\n\t\t\t\t\t\t\tto_date: frm.doc.posting_date,\n\t\t\t\t\t\t\tcompany: frm.doc.company,\n\t\t\t\t\t\t\tgroup_by: \"Group by Voucher (Consolidated)\",\n\t\t\t\t\t\t\tshow_cancelled_entries: frm.doc.docstatus === 2\n\t\t\t\t\t\t};\n\t\t\t\t\t\tfrappe.set_route(\"query-report\", \"General Ledger\");\n\t\t\t\t\t}, __(\"View\"));\n\t\t\t\t}\n\t\t\t\terpnext.hide_company();\n\t\t\t},\n\n\t\t\tapplicant: function(frm) {\n\t\t\t\tif (![\"Loan Application\", \"Loan\"].includes(frm.doc.doctype)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (frm.doc.applicant) {\n\t\t\t\t\tfrappe.model.with_doc(frm.doc.applicant_type, frm.doc.applicant, function() {\n\t\t\t\t\t\tvar applicant = frappe.model.get_doc(frm.doc.applicant_type, frm.doc.applicant);\n\t\t\t\t\t\tfrm.set_value(\"applicant_name\",\n\t\t\t\t\t\t\tapplicant.employee_name || applicant.member_name);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfrm.set_value(\"applicant_name\", null);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}"], - "mappings": ";;AAEA,SAAO,QAAQ,gBAAgB;AAE/B,UAAQ,SAAS;AAAA,IAChB,eAAe,SAAS,SAAS;AAChC,aAAO,GAAG,KAAK,GAAG,SAAS;AAAA,QAC1B,SAAS,SAAS,KAAK;AACtB,cAAI,CAAC,qBAAqB,kBAAkB,yBAAyB,gBAAgB,EAAE,SAAS,IAAI,IAAI,OAAO,KAC3G,IAAI,IAAI,YAAY,GAAG;AAC1B,oBAAQ,kBAAkB,GAAG,mBAAmB,GAAG,WAAW;AAC7D,qBAAO,gBAAgB;AAAA,gBACtB,YAAY,IAAI,IAAI;AAAA,gBACpB,WAAW,IAAI,IAAI;AAAA,gBACnB,SAAS,IAAI,IAAI;AAAA,gBACjB,SAAS,IAAI,IAAI;AAAA,gBACjB,UAAU;AAAA,gBACV,wBAAwB,IAAI,IAAI,cAAc;AAAA,cAC/C;AACA,qBAAO,UAAU,gBAAgB,gBAAgB;AAAA,YAClD,GAAG,GAAG,MAAM,CAAC;AAAA,UACd;AACA,kBAAQ,aAAa;AAAA,QACtB;AAAA,QAEA,WAAW,SAAS,KAAK;AACxB,cAAI,CAAC,CAAC,oBAAoB,MAAM,EAAE,SAAS,IAAI,IAAI,OAAO,GAAG;AAC5D;AAAA,UACD;AAEA,cAAI,IAAI,IAAI,WAAW;AACtB,mBAAO,MAAM,SAAS,IAAI,IAAI,gBAAgB,IAAI,IAAI,WAAW,WAAW;AAC3E,kBAAI,YAAY,OAAO,MAAM,QAAQ,IAAI,IAAI,gBAAgB,IAAI,IAAI,SAAS;AAC9E,kBAAI;AAAA,gBAAU;AAAA,gBACb,UAAU,iBAAiB,UAAU;AAAA,cAAW;AAAA,YAClD,CAAC;AAAA,UACF,OACK;AACJ,gBAAI,UAAU,kBAAkB,IAAI;AAAA,UACrC;AAAA,QACD;AAAA,MACD,CAAC;AAAA,IACF;AAAA,EACD;", - "names": [] -} diff --git a/lending/public/dist/js/lending.bundle.2O3MYYF2.js b/lending/public/dist/js/lending.bundle.H2KPP2TL.js similarity index 65% rename from lending/public/dist/js/lending.bundle.2O3MYYF2.js rename to lending/public/dist/js/lending.bundle.H2KPP2TL.js index ed0b7d4c..42bb74bc 100644 --- a/lending/public/dist/js/lending.bundle.2O3MYYF2.js +++ b/lending/public/dist/js/lending.bundle.H2KPP2TL.js @@ -19,6 +19,31 @@ }, __("View")); } erpnext.hide_company(); + frm.trigger("set_company_filter"); + }, + applicant_type: function(frm) { + frm.trigger("set_company_filter"); + }, + set_company_filter: function(frm) { + if (["Loan Application", "Loan"].includes(frm.doc.doctype)) { + if (frm.doc.applicant_type === "Employee") { + frm.set_query("applicant", function() { + return { + "filters": { + "company": frm.doc.company + } + }; + }); + } else { + frm.set_query("applicant", function() { + return { + "filters": { + "docstatus": 0 + } + }; + }); + } + } }, applicant: function(frm) { if (!["Loan Application", "Loan"].includes(frm.doc.doctype)) { @@ -40,4 +65,4 @@ } }; })(); -//# sourceMappingURL=lending.bundle.2O3MYYF2.js.map +//# sourceMappingURL=lending.bundle.H2KPP2TL.js.map diff --git a/lending/public/dist/js/lending.bundle.H2KPP2TL.js.map b/lending/public/dist/js/lending.bundle.H2KPP2TL.js.map new file mode 100644 index 00000000..17a7352d --- /dev/null +++ b/lending/public/dist/js/lending.bundle.H2KPP2TL.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../../../../../apps/lending/lending/public/js/loan_common.js"], + "sourcesContent": ["// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors\n// For license information, please see license.txt\nfrappe.provide(\"lending.common\");\n\nlending.common = {\n\tsetup_filters: function(doctype) {\n\t\tfrappe.ui.form.on(doctype, {\n\t\t\trefresh: function(frm) {\n\t\t\t\tif (['Loan Disbursement', 'Loan Repayment', 'Loan Interest Accrual', 'Loan Write Off'].includes(frm.doc.doctype)\n\t\t\t\t\t&& frm.doc.docstatus > 0) {\n\t\t\t\t\tcur_frm.add_custom_button(__('Accounting Ledger'), function() {\n\t\t\t\t\t\tfrappe.route_options = {\n\t\t\t\t\t\t\tvoucher_no: frm.doc.name,\n\t\t\t\t\t\t\tfrom_date: frm.doc.posting_date,\n\t\t\t\t\t\t\tto_date: frm.doc.posting_date,\n\t\t\t\t\t\t\tcompany: frm.doc.company,\n\t\t\t\t\t\t\tgroup_by: \"Group by Voucher (Consolidated)\",\n\t\t\t\t\t\t\tshow_cancelled_entries: frm.doc.docstatus === 2\n\t\t\t\t\t\t};\n\t\t\t\t\t\tfrappe.set_route(\"query-report\", \"General Ledger\");\n\t\t\t\t\t}, __(\"View\"));\n\t\t\t\t}\n\t\t\t\terpnext.hide_company();\n\t\t\t\tfrm.trigger(\"set_company_filter\");\n\t\t\t},\n\t\t\tapplicant_type: function(frm) {\n\t\t\t\tfrm.trigger(\"set_company_filter\");\n\t\t\t},\n\t\t\tset_company_filter: function(frm) {\n\t\t\t\tif ([\"Loan Application\", \"Loan\"].includes(frm.doc.doctype)) {\n\t\t\t\t\tif (frm.doc.applicant_type === \"Employee\") {\n\t\t\t\t\t\tfrm.set_query(\"applicant\", function() {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\"filters\": {\n\t\t\t\t\t\t\t\t\t\"company\": frm.doc.company\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfrm.set_query(\"applicant\", function() {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\"filters\": {\n\t\t\t\t\t\t\t\t\t\"docstatus\": 0\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tapplicant: function(frm) {\n\t\t\t\tif (![\"Loan Application\", \"Loan\"].includes(frm.doc.doctype)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (frm.doc.applicant) {\n\t\t\t\t\tfrappe.model.with_doc(frm.doc.applicant_type, frm.doc.applicant, function() {\n\t\t\t\t\t\tvar applicant = frappe.model.get_doc(frm.doc.applicant_type, frm.doc.applicant);\n\t\t\t\t\t\tfrm.set_value(\"applicant_name\",\n\t\t\t\t\t\t\tapplicant.employee_name || applicant.member_name);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfrm.set_value(\"applicant_name\", null);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}"], + "mappings": ";;AAEA,SAAO,QAAQ,gBAAgB;AAE/B,UAAQ,SAAS;AAAA,IAChB,eAAe,SAAS,SAAS;AAChC,aAAO,GAAG,KAAK,GAAG,SAAS;AAAA,QAC1B,SAAS,SAAS,KAAK;AACtB,cAAI,CAAC,qBAAqB,kBAAkB,yBAAyB,gBAAgB,EAAE,SAAS,IAAI,IAAI,OAAO,KAC3G,IAAI,IAAI,YAAY,GAAG;AAC1B,oBAAQ,kBAAkB,GAAG,mBAAmB,GAAG,WAAW;AAC7D,qBAAO,gBAAgB;AAAA,gBACtB,YAAY,IAAI,IAAI;AAAA,gBACpB,WAAW,IAAI,IAAI;AAAA,gBACnB,SAAS,IAAI,IAAI;AAAA,gBACjB,SAAS,IAAI,IAAI;AAAA,gBACjB,UAAU;AAAA,gBACV,wBAAwB,IAAI,IAAI,cAAc;AAAA,cAC/C;AACA,qBAAO,UAAU,gBAAgB,gBAAgB;AAAA,YAClD,GAAG,GAAG,MAAM,CAAC;AAAA,UACd;AACA,kBAAQ,aAAa;AACrB,cAAI,QAAQ,oBAAoB;AAAA,QACjC;AAAA,QACA,gBAAgB,SAAS,KAAK;AAC7B,cAAI,QAAQ,oBAAoB;AAAA,QACjC;AAAA,QACA,oBAAoB,SAAS,KAAK;AACjC,cAAI,CAAC,oBAAoB,MAAM,EAAE,SAAS,IAAI,IAAI,OAAO,GAAG;AAC3D,gBAAI,IAAI,IAAI,mBAAmB,YAAY;AAC1C,kBAAI,UAAU,aAAa,WAAW;AACrC,uBAAO;AAAA,kBACN,WAAW;AAAA,oBACV,WAAW,IAAI,IAAI;AAAA,kBACpB;AAAA,gBACD;AAAA,cACD,CAAC;AAAA,YACF,OAAO;AACN,kBAAI,UAAU,aAAa,WAAW;AACrC,uBAAO;AAAA,kBACN,WAAW;AAAA,oBACV,aAAa;AAAA,kBACd;AAAA,gBACD;AAAA,cACD,CAAC;AAAA,YACF;AAAA,UACD;AAAA,QACD;AAAA,QAEA,WAAW,SAAS,KAAK;AACxB,cAAI,CAAC,CAAC,oBAAoB,MAAM,EAAE,SAAS,IAAI,IAAI,OAAO,GAAG;AAC5D;AAAA,UACD;AAEA,cAAI,IAAI,IAAI,WAAW;AACtB,mBAAO,MAAM,SAAS,IAAI,IAAI,gBAAgB,IAAI,IAAI,WAAW,WAAW;AAC3E,kBAAI,YAAY,OAAO,MAAM,QAAQ,IAAI,IAAI,gBAAgB,IAAI,IAAI,SAAS;AAC9E,kBAAI;AAAA,gBAAU;AAAA,gBACb,UAAU,iBAAiB,UAAU;AAAA,cAAW;AAAA,YAClD,CAAC;AAAA,UACF,OACK;AACJ,gBAAI,UAAU,kBAAkB,IAAI;AAAA,UACrC;AAAA,QACD;AAAA,MACD,CAAC;AAAA,IACF;AAAA,EACD;", + "names": [] +}