An composer extension to the MT940 parser from the jejik/mt940 library that fixes parsing ING Bank statements in the MT940 format and adds support for Rabobank CSV statements
You can install cyberwizzard/MT940 using Composer. You can read more about Composer and its main repository at
http://packagist.org. First install Composer for your project using the instructions on the
Packagist home page, then define your dependency on cyberwizzard/MT940 in your composer.json
file.
Note: currently this library is not published on Packagist; as soon as it is cleaned up, it will get published and there will be no need to specify a repository.
{
"repositories": [{
"type": "vcs",
"url": "https://github.com/cyberwizzard/mt940"
}],
"require": {
"cyberwizzard/mt940": ">=0.3"
}
}
This library follows the PSR-0 standard. You will need
a PSR-0 compliant autoloader to load the cyberwizzard/MT940 classes. Composer provides one for you in your vendor/.composer/autoload.php
.
<?php
use Jejik\MT940\Reader;
$reader = new Reader();
// Load the Rabobank CSV parser
$reader->addParser( 'RabobankCSV', 'cyberwizzard\MT940\Parser\RabobankCSV' );
// Append the list of default bank parsers (optional)
$reader->addParsers( $reader->getDefaultParsers() );
// Load the Ing parser from this repository to replace the one from jejik/MT940
$reader->addParser( 'Ing', 'cyberwizzard\MT940\Parser\Ing' );
$statements = $reader->getStatements(file_get_contents('mt940.txt'));
foreach ($statements as $statement) {
echo $statement->getOpeningBalance()->getAmount() . "\n";
foreach ($statement->getTransactions() as $transaction) {
echo $transaction->getAmount() . "\n";
}
echo $statement->getClosingBalance()->getAmount() . "\n";
}
For more information, see the jejik/MT940 repository.
Use this parser at your own risk. While the utmost care is taken to design parsers which are fully compliant with the official bank statement formats, most of the implementations from the banks themselves seem to have quirks.
This parser is in use in a private project and as such is tested regularly.