Skip to content

Bug 641388: Fix WIP transfer remainder over-creation when open line quantity is reduced - #9797

Open
ChethanT wants to merge 2 commits into
mainfrom
bugs/Subcontracting/bugs/641388-WIPTransferRemainderCreatedWhenOpenLineQuantityReduced
Open

Bug 641388: Fix WIP transfer remainder over-creation when open line quantity is reduced#9797
ChethanT wants to merge 2 commits into
mainfrom
bugs/Subcontracting/bugs/641388-WIPTransferRemainderCreatedWhenOpenLineQuantityReduced

Conversation

@ChethanT

@ChethanT ChethanT commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bug 641388: the regression test WIPTransferRemainderCreatedWhenOpenLineQuantityReduced (added by the bug 639382 fix) started failing once CI actually ran it, and was temporarily disabled to unblock the pipeline.
  • Root cause: GetOpenWIPTransferLineQtyBase in Subc. Create Transf. Order summed "Quantity (Base)" on open (unposted) WIP transfer lines. But "Qty. per Unit of Measure" is force-set to 0 for WIP transfer lines (see Subc. Transfer Line.OnValidate("Transfer WIP Item")), which makes "Quantity (Base)" always evaluate to 0 for these lines regardless of the actual quantity. So after reducing an open WIP transfer line's quantity and re-running Create Transfer Order to Subcontractor, the existing (reduced) quantity was never counted as "already covered", and the report inserted a brand-new line for the full amount again instead of only the remainder.
  • Fix: compute the open quantity from Quantity (which is correctly maintained) instead of the always-zero "Quantity (Base)", and convert it to the item's base UOM ourselves using the same Purchase Line unit-of-measure factor used elsewhere in the report (CalcPurchLineQtyBase / InsertWIPTransferLine).
  • Re-enabled the test by removing its entry from src/DisabledTests/Subcontracting_Test/Subcontracting_Test.DisabledTest.json.

Test

Re-enabled and validated \WIPTransferRemainderCreatedWhenOpenLineQuantityReduced\ ([SCENARIO 639382], codeunit 149911). Also ran the full Subc. WIP Trans. Create Test (149911) suite (19 tests) — all pass, no regressions.

  • Baseline (before fix): test FAILS — Assert.AreEqual failed. Expected:<6> (Decimal). Actual:<8> (Decimal). Re-running Create Transfer Order must create the remaining WIP quantity after the open line was reduced.
  • After fix: test PASSES, and the full 19-test suite for codeunit 149911 passes.

Fixes AB#641388

🤖 Generated with GitHub Copilot

…uantity is reduced

Root cause: GetOpenWIPTransferLineQtyBase summed "Quantity (Base)" on open
WIP transfer lines, but "Qty. per Unit of Measure" is force-set to 0 for
WIP transfer lines (Subc. Transfer Line OnValidate(`Transfer WIP Item`)),
which makes "Quantity (Base)" always evaluate to 0 for these lines. As a
result, re-running "Create Transfer Order to Subcontractor" after reducing
an open WIP transfer line's quantity never saw the existing reduced
quantity as "open", and created a brand new line for the full amount
instead of only the remainder.

Fix: compute the open quantity from "Quantity" (which is correctly
maintained) and convert it to the item's base UOM ourselves, using the
same Purchase Line unit-of-measure conversion used elsewhere in this
report (CalcPurchLineQtyBase / InsertWIPTransferLine).

Re-enables the regression test WIPTransferRemainderCreatedWhenOpenLineQuantityReduced
(added by the bug 639382 fix, temporarily disabled by this bug) in
src/DisabledTests/Subcontracting_Test/Subcontracting_Test.DisabledTest.json.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ChethanT
ChethanT requested review from a team July 28, 2026 13:08
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Jul 28, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 28, 2026
@ChethanT ChethanT added the SCM GitHub request for SCM area label Jul 28, 2026
@ChethanT ChethanT closed this Jul 28, 2026
@ChethanT ChethanT reopened this Jul 28, 2026
… calc

Independent review of the prior fix (this bug) surfaced a latent filter
gap in GetOpenWIPTransferLineQtyBase: it matches "Transfer Line" records
by Subc. Purch./Prod. Order No., Prod. Order Line No. and Operation No.
with "Transfer WIP Item" = true, but does not exclude return transfer
lines ("Subc. Return Order" = true, created by
SubcCreateSubCReturnOrder.Report's InsertWIPReturnTransferLine), which
share the same key fields.

Previously this was harmless because CalcSums("Quantity (Base)") always
evaluated to 0 for every "Transfer WIP Item" line regardless of match
(the root cause of this bug). Now that the fix sums the real Quantity
field, an open (unposted) WIP return transfer line would be summed into
OpenWIPLineQtyBase and mistaken for already-open outbound quantity,
under-reporting (or suppressing) the need to create the outbound
remainder - the same class of bug this PR fixes, from a different,
previously-masked source.

Fix: add SetRange("Subc. Return Order", false) to
GetOpenWIPTransferLineQtyBase's filter so only open outbound WIP
transfer lines are counted, mirroring the direction filters already
used by WIPReturnTransferLineAlreadyExists/InsertWIPReturnTransferLine
for the return-order side.

Validated locally via al-mcp-action.sh: full codeunit 149911 "Subc. WIP
Trans. Create Test" (19/19, including WIPReturnTransferOrderCreated-
WithCorrectLocations and DeleteReturnTransferOrderAndRecreateSucceeds)
passes with this change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ChethanT

Copy link
Copy Markdown
Contributor Author

Pipeline investigation & follow-up fix

Failing check found: Classify team ownership (run 30397409117) — the only failing check on this PR; not required for merge.

Root cause: This is a pull_request_target workflow (.github/workflows/ownership-classification.yml, executed from the base branch, not this PR's branch) that dispatches a workflow_dispatch event to microsoft/BCAppsTriage's ownership-classification.yml. At the time this run executed, that target workflow did not expose a workflow_dispatch trigger (HTTP 422: Workflow does not have 'workflow_dispatch' trigger). This is an external, transient infra issue unrelated to any code in this PR — confirmed because every run of the same workflow on other PRs/branches (including main) since that time has succeeded. Since the workflow definition is pulled from the base branch, no change to this branch could have affected it.

Action taken: Re-ran the failed job via the GitHub API (
erun-failed-jobs) — it now passes, confirming the upstream issue has since resolved and no code change was needed for this check.

Additional fix (independent review finding)

While validating the existing bug fix, an independent code review pass flagged a latent filter gap exposed by the original fix: GetOpenWIPTransferLineQtyBase didn't exclude open WIP return transfer lines ("Subc. Return Order" = true), which share the same key fields as outbound WIP transfer lines. Before this PR's fix, that gap was harmless because CalcSums("Quantity (Base)") always evaluated to 0 for every WIP line regardless of match. Now that the fix correctly sums Quantity, an open return transfer line could be miscounted as open outbound quantity, masking the need to create the outbound remainder in some scenarios.

Pushed a follow-up commit (�b12647084) adding SetRange("Subc. Return Order", false) to that filter, mirroring the direction filter already used on the return-order side (WIPReturnTransferLineAlreadyExists).

Validation: Compiled and published both the App and Test app via �l-mcp-action.sh; ran the full Subc. WIP Trans. Create Test codeunit (149911) locally — 19/19 tests pass, including the return-order scenarios (WIPReturnTransferOrderCreatedWithCorrectLocations, DeleteReturnTransferOrderAndRecreateSucceeds) and the original regression test (WIPTransferRemainderCreatedWhenOpenLineQuantityReduced).

🤖 Generated with GitHub Copilot

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 SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant