diff --git a/README.md b/README.md index 32b587de..58d396f5 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,9 @@ It is open for changes and input from the community, your [ideas and questions]( > You don't have to wait for the next official release, upgrade it at any time from the master branch, > which is always deployable - release tags are simple snapshots of the development version. -Release versions will be created on a regular base (approx. one release every 2 months). +Release versions will be created on a regular basis, every couple of weeks. Every code change, whether it's a new feature or a bugfix, will be done on the master branch. -Kimai is actively developed in my spare time, I put my effort into the software instead of backporting changes. +Kimai is actively developed in my spare time, I put my effort into the software instead of back-porting changes. ## Contributing diff --git a/src/Constants.php b/src/Constants.php index d6fa7f4c..264de03e 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -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" */ diff --git a/src/Form/Extension/ToolbarFormExtension.php b/src/Form/Extension/ToolbarFormExtension.php index 17cebda6..0566e373 100644 --- a/src/Form/Extension/ToolbarFormExtension.php +++ b/src/Form/Extension/ToolbarFormExtension.php @@ -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); } } diff --git a/src/Form/Helper/ToolbarHelper.php b/src/Form/Helper/ToolbarHelper.php new file mode 100644 index 00000000..4a4c687d --- /dev/null +++ b/src/Form/Helper/ToolbarHelper.php @@ -0,0 +1,63 @@ +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); + } + } + } + } +} diff --git a/src/Form/InvoiceTemplateForm.php b/src/Form/InvoiceTemplateForm.php index 12b5526a..e73f877f 100644 --- a/src/Form/InvoiceTemplateForm.php +++ b/src/Form/InvoiceTemplateForm.php @@ -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) diff --git a/tests/Controller/InvoiceControllerTest.php b/tests/Controller/InvoiceControllerTest.php index 4f35f7c2..7faabbbc 100644 --- a/tests/Controller/InvoiceControllerTest.php +++ b/tests/Controller/InvoiceControllerTest.php @@ -107,6 +107,7 @@ class InvoiceControllerTest extends ControllerBaseTest 'company' => 'Company name', 'renderer' => 'default', 'calculator' => 'default', + 'vat' => '27,937', ] ]); @@ -114,6 +115,14 @@ class InvoiceControllerTest extends ControllerBaseTest $client->followRedirect(); $this->assertTrue($client->getResponse()->isSuccessful()); $this->assertHasFlashSuccess($client); + + $template = $this->getEntityManager()->getRepository(InvoiceTemplate::class)->findAll()[0]; + self::assertEquals('Test', $template->getName()); + self::assertEquals('Test invoice template', $template->getTitle()); + self::assertEquals('Company name', $template->getCompany()); + self::assertEquals('default', $template->getRenderer()); + self::assertEquals('default', $template->getCalculator()); + self::assertEquals('27.937', $template->getVat()); } public function testCopyTemplateAction()