Page 7326 Whse. Phys. Invt. Journal, source in 29
Source29
src/Layers/W1/BaseApp/Warehouse/Journal/WhsePhysInvtJournal.Page.al544 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.Warehouse.Journal;
using Microsoft.Foundation.Reporting;
using Microsoft.Inventory.Counting.Journal;
using Microsoft.Inventory.Item;
using Microsoft.Inventory.Ledger;
using Microsoft.Inventory.Location;
using Microsoft.Warehouse.Ledger;
using Microsoft.Warehouse.Reports;
using Microsoft.Warehouse.Structure;
using System.Environment;
using System.Environment.Configuration;
using System.Integration;
using System.Integration.Excel;
page 7326 "Whse. Phys. Invt. Journal"
{
AdditionalSearchTerms = 'physical count';
ApplicationArea = Warehouse;
AutoSplitKey = true;
Caption = 'Warehouse Physical Inventory Journal';
DataCaptionFields = "Journal Batch Name";
DelayedInsert = true;
PageType = Worksheet;
SaveValues = true;
SourceTable = "Warehouse Journal Line";
UsageCategory = Tasks;
layout
{
area(content)
{
field(CurrentJnlBatchName; CurrentJnlBatchName)
{
ApplicationArea = Warehouse;
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();
Rec.LookupName(CurrentJnlBatchName, CurrentLocationCode, Rec);
CurrPage.Update(false);
end;
trigger OnValidate()
begin
Rec.CheckName(CurrentJnlBatchName, CurrentLocationCode, Rec);
CurrentJnlBatchNameOnAfterVali();
end;
}
field(CurrentLocationCode; CurrentLocationCode)
{
ApplicationArea = Warehouse;
Caption = 'Location Code';
Editable = false;
Lookup = true;
TableRelation = Location;
ToolTip = 'Specifies the code for the location where the warehouse activity takes place.';
}
repeater(Control1)
{
ShowCaption = false;
field("Registering Date"; Rec."Registering Date")
{
ApplicationArea = Warehouse;
}
field("Whse. Document No."; Rec."Whse. Document No.")
{
ApplicationArea = Warehouse;
Caption = 'Whse. Document No.';
}
field("Item No."; Rec."Item No.")
{
ApplicationArea = Warehouse;
trigger OnValidate()
begin
ItemNoOnAfterValidate();
end;
}
field("Variant Code"; Rec."Variant Code")
{
ApplicationArea = Planning;
Visible = false;
}
field(Description; Rec.Description)
{
ApplicationArea = Warehouse;
}
field("Serial No."; Rec."Serial No.")
{
ApplicationArea = ItemTracking;
Editable = SerialNoEditable;
ExtendedDatatype = Barcode;
Visible = false;
}
field("Lot No."; Rec."Lot No.")
{
ApplicationArea = ItemTracking;
Editable = LotNoEditable;
ExtendedDatatype = Barcode;
Visible = false;
}
field("Package No."; Rec."Package No.")
{
ApplicationArea = ItemTracking;
Editable = PackageNoEditable;
ExtendedDatatype = Barcode;
Visible = false;
}
field("Warranty Date"; Rec."Warranty Date")
{
ApplicationArea = ItemTracking;
visible = false;
}
field("Expiration Date"; Rec."Expiration Date")
{
ApplicationArea = ItemTracking;
Editable = ExpirationDateEditable;
visible = false;
}
field("Zone Code"; Rec."Zone Code")
{
ApplicationArea = ItemTracking;
}
field("Bin Code"; Rec."Bin Code")
{
ApplicationArea = Warehouse;
}
field("Qty. (Calculated) (Base)"; Rec."Qty. (Calculated) (Base)")
{
ApplicationArea = Warehouse;
ToolTip = 'Specifies the same as for the field in the Item Journal window.';
Visible = false;
}
field("Qty. (Phys. Inventory) (Base)"; Rec."Qty. (Phys. Inventory) (Base)")
{
ApplicationArea = Warehouse;
Editable = QtyPhysInventoryBaseIsEditable;
ToolTip = 'Specifies the same as for the field in the Item Journal window.';
Visible = false;
}
field("Qty. (Calculated)"; Rec."Qty. (Calculated)")
{
ApplicationArea = Warehouse;
ToolTip = 'Specifies the quantity of the bin item that is calculated when you use the function, Calculate Inventory, in the Whse. Physical Inventory Journal.';
}
field("Qty. (Phys. Inventory)"; Rec."Qty. (Phys. Inventory)")
{
ApplicationArea = Warehouse;
ToolTip = 'Specifies the quantity of items in the bin that you have counted.';
}
field(Quantity; Rec.Quantity)
{
ApplicationArea = Warehouse;
}
field("Unit of Measure Code"; Rec."Unit of Measure Code")
{
ApplicationArea = Warehouse;
}
field("Reason Code"; Rec."Reason Code")
{
ApplicationArea = Warehouse;
Caption = 'Reason Code';
Visible = false;
}
field("Phys Invt Counting Period Type"; Rec."Phys Invt Counting Period Type")
{
ApplicationArea = Warehouse;
Visible = false;
}
field("Phys Invt Counting Period Code"; Rec."Phys Invt Counting Period Code")
{
ApplicationArea = Warehouse;
Visible = false;
}
}
group(Control22)
{
ShowCaption = false;
fixed(Control1900669001)
{
ShowCaption = false;
group("Item Description")
{
Caption = 'Item Description';
field(ItemDescription; ItemDescription)
{
ApplicationArea = Warehouse;
Editable = false;
ShowCaption = false;
}
}
}
}
}
area(factboxes)
{
systempart(Control1900383207; Links)
{
ApplicationArea = RecordLinks;
Visible = false;
}
systempart(Control1905767507; Notes)
{
ApplicationArea = Notes;
Visible = false;
}
}
}
actions
{
area(navigation)
{
group("&Item")
{
Caption = '&Item';
Image = Item;
action(Card)
{
ApplicationArea = Warehouse;
Caption = 'Card';
Image = EditLines;
RunObject = Page "Item Card";
RunPageLink = "No." = field("Item No.");
ShortCutKey = 'Shift+F7';
ToolTip = 'View or change detailed information about the record on the document or journal line.';
}
action("Warehouse Entries")
{
ApplicationArea = Warehouse;
Caption = 'Warehouse Entries';
Image = BinLedger;
RunObject = Page "Warehouse Entries";
RunPageLink = "Item No." = field("Item No."),
"Variant Code" = field("Variant Code"),
"Location Code" = field("Location Code");
RunPageView = sorting("Item No.", "Location Code", "Variant Code", "Bin Type Code", "Unit of Measure Code", "Lot No.", "Serial No.");
ShortCutKey = 'Ctrl+F7';
ToolTip = 'View completed warehouse activities related to the document.';
}
action("Ledger E&ntries")
{
ApplicationArea = Warehouse;
Caption = 'Ledger E&ntries';
Image = ItemLedger;
RunObject = Page "Item Ledger Entries";
RunPageLink = "Item No." = field("Item No."),
"Variant Code" = field("Variant Code"),
"Location Code" = field("Location Code");
RunPageView = sorting("Item No.");
ToolTip = 'View the history of transactions that have been posted for the selected record.';
}
action("Bin Contents")
{
ApplicationArea = Warehouse;
Caption = 'Bin Contents';
Image = BinContent;
RunObject = Page "Bin Contents List";
RunPageLink = "Location Code" = field("Location Code"),
"Item No." = field("Item No."),
"Variant Code" = field("Variant Code");
RunPageView = sorting("Location Code", "Item No.", "Variant Code");
ToolTip = 'View items in the bin if the selected line contains a bin code.';
}
}
}
area(processing)
{
group("F&unctions")
{
Caption = 'F&unctions';
Image = "Action";
action("Calculate &Inventory")
{
ApplicationArea = Warehouse;
Caption = 'Calculate &Inventory';
Ellipsis = true;
Image = CalculateInventory;
ToolTip = 'Start the process of counting inventory by filling the journal with known quantities.';
trigger OnAction()
var
BinContent: Record "Bin Content";
WhseCalcInventory: Report "Whse. Calculate Inventory";
begin
BinContent.SetRange("Location Code", Rec."Location Code");
WhseCalcInventory.SetWhseJnlLine(Rec);
WhseCalcInventory.SetTableView(BinContent);
WhseCalcInventory.SetProposalMode(true);
WhseCalcInventory.RunModal();
Clear(WhseCalcInventory);
end;
}
action("&Calculate Counting Period")
{
ApplicationArea = Warehouse;
Caption = '&Calculate Counting Period';
Ellipsis = true;
Image = CalculateCalendar;
ToolTip = 'Show all items that a counting period has been assigned to, according to the counting period, the last counting period update, and the current work date.';
trigger OnAction()
var
PhysInvtCountMgt: Codeunit "Phys. Invt. Count.-Management";
SortingMethod: Option " ",Item,Bin;
begin
PhysInvtCountMgt.InitFromWhseJnl(Rec);
PhysInvtCountMgt.Run();
PhysInvtCountMgt.GetSortingMethod(SortingMethod);
case SortingMethod of
SortingMethod::Item:
Rec.SetCurrentKey("Location Code", "Item No.", "Variant Code");
SortingMethod::Bin:
Rec.SetCurrentKey("Location Code", "Bin Code");
end;
Clear(PhysInvtCountMgt);
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
EditinExcel: Codeunit "Edit in Excel";
EditinExcelFilters: Codeunit "Edit in Excel Filters";
ODataUtility: Codeunit "ODataUtility";
begin
EditinExcelFilters.AddFieldV2(ODataUtility.ExternalizeName(Rec.FieldName(Rec."Journal Batch Name")), Enum::"Edit in Excel Filter Type"::Equal, CurrentJnlBatchName, Enum::"Edit in Excel Edm Type"::"Edm.String");
EditinExcelFilters.AddFieldV2(ODataUtility.ExternalizeName(Rec.FieldName(Rec."Journal Template Name")), Enum::"Edit in Excel Filter Type"::Equal, Rec."Journal Template Name", Enum::"Edit in Excel Edm Type"::"Edm.String");
EditinExcelFilters.AddFieldV2(ODataUtility.ExternalizeName(Rec.FieldName(Rec."Location Code")), Enum::"Edit in Excel Filter Type"::Equal, CurrentLocationCode, Enum::"Edit in Excel Edm Type"::"Edm.String");
EditinExcel.EditPageInExcel(Text.CopyStr(CurrPage.Caption, 1, 240), Page::"Whse. Phys. Invt. Journal", EditInExcelFilters);
end;
}
}
action("&Print")
{
ApplicationArea = Warehouse;
Caption = '&Print';
Ellipsis = true;
Image = Print;
ToolTip = 'Prepare to print the document. A report request window for the document opens where you can specify what to include on the print-out.';
trigger OnAction()
begin
WhseJournalBatch.SetRange("Journal Template Name", Rec."Journal Template Name");
WhseJournalBatch.SetRange(Name, Rec."Journal Batch Name");
WhseJournalBatch.SetRange("Location Code", CurrentLocationCode);
WhsePhysInventoryList.SetTableView(WhseJournalBatch);
WhsePhysInventoryList.RunModal();
Clear(WhsePhysInventoryList);
end;
}
group("&Registering")
{
Caption = '&Registering';
Image = PostOrder;
action("Test Report")
{
ApplicationArea = Warehouse;
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.PrintWhseJnlLine(Rec);
end;
}
action("&Register")
{
ApplicationArea = Warehouse;
Caption = '&Register';
Image = Confirm;
ShortCutKey = 'F9';
ToolTip = 'Register the warehouse entry in question, such as a positive adjustment. ';
trigger OnAction()
begin
CODEUNIT.Run(CODEUNIT::"Whse. Jnl.-Register", Rec);
CurrentJnlBatchName := Rec.GetRangeMax("Journal Batch Name");
CurrPage.Update(false);
end;
}
action("Register and &Print")
{
ApplicationArea = Warehouse;
Caption = 'Register and &Print';
Image = ConfirmAndPrint;
ShortCutKey = 'Shift+F9';
ToolTip = 'Register the warehouse entry adjustments and print an overview of the changes. ';
trigger OnAction()
begin
CODEUNIT.Run(CODEUNIT::"Whse. Jnl.-Register+Print", Rec);
CurrentJnlBatchName := Rec.GetRangeMax("Journal Batch Name");
CurrPage.Update(false);
end;
}
}
}
area(Promoted)
{
group(Category_Process)
{
Caption = 'Process', Comment = 'Generated from the PromotedActionCategories property index 1.';
actionref("Calculate &Inventory_Promoted"; "Calculate &Inventory")
{
}
actionref("&Calculate Counting Period_Promoted"; "&Calculate Counting Period")
{
}
group(Category_Category4)
{
Caption = 'Registering';
ShowAs = SplitButton;
actionref("&Register_Promoted"; "&Register")
{
}
actionref("Register and &Print_Promoted"; "Register and &Print")
{
}
}
actionref("&Print_Promoted"; "&Print")
{
}
}
group(Category_Report)
{
Caption = 'Report', Comment = 'Generated from the PromotedActionCategories property index 2.';
}
group(Category_Category5)
{
Caption = 'Item', Comment = 'Generated from the PromotedActionCategories property index 4.';
}
group(Category_Category6)
{
Caption = 'Line', Comment = 'Generated from the PromotedActionCategories property index 5.';
}
}
}
trigger OnAfterGetCurrRecord()
begin
Rec.GetItem(Rec."Item No.", ItemDescription);
SetControls();
end;
trigger OnInit()
begin
LotNoEditable := true;
SerialNoEditable := true;
PackageNoEditable := true;
ExpirationDateEditable := true;
end;
trigger OnNewRecord(BelowxRec: Boolean)
begin
Rec.SetUpNewLine(xRec);
end;
trigger OnOpenPage()
var
ClientTypeManagement: Codeunit "Client Type Management";
ServerSetting: Codeunit "Server Setting";
JnlSelected: Boolean;
begin
IsSaaSExcelAddinEnabled := ServerSetting.GetIsSaasExcelAddinEnabled();
// if called from API (such as edit-in-excel), do not filter
if ClientTypeManagement.GetCurrentClientType() = CLIENTTYPE::ODataV4 then
exit;
if Rec.IsOpenedFromBatch() then begin
CurrentJnlBatchName := Rec."Journal Batch Name";
CurrentLocationCode := Rec."Location Code";
Rec.OpenJnl(CurrentJnlBatchName, CurrentLocationCode, Rec);
exit;
end;
JnlSelected := Rec.TemplateSelection(PAGE::"Whse. Phys. Invt. Journal", "Warehouse Journal Template Type"::"Physical Inventory", Rec);
if not JnlSelected then
Error('');
Rec.OpenJnl(CurrentJnlBatchName, CurrentLocationCode, Rec);
end;
var
WhseJournalBatch: Record "Warehouse Journal Batch";
WhsePhysInventoryList: Report "Whse. Phys. Inventory List";
ReportPrint: Codeunit "Test Report-Print";
CurrentJnlBatchName: Code[10];
CurrentLocationCode: Code[10];
IsSaaSExcelAddinEnabled: Boolean;
protected var
ItemDescription: Text[100];
SerialNoEditable: Boolean;
LotNoEditable: Boolean;
PackageNoEditable: Boolean;
QtyPhysInventoryBaseIsEditable: Boolean;
ExpirationDateEditable: Boolean;
procedure SetControls()
begin
SerialNoEditable := not Rec."Phys. Inventory";
LotNoEditable := not Rec."Phys. Inventory";
PackageNoEditable := not Rec."Phys. Inventory";
ExpirationDateEditable := not (Rec.CheckExpirationDateExists() or Rec."Phys. Inventory");
QtyPhysInventoryBaseIsEditable := Rec.IsQtyPhysInventoryBaseEditable();
end;
local procedure CurrentJnlBatchNameOnAfterVali()
begin
CurrPage.SaveRecord();
Rec.SetName(CurrentJnlBatchName, CurrentLocationCode, Rec);
CurrPage.Update(false);
end;
procedure ItemNoOnAfterValidate()
begin
Rec.GetItem(Rec."Item No.", ItemDescription);
end;
}