Resultado y fix cuentas
This commit is contained in:
@ -245,6 +245,29 @@ const cuentas = {
|
||||
table.append(parent)
|
||||
segment.append(table)
|
||||
return parent
|
||||
},
|
||||
resultado: (segment) => {
|
||||
segment.append(
|
||||
$('<table></table>').attr('class', 'ui collapsing table').append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html('Ganancias')
|
||||
).append(
|
||||
$('<td></td>').attr('data-tipo', 'ganancias')
|
||||
)
|
||||
).append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html('Perdidas')
|
||||
).append(
|
||||
$('<td></td>').attr('data-tipo', 'perdidas')
|
||||
)
|
||||
).append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html('Resultado')
|
||||
).append(
|
||||
$('<td></td>').attr('data-tipo', 'resultado')
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -285,6 +308,8 @@ const cuentas = {
|
||||
this.balance = data
|
||||
}).then(() => {
|
||||
this.draw().balance()
|
||||
}).then(() => {
|
||||
this.draw().resultado()
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -320,6 +345,17 @@ const cuentas = {
|
||||
)
|
||||
})
|
||||
foot.append(tr)
|
||||
},
|
||||
resultado: () => {
|
||||
const div = $('#resultado')
|
||||
if (div.find("[data-tipo='resultado']").length === 0) {
|
||||
div.html('')
|
||||
this.build().resultado(div)
|
||||
}
|
||||
const format = Intl.NumberFormat('es-CL', {style: 'currency', currency: 'CLP'})
|
||||
div.find("[data-tipo='ganancias']").html(format.format(this.balance['ganancias']))
|
||||
div.find("[data-tipo='perdidas']").html(format.format(this.balance['perdidas']))
|
||||
div.find("[data-tipo='resultado']").html(format.format(this.balance['ganancias'] - this.balance['perdidas']))
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user