Resolved two more edge cases in quota handling

Scenario 1) Blocking voucher is used in a CartPosition. Previously
too much was subtracted from the quota.

Scenario 2) When two quotas are assigned to a product and one of them
is sold out, blocking vouchers for the other quota should not enable to
buy the product.
This commit is contained in:
Raphael Michel
2016-08-15 22:53:32 +02:00
parent fddd612a63
commit 63b683096b
5 changed files with 132 additions and 1 deletions

View File

@@ -554,6 +554,10 @@ class Quota(LoggedModel):
return CartPosition.objects.filter(
Q(expires__gte=now()) &
~Q(
Q(voucher__isnull=False) & Q(voucher__block_quota=True)
& Q(Q(voucher__valid_until__isnull=True) | Q(voucher__valid_until__gte=now()))
) &
self._position_lookup
).distinct().count()