Working on the Calculated thing
Did some work towards the lua interface, but its kinda shit tbh
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
lua "github.com/yuin/gopher-lua"
|
||||
)
|
||||
|
||||
func (s *Service) GetAllExpenses() ([]mod.Expense, error) {
|
||||
@@ -21,32 +20,6 @@ func (s *Service) GetAllExpenses() ([]mod.Expense, error) {
|
||||
return expenses, tx.Commit()
|
||||
}
|
||||
|
||||
func (s *Service) LuaGetAllExpenses(L *lua.LState) int {
|
||||
tx, err := s.DB.Begin()
|
||||
if err != nil {
|
||||
L.Push(lua.LNil)
|
||||
L.Push(lua.LString(err.Error()))
|
||||
return 2
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
expenses, err := mod.GetAllExpenses(tx)
|
||||
|
||||
tbl := L.NewTable()
|
||||
for _, e := range expenses {
|
||||
et := L.NewTable()
|
||||
|
||||
et.RawSetString("id", lua.LNumber(e.ExpID))
|
||||
et.RawSetString("description", lua.LString(e.Description))
|
||||
et.RawSetString("amount", lua.LString(e.Value.StringFixed(2)))
|
||||
|
||||
tbl.Append(et)
|
||||
}
|
||||
|
||||
L.Push(tbl)
|
||||
return 1
|
||||
}
|
||||
|
||||
func (s *Service) GetExpensesRanged(startDate string, endDate string) ([]mod.Expense, error) {
|
||||
startDateTime, err := time.ParseInLocation("02-Jan-2006 15:04:05", startDate, time.UTC)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user