Compare commits
179 Commits
2.2.0
...
28036fdd05
Author | SHA1 | Date | |
---|---|---|---|
28036fdd05 | |||
54f3b95b88 | |||
1e2bd617fa | |||
62e7001fba | |||
bc8aa02236 | |||
5b30c0e36c | |||
da1fb26647 | |||
b1609465a9 | |||
cb2edb1543 | |||
1e1994264e | |||
f2cc0a8c47 | |||
e474123699 | |||
c3a99d5939 | |||
0212b3e405 | |||
e4ffcb52d8 | |||
37c28c3080 | |||
d154212732 | |||
be410daa8b | |||
38202d1382 | |||
1b99358597 | |||
6107861381 | |||
3d5799ae58 | |||
d649e03684 | |||
fc3d25dd18 | |||
532e0ec601 | |||
3e9f9a3fef | |||
d1b255aa8b | |||
93a0832800 | |||
4894809105 | |||
389e60980e | |||
fe6a01b2fb | |||
2b6a8b35a5 | |||
30a4d66be5 | |||
089579f39f | |||
63ea21f105 | |||
33409a18e3 | |||
2592794a49 | |||
196c5b947f | |||
b9c2972fe9 | |||
37015f7e95 | |||
c3b36dcdf7 | |||
c68b773cbb | |||
933e652dac | |||
ff1e9ebb53 | |||
599880ae27 | |||
a4da8d8624 | |||
87dfb0ae6e | |||
afbac7259a | |||
e2573f35d1 | |||
b8d4b260b6 | |||
ff06e70869 | |||
5e7326a4b6 | |||
26a227c8ae | |||
5defd2b564 | |||
74b15add36 | |||
d8d2cba308 | |||
5983a4b20f | |||
6e4dd8180e | |||
7447579ef0 | |||
ccd5b296f3 | |||
095c33e8aa | |||
4604a9af48 | |||
55d879274c | |||
85b529c22d | |||
3ba45c48f5 | |||
552a4c7aca | |||
2070987403 | |||
d9dab9c88d | |||
f9f133d3a9 | |||
f85af642d2 | |||
f3d9b58ffb | |||
8f682f7f13 | |||
26e626074a | |||
478b407646 | |||
7d210601da | |||
9563876b36 | |||
d9e27d5af7 | |||
936830ae64 | |||
e93149456a | |||
93a15ef1e4 | |||
6950413eec | |||
9162ed240e | |||
84861b5e57 | |||
43bb7a83c8 | |||
081187e3d3 | |||
b2f1bd5ba0 | |||
a471a1083e | |||
8e7f43e487 | |||
390e79ad6d | |||
6169089475 | |||
a7ce78a3fb | |||
6f023928e8 | |||
a4b7183de1 | |||
a428aeebe1 | |||
fc543729d2 | |||
8cec046d66 | |||
1f730fb7f3 | |||
964d8d4237 | |||
0d5c9efd68 | |||
d68eba5697 | |||
d5b9be0196 | |||
d0d99eaa81 | |||
15e9a54c7e | |||
b7e9a17586 | |||
61533b5a4c | |||
5864e7ee94 | |||
3fc7aa88dc | |||
1caa62500a | |||
27e88761e0 | |||
b27a6fab33 | |||
fa978728ce | |||
256a3d2459 | |||
f8f5796a66 | |||
0e0b783a80 | |||
a5125aff74 | |||
71bbe7f2d7 | |||
e2c68a14d1 | |||
5e51562aec | |||
7719a5c614 | |||
05b9a3ad8a | |||
665bed8553 | |||
9c024d1ef7 | |||
94d618b2a1 | |||
4786ee2552 | |||
39d8d4943e | |||
e63a3d0077 | |||
d580cc1a11 | |||
86034a6349 | |||
97ab5acf3e | |||
435180ebaf | |||
d2511901ec | |||
9388dc17fc | |||
a33dd341cd | |||
8e4b5eaaf8 | |||
91679b164f | |||
3c7e4b9ef4 | |||
20045c9a64 | |||
47d43f504d | |||
0502b8e735 | |||
905e8263bc | |||
8710c8a111 | |||
5d9ac2bc51 | |||
062e0543e4 | |||
b97916cfc4 | |||
7af9cafdb6 | |||
84a2fbd119 | |||
bc9c71870c | |||
912e8624b2 | |||
86406bf027 | |||
7b8d44e8c8 | |||
c10f2e5912 | |||
bef0a22758 | |||
092eb95f06 | |||
5f56022109 | |||
4b3397dd63 | |||
529f9e32a1 | |||
939adf126f | |||
63400af1db | |||
019974614c | |||
735c341729 | |||
444ff687fc | |||
f3a5fa2cdc | |||
2ed265dcf1 | |||
dbae630fdd | |||
d69976d015 | |||
2ccbc31ae0 | |||
e50d80560c | |||
7cc0333876 | |||
eb38236926 | |||
85ef4dd60e | |||
f1e29e3b0b | |||
6617a92f5f | |||
ca958b8a88 | |||
dc2e2c7f71 | |||
936fd2d1e1 | |||
7c6a397e31 | |||
7385225a2e | |||
9c335fd350 | |||
57f9169cc7 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,3 +10,5 @@
|
|||||||
**/.idea/
|
**/.idea/
|
||||||
**/upload?/
|
**/upload?/
|
||||||
**/informe?/
|
**/informe?/
|
||||||
|
**/.phpunit.cache/
|
||||||
|
**/coverage/
|
||||||
|
18
Dockerfile
18
Dockerfile
@ -1,14 +1,18 @@
|
|||||||
FROM php:8.1-fpm
|
FROM php:8.2-fpm
|
||||||
|
|
||||||
|
ENV TZ=America/Santiago
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends libzip-dev libicu-dev git libpng-dev unzip tzdata \
|
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/*
|
&& rm -r /var/lib/apt/lists/* \
|
||||||
|
&& docker-php-ext-install pdo pdo_mysql zip intl gd bcmath \
|
||||||
RUN docker-php-ext-install pdo pdo_mysql zip intl gd bcmath
|
&& pecl install xdebug-3.3.2 \
|
||||||
|
&& docker-php-ext-enable xdebug \
|
||||||
RUN pecl install xdebug-3.1.3 \
|
&& echo $TZ > /etc/timezone
|
||||||
&& docker-php-ext-enable xdebug
|
|
||||||
|
|
||||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
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
|
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
9
api.compose.yml
Normal file
9
api.compose.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
services:
|
||||||
|
httpclient:
|
||||||
|
profiles:
|
||||||
|
- testing
|
||||||
|
container_name: incoviba_client
|
||||||
|
image: flawiddsouza/restfox
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "${HTTPCLIENT_PORT:-4004}:4004"
|
1
app/.gitignore
vendored
Normal file
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
**/bin
|
14
app/.phpunit-watcher.yml
Normal file
14
app/.phpunit-watcher.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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,6 +5,11 @@ use Psr\Http\Message\UploadedFileInterface;
|
|||||||
|
|
||||||
interface Banco
|
interface Banco
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Process bank movements for database inserts
|
||||||
|
* @param UploadedFileInterface $file
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function process(UploadedFileInterface $file): array;
|
public function process(UploadedFileInterface $file): array;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,5 @@ use Incoviba\Model;
|
|||||||
|
|
||||||
interface Exporter
|
interface Exporter
|
||||||
{
|
{
|
||||||
public function export(Model\Inmobiliaria $inmobiliaria, Model\Banco $banco, DateTimeInterface $mes, array $movimientos): string;
|
public function export(Model\Inmobiliaria $inmobiliaria, Model\Contabilidad\Banco $banco, DateTimeInterface $mes, array $movimientos): string;
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,55 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
|||||||
{
|
{
|
||||||
public function process(UploadedFileInterface $file): array
|
public function process(UploadedFileInterface $file): array
|
||||||
{
|
{
|
||||||
$data = $this->parseFile($file);
|
$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
|
||||||
|
{
|
||||||
$temp = [];
|
$temp = [];
|
||||||
$columns = $this->columnMap();
|
$columns = $this->columnMap();
|
||||||
|
|
||||||
foreach ($data as $row) {
|
foreach ($data as $row) {
|
||||||
$r = [];
|
$r = [];
|
||||||
foreach ($columns as $old => $new) {
|
foreach ($columns as $old => $new) {
|
||||||
@ -24,11 +70,24 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
|||||||
}
|
}
|
||||||
return $temp;
|
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;
|
abstract protected function columnMap(): array;
|
||||||
abstract protected function parseFile(UploadedFileInterface $uploadedFile): array;
|
|
||||||
|
/**
|
||||||
|
* Translate uploaded file data to database data
|
||||||
|
* @param string $filename
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
abstract protected function parseFile(string $filename): array;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,9 @@ abstract class Repository implements Define\Repository
|
|||||||
$this->connection->execute($query, [$model->id]);
|
$this->connection->execute($query, [$model->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws EmptyResult
|
||||||
|
*/
|
||||||
public function fetchById(int $id): Define\Model
|
public function fetchById(int $id): Define\Model
|
||||||
{
|
{
|
||||||
$query = $this->connection->getQueryBuilder()
|
$query = $this->connection->getQueryBuilder()
|
||||||
@ -45,6 +48,10 @@ abstract class Repository implements Define\Repository
|
|||||||
->where("{$this->getKey()} = ?");
|
->where("{$this->getKey()} = ?");
|
||||||
return $this->fetchOne($query, [$id]);
|
return $this->fetchOne($query, [$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws EmptyResult
|
||||||
|
*/
|
||||||
public function fetchAll(null|string|array $ordering = null): array
|
public function fetchAll(null|string|array $ordering = null): array
|
||||||
{
|
{
|
||||||
$query = $this->connection->getQueryBuilder()
|
$query = $this->connection->getQueryBuilder()
|
||||||
@ -161,4 +168,9 @@ abstract class Repository implements Define\Repository
|
|||||||
}
|
}
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function filterData(array $data): array
|
||||||
|
{
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ use Throwable;
|
|||||||
|
|
||||||
class EmptyResult extends Exception
|
class EmptyResult extends Exception
|
||||||
{
|
{
|
||||||
public function __construct(string $query, ?Throwable $previous = null)
|
public function __construct(public string $query, ?Throwable $previous = null)
|
||||||
{
|
{
|
||||||
$message = "Empty results for {$query}";
|
$message = "Empty results for {$query}";
|
||||||
$code = 700;
|
$code = 700;
|
||||||
|
19
app/common/Implement/Exception/HttpResponse.php
Normal file
19
app/common/Implement/Exception/HttpResponse.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
}
|
60
app/common/Implement/Log/MySQLHandler.php
Normal file
60
app/common/Implement/Log/MySQLHandler.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Common\Implement\Log;
|
||||||
|
|
||||||
|
use PDOStatement;
|
||||||
|
use Monolog\Handler\AbstractProcessingHandler;
|
||||||
|
use Monolog\LogRecord;
|
||||||
|
use Monolog\Level;
|
||||||
|
use Incoviba\Common\Define\Connection;
|
||||||
|
|
||||||
|
class MySQLHandler extends AbstractProcessingHandler
|
||||||
|
{
|
||||||
|
private bool $initialized = false;
|
||||||
|
private PDOStatement $statement;
|
||||||
|
|
||||||
|
public function __construct(protected Connection $connection, 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);
|
||||||
|
}
|
||||||
|
}
|
19
app/common/Implement/Log/PDOFormatter.php
Normal file
19
app/common/Implement/Log/PDOFormatter.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Common\Implement\Log;
|
||||||
|
|
||||||
|
use Monolog\Formatter\JsonFormatter;
|
||||||
|
use Monolog\LogRecord;
|
||||||
|
|
||||||
|
class PDOFormatter extends JsonFormatter
|
||||||
|
{
|
||||||
|
public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = true)
|
||||||
|
{
|
||||||
|
parent::__construct($batchMode, $appendNewline, $ignoreEmptyContextAndExtra, $includeStacktraces);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function format(LogRecord $record): string
|
||||||
|
{
|
||||||
|
$normalized = $this->normalize($record);
|
||||||
|
return $normalized['message'];
|
||||||
|
}
|
||||||
|
}
|
18
app/common/Implement/Log/UserProcessor.php
Normal file
18
app/common/Implement/Log/UserProcessor.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?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,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Incoviba\Common\Implement\Repository;
|
namespace Incoviba\Common\Implement\Repository;
|
||||||
|
|
||||||
|
use Error;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Incoviba\Common\Define;
|
use Incoviba\Common\Define;
|
||||||
|
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||||
|
|
||||||
class Mapper implements Define\Repository\Mapper
|
class Mapper implements Define\Repository\Mapper
|
||||||
{
|
{
|
||||||
@ -46,7 +48,11 @@ class Mapper implements Define\Repository\Mapper
|
|||||||
}
|
}
|
||||||
public function hasDefault(): bool
|
public function hasDefault(): bool
|
||||||
{
|
{
|
||||||
return isset($this->default);
|
try {
|
||||||
|
return isset($this->default) or $this->default === null;
|
||||||
|
} catch (Error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parse(Define\Model &$model, string $column, ?array $data): bool
|
public function parse(Define\Model &$model, string $column, ?array $data): bool
|
||||||
@ -62,8 +68,16 @@ class Mapper implements Define\Repository\Mapper
|
|||||||
}
|
}
|
||||||
$value = $data[$column];
|
$value = $data[$column];
|
||||||
if ($this->hasFunction()) {
|
if ($this->hasFunction()) {
|
||||||
if ($value !== null) {
|
if ($value !== null and $value !== '') {
|
||||||
$value = ($this->function)($data);
|
try {
|
||||||
|
$value = ($this->function)($data);
|
||||||
|
} catch (EmptyResult $exception) {
|
||||||
|
if ($this->hasDefault()) {
|
||||||
|
$value = $this->default;
|
||||||
|
} else {
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
} elseif ($this->hasDefault()) {
|
} elseif ($this->hasDefault()) {
|
||||||
$value = $this->default;
|
$value = $this->default;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "incoviba/web",
|
"name": "incoviba/web",
|
||||||
|
"version": "2.0.0",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
|
"ext-gd": "*",
|
||||||
|
"ext-openssl": "*",
|
||||||
|
"ext-pdo": "*",
|
||||||
"berrnd/slim-blade-view": "^1.0",
|
"berrnd/slim-blade-view": "^1.0",
|
||||||
"guzzlehttp/guzzle": "^7.8",
|
"guzzlehttp/guzzle": "^7.8",
|
||||||
"monolog/monolog": "^3.4",
|
"monolog/monolog": "^3.4",
|
||||||
@ -9,13 +13,17 @@
|
|||||||
"nyholm/psr7-server": "^1.0",
|
"nyholm/psr7-server": "^1.0",
|
||||||
"php-di/php-di": "^7.0",
|
"php-di/php-di": "^7.0",
|
||||||
"php-di/slim-bridge": "^3.4",
|
"php-di/slim-bridge": "^3.4",
|
||||||
"phpoffice/phpspreadsheet": "^1.29",
|
"phpoffice/phpspreadsheet": "^3.0",
|
||||||
"predis/predis": "^2.2",
|
"predis/predis": "^2.2",
|
||||||
|
"robmorgan/phinx": "^0.16.5",
|
||||||
"slim/slim": "^4.11"
|
"slim/slim": "^4.11"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"fakerphp/faker": "^1.23",
|
||||||
"kint-php/kint": "^5.1",
|
"kint-php/kint": "^5.1",
|
||||||
"phpunit/phpunit": "^10.2"
|
"odan/phinx-migrations-generator": "^6.2",
|
||||||
|
"phpunit/phpunit": "^11",
|
||||||
|
"spatie/phpunit-watcher": "^1.23"
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@ -30,6 +38,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"sort-packages": true
|
"sort-packages": true,
|
||||||
|
"process-timeout": 0,
|
||||||
|
"bin-dir": "bin"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
46
app/phinx.php
Normal file
46
app/phinx.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?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
|
||||||
|
];
|
43
app/phpunit.xml
Normal file
43
app/phpunit.xml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/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>
|
BIN
app/public/favicon.ico
Normal file
BIN
app/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 894 B |
File diff suppressed because it is too large
Load Diff
19644
app/resources/database/schema.php
Normal file
19644
app/resources/database/schema.php
Normal file
File diff suppressed because it is too large
Load Diff
677
app/resources/database/schema.sql
Normal file
677
app/resources/database/schema.sql
Normal file
@ -0,0 +1,677 @@
|
|||||||
|
-- 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,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use Incoviba\Controller\API\Base;
|
||||||
|
|
||||||
$app->group('/api', function($app) {
|
$app->group('/api', function($app) {
|
||||||
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'api']);
|
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'api']);
|
||||||
if (file_exists($folder)) {
|
if (file_exists($folder)) {
|
||||||
@ -10,4 +12,5 @@ $app->group('/api', function($app) {
|
|||||||
include_once $file->getRealPath();
|
include_once $file->getRealPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$app->get('[/]', Base::class);
|
||||||
})->add($app->getContainer()->get(Incoviba\Middleware\API::class));
|
})->add($app->getContainer()->get(Incoviba\Middleware\API::class));
|
||||||
|
@ -2,5 +2,15 @@
|
|||||||
use Incoviba\Controller\Inmobiliarias;
|
use Incoviba\Controller\Inmobiliarias;
|
||||||
|
|
||||||
$app->group('/inmobiliarias', function($app) {
|
$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->get('[/]', Inmobiliarias::class);
|
||||||
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||||
|
@ -28,6 +28,9 @@ $app->group('/venta/{venta_id:[0-9]+}', function($app) {
|
|||||||
});
|
});
|
||||||
$app->get('[/]', [Ventas::class, 'pie']);
|
$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('/escritura', function($app) {
|
||||||
$app->get('/add[/]', [Ventas\Escrituras::class, 'add']);
|
$app->get('/add[/]', [Ventas\Escrituras::class, 'add']);
|
||||||
});
|
});
|
||||||
|
10
app/resources/routes/96_admin.php
Normal file
10
app/resources/routes/96_admin.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
});
|
6
app/resources/routes/admin/users.php
Normal file
6
app/resources/routes/admin/users.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\Admin\Users;
|
||||||
|
|
||||||
|
$app->group('/users', function($app) {
|
||||||
|
$app->get('[/]', Users::class);
|
||||||
|
});
|
13
app/resources/routes/api/admin.php
Normal file
13
app/resources/routes/api/admin.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
6
app/resources/routes/api/admin/users.php
Normal file
6
app/resources/routes/api/admin/users.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\API\Admin\Users;
|
||||||
|
|
||||||
|
$app->group('/users', function($app) {
|
||||||
|
$app->post('/add[/]', Users::class . ':add');
|
||||||
|
});
|
@ -3,6 +3,8 @@ use Incoviba\Controller\API\Contabilidad\Cartolas;
|
|||||||
|
|
||||||
$app->group('/cartolas', function($app) {
|
$app->group('/cartolas', function($app) {
|
||||||
$app->post('/procesar[/]', [Cartolas::class, 'procesar']);
|
$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('/cartola', function($app) {
|
||||||
$app->group('/diaria', function($app) {
|
$app->group('/diaria', function($app) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Incoviba\Controller\API\CentrosCostos;
|
|
||||||
|
use Incoviba\Controller\API\Contabilidad\CentrosCostos;
|
||||||
|
|
||||||
$app->group('/centros_costos', function($app) {
|
$app->group('/centros_costos', function($app) {
|
||||||
$app->post('/add[/]', [CentrosCostos::class, 'add']);
|
$app->post('/add[/]', [CentrosCostos::class, 'add']);
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
use Incoviba\Controller\API\Contabilidad\Movimientos;
|
use Incoviba\Controller\API\Contabilidad\Movimientos;
|
||||||
|
|
||||||
$app->group('/movimiento/{movimiento_id}', function($app) {
|
$app->group('/movimientos', function($app) {
|
||||||
$app->post('/detalles', [Movimientos::class, 'detalles']);
|
$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']);
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
use Incoviba\Controller\API\Nubox;
|
use Incoviba\Controller\API\Contabilidad\Nubox;
|
||||||
|
|
||||||
$app->group('/nubox/{inmobiliaria_rut}', function($app) {
|
$app->group('/nubox/{inmobiliaria_rut}', function($app) {
|
||||||
$app->get('/token[/]', [Nubox::class, 'token']);
|
$app->get('/token[/]', [Nubox::class, 'token']);
|
||||||
$app->get('/sistemas[/]', [Nubox::class, 'sistemas']);
|
$app->get('/sistemas[/]', [Nubox::class, 'sistemas']);
|
||||||
|
$app->get('/cuentas[/]', [Nubox::class, 'cuentas']);
|
||||||
$app->group('/libro', function($app) {
|
$app->group('/libro', function($app) {
|
||||||
$app->post('/mayor[/]', [Nubox::class, 'libroMayor']);
|
$app->post('/mayor[/]', [Nubox::class, 'libroMayor']);
|
||||||
$app->post('/diario[/]', [Nubox::class, 'libroDiario']);
|
$app->post('/diario[/]', [Nubox::class, 'libroDiario']);
|
||||||
});
|
});
|
||||||
|
$app->get('/facturas/{dia}[/]', [Nubox::class, 'facturas']);
|
||||||
|
$app->post('/cuenta', [Nubox::class, 'cuenta']);
|
||||||
});
|
});
|
||||||
|
6
app/resources/routes/api/contabilidad/tesoreria.php
Normal file
6
app/resources/routes/api/contabilidad/tesoreria.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\API\Contabilidad\Tesoreria;
|
||||||
|
|
||||||
|
$app->group('/tesoreria', function($app) {
|
||||||
|
$app->post('/import[/]', [Tesoreria::class, 'import']);
|
||||||
|
});
|
@ -2,9 +2,20 @@
|
|||||||
use Incoviba\Controller\API\Inmobiliarias;
|
use Incoviba\Controller\API\Inmobiliarias;
|
||||||
|
|
||||||
$app->group('/inmobiliarias', function($app) {
|
$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->get('[/]', Inmobiliarias::class);
|
||||||
});
|
});
|
||||||
$app->group('/inmobiliaria/{inmobiliaria_rut}', function($app) {
|
$app->group('/inmobiliaria/{inmobiliaria_rut}', function($app) {
|
||||||
|
$app->post('/proveedores', [Inmobiliarias::class, 'proveedores']);
|
||||||
$app->get('/cuentas[/]', [Inmobiliarias::class, 'cuentas']);
|
$app->get('/cuentas[/]', [Inmobiliarias::class, 'cuentas']);
|
||||||
$app->get('/proyectos[/]', [Inmobiliarias::class, 'proyectos']);
|
$app->get('/proyectos[/]', [Inmobiliarias::class, 'proyectos']);
|
||||||
});
|
});
|
||||||
|
11
app/resources/routes/api/inmobiliarias/proveedores.php
Normal file
11
app/resources/routes/api/inmobiliarias/proveedores.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\API\Inmobiliarias\Agentes;
|
||||||
|
|
||||||
|
$app->group('/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']);
|
||||||
|
});
|
7
app/resources/routes/api/inmobiliarias/sociedades.php
Normal file
7
app/resources/routes/api/inmobiliarias/sociedades.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\API\Inmobiliarias\Sociedades;
|
||||||
|
|
||||||
|
$app->group('/sociedades', function($app) {
|
||||||
|
$app->post('/add[/]', [Sociedades::class, 'add']);
|
||||||
|
$app->get('[/]', Sociedades::class);
|
||||||
|
});
|
4
app/resources/routes/api/login.php
Normal file
4
app/resources/routes/api/login.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\API\Login;
|
||||||
|
|
||||||
|
$app->post('/login[/]', Login::class);
|
@ -4,5 +4,10 @@ use Incoviba\Controller\API\Money;
|
|||||||
$app->group('/money', function($app) {
|
$app->group('/money', function($app) {
|
||||||
$app->post('/ipc[/]', [Money::class, 'ipc']);
|
$app->post('/ipc[/]', [Money::class, 'ipc']);
|
||||||
$app->post('/uf[/]', [Money::class, 'uf']);
|
$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']);
|
$app->post('[/]', [Money::class, 'get']);
|
||||||
});
|
});
|
||||||
|
17
app/resources/routes/api/sociedades.php
Normal file
17
app/resources/routes/api/sociedades.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?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');
|
||||||
|
});
|
6
app/resources/routes/api/tokens.php
Normal file
6
app/resources/routes/api/tokens.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\API\Tokens;
|
||||||
|
|
||||||
|
$app->group('/tokens', function($app) {
|
||||||
|
$app->get('/try[/]', Tokens::class . ':try');
|
||||||
|
});
|
@ -27,7 +27,13 @@ $app->group('/ventas', function($app) {
|
|||||||
});
|
});
|
||||||
$app->group('/venta/{venta_id}', function($app) {
|
$app->group('/venta/{venta_id}', function($app) {
|
||||||
$app->get('/unidades[/]', [Ventas::class, 'unidades']);
|
$app->get('/unidades[/]', [Ventas::class, 'unidades']);
|
||||||
$app->get('/comentarios[/]', [Ventas::class, 'comentarios']);
|
$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->group('/escritura', function($app) {
|
$app->group('/escritura', function($app) {
|
||||||
$app->post('/add[/]', [Ventas\Escrituras::class, 'add']);
|
$app->post('/add[/]', [Ventas\Escrituras::class, 'add']);
|
||||||
});
|
});
|
||||||
@ -39,6 +45,9 @@ $app->group('/venta/{venta_id}', function($app) {
|
|||||||
$app->get('/eliminar[/]', [Ventas::class, 'insistir']);
|
$app->get('/eliminar[/]', [Ventas::class, 'insistir']);
|
||||||
$app->post('[/]', [Ventas::class, 'desistir']);
|
$app->post('[/]', [Ventas::class, 'desistir']);
|
||||||
});
|
});
|
||||||
|
$app->group('/propietario', function($app) {
|
||||||
|
$app->put('/edit[/]', [Ventas::class, 'propietario']);
|
||||||
|
});
|
||||||
$app->post('[/]', [Ventas::class, 'edit']);
|
$app->post('[/]', [Ventas::class, 'edit']);
|
||||||
$app->get('[/]', [Ventas::class, 'get']);
|
$app->get('[/]', [Ventas::class, 'get']);
|
||||||
});
|
});
|
||||||
|
8
app/resources/routes/api/ventas/comentarios.php
Normal file
8
app/resources/routes/api/ventas/comentarios.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?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,4 +3,5 @@ use Incoviba\Controller\API\Ventas\Facturacion;
|
|||||||
|
|
||||||
$app->group('/facturacion', function($app) {
|
$app->group('/facturacion', function($app) {
|
||||||
$app->get('/proyecto/{proyecto_id}[/]', [Facturacion::class, 'proyecto']);
|
$app->get('/proyecto/{proyecto_id}[/]', [Facturacion::class, 'proyecto']);
|
||||||
|
$app->post('/get[/]', [Facturacion::class, 'ventas']);
|
||||||
});
|
});
|
||||||
|
6
app/resources/routes/api/ventas/facturas.php
Normal file
6
app/resources/routes/api/ventas/facturas.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\API\Ventas\Facturas;
|
||||||
|
|
||||||
|
$app->group('/facturas', function($app) {
|
||||||
|
$app->post('/add[/]', [Facturas::class, 'add']);
|
||||||
|
});
|
@ -11,5 +11,6 @@ $app->group('/pago/{pago_id:[0-9]+}', function($app) {
|
|||||||
$app->post('/abonar[/]', [Pagos::class, 'abonar']);
|
$app->post('/abonar[/]', [Pagos::class, 'abonar']);
|
||||||
$app->post('/devolver[/]', [Pagos::class, 'devolver']);
|
$app->post('/devolver[/]', [Pagos::class, 'devolver']);
|
||||||
$app->get('/anular[/]', [Pagos::class, 'anular']);
|
$app->get('/anular[/]', [Pagos::class, 'anular']);
|
||||||
|
$app->post('/estado[/]', [Pagos::class, 'estado']);
|
||||||
$app->post('[/]', [Pagos::class, 'edit']);
|
$app->post('[/]', [Pagos::class, 'edit']);
|
||||||
});
|
});
|
||||||
|
@ -3,4 +3,5 @@ use Incoviba\Controller\Contabilidad;
|
|||||||
|
|
||||||
$app->group('/cartolas', function($app) {
|
$app->group('/cartolas', function($app) {
|
||||||
$app->get('/diaria[/]', [Contabilidad::class, 'diaria']);
|
$app->get('/diaria[/]', [Contabilidad::class, 'diaria']);
|
||||||
|
$app->get('/importar[/]', [Contabilidad::class, 'importar']);
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Incoviba\Controller\CentrosCostos;
|
|
||||||
|
use Incoviba\Controller\Contabilidad\CentrosCostos;
|
||||||
|
|
||||||
$app->group('/centros_costos', function($app) {
|
$app->group('/centros_costos', function($app) {
|
||||||
$app->get('/asignar[/]', [CentrosCostos::class, 'asignar']);
|
$app->get('/asignar[/]', [CentrosCostos::class, 'asignar']);
|
||||||
|
4
app/resources/routes/contabilidad/cuadratura.php
Normal file
4
app/resources/routes/contabilidad/cuadratura.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\Contabilidad;
|
||||||
|
|
||||||
|
$app->get('/cuadratura[/]', [Contabilidad::class, 'cuadratura']);
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
use Incoviba\Controller\Contabilidad;
|
use Incoviba\Controller\Contabilidad;
|
||||||
|
use Incoviba\Controller\Contabilidad\Tesoreria;
|
||||||
|
|
||||||
$app->group('/tesoreria', function($app) {
|
$app->group('/tesoreria', function($app) {
|
||||||
|
$app->get('/import[/]', [Tesoreria::class, 'import']);
|
||||||
$app->get('[/[{fecha}[/]]]', [Contabilidad::class, 'tesoreria']);
|
$app->get('[/[{fecha}[/]]]', [Contabilidad::class, 'tesoreria']);
|
||||||
});
|
});
|
||||||
|
4
app/resources/routes/contabilidad/movimientos.php
Normal file
4
app/resources/routes/contabilidad/movimientos.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\Contabilidad\Movimientos;
|
||||||
|
|
||||||
|
$app->get('/movimientos', Movimientos::class);
|
6
app/resources/routes/inmobiliarias/proveedores.php
Normal file
6
app/resources/routes/inmobiliarias/proveedores.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\Inmobiliarias\Proveedores;
|
||||||
|
|
||||||
|
$app->group('/proveedores', function($app) {
|
||||||
|
$app->get('[/]', Proveedores::class);
|
||||||
|
});
|
@ -10,4 +10,11 @@ $app->group('/pie/{pie_id}', function($app) {
|
|||||||
});
|
});
|
||||||
$app->get('[/]', [Pies::class, 'cuotas']);
|
$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();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
6
app/resources/routes/ventas/pies/bonos.php
Normal file
6
app/resources/routes/ventas/pies/bonos.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
use Incoviba\Controller\Ventas\Bonos;
|
||||||
|
|
||||||
|
$app->group('/bono_pie', function($app) {
|
||||||
|
$app->get('/add[/]', [Bonos::class, 'add']);
|
||||||
|
});
|
100
app/resources/views/admin/users.blade.php
Normal file
100
app/resources/views/admin/users.blade.php
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
@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,5 +10,23 @@
|
|||||||
<i class="hammer icon"></i>
|
<i class="hammer icon"></i>
|
||||||
Esta parte del sitio está en construcción.
|
Esta parte del sitio está en construcción.
|
||||||
</div>
|
</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>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -52,8 +52,7 @@
|
|||||||
<th class="right aligned">Cargo</th>
|
<th class="right aligned">Cargo</th>
|
||||||
<th class="right aligned">Abono</th>
|
<th class="right aligned">Abono</th>
|
||||||
<th class="right aligned">Saldo</th>
|
<th class="right aligned">Saldo</th>
|
||||||
<th>Centro de Costo</th>
|
<th class="right aligned"></th>
|
||||||
<th>Detalle</th>
|
|
||||||
<th>Orden</th>
|
<th>Orden</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -115,10 +114,85 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</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
|
@endsection
|
||||||
|
|
||||||
@include('layout.head.styles.datatables')
|
@include('layout.head.styles.datatables')
|
||||||
@include('layout.body.scripts.datatables')
|
@include('layout.body.scripts.datatables')
|
||||||
|
@include('layout.body.scripts.rut')
|
||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script>
|
<script>
|
||||||
@ -126,7 +200,8 @@
|
|||||||
idx
|
idx
|
||||||
inmobiliaria = {
|
inmobiliaria = {
|
||||||
rut: 0,
|
rut: 0,
|
||||||
razon: ''
|
razon: '',
|
||||||
|
sigla: ''
|
||||||
}
|
}
|
||||||
cuenta = {
|
cuenta = {
|
||||||
id: 0,
|
id: 0,
|
||||||
@ -187,46 +262,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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() {
|
draw() {
|
||||||
return {
|
return {
|
||||||
form: ($form, inmobiliarias, first = false) => {
|
form: ($form, inmobiliarias, first = false) => {
|
||||||
@ -326,6 +361,10 @@
|
|||||||
onChange: (value, text, $choice) => {
|
onChange: (value, text, $choice) => {
|
||||||
this.inmobiliaria.rut = value
|
this.inmobiliaria.rut = value
|
||||||
this.inmobiliaria.razon = text
|
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(() => {
|
this.get().bancos(value).then(() => {
|
||||||
$cuentas_dropdown.dropdown('change values', this.bancos)
|
$cuentas_dropdown.dropdown('change values', this.bancos)
|
||||||
})
|
})
|
||||||
@ -380,74 +419,42 @@
|
|||||||
cartola: ($tbody, dateFormatter, numberFormatter) => {
|
cartola: ($tbody, dateFormatter, numberFormatter) => {
|
||||||
this.movimientos.forEach((row, idx) => {
|
this.movimientos.forEach((row, idx) => {
|
||||||
$tbody.append(
|
$tbody.append(
|
||||||
$('<tr></tr>').append(
|
[
|
||||||
'<td>' + this.inmobiliaria.razon + '</td>' + "\n"
|
'<tr>',
|
||||||
+ '<td>' + this.cuenta.descripcion + '</td>' + "\n"
|
`<td>${this.inmobiliaria.sigla ?? this.inmobiliaria.razon}</td>`,
|
||||||
+ '<td>' + dateFormatter.format(row.fecha) + '</td>' + "\n"
|
`<td>${this.cuenta.descripcion}</td>`,
|
||||||
+ '<td>' + row.glosa + '</td>' + "\n"
|
`<td>${dateFormatter.format(row.fecha)}</td>`,
|
||||||
+ '<td class="right aligned">' + (row.cargo === 0 ? '' : numberFormatter.format(row.cargo)) + '</td>' + "\n"
|
`<td>${row.glosa}</td>`,
|
||||||
+ '<td class="right aligned">' + (row.abono === 0 ? '' : numberFormatter.format(row.abono)) + '</td>' + "\n"
|
`<td class="right aligned">${row.cargo === 0 ? '' : numberFormatter.format(row.cargo)}</td>`,
|
||||||
+ '<td class="right aligned">' + (row.saldo === 0 ? '' : numberFormatter.format(row.saldo)) + '</td>' + "\n"
|
`<td class="right aligned">${row.abono === 0 ? '' : numberFormatter.format(row.abono)}</td>`,
|
||||||
).append(
|
`<td class="right aligned">${row.saldo === 0 ? '' : numberFormatter.format(row.saldo)}</td>`,
|
||||||
$('<td></td>').append(
|
'<td class="center aligned">',
|
||||||
this.draw().centroCosto(idx)
|
`<button class="ui icon button edit_movimiento" data-movimiento="${idx}">`,
|
||||||
)
|
'<i class="edit icon"></i>',
|
||||||
).append(
|
'</button>',
|
||||||
$('<td></td>').append(
|
'</td>',
|
||||||
this.draw().detalle(idx)
|
`<td>${(idx + 1).toString()}</td>`,
|
||||||
)
|
].join("\n")
|
||||||
).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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -460,8 +467,7 @@
|
|||||||
'cargo',
|
'cargo',
|
||||||
'abono',
|
'abono',
|
||||||
'saldo',
|
'saldo',
|
||||||
'centro',
|
'edit',
|
||||||
'detalle',
|
|
||||||
'orden'
|
'orden'
|
||||||
];
|
];
|
||||||
@endphp
|
@endphp
|
||||||
@ -471,17 +477,18 @@
|
|||||||
inmobiliarias: JSON.parse('{!! json_encode($inmobiliarias) !!}'),
|
inmobiliarias: JSON.parse('{!! json_encode($inmobiliarias) !!}'),
|
||||||
cartolasIdx: [],
|
cartolasIdx: [],
|
||||||
cartolas: [],
|
cartolas: [],
|
||||||
|
movimientos: [],
|
||||||
},
|
},
|
||||||
dataTableConfig: {
|
dataTableConfig: {
|
||||||
order: [[{{array_search('orden', $columns)}}, 'asc']],
|
order: [[{{array_search('orden', $columns)}}, 'asc']],
|
||||||
columnDefs: [
|
columnDefs: [
|
||||||
{
|
{
|
||||||
targets: [{{implode(',', array_keys(array_filter($columns, function($column) {return in_array($column, ['fecha', 'cargo', 'abono', 'saldo']);})))}}],
|
targets: [{{implode(',', array_keys(array_filter($columns, function($column) {return in_array($column, ['fecha', 'cargo', 'abono', 'saldo', 'edit']);})))}}],
|
||||||
width: '{{round((1/(count($columns) + 3 - 1)) * 100,2)}}%'
|
width: '{{round((1/(count($columns) + 2)) * 100, 2)}}%'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
targets: [{{implode(',', array_keys(array_filter($columns, function($column) {return in_array($column, ['sociedad', 'cuenta', 'glosa', 'centro', 'detalle']);})))}}],
|
targets: [{{implode(',', array_keys(array_filter($columns, function($column) {return in_array($column, ['sociedad', 'cuenta', 'glosa']);})))}}],
|
||||||
width: '{{round((1/(count($columns) + 3 - 1)) * 2 * 100, 2)}}%'
|
width: '{{round((1/(count($columns) + 2)) * 2 * 100, 2)}}%'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
targets: [{{array_search('orden', $columns)}}],
|
targets: [{{array_search('orden', $columns)}}],
|
||||||
@ -605,8 +612,12 @@
|
|||||||
cargo: row.cargo,
|
cargo: row.cargo,
|
||||||
abono: row.abono,
|
abono: row.abono,
|
||||||
saldo: row.saldo,
|
saldo: row.saldo,
|
||||||
centro: row.detalles?.centro_costo.descripcion ?? '',
|
centro: row.detalles?.centro_costo?.id ?? '',
|
||||||
detalle: row.detalles?.detalle ?? ''
|
detalle: row.detalles?.detalle ?? '',
|
||||||
|
categoria: row.detalles?.categoria ?? '',
|
||||||
|
rut: row.detalles?.rut ?? '',
|
||||||
|
nombres: row.detalles?.nombres ?? '',
|
||||||
|
identificador: row.detalles?.identificador ?? ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const ayer = new Date(this.data.cartolas[cartolaIdx].fecha.getTime())
|
const ayer = new Date(this.data.cartolas[cartolaIdx].fecha.getTime())
|
||||||
@ -638,6 +649,51 @@
|
|||||||
$(this.ids.table.base).DataTable(this.dataTableConfig)
|
$(this.ids.table.base).DataTable(this.dataTableConfig)
|
||||||
|
|
||||||
this.cartolas().add()
|
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 = {
|
const manual = {
|
||||||
@ -807,7 +863,8 @@
|
|||||||
add: '#add_button',
|
add: '#add_button',
|
||||||
process: '#process_button'
|
process: '#process_button'
|
||||||
},
|
},
|
||||||
loader: '#loader'
|
loader: '#loader',
|
||||||
|
editModal: '#edit_modal'
|
||||||
})
|
})
|
||||||
manual.setup({
|
manual.setup({
|
||||||
modal: '#manual_modal',
|
modal: '#manual_modal',
|
||||||
|
345
app/resources/views/contabilidad/cartolas/import.blade.php
Normal file
345
app/resources/views/contabilidad/cartolas/import.blade.php
Normal file
@ -0,0 +1,345 @@
|
|||||||
|
@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,9 +14,10 @@
|
|||||||
<i class="dropdown icon"></i>
|
<i class="dropdown icon"></i>
|
||||||
<div class="default text">Inmobiliaria</div>
|
<div class="default text">Inmobiliaria</div>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
@foreach ($inmobiliarias as $inmobiliaria)
|
@foreach ($inmobiliarias as $inmobiliaria)
|
||||||
<div class="item" data-value="{{$inmobiliaria->rut}}">{{$inmobiliaria->razon}}</div>
|
<div class="item"
|
||||||
@endforeach
|
data-value="{{$inmobiliaria->rut}}">{{$inmobiliaria->razon}}</div>
|
||||||
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -40,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label for="file">Cartola</label>
|
<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">
|
<label for="file" class="ui icon button">
|
||||||
<i class="file icon"></i>
|
<i class="file icon"></i>
|
||||||
Cargar
|
Cargar
|
||||||
@ -119,20 +120,20 @@
|
|||||||
mes: '',
|
mes: '',
|
||||||
movimientos: [],
|
movimientos: [],
|
||||||
centrosCostos: {
|
centrosCostos: {
|
||||||
ingresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\CentroCosto $centroCosto) {
|
ingresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||||
return [
|
return [
|
||||||
'id' => $centroCosto->id,
|
'id' => $centroCosto->id,
|
||||||
'descripcion' => $centroCosto->descripcion
|
'descripcion' => $centroCosto->descripcion
|
||||||
];
|
];
|
||||||
}, array_filter($centrosCostos, function(\Incoviba\Model\CentroCosto $centroCosto) {
|
}, array_filter($centrosCostos, function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||||
return $centroCosto->tipoCentro->descripcion === 'Ingreso';
|
return $centroCosto->tipoCentro->descripcion === 'Ingreso';
|
||||||
})))) !!}'),
|
})))) !!}'),
|
||||||
egresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\CentroCosto $centroCosto) {
|
egresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||||
return [
|
return [
|
||||||
'id' => $centroCosto->id,
|
'id' => $centroCosto->id,
|
||||||
'descripcion' => $centroCosto->descripcion
|
'descripcion' => $centroCosto->descripcion
|
||||||
];
|
];
|
||||||
}, array_filter($centrosCostos, function(\Incoviba\Model\CentroCosto $centroCosto) {
|
}, array_filter($centrosCostos, function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||||
return $centroCosto->tipoCentro->descripcion === 'Egreso';
|
return $centroCosto->tipoCentro->descripcion === 'Egreso';
|
||||||
})))) !!}'),
|
})))) !!}'),
|
||||||
}
|
}
|
||||||
@ -170,7 +171,11 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
$(this.ids.form.banco).dropdown('change values', json.cuentas.map(cuenta => {
|
$(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')
|
})).dropdown('refresh')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -247,12 +252,12 @@
|
|||||||
const movimientos = this.data.movimientos.map((movimiento, idx) => {
|
const movimientos = this.data.movimientos.map((movimiento, idx) => {
|
||||||
const temp = structuredClone(movimiento)
|
const temp = structuredClone(movimiento)
|
||||||
temp.fecha = movimiento.fecha.toISOString()
|
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) {
|
if (centro.length === 0) {
|
||||||
centro = ''
|
centro = ''
|
||||||
}
|
}
|
||||||
temp.centro_costo = centro
|
temp.centro_costo = centro
|
||||||
let detalle = $("[name='detalle" + (idx+1) + "']").val()
|
let detalle = $("[name='detalle" + (idx + 1) + "']").val()
|
||||||
if (typeof detalle === 'undefined') {
|
if (typeof detalle === 'undefined') {
|
||||||
detalle = ''
|
detalle = ''
|
||||||
}
|
}
|
||||||
@ -294,7 +299,10 @@
|
|||||||
month: 'numeric',
|
month: 'numeric',
|
||||||
day: '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) => {
|
this.data.movimientos.forEach((row, idx) => {
|
||||||
tbody.append(
|
tbody.append(
|
||||||
$('<tr></tr>').append(
|
$('<tr></tr>').append(
|
||||||
@ -322,7 +330,7 @@
|
|||||||
})
|
})
|
||||||
table.DataTable(this.dataTableConfig)
|
table.DataTable(this.dataTableConfig)
|
||||||
},
|
},
|
||||||
centrosDropdown: (idx, ingreso=true) => {
|
centrosDropdown: (idx, ingreso = true) => {
|
||||||
const menu = $('<div></div>').addClass('menu')
|
const menu = $('<div></div>').addClass('menu')
|
||||||
let centros = this.data.centrosCostos.ingresos
|
let centros = this.data.centrosCostos.ingresos
|
||||||
if (!ingreso) {
|
if (!ingreso) {
|
||||||
|
225
app/resources/views/contabilidad/cuadratura.blade.php
Normal file
225
app/resources/views/contabilidad/cuadratura.blade.php
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
@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,14 +1,23 @@
|
|||||||
@extends('layout.base')
|
@extends('layout.base')
|
||||||
|
|
||||||
|
@push('page_styles')
|
||||||
|
<style>
|
||||||
|
tr.bold > th {
|
||||||
|
font-weight: bold !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@endpush
|
||||||
|
|
||||||
@section('page_content')
|
@section('page_content')
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<h1 class="ui centered header">Informe de Tesorería</h1>
|
<h1 class="ui centered header">Informe de Tesorería</h1>
|
||||||
<h4 class="ui centered sub header">{{$fecha->format('d M Y')}}</h4>
|
<h4 class="ui centered sub header">{{$fecha->format('d M Y')}}</h4>
|
||||||
<div class="ui grid">
|
<div class="ui grid">
|
||||||
<div class="three wide column">
|
<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">
|
<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>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -19,7 +28,11 @@
|
|||||||
<table class="ui collapsing simple table">
|
<table class="ui collapsing simple table">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Informe anterior</td>
|
<td>Informe anterior</td>
|
||||||
<td>{{$anterior->format('d/m/Y')}}</td>
|
<td>
|
||||||
|
<a href="{{$urls->base}}/contabilidad/informes/tesoreria/{{$anterior->format('Y-m-d')}}">
|
||||||
|
{{$anterior->format('d/m/Y')}}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Informe actual</td>
|
<td>Informe actual</td>
|
||||||
@ -40,6 +53,17 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
<table class="ui striped table">
|
<table class="ui striped table">
|
||||||
<thead>
|
<thead>
|
||||||
@ -60,27 +84,31 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach ($informes['inmobiliarias'] as $inmobiliaria_rut => $informe)
|
@foreach ($informes['sociedades'] as $sociedad_rut => $informe)
|
||||||
@foreach ($informe->cuentas as $i => $cuenta)
|
@foreach ($informe->cuentas as $i => $cuenta)
|
||||||
<tr>
|
<tr>
|
||||||
@if ($i === 0)
|
@if ($i === 0)
|
||||||
<td rowspan="{{count($informe->cuentas)}}">{{$informe->inmobiliaria->razon}}</td>
|
<td rowspan="{{count($informe->cuentas)}}">{{$informe->sociedad->razon}}</td>
|
||||||
@endif
|
@endif
|
||||||
<td>{{$cuenta->banco}}</td>
|
<td>{{$cuenta->banco}}</td>
|
||||||
<td>{{$cuenta->numero}}</td>
|
<td>{{$cuenta->numero}}</td>
|
||||||
<td class="right aligned">{{$format->pesos($cuenta->anterior)}}</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->actual)}}</td>
|
||||||
<td class="right aligned">{{$format->pesos($cuenta->diferencia())}}</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->ffmm)}}</td>
|
||||||
<td class="right aligned">{{$format->pesos($cuenta->deposito)}}</td>
|
<td class="right aligned">{{$format->pesos($cuenta->deposito)}}</td>
|
||||||
<td class="right aligned">{{$format->pesos($cuenta->saldo())}}</td>
|
<td class="right aligned">{{$format->pesos($cuenta->saldo())}}</td>
|
||||||
@if ($i === 0)
|
@if ($i === 0)
|
||||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->total())}}</td>
|
<td class="right aligned"
|
||||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->ffmm())}}</td>
|
rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->total())}}</td>
|
||||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->deposito())}}</td>
|
<td class="right aligned"
|
||||||
<td class="right aligned" rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->caja())}}</td>
|
rowspan="{{count($informe->cuentas)}}">{{$format->pesos($informe->ffmm())}}</td>
|
||||||
@endif
|
<td class="right aligned"
|
||||||
</tr>
|
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
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -123,7 +151,7 @@
|
|||||||
@foreach ($movimientos as $ms)
|
@foreach ($movimientos as $ms)
|
||||||
@foreach ($ms as $movimiento)
|
@foreach ($ms as $movimiento)
|
||||||
<tr>
|
<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->abono)}}</td>
|
||||||
<td class="right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
<td class="right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
||||||
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
||||||
@ -142,7 +170,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
@foreach ($movimientos as $movimiento)
|
@foreach ($movimientos as $movimiento)
|
||||||
<tr>
|
<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->abono)}}</td>
|
||||||
<td class="red right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
<td class="red right aligned">{{$format->pesos($movimiento->cargo)}}</td>
|
||||||
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
<td>{{$movimiento->fecha->format('d/m/Y')}}</td>
|
||||||
|
136
app/resources/views/contabilidad/movimientos.blade.php
Normal file
136
app/resources/views/contabilidad/movimientos.blade.php
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
@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
|
@ -0,0 +1,67 @@
|
|||||||
|
<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>
|
@ -0,0 +1,22 @@
|
|||||||
|
<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>
|
@ -0,0 +1,98 @@
|
|||||||
|
<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>
|
@ -0,0 +1,74 @@
|
|||||||
|
<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>
|
@ -0,0 +1,54 @@
|
|||||||
|
<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>
|
@ -0,0 +1,16 @@
|
|||||||
|
<script>
|
||||||
|
class LoadingHandler {
|
||||||
|
props
|
||||||
|
constructor(ids) {
|
||||||
|
this.props = {
|
||||||
|
...ids
|
||||||
|
}
|
||||||
|
}
|
||||||
|
show() {
|
||||||
|
$(this.props.id).addClass('loading')
|
||||||
|
}
|
||||||
|
hide() {
|
||||||
|
$(this.props.id).removeClass('loading')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,86 @@
|
|||||||
|
<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>
|
@ -0,0 +1,234 @@
|
|||||||
|
<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>
|
@ -0,0 +1,37 @@
|
|||||||
|
<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>
|
53
app/resources/views/contabilidad/tesoreria/import.blade.php
Normal file
53
app/resources/views/contabilidad/tesoreria/import.blade.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
@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,13 +10,11 @@
|
|||||||
<div class="ui two column grid">
|
<div class="ui two column grid">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
@include('home.cuotas_por_vencer')
|
@include('home.cuotas_por_vencer')
|
||||||
|
@include('home.cierres_vigentes')
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
@include('home.alertas')
|
@include('home.alertas')
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
|
||||||
@include('home.cierres_vigentes')
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -68,21 +68,6 @@
|
|||||||
const index = this.data.proyectos.findIndex(proyecto => proyecto.id === data.proyecto_id)
|
const index = this.data.proyectos.findIndex(proyecto => proyecto.id === data.proyecto_id)
|
||||||
this.data.proyectos[index].escrituras = data.escrituras
|
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
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -132,7 +117,7 @@
|
|||||||
$('<div></div>').addClass('event').append(
|
$('<div></div>').addClass('event').append(
|
||||||
$('<div></div>').addClass('content').html(tipo)
|
$('<div></div>').addClass('content').html(tipo)
|
||||||
).append(
|
).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,11 +10,6 @@
|
|||||||
<div class="column">
|
<div class="column">
|
||||||
Inmobiliarias
|
Inmobiliarias
|
||||||
</div>
|
</div>
|
||||||
{{--<div class="right aligned column">
|
|
||||||
<button class="ui icon button" type="button">
|
|
||||||
<i class="plus icon"></i>
|
|
||||||
</button>
|
|
||||||
</div>--}}
|
|
||||||
</h2>
|
</h2>
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
<div class="ui cards">
|
<div class="ui cards">
|
||||||
@ -22,9 +17,7 @@
|
|||||||
<div class="ui card">
|
<div class="ui card">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
{{$inmobiliaria->abreviacion}}
|
{{$inmobiliaria->abreviacion}}
|
||||||
{{--<a href="{{$urls->base}}/inmobiliaria/{{$inmobiliaria->rut}}">
|
|
||||||
</a>--}}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="description">{{$inmobiliaria->razon}} {{$inmobiliaria->tipoSociedad->descripcion}}</div>
|
<div class="description">{{$inmobiliaria->razon}} {{$inmobiliaria->tipoSociedad->descripcion}}</div>
|
||||||
<div class="meta">{{$inmobiliaria->rut()}}</div>
|
<div class="meta">{{$inmobiliaria->rut()}}</div>
|
||||||
|
330
app/resources/views/inmobiliarias/proveedores.blade.php
Normal file
330
app/resources/views/inmobiliarias/proveedores.blade.php
Normal file
@ -0,0 +1,330 @@
|
|||||||
|
@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,7 +16,14 @@
|
|||||||
<a class="item" href="{{$urls->base}}/contabilidad/centros_costos/asignar">Asignar en Cartola</a>
|
<a class="item" href="{{$urls->base}}/contabilidad/centros_costos/asignar">Asignar en Cartola</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a class="item" href="{{$urls->base}}/contabilidad/cartolas/diaria">Cartola Diaria</a>
|
<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/depositos">Depósitos a Plazo</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>
|
||||||
</div>
|
</div>
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
</div>--}}
|
</div>--}}
|
||||||
{{--<a class="item" href="{{$urls->base}}/ventas/precios/importar">Importar Precios</a>--}}
|
{{--<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/cierres/evaluar">Evaluar Cierre</a>--}}
|
||||||
|
<a class="item" href="{{$urls->base}}/ventas/facturacion">Facturación</a>
|
||||||
<a class="item" href="{{$urls->base}}/ventas/add">
|
<a class="item" href="{{$urls->base}}/ventas/add">
|
||||||
Nueva Venta
|
Nueva Venta
|
||||||
<i class="plus icon"></i>
|
<i class="plus icon"></i>
|
||||||
|
@ -2,7 +2,12 @@
|
|||||||
<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 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">
|
<script type="text/javascript">
|
||||||
function fetchAPI(url, options=null) {
|
class APIClient {
|
||||||
|
static fetch(url, options=null, showErrors=false) {
|
||||||
|
return fetchAPI(url, options, showErrors)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function fetchAPI(url, options=null, showErrors=false) {
|
||||||
if (options === null) {
|
if (options === null) {
|
||||||
options = {}
|
options = {}
|
||||||
}
|
}
|
||||||
@ -10,7 +15,7 @@
|
|||||||
options['headers'] = {}
|
options['headers'] = {}
|
||||||
}
|
}
|
||||||
if (!Object.hasOwn(options['headers'], 'Authorization')) {
|
if (!Object.hasOwn(options['headers'], 'Authorization')) {
|
||||||
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}'
|
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}{{($login->isIn()) ? $login->getSeparator() . $login->getToken() : ''}}'
|
||||||
}
|
}
|
||||||
return fetch(url, options).then(response => {
|
return fetch(url, options).then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
@ -18,9 +23,33 @@
|
|||||||
}
|
}
|
||||||
throw new Error(JSON.stringify({code: response.status, message: response.statusText, url}))
|
throw new Error(JSON.stringify({code: response.status, message: response.statusText, url}))
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error(error)
|
if (showErrors) {
|
||||||
|
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 = {
|
const calendar_date_options = {
|
||||||
type: 'date',
|
type: 'date',
|
||||||
firstDayOfWeek: 1,
|
firstDayOfWeek: 1,
|
||||||
@ -28,9 +57,12 @@
|
|||||||
monthFirst: false,
|
monthFirst: false,
|
||||||
text: {
|
text: {
|
||||||
days: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
|
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'],
|
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'],
|
monthsShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
|
||||||
today: 'Hoy'
|
today: 'Hoy',
|
||||||
|
now: 'Ahora',
|
||||||
},
|
},
|
||||||
formatter: {
|
formatter: {
|
||||||
date: 'DD-MM-YYYY'
|
date: 'DD-MM-YYYY'
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
@push('page_scripts')
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js" integrity="sha512-a+SUDuwNzXDvz4XrIcXHuCf089/iJAoN4lmrXJg18XnduKK6YlDHNRalv4yd1N40OKI80tFidF+rqTFKGPoWFQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
@endpush
|
@ -1,5 +1,4 @@
|
|||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
{{--<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.3/js/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.3/js/dataTables.semanticui.min.js"></script>
|
||||||
<script src="https://cdn.datatables.net/2.0.1/js/dataTables.semanticui.min.js"></script>
|
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
@push('page_scripts')
|
@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/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://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.9/pdfmake.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/dataTables.buttons.min.js"></script>
|
<script src="https://cdn.datatables.net/buttons/3.0.1/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.1/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.1/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.1/js/buttons.html5.min.js"></script>
|
||||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.print.min.js"></script>
|
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.print.min.js"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
@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
|
3
app/resources/views/layout/body/scripts/luxon.blade.php
Normal file
3
app/resources/views/layout/body/scripts/luxon.blade.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@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
|
26
app/resources/views/layout/body/scripts/rut.blade.php
Normal file
26
app/resources/views/layout/body/scripts/rut.blade.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
@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')
|
@push('page_styles')
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.1/css/dataTables.semanticui.min.css" />
|
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.3/css/dataTables.semanticui.min.css" />
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
@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,29 +16,30 @@
|
|||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@include('layout.body.scripts.cryptojs')
|
||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script type="text/javascript">
|
<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) {
|
function sendLogin(name, password) {
|
||||||
const data = new FormData()
|
const method = 'post'
|
||||||
data.append('name', name)
|
const headers = {
|
||||||
data.append('password', password)
|
Accept: 'json'
|
||||||
return fetch('{{$urls->base}}/login', {
|
}
|
||||||
method: 'post',
|
const body = new FormData()
|
||||||
headers: {
|
body.append('name', name)
|
||||||
Accept: 'json'
|
body.append('password', encryptPassword(password))
|
||||||
},
|
return fetch('{{$urls->base}}/login', {method, headers, body}).then(response => {
|
||||||
body: data
|
|
||||||
}).then(response => {
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return response.json()
|
return response.json()
|
||||||
}
|
}
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
if (data.login === true) {
|
if (data.login === true) {
|
||||||
@if(isset($redirect_uri))
|
window.location = '{{(isset($redirect_uri)) ? $redirect_uri : $urls->base}}'
|
||||||
window.location = '{{$redirect_uri}}'
|
|
||||||
@else
|
|
||||||
window.location = '{{$urls->base}}'
|
|
||||||
@endif
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
draw() {
|
draw() {
|
||||||
const tipo = this.unidad.proyecto_tipo_unidad.tipo_unidad.descripcion
|
const tipo = this.unidad.proyecto_tipo_unidad.tipo_unidad.descripcion
|
||||||
let unidad = tipo.charAt(0).toUpperCase() + tipo.slice(1) + ' ' + this.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 precio = 0
|
||||||
let propietario = ''
|
let propietario = ''
|
||||||
let fecha = ''
|
let fecha = ''
|
||||||
|
@ -789,6 +789,9 @@
|
|||||||
|
|
||||||
$('#add_form').submit(event => {
|
$('#add_form').submit(event => {
|
||||||
event.preventDefault()
|
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 body = new FormData(event.currentTarget)
|
||||||
const uri = '{{$urls->api}}/ventas/add'
|
const uri = '{{$urls->api}}/ventas/add'
|
||||||
return fetchAPI(uri, {method: 'post', body}).then(response => {
|
return fetchAPI(uri, {method: 'post', body}).then(response => {
|
||||||
@ -800,6 +803,8 @@
|
|||||||
window.location = '{{$urls->base}}/venta/' + data.venta_id
|
window.location = '{{$urls->base}}/venta/' + data.venta_id
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
button.prop('disabled', false)
|
||||||
|
button.css('cursor', 'pointer')
|
||||||
showErrors(data.errors)
|
showErrors(data.errors)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
@extends('layout.base')
|
@extends('layout.base')
|
||||||
|
|
||||||
|
@push('page_styles')
|
||||||
|
<style>
|
||||||
|
#data {
|
||||||
|
margin-left: 1rem;
|
||||||
|
margin-right: 1rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@endpush
|
||||||
|
|
||||||
@section('page_content')
|
@section('page_content')
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<h2 class="ui header">Matriz Facturación</h2>
|
<h2 class="ui header">Matriz Facturación</h2>
|
||||||
@ -24,7 +33,7 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table class="ui table" id="data"></table>
|
<div id="data"></div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@include('layout.head.styles.datatables')
|
@include('layout.head.styles.datatables')
|
||||||
@ -33,53 +42,150 @@
|
|||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script>
|
<script>
|
||||||
const money = {
|
const money = {
|
||||||
|
data: {
|
||||||
|
ufs: {},
|
||||||
|
ipcs: {}
|
||||||
|
},
|
||||||
ufs: {},
|
ufs: {},
|
||||||
ipcs: {},
|
ipcs: {},
|
||||||
sent: {
|
sent: {
|
||||||
uf: {},
|
uf: {},
|
||||||
ipc: {}
|
ipc: {}
|
||||||
},
|
},
|
||||||
|
queue: {
|
||||||
|
size: 0,
|
||||||
|
array: () => {
|
||||||
|
const array = []
|
||||||
|
Object.entries(money.queue).forEach(([type, dates]) => {
|
||||||
|
if (['uf', 'ipc'].includes(type) === false) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (type === 'uf') {
|
||||||
|
Object.entries(dates).forEach(([dateString, ventas]) => {
|
||||||
|
const temp = []
|
||||||
|
ventas.forEach(venta => {
|
||||||
|
temp.push(venta)
|
||||||
|
})
|
||||||
|
array.push({
|
||||||
|
type,
|
||||||
|
date: dateString,
|
||||||
|
ventas: temp
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Object.entries(dates).forEach(([dateString, data]) => {
|
||||||
|
const temp = []
|
||||||
|
data.ventas.forEach(venta => {
|
||||||
|
temp.push(venta)
|
||||||
|
})
|
||||||
|
array.push({
|
||||||
|
type,
|
||||||
|
start: data.start,
|
||||||
|
end: data.end,
|
||||||
|
ventas: temp
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return array
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enqueue() {
|
||||||
|
return {
|
||||||
|
uf: ({date, venta_id}) => {
|
||||||
|
const type = 'uf'
|
||||||
|
const data = {
|
||||||
|
date: [date.getFullYear(), date.getMonth()+1, date.getDate()].join('-'),
|
||||||
|
}
|
||||||
|
if (!(type in this.queue)) {
|
||||||
|
this.queue[type] = {}
|
||||||
|
}
|
||||||
|
if (!(data.date in this.queue[type])) {
|
||||||
|
this.queue[type][data.date] = []
|
||||||
|
}
|
||||||
|
if (this.queue[type][data.date].includes(data)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.queue[type][data.date].push(venta_id)
|
||||||
|
this.queue['size'] ++
|
||||||
|
},
|
||||||
|
ipc: ({start, end, venta_id}) => {
|
||||||
|
const type = 'ipc'
|
||||||
|
let mult = 1
|
||||||
|
if (start > end) {
|
||||||
|
mult = -1
|
||||||
|
let temp = end
|
||||||
|
end = start
|
||||||
|
start = temp
|
||||||
|
}
|
||||||
|
const data = {
|
||||||
|
start: [start.getFullYear(), start.getMonth()+1, start.getDate()].join('-'),
|
||||||
|
end: [end.getFullYear(), end.getMonth()+1, end.getDate()].join('-'),
|
||||||
|
}
|
||||||
|
if (!(type in this.queue)) {
|
||||||
|
this.queue[type] = {}
|
||||||
|
}
|
||||||
|
if (!([data.start, data.end].join('|') in this.queue[type])) {
|
||||||
|
this.queue[type][[data.start, data.end].join('|')] = {
|
||||||
|
start: data.start,
|
||||||
|
end: data.end,
|
||||||
|
ventas: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.queue[type][[data.start, data.end].join('|')].ventas.includes(data)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.queue[type][[data.start, data.end].join('|')].ventas.push({venta_id, mult})
|
||||||
|
this.queue['size'] ++
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
get() {
|
get() {
|
||||||
return {
|
return {
|
||||||
uf: date => {
|
many: () => {
|
||||||
if (typeof this.sent.uf[date.toISOString()] !== 'undefined') {
|
const url = '{{$urls->api}}/money/many'
|
||||||
return this.sent.uf[date.toISOString()]
|
const method = 'post'
|
||||||
}
|
const chunkSize = 100
|
||||||
const url = '{{$urls->api}}/money/uf'
|
const promises = []
|
||||||
const data = new FormData()
|
for (let i = 0; i < this.queue.size; i += chunkSize) {
|
||||||
data.set('fecha', date.toISOString())
|
const chunk = this.queue.array().slice(i, i + chunkSize)
|
||||||
const options = {
|
const missing = chunk.filter(data => {
|
||||||
method: 'post',
|
if (data.type === 'uf') {
|
||||||
body: data
|
return !(data.date in this.data.ufs)
|
||||||
}
|
}
|
||||||
return this.sent.uf[date.toISOString()] = fetchAPI(url, options).then(response => {
|
if (data.type === 'ipc') {
|
||||||
if (response.ok) {
|
const dateKey = [data.start, data.end].join('|')
|
||||||
return response.json()
|
return !(dateKey in this.data.ipcs)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (missing.length === 0) {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
}).then(json => {
|
const body = new FormData()
|
||||||
return this.ufs[json.input.fecha] = json.uf
|
body.set('dates', JSON.stringify(missing))
|
||||||
})
|
const options = {
|
||||||
},
|
method,
|
||||||
ipc: (end, start) => {
|
body
|
||||||
const dateKey = [start.getFullYear(), (start.getMonth()+1), end.getFullYear(), (end.getMonth()+1)].join('-')
|
|
||||||
if (typeof this.sent.ipc[dateKey] !== 'undefined') {
|
|
||||||
return this.sent.ipc[dateKey]
|
|
||||||
}
|
|
||||||
const url = '{{$urls->api}}/money/ipc'
|
|
||||||
const data = new FormData()
|
|
||||||
data.set('start', start.toISOString())
|
|
||||||
data.set('end', end.toISOString())
|
|
||||||
const options = {
|
|
||||||
method: 'post',
|
|
||||||
body: data
|
|
||||||
}
|
|
||||||
return this.sent.ipc[dateKey] = fetchAPI(url, options).then(response => {
|
|
||||||
if (response.ok) {
|
|
||||||
return response.json()
|
|
||||||
}
|
}
|
||||||
}).then(json => {
|
promises.push(fetchAPI(url, options).then(response => {
|
||||||
return this.ipcs[json.date_string] = json.ipc
|
if (!response) {
|
||||||
})
|
return
|
||||||
|
}
|
||||||
|
return response.json().then(json => {
|
||||||
|
json.values.forEach(data => {
|
||||||
|
if (data.type === 'uf') {
|
||||||
|
this.data.ufs[data.date] = data.value
|
||||||
|
}
|
||||||
|
if (data.type === 'ipc') {
|
||||||
|
const dateKey = [data.start, data.end].join('|')
|
||||||
|
this.data.ipcs[dateKey] = data.value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return json.values
|
||||||
|
})
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
return Promise.all(promises)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,8 +198,7 @@
|
|||||||
prorrateo
|
prorrateo
|
||||||
precio
|
precio
|
||||||
|
|
||||||
constructor({id, tipo, descripcion, prorrateo, precio})
|
constructor({id, tipo, descripcion, prorrateo, precio}) {
|
||||||
{
|
|
||||||
this.id = id
|
this.id = id
|
||||||
this.tipo = tipo
|
this.tipo = tipo
|
||||||
this.descripcion = descripcion
|
this.descripcion = descripcion
|
||||||
@ -111,44 +216,13 @@
|
|||||||
unidades
|
unidades
|
||||||
principal
|
principal
|
||||||
|
|
||||||
constructor({id, precio, fecha, escritura}) {
|
constructor({id, precio, fecha, escritura, unidades, principal}) {
|
||||||
this.id = id
|
this.id = id
|
||||||
this.precio = precio
|
this.precio = precio
|
||||||
this.fecha = fecha
|
this.fecha = new Date(fecha)
|
||||||
this.escritura = escritura
|
this.escritura = new Date(escritura)
|
||||||
this.uf = 1
|
this.unidades = unidades
|
||||||
this.ipc = 1
|
this.principal = principal
|
||||||
this.unidades = []
|
|
||||||
}
|
|
||||||
|
|
||||||
get() {
|
|
||||||
return {
|
|
||||||
unidades: () => {
|
|
||||||
const url = '{{$urls->api}}/venta/' + this.id + '/unidades'
|
|
||||||
return fetchAPI(url).then(response => {
|
|
||||||
if (response.ok) {
|
|
||||||
return response.json()
|
|
||||||
}
|
|
||||||
}).then(json => {
|
|
||||||
json.unidades.forEach(unidad => {
|
|
||||||
const tipo = unidad.proyecto_tipo_unidad.tipo_unidad.descripcion
|
|
||||||
const data = {
|
|
||||||
id: unidad.id,
|
|
||||||
tipo: tipo.charAt(0).toUpperCase() + tipo.slice(1),
|
|
||||||
descripcion: unidad.descripcion,
|
|
||||||
prorrateo: unidad.prorrateo,
|
|
||||||
precio: 0
|
|
||||||
}
|
|
||||||
if (unidad.current_precio !== null) {
|
|
||||||
data.precio = unidad.current_precio.valor
|
|
||||||
}
|
|
||||||
const u = new Unidad(data)
|
|
||||||
this.unidades.push(u)
|
|
||||||
})
|
|
||||||
this.principal = this.unidades.filter(unidad => unidad.tipo === 'Departamento')[0]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
draw({tbody, valor_terreno}) {
|
draw({tbody, valor_terreno}) {
|
||||||
@ -173,16 +247,17 @@
|
|||||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {year: 'numeric', month: 'numeric', day: 'numeric'})
|
const dateFormatter = new Intl.DateTimeFormat('es-CL', {year: 'numeric', month: 'numeric', day: 'numeric'})
|
||||||
const pesosFormatter = new Intl.NumberFormat('es-CL', {style: 'currency', currency: 'CLP'})
|
const pesosFormatter = new Intl.NumberFormat('es-CL', {style: 'currency', currency: 'CLP'})
|
||||||
const ufFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2})
|
const ufFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2})
|
||||||
const venta = this.unidades[0].descripcion
|
const venta = this.principal.descripcion
|
||||||
const cantidad = this.unidades.length
|
const cantidad = this.unidades.length
|
||||||
this.unidades.forEach(unidad => {
|
this.unidades.forEach(unidad => {
|
||||||
|
const valor = (unidad.valor > 0) ? unidad.valor : unidad.precio
|
||||||
const values = [
|
const values = [
|
||||||
venta,
|
'<a href="{{$urls->base}}/ventas/factura/' + this.id + '">' + venta + '</a>',
|
||||||
cantidad,
|
cantidad,
|
||||||
unidad.tipo,
|
unidad.tipo,
|
||||||
unidad.descripcion,
|
unidad.descripcion,
|
||||||
dateFormatter.format(this.fecha),
|
dateFormatter.format(this.fecha),
|
||||||
ufFormatter.format(unidad.precio) + ' UF',
|
ufFormatter.format(valor) + ' UF',
|
||||||
unidad.prorrateo,
|
unidad.prorrateo,
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
@ -195,22 +270,23 @@
|
|||||||
''
|
''
|
||||||
]
|
]
|
||||||
if (this.escritura !== null) {
|
if (this.escritura !== null) {
|
||||||
const descuento = valor_terreno * (1 + this.ipc / 100) * unidad.prorrateo
|
const ipc = (this.ipc >= 0) ? (1 + this.ipc) : 1 / (1 + this.ipc)
|
||||||
const precio_venta = unidad.precio * this.uf
|
const descuento = valor_terreno * ipc * unidad.prorrateo
|
||||||
|
const precio_venta = valor * this.uf
|
||||||
const precio_bruto = precio_venta - descuento
|
const precio_bruto = precio_venta - descuento
|
||||||
const precio_neto = precio_bruto / 1.19
|
const precio_neto = precio_bruto / 1.19
|
||||||
const iva = precio_bruto - precio_neto
|
const iva = precio_bruto - precio_neto
|
||||||
|
|
||||||
let i = 7
|
let i = 7
|
||||||
values[i++] = pesosFormatter.format(descuento)
|
values[i++] = (!isNaN(descuento)) ? pesosFormatter.format(descuento) : '<div class="ui active inline loader"></div>'
|
||||||
values[i++] = pesosFormatter.format(precio_venta)
|
values[i++] = (!isNaN(precio_venta)) ? pesosFormatter.format(precio_venta) : ''
|
||||||
values[i++] = pesosFormatter.format(precio_bruto)
|
values[i++] = (!isNaN(precio_bruto)) ? pesosFormatter.format(precio_bruto) : ''
|
||||||
values[i++] = pesosFormatter.format(iva)
|
values[i++] = (!isNaN(iva)) ? pesosFormatter.format(iva) : ''
|
||||||
values[i++] = pesosFormatter.format(precio_neto)
|
values[i++] = (!isNaN(precio_neto)) ? pesosFormatter.format(precio_neto) : ''
|
||||||
values[i++] = (iva / precio_venta * 100).toFixed(2) + '%'
|
values[i++] = (!isNaN(iva) && !isNaN(precio_venta)) ? (iva / precio_venta * 100).toFixed(2) + '%' : ''
|
||||||
values[i++] = dateFormatter.format(this.escritura)
|
values[i++] = dateFormatter.format(this.escritura)
|
||||||
values[i++] = ufFormatter.format(this.uf)
|
values[i++] = (!isNaN(this.uf)) ? ufFormatter.format(this.uf) : ''
|
||||||
values[i++] = (this.ipc).toFixed(2) + '%'
|
values[i++] = (!isNaN(this.ipc)) ? (ufFormatter.format(this.ipc >= 0 ? this.ipc * 100 : -this.ipc * 100) + '%') : ''
|
||||||
}
|
}
|
||||||
const row = $('<tr></tr>')
|
const row = $('<tr></tr>')
|
||||||
values.forEach(value => {
|
values.forEach(value => {
|
||||||
@ -226,74 +302,144 @@
|
|||||||
ids: {},
|
ids: {},
|
||||||
selected: 0,
|
selected: 0,
|
||||||
data: JSON.parse('{!! json_encode($proyectos) !!}'),
|
data: JSON.parse('{!! json_encode($proyectos) !!}'),
|
||||||
|
sent: false,
|
||||||
|
queues: {
|
||||||
|
uf: {},
|
||||||
|
ipc: {}
|
||||||
|
},
|
||||||
|
ufs: {},
|
||||||
|
ipcs: {},
|
||||||
table: null,
|
table: null,
|
||||||
get: function() {
|
get: function() {
|
||||||
return {
|
return {
|
||||||
ventas: () => {
|
ventas: () => {
|
||||||
|
if (this.sent) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.sent = true
|
||||||
const url = '{{$urls->api}}/ventas/facturacion/proyecto/' + this.selected
|
const url = '{{$urls->api}}/ventas/facturacion/proyecto/' + this.selected
|
||||||
|
this.draw().loading()
|
||||||
return fetchAPI(url).then(response => {
|
return fetchAPI(url).then(response => {
|
||||||
if (response.ok) {
|
if (!response) {
|
||||||
return response.json()
|
return
|
||||||
}
|
}
|
||||||
}).then(json => {
|
return response.json().then(json => {
|
||||||
const idx = this.data.findIndex(proyecto => proyecto.id === json.proyecto_id)
|
const idx = this.data.findIndex(proyecto => proyecto.id === json.proyecto_id)
|
||||||
const fecha_terreno = new Date(this.data[idx].terreno.date)
|
this.data[idx]['ventas'] = []
|
||||||
this.data[idx]['ventas'] = []
|
const ventas = []
|
||||||
const ventas = []
|
const chunkSize = 100
|
||||||
json.ventas.forEach(venta => {
|
for (let i = 0; i < json.ventas.length; i += chunkSize) {
|
||||||
const data = {
|
const chunk = json.ventas.slice(i, i + chunkSize).map(venta => venta.id)
|
||||||
id: venta.id,
|
ventas.push(this.get().chunk({idx, chunk}))
|
||||||
precio: venta.valor,
|
|
||||||
fecha: new Date(venta.fecha),
|
|
||||||
escritura: null
|
|
||||||
}
|
}
|
||||||
if (['escriturando'].includes(venta.current_estado.tipo_estado_venta.descripcion)) {
|
Promise.all(ventas).then(() => {
|
||||||
data.escritura = new Date(venta.current_estado.fecha)
|
this.draw().ventas(idx)
|
||||||
}
|
this.sent = false
|
||||||
const v = new Venta(data)
|
money.get().many().then(response => {
|
||||||
const promises = []
|
response.forEach(dates => {
|
||||||
if (v.escritura !== null) {
|
dates.forEach(values => {
|
||||||
promises.push(money.get().uf(v.escritura).then(uf => {
|
values.ventas.forEach(venta => {
|
||||||
v.uf = uf
|
let vidx = 0
|
||||||
}))
|
if (values.type === 'uf') {
|
||||||
promises.push(money.get().ipc(v.escritura, fecha_terreno).then(ipc => {
|
vidx = this.data[idx].ventas.findIndex(v => v.id === venta)
|
||||||
v.ipc = ipc
|
this.data[idx].ventas[vidx].uf = values.value
|
||||||
}))
|
return
|
||||||
}
|
}
|
||||||
promises.push(v.get().unidades())
|
if (values.type === 'ipc') {
|
||||||
const promise = Promise.all(promises).then(() => {
|
vidx = this.data[idx].ventas.findIndex(v => v.id === venta.venta_id)
|
||||||
this.data[idx].ventas.push(v)
|
this.data[idx].ventas[vidx].ipc = values.value * venta.mult
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
this.draw().ventas(idx)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
ventas.push(promise)
|
|
||||||
})
|
|
||||||
Promise.all(ventas).then(() => {
|
|
||||||
this.data[idx].ventas.sort((a, b) => parseInt(a.principal.descripcion) - parseInt(b.principal.descripcion))
|
|
||||||
this.draw().ventas(idx)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
chunk: ({idx, chunk}) => {
|
||||||
|
const url = '{{$urls->api}}/ventas/facturacion/get'
|
||||||
|
const method = 'post'
|
||||||
|
const body = new FormData()
|
||||||
|
body.set('ventas', chunk)
|
||||||
|
|
||||||
|
return fetchAPI(url, {method, body}).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
return response.json().then(json => {
|
||||||
|
json.ventas.forEach(venta => {
|
||||||
|
this.add().venta({proyecto_idx: idx, venta})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
add() {
|
||||||
|
return {
|
||||||
|
venta: ({proyecto_idx, venta}) => {
|
||||||
|
const v = new Venta(venta)
|
||||||
|
this.data[proyecto_idx].ventas.push(v)
|
||||||
|
const fecha_terreno = (typeof this.data[proyecto_idx].terreno.fecha === 'undefined') ? new Date() : new Date(this.data[proyecto_idx].terreno.fecha)
|
||||||
|
|
||||||
|
if (v.escritura !== null) {
|
||||||
|
money.enqueue().uf({date: v.escritura, venta_id: v.id})
|
||||||
|
money.enqueue().ipc({start: v.escritura, end: fecha_terreno, venta_id: v.id})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
register() {
|
||||||
|
return {
|
||||||
|
uf: ({dateString, venta_id}) => {
|
||||||
|
if (!Object.hasOwn(this.queues.uf, dateString)) {
|
||||||
|
this.queues.uf[dateString] = []
|
||||||
|
}
|
||||||
|
this.queues.uf[dateString].push(venta_id)
|
||||||
|
},
|
||||||
|
ipc: ({dateString, venta_id}) => {
|
||||||
|
if (!Object.hasOwn(this.queues.ipc, dateString)) {
|
||||||
|
this.queues.ipc[dateString] = []
|
||||||
|
}
|
||||||
|
this.queues.ipc[dateString].push(venta_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
draw: function() {
|
draw: function() {
|
||||||
return {
|
return {
|
||||||
proyectos: () => {
|
proyectos: () => {
|
||||||
|
$(this.ids.title).html('Proyectos')
|
||||||
if (this.table !== null) {
|
if (this.table !== null) {
|
||||||
this.table.clear()
|
this.table.clear()
|
||||||
|
this.table.destroy()
|
||||||
|
$(this.ids.data).html('')
|
||||||
}
|
}
|
||||||
$(this.ids.data).hide()
|
$(this.ids.data).hide()
|
||||||
|
$(this.ids.proyectos).find('.item').css('cursor', 'pointer')
|
||||||
$(this.ids.proyectos).show()
|
$(this.ids.proyectos).show()
|
||||||
},
|
},
|
||||||
ventas: proyecto_idx => {
|
ventas: proyecto_idx => {
|
||||||
const table = $(this.ids.data)
|
$(this.ids.title).html(this.data[proyecto_idx].descripcion)
|
||||||
|
const parent = $(this.ids.data)
|
||||||
if (this.table !== null) {
|
if (this.table !== null) {
|
||||||
this.table.clear().destroy()
|
this.table.clear()
|
||||||
|
this.table.destroy()
|
||||||
|
this.table = null
|
||||||
|
parent.html('')
|
||||||
}
|
}
|
||||||
|
const table = $('<table></table>').addClass('ui compact table')
|
||||||
table.append(this.draw().thead())
|
table.append(this.draw().thead())
|
||||||
table.append(this.draw().tbody(proyecto_idx))
|
table.append(this.draw().tbody(proyecto_idx))
|
||||||
table.show()
|
parent.show()
|
||||||
|
parent.html(table)
|
||||||
$(this.ids.proyectos).hide()
|
$(this.ids.proyectos).hide()
|
||||||
if (this.table === null) {
|
if (this.table === null) {
|
||||||
this.table = table.DataTable()
|
const dtD = structuredClone(datatables_defaults)
|
||||||
|
dtD['pageLength'] = 100
|
||||||
|
dtD['order'] = [[0, 'asc']]
|
||||||
|
this.table = table.DataTable(dtD)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
thead: () => {
|
thead: () => {
|
||||||
@ -331,6 +477,9 @@
|
|||||||
venta.draw({tbody, valor_terreno: this.data[proyecto_idx].terreno.valor})
|
venta.draw({tbody, valor_terreno: this.data[proyecto_idx].terreno.valor})
|
||||||
})
|
})
|
||||||
return tbody
|
return tbody
|
||||||
|
},
|
||||||
|
loading: () => {
|
||||||
|
$(this.ids.proyectos).find('.item').css('cursor', 'wait')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -369,6 +518,7 @@
|
|||||||
}
|
}
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
proyectos.setup({ids: {
|
proyectos.setup({ids: {
|
||||||
|
title: '#list_title',
|
||||||
proyectos: '#proyectos',
|
proyectos: '#proyectos',
|
||||||
data: '#data',
|
data: '#data',
|
||||||
buttons: {
|
buttons: {
|
||||||
|
File diff suppressed because it is too large
Load Diff
61
app/resources/views/ventas/pies/bonos/add.blade.php
Normal file
61
app/resources/views/ventas/pies/bonos/add.blade.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
@extends('ventas.base')
|
||||||
|
|
||||||
|
@section('venta_subtitle')
|
||||||
|
Agregar Bono - Pie
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('venta_content')
|
||||||
|
<div class="ui compact segment">
|
||||||
|
<p>Valor Promesa {{$format->ufs($venta->valor)}}</p>
|
||||||
|
@if (isset($venta->formaPago()->pie))
|
||||||
|
<p>Valor Anticipo {{$format->ufs($venta->formaPago()->pie->valor)}}</p>
|
||||||
|
@endif
|
||||||
|
<p>Valor 10% {{$format->ufs($venta->valor * 0.1)}}</p>
|
||||||
|
</div>
|
||||||
|
<form class="ui form" id="add_bono">
|
||||||
|
<div class="three wide field">
|
||||||
|
<label for="fecha">Fecha</label>
|
||||||
|
<div class="ui calendar" id="fecha">
|
||||||
|
<div class="ui left icon input">
|
||||||
|
<i class="calendar icon"></i>
|
||||||
|
<input type="text" placeholder="Fecha" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="three wide field">
|
||||||
|
<label for="valor">Valor</label>
|
||||||
|
<div class="ui right labeled input">
|
||||||
|
<input type="text" name="valor" id="valor" />
|
||||||
|
<div class="ui basic label">UF</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="ui button">Agregar</button>
|
||||||
|
</form>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('page_scripts')
|
||||||
|
<script>
|
||||||
|
$(document).ready(() => {
|
||||||
|
calendar_date_options.initialDate = new Date({{$venta->fecha->format('Y, m-1, j')}})
|
||||||
|
$('#fecha').calendar(calendar_date_options)
|
||||||
|
|
||||||
|
$('#add_bono').submit(submitEvent => {
|
||||||
|
submitEvent.preventDefault()
|
||||||
|
const url = '{{$urls->api}}/venta/{{$venta->id}}/bono_pie/add'
|
||||||
|
const data = new FormData()
|
||||||
|
data.set('fecha', $('#fecha').calendar('get date').toISOString())
|
||||||
|
data.set('valor', $('#valor').val())
|
||||||
|
return APIClient.fetch(url, {method: 'post', body: data}).then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
return response.json()
|
||||||
|
}
|
||||||
|
}).then(json => {
|
||||||
|
if (!json.success) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
window.location = '{{$urls->base}}/venta/{{$venta->id}}'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
@endpush
|
@ -4,8 +4,45 @@
|
|||||||
Cuotas - Pie
|
Cuotas - Pie
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@push('page_scripts')
|
||||||
|
<script>
|
||||||
|
const bancos = JSON.parse('{!! json_encode($bancos) !!}')
|
||||||
|
const estados = JSON.parse('{!! json_encode($estados) !!}')
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
|
||||||
@section('venta_content')
|
@section('venta_content')
|
||||||
<table class="ui table" id="cuotas">
|
@if (count($asociadas) > 0)
|
||||||
|
<div class="ui grid">
|
||||||
|
<div class="two wide column">Asociados</div>
|
||||||
|
<div class="six wide column">
|
||||||
|
{!! implode(' - ', array_map(function(Incoviba\Model\Venta $venta) use ($urls) {
|
||||||
|
return "<a href=\"{$urls->base}/venta/{$venta->id}\">{$venta->propiedad()->departamentos()[0]->descripcion}</a>";
|
||||||
|
}, $asociadas)) !!}
|
||||||
|
</div>
|
||||||
|
@if ($venta->formaPago()->pie->asociado !== null)
|
||||||
|
<div class="row">
|
||||||
|
<div class="ui tiny basic segment">
|
||||||
|
* Este pie no es la base para el cálculo de las cuotas
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<div class="ui grid">
|
||||||
|
<div class="column">Valor</div>
|
||||||
|
<div class="four wide column">
|
||||||
|
{{$format->ufs($venta->formaPago()->pie->valor)}}
|
||||||
|
@if (count($asociadas) > 0)
|
||||||
|
[{{$format->ufs($venta->formaPago()->pie->valor + array_reduce($asociadas, function(float $sum, Incoviba\Model\Venta $venta) {
|
||||||
|
return $sum + $venta->formaPago()->pie->valor;
|
||||||
|
}, 0.0))}}]
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div class="column">Cuotas</div>
|
||||||
|
<div class="column">{{$venta->formaPago()->pie->cuotas}}</div>
|
||||||
|
</div>
|
||||||
|
<table class="ui compact table" id="cuotas">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
@ -30,39 +67,54 @@
|
|||||||
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado', 'reemplazado']))
|
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado', 'reemplazado']))
|
||||||
class="disabled"
|
class="disabled"
|
||||||
@endif >
|
@endif >
|
||||||
<td>{{$cuota->numero}}</td>
|
<td>
|
||||||
|
{{$cuota->numero}}
|
||||||
|
<button class="ui mini tertiary icon button edit_cuota" data-cuota="{{$cuota->pago->id}}">
|
||||||
|
<i class="edit icon"></i>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
<td>{{$cuota->pago->fecha->format('d-m-Y')}}</td>
|
<td>{{$cuota->pago->fecha->format('d-m-Y')}}</td>
|
||||||
<td>{{$cuota->pago->fecha->format('Y-m-d')}}</td>
|
<td>{{$cuota->pago->fecha->format('Y-m-d')}}</td>
|
||||||
<td>{{$cuota->pago->banco->nombre}}</td>
|
<td>{{$cuota->pago->banco->nombre}}</td>
|
||||||
<td>{{$cuota->pago->identificador}}</td>
|
<td>{{$cuota->pago->identificador}}</td>
|
||||||
<td class="right aligned">{{$format->pesos($cuota->pago->valor)}}</td>
|
<td class="right aligned">{{$format->pesos($cuota->pago->valor)}}</td>
|
||||||
<td class="right aligned">
|
<td class="right aligned">
|
||||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' and $cuota->pago->currentEstado->fecha <= $now)
|
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['depositado', 'abonado'])
|
||||||
|
and $cuota->pago->currentEstado->fecha <= $now)
|
||||||
{{$format->ufs($cuota->pago->valor())}}
|
{{$format->ufs($cuota->pago->valor())}}
|
||||||
|
@else
|
||||||
|
~{{$format->ufs($cuota->pago->valor / $uf_venta)}}
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td{!! ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' ? ' class="green"' :
|
||||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado')
|
($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado' ? ' class="yellow"' :
|
||||||
class="green"
|
($cuota->pago->currentEstado->tipoEstadoPago->activo !== 1 ? ' class="red"' : ''))) !!}>
|
||||||
@elseif ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
{{ucwords($cuota->pago->currentEstado->tipoEstadoPago->descripcion)}}
|
||||||
class="yellow"
|
<button class="ui mini tertiary icon button edit_estado_cuota" data-cuota="{{$cuota->pago->id}}"
|
||||||
@elseif ($cuota->pago->currentEstado->tipoEstadoPago->activo !== 1)
|
data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->id}}"
|
||||||
class="red"
|
data-fecha="{{$cuota->pago->currentEstado->fecha->format('Y-m-d')}}">
|
||||||
@endif
|
<i class="edit icon"></i>
|
||||||
>{{ucwords($cuota->pago->currentEstado->tipoEstadoPago->descripcion)}}</td>
|
</button>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['abonado', 'anulado', 'reemplazado']))
|
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['abonado', 'anulado', 'reemplazado']))
|
||||||
{{$cuota->pago->currentEstado->fecha->format('d-m-Y')}}
|
{{$cuota->pago->currentEstado->fecha->format('d-m-Y')}}
|
||||||
@elseif (!in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado', 'reemplazado']))
|
@elseif (!in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado', 'reemplazado']))
|
||||||
|
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
||||||
|
{{$cuota->pago->currentEstado->fecha->format('d-m-Y')}}
|
||||||
|
@endif
|
||||||
<div class="ui calendar fecha_estado" data-date="{{$cuota->pago->currentEstado->fecha->format('Y-m-d')}}">
|
<div class="ui calendar fecha_estado" data-date="{{$cuota->pago->currentEstado->fecha->format('Y-m-d')}}">
|
||||||
<div class="ui action left icon input">
|
<div class="ui action left icon input">
|
||||||
<i class="calendar icon"></i>
|
<i class="calendar icon"></i>
|
||||||
<input type="text" name="fecha_estado" />
|
<input type="text" name="fecha_estado" />
|
||||||
<button class="ui green basic icon button accept_estado" data-pago="{{$cuota->pago->id}}" data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->descripcion}}">
|
<button class="ui green basic icon button accept_estado"
|
||||||
|
data-pago="{{$cuota->pago->id}}"
|
||||||
|
data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->descripcion}}">
|
||||||
<i class="check icon"></i>
|
<i class="check icon"></i>
|
||||||
</button>
|
</button>
|
||||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
||||||
<button class="ui red basic icon button reject_estado" data-pago="{{$cuota->pago->id}}">
|
<button class="ui red basic icon button reject_estado"
|
||||||
|
data-pago="{{$cuota->pago->id}}">
|
||||||
<i class="remove icon"></i>
|
<i class="remove icon"></i>
|
||||||
</button>
|
</button>
|
||||||
@endif
|
@endif
|
||||||
@ -85,13 +137,13 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th colspan="5">TOTAL</th>
|
<th colspan="5">TOTAL</th>
|
||||||
<th class="right aligned">
|
<th class="right aligned">
|
||||||
{{$format->pesos($total_pesos = array_reduce($venta->formaPago()->pie->cuotas(),
|
{{$format->pesos($total_pesos = array_reduce($venta->formaPago()->pie->cuotas(vigentes: true),
|
||||||
function(float $sum, Incoviba\Model\Venta\Cuota $cuota) {
|
function(int $sum, Incoviba\Model\Venta\Cuota $cuota) {
|
||||||
return $sum + $cuota->pago->valor;
|
return $sum + $cuota->pago->valor;
|
||||||
}, 0))}}
|
}, 0))}}
|
||||||
</th>
|
</th>
|
||||||
<th class="right aligned">
|
<th class="right aligned">
|
||||||
{{$format->ufs($total = array_reduce($venta->formaPago()->pie->cuotas(),
|
{{$format->ufs($total = array_reduce($venta->formaPago()->pie->cuotas(vigentes: true),
|
||||||
function(float $sum, Incoviba\Model\Venta\Cuota $cuota) use ($now, $uf_venta) {
|
function(float $sum, Incoviba\Model\Venta\Cuota $cuota) use ($now, $uf_venta) {
|
||||||
return $sum + (($cuota->pago->fecha > $now or $cuota->pago->uf === null) ?
|
return $sum + (($cuota->pago->fecha > $now or $cuota->pago->uf === null) ?
|
||||||
$cuota->pago->valor / $uf_venta :
|
$cuota->pago->valor / $uf_venta :
|
||||||
@ -103,19 +155,19 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th colspan="5">TOTAL PAGADO</th>
|
<th colspan="5">TOTAL PAGADO</th>
|
||||||
<th class="right aligned">
|
<th class="right aligned">
|
||||||
{{$format->pesos($pagado_pesos = array_reduce($venta->formaPago()->pie->cuotas(true),
|
{{$format->pesos($pagado_pesos = array_reduce($venta->formaPago()->pie->cuotas(pagadas: true, vigentes: true),
|
||||||
function(int $sum, Incoviba\Model\Venta\Cuota $cuota) {
|
function(int $sum, Incoviba\Model\Venta\Cuota $cuota) {
|
||||||
return $sum + $cuota->pago->valor;
|
return $sum + $cuota->pago->valor;
|
||||||
}, 0))}}
|
}, 0))}}
|
||||||
</th>
|
</th>
|
||||||
<th class="right aligned">
|
<th class="right aligned">
|
||||||
{{$format->ufs($pagado = array_reduce($venta->formaPago()->pie->cuotas(true),
|
{{$format->ufs($pagado = array_reduce($venta->formaPago()->pie->cuotas(pagadas: true, vigentes: true),
|
||||||
function(float $sum, Incoviba\Model\Venta\Cuota $cuota) {
|
function(float $sum, Incoviba\Model\Venta\Cuota $cuota) {
|
||||||
return $sum + $cuota->pago->valor();
|
return $sum + $cuota->pago->valor();
|
||||||
}, 0.0))}}
|
}, 0.0))}}
|
||||||
</th>
|
</th>
|
||||||
<th class="right aligned">
|
<th class="right aligned">
|
||||||
{{$format->number($pagado / $total * 100, 2)}}%
|
{{$format->number(($total > 0) ? $pagado / $total * 100 : 0, 2)}}%
|
||||||
</th>
|
</th>
|
||||||
<th colspan="3"></th>
|
<th colspan="3"></th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -128,12 +180,18 @@
|
|||||||
{{$format->ufs($total - $pagado)}}
|
{{$format->ufs($total - $pagado)}}
|
||||||
</th>
|
</th>
|
||||||
<th class="right aligned">
|
<th class="right aligned">
|
||||||
{{$format->number(($total - $pagado) / $total * 100, 2)}}%
|
{{$format->percent(($total > 0) ? ($total - $pagado) / $total * 100 : 0, 2)}}*
|
||||||
</th>
|
</th>
|
||||||
<th colspan="3"></th>
|
<th colspan="3"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
|
<div class="ui tiny basic right aligned segment">
|
||||||
|
* Porcentaje calculado sobre el valor de la venta
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@include('ventas.pies.cuotas.edit')
|
||||||
|
@include('ventas.pies.cuotas.estados.edit')
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@include('layout.head.styles.datatables')
|
@include('layout.head.styles.datatables')
|
||||||
@ -144,10 +202,15 @@
|
|||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
function updateRow({pago_id, fecha, color, estado, remove_fecha=false, add_reject=false, disable=false}) {
|
function updateRow({pago_id, valor, fecha, color, estado, remove_fecha=false, add_reject=false, disable=false}) {
|
||||||
const tr = $("tr[data-pago='" + pago_id + "']")
|
const tr = $("tr[data-pago='" + pago_id + "']")
|
||||||
|
|
||||||
tr.find(':nth-child(7)').attr('class', color).html(estado)
|
tr.find(':nth-child(6)').html(valor)
|
||||||
|
if (typeof color !== 'undefined') {
|
||||||
|
tr.find(':nth-child(7)').attr('class', color).html(estado)
|
||||||
|
} else {
|
||||||
|
tr.find(':nth-child(7)').html(estado)
|
||||||
|
}
|
||||||
if (remove_fecha) {
|
if (remove_fecha) {
|
||||||
tr.find(':nth-child(8)').html(fecha)
|
tr.find(':nth-child(8)').html(fecha)
|
||||||
}
|
}
|
||||||
@ -181,7 +244,7 @@
|
|||||||
if (!json.depositado) {
|
if (!json.depositado) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
updateRow({pago_id: json.pago_id, fecha: json.input.fecha, estado: 'Depositado', color: 'yellow', add_reject: true})
|
updateRow({pago_id: json.pago_id, valor: json.pago.valor_uf, fecha: json.input.fecha, estado: 'Depositado', color: 'yellow', add_reject: true})
|
||||||
button.attr('data-estado', 'depositado')
|
button.attr('data-estado', 'depositado')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -189,7 +252,7 @@
|
|||||||
function abonar(pago_id, fecha) {
|
function abonar(pago_id, fecha) {
|
||||||
const url = '{{$urls->api}}/ventas/pago/' + pago_id + '/abonar'
|
const url = '{{$urls->api}}/ventas/pago/' + pago_id + '/abonar'
|
||||||
const body = new FormData()
|
const body = new FormData()
|
||||||
body.set('fecha', fecha.toISOString())
|
body.set('fecha', [fecha.getFullYear(), fecha.getMonth() + 1, fecha.getDate()].join('-'))
|
||||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||||
if (!response) {
|
if (!response) {
|
||||||
return
|
return
|
||||||
@ -234,6 +297,66 @@
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
function editar(id, body) {
|
||||||
|
const url = '{{$urls->api}}/ventas/pago/' + id
|
||||||
|
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return response.json().then(json => {
|
||||||
|
if (!json.editado) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const tr = $(`tr[data-pago='${json.pago.id}']`)
|
||||||
|
tr.children(':nth-child(1)').html(json.pago.numero)
|
||||||
|
const fecha = json.pago.fecha.split(' ')[0].split('-').reverse().join('-')
|
||||||
|
tr.children(':nth-child(2)').html(fecha)
|
||||||
|
tr.children(':nth-child(3)').html(json.pago.banco.nombre)
|
||||||
|
tr.children(':nth-child(4)').html(json.pago.identificador)
|
||||||
|
const pesosFormatter = Intl.NumberFormat('es-CL', {style: 'currency', currency: 'CLP'})
|
||||||
|
tr.children(':nth-child(5)').html(pesosFormatter.format(json.pago.valor))
|
||||||
|
const ufFormatter = Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2})
|
||||||
|
tr.children(':nth-child(6)').html(ufFormatter.format(json.pago.valor_uf) + ' UF')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const editModal = new EditModal({id: '#edit_cuota_modal', approve: ({id, data}) => {
|
||||||
|
editar(id, data)
|
||||||
|
}})
|
||||||
|
$('.edit_cuota').on('click', clickEvent => {
|
||||||
|
const id = $(clickEvent.currentTarget).data('cuota')
|
||||||
|
const tr = $(`tr[data-pago='${id}']`)
|
||||||
|
const number = tr.children(':nth-child(1)').text().split('<')[0].trim()
|
||||||
|
const fecha = tr.children(':nth-child(2)').text()
|
||||||
|
const nombre_banco = tr.children(':nth-child(3)').text()
|
||||||
|
const banco_id = bancos.filter(banco => banco.nombre === nombre_banco)[0].id
|
||||||
|
const identificador = tr.find(':nth-child(4)').text()
|
||||||
|
const valor = parseInt(tr.find(':nth-child(5)').text().replace('$', '').replaceAll('.', '').trim())
|
||||||
|
|
||||||
|
editModal.open({id, number, fecha, banco_id, identificador, valor})
|
||||||
|
})
|
||||||
|
const editCuotaModal = new EditEstadoModal({id: '#edit_estado_cuota_modal', approve: ({id, data}) => {
|
||||||
|
const url = '{{$urls->api}}/ventas/pago/' + id + '/estado'
|
||||||
|
return fetchAPI(url, {method: 'post', body: data}).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return response.json().then(json => {
|
||||||
|
if (!json.editado) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
window.location.reload()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}})
|
||||||
|
$('.edit_estado_cuota').on('click', clickEvent => {
|
||||||
|
const id = $(clickEvent.currentTarget).data('cuota')
|
||||||
|
const estado_id = $(clickEvent.currentTarget).data('estado')
|
||||||
|
const fecha = $(clickEvent.currentTarget).data('fecha')
|
||||||
|
|
||||||
|
editCuotaModal.open({id, estado_id, fecha})
|
||||||
|
})
|
||||||
$('.fecha_estado').calendar({
|
$('.fecha_estado').calendar({
|
||||||
type: 'date',
|
type: 'date',
|
||||||
formatter: {
|
formatter: {
|
||||||
@ -270,17 +393,30 @@
|
|||||||
zeroRecords: 'No se encotró cuotas con ese criterio',
|
zeroRecords: 'No se encotró cuotas con ese criterio',
|
||||||
search: 'Buscar: '
|
search: 'Buscar: '
|
||||||
},
|
},
|
||||||
pageLength: "25",
|
pageLength: "100",
|
||||||
columnDefs: [
|
columnDefs: [
|
||||||
{
|
{
|
||||||
target: 1,
|
target: 1,
|
||||||
orderData: [2]
|
orderData: [2],
|
||||||
|
className: 'dt-center'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: 2,
|
target: 2,
|
||||||
visible: false,
|
visible: false,
|
||||||
searchable: false
|
searchable: false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
target: 3,
|
||||||
|
className: 'dt-center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
targets: [5, 6],
|
||||||
|
className: 'dt-right'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 7,
|
||||||
|
className: 'dt-center'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
target: 8,
|
target: 8,
|
||||||
orderData: [9]
|
orderData: [9]
|
||||||
|
108
app/resources/views/ventas/pies/cuotas/edit.blade.php
Normal file
108
app/resources/views/ventas/pies/cuotas/edit.blade.php
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<div class="ui mini 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="field">
|
||||||
|
<label>Fecha de Pago</label>
|
||||||
|
<div class="ui calendar" id="edit_fecha">
|
||||||
|
<div class="ui icon input">
|
||||||
|
<input type="text" name="fecha" />
|
||||||
|
<i class="calendar icon"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Banco</label>
|
||||||
|
<div class="ui search selection dropdown" id="edit_banco">
|
||||||
|
<i class="dropdown icon"></i>
|
||||||
|
<input type="hidden" name="banco" />
|
||||||
|
<div class="default text">Banco</div>
|
||||||
|
<div class="menu">
|
||||||
|
@foreach($bancos as $banco)
|
||||||
|
<div class="item" data-value="{{ $banco->id }}">{{ $banco->nombre }}</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Identificador</label>
|
||||||
|
<input type="text" name="identificador" />
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Valor</label>
|
||||||
|
<div class="ui labeled input">
|
||||||
|
<div class="ui label">$</div>
|
||||||
|
<input type="text" name="valor" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<button class="ui positive approve icon button">
|
||||||
|
<i class="check icon"></i>
|
||||||
|
</button>
|
||||||
|
<button class="ui negative cancel icon button">
|
||||||
|
<i class="times icon"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('page_scripts')
|
||||||
|
<script>
|
||||||
|
class EditModal {
|
||||||
|
id
|
||||||
|
approveCallback
|
||||||
|
data
|
||||||
|
|
||||||
|
constructor({id, approve}) {
|
||||||
|
this.id = id
|
||||||
|
|
||||||
|
this.approveCallback = approve;
|
||||||
|
|
||||||
|
$(this.id).modal({
|
||||||
|
onApprove: $element => {
|
||||||
|
return this.approve($element)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$(this.id).find('#edit_fecha').calendar(calendar_date_options)
|
||||||
|
$(this.id).find('#edit_banco').dropdown()
|
||||||
|
}
|
||||||
|
open({id, number, fecha, banco_id, identificador, valor}) {
|
||||||
|
this.data = {id, fecha: fecha.split('-').reverse().join('-'), banco: banco_id, identificador, valor}
|
||||||
|
$(this.id).find('.numero').text(number)
|
||||||
|
$(this.id).find('input[name="id"]').val(id)
|
||||||
|
const dateParts = fecha.split('-')
|
||||||
|
const date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0])
|
||||||
|
$(this.id).find('#edit_fecha').calendar('set date', date)
|
||||||
|
$(this.id).find('#edit_banco').dropdown('set selected', banco_id)
|
||||||
|
$(this.id).find('input[name="identificador"]').val(identificador)
|
||||||
|
$(this.id).find('input[name="valor"]').val(valor)
|
||||||
|
|
||||||
|
$(this.id).modal('show')
|
||||||
|
}
|
||||||
|
approve($element) {
|
||||||
|
const $form = $(this.id).find('#edit_cuota_form')
|
||||||
|
const temp = new FormData(document.getElementById('edit_cuota_form'))
|
||||||
|
const date = $form.find('#edit_fecha').calendar('get date')
|
||||||
|
|
||||||
|
temp.set('fecha', date.getFullYear() + '-' + (date.getMonth() + 1).toString().padStart(2, '0') + '-' + date.getDate().toString().padStart(2, '0'))
|
||||||
|
temp.set('banco', $form.find('#edit_banco').dropdown('get value'))
|
||||||
|
temp.set('valor', temp.get('valor'))
|
||||||
|
|
||||||
|
const data = new FormData()
|
||||||
|
Object.entries(this.data).forEach(([key, value]) => {
|
||||||
|
if (key === 'id') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (temp.get(key) === value.toString()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.set(key, temp.get(key))
|
||||||
|
})
|
||||||
|
|
||||||
|
return this.approveCallback({id: this.data.id, data})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endpush
|
@ -0,0 +1,93 @@
|
|||||||
|
<div class="ui mini modal" id="edit_estado_cuota_modal">
|
||||||
|
<div class="header">Editar Estado Cuota <span class="numero"></span></div>
|
||||||
|
<div class="content">
|
||||||
|
<form class="ui form" id="edit_estado_cuota_form">
|
||||||
|
<input type="hidden" name="id" />
|
||||||
|
<div class="field">
|
||||||
|
<label>Estado</label>
|
||||||
|
<div class="ui search selection dropdown" id="edit_estado_estado">
|
||||||
|
<i class="dropdown icon"></i>
|
||||||
|
<input type="hidden" name="estado" />
|
||||||
|
<div class="default text">Estado</div>
|
||||||
|
<div class="menu">
|
||||||
|
@foreach($estados as $estado)
|
||||||
|
<div class="item" data-value="{{ $estado->id }}">{{ ucwords($estado->descripcion) }}</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Fecha Estado</label>
|
||||||
|
<div class="ui calendar" id="edit_estado_fecha">
|
||||||
|
<div class="ui icon input">
|
||||||
|
<input type="text" name="fecha" />
|
||||||
|
<i class="calendar icon"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<button class="ui positive approve icon button">
|
||||||
|
<i class="check icon"></i>
|
||||||
|
</button>
|
||||||
|
<button class="ui negative cancel icon button">
|
||||||
|
<i class="times icon"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('page_scripts')
|
||||||
|
<script>
|
||||||
|
class EditEstadoModal {
|
||||||
|
id
|
||||||
|
approveCallback
|
||||||
|
data
|
||||||
|
|
||||||
|
constructor({id, approve}) {
|
||||||
|
this.id = id
|
||||||
|
|
||||||
|
this.approveCallback = approve;
|
||||||
|
|
||||||
|
$(this.id).modal({
|
||||||
|
onApprove: $element => {
|
||||||
|
return this.approve($element)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$(this.id).find('#edit_estado_estado').dropdown()
|
||||||
|
$(this.id).find('#edit_estado_fecha').calendar(calendar_date_options)
|
||||||
|
}
|
||||||
|
open({id, estado_id, fecha}) {
|
||||||
|
this.data = {id, fecha: fecha, estado: estado_id}
|
||||||
|
$(this.id).find('input[name="id"]').val(id)
|
||||||
|
$(this.id).find('#edit_estado_estado').dropdown('set selected', estado_id)
|
||||||
|
const dateParts = fecha.split('-')
|
||||||
|
const date = new Date(dateParts[0], dateParts[1] - 1, dateParts[2])
|
||||||
|
$(this.id).find('#edit_estado_fecha').calendar('set date', date)
|
||||||
|
|
||||||
|
$(this.id).modal('show')
|
||||||
|
}
|
||||||
|
approve($element) {
|
||||||
|
const $form = $(this.id).find('#edit_estado_cuota_form')
|
||||||
|
const temp = new FormData(document.getElementById('edit_estado_cuota_form'))
|
||||||
|
const date = $form.find('#edit_estado_fecha').calendar('get date')
|
||||||
|
|
||||||
|
temp.set('estado', $form.find('#edit_estado_estado').dropdown('get value'))
|
||||||
|
temp.set('fecha', date.getFullYear() + '-' + (date.getMonth() + 1).toString().padStart(2, '0') + '-' + date.getDate().toString().padStart(2, '0'))
|
||||||
|
|
||||||
|
const data = new FormData()
|
||||||
|
Object.entries(this.data).forEach(([key, value]) => {
|
||||||
|
if (key === 'id') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (temp.get(key) === value.toString()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.set(key, temp.get(key))
|
||||||
|
})
|
||||||
|
|
||||||
|
return this.approveCallback({id: this.data.id, data})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endpush
|
@ -81,7 +81,7 @@
|
|||||||
tipo_id: {{$unidad->proyectoTipoUnidad->tipoUnidad->id}},
|
tipo_id: {{$unidad->proyectoTipoUnidad->tipoUnidad->id}},
|
||||||
descripcion: '{{$unidad->descripcion}}',
|
descripcion: '{{$unidad->descripcion}}',
|
||||||
pid: {{$unidad->pu_id}},
|
pid: {{$unidad->pu_id}},
|
||||||
valor: {{($unidad->valor > 0) ? $unidad->valor : $unidad->precio($venta->fecha)->valor}}
|
valor: {{($unidad->valor > 0) ? $unidad->valor : ($unidad->precio($venta->fecha)->valor ?? 0)}}
|
||||||
},
|
},
|
||||||
@endforeach
|
@endforeach
|
||||||
],
|
],
|
||||||
@ -108,9 +108,12 @@
|
|||||||
},
|
},
|
||||||
doAddUnidad: function() {
|
doAddUnidad: function() {
|
||||||
const url = '{{$urls->api}}/ventas/propiedades/unidades/add'
|
const url = '{{$urls->api}}/ventas/propiedades/unidades/add'
|
||||||
const data = new FormData(document.getElementById('add_form'))
|
const body = new FormData(document.getElementById('add_form'))
|
||||||
data.set('propiedad', {{$propiedad->id}})
|
body.set('propiedad', {{$propiedad->id}})
|
||||||
return fetchAPI(url, {method: 'post', body: data}).then(response => {
|
if (body.get('valor') === '') {
|
||||||
|
body.set('valor', '0')
|
||||||
|
}
|
||||||
|
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return response.json()
|
return response.json()
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,12 @@ Editar Propietario
|
|||||||
<h2 class="ui header">Editar Propietario</h2>
|
<h2 class="ui header">Editar Propietario</h2>
|
||||||
<form class="ui form" id="edit_form">
|
<form class="ui form" id="edit_form">
|
||||||
<input type="hidden" name="venta_id" value="{{$venta_id}}" />
|
<input type="hidden" name="venta_id" value="{{$venta_id}}" />
|
||||||
<div class="field">
|
<div class="two wide field">
|
||||||
<label for="rut">RUT</label>
|
<label for="rut">RUT</label>
|
||||||
{{$propietario->rut()}}
|
<div class="ui right labeled input" id="rut">
|
||||||
|
<input type="text" name="rut" value="{{number_format($propietario->rut, 0, ',', '.')}}" />
|
||||||
|
<div class="ui basic label">-<span id="digito">{{$propietario->dv}}</span></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fields">
|
<div class="fields">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
@ -62,165 +65,486 @@ Editar Propietario
|
|||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function drawComunas({parent, comunas}) {
|
class Propietario {
|
||||||
parent.html('')
|
props
|
||||||
comunas.forEach(comuna => {
|
constructor({rut, digito, nombres, apellidos: {paterno, materno}, direccion: {calle, numero, extra, comuna, region}}) {
|
||||||
const option = $('<option></option>')
|
this.props = {
|
||||||
option.attr('value', comuna.id).html(comuna.descripcion)
|
rut,
|
||||||
if (comuna.id === {{$propietario->datos->direccion->comuna->id}}) {
|
digito,
|
||||||
option.prop('selected', true)
|
nombres,
|
||||||
|
apellidos: {
|
||||||
|
paterno,
|
||||||
|
materno
|
||||||
|
},
|
||||||
|
direccion: {
|
||||||
|
calle,
|
||||||
|
numero,
|
||||||
|
extra,
|
||||||
|
comuna,
|
||||||
|
region
|
||||||
|
},
|
||||||
}
|
}
|
||||||
parent.append(option)
|
}
|
||||||
})
|
|
||||||
parent.show()
|
update() {
|
||||||
parent.dropdown()
|
return {
|
||||||
}
|
rut: rut => {
|
||||||
function findComunas(direccion) {
|
this.props.rut = rut
|
||||||
const original_id = $("[name='comuna']").val()
|
this.update().digito(Rut.digito(this.props.rut))
|
||||||
const uri = '{{$urls->api}}/direcciones/comunas/find'
|
},
|
||||||
const data = {direccion}
|
digito: digito => {
|
||||||
return fetchAPI(uri,
|
this.props.digito = digito
|
||||||
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
|
},
|
||||||
).then(response => {
|
nombres: nombres => {
|
||||||
if (response.ok) {
|
this.props.nombres = nombres
|
||||||
return response.json()
|
},
|
||||||
|
apellidos: () => {
|
||||||
|
return {
|
||||||
|
paterno: paterno => {
|
||||||
|
this.props.apellidos.paterno = paterno
|
||||||
|
},
|
||||||
|
materno: materno => {
|
||||||
|
this.props.apellidos.materno = materno
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
direccion: () => {
|
||||||
|
return {
|
||||||
|
calle: calle => {
|
||||||
|
this.props.direccion.calle = calle
|
||||||
|
},
|
||||||
|
numero: numero => {
|
||||||
|
this.props.direccion.numero = numero
|
||||||
|
},
|
||||||
|
extra: extra => {
|
||||||
|
this.props.direccion.extra = extra
|
||||||
|
},
|
||||||
|
comuna: comuna => {
|
||||||
|
this.props.direccion.comuna = comuna
|
||||||
|
},
|
||||||
|
region: region => {
|
||||||
|
this.props.direccion.region = region
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).then(data => {
|
}
|
||||||
if (data.total === 0) {
|
edit() {
|
||||||
|
const uri = '{{$urls->api}}/venta/{{$venta_id}}/propietario/edit'
|
||||||
|
const originales = {
|
||||||
|
rut: '{{trim($propietario->rut)}}',
|
||||||
|
nombres: '{{trim($propietario->nombres)}}',
|
||||||
|
apellidos: {
|
||||||
|
paterno: '{{trim($propietario->apellidos['paterno'])}}',
|
||||||
|
materno: '{{trim($propietario->apellidos['materno'])}}'
|
||||||
|
},
|
||||||
|
direccion: {
|
||||||
|
calle: '{{trim($propietario->datos->direccion->calle)}}',
|
||||||
|
numero: '{{$propietario->datos->direccion->numero}}',
|
||||||
|
extra: '{{trim($propietario->datos->direccion->extra)}}',
|
||||||
|
comuna: '{{$propietario->datos->direccion->comuna->id}}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const data = {}
|
||||||
|
const collator = new Intl.Collator('es')
|
||||||
|
Object.entries(originales).forEach(([key, value]) => {
|
||||||
|
if (key === 'apellidos') {
|
||||||
|
Object.entries(value).forEach(([k, v]) => {
|
||||||
|
const val = this.props[key][k]
|
||||||
|
if (collator.compare(val, v) !== 0) {
|
||||||
|
data[`apellido_${k}`] = val
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (key === 'direccion') {
|
||||||
|
let changed = false
|
||||||
|
Object.entries(value).forEach(([k, v]) => {
|
||||||
|
const val = this.props[key][k]
|
||||||
|
if (collator.compare(val, v) !== 0) {
|
||||||
|
changed = true
|
||||||
|
data[k] = val
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (changed) {
|
||||||
|
Object.entries(value).forEach(([k, v]) => {
|
||||||
|
if (k in data) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data[k] = this.props[key][k]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const val = this.props[key]
|
||||||
|
if (collator.compare(val, value) !== 0) {
|
||||||
|
data[key] = val
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (Object.keys(data).length === 0) {
|
||||||
|
// No changes
|
||||||
|
propietario.redirect()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const comuna_id = data.comunas[0].id
|
if ('rut' in data) {
|
||||||
if (comuna_id === original_id) {
|
data['dv'] = Rut.digito(data['rut'])
|
||||||
return
|
|
||||||
}
|
}
|
||||||
const parent = $('#comunas')
|
return fetchAPI(uri,
|
||||||
parent.dropdown('set selected', comuna_id)
|
{method: 'put', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
|
||||||
})
|
).then(response => {
|
||||||
}
|
if (!response) {
|
||||||
function getComunas(region_id) {
|
return
|
||||||
const parent = $('#comunas')
|
}
|
||||||
parent.hide()
|
return response.json().then(data => {
|
||||||
const uri = '{{$urls->api}}/direcciones/region/' + region_id + '/comunas'
|
if (data.edited) {
|
||||||
return fetchAPI(uri).then(response => {
|
propietario.redirect()
|
||||||
if (response.ok) {
|
}
|
||||||
return response.json()
|
})
|
||||||
}
|
})
|
||||||
}).then(data => {
|
|
||||||
if (data.total === 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
drawComunas({parent, comunas: data.comunas})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
function redirect() {
|
|
||||||
window.location = '{{$urls->base}}/venta/{{$venta_id}}'
|
|
||||||
}
|
|
||||||
function changeDireccion() {
|
|
||||||
const names = [
|
|
||||||
'calle',
|
|
||||||
'numero',
|
|
||||||
'extra'
|
|
||||||
]
|
|
||||||
const originals = [
|
|
||||||
'{{trim($propietario->datos->direccion->calle)}}',
|
|
||||||
'{{trim($propietario->datos->direccion->numero)}}',
|
|
||||||
'{{trim($propietario->datos->direccion->extra)}}'
|
|
||||||
]
|
|
||||||
const values = []
|
|
||||||
names.forEach(name => {
|
|
||||||
const val = $("[name='" + name + "']").val()
|
|
||||||
values.push(val)
|
|
||||||
})
|
|
||||||
const collator = new Intl.Collator('es')
|
|
||||||
if (collator.compare(originals.join(' '), values.join(' ')) !== 0) {
|
|
||||||
findComunas(values.join(' ').trim())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function watchChangeDireccion() {
|
class Region {
|
||||||
const watched = [
|
props
|
||||||
'calle',
|
comunas
|
||||||
'numero',
|
|
||||||
'extra'
|
constructor({id, descripcion, selected = false}) {
|
||||||
]
|
this.props = {
|
||||||
watched.forEach(name => {
|
id,
|
||||||
$("[name='" + name + "']").change(event => {
|
descripcion,
|
||||||
changeDireccion()
|
selected
|
||||||
|
}
|
||||||
|
this.comunas = []
|
||||||
|
}
|
||||||
|
get() {
|
||||||
|
return {
|
||||||
|
comunas: () => {
|
||||||
|
if (this.comunas.length > 0) {
|
||||||
|
return new Promise(resolve => resolve())
|
||||||
|
}
|
||||||
|
const uri = '{{$urls->api}}/direcciones/region/' + this.props.id + '/comunas'
|
||||||
|
return fetchAPI(uri).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return response.json().then(data => {
|
||||||
|
if (data.total === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.comunas = data.comunas.map(comuna => {
|
||||||
|
let selected = false
|
||||||
|
if (comuna.id === {{$propietario->datos->direccion->comuna->id}}) {
|
||||||
|
selected = true
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: comuna.id,
|
||||||
|
descripcion: comuna.descripcion,
|
||||||
|
selected
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Form {
|
||||||
|
static submit(event) {
|
||||||
|
event.preventDefault()
|
||||||
|
propietario.props.data.edit()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Watcher {
|
||||||
|
static rut() {
|
||||||
|
const rut = $("[name='rut']")
|
||||||
|
rut.on('input', EventHandler.rut().update)
|
||||||
|
rut.on('blur', EventHandler.rut().change)
|
||||||
|
}
|
||||||
|
static nombres() {
|
||||||
|
$("[name='nombres']").change(event => {
|
||||||
|
propietario.props.data.update().nombres($(event.currentTarget).val())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
static apellidos() {
|
||||||
|
const watched = [
|
||||||
|
'apellido_paterno',
|
||||||
|
'apellido_materno'
|
||||||
|
]
|
||||||
|
watched.forEach(name => {
|
||||||
|
$("[name='" + name + "']").change(event => {
|
||||||
|
const value = $(event.currentTarget).val()
|
||||||
|
const key = name.split('_')[1]
|
||||||
|
propietario.props.data.update().apellidos()[key](value)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
static direccion() {
|
||||||
|
const watched = [
|
||||||
|
'calle',
|
||||||
|
'numero',
|
||||||
|
'extra'
|
||||||
|
]
|
||||||
|
watched.forEach(name => {
|
||||||
|
$("[name='" + name + "']").change(EventHandler.direccion)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
static region() {
|
||||||
|
$('#region').change(EventHandler.region)
|
||||||
|
}
|
||||||
|
static comuna() {
|
||||||
|
$('#comunas').change(event => {
|
||||||
|
const comuna_id = $(event.currentTarget).val()
|
||||||
|
propietario.props.data.update().direccion().comuna(comuna_id)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
static run() {
|
||||||
|
Watcher.rut()
|
||||||
|
Watcher.nombres()
|
||||||
|
Watcher.apellidos()
|
||||||
|
Watcher.direccion()
|
||||||
|
Watcher.region()
|
||||||
|
Watcher.comuna()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class EventHandler {
|
||||||
|
static region(event) {
|
||||||
|
const region_id = $(event.currentTarget).val()
|
||||||
|
propietario.props.regiones.forEach(region => {
|
||||||
|
region.props.selected = false
|
||||||
|
})
|
||||||
|
const region = propietario.props.regiones.find(region => region.props.id === region_id)
|
||||||
|
region.props.selected = true
|
||||||
|
region.get().comunas().then(() => {
|
||||||
|
propietario.draw().comunas()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
static direccion(event) {
|
||||||
|
const names = [
|
||||||
|
'calle',
|
||||||
|
'numero',
|
||||||
|
'extra'
|
||||||
|
]
|
||||||
|
const originals = [
|
||||||
|
'{{trim($propietario->datos->direccion->calle)}}',
|
||||||
|
'{{trim($propietario->datos->direccion->numero)}}',
|
||||||
|
'{{trim($propietario->datos->direccion->extra)}}'
|
||||||
|
]
|
||||||
|
const values = []
|
||||||
|
names.forEach(name => {
|
||||||
|
const val = $("[name='" + name + "']").val()
|
||||||
|
propietario.props.data.update().direccion()[name](val)
|
||||||
|
values.push(val)
|
||||||
|
})
|
||||||
|
const collator = new Intl.Collator('es')
|
||||||
|
if (collator.compare(originals.join(' '), values.join(' ')) !== 0) {
|
||||||
|
propietario.find().comuna(values.join(' ').trim())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static rut() {
|
||||||
|
return {
|
||||||
|
change: event => {
|
||||||
|
const rut = $("[name='rut']").val().replace(/\D/g, '')
|
||||||
|
if (rut.length < 7) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
propietario.find().propietario(rut)
|
||||||
|
},
|
||||||
|
update: event => {
|
||||||
|
const input = $("[name='rut']")
|
||||||
|
const rut = input.val().replace(/\D/g, '')
|
||||||
|
propietario.props.data.update().rut(rut)
|
||||||
|
input.val(Rut.format(rut))
|
||||||
|
$('#digito').html(propietario.props.data.props.digito)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Rut {
|
||||||
|
static format(rut) {
|
||||||
|
return Intl.NumberFormat('es-CL', {maximumFractionDigits: 0}).format(rut)
|
||||||
|
}
|
||||||
|
static digito(rut) {
|
||||||
|
const cleanRut = rut.replace(/\D/g, ''); // Removes non-digit characters more efficiently
|
||||||
|
let sum = 0;
|
||||||
|
const factors = [2, 3, 4, 5, 6, 7, 2, 3, 4, 5];
|
||||||
|
for (let i = 0; i < cleanRut.length; i++) {
|
||||||
|
const digit = parseInt(cleanRut[cleanRut.length - 1 - i], 10);
|
||||||
|
sum += digit * factors[i % factors.length];
|
||||||
|
}
|
||||||
|
const dv = 11 - (sum % 11);
|
||||||
|
return dv === 10 ? 'K' : dv === 11 ? '0' : dv.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const propietario = {
|
||||||
|
props: {
|
||||||
|
ids: {},
|
||||||
|
data: {},
|
||||||
|
regiones: [],
|
||||||
|
},
|
||||||
|
update() {
|
||||||
|
return {
|
||||||
|
propietario: () => {
|
||||||
|
$("[name='rut']").val(Rut.format(this.props.data.props.rut))
|
||||||
|
$('#digito').html(this.props.data.props.digito)
|
||||||
|
$("[name='nombres']").val(this.props.data.props.nombres)
|
||||||
|
$("[name='apellido_paterno']").val(this.props.data.props.apellidos.paterno)
|
||||||
|
$("[name='apellido_materno']").val(this.props.data.props.apellidos.materno)
|
||||||
|
$("[name='calle']").val(this.props.data.props.direccion.calle)
|
||||||
|
$("[name='numero']").val(this.props.data.props.direccion.numero)
|
||||||
|
$("[name='extra']").val(this.props.data.props.direccion.extra)
|
||||||
|
$('#region').val(this.props.data.props.direccion.region)
|
||||||
|
this.update().region()
|
||||||
|
},
|
||||||
|
region: () => {
|
||||||
|
this.props.regiones.forEach(region => {
|
||||||
|
region.props.selected = false
|
||||||
|
})
|
||||||
|
this.props.regiones.filter(region => region.props.id === this.props.data.props.direccion.region).forEach(region => {
|
||||||
|
region.props.selected = true
|
||||||
|
})
|
||||||
|
const promises = []
|
||||||
|
this.props.regiones.filter(region => region.props.selected).forEach(region => {
|
||||||
|
promises.push(region.get().comunas())
|
||||||
|
})
|
||||||
|
Promise.all(promises).then(() => {
|
||||||
|
this.draw().comunas()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
find() {
|
||||||
|
return {
|
||||||
|
propietario: rut => {
|
||||||
|
const uri = '{{$urls->api}}/ventas/propietario/' + rut
|
||||||
|
return fetchAPI(uri).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
this.draw().reset()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return response.json().then(data => {
|
||||||
|
if (data.propietario === null) {
|
||||||
|
this.draw().reset()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.props.data.update().nombres(data.propietario.nombres)
|
||||||
|
this.props.data.update().apellidos().paterno(data.propietario.apellidos.paterno)
|
||||||
|
this.props.data.update().apellidos().materno(data.propietario.apellidos.materno)
|
||||||
|
this.props.data.update().direccion().calle(data.propietario.direccion.calle)
|
||||||
|
this.props.data.update().direccion().numero(data.propietario.direccion.numero)
|
||||||
|
this.props.data.update().direccion().extra(data.propietario.direccion.extra)
|
||||||
|
this.props.data.update().direccion().comuna(data.propietario.direccion.comuna.id)
|
||||||
|
this.props.data.update().direccion().region(data.propietario.direccion.comuna.provincia.region.id)
|
||||||
|
this.update().propietario()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
comuna: direccion => {
|
||||||
|
const original_id = $("[name='comuna']").val()
|
||||||
|
const uri = '{{$urls->api}}/direcciones/comunas/find'
|
||||||
|
const data = {direccion}
|
||||||
|
return fetchAPI(uri,
|
||||||
|
{method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
|
||||||
|
).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return response.json().then(data => {
|
||||||
|
if (data.total === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const comuna_id = data.comunas[0].id
|
||||||
|
if (comuna_id === original_id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const parent = $('#comunas')
|
||||||
|
parent.dropdown('set selected', comuna_id)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
draw() {
|
||||||
|
return {
|
||||||
|
comunas: () => {
|
||||||
|
const parent = $(this.props.ids.comuna)
|
||||||
|
parent.html('')
|
||||||
|
const region_id = $(this.props.ids.region).val()
|
||||||
|
const comunas = this.props.regiones.find(region => region.props.id === region_id).comunas
|
||||||
|
comunas.forEach(comuna => {
|
||||||
|
const option = $('<option></option>')
|
||||||
|
option.attr('value', comuna.id).html(comuna.descripcion)
|
||||||
|
if (parseInt(comuna.id) === parseInt(this.props.data.props.direccion.comuna)) {
|
||||||
|
option.prop('selected', true)
|
||||||
|
}
|
||||||
|
parent.append(option)
|
||||||
|
})
|
||||||
|
parent.show()
|
||||||
|
parent.dropdown()
|
||||||
|
},
|
||||||
|
reset: () => {
|
||||||
|
$("[name='nombres']").val('')
|
||||||
|
$("[name='apellido_paterno']").val('')
|
||||||
|
$("[name='apellido_materno']").val('')
|
||||||
|
$("[name='calle']").val('')
|
||||||
|
$("[name='numero']").val('')
|
||||||
|
$("[name='extra']").val('')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
redirect() {
|
||||||
|
window.location = '{{$urls->base}}/venta/{{$venta_id}}'
|
||||||
|
},
|
||||||
|
setup({ids, propietario}) {
|
||||||
|
this.props.ids = ids
|
||||||
|
this.props.data = propietario
|
||||||
|
|
||||||
|
$(this.props.ids.region).dropdown()
|
||||||
|
$(this.props.ids.region).change(EventHandler.region)
|
||||||
|
|
||||||
|
$(this.props.ids.comuna).hide()
|
||||||
|
$(this.props.ids.region).find('option').each((index, element) => {
|
||||||
|
const id = $(element).val()
|
||||||
|
const descripcion = $(element).text()
|
||||||
|
const selected = $(element).prop('selected')
|
||||||
|
this.props.regiones.push(new Region({id, descripcion, selected}))
|
||||||
|
})
|
||||||
|
this.update().region()
|
||||||
|
|
||||||
|
$(this.props.ids.forms.edit).submit(Form.submit)
|
||||||
|
Watcher.run()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(() => {
|
||||||
|
propietario.setup({
|
||||||
|
ids: {
|
||||||
|
region: '#region',
|
||||||
|
comuna: '#comunas',
|
||||||
|
forms: {
|
||||||
|
edit: '#edit_form'
|
||||||
|
},
|
||||||
|
buttons: {
|
||||||
|
guardar: '#guardar_button'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
propietario: new Propietario({
|
||||||
|
rut: '{{$propietario->rut}}',
|
||||||
|
digito: '{{$propietario->dv}}',
|
||||||
|
nombres: '{{$propietario->nombres}}',
|
||||||
|
apellidos: {
|
||||||
|
paterno: '{{$propietario->apellidos['paterno']}}',
|
||||||
|
materno: '{{$propietario->apellidos['materno']}}'
|
||||||
|
},
|
||||||
|
direccion: {
|
||||||
|
calle: '{{$propietario->datos->direccion->calle}}',
|
||||||
|
numero: '{{$propietario->datos->direccion->numero}}',
|
||||||
|
extra: '{{$propietario->datos->direccion->extra}}',
|
||||||
|
comuna: '{{$propietario->datos->direccion->comuna->id}}',
|
||||||
|
region: '{{$propietario->datos->direccion->comuna->provincia->region->id}}',
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
|
||||||
function editPropietario() {
|
|
||||||
const uri = '{{$urls->api}}/ventas/propietario/{{$propietario->rut}}'
|
|
||||||
const names = [
|
|
||||||
'nombres',
|
|
||||||
'apellido_paterno',
|
|
||||||
'apellido_materno'
|
|
||||||
]
|
|
||||||
const values = [
|
|
||||||
'{{trim($propietario->nombres)}}',
|
|
||||||
'{{trim($propietario->apellidos['paterno'])}}',
|
|
||||||
'{{trim($propietario->apellidos['materno'])}}'
|
|
||||||
]
|
|
||||||
const direccion_names = [
|
|
||||||
'calle',
|
|
||||||
'numero',
|
|
||||||
'extra',
|
|
||||||
'comuna'
|
|
||||||
]
|
|
||||||
const direccion_values = [
|
|
||||||
'{{trim($propietario->datos->direccion->calle)}}',
|
|
||||||
'{{$propietario->datos->direccion->numero}}',
|
|
||||||
'{{trim($propietario->datos->direccion->extra)}}',
|
|
||||||
'{{$propietario->datos->direccion->comuna->id}}'
|
|
||||||
]
|
|
||||||
const data = {}
|
|
||||||
const collator = new Intl.Collator('es')
|
|
||||||
names.forEach((name, index) => {
|
|
||||||
const val = $("[name='" + name + "']").val()
|
|
||||||
if (collator.compare(val, values[index]) !== 0) {
|
|
||||||
console.debug(name, val, values[index], collator.compare(val, values[index]))
|
|
||||||
data[name] = val
|
|
||||||
}
|
|
||||||
})
|
|
||||||
direccion_names.forEach((name, index) => {
|
|
||||||
const val = $("[name='" + name + "']").val()
|
|
||||||
if (collator.compare(val, direccion_values[index]) !== 0) {
|
|
||||||
if (typeof data['direccion'] === 'undefined') {
|
|
||||||
data['direccion'] = {}
|
|
||||||
}
|
|
||||||
console.debug(name, val, direccion_values[index])
|
|
||||||
data['direccion'][name] = val
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (Object.keys(data).length === 0) {
|
|
||||||
redirect()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return fetchAPI(uri,
|
|
||||||
{method: 'put', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
|
|
||||||
).then(response => {
|
|
||||||
if (response.ok) {
|
|
||||||
redirect()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
$(document).ready(() => {
|
|
||||||
const regiones = $("select[name='region']")
|
|
||||||
regiones.dropdown()
|
|
||||||
regiones.change(event => {
|
|
||||||
const region_id = $(event.currentTarget).val()
|
|
||||||
getComunas(region_id)
|
|
||||||
})
|
|
||||||
$('#comunas').hide()
|
|
||||||
getComunas({{$propietario->datos->direccion->comuna->provincia->region->id}})
|
|
||||||
$('#edit_form').submit(event => {
|
|
||||||
event.preventDefault()
|
|
||||||
editPropietario({{$propietario->rut}})
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
$('#guardar_button').click(event => {
|
|
||||||
editPropietario({{$propietario->rut}})
|
|
||||||
})
|
|
||||||
watchChangeDireccion()
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
COMENTARIOS
|
COMENTARIOS
|
||||||
</div>
|
</div>
|
||||||
<div class="right aligned column">
|
<div class="right aligned column">
|
||||||
<a href="javascript: addComment()" style="color: inherit;">
|
<button class="ui icon button" style="background: none; color: inherit; padding: 0;" id="add_comentario_button">
|
||||||
<i class="plus icon"></i>
|
<i class="plus icon"></i>
|
||||||
</a>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
@ -13,37 +13,199 @@
|
|||||||
<tbody id="comentarios"></tbody>
|
<tbody id="comentarios"></tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ui modal" id="addComment">
|
||||||
|
<div class="header">
|
||||||
|
Agregar Comentario
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<form class="ui form">
|
||||||
|
<div class="three wide field">
|
||||||
|
<label>Fecha</label>
|
||||||
|
<div class="ui calendar" id="fecha">
|
||||||
|
<div class="ui icon input">
|
||||||
|
<input type="text" placeholder="Fecha">
|
||||||
|
<i class="calendar icon"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Comentario</label>
|
||||||
|
<textarea id="comentario" rows="2"></textarea>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<div class="ui black deny button">
|
||||||
|
Cancelar
|
||||||
|
</div>
|
||||||
|
<div class="ui positive right labeled icon button">
|
||||||
|
Agregar
|
||||||
|
<i class="checkmark icon"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ui modal" id="editComment">
|
||||||
|
<div class="header">
|
||||||
|
Edit Comentario
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<form class="ui form">
|
||||||
|
<input type="hidden" name="id" />
|
||||||
|
<div class="three wide field">
|
||||||
|
<label>Fecha</label>
|
||||||
|
<div class="ui calendar" id="fechaEdit">
|
||||||
|
<div class="ui icon input">
|
||||||
|
<input type="text" placeholder="Fecha">
|
||||||
|
<i class="calendar icon"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label>Comentario</label>
|
||||||
|
<textarea id="comentarioEdit" rows="2"></textarea>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<div class="ui black deny button">
|
||||||
|
Cancelar
|
||||||
|
</div>
|
||||||
|
<div class="ui positive right labeled icon button">
|
||||||
|
Editar
|
||||||
|
<i class="checkmark icon"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
class Comentario
|
class Comentario {
|
||||||
{
|
id
|
||||||
fecha
|
fecha
|
||||||
texto
|
texto
|
||||||
|
|
||||||
constructor({fecha, texto})
|
constructor({id, fecha, texto})
|
||||||
{
|
{
|
||||||
|
this.id = id
|
||||||
this.fecha = new Date(fecha + 'T00:00:00')
|
this.fecha = new Date(fecha + 'T00:00:00')
|
||||||
this.texto = texto
|
this.texto = texto
|
||||||
}
|
}
|
||||||
draw(dateFormatter)
|
draw(dateFormatter)
|
||||||
{
|
{
|
||||||
return $('<tr></tr>').append(
|
return [
|
||||||
$('<td></td>').html(dateFormatter.format(this.fecha))
|
'<tr>',
|
||||||
).append(
|
`<td class="collapsing">${dateFormatter.format(this.fecha)}</td>`,
|
||||||
$('<td></td>').html(this.texto)
|
`<td>${this.texto}</td>`,
|
||||||
).append(
|
'<td class="right aligned">',
|
||||||
$('<td></td>').addClass('right aligned').append(
|
`<button class="ui tiny tertiary icon button editComentario" data-id="${this.id}">`,
|
||||||
$('<a></a>').attr('href', 'javascript: removeComment();').append(
|
'<i class="edit icon"></i>',
|
||||||
$('<i></i>').addClass('minus icon')
|
'</button>',
|
||||||
)
|
`<button class="ui tiny tertiary red icon button removeComentario" data-id="${this.id}">`,
|
||||||
)
|
'<i class="minus icon"></i>',
|
||||||
)
|
'</button>',
|
||||||
|
'</td>',
|
||||||
|
'</tr>'
|
||||||
|
].join("\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class AddModal {
|
||||||
|
props
|
||||||
|
constructor({id}) {
|
||||||
|
this.props = {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
$(this.props.id).modal({
|
||||||
|
onApprove: () => {
|
||||||
|
this.approve()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const cdo = structuredClone(calendar_date_options)
|
||||||
|
$(this.props.id).find('.ui.calendar').calendar(cdo)
|
||||||
|
this.hide()
|
||||||
|
}
|
||||||
|
approve() {
|
||||||
|
const fecha = $(this.props.id).find('#fecha').calendar('get date')
|
||||||
|
const fechaString = [fecha.getFullYear(), fecha.getMonth()+1, fecha.getDate()].join('-')
|
||||||
|
const comentario = $(this.props.id).find('#comentario').val()
|
||||||
|
const uri = '{{$urls->api}}/venta/{{$venta->id}}/comentarios/add'
|
||||||
|
const body = new FormData()
|
||||||
|
body.append('fecha', fechaString)
|
||||||
|
body.append('texto', comentario)
|
||||||
|
fetchAPI(uri, {method: 'post', body}).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return response.json().then(data => {
|
||||||
|
if (data.added) {
|
||||||
|
comentarios.comentarios.push(new Comentario(data.comentario))
|
||||||
|
comentarios.draw().comentarios()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
show() {
|
||||||
|
const modal = $(this.props.id)
|
||||||
|
modal.find('form').trigger('reset')
|
||||||
|
modal.modal('show')
|
||||||
|
}
|
||||||
|
hide() {
|
||||||
|
const modal = $(this.props.id)
|
||||||
|
modal.modal('hide')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class EditModal {
|
||||||
|
props
|
||||||
|
constructor({id}) {
|
||||||
|
this.props = {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
$(this.props.id).modal({
|
||||||
|
onApprove: () => {
|
||||||
|
this.approve()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const cdo = structuredClone(calendar_date_options)
|
||||||
|
$(this.props.id).find('.ui.calendar').calendar(cdo)
|
||||||
|
this.hide()
|
||||||
|
}
|
||||||
|
approve() {
|
||||||
|
const id = $(this.props.id).find("[name='id']").val()
|
||||||
|
const fecha = $(this.props.id).find('#fechaEdit').calendar('get date')
|
||||||
|
const fechaString = [fecha.getFullYear(), fecha.getMonth()+1, fecha.getDate()].join('-')
|
||||||
|
const comentario = $(this.props.id).find('#comentarioEdit').val()
|
||||||
|
const uri = `{{$urls->api}}/ventas/comentario/${id}/edit`
|
||||||
|
const body = new FormData()
|
||||||
|
body.append('fecha', fechaString)
|
||||||
|
body.append('texto', comentario)
|
||||||
|
fetchAPI(uri, {method: 'post', body}).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return response.json().then(data => {
|
||||||
|
if (data.edited) {
|
||||||
|
const idx = comentarios.comentarios.findIndex(comentario => comentario.id === data.comentario_id)
|
||||||
|
comentarios.comentarios[idx] = new Comentario(data.comentario)
|
||||||
|
comentarios.draw().comentarios()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
show() {
|
||||||
|
const modal = $(this.props.id)
|
||||||
|
modal.modal('show')
|
||||||
|
}
|
||||||
|
hide() {
|
||||||
|
const modal = $(this.props.id)
|
||||||
|
modal.modal('hide')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const comentarios = {
|
const comentarios = {
|
||||||
comentarios: [],
|
comentarios: [],
|
||||||
id: '',
|
id: '',
|
||||||
|
modals: {
|
||||||
|
add: null,
|
||||||
|
edit: null
|
||||||
|
},
|
||||||
fetch: function() {
|
fetch: function() {
|
||||||
return {
|
return {
|
||||||
comentarios: () => {
|
comentarios: () => {
|
||||||
@ -60,6 +222,7 @@
|
|||||||
this.comentarios.push(new Comentario(settings))
|
this.comentarios.push(new Comentario(settings))
|
||||||
})
|
})
|
||||||
this.draw().comentarios()
|
this.draw().comentarios()
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,11 +236,41 @@
|
|||||||
this.comentarios.forEach(comentario => {
|
this.comentarios.forEach(comentario => {
|
||||||
body.append(comentario.draw(dateFormatter))
|
body.append(comentario.draw(dateFormatter))
|
||||||
})
|
})
|
||||||
|
$('.editComentario').on('click', event => {
|
||||||
|
const id = $(event.currentTarget).data('id')
|
||||||
|
const comentario = this.comentarios.find(comentario => comentario.id === id)
|
||||||
|
const modal = this.modals.edit
|
||||||
|
const fecha = new Date(comentario.fecha)
|
||||||
|
$(modal.props.id).find("[name='id']").val(id)
|
||||||
|
$(modal.props.id).find('#fechaEdit').calendar('set date', fecha)
|
||||||
|
$(modal.props.id).find('#comentarioEdit').val(comentario.texto)
|
||||||
|
modal.show()
|
||||||
|
})
|
||||||
|
$('.removeComentario').click(event => {
|
||||||
|
const id = $(event.currentTarget).data('id')
|
||||||
|
const uri = `{{$urls->api}}/ventas/comentario/${id}/remove`
|
||||||
|
fetchAPI(uri, {method: 'delete'}).then(response => {
|
||||||
|
if (!response) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return response.json().then(data => {
|
||||||
|
if (data.removed) {
|
||||||
|
this.comentarios = this.comentarios.filter(comentario => comentario.id !== id)
|
||||||
|
this.draw().comentarios()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup: function(id) {
|
setup: function(id) {
|
||||||
this.id = id
|
this.id = id
|
||||||
|
this.modals.add = new AddModal({id: '#addComment'})
|
||||||
|
this.modals.edit = new EditModal({id: '#editComment'})
|
||||||
|
$('#add_comentario_button').click(() => {
|
||||||
|
this.modals.add.show()
|
||||||
|
})
|
||||||
this.fetch().comentarios()
|
this.fetch().comentarios()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user