From 067407c4eb9c555a77705e51e1ef3633cd1172ff Mon Sep 17 00:00:00 2001 From: silasb Date: Wed, 7 Sep 2016 21:04:25 -0400 Subject: [PATCH] Skipping all comment lines --- parse.go | 2 +- parse_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/parse.go b/parse.go index 30cebf8a..6a6110c4 100644 --- a/parse.go +++ b/parse.go @@ -32,7 +32,7 @@ func ParseLedger(ledgerReader io.Reader) (generalLedger []*Transaction, err erro // remove heading and tailing space from the line trimmedLine := strings.Trim(line, whitespace) lineCount++ - if strings.HasPrefix(line, ";") { + if strings.HasPrefix(trimmedLine, ";") { // nop } else if len(trimmedLine) == 0 { if trans != nil { diff --git a/parse_test.go b/parse_test.go index 04980476..52635e00 100644 --- a/parse_test.go +++ b/parse_test.go @@ -100,6 +100,30 @@ var testCases = []testCase{ `1970-01-01 Payee Expense/test 123 Assets +`, + []*Transaction{ + &Transaction{ + Payee: "Payee", + Date: time.Unix(0, 0).UTC(), + AccountChanges: []Account{ + Account{ + "Expense/test", + big.NewRat(123.0, 1), + }, + Account{ + "Assets", + big.NewRat(-123.0, 1), + }, + }, + }, + }, + nil, + }, + testCase{ + `1970-01-01 Payee + Expense/test 123 + ; Expense/test 123 + Assets `, []*Transaction{ &Transaction{