Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
 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 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()