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 @@ -68,7 +68,7 @@ report 20412 "Qlty. Schedule Inspection"
QltyManagementSetup: Record "Qlty. Management Setup";
QltyInspectionCreate: Codeunit "Qlty. Inspection - Create";
ShowWarningIfCreateInspection: Boolean;
CreatedQltyInspectionIds: List of [Code[20]];
CreatedQltyInspectionIds: List of [RecordId];
ZeroInspectionsCreatedMsg: Label 'No inspections were created.';
SomeInspectionsWereCreatedQst: Label '%1 inspections were created. Do you want to see them?', Comment = '%1=the count of inspections that were created.';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ codeunit 20404 "Qlty. Inspection - Create"
RelatedItem: Record Item;
QltyPermissionMgmt: Codeunit "Qlty. Permission Mgmt.";
QltyStartWorkflow: Codeunit "Qlty. Start Workflow";
QltyNotificationMgmt: Codeunit "Qlty. Notification Mgmt.";
RecordRefToBufferTriggeringRecord: RecordRef;
OriginalRecordId: RecordId;
NullRecordId: RecordId;
Expand Down Expand Up @@ -358,12 +357,8 @@ codeunit 20404 "Qlty. Inspection - Create"
if IsNewlyCreatedInspection then
QltyStartWorkflow.StartWorkflowInspectionCreated(QltyInspectionHeader);

if GuiAllowed() and not PreventShowingGeneratedInspectionEvenIfConfigured
and (QltyInspectionHeader."No." <> '') then
if IsManualCreation then
Page.Run(Page::"Qlty. Inspection", QltyInspectionHeader)
else
QltyNotificationMgmt.NotifyInspectionCreated(QltyInspectionHeader);
if IsManualCreation then
DisplayInspectionIfConfigured(IsManualCreation, QltyInspectionHeader);
end else begin
LogCreateInspectionProblem(TargetRecordRef, UnableToCreateInspectionForErr, Format(OriginalRecordId));
if IsManualCreation and (not AvoidThrowingErrorWhenPossible) then
Expand Down Expand Up @@ -839,31 +834,43 @@ codeunit 20404 "Qlty. Inspection - Create"

internal procedure CreateMultipleInspectionsForMultipleRecords(var SetOfRecordsRecordRef: RecordRef; IsManualCreation: Boolean; var TempFiltersQltyInspectionGenRule: Record "Qlty. Inspection Gen. Rule" temporary)
var
CreatedQltyInspectionIds: List of [Code[20]];
CreatedQltyInspectionIds: List of [RecordId];
begin
CreateMultipleInspectionsWithoutDisplaying(SetOfRecordsRecordRef, IsManualCreation, TempFiltersQltyInspectionGenRule, CreatedQltyInspectionIds);

if IsManualCreation and GuiAllowed() then
DisplayInspectionsIfConfigured(IsManualCreation, CreatedQltyInspectionIds);
end;

internal procedure DisplayInspectionsIfConfigured(IsManualCreation: Boolean; var CreatedQltyInspectionIds: List of [Code[20]])
internal procedure DisplayInspectionIfConfigured(IsManualCreation: Boolean; CreatedQltyInspectionHeader: Record "Qlty. Inspection Header")
var
CreatedQltyInspectionIds: List of [RecordId];
begin
CreatedQltyInspectionIds.Add(CreatedQltyInspectionHeader.RecordId);
DisplayInspectionsIfConfigured(IsManualCreation, CreatedQltyInspectionIds);
end;

internal procedure DisplayInspectionsIfConfigured(IsManualCreation: Boolean; var CreatedQltyInspectionIds: List of [RecordId])
var
CreatedQltyInspectionHeader: Record "Qlty. Inspection Header";
QltyNotificationMgmt: Codeunit "Qlty. Notification Mgmt.";
InspectionNo: Code[20];
InspectionRecordId: RecordId;
PipeSeparatedFilter: Text;
begin
if PreventShowingGeneratedInspectionEvenIfConfigured then
exit;
QltyManagementSetup.Get();

