Besseres Handling Rückerstattungen
This commit is contained in:
@@ -74,14 +74,24 @@ class AcceptRefundCommand
|
||||
$response->errorTypes['declaration'] = 'Bitte bestätige die Erklärung, damit wir erstatten können.';
|
||||
}
|
||||
|
||||
if ($owner === '') {
|
||||
$response->errorTypes['accountOwner'] = 'Bitte gib an, wem das Konto gehört.';
|
||||
}
|
||||
// Wer spendet, gibt kein Konto an -- alles Weitere betrifft nur die Auszahlung.
|
||||
if (!$this->request->donation) {
|
||||
// Erstattet wird ausschließlich auf das Konto, von dem der Beitrag kam. Ohne diese
|
||||
// Bestätigung ließe sich über eine Erstattung Geld auf ein fremdes Konto umleiten.
|
||||
if (!$this->request->accountDeclarationAccepted && $this->request->capturedBy === null) {
|
||||
$response->errorTypes['accountDeclaration'] = 'Bitte bestätige, dass es das Konto ist, '
|
||||
. 'von dem der Beitrag gezahlt wurde.';
|
||||
}
|
||||
|
||||
if ($iban === '') {
|
||||
$response->errorTypes['accountIban'] = 'Bitte gib die IBAN des Kontos ein.';
|
||||
} elseif (!Iban::isValid($iban)) {
|
||||
$response->errorTypes['accountIban'] = 'Diese IBAN stimmt nicht. Bitte prüfe deine Eingabe.';
|
||||
if ($owner === '') {
|
||||
$response->errorTypes['accountOwner'] = 'Bitte gib an, wem das Konto gehört.';
|
||||
}
|
||||
|
||||
if ($iban === '') {
|
||||
$response->errorTypes['accountIban'] = 'Bitte gib die IBAN des Kontos ein.';
|
||||
} elseif (!Iban::isValid($iban)) {
|
||||
$response->errorTypes['accountIban'] = 'Diese IBAN stimmt nicht. Bitte prüfe deine Eingabe.';
|
||||
}
|
||||
}
|
||||
|
||||
if ($response->errorTypes !== []) {
|
||||
@@ -108,14 +118,21 @@ class AcceptRefundCommand
|
||||
// Der Beleg entsteht in der Transaktion, weil er den bestätigten Stand abbildet; scheitert das
|
||||
// Einreichen, soll auch kein Beleg gelten.
|
||||
$document = DB::transaction(function () use ($refund, $owner, $iban, $costUnit) {
|
||||
$refund->account_owner = $owner;
|
||||
$refund->account_iban = $iban;
|
||||
// Bei einer Spende bleiben die Kontofelder leer -- und zwar `null` und nicht Leerstring: Der
|
||||
// SEPA-Export unterscheidet daran, ob es etwas auszuzahlen gibt.
|
||||
$refund->account_owner = $this->request->donation ? null : $owner;
|
||||
$refund->account_iban = $this->request->donation ? null : $iban;
|
||||
$refund->captured_by = $this->request->capturedBy;
|
||||
$refund->status = ParticipantRefund::STATUS_ACCEPTED;
|
||||
$refund->accepted_at = now();
|
||||
$refund->save();
|
||||
|
||||
$document = new CreateRefundDocumentCommand(new CreateRefundDocumentRequest($refund))->execute();
|
||||
// Die Spende wird hier ausdrücklich mitgegeben statt am Vorgang abgelesen: Die Abrechnung,
|
||||
// die sie führt, entsteht erst weiter unten -- dieser Beleg ist ihr Anhang.
|
||||
$document = new CreateRefundDocumentCommand(new CreateRefundDocumentRequest(
|
||||
refund: $refund,
|
||||
donation: $this->request->donation,
|
||||
))->execute();
|
||||
|
||||
$invoice = $this->createInvoice($refund, $costUnit, $document);
|
||||
|
||||
@@ -132,7 +149,9 @@ class AcceptRefundCommand
|
||||
$this->notify($refund, $document);
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Vielen Dank. Deine Angaben liegen uns vor.';
|
||||
$response->message = $this->request->donation
|
||||
? 'Vielen Dank für deine Spende.'
|
||||
: 'Vielen Dank. Deine Angaben liegen uns vor.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
@@ -177,7 +196,9 @@ class AcceptRefundCommand
|
||||
invoiceType: InvoiceType::INVOICE_TYPE_PARTICIPATION_REFUND,
|
||||
totalAmount: $refund->amount?->getAmount() ?? 0.0,
|
||||
receiptFile: $this->storeReceipt($costUnit, $document),
|
||||
isDonation: false,
|
||||
// Hier landet die Entscheidung des Teilis, und nur hier: Die Abrechnung führt sie, der
|
||||
// Vorgang liest sie über ParticipantRefund::isDonation() zurück.
|
||||
isDonation: $this->request->donation,
|
||||
userId: $participant->user_id,
|
||||
contactEmail: $participant->email_1,
|
||||
contactPhone: $participant->phone_1,
|
||||
@@ -247,8 +268,15 @@ class AcceptRefundCommand
|
||||
{
|
||||
$paid = $refund->participant->amount_paid?->toString() ?? '0,00 Euro';
|
||||
|
||||
// Die Schatzmeisterei sieht die Abrechnung ohne den Vorgang dahinter. Dass nichts ausgezahlt
|
||||
// wird, steht zwar im Spendenkennzeichen -- warum keine Bankverbindung dabei ist, aber nur hier.
|
||||
$subject = $this->request->donation
|
||||
? 'Spende statt Rückerstattung Teilnahmebeitrag'
|
||||
: 'Rückerstattung Teilnahmebeitrag';
|
||||
|
||||
return Str::limit(sprintf(
|
||||
'Rückerstattung Teilnahmebeitrag %s – %s',
|
||||
'%s %s – %s',
|
||||
$subject,
|
||||
$refund->event->name,
|
||||
$refund->reasonLabel()
|
||||
), 180) . sprintf(' | Gezahlter Beitrag vor Erstattung: %s', $paid);
|
||||
|
||||
Reference in New Issue
Block a user