{{-- Interactive deal structuring calculator. Inputs are sent to POST /deals/calculate (FinanceCalculator on the server) after a short pause, so the numbers shown are exactly what will be saved. Used on the quick calculator page ($mode = 'quick') and on the deal edit form ($mode = 'deal'). --}} @php $d = $deal ?? null; $init = [ 'mode' => $mode, 'dealId' => $d?->id, 'vehicleId' => $d?->vehicle_id ?? ($vehicleId ?? ''), 'payment_type' => old('payment_type', $d?->payment_type ?? 'cash'), 'discount_mode' => old('discount_mode', 'amount'), 'discount_value' => old('discount_value', $d ? (float) $d->discount_amount : ''), 'tax_rate_id' => old('tax_rate_id', $d?->tax_rate_id ?? ($taxRates->firstWhere('is_default', true)->id ?? '')), 'tax_inclusive' => (bool) old('tax_inclusive', $d?->tax_inclusive ?? true), 'trade_in_id' => old('trade_in_id', $d?->trade_in_id ?? ''), 'trade_in_value' => '', 'trade_in_payoff' => '', 'deposit_mode' => old('deposit_mode', 'amount'), 'deposit_value' => old('deposit_value', $d ? (float) $d->deposit_required : ''), 'interest_rate' => old('interest_rate', $d && $d->payment_type === 'finance' ? (float) $d->interest_rate : 14), 'interest_method' => old('interest_method', $d?->interest_method ?? 'reducing'), 'term_months' => old('term_months', $d?->term_months ?? 48), 'finance_fee' => old('finance_fee', $d ? (float) $d->finance_fee : ''), 'first_payment_date' => old('first_payment_date', optional($d?->first_payment_date)->toDateString() ?? ''), 'list_price' => '', 'items' => old('items', $d ? $d->items->map(fn ($i) => ['type' => $i->type, 'description' => $i->description, 'quantity' => $i->quantity, 'unit_price' => (float) $i->unit_price, 'taxable' => $i->taxable ? '1' : '0'])->all() : []), 'prices' => isset($vehicles) ? $vehicles->mapWithKeys(fn ($v) => [$v->id => (float) $v->selling_price])->all() : [], 'url' => route('deals.calculate'), ]; @endphp
@if ($mode === 'quick')
Vehicle
@endif
Discount and tax
Add-ons and fees

Insurance, warranty, tracker, accessories, registration or transfer fees.

Trade-in @if ($mode === 'deal')
@if ($tradeIns->isEmpty())

None available. Appraise the customer's vehicle and have them accept the offer first.

@endif
@else
@endif
Payment
Finance terms
@if ($mode === 'deal')
@endif
{{-- Live summary --}}
@once @endonce