monthly budget, monthly report, unified report calculation (#2684)

This commit is contained in:
Kevin Papst
2021-08-06 18:38:41 +02:00
committed by GitHub
parent 21f785638c
commit cefd747e91
196 changed files with 5031 additions and 2167 deletions

View File

@@ -12,7 +12,6 @@ namespace App\Reporting;
use App\Form\Type\MonthPickerType;
use App\Form\Type\UserType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -37,7 +36,6 @@ class MonthByUserForm extends AbstractType
'model_timezone' => $options['timezone'],
'view_timezone' => $options['timezone'],
'start_date' => $options['start_date'],
'format' => $options['format'],
]);
if ($options['include_user']) {
@@ -54,7 +52,6 @@ class MonthByUserForm extends AbstractType
'data_class' => MonthByUser::class,
'timezone' => date_default_timezone_get(),
'start_date' => new \DateTime(),
'format' => DateType::HTML5_FORMAT,
'include_user' => false,
'csrf_protection' => false,
'method' => 'GET',

View File

@@ -11,7 +11,6 @@ namespace App\Reporting;
use App\Form\Type\MonthPickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -36,7 +35,6 @@ class MonthlyUserListForm extends AbstractType
'model_timezone' => $options['timezone'],
'view_timezone' => $options['timezone'],
'start_date' => $options['start_date'],
'format' => $options['format'],
]);
}
@@ -49,7 +47,6 @@ class MonthlyUserListForm extends AbstractType
'data_class' => MonthlyUserList::class,
'timezone' => date_default_timezone_get(),
'start_date' => new \DateTime(),
'format' => DateType::HTML5_FORMAT,
'csrf_protection' => false,
'method' => 'GET',
]);

View File

@@ -0,0 +1,66 @@
<?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\Reporting\ProjectDateRange;
use App\Form\Type\CustomerType;
use App\Form\Type\MonthPickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ProjectDateRangeForm extends AbstractType
{
/**
* Simplify cross linking between pages by removing the block prefix.
*
* @return null|string
*/
public function getBlockPrefix()
{
return null;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('customer', CustomerType::class, [
'required' => false,
'label' => false,
'width' => false,
]);
$builder->add('month', MonthPickerType::class, [
'label' => false,
'view_timezone' => $options['timezone'],
'model_timezone' => $options['timezone'],
]);
$builder->add('includeNoBudget', CheckboxType::class, [
'required' => false,
'label' => 'label.includeNoBudget',
]);
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => ProjectDateRangeQuery::class,
'timezone' => date_default_timezone_get(),
'csrf_protection' => false,
'method' => 'GET',
]);
}
}

View File

@@ -0,0 +1,83 @@
<?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\Reporting\ProjectDateRange;
use App\Entity\Customer;
use App\Entity\User;
final class ProjectDateRangeQuery
{
/**
* @var \DateTime
*/
private $month;
/**
* @var User|null
*/
private $user;
/**
* @var Customer|null
*/
private $customer;
private $includeNoBudget = false;
private $onlyWithRecords = false;
public function __construct(\DateTime $month, User $user)
{
$this->month = clone $month;
$this->user = $user;
}
public function isIncludeNoBudget(): bool
{
return $this->includeNoBudget;
}
public function setIncludeNoBudget(bool $includeNoBudget): void
{
$this->includeNoBudget = $includeNoBudget;
}
public function isOnlyWithRecords(): bool
{
return $this->onlyWithRecords;
}
public function setOnlyWithRecords(bool $onlyWithRecords): void
{
$this->onlyWithRecords = $onlyWithRecords;
}
public function getUser(): ?User
{
return $this->user;
}
public function getMonth(): \DateTime
{
return $this->month;
}
public function setMonth(\DateTime $month): void
{
$this->month = $month;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): void
{
$this->customer = $customer;
}
}

View File

