예제 #1
0
 def getBasePrice(self):
     """
     """
     p = IPrices(self.context)
     price = p.getPriceGross()
     
     cm = ICurrencyManagement(self.context)        
     return cm.priceToString(price)
예제 #2
0
    def testGetPriceGross(self):
        """
        """
        p = IPrices(self.item1)
        self.assertEqual(p.getPriceGross(), 44.0)

        p = IPrices(self.item2)
        self.assertEqual(p.getPriceGross(), 57.0)
예제 #3
0
    def testGetPriceForCustomer(self):
        """
        """
        p = IPrices(self.item1)
        self.assertEqual("%.2f" % p.getPriceForCustomer(), "44.00")

        p = IPrices(self.item2)
        self.assertEqual(p.getPriceForCustomer(), 57.0)
예제 #4
0
    def getBasePrice(self):
        """
        """
        p = IPrices(self.context)
        price = p.getPriceGross()

        cm = ICurrencyManagement(self.context)
        return cm.priceToString(price)
예제 #5
0
    def testGetPriceNet(self):
        """
        """
        p = IPrices(self.item1)
        price_net = "%.2f" % p.getPriceNet()
        self.assertEqual(price_net, "36.97")

        p = IPrices(self.item2)
        price_net = "%.2f" % p.getPriceNet()
        self.assertEqual(price_net, "47.90")
예제 #6
0
    def getPriceForCustomer(self):
        """Returns the price for the customer.
        """
        price = IPrices(self.context).getPriceForCustomer()
        cm = ICurrencyManagement(self.context)

        return cm.priceToString(price, symbol="symbol", position="before")
예제 #7
0
    def getCurrentPrice(self):
        """
        """
        pm = IPropertyManagement(self.context)

        total_diff = 0.0
        for property_id, selected_option in self.request.form.items():
            if property_id.startswith("property"):
                total_diff += pm.getPriceForCustomer(property_id[9:],
                                                     selected_option)

        p = IPrices(self.context)
        price = p.getPriceGross() + total_diff

        cm = ICurrencyManagement(self.context)
        return cm.priceToString(price)
예제 #8
0
    def getCurrentPrice(self):
        """
        """
        pm = IPropertyManagement(self.context)
        
        total_diff = 0.0
        for property_id, selected_option in self.request.form.items():
            if property_id.startswith("property"):                
                total_diff += pm.getPriceForCustomer(
                    property_id[9:], 
                    selected_option
                )

        p = IPrices(self.context)
        price = p.getPriceGross() + total_diff

        cm = ICurrencyManagement(self.context)        
        return cm.priceToString(price)
예제 #9
0
    def testGetPriceGross(self):
        """
        """
        p = IPrices(self.item1)
        self.assertEqual(p.getPriceGross(), 44.0)

        p = IPrices(self.item2)
        self.assertEqual(p.getPriceGross(), 57.0)
예제 #10
0
    def testGetPriceForCustomer(self):
        """
        """
        p = IPrices(self.item1)
        self.assertEqual("%.2f" % p.getPriceForCustomer(), "44.00")

        p = IPrices(self.item2)
        self.assertEqual(p.getPriceForCustomer(), 57.0)
예제 #11
0
    def testGetPriceNet(self):
        """
        """
        p = IPrices(self.item1)
        price_net = "%.2f" % p.getPriceNet()
        self.assertEqual(price_net, "36.97")

        p = IPrices(self.item2)
        price_net = "%.2f" % p.getPriceNet()
        self.assertEqual(price_net, "47.90")
예제 #12
0
 def testGetPriceNet(self):
     """
     """
     p = IPrices(self.shop.products.product_1)
     self.assertEqual("%.2f" % p.getPriceNet(), "18.49")
예제 #13
0
 def testGetPriceNet(self):
     """
     """
     pp = IPrices(self.item1)
     price_net = "%.2f" % pp.getPriceNet()
     self.assertEqual(price_net, "3811.76")
예제 #14
0
 def testGetPriceGross(self):
     """
     """
     pp = IPrices(self.item1)
     self.assertEqual(pp.getPriceGross(), 4536.0)
예제 #15
0
 def testGetPriceForCustomer(self):
     """
     """
     pp = IPrices(self.item1)
     self.assertEqual(pp.getPriceForCustomer(), 4536.0)
 def testGetPriceForCustomer(self):
     """
     """
     p = IPrices(self.shop.products.product_1)
     self.assertEqual("%.2f" % p.getPriceForCustomer(), "20.34")
