Agregar Proveedor

This commit is contained in:
Juan Pablo Vial
2024-12-03 16:45:20 -03:00
parent 5b44260245
commit 42e1dcdff7
19 changed files with 473 additions and 283 deletions

View File

@ -1,32 +0,0 @@
<?php
namespace Incoviba\Model;
use DateTimeInterface;
use Incoviba\Common\Ideal;
class DatosPersona extends Ideal\Model
{
public Persona $persona;
public ?Direccion $direccion;
public ?int $telefono;
public ?string $email;
public ?DateTimeInterface $fechaNacimiento;
public ?string $sexo;
public ?string $estadoCivil;
public ?string $nacionalidad;
public ?string $ocupacion;
public function jsonSerialize(): mixed
{
return [
'direccion' => $this->direccion,
'telefono' => $this->telefono,
'email' => $this->email,
'fechaNacimiento' => $this->fechaNacimiento,
'sexo' => $this->sexo,
'estadoCivil' => $this->estadoCivil,
'nacionalidad' => $this->nacionalidad,
'profesion' => $this->ocupacion,
];
}
}

View File

@ -2,7 +2,9 @@
namespace Incoviba\Model\Inmobiliaria;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Model;
use Incoviba\Model\Inmobiliaria\Proveedor\Datos;
class Proveedor extends Ideal\Model
{
@ -10,18 +12,30 @@ class Proveedor extends Ideal\Model
public string $digito;
public string $nombre;
public ?string $razon;
public ?DatosProveedor $datos;
public ?Model\Persona $contacto;
public ?Datos $datos;
public function datos(): ?Datos
{
if (!isset($this->datos)) {
$this->datos = $this->runFactory('datos');
}
return $this->datos;
}
public function jsonSerialize(): mixed
{
return [
$json = [
'rut' => $this->rut,
'digito' => $this->digito,
'nombre' => $this->nombre,
'razon' => $this->razon,
'datos' => $this->datos,
'datos' => null,
'contacto' => $this->contacto
];
try {
$json['datos'] = $this->datos();
} catch (EmptyResult) {}
return $json;
}
}

View File

@ -1,10 +1,11 @@
<?php
namespace Incoviba\Model\Inmobiliaria;
namespace Incoviba\Model\Inmobiliaria\Proveedor;
use Incoviba\Common\Ideal;
use Incoviba\Model\Direccion;
use Incoviba\Model\Inmobiliaria\Proveedor;
class DatosProveedor extends Ideal\Model
class Datos extends Ideal\Model
{
public Proveedor $proveedor;
public ?Direccion $direccion;

View File

@ -2,6 +2,7 @@
namespace Incoviba\Model;
use Incoviba\Common\Ideal;
use Incoviba\Model\Persona\Datos;
class Persona extends Ideal\Model
{
@ -21,8 +22,8 @@ class Persona extends Ideal\Model
return number_format($this->rut, 0, ',', '.') . '-' . $this->digito;
}
protected ?DatosPersona $datos;
public function datos(): ?DatosPersona
protected ?Datos $datos;
public function datos(): ?Datos
{
if (!isset($this->datos)) {
$this->datos = $this->runFactory('datos');
@ -40,7 +41,7 @@ class Persona extends Ideal\Model
'apellidoMaterno' => $this->apellidoMaterno,
'nombreCompleto' => $this->nombreCompleto(),
'rutCompleto' => $this->rutCompleto(),
'datos' => $this->datos(),
'datos' => $this->datos() ?? null,
];
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace Incoviba\Model\Persona;
use DateTimeInterface;
use Incoviba\Common\Ideal;
use Incoviba\Model\Direccion;
use Incoviba\Model\Persona;
class Datos extends Ideal\Model
{
public Persona $persona;
public ?Direccion $direccion;
public ?int $telefono;
public ?string $email;
public ?DateTimeInterface $fechaNacimiento;
public ?string $sexo;
public ?string $estadoCivil;
public ?string $nacionalidad;
public ?string $ocupacion;
public function jsonSerialize(): mixed
{
return [
'direccion' => $this->direccion ?? null,
'telefono' => $this->telefono ?? null,
'email' => $this->email ?? null,
'fechaNacimiento' => $this->fechaNacimiento ?? null,
'sexo' => $this->sexo ?? null,
'estadoCivil' => $this->estadoCivil ?? null,
'nacionalidad' => $this->nacionalidad ?? null,
'ocupacion' => $this->ocupacion ?? null,
];
}
}