def getShippingPrices(self): """ """ shop = IShopManagement(self.context).getShop() sm = IShippingPriceManagement(shop) cm = ICurrencyManagement(shop) result = [] for shipping_price in sm.getShippingPrices(): price = cm.priceToString(shipping_price.getPrice()) result.append({ "id": shipping_price.getId(), "title": shipping_price.Title(), "description": shipping_price.Description(), "price": price, "url": shipping_price.absolute_url(), "up_url": "%s/es_folder_position?position=up&id=%s" % (self.context.absolute_url(), shipping_price.getId()), "down_url": "%s/es_folder_position?position=down&id=%s" % (self.context.absolute_url(), shipping_price.getId()), "amount_of_criteria": self._getAmountOfCriteria(shipping_price.getId()) }) return result
def getShippingPrices(self): """ """ shop = IShopManagement(self.context).getShop() sm = IShippingPriceManagement(shop) cm = ICurrencyManagement(shop) result = [] for shipping_price in sm.getShippingPrices(): price = cm.priceToString(shipping_price.getPrice()) result.append({ "id" : shipping_price.getId(), "title" : shipping_price.Title(), "description" : shipping_price.Description(), "price" : price, "url" : shipping_price.absolute_url(), "up_url" : "%s/es_folder_position?position=up&id=%s" % (self.context.absolute_url(), shipping_price.getId()), "down_url" : "%s/es_folder_position?position=down&id=%s" % (self.context.absolute_url(), shipping_price.getId()), "amount_of_criteria" : self._getAmountOfCriteria(shipping_price.getId()) }) return result
class TestShopShippingManagement(EasyShopTestCase): """ """ def afterSetUp(self): """ """ super(TestShopShippingManagement, self).afterSetUp() self.shop.taxes.invokeFactory("CustomerTax", id="customer", rate=10.0) self.sm = IShippingPriceManagement(self.shop) def testGetShippingPrice(self): """ """ price = self.sm.getShippingPrice("default") self.assertEqual(price.getPrice(), 10.0) def testGetShippingPrices(self): """ """ self.shop.shippingprices.invokeFactory("ShippingPrice", "s1") self.shop.shippingprices.invokeFactory("ShippingPrice", "s2") self.shop.shippingprices.invokeFactory("ShippingPrice", "s3") self.shop.shippingprices.invokeFactory("ShippingPrice", "s4") ids = [p.getId() for p in self.sm.getShippingPrices()] self.assertEqual(ids, ["default", "s1", "s2", "s3", "s4"]) def testGetPriceGross(self): """ """ self.assertEqual(self.sm.getPriceGross(), 10.0) def testGetTaxRate(self): """ """ self.assertEqual(self.sm.getTaxRate(), 19.0) def testGetTaxRateForCustomer(self): """ """ self.assertEqual(self.sm.getTaxRateForCustomer(), 10.0) def testGetTax(self): """ """ self.assertEqual("%.2f" % self.sm.getTax(), "1.60") def testGetTaxForCustomer_1(self): """ """ self.assertEqual(self.sm.getTaxForCustomer(), 0) def testGetTaxForCustomer_2(self): """ """ self.login("newmember") view = getMultiAdapter((self.shop.products.product_1, self.shop.products.product_1.REQUEST), name="addToCart") view.addToCart() self.assertEqual("%.2f" % self.sm.getTaxForCustomer(), "0.84") def testGetPriceNet(self): """ """ self.assertEqual("%.2f" % self.sm.getPriceNet(), "8.40") def testGetPriceForCustomer_1(self): """ """ self.assertEqual(self.sm.getPriceForCustomer(), 0.0) def testGetPriceForCustomer_2(self): """ """ self.login("newmember") view = getMultiAdapter((self.shop.products.product_1, self.shop.products.product_1.REQUEST), name="addToCart") view.addToCart() self.assertEqual("%.2f" % self.sm.getPriceForCustomer(), "9.24") def testCreateTemporaryShippingProduct(self): """ """ product = self.sm._createTemporaryShippingProduct() self.assertEqual(product.getPrice(), 10.0) self.assertEqual(product.getId(), "shipping")
class TestShopShippingManagement(EasyShopTestCase): """ """ def afterSetUp(self): """ """ super(TestShopShippingManagement, self).afterSetUp() self.shop.taxes.invokeFactory("CustomerTax", id="customer", rate=10.0) self.sm = IShippingPriceManagement(self.shop) def testGetShippingPrice(self): """ """ price = self.sm.getShippingPrice("default") self.assertEqual(price.getPrice(), 10.0) def testGetShippingPrices(self): """ """ self.shop.shippingprices.invokeFactory("ShippingPrice", "s1") self.shop.shippingprices.invokeFactory("ShippingPrice", "s2") self.shop.shippingprices.invokeFactory("ShippingPrice", "s3") self.shop.shippingprices.invokeFactory("ShippingPrice", "s4") ids = [p.getId() for p in self.sm.getShippingPrices()] self.assertEqual(ids, ["default", "s1", "s2", "s3", "s4"]) def testGetPriceGross(self): """ """ self.assertEqual(self.sm.getPriceGross(), 10.0) def testGetTaxRate(self): """ """ self.assertEqual(self.sm.getTaxRate(), 19.0) def testGetTaxRateForCustomer(self): """ """ self.assertEqual(self.sm.getTaxRateForCustomer(), 10.0) def testGetTax(self): """ """ self.assertEqual("%.2f" % self.sm.getTax(), "1.60") def testGetTaxForCustomer_1(self): """ """ self.assertEqual(self.sm.getTaxForCustomer(), 0) def testGetTaxForCustomer_2(self): """ """ self.login("newmember") view = getMultiAdapter((self.shop.products.product_1, self.shop.products.product_1.REQUEST), name="addToCart") view.addToCart() self.assertEqual("%.2f" % self.sm.getTaxForCustomer(), "0.84") def testGetPriceNet(self): """ """ self.assertEqual("%.2f" % self.sm.getPriceNet(), "8.40") def testGetPriceForCustomer_1(self): """ """ self.assertEqual(self.sm.getPriceForCustomer(), 0.0) def testGetPriceForCustomer_2(self): """ """ self.login("newmember") view = getMultiAdapter((self.shop.products.product_1, self.shop.products.product_1.REQUEST), name="addToCart") view.addToCart() self.assertEqual("%.2f" % self.sm.getPriceForCustomer(), "9.24") def testCreateTemporaryShippingProduct(self): """ """ product = self.sm._createTemporaryShippingProduct() self.assertEqual(product.getPrice(), 10.0) self.assertEqual(product.getId(), "shipping")