ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[EVENT REQUEST] - Codeunit 80 Sales-Post - New Publisher and local procedure

Open mertkanozdilek1 opened this issue 2 years ago • 2 comments

Describe the request

Hi AL Dev Team, We request that the chek operation in Codeunit 80 code be moved to the function.

Additional context

Current Code: procedure PostItemTrackingForShipment(SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; TrackingSpecificationExists: Boolean; var TempTrackingSpecification: Record "Tracking Specification" temporary; var TempItemLedgEntryNotInvoiced: Record "Item Ledger Entry" temporary; HasATOShippedNotInvoiced: Boolean) var ItemEntryRelation: Record "Item Entry Relation"; SalesShptLine: Record "Sales Shipment Line"; RemQtyToInvoiceCurrLine: Decimal; RemQtyToInvoiceCurrLineBase: Decimal; QtyToBeInvoiced: Decimal; QtyToBeInvoicedBase: Decimal; ShouldAdjustQuantityRounding: Boolean; IsHandled: Boolean; begin //.. if SalesShptLine.FindFirst() then begin ItemJnlRollRndg := true; repeat SetItemEntryRelation( ItemEntryRelation, SalesShptLine, TempTrackingSpecification, TempItemLedgEntryNotInvoiced, TrackingSpecificationExists, HasATOShippedNotInvoiced);

            UpdateRemainingQtyToBeInvoiced(SalesShptLine, RemQtyToInvoiceCurrLine, RemQtyToInvoiceCurrLineBase);
            UpdateChargeItemSalesShptLineGenProdPostingGroup(SalesShptLine);
            OnPostItemTrackingForShipmentOnAfterUpdateSalesShptLineFields(SalesShptLine, SalesLine);
            SalesShptLine.TestField("Sell-to Customer No.", SalesLine."Sell-to Customer No.");
            SalesShptLine.TestField(Type, SalesLine.Type);
            SalesShptLine.TestField("No.", SalesLine."No.");
            SalesShptLine.TestField("Gen. Bus. Posting Group", SalesLine."Gen. Bus. Posting Group");
            SalesShptLine.TestField("Gen. Prod. Posting Group", SalesLine."Gen. Prod. Posting Group");
            CheckJobNoOnShptLineEqualToSales(SalesShptLine, SalesLine);
            SalesShptLine.TestField("Unit of Measure Code", SalesLine."Unit of Measure Code");
            SalesShptLine.TestField("Variant Code", SalesLine."Variant Code");
            if -SalesLine."Qty. to Invoice" * SalesShptLine.Quantity < 0 then
                SalesLine.FieldError("Qty. to Invoice", ShipmentSameSignErr);

...// end;

Suggested Code:

procedure PostItemTrackingForShipment(SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; TrackingSpecificationExists: Boolean; var TempTrackingSpecification: Record "Tracking Specification" temporary; var TempItemLedgEntryNotInvoiced: Record "Item Ledger Entry" temporary; HasATOShippedNotInvoiced: Boolean) var ItemEntryRelation: Record "Item Entry Relation"; SalesShptLine: Record "Sales Shipment Line"; RemQtyToInvoiceCurrLine: Decimal; RemQtyToInvoiceCurrLineBase: Decimal; QtyToBeInvoiced: Decimal; QtyToBeInvoicedBase: Decimal; ShouldAdjustQuantityRounding: Boolean; IsHandled: Boolean; begin //.... if SalesShptLine.FindFirst() then begin ItemJnlRollRndg := true; repeat SetItemEntryRelation( ItemEntryRelation, SalesShptLine, TempTrackingSpecification, TempItemLedgEntryNotInvoiced, TrackingSpecificationExists, HasATOShippedNotInvoiced);

            UpdateRemainingQtyToBeInvoiced(SalesShptLine, RemQtyToInvoiceCurrLine, RemQtyToInvoiceCurrLineBase);
            UpdateChargeItemSalesShptLineGenProdPostingGroup(SalesShptLine);
            OnPostItemTrackingForShipmentOnAfterUpdateSalesShptLineFields(SalesShptLine, SalesLine);
            CheckSalesShptLine(SalesShptLine,SalesLine);          

..// end;

local procedure CheckSalesShptLine(var SalesShptLine: Record "Sales Shipment Line"; SalesLine: Record "Sales Line") var IsHandled: Boolean; begin IsHandled := false; OnBeforeCheckSalesShptLine(SalesShptLine, SalesLine, IsHandled); if IsHandled then exit;

   SalesShptLine.TestField("Sell-to Customer No.", SalesLine."Sell-to Customer No.");
   SalesShptLine.TestField(Type, SalesLine.Type);
   SalesShptLine.TestField("No.", SalesLine."No.");
   SalesShptLine.TestField("Gen. Bus. Posting Group", SalesLine."Gen. Bus. Posting Group");
   SalesShptLine.TestField("Gen. Prod. Posting Group", SalesLine."Gen. Prod. Posting Group");
   CheckJobNoOnShptLineEqualToSales(SalesShptLine, SalesLine);
   SalesShptLine.TestField("Unit of Measure Code", SalesLine."Unit of Measure Code");
   SalesShptLine.TestField("Variant Code", SalesLine."Variant Code");
   if -SalesLine."Qty. to Invoice" * SalesShptLine.Quantity < 0 then
      SalesLine.FieldError("Qty. to Invoice", ShipmentSameSignErr);
end;

[IntegrationEvent(false, false)] local procedure OnBeforeCheckReturnRcptLine(var SalesShptLine: Record "Sales Shipment Line"; var SalesLine: Record "Sales Line"; var IsHandled: Boolean) begin end;``` Internal work item: AB#535506

mertkanozdilek1 avatar May 16 '24 12:05 mertkanozdilek1

Hi,

We already have publisher OnPostItemTrackingForShipmentOnBeforeTestLineFields, only it's not in the procedure.

Can you use that publisher?

tomasevicst avatar May 23 '24 10:05 tomasevicst

Closed due inactivity.

tomasevicst avatar May 30 '24 07:05 tomasevicst