Release 1.28 (#3587)

* bump version
* extract toolbar cleanup logic to helper class
* allow 3 digits in invoice template tax rate
This commit is contained in:
Kevin Papst
2022-10-24 11:42:56 +02:00
committed by GitHub
parent 14f4530de0
commit 006de60f66
6 changed files with 82 additions and 45 deletions

View File

@@ -17,11 +17,11 @@ class Constants
/**
* The current release version
*/
public const VERSION = '1.27.0';
public const VERSION = '1.28.0';
/**
* The current release: major * 10000 + minor * 100 + patch
*/
public const VERSION_ID = 12700;
public const VERSION_ID = 12800;
/**
* The current release status, either "stable" or "dev"
*/

View File

@@ -9,6 +9,7 @@
namespace App\Form\Extension;
use App\Form\Helper\ToolbarHelper;
use App\Form\Toolbar\ExportToolbarForm;
use App\Form\Toolbar\InvoiceToolbarForm;
use App\Form\Toolbar\InvoiceToolbarSimpleForm;
@@ -18,22 +19,16 @@ use App\Form\Toolbar\UserToolbarForm;
use App\Reporting\MonthlyUserListForm;
use App\Reporting\WeeklyUserListForm;
use App\Reporting\YearlyUserListForm;
use App\User\TeamService;
use App\User\UserService;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;
final class ToolbarFormExtension extends AbstractTypeExtension
{
private $userService;
private $teamService;
private $teamNames = ['team', 'teams', 'searchTeams'];
private $userNames = ['user', 'users'];
private $toolbarHelper;
public function __construct(UserService $userService, TeamService $teamService)
public function __construct(ToolbarHelper $toolbarHelper)
{
$this->userService = $userService;
$this->teamService = $teamService;
$this->toolbarHelper = $toolbarHelper;
}
public static function getExtendedTypes(): iterable
@@ -53,36 +48,6 @@ final class ToolbarFormExtension extends AbstractTypeExtension
public function buildForm(FormBuilderInterface $builder, array $options)
{
$deleteUser = false;
foreach ($this->userNames as $name) {
if ($builder->has($name) && $this->userService->countUser(true) < 2) {
$deleteUser = true;
break;
}
}
if ($deleteUser) {
foreach ($this->userNames as $name) {
if ($builder->has($name)) {
$builder->remove($name);
}
}
}
$deleteTeams = false;
foreach ($this->teamNames as $name) {
if ($builder->has($name) && !$this->teamService->hasTeams()) {
$deleteTeams = true;
break;
}
}
if ($deleteTeams) {
foreach ($this->teamNames as $name) {
if ($builder->has($name)) {
$builder->remove($name);
}
}
}
$this->toolbarHelper->cleanupForm($builder);
}
}

View File

@@ -0,0 +1,63 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Form\Helper;
use App\User\TeamService;
use App\User\UserService;
use Symfony\Component\Form\FormBuilderInterface;
final class ToolbarHelper
{
private $userService;
private $teamService;
private $teamNames = ['team', 'teams', 'searchTeams'];
private $userNames = ['user', 'users'];
public function __construct(UserService $userService, TeamService $teamService)
{
$this->userService = $userService;
$this->teamService = $teamService;
}
public function cleanupForm(FormBuilderInterface $builder)
{
$deleteUser = false;
foreach ($this->userNames as $name) {
if ($builder->has($name) && $this->userService->countUser(true) < 2) {
$deleteUser = true;
break;
}
}
if ($deleteUser) {
foreach ($this->userNames as $name) {
if ($builder->has($name)) {
$builder->remove($name);
}
}
}
$deleteTeams = false;
foreach ($this->teamNames as $name) {
if ($builder->has($name) && !$this->teamService->hasTeams()) {
$deleteTeams = true;
break;
}
}
if ($deleteTeams) {
foreach ($this->teamNames as $name) {
if ($builder->has($name)) {
$builder->remove($name);
}
}
}
}
}

View File

@@ -68,7 +68,7 @@ class InvoiceTemplateForm extends AbstractType
])
->add('vat', NumberType::class, [
'label' => 'label.tax_rate',
'scale' => 2,
'scale' => 3,
])
->add('renderer', InvoiceRendererType::class)
->add('calculator', InvoiceCalculatorType::class)