@php $establishment = $cash->user->establishment; $final_balance = 0; $cash_income = 0; // Calcular el total de egresos (gastos) $cashEgress = $cash->cash_documents->sum(function ($cashDocument) { return $cashDocument->expense_payment ? $cashDocument->expense_payment->payment : 0; }); $cash_final_balance = 0; $document_count = 0; $cash_taxes = 0; $cash_documents = $cash->cash_documents; // dd($cash_documents); $is_complete = $only_head === 'resumido' ? false : true; $first_document = ''; $last_document = ''; $list = $cash_documents->filter(function ($item) { return $item->document_pos_id !== null; }); if ($list->count() > 0) { $first_document = $list->first()->document_pos->series . '-' . $list->first()->document_pos->number; $last_document = $list->last()->document_pos->series . '-' . $list->last()->document_pos->number; } foreach ($methods_payment as $method) { $method->transaction_count = 0; // Se Incializa el contador de transacciones } foreach ($cash_documents as $cash_document) { if ($cash_document->document_pos) { $cash_income += $cash_document->document_pos->getTotalCash(); $final_balance += $cash_document->document_pos->getTotalCash(); $cash_taxes += $cash_document->document_pos->total_tax; $document_count = $cash_document->document_pos->count(); if (count($cash_document->document_pos->payments) > 0) { $pays = $cash_document->document_pos->state_type_id === '11' ? collect() : $cash_document->document_pos->payments; foreach ($methods_payment as $record) { $record->sum = $record->sum + $pays->where('payment_method_type_id', $record->id)->sum('payment'); } foreach ($cash_document->document_pos->payments as $payment) { $paymentMethod = $methods_payment->firstWhere('id', $payment->payment_method_type_id); if ($paymentMethod) { $paymentMethod->transaction_count++; // Se incrementa el contador de transacciones } } } } } $cash_final_balance = $final_balance + $cash->beginning_balance - $cashEgress; @endphp <
COMPROBANTE INFORME DIARIO
Empresa: {{ $company->name }}
N° Documento: {{ $company->number }}
Establecimiento: {{ $establishment->description }}
Fecha reporte: {{ date('Y-m-d') }}
Vendedor: {{ $cash->user->name }}
Fecha y hora apertura: {{ $cash->date_opening }} {{ $cash->time_opening }}
Estado de caja: {{ $cash->state ? 'Aperturada' : 'Cerrada' }}
@if (!$cash->state)
Fecha y hora cierre: {{ $cash->date_closed }} {{ $cash->time_closed }}
@endif
Tipo de comprobante | Comprobante Número inicial | Número final |
---|---|---|
{{ $tipoComprobante }} | {{ $numeroInicial }} | {{ $numeroFinal }} |
Empresa: {{ $company->name }} | Fecha reporte: {{ date('Y-m-d') }} |
Establecimiento: {{ $establishment->description }} | Vendedor: {{ $cash->user->name }} |
Fecha y hora apertura: {{ $cash->date_opening }} {{ $cash->time_opening }} | Estado de caja: {{ $cash->state ? 'Aperturada' : 'Cerrada' }} |
Fecha y hora cierre: {{ $cash->date_closed }} {{ $cash->time_closed }} |
Saldo inicial | Ingreso | Egreso | Saldo final |
---|---|---|---|
${{ number_format($cash->beginning_balance, 2, '.', ',') }} | ${{ number_format($cash_income, 2, '.', ',') }} | ${{ number_format($cashEgress, 2, '.', ',') }} | ${{ number_format($cash->beginning_balance + $cash_income - $cashEgress, 2, '.', ',') }} |
# | Medio de Pago | Número de Transacciones | Valor Transacción |
---|---|---|---|
{{ $loop->iteration }} | {{ $item->name }} | {{ $item->transaction_count }} | ${{ number_format($item->sum, 2, '.', ',') }} |
Total: | ${{ number_format($totalSum, 2, '.', ',') }} |
No se encontraron registros de documentos.
@endif @elseSaldo inicial | Ingreso | Egreso | Saldo final |
---|---|---|---|
${{ number_format($cash->beginning_balance, 2, '.', ',') }} | ${{ number_format($cash_income, 2, '.', ',') }} | ${{ number_format($cashEgress, 2, '.', ',') }} | ${{ number_format($cash->beginning_balance + $cash_income - $cashEgress, 2, '.', ',') }} |
# | Medio de Pago | Número de Transacciones | Valor Transacción |
---|---|---|---|
{{ $loop->iteration }} | {{ $item->name }} | {{ $item->transaction_count }} | ${{ number_format($item->sum, 2, '.', ',') }} |
Total: | ${{ number_format($totalSum, 2, '.', ',') }} |
No se encontraron registros de documentos.
@endif @php $all_documents = []; $totalsByCategory = []; $ivaTotalsByCategory = []; // Para almacenar los totales de IVA por categoría foreach ($cash_documents as $cash_document) { if ($cash_document->document_pos) { $all_documents[] = $cash_document; } } foreach ($all_documents as $document) { foreach ($document->document_pos->items as $item) { if ($item->refund == 0) { $categoryId = $item->item->category_id ?? 'Categoría no especificada'; if (!isset($totalsByCategory[$categoryId])) { $totalsByCategory[$categoryId] = [ 'subtotal' => 0, 'discount' => 0, 'otherTaxes' => 0, 'iva' => [], 'total' => 0, ]; } $itemIvaRate = $item->tax->name ?? ""; // "IVA19", "IVA5", etc. $itemIvaValue = $item->total_tax ?? 0; // Total de IVA para ese ítem if (!isset($totalsByCategory[$categoryId]['iva'][$itemIvaRate])) { $totalsByCategory[$categoryId]['iva'][$itemIvaRate] = 0; } // Acumular el IVA por tasa dentro de cada categoría $totalsByCategory[$categoryId]['iva'][$itemIvaRate] += $itemIvaValue; // Sumar los otros valores al total por categoría $totalsByCategory[$categoryId]['subtotal'] += $item->subtotal ?? 0; $totalsByCategory[$categoryId]['discount'] += $item->discount ?? 0; $totalsByCategory[$categoryId]['otherTaxes'] += $item->other_taxes ?? 0; $totalsByCategory[$categoryId]['total'] += $item->total ?? 0; } } } // Ahora, se calcula el total de IVA por categoría foreach ($totalsByCategory as $categoryId => &$categoryTotals) { $categoryTotals['totalIva'] = array_sum($categoryTotals['iva']); // Se Suma todos los valores de IVA } unset($categoryTotals); // Se Quita referencia @endphp# | Referencia | Total |
---|---|---|
{{ $index + 1 }} | {{ $expensePayment->reference ?? 'Sin referencia' }} | {{ number_format($expensePayment->payment, 2) }} |
No se encontraron gastos.
@endifCategoría/IVA | Tarifa | Base Gravable | Descuento | Valor IVA | Valor neto |
---|---|---|---|---|---|
{{ $categoryName }} |
@foreach ($totals['iva'] as $ivaName => $ivaValue)
@if ($ivaValue)
{{ $ivaName }} @endif @endforeach |
{{ number_format($totals['subtotal'] - $totals['totalIva'], 2) }} | {{ number_format($totals['discount'], 2) }} | {{ number_format($totals['totalIva'], 2) }} | {{ number_format($totals['total'], 2) }} |
Totales: | {{ number_format($grandTotalSubtotal, 2) }} | {{ number_format($grandTotalDiscount, 2) }} | {{ number_format($grandTotalIva, 2) }} | {{ number_format($grandTotal, 2) }} |
Categoría/IVA | Tarifa | Base Gravable | Descuento | Valor IVA | Valor neto |
---|---|---|---|---|---|
{{ $categoryName }} |
@foreach ($totals['iva'] as $ivaName => $ivaValue)
@if ($ivaValue)
{{ $ivaName }} @endif @endforeach |
{{ number_format($totals['subtotal'] - $totals['totalIva'], 2) }} | {{ number_format($totals['discount'], 2) }} | {{ number_format($totals['totalIva'], 2) }} | {{ number_format($totals['total'], 2) }} |
Totales: | {{ number_format($grandTotalSubtotal, 2) }} | {{ number_format($grandTotalDiscount, 2) }} | {{ number_format($grandTotalIva, 2) }} | {{ number_format($grandTotal, 2) }} |
Tarifa | Base Gravable | Valor IVA | Total Incluido IVA |
---|---|---|---|
{{ $ivaName }} ({{ $totals['rate'] }}%) | {{ number_format($totals['base_gravable'], 2, '.', ',') }} | {{ number_format($totals['valor_iva'], 2, '.', ',') }} | {{ number_format($totals['total'], 2, '.', ',') }} |
Total | {{ number_format($totalValorAntesIva, 2, '.', ',') }} | {{ number_format($totalValorIva, 2, '.', ',') }} | {{ number_format($totalGeneral, 2, '.', ',') }} |
Tipo de caja | Número de Caja o Serial |
---|---|
{{ $resolution->cash_type ?? 'N/A' }} | {{ $resolution->plate_number ?? 'N/A' }} |
No se encontraron máquinas. |