Skip to content

[master] - Posting service order without External document no. will copy the 'Service Order No.' to GL entries#8897

Draft
MSNehaNawal wants to merge 6 commits into
microsoft:mainfrom
MSNehaNawal:bugs/Bug-638182--master]-Postserviceorder_ExtDocNo_GLEntries
Draft

[master] - Posting service order without External document no. will copy the 'Service Order No.' to GL entries#8897
MSNehaNawal wants to merge 6 commits into
microsoft:mainfrom
MSNehaNawal:bugs/Bug-638182--master]-Postserviceorder_ExtDocNo_GLEntries

Conversation

@MSNehaNawal

@MSNehaNawal MSNehaNawal commented Jun 30, 2026

Copy link
Copy Markdown

Bug 638670: [master][ALL-E] Posting service order without External document no. will copy the 'Service Order No.' to GL entries

AB#638670

@MSNehaNawal MSNehaNawal requested a review from a team June 30, 2026 07:02
@MSNehaNawal MSNehaNawal marked this pull request as draft June 30, 2026 07:02
@github-actions github-actions Bot added From Fork Pull request is coming from a fork Linked Issue is linked to a Azure Boards work item labels Jun 30, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jun 30, 2026
@MSNehaNawal MSNehaNawal reopened this Jun 30, 2026
ServiceInvoiceHeader.FindFirst();
GLEntry.SetRange("Document Type", GLEntry."Document Type"::Invoice);
GLEntry.SetRange("Document No.", ServiceInvoiceHeader."No.");
GLEntry.FindSet();

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.

$\textbf{🟡\ Medium\ Severity\ —\ Agent} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

GLEntry.FindSet() is called as a standalone statement (return value discarded) immediately before a repeat…until GLEntry.Next() = 0 loop.

Because AL's repeat…until is a do-while construct it always executes the loop body at least once, regardless of whether FindSet found any records. If no GL entries exist the loop body runs once on the default (empty) GLEntry variable, GLEntry."External Document No." equals '' by default, and Assert.AreEqual('', '', …) passes vacuously. The test would silently pass even when the posting path produces no GL entries.

Recommendation:

  • replace the standalone GLEntry.FindSet() call with a guarded assertion, e.g. Assert.IsTrue(GLEntry.FindSet(), 'Expected GL entries for invoice ' + ServiceInvoiceHeader."No."); before the repeat block.

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

Assert.IsTrue(GLEntry.FindSet(), 'Expected GL entries to exist for posted invoice ' + ServiceInvoiceHeader."No.");
        repeat
            Assert.AreEqual('', GLEntry."External Document No.", 'External Document No. should be blank on G/L Entry when not specified on Service Order');
        until GLEntry.Next() = 0;

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

@github-actions

Copy link
Copy Markdown
Contributor

Copilot PR Review

Iteration 1 · Outcome: completed

Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630

Findings by domain

Findings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).

Domain Findings Knowledge-backed Agent Inline Fallback
Agent 1 0 1 1 0

Totals: 0 knowledge-backed · 1 agent findings.

Orchestrator pre-filter (13 file(s) excluded)

  • layer-disabled (knowledge) : 13 file(s)

Findings produced by the Copilot CLI agent against BCQuality at 822cae1b2771ac25f665f73369f69093bd4fd630. Reply 👎 on any inline comment to flag false positives.

@JesperSchulz JesperSchulz added the SCM GitHub request for SCM area label Jun 30, 2026
@MSNehaNawal MSNehaNawal closed this Jul 1, 2026
@MSNehaNawal MSNehaNawal reopened this Jul 1, 2026
@MSNehaNawal MSNehaNawal self-assigned this Jul 2, 2026
@MSNehaNawal MSNehaNawal closed this Jul 2, 2026
@MSNehaNawal MSNehaNawal reopened this Jul 2, 2026
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Agentic PR Review - Round 1

Recommendation: Request Changes

What this PR does

This PR changes service posting so a blank service External Document No. stays blank on posted invoice and credit memo G/L entries when Service Management Setup does not require it. That matches the linked bug and the Sales posting pattern for the reported service order invoice flow. The code change is narrow and applied consistently in W1, ES, IT, and NA, but the test coverage does not yet prove all changed paths.

Suggestions

S1 - Guard the G/L entry assertion
The new G/L entry test calls GLEntry.FindSet() and then enters a repeat loop without checking that a record was found. Add an assertion before the loop, so the test fails if no G/L entries match the posted invoice.

S2 - Cover the credit memo path
The PR changes PrepareCrMemoHeader in every layer, but the new regression test only posts a service order invoice. Add the same blank External Document No. check for service credit memo G/L entries, because this is posting logic and the credit memo path is changed too.

Risk assessment and necessity

Risk: This touches service posting and the values written to G/L entries in W1, ES, IT, and NA. There is no public API signature change, but integrations and reports that read G/L Entry.External Document No. for service invoices or credit memos can see changed data when the setup allows blank external document numbers.

Necessity: The linked Bug 638670 / copied Bug 638182 has clear repro steps and an [AI-REPRO] score of 9/10. The change is justified to align service invoice posting with Sales behavior, but the tests must prove the changed G/L entry paths before merge.


[AI-PR-REVIEW] version=1 system=github pr=8897 round=1 by=alexei-dobriansky at=2026-07-06T09:06:00Z lastSha=b7740de61a8d538c28fd4e53d65b1a7614591aa4 suggestions=S1,S2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

From Fork Pull request is coming from a fork Linked Issue is linked to a Azure Boards work item SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants