Giter Site home page Giter Site logo

ofxparser's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ofxparser's Issues

Using namespaces

I am using this manually without composer & including:

include 'ofxparser/lib/OfxParser/Parser.php';

I thought this should be technically enough, but its not including classes inside entities folder for some reason:(

Fatal error: Class 'OfxParser\Entities\SignOn' not found in /Applications/AMPPS/www/ofx/ofxparser/lib/OfxParser/Ofx.php on line 77

Help or sample index file would be helpful! Thank you :)

Additional metadata on transactions

The OFX file includes some additional details for each transaction that are not captured when parsing. Would it be possible to extract those fields or include a SimpleXMLElement referencing the whole transaction so that other tools could pluck them out as needed? This seems to be the most straightforward way to extend the library without having to build a more extensive system.

Cast entities values assignments

The parser are storing SimpleXML elements in the entities properties.
I think, for example, the code from Parser::buildCreditAccount:

....
$bankAccount->accountNumber = $statementResponse->BANKACCTFROM->ACCTID;
$bankAccount->routingNumber = $statementResponse->BANKACCTFROM->BANKID;
$bankAccount->accountType = $statementResponse->BANKACCTFROM->ACCTTYPE;
....

should be:

....
$bankAccount->accountNumber = (string)$statementResponse->BANKACCTFROM->ACCTID;
$bankAccount->routingNumber = (string)$statementResponse->BANKACCTFROM->BANKID;
$bankAccount->accountType = (string)$statementResponse->BANKACCTFROM->ACCTTYPE;
....

Unable to parse Amex credit card statement

Attempting to parse an Amex statement results in 39 occurrences of this and related tag mismatches :

