ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] Codeunit 80 "Sales-Post" - Function "PostItemChargePerShpt" - OnBeforeDistributeChargeCalculation

Open SWE-Tina opened this issue 5 years ago • 5 comments

Due to Service Value Credit Memos we need to have a different source where to get the information of "Quantity (Base)" from and when DistributeCharge is calculated. After all checks and calculations we have another call in the "If DistributeCharge then" for the service value credit memos. Therefore we need a possibility to exit the function with IsHandled (not just the Job No TESTFIELD) after "OnPostItemChargePerShptOnBeforeTestJobNo(SalesShptLine, IsHandled, SalesLine); if not IsHandled then SalesShptLine.TestField("Job No.", '');"

and proceed the function with its specialties in the event subscriber. Event should look like this:

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnBeforeDistributeChargeCalculation', '', true, true)]
local procedure "Sales-Post_OnBeforeDistributeChargeCalculation"
(
    SalesShipmentLine: Record "Sales Shipment Line";
    TempItemChargeAssgntSales: Record "Item Charge Assignment Sales";
    DistributeCharge; Boolean;
    IsHandled: Boolean;
    QTYBase: Decimal;
).

SWE-Tina avatar Dec 07 '20 14:12 SWE-Tina

Please always put the full detailed signature of the requested events. You help us implementing the requests faster when your request contains AL code copied from VSCode instead of screenshots. e.g. https://github.com/microsoft/ALAppExtensions/issues/10147

StanPesotskiy avatar Dec 08 '20 10:12 StanPesotskiy

The signature is (as text) available in the original comment, completely with all wanted parameters? What are you missing?

Preferred placement in the code: local procedure PostItemChargePerShpt(SalesHeader: Record "Sales Header"; var SalesLine: Record "Sales Line") var SalesShptLine: Record "Sales Shipment Line"; TempItemLedgEntry: Record "Item Ledger Entry" temporary; ItemTrackingMgt: Codeunit "Item Tracking Management"; DistributeCharge: Boolean; IsHandled: Boolean; begin if not SalesShptLine.Get( TempItemChargeAssgntSales."Applies-to Doc. No.", TempItemChargeAssgntSales."Applies-to Doc. Line No.") then Error(ShipmentLinesDeletedErr);

    IsHandled := false;
    OnPostItemChargePerShptOnBeforeTestJobNo(SalesShptLine, IsHandled, SalesLine);
    if not IsHandled then
        SalesShptLine.TestField("Job No.", '');

### OnBeforeDistributeChargeCalculation

SWE-Tina avatar Dec 08 '20 12:12 SWE-Tina

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. We will update this issue with information about availability. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

JesperSchulz avatar Dec 09 '20 16:12 JesperSchulz

I just saw, that I missed two needed parameters, please deliver them as well :). Thanks in advance and sorry not forgetting them.

Here's the updated signature:

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnBeforeDistributeChargeCalculation', '', true, true)] local procedure "Sales-Post_OnBeforeDistributeChargeCalculation" ( SalesShipmentLine: Record "Sales Shipment Line"; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; TempItemChargeAssgntSales: Record "Item Charge Assignment Sales"; DistributeCharge; Boolean; IsHandled: Boolean; QTYBase: Decimal; )

SWE-Tina avatar Feb 04 '21 14:02 SWE-Tina

This is the closed request. It will not be handled. Please create a new one and add a link to the original one.

StanPesotskiy avatar Feb 04 '21 19:02 StanPesotskiy