{{-- KATILIMCI VE TUTAR KÜNYESİ — satış kartının sağ sütunu, ortak defter tasarımı. Kaydetme yolu qc-deal-ledger ile aynı: satırlar PATCH atmaz, gerçek form alanına yazar ve kaydı kartın kendi otomatik kaydı gönderir. İki satır kartın HESABINDAN beslenir, kullanıcıdan değil: • Kalan Tutar — qcUpdateMetrics hesaplar (#qc-remaining-display) • Ödeme Durumu — ödenen/toplam oranından türetilir ama elle de değiştirilebilir Beklenen: $sale (null olabilir), $activeCurrencies --}} @php $qcCurCode = $sale?->currency ?: 'TRY'; $qcSym = $activeCurrencies->firstWhere('code', $qcCurCode)?->symbol ?? '₺'; $qcCurOpts = $activeCurrencies ->map(fn ($c) => ['value' => $c->code, 'label' => $c->code . ' (' . $c->symbol . ')']) ->values()->all() ?: [['value' => 'TRY', 'label' => 'TRY (₺)']]; $qcPayOpts = [ ['value' => 'unpaid', 'label' => 'Ödenmedi'], ['value' => 'partial', 'label' => 'Kısmi Ödeme'], ['value' => 'paid', 'label' => 'Ödendi'], ]; $qcPayVal = $sale?->payment_status ?: 'unpaid'; $qcPayLabel = collect($qcPayOpts)->firstWhere('value', $qcPayVal)['label'] ?? 'Ödenmedi'; $qcTotal = $sale && $sale->total_amount ? number_format((float) $sale->total_amount, 2, '.', '') : ''; $qcPaid = $sale && $sale->paid_amount ? number_format((float) $sale->paid_amount, 2, '.', '') : '0.00'; $qcRemain = number_format(max(0, (float) ($sale?->total_amount ?? 0) - (float) ($sale?->paid_amount ?? 0)), 2, '.', ''); $qcMoneyText = fn ($v) => $v === '' ? '' : number_format((float) $v, 2, ',', '.') . ' ' . $qcSym; // Faturalama: kesilen faturaların toplamı ve satış tutarından kalanı $qcInv = $sale ? $sale->invoicingSummary() : ['invoiced' => 0.0, 'remaining' => (float) ($sale?->total_amount ?? 0)]; $qcInvoiced = number_format($qcInv['invoiced'], 2, '.', ''); $qcUninvoiced = number_format($qcInv['remaining'], 2, '.', ''); $qcRow = function (string $label, ?string $target, $value, ?string $text = null, array $o = []) { return [ 'label' => $label, 'field' => ($o['readonly'] ?? false) ? null : ltrim((string) $target, '#'), 'target' => $target, 'type' => $o['type'] ?? 'text', 'value' => $value === null ? '' : (string) $value, 'text' => $text === null ? ($value === null ? '' : (string) $value) : $text, 'options' => $o['options'] ?? null, 'mono' => $o['mono'] ?? false, 'ph' => $o['ph'] ?? null, 'suffix' => $o['suffix'] ?? null, 'dec' => $o['dec'] ?? null, 'attrs' => $o['attrs'] ?? null, ]; }; // Para satırları toplu bulunur: para birimi değişince birim eki hepsinde // birden güncellenir (bkz. qcUpdateMetrics → PFX.repaint). $qcMoneyAttrs = ['data-qc-money' => '1']; @endphp @include('components.quick-view.ledger-card', ['card' => [ 'title' => 'Katılımcı ve Tutar', 'icon' => 'fa-coins', 'foldable' => true, 'sections' => [ [ 'title' => 'Katılımcılar', 'icon' => 'fa-users', 'rows' => [ $qcRow('Yetişkin', '#qc-adult', (string) ($sale?->adult_count ?? 1), (string) ($sale?->adult_count ?? 1), ['type' => 'number', 'dec' => 0, 'mono' => true]), $qcRow('Çocuk', '#qc-child', (string) ($sale?->child_count ?? 0), (string) ($sale?->child_count ?? 0), ['type' => 'number', 'dec' => 0, 'mono' => true]), $qcRow('Bebek', '#qc-infant', (string) ($sale?->infant_count ?? 0), (string) ($sale?->infant_count ?? 0), ['type' => 'number', 'dec' => 0, 'mono' => true]), ], ], [ 'title' => 'Fiyat ve Ödeme', 'icon' => 'fa-wallet', 'rows' => [ $qcRow('Toplam Tutar', '#qc-total-amount', $qcTotal, $qcMoneyText($qcTotal), ['type' => 'number', 'dec' => 2, 'mono' => true, 'suffix' => $qcSym, 'ph' => '0,00', 'attrs' => $qcMoneyAttrs]), $qcRow('Para Birimi', '#qc-currency', $qcCurCode, $qcCurCode . ' (' . $qcSym . ')', ['type' => 'select', 'options' => $qcCurOpts]), $qcRow('Ödenen Tutar', '#qc-paid-amount', $qcPaid, $qcMoneyText($qcPaid), ['type' => 'number', 'dec' => 2, 'mono' => true, 'suffix' => $qcSym, 'ph' => '0,00', 'attrs' => $qcMoneyAttrs]), {{-- Kalan elle girilmez: toplam − ödenen. Değeri qcUpdateMetrics hesaplar; satır salt okunur bir aynadır. --}} $qcRow('Kalan Tutar', '#qc-remaining-display', $qcRemain, $qcMoneyText($qcRemain), ['readonly' => true, 'type' => 'number', 'dec' => 2, 'mono' => true, 'suffix' => $qcSym, 'attrs' => $qcMoneyAttrs]), $qcRow('Ödeme Durumu', '#qc-payment-status', $qcPayVal, $qcPayLabel, ['type' => 'select', 'options' => $qcPayOpts]), {{-- Faturalama: salt okunur; faturalar sekmesindeki değişiklikle ve toplam tutarla birlikte qcUpdateMetrics tazeler --}} $qcRow('Fatura Edilen', '#qc-invoiced-display', $qcInvoiced, $qcMoneyText($qcInvoiced), ['readonly' => true, 'type' => 'number', 'dec' => 2, 'mono' => true, 'suffix' => $qcSym, 'attrs' => $qcMoneyAttrs]), $qcRow('Fatura Edilecek', '#qc-uninvoiced-display', $qcUninvoiced, $qcMoneyText($qcUninvoiced), ['readonly' => true, 'type' => 'number', 'dec' => 2, 'mono' => true, 'suffix' => $qcSym, 'attrs' => $qcMoneyAttrs]), ], ], ], ]])