Skip to content
Merged
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 @@ -48,13 +48,13 @@ codeunit 99001505 "Subcontracting Management"
"Component Supply Method"::"Consignment at Vendor",
"Component Supply Method"::"Vendor-Supplied":
if (VendorSubcontrLocation <> '') and (ProdOrderComponent."Location Code" <> VendorSubcontrLocation) then
ProdOrderComponent.Validate("Location Code", VendorSubcontrLocation);
ValidateProdOrderCompLocationPreservingFlushingMethod(ProdOrderComponent, VendorSubcontrLocation);

"Component Supply Method"::"Transfer to Vendor",
"Component Supply Method"::Empty:
begin
if (ProdOrderComponent."Location Code" <> OriginalLocationCode) and (OriginalLocationCode <> '') then begin
ProdOrderComponent.Validate("Location Code", OriginalLocationCode);
ValidateProdOrderCompLocationPreservingFlushingMethod(ProdOrderComponent, OriginalLocationCode);
ProdOrderComponent."Subc. Original Location Code" := '';
end;
if (ProdOrderComponent."Bin Code" <> OriginalBinCode) and (OriginalBinCode <> '') then begin
Expand All @@ -65,6 +65,38 @@ codeunit 99001505 "Subcontracting Management"
end;
end;

internal procedure ValidateProdOrderCompLocationPreservingFlushingMethod(var ProdOrderComponent: Record "Prod. Order Component"; NewLocationCode: Code[10])
Comment thread
ChethanT marked this conversation as resolved.
var
PreservedFlushingMethod: Enum "Flushing Method";
PreservedLocationCode: Code[10];
PreservedBinCode: Code[20];
begin
// Validating "Location Code" re-reads the planning parameters from the item or SKU (Prod. Order Component.GetUpdateFromSKU),
// which silently overwrites a manually chosen "Flushing Method". Subcontracting only shuttles the component between the
// shop floor and the subcontractor location, so a manually set "Flushing Method" must survive that automatic move.
// The "Flushing Method" is restored by direct assignment on purpose: re-validating it errors once consumption has been
// posted at the subcontractor (see the return leg), which is a lifecycle subcontracting must support.
PreservedFlushingMethod := ProdOrderComponent."Flushing Method";
PreservedLocationCode := ProdOrderComponent."Location Code";
PreservedBinCode := ProdOrderComponent."Bin Code";

ProdOrderComponent.Validate("Location Code", NewLocationCode);

if ProdOrderComponent."Flushing Method" <> PreservedFlushingMethod then
ProdOrderComponent."Flushing Method" := PreservedFlushingMethod;

// Restoring the "Flushing Method" by direct assignment does not undo the "Bin Code" that the "Location Code"/temporary
// "Flushing Method" validation already derived (GetDefaultBin/GetUpdateFromSKU -> UpdateBin). Realign the default bin with
// the preserved flushing method so it never lingers on the bin picked for the item/SKU flushing method.
if ProdOrderComponent."Location Code" <> PreservedLocationCode then
// The component actually moved: recompute the default bin, now evaluated against the preserved flushing method.
ProdOrderComponent.GetDefaultBin()
else
// Same location (e.g. the direct-transfer post revalidates the current location to trigger side effects): keep the
// component on the bin it already had instead of the one derived for the temporary flushing method.
ProdOrderComponent."Bin Code" := PreservedBinCode;
end;

procedure ChangeLocationOnPlanningComponent(var PlanningComponent: Record "Planning Component"; VendorSubcontrLocation: Code[10]; OriginalLocationCode: Code[10]; OriginalBinCode: Code[20])
begin
#if not CLEAN29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ codeunit 99001524 "Subc. Prod. Order Comp. Ext."
end else
if xProdOrderComponent."Routing Link Code" <> '' then
if ProdOrderComponent."Subc. Original Location Code" <> '' then begin
ProdOrderComponent.Validate("Location Code", ProdOrderComponent."Subc. Original Location Code");
SubcontractingManagement.ValidateProdOrderCompLocationPreservingFlushingMethod(ProdOrderComponent, ProdOrderComponent."Subc. Original Location Code");
ProdOrderComponent."Subc. Original Location Code" := '';
if ProdOrderComponent."Subc. Orig. Bin Code" <> '' then begin
ProdOrderComponent.Validate("Bin Code", ProdOrderComponent."Subc. Orig. Bin Code");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ report 99001502 "Subc. Create SubCReturnOrder"
ProdOrderRoutingLine: Record "Prod. Order Routing Line";
MfgCostCalculationMgt: Codeunit "Mfg. Cost Calculation Mgt.";
SubcTransferManagement: Codeunit "Subc. Transfer Management";
SubcontractingManagement: Codeunit "Subcontracting Management";
UnitofMeasureManagement: Codeunit "Unit of Measure Management";
SubcFromLocationCode: Code[10];
AvailableToReturn: Decimal;
Expand Down Expand Up @@ -246,10 +247,8 @@ report 99001502 "Subc. Create SubCReturnOrder"