Failed to parse OFX: array (
0 =>
LibXMLError::__set_state(array(
'level' => 3,
'code' => 76,
'column' => 92,
'message' => 'Opening and ending tag mismatch: MESSAGE line 1 and STATUS
',
'file' => '',
'line' => 1,
)),......

Looking in wrong tag for credit card account info?

In BuildCreditAccount, you are using $xml->CCSTMTRS->BANKACCTFROM. My statement has this:

$xml->CCSTMTRS->CCACCTFROM

Perhaps different credit card companies use different ones? Or is this just a bug?

I can't parse the file given in tests : ofxdata.ofx

I copy-paste the example like this :

<?php
include("vendor/autoload.php");
$file = 'vendor/asgrim/ofxparser/tests/fixtures/ofxdata.ofx';

$ofxParser = new \OfxParser\Parser;
$ofx = $ofxParser->loadFromFile($file);

$bankAccount = reset($ofx->bankAccounts);

// Get the statement start and end dates
$startDate = $bankAccount->statement->startDate;
$endDate = $bankAccount->statement->endDate;

echo $startDate." ".$endDate;

// Get the statement transactions for the account
$transactions = $bankAccount->statement->transactions;

var_dump($transactions);

But the var_dump says "NULL", and no startDate or endDate prints out.

Needs to be able to handle multiple items on one line in the xml

FNB seem to lump transactions items onto one line which only passes the memo to the buildTransactions function.

Snippet from the OFX file:

 <STMTTRN>
<TRNTYPE>CREDIT<DTPOSTED>20170106<TRNAMT>10.00<FITID>201701063<CHECKNUM>0000000000<MEMO>ADT CASH DEPOSIT      49120010998 JM       49120010998 JM
 </STMTTRN>
 <STMTTRN>
<TRNTYPE>CREDIT<DTPOSTED>20170106<TRNAMT>10.00<FITID>201701064<CHECKNUM>0000000000<MEMO>CASH DEPOSIT LONG ST  4912001098 JM TEST 2 4912001098 JM TEST 2
 </STMTTRN>

Regex amount parsing wrong

The function createAmountFromStr($amountString) seems to have some bugs with strings that aren't number formatted and have one or more trailing 0s. For example, 750 will parse as 7.5 but 50 parses fine.

Here's a playground link demonstrating the issue. http://tehplayground.com/#SSeFA3M80

Thanks

xmlParseEntityRef: no name

I am getting the following error "xmlParseEntityRef: no name" when trying to parse an ofx file submitted from a file upload form.

I searched over the internet and it looks like the problem is related to the stray ‘&’ (ampersand character) somewhere in the file. How can I come over this? They suggest to remove or encode the ampersand, but the file is being uploaded from an upload form.

$file_path = $_FILES["fileUpload"]["tmp_name"];

$ofxParser = new \OfxParser\Parser();
$ofx = $ofxParser->loadFromFile($file_path);

$bankAccount = reset($ofx->bankAccounts);

// Get the statement transactions for the account
$transactions = $bankAccount->statement->transactions;

var_dump($startDate, $endDate, $transactions);


Support multi-line and one-line OFX

Since version 1.1.1 you added

$ofxContent = str_replace("<", "\n<", $ofxContent); //add linebreaks to allow XML to parse

But this line is relevant only for one-line OFX files (like French Banque Postale).
Other banks are using multi-line formatting (such as French Credit Mutuel, Banque Populaire).

Oneline snippet:

OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
<OFX><SIGNONMSGSRSV1><SONRS><STATUS><CODE>0<SEVERITY>INFO</STATUS><DTSERVER>20160720101818<LANGUAGE>FRE</SONRS></SIGNONMSGSRSV1><BANKMSGSRSV1><STMTTRNRS><TRNUID>1469002698556<STATUS><CODE>0<SEVERITY>INFO</STATUS>…

Multiline snippet:

OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE

<OFX>
<SIGNONMSGSRSV1>
    <SONRS>
        <STATUS>
            <CODE>0
            <SEVERITY>INFO
        </STATUS>
        <DTSERVER>20160720000000
        <LANGUAGE>FRA
    </SONRS>
</SIGNONMSGSRSV1>
…

Could we detect the OFX formatting before converting it to XML?

Open <MEMO> with symbol " closeUnclosedXmlTags don't add </MEMO>

Got an error when tried to import a credit card statement, failing to parse OFX.

Debugging I got the message Opening and ending tag mismatch: MEMO line 68 and STMTTRN.

When I verified the OFX file, I noticed that this line has a " symbol in it. When I removed it from my original file, everything worked fine.

Debugging parser I saw that closeUnclosedXmlTags is not working when there is a " symbol.

bug-parserofx

Maintainer wanted

Hi folks; unfortunately, I just don't have the time or inclination to maintain this any more. I've kept telling myself I'll get around to modernising this, but as I'm no longer using this on any projects, it's unlikely I'll ever get around to it.

I'm happy for someone to fork this, take it over etc., but I won't be maintaining it any more (not that I was doing much with it anyway...

Opinions/thoughts/suggestions welcome. Previous contributors would be favoured.

I will mark this repo as archived in ~2 weeks.

Transaction : DTUSER

Hello,

Would it be possible to include DTUSER field in addition to DTPOSTED in Transaction entity ?

Regards

XML Tags uncloseds

I created a .txt with the final string of the ofx and have some XML tags unclosed...

"Failed to parse OFX: array ( 0 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 8, 'message' => 'Opening and ending tag mismatch: STATUS line 7 and CODE ', 'file' => '', 'line' => 10, )), 1 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 13, 'message' => 'Opening and ending tag mismatch: SONRS line 5 and SEVERITY ', 'file' => '', 'line' => 13, )), 2 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 11, 'message' => 'Opening and ending tag mismatch: SIGNONMSGSRSV1 line 3 and STATUS ', 'file' => '', 'line' => 15, )), 3 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 9, 'message' => 'Opening and ending tag mismatch: OFX line 1 and SONRS ', 'file' => '', 'line' => 31, )), 4 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 5, 'column' => 1, 'message' => 'Extra content at the end of the document ', 'file' => '', 'line' => 33, )), )"

Investment Accounts OFX not parsing

Downloaded Merrill Lynch OFX file and results are blank.

Example file:
OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:TYPE1
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE

<OFX>
  <SIGNONMSGSRSV1>
    <SONRS>
      <STATUS>
        <CODE>0
        <SEVERITY>INFO
        <MESSAGE>SUCCESS
      </STATUS>
      <DTSERVER>20170204082107.751[-5:EST]
      <LANGUAGE>ENG
      <DTPROFUP>20170204082107.751[-5:EST]
      <FI>
        <ORG>Merrill Lynch &amp; Co., Inc.
        <FID>5550
      </FI>
      <INTU.BID>5550
      <INTU.USERID>xxxxxxxxxxx
    </SONRS>
  </SIGNONMSGSRSV1>
  <INVSTMTMSGSRSV1>
    <INVSTMTTRNRS>
      <TRNUID>0
      <STATUS>
        <CODE>0
        <SEVERITY>INFO
        <MESSAGE>SUCCESS
      </STATUS>
      <INVSTMTRS>
        <DTASOF>20170204082107.821[-5:EST]
        <CURDEF>USD</CURDEF>
        <INVACCTFROM>
          <BROKERID>www.mldirect.ml.com
          <ACCTID>99Z99999
        </INVACCTFROM>
        <INVTRANLIST>
          <DTSTART>20170104110000.000[-5:EST]
          <DTEND>20170203110000.000[-5:EST]
          <INVBANKTRAN>
            <STMTTRN>
              <TRNTYPE>CREDIT
              <DTPOSTED>20170203110000.000[-5:EST]</DTPOSTED>
              <TRNAMT>10
              <FITID>20170203AF180757320068440
              <NAME>Funds Transfer
              <MEMO>FR BAC#99999999999999
            </STMTTRN>
            <SUBACCTFUND>CASH
          </INVBANKTRAN>
        </INVTRANLIST>
        <INVBAL>
          <AVAILCASH>10
          <MARGINBALANCE>0
          <SHORTBALANCE>0
          <BUYPOWER>0
        </INVBAL>
      </INVSTMTRS>
    </INVSTMTTRNRS>
  </INVSTMTMSGSRSV1>
</OFX>

Unable to parse Google Finance ("Investment" type) OFX

Hey there, I've just tried parsing an OFX file from a dummy account on Google Finance and I get the following really long error:

Failed to parse OFX: array ( 0 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 11, 'message' => 'Opening and ending tag mismatch: MEMO line 67 and INVTRAN ', 'file' => '', 'line' => 69, )), 1 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 13, 'message' => 'Opening and ending tag mismatch: INVTRAN line 61 and INVBUY ', 'file' => '', 'line' => 89, )), 2 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 12, 'message' => 'Opening and ending tag mismatch: INVBUY line 59 and BUYSTOCK ', 'file' => '', 'line' => 93, )), 3 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 11, 'message' => 'Opening and ending tag mismatch: MEMO line 105 and INVTRAN ', 'file' => '', 'line' => 107, )), 4 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 13, 'message' => 'Opening and ending tag mismatch: INVTRAN line 99 and INVBUY ', 'file' => '', 'line' => 127, )), 5 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 12, 'message' => 'Opening and ending tag mismatch: INVBUY line 97 and BUYSTOCK ', 'file' => '', 'line' => 131, )), 6 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 11, 'message' => 'Opening and ending tag mismatch: MEMO line 143 and INVTRAN ', 'file' => '', 'line' => 145, )), 7 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 14, 'message' => 'Opening and ending tag mismatch: INVTRAN line 137 and INVSELL ', 'file' => '', 'line' => 165, )), 8 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 13, 'message' => 'Opening and ending tag mismatch: INVSELL line 135 and SELLSTOCK ', 'file' => '', 'line' => 169, )), 9 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 15, 'message' => 'Opening and ending tag mismatch: SELLSTOCK line 133 and INVTRANLIST ', 'file' => '', 'line' => 171, )), 10 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 13, 'message' => 'Opening and ending tag mismatch: BUYSTOCK line 95 and INVSTMTRS ', 'file' => '', 'line' => 173, )), 11 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 16, 'message' => 'Opening and ending tag mismatch: BUYSTOCK line 57 and INVSTMTTRNRS ', 'file' => '', 'line' => 175, )), 12 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 22, 'message' => 'Opening and ending tag mismatch: INVTRANLIST line 51 and INVSTMTMSGSRSV1 ', 'file' => '', 'line' => 177, )), 13 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 76, 'column' => 7, 'message' => 'Opening and ending tag mismatch: INVSTMTRS line 37 and OFX ', 'file' => '', 'line' => 207, )), 14 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 77, 'column' => 7, 'message' => 'Premature end of data in tag INVSTMTTRNRS line 25 ', 'file' => '', 'line' => 207, )), 15 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 77, 'column' => 7, 'message' => 'Premature end of data in tag INVSTMTMSGSRSV1 line 23 ', 'file' => '', 'line' => 207, )), 16 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 77, 'column' => 7, 'message' => 'Premature end of data in tag OFX line 1 ', 'file' => '', 'line' => 207, )), )

