Skip to content

Commit

Permalink
chore: company_collection_percentage, validations for shareable percents
Browse files Browse the repository at this point in the history
(cherry picked from commit c45c05b)
  • Loading branch information
anandbaburajan authored and mergify[bot] committed Nov 2, 2023
1 parent 1c0df03 commit d25b61e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
12 changes: 12 additions & 0 deletions lending/loan_management/doctype/loan_partner/loan_partner.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ frappe.ui.form.on("Loan Partner", {
frm.set_value("partner_loan_share_percentage", 100 - frm.doc.company_loan_share_percentage);
},
});

frappe.ui.form.on('Loan Partner Shareable', {
partner_collection_percentage: function(frm, cdt, cdn) {
const row = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, "company_collection_percentage", 100 - row.partner_collection_percentage);
},

company_collection_percentage: function(frm, cdt, cdn) {
const row = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, "partner_collection_percentage", 100 - row.company_collection_percentage);
},
});
16 changes: 16 additions & 0 deletions lending/loan_management/doctype/loan_partner/loan_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,19 @@ def validate_percentage_and_interest_fields(self):
for field in fields:
if self.get(field) and (self.get(field) < 0 or self.get(field) > 100):
frappe.throw(_("{0} should be between 0 and 100").format(frappe.bold(frappe.unscrub(field))))

shareables_fields = [
"partner_collection_percentage",
"company_collection_percentage",
"partner_loan_amount_percentage",
"minimum_partner_loan_amount_percentage",
]

for shareable in self.shareables:
for field in shareables_fields:
if shareable.get(field) and (shareable.get(field) < 0 or shareable.get(field) > 100):
frappe.throw(
_("Row {0}: {1} should be between 0 and 100").format(
shareable.idx, frappe.bold(frappe.unscrub(field))
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"shareable_type",
"sharing_parameter",
"partner_collection_percentage",
"company_collection_percentage",
"partner_loan_amount_percentage",
"minimum_partner_loan_amount_percentage"
],
Expand All @@ -28,7 +29,6 @@
{
"fieldname": "minimum_partner_loan_amount_percentage",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "Minimum Partner Loan Amount Percentage"
},
{
Expand All @@ -45,13 +45,20 @@
"in_list_view": 1,
"label": "Sharing Parameter",
"options": "\nCollection Percentage\nLoan Amount Percentage",
"reqd": 1
"reqd": 1,
"translatable": 1
},
{
"fieldname": "company_collection_percentage",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "Company Collection Percentage"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-10-02 17:38:34.208157",
"modified": "2023-11-02 11:48:00.797758",
"modified_by": "Administrator",
"module": "Loan Management",
"name": "Loan Partner Shareable",
Expand Down

0 comments on commit d25b61e

Please sign in to comment.