diff --git a/reports/monthly_expenses.lua b/reports/monthly_expenses.lua index 0640c9c..dfd24f1 100644 --- a/reports/monthly_expenses.lua +++ b/reports/monthly_expenses.lua @@ -27,6 +27,7 @@ function generate() accounts = get_accounts() r = report.new(12) + r:title(year .. " Monthly Expenses") series_map = account_series_map(accounts, r) for month=1,12 do diff --git a/reports_lua.go b/reports_lua.go index 2e11685..e889063 100644 --- a/reports_lua.go +++ b/reports_lua.go @@ -81,6 +81,14 @@ func luaReport__index(L *lua.LState) int { L.Push(L.NewFunction(luaReportLabel)) case "Series", "series": L.Push(L.NewFunction(luaReportSeries)) + case "Title", "title": + L.Push(L.NewFunction(luaReportTitle)) + case "Subtitle", "subtitle": + L.Push(L.NewFunction(luaReportSubtitle)) + case "XAxisLabel", "xaxislabel": + L.Push(L.NewFunction(luaReportXAxis)) + case "YAxisLabel", "yaxislabel": + L.Push(L.NewFunction(luaReportYAxis)) default: L.ArgError(2, "unexpected report attribute: "+field) } @@ -120,6 +128,50 @@ func luaReportSeries(L *lua.LState) int { return 1 } +func luaReportTitle(L *lua.LState) int { + report := luaCheckReport(L, 1) + + if L.GetTop() == 2 { + report.Title = L.CheckString(2) + return 0 + } + L.Push(lua.LString(report.Title)) + return 1 +} + +func luaReportSubtitle(L *lua.LState) int { + report := luaCheckReport(L, 1) + + if L.GetTop() == 2 { + report.Subtitle = L.CheckString(2) + return 0 + } + L.Push(lua.LString(report.Subtitle)) + return 1 +} + +func luaReportXAxis(L *lua.LState) int { + report := luaCheckReport(L, 1) + + if L.GetTop() == 2 { + report.XAxisLabel = L.CheckString(2) + return 0 + } + L.Push(lua.LString(report.XAxisLabel)) + return 1 +} + +func luaReportYAxis(L *lua.LState) int { + report := luaCheckReport(L, 1) + + if L.GetTop() == 2 { + report.YAxisLabel = L.CheckString(2) + return 0 + } + L.Push(lua.LString(report.YAxisLabel)) + return 1 +} + func luaSeries__index(L *lua.LState) int { field := L.CheckString(2)