Skip to content

Resolve purchase lines to items on exact description match - #10466

Merged
Jatin Kumar (Explorer986) merged 1 commit into
mainfrom
private/kumarjatin/647171
Aug 24, 2026
Merged

Jatin Kumar (Explorer986) merged 1 commit into
mainfrom
private/kumarjatin/647171

Conversation

@Explorer986

@Explorer986 Jatin Kumar (Explorer986) commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

What & why

Inbound invoice lines were falling through to G/L account matching even when an item with the exact same description already existed. The line was posted to a G/L account instead of the item.

This PR adds a deterministic step that resolves the line to the item when there is exactly one eligible item with that description. It runs after item reference and text-to-account mapping, so no impact on explicit setup.

Fixes AB#647171

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome

Imported a sample invoice with a line whose description exactly matches an existing item. Before the change it resolved to a G/L account, after the change it resolves to the item.

Risk & compatibility

Matching only triggers when exactly one non blocked item matches and the unit of measure fits, so ambiguous cases keep the old behavior. No schema or upgrade impact.

@Explorer986
Jatin Kumar (Explorer986) requested review from a team August 20, 2026 19:48
@Explorer986 Jatin Kumar (Explorer986) changed the title Match invoice lines to items by description Resolve purchase lines to items on exact description match Aug 20, 2026
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Aug 20, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 20, 2026
@github-actions github-actions Bot added the Team: Integrations GitHub request for Integrations area label Aug 20, 2026
Comment thread src/Apps/W1/EDocument/Test/src/Processing/EDocProcessTest.Codeunit.al Outdated
@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

The new tests prove Text-to-Account Mapping takes precedence over the description match, but nothing proves that an Item Reference match still wins over the new description-match fallback when both would resolve the line. Add a regression test combining both signals to protect the resolution order (Item Reference > Text-to-Account Mapping > description match) against future reordering.

Line mapping was unavailable, so this was posted as an issue comment.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

ventselartur
ventselartur previously approved these changes Aug 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

The new tests hand-insert EDocumentPurchaseLine fixtures with bare Insert() calls instead of using the existing LibraryEDoc.InsertPurchaseDraftLine(EDocument) helper (variable of codeunit "Library - E-Document", already used pervasively elsewhere, e.g. EDocPOMatchingUnitTests.Codeunit.al). That bypasses the app's own fixture path for assigning line numbers/defaults and creates line-0 draft rows that can drift from production behavior as the draft schema evolves; the same pattern is repeated across the other new tests (PreparingPurchaseDraftFindsItemByExactDescription, PurchaseLineProviderDoesNotMatchDuplicateItemDescriptions, PurchaseLineProviderDoesNotMatchPurchasingBlockedItem).

Suggested fix (apply manually — could not be anchored as a one-click suggestion):

EDocumentPurchaseLine := LibraryEDoc.InsertPurchaseDraftLine(EDocument);
EDocumentPurchaseLine.Description := Item.Description;
EDocumentPurchaseLine.Modify();

Knowledge:

Line mapping was unavailable, so this was posted as an issue comment.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

@mynjj Joshua (mynjj) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be aware that after this PR: #7546

This fix will no longer be applicable

@Explorer986
Jatin Kumar (Explorer986) added this pull request to the merge queue Aug 24, 2026
@Explorer986
Jatin Kumar (Explorer986) removed this pull request from the merge queue due to a manual request Aug 24, 2026
@Explorer986
Jatin Kumar (Explorer986) added this pull request to the merge queue Aug 24, 2026
Merged via the queue into main with commit 79ee343 Aug 24, 2026
178 of 183 checks passed
@Explorer986
Jatin Kumar (Explorer986) deleted the private/kumarjatin/647171 branch August 24, 2026 13:12
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 Team: Integrations GitHub request for Integrations area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants