From 4ae215621ec34bfafe9c002e2c84ee25c827331b Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Sat, 14 Nov 2020 17:22:20 +0100 Subject: [PATCH] Kassenspiel --- main.py | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test.txt | 12 +++++++++ 2 files changed, 90 insertions(+) create mode 100644 main.py create mode 100644 test.txt diff --git a/main.py b/main.py new file mode 100644 index 0000000..34c84a8 --- /dev/null +++ b/main.py @@ -0,0 +1,78 @@ +# This is a sample Python script. + +# Press ⇧F10 to execute it or replace it with your code. +# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings. + +from escpos.printer import Usb + +def print_hi(name): + # Use a breakpoint in the code line below to debug your script. + print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint. + + +articles = { + '40267609': { + 'price': 3.99, + 'name': 'kleber' + }, + '5449000138170': { + 'price': 1.50, + 'name': 'fanta zero' + }, + '4005401170006': { + 'price': 1.50, + 'name': 'stift' + }, + '4012700987020': {'price': 2.00, 'name': 'tintenkiller'}, '4006381333634': {'price': 2.50, 'name': 'textmarker'}, + '4006381333214': {'price': 1.00, 'name': 'filzstift'}, '4005401743354': {'price': 5.00, 'name': 'zirkel'}, + '4006144241022': {'price': 3.00, 'name': 'schulheft'}, + '9783551050113': {'price': 0.50, 'name': 'pixibuch'}, '9781474969314': {'price': 8.00, 'name': 'puzzle pad'}, + '4009900533652': {'price': 1.00, 'name': 'kaugummis'}, '746775261344': {'price': 11.00, 'name': 'scrabble junior'}, + '4000540000108': {'price': 9.00, 'name': 'haferflocken'} + +} + +def main(): + printer = Usb(0x04B8, 0x0202, profile="TM-T88V") + while True: + endprice = 0 + barcode = 'x' + while barcode != '' and barcode != 'XXXX': + barcode = input() + print(barcode) + if barcode in articles: + print(articles[barcode]['name'], articles[barcode]['price']) + endprice += articles[barcode]['price'] + printer.textln(f"{barcode}") + printer.textln(f"{articles[barcode]['name']} {articles[barcode]['price']}") + printer.textln() + print('-------------------') + print(endprice) + print() + print() + printer.textln('-------------------') + printer.textln(endprice) + printer.textln(" Danke für den Einkauf ") + printer.cut() + + +def createproduct(): + barcode = ' ' + products = [] + while barcode != '': + barcode = input() + print('name:', end='') + name = input() + print('price:', end='') + price = input() + products.append(f"'{barcode}': {{ 'price': {price}, 'name': '{name}' }}") + print(','.join(products)) + + +# Press the green button in the gutter to run the script. +if __name__ == '__main__': + print_hi('Lily') + # createproduct() + main() + +# See PyCharm help at https://www.jetbrains.com/help/pycharm/ diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..6330660 --- /dev/null +++ b/test.txt @@ -0,0 +1,12 @@ +40267609 +40267609 +4005401170006 +4006381333214 +4006381333214 +746775261344 +9781474969314 +5449000138170 +4009900533652 +9783593512549 +40267609 +5449000187390