diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index e210fed..5de3456 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -127,12 +127,21 @@ local function format(template, params) end local function format_amount(amount, tag, classes) - local s = string.format("%s%.02f%s", amount > 0 and "+" or "", amount / 100, config.unit or "€") + local s = format("{+price.amount}", { + sign = amount > 0 and "{+price.sign.pos}" or "{+price.sign.neg}", + amount = string.format("%.2f", math.abs(amount / 100)), + unit = config.unit or "€" + }) + + -- local s = string.format("%s%.02f%s", amount > 0 and "+" or "", amount / 100, ) if tag == nil then return s end return format( - [[<{tag} class="amount-{sign} {classes}">{content}]], - { tag = tag, sign = amount >= 0 and "pos" or "neg", classes = classes or "", content = s } - ) + [[<{tag} class="amount-{sign} {classes}">{content}]], { + tag = tag, + sign = amount >= 0 and "pos" or "neg", + classes = classes or "", + content = s + }) end local function get_user_theme(username) @@ -483,7 +492,7 @@ local function r_log(filter) - + @@ -496,8 +505,12 @@ local function r_log(filter) user_dst_url = urlencode(user_dst), amount = format_amount(amount, "td"), pcode = escape(pcode), - pcount = (pcount and (pcount < 0 and "buy " or "stock ") or "") .. - (pcount and tostring(math.abs(pcount)) or ""), + pcount = (pcount + and (pcount < 0 + and "{+log.count.purchase}" + or "{+log.count.stock}" + ) or ""), + n = (pcount and tostring(math.abs(pcount)) or ""), comment = escape(comment), revert_amount = -amount, revert_pcount = -(pcount or 0), @@ -595,38 +608,40 @@ local function r_products() notif = r_products_post() end respond(200, "Abrechenbare Product List", function() - print("

Product List

") + print(format("

{+products.title}

")) if notif then print(notif) end - print([[ + print(format([[
-

Add Product

- +

{+products.form.add}

+ - + - + - + - +
-

Remove Product

+

{+products.form.remove}

- + - +
- ]]) - print([[ - - - - - - ]]) + ]], { + currency = config.unit or "€", + })) + print(format([[
NamePriceBarcodeCountUser
+ + + + + + ]])) local pbals = product_balances() for barcode, price, user, name in read_products() do print(format([[
{+products.list.name}{+products.list.price}{+products.list.barcode}{+products.list.count}{+products.list.user}