Compare commits
11 Commits
da46914de4
...
98b18fab3e
Author | SHA1 | Date | |
---|---|---|---|
98b18fab3e | |||
12a4831887 | |||
86d030bb71 | |||
3b38b5d349 | |||
28fb96db6a | |||
af4dec77d1 | |||
df7f462ead | |||
68e436cd67 | |||
6d1782cac6 | |||
74a2cf7303 | |||
4d6a1827a3 |
@ -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
|
||||
|
@ -5,8 +5,10 @@
|
||||
<th class="center aligned">Línea</th>
|
||||
<th class="center aligned">Orientación</th>
|
||||
<th class="center aligned">Cantidad</th>
|
||||
<th class="right aligned" style="text-decoration: overline">Precio Lista</th>
|
||||
<th class="right aligned" style="text-decoration: overline">Precio Base</th>
|
||||
<th class="right aligned" style="text-decoration: overline">Comisión</th>
|
||||
<th class="right aligned" style="text-decoration: overline">Porcentaje</th>
|
||||
<th class="right aligned" style="text-decoration: overline">Precio Operador</th>
|
||||
<th class="right aligned" style="text-decoration: overline">Precio Final</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -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 @@
|
||||
`<td class="center aligned">${orientacion}</td>`,
|
||||
`<td class="center aligned">${unidades.length}</td>`,
|
||||
`<td class="right aligned"><span data-tooltip="${base_tooltip}" data-position="right center" data-variation="wide multiline">UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.base)))}</span></td>`,
|
||||
`<td class="right aligned"><span data-tooltip="${commission_tooltip}" data-position="right center" data-variation="wide multiline">${formatters.percent.format(Stat.mean(prices.map(p => p.commission)))}</span></td>`,
|
||||
`<td class="right aligned"><span data-tooltip="${broker_tooltip}" data-position="right center" data-variation="wide multiline">UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.broker)))}</span></td>`,
|
||||
`<td class="right aligned"><span data-tooltip="${amount_tooltip}" data-position="right center" data-variation="wide multiline">${formatters.percent.format(Stat.mean(prices.map(p => p.amount)))}</span></td>`,
|
||||
`<td class="right aligned"><span data-tooltip="${final_tooltip}" data-position="right center" data-variation="wide multiline">UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.final)))}</span></td>`,
|
||||
`</tr>`
|
||||
|
@ -4,6 +4,8 @@
|
||||
<th>Tipo</th>
|
||||
<th class="center aligned">Cantidad</th>
|
||||
<th class="right aligned" style="text-decoration: overline">Precio Base</th>
|
||||
<th class="right aligned" style="text-decoration: overline">Comisión</th>
|
||||
<th class="right aligned" style="text-decoration: overline">Precio Operador</th>
|
||||
<th class="right aligned" style="text-decoration: overline">Porcentaje</th>
|
||||
<th class="right aligned" style="text-decoration: overline">Precio Final</th>
|
||||
</tr>
|
||||
@ -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 @@
|
||||
`<td>${tipo.charAt(0).toUpperCase() + tipo.slice(1)}</td>`,
|
||||
`<td class="center aligned">${unidades.length}</td>`,
|
||||
`<td class="right aligned"><span data-tooltip="${base_tooltip}" data-position="right center" data-variation="wide multiline">UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.base)))}</span></td>`,
|
||||
`<td class="right aligned"><span data-tooltip="${commission_tooltip}" data-position="right center" data-variation="wide multiline">${formatters.percent.format(Stat.mean(prices.map(p => p.commission)))}</span></td>`,
|
||||
`<td class="right aligned"><span data-tooltip="${broker_tooltip}" data-position="right center" data-variation="wide multiline">UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.broker)))}</span></td>`,
|
||||
`<td class="right aligned"><span data-tooltip="${amount_tooltip}" data-position="right center" data-variation="wide multiline">${formatters.percent.format(Stat.mean(prices.map(p => p.amount)))}</span></td>`,
|
||||
`<td class="right aligned"><span data-tooltip="${final_tooltip}" data-position="right center" data-variation="wide multiline">UF ${formatters.ufs.format(Stat.mean(prices.map(p => p.final)))}</span></td>`,
|
||||
`</tr>`
|
||||
|
@ -5,12 +5,13 @@
|
||||
<th>Tipo Order</th>
|
||||
<th class="right aligned">Unidad</th>
|
||||
<th>Unidad Orden</th>
|
||||
<th>m²</th>
|
||||
<th>Estado</th>
|
||||
<th class="right aligned">Precio Lista</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">Porcentaje</th>
|
||||
<th class="right aligned">Precio Final</th>
|
||||
<th>Fecha Inicio</th>
|
||||
<th>Fecha Término</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
@ -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')) {
|
||||
return data.replace(/<span.*>(.*)<\/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 ? '<span class="ui yellow text">Vendida</span>' : '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 ?? '',
|
||||
|
@ -23,43 +23,45 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@if ($venta->formaPago()->pie->reajuste === null)
|
||||
<h4 class="ui header optional" data-name="reajuste">Reajuste <i class="small plus icon"></i></h4>
|
||||
<div class="fields optional" id="reajuste">
|
||||
<div class="field">
|
||||
<label for="valor_reajuste">Valor [$]</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="valor_reajuste" id="valor_reajuste" />
|
||||
@if ($venta->formaPago()->pie !== null)
|
||||
@if ($venta->formaPago()->pie->reajuste === null)
|
||||
<h4 class="ui header optional" data-name="reajuste">Reajuste <i class="small plus icon"></i></h4>
|
||||
<div class="fields optional" id="reajuste">
|
||||
<div class="field">
|
||||
<label for="valor_reajuste">Valor [$]</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="valor_reajuste" id="valor_reajuste" />
|
||||
</div>
|
||||
</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 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>
|
||||
@else
|
||||
<h4 class="ui header" data-name="reajuste">Reajuste</h4>
|
||||
<div class="fields" id="reajuste">
|
||||
<div class="field">
|
||||
<label for="valor_reajuste">Valor [$]</label>
|
||||
<div class="ui left labeled disabled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" value="{{$format->number($venta->formaPago()->pie->reajuste->valor)}}" />
|
||||
@else
|
||||
<h4 class="ui header" data-name="reajuste">Reajuste</h4>
|
||||
<div class="fields" id="reajuste">
|
||||
<div class="field">
|
||||
<label for="valor_reajuste">Valor [$]</label>
|
||||
<div class="ui left labeled disabled input">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" value="{{$format->number($venta->formaPago()->pie->reajuste->valor)}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="fecha_reajuste">Fecha</label>
|
||||
<div class="ui disabled input">
|
||||
<input type="text" value="{{$venta->formaPago()->pie->reajuste->fecha->format('d-m-Y')}}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="fecha_reajuste">Fecha</label>
|
||||
<div class="ui disabled input">
|
||||
<input type="text" value="{{$venta->formaPago()->pie->reajuste->fecha->format('d-m-Y')}}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
@if (!isset($venta->formaPago()->escritura))
|
||||
<h4 class="ui header optional" data-name="pago">Pago en Escritura <i class="small plus icon"></i></h4>
|
||||
@ -249,6 +251,7 @@
|
||||
subsidio.watch()
|
||||
$('#escriturar_form').submit(event => {
|
||||
event.preventDefault()
|
||||
$('.ui.button').addClass('loading')
|
||||
const url = '{{$urls->api}}/venta/{{$venta->id}}/escriturar'
|
||||
const body = new FormData(event.currentTarget)
|
||||
const fecha = $('#fecha').calendar('get date')
|
||||
@ -268,6 +271,7 @@
|
||||
}
|
||||
}
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
$('.ui.button').removeClass('loading')
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
|
Reference in New Issue
Block a user