ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

codeunit 22 "Item Jnl.-Post Line"

Open xtiche opened this issue 3 years ago • 1 comments

Business process: The setup allows sales in minus. We sell Item1 from Location1, posting date of sale is 20.01.2023 and after 2 days, to increase the quantity we transfer item1 from location2 to Location1, but the posting date is 18.01.2023. On posting the transfer receipt we have the error: "There is no Value Entry in filter:..."

This happend in this place image

Because in function InsertTransferEntry system at first create "Item Application Entry" and after that Item Ledger Entry and Value Entry.

local procedure InsertTransferEntry(var ItemLedgEntry: Record "Item Ledger Entry"; var OldItemLedgEntry: Record "Item Ledger Entry"; AppliedQty: Decimal)
    var
        NewItemLedgEntry: Record "Item Ledger Entry";
        NewValueEntry: Record "Value Entry";
        ItemLedgEntry2: Record "Item Ledger Entry";
        IsReserved: Boolean;
        IsHandled: Boolean;
    begin
        with ItemJnlLine do begin
         
            ....

            OnInsertTransferEntryOnBeforeInsertApplEntry(NewItemLedgEntry, ItemLedgEntry);
            if AverageTransfer then begin
                InsertApplEntry(
                  NewItemLedgEntry."Entry No.", NewItemLedgEntry."Entry No.", ItemLedgEntry."Entry No.",
                  0, NewItemLedgEntry."Posting Date", NewItemLedgEntry.Quantity, true);
                NewItemLedgEntry."Completely Invoiced" := ItemLedgEntry."Completely Invoiced";
            end else begin
                InsertApplEntry(
                  NewItemLedgEntry."Entry No.", NewItemLedgEntry."Entry No.", ItemLedgEntry."Entry No.",
                  OldItemLedgEntry."Entry No.", NewItemLedgEntry."Posting Date", NewItemLedgEntry.Quantity, true);
                NewItemLedgEntry."Completely Invoiced" := OldItemLedgEntry."Completely Invoiced";
            end;

              ...

            ApplyItemLedgEntry(NewItemLedgEntry, ItemLedgEntry2, NewValueEntry, true);  // issue here
            AutoTrack(NewItemLedgEntry, IsReserved);

            OnBeforeInsertTransferEntry(NewItemLedgEntry, OldItemLedgEntry, ItemJnlLine);

            InsertItemLedgEntry(NewItemLedgEntry, true);
            InsertValueEntry(NewValueEntry, NewItemLedgEntry, true);

            UpdateUnitCost(NewValueEntry);

            OnAfterInsertTransferEntry(ItemJnlLine, NewItemLedgEntry, OldItemLedgEntry);
        end;
    end;

xtiche avatar Apr 26 '23 12:04 xtiche

Sorry about the long reply-time on this issue. I wasn't aware that this many bugs had been filed here, and hence wasn't monitoring this repo.

Unfortunately, this repository is only for extensibility requests for Dynamics 365 Business Central or pull requests towards the 1st party Business Central apps. We suggest that you open a support case or file a bug to ensure that all Business Central users benefit from your catch as soon as possible:

On premises - https://support.microsoft.com/en-us/supportforbusiness/productselection?sapId=93d37907-ad94-d591-22e9-593cfa09dd3f

Cloud – contact your partner, or if you are a partner open a support incident through Partner Center - https://partner.microsoft.com/en-us/pcv/dashboard/overview

JesperSchulz avatar Feb 15 '24 13:02 JesperSchulz