Skip to content

Commit

Permalink
Merge branch 'release/2.8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiov committed Oct 2, 2021
2 parents 61125ac + ba480bb commit cc70783
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 30 deletions.
1 change: 1 addition & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ if [[ -n "$PHP_STAGED_FILES" ]]; then

if [[ "$STATUS" -eq 0 ]]; then
echo -e "\e[42mPHP Unit Tests Suite is OK\e[m"
git add coverage.txt
else
while true; do
read -p $'\e[31mDo you really want to commit ignoring Tests errors? y/n \e[0m: ' yn < /dev/tty
Expand Down
8 changes: 4 additions & 4 deletions coverage.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@


Code Coverage Report:
2021-09-30 21:16:19
2021-10-02 05:46:54

Summary:
Classes: 51.61% (32/62)
Methods: 54.46% (110/202)
Lines: 34.53% (403/1167)
Lines: 35.10% (410/1168)

Application\Controller\PageController
Methods: 100.00% ( 2/ 2) Lines: 100.00% ( 2/ 2)
Expand Down Expand Up @@ -87,7 +87,7 @@ MoneyLog\Controller\CategoryController
MoneyLog\Controller\DashboardController
Methods: 0.00% ( 0/ 2) Lines: 0.00% ( 0/ 46)
MoneyLog\Controller\MovementController
Methods: 0.00% ( 0/11) Lines: 0.00% ( 0/133)
Methods: 0.00% ( 0/11) Lines: 0.00% ( 0/128)
MoneyLog\Controller\ProvisionController
Methods: 0.00% ( 0/ 5) Lines: 0.00% ( 0/ 43)
MoneyLog\Controller\SettingsController
Expand Down Expand Up @@ -129,6 +129,6 @@ MoneyLog\View\Helper\Morris
MoneyLog\View\Helper\PageHeader
Methods: 100.00% ( 1/ 1) Lines: 100.00% ( 3/ 3)
MoneyLog\View\Helper\SynopsisFilters
Methods: 0.00% ( 0/ 1) Lines: 0.00% ( 0/ 24)
Methods: 0.00% ( 0/ 1) Lines: 23.33% ( 7/ 30)
MoneyLog\View\Helper\WidgetText
Methods: 0.00% ( 0/ 1) Lines: 0.00% ( 0/ 8)
1 change: 1 addition & 0 deletions module/Application/view/layout/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ $identity = $this->identity();
<li><a href="<?php echo $this->url('accantona_recap'); ?>"><i class="fa fa-dashboard fa-fw"></i> Cruscotto</a></li>
<li><a href="<?php echo $this->url('accantona_categoria'); ?>"><i class="fa fa-table fa-fw"></i> <?php echo $this->translate('Categorie'); ?></a></li>
<li><a href="<?php echo $this->url('accantonaAccount'); ?>"><i class="fa fa-table fa-fw"></i> <?php echo $this->translate('Conti'); ?></a></li>
<li><a href="<?php echo $this->url('accantonaMovement'); ?>"><i class="fa fa-table fa-fw"></i> <?php echo $this->translate('Movimenti'); ?></a></li>
<?php if ($this->userData()->hasStored()): ?>
<li><a href="<?php echo $this->url('accantona_accantonato'); ?>"><i class="fa fa-table fa-fw"></i> <?php echo $this->translate('Accantonati'); ?></a></li>
<?php endif; ?>
Expand Down
29 changes: 10 additions & 19 deletions module/MoneyLog/src/MoneyLog/Controller/MovementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,30 +136,21 @@ public function accountAction()
*/
public function exportAction()
{
$accountId = $this->params()->fromRoute('id', 0);
$dateMin = $this->params()->fromQuery('dateMin', date('Y-m-d', strtotime('-3 months')));
$searchParams = [
'accountId' => $accountId,
'amountMax' => $this->params()->fromQuery('amountMax'),
'amountMin' => $this->params()->fromQuery('amountMin'),
'category' => $this->params()->fromQuery('category'),
'dateMax' => $this->params()->fromQuery('dateMax'),
'dateMin' => $dateMin,
'accountId' => $this->params()->fromRoute('id'),
'amountMax' => $this->params()->fromQuery('amountMax'),
'amountMin' => $this->params()->fromQuery('amountMin'),
'category' => $this->params()->fromQuery('category'),
'dateMax' => $this->params()->fromQuery('dateMax'),
'dateMin' => $this->params()->fromQuery('dateMin'),
'description' => $this->params()->fromQuery('description'),
'user' => $this->user->getId(),
];

/** @var ?Account $account */
$account = $this->em->getRepository(Account::class)
->findOneBy(['id' => $accountId, 'user' => $this->user->getId()]);

if (!$account) {
return $this->getRedirectToDashboard();
}

/** @var \Application\Repository\MovementRepository $movementRepository */
$movementRepository = $this->em->getRepository(Movement::class);

$fileName = 'export-' . strtolower($account->getName()) . '.csv';
$fileName = 'export-' . date('Y-m-d') . '.csv';
$this->getResponse()->getHeaders()
->addHeaderLine('Content-Disposition: attachment; filename="' . $fileName . '"')
->addHeaderLine('Content-Type: text/csv; charset=utf-8');
Expand Down Expand Up @@ -206,8 +197,8 @@ public function moveAction()
return $this->getRedirectToDashboard();
}

