REPORTE GENERAL PEDIDOS


@if(!empty($records))
@php $total_prev=0; $acum_total_taxed=0; $acum_total_igv=0; $acum_total=0; $serie_affec = ''; $acum_total_exonerado=0; $acum_total_inafecto=0; $acum_total_free=0; @endphp @foreach($records as $key => $value) @php $serie_document=0; $discount_description=0; $guide_remision=0; $brand_items=0; $category_items=0; $name_items=0; $obs=0; $data = $value->getCollectionData(); /* dd($value); */ $items_order=0; $identifier_order=0; $guide_remision=0; $acum_price=0; $acum_discount=0; $acum_total = $value->total_value; $acum_total_taxed = $value->total_taxed; $acum_total_igv = $value->total_igv; $acum_total_exonerado = $value->total_exonerated; $acum_total_inafecto = $value->total_unaffected; $acum_total_free = $value->total_free; $total_prev = $acum_total+$acum_total_igv+$acum_total_exonerado+$acum_total_free+$acum_total_inafecto; $state_type_description=$data['state_type_description']; $guide_remision=empty($data['dispatches'][0])?0:$data['dispatches'][0]['number']; $identifier_order=$data['identifier']; /* dd(empty($data['sale_notes'][0])); */ $documents_order_id = empty($data['documents'][0]) ? 0 : $data['documents'][0]['series'].'-'.$data['documents'][0]['id']; $sale_order_id= empty($data['sale_notes'][0]) ? 0 : $data['sale_notes'][0]['series'].'-'.$data['sale_notes'][0]['id']; /* dd($guide_remision); */ $items_brand=''; $category_string=''; $discount_string=''; $name_string=''; $serie_document=(!$documents_order_id) ? $sale_order_id : $documents_order_id; foreach ($value->items as $itm) { $discount=(array)$itm['discounts']; $items_order+=$itm['quantity']; $item=(array)$itm['item']; if (!empty($item['brand'])) { $items_brand= str_contains($brand_items,$item['brand']) ? $item['brand'].' - ' : $items_brand.=$item['brand'].' - '; $brand_items = trim($items_brand,' - '); } if (!empty($item['category'])) { $category_string= str_contains($category_items,$item['category']) ? $item['category'].' - ' : $category_string.=$item['category'].' - '; $category_items = trim($category_string,' - '); } $acum_price += ($itm['unit_price']*$itm['quantity']); $acum_discount += $itm['total_discount']; if (!empty($discount)) { $discount_format=(array) $discount[0]; $discount_string = str_contains($discount_description, $discount_format['description']) ? $discount_format['description'] : $discount_string.=$discount_format['description'].' - '; $discount_description = trim($discount_string,' - '); } /* dd(empty($itm['item_details'][0])); */ if(!empty($itm['item_details'][0]['name'])&& !is_null($itm['item_details'][0]['name'])){ $name_string = str_contains($name_items, $itm['item_details'][0]['name']) ? $itm['item_details'][0]['name'].' - ' : $name_string.=$itm['item_details'][0]['name'].' - '; $name_items=trim($name_string,' - '); } } $obs=$value->observation; @endphp @endforeach
Número Cliente Dirección Total Estado Descuento Total venta Tipo de pago Vendedor Motivo Detalle Codigo interno Nombre de producto Categoria Marca Cantidad de producto Precio unitario Documento Asociado Guia de remision
{{$loop->iteration}} {{ $value->customer->name }} {{$value->shipping_address}} {{$total_prev}} {{$state_type_description}} {{number_format($acum_discount,2)}} {{ $value->total }} {{ $value->payment_method_type->description }} {{ $value->user->name }} {{$discount_description}} {{$obs}} {{$identifier_order}} {{$name_items}} {{$category_items}} {{$brand_items}} {{$items_order}} {{number_format($acum_price,2)}} {{$serie_document}} {{$guide_remision}}
@else

No se encontraron registros.

@endif