Compare commits
5 Commits
8aa1c787f4
...
master
Author | SHA1 | Date | |
---|---|---|---|
6ddc48ec60 | |||
331ee1e584 | |||
24c17debf3 | |||
552fd0aa06 | |||
60faf293d4 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,5 +10,3 @@
|
||||
**/.idea/
|
||||
**/upload?/
|
||||
**/informe?/
|
||||
**/.phpunit.cache/
|
||||
**/coverage/
|
||||
|
18
Dockerfile
18
Dockerfile
@ -1,18 +1,14 @@
|
||||
FROM php:8.2-fpm
|
||||
|
||||
ENV TZ=America/Santiago
|
||||
FROM php:8.1-fpm
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends libzip-dev libicu-dev git libpng-dev unzip tzdata \
|
||||
&& rm -r /var/lib/apt/lists/* \
|
||||
&& docker-php-ext-install pdo pdo_mysql zip intl gd bcmath \
|
||||
&& pecl install xdebug-3.3.2 \
|
||||
&& docker-php-ext-enable xdebug \
|
||||
&& echo $TZ > /etc/timezone
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
|
||||
RUN docker-php-ext-install pdo pdo_mysql zip intl gd bcmath
|
||||
|
||||
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 ./php-memory.ini /usr/local/etc/php/conf.d/docker-php-memory.ini
|
||||
COPY ./php-timezone.ini /usr/local/etc/php/conf.d/docker-php-timezone.ini
|
||||
|
||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
services:
|
||||
httpclient:
|
||||
profiles:
|
||||
- testing
|
||||
container_name: incoviba_client
|
||||
image: flawiddsouza/restfox
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${HTTPCLIENT_PORT:-4004}:4004"
|
1
app/.gitignore
vendored
1
app/.gitignore
vendored
@ -1 +0,0 @@
|
||||
**/bin
|
@ -1,14 +0,0 @@
|
||||
watch:
|
||||
directories:
|
||||
- src
|
||||
- tests
|
||||
- common
|
||||
- resources
|
||||
fileMask: '*.php'
|
||||
notifications:
|
||||
passingTests: false
|
||||
failingTests: false
|
||||
hideManual: true
|
||||
phpunit:
|
||||
arguments: '--log-events-text /logs/output.txt --stop-on-failure'
|
||||
timeout: 180
|
@ -5,11 +5,6 @@ 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\Contabilidad\Banco $banco, DateTimeInterface $mes, array $movimientos): string;
|
||||
public function export(Model\Inmobiliaria $inmobiliaria, Model\Banco $banco, DateTimeInterface $mes, array $movimientos): string;
|
||||
}
|
||||
|
@ -9,55 +9,9 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
||||
{
|
||||
public function process(UploadedFileInterface $file): array
|
||||
{
|
||||
$filename = $this->processUploadedFile($file);
|
||||
$data = $this->processFile($filename);
|
||||
return $this->mapColumns($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param UploadedFileInterface $uploadedFile
|
||||
* @return string
|
||||
*/
|
||||
protected function processUploadedFile(UploadedFileInterface $uploadedFile): string
|
||||
{
|
||||
$filename = $this->getFilename($uploadedFile);
|
||||
$uploadedFile->moveTo($filename);
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the temp file from getFilename and remove it
|
||||
* @param string $filename
|
||||
* @return array
|
||||
*/
|
||||
protected function processFile(string $filename): array
|
||||
{
|
||||
$data = $this->parseFile($filename);
|
||||
unlink($filename);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map columns from uploaded file data to database columns
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function mapColumns(array $data): array
|
||||
{
|
||||
$data = $this->parseFile($file);
|
||||
$temp = [];
|
||||
$columns = $this->columnMap();
|
||||
|
||||
foreach ($data as $row) {
|
||||
$r = [];
|
||||
foreach ($columns as $old => $new) {
|
||||
@ -70,24 +24,11 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
public function processMovimientosDiarios(array $movimientos): array
|
||||
{
|
||||
return $movimientos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Translate uploaded file data to database data
|
||||
* @param string $filename
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function parseFile(string $filename): array;
|
||||
abstract protected function parseFile(UploadedFileInterface $uploadedFile): array;
|
||||
}
|
||||
|
@ -37,9 +37,6 @@ abstract class Repository implements Define\Repository
|
||||
$this->connection->execute($query, [$model->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws EmptyResult
|
||||
*/
|
||||
public function fetchById(int $id): Define\Model
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -48,10 +45,6 @@ abstract class Repository implements Define\Repository
|
||||
->where("{$this->getKey()} = ?");
|
||||
return $this->fetchOne($query, [$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws EmptyResult
|
||||
*/
|
||||
public function fetchAll(null|string|array $ordering = null): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -168,9 +161,4 @@ abstract class Repository implements Define\Repository
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function filterData(array $data): array
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use Throwable;
|
||||
|
||||
class EmptyResult extends Exception
|
||||
{
|
||||
public function __construct(public string $query, ?Throwable $previous = null)
|
||||
public function __construct(string $query, ?Throwable $previous = null)
|
||||
{
|
||||
$message = "Empty results for {$query}";
|
||||
$code = 700;
|
||||
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Exception;
|
||||
|
||||
use Throwable;
|
||||
use Exception;
|
||||
|
||||
class HttpResponse extends Exception
|
||||
{
|
||||
public function __construct($reason = "", $message = "", $code = 0, Throwable $previous = null)
|
||||
{
|
||||
$this->reason = "HTTP Reason: {$reason}";
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
protected string $reason;
|
||||
public function getReason(): string
|
||||
{
|
||||
return $this->reason;
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?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, protected int $retainDays = 90, 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 {$this->retainDays} DAY)";
|
||||
$this->connection->query($query);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?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,18 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Log;
|
||||
|
||||
use Monolog\LogRecord;
|
||||
use Monolog\Processor\ProcessorInterface;
|
||||
use Incoviba\Service;
|
||||
|
||||
class UserProcessor implements ProcessorInterface
|
||||
{
|
||||
public function __construct(protected Service\Login $loginService) {}
|
||||
public function __invoke(LogRecord $record): LogRecord
|
||||
{
|
||||
if ($this->loginService->isIn()) {
|
||||
$record->extra['user'] = $this->loginService->getUser()->name;
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Repository;
|
||||
|
||||
use Error;
|
||||
use Closure;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
|
||||
class Mapper implements Define\Repository\Mapper
|
||||
{
|
||||
@ -48,11 +46,7 @@ class Mapper implements Define\Repository\Mapper
|
||||
}
|
||||
public function hasDefault(): bool
|
||||
{
|
||||
try {
|
||||
return isset($this->default) or $this->default === null;
|
||||
} catch (Error) {
|
||||
return false;
|
||||
}
|
||||
return isset($this->default);
|
||||
}
|
||||
|
||||
public function parse(Define\Model &$model, string $column, ?array $data): bool
|
||||
@ -68,16 +62,8 @@ class Mapper implements Define\Repository\Mapper
|
||||
}
|
||||
$value = $data[$column];
|
||||
if ($this->hasFunction()) {
|
||||
if ($value !== null and $value !== '') {
|
||||
try {
|
||||
$value = ($this->function)($data);
|
||||
} catch (EmptyResult $exception) {
|
||||
if ($this->hasDefault()) {
|
||||
$value = $this->default;
|
||||
} else {
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
if ($value !== null) {
|
||||
$value = ($this->function)($data);
|
||||
} elseif ($this->hasDefault()) {
|
||||
$value = $this->default;
|
||||
}
|
||||
|
@ -1,30 +1,21 @@
|
||||
{
|
||||
"name": "incoviba/web",
|
||||
"version": "2.0.0",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-pdo": "*",
|
||||
"berrnd/slim-blade-view": "^1",
|
||||
"guzzlehttp/guzzle": "^7",
|
||||
"monolog/monolog": "^3",
|
||||
"nyholm/psr7": "^1",
|
||||
"nyholm/psr7-server": "^1",
|
||||
"php-di/php-di": "^7",
|
||||
"php-di/slim-bridge": "^3",
|
||||
"phpoffice/phpspreadsheet": "^3",
|
||||
"predis/predis": "^2",
|
||||
"robmorgan/phinx": "^0.16",
|
||||
"slim/slim": "^4"
|
||||
"berrnd/slim-blade-view": "^1.0",
|
||||
"guzzlehttp/guzzle": "^7.8",
|
||||
"monolog/monolog": "^3.4",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"nyholm/psr7-server": "^1.0",
|
||||
"php-di/php-di": "^7.0",
|
||||
"php-di/slim-bridge": "^3.4",
|
||||
"phpoffice/phpspreadsheet": "^1.29",
|
||||
"predis/predis": "^2.2",
|
||||
"slim/slim": "^4.11"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1",
|
||||
"kint-php/kint": "^5",
|
||||
"odan/phinx-migrations-generator": "^6",
|
||||
"phpunit/phpunit": "^11",
|
||||
"spatie/phpunit-watcher": "^1"
|
||||
"kint-php/kint": "^5.1",
|
||||
"phpunit/phpunit": "^10.2"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
@ -39,8 +30,6 @@
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"process-timeout": 0,
|
||||
"bin-dir": "bin"
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
return
|
||||
[
|
||||
'paths' => [
|
||||
'migrations' => '%%PHINX_CONFIG_DIR%%/resources/database/migrations',
|
||||
'seeds' => '%%PHINX_CONFIG_DIR%%/resources/database/seeds'
|
||||
],
|
||||
'environments' => [
|
||||
'default_migration_table' => 'phinxlog',
|
||||
'default_environment' => 'development',
|
||||
'production' => [
|
||||
'adapter' => 'mysql',
|
||||
'host' => $_ENV['DB_HOST'] ?? 'localhost',
|
||||
'name' => $_ENV['DB_DATABASE'],
|
||||
'user' => $_ENV['DB_USER'],
|
||||
'pass' => $_ENV['DB_PASSWORD'],
|
||||
'port' => '3306',
|
||||
'charset' => 'utf8',
|
||||
],
|
||||
'development' => [
|
||||
'adapter' => 'mysql',
|
||||
'host' => $_ENV['DB_HOST'] ?? 'localhost',
|
||||
'name' => $_ENV['DB_DATABASE'],
|
||||
'user' => $_ENV['DB_USER'],
|
||||
'pass' => $_ENV['DB_PASSWORD'],
|
||||
'port' => '3306',
|
||||
'charset' => 'utf8',
|
||||
],
|
||||
'testing' => [
|
||||
'adapter' => 'mysql',
|
||||
'host' => $_ENV['DB_HOST'] ?? 'localhost',
|
||||
'name' => $_ENV['DB_DATABASE'],
|
||||
'user' => $_ENV['DB_USER'],
|
||||
'pass' => $_ENV['DB_PASSWORD'],
|
||||
'port' => '3306',
|
||||
'charset' => 'utf8',
|
||||
]
|
||||
],
|
||||
'version_order' => 'creation',
|
||||
'schema_file' => '%%PHINX_CONFIG_DIR%%/resources/database/schema.php',
|
||||
'foreign_keys' => true,
|
||||
'generate_migration_name' => true,
|
||||
'default_migration_prefix' => 'incoviba_',
|
||||
'mark_generated_migration' => true
|
||||
];
|
@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
|
||||
bootstrap="test.bootstrap.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/unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="acceptance">
|
||||
<directory>tests/integration</directory>
|
||||
</testsuite>
|
||||
<testsuite name="performance">
|
||||
<directory>tests/performance</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<source restrictNotices="true" restrictWarnings="true" ignoreIndirectDeprecations="true">
|
||||
<include>
|
||||
<directory>src</directory>
|
||||
<directory>common</directory>
|
||||
</include>
|
||||
</source>
|
||||
<coverage 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>
|
Binary file not shown.
Before Width: | Height: | Size: 894 B |
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreatePersonas extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
$this->table('personas', ['id' => false, 'primary_key' => ['rut', 'digito']])
|
||||
->addColumn('rut', 'integer', ['identity' => true, 'signed' => false, 'null' => false])
|
||||
->addColumn('digito', 'string', ['limit' => 1, 'null' => false])
|
||||
->addColumn('nombres', 'string', ['limit' => 255, 'null' => false])
|
||||
->addColumn('apellido_paterno', 'string', ['limit' => 255, 'null' => false])
|
||||
->addColumn('apellido_materno', 'string', ['limit' => 255, 'null' => false])
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateProveedores extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
$this->table('proveedores', ['id' => false, 'primary_key' => ['rut', 'digito']])
|
||||
->addColumn('rut', 'integer', ['identity' => true, 'signed' => false, 'null' => false])
|
||||
->addColumn('digito', 'string', ['limit' => 1, 'null' => false])
|
||||
->addColumn('nombre', 'string', ['limit' => 255, 'null' => false])
|
||||
->addColumn('razon', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('contacto_rut', 'integer', ['signed' => false, 'null' => true])
|
||||
->addForeignKey('contacto_rut', 'personas', ['rut'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateDatosProveedores extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
$this->table('datos_proveedores')
|
||||
->addColumn('proveedor_rut', 'integer', ['signed' => false, 'null' => false])
|
||||
->addForeignKey('proveedor_rut', 'proveedores', ['rut'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->addColumn('direccion_id', 'integer', ['signed' => false, 'null' => true])
|
||||
->addForeignKey('direccion_id', 'direccion', ['id'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->addColumn('telefono', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('giro', 'string', ['limit' => 255, 'null' => true])
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateDatosPersonas extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
$this->table('datos_personas')
|
||||
->addColumn('persona_rut', 'integer', ['signed' => false, 'null' => false])
|
||||
->addForeignKey('persona_rut', 'personas', ['rut'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->addColumn('direccion_id', 'integer', ['signed' => false, 'null' => true])
|
||||
->addForeignKey('direccion_id', 'direccion', ['id'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->addColumn('telefono', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('email', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('fecha_nacimiento', 'datetime', ['null' => true])
|
||||
->addColumn('sexo', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('estado_civil', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('nacionalidad', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('ocupacion', 'string', ['limit' => 255, 'null' => true])
|
||||
->create();
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateVentaAbonoCuota extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
$this->table('venta_abono_cuotas')
|
||||
->addColumn('venta_id', 'integer', ['signed' => false, 'null' => false])
|
||||
->addForeignKey('venta_id', 'venta', ['id'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->addColumn('pago_id', 'integer', ['signed' => false, 'null' => false])
|
||||
->addForeignKey('pago_id', 'pago', ['id'], ['delete' => 'CASCADE', 'update' => 'CASCADE'])
|
||||
->addColumn('numero', 'integer', ['signed' => false, 'null' => false, 'default' => 1])
|
||||
->create();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,677 +0,0 @@
|
||||
-- Adminer 4.8.1 MySQL 11.5.2-MariaDB-ubu2404 dump
|
||||
|
||||
SET NAMES utf8;
|
||||
SET time_zone = '+00:00';
|
||||
SET foreign_key_checks = 0;
|
||||
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||
|
||||
USE `incoviba`;
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `action`;
|
||||
CREATE TABLE `action` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`description` varchar(50) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `agente`;
|
||||
CREATE TABLE `agente` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`tipo` int(11) DEFAULT NULL,
|
||||
`rut` int(11) DEFAULT NULL,
|
||||
`descripcion` varchar(100) DEFAULT NULL,
|
||||
`representante` varchar(100) DEFAULT NULL,
|
||||
`telefono` int(11) DEFAULT NULL,
|
||||
`correo` varchar(50) DEFAULT NULL,
|
||||
`direccion` int(11) DEFAULT NULL,
|
||||
`giro` mediumtext DEFAULT NULL,
|
||||
`abreviacion` varchar(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_tipo` (`tipo`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `agente_tipo`;
|
||||
CREATE TABLE `agente_tipo` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`agente` int(10) unsigned NOT NULL,
|
||||
`tipo` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `agente` (`agente`),
|
||||
KEY `tipo` (`tipo`),
|
||||
CONSTRAINT `agente_tipo_ibfk_1` FOREIGN KEY (`agente`) REFERENCES `agente` (`id`) ON DELETE NO ACTION,
|
||||
CONSTRAINT `agente_tipo_ibfk_2` FOREIGN KEY (`tipo`) REFERENCES `tipo_agente` (`id`) ON DELETE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `avance_construccion`;
|
||||
CREATE TABLE `avance_construccion` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`proyecto` int(10) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`numero` int(10) unsigned NOT NULL,
|
||||
`avance` double unsigned NOT NULL,
|
||||
`estado_pago` double unsigned NOT NULL,
|
||||
`pagado` int(10) unsigned DEFAULT NULL,
|
||||
`uf` double unsigned DEFAULT NULL,
|
||||
`fecha_pagado` date DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `proyecto` (`proyecto`),
|
||||
CONSTRAINT `avance_construccion_ibfk_1` FOREIGN KEY (`proyecto`) REFERENCES `proyecto` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `backup`;
|
||||
CREATE TABLE `backup` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`date` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `banco`;
|
||||
CREATE TABLE `banco` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`nombre` varchar(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `bono_pie`;
|
||||
CREATE TABLE `bono_pie` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`valor` float DEFAULT NULL,
|
||||
`pago` int(11) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `pago` (`pago`),
|
||||
CONSTRAINT `bono_pie_ibfk_1` FOREIGN KEY (`pago`) REFERENCES `pago` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `cartolas`;
|
||||
CREATE TABLE `cartolas` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cuenta_id` int(10) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`cargos` bigint(20) unsigned NOT NULL DEFAULT 0,
|
||||
`abonos` bigint(20) unsigned NOT NULL DEFAULT 0,
|
||||
`saldo` bigint(20) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `cuenta_id` (`cuenta_id`),
|
||||
CONSTRAINT `cartolas_ibfk_2` FOREIGN KEY (`cuenta_id`) REFERENCES `cuenta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `categorias_centros_costos`;
|
||||
CREATE TABLE `categorias_centros_costos` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`descripcion` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `centros_costos`;
|
||||
CREATE TABLE `centros_costos` (
|
||||
`id` int(10) unsigned NOT NULL,
|
||||
`tipo_centro_id` int(10) unsigned NOT NULL,
|
||||
`categoria_id` int(10) unsigned NOT NULL,
|
||||
`tipo_cuenta_id` int(10) unsigned DEFAULT NULL,
|
||||
`cuenta_contable` varchar(100) NOT NULL,
|
||||
`descripcion` mediumtext NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tipo_centro_id` (`tipo_centro_id`),
|
||||
KEY `categoria_id` (`categoria_id`),
|
||||
KEY `tipo_cuenta_id` (`tipo_cuenta_id`),
|
||||
CONSTRAINT `centros_costos_ibfk_3` FOREIGN KEY (`tipo_centro_id`) REFERENCES `tipos_centros_costos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `centros_costos_ibfk_4` FOREIGN KEY (`categoria_id`) REFERENCES `categorias_centros_costos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `cierre`;
|
||||
CREATE TABLE `cierre` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`proyecto` int(10) unsigned NOT NULL,
|
||||
`precio` double NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`relacionado` int(1) DEFAULT 0,
|
||||
`propietario` int(10) unsigned DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `proyecto` (`proyecto`),
|
||||
CONSTRAINT `cierre_ibfk_2` FOREIGN KEY (`proyecto`) REFERENCES `proyecto` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `cobro`;
|
||||
CREATE TABLE `cobro` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`proyecto` int(11) DEFAULT NULL,
|
||||
`agente` int(11) DEFAULT NULL,
|
||||
`tipo` int(11) DEFAULT NULL,
|
||||
`fecha` date DEFAULT NULL,
|
||||
`valor` float DEFAULT NULL,
|
||||
`iva` float DEFAULT 0,
|
||||
`uf` float DEFAULT NULL,
|
||||
`identificador` varchar(50) DEFAULT NULL,
|
||||
`glosa` mediumtext DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `comentario`;
|
||||
CREATE TABLE `comentario` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`venta` int(10) unsigned DEFAULT NULL,
|
||||
`fecha` datetime DEFAULT NULL,
|
||||
`texto` blob DEFAULT NULL,
|
||||
`estado` int(11) DEFAULT 1,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `comuna`;
|
||||
CREATE TABLE `comuna` (
|
||||
`id` int(11) unsigned NOT NULL,
|
||||
`descripcion` varchar(50) NOT NULL,
|
||||
`provincia` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `fk_provincia` (`provincia`),
|
||||
CONSTRAINT `comuna_ibfk_1` FOREIGN KEY (`provincia`) REFERENCES `provincia` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `configurations`;
|
||||
CREATE TABLE `configurations` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(30) NOT NULL,
|
||||
`value` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `costo`;
|
||||
CREATE TABLE `costo` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`proyecto` int(11) DEFAULT NULL,
|
||||
`tipo` int(11) DEFAULT NULL,
|
||||
`valor` float DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `credito`;
|
||||
CREATE TABLE `credito` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`banco` varchar(50) DEFAULT NULL,
|
||||
`valor` float DEFAULT NULL,
|
||||
`fecha` date DEFAULT NULL,
|
||||
`uf` float DEFAULT NULL,
|
||||
`abonado` int(1) DEFAULT 0,
|
||||
`fecha_abono` date DEFAULT NULL,
|
||||
`pago` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `cuenta`;
|
||||
CREATE TABLE `cuenta` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`inmobiliaria` int(8) unsigned NOT NULL,
|
||||
`banco` int(10) unsigned NOT NULL,
|
||||
`cuenta` varchar(50) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `inmobiliaria` (`inmobiliaria`),
|
||||
KEY `banco` (`banco`),
|
||||
CONSTRAINT `cuenta_ibfk_1` FOREIGN KEY (`inmobiliaria`) REFERENCES `inmobiliaria` (`rut`) ON DELETE NO ACTION,
|
||||
CONSTRAINT `cuenta_ibfk_2` FOREIGN KEY (`banco`) REFERENCES `banco` (`id`) ON DELETE NO ACTION
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `cuota`;
|
||||
CREATE TABLE `cuota` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`pie` int(10) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`valor_$` int(10) unsigned NOT NULL,
|
||||
`estado` tinyint(1) DEFAULT 0,
|
||||
`banco` varchar(20) NOT NULL,
|
||||
`fecha_pago` date DEFAULT NULL,
|
||||
`abonado` tinyint(1) DEFAULT 0,
|
||||
`fecha_abono` date DEFAULT NULL,
|
||||
`uf` double DEFAULT 0,
|
||||
`pago` int(10) unsigned DEFAULT NULL,
|
||||
`numero` int(10) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `fk_pago_cuota` (`pago`),
|
||||
KEY `pie` (`pie`),
|
||||
CONSTRAINT `cuota_ibfk_1` FOREIGN KEY (`pago`) REFERENCES `pago` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `cuota_ibfk_2` FOREIGN KEY (`pie`) REFERENCES `pie` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `depositos`;
|
||||
CREATE TABLE `depositos` (
|
||||
`id` int(10) unsigned NOT NULL,
|
||||
`cuenta_id` int(10) unsigned NOT NULL,
|
||||
`capital` int(10) unsigned NOT NULL,
|
||||
`futuro` int(10) unsigned NOT NULL,
|
||||
`inicio` date NOT NULL,
|
||||
`termino` date NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `cuenta_id` (`cuenta_id`),
|
||||
CONSTRAINT `depositos_ibfk_2` FOREIGN KEY (`cuenta_id`) REFERENCES `cuenta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `direccion`;
|
||||
CREATE TABLE `direccion` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`calle` varchar(255) NOT NULL,
|
||||
`numero` int(10) unsigned NOT NULL,
|
||||
`extra` varchar(255) NOT NULL,
|
||||
`comuna` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `fk_comuna` (`comuna`),
|
||||
CONSTRAINT `direccion_ibfk_1` FOREIGN KEY (`comuna`) REFERENCES `comuna` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `entrega`;
|
||||
CREATE TABLE `entrega` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`fecha` date NOT NULL,
|
||||
`fondo_operacion` int(11) DEFAULT 0,
|
||||
`fondo_reserva` int(11) DEFAULT 0,
|
||||
`fecha_fondo_operacion` date DEFAULT NULL,
|
||||
`fecha_fondo_reserva` date DEFAULT NULL,
|
||||
`pago_operacion` int(11) DEFAULT NULL,
|
||||
`pago_reserva` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `escritura`;
|
||||
CREATE TABLE `escritura` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`valor` bigint(20) NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`uf` float DEFAULT NULL,
|
||||
`abonado` int(11) DEFAULT 0,
|
||||
`fecha_abono` date DEFAULT NULL,
|
||||
`pago` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `estados_cuentas`;
|
||||
CREATE TABLE `estados_cuentas` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cuenta_id` int(10) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`active` tinyint(1) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `cuenta_id` (`cuenta_id`),
|
||||
CONSTRAINT `estados_cuentas_ibfk_2` FOREIGN KEY (`cuenta_id`) REFERENCES `cuenta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `estado_cierre`;
|
||||
CREATE TABLE `estado_cierre` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cierre` int(10) unsigned NOT NULL,
|
||||
`tipo` int(10) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `cierre` (`cierre`),
|
||||
KEY `tipo` (`tipo`),
|
||||
CONSTRAINT `estado_cierre_ibfk_3` FOREIGN KEY (`cierre`) REFERENCES `cierre` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `estado_cierre_ibfk_4` FOREIGN KEY (`tipo`) REFERENCES `tipo_estado_cierre` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `estado_cobro`;
|
||||
CREATE TABLE `estado_cobro` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cobro` int(10) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`estado` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`,`cobro`,`estado`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `estado_pago`;
|
||||
CREATE TABLE `estado_pago` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`pago` int(11) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`estado` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `estado` (`estado`),
|
||||
CONSTRAINT `estado_pago_ibfk_1` FOREIGN KEY (`estado`) REFERENCES `tipo_estado_pago` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `estado_precio`;
|
||||
CREATE TABLE `estado_precio` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`precio` int(10) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`estado` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `precio` (`precio`),
|
||||
KEY `estado` (`estado`),
|
||||
CONSTRAINT `estado_precio_ibfk_3` FOREIGN KEY (`precio`) REFERENCES `precio` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `estado_precio_ibfk_4` FOREIGN KEY (`estado`) REFERENCES `tipo_estado_precio` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `estado_problema`;
|
||||
CREATE TABLE `estado_problema` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`problema` int(11) DEFAULT NULL,
|
||||
`fecha` date DEFAULT NULL,
|
||||
`estado` enum('ingreso','revision','correccion','ok') DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `estado_proyecto`;
|
||||
CREATE TABLE `estado_proyecto` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`proyecto` int(10) unsigned NOT NULL,
|
||||
`estado` int(11) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `proyecto` (`proyecto`),
|
||||
KEY `estado` (`estado`),
|
||||
CONSTRAINT `estado_proyecto_ibfk_1` FOREIGN KEY (`proyecto`) REFERENCES `proyecto` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `estado_proyecto_ibfk_3` FOREIGN KEY (`estado`) REFERENCES `tipo_estado_proyecto` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `estado_proyecto_agente`;
|
||||
CREATE TABLE `estado_proyecto_agente` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`agente` int(10) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`tipo` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `estado_unidad_bloqueada`;
|
||||
CREATE TABLE `estado_unidad_bloqueada` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`unidad` int(10) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`tipo` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `estado_venta`;
|
||||
CREATE TABLE `estado_venta` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`venta` int(10) unsigned NOT NULL,
|
||||
`estado` int(11) unsigned NOT NULL DEFAULT 1,
|
||||
`fecha` date NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `escritura` (`venta`),
|
||||
KEY `estado` (`estado`),
|
||||
CONSTRAINT `estado_venta_ibfk_1` FOREIGN KEY (`estado`) REFERENCES `tipo_estado_venta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `estado_venta_ibfk_2` FOREIGN KEY (`venta`) REFERENCES `venta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `etapa_proyecto`;
|
||||
CREATE TABLE `etapa_proyecto` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`descripcion` varchar(20) DEFAULT NULL,
|
||||
`orden` int(10) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `facturas`;
|
||||
CREATE TABLE `facturas` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`venta_id` int(10) unsigned NOT NULL,
|
||||
`index` int(10) unsigned NOT NULL,
|
||||
`proporcion` double unsigned NOT NULL,
|
||||
`data` text NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `venta_id` (`venta_id`),
|
||||
CONSTRAINT `facturas_ibfk_2` FOREIGN KEY (`venta_id`) REFERENCES `venta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `factura_proyecto_operador`;
|
||||
CREATE TABLE `factura_proyecto_operador` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`proyecto_id` int(10) unsigned NOT NULL,
|
||||
`operador_id` int(10) unsigned NOT NULL,
|
||||
`factura` int(10) unsigned NOT NULL,
|
||||
`valor_uf` double unsigned NOT NULL,
|
||||
`valor_neto` int(10) unsigned NOT NULL,
|
||||
`iva` int(10) unsigned DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `proyecto_id` (`proyecto_id`),
|
||||
KEY `operador_id` (`operador_id`),
|
||||
CONSTRAINT `factura_proyecto_operador_ibfk_1` FOREIGN KEY (`proyecto_id`) REFERENCES `proyecto` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `factura_proyecto_operador_ibfk_2` FOREIGN KEY (`operador_id`) REFERENCES `agente` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `factura_venta`;
|
||||
CREATE TABLE `factura_venta` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`factura_id` int(10) unsigned NOT NULL,
|
||||
`venta_id` int(10) unsigned NOT NULL,
|
||||
`valor` double NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `factura_id` (`factura_id`),
|
||||
KEY `venta_id` (`venta_id`),
|
||||
CONSTRAINT `factura_venta_ibfk_1` FOREIGN KEY (`factura_id`) REFERENCES `factura_proyecto_operador` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `factura_venta_ibfk_2` FOREIGN KEY (`venta_id`) REFERENCES `venta` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `inmobiliaria`;
|
||||
CREATE TABLE `inmobiliaria` (
|
||||
`rut` int(8) unsigned NOT NULL,
|
||||
`dv` char(1) DEFAULT NULL,
|
||||
`razon` varchar(255) DEFAULT NULL,
|
||||
`abreviacion` varchar(50) DEFAULT NULL,
|
||||
`cuenta` varchar(50) DEFAULT NULL,
|
||||
`banco` int(11) DEFAULT NULL,
|
||||
`sociedad` int(10) unsigned DEFAULT NULL,
|
||||
`sigla` varchar(4) DEFAULT NULL,
|
||||
PRIMARY KEY (`rut`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `inmobiliarias_nubox`;
|
||||
CREATE TABLE `inmobiliarias_nubox` (
|
||||
`inmobiliaria_rut` int(8) unsigned NOT NULL,
|
||||
`alias` varchar(100) NOT NULL,
|
||||
`usuario` varchar(100) NOT NULL,
|
||||
`contraseña` varchar(100) NOT NULL,
|
||||
KEY `inmobiliaria_rut` (`inmobiliaria_rut`),
|
||||
CONSTRAINT `inmobiliarias_nubox_ibfk_2` FOREIGN KEY (`inmobiliaria_rut`) REFERENCES `inmobiliaria` (`rut`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `locations`;
|
||||
CREATE TABLE `locations` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`controller` varchar(50) NOT NULL,
|
||||
`action` varchar(100) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `logins`;
|
||||
CREATE TABLE `logins` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(10) unsigned NOT NULL,
|
||||
`time` datetime NOT NULL,
|
||||
`selector` varchar(255) NOT NULL,
|
||||
`token` varchar(255) NOT NULL,
|
||||
`status` int(1) NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `fk_logins_users` (`user_id`),
|
||||
CONSTRAINT `fk_logins_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `monolog`;
|
||||
CREATE TABLE `monolog` (
|
||||
`channel` varchar(255) DEFAULT NULL,
|
||||
`level` varchar(100) DEFAULT NULL,
|
||||
`message` longtext DEFAULT NULL,
|
||||
`time` datetime DEFAULT NULL,
|
||||
`context` longtext DEFAULT NULL,
|
||||
`extra` longtext DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `movimientos`;
|
||||
CREATE TABLE `movimientos` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cuenta_id` int(10) unsigned NOT NULL,
|
||||
`fecha` date NOT NULL,
|
||||
`glosa` text NOT NULL,
|
||||
`documento` varchar(50) NOT NULL,
|
||||
`cargo` bigint(20) unsigned NOT NULL DEFAULT 0,
|
||||
`abono` bigint(20) unsigned NOT NULL DEFAULT 0,
|
||||
`saldo` bigint(20) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `cuenta_id` (`cuenta_id`),
|
||||
CONSTRAINT `movimientos_ibfk_2` FOREIGN KEY (`cuenta_id`) REFERENCES `cuenta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `movimientos_detalles`;
|
||||
CREATE TABLE `movimientos_detalles` (
|
||||
`movimiento_id` int(10) unsigned NOT NULL,
|
||||
`centro_costo_id` int(10) unsigned DEFAULT NULL,
|
||||
`categoria` varchar(100) DEFAULT NULL,
|
||||
`detalle` text DEFAULT NULL,
|
||||
`rut` int(11) DEFAULT NULL,
|
||||
`digito` varchar(1) DEFAULT NULL,
|
||||
`nombres` varchar(255) DEFAULT NULL,
|
||||
`identificador` varchar(100) DEFAULT NULL,
|
||||
KEY `movimiento_id` (`movimiento_id`),
|
||||
KEY `centro_costo_id` (`centro_costo_id`),
|
||||
CONSTRAINT `movimientos_detalles_ibfk_3` FOREIGN KEY (`movimiento_id`) REFERENCES `movimientos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `movimientos_detalles_ibfk_5` FOREIGN KEY (`centro_costo_id`) REFERENCES `centros_costos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `pagare`;
|
||||
CREATE TABLE `pagare` (
|
||||
`id` int(10) unsigned NOT NULL,
|
||||
`proyecto` int(10) unsigned NOT NULL,
|
||||
`moneda` int(10) unsigned NOT NULL,
|
||||
`capital` double unsigned NOT NULL DEFAULT 0,
|
||||
`tasa` double unsigned NOT NULL DEFAULT 0,
|
||||
`fecha` date NOT NULL,
|
||||
`fecha_banco` date NOT NULL DEFAULT '0000-00-00',
|
||||
`duracion` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
`uf` double unsigned NOT NULL DEFAULT 0,
|
||||
`abonado` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
`estado_pago` int(10) unsigned NOT NULL DEFAULT 99999999,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `moneda` (`moneda`),
|
||||
KEY `proyecto` (`proyecto`),
|
||||
CONSTRAINT `pagare_ibfk_1` FOREIGN KEY (`moneda`) REFERENCES `tipo_moneda_pagare` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `pagare_ibfk_2` FOREIGN KEY (`proyecto`) REFERENCES `proyecto` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `pago`;
|
||||
CREATE TABLE `pago` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`valor` double NOT NULL,
|
||||
`banco` int(11) DEFAULT NULL,
|
||||
`tipo` int(11) DEFAULT NULL,
|
||||
`identificador` varchar(50) DEFAULT NULL,
|
||||
`fecha` date DEFAULT NULL,
|
||||
`uf` double DEFAULT NULL,
|
||||
`pagador` varchar(50) DEFAULT NULL,
|
||||
`asociado` int(10) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `pagos_centros_costos`;
|
||||
CREATE TABLE `pagos_centros_costos` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`pago_id` int(11) unsigned NOT NULL,
|
||||
`centro_costo_id` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `pago_id` (`pago_id`),
|
||||
KEY `centro_costo_id` (`centro_costo_id`),
|
||||
CONSTRAINT `pagos_centros_costos_ibfk_3` FOREIGN KEY (`pago_id`) REFERENCES `pago` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `pagos_centros_costos_ibfk_4` FOREIGN KEY (`centro_costo_id`) REFERENCES `centros_costos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `permissions`;
|
||||
CREATE TABLE `permissions` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`type` int(1) unsigned NOT NULL,
|
||||
`ext_id` int(10) unsigned NOT NULL,
|
||||
`action_id` int(10) unsigned NOT NULL,
|
||||
`status` int(1) unsigned NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `phinxlog`;
|
||||
CREATE TABLE `phinxlog` (
|
||||
`version` bigint(20) NOT NULL,
|
||||
`migration_name` varchar(100) DEFAULT NULL,
|
||||
`start_time` timestamp NULL DEFAULT NULL,
|
||||
`end_time` timestamp NULL DEFAULT NULL,
|
||||
`breakpoint` tinyint(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`version`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `pie`;
|
||||
CREATE TABLE `pie` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`fecha` date NOT NULL,
|
||||
`valor` double unsigned NOT NULL,
|
||||
`uf` double unsigned DEFAULT NULL,
|
||||
`cuotas` int(10) unsigned NOT NULL,
|
||||
`asociado` int(11) DEFAULT 0,
|
||||
`reajuste` int(11) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `precio`;
|
||||
CREATE TABLE `precio` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`unidad` int(10) unsigned NOT NULL,
|
||||
`valor` double NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `unidad` (`unidad`),
|
||||
CONSTRAINT `precio_ibfk_2` FOREIGN KEY (`unidad`) REFERENCES `unidad` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `problema`;
|
||||
CREATE TABLE `problema` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`venta` int(11) DEFAULT NULL,
|
||||
`descripcion` mediumtext DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
-- 2024-11-12 15:11:54
|
@ -1,6 +1,4 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Base;
|
||||
|
||||
$app->group('/api', function($app) {
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'api']);
|
||||
if (file_exists($folder)) {
|
||||
@ -12,5 +10,4 @@ $app->group('/api', function($app) {
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
$app->get('[/]', Base::class);
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\API::class));
|
||||
|
@ -2,15 +2,5 @@
|
||||
use Incoviba\Controller\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);
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
|
@ -28,15 +28,8 @@ $app->group('/venta/{venta_id:[0-9]+}', function($app) {
|
||||
});
|
||||
$app->get('[/]', [Ventas::class, 'pie']);
|
||||
});
|
||||
$app->group('/bono_pie', function($app) {
|
||||
$app->get('/add[/]', [Ventas\Bonos::class, 'add']);
|
||||
});
|
||||
$app->group('/escritura', function($app) {
|
||||
$app->group('/cuotas', function($app) {
|
||||
$app->get('[/]', Ventas\Abono\Cuotas::class);
|
||||
});
|
||||
$app->get('/add[/]', [Ventas\Escrituras::class, 'add']);
|
||||
$app->get('[/]', [Ventas\Escrituras::class, 'show']);
|
||||
});
|
||||
$app->group('/credito', function($app) {
|
||||
$app->get('[/]', [Ventas\Creditos::class, 'show']);
|
||||
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
$app->group('/admin', function($app) {
|
||||
$files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'admin']));
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
});
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Admin\Users;
|
||||
|
||||
$app->group('/users', function($app) {
|
||||
$app->get('[/]', Users::class);
|
||||
});
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
$app->group('/admin', function($app) {
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'admin']);
|
||||
if (file_exists($folder)) {
|
||||
$files = new FilesystemIterator($folder);
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
});
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Admin\Users;
|
||||
|
||||
$app->group('/users', function($app) {
|
||||
$app->post('/add[/]', Users::class . ':add');
|
||||
});
|
@ -3,8 +3,6 @@ use Incoviba\Controller\API\Contabilidad\Cartolas;
|
||||
|
||||
$app->group('/cartolas', function($app) {
|
||||
$app->post('/procesar[/]', [Cartolas::class, 'procesar']);
|
||||
$app->post('/importar[/]', [Cartolas::class, 'importar']);
|
||||
$app->get('/update[/]', [Cartolas::class, 'update']);
|
||||
});
|
||||
$app->group('/cartola', function($app) {
|
||||
$app->group('/diaria', function($app) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Incoviba\Controller\API\Contabilidad\CentrosCostos;
|
||||
use Incoviba\Controller\API\CentrosCostos;
|
||||
|
||||
$app->group('/centros_costos', function($app) {
|
||||
$app->post('/add[/]', [CentrosCostos::class, 'add']);
|
||||
|
@ -1,13 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad\Movimientos;
|
||||
|
||||
$app->group('/movimientos', function($app) {
|
||||
$app->post('/sociedad/mes[/]', [Movimientos::class, 'sociedad']);
|
||||
$app->post('/edit[/]', [Movimientos::class, 'edit']);
|
||||
$app->post('/segment[/]', [Movimientos::class, 'segment']);
|
||||
$app->get('[/]', Movimientos::class);
|
||||
});
|
||||
$app->group('/movimiento/{movimiento_id}', function($app) {
|
||||
$app->post('/detalles[/]', [Movimientos::class, 'detalles']);
|
||||
$app->delete('[/]', [Movimientos::class, 'remove']);
|
||||
$app->post('/detalles', [Movimientos::class, 'detalles']);
|
||||
});
|
||||
|
@ -1,14 +1,11 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad\Nubox;
|
||||
use Incoviba\Controller\API\Nubox;
|
||||
|
||||
$app->group('/nubox/{inmobiliaria_rut}', function($app) {
|
||||
$app->get('/token[/]', [Nubox::class, 'token']);
|
||||
$app->get('/sistemas[/]', [Nubox::class, 'sistemas']);
|
||||
$app->get('/cuentas[/]', [Nubox::class, 'cuentas']);
|
||||
$app->group('/libro', function($app) {
|
||||
$app->post('/mayor[/]', [Nubox::class, 'libroMayor']);
|
||||
$app->post('/diario[/]', [Nubox::class, 'libroDiario']);
|
||||
});
|
||||
$app->get('/facturas/{dia}[/]', [Nubox::class, 'facturas']);
|
||||
$app->post('/cuenta', [Nubox::class, 'cuenta']);
|
||||
});
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad\Tesoreria;
|
||||
|
||||
$app->group('/tesoreria', function($app) {
|
||||
$app->post('/import[/]', [Tesoreria::class, 'import']);
|
||||
});
|
@ -2,20 +2,9 @@
|
||||
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('/proveedores', [Inmobiliarias::class, 'proveedores']);
|
||||
$app->get('/cuentas[/]', [Inmobiliarias::class, 'cuentas']);
|
||||
$app->get('/proyectos[/]', [Inmobiliarias::class, 'proyectos']);
|
||||
});
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Inmobiliarias\Agentes;
|
||||
|
||||
$app->group('/proveedores', function($app) {
|
||||
$app->post('/add[/]', [Agentes::class, 'add']);
|
||||
$app->post('/register[/]', [Agentes::class, 'register']);
|
||||
$app->get('[/]', Agentes::class);
|
||||
});
|
||||
$app->group('/proveedor/{agente_id}', function($app) {
|
||||
$app->post('/edit[/]', [Agentes::class, 'edit']);
|
||||
});
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Inmobiliarias\Sociedades;
|
||||
|
||||
$app->group('/sociedades', function($app) {
|
||||
$app->post('/add[/]', [Sociedades::class, 'add']);
|
||||
$app->get('[/]', Sociedades::class);
|
||||
});
|
@ -1,4 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Login;
|
||||
|
||||
$app->post('/login[/]', Login::class);
|
@ -4,10 +4,5 @@ use Incoviba\Controller\API\Money;
|
||||
$app->group('/money', function($app) {
|
||||
$app->post('/ipc[/]', [Money::class, 'ipc']);
|
||||
$app->post('/uf[/]', [Money::class, 'uf']);
|
||||
$app->group('/ufs', function($app) {
|
||||
$app->post('[/]', [Money::class, 'updateUfs']);
|
||||
$app->get('[/]', [Money::class, 'ufs']);
|
||||
});
|
||||
$app->post('/many[/]', [Money::class, 'getMany']);
|
||||
$app->post('[/]', [Money::class, 'get']);
|
||||
});
|
||||
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Sociedades;
|
||||
|
||||
$app->group('/sociedades', function($app) {
|
||||
$app->group('/add', function($app) {
|
||||
$app->post('/one[/]', Sociedades::class . ':add');
|
||||
$app->post('[/]', Sociedades::class . ':addMany');
|
||||
});
|
||||
$app->post('/get[/]', [Sociedades::class, 'getMany']);
|
||||
$app->post('/edit[/]', [Sociedades::class, 'edit']);
|
||||
$app->post('/delete[/]', [Sociedades::class, 'delete']);
|
||||
$app->post('/asisgnar[/]', [Sociedades::class, 'asignar']);
|
||||
$app->get('[/]', Sociedades::class);
|
||||
});
|
||||
$app->group('/sociedad/{sociedad_rut}', function($app) {
|
||||
$app->get('[/]', Sociedades::class . ':get');
|
||||
});
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Tokens;
|
||||
|
||||
$app->group('/tokens', function($app) {
|
||||
$app->get('/try[/]', Tokens::class . ':try');
|
||||
});
|
@ -27,20 +27,8 @@ $app->group('/ventas', function($app) {
|
||||
});
|
||||
$app->group('/venta/{venta_id}', function($app) {
|
||||
$app->get('/unidades[/]', [Ventas::class, 'unidades']);
|
||||
$app->group('/comentarios', function($app) {
|
||||
$app->post('/add[/]', [Ventas::class, 'addComentario']);
|
||||
$app->get('[/]', [Ventas::class, 'comentarios']);
|
||||
});
|
||||
$app->group('/bono_pie', function($app) {
|
||||
$app->post('/add[/]', [Ventas\Bonos::class, 'add']);
|
||||
});
|
||||
$app->get('/comentarios[/]', [Ventas::class, 'comentarios']);
|
||||
$app->group('/escritura', function($app) {
|
||||
$app->group('/cuotas', function($app) {
|
||||
$app->post('/add[/]', [Ventas\Abonos\Cuotas::class, 'add']);
|
||||
});
|
||||
$app->group('/cuota/{cuota_id:[0-9]+}', function($app) {
|
||||
$app->post('/edit[/]', [Ventas\Abonos\Cuotas::class, 'edit']);
|
||||
});
|
||||
$app->post('/add[/]', [Ventas\Escrituras::class, 'add']);
|
||||
});
|
||||
$app->group('/credito', function($app) {
|
||||
@ -51,9 +39,6 @@ $app->group('/venta/{venta_id}', function($app) {
|
||||
$app->get('/eliminar[/]', [Ventas::class, 'insistir']);
|
||||
$app->post('[/]', [Ventas::class, 'desistir']);
|
||||
});
|
||||
$app->group('/propietario', function($app) {
|
||||
$app->put('/edit[/]', [Ventas::class, 'propietario']);
|
||||
});
|
||||
$app->post('[/]', [Ventas::class, 'edit']);
|
||||
$app->get('[/]', [Ventas::class, 'get']);
|
||||
});
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Ventas\Comentarios;
|
||||
|
||||
$app->group('/comentario/{comentario_id}', function($app) {
|
||||
$app->post('/edit[/]', [Comentarios::class, 'edit']);
|
||||
$app->delete('/remove[/]', [Comentarios::class, 'remove']);
|
||||
//$app->get('[/]', [Comentarios::class, 'get']);
|
||||
});
|
@ -3,5 +3,4 @@ use Incoviba\Controller\API\Ventas\Facturacion;
|
||||
|
||||
$app->group('/facturacion', function($app) {
|
||||
$app->get('/proyecto/{proyecto_id}[/]', [Facturacion::class, 'proyecto']);
|
||||
$app->post('/get[/]', [Facturacion::class, 'ventas']);
|
||||
});
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Ventas\Facturas;
|
||||
|
||||
$app->group('/facturas', function($app) {
|
||||
$app->post('/add[/]', [Facturas::class, 'add']);
|
||||
});
|
@ -11,6 +11,5 @@ $app->group('/pago/{pago_id:[0-9]+}', function($app) {
|
||||
$app->post('/abonar[/]', [Pagos::class, 'abonar']);
|
||||
$app->post('/devolver[/]', [Pagos::class, 'devolver']);
|
||||
$app->get('/anular[/]', [Pagos::class, 'anular']);
|
||||
$app->post('/estado[/]', [Pagos::class, 'estado']);
|
||||
$app->post('[/]', [Pagos::class, 'edit']);
|
||||
});
|
||||
|
@ -3,5 +3,4 @@ use Incoviba\Controller\Contabilidad;
|
||||
|
||||
$app->group('/cartolas', function($app) {
|
||||
$app->get('/diaria[/]', [Contabilidad::class, 'diaria']);
|
||||
$app->get('/importar[/]', [Contabilidad::class, 'importar']);
|
||||
});
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Incoviba\Controller\Contabilidad\CentrosCostos;
|
||||
use Incoviba\Controller\CentrosCostos;
|
||||
|
||||
$app->group('/centros_costos', function($app) {
|
||||
$app->get('/asignar[/]', [CentrosCostos::class, 'asignar']);
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad;
|
||||
|
||||
$app->get('/cuadratura[/]', [Contabilidad::class, 'cuadratura']);
|
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad;
|
||||
use Incoviba\Controller\Contabilidad\Tesoreria;
|
||||
|
||||
$app->group('/tesoreria', function($app) {
|
||||
$app->get('/import[/]', [Tesoreria::class, 'import']);
|
||||
$app->get('[/[{fecha}[/]]]', [Contabilidad::class, 'tesoreria']);
|
||||
});
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad\Movimientos;
|
||||
|
||||
$app->get('/movimientos', Movimientos::class);
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Inmobiliarias\Proveedores;
|
||||
|
||||
$app->group('/proveedores', function($app) {
|
||||
$app->get('[/]', Proveedores::class);
|
||||
});
|
@ -10,11 +10,4 @@ $app->group('/pie/{pie_id}', function($app) {
|
||||
});
|
||||
$app->get('[/]', [Pies::class, 'cuotas']);
|
||||
});
|
||||
$files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'pies']));
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Bonos;
|
||||
|
||||
$app->group('/bono_pie', function($app) {
|
||||
$app->get('/add[/]', [Bonos::class, 'add']);
|
||||
});
|
@ -1,100 +0,0 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Usuarios</h2>
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nombre</th>
|
||||
<th class="right aligned">
|
||||
<button class="ui mini green icon button" id="create-user-button">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($users as $user)
|
||||
<tr>
|
||||
<td>{{ $user->name }}</td>
|
||||
<td class="right aligned">
|
||||
<button class="ui mini blue icon button">
|
||||
<i class="edit icon"></i>
|
||||
</button>
|
||||
<button class="ui mini red icon button">
|
||||
<i class="trash icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui modal" id="create-user-modal">
|
||||
<i class="close icon"></i>
|
||||
<div class="header">
|
||||
Crear usuario
|
||||
</div>
|
||||
<div class="content">
|
||||
<form class="ui form">
|
||||
<div class="field">
|
||||
<label>Nombre</label>
|
||||
<input type="text" name="name" placeholder="Nombre">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Correo</label>
|
||||
<input type="email" name="email" placeholder="Correo">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Contraseña</label>
|
||||
<input type="password" name="password" placeholder="Contraseña">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<div class="ui black deny button">
|
||||
Cancelar
|
||||
</div>
|
||||
<div class="ui positive right labeled icon button">
|
||||
Crear
|
||||
<i class="checkmark icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.body.scripts.cryptojs')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
function encryptPassword(password) {
|
||||
const passphrase = Math.floor(Math.random() * Date.now()).toString()
|
||||
const encrypted = CryptoJS.AES.encrypt(password, passphrase)
|
||||
return [passphrase, encrypted.toString()].join('')
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$('#create-user-modal').modal({
|
||||
onApprove: function() {
|
||||
const url = '{{$urls->api}}/admin/users/add'
|
||||
const method = 'post'
|
||||
const body = new FormData(document.querySelector('#create-user-modal form'))
|
||||
body.set('password', encryptPassword(body.get('password')))
|
||||
fetchAPI(url, {method, body}).then(response => {
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
response.json().then(result => {
|
||||
if (result.success) {
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
$('#create-user-button').on('click', function () {
|
||||
$('#create-user-modal').modal('show')
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
@ -10,23 +10,5 @@
|
||||
<i class="hammer icon"></i>
|
||||
Esta parte del sitio está en construcción.
|
||||
</div>
|
||||
@if (isset($exception))
|
||||
<div class="ui warning message">
|
||||
<i class="exclamation triangle icon"></i>
|
||||
<div class="content">
|
||||
<div class="header">Error</div>
|
||||
<p>{{$message}}</p>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@if (isset($error))
|
||||
<div class="ui error message">
|
||||
<i class="exclamation triangle icon"></i>
|
||||
<div class="content">
|
||||
<div class="header">Error</div>
|
||||
<p>{{$message}}</p>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -52,7 +52,8 @@
|
||||
<th class="right aligned">Cargo</th>
|
||||
<th class="right aligned">Abono</th>
|
||||
<th class="right aligned">Saldo</th>
|
||||
<th class="right aligned"></th>
|
||||
<th>Centro de Costo</th>
|
||||
<th>Detalle</th>
|
||||
<th>Orden</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -114,85 +115,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui modal" id="edit_modal" data-cartola="">
|
||||
<div class="header">
|
||||
Movimiento
|
||||
<div class="meta">
|
||||
<span id="edit_inmobiliaria"></span> |
|
||||
<span id="edit_cuenta"></span> |
|
||||
<span id="edit_fecha"></span> |
|
||||
<span id="edit_glosa"></span> |
|
||||
<span id="edit_cargo"></span> |
|
||||
<span id="edit_abono"></span> |
|
||||
<span id="edit_saldo"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<form class="ui form" id="edit_form">
|
||||
<input type="hidden" name="movimiento_id" value="" />
|
||||
<div class="equal width fields">
|
||||
<div class="field">
|
||||
<label>Centro de Costo</label>
|
||||
<div class="ui search selection dropdown">
|
||||
<input type="hidden" name="centro_costo_id" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Centro de Costo</div>
|
||||
<div class="menu">
|
||||
@foreach($centrosCostos as $centro)
|
||||
<div class="item" data-value="{{$centro->id}}">
|
||||
{{$centro->id}} - {{$centro->descripcion}}
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Categoría</label>
|
||||
<div class="ui input">
|
||||
<input type="text" name="categoria" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Detalle</label>
|
||||
<div class="ui input">
|
||||
<input type="text" name="detalle" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="equal width fields">
|
||||
<div class="field">
|
||||
<label>RUT</label>
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="rut" />
|
||||
<div class="ui basic label">-<span id="digito"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Nombres</label>
|
||||
<div class="ui input">
|
||||
<input type="text" name="nombres" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Identificador</label>
|
||||
<div class="ui input">
|
||||
<input type="text" name="identificador" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="ui approve button">
|
||||
Editar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
@include('layout.body.scripts.rut')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
@ -200,8 +126,7 @@
|
||||
idx
|
||||
inmobiliaria = {
|
||||
rut: 0,
|
||||
razon: '',
|
||||
sigla: ''
|
||||
razon: ''
|
||||
}
|
||||
cuenta = {
|
||||
id: 0,
|
||||
@ -262,6 +187,46 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
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) => {
|
||||
@ -361,10 +326,6 @@
|
||||
onChange: (value, text, $choice) => {
|
||||
this.inmobiliaria.rut = value
|
||||
this.inmobiliaria.razon = text
|
||||
const inmobiliaria = diaria.data.inmobiliarias.find(inmobiliaria => inmobiliaria.rut === parseInt(value))
|
||||
if (typeof inmobiliaria !== 'undefined') {
|
||||
this.inmobiliaria.sigla = inmobiliaria.sigla
|
||||
}
|
||||
this.get().bancos(value).then(() => {
|
||||
$cuentas_dropdown.dropdown('change values', this.bancos)
|
||||
})
|
||||
@ -419,42 +380,74 @@
|
||||
cartola: ($tbody, dateFormatter, numberFormatter) => {
|
||||
this.movimientos.forEach((row, idx) => {
|
||||
$tbody.append(
|
||||
[
|
||||
'<tr>',
|
||||
`<td>${this.inmobiliaria.sigla ?? this.inmobiliaria.razon}</td>`,
|
||||
`<td>${this.cuenta.descripcion}</td>`,
|
||||
`<td>${dateFormatter.format(row.fecha)}</td>`,
|
||||
`<td>${row.glosa}</td>`,
|
||||
`<td class="right aligned">${row.cargo === 0 ? '' : numberFormatter.format(row.cargo)}</td>`,
|
||||
`<td class="right aligned">${row.abono === 0 ? '' : numberFormatter.format(row.abono)}</td>`,
|
||||
`<td class="right aligned">${row.saldo === 0 ? '' : numberFormatter.format(row.saldo)}</td>`,
|
||||
'<td class="center aligned">',
|
||||
`<button class="ui icon button edit_movimiento" data-movimiento="${idx}">`,
|
||||
'<i class="edit icon"></i>',
|
||||
'</button>',
|
||||
'</td>',
|
||||
`<td>${(idx + 1).toString()}</td>`,
|
||||
].join("\n")
|
||||
$('<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)
|
||||
)
|
||||
)
|
||||
})
|
||||
Array.from(document.getElementsByClassName('edit_movimiento')).forEach(button => {
|
||||
button.addEventListener('click', function(clickEvent) {
|
||||
const idx = clickEvent.currentTarget.dataset['movimiento']
|
||||
const movimiento = this.movimientos[idx]
|
||||
const $modal = $('#edit_modal')
|
||||
$modal.attr('data-cartola', this.idx)
|
||||
$modal.find('#edit_inmobiliaria').html(this.inmobiliaria.razon)
|
||||
$modal.find('#edit_cuenta').html(this.cuenta.descripcion)
|
||||
$modal.find('#edit_fecha').html(dateFormatter.format(movimiento.fecha))
|
||||
$modal.find('#edit_glosa').html(movimiento.glosa)
|
||||
$modal.find('#edit_cargo').html(numberFormatter.format(movimiento.cargo))
|
||||
$modal.find('#edit_abono').html(numberFormatter.format(movimiento.abono))
|
||||
$modal.find('#edit_saldo').html(numberFormatter.format(movimiento.saldo))
|
||||
$modal.find('input[name="movimiento_id"]').val(movimiento.id)
|
||||
$modal.modal('show')
|
||||
}.bind(this))
|
||||
})
|
||||
},
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -467,7 +460,8 @@
|
||||
'cargo',
|
||||
'abono',
|
||||
'saldo',
|
||||
'edit',
|
||||
'centro',
|
||||
'detalle',
|
||||
'orden'
|
||||
];
|
||||
@endphp
|
||||
@ -477,18 +471,17 @@
|
||||
inmobiliarias: JSON.parse('{!! json_encode($inmobiliarias) !!}'),
|
||||
cartolasIdx: [],
|
||||
cartolas: [],
|
||||
movimientos: [],
|
||||
},
|
||||
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', 'edit']);})))}}],
|
||||
width: '{{round((1/(count($columns) + 2)) * 100, 2)}}%'
|
||||
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']);})))}}],
|
||||
width: '{{round((1/(count($columns) + 2)) * 2 * 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)}}],
|
||||
@ -612,12 +605,8 @@
|
||||
cargo: row.cargo,
|
||||
abono: row.abono,
|
||||
saldo: row.saldo,
|
||||
centro: row.detalles?.centro_costo?.id ?? '',
|
||||
detalle: row.detalles?.detalle ?? '',
|
||||
categoria: row.detalles?.categoria ?? '',
|
||||
rut: row.detalles?.rut ?? '',
|
||||
nombres: row.detalles?.nombres ?? '',
|
||||
identificador: row.detalles?.identificador ?? ''
|
||||
centro: row.detalles?.centro_costo.descripcion ?? '',
|
||||
detalle: row.detalles?.detalle ?? ''
|
||||
}
|
||||
})
|
||||
const ayer = new Date(this.data.cartolas[cartolaIdx].fecha.getTime())
|
||||
@ -649,51 +638,6 @@
|
||||
$(this.ids.table.base).DataTable(this.dataTableConfig)
|
||||
|
||||
this.cartolas().add()
|
||||
|
||||
$(this.ids.editModal).modal({
|
||||
onApprove: $element => {
|
||||
const idx = $(this.ids.editModal).data('cartola')
|
||||
const id = $(this.ids.editModal).find('input[name="movimiento_id"]').val()
|
||||
const body = new FormData($(this.ids.editModal).find('form')[0])
|
||||
body.set('idx', idx)
|
||||
if (body.has('rut')) {
|
||||
body.set('rut', body.get('rut').replace(/\D/g, ''))
|
||||
body.set('digito', Rut.digitoVerificador(body.get('rut')))
|
||||
}
|
||||
const url = '{{$urls->api}}/contabilidad/movimiento/' + id + '/detalles'
|
||||
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
response.json().then(json => {
|
||||
if (!json.status || json.movimiento === null || json.movimiento.detalles === null) {
|
||||
return
|
||||
}
|
||||
const idx = diaria.data.cartolas.findIndex(cartola => cartola.idx = json.input.idx)
|
||||
const movimiento = diaria.data.cartolas[idx].movimientos.find(movimiento => movimiento.id === id)
|
||||
movimiento.centro = json.movimiento.detalles.centro_costo.id
|
||||
movimiento.categoria = json.movimiento.detalles.categoria
|
||||
movimiento.detalle = json.movimiento.detalles.detalle
|
||||
movimiento.rut = json.movimiento.detalles.rut
|
||||
movimiento.digito = json.movimiento.detalles.digito
|
||||
movimiento.nombres = json.movimiento.detalles.nombres
|
||||
movimiento.identificador = json.movimiento.detalles.identificador
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
$(this.ids.editModal).find('.dropdown').dropdown()
|
||||
$(this.ids.editModal).find('[name="rut"]').on('input', function(event) {
|
||||
const rut = event.currentTarget.value
|
||||
const rut_clean = rut.replace(/\D/g, '')
|
||||
event.currentTarget.value = Rut.format(rut_clean)
|
||||
document.getElementById('digito').innerHTML = Rut.digitoVerificador(rut_clean)
|
||||
}.bind(this))
|
||||
const rut = $(this.ids.editModal).find('[name="rut"]')
|
||||
const rut_clean = rut.val().replace(/\D/g, '')
|
||||
rut.val(Rut.format(rut_clean))
|
||||
document.getElementById('digito').innerHTML = Rut.digitoVerificador(rut_clean)
|
||||
}
|
||||
}
|
||||
const manual = {
|
||||
@ -863,8 +807,7 @@
|
||||
add: '#add_button',
|
||||
process: '#process_button'
|
||||
},
|
||||
loader: '#loader',
|
||||
editModal: '#edit_modal'
|
||||
loader: '#loader'
|
||||
})
|
||||
manual.setup({
|
||||
modal: '#manual_modal',
|
||||
|
@ -1,345 +0,0 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">
|
||||
Importar 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">
|
||||
</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>
|
||||
</div>
|
||||
<table class="ui celled table" id="movimientos" style="display: none;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sigla</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 class="center aligned">Centro de Costo</th>
|
||||
<th>Categoría</th>
|
||||
<th>Detalle</th>
|
||||
<th>RUT</th>
|
||||
<th>Nombres</th>
|
||||
<th class="center aligned">Identificador</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
class Cartola {
|
||||
props
|
||||
ids
|
||||
constructor({index, ids}) {
|
||||
this.props = {
|
||||
index
|
||||
}
|
||||
this.ids = ids
|
||||
}
|
||||
get sociedad() {
|
||||
return $(`#${this.ids.sociedad}${this.props.index}`).dropdown('get value')
|
||||
}
|
||||
get banco() {
|
||||
return $(`#${this.ids.banco}${this.props.index}`).dropdown('get value')
|
||||
}
|
||||
get mes() {
|
||||
return $(`#${this.ids.mes}${this.props.index}`).calendar('get date')
|
||||
}
|
||||
get file() {
|
||||
return $(`#archivo${this.props.index}`)[0].files[0]
|
||||
}
|
||||
get data() {
|
||||
return {
|
||||
sociedad_rut: this.sociedad,
|
||||
cuenta_id: this.banco,
|
||||
mes: [this.mes.getFullYear(), this.mes.getMonth() + 1, 1].join('-'),
|
||||
file: this.file,
|
||||
index: this.props.index
|
||||
}
|
||||
}
|
||||
draw({sociedades}) {
|
||||
const output = [
|
||||
`<div class="fields" data-idx="${this.props.index}">`,
|
||||
'<div class="five wide field">',
|
||||
'<label>Sociedad</label>',
|
||||
`<div class="ui search selection dropdown" id="${this.ids.sociedad}${this.props.index}">`,
|
||||
`<input type="hidden" name="sociedad_rut${this.props.index}" />`,
|
||||
'<i class="dropdown icon"></i>',
|
||||
'<div class="default text">Sociedad</div>',
|
||||
'<div class="menu">',
|
||||
...sociedades.map(sociedad => {
|
||||
return [
|
||||
`<div class="item" data-value="${sociedad.rut}">${sociedad.razon}</div>`
|
||||
].join("\n")
|
||||
}),
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="four wide field">',
|
||||
'<label>Banco</label>',
|
||||
`<div class="ui search selection dropdown" id="${this.ids.banco}${this.props.index}">`,
|
||||
`<input type="hidden" name="banco_id${this.props.index}" />`,
|
||||
'<i class="dropdown icon"></i>',
|
||||
'<div class="default text">Banco</div>',
|
||||
'<div class="menu"></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<label>Mes</label>',
|
||||
`<div class="ui calendar" id="${this.ids.mes}${this.props.index}">`,
|
||||
'<div class="ui input left icon">',
|
||||
'<i class="calendar icon"></i>',
|
||||
`<input type="text" name="mes${this.props.index}" placeholder="Mes" />`,
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<label>Archivo</label>',
|
||||
`<input type="file" class="ui invisible file input" name="archivo${this.props.index}" id="archivo${this.props.index}" />`,
|
||||
`<label for="archivo${this.props.index}" class="ui icon button" id="archivo_button">`,
|
||||
'<i class="file icon"></i>',
|
||||
'</label>',
|
||||
'</div>',
|
||||
]
|
||||
if (this.props.index > 1) {
|
||||
output.push(...[
|
||||
'<div class="field">',
|
||||
'<label> </label>',
|
||||
`<button class="ui red icon button remove" data-idx="${this.props.index}">`,
|
||||
'<i class="trash icon"></i>',
|
||||
'</button>',
|
||||
'</div>',
|
||||
])
|
||||
}
|
||||
output.push('</div>')
|
||||
return output.join("\n")
|
||||
}
|
||||
activate() {
|
||||
$(`#${this.ids.sociedad}${this.props.index}`).dropdown({
|
||||
onChange: (value, text, $choice) => {
|
||||
cartolas.fetch().bancos(value).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(data => {
|
||||
const dropdown = $(`#${this.ids.banco}${this.props.index}`)
|
||||
dropdown.dropdown('clear')
|
||||
dropdown.dropdown('change values', data.cuentas.map(cuenta => {
|
||||
const desc = [cuenta.banco.nombre, cuenta.cuenta].join(' - ')
|
||||
return {
|
||||
name: desc,
|
||||
value: cuenta.id,
|
||||
text: desc
|
||||
}
|
||||
}))
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
$(`#${this.ids.banco}${this.props.index}`).dropdown()
|
||||
const cdo = structuredClone(calendar_date_options)
|
||||
cdo.type = 'month'
|
||||
$(`#${this.ids.mes}${this.props.index}`).calendar(cdo)
|
||||
if (this.props.index > 1) {
|
||||
$(`.${this.ids.buttons.remove}[data-idx="${this.props.index}"]`).click(clickEvent => {
|
||||
const index = $(clickEvent.currentTarget).data('idx')
|
||||
this.remove(index)
|
||||
})
|
||||
}
|
||||
}
|
||||
remove(idx) {
|
||||
$(`.fields[data-idx=${idx}]`).remove()
|
||||
cartolas.data.cartolas = cartolas.data.cartolas.filter(cartola => cartola.props.index !== idx)
|
||||
cartolas.draw().form()
|
||||
}
|
||||
}
|
||||
class Movimiento {
|
||||
props
|
||||
constructor({sociedad, fecha, glosa, cargo, abono, saldo, categoria, detalle, centro_costo, rut, nombres, identificador}) {
|
||||
this.props = {
|
||||
sociedad,
|
||||
fecha,
|
||||
glosa,
|
||||
cargo,
|
||||
abono,
|
||||
saldo,
|
||||
categoria,
|
||||
detalle,
|
||||
centro_costo,
|
||||
rut,
|
||||
nombres,
|
||||
identificador
|
||||
}
|
||||
}
|
||||
draw({formatters}) {
|
||||
const fecha = new Date(this.props.fecha)
|
||||
return [
|
||||
'<tr>',
|
||||
`<td>${this.props.sociedad.sigla}</td>`,
|
||||
`<td>${formatters.date.format(fecha)}</td>`,
|
||||
`<td>${this.props.glosa}</td>`,
|
||||
`<td class="right aligned">${formatters.number.format(this.props.cargo ?? 0)}</td>`,
|
||||
`<td class="right aligned">${formatters.number.format(this.props.abono ?? 0)}</td>`,
|
||||
`<td class="right aligned">${formatters.number.format(this.props.saldo)}</td>`,
|
||||
`<td class="center aligned">${this.props.centro_costo ?? ''}</td>`,
|
||||
`<td>${this.props.categoria ?? ''}</td>`,
|
||||
`<td>${this.props.detalle ?? ''}</td>`,
|
||||
`<td>${this.props.rut ?? ''}</td>`,
|
||||
`<td>${this.props.nombres ?? ''}</td>`,
|
||||
`<td class="center aligned">${this.props.identificador ?? ''}</td>`,
|
||||
'</tr>'
|
||||
].join("\n")
|
||||
}
|
||||
}
|
||||
const cartolas = {
|
||||
ids: {},
|
||||
data: {
|
||||
sociedades: {!! json_encode($inmobiliarias) !!},
|
||||
bancos: {!! json_encode($bancos) !!},
|
||||
cartolas: [],
|
||||
movimientos: [],
|
||||
},
|
||||
formatters: {
|
||||
number: new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0}),
|
||||
date: new Intl.DateTimeFormat('es-CL', {dateStyle: 'short', timeStyle: 'short'})
|
||||
},
|
||||
add() {
|
||||
return {
|
||||
cartola: () => {
|
||||
const idx = cartolas.data.cartolas.length + 1
|
||||
const cartola = new Cartola({index: idx, ids: cartolas.ids.cartolas})
|
||||
cartolas.data.cartolas.push(cartola)
|
||||
cartolas.draw().form()
|
||||
}
|
||||
}
|
||||
},
|
||||
draw() {
|
||||
return {
|
||||
form: () => {
|
||||
const form = $(this.ids.form)
|
||||
form.empty()
|
||||
form.append(`<input type="hidden" name="cartolas" value="${this.data.cartolas.length}" />`)
|
||||
this.data.cartolas.forEach(cartola => {
|
||||
form.append(cartola.draw({sociedades: this.data.sociedades, bancos: this.data.bancos}))
|
||||
cartola.activate()
|
||||
})
|
||||
},
|
||||
movimientos: () => {
|
||||
const table = $(this.ids.movimientos)
|
||||
const tbody = table.find('tbody')
|
||||
tbody.empty()
|
||||
this.data.movimientos.forEach(movimiento => {
|
||||
tbody.append(movimiento.draw({formatters: this.formatters}))
|
||||
})
|
||||
table.show()
|
||||
}
|
||||
}
|
||||
},
|
||||
fetch() {
|
||||
return {
|
||||
bancos: sociedad_rut => {
|
||||
const url = `{{$urls->api}}/inmobiliaria/${sociedad_rut}/cuentas`
|
||||
return fetchAPI(url)
|
||||
}
|
||||
}
|
||||
},
|
||||
import() {
|
||||
return {
|
||||
cartolas: () => {
|
||||
const url = '{{$urls->api}}/contabilidad/cartolas/importar'
|
||||
const method = 'post'
|
||||
const body = new FormData()
|
||||
this.data.cartolas.forEach(cartola => {
|
||||
Object.entries(cartola.data).forEach(([key, value]) => {
|
||||
const name = `${key}[${cartola.props.index - 1}]`
|
||||
body.append(name, value)
|
||||
})
|
||||
})
|
||||
|
||||
fetchAPI(url, {method, body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(data => {
|
||||
if (data.errors.length > 0) {
|
||||
data.errors.forEach(errorData => {
|
||||
console.error(errorData)
|
||||
})
|
||||
}
|
||||
this.data.movimientos = data.movimientos.map(movimiento => new Movimiento(movimiento))
|
||||
this.draw().movimientos()
|
||||
})
|
||||
}).catch(error => {
|
||||
const table = $(this.ids.movimientos)
|
||||
const tbody = table.find('tbody')
|
||||
tbody.empty()
|
||||
table.hide()
|
||||
}).finally(() => {
|
||||
$(this.ids.loader).hide()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
this.add().cartola()
|
||||
$(this.ids.buttons.add).click(() => {
|
||||
this.add().cartola()
|
||||
})
|
||||
$(this.ids.loader).hide()
|
||||
$(this.ids.form).submit(submitEvent => {
|
||||
submitEvent.preventDefault()
|
||||
$(this.ids.loader).show()
|
||||
this.import().cartolas()
|
||||
return false
|
||||
})
|
||||
$(this.ids.buttons.process).click(() => {
|
||||
$(this.ids.form).submit()
|
||||
})
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
cartolas.setup({
|
||||
form: '#cartola_form',
|
||||
buttons: {
|
||||
add: '#add_button',
|
||||
process: '#process_button'
|
||||
},
|
||||
movimientos: '#movimientos',
|
||||
loader: '#loader',
|
||||
cartolas: {
|
||||
sociedad: 'sociedad',
|
||||
banco: 'banco',
|
||||
mes: 'mes',
|
||||
buttons: {
|
||||
remove: 'remove'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -14,10 +14,9 @@
|
||||
<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>
|
||||
@ -41,7 +40,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
|
||||
@ -120,20 +119,20 @@
|
||||
mes: '',
|
||||
movimientos: [],
|
||||
centrosCostos: {
|
||||
ingresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
ingresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return [
|
||||
'id' => $centroCosto->id,
|
||||
'descripcion' => $centroCosto->descripcion
|
||||
];
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return $centroCosto->tipoCentro->descripcion === 'Ingreso';
|
||||
})))) !!}'),
|
||||
egresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
egresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return [
|
||||
'id' => $centroCosto->id,
|
||||
'descripcion' => $centroCosto->descripcion
|
||||
];
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return $centroCosto->tipoCentro->descripcion === 'Egreso';
|
||||
})))) !!}'),
|
||||
}
|
||||
@ -171,11 +170,7 @@
|
||||
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')
|
||||
})
|
||||
})
|
||||
@ -252,12 +247,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 = ''
|
||||
}
|
||||
@ -299,10 +294,7 @@
|
||||
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(
|
||||
@ -330,7 +322,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) {
|
||||
|
@ -1,225 +0,0 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">
|
||||
Cuadratura de Cartola Mensual
|
||||
</h1>
|
||||
<form class="ui form" id="cuadratura_form">
|
||||
<div class="ui grid">
|
||||
<div class="fourteen wide column">
|
||||
<div class="fields">
|
||||
<div class="five wide field">
|
||||
<label>Inmobiliaria</label>
|
||||
<div class="ui selection search dropdown" id="inmobiliaria">
|
||||
<input type="hidden" name="inmobiliaria"/>
|
||||
<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="two wide field">
|
||||
<label>Banco</label>
|
||||
<div class="ui selection search dropdown" id="banco">
|
||||
<input type="hidden" name="banco"/>
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Banco</div>
|
||||
<div class="menu"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Mes</label>
|
||||
<div class="ui calendar" id="mes">
|
||||
<div class="ui icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="mes"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="file">Cartola</label>
|
||||
<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
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two wide middle aligned column">
|
||||
<button class="ui icon button">
|
||||
Procesar
|
||||
<i class="sync icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="ui two columns grid">
|
||||
<div class="column"></div>
|
||||
<div class="right aligned column">
|
||||
<div class="ui inline active loader" id="loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui fluid container" id="movimientos"></div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
class LibroMayor {
|
||||
props
|
||||
constructor(props) {
|
||||
this.props = props
|
||||
}
|
||||
}
|
||||
class Cartola {
|
||||
|
||||
}
|
||||
const movimientos = {
|
||||
ids: {},
|
||||
data: {
|
||||
inmobiliaria: {
|
||||
rut: '',
|
||||
razon: ''
|
||||
},
|
||||
banco: {
|
||||
id: '',
|
||||
nombre: ''
|
||||
}
|
||||
},
|
||||
get() {
|
||||
return {
|
||||
bancos: inmobiliaria_rut => {
|
||||
const url = '{{$urls->api}}/inmobiliaria/' + inmobiliaria_rut + '/cuentas'
|
||||
$(this.ids.loader).show()
|
||||
return fetchAPI(url).then(response => {
|
||||
$(this.ids.loader).hide()
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.cuentas.length === 0) {
|
||||
return
|
||||
}
|
||||
$(this.ids.inputs.banco).dropdown('change values', json.cuentas.map(cuenta => {
|
||||
return {value: cuenta.banco.id, text: cuenta.banco.nombre, name: cuenta.banco.nombre}
|
||||
})).dropdown('refresh')
|
||||
})
|
||||
})
|
||||
},
|
||||
firstDate: inmobiliaria_rut => {
|
||||
const url = '{{$urls->api}}/inmobiliaria/' + inmobiliaria_rut + '/proyectos'
|
||||
$(this.ids.loader).show()
|
||||
return fetchAPI(url).then(response => {
|
||||
$(this.ids.loader).hide()
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.proyectos.length === 0) {
|
||||
return
|
||||
}
|
||||
const min = json.proyectos.reduce((min, proyecto) => {
|
||||
const date = new Date(proyecto.current_estado.fecha.date)
|
||||
if (min > date.getTime()) {
|
||||
return date.getTime()
|
||||
}
|
||||
return min
|
||||
}, (new Date()).getTime())
|
||||
$(this.ids.inputs.mes).calendar('set minDate', new Date(min))
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
parse() {
|
||||
return {
|
||||
cartola: submitEvent => {
|
||||
submitEvent.preventDefault()
|
||||
const body = new FormData(document.getElementById('asignar_form'))
|
||||
body.set('mes', $(this.ids.inputs.mes).calendar('get date').toISOString())
|
||||
const url = '{{$urls->api}}/contabilidad/cartolas/procesar'
|
||||
$(this.ids.loader).show()
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
$(this.ids.loader).hide()
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.movimientos.length === 0) {
|
||||
return
|
||||
}
|
||||
this.data.movimientos = []
|
||||
json.movimientos.forEach((row, idx) => {
|
||||
const fecha = new Date(row.fecha)
|
||||
fecha.setDate(fecha.getDate() + 1)
|
||||
this.data.movimientos[idx] = {
|
||||
fecha: fecha,
|
||||
glosa: row.glosa,
|
||||
documento: row.documento,
|
||||
cargo: row.cargo,
|
||||
abono: row.abono,
|
||||
}
|
||||
})
|
||||
this.draw().cartola()
|
||||
})
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
|
||||
$(this.ids.inputs.inmobiliaria).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.inmobiliaria.rut = value
|
||||
this.data.inmobiliaria.razon = text
|
||||
this.get().bancos(value)
|
||||
this.get().firstDate(value)
|
||||
},
|
||||
})
|
||||
$(this.ids.inputs.banco).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.banco.id = value
|
||||
this.data.banco.nombre = text
|
||||
}
|
||||
})
|
||||
$(this.ids.loader).hide()
|
||||
|
||||
calendar_date_options['type'] = 'month'
|
||||
const lastMonth = new Date()
|
||||
lastMonth.setDate(0)
|
||||
calendar_date_options['maxDate'] = lastMonth
|
||||
calendar_date_options['onChange'] = (date, text, mode) => {
|
||||
this.data.mes = text
|
||||
}
|
||||
$(this.ids.inputs.mes).calendar(calendar_date_options)
|
||||
$(this.ids.form).submit(this.parse().cartola)
|
||||
//$(this.ids.button).click(this.export().cartola)
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
movimientos.setup({
|
||||
movimientos: '#movimientos',
|
||||
form: '#cuadratura_form',
|
||||
loader: '#loader',
|
||||
inputs: {
|
||||
inmobiliaria: '#inmobiliaria',
|
||||
banco: '#banco',
|
||||
mes: '#mes',
|
||||
cartola: '#file'
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -1,23 +1,14 @@
|
||||
@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;">
|
||||
<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>
|
||||
Descargar en Excel <i class="file excel icon"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@ -28,11 +19,7 @@
|
||||
<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>
|
||||
<td>{{$anterior->format('d/m/Y')}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Informe actual</td>
|
||||
@ -53,17 +40,6 @@
|
||||
</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>
|
||||
@ -84,31 +60,27 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($informes['sociedades'] as $sociedad_rut => $informe)
|
||||
@foreach ($informes['inmobiliarias'] as $inmobiliaria_rut => $informe)
|
||||
@foreach ($informe->cuentas as $i => $cuenta)
|
||||
<tr>
|
||||
@if ($i === 0)
|
||||
<td rowspan="{{count($informe->cuentas)}}">{{$informe->sociedad->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>
|
||||
<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>
|
||||
@ -151,7 +123,7 @@
|
||||
@foreach ($movimientos as $ms)
|
||||
@foreach ($ms as $movimiento)
|
||||
<tr>
|
||||
<td>{{$movimiento->cuenta->inmobiliaria->razon}}</td>
|
||||
<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>
|
||||
@ -170,7 +142,7 @@
|
||||
</tr>
|
||||
@foreach ($movimientos as $movimiento)
|
||||
<tr>
|
||||
<td>{{$movimiento->cuenta->inmobiliaria->razon}}</td>
|
||||
<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>
|
||||
|
@ -1,136 +0,0 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.head.styles.datatables.searchbuilder')
|
||||
@include('layout.head.styles.datatables.buttons')
|
||||
|
||||
@push('page_styles')
|
||||
<style>
|
||||
#table_container {
|
||||
margin-left: 1rem;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">Movimientos Contables</h1>
|
||||
<form class="ui form" id="movimientos_form">
|
||||
<div class="fields">
|
||||
<div class="six wide field">
|
||||
<label for="sociedad">Sociedad</label>
|
||||
<div class="ui selection search multiple dropdown" id="sociedades">
|
||||
<input type="hidden" name="sociedad[]"/>
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Sociedad</div>
|
||||
<div class="menu">
|
||||
@foreach($sociedades as $sociedad)
|
||||
<div class="item" data-value="{{$sociedad->rut}}">{{$sociedad->razon}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label for="mes">Mes</label>
|
||||
<div class="ui calendar" id="mes">
|
||||
<div class="ui right icon input">
|
||||
<input type="text" name="mes"/>
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label></label>
|
||||
<button class="ui circular icon button">
|
||||
<i class="sync alternate icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div id="table_container">
|
||||
<table id="tabla_movimientos" class="ui compact table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sigla</th>
|
||||
<th>Banco</th>
|
||||
<th>Cuenta</th>
|
||||
<th>Fecha</th>
|
||||
<th>ISO Fecha</th>
|
||||
<th>Mes</th>
|
||||
<th>Año</th>
|
||||
<th class="right aligned">Valor</th>
|
||||
<th>Valor</th>
|
||||
<th>Glosa</th>
|
||||
<th>Centro de Costo</th>
|
||||
<th>Detalle</th>
|
||||
<th>Editar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="movimientos"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
@include('contabilidad.movimientos.edit_modal')
|
||||
@endsection
|
||||
|
||||
@include('layout.body.scripts.datatables')
|
||||
@include('layout.body.scripts.datatables.searchbuilder')
|
||||
@include('layout.body.scripts.datatables.buttons')
|
||||
@include('layout.body.scripts.rut')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
class CentrosCostos {
|
||||
static data = []
|
||||
static get() {
|
||||
if (this.data.length === 0) {
|
||||
this.data = JSON.parse('{!! json_encode($centros) !!}')
|
||||
}
|
||||
return this.data
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@push('page_scripts')
|
||||
@include('contabilidad.movimientos.scripts.event_handler')
|
||||
@include('contabilidad.movimientos.scripts.loading_handler')
|
||||
@include('contabilidad.movimientos.scripts.control_form')
|
||||
@include('contabilidad.movimientos.scripts.movimientos_table')
|
||||
@include('contabilidad.movimientos.scripts.edit_modal')
|
||||
@include('contabilidad.movimientos.scripts.edit_form')
|
||||
@include('contabilidad.movimientos.scripts.movimientos_handler')
|
||||
@include('contabilidad.movimientos.scripts.results_handler')
|
||||
<script>
|
||||
const app = {
|
||||
handlers: {},
|
||||
setup() {
|
||||
this.handlers.results = new ResultsHandler()
|
||||
this.handlers.loading = new LoadingHandler({id: '#movimientos_form'})
|
||||
this.handlers.movimientos = new MovimientosHandler({
|
||||
urls: {
|
||||
get: '{{$urls->api}}/contabilidad/movimientos/sociedad/mes',
|
||||
edit: '{{$urls->api}}/contabilidad/movimientos/edit',
|
||||
remove: '{{$urls->api}}/contabilidad/movimiento',
|
||||
},
|
||||
loadingHandler: this.handlers.loading,
|
||||
resultsHandler: this.handlers.results
|
||||
})
|
||||
this.handlers.forms = {
|
||||
edit: new EditForm({ids: {modal: '#movimientos_modal', data: '#movimientos_data', form: '#movimientos_edit',}})
|
||||
}
|
||||
this.handlers.modals = {
|
||||
edit: new EditModal({ids: {modal: '#movimientos_modal'}, editForm: this.handlers.forms.edit})
|
||||
}
|
||||
this.handlers.events = new EventHandler({movimientosHandler: this.handlers.movimientos, modalHandler: this.handlers.modals.edit})
|
||||
this.handlers.table = new MovimientosTable({ids: {table: '#tabla_movimientos', buttons: {edit: '.edit_button', remove: '.remove_button'}}, eventHandler: this.handlers.events})
|
||||
this.handlers.forms.control = new ControlForm({ids: {form: '#movimientos_form', sociedades: '#sociedades', mes: '#mes',},})
|
||||
|
||||
this.handlers.forms.edit.setup()
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
app.setup()
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -1,67 +0,0 @@
|
||||
<div class="ui fluid modal" id="movimientos_modal">
|
||||
<div class="content">
|
||||
<h3 class="header">
|
||||
Editar Movimiento
|
||||
</h3>
|
||||
<div class="ui divider"></div>
|
||||
<div class="ui grid container" id="modal_info">
|
||||
<div class="column sociedad"></div>
|
||||
<div class="column banco"></div>
|
||||
<div class="column cuenta"></div>
|
||||
<div class="column fecha"></div>
|
||||
<div class="column valor"></div>
|
||||
<div class="column glosa"></div>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
<form class="ui form" id="movimientos_edit">
|
||||
<input type="hidden" name="index"/>
|
||||
<input type="hidden" name="id"/>
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label for="centro_costo">Centro de Costo</label>
|
||||
<div class="ui selection search dropdown" id="centro_costo">
|
||||
<input type="hidden" name="centro_id"/>
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Centro de Costo</div>
|
||||
<div class="menu">
|
||||
@foreach($centros as $centroCosto)
|
||||
<div class="item" data-value="{{$centroCosto->id}}">{{$centroCosto->id}} - {{$centroCosto->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Categoría</label>
|
||||
<input type="text" name="categoria" placeholder="Categoría" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Identificador</label>
|
||||
<input type="text" name="identificador" placeholder="Identificador" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label>RUT</label>
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="rut" placeholder="RUT" />
|
||||
<div class="ui basic label">-<span id="digito"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Nombre</label>
|
||||
<input type="text" name="nombre" placeholder="Nombre" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="detalle">Detalle</label>
|
||||
<div class="ui input">
|
||||
<textarea id="detalle" name="detalle"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<div class="ui red cancel button">Cancelar</div>
|
||||
<div class="ui green approve success button">Guardar</div>
|
||||
</div>
|
||||
</div>
|
@ -1,22 +0,0 @@
|
||||
<script>
|
||||
class ControlForm {
|
||||
props
|
||||
constructor({ids,}) {
|
||||
this.props = {
|
||||
ids,
|
||||
}
|
||||
$(this.props.ids.sociedades).dropdown()
|
||||
|
||||
const cdo = structuredClone(calendar_date_options)
|
||||
cdo['type'] = 'month'
|
||||
cdo['maxDate'] = new Date()
|
||||
$(this.props.ids.mes).calendar(cdo)
|
||||
|
||||
$(this.props.ids.form).on('submit', {
|
||||
sociedades_id: this.props.ids.sociedades,
|
||||
mes_id: this.props.ids.mes,
|
||||
handler: app.handlers.events
|
||||
}, app.handlers.events.get().movimientos)
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,98 +0,0 @@
|
||||
<script>
|
||||
class EditForm {
|
||||
props
|
||||
fields
|
||||
constructor({ids}) {
|
||||
this.props = {
|
||||
ids,
|
||||
movimientos: []
|
||||
}
|
||||
this.fields = [
|
||||
{
|
||||
name: 'index',
|
||||
value: index => index
|
||||
},
|
||||
{
|
||||
name: 'id',
|
||||
value: movimiento => movimiento.id
|
||||
},
|
||||
{
|
||||
id: 'centro_costo',
|
||||
name: 'centro_id',
|
||||
type: 'dropdown',
|
||||
value: movimiento => movimiento.detalles.centro_costo.id ?? '',
|
||||
values: CentrosCostos.get().map(centroCosto => {
|
||||
return {
|
||||
value: centroCosto.id,
|
||||
name: `${centroCosto.id} - ${centroCosto.descripcion}`,
|
||||
text: `${centroCosto.id} - ${centroCosto.descripcion}`,
|
||||
}
|
||||
})
|
||||
},
|
||||
{
|
||||
name: 'rut',
|
||||
type: 'text',
|
||||
value: movimiento => movimiento.detalles.rut ?? ''
|
||||
},
|
||||
{
|
||||
id: 'digito',
|
||||
value: movimiento => movimiento.detalles.digito ?? ''
|
||||
},
|
||||
{
|
||||
name: 'nombre',
|
||||
type: 'text',
|
||||
value: movimiento => movimiento.detalles.nombres ?? ''
|
||||
},
|
||||
{
|
||||
name: 'categoria',
|
||||
type: 'text',
|
||||
value: movimiento => movimiento.detalles.categoria ?? ''
|
||||
},
|
||||
{
|
||||
name: 'detalle',
|
||||
type: 'text',
|
||||
value: movimiento => movimiento.detalles.detalle ?? ''
|
||||
},
|
||||
{
|
||||
name: 'identificador',
|
||||
type: 'text',
|
||||
value: movimiento => movimiento.detalles.identificador ?? ''
|
||||
}
|
||||
]
|
||||
|
||||
this.fields.filter(field => typeof field.values !== 'undefined').forEach(field => {
|
||||
$(this.props.ids.form).find(`#${field.id}`).dropdown('change values', field.values)
|
||||
})
|
||||
}
|
||||
reset() {
|
||||
$(this.props.ids.form).form('reset')
|
||||
}
|
||||
show({modal, movimiento, index}) {
|
||||
modal.find(this.props.ids.data).show()
|
||||
|
||||
this.fields.forEach(field => {
|
||||
if (typeof field.name !== 'undefined') {
|
||||
switch (field.type) {
|
||||
case 'dropdown':
|
||||
modal.find(`#${field.id}`).dropdown('set selected', field.value(movimiento))
|
||||
break
|
||||
default:
|
||||
if (field.name === 'index') {
|
||||
modal.find(`[name='${field.name}']`).val(index)
|
||||
return
|
||||
}
|
||||
modal.find(`[name='${field.name}']`).val(field.value(movimiento))
|
||||
break
|
||||
}
|
||||
return
|
||||
}
|
||||
modal.find(`#${field.id}`).text(field.value(movimiento))
|
||||
})
|
||||
}
|
||||
setup() {
|
||||
$(this.props.ids.form).on('submit', {
|
||||
form_id: this.props.ids.form,
|
||||
}, app.handlers.events.edit().modal)
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,74 +0,0 @@
|
||||
<script>
|
||||
class EditModal {
|
||||
props
|
||||
info
|
||||
constructor({ids, editForm}) {
|
||||
this.props = {
|
||||
ids,
|
||||
editForm,
|
||||
movimientos: []
|
||||
}
|
||||
this.info = [
|
||||
{
|
||||
className: 'sociedad',
|
||||
width: 'three wide',
|
||||
value: movimiento => `<b>Sociedad</b>: ${movimiento.cuenta.inmobiliaria.sigla}`
|
||||
},
|
||||
{
|
||||
className: 'banco',
|
||||
width: 'three wide',
|
||||
value: movimiento => `<b>Banco</b>: ${movimiento.cuenta.banco.nombre}`
|
||||
},
|
||||
{
|
||||
className: 'cuenta',
|
||||
width: 'three wide',
|
||||
value: movimiento => `<b>Cuenta</b>: ${movimiento.cuenta.cuenta}`
|
||||
},
|
||||
{
|
||||
className: 'fecha',
|
||||
width: 'three wide',
|
||||
value: movimiento => `<b>Fecha</b>: ${movimiento.fecha}`
|
||||
},
|
||||
{
|
||||
className: 'valor',
|
||||
width: 'three wide',
|
||||
value: movimiento => `<b>Valor</b>: ${movimiento.abono - movimiento.cargo}`
|
||||
},
|
||||
{
|
||||
className: 'glosa',
|
||||
width: 'ten wide',
|
||||
value: movimiento => `<b>Glosa</b>: ${movimiento.glosa}`
|
||||
},
|
||||
]
|
||||
|
||||
const $info = $(this.props.ids.modal).find('#modal_info')
|
||||
$info.empty()
|
||||
this.info.forEach(field => {
|
||||
$info.append(`<div class="${field.width} column ${field.className}"></div>`)
|
||||
})
|
||||
|
||||
$(this.props.ids.modal).modal({
|
||||
onApprove: $element => {
|
||||
$(this.props.editForm.props.ids.form).submit()
|
||||
}
|
||||
})
|
||||
}
|
||||
reset() {
|
||||
this.info.forEach(info => {
|
||||
$(this.props.ids.modal).find(`.${info.className}`).text('')
|
||||
})
|
||||
this.props.editForm.reset()
|
||||
}
|
||||
show({movimiento, index}) {
|
||||
$(this.props.ids.modal).modal('show')
|
||||
this.info.forEach(info => {
|
||||
$(this.props.ids.modal).find(`.${info.className}`).html(info.value(movimiento))
|
||||
})
|
||||
this.props.editForm.show({modal: $(this.props.ids.modal), movimiento, index})
|
||||
}
|
||||
hide() {
|
||||
$(this.props.ids.modal).modal('hide')
|
||||
this.reset()
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,54 +0,0 @@
|
||||
<script>
|
||||
class EventHandler {
|
||||
props
|
||||
constructor({movimientosHandler, modalHandler}) {
|
||||
this.props = {
|
||||
movimientosHandler,
|
||||
modalHandler
|
||||
}
|
||||
}
|
||||
get() {
|
||||
return {
|
||||
movimientos: submitEvent => {
|
||||
submitEvent.preventDefault()
|
||||
submitEvent.data.handler.props.movimientosHandler.get().movimientos({
|
||||
sociedades_ruts: $(submitEvent.data.sociedades_id).dropdown('get values'),
|
||||
mes: $(submitEvent.data.mes_id).calendar('get date')
|
||||
}).then(() => {
|
||||
app.handlers.table.draw().table(app.handlers.results.props.parsed)
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
edit() {
|
||||
return {
|
||||
movimiento: clickEvent => {
|
||||
const id = $(clickEvent.currentTarget).data('id')
|
||||
const index = $(clickEvent.currentTarget).data('index')
|
||||
const movimiento = this.props.movimientosHandler.find().id(id)
|
||||
clickEvent.data.handler.props.modalHandler.show({movimiento, index})
|
||||
},
|
||||
modal: submitEvent => {
|
||||
submitEvent.preventDefault()
|
||||
const form = submitEvent.currentTarget
|
||||
const data = new FormData(form)
|
||||
app.handlers.movimientos.edit().movimiento(data).then(() => {
|
||||
app.handlers.table.draw().table(app.handlers.results.props.parsed)
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
remove() {
|
||||
return {
|
||||
movimiento: clickEvent => {
|
||||
const id = $(clickEvent.currentTarget).data('id')
|
||||
app.handlers.movimientos.remove().movimiento(id).then(() => {
|
||||
app.handlers.table.draw().table(app.handlers.results.props.parsed)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,16 +0,0 @@
|
||||
<script>
|
||||
class LoadingHandler {
|
||||
props
|
||||
constructor(ids) {
|
||||
this.props = {
|
||||
...ids
|
||||
}
|
||||
}
|
||||
show() {
|
||||
$(this.props.id).addClass('loading')
|
||||
}
|
||||
hide() {
|
||||
$(this.props.id).removeClass('loading')
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,86 +0,0 @@
|
||||
<script>
|
||||
class MovimientosHandler {
|
||||
props
|
||||
constructor({urls, loadingHandler, resultsHandler}) {
|
||||
this.props = {
|
||||
urls,
|
||||
loadingHandler,
|
||||
resultsHandler
|
||||
}
|
||||
}
|
||||
get() {
|
||||
return {
|
||||
movimientos: ({sociedades_ruts, mes}) => {
|
||||
this.props.loadingHandler.show()
|
||||
const method = 'post'
|
||||
const body = new FormData()
|
||||
sociedades_ruts.forEach(sociedad_rut => {
|
||||
body.append('sociedades_ruts[]', sociedad_rut)
|
||||
})
|
||||
body.set('mes', [mes.getFullYear(), mes.getMonth() + 1, mes.getDate()].join('-'))
|
||||
return APIClient.fetch(this.props.urls.get, {method, body}).then(response => {
|
||||
if (!response) {
|
||||
throw new Error('No se pudo obtener los movimientos')
|
||||
}
|
||||
return response.json().then(json => {
|
||||
this.movimientos = json.movimientos
|
||||
this.props.resultsHandler.props.movimientos = json.movimientos
|
||||
this.props.resultsHandler.parse().movimientos()
|
||||
return json.movimientos
|
||||
})
|
||||
}).catch(error => {
|
||||
console.error(error)
|
||||
}).finally(() => {
|
||||
this.props.loadingHandler.hide()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
edit() {
|
||||
return {
|
||||
movimiento: (data) => {
|
||||
data.set('digito', Rut.digitoVerificador(data.get('rut')))
|
||||
const method = 'post'
|
||||
return APIClient.fetch(this.props.urls.edit, {method, body: data}).then(response => {
|
||||
if (!response) {
|
||||
throw new Error('No se pudo editar el movimiento')
|
||||
}
|
||||
return response.json().then(json => {
|
||||
this.props.resultsHandler.props.movimientos = this.props.resultsHandler.props.movimientos.map(movimiento => {
|
||||
if (movimiento.id === json.movimiento.id) {
|
||||
movimiento.detalles = json.movimiento.detalles
|
||||
}
|
||||
return movimiento
|
||||
})
|
||||
this.props.resultsHandler.parse().movimientos()
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
remove() {
|
||||
return {
|
||||
movimiento: id => {
|
||||
const method = 'delete'
|
||||
const url = this.props.urls.remove.replace(/\/$/, '') + '/' + id
|
||||
return APIClient.fetch(url, {method}).then(response => {
|
||||
if (!response) {
|
||||
throw new Error('No se pudo eliminar el movimiento')
|
||||
}
|
||||
return response.json().then(json => {
|
||||
this.props.resultsHandler.props.movimientos = this.props.resultsHandler.props.movimientos.filter(movimiento => movimiento.id !== id)
|
||||
this.props.resultsHandler.parse().movimientos()
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
find() {
|
||||
return {
|
||||
id: id => {
|
||||
return this.props.resultsHandler.props.movimientos.find(movimiento => movimiento.id === id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,234 +0,0 @@
|
||||
<script>
|
||||
class MovimientosTable {
|
||||
props
|
||||
columns
|
||||
constructor({ids, eventHandler}) {
|
||||
this.props = {
|
||||
ids,
|
||||
eventHandler,
|
||||
movimientos: [],
|
||||
formatters: {
|
||||
number: new Intl.NumberFormat('es-CL'),
|
||||
date: new Intl.DateTimeFormat('es-CL', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric'
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
this.columns = [
|
||||
{title: 'Sigla', defs: {width: 'short', type: 'string'}, searchable: true, export: true}, //0
|
||||
{title: 'Banco', defs: {width: 'long', type: 'string'}, searchable: true, export: true},
|
||||
{title: 'Cuenta', defs: {width: 'short', type: 'string'}, searchable: true, export: true},
|
||||
{title: 'Fecha', defs: {width: 'long', type: 'string'}, searchable: true, export: true},
|
||||
{title: 'ISO Fecha', defs: {visible: false}},
|
||||
{title: 'Mes', defs: {width: 'short', type: 'string'}, searchable: true}, //5
|
||||
{title: 'Año', defs: {width: 'long', type: 'string'}, searchable: true},
|
||||
{title: 'Valor', defs: {className: 'dt-right', width: 'long', type: 'num'}, export: true},
|
||||
{title: 'ISO Valor', defs: {visible: false, type: 'num'}},
|
||||
{title: 'Glosa', defs: {width: 'short', type: 'string'}, export: true},
|
||||
{title: 'Centro de Costo', defs: {width: 'short', type: 'string'}, searchable: true, export: true}, //10
|
||||
{title: 'Categoria', defs: {width: 'short', type: 'string'}},
|
||||
{title: 'Detalle', defs: {width: 'long', type: 'string'}, export: true},
|
||||
{title: 'RUT', defs: {width: 'short', type: 'string'}, export: true},
|
||||
{title: 'Nombre', defs: {width: 'short', type: 'string'}, export: true},
|
||||
{title: 'Identificador', defs: {width: 'short', type: 'string'}, export: true}, //15
|
||||
{title: 'Editar', defs: {width: 'short', type: 'string'}},
|
||||
]
|
||||
const N = this.columns.filter(column => typeof column.defs.visible === 'undefined' || column.defs.visible).length
|
||||
const nShort = this.columns.filter(column => column.defs.width === 'short').length
|
||||
const nLong = this.columns.filter(column => column.defs.width === 'long').length
|
||||
const short = `${(nShort / N).toFixed(2)}%`
|
||||
const long = `${(nLong / N).toFixed(2)}%`
|
||||
|
||||
this.columns = this.columns.map(column => {
|
||||
if (typeof column.defs.width === 'undefined') {
|
||||
return column
|
||||
}
|
||||
switch (column.defs.width) {
|
||||
case 'short':
|
||||
column.defs.width = short
|
||||
break
|
||||
case 'long':
|
||||
column.defs.width = long
|
||||
break
|
||||
}
|
||||
return column
|
||||
})
|
||||
|
||||
const tr = $(this.props.ids.table).find('thead tr')
|
||||
tr.empty()
|
||||
this.columns.forEach(column => {
|
||||
if (typeof column.defs.className === 'undefined') {
|
||||
tr.append(`<th>${column.title}</th>`)
|
||||
return
|
||||
}
|
||||
switch (column.defs.className) {
|
||||
case 'dt-right':
|
||||
tr.append(`<th class="right aligned">${column.title}</th>`)
|
||||
break
|
||||
case 'dt-center':
|
||||
tr.append(`<th class="center aligned">${column.title}</th>`)
|
||||
break
|
||||
default:
|
||||
tr.append(`<th>${column.title}</th>`)
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
let dtD = structuredClone(datatables_defaults)
|
||||
const groupedColumns = Object.groupBy(this.columns, ({defs}) => Object.entries(defs).map((field, value) => `${field}: ${value}`).join(' - '))
|
||||
const columnDefs = Object.values(groupedColumns).map(group => {
|
||||
return {
|
||||
targets: group.map(({title}) => title).map(title => this.columns.map(column => column.title).indexOf(title)),
|
||||
...group[0].defs
|
||||
}
|
||||
})
|
||||
const searchBuilderColumns = this.columns.filter(column => column.searchable)
|
||||
.map(column => column.title).map(title => this.columns.map(column => column.title).indexOf(title))
|
||||
const exportColumns = this.columns.filter(column => column.export)
|
||||
.map(column => column.title).map(title => this.columns.map(column => column.title).indexOf(title))
|
||||
const order = ['Sigla', 'Banco', 'ISO Fecha'].map(title => {
|
||||
return [this.columns.map(column => column.title).indexOf(title), 'asc']
|
||||
})
|
||||
dtD = Object.assign(dtD, {
|
||||
columnDefs,
|
||||
order,
|
||||
language: Object.assign(dtD.language, {
|
||||
searchBuilder: {
|
||||
add: 'Filtrar',
|
||||
condition: 'Comparador',
|
||||
clearAll: 'Resetear',
|
||||
delete: 'Eliminar',
|
||||
deleteTitle: 'Eliminar Titulo',
|
||||
data: 'Columna',
|
||||
left: 'Izquierda',
|
||||
leftTitle: 'Titulo Izquierdo',
|
||||
logicAnd: 'Y',
|
||||
logicOr: 'O',
|
||||
right: 'Derecha',
|
||||
rightTitle: 'Titulo Derecho',
|
||||
title: {
|
||||
0: 'Filtros',
|
||||
_: 'Filtros (%d)'
|
||||
},
|
||||
value: 'Opciones',
|
||||
valueJoiner: 'y'
|
||||
}
|
||||
}),
|
||||
layout: {
|
||||
top1: {
|
||||
searchBuilder: {
|
||||
columns: searchBuilderColumns,
|
||||
}
|
||||
},
|
||||
top1End: {
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
className: 'green',
|
||||
text: 'Exportar a Excel <i class="file excel icon"></i>',
|
||||
title: 'Movimientos Contables',
|
||||
download: 'open',
|
||||
exportOptions: {
|
||||
columns: exportColumns,
|
||||
format: {
|
||||
body: (data, row, column, node) => {
|
||||
if (column === this.columns.map(({title}) => title).indexOf('Fecha')) {
|
||||
return data.split('-').reverse().join('-')
|
||||
}
|
||||
if (column === this.columns.map(({title}) => title).indexOf('Valor')) {
|
||||
return data.replace(/\./g, '')
|
||||
}
|
||||
return data
|
||||
}
|
||||
}
|
||||
},
|
||||
customize: xlsx => {
|
||||
const sheet = xlsx.xl.worksheets['sheet1.xml']
|
||||
const columns = Object.values($('row[r="2"] t', sheet).map((idx, column) => column.textContent))
|
||||
const columnStylesMap = {
|
||||
Valor: '63',
|
||||
Fecha: '15'
|
||||
}
|
||||
Object.entries(columnStylesMap).forEach((column, style) => {
|
||||
const columnIndex = String.fromCharCode('A'.charCodeAt(0) + columns.indexOf(column))
|
||||
$(`c[r^="${columnIndex}"]`, sheet).attr('s', style)
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
data: this.props.movimientos,
|
||||
rowCallback: (row, data) => {
|
||||
$(row).find(this.props.ids.buttons.edit).on('click', {handler: this.props.eventHandler}, this.props.eventHandler.edit().movimiento)
|
||||
$(row).find(this.props.ids.buttons.remove).on('click', {handler: this.props.eventHandler}, this.props.eventHandler.remove().movimiento)
|
||||
}
|
||||
})
|
||||
this.props.table = new DataTable(this.props.ids.table, dtD)
|
||||
}
|
||||
draw() {
|
||||
return {
|
||||
table: (movimientos) => {
|
||||
const info = this.props.table.page.info()
|
||||
this.props.table.clear().rows.add(this.draw().movimientos(movimientos)).draw()
|
||||
this.props.table.page(info.page).draw(false)
|
||||
$(this.props.ids.buttons.edit).on('click', {handler: this.props.eventHandler}, this.props.eventHandler.edit().movimiento)
|
||||
$(this.props.ids.buttons.remove).on('click', {handler: this.props.eventHandler}, this.props.eventHandler.remove().movimiento)
|
||||
},
|
||||
movimientos: (movimientos) => {
|
||||
const output = []
|
||||
movimientos.forEach(movimiento => {
|
||||
this.draw().movimiento({movimiento, output})
|
||||
})
|
||||
return output
|
||||
},
|
||||
movimiento: ({movimiento, output}) => {
|
||||
const valor = movimiento.abono - movimiento.cargo
|
||||
const fecha = movimiento.fecha
|
||||
|
||||
const buttons = {
|
||||
edit: {
|
||||
icon: 'edit'
|
||||
},
|
||||
remove: {
|
||||
color: ' red',
|
||||
icon: 'trash'
|
||||
}
|
||||
}
|
||||
const buttonsHTML = Object.entries(buttons).map(([action, {color='', icon}]) => {
|
||||
const className = this.props.ids.buttons[action].replace('.', '')
|
||||
return `<button class="ui${color} icon button ${className}" data-id="${movimiento.id}" data-index="${movimiento.index}" data-type="movimiento"><i class="${icon} icon"></i></button>`
|
||||
}).join('')
|
||||
|
||||
const data = {
|
||||
Sigla: movimiento.cuenta.inmobiliaria.sigla,
|
||||
Banco: movimiento.cuenta.banco.nombre,
|
||||
Cuenta: movimiento.cuenta.cuenta,
|
||||
Fecha: this.props.formatters.date.format(fecha),
|
||||
'ISO Fecha': [fecha.getFullYear(), fecha.getMonth() + 1, fecha.getDate()].join('-'),
|
||||
Mes: fecha.getMonth() + 1,
|
||||
'Año': fecha.getFullYear(),
|
||||
Valor: this.props.formatters.number.format(valor),
|
||||
'ISO Valor': valor,
|
||||
Glosa: movimiento.glosa,
|
||||
'Centro de Costo': (movimiento.detalles && movimiento.detalles.centro_costo) ? movimiento.detalles.centro_costo.id : '',
|
||||
Categoria: (movimiento.detalles) ? movimiento.detalles.categoria : '',
|
||||
Detalle: (movimiento.detalles) ? movimiento.detalles.detalle : '',
|
||||
RUT: (movimiento.detalles && movimiento.detalles.digito) ? `${this.props.formatters.number.format(movimiento.detalles.rut)}-${movimiento.detalles.digito}` : '',
|
||||
Nombre: (movimiento.detalles) ? movimiento.detalles.nombres : '',
|
||||
Identificador: (movimiento.detalles) ? movimiento.detalles.identificador : '',
|
||||
Editar: buttonsHTML,
|
||||
}
|
||||
const values = []
|
||||
this.columns.forEach(column => {
|
||||
values.push(data[column.title])
|
||||
})
|
||||
output.push(values)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,37 +0,0 @@
|
||||
<script>
|
||||
class ResultsHandler {
|
||||
props
|
||||
constructor() {
|
||||
this.props = {
|
||||
movimientos: [],
|
||||
timezone: ((new Date()).getTimezoneOffset()) / -60
|
||||
}
|
||||
}
|
||||
parse() {
|
||||
return {
|
||||
movimientos: () => {
|
||||
const movimientos = this.props.movimientos
|
||||
const data = []
|
||||
movimientos.forEach((movimiento, index) => {
|
||||
this.parse().movimiento({data, movimiento, index})
|
||||
})
|
||||
this.props.parsed = data
|
||||
},
|
||||
movimiento: ({data, movimiento, index}) => {
|
||||
const fecha = new Date(movimiento.fecha + 'Z' + this.props.timezone)
|
||||
data.push({
|
||||
tipo: 'movimiento',
|
||||
id: movimiento.id,
|
||||
index,
|
||||
cuenta: movimiento.cuenta,
|
||||
fecha,
|
||||
cargo: movimiento.cargo,
|
||||
abono: movimiento.abono,
|
||||
glosa: movimiento.glosa,
|
||||
detalles: movimiento.detalles,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,53 +0,0 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">Importar Informe de Tesorería</h1>
|
||||
|
||||
<form class="ui form" id="import_form" enctype="multipart/form-data">
|
||||
<div class="ten wide field">
|
||||
<label>Informe</label>
|
||||
<div class="ui file action input">
|
||||
<input type="file" name="file[]" id="file" accept=".xlsx" multiple placeholder="Informe" />
|
||||
<label for="file" class="ui icon button">
|
||||
<i class="file icon"></i>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui icon button">
|
||||
<i class="arrow up icon"></i>
|
||||
Subir
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
$('#import_form').submit(submitEvent => {
|
||||
submitEvent.preventDefault()
|
||||
|
||||
let formData = new FormData()
|
||||
formData.append('file', $('#file')[0].files[0])
|
||||
|
||||
const url = '{{$urls->api}}/contabilidad/tesoreria/import'
|
||||
const method = 'post'
|
||||
const body = new FormData(submitEvent.currentTarget)
|
||||
|
||||
fetchAPI(url, {method, body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(data => {
|
||||
console.log(data)
|
||||
|
||||
})
|
||||
}).catch(error => {
|
||||
console.error(error)
|
||||
})
|
||||
return false
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -10,11 +10,13 @@
|
||||
<div class="ui two column grid">
|
||||
<div class="column">
|
||||
@include('home.cuotas_por_vencer')
|
||||
@include('home.cierres_vigentes')
|
||||
</div>
|
||||
<div class="column">
|
||||
@include('home.alertas')
|
||||
</div>
|
||||
<div class="column">
|
||||
@include('home.cierres_vigentes')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -68,6 +68,21 @@
|
||||
const index = this.data.proyectos.findIndex(proyecto => proyecto.id === data.proyecto_id)
|
||||
this.data.proyectos[index].escrituras = data.escrituras
|
||||
})
|
||||
/*const index = this.data.proyectos.findIndex(proyecto => proyecto.id === proyecto_id)
|
||||
if (proyecto_id === 3) {
|
||||
this.data.proyectos[index].escrituras = {
|
||||
firmar: 20,
|
||||
pagar: 70,
|
||||
abonar: 3
|
||||
}
|
||||
}
|
||||
if (proyecto_id === 4) {
|
||||
this.data.proyectos[index].escrituras = {
|
||||
firmar: 0,
|
||||
pagar: 0,
|
||||
abonar: 2
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -117,7 +132,7 @@
|
||||
$('<div></div>').addClass('event').append(
|
||||
$('<div></div>').addClass('content').html(tipo)
|
||||
).append(
|
||||
$('<div></div>').addClass('meta').html(total + '/' + full + ' [' + formatter.format(Math.round(total / full * 10000) / 100).padStart(2, ' ') + '%]')
|
||||
$('<div></div>').addClass('meta').html(total + '/' + full + ' ' + formatter.format(Math.round(total / full * 10000) / 100).padStart(2, ' ') + '%')
|
||||
)
|
||||
)
|
||||
})
|
||||
|
@ -10,6 +10,11 @@
|
||||
<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">
|
||||
@ -17,7 +22,9 @@
|
||||
<div class="ui card">
|
||||
<div class="content">
|
||||
<div class="header">
|
||||
{{$inmobiliaria->abreviacion}}
|
||||
{{$inmobiliaria->abreviacion}}
|
||||
{{--<a href="{{$urls->base}}/inmobiliaria/{{$inmobiliaria->rut}}">
|
||||
</a>--}}
|
||||
</div>
|
||||
<div class="description">{{$inmobiliaria->razon}} {{$inmobiliaria->tipoSociedad->descripcion}}</div>
|
||||
<div class="meta">{{$inmobiliaria->rut()}}</div>
|
||||
|
@ -1,330 +0,0 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nombre</th>
|
||||
<th>Contacto</th>
|
||||
<th class="right aligned">
|
||||
<button class="ui green icon button" id="add_button">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="proveedores">
|
||||
@foreach ($sociedades as $sociedad)
|
||||
<tr>
|
||||
<td>{{$sociedad->nombre}}</td>
|
||||
<td>{{$sociedad->contacto->nombreCompleto()}}</td>
|
||||
<td class="right aligned">
|
||||
<button class="ui icon button" data-sociedad="{{$sociedad->rut}}">
|
||||
<i class="edit icon"></i>
|
||||
</button>
|
||||
<button class="ui red icon button" data-sociedad="{{$sociedad->rut}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui modal" id="add_modal">
|
||||
<div class="content">
|
||||
<form class="ui form">
|
||||
<div class="three wide field">
|
||||
<label for="rut">RUT</label>
|
||||
<div class="ui right labeled input">
|
||||
<input class="right aligned" type="text" id="rut" name="rut" placeholder="RUT" maxlength="10" required />
|
||||
<div class="ui basic label">-<span id="dv"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="five wide field">
|
||||
<label for="nombre">Nombre</label>
|
||||
<input type="text" id="nombre" name="nombre" placeholder="Nombre" required />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="razon">Razón Social</label>
|
||||
<input type="text" id="razon" name="razon" placeholder="Razón Social" required />
|
||||
</div>
|
||||
<div class="four wide field">
|
||||
<label for="tipo">Tipo</label>
|
||||
<div class="ui selection dropdown" id="tipo">
|
||||
<input type="hidden" name="tipo" required />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Tipo</div>
|
||||
<div class="menu">
|
||||
@foreach ($tiposSociedades as $tipo)
|
||||
<div class="item" data-value="{{$tipo->id}}">{{$tipo->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider">Contacto</div>
|
||||
<div class="three wide field">
|
||||
<label for="rut_contacto">RUT</label>
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" id="rut_contacto" name="rut_contacto" placeholder="RUT" maxlength="10" required />
|
||||
<div class="ui basic label">-<span id="dv_contacto"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="five wide field">
|
||||
<label for="nombre_contacto">Nombre</label>
|
||||
<input type="text" id="nombre_contacto" name="nombre_contacto" placeholder="Nombre" required />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="apellido_paterno_contacto">Apellido Paterno</label>
|
||||
<input type="text" id="apellido_paterno_contacto" name="apellido_paterno_contacto" placeholder="Apellido Paterno" required />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="apellido_materno_contacto">Apellido Materno</label>
|
||||
<input type="text" id="apellido_materno_contacto" name="apellido_materno_contacto" placeholder="Apellido Materno" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="email_contacto">Email</label>
|
||||
<input type="email" id="email_contacto" name="email_contacto" placeholder="Email" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="telefono_contacto">Teléfono</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">+56</div>
|
||||
<input type="text" id="telefono_contacto" name="telefono_contacto" placeholder="Teléfono" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="ui green approve button">Guardar</button>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
const proveedores = {
|
||||
ids: {
|
||||
modal: '',
|
||||
buttons: {
|
||||
add: '',
|
||||
edit: '',
|
||||
remove: ''
|
||||
},
|
||||
add: {
|
||||
form: '',
|
||||
rut: '',
|
||||
dv: '',
|
||||
nombre: '',
|
||||
razon: '',
|
||||
tipo: '',
|
||||
contacto: {
|
||||
rut: '',
|
||||
dv: '',
|
||||
nombre: '',
|
||||
apellido_paterno: '',
|
||||
apellido_materno: '',
|
||||
email: '',
|
||||
telefono: ''
|
||||
}
|
||||
},
|
||||
proveedores: ''
|
||||
},
|
||||
data: JSON.parse('{!! json_encode($sociedades) !!}'),
|
||||
add() {
|
||||
return {
|
||||
sociedad: () => {
|
||||
const data = {
|
||||
rut: $(this.ids.add.rut).val().replace(/\D/g, ''),
|
||||
digito: $(this.ids.add.dv).text(),
|
||||
nombre: $(this.ids.add.nombre).val(),
|
||||
razon: $(this.ids.add.razon).val(),
|
||||
tipo_sociedad_id: $(this.ids.add.tipo).dropdown('get value'),
|
||||
contacto: {
|
||||
rut: $(this.ids.add.contacto.rut).val().replace(/\D/g, ''),
|
||||
digito: $(this.ids.add.contacto.dv).text(),
|
||||
nombres: $(this.ids.add.contacto.nombre).val(),
|
||||
apellido_paterno: $(this.ids.add.contacto.apellido_paterno).val(),
|
||||
apellido_materno: $(this.ids.add.contacto.apellido_materno).val(),
|
||||
email: $(this.ids.add.contacto.email).val(),
|
||||
telefono: $(this.ids.add.contacto.telefono).val().replace(/\D/g, ''),
|
||||
}
|
||||
}
|
||||
const body = new FormData()
|
||||
body.append('sociedades[]', JSON.stringify(data))
|
||||
const url = '{{$urls->api}}/sociedades/add'
|
||||
const method = 'post'
|
||||
fetchAPI(url, {method, body})
|
||||
.then(response => (response) ? response.json() : null)
|
||||
.then(data => {
|
||||
if (data.sociedades !== null) {
|
||||
data.sociedades.forEach(sociedad => {
|
||||
const exists = this.data.find(s => s.rut === sociedad.rut)
|
||||
if (typeof exists !== 'undefined') {
|
||||
return
|
||||
}
|
||||
this.data.push(sociedad)
|
||||
})
|
||||
this.draw().sociedades()
|
||||
$(this.ids.modal).find('form.form').trigger('reset')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
edit() {},
|
||||
remove() {
|
||||
return {
|
||||
sociedad: rut => {
|
||||
const body = new FormData()
|
||||
body.append('sociedades_ruts[]', rut)
|
||||
const url = '{{$urls->api}}/sociedades/delete'
|
||||
const method = 'post'
|
||||
fetchAPI(url, {method, body})
|
||||
.then(response => (response) ? response.json() : null)
|
||||
.then(data => {
|
||||
if (data.sociedades !== null) {
|
||||
data.sociedades.forEach(sociedad => {
|
||||
if (sociedad.sociedad.rut !== rut) {
|
||||
return
|
||||
}
|
||||
if (!sociedad.deleted) {
|
||||
return
|
||||
}
|
||||
$(this.ids.proveedores).find(`button[data-sociedad="${rut}"]`).closest('tr').remove()
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
draw() {
|
||||
return {
|
||||
sociedades: () => {
|
||||
$(this.ids.proveedores).empty()
|
||||
this.data.forEach(sociedad => {
|
||||
$(this.ids.proveedores).append(`
|
||||
<tr>
|
||||
<td>${sociedad.nombre}</td>
|
||||
<td>${sociedad.contacto.nombreCompleto}</td>
|
||||
<td class="right aligned">
|
||||
<button class="ui icon button" data-sociedad="${sociedad.rut}">
|
||||
<i class="edit icon"></i>
|
||||
</button>
|
||||
<button class="ui red icon button" data-sociedad="${sociedad.rut}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
`)
|
||||
})
|
||||
$(this.ids.buttons.remove).click((e) => {
|
||||
this.remove().sociedad($(e.target).data('sociedad'))
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
formatters() {
|
||||
return {
|
||||
rut: value => {
|
||||
const rut = value.replace(/[^0-9]/g, '')
|
||||
if (rut.length <= 1) {
|
||||
return rut
|
||||
}
|
||||
return rut.replace(/\B(?=(\d{3})+(?!\d))/g, '.')
|
||||
},
|
||||
telefono: value => {
|
||||
const phone = value.replace(/[^0-9]/g, '')
|
||||
if (phone.length <= 1) {
|
||||
return phone
|
||||
}
|
||||
return phone.replace(/(\d{2})(\d{3})(\d{4})/, '$1 $2 $3')
|
||||
}
|
||||
}
|
||||
},
|
||||
digitoVerificador(value) {
|
||||
let rut = value.replace(/[^0-9kK]/g, '')
|
||||
if (rut.length < 1) {
|
||||
return ''
|
||||
}
|
||||
let suma = 0
|
||||
let mul = 2
|
||||
for (let i = rut.length-1; i >= 0; i--) {
|
||||
suma += parseInt(rut[i]) * mul
|
||||
mul = (mul + 1) % 8 || 2
|
||||
}
|
||||
const dv = 11 - suma % 11
|
||||
return dv === 10 ? 'K' : (dv === 11 ? '0' : dv.toString())
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
$(this.ids.buttons.add).click(() => {
|
||||
$(this.ids.modal).modal('show')
|
||||
})
|
||||
$(this.ids.add.rut).on('input', (e) => {
|
||||
e.target.value = this.formatters().rut(e.target.value)
|
||||
$(this.ids.add.dv).text(this.digitoVerificador(e.target.value))
|
||||
})
|
||||
if ($(this.ids.add.rut).val().length > 0) {
|
||||
$(this.ids.add.rut).val(this.formatters().rut($(this.ids.add.rut).val()))
|
||||
$(this.ids.add.dv).text(this.digitoVerificador($(this.ids.add.rut).val()))
|
||||
}
|
||||
$(this.ids.tipo).dropdown()
|
||||
$(this.ids.add.contacto.rut).on('input', (e) => {
|
||||
e.target.value = this.formatters().rut(e.target.value)
|
||||
$(this.ids.add.contacto.dv).text(this.digitoVerificador(e.target.value))
|
||||
})
|
||||
if ($(this.ids.add.contacto.rut).val().length > 0) {
|
||||
$(this.ids.add.contacto.rut).val(this.formatters().rut($(this.ids.add.contacto.rut).val()))
|
||||
$(this.ids.add.contacto.dv).text(this.digitoVerificador($(this.ids.add.contacto.rut).val()))
|
||||
}
|
||||
$(this.ids.add.contacto.telefono).on('input', (e) => {
|
||||
e.target.value = this.formatters().telefono(e.target.value)
|
||||
})
|
||||
if ($(this.ids.add.contacto.telefono).val().length > 0) {
|
||||
$(this.ids.add.contacto.telefono).val(this.formatters().telefono($(this.ids.add.contacto.telefono).val()))
|
||||
}
|
||||
$(this.ids.modal).modal({
|
||||
onApprove: () => {
|
||||
this.add().sociedad()
|
||||
}
|
||||
})
|
||||
$(this.ids.buttons.remove).click((e) => {
|
||||
this.remove().sociedad($(e.target).data('sociedad'))
|
||||
})
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
proveedores.setup({
|
||||
modal: '#add_modal',
|
||||
buttons: {
|
||||
add: '#add_button',
|
||||
edit: '.edit',
|
||||
remove: '.remove'
|
||||
},
|
||||
add: {
|
||||
form: '#add_modal form.form',
|
||||
rut: '#rut',
|
||||
dv: '#dv',
|
||||
nombre: '#nombre',
|
||||
razon: '#razon',
|
||||
tipo: '#tipo',
|
||||
contacto: {
|
||||
rut: '#rut_contacto',
|
||||
dv: '#dv_contacto',
|
||||
nombre: '#nombre_contacto',
|
||||
apellido_paterno: '#apellido_paterno_contacto',
|
||||
apellido_materno: '#apellido_materno_contacto',
|
||||
email: '#email_contacto',
|
||||
telefono: '#telefono_contacto'
|
||||
}
|
||||
},
|
||||
proveedores: '#proveedores'
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -16,14 +16,7 @@
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/centros_costos/asignar">Asignar en Cartola</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<i class="dropdown icon"></i>
|
||||
<a class="text" href="{{$urls->base}}/contabilidad/cartolas/diaria">Cartola Diaria</a>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/cartolas/importar">Importar</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>
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/movimientos">Movimientos</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -33,7 +33,6 @@
|
||||
</div>--}}
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/precios/importar">Importar Precios</a>--}}
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/cierres/evaluar">Evaluar Cierre</a>--}}
|
||||
<a class="item" href="{{$urls->base}}/ventas/facturacion">Facturación</a>
|
||||
<a class="item" href="{{$urls->base}}/ventas/add">
|
||||
Nueva Venta
|
||||
<i class="plus icon"></i>
|
||||
|
@ -2,12 +2,7 @@
|
||||
<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">
|
||||
class APIClient {
|
||||
static fetch(url, options=null, showErrors=false) {
|
||||
return fetchAPI(url, options, showErrors)
|
||||
}
|
||||
}
|
||||
function fetchAPI(url, options=null, showErrors=false) {
|
||||
function fetchAPI(url, options=null) {
|
||||
if (options === null) {
|
||||
options = {}
|
||||
}
|
||||
@ -15,7 +10,7 @@
|
||||
options['headers'] = {}
|
||||
}
|
||||
if (!Object.hasOwn(options['headers'], 'Authorization')) {
|
||||
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}{{($login->isIn()) ? $login->getSeparator() . $login->getToken() : ''}}'
|
||||
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}'
|
||||
}
|
||||
return fetch(url, options).then(response => {
|
||||
if (response.ok) {
|
||||
@ -23,33 +18,9 @@
|
||||
}
|
||||
throw new Error(JSON.stringify({code: response.status, message: response.statusText, url}))
|
||||
}).catch(error => {
|
||||
if (showErrors) {
|
||||
console.error(error)
|
||||
}
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
const datatables_defaults = {
|
||||
language: {
|
||||
emptyTable: 'No hay datos disponibles',
|
||||
info: 'Mostrando _START_ a _END_ de _TOTAL_ registros',
|
||||
infoEmpty: 'Mostrando desde 0 a 0 de 0 registros',
|
||||
infoFiltered: '(filtrado de _MAX_ registros totales)',
|
||||
lengthMenu: 'Mostrar _MENU_ registros',
|
||||
loadingRecords: 'Cargando...',
|
||||
search: 'Buscar:',
|
||||
zeroRecords: 'No se encontraron registros',
|
||||
paginate: {
|
||||
first: 'Primero',
|
||||
last: 'Último',
|
||||
next: 'Siguiente',
|
||||
previous: 'Anterior',
|
||||
},
|
||||
aria: {
|
||||
orderable: 'Ordenar por esta columna',
|
||||
orderableReverse: 'Ordenar por esta columna en orden inverso',
|
||||
}
|
||||
}
|
||||
}
|
||||
const calendar_date_options = {
|
||||
type: 'date',
|
||||
firstDayOfWeek: 1,
|
||||
@ -57,12 +28,9 @@
|
||||
monthFirst: false,
|
||||
text: {
|
||||
days: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
|
||||
dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab'],
|
||||
dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
|
||||
months: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
|
||||
monthsShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
|
||||
today: 'Hoy',
|
||||
now: 'Ahora',
|
||||
today: 'Hoy'
|
||||
},
|
||||
formatter: {
|
||||
date: 'DD-MM-YYYY'
|
||||
|
@ -1,3 +0,0 @@
|
||||
@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/2.0.3/js/dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/2.0.3/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
|
||||
|
@ -1,9 +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.1/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.semanticui.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.colVis.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.print.min.js"></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,5 +0,0 @@
|
||||
@push('page_scripts')
|
||||
<script src="https://cdn.datatables.net/datetime/1.5.2/js/dataTables.dateTime.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/searchbuilder/1.7.0/js/dataTables.searchBuilder.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/searchbuilder/1.7.0/js/searchBuilder.semanticui.js"></script>
|
||||
@endpush
|
@ -1,3 +0,0 @@
|
||||
@push('page_scripts')
|
||||
<script src="https://cdn.jsdelivr.net/npm/luxon@3.4.4/build/global/luxon.min.js" integrity="sha256-7NQm0bhvDJKosL8d+6ZgSi2LxZCIcA/TD087GLEBO9M=" crossorigin="anonymous"></script>
|
||||
@endpush
|
@ -1,26 +0,0 @@
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
class Rut {
|
||||
static digitoVerificador(rut) {
|
||||
if (rut.length === 0) {
|
||||
return ''
|
||||
}
|
||||
let M = 0, S = 1
|
||||
for (; rut; rut = Math.floor(rut / 10)) {
|
||||
S = (S + rut % 10 * (9 - M++ % 6)) % 11
|
||||
}
|
||||
return S ? S - 1 : 'K'
|
||||
}
|
||||
static format(rut) {
|
||||
if (rut.length === 0) {
|
||||
return ''
|
||||
}
|
||||
rut.replace(/\D/g, '')
|
||||
return rut.replace(/^(\d{1,2})(\d{3})(\d{3})$/, '$1.$2.$3')
|
||||
}
|
||||
static validar(rut, digito) {
|
||||
return Rut.digitoVerificador(rut) === digito
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endpush
|
@ -1,3 +1,3 @@
|
||||
@push('page_styles')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.3/css/dataTables.semanticui.min.css" />
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.1/css/dataTables.semanticui.min.css" />
|
||||
@endpush
|
||||
|
@ -1,4 +0,0 @@
|
||||
@push('page_styles')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/datetime/1.5.2/css/dataTables.dateTime.min.css" />
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/searchbuilder/1.7.0/css/searchBuilder.dataTables.min.css" />
|
||||
@endpush
|
@ -16,30 +16,29 @@
|
||||
</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 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 => {
|
||||
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 => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.login === true) {
|
||||
window.location = '{{(isset($redirect_uri)) ? $redirect_uri : $urls->base}}'
|
||||
@if(isset($redirect_uri))
|
||||
window.location = '{{$redirect_uri}}'
|
||||
@else
|
||||
window.location = '{{$urls->base}}'
|
||||
@endif
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -45,9 +45,6 @@
|
||||
draw() {
|
||||
const tipo = this.unidad.proyecto_tipo_unidad.tipo_unidad.descripcion
|
||||
let unidad = tipo.charAt(0).toUpperCase() + tipo.slice(1) + ' ' + this.unidad.descripcion
|
||||
if (typeof this.venta !== 'undefined') {
|
||||
unidad = this.venta.propiedad.tipologia
|
||||
}
|
||||
let precio = 0
|
||||
let propietario = ''
|
||||
let fecha = ''
|
||||
|
@ -789,9 +789,6 @@
|
||||
|
||||
$('#add_form').submit(event => {
|
||||
event.preventDefault()
|
||||
const button = $(event.currentTarget).find(".ui.button[type='submit']")
|
||||
button.prop('disabled', true)
|
||||
button.css('cursor', 'wait')
|
||||
const body = new FormData(event.currentTarget)
|
||||
const uri = '{{$urls->api}}/ventas/add'
|
||||
return fetchAPI(uri, {method: 'post', body}).then(response => {
|
||||
@ -803,8 +800,6 @@
|
||||
window.location = '{{$urls->base}}/venta/' + data.venta_id
|
||||
return true
|
||||
}
|
||||
button.prop('disabled', false)
|
||||
button.css('cursor', 'pointer')
|
||||
showErrors(data.errors)
|
||||
return false
|
||||
})
|
||||
|
@ -1,166 +0,0 @@
|
||||
@extends('ventas.base')
|
||||
|
||||
@section('venta_subtitle')
|
||||
Cuotas - Abono a Escritura
|
||||
@endsection
|
||||
|
||||
@section('venta_content')
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th rowspan="2">#</th>
|
||||
<th rowspan="2">Fecha</th>
|
||||
<th colspan="2">Valor</th>
|
||||
<th rowspan="2" colspan="2">Estado</th>
|
||||
<th class="right aligned" rowspan="2">
|
||||
<button class="ui tertiary green icon button" id="add_button">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="right aligned">$</th>
|
||||
<th class="right aligned">UF</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="cuotas">
|
||||
@foreach ($cuotas as $cuota)
|
||||
<tr data-id="{{$cuota->id}}">
|
||||
<td class="numero" data-value="{{$cuota->numero}}">{{$cuota->numero}}</td>
|
||||
<td class="fecha" data-value="{{$cuota->pago->fecha->format('Y-m-d')}}">{{$cuota->pago->fecha->format('d-m-Y')}}</td>
|
||||
<td class="valor right aligned" data-value="{{$cuota->pago->valor}}">{{$format->pesos($cuota->pago->valor)}}</td>
|
||||
<td class="valor_uf right aligned" data-value="{{$cuota->pago->valor()}}">{{$format->ufs($cuota->pago->valor())}}</td>
|
||||
<td class="estado{{$cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'no pagado' ? ' warning' :
|
||||
($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' ? ' positive' : '')}}" rowspan="2"
|
||||
data-value="{{$cuota->pago->currentEstado->tipoEstadoPago->id}}">
|
||||
{{ucwords($cuota->pago->currentEstado->tipoEstadoPago->descripcion)}}
|
||||
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['abonado', 'depositado']))
|
||||
<br />
|
||||
{{$cuota->pago->currentEstado->fecha->format('d-m-Y')}}
|
||||
@endif
|
||||
</td>
|
||||
<td class="collapsing">
|
||||
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['depositado', 'no pagado']))
|
||||
<form class="ui compact form avance_pago_form" data-id="{{$cuota->id}}"
|
||||
data-pago="{{$cuota->pago->id}}"
|
||||
data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->descripcion}}">
|
||||
<div class="inline field">
|
||||
<div class="ui calendar">
|
||||
<div class="ui icon input">
|
||||
<input type="text" name="fecha_avance_pago{{$cuota->id}}" />
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui tertiary green icon button accept_button" data-id="{{$cuota->id}}"><i class="check icon"></i></button>
|
||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
||||
<button class="ui tertiary red icon button cancel_button" data-id="{{$cuota->id}}"><i class="remove icon"></i></button>
|
||||
@endif
|
||||
</div>
|
||||
</form>
|
||||
@endif
|
||||
</td>
|
||||
<td class="right aligned">
|
||||
<button class="ui tertiary icon button edit_button" data-id="{{$cuota->id}}">
|
||||
<i class="edit icon"></i>
|
||||
</button>
|
||||
<button class="ui tertiary red icon button remove_button" data-id="{{$cuota->id}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@include('ventas.escrituras.abono.cuotas.add_modal')
|
||||
@include('ventas.escrituras.abono.cuotas.edit_modal')
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
const addModal = new AddModal({
|
||||
modal: '#add_cuota_modal',
|
||||
form: 'add_cuota_form',
|
||||
fecha: '#add_fecha',
|
||||
})
|
||||
const editModal = new EditModal({
|
||||
table: 'cuotas',
|
||||
modal: '#edit_cuota_modal',
|
||||
form: 'edit_cuota_form',
|
||||
fecha: '#edit_fecha',
|
||||
estado: '#edit_estado'
|
||||
})
|
||||
|
||||
document.getElementById('add_button').addEventListener('click', clickEvent => {
|
||||
addModal.draw()
|
||||
})
|
||||
Array.from(document.getElementsByClassName('edit_button')).forEach(button => {
|
||||
button.addEventListener('click', clickEvent => {
|
||||
const id = $(clickEvent.currentTarget).data('id')
|
||||
editModal.getData({cuota_id: id})
|
||||
})
|
||||
})
|
||||
Array.from(document.getElementsByClassName('remove_button')).forEach(button => {
|
||||
button.addEventListener('click', clickEvent => {
|
||||
const id = $(clickEvent.currentTarget).data('id')
|
||||
const url = `{{$urls->api}}/venta/{{$venta->id}}/cuota/${id}`
|
||||
const method = 'delete'
|
||||
console.debug(url)
|
||||
})
|
||||
})
|
||||
|
||||
Array.from(document.getElementsByClassName('avance_pago_form')).forEach(form => {
|
||||
form.addEventListener('submit', submitEvent => {
|
||||
submitEvent.preventDefault()
|
||||
return false
|
||||
})
|
||||
const cdo = structuredClone(calendar_date_options)
|
||||
cdo['initialDate'] = new Date()
|
||||
cdo['maxDate'] = new Date()
|
||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
||||
cdo['initialDate'] = new Date('{{$cuota->pago->currentEstado->fecha->format('Y-m-d')}}')
|
||||
@endif
|
||||
$(form).find('.ui.calendar').calendar(cdo)
|
||||
})
|
||||
Array.from(document.getElementsByClassName('accept_button')).forEach(button => {
|
||||
button.addEventListener('click', clickEvent => {
|
||||
const id = $(clickEvent.currentTarget).data('id')
|
||||
const method = 'post'
|
||||
const form = Array.from(document.getElementsByClassName('avance_pago_form')).filter(form => parseInt(form.dataset.id) === id)[0]
|
||||
const pago = form.dataset.pago
|
||||
const estado = form.dataset.estado
|
||||
const newEstado = estado === 'depositado' ? 'abonar' : 'depositar'
|
||||
const url = `{{$urls->api}}/ventas/pago/${pago}/${newEstado}`
|
||||
const body = new FormData()
|
||||
const fecha = $(form).find('.ui.calendar').calendar('get date')[0]
|
||||
body.set('fecha', fecha.getFullYear() + '-' + (fecha.getMonth() + 1).toString().padStart(2, '0') + '-' + fecha.getDate().toString().padStart(2, '0'))
|
||||
|
||||
APIClient.fetch(url, {method, body}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json().then(json => {
|
||||
if (json.success) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
Array.from(document.getElementsByClassName('cancel_button')).forEach(button => {
|
||||
button.addEventListener('click', clickEvent => {
|
||||
const id = $(clickEvent.currentTarget).data('id')
|
||||
const method = 'post'
|
||||
const form = Array.from(document.getElementsByClassName('avance_pago_form')).filter(form => parseInt(form.dataset.id) === id)[0]
|
||||
const pago = form.dataset.pago
|
||||
const url = `{{$urls->api}}/ventas/pago/${pago}/devolver`
|
||||
const body = new FormData()
|
||||
const fecha = $(form).find('.ui.calendar').calendar('get date')[0]
|
||||
body.set('fecha', fecha.getFullYear() + '-' + (fecha.getMonth() + 1).toString().padStart(2, '0') + '-' + fecha.getDate().toString().padStart(2, '0'))
|
||||
|
||||
console.debug(url, body)
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -1,87 +0,0 @@
|
||||
<div class="ui modal" id="add_cuota_modal">
|
||||
<div class="header">
|
||||
Agregar Cuota
|
||||
</div>
|
||||
<div class="content">
|
||||
<form class="ui form" id="add_cuota_form">
|
||||
<input type="hidden" name="venta_id" value="{{$venta->id}}" />
|
||||
<div class="two wide field">
|
||||
<label>Número</label>
|
||||
<input type="text" name="numero" />
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label>Fecha</label>
|
||||
<div class="ui calendar" id="add_fecha">
|
||||
<div class="ui icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="fecha" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label>Valor $</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="valor" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<div class="ui negative button">
|
||||
Cancelar
|
||||
</div>
|
||||
<div class="ui positive right labeled icon button">
|
||||
Agregar
|
||||
<i class="add icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
class AddModal {
|
||||
props
|
||||
|
||||
constructor(props) {
|
||||
this.setup(props)
|
||||
}
|
||||
draw() {
|
||||
$(this.props.modal).modal('show')
|
||||
}
|
||||
save() {
|
||||
const form = document.getElementById(this.props.form)
|
||||
const body = new FormData(form)
|
||||
const fecha = $(this.props.fecha).calendar('get date')
|
||||
body.set('fecha', fecha.getFullYear() + '-' + (fecha.getMonth() + 1).toString().padStart(2, '0') + '-' + fecha.getDate().toString().padStart(2, '0'))
|
||||
const url = `{{$urls->api}}/venta/{{$venta->id}}/escritura/cuotas/add`
|
||||
const method = 'post'
|
||||
APIClient.fetch(url, {method, body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.success) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
setup(ids) {
|
||||
this.props = ids
|
||||
|
||||
$(this.props.modal).modal({
|
||||
onApprove: () => {
|
||||
this.save()
|
||||
}
|
||||
})
|
||||
$(this.props.form).submit(event => {
|
||||
event.preventDefault()
|
||||
this.save()
|
||||
return false
|
||||
})
|
||||
$(this.props.fecha).calendar(calendar_date_options)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endpush
|
@ -1,130 +0,0 @@
|
||||
<div class="ui modal" id="edit_cuota_modal">
|
||||
<div class="header">
|
||||
Editar Cuota <span class="numero"></span>
|
||||
</div>
|
||||
<div class="content">
|
||||
<form class="ui form" id="edit_cuota_form">
|
||||
<input type="hidden" name="id" />
|
||||
<div class="two wide field">
|
||||
<label>Número</label>
|
||||
<input type="text" name="numero" />
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label>Fecha</label>
|
||||
<div class="ui calendar" id="edit_fecha">
|
||||
<div class="ui icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="fecha" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label>Valor $</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="valor" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label>Estado</label>
|
||||
<div class="ui selection search dropdown" id="edit_estado">
|
||||
<i class="dropdown icon"></i>
|
||||
<input type="hidden" name="tipo_estado_id" />
|
||||
<div class="default text">Estado</div>
|
||||
<div class="menu">
|
||||
@foreach($estados as $estado)
|
||||
<div class="item" data-value="{{$estado->id}}">{{$estado->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<div class="ui negative button">
|
||||
Cancelar
|
||||
</div>
|
||||
<div class="ui positive right labeled icon button">
|
||||
Editar
|
||||
<i class="edit icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
class EditModal {
|
||||
props
|
||||
data
|
||||
|
||||
constructor(props) {
|
||||
this.setup(props)
|
||||
this.data = null
|
||||
}
|
||||
getData({cuota_id}) {
|
||||
const table = document.getElementById(this.props.table)
|
||||
const row = table.querySelector(`tr[data-id='${cuota_id}']`)
|
||||
const fecha = row.querySelector('.fecha').dataset.value.split('-')
|
||||
this.data = {
|
||||
id: cuota_id,
|
||||
numero: row.querySelector('.numero').dataset.value,
|
||||
fecha: new Date(fecha[0], fecha[1] - 1, fecha[2]),
|
||||
valor: row.querySelector('.valor').dataset.value,
|
||||
estado: row.querySelector('.estado').dataset.value
|
||||
}
|
||||
|
||||
this.draw()
|
||||
}
|
||||
draw() {
|
||||
const form = document.getElementById(this.props.form)
|
||||
form.querySelector('input[name="id"]').value = this.data.id
|
||||
form.querySelector('input[name="numero"]').value = this.data.numero
|
||||
$(this.props.fecha).calendar('set date', this.data.fecha)
|
||||
form.querySelector('input[name="valor"]').value = this.data.valor
|
||||
$(this.props.estado).dropdown('set selected', this.data.estado)
|
||||
|
||||
$(this.props.modal).find('.header .numero').text(this.data.numero)
|
||||
|
||||
$(this.props.modal).modal('show')
|
||||
}
|
||||
save() {
|
||||
const form = document.getElementById(this.props.form)
|
||||
const body = new FormData(form)
|
||||
const fecha = $(this.props.fecha).calendar('get date')
|
||||
body.set('fecha', fecha.getFullYear() + '-' + (fecha.getMonth() + 1).toString().padStart(2, '0') + '-' + fecha.getDate().toString().padStart(2, '0'))
|
||||
body.set('tipo_estado_id', $(this.props.estado).dropdown('get value'))
|
||||
const url = `{{$urls->api}}/venta/{{$venta->id}}/escritura/cuota/${this.data.id}/edit`
|
||||
const method = 'post'
|
||||
APIClient.fetch(url, {method, body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.success) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
setup(ids) {
|
||||
this.props = ids
|
||||
|
||||
$(this.props.modal).modal({
|
||||
onApprove: () => {
|
||||
this.save()
|
||||
},
|
||||
onHidden: () => {
|
||||
this.data = null
|
||||
}
|
||||
})
|
||||
$(this.props.form).submit(event => {
|
||||
event.preventDefault()
|
||||
this.save()
|
||||
return false
|
||||
})
|
||||
$(this.props.fecha).calendar(calendar_date_options)
|
||||
$(this.props.estado).dropdown()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endpush
|
@ -14,7 +14,6 @@
|
||||
<p>Crédito {{$format->ufs($venta->formaPago()->credito->pago->valor())}}</p>
|
||||
@endif
|
||||
</div>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas" class="ui small green button"><i class="plus icon"></i> Agregar Cuotas</a>
|
||||
<form class="ui form" id="add_form">
|
||||
<div class="three wide field">
|
||||
<label for="fecha">Fecha</label>
|
||||
|
@ -5,24 +5,6 @@
|
||||
@endsection
|
||||
|
||||
@section('venta_content')
|
||||
@if (count($venta->formaPago()->cuotasAbono) > 0)
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas" class="ui tertiary green button">Ver Cuotas</a>
|
||||
<div class="ui compact segment">
|
||||
<div class="header">
|
||||
Cuotas
|
||||
</div>
|
||||
<div class="ui horizontal list">
|
||||
<div class="item">
|
||||
{{$format->pesos($venta->formaPago()->cuotasAbono('pesos'))}}
|
||||
</div>
|
||||
<div class="item">
|
||||
{{$format->ufs($venta->formaPago()->cuotasAbono())}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas" class="ui small green button"><i class="plus icon"></i> Agregar Cuotas</a>
|
||||
@endif
|
||||
<form class="ui form" id="edit_form">
|
||||
<div class="three wide field">
|
||||
<label for="fecha">Fecha</label>
|
||||
@ -33,26 +15,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label for="valor">Valor</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="valor" value="{{$venta->formaPago()->escritura->pago->valor}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label>Estado</label>
|
||||
<div class="ui selection dropdown" id="estado">
|
||||
<input type="hidden" name="estado" />
|
||||
<div class="default text">Estado</div>
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
@foreach($estados as $estado)
|
||||
<div class="item" data-value="{{$estado->id}}">{{ucwords($estado->descripcion)}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui button">Guardar</button>
|
||||
</form>
|
||||
@endsection
|
||||
@ -65,13 +27,12 @@
|
||||
data.set('venta', {{$venta->id}})
|
||||
const fecha = $('#fecha').calendar('get date')
|
||||
data.set('fecha', fecha.toISOString())
|
||||
data.set('estado', $('#estado').dropdown('get value'))
|
||||
return fetchAPI(url, {method: 'post', body: data}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(json => {
|
||||
if (!json.success) {
|
||||
if (!json.edited) {
|
||||
return
|
||||
}
|
||||
window.location = '{{$urls->base}}/venta/{{$venta->id}}'
|
||||
@ -80,8 +41,6 @@
|
||||
$(document).ready(() => {
|
||||
calendar_date_options.initialDate = new Date({{$venta->currentEstado()->fecha->format('Y, m-1, j')}})
|
||||
$('#fecha').calendar(calendar_date_options)
|
||||
$('#estado').dropdown()
|
||||
$('#estado').dropdown('set selected', '{{$venta->currentEstado()->id}}')
|
||||
$('#edit_form').submit(event => {
|
||||
event.preventDefault()
|
||||
editEscritura()
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user