예제 #17
0
    def getInfo(self):
        """
        """
        products_per_line = self.getFormatInfo().get("products_per_line")

        batch = self._getBatch()
        # This optimized for speed, as we need _getBatch here anyway.
        # So there is no need of an extra method call within the page
        # template to get informations we have here already. Same is true
        # for format infos, see below
        batch_infos = {
            "previous_url": self._getPreviousUrl(batch),
            "previous": batch.previous,
            "next_url": self._getNextUrl(batch),
            "next": batch.next,
            "last_url": self._getLastUrl(batch),
            "navigation_list": batch.navlist,
            "number_of_pages": batch.numpages,
            "page_number": batch.pagenumber,
        }

        sorting = self.request.get("sorting", None)

        f = self.getFormatInfo()

        line = []
        products = []
        for index, product in enumerate(batch):

            cm = ICurrencyManagement(self.context)
            price = IPrices(product).getPriceForCustomer()
            price = cm.priceToString(price, symbol="symbol", position="before")

            # photo
            image = IPhotoManagement(product).getMainPhoto()
            if image is not None:
                image = "%s/image_%s" % (image.absolute_url(),
                                         f.get("image_size"))

            # properties view
            property_manager = IPropertyManagement(product)
            if len(property_manager.getProperties()) > 0:
                showSelectPropertiesView = True
            else:
                showSelectPropertiesView = False

            t = f.get("text")
            if t == "description":
                text = product.getDescription()
            elif t == "short_text":
                text = product.getShortText()
            elif t == "text":
                text = product.getText()
            else:
                text = ""

            if (index + 1) % products_per_line == 0 and products_per_line > 1:
                klass = "last"
            else:
                klass = "notlast"

            line.append({
                "title":
                product.Title(),
                "short_title":
                product.getShortTitle() or product.Title(),
                "text":
                text,
                "url":
                "%s?sorting=%s" % (product.absolute_url(), sorting),
                "image":
                image,
                "price":
                price,
                "showSelectPropertiesView":
                showSelectPropertiesView,
                "class":
                klass,
            })

            if (index + 1) % products_per_line == 0:
                products.append(line)
                line = []

        # the rest
        products.append(line)

        # Return format infos here, because we need it anyway in this method
        # This is for speed reasons. See above.
        return {
            "products": products,
            "batch_info": batch_infos,
            "format_info": f,
        }
예제 #18
0
 def testGetPriceGross(self):
     """
     """
     p = IPrices(self.order)
     self.assertEqual("%.2f" % p.getPriceGross(), "151.00")
예제 #19
0
 def testGetPriceGross(self):
     """
     """
     p = IPrices(self.shop.products.product_1)
     self.assertEqual(p.getPriceGross(), 22.0)
 def testGetPriceNet(self):
     """
     """
     p = IPrices(self.shop.products.product_1)
     self.assertEqual("%.2f" % p.getPriceNet(), "18.49")
예제 #21
0
 def testGetPriceNet(self):
     """
     """
     pp = IPrices(self.item1)
     price_net = "%.2f" % pp.getPriceNet()
     self.assertEqual(price_net, "3811.76")
예제 #22
0
 def testGetPriceGross(self):
     """
     """
     pp = IPrices(self.item1)
     self.assertEqual(pp.getPriceGross(), 4536.0)
예제 #23
0
 def testGetPriceForCustomer(self):
     """
     """
     pp = IPrices(self.item1)
     self.assertEqual(pp.getPriceForCustomer(), 4536.0)
 def testGetPriceGross(self):
     """
     """
     p = IPrices(self.shop.products.product_1)
     self.assertEqual(p.getPriceGross(), 22.0)
예제 #25
0
 def testGetPriceNet(self):
     """
     """
     p = IPrices(self.order)
     self.assertEqual("%.2f" % p.getPriceNet(), "126.89")
예제 #26
0
 def testGetPriceForCustomer(self):
     """
     """
     p = IPrices(self.shop.products.product_1)
     self.assertEqual("%.2f" % p.getPriceForCustomer(), "20.34")
예제 #27
0
 def testGetPriceForCustomer(self):
     """
     """
     p = IPrices(self.order)
     self.assertEqual("%.2f" % p.getPriceForCustomer(), "151.00")
예제 #28
0
 def testGetPriceGross(self):
     """
     """
     p = IPrices(self.cart)
     self.assertEqual(p.getPriceGross(), 111.00)
예제 #29
0
 def testGetPriceNet(self):
     """
     """
     p = IPrices(self.cart)
     price_net = "%.2f" % p.getPriceNet()
     self.assertEqual(price_net, "93.28")
 def testGetPriceForCustomer(self):
     """Customer has same tax rate as default
     """
     p = IPrices(self.shop.products.product_1)
     self.assertEqual("%.2f" % p.getPriceForCustomer(), "22.00")
예제 #31
0
 def testGetPriceForCustomer(self):
     """
     """
     p = IPrices(self.cart)
     # products + shipping (no payment, atm)
     self.assertEqual(p.getPriceForCustomer(), 111.00)
예제 #32
0
 def testGetPriceForCustomer(self):
     """Customer has same tax rate as default
     """
     p = IPrices(self.shop.products.product_1)
     self.assertEqual("%.2f" % p.getPriceForCustomer(), "22.00")