diff --git a/src/Apps/W1/Subcontracting/App/src/Install/SubcBusinessSetupExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Install/SubcBusinessSetupExt.Codeunit.al
index 1955550961..8b6c88a924 100644
--- a/src/Apps/W1/Subcontracting/App/src/Install/SubcBusinessSetupExt.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/App/src/Install/SubcBusinessSetupExt.Codeunit.al
@@ -5,6 +5,7 @@
namespace Microsoft.Manufacturing.Subcontracting;
using Microsoft.Foundation.Company;
+using Microsoft.Manufacturing.Setup;
using System.Environment.Configuration;
codeunit 99001502 "Subc. Business Setup Ext."
@@ -19,7 +20,7 @@ codeunit 99001502 "Subc. Business Setup Ext."
var
ManualSetupCategory: Enum "Manual Setup Category";
begin
- sender.InsertManualSetup(SubcontractingLbl, SubcontractingLbl, SubcontractingDescriptionLbl, 0, ObjectType::Page, Page::"Subc. Management Setup", ManualSetupCategory::Uncategorized, SubcontractingKeyWordsLbl);
+ sender.InsertManualSetup(SubcontractingLbl, SubcontractingLbl, SubcontractingDescriptionLbl, 0, ObjectType::Page, Page::"Manufacturing Setup", ManualSetupCategory::Uncategorized, SubcontractingKeyWordsLbl);
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Company-Initialize", OnCompanyInitialize, '', false, false)]
diff --git a/src/Apps/W1/Subcontracting/App/src/Install/SubcontractingCompInit.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Install/SubcontractingCompInit.Codeunit.al
index 6102b835f9..0d68d399d2 100644
--- a/src/Apps/W1/Subcontracting/App/src/Install/SubcontractingCompInit.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/App/src/Install/SubcontractingCompInit.Codeunit.al
@@ -18,10 +18,10 @@ codeunit 99001503 "Subcontracting Comp. Init."
procedure CreateBasicSubcontractingMgtSetup()
begin
- CreateSubcontractingManagementSetup();
+ InitializeManufacturingSetupDefaults();
end;
- local procedure CreateSubcontractingManagementSetup()
+ local procedure InitializeManufacturingSetupDefaults()
var
ManufacturingSetup: Record "Manufacturing Setup";
begin
diff --git a/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractEdit.PermissionSet.al b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractEdit.PermissionSet.al
index a7eb20b909..871f4ad41e 100644
--- a/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractEdit.PermissionSet.al
+++ b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractEdit.PermissionSet.al
@@ -13,7 +13,6 @@ permissionset 99001503 "Subcontract. - Edit"
IncludedPermissionSets = "Subcontract. - Read";
Permissions =
- tabledata "Subc. Management Setup" = IMD,
tabledata "Subcontractor Price" = IMD,
tabledata "Subcontractor WIP Ledger Entry" = IMD;
}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractObjs.PermissionSet.al b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractObjs.PermissionSet.al
index b9ffa8d9c6..e69b8bcfb0 100644
--- a/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractObjs.PermissionSet.al
+++ b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractObjs.PermissionSet.al
@@ -11,7 +11,6 @@ permissionset 99001501 "Subcontract. - Objs"
Access = Internal;
Permissions =
// Tables
- table "Subc. Management Setup" = X,
table "Subcontractor Price" = X,
table "Subcontractor WIP Ledger Entry" = X,
@@ -23,9 +22,6 @@ permissionset 99001501 "Subcontract. - Objs"
codeunit "Subc. Calc BOM Tree Ext." = X,
codeunit "Subc. Calc Subcontracts Ext." = X,
codeunit "Subc. Carry Out Action Ext." = X,
- codeunit "Subc. Create Prod. Ord. Opt." = X,
- codeunit "Subc. Create Prod. Rtng. Ext." = X,
- codeunit "Subc. CrPurchSubcon(Yes/No)" = X,
codeunit "Subc. DirectTransferLine Ext." = X,
codeunit "Subc. Comp. Factbox Mgmt." = X,
codeunit "Subc. ProdO. Factbox Mgmt." = X,
@@ -33,7 +29,6 @@ permissionset 99001501 "Subcontract. - Objs"
codeunit "Subc. Routing Factbox Mgmt." = X,
codeunit "Subc. ItemChargeAssPurchExt" = X,
codeunit "Subc. Item Extension" = X,
- codeunit "Subc. ItemJnlCheckExt" = X,
codeunit "Subc. ItemJnlPostLine Ext" = X,
codeunit "Subc. Notification Mgmt." = X,
codeunit "Subc. Planning Comp. Ext." = X,
@@ -42,7 +37,6 @@ permissionset 99001501 "Subcontract. - Objs"
codeunit "Subc. Prod. Order Comp. Ext." = X,
codeunit "Subc. Prod. Order Rtng. Ext." = X,
codeunit "Subc. Prod. Ord. Comp. Res." = X,
- codeunit "Subc. ProdOrderCreateBind" = X,
codeunit "Subc. Purch. Post Ext" = X,
codeunit "Subc. Purchase Header Ext" = X,
codeunit "Subc. Purchase Line Ext" = X,
@@ -53,8 +47,6 @@ permissionset 99001501 "Subcontract. - Objs"
codeunit "Subcontracting Management" = X,
codeunit "Subcontracting Management Ext." = X,
codeunit "Subc. Synchronize Management" = X,
- codeunit "Subc. Temp Data Initializer" = X,
- codeunit "Subc. TempProdOrdBind" = X,
codeunit "Subc. Transfer Line Ext." = X,
codeunit "Subc. Transfer Rcpt Line Ext." = X,
codeunit "Subc. Transfer Shpt Line Ext." = X,
@@ -64,7 +56,6 @@ permissionset 99001501 "Subcontract. - Objs"
codeunit "Subc. Trans Rcpt Header Ext" = X,
codeunit "Subc. Trans Shpt Header Ext" = X,
codeunit "Subc. Vendor Extension" = X,
- codeunit "Subc. Version Mgmt." = X,
codeunit "Subc. WhsePostReceipt Ext" = X,
codeunit "Subc. WhsePurchRelease Ext" = X,
codeunit "Subc. Work Center Extension" = X,
@@ -79,15 +70,9 @@ permissionset 99001501 "Subcontract. - Objs"
codeunit "Subc. WIP Item Ledg Find Entry" = X,
// Pages
- page "Subc. Management Setup" = X,
page "Subc. Prod. Order Components" = X,
page "Subc. Purchase Line Factbox" = X,
- page "Subc. PurchProvisionWizard" = X,
page "Subc. Routing Info Factbox" = X,
- page "Subc. Temp BOM Lines" = X,
- page "Subc. Temp Prod Order Comp" = X,
- page "Subc. TempProdOrdRtngLines" = X,
- page "Subc. Temp Routing Lines" = X,
page "Subc. Transfer Line Factbox" = X,
page "Subcontractor Prices" = X,
page "Subc. WIP Adjustment" = X,
diff --git a/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractRead.PermissionSet.al b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractRead.PermissionSet.al
index e3fcc4db1d..2bbbecde21 100644
--- a/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractRead.PermissionSet.al
+++ b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractRead.PermissionSet.al
@@ -13,7 +13,6 @@ permissionset 99001502 "Subcontract. - Read"
IncludedPermissionSets = "Subcontract. - Objs";
Permissions =
- tabledata "Subc. Management Setup" = R,
tabledata "Subcontractor Price" = R,
tabledata "Subcontractor WIP Ledger Entry" = R;
}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/Manufacturing/SubcCreateProdRtngExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/Manufacturing/SubcCreateProdRtngExt.Codeunit.al
deleted file mode 100644
index 8d67a5450c..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/Manufacturing/SubcCreateProdRtngExt.Codeunit.al
+++ /dev/null
@@ -1,20 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Manufacturing.Routing;
-
-codeunit 99001526 "Subc. Create Prod. Rtng. Ext."
-{
- EventSubscriberInstance = Manual;
-
- [EventSubscriber(ObjectType::Report, Report::"Subc. Create Prod. Routing", OnAfterInsertRoutingHeader, '', false, false)]
- local procedure OnAfterInsertRoutingHeader(RoutingHeader: Record "Routing Header")
- var
- SubcontractingManagement: Codeunit "Subcontracting Management";
- begin
- SubcontractingManagement.CreatePurchProvisionRoutingLine(RoutingHeader);
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/Purchase/SubcItemChargeAssPurchExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/Purchase/SubcItemChargeAssPurchExt.Codeunit.al
index 02eca586e0..cd794c368d 100644
--- a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/Purchase/SubcItemChargeAssPurchExt.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/Purchase/SubcItemChargeAssPurchExt.Codeunit.al
@@ -4,18 +4,19 @@
// ------------------------------------------------------------------------------------------------
namespace Microsoft.Manufacturing.Subcontracting;
+using Microsoft.Manufacturing.Setup;
using Microsoft.Purchases.Document;
using Microsoft.Purchases.History;
codeunit 99001536 "Subc. ItemChargeAssPurchExt"
{
var
- SubcManagementSetup: Record "Subc. Management Setup";
+ ManufacturingSetup: Record "Manufacturing Setup";
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Charge Assgnt. (Purch.)", OnBeforeCreateRcptChargeAssgnt, '', false, false)]
local procedure "Item Charge Assgnt. (Purch.)_OnBeforeCreateRcptChargeAssgnt"(var FromPurchRcptLine: Record "Purch. Rcpt. Line"; ItemChargeAssignmentPurch: Record "Item Charge Assignment (Purch)"; var IsHandled: Boolean)
begin
- if not SubcManagementSetup.ItemChargeToRcptSubReferenceEnabled() then
+ if not ManufacturingSetup.ItemChargeToRcptSubReferenceEnabled() then
exit;
IsHandled := true;
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/Purchase/SubcPurchPostExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/Purchase/SubcPurchPostExt.Codeunit.al
index 097fac937f..e32902ce04 100644
--- a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/Purchase/SubcPurchPostExt.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/Extensions/Purchase/SubcPurchPostExt.Codeunit.al
@@ -12,13 +12,14 @@ using Microsoft.Inventory.Ledger;
using Microsoft.Inventory.Posting;
using Microsoft.Inventory.Tracking;
using Microsoft.Manufacturing.Capacity;
+using Microsoft.Manufacturing.Setup;
using Microsoft.Purchases.Document;
using Microsoft.Purchases.History;
using Microsoft.Purchases.Posting;
codeunit 99001535 "Subc. Purch. Post Ext"
{
var
- SubcManagementSetup: Record "Subc. Management Setup";
+ ManufacturingSetup: Record "Manufacturing Setup";
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch.-Post", OnBeforeItemJnlPostLine, '', false, false)]
local procedure "Purch.-Post_OnBeforeItemJnlPostLine"(var ItemJournalLine: Record "Item Journal Line"; TempItemChargeAssignmentPurch: Record "Item Charge Assignment (Purch)" temporary)
@@ -44,7 +45,7 @@ codeunit 99001535 "Subc. Purch. Post Ext"
var
PurchRcptLine: Record "Purch. Rcpt. Line";
begin
- if not SubcManagementSetup.ItemChargeToRcptSubReferenceEnabled() then
+ if not ManufacturingSetup.ItemChargeToRcptSubReferenceEnabled() then
exit;
if ItemJournalLine."Item Charge No." = '' then
exit;
@@ -60,7 +61,7 @@ codeunit 99001535 "Subc. Purch. Post Ext"
var
UnitofMeasureManagement: Codeunit "Unit of Measure Management";
begin
- if not SubcManagementSetup.ItemChargeToRcptSubReferenceEnabled() then
+ if not ManufacturingSetup.ItemChargeToRcptSubReferenceEnabled() then
exit;
if PurchRcptLine."Quantity (Base)" = 0 then
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcCrPurchSubconYesNo.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcCrPurchSubconYesNo.Codeunit.al
deleted file mode 100644
index ed55cb8aa3..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcCrPurchSubconYesNo.Codeunit.al
+++ /dev/null
@@ -1,65 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Purchases.Document;
-using System.Utilities;
-
-codeunit 99001509 "Subc. CrPurchSubcon(Yes/No)"
-{
- TableNo = "Purchase Line";
-
- var
- NothingToCreateErr: Label 'There is nothing to create.';
- PostConfirmQst: Label 'Do you want to create a production order from %1, %2 line no. %3?', Comment = '%1=Document Type, %2=Document No., %3=Line No.';
-
- trigger OnRun()
- var
- PurchaseLine: Record "Purchase Line";
- begin
- if not Rec.Find() then
- Error(NothingToCreateErr);
-
- PurchaseLine.Copy(Rec);
-
- CheckPurchaseLine(PurchaseLine);
-
- CreateProductionOrderFromPurchaseLine(PurchaseLine);
-
- Rec := PurchaseLine;
- end;
-
- local procedure CheckPurchaseLine(PurchaseLine: Record "Purchase Line")
- begin
- PurchaseLine.TestField(Type, "Purchase Line Type"::Item);
- PurchaseLine.TestField("Prod. Order No.", '');
- PurchaseLine.TestField("Prod. Order Line No.", 0);
- PurchaseLine.TestField("Qty. Assigned", 0);
- PurchaseLine.TestField("Qty. Rcd. Not Invoiced", 0);
-
- PurchaseLine.TestStatusOpen();
- end;
-
- local procedure CreateProductionOrderFromPurchaseLine(var PurchaseLine: Record "Purchase Line")
- var
- HideDialog: Boolean;
- begin
- if not HideDialog then
- if not ConfirmCreateProductionOrder(PurchaseLine) then
- exit;
-
- Codeunit.Run(Codeunit::"Subc. Create Prod. Ord. Opt.", PurchaseLine);
- end;
-
- local procedure ConfirmCreateProductionOrder(var PurchaseLine: Record "Purchase Line"): Boolean
- var
- ConfirmManagement: Codeunit "Confirm Management";
- begin
- if not ConfirmManagement.GetResponse(StrSubstNo(PostConfirmQst, Format(PurchaseLine."Document Type"), PurchaseLine."Document No.", PurchaseLine."Line No."), true) then
- exit(false);
-
- exit(true);
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcItemJnlCheckExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcItemJnlCheckExt.Codeunit.al
deleted file mode 100644
index 5abf0ece0d..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcItemJnlCheckExt.Codeunit.al
+++ /dev/null
@@ -1,19 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Inventory.Journal;
-
-codeunit 99001510 "Subc. ItemJnlCheckExt"
-{
- [EventSubscriber(ObjectType::Codeunit, Codeunit::"Mfg. Item Jnl. Check Line", OnBeforeCheckSubcontracting, '', false, false)]
- local procedure OnBeforeCheckSubcontracting(var ItemJournalLine: Record "Item Journal Line"; var IsHandled: Boolean)
- var
- SubcontractingManagement: Codeunit "Subcontracting Management";
- begin
- if not IsHandled then
- IsHandled := SubcontractingManagement.HandleCommonWorkCenter(ItemJournalLine);
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPriceManagement.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPriceManagement.Codeunit.al
index f6eae35930..9d74f136cc 100644
--- a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPriceManagement.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPriceManagement.Codeunit.al
@@ -21,14 +21,14 @@ using Microsoft.Purchases.Document;
codeunit 99001508 "Subc. Price Management"
{
var
- SubcManagementSetup: Record "Subc. Management Setup";
+ ManufacturingSetup: Record "Manufacturing Setup";
procedure ApplySubcontractorPricingToProdOrderRouting(var ProdOrderLine: Record "Prod. Order Line"; var RoutingLine: Record "Routing Line"; var ProdOrderRoutingLine: Record "Prod. Order Routing Line")
var
SubcontractorPrice: Record "Subcontractor Price";
WorkCenter: Record "Work Center";
begin
- if not SubcManagementSetup.Get() then
+ if not ManufacturingSetup.Get() then
exit;
if ProdOrderRoutingLine.Type <> "Capacity Type Routing"::"Work Center" then
@@ -67,7 +67,7 @@ codeunit 99001508 "Subc. Price Management"
SubcontractorPrice: Record "Subcontractor Price";
WorkCenter: Record "Work Center";
begin
- if not SubcManagementSetup.Get() then
+ if not ManufacturingSetup.Get() then
exit;
if RoutingLine.Type <> "Capacity Type Routing"::"Work Center" then
@@ -108,7 +108,6 @@ codeunit 99001508 "Subc. Price Management"
procedure CalcStandardCostOnAfterCalcRtngLineCost(RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal; var SLSub: Decimal)
var
Item: Record Item;
- ManufacturingSetup: Record "Manufacturing Setup";
WorkCenter: Record "Work Center";
MfgCostCalculationMgt: Codeunit "Mfg. Cost Calculation Mgt.";
SubcSessionState: Codeunit "Subc. Session State";
@@ -122,7 +121,7 @@ codeunit 99001508 "Subc. Price Management"
UnitCost: Decimal;
UnitCostCalculationType: Enum "Unit Cost Calculation Type";
begin
- if not SubcManagementSetup.Get() then
+ if not ManufacturingSetup.Get() then
exit;
if RoutingLine.Type <> "Capacity Type Routing"::"Work Center" then
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPurchFactboxMgmt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPurchFactboxMgmt.Codeunit.al
index c21c0e3454..88869d80d5 100644
--- a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPurchFactboxMgmt.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPurchFactboxMgmt.Codeunit.al
@@ -527,4 +527,4 @@ codeunit 99001560 "Subc. Purch. Factbox Mgmt."
TransferLine.SetFilter("Operation No.", '<>%1', '');
TransferLine.SetFilter("Routing No.", '<>%1', '');
end;
-}
+}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPurchaseOrderCreator.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPurchaseOrderCreator.Codeunit.al
index e803792afa..674c9c8dd7 100644
--- a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPurchaseOrderCreator.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcPurchaseOrderCreator.Codeunit.al
@@ -24,11 +24,9 @@ using System.Utilities;
codeunit 99001557 "Subc. Purchase Order Creator"
{
var
- SubcManagementSetup: Record "Subc. Management Setup";
ManufacturingSetup: Record "Manufacturing Setup";
PageManagement: Codeunit "Page Management";
UnitofMeasureManagement: Codeunit "Unit of Measure Management";
- HasSubManagementSetup: Boolean;
HasManufacturingSetup: Boolean;
OperationNo: Code[10];
PurchOrderCreatedTxt: Label '%1 Purchase Order(s) created.\\Do you want to view them?', Comment = '%1 = No of Purchase Order(s) created.';
@@ -113,7 +111,7 @@ codeunit 99001557 "Subc. Purchase Order Creator"
SubContractorWorkCenterNo: Code[20];
DimensionSetIDArr: array[10] of Integer;
begin
- GetSubmanagementSetup();
+ GetManufacturingSetup();
ProdOrderRoutingLine.SetLoadFields("Work Center No.", Status, "Prod. Order No.", "Routing Link Code");
if ProdOrderRoutingLine.Get("Production Order Status"::Released, RequisitionLine."Prod. Order No.", RequisitionLine."Routing Reference No.", RequisitionLine."Routing No.", RequisitionLine."Operation No.") then begin
WorkCenter.SetLoadFields("Subcontractor No.");
@@ -359,14 +357,6 @@ codeunit 99001557 "Subc. Purchase Order Creator"
exit(BaseQuantityToPurch);
end;
- local procedure GetSubmanagementSetup()
- begin
- if HasSubManagementSetup then
- exit;
- if SubcManagementSetup.Get() then
- HasSubManagementSetup := true;
- end;
-
local procedure GetManufacturingSetup()
begin
if HasManufacturingSetup then
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcontractingManagement.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcontractingManagement.Codeunit.al
index e5296184d5..85b73b1ce3 100644
--- a/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcontractingManagement.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/App/src/Process/Codeunits/SubcontractingManagement.Codeunit.al
@@ -6,7 +6,6 @@ namespace Microsoft.Manufacturing.Subcontracting;
using Microsoft.Foundation.Company;
using Microsoft.Inventory.Item;
-using Microsoft.Inventory.Journal;
using Microsoft.Inventory.Ledger;
using Microsoft.Inventory.Location;
using Microsoft.Inventory.Planning;
@@ -25,10 +24,8 @@ using System.Utilities;
codeunit 99001505 "Subcontracting Management"
{
var
- SubcManagementSetup: Record "Subc. Management Setup";
ManufacturingSetup: Record "Manufacturing Setup";
TempGlobalReservationEntry: Record "Reservation Entry" temporary;
- HasSubManagementSetup: Boolean;
RoutingLinkUpdConfQst: Label 'If you change the Work Center, you will also change the default location for components with Routing Link Code=%1.\Do you want to continue anyway?', Comment = '%1=Routing Link Code';
SuccessfullyUpdatedMsg: Label 'Successfully updated.';
UpdateIsCancelledErr: Label 'Update cancelled.';
@@ -99,40 +96,6 @@ codeunit 99001505 "Subcontracting Management"
TransferHeader.CheckDirectTransferPosting();
end;
- procedure CreatePurchProvisionRoutingLine(RoutingHeader: Record "Routing Header")
- var
- RoutingLine: Record "Routing Line";
- Vendor: Record Vendor;
- SubcSessionState: Codeunit "Subc. Session State";
- RoutingLinkCode: Code[10];
- WorkCenterNo: Code[20];
- begin
- GetManufacturingSetup();
- if HasManufacturingSetup then
- RoutingLinkCode := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
-
- Vendor.SetLoadFields("Work Center No.");
- if Vendor.Get(SubcSessionState.GetCode(GetKeyCreateProdOrderProcess())) then
- WorkCenterNo := Vendor."Work Center No.";
-
- GetSubmanagementSetup();
- if WorkCenterNo = '' then
- WorkCenterNo := SubcManagementSetup."Common Work Center No.";
-
- if WorkCenterNo = '' then
- exit;
-
- RoutingLine.Init();
- RoutingLine."Routing No." := RoutingHeader."No.";
- RoutingLine."Operation No." := '01';
- RoutingLine.Type := "Capacity Type Routing"::"Work Center";
- RoutingLine.Validate("No.", WorkCenterNo);
- if RoutingLinkCode <> '' then
- RoutingLine."Routing Link Code" := RoutingLinkCode;
-
- RoutingLine.Insert();
- end;
-
procedure DelLocationLinkedComponents(ProdOrderRoutingLine: Record "Prod. Order Routing Line"; ShowMsg: Boolean)
var
ProdOrderComponent: Record "Prod. Order Component";
@@ -195,17 +158,6 @@ codeunit 99001505 "Subcontracting Management"
exit(false);
end;
- procedure HandleCommonWorkCenter(ItemJournalLine: Record "Item Journal Line"): Boolean
- begin
- if ItemJournalLine."Work Center No." = '' then
- exit(false);
- GetSubmanagementSetup();
- if SubcManagementSetup."Common Work Center No." = ItemJournalLine."Work Center No." then
- exit(true);
-
- exit(false);
- end;
-
procedure UpdateSubcontractorPriceForRequisitionLine(var RequisitionLine: Record "Requisition Line")
begin
if IsSubcontracting(RequisitionLine."Work Center No.") then
@@ -556,14 +508,6 @@ codeunit 99001505 "Subcontracting Management"
exit(ComponentsLocationCode);
end;
- local procedure GetSubmanagementSetup()
- begin
- if HasSubManagementSetup then
- exit;
- if SubcManagementSetup.Get() then
- HasSubManagementSetup := true;
- end;
-
local procedure GetManufacturingSetup()
begin
if HasManufacturingSetup then
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/MasterData/SubcItemCard.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/MasterData/SubcItemCard.PageExt.al
index e14fa5ce72..ae96ba5ddb 100644
--- a/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/MasterData/SubcItemCard.PageExt.al
+++ b/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/MasterData/SubcItemCard.PageExt.al
@@ -23,24 +23,5 @@ pageextension 99001518 "Subc. Item Card" extends "Item Card"
ToolTip = 'Set up different prices for the item in subcontracting.';
}
}
- addlast(Functions)
- {
- action(CreatePurchProvProdBOMRtng)
- {
- ApplicationArea = Manufacturing;
- Caption = 'Create Prod. BOM/Routing';
- Image = CreateForm;
- ToolTip = 'Create a Production BOM and/or Routing for the item.';
- trigger OnAction()
- var
- SubcCreateProdRtngExt: Codeunit "Subc. Create Prod. Rtng. Ext.";
- begin
- Rec.SetRecFilter();
- BindSubscription(SubcCreateProdRtngExt);
- Report.Run(Report::"Subc. Create Prod. Routing", true, true, Rec);
- UnbindSubscription(SubcCreateProdRtngExt);
- end;
- }
- }
}
}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/MasterData/SubcItemChargeAssPurch.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/MasterData/SubcItemChargeAssPurch.PageExt.al
index f13675f85b..2ca638a693 100644
--- a/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/MasterData/SubcItemChargeAssPurch.PageExt.al
+++ b/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/MasterData/SubcItemChargeAssPurch.PageExt.al
@@ -4,6 +4,8 @@
// ------------------------------------------------------------------------------------------------
namespace Microsoft.Manufacturing.Subcontracting;
+using Microsoft.Manufacturing.Setup;
+
using Microsoft.Purchases.Document;
using Microsoft.Purchases.History;
@@ -33,7 +35,7 @@ pageextension 99001522 "Subc. ItemChargeAss.(Purch)" extends "Item Charge Assign
}
}
var
- SubcManagementSetup: Record "Subc. Management Setup";
+ ManufacturingSetup: Record "Manufacturing Setup";
GetReceiptLinesSubcontractingVisible: Boolean;
local procedure OpenPurchaseReceiptLinesSubcontracting()
@@ -64,6 +66,6 @@ pageextension 99001522 "Subc. ItemChargeAss.(Purch)" extends "Item Charge Assign
trigger OnOpenPage()
begin
- GetReceiptLinesSubcontractingVisible := SubcManagementSetup.ItemChargeToRcptSubReferenceEnabled();
+ GetReceiptLinesSubcontractingVisible := ManufacturingSetup.ItemChargeToRcptSubReferenceEnabled();
end;
}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/Purchase/SubcPOSubform.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/Purchase/SubcPOSubform.PageExt.al
index ee35fa5ab6..29d83b4b7b 100644
--- a/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/Purchase/SubcPOSubform.PageExt.al
+++ b/src/Apps/W1/Subcontracting/App/src/Process/Pageextensions/Purchase/SubcPOSubform.PageExt.al
@@ -4,10 +4,7 @@
// ------------------------------------------------------------------------------------------------
namespace Microsoft.Manufacturing.Subcontracting;
-using Microsoft.Manufacturing.Document;
using Microsoft.Purchases.Document;
-using Microsoft.Utilities;
-using System.Utilities;
pageextension 99001524 "Subc. PO Subform" extends "Purchase Order Subform"
{
@@ -24,21 +21,6 @@ pageextension 99001524 "Subc. PO Subform" extends "Purchase Order Subform"
}
actions
{
- addlast("F&unctions")
- {
- action(CreateProdOrder)
- {
- ApplicationArea = Manufacturing;
- Caption = 'Create Production Order';
- Image = CreateSerialNo;
- ToolTip = 'Create the production order for the current purchase order.';
- trigger OnAction()
- begin
- Rec.TestStatusOpen();
- CreateProductionOrder(Codeunit::"Subc. CrPurchSubcon(Yes/No)", true);
- end;
- }
- }
addafter("F&unctions")
{
group(Production)
@@ -106,46 +88,6 @@ pageextension 99001524 "Subc. PO Subform" extends "Purchase Order Subform"
var
SubcProdOrderFactboxMgmt: Codeunit "Subc. ProdO. Factbox Mgmt.";
SubcPurchFactboxMgmt: Codeunit "Subc. Purch. Factbox Mgmt.";
- OpenCreatedTransferOrderQst: Label 'The production order %1 was created from the current purchase order.\\Would you like to open the production order?', Comment = '%1=Production Order No.';
-
- local procedure CreateProductionOrder(CreatingCodeunitID: Integer; ShowCreatedDocument: Boolean)
- var
- ErrorMessageHandler: Codeunit "Error Message Handler";
- ErrorMessageManagement: Codeunit "Error Message Management";
- InstructionMgt: Codeunit "Instruction Mgt.";
- SubcNotificationMgmt: Codeunit "Subc. Notification Mgmt.";
- ProdOrderCreated: Boolean;
- begin
- ErrorMessageManagement.Activate(ErrorMessageHandler);
-
- Commit(); // Used for following call of codeunit run
- ProdOrderCreated := Codeunit.Run(CreatingCodeunitID, Rec);
-
- if CreatingCodeunitID <> Codeunit::"Subc. CrPurchSubcon(Yes/No)" then
- exit;
-
- if ProdOrderCreated then begin
- if ShowCreatedDocument then
- if InstructionMgt.IsEnabled(SubcNotificationMgmt.ShowCreatedProductionOrderConfirmationMessageCode()) then
- ShowCreatedProdOrderConfirmationMessage()
- end else
- ErrorMessageHandler.ShowErrors();
- end;
-
- local procedure ShowCreatedProdOrderConfirmationMessage()
- var
- ProductionOrder: Record "Production Order";
- InstructionMgt: Codeunit "Instruction Mgt.";
- PageManagement: Codeunit "Page Management";
- SubcNotificationMgmt: Codeunit "Subc. Notification Mgmt.";
- begin
- ProductionOrder.SetRange(Status, "Production Order Status"::Released);
- ProductionOrder.SetRange("No.", Rec."Prod. Order No.");
- if ProductionOrder.FindFirst() then
- if InstructionMgt.ShowConfirm(StrSubstNo(OpenCreatedTransferOrderQst, ProductionOrder."No."),
- SubcNotificationMgmt.ShowCreatedProductionOrderConfirmationMessageCode()) then
- PageManagement.PageRun(ProductionOrder);
- end;
local procedure ShowProductionOrder(RecRelatedVariant: Variant)
begin
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcCreateProdOrdOpt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcCreateProdOrdOpt.Codeunit.al
deleted file mode 100644
index eb6a615186..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcCreateProdOrdOpt.Codeunit.al
+++ /dev/null
@@ -1,1213 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Foundation.NoSeries;
-using Microsoft.Inventory.Item;
-using Microsoft.Inventory.Location;
-using Microsoft.Inventory.Requisition;
-using Microsoft.Inventory.Tracking;
-using Microsoft.Manufacturing.Capacity;
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.ProductionBOM;
-using Microsoft.Manufacturing.Routing;
-using Microsoft.Manufacturing.Setup;
-using Microsoft.Manufacturing.WorkCenter;
-using Microsoft.Purchases.Document;
-using Microsoft.Purchases.Vendor;
-codeunit 99001556 "Subc. Create Prod. Ord. Opt."
-{
- TableNo = "Purchase Line";
-
- var
- ManufacturingSetup: Record "Manufacturing Setup";
- SubcManagementSetup: Record "Subc. Management Setup";
- SubcTempDataInitializer: Codeunit "Subc. Temp Data Initializer";
- SubcVersionMgmt: Codeunit "Subc. Version Mgmt.";
- BOMCreated, BOMVersionCreated : Boolean;
- HasSubManagementSetup: Boolean;
- HasManufacturingSetup: Boolean;
- ProdCompRoutingModified: Boolean;
- ProdOrderCompRoutingCreated: Boolean;
- RoutingCreated, RoutingVersionCreated : Boolean;
- GlobalSubcRtngBOMSourceType: Enum "Subc. RtngBOMSourceType";
-
- trigger OnRun()
- begin
- CreateProductionOrderWithTemporaryData(Rec);
- end;
-
- ///
- /// Main orchestration method for creating production orders with temporary data handling
- ///
- local procedure CreateProductionOrderWithTemporaryData(var PurchaseLine: Record "Purchase Line")
- var
- Item: Record Item;
- SubcScenarioType: Enum "Subc. Scenario Type";
- begin
- ValidateAndPrepareCreation(PurchaseLine, Item);
- SubcScenarioType := DetermineScenarioAndPrepareData(Item, PurchaseLine);
-
- if not ExecuteBOMRoutingWizardProcess(Item, SubcScenarioType) then
- Error('');
-
- TransferTemporaryDataToRealTables(PurchaseLine);
- end;
-
- ///
- /// Determines the scenario type based on existing BOM and Routing data from best source
- ///
- local procedure DetermineScenarioAndPrepareData(Item: Record Item; PurchaseLine: Record "Purchase Line") SubcScenarioType: Enum "Subc. Scenario Type"
- var
- BOMNo, RoutingNo : Code[20];
- SubcRtngBOMSourceType: Enum "Subc. RtngBOMSourceType";
- begin
- SubcTempDataInitializer.InitializeTemporaryProdOrder(PurchaseLine);
-
- GetBOMAndRoutingFromBestSource(Item, BOMNo, RoutingNo, SubcRtngBOMSourceType);
-
- SubcTempDataInitializer.SetRtngBOMSourceType(SubcRtngBOMSourceType);
-
- SubcScenarioType := GetScenarioTypeFromBOMRouting(BOMNo, RoutingNo);
-
- PrepareBOMAndRoutingDataForScenario(BOMNo, RoutingNo);
-
- exit(SubcScenarioType);
- end;
-
- ///
- /// Gets BOM and routing from best source (Stockkeeping Unit or Item)
- ///
- local procedure GetBOMAndRoutingFromBestSource(var Item: Record Item; var BOMNo: Code[20]; var RoutingNo: Code[20]; var SubcRtngBOMSourceType: Enum "Subc. RtngBOMSourceType")
- var
- LocationCode, VariantCode : Code[10];
- begin
- Clear(BOMNo);
- Clear(RoutingNo);
- SubcRtngBOMSourceType := SubcRtngBOMSourceType::Empty;
-
- GetLocationAndVariantForStockkeepingUnit(LocationCode, VariantCode);
-
- if GetBOMAndRoutingFromStockkeepingUnit(Item."No.", VariantCode, LocationCode, BOMNo, RoutingNo) then begin
- SubcRtngBOMSourceType := SubcRtngBOMSourceType::StockkeepingUnit;
- exit;
- end;
-
- BOMNo := Item."Production BOM No.";
- RoutingNo := Item."Routing No.";
-
- if (BOMNo <> '') or (RoutingNo <> '') then
- SubcRtngBOMSourceType := SubcRtngBOMSourceType::Item;
- end;
-
- ///
- /// Gets BOM and routing from Stockkeeping Unit
- ///
- local procedure GetBOMAndRoutingFromStockkeepingUnit(ItemNo: Code[20]; VariantCode: Code[10]; LocationCode: Code[10]; var BOMNo: Code[20]; var RoutingNo: Code[20]): Boolean
- var
- StockkeepingUnit: Record "Stockkeeping Unit";
- begin
- StockkeepingUnit.SetLoadFields("Production BOM No.", "Routing No.");
- if not StockkeepingUnit.Get(LocationCode, ItemNo, VariantCode) then
- exit(false);
-
- BOMNo := StockkeepingUnit."Production BOM No.";
- RoutingNo := StockkeepingUnit."Routing No.";
-
- exit((BOMNo <> '') or (RoutingNo <> ''));
- end;
-
- ///
- /// Determines scenario type based on BOM and Routing presence
- ///
- local procedure GetScenarioTypeFromBOMRouting(BOMNo: Code[20]; RoutingNo: Code[20]): Enum "Subc. Scenario Type"
- var
- SubcScenarioType: Enum "Subc. Scenario Type";
- begin
- if (BOMNo <> '') and (RoutingNo <> '') then
- exit(SubcScenarioType::BothAvailable);
-
- if (BOMNo <> '') or (RoutingNo <> '') then
- exit(SubcScenarioType::PartiallyAvailable);
-
- exit(SubcScenarioType::NothingAvailable);
- end;
-
- ///
- /// Validates purchase line and prepares item data
- ///
- local procedure ValidateAndPrepareCreation(var PurchaseLine: Record "Purchase Line"; var Item: Record Item)
- begin
- ValidateMandatoryFields(PurchaseLine);
- Item.SetLoadFields("Production BOM No.", "Routing No.", "Scrap %", "Inventory Posting Group");
- Item.Get(PurchaseLine."No.");
- end;
-
- ///
- /// Prepares BOM and Routing data based on scenario requirements
- ///
- local procedure PrepareBOMAndRoutingDataForScenario(BOMNo: Code[20]; RoutingNo: Code[20])
- var
- BOMVersionCode, RoutingVersionCode : Code[20];
- begin
- SubcTempDataInitializer.InitializeNewTemporaryBOMInformation();
- if BOMNo <> '' then begin
- BOMVersionCode := SubcVersionMgmt.GetDefaultBOMVersion(BOMNo);
- SubcTempDataInitializer.LoadBOMLines(BOMNo, BOMVersionCode);
- end;
-
- SubcTempDataInitializer.InitializeNewTemporaryRoutingInformation();
- if RoutingNo <> '' then begin
- RoutingVersionCode := SubcVersionMgmt.GetDefaultRoutingVersion(RoutingNo);
- SubcTempDataInitializer.LoadRoutingLines(RoutingNo, RoutingVersionCode);
- end;
- end;
-
- ///
- /// Executes the BOM/Routing wizard process with user interaction
- ///
- local procedure ExecuteBOMRoutingWizardProcess(Item: Record Item; SubcScenarioType: Enum "Subc. Scenario Type"): Boolean
- begin
- exit(RunBOMRoutingWizardWithUserInteraction(Item, SubcScenarioType));
- end;
-
- ///
- /// Handles the wizard interaction with show/edit type determination
- ///
- local procedure RunBOMRoutingWizardWithUserInteraction(Item: Record Item; SubcScenarioType: Enum "Subc. Scenario Type"): Boolean
- var
- SubcTempProdOrdBind: Codeunit "Subc. TempProdOrdBind";
- BOMRoutingShowEditType: Enum "Subc. Show/Edit Type";
- ProdCompRoutingShowEditType: Enum "Subc. Show/Edit Type";
- begin
- BindSubscription(SubcTempProdOrdBind);
- GetShowEditTypesForScenario(SubcScenarioType, BOMRoutingShowEditType, ProdCompRoutingShowEditType);
-
- if ShouldSkipUserInteraction(BOMRoutingShowEditType, ProdCompRoutingShowEditType) then begin
- SubcTempDataInitializer.BuildTemporaryStructureFromBOMRouting();
- exit(true);
- end;
-
- exit(ExecuteWizardPageWithTemporaryData(Item, BOMRoutingShowEditType, ProdCompRoutingShowEditType));
- end;
-
- ///
- /// Gets show/edit types for both BOM/Routing and Production Components/Routing in one call
- ///
- local procedure GetShowEditTypesForScenario(SubcScenarioType: Enum "Subc. Scenario Type"; var BOMRoutingShowEditType: Enum "Subc. Show/Edit Type"; var ProdCompRoutingShowEditType: Enum "Subc. Show/Edit Type")
- begin
- GetSubManagementSetupCached();
-
- case SubcScenarioType of
- SubcScenarioType::BothAvailable:
- begin
- BOMRoutingShowEditType := SubcManagementSetup.ShowRtngBOMSelect_Both;
- ProdCompRoutingShowEditType := SubcManagementSetup.ShowProdRtngCompSelect_Both;
- end;
- SubcScenarioType::PartiallyAvailable:
- begin
- BOMRoutingShowEditType := SubcManagementSetup.ShowRtngBOMSelect_Partial;
- ProdCompRoutingShowEditType := SubcManagementSetup.ShowProdRtngCompSelect_Partial;
- end;
- SubcScenarioType::NothingAvailable:
- begin
- BOMRoutingShowEditType := SubcManagementSetup.ShowRtngBOMSelect_Nothing;
- ProdCompRoutingShowEditType := SubcManagementSetup.ShowProdRtngCompSelect_Nothing;
- end
- end;
- end;
-
- ///
- /// Determines if user interaction can be skipped
- ///
- local procedure ShouldSkipUserInteraction(BOMRoutingShowEditType: Enum "Subc. Show/Edit Type"; ProdCompRoutingShowEditType: Enum "Subc. Show/Edit Type"): Boolean
- begin
- exit((BOMRoutingShowEditType = BOMRoutingShowEditType::Hide) and
- (ProdCompRoutingShowEditType = ProdCompRoutingShowEditType::Hide));
- end;
-
- ///
- /// Executes the wizard page with temporary data binding
- ///
- local procedure ExecuteWizardPageWithTemporaryData(Item: Record Item; BOMRoutingShowEditType: Enum "Subc. Show/Edit Type"; ProdCompRoutingShowEditType: Enum "Subc. Show/Edit Type"): Boolean
- var
- SubcPurchProvisionWizard: Page "Subc. PurchProvisionWizard";
- begin
- SetupWizardPageWithTemporaryData(SubcPurchProvisionWizard, Item, BOMRoutingShowEditType, ProdCompRoutingShowEditType);
- SubcPurchProvisionWizard.RunModal();
-
- if SubcPurchProvisionWizard.GetFinished() then begin
- UpdateWizardResults(SubcPurchProvisionWizard);
- exit(true);
- end;
-
- exit(false);
- end;
-
- ///
- /// Updates internal flags based on wizard results
- ///
- local procedure UpdateWizardResults(var SubcPurchProvisionWizard: Page "Subc. PurchProvisionWizard")
- begin
- ProdCompRoutingModified := SubcPurchProvisionWizard.GetApplyChangesComponents() or SubcPurchProvisionWizard.GetApplyChangesProdRouting();
- GlobalSubcRtngBOMSourceType := SubcPurchProvisionWizard.GetApplyBomRtngToSource();
- end;
-
- ///
- /// Configures the wizard page with temporary data
- ///
- local procedure SetupWizardPageWithTemporaryData(var SubcPurchProvisionWizard: Page "Subc. PurchProvisionWizard"; Item: Record Item; BOMRoutingShowEditType: Enum "Subc. Show/Edit Type"; ProdCompRoutingShowEditType: Enum "Subc. Show/Edit Type")
- begin
- SubcPurchProvisionWizard.SetItem(Item);
- SubcPurchProvisionWizard.SetBOMRoutingShowEditType(BOMRoutingShowEditType);
- SubcPurchProvisionWizard.SetProdCompRoutingShowEditType(ProdCompRoutingShowEditType);
- SubcPurchProvisionWizard.SetTempDataInitializer(SubcTempDataInitializer);
- end;
-
- ///
- /// Main method for transferring temporary data to real tables with transaction safety
- ///
- [CommitBehavior(CommitBehavior::Ignore)]
- local procedure TransferTemporaryDataToRealTables(var PurchaseLine: Record "Purchase Line")
- var
- ProductionOrder: Record "Production Order";
- SubcProdOrderCreateBind: Codeunit "Subc. ProdOrderCreateBind";
- begin
- BindSubscription(SubcProdOrderCreateBind);
- SubcProdOrderCreateBind.SetSubcontractingPurchaseLine(PurchaseLine);
-
- UpdateItemWithBOMAndRoutingFromTemp(PurchaseLine);
- CreateReleasedProductionOrderFromTemp(ProductionOrder);
- TransferTemporaryDataToProductionOrder(ProductionOrder);
- RefreshProductionOrderWithOptimalSettings(ProductionOrder);
- FinalizeProductionOrderCreation(PurchaseLine, ProductionOrder);
-
- UnbindSubscription(SubcProdOrderCreateBind);
- end;
-
- ///
- /// Refreshes production order based on modification state
- ///
- local procedure RefreshProductionOrderWithOptimalSettings(var ProductionOrder: Record "Production Order")
- var
- Direction: Option Forward,Backward;
- begin
- if ProdOrderCompRoutingCreated then
- RefreshProductionOrderAfterUpdate(ProductionOrder, Direction::Backward, false, false, false)
- else
- RefreshProductionOrderAfterUpdate(ProductionOrder, Direction::Backward, true, true, false);
- end;
-
- ///
- /// Finalizes production order creation with all related operations
- ///
- local procedure FinalizeProductionOrderCreation(var PurchaseLine: Record "Purchase Line"; var ProductionOrder: Record "Production Order")
- begin
- TransferReservationEntryFromPurchOrderCompToProdOrderLine(PurchaseLine, ProductionOrder);
- UpdatePurchaseLineWithProdOrder(PurchaseLine, ProductionOrder);
- CleanupTemporaryBOMAndRoutingIfNotNeeded();
- HandleSubcontractingAfterUpdate(PurchaseLine);
- end;
-
- ///
- /// Creates released production order from temporary data
- ///
- local procedure CreateReleasedProductionOrderFromTemp(var ProductionOrder: Record "Production Order")
- var
- TempProductionOrder: Record "Production Order" temporary;
- begin
- SubcTempDataInitializer.GetGlobalProdOrder(TempProductionOrder);
-
- InitializeProductionOrder(ProductionOrder);
-
- ConfigureProductionOrderFromTemp(ProductionOrder, TempProductionOrder);
-
- ProductionOrder."Created from Purch. Order" := true;
- ProductionOrder.Modify(true);
- end;
-
- ///
- /// Initializes production order with basic settings
- ///
- local procedure InitializeProductionOrder(var ProductionOrder: Record "Production Order")
- begin
- Clear(ProductionOrder);
- ProductionOrder.Init();
- ProductionOrder.Validate(Status, "Production Order Status"::Released);
- ProductionOrder.Insert(true);
-
- end;
-
- ///
- /// Configures production order with data from temporary record
- ///
- local procedure ConfigureProductionOrderFromTemp(var ProductionOrder: Record "Production Order"; var TempProductionOrder: Record "Production Order" temporary)
- begin
- ProductionOrder."Source Type" := TempProductionOrder."Source Type";
- ProductionOrder.Validate("Source No.", TempProductionOrder."Source No.");
-
- if TempProductionOrder."Variant Code" <> '' then
- ProductionOrder.Validate("Variant Code", TempProductionOrder."Variant Code");
-
- ProductionOrder.Validate("Due Date", TempProductionOrder."Due Date");
- ProductionOrder.Validate(Quantity, TempProductionOrder.Quantity);
- ProductionOrder.Validate("Location Code", TempProductionOrder."Location Code");
- end;
-
- ///
- /// Transfers temporary data to production order
- ///
- local procedure TransferTemporaryDataToProductionOrder(ProductionOrder: Record "Production Order")
- var
- ProdOrderLine: Record "Prod. Order Line";
- TempProdOrderLine: Record "Prod. Order Line" temporary;
- begin
- SubcTempDataInitializer.GetGlobalProdOrderLine(TempProdOrderLine);
- if not TempProdOrderLine.FindFirst() then
- exit;
-
- CreateProdOrderLineFromTemp(ProdOrderLine, ProductionOrder, TempProdOrderLine);
- TransferComponentsAndRoutingLines(ProdOrderLine);
- end;
-
- ///
- /// Transfers components and routing lines
- ///
- local procedure TransferComponentsAndRoutingLines(var ProdOrderLine: Record "Prod. Order Line")
- begin
- if not CheckCreateProdOrderCompRtng() then
- exit;
-
- TransferProductionOrderComponents(ProdOrderLine);
- TransferProductionOrderRoutingLines(ProdOrderLine);
-
- ProdOrderCompRoutingCreated := true;
- end;
-
- ///
- /// Transfers production order components
- ///
- local procedure TransferProductionOrderComponents(var ProdOrderLine: Record "Prod. Order Line")
- var
- ProdOrderComponent: Record "Prod. Order Component";
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- begin
- SubcTempDataInitializer.GetGlobalProdOrderComponent(TempProdOrderComponent);
- if TempProdOrderComponent.FindSet() then
- repeat
- CreateProdOrderComponentFromTemp(ProdOrderComponent, TempProdOrderComponent, ProdOrderLine);
- until TempProdOrderComponent.Next() = 0;
- end;
-
- ///
- /// Transfers production order routing lines
- ///
- local procedure TransferProductionOrderRoutingLines(var ProdOrderLine: Record "Prod. Order Line")
- var
- ProdOrderRoutingLine: Record "Prod. Order Routing Line";
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- begin
- SubcTempDataInitializer.GetGlobalProdOrderRoutingLine(TempProdOrderRoutingLine);
- if TempProdOrderRoutingLine.FindSet() then
- repeat
- CreateProdOrderRoutingLineFromTemp(ProdOrderRoutingLine, TempProdOrderRoutingLine, ProdOrderLine);
- until TempProdOrderRoutingLine.Next() = 0;
- end;
-
- ///
- /// Updates purchase line with production order information
- ///
- local procedure UpdatePurchaseLineWithProdOrder(var PurchaseLine: Record "Purchase Line"; ProductionOrder: Record "Production Order")
- var
- ProdOrderLine: Record "Prod. Order Line";
- begin
- InitializePurchaseLineFields(PurchaseLine, ProductionOrder);
- FindAndSetProdOrderLineNo(PurchaseLine, ProductionOrder, ProdOrderLine);
- UpdatePurchLineWithRoutingInfo(PurchaseLine, ProdOrderLine);
- PurchaseLine.Modify(true);
- end;
-
- ///
- /// Initializes basic purchase line fields
- ///
- local procedure InitializePurchaseLineFields(var PurchaseLine: Record "Purchase Line"; ProductionOrder: Record "Production Order")
- begin
- PurchaseLine."Prod. Order No." := ProductionOrder."No.";
- PurchaseLine."Qty. per Unit of Measure" := 0;
- PurchaseLine."Quantity (Base)" := 0;
- PurchaseLine."Qty. to Invoice (Base)" := 0;
- PurchaseLine."Qty. to Receive (Base)" := 0;
- PurchaseLine."Outstanding Qty. (Base)" := 0;
- end;
-
- ///
- /// Finds and sets production order line number
- ///
- local procedure FindAndSetProdOrderLineNo(var PurchaseLine: Record "Purchase Line"; ProductionOrder: Record "Production Order"; var ProdOrderLine: Record "Prod. Order Line")
- begin
- ProdOrderLine.SetLoadFields("Line No.");
- ProdOrderLine.SetRange(Status, ProductionOrder.Status);
- ProdOrderLine.SetRange("Prod. Order No.", ProductionOrder."No.");
- ProdOrderLine.SetRange("Item No.", PurchaseLine."No.");
- if ProdOrderLine.FindFirst() then
- PurchaseLine."Prod. Order Line No." := ProdOrderLine."Line No.";
- end;
-
- ///
- /// Updates purchase line with routing information
- ///
- local procedure UpdatePurchLineWithRoutingInfo(var PurchaseLine: Record "Purchase Line"; var ProdOrderLine: Record "Prod. Order Line")
- var
- ProdOrderRoutingLine: Record "Prod. Order Routing Line";
- WorkCenter: Record "Work Center";
- begin
- if not FindRoutingLinesForProdOrderLine(ProdOrderRoutingLine, ProdOrderLine) then
- exit;
-
- if FindMatchingWorkCenterForVendor(ProdOrderRoutingLine, WorkCenter, PurchaseLine."Buy-from Vendor No.") or
- FindAnySubcontractorWorkCenter(ProdOrderRoutingLine, WorkCenter) then begin
- UpdatePurchLineFromRoutingLine(PurchaseLine, ProdOrderRoutingLine);
- exit;
- end;
-
- ProdOrderRoutingLine.FindFirst();
- UpdatePurchLineFromRoutingLine(PurchaseLine, ProdOrderRoutingLine);
- end;
-
- ///
- /// Finds routing lines for production order line
- ///
- local procedure FindRoutingLinesForProdOrderLine(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var ProdOrderLine: Record "Prod. Order Line"): Boolean
- begin
- ProdOrderRoutingLine.SetLoadFields("Work Center No.", "Operation No.", Description, "Description 2", "Routing No.", "Routing Reference No.");
- ProdOrderRoutingLine.SetRange(Status, ProdOrderLine.Status);
- ProdOrderRoutingLine.SetRange("Prod. Order No.", ProdOrderLine."Prod. Order No.");
- ProdOrderRoutingLine.SetRange("Routing No.", ProdOrderLine."Routing No.");
- ProdOrderRoutingLine.SetRange("Routing Reference No.", ProdOrderLine."Line No.");
- ProdOrderRoutingLine.SetRange(Type, "Capacity Type"::"Work Center");
- exit(not ProdOrderRoutingLine.IsEmpty());
- end;
-
- ///
- /// Finds work center matching specific vendor
- ///
- local procedure FindMatchingWorkCenterForVendor(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var WorkCenter: Record "Work Center"; VendorNo: Code[20]): Boolean
- begin
- if ProdOrderRoutingLine.FindSet() then
- repeat
- WorkCenter.SetLoadFields("Gen. Prod. Posting Group");
- WorkCenter.SetRange("No.", ProdOrderRoutingLine."Work Center No.");
- WorkCenter.SetRange("Subcontractor No.", VendorNo);
- if WorkCenter.FindFirst() then
- exit(true);
- until ProdOrderRoutingLine.Next() = 0;
- exit(false);
- end;
-
- ///
- /// Finds any work center with subcontractor
- ///
- local procedure FindAnySubcontractorWorkCenter(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var WorkCenter: Record "Work Center"): Boolean
- begin
- ProdOrderRoutingLine.FindSet();
- repeat
- WorkCenter.SetLoadFields("Gen. Prod. Posting Group");
- WorkCenter.SetRange("No.", ProdOrderRoutingLine."Work Center No.");
- WorkCenter.SetFilter("Subcontractor No.", '<>%1', '');
- if WorkCenter.FindFirst() then
- exit(true);
- until ProdOrderRoutingLine.Next() = 0;
- exit(false);
- end;
-
- local procedure UpdatePurchLineFromRoutingLine(var PurchaseLine: Record "Purchase Line"; ProdOrderRoutingLine: Record "Prod. Order Routing Line")
- var
- SubcPriceManagement: Codeunit "Subc. Price Management";
- begin
- PurchaseLine.Description := ProdOrderRoutingLine.Description;
- PurchaseLine."Description 2" := ProdOrderRoutingLine."Description 2";
- PurchaseLine."Routing No." := ProdOrderRoutingLine."Routing No.";
- PurchaseLine."Routing Reference No." := ProdOrderRoutingLine."Routing Reference No.";
- PurchaseLine."Operation No." := ProdOrderRoutingLine."Operation No.";
- PurchaseLine."Expected Receipt Date" := ProdOrderRoutingLine."Ending Date";
- PurchaseLine.Validate("Work Center No.", ProdOrderRoutingLine."Work Center No.");
-
- SubcPriceManagement.GetSubcPriceForPurchLine(PurchaseLine);
- PurchaseLine.GetItemTranslation();
- end;
-
- ///
- /// Transfers reservation entries
- ///
- local procedure TransferReservationEntryFromPurchOrderCompToProdOrderLine(PurchaseLine: Record "Purchase Line"; ProductionOrder: Record "Production Order")
- var
- ProdOrderLine: Record "Prod. Order Line";
- TempReservationEntry: Record "Reservation Entry" temporary;
- PurchLineReserve: Codeunit "Purch. Line-Reserve";
- begin
- if not FindProdOrderLineForReservation(ProdOrderLine, ProductionOrder, PurchaseLine."No.") then
- exit;
-
- CollectReservationEntries(PurchaseLine, TempReservationEntry, PurchLineReserve);
- ReassignReservationEntries(ProdOrderLine, TempReservationEntry);
- end;
-
- ///
- /// Finds production order line for reservation transfer
- ///
- local procedure FindProdOrderLineForReservation(var ProdOrderLine: Record "Prod. Order Line"; ProductionOrder: Record "Production Order"; ItemNo: Code[20]): Boolean
- begin
- ProdOrderLine.SetLoadFields("Line No.");
- ProdOrderLine.SetRange(Status, "Production Order Status"::Released);
- ProdOrderLine.SetRange("Prod. Order No.", ProductionOrder."No.");
- ProdOrderLine.SetRange("Item No.", ItemNo);
- exit(ProdOrderLine.FindFirst());
- end;
-
- ///
- /// Collects reservation entries into temporary table
- ///
- local procedure CollectReservationEntries(PurchaseLine: Record "Purchase Line"; var TempReservationEntry: Record "Reservation Entry" temporary; var PurchLineReserve: Codeunit "Purch. Line-Reserve")
- var
- ReservationEntry: Record "Reservation Entry";
- begin
- PurchLineReserve.FindReservEntry(PurchaseLine, ReservationEntry);
- if ReservationEntry.FindSet() then begin
- repeat
- TempReservationEntry := ReservationEntry;
- TempReservationEntry.Insert();
- until ReservationEntry.Next() = 0;
- ReservationEntry.DeleteAll();
- end;
- end;
-
- ///
- /// Reassigns reservation entries to production order line
- ///
- local procedure ReassignReservationEntries(ProdOrderLine: Record "Prod. Order Line"; var TempReservationEntry: Record "Reservation Entry" temporary)
- begin
- if TempReservationEntry.FindSet() then
- repeat
- ReassignSingleReservationEntry(ProdOrderLine, TempReservationEntry);
- until TempReservationEntry.Next() = 0;
- end;
-
- local procedure ReassignSingleReservationEntry(ProdOrderLine: Record "Prod. Order Line"; var TempReservationEntry: Record "Reservation Entry" temporary)
- var
- ReservationEntry2: Record "Reservation Entry";
- begin
- ReservationEntry2 := TempReservationEntry;
- ReservationEntry2."Source Type" := Database::"Prod. Order Line";
- ReservationEntry2."Source Subtype" := ProdOrderLine.Status.AsInteger();
- ReservationEntry2."Source ID" := ProdOrderLine."Prod. Order No.";
- ReservationEntry2."Source Ref. No." := 0;
- ReservationEntry2."Source Batch Name" := '';
- ReservationEntry2."Source Prod. Order Line" := ProdOrderLine."Line No.";
- ReservationEntry2.Insert();
- end;
-
- local procedure HandleSubcontractingAfterUpdate(var PurchaseLine: Record "Purchase Line")
- var
- RequisitionLine: Record "Requisition Line";
- SubcPurchaseOrderCreator: Codeunit "Subc. Purchase Order Creator";
- SubcontractingManagementExt: Codeunit "Subcontracting Management Ext.";
- NextLineNo: Integer;
- begin
- RequisitionLine."Prod. Order No." := PurchaseLine."Prod. Order No.";
- RequisitionLine."Prod. Order Line No." := PurchaseLine."Prod. Order Line No.";
- RequisitionLine."Operation No." := PurchaseLine."Operation No.";
- RequisitionLine."Routing No." := PurchaseLine."Routing No.";
- RequisitionLine."Routing Reference No." := PurchaseLine."Routing Reference No.";
-
- NextLineNo := PurchaseLine."Line No." + 10000;
- BindSubscription(SubcontractingManagementExt);
- SubcPurchaseOrderCreator.TransferSubcontractingProdOrderComp(PurchaseLine, RequisitionLine, NextLineNo);
- UnbindSubscription(SubcontractingManagementExt);
- end;
-
- ///
- /// Validates mandatory fields
- ///
- local procedure ValidateMandatoryFields(PurchaseLine: Record "Purchase Line")
- var
- Vendor: Record Vendor;
- begin
- GetManufacturingSetupCached();
- ManufacturingSetup.TestField("Rtng. Link Code Purch. Prov.");
- ManufacturingSetup.TestField("Subc. Default Comp. Location");
-
- ManufacturingSetup.TestField("Released Order Nos.");
- ManufacturingSetup.TestField("Production BOM Nos.");
- ManufacturingSetup.TestField("Routing Nos.");
-
- GetSubManagementSetupCached();
- SubcManagementSetup.TestField("Preset Component Item No.");
- SubcManagementSetup.TestField("Common Work Center No.");
-
- Vendor.Get(PurchaseLine."Buy-from Vendor No.");
- Vendor.TestField("Subcontr. Location Code");
-
- PurchaseLine.TestField(Type, "Purchase Line Type"::Item);
- PurchaseLine.TestField("Prod. Order No.", '');
- PurchaseLine.TestField("Prod. Order Line No.", 0);
- PurchaseLine.TestField(Quantity);
- PurchaseLine.TestField("Location Code");
- PurchaseLine.TestField("Expected Receipt Date");
- PurchaseLine.TestField("Qty. Assigned", 0);
- PurchaseLine.TestField("Qty. Rcd. Not Invoiced", 0);
- PurchaseLine.TestField("Drop Shipment", false);
- PurchaseLine.TestField("Special Order", false);
-
- PurchaseLine.TestStatusOpen();
- end;
-
- ///
- /// Gets Sub Management Setup with caching
- ///
- local procedure GetSubManagementSetupCached()
- begin
- if HasSubManagementSetup then
- exit;
- if SubcManagementSetup.Get() then
- HasSubManagementSetup := true;
- end;
-
- ///
- /// Gets Manufacturing Setup with caching
- ///
- local procedure GetManufacturingSetupCached()
- begin
- if HasManufacturingSetup then
- exit;
- if ManufacturingSetup.Get() then
- HasManufacturingSetup := true;
- end;
-
- ///
- /// Updates item with BOM and routing from temporary data
- ///
- local procedure UpdateItemWithBOMAndRoutingFromTemp(var PurchaseLine: Record "Purchase Line")
- var
- SkipProcessBOMAndRouting: Boolean;
- begin
- SkipProcessBOMAndRouting := CheckCreateProdOrderCompRtng() and (GlobalSubcRtngBOMSourceType = "Subc. RtngBOMSourceType"::Empty);
- if SkipProcessBOMAndRouting then
- exit;
-
- ProcessBOMAndRoutingData(PurchaseLine."No.");
- end;
-
- ///
- /// Processes BOM and routing data
- ///
- local procedure ProcessBOMAndRoutingData(ItemNo: Code[20])
- var
- TempProductionBOMHeader: Record "Production BOM Header" temporary;
- TempProductionBOMLine: Record "Production BOM Line" temporary;
- TempRoutingHeader: Record "Routing Header" temporary;
- TempRoutingLine: Record "Routing Line" temporary;
- BOMNo, BOMVersionCode, RoutingNo, RoutingVersionCode : Code[20];
- begin
- GetTemporaryBOMAndRoutingData(TempProductionBOMHeader, TempProductionBOMLine, TempRoutingHeader, TempRoutingLine);
- GetBOMAndRoutingInfoFromTempData(BOMNo, BOMVersionCode, RoutingNo, RoutingVersionCode);
-
- if BOMVersionCode = '' then
- CreateBOMIfNotExists(TempProductionBOMHeader, TempProductionBOMLine, BOMNo)
- else
- SaveBOMVersionIfRequired(TempProductionBOMHeader, TempProductionBOMLine, BOMNo, BOMVersionCode);
-
- if RoutingVersionCode = '' then
- CreateRoutingIfNotExists(TempRoutingHeader, TempRoutingLine, RoutingNo)
- else
- SaveRoutingVersionIfRequired(TempRoutingHeader, TempRoutingLine, RoutingNo, RoutingVersionCode);
-
- UpdateSourceWithBOMRoutingNumbers(ItemNo, BOMNo, RoutingNo);
- end;
-
- ///
- /// Gets temporary BOM and routing data
- ///
- local procedure GetTemporaryBOMAndRoutingData(var TempProductionBOMHeader: Record "Production BOM Header" temporary; var TempProductionBOMLine: Record "Production BOM Line" temporary; var TempRoutingHeader: Record "Routing Header" temporary; var TempRoutingLine: Record "Routing Line" temporary)
- begin
- SubcTempDataInitializer.GetGlobalBOMHeader(TempProductionBOMHeader);
- SubcTempDataInitializer.GetGlobalBOMLines(TempProductionBOMLine);
- SubcTempDataInitializer.GetGlobalRoutingHeader(TempRoutingHeader);
- SubcTempDataInitializer.GetGlobalRoutingLines(TempRoutingLine);
- end;
-
- ///
- /// Saves BOM version if required
- ///
- local procedure SaveBOMVersionIfRequired(var TempProductionBOMHeader: Record "Production BOM Header" temporary; var TempProductionBOMLine: Record "Production BOM Line" temporary; BomNo: Code[20]; BOMVersionCode: Code[20])
- var
- ProductionBOMLine: Record "Production BOM Line";
- ProductionBOMVersion: Record "Production BOM Version";
- NoSeries: Codeunit "No. Series";
- NewBOMVersionCode: Code[20];
- begin
- if BOMVersionCode = '' then
- exit;
-
- if SubcVersionMgmt.CheckBOMExists(BomNo, BOMVersionCode) then
- exit;
-
- NewBOMVersionCode := NoSeries.GetNextNo(SubcVersionMgmt.GetBOMVersionNoSeries(BomNo));
- SubcTempDataInitializer.UpdateBOMVersionCode(NewBOMVersionCode);
-
- ProductionBOMVersion.Init();
- ProductionBOMVersion."Production BOM No." := BomNo;
- ProductionBOMVersion."Version Code" := NewBOMVersionCode;
- ProductionBOMVersion.Status := "BOM Status"::Certified;
- ProductionBOMVersion.Description := TempProductionBOMHeader.Description;
- ProductionBOMVersion."Unit of Measure Code" := TempProductionBOMHeader."Unit of Measure Code";
- ProductionBOMVersion."Starting Date" := WorkDate();
- ProductionBOMVersion.Status := TempProductionBOMHeader.Status;
- ProductionBOMVersion.Insert(true);
- BOMVersionCreated := true;
-
- if TempProductionBOMLine.FindSet() then
- repeat
- ProductionBOMLine := TempProductionBOMLine;
- ProductionBOMLine.Insert(true);
- until TempProductionBOMLine.Next() = 0;
- ProductionBOMVersion.Validate(Status, "BOM Status"::Certified);
- ProductionBOMVersion.Modify(true);
-
- end;
-
- ///
- /// Saves routing version if required
- ///
- local procedure SaveRoutingVersionIfRequired(var TempRoutingHeader: Record "Routing Header" temporary; var TempRoutingLine: Record "Routing Line" temporary; RoutingNo: Code[20]; RoutingVersionCode: Code[20])
- var
- RoutingLine: Record "Routing Line";
- RoutingVersion: Record "Routing Version";
- NoSeries: Codeunit "No. Series";
- NewRoutingVersionCode: Code[20];
- begin
- if SubcVersionMgmt.CheckRoutingExists(RoutingNo, RoutingVersionCode) then
- exit;
-
- NewRoutingVersionCode := NoSeries.GetNextNo(SubcVersionMgmt.GetRoutingVersionNoSeries(RoutingNo));
- SubcTempDataInitializer.UpdateRoutingVersionCode(NewRoutingVersionCode);
-
- RoutingVersion.Init();
- RoutingVersion."Routing No." := RoutingNo;
- RoutingVersion."Version Code" := NewRoutingVersionCode;
- RoutingVersion.Description := TempRoutingHeader.Description;
- RoutingVersion."Starting Date" := WorkDate();
- RoutingVersion.Status := TempRoutingHeader.Status;
- RoutingVersion.Insert(true);
- RoutingVersionCreated := true;
-
- if TempRoutingLine.FindSet() then
- repeat
- RoutingLine := TempRoutingLine;
- RoutingLine.Insert(true);
- until TempRoutingLine.Next() = 0;
- RoutingVersion.Validate(Status, "Routing Status"::Certified);
- RoutingVersion.Modify(true);
- end;
-
- ///
- /// Creates BOM if it doesn't exist
- ///
- local procedure CreateBOMIfNotExists(var TempProductionBOMHeader: Record "Production BOM Header" temporary; var TempProductionBOMLine: Record "Production BOM Line" temporary; var BOMNo: Code[20])
- var
- ProductionBOMHeader: Record "Production BOM Header";
- ProductionBOMLine: Record "Production BOM Line";
- NoSeries: Codeunit "No. Series";
- begin
- if SubcVersionMgmt.CheckBOMExists(BOMNo, '') then
- exit;
-
- GetManufacturingSetupCached();
- BOMNo := NoSeries.GetNextNo(ManufacturingSetup."Production BOM Nos.");
-
- ProductionBOMHeader.Init();
- ProductionBOMHeader."No." := BOMNo;
- ProductionBOMHeader.Description := TempProductionBOMHeader.Description;
- ProductionBOMHeader."Description 2" := TempProductionBOMHeader."Description 2";
- ProductionBOMHeader.Validate("Unit of Measure Code", TempProductionBOMHeader."Unit of Measure Code");
- ProductionBOMHeader.Insert(true);
- BOMCreated := true;
-
- if TempProductionBOMLine.FindSet() then
- repeat
- ProductionBOMLine := TempProductionBOMLine;
- ProductionBOMLine."Production BOM No." := BOMNo;
- ProductionBOMLine."Version Code" := '';
- ProductionBOMLine.Insert(true);
- until TempProductionBOMLine.Next() = 0;
- ProductionBOMHeader.Status := "BOM Status"::Certified;
- ProductionBOMHeader.Modify(true);
- SubcTempDataInitializer.LoadBOMLines(BOMNo, '');
- end;
-
- ///
- /// Checks if BOM and routing exist and if the production components or routing have to be created out of the temporary data.
- ///
- ///
- local procedure CheckCreateProdOrderCompRtng(): Boolean
- var
- TempProductionBOMLine: Record "Production BOM Line" temporary;
- TempRoutingLine: Record "Routing Line" temporary;
- BOMRoutingExists: Boolean;
- begin
- SubcTempDataInitializer.GetGlobalBOMLines(TempProductionBOMLine);
- SubcTempDataInitializer.GetGlobalRoutingLines(TempRoutingLine);
-
- BOMRoutingExists := SubcVersionMgmt.CheckBOMExists(TempProductionBOMLine."Production BOM No.", '') and SubcVersionMgmt.CheckRoutingExists(TempRoutingLine."Routing No.", '');
- exit(not BOMRoutingExists or ProdCompRoutingModified);
- end;
- ///
- /// Creates routing if it doesn't exist
- ///
- local procedure CreateRoutingIfNotExists(var TempRoutingHeader: Record "Routing Header" temporary; var TempRoutingLine: Record "Routing Line" temporary; var RoutingNo: Code[20])
- var
- RoutingHeader: Record "Routing Header";
- RoutingLine: Record "Routing Line";
- NoSeries: Codeunit "No. Series";
- begin
- if not TempRoutingHeader.FindFirst() then
- exit;
-
- if SubcVersionMgmt.CheckRoutingExists(RoutingNo, '') then
- exit;
-
- GetManufacturingSetupCached();
- RoutingNo := NoSeries.GetNextNo(ManufacturingSetup."Routing Nos.");
-
- RoutingHeader.Init();
- RoutingHeader."No." := RoutingNo;
- RoutingHeader.Description := TempRoutingHeader.Description;
- RoutingHeader."Description 2" := TempRoutingHeader."Description 2";
- RoutingHeader.Insert(true);
- RoutingCreated := true;
-
- if TempRoutingLine.FindSet() then
- repeat
- RoutingLine := TempRoutingLine;
- RoutingLine."Routing No." := RoutingNo;
- RoutingLine."Version Code" := '';
- RoutingLine.Insert(true);
- until TempRoutingLine.Next() = 0;
-
- RoutingHeader.Validate(Status, "Routing Status"::Certified);
- RoutingHeader.Modify(true);
- SubcTempDataInitializer.LoadRoutingLines(RoutingNo, '');
- end;
-
- ///
- /// Updates item or stockkeeping unit with BOM and routing numbers based on SubcRtngBOMSourceType
- ///
- local procedure UpdateSourceWithBOMRoutingNumbers(ItemNo: Code[20]; BOMNo: Code[20]; RoutingNo: Code[20])
- var
- Item: Record Item;
- StockkeepingUnit: Record "Stockkeeping Unit";
- LocationCode: Code[10];
- VariantCode: Code[10];
- begin
- case GlobalSubcRtngBOMSourceType of
- GlobalSubcRtngBOMSourceType::Item:
-
- if Item.Get(ItemNo) and ((Item."Production BOM No." <> BOMNo) or (Item."Routing No." <> RoutingNo)) then begin
- Item."Production BOM No." := BOMNo;
- Item."Routing No." := RoutingNo;
- Item.Modify(true);
- end;
- GlobalSubcRtngBOMSourceType::StockkeepingUnit:
- begin
- GetLocationAndVariantForStockkeepingUnit(LocationCode, VariantCode);
- if StockkeepingUnit.Get(LocationCode, ItemNo, VariantCode) then begin
- if (StockkeepingUnit."Production BOM No." <> BOMNo) or (StockkeepingUnit."Routing No." <> RoutingNo) then begin
- StockkeepingUnit."Production BOM No." := BOMNo;
- StockkeepingUnit."Routing No." := RoutingNo;
- StockkeepingUnit.Modify(true);
- end;
- end else
- CreateStockkeepingUnitWithBOMRouting(LocationCode, ItemNo, VariantCode, BOMNo, RoutingNo);
- end;
- end;
- end;
-
- ///
- /// Gets location and variant codes for stockkeeping unit operations
- ///
- local procedure GetLocationAndVariantForStockkeepingUnit(var LocationCode: Code[10]; var VariantCode: Code[10])
- var
- TempPurchaseLine: Record "Purchase Line" temporary;
- begin
- SubcTempDataInitializer.GetGlobalPurchLine(TempPurchaseLine);
- if TempPurchaseLine.FindFirst() then begin
- LocationCode := TempPurchaseLine."Location Code";
- VariantCode := TempPurchaseLine."Variant Code";
- end;
- end;
-
- ///
- /// Creates a new stockkeeping unit with BOM and routing information
- ///
- local procedure CreateStockkeepingUnitWithBOMRouting(LocationCode: Code[10]; ItemNo: Code[20]; VariantCode: Code[10]; BOMNo: Code[20]; RoutingNo: Code[20])
- var
- StockkeepingUnit: Record "Stockkeeping Unit";
- begin
- StockkeepingUnit.Init();
- StockkeepingUnit."Location Code" := LocationCode;
- StockkeepingUnit."Item No." := ItemNo;
- StockkeepingUnit."Variant Code" := VariantCode;
- StockkeepingUnit."Production BOM No." := BOMNo;
- StockkeepingUnit."Routing No." := RoutingNo;
- StockkeepingUnit.Insert(true);
-
- end;
-
- ///
- /// Cleans up temporary BOM and routing if not needed
- ///
- local procedure CleanupTemporaryBOMAndRoutingIfNotNeeded()
- var
- BOMNo, BOMVersionCode, RoutingNo, RoutingVersionCode : Code[20];
- begin
- GetSubManagementSetupCached();
- GetBOMAndRoutingInfoFromTempData(BOMNo, BOMVersionCode, RoutingNo, RoutingVersionCode);
-
- if (GlobalSubcRtngBOMSourceType = GlobalSubcRtngBOMSourceType::Empty) then begin
- DeleteCreatedBOMIfExists(BOMNo);
- DeleteCreatedRoutingIfExists(RoutingNo);
-
- if not SubcManagementSetup."Always Save Modified Versions" then begin
- DeleteCreatedBOMVersionIfExists(BOMNo, BOMVersionCode);
- DeleteCreatedRoutingVersionIfExists(RoutingNo, RoutingVersionCode);
- end;
- end;
- end;
-
- local procedure DeleteCreatedBOMIfExists(BOMNo: Code[20])
- var
- ProductionBOMHeader: Record "Production BOM Header";
- begin
- if not BOMCreated then
- exit;
-
- if BOMNo = '' then
- exit;
-
- if ProductionBOMHeader.Get(BOMNo) then begin
- ProductionBOMHeader.Validate(Status, "BOM Status"::"Under Development");
- ProductionBOMHeader.Modify(true);
- ProductionBOMHeader.Delete(true);
- end;
- end;
-
- local procedure DeleteCreatedRoutingIfExists(RoutingNo: Code[20])
- var
- RoutingHeader: Record "Routing Header";
- begin
- if not RoutingCreated then
- exit;
-
- if RoutingNo = '' then
- exit;
-
- if RoutingHeader.Get(RoutingNo) then begin
- RoutingHeader.Validate(Status, "Routing Status"::"Under Development");
- RoutingHeader.Modify(true);
- RoutingHeader.Delete(true);
- end;
- end;
-
- local procedure DeleteCreatedBOMVersionIfExists(BOMNo: Code[20]; BOMVersionCode: Code[20])
- var
- ProductionBOMVersion: Record "Production BOM Version";
- begin
- if not BOMVersionCreated then
- exit;
-
- if (BOMNo = '') or (BOMVersionCode = '') then
- exit;
-
- if ProductionBOMVersion.Get(BOMNo, BOMVersionCode) then begin
- ProductionBOMVersion.Validate(Status, "BOM Status"::"Under Development");
- ProductionBOMVersion.Modify();
- ProductionBOMVersion.Delete(true);
- end;
- end;
-
- local procedure DeleteCreatedRoutingVersionIfExists(RoutingNo: Code[20]; RoutingVersionCode: Code[20])
- var
- RoutingVersion: Record "Routing Version";
- begin
- if not RoutingVersionCreated then
- exit;
-
- if (RoutingNo = '') or (RoutingVersionCode = '') then
- exit;
-
- if RoutingVersion.Get(RoutingNo, RoutingVersionCode) then begin
- RoutingVersion.Validate(Status, "Routing Status"::"Under Development");
- RoutingVersion.Modify(true);
- RoutingVersion.Delete(true);
- end;
- end;
-
- ///
- /// Refreshes production order after update
- ///
- local procedure RefreshProductionOrderAfterUpdate(var ProductionOrder: Record "Production Order"; NewDirection: Option; CalcRoutings: Boolean; CalcComponents: Boolean; DeleteRelations: Boolean)
- var
- ProdOrderLine: Record "Prod. Order Line";
- CalculateProdOrder: Codeunit "Calculate Prod. Order";
- begin
- ProdOrderLine.SetLoadFields("Prod. Order No.", Status);
- ProdOrderLine.SetRange("Prod. Order No.", ProductionOrder."No.");
- ProdOrderLine.SetRange(Status, ProductionOrder.Status);
- if not ProdOrderLine.FindFirst() then
- exit;
- CalculateProdOrder.Calculate(ProdOrderLine, NewDirection, CalcRoutings, CalcComponents, DeleteRelations, true);
- end;
-
- ///
- /// Creates production order line from temporary data
- ///
- local procedure CreateProdOrderLineFromTemp(var ProdOrderLine: Record "Prod. Order Line"; ProductionOrder: Record "Production Order"; TempProdOrderLine: Record "Prod. Order Line" temporary)
- var
- Item: Record Item;
- CalculateProdOrder: Codeunit "Calculate Prod. Order";
- BOMNo, BOMVersionCode, RoutingNo, RoutingVersionCode : Code[20];
- begin
- GetBOMAndRoutingInfoFromTempData(BOMNo, BOMVersionCode, RoutingNo, RoutingVersionCode);
-
- ProdOrderLine.Init();
- ProdOrderLine.SetIgnoreErrors();
- ProdOrderLine.Status := ProductionOrder.Status;
- ProdOrderLine."Prod. Order No." := ProductionOrder."No.";
- ProdOrderLine."Line No." := TempProdOrderLine."Line No.";
- ProdOrderLine."Routing Reference No." := ProdOrderLine."Line No.";
-
- ProdOrderLine.Validate("Item No.", ProductionOrder."Source No.");
- ProdOrderLine."Location Code" := ProductionOrder."Location Code";
- ProdOrderLine.Validate("Variant Code", ProductionOrder."Variant Code");
-
- if not CheckCreateProdOrderCompRtng() then begin
- if BOMNo <> '' then begin
- ProdOrderLine.Validate("Production BOM No.", BOMNo);
- ProdOrderLine.Validate("Production BOM Version Code", BOMVersionCode);
- end;
-
- if RoutingNo <> '' then begin
- ProdOrderLine.Validate("Routing No.", RoutingNo);
- ProdOrderLine.Validate("Routing Version Code", RoutingVersionCode);
- end;
- end else
- ProdOrderLine."Routing No." := TempProdOrderLine."Routing No.";
-
- if ProductionOrder."Bin Code" <> '' then
- ProdOrderLine.Validate("Bin Code", ProductionOrder."Bin Code")
- else
- CalculateProdOrder.SetProdOrderLineBinCodeFromRoute(ProdOrderLine, ProdOrderLine."Location Code", ProdOrderLine."Routing No.");
-
- Item.SetLoadFields("Scrap %", "Inventory Posting Group");
- Item.Get(ProductionOrder."Source No.");
- ProdOrderLine."Scrap %" := Item."Scrap %";
-
- ProdOrderLine."Due Date" := ProductionOrder."Due Date";
- ProdOrderLine."Starting Date-Time" := ProductionOrder."Starting Date-Time";
- ProdOrderLine."Ending Date-Time" := ProductionOrder."Ending Date-Time";
- ProdOrderLine."Planning Level Code" := 0;
- ProdOrderLine."Inventory Posting Group" := Item."Inventory Posting Group";
- ProdOrderLine.UpdateDatetime();
- ProdOrderLine.Validate("Unit Cost");
-
- ProdOrderLine.Description := ProductionOrder.Description;
- ProdOrderLine."Description 2" := ProductionOrder."Description 2";
- ProdOrderLine.Validate(Quantity, ProductionOrder.Quantity);
- ProdOrderLine.UpdateDatetime();
- ProdOrderLine.Insert();
- end;
-
- ///
- /// Gets BOM and routing information from temporary data
- ///
- local procedure GetBOMAndRoutingInfoFromTempData(var BOMNo: Code[20]; var BOMVersionCode: Code[20]; var RoutingNo: Code[20]; var RoutingVersionCode: Code[20])
- var
- TempProductionBOMLine: Record "Production BOM Line" temporary;
- TempRoutingLine: Record "Routing Line" temporary;
- begin
- SubcTempDataInitializer.GetGlobalRoutingLines(TempRoutingLine);
- SubcTempDataInitializer.GetGlobalBOMLines(TempProductionBOMLine);
-
- if TempRoutingLine.FindFirst() then begin
- RoutingNo := TempRoutingLine."Routing No.";
- RoutingVersionCode := TempRoutingLine."Version Code";
- end;
-
- if TempProductionBOMLine.FindFirst() then begin
- BOMNo := TempProductionBOMLine."Production BOM No.";
- BOMVersionCode := TempProductionBOMLine."Version Code";
- end;
- end;
-
- ///
- /// Creates production order component from temporary data
- ///
- local procedure CreateProdOrderComponentFromTemp(var ProdOrderComponent: Record "Prod. Order Component"; TempProdOrderComponent: Record "Prod. Order Component" temporary; var ProdOrderLine: Record "Prod. Order Line")
- begin
- GetSubManagementSetupCached();
-
- ProdOrderComponent.Init();
- ProdOrderComponent.Validate(Status, ProdOrderLine.Status);
- ProdOrderComponent.Validate("Prod. Order No.", ProdOrderLine."Prod. Order No.");
- ProdOrderComponent.Validate("Prod. Order Line No.", ProdOrderLine."Line No.");
- ProdOrderComponent.Validate("Line No.", TempProdOrderComponent."Line No.");
- ProdOrderComponent.Insert(true);
-
- ProdOrderComponent.Validate("Item No.", TempProdOrderComponent."Item No.");
- ProdOrderComponent.Validate("Variant Code", TempProdOrderComponent."Variant Code");
- ProdOrderComponent.Description := TempProdOrderComponent.Description;
- ProdOrderComponent."Description 2" := TempProdOrderComponent."Description 2";
- ProdOrderComponent.Validate("Quantity per", TempProdOrderComponent."Quantity per");
- ProdOrderComponent.Validate("Unit of Measure Code", TempProdOrderComponent."Unit of Measure Code");
- ProdOrderComponent.Validate("Location Code", TempProdOrderComponent."Location Code");
- if ProdOrderComponent."Bin Code" <> '' then
- ProdOrderComponent.Validate("Bin Code", TempProdOrderComponent."Bin Code");
- ProdOrderComponent."Routing Link Code" := TempProdOrderComponent."Routing Link Code";
- ProdOrderComponent."Flushing Method" := TempProdOrderComponent."Flushing Method";
- ProdOrderComponent."Subcontracting Type" := TempProdOrderComponent."Subcontracting Type";
- ProdOrderComponent."Orig. Location Code" := TempProdOrderComponent."Orig. Location Code";
- ProdOrderComponent."Orig. Bin Code" := TempProdOrderComponent."Orig. Bin Code";
- ProdOrderComponent."Subcontracting Type" := TempProdOrderComponent."Subcontracting Type";
- ProdOrderComponent.Modify(true);
- end;
-
- ///
- /// Creates production order routing line from temporary data
- ///
- local procedure CreateProdOrderRoutingLineFromTemp(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary; var ProdOrderLine: Record "Prod. Order Line")
- begin
- ProdOrderRoutingLine.Init();
- ProdOrderRoutingLine.Validate(Status, ProdOrderLine.Status);
- ProdOrderRoutingLine.Validate("Prod. Order No.", ProdOrderLine."Prod. Order No.");
- ProdOrderRoutingLine.Validate("Routing Reference No.", ProdOrderLine."Line No.");
- ProdOrderRoutingLine."Routing No." := ProdOrderLine."Routing No.";
- ProdOrderRoutingLine.Validate("Operation No.", TempProdOrderRoutingLine."Operation No.");
- ProdOrderRoutingLine.Insert(true);
-
- ProdOrderRoutingLine."Vendor No. Subc. Price" := TempProdOrderRoutingLine."Vendor No. Subc. Price";
- ProdOrderRoutingLine.Validate(Type, TempProdOrderRoutingLine.Type);
- ProdOrderRoutingLine.Validate("No.", TempProdOrderRoutingLine."No.");
- ProdOrderRoutingLine.Description := TempProdOrderRoutingLine.Description;
- ProdOrderRoutingLine."Description 2" := TempProdOrderRoutingLine."Description 2";
- ProdOrderRoutingLine."Setup Time" := TempProdOrderRoutingLine."Setup Time";
- ProdOrderRoutingLine."Run Time" := TempProdOrderRoutingLine."Run Time";
- ProdOrderRoutingLine."Wait Time" := TempProdOrderRoutingLine."Wait Time";
- ProdOrderRoutingLine."Move Time" := TempProdOrderRoutingLine."Move Time";
- ProdOrderRoutingLine."Ending Date" := TempProdOrderRoutingLine."Ending Date";
- ProdOrderRoutingLine."Ending Time" := TempProdOrderRoutingLine."Ending Time";
- ProdOrderRoutingLine.UpdateDatetime();
- ProdOrderRoutingLine."Routing Link Code" := TempProdOrderRoutingLine."Routing Link Code";
- ProdOrderRoutingLine.Modify(true);
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcProdOrderCreateBind.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcProdOrderCreateBind.Codeunit.al
deleted file mode 100644
index aa1f5a0b59..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcProdOrderCreateBind.Codeunit.al
+++ /dev/null
@@ -1,69 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.ProductionBOM;
-using Microsoft.Manufacturing.Setup;
-using Microsoft.Purchases.Document;
-using Microsoft.Purchases.Vendor;
-
-codeunit 99001555 "Subc. ProdOrderCreateBind"
-{
- EventSubscriberInstance = Manual;
-
- var
- SubcontractingPurchaseLine: Record "Purchase Line";
-
- [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnBeforeCheckRoutingNoNotBlank, '', false, false)]
- local procedure "Prod. Order Routing Line_OnBeforeCheckRoutingNoNotBlank"(var IsHandled: Boolean)
- begin
- IsHandled := true;
- end;
-
- [EventSubscriber(ObjectType::Codeunit, Codeunit::"Subcontracting Management", OnBeforeGetSubcontractor, '', false, false)]
- local procedure OnBeforeGetSubcontractor(WorkCenterNo: Code[20]; var Vendor: Record Vendor; var HasSubcontractor: Boolean; var IsHandled: Boolean)
- begin
- GetSubcontractorForPurchaseProvision(Vendor, HasSubcontractor, IsHandled);
- end;
-
- [EventSubscriber(ObjectType::Codeunit, Codeunit::"Subc. Calc. Prod. Order Ext.", OnAfterTransferSubcontractingFieldsBOMComponent, '', false, false)]
- local procedure "Sub. Calc. Prod. Order Ext._OnAfterTransferSubcontractingFieldsBOMComponent"(var ProductionBOMLine: Record "Production BOM Line"; var ProdOrderComponent: Record "Prod. Order Component")
- begin
- TransferSubcontractingFieldsBOMComponentForPurchaseProvision(ProdOrderComponent);
- end;
-
- procedure SetSubcontractingPurchaseLine(PurchaseLine: Record "Purchase Line")
- begin
- SubcontractingPurchaseLine := PurchaseLine;
- end;
-
- local procedure TransferSubcontractingFieldsBOMComponentForPurchaseProvision(var ProdOrderComponent: Record "Prod. Order Component")
- var
- ManufacturingSetup: Record "Manufacturing Setup";
- SubcontractingManagement: Codeunit "Subcontracting Management";
- ComponentsLocationCode: Code[10];
- begin
- ManufacturingSetup.SetLoadFields("Rtng. Link Code Purch. Prov.");
- ManufacturingSetup.Get();
- if (ProdOrderComponent."Routing Link Code" <> ManufacturingSetup."Rtng. Link Code Purch. Prov.") or
- (ProdOrderComponent."Subcontracting Type" <> "Subcontracting Type"::Transfer) then
- exit;
-
- ComponentsLocationCode := SubcontractingManagement.GetComponentsLocationCode(SubcontractingPurchaseLine);
-
- ProdOrderComponent.Validate("Location Code", ComponentsLocationCode);
- ProdOrderComponent."Orig. Location Code" := '';
- end;
-
- local procedure GetSubcontractorForPurchaseProvision(var Vendor: Record Vendor; var HasSubcontractor: Boolean; var IsHandled: Boolean)
- begin
- if SubcontractingPurchaseLine."Buy-from Vendor No." = '' then
- exit;
- Vendor.Get(SubcontractingPurchaseLine."Buy-from Vendor No.");
- IsHandled := true;
- HasSubcontractor := true;
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcTempDataInitializer.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcTempDataInitializer.Codeunit.al
deleted file mode 100644
index a17a90e9ba..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcTempDataInitializer.Codeunit.al
+++ /dev/null
@@ -1,747 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Inventory.Item;
-using Microsoft.Inventory.Location;
-using Microsoft.Manufacturing.Capacity;
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.ProductionBOM;
-using Microsoft.Manufacturing.Routing;
-using Microsoft.Manufacturing.Setup;
-using Microsoft.Purchases.Document;
-using Microsoft.Purchases.Vendor;
-
-codeunit 99001552 "Subc. Temp Data Initializer"
-{
- var
- TempGlobalProdOrderComponent: Record "Prod. Order Component" temporary;
- TempGlobalProdOrderLine: Record "Prod. Order Line" temporary;
- TempGlobalProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- TempGlobalProductionBOMHeader: Record "Production BOM Header" temporary;
- TempGlobalProductionBOMLine: Record "Production BOM Line" temporary;
- TempGlobalProductionOrder: Record "Production Order" temporary;
- TempGlobalPurchaseLine: Record "Purchase Line" temporary;
- TempGlobalRoutingHeader: Record "Routing Header" temporary;
- TempGlobalRoutingLine: Record "Routing Line" temporary;
- TempGlobalVendor: Record Vendor temporary;
- ManufacturingSetup: Record "Manufacturing Setup";
- SubcManagementSetup: Record "Subc. Management Setup";
- SubcSessionState: Codeunit "Subc. Session State";
- SubcVersionMgmt: Codeunit "Subc. Version Mgmt.";
- HasManufacturingSetup: Boolean;
- HasSubcManagementSetup: Boolean;
- SubcRtngBOMSourceType: Enum "Subc. RtngBOMSourceType";
- TempProdOrderNoLbl: Label 'TEMP-%1', Locked = true, MaxLength = 20;
- BOMForLbl: Label 'BOM for %1', Comment = '%1 = Item description';
- TempBOMNoLbl: Label 'TEMP-BOM-%1', Locked = true, MaxLength = 20;
- RoutingForLbl: Label 'Routing for %1', Comment = '%1 = Item description';
- TempRoutingNoLbl: Label 'TEMP-RTNG-%1', Locked = true, MaxLength = 20;
- PutAwayOperationLbl: Label 'Put-Away Operation';
- SubcontractingOperationLbl: Label 'Subcontracting Operation';
-
- ///
- /// Initializes the temporary structure for production order processing based on a purchase line.
- ///
- /// The purchase line to base the temporary structure on.
- procedure InitializeTemporaryProdOrder(PurchaseLine: Record "Purchase Line")
- begin
- InitGlobalPurchLine(PurchaseLine);
- CreateTemporaryProductionOrder();
- CreateTemporaryProdOrderLine();
- ClearTemporaryProductionTables();
- end;
-
- ///
- /// Initializes the temporary structure for production order processing based on a purchase line.
- ///
- /// The purchase line to base the temporary structure on.
- procedure InitGlobalPurchLine(var PurchaseLine: Record "Purchase Line")
- begin
- TempGlobalPurchaseLine.Reset();
- TempGlobalPurchaseLine.DeleteAll();
- TempGlobalPurchaseLine := PurchaseLine;
- TempGlobalPurchaseLine.Insert();
- end;
-
- local procedure CreateTemporaryProductionOrder()
- begin
- TempGlobalProductionBOMLine.Reset();
- TempGlobalProductionBOMLine.DeleteAll();
- TempGlobalProductionOrder.Init();
- TempGlobalProductionOrder.Status := "Production Order Status"::Released;
- TempGlobalProductionOrder."No." := StrSubstNo(TempProdOrderNoLbl, CopyStr(Format(CreateGuid()), 2, 10));
- TempGlobalProductionOrder."Source Type" := "Prod. Order Source Type"::Item;
- TempGlobalProductionOrder."Source No." := TempGlobalPurchaseLine."No.";
- if TempGlobalPurchaseLine."Variant Code" <> '' then
- TempGlobalProductionOrder."Variant Code" := TempGlobalPurchaseLine."Variant Code";
- TempGlobalProductionOrder."Due Date" := TempGlobalPurchaseLine."Expected Receipt Date";
- TempGlobalProductionOrder.Quantity := TempGlobalPurchaseLine."Quantity (Base)";
- TempGlobalProductionOrder."Location Code" := TempGlobalPurchaseLine."Location Code";
- TempGlobalProductionOrder."Created from Purch. Order" := true;
- TempGlobalProductionOrder.Insert();
- end;
-
- local procedure CreateTemporaryProdOrderLine()
- var
- Item: Record Item;
- begin
- TempGlobalProdOrderLine.Init();
- TempGlobalProdOrderLine.Status := TempGlobalProductionOrder.Status;
- TempGlobalProdOrderLine."Prod. Order No." := TempGlobalProductionOrder."No.";
- TempGlobalProdOrderLine."Line No." := 10000;
- TempGlobalProdOrderLine."Routing Reference No." := TempGlobalProdOrderLine."Line No.";
- TempGlobalProdOrderLine."Item No." := TempGlobalProductionOrder."Source No.";
- TempGlobalProdOrderLine."Location Code" := TempGlobalProductionOrder."Location Code";
- TempGlobalProdOrderLine."Variant Code" := TempGlobalProductionOrder."Variant Code";
- TempGlobalProdOrderLine.Description := TempGlobalProductionOrder.Description;
- TempGlobalProdOrderLine."Description 2" := TempGlobalProductionOrder."Description 2";
- TempGlobalProdOrderLine.Quantity := TempGlobalProductionOrder.Quantity;
- TempGlobalProdOrderLine."Due Date" := TempGlobalProductionOrder."Due Date";
- TempGlobalProdOrderLine."Starting Date-Time" := TempGlobalProductionOrder."Starting Date-Time";
- TempGlobalProdOrderLine."Ending Date-Time" := TempGlobalProductionOrder."Ending Date-Time";
-
- Item.SetLoadFields("Scrap %", "Inventory Posting Group");
- Item.Get(TempGlobalProductionOrder."Source No.");
- TempGlobalProdOrderLine."Scrap %" := Item."Scrap %";
- TempGlobalProdOrderLine."Inventory Posting Group" := Item."Inventory Posting Group";
-
- GetManufacturingSetup();
-
- TempGlobalProdOrderLine.Insert();
- end;
-
- local procedure ClearTemporaryProductionTables()
- begin
- TempGlobalProdOrderComponent.Reset();
- TempGlobalProdOrderComponent.DeleteAll();
- TempGlobalProdOrderRoutingLine.Reset();
- TempGlobalProdOrderRoutingLine.DeleteAll();
- end;
-
- ///
- /// Initializes new temporary BOM information for items without existing BOM.
- ///
- procedure InitializeNewTemporaryBOMInformation()
- var
- Item: Record Item;
- BOMNo: Code[20];
- begin
- ClearBOMTables();
- GetManufacturingSetup();
-
- ManufacturingSetup.TestField("Production BOM Nos.");
-
- Item.SetLoadFields(Description, "Base Unit of Measure", "No.");
- if not Item.Get(TempGlobalPurchaseLine."No.") then
- exit;
-
- BOMNo := InitializeTemporaryBOMHeaderFromSetup(Item);
-
- InitializeTemporaryBOMLineFromSetup(BOMNo);
- end;
-
- local procedure InitializeTemporaryBOMHeaderFromSetup(Item: Record Item): Code[20]
- var
- BOMNo: Code[20];
- begin
- TempGlobalProductionBOMHeader.Init();
- BOMNo := StrSubstNo(TempBOMNoLbl, CopyStr(Format(CreateGuid()), 2, 10));
- TempGlobalProductionBOMHeader."No." := BOMNo;
- TempGlobalProductionBOMHeader.Description := CopyStr(StrSubstNo(BOMForLbl, Item.Description), 1, MaxStrLen(TempGlobalProductionBOMHeader.Description));
- TempGlobalProductionBOMHeader."Unit of Measure Code" := Item."Base Unit of Measure";
- TempGlobalProductionBOMHeader.Insert();
- exit(BOMNo);
- end;
-
- local procedure InitializeTemporaryBOMLineFromSetup(BOMNo: Code[20])
- begin
- GetManufacturingSetup();
- GetSubcManagementSetup();
- TempGlobalProductionBOMLine.Init();
- TempGlobalProductionBOMLine."Production BOM No." := BOMNo;
- TempGlobalProductionBOMLine."Line No." := 10000;
- TempGlobalProductionBOMLine."Type" := "Production BOM Line Type"::Item;
- TempGlobalProductionBOMLine.Validate("No.", SubcManagementSetup."Preset Component Item No.");
- TempGlobalProductionBOMLine."Quantity per" := 1;
- TempGlobalProductionBOMLine."Routing Link Code" := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
- TempGlobalProductionBOMLine."Subcontracting Type" := "Subcontracting Type"::InventoryByVendor;
- TempGlobalProductionBOMLine.Insert();
- end;
-
- ///
- /// Initializes new temporary routing information for items without existing routing.
- ///
- procedure InitializeNewTemporaryRoutingInformation()
- var
- Item: Record Item;
- RoutingNo: Code[20];
- WorkCenterNo: Code[20];
- begin
- ClearRoutingTables();
- GetManufacturingSetup();
- GetSubcManagementSetup();
-
- ManufacturingSetup.TestField("Routing Nos.");
-
- Item.SetLoadFields(Description, "Base Unit of Measure", "No.");
- Item.Get(TempGlobalPurchaseLine."No.");
-
- RoutingNo := InitializeTemporaryRoutingHeaderFromSetup(Item);
- WorkCenterNo := DetermineWorkCenter();
- InitializeTemporaryRoutingLinesFromSetup(RoutingNo, WorkCenterNo);
- TempGlobalProdOrderLine."Routing No." := RoutingNo;
- TempGlobalProdOrderLine.Modify();
- end;
-
- local procedure InitializeTemporaryRoutingHeaderFromSetup(Item: Record Item): Code[20]
- var
- RoutingNo: Code[20];
- begin
- TempGlobalRoutingHeader.Init();
- RoutingNo := StrSubstNo(TempRoutingNoLbl, CopyStr(Format(CreateGuid()), 2, 10));
- TempGlobalRoutingHeader."No." := RoutingNo;
- TempGlobalRoutingHeader.Description := CopyStr(StrSubstNo(RoutingForLbl, Item.Description), 1, MaxStrLen(TempGlobalRoutingHeader.Description));
- TempGlobalRoutingHeader.Insert();
- exit(RoutingNo);
- end;
-
- local procedure DetermineWorkCenter(): Code[20]
- var
- Vendor: Record Vendor;
- WorkCenterNo: Code[20];
- begin
- GetManufacturingSetup();
- Vendor.SetLoadFields("Work Center No.");
- Vendor.Get(TempGlobalPurchaseLine."Buy-from Vendor No.");
- WorkCenterNo := Vendor."Work Center No.";
- if WorkCenterNo = '' then begin
- SubcManagementSetup.TestField("Common Work Center No.");
- WorkCenterNo := SubcManagementSetup."Common Work Center No.";
- end;
- exit(WorkCenterNo);
- end;
-
- local procedure InitializeTemporaryRoutingLinesFromSetup(RoutingNo: Code[20]; WorkCenterNo: Code[20])
- var
- Location: Record Location;
- begin
- TempGlobalRoutingLine.Init();
- TempGlobalRoutingLine."Routing No." := RoutingNo;
- TempGlobalRoutingLine."Operation No." := '10';
- TempGlobalRoutingLine.Type := "Capacity Type Routing"::"Work Center";
- TempGlobalRoutingLine."No." := WorkCenterNo;
- TempGlobalRoutingLine."Work Center No." := WorkCenterNo;
- TempGlobalRoutingLine.Description := CopyStr(SubcontractingOperationLbl, 1, MaxStrLen(TempGlobalRoutingLine.Description));
- TempGlobalRoutingLine."Routing Link Code" := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
- TempGlobalRoutingLine.Insert();
-
- Location.SetLoadFields("Prod. Output Whse. Handling");
- Location.Get(TempGlobalPurchaseLine."Location Code");
- if Location."Prod. Output Whse. Handling" <> "Prod. Output Whse. Handling"::"No Warehouse Handling" then
- if SubcManagementSetup."Put-Away Work Center No." <> '' then begin
- TempGlobalRoutingLine.Init();
- TempGlobalRoutingLine."Routing No." := RoutingNo;
- TempGlobalRoutingLine."Operation No." := '20';
- TempGlobalRoutingLine.Type := "Capacity Type Routing"::"Work Center";
- TempGlobalRoutingLine."No." := SubcManagementSetup."Put-Away Work Center No.";
- TempGlobalRoutingLine."Work Center No." := SubcManagementSetup."Put-Away Work Center No.";
- TempGlobalRoutingLine.Description := CopyStr(PutAwayOperationLbl, 1, MaxStrLen(TempGlobalRoutingLine.Description));
- TempGlobalRoutingLine."Routing Link Code" := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
- TempGlobalRoutingLine.Insert();
- end;
- end;
-
- ///
- /// Builds the temporary structure for production order processing based on the BOM and routing of the purchase line.
- /// Components and Prod. Order Routing Lines were created.
- ///
- procedure BuildTemporaryStructureFromBOMRouting()
- begin
- OnBeforeBuildTemporaryStructureFromBOMRouting(this);
-
- BuildTemporaryRoutingLines();
-
- BuildTemporaryComponents();
-
- GetVendor();
- SubcSessionState.SetCode('SetSubcontractingLocationCodeFromVendor', TempGlobalVendor."Subcontr. Location Code");
- end;
-
- local procedure BuildTemporaryComponents()
- var
- TempProductionBOMLine: Record "Production BOM Line" temporary;
- LineNo: Integer;
- begin
- TempGlobalProdOrderComponent.Reset();
- TempGlobalProdOrderComponent.DeleteAll();
- GetGlobalBOMLines(TempProductionBOMLine);
- if TempProductionBOMLine.FindSet() then begin
- LineNo := 0;
- repeat
- CreateTemporaryComponentFromBOMLine(TempProductionBOMLine, 1, LineNo);
- until TempProductionBOMLine.Next() = 0;
- end;
- end;
-
- local procedure BuildTemporaryRoutingLines()
- var
- TempRoutingLine: Record "Routing Line" temporary;
- begin
- TempGlobalProdOrderRoutingLine.Reset();
- TempGlobalProdOrderRoutingLine.DeleteAll();
- GetGlobalRoutingLines(TempRoutingLine);
- if TempRoutingLine.FindSet() then
- repeat
- CreateTemporaryProdOrderRoutingLineFromRouting(TempRoutingLine);
- until TempRoutingLine.Next() = 0;
- end;
-
- local procedure CreateTemporaryComponentFromBOMLine(ProductionBOMLine: Record "Production BOM Line"; BOMQuantity: Decimal; var LineNo: Integer)
- var
- ProductionBOMLine_NextLevel: Record "Production BOM Line";
- begin
-
- GetManufacturingSetup();
-
- case ProductionBOMLine.Type of
- "Production BOM Line Type"::Item:
- begin
- LineNo += 10000;
- TempGlobalProdOrderComponent.Init();
- TempGlobalProdOrderComponent.Status := TempGlobalProdOrderLine.Status;
- TempGlobalProdOrderComponent."Prod. Order No." := TempGlobalProdOrderLine."Prod. Order No.";
- TempGlobalProdOrderComponent.Validate("Prod. Order Line No.", TempGlobalProdOrderLine."Line No.");
- TempGlobalProdOrderComponent."Line No." := LineNo;
- TempGlobalProdOrderComponent."Qty. per Unit of Measure" := 1;
- TempGlobalProdOrderComponent.Validate("Item No.", ProductionBOMLine."No.");
- TempGlobalProdOrderComponent.Description := ProductionBOMLine.Description;
- TempGlobalProdOrderComponent."Description 2" := ProductionBOMLine."Description 2";
- TempGlobalProdOrderComponent.Validate("Quantity per", ProductionBOMLine."Quantity per" * BOMQuantity);
- if ProductionBOMLine."Unit of Measure Code" <> '' then
- TempGlobalProdOrderComponent.Validate("Unit of Measure Code", ProductionBOMLine."Unit of Measure Code");
- TempGlobalProdOrderComponent.Validate("Routing Link Code", ProductionBOMLine."Routing Link Code");
-
- TempGlobalProdOrderComponent."Subcontracting Type" := ProductionBOMLine."Subcontracting Type";
- PresetComponentLocationCode();
-
- if not SubcVersionMgmt.CheckBOMExists(ProductionBOMLine."Production BOM No.", '') then
- TempGlobalProdOrderComponent.Validate("Flushing Method", SubcManagementSetup."Def. provision flushing method");
-
- FillProdOrderComponentDefaultBin();
- TempGlobalProdOrderComponent.Insert();
- end;
- "Production BOM Line Type"::"Production BOM":
- begin
- ProductionBOMLine_NextLevel.SetRange("Production BOM No.", ProductionBOMLine."No.");
- ProductionBOMLine_NextLevel.SetRange("Version Code", SubcVersionMgmt.GetDefaultBOMVersion(ProductionBOMLine."No."));
- if ProductionBOMLine_NextLevel.FindSet() then
- repeat
- CreateTemporaryComponentFromBOMLine(ProductionBOMLine_NextLevel, ProductionBOMLine_NextLevel."Quantity per", LineNo);
- until ProductionBOMLine_NextLevel.Next() = 0;
- end;
- end;
- end;
-
- local procedure CreateTemporaryProdOrderRoutingLineFromRouting(RoutingLine: Record "Routing Line")
- begin
- GetManufacturingSetup();
- GetVendor();
-
- TempGlobalProdOrderRoutingLine.Init();
- TempGlobalProdOrderRoutingLine.Status := TempGlobalProdOrderLine.Status;
- TempGlobalProdOrderRoutingLine."Prod. Order No." := TempGlobalProdOrderLine."Prod. Order No.";
- TempGlobalProdOrderRoutingLine."Routing No." := RoutingLine."Routing No.";
- TempGlobalProdOrderRoutingLine.Validate("Routing Reference No.", TempGlobalProdOrderLine."Line No.");
- TempGlobalProdOrderRoutingLine.Validate("Operation No.", RoutingLine."Operation No.");
- TempGlobalProdOrderRoutingLine.Validate(Type, RoutingLine.Type);
- TempGlobalProdOrderRoutingLine.Validate("No.", RoutingLine."No.");
- TempGlobalProdOrderRoutingLine.Validate("Work Center No.", RoutingLine."Work Center No.");
- TempGlobalProdOrderRoutingLine.Description := RoutingLine.Description;
- TempGlobalProdOrderRoutingLine."Description 2" := RoutingLine."Description 2";
- TempGlobalProdOrderRoutingLine.Validate("Setup Time", RoutingLine."Setup Time");
- TempGlobalProdOrderRoutingLine.Validate("Run Time", RoutingLine."Run Time");
- TempGlobalProdOrderRoutingLine.Validate("Wait Time", RoutingLine."Wait Time");
- TempGlobalProdOrderRoutingLine.Validate("Move Time", RoutingLine."Move Time");
- TempGlobalProdOrderRoutingLine.Validate("Ending Date", TempGlobalProdOrderLine."Ending Date");
- TempGlobalProdOrderRoutingLine.Validate("Ending Time", TempGlobalProdOrderLine."Ending Time");
- TempGlobalProdOrderRoutingLine."Routing Link Code" := RoutingLine."Routing Link Code";
- TempGlobalProdOrderRoutingLine.Validate("Vendor No. Subc. Price", TempGlobalVendor."No.");
- TempGlobalProdOrderRoutingLine.FillDefaultLocationAndBins();
- TempGlobalProdOrderRoutingLine.Insert();
- end;
-
- ///
- /// Loads BOM lines into temporary storage.
- ///
- /// The BOM number to load lines for.
- /// The version code to filter by.
- procedure LoadBOMLines(BOMNo: Code[20]; VersionCode: Code[20])
- var
- ProductionBOMLine: Record "Production BOM Line";
- begin
- ClearBOMTables();
-
- if BOMNo = '' then
- exit;
-
- SetBOMLineFilters(ProductionBOMLine, BOMNo, VersionCode);
- CopyBOMLinesToTemporary(ProductionBOMLine);
- end;
-
- local procedure SetBOMLineFilters(var ProductionBOMLine: Record "Production BOM Line"; BOMNo: Code[20]; VersionCode: Code[20])
- begin
- if VersionCode <> '' then begin
- ProductionBOMLine.SetRange("Production BOM No.", BOMNo);
- ProductionBOMLine.SetRange("Version Code", VersionCode);
- end else begin
- ProductionBOMLine.SetRange("Production BOM No.", BOMNo);
- ProductionBOMLine.SetRange("Version Code", '');
- end;
- end;
-
- local procedure CopyBOMLinesToTemporary(var ProductionBOMLine: Record "Production BOM Line")
- begin
- if ProductionBOMLine.FindSet() then
- repeat
- TempGlobalProductionBOMLine := ProductionBOMLine;
- TempGlobalProductionBOMLine.Insert();
- until ProductionBOMLine.Next() = 0;
- end;
-
- ///
- /// Loads routing lines into temporary storage.
- ///
- /// The routing number to load lines for.
- /// The version code to filter by.
- procedure LoadRoutingLines(RoutingNo: Code[20]; VersionCode: Code[20])
- var
- RoutingLine: Record "Routing Line";
- begin
-
- ClearRoutingTables();
-
- if RoutingNo = '' then
- exit;
-
- if VersionCode = '' then
- VersionCode := SubcVersionMgmt.GetDefaultRoutingVersion(RoutingNo);
-
- SetRoutingLineFilters(RoutingLine, RoutingNo, VersionCode);
- CopyRoutingLinesToTemporary(RoutingLine);
- end;
-
- local procedure SetRoutingLineFilters(var RoutingLine: Record "Routing Line"; RoutingNo: Code[20]; VersionCode: Code[20])
- begin
- if VersionCode <> '' then begin
- RoutingLine.SetRange("Routing No.", RoutingNo);
- RoutingLine.SetRange("Version Code", VersionCode);
- end else begin
- RoutingLine.SetRange("Routing No.", RoutingNo);
- RoutingLine.SetRange("Version Code", '');
- end;
- end;
-
- local procedure CopyRoutingLinesToTemporary(var RoutingLine: Record "Routing Line")
- begin
- if RoutingLine.FindSet() then
- repeat
- TempGlobalRoutingLine := RoutingLine;
- TempGlobalRoutingLine.Insert();
- until RoutingLine.Next() = 0;
- end;
-
- ///
- /// Updates the version code for all routing lines.
- ///
- /// The new version code to apply.
- procedure UpdateRoutingVersionCode(NewVersionCode: Code[20])
- var
- TempRoutingLine: Record "Routing Line" temporary;
- TempRoutingLine2: Record "Routing Line" temporary;
- begin
- TempRoutingLine.Copy(TempGlobalRoutingLine, true);
- TempRoutingLine2.Copy(TempGlobalRoutingLine, true);
-
- TempRoutingLine.SetFilter("Version Code", '<>%1', NewVersionCode);
- if TempRoutingLine.FindSet() then
- repeat
- TempRoutingLine2 := TempRoutingLine;
- TempRoutingLine2."Version Code" := NewVersionCode;
- TempRoutingLine2.Insert();
- until TempRoutingLine.Next() = 0;
-
- TempRoutingLine.DeleteAll();
- end;
-
- ///
- /// Updates the version code for all BOM lines.
- ///
- /// The new version code to apply.
- procedure UpdateBOMVersionCode(NewVersionCode: Code[20])
- var
- TempProductionBOMLine: Record "Production BOM Line" temporary;
- TempProductionBOMLine2: Record "Production BOM Line" temporary;
- begin
- TempProductionBOMLine.Copy(TempGlobalProductionBOMLine, true);
- TempProductionBOMLine2.Copy(TempGlobalProductionBOMLine, true);
-
- TempProductionBOMLine.SetFilter("Version Code", '<>%1', NewVersionCode);
- if TempProductionBOMLine.FindSet(true) then
- repeat
- TempProductionBOMLine2 := TempProductionBOMLine;
- TempProductionBOMLine2."Version Code" := NewVersionCode;
- TempProductionBOMLine2.Insert();
- until TempProductionBOMLine.Next() = 0;
-
- TempProductionBOMLine.DeleteAll();
- end;
-
- ///
- /// Gets the global routing lines as routing records.
- ///
- /// The temporary routing lines to copy to.
- procedure GetGlobalRoutingLinesAsRouting(var TempRoutingLines: Record "Routing Line" temporary)
- begin
- TempRoutingLines.Copy(TempGlobalRoutingLine, true);
- end;
-
- local procedure GetManufacturingSetup()
- begin
- if HasManufacturingSetup then
- exit;
- HasManufacturingSetup := ManufacturingSetup.Get();
- end;
-
- local procedure GetSubcManagementSetup()
- begin
- if HasSubcManagementSetup then
- exit;
- HasSubcManagementSetup := SubcManagementSetup.Get();
- end;
-
- local procedure ClearBOMTables()
- begin
- TempGlobalProductionBOMLine.Reset();
- TempGlobalProductionBOMLine.DeleteAll();
- end;
-
- local procedure ClearRoutingTables()
- begin
- TempGlobalRoutingLine.Reset();
- TempGlobalRoutingLine.DeleteAll();
- end;
-
- local procedure FillProdOrderComponentDefaultBin()
- var
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- Item: Record Item;
- begin
- Item.SetLoadFields(Type);
- if not Item.Get(TempGlobalProdOrderComponent."Item No.") then
- exit;
- if not Item.IsInventoriableType() then
- exit;
-
- TempProdOrderRoutingLine.Copy(TempProdOrderRoutingLine, true);
- TempGlobalProdOrderComponent."Bin Code" := TempGlobalProdOrderComponent.GetDefaultConsumptionBin(TempProdOrderRoutingLine);
- end;
-
- local procedure GetVendor()
- var
- Vendor: Record Vendor;
- begin
- if (TempGlobalVendor."No." <> '') and (Vendor."No." = TempGlobalPurchaseLine."Buy-from Vendor No.") then
- exit;
- Vendor.Get(TempGlobalPurchaseLine."Buy-from Vendor No.");
- TempGlobalVendor := Vendor;
- end;
-
- local procedure PresetComponentLocationCode()
- var
- SubcontractingManagement: Codeunit "Subcontracting Management";
- ComponentsLocationCode: Code[10];
- begin
-
- ComponentsLocationCode := SubcontractingManagement.GetComponentsLocationCode(TempGlobalPurchaseLine);
-
- if TempGlobalProdOrderComponent."Routing Link Code" = ManufacturingSetup."Rtng. Link Code Purch. Prov." then
- case TempGlobalProdOrderComponent."Subcontracting Type" of
- "Subcontracting Type"::InventoryByVendor, "Subcontracting Type"::Purchase:
- begin
- GetVendor();
- TempGlobalProdOrderComponent.Validate("Location Code", TempGlobalVendor."Subcontr. Location Code");
- TempGlobalProdOrderComponent."Orig. Location Code" := ComponentsLocationCode;
- end;
- "Subcontracting Type"::Transfer:
- TempGlobalProdOrderComponent.Validate("Location Code", ComponentsLocationCode);
- end;
-
- if TempGlobalProdOrderComponent."Location Code" = '' then
- TempGlobalProdOrderComponent.Validate("Location Code", TempGlobalProductionOrder."Location Code");
- end;
-
- ///
- /// Sets new BOM information from temporary records.
- ///
- /// The temporary BOM header to copy from.
- /// The temporary BOM lines to copy from.
- procedure SetNewBOMInformation(var TempProductionBOMHeader: Record "Production BOM Header" temporary; var TempProductionBOMLine: Record "Production BOM Line" temporary)
- begin
- ClearBOMTables();
- TempGlobalProductionBOMHeader.Copy(TempProductionBOMHeader, true);
- TempGlobalProductionBOMLine.Copy(TempProductionBOMLine, true);
- end;
-
- ///
- /// Sets new routing information from temporary records.
- ///
- /// The temporary routing header to copy from.
- /// The temporary routing lines to copy from.
- procedure SetNewRoutingInformation(var TempRoutingHeader: Record "Routing Header" temporary; var TempRoutingLine: Record "Routing Line" temporary)
- begin
- ClearRoutingTables();
- TempGlobalRoutingHeader.Copy(TempRoutingHeader, true);
- TempGlobalRoutingLine.Copy(TempRoutingLine, true);
- end;
-
- ///
- /// Sets new production order components from temporary records.
- ///
- /// The temporary production order components to copy from.
- procedure SetNewProdOrderComponent(var TempProdOrderComponent: Record "Prod. Order Component" temporary)
- begin
- TempGlobalProdOrderComponent.Reset();
- TempGlobalProdOrderComponent.DeleteAll();
- TempGlobalProdOrderComponent.Copy(TempProdOrderComponent, true);
- end;
-
- ///
- /// Sets new production order routing lines from temporary records.
- ///
- /// The temporary production order routing lines to copy from.
- procedure SetNewProdOrderRoutingLine(var TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary)
- begin
- TempGlobalProdOrderRoutingLine.Reset();
- TempGlobalProdOrderRoutingLine.DeleteAll();
- TempGlobalProdOrderRoutingLine.Copy(TempProdOrderRoutingLine, true);
- end;
-
- ///
- /// Sets new production order from temporary records.
- ///
- /// The temporary production order to copy from.
- procedure SetNewProdOrder(var TempProductionOrder: Record "Production Order" temporary)
- begin
- TempGlobalProductionOrder.Reset();
- TempGlobalProductionOrder.DeleteAll();
- TempGlobalProductionOrder.Copy(TempProductionOrder, true);
- end;
-
- ///
- /// Sets the routing and BOM source type.
- ///
- /// The source type to set.
- procedure SetRtngBOMSourceType(SourceType: Enum "Subc. RtngBOMSourceType")
- begin
- SubcRtngBOMSourceType := SourceType;
- end;
-
- ///
- /// Gets the global BOM lines.
- ///
- /// The temporary BOM lines to copy to.
- procedure GetGlobalBOMLines(var TempProductionBOMLine: Record "Production BOM Line" temporary)
- begin
- TempProductionBOMLine.Copy(TempGlobalProductionBOMLine, true);
- end;
-
- ///
- /// Gets the global routing lines.
- ///
- /// The temporary routing lines to copy to.
- procedure GetGlobalRoutingLines(var TempRoutingLine: Record "Routing Line" temporary)
- begin
- TempRoutingLine.Copy(TempGlobalRoutingLine, true);
- end;
-
- ///
- /// Gets the global BOM header.
- ///
- /// The temporary BOM header to copy to.
- procedure GetGlobalBOMHeader(var TempProductionBOMHeader: Record "Production BOM Header" temporary)
- begin
- TempProductionBOMHeader.Copy(TempGlobalProductionBOMHeader, true);
- end;
-
- ///
- /// Gets the global routing header.
- ///
- /// The temporary routing header to copy to.
- procedure GetGlobalRoutingHeader(var TempRoutingHeader: Record "Routing Header" temporary)
- begin
- TempRoutingHeader.Copy(TempGlobalRoutingHeader, true);
- end;
-
- ///
- /// Gets the global production order components.
- ///
- /// The temporary production order components to copy to.
- procedure GetGlobalProdOrderComponent(var TempProdOrderComponent: Record "Prod. Order Component" temporary)
- begin
- TempProdOrderComponent.Copy(TempGlobalProdOrderComponent, true);
- end;
-
- ///
- /// Gets the global production order routing lines.
- ///
- /// The temporary production order routing lines to copy to.
- procedure GetGlobalProdOrderRoutingLine(var TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary)
- begin
- TempProdOrderRoutingLine.Copy(TempGlobalProdOrderRoutingLine, true);
- end;
-
- ///
- /// Gets the global production order.
- ///
- /// The temporary production order to copy to.
- procedure GetGlobalProdOrder(var TempProductionOrder: Record "Production Order" temporary)
- begin
- TempProductionOrder.Copy(TempGlobalProductionOrder, true);
- end;
-
- ///
- /// Gets the global production order line.
- ///
- /// The temporary production order line to copy to.
- procedure GetGlobalProdOrderLine(var TempProdOrderLine: Record "Prod. Order Line" temporary)
- begin
- TempProdOrderLine.Copy(TempGlobalProdOrderLine, true);
- end;
-
- ///
- /// Gets the routing and BOM source type.
- ///
- /// The current routing and BOM source type.
- procedure GetRtngBOMSourceType(): Enum "Subc. RtngBOMSourceType"
- begin
- exit(SubcRtngBOMSourceType);
- end;
-
- ///
- /// Gets the global purchase line.
- ///
- /// The temporary purchase line to copy to.
- procedure GetGlobalPurchLine(var TempPurchaseLine: Record "Purchase Line" temporary)
- begin
- TempPurchaseLine.Copy(TempGlobalPurchaseLine, true);
- end;
-
-
- [InternalEvent(false, false)]
- local procedure OnBeforeBuildTemporaryStructureFromBOMRouting(SubcTempDataInitializer: Codeunit "Subc. Temp Data Initializer")
- begin
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcTempProdOrdBind.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcTempProdOrdBind.Codeunit.al
deleted file mode 100644
index d1081b8b2f..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcTempProdOrdBind.Codeunit.al
+++ /dev/null
@@ -1,108 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.Routing;
-
-codeunit 99001554 "Subc. TempProdOrdBind"
-{
- EventSubscriberInstance = Manual;
-
- [EventSubscriber(ObjectType::Codeunit, Codeunit::"Subc. Temp Data Initializer", OnBeforeBuildTemporaryStructureFromBOMRouting, '', false, false)]
- local procedure "Sub. Temp Data Initializer_OnBeforeBuildTemporaryStructureFromBOMRouting"(SubcTempDataInitializer: Codeunit "Subc. Temp Data Initializer")
- var
- TempProdOrderLine: Record "Prod. Order Line" temporary;
- TempRoutingLine: Record "Routing Line" temporary;
- begin
- SubcTempDataInitializer.GetGlobalProdOrderLine(TempProdOrderLine);
- SubcTempDataInitializer.GetGlobalRoutingLines(TempRoutingLine);
- PrepareDummyProdOrderLine(TempProdOrderLine, TempRoutingLine."Routing No.");
- end;
-
- [EventSubscriber(ObjectType::Page, Page::"Subc. PurchProvisionWizard", OnClosePageEvent, '', false, false)]
- local procedure OnCloseBOMRtngWizard()
- begin
- DeleteDummyProdOrderLine();
- end;
-
- [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnBeforeCalcStartingEndingDates, '', false, false)]
- local procedure "Prod. Order Routing Line_OnBeforeCalcStartingEndingDates"(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var Direction: Option; var IsHandled: Boolean)
- begin
- if ProdOrderRoutingLine.IsTemporary() then
- IsHandled := true;
- end;
-
- [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnBeforeCheckRoutingNoNotBlank, '', false, false)]
- local procedure "Prod. Order Routing Line_OnBeforeCheckRoutingNoNotBlank"(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var IsHandled: Boolean)
- begin
- if ProdOrderRoutingLine.IsTemporary() then
- IsHandled := true;
- end;
-
- [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnBeforeDeleteEvent, '', false, false)]
- local procedure "Prod. Order Routing Line_OnBeforeDeleteEvent"(var Rec: Record "Prod. Order Routing Line")
- begin
- if Rec.IsTemporary() then
- PrepareDummyProdOrderRoutingLine(Rec);
- end;
-
- [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnAfterDeleteEvent, '', false, false)]
- local procedure "Prod. Order Routing Line_OnAfterDeleteEvent"(var Rec: Record "Prod. Order Routing Line")
- begin
- DeleteDummyProdOrderRoutingLine();
- end;
-
- [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnBeforeModifyEvent, '', false, false)]
- local procedure "Prod. Order Routing Line_OnBeforeModifyEvent"(var Rec: Record "Prod. Order Routing Line")
- begin
- if Rec.IsTemporary() then
- PrepareDummyProdOrderRoutingLine(Rec);
- end;
-
- [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnAfterModifyEvent, '', false, false)]
- local procedure "Prod. Order Routing Line_OnAfterModifyEvent"(var Rec: Record "Prod. Order Routing Line")
- begin
- if Rec.IsTemporary() then
- DeleteDummyProdOrderRoutingLine();
- end;
-
- var
- DummyProdOrderLine: Record "Prod. Order Line";
- DummyProdOrderRoutingLine: Record "Prod. Order Routing Line";
-
- procedure PrepareDummyProdOrderLine(var TempProdOrderLine: Record "Prod. Order Line" temporary; RoutingNo: Code[20])
- begin
- if not DummyProdOrderLine.Get(TempProdOrderLine.Status, TempProdOrderLine."Prod. Order No.", TempProdOrderLine."Line No.") then begin
- DummyProdOrderLine := TempProdOrderLine;
- DummyProdOrderLine."Routing No." := RoutingNo;
- DummyProdOrderLine.Insert()
- end else begin
- DummyProdOrderLine."Routing No." := RoutingNo;
- DummyProdOrderLine.Modify();
- end;
- end;
-
- procedure DeleteDummyProdOrderLine()
- begin
- if DummyProdOrderLine.Get(DummyProdOrderLine.Status, DummyProdOrderLine."Prod. Order No.", DummyProdOrderLine."Line No.") then
- DummyProdOrderLine.Delete();
- end;
-
- local procedure PrepareDummyProdOrderRoutingLine(ProdOrderRoutingLineToDelete: Record "Prod. Order Routing Line")
- begin
- if not DummyProdOrderRoutingLine.Get(ProdOrderRoutingLineToDelete.Status, ProdOrderRoutingLineToDelete."Prod. Order No.", ProdOrderRoutingLineToDelete."Routing Reference No.", ProdOrderRoutingLineToDelete."Routing No.", ProdOrderRoutingLineToDelete."Operation No.") then begin
- DummyProdOrderRoutingLine := ProdOrderRoutingLineToDelete;
- DummyProdOrderRoutingLine.Insert();
- end;
- end;
-
- local procedure DeleteDummyProdOrderRoutingLine()
- begin
- if DummyProdOrderRoutingLine.Get(DummyProdOrderRoutingLine.Status, DummyProdOrderRoutingLine."Prod. Order No.", DummyProdOrderRoutingLine."Routing Reference No.", DummyProdOrderRoutingLine."Routing No.", DummyProdOrderRoutingLine."Operation No.") then
- DummyProdOrderRoutingLine.Delete();
- Clear(DummyProdOrderRoutingLine);
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcVersionMgmt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcVersionMgmt.Codeunit.al
deleted file mode 100644
index b590272960..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Codeunits/SubcVersionMgmt.Codeunit.al
+++ /dev/null
@@ -1,185 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Manufacturing.ProductionBOM;
-using Microsoft.Manufacturing.Routing;
-
-codeunit 99001553 "Subc. Version Mgmt."
-{
- var
- VersionManagement: Codeunit VersionManagement;
-
- procedure ShowBOMVersionSelection(ProductionBOMNo: Code[20]; var SelectedVersion: Code[20]): Boolean
- var
- ProductionBOMVersion: Record "Production BOM Version";
- ProdBOMVersionList: Page "Prod. BOM Version List";
- begin
- if ProductionBOMNo = '' then
- exit(false);
-
- ProductionBOMVersion.SetRange("Production BOM No.", ProductionBOMNo);
- ProductionBOMVersion.SetRange(Status, "BOM Status"::Certified);
- ProdBOMVersionList.SetTableView(ProductionBOMVersion);
- ProdBOMVersionList.LookupMode(true);
-
- if ProdBOMVersionList.RunModal() = Action::LookupOK then begin
- ProdBOMVersionList.GetRecord(ProductionBOMVersion);
- SelectedVersion := ProductionBOMVersion."Version Code";
- exit(true);
- end;
-
- exit(false);
- end;
-
- procedure ShowRoutingVersionSelection(RoutingNo: Code[20]; var SelectedVersion: Code[20]): Boolean
- var
- RoutingVersion: Record "Routing Version";
- RoutingVersionList: Page "Routing Version List";
- begin
- if RoutingNo = '' then
- exit(false);
-
- RoutingVersion.SetRange("Routing No.", RoutingNo);
- RoutingVersion.SetRange(Status, "Routing Status"::Certified);
- RoutingVersionList.SetTableView(RoutingVersion);
- RoutingVersionList.LookupMode(true);
-
- if RoutingVersionList.RunModal() = Action::LookupOK then begin
- RoutingVersionList.GetRecord(RoutingVersion);
- SelectedVersion := RoutingVersion."Version Code";
- exit(true);
- end;
-
- exit(false);
- end;
-
- procedure GetDefaultBOMVersion(ProductionBOMNo: Code[20]): Code[20]
- begin
- exit(VersionManagement.GetBOMVersion(ProductionBOMNo, WorkDate(), true));
- end;
-
- procedure GetDefaultRoutingVersion(RoutingNo: Code[20]): Code[20]
- begin
- exit(VersionManagement.GetRtngVersion(RoutingNo, WorkDate(), true));
- end;
-
- procedure ShowBOMSelection(var SelectedBOMNo: Code[20]): Boolean
- var
- ProductionBOMHeader: Record "Production BOM Header";
- ProductionBOMList: Page "Production BOM List";
- begin
- ProductionBOMHeader.SetRange(Status, "BOM Status"::Certified);
- ProductionBOMList.SetTableView(ProductionBOMHeader);
- ProductionBOMList.LookupMode(true);
-
- if ProductionBOMList.RunModal() = Action::LookupOK then begin
- ProductionBOMList.GetRecord(ProductionBOMHeader);
- SelectedBOMNo := ProductionBOMHeader."No.";
- exit(true);
- end;
-
- exit(false);
- end;
-
- procedure ShowRoutingSelection(var SelectedRoutingNo: Code[20]): Boolean
- var
- RoutingHeader: Record "Routing Header";
- RoutingList: Page "Routing List";
- begin
- RoutingHeader.SetRange(Status, "Routing Status"::Certified);
- RoutingList.SetTableView(RoutingHeader);
- RoutingList.LookupMode(true);
- if RoutingList.RunModal() = Action::LookupOK then begin
- RoutingList.GetRecord(RoutingHeader);
- SelectedRoutingNo := RoutingHeader."No.";
- exit(true);
- end;
-
- exit(false);
- end;
-
- procedure CheckRoutingExists(RoutingNo: Code[20]; RoutingVersionCode: Code[20]): Boolean
- var
- RoutingHeader: Record "Routing Header";
- RoutingVersion: Record "Routing Version";
- begin
- if RoutingVersionCode <> '' then begin
- RoutingVersion.SetLoadFields(SystemId);
- exit(RoutingVersion.Get(RoutingNo, RoutingVersionCode));
- end;
-
- RoutingHeader.SetLoadFields(SystemId);
- exit(RoutingHeader.Get(RoutingNo));
- end;
-
- procedure TestRoutingCertified(RoutingNo: Code[20]; RoutingVersionCode: Code[20])
- var
- RoutingHeader: Record "Routing Header";
- RoutingVersion: Record "Routing Version";
- begin
- if RoutingNo = '' then
- exit;
-
- RoutingVersion.SetLoadFields(Status);
- if RoutingVersion.Get(RoutingNo, RoutingVersionCode) then
- RoutingVersion.TestField(Status, "Routing Status"::Certified);
-
- RoutingHeader.SetLoadFields(Status);
- if RoutingHeader.Get(RoutingNo) then
- RoutingHeader.TestField(Status, "Routing Status"::Certified);
- end;
-
- procedure CheckBOMExists(ProductionBOMNo: Code[20]; BOMVersionCode: Code[20]): Boolean
- var
- ProductionBOMHeader: Record "Production BOM Header";
- ProductionBOMVersion: Record "Production BOM Version";
- begin
- if BOMVersionCode <> '' then begin
- ProductionBOMVersion.SetLoadFields(SystemId);
- exit(ProductionBOMVersion.Get(ProductionBOMNo, BOMVersionCode));
- end;
-
- ProductionBOMHeader.SetLoadFields(SystemId);
- exit(ProductionBOMHeader.Get(ProductionBOMNo));
- end;
-
- procedure TestBOMCertified(ProductionBOMNo: Code[20]; BOMVersionCode: Code[20])
- var
- ProductionBOMHeader: Record "Production BOM Header";
- ProductionBOMVersion: Record "Production BOM Version";
- begin
- if ProductionBOMNo = '' then
- exit;
-
- ProductionBOMVersion.SetLoadFields(Status);
- if ProductionBOMVersion.Get(ProductionBOMNo, BOMVersionCode) then
- ProductionBOMVersion.TestField(Status, "BOM Status"::Certified);
-
- ProductionBOMHeader.SetLoadFields(Status);
- if ProductionBOMHeader.Get(ProductionBOMNo) then
- ProductionBOMHeader.TestField(Status, "BOM Status"::Certified);
- end;
-
- procedure GetBOMVersionNoSeries(ProductionBOMNo: Code[20]): Code[20]
- var
- ProductionBOMHeader: Record "Production BOM Header";
- begin
- ProductionBOMHeader.SetLoadFields("Version Nos.");
- ProductionBOMHeader.Get(ProductionBOMNo);
- ProductionBOMHeader.TestField("Version Nos.");
- exit(ProductionBOMHeader."Version Nos.");
- end;
-
- procedure GetRoutingVersionNoSeries(RoutingNo: Code[20]): Code[20]
- var
- RoutingHeader: Record "Routing Header";
- begin
- RoutingHeader.SetLoadFields("Version Nos.");
- RoutingHeader.Get(RoutingNo);
- RoutingHeader.TestField("Version Nos.");
- exit(RoutingHeader."Version Nos.");
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Enums/SubcRtngBOMSourceType.Enum.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Enums/SubcRtngBOMSourceType.Enum.al
deleted file mode 100644
index 3dbfa6df94..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Enums/SubcRtngBOMSourceType.Enum.al
+++ /dev/null
@@ -1,23 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-enum 99001506 "Subc. RtngBOMSourceType"
-{
- Extensible = true;
-
- value(0; Empty)
- {
- Caption = ' ', Locked = true;
- }
- value(1; Item)
- {
- Caption = 'Item';
- }
- value(2; StockkeepingUnit)
- {
- Caption = 'Stockkeeping Unit';
- }
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Enums/SubcScenarioType.Enum.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Enums/SubcScenarioType.Enum.al
deleted file mode 100644
index 8648781a07..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Enums/SubcScenarioType.Enum.al
+++ /dev/null
@@ -1,23 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-enum 99001505 "Subc. Scenario Type"
-{
- Extensible = true;
-
- value(0; BothAvailable)
- {
- Caption = 'Both Available';
- }
- value(1; PartiallyAvailable)
- {
- Caption = 'Partially Available';
- }
- value(2; NothingAvailable)
- {
- Caption = 'Nothing Available';
- }
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Enums/SubcShowEditType.Enum.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Enums/SubcShowEditType.Enum.al
deleted file mode 100644
index 1cbe353e67..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Enums/SubcShowEditType.Enum.al
+++ /dev/null
@@ -1,23 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-enum 99001504 "Subc. Show/Edit Type"
-{
- Extensible = true;
-
- value(0; Hide)
- {
- Caption = 'Hide';
- }
- value(1; Show)
- {
- Caption = 'Show';
- }
- value(2; Edit)
- {
- Caption = 'Edit';
- }
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcPurchProvisionWizard.Page.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcPurchProvisionWizard.Page.al
deleted file mode 100644
index cf1132ffbb..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcPurchProvisionWizard.Page.al
+++ /dev/null
@@ -1,702 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Inventory.Item;
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.ProductionBOM;
-using Microsoft.Manufacturing.Routing;
-using System.Environment;
-using System.Utilities;
-
-page 99001505 "Subc. PurchProvisionWizard"
-{
- ApplicationArea = Manufacturing;
- Caption = 'Purchase Provision Wizard';
- PageType = NavigatePage;
- SourceTable = Item;
- SourceTableTemporary = true;
- UsageCategory = None;
-
- layout
- {
- area(Content)
- {
- group(StandardBanner)
- {
- Editable = false;
- ShowCaption = false;
- Visible = TopBannerVisible;
- field(MediaResourcesStandardBanner; MediaResourcesStandard."Media Reference")
- {
- Editable = false;
- ShowCaption = false;
- }
- }
- // Step 1: Introduction
- group(IntroStep)
- {
- ShowCaption = false;
- Visible = IntroStepVisible;
-
- group(WelcomeGroup)
- {
- Caption = 'Welcome to Purchase Provision Setup';
-
- group(IntroductionGroup)
- {
- InstructionalText = 'This wizard helps you select and configure the BOM and Routing for your production order. You can select which BOM and Routing to use, and preview the components and operations before creating the production order.';
- ShowCaption = false;
- }
- }
- group(General)
- {
- Caption = 'General';
- field("No."; Rec."No.")
- {
- Caption = 'Item No.';
- Editable = false;
- ToolTip = 'Specifies the item number for which the purchase provision is being set up.';
- }
- field(Description; Rec.Description)
- {
- Caption = 'Description';
- Editable = false;
- ToolTip = 'Specifies the description of the item for which the purchase provision is being set up.';
- }
- field("Description 2"; Rec."Description 2")
- {
- Caption = 'Description 2';
- Editable = false;
- ToolTip = 'Specifies additional description of the item for which the purchase provision is being set up.';
- Visible = false;
- }
- group(BomRoutingTransfer)
- {
- Caption = 'BOM/Routing Transfer';
- field(BomRtngFromSource; BomRtngFromSourceTxt)
- {
- Caption = 'Source';
- Editable = false;
- ToolTip = 'Specifies the source where BOM and Routing data was retrieved from.';
- }
- field(SaveBOMRouting; SaveBOMRouting)
- {
- Caption = 'Save';
- ToolTip = 'Specifies whether to apply the selected BOM and Routing to the specified source.';
-
- trigger OnValidate()
- begin
- if SaveBOMRouting then begin
- SaveBomRtngToSource := BomRtngFromSource;
- if SaveBomRtngToSource = SaveBomRtngToSource::Empty then
- SaveBomRtngToSource := SaveBomRtngToSource::Item
- end else
- Clear(SaveBomRtngToSource);
- end;
- }
- field(SaveBomRtngToSource; SaveBomRtngToSource)
- {
- Caption = 'Save in';
- Editable = SaveBOMRouting;
- ToolTip = 'Specifies where to apply the BOM and Routing changes.';
- trigger OnValidate()
- begin
- if SaveBOMRouting and (SaveBomRtngToSource = SaveBomRtngToSource::Empty) then
- Error(SaveBOMRtngSourceNotEmptyErr);
- end;
- }
- }
- }
- group(ShowEditOptions)
- {
- Caption = 'Show/Edit Options';
- Enabled = ShowEditOptionsEnabled;
-
- field(BOMRoutingShowEditTypeField; BOMRoutingShowEditType)
- {
- Caption = 'BOM/Routing';
- ToolTip = 'Specifies how BOM and routing selection steps behave in the wizard. Hide: skip selection. Show: display with version choice, no editing. Edit: display with full editing and version creation.';
- trigger OnValidate()
- begin
- SetBOMRoutingEditable();
- end;
- }
- field(ProdCompRoutingShowEditTypeField; ProdCompRoutingShowEditType)
- {
- Caption = 'Prod. Components/Prod. Operations';
- ToolTip = 'Specifies how the component and routing-operations preview steps behave in the wizard. Hide: skip preview, use generated data. Show: display for review only. Edit: display with full editing before production order creation.';
- }
- }
- }
- // Step 2: BOM Selection
- group(BOMStep)
- {
- ShowCaption = false;
- Visible = BOMStepVisible;
-
- group(BOMSelection)
- {
- Caption = 'Production BOM Selection';
- InstructionalText = 'Select the Production BOM and version to use for the production order.';
-
- group(BOMCreationGroup)
- {
- ShowCaption = false;
- Visible = CreateBOMVersionVisible;
- field(BOMIntroductionText; NewVersionIntroductionLbl)
- {
- Editable = false;
- MultiLine = true;
- ShowCaption = false;
- Style = StandardAccent;
- }
- field(CreateBOMVersion; CreateBOMVersion)
- {
- Caption = 'Create New BOM Version';
- ToolTip = 'Specifies whether to create a new version of the Production BOM with an automatically generated version number.';
-
- trigger OnValidate()
- begin
- if CreateBOMVersion then begin
- SelectedBOMVersion := 'TEMP-VERSION-' + CopyStr(Format(CreateGuid()), 2, 7);
- SubcVersionMgmt.GetBOMVersionNoSeries(SelectedBOMNo)
- end else begin
- SelectedBOMVersion := '';
- LoadBOMLines();
- end;
- SetBOMRoutingEditable();
- SubcTempDataInitializer.UpdateBOMVersionCode(SelectedBOMVersion);
- end;
- }
- }
- field("Production BOM No."; SelectedBOMNo)
- {
- Caption = 'Production BOM No.';
- Editable = false;
- ToolTip = 'Specifies the Production BOM to use for the production order.';
-
- trigger OnAssistEdit()
- var
- NewBOMNo: Code[20];
- begin
- NewBOMNo := SelectedBOMNo;
- if SubcVersionMgmt.ShowBOMSelection(NewBOMNo) then
- if NewBOMNo <> SelectedBOMNo then begin
- SelectedBOMNo := NewBOMNo;
- SelectedBOMVersion := '';
- LoadBOMLines();
- SetBOMRoutingEditable();
- end;
- end;
- }
- field(SelectedBOMVersion; SelectedBOMVersion)
- {
- Caption = 'Selected BOM Version';
- Editable = false;
- ToolTip = 'Specifies the version of the Production BOM to use for the production order.';
-
- trigger OnAssistEdit()
- begin
- if SubcVersionMgmt.ShowBOMVersionSelection(SelectedBOMNo, SelectedBOMVersion) then
- LoadBOMLines();
- end;
- }
- part(BOMLinesPart; "Subc. Temp BOM Lines")
- {
- Caption = 'Production BOM Lines';
- Editable = EditBOMLines;
- }
- }
- }
- // Step 3: Routing Selection
- group(RoutingStep)
- {
- ShowCaption = false;
- Visible = RoutingStepVisible;
-
- group(RoutingSelection)
- {
- Caption = 'Routing Selection';
- InstructionalText = 'Select the Routing and version to use for the production order.';
-
- group(RoutingCreationGroup)
- {
- ShowCaption = false;
- Visible = CreateRoutingVersionVisible;
- field(RoutingIntroductionText; NewVersionIntroductionLbl)
- {
- Editable = false;
- MultiLine = true;
- ShowCaption = false;
- Style = StandardAccent;
- }
- field(CreateRoutingVersion; CreateRoutingVersion)
- {
- Caption = 'Create New Routing Version';
- ToolTip = 'Specifies whether to create a new version of the Routing with an automatically generated version number.';
-
- trigger OnValidate()
- begin
- if CreateRoutingVersion then begin
- SelectedRoutingVersion := 'TEMP-VER-' + CopyStr(Format(CreateGuid()), 2, 7);
- SubcVersionMgmt.GetRoutingVersionNoSeries(SelectedRoutingNo)
- end else begin
- SelectedRoutingVersion := '';
- LoadRoutingLines();
- end;
- SetBOMRoutingEditable();
- SubcTempDataInitializer.UpdateRoutingVersionCode(SelectedRoutingVersion);
- end;
- }
- }
- field("Routing No."; SelectedRoutingNo)
- {
- Caption = 'Routing No.';
- Editable = false;
- ToolTip = 'Specifies the Routing to use for the production order.';
-
- trigger OnAssistEdit()
- var
- NewRoutingNo: Code[20];
- begin
- NewRoutingNo := SelectedRoutingNo;
- if SubcVersionMgmt.ShowRoutingSelection(NewRoutingNo) then
- if NewRoutingNo <> SelectedRoutingNo then begin
- SelectedRoutingNo := NewRoutingNo;
- SelectedRoutingVersion := '';
- LoadRoutingLines();
- SetBOMRoutingEditable();
- end;
- end;
- }
- field(SelectedRoutingVersion; SelectedRoutingVersion)
- {
- Caption = 'Selected Routing Version';
- Editable = false;
- ToolTip = 'Specifies the version of the Routing to use for the production order.';
-
- trigger OnAssistEdit()
- begin
- if SubcVersionMgmt.ShowRoutingVersionSelection(SelectedRoutingNo, SelectedRoutingVersion) then
- LoadRoutingLines();
- end;
- }
- part(RoutingLinesPart; "Subc. Temp Routing Lines")
- {
- Caption = 'Routing Lines';
- Editable = EditRoutingLines;
- }
- }
- }
- // Step 4: Components Preview
- group(ComponentsStep)
- {
- ShowCaption = false;
- Visible = ComponentsStepVisible;
-
- group(ComponentsPreview)
- {
- Caption = 'Components Preview';
- InstructionalText = 'Review and edit the components that will be created for the production order.';
-
- part(ComponentsPart; "Subc. Temp Prod Order Comp")
- {
- Caption = 'Components';
- Editable = ProdCompRoutingShowEditType = ProdCompRoutingShowEditType::Edit;
- }
- }
- }
- // Step 5: Production Order Routing Preview
- group(ProdRoutingStep)
- {
- ShowCaption = false;
- Visible = ProdRoutingStepVisible;
-
- group(ProdRoutingPreview)
- {
- Caption = 'Production Order Routing Preview';
- InstructionalText = 'Review and edit the routing operations that will be created for the production order.';
-
- part(ProdOrderRoutingPart; "Subc. TempProdOrdRtngLines")
- {
- Caption = 'Prod. Order Routing Lines';
- Editable = ProdCompRoutingShowEditType = ProdCompRoutingShowEditType::Edit;
- }
- }
- }
- }
- }
- actions
- {
- area(Processing)
- {
- action(ActionBack)
- {
- Caption = 'Back';
- Enabled = BackActionEnabled;
- Image = PreviousRecord;
- InFooterBar = true;
-
- trigger OnAction()
- begin
- NextStep(true);
- end;
- }
- action(ActionNext)
- {
- Caption = 'Next';
- Enabled = NextActionEnabled;
- Image = NextRecord;
- InFooterBar = true;
-
- trigger OnAction()
- begin
- NextStep(false);
- end;
- }
- action(ActionFinish)
- {
- Caption = 'Finish';
- Enabled = FinishActionEnabled;
- Image = Approve;
- InFooterBar = true;
-
- trigger OnAction()
- begin
- FinishAction();
- end;
- }
- }
- }
- protected var
- BackActionEnabled, FinishActionEnabled, NextActionEnabled, ShowEditOptionsEnabled : Boolean;
- BOMStepVisible, ComponentsStepVisible, IntroStepVisible, ProdRoutingStepVisible, RoutingStepVisible, TopBannerVisible : Boolean;
- CreateBOMVersion, CreateRoutingVersion : Boolean;
- CreateBOMVersionVisible, CreateRoutingVersionVisible : Boolean;
- EditBOMLines, EditRoutingLines : Boolean;
- SaveBOMRouting: Boolean;
- SelectedBOMNo, SelectedBOMVersion, SelectedRoutingNo, SelectedRoutingVersion : Code[20];
- SaveBomRtngToSource: Enum "Subc. RtngBOMSourceType";
- BOMRoutingShowEditType, ProdCompRoutingShowEditType : Enum "Subc. Show/Edit Type";
- Step: Option Intro,BOM,Routing,Components,ProdRouting;
-
- var
- MediaRepositoryStandard: Record "Media Repository";
- MediaResourcesStandard: Record "Media Resources";
- SubcTempDataInitializer: Codeunit "Subc. Temp Data Initializer";
- SubcVersionMgmt: Codeunit "Subc. Version Mgmt.";
- Finished: Boolean;
- BomRtngFromSource: Enum "Subc. RtngBOMSourceType";
- BomRtngFromSourceTxt: Text;
- NewVersionIntroductionLbl: Label 'To edit lines directly, activate "Create New Version". This generates a temporary version code (replaced by a number series upon saving). Without this, existing master data is used, and editing is not available for this step.';
- SaveBOMRtngSourceNotEmptyErr: Label 'Please select a valid source for saving BOM and Routing changes.';
- SetupSourceLbl: Label 'Subcontracting Management Setup';
-
- trigger OnInit()
- begin
- LoadTopBanners();
- end;
-
- trigger OnOpenPage()
- begin
- SetBOMDataReference();
- SetRoutingDataReference();
- SetProdOrderDataReference();
-
- InitBomRoutingSource();
-
- Step := Step::Intro;
- EnableControls();
-
- SetBOMRoutingEditable();
- SetShowEditOptionsEnabled();
-
- if Rec.FindFirst() then;
- end;
-
- ///
- /// Sets the item for which the production order will be created.
- ///
- /// The item record to use for production order creation.
- procedure SetItem(Item: Record Item)
- begin
- Rec := Item;
- Rec.Insert();
- end;
-
- ///
- /// Sets the display and editing behavior for BOM and Routing selection steps.
- ///
- /// The show/edit type to control BOM and Routing step behavior.
- procedure SetBOMRoutingShowEditType(SubcShowEditType: Enum "Subc. Show/Edit Type")
- begin
- BOMRoutingShowEditType := SubcShowEditType;
- end;
-
- ///
- /// Sets the display and editing behavior for Production Order Components and Routing preview steps.
- ///
- /// The show/edit type to control component and routing preview behavior.
- procedure SetProdCompRoutingShowEditType(SubcShowEditType: Enum "Subc. Show/Edit Type")
- begin
- ProdCompRoutingShowEditType := SubcShowEditType;
- end;
-
- ///
- /// Sets the temporary data initializer codeunit for managing temporary production order data.
- ///
- /// The temporary data initializer codeunit to use.
- procedure SetTempDataInitializer(var NewSubcTempDataInitializer: Codeunit "Subc. Temp Data Initializer")
- begin
- SubcTempDataInitializer := NewSubcTempDataInitializer;
- end;
-
- ///
- /// Gets the source where BOM and Routing changes should be applied.
- ///
- /// The source type for applying BOM and Routing changes.
- procedure GetApplyBomRtngToSource(): Enum "Subc. RtngBOMSourceType"
- begin
- exit(SaveBomRtngToSource);
- end;
-
- ///
- /// Checks if changes were made to the production order components.
- ///
- /// True if components were modified, false otherwise.
- procedure GetApplyChangesComponents(): Boolean
- begin
- exit(CurrPage.ComponentsPart.Page.GetLinesChanged());
- end;
-
- ///
- /// Checks if changes were made to the production order routing.
- ///
- /// True if routing was modified, false otherwise.
- procedure GetApplyChangesProdRouting(): Boolean
- begin
- exit(CurrPage.ProdOrderRoutingPart.Page.GetLinesChanged());
- end;
-
- ///
- /// Gets the completion status of the wizard.
- ///
- /// True if the wizard was completed successfully, false otherwise.
- procedure GetFinished(): Boolean
- begin
- exit(Finished);
- end;
-
- local procedure LoadBOMLines()
- begin
- if SelectedBOMNo = '' then
- exit;
-
- if not SubcVersionMgmt.CheckBOMExists(SelectedBOMNo, SelectedBOMVersion) then
- exit;
-
- SubcTempDataInitializer.LoadBOMLines(SelectedBOMNo, SelectedBOMVersion);
- end;
-
- local procedure LoadRoutingLines()
- begin
- if SelectedRoutingNo = '' then
- exit;
-
- if not SubcVersionMgmt.CheckRoutingExists(SelectedRoutingNo, SelectedRoutingVersion) then
- exit;
-
- SubcTempDataInitializer.LoadRoutingLines(SelectedRoutingNo, SelectedRoutingVersion);
- end;
-
- local procedure LoadTopBanners()
- begin
- if MediaRepositoryStandard.Get('AssistedSetup-NoText-400px.png', Format(CurrentClientType())) then
- if MediaResourcesStandard.Get(MediaRepositoryStandard."Media Resources Ref") then
- TopBannerVisible := MediaResourcesStandard."Media Reference".HasValue();
- end;
-
- local procedure SetBOMDataReference()
- var
- TempProductionBOMLine: Record "Production BOM Line" temporary;
- begin
- SubcTempDataInitializer.GetGlobalBOMLines(TempProductionBOMLine);
- CurrPage.BOMLinesPart.Page.SetTemporaryRecords(TempProductionBOMLine);
-
- SelectedBOMNo := TempProductionBOMLine."Production BOM No.";
- SelectedBOMVersion := TempProductionBOMLine."Version Code";
- end;
-
- local procedure SetRoutingDataReference()
- var
- TempRoutingLine: Record "Routing Line" temporary;
- begin
- SubcTempDataInitializer.GetGlobalRoutingLines(TempRoutingLine);
- CurrPage.RoutingLinesPart.Page.SetTemporaryRecords(TempRoutingLine);
-
- SelectedRoutingNo := TempRoutingLine."Routing No.";
- SelectedRoutingVersion := TempRoutingLine."Version Code";
- end;
-
- local procedure SetProdOrderDataReference()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- begin
- SubcTempDataInitializer.GetGlobalProdOrderComponent(TempProdOrderComponent);
- CurrPage.ComponentsPart.Page.SetTemporaryRecords(TempProdOrderComponent);
- SubcTempDataInitializer.GetGlobalProdOrderRoutingLine(TempProdOrderRoutingLine);
- CurrPage.ProdOrderRoutingPart.Page.SetTemporaryRecords(TempProdOrderRoutingLine);
- end;
-
- local procedure SetBOMRoutingEditable()
- begin
- EditBOMLines := not SubcVersionMgmt.CheckBOMExists(SelectedBOMNo, SelectedBOMVersion) and (BOMRoutingShowEditType = BOMRoutingShowEditType::Edit);
- EditRoutingLines := not SubcVersionMgmt.CheckRoutingExists(SelectedRoutingNo, SelectedRoutingVersion) and (BOMRoutingShowEditType = BOMRoutingShowEditType::Edit);
-
- CreateBOMVersionVisible := SubcVersionMgmt.CheckBOMExists(SelectedBOMNo, '') and (BOMRoutingShowEditType = BOMRoutingShowEditType::Edit);
- CreateRoutingVersionVisible := SubcVersionMgmt.CheckRoutingExists(SelectedRoutingNo, '') and (BOMRoutingShowEditType = BOMRoutingShowEditType::Edit);
- end;
-
- local procedure SetShowEditOptionsEnabled()
- var
- SubcManagementSetup: Record "Subc. Management Setup";
- begin
- SubcManagementSetup.SetLoadFields(AllowEditUISelection);
- SubcManagementSetup.Get();
- ShowEditOptionsEnabled := SubcManagementSetup.AllowEditUISelection;
- end;
-
- local procedure SetProdOrderPresetValuesInSubpages()
- var
- PresetBOMValues, PresetRoutingValues : Boolean;
- begin
- PresetBOMValues := not SubcVersionMgmt.CheckBOMExists(SelectedBOMNo, '');
- PresetRoutingValues := not SubcVersionMgmt.CheckRoutingExists(SelectedRoutingNo, '');
- CurrPage.ComponentsPart.Page.SetPresetSubValues(PresetBOMValues);
- CurrPage.ProdOrderRoutingPart.Page.SetPresetSubValues(PresetRoutingValues);
- end;
-
- local procedure NextStep(Backwards: Boolean)
- begin
- if Backwards then begin
- Step := Step - 1;
-
- if (Step = Step::ProdRouting) and (ProdCompRoutingShowEditType = ProdCompRoutingShowEditType::Hide) then
- Step := Step::Routing;
- if (Step = Step::Components) and (ProdCompRoutingShowEditType = ProdCompRoutingShowEditType::Hide) then
- Step := Step::Routing;
- if (Step = Step::Routing) and (BOMRoutingShowEditType = BOMRoutingShowEditType::Hide) then
- Step := Step::Intro;
- if (Step = Step::BOM) and (BOMRoutingShowEditType = BOMRoutingShowEditType::Hide) then
- Step := Step::Intro;
-
- end else begin
- Step := Step + 1;
-
- if (Step = Step::BOM) and (BOMRoutingShowEditType = BOMRoutingShowEditType::Hide) then
- Step := Step::Components;
- if (Step = Step::Routing) and (BOMRoutingShowEditType = BOMRoutingShowEditType::Hide) then
- Step := Step::Components;
-
- case Step of
- Step::Components:
- begin
- SubcTempDataInitializer.BuildTemporaryStructureFromBOMRouting();
- SetProdOrderPresetValuesInSubpages();
- end;
- end;
- end;
-
- if Step < Step::Intro then
- Step := Step::Intro;
- if Step > Step::ProdRouting then
- Step := Step::ProdRouting;
-
- EnableControls();
- end;
-
- local procedure EnableControls()
- begin
- ResetControls();
-
- case Step of
- Step::Intro:
- ShowIntroStep();
- Step::BOM:
- ShowBOMStep();
- Step::Routing:
- ShowRoutingStep();
- Step::Components:
- ShowComponentsStep();
- Step::ProdRouting:
- ShowProdRoutingStep();
- end;
- end;
-
- local procedure ResetControls()
- begin
- IntroStepVisible := false;
- BOMStepVisible := false;
- RoutingStepVisible := false;
- ComponentsStepVisible := false;
- ProdRoutingStepVisible := false;
-
- BackActionEnabled := true;
- NextActionEnabled := true;
- FinishActionEnabled := false;
- end;
-
- local procedure ShowIntroStep()
- begin
- IntroStepVisible := true;
- BackActionEnabled := false;
- end;
-
- local procedure ShowBOMStep()
- begin
- BOMStepVisible := true;
- end;
-
- local procedure ShowRoutingStep()
- begin
- RoutingStepVisible := true;
- if ProdCompRoutingShowEditType = ProdCompRoutingShowEditType::Hide then begin
- NextActionEnabled := false;
- FinishActionEnabled := true;
- end;
- end;
-
- local procedure ShowComponentsStep()
- begin
- ComponentsStepVisible := true;
- end;
-
- local procedure ShowProdRoutingStep()
- begin
- ProdRoutingStepVisible := true;
- NextActionEnabled := false;
- FinishActionEnabled := true;
- end;
-
- local procedure FinishAction()
- begin
- Finished := true;
- CurrPage.SetSelectionFilter(Rec);
- CurrPage.Close();
- end;
-
- local procedure InitBomRoutingSource()
- begin
- BomRtngFromSource := SubcTempDataInitializer.GetRtngBOMSourceType();
- case BomRtngFromSource of
- "Subc. RtngBOMSourceType"::Empty:
- BomRtngFromSourceTxt := SetupSourceLbl;
- else
- BomRtngFromSourceTxt := Format(BomRtngFromSource);
- end;
- end;
-}
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempBOMLines.Page.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempBOMLines.Page.al
deleted file mode 100644
index c23b9e3b5c..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempBOMLines.Page.al
+++ /dev/null
@@ -1,135 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Manufacturing.ProductionBOM;
-using Microsoft.Manufacturing.Setup;
-
-page 99001506 "Subc. Temp BOM Lines"
-{
- ApplicationArea = Manufacturing;
- AutoSplitKey = true;
- Caption = 'Temporary Production BOM Lines';
- DelayedInsert = true;
- PageType = ListPart;
- SourceTable = "Production BOM Line";
- SourceTableTemporary = true;
- UsageCategory = None;
-
- layout
- {
- area(Content)
- {
- repeater(BOMLines)
- {
- ShowCaption = false;
- field("Line No."; Rec."Line No.")
- {
- ToolTip = 'Specifies the line number for the production BOM line.';
- Visible = false;
- }
- field(Type; Rec.Type)
- {
- ToolTip = 'Specifies the type of the production BOM line.';
- }
- field("No."; Rec."No.")
- {
- ToolTip = 'Specifies the number of the item or resource.';
- }
- field(Description; Rec.Description)
- {
- ToolTip = 'Specifies a description of the item or resource.';
- }
- field("Description 2"; Rec."Description 2")
- {
- ApplicationArea = Manufacturing;
- ToolTip = 'Specifies additional description of the item or resource.';
- Visible = false;
- }
- field("Quantity per"; Rec."Quantity per")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies how many units of the component are required to produce the parent item.';
- }
- field("Unit of Measure Code"; Rec."Unit of Measure Code")
- {
- ToolTip = 'Specifies how each unit of the item or resource is measured.';
- }
- field("Scrap %"; Rec."Scrap %")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies the percentage of the item that you expect to be scrapped in the production process.';
- Visible = false;
- }
- field("Variant Code"; Rec."Variant Code")
- {
- ToolTip = 'Specifies the variant of the item on the line.';
- Visible = false;
- }
- field("Starting Date"; Rec."Starting Date")
- {
- ToolTip = 'Specifies the date from which this production BOM line is valid.';
- Visible = false;
- }
- field("Ending Date"; Rec."Ending Date")
- {
- ToolTip = 'Specifies the date until which this production BOM line is valid.';
- Visible = false;
- }
- field("Routing Link Code"; Rec."Routing Link Code")
- {
- ToolTip = 'Specifies the routing link code.';
- }
- field("Subcontracting Type"; Rec."Subcontracting Type")
- {
- ToolTip = 'Specifies the Type of Subcontracting that is assigned to the Production BOM Line.';
- ApplicationArea = Manufacturing;
- trigger OnValidate()
- begin
- if Rec."Subcontracting Type" = Rec."Subcontracting Type"::Purchase then
- Rec.FieldError("Subcontracting Type");
-
- if (Rec."Routing Link Code" = '') and (Rec."Subcontracting Type" <> Rec."Subcontracting Type"::Empty) then begin
- GetManufacturingSetup();
- Rec."Routing Link Code" := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
- end;
- end;
- }
- }
- }
- }
- trigger OnOpenPage()
- begin
- if Rec.FindFirst() then;
- end;
-
- trigger OnNewRecord(BelowxRec: Boolean)
- begin
- Rec."Production BOM No." := xRec."Production BOM No.";
- Rec."Version Code" := xRec."Version Code";
- Rec."Routing Link Code" := xRec."Routing Link Code";
- Rec."Subcontracting Type" := xRec."Subcontracting Type";
- GetManufacturingSetup();
- Rec."Routing Link Code" := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
- end;
-
- var
- ManufacturingSetup: Record "Manufacturing Setup";
- ManufacturingSetupRead: Boolean;
-
- procedure SetTemporaryRecords(var TempProductionBOMLine: Record "Production BOM Line" temporary)
- begin
- Rec.Copy(TempProductionBOMLine, true);
- end;
-
- local procedure GetManufacturingSetup()
- begin
- if not ManufacturingSetupRead then begin
- ManufacturingSetup.SetLoadFields("Rtng. Link Code Purch. Prov.");
- ManufacturingSetup.Get();
- ManufacturingSetupRead := true;
- end;
- end;
-}
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempProdOrdRtngLines.Page.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempProdOrdRtngLines.Page.al
deleted file mode 100644
index cce44a3e5f..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempProdOrdRtngLines.Page.al
+++ /dev/null
@@ -1,178 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.Setup;
-
-page 99001509 "Subc. TempProdOrdRtngLines"
-{
- ApplicationArea = Manufacturing;
- Caption = 'Temporary Prod. Order Routing Lines';
- DelayedInsert = true;
- PageType = ListPart;
- SourceTable = "Prod. Order Routing Line";
- SourceTableTemporary = true;
- UsageCategory = None;
-
- layout
- {
- area(Content)
- {
- repeater(ProdOrderRoutingLines)
- {
- ShowCaption = false;
- field("Operation No."; Rec."Operation No.")
- {
- ToolTip = 'Specifies the operation number for this routing line.';
- }
- field(Type; Rec.Type)
- {
- ToolTip = 'Specifies the type of operation.';
- }
- field("No."; Rec."No.")
- {
- ToolTip = 'Specifies the number of the work center or machine center.';
- }
- field(Description; Rec.Description)
- {
- ToolTip = 'Specifies a description of the operation.';
- }
- field("Description 2"; Rec."Description 2")
- {
- ApplicationArea = Manufacturing;
- ToolTip = 'Specifies additional description of the operation.';
- Visible = false;
- }
- field("Setup Time"; Rec."Setup Time")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies the setup time of the operation.';
- }
- field("Run Time"; Rec."Run Time")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies the run time of the operation.';
- }
- field("Wait Time"; Rec."Wait Time")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies the wait time after processing.';
- }
- field("Move Time"; Rec."Move Time")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies the move time.';
- }
- field("Routing Link Code"; Rec."Routing Link Code")
- {
- ToolTip = 'Specifies the routing link code.';
- }
- field("Flushing Method"; Rec."Flushing Method")
- {
- ToolTip = 'Specifies the flushing method for the operation.';
- }
- field("Work Center No."; Rec."Work Center No.")
- {
- ToolTip = 'Specifies the work center number.';
- }
- field("Input Quantity"; Rec."Input Quantity")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies the input quantity for the operation.';
- }
- field("Expected Operation Cost Amt."; Rec."Expected Operation Cost Amt.")
- {
- AutoFormatExpression = '';
- AutoFormatType = 1;
- ToolTip = 'Specifies the expected operation cost amount.';
- }
- field("Vendor No. Subc. Price"; Rec."Vendor No. Subc. Price")
- {
- ToolTip = 'Specifies the vendor number for subcontracting prices.';
- }
- }
- }
- }
- trigger OnNewRecord(BelowxRec: Boolean)
- begin
- Rec."Prod. Order No." := xRec."Prod. Order No.";
- Rec."Routing Reference No." := xRec."Routing Reference No.";
- Rec."Routing No." := xRec."Routing No.";
- Rec.Status := xRec.Status;
- Rec."Vendor No. Subc. Price" := xRec."Vendor No. Subc. Price";
-
- if PresetSubValues then begin
- GetManufacturingSetup();
- GetSubManagementSetup();
- Rec."Routing Link Code" := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
- Rec."Flushing Method" := SubcManagementSetup."Def. provision flushing method";
- end;
- end;
-
- protected var
- LinesChanged: Boolean;
-
- var
- ManufacturingSetup: Record "Manufacturing Setup";
- SubcManagementSetup: Record "Subc. Management Setup";
- PresetSubValues: Boolean;
- ManufacturingSetupRead: Boolean;
- SubManagementSetupRead: Boolean;
-
- trigger OnModifyRecord(): Boolean
- begin
- LinesChanged := true;
- end;
-
- trigger OnInsertRecord(BelowxRec: Boolean): Boolean
- begin
- LinesChanged := true;
- end;
-
- trigger OnDeleteRecord(): Boolean
- begin
- LinesChanged := true;
- end;
-
- trigger OnOpenPage()
- begin
- if Rec.FindFirst() then;
- end;
-
- procedure GetLinesChanged(): Boolean
- begin
- exit(LinesChanged);
- end;
-
- procedure SetTemporaryRecords(var TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary)
- begin
- Rec.Copy(TempProdOrderRoutingLine, true);
- if Rec.FindFirst() then;
- end;
-
- procedure SetPresetSubValues(Preset: Boolean)
- begin
- PresetSubValues := Preset;
- end;
-
- local procedure GetManufacturingSetup()
- begin
- if not ManufacturingSetupRead then begin
- ManufacturingSetup.SetLoadFields("Rtng. Link Code Purch. Prov.");
- ManufacturingSetup.Get();
- ManufacturingSetupRead := true;
- end;
- end;
-
- local procedure GetSubManagementSetup()
- begin
- if not SubManagementSetupRead then begin
- SubcManagementSetup.SetLoadFields("Def. provision flushing method");
- SubcManagementSetup.Get();
- SubManagementSetupRead := true;
- end;
- end;
-}
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempProdOrderComp.Page.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempProdOrderComp.Page.al
deleted file mode 100644
index 7def40c9b9..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempProdOrderComp.Page.al
+++ /dev/null
@@ -1,189 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.Setup;
-
-page 99001508 "Subc. Temp Prod Order Comp"
-{
- ApplicationArea = Manufacturing;
- AutoSplitKey = true;
- Caption = 'Temporary Prod. Order Components';
- DelayedInsert = true;
- MultipleNewLines = true;
- PageType = ListPart;
- SourceTable = "Prod. Order Component";
- SourceTableTemporary = true;
- UsageCategory = None;
-
- layout
- {
- area(Content)
- {
- repeater(Components)
- {
- ShowCaption = false;
- field("Item No."; Rec."Item No.")
- {
- ToolTip = 'Specifies the number of the item that is a component in the production order component list.';
-
- trigger OnValidate()
- begin
- if (xRec."Item No." = '') and (xRec."Item No." <> Rec."Item No.") then
- Rec.Validate("Flushing Method", xRec."Flushing Method");
- end;
- }
- field("Variant Code"; Rec."Variant Code")
- {
- ToolTip = 'Specifies the variant of the item on the line.';
- Visible = false;
- }
- field(Description; Rec.Description)
- {
- ToolTip = 'Specifies a description of the item on the line.';
- }
- field("Description 2"; Rec."Description 2")
- {
- ApplicationArea = Manufacturing;
- ToolTip = 'Specifies additional description of the item on the line.';
- Visible = false;
- }
- field("Location Code"; Rec."Location Code")
- {
- ToolTip = 'Specifies the location where the component is stored.';
- }
- field("Bin Code"; Rec."Bin Code")
- {
- ToolTip = 'Specifies the bin in which the component is to be placed before it is consumed.';
- Visible = false;
- }
- field("Quantity per"; Rec."Quantity per")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies how many units of the component are required to produce the parent item.';
- }
- field("Unit of Measure Code"; Rec."Unit of Measure Code")
- {
- ToolTip = 'Specifies how each unit of the item or resource is measured, such as in pieces or hours.';
- }
- field("Flushing Method"; Rec."Flushing Method")
- {
- ToolTip = 'Specifies how consumption of the item (component) is calculated and handled in production processes.';
- }
- field("Routing Link Code"; Rec."Routing Link Code")
- {
- ToolTip = 'Specifies the routing link code when you calculate the production order.';
- }
- field("Subcontracting Type"; Rec."Subcontracting Type")
- {
- ToolTip = 'Specifies the Type of Subcontracting that is assigned to the Production BOM Line.';
- trigger OnValidate()
- begin
- if Rec."Subcontracting Type" = Rec."Subcontracting Type"::Purchase then
- Rec.FieldError("Subcontracting Type");
-
- if (Rec."Routing Link Code" = '') and (Rec."Subcontracting Type" <> Rec."Subcontracting Type"::Empty) then begin
- GetManufacturingSetup();
- Rec."Routing Link Code" := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
- end;
-
- if Rec."Subcontracting Type" <> Rec."Subcontracting Type"::Transfer then
- Rec.Validate("Location Code", CopyStr(SubcSessionState.GetCode('SetSubcontractingLocationCodeFromVendor'), 1, MaxStrLen(Rec."Location Code")))
- else
- Rec.Validate("Location Code", Rec."Orig. Location Code");
- end;
- }
- field("Due Date"; Rec."Due Date")
- {
- ToolTip = 'Specifies the date when the produced item must be available.';
- Visible = false;
- }
- }
- }
- }
- trigger OnNewRecord(BelowxRec: Boolean)
- begin
- Rec."Prod. Order No." := xRec."Prod. Order No.";
- Rec."Prod. Order Line No." := xRec."Prod. Order Line No.";
- Rec.Status := xRec.Status;
- Rec."Routing Link Code" := xRec."Routing Link Code";
- Rec."Subcontracting Type" := xRec."Subcontracting Type";
- Rec."Location Code" := xRec."Location Code";
- Rec."Orig. Location Code" := xRec."Orig. Location Code";
-
- if PresetSubValues then begin
- GetSubManagementSetup();
- GetManufacturingSetup();
- Rec."Routing Link Code" := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
- Rec."Flushing Method" := SubcManagementSetup."Def. provision flushing method";
- end;
- end;
-
- trigger OnModifyRecord(): Boolean
- begin
- LinesChanged := true;
- end;
-
- trigger OnInsertRecord(BelowxRec: Boolean): Boolean
- begin
- LinesChanged := true;
- end;
-
- trigger OnDeleteRecord(): Boolean
- begin
- LinesChanged := true;
- end;
-
- trigger OnOpenPage()
- begin
- if Rec.FindFirst() then;
- end;
-
- protected var
- LinesChanged: Boolean;
-
- var
- SubcManagementSetup: Record "Subc. Management Setup";
- ManufacturingSetup: Record "Manufacturing Setup";
- SubcSessionState: Codeunit "Subc. Session State";
- PresetSubValues: Boolean;
- SubManagementSetupRead: Boolean;
- ManufacturingSetupRead: Boolean;
-
- procedure GetLinesChanged(): Boolean
- begin
- exit(LinesChanged);
- end;
-
- procedure SetTemporaryRecords(var TempProdOrderComponent: Record "Prod. Order Component" temporary)
- begin
- Rec.Copy(TempProdOrderComponent, true);
- if Rec.FindFirst() then;
- end;
-
- procedure SetPresetSubValues(Preset: Boolean)
- begin
- PresetSubValues := Preset;
- end;
-
- local procedure GetSubManagementSetup()
- begin
- if not SubManagementSetupRead then begin
- SubcManagementSetup.SetLoadFields("Def. provision flushing method");
- SubcManagementSetup.Get();
- SubManagementSetupRead := true;
- end;
- end;
-
- local procedure GetManufacturingSetup()
- begin
- if not ManufacturingSetupRead then begin
- ManufacturingSetup.SetLoadFields("Rtng. Link Code Purch. Prov.");
- ManufacturingSetup.Get();
- ManufacturingSetupRead := true;
- end;
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempRoutingLines.Page.al b/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempRoutingLines.Page.al
deleted file mode 100644
index f93dcb77b5..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Process/Prod Order Creation Wizard/Pages/SubcTempRoutingLines.Page.al
+++ /dev/null
@@ -1,111 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Manufacturing.Routing;
-using Microsoft.Manufacturing.Setup;
-
-page 99001507 "Subc. Temp Routing Lines"
-{
- ApplicationArea = Manufacturing;
- Caption = 'Temporary Routing Lines';
- DelayedInsert = true;
- PageType = ListPart;
- SourceTable = "Routing Line";
- SourceTableTemporary = true;
- UsageCategory = None;
-
- layout
- {
- area(Content)
- {
- repeater(RoutingLines)
- {
- ShowCaption = false;
- field("Operation No."; Rec."Operation No.")
- {
- ToolTip = 'Specifies the operation number for this routing line.';
- }
- field(Type; Rec.Type)
- {
- ToolTip = 'Specifies the type of operation.';
- }
- field("No."; Rec."No.")
- {
- ToolTip = 'Specifies the number of the work center or machine center.';
- }
- field(Description; Rec.Description)
- {
- ToolTip = 'Specifies a description of the operation.';
- }
- field("Description 2"; Rec."Description 2")
- {
- ApplicationArea = Manufacturing;
- ToolTip = 'Specifies additional description of the operation.';
- Visible = false;
- }
- field("Setup Time"; Rec."Setup Time")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies the setup time of the operation.';
- }
- field("Run Time"; Rec."Run Time")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies the run time of the operation.';
- }
- field("Wait Time"; Rec."Wait Time")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies the wait time after processing.';
- }
- field("Move Time"; Rec."Move Time")
- {
- AutoFormatType = 0;
- ToolTip = 'Specifies the move time.';
- }
- field("Routing Link Code"; Rec."Routing Link Code")
- {
- ToolTip = 'Specifies the routing link code.';
- }
- field("Work Center No."; Rec."Work Center No.")
- {
- ToolTip = 'Specifies the work center number.';
- }
- }
- }
- }
- trigger OnOpenPage()
- begin
- if Rec.FindFirst() then;
- end;
-
- trigger OnNewRecord(BelowxRec: Boolean)
- begin
- Rec."Routing No." := xRec."Routing No.";
- Rec."Version Code" := xRec."Version Code";
- GetManufacturingSetup();
- if Rec."Version Code" = '' then
- Rec."Routing Link Code" := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
- end;
-
- var
- ManufacturingSetup: Record "Manufacturing Setup";
- ManufacturingSetupRead: Boolean;
-
- procedure SetTemporaryRecords(var TempRoutingLine: Record "Routing Line" temporary)
- begin
- Rec.Copy(TempRoutingLine, true);
- end;
-
- local procedure GetManufacturingSetup()
- begin
- if not ManufacturingSetupRead then begin
- ManufacturingSetup.SetLoadFields("Rtng. Link Code Purch. Prov.");
- ManufacturingSetup.Get();
- ManufacturingSetupRead := true;
- end;
- end;
-}
diff --git a/src/Apps/W1/Subcontracting/App/src/Setup/Pages/SubcManagementSetup.Page.al b/src/Apps/W1/Subcontracting/App/src/Setup/Pages/SubcManagementSetup.Page.al
deleted file mode 100644
index 876142ec25..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Setup/Pages/SubcManagementSetup.Page.al
+++ /dev/null
@@ -1,115 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-page 99001510 "Subc. Management Setup"
-{
- ApplicationArea = Manufacturing;
- Caption = 'Subcontracting Setup';
- DeleteAllowed = false;
- InsertAllowed = false;
- PageType = Card;
- SourceTable = "Subc. Management Setup";
- UsageCategory = Administration;
- layout
- {
- area(Content)
- {
- group(Provision)
- {
- Caption = 'Purchase Provision';
- field("Preset Component Item No."; Rec."Preset Component Item No.")
- {
- ToolTip = 'Specifies the item number of the preset component for purchase provision. This item will be used as a default when creating a purchase provision.';
- }
- field("Common Work Center No."; Rec."Common Work Center No.")
- {
- ToolTip = 'Specifies the value of the Common Work Center No. for purchase provision.';
- }
- field("Put-Away Work Center No."; Rec."Put-Away Work Center No.")
- {
- ToolTip = 'Specifies the work center number used for put-away operations in purchase provision. A second generic production order routing line is created for the put-away of the provision components.';
- }
- field("Default Provision Flushing Method"; Rec."Def. provision flushing method")
- {
- ToolTip = 'Specifies the default flushing method used for purchase provision components. This determines how component consumption is automatically posted during production.';
- }
- }
- group("Prod. Order Create UI")
- {
- Caption = 'Purchase Provision Wizard UI';
-
- field("Save Modified Versions"; Rec."Always Save Modified Versions")
- {
- ToolTip = 'Specifies whether modified versions of the routing and BOM should be saved when creating a production order.';
- }
- field(AllowEditUISelection; Rec.AllowEditUISelection)
- {
- ToolTip = 'Specifies whether the user can change display and editing options for BOM and routing steps in the wizard. If turned on, users can hide, show, or edit details. If turned off, the options from setup are applied without user changes.';
- }
- group("Both Available")
- {
- Caption = 'Both Routing and BOM Available';
- field(ShowRtngBOMSelect_Both; Rec.ShowRtngBOMSelect_Both)
- {
- Caption = 'BOM/Routing';
- ToolTip = 'Specifies how the Routing/BOM selection dialog should be shown when both routing and BOM are available on the item.';
- }
- field(ShowProdRtngCompSelect_Both; Rec.ShowProdRtngCompSelect_Both)
- {
- Caption = 'Prod. Components/Prod. Operations';
- ToolTip = 'Specifies how the production routing and component selection should be shown when both routing and BOM are available.';
- }
- }
- group("Partially Available")
- {
- Caption = 'Routing or BOM Partially Available';
- field(ShowRtngBOMSelect_Partial; Rec.ShowRtngBOMSelect_Partial)
- {
- Caption = 'BOM/Routing';
- ToolTip = 'Specifies how the Routing/BOM selection dialog should be shown when only routing or BOM is available on the item.';
- }
- field(ShowProdRtngCompSelect_Partial; Rec.ShowProdRtngCompSelect_Partial)
- {
- Caption = 'Prod. Components/Prod. Operations';
- ToolTip = 'Specifies how the production routing and component selection should be shown when only routing or BOM is available.';
- }
- }
- group("Nothing Available")
- {
- Caption = 'Neither Routing nor BOM Available';
- field(ShowRtngBOMSelect_Nothing; Rec.ShowRtngBOMSelect_Nothing)
- {
- Caption = 'BOM/Routing';
- ToolTip = 'Specifies how the Routing/BOM selection dialog should be shown when neither routing nor BOM is available on the item.';
- }
- field(ShowProdRtngCompSelect_Nothing; Rec.ShowProdRtngCompSelect_Nothing)
- {
- Caption = 'Prod. Components/Prod. Operations';
- ToolTip = 'Specifies how the production routing and component selection should be shown when neither routing nor BOM is available.';
- }
- }
- }
- }
- area(FactBoxes)
- {
- systempart(SystemPartNotes; Notes)
- {
- Visible = false;
- }
- systempart(SystemPartLinks; Links)
- {
- Visible = false;
- }
- }
- }
- trigger OnOpenPage()
- begin
- if not Rec.Get() then begin
- Rec.Init();
- Rec.Insert();
- end;
- end;
-}
diff --git a/src/Apps/W1/Subcontracting/App/src/Setup/Tables/SubcManagementSetup.Table.al b/src/Apps/W1/Subcontracting/App/src/Setup/Tables/SubcManagementSetup.Table.al
deleted file mode 100644
index 98c0b5b795..0000000000
--- a/src/Apps/W1/Subcontracting/App/src/Setup/Tables/SubcManagementSetup.Table.al
+++ /dev/null
@@ -1,100 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting;
-
-using Microsoft.Inventory.Item;
-using Microsoft.Manufacturing.Setup;
-using Microsoft.Manufacturing.WorkCenter;
-
-table 99001501 "Subc. Management Setup"
-{
- AllowInCustomizations = AsReadOnly;
- Caption = 'Subcontracting Setup';
- DataClassification = CustomerContent;
- fields
- {
- field(1; "Primary Key"; Code[10])
- {
- Caption = 'Primary Key';
- }
- field(100; "Common Work Center No."; Code[20])
- {
- Caption = 'Common Work Center No.';
- TableRelation = "Work Center";
- }
- field(110; "Def. provision flushing method"; Enum "Flushing Method Routing")
- {
- Caption = 'Default flushing method purchase provision';
- }
- field(200; ShowRtngBOMSelect_Both; Enum "Subc. Show/Edit Type")
- {
- Caption = 'Routing/BOM Selection - Both';
- }
- field(210; ShowProdRtngCompSelect_Both; Enum "Subc. Show/Edit Type")
- {
- Caption = 'Show Prod. Routing/Component Selection - Both';
- }
- field(220; ShowRtngBOMSelect_Partial; Enum "Subc. Show/Edit Type")
- {
- Caption = 'Routing/BOM Selection - Partial';
- }
- field(230; ShowProdRtngCompSelect_Partial; Enum "Subc. Show/Edit Type")
- {
- Caption = 'Show Prod. Routing/Component Selection - Partial';
- }
- field(240; ShowRtngBOMSelect_Nothing; Enum "Subc. Show/Edit Type")
- {
- Caption = 'Routing/BOM Selection - Nothing';
- }
- field(250; ShowProdRtngCompSelect_Nothing; Enum "Subc. Show/Edit Type")
- {
- Caption = 'Show Prod. Routing/Component Selection - Nothing';
- }
- field(260; "Always Save Modified Versions"; Boolean)
- {
- Caption = 'Always Save Modified Versions';
- }
- field(270; "Put-Away Work Center No."; Code[20])
- {
- Caption = 'Put-Away Work Center No.';
- TableRelation = "Work Center";
- }
- field(280; AllowEditUISelection; Boolean)
- {
- Caption = 'Allow Edit UI Selection';
- }
- field(290; "Preset Component Item No."; Code[20])
- {
- Caption = 'Preset Component Item No.';
- TableRelation = Item;
- }
- }
- keys
- {
- key(PK; "Primary Key")
- {
- Clustered = true;
- }
- }
- fieldgroups
- {
- fieldgroup(DropDown; "Primary Key")
- {
- }
- fieldgroup(Brick; "Primary Key")
- {
- }
- }
- procedure ItemChargeToRcptSubReferenceEnabled(): Boolean
- var
- ManufacturingSetup: Record "Manufacturing Setup";
- begin
- ManufacturingSetup.SetLoadFields(RefItemChargeToRcptSubLines);
- if not ManufacturingSetup.Get() then
- exit(false);
-
- exit(ManufacturingSetup.RefItemChargeToRcptSubLines);
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/App/src/Setup/Tables/SubcManufacturingSetup.TableExt.al b/src/Apps/W1/Subcontracting/App/src/Setup/Tables/SubcManufacturingSetup.TableExt.al
index 6a1e4dfbfc..5b0fd1a678 100644
--- a/src/Apps/W1/Subcontracting/App/src/Setup/Tables/SubcManufacturingSetup.TableExt.al
+++ b/src/Apps/W1/Subcontracting/App/src/Setup/Tables/SubcManufacturingSetup.TableExt.al
@@ -87,4 +87,15 @@ tableextension 99001501 "Subc. Manufacturing Setup" extends "Manufacturing Setup
DataClassification = CustomerContent;
}
}
+
+ internal procedure ItemChargeToRcptSubReferenceEnabled(): Boolean
+ var
+ ManufacturingSetup: Record "Manufacturing Setup";
+ begin
+ ManufacturingSetup.SetLoadFields(RefItemChargeToRcptSubLines);
+ if not ManufacturingSetup.Get() then
+ exit(false);
+
+ exit(ManufacturingSetup.RefItemChargeToRcptSubLines);
+ end;
}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcManagementLibrary.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcManagementLibrary.Codeunit.al
index 10621b0f43..f52e4f505e 100644
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcManagementLibrary.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcManagementLibrary.Codeunit.al
@@ -25,12 +25,11 @@ codeunit 139983 "Subc. Management Library"
procedure CreateSubcontractingManagementSetup()
var
- SubcontractingManagementSetup: Record "Subc. Management Setup";
+ ManufacturingSetup: Record "Manufacturing Setup";
begin
- SubcontractingManagementSetup.Reset();
- if not SubcontractingManagementSetup.Get() then begin
- SubcontractingManagementSetup.Init();
- SubcontractingManagementSetup.Insert(true);
+ if not ManufacturingSetup.Get() then begin
+ ManufacturingSetup.Init();
+ ManufacturingSetup.Insert(true);
end;
end;
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcProdOrderCheckLib.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcProdOrderCheckLib.Codeunit.al
index a936d516f5..16c86b8317 100644
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcProdOrderCheckLib.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcProdOrderCheckLib.Codeunit.al
@@ -5,20 +5,12 @@
namespace Microsoft.Manufacturing.Subcontracting.Test;
using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.MachineCenter;
-using Microsoft.Manufacturing.ProductionBOM;
-using Microsoft.Manufacturing.Routing;
-using Microsoft.Manufacturing.Setup;
-using Microsoft.Manufacturing.Subcontracting;
-using Microsoft.Manufacturing.WorkCenter;
using Microsoft.Purchases.Document;
-using Microsoft.Purchases.Vendor;
codeunit 139987 "Subc. ProdOrderCheckLib"
{
var
Assert: Codeunit Assert;
- ProdOrderRefreshed: Boolean;
Description2MismatchOnLineLbl: Label 'Description 2 mismatch on Line %1. Expected: %2, Actual: %3', Locked = true;
Description2MismatchOnOperationLbl: Label 'Description 2 mismatch on Operation %1. Expected: %2, Actual: %3', Locked = true;
DescriptionMismatchOnOperationLbl: Label 'Description mismatch on Operation %1. Expected: %2, Actual: %3', Locked = true;
@@ -45,70 +37,6 @@ codeunit 139987 "Subc. ProdOrderCheckLib"
WorkCenterGroupCodeMismatchOnOperationLbl: Label 'Work Center Group Code mismatch on Operation %1. Expected: %2, Actual: %3', Locked = true;
WorkCenterNoMismatchOnOperationLbl: Label 'Work Center No. mismatch on Operation %1. Expected: %2, Actual: %3', Locked = true;
- procedure CreateTempProdOrderComponentFromSetup(var TempProdOrderComponent: Record "Prod. Order Component" temporary; PurchLine: Record "Purchase Line")
- var
- TempProdOrderComponent2: Record "Prod. Order Component" temporary;
- ManufacturingSetup: Record "Manufacturing Setup";
- SubManagementSetup: Record "Subc. Management Setup";
- LineNo: Integer;
- begin
- // Fill temporary Production Order Component from setup configuration
- SubManagementSetup.Get();
- ManufacturingSetup.Get();
-
- TempProdOrderComponent2.Copy(TempProdOrderComponent, true);
- if TempProdOrderComponent2.FindLast() then
- LineNo := TempProdOrderComponent2."Line No." + 10000
- else
- LineNo := 10000;
-
- TempProdOrderComponent.Init();
- TempProdOrderComponent."Line No." := LineNo;
- TempProdOrderComponent."Item No." := SubManagementSetup."Preset Component Item No.";
- TempProdOrderComponent."Location Code" := GetVendorSubcontractingLocation(PurchLine."Buy-from Vendor No.");
- TempProdOrderComponent."Routing Link Code" := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
- TempProdOrderComponent."Flushing Method" := SubManagementSetup."Def. provision flushing method";
-
- TempProdOrderComponent.Insert();
- end;
-
- local procedure GetVendorSubcontractingLocation(VendorNo: Code[20]): Code[10]
- var
- Vendor: Record Vendor;
- begin
- if Vendor.Get(VendorNo) then
- exit(Vendor."Subcontr. Location Code");
- exit('');
- end;
-
- procedure CreateTempProdOrderRoutingFromSetup(var TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary; OperationNo: Code[10])
- var
- SubManagementSetup: Record "Subc. Management Setup";
- ManufacturingSetup: Record "Manufacturing Setup";
- WorkCenter: Record "Work Center";
- begin
- SubManagementSetup.Get();
- ManufacturingSetup.Get();
-
- TempProdOrderRoutingLine.Init();
- TempProdOrderRoutingLine."Operation No." := OperationNo;
- TempProdOrderRoutingLine.Type := TempProdOrderRoutingLine.Type::"Work Center";
- TempProdOrderRoutingLine."No." := SubManagementSetup."Common Work Center No.";
- TempProdOrderRoutingLine."Routing Link Code" := ManufacturingSetup."Rtng. Link Code Purch. Prov.";
-
- if SubManagementSetup."Common Work Center No." <> '' then
- if WorkCenter.Get(SubManagementSetup."Common Work Center No.") then begin
- TempProdOrderRoutingLine."Work Center No." := WorkCenter."No.";
- TempProdOrderRoutingLine."Unit Cost Calculation" := WorkCenter."Unit Cost Calculation";
- TempProdOrderRoutingLine."Direct Unit Cost" := WorkCenter."Direct Unit Cost";
- TempProdOrderRoutingLine."Indirect Cost %" := WorkCenter."Indirect Cost %";
- TempProdOrderRoutingLine."Overhead Rate" := WorkCenter."Overhead Rate";
- TempProdOrderRoutingLine."Flushing Method" := SubManagementSetup."Def. provision flushing method";
- end;
-
- TempProdOrderRoutingLine.Insert();
- end;
-
procedure VerifyProdOrder(PurchLine: Record "Purchase Line"; var ProdOrder: Record "Production Order")
begin
PurchLine.SetLoadFields("Prod. Order No.", Quantity);
@@ -303,188 +231,4 @@ codeunit 139987 "Subc. ProdOrderCheckLib"
StrSubstNo(Description2MismatchOnOperationLbl,
TempRoutingLine."Operation No.", TempRoutingLine."Description 2", ActualRoutingLine."Description 2"));
end;
-
- procedure CreateTempProdOrderComponentFromBOM(var TempProdOrderComponent: Record "Prod. Order Component" temporary; BOMNo: Code[20]; PurchLine: Record "Purchase Line")
- var
- SubManagementSetup: Record "Subc. Management Setup";
- ProductionBOMLine: Record "Production BOM Line";
- LineNo: Integer;
- begin
- // Create temporary Production Order Components based on BOM lines
- TempProdOrderComponent.Reset();
- TempProdOrderComponent.DeleteAll();
- if TempProdOrderComponent.FindLast() then
- LineNo := TempProdOrderComponent."Line No."
- else
- LineNo := 0;
-
- SubManagementSetup.SetLoadFields("Def. provision flushing method");
- SubManagementSetup.Get();
-
- ProductionBOMLine.SetRange("Production BOM No.", BOMNo);
- ProductionBOMLine.SetRange(Type, ProductionBOMLine.Type::Item);
- if ProductionBOMLine.FindSet() then
- repeat
- LineNo += 10000;
- TempProdOrderComponent.Init();
- TempProdOrderComponent."Line No." := LineNo;
- TempProdOrderComponent."Item No." := ProductionBOMLine."No.";
- TempProdOrderComponent."Quantity per" := ProductionBOMLine."Quantity per";
- TempProdOrderComponent."Unit of Measure Code" := ProductionBOMLine."Unit of Measure Code";
- TempProdOrderComponent."Routing Link Code" := ProductionBOMLine."Routing Link Code";
- TempProdOrderComponent."Description 2" := ProductionBOMLine."Description 2";
- if ProductionBOMLine."Subcontracting Type" in [ProductionBOMLine."Subcontracting Type"::"Purchase", ProductionBOMLine."Subcontracting Type"::InventoryByVendor] then
- TempProdOrderComponent."Location Code" := GetVendorSubcontractingLocation(PurchLine."Buy-from Vendor No.")
- else
- TempProdOrderComponent."Location Code" := PurchLine."Location Code";
- if ProdOrderRefreshed then
- TempProdOrderComponent."Flushing Method" := "Flushing Method"::"Pick + Manual"
- else
- TempProdOrderComponent."Flushing Method" := SubManagementSetup."Def. provision flushing method";
- TempProdOrderComponent.Insert();
- until ProductionBOMLine.Next() = 0;
- end;
-
- procedure CreateTempProdOrderComponentFromBOMVersion(var TempProdOrderComponent: Record "Prod. Order Component" temporary; BOMNo: Code[20]; BOMVersionNo: Code[20]; PurchLine: Record "Purchase Line")
- var
- ProductionBOMLine: Record "Production BOM Line";
- LineNo: Integer;
- begin
- // Create temporary Production Order Components based on BOM Version lines
- TempProdOrderComponent.Reset();
- if TempProdOrderComponent.FindLast() then
- LineNo := TempProdOrderComponent."Line No."
- else
- LineNo := 0;
-
- ProductionBOMLine.SetRange("Production BOM No.", BOMNo);
- ProductionBOMLine.SetRange("Version Code", BOMVersionNo);
- if ProductionBOMLine.FindSet() then
- repeat
- LineNo += 10000;
- TempProdOrderComponent.Init();
- TempProdOrderComponent."Line No." := LineNo;
- TempProdOrderComponent."Item No." := ProductionBOMLine."No.";
- TempProdOrderComponent."Quantity per" := ProductionBOMLine."Quantity per";
- TempProdOrderComponent."Unit of Measure Code" := ProductionBOMLine."Unit of Measure Code";
- TempProdOrderComponent."Routing Link Code" := ProductionBOMLine."Routing Link Code";
- // Set default flushing method and location code from setup or defaults
- TempProdOrderComponent."Location Code" := PurchLine."Location Code";
- TempProdOrderComponent."Flushing Method" := "Flushing Method"::"Pick + Manual";
- TempProdOrderComponent.Insert();
- until ProductionBOMLine.Next() = 0;
- end;
-
- procedure CreateTempProdOrderRoutingFromRouting(var TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary; RoutingNo: Code[20])
- var
- MachineCenter: Record "Machine Center";
- RoutingLine: Record "Routing Line";
- WorkCenter: Record "Work Center";
- begin
- // Create temporary Production Order Routing Lines based on Routing lines
- TempProdOrderRoutingLine.Reset();
- TempProdOrderRoutingLine.DeleteAll();
-
- RoutingLine.SetRange("Routing No.", RoutingNo);
- if RoutingLine.FindSet() then
- repeat
- TempProdOrderRoutingLine.Init();
- TempProdOrderRoutingLine."Operation No." := RoutingLine."Operation No.";
- TempProdOrderRoutingLine.Type := RoutingLine.Type;
- TempProdOrderRoutingLine."No." := RoutingLine."No.";
- TempProdOrderRoutingLine.Description := RoutingLine.Description;
- TempProdOrderRoutingLine."Description 2" := RoutingLine."Description 2";
- TempProdOrderRoutingLine."Setup Time" := RoutingLine."Setup Time";
- TempProdOrderRoutingLine."Run Time" := RoutingLine."Run Time";
- TempProdOrderRoutingLine."Wait Time" := RoutingLine."Wait Time";
- TempProdOrderRoutingLine."Move Time" := RoutingLine."Move Time";
- TempProdOrderRoutingLine."Routing Link Code" := RoutingLine."Routing Link Code";
-
- // Set Work Center specific fields
- case RoutingLine.Type of
- RoutingLine.Type::"Work Center":
- if WorkCenter.Get(RoutingLine."No.") then begin
- TempProdOrderRoutingLine."Work Center No." := WorkCenter."No.";
- TempProdOrderRoutingLine."Unit Cost Calculation" := WorkCenter."Unit Cost Calculation";
- TempProdOrderRoutingLine."Direct Unit Cost" := WorkCenter."Direct Unit Cost";
- TempProdOrderRoutingLine."Indirect Cost %" := WorkCenter."Indirect Cost %";
- TempProdOrderRoutingLine."Overhead Rate" := WorkCenter."Overhead Rate";
- TempProdOrderRoutingLine."Flushing Method" := WorkCenter."Flushing Method";
- end;
- RoutingLine.Type::"Machine Center":
- if MachineCenter.Get(RoutingLine."No.") then begin
- TempProdOrderRoutingLine."Work Center No." := MachineCenter."Work Center No.";
- if WorkCenter.Get(MachineCenter."Work Center No.") then begin
- TempProdOrderRoutingLine."Unit Cost Calculation" := WorkCenter."Unit Cost Calculation";
- TempProdOrderRoutingLine."Direct Unit Cost" := MachineCenter."Direct Unit Cost";
- TempProdOrderRoutingLine."Indirect Cost %" := MachineCenter."Indirect Cost %";
- TempProdOrderRoutingLine."Overhead Rate" := MachineCenter."Overhead Rate";
- TempProdOrderRoutingLine."Flushing Method" := MachineCenter."Flushing Method";
- end;
- end;
- end;
-
- TempProdOrderRoutingLine.Insert();
- until RoutingLine.Next() = 0;
- end;
-
- procedure CreateTempProdOrderRoutingFromRoutingVersion(var TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary; RoutingNo: Code[20]; VersionCode: Code[20])
- var
- MachineCenter: Record "Machine Center";
- RoutingLine: Record "Routing Line";
- WorkCenter: Record "Work Center";
- begin
- // Create temporary Production Order Routing Lines based on Routing Version lines
- TempProdOrderRoutingLine.Reset();
- TempProdOrderRoutingLine.DeleteAll();
-
- RoutingLine.SetRange("Routing No.", RoutingNo);
- RoutingLine.SetRange("Version Code", VersionCode);
- if RoutingLine.FindSet() then
- repeat
- TempProdOrderRoutingLine.Init();
- TempProdOrderRoutingLine."Operation No." := RoutingLine."Operation No.";
- TempProdOrderRoutingLine.Type := RoutingLine.Type;
- TempProdOrderRoutingLine."No." := RoutingLine."No.";
- TempProdOrderRoutingLine.Description := RoutingLine.Description;
- TempProdOrderRoutingLine."Setup Time" := RoutingLine."Setup Time";
- TempProdOrderRoutingLine."Run Time" := RoutingLine."Run Time";
- TempProdOrderRoutingLine."Wait Time" := RoutingLine."Wait Time";
- TempProdOrderRoutingLine."Move Time" := RoutingLine."Move Time";
- TempProdOrderRoutingLine."Routing Link Code" := RoutingLine."Routing Link Code";
-
- // Set Work Center specific fields
- case RoutingLine.Type of
- RoutingLine.Type::"Work Center":
- if WorkCenter.Get(RoutingLine."No.") then begin
- TempProdOrderRoutingLine."Work Center No." := WorkCenter."No.";
- TempProdOrderRoutingLine."Work Center Group Code" := WorkCenter."Work Center Group Code";
- TempProdOrderRoutingLine."Unit Cost Calculation" := WorkCenter."Unit Cost Calculation";
- TempProdOrderRoutingLine."Direct Unit Cost" := WorkCenter."Direct Unit Cost";
- TempProdOrderRoutingLine."Indirect Cost %" := WorkCenter."Indirect Cost %";
- TempProdOrderRoutingLine."Overhead Rate" := WorkCenter."Overhead Rate";
- TempProdOrderRoutingLine."Flushing Method" := WorkCenter."Flushing Method";
- end;
- RoutingLine.Type::"Machine Center":
- if MachineCenter.Get(RoutingLine."No.") then begin
- TempProdOrderRoutingLine."Work Center No." := MachineCenter."Work Center No.";
- if WorkCenter.Get(MachineCenter."Work Center No.") then begin
- TempProdOrderRoutingLine."Work Center Group Code" := WorkCenter."Work Center Group Code";
- TempProdOrderRoutingLine."Unit Cost Calculation" := WorkCenter."Unit Cost Calculation";
- TempProdOrderRoutingLine."Direct Unit Cost" := MachineCenter."Direct Unit Cost";
- TempProdOrderRoutingLine."Indirect Cost %" := MachineCenter."Indirect Cost %";
- TempProdOrderRoutingLine."Overhead Rate" := MachineCenter."Overhead Rate";
- TempProdOrderRoutingLine."Flushing Method" := MachineCenter."Flushing Method";
- end;
- end;
- end;
-
- TempProdOrderRoutingLine.Insert();
- until RoutingLine.Next() = 0;
- end;
-
- procedure SetRefreshedProdOrder(RefreshProdOrder: Boolean)
- begin
- ProdOrderRefreshed := RefreshProdOrder;
- end;
}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcSetupLibrary.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcSetupLibrary.Codeunit.al
index 2545e67efe..4b5cda791e 100644
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcSetupLibrary.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcSetupLibrary.Codeunit.al
@@ -7,7 +7,6 @@ namespace Microsoft.Manufacturing.Subcontracting.Test;
using Microsoft.Inventory.Item;
using Microsoft.Manufacturing.Routing;
using Microsoft.Manufacturing.Setup;
-using Microsoft.Manufacturing.Subcontracting;
using Microsoft.Manufacturing.WorkCenter;
codeunit 139988 "Subc. Setup Library"
@@ -21,7 +20,7 @@ codeunit 139988 "Subc. Setup Library"
var
Item: Record Item;
RoutingLink: Record "Routing Link";
- SubManagementSetup: Record "Subc. Management Setup";
+ ManufacturingSetup2: Record "Manufacturing Setup";
ManufacturingSetup: Record "Manufacturing Setup";
WorkCenter: Record "Work Center";
begin
@@ -31,28 +30,14 @@ codeunit 139988 "Subc. Setup Library"
// Create routing link for purchase provisioning
LibraryManufacturing.CreateRoutingLink(RoutingLink);
- if not SubManagementSetup.Get() then begin
- SubManagementSetup.Init();
- SubManagementSetup.Insert();
+ if not ManufacturingSetup2.Get() then begin
+ ManufacturingSetup2.Init();
+ ManufacturingSetup2.Insert();
end;
LibraryInventory.CreateItem(Item);
// Set required fields for production order creation
- SubManagementSetup."Common Work Center No." := WorkCenter."No.";
- SubManagementSetup."Def. provision flushing method" := "Flushing Method Routing"::Backward;
- SubManagementSetup."Preset Component Item No." := Item."No.";
-
- // Set all Select fields to Edit as default
- SubManagementSetup.ShowRtngBOMSelect_Nothing := SubManagementSetup.ShowRtngBOMSelect_Nothing::Edit;
- SubManagementSetup.ShowRtngBOMSelect_Partial := SubManagementSetup.ShowRtngBOMSelect_Partial::Edit;
- SubManagementSetup.ShowRtngBOMSelect_Both := SubManagementSetup.ShowRtngBOMSelect_Both::Edit;
- SubManagementSetup.ShowProdRtngCompSelect_Nothing := SubManagementSetup.ShowProdRtngCompSelect_Nothing::Edit;
- SubManagementSetup.ShowProdRtngCompSelect_Partial := SubManagementSetup.ShowProdRtngCompSelect_Partial::Edit;
- SubManagementSetup.ShowProdRtngCompSelect_Both := SubManagementSetup.ShowProdRtngCompSelect_Both::Edit;
-
- SubManagementSetup.Modify();
-
if not ManufacturingSetup.Get() then begin
ManufacturingSetup.Init();
ManufacturingSetup.Insert();
@@ -63,45 +48,6 @@ codeunit 139988 "Subc. Setup Library"
ManufacturingSetup.Modify();
end;
- procedure ConfigureSubManagementForNothingPresentScenario(ShowRtngBOMSelect: Enum "Subc. Show/Edit Type"; ShowProdRtngCompSelect: Enum "Subc. Show/Edit Type")
- var
- SubManagementSetup: Record "Subc. Management Setup";
- begin
- SubManagementSetup.Get();
-
- // Configure for NothingPresent scenario
- SubManagementSetup.ShowRtngBOMSelect_Nothing := ShowRtngBOMSelect;
- SubManagementSetup.ShowProdRtngCompSelect_Nothing := ShowProdRtngCompSelect;
-
- SubManagementSetup.Modify();
- end;
-
- procedure ConfigureSubManagementForPartiallyPresentScenario(ShowRtngBOMSelect: Enum "Subc. Show/Edit Type"; ShowProdRtngCompSelect: Enum "Subc. Show/Edit Type")
- var
- SubManagementSetup: Record "Subc. Management Setup";
- begin
- SubManagementSetup.Get();
-
- // Configure for PartiallyPresent scenario
- SubManagementSetup.ShowRtngBOMSelect_Partial := ShowRtngBOMSelect;
- SubManagementSetup.ShowProdRtngCompSelect_Partial := ShowProdRtngCompSelect;
-
- SubManagementSetup.Modify();
- end;
-
- procedure ConfigureSubManagementForBothPresentScenario(ShowRtngBOMSelect: Enum "Subc. Show/Edit Type"; ShowProdRtngCompSelect: Enum "Subc. Show/Edit Type")
- var
- SubManagementSetup: Record "Subc. Management Setup";
- begin
- SubManagementSetup.Get();
-
- // Configure for BothPresent scenario
- SubManagementSetup.ShowRtngBOMSelect_Both := ShowRtngBOMSelect;
- SubManagementSetup.ShowProdRtngCompSelect_Both := ShowProdRtngCompSelect;
-
- SubManagementSetup.Modify();
- end;
-
internal procedure InitialSetupForGenProdPostingGroup()
var
GenProdPostingGroup1: Record Microsoft.Finance.GeneralLedger.Setup."Gen. Product Posting Group";
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcTSTWizComp.PageExt.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcTSTWizComp.PageExt.al
deleted file mode 100644
index 480f2b7b3e..0000000000
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcTSTWizComp.PageExt.al
+++ /dev/null
@@ -1,29 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting.Test;
-
-using Microsoft.Manufacturing.Subcontracting;
-
-pageextension 139981 "Subc. TST WizComp" extends "Subc. Temp Prod Order Comp"
-{
- actions
- {
- addlast(Processing)
- {
- action("Sub Delete")
- {
- ApplicationArea = All;
- Caption = 'Delete';
- Image = Delete;
- ToolTip = 'Delete the current record.';
- trigger OnAction()
- begin
- Rec.Delete(true);
- LinesChanged := true;
- end;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcTSTWizProdRtng.PageExt.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcTSTWizProdRtng.PageExt.al
deleted file mode 100644
index 579ce48d16..0000000000
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Libraries/SubcTSTWizProdRtng.PageExt.al
+++ /dev/null
@@ -1,29 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting.Test;
-
-using Microsoft.Manufacturing.Subcontracting;
-
-pageextension 139982 "Subc. TST WizProdRtng" extends "Subc. TempProdOrdRtngLines"
-{
- actions
- {
- addlast(Processing)
- {
- action("Sub Delete")
- {
- ApplicationArea = All;
- Caption = 'Delete';
- Image = Delete;
- ToolTip = 'Delete the current record.';
- trigger OnAction()
- begin
- Rec.Delete(true);
- LinesChanged := true;
- end;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcLocationHandlerTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcLocationHandlerTest.Codeunit.al
index 727b14b68f..a57e090a83 100644
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcLocationHandlerTest.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcLocationHandlerTest.Codeunit.al
@@ -42,11 +42,9 @@ codeunit 139981 "Subc. Location Handler Test"
LibraryTestInitialize: Codeunit "Library - Test Initialize";
LibraryWarehouse: Codeunit "Library - Warehouse";
SubcontractingMgmtLibrary: Codeunit "Subc. Management Library";
- SubCreateProdOrdWizLibrary: Codeunit "Subc. CreateProdOrdWizLibrary";
SubSetupLibrary: Codeunit "Subc. Setup Library";
SubcWarehouseLibrary: Codeunit "Subc. Warehouse Library";
IsInitialized: Boolean;
- WizardFinishedSuccessfully: Boolean;
CreateSubcontractingOrderAnywayQst: Label 'Do you want to create the Subcontracting Order anyway?';
local procedure Initialize()
@@ -287,63 +285,6 @@ codeunit 139981 "Subc. Location Handler Test"
Assert.AreEqual(QtyRemaining, TransferLine.Quantity, 'Second Transfer Quantity should be remaining quantity');
end;
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizard')]
- procedure TestProdOrderLocationFromMfgSetup_PurchaseLocationMustBeDifferent()
- var
- LocationMfg: Record Location;
- ManufacturingSetup: Record "Manufacturing Setup";
- ProdOrder: Record "Production Order";
- ProdOrderLine: Record "Prod. Order Line";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO] When location code from Manufacturing Setup is used in Production Order,
- // the Purchase Location Code must be different
- // [GIVEN] proper setup configuration with Manufacturing location
- Initialize();
-
- // [GIVEN] Sub Management Setup "Subc. Default Comp. Location" is Manufacturing
- UpdateSubManagementSetup("Components at Location"::Manufacturing);
-
- // [GIVEN] Manufacturing Setup with a specific Location Code
- LibraryWarehouse.CreateLocation(LocationMfg);
- UpdateManufacturingSetup(LocationMfg.Code);
-
- // [GIVEN] Create item without BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // [GIVEN] Create purchase line with subcontracting vendor
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Verify wizard completed successfully
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // [THEN] Find the created Production Order
- ProdOrder.SetRange("Source No.", ItemNo);
- Assert.IsTrue(ProdOrder.FindFirst(), 'Production Order should be created');
-
- // [THEN] Find the Production Order Line
- ProdOrderLine.SetRange(Status, ProdOrder.Status);
- ProdOrderLine.SetRange("Prod. Order No.", ProdOrder."No.");
- Assert.IsTrue(not ProdOrderLine.IsEmpty(), 'Production Order Line should exist');
-
- // [THEN] Verify Manufacturing Setup has the configured Location Code
- ManufacturingSetup.Get();
- Assert.AreEqual(LocationMfg.Code, ManufacturingSetup."Components at Location",
- 'Manufacturing Setup should have the Manufacturing Location Code');
-
- // [THEN] Verify Purchase Location is different from Manufacturing Setup Location
- Assert.AreNotEqual(ManufacturingSetup."Components at Location", PurchLine."Location Code",
- 'Purchase Location Code must be different from Manufacturing Setup Location Code');
- end;
-
[Test]
[HandlerFunctions('ConfirmCreateSubcOrderAnyway_No')]
procedure CreateSubcOrderFromRtngLine_BlankCompLocation_UserDeclines()
@@ -632,23 +573,6 @@ codeunit 139981 "Subc. Location Handler Test"
Reply := false;
end;
- [ModalPageHandler]
- procedure HandlePurchProvisionWizard(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO] Handle the Purchase Provision Wizard
- // The wizard should navigate through all steps and finish successfully
-
- // Click Next to proceed through the wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- // Click Finish to complete the wizard
- if PurchProvisionWizard.ActionFinish.Enabled() then begin
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
- end;
-
[PageHandler]
procedure HandleTransferOrder(var TransfOrderPage: TestPage "Transfer Order")
begin
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcPurchSubcontTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcPurchSubcontTest.Codeunit.al
index 24884d92f5..216056f427 100644
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcPurchSubcontTest.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcPurchSubcontTest.Codeunit.al
@@ -19,7 +19,6 @@ using Microsoft.Manufacturing.Subcontracting;
using Microsoft.Manufacturing.WorkCenter;
using Microsoft.Purchases.Document;
using Microsoft.Purchases.Vendor;
-using System.Utilities;
codeunit 139991 "Subc. Purch. Subcont. Test"
{
@@ -49,222 +48,8 @@ codeunit 139991 "Subc. Purch. Subcont. Test"
SubcWarehouseLibrary: Codeunit "Subc. Warehouse Library";
SubSetupLibrary: Codeunit "Subc. Setup Library";
IsInitialized: Boolean;
- ErrorCounter: Integer;
- ErrorMessageDescriptionList: List of [Text];
ItemTrackingWasOpened: Boolean;
UnitCostCalculation: Option Time,Units;
- NotSupportedErr: Label 'Drop Shipment must be equal to', Locked = true;
-
- [Test]
- [HandlerFunctions('DoConfirmCreateProdOrderForSubcontractingProcess')]
- procedure CreateProductionOrderFromPurchaseOrder_PurchPrice()
- var
- Location, Location2 : Record Location;
- ProdOrder: Record "Production Order";
- PurchaseHeader: Record "Purchase Header";
- PurchLine: Record "Purchase Line";
- RoutingLink: Record "Routing Link";
- SubcontractorPrices, SubcontractorPrices2 : Record "Subcontractor Price";
- Vendor: Record Vendor;
- WorkCenter: Record "Work Center";
- ItemNo, ItemNoOriginPurchLine : Code[20];
- PurchOrder: TestPage "Purchase Order";
- begin
- // [SCENARIO] Create Production Order from Purchase Order from scratch
- Initialize();
-
- // [GIVEN] Create Item for Production include Routing and Prod. BOM
- CreateAndCalculateNeededWorkCenter(WorkCenter, false);
- UpdateSubMgmtCommonWorkCenter(WorkCenter."No.");
- LibraryManufacturing.CreateRoutingLink(RoutingLink);
- UpdateSubMgmtRoutingLink(RoutingLink.Code);
-
- LibraryWarehouse.CreateLocation(Location);
- LibraryWarehouse.CreateLocation(Location2);
- ItemNo := LibraryInventory.CreateItemNo();
-
- LibraryPurchase.CreateVendor(Vendor);
- WorkCenter."Subcontractor No." := Vendor."No.";
- WorkCenter.Modify();
- SubcontractingMgmtLibrary.CreateSubContractingPrice(SubcontractorPrices, WorkCenter."No.", Vendor."No.", ItemNo, '', '', WorkDate(), '', 0, Vendor."Currency Code");
- SubcontractorPrices."Direct Unit Cost" := 99;
- SubcontractorPrices.Modify();
- Vendor."Subcontr. Location Code" := Location2.Code;
- Vendor.Modify();
-
- LibraryPurchase.CreateVendor(Vendor);
- SubcontractingMgmtLibrary.CreateSubContractingPrice(SubcontractorPrices2, WorkCenter."No.", Vendor."No.", ItemNo, '', '', WorkDate(), '', 0, Vendor."Currency Code");
- SubcontractorPrices2."Direct Unit Cost" := 11;
- SubcontractorPrices2.Modify();
- Vendor."Subcontr. Location Code" := Location2.Code;
- Vendor.Modify();
-
- LibraryPurchase.CreatePurchaseOrderWithLocation(PurchaseHeader, Vendor."No.", Location.Code);
- LibraryPurchase.CreatePurchaseLine(PurchLine, PurchaseHeader, PurchLine.Type::Item, ItemNo, LibraryRandom.RandInt(100));
- PurchLine.Validate("Direct Unit Cost", LibraryRandom.RandDecInRange(1, 100, 2));
- ItemNoOriginPurchLine := PurchLine."No.";
- PurchLine.Modify(true);
-
- // [WHEN] Create Prod Order from scratch
- Commit();
- PurchOrder.OpenEdit();
- PurchOrder.GoToRecord(PurchaseHeader);
- PurchOrder.PurchLines.CreateProdOrder.Invoke();
-
- // [THEN]
- PurchLine.Reset();
- PurchLine.SetRange("Document Type", PurchaseHeader."Document Type");
- PurchLine.SetRange("Document No.", PurchaseHeader."No.");
- PurchLine.SetRange(Type, "Purchase Line Type"::Item);
- PurchLine.SetRange("No.", ItemNoOriginPurchLine);
- Assert.RecordCount(PurchLine, 1);
- PurchLine.FindFirst();
- PurchLine.TestField("Direct Unit Cost", SubcontractorPrices2."Direct Unit Cost");
- PurchLine.TestField("Line Amount", PurchLine.Quantity * 11);
-
- // [TEARDOWN]
- PurchLine.SetRange("No.", ItemNoOriginPurchLine);
- PurchLine.FindFirst();
- ProdOrder.Get("Production Order Status"::Released, PurchLine."Prod. Order No.");
- PurchLine."Prod. Order No." := '';
- PurchLine.Modify();
- ProdOrder.Delete(true);
- UpdateSubMgmtCommonWorkCenter('');
- UpdateSubMgmtRoutingLink('');
- end;
-
- [Test]
- [HandlerFunctions('DoConfirmCreateProdOrderForSubcontractingProcess')]
- procedure CreateProductionOrderFromPurchaseOrder_PurchPrice_Variant()
- var
- ItemVariant: Record "Item Variant";
- Location, Location2 : Record Location;
- ProdOrderRtngLine: Record "Prod. Order Routing Line";
- ProdOrder: Record "Production Order";
- PurchaseHeader: Record "Purchase Header";
- PurchLine: Record "Purchase Line";
- RoutingLink: Record "Routing Link";
- SubcontractorPrices2: Record "Subcontractor Price";
- Vendor: Record Vendor;
- WorkCenter: Record "Work Center";
- VariantCode: Code[10];
- ItemNo, ItemNoOriginPurchLine : Code[20];
- PurchOrder: TestPage "Purchase Order";
- begin
- // [SCENARIO] Create Production Order from Purchase Order from scratch
- IsInitialized := false;
- Initialize();
-
- // [GIVEN] Create Item for Production include Routing and Prod. BOM
- CreateAndCalculateNeededWorkCenter(WorkCenter, false);
- UpdateSubMgmtCommonWorkCenter(WorkCenter."No.");
- LibraryManufacturing.CreateRoutingLink(RoutingLink);
- UpdateSubMgmtRoutingLink(RoutingLink.Code);
-
- LibraryWarehouse.CreateLocation(Location);
- LibraryWarehouse.CreateLocation(Location2);
- ItemNo := LibraryInventory.CreateItemNo();
- VariantCode := LibraryInventory.CreateItemVariant(ItemVariant, ItemNo);
-
- LibraryPurchase.CreateVendor(Vendor);
- WorkCenter."Subcontractor No." := Vendor."No.";
- WorkCenter.Modify();
- SubcontractingMgmtLibrary.CreateSubContractingPrice(SubcontractorPrices2, WorkCenter."No.", Vendor."No.", ItemNo, '', ItemVariant.Code, WorkDate(), '', 0, Vendor."Currency Code");
- SubcontractorPrices2."Direct Unit Cost" := 11;
- SubcontractorPrices2.Modify();
- Vendor."Subcontr. Location Code" := Location2.Code;
- Vendor.Modify();
-
- SubcontractingMgmtLibrary.CreateSubContractingPrice(SubcontractorPrices2, WorkCenter."No.", Vendor."No.", ItemNo, '', '', WorkDate(), '', 0, Vendor."Currency Code");
- SubcontractorPrices2."Direct Unit Cost" := 8;
- SubcontractorPrices2.Modify();
-
- LibraryPurchase.CreatePurchaseOrderWithLocation(PurchaseHeader, Vendor."No.", Location.Code);
- LibraryPurchase.CreatePurchaseLine(PurchLine, PurchaseHeader, PurchLine.Type::Item, ItemNo, LibraryRandom.RandInt(100));
- PurchLine.Validate("Variant Code", ItemVariant.Code);
- PurchLine.Validate("Direct Unit Cost", LibraryRandom.RandDecInRange(1, 100, 2));
- ItemNoOriginPurchLine := PurchLine."No.";
- PurchLine.Modify(true);
-
- // [WHEN] Create Prod Order from scratch
- Commit();
- PurchOrder.OpenEdit();
- PurchOrder.GoToRecord(PurchaseHeader);
- PurchOrder.PurchLines.CreateProdOrder.Invoke();
-
- // [THEN]
- PurchLine.Reset();
- PurchLine.SetRange("Document Type", PurchaseHeader."Document Type");
- PurchLine.SetRange("Document No.", PurchaseHeader."No.");
- PurchLine.SetRange(Type, "Purchase Line Type"::Item);
- PurchLine.SetRange("No.", ItemNoOriginPurchLine);
- Assert.RecordCount(PurchLine, 1);
- PurchLine.FindFirst();
- ProdOrder.Get("Production Order Status"::Released, PurchLine."Prod. Order No.");
- ProdOrderRtngLine.SetRange(Status, ProdOrder.Status);
- ProdOrderRtngLine.SetRange("Prod. Order No.", ProdOrder."No.");
- ProdOrderRtngLine.SetRange("Work Center No.", PurchLine."Work Center No.");
- ProdOrderRtngLine.FindFirst();
- PurchLine.TestField("Direct Unit Cost", ProdOrderRtngLine."Direct Unit Cost");
- PurchLine.TestField("Line Amount", PurchLine.Quantity * 11);
-
- // [TEARDOWN]
- PurchLine.SetRange("No.", ItemNoOriginPurchLine);
- PurchLine.FindFirst();
- ProdOrder.Get("Production Order Status"::Released, PurchLine."Prod. Order No.");
- PurchLine."Prod. Order No." := '';
- PurchLine.Modify();
- ProdOrder.Delete(true);
- UpdateSubMgmtCommonWorkCenter('');
- UpdateSubMgmtRoutingLink('');
- end;
-
- [Test]
- [HandlerFunctions('DoConfirmCreateProdOrderForSubcontractingProcess,ErrorPageHandler')]
- procedure CreateProductionOrderFromPurchaseOrderWithDropShipment()
- var
- Location, Location2 : Record Location;
- PurchaseHeader: Record "Purchase Header";
- PurchLine: Record "Purchase Line";
- RoutingLink: Record "Routing Link";
- Vendor: Record Vendor;
- WorkCenter: Record "Work Center";
- PurchOrder: TestPage "Purchase Order";
- begin
- // [SCENARIO] Create Production Order from Purchase Order from scratch
- Initialize();
-
- // [GIVEN] Create Item for Production include Routing and Prod. BOM
- CreateAndCalculateNeededWorkCenter(WorkCenter, false);
- UpdateSubMgmtCommonWorkCenter(WorkCenter."No.");
- LibraryManufacturing.CreateRoutingLink(RoutingLink);
- UpdateSubMgmtRoutingLink(RoutingLink.Code);
-
- LibraryWarehouse.CreateLocation(Location);
- LibraryWarehouse.CreateLocation(Location2);
- LibraryPurchase.CreateVendor(Vendor);
- Vendor."Subcontr. Location Code" := Location2.Code;
- Vendor.Modify();
-
- LibraryPurchase.CreatePurchaseOrderWithLocation(PurchaseHeader, Vendor."No.", Location.Code);
- LibraryPurchase.CreatePurchaseLine(PurchLine, PurchaseHeader, PurchLine.Type::Item, LibraryInventory.CreateItemNo(), LibraryRandom.RandInt(100));
- PurchLine.Validate("Drop Shipment", true);
- PurchLine.Modify(true);
-
- // [WHEN] Create Prod Order from scratch
- Commit();
- PurchOrder.OpenEdit();
- PurchOrder.GoToRecord(PurchaseHeader);
- PurchOrder.PurchLines.CreateProdOrder.Invoke();
-
- // [THEN] Error occurs as drop shipment is not supported
- Assert.AreEqual(1, ErrorCounter, 'Error message should be added for each related record');
- Assert.IsSubstring(ErrorMessageDescriptionList.Get(1), NotSupportedErr);
-
- // [TEARDOWN]
- UpdateSubMgmtCommonWorkCenter('');
- UpdateSubMgmtRoutingLink('');
- end;
[Test]
procedure VendorLocationWithBinMandatoryThrowsError()
@@ -535,17 +320,6 @@ codeunit 139991 "Subc. Purch. Subcont. Test"
ItemTrackingLines.OK().Invoke();
end;
- [PageHandler]
- procedure ErrorPageHandler(var ErrorMessageTestPage: TestPage "Error Messages")
- begin
- ErrorMessageTestPage.First();
- repeat
- ErrorMessageDescriptionList.Add(ErrorMessageTestPage.Description.Value());
- ErrorCounter += 1;
- until not ErrorMessageTestPage.Next();
- ErrorMessageTestPage.Close();
- end;
-
[ConfirmHandler]
procedure DoConfirmCreateProdOrderForSubcontractingProcess(Question: Text[1024]; var Reply: Boolean)
begin
@@ -557,11 +331,6 @@ codeunit 139991 "Subc. Purch. Subcont. Test"
end;
end;
- [MessageHandler]
- procedure MessageBOMCreated(MessageText: Text[1024])
- begin
- end;
-
local procedure CreateAndCalculateNeededWorkCenter(var WorkCenter: Record "Work Center"; IsSubcontracting: Boolean)
var
CapacityUnitOfMeasure: Record "Capacity Unit of Measure";
@@ -615,7 +384,6 @@ codeunit 139991 "Subc. Purch. Subcont. Test"
SubcontractingMgmtLibrary.Initialize();
LibraryMfgManagement.Initialize();
SubSetupLibrary.InitSetupFields();
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
LibraryERMCountryData.CreateVATData();
SubSetupLibrary.InitialSetupForGenProdPostingGroup();
@@ -625,24 +393,6 @@ codeunit 139991 "Subc. Purch. Subcont. Test"
LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Subc. Purch. Subcont. Test");
end;
- local procedure UpdateSubMgmtCommonWorkCenter(WorkCenterNo: Code[20])
- var
- SubManagementSetup: Record "Subc. Management Setup";
- begin
- SubManagementSetup.Get();
- SubManagementSetup."Common Work Center No." := WorkCenterNo;
- SubManagementSetup.Modify();
- end;
-
- local procedure UpdateSubMgmtRoutingLink(RtngLink: Code[10])
- var
- ManufacturingSetup: Record "Manufacturing Setup";
- begin
- ManufacturingSetup.Get();
- ManufacturingSetup."Rtng. Link Code Purch. Prov." := RtngLink;
- ManufacturingSetup.Modify();
- end;
-
local procedure EnsureGeneralPostingSetupIsValid(GenBusPostingGroup: Code[20]; GenProdPostingGroup: Code[20])
var
GeneralPostingSetup: Record "General Posting Setup";
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingSyncTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingSyncTest.Codeunit.al
index 6a80f01dea..0e0b24e2f0 100644
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingSyncTest.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingSyncTest.Codeunit.al
@@ -42,7 +42,6 @@ codeunit 139992 "Subc. Subcontracting Sync Test"
ProductionOrder: Record "Production Order";
PurchLine: Record "Purchase Line";
RequisitionLine: Record "Requisition Line";
- SubcontractingManagementSetup: Record "Subc. Management Setup";
Work_Center: Record "Work Center";
WorkCenter: array[2] of Record "Work Center";
ManufacturingSetup: Record "Manufacturing Setup";
@@ -58,7 +57,7 @@ codeunit 139992 "Subc. Subcontracting Sync Test"
// [GIVEN] Some Parameters for Creation
Subcontracting := true;
- SubcontractingManagementSetup.Get();
+ ManufacturingSetup.Get();
UnitCostCalculation := UnitCostCalculation::Units;
// [GIVEN]
@@ -111,112 +110,6 @@ codeunit 139992 "Subc. Subcontracting Sync Test"
Assert.AreNotEqual(0, ProductionOrder.Quantity, 'Prod. order Qty. must not be zero after calculation of subcontracting in work sheet.');
end;
- [Test]
- [HandlerFunctions('DoConfirmCreateProdOrderForSubcontractingProcess')]
- procedure TestQuantitySynchronizationAfterCreateProductionOrderFromPurchaseOrder()
- var
- ItemUOM: Record "Item Unit of Measure";
- Location, Location2 : Record Location;
- ProdOrder: Record "Production Order";
- PurchaseHeader: Record "Purchase Header";
- PurchLine, PurchLine2 : Record "Purchase Line";
- RoutingLink: Record "Routing Link";
- Vendor: Record Vendor;
- WorkCenter: Record "Work Center";
- SynchMgmt: Codeunit "Subc. Synchronize Management";
- ItemNoOriginPurchLine: Code[20];
- PurchOrder: TestPage "Purchase Order";
- begin
- // [SCENARIO] Create Production Order from Purchase Order from scratch and test Quantity synchronization
- Initialize();
-
- // [GIVEN] Create Item for Production include Routing and Prod. BOM
- CreateAndCalculateNeededWorkCenter(WorkCenter, false);
- UpdateSubMgmtCommonWorkCenter(WorkCenter."No.");
- LibraryManufacturing.CreateRoutingLink(RoutingLink);
- UpdateSubMgmtRoutingLink(RoutingLink.Code);
-
- LibraryWarehouse.CreateLocation(Location);
- LibraryWarehouse.CreateLocation(Location2);
- LibraryPurchase.CreateVendor(Vendor);
- Vendor."Subcontr. Location Code" := Location2.Code;
- Vendor.Modify();
- LibraryPurchase.CreatePurchaseOrderWithLocation(PurchaseHeader, Vendor."No.", Location.Code);
- LibraryPurchase.CreatePurchaseLine(PurchLine, PurchaseHeader, "Purchase Line Type"::Item, LibraryInventory.CreateItemNo(), LibraryRandom.RandInt(100));
- PurchLine.Validate("Direct Unit Cost", LibraryRandom.RandDecInRange(1, 100, 2));
- ItemNoOriginPurchLine := PurchLine."No.";
- PurchLine.Modify(true);
-
- // [WHEN] Create Prod Order from scratch
- Commit();
- PurchOrder.OpenEdit();
- PurchOrder.GoToRecord(PurchaseHeader);
- PurchOrder.PurchLines.CreateProdOrder.Invoke();
-
- // [THEN]
- PurchLine.Reset();
- PurchLine.SetRange("Document Type", PurchaseHeader."Document Type");
- PurchLine.SetRange("Document No.", PurchaseHeader."No.");
- PurchLine.SetRange(Type, "Purchase Line Type"::Item);
- PurchLine.SetRange("No.", ItemNoOriginPurchLine);
- Assert.RecordCount(PurchLine, 1);
- PurchLine.FindFirst();
- PurchLine.TestField("Prod. Order No.");
-
- PurchLine2.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
-
- LibraryInventory.CreateItemUnitOfMeasureCode(ItemUOM, PurchLine."No.", 3);
- PurchLine2.Validate("Unit of Measure Code", ItemUOM.Code);
- PurchLine2.Modify();
- SynchMgmt.SynchronizeQuantity(PurchLine2, PurchLine);
-
- ProdOrder.Get("Production Order Status"::Released, PurchLine."Prod. Order No.");
- Assert.AreEqual(PurchLine.Quantity * 3, ProdOrder.Quantity, 'Quantity of Prod. Order must be equal to Quantity of Purchase Line');
-
- // [TEARDOWN]
- PurchLine.SetRange("No.", ItemNoOriginPurchLine);
- PurchLine.FindFirst();
- ProdOrder.Get("Production Order Status"::Released, PurchLine."Prod. Order No.");
- PurchLine."Prod. Order No." := '';
- PurchLine.Modify();
- ProdOrder.Delete(true);
- UpdateSubMgmtCommonWorkCenter('');
- UpdateSubMgmtRoutingLink('');
- end;
-
- local procedure CreateAndCalculateNeededWorkCenter(var WorkCenter: Record "Work Center"; IsSubcontracting: Boolean)
- var
- CapacityUnitOfMeasure: Record "Capacity Unit of Measure";
- ShopCalendarCode: Code[10];
- WorkCenterNo: Code[20];
- begin
- LibraryManufacturing.CreateCapacityUnitOfMeasure(CapacityUnitOfMeasure, "Capacity Unit of Measure"::Minutes);
- ShopCalendarCode := LibraryManufacturing.UpdateShopCalendarWorkingDays();
-
- // [GIVEN] Create and Calculate needed Work and Machine Center
- CreateWorkCenter(WorkCenterNo, ShopCalendarCode, "Flushing Method"::"Pick + Manual", IsSubcontracting, UnitCostCalculation, '');
- WorkCenter.Get(WorkCenterNo);
- LibraryManufacturing.CalculateWorkCenterCalendar(WorkCenter, CalcDate('<-CY-1Y>', WorkDate()), CalcDate('', WorkDate()));
- end;
-
- local procedure UpdateSubMgmtCommonWorkCenter(WorkCenterNo: Code[20])
- var
- SubManagementSetup: Record "Subc. Management Setup";
- begin
- SubManagementSetup.Get();
- SubManagementSetup."Common Work Center No." := WorkCenterNo;
- SubManagementSetup.Modify();
- end;
-
- local procedure UpdateSubMgmtRoutingLink(RtngLink: Code[10])
- var
- ManufacturingSetup: Record "Manufacturing Setup";
- begin
- ManufacturingSetup.Get();
- ManufacturingSetup."Rtng. Link Code Purch. Prov." := RtngLink;
- ManufacturingSetup.Modify();
- end;
-
local procedure MakeSubconPurchOrder(ProductionOrderNo: Code[20]; WorkCenterNo: Code[20])
var
RequisitionLine: Record "Requisition Line";
@@ -415,7 +308,6 @@ codeunit 139992 "Subc. Subcontracting Sync Test"
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. Subcontracting Sync Test");
SubSetupLibrary.InitSetupFields();
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
LibraryERMCountryData.CreateVATData();
SubSetupLibrary.InitialSetupForGenProdPostingGroup();
@@ -473,10 +365,8 @@ codeunit 139992 "Subc. Subcontracting Sync Test"
Assert: Codeunit Assert;
LibraryERM: Codeunit "Library - ERM";
LibraryERMCountryData: Codeunit "Library - ERM Country Data";
- LibraryInventory: Codeunit "Library - Inventory";
LibraryManufacturing: Codeunit "Library - Manufacturing";
LibraryPlanning: Codeunit "Library - Planning";
- LibraryPurchase: Codeunit "Library - Purchase";
LibraryRandom: Codeunit "Library - Random";
LibrarySetupStorage: Codeunit "Library - Setup Storage";
LibraryTestInitialize: Codeunit "Library - Test Initialize";
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingTest.Codeunit.al
index ebed58e81c..5a4a99380d 100644
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingTest.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingTest.Codeunit.al
@@ -6,7 +6,6 @@ namespace Microsoft.Manufacturing.Subcontracting.Test;
using Microsoft.Finance.GeneralLedger.Setup;
using Microsoft.Finance.VAT.Setup;
-using Microsoft.Foundation.Enums;
using Microsoft.Foundation.NoSeries;
using Microsoft.Inventory.Item;
using Microsoft.Inventory.Journal;
@@ -28,7 +27,6 @@ using Microsoft.Manufacturing.WorkCenter;
using Microsoft.Purchases.Archive;
using Microsoft.Purchases.Comment;
using Microsoft.Purchases.Document;
-using Microsoft.Purchases.History;
using Microsoft.Purchases.Vendor;
using Microsoft.Sales.Customer;
using Microsoft.Sales.Document;
@@ -49,7 +47,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder')]
procedure CreateTransferOrderFromSecondSubcontractingOrderOpensReusedTransferOrder()
var
Item: Record Item;
@@ -164,7 +162,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder')]
procedure CannotDeleteSubcontractingOrderWithAssociatedTransferOrder()
var
Item: Record Item;
@@ -221,30 +219,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- procedure InsertRecordOnOpenPageSubcontractingManagementSetup()
- var
- SubcontractingMgmtSetupPage: TestPage "Subc. Management Setup";
- begin
- // [SCENARIO] OnOpenPage should create a record in Subcontracting Setup
-
- // [GIVEN] No Record exists in Subcontracting Setup
- Initialize();
- RemoveSubcontractingManagementSetupRecord();
- CheckNoSubcontractingManagementSetupRecordExist();
-
- // [WHEN] Open Subcontracting Setup Page
- SubcontractingMgmtSetupPage.OpenView();
- SubcontractingMgmtSetupPage.Close();
-
- // [THEN] A Record should exist in Subcontracting Setup
- CheckSubcontractingManagementSetupRecordExist();
-
- // [TEARDOWN]
- Clear(IsInitialized);
- end;
-
- [Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting')]
+ [HandlerFunctions('ConfirmHandler')]
procedure TestCreationOfPurchOrderFromRtngLineWithSubcontractor()
var
Item: Record Item;
@@ -359,7 +334,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting')]
+ [HandlerFunctions('ConfirmHandler')]
procedure TestCreationOfPurchOrderFromRtngLineWithSubcontractorWithAddLine()
var
Item: Record Item;
@@ -413,7 +388,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting')]
+ [HandlerFunctions('ConfirmHandler')]
procedure TestCreationOfSubcontractingPurchOrderFromRtngLineWithAddInfoLine()
var
Item: Record Item;
@@ -510,7 +485,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder')]
procedure TestCreationOfSubcontrTransferOrderFromSubcontrPurchOrder()
var
Item: Record Item;
@@ -584,7 +559,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder')]
procedure TestLocationInSubContractorTransferOrderAndComponentLine()
var
Item: Record Item;
@@ -669,7 +644,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder')]
procedure TestLocationInSubContractorTransferOrderAndComponentLineWithChangeCompLineLocation()
var
Item: Record Item;
@@ -759,7 +734,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder,HandleCreateTransferOrderMsg')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder,HandleCreateTransferOrderMsg')]
procedure CheckTransferOrderFromSubcontrAndReturnTransferOrderFromSubcontractorPurchOrder()
var
Bin: Record Bin;
@@ -932,8 +907,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoConfirmCreateProdOrderForSubcontractingProcess')]
-
+ [HandlerFunctions('ConfirmHandler')]
procedure CheckGenPostGroupInSubContWorksheetAndSubConRoutingLine()
var
Item: Record Item;
@@ -1065,149 +1039,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoConfirmCreateProdOrderForSubcontractingProcess')]
- procedure CheckGenPostGroupInSubContWorksheetAndSubConInPurchLineFunktion()
- var
- Item: Record Item;
- Location: Record Location;
- MachineCenter: array[2] of Record "Machine Center";
- ProductionOrder: Record "Production Order";
- PurchaseHeader: Record "Purchase Header";
- PurchaseLine: Record "Purchase Line";
- ReqWkshTemplate: Record "Req. Wksh. Template";
- RequisitionLine: Record "Requisition Line";
- RequisitionWkshName: Record "Requisition Wksh. Name";
- RoutingLink: Record "Routing Link";
- Vendor: Record Vendor;
- WorkCenter: array[2] of Record "Work Center";
- SubcCalculateSubContract: Report "Subc. Calculate Subcontracts";
- CarryOutActionMsgReq: Report "Carry Out Action Msg. - Req.";
- LibraryUtility: Codeunit "Library - Utility";
- GenBusPostingGroup1, GenBusPostingGroup2 : Code[20];
- ItemNoOriginPurchLine: Code[20];
- ProdPostingGroup1, ProdPostingGroup2 : Code[20];
- VATBusPostingGroup1, VATBusPostingGroup2 : Code[20];
- VATProdPostingGroup1, VATProdPostingGroup2 : Code[20];
- PurchOrder: TestPage "Purchase Order";
- begin
- // [SCENARIO] Check change Location Code by change Subcontracting Type in Prod Order Component
-
- // [GIVEN] Complete Setup of Manufacturing, include Work- and Machine Centers, Item
- Initialize();
-
- // [GIVEN] Some Parameters for Creation
- Subcontracting := true;
- UnitCostCalculation := UnitCostCalculation::Units;
- UpdateSubMgmtSetupWithReqWkshTemplate();
- // [GIVEN]
- CreateAndCalculateNeededWorkAndMachineCenter(WorkCenter, MachineCenter);
-
- // [GIVEN] Create Item for Production include Routing and Prod. BOM
- CreateItemForProductionIncludeRoutingAndProdBOM(Item, WorkCenter, MachineCenter);
-
- UpdateProdBomAndRoutingWithRoutingLink(Item, WorkCenter[2]."No.");
-
- LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
- Vendor.Get(WorkCenter[2]."Subcontractor No.");
- WorkCenter2 := WorkCenter[2];
- WorkCenter2."Subcontractor No." := Vendor."No.";
- Vendor."Subcontr. Location Code" := Location.Code;
- LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
- Vendor."Location Code" := Location.Code;
- Vendor.Modify();
-
- //[GIVEN] Create Production Order
- SubcontractingMgmtLibrary.CreateAndRefreshProductionOrder(
- ProductionOrder, "Production Order Status"::Released, ProductionOrder."Source Type"::Item, Item."No.", LibraryRandom.RandInt(10) + 5);
-
- //[GIVEN] Create requisition worksheet template
- ReqWkshTemplate.DeleteAll(true);
- ReqWkshTemplate.Name := SelectRequisitionTemplateName();
- RequisitionWkshName.Init();
- RequisitionWkshName.Validate("Worksheet Template Name", ReqWkshTemplate.Name);
- RequisitionWkshName.Validate(
- Name,
- CopyStr(
- LibraryUtility.GenerateRandomCode(RequisitionWkshName.FieldNo(Name), Database::"Requisition Wksh. Name"),
- 1, LibraryUtility.GetFieldLength(Database::"Requisition Wksh. Name", RequisitionWkshName.FieldNo(Name))));
- RequisitionWkshName.Insert(true);
-
- //[GIVEN] create Purchase Order from Subcontracting Worksheet
- RequisitionLine."Worksheet Template Name" := RequisitionWkshName."Worksheet Template Name";
- RequisitionLine."Journal Batch Name" := RequisitionWkshName.Name;
-
- SubcCalculateSubContract.SetWkShLine(RequisitionLine);
- SubcCalculateSubContract.UseRequestPage(false);
- SubcCalculateSubContract.RunModal();
-
- RequisitionLine.SetRange("Worksheet Template Name", RequisitionWkshName."Worksheet Template Name");
- RequisitionLine.SetRange("Journal Batch Name", RequisitionWkshName.Name);
-#pragma warning disable AA0210
- RequisitionLine.SetRange("Prod. Order No.", ProductionOrder."No.");
-#pragma warning restore AA0210
- RequisitionLine.FindFirst();
-
- Assert.AreEqual(ProductionOrder."No.", RequisitionLine."Prod. Order No.", 'Prod. Order No. has not found');
-
- CarryOutActionMsgReq.SetReqWkshLine(RequisitionLine);
- CarryOutActionMsgReq.UseRequestPage(false);
- CarryOutActionMsgReq.RunModal();
-
- PurchaseLine.SetRange("Document Type", PurchaseLine."Document Type"::Order);
- PurchaseLine.SetRange("No.", ProductionOrder."Source No.");
- PurchaseLine.SetRange(Type, "Purchase Line Type"::Item);
- PurchaseLine.SetRange("Prod. Order No.", ProductionOrder."No.");
- PurchaseLine.FindFirst();
-
- //[GIVEN] Keep Gen. Prod. Posting Group value for later Check
- ProdPostingGroup1 := PurchaseLine."Gen. Prod. Posting Group";
- GenBusPostingGroup1 := PurchaseLine."Gen. Bus. Posting Group";
- VATBusPostingGroup1 := PurchaseLine."VAT Bus. Posting Group";
- VATProdPostingGroup1 := PurchaseLine."VAT Prod. Posting Group";
-
- PurchaseHeader.Get(PurchaseLine."Document Type", PurchaseLine."Document No.");
-
- //[GIVEN] Delete Purchase Order
- PurchaseHeader.Delete(true);
- Commit();
-
- LibraryManufacturing.CreateRoutingLink(RoutingLink);
- UpdateSubMgmtRoutingLink(RoutingLink.Code);
- WorkCenter2 := WorkCenter[2];
- UpdateSubMgmtCommonWorkCenter(WorkCenter2."No.");
-
- //[GIVEN] Create Subcontracting Purchase Order from Purch
- LibraryPurchase.CreatePurchaseOrderWithLocation(PurchaseHeader, Vendor."No.", Location.Code);
- LibraryPurchase.CreatePurchaseLine(PurchaseLine, PurchaseHeader, PurchaseLine.Type::Item, LibraryInventory.CreateItemNo(), LibraryRandom.RandInt(100));
- PurchaseLine.Validate("Direct Unit Cost", LibraryRandom.RandDecInRange(1, 100, 2));
- ItemNoOriginPurchLine := PurchaseLine."No.";
- PurchaseLine.Modify(true);
- Commit();
- PurchOrder.OpenEdit();
- PurchOrder.GoToRecord(PurchaseHeader);
- PurchOrder.PurchLines.CreateProdOrder.Invoke();
-
- PurchaseLine.Reset();
- PurchaseLine.SetRange("Document Type", PurchaseHeader."Document Type");
- PurchaseLine.SetRange("Document No.", PurchaseHeader."No.");
- PurchaseLine.SetRange(Type, "Purchase Line Type"::Item);
- PurchaseLine.SetRange("No.", ItemNoOriginPurchLine);
- PurchaseLine.FindFirst();
-
- ProdPostingGroup2 := PurchaseLine."Gen. Prod. Posting Group";
- GenBusPostingGroup2 := PurchaseLine."Gen. Bus. Posting Group";
- VATBusPostingGroup2 := PurchaseLine."VAT Bus. Posting Group";
- VATProdPostingGroup2 := PurchaseLine."VAT Prod. Posting Group";
-
- //[THEN] Check if Gen. Prod. Posting Group is the same as Standard
- Assert.AreEqual(ProdPostingGroup1, ProdPostingGroup2, 'Gen. Prod. Posting Group is not Expected');
- Assert.AreEqual(GenBusPostingGroup1, GenBusPostingGroup2, 'Gen. Bus. Posting Group is not Expected');
- Assert.AreEqual(VATBusPostingGroup1, VATBusPostingGroup2, 'VAT Bus. Posting Group is not Expected');
- Assert.AreEqual(VATProdPostingGroup1, VATProdPostingGroup2, 'VAT Prod. Posting Group');
- end;
-
- [Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting')]
+ [HandlerFunctions('ConfirmHandler')]
procedure TestTransferProdOrderRtngCommentByCreationOfSubcontrPurchOrder()
var
Item: Record Item;
@@ -1277,7 +1109,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder')]
procedure TestExpectedErrorOnChangingLocationCodeInProdOrderCompWithTransferOrderFromSubcontrPurchOrder()
var
Item: Record Item;
@@ -1359,7 +1191,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder')]
procedure TestReceiptDateFromTransferOrderLineFromSubcontrPurchOrderIsEquallyToProdOrderCompDueDate()
var
Item: Record Item;
@@ -1447,7 +1279,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder')]
procedure TestLocationAndBinCodeIsSetFromOriginBinCodeAfterDeletingTransferOrder()
var
Item: Record Item;
@@ -1539,7 +1371,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder')]
procedure CheckBtnTrackingSpecificationOnProdOrderCompOnExistingReserveInTransferLine()
var
Item: Record Item;
@@ -1627,7 +1459,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting')]
+ [HandlerFunctions('ConfirmHandler')]
procedure TestCheckSubcontractorPriceInFactbox()
var
Item: Record Item;
@@ -1736,7 +1568,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,SubcontrDispatchingListDefaultRequestPageHandler')]
+ [HandlerFunctions('ConfirmHandler,SubcontrDispatchingListDefaultRequestPageHandler')]
procedure TestSubcontrDispatchingList()
var
Item: Record Item;
@@ -1857,55 +1689,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- procedure TestPostItemChargeAssignedToSubcontractingLingValueEntryWithCapacityRelation()
- var
- ItemCharge: Record "Item Charge";
- ItemChargeAssignmentPurch: Record "Item Charge Assignment (Purch)";
- ManufacturingSetup: Record "Manufacturing Setup";
- PurchRcptLine: Record "Purch. Rcpt. Line";
- PurchaseHeader: Record "Purchase Header";
- PurchaseLine: Record "Purchase Line";
- ValueEntry: Record "Value Entry";
- begin
- // [SCENARIO] When a Purchase Order is created and the item charge is assigned to a subcontracting line, the value entry should be created with the capacity relation, not with item ledger entry relation.
- // The subcontracting purchase (service) line is created and posted. A new purchase line of type item charge is created, with assignment to subcontracting rcpt line. The the second purchase order is posted
- // and the ledger entries were checked.
-
- // [GIVEN] Complete Setup of Manufacturing, include Work- and Machine Centers, Item
- Initialize();
- SubcontractingMgmtLibrary.SetupInventorySetup();
-
- //[GIVEN] Setup Item Charge Assignment Subcontracting
- ManufacturingSetup.Get();
- ManufacturingSetup.RefItemChargeToRcptSubLines := true;
- ManufacturingSetup.Modify();
-
- // [GIVEN] Some Parameters for Creation
- Subcontracting := true;
- UnitCostCalculation := UnitCostCalculation::Units;
-
- // [GIVEN] Create Subcontracting Purchase Order with Prod Order and Post
- CreateSubcontractingPurchOrderPostAndGetPurchRcptLine(PurchRcptLine);
-
- // [GIVEN] Create Item Charge Purchase Line and Item Charge Assignment
- CreateItemChargeOrderLine(PurchaseHeader, PurchaseLine, ItemCharge);
- LibraryPurchase.CreateItemChargeAssignment(ItemChargeAssignmentPurch, PurchaseLine, ItemCharge, "Purchase Applies-to Document Type"::Receipt, PurchRcptLine."Document No.", PurchRcptLine."Line No.", PurchRcptLine."No.", PurchaseLine.Quantity, PurchaseLine."Direct Unit Cost");
-
- ItemChargeAssignmentPurch.Insert(true);
-
- // [WHEN] Post Purchase Order with Item Charge
- LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, true);
-
- //[THEN] Check Value Entry
- ValueEntry.FindLast();
- Assert.AreEqual(0, ValueEntry."Item Ledger Entry No.", 'Item Ledger Entry No. must be zero on value entry.');
- Assert.AreNotEqual(0, ValueEntry."Capacity Ledger Entry No.", 'Capacity Ledger Entry No. must be filled on value entry.');
- Assert.AreEqual("Inventory Order Type"::Production, ValueEntry."Order Type", 'Order Type must be Production on value entry.');
- Assert.AreEqual(0, ValueEntry."Invoiced Quantity", 'Invoiced Quantity must be zero on value entry.');
- end;
-
- [Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting')]
+ [HandlerFunctions('ConfirmHandler')]
procedure SubcontractingFieldsPopulatedOnIleAfterSubcontractingPurchaseReceipt()
var
Item: Record Item;
@@ -1962,7 +1746,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting')]
+ [HandlerFunctions('ConfirmHandler')]
procedure ProdOFactboxMgmtResolvesProductionOrderForIleFromSubcontractingPurchaseReceipt()
var
Item: Record Item;
@@ -2016,7 +1800,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting')]
+ [HandlerFunctions('ConfirmHandler')]
procedure RoutingFactboxMgmtFiltersPurchOrderQtyByRoutingReferenceNo()
var
Item: Record Item;
@@ -2074,7 +1858,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting')]
+ [HandlerFunctions('ConfirmHandler')]
procedure Description2CopiedFromProdOrderComponentToPurchaseLine()
var
Item: Record Item;
@@ -2246,7 +2030,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder,HandleCreateTransferOrderMsg')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder,HandleCreateTransferOrderMsg')]
procedure PostingDirectSubcontractingTransferSetsSourceFieldsOnDirectTransHeader()
var
Bin: Record Bin;
@@ -2328,7 +2112,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder')]
procedure CreateReturnTransferOrderAfterPartialShipOfOutbound()
var
Bin: Record Bin;
@@ -2428,7 +2212,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[Test]
- [HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder')]
+ [HandlerFunctions('ConfirmHandler,HandleTransferOrder')]
procedure CreateReturnTransferOrderAfterPartialShipOfOutboundDirectTransfer()
var
Bin: Record Bin;
@@ -2620,12 +2404,6 @@ codeunit 139989 "Subc. Subcontracting Test"
begin
end;
- [ConfirmHandler]
- procedure DoNotConfirmShowCreatedPurchOrderForSubcontracting(Question: Text[1024]; var Reply: Boolean)
- begin
- Reply := false;
- end;
-
[RequestPageHandler]
procedure SubcontrDispatchingListDefaultRequestPageHandler(var PurchaseOrderRequestPage: TestRequestPage "Subc. Dispatching List")
begin
@@ -2633,7 +2411,7 @@ codeunit 139989 "Subc. Subcontracting Test"
end;
[ConfirmHandler]
- procedure DoConfirmCreateProdOrderForSubcontractingProcess(Question: Text[1024]; var Reply: Boolean)
+ procedure ConfirmHandler(Question: Text[1024]; var Reply: Boolean)
begin
case true of
Question.Contains('Do you want to create a production order from'):
@@ -2656,23 +2434,6 @@ codeunit 139989 "Subc. Subcontracting Test"
Reply := true;
end;
- local procedure RemoveSubcontractingManagementSetupRecord()
- var
- SubcontractingManagementSetup: Record "Subc. Management Setup";
- begin
- SubcontractingManagementSetup.DeleteAll();
- end;
-
- local procedure CheckNoSubcontractingManagementSetupRecordExist()
- begin
- Assert.TableIsEmpty(Database::"Subc. Management Setup");
- end;
-
- local procedure CheckSubcontractingManagementSetupRecordExist()
- begin
- Assert.TableIsNotEmpty(Database::"Subc. Management Setup");
- end;
-
local procedure CreateAndCalculateNeededWorkAndMachineCenter(var WorkCenter: array[2] of Record "Work Center"; var MachineCenter: array[2] of Record "Machine Center")
var
CapacityUnitOfMeasure: Record "Capacity Unit of Measure";
@@ -2902,48 +2663,6 @@ codeunit 139989 "Subc. Subcontracting Test"
WorkCenterNo := WorkCenter."No.";
end;
- local procedure CreateSubcontractingPurchOrderPostAndGetPurchRcptLine(var PurchRcptLine: Record "Purch. Rcpt. Line")
- var
- Item: Record Item;
- Location: Record Location;
- MachineCenter: array[2] of Record "Machine Center";
- PurchaseHeader: Record "Purchase Header";
- PurchaseLine: Record "Purchase Line";
- Vendor: Record Vendor;
- WorkCenter: array[2] of Record "Work Center";
- begin
- CreateAndCalculateNeededWorkAndMachineCenter(WorkCenter, MachineCenter);
- CreateItemForProductionIncludeRoutingAndProdBOM(Item, WorkCenter, MachineCenter);
- UpdateProdBomAndRoutingWithRoutingLink(Item, WorkCenter[2]."No.");
- SubcontractingMgmtLibrary.UpdateVendorWithSubcontractingLocationCode(WorkCenter[2]);
-
- LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
- Vendor.Get(WorkCenter[2]."Subcontractor No.");
- WorkCenter2 := WorkCenter[2];
- WorkCenter2."Subcontractor No." := Vendor."No.";
- Vendor."Subcontr. Location Code" := Location.Code;
- LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
- Vendor."Location Code" := Location.Code;
- Vendor.Modify();
-
- LibraryPurchase.CreatePurchaseOrderWithLocation(PurchaseHeader, Vendor."No.", Location.Code);
- LibraryPurchase.CreatePurchaseLine(PurchaseLine, PurchaseHeader, PurchaseLine.Type::Item, Item."No.", LibraryRandom.RandInt(100));
- LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
- PurchaseLine.Validate("Location Code", Location.Code);
- PurchaseLine.Validate("Direct Unit Cost", LibraryRandom.RandDecInRange(1, 100, 2));
- PurchaseLine.Modify(true);
-
- Codeunit.Run(Codeunit::"Subc. Create Prod. Ord. Opt.", PurchaseLine);
-
- EnsureGeneralPostingSetupIsValid(PurchaseLine."Gen. Bus. Posting Group", PurchaseLine."Gen. Prod. Posting Group");
-
- LibraryPurchase.PostPurchaseDocument(PurchaseHeader, true, false);
-
- PurchRcptLine.SetRange("Order No.", PurchaseHeader."No.");
- PurchRcptLine.SetRange("Order Line No.", PurchaseLine."Line No.");
- PurchRcptLine.FindFirst();
- end;
-
local procedure EnsureGeneralPostingSetupIsValid(GenBusPostingGroup: Code[20]; GenProdPostingGroup: Code[20])
var
GeneralPostingSetup: Record "General Posting Setup";
@@ -3063,8 +2782,6 @@ codeunit 139989 "Subc. Subcontracting Test"
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. Subcontracting Test");
SubSetupLibrary.InitSetupFields();
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
LibraryERMCountryData.CreateVATData();
SubSetupLibrary.InitialSetupForGenProdPostingGroup();
@@ -3092,9 +2809,7 @@ codeunit 139989 "Subc. Subcontracting Test"
var
ManufacturingSetup: Record "Manufacturing Setup";
begin
- if not ManufacturingSetup.Get() then
- exit;
-
+ ManufacturingSetup.Get();
Evaluate(ManufacturingSetup."Subc. Inb. Whse. Handling Time", '<1D>');
ManufacturingSetup.Modify();
end;
@@ -3122,33 +2837,6 @@ codeunit 139989 "Subc. Subcontracting Test"
LibraryInventory.PostItemJournalLine(ItemJournalLine."Journal Template Name", ItemJournalLine."Journal Batch Name");
end;
- local procedure UpdateSubMgmtRoutingLink(RtngLink: Code[10])
- var
- ManufacturingSetup: Record "Manufacturing Setup";
- begin
- ManufacturingSetup.Get();
- ManufacturingSetup."Rtng. Link Code Purch. Prov." := RtngLink;
- ManufacturingSetup.Modify();
- end;
-
- local procedure UpdateSubMgmtCommonWorkCenter(WorkCenterNo: Code[20])
- var
- SubManagementSetup: Record "Subc. Management Setup";
- begin
- SubManagementSetup.Get();
- SubManagementSetup."Common Work Center No." := WorkCenterNo;
- SubManagementSetup.Modify();
- end;
-
- local procedure CreateItemChargeOrderLine(var PurchaseHeader: Record "Purchase Header"; var PurchaseLine: Record "Purchase Line"; var ItemCharge: Record "Item Charge")
- begin
- LibraryInventory.CreateItemCharge(ItemCharge);
- LibraryPurchase.CreatePurchaseOrder(PurchaseHeader);
- LibraryPurchase.CreatePurchaseLine(PurchaseLine, PurchaseHeader, "Purchase Line Type"::"Charge (Item)", ItemCharge."No.", LibraryRandom.RandInt(100));
- PurchaseLine.Validate("Direct Unit Cost", LibraryRandom.RandDecInRange(1, 100, 2));
- PurchaseLine.Modify(true);
- end;
-
procedure SelectRequisitionTemplateName(): Code[10]
var
ReqWkshTemplate: Record "Req. Wksh. Template";
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingUITest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingUITest.Codeunit.al
index a5a429adb1..94f88a72d1 100644
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingUITest.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcSubcontractingUITest.Codeunit.al
@@ -38,7 +38,6 @@ codeunit 139990 "Subc. Subcontracting UI Test"
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. Subcontracting UI Test");
SubSetupLibrary.InitSetupFields();
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
LibraryERMCountryData.CreateVATData();
SubSetupLibrary.InitialSetupForGenProdPostingGroup();
@@ -468,4 +467,4 @@ codeunit 139990 "Subc. Subcontracting UI Test"
SubcontractingActionsEnabledErr: Label 'Subcontractor Prices action should not be enabled for a non-subcontracting Work Center.';
SubcontractingActionsNotVisibleErr: Label 'Subcontractor Prices action should be visible for a subcontracting Work Center.';
SubcontractingActionsNotEnabledErr: Label 'Subcontractor Prices action should be enabled for a subcontracting Work Center.';
-}
+}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWIPTransCreateTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWIPTransCreateTest.Codeunit.al
index 41a48c569a..5faf350312 100644
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWIPTransCreateTest.Codeunit.al
+++ b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWIPTransCreateTest.Codeunit.al
@@ -1002,8 +1002,9 @@ codeunit 149911 "Subc. WIP Trans. Create Test"
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. WIP Trans. Create Test");
SubSetupLibrary.InitSetupFields();
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
+ // Next lines should be uncommented if the Wizard has been moved to the Base App
+ // SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
+ // SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
LibraryERMCountryData.CreateVATData();
SubSetupLibrary.InitialSetupForGenProdPostingGroup();
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizBOMRtngTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizBOMRtngTest.Codeunit.al
deleted file mode 100644
index 8ef51b7b95..0000000000
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizBOMRtngTest.Codeunit.al
+++ /dev/null
@@ -1,470 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting.Test;
-
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.ProductionBOM;
-using Microsoft.Manufacturing.Routing;
-using Microsoft.Manufacturing.Subcontracting;
-using Microsoft.Purchases.Document;
-
-codeunit 139995 "Subc. Wiz. BOM/Rtng Test"
-{
- Subtype = Test;
- TestPermissions = Disabled;
- TestType = IntegrationTest;
-
- trigger OnRun()
- begin
- // [FEATURE] Subcontracting Management - Production Order Creation Wizard BOM/Routing Selection Tests
- IsInitialized := false;
- end;
-
- var
- Assert: Codeunit Assert;
- LibrarySetupStorage: Codeunit "Library - Setup Storage";
- LibraryTestInitialize: Codeunit "Library - Test Initialize";
- SubCreateProdOrdWizLibrary: Codeunit "Subc. CreateProdOrdWizLibrary";
- LibraryMfgManagement: Codeunit "Subc. Library Mfg. Management";
- SubcontractingMgmtLibrary: Codeunit "Subc. Management Library";
- ProdOrderCheckLib: Codeunit "Subc. ProdOrderCheckLib";
- SubSetupLibrary: Codeunit "Subc. Setup Library";
- LibraryERMCountryData: Codeunit "Library - ERM Country Data";
- IsInitialized: Boolean;
- WizardFinishedSuccessfully: Boolean;
- WizardWasOpened: Boolean;
- BOMNoToSelect, RoutingNoToSelect : Code[20];
-
- // ==================== SCENARIO J: BOM/Routing Selection (not just versions) ====================
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardSelectDifferentBOM,SelectBOM')]
- procedure TestJ1_SelectDifferentBOM_LinesExchanged()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo1, BOMNo2 : Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO J1] Different BOM selected - BOM lines are exchanged
- // [GIVEN] Item with BOM and Routing, alternate BOM exists
- Initialize();
-
- // Create two different BOMs with different components
- BOMNo1 := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- BOMNo2 := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines(); // This will have different component items
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo1, RoutingNo);
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set the BOM to select in the handler
- BOMNoToSelect := BOMNo2;
-
- // [WHEN] Run the Production Order Creation Wizard and select different BOM
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and used the selected BOM
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created with the selected BOM components
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Create expected temporary components from the selected BOM
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo2, PurchLine);
-
- // Verify that the components match the selected BOM
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardSelectDifferentRouting,SelectRouting')]
- procedure TestJ2_SelectDifferentRouting_LinesExchanged()
- var
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo1, RoutingNo2 : Code[20];
- begin
- // [SCENARIO J2] Different Routing selected - Routing lines are exchanged
- // [GIVEN] Item with BOM and Routing, alternate Routing exists
- Initialize();
-
- // Create two different Routings with different operations
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo1 := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- RoutingNo2 := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines(); // This will have different work centers
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo1);
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set the Routing to select in the handler
- RoutingNoToSelect := RoutingNo2;
-
- // [WHEN] Run the Production Order Creation Wizard and select different Routing
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and used the selected Routing
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created with the selected Routing lines
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Create expected temporary routing lines from the selected Routing
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo2);
-
- // Verify that the routing lines match the selected Routing
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardSelectBothDifferent,SelectBOM,SelectRouting')]
- procedure TestJ3_SelectDifferentBOMAndRouting_BothLinesExchanged()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo1, BOMNo2 : Code[20];
- ItemNo: Code[20];
- RoutingNo1, RoutingNo2 : Code[20];
- begin
- // [SCENARIO J3] Different BOM and Routing selected - Both component and routing lines are exchanged
- // [GIVEN] Item with BOM and Routing, alternate BOM and Routing exist
- Initialize();
-
- // Create two different BOMs and Routings
- BOMNo1 := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- BOMNo2 := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo1 := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- RoutingNo2 := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo1, RoutingNo1);
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set the BOM and Routing to select in the handlers
- BOMNoToSelect := BOMNo2;
- RoutingNoToSelect := RoutingNo2;
-
- // [WHEN] Run the Production Order Creation Wizard and select different BOM and Routing
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and used both selected BOM and Routing
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Create expected temporary components from the selected BOM
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo2, PurchLine);
- // Create expected temporary routing lines from the selected Routing
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo2);
-
- // Verify that both components and routing lines match the selected BOM and Routing
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardSelectSameBOM,SelectBOM')]
- procedure TestJ4_SelectSameBOM_NoChanges()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO J4] Same BOM selected - No changes should occur
- // [GIVEN] Item with BOM and Routing
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set the same BOM to select in the handler
- BOMNoToSelect := BOMNo;
-
- // [WHEN] Run the Production Order Creation Wizard and select the same BOM
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully with original BOM
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created with original BOM components
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Create expected temporary components from the original BOM
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo, PurchLine);
-
- // Verify that the components match the original BOM
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- end;
-
- // ==================== MODAL PAGE HANDLERS ====================
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardSelectDifferentBOM(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- NewItemNo: Text;
- OriginalItemNo: Text;
- begin
- // [SCENARIO J1] Handle wizard to select different BOM and verify lines are updated
- WizardWasOpened := true;
-
- // Navigate to BOM step
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- // Get the current BOM lines before changing BOM
- if PurchProvisionWizard.BOMLinesPart.First() then
- OriginalItemNo := PurchProvisionWizard.BOMLinesPart."No.".Value();
-
- // Select the different BOM
- PurchProvisionWizard."Production BOM No.".AssistEdit();
-
- // Verify that the BOM lines have been updated after BOM change
- if PurchProvisionWizard.BOMLinesPart.First() then begin
- NewItemNo := PurchProvisionWizard.BOMLinesPart."No.".Value();
- // The lines should be different between BOMs (different component items)
- Assert.AreNotEqual(OriginalItemNo, NewItemNo, 'BOM lines should be updated when BOM is changed');
- end;
-
- // Navigate through remaining wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardSelectDifferentRouting(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- NewWorkCenterNo: Text;
- OriginalWorkCenterNo: Text;
- begin
- // [SCENARIO J2] Handle wizard to select different Routing and verify lines are updated
- WizardWasOpened := true;
-
- // Navigate to BOM step
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- // Navigate to Routing step
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- // Get the current Routing lines before changing Routing
- if PurchProvisionWizard.RoutingLinesPart.First() then
- OriginalWorkCenterNo := PurchProvisionWizard.RoutingLinesPart."No.".Value();
-
- // Select the different Routing
- PurchProvisionWizard."Routing No.".AssistEdit();
-
- // Verify that the Routing lines have been updated after Routing change
- if PurchProvisionWizard.RoutingLinesPart.First() then begin
- NewWorkCenterNo := PurchProvisionWizard.RoutingLinesPart."No.".Value();
- // The lines should be different between Routings (different work centers)
- Assert.AreNotEqual(OriginalWorkCenterNo, NewWorkCenterNo, 'Routing lines should be updated when Routing is changed');
- end;
-
- // Navigate through remaining wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardSelectBothDifferent(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- NewItemNo, OriginalItemNo : Text;
- NewWorkCenterNo, OriginalWorkCenterNo : Text;
- begin
- // [SCENARIO J3] Handle wizard to select different BOM and Routing
- WizardWasOpened := true;
-
- // Navigate to BOM step
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- // Get the current BOM lines before changing BOM
- if PurchProvisionWizard.BOMLinesPart.First() then
- OriginalItemNo := PurchProvisionWizard.BOMLinesPart."No.".Value();
-
- // Select the different BOM
- PurchProvisionWizard."Production BOM No.".AssistEdit();
-
- // Verify that the BOM lines have been updated
- if PurchProvisionWizard.BOMLinesPart.First() then begin
- NewItemNo := PurchProvisionWizard.BOMLinesPart."No.".Value();
- Assert.AreNotEqual(OriginalItemNo, NewItemNo, 'BOM lines should be updated when BOM is changed');
- end;
-
- // Navigate to Routing step
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- // Get the current Routing lines before changing Routing
- if PurchProvisionWizard.RoutingLinesPart.First() then
- OriginalWorkCenterNo := PurchProvisionWizard.RoutingLinesPart."No.".Value();
-
- // Select the different Routing
- PurchProvisionWizard."Routing No.".AssistEdit();
-
- // Verify that the Routing lines have been updated
- if PurchProvisionWizard.RoutingLinesPart.First() then begin
- NewWorkCenterNo := PurchProvisionWizard.RoutingLinesPart."No.".Value();
- Assert.AreNotEqual(OriginalWorkCenterNo, NewWorkCenterNo, 'Routing lines should be updated when Routing is changed');
- end;
-
- // Navigate through remaining wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardSelectSameBOM(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- NewItemNo: Text;
- OriginalItemNo: Text;
- begin
- // [SCENARIO J4] Handle wizard to select same BOM (no changes expected)
- WizardWasOpened := true;
-
- // Navigate to BOM step
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- // Get the current BOM lines before "changing" BOM
- if PurchProvisionWizard.BOMLinesPart.First() then
- OriginalItemNo := PurchProvisionWizard.BOMLinesPart."No.".Value();
-
- // Select the same BOM (this should not change anything)
- PurchProvisionWizard."Production BOM No.".AssistEdit();
-
- // Verify that the BOM lines remain the same
- if PurchProvisionWizard.BOMLinesPart.First() then begin
- NewItemNo := PurchProvisionWizard.BOMLinesPart."No.".Value();
- Assert.AreEqual(OriginalItemNo, NewItemNo, 'BOM lines should remain the same when same BOM is selected');
- end;
-
- // Navigate through remaining wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure SelectBOM(var ProductionBOMList: TestPage "Production BOM List")
- var
- ProductionBOMHeader: Record "Production BOM Header";
- begin
- ProductionBOMList.First();
- ProductionBOMHeader.Get(BOMNoToSelect);
- ProductionBOMList.GoToRecord(ProductionBOMHeader);
- ProductionBOMList.OK().Invoke();
- end;
-
- [ModalPageHandler]
- procedure SelectRouting(var RoutingList: TestPage "Routing List")
- var
- RoutingHeader: Record "Routing Header";
- begin
- RoutingList.First();
- RoutingHeader.Get(RoutingNoToSelect);
- RoutingList.GoToRecord(RoutingHeader);
- RoutingList.OK().Invoke();
- end;
-
- local procedure Initialize()
- begin
- LibraryTestInitialize.OnTestInitialize(Codeunit::"Subc. Wiz. BOM/Rtng Test");
- LibrarySetupStorage.Restore();
-
- if IsInitialized then
- exit;
- LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. Wiz. BOM/Rtng Test");
-
- SubcontractingMgmtLibrary.Initialize();
- LibraryMfgManagement.Initialize();
- SubSetupLibrary.InitSetupFields();
- LibraryERMCountryData.CreateVATData();
- SubSetupLibrary.InitialSetupForGenProdPostingGroup();
-
- IsInitialized := true;
- Commit();
-
- LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Subc. Wiz. BOM/Rtng Test");
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizChangeTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizChangeTest.Codeunit.al
deleted file mode 100644
index a792066b7b..0000000000
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizChangeTest.Codeunit.al
+++ /dev/null
@@ -1,819 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting.Test;
-
-using Microsoft.Inventory.Item;
-using Microsoft.Manufacturing.Capacity;
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.Setup;
-using Microsoft.Manufacturing.Subcontracting;
-using Microsoft.Manufacturing.WorkCenter;
-using Microsoft.Purchases.Document;
-
-codeunit 139980 "Subc. Wiz. Change Test"
-{
- Subtype = Test;
- TestPermissions = Disabled;
- TestType = IntegrationTest;
-
- trigger OnRun()
- begin
- // [FEATURE] Subcontracting Management - Production Order Creation Wizard Change Tests
- IsInitialized := false;
- end;
-
- var
- Assert: Codeunit Assert;
- LibrarySetupStorage: Codeunit "Library - Setup Storage";
- LibraryTestInitialize: Codeunit "Library - Test Initialize";
- SubCreateProdOrdWizLibrary: Codeunit "Subc. CreateProdOrdWizLibrary";
- LibraryMfgManagement: Codeunit "Subc. Library Mfg. Management";
- SubcontractingMgmtLibrary: Codeunit "Subc. Management Library";
- ProdOrderCheckLib: Codeunit "Subc. ProdOrderCheckLib";
- SubSetupLibrary: Codeunit "Subc. Setup Library";
- LibraryERMCountryData: Codeunit "Library - ERM Country Data";
- IsInitialized: Boolean;
- WizardFinishedSuccessfully: Boolean;
- WizardWasOpened: Boolean;
- NewComponentNo, NewWorkCenterNo : Code[20];
- ModifiedQuantity: Decimal;
- ModifiedRunTime: Decimal;
-
- // ==================== SCENARIO N: Component Change Tests ====================
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardModifyComponents')]
- procedure TestN1_ComponentQuantityChanged_ChangesAppliedToProdOrder()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO N1] Component quantity modified in wizard - Changes should be applied to production order
- // [GIVEN] Item with BOM/Routing, wizard allows component editing
- Initialize();
-
- // Create item with BOM/Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit components
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Show, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set test parameters for handler
- ModifiedQuantity := 5.5; // Change quantity from default
-
- // [WHEN] Run the Production Order Creation Wizard with component modifications
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and component changes should be applied
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Create expected temporary records with modified quantity
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo, PurchLine);
- UpdateTempComponentQuantity(TempProdOrderComponent, ModifiedQuantity);
-
- // Verify production order and components
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardAddComponent')]
- procedure TestN2_ComponentAdded_NewComponentInProdOrder()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO N2] Component added in wizard - New component should appear in production order
- // [GIVEN] Item with BOM/Routing, wizard allows component editing
- Initialize();
-
- // Create item with BOM/Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit components
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Show, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Create new component item
- NewComponentNo := CreateTestItem();
-
- // Set test parameters for handler
- ModifiedQuantity := 2.0;
-
- // [WHEN] Run the Production Order Creation Wizard with component addition
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and new component should be added
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Create expected temporary records with additional component
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo, PurchLine);
- AddTempComponent(TempProdOrderComponent, NewComponentNo, ModifiedQuantity, PurchLine);
-
- // Verify production order and components
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardDeleteComponent')]
- procedure TestN3_ComponentDeleted_ComponentRemovedFromProdOrder()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- FinalComponentCount: Integer;
- OriginalComponentCount: Integer;
- begin
- // [SCENARIO N3] Component deleted in wizard - Component should be removed from production order
- // [GIVEN] Item with BOM/Routing, wizard allows component editing
- Initialize();
-
- // Create item with BOM/Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Get original component count
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo, PurchLine);
- OriginalComponentCount := TempProdOrderComponent.Count();
-
- // Configure setup to edit components
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Show, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard with component deletion
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and component should be deleted
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Create expected temporary records with one less component
- Clear(TempProdOrderComponent);
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo, PurchLine);
- RemoveTempComponent(TempProdOrderComponent);
- FinalComponentCount := TempProdOrderComponent.Count();
-
- // Verify component was deleted
- Assert.AreEqual(OriginalComponentCount - 1, FinalComponentCount, 'One component should have been deleted');
-
- // Verify production order and components
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- end;
-
- // ==================== SCENARIO O: Routing Change Tests ====================
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardModifyRouting')]
- procedure TestO1_RoutingOperationChanged_ChangesAppliedToProdOrder()
- var
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO O1] Routing operation modified in wizard - Changes should be applied to production order
- // [GIVEN] Item with BOM/Routing, wizard allows routing editing
- Initialize();
-
- // Create item with BOM/Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit routing
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Show, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set test parameters for handler
- ModifiedRunTime := 120.5; // Change run time from default
-
- // [WHEN] Run the Production Order Creation Wizard with routing modifications
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and routing changes should be applied
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Create expected temporary records with modified run time
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo);
- UpdateTempRoutingRunTime(TempProdOrderRoutingLine, ModifiedRunTime);
-
- // Verify production order and routing
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardAddRoutingOperation')]
- procedure TestO2_RoutingOperationAdded_NewOperationInProdOrder()
- var
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- FinalOperationCount: Integer;
- OriginalOperationCount: Integer;
- begin
- // [SCENARIO O2] Routing operation added in wizard - New operation should appear in production order
- // [GIVEN] Item with BOM/Routing, wizard allows routing editing
- Initialize();
-
- // Create item with BOM/Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Get original operation count
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo);
- OriginalOperationCount := TempProdOrderRoutingLine.Count();
-
- // Configure setup to edit routing
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Show, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set test parameters for handler
- ModifiedRunTime := 60.0;
- NewWorkCenterNo := CreateWorkCenterNo(); // Create or use existing work center
-
- // [WHEN] Run the Production Order Creation Wizard with routing operation addition
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and new operation should be added
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Create expected temporary records with additional operation
- Clear(TempProdOrderRoutingLine);
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo);
- AddTempRoutingOperation(TempProdOrderRoutingLine, '0030', ModifiedRunTime);
- FinalOperationCount := TempProdOrderRoutingLine.Count();
-
- // Verify operation was added
- Assert.AreEqual(OriginalOperationCount + 1, FinalOperationCount, 'One operation should have been added');
-
- // Verify production order and routing
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardDeleteRoutingOperation')]
- procedure TestO3_RoutingOperationDeleted_OperationRemovedFromProdOrder()
- var
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- FinalOperationCount: Integer;
- OriginalOperationCount: Integer;
- begin
- // [SCENARIO O3] Routing operation deleted in wizard - Operation should be removed from production order
- // [GIVEN] Item with BOM/Routing, wizard allows routing editing
- Initialize();
-
- // Create item with BOM/Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Get original operation count
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo);
- OriginalOperationCount := TempProdOrderRoutingLine.Count();
-
- // Configure setup to edit routing
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Show, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard with routing operation deletion
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and operation should be deleted
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Create expected temporary records without deleted operation
- Clear(TempProdOrderRoutingLine);
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo);
- RemoveTempRoutingOperation(TempProdOrderRoutingLine);
- FinalOperationCount := TempProdOrderRoutingLine.Count();
-
- // Verify operation was deleted
- Assert.AreEqual(OriginalOperationCount - 1, FinalOperationCount, 'One operation should have been deleted');
-
- // Verify production order and routing
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- // ==================== SCENARIO P: Combined Change Tests ====================
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardModifyBoth')]
- procedure TestP1_BothComponentsAndRoutingChanged_AllChangesApplied()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO P1] Both components and routing modified in wizard - All changes should be applied to production order
- // [GIVEN] Item with BOM/Routing, wizard allows editing both
- Initialize();
-
- // Create item with BOM/Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Show, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set test parameters for handler
- ModifiedQuantity := 3.5;
- ModifiedRunTime := 90.0;
-
- // [WHEN] Run the Production Order Creation Wizard with both modifications
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and all changes should be applied
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Create expected temporary records with modifications
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo, PurchLine);
- UpdateTempComponentQuantity(TempProdOrderComponent, ModifiedQuantity);
-
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo);
- UpdateTempRoutingRunTime(TempProdOrderRoutingLine, ModifiedRunTime);
-
- // Verify production order and both components and routing
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardNoChanges')]
- procedure TestP2_NoChanges_OriginalDataUsed()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO P2] No changes made in wizard - Original BOM/Routing data should be used
- // [GIVEN] Item with BOM/Routing, wizard allows editing but no changes made
- Initialize();
-
- // Create item with BOM/Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Show, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard without modifications
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and original data should be used
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Create expected temporary records from original BOM/Routing
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo, PurchLine);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo);
-
- // Verify production order and original data
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- // ==================== MODAL PAGE HANDLERS ====================
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardModifyComponents(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- Step: Option Intro,BOM,Routing,Components,ProdRouting;
- begin
- // Handle wizard with component modifications
- WizardWasOpened := true;
-
- Step := Step::Intro;
- // Navigate through all wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- Step := Step + 1;
- // Check if we're on the components step
- if Step = Step::Components then begin
- Assert.IsTrue(PurchProvisionWizard.ComponentsPart.Editable(), 'Components part should be editable');
- // Modify the first component's quantity
- PurchProvisionWizard.ComponentsPart.First();
- PurchProvisionWizard.ComponentsPart."Quantity per".SetValue(ModifiedQuantity);
- end;
- end;
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardAddComponent(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- Step: Option Intro,BOM,Routing,Components,ProdRouting;
- begin
- // Handle wizard with component addition
- WizardWasOpened := true;
-
- Step := Step::Intro;
- // Navigate to components step
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- Step := Step + 1;
- // Check if we're on the components step
- if Step = Step::Components then begin
- // Add a new component line
- Assert.IsTrue(PurchProvisionWizard.ComponentsPart.Editable(), 'Components part should be editable');
- PurchProvisionWizard.ComponentsPart."Item No.".SetValue(NewComponentNo);
- PurchProvisionWizard.ComponentsPart."Quantity per".SetValue(ModifiedQuantity);
- end;
- end;
-
- // Continue to finish
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardDeleteComponent(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- Step: Option Intro,BOM,Routing,Components,ProdRouting;
- begin
- // Handle wizard with component deletion
- WizardWasOpened := true;
-
- Step := Step::Intro;
- // Navigate to components step
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- Step := Step + 1;
- // Check if we're on the components step
- if Step = Step::Components then begin
- Assert.IsTrue(PurchProvisionWizard.ComponentsPart.Editable(), 'Components part should be editable');
- // Delete the first component using Sub Delete action
- PurchProvisionWizard.ComponentsPart.First();
- PurchProvisionWizard.ComponentsPart."Sub Delete".Invoke();
- end;
- end;
-
- // Continue to finish
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardAddRoutingOperation(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- Step: Option Intro,BOM,Routing,Components,ProdRouting;
- begin
- // Handle wizard with routing operation addition
- WizardWasOpened := true;
-
- Step := Step::Intro;
-
- // Navigate to routing step
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- Step := Step + 1;
- // Check if we're on the routing step
- if Step = Step::ProdRouting then begin
- // Add a new routing operation
- Assert.IsTrue(PurchProvisionWizard.ProdOrderRoutingPart.Editable(), 'Routing part should be editable');
- PurchProvisionWizard.ProdOrderRoutingPart.New();
- PurchProvisionWizard.ProdOrderRoutingPart."Operation No.".SetValue('0030');
- PurchProvisionWizard.ProdOrderRoutingPart.Type.SetValue("Capacity Type"::"Work Center");
- PurchProvisionWizard.ProdOrderRoutingPart."No.".SetValue(NewWorkCenterNo);
- PurchProvisionWizard.ProdOrderRoutingPart."Run Time".SetValue(ModifiedRunTime);
- end;
- end;
-
- // Continue to finish
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardDeleteRoutingOperation(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- Step: Option Intro,BOM,Routing,Components,ProdRouting;
- begin
- // Handle wizard with routing operation deletion
- WizardWasOpened := true;
-
- Step := Step::Intro;
- // Navigate to routing step
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- Step := Step + 1;
- // Check if we're on the routing step
- if Step = Step::ProdRouting then begin
- Assert.IsTrue(PurchProvisionWizard.ProdOrderRoutingPart.Editable(), 'Routing part should be editable');
- // Delete the first routing operation using Sub Delete action
- PurchProvisionWizard.ProdOrderRoutingPart.First();
- PurchProvisionWizard.ProdOrderRoutingPart."Sub Delete".Invoke();
- end;
- end;
-
- // Continue to finish
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardModifyRouting(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- Step: Option Intro,BOM,Routing,Components,ProdRouting;
- begin
- // Handle wizard with routing modifications
- WizardWasOpened := true;
-
- Step := Step::Intro;
- // Navigate through all wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- Step := Step + 1;
- if Step = Step::ProdRouting then begin
- // Modify the first routing line's run time
- Assert.IsTrue(PurchProvisionWizard.ProdOrderRoutingPart.Editable(), 'Routing part should be editable');
- PurchProvisionWizard.ProdOrderRoutingPart.First();
- PurchProvisionWizard.ProdOrderRoutingPart."Run Time".SetValue(ModifiedRunTime);
- end;
- end;
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardModifyBoth(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- Step: Option Intro,BOM,Routing,Components,ProdRouting;
- begin
- // Handle wizard with both component and routing modifications
- WizardWasOpened := true;
-
- Step := Step::Intro;
- // Navigate through all wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- Step := Step + 1;
- if Step = Step::Components then begin
- // Modify the first component's quantity
- Assert.IsTrue(PurchProvisionWizard.ComponentsPart.Editable(), 'Components part should be editable');
- PurchProvisionWizard.ComponentsPart.First();
- PurchProvisionWizard.ComponentsPart."Quantity per".SetValue(ModifiedQuantity);
- end else
- if Step = Step::ProdRouting then begin
- // Modify the first routing line's run time
- Assert.IsTrue(PurchProvisionWizard.ProdOrderRoutingPart.Editable(), 'Routing part should be editable');
- PurchProvisionWizard.ProdOrderRoutingPart.First();
- PurchProvisionWizard.ProdOrderRoutingPart."Run Time".SetValue(ModifiedRunTime);
- end;
- end;
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardNoChanges(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // Handle wizard without any changes
- WizardWasOpened := true;
-
- // Navigate through all wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- // ==================== HELPER METHODS ====================
-
- local procedure Initialize()
- begin
- LibraryTestInitialize.OnTestInitialize(Codeunit::"Subc. Wiz. Change Test");
- LibrarySetupStorage.Restore();
-
- if IsInitialized then
- exit;
- LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. Wiz. Change Test");
-
- SubcontractingMgmtLibrary.Initialize();
- LibraryMfgManagement.Initialize();
- SubSetupLibrary.InitSetupFields();
- LibraryERMCountryData.CreateVATData();
- SubSetupLibrary.InitialSetupForGenProdPostingGroup();
-
- IsInitialized := true;
- Commit();
-
- LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Subc. Wiz. Change Test");
- end;
-
- local procedure UpdateTempComponentQuantity(var TempProdOrderComponent: Record "Prod. Order Component" temporary; NewQuantity: Decimal)
- begin
- // Update the first component's quantity
- TempProdOrderComponent.Reset();
- if TempProdOrderComponent.FindFirst() then begin
- TempProdOrderComponent."Quantity per" := NewQuantity;
- TempProdOrderComponent.Modify();
- end;
- end;
-
- local procedure AddTempComponent(var TempProdOrderComponent: Record "Prod. Order Component" temporary; ItemNo: Code[20]; Quantity: Decimal; PurchLine: Record "Purchase Line")
- var
- LineNo: Integer;
- begin
- // Add a new component to temporary records
- TempProdOrderComponent.Reset();
- if TempProdOrderComponent.FindLast() then
- LineNo := TempProdOrderComponent."Line No." + 10000
- else
- LineNo := 10000;
-
- TempProdOrderComponent.Init();
- TempProdOrderComponent."Line No." := LineNo;
- TempProdOrderComponent."Item No." := ItemNo;
- TempProdOrderComponent."Quantity per" := Quantity;
- TempProdOrderComponent."Location Code" := PurchLine."Location Code";
-#pragma warning disable AL0432
- TempProdOrderComponent."Flushing Method" := "Flushing Method"::Manual;
-#pragma warning restore AL0432
- TempProdOrderComponent.Insert();
- end;
-
- local procedure UpdateTempRoutingRunTime(var TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary; NewRunTime: Decimal)
- begin
- // Update the first routing line's run time
- TempProdOrderRoutingLine.Reset();
- if TempProdOrderRoutingLine.FindFirst() then begin
- TempProdOrderRoutingLine."Run Time" := NewRunTime;
- TempProdOrderRoutingLine.Modify();
- end;
- end;
-
- local procedure RemoveTempComponent(var TempProdOrderComponent: Record "Prod. Order Component" temporary)
- begin
- // Remove the first component from temporary records
- TempProdOrderComponent.Reset();
- if TempProdOrderComponent.FindFirst() then
- TempProdOrderComponent.Delete();
- end;
-
- local procedure AddTempRoutingOperation(var TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary; OperationNo: Code[10]; RunTime: Decimal)
- begin
- // Add a new routing operation to temporary records
- TempProdOrderRoutingLine.Reset();
-
- TempProdOrderRoutingLine.Init();
- TempProdOrderRoutingLine."Operation No." := OperationNo;
- TempProdOrderRoutingLine.Type := TempProdOrderRoutingLine.Type::"Work Center";
- TempProdOrderRoutingLine."No." := NewWorkCenterNo;
- TempProdOrderRoutingLine."Work Center No." := NewWorkCenterNo;
- TempProdOrderRoutingLine."Run Time" := RunTime;
- TempProdOrderRoutingLine.Insert();
- end;
-
- local procedure RemoveTempRoutingOperation(var TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary)
- begin
- // Remove the first routing operation from temporary records
- TempProdOrderRoutingLine.Reset();
- if TempProdOrderRoutingLine.FindFirst() then
- TempProdOrderRoutingLine.Delete();
- end;
-
- local procedure CreateTestItem(): Code[20]
- var
- Item: Record Item;
- LibraryInventory: Codeunit "Library - Inventory";
- begin
- LibraryInventory.CreateItem(Item);
- exit(Item."No.");
- end;
-
- local procedure CreateWorkCenterNo(): Code[20]
- var
- WorkCenter: Record "Work Center";
- begin
- LibraryMfgManagement.CreateWorkCenterWithCalendar(WorkCenter, 1);
- exit(WorkCenter."No.");
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizConfigTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizConfigTest.Codeunit.al
deleted file mode 100644
index f26555c246..0000000000
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizConfigTest.Codeunit.al
+++ /dev/null
@@ -1,1067 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting.Test;
-
-using Microsoft.Manufacturing.Subcontracting;
-using Microsoft.Purchases.Document;
-
-codeunit 139994 "Subc. Wiz. Config Test"
-{
- Subtype = Test;
- TestPermissions = Disabled;
- TestType = IntegrationTest;
-
- trigger OnRun()
- begin
- // [FEATURE] Subcontracting Management - Production Order Creation Wizard Configuration Tests
- IsInitialized := false;
- end;
-
- var
- Assert: Codeunit Assert;
- LibraryERMCountryData: Codeunit "Library - ERM Country Data";
- LibrarySetupStorage: Codeunit "Library - Setup Storage";
- LibraryTestInitialize: Codeunit "Library - Test Initialize";
- SubCreateProdOrdWizLibrary: Codeunit "Subc. CreateProdOrdWizLibrary";
- LibraryMfgManagement: Codeunit "Subc. Library Mfg. Management";
- SubcontractingMgmtLibrary: Codeunit "Subc. Management Library";
- SubSetupLibrary: Codeunit "Subc. Setup Library";
- IsInitialized: Boolean;
- WizardFinishedSuccessfully: Boolean;
- WizardWasOpened: Boolean;
- ExpectedStepWasNotVisitedLbl: Label 'Expected step %1 was not visited', Locked = true;
- ExpectedSteps: List of [Text];
- StepsVisited: List of [Text];
-
- // ==================== SCENARIO B: Setup Configuration (Display) ====================
-
- [Test]
- // [HandlerFunctions('HandlePurchProvisionWizardNotExpected')]
- procedure TestB1_BothHide_WizardNotOpened()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO B1] Both "Do not show" - Wizard does not open at all, production order is created automatically
- // [GIVEN] Item with both BOM and Routing, setup configured to hide both
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to hide both BOM/Routing and ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation process
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should not have opened, but production order should be created automatically
- Assert.IsFalse(WizardWasOpened, 'Wizard should not have opened when both are set to Hide');
- // Production order should still be created automatically
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created automatically');
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardBOMRtngOnly')]
- procedure TestB2_BOMRtngEdit_ProdRtngCompHide_OnlyBOMRtngShown()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO B2] BOM "Edit", Routing "Do not show" - Only BOM is opened in wizard for viewing & editing
- // [GIVEN] Item with both BOM and Routing, setup configured to edit BOM and hide Routing
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit BOM/Routing and hide ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Hide);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> BOM -> Routing (finish here because ProdComp/Routing are hidden)
- SetExpectedSteps('Intro,BOM,Routing');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, showing only BOM editing
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when BOM is set to Edit');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardProdRtngCompOnly')]
- procedure TestB3_ProdRtngCompEdit_BOMRtngHide_OnlyProdRtngCompShown()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO B3] Routing "Edit", BOM "Do not show" - Only routing is opened in wizard for viewing & editing
- // [GIVEN] Item with both BOM and Routing, setup configured to hide BOM and edit Routing
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to hide BOM/Routing and edit ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> Components -> ProdRouting (BOM/Routing steps are hidden)
- SetExpectedSteps('Intro,Components,ProdRouting');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, showing only Routing editing
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when Routing is set to Edit');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardBothShownEdit')]
- procedure TestB4_BothEdit_BothShownEdit()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO B4] Both "Edit" - Both are opened in wizard for viewing & editing
- // [GIVEN] Item with both BOM and Routing, setup configured to edit both
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit both BOM/Routing and ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: All steps should be visible
- SetExpectedSteps('Intro,BOM,Routing,Components,ProdRouting');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, showing both BOM and Routing editing
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when both are set to Edit');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardBOMSelect')]
- procedure TestB6_BOMSelect_ProdRoutingHide_BOMViewOnly()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO B6] BOM "Select" instead of "Edit" - BOM is only displayed for viewing in wizard -> lines are not editable
- // [GIVEN] Item with both BOM and Routing, setup configured to select BOM (view only) and hide Routing
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to select BOM/Routing (view only) and hide ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Show, "Subc. Show/Edit Type"::Hide);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> BOM -> Routing (finish here because ProdComp/Routing are hidden)
- SetExpectedSteps('Intro,BOM,Routing');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, showing BOM for selection only (not editable)
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when BOM is set to Select');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardRoutingSelect')]
- procedure TestB7_ProdRoutingSelect_BOMHide_ProdRoutingViewOnly()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO B7] Routing "Select" instead of "Edit" - Routing is only displayed for viewing in wizard -> lines are not editable
- // [GIVEN] Item with both BOM and Routing, setup configured to hide BOM and select Routing (view only)
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to hide BOM/Routing and select ProdRouting/Components (view only)
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Show);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> Components -> ProdRouting (BOM/Routing steps are hidden)
- SetExpectedSteps('Intro,Components,ProdRouting');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, showing Routing for selection only (not editable)
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when Routing is set to Select');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardComponentsEdit')]
- procedure TestB8_ComponentsEdit_LinesEditable()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO B8] Components / Production routing operations "Edit" - Lines are editable
- // [GIVEN] Item with both BOM and Routing, setup configured to edit Production Components/Routing
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to hide BOM/Routing and edit ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> Components -> ProdRouting (BOM/Routing steps are hidden)
- SetExpectedSteps('Intro,Components,ProdRouting');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, with editable components and routing
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when Components/Routing are set to Edit');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardComponentsHide')]
- procedure TestB10_ComponentsHide_LinesNotDisplayed()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO B10] Components / Production routing operations "Do not show" - Lines are not displayed at all
- // [GIVEN] Item with both BOM and Routing, setup configured to hide Production Components/Routing
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit BOM/Routing and hide ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Hide);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> BOM -> Routing (Components/ProdRouting steps are hidden)
- SetExpectedSteps('Intro,BOM,Routing');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, without showing components and routing steps
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when BOM/Routing are set to Edit');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardBOMSelect')]
- procedure TestB61_BOMSelect_ProdRoutingHide_BOMViewOnly()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO B6] BOM "Select" instead of "Edit" - BOM is only displayed for viewing in wizard -> lines are not editable
- // [GIVEN] Item with Partially BOM and Routing, setup configured to select BOM (view only) and hide Routing
- Initialize();
-
- // Create BOM and Routing
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting('', RoutingNo);
-
- // Configure setup to select BOM/Routing (view only) and hide ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForPartiallyPresentScenario("Subc. Show/Edit Type"::Show, "Subc. Show/Edit Type"::Hide);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> BOM -> Routing (finish here because ProdComp/Routing are hidden)
- SetExpectedSteps('Intro,BOM,Routing');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, showing BOM for selection only (not editable)
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when BOM is set to Select');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardRoutingSelect')]
- procedure TestB71_ProdRoutingSelect_BOMHide_ProdRoutingViewOnly()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- begin
- // [SCENARIO B7] Routing "Select" instead of "Edit" - Routing is only displayed for viewing in wizard -> lines are not editable
- // [GIVEN] Item with Partially BOM and Routing, setup configured to hide BOM and select Routing (view only)
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, '');
-
- // Configure setup to hide BOM/Routing and select ProdRouting/Components (view only)
- SubSetupLibrary.ConfigureSubManagementForPartiallyPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Show);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> Components -> ProdRouting (BOM/Routing steps are hidden)
- SetExpectedSteps('Intro,Components,ProdRouting');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, showing Routing for selection only (not editable)
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when Routing is set to Select');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardComponentsEdit')]
- procedure TestB81_ComponentsEdit_LinesEditable()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- begin
- // [SCENARIO B8] Components / Production routing operations "Edit" - Lines are editable
- // [GIVEN] Item with Partially BOM and Routing, setup configured to edit Production Components/Routing
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, '');
-
- // Configure setup to hide BOM/Routing and edit ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForPartiallyPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> Components -> ProdRouting (BOM/Routing steps are hidden)
- SetExpectedSteps('Intro,Components,ProdRouting');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, with editable components and routing
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when Components/Routing are set to Edit');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardComponentsHide')]
- procedure TestB101_ComponentsHide_LinesNotDisplayed()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO B10] Components / Production routing operations "Do not show" - Lines are not displayed at all
- // [GIVEN] Item with Partially BOM and Routing, setup configured to hide Production Components/Routing
- Initialize();
-
- // Create BOM and Routing
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting('', RoutingNo);
-
- // Configure setup to edit BOM/Routing and hide ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForPartiallyPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Hide);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> BOM -> Routing (Components/ProdRouting steps are hidden)
- SetExpectedSteps('Intro,BOM,Routing');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, without showing components and routing steps
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when BOM/Routing are set to Edit');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardBOMSelect')]
- procedure TestB62_BOMSelect_ProdRoutingHide_BOMViewOnly()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO B6] BOM "Select" instead of "Edit" - BOM is only displayed for viewing in wizard -> lines are not editable
- // [GIVEN] Item with Nothing BOM and Routing, setup configured to select BOM (view only) and hide Routing
- Initialize();
-
- // Create BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting('', '');
-
- // Configure setup to select BOM/Routing (view only) and hide ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Show, "Subc. Show/Edit Type"::Hide);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> BOM -> Routing (finish here because ProdComp/Routing are hidden)
- SetExpectedSteps('Intro,BOM,Routing');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, showing BOM for selection only (not editable)
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when BOM is set to Select');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardRoutingSelect')]
- procedure TestB72_ProdRoutingSelect_BOMHide_ProdRoutingViewOnly()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO B7] Routing "Select" instead of "Edit" - Routing is only displayed for viewing in wizard -> lines are not editable
- // [GIVEN] Item with Nothing BOM and Routing, setup configured to hide BOM and select Routing (view only)
- Initialize();
-
- // Create BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting('', '');
-
- // Configure setup to hide BOM/Routing and select ProdRouting/Components (view only)
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Show);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> Components -> ProdRouting (BOM/Routing steps are hidden)
- SetExpectedSteps('Intro,Components,ProdRouting');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, showing Routing for selection only (not editable)
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when Routing is set to Select');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardComponentsEdit')]
- procedure TestB82_ComponentsEdit_LinesEditable()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO B8] Components / Production routing operations "Edit" - Lines are editable
- // [GIVEN] Item with Nothing BOM and Routing, setup configured to edit Production Components/Routing
- Initialize();
-
- // Create BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting('', '');
-
- // Configure setup to hide BOM/Routing and edit ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> Components -> ProdRouting (BOM/Routing steps are hidden)
- SetExpectedSteps('Intro,Components,ProdRouting');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, with editable components and routing
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when Components/Routing are set to Edit');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardComponentsHide')]
- procedure TestB102_ComponentsHide_LinesNotDisplayed()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO B10] Components / Production routing operations "Do not show" - Lines are not displayed at all
- // [GIVEN] Item with Nothing BOM and Routing, setup configured to hide Production Components/Routing
- Initialize();
-
- // Create BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting('', '');
-
- // Configure setup to edit BOM/Routing and hide ProdRouting/Components
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Hide);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected steps: Intro -> BOM -> Routing (Components/ProdRouting steps are hidden)
- SetExpectedSteps('Intro,BOM,Routing');
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Clear(StepsVisited);
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and finished successfully, without showing components and routing steps
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened when BOM/Routing are set to Edit');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- VerifyExpectedStepsVisited();
- end;
-
- // ==================== HELPER PROCEDURES====================
-
- local procedure SetExpectedSteps(StepsList: Text)
- var
- StepArray: List of [Text];
- Step: Text;
- begin
- Clear(ExpectedSteps);
- StepArray := StepsList.Split(',');
- foreach Step in StepArray do
- ExpectedSteps.Add(Step);
- end;
-
- local procedure VerifyExpectedStepsVisited()
- var
- i: Integer;
- ExpectedStep: Text;
- begin
- Assert.AreEqual(ExpectedSteps.Count(), StepsVisited.Count(), 'Number of visited steps should match expected steps');
-
- for i := 1 to ExpectedSteps.Count() do begin
- ExpectedSteps.Get(i, ExpectedStep);
- Assert.IsTrue(StepsVisited.Contains(ExpectedStep), StrSubstNo(ExpectedStepWasNotVisitedLbl, ExpectedStep));
- end;
- end;
-
- local procedure RecordStepVisited(StepName: Text)
- begin
- if not StepsVisited.Contains(StepName) then
- StepsVisited.Add(StepName);
- end;
-
- // ==================== MODAL PAGE HANDLERS ====================
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardNotExpected(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // This handler should not be called for B1 scenario
- WizardWasOpened := true;
- Error('Wizard should not have opened when both settings are set to Hide');
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardBOMRtngOnly(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- StepCount: Integer;
- begin
- // [SCENARIO B2] Handle wizard when only BOM editing is enabled
- WizardWasOpened := true;
-
- // Record that we started (Intro step)
- RecordStepVisited('Intro');
-
- // Navigate through the wizard and count steps
- StepCount := 0;
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- StepCount += 1;
-
- // Record steps based on expected flow: BOM -> Routing (then finish because ProdComp/Routing are hidden)
- case StepCount of
- 1:
- RecordStepVisited('BOM');
- 2:
- RecordStepVisited('Routing');
- else
- RecordStepVisited('Unexpected Step');
- end;
- end;
-
- // Should be able to finish after BOM and Routing steps (ProdComp/Routing are hidden)
- Assert.IsTrue(PurchProvisionWizard.ActionFinish.Enabled(), 'Finish should be enabled when ProdComp/Routing are hidden');
- Assert.AreEqual(2, StepCount, 'Should have navigated through 2 steps (BOM, Routing) when ProdComp/Routing are hidden');
-
- // Finish the wizard
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardProdRtngCompOnly(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- StepCount: Integer;
- begin
- // [SCENARIO B3] Handle wizard when only Routing editing is enabled
- WizardWasOpened := true;
-
- // Record that we started (Intro step)
- RecordStepVisited('Intro');
-
- // Navigate through the wizard and count steps
- StepCount := 0;
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- StepCount += 1;
-
- // Record steps based on expected flow: Components -> ProdRouting (BOM/Routing steps are hidden)
- case StepCount of
- 1:
- RecordStepVisited('Components');
- 2:
- RecordStepVisited('ProdRouting');
- else
- RecordStepVisited('Unexpected Step');
- end;
- end;
-
- // Should be able to finish after Components and ProdRouting steps (BOM/Routing are hidden)
- Assert.IsTrue(PurchProvisionWizard.ActionFinish.Enabled(), 'Finish should be enabled on ProdRouting step');
- Assert.AreEqual(2, StepCount, 'Should have navigated through 2 steps (Components, ProdRouting) when BOM/Routing are hidden');
-
- // Finish the wizard
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardBothShownEdit(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- StepCount: Integer;
- begin
- // [SCENARIO B4] Handle wizard when both BOM and Routing editing are enabled
- WizardWasOpened := true;
-
- // Record that we started (Intro step)
- RecordStepVisited('Intro');
-
- // Navigate through the wizard and count steps
- StepCount := 0;
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- StepCount += 1;
-
- // Record steps based on expected flow: BOM -> Routing -> Components -> ProdRouting
- case StepCount of
- 1:
- begin
- RecordStepVisited('BOM');
- Assert.IsTrue(PurchProvisionWizard.CreateBOMVersion.Visible(), 'Create BOM Version should be editable when set to Edit');
- end;
- 2:
- begin
- RecordStepVisited('Routing');
- Assert.IsTrue(PurchProvisionWizard.CreateRoutingVersion.Visible(), 'Create Routing Version should be editable when set to Edit');
- end;
- 3:
- begin
- RecordStepVisited('Components');
- Assert.IsTrue(PurchProvisionWizard.ComponentsPart.Editable(), 'Components should be editable when set to Edit');
- end;
- 4:
- begin
- RecordStepVisited('ProdRouting');
- Assert.IsTrue(PurchProvisionWizard.ProdOrderRoutingPart.Editable(), 'ProdRouting should be editable when set to Edit');
- end;
- else
- RecordStepVisited('Unexpected Step');
- end;
- end;
-
- // Should be able to finish after all 4 steps
- Assert.IsTrue(PurchProvisionWizard.ActionFinish.Enabled(), 'Finish should be enabled on ProdRouting step');
- Assert.AreEqual(4, StepCount, 'Should have navigated through 4 steps (BOM, Routing, Components, ProdRouting) when both are enabled');
-
- // Finish the wizard
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardDefaultBehavior(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- StepCount: Integer;
- begin
- // [SCENARIO B5] Handle wizard with default behavior
- WizardWasOpened := true;
-
- // Record that we started (Intro step)
- RecordStepVisited('Intro');
-
- // Navigate through the wizard and count steps
- StepCount := 0;
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- StepCount += 1;
-
- // Record steps based on expected flow: BOM -> Routing -> Components -> ProdRouting (default should be Edit for both)
- case StepCount of
- 1:
- RecordStepVisited('BOM');
- 2:
- RecordStepVisited('Routing');
- 3:
- RecordStepVisited('Components');
- 4:
- RecordStepVisited('ProdRouting');
- else
- RecordStepVisited('Unexpected Step');
- end;
- end;
-
- // Should be able to finish after all 4 steps (default Edit behavior)
- Assert.IsTrue(PurchProvisionWizard.ActionFinish.Enabled(), 'Finish should be enabled on ProdRouting step');
- Assert.AreEqual(4, StepCount, 'Should have navigated through 4 steps (BOM, Routing, Components, ProdRouting) with default Edit behavior');
-
- // Finish the wizard
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardBOMSelect(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- StepCount: Integer;
- begin
- // [SCENARIO B6] Handle wizard when BOM is set to Select (view only) and Routing is hidden
- WizardWasOpened := true;
-
- // Record that we started (Intro step)
- RecordStepVisited('Intro');
-
- // Navigate through the wizard and count steps
- StepCount := 0;
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- StepCount += 1;
-
- // Record steps based on expected flow: BOM -> Routing (then finish because ProdComp/Routing are hidden)
- case StepCount of
- 1:
- begin
- RecordStepVisited('BOM');
- // Verify BOM Version is not editable (Select mode)
- Assert.IsFalse(PurchProvisionWizard.CreateBOMVersion.Visible(), 'Create BOM Version should not be editable when set to Select');
- end;
- 2:
- RecordStepVisited('Routing');
- else
- RecordStepVisited('Unexpected Step');
- end;
- end;
-
- // Should be able to finish after BOM and Routing steps (ProdComp/Routing are hidden)
- Assert.IsTrue(PurchProvisionWizard.ActionFinish.Enabled(), 'Finish should be enabled when ProdComp/Routing are hidden');
- Assert.AreEqual(2, StepCount, 'Should have navigated through 2 steps (BOM, Routing) when ProdComp/Routing are hidden');
-
- // Finish the wizard
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardRoutingSelect(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- StepCount: Integer;
- begin
- // [SCENARIO B7] Handle wizard when Routing is set to Select (view only) and BOM is hidden
- WizardWasOpened := true;
-
- // Record that we started (Intro step)
- RecordStepVisited('Intro');
-
- // Navigate through the wizard and count steps
- StepCount := 0;
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- StepCount += 1;
-
- // Record steps based on expected flow: Components -> ProdRouting (BOM/Routing steps are hidden)
- case StepCount of
- 1:
- begin
- RecordStepVisited('Components');
- // Verify Components are not editable (Select mode)
- Assert.IsFalse(PurchProvisionWizard.ProdCompRoutingShowEditTypeField.Value() = Format("Subc. Show/Edit Type"::Edit), 'Components should not be editable when set to Select');
- end;
- 2:
- begin
- RecordStepVisited('ProdRouting');
- // Verify ProdRouting is not editable (Select mode)
- Assert.IsFalse(PurchProvisionWizard.ProdCompRoutingShowEditTypeField.Value() = Format("Subc. Show/Edit Type"::Edit), 'ProdRouting should not be editable when set to Select');
- end;
- else
- RecordStepVisited('Unexpected Step');
- end;
- end;
-
- // Should be able to finish after Components and ProdRouting steps (BOM/Routing are hidden)
- Assert.IsTrue(PurchProvisionWizard.ActionFinish.Enabled(), 'Finish should be enabled on ProdRouting step');
- Assert.AreEqual(2, StepCount, 'Should have navigated through 2 steps (Components, ProdRouting) when BOM/Routing are hidden');
-
- // Finish the wizard
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardComponentsEdit(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- StepCount: Integer;
- begin
- // [SCENARIO B8] Handle wizard when Components/Routing are set to Edit
- WizardWasOpened := true;
-
- // Record that we started (Intro step)
- RecordStepVisited('Intro');
-
- // Navigate through the wizard and count steps
- StepCount := 0;
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- StepCount += 1;
-
- // Record steps based on expected flow: Components -> ProdRouting (BOM/Routing steps are hidden)
- case StepCount of
- 1:
- begin
- RecordStepVisited('Components');
- // Verify Components are editable (Edit mode)
- Assert.IsTrue(PurchProvisionWizard.ComponentsPart.Editable(), 'Components should be editable when set to Edit');
- end;
- 2:
- begin
- RecordStepVisited('ProdRouting');
- // Verify ProdRouting is editable (Edit mode)
- Assert.IsTrue(PurchProvisionWizard.ProdOrderRoutingPart.Editable(), 'ProdRouting should be editable when set to Edit');
- end;
- else
- RecordStepVisited('Unexpected Step');
- end;
- end;
-
- // Should be able to finish after Components and ProdRouting steps (BOM/Routing are hidden)
- Assert.IsTrue(PurchProvisionWizard.ActionFinish.Enabled(), 'Finish should be enabled on ProdRouting step');
- Assert.AreEqual(2, StepCount, 'Should have navigated through 2 steps (Components, ProdRouting) when BOM/Routing are hidden');
-
- // Finish the wizard
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardComponentsHide(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- StepCount: Integer;
- begin
- // [SCENARIO B10] Handle wizard when Components/Routing are hidden
- WizardWasOpened := true;
-
- // Record that we started (Intro step)
- RecordStepVisited('Intro');
-
- // Navigate through the wizard and count steps
- StepCount := 0;
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- PurchProvisionWizard.ActionNext.Invoke();
- StepCount += 1;
-
- // Record steps based on expected flow: BOM -> Routing (then finish because Components/ProdRouting are hidden)
- case StepCount of
- 1:
- RecordStepVisited('BOM');
- 2:
- RecordStepVisited('Routing');
- else
- RecordStepVisited('Unexpected Step');
- end;
- end;
-
- // Should be able to finish after BOM and Routing steps (Components/ProdRouting are hidden)
- Assert.IsTrue(PurchProvisionWizard.ActionFinish.Enabled(), 'Finish should be enabled when Components/ProdRouting are hidden');
- Assert.AreEqual(2, StepCount, 'Should have navigated through 2 steps (BOM, Routing) when Components/ProdRouting are hidden');
-
- // Finish the wizard
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- local procedure Initialize()
- begin
- LibraryTestInitialize.OnTestInitialize(Codeunit::"Subc. Wiz. Config Test");
- LibrarySetupStorage.Restore();
-
- if IsInitialized then
- exit;
- LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. Wiz. Config Test");
-
- SubcontractingMgmtLibrary.Initialize();
- LibraryMfgManagement.Initialize();
- SubSetupLibrary.InitSetupFields();
- LibraryERMCountryData.CreateVATData();
- SubSetupLibrary.InitialSetupForGenProdPostingGroup();
-
- IsInitialized := true;
- Commit();
-
- LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Subc. Wiz. Config Test");
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizGeneralTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizGeneralTest.Codeunit.al
deleted file mode 100644
index 8d9830636f..0000000000
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizGeneralTest.Codeunit.al
+++ /dev/null
@@ -1,340 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting.Test;
-
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.Subcontracting;
-using Microsoft.Purchases.Document;
-
-codeunit 139993 "Subc. Wiz. General Test"
-{
- Subtype = Test;
- TestPermissions = Disabled;
- TestType = IntegrationTest;
-
- trigger OnRun()
- begin
- // [FEATURE] Subcontracting Management - Production Order Creation Wizard
- IsInitialized := false;
- end;
-
- var
- Assert: Codeunit Assert;
- LibraryERMCountryData: Codeunit "Library - ERM Country Data";
- LibrarySetupStorage: Codeunit "Library - Setup Storage";
- LibraryTestInitialize: Codeunit "Library - Test Initialize";
- SubCreateProdOrdWizLibrary: Codeunit "Subc. CreateProdOrdWizLibrary";
- LibraryMfgManagement: Codeunit "Subc. Library Mfg. Management";
- SubcontractingMgmtLibrary: Codeunit "Subc. Management Library";
- ProdOrderCheckLib: Codeunit "Subc. ProdOrderCheckLib";
- SubSetupLibrary: Codeunit "Subc. Setup Library";
- IsInitialized: Boolean;
- WizardFinishedSuccessfully: Boolean;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizard')]
- procedure TestOpenAndFinishingWizard()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO] Test Open wizard functionality
- // [GIVEN] proper setup configuration
- Initialize();
-
- // Create item without BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Create purchase line with subcontracting vendor
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Verify wizard completed successfully
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizard')]
- procedure TestCreateProdOrderWizardNothingPresentScenario()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO] Test Production Order Creation Wizard for NothingPresent scenario
- // [GIVEN] Item without BOM and Routing, proper setup configuration
- Initialize();
-
- // Create item without BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Create purchase line with subcontracting vendor
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Verify wizard completed successfully
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- ProdOrderCheckLib.SetRefreshedProdOrder(false);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromSetup(TempProdOrderComponent, PurchLine);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromSetup(TempProdOrderRoutingLine, '10');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizard')]
- procedure TestCreateProdOrderWizardBothPresentScenario()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO] Test Production Order Creation Wizard for BothPresent scenario
- // [GIVEN] Item with both BOM (2 lines) and Routing (2 lines), proper setup configuration
- Initialize();
-
- // Create BOM with 2 lines
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
-
- // Create Routing with 2 lines
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
-
- // Create item with BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Create purchase line with subcontracting vendor
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Verify wizard completed successfully
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Create expected temporary records based on BOM and Routing
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo, PurchLine);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo);
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizard')]
- procedure TestCreateProdOrderWizardRoutingPresentBOMFromSetupScenario()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO] Test Production Order Creation Wizard for RoutingPresent scenario
- // [GIVEN] Item with Routing (2 lines) but no BOM, BOM components from setup configuration
- Initialize();
-
- // Create Routing with 2 lines
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
-
- // Create item with Routing but no BOM
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting('', RoutingNo);
-
- // Create purchase line with subcontracting vendor
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Verify wizard completed successfully
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Create expected temporary records: BOM from setup, Routing from item
- ProdOrderCheckLib.SetRefreshedProdOrder(false);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromSetup(TempProdOrderComponent, PurchLine);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo);
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizard')]
- procedure TestCreateProdOrderWizardBOMPresentRoutingFromSetupScenario()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- begin
- // [SCENARIO] Test Production Order Creation Wizard for BOMPresent scenario
- // [GIVEN] Item with BOM (2 lines) but no Routing, Routing from setup configuration
- Initialize();
-
- // Create BOM with 2 lines
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
-
- // Create item with BOM but no Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, '');
-
- // Create purchase line with subcontracting vendor
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Verify wizard completed successfully
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Create expected temporary records: BOM from item, Routing from setup
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo, PurchLine);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromSetup(TempProdOrderRoutingLine, '10');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizard')]
- procedure TestWizardPreservesDescription2ThroughBOMAndRoutingLines()
- var
- ProdOrder: Record "Production Order";
- ProdOrderComponent: Record "Prod. Order Component";
- ProdOrderRoutingLine: Record "Prod. Order Routing Line";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- SubcWorkCenterNo: Code[20];
- BOMLineDescription2: Text[50];
- RoutingLineDescription2: Text[50];
- begin
- // [SCENARIO] Description 2 from BOM line and Routing line is preserved end-to-end through
- // the Production Order Creation Wizard to Prod. Order Components and Routing Lines
- // [FEATURE] Bug 620556 - Subcontracting Description 2 alignment
-
- // [GIVEN] Proper setup configuration
- Initialize();
-
- // [GIVEN] A BOM with a line that has Description 2 set
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithDescription2(BOMLineDescription2);
-
- // [GIVEN] A Routing with a subcontracting work center line that has Description 2 set
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithSubcWorkCenterAndDescription2(SubcWorkCenterNo, RoutingLineDescription2);
-
- // [GIVEN] An item with the BOM and Routing above
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // [GIVEN] A purchase line with a subcontracting vendor
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard completed successfully
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // [THEN] Production Order was created
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order No. should be set on Purchase Line');
- ProdOrder.Get("Production Order Status"::Released, PurchLine."Prod. Order No.");
-
- // [THEN] Description 2 from the BOM line is preserved on the Prod. Order Component
- ProdOrderComponent.SetRange(Status, ProdOrder.Status);
- ProdOrderComponent.SetRange("Prod. Order No.", ProdOrder."No.");
- Assert.IsTrue(ProdOrderComponent.FindFirst(), 'Prod. Order Component must exist');
- Assert.AreEqual(
- BOMLineDescription2, ProdOrderComponent."Description 2",
- 'Description 2 from the Production BOM Line must be preserved on the Prod. Order Component');
-
- // [THEN] Description 2 from the Routing line is preserved on the Prod. Order Routing Line
- ProdOrderRoutingLine.SetRange(Status, ProdOrder.Status);
- ProdOrderRoutingLine.SetRange("Prod. Order No.", ProdOrder."No.");
- ProdOrderRoutingLine.SetRange("Work Center No.", SubcWorkCenterNo);
- Assert.IsTrue(ProdOrderRoutingLine.FindFirst(), 'Prod. Order Routing Line must exist for subcontracting work center');
- Assert.AreEqual(
- RoutingLineDescription2, ProdOrderRoutingLine."Description 2",
- 'Description 2 from the Routing Line must be preserved on the Prod. Order Routing Line');
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizard(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO] Handle the Production Order Creation Wizard for all scenarios
- // The wizard should navigate through all steps and finish successfully
-
- // Simply navigate through the wizard by clicking Next until Finish is available
- // This handler works for both NothingPresent and BothPresent scenarios
-
- // Click Next to proceed through the wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- // Click Finish to complete the wizard
- if PurchProvisionWizard.ActionFinish.Enabled() then begin
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
- end;
-
- local procedure Initialize()
- begin
- LibraryTestInitialize.OnTestInitialize(Codeunit::"Subc. Wiz. General Test");
- LibrarySetupStorage.Restore();
-
- if IsInitialized then
- exit;
- LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. Wiz. General Test");
-
- SubcontractingMgmtLibrary.Initialize();
- LibraryMfgManagement.Initialize();
- SubSetupLibrary.InitSetupFields();
- LibraryERMCountryData.CreateVATData();
- SubSetupLibrary.InitialSetupForGenProdPostingGroup();
-
- IsInitialized := true;
- Commit();
-
- LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Subc. Wiz. General Test");
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizPutAwayTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizPutAwayTest.Codeunit.al
deleted file mode 100644
index 44ceae377d..0000000000
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizPutAwayTest.Codeunit.al
+++ /dev/null
@@ -1,349 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting.Test;
-
-using Microsoft.Inventory.Location;
-using Microsoft.Manufacturing.Capacity;
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.Setup;
-using Microsoft.Manufacturing.Subcontracting;
-using Microsoft.Manufacturing.WorkCenter;
-using Microsoft.Purchases.Document;
-
-codeunit 139999 "Subc. Wiz. Put-Away Test"
-{
- Subtype = Test;
- TestPermissions = Disabled;
- TestType = IntegrationTest;
-
- trigger OnRun()
- begin
- // [FEATURE] Subcontracting Management - Production Order Creation Wizard Put-Away Tests
- IsInitialized := false;
- end;
-
- var
- Assert: Codeunit Assert;
- LibraryERMCountryData: Codeunit "Library - ERM Country Data";
- LibrarySetupStorage: Codeunit "Library - Setup Storage";
- LibraryTestInitialize: Codeunit "Library - Test Initialize";
- LibraryWarehouse: Codeunit "Library - Warehouse";
- SubCreateProdOrdWizLibrary: Codeunit "Subc. CreateProdOrdWizLibrary";
- LibraryMfgManagement: Codeunit "Subc. Library Mfg. Management";
- SubcontractingMgmtLibrary: Codeunit "Subc. Management Library";
- ProdOrderCheckLib: Codeunit "Subc. ProdOrderCheckLib";
- SubSetupLibrary: Codeunit "Subc. Setup Library";
- IsInitialized: Boolean;
-
- // ==================== SCENARIO L: Put-Away Operations ====================
-
- [Test]
- procedure TestL1_LocationWithWarehouseHandling_PutAwaySetup_TwoOperations()
- var
- ProdOrderRtngLine: Record "Prod. Order Routing Line";
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- SubManagementSetup: Record "Subc. Management Setup";
- WorkCenter: Record "Work Center";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- LocationCode: Code[10];
- ItemNo: Code[20];
- PutAwayWorkCenterNo: Code[20];
- OperationCount: Integer;
- begin
- // [SCENARIO L1] Location with warehouse handling + Put-Away setup = 2 operations
- // [GIVEN] Location requires warehouse handling and put-away work center is configured
- Initialize();
-
- // Create location with warehouse handling
- LocationCode := CreateLocationWithWarehouseHandling();
-
- // Create put-away work center
- LibraryMfgManagement.CreateWorkCenterWithCalendar(WorkCenter, 1);
- PutAwayWorkCenterNo := WorkCenter."No.";
-
- // Configure Sub Management Setup with put-away work center
- SubManagementSetup.Get();
- SubManagementSetup."Put-Away Work Center No." := PutAwayWorkCenterNo;
- SubManagementSetup.Modify();
-
- // Configure setup to hide both (automatic creation)
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
-
- // Create item without BOM/Routing (nothing present scenario)
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Create purchase line with the warehouse location
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
- PurchLine.Validate("Location Code", LocationCode);
- PurchLine.Modify();
-
- // [WHEN] Run the Production Order Creation process
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Production order should be created with 2 routing operations
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Count routing operations
- ProdOrderRtngLine.SetRange(Status, ProdOrder.Status);
- ProdOrderRtngLine.SetRange("Prod. Order No.", ProdOrder."No.");
- OperationCount := ProdOrderRtngLine.Count();
- Assert.AreEqual(2, OperationCount, 'Should have 2 routing operations (subcontracting + put-away)');
-
- // Verify first operation (subcontracting)
- ProdOrderRtngLine.SetRange("Operation No.", '10');
- Assert.IsTrue(ProdOrderRtngLine.FindFirst(), 'Should have operation 10 for subcontracting');
- Assert.AreEqual("Capacity Type"::"Work Center", ProdOrderRtngLine.Type, 'Operation 10 should be Work Center type');
-
- // Verify second operation (put-away)
- ProdOrderRtngLine.SetRange("Operation No.", '20');
- Assert.IsTrue(ProdOrderRtngLine.FindFirst(), 'Should have operation 20 for put-away');
- Assert.AreEqual("Capacity Type"::"Work Center", ProdOrderRtngLine.Type, 'Operation 20 should be Work Center type');
- Assert.AreEqual(PutAwayWorkCenterNo, ProdOrderRtngLine."Work Center No.", 'Operation 20 should use put-away work center');
- end;
-
- [Test]
- procedure TestL2_LocationWithWarehouseHandling_NoPutAwaySetup_OneOperation()
- var
- ProdOrderRtngLine: Record "Prod. Order Routing Line";
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- SubManagementSetup: Record "Subc. Management Setup";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- LocationCode: Code[10];
- ItemNo: Code[20];
- OperationCount: Integer;
- begin
- // [SCENARIO L2] Location with warehouse handling + No put-away setup = 1 operation
- // [GIVEN] Location requires warehouse handling but no put-away work center is configured
- Initialize();
-
- // Create location with warehouse handling
- LocationCode := CreateLocationWithWarehouseHandling();
-
- // Configure Sub Management Setup without put-away work center
- SubManagementSetup.Get();
- SubManagementSetup."Put-Away Work Center No." := '';
- SubManagementSetup.Modify();
-
- // Configure setup to hide both (automatic creation)
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
-
- // Create item without BOM/Routing (nothing present scenario)
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Create purchase line with the warehouse location
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
- PurchLine.Validate("Location Code", LocationCode);
- PurchLine.Modify();
-
- // [WHEN] Run the Production Order Creation process
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Production order should be created with 1 routing operation only
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Count routing operations
- ProdOrderRtngLine.SetRange(Status, ProdOrder.Status);
- ProdOrderRtngLine.SetRange("Prod. Order No.", ProdOrder."No.");
- OperationCount := ProdOrderRtngLine.Count();
- Assert.AreEqual(1, OperationCount, 'Should have only 1 routing operation (subcontracting only)');
-
- // Verify only the subcontracting operation exists
- ProdOrderRtngLine.SetRange("Operation No.", '10');
- Assert.IsTrue(ProdOrderRtngLine.FindFirst(), 'Should have operation 10 for subcontracting');
- Assert.AreEqual("Capacity Type"::"Work Center", ProdOrderRtngLine.Type, 'Operation 10 should be Work Center type');
-
- // Verify no put-away operation exists
- ProdOrderRtngLine.SetRange("Operation No.", '20');
- Assert.IsTrue(ProdOrderRtngLine.IsEmpty(), 'Should not have operation 20 for put-away');
- end;
-
- [Test]
- procedure TestL3_LocationWithoutWarehouseHandling_OneOperation()
- var
- ProdOrderRtngLine: Record "Prod. Order Routing Line";
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- SubManagementSetup: Record "Subc. Management Setup";
- WorkCenter: Record "Work Center";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- LocationCode: Code[10];
- ItemNo: Code[20];
- PutAwayWorkCenterNo: Code[20];
- OperationCount: Integer;
- begin
- // [SCENARIO L3] Location without warehouse handling = 1 operation
- // [GIVEN] Location does not require warehouse handling (even with put-away setup)
- Initialize();
-
- // Create location without warehouse handling
- LocationCode := CreateLocationWithoutWarehouseHandling();
-
- // Create put-away work center (should be ignored)
- LibraryMfgManagement.CreateWorkCenterWithCalendar(WorkCenter, 1);
- PutAwayWorkCenterNo := WorkCenter."No.";
-
- // Configure Sub Management Setup with put-away work center
- SubManagementSetup.Get();
- SubManagementSetup."Put-Away Work Center No." := PutAwayWorkCenterNo;
- SubManagementSetup.Modify();
-
- // Configure setup to hide both (automatic creation)
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
-
- // Create item without BOM/Routing (nothing present scenario)
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Create purchase line with the non-warehouse location
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
- PurchLine.Validate("Location Code", LocationCode);
- PurchLine.Modify();
-
- // [WHEN] Run the Production Order Creation process
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Production order should be created with 1 routing operation only
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Count routing operations
- ProdOrderRtngLine.SetRange(Status, ProdOrder.Status);
- ProdOrderRtngLine.SetRange("Prod. Order No.", ProdOrder."No.");
- OperationCount := ProdOrderRtngLine.Count();
- Assert.AreEqual(1, OperationCount, 'Should have only 1 routing operation (subcontracting only)');
-
- // Verify only the subcontracting operation exists
- ProdOrderRtngLine.SetRange("Operation No.", '10');
- Assert.IsTrue(ProdOrderRtngLine.FindFirst(), 'Should have operation 10 for subcontracting');
- Assert.AreEqual("Capacity Type"::"Work Center", ProdOrderRtngLine.Type, 'Operation 10 should be Work Center type');
-
- // Verify no put-away operation exists
- ProdOrderRtngLine.SetRange("Operation No.", '20');
- Assert.IsTrue(ProdOrderRtngLine.IsEmpty(), 'Should not have operation 20 for put-away');
- end;
-
- [Test]
- procedure TestL5_PutAwayWorkCenterValidation()
- var
- ProdOrderRtngLine: Record "Prod. Order Routing Line";
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- SubManagementSetup: Record "Subc. Management Setup";
- WorkCenter: Record "Work Center";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- LocationCode: Code[10];
- ItemNo: Code[20];
- PutAwayWorkCenterNo: Code[20];
- begin
- // [SCENARIO L5] Put-away operation uses correct work center from setup
- // [GIVEN] Location requires warehouse handling and specific put-away work center is configured
- Initialize();
-
- // Create location with warehouse handling
- LocationCode := CreateLocationWithWarehouseHandling();
-
- // Create specific put-away work center with identifiable properties
- LibraryMfgManagement.CreateWorkCenterWithCalendar(WorkCenter, 1);
- PutAwayWorkCenterNo := WorkCenter."No.";
- WorkCenter.Name := 'PUT-AWAY TSubT CENTER';
- WorkCenter.Modify();
-
- // Configure Sub Management Setup with put-away work center
- SubManagementSetup.Get();
- SubManagementSetup."Put-Away Work Center No." := PutAwayWorkCenterNo;
- SubManagementSetup.Modify();
-
- // Configure setup to hide both (automatic creation)
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Hide, "Subc. Show/Edit Type"::Hide);
-
- // Create item without BOM/Routing (nothing present scenario)
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Create purchase line with the warehouse location
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
- PurchLine.Validate("Location Code", LocationCode);
- PurchLine.Modify();
-
- // [WHEN] Run the Production Order Creation process
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Put-away operation should use the configured work center
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Find put-away operation
- ProdOrderRtngLine.SetRange(Status, ProdOrder.Status);
- ProdOrderRtngLine.SetRange("Prod. Order No.", ProdOrder."No.");
- ProdOrderRtngLine.SetRange("Operation No.", '20');
- Assert.IsTrue(ProdOrderRtngLine.FindFirst(), 'Should have operation 20 for put-away');
-
- // Verify work center assignment
- Assert.AreEqual(PutAwayWorkCenterNo, ProdOrderRtngLine."Work Center No.", 'Put-away operation should use configured work center');
- Assert.AreEqual(PutAwayWorkCenterNo, ProdOrderRtngLine."No.", 'Put-away operation No. should match work center');
-
- // Verify operation description
- Assert.IsTrue(StrPos(ProdOrderRtngLine.Description, 'Put-Away') > 0, 'Put-away operation should have descriptive name');
- end;
-
- // ==================== HELPER METHODS ====================
-
- local procedure CreateLocationWithWarehouseHandling(): Code[10]
- var
- Location: Record Location;
- LocationCode: Code[10];
- begin
- LocationCode := LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
- Location.Get(LocationCode);
- Location.Validate("Prod. Output Whse. Handling", "Prod. Output Whse. Handling"::"Inventory Put-away");
- Location.Modify(true);
- exit(LocationCode);
- end;
-
- local procedure CreateLocationWithoutWarehouseHandling(): Code[10]
- var
- Location: Record Location;
- LocationCode: Code[10];
- begin
- LocationCode := LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
- Location.Get(LocationCode);
- Location.Validate("Prod. Output Whse. Handling", "Prod. Output Whse. Handling"::"No Warehouse Handling");
- Location.Modify(true);
- exit(LocationCode);
- end;
-
- local procedure Initialize()
- begin
- LibraryTestInitialize.OnTestInitialize(Codeunit::"Subc. Wiz. Put-Away Test");
- LibrarySetupStorage.Restore();
-
- if IsInitialized then
- exit;
- LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. Wiz. Put-Away Test");
-
- SubcontractingMgmtLibrary.Initialize();
- LibraryMfgManagement.Initialize();
- SubSetupLibrary.InitSetupFields();
- LibraryERMCountryData.CreateVATData();
- SubSetupLibrary.InitialSetupForGenProdPostingGroup();
-
- IsInitialized := true;
- Commit();
-
- LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Subc. Wiz. Put-Away Test");
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizSaveTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizSaveTest.Codeunit.al
deleted file mode 100644
index 77fc82060f..0000000000
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizSaveTest.Codeunit.al
+++ /dev/null
@@ -1,641 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting.Test;
-
-using Microsoft.Inventory.Item;
-using Microsoft.Inventory.Location;
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.ProductionBOM;
-using Microsoft.Manufacturing.Routing;
-using Microsoft.Manufacturing.Subcontracting;
-using Microsoft.Purchases.Document;
-
-codeunit 139998 "Subc. Wiz. Save Test"
-{
- Subtype = Test;
- TestPermissions = Disabled;
- TestType = IntegrationTest;
-
- trigger OnRun()
- begin
- // [FEATURE] Subcontracting Management - Production Order Creation Wizard Save Tests
- IsInitialized := false;
- end;
-
- var
- Assert: Codeunit Assert;
- LibrarySetupStorage: Codeunit "Library - Setup Storage";
- LibraryTestInitialize: Codeunit "Library - Test Initialize";
- SubCreateProdOrdWizLibrary: Codeunit "Subc. CreateProdOrdWizLibrary";
- LibraryMfgManagement: Codeunit "Subc. Library Mfg. Management";
- ProdOrderCheckLib: Codeunit "Subc. ProdOrderCheckLib";
- SubcontractingMgmtLibrary: Codeunit "Subc. Management Library";
- SubSetupLibrary: Codeunit "Subc. Setup Library";
- LibraryERMCountryData: Codeunit "Library - ERM Country Data";
- IsInitialized: Boolean;
- SaveBOMRouting: Boolean;
- WizardFinishedSuccessfully: Boolean;
- WizardWasOpened: Boolean;
- SaveBomRtngToSource: Enum "Subc. RtngBOMSourceType";
- BOMShouldExistLbl: Label 'BOM %1 should exist', Locked = true;
- RoutingShouldExistLbl: Label 'Routing %1 should exist', Locked = true;
-
- // ==================== SCENARIO H: BOM/Routing Save Tests ====================
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardNoSave')]
- procedure TestH1_NoSaveFlag_BOMNotSaved()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO H1] SaveBOMRouting = false - BOM should not be saved to source
- // [GIVEN] Item without BOM/Routing, wizard creates new BOM
- Initialize();
-
- // Create item without BOM/Routing (nothing present scenario)
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Configure setup to edit both for nothing present scenario
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
- SetAlwaysSaveModifiedVersions(false);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set save flags for handler
- SaveBOMRouting := false;
- Clear(SaveBomRtngToSource);
-
- // [WHEN] Run the Production Order Creation Wizard without saving
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully but BOM should not be saved to item
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- // Verify item still has no BOM/Routing assigned
- VerifyItemHasNoBOMRouting(ItemNo);
-
- // Verify temporary BOM was cleaned up (should not exist in master data)
- VerifyTemporaryBOMWasCleanedUp();
-
- // Create expected temporary components from the selected BOM
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromSetup(TempProdOrderComponent, PurchLine);
- // Create expected temporary routing lines from the selected Routing
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromSetup(TempProdOrderRoutingLine, '10');
-
- // Verify that both components and routing lines match the selected BOM and Routing
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardSaveToItem')]
- procedure TestH2_SaveToItem_BOMSavedToItem()
- var
- Item: Record Item;
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO H2] SaveBomRtngToSource = Item - BOM should be saved to item
- // [GIVEN] Item without BOM/Routing, wizard creates new BOM
- Initialize();
-
- // Create item without BOM/Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Configure setup to edit both for nothing present scenario
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
- SetAlwaysSaveModifiedVersions(false);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set save flags for handler
- SaveBOMRouting := true;
- SaveBomRtngToSource := SaveBomRtngToSource::Item;
-
- // [WHEN] Run the Production Order Creation Wizard with save to item
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and BOM should be saved to item
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- // Verify item now has BOM/Routing assigned
- Item.Get(ItemNo);
- Assert.AreNotEqual('', Item."Production BOM No.", 'Item should have BOM assigned');
- Assert.AreNotEqual('', Item."Routing No.", 'Item should have Routing assigned');
-
- // Verify BOM and Routing exist in master data
- VerifyBOMExists(Item."Production BOM No.");
- VerifyRoutingExists(Item."Routing No.");
-
- // Create expected temporary components from the selected BOM
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, Item."Production BOM No.", PurchLine);
- // Create expected temporary routing lines from the selected Routing
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, Item."Routing No.");
-
- // Verify that both components and routing lines match the selected BOM and Routing
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardSaveToStockkeepingUnit')]
- procedure TestH3_SaveToStockkeepingUnit_BOMSavedToSKU()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- StockkeepingUnit: Record "Stockkeeping Unit";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- LocationCode: Code[10];
- ItemNo: Code[20];
- begin
- // [SCENARIO H3] SaveBomRtngToSource = StockkeepingUnit - BOM should be saved to SKU
- // [GIVEN] Item without BOM/Routing, wizard creates new BOM
- Initialize();
-
- // Create item without BOM/Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Configure setup to edit both for nothing present scenario
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
- SetAlwaysSaveModifiedVersions(false);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
- LocationCode := PurchLine."Location Code";
-
- // Set save flags for handler
- SaveBOMRouting := true;
- SaveBomRtngToSource := SaveBomRtngToSource::StockkeepingUnit;
-
- // [WHEN] Run the Production Order Creation Wizard with save to stockkeeping unit
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and BOM should be saved to SKU
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- // Verify item still has no BOM/Routing assigned
- VerifyItemHasNoBOMRouting(ItemNo);
-
- // Verify stockkeeping unit was created with BOM/Routing
- Assert.IsTrue(StockkeepingUnit.Get(LocationCode, ItemNo, ''), 'Stockkeeping Unit should have been created');
- Assert.AreNotEqual('', StockkeepingUnit."Production BOM No.", 'SKU should have BOM assigned');
- Assert.AreNotEqual('', StockkeepingUnit."Routing No.", 'SKU should have Routing assigned');
-
- // Verify BOM and Routing exist in master data
- VerifyBOMExists(StockkeepingUnit."Production BOM No.");
- VerifyRoutingExists(StockkeepingUnit."Routing No.");
-
- // Create expected temporary components from the selected BOM
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, StockkeepingUnit."Production BOM No.", PurchLine);
- // Create expected temporary routing lines from the selected Routing
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, StockkeepingUnit."Routing No.");
-
- // Verify that both components and routing lines match the selected BOM and Routing
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardCreateNewVersion')]
- procedure TestH4_AlwaysSaveModifiedVersionsTrue_VersionSaved()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProductionBOMVersion: Record "Production BOM Version";
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- RoutingVersion: Record "Routing Version";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO H4] Always Save Modified Versions = true - Version should be saved even without SaveBomRtngToSource
- // [GIVEN] Item with BOM/Routing, wizard creates new version
- Initialize();
-
- // Create item with BOM/Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit both and always save modified versions
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
- SetAlwaysSaveModifiedVersions(true);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set save flags for handler (no save to source, but create new version)
- SaveBOMRouting := false;
- Clear(SaveBomRtngToSource);
-
- // [WHEN] Run the Production Order Creation Wizard with new version creation
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and version should be saved
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- // Verify new versions were created and saved
- ProductionBOMVersion.SetRange("Production BOM No.", BOMNo);
- ProductionBOMVersion.SetFilter("Version Code", '<>%1', '');
- Assert.IsFalse(ProductionBOMVersion.IsEmpty(), 'BOM Version should have been created');
-
- RoutingVersion.SetRange("Routing No.", RoutingNo);
- RoutingVersion.SetFilter("Version Code", '<>%1', '');
- Assert.IsFalse(RoutingVersion.IsEmpty(), 'Routing Version should have been created');
-
- // Create expected temporary components from the selected BOM
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProductionBOMVersion.FindFirst();
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOMVersion(TempProdOrderComponent, ProductionBOMVersion."Production BOM No.", ProductionBOMVersion."Version Code", PurchLine);
- // Create expected temporary routing lines from the selected Routing
- RoutingVersion.FindFirst();
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRoutingVersion(TempProdOrderRoutingLine, RoutingVersion."Routing No.", RoutingVersion."Version Code");
-
- // Verify that both components and routing lines match the selected BOM and Routing
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardCreateNewVersionNoSave')]
- procedure TestH5_AlwaysSaveModifiedVersionsFalse_VersionNotSaved()
- var
- ProductionBOMVersion: Record "Production BOM Version";
- PurchLine: Record "Purchase Line";
- RoutingVersion: Record "Routing Version";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO H5] Always Save Modified Versions = false and no SaveBomRtngToSource - Version should not be saved
- // [GIVEN] Item with BOM/Routing, wizard creates new version
- Initialize();
-
- // Create item with BOM/Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit both but don't always save modified versions
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
- SetAlwaysSaveModifiedVersions(false);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set save flags for handler (no save to source, create new version)
- SaveBOMRouting := false;
- Clear(SaveBomRtngToSource);
-
- // [WHEN] Run the Production Order Creation Wizard with new version creation but no save
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully but version should not be saved
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- // Verify no new versions were saved (temporary versions should be cleaned up)
- ProductionBOMVersion.SetRange("Production BOM No.", BOMNo);
- ProductionBOMVersion.SetFilter("Version Code", '<>%1', '');
- Assert.IsTrue(ProductionBOMVersion.IsEmpty(), 'BOM Version should not have been saved');
-
- RoutingVersion.SetRange("Routing No.", RoutingNo);
- RoutingVersion.SetFilter("Version Code", '<>%1', '');
- Assert.IsTrue(RoutingVersion.IsEmpty(), 'Routing Version should not have been saved');
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardCreateNewVersionSaveToItem')]
- procedure TestH6_SaveToItemWithNewVersion_VersionSaved()
- var
- ProductionBOMVersion: Record "Production BOM Version";
- PurchLine: Record "Purchase Line";
- RoutingVersion: Record "Routing Version";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO H6] SaveBomRtngToSource = Item with new version - Version should be saved
- // [GIVEN] Item with BOM/Routing, wizard creates new version
- Initialize();
-
- // Create item with BOM/Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit both but don't always save modified versions
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
- SetAlwaysSaveModifiedVersions(false);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set save flags for handler (save to item, create new version)
- SaveBOMRouting := true;
- SaveBomRtngToSource := SaveBomRtngToSource::Item;
-
- // [WHEN] Run the Production Order Creation Wizard with new version creation and save to item
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and version should be saved
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- // Verify new versions were created and saved (because SaveBomRtngToSource is set)
- ProductionBOMVersion.SetRange("Production BOM No.", BOMNo);
- ProductionBOMVersion.SetFilter("Version Code", '<>%1', '');
- Assert.IsFalse(ProductionBOMVersion.IsEmpty(), 'BOM Version should have been created');
-
- RoutingVersion.SetRange("Routing No.", RoutingNo);
- RoutingVersion.SetFilter("Version Code", '<>%1', '');
- Assert.IsFalse(RoutingVersion.IsEmpty(), 'Routing Version should have been created');
- end;
-
- // ==================== MODAL PAGE HANDLERS ====================
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardNoSave(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // Handle wizard without saving BOM/Routing
- WizardWasOpened := true;
-
- // Set save options
- PurchProvisionWizard.SaveBOMRouting.SetValue(SaveBOMRouting);
-
- // Navigate through all wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardSaveToItem(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // Handle wizard with save to item
- WizardWasOpened := true;
-
- // Set save options
- PurchProvisionWizard.SaveBOMRouting.SetValue(SaveBOMRouting);
- if SaveBOMRouting then
- PurchProvisionWizard.SaveBomRtngToSource.SetValue(SaveBomRtngToSource);
-
- // Navigate through all wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardSaveToStockkeepingUnit(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // Handle wizard with save to stockkeeping unit
- WizardWasOpened := true;
-
- // Set save options
- PurchProvisionWizard.SaveBOMRouting.SetValue(SaveBOMRouting);
- if SaveBOMRouting then
- PurchProvisionWizard.SaveBomRtngToSource.SetValue(SaveBomRtngToSource);
-
- // Navigate through all wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardCreateNewVersion(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // Handle wizard with new version creation
- WizardWasOpened := true;
-
- // Set save options
- PurchProvisionWizard.SaveBOMRouting.SetValue(SaveBOMRouting);
- if SaveBOMRouting then
- PurchProvisionWizard.SaveBomRtngToSource.SetValue(SaveBomRtngToSource);
-
- // Navigate to BOM step and create new version
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.CreateBOMVersion.SetValue(true);
-
- // Navigate to Routing step and create new version
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.CreateRoutingVersion.SetValue(true);
-
- // Navigate through remaining wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardCreateNewVersionNoSave(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // Handle wizard with new version creation but no save
- WizardWasOpened := true;
-
- // Set save options (no save)
- PurchProvisionWizard.SaveBOMRouting.SetValue(SaveBOMRouting);
-
- // Navigate to BOM step and create new version
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.CreateBOMVersion.SetValue(true);
-
- // Navigate to Routing step and create new version
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.CreateRoutingVersion.SetValue(true);
-
- // Navigate through remaining wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardCreateNewVersionSaveToItem(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // Handle wizard with new version creation and save to item
- WizardWasOpened := true;
-
- // Set save options
- PurchProvisionWizard.SaveBOMRouting.SetValue(SaveBOMRouting);
- if SaveBOMRouting then
- PurchProvisionWizard.SaveBomRtngToSource.SetValue(SaveBomRtngToSource);
-
- // Navigate to BOM step and create new version
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.CreateBOMVersion.SetValue(true);
-
- // Navigate to Routing step and create new version
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.CreateRoutingVersion.SetValue(true);
-
- // Navigate through remaining wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- // ==================== HELPER METHODS ====================
-
- local procedure VerifyItemHasNoBOMRouting(ItemNo: Code[20])
- var
- Item: Record Item;
- begin
- Item.Get(ItemNo);
- Assert.AreEqual('', Item."Production BOM No.", 'Item should not have BOM assigned');
- Assert.AreEqual('', Item."Routing No.", 'Item should not have Routing assigned');
- end;
-
- local procedure VerifyBOMExists(BOMNo: Code[20])
- var
- ProductionBOMHeader: Record "Production BOM Header";
- begin
- Assert.IsTrue(ProductionBOMHeader.Get(BOMNo), StrSubstNo(BOMShouldExistLbl, BOMNo));
- end;
-
- local procedure VerifyRoutingExists(RoutingNo: Code[20])
- var
- RoutingHeader: Record "Routing Header";
- begin
- Assert.IsTrue(RoutingHeader.Get(RoutingNo), StrSubstNo(RoutingShouldExistLbl, RoutingNo));
- end;
-
- local procedure VerifyTemporaryBOMWasCleanedUp()
- var
- ProductionBOMHeader: Record "Production BOM Header";
- begin
- // Verify no temporary BOMs remain (BOMs created during wizard should be cleaned up if not saved)
- ProductionBOMHeader.SetFilter("No.", 'TEMP*');
- Assert.IsTrue(ProductionBOMHeader.IsEmpty(), 'Temporary BOMs should have been cleaned up');
- end;
-
- local procedure SetAlwaysSaveModifiedVersions(AlwaysSave: Boolean)
- var
- SubManagementSetup: Record "Subc. Management Setup";
- begin
- if not SubManagementSetup.Get() then begin
- SubManagementSetup.Init();
- SubManagementSetup.Insert();
- end;
- SubManagementSetup."Always Save Modified Versions" := AlwaysSave;
- SubManagementSetup.Modify();
- end;
-
- local procedure Initialize()
- begin
- LibraryTestInitialize.OnTestInitialize(Codeunit::"Subc. Wiz. Save Test");
- LibrarySetupStorage.Restore();
-
- if IsInitialized then
- exit;
- LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. Wiz. Save Test");
-
- SubcontractingMgmtLibrary.Initialize();
- LibraryMfgManagement.Initialize();
- SubSetupLibrary.InitSetupFields();
- LibraryERMCountryData.CreateVATData();
- SubSetupLibrary.InitialSetupForGenProdPostingGroup();
-
- IsInitialized := true;
- Commit();
-
- LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Subc. Wiz. Save Test");
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizSourceTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizSourceTest.Codeunit.al
deleted file mode 100644
index 5dd8af98e9..0000000000
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizSourceTest.Codeunit.al
+++ /dev/null
@@ -1,367 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting.Test;
-
-using Microsoft.Inventory.Location;
-using Microsoft.Manufacturing.Subcontracting;
-using Microsoft.Purchases.Document;
-
-codeunit 139997 "Subc. Wiz. Source Test"
-{
- Subtype = Test;
- TestPermissions = Disabled;
- TestType = IntegrationTest;
-
- trigger OnRun()
- begin
- // [FEATURE] Subcontracting Management - Production Order Creation Wizard BOM/Routing Source Tests
- IsInitialized := false;
- end;
-
- var
- Assert: Codeunit Assert;
- LibrarySetupStorage: Codeunit "Library - Setup Storage";
- LibraryTestInitialize: Codeunit "Library - Test Initialize";
- SubCreateProdOrdWizLibrary: Codeunit "Subc. CreateProdOrdWizLibrary";
- LibraryMfgManagement: Codeunit "Subc. Library Mfg. Management";
- SubcontractingMgmtLibrary: Codeunit "Subc. Management Library";
- SubSetupLibrary: Codeunit "Subc. Setup Library";
- LibraryERMCountryData: Codeunit "Library - ERM Country Data";
- IsInitialized: Boolean;
- WizardFinishedSuccessfully: Boolean;
- WizardWasOpened: Boolean;
- ExpectedSourceType: Enum "Subc. RtngBOMSourceType";
- SubManSetupLbl: Label 'Subcontracting Management Setup', Locked = true;
-
- // ==================== SCENARIO G: Source Data Validation ====================
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardVerifyStockkeepingSource')]
- procedure TestG1_StockkeepingHasData_StockkeepingHasPriority()
- var
- PurchLine: Record "Purchase Line";
- StockkeepingUnit: Record "Stockkeeping Unit";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- LocationCode: Code[10];
- BOMNo: Code[20];
- ItemBOMNo: Code[20];
- ItemNo: Code[20];
- ItemRoutingNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO G1] Stockkeeping has data → Stockkeeping has priority
- // [GIVEN] Item with BOM and Routing, Stockkeeping Unit with different BOM and Routing
- Initialize();
-
- // Create BOMs and Routings for both Item and Stockkeeping Unit
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemBOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- ItemRoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
-
- // Create item with BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(ItemBOMNo, ItemRoutingNo);
-
- // Create location and stockkeeping unit with different BOM and Routing
- LocationCode := SubCreateProdOrdWizLibrary.CreateLocationCode();
- SubCreateProdOrdWizLibrary.CreateStockkeepingUnit(StockkeepingUnit, ItemNo, LocationCode);
- StockkeepingUnit."Production BOM No." := BOMNo;
- StockkeepingUnit."Routing No." := RoutingNo;
- StockkeepingUnit.Modify();
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line with location (to trigger stockkeeping unit usage)
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
- PurchLine.Validate("Location Code", LocationCode);
- PurchLine.Modify();
-
- // Set expected source type for handler verification
- ExpectedSourceType := ExpectedSourceType::StockkeepingUnit;
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should show Stockkeeping Unit as source
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully with Stockkeeping Unit as source');
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardVerifyItemSource')]
- procedure TestG2_ItemHasData_StockkeepingEmpty_ItemUsed()
- var
- PurchLine: Record "Purchase Line";
- StockkeepingUnit: Record "Stockkeeping Unit";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- LocationCode: Code[10];
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO G2] Item has data → Stockkeeping empty → Item used
- // [GIVEN] Item with BOM and Routing, Stockkeeping Unit without BOM and Routing
- Initialize();
-
- // Create BOM and Routing for Item
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Create location and stockkeeping unit without BOM and Routing
- LocationCode := SubCreateProdOrdWizLibrary.CreateLocationCode();
- SubCreateProdOrdWizLibrary.CreateStockkeepingUnit(StockkeepingUnit, ItemNo, LocationCode);
- // Stockkeeping Unit has empty BOM and Routing (default)
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line with location
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
- PurchLine.Validate("Location Code", LocationCode);
- PurchLine.Modify();
-
- // Set expected source type for handler verification
- ExpectedSourceType := ExpectedSourceType::Item;
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should show Item as source
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully with Item as source');
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardVerifySetupSource')]
- procedure TestG3_NothingFilled_NoData_SetupApplies()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO G3] Nothing filled → no data → Setup applies
- // [GIVEN] Item without BOM and Routing, no stockkeeping unit
- Initialize();
-
- // Create item without BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line without location
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected source type for handler verification (should be Empty when using setup)
- ExpectedSourceType := ExpectedSourceType::Empty;
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should show Empty as source (setup is used)
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully with Empty source (setup used)');
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardVerifyEmptySource')]
- procedure TestG4_NothingFilled_NoSetup_FieldsEmpty()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO G4] Nothing filled → no setup → Fields empty
- // [GIVEN] Item without BOM and Routing, no stockkeeping unit, minimal setup
- Initialize();
-
- // Create item without BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line without location
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Set expected source type for handler verification
- ExpectedSourceType := ExpectedSourceType::Empty;
-
- // [WHEN] Run the Production Order Creation Wizard
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should show Empty as source
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully with Empty source');
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardVerifyNewSetupSource')]
- procedure TestG5_SetupChanged_NewSetup_NewSetupApplies()
- var
- PurchLine: Record "Purchase Line";
- SubManagementSetup: Record "Subc. Management Setup";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- ItemNo: Code[20];
- begin
- // [SCENARIO G5] Setup changed → new setup → new setup applies
- // [GIVEN] Item without BOM and Routing, setup is changed during test
- Initialize();
-
- // Create item without BOM and Routing
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithoutBOMAndRouting('', '');
-
- // Configure initial setup for nothing present scenario
- SubSetupLibrary.ConfigureSubManagementForNothingPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line without location
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // Change setup during test (simulate setup change by modifying a field)
- SubManagementSetup.Get();
- SubManagementSetup.ShowRtngBOMSelect_Nothing := SubManagementSetup.ShowRtngBOMSelect_Nothing::Show;
- SubManagementSetup.Modify();
-
- // Set expected source type for handler verification
- ExpectedSourceType := ExpectedSourceType::Empty;
-
- // [WHEN] Run the Production Order Creation Wizard with changed setup
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should use the new setup
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully with new setup');
- end;
-
- // ==================== MODAL PAGE HANDLERS ====================
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardVerifyStockkeepingSource(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO G3] Verify that BomRtngFromSource shows Empty when setup is used
- WizardWasOpened := true;
-
- // Verify that the source field shows StockkeepingUnit
- Assert.AreEqual(Format(ExpectedSourceType::StockkeepingUnit), PurchProvisionWizard.BomRtngFromSource.Value(),
- 'BomRtngFromSource should show StockkeepingUnit when stockkeeping unit has data');
-
- // Navigate through wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardVerifyItemSource(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO G4] Verify that BomRtngFromSource shows Empty when no setup exists
- WizardWasOpened := true;
-
- // Verify that the source field shows Item
- Assert.AreEqual(Format(ExpectedSourceType::Item), PurchProvisionWizard.BomRtngFromSource.Value(),
- 'BomRtngFromSource should show Item when item has data and stockkeeping unit is empty');
-
- // Navigate through wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardVerifySetupSource(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO G5] Verify that BomRtngFromSource reflects new setup
- WizardWasOpened := true;
-
- // Verify that the source field shows Empty (new setup is used)
- Assert.AreEqual(SubManSetupLbl, PurchProvisionWizard.BomRtngFromSource.Value(),
- 'BomRtngFromSource should reflect new setup configuration');
-
- // Navigate through wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardVerifyEmptySource(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO G4] Verify that BomRtngFromSource shows Empty when no setup exists
- WizardWasOpened := true;
-
- // Verify that the source field shows Empty
- Assert.AreEqual(SubManSetupLbl, PurchProvisionWizard.BomRtngFromSource.Value(),
- 'BomRtngFromSource should show Empty when no data and no setup exists');
-
- // Navigate through wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardVerifyNewSetupSource(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO G5] Verify that BomRtngFromSource reflects new setup
- WizardWasOpened := true;
-
- // Verify that the source field shows Empty (new setup is used)
- Assert.AreEqual(SubManSetupLbl, PurchProvisionWizard.BomRtngFromSource.Value(),
- 'BomRtngFromSource should reflect new setup configuration');
-
- // Navigate through wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- local procedure Initialize()
- begin
- LibraryTestInitialize.OnTestInitialize(Codeunit::"Subc. Wiz. Source Test");
- LibrarySetupStorage.Restore();
-
- if IsInitialized then
- exit;
- LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. Wiz. Source Test");
-
- SubcontractingMgmtLibrary.Initialize();
- LibraryMfgManagement.Initialize();
- SubSetupLibrary.InitSetupFields();
- LibraryERMCountryData.CreateVATData();
- SubSetupLibrary.InitialSetupForGenProdPostingGroup();
-
- IsInitialized := true;
- Commit();
-
- LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Subc. Wiz. Source Test");
- end;
-}
\ No newline at end of file
diff --git a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizVariantTest.Codeunit.al b/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizVariantTest.Codeunit.al
deleted file mode 100644
index 9c00494853..0000000000
--- a/src/Apps/W1/Subcontracting/Test/src/Codeunits/Tests/SubcWizVariantTest.Codeunit.al
+++ /dev/null
@@ -1,963 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-// ------------------------------------------------------------------------------------------------
-namespace Microsoft.Manufacturing.Subcontracting.Test;
-
-using Microsoft.Inventory.Item;
-using Microsoft.Inventory.Location;
-using Microsoft.Manufacturing.Document;
-using Microsoft.Manufacturing.ProductionBOM;
-using Microsoft.Manufacturing.Routing;
-using Microsoft.Manufacturing.Subcontracting;
-using Microsoft.Purchases.Document;
-
-codeunit 139996 "Subc. Wiz. Variant Test"
-{
- Subtype = Test;
- TestPermissions = Disabled;
- TestType = IntegrationTest;
-
- trigger OnRun()
- begin
- // [FEATURE] Subcontracting Management - Production Order Creation Wizard Variant Tests
- IsInitialized := false;
- end;
-
- var
- Assert: Codeunit Assert;
- LibrarySetupStorage: Codeunit "Library - Setup Storage";
- LibraryTestInitialize: Codeunit "Library - Test Initialize";
- SubCreateProdOrdWizLibrary: Codeunit "Subc. CreateProdOrdWizLibrary";
- LibraryMfgManagement: Codeunit "Subc. Library Mfg. Management";
- SubcontractingMgmtLibrary: Codeunit "Subc. Management Library";
- ProdOrderCheckLib: Codeunit "Subc. ProdOrderCheckLib";
- SubSetupLibrary: Codeunit "Subc. Setup Library";
- LibraryERMCountryData: Codeunit "Library - ERM Country Data";
- IsInitialized: Boolean;
- WizardFinishedSuccessfully: Boolean;
- WizardWasOpened: Boolean;
- NoToSelect, VersionToSelect : Code[20];
-
- // ==================== SCENARIO C: Variant Editing ====================
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardNewBOMVariant')]
- procedure TestC1_NewBOMVariant_LinesEditable()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO C1] new BOM variant - Button "New Variant" - Lines are editable
- // [GIVEN] Item with BOM and Routing, setup configured to allow editing
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard and create new BOM variant
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and new BOM variant should be creatable with editable lines
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully with new BOM variant');
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardModifyBOMLines')]
- procedure TestC2_ModifyBOMLines_ChangesAppliedToComponents()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO C2] Lines changed, deleted, added - In UI - Changes are output in component lines
- // [GIVEN] Item with BOM and Routing, setup configured to allow editing
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard and modify BOM lines
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and changes should be applied to production order components
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created with modified components
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Create expected temporary components with modified values from handler
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOM(TempProdOrderComponent, BOMNo, PurchLine);
-
- // Update the temporary record with the expected modified values from the handler
- TempProdOrderComponent.Reset();
- if TempProdOrderComponent.FindFirst() then begin
- TempProdOrderComponent."Quantity per" := 5; // Value that will be set in handler
- TempProdOrderComponent.Modify();
- end;
-
- // Verify that the modified components match the expected values
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardNewRoutingVariant')]
- procedure TestC3_NewRoutingVariant_LinesEditable()
- var
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO C3] new routing variant - Button "New Variant" - Lines are editable
- // [GIVEN] Item with BOM and Routing, setup configured to allow editing
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard and create new Routing variant
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have opened and new Routing variant should be creatable with editable lines
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully with new Routing variant');
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardModifyRoutingLines')]
- procedure TestC4_ModifyRoutingLines_ChangesAppliedToOperations()
- var
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO C4] Lines changed, deleted, added - In UI - Changes are output in production routing operations
- // [GIVEN] Item with BOM and Routing, setup configured to allow editing
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard and modify Routing lines
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and changes should be applied to production order routing lines
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created with modified routing lines
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Create expected temporary routing lines with modified values from handler
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRouting(TempProdOrderRoutingLine, RoutingNo);
-
- // Update the temporary record with the expected modified values from the handler
- TempProdOrderRoutingLine.Reset();
- if TempProdOrderRoutingLine.FindFirst() then begin
- TempProdOrderRoutingLine."Run Time" := 10; // Value set in handler
- TempProdOrderRoutingLine."Setup Time" := 20; // Value set in handler
- TempProdOrderRoutingLine.Modify();
- end;
-
- // Verify that the modified routing lines match the expected values
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- // ==================== SCENARIO H: Saving of Variants ====================
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardSaveToStockkeeping')]
- procedure TestH1_SaveWithStockkeeping_NewVariantInStockkeeping()
- var
- ProductionBOMVersion: Record "Production BOM Version";
- PurchLine: Record "Purchase Line";
- StockkeepingUnit: Record "Stockkeeping Unit";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- LocationCode: Code[10];
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO H1] Save + Stockkeeping filled - new variant in stockkeeping
- // [GIVEN] Item with BOM and Routing, Stockkeeping Unit exists, save is enabled
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Create Stockkeeping Unit (using available library methods)
- LocationCode := SubCreateProdOrdWizLibrary.CreateLocationCode();
- SubCreateProdOrdWizLibrary.CreateStockkeepingUnit(StockkeepingUnit, ItemNo, LocationCode);
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line with location
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
- PurchLine.Validate("Location Code", LocationCode);
- PurchLine.Modify();
-
- // [WHEN] Run the Production Order Creation Wizard and save new variant to stockkeeping
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and new BOM variant should be saved to stockkeeping unit
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify that a new BOM version was created and assigned to stockkeeping unit
- StockkeepingUnit.Get(LocationCode, ItemNo, '');
- Assert.AreNotEqual('', StockkeepingUnit."Production BOM No.", 'Stockkeeping Unit should have BOM assigned');
-
- // Verify new BOM version exists
- ProductionBOMVersion.SetRange("Production BOM No.", StockkeepingUnit."Production BOM No.");
- ProductionBOMVersion.SetFilter("Version Code", '<>%1', '');
- Assert.IsFalse(ProductionBOMVersion.IsEmpty(), 'New BOM version should exist');
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardSaveToItem')]
- procedure TestH2_SaveWithItem_NewVariantInItem()
- var
- Item: Record Item;
- ProductionBOMVersion: Record "Production BOM Version";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- OriginalBOMNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO H2] Save + Item filled - new variant in item
- // [GIVEN] Item with BOM and Routing, no stockkeeping unit, save is enabled
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Store original BOM No
- Item.Get(ItemNo);
- OriginalBOMNo := Item."Production BOM No.";
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard and save new variant to item
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and new BOM variant should be saved to item
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify that item has new BOM assigned (equal to original)
- Item.Get(ItemNo);
- Assert.AreEqual(OriginalBOMNo, Item."Production BOM No.", 'Item should have same BOM assigned');
-
- // Verify new BOM version exists
- ProductionBOMVersion.SetRange("Production BOM No.", Item."Production BOM No.");
- ProductionBOMVersion.SetFilter("Version Code", '<>%1', '');
- Assert.IsTrue(ProductionBOMVersion.FindFirst(), 'New BOM version should exist');
- Assert.AreEqual(ProductionBOMVersion.Status, ProductionBOMVersion.Status::Certified, 'New BOM should be certified');
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardSaveNoChanges')]
- procedure TestH3_SaveNoChanges_NoNewVariant()
- var
- Item: Record Item;
- ProductionBOMVersion: Record "Production BOM Version";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- OriginalBOMNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO H3] Save + no changes - no new variant
- // [GIVEN] Item with BOM and Routing, save is enabled but no changes made
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Store original BOM No
- Item.Get(ItemNo);
- OriginalBOMNo := Item."Production BOM No.";
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard without making changes
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully but no new variant should be created
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify that item still has original BOM (no new variant created)
- Item.Get(ItemNo);
- Assert.AreEqual(OriginalBOMNo, Item."Production BOM No.", 'Item should still have original BOM when no changes made');
-
- // Verify no new BOM version was created
- ProductionBOMVersion.SetRange("Production BOM No.", Item."Production BOM No.");
- ProductionBOMVersion.SetFilter("Version Code", '<>%1', '');
- Assert.IsTrue(ProductionBOMVersion.IsEmpty(), 'No new BOM version should exist when no changes made');
- end;
-
- // ==================== SCENARIO I: Versions ====================
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardNewBOMVersion')]
- procedure TestI1_NewBOMVersion_NewestVersionUsed()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO I1] new BOM version - newest version is used
- // [GIVEN] Item with BOM and Routing, new BOM version exists
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Create new BOM version (simulated by creating another BOM)
- SubCreateProdOrdWizLibrary.CreateBOMVersionWithTwoLines(BOMNo, 'A');
- SubCreateProdOrdWizLibrary.CreateBOMVersionWithTwoLines(BOMNo, 'B');
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard with new BOM version available
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should use the new BOM version
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Verify production order was created with new BOM version
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOMVersion(TempProdOrderComponent, BOMNo, 'B', PurchLine);
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardNewRoutingVersion')]
- procedure TestI2_NewRoutingVersion_NewestVersionUsed()
- var
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO I2] new Routing version - newest version is used
- // [GIVEN] Item with BOM and Routing, new Routing version exists
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Create new Routing version
- SubCreateProdOrdWizLibrary.CreateRoutingVersionWithTwoLines(RoutingNo, 'A');
- SubCreateProdOrdWizLibrary.CreateRoutingVersionWithTwoLines(RoutingNo, 'B');
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard with new Routing version available
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should use the new Routing version
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Verify production order was created with new Routing version
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRoutingVersion(TempProdOrderRoutingLine, RoutingNo, 'B');
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- // ==================== SCENARIO J: Variantenwahl / Wechsel ====================
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardSelectBOMVariant,SelectBOMVersion')]
- procedure TestJ1_SelectExistingBOMVariant_LinesExchanged()
- var
- TempProdOrderComponent: Record "Prod. Order Component" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO J1] use existing BOM variant - Lines are exchanged
- // [GIVEN] Item with BOM and Routing, alternate BOM version exists
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Create alternate BOM version with different lines
- SubCreateProdOrdWizLibrary.CreateBOMVersionWithTwoLines(BOMNo, 'A');
- SubCreateProdOrdWizLibrary.CreateBOMVersionWithTwoLines(BOMNo, 'B');
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard and select alternate BOM variant
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and used alternate BOM version
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created with alternate BOM version components
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Create expected temporary components from alternate BOM version
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderComponentFromBOMVersion(TempProdOrderComponent, BOMNo, 'A', PurchLine);
-
- // Verify that the components match the alternate BOM version
- ProdOrderCheckLib.VerifyProdOrderComponentsMatchTempRecords(ProdOrder, TempProdOrderComponent);
- end;
-
- [Test]
- [HandlerFunctions('HandlePurchProvisionWizardSelectRoutingVariant,SelectRoutingVersion')]
- procedure TestJ2_SelectExistingRoutingVariant_LinesExchanged()
- var
- TempProdOrderRoutingLine: Record "Prod. Order Routing Line" temporary;
- ProdOrder: Record "Production Order";
- PurchLine: Record "Purchase Line";
- CreateProdOrdOpt: Codeunit "Subc. Create Prod. Ord. Opt.";
- BOMNo: Code[20];
- ItemNo: Code[20];
- RoutingNo: Code[20];
- begin
- // [SCENARIO J2] use existing Routing variant - Routing lines are exchanged
- // [GIVEN] Item with BOM and Routing, alternate Routing version exists
- Initialize();
-
- // Create BOM and Routing
- BOMNo := SubCreateProdOrdWizLibrary.CreateBOMWithTwoLines();
- RoutingNo := SubCreateProdOrdWizLibrary.CreateRoutingWithTwoLines();
- ItemNo := SubCreateProdOrdWizLibrary.CreateItemWithBOMAndRouting(BOMNo, RoutingNo);
-
- // Create alternate Routing version with different lines
- SubCreateProdOrdWizLibrary.CreateRoutingVersionWithTwoLines(RoutingNo, 'A');
- SubCreateProdOrdWizLibrary.CreateRoutingVersionWithTwoLines(RoutingNo, 'B');
-
- // Configure setup to edit both
- SubSetupLibrary.ConfigureSubManagementForBothPresentScenario("Subc. Show/Edit Type"::Edit, "Subc. Show/Edit Type"::Edit);
-
- // Create purchase line
- SubCreateProdOrdWizLibrary.CreatePurchaseLineWithSubcontractingVendor(PurchLine, ItemNo);
-
- // [WHEN] Run the Production Order Creation Wizard and select alternate Routing variant
- WizardWasOpened := false;
- WizardFinishedSuccessfully := false;
- Commit();
- CreateProdOrdOpt.Run(PurchLine);
-
- // [THEN] Wizard should have finished successfully and used alternate Routing version
- Assert.IsTrue(WizardWasOpened, 'Wizard should have opened');
- Assert.IsTrue(WizardFinishedSuccessfully, 'Wizard should have finished successfully');
-
- // Verify production order was created with alternate Routing version lines
- PurchLine.Get(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.");
- Assert.AreNotEqual('', PurchLine."Prod. Order No.", 'Production Order should have been created');
-
- ProdOrderCheckLib.VerifyProdOrder(PurchLine, ProdOrder);
-
- // Create expected temporary routing lines from alternate Routing version
- ProdOrderCheckLib.SetRefreshedProdOrder(true);
- ProdOrderCheckLib.CreateTempProdOrderRoutingFromRoutingVersion(TempProdOrderRoutingLine, RoutingNo, 'A');
-
- // Verify that the routing lines match the alternate Routing version
- ProdOrderCheckLib.VerifyProdOrderRoutingLinesMatchTempRecords(ProdOrder, TempProdOrderRoutingLine);
- end;
-
- // ==================== MODAL PAGE HANDLERS ====================
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardNewBOMVariant(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO C1] Handle wizard to create new BOM variant
- WizardWasOpened := true;
-
- // Navigate through wizard steps until we can create a new BOM version
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- // Check if we can create a new BOM version on this step
- if PurchProvisionWizard.CreateBOMVersion.Visible() then begin
- PurchProvisionWizard.CreateBOMVersion.SetValue(true);
- // Verify that BOM lines are now editable
- Assert.IsTrue(PurchProvisionWizard.BOMLinesPart.Editable(), 'BOM lines should be editable when creating new version');
- end;
- PurchProvisionWizard.ActionNext.Invoke();
- end;
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardModifyBOMLines(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO C2] Handle wizard to modify BOM lines
- WizardWasOpened := true;
-
- // Navigate through wizard steps and modify BOM lines
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- // Check if we can create a new BOM version on this step
- if PurchProvisionWizard.CreateBOMVersion.Visible() then begin
- PurchProvisionWizard.CreateBOMVersion.SetValue(true);
- // Verify that BOM lines are now editable
- Assert.IsTrue(PurchProvisionWizard.BOMLinesPart.Editable(), 'BOM lines should be editable when creating new version');
- PurchProvisionWizard.BOMLinesPart.First();
- // Modify the quantity per of the first BOM line
- PurchProvisionWizard.BOMLinesPart."Quantity per".SetValue(5);
- end;
- PurchProvisionWizard.ActionNext.Invoke();
- end;
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardNewRoutingVariant(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO C3] Handle wizard to create new Routing variant
- WizardWasOpened := true;
-
- // Navigate through wizard steps until we can create a new Routing version
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- // Check if we can create a new Routing version on this step
- if PurchProvisionWizard.CreateRoutingVersion.Visible() then begin
- PurchProvisionWizard.CreateRoutingVersion.SetValue(true);
- // Verify that Routing lines are now editable
- Assert.IsTrue(PurchProvisionWizard.RoutingLinesPart.Editable(), 'Routing lines should be editable when creating new version');
- end;
- PurchProvisionWizard.ActionNext.Invoke();
- end;
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardModifyRoutingLines(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO C4] Handle wizard to modify Routing lines
- WizardWasOpened := true;
-
- // Navigate through wizard steps and modify Routing lines
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- // Check if we can create a new Routing version on this step
- if PurchProvisionWizard.CreateRoutingVersion.Visible() then begin
- PurchProvisionWizard.CreateRoutingVersion.SetValue(true);
- // Verify that Routing lines are now editable
- Assert.IsTrue(PurchProvisionWizard.RoutingLinesPart.Editable(), 'Routing lines should be editable when creating new version');
- PurchProvisionWizard.RoutingLinesPart.First();
- // Modify some routing lines here
- PurchProvisionWizard.RoutingLinesPart."Run Time".SetValue(10);
- PurchProvisionWizard.RoutingLinesPart."Setup Time".SetValue(20);
- end;
- PurchProvisionWizard.ActionNext.Invoke();
- end;
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- // ==================== SCENARIO H HANDLERS ====================
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardSaveToStockkeeping(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO H1] Handle wizard to save new variant to stockkeeping unit
- WizardWasOpened := true;
-
- Assert.IsFalse(PurchProvisionWizard.SaveBomRtngToSource.Editable(), 'Save to source should not be Editable initially');
- PurchProvisionWizard.SaveBOMRouting.SetValue(true);
- Assert.IsTrue(PurchProvisionWizard.SaveBomRtngToSource.Editable(), 'Save to source should be Editable after enabling save');
- PurchProvisionWizard.SaveBomRtngToSource.SetValue("Subc. RtngBOMSourceType"::StockkeepingUnit);
-
- // Navigate through wizard steps and enable saving to stockkeeping
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- // Check if we can create a new BOM version and save it
- if PurchProvisionWizard.CreateBOMVersion.Visible() then
- PurchProvisionWizard.CreateBOMVersion.SetValue(true);
- // Enable saving the variant (simulated)
- PurchProvisionWizard.ActionNext.Invoke();
- end;
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardSaveToItem(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO H2] Handle wizard to save new variant to item
- WizardWasOpened := true;
-
- Assert.IsFalse(PurchProvisionWizard.SaveBomRtngToSource.Editable(), 'Save to source should not be Editable initially');
- PurchProvisionWizard.SaveBOMRouting.SetValue(true);
- Assert.IsTrue(PurchProvisionWizard.SaveBomRtngToSource.Editable(), 'Save to source should be Editable after enabling save');
- PurchProvisionWizard.SaveBomRtngToSource.SetValue("Subc. RtngBOMSourceType"::Item);
-
- // Navigate through wizard steps and enable saving to item
- while PurchProvisionWizard.ActionNext.Enabled() do begin
- // Check if we can create a new BOM version and save it
- if PurchProvisionWizard.CreateBOMVersion.Visible() then
- PurchProvisionWizard.CreateBOMVersion.SetValue(true);
- // Enable saving the variant (simulated)
- PurchProvisionWizard.ActionNext.Invoke();
- end;
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardSaveNoChanges(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO H3] Handle wizard without making changes (no save needed)
- WizardWasOpened := true;
-
- Assert.AreEqual(Format("Subc. RtngBOMSourceType"::Empty), PurchProvisionWizard.SaveBomRtngToSource.Value(), 'Save to source should be empty initially');
-
- // Navigate through wizard steps without making changes
- while PurchProvisionWizard.ActionNext.Enabled() do
- // Don't create new versions or make changes
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- // ==================== SCENARIO I HANDLERS ====================
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardNewBOMVersion(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO I1] Handle wizard to use new BOM version
- WizardWasOpened := true;
-
- // Navigate through wizard steps and use new BOM version
- while PurchProvisionWizard.ActionNext.Enabled() do
- // The wizard should automatically select the newest version
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardNewRoutingVersion(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO I2] Handle wizard to use new Routing version
- WizardWasOpened := true;
-
- // Navigate through wizard steps and use new Routing version
- while PurchProvisionWizard.ActionNext.Enabled() do
- // The wizard should automatically select the newest version
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- // ==================== SCENARIO J HANDLERS ====================
-
- [ModalPageHandler]
- [HandlerFunctions('SelectBOMVersion')]
- procedure HandlePurchProvisionWizardSelectBOMVariant(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- BOMVersion: Record "Production BOM Version";
- NewItemNo: Text;
- OriginalItemNo: Text;
- begin
- // [SCENARIO J1] Handle wizard to select existing BOM variant and verify lines are updated
- WizardWasOpened := true;
-
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke();
-
- // Get the current BOM lines before changing version
- if PurchProvisionWizard.BOMLinesPart.First() then
- OriginalItemNo := PurchProvisionWizard.BOMLinesPart."No.".Value();
-
- // Find and select the alternate BOM version 'B'
- BOMVersion.SetRange("Production BOM No.", PurchProvisionWizard."Production BOM No.".Value());
- BOMVersion.SetRange("Version Code", 'A');
- Assert.IsTrue(BOMVersion.FindFirst(), 'BOM version A should exist for selected BOM');
-
- // Select the alternate BOM version
- NoToSelect := BOMVersion."Production BOM No.";
- VersionToSelect := BOMVersion."Version Code";
- PurchProvisionWizard.SelectedBOMVersion.AssistEdit();
-
- // Verify that the BOM lines have been updated after version change
- if PurchProvisionWizard.BOMLinesPart.First() then begin
- NewItemNo := PurchProvisionWizard.BOMLinesPart."No.".Value();
- // The lines should be different between versions (different component items)
- Assert.AreNotEqual(OriginalItemNo, NewItemNo, 'BOM lines should be updated when version is changed');
- end;
-
- // Navigate through remaining wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- [HandlerFunctions('SelectRoutingVersion')]
- procedure HandlePurchProvisionWizardSelectRoutingVariant(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- var
- RoutingVersion: Record "Routing Version";
- NewWorkCenterNo: Text;
- OriginalWorkCenterNo: Text;
- begin
- // [SCENARIO J2] Handle wizard to select existing Routing variant and verify lines are updated
- WizardWasOpened := true;
-
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke(); //Components
-
- if PurchProvisionWizard.ActionNext.Enabled() then
- PurchProvisionWizard.ActionNext.Invoke(); //Routing
-
- // Get the current Routing lines before changing version
- if PurchProvisionWizard.RoutingLinesPart.First() then
- OriginalWorkCenterNo := PurchProvisionWizard.RoutingLinesPart."No.".Value();
-
- // Find and select the alternate Routing version 'A'
- RoutingVersion.SetRange("Routing No.", PurchProvisionWizard."Routing No.".Value());
- RoutingVersion.SetRange("Version Code", 'A');
- Assert.IsTrue(RoutingVersion.FindFirst(), 'Routing version A should exist for selected Routing');
-
- // Set global variables for the SelectRoutingVersion handler
- NoToSelect := RoutingVersion."Routing No.";
- VersionToSelect := RoutingVersion."Version Code";
- PurchProvisionWizard.SelectedRoutingVersion.AssistEdit();
-
- // Verify that the Routing lines have been updated after version change
- if PurchProvisionWizard.RoutingLinesPart.First() then begin
- NewWorkCenterNo := PurchProvisionWizard.RoutingLinesPart."No.".Value();
- // The lines should be different between versions (different work centers)
- Assert.AreNotEqual(OriginalWorkCenterNo, NewWorkCenterNo, 'Routing lines should be updated when version is changed');
- end;
-
- // Navigate through remaining wizard steps
- while PurchProvisionWizard.ActionNext.Enabled() do
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardSwitchVariants(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO J3] Handle wizard to switch between variants
- WizardWasOpened := true;
-
- // Navigate through wizard steps and switch between variants
- while PurchProvisionWizard.ActionNext.Enabled() do
- // Switch between variants (simulated)
- PurchProvisionWizard.ActionNext.Invoke();
-
- PurchProvisionWizard.ActionFinish.Invoke();
- WizardFinishedSuccessfully := true;
- end;
-
- [ModalPageHandler]
- procedure HandlePurchProvisionWizardInvalidVariant(var PurchProvisionWizard: TestPage "Subc. PurchProvisionWizard")
- begin
- // [SCENARIO J4] Handle wizard to select invalid variant (should cause error)
- WizardWasOpened := true;
-
- // This handler should cause an error
- Error('Invalid variant selected');
- end;
-
- [ModalPageHandler]
- procedure SelectBOMVersion(var BOMVersionList: TestPage "Prod. BOM Version List")
- var
- BOMVersion: Record "Production BOM Version";
- begin
- BOMVersionList.First();
- BOMVersion.Get(NoToSelect, VersionToSelect);
- BOMVersionList.GoToRecord(BOMVersion);
- BOMVersionList.OK().Invoke();
- end;
-
- [ModalPageHandler]
- procedure SelectRoutingVersion(var RoutingVersionList: TestPage "Routing Version List")
- var
- RoutingVersion: Record "Routing Version";
- begin
- RoutingVersionList.First();
- RoutingVersion.Get(NoToSelect, VersionToSelect);
- RoutingVersionList.GoToRecord(RoutingVersion);
- RoutingVersionList.OK().Invoke();
- end;
-
- local procedure Initialize()
- begin
- LibraryTestInitialize.OnTestInitialize(Codeunit::"Subc. Wiz. Variant Test");
- LibrarySetupStorage.Restore();
-
- if IsInitialized then
- exit;
- LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Subc. Wiz. Variant Test");
-
- SubcontractingMgmtLibrary.Initialize();
- LibraryMfgManagement.Initialize();
- SubSetupLibrary.InitSetupFields();
- LibraryERMCountryData.CreateVATData();
- SubSetupLibrary.InitialSetupForGenProdPostingGroup();
-
- IsInitialized := true;
- Commit();
-
- LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"Subc. Wiz. Variant Test");
- end;
-}
\ No newline at end of file