本文整理汇总了Python中stoqlib.domain.sellable.Sellable.max_discount方法的典型用法代码示例。如果您正苦于以下问题:Python Sellable.max_discount方法的具体用法?Python Sellable.max_discount怎么用?Python Sellable.max_discount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.sellable.Sellable
的用法示例。
在下文中一共展示了Sellable.max_discount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_category_name
# 需要导入模块: from stoqlib.domain.sellable import Sellable [as 别名]
# 或者: from stoqlib.domain.sellable.Sellable import max_discount [as 别名]
def test_category_name(self):
sellable = Sellable(category=None,
cost=50,
description=u"Test",
price=currency(100),
store=self.store)
sellable.max_discount = 0
cat = self.create_client_category(u'Cat 1')
cat_price = ClientCategoryPrice(sellable=sellable, category=cat,
price=150, max_discount=0,
store=self.store)
self.assertEqual(cat_price.category_name, u'Cat 1')
示例2: testIsValidPrice
# 需要导入模块: from stoqlib.domain.sellable import Sellable [as 别名]
# 或者: from stoqlib.domain.sellable.Sellable import max_discount [as 别名]
def testIsValidPrice(self):
sellable = Sellable(category=self._category, cost=50,
description=u"Test",
price=currency(100),
store=self.store)
sellable.max_discount = 0
cat = self.create_client_category(u'Cat 1')
cat_price = ClientCategoryPrice(sellable=sellable, category=cat,
price=150, max_discount=0,
store=self.store)
# without a category, and max_discount = 0
self.assertFalse(sellable.is_valid_price(0))
self.assertFalse(sellable.is_valid_price(-10))
self.assertFalse(sellable.is_valid_price(99))
self.assertTrue(sellable.is_valid_price(101))
self.assertTrue(sellable.is_valid_price(100))
# without a category, and max_discount = 10%
sellable.max_discount = 10
self.assertFalse(sellable.is_valid_price(0))
self.assertFalse(sellable.is_valid_price(-1))
self.assertFalse(sellable.is_valid_price(89))
self.assertTrue(sellable.is_valid_price(90))
self.assertTrue(sellable.is_valid_price(95))
self.assertTrue(sellable.is_valid_price(99))
self.assertTrue(sellable.is_valid_price(101))
# Now with a category, max_discount = 0
self.assertFalse(sellable.is_valid_price(0, cat))
self.assertFalse(sellable.is_valid_price(-10, cat))
self.assertFalse(sellable.is_valid_price(Decimal('149.99'), cat))
self.assertTrue(sellable.is_valid_price(150, cat))
self.assertTrue(sellable.is_valid_price(151, cat))
# Now with a category, max_discount = 10%
cat_price.max_discount = 10
self.assertTrue(sellable.is_valid_price(Decimal('149.99'), cat))
self.assertTrue(sellable.is_valid_price(135, cat))
self.assertFalse(sellable.is_valid_price(134, cat))
示例3: test_price_based_on_category_markup
# 需要导入模块: from stoqlib.domain.sellable import Sellable [as 别名]
# 或者: from stoqlib.domain.sellable.Sellable import max_discount [as 别名]
def test_price_based_on_category_markup(self):
# When the price isn't defined, but the category and the cost. In this
# case the sellable must have the price calculated applying the category's
# markup in the sellable's cost.
self._category.suggested_markup = 0
sellable = Sellable(description=u"MX123",
commission=0,
cost=100,
category=self._category,
store=self.store)
sellable.max_discount = 0
self.failUnless(sellable.markup == self._category.get_markup(),
(u"Expected markup: %r, got %r"
% (self._category.get_markup(),
sellable.markup)))
price = sellable.cost * (sellable.markup / currency(100) + 1)
self.failUnless(sellable.price == price,
(u"Expected price: %r, got %r"
% (price, sellable.price)))
示例4: test_is_valid_price
# 需要导入模块: from stoqlib.domain.sellable import Sellable [as 别名]
# 或者: from stoqlib.domain.sellable.Sellable import max_discount [as 别名]
def test_is_valid_price(self):
def isValidPriceAssert(valid_data, expected_validity, min_price,
max_discount):
self.assertEquals(valid_data['is_valid'], expected_validity)
self.assertEquals(valid_data['min_price'], min_price)
self.assertEquals(valid_data['max_discount'], max_discount)
sellable = Sellable(category=self._category, cost=50,
description=u"Test",
price=currency(100),
store=self.store)
sellable.max_discount = 0
cat = self.create_client_category(u'Cat 1')
cat_price = ClientCategoryPrice(sellable=sellable, category=cat,
price=150, max_discount=0,
store=self.store)
user = self.create_user()
user.profile.max_discount = 50
# without a category, and max_discount = 0, user = None
valid_data = sellable.is_valid_price(-10)
isValidPriceAssert(valid_data, False, sellable.price, 0)
valid_data = sellable.is_valid_price(0)
isValidPriceAssert(valid_data, False, sellable.price, 0)
valid_data = sellable.is_valid_price(99)
isValidPriceAssert(valid_data, False, sellable.price, 0)
valid_data = sellable.is_valid_price(100)
isValidPriceAssert(valid_data, True, sellable.price, 0)
valid_data = sellable.is_valid_price(101)
isValidPriceAssert(valid_data, True, sellable.price, 0)
# without a category, and max_discount = 10%
sellable.max_discount = 10
valid_data = sellable.is_valid_price(-1)
isValidPriceAssert(valid_data, False, currency(90), 10)
valid_data = sellable.is_valid_price(0)
isValidPriceAssert(valid_data, False, currency(90), 10)
valid_data = sellable.is_valid_price(89)
isValidPriceAssert(valid_data, False, currency(90), 10)
valid_data = sellable.is_valid_price(90)
isValidPriceAssert(valid_data, True, currency(90), 10)
valid_data = sellable.is_valid_price(91)
isValidPriceAssert(valid_data, True, currency(90), 10)
# Now with a category, max_discount = 0
valid_data = sellable.is_valid_price(0, cat)
isValidPriceAssert(valid_data, False, currency(150), 0)
valid_data = sellable.is_valid_price(-10, cat)
isValidPriceAssert(valid_data, False, currency(150), 0)
valid_data = sellable.is_valid_price(Decimal('149.99'), cat)
isValidPriceAssert(valid_data, False, currency(150), 0)
valid_data = sellable.is_valid_price(150, cat)
isValidPriceAssert(valid_data, True, currency(150), 0)
valid_data = sellable.is_valid_price(151, cat)
isValidPriceAssert(valid_data, True, currency(150), 0)
# Now with a category, max_discount = 10%
cat_price.max_discount = 10
valid_data = sellable.is_valid_price(Decimal('149.99'), cat)
isValidPriceAssert(valid_data, True, currency(135), 10)
valid_data = sellable.is_valid_price(135, cat)
isValidPriceAssert(valid_data, True, currency(135), 10)
valid_data = sellable.is_valid_price(134, cat)
isValidPriceAssert(valid_data, False, currency(135), 10)
# with a user
valid_data = sellable.is_valid_price(49, None, user)
isValidPriceAssert(valid_data, False, currency(50), 50)
valid_data = sellable.is_valid_price(50, None, user)
isValidPriceAssert(valid_data, True, currency(50), 50)