From beb73ba6dfadc062207d0300a2ed4a5603ecc27d Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 17 Oct 2025 11:59:34 -0300 Subject: [PATCH 1/9] Comparacion con valor base --- .../views/ventas/reservations.blade.php | 171 ++++++++++++++---- app/src/Model/Venta/Reservation.php | 7 +- app/src/Service/Venta/Reservation.php | 3 + 3 files changed, 144 insertions(+), 37 deletions(-) diff --git a/app/resources/views/ventas/reservations.blade.php b/app/resources/views/ventas/reservations.blade.php index 92d46c9..1677931 100644 --- a/app/resources/views/ventas/reservations.blade.php +++ b/app/resources/views/ventas/reservations.blade.php @@ -295,46 +295,72 @@ } } get columnsData() { + const columnValues = { + id: reservation => reservation.id, + unidades: reservation => reservation.summary, + cliente: reservation => reservation.buyer.nombreCompleto, + fecha: reservation => this.formatters.date.format(new Date(Date.parse(reservation.date) + 24 * 60 * 60 * 1000)), + oferta: reservation => `${this.formatters.ufs.format(reservation.offer)} UF`, + valida: reservation => reservation.valid ? 'Si' : 'No', + operador: reservation => reservation.broker?.name ?? '', + }; return this.reservations.map(reservation => { - const date = new Date(Date.parse(reservation.date) + 24 * 60 * 60 * 1000) - return { + //const date = new Date(Date.parse(reservation.date) + 24 * 60 * 60 * 1000) + const data = {} + Object.entries(columnValues).forEach(([key, value]) => { + if (key in this.draw().tooltip()) { + data[key] = `data-content="${this.draw().tooltip()[key](reservation)}" data-variation="very wide">${value(reservation)}` + return + } + data[key] = value(reservation) + }) + return data + /*return { id: reservation.id, unidades: reservation.summary, - cliente: reservation.buyer.nombreCompleto, + cliente: `data-content="${this.draw().tooltip().buyer(reservation)}">${reservation.buyer.nombreCompleto}`, fecha: this.formatters.date.format(date), - oferta: `${this.formatters.ufs.format(reservation.offer)} UF`, + oferta: `data-content="${this.draw().tooltip().payment(reservation)}">${this.formatters.ufs.format(reservation.offer)} UF`, valida: reservation.valid ? 'Si' : 'No', operador: reservation.broker?.name ?? '', - } + }*/ }) } draw() { - if (this.reservations.length === 0) { - this.empty() - return - } - const tbody = this.component.querySelector('tbody') - tbody.innerHTML = '' - this.columnsData.forEach(column => { - const tr = document.createElement('tr') - const contents = [] - const id = column.id - this.columnNames.forEach(name => { - contents.push(`${column[name]}`) - }) - const actions = this.drawActions(id) - if (actions !== '') { - contents.push(actions) - } - tr.innerHTML = contents.join("\n") - tbody.appendChild(tr) - }) - this.show() + return { + tbody: () => { + if (this.reservations.length === 0) { + this.empty() + return + } + const tbody = this.component.querySelector('tbody') + tbody.innerHTML = '' + this.columnsData.forEach(column => { + const tr = document.createElement('tr') + const contents = [] + const id = column.id + this.columnNames.forEach(name => { + let td = `${column[name]}` + if (['oferta', 'cliente', 'valida'].includes(name)) { + td = `` + } + contents.push(td) + }) + const actions = this.draw().actions(id) + if (actions !== '') { + contents.push(actions) + } + tr.innerHTML = contents.join("\n") + tbody.appendChild(tr) + }) + this.show() - this.watch() - } - drawActions(id) { - return ` + $(this.component).find('[data-content]').popup() + + this.watch() + }, + actions: id => { + return ` ` + }, + tooltip: () => { + return { + oferta: reservation => { + const formatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2}) + + const output = [] + reservation.units.forEach(unit => { + const type = unit.unit.proyecto_tipo_unidad.tipo_unidad.descripcion + output.push(`${type.charAt(0).toUpperCase() + type.slice(1)} ${unit.unit.descripcion}: ${formatter.format(unit.value)} UF`) + }) + if (reservation.broker !== null) { + output.push('-----') + let commission = reservation.broker.commission + output.push(`Broker: ${reservation.broker.name} (${commission})`) + } + if (reservation.promotions.length > 0) { + output.push('-----') + reservation.promotions.forEach(promotion => { + output.push(`${promotion.name}: ${formatter.format(promotion.value)} UF`) + }) + } + return output.join("\n") + }, + cliente: reservation => { + const formatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0}) + return [ + `RUT: ${formatter.format(reservation.buyer.rut)}-${reservation.buyer.digito}` + ].join("\n") + } + } + } + } } watch() { if (Object.keys(this.actions).length === 0) { @@ -412,8 +471,10 @@ return row }) } - drawActions(id) { - return ` + draw() { + const draw = super.draw() + draw.actions = (id) => { + return ` ` + } + return draw } actions = { edit: event => { @@ -448,6 +511,40 @@ super({component_id, formatters}) } + draw() { + const draw = super.draw() + const tooltip = draw.tooltip() + tooltip['valida'] = reservation => { + const formatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2}) + + const output = [] + reservation.units.forEach(unit => { + let type = unit.unit.proyecto_tipo_unidad.tipo_unidad.descripcion + type = type.charAt(0).toUpperCase() + type.slice(1) + const base = unit.base ?? (unit.value ?? 0); + const price = unit.unit.current_precio?.valor ?? 0 + const diff = (base - price) / price * 100 + output.push(`${type} ${unit.unit.descripcion}: ${formatter.format(base)} UF - ${formatter.format(price)} UF (${formatter.format(diff)} %)`) + }) + reservation.promotions.forEach(promotion => { + let value = 0 + switch (promotion.type) { + case {{ \Incoviba\Model\Venta\Promotion\Type::FIXED }}: + value = `${formatter.format(promotion.value)} UF` + break; + case {{ \Incoviba\Model\Venta\Promotion\Type::VARIABLE }}: + value = `${formatter.format(promotion.value * 100)} %` + break; + } + output.push(`${promotion.description}: ${value}`) + }) + return output.join("\n") + } + draw['tooltip'] = () => { + return tooltip + } + return draw + } actions = { approve: event => { event.preventDefault() @@ -482,8 +579,12 @@ return data[idx] }) } - drawActions(id) { - return '' + draw() { + const draw = super.draw() + draw.actions = (id) => { + return '' + } + return draw } watch() {} @@ -522,7 +623,7 @@ if (json.reservations.length > 0) { component.set.reservations(json.reservations) } - component.draw() + component.draw().tbody() }) }, active: project_id => { diff --git a/app/src/Model/Venta/Reservation.php b/app/src/Model/Venta/Reservation.php index 8f84ce4..79639d6 100644 --- a/app/src/Model/Venta/Reservation.php +++ b/app/src/Model/Venta/Reservation.php @@ -22,10 +22,13 @@ class Reservation extends Common\Ideal\Model public function withCommission(): float { $base = 0; - foreach ($this->units as $unit) { + foreach ($this->units as &$unit) { + $unitBase = $unit->value; foreach ($this->promotions as $promotion) { - $base += $promotion->activate()->reverse($unit['unit'], $unit['value'], $this->broker); + $unitBase = $promotion->activate()->reverse($unit->unit, $unitBase, $this->broker); } + $unit->base = $unitBase; + $base += $unitBase; } return $base; } diff --git a/app/src/Service/Venta/Reservation.php b/app/src/Service/Venta/Reservation.php index 3be8c93..59a0ded 100644 --- a/app/src/Service/Venta/Reservation.php +++ b/app/src/Service/Venta/Reservation.php @@ -251,6 +251,9 @@ class Reservation extends Ideal\Service\API return $this->stateRepository->fetchByReservation($reservation_id); }) ); + foreach ($model->units as &$unit) { + $unit->unit = $this->unitService->getById($unit->unit->id); + } $model->buyer = $this->personaService->getById($model->buyer->rut); return $model; } From b986e63cc0d4e097e2f8c3ed313c225a0c8d236e Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 17 Oct 2025 12:38:57 -0300 Subject: [PATCH 2/9] FIX: address exists --- app/src/Service/Persona.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/Service/Persona.php b/app/src/Service/Persona.php index 84bc645..6773841 100644 --- a/app/src/Service/Persona.php +++ b/app/src/Service/Persona.php @@ -236,6 +236,9 @@ class Persona extends Ideal\Service } else { $newKey = substr($key, strlen('address_')); } + if ($newKey === 'id') { + continue; + } $addressData[$newKey] = $value; } if (!empty($addressData)) { From 434c1c6d06aeca44438c8f93590ea36e598da4bb Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 17 Oct 2025 12:48:14 -0300 Subject: [PATCH 3/9] FIX: infinite loop --- app/common/Implement/Log/Processor/Exception.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/Implement/Log/Processor/Exception.php b/app/common/Implement/Log/Processor/Exception.php index d02431d..22507b9 100644 --- a/app/common/Implement/Log/Processor/Exception.php +++ b/app/common/Implement/Log/Processor/Exception.php @@ -61,7 +61,7 @@ class Exception implements ProcessorInterface 'trace' => $exception->getTraceAsString(), ]; if ($exception->getPrevious() !== null) { - $output['previous'] = $this->processException($exception); + $output['previous'] = $this->processException($exception->getPrevious()); } return $output; } From 815d81c9c316f356ca9e23ca49b2d85211e17087 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 17 Oct 2025 13:46:03 -0300 Subject: [PATCH 4/9] Forma de pago en reserva --- .../ventas/reservations/modal/add.blade.php | 148 +++++++++++++++++- 1 file changed, 147 insertions(+), 1 deletion(-) diff --git a/app/resources/views/ventas/reservations/modal/add.blade.php b/app/resources/views/ventas/reservations/modal/add.blade.php index 1150441..7896c27 100644 --- a/app/resources/views/ventas/reservations/modal/add.blade.php +++ b/app/resources/views/ventas/reservations/modal/add.blade.php @@ -131,6 +131,41 @@

Unidades

+

Forma de Pago

+
+
+
+ + +
+
+
+ +
+ +
UF
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+ +
+ +
UF
+
+
+
@@ -362,7 +397,7 @@ '
', '', '
', - '', + '', '
UF
', '
', '
', @@ -394,6 +429,101 @@ this.draw.buttons() } } + class AddModalPayments { + ids = { + pie: { + checkbox: 'add_has_pie', + value: 'add_pie', + installments: 'add_cuotas' + }, + credit: { + checkbox: 'add_has_credit', + value: 'add_credit' + } + } + components = { + pie: { + $checkbox: null, + value: null, + installments: null + }, + credit: { + $checkbox: null, + value: null + } + } + data = { + pie: { + value: '', + installments: '' + }, + credit: { + value: '' + } + } + constructor() { + this.setup() + } + reset() { + this.components.pie.$checkbox.prop('checked', false) + this.components.pie.value.value = '' + this.components.pie.installments.value = '' + this.components.credit.$checkbox.prop('checked', false) + this.components.credit.value.value = '' + } + show = { + pie: () => { + this.components.pie.value.style.display = this.data.pie.value + this.components.pie.installments.style.display = this.data.pie.installments + }, + credit: () => { + this.components.credit.value.style.display = this.data.credit.value + } + } + hide = { + pie: () => { + this.components.pie.value.style.display = 'none' + this.components.pie.installments.style.display = 'none' + }, + credit: () => { + this.components.credit.value.style.display = 'none' + }, + all: () => { + this.hide.pie() + this.hide.credit() + } + } + setup() { + this.components.pie.$checkbox = $(`#${this.ids.pie.checkbox}`) + this.components.pie.value = document.getElementById(this.ids.pie.value) + this.components.pie.installments = document.getElementById(this.ids.pie.installments) + this.components.credit.$checkbox = $(`#${this.ids.credit.checkbox}`) + this.components.credit.value = document.getElementById(this.ids.credit.value) + + this.components.pie.$checkbox.checkbox() + this.components.pie.$checkbox.change(changeEvent => { + if (this.components.pie.$checkbox.is(':checked')) { + this.show.pie() + return + } + this.hide.pie() + }) + this.components.credit.$checkbox.checkbox() + this.components.credit.$checkbox.change(changeEvent => { + if (this.components.credit.$checkbox.is(':checked')) { + this.show.credit() + return + } + this.hide.credit() + }) + + this.data.pie.value = this.components.pie.value.style.display + this.data.pie.installments = this.components.pie.installments.style.display + this.data.credit.value = this.components.credit.value.style.display + + this.hide.all() + } + } class AddReservationModal { ids = { modal: '', @@ -429,6 +559,7 @@ project_name: null, unit_buttons: null, units: null, + payments: null, $loader: null } data = { @@ -509,6 +640,7 @@ this.components.form.reset() this.components.promotions.reset() this.components.units.reset() + this.components.payments.reset() } add() { const url = '/api/ventas/reservation/add' @@ -524,6 +656,16 @@ const birthdate = this.components.$birthdate.calendar('get date') body.set('add_buyer_birthdate', [birthdate.getFullYear(), birthdate.getMonth() + 1, birthdate.getDate()].join('-')) + if (this.components.payments.components.pie.$checkbox.checkbox('is unchecked')) { + body.delete('add_pie') + body.delete('add_cuotas') + } + body.delete('add_has_pie') + if (this.components.payments.components.credit.$checkbox.checkbox('is unchecked')) { + body.delete('add_credit') + } + body.delete('add_has_credit') + body.delete('comuna') body.delete('region') body.delete('broker') @@ -672,6 +814,9 @@ } fill = { user: user => { + if (typeof user === 'undefined' || user === null) { + return + } const form = this.components.form form.querySelector('input[name="add_buyer_name"]').value = user.nombres || '' form.querySelector('input[name="add_buyer_last_name"]').value = user.apellidoPaterno || '' @@ -753,6 +898,7 @@ this.components.projects = document.getElementById(this.ids.projects) this.components.project_name = document.getElementById(this.ids.project_name) this.components.units = new AddModalUnits(this) + this.components.payments = new AddModalPayments() this.components.$modal.modal({ onApprove: () => { From 4bd3c7af9b5ee944a4bc7670abd103ecbd0b0a93 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 17 Oct 2025 13:48:07 -0300 Subject: [PATCH 5/9] FIX: remove icon --- app/resources/views/ventas/promotions/show.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/resources/views/ventas/promotions/show.blade.php b/app/resources/views/ventas/promotions/show.blade.php index 9d4eb4d..abd45d4 100644 --- a/app/resources/views/ventas/promotions/show.blade.php +++ b/app/resources/views/ventas/promotions/show.blade.php @@ -79,7 +79,7 @@ 'Todas las Unidades', ``, `', `` ].join("\n") From 1ca087e19b8587cf4469a53b294dd4873aa73e94 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 17 Oct 2025 18:01:49 -0300 Subject: [PATCH 6/9] FIX: Show global promotions correctly --- .../ventas/reservations/modal/add.blade.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/resources/views/ventas/reservations/modal/add.blade.php b/app/resources/views/ventas/reservations/modal/add.blade.php index 7896c27..1f0b9fc 100644 --- a/app/resources/views/ventas/reservations/modal/add.blade.php +++ b/app/resources/views/ventas/reservations/modal/add.blade.php @@ -188,7 +188,8 @@ elements: '' } data = { - promotions: [] + promotions: [], + selected: [] } components = { button: null, @@ -206,16 +207,16 @@ this.setup() } add() { - const idx = Math.max(this.data.promotions.length, 0, Math.max(...this.data.promotions) + 1) - this.data.promotions.push(idx) + const idx = Math.max(this.data.selected.length, 0, Math.max(...this.data.selected) + 1) + this.data.selected.push(idx) this.draw.promotions() } reset() { - this.data.promotions = [] + this.data.selected = [] this.draw.promotions() } remove(idx) { - this.data.promotions = this.data.promotions.filter(promotion => promotion !== idx) + this.data.selected = this.data.selected.filter(promotion => promotion !== idx) this.draw.promotions() } draw = { @@ -248,7 +249,10 @@ return } this.components.button.parentElement.style.display = this.display.button - this.components.promotions.innerHTML = this.data.promotions.map((promotion, idx) => { + if (this.data.selected.length === 0) { + return + } + this.components.promotions.innerHTML = this.data.selected.map(idx => { return this.draw.promotion(idx) }).join('') this.components.promotions.querySelectorAll('.dropdown').forEach(dropdown => { @@ -611,8 +615,8 @@ this.get.promotions(project_id).then(promotions => { this.components.promotions.data.promotions = promotions.map(promotion => { return { - text: promotion.name, - name: promotion.name, + text: promotion.description, + name: promotion.description, value: promotion.id } }) From 9794070925ee3af1db286072a9d27fba70f8304e Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 17 Oct 2025 19:25:12 -0300 Subject: [PATCH 7/9] FIX: Skip blank values --- app/src/Service/Persona.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/Service/Persona.php b/app/src/Service/Persona.php index 6773841..ba219ae 100644 --- a/app/src/Service/Persona.php +++ b/app/src/Service/Persona.php @@ -261,7 +261,7 @@ class Persona extends Ideal\Service 'birthdate' => 'fecha_nacimiento', ]; foreach ($data as $key => $value) { - if (array_key_exists($key, $dataMap)) { + if (array_key_exists($key, $dataMap) and trim($value) !== '') { $data[$dataMap[$key]] = $value; unset($data[$key]); } From b75c4b7efcf03a5a6c65755bf3be6d4ee0d88a86 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 17 Oct 2025 19:25:25 -0300 Subject: [PATCH 8/9] FIX: Format date --- app/src/Repository/Persona/Datos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/Repository/Persona/Datos.php b/app/src/Repository/Persona/Datos.php index 06cd4b7..baf35e8 100644 --- a/app/src/Repository/Persona/Datos.php +++ b/app/src/Repository/Persona/Datos.php @@ -63,7 +63,7 @@ class Datos extends Ideal\Repository 'persona_rut', 'direccion_id', 'telefono', 'email', 'fecha_nacimiento', 'sexo', 'estado_civil', 'nacionalidad', 'ocupacion' ], [ - $model->persona->rut, $model->direccion?->id, $model->telefono, $model->email, $model->fechaNacimiento, + $model->persona->rut, $model->direccion?->id, $model->telefono, $model->email, $model->fechaNacimiento->format('Y-m-d'), $model->sexo, $model->estadoCivil, $model->nacionalidad, $model->ocupacion ]); return $model; From e4100e7f2115234df3871c7f30cbc9be8134f90e Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 17 Oct 2025 19:25:54 -0300 Subject: [PATCH 9/9] Show table tooltips --- .../views/ventas/reservations.blade.php | 76 ++++++++++++------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/app/resources/views/ventas/reservations.blade.php b/app/resources/views/ventas/reservations.blade.php index 1677931..959eb06 100644 --- a/app/resources/views/ventas/reservations.blade.php +++ b/app/resources/views/ventas/reservations.blade.php @@ -304,26 +304,20 @@ valida: reservation => reservation.valid ? 'Si' : 'No', operador: reservation => reservation.broker?.name ?? '', }; - return this.reservations.map(reservation => { - //const date = new Date(Date.parse(reservation.date) + 24 * 60 * 60 * 1000) + const tooltipVariation = 'very wide multiline' + const tooltips = this.draw().tooltip() + return this.reservations.map(reservation => { const data = {} Object.entries(columnValues).forEach(([key, value]) => { - if (key in this.draw().tooltip()) { - data[key] = `data-content="${this.draw().tooltip()[key](reservation)}" data-variation="very wide">${value(reservation)}` + if (key in tooltips) { + const processor = tooltips[key] + const content = processor(reservation)//.replaceAll(' ', ' ') + data[key] = `data-html="${content}" data-variation="${tooltipVariation}">${value(reservation)}` return } data[key] = value(reservation) }) return data - /*return { - id: reservation.id, - unidades: reservation.summary, - cliente: `data-content="${this.draw().tooltip().buyer(reservation)}">${reservation.buyer.nombreCompleto}`, - fecha: this.formatters.date.format(date), - oferta: `data-content="${this.draw().tooltip().payment(reservation)}">${this.formatters.ufs.format(reservation.offer)} UF`, - valida: reservation.valid ? 'Si' : 'No', - operador: reservation.broker?.name ?? '', - }*/ }) } draw() { @@ -341,7 +335,7 @@ const id = column.id this.columnNames.forEach(name => { let td = `${column[name]}` - if (['oferta', 'cliente', 'valida'].includes(name)) { + if (column[name].includes('data-content') || column[name].includes('data-html')) { td = `` } contents.push(td) @@ -355,7 +349,7 @@ }) this.show() - $(this.component).find('[data-content]').popup() + $(this.component).find('[data-content],[data-html]').popup() this.watch() }, @@ -376,28 +370,40 @@ const formatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2}) const output = [] + const table = [''] reservation.units.forEach(unit => { const type = unit.unit.proyecto_tipo_unidad.tipo_unidad.descripcion - output.push(`${type.charAt(0).toUpperCase() + type.slice(1)} ${unit.unit.descripcion}: ${formatter.format(unit.value)} UF`) + table.push(``) }) if (reservation.broker !== null) { - output.push('-----') + table.push('') let commission = reservation.broker.commission - output.push(`Broker: ${reservation.broker.name} (${commission})`) + table.push(``) } if (reservation.promotions.length > 0) { - output.push('-----') + table.push('') reservation.promotions.forEach(promotion => { - output.push(`${promotion.name}: ${formatter.format(promotion.value)} UF`) + let value = 0 + switch (promotion.type) { + case {{ \Incoviba\Model\Venta\Promotion\Type::FIXED }}: + value = `${formatter.format(promotion.amount)} UF` + break; + case {{ \Incoviba\Model\Venta\Promotion\Type::VARIABLE }}: + value = `${formatter.format(promotion.amount * 100)} %` + break; + } + table.push(``) }) } - return output.join("\n") + table.push('
${type.charAt(0).toUpperCase() + type.slice(1)} ${unit.unit.descripcion}:${formatter.format(unit.value)} UF
-----
Broker:${reservation.broker.name}(${commission})
-----
${promotion.description}:${value}
') + output.push(table.join('')) + return output.join("
") }, cliente: reservation => { const formatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0}) return [ `RUT: ${formatter.format(reservation.buyer.rut)}-${reservation.buyer.digito}` - ].join("\n") + ].join("
") } } } @@ -518,27 +524,43 @@ const formatter = new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2}) const output = [] + const table = [ + '', + '', + '', + '', + '', + '', + '' + ] reservation.units.forEach(unit => { let type = unit.unit.proyecto_tipo_unidad.tipo_unidad.descripcion type = type.charAt(0).toUpperCase() + type.slice(1) const base = unit.base ?? (unit.value ?? 0); const price = unit.unit.current_precio?.valor ?? 0 const diff = (base - price) / price * 100 - output.push(`${type} ${unit.unit.descripcion}: ${formatter.format(base)} UF - ${formatter.format(price)} UF (${formatter.format(diff)} %)`) + table.push(``) }) + if (reservation.broker !== null) { + table.push('') + let commission = reservation.broker.commission + table.push(``) + } reservation.promotions.forEach(promotion => { let value = 0 switch (promotion.type) { case {{ \Incoviba\Model\Venta\Promotion\Type::FIXED }}: - value = `${formatter.format(promotion.value)} UF` + value = `${formatter.format(promotion.amount)} UF` break; case {{ \Incoviba\Model\Venta\Promotion\Type::VARIABLE }}: - value = `${formatter.format(promotion.value * 100)} %` + value = `${formatter.format(promotion.amount * 100)} %` break; } - output.push(`${promotion.description}: ${value}`) + table.push(``) }) - return output.join("\n") + table.push('
Base OfertaPrecio
${type} ${unit.unit.descripcion}: ${formatter.format(base)} UF${formatter.format(price)} UF(${formatter.format(diff)} %)
-----
Broker:${reservation.broker.name}(${commission})
${promotion.description}:${value}
') + output.push(table.join('')) + return output.join("
") } draw['tooltip'] = () => { return tooltip