97 lines
3.1 KiB
PHP
97 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Cajas\Components;
|
|
|
|
use App\Enums\TipoDocumento;
|
|
use App\Models\CalculoFondo;
|
|
use App\Models\Documento;
|
|
use App\Models\Turno;
|
|
use Exception;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Support\Number;
|
|
use Illuminate\Validation\ValidationException;
|
|
use Livewire\Attributes\Computed;
|
|
use Livewire\Attributes\Validate;
|
|
use Livewire\Component;
|
|
use Log;
|
|
use TallStackUi\Traits\Interactions;
|
|
|
|
class EfectivoComponent extends Component
|
|
{
|
|
use Interactions;
|
|
|
|
public Turno $turno;
|
|
|
|
#[Validate('required|numeric')]
|
|
public $veinte_mil = 0;
|
|
#[Validate('required|numeric')]
|
|
public $diez_mil = 0;
|
|
#[Validate('required|numeric')]
|
|
public $cinco_mil = 0;
|
|
#[Validate('required|numeric')]
|
|
public $dos_mil = 0;
|
|
#[Validate('required|numeric')]
|
|
public $mil = 0;
|
|
#[Validate('required|numeric')]
|
|
public $quinientos = 0;
|
|
#[Validate('required|numeric')]
|
|
public $cien = 0;
|
|
#[Validate('required|numeric')]
|
|
public $cincuenta = 0;
|
|
#[Validate('required|numeric')]
|
|
public $diez = 0;
|
|
|
|
public function mount(): void
|
|
{
|
|
$efectivo = $this->turno->efectivo()->first();
|
|
$this->veinte_mil = $efectivo->veinte_mil;
|
|
$this->diez_mil = $efectivo->diez_mil;
|
|
$this->cinco_mil = $efectivo->cinco_mil;
|
|
$this->dos_mil = $efectivo->dos_mil;
|
|
$this->mil = $efectivo->mil;
|
|
$this->quinientos = $efectivo->quinientos;
|
|
$this->cien = $efectivo->cien;
|
|
$this->cincuenta = $efectivo->cincuenta;
|
|
$this->diez = $efectivo->diez;
|
|
}
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.cajas.components.efectivo-component');
|
|
}
|
|
|
|
public function updated($attribute): void
|
|
{
|
|
$this->validateOnly($attribute);
|
|
|
|
if ($attribute === 'veinte_mil') {
|
|
$this->turno->efectivo()->first()->update(['veinte_mil' => $this->veinte_mil]);
|
|
} elseif ($attribute === 'diez_mil') {
|
|
$this->turno->efectivo()->first()->update(['diez_mil' => $this->diez_mil]);
|
|
} elseif ($attribute === 'cinco_mil') {
|
|
$this->turno->efectivo()->first()->update(['cinco_mil' => $this->cinco_mil]);
|
|
} elseif ($attribute === 'dos_mil') {
|
|
$this->turno->efectivo()->first()->update(['dos_mil' => $this->dos_mil]);
|
|
} elseif ($attribute === 'mil') {
|
|
$this->turno->efectivo()->first()->update(['mil' => $this->mil]);
|
|
} elseif ($attribute === 'quinientos') {
|
|
$this->turno->efectivo()->first()->update(['quinientos' => $this->quinientos]);
|
|
} elseif ($attribute === 'cien') {
|
|
$this->turno->efectivo()->first()->update(['cien' => $this->cien]);
|
|
} elseif ($attribute === 'cincuenta') {
|
|
$this->turno->efectivo()->first()->update(['cincuenta' => $this->cincuenta]);
|
|
} elseif ($attribute === 'diez') {
|
|
$this->turno->efectivo()->first()->update(['diez' => $this->diez]);
|
|
}
|
|
|
|
$this->dispatch('updated_totals');
|
|
}
|
|
|
|
#[Computed]
|
|
public function totalEfectivo(): int
|
|
{
|
|
return $this->turno->efectivo()->first()->total;
|
|
}
|
|
}
|