Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Event Request] Codeunit 8 AccSchedManagement - Procedure CalcCFAccount - OnAfterSetEntryFilters #27854

Open
mavohra opened this issue Dec 27, 2024 · 0 comments
Labels
event-request Request for adding an event Finance GitHub request for Finance area

Comments

@mavohra
Copy link

mavohra commented Dec 27, 2024

Describe the request

Please add an event OnAfterSetEntryFilters in procedure CalcCFAccount, immediately after the filters for CFForecastEntry or AnalysisViewEntry have been applied and the ColValue is calculated.

procedure CalcCFAccount(var CFAccount: Record "Cash Flow Account"; var AccSchedLine: Record "Acc. Schedule Line"; var ColumnLayout: Record "Column Layout") ColValue: Decimal
var
    CFForecastEntry: Record "Cash Flow Forecast Entry";
    AnalysisViewEntry: Record "Analysis View Entry";
    AmountType: Enum "Account Schedule Amount Type";
    IsHandled: Boolean;
begin
    ColValue := 0;
    IsHandled := false;
    OnBeforeCalcCFAcc(CFAccount, AccSchedLine, ColumnLayout, ColValue, IsHandled);
    if IsHandled then
        exit(ColValue);

    if AccSchedName.Name <> AccSchedLine."Schedule Name" then
        AccSchedName.Get(AccSchedLine."Schedule Name");

    if ConflictAmountType(AccSchedLine, ColumnLayout."Amount Type", AmountType) then
        exit(0);

    if ColumnLayout."Column Type" <> ColumnLayout."Column Type"::Formula then
        case ColumnLayout."Ledger Entry Type" of
            ColumnLayout."Ledger Entry Type"::Entries:
                if AccSchedName."Analysis View Name" = '' then begin
                    SetCFEntryFilters(CFAccount, CFForecastEntry, AccSchedLine, ColumnLayout);
                    case ColumnLayout."Amount Type" of
                        ColumnLayout."Amount Type"::"Net Amount":
                            begin
                                CFForecastEntry.CalcSums("Amount (LCY)");
                                ColValue := CFForecastEntry."Amount (LCY)";
                            end;
                    end;
                end
                else begin
                    SetCFAnalysisViewEntryFilters(CFAccount, AnalysisViewEntry, AccSchedLine, ColumnLayout);
                    case ColumnLayout."Amount Type" of
                        ColumnLayout."Amount Type"::"Net Amount":
                            begin
                                AnalysisViewEntry.CalcSums(Amount);
                                ColValue := AnalysisViewEntry.Amount;
                            end;
                    end;
                end;
            ColumnLayout."Ledger Entry Type"::"Budget Entries":
                if AccSchedName."Analysis View Name" = '' then begin
                    SetCFEntryFiltersForBudgetEntries(CFAccount, CFForecastEntry, AccSchedLine, ColumnLayout);
                    case ColumnLayout."Amount Type" of
                        ColumnLayout."Amount Type"::"Net Amount":
                            begin
                                CFForecastEntry.CalcSums("Amount (LCY)");
                                ColValue := CFForecastEntry."Amount (LCY)";
                            end;
                    end;
                end;
        end;

        OnAfterSetEntryFilters(CFAccount, AccSchedLine, ColumnLayout, ColValue); // <--- New Event
    end;

    exit(ColValue);
end;

Integration Event Definition

[IntegrationEvent(false, false)]
local procedure OnAfterSetEntryFilters(var CFAccount: Record "Cash Flow Account"; var AccSchedLine: Record "Acc. Schedule Line"; var ColumnLayout: Record "Column Layout"; var ColValue: Decimal)
begin
end;

Additional context

This event is required to allow additional processing or customization after the filters have been set. For example, in our case, additional logic is applied to handle budget entries with specific filters and calculations.

Event 3/3
Internal work item: AB#561474

@JesperSchulz JesperSchulz added event-request Request for adding an event Finance GitHub request for Finance area labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-request Request for adding an event Finance GitHub request for Finance area
Projects
None yet
Development

No branches or pull requests

2 participants