feature/cierres (#25)

Varios cambios

Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl>
Reviewed-on: #25
This commit is contained in:
2025-07-22 13:18:00 +00:00
parent ba57cad514
commit 307f2ac7d7
418 changed files with 20045 additions and 984 deletions

View File

@ -3,5 +3,6 @@
<i class="dropdown icon"></i>
<div class="menu">
<a class="item" href="{{$urls->base}}/proyectos/unidades">Unidades</a>
<a class="item" href="{{ $urls->base }}/proyectos/brokers">Operadores</a>
</div>
</div>

View File

@ -11,7 +11,7 @@
</div>
@push('page_scripts')
<script type="text/javascript">
<script>
function logout() {
return fetch('{{$urls->base}}/logout').then(response => {
if (response.ok) {

View File

@ -3,6 +3,7 @@
<i class="dropdown icon"></i>
<div class="menu">
<a class="item" href="{{$urls->base}}/ventas/precios">Precios</a>
<a class="item" href="{{ $urls->base }}/ventas/promotions">Promociones</a>
<a class="item" href="{{$urls->base}}/ventas/cierres">Cierres</a>
<div class="item">
Cuotas
@ -33,6 +34,7 @@
{{--<a class="item" href="{{$urls->base}}/ventas/precios/importar">Importar Precios</a>--}}
{{--<a class="item" href="{{$urls->base}}/ventas/cierres/evaluar">Evaluar Cierre</a>--}}
<a class="item" href="{{$urls->base}}/ventas/facturacion">Facturación</a>
<div class="divider"></div>
<a class="item" href="{{$urls->base}}/ventas/add">
Nueva Venta
<i class="plus icon"></i>

View File

@ -1,33 +1,9 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" integrity="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.js" integrity="sha512-gnoBksrDbaMnlE0rhhkcx3iwzvgBGz6mOEj4/Y5ZY09n55dYddx6+WYc72A55qEesV8VX2iMomteIwobeGK1BQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="text/javascript">
class APIClient {
static fetch(url, options=null, showErrors=false) {
return fetchAPI(url, options, showErrors)
}
}
function fetchAPI(url, options=null, showErrors=false) {
if (options === null) {
options = {}
}
if (!Object.hasOwn(options, 'headers')) {
options['headers'] = {}
}
if (!Object.hasOwn(options['headers'], 'Authorization')) {
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}{{($login->isIn()) ? $login->getSeparator() . $login->getToken() : ''}}'
}
return fetch(url, options).then(response => {
if (response.ok) {
return response
}
throw new Error(JSON.stringify({code: response.status, message: response.statusText, url}))
}).catch(error => {
if (showErrors) {
console.error(error)
}
})
}
@include('layout.body.scripts.api')
<script>
const datatables_defaults = {
language: {
emptyTable: 'No hay datos disponibles',

View File

@ -0,0 +1,32 @@
<script>
class APIClient {
static getApiKey() {
return '{{md5($API_KEY)}}{{($login->isIn()) ? $login->getSeparator() . $login->getToken() : ''}}'
}
static fetch(url, options=null, showErrors=false) {
if (options === null) {
options = {}
}
if (!Object.hasOwn(options, 'headers')) {
options['headers'] = {}
}
if (!Object.hasOwn(options['headers'], 'Authorization')) {
options['headers']['Authorization'] = `Bearer ${APIClient.getApiKey()}`
}
return fetch(url, options).then(response => {
if (response.ok) {
return response
}
throw new Error(JSON.stringify({code: response.status, message: response.statusText, url}))
}).catch(error => {
if (showErrors) {
console.error(error)
}
})
}
}
function fetchAPI(url, options=null, showErrors=false) {
return APIClient.fetch(url, options, showErrors)
}
</script>

View File

@ -1,4 +1,4 @@
@push('page_scripts')
<script type="text/javascript" src="https://cdn.datatables.net/2.0.3/js/dataTables.min.js"></script>
<script src="https://cdn.datatables.net/2.0.3/js/dataTables.min.js"></script>
<script src="https://cdn.datatables.net/2.0.3/js/dataTables.semanticui.min.js"></script>
@endpush

View File

@ -2,4 +2,26 @@
<script src="https://cdn.datatables.net/datetime/1.5.2/js/dataTables.dateTime.min.js"></script>
<script src="https://cdn.datatables.net/searchbuilder/1.7.0/js/dataTables.searchBuilder.min.js"></script>
<script src="https://cdn.datatables.net/searchbuilder/1.7.0/js/searchBuilder.semanticui.js"></script>
<script>
const searchBuilder = {
add: 'Filtrar',
condition: 'Comparador',
clearAll: 'Resetear',
delete: 'Eliminar',
deleteTitle: 'Eliminar Titulo',
data: 'Columna',
left: 'Izquierda',
leftTitle: 'Titulo Izquierdo',
logicAnd: 'Y',
logicOr: 'O',
right: 'Derecha',
rightTitle: 'Titulo Derecho',
title: {
0: 'Filtros',
_: 'Filtros (%d)'
},
value: 'Opciones',
valueJoiner: 'y'
}
</script>
@endpush

View File

@ -0,0 +1,45 @@
@push('page_scripts')
<script>
Intl.NumberFormat.prototype.parse = function(valueString) {
const format = new Intl.NumberFormat(this.resolvedOptions().locale);
const parts = format.formatToParts(-12345.6);
const numerals = Array.from({ length: 10 }).map((_, i) => format.format(i));
const index = new Map(numerals.map((d, i) => [d, i]));
_minusSign = new RegExp(`[${parts.find(d => d.type === 'minusSign').value}]`);
_group = new RegExp(`[${parts.find(d => d.type === 'group').value}]`, 'g');
_decimal = new RegExp(`[${parts.find(d => d.type === 'decimal').value}]`);
_numeral = new RegExp(`[${numerals.join('')}]`, 'g');
_index = d => index.get(d);
const DIRECTION_MARK = /\u061c|\u200e/g
return +(
valueString.trim()
.replace(DIRECTION_MARK, '')
.replace(_group, '')
.replace(_decimal, '.')
.replace(_numeral, _index)
.replace(_minusSign, '-')
)
}
Intl.NumberFormat.prototype.isLocale = function(stringValue) {
const format = new Intl.NumberFormat(this.resolvedOptions().locale);
const parts = format.formatToParts(-12345.6);
const group = parts.find(d => d.type === 'group').value;
const decimal = parts.find(d => d.type === 'decimal').value;
if (stringValue.includes(group)) {
if (stringValue.includes(decimal)) {
return stringValue.indexOf(group) < stringValue.indexOf(decimal)
}
if (stringValue.split(group).map(d => d.length).filter(d => d > 3).length > 0) {
return false
}
return stringValue.split(group).length > 2;
}
if (stringValue.includes(decimal)) {
return stringValue.split(decimal).length <= 2;
}
return false
}
</script>
@endpush

View File

@ -0,0 +1,76 @@
@push('page_scripts')
<script>
if (typeof Intl.NumberFormat.isLocale === 'undefined' || typeof Intl.NumberFormat.isLocale !== 'function') {
// Load Intl.NumberFormat custom methods
@include('layout.body.scripts.number_format')
}
class NumberInput {
input
isRational
outputLocale
currentValue
formatters
constructor({input, isRational, outputLocale}) {
this.input = input
this.isRational = isRational
this.outputLocale = outputLocale || 'es-CL'
this.formatters = {}
const locales = ['es-CL', 'en-US']
locales.forEach(locale => {
this.formatters[locale] = {
rational: new Intl.NumberFormat(locale, {minimumFractionDigits: 2, maximumFractionDigits: 2}),
integer: new Intl.NumberFormat(locale)
}
})
if (this.input.value !== '') {
this.currentValue = this.process(this.input.value)
this.input.value = this.format(this.currentValue)
}
}
watch() {
this.input.addEventListener('change', event => {
this.currentValue = this.process(event.currentTarget.value)
this.input.value = this.format(this.currentValue)
})
}
process(stringValue) {
if (stringValue === '') {
return ''
}
if (typeof stringValue !== 'string') {
return stringValue
}
return this.formatters[this.detectLocale(stringValue)][this.isRational ? 'rational' : 'integer'].parse(stringValue)
}
detectLocale(stringValue) {
if (stringValue === '') {
return ''
}
if (typeof stringValue !== 'string') {
return stringValue
}
const outputFormat = this.formatters[this.outputLocale][this.isRational ? 'rational' : 'integer'].isLocale(stringValue)
const otherFormats = Object.entries(this.formatters).filter(formatter => formatter[0] !== this.outputLocale).map(formatter => {
return {
locale: formatter[0],
value: formatter[1][this.isRational ? 'rational' : 'integer'].isLocale(stringValue)
}
}).filter(formatter => formatter.value)
if (outputFormat) {
return this.outputLocale
}
if (otherFormats.length > 0) {
return otherFormats[0].locale
}
return 'en-US'
}
format(value) {
return this.formatters[this.outputLocale][this.isRational ? 'rational' : 'integer'].format(value)
}
}
</script>
@endpush

View File

@ -28,7 +28,7 @@
if (!(typeof digito === 'string' || digito instanceof String)) {
digito = digito.toString()
}
return Rut.digitoVerificador(rut) === digito
return Rut.digitoVerificador(rut).toString().toUpperCase() === digito.toUpperCase()
}
}
</script>

View File

@ -0,0 +1,6 @@
@prepend('page_scripts')
<script src='https://unpkg.com/simple-statistics@7.8.8/dist/simple-statistics.min.js'></script>
<script>
const Stat = ss
</script>
@endprepend

View File

@ -1,9 +1,9 @@
<head>
<meta charset="utf8" />
@hasSection('page_title')
<title>Incoviba - @yield('page_title')</title>
<title>Incoviba - @yield('page_title')</title>
@else
<title>Incoviba</title>
<title>Incoviba</title>
@endif
<link rel="icon" href="{{$urls->images}}/Isotipo 16.png" />
@include('layout.head.styles')