FIX: Venta

This commit is contained in:
Juan Pablo Vial
2024-03-13 22:43:37 -03:00
parent 57f9169cc7
commit 9c335fd350
8 changed files with 35 additions and 106 deletions

View File

@ -132,9 +132,9 @@ class Venta extends Ideal\Repository
['propietario', 'propiedad', 'pie', 'bono_pie', 'credito', 'escritura', 'subsidio', 'escriturado',
'entrega', 'entregado', 'fecha', 'valor_uf', 'estado', 'fecha_ingreso', 'avalchile', 'agente', 'uf',
'relacionado', 'promocion', 'resciliacion', 'devolucion'],
[$model->propietario()->rut, $model->propiedad()->id, $model->formaPago()->pie?->id, $model->formaPago()->bonoPie?->id,
$model->formaPago()->credito?->id, $model->formaPago()->escritura?->id, $model->formaPago()->subsidio?->id,
$model->formaPago()->escritura !== null ? $model->formaPago()->escritura->pago->fecha->format('Y-m-d') : null,
[$model->propietario()->rut, $model->propiedad()->id, $model->formaPago()?->pie?->id, $model->formaPago()?->bonoPie?->id,
$model->formaPago()?->credito?->id, $model->formaPago()?->escritura?->id, $model->formaPago()?->subsidio?->id,
$model->formaPago()?->escritura !== null ? $model->formaPago()?->escritura->pago->fecha->format('Y-m-d') : null,
null, null, $model->fecha->format('Y-m-d'), $model->valor, 1, $model->fechaIngreso->format('Y-m-d'),
null, null, $model->uf, $model->relacionado ? 1 : 0, null, null, null]
);

View File

@ -18,22 +18,23 @@ class Propiedad extends Ideal\Repository
public function create(?array $data = null): Model\Venta\Propiedad
{
$map = (new Implement\Repository\MapperParser())
->register('unidad_principal', (new Implement\Repository\Mapper())
->setProperty('unidades')
->setFunction(function($data) {
if (isset($data['id'])) {
return $this->unidadService->getByPropiedad($data['id']);
}
return [$this->unidadService->getById($data['unidad_principal'])];
}))
->register('estado', new Implement\Repository\Mapper\Boolean('estado'));
return $this->parseData(new Model\Venta\Propiedad(), $data, $map);
}
public function load(array $data_row): Define\Model
{
$propiedad = parent::load($data_row);
if (isset($propiedad->id)) {
$propiedad->unidades = $this->unidadService->getByPropiedad($propiedad->id);
}
return $propiedad;
}
public function save(Define\Model $model): Model\Venta\Propiedad
{
$model->id = $this->saveNew(
['unidad_principal', 'estacionamientos', 'bodegas', 'estado'],
[$model->departamentos()[0]->id,
[null,
implode(',', array_map(function(Model\Venta\Unidad $unidad) {return $unidad->id;}, $model->estacionamientos())),
implode(',', array_map(function(Model\Venta\Unidad $unidad) {return $unidad->id;}, $model->bodegas())),
1]