@php use Carbon\Carbon; $summaryPickupDate = old('pickup_date', $pickupDate ?? now()->addDay()->toDateString()); $summaryReturnDate = old('return_date', $returnDate ?? now()->addDays(2)->toDateString()); try { $pickupCarbon = Carbon::parse($summaryPickupDate); $returnCarbon = Carbon::parse($summaryReturnDate); $summaryDurationDays = max(1, $pickupCarbon->diffInDays($returnCarbon) + 1); } catch (Throwable $exception) { $summaryDurationDays = $durationDays ?? 1; } $summaryPricePerDay = (float) $vehicle->price_per_day; $summarySubtotal = $summaryDurationDays * $summaryPricePerDay; $summaryAdditionalCost = 0; // Estimasi diskon berdasarkan promo code yang diinput $summaryDiscountAmount = 0; $estimatedPromoApplied = false; $promoCode = old('promo_code', ''); if (!empty($promoCode) && isset($availablePromos)) { $appliedPromo = $availablePromos->firstWhere(function($p) use ($promoCode) { return strtoupper($p->promo_code) === strtoupper($promoCode); }); if ($appliedPromo && $appliedPromo->can_use) { if ($appliedPromo->discount_type === 'percent') { $summaryDiscountAmount = ($appliedPromo->discount_value / 100) * $summarySubtotal; } else { $summaryDiscountAmount = min($appliedPromo->discount_value, $summarySubtotal); } $estimatedPromoApplied = true; } } $summaryTotalAmount = $summarySubtotal + $summaryAdditionalCost - $summaryDiscountAmount; @endphp

Ringkasan

Biaya Pemesanan

Harga sewa per hariRp {{ number_format($summaryPricePerDay, 0, ',', '.') }}
Jumlah hari{{ $summaryDurationDays }} Hari
SubtotalRp {{ number_format($summarySubtotal, 0, ',', '.') }}
Biaya tambahanRp {{ number_format($summaryAdditionalCost, 0, ',', '.') }}
@if ($summaryDiscountAmount > 0)
Diskon {{ $estimatedPromoApplied ? '(estimasi)' : '' }} - Rp {{ number_format($summaryDiscountAmount, 0, ',', '.') }}
@else
Diskon voucher- Rp {{ number_format(0, 0, ',', '.') }}
@endif
Total Pembayaran Rp {{ number_format($summaryTotalAmount, 0, ',', '.') }}
@if ($estimatedPromoApplied)

ℹ️ Diskon promo ditampilkan sebagai estimasi. Nilai final akan dihitung ulang di backend saat booking disimpan.

@else

Total final dihitung ulang di backend saat booking disimpan.

@endif