Table of Contents

Module CAP Finance - Ledger Entry Letter

This application adds a new column to Customer Ledger Entries and Vendor Ledger Entries to easily identifies the entries applied together.

Properties

Name Value
Version 25.202411.31831.0
Publisher Cap Vision
Brief View ledger entries applied together by assigning a readable letter.

Namespace

Name Summary
CapVision

Supporter de nouvelles tables d'écritures

En tant que développeur vous pouvez étendre notre application en supportant les codes de lettrage sur de nouveaux types d'écritures.

Pour cela, vous pouvez utiliser le codeunit ci-dessous après avoir ajouté le champ Application Code MYAPP à votre table d'écritures.

codeunit 50000 "My Application"
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Application Management LTCAP", 'OnRegisterSupportedTable', '', true, false)]
    local procedure OnRegisterSupportedTable(var SupportedTable: Record "Application Table LTCAP")
    begin
        SupportedTable.Init();
        SupportedTable."Table ID" := Database::"My Ledger Entry";
        SupportedTable.Insert();
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Application Management LTCAP", 'OnInitialize', '', true, false)]
    local procedure OnInitialize(TableId: Integer; var Handled: Boolean)
    var
        MyLedgerEntry: Record "My Ledger Entry";
        ApplicationManagement: Codeunit "Application Management LTCAP";
    begin
        if Handled or (TableId <> Database::"My Ledger Entry") then
            exit;

        MyLedgerEntry.ModifyAll("Application Code MYAPP", '');

        if MyLedgerEntry.FindSet(true) then
            repeat
                if MyLedgerEntry."Application Code MYAPP" = '' then
                    ApplicationManagement.PostApply(TableId, <Your Master Data Code linked to this Entry (i.e. Customer No., Vendor No., ...)>, MyLedgerEntry."Entry No.");
            until MyLedgerEntry.Next() = 0;

        Handled := true;
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Application Management LTCAP", 'OnFindLastLetter', '', true, false)]
    local procedure OnFindLastLetter(TableId: Integer; Code: Code[20]; var Letter: Text; var Handled: Boolean)
    var
        MyLedgerEntry: Record "My Ledger Entry";
    begin
        if Handled or (TableId <> Database::"My Ledger Entry") then
            exit;

        Letter := '';

        //TODO: Replace Master Data No. by your Master Data Code linked to this Entry (i.e. Customer No., Vendor No., ...)
        MyLedgerEntry.SetCurrentKey("Master Data No.", "Application Code MYAPP");
        MyLedgerEntry.SetRange("Master Data No.", Code);
        MyLedgerEntry.SetFilter("Application Code MYAPP", '<>%1', '');
        if MyLedgerEntry.FindLast() then
            Letter := MyLedgerEntry."Application Code MYAPP";

        Handled := true;
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Application Management LTCAP", 'OnSetLetterOnEntryNo', '', true, false)]
    local procedure OnSetLetterOnEntryNo(TableId: Integer; EntryNo: Integer; Letter: Text; var Handled: Boolean)
    var
        MyLedgerEntry: Record "My Ledger Entry";
    begin
        if Handled or (TableId <> Database::"My Ledger Entry") then
            exit;

        MyLedgerEntry.Get(EntryNo);
        MyLedgerEntry."Application Code MYAPP" := CopyStr(Letter, 1, MaxStrLen(MyLedgerEntry."Application Code MYAPP"));
        MyLedgerEntry.Modify();

        Handled := true;
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Application Management LTCAP", 'OnFindAppliedEntries', '', true, false)]
    local procedure OnFindAppliedEntries(TableId: Integer; EntryNo: Integer; var AppliedEntryBuffer: Record "Applied Entry Buffer LTCAP"; var Handled: Boolean)
    begin
        if Handled or (TableId <> Database::"My Ledger Entry") then
            exit;

        //TODO: Fill AppliedEntryBuffer with all entries applied with the EntryNo

        Handled := true;
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Application Management LTCAP", 'OnFindUnAppliedEntries', '', true, false)]
    local procedure OnFindUnAppliedEntries(TableId: Integer; EntryNo: Integer; var AppliedEntryBuffer: Record "Applied Entry Buffer LTCAP"; var Handled: Boolean)
    var
        MyLedgerEntry: Record "My Ledger Entry";
    begin
        if Handled or (TableId <> Database::"My Ledger Entry") then
            exit;

        MyLedgerEntry.Get(EntryNo);

        //TODO: Replace Master Data No. by your Master Data Code linked to this Entry (i.e. Customer No., Vendor No., ...)
        MyLedgerEntry.SetRange("Master Data No.", MyLedgerEntry."Master Data No.");
        MyLedgerEntry.SetRange("Application Code MYAPP", MyLedgerEntry."Application Code MYAPP");
        if MyLedgerEntry.FindSet() then
            repeat
                AppliedEntryBuffer.Init();
                AppliedEntryBuffer."Entry No." := MyLedgerEntry."Entry No.";
                AppliedEntryBuffer."Application Code" := MyLedgerEntry."Application Code MYAPP";
                AppliedEntryBuffer.Open := MyLedgerEntry.Open;
                AppliedEntryBuffer.Insert();
            until MyLedgerEntry.Next() = 0;

        Handled := true;
    end;

    [EventSubscriber(<Subscribe when entries are applied on My Ledger Entry>)]
    local procedure OnAfterPostApply(MyLedgerEntry: Record "My Ledger Entry")
    var
        ApplicationManagement: Codeunit "Application Management LTCAP";
    begin
        ApplicationManagement.PostApply(Database::"My Ledger Entry", MyLedgerEntry."Master Data No.", MyLedgerEntry."Entry No.");
    end;

    [EventSubscriber(<Subscribe when entries are unapplied on My Ledger Entry>)]
    local procedure OnAfterPostUnapply(MyLedgerEntry: Record "My Ledger Entry")
    var
        ApplicationManagement: Codeunit "Application Management LTCAP";
    begin
        ApplicationManagement.PostUnApply(Database::"My Ledger Entry", MyLedgerEntry."Master Data No.", MyLedgerEntry."Entry No.");
    end;
}