diff --git a/app/resources/views/ventas/list.blade.php b/app/resources/views/ventas/list.blade.php
index bf6bfa0..dbdcd32 100644
--- a/app/resources/views/ventas/list.blade.php
+++ b/app/resources/views/ventas/list.blade.php
@@ -52,8 +52,12 @@
draw(formatter, dateFormatter) {
const tipo = this.estado.tipo_estado_venta.descripcion
const date = new Date(this.fecha)
+ let unidad = this.propiedad.unidades[0]
+ if (this.propiedad.departamentos.length > 0) {
+ unidad = this.propiedad.departamentos[0]
+ }
return $('
').append(
- $(' | ').attr('data-order', this.propiedad.departamentos[0].descripcion).append(
+ $(' | ').attr('data-order', unidad.descripcion).append(
$('').attr('href', '{{$urls->base}}/venta/' + this.id).html(this.propiedad.summary)
)
).append(
@@ -63,9 +67,9 @@
).append(
$(' | ').html(formatter.format(this.valor) + ' UF')
).append(
- $(' | ').html(this.propiedad.departamentos[0].proyecto_tipo_unidad.abreviacion + ' (' + formatter.format(this.propiedad.departamentos[0].proyecto_tipo_unidad.vendible) + ' m²)')
+ $(' | ').html(unidad.proyecto_tipo_unidad.abreviacion + ' (' + formatter.format(unidad.proyecto_tipo_unidad.vendible) + ' m²)')
).append(
- $(' | ').html(formatter.format(this.valor / this.propiedad.departamentos[0].proyecto_tipo_unidad.vendible) + ' UF/m²')
+ $(' | ').html(formatter.format(this.valor / unidad.proyecto_tipo_unidad.vendible) + ' UF/m²')
).append(
$(' | ').attr('data-order', this.fecha).html(dateFormatter.format(date))
).append(
@@ -237,7 +241,12 @@
const tbody = $('')
this.data.ventas.forEach(venta => {
- tbody.append(venta.draw(this.formatters.number, this.formatters.date))
+ try {
+ tbody.append(venta.draw(this.formatters.number, this.formatters.date))
+ } catch (error) {
+ console.debug(venta)
+ console.error(error)
+ }
})
table.append(this.draw().header()).append(tbody)
table.show()