Codeunit 99000823 Mfg. Item Jnl.-Post Batch, source in 29
Source29
src/Layers/W1/BaseApp/Manufacturing/Inventory/Posting/MfgItemJnlPostBatch.Codeunit.al103 lines, Copyright (c) Microsoft Corporation. MIT
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.Inventory.Posting;
using Microsoft.Inventory.Journal;
using Microsoft.Inventory.Location;
using Microsoft.Inventory.Tracking;
using Microsoft.Manufacturing.Document;
using Microsoft.Warehouse.Activity;
codeunit 99000823 "Mfg. Item Jnl.-Post Batch"
{
SingleInstance = true;
var
MfgCreatePutaway: Codeunit "Mfg. Create Put-away";
#if not CLEAN27
ItemJnlPostBatch: Codeunit "Item Jnl.-Post Batch";
#endif
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Batch", 'OnBeforePostLines', '', true, false)]
local procedure OnBeforePostLines()
begin
// Ensure that reference is not stale
Clear(MfgCreatePutaway);
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Batch", 'OnHandleWhsePutAwayForProdOutput', '', true, false)]
local procedure OnHandleWhsePutAwayForProdOutput(var ItemJnlLine: Record "Item Journal Line")
begin
HandleWhsePutAwayForProdOutput(ItemJnlLine);
end;
local procedure HandleWhsePutAwayForProdOutput(ItemJournalLine: Record "Item Journal Line")
begin
if ItemJournalLine.OutputValuePosting() then
exit;
if ItemJournalLine."Entry Type" <> ItemJournalLine."Entry Type"::Output then
exit;
if (ItemJournalLine."Order No." = '') or (ItemJournalLine."Order Line No." = 0) then
exit;
MfgCreatePutaway.IncludeIntoWhsePutAwayForProdOrder(ItemJournalLine);
OnAfterHandleWhsePutAwayForProdOutput(ItemJournalLine);
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Batch", 'OnAfterPostLines', '', true, false)]
local procedure OnAfterPostLines(var ItemJournalLine: Record "Item Journal Line"; var ItemRegNo: Integer; var WhseRegNo: Integer)
begin
MfgCreatePutaway.CreateWhsePutAwayForProdOutput();
// Clean-up reference
Clear(MfgCreatePutaway);
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Batch", 'OnCheckItemAvailabilityOnAfterSetAvailableQty', '', true, false)]
local procedure OnCheckItemAvailabilityOnAfterSetAvailableQty(var TempSKU: Record "Stockkeeping Unit" temporary; var ItemJnlLine: Record "Item Journal Line"; var AvailableQty: Decimal)
begin
AvailableQty += SelfReservedQty(TempSKU, ItemJnlLine);
end;
local procedure SelfReservedQty(SKU: Record "Stockkeeping Unit"; ItemJnlLine: Record "Item Journal Line") Result: Decimal
var
ReservationEntry: Record "Reservation Entry";
IsHandled: Boolean;
begin
IsHandled := false;
OnBeforeSelfReservedQty(SKU, ItemJnlLine, Result, IsHandled);
#if not CLEAN27
ItemJnlPostBatch.RunOnBeforeSelfReservedQty(SKU, ItemJnlLine, Result, IsHandled);
#endif
if IsHandled then
exit(Result);
if ItemJnlLine."Order Type" <> ItemJnlLine."Order Type"::Production then
exit;
ReservationEntry.SetRange("Reservation Status", ReservationEntry."Reservation Status"::Reservation);
ReservationEntry.SetRange("Item No.", SKU."Item No.");
ReservationEntry.SetRange("Location Code", SKU."Location Code");
ReservationEntry.SetRange("Variant Code", SKU."Variant Code");
ReservationEntry.SetRange("Source Type", Database::"Prod. Order Component");
ReservationEntry.SetRange("Source ID", ItemJnlLine."Order No.");
if ReservationEntry.IsEmpty() then
exit;
ReservationEntry.CalcSums(ReservationEntry."Quantity (Base)");
exit(-ReservationEntry."Quantity (Base)");
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeSelfReservedQty(SKU: Record "Stockkeeping Unit"; ItemJnlLine: Record "Item Journal Line"; var Result: Decimal; var IsHandled: Boolean)
begin
end;
[IntegrationEvent(false, false)]
local procedure OnAfterHandleWhsePutAwayForProdOutput(ItemJournalLine: Record "Item Journal Line")
begin
end;
}