[Extensibility Request] issue 30264: add and extend events in CalcBestDirectUnitCost#9448
[Extensibility Request] issue 30264: add and extend events in CalcBestDirectUnitCost#9448AleksandricMarko wants to merge 2 commits into
Conversation
…of Purch. Price Calc. Mgt. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot PR ReviewIteration 1 · Outcome: completed Knowledge source: https://github.com/microsoft/BCQuality@186d8a131465475c79244d994acb872cd5c0d4bf Findings by domainFindings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).
Totals: 1 knowledge-backed · 0 agent findings. Orchestrator pre-filter (2 file(s) excluded)
Findings produced by the AL review agent v1.7.3. Reply 👎 on any inline comment to flag false positives. |
|
qasimikram
left a comment
There was a problem hiding this comment.
The three publisher changes match the linked request and expose the required state at the intended decision points.
S1: Please add regression coverage for the new override paths. Include multiple candidate prices and verify default behavior, an overridden InMinQty result, and a handled selection that updates both BestPurchPrice and BestPurchPriceFound; also cover the extended no-price fallback context.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2e2f582
|
|
||
| [IntegrationEvent(false, false)] | ||
| local procedure OnCalcBestDirectUnitCostOnBeforeNoPriceFound(var PurchasePrice: Record "Purchase Price"; Item: Record Item; var IsHandled: Boolean) | ||
| local procedure OnCalcBestDirectUnitCostOnBeforeNoPriceFound(var PurchasePrice: Record "Purchase Price"; Item: Record Item; var IsHandled: Boolean; var PriceInSKU: Boolean; var StockkeepingUnit: Record "Stockkeeping Unit") |
There was a problem hiding this comment.
The existing published IntegrationEvent "OnCalcBestDirectUnitCostOnBeforeNoPriceFound" changed its shipped signature by adding the new var parameters "PriceInSKU" and "StockkeepingUnit". Extensions that already subscribe to the old 3-parameter event will no longer compile or bind correctly. Keep the existing event signature unchanged and introduce a new companion event for the extra context instead.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.15.4
|
|
||
| [IntegrationEvent(false, false)] | ||
| local procedure OnCalcBestDirectUnitCostOnBeforeNoPriceFound(var PurchasePrice: Record "Purchase Price"; Item: Record Item; var IsHandled: Boolean) | ||
| local procedure OnCalcBestDirectUnitCostOnBeforeNoPriceFound(var PurchasePrice: Record "Purchase Price"; Item: Record Item; var IsHandled: Boolean; var PriceInSKU: Boolean; var StockkeepingUnit: Record "Stockkeeping Unit") |
There was a problem hiding this comment.
The new and changed event signatures introduce abbreviated subscriber-facing parameter names such as PriceInSKU, InMinQty, BestPurchPriceFound, and LineDiscPerCent. Event parameter names are part of the contract subscribers code against, so spell them out to make the publishers self-explanatory before this surface ships.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.15.4
Summary
The author needs to customize purchase price selection in
CalcBestDirectUnitCost(codeunit 7010 "Purch. Price Calc. Mgt.") on a per-price-record basis - deciding which quantity the minimum-quantity check compares against, applying a different best-price selection rule, and intercepting the no-price fallback cost. The existing events do not expose the required in-scope state (the currentPurchase Pricerecord, the current best price, orPriceInSKU/SKU) at the right points, forcing subscribers to re-implement whole loops. This PR adds two new integration events inside the selection loop and extends one existing event so subscribers can override these decisions without duplicating internal logic.Source issue repository: microsoft/AlAppExtensions; issue number: 30264
Changes Made
OnCalcBestDirectUnitCostOnAfterIsInMinQty- new integration event raised right after theIsInMinQtycall in the loop, exposing thePurchasePricerecord,QtyPerUOM,Qty, and the min-quantityvar Booleanresult so subscribers can override which quantity the minimum is checked against per price record. TheIsInMinQtyresult is now stored in a new localInMinQtyvariable that drives the loop.OnCalcBestDirectUnitCostOnBeforeCaseStatement- new integration event raised after the price conversions and before thecase true ofselection block, exposingPurchasePrice,BestPurchasePrice,BestPurchPriceFound, avar IsHandledskip flag, andLineDiscPerCentso subscribers can replace the best-price selection rule; the standardcaseblock runs only whenIsHandledisfalse.OnCalcBestDirectUnitCostOnBeforeNoPriceFound- extended withvar PriceInSKU: Booleanandvar StockkeepingUnit: Record "Stockkeeping Unit"appended to the signature so subscribers can intercept the no-price fallback with full knowledge of the SKU state; the call site now passesPriceInSKUandSKU.Fixes AB#641452