TRANSPORTISTA: {{ $dispatcher->name }} - {{ $dispatcher->number }}
VENDEDORES: {{ implode(', ', $sellers) }}
# |
Código |
Descripción |
Cantidad |
Unidad de medida |
Cantidad equivalente |
Precio de venta |
@foreach ($records as $key => $value)
@php
$seller_ids = explode(',', $value->seller_ids);
$internal_id = null;
$description = null;
$quantity = $value->total_quantity;
$unit_type_id = null;
$presentations = $value->presentations;
$unit_totals = [];
$has_pipe = strpos($presentations, '|');
if ($has_pipe !== false) {
$presentations = explode(',', $presentations);
$presentations = array_map(function ($row) {
$row = explode('|', $row);
return [
'description' => isset($row[0]) ? $row[0] : null,
'unit_type_id' => isset($row[1]) ? $row[1] : null,
'unit_quantity' => isset($row[2]) ? $row[2] : 0,
'quantity' => isset($row[3]) ? $row[3] : 0,
];
}, $presentations);
foreach ($presentations as $presentation) {
$unit_type = $presentation['description'];
$quantity_ = (float) $presentation['quantity'];
if (!isset($unit_totals[$unit_type])) {
$unit_totals[$unit_type] = 0;
}
$unit_totals[$unit_type] += $quantity_;
}
}
$formatted_result = [];
foreach ($unit_totals as $unit_type => $total_quantity) {
$formatted_result[] = "{$total_quantity} {$unit_type}";
}
$quantity_presentation = null;
$total = null;
$item = App\Models\Tenant\Item::find($value->item_id);
if ($item) {
$internal_id = $item->internal_id;
$description = $item->description;
$unit_type_id = $item->unit_type_id;
$quantity_presentation = $value->presentations;
$total = $value->total;
}
$record = (object) [
'seller_ids' => $seller_ids,
'internal_id' => $internal_id,
'description' => $description,
'quantity' => $quantity,
'unit_type_id' => $unit_type_id,
'quantity_presentation' => $quantity_presentation,
'total' => $total,
'presentations' => implode(', ', $formatted_result),
];
@endphp
{{ $key + 1 }} |
{{ $record->internal_id }}
|
{{ $record->description }}
|
{{ $record->quantity }}
|
{{ $record->unit_type_id }}
|
{{ $record->presentations }}
|
{{ $record->total }}
|
@endforeach
TOTAL ITEMS {{ count($records) }}
|
|
TOTAL VENTA {{$records->sum('total')}} |