Compare commits
5 Commits
d2511901ec
...
master
Author | SHA1 | Date | |
---|---|---|---|
6ddc48ec60 | |||
331ee1e584 | |||
24c17debf3 | |||
552fd0aa06 | |||
60faf293d4 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,5 +10,3 @@
|
||||
**/.idea/
|
||||
**/upload?/
|
||||
**/informe?/
|
||||
**/.phpunit.cache/
|
||||
**/coverage/
|
||||
|
@ -9,7 +9,6 @@ RUN pecl install xdebug-3.1.3 \
|
||||
&& docker-php-ext-enable xdebug
|
||||
|
||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||
COPY ./php-xdebug.ini /usr/local/etc/php/conf.d/docker-php-xdebug.ini
|
||||
|
||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||
|
||||
|
1
app/.gitignore
vendored
1
app/.gitignore
vendored
@ -1 +0,0 @@
|
||||
**/bin
|
@ -1,13 +0,0 @@
|
||||
watch:
|
||||
directories:
|
||||
- src
|
||||
- tests
|
||||
- common
|
||||
fileMask: '*.php'
|
||||
notifications:
|
||||
passingTests: false
|
||||
failingTests: false
|
||||
hideManual: true
|
||||
phpunit:
|
||||
arguments: '--log-events-text /logs/output.txt --stop-on-failure'
|
||||
timeout: 180
|
@ -5,11 +5,6 @@ use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
interface Banco
|
||||
{
|
||||
/**
|
||||
* Process bank movements for database inserts
|
||||
* @param UploadedFileInterface $file
|
||||
* @return array
|
||||
*/
|
||||
public function process(UploadedFileInterface $file): array;
|
||||
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ use Incoviba\Model;
|
||||
|
||||
interface Exporter
|
||||
{
|
||||
public function export(Model\Inmobiliaria $inmobiliaria, Model\Contabilidad\Banco $banco, DateTimeInterface $mes, array $movimientos): string;
|
||||
public function export(Model\Inmobiliaria $inmobiliaria, Model\Banco $banco, DateTimeInterface $mes, array $movimientos): string;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
||||
{
|
||||
public function process(UploadedFileInterface $file): array
|
||||
{
|
||||
$data = $this->handleFile($file);
|
||||
$data = $this->parseFile($file);
|
||||
$temp = [];
|
||||
$columns = $this->columnMap();
|
||||
foreach ($data as $row) {
|
||||
@ -24,48 +24,11 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* There are banks that need some post-processing
|
||||
* @param array $movimientos
|
||||
* @return array
|
||||
*/
|
||||
public function processMovimientosDiarios(array $movimientos): array
|
||||
{
|
||||
return $movimientos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the UploadedFile into a temp file from getFilename and after parseFile remove temp file
|
||||
* @param UploadedFileInterface $uploadedFile
|
||||
* @return array
|
||||
*/
|
||||
protected function handleFile(UploadedFileInterface $uploadedFile): array
|
||||
{
|
||||
$filename = $this->getFilename($uploadedFile);
|
||||
$uploadedFile->moveTo($filename);
|
||||
$data = $this->parseFile($filename);
|
||||
unlink($filename);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filename where to move UploadedFile
|
||||
* @param UploadedFileInterface $uploadedFile
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getFilename(UploadedFileInterface $uploadedFile): string;
|
||||
|
||||
/**
|
||||
* Mapping of uploaded file data columns to database columns
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function columnMap(): array;
|
||||
|
||||
/**
|
||||
* Translate uploaded file data to database data
|
||||
* @param string $filename
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function parseFile(string $filename): array;
|
||||
abstract protected function parseFile(UploadedFileInterface $uploadedFile): array;
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Exception;
|
||||
|
||||
use Throwable;
|
||||
use HttpResponseException;
|
||||
|
||||
class HttpResponse extends HttpResponseException
|
||||
{
|
||||
public function __construct($message = "", $code = 0, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Log;
|
||||
|
||||
use PDOStatement;
|
||||
use Monolog\Handler\AbstractProcessingHandler;
|
||||
use Monolog\LogRecord;
|
||||
use Monolog\Level;
|
||||
use Incoviba\Common\Define\Connection;
|
||||
|
||||
class MySQLHandler extends AbstractProcessingHandler
|
||||
{
|
||||
private bool $initialized = false;
|
||||
private PDOStatement $statement;
|
||||
|
||||
public function __construct(protected Connection $connection, int|string|Level $level = Level::Debug, bool $bubble = true)
|
||||
{
|
||||
parent::__construct($level, $bubble);
|
||||
}
|
||||
public function write(LogRecord $record): void
|
||||
{
|
||||
if (!$this->initialized) {
|
||||
$this->initialized();
|
||||
}
|
||||
$this->cleanup();
|
||||
$this->statement->execute([
|
||||
'channel' => $record->channel,
|
||||
'level' => $record->level->getName(),
|
||||
'message' => $record->formatted,
|
||||
'time' => $record->datetime->format('Y-m-d H:i:s.u'),
|
||||
'context' => (count($record->context) > 0) ? json_encode($record->context, JSON_UNESCAPED_SLASHES) : '',
|
||||
'extra' => (count($record->extra) > 0) ? json_encode($record->extra, JSON_UNESCAPED_SLASHES) : ''
|
||||
]);
|
||||
}
|
||||
|
||||
private function initialized(): void
|
||||
{
|
||||
$query = <<<QUERY
|
||||
CREATE TABLE IF NOT EXISTS monolog (
|
||||
channel VARCHAR(255),
|
||||
level VARCHAR(100),
|
||||
message LONGTEXT,
|
||||
time DATETIME,
|
||||
context LONGTEXT,
|
||||
extra LONGTEXT
|
||||
)
|
||||
QUERY;
|
||||
$this->connection->getPDO()->exec($query);
|
||||
$query = <<<QUERY
|
||||
INSERT INTO monolog (channel, level, message, time, context, extra)
|
||||
VALUES (:channel, :level, :message, :time, :context, :extra)
|
||||
QUERY;
|
||||
$this->statement = $this->connection->getPDO()->prepare($query);
|
||||
$this->initialized = true;
|
||||
}
|
||||
private function cleanup(): void
|
||||
{
|
||||
$query = "DELETE FROM monolog WHERE time < DATE_SUB(CURDATE(), INTERVAL 90 DAY)";
|
||||
$this->connection->query($query);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Log;
|
||||
|
||||
use Monolog\Formatter\JsonFormatter;
|
||||
use Monolog\LogRecord;
|
||||
|
||||
class PDOFormatter extends JsonFormatter
|
||||
{
|
||||
public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = true)
|
||||
{
|
||||
parent::__construct($batchMode, $appendNewline, $ignoreEmptyContextAndExtra, $includeStacktraces);
|
||||
}
|
||||
|
||||
public function format(LogRecord $record): string
|
||||
{
|
||||
$normalized = $this->normalize($record);
|
||||
return $normalized['message'];
|
||||
}
|
||||
}
|
@ -1,12 +1,8 @@
|
||||
{
|
||||
"name": "incoviba/web",
|
||||
"version": "2.0.0",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"berrnd/slim-blade-view": "^1.0",
|
||||
"ext-gd": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-pdo": "*",
|
||||
"guzzlehttp/guzzle": "^7.8",
|
||||
"monolog/monolog": "^3.4",
|
||||
"nyholm/psr7": "^1.8",
|
||||
@ -18,10 +14,8 @@
|
||||
"slim/slim": "^4.11"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"kint-php/kint": "^5.1",
|
||||
"phpunit/phpunit": "^10.2",
|
||||
"spatie/phpunit-watcher": "^1.23"
|
||||
"phpunit/phpunit": "^10.2"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
@ -36,8 +30,6 @@
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"process-timeout": 0,
|
||||
"bin-dir": "bin"
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
cacheDirectory="/code/cache/tests"
|
||||
executionOrder="depends,defects"
|
||||
requireCoverageMetadata="false"
|
||||
beStrictAboutCoverageMetadata="false"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
colors="true"
|
||||
failOnRisky="false"
|
||||
failOnWarning="false">
|
||||
<testsuites>
|
||||
<testsuite name="unit">
|
||||
<directory>tests/units</directory>
|
||||
</testsuite>
|
||||
<testsuite name="acceptance">
|
||||
<directory>tests/integration</directory>
|
||||
</testsuite>
|
||||
<testsuite name="performance">
|
||||
<directory>tests/performance</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
|
||||
<include>
|
||||
<directory>src</directory>
|
||||
<directory>common</directory>
|
||||
</include>
|
||||
</source>
|
||||
<coverage includeUncoveredFiles="true" pathCoverage="false" ignoreDeprecatedCodeUnits="true" disableCodeCoverageIgnore="true">
|
||||
<report>
|
||||
<html outputDirectory="/code/public/coverage/html" />
|
||||
<php outputFile="/code/public/coverage/coverage.php" />
|
||||
</report>
|
||||
</coverage>
|
||||
<logging>
|
||||
<junit outputFile="/code/cache/tests/junit.xml" />
|
||||
<teamcity outputFile="/code/cache/tests/teamcity.txt" />
|
||||
<testdoxHtml outputFile="/code/cache/tests/testdox.html" />
|
||||
<testdoxText outputFile="/code/cache/tests/testdox.txt" />
|
||||
</logging>
|
||||
</phpunit>
|
@ -1,6 +1,4 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Base;
|
||||
|
||||
$app->group('/api', function($app) {
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'api']);
|
||||
if (file_exists($folder)) {
|
||||
@ -12,5 +10,4 @@ $app->group('/api', function($app) {
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
$app->get('[/]', Base::class);
|
||||
})->add($app->getContainer()->get(Incoviba\Middleware\API::class));
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Incoviba\Controller\API\Contabilidad\CentrosCostos;
|
||||
use Incoviba\Controller\API\CentrosCostos;
|
||||
|
||||
$app->group('/centros_costos', function($app) {
|
||||
$app->post('/add[/]', [CentrosCostos::class, 'add']);
|
||||
|
@ -1,10 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Contabilidad\Movimientos;
|
||||
|
||||
$app->group('/movimientos', function($app) {
|
||||
$app->post('/segment', [Movimientos::class, 'segment']);
|
||||
$app->get('[/]', Movimientos::class);
|
||||
});
|
||||
$app->group('/movimiento/{movimiento_id}', function($app) {
|
||||
$app->post('/detalles', [Movimientos::class, 'detalles']);
|
||||
});
|
||||
|
@ -1,14 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Incoviba\Controller\API\Contabilidad\Nubox;
|
||||
use Incoviba\Controller\API\Nubox;
|
||||
|
||||
$app->group('/nubox/{inmobiliaria_rut}', function($app) {
|
||||
$app->get('/token[/]', [Nubox::class, 'token']);
|
||||
$app->get('/sistemas[/]', [Nubox::class, 'sistemas']);
|
||||
$app->get('/cuentas[/]', [Nubox::class, 'cuentas']);
|
||||
$app->group('/libro', function($app) {
|
||||
$app->post('/mayor[/]', [Nubox::class, 'libroMayor']);
|
||||
$app->post('/diario[/]', [Nubox::class, 'libroDiario']);
|
||||
});
|
||||
$app->post('/cuenta', [Nubox::class, 'cuenta']);
|
||||
});
|
||||
|
@ -2,20 +2,9 @@
|
||||
use Incoviba\Controller\API\Inmobiliarias;
|
||||
|
||||
$app->group('/inmobiliarias', function($app) {
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'inmobiliarias']);
|
||||
if (file_exists($folder)) {
|
||||
$files = new FilesystemIterator($folder);
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
$app->get('[/]', Inmobiliarias::class);
|
||||
});
|
||||
$app->group('/inmobiliaria/{inmobiliaria_rut}', function($app) {
|
||||
$app->post('/agentes', [Inmobiliarias::class, 'agentes']);
|
||||
$app->get('/cuentas[/]', [Inmobiliarias::class, 'cuentas']);
|
||||
$app->get('/proyectos[/]', [Inmobiliarias::class, 'proyectos']);
|
||||
});
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Inmobiliarias\Agentes;
|
||||
|
||||
$app->group('/agentes', function($app) {
|
||||
$app->post('/add[/]', [Agentes::class, 'add']);
|
||||
$app->post('/register[/]', [Agentes::class, 'register']);
|
||||
$app->get('[/]', Agentes::class);
|
||||
});
|
||||
$app->group('/agente/{agente_id}', function($app) {
|
||||
$app->post('/edit[/]', [Agentes::class, 'edit']);
|
||||
});
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Incoviba\Controller\Contabilidad\CentrosCostos;
|
||||
use Incoviba\Controller\CentrosCostos;
|
||||
|
||||
$app->group('/centros_costos', function($app) {
|
||||
$app->get('/asignar[/]', [CentrosCostos::class, 'asignar']);
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Contabilidad\Movimientos;
|
||||
|
||||
$app->get('/movimientos', Movimientos::class);
|
@ -14,10 +14,9 @@
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Inmobiliaria</div>
|
||||
<div class="menu">
|
||||
@foreach ($inmobiliarias as $inmobiliaria)
|
||||
<div class="item"
|
||||
data-value="{{$inmobiliaria->rut}}">{{$inmobiliaria->razon}}</div>
|
||||
@endforeach
|
||||
@foreach ($inmobiliarias as $inmobiliaria)
|
||||
<div class="item" data-value="{{$inmobiliaria->rut}}">{{$inmobiliaria->razon}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -41,7 +40,7 @@
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="file">Cartola</label>
|
||||
<input type="file" name="file" id="file" class="ui invisible file input"/>
|
||||
<input type="file" name="file" id="file" class="ui invisible file input" />
|
||||
<label for="file" class="ui icon button">
|
||||
<i class="file icon"></i>
|
||||
Cargar
|
||||
@ -120,20 +119,20 @@
|
||||
mes: '',
|
||||
movimientos: [],
|
||||
centrosCostos: {
|
||||
ingresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
ingresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return [
|
||||
'id' => $centroCosto->id,
|
||||
'descripcion' => $centroCosto->descripcion
|
||||
];
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return $centroCosto->tipoCentro->descripcion === 'Ingreso';
|
||||
})))) !!}'),
|
||||
egresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
egresos: JSON.parse('{!! json_encode(array_values(array_map(function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return [
|
||||
'id' => $centroCosto->id,
|
||||
'descripcion' => $centroCosto->descripcion
|
||||
];
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\Contabilidad\CentroCosto $centroCosto) {
|
||||
}, array_filter($centrosCostos, function(\Incoviba\Model\CentroCosto $centroCosto) {
|
||||
return $centroCosto->tipoCentro->descripcion === 'Egreso';
|
||||
})))) !!}'),
|
||||
}
|
||||
@ -171,11 +170,7 @@
|
||||
return
|
||||
}
|
||||
$(this.ids.form.banco).dropdown('change values', json.cuentas.map(cuenta => {
|
||||
return {
|
||||
value: cuenta.banco.id,
|
||||
text: cuenta.banco.nombre,
|
||||
name: cuenta.banco.nombre
|
||||
}
|
||||
return {value: cuenta.banco.id, text: cuenta.banco.nombre, name: cuenta.banco.nombre}
|
||||
})).dropdown('refresh')
|
||||
})
|
||||
})
|
||||
@ -252,12 +247,12 @@
|
||||
const movimientos = this.data.movimientos.map((movimiento, idx) => {
|
||||
const temp = structuredClone(movimiento)
|
||||
temp.fecha = movimiento.fecha.toISOString()
|
||||
let centro = $(".centro[data-index='" + (idx + 1) + "']").dropdown('get value')
|
||||
let centro = $(".centro[data-index='" + (idx+1) + "']").dropdown('get value')
|
||||
if (centro.length === 0) {
|
||||
centro = ''
|
||||
}
|
||||
temp.centro_costo = centro
|
||||
let detalle = $("[name='detalle" + (idx + 1) + "']").val()
|
||||
let detalle = $("[name='detalle" + (idx+1) + "']").val()
|
||||
if (typeof detalle === 'undefined') {
|
||||
detalle = ''
|
||||
}
|
||||
@ -299,10 +294,7 @@
|
||||
month: 'numeric',
|
||||
day: 'numeric'
|
||||
})
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0
|
||||
})
|
||||
const numberFormatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0})
|
||||
this.data.movimientos.forEach((row, idx) => {
|
||||
tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
@ -330,7 +322,7 @@
|
||||
})
|
||||
table.DataTable(this.dataTableConfig)
|
||||
},
|
||||
centrosDropdown: (idx, ingreso = true) => {
|
||||
centrosDropdown: (idx, ingreso=true) => {
|
||||
const menu = $('<div></div>').addClass('menu')
|
||||
let centros = this.data.centrosCostos.ingresos
|
||||
if (!ingreso) {
|
||||
|
@ -1,13 +1,5 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@push('page_styles')
|
||||
<style>
|
||||
tr.bold>th {
|
||||
font-weight: bold !important;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui centered header">Informe de Tesorería</h1>
|
||||
@ -27,11 +19,7 @@
|
||||
<table class="ui collapsing simple table">
|
||||
<tr>
|
||||
<td>Informe anterior</td>
|
||||
<td>
|
||||
<a href="{{$urls->base}}/contabilidad/informes/tesoreria/{{$anterior->format('Y-m-d')}}">
|
||||
{{$anterior->format('d/m/Y')}}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{$anterior->format('d/m/Y')}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Informe actual</td>
|
||||
@ -52,17 +40,6 @@
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@if ($siguiente !== null)
|
||||
<div class="five wide column"></div>
|
||||
<div class="right aligned two wide column">
|
||||
<div class="ui segment">
|
||||
Siguiente
|
||||
<a href="{{$urls->base}}/contabilidad/informes/tesoreria/{{$siguiente->format('Y-m-d')}}">
|
||||
{{$siguiente->format('d/m/Y')}} >>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<table class="ui striped table">
|
||||
<thead>
|
||||
|
@ -1,160 +0,0 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">Movimientos Contables</h1>
|
||||
</div>
|
||||
<table id="tabla_movimientos" class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sociedad</th>
|
||||
<th>Banco - Cuenta</th>
|
||||
<th>Fecha</th>
|
||||
<th>ISO Fecha</th>
|
||||
<th class="right aligned">Valor</th>
|
||||
<th>Valor</th>
|
||||
<th>Centro de Costo</th>
|
||||
<th>Glosa</th>
|
||||
<th>Detalle</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="movimientos"></tbody>
|
||||
</table>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.head.styles.datatables.searchbuilder')
|
||||
@include('layout.head.styles.datatables.buttons')
|
||||
|
||||
@include('layout.body.scripts.datatables')
|
||||
@include('layout.body.scripts.datatables.searchbuilder')
|
||||
@include('layout.body.scripts.datatables.buttons')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
function getData(table_id, from, amount) {
|
||||
const url = '{{$urls->api}}/contabilidad/movimientos'
|
||||
const movimientos = []
|
||||
return fetchAPI(url).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
response.json().then(json => {
|
||||
if (json.movimientos.length === 0) {
|
||||
return
|
||||
}
|
||||
const formatter = new Intl.NumberFormat('es-CL')
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {day: '2-digit', month: '2-digit', year: 'numeric'})
|
||||
json.movimientos.forEach(movimiento => {
|
||||
const fecha = new Date(movimiento.fecha)
|
||||
const valor = movimiento.abono - movimiento.cargo
|
||||
movimientos.push([
|
||||
movimiento.cuenta.inmobiliaria.razon,
|
||||
movimiento.cuenta.banco.nombre + ' - ' + movimiento.cuenta.cuenta,
|
||||
dateFormatter.format(fecha),
|
||||
fecha.toISOString(),
|
||||
formatter.format(valor),
|
||||
valor,
|
||||
(movimiento.detalles) ? movimiento.detalles.centro_costo.id + ' - ' + movimiento.detalles.centro_costo.descripcion : '',
|
||||
movimiento.glosa,
|
||||
(movimiento.detalles) ? movimiento.detalles.detalle : ''
|
||||
])
|
||||
})
|
||||
}).then(() => {
|
||||
const table = new DataTable(table_id, {
|
||||
columnDefs: [
|
||||
{targets: 3, visible: false},
|
||||
{targets: 4, className: 'dt-right'},
|
||||
{targets: 5, visible: false}
|
||||
],
|
||||
order: [[3, 'asc']],
|
||||
language: {
|
||||
info: 'Mostrando página _PAGE_ de _PAGES_',
|
||||
infoEmpty: 'No hay cuotas ingresadas',
|
||||
infoFiltered: '(filtrado de _MAX_ cuotas)',
|
||||
lengthMenu: 'Mostrando de a _MENU_ cuotas',
|
||||
zeroRecords: 'No se encotró cuotas con ese criterio',
|
||||
search: 'Buscar: ',
|
||||
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: [0, 1, 2, 4, 6, 7, 8]
|
||||
}
|
||||
},
|
||||
top1End: {
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
className: 'green',
|
||||
text: 'Exportar a Excel <i class="file excel icon"></i>',
|
||||
title: 'Movimientos Contables',
|
||||
download: 'open',
|
||||
exportOptions: {
|
||||
columns: [0, 1, 2, 5, 6, 7, 8]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
data: movimientos,
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
function updateTable(table, from, amount) {
|
||||
const url = '{{$urls->api}}/contabilidad/movimientos'
|
||||
return fetchAPI(url).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
response.json().then(json => {
|
||||
if (json.movimientos.length === 0) {
|
||||
return
|
||||
}
|
||||
table.clear()
|
||||
const formatter = new Intl.NumberFormat('es-CL')
|
||||
const dateFormatter = new Intl.DateTimeFormat('es-CL', {day: '2-digit', month: '2-digit', year: 'numeric'})
|
||||
json.movimientos.forEach(movimiento => {
|
||||
const fecha = new Date(movimiento.fecha)
|
||||
table.row.add([
|
||||
movimiento.cuenta.inmobiliaria.razon,
|
||||
movimiento.cuenta.banco.nombre + ' - ' + movimiento.cuenta.cuenta,
|
||||
dateFormatter.format(fecha),
|
||||
fecha.toISOString(),
|
||||
formatter.format(movimiento.abono - movimiento.cargo),
|
||||
(movimiento.detalles) ? movimiento.detalles.centro_costo.id + ' - ' + movimiento.detalles.centro_costo.descripcion : '',
|
||||
movimiento.glosa,
|
||||
(movimiento.detalles) ? movimiento.detalles.detalle : ''
|
||||
])
|
||||
})
|
||||
}).then(() => {
|
||||
table.draw()
|
||||
})
|
||||
})
|
||||
}
|
||||
$(document).ready(() => {
|
||||
getData('#tabla_movimientos', 0, 100)
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -10,6 +10,11 @@
|
||||
<div class="column">
|
||||
Inmobiliarias
|
||||
</div>
|
||||
{{--<div class="right aligned column">
|
||||
<button class="ui icon button" type="button">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</div>--}}
|
||||
</h2>
|
||||
<div class="ui divider"></div>
|
||||
<div class="ui cards">
|
||||
@ -17,7 +22,9 @@
|
||||
<div class="ui card">
|
||||
<div class="content">
|
||||
<div class="header">
|
||||
{{$inmobiliaria->abreviacion}}
|
||||
{{$inmobiliaria->abreviacion}}
|
||||
{{--<a href="{{$urls->base}}/inmobiliaria/{{$inmobiliaria->rut}}">
|
||||
</a>--}}
|
||||
</div>
|
||||
<div class="description">{{$inmobiliaria->razon}} {{$inmobiliaria->tipoSociedad->descripcion}}</div>
|
||||
<div class="meta">{{$inmobiliaria->rut()}}</div>
|
||||
|
@ -18,6 +18,5 @@
|
||||
</div>
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/cartolas/diaria">Cartola Diaria</a>
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/depositos">Depósitos a Plazo</a>
|
||||
<a class="item" href="{{$urls->base}}/contabilidad/movimientos">Movimientos</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -33,7 +33,6 @@
|
||||
</div>--}}
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/precios/importar">Importar Precios</a>--}}
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/cierres/evaluar">Evaluar Cierre</a>--}}
|
||||
<a class="item" href="{{$urls->base}}/ventas/facturacion">Facturación</a>
|
||||
<a class="item" href="{{$urls->base}}/ventas/add">
|
||||
Nueva Venta
|
||||
<i class="plus icon"></i>
|
||||
|
@ -10,7 +10,7 @@
|
||||
options['headers'] = {}
|
||||
}
|
||||
if (!Object.hasOwn(options['headers'], 'Authorization')) {
|
||||
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}{{($login->isIn()) ? $login->getSeparator() . $login->getToken() : ''}}'
|
||||
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}'
|
||||
}
|
||||
return fetch(url, options).then(response => {
|
||||
if (response.ok) {
|
||||
|
@ -1,3 +0,0 @@
|
||||
@push('page_scripts')
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js" integrity="sha512-a+SUDuwNzXDvz4XrIcXHuCf089/iJAoN4lmrXJg18XnduKK6YlDHNRalv4yd1N40OKI80tFidF+rqTFKGPoWFQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
@endpush
|
@ -1,4 +1,5 @@
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/2.0.3/js/dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/2.0.3/js/dataTables.semanticui.min.js"></script>
|
||||
{{--<script type="text/javascript" src="https://cdn.datatables.net/2.0.1/js/jquery.dataTables.min.js"></script>--}}
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/2.0.1/js/dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/2.0.1/js/dataTables.semanticui.min.js"></script>
|
||||
@endpush
|
||||
|
@ -1,9 +1,9 @@
|
||||
@push('page_scripts')
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.9/pdfmake.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.1/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.semanticui.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.colVis.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.1/js/buttons.print.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.semanticui.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.colVis.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/3.0.0/js/buttons.print.min.js"></script>
|
||||
@endpush
|
||||
|
@ -1,5 +0,0 @@
|
||||
@push('page_scripts')
|
||||
<script src="https://cdn.datatables.net/datetime/1.5.2/js/dataTables.dateTime.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/searchbuilder/1.7.0/js/dataTables.searchBuilder.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/searchbuilder/1.7.0/js/searchBuilder.semanticui.js"></script>
|
||||
@endpush
|
@ -1,3 +1,3 @@
|
||||
@push('page_styles')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.3/css/dataTables.semanticui.min.css" />
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.1/css/dataTables.semanticui.min.css" />
|
||||
@endpush
|
||||
|
@ -1,4 +0,0 @@
|
||||
@push('page_styles')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/datetime/1.5.2/css/dataTables.dateTime.min.css" />
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/searchbuilder/1.7.0/css/searchBuilder.dataTables.min.css" />
|
||||
@endpush
|
@ -16,30 +16,29 @@
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.body.scripts.cryptojs')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
function encryptPassword(password) {
|
||||
const passphrase = Math.floor(Math.random() * Date.now()).toString()
|
||||
const encrypted = CryptoJS.AES.encrypt(password, passphrase)
|
||||
return [passphrase, encrypted.toString()].join('')
|
||||
}
|
||||
function sendLogin(name, password) {
|
||||
const method = 'post'
|
||||
const headers = {
|
||||
Accept: 'json'
|
||||
}
|
||||
const body = new FormData()
|
||||
body.append('name', name)
|
||||
body.append('password', encryptPassword(password))
|
||||
return fetch('{{$urls->base}}/login', {method, headers, body}).then(response => {
|
||||
const data = new FormData()
|
||||
data.append('name', name)
|
||||
data.append('password', password)
|
||||
return fetch('{{$urls->base}}/login', {
|
||||
method: 'post',
|
||||
headers: {
|
||||
Accept: 'json'
|
||||
},
|
||||
body: data
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.login === true) {
|
||||
window.location = '{{(isset($redirect_uri)) ? $redirect_uri : $urls->base}}'
|
||||
@if(isset($redirect_uri))
|
||||
window.location = '{{$redirect_uri}}'
|
||||
@else
|
||||
window.location = '{{$urls->base}}'
|
||||
@endif
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
<div id="data"></div>
|
||||
<table class="ui table" id="data"></table>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@ -177,7 +177,7 @@
|
||||
const cantidad = this.unidades.length
|
||||
this.unidades.forEach(unidad => {
|
||||
const values = [
|
||||
'<a href="{{$urls->base}}/ventas/factura/' + this.id + '">' + venta + '</a>',
|
||||
venta,
|
||||
cantidad,
|
||||
unidad.tipo,
|
||||
unidad.descripcion,
|
||||
@ -226,104 +226,49 @@
|
||||
ids: {},
|
||||
selected: 0,
|
||||
data: JSON.parse('{!! json_encode($proyectos) !!}'),
|
||||
sent: false,
|
||||
ufs: {},
|
||||
ipcs: {},
|
||||
table: null,
|
||||
get: function() {
|
||||
return {
|
||||
ventas: () => {
|
||||
if (this.sent) {
|
||||
return
|
||||
}
|
||||
this.sent = true
|
||||
const url = '{{$urls->api}}/ventas/facturacion/proyecto/' + this.selected
|
||||
this.draw().loading()
|
||||
return fetchAPI(url).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
return response.json()
|
||||
}).then(json => {
|
||||
const idx = this.data.findIndex(proyecto => proyecto.id === json.proyecto_id)
|
||||
const fecha_terreno = (typeof this.data[idx].terreno.date === 'undefined') ? new Date() : new Date(this.data[idx].terreno.date)
|
||||
const fecha_terreno = new Date(this.data[idx].terreno.date)
|
||||
this.data[idx]['ventas'] = []
|
||||
const ventas = []
|
||||
const unidadesQueue = []
|
||||
const ufQueue = {}
|
||||
const ipcQueue = {}
|
||||
const chunkSize = 100
|
||||
const url = '{{$urls->api}}/ventas/get'
|
||||
for (let i = 0; i < json.ventas.length; i += chunkSize) {
|
||||
const chunk = json.ventas.slice(i, i + chunkSize).map(venta => venta.id)
|
||||
const body = new FormData()
|
||||
body.set('ventas', chunk)
|
||||
const promise = fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return response
|
||||
}
|
||||
return response.json().then(json => {
|
||||
json.ventas.forEach(venta => {
|
||||
const data = {
|
||||
id: venta.id,
|
||||
precio: venta.valor,
|
||||
fecha: new Date(venta.fecha),
|
||||
escritura: new Date(venta.fecha)
|
||||
}
|
||||
if (['escriturando'].includes(venta.current_estado.tipo_estado_venta.descripcion)) {
|
||||
data.escritura = new Date(venta.current_estado.fecha)
|
||||
}
|
||||
const v = new Venta(data)
|
||||
if (v.escritura !== null) {
|
||||
const dateString = v.escritura.toString()
|
||||
if (!Object.hasOwn(ufQueue, dateString)) {
|
||||
ufQueue[dateString] = []
|
||||
}
|
||||
ufQueue[dateString].push(v.id)
|
||||
if (!Object.hasOwn(ipcQueue, dateString)) {
|
||||
ipcQueue[dateString] = []
|
||||
}
|
||||
ipcQueue[dateString].push(v.id)
|
||||
}
|
||||
unidadesQueue.push(v.id)
|
||||
this.data[idx].ventas.push(v)
|
||||
|
||||
})
|
||||
});
|
||||
json.ventas.forEach(venta => {
|
||||
const data = {
|
||||
id: venta.id,
|
||||
precio: venta.valor,
|
||||
fecha: new Date(venta.fecha),
|
||||
escritura: null
|
||||
}
|
||||
if (['escriturando'].includes(venta.current_estado.tipo_estado_venta.descripcion)) {
|
||||
data.escritura = new Date(venta.current_estado.fecha)
|
||||
}
|
||||
const v = new Venta(data)
|
||||
const promises = []
|
||||
if (v.escritura !== null) {
|
||||
promises.push(money.get().uf(v.escritura).then(uf => {
|
||||
v.uf = uf
|
||||
}))
|
||||
promises.push(money.get().ipc(v.escritura, fecha_terreno).then(ipc => {
|
||||
v.ipc = ipc
|
||||
}))
|
||||
}
|
||||
promises.push(v.get().unidades())
|
||||
const promise = Promise.all(promises).then(() => {
|
||||
this.data[idx].ventas.push(v)
|
||||
})
|
||||
ventas.push(promise)
|
||||
}
|
||||
})
|
||||
Promise.all(ventas).then(() => {
|
||||
const promises = []
|
||||
Object.entries(ufQueue).forEach(([dateString, ventas]) => {
|
||||
const date = new Date(dateString)
|
||||
promises.push(money.get().uf(date).then(uf => {
|
||||
ventas.forEach(id => {
|
||||
const vidx = this.data[idx].ventas.findIndex(venta => venta.id === id)
|
||||
this.data[idx].ventas[vidx].uf = uf
|
||||
})
|
||||
}))
|
||||
})
|
||||
Object.entries(ipcQueue).forEach(([dateString, ventas]) => {
|
||||
const date = new Date(dateString)
|
||||
promises.push(money.get().ipc(date, fecha_terreno).then(ipc => {
|
||||
ventas.forEach(id => {
|
||||
const vidx = this.data[idx].ventas.findIndex(venta => venta.id === id)
|
||||
this.data[idx].ventas[vidx].ipc = ipc
|
||||
})
|
||||
}))
|
||||
})
|
||||
for (let i = 0; i < unidadesQueue.length; i += chunkSize) {
|
||||
const chunk = unidadesQueue.slice(i, i + chunkSize)
|
||||
chunk.forEach(id => {
|
||||
const vidx = this.data[idx].ventas.findIndex(venta => venta.id === id)
|
||||
promises.push(this.data[idx].ventas[vidx].get().unidades())
|
||||
})
|
||||
}
|
||||
Promise.all(promises).then(() => {
|
||||
this.draw().ventas(idx)
|
||||
this.sent = false
|
||||
})
|
||||
this.data[idx].ventas.sort((a, b) => parseInt(a.principal.descripcion) - parseInt(b.principal.descripcion))
|
||||
this.draw().ventas(idx)
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -332,37 +277,23 @@
|
||||
draw: function() {
|
||||
return {
|
||||
proyectos: () => {
|
||||
$(this.ids.title).html('Proyectos')
|
||||
if (this.table !== null) {
|
||||
this.table.clear()
|
||||
this.table.destroy()
|
||||
$(this.ids.data).html('')
|
||||
}
|
||||
$(this.ids.data).hide()
|
||||
$(this.ids.proyectos).find('.item').css('cursor', 'pointer')
|
||||
$(this.ids.proyectos).show()
|
||||
},
|
||||
ventas: proyecto_idx => {
|
||||
$(this.ids.title).html(this.data[proyecto_idx].descripcion)
|
||||
const parent = $(this.ids.data)
|
||||
const table = $(this.ids.data)
|
||||
if (this.table !== null) {
|
||||
this.table.clear()
|
||||
this.table.destroy()
|
||||
this.table = null
|
||||
parent.html('')
|
||||
this.table.clear().destroy()
|
||||
}
|
||||
const table = $('<table></table>').addClass('ui table')
|
||||
table.append(this.draw().thead())
|
||||
table.append(this.draw().tbody(proyecto_idx))
|
||||
parent.show()
|
||||
parent.html(table)
|
||||
table.show()
|
||||
$(this.ids.proyectos).hide()
|
||||
if (this.table === null) {
|
||||
this.table = table.DataTable({
|
||||
orders: [
|
||||
[0, 'asc']
|
||||
]
|
||||
})
|
||||
this.table = table.DataTable()
|
||||
}
|
||||
},
|
||||
thead: () => {
|
||||
@ -400,9 +331,6 @@
|
||||
venta.draw({tbody, valor_terreno: this.data[proyecto_idx].terreno.valor})
|
||||
})
|
||||
return tbody
|
||||
},
|
||||
loading: () => {
|
||||
$(this.ids.proyectos).find('.item').css('cursor', 'wait')
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -441,7 +369,6 @@
|
||||
}
|
||||
$(document).ready(() => {
|
||||
proyectos.setup({ids: {
|
||||
title: '#list_title',
|
||||
proyectos: '#proyectos',
|
||||
data: '#data',
|
||||
buttons: {
|
||||
|
@ -13,18 +13,23 @@
|
||||
{{$venta->propiedad()->summary()}}
|
||||
</a>
|
||||
</h2>
|
||||
<div class="ui grid">
|
||||
<div class="three wide column">
|
||||
<div class="ui very segment">
|
||||
Valor Venta: {{$format->ufs($venta->valor)}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui very basic segment">
|
||||
Valor Venta: {{$format->ufs($venta->valor)}}
|
||||
</div>
|
||||
<form id="venta_form" class="ui form">
|
||||
<div class="two wide field">
|
||||
<label for="proporcion">Proporción Factura</label>
|
||||
<div class="ui right labeled input">
|
||||
<input type="number" name="proporcion" id="proporcion" value="100" max="100" min="0"/>
|
||||
<div class="ui basic icon label">
|
||||
<i class="percent icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
@foreach ($venta->propiedad()->unidades as $unidad)
|
||||
<div class="three wide field">
|
||||
<label for="precio{{$unidad->pu_id}}">Precio<br /> {{ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}} {{$unidad->descripcion}}</label>
|
||||
<label for="precio{{$unidad->pu_id}}">Precio {{ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}} {{$unidad->descripcion}}</label>
|
||||
<div class="ui right labeled input" id="input{{$unidad->pu_id}}">
|
||||
<input class="price" type="text" name="precio{{$unidad->pu_id}}" id="precio{{$unidad->pu_id}}" data-id="{{$unidad->pu_id}}" value="{{($unidad->valor > 0) ? $unidad->valor : $unidad->precio($venta->currentEstado()->fecha)->valor}}" />
|
||||
<div class="ui basic label">UF</div>
|
||||
@ -36,7 +41,7 @@
|
||||
@foreach($venta->propiedad()->unidades as $unidad)
|
||||
<div class="three wide field">
|
||||
@if ($unidad->prorrateo === 0.0)
|
||||
<label for="prorrateo{{$unidad->id}}">Prorrateo<br /> {{ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}} {{$unidad->descripcion}}</label>
|
||||
<label for="prorrateo{{$unidad->id}}">Prorrateo {{ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}} {{$unidad->descripcion}}</label>
|
||||
<div class="ui right labeled input" id="prorrateo{{$unidad->id}}">
|
||||
<input class="prorrateo" type="text" data-id="{{$unidad->id}}" value="{{$unidad->prorrateo}}" />
|
||||
<div class="ui basic label">%</div>
|
||||
@ -46,8 +51,8 @@
|
||||
@endforeach
|
||||
</div>
|
||||
<div class="ui very basic segment" id="total_unidades"></div>
|
||||
@php $lastDic = new DateTimeImmutable((new DateTimeImmutable())->sub(new DateInterval('P1Y'))->format('Y-12-31')); @endphp
|
||||
@if (!isset($terreno->fecha) or $terreno->fecha->getTimestamp() < 0 or $terreno->fecha < $lastDic)
|
||||
@php $lastDic = new DateTimeImmutable((new DateTimeImmutable())->sub(new DateInterval('P1Y'))->format('31-12-Y')); @endphp
|
||||
@if (!isset($venta->proyecto()->terreno->fecha) or $venta->proyecto()->terreno->fecha < $lastDic)
|
||||
<div class="four wide field">
|
||||
<label for="terreno">Valor Terreno al {{$lastDic->format('d-m-Y')}}</label>
|
||||
<div class="ui left labeled input">
|
||||
@ -56,49 +61,9 @@
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="two wide field">
|
||||
<label for="propietarios">Propietarios</label>
|
||||
<input type="number" name="cantidad_propietarios" id="cantidad_propietarios" min="1" value="1" />
|
||||
</div>
|
||||
<div id="propietarios">
|
||||
<div class="fields" data-index="1">
|
||||
<div class="two wide field">
|
||||
<label for="proporcion1">Proporción Factura</label>
|
||||
<div class="ui right labeled input">
|
||||
<input type="number" name="proporcion1" id="proporcion1" value="100" max="100" min="0"/>
|
||||
<div class="ui basic icon label">
|
||||
<i class="percent icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three wide field">
|
||||
<label for="rut1">RUT</label>
|
||||
<div class="ui input">
|
||||
<input type="text" name="rut1" id="rut1" value="{{$venta->propietario()->rut()}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="five wide field">
|
||||
<label for="propietario1">Propietario</label>
|
||||
<div class="ui input">
|
||||
<input type="text" name="propietario1" id="propietario1" value="{{$venta->propietario()->nombreCompleto()}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="six wide field">
|
||||
<label for="direccion_propietario1">Dirección</label>
|
||||
<div class="ui input">
|
||||
<input type="text" name="direccion_propietario1" id="direccion_propietario1" value="{{$venta->propietario()->datos->direccion->simple()}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="two wide field">
|
||||
<label for="comuna_propietario1">Comuna</label>
|
||||
<input type="text" name="comuna_propietario1" id="comuna_propietario1" value="{{$venta->propietario()->datos->direccion->comuna->descripcion}}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="propietarios" class="fields"></div>
|
||||
</form>
|
||||
@if ($venta->currentEstado()->fecha->sub(new DateInterval('P1M')) > $terreno?->fecha
|
||||
and ($terreno?->valor ?? 0) === 0.0)
|
||||
@if ($venta->currentEstado()->fecha->sub(new DateInterval('P1M')) > $venta->proyecto()->terreno->fecha
|
||||
and $IPC->get($venta->proyecto()->terreno->fecha, $venta->currentEstado()->fecha->sub(new DateInterval('P1M'))) === 0.0)
|
||||
<div class="ui compact icon error message">
|
||||
<i class="exclamation triangle icon"></i>
|
||||
<div class="content">
|
||||
@ -106,8 +71,8 @@
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div id="facturas"></div>
|
||||
{{--<div id="factura">
|
||||
<div class="ui divider"></div>
|
||||
<div id="factura">
|
||||
<div class="ui compact grid">
|
||||
<div class="two columns row">
|
||||
<div class="twelve wide column">
|
||||
@ -209,212 +174,18 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>--}}
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
class Factura
|
||||
{
|
||||
props
|
||||
|
||||
constructor(props) {
|
||||
this.props = props
|
||||
}
|
||||
|
||||
draw({parentDiv, inmobiliaria, proyecto, propietario, unidades, venta, estadoVenta, uf, formatters = {date, pesos, ufs, percent}}) {
|
||||
const output = [
|
||||
'<div class="ui divider"></div>'+
|
||||
'<div class="factura">'+
|
||||
'<div class="ui compact grid">'+
|
||||
'<div class="two columns row">'+
|
||||
'<div class="twelve wide column">'+
|
||||
'<strong>'+inmobiliaria.nombre+'</strong><br/>'+
|
||||
'GIRO: <br/>'+
|
||||
'Dirección:'+proyecto.direccion+
|
||||
'</div>'+
|
||||
'<div class="four wide column">'+
|
||||
'<div class="ui center aligned red segment">'+
|
||||
'<strong>'+
|
||||
'RUT:'+inmobiliaria.rut+'<br/>'+
|
||||
'FACTURA ELECTRÓNICA<br/>'+
|
||||
'N° #'+
|
||||
'</strong>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="row">'+
|
||||
'<table class="ui table">'+
|
||||
'<tr>'+
|
||||
'<td class="grey"><strong>Señor(es)</strong></td>'+
|
||||
'<td>'+propietario.nombre+'</td>'+
|
||||
'<td class="grey"><strong>RUT</strong></td>'+
|
||||
'<td>'+propietario.rut+'</td>'+
|
||||
'</tr>'+
|
||||
'<tr>'+
|
||||
'<td class="grey"><strong>Giro</strong></td>'+
|
||||
'<td>Otras Actividades Profesionales</td>'+
|
||||
'<td class="grey"><strong>Fecha Emisión</strong></td>'+
|
||||
'<td>'+formatters.date.format(estadoVenta.fecha)+'</td>'+
|
||||
'</tr>'+
|
||||
'<tr>'+
|
||||
'<td class="grey"><strong>Dirección</strong></td>'+
|
||||
'<td>'+propietario.direccion+'</td>'+
|
||||
'<td class="grey"><strong>Comuna</strong></td>'+
|
||||
'<td>'+propietario.comuna.toUpperCase()+'</td>'+
|
||||
'</tr>'+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'<div class="row">'+
|
||||
'<table class="ui celled table">'+
|
||||
'<thead>'+
|
||||
'<tr class="grey">'+
|
||||
'<th class="center aligned" colspan="6">DETALLES</th>'+
|
||||
'</tr>'+
|
||||
'<tr class="grey">'+
|
||||
'<th>N°</th>'+
|
||||
'<th class="center aligned">Descripción</th>'+
|
||||
'<th class="center aligned">Cant/Unidad</th>'+
|
||||
'<th class="center aligned">Prec. Unit.</th>'+
|
||||
'<th class="center aligned">Ind</th>'+
|
||||
'<th class="center aligned">Total</th>'+
|
||||
'</tr>'+
|
||||
'</thead>'
|
||||
]
|
||||
const unidadesData = []
|
||||
|
||||
let c = 1
|
||||
const classes = [
|
||||
'',
|
||||
'',
|
||||
'center aligned',
|
||||
'right aligned',
|
||||
'center aligned',
|
||||
'right aligned'
|
||||
]
|
||||
unidades.forEach(unidad => {
|
||||
const descuento = parseFloat(proyecto.terreno) * parseFloat(unidad.prorrateo)
|
||||
const bruto = parseFloat(unidad.base) - descuento
|
||||
const neto = bruto / 1.19
|
||||
const data = [
|
||||
c ++,
|
||||
unidad.descripcion + ' (UF ' + formatters.ufs.format(unidad.precio * this.props.proporcion) + ')',
|
||||
'1 UNID',
|
||||
formatters.pesos.format(neto * this.props.proporcion),
|
||||
'AF',
|
||||
formatters.pesos.format(neto * this.props.proporcion)
|
||||
]
|
||||
|
||||
const row = ['<tr>']
|
||||
data.forEach((value, i) => {
|
||||
const cell = ['<td']
|
||||
if (classes[i] !== '') {
|
||||
cell.push(' class="'+classes[i]+'"')
|
||||
}
|
||||
cell.push('>'+value+'</td>')
|
||||
row.push(cell.join(''))
|
||||
})
|
||||
row.push('</tr>')
|
||||
unidadesData.push(row.join(''))
|
||||
})
|
||||
|
||||
const emptyTerreno = '<div class="ui tiny red horizontal circular label">0</div>'
|
||||
const data = [
|
||||
c,
|
||||
'Valor con Terreno ' + formatters.pesos.format((venta.base + venta.terreno) * this.props.proporcion) + ' - Menos valor terreno ' + ((venta.terreno > 0) ? formatters.pesos.format(-venta.terreno * this.props.proporcion) : emptyTerreno) + '<br />' +
|
||||
'Base imponible ' + formatters.pesos.format(venta.base * this.props.proporcion) + '<br />' +
|
||||
'IVA ' + formatters.pesos.format(venta.iva * this.props.proporcion) + '<br />' +
|
||||
'SUBTOTAL ' + formatters.pesos.format(venta.subtotal * this.props.proporcion) + '<br />' +
|
||||
'Mas valor terreno ' + ((venta.terreno > 0) ? formatters.pesos.format(venta.terreno * this.props.proporcion) : emptyTerreno) + '<br />' +
|
||||
'TOTAL ' + formatters.pesos.format(venta.total * this.props.proporcion) + ';' + formatters.ufs.format(venta.totalUF * this.props.proporcion) + ' UF<br /><br />' +
|
||||
'Descuento Terreno: ' + ((venta.terreno > 0) ? formatters.percent.format(venta.prorrateo * 100) : emptyTerreno) + '%<br /><br />' +
|
||||
'UF: ' + formatters.ufs.format(uf),
|
||||
'1 UNID',
|
||||
formatters.pesos.format(venta.terreno * this.props.proporcion),
|
||||
'EX',
|
||||
formatters.pesos.format(venta.terreno * this.props.proporcion)
|
||||
]
|
||||
|
||||
const row = ['<tr class="top aligned">']
|
||||
data.forEach((value, i) => {
|
||||
const cell = ['<td']
|
||||
if (classes[i] !== '') {
|
||||
cell.push(' class="'+classes[i]+'"')
|
||||
}
|
||||
cell.push('>'+value+'</td>')
|
||||
row.push(cell.join(''))
|
||||
})
|
||||
unidadesData.push(row.join(''))
|
||||
|
||||
output.push('<tbody id="unidades">'+unidadesData.join('')+'</tbody>')
|
||||
output.push(
|
||||
'<tfoot>'+
|
||||
'<tr>'+
|
||||
'<td colspan="6">'+
|
||||
'<br />'+
|
||||
'<br />'+
|
||||
'<br />'+
|
||||
'<br />'+
|
||||
'</td>'+
|
||||
'</tr>'+
|
||||
'</tfoot>'+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'<div class="row">'+
|
||||
'<div class="ten wide column"></div>'+
|
||||
'<div class="six wide column">'+
|
||||
'<table class="ui celled very compact table">'+
|
||||
'<thead>'+
|
||||
'<tr>'+
|
||||
'<th class="center aligned grey" colspan="2">TOTALES</th>'+
|
||||
'</tr>'+
|
||||
'</thead>'+
|
||||
'<tbody>'+
|
||||
'<tr>'+
|
||||
'<td class="grey">Monto Neto</td>'+
|
||||
'<td class="right aligned" id="neto">'+formatters.pesos.format(venta.base * this.props.proporcion)+'</td>'+
|
||||
'</tr>'+
|
||||
'<tr>'+
|
||||
'<td class="grey">Monto Exento</td>'+
|
||||
'<td class="right aligned" id="exento">'+formatters.pesos.format(venta.terreno * this.props.proporcion)+'</td>'+
|
||||
'</tr>'+
|
||||
'<tr>'+
|
||||
'<td class="grey">19% IVA</td>'+
|
||||
'<td class="right aligned" id="iva">'+formatters.pesos.format(venta.iva * this.props.proporcion)+'</td>'+
|
||||
'</tr>'+
|
||||
'<tr>'+
|
||||
'<td class="grey">Monto Total</td>'+
|
||||
'<td class="right aligned"><strong id="total">'+formatters.pesos.format(venta.total * this.props.proporcion)+'</strong></td>'+
|
||||
'</tr>'+
|
||||
'</tbody>'+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</div>'
|
||||
)
|
||||
parentDiv.append(output.join(''))
|
||||
}
|
||||
}
|
||||
const facturasForm = {
|
||||
props: {
|
||||
ids: {
|
||||
facturas: '',
|
||||
propietarios: ''
|
||||
}
|
||||
},
|
||||
inmobiliaria: {
|
||||
rut: '{{$venta->proyecto()->inmobiliaria()->rut()}}',
|
||||
nombre: '{{mb_strtoupper($venta->proyecto()->inmobiliaria()->nombreCompleto())}}'
|
||||
},
|
||||
proyecto: {
|
||||
direccion: '{{$venta->proyecto()->direccion()->simple()}}',
|
||||
terreno: {{$terreno?->valor ?? 0}}
|
||||
},
|
||||
estadoVenta: {
|
||||
fecha: new Date('{{$venta->currentEstado()->fecha->format('Y-m-d')}}')
|
||||
},
|
||||
const factura = {
|
||||
id: '#unidades',
|
||||
totales: {},
|
||||
proporcion: 1,
|
||||
precio: {{$UF->transform($venta->currentEstado()->fecha, $venta->valor)}},
|
||||
terreno: {{(isset($venta->proyecto()->terreno->fecha) and $venta->proyecto()->terreno->fecha >= $lastDic) ?
|
||||
$IPC->readjust($venta->proyecto()->terreno->valor, $venta->proyecto()->terreno->fecha, $venta->currentEstado()->fecha) : 0}},
|
||||
uf: {{$UF->get($venta->currentEstado()->fecha)}},
|
||||
unidades: JSON.parse('{!! json_encode(array_map(function(Incoviba\Model\Venta\PropiedadUnidad $unidad) use ($venta, $UF, $format) {
|
||||
$precio = ($unidad->valor > 0) ? $unidad->valor : ($unidad->precio($venta->currentEstado()->fecha) ? $unidad->precio($venta->currentEstado()->fecha)->valor : 0);
|
||||
@ -427,84 +198,98 @@
|
||||
'prorrateo' => $unidad->prorrateo,
|
||||
];
|
||||
}, $venta->propiedad()->unidades)) !!}'),
|
||||
venta: {
|
||||
base: 0,
|
||||
precio: 0,
|
||||
descuento: 0,
|
||||
prorrateo: 0,
|
||||
bruto: 0,
|
||||
iva: 0,
|
||||
neto: 0,
|
||||
subtotal: 0,
|
||||
total: 0,
|
||||
totalUF: 0
|
||||
},
|
||||
propietarios: [
|
||||
{
|
||||
rut: '{{$venta->propietario()->rut()}}',
|
||||
nombre: '{{$venta->propietario()->nombreCompleto()}}',
|
||||
direccion: '{{$venta->propietario()->datos->direccion->simple()}}',
|
||||
comuna: '{{$venta->propietario()->datos->direccion->comuna->descripcion}}'
|
||||
build: function() {
|
||||
const tbody = $(this.id)
|
||||
tbody.html('')
|
||||
const pesoFormatter = new Intl.NumberFormat('es-CL', {maximumFractionDigits: 0, minimumFractionDigits: 0})
|
||||
const ufFormatter = new Intl.NumberFormat('es-CL', {maximumFractionDigits: 2, minimumFractionDigits: 2})
|
||||
const percentFormatter = new Intl.NumberFormat('es-CL', {maximumFractionDigits: 5, minimumFractionDigits: 5})
|
||||
let terreno = 0
|
||||
let prorrateo = 0
|
||||
let totalUnidades = 0
|
||||
let precioUnidades = 0
|
||||
let c = 1
|
||||
const classes = [
|
||||
'',
|
||||
'',
|
||||
'center aligned',
|
||||
'right aligned',
|
||||
'center aligned',
|
||||
'right aligned'
|
||||
]
|
||||
this.unidades.forEach(unidad => {
|
||||
totalUnidades += unidad.base
|
||||
precioUnidades += unidad.precio
|
||||
const descuento = this.terreno * unidad.prorrateo
|
||||
terreno += descuento
|
||||
prorrateo += unidad.prorrateo
|
||||
const bruto = unidad.base - descuento
|
||||
const neto = bruto / 1.19
|
||||
const data = [
|
||||
c ++,
|
||||
unidad.descripcion + ' (UF ' + ufFormatter.format(unidad.precio * this.proporcion) + ')',
|
||||
'1 UNID',
|
||||
pesoFormatter.format(neto * this.proporcion),
|
||||
'AF',
|
||||
pesoFormatter.format(neto * this.proporcion)
|
||||
]
|
||||
|
||||
const row = $('<tr></tr')
|
||||
data.forEach((value, i) => {
|
||||
const cell = $('<td></td>')
|
||||
if (classes[i] !== '') {
|
||||
cell.addClass(classes[i])
|
||||
}
|
||||
cell.html(value)
|
||||
row.append(cell)
|
||||
})
|
||||
tbody.append(row)
|
||||
})
|
||||
$('#total_unidades')
|
||||
.attr('class', 'ui compact segment ' + ((totalUnidades.toFixed(2) !== this.precio.toFixed(2)) ? 'inverted red' : 'inverted green'))
|
||||
.html('Total Unidades: ' + ufFormatter.format(precioUnidades) + ' UF' +
|
||||
((totalUnidades.toFixed(2) !== this.precio.toFixed(2)) ? '; Diferencia: ' + ufFormatter.format({{$venta->valor}} - precioUnidades) + ' UF' : ''))
|
||||
if (totalUnidades.toFixed(2) !== this.precio.toFixed(2)) {
|
||||
this.highlight()
|
||||
}
|
||||
],
|
||||
facturas: [],
|
||||
draw() {
|
||||
return {
|
||||
propietarios: () => {
|
||||
const proporcion = (100 / this.propietarios.length).toFixed()
|
||||
const parent = $(this.props.ids.propietarios)
|
||||
parent.html('')
|
||||
this.propietarios.forEach((propietario, idx) => {
|
||||
parent.append(
|
||||
'<div class="fields" data-index="'+(idx+1)+'">' +
|
||||
'<div class="two wide field">'+
|
||||
'<label for="proporcion'+(idx+1)+'">Proporción Factura</label>'+
|
||||
'<div class="ui right labeled input">'+
|
||||
'<input type="number" class="proporcion" name="proporcion'+(idx+1)+'" id="proporcion'+(idx+1)+'" value="'+proporcion+'" max="100" min="0"/>'+
|
||||
'<div class="ui basic icon label">'+
|
||||
'<i class="percent icon"></i>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="three wide field">'+
|
||||
'<label for="rut'+(idx+1)+'">RUT</label>'+
|
||||
'<div class="ui input">'+
|
||||
'<input type="text" name="rut'+(idx+1)+'" id="rut'+(idx+1)+'" value="'+propietario.rut+'" />'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="five wide field">'+
|
||||
'<label for="propietario'+(idx+1)+'">Propietario</label>'+
|
||||
'<div class="ui input">'+
|
||||
'<input type="text" name="propietario'+(idx+1)+'" id="propietario'+(idx+1)+'" value="'+propietario.nombre+'" />'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="six wide field">'+
|
||||
'<label for="direccion_propietario'+(idx+1)+'">Dirección</label>'+
|
||||
'<div class="ui input">'+
|
||||
'<input type="text" name="direccion_propietario'+(idx+1)+'" id="direccion_propietario'+(idx+1)+'" value="'+propietario.direccion+'" />'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="two wide field">'+
|
||||
'<label for="comuna_propietario'+(idx+1)+'">Comuna</label>'+
|
||||
'<input type="text" name="comuna_propietario'+(idx+1)+'" id="comuna_propietario'+(idx+1)+'" value="'+propietario.comuna+'" />'+
|
||||
'</div>' +
|
||||
'</div>')
|
||||
const inputs = {
|
||||
proporcion: 'proporciones',
|
||||
rut: 'rut',
|
||||
propietario: 'propietario',
|
||||
direccion_propietario: 'direccion',
|
||||
comuna_propietario: 'comuna'
|
||||
}
|
||||
Object.entries(inputs).forEach(([name, method]) => {
|
||||
$("[name='"+name+(idx+1)+"']").change(event => {
|
||||
this.update()[method](idx)
|
||||
this.update().facturas()
|
||||
})
|
||||
})
|
||||
})
|
||||
const bruto = this.precio - terreno
|
||||
const base = bruto / 1.19
|
||||
const iva = base * .19
|
||||
const subtotal = base + iva
|
||||
const total = subtotal + terreno
|
||||
const totalUF = total / this.uf
|
||||
|
||||
const emptyTerreno = '<div class="ui tiny red horizontal circular label">0</div>'
|
||||
const data = [
|
||||
c,
|
||||
'Valor con Terreno ' + pesoFormatter.format((base + terreno) * this.proporcion) + ' - Menos valor terreno ' + ((terreno > 0) ? pesoFormatter.format(-terreno * this.proporcion) : emptyTerreno) + '<br />' +
|
||||
'Base imponible ' + pesoFormatter.format(base * this.proporcion) + '<br />' +
|
||||
'IVA ' + pesoFormatter.format(iva * this.proporcion) + '<br />' +
|
||||
'SUBTOTAL ' + pesoFormatter.format(subtotal * this.proporcion) + '<br />' +
|
||||
'Mas valor terreno ' + ((terreno > 0) ? pesoFormatter.format(terreno * this.proporcion) : emptyTerreno) + '<br />' +
|
||||
'TOTAL ' + pesoFormatter.format(total * this.proporcion) + ';' + ufFormatter.format(totalUF * this.proporcion) + ' UF<br /><br />' +
|
||||
'Descuento Terreno: ' + ((terreno > 0) ? percentFormatter.format(prorrateo * 100) : emptyTerreno) + '%<br /><br />' +
|
||||
'UF: ' + ufFormatter.format(this.uf),
|
||||
'1 UNID',
|
||||
pesoFormatter.format(terreno * this.proporcion),
|
||||
'EX',
|
||||
pesoFormatter.format(terreno * this.proporcion)
|
||||
]
|
||||
const row = $('<tr></tr>').addClass('top aligned')
|
||||
data.forEach((value, i) => {
|
||||
const cell = $('<td></td>')
|
||||
if (classes[i] !== '') {
|
||||
cell.addClass(classes[i])
|
||||
}
|
||||
}
|
||||
cell.html(value)
|
||||
row.append(cell)
|
||||
})
|
||||
tbody.append(row)
|
||||
|
||||
$(this.totales.afecto).html(pesoFormatter.format(base * this.proporcion))
|
||||
$(this.totales.exento).html(pesoFormatter.format(terreno * this.proporcion))
|
||||
$(this.totales.iva).html(pesoFormatter.format(iva * this.proporcion))
|
||||
$(this.totales.total).html(pesoFormatter.format(total * this.proporcion))
|
||||
},
|
||||
update: function() {
|
||||
return {
|
||||
@ -514,7 +299,7 @@
|
||||
if (idx === -1) {
|
||||
return
|
||||
}
|
||||
const old_value = parseFloat(this.unidades[idx].precio)
|
||||
const old_value = this.unidades[idx].precio
|
||||
if (old_value === parseFloat(value)) {
|
||||
return
|
||||
}
|
||||
@ -531,7 +316,8 @@
|
||||
}
|
||||
const idx = this.unidades.findIndex(unidad => unidad.pid === json.propiedad_unidad_id)
|
||||
this.unidades[idx].precio = parseFloat(json.input.valor)
|
||||
this.unidades[idx].base = parseFloat(json.input.valor) * parseFloat(this.unidades[idx].base) / old_value
|
||||
this.unidades[idx].base = parseFloat(json.input.valor * this.unidades[idx].base / old_value)
|
||||
this.build()
|
||||
})
|
||||
},
|
||||
terreno: value => {
|
||||
@ -558,7 +344,7 @@
|
||||
}
|
||||
}).then(json => {
|
||||
this.terreno *= (1 + parseFloat(json.ipc))
|
||||
this.update().unidades()
|
||||
this.build()
|
||||
})
|
||||
})
|
||||
},
|
||||
@ -579,128 +365,35 @@
|
||||
}
|
||||
const idx = this.unidades.findIndex(unidad => unidad.id === json.unidad_id)
|
||||
this.unidades[idx].prorrateo = parseFloat(json.input.prorrateo)
|
||||
})
|
||||
},
|
||||
propietarios: value => {
|
||||
if (value < this.propietarios.length) {
|
||||
for (let i = value; i < this.propietarios.length; i ++) {
|
||||
this.propietarios.splice(i, 1)
|
||||
if (i in this.facturas.keys()) {
|
||||
this.facturas[i].splice(i, 1)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
for (let i = this.propietarios.length; i < value; i ++) {
|
||||
const propietario = {
|
||||
rut: '',
|
||||
nombre: '',
|
||||
direccion: '',
|
||||
comuna: ''
|
||||
}
|
||||
this.propietarios.push(propietario)
|
||||
if (!(i in this.facturas.keys())) {
|
||||
this.facturas.push(new Factura({propietario, proporcion: 0}))
|
||||
}
|
||||
}
|
||||
},
|
||||
proporciones: idx => {
|
||||
const proporcion = $("[name='proporcion"+(idx+1)+"']")
|
||||
const proporciones = $('.proporcion')
|
||||
const total = proporciones.toArray().reduce((sum, input) => sum + parseInt($(input).val()), 0)
|
||||
if (total <= 100) {
|
||||
this.facturas[idx].props.proporcion = parseInt(proporcion.val()) / 100
|
||||
return
|
||||
}
|
||||
const otros = proporciones.toArray().filter(input => input.name !== 'proporcion' + (idx+1)).reduce((sum, input) => sum + parseInt($(input).val()), 0)
|
||||
proporcion.val(100 - otros)
|
||||
this.facturas[idx].props.proporcion = parseInt(proporcion.val()) / 100
|
||||
},
|
||||
rut: idx => {
|
||||
this.propietarios[idx].rut = $("[name='rut"+(idx+1)+"']").val()
|
||||
},
|
||||
propietario: idx => {
|
||||
this.propietarios[idx].nombre = $("[name='propietario"+(idx+1)+"']").val()
|
||||
},
|
||||
direccion: idx => {
|
||||
this.propietarios[idx].direccion = $("[name='direccion"+(idx+1)+"']").val()
|
||||
},
|
||||
comuna: idx => {
|
||||
this.propietarios[idx].comuna = $("[name='comuna"+(idx+1)+"']").val()
|
||||
},
|
||||
unidades: () => {
|
||||
const ufFormatter = new Intl.NumberFormat('es-CL', {maximumFractionDigits: 2, minimumFractionDigits: 2})
|
||||
let totalUnidades = 0
|
||||
let precioUnidades = 0
|
||||
let terreno = 0
|
||||
let prorrateo = 0
|
||||
this.unidades.forEach(unidad => {
|
||||
totalUnidades += parseFloat(unidad.base)
|
||||
precioUnidades += parseFloat(unidad.precio)
|
||||
terreno += parseFloat(this.proyecto.terreno) * parseFloat(unidad.prorrateo)
|
||||
prorrateo += parseFloat(unidad.prorrateo)
|
||||
})
|
||||
|
||||
$('#total_unidades')
|
||||
.attr('class', 'ui compact segment ' + ((totalUnidades.toFixed(2) !== this.precio.toFixed(2)) ? 'inverted red' : 'inverted green'))
|
||||
.html('Total Unidades: ' + ufFormatter.format(precioUnidades) + ' UF' +
|
||||
((totalUnidades.toFixed(2) !== this.precio.toFixed(2)) ? '; Diferencia: ' + ufFormatter.format({{$venta->valor}} - precioUnidades) + ' UF' : ''))
|
||||
if (totalUnidades.toFixed(2) !== this.precio.toFixed(2)) {
|
||||
this.highlight()
|
||||
}
|
||||
this.venta.base = totalUnidades
|
||||
this.venta.precio = precioUnidades
|
||||
this.venta.terreno = terreno
|
||||
this.venta.prorrateo = prorrateo
|
||||
this.venta.bruto = this.venta.base - this.venta.terreno
|
||||
this.venta.neto = this.venta.bruto / 1.19
|
||||
this.venta.iva = this.venta.neto * 0.19
|
||||
this.venta.subtotal = this.venta.base + this.venta.iva
|
||||
this.venta.total = this.venta.subtotal + this.venta.terreno
|
||||
this.venta.totalUF = this.venta.total / this.uf
|
||||
},
|
||||
facturas: () => {
|
||||
const facturas = $(this.props.ids.facturas)
|
||||
facturas.html('')
|
||||
this.facturas.forEach((factura, idx) => {
|
||||
factura.draw({
|
||||
parentDiv: facturas,
|
||||
inmobiliaria: this.inmobiliaria,
|
||||
proyecto: this.proyecto,
|
||||
propietario: this.propietarios[idx],
|
||||
unidades: this.unidades,
|
||||
venta: this.venta,
|
||||
estadoVenta: this.estadoVenta,
|
||||
uf: this.uf,
|
||||
formatters: {
|
||||
date: new Intl.DateTimeFormat('es-CL', {day:'2-digit',month:'2-digit',year:'numeric'}),
|
||||
pesos: new Intl.NumberFormat('es-CL', {maximumFractionDigits: 0, minimumFractionDigits: 0}),
|
||||
ufs: new Intl.NumberFormat('es-CL', {maximumFractionDigits: 2, minimumFractionDigits: 2}),
|
||||
percent: new Intl.NumberFormat('es-CL', {maximumFractionDigits: 5, minimumFractionDigits: 5})
|
||||
}
|
||||
})
|
||||
this.build()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: function() {
|
||||
return {
|
||||
proporcion: id => {
|
||||
$(id).change(event => {
|
||||
const val = $(event.currentTarget).val()
|
||||
if (val / 100 === this.proporcion) {
|
||||
return
|
||||
}
|
||||
this.proporcion = val / 100
|
||||
this.build()
|
||||
})
|
||||
},
|
||||
prices: class_name => {
|
||||
$(class_name).change(event => {
|
||||
const val = $(event.currentTarget).val()
|
||||
const id = $(event.currentTarget).data('id')
|
||||
this.update().price(id, val).then(() => {
|
||||
this.update().unidades()
|
||||
})
|
||||
this.update().price(id, val)
|
||||
})
|
||||
},
|
||||
prorrateo: class_name => {
|
||||
$(class_name).change(event => {
|
||||
const val = $(event.currentTarget).val()
|
||||
const id = $(event.currentTarget).data('id')
|
||||
this.update().prorrateo(id, val).then(() => {
|
||||
this.update().unidades()
|
||||
})
|
||||
this.update().prorrateo(id, val)
|
||||
})
|
||||
},
|
||||
terreno: id => {
|
||||
@ -708,20 +401,8 @@
|
||||
const val = $(event.currentTarget).val()
|
||||
this.update().terreno(val).then(() => {
|
||||
$(id).parent().parent().hide()
|
||||
this.update().unidades()
|
||||
})
|
||||
})
|
||||
},
|
||||
propietarios: id => {
|
||||
$(id).change(event => {
|
||||
let val = $(event.currentTarget).val()
|
||||
if (val < 1) {
|
||||
$(event.currentTarget).val(1)
|
||||
val = 1
|
||||
}
|
||||
this.update().propietarios(val)
|
||||
this.draw().propietarios()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -740,31 +421,31 @@
|
||||
input.find('.label').removeClass('red')
|
||||
input.removeAttr('data-content')
|
||||
},
|
||||
setup: function({form_id, prices_class, prorrateo_class, terreno_id, propietarios_id, count_propietarios_id, facturas_id}) {
|
||||
this.props.ids.facturas = facturas_id
|
||||
this.props.ids.propietarios = propietarios_id
|
||||
setup: function({form_id, tbody_id, input_id, prices_class, prorrateo_class, terreno_id, totales_ids}) {
|
||||
$(form_id).submit(event => {
|
||||
event.preventDefault()
|
||||
return false
|
||||
})
|
||||
this.id = tbody_id
|
||||
this.totales = totales_ids
|
||||
this.proporcion = $(input_id).val() / 100
|
||||
this.watch().proporcion(input_id)
|
||||
this.watch().prices(prices_class)
|
||||
this.watch().prorrateo(prorrateo_class)
|
||||
this.watch().propietarios(count_propietarios_id)
|
||||
@if (!isset($terreno->fecha) or $terreno->fecha->getTimestamp() < 0 or $terreno->fecha <= $lastDic)
|
||||
@if (!isset($venta->proyecto()->terreno->fecha) or $venta->proyecto()->terreno->fecha <= $lastDic)
|
||||
this.watch().terreno(terreno_id)
|
||||
@endif
|
||||
this.facturas.push(new Factura({propietario: this.propietarios[0], proporcion: 1}))
|
||||
this.update().unidades()
|
||||
this.update().propietarios($(count_propietarios_id).val())
|
||||
this.draw().propietarios()
|
||||
this.propietarios.forEach((unidad, idx) => {
|
||||
this.update().proporciones(idx)
|
||||
})
|
||||
this.update().facturas()
|
||||
this.build()
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
facturasForm.setup({form_id: '#venta_form', prices_class: '.price', prorrateo_class: '.prorrateo', terreno_id: '#terreno', propietarios_id: '#propietarios', count_propietarios_id: '#cantidad_propietarios', facturas_id: '#facturas'})
|
||||
factura.setup({form_id: '#venta_form', tbody_id: '#unidades', input_id: '#proporcion',
|
||||
prices_class: '.price', prorrateo_class: '.prorrateo', terreno_id: '#terreno', totales_ids: {
|
||||
afecto: '#neto',
|
||||
exento: '#exento',
|
||||
iva: '#iva',
|
||||
total: '#total'
|
||||
}})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
@ -5,29 +5,6 @@
|
||||
@endsection
|
||||
|
||||
@section('venta_content')
|
||||
@if (count($asociadas) > 0)
|
||||
<div class="ui grid">
|
||||
<div class="two wide column">Asociados</div>
|
||||
<div class="six wide column">
|
||||
{!! implode(' - ', array_map(function(Incoviba\Model\Venta $venta) use ($urls) {
|
||||
return "<a href=\"{$urls->base}/venta/{$venta->id}\">{$venta->propiedad()->departamentos()[0]->descripcion}</a>";
|
||||
}, $asociadas)) !!}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="ui grid">
|
||||
<div class="column">Valor</div>
|
||||
<div class="four wide column">
|
||||
{{$format->ufs($venta->formaPago()->pie->valor)}}
|
||||
@if (count($asociadas) > 0)
|
||||
[{{$format->ufs($venta->formaPago()->pie->valor + array_reduce($asociadas, function(float $sum, Incoviba\Model\Venta $venta) {
|
||||
return $sum + $venta->formaPago()->pie->valor;
|
||||
}, 0.0))}}]
|
||||
@endif
|
||||
</div>
|
||||
<div class="column">Cuotas</div>
|
||||
<div class="column">{{$venta->formaPago()->pie->cuotas}}</div>
|
||||
</div>
|
||||
<table class="ui table" id="cuotas">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -60,37 +37,32 @@
|
||||
<td>{{$cuota->pago->identificador}}</td>
|
||||
<td class="right aligned">{{$format->pesos($cuota->pago->valor)}}</td>
|
||||
<td class="right aligned">
|
||||
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['depositado', 'abonado'])
|
||||
and $cuota->pago->currentEstado->fecha <= $now)
|
||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' and $cuota->pago->currentEstado->fecha <= $now)
|
||||
{{$format->ufs($cuota->pago->valor())}}
|
||||
@else
|
||||
~{{$format->ufs($cuota->pago->valor / $uf_venta)}}
|
||||
@endif
|
||||
</td>
|
||||
<td{!! ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' ? ' class="green"' :
|
||||
($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado' ? ' class="yellow"' :
|
||||
($cuota->pago->currentEstado->tipoEstadoPago->activo !== 1 ? ' class="red"' : ''))) !!}>
|
||||
{{ucwords($cuota->pago->currentEstado->tipoEstadoPago->descripcion)}}
|
||||
</td>
|
||||
<td
|
||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado')
|
||||
class="green"
|
||||
@elseif ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
||||
class="yellow"
|
||||
@elseif ($cuota->pago->currentEstado->tipoEstadoPago->activo !== 1)
|
||||
class="red"
|
||||
@endif
|
||||
>{{ucwords($cuota->pago->currentEstado->tipoEstadoPago->descripcion)}}</td>
|
||||
<td>
|
||||
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['abonado', 'anulado', 'reemplazado']))
|
||||
{{$cuota->pago->currentEstado->fecha->format('d-m-Y')}}
|
||||
@elseif (!in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado', 'reemplazado']))
|
||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
||||
{{$cuota->pago->currentEstado->fecha->format('d-m-Y')}}
|
||||
@endif
|
||||
<div class="ui calendar fecha_estado" data-date="{{$cuota->pago->currentEstado->fecha->format('Y-m-d')}}">
|
||||
<div class="ui action left icon input">
|
||||
<i class="calendar icon"></i>
|
||||
<input type="text" name="fecha_estado" />
|
||||
<button class="ui green basic icon button accept_estado"
|
||||
data-pago="{{$cuota->pago->id}}"
|
||||
data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->descripcion}}">
|
||||
<button class="ui green basic icon button accept_estado" data-pago="{{$cuota->pago->id}}" data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->descripcion}}">
|
||||
<i class="check icon"></i>
|
||||
</button>
|
||||
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
|
||||
<button class="ui red basic icon button reject_estado"
|
||||
data-pago="{{$cuota->pago->id}}">
|
||||
<button class="ui red basic icon button reject_estado" data-pago="{{$cuota->pago->id}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
@endif
|
||||
@ -143,7 +115,7 @@
|
||||
}, 0.0))}}
|
||||
</th>
|
||||
<th class="right aligned">
|
||||
{{$format->number(($total > 0) ? $pagado / $total * 100 : 0, 2)}}%
|
||||
{{$format->number($pagado / $total * 100, 2)}}%
|
||||
</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
@ -156,7 +128,7 @@
|
||||
{{$format->ufs($total - $pagado)}}
|
||||
</th>
|
||||
<th class="right aligned">
|
||||
{{$format->number(($total > 0) ? ($total - $pagado) / $total * 100 : 0, 2)}}%
|
||||
{{$format->number(($total - $pagado) / $total * 100, 2)}}%
|
||||
</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
@ -172,10 +144,9 @@
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(() => {
|
||||
function updateRow({pago_id, valor, fecha, color, estado, remove_fecha=false, add_reject=false, disable=false}) {
|
||||
function updateRow({pago_id, fecha, color, estado, remove_fecha=false, add_reject=false, disable=false}) {
|
||||
const tr = $("tr[data-pago='" + pago_id + "']")
|
||||
|
||||
tr.find(':nth-child(6)').html(valor)
|
||||
tr.find(':nth-child(7)').attr('class', color).html(estado)
|
||||
if (remove_fecha) {
|
||||
tr.find(':nth-child(8)').html(fecha)
|
||||
@ -210,7 +181,7 @@
|
||||
if (!json.depositado) {
|
||||
return
|
||||
}
|
||||
updateRow({pago_id: json.pago_id, valor: json.pago.valor_uf, fecha: json.input.fecha, estado: 'Depositado', color: 'yellow', add_reject: true})
|
||||
updateRow({pago_id: json.pago_id, fecha: json.input.fecha, estado: 'Depositado', color: 'yellow', add_reject: true})
|
||||
button.attr('data-estado', 'depositado')
|
||||
})
|
||||
})
|
||||
@ -218,7 +189,7 @@
|
||||
function abonar(pago_id, fecha) {
|
||||
const url = '{{$urls->api}}/ventas/pago/' + pago_id + '/abonar'
|
||||
const body = new FormData()
|
||||
body.set('fecha', [fecha.getFullYear(), fecha.getMonth() + 1, fecha.getDate()].join('-'))
|
||||
body.set('fecha', fecha.toISOString())
|
||||
return fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
|
@ -50,7 +50,7 @@
|
||||
</td>
|
||||
<td class="right aligned">
|
||||
@if ($unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento')
|
||||
{{$format->number((($unidad->valor === null or $unidad->valor === 0.0) ? $precio : $unidad->valor) / $unidad->proyectoTipoUnidad->vendible(), 2)}} UF/m²
|
||||
{{$format->number(($unidad->valor ?? $precio) / $unidad->proyectoTipoUnidad->vendible(), 2)}} UF/m²
|
||||
@endif
|
||||
</td>
|
||||
<td class="center aligned">
|
||||
|
@ -1,2 +1,2 @@
|
||||
<?php
|
||||
$app->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
//$app->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));
|
||||
|
@ -1,2 +0,0 @@
|
||||
<?php
|
||||
$app->add($app->getContainer()->get(Incoviba\Middleware\CORS::class));
|
@ -4,6 +4,18 @@ use Psr\Container\ContainerInterface;
|
||||
return [
|
||||
Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
|
||||
return new Monolog\Logger('incoviba', [
|
||||
new Monolog\Handler\FilterHandler(
|
||||
(new Monolog\Handler\RotatingFileHandler('/logs/debug.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
Monolog\Level::Debug,
|
||||
Monolog\Level::Debug
|
||||
),
|
||||
new Monolog\Handler\FilterHandler(
|
||||
(new Monolog\Handler\RotatingFileHandler('/logs/info.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
Monolog\Level::Info,
|
||||
Monolog\Level::Warning,
|
||||
),
|
||||
new Monolog\Handler\FilterHandler(
|
||||
(new Monolog\Handler\RotatingFileHandler('/logs/error.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
@ -14,17 +26,6 @@ return [
|
||||
(new Monolog\Handler\RotatingFileHandler('/logs/critical.log', 10))
|
||||
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
|
||||
Monolog\Level::Critical
|
||||
),
|
||||
new Monolog\Handler\FilterHandler(
|
||||
new Monolog\Handler\RedisHandler($container->get(Predis\ClientInterface::class), 'logs:notices'),
|
||||
Monolog\Level::Notice,
|
||||
Monolog\Level::Warning
|
||||
),
|
||||
new Monolog\Handler\FilterHandler(
|
||||
(new Incoviba\Common\Implement\Log\MySQLHandler($container->get(Incoviba\Common\Define\Connection::class)))
|
||||
->setFormatter(new Incoviba\Common\Implement\Log\PDOFormatter()),
|
||||
Monolog\Level::Debug,
|
||||
Monolog\Level::Warning
|
||||
)
|
||||
], [
|
||||
$container->get(Monolog\Processor\PsrLogMessageProcessor::class),
|
||||
|
@ -14,7 +14,6 @@ return [
|
||||
Incoviba\Middleware\API::class => function(ContainerInterface $container) {
|
||||
return new Incoviba\Middleware\API(
|
||||
$container->get(Psr\Http\Message\ResponseFactoryInterface::class),
|
||||
$container->get(Incoviba\Service\Login::class),
|
||||
$container->get('API_KEY')
|
||||
);
|
||||
}
|
||||
|
@ -9,8 +9,7 @@ return [
|
||||
$container->get('COOKIE_NAME'),
|
||||
$container->get('MAX_LOGIN_HOURS'),
|
||||
$container->has('COOKIE_DOMAIN') ? $container->get('COOKIE_DOMAIN') : '',
|
||||
$container->has('COOKIE_PATH') ? $container->get('COOKIE_PATH') : '',
|
||||
$container->has('COOKIE_SEPARATOR') ? $container->get('COOKIE_SEPARATOR') : 'g'
|
||||
$container->has('COOKIE_PATH') ? $container->get('COOKIE_PATH') : ''
|
||||
);
|
||||
},
|
||||
Incoviba\Service\Money::class => function(ContainerInterface $container) {
|
||||
@ -26,40 +25,39 @@ return [
|
||||
->register('usd', $mindicador)
|
||||
->register('ipc', $ine);
|
||||
},
|
||||
Predis\ClientInterface::class => function(ContainerInterface $container) {
|
||||
Predis\Client::class => function(ContainerInterface $container) {
|
||||
return new Predis\Client([
|
||||
'scheme' => 'tcp',
|
||||
'host' => $container->get('REDIS_HOST'),
|
||||
'port' => $container->get('REDIS_PORT')
|
||||
]);
|
||||
},
|
||||
Incoviba\Service\Contabilidad\Cartola::class => function(ContainerInterface $container) {
|
||||
return (new Incoviba\Service\Contabilidad\Cartola(
|
||||
Incoviba\Service\Cartola::class => function(ContainerInterface $container) {
|
||||
return (new Incoviba\Service\Cartola(
|
||||
$container->get(Psr\Log\LoggerInterface::class),
|
||||
$container->get(Psr\Http\Message\StreamFactoryInterface::class),
|
||||
$container->get(Incoviba\Common\Define\Contabilidad\Exporter::class),
|
||||
$container->get(Incoviba\Repository\Inmobiliaria::class),
|
||||
$container->get(Incoviba\Repository\Inmobiliaria\Cuenta::class),
|
||||
$container->get(Incoviba\Repository\Contabilidad\Movimiento::class),
|
||||
$container->get(Incoviba\Service\Contabilidad\Movimiento::class),
|
||||
$container->get(Incoviba\Repository\Contabilidad\Cartola::class)
|
||||
$container->get(Incoviba\Repository\Movimiento::class),
|
||||
$container->get(Incoviba\Service\Movimiento::class),
|
||||
$container->get(Incoviba\Repository\Cartola::class)
|
||||
))
|
||||
->register('security', $container->get(Incoviba\Service\Contabilidad\Cartola\Security::class))
|
||||
->register('itau', $container->get(Incoviba\Service\Contabilidad\Cartola\Itau::class))
|
||||
->register('santander', $container->get(Incoviba\Service\Contabilidad\Cartola\Santander::class))
|
||||
->register('bci', $container->get(Incoviba\Service\Contabilidad\Cartola\BCI::class));
|
||||
->register('security', $container->get(Incoviba\Service\Cartola\Security::class))
|
||||
->register('itau', $container->get(Incoviba\Service\Cartola\Itau::class))
|
||||
->register('santander', $container->get(Incoviba\Service\Cartola\Santander::class));
|
||||
},
|
||||
Incoviba\Common\Define\Contabilidad\Exporter::class => function(ContainerInterface $container) {
|
||||
return $container->get(Incoviba\Service\Contabilidad\Exporter\Nubox::class);
|
||||
},
|
||||
Incoviba\Service\Contabilidad\Exporter\Nubox::class => function(ContainerInterface $container) {
|
||||
return new Incoviba\Service\Contabilidad\Exporter\Nubox($container->get(Incoviba\Repository\Contabilidad\CentroCosto::class),
|
||||
return new Incoviba\Service\Contabilidad\Exporter\Nubox($container->get(Incoviba\Repository\CentroCosto::class),
|
||||
$container->get('folders')->get('uploads'));
|
||||
},
|
||||
Incoviba\Service\Contabilidad\Nubox::class => function(ContainerInterface $container) {
|
||||
return new Incoviba\Service\Contabilidad\Nubox(
|
||||
$container->get(Psr\Log\LoggerInterface::class),
|
||||
$container->get(Incoviba\Repository\Contabilidad\Nubox::class),
|
||||
$container->get(Incoviba\Repository\Nubox::class),
|
||||
$container->get(Incoviba\Service\Redis::class),
|
||||
new GuzzleHttp\Client(),
|
||||
$container->get(Psr\Http\Message\RequestFactoryInterface::class),
|
||||
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
|
||||
class Base extends Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'version' => '2.0.0',
|
||||
'organization' => 'Ingenieria y Construccion Vial Balmaceda Sociedad Anonima'
|
||||
];
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
@ -1,23 +1,24 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use DateTimeInterface;
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Cartolas extends Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function procesar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Contabilidad\Banco $bancoRepository,
|
||||
Service\Contabilidad\Cartola $cartolaService): ResponseInterface
|
||||
public function procesar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
@ -33,10 +34,10 @@ class Cartolas extends Controller
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function exportar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Contabilidad\Banco $bancoRepository,
|
||||
Service\Contabilidad\Cartola $cartolaService): ResponseInterface
|
||||
public function exportar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
@ -51,9 +52,9 @@ class Cartolas extends Controller
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function diaria(ServerRequestInterface $request, ResponseInterface $response,
|
||||
public function diaria(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Service\Contabilidad\Cartola $cartolaService): ResponseInterface
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
@ -79,9 +80,9 @@ class Cartolas extends Controller
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function ayer(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Contabilidad\Cartola $cartolaRepository): ResponseInterface
|
||||
public function ayer(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Cartola $cartolaRepository): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class CentrosCostos
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'added' => false
|
||||
];
|
||||
try {
|
||||
$centroCosto = $centroCostoRepository->create($body);
|
||||
$centroCosto->id = $body['id'];
|
||||
$centroCostoRepository->save($centroCosto);
|
||||
$output['added'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'centro_costo_id' => $centro_costo_id,
|
||||
'input' => $body,
|
||||
'edited' => false
|
||||
];
|
||||
try {
|
||||
$centroCosto = $centroCostoRepository->fetchById($centro_costo_id);
|
||||
if ($body['tipo_cuenta_id'] === '') {
|
||||
$body['tipo_cuenta_id'] = null;
|
||||
}
|
||||
$centroCostoRepository->edit($centroCosto, $body);
|
||||
$output['edited'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function remove(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'centro_costo_id' => $centro_costo_id,
|
||||
'removed' => false
|
||||
];
|
||||
try {
|
||||
$centroCosto = $centroCostoRepository->fetchById($centro_costo_id);
|
||||
$centroCostoRepository->remove($centroCosto);
|
||||
$output['removed'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
@ -2,23 +2,23 @@
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Depositos extends Ideal\Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function inmobiliaria(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Contabilidad\Banco $bancoRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Contabilidad\Deposito $dapRepository,
|
||||
int $inmobiliaria_rut): ResponseInterface
|
||||
public function inmobiliaria(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Deposito $dapRepository,
|
||||
int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
@ -33,10 +33,10 @@ class Depositos extends Ideal\Controller
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository, Repository\Contabilidad\Banco $bancoRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Contabilidad\Deposito $dapRepository): ResponseInterface
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository, Repository\Banco $bancoRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Deposito $dapRepository): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
|
@ -1,21 +1,21 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Movimientos extends Ideal\Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function detalles(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Contabilidad\Movimiento $movimientoService,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository, int $movimiento_id): ResponseInterface
|
||||
public function detalles(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Movimiento $movimientoService,
|
||||
Repository\CentroCosto $centroCostoRepository, int $movimiento_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
@ -47,43 +47,4 @@ class Movimientos extends Ideal\Controller
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Service\Contabilidad\Movimiento $movimientoService): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'movimientos' => []
|
||||
];
|
||||
try {
|
||||
$movimientos = $movimientoService->getAll();
|
||||
$output['movimientos'] = json_decode(json_encode($movimientos), JSON_OBJECT_AS_ARRAY);
|
||||
foreach ($output['movimientos'] as $i => &$arrayMovimiento) {
|
||||
$arrayMovimiento['cuenta'] = json_decode(json_encode($movimientos[$i]->cuenta), JSON_OBJECT_AS_ARRAY);
|
||||
$arrayMovimiento['cuenta']['inmobiliaria'] = json_decode(json_encode($movimientos[$i]->cuenta->inmobiliaria), JSON_OBJECT_AS_ARRAY);
|
||||
if ($arrayMovimiento['detalles'] !== null) {
|
||||
$arrayMovimiento['detalles']['centro_costo'] = $movimientos[$i]->getDetalles()->centroCosto;
|
||||
}
|
||||
}
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function segment(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Contabilidad\Movimiento $movimientoService): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $input,
|
||||
'movimientos' => []
|
||||
];
|
||||
try {
|
||||
$movimientos = $movimientoService->getAmountStartingFrom($input['from'], $input['amount']);
|
||||
$output['movimientos'] = json_decode(json_encode($movimientos), JSON_OBJECT_AS_ARRAY);
|
||||
foreach ($output['movimientos'] as $i => &$arrayMovimiento) {
|
||||
$arrayMovimiento['cuenta'] = json_decode(json_encode($movimientos[$i]->cuenta), JSON_OBJECT_AS_ARRAY);
|
||||
$arrayMovimiento['cuenta']['inmobiliaria'] = json_decode(json_encode($movimientos[$i]->cuenta->inmobiliaria), JSON_OBJECT_AS_ARRAY);
|
||||
if ($arrayMovimiento['detalles'] !== null) {
|
||||
$arrayMovimiento['detalles']['centro_costo'] = $movimientos[$i]->getDetalles()->centroCosto;
|
||||
}
|
||||
}
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
||||
|
@ -1,123 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Implement\Exception\EmptyRedis;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Common\Implement\Exception\HttpResponse;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Nubox
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function token(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Contabilidad\Nubox $nuboxService, int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'token' => ''
|
||||
];
|
||||
try {
|
||||
$output['token'] = $nuboxService->getToken($inmobiliaria_rut);
|
||||
} catch (HttpResponse $exception) {
|
||||
$output['error'] = [
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage()
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function sistemas(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Contabilidad\Nubox $nuboxService, int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'sistemas' => []
|
||||
];
|
||||
try {
|
||||
$output['sistemas'] = $nuboxService->getSistemas($inmobiliaria_rut);
|
||||
} catch (HttpResponse $exception) {
|
||||
$output['error'] = [
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage()
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function libroMayor(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Contabilidad\Nubox $nuboxService, int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'input' => $body,
|
||||
'libro_mayor' => []
|
||||
];
|
||||
try {
|
||||
$from = new DateTimeImmutable($body['inicio']);
|
||||
$to = new DateTimeImmutable($body['termino']);
|
||||
$output['libro_mayor'] = $nuboxService->getLibroMayor($inmobiliaria_rut, $from, $to);
|
||||
} catch (HttpResponse $exception) {
|
||||
$output['error'] = [
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage()
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function libroDiario(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Contabilidad\Nubox $nuboxService, int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'input' => $body,
|
||||
'libro_diario' => []
|
||||
];
|
||||
try {
|
||||
$from = new DateTimeImmutable($body['inicio']);
|
||||
$to = new DateTimeImmutable($body['termino']);
|
||||
$output['libro_diario'] = $nuboxService->getLibroDiario($inmobiliaria_rut, $from, $to);
|
||||
} catch (HttpResponse $exception) {
|
||||
$output['error'] = [
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage()
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function cuentas(ServerRequestInterface $request, ResponseInterface $response, Service\Contabilidad\Nubox $nuboxService, int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'input' => $body,
|
||||
'cuentas' => $nuboxService->getCuentas($inmobiliaria_rut)
|
||||
];
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function cuenta(ServerRequestInterface $request, ResponseInterface $response, Service\Contabilidad\Nubox $nuboxService, int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'inmobiliaria_rut' => $inmobiliaria_rut,
|
||||
'input' => $body,
|
||||
'movimientos' => []
|
||||
];
|
||||
try {
|
||||
$mes = new DateTimeImmutable($body['mes']);
|
||||
$cuenta = $body['cuenta'];
|
||||
$output['movimientos'] = $nuboxService->getMesCuenta($inmobiliaria_rut, $cuenta, $mes);
|
||||
} catch (HttpResponse $exception) {
|
||||
$output['error'] = [
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage()
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
@ -12,16 +12,6 @@ class Inmobiliarias
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'inmobiliarias' => []
|
||||
];
|
||||
try {
|
||||
$output['inmobiliarias'] = $inmobiliariaRepository->fetchAll('razon');
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function cuentas(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository, int $inmobiliaria_rut): ResponseInterface
|
||||
@ -55,29 +45,4 @@ class Inmobiliarias
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function agentes(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Inmobiliaria\SociedadAgente $sociedadAgenteRepository,
|
||||
Repository\Inmobiliaria\TipoAgente $tipoAgenteRepository,
|
||||
int $inmobiliaria_rut): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
$output = [
|
||||
'sociedad_rut' => $inmobiliaria_rut,
|
||||
'input' => $input,
|
||||
'sociedad' => null,
|
||||
'agentes' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($inmobiliaria_rut);
|
||||
$output['sociedad'] = $inmobiliaria;
|
||||
if (isset($input['tipo_agente_id'])) {
|
||||
$tipo = $tipoAgenteRepository->fetchById($input['tipo_agente_id']);
|
||||
$output['agentes'] = $sociedadAgenteRepository->fetchBySociedadAndTipo($inmobiliaria->rut, $tipo->id);
|
||||
} else {
|
||||
$output['agentes'] = $sociedadAgenteRepository->fetchBySociedad($inmobiliaria->rut);
|
||||
}
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
||||
|
@ -1,90 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Inmobiliarias;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
|
||||
class Agentes
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Repository\Inmobiliaria\Agente $agenteRepository): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'agentes' => []
|
||||
];
|
||||
try {
|
||||
$output['agentes'] = $agenteRepository->fetchAll('abreviacion');
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response, Repository\Inmobiliaria\Agente $agenteRepository): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $input,
|
||||
'agente' => null
|
||||
];
|
||||
try {
|
||||
$agente = $agenteRepository->create($input);
|
||||
$output['agente'] = $agenteRepository->save($agente);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria\Agente $agenteRepository, int $agente_id): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
$output = [
|
||||
'agente_id' => $agente_id,
|
||||
'input' => $input,
|
||||
'agente' => null
|
||||
];
|
||||
try {
|
||||
$agente = $agenteRepository->fetchById($agente_id);
|
||||
$output['agente'] = $agenteRepository->edit($agente, $input);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function register(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Inmobiliaria\Agente $agenteRepository,
|
||||
Repository\Inmobiliaria\TipoAgente $tipoAgenteRepository,
|
||||
Repository\Inmobiliaria\AgenteTipo $agenteTipoRepository,
|
||||
Repository\Inmobiliaria\SociedadAgente $sociedadAgenteRepository): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $input,
|
||||
'sociedad' => null,
|
||||
'agente' => null,
|
||||
'tipo_agente' => null,
|
||||
'sociedad_agente' => null
|
||||
];
|
||||
try {
|
||||
$sociedad = $inmobiliariaRepository->fetchById($input['sociedad_rut']);
|
||||
$output['sociedad'] = $sociedad;
|
||||
$agente = $agenteRepository->fetchById($input['agente_id']);
|
||||
$output['agente'] = $agente;
|
||||
$tipo = $tipoAgenteRepository->fetchById($input['tipo_agente_id']);
|
||||
$output['tipo_agente'] = $tipo;
|
||||
$agenteTipo = $agenteTipoRepository->fetchByAgenteAndTipo($agente->id, $tipo->id);
|
||||
try {
|
||||
$output['sociedad_agente'] = $sociedadAgenteRepository->fetchBySociedadAndAgenteAndTipo($sociedad->rut, $agente->id, $tipo->id);
|
||||
} catch (EmptyResult) {
|
||||
$data = [
|
||||
'sociedad_rut' => $sociedad->rut,
|
||||
'agente_tipo_id' => $agenteTipo->id
|
||||
];
|
||||
$sociedadAgente = $sociedadAgenteRepository->create($data);
|
||||
$output['sociedad_agente'] = $sociedadAgenteRepository->save($sociedadAgente);
|
||||
}
|
||||
} catch (EmptyResult) {
|
||||
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
@ -13,19 +13,6 @@ class Pagos
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function get(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService,
|
||||
Service\Format $formatService, int $pago_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'pago_id' => $pago_id,
|
||||
'pago' => null
|
||||
];
|
||||
try {
|
||||
$output['pago'] = json_decode(json_encode($pagoService->getById($pago_id)), JSON_OBJECT_AS_ARRAY);
|
||||
$output['pago']['valor_uf'] = $formatService->ufs($output['pago']['valor_uf']);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Pago $pagoRepository, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
@ -44,41 +31,33 @@ class Pagos
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function depositar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta\Pago $pagoService, Service\Format $formatService, int $pago_id): ResponseInterface
|
||||
public function depositar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'pago_id' => $pago_id,
|
||||
'input' => $body,
|
||||
'pago' => null,
|
||||
'depositado' => false
|
||||
];
|
||||
try {
|
||||
$pago = $pagoService->getById($pago_id);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$fecha = new DateTimeImmutable($body->fecha);
|
||||
$output['depositado'] = $pagoService->depositar($pago, $fecha);
|
||||
$output['pago'] = json_decode(json_encode($pagoService->getById($pago_id)), JSON_OBJECT_AS_ARRAY);
|
||||
$output['pago']['valor_uf'] = $formatService->ufs($output['pago']['valor_uf']);
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService,
|
||||
Service\Format $formatService, int $pago_id): ResponseInterface
|
||||
public function abonar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pago $pagoService, int $pago_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'pago_id' => $pago_id,
|
||||
'input' => $body,
|
||||
'pago' => null,
|
||||
'abonado' => false
|
||||
];
|
||||
try {
|
||||
$pago = $pagoService->getById($pago_id);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$fecha = new DateTimeImmutable($body->fecha);
|
||||
$output['abonado'] = $pagoService->abonar($pago, $fecha);
|
||||
$output['pago'] = json_decode(json_encode($pagoService->getById($pago_id)), JSON_OBJECT_AS_ARRAY);
|
||||
$output['pago']['valor_uf'] = $formatService->ufs($output['pago']['valor_uf']);
|
||||
$output['input']['fecha'] = $fecha->format('d-m-Y');
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
|
@ -1,25 +1,25 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller;
|
||||
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use DateInterval;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Common\Implement\Exception\{EmptyRedis, EmptyResult};
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Implement\Exception\{EmptyResult, EmptyRedis};
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Contabilidad extends Controller
|
||||
{
|
||||
use withRedis;
|
||||
|
||||
public function diaria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Redis $redisService,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository): ResponseInterface
|
||||
public function diaria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Redis $redisService,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\CentroCosto $centroCostoRepository): ResponseInterface
|
||||
{
|
||||
$redisKey = 'inmobiliarias';
|
||||
$inmobiliarias = [];
|
||||
@ -27,17 +27,17 @@ class Contabilidad extends Controller
|
||||
$inmobiliarias = $this->fetchRedis($redisService, $redisKey);
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAll('razon');
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAll();
|
||||
$this->saveRedis($redisService, $redisKey, $inmobiliarias, 30 * 24 * 60 * 60);
|
||||
} catch (EmptyResult) {}
|
||||
}
|
||||
$centrosCostos = $centroCostoRepository->fetchAll();
|
||||
return $view->render($response, 'contabilidad.cartolas.diaria', compact('inmobiliarias', 'centrosCostos'));
|
||||
}
|
||||
public function depositos(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Redis $redisService,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Contabilidad\Deposito $dapRepository): ResponseInterface
|
||||
public function depositos(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Redis $redisService,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Deposito $dapRepository): ResponseInterface
|
||||
{
|
||||
$redisKey = 'inmobiliarias';
|
||||
$inmobiliarias = [];
|
||||
@ -54,11 +54,11 @@ class Contabilidad extends Controller
|
||||
$depositos = $dapRepository->fetchAll();
|
||||
} catch (EmptyResult) {}
|
||||
$fecha = new DateTimeImmutable('today');
|
||||
$activos = array_filter($depositos, function(Model\Contabilidad\Deposito $deposito) use ($fecha) {
|
||||
$activos = array_filter($depositos, function(Model\Deposito $deposito) use ($fecha) {
|
||||
return $deposito->termino >= $fecha;
|
||||
});
|
||||
$mes = $fecha->sub(new DateInterval('P1M'));
|
||||
$vencidos = array_filter($depositos, function(Model\Contabilidad\Deposito $deposito) use ($fecha, $mes) {
|
||||
$vencidos = array_filter($depositos, function(Model\Deposito $deposito) use ($fecha, $mes) {
|
||||
return $deposito->termino < $fecha and $deposito->termino >= $mes;
|
||||
});
|
||||
return $view->render($response, 'contabilidad.depositos', compact('inmobiliarias', 'activos', 'vencidos'));
|
||||
@ -69,25 +69,8 @@ class Contabilidad extends Controller
|
||||
{
|
||||
$fecha = new DateTimeImmutable($fecha);
|
||||
$anterior = $contabilidadService->getAnterior($fecha);
|
||||
$yesterday = new DateTimeImmutable('yesterday');
|
||||
$siguiente = null;
|
||||
if ($yesterday > $fecha) {
|
||||
$siguiente = $fecha->add(new DateInterval('P1D'));
|
||||
if ($siguiente->format('N') === '6') {
|
||||
$siguiente = $fecha->add(new DateInterval('P3D'));
|
||||
}
|
||||
}
|
||||
$informes = $contabilidadService->build($fecha);
|
||||
$filename = "Informe de Tesorería {$fecha->format('d.m.Y')}";
|
||||
return $view->render($response, 'contabilidad.informes.tesoreria', compact('fecha', 'anterior', 'siguiente', 'informes', 'filename'));
|
||||
}
|
||||
public function cuadratura(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||||
{
|
||||
$inmobiliarias = [];
|
||||
try {
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAll('razon');
|
||||
} catch (EmptyResult) {}
|
||||
return $view->render($response, 'contabilidad.cuadratura', compact('inmobiliarias'));
|
||||
return $view->render($response, 'contabilidad.informes.tesoreria', compact('fecha', 'anterior', 'informes', 'filename'));
|
||||
}
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Contabilidad;
|
||||
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Repository;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class CentrosCostos
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository,
|
||||
Repository\Contabilidad\TipoCentro $tipoCentroRepository,
|
||||
Repository\Contabilidad\CategoriaCentro $categoriaCentroRepository,
|
||||
Repository\TipoCuenta $tipoCuentaRepository): ResponseInterface
|
||||
{
|
||||
$centrosCostos = $centroCostoRepository->fetchAll();
|
||||
$tiposCentros = $tipoCentroRepository->fetchAll();
|
||||
$categorias = $categoriaCentroRepository->fetchAll('descripcion');
|
||||
$tiposCuentas = $tipoCuentaRepository->fetchAll();
|
||||
return $view->render($response, 'contabilidad.centros_costos', compact('centrosCostos',
|
||||
'tiposCentros', 'categorias', 'tiposCuentas'));
|
||||
}
|
||||
public function asignar(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Repository\Contabilidad\CentroCosto $centroCostoRepository,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||||
{
|
||||
$centrosCostos = $centroCostoRepository->fetchAll();
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAllActive('razon');
|
||||
return $view->render($response, 'contabilidad.centros_costos.asignar', compact('centrosCostos', 'inmobiliarias'));
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Contabilidad;
|
||||
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Movimientos extends Controller
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view): ResponseInterface
|
||||
{
|
||||
return $view->render($response, 'contabilidad.movimientos');
|
||||
}
|
||||
}
|
@ -20,8 +20,8 @@ class Inmobiliarias
|
||||
$inmobiliarias = [];
|
||||
try {
|
||||
$inmobiliarias = array_map(function($row) use ($inmobiliariaRepository) {
|
||||
return $inmobiliariaRepository->load($row);
|
||||
}, $this->fetchRedis($redisService, $redisKey, true));
|
||||
return $inmobiliariaRepository->load((array) $row);
|
||||
}, $this->fetchRedis($redisService, $redisKey));
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAll();
|
||||
|
@ -1,16 +1,14 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use PDOException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Login extends Controller
|
||||
class Login
|
||||
{
|
||||
public function form(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Login $service): ResponseInterface
|
||||
{
|
||||
@ -22,17 +20,14 @@ class Login extends Controller
|
||||
public function login(ServerRequestInterface $request, ResponseInterface $response, Repository\User $userRepository, Service\Login $service): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$user = $userRepository->fetchByName($body['name']);
|
||||
$output = [
|
||||
'name' => $body['name'],
|
||||
'name' => $user->name,
|
||||
'login' => false
|
||||
];
|
||||
|
||||
try {
|
||||
$user = $userRepository->fetchByName($body['name']);
|
||||
if ($service->validateUser($user, $body['password'])) {
|
||||
$output['login'] = $service->login($user);
|
||||
}
|
||||
} catch (EmptyResult) {}
|
||||
if ($user->validate($body['password'])) {
|
||||
$output['login'] = $service->login($user);
|
||||
}
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Implement\Exception\EmptyRedis;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Common\Implement\Exception\EmptyRedis;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Ventas
|
||||
{
|
||||
@ -101,29 +101,14 @@ class Ventas
|
||||
View $view, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
$asociadas = [];
|
||||
if (isset($venta->formaPago()->pie->asociado)) {
|
||||
$asociadas []= $ventaService->getByPie($venta->formaPago()->pie->asociado->id);
|
||||
foreach ($venta->formaPago()->pie->asociado->asociados() as $asociado) {
|
||||
if ($venta->formaPago()->pie->id === $asociado->id) {
|
||||
continue;
|
||||
}
|
||||
$asociadas []= $ventaService->getByPie($asociado->id);
|
||||
}
|
||||
}
|
||||
if (count($venta->formaPago()->pie->asociados()) > 0) {
|
||||
foreach ($venta->formaPago()->pie->asociados() as $asociado) {
|
||||
$asociadas []= $ventaService->getByPie($asociado->id);
|
||||
}
|
||||
}
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('venta', 'asociadas'));
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('venta'));
|
||||
}
|
||||
public function escriturar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
||||
Repository\Contabilidad\Banco $bancoRepository, View $view, int $venta_id): ResponseInterface
|
||||
public function escriturar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
|
||||
Repository\Banco $bancoRepository, View $view, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
$bancos = $bancoRepository->fetchAll();
|
||||
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
|
||||
usort($bancos, function(Model\Banco $a, Model\Banco $b) {
|
||||
return strcmp($a->nombre, $b->nombre);
|
||||
});
|
||||
return $view->render($response, 'ventas.escriturar', compact('venta', 'bancos'));
|
||||
|
@ -1,20 +1,19 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Creditos extends Controller
|
||||
{
|
||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Venta $ventaService, Repository\Contabilidad\Banco $bancoRepository,
|
||||
int $venta_id): ResponseInterface
|
||||
Repository\Venta $ventaRepository, Repository\Banco $bancoRepository,
|
||||
int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
$venta = $ventaRepository->fetchById($venta_id);
|
||||
$bancos = $bancoRepository->fetchAll('nombre');
|
||||
return $view->render($response, 'ventas.creditos', compact('venta', 'bancos'));
|
||||
}
|
||||
|
@ -2,13 +2,13 @@
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Cuotas
|
||||
{
|
||||
@ -73,12 +73,12 @@ class Cuotas
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Contabilidad\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
|
||||
{
|
||||
$pie = $pieService->getById($pie_id);
|
||||
$venta = $ventaRepository->fetchByPie($pie_id);
|
||||
$bancos = $bancoRepository->fetchAll();
|
||||
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
|
||||
usort($bancos, function(Model\Banco $a, Model\Banco $b) {
|
||||
return strcmp($a->nombre, $b->nombre);
|
||||
});
|
||||
return $view->render($response, 'ventas.pies.cuotas.add', compact('pie', 'venta', 'bancos'));
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class Escrituras
|
||||
{
|
||||
@ -22,8 +22,8 @@ class Escrituras
|
||||
return $view->render($response, 'ventas.escrituras.informe', compact('venta'));
|
||||
}
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Venta $ventaService, Repository\Contabilidad\Banco $bancoRepository,
|
||||
int $venta_id): ResponseInterface
|
||||
Service\Venta $ventaService, Repository\Banco $bancoRepository,
|
||||
int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
$bancos = $bancoRepository->fetchAll('nombre');
|
||||
|
@ -8,21 +8,14 @@ use Incoviba\Service;
|
||||
|
||||
class Facturacion
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Proyecto $proyectoService, Service\Proyecto\Terreno $terrenoService): ResponseInterface
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Proyecto $proyectoService): ResponseInterface
|
||||
{
|
||||
$proyectos = $proyectoService->getEscriturando();
|
||||
foreach ($proyectos as &$proyecto) {
|
||||
$proyecto->terreno = $terrenoService->valor($proyecto->id) ?? $proyecto->terreno;
|
||||
}
|
||||
return $view->render($response, 'ventas.facturacion', compact('proyectos'));
|
||||
}
|
||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Venta $ventaService, Service\Proyecto\Terreno $terrenoService,
|
||||
int $venta_id): ResponseInterface
|
||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Venta $ventaService, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
$terreno = $terrenoService->valor($venta->proyecto()->id);
|
||||
return $view->render($response, 'ventas.facturacion.show', compact('venta', 'terreno'));
|
||||
return $view->render($response, 'ventas.facturacion.show', compact('venta'));
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,23 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Service;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Pies
|
||||
{
|
||||
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService,
|
||||
Repository\Venta $ventaRepository, Repository\Contabilidad\Banco $bancoRepository,
|
||||
View $view, int $pie_id): ResponseInterface
|
||||
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
|
||||
{
|
||||
$pie = $pieService->getById($pie_id);
|
||||
$venta = $ventaRepository->fetchByPie($pie_id);
|
||||
$bancos = $bancoRepository->fetchAll();
|
||||
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
|
||||
usort($bancos, function(Model\Banco $a, Model\Banco $b) {
|
||||
return strcmp($a->nombre, $b->nombre);
|
||||
});
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('pie', 'venta', 'bancos', 'ventaRepository'));
|
||||
return $view->render($response, 'ventas.pies.cuotas', compact('pie', 'venta', 'bancos'));
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ use Incoviba\Service;
|
||||
|
||||
trait withRedis
|
||||
{
|
||||
public function fetchRedis(Service\Redis $redisService, string $redisKey, ?bool $asArray = null): mixed
|
||||
public function fetchRedis(Service\Redis $redisService, string $redisKey): mixed
|
||||
{
|
||||
$jsonString = $redisService->get($redisKey);
|
||||
if ($jsonString === null) {
|
||||
throw new EmptyRedis($redisKey);
|
||||
}
|
||||
return json_decode($jsonString, $asArray);
|
||||
return json_decode($jsonString);
|
||||
}
|
||||
public function saveRedis(Service\Redis $redisService, string $redisKey, mixed $value, ?int $expiration = null): void
|
||||
{
|
||||
|
@ -6,12 +6,10 @@ use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Incoviba\Exception\MissingAuthorizationHeader;
|
||||
use Incoviba\Service;
|
||||
|
||||
class API
|
||||
{
|
||||
public function __construct(protected ResponseFactoryInterface $responseFactory, protected Service\Login $loginService,
|
||||
protected string $key) {}
|
||||
public function __construct(protected ResponseFactoryInterface $responseFactory, protected string $key) {}
|
||||
|
||||
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
@ -20,7 +18,7 @@ class API
|
||||
} catch (MissingAuthorizationHeader $exception) {
|
||||
return $this->responseFactory->createResponse(401);
|
||||
}
|
||||
if ($this->validate($request, $key)) {
|
||||
if ($this->validate($key)) {
|
||||
return $handler->handle($request);
|
||||
}
|
||||
return $this->responseFactory->createResponse(403);
|
||||
@ -35,26 +33,8 @@ class API
|
||||
}
|
||||
throw new MissingAuthorizationHeader();
|
||||
}
|
||||
protected function validate(ServerRequestInterface $request, $incoming_key): bool
|
||||
protected function validate($incoming_key): bool
|
||||
{
|
||||
if (str_contains($incoming_key, $this->loginService->getSeparator())) {
|
||||
list($incoming_key, $selector, $token) = explode($this->loginService->getSeparator(), $incoming_key);
|
||||
if (!$this->loginService->isIn()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!$this->loginService->isIn() and !$this->validPermitted($request)) {
|
||||
return false;
|
||||
}
|
||||
return $incoming_key === md5($this->key);
|
||||
}
|
||||
protected function validPermitted(ServerRequestInterface $request): bool
|
||||
{
|
||||
$uri = $request->getUri();
|
||||
$validPaths = [
|
||||
'/api',
|
||||
'/api/'
|
||||
];
|
||||
return in_array($uri->getPath(), $validPaths);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class Authentication
|
||||
return $handler->handle($request);
|
||||
}
|
||||
$this->logger->notice("Not logged in.");
|
||||
$response = $this->responseFactory->createResponse(307, 'Not logged in')
|
||||
$response = $this->responseFactory->createResponse(301, 'Not logged in')
|
||||
->withHeader('Referer', (string) $request->getUri())
|
||||
->withHeader('X-Redirected-URI', (string) $request->getUri());
|
||||
$url = "{$request->getUri()}";
|
||||
@ -45,22 +45,13 @@ class Authentication
|
||||
]);
|
||||
|
||||
$valid_paths = [
|
||||
'/'
|
||||
'/',
|
||||
];
|
||||
if (in_array($current_path, $valid_paths, true)) {
|
||||
return true;
|
||||
}
|
||||
$valid_subpaths = [
|
||||
'/api/'
|
||||
];
|
||||
foreach ($valid_subpaths as $path) {
|
||||
if (str_starts_with($current_path, $path)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$valid_uris = [
|
||||
$this->login_url,
|
||||
"{$this->login_url}/",
|
||||
];
|
||||
if (in_array($current_url, $valid_uris, true)) {
|
||||
return true;
|
||||
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Middleware;
|
||||
|
||||
use Psr\Http\Message\ResponseFactoryInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
class CORS
|
||||
{
|
||||
public function __construct(protected ResponseFactoryInterface $responseFactory) {}
|
||||
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
if ($request->getMethod() === 'OPTIONS') {
|
||||
return $this->responseFactory->createResponse()
|
||||
->withHeader('Access-Control-Allow-Origin', '*')
|
||||
->withHeader('Access-Control-Allow-Methods', 'POST,GET,OPTIONS');
|
||||
}
|
||||
return $handler->handle($request);
|
||||
}
|
||||
}
|
@ -18,11 +18,11 @@ class Errors
|
||||
try {
|
||||
return $handler->handle($request);
|
||||
} catch (Exception $exception) {
|
||||
$this->logger->warning($exception);
|
||||
$this->logger->notice($exception);
|
||||
} catch (Error $error) {
|
||||
$this->logger->error($error);
|
||||
}
|
||||
$response = $this->responseFactory->createResponse(500, 'Internal Server Error');
|
||||
$response = $this->responseFactory->createResponse(600, 'Internal Server Error');
|
||||
if (str_contains($request->getUri()->getPath(), '/api')) {
|
||||
return $response;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use Incoviba\Common\Ideal\Model;
|
||||
|
@ -1,9 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model\Inmobiliaria;
|
||||
|
||||
class Cartola extends Ideal\Model
|
||||
{
|
5
app/src/Model/CategoriaCentro.php
Normal file
5
app/src/Model/CategoriaCentro.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
namespace Incoviba\Model;
|
||||
|
||||
class CategoriaCentro extends Tipo
|
||||
{}
|
@ -1,8 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model\TipoCuenta;
|
||||
|
||||
class CentroCosto extends Ideal\Model
|
||||
{
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
|
||||
use Incoviba\Model\Tipo;
|
||||
|
||||
class CategoriaCentro extends Tipo
|
||||
{}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
|
||||
use Incoviba\Model\Tipo;
|
||||
|
||||
class TipoCentro extends Tipo
|
||||
{}
|
@ -1,9 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model\Inmobiliaria;
|
||||
|
||||
class Deposito extends Ideal\Model
|
||||
{
|
@ -10,6 +10,8 @@ class Inmobiliaria extends Model
|
||||
public ?string $dv;
|
||||
public ?string $razon;
|
||||
public ?string $abreviacion;
|
||||
public ?string $cuenta;
|
||||
public ?Banco $banco;
|
||||
public ?TipoSociedad $tipoSociedad;
|
||||
|
||||
public function rut(): string
|
||||
@ -35,6 +37,8 @@ class Inmobiliaria extends Model
|
||||
'rut_formateado' => $this->rut(),
|
||||
'razon' => $this->razon ?? '',
|
||||
'abreviacion' => $this->abreviacion ?? '',
|
||||
'cuenta' => $this->cuenta ?? '',
|
||||
'banco' => $this->banco ?? '',
|
||||
'tipo_sociedad' => $this->tipoSociedad ?? ''
|
||||
];
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Agente extends Ideal\Model
|
||||
{
|
||||
public ?int $rut;
|
||||
public string $descripcion;
|
||||
public ?string $contacto;
|
||||
public ?int $telefono;
|
||||
public ?string $correo;
|
||||
public ?Model\Direccion $direccion;
|
||||
public ?string $giro;
|
||||
public string $abreviacion;
|
||||
|
||||
protected ?array $tiposAgentes;
|
||||
public function tipos(): ?array
|
||||
{
|
||||
if (!isset($this->tiposAgentes)) {
|
||||
$this->tiposAgentes = $this->runFactory('tipos_agentes');
|
||||
}
|
||||
return $this->tiposAgentes;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'rut' => $this->rut,
|
||||
'descripcion' => $this->descripcion,
|
||||
'contacto' => $this->contacto,
|
||||
'telefono' => $this->telefono,
|
||||
'correo' => $this->correo,
|
||||
'direccion' => $this->direccion,
|
||||
'giro' => $this->giro,
|
||||
'abreviacion' => $this->abreviacion,
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class AgenteTipo extends Ideal\Model
|
||||
{
|
||||
public Agente $agente;
|
||||
public TipoAgente $tipoAgente;
|
||||
}
|
@ -2,39 +2,14 @@
|
||||
namespace Incoviba\Model\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Cuenta extends Ideal\Model
|
||||
{
|
||||
public Model\Inmobiliaria $inmobiliaria;
|
||||
public Model\Contabilidad\Banco $banco;
|
||||
public Model\Banco $banco;
|
||||
public string $cuenta;
|
||||
|
||||
protected array $estados;
|
||||
public function getEstados(): array
|
||||
{
|
||||
if (!isset($this->estados)) {
|
||||
$this->estados = $this->runFactory('estados');
|
||||
}
|
||||
return $this->estados;
|
||||
}
|
||||
protected Model\Inmobiliaria\Cuenta\Estado $currentEstado;
|
||||
public function currentEstado(): Model\Inmobiliaria\Cuenta\Estado
|
||||
{
|
||||
if (!isset($this->currentEstado)) {
|
||||
$estados = $this->getEstados();
|
||||
if (count($estados) === 0) {
|
||||
throw new EmptyResult('Current Estado Cuenta');
|
||||
}
|
||||
usort($estados, function(Model\Inmobiliaria\Cuenta\Estado $a, Model\Inmobiliaria\Cuenta\Estado $b) {
|
||||
return $a->id - $b->id;
|
||||
});
|
||||
$this->currentEstado = end($estados);
|
||||
}
|
||||
return $this->currentEstado;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Inmobiliaria\Cuenta;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Estado extends Ideal\Model
|
||||
{
|
||||
public Model\Inmobiliaria\Cuenta $cuenta;
|
||||
public DateTimeInterface $fecha;
|
||||
public bool $active;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'cuenta_id' => $this->cuenta->id,
|
||||
'fecha' => $this->fecha->format('Y-m-d'),
|
||||
'active' => $this->active
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model;
|
||||
|
||||
class SociedadAgente extends Ideal\Model
|
||||
{
|
||||
public Model\Inmobiliaria $sociedad;
|
||||
public AgenteTipo $agenteTipo;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return [
|
||||
'sociedad_rut' => $this->sociedad->rut,
|
||||
'agente_tipo_id' => $this->agenteTipo->id
|
||||
];
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Inmobiliaria;
|
||||
|
||||
use Incoviba\Model;
|
||||
|
||||
class TipoAgente extends Model\Tipo
|
||||
{
|
||||
public string $icono;
|
||||
public string $color;
|
||||
public string $bgcolor;
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Model\Inmobiliaria;
|
||||
use Incoviba\Model\Movimiento\Detalle;
|
||||
|
||||
class Movimiento extends Ideal\Model
|
||||
@ -21,11 +19,7 @@ class Movimiento extends Ideal\Model
|
||||
public function getDetalles(): ?Detalle
|
||||
{
|
||||
if (!isset($this->detalles)) {
|
||||
try {
|
||||
$this->detalles = $this->runFactory('detalles');
|
||||
} catch (EmptyResult) {
|
||||
$this->detalles = null;
|
||||
}
|
||||
$this->detalles = $this->runFactory('detalles');
|
||||
}
|
||||
return $this->detalles;
|
||||
}
|
@ -6,8 +6,8 @@ use Incoviba\Model;
|
||||
|
||||
class Detalle extends Ideal\Model
|
||||
{
|
||||
public Model\Contabilidad\Movimiento $movimiento;
|
||||
public ?Model\Contabilidad\CentroCosto $centroCosto;
|
||||
public Model\Movimiento $movimiento;
|
||||
public ?Model\CentroCosto $centroCosto;
|
||||
public ?string $detalle;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model\Inmobiliaria;
|
||||
|
||||
class Nubox extends Ideal\Model
|
||||
{
|
@ -1,8 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Contabilidad;
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model\Venta;
|
||||
|
||||
class PagoCentroCosto extends Ideal\Model
|
||||
{
|
5
app/src/Model/TipoCentro.php
Normal file
5
app/src/Model/TipoCentro.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
namespace Incoviba\Model;
|
||||
|
||||
class TipoCentro extends Tipo
|
||||
{}
|
@ -3,6 +3,9 @@ namespace Incoviba\Model;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Controller\Ventas;
|
||||
use Incoviba\Model\Venta\FormaPago;
|
||||
use Incoviba\Model\Venta\Pago;
|
||||
|
||||
class Venta extends Ideal\Model
|
||||
{
|
||||
@ -15,7 +18,7 @@ class Venta extends Ideal\Model
|
||||
public bool $relacionado;
|
||||
protected ?Venta\Entrega $entrega;
|
||||
public float $uf;
|
||||
protected ?Venta\Pago $resciliacion;
|
||||
protected ?Pago $resciliacion;
|
||||
|
||||
public ?array $estados;
|
||||
public ?Venta\EstadoVenta $currentEstado;
|
||||
@ -41,11 +44,6 @@ class Venta extends Ideal\Model
|
||||
}
|
||||
return $this->formaPago;
|
||||
}
|
||||
public function setFormaPago(Venta\FormaPago $formaPago): Venta
|
||||
{
|
||||
$this->formaPago = $formaPago;
|
||||
return $this;
|
||||
}
|
||||
public function entrega(): ?Venta\Entrega
|
||||
{
|
||||
if (!isset($this->entrega)) {
|
||||
@ -96,9 +94,9 @@ class Venta extends Ideal\Model
|
||||
}
|
||||
return $this->valor_util;
|
||||
}
|
||||
public function saldo(string $moneda = Venta\Pago::UF): float
|
||||
public function saldo(string $moneda = Pago::UF): float
|
||||
{
|
||||
$valor = $this->valor * (($moneda === Venta\Pago::UF) ? 1 : $this->uf);
|
||||
$valor = $this->valor * (($moneda === Pago::UF) ? 1 : $this->uf);
|
||||
return $valor - $this->formaPago()->total($moneda);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ namespace Incoviba\Model\Venta;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal\Model;
|
||||
use Incoviba\Model\Contabilidad\Banco;
|
||||
use Incoviba\Model\Banco;
|
||||
|
||||
class Cuota extends Model
|
||||
{
|
||||
|
@ -3,7 +3,7 @@ namespace Incoviba\Model\Venta;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal\Model;
|
||||
use Incoviba\Model\Contabilidad\Banco;
|
||||
use Incoviba\Model\Banco;
|
||||
|
||||
class Pago extends Model
|
||||
{
|
||||
@ -28,27 +28,10 @@ class Pago extends Model
|
||||
return $this->valor / (($moneda === Pago::UF) ? $uf : 1);
|
||||
}
|
||||
|
||||
public function estado(?string $tipoEstado = null): ?EstadoPago
|
||||
{
|
||||
if (!isset($this->estados)) {
|
||||
return null;
|
||||
}
|
||||
if ($tipoEstado === null) {
|
||||
return $this->currentEstado;
|
||||
}
|
||||
foreach ($this->estados as $estado) {
|
||||
if ($estado->tipoEstado->descripcion === $tipoEstado) {
|
||||
return $estado;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'valor' => $this->valor,
|
||||
'valor_uf' => $this->valor(),
|
||||
'banco' => $this->banco ?? '',
|
||||
'tipo_pago' => $this->tipoPago ?? '',
|
||||
'identificador' => $this->identificador ?? '',
|
||||
|
@ -6,7 +6,8 @@ use Incoviba\Model;
|
||||
|
||||
class Propiedad extends Ideal\Model
|
||||
{
|
||||
public array $unidades = [];
|
||||
public array $unidades;
|
||||
|
||||
protected array $departamentos;
|
||||
public function departamentos(): array
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository\Contabilidad;
|
||||
namespace Incoviba\Repository;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
@ -17,7 +17,7 @@ class Banco extends Ideal\Repository
|
||||
public function create(?array $data = null): Define\Model
|
||||
{
|
||||
$map = new Implement\Repository\MapperParser(['nombre']);
|
||||
return $this->parseData(new Model\Contabilidad\Banco(), $data, $map);
|
||||
return $this->parseData(new Model\Banco(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
{
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository\Contabilidad;
|
||||
namespace Incoviba\Repository;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Define;
|
||||
@ -16,7 +16,7 @@ class Cartola extends Ideal\Repository
|
||||
$this->setTable('cartolas');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Contabilidad\Cartola
|
||||
public function create(?array $data = null): Model\Cartola
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['cargos', 'abonos', 'saldo']))
|
||||
->register('fecha', new Implement\Repository\Mapper\DateTime('fecha'))
|
||||
@ -25,9 +25,9 @@ class Cartola extends Ideal\Repository
|
||||
->setFunction(function($data) {
|
||||
return $this->cuentaRepository->fetchById($data['cuenta_id']);
|
||||
}));
|
||||
return $this->parseData(new Model\Contabilidad\Cartola(), $data, $map);
|
||||
return $this->parseData(new Model\Cartola(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Model\Contabilidad\Cartola
|
||||
public function save(Define\Model $model): Model\Cartola
|
||||
{
|
||||
$model->id = $this->saveNew([
|
||||
'cuenta_id',
|
||||
@ -44,7 +44,7 @@ class Cartola extends Ideal\Repository
|
||||
]);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Model\Contabilidad\Cartola
|
||||
public function edit(Define\Model $model, array $new_data): Model\Cartola
|
||||
{
|
||||
return $this->update($model, ['cuenta_id', 'fecha', 'cargos', 'abonos', 'saldo'], $new_data);
|
||||
}
|
||||
@ -57,7 +57,7 @@ class Cartola extends Ideal\Repository
|
||||
->where('fecha = ?');
|
||||
return $this->fetchMany($query, [$fecha->format('Y-m-d')]);
|
||||
}
|
||||
public function fetchByCuentaAndFecha(int $cuenta_id, DateTimeInterface $fecha): Model\Contabilidad\Cartola
|
||||
public function fetchByCuentaAndFecha(int $cuenta_id, DateTimeInterface $fecha): Model\Cartola
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
@ -65,14 +65,4 @@ class Cartola extends Ideal\Repository
|
||||
->where('cuenta_id = ? AND fecha = ?');
|
||||
return $this->fetchOne($query, [$cuenta_id, $fecha->format('Y-m-d')]);
|
||||
}
|
||||
public function fetchLastByCuentaAndFecha(int $cuenta_id, DateTimeInterface $fecha): Model\Contabilidad\Cartola
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('cuenta_id = ? AND fecha <= ?')
|
||||
->order('fecha DESC')
|
||||
->limit(1);
|
||||
return $this->fetchOne($query, [$cuenta_id, $fecha->format('Y-m-d')]);
|
||||
}
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository\Contabilidad;
|
||||
namespace Incoviba\Repository;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository\Tipo;
|
||||
|
||||
class CategoriaCentro extends Tipo
|
||||
{
|
||||
@ -15,6 +14,6 @@ class CategoriaCentro extends Tipo
|
||||
|
||||
protected function getBlank(): Define\Model
|
||||
{
|
||||
return new Model\Contabilidad\CategoriaCentro();
|
||||
return new Model\CategoriaCentro();
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository\Contabilidad;
|
||||
namespace Incoviba\Repository;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement\Repository\Mapper;
|
||||
use Incoviba\Common\Implement\Repository\MapperParser;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository\TipoCuenta;
|
||||
|
||||
class CentroCosto extends Ideal\Repository
|
||||
{
|
||||
@ -18,7 +18,7 @@ class CentroCosto extends Ideal\Repository
|
||||
$this->setTable('centros_costos');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Contabilidad\CentroCosto
|
||||
public function create(?array $data = null): Model\CentroCosto
|
||||
{
|
||||
$map = (new MapperParser(['descripcion']))
|
||||
->register('tipo_centro_id', (new Mapper())
|
||||
@ -39,9 +39,9 @@ class CentroCosto extends Ideal\Repository
|
||||
->setDefault(null))
|
||||
->register('cuenta_contable', (new Mapper())
|
||||
->setProperty('cuentaContable'));
|
||||
return $this->parseData(new Model\Contabilidad\CentroCosto(), $data, $map);
|
||||
return $this->parseData(new Model\CentroCosto(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Model\Contabilidad\CentroCosto
|
||||
public function save(Define\Model $model): Model\CentroCosto
|
||||
{
|
||||
$this->saveNew(
|
||||
['id', 'tipo_centro_id', 'categoria_id', 'tipo_cuenta_id', 'cuenta_contable', 'descripcion'],
|
||||
@ -49,12 +49,12 @@ class CentroCosto extends Ideal\Repository
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Model\Contabilidad\CentroCosto
|
||||
public function edit(Define\Model $model, array $new_data): Model\CentroCosto
|
||||
{
|
||||
return $this->update($model, ['tipo_centro_id', 'categoria_id', 'tipo_cuenta_id', 'cuenta_contable', 'descripcion'], $new_data);
|
||||
}
|
||||
|
||||
public function fetchByDescripcion(string $descripcion): Model\Contabilidad\CentroCosto
|
||||
public function fetchByDescripcion(string $descripcion): Model\CentroCosto
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository\Contabilidad;
|
||||
namespace Incoviba\Repository;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Deposito extends Ideal\Repository
|
||||
{
|
||||
@ -16,7 +16,7 @@ class Deposito extends Ideal\Repository
|
||||
$this->setTable('depositos');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Contabilidad\Deposito
|
||||
public function create(?array $data = null): Model\Deposito
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['id', 'capital', 'futuro']))
|
||||
->register('cuenta_id', (new Implement\Repository\Mapper())
|
||||
@ -26,9 +26,9 @@ class Deposito extends Ideal\Repository
|
||||
}))
|
||||
->register('inicio', new Implement\Repository\Mapper\DateTime('inicio'))
|
||||
->register('termino', new Implement\Repository\Mapper\DateTime('termino'));
|
||||
return $this->parseData(new Model\Contabilidad\Deposito(), $data, $map);
|
||||
return $this->parseData(new Model\Deposito(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Model\Contabilidad\Deposito
|
||||
public function save(Define\Model $model): Model\Deposito
|
||||
{
|
||||
$this->saveNew([
|
||||
'id', 'cuenta_id', 'capital', 'futuro', 'inicio', 'termino'
|
||||
@ -39,7 +39,7 @@ class Deposito extends Ideal\Repository
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function edit(Define\Model $model, array $new_data): Model\Contabilidad\Deposito
|
||||
public function edit(Define\Model $model, array $new_data): Model\Deposito
|
||||
{
|
||||
return $this->update($model, ['cuenta_id', 'capital', 'futuro', 'inicio', 'termino'], $new_data);
|
||||
}
|
@ -9,7 +9,7 @@ use Incoviba\Repository;
|
||||
|
||||
class Inmobiliaria extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection, protected Contabilidad\Banco $bancoRepository, protected Repository\Inmobiliaria\TipoSociedad $tipoSociedadRepository)
|
||||
public function __construct(Define\Connection $connection, protected Repository\Banco $bancoRepository, protected Repository\Inmobiliaria\TipoSociedad $tipoSociedadRepository)
|
||||
{
|
||||
parent::__construct($connection);
|
||||
$this->setTable('inmobiliaria');
|
||||
@ -20,9 +20,13 @@ class Inmobiliaria extends Ideal\Repository
|
||||
return 'rut';
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Inmobiliaria
|
||||
public function create(?array $data = null): Define\Model
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['dv', 'razon', 'abreviacion']))
|
||||
$map = (new Implement\Repository\MapperParser(['dv', 'razon', 'abreviacion', 'cuenta']))
|
||||
->register('banco', (new Implement\Repository\Mapper())
|
||||
->setFunction(function($data) {
|
||||
return $this->bancoRepository->fetchById($data['banco']);
|
||||
}))
|
||||
->register('sociedad', (new Implement\Repository\Mapper())
|
||||
->setProperty('tipoSociedad')
|
||||
->setFunction(function($data) {
|
||||
@ -30,7 +34,7 @@ class Inmobiliaria extends Ideal\Repository
|
||||
}));
|
||||
return $this->parseData(new Model\Inmobiliaria(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Model\Inmobiliaria
|
||||
public function save(Define\Model $model): Define\Model
|
||||
{
|
||||
$model->rut = $this->saveNew(
|
||||
['dv', 'razon', 'abreviacion', 'cuenta', 'banco', 'sociedad'],
|
||||
@ -38,7 +42,7 @@ class Inmobiliaria extends Ideal\Repository
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Model\Inmobiliaria
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
{
|
||||
return $this->update($model, ['dv', 'razon', 'abreviacion', 'cuenta', 'banco', 'sociedad'], $new_data);
|
||||
}
|
||||
|
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
|
||||
class Agente extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection, protected Repository\Direccion $direccionRepository, protected TipoAgente $tipoAgenteRepository)
|
||||
{
|
||||
parent::__construct($connection);
|
||||
$this->setTable('agente');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Inmobiliaria\Agente
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['rut', 'descripcion', 'telefono', 'correo', 'giro', 'abreviacion']))
|
||||
->register('representante', (new Implement\Repository\Mapper())
|
||||
->setProperty('contacto'))
|
||||
->register('direccion', (new Implement\Repository\Mapper())
|
||||
->setFunction(function(?array $data) {
|
||||
if ($data === null) {
|
||||
return null;
|
||||
}
|
||||
return $this->direccionRepository->fetchById($data['direccion']);
|
||||
}));
|
||||
return $this->parseData(new Model\Inmobiliaria\Agente(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Model\Inmobiliaria\Agente
|
||||
{
|
||||
$model->id = $this->saveNew([
|
||||
'rut', 'descripcion', 'representante', 'telefono', 'correo', 'giro', 'abreviacion'
|
||||
], [
|
||||
$model->rut, $model->descripcion, $model->contacto, $model->telefono, $model->correo, $model->giro, $model->abreviacion
|
||||
]);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Model\Inmobiliaria\Agente
|
||||
{
|
||||
return $this->update($model, [
|
||||
'rut', 'descripcion', 'representante', 'telefono', 'correo', 'giro', 'abreviacion'
|
||||
], $new_data);
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
|
||||
class AgenteTipo extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection, protected Agente $agenteRepository,
|
||||
protected TipoAgente $tipoAgenteRepository)
|
||||
{
|
||||
parent::__construct($connection);
|
||||
$this->setTable('agente_tipo');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Inmobiliaria\AgenteTipo
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser())
|
||||
->register('agente', (new Implement\Repository\Mapper())
|
||||
->setFunction(function(?array $data) {
|
||||
return ($data === null) ? null : $this->agenteRepository->fetchById($data['agente']);
|
||||
}))
|
||||
->register('tipo', (new Implement\Repository\Mapper())
|
||||
->setFunction(function(?array $data) {
|
||||
return ($data === null) ? null : $this->tipoAgenteRepository->fetchById($data['tipo']);
|
||||
}));
|
||||
return $this->parseData(new Model\Inmobiliaria\AgenteTipo(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Model\Inmobiliaria\AgenteTipo
|
||||
{
|
||||
$model->id = $this->saveNew(['agente', 'tipo'], [
|
||||
$model->agente->id, $model->agenteTipo->id
|
||||
]);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Model\Inmobiliaria\AgenteTipo
|
||||
{
|
||||
return $this->update($model, ['agente', 'tipo'], $new_data);
|
||||
}
|
||||
|
||||
public function fetchByAgente(int $agente_id): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('agente = ?');
|
||||
return $this->fetchMany($query, [$agente_id]);
|
||||
}
|
||||
public function fetchByTipo(int $tipo_agente_id): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('tipo = ?');
|
||||
return $this->fetchMany($query, [$tipo_agente_id]);
|
||||
}
|
||||
public function fetchByAgenteAndTipo(int $agente_id, int $tipo_agente_id): Model\Inmobiliaria\AgenteTipo
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('agente = ? AND tipo = ?');
|
||||
return $this->fetchOne($query, [$agente_id, $tipo_agente_id]);
|
||||
}
|
||||
}
|
@ -3,15 +3,16 @@ namespace Incoviba\Repository\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Common\Implement;
|
||||
use PhpParser\Node\Expr\BinaryOp\Mod;
|
||||
|
||||
class Cuenta extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection,
|
||||
protected Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
protected Repository\Contabilidad\Banco $bancoRepository)
|
||||
public function __construct(Define\Connection $connection,
|
||||
protected Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
protected Repository\Banco $bancoRepository)
|
||||
{
|
||||
parent::__construct($connection);
|
||||
$this->setTable('cuenta');
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user