def printKOT(orders, kid): epson = File("/dev/usb/lp0") epson.text('\n\n\n\n') epson.set(text_type='B', width=2, height=2) table = orders[0].table epson.text('' + table.name + ' KID:' + str(kid) + '\n') epson.set(text_type='normal', width=1, height=2) for order in orders: name = order.item.name quantity = order.quantity message = str(order.message) epson.text(' ' + name) epson.set(text_type='U', width=1, height=2) epson.text(' ' + message) epson.set(text_type='normal', width=1, height=2) epson.text(' x' + str(quantity) + '\n') epson.cut() epson.close()
def main(total_price, datetime): try: printer = File(devfile='/dev/usb/lp0') printer.profile.media['width']['pixels'] = 575 printer.image("images/logo-text-small.png", center=True) # printer.image("images/logo-text-small.png") printer.set(align=u'center') printer.text("\n") # printer.text('Your ID: ' + str(user_id) + "\n") printer.text(total_price + " Toman" + "\n") # printer.qr(total_price, size=12, center=True) # printer.text('Support: ' + owner_mobile_number + "\n") # printer.text('ID: ' + str(owner_id) + "\n") printer.text("farazist.ir" + "\n") printer.text(datetime) printer.cut() print("print receipt") except Exception as e: print("error:", e)
def printAJsBill(bill, table): item_quantitys = bill.getBillSummary() bid = str(bill.bid) time = str(datetime.now()) table = table.name.upper() total = str(bill.amount) epson = File("/dev/usb/lp0") Printer.printAJsAddress(bid=bid, table=table, time=time, epson=epson) # epson.text('01234567890123456789012345678901\n') epson.text('--------------------------------\n') epson.set(align='left', text_type='B', width=1, height=1) epson.text('Item Qt Rate Amt\n') epson.set(align='left', text_type='normal', width=1, height=1) epson.text('--------------------------------\n') sub_total = 0 for iq in item_quantitys: name = str(iq.get('item').cat) cost = str(iq.get('item').cost) quantity = str(iq.get('quantity')) amount = str(iq.get('quantity') * iq.get('item').cost) if len(name) > 16: epson.text(txt=name[0:16]) epson.text(' ') Printer.printQuantityCostAndAmount(epson=epson,\ name=name, cost=cost, quantity=quantity, amount=amount) epson.text(txt=name[16:len(name)]) epson.text(txt='\n') else: epson.text(txt=name) for i in range(16 - len(name)): epson.text(' ') epson.text(' ') Printer.printQuantityCostAndAmount(epson=epson,\ name=name, cost=cost, quantity=quantity, amount=amount) epson.set(align='left', text_type='B', width=1, height=1) epson.text('--------------------------------\n') epson.text('TOTAL Rs ' + total + '\n') epson.text('\n') epson.set(align='left', text_type='normal') epson.text('COMPOSITION TAXABLE PERSON\n') epson.text('GSTIN: 30AFGPG9096R1ZT\n') epson.set(align='left', text_type='B') epson.text(' FREE HOME DELIVERY \n') epson.text('\n') epson.cut()
def printReceipt(self): p = File("/dev/usb/lp0", auto_flush=False) # Header Receipt p.set(align='center', text_type='B') p.text("Kantin Wisuda Oktober\n") p.text("Institut Teknologi Bandung\n") p.text(self.orderTime + "\n") # p.text("Rabu,13/02/2019,15:30\n") # printTableNumber(orderList[0]['tableNumber']) p.text("Nomor Meja: " + str(self.orderList[0]['tableNumber'])) p.text("\n") p.text("Order ID: " + str(self.orderID)) p.text("\n\n\n") # Print Receipt List p.set(align='left') p.text('\x1b\x44\x00') # reset tabulation p.text('\x1b\x44\x10\x19\x00') # tabulation setting location for item in self.orderList: subTotal = item['price'] * item['qty'] p.text(str(item['menuName']) + "\n") p.text( str(item['price']) + "\x09" + "x" + str(item['qty']) + "\x09" + str(subTotal) + "\n") p.text("--------------------------------\n\n") p.text("Total Belanja " + "\t" + "\t" + str(self.totalPrice)) p.text("\n") p.set(align='center') p.text("Card ID: {}".format(self.cardID)) p.text("\n") p.text("Saldo Akhir: {}".format(formatRupiah(self.balance))) p.text("\n\n") p.set(align='center') p.text("-TERIMAKASIH-") p.cut() p.flush()
def write_order(order, usb_printer=None, print_item_code=True): if usb_printer: p = usb_printer else: p = File("/dev/usb/lp0") lines = loads(order.lines) # Order p.text('Order Id: {0}\n'.format(order.id)) # Table Number p.text('Table Number: {0}\n'.format(order.table_no)) # Take Away if order.is_takeaway: p.text('Type: TAKE AWAY\n\n') else: p.text('Type: DINE IN\n\n') # Headers header_line = line_block([ {'text': 'Qty', 'align': '<', 'width': QTY_WIDTH}, {'text': 'Item', 'align': '<', 'width': ITEM_WIDTH}, ]) p.text(header_line) # Lines for line in lines: line_text = line_block([ {'text': line['qty'], 'align': '<', 'width': QTY_WIDTH}, {'text': line['itemName'], 'align': '<', 'width': ITEM_WIDTH}, ]) p.text(line_text) if print_item_code: item_code = line_block([ {'text': '-', 'align': '<', 'width': QTY_WIDTH}, {'text': line['itemCode'], 'align': '<', 'width': ITEM_WIDTH} ]) p.text(item_code) # Remarks p.text('\nRemarks:\n{0}'.format(order.remarks)) # Time p.text('\n\nPrinted on:\n') p.text(time.ctime()) p.cut()
from escpos.printer import File printer = File(devfile='/dev/usb/lp0') printer.text("سبسلبلبلل\n") printer.text("some text\n") printer.text("some text\n") printer.text("سبلبلباال\n") # printer.set(codepage='pc864') printer.profile.media['width']['pixels'] = 575 printer.image("images/logo-text-small.png", center=True) # printer.image("images/logo-text-small.png") # printer.set(align=u'center') printer.text("Far" + "\n\n") # printer.text(total_price + " Toman" + "\n") printer.qr('total_price', size=8, center=True) # printer.qr(str(self.total_price), size=8) # printer.text(mobile_number + "\n") printer.text("farazist.ir" + "\n") # printer.text(datetime) printer.cut()
def write_order(order, usb_printer=None, print_item_code=True): if usb_printer: p = usb_printer else: p = File("/dev/usb/lp0") print("ORDER ITEMS") lines = [] for i in order.items: lines.append(i.__dict__) # Order p.text('Order Id: {0}\n'.format(order.id)) # Table Number p.text('Table Number: {0}\n'.format(order.table_no)) # Take Away p.text('Type: {0}\n\n'.format(order.type)) # Headers header_line = line_block([ { 'text': 'Qty', 'align': '<', 'width': QTY_WIDTH }, { 'text': 'Item', 'align': '<', 'width': ITEM_WIDTH }, ]) p.text(header_line) # Lines for line in lines: line_text = line_block([ { 'text': line['qty'], 'align': '<', 'width': QTY_WIDTH }, { 'text': line['item_name'], 'align': '<', 'width': ITEM_WIDTH }, ]) p.text(line_text) if print_item_code: item_code = line_block([{ 'text': '-', 'align': '<', 'width': QTY_WIDTH }, { 'text': line['item_code'], 'align': '<', 'width': ITEM_WIDTH }]) p.text(item_code) # Remarks p.text('\n\nRemarks:\n{0}'.format(order.remarks)) # Time p.text('\n\nPrinted on:\n') p.text(time.ctime()) p.cut()
def write_order_void(order, usb_printer=None, print_item_code=True): if usb_printer: p = usb_printer else: p = File("/dev/usb/lp0") lines = [] for i in order.items: lines.append(i.__dict__) # Order p.text('Void Items') # Headers header_line = line_block([ { 'text': 'Qty', 'align': '<', 'width': QTY_WIDTH }, { 'text': 'Item', 'align': '<', 'width': ITEM_WIDTH }, ]) p.text(header_line) # Lines for line in lines: if line['is_voided']: line_text = line_block([ { 'text': line['qty'], 'align': '<', 'width': QTY_WIDTH }, { 'text': line['item_name'], 'align': '<', 'width': ITEM_WIDTH }, ]) p.text(line_text) if print_item_code: item_code = line_block([{ 'text': '-', 'align': '<', 'width': QTY_WIDTH }, { 'text': line['item_code'], 'align': '<', 'width': ITEM_WIDTH }]) p.text(item_code) # Time p.text('\n\nPrinted on:\n') p.text(time.ctime()) p.cut()