quentinsf / icsv2ledger

Interactive importing of CSV files to Ledger
196 stars 70 forks source link

Credit/debit columns using $0.00 instead of blank creates unbalanced transaction #74

Closed wrycta closed 9 years ago

wrycta commented 9 years ago

My bank exports csv files with credit/debit columns, and the unused column contains 0.00, rather than being blank. An example file:

Bank Account,Date,Narrative,Debit Amount,Credit Amount,Categories,Serial                                                                                         
123456789,01/03/2015,"WITHDRAWAL BY PAYMENT SHOP1", 19.39 , 0.00,POS,                                                                                            
123456789,01/03/2015,"WITHDRAWAL BY PAYMENT SHOP2", 23.60 , 0.00,POS,                                                                                            
123456789,01/03/2015,"WITHDRAWAL BY PAYMENT SHOP3", 17.48 , 0.00,POS,                                                                                            
123456789,01/03/2015,"DEPOSIT", 0.00 , 100.00,CASH,

This results in an output ledger file with unbalanced transactions, as the 0.00 is transferred straight onto one of the accounts in the ledger transaction:

2015/03/01 * Shop 1
    Expenses:Buying Stuff                                           AUD 19.39
    Assets:Bank                                      AUD 0.00

2015/03/01 * Shop 2
    Expenses:Buying Stuff                                           AUD 23.60
    Assets:Bank                                      AUD 0.00

2015/03/01 * Shop 3
    Expenses:Buying Stuff                                           AUD 17.48
    Assets:Bank                                      AUD 0.00

2015/03/01 * Deposit to account
    Assets:Cash In Wallet                                           AUD 0.00
    Assets:Bank                                      AUD 100.00

This causes ledger to complain the transactions are unbalanced:

While parsing file "bugfix.ledger", line 17: 
While balancing transaction from "bugfix.ledger", lines 13-17:
> 2015/03/01 * Shop 3
>     Expenses:Buying Stuff                                           AUD 17.48
>     Assets:Bank                                      AUD 0.00
Unbalanced remainder is:
           AUD 17.48
Amount to balance against:
           AUD 17.48
Error: Transaction does not balance
While parsing file "bugfix.ledger", line 23: 
While balancing transaction from "bugfix.ledger", lines 19-23:
> 2015/03/01 * Deposit to account
>     Assets:Cash In Wallet                                           AUD 0.00
>     Assets:Bank                                      AUD 100.00
Unbalanced remainder is:
          AUD 100.00
Amount to balance against:
          AUD 100.00
Error: Transaction does not balance 

This doesn't seem to happen if the csv file leaves the unused column blank for each transaction.