Implement categories for new transactions

This commit is contained in:
2021-12-14 14:41:10 +00:00
parent 1ab1fa74e0
commit d0ad0dcb3a
5 changed files with 70 additions and 12 deletions

View File

@ -11,10 +11,13 @@ import (
type AccountData struct {
AlwaysNeededData
Account *postgres.Account
Categories []postgres.GetCategoriesRow
Transactions []postgres.GetTransactionsForAccountRow
}
func (h *Handler) account(c *gin.Context) {
data := c.MustGet("data").(AlwaysNeededData)
accountID := c.Param("accountid")
accountUUID, err := uuid.Parse(accountID)
if err != nil {
@ -28,6 +31,12 @@ func (h *Handler) account(c *gin.Context) {
return
}
categories, err := h.Service.GetCategories(c.Request.Context(), data.Budget.ID)
if err != nil {
c.AbortWithError(http.StatusNotFound, err)
return
}
transactions, err := h.Service.GetTransactionsForAccount(c.Request.Context(), accountUUID)
if err != nil {
c.AbortWithError(http.StatusNotFound, err)
@ -35,8 +44,9 @@ func (h *Handler) account(c *gin.Context) {
}
d := AccountData{
c.MustGet("data").(AlwaysNeededData),
data,
&account,
categories,
transactions,
}