From e433181494e1145ba99a85da1896ca771b80ff20 Mon Sep 17 00:00:00 2001 From: "Riley L." Date: Tue, 29 Jul 2025 23:39:51 +0200 Subject: add warning at low balances --- abrechenbarkeit.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'abrechenbarkeit.lua') diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index cb9f30e..29de0ef 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -431,6 +431,19 @@ local function r_transaction_post() return error_box("{+error.open_log}") end local time = os.time() + + -- check if new balance would be less than ;min + local bal = balances()[user_dst] + if amount < 0 and (( bal + amount ) <= (tonumber(config.balance_min) or -99999)) then + return format([[ +

{+user.form.transaction.funds}

+ ]], { + balance = format_amount(bal, "span", ""), + threshold = format_amount(tonumber(config.balance_min), "span", ""), + }) + end + + -- add transaction log:write(string.format("%d,%s,%s,%d,%s,%s,%s\n", time, user_src, user_dst, amount, pcode and (pcode .. (pname and " (" .. pname .. ")" or "")) or (pname or ""), @@ -438,6 +451,7 @@ local function r_transaction_post() comment)) log:flush() log:close() + return format([[

{+user.form.transaction.success}: {amount} ({!comment})

@@ -464,6 +478,12 @@ local function r_user(username) local new_user = balance == nil balance = balance or 0 if notif then print(notif) end + if not is_special and balance <= (tonumber(config.balance_warning) or -99999) then + print(format([[

{+user.balance.warning}

]], { + threshold = format_amount(tonumber(config["balance_warning"]), "span", ""), + threshold2 = format_amount(tonumber(config["balance_min"]), "span", ""), + })) + end if is_special then print(format([[

{+user.special}

]])) end -- cgit v1.2.3-70-g09d2