Calculation errors for refunded amounts
This commit is contained in:
@@ -14,6 +14,7 @@ use App\Enumerations\CostUnitType;
|
||||
use App\Enumerations\InvoiceStatus;
|
||||
use App\Enumerations\InvoiceType;
|
||||
use App\Enumerations\RefundReason;
|
||||
use App\Enumerations\RetentionReason;
|
||||
use App\Enumerations\UserRole;
|
||||
use App\Mail\ParticipantRefundMails\RefundAcceptedMail;
|
||||
use App\Mail\ParticipantRefundMails\RefundReleasedMail;
|
||||
@@ -206,17 +207,23 @@ class ParticipantRefundTest extends TestCase
|
||||
], $attributes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Vorgabewert 300,00 € entspricht dem gezahlten Beitrag -- es bleibt also nichts einbehalten und
|
||||
* es braucht keinen Einbehaltungsgrund. Bei kleineren Beträgen muss einer mitgegeben werden.
|
||||
*/
|
||||
private function release(
|
||||
EventParticipant $participant,
|
||||
float $amount = 300.0,
|
||||
string $reason = RefundReason::SICKNESS,
|
||||
?string $note = null,
|
||||
?string $retentionReason = null,
|
||||
) {
|
||||
return new ReleaseRefundCommand(new ReleaseRefundRequest(
|
||||
participant: $participant,
|
||||
amount: new Amount($amount, 'Euro'),
|
||||
reason: $reason,
|
||||
reasonNote: $note,
|
||||
retentionReason: $retentionReason,
|
||||
))->execute();
|
||||
}
|
||||
|
||||
@@ -296,10 +303,12 @@ class ParticipantRefundTest extends TestCase
|
||||
{
|
||||
$participant = $this->makeParticipant($this->makeEvent());
|
||||
|
||||
$response = $this->release($participant, 220.0);
|
||||
$response = $this->release($participant, 220.0, retentionReason: RetentionReason::CANCELLATION_FEE);
|
||||
|
||||
$this->assertTrue($response->success);
|
||||
$this->assertEqualsWithDelta(220.0, $response->refund->amount->getAmount(), 0.001);
|
||||
// Der Rest wird am Vorgang festgeschrieben, nicht später gerechnet.
|
||||
$this->assertEqualsWithDelta(80.0, $response->refund->retained_amount->getAmount(), 0.001);
|
||||
}
|
||||
|
||||
public function test_release_is_rejected_without_an_amount(): void
|
||||
@@ -626,6 +635,8 @@ class ParticipantRefundTest extends TestCase
|
||||
$response = $this->postJson('/api/v1/participant-refund/' . $participant->identifier . '/release', [
|
||||
'amount' => '220,50',
|
||||
'reason' => RefundReason::SICKNESS,
|
||||
// Weniger als gezahlt -- der Rest bleibt beim Verband und braucht eine Begründung.
|
||||
'retentionReason' => RetentionReason::CANCELLATION_FEE,
|
||||
]);
|
||||
|
||||
$response->assertOk()->assertJsonPath('status', 'success');
|
||||
@@ -768,7 +779,13 @@ class ParticipantRefundTest extends TestCase
|
||||
public function test_the_release_mail_renders_with_the_link(): void
|
||||
{
|
||||
$participant = $this->makeParticipant($this->makeEvent());
|
||||
$refund = $this->release($participant, 220.0, RefundReason::OTHER, 'Umzug')->refund;
|
||||
$refund = $this->release(
|
||||
$participant,
|
||||
220.0,
|
||||
RefundReason::OTHER,
|
||||
'Umzug',
|
||||
RetentionReason::CANCELLATION_FEE
|
||||
)->refund;
|
||||
|
||||
$html = new RefundReleasedMail($participant, $refund)->render();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user