diff --git a/server/transaction.go b/server/transaction.go
index 072f8ad..05b0595 100644
--- a/server/transaction.go
+++ b/server/transaction.go
@@ -35,8 +35,6 @@ func (h *Handler) newTransaction(c *gin.Context) {
return
}
- fmt.Printf("%v\n", payload)
-
amount := postgres.Numeric{}
err = amount.Set(payload.Amount)
if err != nil {
@@ -44,17 +42,37 @@ func (h *Handler) newTransaction(c *gin.Context) {
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,
+ }
+ }
+
newTransaction := postgres.CreateTransactionParams{
Memo: payload.Memo,
Date: time.Time(payload.Date),
Amount: amount,
AccountID: payload.AccountID,
- PayeeID: payload.Payee.ID,
+ PayeeID: payeeID,
CategoryID: payload.Category.ID,
Status: postgres.TransactionStatus(payload.State),
}
- _, err = h.Service.CreateTransaction(c.Request.Context(), newTransaction)
+ transaction, err := h.Service.CreateTransaction(c.Request.Context(), newTransaction)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("create transaction: %w", err))
+ return
}
+
+ c.JSON(http.StatusOK, transaction)
}
diff --git a/web/src/components/TransactionInputRow.vue b/web/src/components/TransactionInputRow.vue
new file mode 100644
index 0000000..d493689
--- /dev/null
+++ b/web/src/components/TransactionInputRow.vue
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/src/pages/Account.vue b/web/src/pages/Account.vue
index dcc7905..af169bf 100644
--- a/web/src/pages/Account.vue
+++ b/web/src/pages/Account.vue
@@ -1,9 +1,8 @@