ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] Codeunit 6620 "Copy Document Mgt." - Procedure "CopyPurchCrMemoLinesToDoc" - new event "OnAfterItemLedgEntryBufSetFilterEntryTypeOnCopyPurchCrMemoLinesToDoc"

Open StHillmann opened this issue 6 years ago • 2 comments

We need to set filter to the variable "ItemLedgEntryBuf" in Procedure "CopyPurchCrMemoLinesToDoc" of Codeunit 6620 "Copy Document Mgt." after your standard filter for lines with "Job No." and before calling the "ItemTrackingDocMgt".

Please add a new event raiser and publisher for doing this.

OLD CODE:

if (Type = Type::Item) and (Quantity <> 0) and ("Prod. Order No." = '') and
   PurchaseDocCanReceiveTracking(ToPurchHeader)
then begin
	FromPurchInvLine."Document No." := OldInvDocNo;
	FromPurchInvLine."Line No." := "Return Shipment Line No.";
	FromPurchInvLine.GetItemLedgEntries(ItemLedgEntryBuf, true);
	if IsCopyItemTrkg(ItemLedgEntryBuf, CopyItemTrkg, FillExactCostRevLink) then begin
		if "Job No." <> '' then
			ItemLedgEntryBuf.SetFilter("Entry Type", '<> %1', ItemLedgEntryBuf."Entry Type"::"Negative Adjmt.");
		if MoveNegLines or not ExactCostRevMandatory then
			ItemTrackingDocMgt.CopyItemLedgerEntriesToTemp(TempTrkgItemLedgEntry, ItemLedgEntryBuf)
		else
			ItemTrackingDocMgt.CollectItemTrkgPerPostedDocLine(
			  TempItemTrkgEntry, TempTrkgItemLedgEntry, true, "Document No.", "Line No.");

NEW CODE:

if (Type = Type::Item) and (Quantity <> 0) and ("Prod. Order No." = '') and
   PurchaseDocCanReceiveTracking(ToPurchHeader)
then begin
	FromPurchInvLine."Document No." := OldInvDocNo;
	FromPurchInvLine."Line No." := "Return Shipment Line No.";
	FromPurchInvLine.GetItemLedgEntries(ItemLedgEntryBuf, true);
	if IsCopyItemTrkg(ItemLedgEntryBuf, CopyItemTrkg, FillExactCostRevLink) then begin
		if "Job No." <> '' then
			ItemLedgEntryBuf.SetFilter("Entry Type", '<> %1', ItemLedgEntryBuf."Entry Type"::"Negative Adjmt.");
                // start kvspsa - Event Raiser
                OnAfterItemLedgEntryBufSetFilterEntryTypeOnCopyPurchCrMemoLinesToDoc(FromPurchLineBuf, ItemLedgEntryBuf);
                // stop kvspsa
		if MoveNegLines or not ExactCostRevMandatory then
			ItemTrackingDocMgt.CopyItemLedgerEntriesToTemp(TempTrkgItemLedgEntry, ItemLedgEntryBuf)
		else
			ItemTrackingDocMgt.CollectItemTrkgPerPostedDocLine(
			  TempItemTrkgEntry, TempTrkgItemLedgEntry, true, "Document No.", "Line No.");

NEW PUBLISHER:

// start kvspsa - Event Publisher
[IntegrationEvent(false, false)]
local procedure OnBeforeItemLedgEntryFindOnSplitPstdPurchLinesPerILE(FromPurchLine: Record "Purchase Line"; var ReturnValue: Boolean; var IsHandled: Boolean)
begin
end;
// stop kvspsa

StHillmann avatar Mar 24 '20 14:03 StHillmann

sorry. Wrong Publisher!

Correct Publisher Code:

// start kvspsa - Event Publisher
[IntegrationEvent(false, false)]
local procedure OnAfterItemLedgEntryBufSetFilterEntryTypeOnCopyPurchCrMemoLinesToDoc(var FromPurchLineBuf: Record "Purchase Line"; var ItemLedgEntryBuf: Record "Item Ledger Entry")
begin
end;
// stop kvspsa

StHillmann avatar Mar 24 '20 14:03 StHillmann

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. We will update this issue with information about availability.

bc-ghost avatar Mar 28 '20 05:03 bc-ghost