10 Commits

Author SHA1 Message Date
ad3285efd9 FIX: find ventas por proyecto y unidad 2024-01-30 12:07:43 -03:00
9d7857621e FIX: findPago sin numero 2024-01-22 12:10:16 -03:00
029cd095cb Base Log cli 2024-01-19 23:27:06 -03:00
c1792907c0 Basic Controller and Service 2024-01-19 23:12:13 -03:00
fa11f5b240 Cleanup logs, fixed add Venta, fixed search 2024-01-19 23:10:20 -03:00
f55e4dbd5f ventas.base 2024-01-18 17:15:32 -03:00
ca83472012 Informe escritura 2024-01-18 16:41:16 -03:00
01af47fba1 FIX: escriturar 2024-01-18 15:18:07 -03:00
e1462657fc Clave -> Contraseña 2024-01-18 13:20:02 -03:00
72f63c5e6c Cleanup 2024-01-18 13:17:23 -03:00
37 changed files with 1044 additions and 733 deletions

View File

@ -0,0 +1,9 @@
<?php
namespace Incoviba\Common\Ideal;
use Psr\Log\LoggerInterface;
abstract class Controller
{
public function __construct(protected LoggerInterface $logger) {}
}

View File

@ -0,0 +1,9 @@
<?php
namespace Incoviba\Common\Ideal;
use Psr\Log\LoggerInterface;
abstract class Service
{
public function __construct(protected LoggerInterface $logger) {}
}

View File

@ -1,4 +1,4 @@
<?php <?php
use Incoviba\Controller\Search; use Incoviba\Controller\API\Search;
$app->post('/search', [Search::class, 'query']); $app->post('/search', [Search::class, 'query']);

View File

@ -8,4 +8,5 @@ $app->group('/unidad/{unidad_id}', function($app) {
$app->group('/prorrateo', function($app) { $app->group('/prorrateo', function($app) {
$app->post('[/]', [Unidades::class, 'prorrateo']); $app->post('[/]', [Unidades::class, 'prorrateo']);
}); });
$app->get('[/]', [Unidades::class, 'get']);
}); });

View File

@ -2,5 +2,6 @@
use Incoviba\Controller\Ventas\Escrituras; use Incoviba\Controller\Ventas\Escrituras;
$app->group('/escritura/{venta_id}', function($app) { $app->group('/escritura/{venta_id}', function($app) {
$app->get('/informe[/]', [Escrituras::class, 'informe']);
$app->get('[/]', [Escrituras::class, 'show']); $app->get('[/]', [Escrituras::class, 'show']);
}); });

View File

@ -8,7 +8,7 @@
<input type="text" id="name" name="name" /> <input type="text" id="name" name="name" />
</div> </div>
<div class="six wide field"> <div class="six wide field">
<label for="password">Clave</label> <label for="password">Contraseña</label>
<input type="password" id="password" name="password" /> <input type="password" id="password" name="password" />
</div> </div>
<button class="ui button" id="enter">Ingresar</button> <button class="ui button" id="enter">Ingresar</button>

View File

