Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loan repay from salary attribute #195

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lending/loan_management/doctype/loan/loan.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt

lending.common.setup_filters("Loan");

frappe.ui.form.on('Loan', {
Expand Down Expand Up @@ -245,7 +242,7 @@ frappe.ui.form.on('Loan', {
if (!r.exc && r.message) {

let loan_fields = ["loan_product", "loan_amount", "repayment_method",
"monthly_repayment_amount", "repayment_periods", "rate_of_interest", "is_secured_loan"]
"monthly_repayment_amount", "repayment_periods", "rate_of_interest", "is_secured_loan", "repay_from_salary"]

loan_fields.forEach(field => {
frm.set_value(field, r.message[field]);
Expand Down Expand Up @@ -277,4 +274,4 @@ frappe.ui.form.on('Loan', {
frm.toggle_enable("monthly_repayment_amount", frm.doc.repayment_method == "Repay Fixed Amount per Period")
frm.toggle_enable("repayment_periods", frm.doc.repayment_method == "Repay Over Number of Periods")
}
});
});
11 changes: 9 additions & 2 deletions lending/loan_management/doctype/loan/loan.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"total_amount_paid",
"is_npa",
"manual_npa",
"amended_from"
"amended_from",
"repay_from_salary"
],
"fields": [
{
Expand Down Expand Up @@ -472,6 +473,12 @@
"fieldtype": "Link",
"label": "Loan Category",
"options": "Loan Category"
},
{
"default": "0",
"fieldname": "repay_from_salary",
"fieldtype": "Check",
"label": "Repay From Salary"
}
],
"index_web_pages_for_search": 1,
Expand Down Expand Up @@ -509,4 +516,4 @@
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
}
3 changes: 3 additions & 0 deletions lending/loan_management/doctype/loan/loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ def set_missing_fields(self):
"Loan Product", self.loan_product, "rate_of_interest"
)

if not hasattr(self, 'repay_from_salary'):
self.repay_from_salary = 0

def check_sanctioned_amount_limit(self):
sanctioned_amount_limit = get_sanctioned_amount_limit(
self.applicant_type, self.applicant, self.company
Expand Down
8 changes: 8 additions & 0 deletions lending/loan_management/doctype/loan/loan_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@ def get_data():
{"items": ["Loan Repayment", "Loan Interest Accrual", "Loan Write Off", "Loan Restructure"]},
{"items": ["Loan Security Unpledge", "Days Past Due Log", "Journal Entry", "Sales Invoice"]},
],
"custom_fields": [
{
"fieldname": "repay_from_salary",
"fieldtype": "Check",
"label": "Repay From Salary",
"default": "0"
}
]
}
6 changes: 3 additions & 3 deletions lending/loan_management/doctype/loan/loan_list.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt

frappe.listview_settings['Loan'] = {
get_indicator: function(doc) {
var status_color = {
Expand All @@ -13,4 +10,7 @@ frappe.listview_settings['Loan'] = {
};
return [__(doc.status), status_color[doc.status], "status,=,"+doc.status];
},
repay_from_salary: function(doc) {
return doc.repay_from_salary ? [__("Repay From Salary"), "green", "repay_from_salary,=,1"] : null;
}
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt

lending.common.setup_filters("Loan Repayment");

frappe.ui.form.on('Loan Repayment', {
Expand Down Expand Up @@ -77,4 +74,4 @@ frappe.ui.form.on('Loan Repayment', {
}
});
}
});
});
Loading