def setup(self): mock_destination_log() mock_upc_log() self.test_inv = Invoice(invoice_number='59128', customer='Saks Fifth Avenue', store_number='0689', store_name='', dc_number='0385', discount_code='05', discount=0, total_cost=4575.0, total_qty=7) self.test_inv_mult = Invoice(invoice_number='65502', customer="Bloomingdale's", store_number='0011', store_name='CHESTNUT HILL', dc_number='SF', discount_code='05', discount=0, total_cost=1570.0, total_qty=2) item = Item(upc='8032762282181', style='OB1403-MPB-Y-02-0.0', cost=785.0, qty=2) self.test_inv_mult.items.append(item)
def test_get_store_info_with_valid_destination(): mock_destination_log() inv = Invoice() inv.customer = 'TestCust' inv = get_store_info(inv, 'TestDest', mock_settings()) assert inv.store_number == '0001' assert inv.dc_number == '0123' assert inv.store_name == 'TestName'
def setup(self): self.test_invoice = Invoice(invoice_number='59128', customer='Saks Fifth Avenue', sscc_number='803276200000591289', tracking_number='1ZW885Y21349335867', ship_date=datetime(2015, 12, 15), address_1='ONE WALDENBOOKS DRIVE', address_2='DC# 185 STORE# 689', city_state_zip='LA VERGNE, TN 37086')
def assign_shipping_info(invoice: Invoice, ship_log: str): invoice = check_ship_log(invoice, ship_log) if invoice.tracking_number is None: dialog = TrackingWarningDialog(invoice.invoice_number) dialog.exec_() if dialog.confirmed is True: invoice.tracking_number = dialog.tracking invoice.ship_date = datetime.now() else: return False return invoice
def get_store_info(invoice: Invoice, destination: str, settings: dict): """Checks the destination file for store info and assigns to the invoice. If the destination is not found, requests user input. Returns False if the user cancels operation""" with open(settings['File Paths']['Destination Log'], 'r') as dest_log: dest_reader = csv.reader(dest_log, delimiter=';') for row in dest_reader: if len(row) > 0 and row[0] == invoice.customer and row[ 1] == destination: invoice.store_number = row[2].zfill(4) invoice.dc_number = row[3].zfill(4) invoice.store_name = row[4] if invoice.store_number is None: invoice = store_not_found(invoice, destination, settings) return invoice
def test_multiple_items(self): invoice_list = get_invoice_info( [Invoice(invoice_number='65502', customer="Bloomingdale's")], "Bloomingdale's", mock_settings()) inv = invoice_list[0] for index, item in enumerate(self.test_inv_mult.items): assert item.__repr__() == inv.items[index].__repr__() assert inv.__repr__() == self.test_inv_mult.__repr__()
def generate_invoice(self): invoice = Invoice(invoice_number=self.InvoiceEdit.text(), customer=self.CustomerBox.currentText(), po_number=self.order.po_number, dc_number=self.DcBox.text(), tracking_number=self.TrackingBox.text(), ship_date=self.ShipDateCal.date(), store_number=self.StoreBox.currentText()) invoice.dept_number( False, self.settings['Customer Settings'][invoice.customer] ['Asset Department'], self.settings['Customer Settings'][ invoice.customer]['Memo Department']) invoice.discount(self.DiscountSpin.value()) invoice.items = self.ItemTable.model().item_list invoice.get_totals() invoice.sscc_number = generate_sscc(invoice.invoice_number) return invoice
class TestGetInvoiceInfo(object): def setup(self): mock_destination_log() mock_upc_log() self.test_inv = Invoice(invoice_number='59128', customer='Saks Fifth Avenue', store_number='0689', store_name='', dc_number='0385', discount_code='05', discount=0, total_cost=4575.0, total_qty=7) self.test_inv_mult = Invoice(invoice_number='65502', customer="Bloomingdale's", store_number='0011', store_name='CHESTNUT HILL', dc_number='SF', discount_code='05', discount=0, total_cost=1570.0, total_qty=2) item = Item(upc='8032762282181', style='OB1403-MPB-Y-02-0.0', cost=785.0, qty=2) self.test_inv_mult.items.append(item) def test_get_invoice_info(self): invoice_list = get_invoice_info([Invoice(invoice_number='59128', customer='Saks Fifth Avenue')], 'Saks Fifth Avenue', mock_settings()) inv = invoice_list[0] assert inv.__repr__() == self.test_inv.__repr__() def test_multiple_items(self): invoice_list = get_invoice_info([Invoice(invoice_number='65502', customer="Bloomingdale's")], "Bloomingdale's", mock_settings()) inv = invoice_list[0] for index, item in enumerate(self.test_inv_mult.items): assert item.__repr__() == inv.items[index].__repr__() assert inv.__repr__() == self.test_inv_mult.__repr__()
class TestGetInvoiceInfo(object): def setup(self): mock_destination_log() mock_upc_log() self.test_inv = Invoice(invoice_number='59128', customer='Saks Fifth Avenue', store_number='0689', store_name='', dc_number='0385', discount_code='05', discount=0, total_cost=4575.0, total_qty=7) self.test_inv_mult = Invoice(invoice_number='65502', customer="Bloomingdale's", store_number='0011', store_name='CHESTNUT HILL', dc_number='SF', discount_code='05', discount=0, total_cost=1570.0, total_qty=2) item = Item(upc='8032762282181', style='OB1403-MPB-Y-02-0.0', cost=785.0, qty=2) self.test_inv_mult.items.append(item) def test_get_invoice_info(self): invoice_list = get_invoice_info( [Invoice(invoice_number='59128', customer='Saks Fifth Avenue')], 'Saks Fifth Avenue', mock_settings()) inv = invoice_list[0] assert inv.__repr__() == self.test_inv.__repr__() def test_multiple_items(self): invoice_list = get_invoice_info( [Invoice(invoice_number='65502', customer="Bloomingdale's")], "Bloomingdale's", mock_settings()) inv = invoice_list[0] for index, item in enumerate(self.test_inv_mult.items): assert item.__repr__() == inv.items[index].__repr__() assert inv.__repr__() == self.test_inv_mult.__repr__()
def generate_invoice(self): invoice = Invoice(invoice_number=self.InvoiceEdit.text(), customer=self.CustomerBox.currentText(), po_number=self.order.po_number, dc_number=self.DcBox.text(), tracking_number=self.TrackingBox.text(), ship_date=self.ShipDateCal.date(), store_number=self.StoreBox.currentText()) invoice.dept_number(False, self.settings['Customer Settings'] [invoice.customer]['Asset Department'], self.settings['Customer Settings'] [invoice.customer]['Memo Department']) invoice.discount(self.DiscountSpin.value()) invoice.items = self.ItemTable.model().item_list invoice.get_totals() invoice.sscc_number = generate_sscc(invoice.invoice_number) return invoice
class TestGetShippingInfo(object): def setup(self): self.test_invoice = Invoice(invoice_number='59128', customer='Saks Fifth Avenue', sscc_number='803276200000591289', tracking_number='1ZW885Y21349335867', ship_date=datetime(2015, 12, 15), address_1='ONE WALDENBOOKS DRIVE', address_2='DC# 185 STORE# 689', city_state_zip='LA VERGNE, TN 37086') def test_get_shipping_info(self): invoice_list = get_shipping_info( [Invoice(invoice_number='59128', customer='Saks Fifth Avenue')], mock_settings()) assert invoice_list[0].__repr__() == self.test_invoice.__repr__()
class TestGetShippingInfo(object): def setup(self): self.test_invoice = Invoice(invoice_number='59128', customer='Saks Fifth Avenue', sscc_number='803276200000591289', tracking_number='1ZW885Y21349335867', ship_date=datetime(2015, 12, 15), address_1='ONE WALDENBOOKS DRIVE', address_2='DC# 185 STORE# 689', city_state_zip='LA VERGNE, TN 37086') def test_get_shipping_info(self): invoice_list = get_shipping_info([Invoice(invoice_number='59128', customer='Saks Fifth Avenue')], mock_settings()) assert invoice_list[0].__repr__() == self.test_invoice.__repr__()
def generate_invoices(self, inv_array): print("%s Starting invoice generation" % datetime.now()) for row in inv_array: if len(row[0]) > 0: invoice = Invoice(invoice_number=row[0], customer=self.customer, po_number=row[1]) invoice.discount(row[2]) invoice.get_dept_number( row[3], self.customer_settings['Asset Department'], self.customer_settings['Memo Department']) self.invoice_list.append(invoice) print( "%s Created Invoice# %s, with PO# %s, Dept# %s, and discount %s" % (datetime.now(), invoice.invoice_number, invoice.po_number, invoice.dept_number, invoice.discount)) print("%s Ending generation. Generated %s invoices" % (datetime.now(), len(self.invoice_list))) self.progress += 1
def test_invoice(self): inv = Invoice() inv.invoice_number = '59128' inv.customer = 'Saks Fifth Avenue' inv.store_number = '0689' inv.tracking_number = '1ZW885Y21349335867' inv.ship_date = datetime(2015, 12, 15) inv.discount_code = '05' inv.discount = 0 inv.sscc_number = '803276200000591289' inv.po_number = '6163130' inv.dept_number = '0162' inv.dc_number = '0185' inv.total_cost = 4575 inv.total_qty = 7 inv.address1 = 'ONE WALDENBOOKS DRIVE' inv.address2 = 'DC# 185 STORE# 689' inv.city_state_zip = 'LA VERGNE, TN 37086' p1 = Item() p1.style = 'CB1779- -Y-02-42.0' p1.upc = '8032762238027' p1.qty = 1 p1.cost = 795.0 inv.items.append(p1) #p2 = Product('OB1234- -Y-02-0') self.test_invoices.append(inv)
def mock_invoices(): return {'12345': Invoice(invoice_number='12345', customer='TestCust')}
def test_get_shipping_info(self): invoice_list = get_shipping_info( [Invoice(invoice_number='59128', customer='Saks Fifth Avenue')], mock_settings()) assert invoice_list[0].__repr__() == self.test_invoice.__repr__()