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 @@ -536,30 +536,14 @@ codeunit 20439 "Qlty. Item Tracking Mgmt."

ReservForReservationEntry."Lot No." := LotNo;
ReservForReservationEntry."Serial No." := SerialNo;
ReservForReservationEntry."Package No." := PackageNo;

CreateReservEntry.CreateReservEntryFor(Database::"Purchase Line", 5, PurchPurchaseLine."Document No.", '', 0, PurchPurchaseLine."Line No.", PurchPurchaseLine."Qty. per Unit of Measure", ChangeQty / PurchPurchaseLine."Qty. per Unit of Measure", ChangeQty, ReservForReservationEntry);

if ExpirationDate <> 0D then
CreateReservEntry.SetDates(0D, ExpirationDate);

CreateReservEntry.CreateEntry(PurchPurchaseLine."No.", PurchPurchaseLine."Variant Code", PurchPurchaseLine."Location Code", PurchPurchaseLine.Description, Today, 0D, 0, ReservationStatus::Surplus);

if PackageNo <> '' then begin
ReservationEntry.Reset();
ReservationEntry.SetRange("Reservation Status", ReservationEntry."Reservation Status"::Surplus);
ReservationEntry.SetRange("Lot No.", LotNo);
ReservationEntry.SetRange("Serial No.", SerialNo);
ReservationEntry.SetFilter("Package No.", '%1', '');
ReservationEntry.SetRange("Location Code", PurchPurchaseLine."Location Code");
ReservationEntry.SetRange("Source Type", Database::"Purchase Line");
ReservationEntry.SetRange("Source ID", PurchPurchaseLine."Document No.");
ReservationEntry.SetRange("Source Ref. No.", PurchPurchaseLine."Line No.");
ReservationEntry.SetRange(Positive, false);
if ReservationEntry.FindLast() then begin
ReservationEntry."Package No." := PackageNo;
ReservationEntry.Modify();
end;
end;
end;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ using Microsoft.QualityManagement.Configuration.GenerationRule;
using Microsoft.QualityManagement.Configuration.SourceConfiguration;
using Microsoft.QualityManagement.Document;
using Microsoft.QualityManagement.Setup;
using Microsoft.QualityManagement.Utilities;

