[Event Request] Codeunit "Allocation Account Mgt." - GenerateVariableAllocationLines
Describe the request
Please add new integration events OnBeforeGenerateVariableAllocationLines() and OnAfterGenerateVariableAllocationLines() with the parameter ExistingDimensionSetId in Codeunit "Allocation Account Mgt."
Example:
procedure GenerateVariableAllocationLines(var AllocationAccount: Record "Allocation Account"; var AllocationLine: Record "Allocation Line"; AmountToDistribute: Decimal; PostingDate: Date; ExistingDimensionSetId: Integer; CurrencyCode: Code[10])
var
AllocAccountDistribution: Record "Alloc. Account Distribution";
VariableAllocationMgt: Codeunit "Variable Allocation Mgt.";
ShareDistributions: Dictionary of [Guid, Decimal];
AmountDistributions: Dictionary of [Guid, Decimal];
begin
OnBeforeGenerateVariableAllocationLines(ExistingDimensionSetId);
VariableAllocationMgt.CalculateAmountDistributions(AllocationAccount, AmountToDistribute, AmountDistributions, ShareDistributions, PostingDate, CurrencyCode);
AllocAccountDistribution.ReadIsolation := IsolationLevel::ReadCommitted;
AllocAccountDistribution.SetRange("Allocation Account No.", AllocationAccount."No.");
if not AllocAccountDistribution.FindSet() then
exit;
repeat
AllocationLine."Allocation Account No." := AllocAccountDistribution."Allocation Account No.";
AllocationLine."Line No." += 10000;
AllocationLine.Amount := AmountDistributions.Get(AllocAccountDistribution.SystemId);
AllocationLine.Percentage := Round(AllocationLine.Amount / AmountToDistribute * 100, 0.00001);
AllocationLine."Destination Account Type" := AllocAccountDistribution."Destination Account Type";
AllocationLine."Destination Account Number" := AllocAccountDistribution."Destination Account Number";
AllocationLine."Destination Account Name" := AllocAccountDistribution.LookupDistributionAccountName();
AllocationLine."Breakdown Account Name" := AllocAccountDistribution.LookupBreakdownAccountName();
AllocationLine."Breakdown Account Balance" := ShareDistributions.Get(AllocAccountDistribution.SystemId);
AllocationLine."Breakdown Account Number" := AllocAccountDistribution."Breakdown Account Number";
AllocationLine."Dimension Set ID" := AllocAccountDistribution."Dimension Set ID";
AllocationLine."Global Dimension 1 Code" := AllocAccountDistribution."Global Dimension 1 Code";
AllocationLine."Global Dimension 2 Code" := AllocAccountDistribution."Global Dimension 2 Code";
CombineDimensionSetIds(ExistingDimensionSetId, AllocationLine);
AllocationLine.Insert();
until AllocAccountDistribution.Next() = 0;
OnAfterGenerateVariableAllocationLines(ExistingDimensionSetId);
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeGenerateVariableAllocationLines(var ExistingDimensionSetId: Integer)
begin
end;
[IntegrationEvent(false, false)]
local procedure OnAfterGenerateVariableAllocationLines(var ExistingDimensionSetId: Integer)
begin
end;
Additional context
This request is the workaround of the rejected request of #25581.
We need to get the dimension of the Gen. Jnl. Line/Sales Line/Purchase Line and assign it to a global variable, calculate the G/L account balance in the OnGetAccountBalance event in codeunit "Variable Allocation Mgt." by filtering the dimension of the G/L Entry in the global variable.
Internal work item: AB#499104
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: 16151.