From 54d205eebe8ff0be59185b27fda0ae68ba5e6904 Mon Sep 17 00:00:00 2001 From: tanshu Date: Mon, 5 Apr 2021 08:20:45 +0530 Subject: [PATCH] Fix: Printer edit shows the proper hex values in printer edit and import the right hex value from old database --- DB/migrate.cmd | 2 +- barker/barker/routers/printer.py | 10 +++++++--- frank/printing.py | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/DB/migrate.cmd b/DB/migrate.cmd index bbd22be..f6a86a5 100644 --- a/DB/migrate.cmd +++ b/DB/migrate.cmd @@ -12,7 +12,7 @@ call:copyQuery j-SaleCategories "SELECT newid(), pgo.GroupType, 1, CAST((select call:copyQuery k-Products "SELECT ProductID, Name, COALESCE(Units, '\N'), ProductGroupID, (SELECT GroupType FROM Test.dbo.ProductGroups pgs WHERE pgs.ProductGroupID = Products.ProductGroupID), Price, CASE WHEN HasHappyHour = 1 THEN 't' ELSE 'f' END , CASE WHEN IsActive = 1 THEN 't' ELSE 'f' END, CASE WHEN IsNotAvailable = 1 THEN 't' ELSE 'f' END, SortOrder, Quantity FROM Test.dbo.Products;" call:copyQuery l-Modifiers "SELECT ModifierID, Name, CASE WHEN ShowInBill = 1 THEN 't' ELSE 'f' END, 't', 'e046ad33-dc65-4c78-8833-c3d3538d44c0', Price FROM Test.dbo.Modifiers;" call:copyQuery m-Sections "SELECT NewID(), Location, 'f' FROM Test.dbo.PrintLocations GROUP BY Location;" -call:copyQuery n-Printers "SELECT NewID(), Printer, Printer, 0x1d764103 FROM Test.dbo.PrintLocations GROUP BY Printer, CutCode;" +call:copyQuery n-Printers "SELECT NewID(), Printer, Printer, 0x1d564103 FROM Test.dbo.PrintLocations GROUP BY Printer, CutCode;" call:copyQuery o-SectionPrinters "SELECT PrintLocationID, COALESCE(CAST(ProductGroupID AS Nvarchar(36)), '\N'), Location, Printer, Copies FROM Test.dbo.PrintLocations;" call:copyQuery p-Vouchers "SELECT VoucherID, Date, Pax, UserID, CreationDate, LastEditDate, COALESCE(CAST(BillID AS Nvarchar(36)), '\N'), TableID, CustomerID, COALESCE(Narration, '\N'), VoidReason, CASE WHEN Printed = 0 THEN '0' WHEN Void = 1 THEN '5' ELSE VoucherType END, KotID FROM Test.dbo.Vouchers;" call:copyQuery q-Kots "SELECT KotID, VoucherID, Code, TableID, Date, UserID FROM Test.dbo.Kots;" diff --git a/barker/barker/routers/printer.py b/barker/barker/routers/printer.py index e17ad55..5b4a90b 100644 --- a/barker/barker/routers/printer.py +++ b/barker/barker/routers/printer.py @@ -33,7 +33,11 @@ def save( user: UserToken = Security(get_user, scopes=["printers"]), ) -> schemas.Printer: try: - item = Printer(name=data.name, address=data.address, cut_code=bytearray.fromhex(data.cut_code).decode()) + item = Printer( + name=data.name, + address=data.address, + cut_code=bytes.fromhex(data.cut_code).decode(), + ) db.add(item) db.commit() return printer_info(item) @@ -123,9 +127,9 @@ def printer_info(item: Printer) -> schemas.Printer: id=item.id, name=item.name, address=item.address, - cutCode=item.cut_code, + cutCode=bytes(item.cut_code, "ascii").hex(), ) def printer_blank() -> schemas.PrinterBlank: - return schemas.PrinterBlank(name="", address="", cutCode="") + return schemas.PrinterBlank(name="", address="", cutCode="1d564103") diff --git a/frank/printing.py b/frank/printing.py index 796313b..82aba9e 100644 --- a/frank/printing.py +++ b/frank/printing.py @@ -28,7 +28,7 @@ async def sent_to_printer(ctx: dict, data: str, address: str, cut_code: str): raise Retry(defer=ctx["job_try"] * 30) # GS = "\x1d" - # PAPER_CUT = GS + "V" + # PAPER_CUT = GS + "\x56" # # For the printer ESC/POS Reference # # https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=87 # # The m codes are in decimal and can be converted using the following table