ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Extensibility Enhancements] Codeunit 5642 FA Reclass. Transfer Line and Codeunit 5606 FA Check Consistency

Open Softstore opened this issue 5 years ago • 1 comments

Hello,

For the portuguese localization there is the need to transfer all entries from the Old FA No. to the New FA No. using the reclassification functionality.

At this moment this is only possible if we develop this functionality completely apart from the Microsoft way, because in Codeunit FA Reclass. Transfer Line, it is posted just one entry (G/L or FA) with the total amounts calculated in CalcAmounts function.

I would suggest that the CalcAmounts function should store the amounts to post in a temporary table (Gen. Journal Line and FA Journal Line) and these two temporary tables would be included in the OnBeforeCalcAmounts event.

That way, we could subscribe the OnBeforeCalcAmounts and fill the temporary tables with the necessary records.

Example:

    local procedure CalcAmounts(var FAReclassJnlLine: Record "FA Reclass. Journal Line"; var TempGenJnlLine: Record "Gen. Journal Line"; var TempFAJnlLine: Record "FA Journal Line")
    var
        IsHandled: Boolean;
        FALedgerEntry: Record "FA Ledger Entry";
        AcquisitionCost: Decimal;
    begin
        IsHandled := false;
        OnBeforeCalcAmounts(FAReclassJnlLine, TempGenJnlLine, TempFAJnlLine, TransferType, Amounts, IsHandled);
        if IsHandled then
            exit;

        ...
		
		InsertTempFAJnlLine(TempFAJnlLine,FAReclassJnlLine,...);
		InsertTempGenJnlLine(TempGenJnlLine,FAReclassJnlLine,...);
    end;

After that, in InsertGenJnlLine and InsertFAJnlLine, the system should loop through all the previously created temporary records and transfer them to the the tables to post.

Example:

    local procedure InsertFAJnlLine(var FAReclassJnlLine: Record "FA Reclass. Journal Line"; var TempFAJnlLine: Record "FA Journal Line"; Sign: Integer; FANo: Code[20])
    begin
        if not FAJnlUsedOnce then begin
            ;
            FAJnlUsedOnce := true;
            FAJnlDocumentNo :=
              FAJnlSetup.GetFAJnlDocumentNo(FAJnlLine, FAReclassJnlLine."FA Posting Date", false);
        end;

        TempFAJnlLine.Reset();
        TempFAJnlLine.SetRange("FA Posting Type", FAPostingType);
        if TempFAJnlLine.FindSet() then
            repeat
                FAJnlLine.Init;
                FAJnlLine."Line No." := 0;
                FAJnlSetup.SetFAJnlTrailCodes(FAJnlLine);
                FAJnlLine."FA Posting Type" := FAPostingType;
                FAJnlLine.Validate("FA No.", FANo);
                FAJnlLine."FA Posting Date" := TempFAJnlLine."FA Posting Date";
                FAJnlLine."Posting Date" := TempFAJnlLine."Posting Date";

                FAJnlLine."Document No." := TempFAJnlLine."Document No.";
                if FAJnlLine."Document No." = '' then
                    FAJnlLine."Document No." := FAJnlDocumentNo;
                if FAJnlLine."Document No." = '' then
                    FAReclassJnlLine.TestField("Document No.");

                FAJnlLine."Posting No. Series" := FAJnlSetup.GetFANoSeries(FAJnlLine);
                FAJnlLine.Validate("Depreciation Book Code", TempFAJnlLine."Depreciation Book Code");
                FAJnlLine.Validate(Amount, Sign * TempFAJnlLine.Amount);
                FAJnlLine.Description := TempFAJnlLine.Description;
                FAJnlLine."FA Reclassification Entry" := true;
                FAJnlNextLineNo := FAJnlNextLineNo + 10000;
                FAJnlLine."Line No." := FAJnlNextLineNo;
                OnBeforeFAJnlLineInsert(FAJnlLine, FAReclassJnlLine, Sign);
                FAJnlLine.Insert(true);
            until TempFAJnlLine.Next() = 0;
    end;

Ideally, if this is implemented the InsertTempFAJnlLine and InsertTempGenJnlLine should have also events with the IsHandled parameters.

Please take into consideration that, at this moment, to apply this functionality three codeunits must be replicated (FA Reclass. Jnl.-Transfer, FA Reclass. Journal Batch and FA Reclass. Transfer Line).

This functionality will also have impact when posting these entries, because it will go through "FA Check Consistency" codeunit and errors may be thrown when validating the amounts. Our Suggestion is to add a new event in OnRun trigger in this codeunit.

Example:

    trigger OnRun()
	var
		IsHandled: Boolean;
    begin
		OnBeforeRunFACheckConsistency("FA Ledger Entry", IsHandled);
		if IsHandled then
			exit;
			
        if ("FA Posting Category" <> "FA Posting Category"::" ") or
           ("FA Posting Type" = "FA Posting Type"::"Gain/Loss") or
           ("FA Posting Type" = "FA Posting Type"::"Book Value on Disposal")
        then
            exit;

Thank you.

Softstore avatar Jul 19 '21 17:07 Softstore

Hi, the request is too complicated to be done as extensibility enhancement. If it is still actual, please post it as an idea on aka.ms/bcidea.

AleksanderGladkov avatar Apr 10 '24 14:04 AleksanderGladkov