option('month') ?: now()->month); $year = (int) ($this->option('year') ?: now()->year); $dryRun = (bool) $this->option('dry-run'); $isCurrentMonth = $month === (int) now()->month && $year === (int) now()->year; if (! $dryRun && ! $isCurrentMonth && ! $this->option('force')) { $this->error('Buchungen in einen anderen als den laufenden Monat nur mit --force (keine rückwirkenden Buchungen in abgeschlossene Provisionsmonate).'); return self::FAILURE; } $this->info("VP-Repair für {$month}/{$year}".($dryRun ? ' (DRY-RUN)' : '')); $result = $service->repair($month, $year, $dryRun); $this->info(" Geprüfte bezahlte Bestellungen mit VP-Produkt: {$result['checked']}"); $this->info(" Bereits gebucht (übersprungen): {$result['skipped_existing']}"); $this->info(($dryRun ? ' Würde nachbuchen: ' : ' Nachgebucht: ').count($result['created'])); if (! empty($result['rebooked'])) { $this->info(($dryRun ? ' Würde vom Firmenaccount umbuchen: ' : ' Vom Firmenaccount umgebucht: ').count($result['rebooked'])); $this->table( ['Order', 'Berater', 'Neupartner', 'Produkt', 'Punkte'], array_map(fn (array $row) => [ $row['order_id'], $row['sponsor'].' (#'.$row['sponsor_id'].')', $row['buyer'], $row['product'], $row['points'], ], $result['rebooked']) ); } if (! empty($result['skipped_other_sponsor'])) { $this->warn(' Achtung — Buchung liegt bei einem ANDEREN Sponsor (Umhängung?), bitte manuell prüfen:'); $this->table( ['Order', 'Neupartner', 'aktueller Sponsor', 'gebucht bei'], array_map(fn (array $row) => [ $row['order_id'], $row['buyer'], '#'.$row['current_sponsor_id'], '#'.$row['booked_sponsor_id'], ], $result['skipped_other_sponsor']) ); } if (! empty($result['created'])) { $this->table( ['Order', 'Sponsor', 'Neupartner', 'Produkt', 'Punkte'], array_map(fn (array $row) => [ $row['order_id'], $row['sponsor'].' (#'.$row['sponsor_id'].')', $row['buyer'], $row['product'], $row['points'], ], $result['created']) ); } $this->info('Fertig.'); return self::SUCCESS; } }