Esempio n. 1
0
    def on_confirm(self):
        # We are using this hook as a callback for the finish button
        branch = self.store.fetch(self.model.branch)
        responsible = self.store.fetch(self.model.user)
        inventory = Inventory(open_date=self.model.open_date,
                              branch=branch,
                              responsible=responsible,
                              store=self.store)
        for sellable in self._get_sellables():
            storable = sellable.product_storable
            if storable is None:
                continue

            if storable.is_batch:
                for batch in storable.get_available_batches(inventory.branch):
                    inventory.add_sellable(sellable,
                                           batch_number=batch.batch_number)
            else:
                inventory.add_sellable(sellable)
Esempio n. 2
0
    def on_confirm(self):
        # We are using this hook as a callback for the finish button
        branch = self.store.fetch(self.model.branch)
        inventory = Inventory(open_date=self.model.open_date,
                              branch=branch,
                              store=self.store)
        for sellable in self._get_sellables():
            storable = sellable.product_storable
            if storable is None:
                continue

            # a sellable without stock can't be part of inventory
            # XXX
            if storable.get_stock_item(self.model.branch, None) is not None:
                recorded_quantity = storable.get_balance_for_branch(
                    self.model.branch)
                # TODO: Move the creation of inventory itens to the domain.
                # TODO: Create one inventory item for each batch, or refactor
                # the way we do the inventory.
                InventoryItem(product=sellable.product,
                              product_cost=sellable.cost,
                              recorded_quantity=recorded_quantity,
                              inventory=inventory,
                              store=self.store)
Esempio n. 3
0
    def testRegisters(self):
        order = self.create_receiving_order()
        order.receival_date = localdate(2007, 6, 1).date()
        order.discount_value = 10
        # order.purchase.discount_value = 5
        # order.purchase.surcharge_value = 8
        # order.surcharge_value = 15
        order.ipi_total = 10
        order.freight_total = 6
        order.secure_value = 6
        order.expense_value = 12
        supplier = self.create_supplier()
        company = supplier.person.has_individual_or_company_facets()
        company.state_registry = u'103238426117'
        order.supplier = supplier
        employee = self.create_employee()
        branch = get_current_branch(self.store)
        branch.manager = employee

        order.purchase.status = order.purchase.ORDER_PENDING

        sellable = self.create_sellable()
        sellable.tax_constant = SellableTaxConstant(
            description=u"18",
            tax_type=int(TaxType.CUSTOM),
            tax_value=18,
            store=self.store)
        self.create_receiving_order_item(order, sellable=sellable)

        sellable2 = self.create_sellable()
        sellable2.tax_constant = SellableTaxConstant(
            description=u"6",
            tax_type=int(TaxType.CUSTOM),
            tax_value=6,
            store=self.store)
        self.create_receiving_order_item(order, sellable=sellable2)

        order.purchase.confirm()
        order.confirm()

        sellable.code = u'9999'
        sellable2.code = u'10000'

        sale = self.create_sale()
        sale.open_date = localdate(2007, 6, 10).date()

        sellable3 = self.create_sellable()
        product = sellable3.product
        sellable.tax_constant = SellableTaxConstant(
            description=u"18",
            tax_type=int(TaxType.CUSTOM),
            tax_value=18,
            store=self.store)

        sale.add_sellable(sellable3, quantity=1)

        self.create_storable(product, get_current_branch(self.store), stock=100)

        sale.order()

        method = PaymentMethod.get_by_name(self.store, u'money')
        method.create_payment(Payment.TYPE_IN, sale.group, sale.branch,
                              sale.get_sale_subtotal())

        sale.confirm()
        sale.group.pay()
        sale.close_date = localdate(2007, 6, 10).date()
        sale.confirm_date = localdate(2007, 6, 10).date()
        sellable3.code = u'09999'

        inventory = Inventory(branch=branch, store=self.store)
        inventory.open_date = localdate(2007, 6, 15).date()

        # product came from sellable3
        inventory_item = InventoryItem(product=product,
                                       product_cost=product.sellable.cost,
                                       inventory=inventory,
                                       recorded_quantity=99,
                                       store=self.store)
        inventory_item.cfop_data = self.store.get(CfopData, 1)
        inventory_item.reason = u'Test'
        inventory_item.actual_quantity = 99
        inventory_item.adjust(invoice_number=999)
        inventory.close(close_date=localdate(2007, 6, 15).date())

        generator = StoqlibSintegraGenerator(self.store,
                                             localdate(2007, 6, 1).date(),
                                             localdate(2007, 6, 30).date())

        try:
            compare_sintegra_file(generator.sintegra, 'sintegra-receival')
        except AssertionError as e:
            self.fail(e)
Esempio n. 4
0
 def create_inventory(self, branch=None):
     from stoqlib.domain.inventory import Inventory
     branch = branch or self.create_branch(u"Main")
     return Inventory(branch=branch, store=self.store)