mirror of
				https://github.com/aclindsa/moneygo.git
				synced 2025-11-03 18:13:27 -05:00 
			
		
		
		
	lua: Add title, subtitle, axis labels to reports
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user