Ticket gondola
This commit is contained in:
71
index.js
71
index.js
@@ -35,6 +35,26 @@ function center() { return ESC + "a" + "\x01"; }
|
|||||||
function centerOff() { return ESC + "a" + "\x00"; }
|
function centerOff() { return ESC + "a" + "\x00"; }
|
||||||
function left() { return ESC + "a" + "\x00"; }
|
function left() { return ESC + "a" + "\x00"; }
|
||||||
function right() { return ESC + "a" + "\x02"; }
|
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 textFifthSize() {
|
||||||
|
return "\x1D\x21\x44"; // GS ! 34 → triple (si la impresora lo soporta)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
app.use(cors())
|
app.use(cors())
|
||||||
@@ -53,6 +73,13 @@ app.post('/digitalpowerstock/ticket/venta', (req, res) => {
|
|||||||
res.send(200)
|
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) => {
|
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;
|
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)
|
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)
|
||||||
@@ -297,6 +324,50 @@ async function ticketDPSTock(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function ticketDPSTockGondola(
|
||||||
|
nombre, top_price, off, bottom_price
|
||||||
|
) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
//const products = productos;
|
||||||
|
let ticket = "";
|
||||||
|
|
||||||
|
// Encabezado
|
||||||
|
ticket += init();
|
||||||
|
ticket += left();
|
||||||
|
ticket += textDoubleWidth() + nombre + textNormal() + line(1);
|
||||||
|
ticket += textFifthSize() + 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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(
|
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
|
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
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user