$accountOptions = ['' => ''];
foreach ($accountRepository->getUserAccounts($this->user->getId()) as $account) {
$accountOptions = [];
foreach ($accountRepository->getByUsage($this->user->getId()) as $account) {
if ($account->getId() != $sourceAccount->getId() && $account->getStatus() !== Account::STATUS_CLOSED) {
$accountOptions[$account->getId()] = $account->getName();
}
Expand Down
14 changes: 13 additions & 1 deletion module/MoneyLog/src/MoneyLog/View/Helper/SynopsisFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,24 @@ class SynopsisFilters extends AbstractHelper
/**
* @param array<string> $filters
* @param array<\Application\Entity\Category> $categories
* @param array<\Application\Entity\Account> $accounts
* @return string
*/
public function __invoke(array $filters, array $categories): string
public function __invoke(array $filters, array $categories, array $accounts): string
{
$pieces = [];

if ($filters['account'] && $accounts) {
$account = '';
foreach ($accounts as $a) {
if ($a->getId() == $filters['account']) {
$account = $a->getName();
}
}

$pieces['account'] = 'Conto <strong>' . $account . '</strong>';
}

if ($filters['dateMin'] || $filters['dateMax']) {
$pieces['date'] = '';
if ($filters['dateMin']) {
Expand Down
27 changes: 27 additions & 0 deletions module/MoneyLog/test/Form/View/Helper/SynopsisFiltersTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace MoneyLogTest\Form\View\Helper;

use MoneyLog\View\Helper\SynopsisFilters;
use PHPUnit\Framework\TestCase;

class SynopsisFiltersTest extends TestCase
{
public static function test(): void
{
$synopsisFilters = new SynopsisFilters();

$filters = [
'account' => '',
'amountMax' => '',
'amountMin' => '',
'category' => '',
'dateMax' => '',
'dateMin' => '',
'description' => '',
];
self::assertSame('<strong>Motra tutto</strong>', ($synopsisFilters)($filters, [], []));
}
}
2 changes: 1 addition & 1 deletion module/MoneyLog/view/money-log/dashboard/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ echo $this->pageHeader('Cruscotto');
<?php foreach ($accounts as $account): ?>
<tr>
<td>
<a href="<?php echo $this->url('accantonaMovement', ['action' => 'account', 'id' => $account['id']]); ?>"><?php echo $account['name']; ?></a>
<a href="<?php echo $this->url('accantonaMovement', [], ['query' => ['account' => $account['id']]] ); ?>"><?php echo $account['name']; ?></a>
</td>
<td class="text-right" style="min-width:130px;"><?php echo $this->currencyForma($account['total']); ?></td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion module/MoneyLog/view/money-log/movement/account.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $morrisData = array();
<div class="panel-body">
<div class="row">
<div class="col-lg-12">
<?php echo $this->synopsisFilters($searchParams, $categories); ?>
<?php echo $this->synopsisFilters($searchParams, $categories, []); ?>
<a class="btn btn-default btn-circle pull-right" id="monthsFilterToggle"><i class="fa fa-chevron-down"></i></a>
</div>
</div>
Expand Down
6 changes: 2 additions & 4 deletions module/MoneyLog/view/money-log/movement/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Saldi e filtri</h4>
<h4 class="panel-title">Filtri</h4>
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-12">
<?php echo $this->synopsisFilters($searchParams, $categories); ?>
<?php echo $this->synopsisFilters($searchParams, $categories, $accounts); ?>
<a class="btn btn-default btn-circle pull-right" id="monthsFilterToggle"><i class="fa fa-chevron-down"></i></a>
</div>
</div>
Expand Down Expand Up @@ -210,6 +210,4 @@
$i = '<i class="mfb-component__child-icon glyphicon glyphicon-equalizer"></i>';
$this->floatingButtons()
->addAnchorItem(['href' => $this->url('accantonaMovement', ['action' => 'add'], ['query' => $searchParams]), 'label' => 'Nuovo movimento', 'icon' => 'plus'])
->addAnchorItem(['href' => $this->url('accantonaMovement', ['action' => 'move'], ['query' => $searchParams]), 'label' => 'Giroconto', 'icon' => 'transfer'])
->addRawItem("<span class=\"balance mfb-component__button--child\" data-toggle=\"modal\" data-target=\"#modal-balance\">$i</span>")
->addAnchorItem(['href' => $this->url('accantonaMovement', ['action' => 'export'], ['query' => $searchParams]), 'label' => 'Esporta', 'icon' => 'export']);

0 comments on commit cc70783

Please sign in to comment.