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 Rank2Types #-}
{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NamedFieldPuns #-}
module Hledger.Data.Transaction ( module Hledger.Data.Transaction (
-- * Transaction -- * Transaction
nulltransaction, nulltransaction,
@ -55,6 +56,7 @@ module Hledger.Data.Transaction (
sourceFirstLine, sourceFirstLine,
showGenericSourcePos, showGenericSourcePos,
annotateErrorWithTransaction, annotateErrorWithTransaction,
transactionFile,
-- * tests -- * tests
tests_Transaction tests_Transaction
) )
@ -628,6 +630,13 @@ transactionMapPostings f t@Transaction{tpostings=ps} = t{tpostings=map f ps}
transactionMapPostingAmounts :: (Amount -> Amount) -> Transaction -> Transaction transactionMapPostingAmounts :: (Amount -> Amount) -> Transaction -> Transaction
transactionMapPostingAmounts f = transactionMapPostings (postingTransformAmount (mapMixedAmount f)) 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
tests_Transaction :: TestTree tests_Transaction :: TestTree