ofx-0.4.4.0: Parser for OFX data

Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.OFX

Contents

- Error handling
- The OFX data tree
- Manipulating the OFX tag tree
- Extracting specific data
- Types to represent specific OFX data
- Running parsers
- Parsec parsers
- Pretty printers

Description

Parser for downloaded OFX files.

This parser was written based on the OFX version 1.03 specification, which is available at

http://www.ofx.net

It will probably work on earlier versions of OFX without incident. However, it may or may not not work on newer versions of OFX, which are XML based (this version of OFX is SGML based.)

It will also parse QFX files, which are OFX files with minor proprietary additions by Intuit, the maker of Quicken.

An OFX file consists of three parts: the HTTP headers (which this parser does NOT handle because typically they will not show up in files downloaded to disk), the OFX headers, and the OFX data. This parser handles the OFX headers and the OFX data.

The parser in this module simply parses the tags and data into a tree, which you can manipulate with other functions. Some functions are provided to find the transactions in the tree and place them into a `Transaction` type, which is the data you are most likely interested in. If you are interested in other data you can query the `Tag` tree for what you need.

The `ofx` package includes two executable files that you can use at the command line to test the library and see how it works. The `renderTransactions` executable reads an OFX file on standard input, runs it through the `prettyRenderTransactions` function, and prints the result to standard output. The `renderOfx` executable reads an OFX file on standard input, runs it through the `prettyRenderOfxFile` function, and prints the result to standard output.

Synopsis

- type Err = Either String
- type HeaderTag = String
- type HeaderValue = String
- data OFXHeader = OFXHeader HeaderTag HeaderValue
- type TagName = String
- type TagData = String
- data Tag = Tag TagName (Either TagData [Tag])
- data OFXFile = OFXFile {
  - fHeader :: [OFXHeader]
  - fTag :: Tag
  }
- find :: TagName -> Tag -> [Tag]
- findPath :: [TagName] -> Tag -> Maybe Tag
- tagData :: Tag -> Maybe TagData
- pathData :: [TagName] -> OFXFile -> Maybe TagData
- findData :: TagName -> Tag -> Maybe TagData
- fiName :: OFXFile -> Maybe TagData
- creditCardNumber :: OFXFile -> Maybe TagData
- bankAccountNumber :: OFXFile -> Maybe TagData
- accountNumber :: OFXFile -> Maybe TagData
- data Transaction = Transaction {
  - txTRNTYPE :: TrnType
  - txDTPOSTED :: ZonedTime
  - txDTUSER :: Maybe ZonedTime
  - txDTAVAIL :: Maybe ZonedTime
  - txTRNAMT :: String
  - txFITID :: String
  - txCORRECTFITID :: Maybe String
  - txCORRECTACTION :: Maybe CorrectAction
  - txSRVRTID :: Maybe String
  - txCHECKNUM :: Maybe String
  - txREFNUM :: Maybe String
  - txSIC :: Maybe String
  - txPAYEEID :: Maybe String
  - txPayeeInfo :: Maybe (Either String Payee)
  - txAccountTo :: Maybe (Either BankAcctTo CCAcctTo)
  - txMEMO :: Maybe String
  - txCurrency :: Maybe (Either Currency OrigCurrency)
  }
- transaction :: Tag -> Err Transaction
- transactions :: OFXFile -> Err [Transaction]
- data TrnType
  - = TCREDIT
  - | TDEBIT
  - | TINT
  - | TDIV
  - | TFEE
  - | TSRVCHG
  - | TDEP
  - | TATM
  - | TPOS
  - | TXFER
  - | TCHECK
  - | TPAYMENT
  - | TCASH
  - | TDIRECTDEP
  - | TDIRECTDEBIT
  - | TREPEATPMT
  - | TOTHER
- trnType :: TagData -> Maybe TrnType
- data Payee = Payee {
  - peNAME :: String
  - peADDR1 :: String
  - peADDR2 :: Maybe String
  - peADDR3 :: Maybe String
  - peCITY :: String
  - peSTATE :: String
  - pePOSTALCODE :: String
  - peCOUNTRY :: Maybe String
  - pePHONE :: String
  }
- payee :: Tag -> Maybe (Err Payee)
- data CorrectAction
  - = REPLACE
  - | DELETE
- data BankAcctTo = BankAcctTo {
  - btBANKID :: String
  - btBRANCHID :: Maybe String
  - btACCTID :: String
  - btACCTTYPE :: AcctType
  - btACCTKEY :: Maybe String
  }
- bankAcctTo :: Tag -> Maybe (Err BankAcctTo)
- data CCAcctTo = CCAcctTo {
  - ctACCTID :: String
  - ctACCTKEY :: Maybe String
  }
- ccAcctTo :: Tag -> Maybe (Err CCAcctTo)
- data AcctType
  - = ACHECKING
  - | ASAVINGS
  - | AMONEYMRKT
  - | ACREDITLINE
- acctType :: String -> Err AcctType
- data CurrencyData = CurrencyData {
  - cdCURRATE :: String
  - cdCURSYM :: String
  }
