Skip to content

[Extensibility Request] issue 29074: expose PurchLineQty in OnSumPurchLines2OnBeforeDivideAmount - #9863

Merged
AleksandricMarko merged 1 commit into
mainfrom
ai-ext-fix/ext_issue-29074
Aug 3, 2026
Merged

[Extensibility Request] issue 29074: expose PurchLineQty in OnSumPurchLines2OnBeforeDivideAmount#9863
AleksandricMarko merged 1 commit into
mainfrom
ai-ext-fix/ext_issue-29074

Conversation

@AleksandricMarko

@AleksandricMarko AleksandricMarko commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

4PS Construct implements an "Amounts only" purchasing mode that processes purchase lines by monetary amount rather than physical quantity, which requires adjusting the calculated quantity before the amount-division logic runs. In SumPurchLines2, the OnSumPurchLines2OnBeforeDivideAmount event fires right before DivideAmount but does not expose the calculated PurchLineQty, so subscribers have no way to influence the quantity used for the division. This change adds PurchLineQty to that event by reference so subscribers can adjust it before DivideAmount runs.

Source issue repository: microsoft/ALAppExtensions; issue number: 29074

Changes Made

  • OnSumPurchLines2OnBeforeDivideAmount - added a new var PurchLineQty: Decimal parameter at the end of the event signature and passed the local PurchLineQty variable at the call site in SumPurchLines2, so subscribers can adjust the quantity before DivideAmount executes. Propagated to the same-named event in every country layer that has its own copy of PurchPost.Codeunit.al (APAC, BE, CH, ES, FI, GB, IT, NA, RU).

Fixes AB#597602

@AleksandricMarko AleksandricMarko added event-request SCM GitHub request for SCM area labels Jul 30, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 30, 2026
@AleksandricMarko
AleksandricMarko marked this pull request as ready for review July 31, 2026 07:21
@AleksandricMarko
AleksandricMarko requested a review from a team July 31, 2026 07:21
@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟠\ High\ Severity\ —\ Events}$

Appending a parameter to this local IntegrationEvent is fine, but the new event parameter is named PurchLineQty, which abbreviates "Purchase" to "Purch" and "Quantity" to "Qty". The sibling parameters on the same event (PurchaseHeader, PurchaseLine) use full, unabbreviated names. Rename the new parameter to a fully spelled-out name such as PurchaseLineQuantity to keep the subscriber contract self-explanatory and consistent with the rest of the signature.

Suggested fix (apply manually — could not be anchored as a one-click suggestion):

    local procedure OnSumPurchLines2OnBeforeDivideAmount(PurchaseHeader: Record "Purchase Header"; var PurchaseLine: Record "Purchase Line"; QtyType: Option General,Invoicing,Shipping; var PurchaseLineQuantity: Decimal)

Knowledge:

Line mapping was unavailable, so this was posted as an issue comment.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.26.4

@PredragMaricic PredragMaricic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking findings. The by-reference PurchLineQty parameter is exposed at the correct point before DivideAmount and is propagated consistently across all country-layer copies.

@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Agentic PR Review - Round 1

Recommendation: Accept

What this PR does

Adds a var PurchLineQty: Decimal parameter to the existing OnSumPurchLines2OnBeforeDivideAmount integration event in Codeunit 90 "Purch.-Post", across all 10 country layers. This enables subscribers to modify the computed purchase-line quantity before DivideAmount runs — needed for "Amounts only" purchasing scenarios where quantity must be overridden.

The value is fully computed at the call site (the case/switch block that assigns PurchLineQty completes immediately before the event fires). The parameter is var, which is correct — the entire purpose is to allow subscribers to override it before DivideAmount consumes it. The sibling OnAfterDivideAmount event already exposes PurchLineQty (by value), confirming naming and position are consistent. The change is mechanical and identical across all layers.

Adding a parameter to an already-published event is technically a compile-time break for existing subscribers. However, BCApps policy accepts this pattern for extensibility requests (confirmed by commit 5dbc86e, 409230a, and others merged in the same wave). Partners must update their subscriber signatures on the next major version — this is expected.

Suggestions

None.

Risk assessment and necessity

Risk: Low for the platform. Existing partner subscribers of this event will get a compile error on the next BC major version and must add the new parameter — this is a known, accepted consequence of in-place event extensions in BCApps. No runtime behavioral change for subscribers that do not modify the new parameter. No performance impact.

Necessity: Without this parameter, a subscriber cannot override PurchLineQty before DivideAmount. The PurchLine record parameter does not carry the computed quantity (it is a local variable derived from multiple fields depending on QtyType). The scenario (amounts-only purchasing) is real and concrete (GitHub issue #29074, ADO AB#597602).


[AI-PR-REVIEW] version=1 system=github pr=9863 round=1 by=alexei-dobriansky at=2026-08-03T09:30:00Z lastSha=8fca122eb108747457ef45e060b75881eaa3e22c suggestions=none

@AleksandricMarko
AleksandricMarko added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit a7209f2 Aug 3, 2026
335 of 337 checks passed
@AleksandricMarko
AleksandricMarko deleted the ai-ext-fix/ext_issue-29074 branch August 3, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

event-request SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants