ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] page 233 "Apply Vendor Entries"

Open iltererdogan opened this issue 4 years ago • 2 comments

Hi, Is it possible to add OnSetApplyingVendLedgEntryOnBeforeCalcTypePurchaseHeaderCalcApplnAmount and OnSetApplyingVendLedgEntryOnBeforeCalcTypeGenJnlLineCalcApplnAmount events to "Apply Vendor Entries" page.

    procedure SetApplyingVendLedgEntry()
    var
        Vendor: Record Vendor;
    begin
        OnBeforeSetApplyingVendLedgEntry(TempApplyingVendLedgEntry, GenJnlLine, PurchHeader, CalcType);

        case CalcType of
            CalcType::"Purchase Header":
                begin
                    TempApplyingVendLedgEntry."Posting Date" := PurchHeader."Posting Date";
                    if PurchHeader."Document Type" = PurchHeader."Document Type"::"Return Order" then
                        TempApplyingVendLedgEntry."Document Type" := TempApplyingVendLedgEntry."Document Type"::"Credit Memo"
                    else
                        TempApplyingVendLedgEntry."Document Type" := TempApplyingVendLedgEntry."Document Type"::Invoice;
                    TempApplyingVendLedgEntry."Document No." := PurchHeader."No.";
                    TempApplyingVendLedgEntry."Vendor No." := PurchHeader."Pay-to Vendor No.";
                    TempApplyingVendLedgEntry.Description := PurchHeader."Posting Description";
                    TempApplyingVendLedgEntry."Currency Code" := PurchHeader."Currency Code";
                    if TempApplyingVendLedgEntry."Document Type" = TempApplyingVendLedgEntry."Document Type"::"Credit Memo" then begin
                        TempApplyingVendLedgEntry.Amount := TotalPurchLine."Amount Including VAT";
                        TempApplyingVendLedgEntry."Remaining Amount" := TotalPurchLine."Amount Including VAT";
                    end else begin
                        TempApplyingVendLedgEntry.Amount := -TotalPurchLine."Amount Including VAT";
                        TempApplyingVendLedgEntry."Remaining Amount" := -TotalPurchLine."Amount Including VAT";
                    end;
                    
                    // NEW BEGIN
                    OnSetApplyingVendLedgEntryOnBeforeCalcTypePurchaseHeaderCalcApplnAmount(TempApplyingVendLedgEntry, PurchHeader);
                    // NEW END

                    CalcApplnAmount();
                end;
            CalcType::Direct:
                begin
                    if Rec."Applying Entry" then begin
                        if TempApplyingVendLedgEntry."Entry No." <> 0 then
                            VendLedgEntry := TempApplyingVendLedgEntry;
                        CODEUNIT.Run(CODEUNIT::"Vend. Entry-Edit", Rec);
                        if Rec."Applies-to ID" = '' then
                            SetVendApplId(false);
                        Rec.CalcFields(Amount);
                        TempApplyingVendLedgEntry := Rec;
                        if VendLedgEntry."Entry No." <> 0 then begin
                            Rec := VendLedgEntry;
                            Rec."Applying Entry" := false;
                            SetVendApplId(false);
                        end;
                        Rec.SetFilter("Entry No.", '<> %1', TempApplyingVendLedgEntry."Entry No.");
                        ApplyingAmount := TempApplyingVendLedgEntry."Remaining Amount";
                        ApplnDate := TempApplyingVendLedgEntry."Posting Date";
                        ApplnCurrencyCode := TempApplyingVendLedgEntry."Currency Code";
                    end;
                    OnSetApplyingVendLedgEntryOnBeforeCalcTypeDirectCalcApplnAmount(ApplyingAmount, TempApplyingVendLedgEntry);
                    CalcApplnAmount();
                end;
            CalcType::"Gen. Jnl. Line":
                begin
                    TempApplyingVendLedgEntry."Posting Date" := GenJnlLine."Posting Date";
                    TempApplyingVendLedgEntry."Document Type" := GenJnlLine."Document Type";
                    TempApplyingVendLedgEntry."Document No." := GenJnlLine."Document No.";
                    if GenJnlLine."Bal. Account Type" = GenJnlLine."Bal. Account Type"::Vendor then begin
                        TempApplyingVendLedgEntry."Vendor No." := GenJnlLine."Bal. Account No.";
                        Vendor.Get(TempApplyingVendLedgEntry."Vendor No.");
                        TempApplyingVendLedgEntry.Description := Vendor.Name;
                    end else begin
                        TempApplyingVendLedgEntry."Vendor No." := GenJnlLine."Account No.";
                        TempApplyingVendLedgEntry.Description := GenJnlLine.Description;
                    end;
                    TempApplyingVendLedgEntry."Currency Code" := GenJnlLine."Currency Code";
                    TempApplyingVendLedgEntry.Amount := GenJnlLine.Amount;
                    TempApplyingVendLedgEntry."Remaining Amount" := GenJnlLine.Amount;

                    // NEW BEGIN
                    OnSetApplyingVendLedgEntryOnBeforeCalcTypeGenJnlLineCalcApplnAmount(TempApplyingVendLedgEntry, GenJnlLine);
                    // NEW END

                    CalcApplnAmount();
                end;
        end;
        OnAfterSetApplyingVendLedgEntry(TempApplyingVendLedgEntry, GenJnlLine, PurchHeader, CalcType);
    end;

    // NEW BEGIN
    [IntegrationEvent(true, false)]
    local procedure OnSetApplyingVendLedgEntryOnBeforeCalcTypePurchaseHeaderCalcApplnAmount(var ApplyingVendLedgEntry: Record "Vendor Ledger Entry"; PurchHeader: Record "Purchase Header")
    begin
    end;

    [IntegrationEvent(true, false)]
    local procedure OnSetApplyingVendLedgEntryOnBeforeCalcTypeGenJnlLineCalcApplnAmount(var ApplyingVendLedgEntry: Record "Vendor Ledger Entry"; GenJournalLine: Record "Gen. Journal Line")
    begin
    end;
    // NEW END

iltererdogan avatar Aug 09 '22 09:08 iltererdogan

Hi, any update on this request?

iltererdogan avatar Sep 05 '22 12:09 iltererdogan

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: 46829.

JesperSchulz avatar Sep 22 '22 12:09 JesperSchulz