- currencyData :: Tag -> Err CurrencyData
- data Currency = Currency CurrencyData
- currency :: Tag -> Maybe (Err Currency)
- data OrigCurrency = OrigCurrency CurrencyData
- origCurrency :: Tag -> Maybe (Err OrigCurrency)
- parseOfxFile :: String -> Err OFXFile
- loadOfxFile :: FilePath -> IO OFXFile
- parseTransactions :: String -> Err [Transaction]
- loadTransactions :: FilePath -> IO [Transaction]
- prettyRenderOfxFile :: String -> String
- prettyRenderTransactions :: String -> String
- ofxFile :: Parser OFXFile
- newline :: Parser ()
- escChar :: Parser Char
- header :: Parser OFXHeader
- openingTag :: Parser TagName
- closingTag :: TagName -> Parser ()
- tag :: Parser Tag
- date :: Parser ZonedTime
- time :: Parser (TimeOfDay, TimeZone)
- tzOffset :: Parser TimeZone
- pPayee :: Payee -> Doc
- pTransaction :: Transaction -> Doc
- pTag :: Tag -> Doc
- pHeader :: OFXHeader -> Doc
- pFile :: OFXFile -> Doc
- pEither :: (a -> Doc) -> (b -> Doc) -> Either a b -> Doc
- pMaybe :: (a -> Doc) -> Maybe a -> Doc
- pList :: [Doc] -> Doc
- label :: String -> Doc -> Doc
- pExceptional :: (e -> Doc) -> (a -> Doc) -> Either e a -> Doc

# Error handling

type Err = Either String Source #

Error handling. Errors are indicated with a Left String; successes with a Right.

# The OFX data tree

type HeaderTag = String Source #

Headers consists of simple `tag:value` pairs; this represents the tag.

type HeaderValue = String Source #

The value in an OFX header.

data OFXHeader Source #

An OFX file starts with a number of headers, which take the form `tag:value` followed by a newline. These are followed by a blank line.

Constructors

OFXHeader HeaderTag HeaderValue |

#### Instances

Instances details

Data OFXHeader Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OFXHeader -> c OFXHeader Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c OFXHeader Source #

toConstr :: OFXHeader -> Constr Source #

dataTypeOf :: OFXHeader -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c OFXHeader) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OFXHeader) Source #

gmapT :: (forall b. Data b => b -> b) -> OFXHeader -> OFXHeader Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OFXHeader -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OFXHeader -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> OFXHeader -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> OFXHeader -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OFXHeader -> m OFXHeader Source #

Generic OFXHeader Source # |
Instance details Defined in Data.OFX Associated Types type Rep OFXHeader :: Type -> Type Source # Methods from :: OFXHeader -> Rep OFXHeader x Source # to :: Rep OFXHeader x -> OFXHeader Source #
Read OFXHeader Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS OFXHeader Source # readList :: ReadS [OFXHeader] Source # readPrec :: ReadPrec OFXHeader Source # readListPrec :: ReadPrec [OFXHeader] Source #
Show OFXHeader Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> OFXHeader -> ShowS Source # show :: OFXHeader -> String Source # showList :: [OFXHeader] -> ShowS Source #
Eq OFXHeader Source # |
Instance details Defined in Data.OFX Methods (==) :: OFXHeader -> OFXHeader -> Bool Source # (/=) :: OFXHeader -> OFXHeader -> Bool Source #
type Rep OFXHeader Source # |

Instance details

Defined in Data.OFX

type Rep OFXHeader = D1 ('MetaData "OFXHeader" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) (C1 ('MetaCons "OFXHeader" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeaderTag) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeaderValue)))

type TagName = String Source #

The name of an OFX tag

type TagData = String Source #

The data accompanying an OFX tag.

data Tag Source #

The main OFX data consists of a series of tags. OFX 1.03 is SGML, not XML. This means that opening tags need not have closing tags. In OFX, a tag either has data and no child elements, or it has no data and it has child elements.

Constructors

Tag TagName (Either TagData [Tag]) |

#### Instances

Instances details

Data Tag Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Tag -> c Tag Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Tag Source #

toConstr :: Tag -> Constr Source #

dataTypeOf :: Tag -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Tag) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag) Source #

gmapT :: (forall b. Data b => b -> b) -> Tag -> Tag Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Tag -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Tag -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tag -> m Tag Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tag -> m Tag Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tag -> m Tag Source #

Generic Tag Source # |
Instance details Defined in Data.OFX Associated Types type Rep Tag :: Type -> Type Source # Methods from :: Tag -> Rep Tag x Source # to :: Rep Tag x -> Tag Source #
Read Tag Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS Tag Source # readList :: ReadS [Tag] Source # readPrec :: ReadPrec Tag Source # readListPrec :: ReadPrec [Tag] Source #
Show Tag Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> Tag -> ShowS Source # show :: Tag -> String Source # showList :: [Tag] -> ShowS Source #
Eq Tag Source # |
Instance details Defined in Data.OFX Methods (==) :: Tag -> Tag -> Bool Source # (/=) :: Tag -> Tag -> Bool Source #
type Rep Tag Source # |

Instance details

Defined in Data.OFX

type Rep Tag = D1 ('MetaData "Tag" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) (C1 ('MetaCons "Tag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TagName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Either TagData [Tag]))))

data OFXFile Source #

All the data from an OFX file.

Constructors

OFXFile |

Fields

- fHeader :: [OFXHeader]
- fTag :: Tag

  All the data will be contained in a root tag with the TagName `OFX`.

#### Instances

Instances details

Data OFXFile Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OFXFile -> c OFXFile Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c OFXFile Source #

toConstr :: OFXFile -> Constr Source #

dataTypeOf :: OFXFile -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c OFXFile) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OFXFile) Source #

