Compare commits
29 Commits
880113fe86
...
develop
Author | SHA1 | Date | |
---|---|---|---|
06558d778d | |||
538833a5a4 | |||
7bee4e3bb4 | |||
0c640d6cab | |||
6d871d77fe | |||
b0267320a1 | |||
a668b6b7be | |||
82ba2cfdff | |||
496dca9133 | |||
d171a61b8a | |||
7b11fdc6ce | |||
31fc1269b4 | |||
46d810555c | |||
3cf67a71b6 | |||
fc65ee581a | |||
b750f80eb7 | |||
2d5a526b43 | |||
b2e0031422 | |||
a478c61563 | |||
be7f5b26f1 | |||
e7a86e37e0 | |||
22195dae8b | |||
c2cb8f91ad | |||
600773a270 | |||
6ddc48ec60 | |||
331ee1e584 | |||
24c17debf3 | |||
552fd0aa06 | |||
60faf293d4 |
@ -2,6 +2,7 @@
|
|||||||
namespace Incoviba\Common\Define\Cartola;
|
namespace Incoviba\Common\Define\Cartola;
|
||||||
|
|
||||||
use Psr\Http\Message\UploadedFileInterface;
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
|
use Incoviba\Exception\ServiceAction\Read;
|
||||||
|
|
||||||
interface Banco
|
interface Banco
|
||||||
{
|
{
|
||||||
@ -9,6 +10,7 @@ interface Banco
|
|||||||
* Process bank movements for database inserts
|
* Process bank movements for database inserts
|
||||||
* @param UploadedFileInterface $file
|
* @param UploadedFileInterface $file
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Read
|
||||||
*/
|
*/
|
||||||
public function process(UploadedFileInterface $file): array;
|
public function process(UploadedFileInterface $file): array;
|
||||||
|
|
||||||
|
@ -3,10 +3,16 @@ namespace Incoviba\Common\Ideal\Cartola;
|
|||||||
|
|
||||||
use Incoviba\Common\Define;
|
use Incoviba\Common\Define;
|
||||||
use Incoviba\Common\Ideal\Service;
|
use Incoviba\Common\Ideal\Service;
|
||||||
|
use Incoviba\Exception\ServiceAction\Read;
|
||||||
use Psr\Http\Message\UploadedFileInterface;
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
|
|
||||||
abstract class Banco extends Service implements Define\Cartola\Banco
|
abstract class Banco extends Service implements Define\Cartola\Banco
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param UploadedFileInterface $file
|
||||||
|
* @return array
|
||||||
|
* @throws Read
|
||||||
|
*/
|
||||||
public function process(UploadedFileInterface $file): array
|
public function process(UploadedFileInterface $file): array
|
||||||
{
|
{
|
||||||
$filename = $this->processUploadedFile($file);
|
$filename = $this->processUploadedFile($file);
|
||||||
@ -40,6 +46,7 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
|||||||
* Process the temp file from getFilename and remove it
|
* Process the temp file from getFilename and remove it
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Read
|
||||||
*/
|
*/
|
||||||
protected function processFile(string $filename): array
|
protected function processFile(string $filename): array
|
||||||
{
|
{
|
||||||
@ -88,6 +95,7 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
|||||||
* Translate uploaded file data to database data
|
* Translate uploaded file data to database data
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws Read
|
||||||
*/
|
*/
|
||||||
abstract protected function parseFile(string $filename): array;
|
abstract protected function parseFile(string $filename): array;
|
||||||
}
|
}
|
||||||
|
68
app/common/Implement/Log/Processor/Exception.php
Normal file
68
app/common/Implement/Log/Processor/Exception.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
namespace Incoviba\Common\Implement\Log\Processor;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
use Monolog\LogRecord;
|
||||||
|
use Monolog\Processor\ProcessorInterface;
|
||||||
|
|
||||||
|
class Exception implements ProcessorInterface
|
||||||
|
{
|
||||||
|
public function __invoke(LogRecord $record): LogRecord
|
||||||
|
{
|
||||||
|
$context = $record->context;
|
||||||
|
$changed = false;
|
||||||
|
array_walk_recursive($context, function (&$item) use (&$changed) {
|
||||||
|
if (is_a($item, Throwable::class)) {
|
||||||
|
$item = $this->processException($item);
|
||||||
|
$changed = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if ($changed) {
|
||||||
|
$new_record = new LogRecord(
|
||||||
|
$record->datetime,
|
||||||
|
$record->channel,
|
||||||
|
$record->level,
|
||||||
|
$record->message,
|
||||||
|
$context,
|
||||||
|
$record->extra
|
||||||
|
);
|
||||||
|
$record = $new_record;
|
||||||
|
}
|
||||||
|
if (is_a($record->message, Throwable::class)) {
|
||||||
|
$exception = $record->message;
|
||||||
|
$output = $this->processException($exception);
|
||||||
|
$message = $output['message'];
|
||||||
|
if (array_key_exists('exception', $context)) {
|
||||||
|
$context['other_exception'] = $context['exception'];
|
||||||
|
}
|
||||||
|
$context['exception'] = $output;
|
||||||
|
$new_record = new LogRecord(
|
||||||
|
$record->datetime,
|
||||||
|
$record->channel,
|
||||||
|
$record->level,
|
||||||
|
$message,
|
||||||
|
$context,
|
||||||
|
$record->extra
|
||||||
|
);
|
||||||
|
$record = $new_record;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $record;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function processException(Throwable $exception): array
|
||||||
|
{
|
||||||
|
$output = [
|
||||||
|
'class' => get_class($exception),
|
||||||
|
'code' => $exception->getCode(),
|
||||||
|
'message' => $exception->getMessage(),
|
||||||
|
'file' => $exception->getFile(),
|
||||||
|
'line' => $exception->getLine(),
|
||||||
|
'trace' => $exception->getTraceAsString(),
|
||||||
|
];
|
||||||
|
if ($exception->getPrevious() !== null) {
|
||||||
|
$output['previous'] = $this->processException($exception);
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
final class AddCommentsToReservations extends AbstractMigration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Change Method.
|
||||||
|
*
|
||||||
|
* Write your reversible migrations using this method.
|
||||||
|
*
|
||||||
|
* More information on writing migrations is available here:
|
||||||
|
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||||
|
*
|
||||||
|
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||||
|
* with the Table class.
|
||||||
|
*/
|
||||||
|
public function change(): void
|
||||||
|
{
|
||||||
|
$this->table('reservations')
|
||||||
|
->addColumn('comments', 'text')
|
||||||
|
->update();
|
||||||
|
}
|
||||||
|
}
|
@ -338,6 +338,7 @@
|
|||||||
data.errors.forEach(errorData => {
|
data.errors.forEach(errorData => {
|
||||||
console.error(errorData)
|
console.error(errorData)
|
||||||
})
|
})
|
||||||
|
throw Error('Error al importar cartolas')
|
||||||
}
|
}
|
||||||
this.data.movimientos = data.movimientos.map(movimiento => new Movimiento(movimiento))
|
this.data.movimientos = data.movimientos.map(movimiento => new Movimiento(movimiento))
|
||||||
this.draw().movimientos()
|
this.draw().movimientos()
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<div class="header">
|
<div class="header">
|
||||||
{{$inmobiliaria->abreviacion}}
|
{{$inmobiliaria->abreviacion}}
|
||||||
</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>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,7 +6,12 @@
|
|||||||
|
|
||||||
@section('venta_content')
|
@section('venta_content')
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
El departamento {{$venta->propiedad()->departamentos()[0]->descripcion}}:<br />
|
@if (count($venta->propiedad()->departamentos()) > 0)
|
||||||
|
El departamento {{$venta->propiedad()->departamentos()[0]->descripcion}}:<br />
|
||||||
|
@else
|
||||||
|
La unidad {{ ucwords($venta->propiedad()->principal()?->proyectoTipoUnidad->tipoUnidad->descripcion) }}
|
||||||
|
{{ $venta->propiedad()->principal()?->descripcion }}:<br />
|
||||||
|
@endif
|
||||||
@php
|
@php
|
||||||
$estacionamientos = $venta->propiedad()->estacionamientos();
|
$estacionamientos = $venta->propiedad()->estacionamientos();
|
||||||
@endphp
|
@endphp
|
||||||
|
@ -47,9 +47,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui top attached tabular menu" id="tabs">
|
<div class="ui top attached tabular menu" id="tabs">
|
||||||
<div class="yellow active item" data-tab="pending">Pendientes</div>
|
<div class="yellow active item link" data-tab="pending">Pendientes</div>
|
||||||
<div class="green item" data-tab="active">Activas</div>
|
<div class="green item link" data-tab="active">Activas</div>
|
||||||
<div class="red item" data-tab="rejected">Rechazadas</div>
|
<div class="red item link" data-tab="rejected">Rechazadas</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui bottom attached tab fitted segment active" data-tab="pending">
|
<div class="ui bottom attached tab fitted segment active" data-tab="pending">
|
||||||
<table class="ui yellow striped table" id="pending_reservations">
|
<table class="ui yellow striped table" id="pending_reservations">
|
||||||
@ -102,12 +102,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@include('ventas.reservations.modal.add')
|
@include('ventas.reservations.modal.add')
|
||||||
|
@include('ventas.reservations.modal.comment')
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@push('page_styles')
|
@push('page_styles')
|
||||||
<style>
|
<style>
|
||||||
.item.link {
|
.item.link {
|
||||||
cursor: pointer;
|
cursor: pointer !important;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -293,10 +294,10 @@
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
columnsData() {
|
get columnsData() {
|
||||||
return this.reservations.map(reservation => {
|
return this.reservations.map(reservation => {
|
||||||
const date = new Date(Date.parse(reservation.date) + 24 * 60 * 60 * 1000)
|
const date = new Date(Date.parse(reservation.date) + 24 * 60 * 60 * 1000)
|
||||||
return {
|
return {
|
||||||
id: reservation.id,
|
id: reservation.id,
|
||||||
unidades: reservation.summary,
|
unidades: reservation.summary,
|
||||||
cliente: reservation.buyer.nombreCompleto,
|
cliente: reservation.buyer.nombreCompleto,
|
||||||
@ -314,7 +315,7 @@
|
|||||||
}
|
}
|
||||||
const tbody = this.component.querySelector('tbody')
|
const tbody = this.component.querySelector('tbody')
|
||||||
tbody.innerHTML = ''
|
tbody.innerHTML = ''
|
||||||
this.columnsData().forEach(column => {
|
this.columnsData.forEach(column => {
|
||||||
const tr = document.createElement('tr')
|
const tr = document.createElement('tr')
|
||||||
const contents = []
|
const contents = []
|
||||||
const id = column.id
|
const id = column.id
|
||||||
@ -376,6 +377,9 @@
|
|||||||
hide() {
|
hide() {
|
||||||
this.component.style.display = 'none'
|
this.component.style.display = 'none'
|
||||||
}
|
}
|
||||||
|
find(id) {
|
||||||
|
return this.reservations.find(reservation => reservation.id === parseInt(id))
|
||||||
|
}
|
||||||
send = {
|
send = {
|
||||||
get(url) {
|
get(url) {
|
||||||
return APIClient.fetch(url).then(response => response.json()).then(json => {
|
return APIClient.fetch(url).then(response => response.json()).then(json => {
|
||||||
@ -392,14 +396,6 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
delete(url) {
|
|
||||||
const method = 'delete'
|
|
||||||
return APIClient.fetch(url, {method}).then(response => response.json()).then(json => {
|
|
||||||
if (json.success) {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
actions = {}
|
actions = {}
|
||||||
}
|
}
|
||||||
@ -409,10 +405,10 @@
|
|||||||
super({component_id, formatters})
|
super({component_id, formatters})
|
||||||
}
|
}
|
||||||
|
|
||||||
columnsData() {
|
get columnsData() {
|
||||||
const data = super.columnsData();
|
const data = super.columnsData;
|
||||||
return data.map(row => {
|
return data.map(row => {
|
||||||
delete (row['valida'])
|
delete(row['valida'])
|
||||||
return row
|
return row
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -436,9 +432,12 @@
|
|||||||
},
|
},
|
||||||
remove: event => {
|
remove: event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const id = event.currentTarget.dataset.id
|
const reservation_id = event.currentTarget.dataset.id
|
||||||
const url = `{{ $urls->api }}/ventas/reservation/${id}/remove`
|
const url = `{{ $urls->api }}/ventas/reservation/${reservation_id}/remove`
|
||||||
this.send.delete(url)
|
const method = 'delete'
|
||||||
|
const action = 'Cancelar'
|
||||||
|
const reservation_data = this.find(reservation_id)
|
||||||
|
reservations.components.modals.comment.show({reservation_id, action, url, method, reservation_data})
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -459,9 +458,12 @@
|
|||||||
},
|
},
|
||||||
reject: event => {
|
reject: event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const id = event.currentTarget.dataset.id
|
const reservation_id = event.currentTarget.dataset.id
|
||||||
const url = `{{ $urls->api }}/ventas/reservation/${id}/reject`
|
const url = `{{ $urls->api }}/ventas/reservation/${reservation_id}/reject`
|
||||||
this.send.get(url)
|
const method = 'delete'
|
||||||
|
const action = 'Rechazar'
|
||||||
|
const reservation_data = this.find(reservation_id)
|
||||||
|
reservations.components.modals.comment.show({reservation_id, action, url, method, reservation_data})
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -472,11 +474,11 @@
|
|||||||
super({component_id, formatters})
|
super({component_id, formatters})
|
||||||
}
|
}
|
||||||
|
|
||||||
columnsData() {
|
get columnsData() {
|
||||||
const data = super.columnsData()
|
const data = super.columnsData
|
||||||
return this.reservations.map((reservation, idx) => {
|
return this.reservations.map((reservation, idx) => {
|
||||||
data[idx]['estado'] = reservation.state.charAt(0).toUpperCase() + reservation.state.slice(1)
|
data[idx]['estado'] = this.mapState(reservation.current_state)
|
||||||
data[idx]['comentarios'] = reservation.comments?.join('<br />\n') ?? ''
|
data[idx]['comentarios'] = reservation.comments ?? ''
|
||||||
return data[idx]
|
return data[idx]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -484,6 +486,13 @@
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
watch() {}
|
watch() {}
|
||||||
|
|
||||||
|
mapState(state) {
|
||||||
|
return {
|
||||||
|
'canceled': 'Cancelado',
|
||||||
|
'rejected': 'Rechazado'
|
||||||
|
}[state.toLowerCase()]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const reservations = {
|
const reservations = {
|
||||||
@ -498,7 +507,8 @@
|
|||||||
rejected: null
|
rejected: null
|
||||||
},
|
},
|
||||||
modals: {
|
modals: {
|
||||||
add: null
|
add: null,
|
||||||
|
comment: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
display: {
|
display: {
|
||||||
@ -638,6 +648,7 @@
|
|||||||
this.show.projects()
|
this.show.projects()
|
||||||
|
|
||||||
this.components.modals.add = new AddReservationModal(configuration.ids.projects)
|
this.components.modals.add = new AddReservationModal(configuration.ids.projects)
|
||||||
|
this.components.modals.comment = new CommentModal()
|
||||||
|
|
||||||
const project_id = {{ $project_id ?? 'null' }};
|
const project_id = {{ $project_id ?? 'null' }};
|
||||||
if (project_id !== null) {
|
if (project_id !== null) {
|
||||||
@ -645,6 +656,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
reservations.setup({
|
reservations.setup({
|
||||||
ids: {
|
ids: {
|
||||||
|
@ -238,6 +238,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
class AddModalUnits {
|
class AddModalUnits {
|
||||||
|
parent = null
|
||||||
ids = {
|
ids = {
|
||||||
buttons_holder: '',
|
buttons_holder: '',
|
||||||
units: ''
|
units: ''
|
||||||
@ -252,7 +253,8 @@
|
|||||||
units: null,
|
units: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor(parent) {
|
||||||
|
this.parent = parent
|
||||||
this.ids = {
|
this.ids = {
|
||||||
buttons_holder: 'add_unit_buttons',
|
buttons_holder: 'add_unit_buttons',
|
||||||
units: 'add_units'
|
units: 'add_units'
|
||||||
@ -265,6 +267,9 @@
|
|||||||
}
|
}
|
||||||
this.setup()
|
this.setup()
|
||||||
}
|
}
|
||||||
|
get promotions() {
|
||||||
|
return this.parent.data.promotions[this.parent.data.current_project]
|
||||||
|
}
|
||||||
draw = {
|
draw = {
|
||||||
button: type => {
|
button: type => {
|
||||||
return [
|
return [
|
||||||
@ -293,36 +298,25 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.components.units.innerHTML = this.data.units.map(unit => {
|
this.components.units.innerHTML = this.data.units.map(unit => {
|
||||||
return [
|
return this.draw.unit(unit)
|
||||||
'<div class="fields">',
|
|
||||||
'<div class="four wide field">',
|
|
||||||
`<label>${unit.type.charAt(0).toUpperCase() + unit.type.slice(1)}</label>`,
|
|
||||||
`<div class="ui search selection dropdown">`,
|
|
||||||
'<input type="hidden" name="add_units[]" />',
|
|
||||||
'<i class="dropdown icon"></i>',
|
|
||||||
`<div class="default text">${unit.type.charAt(0).toUpperCase() + unit.type.slice(1)}</div>`,
|
|
||||||
'<div class="menu">',
|
|
||||||
this.data.types[unit.type].map(unit => {
|
|
||||||
return `<div class="item" data-value="${unit.value}">${unit.name}</div>`
|
|
||||||
}).join(''),
|
|
||||||
'</div>',
|
|
||||||
'</div>',
|
|
||||||
'</div>',
|
|
||||||
'<div class="three wide field">',
|
|
||||||
'<label>Valor</label>',
|
|
||||||
'<div class="ui right labeled input">',
|
|
||||||
'<input type="number" name="add_units_value[]" placeholder="Valor" />',
|
|
||||||
'<div class="ui basic label">UF</div>',
|
|
||||||
'</div>',
|
|
||||||
'</div>',
|
|
||||||
'<div class="field">',
|
|
||||||
'<label></label>',
|
|
||||||
`<button class="ui red tiny icon button remove_unit" type="button" data-id="${unit.idx}"><i class="trash icon"></i></button>`,
|
|
||||||
'</div>',
|
|
||||||
'</div>',
|
|
||||||
].join('')
|
|
||||||
}).join('')
|
}).join('')
|
||||||
this.components.units.querySelectorAll('.dropdown').forEach(dropdown => {
|
this.components.units.querySelectorAll('.dropdown.add_units').forEach(dropdown => {
|
||||||
|
$(dropdown).dropdown({
|
||||||
|
onChange: (value, text, $selectedItem) => {
|
||||||
|
const unitPromotions = this.promotions.filter(promotion => promotion.units.length > 0)
|
||||||
|
const promotions = unitPromotions.filter(promotion => promotion.units.filter(unit => unit.id === parseInt(value)).length > 0)
|
||||||
|
$selectedItem.parent().parent().parent().parent().find('.add_promotions_unit')
|
||||||
|
.dropdown('change values', promotions.map(promotion => {
|
||||||
|
return {
|
||||||
|
value: promotion.id,
|
||||||
|
name: promotion.description,
|
||||||
|
text: promotion.description,
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
this.components.units.querySelectorAll('.dropdown.add_promotions_unit').forEach(dropdown => {
|
||||||
$(dropdown).dropdown()
|
$(dropdown).dropdown()
|
||||||
})
|
})
|
||||||
this.components.units.querySelectorAll('.remove_unit').forEach(button => {
|
this.components.units.querySelectorAll('.remove_unit').forEach(button => {
|
||||||
@ -331,6 +325,54 @@
|
|||||||
this.remove(idx)
|
this.remove(idx)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
unit: unit => {
|
||||||
|
let promotions = ''
|
||||||
|
if (unit.type === 'departamento') {
|
||||||
|
if (this.promotions.filter(promotion => promotion.units.length > 0).length > 0) {
|
||||||
|
promotions = [
|
||||||
|
'<div class="three wide field">',
|
||||||
|
'<label>Promociones</label>',
|
||||||
|
'<div class="ui multiple search selection dropdown add_promotions_unit">',
|
||||||
|
'<input type="hidden" name="add_units_promotions[]" />',
|
||||||
|
'<i class="dropdown icon"></i>',
|
||||||
|
'<div class="default text">Promociones</div>',
|
||||||
|
'<div class="menu">',
|
||||||
|
'</div>',
|
||||||
|
'</div>',
|
||||||
|
'</div>'
|
||||||
|
].join('')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
'<div class="fields">',
|
||||||
|
'<div class="four wide field">',
|
||||||
|
`<label>${unit.type.charAt(0).toUpperCase() + unit.type.slice(1)}</label>`,
|
||||||
|
`<div class="ui search selection dropdown add_units">`,
|
||||||
|
'<input type="hidden" name="add_units[]" />',
|
||||||
|
'<i class="dropdown icon"></i>',
|
||||||
|
`<div class="default text">${unit.type.charAt(0).toUpperCase() + unit.type.slice(1)}</div>`,
|
||||||
|
'<div class="menu">',
|
||||||
|
this.data.types[unit.type].map(unit => {
|
||||||
|
return `<div class="item" data-value="${unit.value}">${unit.name}</div>`
|
||||||
|
}).join(''),
|
||||||
|
'</div>',
|
||||||
|
'</div>',
|
||||||
|
'</div>',
|
||||||
|
'<div class="three wide field">',
|
||||||
|
'<label>Valor</label>',
|
||||||
|
'<div class="ui right labeled input">',
|
||||||
|
'<input type="number" name="add_units_value[]" placeholder="Valor" />',
|
||||||
|
'<div class="ui basic label">UF</div>',
|
||||||
|
'</div>',
|
||||||
|
'</div>',
|
||||||
|
promotions,
|
||||||
|
'<div class="field">',
|
||||||
|
'<label></label>',
|
||||||
|
`<button class="ui red tiny icon button remove_unit" type="button" data-id="${unit.idx}"><i class="trash icon"></i></button>`,
|
||||||
|
'</div>',
|
||||||
|
'</div>',
|
||||||
|
].join('')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reset() {
|
reset() {
|
||||||
@ -436,11 +478,30 @@
|
|||||||
|
|
||||||
this.get.brokers(project_id)
|
this.get.brokers(project_id)
|
||||||
this.get.promotions(project_id).then(promotions => {
|
this.get.promotions(project_id).then(promotions => {
|
||||||
this.components.promotions.data.promotions = promotions
|
this.components.promotions.data.promotions = promotions.map(promotion => {
|
||||||
|
return {
|
||||||
|
text: promotion.name,
|
||||||
|
name: promotion.name,
|
||||||
|
value: promotion.id
|
||||||
|
}
|
||||||
|
})
|
||||||
this.components.promotions.draw.promotions()
|
this.components.promotions.draw.promotions()
|
||||||
})
|
})
|
||||||
this.get.units(project_id).then(units => {
|
this.get.units(project_id).then(unitTypes => {
|
||||||
this.components.units.data.types = units
|
Object.entries(unitTypes).map(([type, units]) => {
|
||||||
|
units = units.map(unit => {
|
||||||
|
return {
|
||||||
|
text: unit.descripcion,
|
||||||
|
name: unit.descripcion,
|
||||||
|
value: unit.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
units.sort((a, b) => {
|
||||||
|
return parseInt(a.text) - parseInt(b.text)
|
||||||
|
})
|
||||||
|
unitTypes[type] = units
|
||||||
|
})
|
||||||
|
this.components.units.data.types = unitTypes
|
||||||
this.components.units.draw.buttons()
|
this.components.units.draw.buttons()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -564,13 +625,7 @@
|
|||||||
if (json.promotions.length === 0) {
|
if (json.promotions.length === 0) {
|
||||||
return this.data.promotions[project_id] = []
|
return this.data.promotions[project_id] = []
|
||||||
}
|
}
|
||||||
return this.data.promotions[project_id] = json.promotions.map(promotion => {
|
return this.data.promotions[project_id] = json.promotions
|
||||||
return {
|
|
||||||
text: promotion.name,
|
|
||||||
name: promotion.name,
|
|
||||||
value: promotion.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
units: project_id => {
|
units: project_id => {
|
||||||
@ -593,18 +648,9 @@
|
|||||||
if (!(type in this.data.units[project_id])) {
|
if (!(type in this.data.units[project_id])) {
|
||||||
this.data.units[project_id][type] = []
|
this.data.units[project_id][type] = []
|
||||||
}
|
}
|
||||||
this.data.units[project_id][type].push({
|
this.data.units[project_id][type].push(unit)
|
||||||
text: unit.descripcion,
|
|
||||||
name: unit.descripcion,
|
|
||||||
value: unit.id
|
|
||||||
})
|
|
||||||
})
|
|
||||||
Object.entries(this.data.units[project_id]).forEach(([type, units]) => {
|
|
||||||
units.sort((a, b) => {
|
|
||||||
return parseInt(a.text) - parseInt(b.text)
|
|
||||||
})
|
|
||||||
this.data.units[project_id][type] = units
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return this.data.units[project_id]
|
return this.data.units[project_id]
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -706,7 +752,7 @@
|
|||||||
this.components.promotions = new AddModalPromotions()
|
this.components.promotions = new AddModalPromotions()
|
||||||
this.components.projects = document.getElementById(this.ids.projects)
|
this.components.projects = document.getElementById(this.ids.projects)
|
||||||
this.components.project_name = document.getElementById(this.ids.project_name)
|
this.components.project_name = document.getElementById(this.ids.project_name)
|
||||||
this.components.units = new AddModalUnits()
|
this.components.units = new AddModalUnits(this)
|
||||||
|
|
||||||
this.components.$modal.modal({
|
this.components.$modal.modal({
|
||||||
onApprove: () => {
|
onApprove: () => {
|
||||||
|
157
app/resources/views/ventas/reservations/modal/comment.blade.php
Normal file
157
app/resources/views/ventas/reservations/modal/comment.blade.php
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
<div class="ui modal" id="comment_modal">
|
||||||
|
<div class="header">
|
||||||
|
Comentar Cierre y <span id="comment_action"></span>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<form class="ui form" id="comment_form">
|
||||||
|
<input type="hidden" name="reservation_id" id="comment_reservation_id" />
|
||||||
|
<input type="hidden" name="user_id" id="comment_user_id" />
|
||||||
|
<table class="ui collapsing table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Unidades</td>
|
||||||
|
<td id="comment_units"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Cliente</td>
|
||||||
|
<td id="comment_client"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Fecha</td>
|
||||||
|
<td id="comment_date"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="field">
|
||||||
|
<label>Comentario</label>
|
||||||
|
<textarea name="comment"></textarea>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<div class="ui cancel button">
|
||||||
|
Cancelar
|
||||||
|
</div>
|
||||||
|
<div class="ui green ok button">
|
||||||
|
Comentar y Guardar
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('page_scripts')
|
||||||
|
<script>
|
||||||
|
class CommentModal {
|
||||||
|
ids = {
|
||||||
|
modal: 'comment_modal',
|
||||||
|
action: 'comment_action',
|
||||||
|
form: 'comment_form',
|
||||||
|
reservation_id: 'comment_reservation_id',
|
||||||
|
user_id: 'comment_user_id',
|
||||||
|
units: 'comment_units',
|
||||||
|
client: 'comment_client',
|
||||||
|
date: 'comment_date',
|
||||||
|
}
|
||||||
|
components = {
|
||||||
|
$modal: null,
|
||||||
|
action: null,
|
||||||
|
form: null,
|
||||||
|
reservation: null,
|
||||||
|
user: null,
|
||||||
|
units: null,
|
||||||
|
client: null,
|
||||||
|
date: null,
|
||||||
|
comment: null,
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
reservation_id: null,
|
||||||
|
url: '',
|
||||||
|
action: '',
|
||||||
|
method: 'delete',
|
||||||
|
reservation_data: {
|
||||||
|
units: '',
|
||||||
|
client: '',
|
||||||
|
date: '',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
constructor() {
|
||||||
|
this.ids = {
|
||||||
|
modal: 'comment_modal',
|
||||||
|
action: 'comment_action',
|
||||||
|
form: 'comment_form',
|
||||||
|
reservation_id: 'comment_reservation_id',
|
||||||
|
user_id: 'comment_user_id',
|
||||||
|
units: 'comment_units',
|
||||||
|
client: 'comment_client',
|
||||||
|
date: 'comment_date',
|
||||||
|
}
|
||||||
|
this.setup()
|
||||||
|
}
|
||||||
|
|
||||||
|
show({reservation_id, reservation_data, url, action, method}) {
|
||||||
|
this.data.reservation_id = reservation_id
|
||||||
|
this.data.url = url
|
||||||
|
this.data.action = action
|
||||||
|
this.data.method = method
|
||||||
|
|
||||||
|
this.components.action.innerHTML = action
|
||||||
|
|
||||||
|
const date = new Date(Date.parse(reservation_data.date) + 24 * 60 * 60 * 1000)
|
||||||
|
const formatter = new Intl.DateTimeFormat('es-CL', {dateStyle: 'medium'})
|
||||||
|
|
||||||
|
this.data.reservation_data = {
|
||||||
|
units: reservation_data.summary,
|
||||||
|
client: reservation_data.buyer.nombreCompleto,
|
||||||
|
date: formatter.format(date),
|
||||||
|
}
|
||||||
|
|
||||||
|
this.components.reservation.value = this.data.reservation_id
|
||||||
|
this.components.units.innerHTML = this.data.reservation_data.units
|
||||||
|
this.components.client.innerHTML = this.data.reservation_data.client
|
||||||
|
this.components.date.innerHTML = this.data.reservation_data.date
|
||||||
|
this.components.$modal.modal('show')
|
||||||
|
}
|
||||||
|
hide() {
|
||||||
|
this.components.$modal.modal('hide')
|
||||||
|
}
|
||||||
|
|
||||||
|
submit() {
|
||||||
|
const url = this.data.url
|
||||||
|
const method = this.data.method
|
||||||
|
const body = new FormData(this.components.form)
|
||||||
|
|
||||||
|
return APIClient.fetch(url, {method, body}).then(response => response.json()).then(json => {
|
||||||
|
if (json.success) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
this.components = {
|
||||||
|
$modal: $(`#${this.ids.modal}`),
|
||||||
|
action: document.getElementById(this.ids.action),
|
||||||
|
form: document.getElementById(this.ids.form),
|
||||||
|
reservation: document.getElementById(this.ids.reservation_id),
|
||||||
|
user: document.getElementById(this.ids.user_id),
|
||||||
|
units: document.getElementById(this.ids.units),
|
||||||
|
client: document.getElementById(this.ids.client),
|
||||||
|
date: document.getElementById(this.ids.date),
|
||||||
|
comment: null,
|
||||||
|
}
|
||||||
|
this.components.comment = this.components.form.querySelector('textarea[name="comment"]')
|
||||||
|
this.components.user.value = '{{ $user->id }}'
|
||||||
|
|
||||||
|
this.components.$modal.modal({
|
||||||
|
onApprove: $element => {
|
||||||
|
this.submit()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.components.form.addEventListener('submit', event => {
|
||||||
|
event.preventDefault()
|
||||||
|
this.submit()
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endpush
|
@ -25,6 +25,7 @@ return [
|
|||||||
$container->get(Monolog\Processor\MemoryPeakUsageProcessor::class),
|
$container->get(Monolog\Processor\MemoryPeakUsageProcessor::class),
|
||||||
$container->get(Monolog\Processor\PsrLogMessageProcessor::class),
|
$container->get(Monolog\Processor\PsrLogMessageProcessor::class),
|
||||||
$container->get(Monolog\Processor\UidProcessor::class),
|
$container->get(Monolog\Processor\UidProcessor::class),
|
||||||
|
$container->get(Incoviba\Common\Implement\Log\Processor\Exception::class),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
'baseDefaultHandlers' => function(ContainerInterface $container) {
|
'baseDefaultHandlers' => function(ContainerInterface $container) {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
namespace Incoviba\Controller\API\Contabilidad;
|
namespace Incoviba\Controller\API\Contabilidad;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
|
use Incoviba\Exception\ServiceAction\Read;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Incoviba\Common\Ideal\Controller;
|
use Incoviba\Common\Ideal\Controller;
|
||||||
@ -117,24 +118,21 @@ class Cartolas extends Controller
|
|||||||
UPLOAD_ERR_CANT_WRITE => 'No se pudo escribir el archivo',
|
UPLOAD_ERR_CANT_WRITE => 'No se pudo escribir el archivo',
|
||||||
UPLOAD_ERR_EXTENSION => 'Una extensión de PHP detuvo la subida del archivo'
|
UPLOAD_ERR_EXTENSION => 'Una extensión de PHP detuvo la subida del archivo'
|
||||||
];
|
];
|
||||||
if (is_array($files['file'])) {
|
if (!is_array($files['file'])) {
|
||||||
foreach ($files['file'] as $i => $file) {
|
$files['file'] = [$files['file']];
|
||||||
if ($file->getError() !== UPLOAD_ERR_OK) {
|
$body['cuenta_id'] = [$body['cuenta_id']];
|
||||||
$output['errors'] []= ['filename' => $file->getClientFilename(), 'error' => $errors[$file->getError()]];
|
}
|
||||||
continue;
|
foreach ($files['file'] as $i => $file) {
|
||||||
}
|
|
||||||
try {
|
|
||||||
$output['movimientos'] = array_merge($output['movimientos'], $cartolaService->import($body['cuenta_id'][$i], $file));
|
|
||||||
} catch (EmptyResult) {}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$file = $files['file'];
|
|
||||||
if ($file->getError() !== UPLOAD_ERR_OK) {
|
if ($file->getError() !== UPLOAD_ERR_OK) {
|
||||||
$output['errors'][] = ['filename' => $file->getClientFilename(), 'error' => $errors[$file->getError()]];
|
$output['errors'] []= ['filename' => $file->getClientFilename(), 'error' => $errors[$file->getError()]];
|
||||||
} else {
|
continue;
|
||||||
try {
|
}
|
||||||
$output['movimientos'] = $cartolaService->import($body['cuenta_id'], $file);
|
try {
|
||||||
} catch (EmptyResult) {}
|
$output['movimientos'] = array_merge($output['movimientos'], $cartolaService->import($body['cuenta_id'][$i], $file));
|
||||||
|
} catch (Read $exception) {
|
||||||
|
$output['errors'] []= ['filename' => $file->getClientFilename(),
|
||||||
|
'error' => ['message' => $exception->getMessage(), 'file' => $exception->getFile(),
|
||||||
|
'line' => $exception->getLine()]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
|
@ -53,7 +53,7 @@ class Money
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$this->data[$provider] = (array) $this->fetchRedis($redisService, $redisKey);
|
$this->data[$provider] = (array) $this->fetchRedis($redisService, $redisKey);
|
||||||
if (!isset($this->data[$provider][$date->format('Y-m-d')])) {
|
if (!isset($this->data[$provider][$date->format('Y-m-d')]) or $this->data[$provider][$date->format('Y-m-d')] === 0) {
|
||||||
throw new EmptyRedis($redisKey);
|
throw new EmptyRedis($redisKey);
|
||||||
}
|
}
|
||||||
} catch (EmptyRedis) {
|
} catch (EmptyRedis) {
|
||||||
|
@ -71,9 +71,9 @@ class Reservations
|
|||||||
$output['errors'] []= $this->parseError($exception);
|
$output['errors'] []= $this->parseError($exception);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (count($input['reservations']) === count($output['reservations'])) {
|
/*if (count($input['reservations']) === count($output['reservations'])) {
|
||||||
$output['success'] = true;
|
$output['success'] = true;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,8 @@ class Reservation extends Common\Ideal\Model
|
|||||||
return $base >= $price;
|
return $base >= $price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string $comments;
|
||||||
|
|
||||||
protected function jsonComplement(): array
|
protected function jsonComplement(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -131,7 +133,10 @@ class Reservation extends Common\Ideal\Model
|
|||||||
'base' => $this->base(),
|
'base' => $this->base(),
|
||||||
'price' => $this->price(),
|
'price' => $this->price(),
|
||||||
'valid' => $this->valid(),
|
'valid' => $this->valid(),
|
||||||
'summary' => $this->summary()
|
'summary' => $this->summary(),
|
||||||
|
'states' => $this->states() ?? [],
|
||||||
|
'current_state' => $this->currentState()?->type?->name ?? null,
|
||||||
|
'comments' => $this->comments ?? '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,10 @@ class State extends Common\Ideal\Model
|
|||||||
return [
|
return [
|
||||||
'reservation_id' => $this->reservation->id,
|
'reservation_id' => $this->reservation->id,
|
||||||
'date' => $this->date->format('Y-m-d'),
|
'date' => $this->date->format('Y-m-d'),
|
||||||
'type' => $this->type
|
'type' => [
|
||||||
|
'id' => $this->type->value,
|
||||||
|
'name' => $this->type->name,
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@ enum Type: int
|
|||||||
}
|
}
|
||||||
public static function getTypes(): array
|
public static function getTypes(): array
|
||||||
{
|
{
|
||||||
return [self::ACTIVE->value, self::INACTIVE->value, self::REJECTED->value];
|
return [self::ACTIVE->value, self::INACTIVE->value, self::REJECTED->value, self::CANCELLED->value];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ class Promotion extends Common\Ideal\Repository
|
|||||||
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu ON ptu.id = pul.unit_line_id')
|
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu ON ptu.id = pul.unit_line_id')
|
||||||
->joined('LEFT OUTER JOIN promotion_units pu ON pu.promotion_id = a.id')
|
->joined('LEFT OUTER JOIN promotion_units pu ON pu.promotion_id = a.id')
|
||||||
->joined('LEFT OUTER JOIN unidad ON unidad.id = pu.unit_id')
|
->joined('LEFT OUTER JOIN unidad ON unidad.id = pu.unit_id')
|
||||||
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu1 ON ptu.id = unidad.pt')
|
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu1 ON ptu1.id = unidad.pt')
|
||||||
->where('pp.project_id = :project_id OR put.project_id = :project_id OR ptu.proyecto = :project_id OR ptu1.proyecto = :project_id')
|
->where('pp.project_id = :project_id OR put.project_id = :project_id OR ptu.proyecto = :project_id OR ptu1.proyecto = :project_id')
|
||||||
->group('a.id');
|
->group('a.id');
|
||||||
return $this->fetchMany($query, ['project_id' => $project_id]);
|
return $this->fetchMany($query, ['project_id' => $project_id]);
|
||||||
|
@ -4,6 +4,7 @@ namespace Incoviba\Repository\Venta;
|
|||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
use Incoviba\Common\Define;
|
use Incoviba\Common\Define;
|
||||||
|
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||||
use Incoviba\Exception\Model\InvalidState;
|
use Incoviba\Exception\Model\InvalidState;
|
||||||
use PDO;
|
use PDO;
|
||||||
use Incoviba\Common;
|
use Incoviba\Common;
|
||||||
@ -29,7 +30,7 @@ class Reservation extends Common\Ideal\Repository
|
|||||||
|
|
||||||
public function create(?array $data = null): Model\Venta\Reservation
|
public function create(?array $data = null): Model\Venta\Reservation
|
||||||
{
|
{
|
||||||
$map = (new Common\Implement\Repository\MapperParser())
|
$map = (new Common\Implement\Repository\MapperParser(['comments']))
|
||||||
->register('project_id', (new Common\Implement\Repository\Mapper())
|
->register('project_id', (new Common\Implement\Repository\Mapper())
|
||||||
->setProperty('project')
|
->setProperty('project')
|
||||||
->setFunction(function($data) {
|
->setFunction(function($data) {
|
||||||
@ -91,18 +92,57 @@ class Reservation extends Common\Ideal\Repository
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $buyer_rut
|
* @param int $buyer_rut
|
||||||
|
* @param int $unit_id
|
||||||
* @param DateTimeInterface $date
|
* @param DateTimeInterface $date
|
||||||
* @return Model\Venta\Reservation
|
* @return Model\Venta\Reservation
|
||||||
* @throws Common\Implement\Exception\EmptyResult
|
* @throws EmptyResult
|
||||||
*/
|
*/
|
||||||
public function fetchByBuyerAndDate(int $buyer_rut, DateTimeInterface $date): Model\Venta\Reservation
|
public function fetchByBuyerAndUnitAndDate(int $buyer_rut, int $unit_id, DateTimeInterface $date): Model\Venta\Reservation
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select('a.*')
|
||||||
|
->from('reservations a')
|
||||||
|
->joined('INNER JOIN reservation_details rd ON a.id = rd.reservation_id')
|
||||||
|
->where('a.buyer_rut = :buyer_rut AND rd.unit_id = :unit_id AND a.date >= :date');
|
||||||
|
return $this->fetchOne($query, ['buyer_rut' => $buyer_rut, 'unit_id' => $unit_id, 'date' => $date->sub(new DateInterval('P10D'))->format('Y-m-d')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $buyer_rut
|
||||||
|
* @param int $project_id
|
||||||
|
* @param DateTimeInterface $date
|
||||||
|
* @return array
|
||||||
|
* @throws EmptyResult
|
||||||
|
*/
|
||||||
|
public function fetchByBuyerAndProjectAndDate(int $buyer_rut, int $project_id, DateTimeInterface $date): array
|
||||||
|
{
|
||||||
|
$query = $this->connection->getQueryBuilder()
|
||||||
|
->select()
|
||||||
|
->from('reservations')
|
||||||
|
->where('buyer_rut = :buyer_rut AND project_id = :project_id AND date >= :date');
|
||||||
|
return $this->fetchMany($query, ['buyer_rut' => $buyer_rut, 'project_id' => $project_id, 'date' => $date->sub(new DateInterval('P10D'))->format('Y-m-d')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $buyer_rut
|
||||||
|
* @param DateTimeInterface $date
|
||||||
|
* @return array
|
||||||
|
* @throws EmptyResult
|
||||||
|
*/
|
||||||
|
public function fetchByBuyerAndDate(int $buyer_rut, DateTimeInterface $date): array
|
||||||
{
|
{
|
||||||
$query = $this->connection->getQueryBuilder()
|
$query = $this->connection->getQueryBuilder()
|
||||||
->select()
|
->select()
|
||||||
->from('reservations')
|
->from('reservations')
|
||||||
->where('buyer_rut = :buyer_rut AND date >= :date');
|
->where('buyer_rut = :buyer_rut AND date >= :date');
|
||||||
return $this->fetchOne($query, ['buyer_rut' => $buyer_rut, 'date' => $date->sub(new DateInterval('P10D'))->format('Y-m-d')]);
|
return $this->fetchMany($query, ['buyer_rut' => $buyer_rut, 'date' => $date->sub(new DateInterval('P10D'))->format('Y-m-d')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $project_id
|
||||||
|
* @return array
|
||||||
|
* @throws EmptyResult
|
||||||
|
*/
|
||||||
public function fetchByProject(int $project_id): array
|
public function fetchByProject(int $project_id): array
|
||||||
{
|
{
|
||||||
$query = $this->connection->getQueryBuilder()
|
$query = $this->connection->getQueryBuilder()
|
||||||
@ -114,13 +154,16 @@ class Reservation extends Common\Ideal\Repository
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $project_id
|
* @param int $project_id
|
||||||
* @param int $state
|
* @param int|string $state
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Common\Implement\Exception\EmptyResult
|
* @throws EmptyResult
|
||||||
* @throws InvalidState
|
* @throws InvalidState
|
||||||
*/
|
*/
|
||||||
public function fetchState(int $project_id, int $state): array
|
public function fetchState(int $project_id, int|string $state): array
|
||||||
{
|
{
|
||||||
|
if (is_string($state)) {
|
||||||
|
$state = Model\Venta\Reservation\State\Type::from($state)->value;
|
||||||
|
}
|
||||||
if (!in_array($state, Model\Venta\Reservation\State\Type::getTypes())) {
|
if (!in_array($state, Model\Venta\Reservation\State\Type::getTypes())) {
|
||||||
throw new InvalidState();
|
throw new InvalidState();
|
||||||
}
|
}
|
||||||
@ -141,6 +184,7 @@ class Reservation extends Common\Ideal\Repository
|
|||||||
return $this->fetchMany($query, ['project_id' => $project_id,
|
return $this->fetchMany($query, ['project_id' => $project_id,
|
||||||
'state' => $state]);
|
'state' => $state]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $project_id
|
* @param int $project_id
|
||||||
* @return array
|
* @return array
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Incoviba\Service\Contabilidad;
|
namespace Incoviba\Service\Contabilidad;
|
||||||
|
|
||||||
|
use DateMalformedStringException;
|
||||||
use PDOException;
|
use PDOException;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
use Psr\Http\Message\StreamFactoryInterface;
|
||||||
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use PhpOffice\PhpSpreadsheet;
|
||||||
use Incoviba\Common\Define\Cartola\Banco;
|
use Incoviba\Common\Define\Cartola\Banco;
|
||||||
use Incoviba\Common\Define\Contabilidad\Exporter;
|
use Incoviba\Common\Define\Contabilidad\Exporter;
|
||||||
use Incoviba\Common\Ideal\Service;
|
use Incoviba\Common\Ideal\Service;
|
||||||
use Incoviba\Common\Implement\Exception;
|
use Incoviba\Common\Implement\Exception;
|
||||||
|
use Incoviba\Exception\ServiceAction\Read;
|
||||||
use Incoviba\Model;
|
use Incoviba\Model;
|
||||||
use Incoviba\Repository;
|
use Incoviba\Repository;
|
||||||
use Psr\Http\Message\StreamFactoryInterface;
|
|
||||||
use Psr\Http\Message\UploadedFileInterface;
|
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
|
|
||||||
class Cartola extends Service
|
class Cartola extends Service
|
||||||
{
|
{
|
||||||
@ -32,6 +35,13 @@ class Cartola extends Service
|
|||||||
$this->bancos[$name] = $banco;
|
$this->bancos[$name] = $banco;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Model\Contabilidad\Banco $banco
|
||||||
|
* @param UploadedFileInterface $file
|
||||||
|
* @return array
|
||||||
|
* @throws Read
|
||||||
|
*/
|
||||||
public function process(Model\Contabilidad\Banco $banco, UploadedFileInterface $file): array
|
public function process(Model\Contabilidad\Banco $banco, UploadedFileInterface $file): array
|
||||||
{
|
{
|
||||||
return $this->bancos[strtolower($banco->nombre)]->process($file);
|
return $this->bancos[strtolower($banco->nombre)]->process($file);
|
||||||
@ -93,9 +103,19 @@ class Cartola extends Service
|
|||||||
return compact('cartola', 'movimientos');
|
return compact('cartola', 'movimientos');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $cuenta_id
|
||||||
|
* @param UploadedFileInterface $file
|
||||||
|
* @return array
|
||||||
|
* @throws Read
|
||||||
|
*/
|
||||||
public function import(int $cuenta_id, UploadedFileInterface $file): array
|
public function import(int $cuenta_id, UploadedFileInterface $file): array
|
||||||
{
|
{
|
||||||
$cuenta = $this->cuentaRepository->fetchById($cuenta_id);
|
try {
|
||||||
|
$cuenta = $this->cuentaRepository->fetchById($cuenta_id);
|
||||||
|
} catch (Exception\EmptyResult $exception) {
|
||||||
|
throw new Read(__CLASS__, $exception);
|
||||||
|
}
|
||||||
$movimientos = $this->process($cuenta->banco, $file);
|
$movimientos = $this->process($cuenta->banco, $file);
|
||||||
|
|
||||||
$inmobiliaria = $cuenta->inmobiliaria;
|
$inmobiliaria = $cuenta->inmobiliaria;
|
||||||
@ -106,15 +126,23 @@ class Cartola extends Service
|
|||||||
if (array_key_exists('centro_costo', $dataMovimiento) and $dataMovimiento['centro_costo'] !== 0) {
|
if (array_key_exists('centro_costo', $dataMovimiento) and $dataMovimiento['centro_costo'] !== 0) {
|
||||||
$dataMovimiento['centro_costo_id'] = $dataMovimiento['centro_costo'];
|
$dataMovimiento['centro_costo_id'] = $dataMovimiento['centro_costo'];
|
||||||
}
|
}
|
||||||
$dataMovimiento['fecha'] = new DateTimeImmutable($dataMovimiento['fecha']);
|
try {
|
||||||
|
$dataMovimiento['fecha'] = new DateTimeImmutable($dataMovimiento['fecha']);
|
||||||
|
} catch (DateMalformedStringException) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (array_key_exists('rut', $dataMovimiento)) {
|
if (array_key_exists('rut', $dataMovimiento)) {
|
||||||
$ruts = $this->parseRut($dataMovimiento['rut']);
|
if ($dataMovimiento['rut'] === '') {
|
||||||
if (key_exists('rut', $ruts)) {
|
unset($dataMovimiento['rut']);
|
||||||
$dataMovimiento['rut'] = $ruts['rut'];
|
|
||||||
$dataMovimiento['digito'] = $ruts['digito'];
|
|
||||||
} else {
|
} else {
|
||||||
$dataMovimiento['rut'] = $ruts[0]['rut'];
|
$ruts = $this->parseRut($dataMovimiento['rut']);
|
||||||
$dataMovimiento['digito'] = $ruts[0]['digito'];
|
if (key_exists('rut', $ruts)) {
|
||||||
|
$dataMovimiento['rut'] = $ruts['rut'];
|
||||||
|
$dataMovimiento['digito'] = $ruts['digito'];
|
||||||
|
} else {
|
||||||
|
$dataMovimiento['rut'] = $ruts[0]['rut'];
|
||||||
|
$dataMovimiento['digito'] = $ruts[0]['digito'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -133,14 +161,28 @@ class Cartola extends Service
|
|||||||
$fechas = array_unique(array_map(function($movimiento) {
|
$fechas = array_unique(array_map(function($movimiento) {
|
||||||
return $movimiento['fecha']->format('Y-m-d');
|
return $movimiento['fecha']->format('Y-m-d');
|
||||||
}, $movimientos));
|
}, $movimientos));
|
||||||
|
if (count($fechas) === 0) {
|
||||||
|
throw new Read(__CLASS__);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($fechas as $dia) {
|
foreach ($fechas as $dia) {
|
||||||
try {
|
try {
|
||||||
$this->cartolaRepository->fetchByCuentaAndFecha($cuenta->id, new DateTimeImmutable($dia));
|
$dayDate = new DateTimeImmutable($dia);
|
||||||
|
} catch (DateMalformedStringException) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$this->cartolaRepository->fetchByCuentaAndFecha($cuenta->id, $dayDate);
|
||||||
continue;
|
continue;
|
||||||
} catch (Exception\EmptyResult) {}
|
} catch (Exception\EmptyResult) {}
|
||||||
|
|
||||||
$movs = array_filter($movimientos, function($movimiento) use ($dia) {
|
$movs = array_filter($movimientos, function($movimiento) use ($dia) {
|
||||||
return $movimiento['fecha'] === $dia;
|
return $movimiento['fecha']->format('Y-m-d') === $dia;
|
||||||
});
|
});
|
||||||
|
if (count($movs) === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$cargos = array_sum(array_map(function($movimiento) {
|
$cargos = array_sum(array_map(function($movimiento) {
|
||||||
return $movimiento['cargo'];
|
return $movimiento['cargo'];
|
||||||
}, $movs));
|
}, $movs));
|
||||||
@ -153,11 +195,19 @@ class Cartola extends Service
|
|||||||
'abonos' => $abonos,
|
'abonos' => $abonos,
|
||||||
'saldo' => $saldo
|
'saldo' => $saldo
|
||||||
];
|
];
|
||||||
$this->buildCartola($cuenta, new DateTimeImmutable($dia), $cartolaData);
|
$this->buildCartola($cuenta, $dayDate, $cartolaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
$startDate = new DateTimeImmutable(min($fechas));
|
try {
|
||||||
$endDate = new DateTimeImmutable(max($fechas));
|
$startDate = new DateTimeImmutable(min($fechas));
|
||||||
|
} catch (DateMalformedStringException $exception) {
|
||||||
|
throw new Read(__CLASS__, $exception);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$endDate = new DateTimeImmutable(max($fechas));
|
||||||
|
} catch (DateMalformedStringException $exception) {
|
||||||
|
throw new Read(__CLASS__, $exception);
|
||||||
|
}
|
||||||
$movimientosFaltantes = $this->movimientoService->findMissing($cuenta, $addedMovimientos, $startDate, $endDate);
|
$movimientosFaltantes = $this->movimientoService->findMissing($cuenta, $addedMovimientos, $startDate, $endDate);
|
||||||
$movimientosObsoletos = [];
|
$movimientosObsoletos = [];
|
||||||
if (count($movimientosFaltantes) > 0) {
|
if (count($movimientosFaltantes) > 0) {
|
||||||
|
@ -3,6 +3,7 @@ namespace Incoviba\Service\Contabilidad\Cartola;
|
|||||||
|
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use Incoviba\Common\Ideal\Cartola\Banco;
|
use Incoviba\Common\Ideal\Cartola\Banco;
|
||||||
|
use Incoviba\Exception\ServiceAction\Read;
|
||||||
use PhpOffice\PhpSpreadsheet;
|
use PhpOffice\PhpSpreadsheet;
|
||||||
use Psr\Http\Message\UploadedFileInterface;
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
|
|
||||||
@ -10,8 +11,8 @@ class Itau extends Banco
|
|||||||
{
|
{
|
||||||
use isExcel;
|
use isExcel;
|
||||||
|
|
||||||
const CUENTA_CORRIENTE = 0;
|
const int CUENTA_CORRIENTE = 0;
|
||||||
const ULTIMOS_MOVIMIENTOS = 1;
|
const int ULTIMOS_MOVIMIENTOS = 1;
|
||||||
|
|
||||||
public function processMovimientosDiarios(array $movimientos): array
|
public function processMovimientosDiarios(array $movimientos): array
|
||||||
{
|
{
|
||||||
@ -44,6 +45,12 @@ class Itau extends Banco
|
|||||||
$ext = pathinfo($uploadedFile->getClientFilename(), PATHINFO_EXTENSION);
|
$ext = pathinfo($uploadedFile->getClientFilename(), PATHINFO_EXTENSION);
|
||||||
return "/tmp/cartola.{$ext}";
|
return "/tmp/cartola.{$ext}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $filename
|
||||||
|
* @return array
|
||||||
|
* @throws Read
|
||||||
|
*/
|
||||||
protected function parseFile(string $filename): array
|
protected function parseFile(string $filename): array
|
||||||
{
|
{
|
||||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||||
@ -62,7 +69,7 @@ class Itau extends Banco
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (PhpSpreadsheet\Exception $exception) {
|
} catch (PhpSpreadsheet\Exception $exception) {
|
||||||
$this->logger->critical($exception);
|
throw new Read(__CLASS__, $exception);
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@ -166,6 +173,11 @@ class Itau extends Banco
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param PhpSpreadsheet\Worksheet\Worksheet $sheet
|
||||||
|
* @return int
|
||||||
|
* @throws PhpSpreadsheet\Exception
|
||||||
|
*/
|
||||||
protected function identifySheet(PhpSpreadsheet\Worksheet\Worksheet $sheet): int
|
protected function identifySheet(PhpSpreadsheet\Worksheet\Worksheet $sheet): int
|
||||||
{
|
{
|
||||||
foreach ($sheet->getRowIterator(1, 10) as $row) {
|
foreach ($sheet->getRowIterator(1, 10) as $row) {
|
||||||
@ -177,7 +189,7 @@ class Itau extends Banco
|
|||||||
return self::ULTIMOS_MOVIMIENTOS;
|
return self::ULTIMOS_MOVIMIENTOS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new PhpSpreadsheet\Exception();
|
throw new PhpSpreadsheet\Exception('Incorrect type of Worksheet');
|
||||||
}
|
}
|
||||||
protected function getDateRange(PhpSpreadsheet\Worksheet\Row $row): array
|
protected function getDateRange(PhpSpreadsheet\Worksheet\Row $row): array
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@ class IPC
|
|||||||
$ipcs = [];
|
$ipcs = [];
|
||||||
try {
|
try {
|
||||||
$ipcs = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY);
|
$ipcs = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY);
|
||||||
if (!isset($ipcs[$dateKey])) {
|
if (!isset($ipcs[$dateKey]) or $ipcs[$dateKey] === 0) {
|
||||||
throw new EmptyRedis($this->redisKey);
|
throw new EmptyRedis($this->redisKey);
|
||||||
}
|
}
|
||||||
} catch (EmptyRedis) {
|
} catch (EmptyRedis) {
|
||||||
|
@ -48,8 +48,8 @@ class Ine implements Provider
|
|||||||
]);
|
]);
|
||||||
try {
|
try {
|
||||||
$response = $this->client->get($request_uri);
|
$response = $this->client->get($request_uri);
|
||||||
} catch (GuzzleException) {
|
} catch (GuzzleException $exception) {
|
||||||
throw new EmptyResponse($request_uri);
|
throw new EmptyResponse($request_uri, $exception);
|
||||||
}
|
}
|
||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
$json = json_decode($body->getContents());
|
$json = json_decode($body->getContents());
|
||||||
|
@ -12,6 +12,9 @@ class MiIndicador implements Provider
|
|||||||
public function __construct(protected ClientInterface $client) {}
|
public function __construct(protected ClientInterface $client) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param string $money_symbol
|
||||||
|
* @param DateTimeInterface|null $dateTime
|
||||||
|
* @return float
|
||||||
* @throws EmptyResponse
|
* @throws EmptyResponse
|
||||||
*/
|
*/
|
||||||
public function get(string $money_symbol, ?DateTimeInterface $dateTime = null): float
|
public function get(string $money_symbol, ?DateTimeInterface $dateTime = null): float
|
||||||
@ -33,7 +36,7 @@ class MiIndicador implements Provider
|
|||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
$json = json_decode($body->getContents());
|
$json = json_decode($body->getContents());
|
||||||
|
|
||||||
if (empty($json) or $json->codigo !== $money_symbol or count($json->serie) === 0) {
|
if (empty($json) or !isset($json->codigo) or !isset($json->serie) or $json->codigo !== $money_symbol or count($json->serie) === 0) {
|
||||||
throw new EmptyResponse($request_uri);
|
throw new EmptyResponse($request_uri);
|
||||||
}
|
}
|
||||||
return $json->serie[0]->valor;
|
return $json->serie[0]->valor;
|
||||||
|
@ -79,13 +79,7 @@ class Queue extends Ideal\Service
|
|||||||
try {
|
try {
|
||||||
$this->jobService->update($job);
|
$this->jobService->update($job);
|
||||||
} catch (Update $exception) {
|
} catch (Update $exception) {
|
||||||
$this->logger->error($exception->getMessage(), ['job' => $job, 'exception' => [
|
$this->logger->error($exception->getMessage(), ['job' => $job, 'exception' => $exception]);
|
||||||
'code' => $exception->getCode(),
|
|
||||||
'message' => $exception->getMessage(),
|
|
||||||
'file' => $exception->getFile(),
|
|
||||||
'line' => $exception->getLine(),
|
|
||||||
'trace' => $exception->getTraceAsString(),
|
|
||||||
]]);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ class UF
|
|||||||
if ($date === null) {
|
if ($date === null) {
|
||||||
$date = new DateTimeImmutable();
|
$date = new DateTimeImmutable();
|
||||||
}
|
}
|
||||||
if ($date->diff($today)->days < 0) {
|
if ($date->diff($today)->invert === 1) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -32,7 +32,7 @@ class UF
|
|||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
$ufs = $this->getRedisUFs();
|
$ufs = $this->getRedisUFs();
|
||||||
if (!isset($ufs[$date->format('Y-m-d')])) {
|
if (!isset($ufs[$date->format('Y-m-d')]) or $ufs[$date->format('Y-m-d')] === 0) {
|
||||||
throw new EmptyRedis($this->redisKey);
|
throw new EmptyRedis($this->redisKey);
|
||||||
}
|
}
|
||||||
return $ufs[$date->format('Y-m-d')];
|
return $ufs[$date->format('Y-m-d')];
|
||||||
@ -54,12 +54,16 @@ class UF
|
|||||||
}
|
}
|
||||||
public function updateMany(array $dates): array
|
public function updateMany(array $dates): array
|
||||||
{
|
{
|
||||||
|
$today = new DateTimeImmutable();
|
||||||
$ufs = [];
|
$ufs = [];
|
||||||
try {
|
try {
|
||||||
$ufs = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY);
|
$ufs = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY);
|
||||||
} catch (EmptyRedis) {}
|
} catch (EmptyRedis) {}
|
||||||
$updated = [];
|
$updated = [];
|
||||||
foreach ($dates as $date) {
|
foreach ($dates as $date) {
|
||||||
|
if ($date->diff($today)->invert === 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!isset($ufs[$date->format('Y-m-d')]) or $ufs[$date->format('Y-m-d')] === 0) {
|
if (!isset($ufs[$date->format('Y-m-d')]) or $ufs[$date->format('Y-m-d')] === 0) {
|
||||||
$uf = $this->moneyService->getUF($date);
|
$uf = $this->moneyService->getUF($date);
|
||||||
if ($uf === 0.0) {
|
if ($uf === 0.0) {
|
||||||
|
@ -19,7 +19,7 @@ class USD
|
|||||||
$usds = [];
|
$usds = [];
|
||||||
try {
|
try {
|
||||||
$usds = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY);
|
$usds = json_decode($this->redisService->get($this->redisKey), JSON_OBJECT_AS_ARRAY);
|
||||||
if (!isset($usds[$date->format('Y-m-d')])) {
|
if (!isset($usds[$date->format('Y-m-d')]) or $usds[$date->format('Y-m-d')] === 0) {
|
||||||
throw new EmptyRedis($this->redisKey);
|
throw new EmptyRedis($this->redisKey);
|
||||||
}
|
}
|
||||||
$usd = $usds[$date->format('Y-m-d')];
|
$usd = $usds[$date->format('Y-m-d')];
|
||||||
|
@ -251,7 +251,7 @@ class Invoice extends AbstractEndPoint
|
|||||||
{
|
{
|
||||||
$paramsMap = [
|
$paramsMap = [
|
||||||
'customer' => 'customer',
|
'customer' => 'customer',
|
||||||
'product_id' => 'cuota_id',
|
'product_id' => 'venta_id',
|
||||||
'due_date' => 'fecha',
|
'due_date' => 'fecha',
|
||||||
'subscription' => 'subscription',
|
'subscription' => 'subscription',
|
||||||
'amount' => 'valor',
|
'amount' => 'valor',
|
||||||
@ -266,8 +266,6 @@ class Invoice extends AbstractEndPoint
|
|||||||
'invoice_external_id' => 'cuota_id'
|
'invoice_external_id' => 'cuota_id'
|
||||||
];
|
];
|
||||||
|
|
||||||
$today = new DateTimeImmutable('now', new DateTimeZone('America/Santiago'));
|
|
||||||
|
|
||||||
$params = [];
|
$params = [];
|
||||||
foreach ($paramsMap as $key => $ref) {
|
foreach ($paramsMap as $key => $ref) {
|
||||||
if ($ref === null) {
|
if ($ref === null) {
|
||||||
@ -278,14 +276,6 @@ class Invoice extends AbstractEndPoint
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($ref === 'valor') {
|
if ($ref === 'valor') {
|
||||||
/*$valor = 0;
|
|
||||||
if ($data['cuota']->pago->fecha <= $today) {
|
|
||||||
$valor = $data['cuota']->pago->valor();
|
|
||||||
}
|
|
||||||
if ($valor === 0) {
|
|
||||||
$valor = $data['cuota']->pago->valor / $data['venta']->uf;
|
|
||||||
}
|
|
||||||
$params[$key] = $valor;*/
|
|
||||||
$params[$key] = $data['cuota']->pago->valor;
|
$params[$key] = $data['cuota']->pago->valor;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -303,6 +293,10 @@ class Invoice extends AbstractEndPoint
|
|||||||
$params[$key] = $data['cuota']->id;
|
$params[$key] = $data['cuota']->id;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ($ref === 'product_id') {
|
||||||
|
$params[$key] = $data['venta']->id;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (array_key_exists($ref, $data) and $data[$ref] !== '' and $data[$ref] !== null) {
|
if (array_key_exists($ref, $data) and $data[$ref] !== '' and $data[$ref] !== null) {
|
||||||
$params[$key] = $data[$ref];
|
$params[$key] = $data[$ref];
|
||||||
}
|
}
|
||||||
|
@ -99,13 +99,13 @@ class Subscription extends AbstractEndPoint
|
|||||||
public function queue(int $venta_id): bool
|
public function queue(int $venta_id): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$venta = $this->ventaService->getById($venta_id);
|
$this->ventaService->getById($venta_id);
|
||||||
} catch (Read $exception) {
|
} catch (Read $exception) {
|
||||||
$this->logger->warning($exception);
|
$this->logger->warning($exception);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$subscription = $this->subscriptionRepsitory->fetchByVenta($venta_id);
|
$this->subscriptionRepsitory->fetchByVenta($venta_id);
|
||||||
return false;
|
return false;
|
||||||
} catch (EmptyResult) {
|
} catch (EmptyResult) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -181,7 +181,8 @@ class Propietario extends Service
|
|||||||
]);
|
]);
|
||||||
$filtered_data = array_intersect_key($data, $fields);
|
$filtered_data = array_intersect_key($data, $fields);
|
||||||
try {
|
try {
|
||||||
$direccion = $this->direccionRepository->fetchByCalleAndNumeroAndExtraAndComuna($filtered_data['calle'], $filtered_data['numero'], $filtered_data['extra'], $filtered_data['comuna']);
|
$direccion = $this->direccionRepository->fetchByCalleAndNumeroAndExtraAndComuna($filtered_data['calle'],
|
||||||
|
$filtered_data['numero'], $filtered_data['extra'], (int) $filtered_data['comuna']);
|
||||||
} catch (EmptyResult) {
|
} catch (EmptyResult) {
|
||||||
try {
|
try {
|
||||||
$direccion = $this->direccionRepository->create($filtered_data);
|
$direccion = $this->direccionRepository->create($filtered_data);
|
||||||
|
@ -123,7 +123,7 @@ class Reservation extends Ideal\Service\API
|
|||||||
$date = new DateTimeImmutable($data['date']);
|
$date = new DateTimeImmutable($data['date']);
|
||||||
} catch (DateMalformedStringException) {}
|
} catch (DateMalformedStringException) {}
|
||||||
try {
|
try {
|
||||||
$reservation = $this->reservationRepository->fetchByBuyerAndDate($data['buyer_rut'], $date);
|
$reservation = $this->reservationRepository->fetchByBuyerAndUnitAndDate($data['buyer_rut'], (int) $data['units'][0], $date);
|
||||||
|
|
||||||
if (array_key_exists('broker_rut', $data) and $data['broker_rut'] !== '') {
|
if (array_key_exists('broker_rut', $data) and $data['broker_rut'] !== '') {
|
||||||
try {
|
try {
|
||||||
@ -174,7 +174,7 @@ class Reservation extends Ideal\Service\API
|
|||||||
$this->reservationRepository->getConnection()->getPDO()->commit();
|
$this->reservationRepository->getConnection()->getPDO()->commit();
|
||||||
}
|
}
|
||||||
} catch (PDOException $exception) {
|
} catch (PDOException $exception) {
|
||||||
$this->logger->warning($exception->getMessage(), ['exception' => $exception->getTraceAsString()]);
|
$this->logger->warning($exception->getMessage(), ['exception' => $exception]);
|
||||||
if ($this->reservationRepository->getConnection()->getPDO()->inTransaction()) {
|
if ($this->reservationRepository->getConnection()->getPDO()->inTransaction()) {
|
||||||
$this->reservationRepository->getConnection()->getPDO()->rollBack();
|
$this->reservationRepository->getConnection()->getPDO()->rollBack();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user