Codeunit 891 Serv. Cash Flow Management

App
Base Application
Namespace
Microsoft.CashFlow.Forecast
Versions
25-28

Versions171819202122232425262728

Source29

Source in 29

src/Layers/W1/BaseApp/Service/CashFlow/ServCashFlowManagement.Codeunit.al50 lines, Copyright (c) Microsoft Corporation. MIT

// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.CashFlow.Forecast;

using Microsoft.CashFlow.Setup;
using Microsoft.Service.Document;

codeunit 891 "Serv. Cash Flow Management"
{
    var
        SourceDataDoesNotExistErr: Label 'Source data does not exist for %1: %2.', Comment = '%1 - G/L Account, %2 - account number';

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Cash Flow Management", 'OnShowSourceLocalSourceTypeCase', '', true, false)]
    local procedure OnShowSourceLocalSourceTypeCase(SourceType: Enum "Cash Flow Source Type"; SourceNo: Code[20]; var IsHandled: Boolean)
    begin
        if SourceType = SourceType::"Service Orders" then begin
            ShowServiceOrder(SourceNo);
            IsHandled := true;
        end;
    end;

    local procedure ShowServiceOrder(SourceNo: Code[20])
    var
        ServiceHeader: Record "Service Header";
        ServiceOrder: Page "Service Order";
        SourceType: Enum "Cash Flow Source Type";
    begin
        ServiceHeader.SetRange("Document Type", ServiceHeader."Document Type"::Order);
        ServiceHeader.SetRange("No.", SourceNo);
        if not ServiceHeader.FindFirst() then
            Error(SourceDataDoesNotExistErr, SourceType::"Service Orders", SourceNo);
        ServiceOrder.SetTableView(ServiceHeader);
        ServiceOrder.Run();
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Cash Flow Management", 'OnAfterCreateCashFlowAccounts', '', true, false)]
    local procedure OnAfterCreateCashFlowAccounts(var sender: Codeunit "Cash Flow Management")
    begin
        sender.CreateCashFlowAccount("Cash Flow Source Type"::"Service Orders", '');
    end;

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Cash Flow Management", 'OnBeforeInsertOnCreateCashFlowSetup', '', true, false)]
    local procedure OnBeforeInsertOnCreateCashFlowSetup(var CashFlowSetup: Record "Cash Flow Setup"; sender: Codeunit "Cash Flow Management")
    begin
        CashFlowSetup.Validate("Service CF Account No.", sender.GetNoFromSourceType("Cash Flow Source Type"::"Service Orders".AsInteger()));
    end;
}