if ProdOrderComponent."Subc. Orig. Bin Code" = '' then
ProdOrderComponent."Subc. Orig. Bin Code" := ProdOrderComponent."Bin Code";
if TransferHeader."Transfer-to Code" <> ProdOrderComponent."Location Code" then begin
ProdOrderComponent.Validate("Location Code", TransferHeader."Transfer-to Code");
ProdOrderComponent.GetDefaultBin();
end;
if TransferHeader."Transfer-to Code" <> ProdOrderComponent."Location Code" then
SubcontractingManagement.ValidateProdOrderCompLocationPreservingFlushingMethod(ProdOrderComponent, TransferHeader."Transfer-to Code");
ProdOrderComponent.Modify();

SubcTransferManagement.CreateReservEntryForTransferReceiptToProdOrderComp(TransferLine, ProdOrderComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ report 99001501 "Subc. Create Transf. Order"
MfgCostCalculationMgt: Codeunit "Mfg. Cost Calculation Mgt.";
SubcProdOrdCompRes: Codeunit "Subc. Prod. Ord. Comp. Res.";
SubcTransferManagement: Codeunit "Subc. Transfer Management";
SubcontractingManagement: Codeunit "Subcontracting Management";
UnitofMeasureManagement: Codeunit "Unit of Measure Management";
TransferFromLocationCode: Code[10];
QtyPerUom: Decimal;
Expand Down Expand Up @@ -245,16 +246,14 @@ report 99001501 "Subc. Create Transf. Order"
Error(ExcessReservationsErr, TransferLine."Quantity (Base)", SubcTransferManagement.GetComponentReservedQtyBase(ProdOrderComponent), ProdOrderComponent."Item No.");

SubcTransferManagement.TransferReservationEntryFromProdOrderCompToTransferOrder(TransferLine, ProdOrderComponent);
if TransferHeader."Transfer-to Code" <> ProdOrderComponent."Location Code" then begin
if TransferHeader."Transfer-to Code" <> ProdOrderComponent."Location Code" then
if Item."Order Tracking Policy" = Item."Order Tracking Policy"::None then
ProdOrderComponent.Validate("Location Code", TransferHeader."Transfer-to Code")
SubcontractingManagement.ValidateProdOrderCompLocationPreservingFlushingMethod(ProdOrderComponent, TransferHeader."Transfer-to Code")
else begin
BindSubscription(SubcProdOrdCompRes);
ProdOrderComponent.Validate("Location Code", TransferHeader."Transfer-to Code");
SubcontractingManagement.ValidateProdOrderCompLocationPreservingFlushingMethod(ProdOrderComponent, TransferHeader."Transfer-to Code");
UnbindSubscription(SubcProdOrdCompRes);
end;
ProdOrderComponent.GetDefaultBin();
end;
ProdOrderComponent.Modify();

SubcTransferManagement.CreateReservEntryForTransferReceiptToProdOrderComp(TransferLine, ProdOrderComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ codeunit 99001540 "Subc. TransOrderPostRcpt Ext"
local procedure OnCheckTransLine(TransferLine: Record "Transfer Line"; TransferHeader: Record "Transfer Header"; Location: Record Location; WhseReceive: Boolean)
var
ProdOrderComponent: Record "Prod. Order Component";
SubcontractingManagement: Codeunit "Subcontracting Management";
begin
#if not CLEAN29
#pragma warning disable AL0432
Expand All @@ -74,7 +75,7 @@ codeunit 99001540 "Subc. TransOrderPostRcpt Ext"
exit;

if Location.Code <> ProdOrderComponent."Location Code" then begin
ProdOrderComponent.Validate("Location Code", Location.Code);
SubcontractingManagement.ValidateProdOrderCompLocationPreservingFlushingMethod(ProdOrderComponent, Location.Code);
ProdOrderComponent.Modify();
end;
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ codeunit 99001547 "Subc. TransOrderPostTrans Ext"
local procedure OnBeforeInsertDirectTransLine(TransferLine: Record "Transfer Line")
var
ProdOrderComponent: Record "Prod. Order Component";
SubcontractingManagement: Codeunit "Subcontracting Management";
begin
#if not CLEAN29
#pragma warning disable AL0432
Expand All @@ -72,7 +73,7 @@ codeunit 99001547 "Subc. TransOrderPostTrans Ext"
if not ProdOrderComponent.Get(ProdOrderComponent.Status::Released, TransferLine."Subc. Prod. Order No.", TransferLine."Subc. Prod. Order Line No.", TransferLine."Subc. Prod. Ord. Comp Line No.") then
exit;

ProdOrderComponent.Validate("Location Code");
SubcontractingManagement.ValidateProdOrderCompLocationPreservingFlushingMethod(ProdOrderComponent, ProdOrderComponent."Location Code");
ProdOrderComponent.Modify();
end;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ codeunit 99001504 "Subc. Transfer Management"
// during Return TO creation. Revert it back to Transfer-from (subcontractor location)
// so the component correctly reflects that items are still at the subcontractor.
if (TransferLine."Transfer-from Code" <> '') and (ProdOrderComponent."Location Code" <> TransferLine."Transfer-from Code") then begin
ProdOrderComponent.Validate("Location Code", TransferLine."Transfer-from Code");
SubcontractingManagement.ValidateProdOrderCompLocationPreservingFlushingMethod(ProdOrderComponent, TransferLine."Transfer-from Code");
ProdOrderComponent.Modify();
end;
exit;
Expand Down
Loading
Loading