Consolidado de items por cliente/vendedor - Totales

@inject('reportService', 'Modules\Report\Services\ReportService') @if(isset($params['sellers'])) @php $sellers = json_decode($params['sellers']); @endphp @if(count($sellers) > 0) @endif @endif @if(isset($params['person_id'])) @endif

Empresa: {{$company->name}}

Ruc: {{$company->number}}

Establecimiento: {{$establishment->address}} - {{$establishment->department->description}} - {{$establishment->district->description}}

Usuario(s): @foreach ($sellers as $seller_id) - {{$reportService->getUserName($seller_id)}} @endforeach

Cliente: {{$reportService->getPersonName($params['person_id'])}}

@if(!empty($records))
@php $showCosts = (bool) ($params['show_costs'] ?? false); $acum_total=0; $acum_units = 0; $acu_total_sale = 0; $acum_cost = 0; $acum_utility = 0; @endphp @if($showCosts) @endif {{-- Fila por producto (totales) y debajo, con sangria, cada presentacion vendida. --}} @foreach($records as $key => $value) @php $single = ($value['presentations_count'] ?? 1) === 1; @endphp @if($showCosts) @endif @if(!$single) @foreach($value['presentations'] as $p) @if($showCosts) @endif @endforeach @endif @php $acum_units += $value['base_units']??0; $acu_total_sale += $value['total_sale']??0; $acum_cost += $value['cost']??0; $acum_utility += $value['utility']??0; @endphp @endforeach @if($showCosts) @endif
# Cod. Interno Producto Presentación Laboratorio Cantidad Unidades Precio prom. x und. Total de ventaCosto Utilidad Margen %
{{ $loop->iteration }} {{$value['item_internal_id']}} {{$value['item_description']}} {{$value['presentation']}} {{$value['brand']}} {{ $single ? ($value['presentations'][0]['quantity'] ?? '') : '' }} {{$value['base_units']}} {{ $value['avg_unit_price'] !== null ? number_format($value['avg_unit_price'], 2) : '' }} {{ number_format($value['total_sale'], 2) }}{{ number_format($value['cost'] ?? 0, 2) }} {{ number_format($value['utility'] ?? 0, 2) }} {{ number_format($value['margin_percent'] ?? 0, 2) }}%
  â†³ {{$p['presentation']}} {{$p['quantity']}} {{$p['base_units']}} {{ $p['avg_unit_price'] !== null ? number_format($p['avg_unit_price'], 2) : '' }} {{ number_format($p['total_sale'], 2) }}{{ number_format($p['cost'] ?? 0, 2) }} {{ number_format($p['utility'] ?? 0, 2) }} {{ number_format($p['margin_percent'] ?? 0, 2) }}%
Total {{ number_format($acum_units, 2) }} {{ $acum_units != 0 ? number_format($acu_total_sale / $acum_units, 2) : '' }} {{ number_format($acu_total_sale, 2) }}{{ number_format($acum_cost, 2) }} {{ number_format($acum_utility, 2) }} {{ $acu_total_sale != 0 ? number_format($acum_utility / $acu_total_sale * 100, 2) : '0.00' }}%
@else

No se encontraron registros.

@endif