This is with the following data:

OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE

<OFX>
<SIGNONMSGSRSV1>
<SONRS>
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<DTSERVER>20151130171040.594
<LANGUAGE>ENG
</SONRS>
</SIGNONMSGSRSV1>
<INVSTMTMSGSRSV1>
<INVSTMTTRNRS>
<TRNUID>1001
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<INVSTMTRS>
<DTASOF>20151130171040.594
<CURDEF>USD
<INVACCTFROM>
<BROKERID>google.com
<ACCTID>StockersTest
</INVACCTFROM>
<INVTRANLIST>
<DTSTART>20100401000000.000
<DTEND>20150401000000.000
<BUYSTOCK>
<INVBUY>
<INVTRAN>
<FITID>1
<DTTRADE>20100401000000.000
<MEMO>
</INVTRAN>
<SECID>
<UNIQUEID>TSE:T
<UNIQUEIDTYPE>TICKER
</SECID>
<UNITS>5
<UNITPRICE>20
<TOTAL>-100
<SUBACCTSEC>CASH
<SUBACCTFUND>CASH
</INVBUY>
<BUYTYPE>BUY
</BUYSTOCK>
<BUYSTOCK>
<INVBUY>
<INVTRAN>
<FITID>3
<DTTRADE>20150101000000.000
<MEMO>
</INVTRAN>
<SECID>
<UNIQUEID>TSE:T
<UNIQUEIDTYPE>TICKER
</SECID>
<UNITS>20
<UNITPRICE>35
<TOTAL>-700
<SUBACCTSEC>CASH
<SUBACCTFUND>CASH
</INVBUY>
<BUYTYPE>BUY
</BUYSTOCK>
<SELLSTOCK>
<INVSELL>
<INVTRAN>
<FITID>2
<DTTRADE>20150401000000.000
<MEMO>
</INVTRAN>
<SECID>
<UNIQUEID>TSE:T
<UNIQUEIDTYPE>TICKER
</SECID>
<UNITS>-20
<UNITPRICE>42.06
<TOTAL>841.2
<SUBACCTSEC>CASH
<SUBACCTFUND>CASH
</INVSELL>
<SELLTYPE>SELL
</SELLSTOCK>
</INVTRANLIST>
</INVSTMTRS>
</INVSTMTTRNRS>
</INVSTMTMSGSRSV1>
<SECLISTMSGSRSV1>
<SECLIST>
<STOCKINFO>
<SECINFO>
<SECID>
<UNIQUEID>TSE:T
<UNIQUEIDTYPE>TICKER
</SECID>
<SECNAME>TELUS Corporation
<TICKER>T
</SECINFO>
</STOCKINFO>
</SECLIST>
</SECLISTMSGSRSV1>
</OFX>

