Introduce own Numeric type and revert to stdlib from pgx

This commit is contained in:
2021-12-02 21:29:44 +00:00
parent 6f8a94ff5d
commit 4646356b2d
16 changed files with 136 additions and 57 deletions

View File

@ -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)