fix: correctly apply due dates for contract and invoice upload reminders
This commit is contained in:
@@ -6,7 +6,7 @@ use App\Entity\Traits\BlameableEntity;
|
||||
use App\Entity\Traits\SoftDeletableEntity;
|
||||
use App\Entity\Traits\TimestampableEntity;
|
||||
use App\Repository\AssignmentRepository;
|
||||
use Carbon\CarbonPeriod;
|
||||
use Carbon\CarbonPeriodImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
@@ -270,13 +270,19 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEffectivePeriod(): ?CarbonPeriod
|
||||
/**
|
||||
* Immutable on purpose: a plain CarbonPeriod hands out mutable Carbon instances, so a caller
|
||||
* deriving one date from another - `$end = $period->getEndDate(); $end->addDays(14)` - moves
|
||||
* the original as well and silently collapses its own period. CarbonPeriodImmutable yields
|
||||
* CarbonImmutable from start, end and getEndDate(), which makes that mistake impossible.
|
||||
*/
|
||||
public function getEffectivePeriod(): ?CarbonPeriodImmutable
|
||||
{
|
||||
if (null !== $destination = $this->getDestination()) {
|
||||
$dateFrom = $this->getDateFrom() ?? $destination->getDateFrom();
|
||||
$dateTo = $this->getDateTo() ?? $destination->getDateTo();
|
||||
|
||||
return new CarbonPeriod($dateFrom, $dateTo);
|
||||
return new CarbonPeriodImmutable($dateFrom, $dateTo);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user