diff --git a/src/Apps/W1/EDocument/App/src/Processing/AI/EDocAIToolProcessor.Codeunit.al b/src/Apps/W1/EDocument/App/src/Processing/AI/EDocAIToolProcessor.Codeunit.al index a423e0f205..b9fd9b5549 100644 --- a/src/Apps/W1/EDocument/App/src/Processing/AI/EDocAIToolProcessor.Codeunit.al +++ b/src/Apps/W1/EDocument/App/src/Processing/AI/EDocAIToolProcessor.Codeunit.al @@ -37,13 +37,20 @@ codeunit 6195 "E-Doc. AI Tool Processor" procedure Setup(EDocAISystem: Interface IEDocAISystem): Boolean var CopilotCapability: Codeunit "Copilot Capability"; + CapabilityNotRegisteredTxt: Label 'Copilot capability is not registered for E-Document Matching Assistance', Locked = true; + CapabilityNotActiveTxt: Label 'Copilot capability is not active for E-Document Matching Assistance', Locked = true; begin Clear(TelemetryDimensions); + AISystem := EDocAISystem; - if not CopilotCapability.IsCapabilityRegistered(Enum::"Copilot Capability"::"E-Document Matching Assistance") then + if not CopilotCapability.IsCapabilityRegistered(Enum::"Copilot Capability"::"E-Document Matching Assistance") then begin + Session.LogMessage('', CapabilityNotRegisteredTxt, Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::All, 'Category', AISystem.GetFeatureName()); exit(false); - if not CopilotCapability.IsCapabilityActive(Enum::"Copilot Capability"::"E-Document Matching Assistance") then + end; + if not CopilotCapability.IsCapabilityActive(Enum::"Copilot Capability"::"E-Document Matching Assistance") then begin + Session.LogMessage('', CapabilityNotActiveTxt, Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::All, 'Category', AISystem.GetFeatureName()); exit(false); + end; // Setup Azure OpenAI AzureOpenAI.SetAuthorization(Enum::"AOAI Model Type"::"Chat Completions", GetDefaultModel()); @@ -54,7 +61,6 @@ codeunit 6195 "E-Doc. AI Tool Processor" AOAIChatCompletionParams.SetTemperature(GetDefaultTemperature()); // Setup AI system and messages - AISystem := EDocAISystem; SetupChatMessages(); // Setup telemetry diff --git a/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocDeferralMatching.Codeunit.al b/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocDeferralMatching.Codeunit.al index 39df7525f2..878a814d78 100644 --- a/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocDeferralMatching.Codeunit.al +++ b/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocDeferralMatching.Codeunit.al @@ -36,9 +36,12 @@ codeunit 6129 "E-Doc. Deferral Matching" implements "AOAI Function", IEDocAISyst MatchedCount: Integer; TelemetryDimensions: Dictionary of [Text, Text]; ActivityLogTitleTxt: Label 'Deferral template %1', Comment = '%1 = Deferral template Code'; + NoDeferralTemplatesTxt: Label 'No Deferral Templates found in the system, skipping AI matching', Locked = true; begin - if DeferralTemplate.IsEmpty() then + if DeferralTemplate.IsEmpty() then begin + Session.LogMessage('', NoDeferralTemplatesTxt, Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::All, 'Category', GetFeatureName()); exit; + end; if EDocumentAIProcessor.Setup(this) then if not EDocumentAIProcessor.Process(CreateUserMessage(Rec), Response) then diff --git a/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocGLAccountMatching.Codeunit.al b/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocGLAccountMatching.Codeunit.al index 69ed3e6490..9cda684427 100644 --- a/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocGLAccountMatching.Codeunit.al +++ b/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocGLAccountMatching.Codeunit.al @@ -39,9 +39,12 @@ codeunit 6126 "E-Doc. GL Account Matching" implements "AOAI Function", IEDocAISy TelemetryDimensions: Dictionary of [Text, Text]; ActivityLogTitleTxt: Label 'GL Account %1', Comment = '%1 = G/L Account No.'; AIAccountMatchEventTok: Label 'GL Account AI Match', Locked = true; + NoGLAccountsTxt: Label 'No G/L Accounts found in the system, skipping AI matching', Locked = true; begin - if GLAccount.IsEmpty() then + if GLAccount.IsEmpty() then begin + Session.LogMessage('', NoGLAccountsTxt, Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::All, 'Category', GetFeatureName()); exit; + end; if not EDocumentAIProcessor.Setup(this) then exit; diff --git a/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocHistoricalMatching.Codeunit.al b/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocHistoricalMatching.Codeunit.al index 9531cafeb0..ea7fce6bab 100644 --- a/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocHistoricalMatching.Codeunit.al +++ b/src/Apps/W1/EDocument/App/src/Processing/AI/Tools/EDocHistoricalMatching.Codeunit.al @@ -135,9 +135,13 @@ codeunit 6177 "E-Doc. Historical Matching" implements "AOAI Function", IEDocAISy CouldNotFindHeaderErr: Label 'Could not find E-Document Purchase Header for E-Document Entry No. %1', Comment = '%1 = E-Document Entry No.', Locked = true; NoUnmatchedLinesErr: Label 'No unmatched E-Document Purchase Lines found for E-Document Entry No. %1', Comment = '%1 = E-Document Entry No.', Locked = true; HistoricalTempTableIsEmptyErr: Label 'No historical purchase invoice lines found for E-Document Entry No. %1', Comment = '%1 = E-Document Entry No.', Locked = true; + NoPurchaseLinesTxt: Label 'No E-Document Purchase Lines found, skipping historical matching', Locked = true; + NoPotentialMatchesTxt: Label 'No potential historical matches found after data collection', Locked = true; begin - if not EDocumentPurchaseLine.FindFirst() then + if not EDocumentPurchaseLine.FindFirst() then begin + Session.LogMessage('', NoPurchaseLinesTxt, Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::All, 'Category', GetFeatureName()); exit(false); + end; EDocSystemId := EDocumentPurchaseLine.SystemId; @@ -171,6 +175,9 @@ codeunit 6177 "E-Doc. Historical Matching" implements "AOAI Function", IEDocAISy Clear(TempHistoricalMatchBuffer); CollectPotentialMatches(EDocumentPurchaseLine, TempPurchInvLine, VendorNo); + if TempHistoricalMatchBuffer.IsEmpty() then + Session.LogMessage('', NoPotentialMatchesTxt, Verbosity::Warning, DataClassification::SystemMetadata, TelemetryScope::All, 'Category', GetFeatureName()); + exit(not TempHistoricalMatchBuffer.IsEmpty()); end;