timedot: a D default commodity (and style) is applied to timedot aounts

This means they can be priced and converted.
This commit is contained in:
Simon Michael 2021-11-05 23:34:46 -10:00
parent f00e5c25ec
commit 41bde20095

View File

@ -171,21 +171,26 @@ entryp = do
lift $ optional $ choice [orgheadingprefixp, skipNonNewlineSpaces1]
a <- modifiedaccountnamep
lift skipNonNewlineSpaces
hours <-
hrs <-
try (lift followingcommentp >> return 0)
<|> (durationp <*
(try (lift followingcommentp) <|> (newline >> return "")))
let t = nulltransaction{
tsourcepos = (pos, pos),
tstatus = Cleared,
tpostings = [
nullposting{paccount=a
,pamount=mixedAmount . amountSetPrecision (Precision 2) $ num hours -- don't assume hours; do set precision to 2
,ptype=VirtualPosting
,ptransaction=Just t
}
]
}
mcs <- getDefaultCommodityAndStyle
let
(c,s) = case mcs of
Just (defc,defs) -> (defc, defs{asprecision=max (asprecision defs) (Precision 2)})
_ -> ("", amountstyle{asprecision=Precision 2})
t = nulltransaction{
tsourcepos = (pos, pos),
tstatus = Cleared,
tpostings = [
nullposting{paccount=a
,pamount=mixedAmount $ nullamt{acommodity=c, aquantity=hrs, astyle=s}
,ptype=VirtualPosting
,ptransaction=Just t
}
]
}
lift $ traceparse' "entryp"
return t