Skip to content

Commit

Permalink
fix(EBICS User): check banking and ebics are enabled before running w…
Browse files Browse the repository at this point in the history
…hitelisted methods

(cherry picked from commit 3090438)
  • Loading branch information
barredterra authored and mergify[bot] committed Jan 21, 2025
1 parent 1030e8c commit 9d2e5a8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions banking/ebics/doctype/ebics_user/ebics_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def on_doctype_update():
def initialize(
ebics_user: str, passphrase: str, signature_passphrase: str, store_passphrase: int
):
ensure_ebics_is_enabled()

user = frappe.get_doc("EBICS User", ebics_user)
user.check_permission("write")

Expand Down Expand Up @@ -151,6 +153,8 @@ def initialize(

@frappe.whitelist()
def download_bank_keys(ebics_user: str, passphrase: str | None = None):
ensure_ebics_is_enabled()

user = frappe.get_doc("EBICS User", ebics_user)
user.check_permission("write")

Expand All @@ -161,6 +165,8 @@ def download_bank_keys(ebics_user: str, passphrase: str | None = None):

@frappe.whitelist()
def confirm_bank_keys(ebics_user: str, passphrase: str | None = None):
ensure_ebics_is_enabled()

user = frappe.get_doc("EBICS User", ebics_user)
user.check_permission("write")

Expand All @@ -176,6 +182,8 @@ def download_bank_statements(
to_date: str | None = None,
passphrase: str | None = None,
):
ensure_ebics_is_enabled()

frappe.has_permission("Bank Transaction", "create", throw=True)

user = frappe.get_doc("EBICS User", ebics_user)
Expand All @@ -190,3 +198,19 @@ def download_bank_statements(
intraday=getdate(from_date) == getdate(),
now=frappe.conf.developer_mode,
)


def ensure_ebics_is_enabled():
if not frappe.db.get_single_value("Banking Settings", "enabled"):
frappe.throw(
_("Please activate the checkbox 'Enabled' in the {0}.").format(
get_link_to_form("Banking Settings", "Banking Settings")
)
)

if not frappe.db.get_single_value("Banking Settings", "enable_ebics"):
frappe.throw(
_("Please activate the checkbox 'Enable EBICS' in the {0}.").format(
get_link_to_form("Banking Settings", "Banking Settings")
)
)

0 comments on commit 9d2e5a8

Please sign in to comment.