@php $range = (array) ($metrics['range'] ?? []); $kpi = (array) ($metrics['kpi'] ?? []); $current = (array) ($metrics['current'] ?? []); $from = $range['from'] ?? null; $to = $range['to'] ?? null; $prevFrom = $range['prevFrom'] ?? null; $prevTo = $range['prevTo'] ?? null; $fmtCurrency = fn ($value) => 'Rp'.number_format((float) $value, 0, ',', '.'); $fmtPercent = fn ($value) => number_format((float) $value, 1, ',', '.').'%'; $fmtDeltaPercent = function ($value) { if ($value === null) { return null; } return number_format((float) $value, 1, ',', '.').'%'; }; $badge = function ($deltaUp) { return $deltaUp ? 'bg-success-50 text-success-600 dark:bg-success-500/15 dark:text-success-500' : 'bg-error-50 text-error-600 dark:bg-error-500/15 dark:text-error-500'; }; @endphp

Laporan Penjualan & Laba

{{ $from ? $from->format('d M Y') : '-' }} - {{ $to ? $to->format('d M Y') : '-' }} @if ($prevFrom && $prevTo) · dibandingkan {{ $prevFrom->format('d M Y') }} - {{ $prevTo->format('d M Y') }} @endif

@php $target = (array) ($metrics['target'] ?? []); $cards = [ [ 'label' => 'Transaksi', 'k' => 'txCount', 'fmt' => fn($v) => number_format((float) $v, 0, ',', '.')], [ 'label' => 'Omzet (Net Sales)', 'k' => 'revenue', 'fmt' => $fmtCurrency, 'subLabel' => 'Avg Order', 'subK' => 'avgOrder', 'subFmt' => $fmtCurrency, ], [ 'label' => 'COGS Penjualan', 'k' => 'cogsInventory', 'fmt' => $fmtCurrency, ], [ 'label' => 'Loss Stok (Net)', 'k' => 'stockLossNet', 'fmt' => $fmtCurrency, ], [ 'label' => 'Total COGS + Loss', 'k' => 'cogsTotal', 'fmt' => $fmtCurrency, ], [ 'label' => 'Laba Kotor (Setelah Loss)', 'k' => 'grossProfit', 'fmt' => $fmtCurrency, 'subLabel' => 'Margin Kotor', 'subK' => 'grossMarginPercent', 'subFmt' => $fmtPercent, ], [ 'label' => 'Beban Operasional', 'k' => 'operatingExpenseTotal', 'fmt' => $fmtCurrency, ], [ 'label' => 'Laba Bersih', 'k' => 'netProfit', 'fmt' => $fmtCurrency, 'subLabel' => 'Margin Bersih', 'subK' => 'netMarginPercent', 'subFmt' => $fmtPercent, ], ]; @endphp

Target Pendapatan

{{ $fmtCurrency((float) ($target['targetAmount'] ?? 0)) }}

{{ (string) ($target['label'] ?? '') }}

Pencapaian

@php $ach = $target['achievementPercent'] ?? null; @endphp {{ $ach === null ? '-' : number_format((float) $ach, 1, ',', '.') . '%' }}

Selisih: {{ ($target['gapAmount'] ?? null) === null ? '-' : $fmtCurrency((float) $target['gapAmount']) }}

Realisasi

{{ $fmtCurrency((float) ($target['revenueAmount'] ?? 0)) }}

@php $percent = (float) ($target['achievementPercent'] ?? 0); $bar = min(100, max(0, $percent)); @endphp
@if (! (bool) ($target['hasAnyTarget'] ?? false))

Target belum diatur untuk periode ini. Atur di Pengaturan → Target Bulanan.

@endif
@foreach ($cards as $card) @php $m = (array) ($kpi[$card['k']] ?? []); $deltaPercent = $fmtDeltaPercent($m['deltaPercent'] ?? null); $subMetric = array_key_exists('subK', $card) ? (array) ($kpi[$card['subK']] ?? []) : []; @endphp

{{ $card['label'] }}

