本文整理汇总了Python中stoqlib.domain.sellable.Sellable.markup方法的典型用法代码示例。如果您正苦于以下问题:Python Sellable.markup方法的具体用法?Python Sellable.markup怎么用?Python Sellable.markup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.sellable.Sellable
的用法示例。
在下文中一共展示了Sellable.markup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_prices_and_markups
# 需要导入模块: from stoqlib.domain.sellable import Sellable [as 别名]
# 或者: from stoqlib.domain.sellable.Sellable import markup [as 别名]
def test_prices_and_markups(self):
self._category.markup = 0
sellable = Sellable(category=self._category, cost=50,
description=u"Test", price=currency(100),
store=self.store)
self.failUnless(sellable.price == 100,
u"Expected price: %r, got %r" % (100, sellable.price))
self.failUnless(sellable.markup == 100,
u"Expected markup: %r, got %r" % (100, sellable.markup))
sellable.markup = 10
self.failUnless(sellable.price == 55,
u"Expected price: %r, got %r" % (55, sellable.price))
sellable.price = 50
self.failUnless(sellable.markup == 0,
u"Expected markup %r, got %r" % (0, sellable.markup))
# When the price specified isn't equivalent to the markup specified.
# In this case the price don't must be updated based on the markup.
sellable = Sellable(cost=50,
description=u"Test", price=currency(100),
store=self.store)
self.failUnless(sellable.price == 100)
# A simple test: product without cost and price, markup must be 0
sellable.cost = currency(0)
sellable.price = currency(0)
self.failUnless(sellable.markup == 0,
u"Expected markup %r, got %r" % (0, sellable.markup))
示例2: test_price_based_on_specified_markup
# 需要导入模块: from stoqlib.domain.sellable import Sellable [as 别名]
# 或者: from stoqlib.domain.sellable.Sellable import markup [as 别名]
def test_price_based_on_specified_markup(self):
# When the price isn't defined, but the category, markup and the cost.
# In this case the category's markup must be ignored and the price
# calculated applying the markup specified in the sellable's cost.
sellable = Sellable(description=u"FY123",
category=self._category,
cost=100,
store=self.store)
sellable.markup = 5
self.assertEquals(sellable.markup, 5)
self.assertEquals(sellable.price, 105)
sellable.cost = Decimal('100.33')
sellable.markup = 7
self.assertEquals(sellable.price, currency('107.35'))
sellable.markup = 8
self.assertEquals(sellable.price, currency('108.36'))