Skip to content

Commit

Permalink
Merge pull request #8 from silasb/skip-all-comment-lines
Browse files Browse the repository at this point in the history
Skipping all comment lines
  • Loading branch information
howeyc authored Sep 8, 2016
2 parents 51d34dd + 067407c commit 15a737d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 24 additions & 0 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 15a737d

Please sign in to comment.