When there are product discountable true and variant discountable false in cart in the same time, discount is calculated for variant which is incorrect. (#4102)
* fix use get_is_discountable instead is_discountable attribute from product
* add test case
* add check discount percentage in test
* Fix test case
* remove file setting
* basket add product in test
* Make the test pass
---------
Co-authored-by: Kaew <ajchariya.ung@gmail.com>
Improve efficiency of Range.product_queryset when fetching matching child products (#3734)
* Improve efficiency of Range.product_queryset when fetching matching child products.
* Add tests to verify that contains_product returns true for child products whose parent is in a range.
- allow creation of offers of all types
- allow creation of vouchers with multiple offers
- allow creation of voucher sets of all usages, and with multiple offers
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.
Fix rendering of upsell messages for exclusive offers (#3548)
* Improve `available` method of `LineOfferConsumer` class
* Add `quantity_available_for_offer` method to `AbstractLine` class
* Improve conditions: "Get num matches" methods updated to use `quantity_available_for_offer`
method of `Line` model.
* Improve conditions: `get_upsell_message` methods updated to show upsell message only in
the cases where `delta` > 0.
* Ensure basket upsell messages are not `None`
Fix Range.all_products() inconsistency with contains_product()
This change fixes the inconsistency with range.all_products() which
didn't check for exclusions when includes_all_products is set
Every other bit of oscar expected range.includes_all_products means
that all products are included, no questions asked. The dashboard
interface even hides the option to edit/remove individual products.
The short circuiting in ConditionalOffer.products() is removed so
the range.all_products() logic is applied consistently.
Refactor Benefit clean methods and add tests for all of them.
- Refactor clean methods to return all validation errors, rather than just the first one we found.
- Fix clean method type errors in Python 3
- Add tests for the clean methods for all benefit types.
Fix logic for checking whether an offer is active based on date.
- If start_datetime is null, then the offer has no start date.
- If end_datetime is null, then the offer never expires.
Use the ActiveOfferManager in Applicator.get_site_offers instead of
reimplementing the same logic there.
Fixes #2344.
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.
- Set Meta.app_label on models created in the tests
- Use logging.NullHandler instead of django.utils.log.NullHandler
- Use oscar.core.loading.get_model() instead of django's get_model
- Remove template tags '{% load url from future %}'