diff --git a/drinkomatic.lua b/drinkomatic.lua
index 0f7c561..bf1a3b5 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'
@@ -635,6 +643,36 @@ TRANSFER_LIST = {
},
}
+LAST_YEAR = {
+ 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 = {
+ 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 = {
wait = timeout,
timeout = function(_, id)