{{-- "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
{{ $formula }}
@endif