ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Call] Codeunit 5606 - FA Check Consistency - OnCheckSalesPostingOnAfterSetFALedgerEntryFilters

Open Codey42 opened this issue 4 years ago • 3 comments

Dear ALAppExtensions team,

In Issue 16933 we asked for adding event publisher OnCheckSalesPostingOnAfterSetFALedgerEntryFilters in Codeunit 5606 FA Check Consistency.

Unfortunately the call of this event publisher is several lines too low in CheckSalesPosting.

Through this issue we would like to request moving call to event publisher OnCheckSalesPostingOnAfterSetFALedgerEntryFilters in Codeunit 5606 FA Check Consistency several lines up to the following position:

local procedure CheckSalesPosting()
begin
    with FALedgEntry do begin
        if FADeprBook."Acquisition Date" = 0D then
            CreateAcquisitionCostError;
        SetCurrentKey("FA No.", "Depreciation Book Code", "Part of Book Value", "FA Posting Date");
        SetRange("FA No.", FANo);
        SetRange("Depreciation Book Code", DeprBookCode);
        SetRange("Part of Book Value", true);
        SetFilter("FA Posting Date", '%1..', FAPostingDate + 1);
        // >>>> New >>>>>>>>>>>>>>>>
        // -> This is the correct position.
        OnCheckSalesPostingOnAfterSetFALedgerEntryFilters(FALedgEntry,FANo,DeprBookCode);
        // <<<< New <<<<<<<<<<<<<<<<
        if Find('-') then
            CreateDisposalError;
        SetRange("Part of Book Value");
        SetCurrentKey("FA No.", "Depreciation Book Code", "Part of Depreciable Basis", "FA Posting Date");
        SetRange("Part of Depreciable Basis", true);
        // >>>> Old >>>>>>>>>>>>>>>>
        // -> Unfortunately wrong position for the call. :(
        //OnCheckSalesPostingOnAfterSetFALedgerEntryFilters(FALedgEntry,FANo,DeprBookCode);
        // <<<< Old <<<<<<<<<<<<<<<<
        if Find('-') then
            CreateDisposalError;
        SetRange("Part of Depreciable Basis");
        if not FADeprBook."Use FA Ledger Check" then
            DeprBook.TestField("Use FA Ledger Check", false)
        else begin
            SetCurrentKey(
                "FA No.", "Depreciation Book Code",
                "FA Posting Category", "FA Posting Type", "FA Posting Date");
            SetRange("FA Posting Category", "FA Posting Category"::" ");
            SetRange("FA Posting Type", "FA Posting Type"::"Proceeds on Disposal");
            SetRange("FA Posting Date");
            if Find('-') then
                repeat
                    NewAmount := NewAmount + Amount;
                    if NewAmount > 0 then
                        CreatePostingTypeError;
                until Next() = 0;
        end;
    end;
end;

Codey42 avatar Apr 26 '22 09:04 Codey42

We can't move it, it would be breaking for someone who could possibly start using this one so instead this will be OnCheckSalesPostingOnBeforeFirstFind with same signature.

Stepanenko-Vadim avatar Apr 28 '22 07:04 Stepanenko-Vadim

Your objection is understandable. The proposed solution is an acceptable alternative.

We will later use OnCheckSalesPostingOnBeforeFirstFind instead of OnCheckSalesPostingOnAfterSetFALedgerEntryFilters.

Thank you very much and happy coding.

Codey42 avatar Apr 28 '22 07:04 Codey42

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.

JesperSchulz avatar Apr 28 '22 15:04 JesperSchulz