Pass only category Id as categories are not to be created on the fly

This commit is contained in:
2022-02-25 21:21:55 +00:00
parent 75b48be20d
commit 2d37ec147c
3 changed files with 9 additions and 15 deletions

View File

@ -19,15 +19,12 @@ type NewTransactionPayload struct {
Name string
IsAccount bool
} `json:"payee"`
Category struct {
ID uuid.NullUUID
Name string
} `json:"category"`
Memo string `json:"memo"`
Amount string `json:"amount"`
BudgetID uuid.UUID `json:"budgetId"`
AccountID uuid.UUID `json:"accountId"`
State string `json:"state"`
CategoryID uuid.NullUUID `json:"categoryId"`
Memo string `json:"memo"`
Amount string `json:"amount"`
BudgetID uuid.UUID `json:"budgetId"`
AccountID uuid.UUID `json:"accountId"`
State string `json:"state"`
}
func (h *Handler) newTransaction(c *gin.Context) {
@ -72,7 +69,7 @@ func (h *Handler) newTransaction(c *gin.Context) {
newTransaction.PayeeID = payeeID
}
newTransaction.CategoryID = payload.Category.ID
newTransaction.CategoryID = payload.CategoryID
newTransaction.AccountID = payload.AccountID
transaction, err := h.Service.CreateTransaction(c.Request.Context(), newTransaction)
if err != nil {