mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-26 20:02:27 +03:00
parsing: ignore cleared flags at the start of postings, parse account name correctly
This commit is contained in:
parent
27a0900ea9
commit
d7617fe154
@ -932,6 +932,10 @@ need to make small edits to restore compatibility for one or the other.
|
||||
hledger does not allow separate dates for individual postings, unlike c++
|
||||
ledger.
|
||||
|
||||
Likewise, hledger does not support per-posting cleared status. It does
|
||||
ignore a cleared flag (`*`) at the start of a posting, so that the account
|
||||
name is parsed correctly.
|
||||
|
||||
#### Features not supported
|
||||
|
||||
c++ ledger features not currently supported include: modifier and periodic
|
||||
|
@ -388,7 +388,7 @@ ledgereffectivedate actualdate = do
|
||||
return edate
|
||||
|
||||
ledgerstatus :: GenParser Char JournalContext Bool
|
||||
ledgerstatus = try (do { many1 spacenonewline; char '*' <?> "status"; return True } ) <|> return False
|
||||
ledgerstatus = try (do { many spacenonewline; char '*' <?> "status"; return True } ) <|> return False
|
||||
|
||||
ledgercode :: GenParser Char JournalContext String
|
||||
ledgercode = try (do { many1 spacenonewline; char '(' <?> "code"; code <- anyChar `manyTill` char ')'; return code } ) <|> return ""
|
||||
@ -442,6 +442,7 @@ ledgerposting :: GenParser Char JournalContext Posting
|
||||
ledgerposting = do
|
||||
many1 spacenonewline
|
||||
status <- ledgerstatus
|
||||
many spacenonewline
|
||||
account <- transactionaccountname
|
||||
let (ptype, account') = (postingTypeFromAccountName account, unbracket account)
|
||||
amount <- postingamount
|
||||
|
55
tests/cleared-marker.test
Normal file
55
tests/cleared-marker.test
Normal file
@ -0,0 +1,55 @@
|
||||
# report cleared transactions only
|
||||
#
|
||||
bin/hledger -f- print --cleared
|
||||
<<<
|
||||
2010/1/1 x
|
||||
a 1
|
||||
b
|
||||
|
||||
2010/1/2 * x
|
||||
a 1
|
||||
b
|
||||
|
||||
2010/1/3 *
|
||||
a 1
|
||||
b
|
||||
>>>
|
||||
2010/01/02 * x
|
||||
a 1
|
||||
b -1
|
||||
|
||||
2010/01/03 *
|
||||
a 1
|
||||
b -1
|
||||
|
||||
# report uncleared transactions only
|
||||
bin/hledger -f- print --uncleared
|
||||
<<<
|
||||
2010/1/1 x
|
||||
a 1
|
||||
b
|
||||
|
||||
2010/1/2 * x
|
||||
a 1
|
||||
b
|
||||
|
||||
2010/1/3 *
|
||||
a 1
|
||||
b
|
||||
>>>
|
||||
2010/01/01 x
|
||||
a 1
|
||||
b -1
|
||||
|
||||
# we don't yet support cleared postings, except we should ignore the marker when parsing them
|
||||
bin/hledger -f- balance --no-total
|
||||
<<<
|
||||
2010/1/1
|
||||
a 1
|
||||
*a 2
|
||||
* a 4
|
||||
b
|
||||
|
||||
>>>
|
||||
7 a
|
||||
-7 b
|
Loading…
Reference in New Issue
Block a user