From b69d765053fe11b972ee46024387cc90f4370ae4 Mon Sep 17 00:00:00 2001 From: Chris Howey Date: Mon, 7 Mar 2022 13:43:31 -0600 Subject: [PATCH] fix(import): set amount to zero when error on parsing csv amount --- ledger/cmd/import.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ledger/cmd/import.go b/ledger/cmd/import.go index 6915dc71..2bbd4583 100644 --- a/ledger/cmd/import.go +++ b/ledger/cmd/import.go @@ -124,8 +124,12 @@ var importCmd = &cobra.Command{ expenseAccount.Name = string(classifier.Classes[likely]) } + // Parse error, set to zero + if _, bset := expenseAccount.Balance.SetString(record[amountColumn]); !bset { + expenseAccount.Balance.SetFloat64(0) + } + // Negate amount if required - expenseAccount.Balance.SetString(record[amountColumn]) if negateAmount { expenseAccount.Balance.Neg(expenseAccount.Balance) }