@if($edit)
@foreach($form->svEdit['colourways'] ?? [] as $c=>$colourway) @php $cwTotalPercentage = collect($colourway['colourway_yarns'] ?? [])->sum('percentage'); $cwHasAllPrices = collect($colourway['colourway_yarns'] ?? [])->every(fn($cy) => isset($cy['price']) && $cy['price'] > 0); $cwPercentageValid = abs($cwTotalPercentage - 100) < 0.5; $cwHasYarns = count($colourway['colourway_yarns'] ?? []) > 0; $cwHasIssues = $cwHasYarns && (!$cwPercentageValid || !$cwHasAllPrices); @endphp

@foreach($colourway['colourway_yarns'] ?? [] as $y=>$colourway_yarn) @endforeach @php $totalPercentage = collect($colourway['colourway_yarns'] ?? [])->sum('percentage'); $hasAllPrices = collect($colourway['colourway_yarns'] ?? [])->every(fn($cy) => isset($cy['price']) && $cy['price'] > 0); $percentageValid = abs($totalPercentage - 100) < 0.5; @endphp
Spinner Yarn Colour Customer # Price % Inc FFP
{{$colourway_yarn['yarn_colours']['yarn']['suppliers']['name'] ?? ""}} {{$colourway_yarn['yarn_colours']['yarn']['description'] ?? ""}} {{$colourway_yarn['yarn_colours']['reference'] ?? ""}} | {{$colourway_yarn['yarn_colours']['description'] ?? ""}} {{$colourway_yarn['cust_ref'] ?? ""}} @if(Gate::check('price:update'))
{{$form->svOrigional->colourways[$c]->colourway_yarns[$y]->yarn_colours->yarn->suppliers->currency}}
@else {{$colourway_yarn['price'] ?? ""}} @endif
@if(Gate::check('price:update')) @else {{$colourway_yarn['percentage'] ?? ""}} @endif @if(Gate::check('price:update')) @else {{$colourway_yarn['not_full_factored'] ?? 0 ? "Y" : "N"}} @endif
Total: {{ number_format($totalPercentage, 1) }}%
@if(!$percentageValid || !$hasAllPrices)
Warning: @if(!$percentageValid) Yarn percentages must add up to 100% (currently {{ number_format($totalPercentage, 1) }}%). @endif @if(!$hasAllPrices) Some yarns are missing prices. @endif Yarn/kg price will show as 0 on the pricing sheet until corrected.
@endif
@endforeach
@endif
@if(Gate::check('style:update')) @else @endif