v0.1.0
This commit is contained in:
@ -53,6 +53,60 @@
|
||||
})
|
||||
}
|
||||
}
|
||||
class Facturas {
|
||||
constructor(venta_id) {
|
||||
this.venta_id = venta_id
|
||||
this.facturas = []
|
||||
}
|
||||
get() {
|
||||
return $.ajax({
|
||||
url: '{{$urls->api}}/venta/' + this.venta_id + '/facturas',
|
||||
method: 'get',
|
||||
dataType: 'json'
|
||||
}).then((data) => {
|
||||
if (data.facturas === null || data.facturas.length == 0) {
|
||||
return
|
||||
}
|
||||
this.facturas = data.facturas
|
||||
this.draw()
|
||||
})
|
||||
}
|
||||
draw() {
|
||||
const parent = $('#' + this.venta_id)
|
||||
let tbody = parent.find('tbody')
|
||||
if (tbody.length == 0) {
|
||||
tbody = $('<tbody></tbody>')
|
||||
const table = $('<table></table>').attr('class', 'table').append(
|
||||
$('<thead></thead>').append(
|
||||
$('<tr></tr>').append(
|
||||
$('<th></th>').html('Factura')
|
||||
).append(
|
||||
$('<th></th>').html('Emisor')
|
||||
).append(
|
||||
$('<th></th>').html('Fecha')
|
||||
).append(
|
||||
$('<th></th>').html('Valor')
|
||||
)
|
||||
)
|
||||
).append(tbody)
|
||||
parent.append(table)
|
||||
}
|
||||
tbody.html('')
|
||||
$.each(this.facturas, (i, el) => {
|
||||
tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html(el.factura.factura)
|
||||
).append(
|
||||
$('<td></td>').html(el.factura.operador.descripcion)
|
||||
).append(
|
||||
$('<td></td>').html(el.factura.fecha.formateada)
|
||||
).append(
|
||||
$('<td></td>').html(el.valor.formateado)
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
const ventas = {
|
||||
id: '#ventas',
|
||||
data: [],
|
||||
@ -69,9 +123,9 @@
|
||||
this.draw()
|
||||
})
|
||||
},
|
||||
facturas: (unidad) => {
|
||||
facturas: (venta) => {
|
||||
return $.ajax({
|
||||
url: '{{$urls->api}}/unidad/' + unidad + '/facturas',
|
||||
url: '{{$urls->api}}/venta/' + venta + '/facturas',
|
||||
method: 'get',
|
||||
dataType: 'json'
|
||||
})
|
||||
@ -86,34 +140,26 @@
|
||||
).append(
|
||||
$('<td></td>').html(el.propietario.nombre_completo)
|
||||
).append(
|
||||
$('<td></td>').attr('class', 'text-right').html(el.valor)
|
||||
$('<td></td>').attr('class', 'text-right').html(el.valor.formateado)
|
||||
)
|
||||
if (el.operador) {
|
||||
row.append(
|
||||
$('<td></td>').html(el.operador.descripcion)
|
||||
).append(
|
||||
$('<td></td>').attr('class', 'text-right').html(el.comision.formateada)
|
||||
).append(
|
||||
$('<td></td>').attr('id', el.propiedad.unidades[0].id)
|
||||
)
|
||||
this.get().facturas(el.propiedad.unidades[0].id).then((data) => {
|
||||
const td = $('td#' + data.unidad.id)
|
||||
if (data.facturas === null || data.facturas.length == 0) {
|
||||
return
|
||||
}
|
||||
$.each(data.facturas, (k, it) => {
|
||||
console.debug(it)
|
||||
})
|
||||
})
|
||||
} else {
|
||||
row.append(
|
||||
$('<td></td>')
|
||||
).append(
|
||||
$('<td></td>')
|
||||
).append(
|
||||
$('<td></td>')
|
||||
)
|
||||
}
|
||||
row.append(
|
||||
$('<td></td>').attr('id', el.id)
|
||||
)
|
||||
this.data[i].facturas = new Facturas(el.id)
|
||||
this.data[i].facturas.get()
|
||||
parent.append(row)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user