models.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:planet-b-saleor 作者: planet-b 项目源码 文件源码
def get_fixed_discount_for(self, amount):
        if self.discount_value_type == self.DISCOUNT_VALUE_FIXED:
            discount_price = Price(net=self.discount_value,
                                   currency=settings.DEFAULT_CURRENCY)
            discount = FixedDiscount(
                amount=discount_price, name=smart_text(self))
        elif self.discount_value_type == self.DISCOUNT_VALUE_PERCENTAGE:
            discount = percentage_discount(
                value=self.discount_value, name=smart_text(self))
            fixed_discount_value = amount - discount.apply(amount)
            discount = FixedDiscount(
                amount=fixed_discount_value, name=smart_text(self))
        else:
            raise NotImplementedError('Unknown discount value type')
        if discount.amount > amount:
            return FixedDiscount(amount, name=smart_text(self))
        else:
            return discount
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号