@ -107,9 +107,10 @@
const uri = '{{$urls->api}}/search' const uri = '{{$urls->api}}/search'
this.data = [] this.data = []
return fetchAPI(uri, {method: 'post', body: data}).then(response => { return fetchAPI(uri, {method: 'post', body: data}).then(response => {
if (response.ok) { if (!response) {
return response.json() return
} }
return response.json()
}).catch(error => { }).catch(error => {
this.draw().clear() this.draw().clear()
this.draw().error(error) this.draw().error(error)
@ -123,7 +124,11 @@
const promises = [] const promises = []
data.results.forEach(row => { data.results.forEach(row => {
if (row.tipo === 'venta') { if (row.tipo === 'venta') {
promises.push(this.get().venta(row.id).then(json => { return promises.push(this.get().venta(row.id).then(json => {
if (json.venta === null) {
console.debug(json)
return
}
const venta = json.venta const venta = json.venta
progress.progress('increment') progress.progress('increment')
const r = new Row({unidad: venta.propiedad.unidades[0], proyecto: venta.proyecto}) const r = new Row({unidad: venta.propiedad.unidades[0], proyecto: venta.proyecto})
@ -134,7 +139,6 @@
console.error(row) console.error(row)
console.error(error) console.error(error)
})) }))
return
} }
promises.push(this.get().unidad(row.id).then(json => { promises.push(this.get().unidad(row.id).then(json => {
const unidad = json.unidad const unidad = json.unidad
@ -164,9 +168,10 @@
venta: id => { venta: id => {
const url = '{{$urls->api}}/venta/' + id const url = '{{$urls->api}}/venta/' + id
return fetchAPI(url).then(response => { return fetchAPI(url).then(response => {
if (response.ok) { if (!response) {
return response.json() return
} }
return response.json()
}) })
} }
} }

View File

@ -3,7 +3,7 @@
@section('page_content') @section('page_content')
<div class="ui container"> <div class="ui container">
<h2 class="ui header">Nueva Venta</h2> <h2 class="ui header">Nueva Venta</h2>
<form class="ui form" id="add_form" action="{{$urls->api}}/ventas/add" method="post"> <form class="ui form" id="add_form" method="post">
<label for="fecha_venta">Fecha de Venta</label> <label for="fecha_venta">Fecha de Venta</label>
<div class="inline field"> <div class="inline field">
<div class="ui calendar" id="fecha_venta_calendar"> <div class="ui calendar" id="fecha_venta_calendar">
@ -686,7 +686,7 @@
$('<div></div>').addClass('content').append(tipo.charAt(0).toUpperCase() + tipo.slice(1) + ' ').append( $('<div></div>').addClass('content').append(tipo.charAt(0).toUpperCase() + tipo.slice(1) + ' ').append(
unidad.draw(this.unidades[tipo]) unidad.draw(this.unidades[tipo])
).append( ).append(
$('<button></button>').addClass('ui icon button').attr('type', 'button').attr('data-number', number).append( $('<button></button>').addClass('ui basic red icon button').attr('type', 'button').attr('data-number', number).append(
$('<i></i>').addClass('remove icon') $('<i></i>').addClass('remove icon')
).click(event => { ).click(event => {
const number = $(event.currentTarget).attr('data-number') const number = $(event.currentTarget).attr('data-number')
@ -766,7 +766,7 @@
} }
function showErrors(errors) { function showErrors(errors) {
console.debug(errors) console.error(errors)
} }
$(document).ready(() => { $(document).ready(() => {
@ -789,20 +789,21 @@
$('#add_form').submit(event => { $('#add_form').submit(event => {
event.preventDefault() event.preventDefault()
const data = new FormData(event.currentTarget) const body = new FormData(event.currentTarget)
const uri = $(event.currentTarget).attr('action') const uri = '{{$urls->api}}/ventas/add'
fetch(uri, {method: 'post', body: data}).then(response => { return fetchAPI(uri, {method: 'post', body}).then(response => {
if (response.ok) { if (!response) {
return response.json() return false
} }
}).then(data => { return response.json().then(data => {
if (data.status) { if (data.status) {
window.location = '{{$urls->base}}' window.location = '{{$urls->base}}/venta/' + data.venta_id
return true return true
} }
showErrors(data.errors) showErrors(data.errors)
return false
})
}) })
return false
}) })
}) })
</script> </script>

View File

@ -0,0 +1,36 @@
@extends('layout.base')
@section('page_title')
Venta {{$venta->proyecto()->descripcion}} {{$venta->propiedad()->summary()}}
@endsection
@section('page_content')
<div class="ui container">
<div class="ui two column grid">
<div class="row">
<h1 class="four wide column header">
<div class="content">
<div class="ui dividing sub header">{{$venta->proyecto()->descripcion}}</div>
<a href="{{$urls->base}}/venta/{{$venta->id}}">
{{$venta->propiedad()->summary()}}
</a>
</div>
</h1>
@if (isset($showPropietario) and $showPropietario)
<div class="right floated column">
@include('ventas.show.propietario')
</div>
@endif
</div>
@hasSection('venta_subtitle')
<div class="row">
<h2 class="ui sub header column">
@yield('venta_subtitle')
</h2>
</div>
@endif
</div>
<br />
@yield('venta_content')
</div>
@endsection

View File

@ -1,47 +1,43 @@
@extends('layout.base') @extends('ventas.base')
@section('page_content') @section('venta_subtitle')
<div class="ui container"> Desistida
<h1 class="ui header"> @endsection
Desistida - {{$venta->proyecto()->descripcion}} -
<a href="{{$urls->base}}/venta/{{$venta->id}}"> @section('venta_content')
{{$venta->propiedad()->summary()}} <form class="ui form" id="desistida_form">
</a> <div class="fields">
</h1> <div class="three wide field">
<form class="ui form" id="desistida_form"> <label for="fecha">Fecha</label>
<div class="fields"> <div class="ui calendar" id="fecha">
<div class="three wide field"> <div class="ui left icon input">
<label for="fecha">Fecha</label> <i class="calendar icon"></i>
<div class="ui calendar" id="fecha"> <input type="text" />
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" />
</div>
</div> </div>
</div> </div>
<div class="one wide field"> </div>
<div id="loading-spinner-fecha" class="ui tiny blue active inline elastic loader" style="display: none;"></div> <div class="one wide field">
<div id="loading-spinner-fecha" class="ui tiny blue active inline elastic loader" style="display: none;"></div>
</div>
</div>
<div class="fields">
<div class="three wide field">
<label for="devolucion">Devolución</label>
<div class="ui left labeled input">
<div class="ui basic label">$</div>
<input type="text" id="devolucion" value="{{$venta->resciliacion()->valor}}" />
</div> </div>
</div> </div>
<div class="fields"> <div class="one wide field">
<div class="three wide field"> <div id="loading-spinner-devolucion" class="ui tiny blue active inline elastic loader" style="display: none;"></div>
<label for="devolucion">Devolución</label>
<div class="ui left labeled input">
<div class="ui basic label">$</div>
<input type="text" id="devolucion" value="{{$venta->resciliacion()->valor}}" />
</div>
</div>
<div class="one wide field">
<div id="loading-spinner-devolucion" class="ui tiny blue active inline elastic loader" style="display: none;"></div>
</div>
</div> </div>
<button class="ui red icon button" type="button" id="eliminar_desistimiento"> </div>
<i class="ban icon"></i> <button class="ui red icon button" type="button" id="eliminar_desistimiento">
Elmininar desistimiento <i class="ban icon"></i>
</button> Elmininar desistimiento
<div id="loading-spinner-eliminar" class="ui tiny blue active inline elastic loader" style="display: none;"></div> </button>
</form> <div id="loading-spinner-eliminar" class="ui tiny blue active inline elastic loader" style="display: none;"></div>
</div> </form>
@endsection @endsection
@push('page_scripts') @push('page_scripts')

View File

@ -1,51 +1,49 @@
@extends('layout.base') @extends('ventas.base')
@section('page_content') @section('venta_subtitle')
<div class="ui container"> Desistir
<h1 class="ui header"> @endsection
Desistir - {{$venta->proyecto()->descripcion}} -
<a href="{{$urls->base}}/venta/{{$venta->id}}">{{$venta->propiedad()->summary()}}</a> @section('venta_content')
</h1> <div class="ui list">
<div class="ui list"> <div class="item">
<div class="item"> <div class="header">Valor Pagado</div>
<div class="header">Valor Pagado</div> <div class="content">
<div class="content"> {{$format->pesos($venta->formaPago()->pie->pagado('pesos'))}}
{{$format->pesos($venta->formaPago()->pie->pagado('pesos'))}} <div class="ui left pointing small label">
<div class="ui left pointing small label"> {{$format->number($venta->formaPago()->pie->pagado() / $venta->valor * 100)}}% de la venta
{{$format->number($venta->formaPago()->pie->pagado() / $venta->valor * 100)}}% de la venta
</div>
</div>
</div>
<div class="item">
<div class="header">
Multa Estandar
<div class="ui left pointing small label">5%</div>
</div>
<div class="content">
{{$format->pesos($venta->valor * 0.05 * $UF->get())}}
</div> </div>
</div> </div>
</div> </div>
<form class="ui form" id="desistir_form"> <div class="item">
<div class="three wide field"> <div class="header">
<label for="fecha">Fecha</label> Multa Estandar
<div class="ui calendar" id="fecha"> <div class="ui left pointing small label">5%</div>
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" />
</div>
</div>
</div> </div>
<div class="three wide field"> <div class="content">
<label for="devolucion">Devolución [$]</label> {{$format->pesos($venta->valor * 0.05 * $UF->get())}}
<div class="ui left labeled input">
<div class="ui basic label">$</div>
<input type="text" name="devolucion" />
</div>
</div> </div>
<button class="ui button">Desistir</button> </div>
</form>
</div> </div>
<form class="ui form" id="desistir_form">
<div class="three wide field">
<label for="fecha">Fecha</label>
<div class="ui calendar" id="fecha">
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" />
</div>
</div>
</div>
<div class="three wide field">
<label for="devolucion">Devolución [$]</label>
<div class="ui left labeled input">
<div class="ui basic label">$</div>
<input type="text" name="devolucion" />
</div>
</div>
<button class="ui button">Desistir</button>
</form>
@endsection @endsection
@push('page_scripts') @push('page_scripts')

View File

@ -1,33 +1,31 @@
@extends('layout.base') @extends('ventas.base')
@section('page_content') @section('venta_subtitle')
<div class="ui container"> Editar Venta
<h2 class="ui header">Editar Venta - @endsection
{{$venta->proyecto()->descripcion}} -
<a href="{{$urls->base}}/venta/{{$venta->id}}">{{$venta->propiedad()->summary()}}</a> @section('venta_content')
</h2> <form class="ui form" id="edit_form">
<form class="ui form" id="edit_form"> <div class="inline field">
<div class="inline field"> <label for="valor">Valor</label>
<label for="valor">Valor</label> <div class="ui right labeled input">
<div class="ui right labeled input"> <input type="text" id="valor" name="valor" value="{{$venta->valor}}" />
<input type="text" id="valor" name="valor" value="{{$venta->valor}}" /> <div class="ui label">UF</div>
<div class="ui label">UF</div> </div>
</div>
<div class="inline field">
<label for="fecha">Fecha Promesa</label>
<div class="ui calendar" id="fecha_calendar">
<div class="ui icon input">
<input type="text" name="fecha" id="fecha" />
<i class="calendar icon"></i>
</div> </div>
</div> </div>
<div class="inline field"> </div>
<label for="fecha">Fecha Promesa</label> <button class="ui button">
<div class="ui calendar" id="fecha_calendar"> Guardar
<div class="ui icon input"> </button>
<input type="text" name="fecha" id="fecha" /> </form>
<i class="calendar icon"></i>
</div>
</div>
</div>
<button class="ui button">
Guardar
</button>
</form>
</div>
@endsection @endsection
@push('page_scripts') @push('page_scripts')

View File

@ -1,210 +1,206 @@
@extends('layout.base') @extends('ventas.base')
@section('page_content') @section('venta_subtitle')
<div class="ui container"> Escriturar
<h1 class="ui header"> @endsection
Escriturar - {{$venta->proyecto()->descripcion}} -
<a href="{{$urls->base}}/venta/{{$venta->id}}"> @section('venta_content')
{{$venta->propiedad()->summary()}} <div class="ui basic segment">
</a> <div class="ui four columns grid">
</h1> <div class="column">Faltante</div>
<div class="ui basic segment"> <div class="column">{{$format->pesos($venta->saldo('pesos'))}}</div>
<div class="ui four columns grid"> <div class="column">{{$format->ufs($venta->saldo())}}</div>
<div class="column">Faltante</div> </div>
<div class="column">{{$format->pesos($venta->saldo('pesos'))}}</div> </div>
<div class="column">{{$format->ufs($venta->saldo())}}</div> <div class="ui divider"></div>
<form class="ui form" id="escriturar_form">
<div class="three wide field">
<label for="fecha">Fecha</label>
<div class="ui calendar" id="fecha">
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" name="fecha" />
</div>
</div> </div>
</div> </div>
<div class="ui divider"></div> @if ($venta->formaPago()->pie->reajuste === null)
<form class="ui form" id="escriturar_form"> <h4 class="ui header optional" data-name="reajuste">Reajuste <i class="small plus icon"></i></h4>
<div class="three wide field"> <div class="fields optional" id="reajuste">
<label for="fecha">Fecha</label> <div class="field">
<div class="ui calendar" id="fecha"> <label for="valor_reajuste">Valor [$]</label>
<div class="ui left icon input"> <div class="ui left labeled input">
<i class="calendar icon"></i> <div class="ui basic label">$</div>
<input type="text" name="fecha" /> <input type="text" name="valor_reajuste" id="valor_reajuste" />
</div>
</div>
<div class="field">
<label for="fecha_reajuste">Fecha</label>
<div class="ui calendar" id="fecha_reajuste">
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" name="fecha_reajuste" />
</div>
</div> </div>
</div> </div>
</div> </div>
@if ($venta->formaPago()->pie->reajuste === null) @else
<h4 class="ui header optional" data-name="reajuste">Reajuste <i class="small plus icon"></i></h4> <h4 class="ui header" data-name="reajuste">Reajuste</h4>
<div class="fields optional" id="reajuste"> <div class="fields" id="reajuste">
<div class="field"> <div class="field">
<label for="valor_reajuste">Valor [$]</label> <label for="valor_reajuste">Valor [$]</label>
<div class="ui left labeled input"> <div class="ui left labeled disabled input">
<div class="ui basic label">$</div> <div class="ui basic label">$</div>
<input type="text" name="valor_reajuste" id="valor_reajuste" /> <input type="text" value="{{$format->number($venta->formaPago()->pie->reajuste->valor)}}" />
</div>
</div> </div>
<div class="field"> </div>
<label for="fecha_reajuste">Fecha</label> <div class="field">
<div class="ui calendar" id="fecha_reajuste"> <label for="fecha_reajuste">Fecha</label>
<div class="ui left icon input"> <div class="ui disabled input">
<i class="calendar icon"></i> <input type="text" value="{{$venta->formaPago()->pie->reajuste->fecha->format('d-m-Y')}}" />
<input type="text" name="fecha_reajuste" /> </div>
</div> </div>
</div>
@endif
@if (!isset($venta->formaPago()->escritura))
<h4 class="ui header optional" data-name="pago">Pago en Escritura <i class="small plus icon"></i></h4>
<div class="fields optional" id="pago">
<div class="field">
<label for="valor_pago_pesos">Valor [$]</label>
<div class="ui left labeled input">
<div class="ui basic label">$</div>
<input type="text" name="valor_pago_pesos" id="valor_pago_pesos" />
</div>
</div>
<div class="field">
<label for="valor_pago_ufs">(Valor [UF])</label>
<div class="ui right labeled input">
<input type="text" name="valor_pago_ufs" id="valor_pago_ufs" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="field">
<label for="fecha_pago">Fecha</label>
<div class="ui calendar" id="fecha_pago">
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" name="fecha_pago" />
</div> </div>
</div> </div>
</div> </div>
@else </div>
<h4 class="ui header" data-name="reajuste">Reajuste</h4> @else
<div class="fields" id="reajuste"> <h4 class="ui header" data-name="pago">Pago en Escritura</h4>
<div class="field"> <div class="fields" id="pago">
<label for="valor_reajuste">Valor [$]</label> <div class="field">
<div class="ui left labeled disabled input"> <label for="valor_pago_pesos">Valor [$]</label>
<div class="ui basic label">$</div> <div class="ui left labeled disabled input">
<input type="text" value="{{$format->number($venta->formaPago()->pie->reajuste->valor)}}" /> <div class="ui basic label">$</div>
</div> <input type="text" value="{{$format->number($venta->formaPago()->escritura->pago->valor)}}" />
</div> </div>
<div class="field"> </div>
<label for="fecha_reajuste">Fecha</label> <div class="field">
<div class="ui disabled input"> <label for="valor_pago_ufs">(Valor [UF])</label>
<input type="text" value="{{$venta->formaPago()->pie->reajuste->fecha->format('d-m-Y')}}" /> <div class="ui right labeled disabled input">
<input type="text" value="{{$format->number($venta->formaPago()->escritura->pago->valor(),2)}}" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="field">
<label for="fecha_pago">Fecha</label>
<div class="ui disabled input">
<input type="text" value="{{$venta->formaPago()->escritura->pago->fecha->format('d-m-Y')}}">
</div>
</div>
</div>
@endif
@if (!isset($venta->formaPago()->subsidio))
<h4 class="ui header optional" data-name="subsidio">Subsidio <i class="small plus icon"></i></h4>
<div class="fields optional" id="subsidio">
<div class="field">
<label for="valor_ahorro">Valor Ahorrado [UF]</label>
<div class="ui right labeled input">
<input type="text" name="valor_ahorro" id="valor_ahorro" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="field">
<label for="valor_subsidio">Valor Subsidio [UF]</label>
<div class="ui right labeled input">
<input type="text" name="valor_subsidio" id="valor_subsidio" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="field">
<label for="total_subsidio">Total</label>
<div class="ui right labeled disabled input">
<input type="text" id="total_subsidio" value="0,00" />
<div class="ui basic label">UF</div>
</div>
</div>
</div>
@else
<h4 class="ui header" data-name="subsidio">Subsidio</h4>
<div class="fields">
<div class="field">
<label for="valor_ahorro">Valor Ahorrado</label>
<div class="ui right labeled disabled input">
<input type="text" value="{{$venta->formaPago()->subsidio->ahorro->valor()}}" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="field">
<label for="valor_subsidio">Valor Subsidio</label>
<div class="ui right labeled disabled input">
<input type="text" value="{{$venta->formaPago()->subidio->pago->valor()}}" />
<div class="ui basic label">UF</div>
</div>
</div>
</div>
@endif
@if (!isset($venta->formaPago()->credito) or $venta->formaPago()->credito->pago->banco === null)
<h4 class="ui header">Crédito</h4>
<div class="fields">
<div class="field">
<label for="valor_credito">Valor [UF]</label>
<div class="ui right labeled input">
<input type="text" id="valor_credito" name="valor_credito" value="{{$venta->formaPago()->credito?->pago->valor() ?? ''}}" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="four wide field">
<label for="banco_credito">Banco</label>
<div class="ui selection dropdown" id="banco_credito">
<input type="hidden" name="banco_credito" />
<div class="default text">Banco</div>
<i class="dropdown icon"></i>
<div class="menu">
@foreach ($bancos as $banco)
<div class="item" data-value="{{$banco->id}}">{{$banco->nombre}}</div>
@endforeach
</div> </div>
</div> </div>
</div> </div>
@endif </div>
@if (!isset($venta->formaPago()->escritura)) @else
<h4 class="ui header optional" data-name="pago">Pago en Escritura <i class="small plus icon"></i></h4> <h4 class="ui header">Crédito</h4>
<div class="fields optional" id="pago"> <div class="fields">
<div class="field"> <div class="field">
<label for="valor_pago_pesos">Valor [$]</label> <label for="valor_credito">Valor [UF]</label>
<div class="ui left labeled input"> <div class="ui right labeled disabled input">
<div class="ui basic label">$</div> <input type="text" value="{{$format->number($venta->formaPago()->credito->pago->valor(), 2)}}" />
<input type="text" name="valor_pago_pesos" id="valor_pago_pesos" /> <div class="ui basic label">UF</div>
</div>
</div>
<div class="field">
<label for="valor_pago_ufs">(Valor [UF])</label>
<div class="ui right labeled input">
<input type="text" name="valor_pago_ufs" id="valor_pago_ufs" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="field">
<label for="fecha_pago">Fecha</label>
<div class="ui calendar" id="fecha_pago">
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" class="fecha_pago" />
</div>
</div>
</div> </div>
</div> </div>
@else <div class="four wide field">
<h4 class="ui header" data-name="pago">Pago en Escritura</h4> <label for="banco_credito">Banco</label>
<div class="fields" id="pago"> <div class="ui disabled input">
<div class="field"> <input type="text" value="{{$venta->formaPago()->credito->pago->banco->nombre}}" />
<label for="valor_pago_pesos">Valor [$]</label>
<div class="ui left labeled disabled input">
<div class="ui basic label">$</div>
<input type="text" value="{{$format->number($venta->formaPago()->escritura->pago->valor)}}" />
</div>
</div>
<div class="field">
<label for="valor_pago_ufs">(Valor [UF])</label>
<div class="ui right labeled disabled input">
<input type="text" value="{{$format->number($venta->formaPago()->escritura->pago->valor(),2)}}" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="field">
<label for="fecha_pago">Fecha</label>
<div class="ui disabled input">
<input type="text" value="{{$venta->formaPago()->escritura->pago->fecha->format('d-m-Y')}}">
</div>
</div> </div>
</div> </div>
@endif </div>
@if (!isset($venta->formaPago()->subsidio)) @endif
<h4 class="ui header optional" data-name="subsidio">Subsidio <i class="small plus icon"></i></h4> <button class="ui button">Escriturar</button>
<div class="fields optional" id="subsidio"> </form>
<div class="field">
<label for="valor_ahorro">Valor Ahorrado [UF]</label>
<div class="ui right labeled input">
<input type="text" name="valor_ahorro" id="valor_ahorro" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="field">
<label for="valor_subsidio">Valor Subsidio [UF]</label>
<div class="ui right labeled input">
<input type="text" name="valor_subsidio" id="valor_subsidio" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="field">
<label for="total_subsidio">Total</label>
<div class="ui right labeled disabled input">
<input type="text" id="total_subsidio" value="0,00" />
<div class="ui basic label">UF</div>
</div>
</div>
</div>
@else
<h4 class="ui header" data-name="subsidio">Subsidio</h4>
<div class="fields">
<div class="field">
<label for="valor_ahorro">Valor Ahorrado</label>
<div class="ui right labeled disabled input">
<input type="text" value="{{$venta->formaPago()->subsidio->ahorro->valor()}}" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="field">
<label for="valor_subsidio">Valor Subsidio</label>
<div class="ui right labeled disabled input">
<input type="text" value="{{$venta->formaPago()->subidio->pago->valor()}}" />
<div class="ui basic label">UF</div>
</div>
</div>
</div>
@endif
@if (isset($venta->formaPago()->credito) and $venta->formaPago()->credito->pago->banco === null)
<h4 class="ui header">Crédito</h4>
<div class="fields">
<div class="field">
<label for="valor_credito">Valor [UF]</label>
<div class="ui right labeled disabled input">
<input type="text" value="{{$format->number($venta->formaPago()->credito->pago->valor(), 2)}}" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="four wide field">
<label for="banco_credito">Banco</label>
<div class="ui selection dropdown" id="banco_credito">
<input type="hidden" name="banco_credito" />
<div class="default text">Banco</div>
<i class="dropdown icon"></i>
<div class="menu">
@foreach ($bancos as $banco)
<div class="item" data-value="{{$banco->id}}">{{$banco->nombre}}</div>
@endforeach
</div>
</div>
</div>
</div>
@else
<h4 class="ui header">Crédito</h4>
<div class="fields">
<div class="field">
<label for="valor_credito">Valor [UF]</label>
<div class="ui right labeled disabled input">
<input type="text" value="{{$format->number($venta->formaPago()->credito->pago->valor(), 2)}}" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="four wide field">
<label for="banco_credito">Banco</label>
<div class="ui disabled input">
<input type="text" value="{{$venta->formaPago()->credito->pago->banco->nombre}}" />
</div>
</div>
</div>
@endif
<button class="ui button">Escriturar</button>
</form>
</div>
@endsection @endsection
@push('page_scripts') @push('page_scripts')
@ -254,9 +250,15 @@
$('#escriturar_form').submit(event => { $('#escriturar_form').submit(event => {
event.preventDefault() event.preventDefault()
const url = '{{$urls->api}}/venta/{{$venta->id}}/escriturar' const url = '{{$urls->api}}/venta/{{$venta->id}}/escriturar'
const data = new FormData(event.currentTarget) const body = new FormData(event.currentTarget)
data.set('fecha', $('#fecha').calendar('get date').toISOString()) body.set('fecha', $('#fecha').calendar('get date').toISOString())
fetchAPI(url, {method: 'post', body: data}).then(response => { if (body.get('fecha_pago') !== '') {
body.set('fecha_pago', $('#fecha_pago').calendar('get date').toISOString())
}
if (body.get('fecha_reajuste') !== '') {
body.set('fecha_reajuste', $('#fecha_reajuste').calendar('get date').toISOString())
}
fetchAPI(url, {method: 'post', body}).then(response => {
if (response.ok) { if (response.ok) {
return response.json() return response.json()
} }
@ -267,6 +269,8 @@
}) })
return false return false
}) })
$('#fecha_pago').calendar(calendar_date_options)
$('#fecha_reajuste').calendar(calendar_date_options)
}) })
</script> </script>
@endpush @endpush

View File

@ -0,0 +1,88 @@
@extends('ventas.base')
@section('venta_subtitle')
Resumen Escritura
@endsection
@section('venta_content')
<div class="ui segment">
El departamento {{$venta->propiedad()->departamentos()[0]->descripcion}}:<br />
@php
$estacionamientos = $venta->propiedad()->estacionamientos();
@endphp
@if (count($estacionamientos) === 0)
no tiene estacionamientos
@else
tiene
{{count($estacionamientos) === 1 ? 'el' : 'los'}}
estacionamiento{{count($estacionamientos) === 1 ? '': 's'}}
{{implode(', ', array_map(function(Incoviba\Model\Venta\Unidad $unidad) {
return $unidad->descripcion;
}, $estacionamientos))}}
@endif
y
@php
$bodegas = $venta->propiedad()->bodegas();
@endphp
@if (count($bodegas) === 0)
no tiene bodegas
@else
tiene
{{count($bodegas) === 1 ? 'la' : 'las'}}
bodega{{count($bodegas) === 1 ? '' : 's'}}
{{implode(', ', array_map(function(Incoviba\Model\Venta\Unidad $unidad) {
return $unidad->descripcion;
}, $bodegas))}}
@endif
<br />
<br />
<strong>PRECIO</strong>
{{$format->ufs($venta->valor)}}
<div class="ui fitted divider"></div>
<br />
@if (isset($venta->formaPago()->pie))
@php($pie = $venta->formaPago()->pie)
<strong>PIE</strong>
{{$pie->cuotas}} cuotas que suman
{{$format->pesos($pie->pagado('pesos'))}}
equivalente a
{{$format->ufs($pie->pagado())}}.
<br />
@endif
@if (isset($venta->formaPago()->escritura))
@php($escritura = $venta->formaPago()->escritura)
<strong>ESCRITURA</strong>
{{$format->pesos($escritura->pago->valor)}}
el
{{$escritura->fecha->format('d-m-Y')}}
equivalente a
{{$format->ufs($escritura->pago->valor())}}
<br />
@endif
<div class="ui fitted divider"></div>
<strong>TOTAL ANTICIPO</strong>
{{$format->ufs($venta->formaPago()->anticipo())}}
<br />
@if (isset($venta->formaPago()->bonoPie))
@php($bono = $venta->formaPago()->bonoPie)
<strong>BONO PIE</strong>
{{$format->ufs($bono->pago->valor())}}
<br />
@endif
@if (isset($venta->formaPago()->credito))
@php($credito = $venta->formaPago()->credito)
<strong>CRÉDITO</strong>
{{$format->ufs($credito->pago->valor())}}
en Banco {{$credito->pago->banco->nombre}}
<br />
@endif
<div class="ui fitted divider"></div>
<strong>TOTAL</strong>
{{$format->ufs($venta->formaPago()->total())}}
@if (($venta->formaPago()->total() - $venta->valor) !== 0)
<br />
<br />
Diferencia {{$format->ufs($venta->formaPago()->total() - $venta->valor)}}. ({{$format->percent(($venta->formaPago()->total() - $venta->valor) / $venta->valor * 100)}})
@endif
</div>
@endsection

View File

@ -1,27 +1,22 @@
@extends('layout.base') @extends('ventas.base')
@section('page_content') @section('venta_subtitle')
<div class="ui container"> Escritura
<h2 class="ui header"> @endsection
Escritura -
{{$venta->proyecto()->descripcion}} - @section('venta_content')
<a href="{{$urls->base}}/venta/{{$venta->id}}"> <form class="ui form" id="edit_form">
{{$venta->propiedad()->summary()}} <div class="three wide field">
</a> <label for="fecha">Fecha</label>
</h2> <div class="ui calendar" id="fecha">
<form class="ui form" id="edit_form"> <div class="ui left icon input">
<div class="three wide field"> <i class="calendar icon"></i>
<label for="fecha">Fecha</label> <input type="text" placeholder="Fecha" />
<div class="ui calendar" id="fecha">
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" placeholder="Fecha" />
</div>
</div> </div>
</div> </div>
<button class="ui button">Guardar</button> </div>
</form> <button class="ui button">Guardar</button>
</div> </form>
@endsection @endsection
@push('page_scripts') @push('page_scripts')

View File

@ -234,6 +234,7 @@
this.table = new DataTable(table, { this.table = new DataTable(table, {
order: [[0, 'asc']], order: [[0, 'asc']],
pageLength: 50
}) })
}, },
table: () => { table: () => {

View File

@ -1,146 +1,139 @@
@extends('layout.base') @extends('ventas.base')
@section('page_content') @section('venta_subtitle')
<div class="ui container"> Cuotas - Pie
<div class="ui two column grid"> @endsection
<h1 class="four wide column header">
<div class="content"> @section('venta_content')
<div class="ui dividing sub header">{{$venta->proyecto()->descripcion}}</div> <table class="ui table" id="cuotas">
<a href="{{$urls->base}}/venta/{{$venta->id}}">{{$venta->propiedad()->summary()}}</a> <thead>
</div> <tr>
</h1> <th>#</th>
</div> <th>Fecha</th>
<h2>Cuotas - Pie</h2> <th>Fecha ISO</th>
<table class="ui table" id="cuotas"> <th>Banco</th>
<thead> <th>Identificador</th>
<tr> <th class="right aligned">Valor</th>
<th>#</th> <th class="right aligned">Valor UF</th>
<th>Fecha</th> <th>Estado</th>
<th>Fecha ISO</th> <th>Fecha Estado</th>
<th>Banco</th> <th>Fecha Estado ISO</th>
<th>Identificador</th> <th></th>
<th class="right aligned">Valor</th> </tr>
<th class="right aligned">Valor UF</th> </thead>
<th>Estado</th> <tbody>@php
<th>Fecha Estado</th> $now = new DateTimeImmutable();
<th>Fecha Estado ISO</th> $uf_venta = $venta->uf === 0.0 ? $UF->get($venta->currentEstado()->fecha) : $venta->uf;
<th></th> @endphp
</tr> @foreach ($venta->formaPago()->pie->cuotas() as $cuota)
</thead> <tr data-pago="{{$cuota->pago->id}}"
<tbody>@php @if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado', 'reemplazado']))
$now = new DateTimeImmutable(); class="disabled"
$uf_venta = $venta->uf === 0.0 ? $UF->get($venta->currentEstado()->fecha) : $venta->uf; @endif >
@endphp <td>{{$cuota->numero}}</td>
@foreach ($venta->formaPago()->pie->cuotas() as $cuota) <td>{{$cuota->pago->fecha->format('d-m-Y')}}</td>
<tr data-pago="{{$cuota->pago->id}}" <td>{{$cuota->pago->fecha->format('Y-m-d')}}</td>
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado', 'reemplazado'])) <td>{{$cuota->pago->banco->nombre}}</td>
class="disabled" <td>{{$cuota->pago->identificador}}</td>
@endif > <td class="right aligned">{{$format->pesos($cuota->pago->valor)}}</td>
<td>{{$cuota->numero}}</td> <td class="right aligned">
<td>{{$cuota->pago->fecha->format('d-m-Y')}}</td> @if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' and $cuota->pago->currentEstado->fecha <= $now)
<td>{{$cuota->pago->fecha->format('Y-m-d')}}</td> {{$format->ufs($cuota->pago->valor())}}
<td>{{$cuota->pago->banco->nombre}}</td>
<td>{{$cuota->pago->identificador}}</td>
<td class="right aligned">{{$format->pesos($cuota->pago->valor)}}</td>
<td class="right aligned">
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' and $cuota->pago->currentEstado->fecha <= $now)
{{$format->ufs($cuota->pago->valor())}}
@endif
</td>
<td
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado')
class="green"
@elseif ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
class="yellow"
@elseif ($cuota->pago->currentEstado->tipoEstadoPago->activo !== 1)
class="red"
@endif
>{{ucwords($cuota->pago->currentEstado->tipoEstadoPago->descripcion)}}</td>
<td>
@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']))
<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}}">
<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}}">
<i class="remove icon"></i>
</button>
@endif
</div>
</div>
@endif
</td>
<td>{{$cuota->pago->currentEstado->fecha->format('Y-m-d')}}</td>
<td>
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion !== 'anulado')
<button class="ui mini red icon basic button anular" data-pago="{{$cuota->pago->id}}">
<i class="remove icon"></i>
</button>
@endif @endif
</td> </td>
</tr> <td
@endforeach @if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado')
</tbody> class="green"
<tfoot> @elseif ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
<tr> class="yellow"
<th colspan="5">TOTAL</th> @elseif ($cuota->pago->currentEstado->tipoEstadoPago->activo !== 1)
<th class="right aligned"> class="red"
{{$format->pesos($total_pesos = array_reduce($venta->formaPago()->pie->cuotas(), @endif
function(float $sum, Incoviba\Model\Venta\Cuota $cuota) { >{{ucwords($cuota->pago->currentEstado->tipoEstadoPago->descripcion)}}</td>
return $sum + $cuota->pago->valor; <td>
}, 0))}} @if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['abonado', 'anulado', 'reemplazado']))
</th> {{$cuota->pago->currentEstado->fecha->format('d-m-Y')}}
<th class="right aligned"> @elseif (!in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado', 'reemplazado']))
{{$format->ufs($total = array_reduce($venta->formaPago()->pie->cuotas(), <div class="ui calendar fecha_estado" data-date="{{$cuota->pago->currentEstado->fecha->format('Y-m-d')}}">
function(float $sum, Incoviba\Model\Venta\Cuota $cuota) use ($now, $uf_venta) { <div class="ui action left icon input">
return $sum + (($cuota->pago->fecha > $now or $cuota->pago->uf === null) ? <i class="calendar icon"></i>
$cuota->pago->valor / $uf_venta : <input type="text" name="fecha_estado" />
$cuota->pago->valor()); <button class="ui green basic icon button accept_estado" data-pago="{{$cuota->pago->id}}" data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->descripcion}}">
}, 0.0))}} <i class="check icon"></i>
</th> </button>
<th colspan="4"></th> @if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
<button class="ui red basic icon button reject_estado" data-pago="{{$cuota->pago->id}}">
<i class="remove icon"></i>
</button>
@endif
</div>
</div>
@endif
</td>
<td>{{$cuota->pago->currentEstado->fecha->format('Y-m-d')}}</td>
<td>
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion !== 'anulado')
<button class="ui mini red icon basic button anular" data-pago="{{$cuota->pago->id}}">
<i class="remove icon"></i>
</button>
@endif
</td>
</tr> </tr>
<tr> @endforeach
<th colspan="5">TOTAL PAGADO</th> </tbody>
<th class="right aligned"> <tfoot>
{{$format->pesos($pagado_pesos = array_reduce($venta->formaPago()->pie->cuotas(true), <tr>
function(int $sum, Incoviba\Model\Venta\Cuota $cuota) { <th colspan="5">TOTAL</th>
return $sum + $cuota->pago->valor; <th class="right aligned">
}, 0))}} {{$format->pesos($total_pesos = array_reduce($venta->formaPago()->pie->cuotas(),
</th> function(float $sum, Incoviba\Model\Venta\Cuota $cuota) {
<th class="right aligned"> return $sum + $cuota->pago->valor;
{{$format->ufs($pagado = array_reduce($venta->formaPago()->pie->cuotas(true), }, 0))}}
function(float $sum, Incoviba\Model\Venta\Cuota $cuota) { </th>
return $sum + $cuota->pago->valor(); <th class="right aligned">
}, 0.0))}} {{$format->ufs($total = array_reduce($venta->formaPago()->pie->cuotas(),
</th> function(float $sum, Incoviba\Model\Venta\Cuota $cuota) use ($now, $uf_venta) {
<th class="right aligned"> return $sum + (($cuota->pago->fecha > $now or $cuota->pago->uf === null) ?
{{$format->number($pagado / $total * 100, 2)}}% $cuota->pago->valor / $uf_venta :
</th> $cuota->pago->valor());
<th colspan="3"></th> }, 0.0))}}
</tr> </th>
<tr> <th colspan="4"></th>
<th colspan="5">POR PAGAR</th> </tr>
<th class="right aligned"> <tr>
{{$format->pesos($total_pesos - $pagado_pesos)}} <th colspan="5">TOTAL PAGADO</th>
</th> <th class="right aligned">
<th class="right aligned"> {{$format->pesos($pagado_pesos = array_reduce($venta->formaPago()->pie->cuotas(true),
{{$format->ufs($total - $pagado)}} function(int $sum, Incoviba\Model\Venta\Cuota $cuota) {
</th> return $sum + $cuota->pago->valor;
<th class="right aligned"> }, 0))}}
{{$format->number(($total - $pagado) / $total * 100, 2)}}% </th>
</th> <th class="right aligned">
<th colspan="3"></th> {{$format->ufs($pagado = array_reduce($venta->formaPago()->pie->cuotas(true),
</tr> function(float $sum, Incoviba\Model\Venta\Cuota $cuota) {
</tfoot> return $sum + $cuota->pago->valor();
</table> }, 0.0))}}
</div> </th>
<th class="right aligned">
{{$format->number($pagado / $total * 100, 2)}}%
</th>
<th colspan="3"></th>
</tr>
<tr>
<th colspan="5">POR PAGAR</th>
<th class="right aligned">
{{$format->pesos($total_pesos - $pagado_pesos)}}
</th>
<th class="right aligned">
{{$format->ufs($total - $pagado)}}
</th>
<th class="right aligned">
{{$format->number(($total - $pagado) / $total * 100, 2)}}%
</th>
<th colspan="3"></th>
</tr>
</tfoot>
</table>
@endsection @endsection
@include('layout.body.scripts.datatables') @include('layout.body.scripts.datatables')

View File

@ -1,93 +1,86 @@
@extends('layout.base') @extends('ventas.base')
@section('page_content') @section('venta_subtitle')
<div class="ui container"> Agregar Cuotas - Pie
<div class="ui two column grid"> @endsection
<h1 class="four wide column header">
<div class="content"> @section('venta_content')
<div class="ui dividing sub header">{{$venta->proyecto()->descripcion}}</div> <form class="ui form" id="add_form" action="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add" method="post">
{{$venta->propiedad()->summary()}} <table class="ui table">
</div> <thead>
</h1> <tr>
</div> <th>#</th>
<h2>Agregar Cuotas - Pie</h2> <th>Fecha</th>
<form class="ui form" id="add_form" action="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add" method="post"> <th>Banco</th>
<table class="ui table"> <th>Identificador</th>
<thead> <th>Valor</th>
<tr> </tr>
<th>#</th> </thead>
<th>Fecha</th> <tbody id="cuotas">
<th>Banco</th> @for ($i = count($pie->cuotas(vigentes: true)); $i < $pie->cuotas; $i ++)
<th>Identificador</th> <tr>
<th>Valor</th> <td>{{$i + 1}}</td>
</tr> <td>
</thead> <div class="inline field">
<tbody id="cuotas"> <div class="ui calendar fecha" data-index="{{$i}}">
@for ($i = count($pie->cuotas(vigentes: true)); $i < $pie->cuotas; $i ++) <div class="ui icon input">
<tr> <input type="text" name="fecha{{$i}}" />
<td>{{$i + 1}}</td> <i class="calendar icon"></i>
<td>
<div class="inline field">
<div class="ui calendar fecha" data-index="{{$i}}">
<div class="ui icon input">
<input type="text" name="fecha{{$i}}" />
<i class="calendar icon"></i>
</div>
</div>
<button class="ui mini compact basic icon button copy fecha" type="button" data-index="{{$i}}">
<i class="down arrow icon"></i>
</button>
</div>
</td>
<td>
<div class="ui search selection dropdown banco" data-index="{{$i}}">
<input type="hidden" name="banco{{$i}}" />
<i class="dropdown icon"></i>
<div class="default text">Banco</div>
<div class="menu">
@foreach ($bancos as $banco)
@if ($banco->nombre === '')
@continue
@endif
<div class="item" data-value="{{$banco->id}}">{{$banco->nombre}}</div>
@endforeach
</div> </div>
</div> </div>
<button class="ui mini compact basic icon button copy banco" type="button" data-index="{{$i}}"> <button class="ui mini compact basic icon button copy fecha" type="button" data-index="{{$i}}">
<i class="down arrow icon"></i> <i class="down arrow icon"></i>
</button> </button>
</td> </div>
<td> </td>
<div class="ui input"> <td>
<input type="text" name="identificador{{$i}}" /> <div class="ui search selection dropdown banco" data-index="{{$i}}">
<input type="hidden" name="banco{{$i}}" />
<i class="dropdown icon"></i>
<div class="default text">Banco</div>
<div class="menu">
@foreach ($bancos as $banco)
@if ($banco->nombre === '')
@continue
@endif
<div class="item" data-value="{{$banco->id}}">{{$banco->nombre}}</div>
@endforeach
</div> </div>
</td> </div>
<td> <button class="ui mini compact basic icon button copy banco" type="button" data-index="{{$i}}">
<div class="inline field"> <i class="down arrow icon"></i>
<div class="ui left labeled input"> </button>
<div class="ui label">$</div> </td>
<input type="text" name="valor{{$i}}" /> <td>
</div> <div class="ui input">
<button class="ui mini compact basic icon button copy valor" type="button" data-index="{{$i}}"> <input type="text" name="identificador{{$i}}" />
<i class="down arrow icon"></i> </div>
</button> </td>
<td>
<div class="inline field">
<div class="ui left labeled input">
<div class="ui label">$</div>
<input type="text" name="valor{{$i}}" />
</div> </div>
</td> <button class="ui mini compact basic icon button copy valor" type="button" data-index="{{$i}}">
</tr> <i class="down arrow icon"></i>
@endfor
</tbody>
<tfoot>
<tr>
<td colspan="5">
<button class="ui button" type="submit">
Agregar
</button> </button>
</td> </div>
</tr> </td>
</tfoot> </tr>
</table> @endfor
</form> </tbody>
</div> <tfoot>
<tr>
<td colspan="5">
<button class="ui button" type="submit">
Agregar
</button>
</td>
</tr>
</tfoot>
</table>
</form>
@endsection @endsection
@include('layout.body.scripts.dayjs') @include('layout.body.scripts.dayjs')

View File

@ -1,27 +1,24 @@
@extends('layout.base') @extends('ventas.base')
@section('page_content') @section('venta_subtitle')
<div class="ui container"> Pie
<h2 class="ui header"> @endsection
Pie -
{{$venta->proyecto()->descripcion}} - @section('venta_content')
<a href="{{$urls->base}}/venta/{{$venta->id}}">{{$venta->propiedad()->summary()}}</a> <form class="ui form" id="edit_pie">
</h2> <div class="three wide field">
<form class="ui form" id="edit_pie"> <label for="valor">Valor</label>
<div class="three wide field"> <div class="ui right labeled input">
<label for="valor">Valor</label> <input type="text" name="valor" id="valor" value="{{$venta->formaPago()->pie->valor}}" />
<div class="ui right labeled input"> <div class="ui basic label">UF</div>
<input type="text" name="valor" id="valor" value="{{$venta->formaPago()->pie->valor}}" />
<div class="ui basic label">UF</div>
</div>
</div> </div>
<div class="three wide field"> </div>
<label for="cuotas"># Cuotas</label> <div class="three wide field">
<input type="number" name="cuotas" id="cuotas" value="{{$venta->formaPago()->pie->cuotas}}" /> <label for="cuotas"># Cuotas</label>
</div> <input type="number" name="cuotas" id="cuotas" value="{{$venta->formaPago()->pie->cuotas}}" />
<button class="ui button">Editar</button> </div>
</form> <button class="ui button">Editar</button>
</div> </form>
@endsection @endsection
@push('page_scripts') @push('page_scripts')

View File

@ -1,10 +1,39 @@
@extends('layout.base') @extends('ventas.base')
@section('page_title') @php
Venta {{$venta->proyecto()->descripcion}} {{$venta->propiedad()->summary()}} $showPropietario = true;
@endphp
@section('venta_content')
<div class="ui fitted basic mini segment">
@if ($venta->currentEstado()->tipoEstadoVenta->activa)
<a href="{{$urls->base}}/venta/{{$venta->id}}/desistir">
Desistir <i class="minus icon"></i>
</a>
<a href="{{$urls->base}}/venta/{{$venta->id}}/ceder">
Ceder <i clasS="right chevron icon"></i>
</a>
@else
<div class="ui red icon label">
<i class="ban icon"></i>
{{ucwords($venta->currentEstado()->tipoEstadoVenta->descripcion)}}
(<a href="{{$urls->base}}/venta/{{$venta->id}}/desistida">
{{$format->pesos($venta->resciliacion()->valor)}}
</a>)
</div>
@endif
</div>
<div class="ui segments">
@include('ventas.show.propiedad')
@include('ventas.show.detalle')
@include('ventas.show.forma_pago', ['formaPago' => $venta->formaPago()])
@include('ventas.show.escritura')
@include('ventas.show.entrega')
@include('ventas.show.comentarios')
</div>
@endsection @endsection
@section('page_content') {{--@section('page_content')
<div class="ui container"> <div class="ui container">
<div class="ui two column grid"> <div class="ui two column grid">
<h1 class="four wide column header"> <h1 class="four wide column header">
@ -45,4 +74,4 @@
@include('ventas.show.comentarios') @include('ventas.show.comentarios')
</div> </div>
</div> </div>
@endsection @endsection--}}

View File

@ -9,7 +9,7 @@
<i class="small edit icon"></i> <i class="small edit icon"></i>
</a> </a>
</sub> </sub>
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/informe"> <a href="{{$urls->base}}/ventas/escritura/{{$venta->id}}/informe">
Informe Informe
<i class="right chevron icon"></i> <i class="right chevron icon"></i>
</a> </a>

View File

@ -8,12 +8,18 @@ return [
(new Monolog\Handler\RotatingFileHandler('/logs/debug.log', 10)) (new Monolog\Handler\RotatingFileHandler('/logs/debug.log', 10))
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)), ->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
Monolog\Level::Debug, Monolog\Level::Debug,
Monolog\Level::Notice 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\FilterHandler(
(new Monolog\Handler\RotatingFileHandler('/logs/error.log', 10)) (new Monolog\Handler\RotatingFileHandler('/logs/error.log', 10))
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)), ->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
Monolog\Level::Warning, Monolog\Level::Error,
Monolog\Level::Error Monolog\Level::Error
), ),
new Monolog\Handler\FilterHandler( new Monolog\Handler\FilterHandler(

View File

@ -0,0 +1,20 @@
<?php
namespace Incoviba\Controller\API;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Service;
class Search
{
use withJson;
public function query(ServerRequestInterface $request, ResponseInterface $response,
Service\Search $service): ResponseInterface
{
$data = $request->getParsedBody();
$results = $service->query($data['query'], $data['tipo']);
$output = compact('results');
return $this->withJson($response, $output);
}
}

View File

@ -1,17 +1,19 @@
<?php <?php
namespace Incoviba\Controller\API; namespace Incoviba\Controller\API;
use PDOException;
use DateTimeImmutable; use DateTimeImmutable;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Ideal\Controller;
use Incoviba\Common\Implement\Exception\EmptyRedis; use Incoviba\Common\Implement\Exception\EmptyRedis;
use Incoviba\Common\Implement\Exception\EmptyResult; use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Controller\withRedis; use Incoviba\Controller\withRedis;
use Incoviba\Model; use Incoviba\Model;
use Incoviba\Repository; use Incoviba\Repository;
use Incoviba\Service; use Incoviba\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Ventas class Ventas extends Controller
{ {
use withJson, withRedis; use withJson, withRedis;
@ -55,6 +57,9 @@ class Ventas
Service\Venta $service, int $venta_id): ResponseInterface Service\Venta $service, int $venta_id): ResponseInterface
{ {
$redisKey = "venta:{$venta_id}"; $redisKey = "venta:{$venta_id}";
$output = [
'venta' => null
];
try { try {
$venta = $this->fetchRedis($redisService, $redisKey); $venta = $this->fetchRedis($redisService, $redisKey);
$output = compact('venta'); $output = compact('venta');
@ -64,12 +69,7 @@ class Ventas
$output = compact('venta'); $output = compact('venta');
$this->saveRedis($redisService, $redisKey, $venta); $this->saveRedis($redisService, $redisKey, $venta);
} catch (EmptyResult $exception) { } catch (EmptyResult $exception) {
$output = [ $this->logger->notice($exception);
'error' => [
'code' => $exception->getCode(),
'message' => str_replace([PHP_EOL, "\r"], [' ', ''], $exception->getMessage())
]
];
} }
} }
return $this->withJson($response, $output); return $this->withJson($response, $output);
@ -178,14 +178,20 @@ class Ventas
$data = $request->getParsedBody(); $data = $request->getParsedBody();
$output = [ $output = [
'status' => false, 'status' => false,
'venta_id' => null,
'errors' => [] 'errors' => []
]; ];
try { try {
$venta = $ventaService->add($data); $venta = $ventaService->add($data);
$this->saveRedis($redisService, "venta:{$venta->id}", $venta); $this->saveRedis($redisService, "venta:{$venta->id}", $venta);
$output['venta_id'] = $venta->id;
$output['status'] = true; $output['status'] = true;
} catch (\Exception $exception) { } catch (EmptyResult | PDOException $exception) {
$output['errors'] = $exception; $output['errors'] = [
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
'stack' => $exception->getTraceAsString()
];
} }
return $this->withJson($response, $output); return $this->withJson($response, $output);
} }

