Skip to content

[Event-Request] Report 1131 Cost Allocation #30422

Description

Why do you need this change?

To further allocate the costs, project details must also be transferred to the journal entry and carried over to the account entries.

Describe the request

local procedure WriteJournalLine(CostTypeCode: Code[20]; CostCenterCode: Code[20]; CostObjectCode: Code[20]; PostAmount: Decimal; Text: Text; AllocKey: Text; AllocID: Code[10]; Allocated2: Boolean)
var
CostCenter: Record "Cost Center";
begin
if PostAmount = 0 then
exit;

    if CostCenterCode <> '' then
        if CostCenter.Get(CostCenterCode) then
            CostCenter.TestField(Blocked, false);

    if CostTypeCode = '' then
        Error(Text015, "Cost Allocation Source".ID);

    if ((CostCenterCode = '') and (CostObjectCode = '')) or ((CostCenterCode <> '') and (CostObjectCode <> '')) then
        Error(Text016, "Cost Allocation Source".ID, CostCenterCode, CostObjectCode);

    LastCostJourLineNo := LastCostJourLineNo + 10000;
    TempCostJnlLine."Line No." := LastCostJourLineNo;
    TempCostJnlLine."Posting Date" := AllocDate;
    TempCostJnlLine."Cost Type No." := CostTypeCode;
    TempCostJnlLine."Cost Center Code" := CostCenterCode;
    TempCostJnlLine."Cost Object Code" := CostObjectCode;
    TempCostJnlLine."Document No." := IncStr(CostAccSetup."Last Allocation Doc. No.");
    TempCostJnlLine.Description := CopyStr(Text, 1, MaxStrLen(TempCostJnlLine.Description));
    TempCostJnlLine.Amount := PostAmount;
    TempCostJnlLine."System-Created Entry" := true;
    TempCostJnlLine.Allocated := Allocated2;
    TempCostJnlLine."Allocation Description" := CopyStr(AllocKey, 1, MaxStrLen(TempCostJnlLine."Allocation Description"));
    TempCostJnlLine."Allocation ID" := AllocID;
    TempCostJnlLine."Source Code" := SourceCodeSetup."Cost Allocation";
    TempCostJnlLine."Budget Name" := CostBudgetName.Name;
     OnBeforeInsertTempCostLine(TempCostLine);
    TempCostJnlLine.Insert();

    if TempCostJnlLine.Amount > 0 then
        TotalDebit := TotalDebit + TempCostJnlLine.Amount
    else
        TotalCredit := TotalCredit + TempCostJnlLine.Amount;

    EntriesPerLevel := EntriesPerLevel + 1;
    TotalEntries := TotalEntries + 1;
    Window.Update(4, Format(TotalEntries));
end;

[IntegrationEvent(false, false)]
local procedure OnBeforeInsertTempCostLine(var TempCostLine: Record "Cost Journal Line" temporary)
begin
end;

Internal work item: AB#646934

Metadata

Metadata

Assignees

No one assigned

    Labels

    FinanceGitHub request for Finance areaevent-requestRequest for adding an event

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions