90 lines
2.1 KiB
PHP
90 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Cajas;
|
|
|
|
use App\Models\Turno;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Support\Number;
|
|
use Livewire\Attributes\Computed;
|
|
use Livewire\Attributes\On;
|
|
use Livewire\Attributes\Url;
|
|
use Livewire\Component;
|
|
|
|
class Edit extends Component
|
|
{
|
|
public Turno $turno;
|
|
|
|
#[Url]
|
|
public $tab = 'Ingresos';
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.cajas.edit');
|
|
}
|
|
|
|
#[On('updated_totals')]
|
|
public function recalculateTotals(): void
|
|
{
|
|
unset($this->totalIngresos);
|
|
}
|
|
|
|
|
|
/*
|
|
private void fillResumen() {
|
|
long totalEfectivo = efectivo.getTotal();
|
|
long totalDocumentos = repos.documento.getTotalOfTurno(state.getTurno());
|
|
long totalIngresos = repos.ingreso.getTotalOfTurno(state.getTurno());
|
|
long totalEgresos = repos.egreso.getTotalTurno(state.getTurno());
|
|
|
|
long rendido = totalDocumentos + totalEfectivo + totalEgresos;
|
|
long diferencia = rendido - totalIngresos;
|
|
|
|
view.setResumenEfectivo(totalEfectivo);
|
|
view.setResumenDocumentos(totalDocumentos);
|
|
view.setResumenEgreso(totalEgresos);
|
|
view.setResumenRendido(rendido);
|
|
view.setResumenDebeRendir(totalIngresos);
|
|
view.setResumenDiferencia(diferencia);
|
|
}
|
|
*/
|
|
|
|
#[Computed]
|
|
public function totalEfectivo()
|
|
{
|
|
return $this->turno->efectivo()->first()?->total ?? 0;
|
|
}
|
|
|
|
#[Computed]
|
|
public function totalEgresos()
|
|
{
|
|
return $this->turno->egresos()->sum('valor');
|
|
}
|
|
#[Computed]
|
|
public function totalDocumentos()
|
|
{
|
|
return $this->turno->documentos()->sum('valor');
|
|
}
|
|
|
|
|
|
#[Computed]
|
|
public function rendido()
|
|
{
|
|
$documentos = $this->turno->documentos()->sum('valor');
|
|
$egresos = $this->turno->egresos()->sum('valor');
|
|
$efectivo = $this->turno->efectivo()->first()?->total ?? 0;
|
|
|
|
return $documentos + $efectivo + $egresos;
|
|
}
|
|
|
|
#[Computed]
|
|
public function debeRendir() {
|
|
return $this->turno->ingresos()->sum('total');
|
|
}
|
|
|
|
#[Computed]
|
|
public function diferencia() {
|
|
return $this->rendido - $this->debeRendir;
|
|
}
|
|
|
|
}
|