Skip to content

Commit

Permalink
Ensure get_discount uses the correct parent charge for discount
Browse files Browse the repository at this point in the history
Before this, it was wrongly using the tax inclusive charge each time.
  • Loading branch information
codeinthehole committed Dec 13, 2013
1 parent 2de69cc commit a9eb4f2
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions oscar/apps/shipping/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def is_discounted(self):
# We check to see if the discount is non-zero. It is possible to have
# zero shipping already in which case this the offer does not lead to
# any further discount.
return self.get_discount()['discount'] > 0
return self.discount > 0

@property
def discount(self):
Expand All @@ -68,15 +68,14 @@ def description(self):
def get_discount(self):
# Return a 'discount' dictionary in the same form as that used by the
# OfferApplications class
parent_charge = self.method.charge_incl_tax
return {
'offer': self.offer,
'result': None,
'name': self.offer.name,
'description': '',
'voucher': self.offer.get_voucher(),
'freq': 1,
'discount': self.offer.shipping_discount(parent_charge)}
'discount': self.effective_discount}

@property
def charge_incl_tax_before_discount(self):
Expand All @@ -90,6 +89,13 @@ def charge_excl_tax_before_discount(self):
def is_tax_known(self):
return self.method.is_tax_known

@property
def effective_discount(self):
"""
The discount value.
"""
raise NotImplemented()

@property
def charge_excl_tax(self):
raise NotImplemented()
Expand All @@ -101,6 +107,11 @@ def charge_incl_tax(self):

class TaxExclusiveOfferDiscount(OfferDiscount):

@property
def effective_discount(self):
parent_charge = self.method.charge_excl_tax
return self.offer.shipping_discount(parent_charge)

@property
def charge_excl_tax(self):
parent_charge = self.method.charge_excl_tax
Expand All @@ -117,6 +128,11 @@ def charge_incl_tax(self):

class TaxInclusiveOfferDiscount(OfferDiscount):

@property
def effective_discount(self):
parent_charge = self.method.charge_incl_tax
return self.offer.shipping_discount(parent_charge)

@property
def charge_incl_tax(self):
parent_charge = self.method.charge_incl_tax
Expand Down

0 comments on commit a9eb4f2

Please sign in to comment.