Ejemplo n.º 1
0
    def confirm(self):
        for item in self.get_items():
            item.add_stock_items()

        FiscalBookEntry.create_product_entry(self.store, self.purchase.group,
                                             self.cfop, self.invoice_number,
                                             self.icms_total, self.ipi_total)
        self.invoice_total = self.get_total()
        if self.purchase.can_close():
            self.purchase.close()
Ejemplo n.º 2
0
    def confirm(self):
        for item in self.get_items():
            item.add_stock_items()

        FiscalBookEntry.create_product_entry(
            self.store, self.purchase.group, self.cfop, self.invoice_number, self.icms_total, self.ipi_total
        )
        self.invoice_total = self.get_total()
        if self.purchase.can_close():
            self.purchase.close()
Ejemplo n.º 3
0
    def confirm(self):
        self.invoice_total = self.total
        if self.group:
            self.group.confirm()
        for receiving in self.receiving_orders:
            receiving.invoice_number = self.invoice_number

        # XXX: Maybe FiscalBookEntry should not reference the payment group, but
        # lets keep this way for now until we refactor the fiscal book related
        # code, since it will pretty soon need a lot of changes.
        group = self.group or self.get_purchase_orders().pop().group
        FiscalBookEntry.create_product_entry(
            self.store, group, receiving.cfop, self.invoice_number,
            self.icms_total, self.ipi_total)
Ejemplo n.º 4
0
    def confirm(self):
        self.invoice_total = self.total
        if self.group:
            self.group.confirm()
        for receiving in self.receiving_orders:
            receiving.invoice_number = self.invoice_number

        # XXX: Maybe FiscalBookEntry should not reference the payment group, but
        # lets keep this way for now until we refactor the fiscal book related
        # code, since it will pretty soon need a lot of changes.
        group = self.group or self.get_purchase_orders().pop().group
        FiscalBookEntry.create_product_entry(self.store, group, receiving.cfop,
                                             self.invoice_number,
                                             self.icms_total, self.ipi_total)
Ejemplo n.º 5
0
 def _add_inventory_fiscal_entry(self, invoice_number):
     inventory = self.inventory
     return FiscalBookEntry(entry_type=FiscalBookEntry.TYPE_INVENTORY,
                            invoice_number=inventory.invoice_number,
                            branch=inventory.branch,
                            cfop=self.cfop_data,
                            store=self.store)
Ejemplo n.º 6
0
 def testCreateProductEntry(self):
     sale = self.create_sale()
     sale.add_sellable(self.create_sellable(), price=150)
     book_entry = FiscalBookEntry.create_product_entry(
         self.store, sale.group, sale.cfop, sale.coupon_id, 123)
     self.failUnless(book_entry)
     self.assertEquals(book_entry.icms_value, 123)
     self.assertEquals(book_entry.entry_type, FiscalBookEntry.TYPE_PRODUCT)
Ejemplo n.º 7
0
    def confirm(self):
        for item in self.get_items():
            item.add_stock_items()

        purchases = list(self.purchase_orders)
        # XXX: Maybe FiscalBookEntry should not reference the payment group, but
        # lets keep this way for now until we refactor the fiscal book related
        # code, since it will pretty soon need a lot of changes.
        group = purchases[0].group
        FiscalBookEntry.create_product_entry(self.store, group, self.cfop,
                                             self.invoice_number,
                                             self.icms_total, self.ipi_total)

        self.invoice_total = self.total

        for purchase in purchases:
            if purchase.can_close():
                purchase.close()
Ejemplo n.º 8
0
 def testCreateServiceEntry(self):
     sale = self.create_sale()
     sale.add_sellable(self.create_sellable(), price=150)
     book_entry = FiscalBookEntry.create_service_entry(
         self.store, sale.group, sale.cfop, sale.service_invoice_number,
         123)
     self.failUnless(book_entry)
     self.assertEquals(book_entry.iss_value, 123)
     self.assertEquals(book_entry.entry_type, FiscalBookEntry.TYPE_SERVICE)
Ejemplo n.º 9
0
 def test_create_service_entry(self):
     sale = self.create_sale()
     sale.add_sellable(self.create_sellable(), price=150)
     book_entry = FiscalBookEntry.create_service_entry(
         self.store, self.current_branch, self.current_user, sale.group,
         sale.cfop, sale.service_invoice_number, 123)
     self.assertTrue(book_entry)
     self.assertEqual(book_entry.iss_value, 123)
     self.assertEqual(book_entry.entry_type, FiscalBookEntry.TYPE_SERVICE)
