1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-07-03 04:38:38 -04:00

Add more sample reports

Also switch tabs to spaces in existing sample reports
This commit is contained in:
2017-07-13 21:38:30 -04:00
parent f213e1061c
commit 8f884f7a69
7 changed files with 314 additions and 91 deletions

View File

@ -1,47 +1,47 @@
function account_series_map(accounts, tabulation)
map = {}
map = {}
for i=1,100 do -- we're not messing with accounts more than 100 levels deep
all_handled = true
for id, acct in pairs(accounts) do
if not map[id] then
all_handled = false
if not acct.parent then
map[id] = tabulation:series(acct.name)
elseif map[acct.parent.accountid] then
map[id] = map[acct.parent.accountid]:series(acct.name)
end
end
end
if all_handled then
return map
end
end
for i=1,100 do -- we're not messing with accounts more than 100 levels deep
all_handled = true
for id, acct in pairs(accounts) do
if not map[id] then
all_handled = false
if not acct.parent then
map[id] = tabulation:series(acct.name)
elseif map[acct.parent.accountid] then
map[id] = map[acct.parent.accountid]:series(acct.name)
end
end
end
if all_handled then
return map
end
end
error("Accounts nested (at least) 100 levels deep")
error("Accounts nested (at least) 100 levels deep")
end
function generate()
year = date.now().year
account_type = account.Income
year = date.now().year
account_type = account.Income
accounts = get_accounts()
t = tabulation.new(1)
t:title(year .. " Income")
series_map = account_series_map(accounts, t)
accounts = get_accounts()
t = tabulation.new(1)
t:title(year .. " Income")
series_map = account_series_map(accounts, t)
begin_date = date.new(year, 1, 1)
end_date = date.new(year+1, 1, 1)
begin_date = date.new(year, 1, 1)
end_date = date.new(year+1, 1, 1)
t:label(1, year .. " Income")
t:label(1, year .. " Income")
for id, acct in pairs(accounts) do
series = series_map[id]
if acct.type == account_type then
balance = acct:balance(begin_date, end_date)
series:value(1, balance.amount)
end
end
for id, acct in pairs(accounts) do
series = series_map[id]
if acct.type == account_type then
balance = acct:balance(begin_date, end_date)
series:value(1, balance.amount)
end
end
return t
return t
end