gmapT :: (forall b. Data b => b -> b) -> OFXFile -> OFXFile Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OFXFile -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OFXFile -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> OFXFile -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> OFXFile -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OFXFile -> m OFXFile Source #

Generic OFXFile Source # |
Instance details Defined in Data.OFX Associated Types type Rep OFXFile :: Type -> Type Source # Methods from :: OFXFile -> Rep OFXFile x Source # to :: Rep OFXFile x -> OFXFile Source #
Read OFXFile Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS OFXFile Source # readList :: ReadS [OFXFile] Source # readPrec :: ReadPrec OFXFile Source # readListPrec :: ReadPrec [OFXFile] Source #
Show OFXFile Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> OFXFile -> ShowS Source # show :: OFXFile -> String Source # showList :: [OFXFile] -> ShowS Source #
Eq OFXFile Source # |
Instance details Defined in Data.OFX Methods (==) :: OFXFile -> OFXFile -> Bool Source # (/=) :: OFXFile -> OFXFile -> Bool Source #
type Rep OFXFile Source # |
Instance details Defined in Data.OFX type Rep OFXFile = D1 ('MetaData "OFXFile" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) (C1 ('MetaCons "OFXFile" 'PrefixI 'True) (S1 ('MetaSel ('Just "fHeader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [OFXHeader]) :*: S1 ('MetaSel ('Just "fTag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Tag)))

# Manipulating the OFX tag tree

find :: TagName -> Tag -> [Tag] Source #

Finds child tags with the given name. When a tag is found, that tag is not searched for further children with the same name.

findPath :: [TagName] -> Tag -> Maybe Tag Source #

Descends through a tree of tags to find a tag at a specific location in the tree. Fails if any part of the search fails. For example, to find the financial institution ORG tag, where `t` is the root `OFX` tag:

    findPath ["SIGNONMSGSRSV1", "SONRS", "FI", "ORG"] t

tagData :: Tag -> Maybe TagData Source #

Gets the data from a tag, if it is a tag with data.

pathData :: [TagName] -> OFXFile -> Maybe TagData Source #

Goes to a certain path in the tag hierarchy and pulls the requested data, if the tag is present and it is a data tag. For example, to get the name of the financial institution:

    pathData ["SIGNONMSGSRSV1", "SONRS", "FI", "ORG"] f

findData :: TagName -> Tag -> Maybe TagData Source #

Finds the first tag (either this tag or any children) that has the given name and that is a data tag (not an aggregate tag.) If no data tag with the given name is found, returns Nothing.

# Extracting specific data

fiName :: OFXFile -> Maybe TagData Source #

Gets the name of the financial institution from the FI tag, if available. The OFX spec does not require this tag to be present.

creditCardNumber :: OFXFile -> Maybe TagData Source #

Gets the credit card number, if available. The OFX spec does not require this tag to be present.

bankAccountNumber :: OFXFile -> Maybe TagData Source #

Gets the bank account number, if available. The OFX spec does not require this tag to be present.

accountNumber :: OFXFile -> Maybe TagData Source #

Gets either the credit card or bank account number, if available.

# Types to represent specific OFX data

data Transaction Source #

A single STMTTRN, see OFX spec section 11.4.2.3.1. This is most likely what you are interested in after downloading a statement from a bank.

Constructors

Transaction |

Fields

- txTRNTYPE :: TrnType

  Transaction type

- txDTPOSTED :: ZonedTime

  Date transaction was posted to account

- txDTUSER :: Maybe ZonedTime

  Date user initiated transaction, if known

- txDTAVAIL :: Maybe ZonedTime

  Date funds are available

- txTRNAMT :: String

  Amount of transaction. This is left as the string that was originally in the download. That means the transaction may include a plus or minus sign (no sign is the same as a plus sign.) According to section 3.2.9.2, amounts are always signed from the perspective of the customer.

  Typically negative amounts:

  - Investment buy amount, investment sell quantity
  - Bank statement debit amounts, checks, fees
  - Credit card purchases
  - Margin balance (unless the institution owes the client money)

  Typically positive amounts:

  - Investment sell amount, investment buy quantity
  - Bank statement credits
  - Credit card payments
  - Ledger balance (unless the account is overdrawn)

  Formats for amounts are described in 3.2.9.1. If there is no decimal point, there is an implied decimal point at the end of the value. Trailing and leading spaces "should" be stripped. Positive or minus is indicated with a leading sign; a plus sign is assumed if there is no sign.

  An amount has a maximum of 32 alphanumeric characters, including digits and punctuation.

  The radix point is indicated with either a period or a comma. Amounts "should" not include any digit grouping characters.

- txFITID :: String

  Transaction ID issued by financial institution. Used to detect duplicate downloads.

- txCORRECTFITID :: Maybe String

  If present, this indicates the FITID of a previously sent transaction that is corrected by this record. This transaction replaces or deletes the transaction that it corrects, based on the value of CORRECTACTION below.

- txCORRECTACTION :: Maybe CorrectAction

  See `CorrectAction` and `txCORRECTFITID`

- txSRVRTID :: Maybe String

  Server assigned transaction ID; used for transactions initiated by client, such as payment or funds transfer

- txCHECKNUM :: Maybe String

  Check or other reference number

- txREFNUM :: Maybe String

  Reference number that uniquely identifies the transaction. Can be used in addition to or instead of a CHECKNUM.

