aboutsummaryrefslogtreecommitdiff
path: root/abrechenbarkeit.lua
diff options
context:
space:
mode:
Diffstat (limited to 'abrechenbarkeit.lua')
-rwxr-xr-xabrechenbarkeit.lua20
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