lib: transactionFile

This commit is contained in:
Simon Michael 2021-03-03 06:44:25 -08:00
parent 642ad24b0e
commit 2505c69f80

View File

@ -14,6 +14,7 @@ tags.
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NamedFieldPuns #-}
module Hledger.Data.Transaction (
-- * Transaction
nulltransaction,
@ -55,6 +56,7 @@ module Hledger.Data.Transaction (
sourceFirstLine,
showGenericSourcePos,
annotateErrorWithTransaction,
transactionFile,
-- * tests
tests_Transaction
)
@ -628,6 +630,13 @@ transactionMapPostings f t@Transaction{tpostings=ps} = t{tpostings=map f ps}
transactionMapPostingAmounts :: (Amount -> Amount) -> Transaction -> Transaction
transactionMapPostingAmounts f = transactionMapPostings (postingTransformAmount (mapMixedAmount f))
-- | The file path from which this transaction was parsed.
transactionFile :: Transaction -> FilePath
transactionFile Transaction{tsourcepos} =
case tsourcepos of
GenericSourcePos f _ _ -> f
JournalSourcePos f _ -> f
-- tests
tests_Transaction :: TestTree