Ejemplo n.º 1
0
    def testGetTax(self):
        """
        """
        t = ITaxes(self.item1)
        tax = "%.2f" % t.getTax()
        self.assertEqual(tax, "7.03")

        t = ITaxes(self.item2)
        tax = "%.2f" % t.getTax()
        self.assertEqual(tax, "9.10")
Ejemplo n.º 2
0
    def testGetTax(self):
        """
        """
        t = ITaxes(self.item1)
        tax = "%.2f" % t.getTax()
        self.assertEqual(tax, "7.03")

        t = ITaxes(self.item2)
        tax = "%.2f" % t.getTax()
        self.assertEqual(tax, "9.10")
Ejemplo n.º 3
0
 def getTax(self):
     """
     """
     temp_payment_product = self._createTemporaryPaymentProduct()
     taxes = ITaxes(temp_payment_product)
     tax = taxes.getTax()
     return tax
Ejemplo n.º 4
0
 def getTax(self):
     """
     """
     temp_payment_product = self._createTemporaryPaymentProduct()
     taxes = ITaxes(temp_payment_product)        
     tax = taxes.getTax()
     return tax
Ejemplo n.º 5
0
    def getTax(self):
        """
        """
        im = IItemManagement(self.context)
        if im.hasItems() == False:
            return 0.0

        tax = 0.0
        for cart_item in im.getItems():
            taxes = ITaxes(cart_item)
            tax += taxes.getTax()

        # Get shop
        shop = IShopManagement(self.context).getShop()

        # Shipping
        tax += IShippingPriceManagement(shop).getTax()

        # Payment
        tax += IPaymentPriceManagement(shop).getTax()

        return tax
Ejemplo n.º 6
0
    def getTax(self):
        """
        """
        im = IItemManagement(self.context)
        if im.hasItems() == False:
            return 0.0
            
        tax = 0.0        
        for cart_item in im.getItems():
            taxes = ITaxes(cart_item)
            tax += taxes.getTax()

        # Get shop
        shop = IShopManagement(self.context).getShop()
        
        # Shipping
        tax += IShippingPriceManagement(shop).getTax()

        # Payment
        tax += IPaymentPriceManagement(shop).getTax()
        
        return tax
Ejemplo n.º 7
0
 def testGetTax(self):
     """
     """
     t = ITaxes(self.shop.products.product_1)
     self.assertEqual("%.2f" % t.getTax(), "3.51")
Ejemplo n.º 8
0
class ProductPrices(object):
    """Provides IPrices for product content object.
    """
    implements(IPrices)
    adapts(IProduct)

    def __init__(self, context):
        """
        """
        pvm  = IProductVariantsManagement(context)
        shop = IShopManagement(context).getShop()
        
        self.context = context

        self.gross_prices = shop.getGrossPrices()
        self.has_variants = pvm.hasVariants()
        self.taxes = ITaxes(context)

        if self.has_variants:
            self.product_variant = \
                pvm.getSelectedVariant() or pvm.getDefaultVariant()
                                   
    def getPriceForCustomer(self, effective=True, variant_price=True):
        """
        """
        if self.has_variants and variant_price and \
           self.product_variant.getPrice() != 0:
            return IPrices(self.product_variant).getPriceForCustomer(effective)
        else:
            if effective == True:
                return self._getEffectivePriceForCustomer()
            else:
                return self._getStandardPriceForCustomer()
            
    def getPriceNet(self, effective=True, variant_price=True):
        """
        """
        if self.has_variants and variant_price and \
           self.product_variant.getPrice() != 0:
            return IPrices(self.product_variant).getPriceNet(effective)
        else:
            if effective == True:
                return self._getEffectivePriceNet()
            else:
                return self._getStandardPriceNet()

    def getPriceGross(self, effective=True, variant_price=True):
        """
        """
        if self.has_variants and variant_price and \
           self.product_variant.getPrice() != 0:
            return IPrices(self.product_variant).getPriceGross(effective)
        else:
            if effective == True:
                return self._getEffectivePriceGross()
            else:
                return self._getStandardPriceGross()

    # Effective Price
    def _getEffectivePriceForCustomer(self):
        """Returns the effective price for customer, dependend of the product 
        is for sale or not.
        """
        tax_abs_customer = self.taxes.getTaxForCustomer()
        return self._getEffectivePriceNet() + tax_abs_customer

    def _getEffectivePriceNet(self):
        """Returns the effective price for customer, dependend of the product 
        is for sale or not.
        """
        if self.context.getForSale() == True:
            price = self.context.getSalePrice()
        else:
            price = self.context.getPrice()
        
        if self.gross_prices == True:
            return price - self.taxes.getTax()
        else:
            return price

    def _getEffectivePriceGross(self):
        """Returns the effective price for customer, dependend of the product 
        is for sale or not.
        """
        if self.context.getForSale() == True:
            price = self.context.getSalePrice()
        else:
            price = self.context.getPrice()
            
        if self.gross_prices == True:
            return price
        else:
            return price + self.taxes.getTax()

    # Standard Price
    def _getStandardPriceForCustomer(self):
        """Returns always the standard price, independent of the product is for 
        sale or not. We need this in any case to display the standard price 
        (e.g. stroked).
        """
        tax_abs_customer = self.taxes.getTaxForCustomer(False)
        return self._getStandardPriceNet() + tax_abs_customer

    def _getStandardPriceNet(self):
        """Returns always the standard price, independent of the product is for 
        sale or not. We need this in any case to display the standard price 
        (e.g. stroked).
        """
        if self.gross_prices == True:
            return self.context.getPrice() - self.taxes.getTax(False)
        else:
            return self.context.getPrice()

    def _getStandardPriceGross(self):
        """Returns always the standard price, independent of the product is for 
        sale or not. We need this in any case to display the standard price 
        (e.g. stroked).
        """
        if self.gross_prices == True:
            return self.context.getPrice()
        else:
            return self.context.getPrice() + self.taxes.getTax(False)
