rename metadata fields to tags
This commit is contained in:
parent
3ee6a351f3
commit
2fb2aea056
@ -516,7 +516,7 @@ tests_journalAccountInfo = [
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -525,7 +525,7 @@ tests_journalAccountInfo = [
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -534,7 +534,7 @@ tests_journalAccountInfo = [
|
|||||||
pamount=(Mixed [dollars (-1)]),
|
pamount=(Mixed [dollars (-1)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -543,7 +543,7 @@ tests_journalAccountInfo = [
|
|||||||
pamount=(Mixed [dollars (-1)]),
|
pamount=(Mixed [dollars (-1)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
] (Mixed [nullamt]))
|
] (Mixed [nullamt]))
|
||||||
@ -554,7 +554,7 @@ tests_journalAccountInfo = [
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
] (Mixed [dollars 1]))
|
] (Mixed [dollars 1]))
|
||||||
@ -565,7 +565,7 @@ tests_journalAccountInfo = [
|
|||||||
pamount=(Mixed [dollars (-2)]),
|
pamount=(Mixed [dollars (-2)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
] (Mixed [dollars (-2)]))
|
] (Mixed [dollars (-2)]))
|
||||||
@ -577,7 +577,7 @@ tests_journalAccountInfo = [
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
] (Mixed [dollars 1]))
|
] (Mixed [dollars 1]))
|
||||||
@ -588,7 +588,7 @@ tests_journalAccountInfo = [
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
] (Mixed [dollars 1]))
|
] (Mixed [dollars 1]))
|
||||||
@ -600,7 +600,7 @@ tests_journalAccountInfo = [
|
|||||||
pamount=(Mixed [dollars (-1)]),
|
pamount=(Mixed [dollars (-1)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
] (Mixed [dollars (-1)]))
|
] (Mixed [dollars (-1)]))
|
||||||
@ -611,7 +611,7 @@ tests_journalAccountInfo = [
|
|||||||
pamount=(Mixed [dollars (-1)]),
|
pamount=(Mixed [dollars (-1)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
] (Mixed [dollars (-1)]))
|
] (Mixed [dollars (-1)]))
|
||||||
@ -623,7 +623,7 @@ tests_journalAccountInfo = [
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
] (Mixed [dollars 1]))
|
] (Mixed [dollars 1]))
|
||||||
@ -712,7 +712,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
tcode="",
|
tcode="",
|
||||||
tdescription="income",
|
tdescription="income",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -720,7 +720,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -729,7 +729,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
pamount=(missingmixedamt),
|
pamount=(missingmixedamt),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -743,7 +743,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
tcode="",
|
tcode="",
|
||||||
tdescription="gift",
|
tdescription="gift",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -751,7 +751,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -760,7 +760,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
pamount=(missingmixedamt),
|
pamount=(missingmixedamt),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -774,7 +774,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
tcode="",
|
tcode="",
|
||||||
tdescription="save",
|
tdescription="save",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -782,7 +782,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -791,7 +791,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
pamount=(Mixed [dollars (-1)]),
|
pamount=(Mixed [dollars (-1)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -805,7 +805,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
tcode="",
|
tcode="",
|
||||||
tdescription="eat & shop",
|
tdescription="eat & shop",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -813,7 +813,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -822,7 +822,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -831,7 +831,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
pamount=(missingmixedamt),
|
pamount=(missingmixedamt),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -845,7 +845,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
tcode="",
|
tcode="",
|
||||||
tdescription="pay off",
|
tdescription="pay off",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -853,7 +853,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -862,7 +862,7 @@ Right samplejournal = journalBalanceTransactions $ Journal
|
|||||||
pamount=(Mixed [dollars (-1)]),
|
pamount=(Mixed [dollars (-1)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@ -35,8 +35,8 @@ module Hledger.Data.Posting (
|
|||||||
showPosting,
|
showPosting,
|
||||||
showPostingForRegister,
|
showPostingForRegister,
|
||||||
-- * misc.
|
-- * misc.
|
||||||
postingMetadataAsLines,
|
postingTagsAsLines,
|
||||||
metadataAsLines,
|
tagsAsLines,
|
||||||
showComment,
|
showComment,
|
||||||
tests_Hledger_Data_Posting
|
tests_Hledger_Data_Posting
|
||||||
)
|
)
|
||||||
@ -62,7 +62,7 @@ nullposting = Posting False "" nullmixedamt "" RegularPosting [] Nothing
|
|||||||
|
|
||||||
showPosting :: Posting -> String
|
showPosting :: Posting -> String
|
||||||
showPosting p@Posting{paccount=a,pamount=amt,ptype=t} =
|
showPosting p@Posting{paccount=a,pamount=amt,ptype=t} =
|
||||||
unlines $ [concatTopPadded [showaccountname a ++ " ", showamount amt, showComment (pcomment p)]] ++ postingMetadataAsLines p
|
unlines $ [concatTopPadded [showaccountname a ++ " ", showamount amt, showComment (pcomment p)]] ++ postingTagsAsLines p
|
||||||
where
|
where
|
||||||
ledger3ishlayout = False
|
ledger3ishlayout = False
|
||||||
acctnamewidth = if ledger3ishlayout then 25 else 22
|
acctnamewidth = if ledger3ishlayout then 25 else 22
|
||||||
@ -74,11 +74,11 @@ showPosting p@Posting{paccount=a,pamount=amt,ptype=t} =
|
|||||||
showamount = padleft 12 . showMixedAmount
|
showamount = padleft 12 . showMixedAmount
|
||||||
|
|
||||||
|
|
||||||
postingMetadataAsLines :: Posting -> [String]
|
postingTagsAsLines :: Posting -> [String]
|
||||||
postingMetadataAsLines = metadataAsLines . pmetadata
|
postingTagsAsLines = tagsAsLines . ptags
|
||||||
|
|
||||||
metadataAsLines :: [(String, String)] -> [String]
|
tagsAsLines :: [(String, String)] -> [String]
|
||||||
metadataAsLines mds = map (\(k,v) -> " ; " ++ k++": "++v) mds
|
tagsAsLines mds = map (\(k,v) -> " ; " ++ k++": "++v) mds
|
||||||
|
|
||||||
showComment :: String -> String
|
showComment :: String -> String
|
||||||
showComment s = if null s then "" else " ; " ++ s
|
showComment s = if null s then "" else " ; " ++ s
|
||||||
|
|||||||
@ -81,7 +81,7 @@ entryFromTimeLogInOut i o
|
|||||||
tcode = "",
|
tcode = "",
|
||||||
tdescription = showtime itod ++ "-" ++ showtime otod,
|
tdescription = showtime itod ++ "-" ++ showtime otod,
|
||||||
tcomment = "",
|
tcomment = "",
|
||||||
tmetadata = [],
|
ttags = [],
|
||||||
tpostings = ps,
|
tpostings = ps,
|
||||||
tpreceding_comment_lines=""
|
tpreceding_comment_lines=""
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ entryFromTimeLogInOut i o
|
|||||||
hrs = elapsedSeconds (toutc otime) (toutc itime) / 3600 where toutc = localTimeToUTC utc
|
hrs = elapsedSeconds (toutc otime) (toutc itime) / 3600 where toutc = localTimeToUTC utc
|
||||||
amount = Mixed [hours hrs]
|
amount = Mixed [hours hrs]
|
||||||
ps = [Posting{pstatus=False,paccount=acctname,pamount=amount,
|
ps = [Posting{pstatus=False,paccount=acctname,pamount=amount,
|
||||||
pcomment="",ptype=VirtualPosting,pmetadata=[],ptransaction=Just t}]
|
pcomment="",ptype=VirtualPosting,ptags=[],ptransaction=Just t}]
|
||||||
|
|
||||||
tests_Hledger_Data_TimeLog = TestList [
|
tests_Hledger_Data_TimeLog = TestList [
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
A 'Transaction' represents a movement of some commodity(ies) between two
|
A 'Transaction' represents a movement of some commodity(ies) between two
|
||||||
or more accounts. It consists of multiple account 'Posting's which balance
|
or more accounts. It consists of multiple account 'Posting's which balance
|
||||||
to zero, a date, and optional metadata like description and cleared
|
to zero, a date, and optional extras like description, cleared status, and
|
||||||
status.
|
tags.
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ nulltransaction = Transaction {
|
|||||||
tcode="",
|
tcode="",
|
||||||
tdescription="",
|
tdescription="",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[],
|
tpostings=[],
|
||||||
tpreceding_comment_lines=""
|
tpreceding_comment_lines=""
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ tests_showTransactionUnelided = [
|
|||||||
tcode="code",
|
tcode="code",
|
||||||
tdescription="desc",
|
tdescription="desc",
|
||||||
tcomment="tcomment1\ntcomment2\n",
|
tcomment="tcomment1\ntcomment2\n",
|
||||||
tmetadata=[("ttag1","val1")],
|
ttags=[("ttag1","val1")],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
nullposting{
|
nullposting{
|
||||||
pstatus=True,
|
pstatus=True,
|
||||||
@ -111,7 +111,7 @@ tests_showTransactionUnelided = [
|
|||||||
pamount=Mixed [dollars 1, hours 2],
|
pamount=Mixed [dollars 1, hours 2],
|
||||||
pcomment="pcomment1\npcomment2\n",
|
pcomment="pcomment1\npcomment2\n",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[("ptag1","val1"),("ptag2","val2")]
|
ptags=[("ptag1","val1"),("ptag2","val2")]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ showTransaction' :: Bool -> Transaction -> String
|
|||||||
showTransaction' elide t =
|
showTransaction' elide t =
|
||||||
unlines $ [descriptionline]
|
unlines $ [descriptionline]
|
||||||
++ commentlines
|
++ commentlines
|
||||||
++ (metadataAsLines $ tmetadata t)
|
++ (tagsAsLines $ ttags t)
|
||||||
++ (postingsAsLines elide t (tpostings t))
|
++ (postingsAsLines elide t (tpostings t))
|
||||||
++ [""]
|
++ [""]
|
||||||
where
|
where
|
||||||
@ -163,7 +163,7 @@ postingAsLines :: Bool -> [Posting] -> Posting -> [String]
|
|||||||
postingAsLines elideamount ps p =
|
postingAsLines elideamount ps p =
|
||||||
postinglines
|
postinglines
|
||||||
++ commentlines
|
++ commentlines
|
||||||
++ metadataAsLines (pmetadata p)
|
++ tagsAsLines (ptags p)
|
||||||
where
|
where
|
||||||
postinglines = map rstrip $ lines $ concatTopPadded [showacct p, " ", amount, firstcomment]
|
postinglines = map rstrip $ lines $ concatTopPadded [showacct p, " ", amount, firstcomment]
|
||||||
amount = if elideamount then "" else showamt (pamount p)
|
amount = if elideamount then "" else showamt (pamount p)
|
||||||
@ -186,7 +186,7 @@ tests_postingAsLines = [
|
|||||||
pamount=Mixed [dollars 1, hours 2],
|
pamount=Mixed [dollars 1, hours 2],
|
||||||
pcomment="pcomment1\npcomment2\n",
|
pcomment="pcomment1\npcomment2\n",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[("ptag1","val1"),("ptag2","val2")]
|
ptags=[("ptag1","val1"),("ptag2","val2")]
|
||||||
}
|
}
|
||||||
`gives` [
|
`gives` [
|
||||||
" $1.00",
|
" $1.00",
|
||||||
|
|||||||
@ -95,7 +95,7 @@ data Posting = Posting {
|
|||||||
pamount :: MixedAmount,
|
pamount :: MixedAmount,
|
||||||
pcomment :: String, -- ^ this posting's non-tag comment lines, as a single non-indented string
|
pcomment :: String, -- ^ this posting's non-tag comment lines, as a single non-indented string
|
||||||
ptype :: PostingType,
|
ptype :: PostingType,
|
||||||
pmetadata :: [(String,String)],
|
ptags :: [(String,String)],
|
||||||
ptransaction :: Maybe Transaction -- ^ this posting's parent transaction (co-recursive types).
|
ptransaction :: Maybe Transaction -- ^ this posting's parent transaction (co-recursive types).
|
||||||
-- Tying this knot gets tedious, Maybe makes it easier/optional.
|
-- Tying this knot gets tedious, Maybe makes it easier/optional.
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ data Transaction = Transaction {
|
|||||||
tcode :: String,
|
tcode :: String,
|
||||||
tdescription :: String,
|
tdescription :: String,
|
||||||
tcomment :: String, -- ^ this transaction's non-tag comment lines, as a single non-indented string
|
tcomment :: String, -- ^ this transaction's non-tag comment lines, as a single non-indented string
|
||||||
tmetadata :: [(String,String)],
|
ttags :: [(String,String)],
|
||||||
tpostings :: [Posting], -- ^ this transaction's postings (co-recursive types).
|
tpostings :: [Posting], -- ^ this transaction's postings (co-recursive types).
|
||||||
tpreceding_comment_lines :: String
|
tpreceding_comment_lines :: String
|
||||||
} deriving (Eq)
|
} deriving (Eq)
|
||||||
|
|||||||
@ -436,7 +436,7 @@ transactionFromCsvRecord rules fields =
|
|||||||
tdescription=newdesc,
|
tdescription=newdesc,
|
||||||
tcomment=comment,
|
tcomment=comment,
|
||||||
tpreceding_comment_lines=precomment,
|
tpreceding_comment_lines=precomment,
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -444,7 +444,7 @@ transactionFromCsvRecord rules fields =
|
|||||||
pamount=a,
|
pamount=a,
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Just t
|
ptransaction=Just t
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -453,7 +453,7 @@ transactionFromCsvRecord rules fields =
|
|||||||
pamount=(-baseamount),
|
pamount=(-baseamount),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Just t
|
ptransaction=Just t
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -312,7 +312,7 @@ transaction = do
|
|||||||
edate <- optionMaybe (effectivedate date) <?> "effective date"
|
edate <- optionMaybe (effectivedate date) <?> "effective date"
|
||||||
status <- status <?> "cleared flag"
|
status <- status <?> "cleared flag"
|
||||||
code <- code <?> "transaction code"
|
code <- code <?> "transaction code"
|
||||||
-- now there can be whitespace followed by a description and/or comment/metadata comment
|
-- now there can be whitespace followed by a description and/or comment/tag comment
|
||||||
let pdescription = many (noneOf ";\n") >>= return . strip
|
let pdescription = many (noneOf ";\n") >>= return . strip
|
||||||
(description, inlinecomment, inlinemd) <-
|
(description, inlinecomment, inlinemd) <-
|
||||||
try (do many1 spacenonewline
|
try (do many1 spacenonewline
|
||||||
@ -340,7 +340,7 @@ tests_transaction = [
|
|||||||
same tcode
|
same tcode
|
||||||
same tdescription
|
same tdescription
|
||||||
same tcomment
|
same tcomment
|
||||||
same tmetadata
|
same ttags
|
||||||
same tpreceding_comment_lines
|
same tpreceding_comment_lines
|
||||||
same tpostings
|
same tpostings
|
||||||
-- "0000/01/01\n\n" `gives` nulltransaction
|
-- "0000/01/01\n\n" `gives` nulltransaction
|
||||||
@ -361,7 +361,7 @@ tests_transaction = [
|
|||||||
tcode="code",
|
tcode="code",
|
||||||
tdescription="desc",
|
tdescription="desc",
|
||||||
tcomment="tcomment1\ntcomment2\n",
|
tcomment="tcomment1\ntcomment2\n",
|
||||||
tmetadata=[("ttag1","val1")],
|
ttags=[("ttag1","val1")],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
nullposting{
|
nullposting{
|
||||||
pstatus=True,
|
pstatus=True,
|
||||||
@ -369,7 +369,7 @@ tests_transaction = [
|
|||||||
pamount=Mixed [dollars 1],
|
pamount=Mixed [dollars 1],
|
||||||
pcomment="pcomment1\npcomment2\n",
|
pcomment="pcomment1\npcomment2\n",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[("ptag1","val1"),("ptag2","val2")],
|
ptags=[("ptag1","val1"),("ptag2","val2")],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -465,8 +465,7 @@ status = try (do { many spacenonewline; char '*' <?> "status"; return True } ) <
|
|||||||
code :: GenParser Char JournalContext String
|
code :: GenParser Char JournalContext String
|
||||||
code = try (do { many1 spacenonewline; char '(' <?> "code"; code <- anyChar `manyTill` char ')'; return code } ) <|> return ""
|
code = try (do { many1 spacenonewline; char '(' <?> "code"; code <- anyChar `manyTill` char ')'; return code } ) <|> return ""
|
||||||
|
|
||||||
-- Parse the following whitespace-beginning lines as postings, posting metadata, and/or comments.
|
-- Parse the following whitespace-beginning lines as postings, posting tags, and/or comments.
|
||||||
-- complicated to handle intermixed comment and metadata lines.. make me better ?
|
|
||||||
postings :: GenParser Char JournalContext [Posting]
|
postings :: GenParser Char JournalContext [Posting]
|
||||||
postings = many1 (try posting) <?> "postings"
|
postings = many1 (try posting) <?> "postings"
|
||||||
|
|
||||||
@ -505,7 +504,7 @@ tests_posting = [
|
|||||||
same pamount
|
same pamount
|
||||||
same pcomment
|
same pcomment
|
||||||
same ptype
|
same ptype
|
||||||
same pmetadata
|
same ptags
|
||||||
same ptransaction
|
same ptransaction
|
||||||
" expenses:food:dining $10.00 ; a: a a \n ; b: b b \n"
|
" expenses:food:dining $10.00 ; a: a a \n ; b: b b \n"
|
||||||
`gives`
|
`gives`
|
||||||
@ -769,7 +768,7 @@ tests_inlinecomment = [
|
|||||||
|
|
||||||
commentlines :: GenParser Char JournalContext ([String],[Tag])
|
commentlines :: GenParser Char JournalContext ([String],[Tag])
|
||||||
commentlines = do
|
commentlines = do
|
||||||
comormds <- many $ choice' [(liftM Right metadataline)
|
comormds <- many $ choice' [(liftM Right tagline)
|
||||||
,(do {many1 spacenonewline; c <- comment; newline; return $ Left c }) -- XXX fix commentnewline
|
,(do {many1 spacenonewline; c <- comment; newline; return $ Left c }) -- XXX fix commentnewline
|
||||||
]
|
]
|
||||||
return $ partitionEithers comormds
|
return $ partitionEithers comormds
|
||||||
@ -781,10 +780,10 @@ tests_commentlines = [
|
|||||||
`gives` (["comment 1","comment 2"],[("tag1","val1")])
|
`gives` (["comment 1","comment 2"],[("tag1","val1")])
|
||||||
]
|
]
|
||||||
|
|
||||||
-- a comment line containing a metadata declaration, eg:
|
-- a comment line containing a tag declaration, eg:
|
||||||
-- ; name: value
|
-- ; name: value
|
||||||
metadataline :: GenParser Char JournalContext (String,String)
|
tagline :: GenParser Char JournalContext (String,String)
|
||||||
metadataline = do
|
tagline = do
|
||||||
many1 spacenonewline
|
many1 spacenonewline
|
||||||
md <- tagcomment
|
md <- tagcomment
|
||||||
newline
|
newline
|
||||||
@ -800,7 +799,7 @@ tagcomment = do
|
|||||||
many spacenonewline
|
many spacenonewline
|
||||||
value <- many (noneOf "\n")
|
value <- many (noneOf "\n")
|
||||||
return (name, rstrip value)
|
return (name, rstrip value)
|
||||||
<?> "metadata comment"
|
<?> "tag comment"
|
||||||
|
|
||||||
tests_tagcomment = [
|
tests_tagcomment = [
|
||||||
"tagcomment" ~: do
|
"tagcomment" ~: do
|
||||||
|
|||||||
@ -914,7 +914,7 @@ Right samplejournal2 = journalBalanceTransactions $ Journal
|
|||||||
tcode="",
|
tcode="",
|
||||||
tdescription="income",
|
tdescription="income",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -922,7 +922,7 @@ Right samplejournal2 = journalBalanceTransactions $ Journal
|
|||||||
pamount=(Mixed [dollars 1]),
|
pamount=(Mixed [dollars 1]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -931,7 +931,7 @@ Right samplejournal2 = journalBalanceTransactions $ Journal
|
|||||||
pamount=(missingmixedamt),
|
pamount=(missingmixedamt),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@ -347,7 +347,7 @@ journal7 = Journal
|
|||||||
tcode="*",
|
tcode="*",
|
||||||
tdescription="opening balance",
|
tdescription="opening balance",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -355,7 +355,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars 4.82]),
|
pamount=(Mixed [dollars 4.82]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -364,7 +364,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars (-4.82)]),
|
pamount=(Mixed [dollars (-4.82)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -378,7 +378,7 @@ journal7 = Journal
|
|||||||
tcode="*",
|
tcode="*",
|
||||||
tdescription="ayres suites",
|
tdescription="ayres suites",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -386,7 +386,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars 179.92]),
|
pamount=(Mixed [dollars 179.92]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -395,7 +395,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars (-179.92)]),
|
pamount=(Mixed [dollars (-179.92)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -409,7 +409,7 @@ journal7 = Journal
|
|||||||
tcode="*",
|
tcode="*",
|
||||||
tdescription="auto transfer to savings",
|
tdescription="auto transfer to savings",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -417,7 +417,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars 200]),
|
pamount=(Mixed [dollars 200]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -426,7 +426,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars (-200)]),
|
pamount=(Mixed [dollars (-200)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -440,7 +440,7 @@ journal7 = Journal
|
|||||||
tcode="*",
|
tcode="*",
|
||||||
tdescription="poquito mas",
|
tdescription="poquito mas",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -448,7 +448,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars 4.82]),
|
pamount=(Mixed [dollars 4.82]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -457,7 +457,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars (-4.82)]),
|
pamount=(Mixed [dollars (-4.82)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -471,7 +471,7 @@ journal7 = Journal
|
|||||||
tcode="*",
|
tcode="*",
|
||||||
tdescription="verizon",
|
tdescription="verizon",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -479,7 +479,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars 95.11]),
|
pamount=(Mixed [dollars 95.11]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -488,7 +488,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars (-95.11)]),
|
pamount=(Mixed [dollars (-95.11)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -502,7 +502,7 @@ journal7 = Journal
|
|||||||
tcode="*",
|
tcode="*",
|
||||||
tdescription="discover",
|
tdescription="discover",
|
||||||
tcomment="",
|
tcomment="",
|
||||||
tmetadata=[],
|
ttags=[],
|
||||||
tpostings=[
|
tpostings=[
|
||||||
Posting {
|
Posting {
|
||||||
pstatus=False,
|
pstatus=False,
|
||||||
@ -510,7 +510,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars 80]),
|
pamount=(Mixed [dollars 80]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
},
|
},
|
||||||
Posting {
|
Posting {
|
||||||
@ -519,7 +519,7 @@ journal7 = Journal
|
|||||||
pamount=(Mixed [dollars (-80)]),
|
pamount=(Mixed [dollars (-80)]),
|
||||||
pcomment="",
|
pcomment="",
|
||||||
ptype=RegularPosting,
|
ptype=RegularPosting,
|
||||||
pmetadata=[],
|
ptags=[],
|
||||||
ptransaction=Nothing
|
ptransaction=Nothing
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user