automatic billable calculation (#3200)

This commit is contained in:
Kevin Papst
2022-03-18 22:31:50 +01:00
committed by GitHub
parent f7480902b4
commit 30c7782d6e
34 changed files with 409 additions and 53 deletions

View File

@@ -47,7 +47,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* }
* )
*
* @Exporter\Order({"id", "name", "project", "budget", "timeBudget", "budgetType", "color", "visible", "comment"})
* @Exporter\Order({"id", "name", "project", "budget", "timeBudget", "budgetType", "color", "visible", "comment", "billable"})
* @Exporter\Expose("project", label="label.project", exp="object.getProject() === null ? null : object.getProject().getName()")
*/
class Activity implements EntityWithMetaFields, EntityWithBudget
@@ -123,6 +123,18 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
* @Assert\NotNull()
*/
private $visible = true;
/**
* @var bool
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.billable", type="boolean")
*
* @ORM\Column(name="billable", type="boolean", nullable=false)
* @Assert\NotNull()
*/
private $billable = true;
/**
* Meta fields
*
@@ -227,6 +239,16 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
return $this->visible;
}
public function setBillable(bool $billable): void
{
$this->billable = $billable;
}
public function isBillable(): bool
{
return $this->billable;
}
/**
* @return Collection|MetaTableTypeInterface[]
*/

View File

@@ -27,7 +27,7 @@ use Symfony\Component\Validator\Constraints as Assert;
*
* @Serializer\ExclusionPolicy("all")
*
* @Exporter\Order({"id", "name", "company", "number", "vatId", "address", "contact","email", "phone", "mobile", "fax", "homepage", "country", "currency", "timezone", "budget", "timeBudget", "budgetType", "color", "visible", "teams", "comment"})
* @Exporter\Order({"id", "name", "company", "number", "vatId", "address", "contact","email", "phone", "mobile", "fax", "homepage", "country", "currency", "timezone", "budget", "timeBudget", "budgetType", "color", "visible", "teams", "comment", "billable"})
* @ Exporter\Expose("teams", label="label.team", exp="object.getTeams().toArray()", type="array")
*/
class Customer implements EntityWithMetaFields, EntityWithBudget
@@ -98,6 +98,18 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
* @Assert\NotNull()
*/
private $visible = true;
/**
* @var bool
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.billable", type="boolean")
*
* @ORM\Column(name="billable", type="boolean", nullable=false)
* @Assert\NotNull()
*/
private $billable = true;
/**
* @var string|null
*
@@ -353,6 +365,16 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
return $this->visible;
}
public function setBillable(bool $billable): void
{
$this->billable = $billable;
}
public function isBillable(): bool
{
return $this->billable;
}
public function setCompany(?string $company): Customer
{
$this->company = $company;

View File

@@ -48,7 +48,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* }
* )
*
* @Exporter\Order({"id", "name", "customer", "orderNumber", "orderDate", "start", "end", "budget", "timeBudget", "budgetType", "color", "visible", "teams", "comment"})
* @Exporter\Order({"id", "name", "customer", "orderNumber", "orderDate", "start", "end", "budget", "timeBudget", "budgetType", "color", "visible", "teams", "comment", "billable"})
* @Exporter\Expose("customer", label="label.customer", exp="object.getCustomer() === null ? null : object.getCustomer().getName()")
* @ Exporter\Expose("teams", label="label.team", exp="object.getTeams().toArray()", type="array")
*/
@@ -195,6 +195,18 @@ class Project implements EntityWithMetaFields, EntityWithBudget
* @Assert\NotNull()
*/
private $visible = true;
/**
* @var bool
*
* @Serializer\Expose()
* @Serializer\Groups({"Default"})
*
* @Exporter\Expose(label="label.billable", type="boolean")
*
* @ORM\Column(name="billable", type="boolean", nullable=false)
* @Assert\NotNull()
*/
private $billable = true;
/**
* Meta fields
*
@@ -294,6 +306,16 @@ class Project implements EntityWithMetaFields, EntityWithBudget
return $this->visible;
}
public function setBillable(bool $billable): void
{
$this->billable = $billable;
}
public function isBillable(): bool
{
return $this->billable;
}
public function getOrderNumber(): ?string
{
return $this->orderNumber;

View File

@@ -98,6 +98,11 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
*/
public const OVERTIME = 'overtime';
public const BILLABLE_AUTOMATIC = 'auto';
public const BILLABLE_YES = 'yes';
public const BILLABLE_NO = 'no';
public const BILLABLE_DEFAULT = 'default';
/**
* @var int|null
*
@@ -269,6 +274,11 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
* @Assert\NotNull()
*/
private $billable = true;
/**
* Internal property used to determine whether the billable field should be calculated automatically.
* @var string
*/
private $billableMode = self::BILLABLE_DEFAULT;
/**
* @var string
*
@@ -649,6 +659,11 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
return $this->billable;
}
public function getBillable(): bool
{
return $this->billable;
}
public function setBillable(bool $billable): Timesheet
{
$this->billable = $billable;
@@ -656,6 +671,16 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
return $this;
}
public function getBillableMode(): string
{
return $this->billableMode;
}
public function setBillableMode(string $billableMode): void
{
$this->billableMode = $billableMode;
}
public function getFixedRate(): ?float
{
return $this->fixedRate;