예제 #1
0
 def read_export(self, customer):
     """Reads the TLW export based on customer name. If the PO number is not
     already in the program data, adds it"""
     export_file = self.get_export_file(customer)
     with open(export_file, 'r') as export:
         for line in export:
             line = line.rstrip('\n').rstrip('\r').split(',')
             if line[1] != 'PO #':
                 if line[1].lstrip('0') not in self.purchase_orders:
                     PO = PurchaseOrder(line[1].lstrip('0'), customer)
                     PO.cancel_ship = line[4]
                     #PO.total_cost = self.get_cost_from_exp(PO.po_number,
                     #                                       export_file)
                     PO.get_items_from_export(export_file)
                     PO.get_stores_from_export(export_file)
                     for item in PO.items.itervalues():
                         PO.total_cost += (item.cost * item.total_qty)
                     self.purchase_orders[PO.po_number] = PO
                 else:
                     PO = self.purchase_orders[line[1].lstrip('0')]
                     PO.cancel_ship = line[4]
                     #PO.total_cost = self.get_cost_from_exp(PO.po_number,
                                                            #export_file)
                     PO.get_items_from_export(export_file)
                     PO.get_stores_from_export(export_file)
                     PO.total_cost = 0
                     for item in PO.items.itervalues():
                         PO.total_cost += (item.cost * item.total_qty)
                     self.purchase_orders.sync()
예제 #2
0
 def read_db(self, db_file):
     """Reads POs from supplied CSV file and adds to the database object"""
     with open(db_file, 'r') as db:
         for line in db:
             if len(line) > 1:
                 line = line.replace('\n','').replace('\r','').split(',')
                 PO = PurchaseOrder(line[0], line[1])
                 PO.creation_date = line[2]
                 PO.start_ship = line[3]
                 PO.cancel_ship = line[4]
                 PO.total_cost = line[5]
                 PO.discount = line[6]
                 PO.label = line[7]
                 PO.complete = line[8]
                 self.purchase_orders[PO.po_number] = PO