Skip to content

E-Document PO matching improvements#7021

Open
mynjj wants to merge 4 commits intomainfrom
bugs/pomatching-bugs
Open

E-Document PO matching improvements#7021
mynjj wants to merge 4 commits intomainfrom
bugs/pomatching-bugs

Conversation

@mynjj
Copy link
Contributor

@mynjj mynjj commented Mar 6, 2026

  • Fix PO match warning severity display and refactor into dedicated procedure
  • Add missing UoM validation check during invoice finalization
  • Fix finalization to block on correct warning types
  • Improve warning messages and formatting

Fixes AB#621954

@mynjj mynjj requested a review from a team as a code owner March 6, 2026 13:30
@mynjj mynjj requested a review from a team March 6, 2026 13:30
@github-actions github-actions bot added the AL: Apps (W1) Add-on apps for W1 label Mar 6, 2026
@mynjj mynjj requested a review from Groenbech96 March 6, 2026 13:31
@github-actions github-actions bot added this to the Version 29.0 milestone Mar 6, 2026
@Groenbech96 Groenbech96 requested review from Copilot and removed request for a team and Groenbech96 March 6, 2026 14:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors E-Document purchase order matching warnings to replace the coarse-grained QuantityMismatch and NotYetReceived warning types with more specific, granular warning types: ExceedsInvoiceableQty, ExceedsRemainingToInvoice, and OverReceipt. It also improves the UI presentation by adding severity-based styling, a drill-down detail view, and a warning message field. Additionally, it adds a missing UoM validation check during invoice finalization.

Changes:

  • Replaced QuantityMismatch/NotYetReceived warnings with three new granular warning types (ExceedsInvoiceableQty, ExceedsRemainingToInvoice, OverReceipt) with computed warning messages stored in a new "Warning Message" field on the table
  • Refactored the draft subform page to display warnings with severity-based styling (Unfavorable/Ambiguous/Subordinate) and added a drill-down to show detailed warning messages
  • Added a MissingInformationForMatch check during invoice finalization to block creation when UoM information is missing

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
EDocPOMatchWarning.Enum.al Added three new enum values: ExceedsInvoiceableQty, ExceedsRemainingToInvoice, OverReceipt
EDocPOMatchWarning.Table.al Added "Warning Message" Text[250] field to store computed warning details
EDocPOMatching.Codeunit.al Replaced old warning logic with new granular quantity checks (I vs R, I vs J) and updated finalization/validation references
EDocPurchaseDraftSubform.Page.al Extracted UpdateMatchWarnings and ShowMatchWarningDetails procedures; added severity-based styling and drill-down
EDocCreatePurchaseInvoice.Codeunit.al Updated finalization to check ExceedsInvoiceableQty and added MissingInformationForMatch blocking check
EDocPOMatchingUnitTests.Codeunit.al Expanded tests from 2 to 5 quantity warning scenarios, updated all references to new warning types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 234 to 237
POMatchWarnings."E-Doc. Purchase Line SystemId" := EDocumentPurchaseLine.SystemId;
POMatchWarnings."Warning Type" := "E-Doc PO Match Warning"::MissingInformationForMatch;
POMatchWarnings.Insert();
exit;
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The MissingInformationForMatch warning is inserted without setting the "Warning Message" field (lines 234-236), while all other warning types set it. This requires ShowMatchWarningDetails() in the subform page to special-case this warning type with a hardcoded label. Consider setting the "Warning Message" here as well, so that all warning types are handled uniformly and future consumers of this record don't need to know about this special case.

Copilot uses AI. Check for mistakes.
Comment on lines +54 to +59
TempPOMatchWarnings.SetRange("Warning Type", "E-Doc PO Match Warning"::ExceedsInvoiceableQty);
if not TempPOMatchWarnings.IsEmpty() then
Error(SomeLinesNotYetReceivedErr);
TempPOMatchWarnings.SetRange("Warning Type", "E-Doc PO Match Warning"::MissingInformationForMatch);
if not TempPOMatchWarnings.IsEmpty() then
Error(MissingInformationForMatchErr);
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The newly added MissingInformationForMatch finalization check (lines 57-59) blocks invoice creation when draft lines are missing unit of measure information. While the warning calculation itself is tested in EDocPOMatchingUnitTests, there's no test verifying that finalization is actually blocked when this warning is present. Consider adding a test that sets up a draft with a line missing UoM, matches it to a PO line, and verifies that ApplyDraftToBC raises the MissingInformationForMatchErr error. The existing ExceedsInvoiceableQty check (lines 54-56) similarly lacks a finalization-level test.

Copilot uses AI. Check for mistakes.
Groenbech96
Groenbech96 previously approved these changes Mar 7, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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