- txSIC :: Maybe String

  Standard Industrial Code

- txPAYEEID :: Maybe String

  Payee identifier if available

- txPayeeInfo :: Maybe (Either String Payee)

  Information on the payee. The OFX spec seems to be saying that every transaction must have either NAME, wich is "name of payee or description of transaction", or the Payee aggregate. The former is indicated with a Left, the latter with a Right.

- txAccountTo :: Maybe (Either BankAcctTo CCAcctTo)

  Information on a transfer. If this transaction wa sa transfer, this may contain information about the account being transferred to.

- txMEMO :: Maybe String

  Extra information not in NAME

- txCurrency :: Maybe (Either Currency OrigCurrency)

  Currency option. OFX spec says to choose either CURRENCY or ORIGCURRENCY.

#### Instances

Instances details

Data Transaction Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Transaction -> c Transaction Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Transaction Source #

toConstr :: Transaction -> Constr Source #

dataTypeOf :: Transaction -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Transaction) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Transaction) Source #

gmapT :: (forall b. Data b => b -> b) -> Transaction -> Transaction Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Transaction -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Transaction -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Transaction -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Transaction -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Transaction -> m Transaction Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Transaction -> m Transaction Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Transaction -> m Transaction Source #

Generic Transaction Source # |
Instance details Defined in Data.OFX Associated Types type Rep Transaction :: Type -> Type Source # Methods from :: Transaction -> Rep Transaction x Source # to :: Rep Transaction x -> Transaction Source #
Read Transaction Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS Transaction Source # readList :: ReadS [Transaction] Source # readPrec :: ReadPrec Transaction Source # readListPrec :: ReadPrec [Transaction] Source #
Show Transaction Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> Transaction -> ShowS Source # show :: Transaction -> String Source # showList :: [Transaction] -> ShowS Source #
type Rep Transaction Source # |

Instance details

Defined in Data.OFX

type Rep Transaction = D1 ('MetaData "Transaction" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) (C1 ('MetaCons "Transaction" 'PrefixI 'True) ((((S1 ('MetaSel ('Just "txTRNTYPE") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TrnType) :*: S1 ('MetaSel ('Just "txDTPOSTED") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ZonedTime)) :*: (S1 ('MetaSel ('Just "txDTUSER") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ZonedTime)) :*: S1 ('MetaSel ('Just "txDTAVAIL") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ZonedTime)))) :*: ((S1 ('MetaSel ('Just "txTRNAMT") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "txFITID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :*: (S1 ('MetaSel ('Just "txCORRECTFITID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String)) :*: S1 ('MetaSel ('Just "txCORRECTACTION") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe CorrectAction))))) :*: (((S1 ('MetaSel ('Just "txSRVRTID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String)) :*: S1 ('MetaSel ('Just "txCHECKNUM") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String))) :*: (S1 ('MetaSel ('Just "txREFNUM") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String)) :*: S1 ('MetaSel ('Just "txSIC") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String)))) :*: ((S1 ('MetaSel ('Just "txPAYEEID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String)) :*: S1 ('MetaSel ('Just "txPayeeInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Either String Payee)))) :*: (S1 ('MetaSel ('Just "txAccountTo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Either BankAcctTo CCAcctTo))) :*: (S1 ('MetaSel ('Just "txMEMO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String)) :*: S1 ('MetaSel ('Just "txCurrency") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Either Currency OrigCurrency)))))))))

transaction :: Tag -> Err Transaction Source #

Gets a single Transaction from a tag. The tag should be the one named STMTTRN. Fails with an error message if any required field was not present.

transactions :: OFXFile -> Err [Transaction] Source #

Pulls all Transactions from a file. Might fail if the OFX file does not conform to the specification (or if there are bugs in this library.) In case of the former, you can manually parse the transaction information yourself using functions like `pathData`. In case of the latter, please send bugreports :-)

data TrnType Source #

OFX transaction types. These are used in STMTTRN aggregates, see OFX spec section 11.4.2.3.1.1.

Constructors

TCREDIT |
TDEBIT |
TINT | Interest earned or paid (which it is depends on sign of amount)
TDIV | Dividend
TFEE |
TSRVCHG |
TDEP | Deposit
TATM | ATM debit or credit (which it is depends on sign of amount)
TPOS | Point of sale debit or credit (which it is depends on sign of amount)
TXFER | Transfer
TCHECK |
TPAYMENT | Electronic payment
TCASH | Cash withdrawal
TDIRECTDEP | Direct deposit
TDIRECTDEBIT | Merchant initiated debit
TREPEATPMT | Repeating payment / standing order
TOTHER |

#### Instances

Instances details

Data TrnType Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TrnType -> c TrnType Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TrnType Source #

toConstr :: TrnType -> Constr Source #

dataTypeOf :: TrnType -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TrnType) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TrnType) Source #

gmapT :: (forall b. Data b => b -> b) -> TrnType -> TrnType Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TrnType -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TrnType -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TrnType -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TrnType -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TrnType -> m TrnType Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TrnType -> m TrnType Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TrnType -> m TrnType Source #

