mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-26 20:02:27 +03:00
timedot: allow a note after the date, use as transaction descriptions
This commit is contained in:
parent
190233b576
commit
26c19c65b0
@ -53,6 +53,7 @@ import Data.Char (isSpace)
|
|||||||
import Data.List (foldl')
|
import Data.List (foldl')
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
|
import qualified Data.Text as T
|
||||||
import Text.Megaparsec hiding (parse)
|
import Text.Megaparsec hiding (parse)
|
||||||
import Text.Megaparsec.Char
|
import Text.Megaparsec.Char
|
||||||
|
|
||||||
@ -115,10 +116,11 @@ timedotdayp :: JournalParser m [Transaction]
|
|||||||
timedotdayp = do
|
timedotdayp = do
|
||||||
traceparse " timedotdayp"
|
traceparse " timedotdayp"
|
||||||
lift $ optional orgheadingprefixp
|
lift $ optional orgheadingprefixp
|
||||||
d <- datep <* lift eolof
|
d <- datep
|
||||||
|
daydesc <- strip <$> lift restofline
|
||||||
es <- catMaybes <$> many (const Nothing <$> try (lift emptyorcommentlinep') <|>
|
es <- catMaybes <$> many (const Nothing <$> try (lift emptyorcommentlinep') <|>
|
||||||
Just <$> (notFollowedBy datep >> timedotentryp))
|
Just <$> (notFollowedBy datep >> timedotentryp))
|
||||||
return $ map (\t -> t{tdate=d}) es -- <$> many timedotentryp
|
return $ map (\t -> t{tdate=d, tdescription=T.pack daydesc}) es -- <$> many timedotentryp
|
||||||
|
|
||||||
-- | Parse a single timedot entry to one (dateless) transaction.
|
-- | Parse a single timedot entry to one (dateless) transaction.
|
||||||
-- @
|
-- @
|
||||||
|
@ -22,11 +22,14 @@ so it could be used to represent dated quantities other than time.
|
|||||||
In the docs below we'll assume it's time.
|
In the docs below we'll assume it's time.
|
||||||
|
|
||||||
A timedot file contains a series of day entries.
|
A timedot file contains a series of day entries.
|
||||||
A day entry begins with a non-indented hledger-style [simple date](journal.html#simple-dates) (see hledger_journal(5)).
|
A day entry begins with a non-indented hledger-style
|
||||||
|
[simple date](journal.html#simple-dates) (Y-M-D, Y/M/D, Y.M.D..)
|
||||||
|
Any additional text on the same line is used as a transaction description for this day.
|
||||||
|
|
||||||
This is followed by optionally-indented timelog items for that day, one per line.
|
This is followed by optionally-indented timelog items for that day, one per line.
|
||||||
Each timelog item is a note, usually a hledger:style:account:name representing a time category,
|
Each timelog item is a note, usually a hledger:style:account:name representing a time category,
|
||||||
followed by two or more spaces, and a quantity.
|
followed by two or more spaces, and a quantity.
|
||||||
|
Each timelog item generates a hledger transaction.
|
||||||
|
|
||||||
Quantities can be written as:
|
Quantities can be written as:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user