ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] page 232 "Apply Customer Entries"

Open iltererdogan opened this issue 4 years ago • 2 comments

Hi, Is it possible to add OnSetApplyingCustLedgEntryOnBeforeCalcTypeSalesHeaderCalcApplnAmount, OnSetApplyingCustLedgEntryOnBeforeCalcTypeServiceHeaderCalcApplnAmount and OnSetApplyingCustLedgEntryOnBeforeCalcTypeGenJnlLineCalcApplnAmount events to "Apply Customer Entries" page.

    procedure SetApplyingCustLedgEntry()
    var
        Customer: Record Customer;
    begin
        OnBeforeSetApplyingCustLedgEntry(TempApplyingCustLedgEntry, GenJnlLine, SalesHeader, CalcType, ServHeader);

        case CalcType of
            CalcType::"Sales Header":
                begin
                    TempApplyingCustLedgEntry."Entry No." := 1;
                    TempApplyingCustLedgEntry."Posting Date" := SalesHeader."Posting Date";
                    if SalesHeader."Document Type" = SalesHeader."Document Type"::"Return Order" then
                        TempApplyingCustLedgEntry."Document Type" := TempApplyingCustLedgEntry."Document Type"::"Credit Memo"
                    else
                        TempApplyingCustLedgEntry."Document Type" := TempApplyingCustLedgEntry."Document Type"::Invoice;
                    TempApplyingCustLedgEntry."Document No." := SalesHeader."No.";
                    TempApplyingCustLedgEntry."Customer No." := SalesHeader."Bill-to Customer No.";
                    TempApplyingCustLedgEntry.Description := SalesHeader."Posting Description";
                    TempApplyingCustLedgEntry."Currency Code" := SalesHeader."Currency Code";
                    if TempApplyingCustLedgEntry."Document Type" = TempApplyingCustLedgEntry."Document Type"::"Credit Memo" then begin
                        TempApplyingCustLedgEntry.Amount := -TotalSalesLine."Amount Including VAT";
                        TempApplyingCustLedgEntry."Remaining Amount" := -TotalSalesLine."Amount Including VAT";
                    end else begin
                        TempApplyingCustLedgEntry.Amount := TotalSalesLine."Amount Including VAT";
                        TempApplyingCustLedgEntry."Remaining Amount" := TotalSalesLine."Amount Including VAT";
                    end;
                    
                    // NEW BEGIN
                    OnSetApplyingCustLedgEntryOnBeforeCalcTypeSalesHeaderCalcApplnAmount(TempApplyingCustLedgEntry,SalesHeader);
                    // NEW END

                    CalcApplnAmount();
                end;
            CalcType::"Service Header":
                begin
                    TempApplyingCustLedgEntry."Entry No." := 1;
                    TempApplyingCustLedgEntry."Posting Date" := ServHeader."Posting Date";
                    if ServHeader."Document Type" = ServHeader."Document Type"::"Credit Memo" then
                        TempApplyingCustLedgEntry."Document Type" := TempApplyingCustLedgEntry."Document Type"::"Credit Memo"
                    else
                        TempApplyingCustLedgEntry."Document Type" := TempApplyingCustLedgEntry."Document Type"::Invoice;
                    TempApplyingCustLedgEntry."Document No." := ServHeader."No.";
                    TempApplyingCustLedgEntry."Customer No." := ServHeader."Bill-to Customer No.";
                    TempApplyingCustLedgEntry.Description := ServHeader."Posting Description";
                    TempApplyingCustLedgEntry."Currency Code" := ServHeader."Currency Code";
                    if TempApplyingCustLedgEntry."Document Type" = TempApplyingCustLedgEntry."Document Type"::"Credit Memo" then begin
                        TempApplyingCustLedgEntry.Amount := -TotalServLine."Amount Including VAT";
                        TempApplyingCustLedgEntry."Remaining Amount" := -TotalServLine."Amount Including VAT";
                    end else begin
                        TempApplyingCustLedgEntry.Amount := TotalServLine."Amount Including VAT";
                        TempApplyingCustLedgEntry."Remaining Amount" := TotalServLine."Amount Including VAT";
                    end;

                    // NEW BEGIN
                    OnSetApplyingCustLedgEntryOnBeforeCalcTypeServiceHeaderCalcApplnAmount(TempApplyingCustLedgEntry,ServHeader);
                    // NEW END

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

                    // NEW BEGIN
                    OnSetApplyingCustLedgEntryOnBeforeCalcTypeGenJnlLineCalcApplnAmount(TempApplyingCustLedgEntry,GenJnlLine);
                    // NEW END

                    CalcApplnAmount();
                end;
        end;

        OnAfterSetApplyingCustLedgEntry(TempApplyingCustLedgEntry, GenJnlLine, SalesHeader);
    end;

    // NEW BEGIN
    [IntegrationEvent(true, false)]
    local procedure OnSetApplyingCustLedgEntryOnBeforeCalcTypeSalesHeaderCalcApplnAmount(var ApplyingCustLedgEntry: Record "Cust. Ledger Entry"; SalesHeader: Record "Sales Header")
    begin
    end;

    [IntegrationEvent(true, false)]
    local procedure OnSetApplyingCustLedgEntryOnBeforeCalcTypeServiceHeaderCalcApplnAmount(var ApplyingCustLedgEntry: Record "Cust. Ledger Entry";ServHeader: Record "Service Header")
    begin
    end;

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

iltererdogan avatar Aug 04 '22 08: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