Generic TrnType Source # |
Instance details Defined in Data.OFX Associated Types type Rep TrnType :: Type -> Type Source # Methods from :: TrnType -> Rep TrnType x Source # to :: Rep TrnType x -> TrnType Source #
Read TrnType Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS TrnType Source # readList :: ReadS [TrnType] Source # readPrec :: ReadPrec TrnType Source # readListPrec :: ReadPrec [TrnType] Source #
Show TrnType Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> TrnType -> ShowS Source # show :: TrnType -> String Source # showList :: [TrnType] -> ShowS Source #
Eq TrnType Source # |
Instance details Defined in Data.OFX Methods (==) :: TrnType -> TrnType -> Bool Source # (/=) :: TrnType -> TrnType -> Bool Source #
Ord TrnType Source # |
Instance details Defined in Data.OFX Methods compare :: TrnType -> TrnType -> Ordering Source # (<) :: TrnType -> TrnType -> Bool Source # (<=) :: TrnType -> TrnType -> Bool Source # (>) :: TrnType -> TrnType -> Bool Source # (>=) :: TrnType -> TrnType -> Bool Source # max :: TrnType -> TrnType -> TrnType Source # min :: TrnType -> TrnType -> TrnType Source #
type Rep TrnType Source # |

Instance details

Defined in Data.OFX

type Rep TrnType = D1 ('MetaData "TrnType" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) ((((C1 ('MetaCons "TCREDIT" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TDEBIT" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TINT" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TDIV" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "TFEE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TSRVCHG" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TDEP" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TATM" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "TPOS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TXFER" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TCHECK" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TPAYMENT" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "TCASH" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TDIRECTDEP" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TDIRECTDEBIT" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "TREPEATPMT" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TOTHER" 'PrefixI 'False) (U1 :: Type -> Type))))))

trnType :: TagData -> Maybe TrnType Source #

data Payee Source #

Constructors

Payee |

Fields

- peNAME :: String
- peADDR1 :: String
- peADDR2 :: Maybe String
- peADDR3 :: Maybe String
- peCITY :: String
- peSTATE :: String
- pePOSTALCODE :: String
- peCOUNTRY :: Maybe String
- pePHONE :: String

#### Instances

Instances details

Data Payee Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Payee -> c Payee Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Payee Source #

toConstr :: Payee -> Constr Source #

dataTypeOf :: Payee -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Payee) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Payee) Source #

gmapT :: (forall b. Data b => b -> b) -> Payee -> Payee Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Payee -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Payee -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Payee -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Payee -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Payee -> m Payee Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Payee -> m Payee Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Payee -> m Payee Source #

Generic Payee Source # |
Instance details Defined in Data.OFX Associated Types type Rep Payee :: Type -> Type Source # Methods from :: Payee -> Rep Payee x Source # to :: Rep Payee x -> Payee Source #
Read Payee Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS Payee Source # readList :: ReadS [Payee] Source # readPrec :: ReadPrec Payee Source # readListPrec :: ReadPrec [Payee] Source #
Show Payee Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> Payee -> ShowS Source # show :: Payee -> String Source # showList :: [Payee] -> ShowS Source #
Eq Payee Source # |
Instance details Defined in Data.OFX Methods (==) :: Payee -> Payee -> Bool Source # (/=) :: Payee -> Payee -> Bool Source #
type Rep Payee Source # |

Instance details

Defined in Data.OFX

type Rep Payee = D1 ('MetaData "Payee" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) (C1 ('MetaCons "Payee" 'PrefixI 'True) (((S1 ('MetaSel ('Just "peNAME") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "peADDR1") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :*: (S1 ('MetaSel ('Just "peADDR2") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String)) :*: S1 ('MetaSel ('Just "peADDR3") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String)))) :*: ((S1 ('MetaSel ('Just "peCITY") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "peSTATE") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :*: (S1 ('MetaSel ('Just "pePOSTALCODE") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Just "peCOUNTRY") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String)) :*: S1 ('MetaSel ('Just "pePHONE") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))))))

payee Source #

Arguments

:: Tag | The tag which contains the PAYEE tag, if there is one. This would typically be a STMTTRN tag.
-> Maybe (Err Payee) | Nothing if there is no PAYEE tag. Just if a PAYEE tag is found, with a Left if the tag is lacking a required element, or a Right if the tag is successfully parsed. If there is more than one PAYEE tag, only the first one is considered.

Parses a Payee record from its parent tag.

data CorrectAction Source #

Can be either REPLACE or DELETE.

Constructors

REPLACE | Replaces the transaction referenced by the CORRECTFITID
DELETE | Deletes the transaction referenced by the CORRECTFITID

#### Instances

Instances details

Data CorrectAction Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CorrectAction -> c CorrectAction Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CorrectAction Source #

toConstr :: CorrectAction -> Constr Source #

dataTypeOf :: CorrectAction -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CorrectAction) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CorrectAction) Source #

gmapT :: (forall b. Data b => b -> b) -> CorrectAction -> CorrectAction Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CorrectAction -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CorrectAction -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CorrectAction -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CorrectAction -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CorrectAction -> m CorrectAction Source #

Generic CorrectAction Source # |
Instance details Defined in Data.OFX Associated Types type Rep CorrectAction :: Type -> Type Source # Methods from :: CorrectAction -> Rep CorrectAction x Source # to :: Rep CorrectAction x -> CorrectAction Source #
Read CorrectAction Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS CorrectAction Source # readList :: ReadS [CorrectAction] Source # readPrec :: ReadPrec CorrectAction Source # readListPrec :: ReadPrec [CorrectAction] Source #
Show CorrectAction Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> CorrectAction -> ShowS Source # show :: CorrectAction -> String Source # showList :: [CorrectAction] -> ShowS Source #
Eq CorrectAction Source # |
Instance details Defined in Data.OFX Methods (==) :: CorrectAction -> CorrectAction -> Bool Source # (/=) :: CorrectAction -> CorrectAction -> Bool Source #
type Rep CorrectAction Source # |
Instance details Defined in Data.OFX type Rep CorrectAction = D1 ('MetaData "CorrectAction" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) (C1 ('MetaCons "REPLACE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DELETE" 'PrefixI 'False) (U1 :: Type -> Type))

