An application written in PHP (Symfony 4 framework) to import, categorize and analyze transactions.
Follow the workflow to get to know how to use the app.
docker-compose up -d mysql
docker-compose logs -f mysql # wait for mysql to be ready
docker-compose up -d # doctrine migrations will run as soon as the php container get started
# optionally, create some default transaction categories
docker-compose run php php bin/console doctrine:fixtures:load --append
Browse http://localhost
To run the app in prod, prefix all above docker-compose commands with -f docker-compose-prod.yml.
Update the services environment variables in the docker-compose-prod.yml file according to your needs.
docker-compose run php php bin/phpunit
The current implementation can import transactions from french account statements coming from the following banks:
Source code for these parsers can be found at https://github.com/Ovski4/account-statement-parsers.
To add a new file parser, create a new class that implements AbstractFileParser. The symfony framework will take care of creating tagged services automatically and update the user interface (the forms) accordingly.
You will have to implement the following methods:
Here is an example below:
<?php
namespace App\Services\FileParser;
use App\Entity\Transaction;
class HelloBankAccountStatementParser extends AbstractFileParser
{
private $accountRepository;
public function __construct(AccountRepository $accountRepository)
{
$this->accountRepository = $accountRepository;
}
public function getName(): string
{
return 'hello-bank';
}
public function getLabel(): string
{
return 'Hello Bank account statement';
}
public function parse(string $filepath): array
{
$results = ... // do your magic here with the file
$transactions = [];
foreach($results as $result) {
$transaction = new Transaction();
$transaction
->setAmount($result['value'])
->setCreatedAt(
(\DateTime::createFromFormat('d/m/Y', $result['date']))->setTime(0, 0, 0)
)
->setLabel($result['label'])
->setAccount($this->accountRepository->findByAliasOrName($result['account']))
;
$transactions[] = $transaction;
}
return $transactions;
}
}
Content type
Image
Digest
sha256:7e5e51e12…
Size
320.7 MB
Last updated
about 1 month ago
docker pull ovski/expenses-categorizer-php