Base de Datos

This commit is contained in:
Juan Pablo Vial
2025-02-18 16:02:10 -03:00
parent 8b386b8b44
commit 9d135e2c26
25 changed files with 1091 additions and 1 deletions

View File

@ -0,0 +1,41 @@
<?php
namespace Incoviba\Model\Proyecto\Broker;
use Incoviba\Common;
use Incoviba\Model;
class Contract extends Common\Ideal\Model
{
public Model\Proyecto $project;
public Model\Proyecto\Broker $broker;
public float $commission;
protected array $states = [];
public function states(): array
{
if (!isset($this->states)) {
$this->states = $this->runFactory('states');
}
return $this->states;
}
protected Contract\State $current;
public function currentState(): Contract\State
{
if (!isset($this->current)) {
$this->current = last($this->states());
}
return $this->current;
}
protected function jsonComplement(): array
{
return [
'project_id' => $this->project->id,
'broker_rut' => $this->broker->rut,
'commission' => $this->commission,
'states' => $this->states(),
'current' => $this->currentState(),
];
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Incoviba\Model\Proyecto\Broker\Contract;
use DateTimeInterface;
use Incoviba\Common;
use Incoviba\Model;
class State extends Common\Ideal\Model
{
public Model\Proyecto\Broker\Contract $contract;
public DateTimeInterface $date;
public int $type;
protected function jsonComplement(): array
{
return [
'contract_id' => $this->contract->id,
'date' => $this->date->format('Y-m-d'),
'type' => [
'id' => $this->type,
'description' => State\Type::name($this->type)
]
];
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace Incoviba\Model\Proyecto\Broker\Contract\State;
enum Type: int
{
case ACTIVE = 1;
case INACTIVE = 0;
public static function name(int $type): string
{
return match ($type) {
self::ACTIVE => 'active',
self::INACTIVE => 'inactive',
default => throw new \InvalidArgumentException('Unexpected match value')
};
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace Incoviba\Model\Proyecto\Broker;
use Incoviba\Common;
use Incoviba\Model;
class Data extends Common\Ideal\Model
{
public Model\Proyecto\Broker $broker;
public ?Model\Persona $representative = null;
public ?string $legalName = null;
protected function jsonComplement(): array
{
return [
'broker_rut' => $this->broker->rut,
'representative_rut' => $this->representative?->rut,
'legal_name' => $this->legalName
];
}
}