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

This commit is contained in:
Jan Bader 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 {

View File

@ -16,7 +16,7 @@ const payload = computed(() => JSON.stringify({
Name: Transaction.Payee,
ID: Transaction.PayeeID,
},
category: Transaction.CategoryID,
categoryId: Transaction.CategoryID,
memo: Transaction.Memo,
amount: Transaction.Amount,
state: "Uncleared"

View File

@ -31,10 +31,7 @@ const payload = computed(() => JSON.stringify({
Name: TX.value.Payee,
ID: TX.value.PayeeID,
},
category: {
Name: TX.value.Category,
ID: TX.value.CategoryID,
},
categoryId: TX.value.CategoryID,
memo: TX.value.Memo,
amount: TX.value.Amount,
state: "Uncleared"