Fix: Restore Completely Shipped after RedistributeInvoiceDiscounts in Sales Order API pages#29954
Open
jeffreybulanadi wants to merge 1 commit intomicrosoft:mainfrom
Open
Conversation
… Sales Order API pages RedistributeInvoiceDiscounts called in OnAfterGetRecord triggers an OnAfterModifySalesLine event handler (UpdateCompletelyShipped) that copies spurious filters from the SalesLine record and incorrectly evaluates IsEmpty() as true, causing Completely Shipped to be set to true regardless of actual shipment status. Save and restore Rec.'Completely Shipped' around the call in both APIV1 - Sales Orders and APIV2 - Sales Orders pages so that the value returned by the API reflects the actual state of sales lines. Fixes microsoft#29071
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.
Summary
Fixes #29071
Root Cause
In OnAfterGetRecord of both APIV1 - Sales Orders (page 20000) and APIV2 - Sales Orders (page 30028), calling GraphMgtSalesOrderBuffer.RedistributeInvoiceDiscounts(Rec) has an unintended side effect on Rec.\Completely Shipped\`.
The call chain is:
Fix
Save the value of Rec.\Completely Shipped\` from the database before invoking RedistributeInvoiceDiscounts and restore it afterward. The invoice discount redistribution function has no business modifying shipping status; this ensures the API returns the actual shipment state of the sales lines.
Files Changed
How to Test