[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 1 commit into
Conversation
…of Purch. Price Calc. Mgt. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| repeat | ||
| if IsInMinQty(PurchPrice."Unit of Measure Code", PurchPrice."Minimum Quantity") then begin | ||
| InMinQty := IsInMinQty(PurchPrice."Unit of Measure Code", PurchPrice."Minimum Quantity"); | ||
| OnCalcBestDirectUnitCostOnAfterIsInMinQty(PurchPrice, QtyPerUOM, Qty, InMinQty); |
There was a problem hiding this comment.
The new OnCalcBestDirectUnitCostOnAfterIsInMinQty and OnCalcBestDirectUnitCostOnBeforeCaseStatement integration events are both raised inside the repeat...until loop that iterates over PurchPrice records (lines 310-341), so every subscriber now runs once per purchase price agreement row instead of once per call to CalcBestDirectUnitCost.
A subscriber doing non-trivial work multiplies its cost by the row count. Consider whether the per-row hook is genuinely required, or whether the extension point can be exposed once before/after the loop with enough context (a buffer or the full record set) for subscribers to act on.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
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. |
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