Skip to content

Commit

Permalink
feat: add read_only decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
agritheory committed Sep 7, 2023
1 parent 8368879 commit c7bb83c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion check_run/check_run/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


@frappe.whitelist()
@frappe.read_only()
def show_bank_account_number(doctype, docname):
doc = frappe.get_doc(doctype, docname)
routing_number = frappe.get_value("Bank", doc.bank, "aba_number") or ""
Expand All @@ -27,4 +28,4 @@ def disallow_cancellation_if_in_check_run(doc, method=None):
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."""
)
)
)
7 changes: 7 additions & 0 deletions check_run/check_run/doctype/check_run/check_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@


class CheckRun(Document):
@frappe.read_only()
def onload(self):
if self.is_new():
return
Expand Down Expand Up @@ -103,6 +104,7 @@ def set_default_dates(self):
if not self.end_date:
self.end_date = getdate()

@frappe.read_only()
def filter_transactions(self):
if not self.get("transactions"):
return
Expand All @@ -116,6 +118,7 @@ def filter_transactions(self):
if not t["mode_of_payment"]:
frappe.throw(frappe._(f"Mode of Payment Required: {t['party_name']} {t['ref_number']}"))

@frappe.read_only()
def not_outstanding_or_cancelled(self, transaction):
filters = {
"name": transaction["name"]
Expand Down Expand Up @@ -215,6 +218,7 @@ def build_nacha_file(self, settings=None):
return build_nacha_file_from_payment_entries(self, payment_entries, settings)

@frappe.whitelist()
@frappe.read_only()
def ach_only(self):
transactions = json.loads(self.transactions) if self.transactions else []
ach_only = frappe._dict({"ach_only": True, "print_checks_only": True})
Expand Down Expand Up @@ -444,6 +448,7 @@ def confirm_print(docname):


@frappe.whitelist()
@frappe.read_only()
def get_entries(doc):
doc = frappe._dict(json.loads(doc)) if isinstance(doc, str) else doc
if isinstance(doc.end_date, str):
Expand Down Expand Up @@ -614,6 +619,7 @@ def get_entries(doc):


@frappe.whitelist()
@frappe.read_only()
def get_balance(doc):
doc = frappe._dict(json.loads(doc)) if isinstance(doc, str) else doc
if not doc.bank_account or not doc.posting_date:
Expand Down Expand Up @@ -770,6 +776,7 @@ def get_address(party, party_type, doctype, name):


@frappe.whitelist()
@frappe.read_only()
def ach_only(docname):
if not frappe.db.exists("Check Run", docname):
return {"ach_only": False, "checks_only": False}
Expand Down

0 comments on commit c7bb83c

Please sign in to comment.