Compare commits

...
5 Commits
Author SHA1 Message Date
LMartz 32bd5669fb Credito 2026-05-21 19:35:22 -03:00
martin ed58da67ef ticket con los datos del cliente 2026-03-16 23:50:08 -03:00
martin 63e3883984 Nueva funcion de impresion de pedidos 2026-03-13 21:48:10 -03:00
LMartz d26992a2fc Merge branch 'main' of https://gitea.digitalpower.ar/LMartz/servicio_impresoras_ticket 2025-12-16 12:12:37 -03:00
LMartz 180ded5dba Adelanto 2025-12-16 12:12:25 -03:00
2 changed files with 134 additions and 3 deletions
+8
View File
@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+126 -3
View File
@@ -71,9 +71,16 @@ app.get('/printers', (req, res) => {
})
app.post('/digitalpowerstock/ticket/venta', (req, res) => {
const { nombre, direccion, cp, localidad, provincia, pais, telefono, mensaje, comprobante, cliente, fecha, vendedor, productos, total } = req.body;
const { nombre, direccion, cp, localidad, provincia, pais, telefono, mensaje, comprobante, cliente, fecha, vendedor, productos, total, adelanto } = req.body;
ticketDPSTock(nombre, direccion, cp, localidad, provincia, pais, telefono, mensaje, comprobante, cliente, fecha, vendedor, productos, total)
ticketDPSTock(nombre, direccion, cp, localidad, provincia, pais, telefono, mensaje, comprobante, cliente, fecha, vendedor, productos, total, adelanto)
res.send(200)
})
app.post('/digitalpowerstock/ticket/credito', (req, res) => {
const { monto, cliente, fecha } = req.body;
ticketCredito(monto, cliente, fecha)
res.send(200)
})
@@ -84,6 +91,13 @@ app.post('/digitalpowerstock/ticket/gondola', (req, res) => {
res.send(200)
})
app.post('/digitalpowerstock/ticket/pedido', (req, res) => {
const { cliente, direccion, altura, ciudad, cp, telefono, email, comprobante, fecha, productos, total, estado, tipo_envio, tipo_pago, calles } = req.body;
ticketPedido(cliente, direccion, altura, ciudad, cp, telefono, email, comprobante, fecha, productos, total, estado, tipo_envio, tipo_pago, calles)
res.send(200)
})
app.post('/facturador/ticket/a', (req, res) => {
const { comercio, comercio_cuit, inicio_actividades, condicion_iva_comercio, punto_venta, cae, vencimiento_cae, iva_contenido, cliente_cuit, cliente_condicion, cliente_direccion, nombre, direccion, localidad, provincia, comprobante, cliente, fecha, qr_link, productos, total, subtotal } = req.body;
ticketFacturadorA(comercio, comercio_cuit, inicio_actividades, condicion_iva_comercio, punto_venta, cae, vencimiento_cae, iva_contenido, cliente_cuit, cliente_condicion, cliente_direccion, nombre, direccion, localidad, provincia, comprobante, cliente, fecha, qr_link, productos, total, subtotal)
@@ -273,7 +287,7 @@ function printBetween(leftText, rightText, lineWidth = 46) {
async function ticketDPSTock(
nombre, direccion, cp, localidad, provincia, pais,
telefono, mensaje, comprobante, cliente, fecha,
vendedor, productos, total
vendedor, productos, total, adelanto
) {
try {
@@ -306,6 +320,9 @@ async function ticketDPSTock(
//ticket += left() + `Total: $${total}` + line(3);
ticket += boldOn();
ticket += printBetween("Total: ", `$${total}`) + line(3);
if (adelanto) {
ticket += printBetween("Abonado: ", `$${adelanto}`) + line(3);
}
ticket += boldOff();
// Corte
@@ -373,6 +390,112 @@ async function ticketDPSTockGondola(
}
}
async function ticketCredito(monto, cliente, fecha) {
try {
let ticket = "";
// Encabezado
ticket += init();
ticket += center();
ticket += textDoubleSize() + boldOn() + "NOTA DE CREDITO" + boldOff() + textNormal() + line(2);
ticket += left();
ticket += "Cliente: " + cliente + line();
ticket += "Fecha: " + fecha + line(2);
ticket += printDoubleLine();
ticket += boldOn();
const formattedMonto = !isNaN(Number(monto)) ? Number(monto).toFixed(2) : monto;
ticket += printBetween("Monto a favor: ", `$${formattedMonto}`) + line(3);
ticket += boldOff();
// Corte
ticket += cut();
// Convertir a CP850 (acentos correctos)
const data = iconv.encode(ticket, "CP850");
// Enviar a la impresora
printer.printDirect({
data,
printer: printer.getDefaultPrinterName(),
type: "RAW",
success: jobID => console.log("Trabajo enviado:", jobID),
error: err => console.error("Error:", err)
});
} catch (error) {
console.error("Error al imprimir:", error);
}
}
async function ticketPedido(
cliente, direccion, altura, ciudad, cp, telefono, email, comprobante, fecha, productos, total, estado, tipo_envio, tipo_pago, calles
) {
try {
let ticket = "";
// Encabezado
ticket += init();
ticket += center();
ticket += textDoubleSize() + boldOn() + "NUEVO PEDIDO" + boldOff() + textNormal() + line(2);
ticket += left();
ticket += "Comprobante: #" + comprobante + line();
ticket += "Fecha: " + fecha + line();
ticket += "Estado: " + estado + line();
ticket += printDoubleLine();
ticket += boldOn() + "DATOS DEL CLIENTE" + boldOff() + line();
ticket += "Cliente: " + cliente + line();
ticket += "Telefono: " + telefono + line();
ticket += "Email: " + (email || "-") + line();
ticket += printDoubleLine();
ticket += boldOn() + "DATOS DE ENVIO" + boldOff() + line();
ticket += "Tipo: " + tipo_envio + line();
ticket += "Direccion: " + direccion + " " + altura + line();
ticket += "Calles: " + (calles || "-") + line();
ticket += "Ciudad: " + ciudad + " (" + cp + ")" + line();
ticket += printDoubleLine();
ticket += boldOn() + "DATOS DE PAGO" + boldOff() + line();
ticket += "Metodo de pago: " + tipo_pago + line();
ticket += printDoubleLine();
//ticket += printProducts(JSON.parse(productos));
//ticket += line();
// Total
//ticket += boldOn();
//ticket += textDoubleHeight() + printBetween("Total: ", `$${total}`) + textNormal() + line(3);
//ticket += boldOff();
// Corte
ticket += cut();
// Convertir a CP850 (acentos correctos)
const data = iconv.encode(ticket, "CP850");
// Enviar a la impresora
printer.printDirect({
data,
printer: printer.getDefaultPrinterName(),
type: "RAW",
success: jobID => console.log("Trabajo enviado:", jobID),
error: err => console.error("Error:", err)
});
} catch (error) {
console.error("Error al imprimir:", error);
}
}
async function ticketFacturadorA(
comercio, comercio_cuit, inicio_actividades, condicion_iva_comercio, punto_venta, cae, vencimiento_cae, iva_contenido, cliente_cuit, cliente_condicion, cliente_direccion, nombre, direccion, localidad, provincia, comprobante, cliente, fecha, qr_link, productos, total, subtotal
) {