upgestao / ofxparser
简单的OFX文件解析器
1.2.8
2024-05-17 18:05 UTC
Requires
- php: ~5.6|~7.0
Requires (Dev)
- phpunit/phpunit: ~5.5
- squizlabs/php_codesniffer: ~2.6
- dev-master
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-ajuste_data_ofx_santander
- dev-10773/fix_quebra_linha
- dev-10632/bug_ofx_importacao_loop_infinito
- dev-10230/Fix_erro_importacao_arquivo_ofx_conciliacao
- dev-fix/parse_amount
- dev-fork_up
- dev-feature/fork_inicial
This package is auto-updated.
Last update: 2024-09-17 19:37:27 UTC
README
此仓库是一个分支。为了修复已弃用的主分支中的错误而创建。UpGestão
OFX解析器是一个PHP库,旨在将金融机构下载的OFX文件解析成简单的PHP对象。
它支持多个银行账户、所需的“登录”响应,并识别OFX时间戳。
安装
只需使用Composer要求此包
$ composer require samueledson/ofxparser
使用方法
您可以通过以下方式访问OFX文件中的节点
$ofxParser = new \OfxParser\Parser(); $ofx = $ofxParser->loadFromFile('/path/to/your/bankstatement.ofx'); $bankAccount = reset($ofx->bankAccounts); // Get the statement start and end dates $startDate = $bankAccount->statement->startDate; $endDate = $bankAccount->statement->endDate; // Get the statement transactions for the account $transactions = $bankAccount->statement->transactions;
最常见的节点是support。如果您在OFX文件中遇到无法访问的节点,请提交一个pull request!
投资支持
投资看起来与银行/信用卡交易有很大不同。此版本支持OFX 2.0.3规范中的子集,以满足作者们的即时需求。如果您选择实现此库,请参考OFX文档。特别是,此版本当前不处理投资头寸(INVPOSLIST)或参考证券定义(SECINFO)。
这并不是纯字段透传,例如python中的此实现:csingley/ofxtools。此包包含偶尔被“转换”以使其对不熟悉投资OFX规范的读者更友好的字段。
从Quicken(QFX)文件或MS Money(OFX / XML)文件加载投资
// You'll probably want to alias the namespace: use OfxParser\Entities\Investment as InvEntities; // Load the OFX file $ofxParser = new \OfxParser\Parsers\Investment(); $ofx = $ofxParser->loadFromFile('/path/to/your/investments_file.ofx'); // Loop over investment accounts (named bankAccounts from base lib) foreach ($ofx->bankAccounts as $accountData) { // Loop over transactions foreach ($accountData->statement->transactions as $ofxEntity) { // Keep in mind... not all properties are inherited for all transaction types... // Maybe you'll want to do something based on the transaction properties: $nodeName = $ofxEntity->nodeName; if ($nodeName == 'BUYSTOCK') { // @see OfxParser\Entities\Investment\Transaction... $amount = abs($ofxEntity->total); $cusip = $ofxEntity->securityId; // ... } // Maybe you'll want to do something based on the entity: if ($ofxEntity instanceof InvEntities\Transaction\BuyStock) { // ... } } }
分支 & 信用
这是grimfor/ofxparser的一个分支,目的是使其与框架无关。源存储库是为Symfony 2框架设计的,因此应给予应有的信用!由Oliver Lowe大量重构,并基于Andrew A. Smith的ruby ofx-parser。