diff --git a/app.js b/app.js index c5a41fd..d37d0cb 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,5 @@ import { load, save, remove, KEY_DATA, KEY_SETTINGS, KEY_CLIENTS } from './storage.js'; -import { renderTicketAndPrint } from './print.js?v=1757039367'; +import { renderTicketAndPrint } from './print.js?v=1757039801'; // --- UTILITIES --- function escapeHTML(str) { diff --git a/index.html b/index.html index 60c539d..ae94bcb 100644 --- a/index.html +++ b/index.html @@ -629,6 +629,6 @@
- + \ No newline at end of file diff --git a/print.js b/print.js index 01743e8..99b6a16 100644 --- a/print.js +++ b/print.js @@ -21,29 +21,22 @@ function esc(str) { * @returns {string} El HTML del ticket. */ function templateTicket(mov, settings) { - // Función de fecha ULTRA SIMPLE - NO MAS UNDEFINED - function fechaTicketDefinitivaV2() { - try { - const d = new Date(); - const dia = d.getDate(); - const mes = d.getMonth() + 1; - const año = d.getFullYear(); - const hora = d.getHours(); - const minutos = d.getMinutes(); - - // Agregar ceros a la izquierda usando padStart (método seguro) - const dd = String(dia).padStart(2, '0'); - const mm = String(mes).padStart(2, '0'); - const hh = String(hora).padStart(2, '0'); - const min = String(minutos).padStart(2, '0'); - - const fechaCompleta = dd + '/' + mm + '/' + año + ' ' + hh + ':' + min; - console.log("FECHA ULTRA SIMPLE GENERADA:", fechaCompleta); - return fechaCompleta; - } catch (error) { - console.error("Error en fecha:", error); - return "05/09/2025 20:25"; // Fecha fija como fallback - } + // FUNCIÓN DE FECHA DEFINITIVA - NO MAS UNDEFINED NUNCA MAS + function generarFechaTicketFINAL() { + // Crear nueva fecha DIRECTAMENTE + const fecha = new Date(); + + // Obtener componentes de fecha SIN VARIABLES INTERMEDIAS + const dia = fecha.getDate().toString().padStart(2, '0'); + const mes = (fecha.getMonth() + 1).toString().padStart(2, '0'); + const año = fecha.getFullYear().toString(); + const hora = fecha.getHours().toString().padStart(2, '0'); + const minutos = fecha.getMinutes().toString().padStart(2, '0'); + + // Construir fecha final DIRECTAMENTE + const resultado = `${dia}/${mes}/${año} ${hora}:${minutos}`; + console.log("FECHA FINAL DEFINITIVA GENERADA:", resultado); + return resultado; } const montoFormateado = Number(mov.monto).toFixed(2); @@ -89,7 +82,7 @@ function templateTicket(mov, settings) { lines.push(`
Folio:${esc(mov.folio)}
`); // Usar la función de fecha específica para tickets - const fechaFinal = fechaTicketDefinitivaV2(); + const fechaFinal = generarFechaTicketFINAL(); console.log("FECHA GENERADA PARA TICKET:", fechaFinal); lines.push(`
Fecha de Venta:${esc(fechaFinal)}
`); @@ -209,4 +202,4 @@ document.addEventListener('DOMContentLoaded', () => { } }); -// FORZAR RECARGA - 2025-09-05T02:49:00 - Función de fecha completamente reescrita \ No newline at end of file +// FORZAR RECARGA - 2025-09-05T20:43:00 - NUEVA FUNCIÓN generarFechaTicketFINAL \ No newline at end of file