Safe Haskell | None |
---|
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.
- type Dollars = Decimal
- type Shares = Decimal
- data BySource = BySource {}
- data BySourceSummary = BySourceSummary {}
- type BySourceBeginningBal = BySourceSummary
- type BySourceGainLoss = BySourceSummary
- type BySourceEndingBal = BySourceSummary
- data BySourcePosting = BySourcePosting {}
- data ByFund = ByFund {}
- data ByFundBeginningBal = ByFundBeginningBal {}
- data ByFundGainLoss = ByFundGainLoss {}
- data ByFundEndingBal = ByFundEndingBal {}
- data ByFundPosting = ByFundPosting {}
- data TspStatement = TspStatement {}
- parseTsp :: Parser TspStatement
- parseTspFromFile :: String -> IO TspStatement
- class Pretty a where
Data types
Basic types
Transaction Detail By Source
Represents the entire YOUR TRANSACTION DETAIL BY SOURCE
section.
data BySourceSummary Source
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.
BySourceSummary | |
|
type BySourceBeginningBal = BySourceSummarySource
YOUR TRANSACTION DETAIL BY SOURCE
Beginning Balance.
type BySourceGainLoss = BySourceSummarySource
YOUR TRANSACTION DETAIL BY SOURCE
Gain or Loss This Quarter.
type BySourceEndingBal = BySourceSummarySource
YOUR TRANSACTION DETAIL BY SOURCE
Ending Balance.
data BySourcePosting Source
BySourcePosting | |
|
Transaction Detail By Fund
A single fund in the YOUR TRANSACTION DETAIL BY FUND
section
(e.g. the G Fund
, L 2040 Fund
, etc.)
data ByFundBeginningBal Source
The beginning balance in a YOUR TRANSACTION DETAIL BY FUND
section.
data ByFundGainLoss Source
Gain or Loss This Quarter in the YOUR TRANSACTION DETAIL BY
FUND
section.
data ByFundEndingBal Source
Ending balance in the YOUR TRANSACTION DETAIL BY FUND
section.
data ByFundPosting Source
A single posting in the YOUR TRANSACTION DETAIL BY FUND
section.
ByFundPosting | |
|
TSP statement
data TspStatement Source
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.
Parsing a TSP statement
parseTsp :: Parser TspStatementSource
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.
:: String | Filename |
-> IO 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.