Esempio n. 1
0
 def testGetDefaultTaxes(self):
     """
     """
     tm = ITaxManagement(self.shop)
     ids = [t.getId() for t in tm.getDefaultTaxes()]
     
     self.assertEqual(ids, ["default", "d1", "d2", "d3", "d4"])
Esempio n. 2
0
    def testGetDefaultTaxes(self):
        """
        """
        tm = ITaxManagement(self.shop)
        ids = [t.getId() for t in tm.getDefaultTaxes()]

        self.assertEqual(ids, ["default", "d1", "d2", "d3", "d4"])
Esempio n. 3
0
    def getDefaultTaxes(self):
        """
        """
        tm = ITaxManagement(IShopManagement(self.context).getShop())
        nc = queryUtility(INumberConverter)

        result = []
        for tax in tm.getDefaultTaxes():
            result.append({
                "id":
                tax.getId(),
                "title":
                tax.Title(),
                "rate":
                nc.floatToTaxString(tax.getRate()),
                "up_link":
                "%s/es_folder_position?position=up&id=%s" %
                (self.context.absolute_url(), tax.getId()),
                "down_link":
                "%s/es_folder_position?position=down&id=%s" %
                (self.context.absolute_url(), tax.getId()),
                "url":
                tax.absolute_url(),
                "amount_of_criteria":
                self._getAmountOfCriteria(tax.getId()),
            })

        return result
Esempio n. 4
0
    def _calcTaxRateForProduct(self):
        """Calculates the default tax for a given product.
        """
        # Returns the first tax rate, which is true. Taxes are sorted by 
        # position which is also the priority
        tm = ITaxManagement(self.shop)
        for tax in tm.getDefaultTaxes():
            if IValidity(tax).isValid(self.context) == True:
                return tax.getRate()

        return 0
Esempio n. 5
0
    def _calcTaxRateForProduct(self):
        """Calculates the default tax for a given product.
        """
        # Returns the first tax rate, which is true. Taxes are sorted by
        # position which is also the priority
        tm = ITaxManagement(self.shop)
        for tax in tm.getDefaultTaxes():
            if IValidity(tax).isValid(self.context) == True:
                return tax.getRate()

        return 0
Esempio n. 6
0
 def getDefaultTaxes(self):
     """
     """
     tm = ITaxManagement(IShopManagement(self.context).getShop())
     nc = queryUtility(INumberConverter)
     
     result = []
     for tax in tm.getDefaultTaxes(): 
         result.append({
             "id"        : tax.getId(),
             "title"     : tax.Title(),
             "rate"      : nc.floatToTaxString(tax.getRate()),
             "up_link"   : "%s/es_folder_position?position=up&id=%s" % (self.context.absolute_url(), tax.getId()),
             "down_link" : "%s/es_folder_position?position=down&id=%s" % (self.context.absolute_url(), tax.getId()),
             "url"       : tax.absolute_url(),
             "amount_of_criteria" : self._getAmountOfCriteria(tax.getId()),
         })
     
     return result