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: fetch logic for repay_from_salary in loan_repayment [v14] #37135

Merged
merged 2 commits into from
Sep 19, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
frappe.ui.form.on('Loan Repayment', {
// refresh: function(frm) {

// }
// },

setup: function(frm) {
if (frappe.meta.has_field("Loan Repayment", "repay_from_salary")) {
frm.add_fetch("against_loan", "repay_from_salary", "repay_from_salary");
}
},

onload: function(frm) {
frm.set_query('against_loan', function() {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def set_missing_values(self, amounts):
if amounts.get("due_date"):
self.due_date = amounts.get("due_date")

if hasattr(self, "repay_from_salary") and hasattr(self, "payroll_payable_account"):
if self.repay_from_salary and not self.payroll_payable_account:
frappe.throw(_("Please set Payroll Payable Account in Loan Repayment"))
elif not self.repay_from_salary and self.payroll_payable_account:
self.repay_from_salary = 1

def check_future_entries(self):
future_repayment_date = frappe.db.get_value(
"Loan Repayment",
Expand Down
Loading