diff --git a/app/resources/views/proyectos/brokers/contracts/show.blade.php b/app/resources/views/proyectos/brokers/contracts/show.blade.php index a9cafa1..7af1416 100644 --- a/app/resources/views/proyectos/brokers/contracts/show.blade.php +++ b/app/resources/views/proyectos/brokers/contracts/show.blade.php @@ -25,13 +25,14 @@ unit.promotions?.forEach(promotion => { amount /= 1/(1 - promotion.amount) }) - amount /= 1/(1 - this.commission) amount = 1 - amount prices.push({ id: unit.id, base: price, + commission: this.commission, + broker: price / (1 - this.commission), amount, - final: price / (1 - amount) + final: price / (1 - this.commission) / (1 - amount) }) }) return prices diff --git a/app/resources/views/proyectos/brokers/contracts/show/linea.blade.php b/app/resources/views/proyectos/brokers/contracts/show/linea.blade.php index 8a20b39..eb06fb8 100644 --- a/app/resources/views/proyectos/brokers/contracts/show/linea.blade.php +++ b/app/resources/views/proyectos/brokers/contracts/show/linea.blade.php @@ -5,8 +5,10 @@ Línea Orientación Cantidad - Precio Lista + Precio Base + Comisión Porcentaje + Precio Operador Precio Final @@ -51,6 +53,16 @@ `Max: UF ${formatters.ufs.format(Math.max(...prices.map(p => p.base)))}`, `Desv: UF ${formatters.ufs.format(Stat.standardDeviation(prices.map(p => p.base)))}` ].join("\n").replaceAll(' ', ' ') + const commission_tooltip = [ + `Min: ${formatters.percent.format(Math.min(...prices.map(p => p.commission)))}`, + `Max: ${formatters.percent.format(Math.max(...prices.map(p => p.commission)))}`, + `Desv: ${formatters.percent.format(Stat.standardDeviation(prices.map(p => p.commission)))}` + ].join("\n").replaceAll(' ', ' ') + const broker_tooltip = [ + `Min: ${formatters.ufs.format(Math.min(...prices.map(p => p.broker)))}`, + `Max: ${formatters.ufs.format(Math.max(...prices.map(p => p.broker)))}`, + `Desv: ${formatters.ufs.format(Stat.standardDeviation(prices.map(p => p.broker)))}` + ].join("\n").replaceAll(' ', ' ') const amount_tooltip = [ `Min: ${formatters.percent.format(Math.min(...prices.map(p => p.amount)))}`, `Max: ${formatters.percent.format(Math.max(...prices.map(p => p.amount)))}`, @@ -69,6 +81,8 @@ `${orientacion}`, `${unidades.length}`, `UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.base)))}`, + `${formatters.percent.format(Stat.mean(prices.map(p => p.commission)))}`, + `UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.broker)))}`, `${formatters.percent.format(Stat.mean(prices.map(p => p.amount)))}`, `UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.final)))}`, `` diff --git a/app/resources/views/proyectos/brokers/contracts/show/tipo.blade.php b/app/resources/views/proyectos/brokers/contracts/show/tipo.blade.php index 227dae5..3e67f1a 100644 --- a/app/resources/views/proyectos/brokers/contracts/show/tipo.blade.php +++ b/app/resources/views/proyectos/brokers/contracts/show/tipo.blade.php @@ -4,6 +4,8 @@ Tipo Cantidad Precio Base + Comisión + Precio Operador Porcentaje Precio Final @@ -34,6 +36,16 @@ `Max: UF ${formatters.ufs.format(Math.max(...prices.map(p => p.base)))}`, `Desv: UF ${formatters.ufs.format(Stat.standardDeviation(prices.map(p => p.base)))}` ].join("\n").replaceAll(' ', ' ') + const commission_tooltip = [ + `Min: ${formatters.percent.format(Math.min(...prices.map(p => p.commission)))}`, + `Max: ${formatters.percent.format(Math.max(...prices.map(p => p.commission)))}`, + `Desv: ${formatters.percent.format(Stat.standardDeviation(prices.map(p => p.commission)))}` + ].join("\n").replaceAll(' ', ' ') + const broker_tooltip = [ + `Min: ${formatters.ufs.format(Math.min(...prices.map(p => p.broker)))}`, + `Max: ${formatters.ufs.format(Math.max(...prices.map(p => p.broker)))}`, + `Desv: ${formatters.ufs.format(Stat.standardDeviation(prices.map(p => p.broker)))}` + ].join("\n").replaceAll(' ', ' ') const amount_tooltip = [ `Min: ${formatters.percent.format(Math.min(...prices.map(p => p.amount)))}`, `Max: ${formatters.percent.format(Math.max(...prices.map(p => p.amount)))}`, @@ -50,6 +62,8 @@ `${tipo.charAt(0).toUpperCase() + tipo.slice(1)}`, `${unidades.length}`, `UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.base)))}`, + `${formatters.percent.format(Stat.mean(prices.map(p => p.commission)))}`, + `UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.broker)))}`, `${formatters.percent.format(Stat.mean(prices.map(p => p.amount)))}`, `UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.final)))}`, `` diff --git a/app/resources/views/proyectos/brokers/contracts/show/unidades.blade.php b/app/resources/views/proyectos/brokers/contracts/show/unidades.blade.php index 1538f6e..50cacac 100644 --- a/app/resources/views/proyectos/brokers/contracts/show/unidades.blade.php +++ b/app/resources/views/proyectos/brokers/contracts/show/unidades.blade.php @@ -5,12 +5,13 @@ Tipo Order Unidad Unidad Orden + m² Estado - Precio Lista + Precio Base + Comisión + Precio Operador Porcentaje Precio Final - Fecha Inicio - Fecha Término @@ -22,6 +23,19 @@ ids = { units: 'unidades', } + columns = [ + 'tipo', + 'tipo_order', + 'unidad', + 'unidad_order', + 'metros', + 'estado', + 'precio_base', + 'commission', + 'precio_operador', + 'porcentaje', + 'precio_final', + ] constructor(commission) { super(commission) @@ -41,7 +55,8 @@ orderData: 3 }, { - target: [2, 5, 6, 7], + target: ['metros', 'precio_base', 'commission', 'precio_operador', 'porcentaje', 'precio_final'] + .map(column => this.columns.indexOf(column)), className: 'dt-right right aligned' } ] @@ -50,7 +65,8 @@ dto.layout = { top1Start: { searchBuilder: { - columns: [0, 2, 4, 5, 6, 7, 8, 9], + columns: this.columns.filter(column => !['tipo_order', 'unidad_order'].includes(column)) + .map(column => this.columns.indexOf(column)), } }, top1End: { @@ -62,31 +78,23 @@ title: 'Lista de Precios - {{ $contract->broker->name }} - {{ $contract->project->descripcion }} - {{ (new DateTime())->format('Y-m-d') }}', download: 'open', exportOptions: { - columns: [0, 2, 5, 6, 7], + columns: ['tipo', 'unidad', 'metros', 'commission', 'precio_operador', 'porcentaje', 'precio_final'] + .map(column => this.columns.indexOf(column)), rows: (idx, data, node) => { - return data[4] === 'Disponible' + return data[this.columns.indexOf('estado')] === 'Disponible' }, format: { body: (data, row, columnIdx, node) => { if (typeof data === 'string' && data.includes('(.*)<\/span>/, '$1') } + if (columnIdx === this.columns.indexOf('metros')) { + return data.replaceAll('.', '').replaceAll(',', '.') + } return data } } }, - customize: xlsx => { - const sheet = xlsx.xl.worksheets['sheet1.xml'] - const columns = Object.values($('row[r="2"] t', sheet).map((idx, column) => column.textContent)) - const columnStylesMap = { - Valor: '63', - Fecha: '15' - } - Object.entries(columnStylesMap).forEach((column, style) => { - const columnIndex = String.fromCharCode('A'.charCodeAt(0) + columns.indexOf(column)) - $(`c[r^="${columnIndex}"]`, sheet).attr('s', style) - }) - } } ] } @@ -106,8 +114,11 @@ unidad.proyecto_tipo_unidad.tipo_unidad.orden, unidad.descripcion, unidad.descripcion.padStart(4, '0'), + formatters.ufs.format(unidad.proyecto_tipo_unidad.vendible) ?? 0, unidad.sold ? 'Vendida' : 'Disponible', 'UF ' + formatters.ufs.format(price.base ?? 0), + formatters.percent.format(price.commission ?? 0), + 'UF ' + formatters.ufs.format(price.broker ?? 0), formatters.percent.format(price.amount ?? 0), 'UF ' + formatters.ufs.format(price.final ?? 0), unidad.promotion?.start_date ?? '',