Feedback-Umsetzung (dev/2026-07-22/feedback-analyse-2026-07-24.md, alle 10 Punkte):
- VIP-Statistik: eigener Berater ('ich', Linie 0) in Neue-Kundenabos- und beiden Top-10-Listen; Top-10-Umsatz sortiert nach abgerechneten Ist-Punkten + Abo-Anzahl-Spalte; Fußnote nicht-payline-wirksame Punkte (SalesVolumePoints::nonPaylinePoints)
- Führungskräfte-Liste: beide Sichten 'direkt' (an nächster FK abgeschnitten, additiv) und 'gesamt' (komplette Downline), Gesamt-Spalte nach Kundenzählweise
- Team-Abos: je Ebene 'abgerechnet (Monat)' und 'bis zum 25. erwartet'; Payline-Karte mit Teamabo-/Kundenabo-Zählern
- Incentive-Live-Ranking: Qualifizierte zuerst nummeriert (fixt auch isWinner rank<=max_winners)
- Porto: Netto-/Brutto-Kennzeichnung (Berater netto, Endkunden inkl. MwSt., portal_view-Flag; auch CRM-/Shop-Warenkorb + Checkout), Yard::shipping_tax-Fix
- Struktur-Ansicht: Abo-Badges 'A' (eigenes Abo) und '(n)' (Kundenabos) je Teampartner, gebatcht
- Abo-Löschung: Softdelete setzt active=0 (UserAbo deleting-Hook) + Bereinigungs-Migration für gelöschte-aber-aktive Abos
- Doku: technische Analyse + Kundinnen-Feedback-Dokument unter dev/2026-07-22/
- Tests: IncentiveRankingTest, TeamStructureAboBadgesTest, YardShippingTaxTest (neu); BackofficeStatisticsListsTest, TeamAboOverviewTest, PaylineForecastServiceTest, AboAdminDeleteTest, AboOneTimeViewTest erweitert
Außerdem enthalten (Branch-WIP vor dem Feedback): DATEV-Abgleich-Fixes 08+09/2025, USt-ID-Live-Validierung sowie restliche unkommittete Stände (u. a. Abo-Pause-Sprachkeys).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
118 lines
3.5 KiB
PHP
118 lines
3.5 KiB
PHP
<?php
|
|
|
|
use App\Models\Incentive;
|
|
use App\Models\IncentiveParticipant;
|
|
use App\Models\IncentivePointsLog;
|
|
use App\Models\UserSalesVolume;
|
|
use App\Services\Incentive\IncentiveTracker;
|
|
|
|
// === Ranking Logic ===
|
|
|
|
it('ranking logic assigns ranks qualified first, then by total_points descending', function () {
|
|
$p1 = new IncentiveParticipant(['total_points' => 3000, 'is_qualified' => false]);
|
|
$p2 = new IncentiveParticipant(['total_points' => 1000, 'is_qualified' => true]);
|
|
$p3 = new IncentiveParticipant(['total_points' => 2000, 'is_qualified' => true]);
|
|
|
|
// Simulate the ranking logic from IncentiveTracker::updateRanking
|
|
$participants = collect([$p1, $p2, $p3])
|
|
->sortByDesc(fn (IncentiveParticipant $p) => [$p->is_qualified, $p->total_points])
|
|
->values();
|
|
$rank = 1;
|
|
foreach ($participants as $p) {
|
|
$p->rank = $rank;
|
|
$rank++;
|
|
}
|
|
|
|
expect($p3->rank)->toBe(1)
|
|
->and($p2->rank)->toBe(2)
|
|
->and($p1->rank)->toBe(3);
|
|
});
|
|
|
|
// === Determine Log Type ===
|
|
|
|
it('determines abo type for shop orders', function () {
|
|
$method = new ReflectionMethod(IncentiveParticipant::class, 'determineLogType');
|
|
|
|
$usv = new UserSalesVolume([
|
|
'status_turnover' => 2,
|
|
'status_points' => 1,
|
|
]);
|
|
|
|
expect($method->invoke(null, $usv))->toBe('abo');
|
|
});
|
|
|
|
it('determines abo type for customer-only points', function () {
|
|
$method = new ReflectionMethod(IncentiveParticipant::class, 'determineLogType');
|
|
|
|
$usv = new UserSalesVolume([
|
|
'status_turnover' => 1,
|
|
'status_points' => 2,
|
|
]);
|
|
|
|
expect($method->invoke(null, $usv))->toBe('abo');
|
|
});
|
|
|
|
it('determines partner type for advisor orders', function () {
|
|
$method = new ReflectionMethod(IncentiveParticipant::class, 'determineLogType');
|
|
|
|
$usv = new UserSalesVolume([
|
|
'status_turnover' => 1,
|
|
'status_points' => 1,
|
|
]);
|
|
|
|
expect($method->invoke(null, $usv))->toBe('partner');
|
|
});
|
|
|
|
// === Edge Cases ===
|
|
|
|
it('qualification changes correctly on increment/decrement', function () {
|
|
$incentive = new Incentive(['min_direct_partners' => 4, 'min_customer_abos' => 6]);
|
|
|
|
$participant = new IncentiveParticipant([
|
|
'qualified_partners' => 3,
|
|
'qualified_abos' => 6,
|
|
]);
|
|
$participant->setRelation('incentive', $incentive);
|
|
|
|
// Not qualified yet
|
|
expect($participant->checkQualification())->toBeFalse();
|
|
|
|
// Add one more partner
|
|
$participant->qualified_partners = 4;
|
|
expect($participant->checkQualification())->toBeTrue();
|
|
|
|
// Storno removes a partner
|
|
$participant->qualified_partners = 3;
|
|
expect($participant->checkQualification())->toBeFalse();
|
|
});
|
|
|
|
it('handles zero max_winners edge case', function () {
|
|
$incentive = new Incentive(['max_winners' => 1]);
|
|
|
|
$winner = new IncentiveParticipant(['is_qualified' => true, 'rank' => 1]);
|
|
$winner->setRelation('incentive', $incentive);
|
|
|
|
$loser = new IncentiveParticipant(['is_qualified' => true, 'rank' => 2]);
|
|
$loser->setRelation('incentive', $incentive);
|
|
|
|
expect($winner->isWinner())->toBeTrue()
|
|
->and($loser->isWinner())->toBeFalse();
|
|
});
|
|
|
|
it('points log total handles negative values for storno', function () {
|
|
$log = new IncentivePointsLog([
|
|
'points_onetime' => -600,
|
|
'points_accumulated' => 0,
|
|
]);
|
|
|
|
expect($log->getTotalPoints())->toBe(-600);
|
|
});
|
|
|
|
it('points log total handles mixed values', function () {
|
|
$log = new IncentivePointsLog([
|
|
'points_onetime' => 0,
|
|
'points_accumulated' => 250,
|
|
]);
|
|
|
|
expect($log->getTotalPoints())->toBe(250);
|
|
});
|