Skip to content

Commit

Permalink
small set of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jul 14, 2017
1 parent 5534ccb commit d45cf83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/budy/models/order.py
Expand Up @@ -591,7 +591,12 @@ def disuse_vouchers_s(self):
as waiting payment.
"""

# in case the discount data is not valid there's no voucher
# value to be reverted/disused, should return immediately
if not self.discount_data: return

# iterates over the complete set of vouchers and associated amount
# to disuse the associated amount in the related vouchers
for voucher_id, amount in appier.legacy.items(self.discount_data):
voucher_id = int(voucher_id)
_voucher = voucher.Voucher.get(id = voucher_id)
Expand Down
2 changes: 1 addition & 1 deletion src/budy/models/voucher.py
Expand Up @@ -248,8 +248,8 @@ def disuse_s(self, amount, currency = None):
appier.verify(self.usage_count > 0)
amount_l = self.to_local(amount, currency)
if self.is_value and not self.unlimited:
appier.verify(self.used_amount >= commons.Decimal(amount_l))
self.used_amount -= commons.Decimal(amount_l)
self.used_amount = max(self.used_amount, commons.Decimal(0.0))
self.usage_count -= 1
self.save()

Expand Down

0 comments on commit d45cf83

Please sign in to comment.