<?php
namespace Incoviba\Model;

use Incoviba\Common\Ideal\Model;
use Incoviba\Model\Inmobiliaria\TipoSociedad;

class Inmobiliaria extends Model
{
    public int $rut;
    public ?string $dv;
    public ?string $razon;
    public ?string $abreviacion;
    public ?string $cuenta;
    public ?Banco $banco;
    public ?TipoSociedad $tipoSociedad;

    public function rut(): string
    {
        return implode('-', [
            number_format($this->rut, 0, ',', '.'),
            $this->dv
        ]);
    }

    public function jsonSerialize(): mixed
    {
        return [
            'rut' => $this->rut,
            'dv' => $this->dv ?? '',
            'rut_formateado' => $this->rut(),
            'razon' => $this->razon ?? '',
            'abreviacion' => $this->abreviacion ?? '',
            'cuenta' => $this->cuenta ?? '',
            'banco' => $this->banco ?? '',
            'tipo_sociedad' => $this->tipoSociedad ?? ''
        ];
    }
}
