<?php
namespace Incoviba\Model\Contabilidad\Movimiento\Auxiliar;

use Incoviba\Common\Ideal;
use Incoviba\Model;

class Detalle extends Ideal\Model
{
    public Model\Contabilidad\Movimiento\Auxiliar $auxiliar;
    public ?Model\Contabilidad\CentroCosto $centroCosto;
    public ?int $rut;
    public ?string $digito;
    public ?string $nombre;
    public ?string $categoria;
    public ?string $detalle;

    public function rut(): string
    {
        return $this->rut . '-' . $this->digito;
    }
    public function rutFormatted(): string
    {
        return number_format($this->rut, 0, ',', '.') . '-' . $this->digito;
    }

    public function jsonSerialize(): mixed
    {
        return [
            'auxiliar_id' => $this->auxiliar->id,
            'centro_costo' => $this->centroCosto,
            'rut' => $this->rut,
            'digito' => $this->digito,
            'nombre' => $this->nombre,
            'categoria' => $this->categoria,
            'detalle' => $this->detalle,
            'rutFormatted' => $this->rutFormatted(),
        ];
    }
}
