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