2023-07-24 20:55:26 -04:00
|
|
|
<?php
|
|
|
|
namespace Incoviba\Model\Venta;
|
|
|
|
|
|
|
|
use DateTimeInterface;
|
|
|
|
use Incoviba\Common\Ideal\Model;
|
2024-03-26 09:38:20 -03:00
|
|
|
use Incoviba\Model\Contabilidad\Banco;
|
2023-07-24 20:55:26 -04:00
|
|
|
|
|
|
|
class Pago extends Model
|
|
|
|
{
|
2023-08-08 23:53:49 -04:00
|
|
|
const UF = 'uf';
|
|
|
|
const PESOS = 'pesos';
|
|
|
|
|
2023-07-24 20:55:26 -04:00
|
|
|
public float $valor;
|
|
|
|
public ?Banco $banco;
|
|
|
|
public ?TipoPago $tipoPago;
|
|
|
|
public ?string $identificador;
|
|
|
|
public ?DateTimeInterface $fecha;
|
|
|
|
public ?float $uf;
|
|
|
|
public ?string $pagador;
|
|
|
|
public ?Pago $asociado;
|
|
|
|
|
2023-08-08 23:53:49 -04:00
|
|
|
public array $estados;
|
|
|
|
public EstadoPago $currentEstado;
|
|
|
|
|
|
|
|
public function valor(string $moneda = Pago::UF): float
|
|
|
|
{
|
2024-01-08 13:16:12 -03:00
|
|
|
$uf = $this->uf ?? ($this->uf > 0.0 ? $this->uf : 1);
|
|
|
|
return $this->valor / (($moneda === Pago::UF) ? $uf : 1);
|
2023-08-08 23:53:49 -04:00
|
|
|
}
|
|
|
|
|
2023-07-24 20:55:26 -04:00
|
|
|
public function jsonSerialize(): mixed
|
|
|
|
{
|
|
|
|
return array_merge(parent::jsonSerialize(), [
|
|
|
|
'valor' => $this->valor,
|
|
|
|
'banco' => $this->banco ?? '',
|
|
|
|
'tipo_pago' => $this->tipoPago ?? '',
|
|
|
|
'identificador' => $this->identificador ?? '',
|
2023-12-21 21:06:38 -03:00
|
|
|
'fecha' => $this->fecha->format('Y-m-d H:i:s') ?? '',
|
2023-07-24 20:55:26 -04:00
|
|
|
'uf' => $this->uf ?? 1,
|
|
|
|
'pagador' => $this->pagador ?? '',
|
|
|
|
'asociado' => $this->asociado ?? ''
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|