c90c35d930
Contextual multipliers layered on top of base MarkupRule pricing, applied
per work-order line based on vehicle, client and urgency.
Schema:
- pricing_coefficients (multiplier, conditions JSON, priority, stackable)
- vehicles.vehicle_class (sedan/suv/commercial/hybrid/ev/premium)
- clients.is_vip
- work_orders.urgency (normal/urgent/express)
PricingEngine::quote(Part, Vehicle?, Client?, urgency):
- base = MarkupRule on buy_price (fallback sell_price or buy×1.30)
- context: class (explicit or inferred hybrid/ev from fuel), age, vip, urgency
- stackable coefficients all multiply; non-stackable take only the highest
- returns {base, final, applied[]} breakdown
PricingCoefficient::matches(ctx) — classes/age range/vip/urgency conditions
(empty = always applies).
Filament:
- PricingCoefficientResource with condition builder (classes, age, vip, urgency)
- vehicle_class select, client is_vip toggle, WO urgency select
- "Preț inteligent" action on WO parts shows breakdown + applies sell_price
Tests (6 new):
- base-only without coefficients; age coefficient gating; VIP; express urgency;
stackable multiply vs non-stackable highest-wins; hybrid inferred from fuel
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
29 lines
1.3 KiB
PHP
29 lines
1.3 KiB
PHP
<div class="space-y-3 text-sm">
|
||
<div class="flex justify-between">
|
||
<span class="text-gray-500 dark:text-gray-400">Preț de bază (markup)</span>
|
||
<span class="font-mono">{{ number_format($quote['base'], 2) }} MDL</span>
|
||
</div>
|
||
|
||
@if (! empty($quote['applied']))
|
||
<div class="border-t border-gray-200 dark:border-gray-700 pt-2 space-y-1">
|
||
@foreach ($quote['applied'] as $a)
|
||
<div class="flex justify-between">
|
||
<span>{{ $a['name'] }}</span>
|
||
<span class="font-mono text-primary-600">×{{ rtrim(rtrim(number_format($a['multiplier'], 3), '0'), '.') }}</span>
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
@else
|
||
<div class="text-gray-400 text-xs">Niciun coeficient contextual nu se aplică (preț de bază).</div>
|
||
@endif
|
||
|
||
<div class="flex justify-between border-t-2 border-gray-300 dark:border-gray-600 pt-2 text-base font-bold">
|
||
<span>Preț recomandat</span>
|
||
<span class="text-primary-600">{{ number_format($quote['final'], 2) }} MDL</span>
|
||
</div>
|
||
|
||
@if ((float) $item->sell_price > 0)
|
||
<div class="text-xs text-gray-500">Preț curent pe linie: {{ number_format((float) $item->sell_price, 2) }} MDL</div>
|
||
@endif
|
||
</div>
|