Repository navigation
[FEATURE] Store the taxes per tax class of order discounts - #897
Merged
Merged
Conversation
A percentage coupon reduces the taxes of every tax class of the cart, but the discount of the order stored only the tax of the coupon in its own tax class, which is 0.0 for percentage coupons. The tax class of the discount was not stored at all, Order\Discount::$taxClass was not mapped. The totals of the order were correct. The discount of an order now stores the taxes per tax class of the order as JSON (`taxes`), the tax class of the order (`tax_class`) and the class of the cart coupon (`coupon_type`). The taxes are calculated like Cart::getCouponTaxes(), for fixed and percentage coupons. The order views in the backend and in the frontend show the taxes of a discount in the columns of their tax classes. The frontend view shows the discounts of the order, too. Passing the tax class of the cart to the constructor of Order\Discount is deprecated, it expects the tax class of the order. Resolves: #896 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The upgrade wizard calculates the taxes per tax class of the discounts of existing orders from the stored taxes of the order: tax of the products plus tax of shipping and payment minus total tax. The taxes of several discounts are split by their gross. It stores the tax class of fixed coupons and the coupon type, if a coupon with the code exists. Orders whose numbers do not add up are skipped and listed, e.g. orders with special services or with fixed coupons of different tax classes. The taxes of their discounts stay unknown. Resolves: #896 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves: #896
A percentage coupon reduces the taxes of every tax class of the cart, but the discount of the order stored only the tax of the coupon in its own tax class (always 0.0 for
CartCouponPercentage), and the tax class of the discount was not stored at all (Order\Discount::$taxClassnot mapped,tax_class_idalways 1).tx_cart_domain_model_order_discountgetstax_class(tax class of the order),coupon_type(class of the cart coupon) andtaxes(JSON, uid of the tax class of the order => tax).PersistOrder\Couponsstores them for fixed and percentage coupons, calculated likeCart::getCouponTaxes().Order\Discountgets them as optional constructor arguments and providesgetTaxClass(),getCouponType(),getTaxes()andhasTaxes(), no setters: the discount is not changed after the order was persisted.Order\Discount(it was never stored) and the columntax_class_id; both are removed in 13.0.extcodeCartOrderDiscountTaxesfor existing orders: coupon tax per tax class = tax + tax of shipping and payment - total tax, split by gross for several coupons. It is conservative, orders whose numbers do not add up are skipped and listed.Tests: unit tests for
Order\Discount, functional tests for persisting fixed and percentage coupons with mixed tax classes, the order views and the upgrade wizard (six orders incl. two skipped ones).The changelog of 12.8 is also added by #898; the second PR to be merged needs a rebase of
Documentation/Changelog/12.8/Index.rst.