Merge branch 'main' of https://gitea.digitalpower.ar/LMartz/servicio_impresoras_ticket
This commit is contained in:
76
index.js
76
index.js
@@ -35,6 +35,30 @@ function center() { return ESC + "a" + "\x01"; }
|
||||
function centerOff() { return ESC + "a" + "\x00"; }
|
||||
function left() { return ESC + "a" + "\x00"; }
|
||||
function right() { return ESC + "a" + "\x02"; }
|
||||
function textNormal() {
|
||||
return "\x1D\x21\x00"; // GS ! n → normal
|
||||
}
|
||||
function textDoubleHeight() {
|
||||
return "\x1D\x21\x10"; // GS ! 16 → doble alto
|
||||
}
|
||||
function textDoubleWidth() {
|
||||
return "\x1D\x21\x01"; // GS ! 1 → doble ancho
|
||||
}
|
||||
function textDoubleSize() {
|
||||
return "\x1D\x21\x11"; // GS ! 17 → doble ancho y alto
|
||||
}
|
||||
function textTripleSize() {
|
||||
return "\x1D\x21\x22"; // GS ! 34 → triple (si la impresora lo soporta)
|
||||
}
|
||||
|
||||
function textQuadSize() {
|
||||
return "\x1D\x21\x33"; // GS ! 34 → triple (si la impresora lo soporta)
|
||||
}
|
||||
|
||||
function textFifthSize() {
|
||||
return "\x1D\x21\x44"; // GS ! 34 → triple (si la impresora lo soporta)
|
||||
}
|
||||
|
||||
|
||||
const app = express()
|
||||
app.use(cors())
|
||||
@@ -53,6 +77,13 @@ app.post('/digitalpowerstock/ticket/venta', (req, res) => {
|
||||
res.send(200)
|
||||
})
|
||||
|
||||
app.post('/digitalpowerstock/ticket/gondola', (req, res) => {
|
||||
const { nombre, top_price, off, bottom_price } = req.body;
|
||||
|
||||
ticketDPSTockGondola(nombre, top_price, off, bottom_price)
|
||||
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)
|
||||
@@ -300,6 +331,51 @@ async function ticketDPSTock(
|
||||
}
|
||||
}
|
||||
|
||||
async function ticketDPSTockGondola(
|
||||
nombre, top_price, off, bottom_price
|
||||
) {
|
||||
|
||||
try {
|
||||
//const products = productos;
|
||||
let ticket = "";
|
||||
|
||||
// Encabezado
|
||||
ticket += init();
|
||||
ticket += left();
|
||||
ticket += textDoubleSize() + nombre + textNormal() + line(1);
|
||||
ticket += textQuadSize() + boldOn() + "$" + top_price + textNormal() + line();
|
||||
ticket += textTripleSize() + "x unidad" + textNormal() + boldOff() + line();
|
||||
|
||||
if (off) {
|
||||
ticket += textDoubleSize() + off + "% OFF" + line();
|
||||
}
|
||||
|
||||
if (bottom_price && !off) {
|
||||
ticket += textDoubleSize() + "$" + bottom_price + line();
|
||||
}
|
||||
|
||||
|
||||
ticket += line(2);
|
||||
// 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
|
||||
) {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user