<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kokonut-ch / laravel-swiss-bank-csv-parser example snippets
use Kokonut\SwissBankCsvParser\Facades\SwissBankCsvParser;
$file = SwissBankCsvParser::parse($request->file('statement')->get());
// or SwissBankCsvParser::parseFile('/path/to/statement.csv')
$file->bank->name; // 'PostFinance'
$file->profile; // 'postfinance.efinance'
$file->account->iban; // 'CH9300762011623852957'
$file->account->currency; // 'CHF'
$file->period->from; // DateTimeImmutable|null, the period the file announces
foreach ($file as $row) {
$row->date; // DateTimeImmutable
$row->valueDate; // DateTimeImmutable|null
$row->label; // 'Paiement fournisseur'
$row->amount; // '-150.50', signed decimal string, negative means money out
$row->currency; // 'CHF'
$row->balance; // '8759.45' or null
$row->reference; // whatever the bank printed, if anything
$row->extras; // ['Catégorie' => 'Achats'], recognised but outside the core model
$row->raw; // the original cells, so nothing is ever lost
}
$file = \SwissBankCsvParser::parse($contents);
$report = SwissBankCsvParser::detect($csvContents);
$report->best()->bank->name; // 'PostFinance'
$report->best()->score; // 0.90
$report->best()->reasons; // ['distinctive heading "Texte de notification"', …]
if (! $report->isConfident()) {
// Several profiles could read this, or none stands out.
// A good moment to ask whoever uploaded it.
}
$row->extras['Status']; // 'Booked'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.