Skip to content
Draft
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 @@ -203,7 +203,7 @@ codeunit 99001505 "Subcontracting Management"
TransferLine."Variant Code",
TransferLine."Transfer-from Code",
true,
0,
TransferLine."Quantity (Base)",
TransferLine."Qty. per Unit of Measure",
Database::"Transfer Line",
0, // Direction::Outbound
Expand All @@ -213,6 +213,28 @@ codeunit 99001505 "Subcontracting Management"
TransferLine."Line No.");
end;

procedure ComponentHasExcessReservations(ProdOrderComponent: Record "Prod. Order Component"; MaxQtyBase: Decimal): Boolean
begin
exit(GetComponentReservedQtyBase(ProdOrderComponent) > MaxQtyBase);
end;

procedure GetComponentReservedQtyBase(ProdOrderComponent: Record "Prod. Order Component"): Decimal
var
ReservationEntry: Record "Reservation Entry";
ProdOrderCompReserve: Codeunit "Prod. Order Comp.-Reserve";
TotalReservedQtyBase: Decimal;
begin
if not ProdOrderCompReserve.FindReservEntry(ProdOrderComponent, ReservationEntry) then
exit(0);

if ReservationEntry.FindSet() then
repeat
TotalReservedQtyBase += Abs(ReservationEntry."Quantity (Base)");
until ReservationEntry.Next() = 0;

exit(TotalReservedQtyBase);
end;

procedure CreateReservEntryForTransferReceiptToProdOrderComp(
TransferLine: Record "Transfer Line";
ProdOrderComponent: Record "Prod. Order Component")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ report 99001501 "Subc. Create Transf. Order"
Vendor: Record Vendor;
PurchOrderNo: Code[20];
LineNo: Integer;
ExcessReservationsErr: Label 'The transfer quantity (%1) is less than the reserved quantity (%2) on the production order component for item %3. Cancel existing reservations on the component before creating a partial transfer.', Comment = '%1=Transfer Quantity, %2=Reserved Quantity, %3=Item No.';
NothingToCreateErr: Label 'Nothing to create. No components or WIP to transfer for the specified subcontracting order.';
OrderNoDoesNotExistInProdOrderErr: Label 'Operation %1 in the subcontracting order %2 does not exist in the routing %3 of the production order %4.', Comment = '%1=Operation No., %2=Purchase Order No., %3=Routing No., %4=Production Order No.';
OrderNoIsNotSubcontractorErr: Label 'Order %1 is not a Subcontractor work.', Comment = '%1=Purchase Order No.';
Expand Down Expand Up @@ -229,6 +230,9 @@ report 99001501 "Subc. Create Transf. Order"
if ProdOrderComponent."Subc. Orig. Bin Code" = '' then
ProdOrderComponent."Subc. Orig. Bin Code" := ProdOrderComponent."Bin Code";

if SubcontractingManagement.ComponentHasExcessReservations(ProdOrderComponent, TransferLine."Quantity (Base)") then
Comment thread
ChethanT marked this conversation as resolved.
Error(ExcessReservationsErr, TransferLine."Quantity (Base)", SubcontractingManagement.GetComponentReservedQtyBase(ProdOrderComponent), ProdOrderComponent."Item No.");

SubcontractingManagement.TransferReservationEntryFromProdOrderCompToTransferOrder(TransferLine, ProdOrderComponent);
if TransferHeader."Transfer-to Code" <> ProdOrderComponent."Location Code" then begin
if Item."Order Tracking Policy" = Item."Order Tracking Policy"::None then
Expand Down
Loading
Loading