From 3d8bae0b7ba69b7805dcb260c653b3be609e43c4 Mon Sep 17 00:00:00 2001 From: Tyler Matteson Date: Wed, 25 Jun 2025 16:15:34 -0400 Subject: [PATCH] feat: add jinja method for amount --- suppliers_portal/hooks.py | 6 ++++++ suppliers_portal/overrides/print.py | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 suppliers_portal/overrides/print.py diff --git a/suppliers_portal/hooks.py b/suppliers_portal/hooks.py index 93d4742..d595689 100644 --- a/suppliers_portal/hooks.py +++ b/suppliers_portal/hooks.py @@ -248,3 +248,9 @@ website_route_rules = [ ] export_python_type_annotations = True + +jinja = { + "methods": [ + "suppliers_portal.overrides.print.amount_in_words_with_asterisks", + ] +} diff --git a/suppliers_portal/overrides/print.py b/suppliers_portal/overrides/print.py new file mode 100644 index 0000000..7c5260d --- /dev/null +++ b/suppliers_portal/overrides/print.py @@ -0,0 +1,11 @@ +import frappe +from frappe.utils import flt, money_in_words + + +@frappe.whitelist() +def amount_in_words_with_asterisks(amount): + amount = flt(amount) + amount_in_words = money_in_words(amount)[4:-6] + if amount % 1 == 0: + return f"{amount_in_words + ' and Zero Cents ':*<70}" + return f"{amount_in_words + 's ':*<84}" -- 2.50.1