19 Commits

Author SHA1 Message Date
907c756aa2 FIX: cuotas 2023-02-13 17:18:26 -03:00
84d50e0209 Logging 2023-02-10 15:14:34 +00:00
87643a5b99 Fixes for upgrade 2023-02-10 15:14:14 +00:00
de6100a546 Upgrade to php 8 2023-02-10 15:12:30 +00:00
b6c0c90943 Merge branch 'develop' 2023-02-10 06:45:42 +00:00
726bdaec4c logs 2023-02-10 06:39:24 +00:00
009ba01e69 Releas dependencies versions 2023-02-10 06:38:43 +00:00
bb1d2b2159 Update aldarien dependencies 2023-02-10 06:38:16 +00:00
0550ff11a4 Merge branch 'develop' 2022-03-08 12:15:31 -03:00
66a128663d Merge branch 'develop' 2022-03-08 09:02:22 -03:00
a5940019bc Merge branch 'develop' 2022-03-07 23:49:52 -03:00
4971570474 Merge branch 'develop' 2022-03-07 22:21:55 -03:00
85be709ab0 Merge branch 'develop' 2022-03-07 21:45:05 -03:00
52bead5104 Merge branch 'develop' 2022-03-07 21:31:10 -03:00
66dbf54714 Merge branch 'develop' 2022-03-07 21:23:58 -03:00
d2e6a11e0b Merge branch 'develop' 2022-03-07 21:20:58 -03:00
9d13a193b6 Merge branch 'develop' 2022-03-07 18:28:27 -03:00
b0c587532f Merge branch 'develop' 2022-03-07 18:08:44 -03:00
68ab19b874 Merge branch 'develop' 2022-03-07 12:07:51 -03:00
22 changed files with 158 additions and 105 deletions

View File

@ -2,7 +2,7 @@ FROM php:8.1-fpm
RUN apt-get update && apt-get install -y libzip-dev libicu-dev git libpng-dev unzip
RUN docker-php-ext-install pdo pdo_mysql zip intl gd
RUN docker-php-ext-install pdo pdo_mysql zip intl gd bcmath
RUN pecl install xdebug-3.1.3 \
&& docker-php-ext-enable xdebug

View File

@ -7,7 +7,7 @@
"aldarien/contract" : "*"
},
"require-dev" : {
"phpunit/phpunit" : "^6.3"
"phpunit/phpunit" : "*"
},
"license" : "MIT",
"authors" : [{

View File

@ -122,7 +122,11 @@ class Config
$ini = strpos($value, '{') + 1;
$end = strpos($value, '}', $ini);
$rep = substr($value, $ini, $end - $ini);
$value = str_replace('{' . $rep . '}', $this->get($rep), $value);
$new = $this->get($rep);
if ($new === null) {
$new = '';
}
$value = str_replace('{' . $rep . '}', $new, $value);
}
}
return $value;

View File

