mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-19 10:17:35 +03:00
lib: Allow multiline comments in csv rules
This commit is contained in:
parent
b79a8473f7
commit
e31eb58ada
@ -920,10 +920,11 @@ transactionFromCsvRecord sourcepos rules record = t
|
||||
]
|
||||
code = maybe "" singleline $ fieldval "code"
|
||||
description = maybe "" singleline $ fieldval "description"
|
||||
comment = maybe "" singleline $ fieldval "comment"
|
||||
precomment = maybe "" singleline $ fieldval "precomment"
|
||||
comment = maybe "" unescapeNewlines $ fieldval "comment"
|
||||
precomment = maybe "" unescapeNewlines $ fieldval "precomment"
|
||||
|
||||
singleline = T.unwords . filter (not . T.null) . map T.strip . T.lines
|
||||
unescapeNewlines = T.intercalate "\n" . T.splitOn "\\n"
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 3. Generate the postings for which an account has been assigned
|
||||
@ -931,7 +932,7 @@ transactionFromCsvRecord sourcepos rules record = t
|
||||
|
||||
p1IsVirtual = (accountNamePostingType <$> fieldval "account1") == Just VirtualPosting
|
||||
ps = [p | n <- [1..maxpostings]
|
||||
,let comment = fromMaybe "" $ fieldval ("comment"<> T.pack (show n))
|
||||
,let comment = maybe "" unescapeNewlines $ fieldval ("comment"<> T.pack (show n))
|
||||
,let currency = fromMaybe "" (fieldval ("currency"<> T.pack (show n)) <|> fieldval "currency")
|
||||
,let mamount = getAmount rules record currency p1IsVirtual n
|
||||
,let mbalance = getBalance rules record currency n
|
||||
|
@ -3803,7 +3803,7 @@ Assigning to `date` sets the [transaction date](#simple-dates).
|
||||
`commentN`, where N is a number, sets the Nth posting's comment.
|
||||
|
||||
Tips:
|
||||
- Only single-line comments can be assigned.
|
||||
- You can assign multi-line comments by writing literal `\n` in the code. A comment starting with `\n` will begin on a new line.
|
||||
- Comments can contain [tags](#tags), as usual.
|
||||
|
||||
#### account field
|
||||
|
Loading…
Reference in New Issue
Block a user