Пример #1
0
    def test_close_returned_in_consignment_wizard(self, run_dialog, info):
        purchase_item = self.create_purchase_order_item()
        self.create_receiving_order_item(purchase_item=purchase_item)

        # Create storable.
        product = purchase_item.sellable.product
        Storable(store=self.store, product=product)
        storable = product.storable
        branch = purchase_item.order.branch
        storable.increase_stock(5, branch,
                                StockTransactionHistory.TYPE_INITIAL, None,
                                self.current_user)
        stock_quantity = storable.get_stock_item(branch, None).quantity
        self.assertEqual(stock_quantity, 5)

        purchase_item.quantity_received = 5
        purchase_item.order.status = PurchaseOrder.ORDER_CONSIGNED
        purchase_item.order.identifier = 334
        purchase_item.order.open_date = localdatetime(2012, 1, 1)
        purchase_item.order.expected_receival_date = localdatetime(2012, 2, 2)

        wizard = CloseInConsignmentWizard(self.store)

        step = wizard.get_current_step()
        self.click(step.search.search_button)

        product_stock_item = self.store.find(ProductStockItem,
                                             storable=storable).one()
        self.check_wizard(wizard, 'wizard-return-consignment-selection-step')

        order_view = step.search.results[0]
        step.search.results.select(order_view)
        self.click(wizard.next_button)

        step = wizard.get_current_step()

        # Select consignment.
        step.consignment_items.emit('row_activated', step.consignment_items[0])
        self.assertEqual(run_dialog.call_count, 1)
        args, kwargs = run_dialog.call_args
        editor, parent, store, item = args
        self.assertEqual(editor, InConsignmentItemEditor)
        self.assertEqual(parent, wizard)
        self.assertEqual(item, purchase_item)
        self.assertTrue(store is not None)

        # Return the total received.
        purchase_item.quantity_returned = 5

        self.click(wizard.next_button)
        # After return. Item quantity in stock must be decreased.
        stock_quantity = storable.get_stock_item(branch, None).quantity
        self.assertEqual(stock_quantity, 0)
        self.check_wizard(wizard,
                          'wizard-close-returned-in-consignment-confirm',
                          [wizard.retval, purchase_item, product_stock_item])
Пример #2
0
    def test_close_returned_in_consignment_wizard(self, run_dialog, info):
        purchase_item = self.create_purchase_order_item()
        self.create_receiving_order_item(purchase_item=purchase_item)

        # Create storable.
        product = purchase_item.sellable.product
        Storable(store=self.store, product=product)
        storable = product.storable
        branch = purchase_item.order.branch
        storable.increase_stock(5, branch,
                                StockTransactionHistory.TYPE_INITIAL, None)
        stock_quantity = storable.get_stock_item(branch, None).quantity
        self.assertEqual(stock_quantity, 5)

        purchase_item.quantity_received = 5
        purchase_item.order.status = PurchaseOrder.ORDER_CONSIGNED
        purchase_item.order.identifier = 334
        purchase_item.order.open_date = localdatetime(2012, 1, 1)
        purchase_item.order.expected_receival_date = localdatetime(2012, 2, 2)

        wizard = CloseInConsignmentWizard(self.store)

        step = wizard.get_current_step()
        self.click(step.search.search_button)

        product_stock_item = self.store.find(ProductStockItem,
                                             storable=storable).one()
        self.check_wizard(wizard, 'wizard-return-consignment-selection-step')

        order_view = step.search.results[0]
        step.search.results.select(order_view)
        self.click(wizard.next_button)

        step = wizard.get_current_step()

        # Select consignment.
        step.consignment_items.emit('row_activated', step.consignment_items[0])
        self.assertEqual(run_dialog.call_count, 1)
        args, kwargs = run_dialog.call_args
        editor, parent, store, item = args
        self.assertEqual(editor, InConsignmentItemEditor)
        self.assertEqual(parent, wizard)
        self.assertEqual(item, purchase_item)
        self.assertTrue(store is not None)

        # Return the total received.
        purchase_item.quantity_returned = 5

        self.click(wizard.next_button)
        # After return. Item quantity in stock must be decreased.
        stock_quantity = storable.get_stock_item(branch, None).quantity
        self.assertEqual(stock_quantity, 0)
        self.check_wizard(wizard,
                          'wizard-close-returned-in-consignment-confirm',
                          [wizard.retval, purchase_item, product_stock_item])
    def test_close_in_consignment_wizard(self, run_dialog, info):
        purchase_item = self.create_purchase_order_item()
        self.create_receiving_order_item(purchase_item=purchase_item)

        # Create storable.
        product = purchase_item.sellable.product
        Storable(store=self.store, product=product)
        storable = product.storable
        branch = purchase_item.order.branch
        storable.increase_stock(10, branch, 0, None)
        stock_quantity = storable.get_stock_item(branch, None).quantity
        self.assertEquals(stock_quantity, 10)

        purchase_item.quantity_received = 10
        purchase_item.quantity_returned = 1
        purchase_item.quantity_sold = 1
        purchase_item.order.status = PurchaseOrder.ORDER_CONSIGNED
        purchase_item.order.identifier = 333
        purchase_item.order.open_date = localdatetime(2012, 1, 1)
        purchase_item.order.expected_receival_date = localdatetime(2012, 2, 2)

        wizard = CloseInConsignmentWizard(self.store)

        step = wizard.get_current_step()
        self.click(step.search.search_button)

        product_stock_item = self.store.find(ProductStockItem,
                                             storable=storable).one()
        self.check_wizard(wizard, 'wizard-consignment-selection-step')

        order_view = step.search.results[0]
        step.search.results.select(order_view)
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.consignment_items.select(step.consignment_items[0])

        self.click(step.edit_button)
        self.assertEquals(run_dialog.call_count, 1)
        args, kwargs = run_dialog.call_args
        editor, parent, store, item = args
        self.assertEquals(editor, InConsignmentItemEditor)
        self.assertEquals(parent, wizard)
        self.assertEquals(item, purchase_item)
        self.assertTrue(store is not None)

        purchase_item.quantity_sold = 2
        purchase_item.quantity_returned = 2
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        self.assertNotSensitive(wizard, ['next_button'])

        self.click(step.slave.add_button)
        step.slave.payments[0].due_date = localdatetime(2012, 10, 10)
        self.check_wizard(wizard, 'wizard-consignment-payment-step')
        self.assertSensitive(wizard, ['next_button'])

        self.click(wizard.next_button)
        stock_quantity = storable.get_stock_item(branch, None).quantity
        self.assertEquals(stock_quantity, 9)
        self.check_wizard(wizard, 'wizard-close-in-consignment-confirm',
                          [wizard.retval, purchase_item, product_stock_item])
