def testGetPriceGross_2(self): """Test a properties which is just in groups """ pm = IPropertyManagement(self.shop.products.product_1) price = pm.getPriceGross("size", "Small") self.assertEqual(price, -11.0) price = pm.getPriceGross("size", "Medium") self.assertEqual(price, 1.0) price = pm.getPriceGross("size", "Large") self.assertEqual(price, 22.0)
def testGetPriceGross_1(self): """Test a property which is in group and product. """ pm = IPropertyManagement(self.shop.products.product_1) price = pm.getPriceGross("color", "Red") self.assertEqual(price, -10.0) price = pm.getPriceGross("color", "Blue") self.assertEqual(price, 0.0) price = pm.getPriceGross("color", "Green") self.assertEqual(price, 15.0)
def testGetPriceGross_2(self): """Test a properties which is just in groups """ pm = IPropertyManagement(self.shop.products.product_1) price = pm.getPriceGross("size", "Small") self.assertEqual(price, -11.0) price = pm.getPriceGross("size", "Medium") self.assertEqual(price, 1.0) price = pm.getPriceGross("size", "Large") self.assertEqual(price, 22.0)
def testGetPriceGross_1(self): """Test a property which is in group and product. """ pm = IPropertyManagement(self.shop.products.product_1) price = pm.getPriceGross("color", "Red") self.assertEqual(price, -10.0) price = pm.getPriceGross("color", "Blue") self.assertEqual(price, 0.0) price = pm.getPriceGross("color", "Green") self.assertEqual(price, 15.0)
def getPriceGross(self, with_discount=False): """Returns the gross price for a cart item. This is just the gross product price plus the properties gross prices (can be positiv or negative) multiply with the amount. """ product = self.context.getProduct() price = IPrices(product).getPriceGross() pm = IPropertyManagement(product) for selected_property in self.context.getProperties(): price += pm.getPriceGross( 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)).getPriceGross() price -= discount_value return price
def getPriceGross(self, with_discount=False): """Returns the gross price for a cart item. This is just the gross product price plus the properties gross prices (can be positiv or negative) multiply with the amount. """ product = self.context.getProduct() price = IPrices(product).getPriceGross() pm = IPropertyManagement(product) for selected_property in self.context.getProperties(): price += pm.getPriceGross(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)).getPriceGross() price -= discount_value return price