helper for handling billable fields (#1900)

This commit is contained in:
Kevin Papst
2020-08-20 15:03:57 +02:00
committed by GitHub
parent 7a1dada9dc
commit b9ee811cbf
12 changed files with 213 additions and 44 deletions

View File

@@ -17,15 +17,15 @@ use App\Form\Model\DateRange;
/**
* Can be used for advanced timesheet repository queries.
*/
class TimesheetQuery extends ActivityQuery
class TimesheetQuery extends ActivityQuery implements BillableInterface
{
use BillableTrait;
public const STATE_ALL = 1;
public const STATE_RUNNING = 2;
public const STATE_STOPPED = 3;
public const STATE_EXPORTED = 4;
public const STATE_NOT_EXPORTED = 5;
public const STATE_BILLABLE = 6;
public const STATE_NOT_BILLABLE = 7;
public const TIMESHEET_ORDER_ALLOWED = ['begin', 'end', 'duration', 'rate', 'customer', 'project', 'activity', 'description'];
@@ -45,10 +45,6 @@ class TimesheetQuery extends ActivityQuery
* @var int
*/
protected $exported = self::STATE_ALL;
/**
* @var int
*/
private $billable = self::STATE_ALL;
/**
* @var \DateTime|null
*/
@@ -295,30 +291,6 @@ class TimesheetQuery extends ActivityQuery
return $this;
}
public function getBillable(): int
{
return $this->billable;
}
public function isBillable(): bool
{
return $this->billable === self::STATE_BILLABLE;
}
public function isNotBillable(): bool
{
return $this->billable === self::STATE_NOT_BILLABLE;
}
public function setBillable(int $billable): TimesheetQuery
{
if (\in_array($billable, [self::STATE_ALL, self::STATE_BILLABLE, self::STATE_NOT_BILLABLE], true)) {
$this->billable = $billable;
}
return $this;
}
public function getModifiedAfter(): ?\DateTime
{
return $this->modifiedAfter;