Ejemplo n.º 10
0
 def test_create_product_entry(self):
     sale = self.create_sale()
     sale.add_sellable(self.create_sellable(), price=150)
     book_entry = FiscalBookEntry.create_product_entry(
         self.store, self.current_branch, self.current_user, sale.group,
         sale.cfop, sale.coupon_id, 123)
     self.assertTrue(book_entry)
     self.assertEqual(book_entry.icms_value, 123)
     self.assertEqual(book_entry.entry_type, FiscalBookEntry.TYPE_PRODUCT)
Ejemplo n.º 11
0
    def confirm(self):
        for item in self.get_items():
            item.add_stock_items()

        purchases = list(self.purchase_orders)
        # XXX: Maybe FiscalBookEntry should not reference the payment group, but
        # lets keep this way for now until we refactor the fiscal book related
        # code, since it will pretty soon need a lot of changes.
        group = purchases[0].group
        FiscalBookEntry.create_product_entry(
            self.store, group, self.cfop, self.invoice_number, self.icms_total, self.ipi_total
        )

        self.invoice_total = self.total

        for purchase in purchases:
            if purchase.can_close():
                purchase.close()
Ejemplo n.º 12
0
 def test_default_return_sales_cfop(self):
     from stoqlib.domain.fiscal import FiscalBookEntry
     self._create_examples()
     wrong_param = self.sparam.get_object(self.store, 'DEFAULT_SALES_CFOP')
     drawee = Person(name=u'Antonione', store=self.store)
     group = self.create_payment_group()
     book_entry = FiscalBookEntry(entry_type=FiscalBookEntry.TYPE_SERVICE,
                                  invoice_number=123,
                                  cfop=wrong_param,
                                  branch=self.branch,
                                  drawee=drawee,
                                  payment_group=group,
                                  iss_value=1,
                                  icms_value=0,
                                  ipi_value=0,
                                  store=self.store)
     reversal = book_entry.reverse_entry(invoice_number=124)
     self.assertEqual(wrong_param, reversal.cfop)
Ejemplo n.º 13
0
 def test_default_return_sales_cfop(self):
     from stoqlib.domain.fiscal import FiscalBookEntry
     self._create_examples()
     wrong_param = self.sparam.get_object(self.store, 'DEFAULT_SALES_CFOP')
     drawee = Person(name=u'Antonione', store=self.store)
     group = self.create_payment_group()
     book_entry = FiscalBookEntry(
         entry_type=FiscalBookEntry.TYPE_SERVICE,
         invoice_number=123,
         cfop=wrong_param,
         branch=self.branch,
         drawee=drawee,
         payment_group=group,
         iss_value=1,
         icms_value=0,
         ipi_value=0,
         store=self.store)
     reversal = book_entry.reverse_entry(invoice_number=124)
     self.assertEqual(wrong_param, reversal.cfop)
Ejemplo n.º 14
0
 def test_create_product_entry(self):
     sale = self.create_sale()
     sale.add_sellable(self.create_sellable(), price=150)
     book_entry = FiscalBookEntry.create_product_entry(
         self.store,
         sale.group, sale.cfop, sale.coupon_id,
         123)
     self.assertTrue(book_entry)
     self.assertEqual(book_entry.icms_value, 123)
     self.assertEqual(book_entry.entry_type, FiscalBookEntry.TYPE_PRODUCT)
Ejemplo n.º 15
0
 def test_create_service_entry(self):
     sale = self.create_sale()
     sale.add_sellable(self.create_sellable(), price=150)
     book_entry = FiscalBookEntry.create_service_entry(
         self.store,
         sale.group,
         sale.cfop,
         sale.service_invoice_number,
         123)
     self.assertTrue(book_entry)
     self.assertEqual(book_entry.iss_value, 123)
     self.assertEqual(book_entry.entry_type, FiscalBookEntry.TYPE_SERVICE)
Ejemplo n.º 16
0
 def create_fiscal_book_entry(self, entry_type=None, icms_value=0,
                              iss_value=0, ipi_value=0,
                              invoice_number=None):
     from stoqlib.domain.payment.group import PaymentGroup
     from stoqlib.domain.fiscal import FiscalBookEntry
     payment_group = PaymentGroup(store=self.store)
     return FiscalBookEntry(invoice_number=invoice_number,
                            icms_value=icms_value,
                            iss_value=iss_value,
                            ipi_value=ipi_value,
                            entry_type=entry_type,
                            cfop=self.create_cfop_data(),
                            branch=self.create_branch(),
                            drawee=self.create_person(),
                            payment_group=payment_group,
                            store=self.store)