Issue: https://github.com/django-oscar/django-oscar/issues/3162
* Checking of `offer.benefit.max_affected_items` removed from the
`available` method of `LineOfferConsumer` class - available items should
not be limited by related benefit (it should be considered when applying
the offer).
* Improved `apply` method of `PercentageDiscountBenefit` - affected
items must include "quantities with discount applied".
* `is_satisfied` method of `CountCondition` updated to pass `offer`
instead of `None` to `line.quantity_without_offer_discount` - this
change is required to fix the initial issue.
* Updated `test_available_with_offer` test - initially this test was
added to check the lines that we removed from the `available` method of
`LineOfferConsumer` class (See fda27a183d/).
* Added tests to confirm that the initial issue is fixed.
Cleanup unused benefits and conditions after conditional offer removal.
Now after ConditionalOffer deleted will be deleted related Benefits and Conditions models (through post_delete signal) if they are no longer used by other offers (with exception of custom benefits/conditions). Plus some small changes related to PEP8 and typos.
The idea of splitting integration from unittests is good in theory
but leads to a lot of mental overhead. Besides whenever a tests
interacts with a database it isn't a unittest anyway.
The offer tests contained a stray test case that I suppose was once
intended as a base class for all the other tests. But it's only used
twice, and for very little gain, so let's delete it.
This involves some quite involved changes to the internals of how offers
and organised. A new boolean field has been added to the offer model to
indicate whether to apply to prices exclusive of tax. This is used
within the offer methods to determine whether a basket meets a
condition, and how to apply the benefit if it does.
Fixes #925
Fixes #924
Hmmm, this turned out to be a monster commit. This change allows the
basket to be able to correctly calculate prices including tax.
It also requires a whole load of test changes since all baskets now
require a strategy instance to be assigned.
This allows updating code in both places, if necessary. Getting Django
1.5 support would be painful otherwise. This also removes the circular
dependency of django-oscar-testsupport on Oscar.
The requirements were merged. The imports were updated
accordingly. Unused imports in the touched files were removed. No
further changes.
This change applies the discount to all matching lines in the benefit
range, weighting the discount by the line prices. The old way was to
iterate over each line and try and apply all the discount.
This new way means that applying an absolute benefit consumes more
products from the basket than the old way, which may possibly have some
confusing side-effects.
This change avoids an issue where customers can get a free product if
they return most of the ordered products apart from the one that was
discounted to zero.
This is a major clean-up of offers, tidying up the implementations and
rewriting the test suite. This should also clean up some edge cases
around the use of max_affected_items.