Implement problematic transactions endpoint
This commit is contained in:
parent
24fa12dfb3
commit
10d3f445a1
@ -8,6 +8,23 @@ import (
|
|||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (h *Handler) problematicTransactions(c *gin.Context) {
|
||||||
|
budgetID := c.Param("budgetid")
|
||||||
|
budgetUUID, err := uuid.Parse(budgetID)
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions, err := h.Service.GetProblematicTransactions(c.Request.Context(), budgetUUID)
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, TransactionsResponse{nil, transactions})
|
||||||
|
}
|
||||||
|
|
||||||
func (h *Handler) transactionsForAccount(c *gin.Context) {
|
func (h *Handler) transactionsForAccount(c *gin.Context) {
|
||||||
accountID := c.Param("accountid")
|
accountID := c.Param("accountid")
|
||||||
accountUUID, err := uuid.Parse(accountID)
|
accountUUID, err := uuid.Parse(accountID)
|
||||||
@ -28,11 +45,11 @@ func (h *Handler) transactionsForAccount(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, TransactionsResponse{account, transactions})
|
c.JSON(http.StatusOK, TransactionsResponse{&account, transactions})
|
||||||
}
|
}
|
||||||
|
|
||||||
type TransactionsResponse struct {
|
type TransactionsResponse struct {
|
||||||
Account postgres.Account
|
Account *postgres.Account
|
||||||
Transactions []postgres.DisplayTransaction
|
Transactions []postgres.DisplayTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ func (h *Handler) LoadRoutes(router *gin.Engine) {
|
|||||||
budget.POST("/:budgetid/category/:categoryid/:year/:month", h.setCategoryAssignment)
|
budget.POST("/:budgetid/category/:categoryid/:year/:month", h.setCategoryAssignment)
|
||||||
budget.GET("/:budgetid/autocomplete/payees", h.autocompletePayee)
|
budget.GET("/:budgetid/autocomplete/payees", h.autocompletePayee)
|
||||||
budget.GET("/:budgetid/autocomplete/categories", h.autocompleteCategories)
|
budget.GET("/:budgetid/autocomplete/categories", h.autocompleteCategories)
|
||||||
|
budget.GET("/:budgetid/problematic-transactions", h.problematicTransactions)
|
||||||
budget.DELETE("/:budgetid", h.deleteBudget)
|
budget.DELETE("/:budgetid", h.deleteBudget)
|
||||||
budget.POST("/:budgetid/import/ynab", h.importYNAB)
|
budget.POST("/:budgetid/import/ynab", h.importYNAB)
|
||||||
budget.POST("/:budgetid/export/ynab/transactions", h.exportYNABTransactions)
|
budget.POST("/:budgetid/export/ynab/transactions", h.exportYNABTransactions)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user