Feat: Implement overridable effective pickup date

This commit is contained in:
Björn Fromme
2023-10-18 17:51:44 +02:00
parent 8a96533560
commit 22db06ec64
4 changed files with 27 additions and 8 deletions
+24 -5
View File
@@ -172,13 +172,32 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
return $this;
}
public function getTotalPeriod(): CarbonPeriod
public function getTotalPeriod(): ?CarbonPeriod
{
$destination = $this->getDestination();
$dateFrom = $this->getDateFrom() ?? $destination->getDateFrom();
$dateTo = $this->getDateTo() ?? $destination->getDateTo();
if (null !== $destination = $this->getDestination()) {
$dateFrom = $this->getDateFrom() ?? $destination->getDateFrom();
$dateTo = $this->getDateTo() ?? $destination->getDateTo();
return new CarbonPeriod($dateFrom, $dateTo);
return new CarbonPeriod($dateFrom, $dateTo);
}
return null;
}
public function getEffectivePickupDate(): ?\DateTimeImmutable
{
if (null !== $this->pickupDate) {
return $this->pickupDate;
}
if (0 !== (int) $this->pickup && null !== $destination = $this->getDestination()) {
return $destination
->getDateFrom()
->modify('-1 day')
;
}
return null;
}
public function getPickupDate(): ?\DateTimeImmutable