From 088982c6d47896ecfd8378c9a259e2382c6bfdd5 Mon Sep 17 00:00:00 2001 From: tanshu Date: Thu, 18 Mar 2021 17:48:31 +0530 Subject: [PATCH] Printer import now assigns the cut code for TM-m30 Also, hard-coding of the cut string is removed. Now need to see how it will be handled in update printer --- barker/alembic/versions/34fe3d061c5f_finish_import.py | 8 +++++++- barker/barker/printing/bill.py | 2 +- barker/barker/printing/cashier_report.py | 2 +- barker/barker/printing/discount_report.py | 2 +- barker/barker/printing/kot.py | 2 +- barker/barker/printing/sale_report.py | 2 +- import.sh | 5 ++--- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/barker/alembic/versions/34fe3d061c5f_finish_import.py b/barker/alembic/versions/34fe3d061c5f_finish_import.py index e15c122..1f413a9 100644 --- a/barker/alembic/versions/34fe3d061c5f_finish_import.py +++ b/barker/alembic/versions/34fe3d061c5f_finish_import.py @@ -56,7 +56,12 @@ def update_section_printers(): column("printer_name", sa.Unicode(length=255)), ) section = table("sections", column("id", postgresql.UUID(as_uuid=True)), column("name", sa.Unicode(length=255))) - printer = table("printers", column("id", postgresql.UUID(as_uuid=True)), column("name", sa.Unicode(length=255))) + printer = table( + "printers", + column("id", postgresql.UUID(as_uuid=True)), + column("name", sa.Unicode(length=255)), + column("cut_code", sa.Unicode(length=255)), + ) op.execute( section_printer.update( values={"section_id": select([section.c.id]).where(section_printer.c.section_name == section.c.name)} @@ -67,6 +72,7 @@ def update_section_printers(): values={"printer_id": select([printer.c.id]).where(section_printer.c.printer_name == printer.c.name)} ) ) + op.execute(printer.update(values={"cut_code": "\x1dV\x41\x03"})) with op.batch_alter_table("section_printers") as batch_op: batch_op.alter_column("section_id", nullable=False) batch_op.drop_column("section_name") diff --git a/barker/barker/printing/bill.py b/barker/barker/printing/bill.py index d69ebf4..fc96a26 100644 --- a/barker/barker/printing/bill.py +++ b/barker/barker/printing/bill.py @@ -53,7 +53,7 @@ def print_bill(voucher_id: uuid.UUID, db: Session): redis: ArqRedis = asyncio.run(create_pool(redis_settings)) asyncio.run( redis.enqueue_job( - "sent_to_printer", data, printer.address, "\x1dV\x41\x03", _queue_name=f"barker:print:{printer.name}" + "sent_to_printer", data, printer.address, printer.cut_code, _queue_name=f"barker:print:{printer.name}" ) ) diff --git a/barker/barker/printing/cashier_report.py b/barker/barker/printing/cashier_report.py index 85feec6..e4dc257 100644 --- a/barker/barker/printing/cashier_report.py +++ b/barker/barker/printing/cashier_report.py @@ -30,7 +30,7 @@ def print_cashier_report(report: CashierReport, device_id: uuid.UUID, db: Sessio redis: ArqRedis = asyncio.run(create_pool(redis_settings)) asyncio.run( redis.enqueue_job( - "sent_to_printer", data, printer.address, "\x1dV\x41\x03", _queue_name=f"barker:print:{printer.name}" + "sent_to_printer", data, printer.address, printer.cut_code, _queue_name=f"barker:print:{printer.name}" ) ) diff --git a/barker/barker/printing/discount_report.py b/barker/barker/printing/discount_report.py index 826acf2..8b8f447 100644 --- a/barker/barker/printing/discount_report.py +++ b/barker/barker/printing/discount_report.py @@ -28,7 +28,7 @@ def print_discount_report(report: DiscountReport, device_id: uuid.UUID, db: Sess redis: ArqRedis = asyncio.run(create_pool(redis_settings)) asyncio.run( redis.enqueue_job( - "sent_to_printer", data, printer.address, "\x1dV\x41\x03", _queue_name=f"barker:print:{printer.name}" + "sent_to_printer", data, printer.address, printer.cut_code, _queue_name=f"barker:print:{printer.name}" ) ) diff --git a/barker/barker/printing/kot.py b/barker/barker/printing/kot.py index bc3e672..1748b9d 100644 --- a/barker/barker/printing/kot.py +++ b/barker/barker/printing/kot.py @@ -118,7 +118,7 @@ def print_kot(voucher_id: uuid.UUID, db: Session): "sent_to_printer", data, printer.address, - "\x1dV\x41\x03", + printer.cut_code, _queue_name=f"barker:print:{printer.name}", ) ) diff --git a/barker/barker/printing/sale_report.py b/barker/barker/printing/sale_report.py index 27485ea..58739e6 100644 --- a/barker/barker/printing/sale_report.py +++ b/barker/barker/printing/sale_report.py @@ -30,7 +30,7 @@ def print_sale_report(report: SaleReport, device_id: uuid.UUID, db: Session): redis: ArqRedis = asyncio.run(create_pool(redis_settings)) asyncio.run( redis.enqueue_job( - "sent_to_printer", data, printer.address, "\x1dV\x41\x03", _queue_name=f"barker:print:{printer.name}" + "sent_to_printer", data, printer.address, printer.cut_code, _queue_name=f"barker:print:{printer.name}" ) ) diff --git a/import.sh b/import.sh index 7df9975..bbc53b0 100755 --- a/import.sh +++ b/import.sh @@ -27,7 +27,6 @@ else tar xvf "$parent_path"/csv/csv.tar.zip -C "$parent_path"/csv || exit fi - if [ $docker -eq 1 ] then docker stop "$doname" || exit @@ -92,8 +91,8 @@ else alembic upgrade 48bc1c7c07ce || exit fi -#rm "$parent_path"/csv/*.csv "$parent_path"/csv/csv.tar.zip || exit -#rmdir "$parent_path"/csv || exit +rm -f "$parent_path"/csv/*.csv "$parent_path"/csv/csv.tar.zip || exit +rmdir "$parent_path"/csv || exit # Show the file in code to see the hidden chars