Page 5803 Revaluation Journal
src/Layers/W1/BaseApp/Inventory/Journal/RevaluationJournal.Page.al772 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.Inventory.Journal;using Microsoft.Finance.Dimension;using Microsoft.Foundation.Reporting;using Microsoft.Inventory.Availability;using Microsoft.Inventory.Costing;using Microsoft.Inventory.Item;using Microsoft.Inventory.Item.Catalog;using Microsoft.Inventory.Ledger;using Microsoft.Inventory.Location;using Microsoft.Inventory.Posting;using Microsoft.Inventory.Reports;using System.Environment;using System.Environment.Configuration;using System.Globalization;using System.Integration;page 5803 "Revaluation Journal"{ ApplicationArea = Basic, Suite; AutoSplitKey = true; Caption = 'Item Revaluation Journals'; DataCaptionFields = "Journal Batch Name"; DelayedInsert = true; PageType = Worksheet; SaveValues = true; SourceTable = "Item Journal Line"; UsageCategory = Tasks; layout { area(content) { field(CurrentJnlBatchName; CurrentJnlBatchName) { ApplicationArea = Basic, Suite; 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(); ItemJnlMgt.LookupName(CurrentJnlBatchName, Rec); CurrPage.Update(false); end; trigger OnValidate() begin ItemJnlMgt.CheckName(CurrentJnlBatchName, Rec); CurrentJnlBatchNameOnAfterValidate(); end; } repeater(Control1) { ShowCaption = false; field("Posting Date"; Rec."Posting Date") { ApplicationArea = Basic, Suite; Editable = false; } field("Document Date"; Rec."Document Date") { ApplicationArea = Basic, Suite; Visible = false; } field("Document No."; Rec."Document No.") { ApplicationArea = Basic, Suite; } field("External Document No."; Rec."External Document No.") { ApplicationArea = Basic, Suite; Visible = false; } field("Item No."; Rec."Item No.") { ApplicationArea = Basic, Suite; trigger OnValidate() begin ItemNoOnAfterValidate(); end; } field("Item Reference No."; Rec."Item Reference No.") { AccessByPermission = tabledata "Item Reference" = R; ApplicationArea = Suite, ItemReferences; QuickEntry = false; Visible = false; trigger OnLookup(var Text: Text): Boolean var ItemReferenceManagement: Codeunit "Item Reference Management"; begin ItemReferenceManagement.ItemJournalReferenceNoLookup(Rec); ItemNoOnAfterValidate(); OnReferenceNoOnAfterLookup(Rec); end; trigger OnValidate() begin ItemNoOnAfterValidate(); end; } field("Variant Code"; Rec."Variant Code") { ApplicationArea = Planning; Editable = false; Visible = false; } field(Description; Rec.Description) { ApplicationArea = Basic, Suite; } field("Location Code"; Rec."Location Code") { ApplicationArea = Location; Editable = false; } field("Salespers./Purch. Code"; Rec."Salespers./Purch. Code") { ApplicationArea = Suite; Visible = false; } field("Gen. Bus. Posting Group"; Rec."Gen. Bus. Posting Group") { ApplicationArea = Suite; Visible = false; } field(Quantity; Rec.Quantity) { ApplicationArea = Basic, Suite; Editable = false; ToolTip = 'Specifies the number of units of the item specified on the line.'; } field("Unit of Measure Code"; Rec."Unit of Measure Code") { ApplicationArea = Suite; Editable = false; Visible = false; } field(Amount; Rec.Amount) { ApplicationArea = Basic, Suite; Editable = false; } field("Unit Cost (Calculated)"; Rec."Unit Cost (Calculated)") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the current unit cost of this item before revaluation.'; } field("Inventory Value (Calculated)"; Rec."Inventory Value (Calculated)") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the calculated inventory value of the item at the specified posting date.'; } field("Unit Cost (Revalued)"; Rec."Unit Cost (Revalued)") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the revalued unit cost of this item.'; } field("Inventory Value (Revalued)"; Rec."Inventory Value (Revalued)") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the new inventory value.'; } field("Applies-to Entry"; Rec."Applies-to Entry") { ApplicationArea = Basic, Suite; } field("Country/Region Code"; Rec."Country/Region Code") { ApplicationArea = Basic, Suite; Visible = false; } field("Reason Code"; Rec."Reason Code") { ApplicationArea = Basic, Suite; 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(Control22) { ShowCaption = false; fixed(Control1900669001) { ShowCaption = false; group("Item Description") { Caption = 'Item Description'; field(ItemDescription; ItemDescription) { ApplicationArea = Basic, Suite; Editable = false; ShowCaption = false; ToolTip = 'Specifies a description of the item.'; } } } } } area(factboxes) { 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; Scope = Repeater; 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("&Item") { Caption = '&Item'; Image = Item; action(Card) { ApplicationArea = Basic, Suite; Caption = 'Card'; Image = EditLines; RunObject = Page "Item Card"; RunPageLink = "No." = field("Item No."); Scope = Repeater; ShortCutKey = 'Shift+F7'; ToolTip = 'View or change detailed information about the record on the document or journal line.'; } action("Ledger E&ntries") { ApplicationArea = Basic, Suite; Caption = 'Ledger E&ntries'; Image = ItemLedger; RunObject = Page "Item Ledger Entries"; RunPageLink = "Item No." = field("Item No."); RunPageView = sorting("Item No."); Scope = Repeater; ShortCutKey = 'Ctrl+F7'; ToolTip = 'View the history of transactions that have been posted for the selected record.'; } action("Value Entries") { ApplicationArea = Basic, Suite; Caption = 'Value Entries'; Image = ValueLedger; RunObject = Page "Value Entries"; RunPageLink = "Item No." = field("Item No."); RunPageView = sorting("Item No."); Scope = Repeater; ToolTip = 'View the value entries of the item on the document or journal line.'; } group("Item Availability by") { Caption = 'Item Availability by'; Image = ItemAvailability; action("Event") { ApplicationArea = Basic, Suite; Caption = 'Event'; Image = "Event"; Scope = Repeater; ToolTip = 'View how the actual and the projected available balance of an item will develop over time according to supply and demand events.'; trigger OnAction() begin ItemAvailFormsMgt.ShowItemAvailabilityFromItemJnlLine(Rec, "Item Availability Type"::"Event") end; } action(Period) { ApplicationArea = Basic, Suite; Caption = 'Period'; Image = Period; Scope = Repeater; ToolTip = 'Show the projected quantity of the item over time according to time periods, such as day, week, or month.'; trigger OnAction() begin ItemAvailFormsMgt.ShowItemAvailabilityFromItemJnlLine(Rec, "Item Availability Type"::Period) end; } action(Variant) { ApplicationArea = Planning; Caption = 'Variant'; Image = ItemVariant; Scope = Repeater; ToolTip = 'View or edit the item''s variants. Instead of setting up each color of an item as a separate item, you can set up the various colors as variants of the item.'; trigger OnAction() begin ItemAvailFormsMgt.ShowItemAvailabilityFromItemJnlLine(Rec, "Item Availability Type"::Variant) end; } action(Location) { AccessByPermission = TableData Location = R; ApplicationArea = Basic, Suite; Caption = 'Location'; Image = Warehouse; Scope = Repeater; ToolTip = 'View the actual and projected quantity of the item per location.'; trigger OnAction() begin ItemAvailFormsMgt.ShowItemAvailabilityFromItemJnlLine(Rec, "Item Availability Type"::Location) end; } action(Lot) { ApplicationArea = ItemTracking; Caption = 'Lot'; Image = LotInfo; RunObject = Page "Item Availability by Lot No."; RunPageLink = "No." = field("Item No."), "Location Filter" = field("Location Code"), "Variant Filter" = field("Variant Code"); ToolTip = 'View the current and projected quantity of the item in each lot.'; } action("BOM Level") { ApplicationArea = Basic, Suite; Caption = 'BOM Level'; Image = BOMLevel; Scope = Repeater; ToolTip = 'View availability figures for items on bills of materials that show how many units of a parent item you can make based on the availability of child items.'; trigger OnAction() begin ItemAvailFormsMgt.ShowItemAvailabilityFromItemJnlLine(Rec, "Item Availability Type"::BOM) end; } } } } area(processing) { group("F&unctions") { Caption = 'F&unctions'; Image = "Action"; action("Calculate Inventory Value - Test") { ApplicationArea = Basic, Suite; Caption = 'Calculate Inventory Value - Test'; Ellipsis = true; Image = CalculateSimulation; RunObject = Report "Calc. Inventory Value - Test"; } action("Calculate Inventory Value") { ApplicationArea = Basic, Suite; Caption = 'Calculate Inventory Value'; Ellipsis = true; Image = Calculate; Scope = Repeater; ToolTip = 'Calculate the inventory value for posting date that you specify.'; trigger OnAction() var ObjTransl: Record "Object Translation"; begin if Confirm( StrSubstNo( Text001, ObjTransl.TranslateObject(ObjTransl."Object Type"::Report, REPORT::"Adjust Cost - Item Entries")), false) then begin CalcInvtValue.SetItemJnlLine(Rec); CalcInvtValue.RunModal(); Clear(CalcInvtValue); end; end; } } group("P&osting") { Caption = 'P&osting'; Image = Post; action("Test Report") { ApplicationArea = Basic, Suite; Caption = 'Test Report'; Ellipsis = true; Image = TestReport; Scope = Repeater; 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.PrintItemJnlLine(Rec); end; } action("P&ost") { ApplicationArea = Basic, Suite; Caption = 'P&ost'; Image = PostOrder; Scope = Repeater; 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::"Item Jnl.-Post", Rec); CurrentJnlBatchName := Rec.GetRangeMax("Journal Batch Name"); CurrPage.Update(false); end; } action(PreviewPosting) { ApplicationArea = Basic, Suite; Caption = 'Preview Posting'; Image = ViewPostedOrder; ShortCutKey = 'Ctrl+Alt+F9'; ToolTip = 'Review the different types of entries that will be created when you post the document or journal.'; trigger OnAction() begin ShowPreview(); CurrPage.Update(false); end; } action("Post and &Print") { ApplicationArea = Basic, Suite; Caption = 'Post and &Print'; Image = PostPrint; Scope = Repeater; 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::"Item Jnl.-Post+Print", Rec); CurrentJnlBatchName := Rec.GetRangeMax("Journal Batch Name"); CurrPage.Update(false); 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; } } } area(Promoted) { group(Category_Process) { Caption = 'Process', Comment = 'Generated from the PromotedActionCategories property index 1.'; actionref("Calculate Inventory Value_Promoted"; "Calculate Inventory Value") { } group(Category_Category5) { Caption = 'Post/Print', Comment = 'Generated from the PromotedActionCategories property index 4.'; ShowAs = SplitButton; actionref("P&ost_Promoted"; "P&ost") { } actionref(PreviewPosting_Promoted; PreviewPosting) { } actionref("Post and &Print_Promoted"; "Post and &Print") { } } } group(Category_Category6) { Caption = 'Line', Comment = 'Generated from the PromotedActionCategories property index 5.'; actionref(Dimensions_Promoted; Dimensions) { } } group(Category_Category7) { Caption = 'Item', Comment = 'Generated from the PromotedActionCategories property index 6.'; actionref("Value Entries_Promoted"; "Value Entries") { } } group(Category_Category4) { Caption = 'Page', Comment = 'Generated from the PromotedActionCategories property index 3.'; actionref(EditInExcel_Promoted; EditInExcel) { } } group(Category_Report) { Caption = 'Report', Comment = 'Generated from the PromotedActionCategories property index 2.'; } } } trigger OnAfterGetCurrRecord() begin ItemJnlMgt.GetItem(Rec."Item No.", ItemDescription); 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(); if Rec.IsOpenedFromBatch() then begin CurrentJnlBatchName := Rec."Journal Batch Name"; ItemJnlMgt.OpenJnl(CurrentJnlBatchName, Rec); exit; end; ItemJnlMgt.TemplateSelection(PAGE::"Revaluation Journal", 3, false, Rec, JnlSelected); if not JnlSelected then Error(''); ItemJnlMgt.OpenJnl(CurrentJnlBatchName, Rec); end; var CalcInvtValue: Report "Calculate Inventory Value"; ItemJnlMgt: Codeunit ItemJnlManagement; ReportPrint: Codeunit "Test Report-Print"; ItemAvailFormsMgt: Codeunit "Item Availability Forms Mgt"; ClientTypeManagement: Codeunit "Client Type Management";#pragma warning disable AA0074#pragma warning disable AA0470 Text001: Label 'To make sure that all items are adjusted before you start the revaluation, you should run the %1 batch job first.\Do you want to continue with the revaluation?';#pragma warning restore AA0470#pragma warning restore AA0074 IsSaaSExcelAddinEnabled: Boolean; protected var ShortcutDimCode: array[8] of Code[20]; CurrentJnlBatchName: Code[10]; ItemDescription: Text[100]; DimVisible1: Boolean; DimVisible2: Boolean; DimVisible3: Boolean; DimVisible4: Boolean; DimVisible5: Boolean; DimVisible6: Boolean; DimVisible7: Boolean; DimVisible8: Boolean; local procedure CurrentJnlBatchNameOnAfterValidate() begin CurrPage.SaveRecord(); ItemJnlMgt.SetName(CurrentJnlBatchName, Rec); CurrPage.Update(false); end; procedure ItemNoOnAfterValidate() begin ItemJnlMgt.GetItem(Rec."Item No.", ItemDescription); Rec.ShowShortcutDimCode(ShortcutDimCode); 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; local procedure ShowPreview() var ItemJnlPost: Codeunit "Item Jnl.-Post"; begin ItemJnlPost.Preview(Rec); end; [IntegrationEvent(false, false)] local procedure OnAfterValidateShortcutDimCode(var ItemJournalLine: Record "Item Journal Line"; var ShortcutDimCode: array[8] of Code[20]; DimIndex: Integer) begin end; [IntegrationEvent(false, false)] local procedure OnReferenceNoOnAfterLookup(var ItemJournalLine: Record "Item Journal Line") begin end;}