@php $measures = ['unit' => __('Unit'), 'area' => __('Area (m²)'), 'linear' => __('Linear (m)')]; @endphp
{{-- Breadcrumb + heading --}}

{{ __('Job Costing Studio') }}

@if ($worksheetId) @endif {{ __('Save') }} {{ __('Create quote') }}
{{-- Details --}}

{{ __('Applied to new deliverables.') }}

@if (! empty($templateKeys))
{{ __('Add from template') }} @foreach ($templateKeys as $key => $label) @endforeach
@endif
{{-- ============ Canvas ============ --}}
{{-- Deliverable tabs --}}
@foreach ($deliverables as $di => $d) @php $dt = $this->deliverableTotals($di); @endphp @endforeach
{{-- Active deliverable --}} @php $d = $deliverables[$activeDeliverable] ?? null; $di = $activeDeliverable; @endphp @if ($d) @php $dt = $this->deliverableTotals($di); @endphp {{-- Deliverable header --}}
{{-- Sections --}} @foreach ($d['sections'] as $si => $section)
{{ chr(65 + $si) }}
{{ $baseCode }} {{ number_format($this->sectionSubtotal($di, $si), 2) }}
{{-- Lines --}}
@forelse ($section['lines'] as $li => $line)
@php $stockMat = ($line['kind'] ?? '') === 'material' && ($line['source'] ?? '') === 'stock'; @endphp @if ($stockMat) {{ __('stock · m²/offcut') }} = {{ $baseCode }} {{ number_format($this->lineCost($line), 2) }} @else @if (($line['measure'] ?? 'unit') === 'area')
× = {{ number_format((float) ($line['w'] ?? 0) * (float) ($line['h'] ?? 0), 2) }} m²
@elseif (($line['measure'] ?? 'unit') === 'linear') @endif
{{ __('Unit') }} {{ $baseCode }}
{{ __('Qty') }}
= {{ $baseCode }} {{ number_format($this->lineCost($line), 2) }} @endif
@empty

{{ __('No lines yet, add a cost line or a stock material below.') }}

@endforelse
{{-- Add line + calculator --}}
@if ($calcTargetDi === $di && $calcTargetSi === $si) @include('livewire.costing.partials.material-calculator', ['di' => $di, 'si' => $si]) @endif
@endforeach {{-- Add section --}}
{{ __('Add section') }} @foreach ($sectionPresets as $key => $label) @endforeach
{{-- Deliverable price build-up --}}

{{ __('Production cost') }}

{{ $baseCode }} {{ number_format($dt['cost'], 2) }}

{{ __('Profit :p%', ['p' => rtrim(rtrim(number_format((float) ($d['profit_pct'] ?? 0), 2), '0'), '.')]) }}

+ {{ number_format($dt['profit'], 2) }}

{{ __('Misc :p%', ['p' => rtrim(rtrim(number_format((float) ($d['misc_pct'] ?? 0), 2), '0'), '.')]) }}

+ {{ number_format($dt['misc'], 2) }}

{{ __('Final price') }}

{{ $baseCode }} {{ number_format($dt['price'], 2) }}

@if ($dt['margin'] !== null)

{{ __('margin :m%', ['m' => number_format($dt['margin'], 1)]) }}

@endif
@endif
{{-- ============ Summary rail ============ --}}
{{-- Job total --}}

{{ __('Job total') }}

{{ trans_choice(':count deliverable|:count deliverables', count($deliverables), ['count' => count($deliverables)]) }}

{{ $baseCode }} {{ number_format($totals['price'], 2) }}

@if ($totals['margin'] !== null) {{ number_format($totals['margin'], 1) }}% {{ __('GP') }} @endif

{{ __('Cost :cur :c · Profit :cur :p', ['cur' => $baseCode, 'c' => number_format($totals['cost'], 2), 'p' => number_format($totals['profit'] + $totals['misc'], 2)]) }}@if ($totals['weight'] > 0) · {{ number_format($totals['weight'], 2) }} kg @endif

{{-- Quote roll-up --}}

{{ __('Customer quote') }}

@foreach ($deliverables as $di => $d) @php $dt = $this->deliverableTotals($di); @endphp
{{ $d['title'] ?: __('Deliverable :n', ['n' => $di + 1]) }} {{ number_format($dt['price'], 2) }}
@endforeach @if ($totals['additions'] > 0)
{{ __('Additions') }} + {{ number_format($totals['additions'], 2) }}
@endif
{{ __('Quote total') }} {{ $baseCode }} {{ number_format($totals['price'], 2) }}

{{ __('Create quote makes one line per deliverable, each carrying its full cost breakdown.') }}

{{-- Additions + delivery --}}

{{ __('Job additions') }}

@foreach ($additions as $ai => $addition)
@endforeach
@if ($totals['weight'] > 0)
{{ number_format($totals['weight'], 2) }} kg @
@endif
{{-- Actions --}} {{ __('Create quote') }}
{{ __('Save') }} {{ __('As product') }}
@if ($worksheetId) {{ __('Duplicate / reuse') }} @endif
{{-- Reconciliation (estimate vs actual) --}} @if ($reconciliation) @php $rc = $reconciliation; @endphp

{{ __('Estimate vs actual') }}

{{ __('Actuals pulled live from :job’s cost ledger (incl. production & completion expenses).', ['job' => $rc['job']->job_number]) }}

@foreach ($rc['rows'] as $row) @endforeach
{{ __('Category') }} {{ __('Estimate') }} {{ __('Actual') }} {{ __('Variance') }}
{{ __($costCategories[$row['category']] ?? ucfirst($row['category'])) }} {{ number_format($row['estimate'], 2) }} {{ number_format($row['actual'], 2) }} {{ $row['variance'] > 0 ? '+' : '' }}{{ number_format($row['variance'], 2) }}
{{ __('Total cost') }} {{ number_format($rc['estimate_total'], 2) }} {{ number_format($rc['actual_total'], 2) }} {{ $rc['variance_total'] > 0 ? '+' : '' }}{{ number_format($rc['variance_total'], 2) }}

{{ __('Quoted price') }}

{{ $baseCode }} {{ number_format($rc['quoted_price'], 2) }}

{{ __('Actual cost') }}

{{ $baseCode }} {{ number_format($rc['actual_total'], 2) }}

{{ __('Estimated margin') }}

{{ $rc['estimated_margin'] !== null ? number_format($rc['estimated_margin'], 1).'%' : '—' }}

{{ __('Realized margin') }}

{{ $rc['realized_margin'] !== null ? number_format($rc['realized_margin'], 1).'%' : '—' }}

@endif