Exemplo n.º 1
0
    def testHasItems(self):
        """
        """
        self.logout()

        cm = ICartManagement(self.shop)
        cart = cm.createCart()
        
        im = IItemManagement(cart)

        self.assertEqual(im.hasItems(), False)
        im.addItem(self.product_1, properties=[])                
        self.assertEqual(im.hasItems(), True)
Exemplo n.º 2
0
    def getPriceNet(self,
                    with_shipping=True,
                    with_payment=True,
                    with_discount=True):
        """Returns the net price of the cart. This is just a sum over net
        prices of all items of the cart plus shipping and payment.
        """
        im = IItemManagement(self.context)
        if im.hasItems() == False:
            return 0.0

        price = 0.0
        for cart_item in im.getItems():
            # NOTE: with_discount is passed here
            price += IPrices(cart_item).getPriceNet(
                with_discount=with_discount)

        if with_shipping == True:
            sm = IShippingPriceManagement(self.shop)
            shipping_price = sm.getPriceNet()
            price += shipping_price

        if with_payment == True:
            sm = IPaymentPriceManagement(self.shop)
            payment_price = sm.getPriceNet()
            price += payment_price

        return price
Exemplo n.º 3
0
 def hasCartItems(self):
     """
     """
     cart = self._getCart()
     
     if cart is None:
         return False
         
     im = IItemManagement(cart)
     
     if im.hasItems():
         return True
     return False
Exemplo n.º 4
0
    def hasCartItems(self):
        """
        """
        cart = self._getCart()

        if cart is None:
            return False

        im = IItemManagement(cart)

        if im.hasItems():
            return True
        return False
Exemplo n.º 5
0
    def getPriceForCustomer(self):
        """
        """
        # If there a no items the shipping price for cutomers is zero.
        cart_manager = ICartManagement(self.context)
        cart = cart_manager.getCart()

        if cart is None:
            return 0

        cart_item_manager = IItemManagement(cart)
        if cart_item_manager.hasItems() == False:
            return 0

        return self.getPriceNet() + self.getTaxForCustomer()
Exemplo n.º 6
0
 def getPriceForCustomer(self):
     """
     """
     # If there a no items the payment price for cutomers is zero.
     cart_manager = ICartManagement(self.context)
     cart = cart_manager.getCart()        
     
     if cart is None:
         return 0
                 
     cart_item_manager = IItemManagement(cart)
     if cart_item_manager.hasItems() == False:
         return 0
             
     return self.getPriceNet() + self.getTaxForCustomer()
Exemplo n.º 7
0
    def getTaxForCustomer(self):
        """
        """
        # If there a no items the shipping tax is 0
        cart_manager = ICartManagement(self.context)
        cart = cart_manager.getCart()

        if cart is None:
            return 0

        cart_item_manager = IItemManagement(cart)
        if cart_item_manager.hasItems() == False:
            return 0

        temp_shipping_product = self._createTemporaryShippingProduct()
        return ITaxes(temp_shipping_product).getTaxForCustomer()
Exemplo n.º 8
0
    def getTaxForCustomer(self):
        """
        """
        # If there a no items the shipping tax is 0
        cart_manager = ICartManagement(self.context)
        cart = cart_manager.getCart()

        if cart is None:
            return 0

        cart_item_manager = IItemManagement(cart)
        if cart_item_manager.hasItems() == False:
            return 0

        temp_shipping_product = self._createTemporaryShippingProduct()
        return ITaxes(temp_shipping_product).getTaxForCustomer()
Exemplo n.º 9
0
    def isComplete(self):
        """Checks weather the customer is complete to checkout.
        
           Customer completeness means the customer is ready to check out:
             1. Invoice address is complete
             2. Shipping address is complete
             3. Selected payment method is complete
             4. There a items in the cart            
        """        
        # Get shop
        shop = IShopManagement(self.context).getShop()
        
        # Get shipping and invoice address
        adressman = IAddressManagement(self.context)
        
        s_addr = adressman.getShippingAddress()
        if s_addr is None: return False
        
        i_addr = adressman.getInvoiceAddress()
        if i_addr is None: return False

        # Get payment method
        payman = IPaymentManagement(self.context)
        paymeth = payman.getSelectedPaymentMethod()

        # Get cart of the customer
        cart = ICartManagement(shop).getCart()

        # If there is no cart, the customer hasn't selected a product, hence
        # he is not complete
        if cart is None:
            return False
            
        im = IItemManagement(cart)
        
        # Check all for completeness
        # if at least one is False customer is not complete, too.        
        for toCheck in s_addr, i_addr, paymeth:
            if ICompleteness(toCheck).isComplete() == False:
                return False
        
        # check items in cart
        if im.hasItems() == False:
            return False

        return True
Exemplo n.º 10
0
    def isComplete(self):
        """Checks weather the customer is complete to checkout.
        
           Customer completeness means the customer is ready to check out:
             1. Invoice address is complete
             2. Shipping address is complete
             3. Selected payment method is complete
             4. There a items in the cart            
        """
        # Get shop
        shop = IShopManagement(self.context).getShop()

        # Get shipping and invoice address
        adressman = IAddressManagement(self.context)

        s_addr = adressman.getShippingAddress()
        if s_addr is None: return False

        i_addr = adressman.getInvoiceAddress()
        if i_addr is None: return False

        # Get payment method
        payman = IPaymentManagement(self.context)
        paymeth = payman.getSelectedPaymentMethod()

        # Get cart of the customer
        cart = ICartManagement(shop).getCart()

        # If there is no cart, the customer hasn't selected a product, hence
        # he is not complete
        if cart is None:
            return False

        im = IItemManagement(cart)

        # Check all for completeness
        # if at least one is False customer is not complete, too.
        for toCheck in s_addr, i_addr, paymeth:
            if ICompleteness(toCheck).isComplete() == False:
                return False

        # check items in cart
        if im.hasItems() == False:
            return False

        return True
Exemplo n.º 11
0
    def getTaxForCustomer(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.getTaxForCustomer()

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

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

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

        return tax
Exemplo n.º 12
0
    def getTaxForCustomer(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.getTaxForCustomer()

        # Get shop
        shop = IShopManagement(self.context).getShop()
        
        # Shipping
        tax += IShippingPriceManagement(shop).getTaxForCustomer()
        
        # Payment
        tax += IPaymentPriceManagement(shop).getTaxForCustomer()
        
        return tax
Exemplo n.º 13
0
    def getPriceNet(self, with_shipping=True, with_payment=True, with_discount=True):
        """Returns the net price of the cart. This is just a sum over net
        prices of all items of the cart plus shipping and payment.
        """
        im = IItemManagement(self.context)
        if im.hasItems() == False:
            return 0.0
        
        price = 0.0
        for cart_item in im.getItems():
            # NOTE: with_discount is passed here
            price += IPrices(cart_item).getPriceNet(with_discount=with_discount)

        if with_shipping == True:
            sm = IShippingPriceManagement(self.shop)
            shipping_price = sm.getPriceNet()
            price += shipping_price        

        if with_payment == True:
            sm = IPaymentPriceManagement(self.shop)
            payment_price = sm.getPriceNet()
            price += payment_price

        return price