-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: disallow cancellation of source documents selected for payment …
- Loading branch information
1 parent
079aa52
commit bddc888
Showing
4 changed files
with
168 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,28 @@ | ||
import json | ||
|
||
import frappe | ||
|
||
|
||
@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') or '' | ||
account_number = doc.get_password('bank_account', raise_exception=False) or '' | ||
return {'routing_number': routing_number, 'account_number': account_number} | ||
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} | ||
|
||
|
||
@frappe.whitelist() | ||
def disallow_cancellation_if_in_check_run(doc, method=None): | ||
draft_check_runs = frappe.get_all("Check Run", ["name", "transactions"], {"docstatus": 0}) | ||
for draft_check_run in draft_check_runs: | ||
transactions = [ | ||
t.get("ref_number") or t.get("name") | ||
for t in json.loads(draft_check_run.transactions) | ||
if t.get("pay") | ||
] | ||
if doc.name in transactions: | ||
frappe.throw( | ||
frappe._( | ||
f"""This document is currently selected for payment in draft {frappe.get_desk_link('Check Run', draft_check_run.name)} and cannot be cancelled.""" | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.