Skip to content

[FEATURE] Store the taxes per tax class of order discounts - #897

Merged
d-g-codappix merged 2 commits into
mainfrom
coupon-taxes-per-class
Nov 24, 2026
Merged

d-g-codappix merged 2 commits into
mainfrom
coupon-taxes-per-class

Conversation

@d-g-codappix

@d-g-codappix d-g-codappix commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

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::$taxClass not mapped, tax_class_id always 1).

  • tx_cart_domain_model_order_discount gets tax_class (tax class of the order), coupon_type (class of the cart coupon) and taxes (JSON, uid of the tax class of the order => tax). PersistOrder\Coupons stores them for fixed and percentage coupons, calculated like Cart::getCouponTaxes().
  • Order\Discount gets them as optional constructor arguments and provides getTaxClass(), getCouponType(), getTaxes() and hasTaxes(), no setters: the discount is not changed after the order was persisted.
  • The order views in the backend and the frontend show the taxes of a discount in the column of its tax class. The frontend view did not show discounts at all, it gets a discount row.
  • Deprecated: passing the tax class of the cart to the constructor of Order\Discount (it was never stored) and the column tax_class_id; both are removed in 13.0.
  • Upgrade wizard extcodeCartOrderDiscountTaxes for 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.

d-g-codappix and others added 2 commits November 24, 2026 12:39
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>
@d-g-codappix
d-g-codappix merged commit 658004d into main Nov 24, 2026
25 checks passed
@d-g-codappix
d-g-codappix deleted the coupon-taxes-per-class branch November 24, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Store the taxes per tax class of order discounts

1 participant