moved shared entity fields and functions to trait (#750)
This commit is contained in:
@@ -12,7 +12,9 @@ doctrine:
|
|||||||
default:
|
default:
|
||||||
url: '%env(resolve:DATABASE_URL)%'
|
url: '%env(resolve:DATABASE_URL)%'
|
||||||
driver: 'pdo_mysql'
|
driver: 'pdo_mysql'
|
||||||
server_version: '5.7'
|
# this setting prevents automatic database detection and finds a lot of false-negatives on doctrine:migrations:diff
|
||||||
|
# for null columns with MariaDB. Each migration tries to convert EVERY nullable column.
|
||||||
|
# server_version: '5.7'
|
||||||
charset: utf8mb4
|
charset: utf8mb4
|
||||||
default_table_options:
|
default_table_options:
|
||||||
charset: utf8mb4
|
charset: utf8mb4
|
||||||
|
|||||||
@@ -66,21 +66,8 @@ class Activity
|
|||||||
*/
|
*/
|
||||||
private $timesheets;
|
private $timesheets;
|
||||||
|
|
||||||
/**
|
// keep the trait include exactly here, for placing the column at the correct position
|
||||||
* @var float
|
use RatesTrait;
|
||||||
*
|
|
||||||
* @ORM\Column(name="fixed_rate", type="float", precision=10, scale=2, nullable=true)
|
|
||||||
* @Assert\GreaterThanOrEqual(0)
|
|
||||||
*/
|
|
||||||
private $fixedRate = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var float
|
|
||||||
*
|
|
||||||
* @ORM\Column(name="hourly_rate", type="float", precision=10, scale=2, nullable=true)
|
|
||||||
* @Assert\GreaterThanOrEqual(0)
|
|
||||||
*/
|
|
||||||
private $hourlyRate = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
@@ -174,44 +161,6 @@ class Activity
|
|||||||
return $this->visible;
|
return $this->visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getFixedRate(): ?float
|
|
||||||
{
|
|
||||||
return $this->fixedRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param float $fixedRate
|
|
||||||
* @return Activity
|
|
||||||
*/
|
|
||||||
public function setFixedRate(?float $fixedRate)
|
|
||||||
{
|
|
||||||
$this->fixedRate = $fixedRate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getHourlyRate(): ?float
|
|
||||||
{
|
|
||||||
return $this->hourlyRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param float $hourlyRate
|
|
||||||
* @return Activity
|
|
||||||
*/
|
|
||||||
public function setHourlyRate(?float $hourlyRate)
|
|
||||||
{
|
|
||||||
$this->hourlyRate = $hourlyRate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -147,21 +147,8 @@ class Customer
|
|||||||
*/
|
*/
|
||||||
private $timezone;
|
private $timezone;
|
||||||
|
|
||||||
/**
|
// keep the trait include exactly here, for placing the column at the correct position
|
||||||
* @var float
|
use RatesTrait;
|
||||||
*
|
|
||||||
* @ORM\Column(name="fixed_rate", type="float", precision=10, scale=2, nullable=true)
|
|
||||||
* @Assert\GreaterThanOrEqual(0)
|
|
||||||
*/
|
|
||||||
private $fixedRate = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var float
|
|
||||||
*
|
|
||||||
* @ORM\Column(name="hourly_rate", type="float", precision=10, scale=2, nullable=true)
|
|
||||||
* @Assert\GreaterThanOrEqual(0)
|
|
||||||
*/
|
|
||||||
private $hourlyRate = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
@@ -523,44 +510,6 @@ class Customer
|
|||||||
return $this->projects;
|
return $this->projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getFixedRate(): ?float
|
|
||||||
{
|
|
||||||
return $this->fixedRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param float $fixedRate
|
|
||||||
* @return Customer
|
|
||||||
*/
|
|
||||||
public function setFixedRate(?float $fixedRate)
|
|
||||||
{
|
|
||||||
$this->fixedRate = $fixedRate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getHourlyRate(): ?float
|
|
||||||
{
|
|
||||||
return $this->hourlyRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param float $hourlyRate
|
|
||||||
* @return Customer
|
|
||||||
*/
|
|
||||||
public function setHourlyRate(?float $hourlyRate)
|
|
||||||
{
|
|
||||||
$this->hourlyRate = $hourlyRate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -83,21 +83,8 @@ class Project
|
|||||||
*/
|
*/
|
||||||
private $activities;
|
private $activities;
|
||||||
|
|
||||||
/**
|
// keep the trait include exactly here, for placing the column at the correct position
|
||||||
* @var float
|
use RatesTrait;
|
||||||
*
|
|
||||||
* @ORM\Column(name="fixed_rate", type="float", precision=10, scale=2, nullable=true)
|
|
||||||
* @Assert\GreaterThanOrEqual(0)
|
|
||||||
*/
|
|
||||||
private $fixedRate = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var float
|
|
||||||
*
|
|
||||||
* @ORM\Column(name="hourly_rate", type="float", precision=10, scale=2, nullable=true)
|
|
||||||
* @Assert\GreaterThanOrEqual(0)
|
|
||||||
*/
|
|
||||||
private $hourlyRate = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Timesheet[]
|
* @var Timesheet[]
|
||||||
@@ -266,44 +253,6 @@ class Project
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getFixedRate(): ?float
|
|
||||||
{
|
|
||||||
return $this->fixedRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param float $fixedRate
|
|
||||||
* @return Project
|
|
||||||
*/
|
|
||||||
public function setFixedRate(?float $fixedRate)
|
|
||||||
{
|
|
||||||
$this->fixedRate = $fixedRate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getHourlyRate(): ?float
|
|
||||||
{
|
|
||||||
return $this->hourlyRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param float $hourlyRate
|
|
||||||
* @return Project
|
|
||||||
*/
|
|
||||||
public function setHourlyRate(?float $hourlyRate)
|
|
||||||
{
|
|
||||||
$this->hourlyRate = $hourlyRate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|||||||
70
src/Entity/RatesTrait.php
Normal file
70
src/Entity/RatesTrait.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?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\Entity;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
trait RatesTrait
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var float
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="fixed_rate", type="float", precision=10, scale=2, nullable=true)
|
||||||
|
* @Assert\GreaterThanOrEqual(0)
|
||||||
|
*/
|
||||||
|
private $fixedRate = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var float
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="hourly_rate", type="float", precision=10, scale=2, nullable=true)
|
||||||
|
* @Assert\GreaterThanOrEqual(0)
|
||||||
|
*/
|
||||||
|
private $hourlyRate = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public function getFixedRate(): ?float
|
||||||
|
{
|
||||||
|
return $this->fixedRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param float $fixedRate
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setFixedRate(?float $fixedRate)
|
||||||
|
{
|
||||||
|
$this->fixedRate = $fixedRate;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public function getHourlyRate(): ?float
|
||||||
|
{
|
||||||
|
return $this->hourlyRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param float $hourlyRate
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setHourlyRate(?float $hourlyRate)
|
||||||
|
{
|
||||||
|
$this->hourlyRate = $hourlyRate;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -111,21 +111,8 @@ class Timesheet
|
|||||||
*/
|
*/
|
||||||
private $rate = 0.00;
|
private $rate = 0.00;
|
||||||
|
|
||||||
/**
|
// keep the trait include exactly here, for placing the column at the correct position
|
||||||
* @var float
|
use RatesTrait;
|
||||||
*
|
|
||||||
* @ORM\Column(name="fixed_rate", type="float", precision=10, scale=2, nullable=true)
|
|
||||||
* @Assert\GreaterThanOrEqual(0)
|
|
||||||
*/
|
|
||||||
private $fixedRate = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var float
|
|
||||||
*
|
|
||||||
* @ORM\Column(name="hourly_rate", type="float", precision=10, scale=2, nullable=true)
|
|
||||||
* @Assert\GreaterThanOrEqual(0)
|
|
||||||
*/
|
|
||||||
private $hourlyRate = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
@@ -332,44 +319,6 @@ class Timesheet
|
|||||||
return $this->rate;
|
return $this->rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getFixedRate(): ?float
|
|
||||||
{
|
|
||||||
return $this->fixedRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param float $fixedRate
|
|
||||||
* @return Timesheet
|
|
||||||
*/
|
|
||||||
public function setFixedRate(?float $fixedRate)
|
|
||||||
{
|
|
||||||
$this->fixedRate = $fixedRate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getHourlyRate(): ?float
|
|
||||||
{
|
|
||||||
return $this->hourlyRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param float $hourlyRate
|
|
||||||
* @return Timesheet
|
|
||||||
*/
|
|
||||||
public function setHourlyRate(?float $hourlyRate)
|
|
||||||
{
|
|
||||||
$this->hourlyRate = $hourlyRate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
|||||||
12
symfony.lock
12
symfony.lock
@@ -72,7 +72,11 @@
|
|||||||
"branch": "master",
|
"branch": "master",
|
||||||
"version": "1.2",
|
"version": "1.2",
|
||||||
"ref": "c1431086fec31f17fbcfe6d6d7e92059458facc1"
|
"ref": "c1431086fec31f17fbcfe6d6d7e92059458facc1"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"config/packages/doctrine_migrations.yaml",
|
||||||
|
"src/Migrations/.gitignore"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"doctrine/event-manager": {
|
"doctrine/event-manager": {
|
||||||
"version": "v1.0.0"
|
"version": "v1.0.0"
|
||||||
@@ -87,10 +91,10 @@
|
|||||||
"version": "v1.0.1"
|
"version": "v1.0.1"
|
||||||
},
|
},
|
||||||
"doctrine/migrations": {
|
"doctrine/migrations": {
|
||||||
"version": "v1.6.2"
|
"version": "v2.0.2"
|
||||||
},
|
},
|
||||||
"doctrine/orm": {
|
"doctrine/orm": {
|
||||||
"version": "v2.6.0"
|
"version": "v2.6.3"
|
||||||
},
|
},
|
||||||
"doctrine/persistence": {
|
"doctrine/persistence": {
|
||||||
"version": "v1.0.0"
|
"version": "v1.0.0"
|
||||||
@@ -495,7 +499,7 @@
|
|||||||
"version": "v4.0.3"
|
"version": "v4.0.3"
|
||||||
},
|
},
|
||||||
"symfony/orm-pack": {
|
"symfony/orm-pack": {
|
||||||
"version": "v1.0.5"
|
"version": "v1.0.6"
|
||||||
},
|
},
|
||||||
"symfony/phpunit-bridge": {
|
"symfony/phpunit-bridge": {
|
||||||
"version": "3.3",
|
"version": "3.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user