Listado de promociones

This commit is contained in:
Juan Pablo Vial
2025-04-22 18:34:23 -04:00
parent 90b05ca25c
commit 966b341b65
4 changed files with 210 additions and 55 deletions

View File

@ -9,13 +9,15 @@
<th>Tipología</th>
<th>Piso</th>
<th>Orientación</th>
<th>m&#0178;</th>
<th>m&#0178; Interior</th>
<th>m&#0178; Terraza</th>
<th>m&#0178; Vendibles</th>
<th>m&#0178; Total</th>
<th class="right aligned">Precio Base</th>
<th class="right aligned">Comisión</th>
<th class="right aligned">Precio Operador</th>
<th class="right aligned">UF/</th>
<th class="right aligned">Porcentaje</th>
<th class="right aligned">Precio Final</th>
<th class="right aligned">Promociones</th>
</tr>
</thead>
<tbody></tbody>
@ -36,13 +38,15 @@
'tipologia',
'piso',
'orientacion',
'metros_interior',
'metros_terraza',
'metros',
'metros_total',
'precio_base',
'commission',
'precio_operador',
'UF/m²',
'porcentaje',
'precio_final',
'promociones',
]
constructor(commission) {
super(commission)
@ -86,7 +90,7 @@
title: 'Lista de Precios - {{ $contract->broker->name }} - {{ $contract->project->descripcion }} - {{ (new DateTime())->format('Y-m-d') }}',
download: 'open',
exportOptions: {
columns: ['tipo', 'unidad', 'tipologia', 'piso', 'orientacion', 'metros', 'precio_operador', 'porcentaje', 'precio_final']
columns: ['tipo', 'unidad', 'tipologia', 'piso', 'orientacion', 'metros_interior', 'metros_terraza', 'metros', 'metros_total', 'precio_operador', 'promociones']
.map(column => this.columns.indexOf(column)),
rows: (idx, data, node) => {
return data[this.columns.indexOf('estado')] === 'Libre'
@ -117,6 +121,35 @@
units.forEach(unidad => {
const tipo = unidad.proyecto_tipo_unidad.tipo_unidad.descripcion
const price = prices.find(p => p.id === unidad.id)
let subTable = false
if (price.promotions.length > 0) {
subTable = document.createElement('table')
subTable.className = 'ui table'
const subTHead = document.createElement('thead')
price.promotions.forEach(p => {
subTHead.insertAdjacentHTML('beforeend', [
'<tr>',
'<th class="center aligned">Nombre</th>',
'<th class="center aligned">Forma</th>',
'<th class="right aligned">Precio Final</th>',
'</tr>'
].join("\n"))
})
const subTBody = document.createElement('tbody')
price.promotions.forEach(p => {
subTBody.insertAdjacentHTML('beforeend', [
'<tr>',
`<td class="center aligned">${p.name}</td>`,
`<td class="right aligned">${p.type === 1 ? 'UF ' + formatters.ufs.format(p.amount) : formatters.percent.format(p.amount)}</td>`,
`<td class="right aligned">UF ${formatters.ufs.format(p.final)}</td>`,
'</tr>'
].join("\n"))
})
subTable.appendChild(subTHead).appendChild(subTBody)
}
tableData.push([
unidad.sold ? `<span class="ui yellow text">Vendida</span>` : 'Libre',
tipo.charAt(0).toUpperCase() + tipo.slice(1),
@ -126,15 +159,15 @@
unidad.proyecto_tipo_unidad.tipologia,
unidad.piso,
unidad.orientacion,
formatters.ufs.format(unidad.proyecto_tipo_unidad.util) ?? 0,
formatters.ufs.format(unidad.proyecto_tipo_unidad.terraza) ?? 0,
formatters.ufs.format(unidad.proyecto_tipo_unidad.vendible) ?? 0,
formatters.ufs.format(unidad.proyecto_tipo_unidad.superficie) ?? 0,
'UF ' + formatters.ufs.format(price.base ?? 0),
formatters.percent.format(price.commission ?? 0),
'UF ' + formatters.ufs.format(price.broker ?? 0),
formatters.ufs.format(price.broker / unidad.proyecto_tipo_unidad.vendible),
formatters.percent.format(price.amount ?? 0),
'UF ' + formatters.ufs.format(price.final ?? 0),
unidad.promotion?.start_date ?? '',
unidad.promotion?.end_date ?? '',
subTable ? subTable.outerHTML : 'UF ' + formatters.ufs.format(price.broker ?? 0),
])
})
table.rows.add(tableData)