lib: rename, reposition tprecedingcomment field
This commit is contained in:
parent
cd1455e9ea
commit
6f36702141
@ -1063,7 +1063,7 @@ Right samplejournal = journalBalanceTransactions False $
|
|||||||
["assets:bank:checking" `post` usd 1
|
["assets:bank:checking" `post` usd 1
|
||||||
,"income:salary" `post` missingamt
|
,"income:salary" `post` missingamt
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
txnTieKnot $ Transaction {
|
txnTieKnot $ Transaction {
|
||||||
@ -1080,7 +1080,7 @@ Right samplejournal = journalBalanceTransactions False $
|
|||||||
["assets:bank:checking" `post` usd 1
|
["assets:bank:checking" `post` usd 1
|
||||||
,"income:gifts" `post` missingamt
|
,"income:gifts" `post` missingamt
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
txnTieKnot $ Transaction {
|
txnTieKnot $ Transaction {
|
||||||
@ -1097,7 +1097,7 @@ Right samplejournal = journalBalanceTransactions False $
|
|||||||
["assets:bank:saving" `post` usd 1
|
["assets:bank:saving" `post` usd 1
|
||||||
,"assets:bank:checking" `post` usd (-1)
|
,"assets:bank:checking" `post` usd (-1)
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
txnTieKnot $ Transaction {
|
txnTieKnot $ Transaction {
|
||||||
@ -1114,7 +1114,7 @@ Right samplejournal = journalBalanceTransactions False $
|
|||||||
,"expenses:supplies" `post` usd 1
|
,"expenses:supplies" `post` usd 1
|
||||||
,"assets:cash" `post` missingamt
|
,"assets:cash" `post` missingamt
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
txnTieKnot $ Transaction {
|
txnTieKnot $ Transaction {
|
||||||
@ -1130,7 +1130,7 @@ Right samplejournal = journalBalanceTransactions False $
|
|||||||
tpostings=["assets:bank:checking" `post` usd 1
|
tpostings=["assets:bank:checking" `post` usd 1
|
||||||
,"liabilities:debts" `post` usd (-1)
|
,"liabilities:debts" `post` usd (-1)
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
txnTieKnot $ Transaction {
|
txnTieKnot $ Transaction {
|
||||||
@ -1146,7 +1146,7 @@ Right samplejournal = journalBalanceTransactions False $
|
|||||||
tpostings=["liabilities:debts" `post` usd 1
|
tpostings=["liabilities:debts" `post` usd 1
|
||||||
,"assets:bank:checking" `post` usd (-1)
|
,"assets:bank:checking" `post` usd (-1)
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,7 +95,7 @@ entryFromTimeclockInOut i o
|
|||||||
tcomment = "",
|
tcomment = "",
|
||||||
ttags = [],
|
ttags = [],
|
||||||
tpostings = ps,
|
tpostings = ps,
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
itime = tldatetime i
|
itime = tldatetime i
|
||||||
otime = tldatetime o
|
otime = tldatetime o
|
||||||
|
|||||||
@ -90,7 +90,7 @@ nulltransaction = Transaction {
|
|||||||
tcomment="",
|
tcomment="",
|
||||||
ttags=[],
|
ttags=[],
|
||||||
tpostings=[],
|
tpostings=[],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
@ -689,10 +689,10 @@ tests_Transaction = tests "Transaction" [
|
|||||||
|
|
||||||
,tests "showTransaction" [
|
,tests "showTransaction" [
|
||||||
test "show a balanced transaction, eliding last amount" $
|
test "show a balanced transaction, eliding last amount" $
|
||||||
let t = Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
let t = Transaction 0 "" nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
||||||
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18], ptransaction=Just t}
|
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18], ptransaction=Just t}
|
||||||
,posting{paccount="assets:checking", pamount=Mixed [usd (-47.18)], ptransaction=Just t}
|
,posting{paccount="assets:checking", pamount=Mixed [usd (-47.18)], ptransaction=Just t}
|
||||||
] ""
|
]
|
||||||
in
|
in
|
||||||
showTransaction t
|
showTransaction t
|
||||||
`is`
|
`is`
|
||||||
@ -704,10 +704,10 @@ tests_Transaction = tests "Transaction" [
|
|||||||
]
|
]
|
||||||
|
|
||||||
,test "show a balanced transaction, no eliding" $
|
,test "show a balanced transaction, no eliding" $
|
||||||
(let t = Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
(let t = Transaction 0 "" nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
||||||
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18], ptransaction=Just t}
|
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18], ptransaction=Just t}
|
||||||
,posting{paccount="assets:checking", pamount=Mixed [usd (-47.18)], ptransaction=Just t}
|
,posting{paccount="assets:checking", pamount=Mixed [usd (-47.18)], ptransaction=Just t}
|
||||||
] ""
|
]
|
||||||
in showTransactionUnelided t)
|
in showTransactionUnelided t)
|
||||||
`is`
|
`is`
|
||||||
(unlines
|
(unlines
|
||||||
@ -720,10 +720,10 @@ tests_Transaction = tests "Transaction" [
|
|||||||
-- document some cases that arise in debug/testing:
|
-- document some cases that arise in debug/testing:
|
||||||
,test "show an unbalanced transaction, should not elide" $
|
,test "show an unbalanced transaction, should not elide" $
|
||||||
(showTransaction
|
(showTransaction
|
||||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
(txnTieKnot $ Transaction 0 "" nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
||||||
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18]}
|
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18]}
|
||||||
,posting{paccount="assets:checking", pamount=Mixed [usd (-47.19)]}
|
,posting{paccount="assets:checking", pamount=Mixed [usd (-47.19)]}
|
||||||
] ""))
|
]))
|
||||||
`is`
|
`is`
|
||||||
(unlines
|
(unlines
|
||||||
["2007/01/28 coopportunity"
|
["2007/01/28 coopportunity"
|
||||||
@ -734,9 +734,9 @@ tests_Transaction = tests "Transaction" [
|
|||||||
|
|
||||||
,test "show an unbalanced transaction with one posting, should not elide" $
|
,test "show an unbalanced transaction with one posting, should not elide" $
|
||||||
(showTransaction
|
(showTransaction
|
||||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
(txnTieKnot $ Transaction 0 "" nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
||||||
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18]}
|
[posting{paccount="expenses:food:groceries", pamount=Mixed [usd 47.18]}
|
||||||
] ""))
|
]))
|
||||||
`is`
|
`is`
|
||||||
(unlines
|
(unlines
|
||||||
["2007/01/28 coopportunity"
|
["2007/01/28 coopportunity"
|
||||||
@ -746,9 +746,9 @@ tests_Transaction = tests "Transaction" [
|
|||||||
|
|
||||||
,test "show a transaction with one posting and a missing amount" $
|
,test "show a transaction with one posting and a missing amount" $
|
||||||
(showTransaction
|
(showTransaction
|
||||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
(txnTieKnot $ Transaction 0 "" nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "coopportunity" "" []
|
||||||
[posting{paccount="expenses:food:groceries", pamount=missingmixedamt}
|
[posting{paccount="expenses:food:groceries", pamount=missingmixedamt}
|
||||||
] ""))
|
]))
|
||||||
`is`
|
`is`
|
||||||
(unlines
|
(unlines
|
||||||
["2007/01/28 coopportunity"
|
["2007/01/28 coopportunity"
|
||||||
@ -758,10 +758,10 @@ tests_Transaction = tests "Transaction" [
|
|||||||
|
|
||||||
,test "show a transaction with a priced commodityless amount" $
|
,test "show a transaction with a priced commodityless amount" $
|
||||||
(showTransaction
|
(showTransaction
|
||||||
(txnTieKnot $ Transaction 0 nullsourcepos (parsedate "2010/01/01") Nothing Unmarked "" "x" "" []
|
(txnTieKnot $ Transaction 0 "" nullsourcepos (parsedate "2010/01/01") Nothing Unmarked "" "x" "" []
|
||||||
[posting{paccount="a", pamount=Mixed [num 1 `at` (usd 2 `withPrecision` 0)]}
|
[posting{paccount="a", pamount=Mixed [num 1 `at` (usd 2 `withPrecision` 0)]}
|
||||||
,posting{paccount="b", pamount= missingmixedamt}
|
,posting{paccount="b", pamount= missingmixedamt}
|
||||||
] ""))
|
]))
|
||||||
`is`
|
`is`
|
||||||
(unlines
|
(unlines
|
||||||
["2010/01/01 x"
|
["2010/01/01 x"
|
||||||
@ -774,95 +774,95 @@ tests_Transaction = tests "Transaction" [
|
|||||||
,tests "balanceTransaction" [
|
,tests "balanceTransaction" [
|
||||||
test "detect unbalanced entry, sign error" $
|
test "detect unbalanced entry, sign error" $
|
||||||
(expectLeft $ balanceTransaction Nothing
|
(expectLeft $ balanceTransaction Nothing
|
||||||
(Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "test" "" []
|
(Transaction 0 "" nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "test" "" []
|
||||||
[posting{paccount="a", pamount=Mixed [usd 1]}
|
[posting{paccount="a", pamount=Mixed [usd 1]}
|
||||||
,posting{paccount="b", pamount=Mixed [usd 1]}
|
,posting{paccount="b", pamount=Mixed [usd 1]}
|
||||||
] ""))
|
]))
|
||||||
|
|
||||||
,test "detect unbalanced entry, multiple missing amounts" $
|
,test "detect unbalanced entry, multiple missing amounts" $
|
||||||
(expectLeft $ balanceTransaction Nothing
|
(expectLeft $ balanceTransaction Nothing
|
||||||
(Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "test" "" []
|
(Transaction 0 "" nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "test" "" []
|
||||||
[posting{paccount="a", pamount=missingmixedamt}
|
[posting{paccount="a", pamount=missingmixedamt}
|
||||||
,posting{paccount="b", pamount=missingmixedamt}
|
,posting{paccount="b", pamount=missingmixedamt}
|
||||||
] ""))
|
]))
|
||||||
|
|
||||||
,test "one missing amount is inferred" $
|
,test "one missing amount is inferred" $
|
||||||
(pamount . last . tpostings <$> balanceTransaction
|
(pamount . last . tpostings <$> balanceTransaction
|
||||||
Nothing
|
Nothing
|
||||||
(Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "" "" []
|
(Transaction 0 "" nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "" "" []
|
||||||
[posting{paccount="a", pamount=Mixed [usd 1]}
|
[posting{paccount="a", pamount=Mixed [usd 1]}
|
||||||
,posting{paccount="b", pamount=missingmixedamt}
|
,posting{paccount="b", pamount=missingmixedamt}
|
||||||
] ""))
|
]))
|
||||||
`is` Right (Mixed [usd (-1)])
|
`is` Right (Mixed [usd (-1)])
|
||||||
|
|
||||||
,test "conversion price is inferred" $
|
,test "conversion price is inferred" $
|
||||||
(pamount . head . tpostings <$> balanceTransaction
|
(pamount . head . tpostings <$> balanceTransaction
|
||||||
Nothing
|
Nothing
|
||||||
(Transaction 0 nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "" "" []
|
(Transaction 0 "" nullsourcepos (parsedate "2007/01/28") Nothing Unmarked "" "" "" []
|
||||||
[posting{paccount="a", pamount=Mixed [usd 1.35]}
|
[posting{paccount="a", pamount=Mixed [usd 1.35]}
|
||||||
,posting{paccount="b", pamount=Mixed [eur (-1)]}
|
,posting{paccount="b", pamount=Mixed [eur (-1)]}
|
||||||
] ""))
|
]))
|
||||||
`is` Right (Mixed [usd 1.35 @@ (eur 1 `withPrecision` maxprecision)])
|
`is` Right (Mixed [usd 1.35 @@ (eur 1 `withPrecision` maxprecision)])
|
||||||
|
|
||||||
,test "balanceTransaction balances based on cost if there are unit prices" $
|
,test "balanceTransaction balances based on cost if there are unit prices" $
|
||||||
expectRight $
|
expectRight $
|
||||||
balanceTransaction Nothing (Transaction 0 nullsourcepos (parsedate "2011/01/01") Nothing Unmarked "" "" "" []
|
balanceTransaction Nothing (Transaction 0 "" nullsourcepos (parsedate "2011/01/01") Nothing Unmarked "" "" "" []
|
||||||
[posting{paccount="a", pamount=Mixed [usd 1 `at` eur 2]}
|
[posting{paccount="a", pamount=Mixed [usd 1 `at` eur 2]}
|
||||||
,posting{paccount="a", pamount=Mixed [usd (-2) `at` eur 1]}
|
,posting{paccount="a", pamount=Mixed [usd (-2) `at` eur 1]}
|
||||||
] "")
|
])
|
||||||
|
|
||||||
,test "balanceTransaction balances based on cost if there are total prices" $
|
,test "balanceTransaction balances based on cost if there are total prices" $
|
||||||
expectRight $
|
expectRight $
|
||||||
balanceTransaction Nothing (Transaction 0 nullsourcepos (parsedate "2011/01/01") Nothing Unmarked "" "" "" []
|
balanceTransaction Nothing (Transaction 0 "" nullsourcepos (parsedate "2011/01/01") Nothing Unmarked "" "" "" []
|
||||||
[posting{paccount="a", pamount=Mixed [usd 1 @@ eur 1]}
|
[posting{paccount="a", pamount=Mixed [usd 1 @@ eur 1]}
|
||||||
,posting{paccount="a", pamount=Mixed [usd (-2) @@ eur 1]}
|
,posting{paccount="a", pamount=Mixed [usd (-2) @@ eur 1]}
|
||||||
] "")
|
])
|
||||||
]
|
]
|
||||||
|
|
||||||
,tests "isTransactionBalanced" [
|
,tests "isTransactionBalanced" [
|
||||||
test "detect balanced" $ expect $
|
test "detect balanced" $ expect $
|
||||||
isTransactionBalanced Nothing $ Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
isTransactionBalanced Nothing $ Transaction 0 "" nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||||
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
||||||
,posting{paccount="c", pamount=Mixed [usd (-1.00)]}
|
,posting{paccount="c", pamount=Mixed [usd (-1.00)]}
|
||||||
] ""
|
]
|
||||||
|
|
||||||
,test "detect unbalanced" $ expect $
|
,test "detect unbalanced" $ expect $
|
||||||
not $ isTransactionBalanced Nothing $ Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
not $ isTransactionBalanced Nothing $ Transaction 0 "" nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||||
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
||||||
,posting{paccount="c", pamount=Mixed [usd (-1.01)]}
|
,posting{paccount="c", pamount=Mixed [usd (-1.01)]}
|
||||||
] ""
|
]
|
||||||
|
|
||||||
,test "detect unbalanced, one posting" $ expect $
|
,test "detect unbalanced, one posting" $ expect $
|
||||||
not $ isTransactionBalanced Nothing $ Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
not $ isTransactionBalanced Nothing $ Transaction 0 "" nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||||
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
||||||
] ""
|
]
|
||||||
|
|
||||||
,test "one zero posting is considered balanced for now" $ expect $
|
,test "one zero posting is considered balanced for now" $ expect $
|
||||||
isTransactionBalanced Nothing $ Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
isTransactionBalanced Nothing $ Transaction 0 "" nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||||
[posting{paccount="b", pamount=Mixed [usd 0]}
|
[posting{paccount="b", pamount=Mixed [usd 0]}
|
||||||
] ""
|
]
|
||||||
|
|
||||||
,test "virtual postings don't need to balance" $ expect $
|
,test "virtual postings don't need to balance" $ expect $
|
||||||
isTransactionBalanced Nothing $ Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
isTransactionBalanced Nothing $ Transaction 0 "" nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||||
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
||||||
,posting{paccount="c", pamount=Mixed [usd (-1.00)]}
|
,posting{paccount="c", pamount=Mixed [usd (-1.00)]}
|
||||||
,posting{paccount="d", pamount=Mixed [usd 100], ptype=VirtualPosting}
|
,posting{paccount="d", pamount=Mixed [usd 100], ptype=VirtualPosting}
|
||||||
] ""
|
]
|
||||||
|
|
||||||
,test "balanced virtual postings need to balance among themselves" $ expect $
|
,test "balanced virtual postings need to balance among themselves" $ expect $
|
||||||
not $ isTransactionBalanced Nothing $ Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
not $ isTransactionBalanced Nothing $ Transaction 0 "" nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||||
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
||||||
,posting{paccount="c", pamount=Mixed [usd (-1.00)]}
|
,posting{paccount="c", pamount=Mixed [usd (-1.00)]}
|
||||||
,posting{paccount="d", pamount=Mixed [usd 100], ptype=BalancedVirtualPosting}
|
,posting{paccount="d", pamount=Mixed [usd 100], ptype=BalancedVirtualPosting}
|
||||||
] ""
|
]
|
||||||
|
|
||||||
,test "balanced virtual postings need to balance among themselves (2)" $ expect $
|
,test "balanced virtual postings need to balance among themselves (2)" $ expect $
|
||||||
isTransactionBalanced Nothing $ Transaction 0 nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
isTransactionBalanced Nothing $ Transaction 0 "" nullsourcepos (parsedate "2009/01/01") Nothing Unmarked "" "a" "" []
|
||||||
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
[posting{paccount="b", pamount=Mixed [usd 1.00]}
|
||||||
,posting{paccount="c", pamount=Mixed [usd (-1.00)]}
|
,posting{paccount="c", pamount=Mixed [usd (-1.00)]}
|
||||||
,posting{paccount="d", pamount=Mixed [usd 100], ptype=BalancedVirtualPosting}
|
,posting{paccount="d", pamount=Mixed [usd 100], ptype=BalancedVirtualPosting}
|
||||||
,posting{paccount="3", pamount=Mixed [usd (-100)], ptype=BalancedVirtualPosting}
|
,posting{paccount="3", pamount=Mixed [usd (-100)], ptype=BalancedVirtualPosting}
|
||||||
] ""
|
]
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -302,8 +302,9 @@ instance NFData GenericSourcePos
|
|||||||
-- prevents the constraint ‘(Data p0)’ from being solved.
|
-- prevents the constraint ‘(Data p0)’ from being solved.
|
||||||
-- Probable fix: use a type annotation to specify what ‘p0’ should be.
|
-- Probable fix: use a type annotation to specify what ‘p0’ should be.
|
||||||
data Transaction = Transaction {
|
data Transaction = Transaction {
|
||||||
tindex :: Integer, -- ^ this transaction's 1-based position in the input stream, or 0 when not available
|
tindex :: Integer, -- ^ this transaction's 1-based position in the transaction stream, or 0 when not available
|
||||||
tsourcepos :: GenericSourcePos,
|
tprecedingcomment :: Text, -- ^ any comment lines immediately preceding this transaction
|
||||||
|
tsourcepos :: GenericSourcePos, -- ^ the file position where the date starts
|
||||||
tdate :: Day,
|
tdate :: Day,
|
||||||
tdate2 :: Maybe Day,
|
tdate2 :: Maybe Day,
|
||||||
tstatus :: Status,
|
tstatus :: Status,
|
||||||
@ -311,8 +312,7 @@ data Transaction = Transaction {
|
|||||||
tdescription :: Text,
|
tdescription :: Text,
|
||||||
tcomment :: Text, -- ^ this transaction's comment lines, as a single non-indented multi-line string
|
tcomment :: Text, -- ^ this transaction's comment lines, as a single non-indented multi-line string
|
||||||
ttags :: [Tag], -- ^ tag names and values, extracted from the comment
|
ttags :: [Tag], -- ^ tag names and values, extracted from the comment
|
||||||
tpostings :: [Posting], -- ^ this transaction's postings
|
tpostings :: [Posting] -- ^ this transaction's postings
|
||||||
tpreceding_comment_lines :: Text -- ^ any comment lines immediately preceding this transaction
|
|
||||||
} deriving (Eq,Typeable,Data,Generic,Show)
|
} deriving (Eq,Typeable,Data,Generic,Show)
|
||||||
|
|
||||||
instance NFData Transaction
|
instance NFData Transaction
|
||||||
|
|||||||
@ -746,7 +746,7 @@ transactionFromCsvRecord sourcepos rules record = t
|
|||||||
tcode = T.pack code,
|
tcode = T.pack code,
|
||||||
tdescription = T.pack description,
|
tdescription = T.pack description,
|
||||||
tcomment = T.pack comment,
|
tcomment = T.pack comment,
|
||||||
tpreceding_comment_lines = T.pack precomment,
|
tprecedingcomment = T.pack precomment,
|
||||||
tpostings =
|
tpostings =
|
||||||
[posting {paccount=account1, pamount=amount1, ptransaction=Just t, pbalanceassertion=toAssertion <$> balance}
|
[posting {paccount=account1, pamount=amount1, ptransaction=Just t, pbalanceassertion=toAssertion <$> balance}
|
||||||
,posting {paccount=account2, pamount=amount2, ptransaction=Just t}
|
,posting {paccount=account2, pamount=amount2, ptransaction=Just t}
|
||||||
|
|||||||
@ -573,7 +573,7 @@ transactionp = do
|
|||||||
postings <- postingsp (Just year)
|
postings <- postingsp (Just year)
|
||||||
endpos <- getSourcePos
|
endpos <- getSourcePos
|
||||||
let sourcepos = journalSourcePos startpos endpos
|
let sourcepos = journalSourcePos startpos endpos
|
||||||
return $ txnTieKnot $ Transaction 0 sourcepos date edate status code description comment tags postings ""
|
return $ txnTieKnot $ Transaction 0 "" sourcepos date edate status code description comment tags postings
|
||||||
|
|
||||||
--- ** postings
|
--- ** postings
|
||||||
|
|
||||||
@ -760,7 +760,7 @@ tests_JournalReader = tests "JournalReader" [
|
|||||||
])
|
])
|
||||||
nulltransaction{
|
nulltransaction{
|
||||||
tsourcepos=JournalSourcePos "" (1,7), -- XXX why 7 here ?
|
tsourcepos=JournalSourcePos "" (1,7), -- XXX why 7 here ?
|
||||||
tpreceding_comment_lines="",
|
tprecedingcomment="",
|
||||||
tdate=fromGregorian 2012 5 14,
|
tdate=fromGregorian 2012 5 14,
|
||||||
tdate2=Just $ fromGregorian 2012 5 15,
|
tdate2=Just $ fromGregorian 2012 5 15,
|
||||||
tstatus=Unmarked,
|
tstatus=Unmarked,
|
||||||
|
|||||||
@ -198,7 +198,7 @@ Right samplejournal2 =
|
|||||||
[posting {paccount="assets:bank:checking", pamount=Mixed [usd 1]}
|
[posting {paccount="assets:bank:checking", pamount=Mixed [usd 1]}
|
||||||
,posting {paccount="income:salary", pamount=missingmixedamt}
|
,posting {paccount="income:salary", pamount=missingmixedamt}
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -537,7 +537,7 @@ journal7 = nulljournal {jtxns =
|
|||||||
["assets:cash" `post` usd 4.82
|
["assets:cash" `post` usd 4.82
|
||||||
,"equity:opening balances" `post` usd (-4.82)
|
,"equity:opening balances" `post` usd (-4.82)
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
txnTieKnot Transaction {
|
txnTieKnot Transaction {
|
||||||
@ -554,7 +554,7 @@ journal7 = nulljournal {jtxns =
|
|||||||
["expenses:vacation" `post` usd 179.92
|
["expenses:vacation" `post` usd 179.92
|
||||||
,"assets:checking" `post` usd (-179.92)
|
,"assets:checking" `post` usd (-179.92)
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
txnTieKnot Transaction {
|
txnTieKnot Transaction {
|
||||||
@ -571,7 +571,7 @@ journal7 = nulljournal {jtxns =
|
|||||||
["assets:saving" `post` usd 200
|
["assets:saving" `post` usd 200
|
||||||
,"assets:checking" `post` usd (-200)
|
,"assets:checking" `post` usd (-200)
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
txnTieKnot Transaction {
|
txnTieKnot Transaction {
|
||||||
@ -588,7 +588,7 @@ journal7 = nulljournal {jtxns =
|
|||||||
["expenses:food:dining" `post` usd 4.82
|
["expenses:food:dining" `post` usd 4.82
|
||||||
,"assets:cash" `post` usd (-4.82)
|
,"assets:cash" `post` usd (-4.82)
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
txnTieKnot Transaction {
|
txnTieKnot Transaction {
|
||||||
@ -605,7 +605,7 @@ journal7 = nulljournal {jtxns =
|
|||||||
["expenses:phone" `post` usd 95.11
|
["expenses:phone" `post` usd 95.11
|
||||||
,"assets:checking" `post` usd (-95.11)
|
,"assets:checking" `post` usd (-95.11)
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
txnTieKnot Transaction {
|
txnTieKnot Transaction {
|
||||||
@ -622,7 +622,7 @@ journal7 = nulljournal {jtxns =
|
|||||||
["liabilities:credit cards:discover" `post` usd 80
|
["liabilities:credit cards:discover" `post` usd 80
|
||||||
,"assets:checking" `post` usd (-80)
|
,"assets:checking" `post` usd (-80)
|
||||||
],
|
],
|
||||||
tpreceding_comment_lines=""
|
tprecedingcomment=""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user