packages feed

ofx 0.4.2.0 → 0.4.4.0

raw patch · 3 files changed

+54/−41 lines, 3 filesdep ~parsecdep ~prettydep ~time

Dependency ranges changed: parsec, pretty, time

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2016 Omari Norman+Copyright (c) 2016-2019 Omari Norman All rights reserved.  Redistribution and use in source and binary forms, with or without
lib/Data/OFX.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE OverloadedStrings, FlexibleContexts #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveGeneric #-} -- | Parser for downloaded OFX files. -- -- This parser was written based on the OFX version 1.03@@ -25,9 +27,6 @@ -- interested in. If you are interested in other data you can query -- the 'Tag' tree for what you need. ----- For example, to read in the filename given on the command line and--- parse it and print it nicely:--- -- 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@@ -87,7 +86,9 @@    -- * Running parsers   , parseOfxFile+  , loadOfxFile   , parseTransactions+  , loadTransactions   , prettyRenderOfxFile   , prettyRenderTransactions @@ -122,16 +123,18 @@  import Control.Applicative (many, optional, (<|>)) import Control.Monad (replicateM, (<=<))+import Data.Data (Data)+import Data.Maybe (listToMaybe)+import Data.Monoid ((<>))+import qualified Data.Monoid as M import qualified Data.Time as T-  +import Data.Typeable (Typeable)+import GHC.Generics (Generic) import Text.Parsec.String (Parser) import Text.Parsec   ( lookAhead, char, manyTill, anyChar, (<?>), eof,     try, digit, many1, spaces, string, choice, parse ) import qualified Text.Parsec as P-import Data.Maybe (listToMaybe)-import Data.Monoid ((<>))-import qualified Data.Monoid as M import Text.PrettyPrint   ( Doc, hang, text, sep, vcat, nest, (<+>), ($$),     parens, brackets, render )@@ -160,7 +163,7 @@ -- @tag:value@ followed by a newline. These are followed by a blank -- line. data OFXHeader = OFXHeader HeaderTag HeaderValue-  deriving (Eq, Show, Read)+  deriving (Eq, Show, Read, Data, Generic, Typeable)  -- | The name of an OFX tag type TagName = String@@ -173,7 +176,7 @@ -- tags. In OFX, a tag either has data and no child elements, or it -- has no data and it has child elements. data Tag = Tag TagName (Either TagData [Tag])-  deriving (Eq, Show, Read)+  deriving (Eq, Show, Read, Data, Generic, Typeable)  -- | All the data from an OFX file. data OFXFile = OFXFile@@ -183,7 +186,7 @@   -- ^ All the data will be contained in a root tag with the TagName   -- @OFX@. -  } deriving (Eq, Show, Read)+  } deriving (Eq, Show, Read, Data, Generic, Typeable)  -- -- # Parsers@@ -512,7 +515,7 @@   -- ^ Repeating payment / standing order    | TOTHER-  deriving (Eq, Ord, Show, Read)+  deriving (Eq, Ord, Show, Read, Data, Generic, Typeable)  -- | 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@@ -619,7 +622,7 @@     , txCurrency :: Maybe (Either Currency OrigCurrency)     -- ^ Currency option. OFX spec says to choose either CURRENCY or     -- ORIGCURRENCY.-    } deriving (Show, Read)+    } deriving (Show, Read, Data, Generic, Typeable)  data Payee = Payee   { peNAME :: String@@ -631,7 +634,7 @@   , pePOSTALCODE :: String   , peCOUNTRY :: Maybe String   , pePHONE :: String-  } deriving (Eq, Show, Read)+  } deriving (Eq, Show, Read, Data, Generic, Typeable)  -- | Can be either REPLACE or DELETE. data CorrectAction@@ -640,7 +643,7 @@    | DELETE   -- ^ Deletes the transaction referenced by the CORRECTFITID-  deriving (Eq, Show, Read)+  deriving (Eq, Show, Read, Data, Generic, Typeable)  data BankAcctTo = BankAcctTo   { btBANKID :: String@@ -657,7 +660,7 @@    , btACCTKEY :: Maybe String   -- ^ Checksum for international banks-  } deriving (Show, Read)+  } deriving (Show, Read, Data, Generic, Typeable)  data CCAcctTo = CCAcctTo   { ctACCTID :: String@@ -666,14 +669,14 @@   , ctACCTKEY :: Maybe String   -- ^ Checksum for international banks -  } deriving (Eq, Show, Read)+  } deriving (Eq, Show, Read, Data, Generic, Typeable)  data AcctType   = ACHECKING   | ASAVINGS   | AMONEYMRKT   | ACREDITLINE-  deriving (Eq, Show, Ord, Read)+  deriving (Eq, Show, Ord, Read, Data, Generic, Typeable)  acctType :: String -> Err AcctType acctType s@@ -691,13 +694,13 @@    , cdCURSYM :: String   -- ^ ISO-4217 3-letter currency identifier-  } deriving (Eq, Show, Read)+  } deriving (Eq, Show, Read, Data, Generic, Typeable)  data Currency = Currency CurrencyData-  deriving (Eq, Show, Read)+  deriving (Eq, Show, Read, Data, Generic, Typeable)  data OrigCurrency = OrigCurrency CurrencyData-  deriving (Eq, Show, Read)+  deriving (Eq, Show, Read, Data, Generic, Typeable)  -- -- # Helpers to build aggregates@@ -971,9 +974,27 @@ parseOfxFile :: String -> Err OFXFile parseOfxFile = either (Left . show) (Right . id) . parse ofxFile "" --- | Parses an OFX file and gets the list of 'Tranasction'.+-- | Parses an OFX file and gets the list of 'Transaction'. parseTransactions :: String -> Err [Transaction] parseTransactions = transactions <=< parseOfxFile++-- | Loads an OFX file from disk, parses it, and returns the+-- resulting 'OFXFile'.  Uses 'fail' if the parse fails.+loadOfxFile :: FilePath -> IO OFXFile+loadOfxFile fp = do+  txt <- readFile fp+  case parseOfxFile txt of+    Left e -> fail e+    Right g -> return g++-- | Loads an OFX file from disk, parses it, and returns the resulting list of+-- 'Transaction'.  Uses 'fail' if the parse fails.+loadTransactions :: FilePath -> IO [Transaction]+loadTransactions fp = do+  txt <- readFile fp+  case parseTransactions txt of+    Left e -> fail e+    Right g -> return g  -- # Parsing and pretty printing 
ofx.cabal view
@@ -1,18 +1,10 @@--- This Cabal file generated using the Cartel library.--- Cartel is available at:--- http://www.github.com/massysett/cartel------ Script name used to generate: gen-ofx-cabal--- Generated on: 2016-07-12 21:19:09.028404 EDT--- Cartel library version: 0.16.0.0- name: ofx-version: 0.4.2.0+version: 0.4.4.0 cabal-version: >= 1.10 license: BSD3 license-file: LICENSE build-type: Simple-copyright: Copyright (c) 2016 Omari Norman+copyright: Copyright (c) 2016-2019 Omari Norman author: Omari Norman maintainer: omari@smileystation.com stability: Experimental@@ -47,9 +39,9 @@     lib   build-depends:       base >= 4.8 && < 5-    , parsec >= 3.1-    , pretty >= 1.1-    , time >= 1.4+    , parsec+    , pretty+    , time  source-repository head   type: git@@ -68,9 +60,9 @@     lib   build-depends:       base >= 4.8 && < 5-    , parsec >= 3.1-    , pretty >= 1.1-    , time >= 1.4+    , parsec+    , pretty+    , time  Executable renderTransactions   main-is: renderTransactions.hs@@ -85,6 +77,6 @@     lib   build-depends:       base >= 4.8 && < 5-    , parsec >= 3.1-    , pretty >= 1.1-    , time >= 1.4+    , parsec+    , pretty+    , time