View File

@ -13,11 +13,4 @@ class Search
$post = $request->getParsedBody() ?? ''; $post = $request->getParsedBody() ?? '';
return $view->render($response, 'search', compact('post', 'query', 'tipo')); return $view->render($response, 'search', compact('post', 'query', 'tipo'));
} }
public function query(ServerRequestInterface $request, ResponseInterface $response, Service\Search $service): ResponseInterface
{
$data = $request->getParsedBody();
$results = $service->query($data['query'], $data['tipo']);
$response->getBody()->write(json_encode(compact('results')));
return $response->withHeader('Content-Type', 'application/json');
}
} }

View File

@ -8,9 +8,16 @@ use Incoviba\Service;
class Escrituras class Escrituras
{ {
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Venta $ventaService, 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); $venta = $ventaService->getById($venta_id);
return $view->render($response, 'ventas.escrituras.show', compact('venta')); return $view->render($response, 'ventas.escrituras.show', compact('venta'));
} }
public function informe(ServerRequestInterface $request, ResponseInterface $response, View $view,
Service\Venta $ventaService, int $venta_id): ResponseInterface
{
$venta = $ventaService->getById($venta_id);
return $view->render($response, 'ventas.escrituras.informe', compact('venta'));
}
} }

View File

@ -17,7 +17,7 @@ class NotFound
try { try {
return $handler->handle($request); return $handler->handle($request);
} catch (HttpNotFoundException $exception) { } catch (HttpNotFoundException $exception) {
$this->logger->warning($exception); $this->logger->notice($exception);
$response = $this->responseFactory->createResponse(404); $response = $this->responseFactory->createResponse(404);
if (str_contains($request->getUri()->getPath(), '/api')) { if (str_contains($request->getUri()->getPath(), '/api')) {
return $response; return $response;

View File

@ -19,8 +19,8 @@ class Venta extends Ideal\Model
public float $uf; public float $uf;
protected ?Pago $resciliacion; protected ?Pago $resciliacion;
public array $estados; public ?array $estados;
public Venta\EstadoVenta $currentEstado; public ?Venta\EstadoVenta $currentEstado;
public function propietario(): Venta\Propietario public function propietario(): Venta\Propietario
{ {
@ -63,7 +63,7 @@ class Venta extends Ideal\Model
if (!isset($this->estados)) { if (!isset($this->estados)) {
$this->estados = $this->runFactory('estados'); $this->estados = $this->runFactory('estados');
} }
return $this->estados; return $this->estados ?? [];
} }
public function currentEstado(): ?Venta\EstadoVenta public function currentEstado(): ?Venta\EstadoVenta
{ {

View File

@ -115,13 +115,15 @@ class Venta extends Ideal\Repository
->register('fecha_ingreso', new Implement\Repository\Mapper\DateTime('fecha_ingreso', 'fechaIngreso')) ->register('fecha_ingreso', new Implement\Repository\Mapper\DateTime('fecha_ingreso', 'fechaIngreso'))
//->register('avalchile') //->register('avalchile')
//->register('agente') //->register('agente')
->register('resciliacion', (new Implement\Repository\Mapper())
->setFactory((new Implement\Repository\Factory())
->setCallable([$this->pagoService, 'getById'])
->setArgs(['pago_id' => $data['resciliacion']])))
->register('relacionado', new Implement\Repository\Mapper\Boolean('relacionado')); ->register('relacionado', new Implement\Repository\Mapper\Boolean('relacionado'));
//->register('promocion') //->register('promocion')
//->register('devolucion'); //->register('devolucion');
if (array_key_exists('resciliacion', $data)) {
$map = $map->register('resciliacion', (new Implement\Repository\Mapper())
->setFactory((new Implement\Repository\Factory())
->setCallable([$this->pagoService, 'getById'])
->setArgs(['pago_id' => $data['resciliacion']])));
}
return $this->parseData(new Model\Venta(), $data, $map); return $this->parseData(new Model\Venta(), $data, $map);
} }
public function save(Define\Model $model): Model\Venta public function save(Define\Model $model): Model\Venta
@ -147,7 +149,17 @@ class Venta extends Ideal\Repository
public function fetchByProyecto(int $proyecto_id): array public function fetchByProyecto(int $proyecto_id): array
{ {
$query = "SELECT a.* $query = $this->connection->getQueryBuilder()
->select('a.*')
->from("{$this->getTable()} a")
->joined('JOIN propiedad_unidad pu ON pu.propiedad = a.propiedad')
->joined('JOIN unidad ON unidad.id = pu.unidad AND pu.principal = 1')
->joined('JOIN proyecto_tipo_unidad ptu ON ptu.id = unidad.pt')
->joined('JOIN (SELECT ev1.* FROM estado_venta ev1 JOIN (SELECT MAX(id) AS id, venta FROM estado_venta GROUP BY venta) ev0 ON ev0.id = ev1.id) ev ON ev.venta = a.id')
->joined('JOIN tipo_estado_venta tev ON tev.id = ev.estado')
->where('ptu.proyecto = ? AND tev.activa')
->group('a.id');
/*$query = "SELECT a.*
FROM `{$this->getTable()}` a FROM `{$this->getTable()}` a
JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad` JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad`
JOIN `unidad` ON `unidad`.`id` = pu.`unidad` AND pu.`principal` = 1 JOIN `unidad` ON `unidad`.`id` = pu.`unidad` AND pu.`principal` = 1
@ -155,129 +167,158 @@ FROM `{$this->getTable()}` a
JOIN (SELECT e1.* FROM `estado_venta` e1 JOIN (SELECT MAX(`id`) AS 'id', `venta` FROM `estado_venta` GROUP BY `venta`) e0 ON e0.`id` = e1.`id`) ev ON ev.`venta` = a.`id` JOIN (SELECT e1.* FROM `estado_venta` e1 JOIN (SELECT MAX(`id`) AS 'id', `venta` FROM `estado_venta` GROUP BY `venta`) e0 ON e0.`id` = e1.`id`) ev ON ev.`venta` = a.`id`
JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado` JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`
WHERE ptu.`proyecto` = ? AND tev.`activa` WHERE ptu.`proyecto` = ? AND tev.`activa`
GROUP BY a.`id`"; GROUP BY a.`id`";*/
return $this->fetchMany($query, [$proyecto_id]); return $this->fetchMany($query, [$proyecto_id]);
} }
public function fetchIdsByProyecto(int $proyecto_id): array public function fetchIdsByProyecto(int $proyecto_id): array
{ {
$query = "SELECT a.`id` $query = $this->connection->getQueryBuilder()
FROM `{$this->getTable()}` a ->select('a.id')
JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad` ->from("{$this->getTable()} a")
JOIN `unidad` ON `unidad`.`id` = pu.`unidad` AND pu.`principal` = 1 ->joined('JOIN propiedad_unidad pu ON pu.propiedad = a.propiedad')
JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt` ->joined('JOIN unidad ON unidad.id = pu.unidad AND unidad.pt')
JOIN (SELECT e1.* FROM `estado_venta` e1 JOIN (SELECT MAX(`id`) AS 'id', `venta` FROM `estado_venta` GROUP BY `venta`) e0 ON e0.`id` = e1.`id`) ev ON ev.`venta` = a.`id` ->joined('JOIN proyecto_tipo_unidad ptu ON ptu.id = unidad.pt')
JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado` ->joined('JOIN (SELECT ev1.* FROM estado_venta ev1 JOIN (SELECT MAX(id) AS id, venta FROM estado_venta GROUP BY venta) ev0 ON ev0.id = ev1.id) ev ON ev.venta = a.id')
WHERE ptu.`proyecto` = ? AND tev.`activa` ->joined('JOIN tipo_estado_venta tev ON tev.id = ev.estado')
GROUP BY a.`id`"; ->where('ptu.proyecto = ? AND tev.activa')
return $this->connection->execute($query, [$proyecto_id])->fetchAll(PDO::FETCH_ASSOC); ->group('a.id');
return $this->fetchIds($query, [$proyecto_id]);
} }
public function fetchActivaByProyecto(int $proyecto_id): array public function fetchActivaByProyecto(int $proyecto_id): array
{ {
$query = "SELECT a.* $query = $this->connection->getQueryBuilder()
FROM `{$this->getTable()}` a ->select('a.*')
JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad` ->from("{$this->getTable()} a")
JOIN `unidad` ON `unidad`.`id` = pu.`unidad` AND pu.`principal` = 1 ->joined('JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad`')
JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt` ->joined('JOIN `unidad` ON `unidad`.`id` = pu.`unidad` AND pu.`principal` = 1')
JOIN (SELECT e1.* FROM `estado_venta` e1 JOIN (SELECT MAX(`id`) AS 'id', `venta` FROM `estado_venta` GROUP BY `venta`) e0 ON e0.`id` = e1.`id`) ev ON ev.`venta` = a.`id` ->joined('JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt`')
JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado` ->joined("JOIN (SELECT e1.* FROM `estado_venta` e1 JOIN (SELECT MAX(`id`) AS 'id', `venta` FROM `estado_venta` GROUP BY `venta`) e0 ON e0.`id` = e1.`id`) ev ON ev.`venta` = a.`id`")
WHERE ptu.`proyecto` = ? AND tev.`activa` ->joined('JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`')
GROUP BY a.`id`"; ->where('ptu.`proyecto` = ? AND tev.`activa`')
->group('a.id');
return $this->fetchMany($query, [$proyecto_id]); return $this->fetchMany($query, [$proyecto_id]);
} }
public function fetchByProyectoAndUnidad(string $proyecto_nombre, int $unidad_descripcion): Model\Venta public function fetchByProyectoAndUnidad(string $proyecto_nombre, int $unidad_descripcion): Model\Venta
{ {
$query = "SELECT a.* $query = $this->connection->getQueryBuilder()
FROM `{$this->getTable()}` a ->select("a.*")
JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad` ->from("`{$this->getTable()}` a")
JOIN `unidad` ON `unidad`.`id` = pu.`unidad` AND pu.`principal` = 1 ->joined('JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad`')
JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt` ->joined('JOIN `unidad` ON `unidad`.`id` = pu.`unidad` AND pu.`principal` = 1')
JOIN `proyecto` ON `proyecto`.`id` = ptu.`proyecto` ->joined('JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt`')
JOIN (SELECT e1.* FROM `estado_venta` e1 JOIN (SELECT MAX(`id`) AS 'id', `venta` FROM `estado_venta` GROUP BY `venta`) e0 ON e0.`id` = e1.`id`) ev ON ev.`venta` = a.`id` ->joined('JOIN `proyecto` ON `proyecto`.`id` = ptu.`proyecto`')
JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado` ->joined("JOIN (SELECT e1.* FROM `estado_venta` e1 JOIN (SELECT MAX(`id`) AS 'id', `venta` FROM `estado_venta` GROUP BY `venta`) e0 ON e0.`id` = e1.`id`) ev ON ev.`venta` = a.`id`")
WHERE `proyecto`.`descripcion` = ? AND `unidad`.`descripcion` = ? AND tev.`activa`"; ->joined('JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`')
->where('`proyecto`.`descripcion` = ? AND `unidad`.`descripcion` = ? AND tev.`activa`');
return $this->fetchOne($query, [$proyecto_nombre, $unidad_descripcion]); return $this->fetchOne($query, [$proyecto_nombre, $unidad_descripcion]);
} }
public function fetchByPie(int $pie_id): Model\Venta public function fetchByPie(int $pie_id): Model\Venta
{ {
$query = "SELECT * FROM `{$this->getTable()}` WHERE `pie` = ?"; $query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('pie = ?');
return $this->fetchOne($query, [$pie_id]); return $this->fetchOne($query, [$pie_id]);
} }
public function fetchIdByPie(int $pie_id): array public function fetchIdByPie(int $pie_id): array
{ {
$query = "SELECT `id` FROM `{$this->getTable()}` WHERE `pie` = ?"; $query = $this->connection->getQueryBuilder()
return $this->connection->execute($query, [$pie_id])->fetch(PDO::FETCH_ASSOC); ->select('id')
->from($this->getTable())
->where('pie = ?');
return $this->fetchId($query, [$pie_id]);
} }
public function fetchByUnidad(string $unidad, string $tipo): array public function fetchByUnidad(string $unidad, string $tipo): array
{ {
$query = "SELECT a.* $query = $this->connection->getQueryBuilder()
FROM `{$this->getTable()}` a ->select('a.*')
JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad` ->from("{$this->getTable()} a")
JOIN `unidad` ON `unidad`.`id` = pu.`unidad` ->joined('JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad`')
JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt` ->joined('JOIN `unidad` ON `unidad`.`id` = pu.`unidad`')
JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo` ->joined('JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt`')
WHERE `unidad`.`descripcion` LIKE ? AND tu.`descripcion` = ?"; ->joined('JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`')
->where('`unidad`.`descripcion` LIKE ? AND tu.`descripcion` = ?');
return $this->fetchMany($query, [$unidad, $tipo]); return $this->fetchMany($query, [$unidad, $tipo]);
} }
public function fetchIdsByUnidad(string $unidad, string $tipo): array public function fetchIdsByUnidad(string $unidad, string $tipo): array
{ {
$query = "SELECT a.id $query = $this->connection->getQueryBuilder()
FROM `{$this->getTable()}` a ->select('a.id')
JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad` ->from("{$this->getTable()} a")
JOIN `unidad` ON `unidad`.`id` = pu.`unidad` ->joined('JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad`')
JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt` ->joined('JOIN `unidad` ON `unidad`.`id` = pu.`unidad`')
JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo` ->joined('JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt`')
WHERE `unidad`.`descripcion` LIKE ? AND tu.`descripcion` = ?"; ->joined('JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`')
return $this->connection->execute($query, [$unidad, $tipo])->fetchAll(PDO::FETCH_ASSOC); ->where('`unidad`.`descripcion` LIKE ? AND tu.`descripcion` = ?');
return $this->fetchIds($query, [$unidad, $tipo]);
} }
public function fetchByPrecio(string $precio): array public function fetchByPrecio(string $precio): array
{ {
$query = "SELECT * FROM `{$this->getTable()}` WHERE `valor_uf` = ?"; $query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('valor_uf = ?');
return $this->fetchMany($query, [$precio]); return $this->fetchMany($query, [$precio]);
} }
public function fetchIdsByPrecio(string $precio): array public function fetchIdsByPrecio(string $precio): array
{ {
$query = "SELECT `id` FROM `{$this->getTable()}` WHERE `valor_uf` = ?"; $query = $this->connection->getQueryBuilder()
return $this->connection->execute($query, [$precio])->fetchAll(PDO::FETCH_ASSOC); ->select('id')
->from($this->getTable())
->where('valor_uf = ?');
return $this->fetchIds($query, [$precio]);
}
public function fetchByPropietarioAndPropiedad(int $propietario_rut, int $propiedad_id): Model\Venta
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('propietario = ? AND propiedad = ?');
return $this->fetchOne($query, [$propietario_rut, $propiedad_id]);
} }
public function fetchByPropietario(string $propietario): array public function fetchByPropietario(string $propietario): array
{ {
$query = "SELECT a.* $query = $this->connection->getQueryBuilder()
FROM `{$this->getTable()}` a ->select('a.*')
JOIN `propietario` ON `propietario`.`rut` = a.`propietario` ->from("{$this->getTable()} a")
WHERE CONCAT_WS('-', `propietario`.`rut`, `propietario`.`dv`) LIKE :propietario OR `propietario`.`nombres` LIKE :propietario ->joined('JOIN `propietario` ON `propietario`.`rut` = a.`propietario`')
->where("CONCAT_WS('-', `propietario`.`rut`, `propietario`.`dv`) LIKE :propietario OR `propietario`.`nombres` LIKE :propietario
OR `propietario`.`apellido_paterno` LIKE :propietario OR `propietario`.`apellido_materno` LIKE :propietario OR `propietario`.`apellido_paterno` LIKE :propietario OR `propietario`.`apellido_materno` LIKE :propietario
OR CONCAT_WS(' ', `propietario`.`nombres`, `propietario`.`apellido_paterno`, `propietario`.`apellido_materno`) LIKE :propietario"; OR CONCAT_WS(' ', `propietario`.`nombres`, `propietario`.`apellido_paterno`, `propietario`.`apellido_materno`) LIKE :propietario");
return $this->fetchMany($query, [':propietario' => "%{$propietario}%"]); return $this->fetchMany($query, [':propietario' => "%{$propietario}%"]);
} }
public function fetchIdsByPropietario(string $propietario): array public function fetchIdsByPropietario(string $propietario): array
{ {
$query = "SELECT a.id $query = $this->connection->getQueryBuilder()
FROM `{$this->getTable()}` a ->select('a.id')
JOIN `propietario` ON `propietario`.`rut` = a.`propietario` ->from("{$this->getTable()} a")
WHERE CONCAT_WS('-', `propietario`.`rut`, `propietario`.`dv`) LIKE :propietario OR `propietario`.`nombres` LIKE :propietario ->joined('JOIN `propietario` ON `propietario`.`rut` = a.`propietario`')
->where("CONCAT_WS('-', `propietario`.`rut`, `propietario`.`dv`) LIKE :propietario OR `propietario`.`nombres` LIKE :propietario
OR `propietario`.`apellido_paterno` LIKE :propietario OR `propietario`.`apellido_materno` LIKE :propietario OR `propietario`.`apellido_paterno` LIKE :propietario OR `propietario`.`apellido_materno` LIKE :propietario
OR CONCAT_WS(' ', `propietario`.`nombres`, `propietario`.`apellido_paterno`, `propietario`.`apellido_materno`) LIKE :propietario"; OR CONCAT_WS(' ', `propietario`.`nombres`, `propietario`.`apellido_paterno`, `propietario`.`apellido_materno`) LIKE :propietario");
return $this->connection->execute($query, [':propietario' => "%{$propietario}%"])->fetchAll(PDO::FETCH_ASSOC); return $this->fetchIds($query, [':propietario' => "%{$propietario}%"]);
} }
public function fetchByPropietarioNombreCompleto(string $propietario): array public function fetchByPropietarioNombreCompleto(string $propietario): array
{ {
$query = "SELECT a.* $query = $this->connection->getQueryBuilder()
FROM `{$this->getTable()}` a ->select('a.*')
JOIN `propietario` ON `propietario`.`rut` = a.`propietario` ->from("{$this->getTable()} a")
WHERE CONCAT_WS(' ', `propietario`.`nombres`, `propietario`.`apellido_paterno`, `propietario`.`apellido_materno`) LIKE ?"; ->joined('JOIN `propietario` ON `propietario`.`rut` = a.`propietario`')
->where("CONCAT_WS(' ', `propietario`.`nombres`, `propietario`.`apellido_paterno`, `propietario`.`apellido_materno`) LIKE ?");
return $this->fetchMany($query, [$propietario]); return $this->fetchMany($query, [$propietario]);
} }
public function fetchEscriturasByProyecto(int $proyecto_id): array public function fetchEscriturasByProyecto(int $proyecto_id): array
{ {
$query = "SELECT DISTINCT a.* $query = $this->connection->getQueryBuilder()
FROM `{$this->getTable()}` a ->select('DISTINCT a.*')
JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad` ->from("{$this->getTable()} a")
JOIN `unidad` ON `unidad`.`id` = pu.`unidad` ->joined('JOIN `propiedad_unidad` pu ON pu.`propiedad` = a.`propiedad`')
JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`id` ->joined('JOIN `unidad` ON `unidad`.`id` = pu.`unidad`')
JOIN (SELECT e1.* FROM `estado_venta` e1 JOIN (SELECT MAX(`id`) AS 'id', `venta` FROM `estado_venta` GROUP BY `venta`) e0 ON e0.`id` = e1.`id`) ev ON ev.`venta` = a.`id` ->joined('JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`id`')
JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado` ->joined("JOIN (SELECT e1.* FROM `estado_venta` e1 JOIN (SELECT MAX(`id`) AS 'id', `venta` FROM `estado_venta` GROUP BY `venta`) e0 ON e0.`id` = e1.`id`) ev ON ev.`venta` = a.`id`")
WHERE ptu.`proyecto` = ? AND tev.`descripcion` IN ('firmado por inmobiliaria', 'escriturando') ->joined('JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`')
GROUP BY a.`id`"; ->where("ptu.`proyecto` = ? AND tev.`descripcion` IN ('firmado por inmobiliaria', 'escriturando')")
->group('a.id');
return $this->fetchMany($query, [$proyecto_id]); return $this->fetchMany($query, [$proyecto_id]);
} }
public function fetchIdByEscritura(int $escritura_id): array public function fetchIdByEscritura(int $escritura_id): array
@ -286,7 +327,7 @@ GROUP BY a.`id`";
->select('id') ->select('id')
->from($this->getTable()) ->from($this->getTable())
->where('escritura = ?'); ->where('escritura = ?');
return $this->connection->execute($query, [$escritura_id])->fetch(PDO::FETCH_ASSOC); return $this->fetchId($query, [$escritura_id]);
} }
public function fetchIdBySubsidio(int $subsidio_id): array public function fetchIdBySubsidio(int $subsidio_id): array
{ {
@ -294,7 +335,7 @@ GROUP BY a.`id`";
->select('id') ->select('id')
->from($this->getTable()) ->from($this->getTable())
->where('subsidio = ?'); ->where('subsidio = ?');
return $this->connection->execute($query, [$subsidio_id])->fetch(PDO::FETCH_ASSOC); return $this->fetchId($query, [$subsidio_id]);
} }
public function fetchIdByCredito(int $credito_id): array public function fetchIdByCredito(int $credito_id): array
{ {
@ -302,7 +343,7 @@ GROUP BY a.`id`";
->select('id') ->select('id')
->from($this->getTable()) ->from($this->getTable())
->where('credito = ?'); ->where('credito = ?');
return $this->connection->execute($query, [$credito_id])->fetch(PDO::FETCH_ASSOC); return $this->fetchId($query, [$credito_id]);
} }
public function fetchIdByBono(int $bono_id): array public function fetchIdByBono(int $bono_id): array
{ {
@ -310,6 +351,23 @@ GROUP BY a.`id`";
->select('id') ->select('id')
->from($this->getTable()) ->from($this->getTable())
->where('bono_pie = ?'); ->where('bono_pie = ?');
return $this->connection->execute($query, [$bono_id])->fetch(PDO::FETCH_ASSOC); return $this->fetchId($query, [$bono_id]);
}
protected function fetchIds(string $query, ?array $data = null): array
{
$results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC);
if ($results === false) {
throw new Implement\Exception\EmptyResult($query);
}
return $results;
}
protected function fetchId(string $query, ?array $data = null): array
{
$results = $this->connection->execute($query, $data)->fetch(PDO::FETCH_ASSOC);
if ($results === false) {
throw new Implement\Exception\EmptyResult($query);
}
return $results;
} }
} }

