Movimiento + Detalles
This commit is contained in:
@ -13,7 +13,7 @@ class CentroCosto extends Ideal\Model
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_map(parent::jsonSerialize(), [
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'tipo_centro' => $this->tipoCentro,
|
||||
'categoria' => $this->categoria,
|
||||
'tipo_cuenta' => $this->tipoCuenta,
|
||||
|
@ -3,6 +3,7 @@ namespace Incoviba\Model;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model\Movimiento\Detalle;
|
||||
|
||||
class Movimiento extends Ideal\Model
|
||||
{
|
||||
@ -14,6 +15,15 @@ class Movimiento extends Ideal\Model
|
||||
public int $abono;
|
||||
public int $saldo;
|
||||
|
||||
protected ?Detalle $detalles;
|
||||
public function getDetalles(): ?Detalle
|
||||
{
|
||||
if (!isset($this->detalles)) {
|
||||
$this->detalles = $this->runFactory('detalles');
|
||||
}
|
||||
return $this->detalles;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
@ -23,7 +33,8 @@ class Movimiento extends Ideal\Model
|
||||
'documento' => $this->documento,
|
||||
'cargo' => $this->cargo,
|
||||
'abono' => $this->abono,
|
||||
'saldo' => $this->saldo
|
||||
'saldo' => $this->saldo,
|
||||
'detalles' => $this->getDetalles() ?? null
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
21
app/src/Model/Movimiento/Detalle.php
Normal file
21
app/src/Model/Movimiento/Detalle.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Movimiento;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Detalle extends Ideal\Model
|
||||
{
|
||||
public Model\Movimiento $movimiento;
|
||||
public ?Model\CentroCosto $centroCosto;
|
||||
public ?string $detalle;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return [
|
||||
'movimiento_id' => $this->movimiento->id,
|
||||
'centro_costo' => $this->centroCosto,
|
||||
'detalle' => $this->detalle
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user