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 @@ -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());
Expand All @@ -54,7 +61,6 @@ codeunit 6195 "E-Doc. AI Tool Processor"
AOAIChatCompletionParams.SetTemperature(GetDefaultTemperature());

// Setup AI system and messages
AISystem := EDocAISystem;
SetupChatMessages();

// Setup telemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down