E-Document Import Helper: return vendor when matched by name but not address#7904
Open
jeffreybulanadi wants to merge 1 commit intomicrosoft:mainfrom
Open
Conversation
…address When a vendor's name meets the required nearness threshold but its address does not, FindVendorByNameAndAddressWithNotification logged a notification but omitted the exit statement, causing the function to silently discard the match and return an empty Code[20]. Add exit(Vendor.No.) after the notification call so the function returns the vendor when matched by name. The unused MatchedByAddress local variable is also removed. Add three tests to EDocHelperTest covering: - Vendor found by name when address does not match (the reported bug scenario) - Vendor found when both name and address match (existing happy path) - Empty result when no vendor name is similar enough Fixes microsoft#7419
32bd2a4 to
c5d5634
Compare
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
FindVendorByNameAndAddressWithNotificationin codeunit 6109 "E-Document Import Helper" iterates vendors looking for a name-and-address match. When a vendor's name meets the required nearness threshold but its address does not, the procedure logged a notification and then continued the loop without returning the vendor. At the end of the loop, the function fell through and returned an emptyCode[20].Fixes #7419
Root Cause
The
if NameNearness >= RequiredNearness()branch handled the address-match case with anexit, but there was noexitafter the name-only notification path:Fix
Add
exit(Vendor."No.")after the notification call. The now-redundantMatchedByAddresslocal variable is also removed.Tests
Three new tests are added to
EDocHelperTest(codeunit 139799):FindVendorByNameAndAddressReturnsVendorWhenNameMatchesAddressDoesNotFindVendorByNameAndAddressReturnsVendorWhenBothNameAndAddressMatchFindVendorByNameAndAddressReturnsEmptyWhenNoNameMatches