feat: show due documents on teamer dashboard

This commit is contained in:
Björn Fromme
2024-01-29 18:27:38 +01:00
parent 26bb6d4f55
commit 92e3dde9b8
5 changed files with 150 additions and 64 deletions
+32
View File
@@ -6,6 +6,8 @@ use App\Entity\Traits\BlameableEntity;
use App\Entity\Traits\SoftDeletableEntity;
use App\Entity\Traits\TimestampableEntity;
use App\Repository\DispositionRepository;
use Carbon\Carbon;
use Carbon\CarbonPeriod;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
@@ -187,4 +189,34 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
return $this;
}
public function isContractDue(): bool
{
if (null !== $this->getDocumentByType(Upload::TYPE_CONTRACT)) {
return false;
}
$assignment = $this->getAssignment();
$assignmentPeriod = $assignment->getEffectivePeriod();
$dueDateFrom = $this->getCreatedAt()->modify('+ 7days');
$dueDateTo = $assignmentPeriod->end->modify('-1 day');
$period = CarbonPeriod::create($dueDateFrom, $dueDateTo);
return $period->isStarted();
}
public function isInvoiceDue(): bool
{
if (null !== $this->getDocumentByType(Upload::TYPE_INVOICE)) {
return false;
}
$assignment = $this->getAssignment();
$assignmentPeriod = $assignment->getEffectivePeriod();
$period = CarbonPeriod::create($assignmentPeriod->getEndDate(), $assignmentPeriod->getEndDate()->modify('+14 days'));
return $period->isStarted();
}
}