Handle amount in import and display
This commit is contained in:
@ -123,7 +123,16 @@ func GetAmount(inflow string, outflow string) (pgtype.Numeric, error) {
|
||||
num := pgtype.Numeric{}
|
||||
err := num.Set(inflow)
|
||||
if err != nil {
|
||||
return num, fmt.Errorf("Could not inflow %s: %w", inflow, err)
|
||||
return num, fmt.Errorf("Could not parse inflow %s: %w", inflow, err)
|
||||
}
|
||||
|
||||
if num.Int.Int64() != 0 {
|
||||
return num, nil
|
||||
}
|
||||
|
||||
err = num.Set("-" + outflow)
|
||||
if err != nil {
|
||||
return num, fmt.Errorf("Could not parse outflow %s: %w", inflow, err)
|
||||
}
|
||||
return num, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user