diff options
author | Riley L. <riley@e926.de> | 2025-07-29 23:39:51 +0200 |
---|---|---|
committer | Riley L. <riley@e926.de> | 2025-07-29 23:39:51 +0200 |
commit | e433181494e1145ba99a85da1896ca771b80ff20 (patch) | |
tree | 1e039774b047ad8e41e5adb3d8c9357a728927ea /abrechenbarkeit.lua | |
parent | f3562cf44ec056281488ccadb78d87f86dbcfce5 (diff) | |
download | abrechenbarkeit-e433181494e1145ba99a85da1896ca771b80ff20.tar abrechenbarkeit-e433181494e1145ba99a85da1896ca771b80ff20.tar.bz2 abrechenbarkeit-e433181494e1145ba99a85da1896ca771b80ff20.tar.zst |
add warning at low balances
Diffstat (limited to 'abrechenbarkeit.lua')
-rwxr-xr-x | abrechenbarkeit.lua | 20 |
1 files changed, 20 insertions, 0 deletions
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([[ + <div class="notif error"><p>{+user.form.transaction.funds}</p></div> + ]], { + 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([[ <div class="notif"><p>{+user.form.transaction.success}: {amount} ({!comment})</p></div> <audio src="{sound}" autoplay></audio> @@ -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([[<div class="notif warning"><p><i>{+user.balance.warning}</i></p></div>]], { + threshold = format_amount(tonumber(config["balance_warning"]), "span", ""), + threshold2 = format_amount(tonumber(config["balance_min"]), "span", ""), + })) + end if is_special then print(format([[<div class="notif"><p><i>{+user.special}</i></p></div>]])) end |