Пример #4
0
    def test_close_in_consignment_wizard(self, run_dialog, info):
        purchase_item = self.create_purchase_order_item()
        self.create_receiving_order_item(purchase_item=purchase_item)

        # Create storable.
        product = purchase_item.sellable.product
        Storable(store=self.store, product=product)
        storable = product.storable
        branch = purchase_item.order.branch
        storable.increase_stock(10, branch,
                                StockTransactionHistory.TYPE_INITIAL, None)
        stock_quantity = storable.get_stock_item(branch, None).quantity
        self.assertEqual(stock_quantity, 10)

        purchase_item.quantity_received = 10
        purchase_item.quantity_returned = 1
        purchase_item.quantity_sold = 1
        purchase_item.order.status = PurchaseOrder.ORDER_CONSIGNED
        purchase_item.order.identifier = 333
        purchase_item.order.open_date = localdatetime(2012, 1, 1)
        purchase_item.order.expected_receival_date = localdatetime(2012, 2, 2)

        wizard = CloseInConsignmentWizard(self.store)

        step = wizard.get_current_step()
        self.click(step.search.search_button)

        product_stock_item = self.store.find(ProductStockItem,
                                             storable=storable).one()
        self.check_wizard(wizard, 'wizard-consignment-selection-step')

        order_view = step.search.results[0]
        step.search.results.select(order_view)
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.consignment_items.select(step.consignment_items[0])

        self.click(step.edit_button)
        self.assertEqual(run_dialog.call_count, 1)
        args, kwargs = run_dialog.call_args
        editor, parent, store, item = args
        self.assertEqual(editor, InConsignmentItemEditor)
        self.assertEqual(parent, wizard)
        self.assertEqual(item, purchase_item)
        self.assertTrue(store is not None)

        purchase_item.quantity_sold = 2
        purchase_item.quantity_returned = 2
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        self.assertNotSensitive(wizard, ['next_button'])

        self.click(step.slave.add_button)
        step.slave.payments[0].due_date = localdatetime(2012, 10, 10)
        self.check_wizard(wizard, 'wizard-consignment-payment-step')
        self.assertSensitive(wizard, ['next_button'])

        self.click(wizard.next_button)
        stock_quantity = storable.get_stock_item(branch, None).quantity
        self.assertEqual(stock_quantity, 9)
        self.check_wizard(wizard, 'wizard-close-in-consignment-confirm',
                          [wizard.retval, purchase_item, product_stock_item])