Creating Participation refunds
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\ParticipantRefund\Actions\CancelRefund;
|
||||
|
||||
use App\Models\ParticipantRefund;
|
||||
|
||||
/**
|
||||
* Bricht eine freigegebene, aber noch nicht bestätigte Erstattung ab.
|
||||
*
|
||||
* Danach läuft der Link des Teilis ins Leere und die Anmeldung sieht aus wie vor der Freigabe. Bewusst
|
||||
* ohne Mail: der Teili soll nicht über etwas informiert werden, das für ihn nie stattgefunden hat --
|
||||
* die Aktionsleitung klärt das im Zweifel direkt.
|
||||
*
|
||||
* Ein bereits bestätigter Vorgang ist unantastbar: dazu gibt es einen Beleg, und der Teili hat seine
|
||||
* Bankverbindung im Vertrauen darauf herausgegeben.
|
||||
*/
|
||||
class CancelRefundCommand
|
||||
{
|
||||
public function __construct(private readonly CancelRefundRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): CancelRefundResponse
|
||||
{
|
||||
$response = new CancelRefundResponse();
|
||||
$refund = $this->request->refund;
|
||||
|
||||
if (!$refund->isPending()) {
|
||||
$response->message = $refund->isAccepted()
|
||||
? 'Diese Erstattung wurde bereits bestätigt und kann nicht mehr abgebrochen werden.'
|
||||
: 'Diese Erstattung wurde bereits abgebrochen.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$refund->status = ParticipantRefund::STATUS_CANCELLED;
|
||||
$refund->cancelled_at = now();
|
||||
$refund->save();
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Die Erstattung wurde abgebrochen.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user