Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added inital status stuff - not testet #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions drinkomatic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ local function main_menu()
print " 2 | Update or create new product."
print " /<p>| Check price for the product <p>."
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(
Expand Down Expand Up @@ -152,6 +154,12 @@ MAIN = {
print(" Scan barcode (or /<barcode>, 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'
Expand Down Expand Up @@ -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)
Expand Down