[releases/27.x][Shopify] Backport BE test fix for UnitTestUpdateTaxRegistrationIdForVATRegistrationNo#7889
Merged
onbuyuka merged 2 commits intoreleases/27.xfrom Apr 29, 2026
Conversation
…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)
- 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>
5b0bfed to
6a8b3c0
Compare
mirouhl
approved these changes
Apr 28, 2026
gggdttt
approved these changes
Apr 29, 2026
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.
Summary
Backports the BE test fix for
UnitTestUpdateTaxRegistrationIdForVATRegistrationNofrommaintoreleases/27.x. The original Shopify tax registration ID feature (PR #7750 / cherry-picked asda0adec0) was backported, but the follow-up test fixes that make the test pass on the BE gate were not.The
RunALUnitTests_BE_Extensionstask is currently failing onreleases/27.xBCApps validation as a result.Cherry-picked commits
1d87928— [Shopify] Test failure in UnitTestUpdateTaxRegistrationIdForVATRegistrationNo for Belgian customers ([Shopify] Test failure in UnitTestUpdateTaxRegistrationIdForVATRegistrationNo for Belgian customers #6400)bfdac91— [Shopify] Fix VAT Registration No. test for BE gate ([Shopify] Fix VAT Registration No. test for BE gate #6606)#6606 supersedes #6400 (replaces the country-code check with an
EventSubscriberonOnBeforeValidateVATRegistrationNoto handle the Empty Company case used by the BE gate). Both are cherry-picked here so the resulting test code matchesmain.Fixes AB#632782