def on_brieven( self, button ): dieren = [] self.dialog = self.builder.get_object('dialog1') self.buffer = self.builder.get_object('briefresultaten') textview=self.builder.get_object('textview1') textview.set_buffer(self.buffer) self.next = self.builder.get_object('button7') self.previous = self.builder.get_object('button6') self.first = self.builder.get_object('button9') self.type = 'Brief' for index, row in enumerate(self.store): if row[0]: dieren.append(row[2]) order = self.find_order(index) if order: result = order.get_result() if not result: self.letters[index] = 'bestelling voor {0},{1} nog niet uitgevoerd. Kies "picklijst" eerst.'.format(row[1], row[2]),\ order.get_owner(), order.get_animal() else: if order.get_ras() == 'KAT' and order.get_kind() == '100': self.brief = self.kat100 elif order.get_ras() == 'HOND' and order.get_kind() == '100': self.brief = self.hond100 elif order.get_ras() == 'KAT' and order.get_kind() == 'COMBI': self.brief = self.katcombi elif order.get_ras() == 'HOND' and order.get_kind() == 'COMBI': self.brief = self.hondcombi elif order.get_ras() == 'KAT' and order.get_kind() == 'PLUS': self.brief = self.katplus else: self.brief = self.hondplus d = Delivery(self.testdir, order, result) res = d.csvout(True) print res weight = float(row[6])*order.get_weight() if order.get_ras() == 'KAT': weight *= 35 else: weight *= 25 brief = self.brief.format("{:%d %B %Y}".format(datetime.date.today()), order.get_owner(), order.get_kind(), order.get_animal(), order.get_weight(), weight, order.get_kind(), order.get_kind()) self.letters[index] = brief+res, order.get_owner(), order.get_animal() else: self.letters[index] = 'Geen bestelling voor {0},{1}'.format(row[1], row[2]), order.get_owner(), order.get_animal() #else: # self.letters[index] = 'Geen bestelling voor {0},{1}'.format(row[1], row[2]), order.get_owner(), order.get_animal() self.buffer.set_text(self.letters[self.position][0]) self.dialog.set_title("Brief voor {0},{1}".format(*self.letters[self.position][1:])) self.results = self.letters response = self.dialog.run()
def on_picklijst( self, button ): dieren = [] self.dialog = self.builder.get_object('dialog1') self.buffer = self.builder.get_object('picklijstresultaten') textview=self.builder.get_object('textview1') textview.set_buffer(self.buffer) self.next = self.builder.get_object('button7') self.previous = self.builder.get_object('button6') self.first = self.builder.get_object('button9') self.type = 'Picklijst' for index, row in enumerate(self.store): if row[0]: dieren.append(row[2]) order = self.find_order(index) order.set_portie(row[9]) if order: result = self.oervoer.process_order(order) #mealsize adjusted by factor for ex in self.oervoer.exceptions: warning('Geen {0} voor {1} afzondering\n {2}'.format(*ex), self.window) self.oervoer.exceptions = [] d = Delivery(self.testdir, order, result) res = '''datum: {7}\ndier: {0}\npakket: {1}\ngewicht dier: {2}\ngewicht pakket: {3}\nvermijd: {5}\nmaaltijd: {6}\n{4}'''.format(row[3],row[4],row[5], row[7], d.csvout(), ','.join(order.get_donts()),order.get_meal_size(), "{:%d %B %Y}".format(datetime.date.today() )) print res self.picklists[index] = res,order.get_owner(), order.get_animal() else: self.picklists[index] = 'geen bestelling voor {0},{1}'.format(row[1], row[2]),'','' self.buffer.set_text(self.picklists[self.position][0]) self.dialog.set_title('Picklijst voor {0},{1}'.format(*self.picklists[self.position][1:])) self.results = self.picklists response = self.dialog.run()
def write_inventory(self): import csv name = '.'.join(self.productname.split('.')[:-1])+'.new.csv' f = file(name, 'w') fcsv = csv.writer(f) fcsv.writerow('store sku qty is_in_stock geschiktmenu name smaak type_vlees shelf weight'.split()) for prodtype in self.prodlists.values(): for prod in prodtype: fcsv.writerow (['admin', prod.sku, prod.qty, 1, 'Ja', prod.name, prod.smaak, prod.type, prod.shelf, prod.weight]) if __name__ == '__main__': testdir = os.getenv('OERVOERTESTENV') if not testdir: testdir = '../test/' oervoer = Oervoer(testdir+'products.csv',testdir+'orders.csv',testdir+'picklists.csv') oervoer.parse_products() oervoer.parse_orders() for order in oervoer.ordlist: try: result = oervoer.process_order(order) d = Delivery(testdir, order, result) print d.csvout() oervoer.write_inventory() except NoProductsException,e: print e print '%s\nKan order %s-%s niet vervullen.\n%s\n' % ('^'*70, order.owner, order.animal,'#$'*35 ) oervoer.dump()