From bef3d7aacedada6f4b32b32ee540701ea96db67d Mon Sep 17 00:00:00 2001 From: Davse Bamse Date: Wed, 27 May 2020 21:11:02 +0200 Subject: [PATCH 1/2] Added inital status stuff - not testet --- drinkomatic.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drinkomatic.lua b/drinkomatic.lua index 0f7c561..c256b75 100755 --- a/drinkomatic.lua +++ b/drinkomatic.lua @@ -53,6 +53,8 @@ local function main_menu() print " 2 | Update or create new product." print " /

| Check price for the product

." print " . | Print this menu." + print " 3 | Show account numbers for last year" + print " 4 | Show account numbers for current year" print "-------------------------------------------" local r = assert(db:fetchone( @@ -152,6 +154,12 @@ MAIN = { print(" Scan barcode (or /, or press enter to abort):") return 'PROD_CODE' end, + ['3'] = function() + return 'LAST_YEAR' + end, + ['4'] = function() + return 'CURRENT_YEAR' + end, ['.'] = function() main_menu() return 'MAIN' @@ -634,6 +642,19 @@ TRANSFER_LIST = { end, }, } +LAST_YEAR = { + local r = assert(db:fetchone( + 'select sum(amount*count) from full_log where dt<("'..math.floor(os.date("%Y")-1)..'-12-31 23:59:59") and dt > ("'..math.floor(os.date("%Y")-1)..'-01-01 00:00:00")')) + print(" Last year: %16.2f DKK", r[1]) + return 'MAIN' +} + +CURRENT_YEAR = { + local r = assert(db:fetchone( + 'select sum(amount*count) from full_log where dt>("'..math.floor(os.date("%Y")-1)..'-12-31 23:59:59")')) + print(" Current year: %16.2f DKK", r[1]) + return 'MAIN' +} TRANSFER_AMOUNT = { wait = timeout, From 52190ca8bd22f1901f6de21baf3e7b6f6e8a8148 Mon Sep 17 00:00:00 2001 From: Davse Bamse Date: Wed, 27 May 2020 21:31:20 +0200 Subject: [PATCH 2/2] Now semi-testet --- drinkomatic.lua | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/drinkomatic.lua b/drinkomatic.lua index c256b75..bf1a3b5 100755 --- a/drinkomatic.lua +++ b/drinkomatic.lua @@ -642,18 +642,35 @@ TRANSFER_LIST = { end, }, } + LAST_YEAR = { - local r = assert(db:fetchone( - 'select sum(amount*count) from full_log where dt<("'..math.floor(os.date("%Y")-1)..'-12-31 23:59:59") and dt > ("'..math.floor(os.date("%Y")-1)..'-01-01 00:00:00")')) - print(" Last year: %16.2f DKK", r[1]) - return 'MAIN' + keyboard = { + [''] = function() + print " Aborted." + return 'MAIN' + end, + function() --default + local r = assert(db:fetchone( + 'select sum(amount*count) from full_log where dt<("'..math.floor(os.date("%Y")-1)..'-12-31 23:59:59") and dt > ("'..math.floor(os.date("%Y")-1)..'-01-01 00:00:00")')) + print(" Last year: %16.2f DKK", r[1]) + return 'MAIN' + end, + }, } CURRENT_YEAR = { - local r = assert(db:fetchone( - 'select sum(amount*count) from full_log where dt>("'..math.floor(os.date("%Y")-1)..'-12-31 23:59:59")')) - print(" Current year: %16.2f DKK", r[1]) - return 'MAIN' + keyboard = { + [''] = function() + print " Aborted." + return 'MAIN' + end, + function() --default + local r = assert(db:fetchone( + 'select sum(amount*count) from full_log where dt>("'..math.floor(os.date("%Y")-1)..'-12-31 23:59:59")')) + print(" Current year: %16.2f DKK", r[1]) + return 'MAIN' + end, + }, } TRANSFER_AMOUNT = {