Page 207 Resource Journal

Base Application, Microsoft.Projects.Resources.Journal

src/Layers/W1/BaseApp/Projects/Resources/Journal/ResourceJournal.Page.al672 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.Projects.Resources.Journal;using Microsoft.Finance.Dimension;using Microsoft.Foundation.Reporting;using Microsoft.Projects.Resources.Ledger;using Microsoft.Projects.Resources.Resource;using Microsoft.Projects.TimeSheet;using Microsoft.Utilities;using System.Environment;using System.Environment.Configuration;using System.Integration;page 207 "Resource Journal"{    AdditionalSearchTerms = 'register hours';    ApplicationArea = Jobs;    AutoSplitKey = true;    Caption = 'Resource Journals';    DataCaptionFields = "Journal Batch Name";    DelayedInsert = true;    PageType = Worksheet;    SaveValues = true;    SourceTable = "Res. Journal Line";    UsageCategory = Tasks;    layout    {        area(content)        {            field(CurrentJnlBatchName; CurrentJnlBatchName)            {                ApplicationArea = Jobs;                Caption = 'Batch Name';                Lookup = true;                ToolTip = 'Specifies the name of the journal batch, a personalized journal layout, that the journal is based on.';                trigger OnLookup(var Text: Text): Boolean                begin                    CurrPage.SaveRecord();                    ResJnlManagement.LookupName(CurrentJnlBatchName, Rec);                    SetControlAppearanceFromBatch();                    CurrPage.Update(false);                end;                trigger OnValidate()                begin                    ResJnlManagement.CheckName(CurrentJnlBatchName, Rec);                    CurrentJnlBatchNameOnAfterVali();                end;            }            repeater(Control1)            {                ShowCaption = false;                field("Posting Date"; Rec."Posting Date")                {                    ApplicationArea = Jobs;                }                field("Document Date"; Rec."Document Date")                {                    ApplicationArea = Jobs;                    Visible = false;                }                field("Entry Type"; Rec."Entry Type")                {                    ApplicationArea = Jobs;                }                field("Document No."; Rec."Document No.")                {                    ApplicationArea = Jobs;                    ShowMandatory = true;                }                field("External Document No."; Rec."External Document No.")                {                    ApplicationArea = Jobs;                    Visible = false;                }                field("Resource No."; Rec."Resource No.")                {                    ApplicationArea = Jobs;                    trigger OnValidate()                    begin                        ResJnlManagement.GetRes(Rec."Resource No.", ResName);                        Rec.ShowShortcutDimCode(ShortcutDimCode);                    end;                }                field("Resource Group No."; Rec."Resource Group No.")                {                    ApplicationArea = Jobs;                    Visible = false;                    trigger OnValidate()                    begin                        Rec.ShowShortcutDimCode(ShortcutDimCode);                    end;                }                field(Description; Rec.Description)                {                    ApplicationArea = Jobs;                }                field("Work Type Code"; Rec."Work Type Code")                {                    ApplicationArea = Jobs;                }                field("Gen. Bus. Posting Group"; Rec."Gen. Bus. Posting Group")                {                    ApplicationArea = Jobs;                    Visible = false;                }                field("Gen. Prod. Posting Group"; Rec."Gen. Prod. Posting Group")                {                    ApplicationArea = Jobs;                    Visible = false;                }                field(Quantity; Rec.Quantity)                {                    ApplicationArea = Jobs;                }                field("Unit of Measure Code"; Rec."Unit of Measure Code")                {                    ApplicationArea = Jobs;                }                field("Direct Unit Cost"; Rec."Direct Unit Cost")                {                    ApplicationArea = Jobs;                }                field("Unit Cost"; Rec."Unit Cost")                {                    ApplicationArea = Jobs;                }                field("Total Cost"; Rec."Total Cost")                {                    ApplicationArea = Jobs;                }                field("Unit Price"; Rec."Unit Price")                {                    ApplicationArea = Jobs;                }                field("Total Price"; Rec."Total Price")                {                    ApplicationArea = Jobs;                }                field("Reason Code"; Rec."Reason Code")                {                    ApplicationArea = Jobs;                    Visible = false;                }                field("Time Sheet No."; Rec."Time Sheet No.")                {                    ApplicationArea = Jobs;                    Visible = false;                }                field("Time Sheet Line No."; Rec."Time Sheet Line No.")                {                    ApplicationArea = Jobs;                    Visible = false;                }                field("Time Sheet Date"; Rec."Time Sheet Date")                {                    ApplicationArea = Jobs;                    Visible = false;                }                field("Shortcut Dimension 1 Code"; Rec."Shortcut Dimension 1 Code")                {                    ApplicationArea = Dimensions;                    Visible = DimVisible1;                }                field("Shortcut Dimension 2 Code"; Rec."Shortcut Dimension 2 Code")                {                    ApplicationArea = Dimensions;                    Visible = DimVisible2;                }                field(ShortcutDimCode3; ShortcutDimCode[3])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,3';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(3),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible3;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(3, ShortcutDimCode[3]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 3);                    end;                }                field(ShortcutDimCode4; ShortcutDimCode[4])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,4';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(4),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible4;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(4, ShortcutDimCode[4]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 4);                    end;                }                field(ShortcutDimCode5; ShortcutDimCode[5])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,5';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(5),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible5;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(5, ShortcutDimCode[5]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 5);                    end;                }                field(ShortcutDimCode6; ShortcutDimCode[6])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,6';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(6),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible6;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(6, ShortcutDimCode[6]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 6);                    end;                }                field(ShortcutDimCode7; ShortcutDimCode[7])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,7';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(7),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible7;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(7, ShortcutDimCode[7]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 7);                    end;                }                field(ShortcutDimCode8; ShortcutDimCode[8])                {                    ApplicationArea = Dimensions;                    CaptionClass = '1,2,8';                    TableRelation = "Dimension Value".Code where("Global Dimension No." = const(8),                                                                  "Dimension Value Type" = const(Standard),                                                                  Blocked = const(false));                    Visible = DimVisible8;                    trigger OnValidate()                    begin                        Rec.ValidateShortcutDimCode(8, ShortcutDimCode[8]);                        OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 8);                    end;                }            }            group(Control41)            {                ShowCaption = false;                fixed(Control1903222401)                {                    ShowCaption = false;                    group("Resource Name")                    {                        Caption = 'Resource Name';                        field(ResName; ResName)                        {                            ApplicationArea = Jobs;                            Editable = false;                            ShowCaption = false;                        }                    }                }            }        }        area(factboxes)        {            part(JournalErrorsFactBox; "Res. Journal Errors FactBox")            {                ApplicationArea = Basic, Suite;                ShowFilter = false;                Visible = BackgroundErrorCheck;                SubPageLink = "Journal Template Name" = field("Journal Template Name"),                              "Journal Batch Name" = field("Journal Batch Name"),                              "Line No." = field("Line No.");            }            systempart(Control1900383207; Links)            {                ApplicationArea = RecordLinks;                Visible = false;            }            systempart(Control1905767507; Notes)            {                ApplicationArea = Notes;                Visible = false;            }        }    }    actions    {        area(navigation)        {            group("&Line")            {                Caption = '&Line';                Image = Line;                action(Dimensions)                {                    AccessByPermission = TableData Dimension = R;                    ApplicationArea = Dimensions;                    Caption = 'Dimensions';                    Image = Dimensions;                    ShortCutKey = 'Alt+D';                    ToolTip = 'View or edit dimensions, such as area, project, or department, that you can assign to sales and purchase documents to distribute costs and analyze transaction history.';                    trigger OnAction()                    begin                        Rec.ShowDimensions();                        CurrPage.SaveRecord();                    end;                }            }            group("&Resource")            {                Caption = '&Resource';                Image = Resource;                action(Card)                {                    ApplicationArea = Jobs;                    Caption = 'Card';                    Image = EditLines;                    RunObject = Page "Resource Card";                    RunPageLink = "No." = field("Resource No.");                    ShortCutKey = 'Shift+F7';                    ToolTip = 'View or change detailed information about the record on the document or journal line.';                }                action("Ledger E&ntries")                {                    ApplicationArea = Jobs;                    Caption = 'Ledger E&ntries';                    Image = ResourceLedger;                    RunObject = Page "Resource Ledger Entries";                    RunPageLink = "Resource No." = field("Resource No.");                    RunPageView = sorting("Resource No.");                    ShortCutKey = 'Ctrl+F7';                    ToolTip = 'View the history of transactions that have been posted for the selected record.';                }            }        }        area(processing)        {            group("P&osting")            {                Caption = 'P&osting';                Image = Post;                action("Test Report")                {                    ApplicationArea = Jobs;                    Caption = 'Test Report';                    Ellipsis = true;                    Image = TestReport;                    ToolTip = 'View a test report so that you can find and correct any errors before you perform the actual posting of the journal or document.';                    trigger OnAction()                    begin                        ReportPrint.PrintResJnlLine(Rec);                    end;                }                action(Post)                {                    ApplicationArea = Jobs;                    Caption = 'P&ost';                    Image = PostOrder;                    ShortCutKey = 'F9';                    ToolTip = 'Finalize the document or journal by posting the amounts and quantities to the related accounts in your company books.';                    trigger OnAction()                    begin                        CODEUNIT.Run(CODEUNIT::"Res. Jnl.-Post", Rec);                        CurrentJnlBatchName := Rec.GetRangeMax("Journal Batch Name");                        CurrPage.Update(false);                    end;                }                action("Post and &Print")                {                    ApplicationArea = Jobs;                    Caption = 'Post and &Print';                    Image = PostPrint;                    ShortCutKey = 'Shift+F9';                    ToolTip = 'Finalize and prepare to print the document or journal. The values and quantities are posted to the related accounts. A report request window where you can specify what to include on the print-out.';                    trigger OnAction()                    begin                        CODEUNIT.Run(CODEUNIT::"Res. Jnl.-Post+Print", Rec);                        CurrentJnlBatchName := Rec.GetRangeMax("Journal Batch Name");                        CurrPage.Update(false);                    end;                }            }            group("F&unctions")            {                Caption = 'F&unctions';                Image = "Action";                action(SuggestLinesFromTimeSheets)                {                    ApplicationArea = Jobs;                    Caption = 'Suggest Lines from Time Sheets';                    Ellipsis = true;                    Image = SuggestLines;                    ToolTip = 'Fill the journal with lines that exist in the time sheets.';                    trigger OnAction()                    var                        SuggestResJnlLines: Report "Suggest Res. Jnl. Lines";                    begin                        SuggestResJnlLines.SetResJnlLine(Rec);                        SuggestResJnlLines.RunModal();                    end;                }            }            group("Page")            {                Caption = 'Page';                action(EditInExcel)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Edit in Excel';                    Image = Excel;                    ToolTip = 'Send the data in the journal to an Excel file for analysis or editing.';                    Visible = IsSaaSExcelAddinEnabled;                    AccessByPermission = System "Allow Action Export To Excel" = X;                    trigger OnAction()                    var                        ODataUtility: Codeunit ODataUtility;                    begin                        ODataUtility.EditJournalWorksheetInExcel(CurrPage.Caption, CurrPage.ObjectId(false), Rec."Journal Batch Name", Rec."Journal Template Name");                    end;                }                group(Errors)                {                    Caption = 'Issues';                    Image = ErrorLog;                    Visible = BackgroundErrorCheck;                    action(ShowLinesWithErrors)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Show Lines with Issues';                        Image = Error;                        Visible = BackgroundErrorCheck;                        Enabled = not ShowAllLinesEnabled;                        ToolTip = 'View a list of journal lines that have issues before you post the journal.';                        trigger OnAction()                        begin                            Rec.SwitchLinesWithErrorsFilter(ShowAllLinesEnabled);                        end;                    }                    action(ShowAllLines)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Show All Lines';                        Image = ExpandAll;                        Visible = BackgroundErrorCheck;                        Enabled = ShowAllLinesEnabled;                        ToolTip = 'View all journal lines, including lines with and without issues.';                        trigger OnAction()                        begin                            Rec.SwitchLinesWithErrorsFilter(ShowAllLinesEnabled);                        end;                    }                }            }        }        area(Promoted)        {            group(Category_Process)            {                Caption = 'Process', Comment = 'Generated from the PromotedActionCategories property index 1.';                group(Category_Category5)                {                    Caption = 'Post/Print', Comment = 'Generated from the PromotedActionCategories property index 4.';                    ShowAs = SplitButton;                    actionref(Post_Promoted; Post)                    {                    }                    actionref("Post and &Print_Promoted"; "Post and &Print")                    {                    }                }                actionref(SuggestLinesFromTimeSheets_Promoted; SuggestLinesFromTimeSheets)                {                }                actionref(Dimensions_Promoted; Dimensions)                {                }            }            group(Category_Category6)            {                Caption = 'Line', Comment = 'Generated from the PromotedActionCategories property index 5.';            }            group(Category_Category7)            {                Caption = 'Resource', Comment = 'Generated from the PromotedActionCategories property index 6.';                actionref(Card_Promoted; Card)                {                }            }            group(Category_Category8)            {                Caption = 'Page', Comment = 'Generated from the PromotedActionCategories property index 7.';            }            group(Category_Report)            {                Caption = 'Report', Comment = 'Generated from the PromotedActionCategories property index 2.';            }            group(Category_Category4)            {                Caption = 'Page', Comment = 'Generated from the PromotedActionCategories property index 3.';                actionref(EditInExcel_Promoted; EditInExcel)                {                }                actionref(ShowLinesWithErrors_Promoted; ShowLinesWithErrors)                {                }                actionref(ShowAllLines_Promoted; ShowAllLines)                {                }            }        }    }    trigger OnAfterGetCurrRecord()    begin        ResJnlManagement.GetRes(Rec."Resource No.", ResName);    end;    trigger OnAfterGetRecord()    begin        Rec.ShowShortcutDimCode(ShortcutDimCode);    end;    trigger OnNewRecord(BelowxRec: Boolean)    begin        Rec.SetUpNewLine(xRec);        Clear(ShortcutDimCode);    end;    trigger OnOpenPage()    var        ServerSetting: Codeunit "Server Setting";        JnlSelected: Boolean;    begin        IsSaaSExcelAddinEnabled := ServerSetting.GetIsSaasExcelAddinEnabled();        if ClientTypeManagement.GetCurrentClientType() = CLIENTTYPE::ODataV4 then            exit;        SetDimensionsVisibility();        OnOpenPageOnBeforeOpenJnl(Rec, CurrentJnlBatchName);        if Rec.IsOpenedFromBatch() then begin            CurrentJnlBatchName := Rec."Journal Batch Name";            ResJnlManagement.OpenJnl(CurrentJnlBatchName, Rec);            SetControlAppearanceFromBatch();            exit;        end;        ResJnlManagement.TemplateSelection(PAGE::"Resource Journal", false, Rec, JnlSelected);        if not JnlSelected then            Error('');        ResJnlManagement.OpenJnl(CurrentJnlBatchName, Rec);        SetControlAppearanceFromBatch();    end;    var        ResJnlManagement: Codeunit ResJnlManagement;        ReportPrint: Codeunit "Test Report-Print";        ClientTypeManagement: Codeunit "Client Type Management";        ResJournalErrorsMgt: Codeunit "Res. Journal Errors Mgt.";        IsSaaSExcelAddinEnabled: Boolean;        BackgroundErrorCheck: Boolean;        ShowAllLinesEnabled: Boolean;    protected var        ShortcutDimCode: array[8] of Code[20];        CurrentJnlBatchName: Code[10];        ResName: Text[50];        DimVisible1: Boolean;        DimVisible2: Boolean;        DimVisible3: Boolean;        DimVisible4: Boolean;        DimVisible5: Boolean;        DimVisible6: Boolean;        DimVisible7: Boolean;        DimVisible8: Boolean;    local procedure CurrentJnlBatchNameOnAfterVali()    begin        CurrPage.SaveRecord();        ResJnlManagement.SetName(CurrentJnlBatchName, Rec);        SetControlAppearanceFromBatch();        CurrPage.Update(false);    end;    local procedure SetControlAppearanceFromBatch()    var        ResJournalBatch: Record "Res. Journal Batch";        BackgroundErrorHandlingMgt: Codeunit "Background Error Handling Mgt.";    begin        if not ResJournalBatch.Get(Rec.GetRangeMax("Journal Template Name"), CurrentJnlBatchName) then            exit;        BackgroundErrorCheck := BackgroundErrorHandlingMgt.BackgroundValidationFeatureEnabled();        ShowAllLinesEnabled := true;        Rec.SwitchLinesWithErrorsFilter(ShowAllLinesEnabled);        ResJournalErrorsMgt.SetFullBatchCheck(true);    end;    local procedure SetDimensionsVisibility()    var        DimMgt: Codeunit DimensionManagement;    begin        DimVisible1 := false;        DimVisible2 := false;        DimVisible3 := false;        DimVisible4 := false;        DimVisible5 := false;        DimVisible6 := false;        DimVisible7 := false;        DimVisible8 := false;        DimMgt.UseShortcutDims(          DimVisible1, DimVisible2, DimVisible3, DimVisible4, DimVisible5, DimVisible6, DimVisible7, DimVisible8);        Clear(DimMgt);    end;    [IntegrationEvent(false, false)]    local procedure OnAfterValidateShortcutDimCode(var ResJournalLine: Record "Res. Journal Line"; var ShortcutDimCode: array[8] of Code[20]; DimIndex: Integer)    begin    end;    [IntegrationEvent(false, false)]    local procedure OnOpenPageOnBeforeOpenJnl(var ResJournalLine: Record "Res. Journal Line"; var CurrentJnlBatchName: Code[10])    begin    end;}