Creating Participation refunds
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Enumerations\ParticipationType;
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
use App\Models\EventParticipant;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Repositories\ParticipantRefundRepository;
|
||||
use App\ValueObjects\Age;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -74,6 +75,10 @@ class EventParticipantResource extends JsonResource
|
||||
// Numerisch, damit das Frontend rechnen bzw. auf "kostenlos" prüfen kann -- `value` oben ist
|
||||
// ein Amount-Objekt und serialisiert nicht.
|
||||
'amountExpectedValue' => $this->resource->amount?->getAmount() ?? 0.0,
|
||||
'amountPaidValue' => $this->resource->amount_paid?->getAmount() ?? 0.0,
|
||||
// Der laufende bzw. bestätigte Erstattungsvorgang -- null, wenn keiner existiert oder
|
||||
// der letzte abgebrochen wurde.
|
||||
'refund' => $this->refund($request),
|
||||
'alcoholicsAllowed' => new Age($this->resource->birthday)->getAge() >= $event->alcoholics_age,
|
||||
'localGroupPostcode' => $this->resource->localGroup()->first()?->postcode ?? '00000',
|
||||
'localGroupCity' => $this->resource->localGroup()->first()?->city ?? '00000',
|
||||
@@ -106,4 +111,17 @@ class EventParticipantResource extends JsonResource
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Der für die Anzeige maßgebliche Erstattungsvorgang.
|
||||
*
|
||||
* Abgebrochene Vorgänge bleiben außen vor: für die Aktionsleitung soll die Anmeldung danach
|
||||
* aussehen wie vor der Freigabe.
|
||||
*/
|
||||
private function refund($request): ?array
|
||||
{
|
||||
$refund = new ParticipantRefundRepository()->currentFor($this->resource);
|
||||
|
||||
return $refund?->toResource()->toArray($request);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user