accept normal simple date syntax in posting dates, give an error on bad date syntax here
This commit is contained in:
parent
20e68f23a8
commit
869ff2528a
13
MANUAL.md
13
MANUAL.md
@ -411,13 +411,14 @@ NAME=EXACTVALUE` on the command line.
|
|||||||
### Posting dates
|
### Posting dates
|
||||||
|
|
||||||
You can give individual postings a different date from their parent
|
You can give individual postings a different date from their parent
|
||||||
transaction, by adding posting tag `date:ACTUALDATE`. The effective date
|
transaction, by adding a [posting tag]("tags") like `date:DATE` where
|
||||||
can be set similarly: `date2:EFFECTIVEDATE`. If present, these dates will
|
DATE is a [simple date](#simple-dates). The effective date can be set
|
||||||
take precedence in register and balance reports.
|
with `date2:DATE`. If present, these dates will take precedence in
|
||||||
|
reports.
|
||||||
|
|
||||||
For compatibility, ledger's posting date syntax is also supported
|
Ledger's posting date syntax is also supported (`[ACTUALDATE]`,
|
||||||
(`[ACTUALDATE]`, `[ACTUALDATE=EFFECTIVEDATE]` or `[=EFFECTIVEDATE]` in a
|
`[ACTUALDATE=EFFECTIVEDATE]` or `[=EFFECTIVEDATE]` in a posting comment)
|
||||||
posting comment) and treated as an alterate spelling of the date tags.
|
and treated as an alternate spelling of the date tags.
|
||||||
|
|
||||||
### Including other files
|
### Including other files
|
||||||
|
|
||||||
|
|||||||
@ -511,11 +511,13 @@ postingp = do
|
|||||||
_ <- balanceassertion
|
_ <- balanceassertion
|
||||||
_ <- fixedlotprice
|
_ <- fixedlotprice
|
||||||
many spacenonewline
|
many spacenonewline
|
||||||
|
ctx <- getState
|
||||||
comment <- try followingcomment <|> (newline >> return "")
|
comment <- try followingcomment <|> (newline >> return "")
|
||||||
let tags = tagsInComment comment
|
let tags = tagsInComment comment
|
||||||
date = dateFromTags tags
|
-- oh boy
|
||||||
date2 = date2FromTags tags
|
d <- maybe (return Nothing) (either (fail.show) (return.Just)) (parseWithCtx ctx date `fmap` dateValueFromTags tags)
|
||||||
return posting{pdate=date, pdate2=date2, pstatus=status, paccount=account', pamount=amount, pcomment=comment, ptype=ptype, ptags=tags}
|
d2 <- maybe (return Nothing) (either (fail.show) (return.Just)) (parseWithCtx ctx date `fmap` date2ValueFromTags tags)
|
||||||
|
return posting{pdate=d, pdate2=d2, pstatus=status, paccount=account', pamount=amount, pcomment=comment, ptype=ptype, ptags=tags}
|
||||||
|
|
||||||
#ifdef TESTS
|
#ifdef TESTS
|
||||||
test_postingp = do
|
test_postingp = do
|
||||||
@ -886,11 +888,9 @@ test_ledgerDateSyntaxToTags = do
|
|||||||
assertEqual "date2:2012/11/28, " $ ledgerDateSyntaxToTags "[=2012/11/28]"
|
assertEqual "date2:2012/11/28, " $ ledgerDateSyntaxToTags "[=2012/11/28]"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dateFromTags :: [Tag] -> Maybe Day
|
dateValueFromTags, date2ValueFromTags :: [Tag] -> Maybe String
|
||||||
dateFromTags = maybe Nothing parsedateM . fmap snd . find ((=="date").fst)
|
dateValueFromTags ts = maybe Nothing (Just . snd) $ find ((=="date") . fst) ts
|
||||||
|
date2ValueFromTags ts = maybe Nothing (Just . snd) $ find ((=="date2") . fst) ts
|
||||||
date2FromTags :: [Tag] -> Maybe Day
|
|
||||||
date2FromTags = maybe Nothing parsedateM . fmap snd . find ((=="date2").fst)
|
|
||||||
|
|
||||||
|
|
||||||
{- old hunit tests
|
{- old hunit tests
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user