if GuiAllowed() then begin
foreach InspectionNo in CreatedQltyInspectionIds do
if InspectionNo <> '' then begin
if StrLen(PipeSeparatedFilter) > 1 then
PipeSeparatedFilter += '|';
PipeSeparatedFilter += InspectionNo;
end;
foreach InspectionRecordId in CreatedQltyInspectionIds do
if CreatedQltyInspectionHeader.Get(InspectionRecordId) then
if CreatedQltyInspectionHeader."No." <> '' then begin
if StrLen(PipeSeparatedFilter) > 1 then
PipeSeparatedFilter += '|';
PipeSeparatedFilter += CreatedQltyInspectionHeader."No.";
end;

Clear(CreatedQltyInspectionHeader);
CreatedQltyInspectionHeader.SetFilter("No.", PipeSeparatedFilter);
if CreatedQltyInspectionIds.Count() = 1 then begin
CreatedQltyInspectionHeader.SetCurrentKey("No.", "Re-inspection No.");
Expand All @@ -889,7 +896,7 @@ codeunit 20404 "Qlty. Inspection - Create"
/// <param name="IsManualCreation"></param>
/// <param name="ptrecOptionalFiltersGenerationRule"></param>
/// <param name="CreatedQltyInspectionIds"></param>
internal procedure CreateMultipleInspectionsWithoutDisplaying(var SetOfRecordsRecordRef: RecordRef; IsManualCreation: Boolean; var TempFiltersQltyInspectionGenRule: Record "Qlty. Inspection Gen. Rule" temporary; var CreatedQltyInspectionIds: List of [Code[20]])
internal procedure CreateMultipleInspectionsWithoutDisplaying(var SetOfRecordsRecordRef: RecordRef; IsManualCreation: Boolean; var TempFiltersQltyInspectionGenRule: Record "Qlty. Inspection Gen. Rule" temporary; var CreatedQltyInspectionIds: List of [RecordId])
var
TempCopyOfSingleRecordRecordRef: RecordRef;
ParentRecordRef: RecordRef;
Expand Down Expand Up @@ -929,7 +936,7 @@ codeunit 20404 "Qlty. Inspection - Create"
end;
end;

