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 7326 "Whse. Item Tracking FEFO".SummarizeInventoryFEFO #27667

Open
fridrichovsky opened this issue Nov 22, 2024 · 1 comment
Labels
event-request Request for adding an event SCM GitHub request for SCM area

Comments

@fridrichovsky
Copy link
Contributor

fridrichovsky commented Nov 22, 2024

Describe the request

Please add new event

   local procedure SummarizeInventoryFEFO(Location: Record Location; ItemNo: Code[20]; VariantCode: Code[10]; HasExpirationDate: Boolean)
    var
        ItemTrackingSetup: Record "Item Tracking Setup";
        SummarizedStockByItemTrkg: Query "Summarized Stock By Item Trkg.";
        QtyReservedFromItemLedger: Query "Qty. Reserved From Item Ledger";
        NonReservedQtyLotSN: Decimal;
        IsHandled: Boolean;
        // ----------------------------------------------------------------------------------------:BEGIN
        DoInsertEntrySummary: Boolean;
        // ----------------------------------------------------------------------------------------:END

#if not CLEAN23
        UseLegacyImplementation: Boolean;
#endif
    begin
        IsHandled := false;
        OnBeforeSummarizeInventoryFEFO(Location, ItemNo, VariantCode, HasExpirationDate, IsHandled,
            TempGlobalEntrySummary, StrictExpirationPosting, LastSummaryEntryNo, HasExpiredItems);
        if IsHandled then
            exit;

#if not CLEAN23
        UseLegacyImplementation := false;
        OnSummarizeInventoryFEFOLegacyImplementation(UseLegacyImplementation);
        if UseLegacyImplementation then begin
            SummarizeInventoryFEFO_LegacyImplementation(Location, ItemNo, VariantCode, HasExpirationDate);
            exit;
        end;
#endif
        SummarizedStockByItemTrkg.SetSKUFilters(ItemNo, VariantCode, Location.Code);
        SummarizedStockByItemTrkg.SetRange(Open, true);
        SummarizedStockByItemTrkg.SetRange(Positive, true);
        if HasExpirationDate then
            SummarizedStockByItemTrkg.SetFilter(Expiration_Date, '<>%1', 0D)
        else
            SummarizedStockByItemTrkg.SetRange(Expiration_Date, 0D);

        SummarizedStockByItemTrkg.Open();
        while SummarizedStockByItemTrkg.Read() do begin
            SummarizedStockByItemTrkg.GetItemTrackingSetup(ItemTrackingSetup);
            if not IsItemTrackingBlocked(ItemNo, VariantCode, ItemTrackingSetup) then begin
                NonReservedQtyLotSN := SummarizedStockByItemTrkg.Remaining_Quantity;

                QtyReservedFromItemLedger.SetSKUFilters(ItemNo, VariantCode, Location.Code);
                QtyReservedFromItemLedger.SetTrackingFilters(ItemTrackingSetup);
                QtyReservedFromItemLedger.Open();
                if QtyReservedFromItemLedger.Read() then
                    NonReservedQtyLotSN -= QtyReservedFromItemLedger.Quantity__Base_;
                // ----------------------------------------------------------------------------------------OnSummarizeInventoryFEFOOnBeforeInsertEntrySummaryFEFO:BEGIN
                // ORIG:BEGIN
                //if NonReservedQtyLotSN - CalcNonRegisteredQtyOutstanding(
                //      ItemNo, VariantCode, Location.Code, ItemTrackingSetup, HasExpirationDate) > 0
                //then
                //    InsertEntrySummaryFEFO(ItemTrackingSetup, SummarizedStockByItemTrkg.Expiration_Date);
                // ORIG:END
                DoInsertEntrySummary := NonReservedQtyLotSN - CalcNonRegisteredQtyOutstanding(ItemNo, VariantCode, Location.Code, ItemTrackingSetup
                 , HasExpirationDate) > 0
                OnSummarizeInventoryFEFOOnBeforeInsertEntrySummaryFEFO(Location, ItemNo, VariantCode, HasExpirationDate, NonReservedQtyLotSN, ItemTrackingSetup, SummarizedStockByItemTrkg.Expiration_Date, DoInsertEntrySummary);                    
                if DoInsertEntrySummary then
                    InsertEntrySummaryFEFO(ItemTrackingSetup, SummarizedStockByItemTrkg.Expiration_Date);
                // ----------------------------------------------------------------------------------------OnSummarizeInventoryFEFOOnBeforeInsertEntrySummaryFEFO:END
            end;
        end;
    end;

    // ----------------------------------------------------------------------------------------OnSummarizeInventoryFEFOOnBeforeInsertEntrySummaryFEFO:BEGIN
    [IntegrationEvent(true, false)]
    local procedure OnSummarizeInventoryFEFOOnBeforeInsertEntrySummaryFEFO(Location: Record Location; ItemNo: Code[20]; VariantCode: Code[10]; HasExpirationDate: Boolean; NonReservedQtyLotSN: Decimal; ItemTrackingSetup: Record "Item Tracking Setup"; ExpirationDate: Date; var DoInsertEntrySummary: Boolean)
    begin
    end;
    // ----------------------------------------------------------------------------------------OnSummarizeInventoryFEFOOnBeforeInsertEntrySummaryFEFO:END

Additional context

We need option decide if insert can be raise.
Internal work item: AB#558487

@BardurKnudsen BardurKnudsen added event-request Request for adding an event SCM GitHub request for SCM area labels Nov 25, 2024
@BardurKnudsen
Copy link

Looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-request Request for adding an event SCM GitHub request for SCM area
Projects
None yet
Development

No branches or pull requests

2 participants