Skip to content

Commit

Permalink
initial custom discount support
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed May 31, 2016
1 parent 4e35825 commit cbafc3d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/budy/models/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,16 @@ def empty_referrals_s(self):
def calculate(self):
lines = self.lines if hasattr(self, "lines") else []
self.sub_total = sum(line.total for line in lines)
self.discount = self.discount or self.build_discount()
self.shipping_cost = self.build_shipping()
self.total = self.sub_total - self.discount + self.taxes + self.shipping_cost

def build_discount(self):
discount = appier.conf("BUDY_DISCOUNT", None)
if not discount: return 0.0
discount = eval(discount)
return discount(self.sub_total, self.taxes, self.quantity)

def build_shipping(self):
shipping = appier.conf("BUDY_SHIPPING", None)
if not shipping: return 0.0
Expand Down

0 comments on commit cbafc3d

Please sign in to comment.