local procedure CreateInspectionForSelfOrDirectParent(var TempSelfRecordRef: RecordRef; var TempFiltersQltyInspectionGenRule: Record "Qlty. Inspection Gen. Rule" temporary; var FoundParentRecordRef: RecordRef; var CreatedQltyInspectionIds: List of [Code[20]]; PreventInspectionFromDisplayingEvenIfConfigured: Boolean; IsManualCreation: Boolean) InspectionCreatedCount: Integer
local procedure CreateInspectionForSelfOrDirectParent(var TempSelfRecordRef: RecordRef; var TempFiltersQltyInspectionGenRule: Record "Qlty. Inspection Gen. Rule" temporary; var FoundParentRecordRef: RecordRef; var CreatedQltyInspectionIds: List of [RecordId]; PreventInspectionFromDisplayingEvenIfConfigured: Boolean; IsManualCreation: Boolean) InspectionCreatedCount: Integer
var
LastCreatedQltyInspectionHeader2: Record "Qlty. Inspection Header";
Item: Record Item;
Expand Down Expand Up @@ -1007,8 +1014,8 @@ codeunit 20404 "Qlty. Inspection - Create"
if LocalQltyInspectionCreate.CreateInspectionWithMultiVariants(ParentRecordRef, TempSelfRecordRef, VariantEmptyOrTrackingSpecification, Dummy4Variant, IsManualCreation, TempFiltersQltyInspectionGenRule) then
if LocalQltyInspectionCreate.GetCreatedInspection(LastCreatedQltyInspectionHeader2) then begin
InspectionCreatedCount += 1;
if not CreatedQltyInspectionIds.Contains(LastCreatedQltyInspectionHeader2."No.") then
CreatedQltyInspectionIds.Add(LastCreatedQltyInspectionHeader2."No.");
if not CreatedQltyInspectionIds.Contains(LastCreatedQltyInspectionHeader2.RecordId) then
CreatedQltyInspectionIds.Add(LastCreatedQltyInspectionHeader2.RecordId);
end;
until RelatedReservFilterReservationEntry.Next() = 0;
end else begin
Expand All @@ -1021,8 +1028,8 @@ codeunit 20404 "Qlty. Inspection - Create"
if LocalQltyInspectionCreate.CreateInspectionWithMultiVariants(TempSelfRecordRef, ParentRecordRef, Dummy4Variant, Dummy4Variant, IsManualCreation, TempFiltersQltyInspectionGenRule) then
if LocalQltyInspectionCreate.GetCreatedInspection(LastCreatedQltyInspectionHeader2) then begin
InspectionCreatedCount += 1;
if not CreatedQltyInspectionIds.Contains(LastCreatedQltyInspectionHeader2."No.") then
CreatedQltyInspectionIds.Add(LastCreatedQltyInspectionHeader2."No.");
if not CreatedQltyInspectionIds.Contains(LastCreatedQltyInspectionHeader2.RecordId) then
CreatedQltyInspectionIds.Add(LastCreatedQltyInspectionHeader2.RecordId);
end;
end;
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ using Microsoft.Warehouse.Journal;
/// </summary>
codeunit 20412 "Qlty. Assembly Integration"
{
SingleInstance = true;

var
ListOfCreatedInspectionIds: List of [RecordId];

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Assembly-Post", 'OnAfterPost', '', true, true)]
local procedure HandleOnAfterPost(var AssemblyHeader: Record "Assembly Header"; var AssemblyLine: Record "Assembly Line"; PostedAssemblyHeader: Record "Posted Assembly Header"; var ItemJnlPostLine: Codeunit "Item Jnl.-Post Line"; var ResJnlPostLine: Codeunit "Res. Jnl.-Post Line"; var WhseJnlRegisterLine: Codeunit "Whse. Jnl.-Register Line")
var
Expand All @@ -45,11 +50,15 @@ codeunit 20412 "Qlty. Assembly Integration"

if not TempSpecTrackingSpecification.IsEmpty() then
repeat
Clear(QltyInspectionHeader);
HasInspection := QltyInspectionCreate.CreateInspectionWithMultiVariants(PostedAssemblyHeader, TempSpecTrackingSpecification, AssemblyHeader, UnusedVariant1, false, QltyInspectionGenRule);
if HasInspection then begin
QltyInspectionCreate.GetCreatedInspection(QltyInspectionHeader);
QltyInspectionHeader."Source Quantity (Base)" := TempSpecTrackingSpecification."Quantity (Base)";
QltyInspectionHeader.Modify(false);
if QltyInspectionHeader."No." <> '' then begin
QltyInspectionHeader."Source Quantity (Base)" := TempSpecTrackingSpecification."Quantity (Base)";
QltyInspectionHeader.Modify(false);
ListOfCreatedInspectionIds.Add(QltyInspectionHeader.RecordId);
end;
end;
OnAfterAttemptCreateInspectionFromPostedAssembly(AssemblyHeader, PostedAssemblyHeader, TempSpecTrackingSpecification, QltyInspectionHeader);
until TempSpecTrackingSpecification.Next(-1) = 0
Expand All @@ -59,10 +68,23 @@ codeunit 20412 "Qlty. Assembly Integration"
if IsHandled then
exit;
HasInspection := QltyInspectionCreate.CreateInspectionWithMultiVariants(PostedAssemblyHeader, AssemblyHeader, UnusedVariant1, UnusedVariant2, false, TempQltyInspectionGenRule);
if HasInspection then
if HasInspection then begin
QltyInspectionCreate.GetCreatedInspection(QltyInspectionHeader);
if QltyInspectionHeader."No." <> '' then
ListOfCreatedInspectionIds.Add(QltyInspectionHeader.RecordId);
end;
OnAfterAttemptCreateInspectionFromPostedAssembly(AssemblyHeader, PostedAssemblyHeader, TempSpecTrackingSpecification, QltyInspectionHeader);
end;
if ListOfCreatedInspectionIds.Count() > 0 then begin
QltyInspectionCreate.DisplayInspectionsIfConfigured(false, ListOfCreatedInspectionIds);
Clear(ListOfCreatedInspectionIds);
end;
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Assembly-Post", 'OnBeforePost', '', true, true)]
local procedure HandleOnBeforePost(var AssemblyHeader: Record "Assembly Header")
begin
Clear(ListOfCreatedInspectionIds);
end;

/// <summary>
Expand Down
Loading