Compare commits
4 Commits
eabdab23c3
...
5736a346e7
Author | SHA1 | Date | |
---|---|---|---|
5736a346e7 | |||
4f4e69f0c3 | |||
00deebeaa8 | |||
aee0754b5a |
@ -231,12 +231,12 @@
|
||||
return
|
||||
}
|
||||
const sum_precios = departamentos.map(departamento => {
|
||||
return departamento.current_precio.valor
|
||||
return departamento.valor
|
||||
}).reduce((sum, precio) => sum + precio, 0)
|
||||
departamentos.forEach(departamento => {
|
||||
const idx = units.data.units.findIndex(unit => unit.id === departamento.id)
|
||||
const saldo = venta.valor - precios
|
||||
units.data.units[idx].valor = saldo / sum_precios * departamento.current_precio.valor
|
||||
units.data.units[idx].valor = saldo / sum_precios * departamento.valor
|
||||
units.data.units[idx].venta = venta
|
||||
})
|
||||
})
|
||||
|
@ -333,7 +333,7 @@ class Venta extends Ideal\Repository
|
||||
->joined("INNER JOIN ({$subSubQuery}) e0 ON e0.`id` = e1.`id`");
|
||||
$interrogations = implode(',', array_fill(0, count($unidad_ids), '?'));
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select('a.*, pu.unidad')
|
||||
->select('a.*, a.valor_uf AS valor, pu.unidad')
|
||||
->from("{$this->getTable()} a")
|
||||
->joined('INNER JOIN propiedad_unidad pu ON pu.propiedad = a.propiedad')
|
||||
->joined("INNER JOIN ({$subQuery}) ev ON ev.`venta` = a.`id`")
|
||||
|
@ -19,7 +19,7 @@ class Propiedad extends Ideal\Repository
|
||||
|
||||
public function create(?array $data = null): Model\Venta\Propiedad
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['unidad_principal', 'estacionamientos', 'bodegas', 'estado']))
|
||||
$map = (new Implement\Repository\MapperParser())
|
||||
->register('estado', new Implement\Repository\Mapper\Boolean('estado'));
|
||||
return $this->parseData(new Model\Venta\Propiedad(), $data, $map);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class Propiedad extends Service
|
||||
public function getArrayById(int $propiedad_id): array
|
||||
{
|
||||
try {
|
||||
return $this->propiedadRepository->fetchArrayById($propiedad_id);
|
||||
return json_decode(json_encode($this->propiedadRepository->fetchById($propiedad_id)), true);
|
||||
} catch (EmptyResult $exception) {
|
||||
throw new Exception\ServiceAction\Read(__CLASS__, $exception);
|
||||
}
|
||||
|
@ -96,9 +96,7 @@ class PropiedadUnidad
|
||||
try {
|
||||
$unidad->precios = $this->precioService->getByUnidad($unidad->id);
|
||||
$unidad->currentPrecio = $this->precioService->getVigenteByUnidad($unidad->id);
|
||||
if ($unidad->valor === null or $unidad->valor === 0) {
|
||||
$unidad->valor = $unidad->currentPrecio->valor;
|
||||
}
|
||||
$unidad->valor = $unidad->currentPrecio->valor;
|
||||
} catch (Read) {}
|
||||
return $unidad;
|
||||
}
|
||||
|
Reference in New Issue
Block a user