data BankAcctTo Source #

Constructors

BankAcctTo |

Fields

- btBANKID :: String

  Routing and transit number

- btBRANCHID :: Maybe String

  Bank identifier for international banks

- btACCTID :: String

  Account number

- btACCTTYPE :: AcctType

  Type of account

- btACCTKEY :: Maybe String

  Checksum for international banks

#### Instances

Instances details

Data BankAcctTo Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BankAcctTo -> c BankAcctTo Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BankAcctTo Source #

toConstr :: BankAcctTo -> Constr Source #

dataTypeOf :: BankAcctTo -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BankAcctTo) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BankAcctTo) Source #

gmapT :: (forall b. Data b => b -> b) -> BankAcctTo -> BankAcctTo Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BankAcctTo -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BankAcctTo -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> BankAcctTo -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> BankAcctTo -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BankAcctTo -> m BankAcctTo Source #

Generic BankAcctTo Source # |
Instance details Defined in Data.OFX Associated Types type Rep BankAcctTo :: Type -> Type Source # Methods from :: BankAcctTo -> Rep BankAcctTo x Source # to :: Rep BankAcctTo x -> BankAcctTo Source #
Read BankAcctTo Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS BankAcctTo Source # readList :: ReadS [BankAcctTo] Source # readPrec :: ReadPrec BankAcctTo Source # readListPrec :: ReadPrec [BankAcctTo] Source #
Show BankAcctTo Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> BankAcctTo -> ShowS Source # show :: BankAcctTo -> String Source # showList :: [BankAcctTo] -> ShowS Source #
type Rep BankAcctTo Source # |

Instance details

Defined in Data.OFX

type Rep BankAcctTo = D1 ('MetaData "BankAcctTo" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) (C1 ('MetaCons "BankAcctTo" 'PrefixI 'True) ((S1 ('MetaSel ('Just "btBANKID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "btBRANCHID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String))) :*: (S1 ('MetaSel ('Just "btACCTID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Just "btACCTTYPE") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 AcctType) :*: S1 ('MetaSel ('Just "btACCTKEY") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String))))))

bankAcctTo :: Tag -> Maybe (Err BankAcctTo) Source #

data CCAcctTo Source #

Constructors

CCAcctTo |

Fields

- ctACCTID :: String

  Account number

- ctACCTKEY :: Maybe String

  Checksum for international banks

#### Instances

Instances details

Data CCAcctTo Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CCAcctTo -> c CCAcctTo Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CCAcctTo Source #

toConstr :: CCAcctTo -> Constr Source #

dataTypeOf :: CCAcctTo -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CCAcctTo) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CCAcctTo) Source #

gmapT :: (forall b. Data b => b -> b) -> CCAcctTo -> CCAcctTo Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CCAcctTo -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CCAcctTo -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CCAcctTo -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CCAcctTo -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CCAcctTo -> m CCAcctTo Source #

Generic CCAcctTo Source # |
Instance details Defined in Data.OFX Associated Types type Rep CCAcctTo :: Type -> Type Source # Methods from :: CCAcctTo -> Rep CCAcctTo x Source # to :: Rep CCAcctTo x -> CCAcctTo Source #
Read CCAcctTo Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS CCAcctTo Source # readList :: ReadS [CCAcctTo] Source # readPrec :: ReadPrec CCAcctTo Source # readListPrec :: ReadPrec [CCAcctTo] Source #
Show CCAcctTo Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> CCAcctTo -> ShowS Source # show :: CCAcctTo -> String Source # showList :: [CCAcctTo] -> ShowS Source #
Eq CCAcctTo Source # |
Instance details Defined in Data.OFX Methods (==) :: CCAcctTo -> CCAcctTo -> Bool Source # (/=) :: CCAcctTo -> CCAcctTo -> Bool Source #
type Rep CCAcctTo Source # |
Instance details Defined in Data.OFX type Rep CCAcctTo = D1 ('MetaData "CCAcctTo" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) (C1 ('MetaCons "CCAcctTo" 'PrefixI 'True) (S1 ('MetaSel ('Just "ctACCTID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "ctACCTKEY") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe String))))

ccAcctTo :: Tag -> Maybe (Err CCAcctTo) Source #

data AcctType Source #

Constructors

ACHECKING |
ASAVINGS |
AMONEYMRKT |
ACREDITLINE |

#### Instances

Instances details

Data AcctType Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AcctType -> c AcctType Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AcctType Source #

toConstr :: AcctType -> Constr Source #

dataTypeOf :: AcctType -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AcctType) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AcctType) Source #

gmapT :: (forall b. Data b => b -> b) -> AcctType -> AcctType Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AcctType -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AcctType -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> AcctType -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AcctType -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AcctType -> m AcctType Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AcctType -> m AcctType Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AcctType -> m AcctType Source #

