Reporte ventas sabana


Empresa:

{{ $company->name }}

Fecha:

{{ date('Y-m-d') }}

Ruc:

{{ $company->number }}

@php $total_general = 0; @endphp @if (!empty($records))
@foreach ($records as $key => $value) @php $item_id = $value->item_id; $seller_name = null; $document_type = null; $document_number = null; $supplier_name = null; $date_of_issue = null; $item_internal_id = null; $item_description = null; $unit_type_id = null; $customer_internal_code = null; $customer_name = null; $payment_condition = null; $unit_value = null; $unit_price = null; $total = null; $quantity = null; $seller_name = isset($value->seller_id) ? App\Models\Tenant\User::find($value->seller_id)->name : null; $document_type = App\Models\Tenant\Catalogs\DocumentType::find($value->document_type_id) ->description; $document_number = $value->number_full; $last_purchase_item = App\Models\Tenant\PurchaseItem::where('item_id', $item_id) ->join('purchases', 'purchase_items.purchase_id', '=', 'purchases.id') ->orderBy('purchases.date_of_issue', 'desc') ->select('purchase_items.*') ->first(); $last_purchase_document = $last_purchase_item ? $last_purchase_item->purchase : null; $supplier_name = $last_purchase_document ? $last_purchase_document->supplier->name : null; $date_of_issue = $value->date_of_issue; $item = json_decode($value->item); $item_internal_id = isset($item->internal_id) ? $item->internal_id : null; if ($item_internal_id == null) { $item_db = App\Models\Tenant\Item::find($item_id); if ($item_db) { $item_internal_id = $item_db->internal_id; } } $item_description = $item->description; $unit_type_id = $item->unit_type_id; $customer = App\Models\Tenant\Person::find($value->customer_id); $customer_internal_code = $customer->internal_code; $customer_name = $customer->name; $payment_condition = $value->payment_condition_id == '01' ? 'Contado' : 'Crédito'; if ($value->payment_condition_id == '02' && $value->order_note_id) { $order_note = \Modules\Order\Models\OrderNote::find($value->order_note_id); $payment_method = \App\Models\Tenant\PaymentMethodType::find( $order_note->payment_method_type_id, ); if ($payment_method->is_credit) { $payment_condition = $payment_method->description; } } $unit_value = $value->unit_value; $unit_price = $value->unit_price; $total = $value->unit_price * $value->quantity; $quantity = $value->quantity; $record = (object) [ 'seller_name' => $seller_name, 'document_type' => $document_type, 'document_number' => $document_number, 'supplier_name' => $supplier_name, 'date_of_issue' => $date_of_issue, 'item_internal_id' => $item_internal_id, 'item_description' => $item_description, 'unit_type_id' => $unit_type_id, 'customer_internal_code' => $customer_internal_code, 'customer_name' => $customer_name, 'payment_condition' => $payment_condition, 'unit_value' => number_format($unit_value, 2), 'unit_price' => number_format($unit_price, 2), 'total' => $total, 'quantity' => $quantity, ]; $total_general += $record->total; @endphp @endforeach
# Vendedor Tipo documento Número documento Proveedor Fecha de documento Cod producto Producto Cantidad Unidad de medida Cod cliente Cliente Forma de pago Importe sin igv Importe con igv Importe total
{{ $key + 1 }} {{ $record->seller_name }} {{ $record->document_type }} {{ $record->document_number }} {{ $record->supplier_name }} {{ $record->date_of_issue }} {{ $record->item_internal_id }} {{ $record->item_description }} {{ $record->quantity }} {{ $record->unit_type_id }} {{ $record->customer_internal_code }} {{ $record->customer_name }} {{ $record->payment_condition }} {{ $record->unit_value }} {{ $record->unit_price }} {{ $record->total }}
Total {{ number_format($total_general, 2) }}
@else

No se encontraron registros.

@endif