Skip to content

fix(promotions): a free-setup code waives the setup fee, in the cart and on the invoice - #445

Merged
Panelica merged 1 commit into
Panelica:mainfrom
ertugrulkeyvan:fix/free-setup-promotion
Nov 16, 2026
Merged

Panelica merged 1 commit into
Panelica:mainfrom
ertugrulkeyvan:fix/free-setup-promotion

Conversation

@ertugrulkeyvan

Copy link
Copy Markdown
Contributor

What was wrong

The promotions form offers five types. Two are worked out (percentage, fixed amount). The other three were read by nothing, and the cart and the invoice disagreed about them:

  • The invoice gave no discount for free_setup, price_override or override_recurring.
  • The cart treated every type but a percentage as a fixed amount of the code's value. A free-setup code with a value of 5 was quoted as 5 off, and the invoice then charged the full amount.

So an operator who made a "free setup" code got a code that waived nothing, and a customer could be quoted a discount the invoice did not give.

What changes

  • A free-setup code waives the setup fees of the lines it covers, in the cart and on the invoice alike. The price is untouched and the code's value is not used.
  • It follows the code's own limits: particular products, billing periods, and the per-order product limit from feat(promotions): a code can limit how many products one order has discounted (#439) #442 (one product per order waives one setup fee, that of the highest-priced product).
  • The waived fee is written as the same Discount line every other code gets, taxed as the fee was, so its tax goes with it.
  • With no setup fee on the order the code gives nothing and is not counted as used.
  • The cart quotes a discount only for the types the invoice gives one for. price_override and override_recurring now show no discount in the cart, which is what the invoice has always charged.

No migration, no new setting, no new text.

Not in this PR

price_override and override_recurring are still offered on the form and still do nothing. They need a decision first: implement them, or take them off the form. I can do either as a follow-up.

Tests

PromotionFreeSetupTest (10): the fee is waived and the price left alone; the code's value is not money off; every fee on an unrestricted code; only the covered product's fee; one fee under a per-order limit; tax follows the waived fee; nothing given and nothing spent when there is no fee; the two unread types quote nothing; percentage and fixed codes as before. Full suite run in two halves.

…and on the invoice

The promotions form offers a 'free setup' type that nothing read. The
invoice gave no discount for it, while the cart treated every type but a
percentage as a fixed amount of the code's value and quoted that as
money off. A free-setup code now waives the setup fees of the lines it
covers, and the cart quotes a discount only for the types the invoice
gives one for.
@Panelica
Panelica merged commit 04ca126 into Panelica:main Nov 16, 2026
1 check passed
@Panelica

Copy link
Copy Markdown
Owner

Merged — thank you. The bigger finding here is the one in your first paragraph: the cart was quoting a discount the invoice would not give, for three of the five types the form offers. A quote that does not match the bill is worse than a feature that does nothing.

Read line by line, because it moves money:

  • The cart and the invoice now agree on every type. percentage, fixed/fixed_amount and free_setup are worked out the same way on both sides, and anything else is 0.0 in the cart because it is 0.0 on the invoice. That alignment is the fix; waiving the fee is the feature.
  • Setup is a real line type (OrderService writes it as its own line, taxed as the product, never on a renewal), and setupLines() picks exactly those, restricted by the same coveredItems() selection — so feat(promotions): a code can limit how many products one order has discounted (#439) #442's per-order limit carries through to which fee is waived. Measured on the same basket in your tests.
  • The waived fee takes its tax with it, through the existing promoGroups() path rather than a second mechanism.
  • Seven of your tests fail on main and pass here; the promotion tests together are 57 of 57 on the merge result; full suite 5426 passed, 0 failed.

One thing left standing, worth its own decision rather than a quiet gap: price_override and override_recurring are still read by nothing, and the form still offers them. Now that a code of those types visibly gives zero on both sides, an operator who picks one gets a code that does nothing — either they should work or the form should stop offering them. Happy to take whichever you prefer as a follow-up.

Merging is not shipping: this reaches installations with the next release.

@Panelica

Copy link
Copy Markdown
Owner

Released in 1.29.0 — thank you.

Gates on the tag: the full suite 5426 passed, 0 failed; the update lab's 14 scenarios green on a run of its own; the real package updating 1.28.0 on the stable channel and the last beta on the beta channel.

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.

2 participants