Skip to content

Commit

Permalink
Bank account lookup fix (#61)
Browse files Browse the repository at this point in the history
* feat: fix lookup for non-existient bank account info, improve UX

* fix: don't raise exception on bank account lookup
  • Loading branch information
agritheory authored Feb 28, 2023
1 parent 4ef8a91 commit c4357a8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions check_run/check_run/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
@frappe.whitelist()
def show_bank_account_number(doctype, docname):
doc = frappe.get_doc(doctype, docname)
routing_number = frappe.get_value('Bank', doc.bank, 'aba_number')
account_number = doc.get_password('bank_account')
routing_number = frappe.get_value('Bank', doc.bank, 'aba_number') or ''
account_number = doc.get_password('bank_account', raise_exception=False) or ''
return {'routing_number': routing_number, 'account_number': account_number}
2 changes: 1 addition & 1 deletion check_run/public/js/custom/employee_custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ function set_required_banking_fields(frm){
frm.set_df_property('bank_account', 'hidden', 1)
}
})
}
}
36 changes: 18 additions & 18 deletions check_run/public/js/custom/supplier_custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ function show_bank_account_number(frm) {
frappe.msgprint(msg, "Bank Information")
} else {
frappe.xcall('check_run.check_run.show_bank_account_number', { doctype: frm.doc.doctype, docname: frm.doc.name })
.then(r => {
let msg = `Routing Number ${r.routing_number}<br>Account Number: ${r.account_number}`
frappe.msgprint(msg, "Bank Information")
})
.then(r => {
let msg = `Routing Number ${r.routing_number}<br>Account Number: ${r.account_number}`
frappe.msgprint(msg, "Bank Information")
})
}
}

function set_required_banking_fields(frm) {
if (!frm.doc.supplier_default_mode_of_payment) { return }
frappe.db.get_value('Mode of Payment', frm.doc.supplier_default_mode_of_payment, 'type')
.then(r => {
if (r.message.type == 'Electronic') {
frm.set_df_property('bank', 'reqd', 1)
frm.set_df_property('bank', 'hidden', 0)
frm.set_df_property('bank_account', 'reqd', 1)
frm.set_df_property('bank_account', 'hidden', 0)
} else {
frm.set_df_property('bank', 'reqd', 0)
frm.set_df_property('bank', 'hidden', 1)
frm.set_df_property('bank_account', 'reqd', 0)
frm.set_df_property('bank_account', 'hidden', 1)
}
})
}
.then(r => {
if (r.message.type == 'Electronic') {
frm.set_df_property('bank', 'reqd', 1)
frm.set_df_property('bank', 'hidden', 0)
frm.set_df_property('bank_account', 'reqd', 1)
frm.set_df_property('bank_account', 'hidden', 0)
} else {
frm.set_df_property('bank', 'reqd', 0)
frm.set_df_property('bank', 'hidden', 1)
frm.set_df_property('bank_account', 'reqd', 0)
frm.set_df_property('bank_account', 'hidden', 1)
}
})
}

0 comments on commit c4357a8

Please sign in to comment.