Use type instead of isAccount flag
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -15,9 +15,9 @@ import (
|
||||
type NewTransactionPayload struct {
|
||||
Date JSONDate `json:"date"`
|
||||
Payee struct {
|
||||
ID uuid.NullUUID
|
||||
Name string
|
||||
IsAccount bool
|
||||
ID uuid.NullUUID
|
||||
Name string
|
||||
Type string
|
||||
} `json:"payee"`
|
||||
CategoryID uuid.NullUUID `json:"categoryId"`
|
||||
Memo string `json:"memo"`
|
||||
@ -56,7 +56,7 @@ func (h *Handler) newTransaction(c *gin.Context) {
|
||||
AccountID: payload.AccountID,
|
||||
}
|
||||
|
||||
if payload.Payee.IsAccount {
|
||||
if payload.Payee.Type == "account" {
|
||||
err := h.CreateTransferForOtherAccount(newTransaction, amount, payload, c)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
@ -103,7 +103,10 @@ func (h *Handler) CreateTransferForOtherAccount(newTransaction postgres.CreateTr
|
||||
newTransaction.CategoryID = uuid.NullUUID{}
|
||||
|
||||
_, err := h.Service.CreateTransaction(c.Request.Context(), newTransaction)
|
||||
return fmt.Errorf("create transfer transaction: %w", err)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create transfer transaction: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetPayeeID(context context.Context, payload NewTransactionPayload, h *Handler) (uuid.NullUUID, error) {
|
||||
|
Reference in New Issue
Block a user