Besseres Handling Rückerstattungen

This commit is contained in:
2026-09-06 20:11:50 +02:00
parent e730d6db63
commit b9795f08f0
26 changed files with 927 additions and 104 deletions
+59 -5
View File
@@ -98,7 +98,8 @@ class RefundDocumentTest extends TestCase
DocumentTemplate::create([
'document_type' => DocumentTemplate::TYPE_PARTICIPANT_REFUND,
'block' => DocumentTemplate::BLOCK_BODY,
'content' => '{details_table}<p>{refund_amount} / {refund_reason} / {refund_reason_text}</p>'
'content' => '<p>{intro_text}</p>{details_table}'
. '<p>{refund_amount} / {refund_reason} / {refund_reason_text}</p>'
. '<p>{account_owner} / {account_iban}</p>'
. '<p>{paid_amount} / {invoice_number}</p>'
. '<p>{declaration_text}</p>',
@@ -195,15 +196,19 @@ class RefundDocumentTest extends TestCase
], $attributes));
}
private function document(ParticipantRefund $refund)
private function document(ParticipantRefund $refund, bool $donation = false)
{
return new CreateRefundDocumentCommand(new CreateRefundDocumentRequest($refund))->execute();
return new CreateRefundDocumentCommand(
new CreateRefundDocumentRequest($refund, donation: $donation)
)->execute();
}
/** Das gerenderte HTML -- die Zwischenstufe vor dem PDF, an der sich der Inhalt prüfen lässt. */
private function html(ParticipantRefund $refund): string
private function html(ParticipantRefund $refund, bool $donation = false): string
{
$command = new CreateRefundDocumentCommand(new CreateRefundDocumentRequest($refund));
$command = new CreateRefundDocumentCommand(
new CreateRefundDocumentRequest($refund, donation: $donation)
);
$number = new ReflectionMethod($command, 'documentNumber')->invoke($command);
$tokens = new ReflectionMethod($command, 'buildTokens')->invoke($command, $number);
@@ -380,6 +385,55 @@ class RefundDocumentTest extends TestCase
$this->assertStringContainsString('Ich versichere', $this->html($this->makeRefund()));
}
public function test_the_payout_receipt_carries_the_account_declaration_too(): void
{
// Beide Sätze wurden angekreuzt, beide gehören auf den Beleg: Die Kontoerklärung ist der Grund,
// warum die Auszahlung auf genau dieses Konto zulässig ist.
$html = $this->html($this->makeRefund());
$this->assertStringContainsString('Ich versichere, dass ich den genannten Betrag beglichen habe', $html);
$this->assertStringContainsString('dass das angegebene Konto dasselbe ist', $html);
}
/*
|--------------------------------------------------------------------------
| Der Beleg über eine Spende
|--------------------------------------------------------------------------
*/
public function test_a_donation_receipt_carries_the_waiver_instead(): void
{
$html = $this->html($this->makeRefund(['account_owner' => null, 'account_iban' => null]), donation: true);
$this->assertStringContainsString('verzichte auf die Auszahlung', $html);
// Die Erklärungen des Auszahlungswegs haben hier nichts zu suchen -- es gibt kein Konto.
$this->assertStringNotContainsString('dass das angegebene Konto dasselbe ist', $html);
}
public function test_a_donation_receipt_shows_no_bank_details(): void
{
$html = $this->html($this->makeRefund(['account_owner' => null, 'account_iban' => null]), donation: true);
$this->assertStringNotContainsString('IBAN', $html);
$this->assertStringContainsString('Auf die Auszahlung wird verzichtet', $html);
}
public function test_the_intro_sentence_follows_the_chosen_way(): void
{
$refund = $this->makeRefund();
$this->assertStringContainsString('bitte um die Rückerstattung', $this->html($refund));
$this->assertStringContainsString('spende ihn an den Verband', $this->html($refund, donation: true));
}
public function test_a_donation_receipt_is_a_pdf_as_well(): void
{
$response = $this->document($this->makeRefund(['account_owner' => null, 'account_iban' => null]), donation: true);
$this->assertTrue($response->success);
$this->assertStringStartsWith('%PDF', $response->pdfContent);
}
public function test_free_text_reason_replaces_the_catalog_text(): void
{
$html = $this->html($this->makeRefund([