[main] - Incorrect Prepayment Invoice Amount for Sales Orders with Invoice Discount, Prices Including VAT and negative non-inventory line. - #9656
Conversation
…invoice discounts in SalesPostPrepayments
…ounts in SalesPostPrepayments
…Bug-643210-Master-Incorrect-Prepmt-Inv.-Amt.-for-SO-with-Discount
…tive non-inventory line
…and negative non-inventory line
…Bug-643210-Master-Incorrect-Prepmt-Inv.-Amt.-for-SO-with-Discount
…O-with-Discount' of https://github.com/microsoft/BCApps into bugs/Bug-643210-Master-Incorrect-Prepmt-Inv.-Amt.-for-SO-with-Discount
|
Agentic PR Review - Round 1Recommendation: Accept with SuggestionsWhat this PR doesFixes an incorrect prepayment invoice amount on Sales Orders that combine invoice discount, "Prices Including VAT", and a negative non-inventory line with 0% prepayment. The old code computed expected prepayment as The fix replaces the header-based calculation with a line-by-line sum using SuggestionsS1 - Guard still requires header Prepayment % <> 0 S2 - Test uses only 100% prepayment — add a partial-prepayment variant S3 - Test helper GetSalesPrepaymentLineAmount uses FindSalesLine, not ApplyFilter Risk assessment and necessityRisk: Low regression risk. The change only affects Necessity: High. Without this fix, any Sales Order combining invoice discount + negative non-prepayment line posts a prepayment invoice with an amount lower than the lines'
|
…n SalesPostPrepayments and adding tests for partial prepayments with multiple VAT rates.
…Bug-643210-Master-Incorrect-Prepmt-Inv.-Amt.-for-SO-with-Discount
Agentic PR Review - Round 2Recommendation: AcceptWhat this PR doesThis round adds one new test ( Status of previous suggestions
New observations (commits since round 1)None — changes only addressed prior suggestions. Risk assessment and necessityRisk: The Necessity: Unchanged from round 1. The fix is targeted and the new tests meaningfully strengthen coverage of the corrected calculation path.
|
Fixes : AB#643210
Issue :- Incorrect Prepayment Invoice Amount for Sales Orders with Invoice Discount, Prices Including VAT and a negative non-inventory line (regression). The posted prepayment invoice is lower than the sum of the lines' "Prepmt. Line Amount".
Root cause :-
The UpdateDifferenceAmount correction (added for work item 612821) derived the expected prepayment from the header: SalesHeader.Amount * SalesHeader."Prepayment %". SalesHeader.Amount includes negative and non-prepayment lines, and the single header Prepayment % does not reflect per-line prepayment, so the base is too low. The valid prepayment is then misread as a rounding difference and subtracted from the last buffer line, understating the invoice.
Solutions :-
Compute the expected prepayment amount line by line from the actual prepayment lines, using each line's own Amount and Prepayment %, so negative/non-prepayment lines are excluded and mixed percentages are respected. The correction still only fires on a genuine rounding surplus.