Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ codeunit 99001559 "Subc. ProdO. Factbox Mgmt."
ProdOrderRoutingLine.SetRange(Status, ProdOrderRoutingLine.Status::Released);
ProdOrderRoutingLine.SetRange("Prod. Order No.", ProdOrderNo);
ProdOrderRoutingLine.SetRange("Routing Reference No.", ProdOrderLineNo);
ProdOrderRoutingLine.SetRange("Routing No.", RoutingNo);
Comment thread
ChethanT marked this conversation as resolved.
ProdOrderRoutingLine.SetRange("Operation No.", OperationNo);
exit(ProdOrderRoutingLine.Count());
end;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2245,6 +2245,54 @@ codeunit 139989 "Subc. Subcontracting Test"
'Routing Link Code duplicate confirmation must be shown exactly once, not twice');
end;

[Test]
[HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting')]
procedure CalcNoOfProductionOrderRoutingsReturnsOneForSubcontractingPurchaseLine()
var
Item: Record Item;
MachineCenter: array[2] of Record "Machine Center";
ProdOrderRoutingLine: Record "Prod. Order Routing Line";
ProductionOrder: Record "Production Order";
PurchaseLine: Record "Purchase Line";
WorkCenter: array[2] of Record "Work Center";
SubcProdOFactboxMgmt: Codeunit "Subc. ProdO. Factbox Mgmt.";
begin
// [SCENARIO 634720] CalcNoOfProductionOrderRoutings must filter by Routing No. and Operation No. so the factbox count matches the drill-down (which is always a single routing line for a subcontracting purchase line).

// [GIVEN] Manufacturing setup with a routing of multiple operations where only the second work center is subcontracting
Initialize();
Subcontracting := true;
UnitCostCalculation := UnitCostCalculation::Units;

CreateAndCalculateNeededWorkAndMachineCenter(WorkCenter, MachineCenter);
CreateItemForProductionIncludeRoutingAndProdBOM(Item, WorkCenter, MachineCenter);

// [GIVEN] A Released Production Order whose routing has more than one operation
SubcontractingMgmtLibrary.CreateAndRefreshProductionOrder(
ProductionOrder, "Production Order Status"::Released, ProductionOrder."Source Type"::Item, Item."No.", LibraryRandom.RandInt(10) + 5);

ProdOrderRoutingLine.SetRange(Status, ProdOrderRoutingLine.Status::Released);
ProdOrderRoutingLine.SetRange("Prod. Order No.", ProductionOrder."No.");
Assert.IsTrue(ProdOrderRoutingLine.Count() > 1, 'Test precondition: routing must have more than one operation to detect the bug.');
Comment thread
ChethanT marked this conversation as resolved.

UpdateSubMgmtSetupWithReqWkshTemplate();

// [GIVEN] A Subcontracting Purchase Order created from the routing line of the subcontracting work center
SubcontractingMgmtLibrary.CreateSubcontractingOrderFromProdOrderRtngPage(Item."Routing No.", WorkCenter[2]."No.");
PurchaseLine.SetRange("Document Type", PurchaseLine."Document Type"::Order);
PurchaseLine.SetRange("Prod. Order No.", ProductionOrder."No.");
#pragma warning disable AA0210
PurchaseLine.SetRange("Work Center No.", WorkCenter[2]."No.");
#pragma warning restore AA0210
PurchaseLine.FindFirst();

// [WHEN] CalcNoOfProductionOrderRoutings is called with the purchase line
// [THEN] It returns 1, matching the single routing line shown by the drill-down (not the total operations of the prod order line)
Assert.AreEqual(
1, SubcProdOFactboxMgmt.CalcNoOfProductionOrderRoutings(PurchaseLine),
'CalcNoOfProductionOrderRoutings must equal the number of routing lines opened by the drill-down (exactly one for a subcontracting purchase line).');
end;

[Test]
[HandlerFunctions('DoNotConfirmShowCreatedPurchOrderForSubcontracting,HandleTransferOrder,HandleCreateTransferOrderMsg')]
procedure PostingDirectSubcontractingTransferSetsSourceFieldsOnDirectTransHeader()
Expand Down
Loading