Skip to content

[releases/27.x][Shopify] Backport BE test fix for UnitTestUpdateTaxRegistrationIdForVATRegistrationNo#7889

Merged
onbuyuka merged 2 commits intoreleases/27.xfrom
bugs/632782-backport-be-test-fix
Apr 29, 2026
Merged

[releases/27.x][Shopify] Backport BE test fix for UnitTestUpdateTaxRegistrationIdForVATRegistrationNo#7889
onbuyuka merged 2 commits intoreleases/27.xfrom
bugs/632782-backport-be-test-fix

Conversation

@onbuyuka
Copy link
Copy Markdown
Contributor

@onbuyuka onbuyuka commented Apr 28, 2026

Summary

Backports the BE test fix for UnitTestUpdateTaxRegistrationIdForVATRegistrationNo from main to releases/27.x. The original Shopify tax registration ID feature (PR #7750 / cherry-picked as da0adec0) was backported, but the follow-up test fixes that make the test pass on the BE gate were not.

The RunALUnitTests_BE_Extensions task is currently failing on releases/27.x BCApps validation as a result.

Cherry-picked commits

#6606 supersedes #6400 (replaces the country-code check with an EventSubscriber on OnBeforeValidateVATRegistrationNo to handle the Empty Company case used by the BE gate). Both are cherry-picked here so the resulting test code matches main.

Fixes AB#632782

…rationNo for Belgian customers (#6400)

#### Problem
The unit test `UnitTestUpdateTaxRegistrationIdForVATRegistrationNo` in
`Shpfy Tax Id Mapping Test` codeunit was failing when running on the
Belgian (BE) localization.

The test was attempting to validate a VAT Registration No. on a Customer
record, but Belgian localization requires customers to use the
"Enterprise No." field instead of "VAT Registration No." for Belgian
customers. This triggered the validation error:
> "You must use Enterprise No. for Belgian customers."

#### Root Cause
When the Company Information has `Country/Region Code` = 'BE', the
`Customer.VAT Registration No.` field validation rejects VAT
Registration numbers because Belgian regulations require the use of the
Enterprise No. field instead.

#### Solution
Added a condition in the test to detect when running on Belgian
localization and handle it by:
1. Setting the customer's `Country/Region Code` to 'DE' (Germany) to
bypass the Belgian-specific validation
2. Regenerating a valid VAT Registration No. for the German country code

#### Changes
- ShpfyTaxIdMappingTest.Codeunit.al: Added conditional logic to handle
Belgian localization in
`UnitTestUpdateTaxRegistrationIdForVATRegistrationNo` test

```al
if CompanyInformation."Country/Region Code" = 'BE' then begin
    Customer."Country/Region Code" := 'DE'; // VAT Reg No. not allowed for BE Customers
    Customer.Modify();
    NewTaxRegistrationId := LibraryERM.GenerateVATRegistrationNo(Customer."Country/Region Code");
end;
```

Fixes
[AB#618120](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/618120)
@onbuyuka onbuyuka requested a review from a team as a code owner April 28, 2026 09:33
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Apr 28, 2026
@onbuyuka onbuyuka enabled auto-merge (squash) April 28, 2026 09:35
- Fix `UnitTestUpdateTaxRegistrationIdForVATRegistrationNo` failing in
`RunALUnitTests_BE_Extensions` gate
- Replace country code check with `EventSubscriber` on
`OnBeforeValidateVATRegistrationNo` to bypass localization-specific
validation
- The previous fix checked `CompanyInformation."Country/Region Code" =
'BE'`, but the BE gate runs unit tests in an "Empty Company" where the
country is blank — and the BE layer's `DetermineCountry('')` treats
blank as Belgian

- [x] Verify `UnitTestUpdateTaxRegistrationIdForVATRegistrationNo`
passes in `RunALUnitTests_BE_Extensions`
- [x] Verify all other tests in `Shpfy Tax Id Mapping Test` codeunit
still pass
- [x] Verify W1 unit tests are not affected

Fixes
[AB#618120](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/618120)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@onbuyuka onbuyuka force-pushed the bugs/632782-backport-be-test-fix branch from 5b0bfed to 6a8b3c0 Compare April 28, 2026 09:38
@onbuyuka onbuyuka merged commit 6e82d8f into releases/27.x Apr 29, 2026
23 checks passed
@onbuyuka onbuyuka deleted the bugs/632782-backport-be-test-fix branch April 29, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants