Handle new Payees
This commit is contained in:
parent
368ac7f15d
commit
a09511061f
@ -35,8 +35,6 @@ func (h *Handler) newTransaction(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%v\n", payload)
|
|
||||||
|
|
||||||
amount := postgres.Numeric{}
|
amount := postgres.Numeric{}
|
||||||
amount.Set(payload.Amount)
|
amount.Set(payload.Amount)
|
||||||
|
|
||||||
@ -46,13 +44,30 @@ func (h *Handler) newTransaction(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
payeeID := payload.Payee.ID
|
||||||
|
if !payeeID.Valid && payload.Payee.Name != "" {
|
||||||
|
newPayee := postgres.CreatePayeeParams{
|
||||||
|
Name: payload.Payee.Name,
|
||||||
|
BudgetID: payload.BudgetID,
|
||||||
|
}
|
||||||
|
payee, err := h.Service.CreatePayee(c.Request.Context(), newPayee)
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("create payee: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
payeeID = uuid.NullUUID{
|
||||||
|
UUID: payee.ID,
|
||||||
|
Valid: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//if !transactionUUID.Valid {
|
//if !transactionUUID.Valid {
|
||||||
new := postgres.CreateTransactionParams{
|
new := postgres.CreateTransactionParams{
|
||||||
Memo: payload.Memo,
|
Memo: payload.Memo,
|
||||||
Date: time.Time(payload.Date),
|
Date: time.Time(payload.Date),
|
||||||
Amount: amount,
|
Amount: amount,
|
||||||
AccountID: payload.AccountID,
|
AccountID: payload.AccountID,
|
||||||
PayeeID: payload.Payee.ID, //TODO handle new payee
|
PayeeID: payeeID, //TODO handle new payee
|
||||||
CategoryID: payload.Category.ID, //TODO handle new category
|
CategoryID: payload.Category.ID, //TODO handle new category
|
||||||
Status: postgres.TransactionStatus(payload.State),
|
Status: postgres.TransactionStatus(payload.State),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user