Compare commits
5 Commits
444ff687fc
...
master
Author | SHA1 | Date | |
---|---|---|---|
6ddc48ec60 | |||
331ee1e584 | |||
24c17debf3 | |||
552fd0aa06 | |||
60faf293d4 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,5 +10,3 @@
|
|||||||
**/.idea/
|
**/.idea/
|
||||||
**/upload?/
|
**/upload?/
|
||||||
**/informe?/
|
**/informe?/
|
||||||
**/.phpunit.cache/
|
|
||||||
**/coverage/
|
|
||||||
|
@ -9,7 +9,6 @@ RUN pecl install xdebug-3.1.3 \
|
|||||||
&& docker-php-ext-enable xdebug
|
&& docker-php-ext-enable xdebug
|
||||||
|
|
||||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||||
COPY ./php-xdebug.ini /usr/local/etc/php/conf.d/docker-php-xdebug.ini
|
|
||||||
|
|
||||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
@ -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
|
interface Banco
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Process bank movements for database inserts
|
|
||||||
* @param UploadedFileInterface $file
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function process(UploadedFileInterface $file): array;
|
public function process(UploadedFileInterface $file): array;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
|||||||
{
|
{
|
||||||
public function process(UploadedFileInterface $file): array
|
public function process(UploadedFileInterface $file): array
|
||||||
{
|
{
|
||||||
$data = $this->handleFile($file);
|
$data = $this->parseFile($file);
|
||||||
$temp = [];
|
$temp = [];
|
||||||
$columns = $this->columnMap();
|
$columns = $this->columnMap();
|
||||||
foreach ($data as $row) {
|
foreach ($data as $row) {
|
||||||
@ -24,48 +24,11 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
|||||||
}
|
}
|
||||||
return $temp;
|
return $temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* There are banks that need some post-processing
|
|
||||||
* @param array $movimientos
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function processMovimientosDiarios(array $movimientos): array
|
public function processMovimientosDiarios(array $movimientos): array
|
||||||
{
|
{
|
||||||
return $movimientos;
|
return $movimientos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Move the UploadedFile into a temp file from getFilename and after parseFile remove temp file
|
|
||||||
* @param UploadedFileInterface $uploadedFile
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function handleFile(UploadedFileInterface $uploadedFile): array
|
|
||||||
{
|
|
||||||
$filename = $this->getFilename($uploadedFile);
|
|
||||||
$uploadedFile->moveTo($filename);
|
|
||||||
$data = $this->parseFile($filename);
|
|
||||||
unlink($filename);
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get filename where to move UploadedFile
|
|
||||||
* @param UploadedFileInterface $uploadedFile
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
abstract protected function getFilename(UploadedFileInterface $uploadedFile): string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping of uploaded file data columns to database columns
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
abstract protected function columnMap(): array;
|
abstract protected function columnMap(): array;
|
||||||
|
abstract protected function parseFile(UploadedFileInterface $uploadedFile): array;
|
||||||
/**
|
|
||||||
* Translate uploaded file data to database data
|
|
||||||
* @param string $filename
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
abstract protected function parseFile(string $filename): array;
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "incoviba/web",
|
"name": "incoviba/web",
|
||||||
"version": "2.0.0",
|
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"berrnd/slim-blade-view": "^1.0",
|
"berrnd/slim-blade-view": "^1.0",
|
||||||
@ -15,10 +14,8 @@
|
|||||||
"slim/slim": "^4.11"
|
"slim/slim": "^4.11"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fakerphp/faker": "^1.23",
|
|
||||||
"kint-php/kint": "^5.1",
|
"kint-php/kint": "^5.1",
|
||||||
"phpunit/phpunit": "^10.2",
|
"phpunit/phpunit": "^10.2"
|
||||||
"spatie/phpunit-watcher": "^1.23"
|
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@ -33,7 +30,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"sort-packages": true,
|
"sort-packages": true
|
||||||
"process-timeout": 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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=".phpunit.cache"
|
|
||||||
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="/logs/junit.xml" />
|
|
||||||
<teamcity outputFile="/logs/teamcity.txt" />
|
|
||||||
<testdoxHtml outputFile="/logs/testdox.html" />
|
|
||||||
<testdoxText outputFile="/logs/testdox.txt" />
|
|
||||||
</logging>
|
|
||||||
</phpunit>
|
|
@ -1,6 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
use Incoviba\Controller\API\Base;
|
|
||||||
|
|
||||||
$app->group('/api', function($app) {
|
$app->group('/api', function($app) {
|
||||||
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'api']);
|
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'api']);
|
||||||
if (file_exists($folder)) {
|
if (file_exists($folder)) {
|
||||||
@ -12,5 +10,4 @@ $app->group('/api', function($app) {
|
|||||||
include_once $file->getRealPath();
|
include_once $file->getRealPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$app->get('[/]', Base::class);
|
|
||||||
})->add($app->getContainer()->get(Incoviba\Middleware\API::class));
|
})->add($app->getContainer()->get(Incoviba\Middleware\API::class));
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
@extends('layout.base')
|
@extends('layout.base')
|
||||||
|
|
||||||
@push('page_styles')
|
|
||||||
<style>
|
|
||||||
tr.bold>th {
|
|
||||||
font-weight: bold !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@endpush
|
|
||||||
|
|
||||||
@section('page_content')
|
@section('page_content')
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<h1 class="ui centered header">Informe de Tesorería</h1>
|
<h1 class="ui centered header">Informe de Tesorería</h1>
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
<div class="column">
|
<div class="column">
|
||||||
Inmobiliarias
|
Inmobiliarias
|
||||||
</div>
|
</div>
|
||||||
|
{{--<div class="right aligned column">
|
||||||
|
<button class="ui icon button" type="button">
|
||||||
|
<i class="plus icon"></i>
|
||||||
|
</button>
|
||||||
|
</div>--}}
|
||||||
</h2>
|
</h2>
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
<div class="ui cards">
|
<div class="ui cards">
|
||||||
@ -17,7 +22,9 @@
|
|||||||
<div class="ui card">
|
<div class="ui card">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
{{$inmobiliaria->abreviacion}}
|
{{$inmobiliaria->abreviacion}}
|
||||||
|
{{--<a href="{{$urls->base}}/inmobiliaria/{{$inmobiliaria->rut}}">
|
||||||
|
</a>--}}
|
||||||
</div>
|
</div>
|
||||||
<div class="description">{{$inmobiliaria->razon}} {{$inmobiliaria->tipoSociedad->descripcion}}</div>
|
<div class="description">{{$inmobiliaria->razon}} {{$inmobiliaria->tipoSociedad->descripcion}}</div>
|
||||||
<div class="meta">{{$inmobiliaria->rut()}}</div>
|
<div class="meta">{{$inmobiliaria->rut()}}</div>
|
||||||
|
@ -2,13 +2,6 @@
|
|||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.js" integrity="sha512-gnoBksrDbaMnlE0rhhkcx3iwzvgBGz6mOEj4/Y5ZY09n55dYddx6+WYc72A55qEesV8VX2iMomteIwobeGK1BQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.js" integrity="sha512-gnoBksrDbaMnlE0rhhkcx3iwzvgBGz6mOEj4/Y5ZY09n55dYddx6+WYc72A55qEesV8VX2iMomteIwobeGK1BQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function cleanNoCache() {
|
|
||||||
const url = new URL(window.location.href)
|
|
||||||
if (url.searchParams.has('nocache')) {
|
|
||||||
url.searchParams.delete('nocache')
|
|
||||||
window.location.href = url.href
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function fetchAPI(url, options=null) {
|
function fetchAPI(url, options=null) {
|
||||||
if (options === null) {
|
if (options === null) {
|
||||||
options = {}
|
options = {}
|
||||||
@ -17,11 +10,7 @@
|
|||||||
options['headers'] = {}
|
options['headers'] = {}
|
||||||
}
|
}
|
||||||
if (!Object.hasOwn(options['headers'], 'Authorization')) {
|
if (!Object.hasOwn(options['headers'], 'Authorization')) {
|
||||||
@if (!$login->isIn())
|
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}'
|
||||||
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}'
|
|
||||||
@else
|
|
||||||
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}{{$login->getSeparator()}}{{$login->getToken()}}'
|
|
||||||
@endif
|
|
||||||
}
|
}
|
||||||
return fetch(url, options).then(response => {
|
return fetch(url, options).then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
@ -47,7 +36,6 @@
|
|||||||
date: 'DD-MM-YYYY'
|
date: 'DD-MM-YYYY'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cleanNoCache()
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@stack('page_scripts')
|
@stack('page_scripts')
|
||||||
|
@ -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
|
|
@ -16,33 +16,28 @@
|
|||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@include('layout.body.scripts.cryptojs')
|
|
||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function encryptPassword(password) {
|
|
||||||
const passphrase = Math.floor(Math.random() * Date.now()).toString()
|
|
||||||
const encrypted = CryptoJS.AES.encrypt(password, passphrase)
|
|
||||||
return [passphrase, encrypted.toString()].join('')
|
|
||||||
}
|
|
||||||
function sendLogin(name, password) {
|
function sendLogin(name, password) {
|
||||||
const method = 'post'
|
const data = new FormData()
|
||||||
const headers = {
|
data.append('name', name)
|
||||||
Accept: 'json'
|
data.append('password', password)
|
||||||
}
|
return fetch('{{$urls->base}}/login', {
|
||||||
const body = new FormData()
|
method: 'post',
|
||||||
body.append('name', name)
|
headers: {
|
||||||
body.append('password', encryptPassword(password))
|
Accept: 'json'
|
||||||
return fetch('{{$urls->base}}/login', {method, headers, body}).then(response => {
|
},
|
||||||
|
body: data
|
||||||
|
}).then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return response.json()
|
return response.json()
|
||||||
}
|
}
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
if (data.login === true) {
|
if (data.login === true) {
|
||||||
@if(isset($redirect_uri))
|
@if(isset($redirect_uri))
|
||||||
window.location = '{{$redirect_uri}}?nocache=' + (new Date()).getTime()
|
window.location = '{{$redirect_uri}}'
|
||||||
@else
|
@else
|
||||||
window.location = '{{$urls->base}}?nocache=' + (new Date()).getTime()
|
window.location = '{{$urls->base}}'
|
||||||
@endif
|
@endif
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="right aligned">
|
<td class="right aligned">
|
||||||
@if ($unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento')
|
@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
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td class="center aligned">
|
<td class="center aligned">
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
<?php
|
<?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));
|
|
@ -14,7 +14,6 @@ return [
|
|||||||
Incoviba\Middleware\API::class => function(ContainerInterface $container) {
|
Incoviba\Middleware\API::class => function(ContainerInterface $container) {
|
||||||
return new Incoviba\Middleware\API(
|
return new Incoviba\Middleware\API(
|
||||||
$container->get(Psr\Http\Message\ResponseFactoryInterface::class),
|
$container->get(Psr\Http\Message\ResponseFactoryInterface::class),
|
||||||
$container->get(Incoviba\Service\Login::class),
|
|
||||||
$container->get('API_KEY')
|
$container->get('API_KEY')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,7 @@ return [
|
|||||||
$container->get('COOKIE_NAME'),
|
$container->get('COOKIE_NAME'),
|
||||||
$container->get('MAX_LOGIN_HOURS'),
|
$container->get('MAX_LOGIN_HOURS'),
|
||||||
$container->has('COOKIE_DOMAIN') ? $container->get('COOKIE_DOMAIN') : '',
|
$container->has('COOKIE_DOMAIN') ? $container->get('COOKIE_DOMAIN') : '',
|
||||||
$container->has('COOKIE_PATH') ? $container->get('COOKIE_PATH') : '',
|
$container->has('COOKIE_PATH') ? $container->get('COOKIE_PATH') : ''
|
||||||
$container->has('COOKIE_SEPARATOR') ? $container->get('COOKIE_SEPARATOR') : 'g'
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
Incoviba\Service\Money::class => function(ContainerInterface $container) {
|
Incoviba\Service\Money::class => function(ContainerInterface $container) {
|
||||||
@ -46,8 +45,7 @@ return [
|
|||||||
))
|
))
|
||||||
->register('security', $container->get(Incoviba\Service\Cartola\Security::class))
|
->register('security', $container->get(Incoviba\Service\Cartola\Security::class))
|
||||||
->register('itau', $container->get(Incoviba\Service\Cartola\Itau::class))
|
->register('itau', $container->get(Incoviba\Service\Cartola\Itau::class))
|
||||||
->register('santander', $container->get(Incoviba\Service\Cartola\Santander::class))
|
->register('santander', $container->get(Incoviba\Service\Cartola\Santander::class));
|
||||||
->register('bci', $container->get(Incoviba\Service\Cartola\BCI::class));
|
|
||||||
},
|
},
|
||||||
Incoviba\Common\Define\Contabilidad\Exporter::class => function(ContainerInterface $container) {
|
Incoviba\Common\Define\Contabilidad\Exporter::class => function(ContainerInterface $container) {
|
||||||
return $container->get(Incoviba\Service\Contabilidad\Exporter\Nubox::class);
|
return $container->get(Incoviba\Service\Contabilidad\Exporter\Nubox::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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,16 +12,6 @@ class Inmobiliarias
|
|||||||
{
|
{
|
||||||
use withJson;
|
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,
|
public function cuentas(ServerRequestInterface $request, ResponseInterface $response,
|
||||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||||
Repository\Inmobiliaria\Cuenta $cuentaRepository, int $inmobiliaria_rut): ResponseInterface
|
Repository\Inmobiliaria\Cuenta $cuentaRepository, int $inmobiliaria_rut): ResponseInterface
|
||||||
|
@ -20,8 +20,8 @@ class Inmobiliarias
|
|||||||
$inmobiliarias = [];
|
$inmobiliarias = [];
|
||||||
try {
|
try {
|
||||||
$inmobiliarias = array_map(function($row) use ($inmobiliariaRepository) {
|
$inmobiliarias = array_map(function($row) use ($inmobiliariaRepository) {
|
||||||
return $inmobiliariaRepository->load($row);
|
return $inmobiliariaRepository->load((array) $row);
|
||||||
}, $this->fetchRedis($redisService, $redisKey, true));
|
}, $this->fetchRedis($redisService, $redisKey));
|
||||||
} catch (EmptyRedis) {
|
} catch (EmptyRedis) {
|
||||||
try {
|
try {
|
||||||
$inmobiliarias = $inmobiliariaRepository->fetchAll();
|
$inmobiliarias = $inmobiliariaRepository->fetchAll();
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Incoviba\Controller;
|
namespace Incoviba\Controller;
|
||||||
|
|
||||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
|
||||||
use PDOException;
|
use PDOException;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Incoviba\Common\Alias\View;
|
use Incoviba\Common\Alias\View;
|
||||||
use Incoviba\Common\Ideal\Controller;
|
|
||||||
use Incoviba\Repository;
|
use Incoviba\Repository;
|
||||||
use Incoviba\Service;
|
use Incoviba\Service;
|
||||||
|
|
||||||
class Login extends Controller
|
class Login
|
||||||
{
|
{
|
||||||
public function form(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Login $service): ResponseInterface
|
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
|
public function login(ServerRequestInterface $request, ResponseInterface $response, Repository\User $userRepository, Service\Login $service): ResponseInterface
|
||||||
{
|
{
|
||||||
$body = $request->getParsedBody();
|
$body = $request->getParsedBody();
|
||||||
|
$user = $userRepository->fetchByName($body['name']);
|
||||||
$output = [
|
$output = [
|
||||||
'name' => $body['name'],
|
'name' => $user->name,
|
||||||
'login' => false
|
'login' => false
|
||||||
];
|
];
|
||||||
|
if ($user->validate($body['password'])) {
|
||||||
try {
|
$output['login'] = $service->login($user);
|
||||||
$user = $userRepository->fetchByName($body['name']);
|
}
|
||||||
if ($service->validateUser($user, $body['password'])) {
|
|
||||||
$output['login'] = $service->login($user);
|
|
||||||
}
|
|
||||||
} catch (EmptyResult) {}
|
|
||||||
$response->getBody()->write(json_encode($output));
|
$response->getBody()->write(json_encode($output));
|
||||||
return $response->withHeader('Content-Type', 'application/json');
|
return $response->withHeader('Content-Type', 'application/json');
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,14 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||||||
use Incoviba\Common\Alias\View;
|
use Incoviba\Common\Alias\View;
|
||||||
use Incoviba\Common\Ideal\Controller;
|
use Incoviba\Common\Ideal\Controller;
|
||||||
use Incoviba\Repository;
|
use Incoviba\Repository;
|
||||||
use Incoviba\Service;
|
|
||||||
|
|
||||||
class Creditos extends Controller
|
class Creditos extends Controller
|
||||||
{
|
{
|
||||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||||
Service\Venta $ventaService, Repository\Banco $bancoRepository,
|
Repository\Venta $ventaRepository, Repository\Banco $bancoRepository,
|
||||||
int $venta_id): ResponseInterface
|
int $venta_id): ResponseInterface
|
||||||
{
|
{
|
||||||
$venta = $ventaService->getById($venta_id);
|
$venta = $ventaRepository->fetchById($venta_id);
|
||||||
$bancos = $bancoRepository->fetchAll('nombre');
|
$bancos = $bancoRepository->fetchAll('nombre');
|
||||||
return $view->render($response, 'ventas.creditos', compact('venta', 'bancos'));
|
return $view->render($response, 'ventas.creditos', compact('venta', 'bancos'));
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,13 @@ use Incoviba\Service;
|
|||||||
|
|
||||||
trait withRedis
|
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);
|
$jsonString = $redisService->get($redisKey);
|
||||||
if ($jsonString === null) {
|
if ($jsonString === null) {
|
||||||
throw new EmptyRedis($redisKey);
|
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
|
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\Message\ServerRequestInterface;
|
||||||
use Psr\Http\Server\RequestHandlerInterface;
|
use Psr\Http\Server\RequestHandlerInterface;
|
||||||
use Incoviba\Exception\MissingAuthorizationHeader;
|
use Incoviba\Exception\MissingAuthorizationHeader;
|
||||||
use Incoviba\Service;
|
|
||||||
|
|
||||||
class API
|
class API
|
||||||
{
|
{
|
||||||
public function __construct(protected ResponseFactoryInterface $responseFactory, protected Service\Login $loginService,
|
public function __construct(protected ResponseFactoryInterface $responseFactory, protected string $key) {}
|
||||||
protected string $key) {}
|
|
||||||
|
|
||||||
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||||
{
|
{
|
||||||
@ -20,7 +18,7 @@ class API
|
|||||||
} catch (MissingAuthorizationHeader $exception) {
|
} catch (MissingAuthorizationHeader $exception) {
|
||||||
return $this->responseFactory->createResponse(401);
|
return $this->responseFactory->createResponse(401);
|
||||||
}
|
}
|
||||||
if ($this->validate($request, $key)) {
|
if ($this->validate($key)) {
|
||||||
return $handler->handle($request);
|
return $handler->handle($request);
|
||||||
}
|
}
|
||||||
return $this->responseFactory->createResponse(403);
|
return $this->responseFactory->createResponse(403);
|
||||||
@ -35,26 +33,8 @@ class API
|
|||||||
}
|
}
|
||||||
throw new MissingAuthorizationHeader();
|
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);
|
return $incoming_key === md5($this->key);
|
||||||
}
|
}
|
||||||
protected function validPermitted(ServerRequestInterface $request): bool
|
|
||||||
{
|
|
||||||
$uri = $request->getUri();
|
|
||||||
$validPaths = [
|
|
||||||
'/api',
|
|
||||||
'/api/'
|
|
||||||
];
|
|
||||||
return in_array($uri->getPath(), $validPaths);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -45,22 +45,13 @@ class Authentication
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$valid_paths = [
|
$valid_paths = [
|
||||||
'/'
|
'/',
|
||||||
];
|
];
|
||||||
if (in_array($current_path, $valid_paths, true)) {
|
if (in_array($current_path, $valid_paths, true)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$valid_subpaths = [
|
|
||||||
'/api/'
|
|
||||||
];
|
|
||||||
foreach ($valid_subpaths as $path) {
|
|
||||||
if (str_starts_with($current_path, $path)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$valid_uris = [
|
$valid_uris = [
|
||||||
$this->login_url,
|
$this->login_url,
|
||||||
"{$this->login_url}/",
|
|
||||||
];
|
];
|
||||||
if (in_array($current_url, $valid_uris, true)) {
|
if (in_array($current_url, $valid_uris, true)) {
|
||||||
return 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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,6 +10,8 @@ class Inmobiliaria extends Model
|
|||||||
public ?string $dv;
|
public ?string $dv;
|
||||||
public ?string $razon;
|
public ?string $razon;
|
||||||
public ?string $abreviacion;
|
public ?string $abreviacion;
|
||||||
|
public ?string $cuenta;
|
||||||
|
public ?Banco $banco;
|
||||||
public ?TipoSociedad $tipoSociedad;
|
public ?TipoSociedad $tipoSociedad;
|
||||||
|
|
||||||
public function rut(): string
|
public function rut(): string
|
||||||
@ -35,6 +37,8 @@ class Inmobiliaria extends Model
|
|||||||
'rut_formateado' => $this->rut(),
|
'rut_formateado' => $this->rut(),
|
||||||
'razon' => $this->razon ?? '',
|
'razon' => $this->razon ?? '',
|
||||||
'abreviacion' => $this->abreviacion ?? '',
|
'abreviacion' => $this->abreviacion ?? '',
|
||||||
|
'cuenta' => $this->cuenta ?? '',
|
||||||
|
'banco' => $this->banco ?? '',
|
||||||
'tipo_sociedad' => $this->tipoSociedad ?? ''
|
'tipo_sociedad' => $this->tipoSociedad ?? ''
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ namespace Incoviba\Model;
|
|||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Incoviba\Common\Ideal;
|
use Incoviba\Common\Ideal;
|
||||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
|
||||||
use Incoviba\Model\Movimiento\Detalle;
|
use Incoviba\Model\Movimiento\Detalle;
|
||||||
|
|
||||||
class Movimiento extends Ideal\Model
|
class Movimiento extends Ideal\Model
|
||||||
@ -20,11 +19,7 @@ class Movimiento extends Ideal\Model
|
|||||||
public function getDetalles(): ?Detalle
|
public function getDetalles(): ?Detalle
|
||||||
{
|
{
|
||||||
if (!isset($this->detalles)) {
|
if (!isset($this->detalles)) {
|
||||||
try {
|
$this->detalles = $this->runFactory('detalles');
|
||||||
$this->detalles = $this->runFactory('detalles');
|
|
||||||
} catch (EmptyResult) {
|
|
||||||
$this->detalles = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $this->detalles;
|
return $this->detalles;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ namespace Incoviba\Model;
|
|||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Incoviba\Common\Ideal;
|
use Incoviba\Common\Ideal;
|
||||||
|
use Incoviba\Controller\Ventas;
|
||||||
|
use Incoviba\Model\Venta\FormaPago;
|
||||||
|
use Incoviba\Model\Venta\Pago;
|
||||||
|
|
||||||
class Venta extends Ideal\Model
|
class Venta extends Ideal\Model
|
||||||
{
|
{
|
||||||
@ -15,7 +18,7 @@ class Venta extends Ideal\Model
|
|||||||
public bool $relacionado;
|
public bool $relacionado;
|
||||||
protected ?Venta\Entrega $entrega;
|
protected ?Venta\Entrega $entrega;
|
||||||
public float $uf;
|
public float $uf;
|
||||||
protected ?Venta\Pago $resciliacion;
|
protected ?Pago $resciliacion;
|
||||||
|
|
||||||
public ?array $estados;
|
public ?array $estados;
|
||||||
public ?Venta\EstadoVenta $currentEstado;
|
public ?Venta\EstadoVenta $currentEstado;
|
||||||
@ -41,11 +44,6 @@ class Venta extends Ideal\Model
|
|||||||
}
|
}
|
||||||
return $this->formaPago;
|
return $this->formaPago;
|
||||||
}
|
}
|
||||||
public function setFormaPago(Venta\FormaPago $formaPago): Venta
|
|
||||||
{
|
|
||||||
$this->formaPago = $formaPago;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
public function entrega(): ?Venta\Entrega
|
public function entrega(): ?Venta\Entrega
|
||||||
{
|
{
|
||||||
if (!isset($this->entrega)) {
|
if (!isset($this->entrega)) {
|
||||||
@ -96,9 +94,9 @@ class Venta extends Ideal\Model
|
|||||||
}
|
}
|
||||||
return $this->valor_util;
|
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);
|
return $valor - $this->formaPago()->total($moneda);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@ use Incoviba\Model;
|
|||||||
|
|
||||||
class Propiedad extends Ideal\Model
|
class Propiedad extends Ideal\Model
|
||||||
{
|
{
|
||||||
public array $unidades = [];
|
public array $unidades;
|
||||||
|
|
||||||
protected array $departamentos;
|
protected array $departamentos;
|
||||||
public function departamentos(): array
|
public function departamentos(): array
|
||||||
{
|
{
|
||||||
|
@ -65,14 +65,4 @@ class Cartola extends Ideal\Repository
|
|||||||
->where('cuenta_id = ? AND fecha = ?');
|
->where('cuenta_id = ? AND fecha = ?');
|
||||||
return $this->fetchOne($query, [$cuenta_id, $fecha->format('Y-m-d')]);
|
return $this->fetchOne($query, [$cuenta_id, $fecha->format('Y-m-d')]);
|
||||||
}
|
}
|
||||||
public function fetchLastByCuentaAndFecha(int $cuenta_id, DateTimeInterface $fecha): Model\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')]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,13 @@ class Inmobiliaria extends Ideal\Repository
|
|||||||
return 'rut';
|
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())
|
->register('sociedad', (new Implement\Repository\Mapper())
|
||||||
->setProperty('tipoSociedad')
|
->setProperty('tipoSociedad')
|
||||||
->setFunction(function($data) {
|
->setFunction(function($data) {
|
||||||
@ -30,7 +34,7 @@ class Inmobiliaria extends Ideal\Repository
|
|||||||
}));
|
}));
|
||||||
return $this->parseData(new Model\Inmobiliaria(), $data, $map);
|
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(
|
$model->rut = $this->saveNew(
|
||||||
['dv', 'razon', 'abreviacion', 'cuenta', 'banco', 'sociedad'],
|
['dv', 'razon', 'abreviacion', 'cuenta', 'banco', 'sociedad'],
|
||||||
@ -38,7 +42,7 @@ class Inmobiliaria extends Ideal\Repository
|
|||||||
);
|
);
|
||||||
return $model;
|
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);
|
return $this->update($model, ['dv', 'razon', 'abreviacion', 'cuenta', 'banco', 'sociedad'], $new_data);
|
||||||
}
|
}
|
||||||
|
@ -132,9 +132,9 @@ class Venta extends Ideal\Repository
|
|||||||
['propietario', 'propiedad', 'pie', 'bono_pie', 'credito', 'escritura', 'subsidio', 'escriturado',
|
['propietario', 'propiedad', 'pie', 'bono_pie', 'credito', 'escritura', 'subsidio', 'escriturado',
|
||||||
'entrega', 'entregado', 'fecha', 'valor_uf', 'estado', 'fecha_ingreso', 'avalchile', 'agente', 'uf',
|
'entrega', 'entregado', 'fecha', 'valor_uf', 'estado', 'fecha_ingreso', 'avalchile', 'agente', 'uf',
|
||||||
'relacionado', 'promocion', 'resciliacion', 'devolucion'],
|
'relacionado', 'promocion', 'resciliacion', 'devolucion'],
|
||||||
[$model->propietario()->rut, $model->propiedad()->id, $model->formaPago()?->pie?->id, $model->formaPago()?->bonoPie?->id,
|
[$model->propietario()->rut, $model->propiedad()->id, $model->formaPago()->pie?->id, $model->formaPago()->bonoPie?->id,
|
||||||
$model->formaPago()?->credito?->id, $model->formaPago()?->escritura?->id, $model->formaPago()?->subsidio?->id,
|
$model->formaPago()->credito?->id, $model->formaPago()->escritura?->id, $model->formaPago()->subsidio?->id,
|
||||||
$model->formaPago()?->escritura !== null ? $model->formaPago()?->escritura->pago->fecha->format('Y-m-d') : null,
|
$model->formaPago()->escritura !== null ? $model->formaPago()->escritura->pago->fecha->format('Y-m-d') : null,
|
||||||
null, null, $model->fecha->format('Y-m-d'), $model->valor, 1, $model->fechaIngreso->format('Y-m-d'),
|
null, null, $model->fecha->format('Y-m-d'), $model->valor, 1, $model->fechaIngreso->format('Y-m-d'),
|
||||||
null, null, $model->uf, $model->relacionado ? 1 : 0, null, null, null]
|
null, null, $model->uf, $model->relacionado ? 1 : 0, null, null, null]
|
||||||
);
|
);
|
||||||
|
@ -18,23 +18,22 @@ class Propiedad extends Ideal\Repository
|
|||||||
public function create(?array $data = null): Model\Venta\Propiedad
|
public function create(?array $data = null): Model\Venta\Propiedad
|
||||||
{
|
{
|
||||||
$map = (new Implement\Repository\MapperParser())
|
$map = (new Implement\Repository\MapperParser())
|
||||||
|
->register('unidad_principal', (new Implement\Repository\Mapper())
|
||||||
|
->setProperty('unidades')
|
||||||
|
->setFunction(function($data) {
|
||||||
|
if (isset($data['id'])) {
|
||||||
|
return $this->unidadService->getByPropiedad($data['id']);
|
||||||
|
}
|
||||||
|
return [$this->unidadService->getById($data['unidad_principal'])];
|
||||||
|
}))
|
||||||
->register('estado', new Implement\Repository\Mapper\Boolean('estado'));
|
->register('estado', new Implement\Repository\Mapper\Boolean('estado'));
|
||||||
return $this->parseData(new Model\Venta\Propiedad(), $data, $map);
|
return $this->parseData(new Model\Venta\Propiedad(), $data, $map);
|
||||||
}
|
}
|
||||||
public function load(array $data_row): Define\Model
|
|
||||||
{
|
|
||||||
$propiedad = parent::load($data_row);
|
|
||||||
if (isset($propiedad->id)) {
|
|
||||||
$propiedad->unidades = $this->unidadService->getByPropiedad($propiedad->id);
|
|
||||||
}
|
|
||||||
return $propiedad;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Define\Model $model): Model\Venta\Propiedad
|
public function save(Define\Model $model): Model\Venta\Propiedad
|
||||||
{
|
{
|
||||||
$model->id = $this->saveNew(
|
$model->id = $this->saveNew(
|
||||||
['unidad_principal', 'estacionamientos', 'bodegas', 'estado'],
|
['unidad_principal', 'estacionamientos', 'bodegas', 'estado'],
|
||||||
[null,
|
[$model->departamentos()[0]->id,
|
||||||
implode(',', array_map(function(Model\Venta\Unidad $unidad) {return $unidad->id;}, $model->estacionamientos())),
|
implode(',', array_map(function(Model\Venta\Unidad $unidad) {return $unidad->id;}, $model->estacionamientos())),
|
||||||
implode(',', array_map(function(Model\Venta\Unidad $unidad) {return $unidad->id;}, $model->bodegas())),
|
implode(',', array_map(function(Model\Venta\Unidad $unidad) {return $unidad->id;}, $model->bodegas())),
|
||||||
1]
|
1]
|
||||||
|
@ -121,12 +121,7 @@ class Cartola extends Service
|
|||||||
} catch (Exception\EmptyResult $exception) {
|
} catch (Exception\EmptyResult $exception) {
|
||||||
$data['cuenta_id'] = $cuenta->id;
|
$data['cuenta_id'] = $cuenta->id;
|
||||||
$movimiento = $this->movimientoRepository->create($data);
|
$movimiento = $this->movimientoRepository->create($data);
|
||||||
try {
|
return $this->movimientoRepository->save($movimiento);
|
||||||
return $this->movimientoRepository->save($movimiento);
|
|
||||||
} catch (\PDOException $exception) {
|
|
||||||
$this->logger->critical(var_export($data,true));
|
|
||||||
throw $exception;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,87 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Incoviba\Service\Cartola;
|
|
||||||
|
|
||||||
use Psr\Http\Message\UploadedFileInterface;
|
|
||||||
use PhpOffice\PhpSpreadsheet;
|
|
||||||
use Incoviba\Common\Ideal\Cartola\Banco;
|
|
||||||
|
|
||||||
class BCI extends Banco
|
|
||||||
{
|
|
||||||
protected function columnMap(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'Fecha Transacción' => 'fecha',
|
|
||||||
'Cargo $ (-)' => 'cargo',
|
|
||||||
'Abono $ (+)' => 'abono',
|
|
||||||
'Descripción' => 'descripcion',
|
|
||||||
'Saldo' => 'saldo'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
protected function getFilename(UploadedFileInterface $uploadedFile): string
|
|
||||||
{
|
|
||||||
return '/tmp/cartola.xlsx';
|
|
||||||
}
|
|
||||||
protected function parseFile(string $filename): array
|
|
||||||
{
|
|
||||||
$xlsx = @PhpSpreadsheet\IOFactory::load($filename);
|
|
||||||
$worksheet = $xlsx->getActiveSheet();
|
|
||||||
$rows = $worksheet->getRowIterator();
|
|
||||||
|
|
||||||
$rows->seek(3);
|
|
||||||
$row = $rows->current();
|
|
||||||
$columnIterator = $row->getColumnIterator();
|
|
||||||
$saldoFinal = 0;
|
|
||||||
foreach ($columnIterator as $column) {
|
|
||||||
if ($column->getValue() === null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($column->getCalculatedValue() === 'Saldo Contable') {
|
|
||||||
$columnIterator->next();
|
|
||||||
$column = $columnIterator->current();
|
|
||||||
$saldoFinal = (int) str_replace('.', '', $column->getCalculatedValue());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$saldo = $saldoFinal;
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
$columns = [];
|
|
||||||
$dataFound = false;
|
|
||||||
foreach ($rows as $row) {
|
|
||||||
if (!$dataFound and $worksheet->getCell([1, $row->getRowIndex()])->getCalculatedValue() !== null
|
|
||||||
and trim($worksheet->getCell([1, $row->getRowIndex()])->getCalculatedValue()) === 'Fecha Contable') {
|
|
||||||
$dataFound = true;
|
|
||||||
$columns = $this->getRowData($row);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!$dataFound) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($worksheet->getCell([1, $row->getRowIndex()])->getValue() === null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$rowData = $this->getRowData($row);
|
|
||||||
$rowData = array_combine($columns, $rowData);
|
|
||||||
$rowData['Fecha Transacción'] = implode('-', array_reverse(explode('/', $rowData['Fecha Transacción'])));
|
|
||||||
$rowData['Cargo $ (-)'] = (int) str_replace('.', '', $rowData['Cargo $ (-)'] ?? 0);
|
|
||||||
$rowData['Abono $ (+)'] = (int) str_replace('.', '', $rowData['Abono $ (+)'] ?? 0);
|
|
||||||
$saldo = $saldo + $rowData['Cargo $ (-)'] - $rowData['Abono $ (+)'];
|
|
||||||
$rowData['Saldo'] = $saldo;
|
|
||||||
unset($rowData['']);
|
|
||||||
|
|
||||||
$data []= $rowData;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getRowData(PhpSpreadsheet\Worksheet\Row $row): array
|
|
||||||
{
|
|
||||||
$data = [];
|
|
||||||
$cells = $row->getColumnIterator();
|
|
||||||
foreach ($cells as $cell) {
|
|
||||||
$data []= $cell->getCalculatedValue();
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,12 +29,12 @@ class Itau extends Banco
|
|||||||
'Saldos' => 'saldo'
|
'Saldos' => 'saldo'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
protected function getFilename(UploadedFileInterface $uploadedFile): string
|
|
||||||
{
|
protected function parseFile(UploadedFileInterface $uploadedFile): array
|
||||||
return '/tmp/cartola.xls';
|
|
||||||
}
|
|
||||||
protected function parseFile(string $filename): array
|
|
||||||
{
|
{
|
||||||
|
$filename = '/tmp/cartola.xls';
|
||||||
|
$uploadedFile->moveTo($filename);
|
||||||
|
|
||||||
$reader = PhpSpreadsheet\IOFactory::createReader('Xls');
|
$reader = PhpSpreadsheet\IOFactory::createReader('Xls');
|
||||||
$xlsx = $reader->load($filename);
|
$xlsx = $reader->load($filename);
|
||||||
$sheet = $xlsx->getActiveSheet();
|
$sheet = $xlsx->getActiveSheet();
|
||||||
@ -51,6 +51,8 @@ class Itau extends Banco
|
|||||||
}
|
}
|
||||||
} catch (PhpSpreadsheet\Exception $exception) {
|
} catch (PhpSpreadsheet\Exception $exception) {
|
||||||
$this->logger->critical($exception);
|
$this->logger->critical($exception);
|
||||||
|
} finally {
|
||||||
|
unlink($filename);
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ class Santander extends Banco
|
|||||||
{
|
{
|
||||||
protected function columnMap(): array
|
protected function columnMap(): array
|
||||||
{
|
{
|
||||||
|
// MONTO DESCRIPCIÓN MOVIMIENTO FECHA N° DOCUMENTO SUCURSAL CARGO/ABONO
|
||||||
return [
|
return [
|
||||||
'cargo' => 'cargo',
|
'cargo' => 'cargo',
|
||||||
'abono' => 'abono',
|
'abono' => 'abono',
|
||||||
@ -24,13 +25,11 @@ class Santander extends Banco
|
|||||||
'Saldo Diario' => 'saldo'
|
'Saldo Diario' => 'saldo'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
protected function getFilename(UploadedFileInterface $uploadedFile): string
|
protected function parseFile(UploadedFileInterface $uploadedFile): array
|
||||||
{
|
{
|
||||||
return '/tmp/cartola.xlsx';
|
$filename = '/tmp/cartola.xlsx';
|
||||||
}
|
$uploadedFile->moveTo($filename);
|
||||||
|
|
||||||
protected function parseFile(string $filename): array
|
|
||||||
{
|
|
||||||
$reader = PhpSpreadsheet\IOFactory::createReader('Xlsx');
|
$reader = PhpSpreadsheet\IOFactory::createReader('Xlsx');
|
||||||
try {
|
try {
|
||||||
$xlsx = $reader->load($filename);
|
$xlsx = $reader->load($filename);
|
||||||
|
@ -16,21 +16,14 @@ class Security extends Banco
|
|||||||
return $movimientos;
|
return $movimientos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getFilename(UploadedFileInterface $uploadedFile): string
|
protected function parseFile(UploadedFileInterface $uploadedFile): array
|
||||||
{
|
{
|
||||||
$stream = $uploadedFile->getStream();
|
$stream = $uploadedFile->getStream();
|
||||||
$stream->seek(3);
|
$stream->seek(3);
|
||||||
if ($stream->read(strlen('table')) === 'table') {
|
if ($stream->read(strlen('table')) === 'table') {
|
||||||
return '/tmp/cartola.htm';
|
return $this->processHtm($uploadedFile);
|
||||||
}
|
}
|
||||||
return '/tmp/cartola.xls';
|
return $this->processXls($uploadedFile);
|
||||||
}
|
|
||||||
protected function parseFile(string $filename): array
|
|
||||||
{
|
|
||||||
if (str_ends_with($filename, '.htm')) {
|
|
||||||
return $this->processHtm($filename);
|
|
||||||
}
|
|
||||||
return $this->processXls($filename);
|
|
||||||
}
|
}
|
||||||
protected function columnMap(): array
|
protected function columnMap(): array
|
||||||
{
|
{
|
||||||
@ -45,8 +38,10 @@ class Security extends Banco
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processXls(string $filename): array
|
private function processXls(UploadedFileInterface $file): array
|
||||||
{
|
{
|
||||||
|
$filename = '/tmp/cartola.xls';
|
||||||
|
$file->moveTo($filename);
|
||||||
$xlsx = @PhpSpreadsheet\IOFactory::load($filename);
|
$xlsx = @PhpSpreadsheet\IOFactory::load($filename);
|
||||||
$worksheet = $xlsx->getActiveSheet();
|
$worksheet = $xlsx->getActiveSheet();
|
||||||
$rows = $worksheet->getRowIterator(3);
|
$rows = $worksheet->getRowIterator(3);
|
||||||
@ -87,10 +82,14 @@ class Security extends Banco
|
|||||||
$data []= $rowData;
|
$data []= $rowData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
unlink($filename);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
private function processHtm(string $filename): array
|
private function processHtm(UploadedFileInterface $file): array
|
||||||
{
|
{
|
||||||
|
$filename = '/tmp/cartola.htm';
|
||||||
|
$file->moveTo($filename);
|
||||||
|
|
||||||
$domDocument = new DOMDocument();
|
$domDocument = new DOMDocument();
|
||||||
$domDocument->loadHTML('<body>' . file_get_contents($filename) . '</body>');
|
$domDocument->loadHTML('<body>' . file_get_contents($filename) . '</body>');
|
||||||
|
|
||||||
@ -123,6 +122,7 @@ class Security extends Banco
|
|||||||
}
|
}
|
||||||
$data []= $rowData;
|
$data []= $rowData;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,14 +228,12 @@ class Tesoreria extends Ideal\Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Implement\Exception\EmptyResult) {}
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
$anterior = $this->getAnterior($fecha);
|
|
||||||
try {
|
try {
|
||||||
$cartola = $this->cartolaRepository->fetchLastByCuentaAndFecha($cuenta->id, $fecha);
|
$cartola = $this->cartolaRepository->fetchByCuentaAndFecha($cuenta->id, $fecha);
|
||||||
$data->actual = $cartola->saldo;
|
$data->actual = $cartola->saldo;
|
||||||
//$anterior = $this->getAnterior($cartola->fecha);
|
|
||||||
} catch (Implement\Exception\EmptyResult) {}
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
try {
|
try {
|
||||||
$cartola = $this->cartolaRepository->fetchLastByCuentaAndFecha($cuenta->id, $anterior);
|
$cartola = $this->cartolaRepository->fetchByCuentaAndFecha($cuenta->id, $this->getAnterior($fecha));
|
||||||
$data->anterior = $cartola->saldo;
|
$data->anterior = $cartola->saldo;
|
||||||
} catch (Implement\Exception\EmptyResult) {}
|
} catch (Implement\Exception\EmptyResult) {}
|
||||||
if ($data->diferencia() !== 0) {
|
if ($data->diferencia() !== 0) {
|
||||||
@ -291,4 +289,5 @@ class Tesoreria extends Ideal\Service
|
|||||||
$this->totales->{$tipo} += $total;
|
$this->totales->{$tipo} += $total;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,24 +47,7 @@ class Login
|
|||||||
}
|
}
|
||||||
return $login->user;
|
return $login->user;
|
||||||
}
|
}
|
||||||
public function getToken(): string
|
|
||||||
{
|
|
||||||
return implode($this->cookie_separator, [$this->selector, $this->token]);
|
|
||||||
}
|
|
||||||
public function getSeparator(): string
|
|
||||||
{
|
|
||||||
return $this->cookie_separator;
|
|
||||||
}
|
|
||||||
public function validateUser(Model\User $user, string $encryptedPassword): bool
|
|
||||||
{
|
|
||||||
list($passphrase, $encrypted) = $this->splitPassword($encryptedPassword);
|
|
||||||
try {
|
|
||||||
$password = $this->cryptoJs_aes_decrypt($encrypted, $passphrase);
|
|
||||||
} catch (Exception) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return $user->validate($password);
|
|
||||||
}
|
|
||||||
public function login(Model\User $user): bool
|
public function login(Model\User $user): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -121,12 +104,9 @@ class Login
|
|||||||
setcookie(
|
setcookie(
|
||||||
$this->cookie_name,
|
$this->cookie_name,
|
||||||
implode($this->cookie_separator, [$selector, $token]),
|
implode($this->cookie_separator, [$selector, $token]),
|
||||||
[
|
$expires->getTimestamp(),
|
||||||
'expires' => $expires->getTimestamp(),
|
$this->path,
|
||||||
'path' => $this->path,
|
$this->domain
|
||||||
'domain' => $this->domain,
|
|
||||||
'samesite' => 'Strict'
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
$this->selector = $selector;
|
$this->selector = $selector;
|
||||||
$this->token = $token;
|
$this->token = $token;
|
||||||
@ -146,70 +126,10 @@ class Login
|
|||||||
{
|
{
|
||||||
return password_verify($this->token, $login->token);
|
return password_verify($this->token, $login->token);
|
||||||
}
|
}
|
||||||
protected function generateToken(Model\Login $login): array
|
protected function generateToken(Model\Login $login)
|
||||||
{
|
{
|
||||||
$selector = bin2hex(random_bytes(12));
|
$selector = bin2hex(random_bytes(12));
|
||||||
$token = bin2hex(random_bytes(20));
|
$token = bin2hex(random_bytes(20));
|
||||||
return ['selector' => $selector, 'token' => $token];
|
return ['selector' => $selector, 'token' => $token];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function splitPassword(string $input): array
|
|
||||||
{
|
|
||||||
$ini = strpos($input, 'U');
|
|
||||||
$passphrase = substr($input, 0, $ini);
|
|
||||||
$message = substr($input, $ini);
|
|
||||||
return [$passphrase, $message];
|
|
||||||
}
|
|
||||||
protected function cryptoJs_aes_decrypt($data, $key): string
|
|
||||||
{
|
|
||||||
$data = base64_decode($data);
|
|
||||||
if (substr($data, 0, 8) != "Salted__") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$salt = substr($data, 8, 8);
|
|
||||||
$keyAndIV = $this->aes_evpKDF($key, $salt);
|
|
||||||
$decrypted = openssl_decrypt(
|
|
||||||
substr($data, 16),
|
|
||||||
"aes-256-cbc",
|
|
||||||
$keyAndIV["key"],
|
|
||||||
OPENSSL_RAW_DATA, // base64 was already decoded
|
|
||||||
$keyAndIV["iv"]
|
|
||||||
);
|
|
||||||
if ($decrypted === false) {
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
return $decrypted;
|
|
||||||
}
|
|
||||||
protected function aes_evpKDF($password, $salt, $keySize = 8, $ivSize = 4, $iterations = 1, $hashAlgorithm = "md5"): array
|
|
||||||
{
|
|
||||||
$targetKeySize = $keySize + $ivSize;
|
|
||||||
$derivedBytes = "";
|
|
||||||
$numberOfDerivedWords = 0;
|
|
||||||
$block = NULL;
|
|
||||||
$hasher = hash_init($hashAlgorithm);
|
|
||||||
while ($numberOfDerivedWords < $targetKeySize) {
|
|
||||||
if ($block != NULL) {
|
|
||||||
hash_update($hasher, $block);
|
|
||||||
}
|
|
||||||
hash_update($hasher, $password);
|
|
||||||
hash_update($hasher, $salt);
|
|
||||||
$block = hash_final($hasher, TRUE);
|
|
||||||
$hasher = hash_init($hashAlgorithm);
|
|
||||||
|
|
||||||
// Iterations
|
|
||||||
for ($i = 1; $i < $iterations; $i++) {
|
|
||||||
hash_update($hasher, $block);
|
|
||||||
$block = hash_final($hasher, TRUE);
|
|
||||||
$hasher = hash_init($hashAlgorithm);
|
|
||||||
}
|
|
||||||
|
|
||||||
$derivedBytes .= substr($block, 0, min(strlen($block), ($targetKeySize - $numberOfDerivedWords) * 4));
|
|
||||||
|
|
||||||
$numberOfDerivedWords += strlen($block) / 4;
|
|
||||||
}
|
|
||||||
return array(
|
|
||||||
"key" => substr($derivedBytes, 0, $keySize * 4),
|
|
||||||
"iv" => substr($derivedBytes, $keySize * 4, $ivSize * 4)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class Venta extends Service
|
|||||||
$data['uf'] = $this->moneyService->getUF($fecha);
|
$data['uf'] = $this->moneyService->getUF($fecha);
|
||||||
$propietario = $this->addPropietario($data);
|
$propietario = $this->addPropietario($data);
|
||||||
$propiedad = $this->addPropiedad($data);
|
$propiedad = $this->addPropiedad($data);
|
||||||
$formaPago = $this->addFormaPago($data);
|
$forma_pago = $this->addFormaPago($data);
|
||||||
$venta_data = [
|
$venta_data = [
|
||||||
'propietario' => $propietario->rut,
|
'propietario' => $propietario->rut,
|
||||||
'propiedad' => $propiedad->id,
|
'propiedad' => $propiedad->id,
|
||||||
@ -116,15 +116,14 @@ class Venta extends Service
|
|||||||
$map = ['pie', 'subsidio', 'credito', 'bono_pie'];
|
$map = ['pie', 'subsidio', 'credito', 'bono_pie'];
|
||||||
foreach ($map as $field) {
|
foreach ($map as $field) {
|
||||||
$name = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $field))));
|
$name = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $field))));
|
||||||
if (isset($formaPago->{$name})) {
|
if (isset($forma_pago->{$name})) {
|
||||||
$venta_data[$field] = $formaPago->{$name}->id;
|
$venta_data[$field] = $forma_pago->{$name}->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return $this->ventaRepository->fetchByPropietarioAndPropiedad($propietario->rut, $propiedad->id);
|
return $this->ventaRepository->fetchByPropietarioAndPropiedad($propietario->rut, $propiedad->id);
|
||||||
} catch (Implement\Exception\EmptyResult) {
|
} catch (Implement\Exception\EmptyResult) {
|
||||||
$venta = $this->ventaRepository->create($venta_data);
|
$venta = $this->ventaRepository->create($venta_data);
|
||||||
$venta->setFormaPago($formaPago);
|
|
||||||
$venta = $this->ventaRepository->save($venta);
|
$venta = $this->ventaRepository->save($venta);
|
||||||
|
|
||||||
$tipoEstado = $this->tipoEstadoVentaRepository->fetchByDescripcion('vigente');
|
$tipoEstado = $this->tipoEstadoVentaRepository->fetchByDescripcion('vigente');
|
||||||
@ -232,7 +231,7 @@ class Venta extends Service
|
|||||||
protected function addPropiedad(array $data): Model\Venta\Propiedad
|
protected function addPropiedad(array $data): Model\Venta\Propiedad
|
||||||
{
|
{
|
||||||
$ids = array_filter($data, function($key) {
|
$ids = array_filter($data, function($key) {
|
||||||
return str_starts_with($key, 'unidad');
|
return str_contains($key, 'unidad');
|
||||||
}, ARRAY_FILTER_USE_KEY);
|
}, ARRAY_FILTER_USE_KEY);
|
||||||
|
|
||||||
return $this->propiedadService->addPropiedad($ids);
|
return $this->propiedadService->addPropiedad($ids);
|
||||||
@ -240,7 +239,85 @@ class Venta extends Service
|
|||||||
protected function addFormaPago(array $data): Model\Venta\FormaPago
|
protected function addFormaPago(array $data): Model\Venta\FormaPago
|
||||||
{
|
{
|
||||||
return $this->formaPagoService->add($data);
|
return $this->formaPagoService->add($data);
|
||||||
|
/*$fields = [
|
||||||
|
'pie',
|
||||||
|
'subsidio',
|
||||||
|
'credito',
|
||||||
|
'bono_pie'
|
||||||
|
];
|
||||||
|
$forma_pago = new Model\Venta\FormaPago();
|
||||||
|
foreach ($fields as $name) {
|
||||||
|
if (isset($data["has_{$name}"])) {
|
||||||
|
$method = 'add' . str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
|
||||||
|
$obj = $this->{$method}($data);
|
||||||
|
$forma_pago->{$name} = $obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $forma_pago;*/
|
||||||
}
|
}
|
||||||
|
/*protected function addPie(array $data): Model\Venta\Pie
|
||||||
|
{
|
||||||
|
$fields = array_fill_keys([
|
||||||
|
'fecha_venta',
|
||||||
|
'pie',
|
||||||
|
'cuotas',
|
||||||
|
'uf'
|
||||||
|
], 0);
|
||||||
|
$filtered_data = array_intersect_key($data, $fields);
|
||||||
|
$mapped_data = array_combine([
|
||||||
|
'fecha',
|
||||||
|
'valor',
|
||||||
|
'cuotas',
|
||||||
|
'uf'
|
||||||
|
], $filtered_data);
|
||||||
|
$mapped_data['valor'] = $this->cleanValue($mapped_data['valor']);
|
||||||
|
return $this->pieService->add($mapped_data);
|
||||||
|
}
|
||||||
|
protected function addSubsidio(array $data): Model\Venta\Subsidio
|
||||||
|
{
|
||||||
|
$fields = array_fill_keys([
|
||||||
|
'fecha_venta',
|
||||||
|
'ahorro',
|
||||||
|
'subsidio',
|
||||||
|
'uf'
|
||||||
|
], 0);
|
||||||
|
$filtered_data = array_intersect_key($data, $fields);
|
||||||
|
$mapped_data = array_combine([
|
||||||
|
'fecha',
|
||||||
|
'ahorro',
|
||||||
|
'subsidio',
|
||||||
|
'uf'
|
||||||
|
], $filtered_data);
|
||||||
|
return $this->subsidioService->add($mapped_data);
|
||||||
|
}
|
||||||
|
protected function addCredito(array $data): Model\Venta\Credito
|
||||||
|
{
|
||||||
|
$fields = array_fill_keys([
|
||||||
|
'fecha_venta',
|
||||||
|
'credito',
|
||||||
|
'uf'
|
||||||
|
], 0);
|
||||||
|
$filtered_data = array_intersect_key($data, $fields);
|
||||||
|
$mapped_data = array_combine([
|
||||||
|
'fecha',
|
||||||
|
'valor',
|
||||||
|
'uf'
|
||||||
|
], $filtered_data);
|
||||||
|
return $this->creditoService->add($mapped_data);
|
||||||
|
}
|
||||||
|
protected function addBonoPie(array $data): Model\Venta\BonoPie
|
||||||
|
{
|
||||||
|
$fields = array_fill_keys([
|
||||||
|
'fecha_venta',
|
||||||
|
'bono_pie'
|
||||||
|
], 0);
|
||||||
|
$filtered_data = array_intersect_key($data, $fields);
|
||||||
|
$mapped_data = array_combine([
|
||||||
|
'fecha',
|
||||||
|
'valor'
|
||||||
|
], $filtered_data);
|
||||||
|
return $this->bonoPieService->add($mapped_data);
|
||||||
|
}*/
|
||||||
protected function addEstado(Model\Venta $venta, Model\Venta\TipoEstadoVenta $tipoEstadoVenta, array $data): void
|
protected function addEstado(Model\Venta $venta, Model\Venta\TipoEstadoVenta $tipoEstadoVenta, array $data): void
|
||||||
{
|
{
|
||||||
$fecha = new DateTimeImmutable($data['fecha']);
|
$fecha = new DateTimeImmutable($data['fecha']);
|
||||||
|
@ -75,11 +75,10 @@ class Cuota
|
|||||||
}
|
}
|
||||||
public function getByPie(int $pie_id): array
|
public function getByPie(int $pie_id): array
|
||||||
{
|
{
|
||||||
try {
|
return $this->cuotaRepository->fetchByPie($pie_id);
|
||||||
return $this->cuotaRepository->fetchByPie($pie_id);
|
/*return array_filter($this->cuotaRepository->fetchByPie($pie_id), function(Model\Venta\Cuota $cuota) {
|
||||||
} catch (EmptyResult) {
|
return !in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado']);
|
||||||
return [];
|
});*/
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public function getVigenteByPie(int $pie_id): array
|
public function getVigenteByPie(int $pie_id): array
|
||||||
{
|
{
|
||||||
|
@ -77,6 +77,7 @@ class FormaPago extends Ideal\Service
|
|||||||
'uf'
|
'uf'
|
||||||
], 0);
|
], 0);
|
||||||
$filtered_data = array_intersect_key($data, $fields);
|
$filtered_data = array_intersect_key($data, $fields);
|
||||||
|
$this->logger->critical(var_export($filtered_data,true));
|
||||||
$mapped_data = array_combine([
|
$mapped_data = array_combine([
|
||||||
'fecha',
|
'fecha',
|
||||||
'valor',
|
'valor',
|
||||||
|
@ -3,23 +3,18 @@ namespace Incoviba\Service\Venta;
|
|||||||
|
|
||||||
use PDO;
|
use PDO;
|
||||||
use PDOException;
|
use PDOException;
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use Incoviba\Common\Define;
|
use Incoviba\Common\Define;
|
||||||
use Incoviba\Common\Ideal\Service;
|
|
||||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||||
use Incoviba\Repository;
|
use Incoviba\Repository;
|
||||||
use Incoviba\Model;
|
use Incoviba\Model;
|
||||||
|
|
||||||
class Propiedad extends Service
|
class Propiedad
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
LoggerInterface $logger,
|
|
||||||
protected Repository\Venta\Propiedad $propiedadRepository,
|
protected Repository\Venta\Propiedad $propiedadRepository,
|
||||||
protected Repository\Venta\Unidad $unidadRepository,
|
protected Repository\Venta\Unidad $unidadRepository,
|
||||||
protected Define\Connection $connection
|
protected Define\Connection $connection
|
||||||
) {
|
) {}
|
||||||
parent::__construct($logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addPropiedad(array $ids): Model\Venta\Propiedad
|
public function addPropiedad(array $ids): Model\Venta\Propiedad
|
||||||
{
|
{
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Performance;
|
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
|
||||||
use PHPUnit\Framework;
|
|
||||||
|
|
||||||
class APITest extends Framework\TestCase
|
|
||||||
{
|
|
||||||
public function testLoad(): void
|
|
||||||
{
|
|
||||||
$client = new Client(['base_uri' => 'http://proxy']);
|
|
||||||
$start = microtime(true);
|
|
||||||
$response = $client->get('/api', ['headers' => ['Authorization' => 'Bearer ' . md5($_ENV['API_KEY'])]]);
|
|
||||||
$end = microtime(true);
|
|
||||||
$this->assertLessThanOrEqual(1000, $end - $start);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Performance;
|
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
|
||||||
use PHPUnit\Framework;
|
|
||||||
|
|
||||||
class HomeTest extends Framework\TestCase
|
|
||||||
{
|
|
||||||
public function testLoad(): void
|
|
||||||
{
|
|
||||||
$client = new Client(['base_uri' => 'http://proxy']);
|
|
||||||
$start = microtime(true);
|
|
||||||
$response = $client->get('');
|
|
||||||
$end = microtime(true);
|
|
||||||
$this->assertLessThanOrEqual(1000, $end - $start);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Test\Common\Alias;
|
|
||||||
|
|
||||||
use Incoviba\Common\Alias\View;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
|
||||||
|
|
||||||
class ViewTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testRender(): void
|
|
||||||
{
|
|
||||||
$contents = <<<HTML
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf8" />
|
|
||||||
<title>Test</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
Test
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
HTML;
|
|
||||||
mkdir('/tmp/views');
|
|
||||||
mkdir('/tmp/cache', 777);
|
|
||||||
file_put_contents('/tmp/views/test.blade.php', $contents);
|
|
||||||
$view = new View('/tmp/views', '/tmp/cache');
|
|
||||||
$body = $this->getMockBuilder(StreamInterface::class)->getMock();
|
|
||||||
$body->method('getContents')->willReturn($contents);
|
|
||||||
$response = $this->getMockBuilder(ResponseInterface::class)->getMock();
|
|
||||||
$response->method('getBody')->willReturn($body);
|
|
||||||
$output = $view->render($response, 'test');
|
|
||||||
$this->assertEquals($contents, $output->getBody()->getContents());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Test\Common\Implement;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
class ConnectionTest extends TestCase
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Test\Service;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Incoviba\Common\Define;
|
|
||||||
use Incoviba\Model;
|
|
||||||
use Incoviba\Repository;
|
|
||||||
use Incoviba\Service;
|
|
||||||
|
|
||||||
class MenuTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testBuild(): void
|
|
||||||
{
|
|
||||||
$tests = mt_rand(10, 100);
|
|
||||||
for ($i = 0; $i < $tests; $i ++) {
|
|
||||||
list($expected, $menu) = $this->generateBuildTest();
|
|
||||||
$this->assertEquals($expected, $menu->build(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected function generateBuildTest(): array
|
|
||||||
{
|
|
||||||
$modelCount = mt_rand(3, 100);
|
|
||||||
$expected = [];
|
|
||||||
$models = [];
|
|
||||||
for ($j = 0; $j < $modelCount; $j ++) {
|
|
||||||
$model = $this->generateModel();
|
|
||||||
$models []= $model;
|
|
||||||
$expected []= "<a class=\"item\" href=\"http://localhost/url{$model->id}\">title{$model->id}</a>";
|
|
||||||
}
|
|
||||||
$expected = implode(PHP_EOL, $expected);
|
|
||||||
$connection = $this->getMockBuilder(Define\Connection::class)->getMock();
|
|
||||||
$repository = $this->getMockBuilder(Repository\Menu::class)->setConstructorArgs(compact('connection'))->getMock();
|
|
||||||
$permissionsRepository = $this->getMockBuilder(Repository\Permission::class)->setConstructorArgs(compact('connection'))->getMock();
|
|
||||||
$permissions = $this->getMockBuilder(Service\Permission::class)->setConstructorArgs([$permissionsRepository])->getMock();
|
|
||||||
$repository->method('fetchByUser')->willReturn($models);
|
|
||||||
$menu = new Service\Menu($repository, $permissions, (object) ['base' => 'http://localhost']);
|
|
||||||
|
|
||||||
return [$expected, $menu];
|
|
||||||
}
|
|
||||||
protected function generateModel(): Model\Menu
|
|
||||||
{
|
|
||||||
$id = mt_rand(1, 100000);
|
|
||||||
$model = $this->getMockBuilder(Model\Menu::class)->getMock();
|
|
||||||
$model->id = $id;
|
|
||||||
$model->url = "url{$id}";
|
|
||||||
$model->title = "title{$id}";
|
|
||||||
|
|
||||||
return $model;
|
|
||||||
}
|
|
||||||
}
|
|
@ -83,16 +83,6 @@ services:
|
|||||||
- ${CLI_PATH:-.}:/code
|
- ${CLI_PATH:-.}:/code
|
||||||
- ./logs/cli:/logs
|
- ./logs/cli:/logs
|
||||||
|
|
||||||
testing:
|
|
||||||
profiles:
|
|
||||||
- testing
|
|
||||||
container_name: incoviba_tests
|
|
||||||
extends:
|
|
||||||
service: web
|
|
||||||
volumes:
|
|
||||||
- ./logs/test:/logs
|
|
||||||
command: [ '/code/vendor/bin/phpunit-watcher', 'watch' ]
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
dbdata: {}
|
dbdata: {}
|
||||||
incoviba_redis: {}
|
incoviba_redis: {}
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
[xdebug]
|
|
||||||
xdebug.mode=coverage
|
|
Reference in New Issue
Block a user