View File

@ -21,12 +21,16 @@ class Format
{ {
return number_format($number, $decimal_places, ',', '.'); return number_format($number, $decimal_places, ',', '.');
} }
public function percent(float|string $number, int $decimal_places = 2): string
{
return "{$this->number($number, $decimal_places)}%";
}
public function pesos(string $valor): string public function pesos(string $valor): string
{ {
return '$ ' . $this->number($valor); return "$ {$this->number($valor)}";
} }
public function ufs(string $valor): string public function ufs(string $valor): string
{ {
return $this->number($valor, 2) . ' UF'; return "{$this->number($valor, 2)} UF";
} }
} }

View File

@ -5,12 +5,11 @@ use DateTimeInterface;
use DateTimeImmutable; use DateTimeImmutable;
use DateInterval; use DateInterval;
use Incoviba\Common\Implement\Exception\EmptyRedis; use Incoviba\Common\Implement\Exception\EmptyRedis;
use Psr\Log\LoggerInterface;
class IPC class IPC
{ {
protected string $redisKey = 'ipc'; protected string $redisKey = 'ipc';
public function __construct(protected Redis $redisService, protected Money $moneyService, protected LoggerInterface $logger) {} public function __construct(protected Redis $redisService, protected Money $moneyService) {}
public function get(DateTimeInterface $from, DateTimeInterface $to = new DateTimeImmutable()): float public function get(DateTimeInterface $from, DateTimeInterface $to = new DateTimeImmutable()): float
{ {

View File

@ -65,7 +65,11 @@ class Search
foreach ($queries as $q) { foreach ($queries as $q) {
$this->add($results, $this->findVentas($q, $tipo)); $this->add($results, $this->findVentas($q, $tipo));
if (in_array($tipo, $tiposUnidades)) { if (in_array($tipo, $tiposUnidades)) {
$this->add($results, $this->findUnidadesDisponibles($q, $tipo), false); $disponibles = $this->findUnidadesDisponibles($q, $tipo);
if (count($disponibles) === 0) {
continue;
}
$this->add($results, $disponibles, false);
} }
} }
return $results; return $results;
@ -138,6 +142,9 @@ class Search
} }
protected function findPago(string $query): array protected function findPago(string $query): array
{ {
if ($query != 0) {
return [];
}
$methods = [ $methods = [
'findPie', 'findPie',
'findEscritura', 'findEscritura',
@ -148,7 +155,7 @@ class Search
$valor = str_replace(['$', '.', ','], ['', '', '.'], $query); $valor = str_replace(['$', '.', ','], ['', '', '.'], $query);
$pagos = []; $pagos = [];
try { try {
$pagos = $this->pagoRepository->fetchByValue($valor); $pagos = $this->pagoRepository->fetchByValue((int) $valor);
} catch (EmptyResult) {} } catch (EmptyResult) {}
$results = []; $results = [];
foreach ($methods as $method) { foreach ($methods as $method) {
@ -160,7 +167,7 @@ class Search
{ {
$results = []; $results = [];
try { try {
$pies = $this->pieRepository->fetchByValue($query); $pies = $this->pieRepository->fetchByValue((float) $query);
foreach ($pies as $pie) { foreach ($pies as $pie) {
try { try {
$this->add($results, [$this->ventaRepository->fetchIdByPie($pie->id)]); $this->add($results, [$this->ventaRepository->fetchIdByPie($pie->id)]);
@ -176,7 +183,7 @@ class Search
$results = []; $results = [];
foreach ($pagos as $pago) { foreach ($pagos as $pago) {
try { try {
$pie = $this->pieRepository->fetchByReajuste($pago->id); $pie = $this->pieRepository->fetchByReajuste((int) $pago->id);
$this->add($results, [$this->ventaRepository->fetchIdByPie($pie->id)]); $this->add($results, [$this->ventaRepository->fetchIdByPie($pie->id)]);
} catch (EmptyResult) {} } catch (EmptyResult) {}
} }
@ -197,7 +204,7 @@ class Search
{ {
$results = []; $results = [];
try { try {
$escrituras = $this->escrituraRepository->fetchByValue($query); $escrituras = $this->escrituraRepository->fetchByValue((int) $query);
foreach ($escrituras as $escritura) { foreach ($escrituras as $escritura) {
try { try {
$this->add($results, [$this->ventaRepository->fetchIdByEscritura($escritura->id)]); $this->add($results, [$this->ventaRepository->fetchIdByEscritura($escritura->id)]);
@ -227,7 +234,7 @@ class Search
{ {
$results = []; $results = [];
try { try {
$creditos = $this->creditoRepository->fetchByValue($query); $creditos = $this->creditoRepository->fetchByValue((int) $query);
foreach ($creditos as $credito) { foreach ($creditos as $credito) {
try { try {
$this->add($results, [$this->ventaRepository->fetchIdByCredito($credito->id)]); $this->add($results, [$this->ventaRepository->fetchIdByCredito($credito->id)]);
@ -252,7 +259,7 @@ class Search
{ {
$results = []; $results = [];
try { try {
$bonos = $this->bonoPieRepository->fetchByValue($query); $bonos = $this->bonoPieRepository->fetchByValue((float) $query);
foreach ($bonos as $bono) { foreach ($bonos as $bono) {
try { try {
$this->add($results, [$this->ventaRepository->fetchIdByBono($bono->id)]); $this->add($results, [$this->ventaRepository->fetchIdByBono($bono->id)]);
@ -281,11 +288,10 @@ class Search
protected function add(array &$results, array $found, bool $is_venta = true): void protected function add(array &$results, array $found, bool $is_venta = true): void
{ {
foreach ($found as $item) { foreach ($found as $item) {
if (!isset($item['tipo'])) {
$item['tipo'] = ($is_venta) ? 'venta' : 'unidad';
}
if (!$this->inResults($item, $results)) { if (!$this->inResults($item, $results)) {
$item['tipo'] = 'venta';
if (!$is_venta) {
$item['tipo'] = 'unidad';
}
$results []= $item; $results []= $item;
} }
} }

View File

@ -5,6 +5,7 @@ use DateTimeImmutable;
use Incoviba\Common\Implement; use Incoviba\Common\Implement;
use Incoviba\Repository; use Incoviba\Repository;
use Incoviba\Model; use Incoviba\Model;
use PhpParser\Node\Expr\AssignOp\Mod;
class Venta class Venta
{ {
@ -14,6 +15,8 @@ class Venta
protected Repository\Venta\TipoEstadoVenta $tipoEstadoVentaRepository, protected Repository\Venta\TipoEstadoVenta $tipoEstadoVentaRepository,
protected Repository\Venta\Credito $creditoRepository, protected Repository\Venta\Credito $creditoRepository,
protected Repository\Venta\Escritura $escrituraRepository, protected Repository\Venta\Escritura $escrituraRepository,
protected Repository\Venta\Pago $pagoRepository,
protected Repository\Venta\EstadoPago $estadoPagoRepository,
protected Venta\Propietario $propietarioService, protected Venta\Propietario $propietarioService,
protected Venta\Propiedad $propiedadService, protected Venta\Propiedad $propiedadService,
protected Venta\Pie $pieService, protected Venta\Pie $pieService,
@ -97,17 +100,22 @@ class Venta
$venta_data[$field] = $forma_pago->{$name}->id; $venta_data[$field] = $forma_pago->{$name}->id;
} }
} }
$venta = $this->ventaRepository->create($venta_data); try {
$venta = $this->ventaRepository->save($venta); return $this->ventaRepository->fetchByPropietarioAndPropiedad($propietario->rut, $propiedad->id);
$tipoEstado = $this->tipoEstadoVentaRepository->fetchByDescripcion('vigente'); } catch (Implement\Exception\EmptyResult) {
$estado = $this->estadoVentaRepository->create([ $venta = $this->ventaRepository->create($venta_data);
'venta' => $venta->id, $venta = $this->ventaRepository->save($venta);
'estado' => $tipoEstado->id,
'fecha' => $venta->fecha->format('Y-m-d')
]);
$this->estadoVentaRepository->save($estado);
return $venta; $tipoEstado = $this->tipoEstadoVentaRepository->fetchByDescripcion('vigente');
$estado = $this->estadoVentaRepository->create([
'venta' => $venta->id,
'estado' => $tipoEstado->id,
'fecha' => $venta->fecha->format('Y-m-d')
]);
$this->estadoVentaRepository->save($estado);
return $venta;
}
} }
protected function addPropietario(array $data): Model\Venta\Propietario protected function addPropietario(array $data): Model\Venta\Propietario
{ {
@ -312,8 +320,8 @@ class Venta
if ($this->validarData($data, ['fecha_pago'], ['valor_pago_pesos', 'valor_pago_ufs'])) { if ($this->validarData($data, ['fecha_pago'], ['valor_pago_pesos', 'valor_pago_ufs'])) {
$this->abonoEscritura($venta, $data); $this->abonoEscritura($venta, $data);
} }
if ($this->validarData($data, ['banco_credito'])) { if ($this->validarData($data, ['banco_credito'], ['valor_credito'])) {
$this->creditoRepository->edit($venta->formaPago()->credito, ['banco' => $data['banco_credito']]); $this->editCredito($venta, $data);
} }
if ($this->validarData($data, ['valor_subsidio', 'valor_ahorro', 'fecha'])) { if ($this->validarData($data, ['valor_subsidio', 'valor_ahorro', 'fecha'])) {
$this->subsidioEscritura($venta, $data); $this->subsidioEscritura($venta, $data);
@ -357,11 +365,18 @@ class Venta
$fecha = new DateTimeImmutable($data['fecha_pago']); $fecha = new DateTimeImmutable($data['fecha_pago']);
$uf = $this->moneyService->getUF($fecha); $uf = $this->moneyService->getUF($fecha);
$valor = $data['valor_pago_ufs'] !== '' ? $data['valor_pago_ufs'] * $uf : $data['valor_pago_pesos']; $valor = $data['valor_pago_ufs'] !== '' ? $data['valor_pago_ufs'] * $uf : $data['valor_pago_pesos'];
$escrituraData = [ $pagoData = [
'valor' => $valor, 'valor' => $valor,
'fecha' => $fecha->format('Y-m-d'), 'fecha' => $fecha->format('Y-m-d'),
'uf' => $uf 'uf' => $uf
]; ];
$pago = $this->pagoService->add($pagoData);
$escrituraData = [
'valor' => $valor,
'fecha' => $fecha->format('Y-m-d'),
'uf' => $uf,
'pago' => $pago->id
];
$escritura = $this->escrituraRepository->create($escrituraData); $escritura = $this->escrituraRepository->create($escrituraData);
$escritura = $this->escrituraRepository->save($escritura); $escritura = $this->escrituraRepository->save($escritura);
$this->ventaRepository->edit($venta, ['escritura' => $escritura->id]); $this->ventaRepository->edit($venta, ['escritura' => $escritura->id]);
@ -379,6 +394,42 @@ class Venta
$subsidio = $this->addSubsidio($subsidioData); $subsidio = $this->addSubsidio($subsidioData);
$this->ventaRepository->edit($venta, ['subsidio' => $subsidio->id]); $this->ventaRepository->edit($venta, ['subsidio' => $subsidio->id]);
} }
protected function editCredito(Model\Venta $venta, array $data): void
{
$fecha = new DateTimeImmutable($data['fecha']);
$uf = $this->moneyService->getUF($fecha);
$valor = $data['valor_credito'] * $uf;
if ($venta->formaPago()->credito === null) {
$pagoData = [
'valor' => $valor,
'fecha' => $fecha->format('Y-m-d'),
'uf' => $uf
];
$pago = $this->pagoService->add($pagoData);
$creditoData = [
'banco' => $data['banco_credito'],
'valor' => $valor,
'pago' => $pago->id
];
$credito = $this->creditoRepository->create($creditoData);
$credito = $this->creditoRepository->save($credito);
$this->ventaRepository->edit($venta, ['credito' => $credito->id]);
return;
}
$this->pagoRepository->edit($venta->formaPago()->credito->pago, [
'valor' => $valor,
'banco' => $data['banco_credito'],
'uf' => $uf
]);
$this->estadoPagoRepository->edit($venta->formaPago()->credito->pago->currentEstado, [
'fecha' => $fecha->format('Y-m-d')
]);
$this->creditoRepository->edit($venta->formaPago()->credito, [
'valor' => $valor,
'fecha' => $fecha->format('Y-m-d'),
'uf' => $uf
]);
}
public function desistir(Model\Venta $venta, array $data): bool public function desistir(Model\Venta $venta, array $data): bool
{ {

View File

@ -78,7 +78,7 @@ class Propiedad
if (count($diff) === 0) { if (count($diff) === 0) {
return; return;
} }
$query = "DELECT FROM `propiedad_unidad` WHERE `propiedad` = ? AND `unidad` = ?"; $query = "DELETE FROM `propiedad_unidad` WHERE `propiedad` = ? AND `unidad` = ?";
$statement = $this->connection->prepare($query); $statement = $this->connection->prepare($query);
foreach ($diff as $id) { foreach ($diff as $id) {
$statement->execute([$propiedad->id, $id]); $statement->execute([$propiedad->id, $id]);

View File

@ -0,0 +1,2 @@
<?php
Monolog\ErrorHandler::register($app->getContainer()->get(Psr\Log\LoggerInterface::class));

View File

@ -8,12 +8,18 @@ return [
(new Monolog\Handler\RotatingFileHandler('/logs/debug.log', 10)) (new Monolog\Handler\RotatingFileHandler('/logs/debug.log', 10))
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)), ->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
Monolog\Level::Debug, Monolog\Level::Debug,
Monolog\Level::Notice 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\FilterHandler(
(new Monolog\Handler\RotatingFileHandler('/logs/error.log', 10)) (new Monolog\Handler\RotatingFileHandler('/logs/error.log', 10))
->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)), ->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)),
Monolog\Level::Warning, Monolog\Level::Error,
Monolog\Level::Error Monolog\Level::Error
), ),
new Monolog\Handler\FilterHandler( new Monolog\Handler\FilterHandler(
@ -23,7 +29,6 @@ return [
) )
], [ ], [
$container->get(Monolog\Processor\PsrLogMessageProcessor::class), $container->get(Monolog\Processor\PsrLogMessageProcessor::class),
$container->get(Monolog\Processor\WebProcessor::class),
$container->get(Monolog\Processor\IntrospectionProcessor::class), $container->get(Monolog\Processor\IntrospectionProcessor::class),
$container->get(Monolog\Processor\MemoryUsageProcessor::class), $container->get(Monolog\Processor\MemoryUsageProcessor::class),
$container->get(Monolog\Processor\MemoryPeakUsageProcessor::class) $container->get(Monolog\Processor\MemoryPeakUsageProcessor::class)

View File

@ -1,3 +1,3 @@
display_errors=no display_errors=no
log_errors=yes log_errors=yes
error_log=/logs/errors.log #error_log=/logs/errors.log