*/ public function build(): array { $singleCents = (int) config('billing.single_pm_price_cents'); $starter = Plan::query()->active()->where('slug', Tier::Starter->value)->first(); $starterMonthlyCents = (int) ($starter->monthly_price_cents ?? 0); $starterQuota = (int) ($starter->press_release_quota ?? 0); $vatRate = (float) config('billing.vat_rate'); return [ 'singleCents' => $singleCents, 'singleNet' => $this->euro($singleCents), 'singleGross' => $this->euro((int) round($singleCents * (1 + $vatRate))), 'vatPercent' => (int) round($vatRate * 100), 'starterName' => $starter->name ?? 'Starter', 'starterMonthlyNet' => $this->euro($starterMonthlyCents), 'starterYearlyNet' => $this->euro((int) ($starter->yearly_price_cents ?? 0)), 'starterQuota' => $starterQuota, 'extraPmStarterNet' => $this->euro((int) config('credits.extra_pm.'.Tier::Starter->value, 0) * 100), 'changeNet' => $this->euro((int) config('billing.change_price_cents')), 'depublicationNet' => $this->euro((int) config('billing.depublication_price_cents')), 'correctionMaxPercent' => (int) config('legal.correction_max_distance_percent'), 'examples' => $starterMonthlyCents > 0 && $starterQuota > 0 ? $this->examples($singleCents, $starterMonthlyCents, $starterQuota) : [], ]; } /** * Rechenbeispiel: Meldungen im Jahr, Verteilung, Kosten je Modell. * Der Starter-Monat wird nur in Monaten gebucht, in denen veröffentlicht * wird (monatlich kündbar); je Monat höchstens das Kontingent. * * @return list */ private function examples(int $singleCents, int $starterMonthlyCents, int $starterQuota): array { $cases = [ ['count' => 1, 'months' => 1, 'spread' => 'one'], ['count' => $starterQuota, 'months' => 1, 'spread' => 'same_month'], ['count' => $starterQuota, 'months' => $starterQuota, 'spread' => 'spread'], ['count' => 12, 'months' => 12, 'spread' => 'monthly'], ['count' => 12, 'months' => (int) ceil(12 / $starterQuota), 'spread' => 'clustered'], ]; $rows = []; foreach ($cases as $case) { $single = $case['count'] * $singleCents; $starter = $case['months'] * $starterMonthlyCents; $rows[] = [ 'count' => $case['count'], 'spread' => $case['spread'], 'months' => $case['months'], 'single' => $this->euro($single), 'starter' => $this->euro($starter), 'cheaper' => $single === $starter ? 'equal' : ($single < $starter ? 'single' : 'starter'), ]; } return $rows; } private function euro(int $cents): string { return number_format($cents / 100, $cents % 100 === 0 ? 0 : 2, ',', '.'); } }