Order totals for tipocuenta

This commit is contained in:
2022-01-07 01:12:54 -03:00
parent 5a9dc6602c
commit 84a3f8e2e3
4 changed files with 80 additions and 66 deletions

View File

@ -59,15 +59,12 @@ class Cuenta {
}
}
class Categoria {
constructor({id, nombre, tipo_id, tipo, activos, pasivos, ganancias, perdidas}) {
constructor({id, nombre, tipo_id, tipo, totales}) {
this.id = id
this.nombre = nombre
this.tipo_id = tipo_id
this.tipo = tipo
this.activos = activos
this.pasivos = pasivos
this.ganancias = ganancias
this.perdidas = perdidas
this.totales = totales
this.is_open = false
this.cuentas = []
}
@ -75,7 +72,7 @@ class Categoria {
this.tipos = tipos
}
draw({format}) {
const button = $('<button></button>').attr('class', 'ui mini compact icon button').append(
const button = $('<button></button>').attr('class', 'ui mini compact circular icon button').append(
$('<i></i>').attr('class', down_icon + ' icon')
).click((e) => {
const plus = button.find('.' + down_icon.replace(' ', '.') + '.icon')
@ -98,7 +95,7 @@ class Categoria {
)
$.each(this.tipos, (i, el) => {
tr.append(
$('<td></td>').attr('class', 'right aligned').html(format.format(this[el.descripcion.toLowerCase() + 's']))
$('<td></td>').attr('class', 'right aligned').html(format.format(this.totales[el.descripcion.toLowerCase() + 's']))
)
})
$("[data-id='" + this.tipo_id + "'][data-class='tipo_categoria']").after(tr)
@ -156,21 +153,18 @@ class Categoria {
}
}
class TipoCategoria {
constructor({id, descripcion, activo, activos, pasivos, ganancias, perdidas}) {
constructor({id, descripcion, activo, totales}) {
this.id = id
this.descripcion = descripcion
this.activo = activo
this.activos = activos
this.pasivos = pasivos
this.ganancias = ganancias
this.perdidas = perdidas
this.totales = totales
this.categorias = []
}
setTipos(tipos) {
this.tipos = tipos
}
draw({format}) {
const button = $('<button></button>').attr('class', 'ui mini compact icon button').append(
const button = $('<button></button>').attr('class', 'ui mini compact circular icon button').append(
$('<i></i>').attr('class', down_icon + ' icon')
).click((e) => {
const plus = button.find('.' + down_icon.replace(' ', '.') + '.icon')
@ -188,7 +182,7 @@ class TipoCategoria {
)
)
$.each(this.tipos, (i, el) => {
tr.append($('<td></td>').attr('class', 'right aligned').html(format.format(this[el.descripcion.toLowerCase() + 's'])))
tr.append($('<td></td>').attr('class', 'right aligned').html(format.format(this.totales[el.descripcion.toLowerCase() + 's'])))
})
return tr
}
@ -295,7 +289,7 @@ const cuentas = {
return
}
$.each(data.tipos, (i, el) => {
tipo = new TipoCategoria(el)
const tipo = new TipoCategoria(el)
tipo.setTipos(this.tipos)
this.tipos_categorias.push(tipo)
})