Terminado core :p
This commit is contained in:
@@ -4,6 +4,8 @@ namespace App\Livewire\Cajas;
|
|||||||
|
|
||||||
use App\Models\Efectivo;
|
use App\Models\Efectivo;
|
||||||
use App\Models\Turno;
|
use App\Models\Turno;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Exception;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
@@ -19,6 +21,8 @@ class Index extends Component
|
|||||||
{
|
{
|
||||||
use Interactions, WithPagination;
|
use Interactions, WithPagination;
|
||||||
|
|
||||||
|
public $searchFecha = null;
|
||||||
|
|
||||||
public $modal = false;
|
public $modal = false;
|
||||||
|
|
||||||
public $fecha = null;
|
public $fecha = null;
|
||||||
@@ -27,11 +31,6 @@ class Index extends Component
|
|||||||
|
|
||||||
public $turno = null;
|
public $turno = null;
|
||||||
|
|
||||||
public array $sort = [
|
|
||||||
'column' => 'fecha',
|
|
||||||
'direction' => 'desc',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function render(): View
|
public function render(): View
|
||||||
{
|
{
|
||||||
return view('livewire.cajas.index');
|
return view('livewire.cajas.index');
|
||||||
@@ -133,22 +132,21 @@ class Index extends Component
|
|||||||
#[Computed]
|
#[Computed]
|
||||||
public function rows(): LengthAwarePaginator
|
public function rows(): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
$turnos = Turno::orderBy('fecha', 'desc')
|
return Turno::orderBy('fecha', 'desc')
|
||||||
->orderBy('numero_caja', 'asc')
|
->orderBy('numero_caja', 'asc')
|
||||||
->orderBy('numero_turno', 'asc')
|
->orderBy('numero_turno', 'asc')
|
||||||
->paginate()
|
->when($this->searchFecha, function ($query) {
|
||||||
->through(function ($turno) {
|
if (!$this->searchFecha) {
|
||||||
return (object) [
|
return;
|
||||||
'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),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
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>
|
</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 wire:model="tab">
|
||||||
<x-tab.items tab="Ingresos">
|
<x-tab.items tab="Ingresos">
|
||||||
<x-slot:left>
|
<x-slot:left>
|
||||||
|
|||||||
@@ -1,13 +1,28 @@
|
|||||||
|
@use(Illuminate\Support\Number)
|
||||||
<div>
|
<div>
|
||||||
<x-title>Cajas</x-title>
|
<x-title>Cajas</x-title>
|
||||||
|
|
||||||
<div class="flex gap-2 justify-between items-end">
|
<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>
|
<x-button wire:click="createTurno" icon="plus">Registrar Caja</x-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-4">
|
<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)
|
@interact('column_action', $row)
|
||||||
<x-button.circle icon="edit" :href="route('cajas.edit', $row->id)" :key="uniqid()"/>
|
<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()"/>
|
<x-button.circle icon="trash" color="red" wire:click="confirmDelete('{{$row->id}}')" :key="uniqid()"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user