Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Event Request] Codeunit 5988 "Serv-Documents Mgt." - UpdateShptLinesOnInv #28178

Open
ISliceUrPanties opened this issue Feb 19, 2025 · 0 comments

Comments

@ISliceUrPanties
Copy link

Describe the request

Hello,
please extend UpdateShptLinesOnInv and add an event with ishandled-pattern before the testfields.
There is some similar function in Codeunit Purch.-Post for procudure PostItemTrackingForReceipt with procedure CheckPurchRcptLine.

local procedure UpdateShptLinesOnInv(var ServiceLine: Record "Service Line"; var RemQtyToBeInvoiced: Decimal; var RemQtyToBeInvoicedBase: Decimal; var RemQtyToBeConsumed: Decimal; var RemQtyToBeConsumedBase: Decimal)
var
    ServiceShptLine: Record "Service Shipment Line";
    ItemEntryRelation: Record "Item Entry Relation";
    QtyToBeInvoiced: Decimal;
    QtyToBeInvoicedBase: Decimal;
    QtyToBeConsumed: Decimal;
    QtyToBeConsumedBase: Decimal;
    EndLoop: Boolean;
    // NEW >>
    IsHandled: Boolean;
    // NEW <<
begin
    EndLoop := false;
    if ((Abs(RemQtyToBeInvoiced) > Abs(ServiceLine."Qty. to Ship")) and Invoice) or
        ((Abs(RemQtyToBeConsumed) > Abs(ServiceLine."Qty. to Ship")) and Consume)
    then begin
        ServiceShptLine.Reset();
        case ServHeader."Document Type" of
            ServHeader."Document Type"::Order:
                begin
                    ServiceShptLine.SetCurrentKey("Order No.", "Order Line No.");
                    ServiceShptLine.SetRange("Order No.", ServiceLine."Document No.");
                    ServiceShptLine.SetRange("Order Line No.", ServiceLine."Line No.");
                end;
            ServHeader."Document Type"::Invoice:
                begin
                    ServiceShptLine.SetRange("Document No.", ServiceLine."Shipment No.");
                    ServiceShptLine.SetRange("Line No.", ServiceLine."Shipment Line No.");
                end;
        end;

        ServiceShptLine.SetFilter("Qty. Shipped Not Invoiced", '<>0');
        if ServiceShptLine.Find('-') then begin
            ServPostingJnlsMgt.SetItemJnlRollRndg(true);
            repeat
                if TrackingSpecificationExists then begin
                    ItemEntryRelation.Get(TempInvoicingSpecification."Item Ledger Entry No.");
                    ServiceShptLine.Get(ItemEntryRelation."Source ID", ItemEntryRelation."Source Ref. No.");
                end else
                    ItemEntryRelation."Item Entry No." := ServiceShptLine."Item Shpt. Entry No.";
                // NEW >>
                IsHandled := false;
                OnUpdateShptLineOnInvOnBeforeTestServiceShptLine(ServiceShptLine, ServiceLine, IsHandled);
                if not IsHandled then begin
                // NEW <<<
                    ServiceShptLine.TestField("Customer No.", ServiceLine."Customer No.");
                    ServiceShptLine.TestField(Type, ServiceLine.Type);
                    ServiceShptLine.TestField("No.", ServiceLine."No.");
                    ServiceShptLine.TestField("Gen. Bus. Posting Group", ServiceLine."Gen. Bus. Posting Group");
                    ServiceShptLine.TestField("Gen. Prod. Posting Group", ServiceLine."Gen. Prod. Posting Group");

                    ServiceShptLine.TestField("Unit of Measure Code", ServiceLine."Unit of Measure Code");
                    ServiceShptLine.TestField("Variant Code", ServiceLine."Variant Code");
                // NEW >>
                end;
                // NEW <<
                if -ServiceLine."Qty. to Invoice" * ServiceShptLine.Quantity < 0 then
                    ServiceLine.FieldError("Qty. to Invoice", Text011);
// ...

Event definition

[IntegrationEvent(false, false)]
local procedure OnUpdateShptLineOnInvOnBeforeTestServiceShptLine(var ServiceShipmentLine: Record "Service Shipment Line"; ServiceLine: Record "Service Line"; var IsHandled: Boolean)
begin
end;

Thanks in advance!

Regards

Additional context

We have some scenarios, in which we want to test for additional and other fields/values while posting.

@ISliceUrPanties ISliceUrPanties changed the title [Event Request] Codeunit 5988 - UpdateShptLinesOnInv [Event Request] Codeunit 5988 "Serv-Documents Mgt." - UpdateShptLinesOnInv Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant