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
+88
View File
@@ -412,6 +412,94 @@ class RefundDirectCaptureTest extends TestCase
$this->assertNotNull(ParticipantRefund::first()->invoice_id);
}
/*
|--------------------------------------------------------------------------
| Der Teili spendet -- die Aktionsleitung nimmt es auf
|--------------------------------------------------------------------------
*/
public function test_a_donation_is_submitted_right_away_without_bank_details(): void
{
$participant = $this->makeParticipant();
$response = new ReleaseRefundCommand(new ReleaseRefundRequest(
participant: $participant,
amount: new Amount(220.0, 'Euro'),
reason: RefundReason::SICKNESS,
retentionReason: RetentionReason::CANCELLATION_FEE,
donation: true,
))->execute();
$this->assertTrue($response->success);
$this->assertStringContainsString('Spende', $response->message);
$refund = ParticipantRefund::first();
$this->assertSame(ParticipantRefund::STATUS_ACCEPTED, $refund->status);
$this->assertNull($refund->account_iban);
$this->assertTrue($refund->isDonation());
// Wer sie aufgenommen hat, wird auch hier festgehalten -- der Teili hat nichts angekreuzt.
$this->assertSame($this->management->id, $refund->captured_by);
$this->assertTrue((bool) Invoice::first()->donation);
}
public function test_a_donation_with_bank_details_is_refused(): void
{
$participant = $this->makeParticipant();
// Beides zusammen ist widersprüchlich: Lieber nachfragen, als eines stillschweigend zu verwerfen.
$response = new ReleaseRefundCommand(new ReleaseRefundRequest(
participant: $participant,
amount: new Amount(220.0, 'Euro'),
reason: RefundReason::SICKNESS,
accountOwner: 'Mika Muster',
accountIban: 'DE02120300000000202051',
retentionReason: RetentionReason::CANCELLATION_FEE,
donation: true,
))->execute();
$this->assertFalse($response->success);
$this->assertStringContainsString('Bankverbindung', $response->message);
$this->assertSame(0, ParticipantRefund::count());
}
public function test_a_donation_without_a_cost_unit_is_refused(): void
{
// Gebucht wird sie trotzdem -- ohne Kostenstelle gibt es nichts, worauf.
$participant = $this->makeParticipant($this->makeEvent(['cost_unit_id' => null]));
$response = new ReleaseRefundCommand(new ReleaseRefundRequest(
participant: $participant,
amount: new Amount(220.0, 'Euro'),
reason: RefundReason::SICKNESS,
retentionReason: RetentionReason::CANCELLATION_FEE,
donation: true,
))->execute();
$this->assertFalse($response->success);
$this->assertStringContainsString('Kostenstelle', $response->message);
$this->assertSame(0, ParticipantRefund::count());
}
public function test_release_over_http_submits_a_donation(): void
{
$participant = $this->makeParticipant();
$this->postJson('/api/v1/participant-refund/' . $participant->identifier . '/release', [
'amount' => '220,00',
'reason' => RefundReason::SICKNESS,
'retentionReason' => RetentionReason::CANCELLATION_FEE,
'accountOwner' => '',
'accountIban' => '',
'donation' => true,
])
->assertOk()
->assertJsonPath('status', 'success')
->assertJsonPath('refund.status', ParticipantRefund::STATUS_ACCEPTED)
->assertJsonPath('refund.donation', true);
$this->assertTrue((bool) Invoice::first()->donation);
}
public function test_release_over_http_without_bank_details_keeps_the_old_way(): void
{
$participant = $this->makeParticipant();