microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
773 stars 610 forks source link

Codeunit 2000040 "Coda Import Management" – New events “OnAfterParseHeaderRecord” and "OnAfterCheckOldBalance" #26583

Closed vanmito closed 4 months ago

vanmito commented 4 months ago

Describe the request

Hello,

**Could we please have a new event "OnAfterParseHeaderRecord" in function "ParseHeaderRecord" and a new event "OnAfterCheckOldBalance" in function "CheckOldBalance" of Codeunit 2000040 "Coda Import Management"?

local procedure ParseHeaderRecord()
begin
    with CodBankStmtSrcLine do begin
        ProtocolNo := CopyStr(Data, 12, 3);
        VersionCode := CopyStr(Data, 128, 1);
        if VersionCode = '1' then
            VId[1] := DelChr(CopyStr(Data, 61, 11), '>', ' ')
        else
            SWIFTCode := DelChr(CopyStr(Data, 61, 11));
        VId[2] := DelChr(CopyStr(Data, 72, 11), '>', ' ');
        "Transaction Date" := DDMMYY2Date(CopyStr(Data, 6, 6), false);

// --- Begin New Code --- OnAfterParseHeaderRecord(CodBankStmtSrcLine); // --- End New Code ---

    end;
end;

procedure CheckOldBalance(var CodedBankStmtSrcLine: Record "CODA Statement Source Line"): Boolean
var
    BankAccountNo: Text[30];
    IBANNumber: Text[34];
begin
    CodBankStmtSrcLine := CodedBankStmtSrcLine;
    with CodBankStmtSrcLine do begin
        Evaluate("Statement No.", CopyStr(Data, 3, 3));
        BankAccountNo :=
          PaymJnlManagement.ConvertToDigit(
            BankAcc."Bank Account No.",
            MaxStrLen(BankAcc."Bank Account No."));
        IBANNumber := DelChr(BankAcc.IBAN);
        AccountType := CopyStr(Data, 2, 1);
        case AccountType of
            ' ', '0':
                if BankAccountNo <> CopyStr(Data, 6, 12) then
                    Error(Text003,
                      BankAcc.FieldCaption("Bank Account No."),
                      BankAcc."Bank Account No.",
                      BankAcc.TableCaption(),
                      BankAcc."No.",
                      CopyStr(Data, 6, 12),
                      ID);
            '2':
                if IBANNumber <> CopyStr(Data, 6, 16) then
                    Error(Text003,
                      BankAcc.FieldCaption(IBAN),
                      BankAcc.IBAN,
                      BankAcc.TableCaption(),
                      BankAcc."No.",
                      CopyStr(Data, 6, 16),
                      ID);
            else
                Error(Text017);
        end;
        if Data[43] = '0' then
            Evaluate(Amount, CopyStr(Data, 44, 15))
        else
            Evaluate(Amount, '-' + CopyStr(Data, 44, 15));
        Amount := Amount / 1000;
        "Transaction Date" := DDMMYY2Date(CopyStr(Data, 59, 6), false);
        Evaluate("CODA Statement No.", CopyStr(Data, 126, 3));
        Evaluate(CODAStatementNo, CopyStr(Data, 3, 3));

// --- Begin New Code --- OnAfterCheckOldBalance(CodBankStmtSrcLine,CODAStatementNo); // --- End New Code ---

    end;
    CodedBankStmtSrcLine := CodBankStmtSrcLine;
    exit(true);
end;

...

...

[IntegrationEvent(false, false)] local procedure OnAfterParseHeaderRecord(var CODAStatementLine: Record "CODA Statement Line") begin end;

[IntegrationEvent(false, false)] local procedure OnAfterCheckOldBalance(var CODAStatementLine: Record "CODA Statement Line"; var CODAStatementNo: Text[30]) begin end;

Additional context

We would like to read the year out of the statement date (found in header record of CODA file) and add it as a prefix to the Statement No. (found in the OldBalance record of the CODA file).

This in order to prevent that a CODA statement will be overwritten the next year. Internal work item: AB#537214

JesperSchulz commented 4 months ago

Availability update: We will publish a fix for this issue in the next update for release 24.

Build ID to track: 20456.