Merge branch 'develop'
This commit is contained in:
12
Pipfile
12
Pipfile
@ -1,12 +0,0 @@
|
|||||||
[[source]]
|
|
||||||
name = "pypi"
|
|
||||||
url = "https://pypi.org/simple"
|
|
||||||
verify_ssl = true
|
|
||||||
|
|
||||||
[dev-packages]
|
|
||||||
|
|
||||||
[packages]
|
|
||||||
gunicorn = "*"
|
|
||||||
|
|
||||||
[requires]
|
|
||||||
python_version = "3.8"
|
|
9
Python.Dockerfile
Normal file
9
Python.Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM python:3.8
|
||||||
|
|
||||||
|
COPY ./bin /usr/opt/incoviba
|
||||||
|
|
||||||
|
WORKDIR /usr/opt/incoviba/informes
|
||||||
|
|
||||||
|
RUN pip install gunicorn pandas xlsxwriter httpx flask numpy
|
||||||
|
|
||||||
|
CMD ["gunicorn", "-w", "4", "--bind", "0.0.0.0", "app:app"]
|
@ -7,7 +7,7 @@
|
|||||||
"aldarien/contract" : "*"
|
"aldarien/contract" : "*"
|
||||||
},
|
},
|
||||||
"require-dev" : {
|
"require-dev" : {
|
||||||
"phpunit/phpunit" : "^6.3"
|
"phpunit/phpunit" : "*"
|
||||||
},
|
},
|
||||||
"license" : "MIT",
|
"license" : "MIT",
|
||||||
"authors" : [{
|
"authors" : [{
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"aldarien/contract": "*",
|
"aldarien/contract": "*",
|
||||||
"aldarien/root": "*",
|
"aldarien/root": "*",
|
||||||
"symfony/yaml": "^3.3"
|
"symfony/yaml": "*"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"description" : "Module for formatting data, mostly numbers",
|
"description" : "Module for formatting data, mostly numbers",
|
||||||
"type" : "library",
|
"type" : "library",
|
||||||
"require-dev" : {
|
"require-dev" : {
|
||||||
"phpunit/phpunit" : "^6",
|
"phpunit/phpunit" : "*",
|
||||||
"aldarien/config": "*"
|
"aldarien/config": "*"
|
||||||
},
|
},
|
||||||
"license" : "MIT",
|
"license" : "MIT",
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
"description" : "Response handler module for my apps",
|
"description" : "Response handler module for my apps",
|
||||||
"type" : "library",
|
"type" : "library",
|
||||||
"require" : {
|
"require" : {
|
||||||
"wixel/gump" : "^1.5",
|
"wixel/gump" : "*",
|
||||||
"aldarien/contract" : "*"
|
"aldarien/contract" : "*"
|
||||||
},
|
},
|
||||||
"require-dev" : {
|
"require-dev" : {
|
||||||
"phpunit/phpunit" : "^6.3"
|
"phpunit/phpunit" : "*"
|
||||||
},
|
},
|
||||||
"license" : "MIT",
|
"license" : "MIT",
|
||||||
"authors" : [{
|
"authors" : [{
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require-dev" : {
|
"require-dev" : {
|
||||||
"phpunit/phpunit" : "~6",
|
"phpunit/phpunit" : "*",
|
||||||
"kint-php/kint" : "~2"
|
"kint-php/kint" : "*"
|
||||||
},
|
},
|
||||||
"autoload" : {
|
"autoload" : {
|
||||||
"psr-4" : {
|
"psr-4" : {
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
"description": "Session wrapper for aura/session",
|
"description": "Session wrapper for aura/session",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"require": {
|
"require": {
|
||||||
"aura/session": "^2.1",
|
"aura/session": "*",
|
||||||
"aldarien/contract": "*"
|
"aldarien/contract": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^6.3"
|
"phpunit/phpunit": "*"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
@ -19,7 +19,8 @@ class URL
|
|||||||
protected function findRoot()
|
protected function findRoot()
|
||||||
{
|
{
|
||||||
$base = $_SERVER['HTTP_HOST'] . ((isset($_SERVER['HTTP_PORT'])) ? ':' . $_SERVER['HTTP_PORT'] : '');
|
$base = $_SERVER['HTTP_HOST'] . ((isset($_SERVER['HTTP_PORT'])) ? ':' . $_SERVER['HTTP_PORT'] : '');
|
||||||
$uri = Http::createFromString(\Sabre\Uri\resolve($_SERVER['REQUEST_SCHEME'] . '://' . $base, $_SERVER['SCRIPT_NAME']));
|
$scheme = $_SERVER['HTTPS'] ? 'https' : 'http';
|
||||||
|
$uri = Http::createFromString(\Sabre\Uri\resolve($scheme . '://' . $base, $_SERVER['SCRIPT_NAME']));
|
||||||
$host = new Host($uri->getHost());
|
$host = new Host($uri->getHost());
|
||||||
if ($host->isAbsolute()) {
|
if ($host->isAbsolute()) {
|
||||||
return $host->getRegistrableDomain();
|
return $host->getRegistrableDomain();
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
"require" : {
|
"require" : {
|
||||||
"aldarien/contract" : "*",
|
"aldarien/contract" : "*",
|
||||||
"aldarien/root" : "*",
|
"aldarien/root" : "*",
|
||||||
"league/uri": "^5.2",
|
"league/uri": "*",
|
||||||
"sabre/uri": "^2.1"
|
"sabre/uri": "*"
|
||||||
},
|
},
|
||||||
"require-dev" : {
|
"require-dev" : {
|
||||||
"phpunit/phpunit" : "^6.3"
|
"phpunit/phpunit" : "*"
|
||||||
},
|
},
|
||||||
"license" : "MIT",
|
"license" : "MIT",
|
||||||
"authors" : [{
|
"authors" : [{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"description": "View module for my apps",
|
"description": "View module for my apps",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"require": {
|
"require": {
|
||||||
"philo/laravel-blade": "^3.1",
|
"philo/laravel-blade": "*",
|
||||||
"aldarien/contract": "*",
|
"aldarien/contract": "*",
|
||||||
"aldarien/config": "*"
|
"aldarien/config": "*"
|
||||||
},
|
},
|
||||||
@ -23,6 +23,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^6.3"
|
"phpunit/phpunit": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -461,7 +461,7 @@ class Informes
|
|||||||
['name' => 'Valor Neto', 'style' => 'amount'],
|
['name' => 'Valor Neto', 'style' => 'amount'],
|
||||||
['name' => 'UF/m²*', 'style' => 'amount'],
|
['name' => 'UF/m²*', 'style' => 'amount'],
|
||||||
['name' => 'Comision', 'style' => 'amount'],
|
['name' => 'Comision', 'style' => 'amount'],
|
||||||
['name' => 'Venta s/Comision', 'style' => 'amount'].
|
['name' => 'Venta s/Comision', 'style' => 'amount'],
|
||||||
['name' => 'Precio', 'style' => 'Amount']
|
['name' => 'Precio', 'style' => 'Amount']
|
||||||
];
|
];
|
||||||
//$informe->addColumns($columnas);
|
//$informe->addColumns($columnas);
|
||||||
@ -538,7 +538,7 @@ class Informes
|
|||||||
"Compañía" => $proyecto->inmobiliaria()->abreviacion,
|
"Compañía" => $proyecto->inmobiliaria()->abreviacion,
|
||||||
"data" => $data
|
"data" => $data
|
||||||
];
|
];
|
||||||
$client = new Client(['base_uri' => 'localhost:8011']);
|
$client = new Client(['base_uri' => "{$_ENV['PYTHON_HOST']}"]);
|
||||||
$response = $client->post('/ventas', ['json' => $body]);
|
$response = $client->post('/ventas', ['json' => $body]);
|
||||||
|
|
||||||
header("Content-Type: application/octet-stream; charset=utf-8");
|
header("Content-Type: application/octet-stream; charset=utf-8");
|
||||||
|
@ -1,901 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\Controller;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
use App\Definition\Controller;
|
|
||||||
use App\Alias\PHPExcel;
|
|
||||||
use Incoviba\old\Proyecto\Proyecto;
|
|
||||||
use Incoviba\old\Proyecto\Agente;
|
|
||||||
use Incoviba\old\Proyecto\ProyectoAgente;
|
|
||||||
use Incoviba\old\Venta\Venta;
|
|
||||||
use Incoviba\old\Venta\Pie;
|
|
||||||
use Incoviba\old\Venta\Credito;
|
|
||||||
use Incoviba\old\Venta\Cuota;
|
|
||||||
|
|
||||||
class Informes
|
|
||||||
{
|
|
||||||
use Controller;
|
|
||||||
|
|
||||||
protected static function setDefault()
|
|
||||||
{
|
|
||||||
self::$default = view('informes.list');
|
|
||||||
}
|
|
||||||
public static function gantt_entregas()
|
|
||||||
{
|
|
||||||
if (get('proyecto')) {
|
|
||||||
$id_proyecto = get('proyecto');
|
|
||||||
$proyecto = model(Proyecto::class)->find_one($id_proyecto);
|
|
||||||
$ini = \Carbon\Carbon::parse($proyecto->estado()->fecha, config('app.timezone'));
|
|
||||||
#$informe = new Informador('Carta Gantt Proyecto - ' . $proyecto->descripcion);
|
|
||||||
$name = 'Carta Gantt Proyecto - ' . $proyecto->descripcion;
|
|
||||||
$hoy = Carbon::now(config('app.timezone'));
|
|
||||||
$filename = str_replace('ñ', 'n', $name . ' - ' . $hoy->format('Y-m-d') . '.xls');
|
|
||||||
$informe = new PHPExcel($name, $filename);
|
|
||||||
|
|
||||||
$columnas = ['Departamento', 'Propietario', 'Entrega', 'Estado'];
|
|
||||||
$today = \Carbon\Carbon::today(config('app.timezone'));
|
|
||||||
$end = $today->copy()->addDays(30);
|
|
||||||
$dif = $end->diffInDays($ini);
|
|
||||||
for ($i = 0; $i <= $dif; $i ++) {
|
|
||||||
$f = $ini->copy()->addDays($i);
|
|
||||||
if ($f->isWeekend()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$columnas []= $f->format('Y-m-d');
|
|
||||||
}
|
|
||||||
$informe->addColumns($columnas);
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
foreach ($proyecto->entregas() as $venta) {
|
|
||||||
$info = [];
|
|
||||||
$info []= $venta->unidad()->descripcion;
|
|
||||||
$info []= $venta->propietario()->findOne()->nombreCompleto();
|
|
||||||
$fe = Carbon::parse($venta->entrega()->find_one()->fecha, config('app.timezone'));
|
|
||||||
$info []= $fe->format('Y-m-d');
|
|
||||||
$info []= '';
|
|
||||||
|
|
||||||
for ($i = 0; $i <= $dif; $i ++) {
|
|
||||||
$f = $ini->copy()->addDays($i);
|
|
||||||
if ($f->isWeekend()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($f >= $fe and $f <= $fe->copy()->addDays(14)) {
|
|
||||||
$info []= 'X';
|
|
||||||
} else {
|
|
||||||
$info []= '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$data []= $info;
|
|
||||||
}
|
|
||||||
$informe->addDatas($data);
|
|
||||||
|
|
||||||
return $informe->informe();
|
|
||||||
} else {
|
|
||||||
$proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many();
|
|
||||||
return view('informes.gantt_entregas', compact('proyectos'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static function escrituras()
|
|
||||||
{
|
|
||||||
if (get('proyecto')) {
|
|
||||||
set_time_limit(60);
|
|
||||||
$id_proyecto = get('proyecto');
|
|
||||||
$proyecto = model(Proyecto::class)->find_one($id_proyecto);
|
|
||||||
|
|
||||||
#$informe = new Informador('Escrituras - ' . $proyecto->descripcion);
|
|
||||||
$name = 'Escrituras';
|
|
||||||
$hoy = Carbon::now(config('app.timezone'));
|
|
||||||
$filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls');
|
|
||||||
$informe = new PHPExcel($name, $filename);
|
|
||||||
|
|
||||||
$columnas = [
|
|
||||||
'Departamento',
|
|
||||||
'Estacionamientos',
|
|
||||||
'Bodegas',
|
|
||||||
'Propietario',
|
|
||||||
(object) ['name' => 'Promesa', 'style' => 'number'],
|
|
||||||
['name' => 'Bono Pie', 'style' => 'amount'],
|
|
||||||
['name' => 'Pie Pagado', 'style' => 'amount'],
|
|
||||||
['name' => 'Reajuste', 'style' => 'amount'],
|
|
||||||
['name' => 'Abono Contado', 'style' => 'amount'],
|
|
||||||
['name' => 'Subsidio', 'style' => 'amount'],
|
|
||||||
'Estado Subsidio',
|
|
||||||
['name' => 'Credito', 'style' => 'amount'],
|
|
||||||
'Banco',
|
|
||||||
'Estado Credito',
|
|
||||||
['name' => 'Saldo', 'style' => 'amount'],
|
|
||||||
['name' => 'Escritura', 'style' => 'amount'],
|
|
||||||
['name' => 'Entrega', 'style' => 'date']
|
|
||||||
];
|
|
||||||
$informe->addColumns($columnas);
|
|
||||||
|
|
||||||
//$ventas = $proyecto->escrituras();
|
|
||||||
$ventas = $proyecto->ventas();
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
foreach ($ventas as $venta) {
|
|
||||||
$info = [];
|
|
||||||
$info['Departamento'] = $venta->unidad()->descripcion;
|
|
||||||
$ests = [];
|
|
||||||
foreach ($venta->propiedad()->estacionamientos() as $e) {
|
|
||||||
$ests []= $e->descripcion;
|
|
||||||
}
|
|
||||||
$bods = [];
|
|
||||||
foreach ($venta->propiedad()->bodegas() as $b) {
|
|
||||||
$bods []= $b->descripcion;
|
|
||||||
}
|
|
||||||
$info['Estacionamientos'] = implode(' - ', $ests);
|
|
||||||
$info['Bodegas'] = implode(' - ', $bods);
|
|
||||||
$info['Propietario'] = $venta->propietario()->nombreCompleto();
|
|
||||||
$info['Promesa'] = $venta->valor_uf;
|
|
||||||
$saldo = $venta->valor_uf;
|
|
||||||
$info['Bono Pie'] = '';
|
|
||||||
if ($venta->bono_pie != 0) {
|
|
||||||
$info['Bono Pie'] = $venta->bonoPie()->pago()->valor('ufs');
|
|
||||||
$saldo -= $venta->bonoPie()->pago()->valor('ufs');
|
|
||||||
}
|
|
||||||
$info['Pie'] = '';
|
|
||||||
$info['Reajuste'] = '';
|
|
||||||
if ($venta->pie != 0) {
|
|
||||||
$info['Pie'] = $venta->pie()->valorPagado();
|
|
||||||
$saldo -= $venta->pie()->valorPagado();
|
|
||||||
if ($venta->pie()->reajuste != 0) {
|
|
||||||
$info['Reajuste'] = $venta->pie()->reajuste()->valor('ufs');
|
|
||||||
$saldo -= $venta->pie()->reajuste()->valor('ufs');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info['Abono Contado'] = '';
|
|
||||||
if ($venta->escritura != 0) {
|
|
||||||
$info['Abono Contado'] = $venta->escritura()->pago()->valor('ufs');
|
|
||||||
$saldo -= $venta->escritura()->pago()->valor('ufs');
|
|
||||||
}
|
|
||||||
$info['Subsidio'] = '';
|
|
||||||
$info['Estado Subsidio'] = '';
|
|
||||||
if ($venta->subsidio != 0) {
|
|
||||||
$info['Subsidio'] = $venta->subsidio()->total('ufs');
|
|
||||||
$info['Estado Subsidio'] = implode(' - ', [
|
|
||||||
$venta->subsidio()->subsidio()->estado()->tipo()->descripcion,
|
|
||||||
$venta->subsidio()->pago()->estado()->tipo()->descripcion
|
|
||||||
]);
|
|
||||||
$saldo -= $venta->subsidio()->total('ufs');
|
|
||||||
}
|
|
||||||
$info['Credito'] = '';
|
|
||||||
$info['Banco'] = '';
|
|
||||||
$info['Estado Credito'] = '';
|
|
||||||
if ($venta->credito != 0) {
|
|
||||||
$info['Credito'] = $venta->credito()->pago()->valor('ufs');
|
|
||||||
$saldo -= $venta->credito()->pago()->valor('ufs');
|
|
||||||
if ($venta->credito()->pago()->banco != 0) {
|
|
||||||
$info['Banco'] = $venta->credito()->pago()->banco()->nombre;
|
|
||||||
}
|
|
||||||
$info['Estado Credito'] = $venta->credito()->pago()->estado()->tipo()->descripcion;
|
|
||||||
}
|
|
||||||
$info['Saldo'] = -$saldo;
|
|
||||||
$info['Escritura'] = '';
|
|
||||||
if ($venta->escriturado != 0) {
|
|
||||||
$info['Escritura'] = $venta->escriturado;
|
|
||||||
}
|
|
||||||
$info['Entrega'] = '';
|
|
||||||
if ($venta->entregado != 0) {
|
|
||||||
$info['Entrega'] = $venta->entregado;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data []= $info;
|
|
||||||
}
|
|
||||||
$informe->addData($data);
|
|
||||||
|
|
||||||
return $informe->informe();
|
|
||||||
} else {
|
|
||||||
$proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many();
|
|
||||||
return view('informes.escrituras', compact('proyectos'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static function consolidacion()
|
|
||||||
{
|
|
||||||
$id_proyecto = get('proyecto');
|
|
||||||
$proyecto = model(Proyecto::class)->findOne($id_proyecto);
|
|
||||||
|
|
||||||
$ventas = $proyecto->ventas();
|
|
||||||
set_time_limit(count($ventas));
|
|
||||||
|
|
||||||
$f = Carbon::today(config('app.timezone'));
|
|
||||||
setlocale(LC_TIME, 'es');
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
[$proyecto->descripcion],
|
|
||||||
[strftime('%d de %B de %Y', $f->timestamp)],
|
|
||||||
[''],
|
|
||||||
['']
|
|
||||||
];
|
|
||||||
$columns = [
|
|
||||||
['name' => 'Fecha', 'style' => 'date'],
|
|
||||||
'Glosa',
|
|
||||||
['name' => 'Debe', 'style' => 'number'],
|
|
||||||
['name' => 'Haber', 'style' => 'number'],
|
|
||||||
['name' => 'Saldo', 'style' => 'number'],
|
|
||||||
'Comentario'
|
|
||||||
];
|
|
||||||
$bold_rows = [];
|
|
||||||
|
|
||||||
foreach ($ventas as $venta) {
|
|
||||||
$data []= ['Departamento ' . $venta->unidad()->descripcion . ' (' . format('ufs', $venta->valor_uf) . ' UF)'];
|
|
||||||
$data []= $columns;
|
|
||||||
$bold_rows []= count($data) - 1;
|
|
||||||
$ufs = 0;
|
|
||||||
$debe = 0;
|
|
||||||
$haber = 0;
|
|
||||||
$sum = 0;
|
|
||||||
if ($venta->pie != 0) {
|
|
||||||
$cuotas = $venta->pie()->cuotas();
|
|
||||||
foreach ($cuotas as $cuota) {
|
|
||||||
$sum += $cuota->pago()->valor();
|
|
||||||
$ufs += $cuota->pago()->valor('ufs');
|
|
||||||
$haber += $cuota->pago()->valor();
|
|
||||||
$info = [
|
|
||||||
$cuota->pago()->estado()->fecha,
|
|
||||||
'Pie - Cuota ' . $cuota->numero() . ' - ' . $venta->pie()->cuotas . ' (' . format('ufs', $cuota->pago()->valor('ufs')) . ' UF)',
|
|
||||||
'',
|
|
||||||
$cuota->pago()->valor(),
|
|
||||||
$sum
|
|
||||||
];
|
|
||||||
if ($cuota->pago()->estado()->estado < 2) {
|
|
||||||
$info []= 'No ha sido abonada.';
|
|
||||||
}
|
|
||||||
$data []= $info;
|
|
||||||
}
|
|
||||||
if ($venta->pie()->reajuste != 0) {
|
|
||||||
$sum += $venta->pie()->reajuste()->valor();
|
|
||||||
$ufs += $venta->pie()->reajuste()->valor('ufs');
|
|
||||||
$haber += $venta->pie()->reajuste()->valor();
|
|
||||||
$info = [
|
|
||||||
$venta->pie()->reajuste()->estado()->fecha,
|
|
||||||
'Reajuste (' . format('ufs', $venta->pie()->reajuste()->valor('ufs')) . ' UF)',
|
|
||||||
'',
|
|
||||||
$venta->pie()->reajuste()->valor(),
|
|
||||||
$sum
|
|
||||||
];
|
|
||||||
if ($venta->pie()->reajuste()->estado()->estado < 2) {
|
|
||||||
$info []= 'No ha sido abonado.';
|
|
||||||
}
|
|
||||||
$data []= $info;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($venta->escritura != 0) {
|
|
||||||
$sum += $venta->escritura()->pago()->valor();
|
|
||||||
$ufs += $venta->escritura()->pago()->valor('ufs');
|
|
||||||
$haber += $venta->escritura()->pago()->valor();
|
|
||||||
$info = [
|
|
||||||
$venta->escritura()->pago()->estado()->fecha,
|
|
||||||
'Abono Escritura (' . format('ufs', $venta->escritura()->pago()->valor('ufs')) . ' UF)',
|
|
||||||
'',
|
|
||||||
$venta->escritura()->pago()->valor(),
|
|
||||||
$sum
|
|
||||||
];
|
|
||||||
if ($venta->escritura()->pago()->estado()->estado < 2) {
|
|
||||||
$info []= 'No ha sido abonado.';
|
|
||||||
}
|
|
||||||
$data []= $info;
|
|
||||||
}
|
|
||||||
if ($venta->credito != 0) {
|
|
||||||
$sum += $venta->credito()->pago()->valor();
|
|
||||||
$ufs += $venta->credito()->pago()->valor('ufs');
|
|
||||||
$haber += $venta->credito()->pago()->valor();
|
|
||||||
$info = [
|
|
||||||
$venta->credito()->pago()->estado()->fecha,
|
|
||||||
'Crédito (' . format('ufs', $venta->credito()->pago()->valor('ufs')) . ' UF)',
|
|
||||||
'',
|
|
||||||
$venta->credito()->pago()->valor(),
|
|
||||||
$sum
|
|
||||||
];
|
|
||||||
if ($venta->credito()->pago()->estado()->estado < 2) {
|
|
||||||
$info []= 'No ha sido pagado.';
|
|
||||||
}
|
|
||||||
$data []= $info;
|
|
||||||
}
|
|
||||||
if ($venta->bono_pie != 0) {
|
|
||||||
try {
|
|
||||||
$sum -= $venta->bonoPie()->pago()->valor();
|
|
||||||
$debe += $venta->bonoPie()->pago()->valor();
|
|
||||||
$info = [
|
|
||||||
$venta->bonoPie()->pago()->estado()->fecha,
|
|
||||||
'Bono Pie (' . format('ufs', $venta->bonoPie()->pago()->valor('ufs')) . ' UF)'.
|
|
||||||
$venta->bonoPie()->pago()->valor(),
|
|
||||||
'',
|
|
||||||
$sum
|
|
||||||
];
|
|
||||||
$data []= $info;
|
|
||||||
$sum += $venta->bonoPie()->pago()->valor();
|
|
||||||
$haber += $venta->bonoPie()->pago()->valor();
|
|
||||||
$info = [
|
|
||||||
$venta->bonoPie()->pago()->estado()->fecha,
|
|
||||||
'Bono Pie (' . format('ufs', $venta->bonoPie()->pago()->valor('ufs')) . ' UF)'.
|
|
||||||
'',
|
|
||||||
$venta->bonoPie()->pago()->valor(),
|
|
||||||
$sum
|
|
||||||
];
|
|
||||||
$data []= $info;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info = [
|
|
||||||
'',
|
|
||||||
'TOTAL (' . format('ufs', $ufs) . ' UF)',
|
|
||||||
$debe,
|
|
||||||
$haber,
|
|
||||||
$sum
|
|
||||||
];
|
|
||||||
$data []= $info;
|
|
||||||
$bold_rows []= count($data) - 1;
|
|
||||||
|
|
||||||
$data []= [''];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Departamento #
|
|
||||||
* Fecha |Glosa |Debe |Haber |Saldo
|
|
||||||
* <fecha> |Pie - Cuota 1 - n (# UF) |- |$# |<sum>
|
|
||||||
* <fecha> |Reajuste (# UF) |- |$# |<sum>
|
|
||||||
* <fecha> |Abono Escritura (# UF) |- |$# |<sum>
|
|
||||||
* <fecha> |Crédito (# UF) |- |$# |<sum>
|
|
||||||
* <fecha> |Bono Pie (# UF) |$# |- |<sum>
|
|
||||||
* <fecha> |Bono Pie (# UF) |- |$# |<sum>
|
|
||||||
* <fecha> |Devolución (# UF) |$# |- |<sum>
|
|
||||||
* - |TOTAL (# UF) |<sumDebe> |<sumHaber> |<sum>
|
|
||||||
*/
|
|
||||||
|
|
||||||
array_walk($data, function(&$e, $i) use ($columns) {
|
|
||||||
if (count($e) < count($columns)) {
|
|
||||||
$n = count($columns) - count($e);
|
|
||||||
for ($j = 0; $j < $n; $j ++) {
|
|
||||||
$e []= '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
#$informe = new Informador('Consolidación - ' . $proyecto->descripcion);
|
|
||||||
$name = 'Consolidación';
|
|
||||||
$hoy = Carbon::now(config('app.timezone'));
|
|
||||||
$filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls');
|
|
||||||
$informe = new PHPExcel($name, $filename);
|
|
||||||
$informe->addColumns($columns);
|
|
||||||
$informe->addData($data);
|
|
||||||
|
|
||||||
return $informe->informe();
|
|
||||||
}
|
|
||||||
public static function creditos_pendientes()
|
|
||||||
{
|
|
||||||
function creditos() {
|
|
||||||
$creditos = model(Credito::class)
|
|
||||||
->select('credito.*')
|
|
||||||
->join('venta', ['venta.credito', '=', 'credito.id'])
|
|
||||||
->join('pago', ['pago.id', '=', 'credito.pago'])
|
|
||||||
->rawJoin('JOIN (SELECT ep.* FROM (SELECT pago, MAX(id) AS id FROM estado_pago GROUP BY pago) e0 JOIN estado_pago ep ON ep.id = e0.id)', ['estado_pago.pago', '=', 'pago.id'], 'estado_pago')
|
|
||||||
->whereLt('estado_pago.estado', 2)
|
|
||||||
->where('venta.estado', 1)
|
|
||||||
->orderByAsc('estado_pago.fecha')
|
|
||||||
->findMany();
|
|
||||||
foreach ($creditos as $credito) {
|
|
||||||
yield $credito;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$informe = new Informador('Créditos Pendientes');
|
|
||||||
|
|
||||||
$columnas = ['Proyecto', 'Departamento', 'Valor', 'Fecha Escritura', 'Estado'];
|
|
||||||
$informe->addColumns($columnas);
|
|
||||||
|
|
||||||
$row = 0;
|
|
||||||
foreach (creditos() as $credito) {
|
|
||||||
$informe->addData($row, $credito->venta()->proyecto()->descripcion, 'Proyecto');
|
|
||||||
$informe->addData($row, $credito->venta()->unidad()->descripcion, 'Departamento');
|
|
||||||
$informe->addData($row, $credito->pago()->valor('ufs'), 'Valor');
|
|
||||||
$informe->addData($row, (($credito->venta()->escriturado) ? $credito->venta()->escriturado : $credito->pago()->estado()->fecha), 'Fecha Escritura');
|
|
||||||
$informe->addData($row, ucwords($credito->pago()->estado()->tipo()->descripcion), 'Estado');
|
|
||||||
|
|
||||||
$row ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$date = [
|
|
||||||
'numberFormat' => ['short-date']
|
|
||||||
];
|
|
||||||
$ufs = [
|
|
||||||
'numberFormat' => ['thousands']
|
|
||||||
];
|
|
||||||
$formats = ['Valor' => $ufs, 'Fecha Escritura' => $date];
|
|
||||||
$informe->addFormats($formats);
|
|
||||||
|
|
||||||
return $informe->informe();
|
|
||||||
}
|
|
||||||
public static function ventas()
|
|
||||||
{
|
|
||||||
if (get('proyecto')) {
|
|
||||||
$id = get('proyecto');
|
|
||||||
$proyecto = model(Proyecto::class)->findOne($id);
|
|
||||||
$ventas = $proyecto->ventas();
|
|
||||||
|
|
||||||
usort($ventas, function($a, $b) {
|
|
||||||
return $a->fecha()->timestamp - $b->fecha()->timestamp;
|
|
||||||
});
|
|
||||||
|
|
||||||
$procasa = model(Agente::class)->findOne(1);
|
|
||||||
$pa = model(ProyectoAgente::class)->where('agente', $procasa->id)->where('proyecto', $proyecto->id)->findOne();
|
|
||||||
if ($pa) {
|
|
||||||
$comision = $pa->comision / 100;
|
|
||||||
} else {
|
|
||||||
$comision = 0.03;
|
|
||||||
}
|
|
||||||
|
|
||||||
#$informe = new Informador('Ventas - ' . $proyecto->descripcion);
|
|
||||||
$name = 'Ventas';
|
|
||||||
$hoy = Carbon::now(config('app.timezone'));
|
|
||||||
$filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls');
|
|
||||||
$informe = new PHPExcel($name, $filename);
|
|
||||||
|
|
||||||
$columnas = [
|
|
||||||
'Propietario',
|
|
||||||
['name' => 'Departamento', 'style' => 'number'],
|
|
||||||
['name' => 'Estacionamientos', 'style' => 'number'],
|
|
||||||
['name' => 'Bodegas', 'style' => 'number'],
|
|
||||||
'Fecha Venta',
|
|
||||||
['name' => 'Mes', 'style' => 'mes'],
|
|
||||||
'Tipo',
|
|
||||||
['name' => 'm² Ponderados', 'style' => 'amount'],
|
|
||||||
['name' => 'Valor Promesa', 'style' => 'amount'],
|
|
||||||
['name' => 'Bono Pie', 'style' => 'amount'],
|
|
||||||
'Operador',
|
|
||||||
['name' => 'Valor Operador', 'style' => 'amount'],
|
|
||||||
['name' => 'Premios', 'style' => 'amount'],
|
|
||||||
['name' => 'Subsidio', 'style' => 'amount'],
|
|
||||||
['name' => 'Ahorro', 'style' => 'amount'],
|
|
||||||
['name' => 'Credito', 'style' => 'amount'],
|
|
||||||
'Banco',
|
|
||||||
['name' => 'Valor Ests & Bods', 'style' => 'amount'],
|
|
||||||
['name' => 'Valor Neto', 'style' => 'amount'],
|
|
||||||
['name' => 'UF/m²*', 'style' => 'amount'],
|
|
||||||
['name' => 'Comision', 'style' => 'amount'],
|
|
||||||
['name' => 'Venta s/Comision', 'style' => 'amount']
|
|
||||||
];
|
|
||||||
$informe->addColumns($columnas);
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
foreach ($ventas as $venta) {
|
|
||||||
$info = [];
|
|
||||||
$info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto());
|
|
||||||
$info['Departamento'] = $venta->unidad()->descripcion;
|
|
||||||
$ests = [];
|
|
||||||
if ($venta->propiedad()->estacionamientos != '') {
|
|
||||||
$es = $venta->propiedad()->estacionamientos();
|
|
||||||
foreach ($es as $e) {
|
|
||||||
$ests []= $e->descripcion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info['Estacionamientos'] = implode(', ', $ests);
|
|
||||||
$bods = [];
|
|
||||||
if ($venta->propiedad()->bodegas != '') {
|
|
||||||
$bs = $venta->propiedad()->bodegas();
|
|
||||||
foreach ($bs as $b) {
|
|
||||||
$bods []= $b->descripcion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info['Bodegas'] = implode(', ', $bods);
|
|
||||||
$info['Fecha Venta'] = $venta->fecha()->format('d.m.Y');
|
|
||||||
$info['Mes'] = $venta->fecha()->format('M-y');
|
|
||||||
$info['Tipo'] = $venta->unidad()->abreviacion;
|
|
||||||
$info['m² Ponderados'] = $venta->unidad()->m2('vendible');
|
|
||||||
$info['Valor Promesa'] = $venta->valor_uf;
|
|
||||||
$info['Bono Pie'] = ($venta->bono_pie == 0 or $venta->bonoPie() === false) ? '' : $venta->bonoPie()->pago()->valor('ufs');
|
|
||||||
$info['Operador'] = ($venta->agente and $venta->agente()->agente()->tipo == 19) ? $venta->agente()->agente()->descripcion : '';
|
|
||||||
$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['Subsidio'] = 0;
|
|
||||||
$info['Ahorro'] = 0;
|
|
||||||
if ($venta->subsidio != 0) {
|
|
||||||
$info['Subsidio'] = $venta->subsidio()->subsidio()->valor('ufs');
|
|
||||||
$info['Ahorro'] = $venta->subsidio()->pago()->valor('ufs');
|
|
||||||
}
|
|
||||||
$info['Credito'] = 0;
|
|
||||||
$info['Banco'] = '';
|
|
||||||
if ($venta->credito != 0) {
|
|
||||||
$info['Credito'] = $venta->credito()->pago()->valor('ufs');
|
|
||||||
if ($venta->credito()->pago()->banco != 0) {
|
|
||||||
$info['Banco'] = $venta->credito()->pago()->banco()->nombre;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info['Valor Ests & Bods'] = $venta->valorEstacionamientosYBodegas();
|
|
||||||
$info['Valor Neto'] = $venta->valorFinal();
|
|
||||||
$info['UF/m²*'] = $venta->uf_m2();
|
|
||||||
$info['Comision'] = $venta->valorFinal() * $comision;
|
|
||||||
$info['Venta s/Comision'] = $venta->valorFinal() - $info['Comision'];
|
|
||||||
|
|
||||||
$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();
|
|
||||||
} else {
|
|
||||||
$proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many();
|
|
||||||
return view('informes.ventas', compact('proyectos'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static function resumen_contabilidad()
|
|
||||||
{
|
|
||||||
if (get('proyecto')) {
|
|
||||||
$id = get('proyecto');
|
|
||||||
$proyecto = model(Proyecto::class)->findOne($id);
|
|
||||||
$ventas = $proyecto->ventas();
|
|
||||||
|
|
||||||
usort($ventas, function($a, $b) {
|
|
||||||
return $a->fecha()->timestamp - $b->fecha()->timestamp;
|
|
||||||
});
|
|
||||||
|
|
||||||
$name = 'Ventas';
|
|
||||||
$hoy = Carbon::now(config('app.timezone'));
|
|
||||||
$filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls');
|
|
||||||
$informe = new PHPExcel($name, $filename);
|
|
||||||
|
|
||||||
$columnas = [
|
|
||||||
'Propietario',
|
|
||||||
['name' => 'Departamento', 'style' => 'general_number'],
|
|
||||||
['name' => 'Estacionamientos', 'style' => 'number'],
|
|
||||||
['name' => 'Bodegas', 'style' => 'number'],
|
|
||||||
'Fecha Venta',
|
|
||||||
['name' => 'Mes', 'style' => 'mes'],
|
|
||||||
'Tipo',
|
|
||||||
['name' => 'm² Ponderados', 'style' => 'amount'],
|
|
||||||
['name' => 'Valor Promesa', 'style' => 'amount'],
|
|
||||||
['name' => 'Pie [UF]', 'style' => 'amount'],
|
|
||||||
['name' => 'Pie [$]', 'style' => 'amount'],
|
|
||||||
['name' => 'Abono Escritura', 'style' => 'amount'],
|
|
||||||
['name' => 'Crédito', 'style' => 'amount'],
|
|
||||||
['name' => 'Cuotas', 'style' => 'number'],
|
|
||||||
['name' => 'Cuotas Pagadas', 'style' => 'number'],
|
|
||||||
['name' => 'Pie Pagado [UF]', 'style' => 'amount'],
|
|
||||||
['name' => 'Pie Pagado [$]', 'style' => 'amount']
|
|
||||||
];
|
|
||||||
$informe->addColumns($columnas);
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
foreach ($ventas as $venta) {
|
|
||||||
$info = [];
|
|
||||||
$info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto());
|
|
||||||
$info['Departamento'] = $venta->unidad()->descripcion;
|
|
||||||
$ests = [];
|
|
||||||
if ($venta->propiedad()->estacionamientos != '') {
|
|
||||||
$es = $venta->propiedad()->estacionamientos();
|
|
||||||
foreach ($es as $e) {
|
|
||||||
$ests []= $e->descripcion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info['Estacionamientos'] = implode(', ', $ests);
|
|
||||||
$bods = [];
|
|
||||||
if ($venta->propiedad()->bodegas != '') {
|
|
||||||
$bs = $venta->propiedad()->bodegas();
|
|
||||||
foreach ($bs as $b) {
|
|
||||||
$bods []= $b->descripcion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info['Bodegas'] = implode(', ', $bods);
|
|
||||||
$info['Fecha Venta'] = $venta->fecha()->format('d.m.Y');
|
|
||||||
$info['Mes'] = $venta->fecha()->format('M-y');
|
|
||||||
$info['Tipo'] = $venta->unidad()->abreviacion;
|
|
||||||
$info['m² Ponderados'] = $venta->unidad()->m2('vendible');
|
|
||||||
$info['Valor Promesa'] = $venta->valor_uf;
|
|
||||||
$info['Pie [UF]'] = 0;
|
|
||||||
$info['Pie [$]'] = 0;
|
|
||||||
if ($venta->pie()) {
|
|
||||||
$info['Pie [UF]'] = $venta->pie()->valor;
|
|
||||||
$info['Pie [$]'] = $venta->pie()->valorPesos();
|
|
||||||
}
|
|
||||||
$info['Abono Escritura'] = ($venta->escritura != 0) ? $venta->escritura()->valor('ufs') : ($venta->valor_uf - $venta->pie()->valor - (($venta->credito != 0) ? $venta->credito()->pago()->valor('ufs') : 0));
|
|
||||||
$info['Crédito'] = ($venta->credito != 0) ? $venta->credito()->pago()->valor('ufs') : 0;
|
|
||||||
|
|
||||||
$info['Cuotas'] = $venta->pie()->cuotas;
|
|
||||||
$info['Cuotas Pagadas'] = count($venta->pie()->pagadas());
|
|
||||||
$info['Pie Pagado [UF]'] = $venta->pie()->valorPagado('uf');
|
|
||||||
$info['Pie Pagado [$]'] = $venta->pie()->valorPagado('pesos');
|
|
||||||
|
|
||||||
$data []= $info;
|
|
||||||
}
|
|
||||||
$informe->addData($data);
|
|
||||||
|
|
||||||
$totals = [
|
|
||||||
'Departamento' => 'count',
|
|
||||||
'Estacionamientos' => 'count',
|
|
||||||
'Bodegas' => 'count',
|
|
||||||
'm² Ponderados' => 'sum',
|
|
||||||
'Valor Promesa' => 'sum',
|
|
||||||
'Pie' => 'sum',
|
|
||||||
'Pie Pagado' => 'sum'
|
|
||||||
];
|
|
||||||
$informe->addTotals($totals);
|
|
||||||
|
|
||||||
return $informe->informe();
|
|
||||||
} else {
|
|
||||||
$proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many();
|
|
||||||
return view('informes.resumen_contabilidad', compact('proyectos'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static function contabilidad()
|
|
||||||
{
|
|
||||||
if (get('proyecto')) {
|
|
||||||
$id = get('proyecto');
|
|
||||||
$fecha = get('fecha');
|
|
||||||
$mes = null;
|
|
||||||
if ($fecha != null) {
|
|
||||||
$mes = Carbon::parse($fecha);
|
|
||||||
}
|
|
||||||
$proyecto = model(Proyecto::class)->findOne($id);
|
|
||||||
$q = "SELECT pago.*, venta.id AS vid, venta.tipo AS ctipo, venta.pie AS pie
|
|
||||||
FROM (
|
|
||||||
SELECT pago.id, banco.nombre AS banco, pago.fecha, pago.valor, pago.uf, ep.estado, ep.fecha AS efecha
|
|
||||||
FROM pago JOIN banco ON banco.id = pago.banco JOIN ((
|
|
||||||
SELECT pago, MAX(id) AS id FROM estado_pago GROUP BY pago) e0 JOIN estado_pago ep ON ep.id = e0.id) ON ep.pago = pago.id
|
|
||||||
WHERE ep.estado > 0 ";
|
|
||||||
if ($mes != null) {
|
|
||||||
$q .= "AND (pago.fecha BETWEEN '" . $mes->format('Y-m-01') . "' AND '" . $mes->format('Y-m-t') . "'
|
|
||||||
OR ep.fecha BETWEEN '" . $mes->format('Y-m-01') . "' AND '" . $mes->format('Y-m-t') . "')";
|
|
||||||
}
|
|
||||||
$q .= ") pago JOIN (SELECT venta.*
|
|
||||||
FROM ((
|
|
||||||
SELECT venta.id, venta.pie, venta.propiedad, credito.pago, 'credito' AS tipo
|
|
||||||
FROM venta JOIN credito ON credito.id = venta.credito)
|
|
||||||
UNION ALL (
|
|
||||||
SELECT venta.id, venta.pie, venta.propiedad, escritura.pago, 'escritura' AS tipo
|
|
||||||
FROM venta JOIN escritura ON escritura.id = venta.escritura)
|
|
||||||
UNION ALL (
|
|
||||||
SELECT venta.id, venta.pie, venta.propiedad, cuota.pago, 'cuota' AS tipo
|
|
||||||
FROM venta JOIN cuota ON cuota.pie = venta.pie)) venta
|
|
||||||
JOIN propiedad ON propiedad.id = venta.propiedad
|
|
||||||
JOIN unidad ON unidad.id = propiedad.unidad_principal
|
|
||||||
WHERE unidad.proyecto = ?) venta
|
|
||||||
ON venta.pago = pago.id";
|
|
||||||
$st = \ORM::getDB()->prepare($q);
|
|
||||||
$st->execute([$id]);
|
|
||||||
if ($st->rowCount() > 0) {
|
|
||||||
$R = $st->fetchAll(\PDO::FETCH_OBJ);
|
|
||||||
|
|
||||||
#$informe = new Informador('Contabilidad - ' . (($mes != null) ? $mes->format('Y-m') . ' - ' : '') . $proyecto->descripcion);
|
|
||||||
$name = 'Contabilidad';
|
|
||||||
$hoy = Carbon::now(config('app.timezone'));
|
|
||||||
$filename = str_replace('ñ', 'n', 'Contabilidad - ' . (($mes != null) ? $mes->format('Y-m') . ' - ' : '') . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls');
|
|
||||||
|
|
||||||
$informe = new PHPExcel($name, $filename);
|
|
||||||
|
|
||||||
$columnas = ['Proyecto', 'Fecha', 'Banco', 'Departamento', 'RUT', 'Propietario', 'Glosa', 'Glosa2', (object) ['name' => 'Valor', 'style' => 'integer'], (object) ['name' => 'Valor UF', 'style' => 'currency']];
|
|
||||||
$informe->addColumns($columnas);
|
|
||||||
$data = [];
|
|
||||||
foreach ($R as $r) {
|
|
||||||
$info = [];
|
|
||||||
$info['Proyecto'] = $proyecto->descripcion;
|
|
||||||
$f1 = \Carbon\Carbon::parse($r->fecha, config('app.timezone'));
|
|
||||||
$f2 = \Carbon\Carbon::parse($r->efecha, config('app.timezone'));
|
|
||||||
$info['Fecha'] = ($f1->max($f2))->format('Y-m-d');
|
|
||||||
$info['Banco'] = $r->banco;
|
|
||||||
$venta = model(Venta::class)->findOne($r->vid);
|
|
||||||
$info['Departamento'] = $venta->unidad()->descripcion;
|
|
||||||
$info['RUT'] = $venta->propietario()->rut();
|
|
||||||
$info['Propietario'] = $venta->propietario()->nombreCompleto();
|
|
||||||
$info['Glosa'] = ucwords($r->ctipo);
|
|
||||||
$info['Glosa2'] = '';
|
|
||||||
if ($r->ctipo == 'cuota') {
|
|
||||||
$cuota = model(Cuota::class)->where('pago', $r->id)->findOne();
|
|
||||||
|
|
||||||
$info['Glosa'] = 'Pie - ' . format('ufs', $cuota->pie()->valor('ufs'), null, true);
|
|
||||||
|
|
||||||
$info['Glosa2'] = $cuota->numero() . ' - ' . $cuota->pie()->cuotas;
|
|
||||||
}
|
|
||||||
$info['Valor'] = $r->valor;
|
|
||||||
$info['Valor UF'] = '0';
|
|
||||||
if ($r->uf > 0) {
|
|
||||||
$info['Valor UF'] = $r->valor / $r->uf;
|
|
||||||
}
|
|
||||||
$data []= $info;
|
|
||||||
}
|
|
||||||
|
|
||||||
$informe->addData($data);
|
|
||||||
|
|
||||||
return $informe->informe();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setlocale(LC_TIME, 'es');
|
|
||||||
$proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many();
|
|
||||||
return view('informes.contabilidad', compact('proyectos'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static function para_comision()
|
|
||||||
{
|
|
||||||
$proyectos = model(Proyecto::class)->orderByAsc('descripcion')->findMany();
|
|
||||||
return view('informes.para_comision', compact('proyectos'));
|
|
||||||
}
|
|
||||||
public static function comisiones()
|
|
||||||
{
|
|
||||||
$id = post('proyecto');
|
|
||||||
$proyecto = model(Proyecto::class)->findOne($id);
|
|
||||||
$unidades = explode('-', str_replace([';', '.', ':', ' ', PHP_EOL, '|', '+', ','], '-', post('unidades')));
|
|
||||||
$ventas = model(Venta::class)
|
|
||||||
->select('venta.*')
|
|
||||||
->join('propiedad', ['propiedad.id', '=', 'venta.propiedad'])
|
|
||||||
->join('unidad', ['unidad.id', '=', 'propiedad.unidad_principal'])
|
|
||||||
->where('unidad.proyecto', $proyecto->id)
|
|
||||||
->where('venta.estado', 1)
|
|
||||||
->whereIn('unidad.descripcion', $unidades)
|
|
||||||
->orderByExpr('FIELD(unidad.descripcion, ' . implode(', ', $unidades) . ')')
|
|
||||||
->findMany();
|
|
||||||
$ids = [];
|
|
||||||
$totales = (object) ['precio' => 0, 'neto' => 0, 'comision' => 0];
|
|
||||||
foreach ($ventas as $venta) {
|
|
||||||
$ids []= $venta->id;
|
|
||||||
$totales->precio += $venta->valor_uf;
|
|
||||||
$totales->neto += $venta->valorCorredora();
|
|
||||||
$totales->comision += $venta->valorCorredora() * 1.5 / 100;
|
|
||||||
}
|
|
||||||
return view('informes.comisiones', compact('ventas', 'proyecto', 'totales', 'ids'));
|
|
||||||
}
|
|
||||||
public static function comisiones_xlsx()
|
|
||||||
{
|
|
||||||
$id_ventas = explode(',', get('ventas'));
|
|
||||||
$ventas = model(Venta::class)
|
|
||||||
->whereIn('id', $id_ventas)
|
|
||||||
->orderByExpr('FIELD(id, ' . implode(', ', $id_ventas) . ')')
|
|
||||||
->findMany();
|
|
||||||
|
|
||||||
$informe = new Informador('Comisiones - ' . $ventas[0]->proyecto()->descripcion);
|
|
||||||
$columnas = ['Departamento', 'Estacionamientos', 'Bodegas', 'Propietario', 'Precio', '% Com', 'Com UF'];
|
|
||||||
$informe->addColumns($columnas);
|
|
||||||
$data = [];
|
|
||||||
foreach ($ventas as $venta) {
|
|
||||||
$info = [];
|
|
||||||
$info['Departamento'] = $venta->unidad()->descripcion;
|
|
||||||
$info['Estacionamientos'] = implode(' - ', $venta->propiedad()->estacionamientos('array'));
|
|
||||||
$info['Bodegas'] = implode(' - ', $venta->propiedad()->bodegas('array'));
|
|
||||||
$info['Propietario'] = $venta->propietario()->nombreCompleto();
|
|
||||||
$info['Precio'] = "'" . format('ufs', $venta->valorCorredora());
|
|
||||||
$info['% Com'] = '1,5 %';
|
|
||||||
$info['Com UF'] = "'" . format('ufs', $venta->valorCorredora() * 1.5 / 100);
|
|
||||||
$data []= $info;
|
|
||||||
}
|
|
||||||
|
|
||||||
$informe->addDatas($data);
|
|
||||||
|
|
||||||
return $informe->informe();
|
|
||||||
}
|
|
||||||
public static function cuotas()
|
|
||||||
{
|
|
||||||
$id_venta = get('venta');
|
|
||||||
$venta = model(Venta::class)->findOne($id_venta);
|
|
||||||
|
|
||||||
$name = 'Cuotas - ' . $venta->unidad()->descripcion;
|
|
||||||
$hoy = Carbon::now(config('app.timezone'));
|
|
||||||
$filename = str_replace('ñ', 'n', $name . ' - ' . $venta->proyecto()->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls');
|
|
||||||
$informe = new PHPExcel($name, $filename);
|
|
||||||
$columnas = [
|
|
||||||
['name' => 'Cuota', 'style' => 'number'],
|
|
||||||
['name' => 'Fecha Cuota', 'style' => 'date'],
|
|
||||||
'Banco',
|
|
||||||
'Identificador',
|
|
||||||
['name' => 'Valor $', 'style' => 'number'],
|
|
||||||
['name' => 'Valor UF', 'style' => 'currency'],
|
|
||||||
['name' => 'Fecha Pago', 'style' => 'date']
|
|
||||||
];
|
|
||||||
$informe->addColumns($columnas);
|
|
||||||
$data = [];
|
|
||||||
foreach ($venta->pie()->cuotas() as $cuota) {
|
|
||||||
$info = [];
|
|
||||||
$info['Cuota'] = $cuota->numero();
|
|
||||||
$info['Fecha Cuota'] = $cuota->pago()->fecha()->format('Y-m-d');
|
|
||||||
$info['Banco'] = $cuota->pago()->banco()->descripcion;
|
|
||||||
$info['Identificador'] = $cuota->pago()->identificador;
|
|
||||||
$info['Valor $'] = $cuota->pago()->valor();
|
|
||||||
$info['Valor UF'] = $cuota->pago()->valor('ufs');
|
|
||||||
$info['Fecha Pago'] = $cuota->pago()->estado()->fecha()->format('Y-m-d');
|
|
||||||
$data []= $info;
|
|
||||||
}
|
|
||||||
$informe->addData($data);
|
|
||||||
|
|
||||||
return $informe->informe();
|
|
||||||
}
|
|
||||||
public static function resciliaciones()
|
|
||||||
{
|
|
||||||
if (get('proyecto')) {
|
|
||||||
$id = get('proyecto');
|
|
||||||
$proyecto = model(Proyecto::class)->findOne($id);
|
|
||||||
$ventas = $proyecto->resciliaciones();
|
|
||||||
|
|
||||||
usort($ventas, function($a, $b) {
|
|
||||||
return $a->fecha()->timestamp - $b->fecha()->timestamp;
|
|
||||||
});
|
|
||||||
|
|
||||||
$name = 'Resciliaciones';
|
|
||||||
$hoy = Carbon::now(config('app.timezone'));
|
|
||||||
$filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls');
|
|
||||||
$informe = new PHPExcel($name, $filename);
|
|
||||||
|
|
||||||
$columnas = [
|
|
||||||
'Propietario',
|
|
||||||
['name' => 'Departamento', 'style' => 'number'],
|
|
||||||
['name' => 'Estacionamientos', 'style' => 'number'],
|
|
||||||
['name' => 'Bodegas', 'style' => 'number'],
|
|
||||||
'Fecha Venta',
|
|
||||||
'Fecha Resciliación',
|
|
||||||
['name' => 'Mes', 'style' => 'mes'],
|
|
||||||
'Tipo',
|
|
||||||
['name' => 'm² Ponderados', 'style' => 'amount'],
|
|
||||||
['name' => 'Valor Promesa', 'style' => 'amount'],
|
|
||||||
];
|
|
||||||
$informe->addColumns($columnas);
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
foreach ($ventas as $venta) {
|
|
||||||
$info = [];
|
|
||||||
$info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto());
|
|
||||||
$info['Departamento'] = $venta->unidad()->descripcion;
|
|
||||||
$ests = [];
|
|
||||||
if ($venta->propiedad()->estacionamientos != '') {
|
|
||||||
$es = $venta->propiedad()->estacionamientos();
|
|
||||||
foreach ($es as $e) {
|
|
||||||
$ests []= $e->descripcion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info['Estacionamientos'] = implode(', ', $ests);
|
|
||||||
$bods = [];
|
|
||||||
if ($venta->propiedad()->bodegas != '') {
|
|
||||||
$bs = $venta->propiedad()->bodegas();
|
|
||||||
foreach ($bs as $b) {
|
|
||||||
$bods []= $b->descripcion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info['Bodegas'] = implode(', ', $bods);
|
|
||||||
$info['Fecha Venta'] = $venta->fecha()->format('d.m.Y');
|
|
||||||
$info['Fecha Resciliación'] = $venta->estado()->fecha()->format('d.m.Y');
|
|
||||||
$info['Mes'] = $venta->estado()->fecha()->format('M-y');
|
|
||||||
$info['Tipo'] = $venta->unidad()->abreviacion;
|
|
||||||
$info['m² Ponderados'] = $venta->unidad()->m2('vendible');
|
|
||||||
$info['Valor Promesa'] = $venta->valor_uf;
|
|
||||||
|
|
||||||
$data []= $info;
|
|
||||||
}
|
|
||||||
$informe->addData($data);
|
|
||||||
|
|
||||||
$totals = [
|
|
||||||
'Departamento' => 'count',
|
|
||||||
'Estacionamientos' => 'count',
|
|
||||||
'Bodegas' => 'count',
|
|
||||||
'm² Ponderados' => 'sum',
|
|
||||||
'Valor Promesa' => 'sum'
|
|
||||||
];
|
|
||||||
$informe->addTotals($totals);
|
|
||||||
|
|
||||||
return $informe->informe();
|
|
||||||
} else {
|
|
||||||
$proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many();
|
|
||||||
return view('informes.resciliaciones', compact('proyectos'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -120,19 +120,21 @@ class Ventas
|
|||||||
}
|
}
|
||||||
public static function agregar()
|
public static function agregar()
|
||||||
{
|
{
|
||||||
|
error_log(var_export(post(), true));
|
||||||
$f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone'));
|
$f = Carbon::createFromDate(post('year'), post('month'), post('day'), config('app.timezone'));
|
||||||
$t = Carbon::today(config('app.timezone'));
|
$t = Carbon::today(config('app.timezone'));
|
||||||
$uf = uf($f);
|
$uf = uf($f);
|
||||||
|
error_log(var_export($uf, true));
|
||||||
|
|
||||||
$calle = trim(post('calle'));
|
$calle = trim(post('calle'));
|
||||||
$numero = post('numero');
|
$numero = post('numero');
|
||||||
$extra = trim(post('extra'));
|
$extra = trim(post('extra'));
|
||||||
$comuna = post('comuna');
|
$comuna = post('comuna');
|
||||||
$direccion = model(Direccion::class)
|
$direccion = model(Direccion::class)
|
||||||
->where('calle', $calle)
|
->where('calle', $calle)
|
||||||
->where('numero', $numero)
|
->where('numero', $numero)
|
||||||
->where('extra', $extra)
|
->where('extra', $extra)
|
||||||
->where('comuna', $comuna)
|
->where('comuna', $comuna)
|
||||||
->findOne();
|
->findOne();
|
||||||
if (!$direccion) {
|
if (!$direccion) {
|
||||||
$direccion = model(Direccion::class)->create();
|
$direccion = model(Direccion::class)->create();
|
||||||
@ -192,7 +194,9 @@ class Ventas
|
|||||||
$pie->valor = post('pie');
|
$pie->valor = post('pie');
|
||||||
$pie->fecha = $f->format('Y-m-d');
|
$pie->fecha = $f->format('Y-m-d');
|
||||||
$pie->cuotas = post('cuotas');
|
$pie->cuotas = post('cuotas');
|
||||||
$pie->uf = $uf->uf->value;
|
if ($uf->total > 0) {
|
||||||
|
$pie->uf = $uf->uf->value;
|
||||||
|
}
|
||||||
$pie->save();
|
$pie->save();
|
||||||
|
|
||||||
$venta->pie = $pie->id;
|
$venta->pie = $pie->id;
|
||||||
@ -203,7 +207,9 @@ class Ventas
|
|||||||
|
|
||||||
$pago = model(Pago::class)->create();
|
$pago = model(Pago::class)->create();
|
||||||
$pago->fecha = $f->format('Y-m-d');
|
$pago->fecha = $f->format('Y-m-d');
|
||||||
$pago->uf = $uf->uf->value;
|
if ($uf->total > 0) {
|
||||||
|
$pago->uf = $uf->uf->value;
|
||||||
|
}
|
||||||
$pago->valor = $bono->valor * $uf->uf->value;
|
$pago->valor = $bono->valor * $uf->uf->value;
|
||||||
$pago->tipo = 8;
|
$pago->tipo = 8;
|
||||||
$pago->new();
|
$pago->new();
|
||||||
@ -216,7 +222,9 @@ class Ventas
|
|||||||
if (post('credito')) {
|
if (post('credito')) {
|
||||||
$pago = model(Pago::class)->create();
|
$pago = model(Pago::class)->create();
|
||||||
$pago->fecha = $f->format('Y-m-d');
|
$pago->fecha = $f->format('Y-m-d');
|
||||||
$pago->uf = $uf->uf->value;
|
if ($uf->total > 0) {
|
||||||
|
$pago->uf = $uf->uf->value;
|
||||||
|
}
|
||||||
$pago->valor = post('credito') * $uf->uf->value;
|
$pago->valor = post('credito') * $uf->uf->value;
|
||||||
$pago->tipo = 2;
|
$pago->tipo = 2;
|
||||||
$pago->new();
|
$pago->new();
|
||||||
@ -229,12 +237,14 @@ class Ventas
|
|||||||
}
|
}
|
||||||
|
|
||||||
$venta->fecha = $f->format('Y-m-d');
|
$venta->fecha = $f->format('Y-m-d');
|
||||||
$venta->valor_uf = post('valor');
|
$venta->valor_uf = str_replace(',', '.', post('valor'));
|
||||||
$venta->fecha_ingreso = $t->format('Y-m-d');
|
$venta->fecha_ingreso = $t->format('Y-m-d');
|
||||||
if (post('operador') != 0) {
|
if (post('operador') != 0) {
|
||||||
$venta->agente = post('operador');
|
$venta->agente = post('operador');
|
||||||
}
|
}
|
||||||
$venta->uf = $uf->uf->value;
|
if ($uf->total > 0) {
|
||||||
|
$venta->uf = $uf->uf->value;
|
||||||
|
}
|
||||||
$venta->new();
|
$venta->new();
|
||||||
|
|
||||||
if (post('promociones') != 0) {
|
if (post('promociones') != 0) {
|
||||||
|
@ -55,6 +55,9 @@ function uf($date, $async = false) {
|
|||||||
return (object) ['total' => 0];
|
return (object) ['total' => 0];
|
||||||
}
|
}
|
||||||
function format($tipo, $valor, $format = null, $print = false) {
|
function format($tipo, $valor, $format = null, $print = false) {
|
||||||
|
if ($valor === null) {
|
||||||
|
$valor = 0;
|
||||||
|
}
|
||||||
if (strtolower($tipo) == 'localdate') {
|
if (strtolower($tipo) == 'localdate') {
|
||||||
$d = \Carbon\Carbon::parse($valor);
|
$d = \Carbon\Carbon::parse($valor);
|
||||||
$d->locale('es_ES');
|
$d->locale('es_ES');
|
||||||
|
@ -6,6 +6,7 @@ verify_ssl = true
|
|||||||
[dev-packages]
|
[dev-packages]
|
||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
|
gunicorn = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.8"
|
python_version = "3.8"
|
||||||
|
@ -11,24 +11,25 @@
|
|||||||
"aldarien/session" : "*",
|
"aldarien/session" : "*",
|
||||||
"aldarien/url": "*",
|
"aldarien/url": "*",
|
||||||
"j4mie/paris" : "^1.5",
|
"j4mie/paris" : "^1.5",
|
||||||
"danielstjules/stringy" : "^3.1",
|
"voku/stringy" : "^6",
|
||||||
"phpoffice/phpspreadsheet": "^1",
|
"phpoffice/phpspreadsheet": "^1",
|
||||||
"nesbot/carbon": "^2",
|
"nesbot/carbon": "^2",
|
||||||
"phpoffice/phpword": "^0",
|
"phpoffice/phpword": "^0",
|
||||||
"slam/php-excel": "^4.4",
|
"slam/php-excel": "^4.4",
|
||||||
"fabpot/goutte": "^3.2",
|
"fabpot/goutte": "^3.2",
|
||||||
"incoviba/modelos": "*",
|
"incoviba/modelos": "*",
|
||||||
"slim/slim": "4.x-dev",
|
"slim/slim": "^4",
|
||||||
"php-di/slim-bridge": "dev-master",
|
"php-di/slim-bridge": "*",
|
||||||
"rubellum/slim-blade-view": "dev-master",
|
"rubellum/slim-blade-view": "*",
|
||||||
"nyholm/psr7": "1.4.x-dev",
|
"nyholm/psr7": "*",
|
||||||
"nyholm/psr7-server": "dev-master",
|
"nyholm/psr7-server": "*",
|
||||||
"vlucas/phpdotenv": "^5.3"
|
"vlucas/phpdotenv": "^5.3",
|
||||||
|
"monolog/monolog": "^3"
|
||||||
},
|
},
|
||||||
"require-dev" : {
|
"require-dev" : {
|
||||||
"phpunit/phpunit" : "^8",
|
"phpunit/phpunit" : "*",
|
||||||
"kint-php/kint" : "^2.1",
|
"kint-php/kint" : "*",
|
||||||
"filp/whoops" : "^2.1"
|
"filp/whoops" : "*"
|
||||||
},
|
},
|
||||||
"license" : "GNU AGPLv3",
|
"license" : "GNU AGPLv3",
|
||||||
"authors" : [{
|
"authors" : [{
|
||||||
@ -59,5 +60,8 @@
|
|||||||
"type": "path",
|
"type": "path",
|
||||||
"url": "./incoviba/modelos"
|
"url": "./incoviba/modelos"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"config": {
|
||||||
|
"sort-packages": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
|
x-restart: &restart
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
profiles:
|
profiles:
|
||||||
- app
|
- app
|
||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
container_name: web
|
container_name: incoviba_web
|
||||||
|
<<: *restart
|
||||||
ports:
|
ports:
|
||||||
- "8080:80"
|
- "8080:80"
|
||||||
volumes:
|
volumes:
|
||||||
@ -16,19 +20,22 @@ services:
|
|||||||
profiles:
|
profiles:
|
||||||
- app
|
- app
|
||||||
build: .
|
build: .
|
||||||
container_name: php
|
container_name: incoviba_php
|
||||||
|
<<: *restart
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
- .db.env
|
- .db.env
|
||||||
volumes:
|
volumes:
|
||||||
- .:/code
|
- .:/code
|
||||||
|
- ./php-errors.ini:/usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||||
|
- ./logs:/logs
|
||||||
|
|
||||||
db:
|
db:
|
||||||
profiles:
|
profiles:
|
||||||
- db
|
- db
|
||||||
container_name: db
|
|
||||||
image: mariadb:latest
|
image: mariadb:latest
|
||||||
restart: unless-stopped
|
container_name: incoviba_db
|
||||||
|
<<: *restart
|
||||||
env_file: .db.env
|
env_file: .db.env
|
||||||
volumes:
|
volumes:
|
||||||
- dbdata:/var/lib/mysql
|
- dbdata:/var/lib/mysql
|
||||||
@ -36,12 +43,21 @@ services:
|
|||||||
adminer:
|
adminer:
|
||||||
profiles:
|
profiles:
|
||||||
- db
|
- db
|
||||||
container_name: adminer
|
|
||||||
image: adminer:latest
|
image: adminer:latest
|
||||||
restart: unless-stopped
|
container_name: incoviba_adminer
|
||||||
|
<<: *restart
|
||||||
ports:
|
ports:
|
||||||
- "8083:8080"
|
- "8083:8080"
|
||||||
env_file: .adminer.env
|
env_file: .adminer.env
|
||||||
|
|
||||||
|
python:
|
||||||
|
profiles:
|
||||||
|
- python
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Python.Dockerfile
|
||||||
|
container_name: incoviba_python
|
||||||
|
<<: *restart
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
dbdata:
|
dbdata:
|
||||||
|
Reference in New Issue
Block a user