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; return $this;
} }
public function getTotalPeriod(): CarbonPeriod public function getTotalPeriod(): ?CarbonPeriod
{ {
$destination = $this->getDestination(); if (null !== $destination = $this->getDestination()) {
$dateFrom = $this->getDateFrom() ?? $destination->getDateFrom(); $dateFrom = $this->getDateFrom() ?? $destination->getDateFrom();
$dateTo = $this->getDateTo() ?? $destination->getDateTo(); $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 public function getPickupDate(): ?\DateTimeImmutable
+1 -1
View File
@@ -53,7 +53,7 @@ class AssignmentType extends AbstractType
'required' => false, 'required' => false,
]) ])
->add('pickupDate', DatepickerType::class, [ ->add('pickupDate', DatepickerType::class, [
'label' => 'Busabfahrt', 'label' => 'abweichende Busabfahrt',
'required' => false, 'required' => false,
]) ])
->add('pickup', BpnPickupType::class, [ ->add('pickup', BpnPickupType::class, [
+1 -1
View File
@@ -54,7 +54,7 @@
<td> <td>
{{ assignment.pickup ? assignment.pickup|bpn_pickup_label|default('-') : '-' }} {{ assignment.pickup ? assignment.pickup|bpn_pickup_label|default('-') : '-' }}
<br> <br>
{{ assignment.pickupDate ? assignment.pickupDate|date('d.m.Y') : '' }} {{ assignment.effectivePickupDate ? assignment.effectivePickupDate|date('d.m.Y') : '' }}
</td> </td>
<td> <td>
{{ assignment.applications|length }}/{{ assignment.availableDispositions - assignment.dispositions|length }} {{ assignment.applications|length }}/{{ assignment.availableDispositions - assignment.dispositions|length }}
+1 -1
View File
@@ -62,7 +62,7 @@
<td> <td>
{{ assignment.pickup ? assignment.pickup|bpn_pickup_label|default('-') : '-' }} {{ assignment.pickup ? assignment.pickup|bpn_pickup_label|default('-') : '-' }}
<br> <br>
{{ assignment.pickupDate ? assignment.pickupDate|date('d.m.Y') : '' }} {{ assignment.effectivePickupDate ? assignment.effectivePickupDate|date('d.m.Y') : '' }}
</td> </td>
<td> <td>
<div class="flex items-center space-x-1 justify-end"> <div class="flex items-center space-x-1 justify-end">