Ejemplo n.º 9
0
class ProductPrices(object):
    """Provides IPrices for product content object.
    """
    implements(IPrices)
    adapts(IProduct)

    def __init__(self, context):
        """
        """
        pvm = IProductVariantsManagement(context)
        shop = IShopManagement(context).getShop()

        self.context = context

        self.gross_prices = shop.getGrossPrices()
        self.has_variants = pvm.hasVariants()
        self.taxes = ITaxes(context)

        if self.has_variants:
            self.product_variant = \
                pvm.getSelectedVariant() or pvm.getDefaultVariant()

    def getPriceForCustomer(self, effective=True, variant_price=True):
        """
        """
        if self.has_variants and variant_price and \
           self.product_variant.getPrice() != 0:
            return IPrices(self.product_variant).getPriceForCustomer(effective)
        else:
            if effective == True:
                return self._getEffectivePriceForCustomer()
            else:
                return self._getStandardPriceForCustomer()

    def getPriceNet(self, effective=True, variant_price=True):
        """
        """
        if self.has_variants and variant_price and \
           self.product_variant.getPrice() != 0:
            return IPrices(self.product_variant).getPriceNet(effective)
        else:
            if effective == True:
                return self._getEffectivePriceNet()
            else:
                return self._getStandardPriceNet()

    def getPriceGross(self, effective=True, variant_price=True):
        """
        """
        if self.has_variants and variant_price and \
           self.product_variant.getPrice() != 0:
            return IPrices(self.product_variant).getPriceGross(effective)
        else:
            if effective == True:
                return self._getEffectivePriceGross()
            else:
                return self._getStandardPriceGross()

    # Effective Price
    def _getEffectivePriceForCustomer(self):
        """Returns the effective price for customer, dependend of the product 
        is for sale or not.
        """
        tax_abs_customer = self.taxes.getTaxForCustomer()
        return self._getEffectivePriceNet() + tax_abs_customer

    def _getEffectivePriceNet(self):
        """Returns the effective price for customer, dependend of the product 
        is for sale or not.
        """
        if self.context.getForSale() == True:
            price = self.context.getSalePrice()
        else:
            price = self.context.getPrice()

        if self.gross_prices == True:
            return price - self.taxes.getTax()
        else:
            return price

    def _getEffectivePriceGross(self):
        """Returns the effective price for customer, dependend of the product 
        is for sale or not.
        """
        if self.context.getForSale() == True:
            price = self.context.getSalePrice()
        else:
            price = self.context.getPrice()

        if self.gross_prices == True:
            return price
        else:
            return price + self.taxes.getTax()

    # Standard Price
    def _getStandardPriceForCustomer(self):
        """Returns always the standard price, independent of the product is for 
        sale or not. We need this in any case to display the standard price 
        (e.g. stroked).
        """
        tax_abs_customer = self.taxes.getTaxForCustomer(False)
        return self._getStandardPriceNet() + tax_abs_customer

    def _getStandardPriceNet(self):
        """Returns always the standard price, independent of the product is for 
        sale or not. We need this in any case to display the standard price 
        (e.g. stroked).
        """
        if self.gross_prices == True:
            return self.context.getPrice() - self.taxes.getTax(False)
        else:
            return self.context.getPrice()

    def _getStandardPriceGross(self):
        """Returns always the standard price, independent of the product is for 
        sale or not. We need this in any case to display the standard price 
        (e.g. stroked).
        """
        if self.gross_prices == True:
            return self.context.getPrice()
        else:
            return self.context.getPrice() + self.taxes.getTax(False)
Ejemplo n.º 10
0
 def testGetTax(self):
     """
     """
     t = ITaxes(self.cart)
     tax = "%.2f" % t.getTax()
     self.assertEqual(tax, "33.69")