@ -12,7 +12,7 @@
"require": {
"aldarien/contract": "*",
"aldarien/root": "*",
"symfony/yaml": "^3.3"
"symfony/yaml": "*"
},
"autoload": {
"psr-4": {

View File

@ -3,7 +3,7 @@
"description" : "Module for formatting data, mostly numbers",
"type" : "library",
"require-dev" : {
"phpunit/phpunit" : "^6",
"phpunit/phpunit" : "*",
"aldarien/config": "*"
},
"license" : "MIT",

View File

@ -3,11 +3,11 @@
"description" : "Response handler module for my apps",
"type" : "library",
"require" : {
"wixel/gump" : "^1.5",
"wixel/gump" : "^2.0",
"aldarien/contract" : "*"
},
"require-dev" : {
"phpunit/phpunit" : "^6.3"
"phpunit/phpunit" : "*"
},
"license" : "MIT",
"authors" : [{

View File

@ -7,8 +7,8 @@
],
"license": "MIT",
"require-dev" : {
"phpunit/phpunit" : "~6",
"kint-php/kint" : "~2"
"phpunit/phpunit" : "*",
"kint-php/kint" : "*"
},
"autoload" : {
"psr-4" : {

View File

@ -3,11 +3,11 @@
"description": "Session wrapper for aura/session",
"type": "library",
"require": {
"aura/session": "^2.1",
"aura/session": "*",
"aldarien/contract": "*"
},
"require-dev": {
"phpunit/phpunit": "^6.3"
"phpunit/phpunit": "*"
},
"license": "MIT",
"authors": [

View File

@ -1,8 +1,8 @@
<?php
namespace App\Service;
use League\Uri\Http;
use League\Uri\Components\Host;
use League\Uri\Uri as Http;
use League\Uri\Components\Domain as Host;
use League\Uri\Components\HierarchicalPath;
class URL
@ -19,7 +19,14 @@ class URL
protected function findRoot()
{
$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 = 'http';
if (isset($_SERVER['REQUEST_SCHEME'])) {
$scheme = $_SERVER['REQUEST_SCHEME'];
}
if (isset($_SERVER['HTTPS'])) {
$scheme = 'https';
}
$uri = Http::createFromString(\Sabre\Uri\resolve($scheme . '://' . $base, $_SERVER['SCRIPT_NAME']));
$host = new Host($uri->getHost());
if ($host->isAbsolute()) {
return $host->getRegistrableDomain();

View File

@ -5,11 +5,12 @@
"require" : {
"aldarien/contract" : "*",
"aldarien/root" : "*",
"league/uri": "^5.2",
"sabre/uri": "^2.1"
"league/uri": "*",
"league/uri-components": "*",
"sabre/uri": "*"
},
"require-dev" : {
"phpunit/phpunit" : "^6.3"
"phpunit/phpunit" : "*"
},
"license" : "MIT",
"authors" : [{

View File

@ -1,7 +1,7 @@
<?php
namespace App\Service;
use Philo\Blade\Blade;
use eftec\bladeone\BladeOne;
class View
{
@ -14,14 +14,14 @@ class View
$this->views = config('locations.views');
$this->cache = config('locations.cache');
$this->blade = new Blade($this->views, $this->cache);
$this->blade = new BladeOne($this->views, $this->cache);
}
public function show($template, $vars = null)
{
if ($vars) {
return $this->blade->view()->make($template, $vars)->render();
return $this->blade->run($template, $vars);
}
return $this->blade->view()->make($template)->render();
return $this->blade->run($template);
}
}
?>

View File

@ -3,7 +3,7 @@
"description": "View module for my apps",
"type": "library",
"require": {
"philo/laravel-blade": "^3.1",
"eftec/bladeone": "*",
"aldarien/contract": "*",
"aldarien/config": "*"
},
@ -23,6 +23,6 @@
]
},
"require-dev": {
"phpunit/phpunit": "^6.3"
"phpunit/phpunit": "*"
}
}

View File

@ -486,7 +486,10 @@ 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'] = 0;
if ($venta->pie()) {
$info['Pie'] = $venta->pie()->valor;
}
$info['Pie Pagado'] = 0;
$info['% Pie Pagado'] = 0;
if ($venta->pie()) {
@ -510,10 +513,10 @@ class Informes
}
$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;
if ($venta->credito != 0 and $venta->credito()->pago()) {
$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();
@ -525,6 +528,9 @@ class Informes
$info['Precio'] = 0;
try {
$info['Precio'] = array_reduce($venta->propiedad()->departamentos(), function($sum, $item) use ($fecha) {
if (!$item->precio($fecha)) {
return $sum;
}
return $sum + $item->precio($fecha)->valor;
});
} catch (\Exception $e) {

View File

@ -39,17 +39,16 @@ function uf($date, $async = false) {
return (object) ['total' => 0];
}
$url = 'http://' . config('locations.money') . '/api/uf/value/' . $date->format('Y-m-d');
$client = new \Goutte\Client();
$client->setHeader('Accept', 'application/json');
$client->request('GET', $url);
$client = new \GuzzleHttp\Client(['base_uri' => 'http://' . config('locations.money') . '/', 'headers' => ['Accept' => 'application/json']]);
$response = $client->get('api/uf/value/' . $date->format('Y-m-d'));
$response = $client->getResponse();
//$response = $client->getResponse();
if (!$response) {
return (object) ['total' => 0];
}
$status = $response->getStatusCode();
if ($status >= 200 and $status < 300) {
$data = json_decode($response->getContent());
$data = json_decode($response->getBody()->getContents());
return $data;
}
return (object) ['total' => 0];

View File

@ -1,7 +1,7 @@
<?php
if (config('app.debug')) {
/*if (config('app.debug')) {
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();
}
}*/
?>

View File

@ -11,24 +11,25 @@
"aldarien/session" : "*",
"aldarien/url": "*",
"j4mie/paris" : "^1.5",
"danielstjules/stringy" : "^3.1",
"voku/stringy" : "^6",
"phpoffice/phpspreadsheet": "^1",
"nesbot/carbon": "^2",
"phpoffice/phpword": "^0",
"slam/php-excel": "^4.4",
"fabpot/goutte": "^3.2",
"guzzlehttp/guzzle": "*",
"incoviba/modelos": "*",
"slim/slim": "4.x-dev",
"php-di/slim-bridge": "dev-master",
"rubellum/slim-blade-view": "dev-master",
"nyholm/psr7": "1.4.x-dev",
"nyholm/psr7-server": "dev-master",
"vlucas/phpdotenv": "^5.3"
"slim/slim": "^4",
"php-di/slim-bridge": "*",
"rubellum/slim-blade-view": "*",
"nyholm/psr7": "*",
"nyholm/psr7-server": "*",
"vlucas/phpdotenv": "^5.3",
"monolog/monolog": "^3"
},
"require-dev" : {
"phpunit/phpunit" : "^8",
"kint-php/kint" : "^2.1",
"filp/whoops" : "^2.1"
"phpunit/phpunit" : "*",
"kint-php/kint" : "*",
"filp/whoops" : "*"
},
"license" : "GNU AGPLv3",
"authors" : [{
@ -52,12 +53,15 @@
"type": "path",
"url": "./aldarien/**",
"options": {
"symlink": false
"symlink": true
}
},
{
"type": "path",
"url": "./incoviba/modelos"
}
]
],
"config": {
"sort-packages": true
}
}

View File

@ -11,6 +11,6 @@ return [
'controllers' => '{locations.app}/Controller',
'money' => 'provm.cl/optimus/money',
'api' => '192.168.1.100/intranet/api',
'api_url' => '/incoviba/api'
'api_url' => '/api'
];
?>

View File

@ -27,6 +27,8 @@ services:
- .db.env
volumes:
- .:/code
- ./php-errors.ini:/usr/local/etc/php/conf.d/docker-php-errors.ini
- ./logs:/logs
db:
profiles:

View File

@ -2,11 +2,27 @@
use Carbon\Carbon;
use Incoviba\old\Proyecto\Proyecto;
use App\Contract\Auth;
use Monolog\Level;
use Monolog\Handler;
use Monolog\Processor;
use Monolog\Formatter;
include_once dirname(__DIR__) . '/bootstrap/autoload.php';
header("Access-Control-Allow-Origin: *");
$logger = new Monolog\Logger('global');
$logger->pushHandler(new Handler\RotatingFileHandler('/logs/php.log'));
$handler = new Handler\NativeMailerHandler('jpvial@incoviba.cl', 'Incoviba Error', 'alert@incoviba.cl');
$handler->setFormatter(new Formatter\HtmlFormatter());
$logger->pushHandler(new Handler\FilterHandler($handler, Level::Error));
$logger->pushProcessor(new Processor\PsrLogMessageProcessor());
$logger->pushProcessor(new Processor\IntrospectionProcessor());
$logger->pushProcessor(new Processor\WebProcessor());
$logger->pushProcessor(new Processor\MemoryPeakUsageProcessor());
Monolog\ErrorHandler::register($logger);
if (config('app.debug') == true) {
if (config('app.benchmark') == true) {
$benchmark = (object) ['time' => microtime(true)];
@ -21,65 +37,77 @@ sanitize();
try {
Auth::isIn();
} catch (PDOException $e) {
$logger->error($e);
header('Location: install');
die();
}
if (Auth::isIn()) {
if ((get('p') !== false or get('page') !== false or get('m') !== false or get('module') !== false)) {
if (($route = route()) !== false) {
try {
if (Auth::isIn()) {
if ((get('p') !== false or get('page') !== false or get('m') !== false or get('module') !== false)) {
if (($route = route()) !== false) {
echo $route;
} else {
echo view('construccion');
}
} else {
$proyectos = model(Proyecto::class)->findMany();
$dias = [];
$cierres = [];
$pendientes = 0;
$hoy = 0;
foreach ($proyectos as $proyecto) {
$pendientes += $proyecto->cuotasPendientes();
$hoy += $proyecto->cuotasHoy();
foreach ($proyecto->cuotasMes() as $cuota) {
$f = $cuota->pago()->fecha();
if ($f->isoWeekday() == 6 or $f->isoWeekDay() == 7) {
$f = $f->copy()->addDays(2)->startOfWeek();
}
$dia = $f->format('Y-m-d');
if (!isset($dias[$dia])) {
$dias[$dia] = [$proyecto->descripcion => 0];
}
if (!isset($dias[$dia][$proyecto->descripcion])) {
$dias[$dia][$proyecto->descripcion] = 0;
}
$dias[$dia][$proyecto->descripcion] ++;
}
if (count($proyecto->cierres()) > 0) {
$cierres[$proyecto->descripcion] = (object) ['total' => count($proyecto->cierres()),'vigentes' => $proyecto->cierres(3), 'rechazados' => $proyecto->cierres(-1), 'pendientes' => $proyecto->cierres(2)];
}
}
uksort($dias, function($a, $b) {
return strcmp($a, $b);
});
uksort($cierres, function($a, $b) {
return strcmp($a, $b);
});
echo view('home', compact('pendientes', 'hoy', 'dias', 'cierres'));
}
} elseif (get('p') == 'auth' or get('page') == 'auth') {
$route = route();
if ($route !== false) {
echo $route;
} else {
echo view('construccion');
echo view('guest');
}
} else {
$proyectos = model(Proyecto::class)->findMany();
$dias = [];
$cierres = [];
$pendientes = 0;
$hoy = 0;
foreach ($proyectos as $proyecto) {
$pendientes += $proyecto->cuotasPendientes();
$hoy += $proyecto->cuotasHoy();
foreach ($proyecto->cuotasMes() as $cuota) {
$f = $cuota->pago()->fecha();
if ($f->isoWeekday() == 6 or $f->isoWeekDay() == 7) {
$f = $f->copy()->addDays(2)->startOfWeek();
}
$dia = $f->format('Y-m-d');
if (!isset($dias[$dia])) {
$dias[$dia] = [$proyecto->descripcion => 0];
}
if (!isset($dias[$dia][$proyecto->descripcion])) {
$dias[$dia][$proyecto->descripcion] = 0;
}
$dias[$dia][$proyecto->descripcion] ++;
}
if (count($proyecto->cierres()) > 0) {
$cierres[$proyecto->descripcion] = (object) ['total' => count($proyecto->cierres()),'vigentes' => $proyecto->cierres(3), 'rechazados' => $proyecto->cierres(-1), 'pendientes' => $proyecto->cierres(2)];
}
}
uksort($dias, function($a, $b) {
return strcmp($a, $b);
});
uksort($cierres, function($a, $b) {
return strcmp($a, $b);
});
echo view('home', compact('pendientes', 'hoy', 'dias', 'cierres'));
}
} elseif (get('p') == 'auth' or get('page') == 'auth') {
$route = route();
if ($route !== false) {
echo $route;
} else {
echo view('guest');
}
} else {
echo view('guest');
} catch (Exception $e) {
$logger->warning($e);
echo "";
} catch (Error $e) {
$logger->error($e);
echo "";
}
if (config('app.debug') == 'true') {
if (config('app.benchmark') == 'true') {
$benchmark->time = microtime(true) - $benchmark->time;
$logger->debug("Time {$benchmark->time}");
if (get('ajax') != '1' and get('p') != 'ajax' and get('p') != 'informes') {
echo view('benchmark', compact('benchmark'));
}

View File

@ -66,9 +66,11 @@
</tr>
</thead>
<tbody>
@if (isset($results) and is_array($results) and count($results) > 0)
@foreach ($results as $resultado)
@include('buscar.resultado')
@include('buscar.resultado', ['resultado' => $resultado])
@endforeach
@endif
</tbody>
</table>
</div>

View File

@ -82,7 +82,7 @@
?>
@foreach ($venta->pie()->cuotas() as $cuota)
<tr>
<td class="@include('ventas.pies.cuotas.estado')">
<td class="@include('ventas.pies.cuotas.estado', compact('cuota'))">
<a href="{{url('', ['p' => 'cuotas', 'a' => 'show', 'cuota' => $cuota->id])}}">{{++$cnt}} <span class="glyphicon glyphicon-edit small"></span></a>
</td>
<td>{{\App\Helper\Format::shortDate($cuota->pago()->fecha)}}</td>
@ -96,7 +96,7 @@
</td>
<td class="text-right">$ {{\App\Helper\Format::pesos($cuota->valor())}}</td>
<td class="text-right">{{\App\Helper\Format::ufs($cuota->valor('ufs'))}} UF</td>
<td class="text-center @include('ventas.pies.cuotas.estado')">
<td class="text-center @include('ventas.pies.cuotas.estado', ['cuota' => $cuota])">
{{\App\Helper\Format::shortDate($cuota->pago()->estado()->fecha)}}
<a href="{{url('', ['p' => 'pagos', 'a' => 'edit', 'pago' => $cuota->pago()->id, 'asociado' => 'venta', 'venta' => $venta->id])}}"><span class="glyphicon glyphicon-edit small"></span></a>
</td>
@ -179,25 +179,25 @@
'ufs' => $total->pagado_uf
];
?>
@include('ventas.pies.totales')
@include('ventas.pies.totales', compact('valores'))
<?php
$valores->titulo = 'Por Pagar';
$valores->pesos = $total->por_pagar;
$valores->ufs = $total->por_pagar_uf;
?>
@include('ventas.pies.totales')
@include('ventas.pies.totales', compact('valores'))
<?php
$valores->titulo = 'Total Cuotas';
$valores->pesos = $total->cuotas;
$valores->ufs = $total->cuotas_uf;
?>
@include('ventas.pies.totales')
@include('ventas.pies.totales', compact('valores'))
<?php
$valores->titulo = 'Diferencia c/Pie';
$valores->pesos = $total->dif;
$valores->ufs = $total->dif_uf;
?>
@include('ventas.pies.totales')
@include('ventas.pies.totales', compact('valores'))
</tbody>
</table>
<a href="{{nUrl('informes', 'cuotas', ['venta' => $venta->id])}}">Exportar</a>