Terminado core :p
This commit is contained in:
@@ -4,6 +4,8 @@ namespace App\Livewire\Cajas;
|
||||
|
||||
use App\Models\Efectivo;
|
||||
use App\Models\Turno;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
@@ -19,6 +21,8 @@ class Index extends Component
|
||||
{
|
||||
use Interactions, WithPagination;
|
||||
|
||||
public $searchFecha = null;
|
||||
|
||||
public $modal = false;
|
||||
|
||||
public $fecha = null;
|
||||
@@ -27,11 +31,6 @@ class Index extends Component
|
||||
|
||||
public $turno = null;
|
||||
|
||||
public array $sort = [
|
||||
'column' => 'fecha',
|
||||
'direction' => 'desc',
|
||||
];
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.cajas.index');
|
||||
@@ -133,22 +132,21 @@ class Index extends Component
|
||||
#[Computed]
|
||||
public function rows(): LengthAwarePaginator
|
||||
{
|
||||
$turnos = Turno::orderBy('fecha', 'desc')
|
||||
return Turno::orderBy('fecha', 'desc')
|
||||
->orderBy('numero_caja', 'asc')
|
||||
->orderBy('numero_turno', 'asc')
|
||||
->paginate()
|
||||
->through(function ($turno) {
|
||||
return (object) [
|
||||
'id' => $turno->id,
|
||||
'fecha' => $turno->fecha->format('d-m-Y'),
|
||||
'numero_caja' => $turno->numero_caja,
|
||||
'numero_turno' => $turno->numero_turno,
|
||||
'ingresos' => Number::currency($turno->ingresos()->sum('total')),
|
||||
'egresos' => Number::currency($turno->egresos()->sum('valor')),
|
||||
'arqueo' => Number::currency($turno->arqueo),
|
||||
];
|
||||
});
|
||||
->when($this->searchFecha, function ($query) {
|
||||
if (!$this->searchFecha) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $turnos;
|
||||
try {
|
||||
$fecha = Carbon::parse($this->searchFecha);
|
||||
$query->whereDate('fecha', $fecha);
|
||||
} catch (Exception $exception) {
|
||||
// Pass nada que hacer
|
||||
}
|
||||
})
|
||||
->paginate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-[minmax(0,2fr)_minmax(0,1fr)] gap-4 items-start">
|
||||
<div class="grid grid-cols-[minmax(0,4fr)_minmax(0,1fr)] gap-4 items-start">
|
||||
<x-tab wire:model="tab">
|
||||
<x-tab.items tab="Ingresos">
|
||||
<x-slot:left>
|
||||
|
||||
@@ -1,13 +1,28 @@
|
||||
@use(Illuminate\Support\Number)
|
||||
<div>
|
||||
<x-title>Cajas</x-title>
|
||||
|
||||
<div class="flex gap-2 justify-between items-end">
|
||||
<x-date label="Fecha" helpers/>
|
||||
<x-date label="Fecha" wire:model.live="searchFecha" helpers/>
|
||||
<x-button wire:click="createTurno" icon="plus">Registrar Caja</x-button>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<x-table striped :headers="$this->headers" :rows="$this->rows" paginate :$sort>
|
||||
<x-table striped :headers="$this->headers" :rows="$this->rows" paginate>
|
||||
@interact('column_fecha', $row)
|
||||
{{$row->fecha->format('d-m-Y')}}
|
||||
@endinteract
|
||||
@interact('column_ingresos', $row)
|
||||
{{Number::currency($row->ingresos()->sum('total'))}}
|
||||
@endinteract
|
||||
@interact('column_egresos', $row)
|
||||
{{Number::currency($row->egresos()->sum('valor'))}}
|
||||
@endinteract
|
||||
@interact('column_arqueo', $row)
|
||||
<span class="font-bold {{$row->arqueo >= 0 ? 'text-green-500' : 'text-red-500'}}">
|
||||
{{Number::currency($row->arqueo)}}
|
||||
</span>
|
||||
@endinteract
|
||||
@interact('column_action', $row)
|
||||
<x-button.circle icon="edit" :href="route('cajas.edit', $row->id)" :key="uniqid()"/>
|
||||
<x-button.circle icon="trash" color="red" wire:click="confirmDelete('{{$row->id}}')" :key="uniqid()"/>
|
||||
|
||||
Reference in New Issue
Block a user