Generic AcctType Source # |
Instance details Defined in Data.OFX Associated Types type Rep AcctType :: Type -> Type Source # Methods from :: AcctType -> Rep AcctType x Source # to :: Rep AcctType x -> AcctType Source #
Read AcctType Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS AcctType Source # readList :: ReadS [AcctType] Source # readPrec :: ReadPrec AcctType Source # readListPrec :: ReadPrec [AcctType] Source #
Show AcctType Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> AcctType -> ShowS Source # show :: AcctType -> String Source # showList :: [AcctType] -> ShowS Source #
Eq AcctType Source # |
Instance details Defined in Data.OFX Methods (==) :: AcctType -> AcctType -> Bool Source # (/=) :: AcctType -> AcctType -> Bool Source #
Ord AcctType Source # |
Instance details Defined in Data.OFX Methods compare :: AcctType -> AcctType -> Ordering Source # (<) :: AcctType -> AcctType -> Bool Source # (<=) :: AcctType -> AcctType -> Bool Source # (>) :: AcctType -> AcctType -> Bool Source # (>=) :: AcctType -> AcctType -> Bool Source # max :: AcctType -> AcctType -> AcctType Source # min :: AcctType -> AcctType -> AcctType Source #
type Rep AcctType Source # |

Instance details

Defined in Data.OFX

type Rep AcctType = D1 ('MetaData "AcctType" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) ((C1 ('MetaCons "ACHECKING" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ASAVINGS" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "AMONEYMRKT" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ACREDITLINE" 'PrefixI 'False) (U1 :: Type -> Type)))

acctType :: String -> Err AcctType Source #

data CurrencyData Source #

Holds all data both for CURRENCY and for ORIGCURRENCY.

Constructors

CurrencyData |

Fields

- cdCURRATE :: String

  Ratio of CURDEF currency to CURSYM currency, in decimal form

- cdCURSYM :: String

  ISO-4217 3-letter currency identifier

#### Instances

Instances details

Data CurrencyData Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CurrencyData -> c CurrencyData Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CurrencyData Source #

toConstr :: CurrencyData -> Constr Source #

dataTypeOf :: CurrencyData -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CurrencyData) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CurrencyData) Source #

gmapT :: (forall b. Data b => b -> b) -> CurrencyData -> CurrencyData Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CurrencyData -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CurrencyData -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CurrencyData -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CurrencyData -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CurrencyData -> m CurrencyData Source #

Generic CurrencyData Source # |
Instance details Defined in Data.OFX Associated Types type Rep CurrencyData :: Type -> Type Source # Methods from :: CurrencyData -> Rep CurrencyData x Source # to :: Rep CurrencyData x -> CurrencyData Source #
Read CurrencyData Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS CurrencyData Source # readList :: ReadS [CurrencyData] Source # readPrec :: ReadPrec CurrencyData Source # readListPrec :: ReadPrec [CurrencyData] Source #
Show CurrencyData Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> CurrencyData -> ShowS Source # show :: CurrencyData -> String Source # showList :: [CurrencyData] -> ShowS Source #
Eq CurrencyData Source # |
Instance details Defined in Data.OFX Methods (==) :: CurrencyData -> CurrencyData -> Bool Source # (/=) :: CurrencyData -> CurrencyData -> Bool Source #
type Rep CurrencyData Source # |

Instance details

Defined in Data.OFX

type Rep CurrencyData = D1 ('MetaData "CurrencyData" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) (C1 ('MetaCons "CurrencyData" 'PrefixI 'True) (S1 ('MetaSel ('Just "cdCURRATE") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "cdCURSYM") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))

currencyData Source #

Arguments

:: Tag | The tag that contains the data, e.g. CURRENCY or ORIGCURRENCY.
-> Err CurrencyData |

Parses currency data.

data Currency Source #

Constructors

Currency CurrencyData |

#### Instances

Instances details

Data Currency Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Currency -> c Currency Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Currency Source #

toConstr :: Currency -> Constr Source #

dataTypeOf :: Currency -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Currency) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Currency) Source #

gmapT :: (forall b. Data b => b -> b) -> Currency -> Currency Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Currency -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Currency -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Currency -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Currency -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Currency -> m Currency Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Currency -> m Currency Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Currency -> m Currency Source #

Generic Currency Source # |
Instance details Defined in Data.OFX Associated Types type Rep Currency :: Type -> Type Source # Methods from :: Currency -> Rep Currency x Source # to :: Rep Currency x -> Currency Source #
Read Currency Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS Currency Source # readList :: ReadS [Currency] Source # readPrec :: ReadPrec Currency Source # readListPrec :: ReadPrec [Currency] Source #
Show Currency Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> Currency -> ShowS Source # show :: Currency -> String Source # showList :: [Currency] -> ShowS Source #
Eq Currency Source # |
Instance details Defined in Data.OFX Methods (==) :: Currency -> Currency -> Bool Source # (/=) :: Currency -> Currency -> Bool Source #
type Rep Currency Source # |
Instance details Defined in Data.OFX type Rep Currency = D1 ('MetaData "Currency" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) (C1 ('MetaCons "Currency" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CurrencyData)))

currency :: Tag -> Maybe (Err Currency) Source #

data OrigCurrency Source #

Constructors

OrigCurrency CurrencyData |

#### Instances

Instances details

Data OrigCurrency Source # |

Instance details

Defined in Data.OFX

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OrigCurrency -> c OrigCurrency Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c OrigCurrency Source #

toConstr :: OrigCurrency -> Constr Source #

dataTypeOf :: OrigCurrency -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c OrigCurrency) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OrigCurrency) Source #

