{{-- "Biaya Pembayaran" of the campaign reports (campaign-sms/show-report and partials/broadcast-report), from the API's campaign_billing.billing(): what was bought on the left, how it was paid on the right. Uses the including view's $billing, $categoryLabel, $methodChannel, $unitPrice, $grandTotal, $successRaw, $channel, $menu, $formatNumber and $formatMoney. --}} @php $paidWith = $billing['paid_with'] ?? null; $recipients = is_numeric($billing['recipients'] ?? null) ? (int) $billing['recipients'] : null; $perRecipient = max(1, (int) ($billing['messages_per_recipient'] ?? 1)); // DigitalCore sends to every recipient on each delivery day: Saldo Utama pays recipients x days // ("sends"); membership and paket quota count sends too. $days = max(1, (int) ($billing['delivery_days'] ?? 1)); $sends = is_numeric($billing['sends'] ?? null) ? (int) $billing['sends'] : ($recipients !== null ? $recipients * $days : null); // Sends a paket paid for; on a split payment Saldo Utama paid only the rest. $packageRecipients = is_numeric($billing['package_recipients'] ?? null) ? (int) $billing['package_recipients'] : null; $billedRecipients = $sends !== null ? $sends - (int) $packageRecipients : null; // Paid with quota (membership or paket): no price, so Kuota Terpakai (Sukses, else Jumlah Penerima, else "-") // and the merchant's Sisa Kuota for this service instead of Harga Satuan and Grand Total. $paidWithQuota = in_array($paidWith, ['membership', 'package'], true); $quotaUsed = is_numeric($successRaw ?? null) && (int) $successRaw > 0 ? $successRaw : $recipients; $quotaLeft = $paidWithQuota ? (\App\Support\CampaignQuota::current()->labelFor($channel ?? null, $menu ?? null) ?? '-') : null; // How the total was reached, e.g. "Rp 600 × 3 penerima = Rp 1.800"; only when the parts give the // amount (unit_price is derived from the amount by the API, so a rounded one is not shown as exact). $formula = null; if ($paidWith === 'main_balance' && is_numeric($billing['unit_price'] ?? null) && $billedRecipients && is_numeric($billing['amount'] ?? null) && abs((float) $billing['unit_price'] * $billedRecipients * $perRecipient - (float) $billing['amount']) < 1) { $formula = $formatMoney($billing['unit_price'], '-').' × ' .($days > 1 && ! $packageRecipients ? $formatNumber($recipients, '-').' penerima × '.$days.' hari' : $formatNumber($billedRecipients, '-').' penerima') .($perRecipient > 1 ? ' × '.$perRecipient.' SMS' : '').' = '.$grandTotal; } // paid_at is UTC; shown in WIB like the rest of the portal. $paidAt = null; if (! empty($billing['paid_at'])) { try { $paidAt = \Illuminate\Support\Carbon::parse($billing['paid_at'], 'UTC')->setTimezone('Asia/Jakarta')->translatedFormat('d M Y, H.i').' WIB'; } catch (\Throwable) { $paidAt = null; } } @endphp

Detil Biaya

Produk yang Dipilih
Kategori Iklan{{ $categoryLabel }}
Tipe Kanal{{ strtoupper($methodChannel) }}
@if ($paidWithQuota)
Kuota Terpakai{{ $quotaUsed !== null ? $formatNumber($quotaUsed, '-').' penerima' : '-' }}
@else
Harga Satuan{{ $unitPrice }}
@endif @if ($recipients !== null) @if ($paidWith === 'main_balance' && $days > 1)
Jumlah Penerima{{ $formatNumber($sends, '-') }} pesan ({{ $formatNumber($recipients, '-') }} penerima × {{ $days }} hari)
@else
Jumlah Penerima{{ $formatNumber($recipients, '-') }} penerima
@endif @endif @if ($perRecipient > 1)
Pesan per Penerima{{ $perRecipient }} SMS
@endif
{{ $paidWithQuota ? 'Sisa Kuota' : 'Grand Total' }} {{ $paidWithQuota ? $quotaLeft : $grandTotal }}
@if ($formula)

{{ $formula }}

@endif
Pembayaran Anda Menggunakan
@if ($paidWith === 'membership')
Kuota Membership{{ $formatNumber($billing['recipients'] ?? null, '-') }} penerima
@if (! empty($billing['quota_returned']))
Kuota dikembalikan (iklan ditolak)Ya
@endif @elseif ($paidWith === 'package')
{{ $billing['package_name'] ?? 'Paket' }}{{ $formatNumber($packageRecipients, '-') }} penerima
@if (! empty($billing['quota_returned']))
Penerima paket dikembalikan (iklan ditolak)Ya
@endif @elseif ($paidWith === 'main_balance') @if ($packageRecipients)
{{ $billing['package_name'] ?? 'Paket' }}{{ $formatNumber($packageRecipients, '-') }} penerima
@if (! empty($billing['quota_returned']))
Penerima paket dikembalikan (iklan ditolak)Ya
@endif @endif
Saldo Utama{{ $packageRecipients ? ' (sisa '.$formatNumber($billedRecipients, '-').' penerima)' : '' }}{{ $grandTotal }}
@if (is_numeric($billing['refunded_amount'] ?? null))
Dikembalikan ke Saldo Utama (iklan ditolak){{ $formatMoney($billing['refunded_amount'], '-') }}
@endif @else
Tidak ada biaya yang tercatat-
@endif @if ($paidAt)
{{ in_array($paidWith, ['membership', 'package'], true) ? 'Kuota dipakai' : 'Dibayar' }}{{ $paidAt }}
@endif