@@ -12,6 +12,7 @@ namespace App\Reporting\ProjectDetails;
use App\Entity\Project;
use App\Entity\User;
use App\Model\ActivityStatistic;
use App\Model\BudgetStatisticModel;
use App\Model\Statistic\UserYear;
use App\Model\Statistic\Year;
use App\Model\UserStatistic;
@@ -38,6 +39,10 @@ final class ProjectDetailsModel
* @var ActivityStatistic[]
*/
private $activities = [];
/**
* @var BudgetStatisticModel
*/
private $budgetStatisticModel;
public function __construct(Project $project)
{
@@ -155,4 +160,14 @@ final class ProjectDetailsModel
{
$this->years = $years;
}
public function getBudgetStatisticModel(): ?BudgetStatisticModel
{
return $this->budgetStatisticModel;
}
public function setBudgetStatisticModel(BudgetStatisticModel $budgetStatisticModel): void
{
$this->budgetStatisticModel = $budgetStatisticModel;
}
}

View File

@@ -10,6 +10,7 @@
namespace App\Reporting\ProjectView;
use App\Entity\Project;
use App\Model\BudgetStatisticModelInterface;
use DateTime;
final class ProjectViewModel
@@ -27,7 +28,14 @@ final class ProjectViewModel
private $notBilledRate = 0.00;
private $billableDuration = 0;
private $billableRate = 0.00;
/**
* @var \DateTime|null
*/
private $lastRecord;
/**
* @var BudgetStatisticModelInterface
*/
private $budgetStatisticModel;
public function __construct(Project $project)
{
@@ -168,4 +176,14 @@ final class ProjectViewModel
{
$this->lastRecord = $lastRecord;
}
public function getBudgetStatisticModel(): BudgetStatisticModelInterface
{
return $this->budgetStatisticModel;
}
public function setBudgetStatisticModel(BudgetStatisticModelInterface $budgetStatisticModel): void
{
$this->budgetStatisticModel = $budgetStatisticModel;
}
}

View File

@@ -56,6 +56,7 @@ final class ReportingService
$event->addReport(new Report('project_details', 'report_project_details', 'report_project_details', 'project'));
}
if ($this->security->isGranted('budget_project')) {
$event->addReport(new Report('daterange_projects', 'report_project_daterange', 'report_project_daterange', 'project'));
$event->addReport(new Report('inactive_projects', 'report_project_inactive', 'report_inactive_project', 'project'));
}

View File

@@ -12,7 +12,6 @@ namespace App\Reporting;
use App\Form\Type\UserType;
use App\Form\Type\WeekPickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -37,7 +36,6 @@ class WeekByUserForm extends AbstractType
'model_timezone' => $options['timezone'],
'view_timezone' => $options['timezone'],
'start_date' => $options['start_date'],
'format' => $options['format'],
]);
if ($options['include_user']) {
@@ -54,7 +52,6 @@ class WeekByUserForm extends AbstractType
'data_class' => WeekByUser::class,
'timezone' => date_default_timezone_get(),
'start_date' => new \DateTime(),
'format' => DateType::HTML5_FORMAT,
'include_user' => false,
'csrf_protection' => false,
'method' => 'GET',

View File

@@ -11,7 +11,6 @@ namespace App\Reporting;
use App\Form\Type\WeekPickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -36,7 +35,6 @@ class WeeklyUserListForm extends AbstractType
'model_timezone' => $options['timezone'],
'view_timezone' => $options['timezone'],
'start_date' => $options['start_date'],
'format' => $options['format'],
]);
}
@@ -49,7 +47,6 @@ class WeeklyUserListForm extends AbstractType
'data_class' => WeeklyUserList::class,
'timezone' => date_default_timezone_get(),
'start_date' => new \DateTime(),
'format' => DateType::HTML5_FORMAT,
'csrf_protection' => false,
'method' => 'GET',
]);

View File

@@ -11,7 +11,6 @@ namespace App\Reporting;
use App\Form\Type\YearPickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -36,7 +35,6 @@ class YearlyUserListForm extends AbstractType
'model_timezone' => $options['timezone'],
'view_timezone' => $options['timezone'],
'start_date' => $options['start_date'],
'format' => $options['format'],
'show_range' => true,
]);
}
@@ -50,7 +48,6 @@ class YearlyUserListForm extends AbstractType
'data_class' => YearlyUserList::class,
'timezone' => date_default_timezone_get(),
'start_date' => new \DateTime(),
'format' => DateType::HTML5_FORMAT,
'csrf_protection' => false,
'method' => 'GET',
]);