Introduce own Numeric type and revert to stdlib from pgx
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type AccountData struct {
|
||||
Accounts []postgres.GetAccountsRow
|
||||
Accounts []postgres.GetAccountsWithBalanceRow
|
||||
}
|
||||
|
||||
func (h *Handler) accounts(c *gin.Context) {
|
||||
@@ -20,7 +20,7 @@ func (h *Handler) accounts(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
accounts, err := h.Service.DB.GetAccounts(c.Request.Context(), budgetUUID)
|
||||
accounts, err := h.Service.DB.GetAccountsWithBalance(c.Request.Context(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
|
@@ -12,7 +12,6 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgtype"
|
||||
)
|
||||
|
||||
// Handler handles incoming requests
|
||||
@@ -160,7 +159,7 @@ func (h *Handler) newTransaction(c *gin.Context) {
|
||||
new := postgres.CreateTransactionParams{
|
||||
Memo: transactionMemo,
|
||||
Date: transactionDateValue,
|
||||
Amount: pgtype.Numeric{},
|
||||
Amount: postgres.Numeric{},
|
||||
AccountID: transactionAccountID,
|
||||
}
|
||||
_, err = h.Service.DB.CreateTransaction(c.Request.Context(), new)
|
||||
|
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgtype"
|
||||
)
|
||||
|
||||
type YNABImport struct {
|
||||
@@ -115,12 +114,12 @@ func trimLastChar(s string) string {
|
||||
return s[:len(s)-size]
|
||||
}
|
||||
|
||||
func GetAmount(inflow string, outflow string) (pgtype.Numeric, error) {
|
||||
func GetAmount(inflow string, outflow string) (postgres.Numeric, error) {
|
||||
// Remove trailing currency
|
||||
inflow = strings.Replace(trimLastChar(inflow), ",", ".", 1)
|
||||
outflow = strings.Replace(trimLastChar(outflow), ",", ".", 1)
|
||||
|
||||
num := pgtype.Numeric{}
|
||||
num := postgres.Numeric{}
|
||||
err := num.Set(inflow)
|
||||
if err != nil {
|
||||
return num, fmt.Errorf("Could not parse inflow %s: %w", inflow, err)
|
||||
|
Reference in New Issue
Block a user