Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.
This repository was archived by the owner on Oct 19, 2026. It is now read-only.

[Event Request] codeunit 1303 "Correct Posted Sales Invoice" - OnBeforeUpdateSalesOrderLinePrepmtAmount #30424

Closed

Description

Why do you need this change?

We would like to request a new integration event to skip updating the prepayment amounts on sales order lines when posting a return order with prepayments in the UpdateSalesOrderLinePrepmtAmount function in codeunit 1303 "Correct Posted Sales Invoice".

Describe the request

We suggest a new integration event here after the currency variable is retrieved in the function:

    [IntegrationEvent(false, false)]
    local procedure OnBeforeUpdateSalesOrderLinePrepmtAmount(SalesInvoiceLine: Record "Sales Invoice Line"; SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"; Currency: Record "Currency"; var IsHandled: Boolean)
    begin
    end;
Image Internal work item: [AB#648506](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/648506)

Activity

  1. added
    missing-infoThe issue misses information that prevents it from completion.
    on Aug 17, 2026
  2. github-actions commented on Aug 17, 2026

    @github-actions
    Contributor

    Hi Tuan Nguyen (@tuan-nguyen-fenwick),

    Thank you for your extensibility request. To help us process it efficiently, please update the issue to include the required information.

    📚 Extensibility Guidelines

    Missing Information:

    • Existing extensibility options reviewed: Explain what existing events or extension patterns were evaluated and why they are insufficient for this scenario.
    • IsHandled justification: Explain why an IsHandled bypass is required instead of a regular event or another extensibility design.
    • Execution frequency / performance impact: Describe the expected execution frequency and any performance considerations for this event.
    • Sensitive data exposure assessment: Confirm whether this change would expose any sensitive data and, if so, how that risk is addressed.
    • Multiple-subscriber conflict considerations: Describe expected behavior and any risks if multiple extensions subscribe to the handled event.

    Please update the issue with the missing details. We'll automatically re-analyze once updated.

    Note

    Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.

    Tip

    Not accurate? Reply with /not-accurate (optional: add a short explanation). Your feedback improves future responses.

  3. tuan-nguyen-fenwick commented on Aug 28, 2026

    @tuan-nguyen-fenwick
    ContributorAuthor
    • Existing extensibility options reviewed: There is no alternative option to handle prepayment amounts update back to the sales order after posting a return order.
    • IsHandled justification: Under some circumstances, the prepayment amounts should not be updated back to the open order.
    • Execution frequency / performance impact: Should only impact sales prepayment orders.
    • Sensitive data exposure assessment: Minimal.
    • Multiple-subscriber conflict considerations: The event is intended to be used with manual-binding subscriber so conflict should be minimal.
  4. added
    missing-infoThe issue misses information that prevents it from completion.
    and removed
    missing-infoThe issue misses information that prevents it from completion.
    on Aug 28, 2026
  5. github-actions commented on Aug 28, 2026

    @github-actions
    Contributor

    Hi Tuan Nguyen (@tuan-nguyen-fenwick),

    Thank you for your extensibility request. To help us process it efficiently, please update the issue to include the required information.

    📚 Extensibility Guidelines

    Missing Information:

    • Safe handling of skipped prepayment state updates: Confirm that your extension will safely handle the prepayment field and record state updates that would be bypassed by this IsHandled event in UpdateSalesOrderLinePrepmtAmount, including the SalesLine.Modify(true) path.

    Please update the issue with the missing details. We'll automatically re-analyze once updated.

    Note

    Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.

    Tip

    Not accurate? Reply with /not-accurate (optional: add a short explanation). Your feedback improves future responses.

  6. tuan-nguyen-fenwick commented on Sep 1, 2026

    @tuan-nguyen-fenwick
    ContributorAuthor

    Safe handling of skipped prepayment state updates: Yes.

  7. added
    SCMGitHub request for SCM area
    event-requestRequest for adding an event
    and removed
    missing-infoThe issue misses information that prevents it from completion.
    on Sep 1, 2026
  8. github-actions commented on Sep 1, 2026

    @github-actions
    Contributor

    ✅ Analysis complete - ready for further processing


    Implementation:

    Add a new handled integration event in UpdateSalesOrderLinePrepmtAmount() after the currency is initialized so extensions can skip the standard prepayment amount update logic.

    Location in UpdateSalesOrderLinePrepmtAmount() procedure:

        local procedure UpdateSalesOrderLinePrepmtAmount(SalesInvoiceLine: Record "Sales Invoice Line")
        var
            CurrExchRate: Record "Currency Exchange Rate";
            SalesHeader: Record "Sales Header";
            SalesLine: Record "Sales Line";
            Currency: Record Currency;
            IsHandled: Boolean;
        begin
            if not SalesLine.Get(
                SalesLine."Document Type"::Order,
                SalesInvoiceLine."Order No.",
                SalesInvoiceLine."Order Line No.")
            then
                exit;
    
            if (SalesLine."Prepayment Amount" = 0) or SalesInvoiceLine."Prepayment Line" then
                exit;
    
            SalesHeader.Get(SalesLine."Document Type"::Order, SalesLine."Document No.");
            Currency.Initialize(SalesHeader."Currency Code", true);
    
            IsHandled := false;
            OnUpdateSalesOrderLinePrepmtAmountOnBeforeUpdatePrepmtAmounts(
                SalesInvoiceLine, SalesLine, SalesHeader, Currency, IsHandled);
            if IsHandled then
                exit;
    
            if SalesHeader."Currency Code" <> '' then
                SalesLine.Validate(
                    "Prepmt. Amount Inv. (LCY)",
                    SalesLine."Prepmt. Amount Inv. (LCY)" +
                        Round(
                            CurrExchRate.ExchangeAmtFCYToLCY(
                                SalesHeader."Posting Date",
                                SalesHeader."Currency Code",

    Event Publisher (add at the end of the codeunit with other events):

        /// <summary>
        /// Raised before updating prepayment amounts on a sales order line during correction.
        /// </summary>
        /// <param name="SalesInvoiceLine">The sales invoice line being processed.</param>
        /// <param name="SalesLine">The sales order line that would be updated.</param>
        /// <param name="SalesHeader">The related sales order header.</param>
        /// <param name="Currency">The initialized currency for the sales order.</param>
        /// <param name="IsHandled">Set to true to skip the default prepayment amount update.</param>
        [IntegrationEvent(false, false)]
        local procedure OnUpdateSalesOrderLinePrepmtAmountOnBeforeUpdatePrepmtAmounts(SalesInvoiceLine: Record "Sales Invoice Line"; var SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"; Currency: Record Currency; var IsHandled: Boolean)
        begin
        end;

    File: CorrectPostedSalesInvoice.Codeunit.al

    Note

    Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.

    Tip

    Not accurate? Reply with /not-accurate (optional: add a short explanation). Your feedback improves future responses.

  9. JesperSchulz commented on Sep 3, 2026

    @JesperSchulz
    Contributor

    The requested change has been implemented in microsoft/BCApps#10902, and the corresponding Azure Boards work item 648506 is resolved as fixed. Closing this issue as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an eventext-ready-to-implementReviewed and ready to implement and create PR

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions