Team-Abo-Uebersicht: nur aktive Berater zaehlen

Die Linientabelle zaehlte alle Downline-User statt nur aktive Berater
(m_level + gueltiges payment_account), wodurch zu viele Berater angezeigt
wurden. Filter-Logik aus BackofficeDashboardService (isActiveConsultant,
activeTeamUserIds) wiederverwendet und in TeamAboOverviewService
(buildLineRow, teamKpis, monthlyGrowth) angewendet.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Kevin 2026-06-25 13:25:44 +00:00
parent 386851aee8
commit 9565814221
3 changed files with 74 additions and 11 deletions

View file

@ -123,6 +123,38 @@ it('gruppiert Team-Abos nach Ebenen mit Eigen- und Kundenabos', function (): voi
->and($totals['total_abos'])->toBe(5);
});
it('zählt nur aktive Berater und blendet inaktive/fehlerhafte aus', function (): void {
$root = makeUser();
// Aktiver Berater (m_level + gültiges payment_account)
$anna = makeUser($root->id);
// Inaktiv: kein payment_account
$noPayment = makeUser($root->id);
$noPayment->forceFill(['payment_account' => null])->save();
// Inaktiv: keine Mitgliedsebene
$noLevel = makeUser($root->id);
$noLevel->forceFill(['m_level' => null])->save();
// Abos der inaktiven Berater dürfen nicht in die Übersicht einfließen
makeAbo($anna->id, $anna->id, 'me', '2026-06-05', 50);
makeAbo($noPayment->id, $noPayment->id, 'me', '2026-06-05', 10);
makeAbo($noLevel->id, $noLevel->id, 'ot', '2026-06-05', 10);
$service = app(TeamAboOverviewService::class);
$overview = $service->linesOverview($root, 6, 2026);
$line1 = $overview['lines'][1];
expect($line1['consultants'])->toBe(1)
->and($line1['members'])->toHaveCount(1)
->and($line1['members'][0]['user_id'])->toBe($anna->id)
->and($line1['own_abos'])->toBe(1)
->and($line1['customer_abos'])->toBe(0)
->and($overview['totals']['consultants'])->toBe(1);
});
it('liefert pro Mitglied das Eigen-Abo-Flag und Punkte', function (): void {
$root = makeUser();
$anna = makeUser($root->id);
@ -229,6 +261,7 @@ it('liefert leichtgewichtige Dashboard-KPIs inkl. 1000-Punkte-Shop', function ()
'year' => 2026,
'month_KP_points' => 600,
'month_shop_points' => 500,
'points' => 1100,
'status' => 1,
]);