[Event Request] Codeunit 22 "Item Jnl.-Post Line"."Code" #27929
Open
Description
Describe the request
Please add new event
local procedure "Code"()
var
IsHandled: Boolean;
begin
OnBeforePostItemJnlLine(ItemJnlLine, CalledFromAdjustment, CalledFromInvtPutawayPick, ItemReg, ItemLedgEntryNo, ValueEntryNo, ItemApplnEntryNo);
if ItemJnlLine.EmptyLine() and not ItemJnlLine.Correction and not ItemJnlLine.Adjustment then
if not ItemJnlLine.IsValueEntryForDeletedItem() then
exit;
ItemJnlCheckLine.SetCalledFromInvtPutawayPick(CalledFromInvtPutawayPick);
ItemJnlCheckLine.SetCalledFromAdjustment(CalledFromAdjustment);
OnCodeOnBeforeRunCheck(ItemJnlCheckLine, ItemJnlLine);
ItemJnlCheckLine.RunCheck(ItemJnlLine);
//------------------------------------------------------OnCodeOnAfterRunCheck:BEGIN
OnCodeOnAfterRunCheck(ItemJnlLine);
//------------------------------------------------------OnCodeOnAfterRunCheck:END
if ItemJnlLine."Document Date" = 0D then
ItemJnlLine."Document Date" := ItemJnlLine."Posting Date";
if ItemJnlLine."VAT Reporting Date" = 0D then
ItemJnlLine."VAT Reporting Date" := GLSetup.GetVATDate(ItemJnlLine."Posting Date", ItemJnlLine."Document Date");
if ItemLedgEntryNo = 0 then begin
GlobalItemLedgEntry.LockTable();
ItemLedgEntryNo := GlobalItemLedgEntry.GetLastEntryNo();
GlobalItemLedgEntry."Entry No." := ItemLedgEntryNo;
end;
InitValueEntryNo();
GetInvtSetup();
if not CalledFromAdjustment then
PostToGL := InvtSetup."Automatic Cost Posting";
OnCheckPostingCostToGL(PostToGL);
IsHandled := false;
OnCodeOnBeforeCheckItemTracking(ItemJnlLine, DisableItemTracking, IsHandled, TempTrackingSpecification, GlobalItemTrackingSetup);
if not IsHandled then
if GlobalItemTrackingSetup.TrackingRequired() and (ItemJnlLine."Quantity (Base)" <> 0) and
(ItemJnlLine."Value Entry Type" = ItemJnlLine."Value Entry Type"::"Direct Cost") and
not DisableItemTracking and not ItemJnlLine.Adjustment and
not ItemJnlLine.Subcontracting and not ItemJnlLine.IsAssemblyResourceConsumpLine()
then
CheckItemTracking();
if ItemJnlLine.Correction then
UndoQuantityPosting();
if (ItemJnlLine."Entry Type" in
[ItemJnlLine."Entry Type"::Consumption, ItemJnlLine."Entry Type"::Output, ItemJnlLine."Entry Type"::"Assembly Consumption", ItemJnlLine."Entry Type"::"Assembly Output"]) and
not (ItemJnlLine."Value Entry Type" = ItemJnlLine."Value Entry Type"::Revaluation) and
not ItemJnlLine.OnlyStopTime()
then begin
case ItemJnlLine."Entry Type" of
ItemJnlLine."Entry Type"::"Assembly Consumption", ItemJnlLine."Entry Type"::"Assembly Output":
ItemJnlLine.TestField("Order Type", ItemJnlLine."Order Type"::Assembly);
ItemJnlLine."Entry Type"::Consumption, ItemJnlLine."Entry Type"::Output:
ItemJnlLine.TestField("Order Type", ItemJnlLine."Order Type"::Production);
end;
IsHandled := false;
OnCodeOnBeforeTestOrder(ItemJnlLine, IsHandled);
if not IsHandled then begin
ItemJnlLine.TestField("Order No.");
if ItemJnlLine.IsAssemblyOutputLine() then
ItemJnlLine.TestField("Order Line No.", 0)
else
ItemJnlLine.TestField("Order Line No.");
end;
end;
GetGeneralPostingSetup(ItemJnlLine);
if ItemJnlLine."Qty. per Unit of Measure" = 0 then
ItemJnlLine."Qty. per Unit of Measure" := 1;
if ItemJnlLine."Qty. per Cap. Unit of Measure" = 0 then
ItemJnlLine."Qty. per Cap. Unit of Measure" := 1;
OnCodeOnBeforeSetQuantity(ItemJnlLine);
ItemJnlLine.Quantity := ItemJnlLine."Quantity (Base)";
ItemJnlLine."Invoiced Quantity" := ItemJnlLine."Invoiced Qty. (Base)";
ItemJnlLine."Setup Time" := ItemJnlLine."Setup Time (Base)";
ItemJnlLine."Run Time" := ItemJnlLine."Run Time (Base)";
ItemJnlLine."Stop Time" := ItemJnlLine."Stop Time (Base)";
ItemJnlLine."Output Quantity" := ItemJnlLine."Output Quantity (Base)";
ItemJnlLine."Scrap Quantity" := ItemJnlLine."Scrap Quantity (Base)";
if not ItemJnlLine.Subcontracting and
((ItemJnlLine."Entry Type" = ItemJnlLine."Entry Type"::Output) or
ItemJnlLine.IsAssemblyResourceConsumpLine())
then
QtyPerUnitOfMeasure := ItemJnlLine."Qty. per Cap. Unit of Measure"
else
QtyPerUnitOfMeasure := ItemJnlLine."Qty. per Unit of Measure";
OnCodeOnAfterCalcQtyPerUnitOfMeasure(ItemJnlLine, ItemJnlLine.Subcontracting, QtyPerUnitOfMeasure);
RoundingResidualAmount := 0;
RoundingResidualAmountACY := 0;
RoundingResidualAmount := ItemJnlLine.Quantity *
(ItemJnlLine."Unit Cost" / QtyPerUnitOfMeasure - Round(ItemJnlLine."Unit Cost" / QtyPerUnitOfMeasure, GLSetup."Unit-Amount Rounding Precision"));
RoundingResidualAmountACY := ItemJnlLine.Quantity *
(ItemJnlLine."Unit Cost (ACY)" / QtyPerUnitOfMeasure - Round(ItemJnlLine."Unit Cost (ACY)" / QtyPerUnitOfMeasure, Currency."Unit-Amount Rounding Precision"));
ItemJnlLine."Unit Amount" := Round(
ItemJnlLine."Unit Amount" / QtyPerUnitOfMeasure, GLSetup."Unit-Amount Rounding Precision");
ItemJnlLine."Unit Cost" := Round(
ItemJnlLine."Unit Cost" / QtyPerUnitOfMeasure, GLSetup."Unit-Amount Rounding Precision");
ItemJnlLine."Unit Cost (ACY)" := Round(
ItemJnlLine."Unit Cost (ACY)" / QtyPerUnitOfMeasure, Currency."Unit-Amount Rounding Precision");
OverheadAmount := 0;
VarianceAmount := 0;
OverheadAmountACY := 0;
VarianceAmountACY := 0;
VarianceRequired := false;
LastOperation := false;
OnBeforePostLineByEntryType(ItemJnlLine, CalledFromAdjustment, CalledFromInvtPutawayPick);
case true of
ItemJnlLine.IsAssemblyResourceConsumpLine():
PostAssemblyResourceConsump();
ItemJnlLine.Adjustment,
ItemJnlLine."Value Entry Type" in [ItemJnlLine."Value Entry Type"::Rounding, ItemJnlLine."Value Entry Type"::Revaluation],
ItemJnlLine."Entry Type" = ItemJnlLine."Entry Type"::"Assembly Consumption",
ItemJnlLine."Entry Type" = ItemJnlLine."Entry Type"::"Assembly Output":
PostItem();
ItemJnlLine."Entry Type" = ItemJnlLine."Entry Type"::Consumption:
PostConsumption();
ItemJnlLine."Entry Type" = ItemJnlLine."Entry Type"::Output:
PostOutput();
not ItemJnlLine.Correction:
PostItem();
end;
// Entry no. is returned to shipment/receipt
if ItemJnlLine.Subcontracting then
ItemJnlLine."Item Shpt. Entry No." := CapLedgEntryNo
else
ItemJnlLine."Item Shpt. Entry No." := GlobalItemLedgEntry."Entry No.";
OnAfterPostItemJnlLine(ItemJnlLine, GlobalItemLedgEntry, ValueEntryNo, InventoryPostingToGL, CalledFromAdjustment, CalledFromInvtPutawayPick, ItemReg, ItemLedgEntryNo, ItemApplnEntryNo, WhseJnlRegisterLine);
end;
//------------------------------------------------------OnCodeOnAfterRunCheck:BEGIN
[IntegrationEvent(true, false)]
local procedure OnCodeOnAfterRunCheck(var ItemJnlLine: Record "Item Journal Line")
begin
end;
//------------------------------------------------------OnCodeOnAfterRunCheck:END
Additional context
We need do action after run checks
Internal work item: AB#562611