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

@@ -11,8 +11,8 @@ declare(strict_types=1);
namespace DoctrineMigrations;
use App\Doctrine\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* @version 1.15

View File

@@ -11,8 +11,8 @@ declare(strict_types=1);
namespace DoctrineMigrations;
use App\Doctrine\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* @version 1.15

View File

@@ -11,8 +11,8 @@ declare(strict_types=1);
namespace DoctrineMigrations;
use App\Doctrine\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* @version 1.15

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
/*
* 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 DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20210719123928 extends AbstractMigration
{
public function getDescription(): string
{
return 'Adds the budget_type columns to customer, project and activity';
}
public function up(Schema $schema): void
{
$activities = $schema->getTable('kimai2_activities');
$activities->addColumn('budget_type', 'string', ['length' => 10, 'notnull' => false, 'default' => null]);
$customers = $schema->getTable('kimai2_customers');
$customers->addColumn('budget_type', 'string', ['length' => 10, 'notnull' => false, 'default' => null]);
$projects = $schema->getTable('kimai2_projects');
$projects->addColumn('budget_type', 'string', ['length' => 10, 'notnull' => false, 'default' => null]);
}
public function down(Schema $schema): void
{
$activities = $schema->getTable('kimai2_activities');
$activities->dropColumn('budget_type');
$customers = $schema->getTable('kimai2_customers');
$customers->dropColumn('budget_type');
$projects = $schema->getTable('kimai2_projects');
$projects->dropColumn('budget_type');
}
}

View File

@@ -11,10 +11,10 @@ declare(strict_types=1);
namespace DoctrineMigrations;
use App\Doctrine\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
/**
* @version 1.15

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
/*
* 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 DoctrineMigrations;
use App\Doctrine\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
/**
* @version 1.15
*/
final class Version20210802152259 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add the date column to the timesheet table';
}
public function up(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->addColumn('date_tz', Types::DATE_MUTABLE, ['notnull' => false]);
}
public function down(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->dropColumn('date_tz');
}
}

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
/*
* 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 DoctrineMigrations;
use App\Doctrine\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* @version 1.15
*/
final class Version20210802152814 extends AbstractMigration
{
public function getDescription(): string
{
return 'Fills the new date column in the timesheet table';
}
public function up(Schema $schema): void
{
$fetch = $this->connection->prepare('SELECT id, start_time, timezone FROM kimai2_timesheet WHERE date_tz IS NULL');
$timezones = [];
foreach (\DateTimeZone::listIdentifiers() as $tz) {
$timezones[$tz] = new \DateTimeZone($tz);
}
foreach ($fetch->executeQuery()->iterateAssociative() as $row) {
if (!isset($timezones[$row['timezone']])) {
$timezones[$row['timezone']] = new \DateTimeZone($row['timezone']);
}
$date = new \DateTime($row['start_time'], $timezones['UTC']);
$date->setTimezone($timezones[$row['timezone']]);
$this->addSql('UPDATE kimai2_timesheet SET date_tz = ? WHERE id = ?', [$date->format('Y-m-d'), $row['id']]);
}
$fetch->free();
}
public function down(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->changeColumn('date_tz', ['notnull' => false]);
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
/*
* 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 DoctrineMigrations;
use App\Doctrine\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* @version 1.15
*/
final class Version20210802160837 extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates the index on the new timesheet statistic date column';
}
public function up(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->changeColumn('date_tz', ['notnull' => true]);
$timesheet->addIndex(['date_tz', 'user'], 'IDX_4F60C6B1BDF467148D93D649');
}
public function down(Schema $schema): void
{
$timesheet = $schema->getTable('kimai2_timesheet');
$timesheet->changeColumn('date_tz', ['notnull' => false]);
$timesheet->dropIndex('IDX_4F60C6B1BDF467148D93D649');
}
}