Skip to content

Fix 644744: Undo subcontracting receipt keys Item Entry Relation with Capacity Ledger Entry No. - #10254

Open
alexei-dobriansky wants to merge 2 commits into
mainfrom
bugs/644744-Subcon_ItemEntryRelationErrorOnUndoReceipt
Open

Fix 644744: Undo subcontracting receipt keys Item Entry Relation with Capacity Ledger Entry No.#10254
alexei-dobriansky wants to merge 2 commits into
mainfrom
bugs/644744-Subcon_ItemEntryRelationErrorOnUndoReceipt

Conversation

@alexei-dobriansky

@alexei-dobriansky alexei-dobriansky commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes AB#644744: undoing a subcontracting purchase receipt could fail with a duplicate Item Entry Relation (table 6507) error, or silently store a wrong relation key.

Root cause

During undo of a tracked (or multi-output) subcontracting receipt, UndoPostingManagement.PostItemJnlLineAppliedToList copied ItemJnlLine."Item Shpt. Entry No." into Item Entry Relation."Item Entry No.". For subcontracting, that field carries the Capacity Ledger Entry No. (set in Item Jnl.-Post Line), not the reversing Output Item Ledger Entry. So the relation — whose primary key is a TableRelation to Item Ledger Entry — was keyed with a capacity entry number, causing either silent corruption or a duplicate-key error when that number already existed as a relation key.

The forward receipt path is unaffected because it keys the relation from the tracking specification (InitFromTrackingSpec), which always carries the real Output ILE. The untracked single-output undo takes a shortcut path that never builds the relation, which is why the bug only reproduces with tracked/multi-output undo.

Fix

In PostItemJnlLineAppliedToList, for subcontracting key the relation from the actual posted Output Item Ledger Entry (ItemJnlPostLine.GetItemLedgerEntryNo()). Normal items and the capacity-only (non-last-operation) single-line undo path are unaffected.

Tests

  • New SubcWhseItemTracking tests: tracked undo repro (asserts the relation is not keyed by a Capacity Ledger Entry and does reference the reversing Output ILE) and a non-last-operation guard (capacity-only undo creates no capacity-keyed relation).
  • Re-enabled SCM Production Order III.UndoPurchReceiptWithProductionSubcontracting_LotTracking.

alexei-dobriansky and others added 2 commits August 14, 2026 13:49
… Capacity Ledger Entry No.

During undo of a tracked (or multi-output) subcontracting receipt,
UndoPostingManagement.PostItemJnlLineAppliedToList copied
ItemJnlLine."Item Shpt. Entry No." into Item Entry Relation."Item Entry No.".
For subcontracting that field carries the Capacity Ledger Entry No.
(set in Item Jnl.-Post Line), not the reversing Output Item Ledger Entry,
so the relation was keyed with a capacity entry - causing silent corruption
or a duplicate-key error on table 6507 when the number already existed.

Key the relation from the actual posted Output Item Ledger Entry
(ItemJnlPostLine.GetItemLedgerEntryNo()) for subcontracting. Normal items and
the capacity-only (non-last-operation) single-line undo path are unaffected.

- Add subcontracting undo repro/guard tests (tracked repro + non-last-operation guard).
- Re-enable UndoPurchReceiptWithProductionSubcontracting_LotTracking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 658f7a29-90df-404c-bd6d-952085412bad
…644744-Subcon_ItemEntryRelationErrorOnUndoReceipt
@alexei-dobriansky
alexei-dobriansky requested review from a team August 14, 2026 11:55
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Aug 14, 2026
@alexei-dobriansky alexei-dobriansky self-assigned this Aug 14, 2026
@alexei-dobriansky alexei-dobriansky added SCM GitHub request for SCM area Subcontracting Subcontracting related activities labels Aug 14, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 14, 2026
end;

[ConfirmHandler]
procedure ConfirmHandler(Question: Text[1024]; var Reply: Boolean)

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{🟠\ High\ Severity\ —\ Testing}$

The new undo-receipt tests use a Confirm handler that always returns true without enqueueing or asserting the expected prompt. That means the tests can stay green even if the wrong confirmation is shown or the dialog interaction count changes, instead of proving the intended UI contract.

Knowledge:

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

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 Subcontracting Subcontracting related activities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant