Esempio n. 1
0
    def testIsPCredSnValid(self):
        tax_template = ProductTaxTemplate(
            store=self.store, tax_type=ProductTaxTemplate.TYPE_ICMS)
        icms_template = ProductIcmsTemplate(store=self.store,
                                            product_tax_template=tax_template)

        self.assertTrue(icms_template.is_p_cred_sn_valid())

        expire_date = localnow()
        icms_template.p_cred_sn_valid_until = expire_date
        self.assertTrue(icms_template.is_p_cred_sn_valid())

        expire_date = localnow() + relativedelta(days=+1)
        icms_template.p_cred_sn_valid_until = expire_date
        self.assertTrue(icms_template.is_p_cred_sn_valid())

        expire_date = localnow() + relativedelta(days=-1)
        icms_template.p_cred_sn_valid_until = expire_date
        self.assertFalse(icms_template.is_p_cred_sn_valid())
Esempio n. 2
0
    def test_is_p_cred_sn_valid(self):
        tax_template = ProductTaxTemplate(
            store=self.store,
            tax_type=ProductTaxTemplate.TYPE_ICMS)
        icms_template = ProductIcmsTemplate(
            store=self.store,
            product_tax_template=tax_template)

        self.assertTrue(icms_template.is_p_cred_sn_valid())

        expire_date = localnow()
        icms_template.p_cred_sn_valid_until = expire_date
        self.assertTrue(icms_template.is_p_cred_sn_valid())

        expire_date = localnow() + relativedelta(days=+1)
        icms_template.p_cred_sn_valid_until = expire_date
        self.assertTrue(icms_template.is_p_cred_sn_valid())

        expire_date = localnow() + relativedelta(days=-1)
        icms_template.p_cred_sn_valid_until = expire_date
        self.assertFalse(icms_template.is_p_cred_sn_valid())
Esempio n. 3
0
    def test_check_taxes_validity(self):
        sellable = self.create_sellable()
        sellable.check_taxes_validity(self.current_branch)

        tax = ProductTaxTemplate(store=self.store, name=u'foo')
        template = ProductIcmsTemplate(store=self.store, product_tax_template=tax)
        sellable.product.set_icms_template(template)

        sellable.check_taxes_validity(self.current_branch)

        template.p_cred_sn = 10
        template.p_cred_sn_valid_until = localdate(2000, 1, 1)

        with self.assertRaises(TaxError) as e:
            sellable.check_taxes_validity(self.current_branch)
            self.assertEqual(str(e), ("You cannot sell this item before updating "
                                      "the 'ICMS tax rate credit' field on 'foo' "
                                      "Tax Class.\n"
                                      "If you don't know what this means, contact "
                                      "the system administrator."))