[Main] -Drop shipment undo receipt fails for service and non-inventory items. - #10154
Open
DhavalMore88 wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug 646535: [master] [ALL-E] Drop shipment undo receipt fails for service and non-inventory items.
AB#646535
Issue: When a Drop Shipment is posted for a Service or Non-Inventory item, both Undo Shipment on the Posted Sales Shipment and Undo Receipt on the Posted Purchase Receipt fail with There is no Item Application Entry within the filter. Filters: Item Ledger Entry No.: 888, Inbound Item Entry No.: 887, Outbound Item Entry No.: 888, Cost Application: Yes. Because Undo Receipt internally calls Undo Shipment for the linked drop shipment line, one defect blocks both actions and the linked document can never be reversed.
Cause: Two problems. (1) In UnApplyDropShipment in UndoSalesShipmentLine.Codeunit.al (CU 5815), the lookup filtered on ItemApplicationEntry.SetRange("Cost Application", true) and then called FindFirst() unguarded. Non-inventoriable items post a drop shipment application entry that carries no cost, so the "Cost Application" field is not set and the record is filtered out — even though the callee ItemJnlPostLine.UnApplyDropShipment never reads that field. (2) In FindSalesShipmentLine in UndoPurchaseReceiptLine.Codeunit.al (CU 5813), the linked Sales Shipment Line was resolved only through Item Ledger / Item Application Entries and ended with an unguarded FindFirst(), which errors for these items because that application link is not always present.
Solution: Removed the "Cost Application" filter in UnApplyDropShipment and guarded the lookup with if ItemApplicationEntry.FindFirst() then, so cost-less drop shipment application entries are unapplied and a missing entry is simply skipped instead of erroring. In FindSalesShipmentLine, the Item Ledger Entry path now exits only on a successful FindFirst(), otherwise it falls back to the new FindSalesShipmentLineByDropShipmentLink, which locates the Sales Shipment Line through the drop shipment document link (Order No./Order Line No./Purchase Order No./Purch. Order Line No. with Drop Shipment = true, Correction = false). The change was propagated to the RU layer copy of CU 5815 via Miapp; CU 5813 has no country overrides.