diff --git a/http/ynab-import.go b/http/ynab-import.go index f710922..9d9cbb4 100644 --- a/http/ynab-import.go +++ b/http/ynab-import.go @@ -116,7 +116,7 @@ func trimLastChar(s string) string { } func GetAmount(inflow string, outflow string) (pgtype.Numeric, error) { - // Remove currency + // Remove trailing currency inflow = strings.Replace(trimLastChar(inflow), ",", ".", 1) outflow = strings.Replace(trimLastChar(outflow), ",", ".", 1) @@ -126,6 +126,7 @@ func GetAmount(inflow string, outflow string) (pgtype.Numeric, error) { return num, fmt.Errorf("Could not parse inflow %s: %w", inflow, err) } + // if inflow is zero, use outflow if num.Int.Int64() != 0 { return num, nil } diff --git a/postgres/conn.go b/postgres/conn.go index 8f38c69..ecc2196 100644 --- a/postgres/conn.go +++ b/postgres/conn.go @@ -44,11 +44,6 @@ func (tx Transaction) GetAmount() float64 { return amount } -func (tx Transaction) GetAmountString() string { - amount := tx.GetAmount() - return fmt.Sprintf("%.2f", amount) -} - func (tx Transaction) GetPositive() bool { amount := tx.GetAmount() return amount >= 0 diff --git a/web/budget.html b/web/budget.html index fe9ea2d..e2205d6 100644 --- a/web/budget.html +++ b/web/budget.html @@ -19,7 +19,9 @@