{{ ($card['fmt'])($m['value'] ?? 0) }}

@if ($deltaPercent !== null) {{ ($m['deltaUp'] ?? true) ? '+' : '' }}{{ $deltaPercent }} @endif

Periode sebelumnya: {{ ($card['fmt'])($m['previous'] ?? 0) }}

@if (array_key_exists('subK', $card))

{{ (string) ($card['subLabel'] ?? '') }}: {{ ($card['subFmt'])($subMetric['value'] ?? 0) }}

@endif
@endforeach

Cara Baca

Ringkasan definisi angka agar laporan mudah dipahami (best practice UMKM).

UMKM

Rumus Utama

Omzet (Net Sales) subtotal item − diskon item
COGS Penjualan pemakaian stok dari penjualan
Loss Stok (Net) waste + usage + opname + penyesuaian
Laba Kotor omzet − (COGS + loss stok)
Laba Bersih laba kotor − beban operasional

Catatan Praktis

Biaya admin adalah ditagihkan ke customer (informasi), bukan pengurang laba.
Pajak PB1 tidak dimasukkan ke omzet (omzet dihitung dari item setelah diskon).
Jika HPP belum lengkap, pastikan stok & harga pokok inventory sudah diproses.
Jika loss stok besar, cek menu Pergerakan Stok dan Stock Opname.

Trend Harian

Omzet, HPP, dan Laba Kotor per hari.

Metode Pembayaran

@forelse ($paymentMethods as $row)

{{ \App\Helpers\DataLabelHelper::enum($row['payment_method'] ?? null, 'payment_method') }}

{{ number_format((float) $row['percent'], 1, ',', '.') }}%

{{ $fmtCurrency($row['revenue']) }}

@empty

Belum ada data.

@endforelse

Top 10 Profit (Per Menu)

Perhitungan profit per menu mengikuti HPP resep yang tersimpan.

@forelse ($topByProfit as $row) @empty @endforelse
Item Qty Omzet Profit (Resep) Margin

{{ $row['product_name'] }}

{{ $row['variant_name'] }}

{{ number_format((int) $row['qty'], 0, ',', '.') }}

{{ $fmtCurrency($row['revenue']) }}

{{ $fmtCurrency($row['profit']) }}

{{ number_format((float) $row['margin_percent'], 1, ',', '.') }}%

Top 10 Omzet (Per Menu)

@forelse ($topByRevenue as $row) @empty @endforelse
Item Qty Omzet Profit (Resep) Margin

{{ $row['product_name'] }}

{{ $row['variant_name'] }}

{{ number_format((int) $row['qty'], 0, ',', '.') }}

{{ $fmtCurrency($row['revenue']) }}

{{ $fmtCurrency($row['profit']) }}

{{ number_format((float) $row['margin_percent'], 1, ',', '.') }}%

Ringkasan Harian

@forelse ($dailyRows as $row) @empty @endforelse
Tanggal Transaksi Item Omzet COGS Penjualan Loss Stok (Net) Total COGS Laba Kotor Margin Biaya Admin Beban Laba Bersih

{{ \Carbon\CarbonImmutable::parse($row['day'])->format('d M Y') }}

{{ $row['day'] }}

{{ number_format((int) $row['tx_count'], 0, ',', '.') }}

{{ number_format((int) $row['items_qty'], 0, ',', '.') }}

{{ $fmtCurrency($row['revenue']) }}

{{ $fmtCurrency($row['cogs_sales'] ?? 0) }}

{{ $fmtCurrency($row['stock_loss_net'] ?? 0) }}

{{ $fmtCurrency($row['cogs_total'] ?? 0) }}

{{ $fmtCurrency($row['gross_profit'] ?? 0) }}

{{ number_format((float) ($row['gross_margin_percent'] ?? 0), 1, ',', '.') }}%

{{ $fmtCurrency($row['payment_fee_total'] ?? 0) }}

{{ $fmtCurrency($row['operating_expense_total'] ?? 0) }}

{{ $fmtCurrency($row['net_profit'] ?? 0) }}