añadida tabla de credito al presupuesto

This commit is contained in:
2025-03-29 11:31:03 +01:00
parent 8d289fde15
commit d1a9aaac77
10 changed files with 250 additions and 20 deletions

View File

@ -22,8 +22,12 @@
<tbody></tbody>
<tfoot>
<tr>
<td colspan="6" style="text-align:right">Total:</td>
<td id="totalCobrado-sum"></td>
<td colspan="6" style="text-align:right">Total cobrado:</td>
<td><span id="totalCobrado-sum" class="autonumeric"></span></td>
</tr>
<tr>
<td colspan="6" style="text-align:right">Total pendiente:</td>
<td><span id="pendienteCobro-sum" class="autonumeric"></span></td>
</tr>
</tfoot>
</table>
@ -225,21 +229,38 @@ var tablePagos = $('#tableOfLineasPagos').DataTable({
footerCallback: function (row, data, start, end, display) {
var api = this.api();
// Remove the formatting to get integer data for summation
var intVal = function (i) {
// Convertir a número o devolver 0 si no es válido
return typeof i === 'string' ? i.replace(/[\$,]/g, '')*1 : typeof i === 'number' ? i : 0;
};
// Total over all pages
var totalPagos = api
.column(6)
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
var filas = [];
api.rows().every(function() {
var data = this.data();
if (data['fecha_pago_at'] !== undefined && data['fecha_pago_at'] !== null && data['fecha_pago_at'] !== '') {
filas.push(data); // Agregar la fila a la variable
}
});
var totalPagos = filas
.reduce(function(a, data) {
return a + intVal(data['total']); // Aquí asumimos que la columna 6 está en el índice 5
}, 0);
var filas = [];
api.rows().every(function() {
var data = this.data();
if (data['fecha_pago_at'] === undefined || data['fecha_pago_at'] === null || data['fecha_pago_at'] === '') {
filas.push(data); // Agregar la fila a la variable
}
});
var totalPendiente = filas
.reduce(function(a, data) {
return a + intVal(data['total']); // Aquí asumimos que la columna 6 está en el índice 5
}, 0);
// Update footer
$('#totalCobrado-sum').html(totalPagos.toFixed(2));
$('#pendienteCobro-sum').html(totalPendiente.toFixed(2));
// call footerCallback of the other table
if (typeof tableLineas !== 'undefined') {