Compare commits
100 Commits
2.1.21
...
47d43f504d
Author | SHA1 | Date | |
---|---|---|---|
47d43f504d | |||
0502b8e735 | |||
905e8263bc | |||
8710c8a111 | |||
5d9ac2bc51 | |||
062e0543e4 | |||
b97916cfc4 | |||
7af9cafdb6 | |||
84a2fbd119 | |||
bc9c71870c | |||
912e8624b2 | |||
86406bf027 | |||
7b8d44e8c8 | |||
c10f2e5912 | |||
bef0a22758 | |||
092eb95f06 | |||
5f56022109 | |||
4b3397dd63 | |||
529f9e32a1 | |||
939adf126f | |||
63400af1db | |||
019974614c | |||
735c341729 | |||
444ff687fc | |||
f3a5fa2cdc | |||
2ed265dcf1 | |||
dbae630fdd | |||
d69976d015 | |||
2ccbc31ae0 | |||
e50d80560c | |||
7cc0333876 | |||
eb38236926 | |||
85ef4dd60e | |||
f1e29e3b0b | |||
6617a92f5f | |||
ca958b8a88 | |||
dc2e2c7f71 | |||
936fd2d1e1 | |||
7c6a397e31 | |||
7385225a2e | |||
9c335fd350 | |||
57f9169cc7 | |||
8caa80459e | |||
98953cce42 | |||
c7dd309185 | |||
48bfe5d8ab | |||
d9b5bc6507 | |||
21d1ef653f | |||
e8d43e43ff | |||
fc9788a1cd | |||
02dcc950f4 | |||
370b6714bc | |||
dc7a9f9e7a | |||
cfe18c1909 | |||
5156858205 | |||
415ba31270 | |||
c784d1bee9 | |||
a1ade5c2c7 | |||
879b612493 | |||
b4cdd2d5f7 | |||
51cabee824 | |||
d2e51e76f8 | |||
1621d6fe30 | |||
0e32512adc | |||
338f290539 | |||
2aad7e1152 | |||
e542615128 | |||
1c7797b1b1 | |||
ba0d4073d7 | |||
faac3874a8 | |||
ade107ab3c | |||
c192cf1883 | |||
4fb75b11c4 | |||
ccbb71d875 | |||
7f25b4b5e1 | |||
f0b26a251b | |||
ea068d95d0 | |||
1ccc9ab3d4 | |||
5cd19bcdce | |||
712c70b34d | |||
35ab7e7e8b | |||
4b39f93f30 | |||
d3f188684a | |||
82647a171d | |||
e44ab30665 | |||
19333bc338 | |||
4738dae7c8 | |||
a370ffff43 | |||
88f9e539f7 | |||
671b26f038 | |||
e133bd36cf | |||
251dbbe0f0 | |||
e1eb2c4c56 | |||
1078f4c188 | |||
38962cb9cf | |||
3cd699d2e2 | |||
d8b8787be9 | |||
62edca5335 | |||
ac6c5b7d3d | |||
5b5a0ed1f5 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,3 +9,6 @@
|
||||
**/modules/
|
||||
**/.idea/
|
||||
**/upload?/
|
||||
**/informe?/
|
||||
**/.phpunit.cache/
|
||||
**/coverage/
|
||||
|
@ -1,16 +1,19 @@
|
||||
FROM php:8.2-fpm
|
||||
FROM php:8.2-cli
|
||||
|
||||
ENV TZ "America/Santiago"
|
||||
ENV TZ "${TZ}"
|
||||
ENV APP_NAME "${APP_NAME}"
|
||||
ENV API_URL "${API_URL}"
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cron && rm -r /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cron rsyslog nano && rm -r /var/lib/apt/lists/*
|
||||
|
||||
RUN pecl install xdebug-3.2.2 \
|
||||
&& docker-php-ext-enable xdebug
|
||||
&& docker-php-ext-enable xdebug \
|
||||
&& echo "#/bin/bash\nprintenv >> /etc/environment\ncron -f -L 11" > /root/entrypoint && chmod a+x /root/entrypoint
|
||||
|
||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||
|
||||
WORKDIR /code/bin
|
||||
|
||||
COPY ./cli/crontab /var/spool/cron/crontabs/root
|
||||
COPY --chmod=644 ./cli/crontab /var/spool/cron/crontabs/root
|
||||
|
||||
CMD ["cron", "-f"]
|
||||
CMD [ "/root/entrypoint" ]
|
||||
|
@ -9,6 +9,7 @@ RUN pecl install xdebug-3.1.3 \
|
||||
&& docker-php-ext-enable xdebug
|
||||
|
||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||
COPY ./php-xdebug.ini /usr/local/etc/php/conf.d/docker-php-xdebug.ini
|
||||
|
||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||
|
||||
|
1
app/.gitignore
vendored
Normal file
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
**/bin
|
13
app/.phpunit-watcher.yml
Normal file
13
app/.phpunit-watcher.yml
Normal file
@ -0,0 +1,13 @@
|
||||
watch:
|
||||
directories:
|
||||
- src
|
||||
- tests
|
||||
- common
|
||||
fileMask: '*.php'
|
||||
notifications:
|
||||
passingTests: false
|
||||
failingTests: false
|
||||
hideManual: true
|
||||
phpunit:
|
||||
arguments: '--log-events-text /logs/output.txt --stop-on-failure'
|
||||
timeout: 180
|
@ -5,6 +5,11 @@ use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
interface Banco
|
||||
{
|
||||
/**
|
||||
* Process bank movements for database inserts
|
||||
* @param UploadedFileInterface $file
|
||||
* @return array
|
||||
*/
|
||||
public function process(UploadedFileInterface $file): array;
|
||||
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ use Incoviba\Model;
|
||||
|
||||
interface Exporter
|
||||
{
|
||||
public function export(Model\Inmobiliaria $inmobiliaria, Model\Banco $banco, DateTimeInterface $mes, array $movimientos): string;
|
||||
public function export(Model\Inmobiliaria $inmobiliaria, Model\Contabilidad\Banco $banco, DateTimeInterface $mes, array $movimientos): string;
|
||||
}
|
||||
|
10
app/common/Define/Informe.php
Normal file
10
app/common/Define/Informe.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define;
|
||||
|
||||
interface Informe
|
||||
{
|
||||
public function setTitle(string $title): Informe;
|
||||
public function setFilename(string $filename): Informe;
|
||||
public function addData(array $rows): Informe;
|
||||
public function build(): void;
|
||||
}
|
@ -2,18 +2,22 @@
|
||||
namespace Incoviba\Common\Ideal\Cartola;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal\Service;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
abstract class Banco implements Define\Cartola\Banco
|
||||
abstract class Banco extends Service implements Define\Cartola\Banco
|
||||
{
|
||||
public function process(UploadedFileInterface $file): array
|
||||
{
|
||||
$data = $this->parseFile($file);
|
||||
$data = $this->handleFile($file);
|
||||
$temp = [];
|
||||
$columns = $this->columnMap();
|
||||
foreach ($data as $row) {
|
||||
$r = [];
|
||||
foreach ($columns as $old => $new) {
|
||||
if (!isset($row[$old])) {
|
||||
continue;
|
||||
}
|
||||
$r[$new] = $row[$old];
|
||||
}
|
||||
$temp []= $r;
|
||||
@ -21,6 +25,47 @@ abstract class Banco implements Define\Cartola\Banco
|
||||
return $temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* There are banks that need some post-processing
|
||||
* @param array $movimientos
|
||||
* @return array
|
||||
*/
|
||||
public function processMovimientosDiarios(array $movimientos): array
|
||||
{
|
||||
return $movimientos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the UploadedFile into a temp file from getFilename and after parseFile remove temp file
|
||||
* @param UploadedFileInterface $uploadedFile
|
||||
* @return array
|
||||
*/
|
||||
protected function handleFile(UploadedFileInterface $uploadedFile): array
|
||||
{
|
||||
$filename = $this->getFilename($uploadedFile);
|
||||
$uploadedFile->moveTo($filename);
|
||||
$data = $this->parseFile($filename);
|
||||
unlink($filename);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filename where to move UploadedFile
|
||||
* @param UploadedFileInterface $uploadedFile
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getFilename(UploadedFileInterface $uploadedFile): string;
|
||||
|
||||
/**
|
||||
* Mapping of uploaded file data columns to database columns
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function columnMap(): array;
|
||||
abstract protected function parseFile(UploadedFileInterface $uploadedFile): array;
|
||||
|
||||
/**
|
||||
* Translate uploaded file data to database data
|
||||
* @param string $filename
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function parseFile(string $filename): array;
|
||||
}
|
||||
|
60
app/common/Implement/Log/MySQLHandler.php
Normal file
60
app/common/Implement/Log/MySQLHandler.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Log;
|
||||
|
||||
use PDOStatement;
|
||||
use Monolog\Handler\AbstractProcessingHandler;
|
||||
use Monolog\LogRecord;
|
||||
use Monolog\Level;
|
||||
use Incoviba\Common\Define\Connection;
|
||||
|
||||
class MySQLHandler extends AbstractProcessingHandler
|
||||
{
|
||||
private bool $initialized = false;
|
||||
private PDOStatement $statement;
|
||||
|
||||
public function __construct(protected Connection $connection, int|string|Level $level = Level::Debug, bool $bubble = true)
|
||||
{
|
||||
parent::__construct($level, $bubble);
|
||||
}
|
||||
public function write(LogRecord $record): void
|
||||
{
|
||||
if (!$this->initialized) {
|
||||
$this->initialized();
|
||||
}
|
||||
$this->cleanup();
|
||||
$this->statement->execute([
|
||||
'channel' => $record->channel,
|
||||
'level' => $record->level->getName(),
|
||||
'message' => $record->formatted,
|
||||
'time' => $record->datetime->format('Y-m-d H:i:s.u'),
|
||||
'context' => (count($record->context) > 0) ? json_encode($record->context, JSON_UNESCAPED_SLASHES) : '',
|
||||
'extra' => (count($record->extra) > 0) ? json_encode($record->extra, JSON_UNESCAPED_SLASHES) : ''
|
||||
]);
|
||||
}
|
||||
|
||||
private function initialized(): void
|
||||
{
|
||||
$query = <<<QUERY
|
||||
CREATE TABLE IF NOT EXISTS monolog (
|
||||
channel VARCHAR(255),
|
||||
level VARCHAR(100),
|
||||
message LONGTEXT,
|
||||
time DATETIME,
|
||||
context LONGTEXT,
|
||||
extra LONGTEXT
|
||||
)
|
||||
QUERY;
|
||||
$this->connection->getPDO()->exec($query);
|
||||
$query = <<<QUERY
|
||||
INSERT INTO monolog (channel, level, message, time, context, extra)
|
||||
VALUES (:channel, :level, :message, :time, :context, :extra)
|
||||
QUERY;
|
||||
$this->statement = $this->connection->getPDO()->prepare($query);
|
||||
$this->initialized = true;
|
||||
}
|
||||
private function cleanup(): void
|
||||
{
|
||||
$query = "DELETE FROM monolog WHERE time < DATE_SUB(CURDATE(), INTERVAL 90 DAY)";
|
||||
$this->connection->query($query);
|
||||
}
|
||||
}
|
19
app/common/Implement/Log/PDOFormatter.php
Normal file
19
app/common/Implement/Log/PDOFormatter.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Log;
|
||||
|
||||
use Monolog\Formatter\JsonFormatter;
|
||||
use Monolog\LogRecord;
|
||||
|
||||
class PDOFormatter extends JsonFormatter
|
||||
{
|
||||
public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = true)
|
||||
{
|
||||
parent::__construct($batchMode, $appendNewline, $ignoreEmptyContextAndExtra, $includeStacktraces);
|
||||
}
|
||||
|
||||
public function format(LogRecord $record): string
|
||||
{
|
||||
$normalized = $this->normalize($record);
|
||||
return $normalized['message'];
|
||||
}
|
||||
}
|
@ -1,8 +1,12 @@
|
||||
{
|
||||
"name": "incoviba/web",
|
||||
"version": "2.0.0",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"berrnd/slim-blade-view": "^1.0",
|
||||
"ext-gd": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-pdo": "*",
|
||||
"guzzlehttp/guzzle": "^7.8",
|
||||
"monolog/monolog": "^3.4",
|
||||
"nyholm/psr7": "^1.8",
|
||||
@ -14,8 +18,10 @@
|
||||
"slim/slim": "^4.11"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"kint-php/kint": "^5.1",
|
||||
"phpunit/phpunit": "^10.2"
|
||||
"phpunit/phpunit": "^10.2",
|
||||
"spatie/phpunit-watcher": "^1.23"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
@ -30,6 +36,8 @@
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
"sort-packages": true,
|
||||
"process-timeout": 0,
|
||||
"bin-dir": "bin"
|
||||
}
|
||||
}
|
||||
|
43
app/phpunit.xml
Normal file
43
app/phpunit.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
cacheDirectory="/code/cache/tests"
|
||||
executionOrder="depends,defects"
|
||||
requireCoverageMetadata="false"
|
||||
beStrictAboutCoverageMetadata="false"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
colors="true"
|
||||
failOnRisky="false"
|
||||
failOnWarning="false">
|
||||
<testsuites>
|
||||
<testsuite name="unit">
|
||||
<directory>tests/units</directory>
|
||||
</testsuite>
|
||||
<testsuite name="acceptance">
|
||||
<directory>tests/integration</directory>
|
||||
</testsuite>
|
||||
<testsuite name="performance">
|
||||
<directory>tests/performance</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
|
||||
<include>
|
||||
<directory>src</directory>
|
||||
<directory>common</directory>
|
||||
</include>
|
||||
</source>
|
||||
<coverage includeUncoveredFiles="true" pathCoverage="false" ignoreDeprecatedCodeUnits="true" disableCodeCoverageIgnore="true">
|
||||
<report>
|
||||
<html outputDirectory="/code/public/coverage/html" />
|
||||
<php outputFile="/code/public/coverage/coverage.php" />
|
||||
</report>
|
||||
</coverage>
|
||||
<logging>
|
||||
<junit outputFile="/code/cache/tests/junit.xml" />
|
||||
<teamcity outputFile="/code/cache/tests/teamcity.txt" />
|
||||
<testdoxHtml outputFile="/code/cache/tests/testdox.html" />
|
||||
<testdoxText outputFile="/code/cache/tests/testdox.txt" />
|
||||
</logging>
|
||||
</phpunit>
|
0
app/public/informes/.gitkeep
Normal file
0
app/public/informes/.gitkeep
Normal file
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Base;
|
||||
|
||||
$app->group('/api', function($app) {
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'api']);
|
||||
if (file_exists($folder)) {
|
||||
@ -10,4 +12,5 @@ $app->group('/api', function($app) {
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
$app->get('[/]', Base::class);
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\API::class));
|
||||
|
@ -28,6 +28,12 @@ $app->group('/venta/{venta_id:[0-9]+}', function($app) {
|
||||
});
|
||||
$app->get('[/]', [Ventas::class, 'pie']);
|
||||
});
|
||||
$app->group('/escritura', function($app) {
|
||||
$app->get('/add[/]', [Ventas\Escrituras::class, 'add']);
|
||||
});
|
||||
$app->group('/credito', function($app) {
|
||||
$app->get('[/]', [Ventas\Creditos::class, 'show']);
|
||||
});
|
||||
$app->get('/escriturar[/]', [Ventas::class, 'escriturar']);
|
||||
$app->get('/desistir[/]', [Ventas::class, 'desistir']);
|
||||
$app->get('/desistida[/]', [Ventas::class, 'desistida']);
|
||||
|
@ -1,9 +1,13 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad;
|
||||
use Incoviba\Controller\API\Contabilidad\Cartolas;
|
||||
|
||||
$app->group('/cartolas', function($app) {
|
||||
$app->post('/procesar[/]', [Contabilidad::class, 'procesarCartola']);
|
||||
$app->post('/procesar[/]', [Cartolas::class, 'procesar']);
|
||||
});
|
||||
$app->group('/cartola', function($app) {
|
||||
$app->post('/exportar[/]', [Contabilidad::class, 'exportarCartola']);
|
||||
$app->group('/diaria', function($app) {
|
||||
$app->post('/ayer[/]', [Cartolas::class, 'ayer']);
|
||||
$app->post('/procesar[/]', [Cartolas::class, 'diaria']);
|
||||
});
|
||||
$app->post('/exportar[/]', [Cartolas::class, 'exportar']);
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\CentrosCostos;
|
||||
|
||||
use Incoviba\Controller\API\Contabilidad\CentrosCostos;
|
||||
|
||||
$app->group('/centros_costos', function($app) {
|
||||
$app->post('/add[/]', [CentrosCostos::class, 'add']);
|
||||
|
7
app/resources/routes/api/contabilidad/daps.php
Normal file
7
app/resources/routes/api/contabilidad/daps.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad\Depositos;
|
||||
|
||||
$app->group('/depositos', function($app) {
|
||||
$app->post('/add[/]', [Depositos::class, 'add']);
|
||||
$app->get('/inmobiliaria/{inmobiliaria_rut}[/]', [Depositos::class, 'inmobiliaria']);
|
||||
});
|
6
app/resources/routes/api/contabilidad/movimientos.php
Normal file
6
app/resources/routes/api/contabilidad/movimientos.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad\Movimientos;
|
||||
|
||||
$app->group('/movimiento/{movimiento_id}', function($app) {
|
||||
$app->post('/detalles', [Movimientos::class, 'detalles']);
|
||||
});
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Nubox;
|
||||
|
||||
use Incoviba\Controller\API\Contabilidad\Nubox;
|
||||
|
||||
$app->group('/nubox/{inmobiliaria_rut}', function($app) {
|
||||
$app->get('/token[/]', [Nubox::class, 'token']);
|
||||
|
@ -2,9 +2,20 @@
|
||||
use Incoviba\Controller\API\Inmobiliarias;
|
||||
|
||||
$app->group('/inmobiliarias', function($app) {
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'inmobiliarias']);
|
||||
if (file_exists($folder)) {
|
||||
$files = new FilesystemIterator($folder);
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
$app->get('[/]', Inmobiliarias::class);
|
||||
});
|
||||
$app->group('/inmobiliaria/{inmobiliaria_rut}', function($app) {
|
||||
$app->post('/agentes', [Inmobiliarias::class, 'agentes']);
|
||||
$app->get('/cuentas[/]', [Inmobiliarias::class, 'cuentas']);
|
||||
$app->get('/proyectos[/]', [Inmobiliarias::class, 'proyectos']);
|
||||
});
|
||||
|
11
app/resources/routes/api/inmobiliarias/proveedores.php
Normal file
11
app/resources/routes/api/inmobiliarias/proveedores.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Inmobiliarias\Agentes;
|
||||
|
||||
$app->group('/agentes', function($app) {
|
||||
$app->post('/add[/]', [Agentes::class, 'add']);
|
||||
$app->post('/register[/]', [Agentes::class, 'register']);
|
||||
$app->get('[/]', Agentes::class);
|
||||
});
|
||||
$app->group('/agente/{agente_id}', function($app) {
|
||||
$app->post('/edit[/]', [Agentes::class, 'edit']);
|
||||
});
|
@ -1,4 +1,12 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Search;
|
||||
|
||||
$app->post('/search', [Search::class, 'query']);
|
||||
$app->group('/search', function($app) {
|
||||
$app->group('/ventas', function($app) {
|
||||
$app->post('/unidades', [Search::class, 'unidades']);
|
||||
$app->get('/unidad/{unidad_id}', [Search::class, 'unidad']);
|
||||
$app->post('[/]', [Search::class, 'ventas']);
|
||||
});
|
||||
$app->get('/venta/{venta_id}', [Search::class, 'venta']);
|
||||
$app->post('[/]', [Search::class, 'query']);
|
||||
});
|
||||
|
@ -19,11 +19,21 @@ $app->group('/ventas', function($app) {
|
||||
$app->group('/escrituras', function($app) {
|
||||
$app->post('/estados[/]', [Ventas::class, 'escrituras']);
|
||||
});
|
||||
$app->group('/by', function($app) {
|
||||
$app->get('/unidad/{unidad_id}', [Ventas::class, 'unidad']);
|
||||
});
|
||||
$app->post('/get[/]', [Ventas::class, 'getMany']);
|
||||
$app->post('[/]', [Ventas::class, 'proyecto']);
|
||||
});
|
||||
$app->group('/venta/{venta_id}', function($app) {
|
||||
$app->get('/unidades[/]', [Ventas::class, 'unidades']);
|
||||
$app->get('/comentarios[/]', [Ventas::class, 'comentarios']);
|
||||
$app->group('/escritura', function($app) {
|
||||
$app->post('/add[/]', [Ventas\Escrituras::class, 'add']);
|
||||
});
|
||||
$app->group('/credito', function($app) {
|
||||
$app->post('[/]', [Ventas\Creditos::class, 'edit']);
|
||||
});
|
||||
$app->post('/escriturar[/]', [Ventas::class, 'escriturar']);
|
||||
$app->group('/desistir', function($app) {
|
||||
$app->get('/eliminar[/]', [Ventas::class, 'insistir']);
|
||||
|
6
app/resources/routes/contabilidad/cartolas.php
Normal file
6
app/resources/routes/contabilidad/cartolas.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad;
|
||||
|
||||
$app->group('/cartolas', function($app) {
|
||||
$app->get('/diaria[/]', [Contabilidad::class, 'diaria']);
|
||||
});
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\CentrosCostos;
|
||||
|
||||
use Incoviba\Controller\Contabilidad\CentrosCostos;
|
||||
|
||||
$app->group('/centros_costos', function($app) {
|
||||
$app->get('/asignar[/]', [CentrosCostos::class, 'asignar']);
|
||||
|
6
app/resources/routes/contabilidad/daps.php
Normal file
6
app/resources/routes/contabilidad/daps.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad;
|
||||
|
||||
$app->group('/depositos', function($app) {
|
||||
$app->get('[/]', [Contabilidad::class, 'depositos']);
|
||||
});
|
10
app/resources/routes/contabilidad/informes.php
Normal file
10
app/resources/routes/contabilidad/informes.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$app->group('/informes', function($app) {
|
||||
$files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'informes']));
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
});
|
6
app/resources/routes/contabilidad/informes/tesoreria.php
Normal file
6
app/resources/routes/contabilidad/informes/tesoreria.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad;
|
||||
|
||||
$app->group('/tesoreria', function($app) {
|
||||
$app->get('[/[{fecha}[/]]]', [Contabilidad::class, 'tesoreria']);
|
||||
});
|
6
app/resources/routes/contabilidad/informes/xlsx.php
Normal file
6
app/resources/routes/contabilidad/informes/xlsx.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad\Informes;
|
||||
|
||||
$app->group('/xlsx', function($app) {
|
||||
$app->get('/tesoreria/{fecha}[/]', [Informes::class, 'tesoreria']);
|
||||
});
|
823
app/resources/views/contabilidad/cartolas/diaria.blade.php
Normal file
823
app/resources/views/contabilidad/cartolas/diaria.blade.php
Normal file
@ -0,0 +1,823 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">
|
||||
Cartola Diaria
|
||||
</h1>
|
||||
<div class="ui grid">
|
||||
<div class="right aligned sixteen wide column">
|
||||
<button class="ui green icon button" id="add_button">
|
||||
Agregar
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form class="ui form" id="cartola_form">
|
||||
<input type="hidden" id="fields" name="fields" value="0" />
|
||||
</form>
|
||||
<div class="ui two columns grid">
|
||||
<div class="column">
|
||||
<button class="ui icon button" id="process_button">
|
||||
<i class="file excel icon"></i>
|
||||
Procesar
|
||||
</button>
|
||||
</div>
|
||||
<div class="right aligned column">
|
||||
<div class="ui inline active loader" id="loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="ui table" id="diferencia">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sociedad</th>
|
||||
<th>Banco - Cuenta</th>
|
||||
<th>Hoy</th>
|
||||
<th>Último Saldo</th>
|
||||
<th>Saldo Actual</th>
|
||||
<th>Diferencia</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui fluid container">
|
||||
<table class="ui table" id="tabla_movimientos">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sociedad</th>
|
||||
<th>Banco - Cuenta</th>
|
||||
<th>Fecha</th>
|
||||
<th>Glosa</th>
|
||||
<th class="right aligned">Cargo</th>
|
||||
<th class="right aligned">Abono</th>
|
||||
<th class="right aligned">Saldo</th>
|
||||
<th>Centro de Costo</th>
|
||||
<th>Detalle</th>
|
||||
<th>Orden</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="movimientos"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui modal" id="manual_modal">
|
||||
<div class="content">
|
||||
<div class="header">
|
||||
Movimientos |
|
||||
<span id="modal_inmobiliaria"></span> |
|
||||
<span id="modal_cuenta"></span> |
|
||||
<span id="modal_fecha"></span>
|
||||
</div>
|
||||
<div class="ui one column grid">
|
||||
<div class="right aligned column">
|
||||
<button class="ui green icon button" id="add_manual">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form class="ui form" id="modal_form">
|
||||
<input type="hidden" name="movimientos" value="[1]" />
|
||||
<div id="modal_movimientos">
|
||||
<div class="fields" data-movimiento="1">
|
||||
<div class="field">
|
||||
<label>Glosa</label>
|
||||
<input type="text" name="glosa1" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Cargo</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="cargo1" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Abono</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="abono1" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Saldo</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="saldo1" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="actions">
|
||||
<button class="ui approve button">
|
||||
Procesar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
class Cartola {
|
||||
idx
|
||||
inmobiliaria = {
|
||||
rut: 0,
|
||||
razon: ''
|
||||
}
|
||||
cuenta = {
|
||||
id: 0,
|
||||
descripcion: ''
|
||||
}
|
||||
fecha = ''
|
||||
bancos = []
|
||||
movimientos = []
|
||||
saldo = 0
|
||||
ayer = 0
|
||||
|
||||
constructor(idx) {
|
||||
this.idx = idx
|
||||
}
|
||||
|
||||
get() {
|
||||
return {
|
||||
bancos: () => {
|
||||
const url = '{{$urls->api}}/inmobiliaria/' + this.inmobiliaria.rut + '/cuentas'
|
||||
diaria.loader().show()
|
||||
return fetchAPI(url).then(response => {
|
||||
diaria.loader().hide()
|
||||
if (!response) {
|
||||
this.bancos = []
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cuentas.length === 0) {
|
||||
this.bancos = []
|
||||
return
|
||||
}
|
||||
this.bancos = json.cuentas.map(cuenta => {
|
||||
return {
|
||||
value: cuenta.id,
|
||||
text: cuenta.banco.nombre + ' - ' + cuenta.cuenta,
|
||||
name: cuenta.banco.nombre + ' - ' + cuenta.cuenta
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
ayer: (fecha) => {
|
||||
const url = '{{$urls->api}}/contabilidad/cartola/diaria/ayer'
|
||||
const body = new FormData()
|
||||
body.set('cuenta_id', this.cuenta.id)
|
||||
body.set('fecha', fecha.toISOString())
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cartola.length === 0) {
|
||||
return
|
||||
}
|
||||
this.ayer = json.cartola.saldo
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
update() {
|
||||
return {
|
||||
centro: (idx, centro_id) => {
|
||||
const id = this.movimientos[idx].id
|
||||
const url = '{{$urls->api}}/contabilidad/movimiento/' + id + '/detalles'
|
||||
const body = new FormData()
|
||||
body.set('centro_id', centro_id)
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
response.json().then(json => {
|
||||
if (!json.status) {
|
||||
return
|
||||
}
|
||||
const dropdown = $(".dropdown[data-idx='" + idx + "']")
|
||||
dropdown.dropdown('set selected', json.centro.id, true)
|
||||
})
|
||||
})
|
||||
},
|
||||
detalle: (idx, detalle) => {
|
||||
const id = this.movimientos[idx].id
|
||||
const url = '{{$urls->api}}/contabilidad/movimiento/' + id + '/detalles'
|
||||
const body = new FormData()
|
||||
body.set('detalle', detalle)
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
response.json().then(json => {
|
||||
if (!json.status) {
|
||||
return
|
||||
}
|
||||
const input = $("input[data-idx='" + idx + "']")
|
||||
input.val(json.detalle)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
draw() {
|
||||
return {
|
||||
form: ($form, inmobiliarias, first = false) => {
|
||||
const $fields = $('<div></div>').addClass('fields cartola').attr('data-cartola', this.idx)
|
||||
const $inmobiliarias_menu = $('<div></div>').addClass('menu')
|
||||
inmobiliarias.forEach(inmobiliaria => {
|
||||
$inmobiliarias_menu.append(
|
||||
$('<div></div>').addClass('item').attr('data-value', inmobiliaria.rut).html(inmobiliaria.razon)
|
||||
)
|
||||
})
|
||||
const $inmobiliarias_dropdown = $('<div></div>').addClass('ui search selection dropdown').attr('id', 'inmobiliaria' + this.idx).append(
|
||||
$('<input />').attr('type', 'hidden')//.attr('name', 'inmobiliaria_rut' + this.idx)
|
||||
).append(
|
||||
$('<i></i>').addClass('dropdown icon')
|
||||
).append(
|
||||
$('<div></div>').addClass('default text').html('Inmobiliaria')
|
||||
).append($inmobiliarias_menu)
|
||||
$fields.append(
|
||||
$('<div></div>').addClass('six wide field').append(
|
||||
$('<label></label>').attr('for', 'inmobiliaria' + this.idx).html('Sociedad')
|
||||
).append($inmobiliarias_dropdown)
|
||||
)
|
||||
const $cuentas_dropdown = $('<div></div>').addClass('ui search selection dropdown').attr('id', 'cuenta' + this.idx).append(
|
||||
$('<input />').attr('type', 'hidden').attr('name', 'cuenta_id' + this.idx)
|
||||
).append(
|
||||
$('<i></i>').addClass('dropdown icon')
|
||||
).append(
|
||||
$('<div></div>').addClass('default text').html('Banco - Cuenta')
|
||||
).append(
|
||||
$('<div></div>').addClass('menu')
|
||||
)
|
||||
$fields.append(
|
||||
$('<div></div>').addClass('four wide field').append(
|
||||
$('<label></label>').html('Banco - Cuenta')
|
||||
).append($cuentas_dropdown)
|
||||
)
|
||||
const $fecha_calendar = $('<div></div>').addClass('ui calendar').attr('id', 'fecha' + this.idx).append(
|
||||
$('<div></div>').addClass('ui left icon input').append(
|
||||
$('<i></i>').addClass('calendar icon')
|
||||
).append(
|
||||
$('<input />').attr('type', 'text')
|
||||
)
|
||||
)
|
||||
$fields.append(
|
||||
$('<div></div>').addClass('three wide field').append(
|
||||
$('<label></label>').attr('for', 'fecha' + this.idx).html('Fecha')
|
||||
).append($fecha_calendar)
|
||||
)
|
||||
$fields.append(
|
||||
$('<div></div>').addClass('field').append(
|
||||
$('<label></label>').html('Cartola')
|
||||
).append(
|
||||
$('<input />').addClass('ui invisible file input').attr('type', 'file').attr('name', 'file' + this.idx).attr('id', 'file' + this.idx)
|
||||
).append(
|
||||
$('<label></label>').addClass('ui icon button').attr('for', 'file' + this.idx).append(
|
||||
$('<i></i>').addClass('file icon')
|
||||
).append('Cargar')
|
||||
)
|
||||
)
|
||||
const $manual_checkbox = $('<div></div>').addClass('ui invisible checkbox').append(
|
||||
$('<input />').attr('type', 'checkbox').attr('name', 'manual' + this.idx).attr('id', 'manual' + this.idx)
|
||||
).append(
|
||||
$('<label></label>').addClass('image').attr('for', 'manual' + this.idx).append(
|
||||
$('<i></i>').addClass('large orange keyboard icon')
|
||||
)
|
||||
)
|
||||
|
||||
$fields.append($('<div></div>').addClass('field').append(
|
||||
$('<label></label>').html('Manual')
|
||||
).append($manual_checkbox))
|
||||
if (!first) {
|
||||
$fields.append(
|
||||
$('<div></div>').addClass('field').append(
|
||||
$('<label></label>').html('Eliminar')
|
||||
).append(
|
||||
$('<button></button>').addClass('ui red icon button').attr('data-cartola', this.idx).append(
|
||||
$('<i></i>').addClass('remove icon')
|
||||
).click(event => {
|
||||
const idx = $(event.currentTarget).data('cartola')
|
||||
diaria.cartolas().remove(idx)
|
||||
})
|
||||
)
|
||||
)
|
||||
}
|
||||
$form.append($fields)
|
||||
|
||||
const cdo = JSON.parse(JSON.stringify(calendar_date_options))
|
||||
cdo['initialDate'] = new Date()
|
||||
cdo['maxDate'] = cdo['initialDate']
|
||||
cdo['onChange'] = (date, text, mode) => {
|
||||
this.fecha = date
|
||||
}
|
||||
this.fecha = cdo['initialDate']
|
||||
|
||||
$inmobiliarias_dropdown.dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.inmobiliaria.rut = value
|
||||
this.inmobiliaria.razon = text
|
||||
this.get().bancos(value).then(() => {
|
||||
$cuentas_dropdown.dropdown('change values', this.bancos)
|
||||
})
|
||||
},
|
||||
})
|
||||
$cuentas_dropdown.dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.cuenta.id = value
|
||||
this.cuenta.descripcion = text
|
||||
}
|
||||
})
|
||||
$fecha_calendar.calendar(cdo)
|
||||
$manual_checkbox.change(event => {
|
||||
const $element = $(event.currentTarget)
|
||||
const status = $element.checkbox('is checked')
|
||||
const $field = $element.parent().parent()
|
||||
const $file = $field.find('#file' + this.idx).parent()
|
||||
if (status) {
|
||||
$file.find('input').attr('type', 'hidden')
|
||||
$file.hide()
|
||||
|
||||
manual.data.inmobiliaria = $inmobiliarias_dropdown.dropdown('get text')
|
||||
manual.data.cuenta = $cuentas_dropdown.dropdown('get text')
|
||||
const fecha = $fecha_calendar.calendar('get date')
|
||||
manual.data.fecha = [fecha.getDate(), (fecha.getMonth()+1).toString().padStart(2, '0'), fecha.getFullYear()].join('-')
|
||||
manual.data.field = this.idx
|
||||
manual.$modal.modal('show')
|
||||
return
|
||||
}
|
||||
$file.find('input').attr('type', 'file')
|
||||
$file.show()
|
||||
})
|
||||
},
|
||||
diferencia: ($tbody, dateFormatter, numberFormatter) => {
|
||||
$tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html(this.inmobiliaria.razon)
|
||||
).append(
|
||||
$('<td></td>').html(this.cuenta.descripcion)
|
||||
).append(
|
||||
$('<td></td>').html(dateFormatter.format(this.fecha))
|
||||
).append(
|
||||
$('<td></td>').html(numberFormatter.format(this.ayer))
|
||||
).append(
|
||||
$('<td></td>').html(numberFormatter.format(this.saldo))
|
||||
).append(
|
||||
$('<td></td>').html(numberFormatter.format(this.saldo - this.ayer))
|
||||
)
|
||||
)
|
||||
},
|
||||
cartola: ($tbody, dateFormatter, numberFormatter) => {
|
||||
this.movimientos.forEach((row, idx) => {
|
||||
$tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
'<td>' + this.inmobiliaria.razon + '</td>' + "\n"
|
||||
+ '<td>' + this.cuenta.descripcion + '</td>' + "\n"
|
||||
+ '<td>' + dateFormatter.format(row.fecha) + '</td>' + "\n"
|
||||
+ '<td>' + row.glosa + '</td>' + "\n"
|
||||
+ '<td class="right aligned">' + (row.cargo === 0 ? '' : numberFormatter.format(row.cargo)) + '</td>' + "\n"
|
||||
+ '<td class="right aligned">' + (row.abono === 0 ? '' : numberFormatter.format(row.abono)) + '</td>' + "\n"
|
||||
+ '<td class="right aligned">' + (row.saldo === 0 ? '' : numberFormatter.format(row.saldo)) + '</td>' + "\n"
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
this.draw().centroCosto(idx)
|
||||
)
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
this.draw().detalle(idx)
|
||||
)
|
||||
).append(
|
||||
$('<td></td>').html(idx + 1)
|
||||
)
|
||||
)
|
||||
})
|
||||
},
|
||||
centroCosto: idx => {
|
||||
const centros = JSON.parse('{!! json_encode($centrosCostos) !!}')
|
||||
const menu = $('<div></div>').addClass('menu')
|
||||
centros.forEach(centro => {
|
||||
menu.append(
|
||||
'<div class="item" data-value="' + centro.id + '">'
|
||||
+ centro.id + ' - ' + centro.descripcion
|
||||
+ '</div>'
|
||||
)
|
||||
})
|
||||
const dropdown = $('<div></div>').addClass('ui search selection dropdown').attr('data-idx', idx).html(
|
||||
'<input type="hidden" name="centro" />' + "\n" +
|
||||
'<i class="dropdown icon"></i>' + "\n" +
|
||||
'<div class="default text">Centro de Costo</div>' + "\n"
|
||||
).append(menu)
|
||||
dropdown.dropdown({
|
||||
onChange: (value, text, $element) => {
|
||||
const idx = $element.parent().parent().data('idx')
|
||||
this.update().centro(idx, value)
|
||||
}
|
||||
})
|
||||
|
||||
if (this.movimientos[idx].centro !== '') {
|
||||
const cid = centros.findIndex(centro => centro.descripcion === this.movimientos[idx].centro)
|
||||
dropdown.dropdown('set selected', centros[cid].id, true)
|
||||
}
|
||||
return dropdown
|
||||
},
|
||||
detalle: idx => {
|
||||
const detalle = document.createElement('input')
|
||||
detalle.type = 'text'
|
||||
detalle.name = 'detalle' + idx
|
||||
detalle.placeholder = 'Detalle'
|
||||
detalle.setAttribute('data-idx', idx)
|
||||
const input = document.createElement('div')
|
||||
input.className = 'ui input'
|
||||
input.appendChild(detalle)
|
||||
if (this.movimientos[idx].detalle !== '') {
|
||||
detalle.value = this.movimientos[idx].detalle
|
||||
}
|
||||
detalle.addEventListener('blur', event => {
|
||||
const idx = event.currentTarget.dataset['idx']
|
||||
this.update().detalle(idx, event.currentTarget.value)
|
||||
})
|
||||
return $(input)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@php
|
||||
$columns = [
|
||||
'sociedad',
|
||||
'cuenta',
|
||||
'fecha',
|
||||
'glosa',
|
||||
'cargo',
|
||||
'abono',
|
||||
'saldo',
|
||||
'centro',
|
||||
'detalle',
|
||||
'orden'
|
||||
];
|
||||
@endphp
|
||||
const diaria = {
|
||||
ids: {},
|
||||
data: {
|
||||
inmobiliarias: JSON.parse('{!! json_encode($inmobiliarias) !!}'),
|
||||
cartolasIdx: [],
|
||||
cartolas: [],
|
||||
},
|
||||
dataTableConfig: {
|
||||
order: [[{{array_search('orden', $columns)}}, 'asc']],
|
||||
columnDefs: [
|
||||
{
|
||||
targets: [{{implode(',', array_keys(array_filter($columns, function($column) {return in_array($column, ['fecha', 'cargo', 'abono', 'saldo']);})))}}],
|
||||
width: '{{round((1/(count($columns) + 3 - 1)) * 100,2)}}%'
|
||||
},
|
||||
{
|
||||
targets: [{{implode(',', array_keys(array_filter($columns, function($column) {return in_array($column, ['sociedad', 'cuenta', 'glosa', 'centro', 'detalle']);})))}}],
|
||||
width: '{{round((1/(count($columns) + 3 - 1)) * 2 * 100, 2)}}%'
|
||||
},
|
||||
{
|
||||
targets: [{{array_search('orden', $columns)}}],
|
||||
visible: false
|
||||
}
|
||||
],
|
||||
},
|
||||
loaderStatus: true,
|
||||
loader() {
|
||||
return {
|
||||
show: () => {
|
||||
if (!this.loaderStatus) {
|
||||
$(this.ids.loader).show()
|
||||
this.loaderStatus = true
|
||||
}
|
||||
},
|
||||
hide: () => {
|
||||
if (this.loaderStatus) {
|
||||
$(this.ids.loader).hide()
|
||||
this.loaderStatus = false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
cartolas() {
|
||||
return {
|
||||
add: () => {
|
||||
let first = false
|
||||
if (this.data.cartolas.length === 0) {
|
||||
first = true
|
||||
}
|
||||
const idx = this.data.cartolas.reduce((prev, cartola) => Math.max(prev, cartola.idx), 0) + 1
|
||||
const cartola = new Cartola(idx)
|
||||
this.data.cartolas.push(cartola)
|
||||
this.data.cartolasIdx.push(idx)
|
||||
const form = $(this.ids.form)
|
||||
cartola.draw().form(form, this.data.inmobiliarias, first)
|
||||
$(this.ids.fields).attr('value', JSON.stringify(this.data.cartolasIdx))
|
||||
},
|
||||
remove: idx => {
|
||||
if (this.data.cartolas.length === 1) {
|
||||
return
|
||||
}
|
||||
const i = this.data.cartolasIdx.findIndex(value => value === idx)
|
||||
const cartolaIdx = this.data.cartolas.findIndex(cartola => cartola.idx === idx)
|
||||
$("div.cartola[data-cartola='" + idx + "']").remove()
|
||||
this.data.cartolasIdx.splice(i,1)
|
||||
this.data.cartolas.splice(cartolaIdx,1)
|
||||
$(this.ids.fields).attr('value', JSON.stringify(this.data.cartolasIdx))
|
||||
}
|
||||
}
|
||||
},
|
||||
draw() {
|
||||
return {
|
||||
empty: () => {
|
||||
Object.values(this.ids.table).forEach(id => $(id).find('tbody').html(''))
|
||||
},
|
||||
diferencia: () => {
|
||||
const $table = $(this.ids.table.diferencia)
|
||||
const $tbody = $table.find('tbody')
|
||||
$tbody.html('')
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric'
|
||||
})
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
||||
this.data.cartolas.forEach(cartola => {
|
||||
cartola.draw().diferencia($tbody, dateFormatter, numberFormatter)
|
||||
})
|
||||
},
|
||||
cartola: () => {
|
||||
const $table = $(this.ids.table.base)
|
||||
$table.DataTable().clear()
|
||||
$table.DataTable().destroy()
|
||||
const $tbody = $(this.ids.table.body)
|
||||
$tbody.html('')
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric'
|
||||
})
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
||||
this.data.cartolas.forEach(cartola => {
|
||||
cartola.draw().cartola($tbody, dateFormatter, numberFormatter)
|
||||
})
|
||||
$table.DataTable(this.dataTableConfig)
|
||||
},
|
||||
}
|
||||
},
|
||||
parse() {
|
||||
return {
|
||||
cartola: event => {
|
||||
const body = new FormData($(this.ids.form)[0])
|
||||
this.data.cartolas.forEach(cartola => {
|
||||
body.set('fecha' + cartola.idx, [cartola.fecha.getFullYear(), cartola.fecha.getMonth()+1, cartola.fecha.getDate()].join('-'))
|
||||
})
|
||||
const url = '{{$urls->api}}/contabilidad/cartola/diaria/procesar'
|
||||
diaria.loader().show()
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
diaria.loader().hide()
|
||||
this.draw().empty()
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cartolas.length === 0) {
|
||||
return
|
||||
}
|
||||
Object.entries(json.cartolas).forEach(entry => {
|
||||
const cartolaIdx = this.data.cartolas.findIndex(cartola => cartola.idx === parseInt(entry[0]))
|
||||
this.data.cartolas[cartolaIdx].movimientos = []
|
||||
entry[1].movimientos.forEach((row, idx) => {
|
||||
const fecha = new Date(row.fecha)
|
||||
fecha.setDate(fecha.getDate() + 1)
|
||||
this.data.cartolas[cartolaIdx].movimientos[idx] = {
|
||||
id: row.id,
|
||||
fecha: fecha,
|
||||
glosa: row.glosa,
|
||||
documento: row.documento,
|
||||
cargo: row.cargo,
|
||||
abono: row.abono,
|
||||
saldo: row.saldo,
|
||||
centro: row.detalles?.centro_costo.descripcion ?? '',
|
||||
detalle: row.detalles?.detalle ?? ''
|
||||
}
|
||||
})
|
||||
const ayer = new Date(this.data.cartolas[cartolaIdx].fecha.getTime())
|
||||
ayer.setDate(this.data.cartolas[cartolaIdx].fecha.getDate() - 1)
|
||||
this.data.cartolas[cartolaIdx].saldo = entry[1].cartola.saldo
|
||||
this.data.cartolas[cartolaIdx].get().ayer(ayer)
|
||||
})
|
||||
this.draw().diferencia()
|
||||
this.draw().cartola()
|
||||
})
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
|
||||
this.loader().hide()
|
||||
|
||||
$(this.ids.form).submit(event => {
|
||||
event.preventDefault()
|
||||
return false
|
||||
})
|
||||
$(this.ids.buttons.add).click(event => {
|
||||
this.cartolas().add()
|
||||
})
|
||||
$(this.ids.buttons.process).click(this.parse().cartola)
|
||||
$(this.ids.table.base).DataTable(this.dataTableConfig)
|
||||
|
||||
this.cartolas().add()
|
||||
}
|
||||
}
|
||||
const manual = {
|
||||
ids: {},
|
||||
$modal: null,
|
||||
data: {
|
||||
inmobiliaria: '',
|
||||
cuenta: '',
|
||||
fecha: '',
|
||||
field: 0,
|
||||
movimientos: [
|
||||
{idx: 1}
|
||||
]
|
||||
},
|
||||
get movimientosIdx() {
|
||||
const $movimientosIdx = $(this.ids.form).find("[name='movimientos']")
|
||||
return JSON.parse($movimientosIdx.val())
|
||||
},
|
||||
set movimientosIdx(list) {
|
||||
const $movimientosIdx = $(this.ids.form).find("[name='movimientos']")
|
||||
$movimientosIdx.val(JSON.stringify(list))
|
||||
},
|
||||
update() {
|
||||
return {
|
||||
file: movimientos => {
|
||||
const $file = $("[name='file" + this.data.field + "']")
|
||||
$file.val(JSON.stringify(movimientos))
|
||||
}
|
||||
}
|
||||
},
|
||||
parse() {
|
||||
return {
|
||||
movimientos: () => {
|
||||
const $fields = $(this.ids.movimientos).find('.fields')
|
||||
const movimientos = []
|
||||
$fields.each((i, fields) => {
|
||||
const idx = $(fields).data('movimiento')
|
||||
const inputs = [
|
||||
'glosa',
|
||||
'cargo',
|
||||
'abono',
|
||||
'saldo'
|
||||
]
|
||||
const data = {}
|
||||
inputs.forEach(name => {
|
||||
data[name] = $(fields).find("[name='"+name+idx+"']").val()
|
||||
if (name !== 'glosa') {
|
||||
data[name] = parseInt(data[name]) || 0
|
||||
}
|
||||
})
|
||||
|
||||
movimientos.push(data)
|
||||
})
|
||||
this.update().file(movimientos)
|
||||
}
|
||||
}
|
||||
},
|
||||
movimiento() {
|
||||
return {
|
||||
add: () => {
|
||||
const idx = this.data.movimientos.reduce((prev, movimiento) => Math.max(prev, movimiento.idx), 0) + 1
|
||||
const movimiento = {
|
||||
idx
|
||||
}
|
||||
this.data.movimientos.push(movimiento)
|
||||
const movimientosidx = this.movimientosIdx
|
||||
movimientosidx.push(idx)
|
||||
this.movimientosIdx = movimientosidx
|
||||
this.draw().movimiento(idx)
|
||||
},
|
||||
remove: idx => {
|
||||
const movimientosIdx = this.movimientosIdx
|
||||
const i = movimientosIdx.findIndex(n => n === idx)
|
||||
movimientosIdx.splice(i, 1)
|
||||
const movimientoIdx = this.data.movimientos.findIndex(movimiento => movimiento.idx === idx)
|
||||
this.data.movimientos.splice(movimientoIdx, 1)
|
||||
$(this.ids.movimientos).find("[data-idx='"+idx+"']").parent().parent().remove()
|
||||
this.movimientosIdx = movimientosIdx
|
||||
}
|
||||
}
|
||||
},
|
||||
draw() {
|
||||
return {
|
||||
movimiento: idx => {
|
||||
$(this.ids.movimientos).append(
|
||||
$('<div></div>').addClass('fields').attr('data-movimiento', idx).append(
|
||||
'<div class="field">' + "\n"
|
||||
+ '<label>Glosa</label>' + "\n"
|
||||
+ '<input type="text" name="glosa' + idx + '" />' + "\n"
|
||||
+ '</div>' + "\n" +
|
||||
'<div class="field">' + "\n"
|
||||
+ '<label>Cargo</label>' + "\n"
|
||||
+ '<div class="ui left labeled input">' + "\n"
|
||||
+ '<div class="ui basic label">$</div>' + "\n"
|
||||
+ '<input type="text" name="cargo' + idx + '" />' + "\n"
|
||||
+ '</div>' + "\n"
|
||||
+ '</div>' + "\n" +
|
||||
'<div class="field">' + "\n"
|
||||
+ '<label>Abono</label>' + "\n"
|
||||
+ '<div class="ui left labeled input">' + "\n"
|
||||
+ '<div class="ui basic label">$</div>' + "\n"
|
||||
+ '<input type="text" name="abono' + idx + '" />' + "\n"
|
||||
+ '</div>' + "\n"
|
||||
+ '</div>' + "\n" +
|
||||
'<div class="field">' + "\n"
|
||||
+ '<label>Saldo</label>' + "\n"
|
||||
+ '<div class="ui left labeled input">' + "\n"
|
||||
+ '<div class="ui basic label">$</div>' + "\n"
|
||||
+ '<input type="text" name="saldo' + idx + '" />' + "\n"
|
||||
+ '</div>' + "\n"
|
||||
+ '</div>'
|
||||
).append(
|
||||
$('<div></div>').addClass('field').append(
|
||||
$('<label></label>').html('Eliminar')
|
||||
).append(
|
||||
$('<button></button>').addClass('ui red icon button').attr('type', 'button').attr('data-idx', idx).append(
|
||||
$('<i></i>').addClass('remove icon')
|
||||
).click(event => {
|
||||
const idx = $(event.currentTarget).data('idx')
|
||||
manual.movimiento().remove(idx)
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
|
||||
$(this.ids.modal).modal({
|
||||
onShow: () => {
|
||||
$(this.ids.inmobiliaria).html(this.data.inmobiliaria)
|
||||
$(this.ids.cuenta).html(this.data.cuenta)
|
||||
$(this.ids.fecha).html(this.data.fecha)
|
||||
this.movimientos = []
|
||||
$(this.ids.form).trigger('reset')
|
||||
},
|
||||
onApprove: $element => {
|
||||
this.parse().movimientos()
|
||||
},
|
||||
onHide: $element => {
|
||||
this.parse().movimientos()
|
||||
}
|
||||
})
|
||||
this.$modal = $(this.ids.modal)
|
||||
$(this.ids.button).click(event => {
|
||||
this.movimiento().add()
|
||||
})
|
||||
$(this.ids.form).submit(event => {
|
||||
event.preventDefault()
|
||||
this.$modal.modal('hide')
|
||||
return false
|
||||
})
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
diaria.setup({
|
||||
table: {
|
||||
base: '#tabla_movimientos',
|
||||
body: '#movimientos',
|
||||
diferencia: '#diferencia'
|
||||
},
|
||||
form: '#cartola_form',
|
||||
fields: '#fields',
|
||||
buttons: {
|
||||
add: '#add_button',
|
||||
process: '#process_button'
|
||||
},
|
||||
loader: '#loader'
|
||||
})
|
||||
manual.setup({
|
||||
modal: '#manual_modal',
|
||||
button: '#add_manual',
|
||||
inmobiliaria: '#modal_inmobiliaria',
|
||||
cuenta: '#modal_cuenta',
|
||||
fecha: '#modal_fecha',
|
||||
form: '#modal_form',
|
||||
movimientos: '#modal_movimientos'
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -14,9 +14,10 @@
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Inmobiliaria</div>
|
||||
<div class="menu">
|
||||
@foreach ($inmobiliarias as $inmobiliaria)
|
||||
<div class="item" data-value="{{$inmobiliaria->rut}}">{{$inmobiliaria->razon}}</div>
|
||||
@endforeach
|
||||
@foreach ($inmobiliarias as $inmobiliaria)
|
||||
<div class="item"
|
||||
data-value="{{$inmobiliaria->rut}}">{{$inmobiliaria->razon}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -40,7 +41,7 @@
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="file">Cartola</label>
|
||||
<input type="file" name="file" id="file" class="ui invisible file input" />
|
||||
<input type="file" name="file" id="file" class="ui invisible file input"/>
|
||||
<label for="file" class="ui icon button">
|
||||
<i class="file icon"></i>
|
||||
Cargar
|
||||
@ -119,20 +120,20 @@
|
||||
mes: '',
|
||||
movimientos: [],
|
||||
centrosCostos: {
|
||||
ingresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
ingresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
return [
|
||||
'id' => $centroCosto->id,
|
||||
'descripcion' => $centroCosto->descripcion
|
||||
];
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
return $centroCosto->tipoCentro->descripcion === 'Ingreso';
|
||||
})))) !!}'),
|
||||
egresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
egresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
return [
|
||||
'id' => $centroCosto->id,
|
||||
'descripcion' => $centroCosto->descripcion
|
||||
];
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
return $centroCosto->tipoCentro->descripcion === 'Egreso';
|
||||
})))) !!}'),
|
||||
}
|
||||
@ -170,7 +171,11 @@
|
||||
return
|
||||
}
|
||||
$(this.ids.form.banco).dropdown('change values', json.cuentas.map(cuenta => {
|
||||
return {value: cuenta.banco.id, text: cuenta.banco.nombre, name: cuenta.banco.nombre}
|
||||
return {
|
||||
value: cuenta.banco.id,
|
||||
text: cuenta.banco.nombre,
|
||||
name: cuenta.banco.nombre
|
||||
}
|
||||
})).dropdown('refresh')
|
||||
})
|
||||
})
|
||||
@ -247,12 +252,12 @@
|
||||
const movimientos = this.data.movimientos.map((movimiento, idx) => {
|
||||
const temp = structuredClone(movimiento)
|
||||
temp.fecha = movimiento.fecha.toISOString()
|
||||
let centro = $(".centro[data-index='" + (idx+1) + "']").dropdown('get value')
|
||||
let centro = $(".centro[data-index='" + (idx + 1) + "']").dropdown('get value')
|
||||
if (centro.length === 0) {
|
||||
centro = ''
|
||||
}
|
||||
temp.centro_costo = centro
|
||||
let detalle = $("[name='detalle" + (idx+1) + "']").val()
|
||||
let detalle = $("[name='detalle" + (idx + 1) + "']").val()
|
||||
if (typeof detalle === 'undefined') {
|
||||
detalle = ''
|
||||
}
|
||||
@ -294,7 +299,10 @@
|
||||
month: 'numeric',
|
||||
day: 'numeric'
|
||||
})
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0
|
||||
})
|
||||
this.data.movimientos.forEach((row, idx) => {
|
||||
tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
@ -322,7 +330,7 @@
|
||||
})
|
||||
table.DataTable(this.dataTableConfig)
|
||||
},
|
||||
centrosDropdown: (idx, ingreso=true) => {
|
||||
centrosDropdown: (idx, ingreso = true) => {
|
||||
const menu = $('<div></div>').addClass('menu')
|
||||
let centros = this.data.centrosCostos.ingresos
|
||||
if (!ingreso) {
|
||||
|
263
app/resources/views/contabilidad/depositos.blade.php
Normal file
263
app/resources/views/contabilidad/depositos.blade.php
Normal file
@ -0,0 +1,263 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">Depósitos a Plazo</h1>
|
||||
</div>
|
||||
<div class="ui stackable grid">
|
||||
<div class="two wide column"></div>
|
||||
<div class="twelve wide column">
|
||||
<table class="ui table" id="depositos">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Inmobiliaria</th>
|
||||
<th>Banco</th>
|
||||
<th>N° Depósito</th>
|
||||
<th>Capital</th>
|
||||
<th>Inicio</th>
|
||||
<th>Plazo</th>
|
||||
<th>Vencimiento</th>
|
||||
<th>Vencimiento ISO</th>
|
||||
<th>Monto al Vencimiento</th>
|
||||
<th>Tasa</th>
|
||||
<th>
|
||||
<button class="ui green icon button" id="add_button">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($activos as $deposito)
|
||||
<tr>
|
||||
<td>{{$deposito->cuenta->inmobiliaria->razon}}</td>
|
||||
<td>{{$deposito->cuenta->banco->nombre}}</td>
|
||||
<td>{{$deposito->id}}</td>
|
||||
<td>{{$format->pesos($deposito->capital)}}</td>
|
||||
<td>{{$deposito->inicio->format('d-m-Y')}}</td>
|
||||
<td>{{$deposito->plazo()}}</td>
|
||||
<td>{{$deposito->termino->format('d-m-Y')}}</td>
|
||||
<td>{{$deposito->termino->format('Y-m-d')}}</td>
|
||||
<td>{{$format->pesos($deposito->futuro)}}</td>
|
||||
<td>{{$format->percent($deposito->tasa() * 100, 4)}}</td>
|
||||
<td>
|
||||
<button class="ui red icon button remove_button" data-deposito="{{$deposito->id}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@foreach ($vencidos as $deposito)
|
||||
<tr class="yellow">
|
||||
<td>{{$deposito->cuenta->inmobiliaria->razon}}</td>
|
||||
<td>{{$deposito->cuenta->banco->nombre}}</td>
|
||||
<td>{{$deposito->id}}</td>
|
||||
<td>{{$format->pesos($deposito->capital)}}</td>
|
||||
<td>{{$deposito->inicio->format('d-m-Y')}}</td>
|
||||
<td>{{$deposito->plazo()}}</td>
|
||||
<td>{{$deposito->termino->format('d-m-Y')}}</td>
|
||||
<td>{{$deposito->termino->format('Y-m-d')}}</td>
|
||||
<td>{{$format->pesos($deposito->futuro)}}</td>
|
||||
<td>{{$format->percent($deposito->tasa() * 100, 4)}}</td>
|
||||
<td>
|
||||
<button class="ui red icon button remove_button" data-deposito="{{$deposito->id}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui modal" id="add_modal">
|
||||
<div class="content">
|
||||
<form class="ui form" id="add_form">
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label for="inmobiliaria">Inmobiliaria</label>
|
||||
<div class="ui search selection dropdown" id="inmobiliaria">
|
||||
<input type="hidden" name="inmobiliaria_rut" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Inmobiliaria</div>
|
||||
<div class="menu">
|
||||
@foreach ($inmobiliarias as $inmobiliaria)
|
||||
<div class="item" data-value="{{$inmobiliaria->rut}}">{{$inmobiliaria->razon}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="banco">Banco</label>
|
||||
<div class="ui search selection dropdown" id="banco">
|
||||
<input type="hidden" name="banco_id" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Banco</div>
|
||||
<div class="menu"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label for="identificador">N° Depósito</label>
|
||||
<input type="text" id="identificador" name="id" />
|
||||
</div>
|
||||
<div class="three fields">
|
||||
<div class="field">
|
||||
<label for="capital">Capital</label>
|
||||
<input type="number" id="capital" name="capital" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="futuro">Monto al Vencimiento</label>
|
||||
<input type="number" id="futuro" name="futuro" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<label for="inicio">Inicio</label>
|
||||
<div class="ui calendar" id="inicio">
|
||||
<div class="ui left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="inicio" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="termino">Vencimiento</label>
|
||||
<div class="ui calendar" id="termino">
|
||||
<div class="ui left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="termino" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="ui approve button">Agregar</button>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
const depositos = {
|
||||
ids: {},
|
||||
data: {
|
||||
inmobiliaria: {
|
||||
rut: 0,
|
||||
razon: ''
|
||||
},
|
||||
banco: {
|
||||
id: 0,
|
||||
nombre: ''
|
||||
}
|
||||
},
|
||||
get() {
|
||||
return {
|
||||
bancos: inmobiliaria_rut => {
|
||||
const url = '{{$urls->api}}/inmobiliaria/' + inmobiliaria_rut + '/cuentas'
|
||||
return fetchAPI(url).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cuentas.length === 0) {
|
||||
return
|
||||
}
|
||||
$(this.ids.forms.add.bancos).dropdown('change values', json.cuentas.map(cuenta => {
|
||||
return {value: cuenta.banco.id, text: cuenta.banco.nombre, name: cuenta.banco.nombre}
|
||||
})).dropdown('refresh')
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
add() {
|
||||
return {
|
||||
deposito: form => {
|
||||
const url = '{{$urls->api}}/contabilidad/depositos/add'
|
||||
const body = new FormData(form)
|
||||
const inicio = $(this.ids.forms.add.inicio).calendar('get date')
|
||||
const termino = $(this.ids.forms.add.termino).calendar('get date')
|
||||
body.set('inicio', [inicio.getFullYear(), inicio.getMonth()+1, inicio.getDate()].join('-'))
|
||||
body.set('termino', [termino.getFullYear(), termino.getMonth()+1, termino.getDate()].join('-'))
|
||||
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.status) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
|
||||
$(this.ids.buttons.add).click(event => {
|
||||
$(this.ids.modals.add).modal('show')
|
||||
})
|
||||
$(this.ids.modals.add).modal({
|
||||
onApprove: $element => {
|
||||
$(this.ids.forms.add.base).submit()
|
||||
}
|
||||
})
|
||||
$(this.ids.forms.add.base).submit(event => {
|
||||
event.preventDefault()
|
||||
this.add().deposito(event.currentTarget)
|
||||
return false
|
||||
})
|
||||
$(this.ids.forms.add.inmobiliarias).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.inmobiliaria.rut = value
|
||||
this.data.inmobiliaria.razon = text
|
||||
this.get().bancos(value)
|
||||
}
|
||||
})
|
||||
$(this.ids.forms.add.banco).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.banco.id = value
|
||||
this.data.banco.nombre = text
|
||||
}
|
||||
})
|
||||
$(this.ids.forms.add.inicio).calendar(calendar_date_options)
|
||||
$(this.ids.forms.add.termino).calendar(calendar_date_options)
|
||||
|
||||
$(this.ids.table).dataTable({
|
||||
columnDefs: [{target: 7, visible: false, searchable: false}],
|
||||
order: [[7, 'desc'], [0, 'asc']]
|
||||
})
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
depositos.setup({
|
||||
table: '#depositos',
|
||||
buttons: {
|
||||
add: '#add_button'
|
||||
},
|
||||
modals: {
|
||||
add: '#add_modal'
|
||||
},
|
||||
forms: {
|
||||
add: {
|
||||
base: '#add_form',
|
||||
inmobiliarias: '#inmobiliaria',
|
||||
bancos: '#banco',
|
||||
inicio: '#inicio',
|
||||
termino: '#termino'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
179
app/resources/views/contabilidad/informes/tesoreria.blade.php
Normal file
179
app/resources/views/contabilidad/informes/tesoreria.blade.php
Normal file
@ -0,0 +1,179 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@push('page_styles')
|
||||
<style>
|
||||
tr.bold>th {
|
||||
font-weight: bold !important;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui centered header">Informe de Tesorería</h1>
|
||||
<h4 class="ui centered sub header">{{$fecha->format('d M Y')}}</h4>
|
||||
<div class="ui grid">
|
||||
<div class="three wide column">
|
||||
<a href="/contabilidad/informes/xlsx/tesoreria/{{$fecha->format('Y-m-d')}}" target="_blank" style="color: inherit;">
|
||||
<div class="ui inverted green center aligned segment">
|
||||
Descargar en Excel <i class="file excel icon"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui grid">
|
||||
<div class="four wide column">
|
||||
<table class="ui collapsing simple table">
|
||||
<tr>
|
||||
<td>Informe anterior</td>
|
||||
<td>
|
||||
<a href="{{$urls->base}}/contabilidad/informes/tesoreria/{{$anterior->format('Y-m-d')}}">
|
||||
{{$anterior->format('d/m/Y')}}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Informe actual</td>
|
||||
<td>{{$fecha->format('d/m/Y')}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="column"></div>
|
||||
<div class="four wide column">
|
||||
<table class="ui collapsing simple table">
|
||||
<tr>
|
||||
<td>Valor UF</td>
|
||||
<td class="right aligned">{{$format->pesos($UF->get($fecha), 2)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Valor Dólar</td>
|
||||
<td class="right aligned">{{$format->pesos($USD->get($fecha), 2)}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@if ($siguiente !== null)
|
||||
<div class="five wide column"></div>
|
||||
<div class="right aligned two wide column">
|
||||
<div class="ui segment">
|
||||
Siguiente
|
||||
<a href="{{$urls->base}}/contabilidad/informes/tesoreria/{{$siguiente->format('Y-m-d')}}">
|
||||
{{$siguiente->format('d/m/Y')}} >>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<table class="ui striped table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>EMPRESA</th>
|
||||
<th>Banco</th>
|
||||
<th>Cuenta</th>
|
||||
<th class="right aligned">Saldo Anterior</th>
|
||||
<th class="right aligned">Saldo Actual</th>
|
||||
<th class="right aligned">Diferencia</th>
|
||||
<th class="right aligned">FFMM</th>
|
||||
<th class="right aligned">DAP</th>
|
||||
<th class="right aligned">Saldo Empresa</th>
|
||||
<th class="right aligned">Total Cuentas</th>
|
||||
<th class="right aligned">Total FFMM</th>
|
||||
<th class="right aligned">Total DAP</th>
|
||||
<th class="right aligned">Caja Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($informes['inmobiliarias'] as $inmobiliaria_rut => $informe)
|
||||
@foreach ($informe->cuentas as $i => $cuenta)
|
||||
<tr>
|
||||
@if ($i === 0)
|
||||
<td rowspan="{{count($informe->cuentas)}}">{{$informe->inmobiliaria->razon}}</td>
|
||||
@endif
|
||||
<td>{{$cuenta->banco}}</td>
|
||||
<td>{{$cuenta->numero}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->anterior)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->actual)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->diferencia())}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->ffmm)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->deposito)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuenta->saldo())}}</td>
|
||||
@if ($i === 0)
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->total())}}</td>
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->ffmm())}}</td>
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->deposito())}}</td>
|
||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->caja())}}</td>
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="bold">
|
||||
<th colspan="3">TOTAL</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->anterior)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->actual)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->diferencia())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->ffmm)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->deposito)}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->saldo())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->cuentas())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->ffmms())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->depositos())}}</th>
|
||||
<th class="right aligned">{{$format->pesos($informes['totales']->caja())}}</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>EMPRESA</th>
|
||||
<th class="right aligned">INGRESOS</th>
|
||||
<th class="right aligned">EGRESOS</th>
|
||||
<th>FECHA</th>
|
||||
<th>BANCO</th>
|
||||
<th>DESCRIPCIÓN</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($informes['movimientos'] as $tipo => $movimientos)
|
||||
@if ($tipo === 'capital dap')
|
||||
@if (count($movimientos['ingresos']) === 0 and count($movimientos['egresos']) === 0)
|
||||
@continue
|
||||
@endif
|
||||
<tr class="grey">
|
||||
<td colspan="6">{{strtoupper($tipo)}}</td>
|
||||
</tr>
|
||||
@foreach ($movimientos as $ms)
|
||||
@foreach ($ms as $movimiento)
|
||||
<tr>
|
||||
<td >{{$movimiento->cuenta->inmobiliaria->razon}}</td>
|
||||
<td class="right aligned">{{$format->pesos($movimiento->abono)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
||||
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
||||
<td>{{$movimiento->cuenta->banco->nombre}}</td>
|
||||
<td>{{$movimiento->glosa}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endforeach
|
||||
@continue
|
||||
@endif
|
||||
@if (count($movimientos) === 0)
|
||||
@continue
|
||||
@endif
|
||||
<tr class="grey">
|
||||
<td colspan="6">{{strtoupper($tipo)}}</td>
|
||||
</tr>
|
||||
@foreach ($movimientos as $movimiento)
|
||||
<tr>
|
||||
<td >{{$movimiento->cuenta->inmobiliaria->razon}}</td>
|
||||
<td class="right aligned">{{$format->pesos($movimiento->abono)}}</td>
|
||||
<td class="red right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
||||
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
||||
<td>{{$movimiento->cuenta->banco->nombre}}</td>
|
||||
<td>{{$movimiento->glosa}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@endsection
|
@ -10,11 +10,6 @@
|
||||
<div class="column">
|
||||
Inmobiliarias
|
||||
</div>
|
||||
{{--<div class="right aligned column">
|
||||
<button class="ui icon button" type="button">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</div>--}}
|
||||
</h2>
|
||||
<div class="ui divider"></div>
|
||||
<div class="ui cards">
|
||||
@ -22,9 +17,7 @@
|
||||
<div class="ui card">
|
||||
<div class="content">
|
||||
<div class="header">
|
||||
{{$inmobiliaria->abreviacion}}
|
||||
{{--<a href="{{$urls->base}}/inmobiliaria/{{$inmobiliaria->rut}}">
|
||||
</a>--}}
|
||||
{{$inmobiliaria->abreviacion}}
|
||||
</div>
|
||||
<div class="description">{{$inmobiliaria->razon}} {{$inmobiliaria->tipoSociedad->descripcion}}</div>
|
||||
<div class="meta">{{$inmobiliaria->rut()}}</div>
|
||||
|
@ -2,6 +2,13 @@
|
||||
Contabilidad
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<div class="item">
|
||||
<i class="dropdown icon"></i>
|
||||
Informes
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/informes/tesoreria/{{$hoy->sub(new DateInterval('P1D'))->format('Y-m-d')}}">Tesorería</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<i class="dropdown icon"></i>
|
||||
<a class="text" href="{{$urls->base}}/contabilidad/centros_costos">Centros de Costos</a>
|
||||
@ -9,5 +16,7 @@
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/centros_costos/asignar">Asignar en Cartola</a>
|
||||
</div>
|
||||
</div>
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/cartolas/diaria">Cartola Diaria</a>
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/depositos">Depósitos a Plazo</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" integrity="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.2/semantic.min.js" integrity="sha512-5cguXwRllb+6bcc2pogwIeQmQPXEzn2ddsqAexIBhh7FO1z5Hkek1J9mrK2+rmZCTU6b6pERxI7acnp1MpAg4Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.js" integrity="sha512-gnoBksrDbaMnlE0rhhkcx3iwzvgBGz6mOEj4/Y5ZY09n55dYddx6+WYc72A55qEesV8VX2iMomteIwobeGK1BQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function fetchAPI(url, options=null) {
|
||||
@ -10,7 +10,7 @@
|
||||
options['headers'] = {}
|
||||
}
|
||||
if (!Object.hasOwn(options['headers'], 'Authorization')) {
|
||||
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}'
|
||||
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}{{($login->isIn()) ? $login->getSeparator() . $login->getToken() : ''}}'
|
||||
}
|
||||
return fetch(url, options).then(response => {
|
||||
if (response.ok) {
|
||||
|
@ -0,0 +1,3 @@
|
||||
@push('page_scripts')
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js" integrity="sha512-a+SUDuwNzXDvz4XrIcXHuCf089/iJAoN4lmrXJg18XnduKK6YlDHNRalv4yd1N40OKI80tFidF+rqTFKGPoWFQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
@endpush
|
@ -1,4 +1,5 @@
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/1.13.5/js/jquery.dataTables.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/1.13.5/js/dataTables.semanticui.min.js"></script>
|
||||
{{--<script type="text/javascript" src="https://cdn.datatables.net/2.0.1/js/jquery.dataTables.min.js"></script>--}}
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/2.0.1/js/dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/2.0.1/js/dataTables.semanticui.min.js"></script>
|
||||
@endpush
|
||||
|
@ -0,0 +1,9 @@
|
||||
@push('page_scripts')
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.9/pdfmake.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.semanticui.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.colVis.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.print.min.js"></script>
|
||||
@endpush
|
@ -1,3 +1,3 @@
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.2/semantic.min.css" integrity="sha512-n//BDM4vMPvyca4bJjZPDh7hlqsQ7hqbP9RH18GF2hTXBY5amBwM2501M0GPiwCU/v9Tor2m13GOTFjk00tkQA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.css" integrity="sha512-3quBdRGJyLy79hzhDDcBzANW+mVqPctrGCfIPosHQtMKb3rKsCxfyslzwlz2wj1dT8A7UX+sEvDjaUv+WExQrA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
|
||||
@stack('page_styles')
|
||||
|
@ -1,3 +1,3 @@
|
||||
@push('page_styles')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.5/css/dataTables.semanticui.min.css" />
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.1/css/dataTables.semanticui.min.css" />
|
||||
@endpush
|
||||
|
@ -0,0 +1,3 @@
|
||||
@push('page_styles')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/3.0.0/css/buttons.semanticui.min.css" />
|
||||
@endpush
|
@ -16,29 +16,30 @@
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.body.scripts.cryptojs')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
function encryptPassword(password) {
|
||||
const passphrase = Math.floor(Math.random() * Date.now()).toString()
|
||||
const encrypted = CryptoJS.AES.encrypt(password, passphrase)
|
||||
return [passphrase, encrypted.toString()].join('')
|
||||
}
|
||||
function sendLogin(name, password) {
|
||||
const data = new FormData()
|
||||
data.append('name', name)
|
||||
data.append('password', password)
|
||||
return fetch('{{$urls->base}}/login', {
|
||||
method: 'post',
|
||||
headers: {
|
||||
Accept: 'json'
|
||||
},
|
||||
body: data
|
||||
}).then(response => {
|
||||
const method = 'post'
|
||||
const headers = {
|
||||
Accept: 'json'
|
||||
}
|
||||
const body = new FormData()
|
||||
body.append('name', name)
|
||||
body.append('password', encryptPassword(password))
|
||||
return fetch('{{$urls->base}}/login', {method, headers, body}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.login === true) {
|
||||
@if(isset($redirect_uri))
|
||||
window.location = '{{$redirect_uri}}'
|
||||
@else
|
||||
window.location = '{{$urls->base}}'
|
||||
@endif
|
||||
window.location = '{{(isset($redirect_uri)) ? $redirect_uri : $urls->base}}'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<form id="search_form" class="ui form" action="{{$urls->base}}/search" method="post">
|
||||
<div class="field">
|
||||
<div class="ui fluid input" data-tooltip="Para buscar frases se deben encerrar entre comillas. ej, 'portal la viña' o "portal la viña"" data-position="bottom left">
|
||||
<div class="ui fluid input" data-tooltip="Para buscar frases se deben encerrar entre comillas. ej, 'portal la viña' o "portal la viña"" data-position="top right">
|
||||
<input type="text" name="query" />
|
||||
</div>
|
||||
</div>
|
||||
@ -56,7 +56,7 @@
|
||||
unidad.html(unidad.html() + ' (I)')
|
||||
}
|
||||
propietario = $('<a></a>')
|
||||
.attr('href','{{$urls->base}}/search/' + encodeURIComponent(this.venta.propietario.nombre_completo) + '/propietario')
|
||||
.attr('href','{{$urls->base}}/search/"' + encodeURIComponent(this.venta.propietario.nombre_completo) + '"/propietario')
|
||||
.html(this.venta.propietario.nombre_completo)
|
||||
fecha = dateFormatter.format(new Date(this.venta.fecha))
|
||||
if (typeof this.venta.entrega !== 'undefined') {
|
||||
@ -96,6 +96,10 @@
|
||||
id: '',
|
||||
data: [],
|
||||
table: null,
|
||||
queues: {
|
||||
unidades: [],
|
||||
ventas: []
|
||||
},
|
||||
get: function() {
|
||||
return {
|
||||
results: () => {
|
||||
@ -122,34 +126,33 @@
|
||||
}
|
||||
const progress = this.draw().progress(data.results.length)
|
||||
const promises = []
|
||||
data.results.forEach(row => {
|
||||
if (row.tipo === 'venta') {
|
||||
return promises.push(this.get().venta(row.id).then(json => {
|
||||
if (json.venta === null) {
|
||||
console.debug(json)
|
||||
return
|
||||
}
|
||||
const venta = json.venta
|
||||
this.queues.ventas = data.results.filter(row => row.tipo === 'venta').map(row => row.id)
|
||||
this.queues.unidades = data.results.filter(row => row.tipo !== 'venta').map(row => row.id)
|
||||
promises.push(this.get().ventas().then(arrays => {
|
||||
arrays.forEach(json => {
|
||||
if (json.ventas.length === 0) {
|
||||
console.debug(json)
|
||||
return
|
||||
}
|
||||
json.ventas.forEach(venta => {
|
||||
progress.progress('increment')
|
||||
const r = new Row({unidad: venta.propiedad.unidades[0], proyecto: venta.proyecto})
|
||||
r.venta = venta
|
||||
this.data.push(r)
|
||||
}).catch(error => {
|
||||
})
|
||||
})
|
||||
}))
|
||||
promises.push(this.get().unidades().then(arrays => {
|
||||
arrays.forEach(json => {
|
||||
if (json.unidades.length === 0) {
|
||||
return
|
||||
}
|
||||
json.unidades.forEach(unidad => {
|
||||
progress.progress('increment')
|
||||
console.error(row)
|
||||
console.error(error)
|
||||
}))
|
||||
}
|
||||
promises.push(this.get().unidad(row.id).then(json => {
|
||||
const unidad = json.unidad
|
||||
progress.progress('increment')
|
||||
this.data.push(new Row({unidad: unidad, proyecto: unidad.proyecto_tipo_unidad.proyecto}))
|
||||
}).catch(error => {
|
||||
progress.progress('increment')
|
||||
console.error(row)
|
||||
console.error(error)
|
||||
}))
|
||||
})
|
||||
this.data.push(new Row({unidad: unidad, proyecto: unidad.proyecto_tipo_unidad.proyecto}))
|
||||
})
|
||||
})
|
||||
}))
|
||||
Promise.all(promises).then(() => {
|
||||
this.sort()
|
||||
this.draw().clear()
|
||||
@ -157,22 +160,43 @@
|
||||
})
|
||||
})
|
||||
},
|
||||
unidad: id => {
|
||||
const url = '{{$urls->api}}/ventas/unidad/' + id
|
||||
return fetchAPI(url).then(response => {
|
||||
if (response.ok) {
|
||||
unidades: () => {
|
||||
const url = '{{$urls->api}}/search/ventas/unidades'
|
||||
const chunks = []
|
||||
for (let i = 0; i < this.queues.unidades.length; i += 100) {
|
||||
chunks.push(this.queues.unidades.slice(i, i + 100))
|
||||
}
|
||||
const promises = []
|
||||
chunks.forEach(ids => {
|
||||
const body = new FormData()
|
||||
body.set('unidades', ids)
|
||||
promises.push(fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json()
|
||||
}
|
||||
}))
|
||||
})
|
||||
return Promise.all(promises)
|
||||
},
|
||||
venta: id => {
|
||||
const url = '{{$urls->api}}/venta/' + id
|
||||
return fetchAPI(url).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json()
|
||||
ventas: () => {
|
||||
const url = '{{$urls->api}}/search/ventas'
|
||||
const chunks = []
|
||||
for (let i = 0; i < this.queues.ventas.length; i += 100) {
|
||||
chunks.push(this.queues.ventas.slice(i, i + 100))
|
||||
}
|
||||
const promises = []
|
||||
chunks.forEach(ids => {
|
||||
const body = new FormData()
|
||||
body.set('ventas', ids)
|
||||
promises.push(fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json()
|
||||
}))
|
||||
})
|
||||
return Promise.all(promises)
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -309,15 +333,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
set: function() {
|
||||
return {
|
||||
query: value => {
|
||||
$("[name='query']").val(value)
|
||||
this.get().results()
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function(id) {
|
||||
this.id = id
|
||||
this.get().results()
|
||||
|
||||
$('#tipo').dropdown().dropdown('set selected', '*')
|
||||
@if (trim($post) !== '')
|
||||
$("[name='query']").val('{{$post}}')
|
||||
this.set().query('{!! $post !!}')
|
||||
@elseif (trim($query) !== '')
|
||||
$("[name='query']").val('{{$query}}')
|
||||
this.set().query('{!! $query !!}')
|
||||
@endif
|
||||
@if (trim($tipo) !== '')
|
||||
$('#tipo').dropdown('set selected', '{{$tipo}}')
|
||||
|
@ -349,7 +349,7 @@
|
||||
const lines = [
|
||||
'<label for="rut">RUT</label>',
|
||||
'<div class="inline field">',
|
||||
'<input type="text" id="rut" name="rut" />',
|
||||
'<input type="text" id="rut" name="rut" placeholder="00000000-0" />',
|
||||
'<span class="ui error message" id="alert_rut">',
|
||||
'<i class="exclamation triangle icon"></i>',
|
||||
'RUT Inválido',
|
||||
@ -358,25 +358,25 @@
|
||||
'<label for="nombres">Nombre</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="nombres" id="nombres" />',
|
||||
'<input type="text" name="nombres" id="nombres" placeholder="Nombre(s)" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_paterno" />',
|
||||
'<input type="text" name="apellido_paterno" placeholder="Apellido Paterno" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_materno" />',
|
||||
'<input type="text" name="apellido_materno" placeholder="Apellido Materno" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<label for="calle">Dirección</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="eight wide field">',
|
||||
'<input type="text" name="calle" id="calle" size="16" />',
|
||||
'<input type="text" name="calle" id="calle" size="16" placeholder="Calle" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="numero" size="5" />',
|
||||
'<input type="text" name="numero" size="5" placeholder="Número" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="extra" />',
|
||||
'<input type="text" name="extra" placeholder="Otros Detalles" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="inline fields">',
|
||||
|
294
app/resources/views/ventas/creditos.blade.php
Normal file
294
app/resources/views/ventas/creditos.blade.php
Normal file
@ -0,0 +1,294 @@
|
||||
@extends('ventas.base')
|
||||
|
||||
@section('venta_subtitle')
|
||||
Crédito
|
||||
@endsection
|
||||
|
||||
@section('venta_content')
|
||||
@php($credito = $venta->formaPago()->credito)
|
||||
<div class="ui grid">
|
||||
<div class="row">
|
||||
<div class="two wide column">Fecha</div>
|
||||
<div class="six wide column" id="fecha" data-status="static">
|
||||
<span id="fecha_data">
|
||||
{{$credito->pago->fecha->format('d-m-Y')}}
|
||||
</span>
|
||||
<a href="#" id="fecha_edit">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
<div class="ui calendar hidden" id="fecha_input">
|
||||
<div class="ui left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="fecha" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="two wide column">Banco</div>
|
||||
<div class="six wide column" id="banco" data-status="static">
|
||||
<span id="banco_data">
|
||||
@if (isset($credito->pago->banco))
|
||||
{{$credito->pago->banco->nombre}}
|
||||
@else
|
||||
No definido
|
||||
@endif
|
||||
</span>
|
||||
<a href="#" id="banco_edit">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
<div class="ui search selection dropdown hidden" id="banco_input">
|
||||
<input type="hidden" name="banco" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Banco</div>
|
||||
<div class="menu">
|
||||
@foreach ($bancos as $banco)
|
||||
<div class="item" data-value="{{$banco->id}}">{{$banco->nombre}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="two wide column">Valor</div>
|
||||
<div class="six wide column" id="valor" data-status="static">
|
||||
<span id="valor_data">
|
||||
{{$format->ufs($credito->pago->valor())}}
|
||||
</span>
|
||||
<a href="#" id="valor_edit">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
<div class="ui right labeled input hidden" id="valor_input">
|
||||
<input type="text" name="valor" />
|
||||
<div class="ui basic label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_styles')
|
||||
<style>
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
const credito = {
|
||||
ids: {},
|
||||
data: {
|
||||
venta: {{$venta->id}},
|
||||
credito: {{$credito->id}},
|
||||
fecha: new Date({{$credito->pago->fecha->format('Y')}},
|
||||
{{$credito->pago->fecha->format('m')}}+1,
|
||||
{{$credito->pago->fecha->format('d')}}),
|
||||
banco: {
|
||||
@if (isset($credito->pago->banco))
|
||||
id: {{$credito->pago->banco->id}},
|
||||
nombre: '{{$credito->pago->banco->nombre}}'
|
||||
@else
|
||||
id: 0,
|
||||
nombre: ''
|
||||
@endif
|
||||
},
|
||||
valor: {{$credito->pago->valor()}},
|
||||
bancos: JSON.parse('{!! json_encode($bancos) !!}')
|
||||
},
|
||||
elements: {},
|
||||
change() {
|
||||
return {
|
||||
status: (id, status) => {
|
||||
this.elements[id].dataset.status = status
|
||||
}
|
||||
}
|
||||
},
|
||||
hide() {
|
||||
return {
|
||||
data: id => {
|
||||
this.elements[id + '.data'].innerHTML = ''
|
||||
this.elements[id + '.data'].classList.add('hidden')
|
||||
this.elements[id + '.data'].hidden = true
|
||||
},
|
||||
input: id => {
|
||||
this.elements[id + '.input'].classList.add('hidden')
|
||||
this.elements[id + '.input'].hidden = true
|
||||
}
|
||||
}
|
||||
},
|
||||
show() {
|
||||
return {
|
||||
data: id => {
|
||||
this.elements[id + '.data'].classList.remove('hidden')
|
||||
this.elements[id + '.data'].hidden = false
|
||||
},
|
||||
input: id => {
|
||||
this.elements[id + '.input'].classList.remove('hidden')
|
||||
this.elements[id + '.input'].hidden = false
|
||||
}
|
||||
}
|
||||
},
|
||||
draw() {
|
||||
return {
|
||||
edit: (id) => {
|
||||
this.change().status(id, 'edit')
|
||||
this.show().input(id)
|
||||
this.update()[id]()
|
||||
},
|
||||
static: (id, text) => {
|
||||
this.change().status(id, 'static')
|
||||
this.hide().input(id)
|
||||
this.elements[this.ids.fields[id] + '.data'].innerHTML = this.format()[id](text)
|
||||
}
|
||||
}
|
||||
},
|
||||
send(id, value) {
|
||||
const url = '{{$urls->api}}/venta/{{$venta->id}}/credito'
|
||||
const body = new FormData()
|
||||
body.set(id, value)
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (!json.status) {
|
||||
return
|
||||
}
|
||||
this.data.fecha = new Date(json.credito.pago.fecha)
|
||||
this.data.banco.id = json.credito.pago.banco.id
|
||||
this.data.banco.nombre = json.credito.pago.banco.nombre
|
||||
this.data.valor = json.credito.pago.valor / json.credito.pago.uf
|
||||
})
|
||||
})
|
||||
},
|
||||
edit() {
|
||||
return {
|
||||
fecha: fecha => {
|
||||
this.send('fecha', fecha).then(() => {
|
||||
this.draw().static('fecha', this.data.fecha)
|
||||
})
|
||||
},
|
||||
banco: banco_id => {
|
||||
this.send('banco', banco_id).then(() => {
|
||||
this.draw().static('banco', this.data.banco.nombre)
|
||||
})
|
||||
},
|
||||
valor: valor => {
|
||||
this.send('valor', valor).then(() => {
|
||||
this.draw().static('valor', this.data.valor)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
format() {
|
||||
return {
|
||||
fecha: value => {
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {year: 'numeric', month: 'numeric', day: 'numeric'})
|
||||
return dateFormatter.format(value)
|
||||
},
|
||||
banco: value => {
|
||||
if (value === '') {
|
||||
value = 'No definido'
|
||||
}
|
||||
return value
|
||||
},
|
||||
valor: value => {
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2})
|
||||
return numberFormatter.format(value) + ' UF'
|
||||
}
|
||||
}
|
||||
},
|
||||
update() {
|
||||
return {
|
||||
fecha: () => {
|
||||
const $fecha = $(this.elements.fecha.querySelector('div.ui.calendar'))
|
||||
$fecha.calendar('set date', this.data.fecha)
|
||||
$fecha.calendar('focus')
|
||||
},
|
||||
banco: () => {
|
||||
const $dropdown = $(this.elements.banco.querySelector('div.ui.dropdown'))
|
||||
$dropdown.dropdown('clear')
|
||||
if (this.data.banco.id !== 0) {
|
||||
$dropdown.dropdown('set selected', this.data.banco.id)
|
||||
}
|
||||
$dropdown.dropdown('toggle')
|
||||
},
|
||||
valor: () => {
|
||||
const input = this.elements.valor.querySelector('input')
|
||||
input.value = this.data.valor ?? ''
|
||||
input.focus()
|
||||
}
|
||||
}
|
||||
},
|
||||
watch(id) {
|
||||
this.elements[id + '.edit'].addEventListener('click', event => {
|
||||
const elem = event.currentTarget.parentNode
|
||||
const id = elem.id
|
||||
const status = elem.dataset.status
|
||||
if (status !== 'static') {
|
||||
return
|
||||
}
|
||||
this.draw().edit(id)
|
||||
})
|
||||
},
|
||||
register(name, elem_id) {
|
||||
this.elements[name] = document.getElementById(elem_id)
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
|
||||
Object.entries(this.ids.fields).forEach(entry => {
|
||||
const name = entry[0]
|
||||
const field = entry[1]
|
||||
this.register(name, field)
|
||||
this.register(name + '.data', field + '_data')
|
||||
this.register(name + '.input', field + '_input')
|
||||
this.register(name + '.edit', field + '_edit')
|
||||
this.watch(field)
|
||||
})
|
||||
calendar_date_options['onChange'] = (date, text, mode) => {
|
||||
if (date === this.data.fecha) {
|
||||
return
|
||||
}
|
||||
this.edit().fecha([date.getFullYear(), date.getMonth()+1, date.getDate()].join('-'))
|
||||
}
|
||||
calendar_date_options['onHide'] = () => {
|
||||
this.draw().static('fecha', this.data.fecha)
|
||||
}
|
||||
$(this.elements.fecha).find('div.ui.calendar').calendar(calendar_date_options)
|
||||
$(this.elements.banco).find('div.ui.dropdown').dropdown({
|
||||
onChange: (value, text, $element) => {
|
||||
if (value === '' || value === this.data.banco.id) {
|
||||
return
|
||||
}
|
||||
this.edit().banco(value)
|
||||
},
|
||||
onHide: () => {
|
||||
this.draw().static('banco', this.data.banco.nombre)
|
||||
}
|
||||
})
|
||||
this.elements.valor.querySelector('input').addEventListener('blur', event => {
|
||||
let valor = event.currentTarget.value
|
||||
if (valor.includes(',')) {
|
||||
valor = valor.replaceAll('.', '').replace(',', '.')
|
||||
}
|
||||
if (parseFloat(valor) === this.data.valor) {
|
||||
this.draw().static('valor', this.data.valor)
|
||||
return
|
||||
}
|
||||
this.edit().valor(valor)
|
||||
})
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
credito.setup({
|
||||
fields: {
|
||||
fecha: 'fecha',
|
||||
banco: 'banco',
|
||||
valor: 'valor'
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
153
app/resources/views/ventas/escrituras/add.blade.php
Normal file
153
app/resources/views/ventas/escrituras/add.blade.php
Normal file
@ -0,0 +1,153 @@
|
||||
@extends('ventas.base')
|
||||
|
||||
@section('venta_subtitle')
|
||||
Agregar Abono en Escritura
|
||||
@endsection
|
||||
|
||||
@section('venta_content')
|
||||
<div class="ui basic segment">
|
||||
<p>Valor Promesa {{$format->ufs($venta->valor)}}</p>
|
||||
@if (isset($venta->formaPago()->pie))
|
||||
<p>Valor Anticipo {{$format->ufs($venta->formaPago()->pie->valor)}}</p>
|
||||
@endif
|
||||
@if (isset($venta->formaPago()->credito))
|
||||
<p>Crédito {{$format->ufs($venta->formaPago()->credito->pago->valor())}}</p>
|
||||
@endif
|
||||
</div>
|
||||
<form class="ui form" id="add_form">
|
||||
<div class="three wide field">
|
||||
<label for="fecha">Fecha</label>
|
||||
<div class="ui calendar" id="fecha">
|
||||
<div class="ui left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="fecha" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label for="valor">Valor</label>
|
||||
<div class="ui labeled input" id="valor">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="valor" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui checkbox" id="uf">
|
||||
<input type="checkbox" name="uf" />
|
||||
<label>Valor en UFs</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="three wide field">
|
||||
<label for="bancos">Banco</label>
|
||||
<div class="ui search selection dropdown" id="bancos">
|
||||
<input type="hidden" name="banco" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Banco</div>
|
||||
<div class="menu">
|
||||
@foreach ($bancos as $banco)
|
||||
<div class="item" data-value="{{$banco->id}}">{{$banco->nombre}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" name="tipo" value="1" checked="checked" />
|
||||
<label>Cheque</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" name="tipo" value="3" />
|
||||
<label>Vale Vista</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui button">Agregar</button>
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
const escritura = {
|
||||
ids: {},
|
||||
add() {
|
||||
return {
|
||||
escritura: event => {
|
||||
event.preventDefault()
|
||||
const body = new FormData(event.currentTarget)
|
||||
const fecha = $(this.ids.fecha).calendar('get date')
|
||||
body.set('fecha', [fecha.getFullYear(), fecha.getMonth()+1, fecha.getDate()].join('-'))
|
||||
const status = $(this.ids.checkbox).checkbox('is checked')
|
||||
body.set('uf', status)
|
||||
|
||||
const url = '{{$urls->api}}/venta/{{$venta->id}}/escritura/add'
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.status) {
|
||||
window.location = '{{$urls->base}}/venta/{{$venta->id}}'
|
||||
}
|
||||
})
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
toggle() {
|
||||
return {
|
||||
checkbox: () => {
|
||||
const status = $(this.ids.checkbox).checkbox('is checked')
|
||||
if (status) {
|
||||
return this.toggle().uf()
|
||||
}
|
||||
return this.toggle().pesos()
|
||||
},
|
||||
uf: () => {
|
||||
const valor = $(this.ids.valor)
|
||||
valor.attr('class', 'ui right labeled input')
|
||||
valor.find('.label').remove()
|
||||
valor.append(
|
||||
$('<div></div>').addClass('ui basic label').html('UF')
|
||||
)
|
||||
},
|
||||
pesos: () => {
|
||||
const valor = $(this.ids.valor)
|
||||
valor.attr('class', 'ui labeled input')
|
||||
valor.find('.label').remove()
|
||||
valor.prepend(
|
||||
$('<div></div>').addClass('ui basic label').html('$')
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
|
||||
$(this.ids.fecha).calendar(calendar_date_options)
|
||||
$(this.ids.checkbox).checkbox({
|
||||
fireOnInit: true,
|
||||
onChange: this.toggle().checkbox
|
||||
})
|
||||
$(this.ids.bancos).dropdown()
|
||||
$(this.ids.form).submit(this.add().escritura)
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
escritura.setup({
|
||||
form: '#add_form',
|
||||
fecha: '#fecha',
|
||||
checkbox: '#uf',
|
||||
valor: '#valor',
|
||||
bancos: '#bancos'
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -116,10 +116,15 @@
|
||||
this.data.id = data.proyecto.id
|
||||
this.data.proyecto = data.proyecto.descripcion
|
||||
this.data.venta_ids = data.ventas
|
||||
const chunkSize = 50
|
||||
const chunks = []
|
||||
for (let i = 0; i < data.ventas.length; i += chunkSize) {
|
||||
chunks.push(data.ventas.splice(i, i + chunkSize))
|
||||
}
|
||||
const promises = []
|
||||
data.ventas.forEach(venta_id => {
|
||||
const promise = this.get().venta(venta_id).then(() => {
|
||||
progress.progress('increment')
|
||||
chunks.forEach(chunk => {
|
||||
const promise = this.get().venta(chunk).then(count => {
|
||||
progress.progress('increment', count)
|
||||
})
|
||||
promises.push(promise)
|
||||
})
|
||||
@ -129,17 +134,22 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
venta: venta_id => {
|
||||
return fetchAPI('{{$urls->api}}/venta/' + venta_id).then(response => {
|
||||
venta: chunk => {
|
||||
const body = new FormData()
|
||||
body.set('ventas', chunk.join(','))
|
||||
return fetchAPI('{{$urls->api}}/ventas/get', {method: 'post', body}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (typeof data.venta === 'undefined') {
|
||||
console.error(venta_id, data.error)
|
||||
if (data.ventas.length === 0) {
|
||||
console.error(chunk, data.error)
|
||||
return
|
||||
}
|
||||
this.add().venta(data.venta)
|
||||
data.ventas.forEach(venta_id => {
|
||||
this.add().venta(venta_id)
|
||||
})
|
||||
return data.ventas.length
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,29 @@
|
||||
@endsection
|
||||
|
||||
@section('venta_content')
|
||||
@if (count($asociadas) > 0)
|
||||
<div class="ui grid">
|
||||
<div class="two wide column">Asociados</div>
|
||||
<div class="six wide column">
|
||||
{!! implode(' - ', array_map(function(Incoviba\Model\Venta $venta) use ($urls) {
|
||||
return "<a href=\"{$urls->base}/venta/{$venta->id}\">{$venta->propiedad()->departamentos()[0]->descripcion}</a>";
|
||||
}, $asociadas)) !!}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="ui grid">
|
||||
<div class="column">Valor</div>
|
||||
<div class="four wide column">
|
||||
{{$format->ufs($venta->formaPago()->pie->valor)}}
|
||||
@if (count($asociadas) > 0)
|
||||
[{{$format->ufs($venta->formaPago()->pie->valor + array_reduce($asociadas, function(float $sum, Incoviba\Model\Venta $venta) {
|
||||
return $sum + $venta->formaPago()->pie->valor;
|
||||
}, 0.0))}}]
|
||||
@endif
|
||||
</div>
|
||||
<div class="column">Cuotas</div>
|
||||
<div class="column">{{$venta->formaPago()->pie->cuotas}}</div>
|
||||
</div>
|
||||
<table class="ui table" id="cuotas">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -37,32 +60,37 @@
|
||||
<td>{{$cuota->pago->identificador}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuota->pago->valor)}}</td>
|
||||
<td class="right aligned">
|
||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' and $cuota->pago->currentEstado->fecha <= $now)
|
||||
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['depositado', 'abonado'])
|
||||
and $cuota->pago->currentEstado->fecha <= $now)
|
||||
{{$format->ufs($cuota->pago->valor())}}
|
||||
@else
|
||||
~{{$format->ufs($cuota->pago->valor / $uf_venta)}}
|
||||
@endif
|
||||
</td>
|
||||
<td
|
||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado')
|
||||
class="green"
|
||||
@elseif ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
||||
class="yellow"
|
||||
@elseif ($cuota->pago->currentEstado->tipoEstadoPago->activo !== 1)
|
||||
class="red"
|
||||
@endif
|
||||
>{{ucwords($cuota->pago->currentEstado->tipoEstadoPago->descripcion)}}</td>
|
||||
<td{!! ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' ? ' class="green"' :
|
||||
($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado' ? ' class="yellow"' :
|
||||
($cuota->pago->currentEstado->tipoEstadoPago->activo !== 1 ? ' class="red"' : ''))) !!}>
|
||||
{{ucwords($cuota->pago->currentEstado->tipoEstadoPago->descripcion)}}
|
||||
</td>
|
||||
<td>
|
||||
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['abonado', 'anulado', 'reemplazado']))
|
||||
{{$cuota->pago->currentEstado->fecha->format('d-m-Y')}}
|
||||
@elseif (!in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado', 'reemplazado']))
|
||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
||||
{{$cuota->pago->currentEstado->fecha->format('d-m-Y')}}
|
||||
@endif
|
||||
<div class="ui calendar fecha_estado" data-date="{{$cuota->pago->currentEstado->fecha->format('Y-m-d')}}">
|
||||
<div class="ui action left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="fecha_estado" />
|
||||
<button class="ui green basic icon button accept_estado" data-pago="{{$cuota->pago->id}}" data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->descripcion}}">
|
||||
<button class="ui green basic icon button accept_estado"
|
||||
data-pago="{{$cuota->pago->id}}"
|
||||
data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->descripcion}}">
|
||||
<i class="check icon"></i>
|
||||
</button>
|
||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
||||
<button class="ui red basic icon button reject_estado" data-pago="{{$cuota->pago->id}}">
|
||||
<button class="ui red basic icon button reject_estado"
|
||||
data-pago="{{$cuota->pago->id}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
@endif
|
||||
@ -115,7 +143,7 @@
|
||||
}, 0.0))}}
|
||||
</th>
|
||||
<th class="right aligned">
|
||||
{{$format->number($pagado / $total * 100, 2)}}%
|
||||
{{$format->number(($total > 0) ? $pagado / $total * 100 : 0, 2)}}%
|
||||
</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
@ -128,7 +156,7 @@
|
||||
{{$format->ufs($total - $pagado)}}
|
||||
</th>
|
||||
<th class="right aligned">
|
||||
{{$format->number(($total - $pagado) / $total * 100, 2)}}%
|
||||
{{$format->number(($total > 0) ? ($total - $pagado) / $total * 100 : 0, 2)}}%
|
||||
</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
@ -136,14 +164,18 @@
|
||||
</table>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.head.styles.datatables.buttons')
|
||||
@include('layout.body.scripts.datatables')
|
||||
@include('layout.body.scripts.datatables.buttons')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(() => {
|
||||
function updateRow({pago_id, fecha, color, estado, remove_fecha=false, add_reject=false, disable=false}) {
|
||||
function updateRow({pago_id, valor, fecha, color, estado, remove_fecha=false, add_reject=false, disable=false}) {
|
||||
const tr = $("tr[data-pago='" + pago_id + "']")
|
||||
|
||||
tr.find(':nth-child(6)').html(valor)
|
||||
tr.find(':nth-child(7)').attr('class', color).html(estado)
|
||||
if (remove_fecha) {
|
||||
tr.find(':nth-child(8)').html(fecha)
|
||||
@ -178,7 +210,7 @@
|
||||
if (!json.depositado) {
|
||||
return
|
||||
}
|
||||
updateRow({pago_id: json.pago_id, fecha: json.input.fecha, estado: 'Depositado', color: 'yellow', add_reject: true})
|
||||
updateRow({pago_id: json.pago_id, valor: json.pago.valor_uf, fecha: json.input.fecha, estado: 'Depositado', color: 'yellow', add_reject: true})
|
||||
button.attr('data-estado', 'depositado')
|
||||
})
|
||||
})
|
||||
@ -186,7 +218,7 @@
|
||||
function abonar(pago_id, fecha) {
|
||||
const url = '{{$urls->api}}/ventas/pago/' + pago_id + '/abonar'
|
||||
const body = new FormData()
|
||||
body.set('fecha', fecha.toISOString())
|
||||
body.set('fecha', [fecha.getFullYear(), fecha.getMonth() + 1, fecha.getDate()].join('-'))
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
@ -210,11 +242,6 @@
|
||||
return
|
||||
}
|
||||
updateRow({pago_id: json.pago_id, fecha: json.fecha, estado: 'Anulado', color: 'red', remove_fecha: true, disable: true})
|
||||
/*const tr = $("button[data-id='" + json.pago_id + "']").parent().parent()
|
||||
tr.addClass('disabled')
|
||||
tr.find(':nth-child(7)').addClass('red').html('Anulado')
|
||||
tr.find(':nth-child(8)').html(json.fecha)
|
||||
tr.find(':nth-child(9)').html('')*/
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -296,7 +323,23 @@
|
||||
order: [
|
||||
[0, 'asc'],
|
||||
[2, 'asc']
|
||||
]
|
||||
],
|
||||
layout: {
|
||||
top2End: {
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excel',
|
||||
className: 'green',
|
||||
text: 'Exportar a Excel <i class="file excel icon"></i>',
|
||||
title: 'Cuotas - {{$venta->proyecto()->descripcion}} - {{$venta->propiedad()->summary()}}',
|
||||
download: 'open',
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
@ -32,46 +32,3 @@ $showPropietario = true;
|
||||
@include('ventas.show.comentarios')
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
{{--@section('page_content')
|
||||
<div class="ui container">
|
||||
<div class="ui two column grid">
|
||||
<h1 class="four wide column header">
|
||||
<div class="content">
|
||||
<div class="ui dividing sub header">{{$venta->proyecto()->descripcion}}</div>
|
||||
{{$venta->propiedad()->summary()}}
|
||||
</div>
|
||||
</h1>
|
||||
<div class="right floated column">
|
||||
@include('ventas.show.propietario')
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="ui fitted basic mini segment">
|
||||
@if ($venta->currentEstado()->tipoEstadoVenta->activa)
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/desistir">
|
||||
Desistir <i class="minus icon"></i>
|
||||
</a>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/ceder">
|
||||
Ceder <i clasS="right chevron icon"></i>
|
||||
</a>
|
||||
@else
|
||||
<div class="ui red icon label">
|
||||
<i class="ban icon"></i>
|
||||
{{ucwords($venta->currentEstado()->tipoEstadoVenta->descripcion)}}
|
||||
(<a href="{{$urls->base}}/venta/{{$venta->id}}/desistida">
|
||||
{{$format->pesos($venta->resciliacion()->valor)}}
|
||||
</a>)
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="ui segments">
|
||||
@include('ventas.show.propiedad')
|
||||
@include('ventas.show.detalle')
|
||||
@include('ventas.show.forma_pago', ['formaPago' => $venta->formaPago()])
|
||||
@include('ventas.show.escritura')
|
||||
@include('ventas.show.entrega')
|
||||
@include('ventas.show.comentarios')
|
||||
</div>
|
||||
</div>
|
||||
@endsection--}}
|
||||
|
@ -3,14 +3,14 @@
|
||||
</div>
|
||||
<div class="ui segment">
|
||||
<table class="ui very basic fluid table">
|
||||
@include('ventas.show.forma_pago.pie', ['pie' => $formaPago->pie])
|
||||
@include('ventas.show.forma_pago.escritura', ['escritura' => $formaPago->escritura])
|
||||
@include('ventas.show.forma_pago.anticipo', ['anticipo' => ['uf' => $formaPago->anticipo(), 'pesos' => $formaPago->anticipo('pesos')]])
|
||||
@include('ventas.show.forma_pago.bono_pie', ['bonoPie' => $formaPago->bonoPie])
|
||||
@include('ventas.show.forma_pago.subsidio', ['subsidio' => $formaPago->subsidio])
|
||||
@include('ventas.show.forma_pago.credito', ['credito' => $formaPago->credito])
|
||||
@include('ventas.show.forma_pago.pie', ['pie' => $formaPago?->pie])
|
||||
@include('ventas.show.forma_pago.escritura', ['escritura' => $formaPago?->escritura])
|
||||
@include('ventas.show.forma_pago.anticipo', ['anticipo' => ['uf' => $formaPago?->anticipo(), 'pesos' => $formaPago?->anticipo('pesos')]])
|
||||
@include('ventas.show.forma_pago.bono_pie', ['bonoPie' => $formaPago?->bonoPie])
|
||||
@include('ventas.show.forma_pago.subsidio', ['subsidio' => $formaPago?->subsidio])
|
||||
@include('ventas.show.forma_pago.credito', ['credito' => $formaPago?->credito])
|
||||
@include('ventas.show.forma_pago.total')
|
||||
@include('ventas.show.forma_pago.devolucion', ['devolucion' => $formaPago->devolucion])
|
||||
@include('ventas.show.forma_pago.devolucion', ['devolucion' => $formaPago?->devolucion])
|
||||
</table>
|
||||
</div>
|
||||
<div id="pago_modal" class="ui modal">
|
||||
|
@ -16,7 +16,7 @@
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie/cuotas">
|
||||
<span data-tooltip="Pagadas">{{count($pie->cuotas(true))}}</span>/{{$pie->cuotas}}
|
||||
</a>
|
||||
@if (count($pie->cuotas()) < $pie->cuotas)
|
||||
@if (count($pie->cuotas(false, true)) < $pie->cuotas)
|
||||
<a href="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add">
|
||||
<i class="plus icon"></i>
|
||||
</a>
|
||||
|
@ -50,7 +50,7 @@
|
||||
</td>
|
||||
<td class="right aligned">
|
||||
@if ($unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento')
|
||||
{{$format->number(($unidad->valor ?? $precio) / $unidad->proyectoTipoUnidad->vendible(), 2)}} UF/m²
|
||||
{{$format->number((($unidad->valor === null or $unidad->valor === 0.0) ? $precio : $unidad->valor) / $unidad->proyectoTipoUnidad->vendible(), 2)}} UF/m²
|
||||
@endif
|
||||
</td>
|
||||
<td class="center aligned">
|
||||
|
@ -1,2 +1,2 @@
|
||||
<?php
|
||||
//$app->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
$app->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
|
2
app/setup/middlewares/96_cors.php
Normal file
2
app/setup/middlewares/96_cors.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$app->add($app->getContainer()->get(Incoviba\Middleware\CORS::class));
|
@ -8,7 +8,8 @@ return [
|
||||
'cache' => DI\String('{base}/cache'),
|
||||
'templates' => DI\String('{resources}/views'),
|
||||
'public' => DI\String('{base}/public'),
|
||||
'uploads' => DI\String('{public}/uploads')
|
||||
'uploads' => DI\String('{public}/uploads'),
|
||||
'informes' => DI\String('{public}/informes')
|
||||
]);
|
||||
}
|
||||
];
|
||||
|
@ -4,10 +4,10 @@ use Psr\Container\ContainerInterface;
|
||||
return [
|
||||
Incoviba\Common\Define\Database::class => function(ContainerInterface $container) {
|
||||
return new Incoviba\Common\Implement\Database\MySQL(
|
||||
$container->has('MYSQL_HOST') ? $container->get('MYSQL_HOST') : 'db',
|
||||
$container->get('MYSQL_DATABASE'),
|
||||
$container->get('MYSQL_USER'),
|
||||
$container->get('MYSQL_PASSWORD')
|
||||
$container->has('DB_HOST') ? $container->get('DB_HOST') : 'db',
|
||||
$container->get('DB_DATABASE'),
|
||||
$container->get('DB_USER'),
|
||||
$container->get('DB_PASSWORD')
|
||||
);
|
||||
},
|
||||
Incoviba\Common\Define\Connection::class => function(ContainerInterface $container) {
|
||||
|
@ -4,18 +4,6 @@ use Psr\Container\ContainerInterface;
|
||||
return [
|
||||
Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
|
||||
return new Monolog\Logger('incoviba', [
|
||||
new Monolog\Handler\FilterHandler(
|
||||
(new Monolog\Handler\RotatingFileHandler('/logs/debug.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
Monolog\Level::Debug,
|
||||
Monolog\Level::Debug
|
||||
),
|
||||
new Monolog\Handler\FilterHandler(
|
||||
(new Monolog\Handler\RotatingFileHandler('/logs/info.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
Monolog\Level::Info,
|
||||
Monolog\Level::Warning,
|
||||
),
|
||||
new Monolog\Handler\FilterHandler(
|
||||
(new Monolog\Handler\RotatingFileHandler('/logs/error.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
@ -26,6 +14,17 @@ return [
|
||||
(new Monolog\Handler\RotatingFileHandler('/logs/critical.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
Monolog\Level::Critical
|
||||
),
|
||||
new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\RedisHandler($container->get(Predis\ClientInterface::class), 'logs:notices'),
|
||||
Monolog\Level::Notice,
|
||||
Monolog\Level::Warning
|
||||
),
|
||||
new Monolog\Handler\FilterHandler(
|
||||
(new Incoviba\Common\Implement\Log\MySQLHandler($container->get(Incoviba\Common\Define\Connection::class)))
|
||||
->setFormatter(new Incoviba\Common\Implement\Log\PDOFormatter()),
|
||||
Monolog\Level::Debug,
|
||||
Monolog\Level::Warning
|
||||
)
|
||||
], [
|
||||
$container->get(Monolog\Processor\PsrLogMessageProcessor::class),
|
||||
|
@ -14,6 +14,7 @@ return [
|
||||
Incoviba\Middleware\API::class => function(ContainerInterface $container) {
|
||||
return new Incoviba\Middleware\API(
|
||||
$container->get(Psr\Http\Message\ResponseFactoryInterface::class),
|
||||
$container->get(Incoviba\Service\Login::class),
|
||||
$container->get('API_KEY')
|
||||
);
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ return [
|
||||
$container->get('COOKIE_NAME'),
|
||||
$container->get('MAX_LOGIN_HOURS'),
|
||||
$container->has('COOKIE_DOMAIN') ? $container->get('COOKIE_DOMAIN') : '',
|
||||
$container->has('COOKIE_PATH') ? $container->get('COOKIE_PATH') : ''
|
||||
$container->has('COOKIE_PATH') ? $container->get('COOKIE_PATH') : '',
|
||||
$container->has('COOKIE_SEPARATOR') ? $container->get('COOKIE_SEPARATOR') : 'g'
|
||||
);
|
||||
},
|
||||
Incoviba\Service\Money::class => function(ContainerInterface $container) {
|
||||
@ -20,38 +21,63 @@ return [
|
||||
$ine = new Incoviba\Service\Money\Ine(new GuzzleHttp\Client([
|
||||
'base_uri' => 'https://api-calculadora.ine.cl/ServiciosCalculadoraVariacion'
|
||||
]));
|
||||
return (new Incoviba\Service\Money())->register('uf', $mindicador)
|
||||
return (new Incoviba\Service\Money($container->get(Psr\Log\LoggerInterface::class)))
|
||||
->register('uf', $mindicador)
|
||||
->register('usd', $mindicador)
|
||||
->register('ipc', $ine);
|
||||
},
|
||||
Predis\Client::class => function(ContainerInterface $container) {
|
||||
Predis\ClientInterface::class => function(ContainerInterface $container) {
|
||||
return new Predis\Client([
|
||||
'scheme' => 'tcp',
|
||||
'host' => $container->get('REDIS_HOST'),
|
||||
'port' => $container->get('REDIS_PORT')
|
||||
]);
|
||||
},
|
||||
Incoviba\Service\Cartola::class => function(ContainerInterface $container) {
|
||||
return (new Incoviba\Service\Cartola(
|
||||
Incoviba\Service\Contabilidad\Cartola::class => function(ContainerInterface $container) {
|
||||
return (new Incoviba\Service\Contabilidad\Cartola(
|
||||
$container->get(Psr\Log\LoggerInterface::class),
|
||||
$container->get(Psr\Http\Message\StreamFactoryInterface::class),
|
||||
$container->get(Incoviba\Common\Define\Contabilidad\Exporter::class)
|
||||
$container->get(Incoviba\Common\Define\Contabilidad\Exporter::class),
|
||||
$container->get(Incoviba\Repository\Inmobiliaria::class),
|
||||
$container->get(Incoviba\Repository\Inmobiliaria\Cuenta::class),
|
||||
$container->get(Incoviba\Repository\Contabilidad\Movimiento::class),
|
||||
$container->get(Incoviba\Service\Contabilidad\Movimiento::class),
|
||||
$container->get(Incoviba\Repository\Contabilidad\Cartola::class)
|
||||
))
|
||||
->register('security', $container->get(Incoviba\Service\Cartola\Security::class))
|
||||
->register('itau', $container->get(Incoviba\Service\Cartola\Itau::class))
|
||||
->register('santander', $container->get(Incoviba\Service\Cartola\Santander::class));
|
||||
->register('security', $container->get(Incoviba\Service\Contabilidad\Cartola\Security::class))
|
||||
->register('itau', $container->get(Incoviba\Service\Contabilidad\Cartola\Itau::class))
|
||||
->register('santander', $container->get(Incoviba\Service\Contabilidad\Cartola\Santander::class))
|
||||
->register('bci', $container->get(Incoviba\Service\Contabilidad\Cartola\BCI::class));
|
||||
},
|
||||
Incoviba\Common\Define\Contabilidad\Exporter::class => function(ContainerInterface $container) {
|
||||
return $container->get(Incoviba\Service\Contabilidad\Exporter\Nubox::class);
|
||||
},
|
||||
Incoviba\Service\Contabilidad\Exporter\Nubox::class => function(ContainerInterface $container) {
|
||||
return new Incoviba\Service\Contabilidad\Exporter\Nubox($container->get(Incoviba\Repository\CentroCosto::class),
|
||||
return new Incoviba\Service\Contabilidad\Exporter\Nubox($container->get(Incoviba\Repository\Contabilidad\CentroCosto::class),
|
||||
$container->get('folders')->get('uploads'));
|
||||
},
|
||||
Incoviba\Service\Contabilidad\Nubox::class => function(ContainerInterface $container) {
|
||||
return new Incoviba\Service\Contabilidad\Nubox(
|
||||
$container->get(Incoviba\Repository\Nubox::class),
|
||||
$container->get(Psr\Log\LoggerInterface::class),
|
||||
$container->get(Incoviba\Repository\Contabilidad\Nubox::class),
|
||||
$container->get(Incoviba\Service\Redis::class),
|
||||
new GuzzleHttp\Client(),
|
||||
$container->get(Psr\Http\Message\RequestFactoryInterface::class),
|
||||
$container->get('nubox')->get('url'));
|
||||
},
|
||||
Incoviba\Service\Informe::class => function(ContainerInterface $container) {
|
||||
return (new Incoviba\Service\Informe(
|
||||
$container->get(Psr\Log\LoggerInterface::class),
|
||||
$container->get('folders')->get('informes'))
|
||||
)
|
||||
->register('xlsx', Incoviba\Service\Informe\Excel::class);
|
||||
},
|
||||
Incoviba\Service\Contabilidad\Informe\Tesoreria\Excel::class => function(ContainerInterface $container) {
|
||||
return new Incoviba\Service\Contabilidad\Informe\Tesoreria\Excel(
|
||||
$container->get(Psr\Log\LoggerInterface::class),
|
||||
$container->get('folders')->get('informes'),
|
||||
$container->get(Incoviba\Service\UF::class),
|
||||
$container->get(Incoviba\Service\USD::class)
|
||||
);
|
||||
}
|
||||
];
|
||||
|
@ -11,7 +11,9 @@ return [
|
||||
'format' => $container->get(Incoviba\Service\Format::class),
|
||||
'API_KEY' => $container->get('API_KEY'),
|
||||
'UF' => $container->get(Incoviba\Service\UF::class),
|
||||
'IPC' => $container->get(Incoviba\Service\IPC::class)
|
||||
'USD' => $container->get(Incoviba\Service\USD::class),
|
||||
'IPC' => $container->get(Incoviba\Service\IPC::class),
|
||||
'hoy' => new DateTimeImmutable()
|
||||
];
|
||||
if ($global_variables['login']->isIn()) {
|
||||
$global_variables['user'] = $global_variables['login']->getUser();
|
||||
|
20
app/src/Controller/API/Base.php
Normal file
20
app/src/Controller/API/Base.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
|
||||
class Base extends Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'version' => '2.0.0',
|
||||
'organization' => 'Ingenieria y Construccion Vial Balmaceda Sociedad Anonima'
|
||||
];
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
@ -2,51 +2,16 @@
|
||||
namespace Incoviba\Controller\API;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Contabilidad
|
||||
class Contabilidad extends Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function procesarCartola(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'movimientos' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria']);
|
||||
$banco = $bancoRepository->fetchById($body['banco']);
|
||||
$mes = new DateTimeImmutable($body['mes']);
|
||||
$file = $request->getUploadedFiles()['file'];
|
||||
$output['movimientos'] = $cartolaService->process($inmobiliaria, $banco, $mes, $file);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function exportarCartola(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'filename' => ''
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria']);
|
||||
$banco = $bancoRepository->fetchById($body['banco']);
|
||||
$mes = new DateTimeImmutable($body['mes']);
|
||||
$output['filename'] = $cartolaService->export($inmobiliaria, $banco, $mes, json_decode($body['movimientos']));
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
|
||||
}
|
||||
|
98
app/src/Controller/API/Contabilidad/Cartolas.php
Normal file
98
app/src/Controller/API/Contabilidad/Cartolas.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Cartolas extends Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function procesar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Contabilidad\Banco $bancoRepository,
|
||||
Service\Contabilidad\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'movimientos' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria']);
|
||||
$banco = $bancoRepository->fetchById($body['banco']);
|
||||
$mes = new DateTimeImmutable($body['mes']);
|
||||
$file = $request->getUploadedFiles()['file'];
|
||||
$output['movimientos'] = $cartolaService->process($inmobiliaria, $banco, $mes, $file);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function exportar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Contabilidad\Banco $bancoRepository,
|
||||
Service\Contabilidad\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'filename' => ''
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria']);
|
||||
$banco = $bancoRepository->fetchById($body['banco']);
|
||||
$mes = new DateTimeImmutable($body['mes']);
|
||||
$output['filename'] = $cartolaService->export($inmobiliaria, $banco, $mes, json_decode($body['movimientos']));
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function diaria(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Service\Contabilidad\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'cartolas' => []
|
||||
];
|
||||
$fields = json_decode($body['fields']);
|
||||
foreach ($fields as $field) {
|
||||
try {
|
||||
$cuenta = $cuentaRepository->fetchById($body["cuenta_id{$field}"]);
|
||||
$fecha = new DateTimeImmutable($body["fecha{$field}"]);
|
||||
if (array_key_exists("manual{$field}", $body)) {
|
||||
$file = json_decode($body["file{$field}"], JSON_OBJECT_AS_ARRAY);
|
||||
$output['cartolas'][$field] = $cartolaService->diariaManual($cuenta, $fecha, $file);
|
||||
continue;
|
||||
}
|
||||
$file = $request->getUploadedFiles()["file{$field}"];
|
||||
|
||||
$output['cartolas'][$field] = $cartolaService->diaria($cuenta, $fecha, $file);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->debug($exception);
|
||||
}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function ayer(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Contabilidad\Cartola $cartolaRepository): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'cartola' => []
|
||||
];
|
||||
try {
|
||||
$cuenta = $cuentaRepository->fetchById($body['cuenta_id']);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$output['cartola'] = $cartolaRepository->fetchByCuentaAndFecha($cuenta->id, $fecha);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
@ -1,17 +1,18 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API;
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class CentrosCostos
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\CentroCosto $centroCostoRepository): ResponseInterface
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
@ -26,8 +27,8 @@ class CentrosCostos
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
@ -45,8 +46,8 @@ class CentrosCostos
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function remove(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
|
||||
public function remove(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'centro_costo_id' => $centro_costo_id,
|
68
app/src/Controller/API/Contabilidad/Depositos.php
Normal file
68
app/src/Controller/API/Contabilidad/Depositos.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Depositos extends Ideal\Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function inmobiliaria(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Contabilidad\Banco $bancoRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Contabilidad\Deposito $dapRepository,
|
||||
int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'depositos' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($inmobiliaria_rut);
|
||||
$cuentas = $cuentaRepository->fetchByInmobiliaria($inmobiliaria->rut);
|
||||
foreach ($cuentas as $cuenta) {
|
||||
$output['depositos'] = $dapRepository->fetchByCuenta($cuenta->id);
|
||||
}
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository, Repository\Contabilidad\Banco $bancoRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Contabilidad\Deposito $dapRepository): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'status' => false
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria_rut']);
|
||||
$banco = $bancoRepository->fetchById($body['banco_id']);
|
||||
$cuenta = $cuentaRepository->fetchByInmobiliariaAndBanco($inmobiliaria->rut, $banco->id);
|
||||
$data = [
|
||||
'id' => $body['id'],
|
||||
'cuenta_id' => $cuenta->id,
|
||||
'capital' => $body['capital'],
|
||||
'futuro' => $body['futuro'],
|
||||
'inicio' => (new DateTimeImmutable($body['inicio']))->format('Y-m-d'),
|
||||
'termino' => (new DateTimeImmutable($body['termino']))->format('Y-m-d')
|
||||
];
|
||||
try {
|
||||
$dapRepository->fetchById($body['id']);
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
$dap = $dapRepository->create($data);
|
||||
$dapRepository->save($dap);
|
||||
}
|
||||
$output['status'] = true;
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
50
app/src/Controller/API/Contabilidad/Movimientos.php
Normal file
50
app/src/Controller/API/Contabilidad/Movimientos.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Movimientos extends Ideal\Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function detalles(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Contabilidad\Movimiento $movimientoService,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository, int $movimiento_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'movimiento_id' => $movimiento_id,
|
||||
'input' => $body,
|
||||
'status' => false,
|
||||
'movimiento' => null,
|
||||
'centro' => null,
|
||||
'detalle' => ''
|
||||
];
|
||||
try {
|
||||
$movimiento = $movimientoService->getById($movimiento_id);
|
||||
$output['movimiento'] = $movimiento;
|
||||
$data = [];
|
||||
if (isset($body['centro_id'])) {
|
||||
$centro = $centroCostoRepository->fetchById($body['centro_id']);
|
||||
$data['centro_costo_id'] = $centro->id;
|
||||
}
|
||||
if (isset($body['detalle'])) {
|
||||
$data['detalle'] = $body['detalle'];
|
||||
}
|
||||
$movimientoService->setDetalles($movimiento, $data);
|
||||
if (isset($body['centro_id'])) {
|
||||
$output['centro'] = $centro;
|
||||
}
|
||||
if (isset($body['detalle'])) {
|
||||
$output['detalle'] = $body['detalle'];
|
||||
}
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API;
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Implement\Exception\HttpResponse;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\HttpResponse;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Nubox
|
||||
{
|
@ -12,6 +12,16 @@ class Inmobiliarias
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'inmobiliarias' => []
|
||||
];
|
||||
try {
|
||||
$output['inmobiliarias'] = $inmobiliariaRepository->fetchAll('razon');
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function cuentas(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository, int $inmobiliaria_rut): ResponseInterface
|
||||
@ -45,4 +55,29 @@ class Inmobiliarias
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function agentes(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Inmobiliaria\SociedadAgente $sociedadAgenteRepository,
|
||||
Repository\Inmobiliaria\TipoAgente $tipoAgenteRepository,
|
||||
int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
$output = [
|
||||
'sociedad_rut' => $inmobiliaria_rut,
|
||||
'input' => $input,
|
||||
'sociedad' => null,
|
||||
'agentes' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($inmobiliaria_rut);
|
||||
$output['sociedad'] = $inmobiliaria;
|
||||
if (isset($input['tipo_agente_id'])) {
|
||||
$tipo = $tipoAgenteRepository->fetchById($input['tipo_agente_id']);
|
||||
$output['agentes'] = $sociedadAgenteRepository->fetchBySociedadAndTipo($inmobiliaria->rut, $tipo->id);
|
||||
} else {
|
||||
$output['agentes'] = $sociedadAgenteRepository->fetchBySociedad($inmobiliaria->rut);
|
||||
}
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
||||
|
90
app/src/Controller/API/Inmobiliarias/Agentes.php
Normal file
90
app/src/Controller/API/Inmobiliarias/Agentes.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Inmobiliarias;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
|
||||
class Agentes
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Repository\Inmobiliaria\Agente $agenteRepository): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'agentes' => []
|
||||
];
|
||||
try {
|
||||
$output['agentes'] = $agenteRepository->fetchAll('abreviacion');
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response, Repository\Inmobiliaria\Agente $agenteRepository): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $input,
|
||||
'agente' => null
|
||||
];
|
||||
try {
|
||||
$agente = $agenteRepository->create($input);
|
||||
$output['agente'] = $agenteRepository->save($agente);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria\Agente $agenteRepository, int $agente_id): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
$output = [
|
||||
'agente_id' => $agente_id,
|
||||
'input' => $input,
|
||||
'agente' => null
|
||||
];
|
||||
try {
|
||||
$agente = $agenteRepository->fetchById($agente_id);
|
||||
$output['agente'] = $agenteRepository->edit($agente, $input);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function register(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Inmobiliaria\Agente $agenteRepository,
|
||||
Repository\Inmobiliaria\TipoAgente $tipoAgenteRepository,
|
||||
Repository\Inmobiliaria\AgenteTipo $agenteTipoRepository,
|
||||
Repository\Inmobiliaria\SociedadAgente $sociedadAgenteRepository): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $input,
|
||||
'sociedad' => null,
|
||||
'agente' => null,
|
||||
'tipo_agente' => null,
|
||||
'sociedad_agente' => null
|
||||
];
|
||||
try {
|
||||
$sociedad = $inmobiliariaRepository->fetchById($input['sociedad_rut']);
|
||||
$output['sociedad'] = $sociedad;
|
||||
$agente = $agenteRepository->fetchById($input['agente_id']);
|
||||
$output['agente'] = $agente;
|
||||
$tipo = $tipoAgenteRepository->fetchById($input['tipo_agente_id']);
|
||||
$output['tipo_agente'] = $tipo;
|
||||
$agenteTipo = $agenteTipoRepository->fetchByAgenteAndTipo($agente->id, $tipo->id);
|
||||
try {
|
||||
$output['sociedad_agente'] = $sociedadAgenteRepository->fetchBySociedadAndAgenteAndTipo($sociedad->rut, $agente->id, $tipo->id);
|
||||
} catch (EmptyResult) {
|
||||
$data = [
|
||||
'sociedad_rut' => $sociedad->rut,
|
||||
'agente_tipo_id' => $agenteTipo->id
|
||||
];
|
||||
$sociedadAgente = $sociedadAgenteRepository->create($data);
|
||||
$output['sociedad_agente'] = $sociedadAgenteRepository->save($sociedadAgente);
|
||||
}
|
||||
} catch (EmptyResult) {
|
||||
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
@ -3,11 +3,13 @@ namespace Incoviba\Controller\API;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Controller\withRedis;
|
||||
use Incoviba\Common\Implement\Exception;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Search
|
||||
{
|
||||
use withJson;
|
||||
use withJson, withRedis;
|
||||
|
||||
public function query(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Search $service): ResponseInterface
|
||||
@ -17,4 +19,155 @@ class Search
|
||||
$output = compact('results');
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function unidad(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||
Service\Venta\Unidad $unidadService, int $unidad_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'unidad_id' => $unidad_id,
|
||||
'unidad' => null
|
||||
];
|
||||
$redisKey = "search:unidad:{$unidad_id}";
|
||||
try {
|
||||
$output['unidad'] = $this->fetchRedis($redisService, $redisKey);
|
||||
} catch (Exception\EmptyRedis) {
|
||||
try {
|
||||
$unidad = $unidadService->getByIdForSearch($unidad_id);
|
||||
$output['unidad'] = [
|
||||
'id' => $unidad['id'],
|
||||
'descripcion' => $unidad['descripcion'],
|
||||
'proyecto_tipo_unidad' => [
|
||||
'proyecto' => [
|
||||
'id' => $unidad['proyecto_id'],
|
||||
'descripcion' => $unidad['proyecto_descripcion']
|
||||
],
|
||||
'tipo_unidad' => [
|
||||
'descripcion' => $unidad['tipo_unidad_descripcion']
|
||||
],
|
||||
'superficie' => $unidad['superficie']
|
||||
],
|
||||
'current_precio' => [
|
||||
'valor' => $unidad['precio']
|
||||
]
|
||||
];
|
||||
$this->saveRedis($redisService, $redisKey, $output['unidad']);
|
||||
} catch (Exception\EmptyResult) {}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function unidades(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||
Service\Venta\Unidad $unidadService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'unidades' => []
|
||||
];
|
||||
$unidades = explode(',', $body['unidades']);
|
||||
foreach ($unidades as $unidad_id) {
|
||||
$redisKey = "search:unidad:{$unidad_id}";
|
||||
try {
|
||||
$output['unidades'] []= $this->fetchRedis($redisService, $redisKey);
|
||||
} catch (Exception\EmptyRedis) {
|
||||
try {
|
||||
$unidad = $unidadService->getByIdForSearch($unidad_id);
|
||||
$unidad = [
|
||||
'id' => $unidad['id'],
|
||||
'descripcion' => $unidad['descripcion'],
|
||||
'proyecto_tipo_unidad' => [
|
||||
'proyecto' => [
|
||||
'id' => $unidad['proyecto_id'],
|
||||
'descripcion' => $unidad['proyecto_descripcion']
|
||||
],
|
||||
'tipo_unidad' => [
|
||||
'descripcion' => $unidad['tipo_unidad_descripcion']
|
||||
],
|
||||
'superficie' => $unidad['superficie']
|
||||
],
|
||||
'current_precio' => [
|
||||
'valor' => $unidad['precio']
|
||||
]
|
||||
];
|
||||
$output['unidades'] []= $unidad;
|
||||
$this->saveRedis($redisService, $redisKey, $unidad);
|
||||
} catch (Exception\EmptyResult) {}
|
||||
}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function venta(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||
Service\Venta $ventaService, int $venta_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'venta_id' => $venta_id,
|
||||
'venta' => null
|
||||
];
|
||||
$redisKey = "search:venta:{$venta_id}";
|
||||
try {
|
||||
$output['venta'] = $this->fetchRedis($redisService, $redisKey);
|
||||
} catch (Exception\EmptyRedis) {
|
||||
try {
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
/*$output['venta'] = [
|
||||
'id' => $venta->id,
|
||||
''
|
||||
];*/
|
||||
$output['venta'] = $venta;
|
||||
$this->saveRedis($redisService, $redisKey, $output['venta']);
|
||||
} catch (Exception\EmptyResult) {}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function ventas(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||
Service\Venta $ventaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'ventas' => []
|
||||
];
|
||||
$ventas = explode(',', $body['ventas']);
|
||||
foreach ($ventas as $venta_id) {
|
||||
$redisKey = "search:venta:{$venta_id}";
|
||||
try {
|
||||
$output['ventas'] []= $this->fetchRedis($redisService, $redisKey);
|
||||
} catch (Exception\EmptyRedis) {
|
||||
try {
|
||||
$venta = $ventaService->getByIdForSearch($venta_id);
|
||||
$venta = [
|
||||
'id' => $venta['id'],
|
||||
'proyecto' => [
|
||||
'id' => $venta['proyecto_id'],
|
||||
'descripcion' => $venta['proyecto_descripcion']
|
||||
],
|
||||
'propietario' => [
|
||||
'nombre_completo' => $venta['propietario']
|
||||
],
|
||||
'propiedad' => [
|
||||
'unidades' => [
|
||||
[
|
||||
'descripcion' => $venta['unidad_descripcion'],
|
||||
'proyecto_tipo_unidad' => [
|
||||
'tipo_unidad' => [
|
||||
'descripcion' => $venta['tipo_unidad_descripcion']
|
||||
],
|
||||
'superficie' => $venta['superficie']
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'fecha' => $venta['fecha'],
|
||||
'current_estado' => [
|
||||
'tipo_estado_venta' => [
|
||||
'activa' => $venta['activa']
|
||||
]
|
||||
],
|
||||
'valor' => $venta['valor']
|
||||
];
|
||||
$output['ventas'] []= $venta;
|
||||
$this->saveRedis($redisService, $redisKey, json_encode($venta));
|
||||
} catch (Exception\EmptyResult) {}
|
||||
}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,32 @@ class Ventas extends Controller
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function getMany(ServerRequestInterface $request, ResponseInterface $response, Service\Redis $redisService,
|
||||
Service\Venta $service): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'ventas' => []
|
||||
];
|
||||
$ventas = explode(',', $body['ventas']);
|
||||
foreach ($ventas as $venta_id) {
|
||||
$redisKey = "venta:{$venta_id}";
|
||||
try {
|
||||
$venta = $this->fetchRedis($redisService, $redisKey);
|
||||
$output['ventas'] []= $venta;
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$venta = $service->getById($venta_id);
|
||||
$output['ventas'] []= $venta;
|
||||
$this->saveRedis($redisService, $redisKey, $venta);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->notice($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function porFirmar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService, Service\Redis $redisService): ResponseInterface
|
||||
{
|
||||
$body = $request->getBody();
|
||||
|
31
app/src/Controller/API/Ventas/Creditos.php
Normal file
31
app/src/Controller/API/Ventas/Creditos.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Ventas;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Creditos extends Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
||||
Service\Venta\Credito $creditoService, int $venta_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'credito' => null,
|
||||
'status' => false
|
||||
];
|
||||
try {
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
$output['credito'] = $creditoService->edit($venta->formaPago()->credito, $body);
|
||||
$output['status'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
@ -13,6 +13,50 @@ class Escrituras
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Venta $ventaRepository, Service\Venta $ventaService,
|
||||
Repository\Venta\Escritura $escrituraRepository, Service\Venta\Pago $pagoService,
|
||||
Service\UF $ufService, int $venta_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'venta_id' => $venta_id,
|
||||
'input' => $body,
|
||||
'status' => false
|
||||
];
|
||||
try {
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
if (isset($venta->formaPago()->escritura)) {
|
||||
throw new EmptyResult('');
|
||||
}
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$uf = $ufService->get($fecha);
|
||||
$valor = $body['valor'];
|
||||
if (str_contains($valor, ',')) {
|
||||
$valor = str_replace(['.', ','], ['', '.'], $valor);
|
||||
}
|
||||
$valor = ((float) $valor) * (($body['uf']) ? $uf : 1);
|
||||
$data = [
|
||||
'fecha' => $fecha->format('Y-m-d'),
|
||||
'valor' => $valor,
|
||||
'banco' => $body['banco'],
|
||||
'tipo' => $body['tipo'],
|
||||
'uf' => $uf
|
||||
];
|
||||
$pago = $pagoService->add($data);
|
||||
$data = [
|
||||
'valor' => $valor,
|
||||
'fecha' => $fecha->format('Y-m-d'),
|
||||
'uf' => $uf,
|
||||
'pago' => $pago->id
|
||||
];
|
||||
$escritura = $escrituraRepository->create($data);
|
||||
$escrituraRepository->save($escritura);
|
||||
$ventaRepository->edit($venta, ['escritura' => $escritura->id]);
|
||||
$output['status'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta $ventaService, Repository\Venta\EstadoVenta $estadoVentaRepository,
|
||||
int $venta_id): ResponseInterface
|
||||
|
@ -13,6 +13,19 @@ class Pagos
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function get(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService,
|
||||
Service\Format $formatService, int $pago_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'pago_id' => $pago_id,
|
||||
'pago' => null
|
||||
];
|
||||
try {
|
||||
$output['pago'] = json_decode(json_encode($pagoService->getById($pago_id)), JSON_OBJECT_AS_ARRAY);
|
||||
$output['pago']['valor_uf'] = $formatService->ufs($output['pago']['valor_uf']);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Pago $pagoRepository, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
@ -31,33 +44,41 @@ class Pagos
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function depositar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService, int $pago_id): ResponseInterface
|
||||
public function depositar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta\Pago $pagoService, Service\Format $formatService, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'pago_id' => $pago_id,
|
||||
'input' => $body,
|
||||
'pago' => null,
|
||||
'depositado' => false
|
||||
];
|
||||
try {
|
||||
$pago = $pagoService->getById($pago_id);
|
||||
$fecha = new DateTimeImmutable($body->fecha);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$output['depositado'] = $pagoService->depositar($pago, $fecha);
|
||||
$output['pago'] = json_decode(json_encode($pagoService->getById($pago_id)), JSON_OBJECT_AS_ARRAY);
|
||||
$output['pago']['valor_uf'] = $formatService->ufs($output['pago']['valor_uf']);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService, int $pago_id): ResponseInterface
|
||||
public function abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService,
|
||||
Service\Format $formatService, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'pago_id' => $pago_id,
|
||||
'input' => $body,
|
||||
'pago' => null,
|
||||
'abonado' => false
|
||||
];
|
||||
try {
|
||||
$pago = $pagoService->getById($pago_id);
|
||||
$fecha = new DateTimeImmutable($body->fecha);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$output['abonado'] = $pagoService->abonar($pago, $fecha);
|
||||
$output['pago'] = json_decode(json_encode($pagoService->getById($pago_id)), JSON_OBJECT_AS_ARRAY);
|
||||
$output['pago']['valor_uf'] = $formatService->ufs($output['pago']['valor_uf']);
|
||||
$output['input']['fecha'] = $fecha->format('d-m-Y');
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Common\Alias\View;
|
||||
|
||||
class CentrosCostos
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Repository\CentroCosto $centroCostoRepository,
|
||||
Repository\TipoCentro $tipoCentroRepository,
|
||||
Repository\CategoriaCentro $categoriaCentroRepository,
|
||||
Repository\TipoCuenta $tipoCuentaRepository): ResponseInterface
|
||||
{
|
||||
$centrosCostos = $centroCostoRepository->fetchAll();
|
||||
$tiposCentros = $tipoCentroRepository->fetchAll();
|
||||
$categorias = $categoriaCentroRepository->fetchAll('descripcion');
|
||||
$tiposCuentas = $tipoCuentaRepository->fetchAll();
|
||||
return $view->render($response, 'contabilidad.centros_costos', compact('centrosCostos',
|
||||
'tiposCentros', 'categorias', 'tiposCuentas'));
|
||||
}
|
||||
public function asignar(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Repository\CentroCosto $centroCostoRepository,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||||
{
|
||||
$centrosCostos = $centroCostoRepository->fetchAll();
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAllActive('razon');
|
||||
return $view->render($response, 'contabilidad.centros_costos.asignar', compact('centrosCostos', 'inmobiliarias'));
|
||||
}
|
||||
}
|
93
app/src/Controller/Contabilidad.php
Normal file
93
app/src/Controller/Contabilidad.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller;
|
||||
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Common\Implement\Exception\{EmptyRedis, EmptyResult};
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Contabilidad extends Controller
|
||||
{
|
||||
use withRedis;
|
||||
|
||||
public function diaria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Redis $redisService,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository): ResponseInterface
|
||||
{
|
||||
$redisKey = 'inmobiliarias';
|
||||
$inmobiliarias = [];
|
||||
try {
|
||||
$inmobiliarias = $this->fetchRedis($redisService, $redisKey);
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAll('razon');
|
||||
$this->saveRedis($redisService, $redisKey, $inmobiliarias, 30 * 24 * 60 * 60);
|
||||
} catch (EmptyResult) {}
|
||||
}
|
||||
$centrosCostos = $centroCostoRepository->fetchAll();
|
||||
return $view->render($response, 'contabilidad.cartolas.diaria', compact('inmobiliarias', 'centrosCostos'));
|
||||
}
|
||||
public function depositos(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Redis $redisService,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Contabilidad\Deposito $dapRepository): ResponseInterface
|
||||
{
|
||||
$redisKey = 'inmobiliarias';
|
||||
$inmobiliarias = [];
|
||||
try {
|
||||
$inmobiliarias = $this->fetchRedis($redisService, $redisKey);
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAll();
|
||||
$this->saveRedis($redisService, $redisKey, $inmobiliarias, 30 * 24 * 60 * 60);
|
||||
} catch (EmptyResult) {}
|
||||
}
|
||||
$depositos = [];
|
||||
try {
|
||||
$depositos = $dapRepository->fetchAll();
|
||||
} catch (EmptyResult) {}
|
||||
$fecha = new DateTimeImmutable('today');
|
||||
$activos = array_filter($depositos, function(Model\Contabilidad\Deposito $deposito) use ($fecha) {
|
||||
return $deposito->termino >= $fecha;
|
||||
});
|
||||
$mes = $fecha->sub(new DateInterval('P1M'));
|
||||
$vencidos = array_filter($depositos, function(Model\Contabilidad\Deposito $deposito) use ($fecha, $mes) {
|
||||
return $deposito->termino < $fecha and $deposito->termino >= $mes;
|
||||
});
|
||||
return $view->render($response, 'contabilidad.depositos', compact('inmobiliarias', 'activos', 'vencidos'));
|
||||
}
|
||||
public function tesoreria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Contabilidad\Informe\Tesoreria $contabilidadService,
|
||||
string $fecha = 'today'): ResponseInterface
|
||||
{
|
||||
$fecha = new DateTimeImmutable($fecha);
|
||||
$anterior = $contabilidadService->getAnterior($fecha);
|
||||
$yesterday = new DateTimeImmutable('yesterday');
|
||||
$siguiente = null;
|
||||
if ($yesterday >= $fecha) {
|
||||
$siguiente = $fecha->add(new DateInterval('P1D'));
|
||||
if ($siguiente->format('N') === '6') {
|
||||
$siguiente = $fecha->add(new DateInterval('P3D'));
|
||||
}
|
||||
}
|
||||
$informes = $contabilidadService->build($fecha);
|
||||
$filename = "Informe de Tesorería {$fecha->format('d.m.Y')}";
|
||||
return $view->render($response, 'contabilidad.informes.tesoreria', compact('fecha', 'anterior', 'siguiente', 'informes', 'filename'));
|
||||
}
|
||||
public function cuadratura(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||||
{
|
||||
$inmobiliarias = [];
|
||||
try {
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAll('razon');
|
||||
} catch (EmptyResult) {}
|
||||
return $view->render($response, 'contabilidad.cuadratura', compact('inmobiliarias'));
|
||||
}
|
||||
}
|
32
app/src/Controller/Contabilidad/CentrosCostos.php
Normal file
32
app/src/Controller/Contabilidad/CentrosCostos.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Contabilidad;
|
||||
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Repository;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class CentrosCostos
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository,
|
||||
Repository\Contabilidad\TipoCentro $tipoCentroRepository,
|
||||
Repository\Contabilidad\CategoriaCentro $categoriaCentroRepository,
|
||||
Repository\TipoCuenta $tipoCuentaRepository): ResponseInterface
|
||||
{
|
||||
$centrosCostos = $centroCostoRepository->fetchAll();
|
||||
$tiposCentros = $tipoCentroRepository->fetchAll();
|
||||
$categorias = $categoriaCentroRepository->fetchAll('descripcion');
|
||||
$tiposCuentas = $tipoCuentaRepository->fetchAll();
|
||||
return $view->render($response, 'contabilidad.centros_costos', compact('centrosCostos',
|
||||
'tiposCentros', 'categorias', 'tiposCuentas'));
|
||||
}
|
||||
public function asignar(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||||
{
|
||||
$centrosCostos = $centroCostoRepository->fetchAll();
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAllActive('razon');
|
||||
return $view->render($response, 'contabilidad.centros_costos.asignar', compact('centrosCostos', 'inmobiliarias'));
|
||||
}
|
||||
}
|
20
app/src/Controller/Contabilidad/Informes.php
Normal file
20
app/src/Controller/Contabilidad/Informes.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Contabilidad;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Informes extends Ideal\Controller
|
||||
{
|
||||
public function tesoreria(ServerRequestInterface $request, ResponseInterface $response, Service\Contabilidad\Informe\Tesoreria $tesoreriaService, string $fecha): ResponseInterface
|
||||
{
|
||||
$fecha = new DateTimeImmutable($fecha);
|
||||
|
||||
$tesoreriaService->buildInforme($fecha, $tesoreriaService->build($fecha));
|
||||
$response->getBody()->write(file_get_contents('php://output'));
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -20,8 +20,8 @@ class Inmobiliarias
|
||||
$inmobiliarias = [];
|
||||
try {
|
||||
$inmobiliarias = array_map(function($row) use ($inmobiliariaRepository) {
|
||||
return $inmobiliariaRepository->load((array) $row);
|
||||
}, $this->fetchRedis($redisService, $redisKey));
|
||||
return $inmobiliariaRepository->load($row);
|
||||
}, $this->fetchRedis($redisService, $redisKey, true));
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAll();
|
||||
|
@ -1,33 +1,38 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use PDOException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Login
|
||||
class Login extends Controller
|
||||
{
|
||||
public function form(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Login $service): ResponseInterface
|
||||
{
|
||||
if ($service->isIn()) {
|
||||
return $response->withStatus(301)->withHeader('Location', $view->get('urls')->base);
|
||||
return $response->withStatus(302)->withHeader('Location', $view->get('urls')->base);
|
||||
}
|
||||
return $view->render($response, 'login.form');
|
||||
}
|
||||
public function login(ServerRequestInterface $request, ResponseInterface $response, Repository\User $userRepository, Service\Login $service): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$user = $userRepository->fetchByName($body['name']);
|
||||
$output = [
|
||||
'name' => $user->name,
|
||||
'name' => $body['name'],
|
||||
'login' => false
|
||||
];
|
||||
if ($user->validate($body['password'])) {
|
||||
$output['login'] = $service->login($user);
|
||||
}
|
||||
|
||||
try {
|
||||
$user = $userRepository->fetchByName($body['name']);
|
||||
if ($service->validateUser($user, $body['password'])) {
|
||||
$output['login'] = $service->login($user);
|
||||
}
|
||||
} catch (EmptyResult) {}
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Common\Implement\Exception\EmptyRedis;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Ventas
|
||||
{
|
||||
@ -32,8 +32,13 @@ class Ventas
|
||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Venta $service, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $service->getById($venta_id);
|
||||
return $view->render($response, 'ventas.show', compact('venta'));
|
||||
try {
|
||||
$venta = $service->getById($venta_id);
|
||||
return $view->render($response, 'ventas.show', compact('venta'));
|
||||
} catch (EmptyResult) {
|
||||
$response = $response->withStatus(404);
|
||||
return $view->render($response, 'not_found');
|
||||
}
|
||||
}
|
||||
public function showUnidad(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Venta $service, string $proyecto_nombre, int $unidad_descripcion): ResponseInterface
|
||||
@ -96,14 +101,29 @@ class Ventas
|
||||
View $view, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('venta'));
|
||||
$asociadas = [];
|
||||
if (isset($venta->formaPago()->pie->asociado)) {
|
||||
$asociadas []= $ventaService->getByPie($venta->formaPago()->pie->asociado->id);
|
||||
foreach ($venta->formaPago()->pie->asociado->asociados() as $asociado) {
|
||||
if ($venta->formaPago()->pie->id === $asociado->id) {
|
||||
continue;
|
||||
}
|
||||
$asociadas []= $ventaService->getByPie($asociado->id);
|
||||
}
|
||||
}
|
||||
if (count($venta->formaPago()->pie->asociados()) > 0) {
|
||||
foreach ($venta->formaPago()->pie->asociados() as $asociado) {
|
||||
$asociadas []= $ventaService->getByPie($asociado->id);
|
||||
}
|
||||
}
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('venta', 'asociadas'));
|
||||
}
|
||||
public function escriturar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
||||
Repository\Banco $bancoRepository, View $view, int $venta_id): ResponseInterface
|
||||
public function escriturar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
||||
Repository\Contabilidad\Banco $bancoRepository, View $view, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
$bancos = $bancoRepository->fetchAll();
|
||||
usort($bancos, function(Model\Banco $a, Model\Banco $b) {
|
||||
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
|
||||
return strcmp($a->nombre, $b->nombre);
|
||||
});
|
||||
return $view->render($response, 'ventas.escriturar', compact('venta', 'bancos'));
|
||||
|
21
app/src/Controller/Ventas/Creditos.php
Normal file
21
app/src/Controller/Ventas/Creditos.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Creditos extends Controller
|
||||
{
|
||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Venta $ventaService, Repository\Contabilidad\Banco $bancoRepository,
|
||||
int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
$bancos = $bancoRepository->fetchAll('nombre');
|
||||
return $view->render($response, 'ventas.creditos', compact('venta', 'bancos'));
|
||||
}
|
||||
}
|
@ -2,13 +2,13 @@
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Incoviba\Model;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Cuotas
|
||||
{
|
||||
@ -73,12 +73,12 @@ class Cuotas
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Contabilidad\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
|
||||
{
|
||||
$pie = $pieService->getById($pie_id);
|
||||
$venta = $ventaRepository->fetchByPie($pie_id);
|
||||
$bancos = $bancoRepository->fetchAll();
|
||||
usort($bancos, function(Model\Banco $a, Model\Banco $b) {
|
||||
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
|
||||
return strcmp($a->nombre, $b->nombre);
|
||||
});
|
||||
return $view->render($response, 'ventas.pies.cuotas.add', compact('pie', 'venta', 'bancos'));
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Escrituras
|
||||
{
|
||||
@ -20,4 +21,12 @@ class Escrituras
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
return $view->render($response, 'ventas.escrituras.informe', compact('venta'));
|
||||
}
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Venta $ventaService, Repository\Contabilidad\Banco $bancoRepository,
|
||||
int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
$bancos = $bancoRepository->fetchAll('nombre');
|
||||
return $view->render($response, 'ventas.escrituras.add', compact('venta', 'bancos'));
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,25 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Service;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Pies
|
||||
{
|
||||
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
|
||||
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService,
|
||||
Repository\Venta $ventaRepository, Repository\Contabilidad\Banco $bancoRepository,
|
||||
View $view, int $pie_id): ResponseInterface
|
||||
{
|
||||
$pie = $pieService->getById($pie_id);
|
||||
$venta = $ventaRepository->fetchByPie($pie_id);
|
||||
$bancos = $bancoRepository->fetchAll();
|
||||
usort($bancos, function(Model\Banco $a, Model\Banco $b) {
|
||||
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
|
||||
return strcmp($a->nombre, $b->nombre);
|
||||
});
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('pie', 'venta', 'bancos'));
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('pie', 'venta', 'bancos', 'ventaRepository'));
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ use Incoviba\Service;
|
||||
|
||||
trait withRedis
|
||||
{
|
||||
public function fetchRedis(Service\Redis $redisService, string $redisKey): mixed
|
||||
public function fetchRedis(Service\Redis $redisService, string $redisKey, ?bool $asArray = null): mixed
|
||||
{
|
||||
$jsonString = $redisService->get($redisKey);
|
||||
if ($jsonString === null) {
|
||||
throw new EmptyRedis($redisKey);
|
||||
}
|
||||
return json_decode($jsonString);
|
||||
return json_decode($jsonString, $asArray);
|
||||
}
|
||||
public function saveRedis(Service\Redis $redisService, string $redisKey, mixed $value, ?int $expiration = null): void
|
||||
{
|
||||
|
@ -6,10 +6,12 @@ use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Incoviba\Exception\MissingAuthorizationHeader;
|
||||
use Incoviba\Service;
|
||||
|
||||
class API
|
||||
{
|
||||
public function __construct(protected ResponseFactoryInterface $responseFactory, protected string $key) {}
|
||||
public function __construct(protected ResponseFactoryInterface $responseFactory, protected Service\Login $loginService,
|
||||
protected string $key) {}
|
||||
|
||||
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
@ -18,7 +20,7 @@ class API
|
||||
} catch (MissingAuthorizationHeader $exception) {
|
||||
return $this->responseFactory->createResponse(401);
|
||||
}
|
||||
if ($this->validate($key)) {
|
||||
if ($this->validate($request, $key)) {
|
||||
return $handler->handle($request);
|
||||
}
|
||||
return $this->responseFactory->createResponse(403);
|
||||
@ -33,8 +35,26 @@ class API
|
||||
}
|
||||
throw new MissingAuthorizationHeader();
|
||||
}
|
||||
protected function validate($incoming_key): bool
|
||||
protected function validate(ServerRequestInterface $request, $incoming_key): bool
|
||||
{
|
||||
if (str_contains($incoming_key, $this->loginService->getSeparator())) {
|
||||
list($incoming_key, $selector, $token) = explode($this->loginService->getSeparator(), $incoming_key);
|
||||
if (!$this->loginService->isIn()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!$this->loginService->isIn() and !$this->validPermitted($request)) {
|
||||
return false;
|
||||
}
|
||||
return $incoming_key === md5($this->key);
|
||||
}
|
||||
protected function validPermitted(ServerRequestInterface $request): bool
|
||||
{
|
||||
$uri = $request->getUri();
|
||||
$validPaths = [
|
||||
'/api',
|
||||
'/api/'
|
||||
];
|
||||
return in_array($uri->getPath(), $validPaths);
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ use Psr\Http\Message\ResponseFactoryInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Incoviba\Service;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Authentication
|
||||
{
|
||||
@ -24,10 +24,14 @@ class Authentication
|
||||
return $handler->handle($request);
|
||||
}
|
||||
$this->logger->notice("Not logged in.");
|
||||
$response = $this->responseFactory->createResponse(301, 'Not logged in')
|
||||
$response = $this->responseFactory->createResponse(307, 'Not logged in')
|
||||
->withHeader('Referer', (string) $request->getUri())
|
||||
->withHeader('X-Redirected-URI', (string) $request->getUri());
|
||||
return $this->view->render($response, 'login.form', ['redirect_uri' => (string) $request->getUri()]);
|
||||
$url = "{$request->getUri()}";
|
||||
if (str_ends_with($url, '/login')) {
|
||||
$url = str_replace('/login', '', $url);
|
||||
}
|
||||
return $this->view->render($response, 'login.form', ['redirect_uri' => $url]);
|
||||
}
|
||||
|
||||
protected function isValid(ServerRequestInterface $request): bool
|
||||
@ -41,13 +45,22 @@ class Authentication
|
||||
]);
|
||||
|
||||
$valid_paths = [
|
||||
'/',
|
||||
'/'
|
||||
];
|
||||
if (in_array($current_path, $valid_paths, true)) {
|
||||
return true;
|
||||
}
|
||||
$valid_subpaths = [
|
||||
'/api/'
|
||||
];
|
||||
foreach ($valid_subpaths as $path) {
|
||||
if (str_starts_with($current_path, $path)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$valid_uris = [
|
||||
$this->login_url,
|
||||
"{$this->login_url}/",
|
||||
];
|
||||
if (in_array($current_url, $valid_uris, true)) {
|
||||
return true;
|
||||
|
21
app/src/Middleware/CORS.php
Normal file
21
app/src/Middleware/CORS.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace Incoviba\Middleware;
|
||||
|
||||
use Psr\Http\Message\ResponseFactoryInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
class CORS
|
||||
{
|
||||
public function __construct(protected ResponseFactoryInterface $responseFactory) {}
|
||||
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
if ($request->getMethod() === 'OPTIONS') {
|
||||
return $this->responseFactory->createResponse()
|
||||
->withHeader('Access-Control-Allow-Origin', '*')
|
||||
->withHeader('Access-Control-Allow-Methods', 'POST,GET,OPTIONS');
|
||||
}
|
||||
return $handler->handle($request);
|
||||
}
|
||||
}
|
@ -18,11 +18,11 @@ class Errors
|
||||
try {
|
||||
return $handler->handle($request);
|
||||
} catch (Exception $exception) {
|
||||
$this->logger->notice($exception);
|
||||
$this->logger->warning($exception);
|
||||
} catch (Error $error) {
|
||||
$this->logger->error($error);
|
||||
}
|
||||
$response = $this->responseFactory->createResponse(600, 'Internal Server Error');
|
||||
$response = $this->responseFactory->createResponse(500, 'Internal Server Error');
|
||||
if (str_contains($request->getUri()->getPath(), '/api')) {
|
||||
return $response;
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Model;
|
||||
|
||||
class CategoriaCentro extends Tipo
|
||||
{}
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Incoviba\Model;
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
|
||||
use Incoviba\Common\Ideal\Model;
|
||||
|
27
app/src/Model/Contabilidad/Cartola.php
Normal file
27
app/src/Model/Contabilidad/Cartola.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model\Inmobiliaria;
|
||||
|
||||
class Cartola extends Ideal\Model
|
||||
{
|
||||
public Inmobiliaria\Cuenta $cuenta;
|
||||
public DateTimeInterface $fecha;
|
||||
|
||||
public int $cargos = 0;
|
||||
public int $abonos = 0;
|
||||
public int $saldo = 0;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'cuenta_id' => $this->cuenta->id,
|
||||
'fecha' => $this->fecha->format('Y-m-d'),
|
||||
'cargos' => $this->cargos,
|
||||
'abonos' => $this->abonos,
|
||||
'saldo' => $this->saldo
|
||||
]);
|
||||
}
|
||||
}
|
7
app/src/Model/Contabilidad/CategoriaCentro.php
Normal file
7
app/src/Model/Contabilidad/CategoriaCentro.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
|
||||
use Incoviba\Model\Tipo;
|
||||
|
||||
class CategoriaCentro extends Tipo
|
||||
{}
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Model;
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model\TipoCuenta;
|
||||
|
||||
class CentroCosto extends Ideal\Model
|
||||
{
|
||||
@ -13,7 +14,7 @@ class CentroCosto extends Ideal\Model
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_map(parent::jsonSerialize(), [
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'tipo_centro' => $this->tipoCentro,
|
||||
'categoria' => $this->categoria,
|
||||
'tipo_cuenta' => $this->tipoCuenta,
|
37
app/src/Model/Contabilidad/Deposito.php
Normal file
37
app/src/Model/Contabilidad/Deposito.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model\Inmobiliaria;
|
||||
|
||||
class Deposito extends Ideal\Model
|
||||
{
|
||||
public Inmobiliaria\Cuenta $cuenta;
|
||||
public int $capital;
|
||||
public int $futuro;
|
||||
public DateTimeInterface $inicio;
|
||||
public DateTimeInterface $termino;
|
||||
|
||||
public function plazo(): int
|
||||
{
|
||||
return $this->termino->diff($this->inicio)->days;
|
||||
}
|
||||
public function tasa(): float
|
||||
{
|
||||
return ($this->futuro - $this->capital) / $this->capital;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'cuenta_id' => $this->cuenta->id,
|
||||
'capital' => $this->capital,
|
||||
'futuro' => $this->futuro,
|
||||
'inicio' => $this->inicio->format('Y-m-d'),
|
||||
'termino' => $this->termino->format('Y-m-d'),
|
||||
'plazo' => $this->plazo(),
|
||||
'tasa' => $this->tasa()
|
||||
]);
|
||||
}
|
||||
}
|
46
app/src/Model/Contabilidad/Movimiento.php
Normal file
46
app/src/Model/Contabilidad/Movimiento.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Model\Inmobiliaria;
|
||||
use Incoviba\Model\Movimiento\Detalle;
|
||||
|
||||
class Movimiento extends Ideal\Model
|
||||
{
|
||||
public Inmobiliaria\Cuenta $cuenta;
|
||||
public DateTimeInterface $fecha;
|
||||
public string $glosa;
|
||||
public string $documento;
|
||||
public int $cargo;
|
||||
public int $abono;
|
||||
public int $saldo;
|
||||
|
||||
protected ?Detalle $detalles;
|
||||
public function getDetalles(): ?Detalle
|
||||
{
|
||||
if (!isset($this->detalles)) {
|
||||
try {
|
||||
$this->detalles = $this->runFactory('detalles');
|
||||
} catch (EmptyResult) {
|
||||
$this->detalles = null;
|
||||
}
|
||||
}
|
||||
return $this->detalles;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'cuenta_id' => $this->cuenta->id,
|
||||
'fecha' => $this->fecha->format('Y-m-d'),
|
||||
'glosa' => $this->glosa,
|
||||
'documento' => $this->documento,
|
||||
'cargo' => $this->cargo,
|
||||
'abono' => $this->abono,
|
||||
'saldo' => $this->saldo,
|
||||
'detalles' => $this->getDetalles() ?? null
|
||||
]);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user