From edbd93c2c4bd5a01b369b044e9fb4e44fac9e798 Mon Sep 17 00:00:00 2001 From: "Riley L." Date: Mon, 19 Jan 2026 20:46:01 +0100 Subject: add max_amount config field and functionality --- abrechenbarkeit.lua | 7 +++++++ locale/de.ini | 1 + locale/en.ini | 1 + readme.md | 1 + 4 files changed, 10 insertions(+) diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index 5421d5a..2496a1b 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -385,6 +385,13 @@ local function r_transaction_post() local pcount = tonumber(data.pcount) local comment = data.comment local pname = data.pname + local max_amount = tonumber(config["max_amount"]) or 9999999999999 + + if math.abs(amount) > max_amount then + return error_box(format("{+error.invalid_amount} - {+max_amount}", { + amount = format_amount(math.abs(max_amount)), + })) + end if pname ~= nil or (pcode ~= nil and pcode ~= "") then -- check if barcode exists diff --git a/locale/de.ini b/locale/de.ini index c02c413..81b1221 100644 --- a/locale/de.ini +++ b/locale/de.ini @@ -81,3 +81,4 @@ error.unknown_barcode = Unbekannter Barcode error.open_new_barcodes = Öffnen der neuen Barcodes-Datei fehlgeschlagen error.open_barcodes = Öffnen der Barcodes-Datei fehlgeschlagen print = Drucken +max_amount = der maximale Betrag beträgt {amount} diff --git a/locale/en.ini b/locale/en.ini index 33f1516..00507af 100644 --- a/locale/en.ini +++ b/locale/en.ini @@ -82,3 +82,4 @@ users.embezzlement=A total of {amount} are currently under embezzlement. users.filter=Filter users.inactive_list=Inactive Users users=Users +max_amount=maximum amount for a single transaction is {amount} diff --git a/readme.md b/readme.md index 020f2fe..93824f1 100644 --- a/readme.md +++ b/readme.md @@ -22,6 +22,7 @@ useful for development or proxyless deployments. - `unit`: unit used in the UI, e.g. €, $, EUR - `disable_balances`: disables showing user balances on `/`, they are still shown for SPUs, and on `/?users[&negative]` etc. - `disabled_balance_replacement`: only effective when `disable_balances` is set, text printed instead of balance, by default none at all; e.g. `(hidden)` + - `max_amount`: maximum transaction worth in cents (intended to stop accidental adding of EAN cents to balances; therefore default is "9"*12, the largest 12 digit number) ## Migration from Strichliste -- cgit v1.3