def testGetPriceNet_2(self): """Test a properties which is just in groups """ pm = IPropertyManagement(self.shop.products.product_1) price = pm.getPriceNet("size", "Small") self.assertEqual("%.2f" % price, "-9.24") price = pm.getPriceNet("size", "Medium") self.assertEqual("%.2f" % price, "0.84") price = pm.getPriceNet("size", "Large") self.assertEqual("%.2f" % price, "18.49")
def testGetPriceNet_1(self): """Test a property which is in group and product """ pm = IPropertyManagement(self.shop.products.product_1) # Note that color prices are taken from product not from group price = pm.getPriceNet("color", "Red") self.assertEqual("%.2f" % price, "-8.40") price = pm.getPriceNet("color", "Blue") self.assertEqual(price, 0.0) price = pm.getPriceNet("color", "Green") self.assertEqual("%.2f" % price, "12.61")
def getPriceNet(self, with_discount=False): """Returns the net price for a cart item. This is just the net product price plus the properties net prices (can be positiv or negative) multiply with the amount. """ product = self.context.getProduct() price = IPrices(product).getPriceNet() pm = IPropertyManagement(product) for selected_property in self.context.getProperties(): price += pm.getPriceNet( selected_property["id"], selected_property["selected_option"] ) price *= self.context.getAmount() if with_discount == True: discount = IDiscountsCalculation(self.context).getDiscount() if discount is not None: discount_value = getMultiAdapter( (discount, self.context)).getPriceNet() price -= discount_value return price
def getPriceNet(self, with_discount=False): """Returns the net price for a cart item. This is just the net product price plus the properties net prices (can be positiv or negative) multiply with the amount. """ product = self.context.getProduct() price = IPrices(product).getPriceNet() pm = IPropertyManagement(product) for selected_property in self.context.getProperties(): price += pm.getPriceNet(selected_property["id"], selected_property["selected_option"]) price *= self.context.getAmount() if with_discount == True: discount = IDiscountsCalculation(self.context).getDiscount() if discount is not None: discount_value = getMultiAdapter( (discount, self.context)).getPriceNet() price -= discount_value return price