gmapT :: (forall b. Data b => b -> b) -> OrigCurrency -> OrigCurrency Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OrigCurrency -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OrigCurrency -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> OrigCurrency -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> OrigCurrency -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OrigCurrency -> m OrigCurrency Source #

Generic OrigCurrency Source # |
Instance details Defined in Data.OFX Associated Types type Rep OrigCurrency :: Type -> Type Source # Methods from :: OrigCurrency -> Rep OrigCurrency x Source # to :: Rep OrigCurrency x -> OrigCurrency Source #
Read OrigCurrency Source # |
Instance details Defined in Data.OFX Methods readsPrec :: Int -> ReadS OrigCurrency Source # readList :: ReadS [OrigCurrency] Source # readPrec :: ReadPrec OrigCurrency Source # readListPrec :: ReadPrec [OrigCurrency] Source #
Show OrigCurrency Source # |
Instance details Defined in Data.OFX Methods showsPrec :: Int -> OrigCurrency -> ShowS Source # show :: OrigCurrency -> String Source # showList :: [OrigCurrency] -> ShowS Source #
Eq OrigCurrency Source # |
Instance details Defined in Data.OFX Methods (==) :: OrigCurrency -> OrigCurrency -> Bool Source # (/=) :: OrigCurrency -> OrigCurrency -> Bool Source #
type Rep OrigCurrency Source # |
Instance details Defined in Data.OFX type Rep OrigCurrency = D1 ('MetaData "OrigCurrency" "Data.OFX" "ofx-0.4.4.0-95J3bnox4SULgFk4ACXJHw" 'False) (C1 ('MetaCons "OrigCurrency" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CurrencyData)))

origCurrency :: Tag -> Maybe (Err OrigCurrency) Source #

# Running parsers

parseOfxFile :: String -> Err OFXFile Source #

Parses an input file. Returns either an error message or the resulting `OFXFile`.

loadOfxFile :: FilePath -> IO OFXFile Source #

Loads an OFX file from disk, parses it, and returns the resulting `OFXFile`. Uses `fail` if the parse fails.

parseTransactions :: String -> Err [Transaction] Source #

Parses an OFX file and gets the list of `Transaction`.

loadTransactions :: FilePath -> IO [Transaction] Source #

Loads an OFX file from disk, parses it, and returns the resulting list of `Transaction`. Uses `fail` if the parse fails.

prettyRenderOfxFile Source #

Arguments

:: String | File contents to parse
-> String | Pretty printed result of rending the result of the parse, which is either an error message or an `OFXFile`.

Parses an input file to an OfxFile. Returns a pretty-printed string with the results of the parse.

prettyRenderTransactions Source #

Arguments

:: String | File contents to parse
-> String | Pretty printed result of rendering the result of the parse, which is either an error message or a list of `Transaction`.

Parses an input file to an OfxFile, and then to a list of `Transaction`. Returns a pretty-printed string with the results.

# Parsec parsers

ofxFile :: Parser OFXFile Source #

Parses an entire OFX file, including headers.

newline :: Parser () Source #

Parses either a UNIX or an MS-DOS newline. According to 1.2.2, OFX does not contain any white space between tags. However, since I have seen OFX files that do have whitespace between tags, the parser makes allowance for this.

escChar :: Parser Char Source #

Parses a character, possibly with an escape sequence. The greater-than sign, less-than sign, and ampersand must be entered with escape sequences.

According to OFX spec section 2.3.2.1, ampersands, less-than signs, and greater-than signs must appear as entities. However some banks deliver broken OFX files that do not use entities for ampersands (and possibly for less-than or greater-than signs too, although I have not yet observed such behavior.) There is now an error message that reflects this problem. Client code can filter the OFX data for known offenders before passing it to this library.

header :: Parser OFXHeader Source #

openingTag :: Parser TagName Source #

Parses any opening tag. Returns the name of the tag.

closingTag :: TagName -> Parser () Source #

Parses a closing tag with the given name.

tag :: Parser Tag Source #

Parses any tag. The tag itself must be followed by at least one character: either the next tag if this is an aggregate tag, or the data if this is a data tag. OFX does not allow empty tags.

The OFX spec seems to say that OFX files do not include trailing newlines after tags or data, but I have seen these newlines in QFX files, so this parses optional trailing newlines and spaces.

date :: Parser ZonedTime Source #

Parses an OFX date. Fails if the date is not valid or if there is no date to be parsed.

time :: Parser (TimeOfDay, TimeZone) Source #

Parses an OFX time. Fails if the time is not valid or if there is no time to parse. Fails if there is no time to parse; however, if there is a time but no zone, returns the time and UTC for the zone.

tzOffset :: Parser TimeZone Source #

Parses a time zone offset. Fails if there is no time zone offset to parse.

# Pretty printers

pPayee :: Payee -> Doc Source #

pTransaction :: Transaction -> Doc Source #

pTag :: Tag -> Doc Source #

pHeader :: OFXHeader -> Doc Source #

pFile :: OFXFile -> Doc Source #

pEither :: (a -> Doc) -> (b -> Doc) -> Either a b -> Doc Source #

pMaybe :: (a -> Doc) -> Maybe a -> Doc Source #

pList :: [Doc] -> Doc Source #

label :: String -> Doc -> Doc Source #

pExceptional :: (e -> Doc) -> (a -> Doc) -> Either e a -> Doc Source #