/// <summary>
/// Used to integrate with manufacturing related events.
Expand All @@ -22,7 +21,6 @@ codeunit 20407 "Qlty. Manufactur. Integration"
{
var
QltyTraversal: Codeunit "Qlty. Traversal";
QltySessionHelper: Codeunit "Qlty. Session Helper";

/// <summary>
/// We subscribe to OnAfterPostOutput to see if we need to create an inspection related to the output.
Expand Down Expand Up @@ -86,36 +84,22 @@ codeunit 20407 "Qlty. Manufactur. Integration"
AttemptCreateInspectionPosting(ProdOrderRoutingLine, VerifiedItemLedgerEntry, ProdOrderLine, ItemJournalLine, QltyInspectionGenRule);
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Prod. Order Status Management", 'OnBeforeChangeStatusOnProdOrder', '', true, true)]
local procedure HandleOnBeforeChangeStatusOnProdOrder(var ProductionOrder: Record "Production Order"; NewStatus: Option Quote,Planned,"Firm Planned",Released,Finished; var IsHandled: Boolean; NewPostingDate: Date; NewUpdateUnitCost: Boolean)
var
QltyManagementSetup: Record "Qlty. Management Setup";
begin
if not QltyManagementSetup.GetSetupRecord() then
exit;

QltySessionHelper.SetProductionOrderBeforeChangingStatus(ProductionOrder);
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Prod. Order Status Management", 'OnAfterChangeStatusOnProdOrder', '', true, true)]
local procedure HandleOnAfterChangeStatusOnProdOrder(var ProdOrder: Record "Production Order"; var ToProdOrder: Record "Production Order"; NewStatus: Enum "Production Order Status"; NewPostingDate: Date; NewUpdateUnitCost: Boolean; var SuppressCommit: Boolean)
local procedure HandleOnAfterChangeStatusOnProdOrder(var ProdOrder: Record "Production Order"; var ToProdOrder: Record "Production Order"; NewStatus: Enum "Production Order Status"; NewPostingDate: Date; NewUpdateUnitCost: Boolean; var SuppressCommit: Boolean; xProductionOrder: Record "Production Order")
var
QltyManagementSetup: Record "Qlty. Management Setup";
OldProductionOrder: Record "Production Order";
QltyInspectionGenRule: Record "Qlty. Inspection Gen. Rule";
IsHandled: Boolean;
begin
if not QltyManagementSetup.GetSetupRecord() then
exit;

QltySessionHelper.GetProductionOrderBeforeChangingStatus(OldProductionOrder);

OnBeforeProductionHandleOnAfterChangeStatusOnProdOrder(OldProductionOrder, ToProdOrder, IsHandled);
OnBeforeProductionHandleOnAfterChangeStatusOnProdOrder(xProductionOrder, ToProdOrder, IsHandled);
if IsHandled then
exit;

if QltyManagementSetup."Production Update Control" in [QltyManagementSetup."Production Update Control"::"Update when source changes"] then
UpdateReferencesForProductionOrder(OldProductionOrder, ToProdOrder);
UpdateReferencesForProductionOrder(xProductionOrder, ToProdOrder);

if ToProdOrder.Status <> ToProdOrder.Status::Released then
exit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ codeunit 20411 "Qlty. Receiving Integration"
TempTrackingSpecification.DeleteAll(false);
TempTrackingSpecification.SetSourceFromReservEntry(ReservationEntry);
TempTrackingSpecification.CopyTrackingFromReservEntry(ReservationEntry);
TempTrackingSpecification."Package No." := ReservationEntry."Package No.";
TempTrackingSpecification."Quantity (Base)" := ReservationEntry."Quantity (Base)";
TempTrackingSpecification.Insert();
AttemptCreateInspectionWithPurchaseLineAndTracking(PurchaseLine, PurchaseHeader, TempTrackingSpecification);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ codeunit 20438 "Qlty. - Warehouse Integration"
TempTrackingSpecification."Entry No." := ReservationCounter;
TempTrackingSpecification.SetSourceFromReservEntry(ReservationEntry);
TempTrackingSpecification.CopyTrackingFromReservEntry(ReservationEntry);
TempTrackingSpecification."Package No." := ReservationEntry."Package No.";
TempTrackingSpecification.Insert();
until ReservationEntry.Next() = 0;
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,21 @@
// ------------------------------------------------------------------------------------------------
namespace Microsoft.QualityManagement.Utilities;

using Microsoft.Manufacturing.Document;

/// <summary>
/// This exists to help keep track of variables to work around a variety of BC issues.
/// Keep track of global session values related to quality management, for example for item tracking.
/// </summary>
codeunit 20430 "Qlty. Session Helper"
{
SingleInstance = true;
InherentPermissions = X;

var
ProductionOrderBeforeChangingStatus: Record "Production Order";
MiscKeyValuePairs: Dictionary of [Text, Text];
ItemTrackingFlagAllOrSingleTok: Label 'Qlty::ItemTracking::AllOrSingle', Locked = true;
ItemTrackingFlagAllDocsTok: Label 'Qlty::ItemTracking::AllOrSingle::ALLDOCS', Locked = true;
ItemTrackingFlagSourceDocOnlyTok: Label 'Qlty::ItemTracking::AllOrSingle::SOURCEDOCONLY', Locked = true;
ItemTrackingIsFromQltyInspectionModeTok: Label 'Qlty::ItemTracking::StartingFromQltyInspection', Locked = true;

#region Manufacturing - Production Order Status Change Handling
internal procedure SetProductionOrderBeforeChangingStatus(var ProductionOrderToSet: Record "Production Order")
begin
ProductionOrderBeforeChangingStatus := ProductionOrderToSet;
end;

internal procedure GetProductionOrderBeforeChangingStatus(var ProductionOrderToGet: Record "Production Order")
begin
ProductionOrderToGet := ProductionOrderBeforeChangingStatus;
end;
#endregion Manufacturing - Production Order Status Change Handling

internal procedure SetSessionValue(CurrentKey: Text; Value: Text)
begin
MiscKeyValuePairs.Set(CurrentKey, Value);
Expand Down
Loading