Skip to content

ABN-443/fix: credit-memo tax tracks surcharge edit (+ auto-refresh)#205

Merged
dgjlindsay merged 2 commits into
stagingfrom
doug/ABN-443-creditmemo-surcharge-tax-tracking
Jun 4, 2026
Merged

ABN-443/fix: credit-memo tax tracks surcharge edit (+ auto-refresh)#205
dgjlindsay merged 2 commits into
stagingfrom
doug/ABN-443-creditmemo-surcharge-tax-tracking

Conversation

@dgjlindsay
Copy link
Copy Markdown
Contributor

Follow-up to #201/#203/#204. Two parts:

Server (collector): after the #201 de-dup fix the credit-memo collector left tax_amount to Magento's native collector, which is blind to the surcharge-override field — so editing the refunded surcharge down still refunded the full surcharge VAT (Tax line stuck; over-refund). Now the collector applies a tax delta = (refundedNet − proportionalDefaultNet) × rate to both tax_amount and grand_total:

  • zero on the non-override path → preserves ABN-443/fix: stop double-counting surcharge VAT on invoice + credit memo #201 + the double-count fix exactly;
  • moves the Tax line to the VAT on the surcharge actually refunded when the merchant overrides (e.g. €1000 goods + €100 surcharge @21%: halving the surcharge → Tax €231→€220.50, Grand €1331→€1270.50);
  • handles override = 0 (removes the default surcharge VAT).

Client (UX): the surcharge input now refreshes the totals automatically — on blur and on a debounced change — by re-firing Magento's own "Update Qty's" round-trip (the input is part of #edit_form), instead of requiring a manual click.

Tests: PHPUnit override/no-op cases (147 pass); Jest blur/debounce/no-op cases under jsdom (33 pass).

Refs ABN-443

dgjlindsay and others added 2 commits June 5, 2026 00:37
After the ABN-443 de-dup fix (#201) the collector left tax_amount to Magento's
native collector, which is blind to the surcharge override field — so editing
the refunded surcharge down still refunded the full surcharge VAT (Tax line
stuck; over-refund).

Apply a tax DELTA = (refundedNet - proportionalDefaultNet) * rate to both
tax_amount and grand_total. The proportional default is the surcharge VAT
native already refunded, so the delta is exactly zero on the non-override path
(preserves #201) and moves the Tax line to the VAT actually refunded when the
merchant overrides. Handles override = 0 (removes the default surcharge VAT).

Refs ABN-443

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bind the surcharge override input so the totals (Tax line + Grand Total)
refresh when the merchant edits it — on blur and on a debounced change —
instead of requiring a manual "Update Qty's" click. Reuses Magento's own
updateQty round-trip (the input is part of #edit_form) by re-enabling and
clicking the existing Update Qty's button; the server-side recalculation is
the tax-delta fix in Model/Total/Creditmemo/Surcharge.

Implemented as an AMD module taking (doc, win) so the blur/debounce/no-op
behaviour is unit-tested under jsdom.

Refs ABN-443

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@dgjlindsay dgjlindsay merged commit 8b828c7 into staging Jun 4, 2026
20 checks passed
@dgjlindsay dgjlindsay deleted the doug/ABN-443-creditmemo-surcharge-tax-tracking branch June 4, 2026 23:51
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.

1 participant