本文整理汇总了Python中stoqlib.domain.event.Event.log_sale_item_discount方法的典型用法代码示例。如果您正苦于以下问题:Python Event.log_sale_item_discount方法的具体用法?Python Event.log_sale_item_discount怎么用?Python Event.log_sale_item_discount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.event.Event
的用法示例。
在下文中一共展示了Event.log_sale_item_discount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_sellable
# 需要导入模块: from stoqlib.domain.event import Event [as 别名]
# 或者: from stoqlib.domain.event.Event import log_sale_item_discount [as 别名]
def add_sellable(self, sellable):
price = sellable.get_price_for_category(self.model.client_category)
new_price = self.cost.read()
# Percentage of discount
discount = 100 - new_price * 100 / price
if discount > 0 and self.manager:
Event.log_sale_item_discount(
store=self.store,
sale_number=self.model.identifier,
user_name=self.manager.username,
discount_value=discount,
product=sellable.description,
original_price=price,
new_price=new_price)
SellableItemStep.add_sellable(self, sellable)
示例2: _maybe_log_discount
# 需要导入模块: from stoqlib.domain.event import Event [as 别名]
# 或者: from stoqlib.domain.event.Event import log_sale_item_discount [as 别名]
def _maybe_log_discount(self):
# If not authorized to apply a discount
if self.manager is None:
return
price = self.model.sellable.get_price_for_category(self.model.sale.client_category)
new_price = self.price.read()
if new_price >= price:
return
discount = 100 - new_price * 100 / price
Event.log_sale_item_discount(
store=self.store, sale_number=self.model.sale.identifier,
user_name=self.manager.username,
discount_value=discount,
product=self.model.sellable.description,
original_price=price,
new_price=new_price)