コード例 #1
0
ファイル: product.py プロジェクト: Easyshop/Easyshop
 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
ファイル: product.py プロジェクト: Easyshop/Easyshop
    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)
コード例 #16
0
 def testGetPriceForCustomer(self):
     """
     """
     p = IPrices(self.shop.products.product_1)
     self.assertEqual("%.2f" % p.getPriceForCustomer(), "20.34")
コード例 #17
0
ファイル: categories.py プロジェクト: viona/Easyshop
    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)
コード例 #20
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)
コード例 #24
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
ファイル: test_adapter_cart.py プロジェクト: viona/Easyshop
 def testGetPriceGross(self):
     """
     """
     p = IPrices(self.cart)
     self.assertEqual(p.getPriceGross(), 111.00)
コード例 #29
0
ファイル: test_adapter_cart.py プロジェクト: viona/Easyshop
 def testGetPriceNet(self):
     """
     """
     p = IPrices(self.cart)
     price_net = "%.2f" % p.getPriceNet()
     self.assertEqual(price_net, "93.28")
コード例 #30
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")
コード例 #31
0
ファイル: test_adapter_cart.py プロジェクト: viona/Easyshop
 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")