Audit 18.09.: Zahlungsdatum nur bei Zahlung, Neupartner-IDs im Snapshot, Pausenende folgt dem Termin
F1: partner_paid_at wird beim Rechnungskauf (paymentStatusPaidAction mit paid=false) nicht mehr gesetzt, sondern erst bei der Rechnungszahlung; der Backfill nimmt das Aktivierungsdatum nur noch ohne jede Registrierungsbestellung (offene Rechnung bleibt leer). F2: Snapshots speichern je Linie new_partner_ids, die Neupartner-Liste zeigt genau diese; aeltere Snapshots ohne IDs rechnen mit der damaligen Regel (Registrierungsmonat, scopeNewPartnerInByActiveDate), damit Kachel und Liste uebereinstimmen. Keine Payload-Versionsaenderung, kein Neuaufbau noetig. F3: Liefertag-/Termin-Aenderung waehrend einer Pause zieht paused_until mit; eine Ausfuehrung loescht auch den paused_by_*-Grund. F4: expiredCount der Firstlines-Seite (Controller, View, Sprachen) zum bereits committeten Test nachgezogen. F5: Backfills schreiben ohne updated_at (toBase()->update, timestamps=false). Kuendigungsbestaetigung abo_cancel_confirm wird im Selfservice serverseitig verlangt. AboStatusExplainer laedt die Historie je Abo und Aktion nur einmal. Stellungnahme und Deploy-Folgen im Audit-Dokument, Regressionstests je Befund. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
b7e8bbd951
commit
03416b0afe
27 changed files with 560 additions and 21 deletions
|
|
@ -165,7 +165,7 @@ it('haelt bei der Kuendigung fest, wer gekuendigt hat', function () {
|
|||
$repository->setModel($abo);
|
||||
$repository->update([
|
||||
'action' => 'abo_update_settings', 'id' => $abo->id, 'view' => 'me',
|
||||
'abo_interval' => 5, 'abo_cancel' => 'true',
|
||||
'abo_interval' => 5, 'abo_cancel' => 'true', 'abo_cancel_confirm' => '1',
|
||||
]);
|
||||
|
||||
$abo = $abo->fresh();
|
||||
|
|
@ -244,6 +244,75 @@ it('rendert das Partial mit Badge, Zustand und Erklaerung', function () {
|
|||
->toContain(__('abo.state_text_payment_failed', ['date' => '10.09.2026']));
|
||||
});
|
||||
|
||||
it('zieht das Pausenende mit, wenn der Liefertermin waehrend der Pause geaendert wird (Audit F3)', function () {
|
||||
$user = aseUser();
|
||||
$abo = aseAbo($user);
|
||||
$this->actingAs($user);
|
||||
|
||||
$repository = new AboRepository;
|
||||
$repository->setModel($abo);
|
||||
$repository->update(['action' => 'abo_update_settings', 'id' => $abo->id, 'view' => 'me', 'abo_interval' => 5, 'abo_pause' => 'true']);
|
||||
|
||||
expect($abo->fresh()->paused_until->format('Y-m-d'))->toBe('2026-11-05');
|
||||
|
||||
// Liefertag im Pausenmonat nach hinten: 5.11. -> 20.11.
|
||||
$repository->setModel($abo->fresh());
|
||||
expect($repository->update(['action' => 'abo_update_settings', 'id' => $abo->id, 'view' => 'me', 'abo_interval' => 20, 'abo_is_active' => 1]))->toBeTrue();
|
||||
|
||||
$abo = $abo->fresh();
|
||||
expect($abo->getRawOriginal('next_date'))->toBe('2026-11-20')
|
||||
->and($abo->paused_until->format('Y-m-d'))->toBe('2026-11-20')
|
||||
->and($abo->status_reason)->toBe('paused_by_consultant')
|
||||
->and(aseExplain($abo)->text)->toContain('20.11.2026');
|
||||
|
||||
// Admin-Termin: gleiche Regel.
|
||||
$repository->setModel($abo);
|
||||
expect($repository->update(['action' => 'abo_update_settings', 'id' => $abo->id, 'view' => 'admin', 'abo_interval' => 10, 'abo_next_month' => '2026-12', 'abo_is_active' => 'true']))->toBeTrue()
|
||||
->and($abo->fresh()->paused_until->format('Y-m-d'))->toBe('2026-12-10');
|
||||
|
||||
// Ausfuehrung gelaufen: Pausenende UND Pausengrund weg.
|
||||
$abo->fresh()->update(['last_date' => '2026-12-10', 'next_date' => '2027-01-10']);
|
||||
|
||||
expect($abo->fresh()->paused_until)->toBeNull()
|
||||
->and($abo->fresh()->status_reason)->toBeNull()
|
||||
->and(aseExplain($abo)->state)->toBe(AboStatusInfo::STATE_ACTIVE);
|
||||
|
||||
// Ohne Pause bleibt paused_until bei einer Terminaenderung leer.
|
||||
$plain = aseAbo(aseUser(), ['next_date' => '2026-10-05']);
|
||||
$repository->setModel($plain);
|
||||
$repository->update(['action' => 'abo_update_settings', 'id' => $plain->id, 'view' => 'me', 'abo_interval' => 20, 'abo_is_active' => 1]);
|
||||
expect($plain->fresh()->paused_until)->toBeNull();
|
||||
});
|
||||
|
||||
it('kuendigt im Selfservice nur mit bestaetigten Folgen (Audit)', function () {
|
||||
$user = aseUser();
|
||||
$abo = aseAbo($user);
|
||||
$this->actingAs($user);
|
||||
|
||||
$repository = new AboRepository;
|
||||
$repository->setModel($abo);
|
||||
|
||||
expect($repository->update(['action' => 'abo_update_settings', 'id' => $abo->id, 'view' => 'me', 'abo_interval' => 5, 'abo_cancel' => 'true']))->toBeFalse()
|
||||
->and(session('alert-error'))->toBe(__('abo.cancel_confirm_required'))
|
||||
->and((int) $abo->fresh()->status)->toBe(2);
|
||||
|
||||
expect($repository->update(['action' => 'abo_update_settings', 'id' => $abo->id, 'view' => 'me', 'abo_interval' => 5, 'abo_cancel' => 'true', 'abo_cancel_confirm' => '0']))->toBeFalse()
|
||||
->and((int) $abo->fresh()->status)->toBe(2);
|
||||
|
||||
expect($repository->update(['action' => 'abo_update_settings', 'id' => $abo->id, 'view' => 'me', 'abo_interval' => 5, 'abo_cancel' => 'true', 'abo_cancel_confirm' => '1']))->toBeTrue()
|
||||
->and((int) $abo->fresh()->status)->toBe(4);
|
||||
});
|
||||
|
||||
it('laesst der Backfill updated_at unangetastet (Audit F5)', function () {
|
||||
$abo = aseAbo(aseUser(), ['status' => 3]);
|
||||
UserAbo::whereKey($abo->id)->toBase()->update(['status_reason' => null, 'updated_at' => '2026-08-01 12:00:00']);
|
||||
|
||||
$this->artisan('abo:backfill-status-reasons')->assertSuccessful();
|
||||
|
||||
expect($abo->fresh()->status_reason)->toBe('payment_failed')
|
||||
->and($abo->fresh()->updated_at->format('Y-m-d H:i:s'))->toBe('2026-08-01 12:00:00');
|
||||
});
|
||||
|
||||
it('traegt Grund und Pausenende fuer Bestandsdaten nach', function () {
|
||||
$failed = aseAbo(aseUser(), ['status' => 3]);
|
||||
$cancelled = aseAbo(aseUser(), ['status' => 4, 'active' => false]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue