diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index 2cf0ba3..be60a18 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -22,6 +22,7 @@ local matchers = { time = "(%d+)", user = "([%w_@ -]+)", + user_opt = "([%w_@ -]*)", amount = "(-?%d+)", amount_opt = "(-?%d*)", comment = "([%w_ -]+)", @@ -50,7 +51,7 @@ end local function urlencode(s) if s == nil then return nil end return s:gsub("[^%w]", - function(cap) return string.format("%02x", string.byte(cap, 1)) end) + function(cap) return string.format("%%%02x", string.byte(cap, 1)) end) end local function parse_query(q) @@ -255,7 +256,7 @@ local function read_products() if l == "" or l == nil then return nil end - local barcode, price, user, name = string.match(l, format("^{barcode},{amount},{user}?,{name}$", matchers)) + local barcode, price, user, name = string.match(l, format("^{barcode},{amount},{user_opt},{name}$", matchers)) return barcode, tonumber(price), user, name end end @@ -326,7 +327,7 @@ local function r_transaction_post() if p_barcode == pcode then pcount = (tonumber(data.pcount) or 1) * (data.negate_pcount ~= nil and -1 or 1) amount = amount or pcount * p_amount - user_dst = user_dst or p_user + user_src = user_src or p_user comment = comment or string.format("%s %d %s", pcount < 0 and "Buy" or "Restock", math.abs(pcount or 0), p_name) exists = true @@ -469,7 +470,7 @@ local function r_log(filter) print(format([[