account balance format

transactions amounts are returned as float, whereas balance amount is returned as string.
with some banks (french caisse d'épargne), balance amount has comma instead of dot as decimal separator (ie. : -34,18). If you apply a floatval() to this string, this cuts down the cents. (french crédit agricole ofx files doesn't have this issue)
of course I can process the string or use NumberFormatter parser, but it would be more convenient if it was integrated into ofxparser and that balance amount was returned as proper float !

Need to be able to parse version 2.0.0 of OFX files

RuntimeException: Failed to parse OFX: array (
  0 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 76,
     'column' => 8,
     'message' => 'Opening and ending tag mismatch: STATUS line 7 and CODE
',
     'file' => '',
     'line' => 10,
  )),
  1 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 76,
     'column' => 13,
     'message' => 'Opening and ending tag mismatch: SONRS line 5 and SEVERITY
',
     'file' => '',
     'line' => 13,
  )),
  2 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 76,
     'column' => 11,
     'message' => 'Opening and ending tag mismatch: SIGNONMSGSRSV1 line 3 and STATUS
',
     'file' => '',
     'line' => 15,
  )),
  3 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 76,
     'column' => 12,
     'message' => 'Opening and ending tag mismatch: OFX line 1 and DTSERVER
',
     'file' => '',
     'line' => 18,
  )),
  4 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 5,
     'column' => 1,
     'message' => 'Extra content at the end of the document
',
     'file' => '',
     'line' => 20,
  )),
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.