示例#1
0
    def test_calculate_item(self):
        # Product with NCM, EX TIPI and ICMS
        sale_item = self.create_sale_item()
        sale_item.price = 150
        product = sale_item.sellable.product
        product.ncm = u'39269090'
        product.ex_tipi = u'001'

        # Create ICMS tax
        tax = ProductTaxTemplate(store=self.store, name=u'Test')
        icms = ProductIcmsTemplate(store=self.store, product_tax_template=tax)
        # Values (0, 3, 4, 5, 8) - taxes codes of brazilian origin.
        # Different values represent taxes of international origin.
        icms.orig = 0
        product.icms_template = icms

        # Values used from IBPT table. Change this values when update the taxes.
        # codigo;ex;tabela;descricao;aliqNac;aliqImp;
        # 39269090;01;0;Ex 01 - Forma para fabricação de calçados;20.11;29.27;
        expected_tax = sale_item.price * (Decimal("20.11") / 100)
        tax_value = calculate_tax_for_item(sale_item)
        self.assertEqual(tax_value, Decimal(expected_tax))

        # With tax of international origin.
        icms.orig = 1
        expected_tax = sale_item.price * (Decimal("29.27") / 100)
        tax_value = calculate_tax_for_item(sale_item)
        self.assertEqual(tax_value, Decimal(expected_tax))
示例#2
0
 def test_calculate_item_without_icms(self):
     # Product with NCM, but without ICMS
     sale_item = self.create_sale_item()
     product = sale_item.sellable.product
     product.ncm = u'01012100'
     tax_value = calculate_tax_for_item(sale_item)
     # When there is no icms information, the value defaults to the nacional
     # tax.
     self.assertEqual(tax_value, Decimal("26.75"))
示例#3
0
 def test_calculate_item_without_ncm(self):
     # Product without NCM
     sale_item = self.create_sale_item()
     tax_value = calculate_tax_for_item(sale_item)
     self.assertEqual(tax_value, Decimal("0"))
示例#4
0
 def _add_tax_for_item(self, item):
     tax_item = calculate_tax_for_item(item)
     self._total_taxes += tax_item