Skip to content

Commit f413ebf

Browse files
Magnus Hartvig GrønbechCopilot
andcommitted
feat(PayablesAgent): Add inbound e-documents count and link to setup page
Show the number of inbound e-documents processed by the agent in the Cost section of the configuration dialog, with a drilldown link to the Inbound E-Documents page filtered to agent-created documents. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5a1d289 commit f413ebf

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

src/Apps/W1/PayablesAgent/app/Setup/PayablesAgentSetup.Codeunit.al

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ codeunit 3307 "Payables Agent Setup"
185185
exit(EDocument.GetEDocumentService().Code = PayablesAgentEDocServiceTok);
186186
end;
187187

188+
procedure GetAgentEDocumentServiceCode(): Code[20]
189+
begin
190+
exit(PayablesAgentEDocServiceTok);
191+
end;
192+
188193
/// <summary>
189194
/// Retrieves the agent record if configured in the database, and ensures that the Payables Agent setup record is updated with the correct user security id.
190195
/// </summary>

src/Apps/W1/PayablesAgent/app/Setup/PayablesAgentSetup.Page.al

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,32 @@ page 3304 "Payables Agent Setup"
154154
Editable = false;
155155
ToolTip = 'Specifies the total number of Copilot credits consumed by the Payables Agent.', Comment = 'Payables Agent is a term, and should not be translated.';
156156
}
157+
field(AgentTasks; AgentTasksText)
158+
{
159+
ShowCaption = false;
160+
Editable = false;
161+
StyleExpr = true;
162+
Style = StandardAccent;
163+
ToolTip = 'Specifies the number of tasks completed by the Payables Agent. Choose this field to open the agent task list.', Comment = 'Payables Agent is a term, and should not be translated.';
164+
165+
trigger OnDrillDown()
166+
begin
167+
DrillDownAgentTasks();
168+
end;
169+
}
170+
field(InboundEDocuments; InboundEDocumentsText)
171+
{
172+
ShowCaption = false;
173+
Editable = false;
174+
StyleExpr = true;
175+
Style = StandardAccent;
176+
ToolTip = 'Specifies the number of inbound e-documents processed by the Payables Agent. Choose this field to open the list of inbound e-documents.', Comment = 'Payables Agent is a term, and should not be translated.';
177+
178+
trigger OnDrillDown()
179+
begin
180+
DrillDownInboundEDocuments();
181+
end;
182+
}
157183
field(LearnMoreCost; LearnMoreCostLbl)
158184
{
159185
ShowCaption = false;
@@ -481,6 +507,58 @@ page 3304 "Payables Agent Setup"
481507
begin
482508
CreditsConsumed := PACostEstimate.GetCreditsConsumed();
483509
CostEstimateText := PACostEstimate.FormatCreditsConsumed(CreditsConsumed);
510+
CalcAgentTasks();
511+
CalcInboundEDocuments();
512+
end;
513+
514+
local procedure CalcAgentTasks()
515+
var
516+
AgentTask: Record "Agent Task";
517+
PayablesAgentSetupRec: Record "Payables Agent Setup";
518+
TaskCount: Integer;
519+
begin
520+
PayablesAgentSetupRec.GetSetup();
521+
if IsNullGuid(PayablesAgentSetupRec."User Security Id") then begin
522+
AgentTasksText := StrSubstNo(AgentTasksLbl, 0);
523+
exit;
524+
end;
525+
AgentTask.SetRange("Agent User Security ID", PayablesAgentSetupRec."User Security Id");
526+
TaskCount := AgentTask.Count();
527+
AgentTasksText := StrSubstNo(AgentTasksLbl, TaskCount);
528+
end;
529+
530+
local procedure DrillDownAgentTasks()
531+
var
532+
AgentTask: Record "Agent Task";
533+
PayablesAgentSetupRec: Record "Payables Agent Setup";
534+
AgentTaskList: Page "Agent Task List";
535+
begin
536+
PayablesAgentSetupRec.GetSetup();
537+
if not IsNullGuid(PayablesAgentSetupRec."User Security Id") then
538+
AgentTask.SetRange("Agent User Security ID", PayablesAgentSetupRec."User Security Id");
539+
AgentTaskList.SetTableView(AgentTask);
540+
AgentTaskList.Run();
541+
end;
542+
543+
local procedure CalcInboundEDocuments()
544+
var
545+
EDocument: Record "E-Document";
546+
EDocCount: Integer;
547+
begin
548+
EDocument.SetRange(Direction, "E-Document Direction"::Incoming);
549+
EDocument.SetRange(Service, PayablesAgentSetup.GetAgentEDocumentServiceCode());
550+
EDocCount := EDocument.Count();
551+
InboundEDocumentsText := StrSubstNo(InboundEDocumentsLbl, EDocCount);
552+
end;
553+
554+
local procedure DrillDownInboundEDocuments()
555+
var
556+
EDocument: Record "E-Document";
557+
InboundEDocumentsPage: Page "Inbound E-Documents";
558+
begin
559+
EDocument.SetRange(Service, PayablesAgentSetup.GetAgentEDocumentServiceCode());
560+
InboundEDocumentsPage.SetTableView(EDocument);
561+
InboundEDocumentsPage.Run();
484562
end;
485563

486564
/// <summary>
@@ -542,6 +620,8 @@ page 3304 "Payables Agent Setup"
542620
MailboxAddress: Text;
543621
TrialProgressText: Text;
544622
CostEstimateText: Text;
623+
AgentTasksText: Text;
624+
InboundEDocumentsText: Text;
545625
TrialExperienceVisible: Boolean;
546626
IsEligibleForTrialVisible: Boolean;
547627
IsInTrialModeVisible: Boolean;
@@ -565,5 +645,7 @@ page 3304 "Payables Agent Setup"
565645
BenefitNoDisruptionLbl: Label '• No disruption to your current process';
566646
SelectFileLbl: Label 'Select file';
567647
PdfFileFilterLbl: Label 'PDF Files (*.pdf)|*.pdf';
648+
InboundEDocumentsLbl: Label 'Based on %1 inbound e-documents', Comment = '%1 is the number of inbound e-documents processed by the agent.';
649+
AgentTasksLbl: Label '%1 agent tasks', Comment = '%1 is the number of tasks completed by the agent.';
568650

569651
}

0 commit comments

Comments
 (0)