def run_all_purchase_list_report(from_date, to_date, delay=.8): send = SendData() run_all_purchase_list(from_date, to_date, False) time.sleep(1) screen = parse.process_scene(window.get_window()) o = parse.distribution_list_product(screen) i = 0 while '< More >' in screen[-1] and i < 300: screen = get_next_screen(screen, 0, delay) o.extend(parse.distribution_list_product(screen)) i += 1 send.send('{LEFT}') time.sleep(1) screen = parse.process_scene(window.get_window()) for i in range(20): send.send('{LEFT 10}') time.sleep(.1) screen = parse.process_scene(window.get_window()) if 'Uniware' in screen[1]: ## print("found") break ## index = 0 ## while "From" not in screen or index > 10: ## send.send('{LEFT}') ## screen = parse.process_scene(window.get_window()) ## index+=1 return o
def to_insert_virtual_purchases(date, delay=.5): match = False for i in range(20): send = SendData() send.activate_window() to_menu(('Purchase', 'Default', 'Insert virtual purchases')) send.send('{home}') time.sleep(delay) send.send('{enter}') send.send(date) send.send('{enter}') time.sleep(delay) time.sleep(.8) screen = parse.process_scene(window.get_window()) #input("break") time.sleep(.8) send.activate_window() screen = parse.process_scene(window.get_window()) if parse.identify_screen(screen, 'Insert virtual purchases Flowers'): screen = parse.process_scene(window.get_window()) match = True print(screen[-6]) #input("break") time.sleep(.8) send.activate_window() if 'Article' not in screen[-6]: send = SendData() send.send('{INSERT}') break return match
def parse_price_list_category(cat_name): items = [] send = SendData() while True: screen = process_scene(window.get_window()) to_process = screen[6:] for line in to_process: if '═' in line: break line = line[4:] l = line.split('║') if l[0].isspace(): break else: if 'x' in line: print(l) quantity = l[7][:l[7].index('x')] price = l[9].replace(',', '.').strip('■').strip('▲').strip('█').strip('▼') print(price) items.append((l[0].strip(), l[1].strip(), l[2].strip(), quantity.strip(), price.strip())) send.send('{PGDN}') time.sleep(0.1) new_screen = process_scene(window.get_window()) if new_screen == screen: time.sleep(0.1) new_screen = process_scene(window.get_window()) if new_screen == screen: break return {cat_name: items}
def read_art_info_pricelist(depth=0): try: send = SendData() window.drag_window() send.send("+{F10}") send.send("{UP}") time.sleep(.05) screen = process_scene(window.get_window()) category_id = get_info(screen, "Agrp:", 1, 5) category_name = get_info(screen, f"Articlegroup : {category_id}", 1, 20) f2_name = get_info(screen[6:], category_name, 1, 30) info = {"f2_code": get_info(screen, "Ofsht:", 1, 10), "f2_category_id": category_id, "f2_name": f2_name, "f2_grade": get_info(screen, "Length/height :", 1, 10), "f2_colour_code_id": get_info(screen, "Kleur :", 1, 3), } send.send("{F12}") send.send("+{F7}") time.sleep(.05) screen = process_scene(window.get_window()) info["packing"] = get_info(screen, "Eenheden per Bos :", 1, 5) send.send("{F12}") send.send("+{F10}") except: if depth < 20: return read_art_info_pricelist(depth + 1) else: assert (1 == 2) return info
def get_categories(): send = SendData() categories = [] old_screen = [] screen = process_scene(window.get_window())[6:-1] send.send('{home 5}') time.sleep(1) screen = process_scene(window.get_window())[6:-1] while old_screen != screen: old_screen = screen for line in screen: line = line.split('║') if '══' not in line[0]: for l in line[2:5]: if l[3:].rstrip() and not l[3:].rstrip().isspace(): categories.append((l[3:].rstrip())) else: for l in line[1:4]: if l[3:].rstrip() and not l[3:].rstrip().isspace(): categories.append((l[3:].rstrip())) # print(line) send.send('{PGDN}') time.sleep(1) screen = process_scene(window.get_window())[6:-1] # a[1].split('║')[2][3:].rstrip() categories.sort() return categories
def get_window(): send = SendData() drag_window() send.send('%c') data = None for i in range(3): data = clipboard.get_clipboard() break return data
def to_assortment(): ''' (None)->None goes to Assortment Menu ''' send = SendData() to_menu(('Maintenance data','Assortment')) send.send('{home}') time.sleep(0.5) send.send('{enter}')
def to_menu_slowest(command_order, verbose=False): send = SendData() if to_main(): send.send("{HOME}") time.sleep(1) if verbose: print(command_order) traverse(command_order) time.sleep(1) return True
def to_order_category(cat_num, cat_name): send = SendData() send.activate_window() send.send(cat_num) for i in range(5): screen = parse.process_scene(window.get_window()) if parse.identify_screen(screen, cat_name, 4): return True time.sleep(.3) screen = parse.process_scene(window.get_window()) return False
def get_next_screen(old_screen, depth=0, delay=.5): if depth > 50: return [''] send = SendData() send.send('{enter}') for i in range(200): time.sleep(delay) screen = parse.process_scene(window.get_window()) if old_screen != screen: return screen return get_next_screen(old_screen, depth + 1, delay)
def to_orderstatus_range(date): if to_main(): send = SendData() index = 0 while not to_menu_slowest(['Sales', 'Orderstatus sales (f/t)']): time.sleep(.3) index += 1 if index > 3: exit() send.send(date) send.send('{ENTER}')
def get_window(): send = SendData() drag_window() send.send('%c') data = None for i in range(3): try: data = clipboard.get_clipboard() break except: time.sleep(0.01) return data
def get_purchase_list_report(from_date,to_date,supplier ): send = SendData() run_purchase_list(from_date, to_date,supplier) screen = parse.process_scene(window.get_window()) o = parse.distribution_list_product(screen) i = 0 while '< More >' in screen[-1] and i < 10: send.send('{enter}') time.sleep(0.8) screen = parse.process_scene(window.get_window()) o.extend(parse.distribution_list_product(screen)) i+=1 return o
def to_order(date, ordernumber, go_to_menu=True): send = SendData() if go_to_menu: to_orderstatus(date) else: send.send('{HOME 5}') found = False time.sleep(.5) while not found: index = 0 screen = parse.process_scene(window.get_window())[6:-6] for line in screen: if ordernumber in line: found = True send.send('{DOWN %s}' % index) send.send('{ENTER}') return True index += 1 if not found: send.send('{PGDN}') time.sleep(.5) next_screen = parse.process_scene(window.get_window())[6:-6] if next_screen == screen: return False
def to_input_order(date, client, list=21): send = SendData() delay = .15 points = [('Article :', 19, 4), ('n/a', 4, 2), ('Client :', 4, 24)] index = 0 commands = [ '{LEFT}', date, '{ENTER}', client, '{ENTER}', '{F11}', '{HOME}', '{ENTER}', list, '{ENTER}' ] to_main() while not verify(points): to_main() to_menu(('Orders', 'Input order')) for c in commands: if c == '{HOME}': if verify([('Client information', 6, 4)]): send.send('{F12}') if c == list: time.sleep(delay) if verify([('Create new order number', 5, 21)]): time.sleep(delay) send.send('{HOME}') time.sleep(delay) send.send('{ENTER}') time.sleep(delay) time.sleep(delay) send.send(c) time.sleep(delay) if index > 10: return False index += 1
def to_pricelist(pricelist_num, date=''): match = False for i in range(2): send = SendData() to_menu_parsed(('Maintenance data', 'Pricelists', 'Edit pricelist')) time.sleep(0.5) send.send('{home}') time.sleep(0.5) send.send('{enter}') time.sleep(0.5) screen = parse.process_scene(window.get_window()) if parse.identify_screen(screen, 'Edit pricelist Flowers'): match = True time.sleep(0.1) if date: send.send('+3') send.send(date) #send.send('{enter}') send.send(pricelist_num) time.sleep(0.1) ## send.send('{enter}') break return match
def to_virtual_stock(from_date,to_date): send = SendData() if to_main(): time.sleep(0.02) menus = ('stock','Stock virtual products','Edit stock virtual') traverse(menus) time.sleep(.5) send.send(from_date) send.send('{enter}') send.send(to_date) send.send('{f11}') send.send('{enter}') send.send('{down}') send.send('{enter}')
def get_window(attempt=0): send = SendData() drag_window() send.send('%c') data = None for i in range(3): try: data = get_clipboard() break except: time.sleep(0.01) #clipboard.empty_clipboard() if data == None and attempt < 10: return get_window(attempt + 1) return data
def to_input_purchase_ps_insert(date): send = SendData() to_menu(('Purchase', 'Per shipment', 'Input purchases (PS)')) send.send('{home}') time.sleep(0.5) send.send('{enter}') send.send(date) send.send('{enter}')
def to_input_purchase(date): send = SendData() to_menu(('Purchase','Default','Input purchases')) send.send('{home}') time.sleep(0.5) send.send('{enter}') send.send(date) send.send('{enter}')
def make_virtual_shipment_list(date = '051115', client='CAN*ON',plist = '03'): send = SendData() navigation.to_order_order(date,client,plist) screen = parse.process_scene(get_window()) categories = parse.order_categories(screen) items = {} for c in categories: if navigation.to_order_category(c[0],c[1]): screen = parse.process_scene(get_window()) ### get items items[c[1]] = parse.parse_virtual_order_category(c[1])[c[1]] ## print(items[c[1]]) send.send("{F12}") return items
def to_main(tries = 25): send = SendData() screen = None for ik in range(tries): for j in range(10): try: screen = parse.process_scene(window.get_window()) break except: time.sleep(0.1) time.sleep(0.1) if parse.identify_screen(screen,'Main Menu'): send.send('{UP}') return True send.send('{F12}') return False
def to_input_purchase_insert(date): send = SendData() to_menu(('Purchase', 'Default', 'Input purchases')) send.send('{home}') time.sleep(0.5) send.send('{enter}') print(date) send.send(date) send.send('{enter}') points = [('Input purchases Flowers', 2, 92), ('Article', 29, 4), ('Buyer :', 29, 59), ('Available', 21, 54), ('Bought for :', 30, 4)] time.sleep(.1) if not verify(points): send.send('{insert}') time.sleep(.2) if not verify(points): to_input_purchase_insert(date)
def to_pricelist_type(list_num): ''' (str)->None goes to list number in price ''' send = SendData() to_menu(('Maintenance data','Pricelists','Pricelist type')) send.send('{home}') time.sleep(0.5) send.send('{enter}') send.send(list_num) send.send('{f12}')
def get_orderstatus_orders(date): send = SendData() screen = process_scene(window.get_window())[6:-1] send.send('{home 5}') screen = process_scene(window.get_window())[6:-1] last_screen = None clients = [] while screen != last_screen: last_screen = screen screen = process_scene(window.get_window())[6:-6] for s in screen: order_num = s[20:27].strip() if order_num: clients.append([s[1:7].strip(), order_num, date]) send.send('{pgdn}') time.sleep(.5) return clients
def to_virtual_stock(from_date, to_date): send = SendData() if to_main(): time.sleep(0.02) menus = ('stock', 'Stock virtual products', 'Edit stock virtual') traverse(menus) send.send(from_date) send.send('{enter}') send.send(to_date) send.send('{f11}') send.send('{enter}') send.send('{down}') send.send('{enter}') for i in range(20): screen = parse.process_scene(window.get_window()) if parse.identify_screen(screen, "Edit stock virtual Flowers", line_num=2): return True time.sleep(.1)
def to_input_purchase_mix_insert(date): send = SendData() points = [('Input purchase mixbox Flowers', 2, 92), ('Inkoopdatum', 4, 2), ('Zendingnr', 6, 19)] index = 0 to_main() while not verify(points): to_menu(('Purchase', 'Per shipment', 'Input purchase mixbox')) send.send('{home}') time.sleep(1) send.send('{enter}') send.send(date) send.send('{enter}') if not verify([('Airbill', 6, 5)]): send.send('{F11}') time.sleep(1) if index > 10: return False index += 9 return True
def price(items, from_date, to_date, margin): navigation.to_virtual_stock(from_date, to_date) screen = process_scene(window.get_window()) send = SendData() for i in items: if items[i]: print(i, items[i], '... ', end='') price = '{0:.2f}'.format(float(items[i]) * margin) print(price) commands = ('{F7}', i, '{right}', '{enter}', '{F2}', '{enter}') for cmd in commands: send.send(cmd) for n in range(8): send.send('{F10}') send.send(price) send.send('{enter}') send.send('{f11}') send.send('{f12}')
def parse_sales_by_client(): send = SendData() send.activate_window() clients = {} old_screen = None screen = process_scene(window.get_window())[8:-5] while old_screen != screen: for s in screen: row = s.split('║') code = row[2].strip() total = row[5].strip().replace(',', '.') if total: if code not in clients: clients[code] = {} invoice_num = row[3].strip() clients[code][invoice_num] = total send.send("{PGDN}") time.sleep(.1) old_screen = screen screen = process_scene(window.get_window())[8:-5] return clients
def to_input_purchase(date): match = False for i in range(20): send = SendData() send.activate_window() to_menu(('Purchase', 'Default', 'Input purchases')) send.send('{home}') time.sleep(0.5) send.send('{enter}') send.send(date) send.send('{enter}') time.sleep(0.5) screen = parse.process_scene(window.get_window()) if parse.identify_screen(screen, 'Input purchases Flowers'): screen = parse.process_scene(window.get_window()) match = True if 'Article' not in screen[-6]: send = SendData() send.send('{INSERT}') break return match