-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parses U.S. federal Thrift Savings Plan PDF quarterly statements -- -- See the TsParse module for details. -- -- There are also multiple tests in the package, but these are not built -- by default. To get the tests, build with the test flag. -- -- Binaries you will get if you build with the test flag: -- -- @package tsparse @version 0.4.0.0 -- | Parses U.S. federal Thrift Savings Plan (TSP) statements. -- -- This module works with PDF TSP statements downloaded from the TSP web -- site. It works with the statement format used as of July 2013. The -- format recently changed to allow for Roth contributions. This works on -- civilian, FERS statements; maybe it works on others, but I cannot test -- these (if you test these and find bugs, send me patches and I will -- merge them.) -- -- You need to have the pdftotext program installed and available on your -- PATH. This program is part of the poppler project. On Debian GNU/Linux -- systems, it is part of the poppler-utils package. module TsParse -- | Any data type that is Dollars on the TSP statement. type Dollars = Decimal -- | Any data type that is a number of shares on the TSP statement. type Shares = Decimal -- | A list of words that indicates the transaction type. Each string in -- this list will not have any spaces in it. type TxnType = [String] -- | Represents the entire YOUR TRANSACTION DETAIL BY SOURCE -- section. data BySource BySource :: BySourceBeginningBal -> [BySourcePosting] -> BySourceGainLoss -> BySourceEndingBal -> BySource bsBeginningBal :: BySource -> BySourceBeginningBal bsTxns :: BySource -> [BySourcePosting] bsGainLoss :: BySource -> BySourceGainLoss bsEndingBal :: BySource -> BySourceEndingBal -- | The TSP statement has several lines in the YOUR TRANSACTION DETAIL -- BY SOURCE section that contain summary data: Beginning -- Balance, Gain or Loss This Quarter, and Ending -- Balance. Since the columns in these lines are all the same they -- are all represented by this single type. Type synonyms -- BySourceBeginningBal, BySourceGainLoss, and -- BySourceEndingBal are used as appropriate. data BySourceSummary BySourceSummary :: Dollars -> Dollars -> Dollars -> Dollars -> Dollars -> BySourceSummary bssTraditional :: BySourceSummary -> Dollars bssRoth :: BySourceSummary -> Dollars bssAuto :: BySourceSummary -> Dollars bssMatching :: BySourceSummary -> Dollars bssTotal :: BySourceSummary -> Dollars -- | YOUR TRANSACTION DETAIL BY SOURCE Beginning Balance. type BySourceBeginningBal = BySourceSummary -- | YOUR TRANSACTION DETAIL BY SOURCE Gain or Loss This Quarter. type BySourceGainLoss = BySourceSummary -- | YOUR TRANSACTION DETAIL BY SOURCE Ending Balance. type BySourceEndingBal = BySourceSummary data BySourcePosting BySourcePosting :: String -> Day -> TxnType -> Dollars -> Dollars -> Dollars -> Dollars -> Dollars -> BySourcePosting bspPayrollOffice :: BySourcePosting -> String bspPostingDate :: BySourcePosting -> Day bspTxnType :: BySourcePosting -> TxnType bspTraditional :: BySourcePosting -> Dollars bspRoth :: BySourcePosting -> Dollars bspAutomatic :: BySourcePosting -> Dollars bspMatching :: BySourcePosting -> Dollars bspTotal :: BySourcePosting -> Dollars -- | The name of a fund, eg C Fund. This is a list of words; each -- word will not contain any spaces. type FundName = [String] -- | A single fund in the YOUR TRANSACTION DETAIL BY FUND section -- (e.g. the G Fund, L 2040 Fund, etc.) data ByFund ByFund :: FundName -> ByFundBeginningBal -> [ByFundPosting] -> ByFundGainLoss -> ByFundEndingBal -> ByFund bfFundName :: ByFund -> FundName bfBeginningBal :: ByFund -> ByFundBeginningBal bfPostings :: ByFund -> [ByFundPosting] bfGainLoss :: ByFund -> ByFundGainLoss bfEndingBal :: ByFund -> ByFundEndingBal -- | The beginning balance in a YOUR TRANSACTION DETAIL BY FUND -- section. data ByFundBeginningBal ByFundBeginningBal :: Dollars -> Shares -> Dollars -> ByFundBeginningBal bfbbSharePrice :: ByFundBeginningBal -> Dollars bfbbNumShares :: ByFundBeginningBal -> Shares bfbbDollarBalance :: ByFundBeginningBal -> Dollars -- | Gain or Loss This Quarter in the YOUR TRANSACTION DETAIL BY -- FUND section. data ByFundGainLoss ByFundGainLoss :: Dollars -> ByFundGainLoss bfglDollarBalance :: ByFundGainLoss -> Dollars -- | Ending balance in the YOUR TRANSACTION DETAIL BY FUND -- section. data ByFundEndingBal ByFundEndingBal :: Dollars -> Shares -> Dollars -> ByFundEndingBal bfebSharePrice :: ByFundEndingBal -> Dollars bfebNumShares :: ByFundEndingBal -> Shares bfebDollarBalance :: ByFundEndingBal -> Dollars -- | A single posting in the YOUR TRANSACTION DETAIL BY FUND -- section. data ByFundPosting ByFundPosting :: Day -> [String] -> Dollars -> Dollars -> Dollars -> Dollars -> Shares -> ByFundPosting bfpPostingDate :: ByFundPosting -> Day bfpTxnType :: ByFundPosting -> [String] bfpTraditional :: ByFundPosting -> Dollars bfpRoth :: ByFundPosting -> Dollars bfpTotal :: ByFundPosting -> Dollars bfpSharePrice :: ByFundPosting -> Dollars bfpNumShares :: ByFundPosting -> Shares -- | All data that is parsed from the TSP statement is in this type. The -- parser does not attempt to parse any of the data that is on Page 1 of -- the PDF; most of this data all appears elsewhere on the statement and -- can be calculated using the data that is in this type (and besides, -- the data on Page 1 is in a multi-column format that would be difficult -- to parse; since the data is all elsewhere, it's not worth the effort.) -- One exception is the investment allocation for future contributions, -- which does not appear elsewhere. -- -- In addition, the statement contains a quarterly account summary. This -- also is not parsed because it can be derived from all the data that is -- elsewhere on the statement. data TspStatement TspStatement :: BySource -> [ByFund] -> TspStatement tspDetailBySource :: TspStatement -> BySource tspDetailByFund :: TspStatement -> [ByFund] -- | Parses a plain text TSP statement. The input must be generated by the -- pdftotext program. This library was tested against pdftotext version -- 0.18.4, which came with Debian Wheezy. parseTsp :: Parser TspStatement -- | Parses a TSP statement from a file. This function relies upon the -- pdftotext program. This program must exist somewhere in your -- PATH. This library was tested against pdftotext version 0.18.4, which -- came with Debian Wheezy. parseTspFromFile :: String -> IO TspStatement class Pretty a pretty :: Pretty a => a -> Doc instance Eq BySourcePosting instance Ord BySourcePosting instance Show BySourcePosting instance Eq BySourceSummary instance Ord BySourceSummary instance Show BySourceSummary instance Eq ByFundPosting instance Ord ByFundPosting instance Show ByFundPosting instance Eq ByFundBeginningBal instance Ord ByFundBeginningBal instance Show ByFundBeginningBal instance Eq ByFundGainLoss instance Ord ByFundGainLoss instance Show ByFundGainLoss instance Eq ByFundEndingBal instance Ord ByFundEndingBal instance Show ByFundEndingBal instance Eq BySource instance Ord BySource instance Show BySource instance Eq ByFund instance Ord ByFund instance Show ByFund instance Eq TspStatement instance Ord TspStatement instance Show TspStatement instance Pretty TspStatement instance Pretty ByFund instance Pretty BySource instance Pretty ByFundEndingBal instance Pretty ByFundGainLoss instance Pretty ByFundBeginningBal instance Pretty ByFundPosting instance Pretty BySourceSummary instance Pretty BySourcePosting instance Pretty Day instance Pretty [String] instance Pretty String instance Pretty Decimal