ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] report 840 "Suggest Worksheet Lines" - Create new event OnInsertCFLineForVendorLedgerEntryOnBeforeInsertTempCFWorksheetLine

Open Sameer-Utekar opened this issue 2 years ago • 1 comments

Describe the request

Could we please have a new event OnInsertCFLineForVendorLedgerEntryOnBeforeInsertTempCFWorksheetLine in the function, InsertCFLineForVendorLedgEntry from report 840 "Suggest Worksheet Lines"

this is similar to an existing event named "OnInsertCFLineForCustLedgerEntryOnBeforeInsertTempCFWorksheetLine" in the procedure InsertCFLineForCustLedgerEntry

Code:

  local procedure InsertCFLineForVendorLedgEntry()
    var
        MaxPmtTolerance: Decimal;
    begin
        with CFWorksheetLine2 do begin
            Init();
            "Source Type" := "Source Type"::Payables;
            "Source No." := "Vendor Ledger Entry"."Document No.";
            "Document Type" := "Vendor Ledger Entry"."Document Type";
            "Document Date" := "Vendor Ledger Entry"."Document Date";
            "Shortcut Dimension 2 Code" := "Vendor Ledger Entry"."Global Dimension 2 Code";
            "Shortcut Dimension 1 Code" := "Vendor Ledger Entry"."Global Dimension 1 Code";
            "Dimension Set ID" := "Vendor Ledger Entry"."Dimension Set ID";
            "Cash Flow Account No." := CFSetup."Payables CF Account No.";
            Description := CopyStr(
                StrSubstNo(PostedPurchaseDocumentDescriptionTxt,
                  Format("Document Type"),
                  Format("Vendor Ledger Entry"."Due Date"),
                  Vendor.Name),
                1, MaxStrLen(Description));
            SetCashFlowDate(CFWorksheetLine2, "Vendor Ledger Entry"."Due Date");
            "Document No." := "Vendor Ledger Entry"."Document No.";
            "Amount (LCY)" := "Vendor Ledger Entry"."Remaining Amt. (LCY)";
            "Pmt. Discount Date" := "Vendor Ledger Entry"."Pmt. Discount Date";
            "Pmt. Disc. Tolerance Date" := "Vendor Ledger Entry"."Pmt. Disc. Tolerance Date";

            if "Vendor Ledger Entry"."Currency Code" <> '' then
                Currency.Get("Vendor Ledger Entry"."Currency Code")
            else
                Currency.InitRoundingPrecision();

            "Payment Discount" := Round("Vendor Ledger Entry"."Remaining Pmt. Disc. Possible" /
                "Vendor Ledger Entry"."Adjusted Currency Factor", Currency."Amount Rounding Precision");

            if "Cash Flow Forecast"."Consider Pmt. Tol. Amount" then
                MaxPmtTolerance := Round("Vendor Ledger Entry"."Max. Payment Tolerance" /
                    "Vendor Ledger Entry"."Adjusted Currency Factor", Currency."Amount Rounding Precision")
            else
                MaxPmtTolerance := 0;

            if "Cash Flow Forecast"."Consider CF Payment Terms" and (Vendor."Cash Flow Payment Terms Code" <> '') then
                "Payment Terms Code" := Vendor."Cash Flow Payment Terms Code"
            else
                "Payment Terms Code" := '';

			//>>>>
			OnInsertCFLineForVendorLedgerEntryOnBeforeInsertTempCFWorksheetLine(CFWorksheetLine2, "Cash Flow Forecast", "Vendor Ledger Entry");
			//<<<<
			
            InsertTempCFWorksheetLine(CFWorksheetLine2, MaxPmtTolerance);
        end;
    end;

Event signature:

  [IntegrationEvent(false, false)]
   local procedure OnInsertCFLineForVendorLedgerEntryOnBeforeInsertTempCFWorksheetLine(var CashFlowWorksheetLine: Record "Cash Flow Worksheet Line"; CashFlowForecast: Record "Cash Flow Forecast"; VendorLedgerEntry: Record "Vendor Ledger Entry")
   begin
   end;

Additional context

We require updating some fields in CFWorksheetLine before performing the insertion. Internal work item: AB#502638

Sameer-Utekar avatar Feb 27 '24 16:02 Sameer-Utekar

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. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 16827.

JesperSchulz avatar Mar 01 '24 12:03 JesperSchulz