Implement EditAccount in Backend

This commit is contained in:
2022-02-24 22:12:10 +00:00
parent 03d1d1e520
commit f51807e459
5 changed files with 79 additions and 5 deletions

View File

@@ -132,6 +132,11 @@ func (*Handler) getAvailableBalance(categories []postgres.GetCategoriesRow, budg
return availableBalance
}
type BudgetingResponse struct {
Accounts []postgres.GetAccountsWithBalanceRow
Budget postgres.Budget
}
func (h *Handler) budgeting(c *gin.Context) {
budgetID := c.Param("budgetid")
budgetUUID, err := uuid.Parse(budgetID)
@@ -140,6 +145,10 @@ func (h *Handler) budgeting(c *gin.Context) {
return
}
h.returnBudgetingData(c, budgetUUID)
}
func (h *Handler) returnBudgetingData(c *gin.Context, budgetUUID uuid.UUID) {
budget, err := h.Service.GetBudget(c.Request.Context(), budgetUUID)
if err != nil {
c.AbortWithError(http.StatusNotFound, err)
@@ -152,10 +161,7 @@ func (h *Handler) budgeting(c *gin.Context) {
return
}
data := struct {
Accounts []postgres.GetAccountsWithBalanceRow
Budget postgres.Budget
}{accounts, budget}
data := BudgetingResponse{accounts, budget}
c.JSON(http.StatusOK, data)
}