Update 2022-03-07

This commit is contained in:
Aldarien
2022-03-07 12:42:34 +00:00
parent 67efd83ae3
commit abe01e5592
14 changed files with 243 additions and 251 deletions

View File

@ -410,6 +410,8 @@ class Informes
public static function ventas()
{
if (get('proyecto')) {
ini_set('memory_limit', "1G");
ini_set('max_execution_time', '3600');
$id = get('proyecto');
$proyecto = model(Proyecto::class)->findOne($id);
$ventas = $proyecto->ventas();
@ -434,7 +436,7 @@ class Informes
$columnas = [
'Propietario',
['name' => 'Departamento', 'style' => 'number'],
'Departamento',
['name' => 'Estacionamientos', 'style' => 'number'],
['name' => 'Bodegas', 'style' => 'number'],
'Fecha Venta',
@ -457,7 +459,8 @@ class Informes
['name' => 'Valor Neto', 'style' => 'amount'],
['name' => 'UF/m²*', 'style' => 'amount'],
['name' => 'Comision', 'style' => 'amount'],
['name' => 'Venta s/Comision', 'style' => 'amount']
['name' => 'Venta s/Comision', 'style' => 'amount'].
['name' => 'Precio', 'style' => 'Amount']
];
//$informe->addColumns($columnas);
@ -465,28 +468,14 @@ class Informes
foreach ($ventas as $venta) {
$info = [];
$info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto());
$info['Departamento'] = trim(array_reduce($venta->propiedad()->departamentos(), function($carry, $item) {
return implode(' - ', [$carry, $item->descripcion]);
}), ' -');
//$ests = [];
$info['Departamento'] = implode(' - ', array_map(function($item) {
return $item->descripcion;
}, $venta->propiedad()->departamentos()));
$es = $venta->propiedad()->estacionamientos();
/*if (count($es) > 0) {
foreach ($es as $e) {
$ests []= $e->descripcion;
}
}
$info['Estacionamientos'] = implode(', ', $ests);*/
$info['Estacionamientos'] = implode(', ', array_map(function($item) {
return $item->descripcion;
}, $es));
//$bods = [];
$bs = $venta->propiedad()->bodegas();
/*if (count($bs) > 0) {
foreach ($bs as $b) {
$bods []= $b->descripcion;
}
}
$info['Bodegas'] = implode(', ', $bods);*/
$info['Bodegas'] = implode(', ', array_map(function($item) {
return $item->descripcion;
}, $bs));
@ -495,7 +484,7 @@ class Informes
$info['Tipo'] = $venta->unidad()->abreviacion;
$info['m² Ponderados'] = $venta->unidad()->m2('vendible');
$info['Valor Promesa'] = $venta->valor_uf;
$info['Pie'] = $venta->pie()->valor;
$info['Pie'] = $venta->pie()->valor;
$info['Pie Pagado'] = 0;
$info['% Pie Pagado'] = 0;
if ($venta->pie()) {
@ -508,12 +497,6 @@ class Informes
$info['Valor Operador'] = $venta->valorComision();
//$promos = 0;
$ps = $venta->promociones();
/*if (count($ps) > 0) {
foreach ($ps as $promo) {
$promos += $promo->valor;
}
}
$info['Premios'] = $promos;*/
$info['Premios'] = array_reduce($ps, function($sum, $item) {
return $sum + $item->valor;
});
@ -536,31 +519,17 @@ class Informes
$info['UF/m²*'] = $venta->uf_m2();
$info['Comision'] = $venta->valorFinal() * $comision;
$info['Venta s/Comision'] = $venta->valorFinal() - $info['Comision'];
$fecha = $venta->fecha();
$info['Precio'] = 0;
try {
$info['Precio'] = array_reduce($venta->propiedad()->departamentos(), function($sum, $item) use ($fecha) {
return $sum + $item->precio($fecha)->valor;
});
} catch (\Exception $e) {
}
$data []= $info;
}
/*$informe->addData($data);
$totals = [
'Propietario' => 'TOTAL',
'Departamento' => 'count',
'Estacionamientos' => 'count',
'Bodegas' => 'count',
'm² Ponderados' => 'sum',
'Valor Promesa' => 'sum',
'Bono Pie' => 'sum',
'Subsidio' => 'sum',
'Ahorro' => 'sum',
'Credito' => 'sum',
'Valor Operador' => 'sum',
'Premios' => 'sum',
'Valor Ests & Bods' => 'sum',
'Valor Neto' => 'sum',
'Comision' => 'sum'
];
$informe->addTotals($totals);
return $informe->informe();*/
$body = [
"Proyecto" => $proyecto->descripcion,