-
Notifications
You must be signed in to change notification settings - Fork 430
Add AI-assisted policy evaluation backend to Expense Agent #10031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
encimita
wants to merge
8
commits into
main
Choose a base branch
from
copilot/expense-agent-policy-evaluation-251762
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f89f029
Expense Agent: port policy evaluation backend to BCApps
encimita b0e571a
Expense Agent: clear lines without applicable policies
encimita 0b09b4d
Expense Agent: address PR review comments (policy invalidation, super…
encimita ec51c1f
Harden policy-flag API: guard mark-evaluated and validate flag inserts
encimita eca39ec
Surface expense-line policy status in the client with drilldown (open…
encimita 9580474
Simplify policy flag: drop Policy Line No., rename Description to Reason
encimita b290796
Add Subject Type to expense policy flag primary key
encimita b7a7902
Renumber Posted Exp. Policy Flag Card page 7110 -> 7106
encimita File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,6 +135,10 @@ | |
| { | ||
| "from": 7073, | ||
| "to": 7099 | ||
| }, | ||
| { | ||
| "from": 7101, | ||
| "to": 7110 | ||
| } | ||
| ], | ||
| "features": [ | ||
|
|
||
66 changes: 66 additions & 0 deletions
66
src/Apps/W1/ExpenseAgent/app/src/APIs/ExpensePoliciesAPI.Page.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
| namespace Microsoft.ExpenseAgent; | ||
|
|
||
| page 7104 "Expense Policies API" | ||
| { | ||
| APIGroup = 'expense'; | ||
| APIPublisher = 'microsoft'; | ||
| APIVersion = 'beta'; | ||
| EntityCaption = 'Expense Policy'; | ||
| EntitySetCaption = 'Expense Policies'; | ||
| DelayedInsert = true; | ||
| EntityName = 'expensePolicy'; | ||
| EntitySetName = 'expensePolicies'; | ||
| PageType = API; | ||
| ODataKeyFields = SystemId; | ||
| SourceTable = "Expense Policy"; | ||
| AboutText = 'Provides access to data from the Expense Policy table'; | ||
| InsertAllowed = false; | ||
| ModifyAllowed = false; | ||
| DeleteAllowed = false; | ||
|
|
||
| layout | ||
| { | ||
| area(Content) | ||
| { | ||
| repeater(General) | ||
| { | ||
| field(id; Rec.SystemId) | ||
| { | ||
| Caption = 'Id'; | ||
| Editable = false; | ||
| } | ||
| field(expenseCategoryCode; Rec."Expense Category Code") | ||
| { | ||
| Caption = 'Expense Category Code'; | ||
| } | ||
| field(lineNo; Rec."Line No.") | ||
| { | ||
| Caption = 'Line No.'; | ||
| } | ||
| field(description; Rec.Description) | ||
| { | ||
| Caption = 'Description'; | ||
| } | ||
| field(policyText; Rec."Policy Text") | ||
| { | ||
| Caption = 'Policy Text'; | ||
| } | ||
| field(enabled; Rec.Enabled) | ||
| { | ||
| Caption = 'Enabled'; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| trigger OnInit() | ||
| var | ||
| ExpenseAgentAPIValidation: Codeunit "Expense Agent API Validation"; | ||
| begin | ||
| ExpenseAgentAPIValidation.VerifyAgentAccess(); | ||
| end; | ||
| } |
90 changes: 90 additions & 0 deletions
90
src/Apps/W1/ExpenseAgent/app/src/APIs/ExpensePolicyFlagsAPI.Page.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
| namespace Microsoft.ExpenseAgent; | ||
|
|
||
| page 7102 "Expense Policy Flags API" | ||
| { | ||
| APIGroup = 'expense'; | ||
| APIPublisher = 'microsoft'; | ||
| APIVersion = 'beta'; | ||
| EntityCaption = 'Expense Policy Flag'; | ||
| EntitySetCaption = 'Expense Policy Flags'; | ||
| DelayedInsert = true; | ||
| EntityName = 'expensePolicyFlag'; | ||
| EntitySetName = 'expensePolicyFlags'; | ||
| PageType = API; | ||
| ODataKeyFields = SystemId; | ||
| SourceTable = "Expense Policy Flag"; | ||
| AboutText = 'Provides access to data from the Expense Policy Flag table'; | ||
| InsertAllowed = true; | ||
| ModifyAllowed = false; | ||
| DeleteAllowed = false; | ||
|
|
||
| layout | ||
| { | ||
| area(Content) | ||
| { | ||
| repeater(General) | ||
| { | ||
| field(id; Rec.SystemId) | ||
| { | ||
| Caption = 'Id'; | ||
| Editable = false; | ||
| } | ||
| field(subjectSystemId; Rec."Subject System Id") | ||
| { | ||
| Caption = 'Subject System Id'; | ||
| } | ||
| field(subjectType; Rec."Subject Type") | ||
| { | ||
| Caption = 'Subject Type'; | ||
| } | ||
| field(subjectVersion; Rec."Subject Version") | ||
| { | ||
| Caption = 'Subject Version'; | ||
| Editable = false; | ||
| } | ||
| field(expenseCategoryCode; Rec."Expense Category Code") | ||
| { | ||
| Caption = 'Expense Category Code'; | ||
| Editable = false; | ||
| } | ||
| field(policySystemId; Rec."Policy System Id") | ||
| { | ||
| Caption = 'Policy System Id'; | ||
| } | ||
| field(policyVersion; Rec."Policy Version") | ||
| { | ||
| Caption = 'Policy Version'; | ||
| Editable = false; | ||
| } | ||
| field(isCurrent; Rec."Is Current") | ||
| { | ||
| Caption = 'Is Current'; | ||
| Editable = false; | ||
| } | ||
| field(reason; Rec."Reason") | ||
| { | ||
| Caption = 'Reason'; | ||
| } | ||
| field(flaggedAt; Rec."Flagged At") | ||
| { | ||
| Caption = 'Flagged At'; | ||
| } | ||
| field(compliant; Rec."Compliant") | ||
| { | ||
| Caption = 'Compliant'; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| trigger OnInit() | ||
| var | ||
| ExpenseAgentAPIValidation: Codeunit "Expense Agent API Validation"; | ||
| begin | ||
| ExpenseAgentAPIValidation.VerifyAgentAccess(); | ||
| end; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/Apps/W1/ExpenseAgent/app/src/APIs/PoliciesToEvaluate/ExpPoliciesToEvalAPI.Page.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
| namespace Microsoft.ExpenseAgent; | ||
|
|
||
| page 7108 "Exp. Policies To Eval API" | ||
| { | ||
| PageType = API; | ||
| APIPublisher = 'microsoft'; | ||
| APIGroup = 'expense'; | ||
| APIVersion = 'beta'; | ||
| EntityName = 'policyToEvaluate'; | ||
| EntitySetName = 'policiesToEvaluate'; | ||
| EntityCaption = 'Policy To Evaluate'; | ||
| EntitySetCaption = 'Policies To Evaluate'; | ||
| SourceTable = "Exp. Policy To Eval Buffer"; | ||
| SourceTableTemporary = true; | ||
| ODataKeyFields = "Subject System Id", "Policy System Id"; | ||
| DataAccessIntent = ReadOnly; | ||
| Editable = false; | ||
| InsertAllowed = false; | ||
| ModifyAllowed = false; | ||
| DeleteAllowed = false; | ||
| Extensible = false; | ||
| AboutTitle = 'Policies To Evaluate'; | ||
| AboutText = 'Returns the enabled policies that still need to be evaluated for an expense report line - policies newly introduced or bumped to a new version, or any policy not yet evaluated at the line''s current version. Read this to know which policies to (re)run when a line is stale.'; | ||
|
|
||
| layout | ||
| { | ||
| area(Content) | ||
| { | ||
| repeater(General) | ||
| { | ||
| field(subjectSystemId; Rec."Subject System Id") | ||
| { | ||
| Caption = 'Subject System Id'; | ||
| } | ||
| field(subjectVersion; Rec."Subject Version") | ||
| { | ||
| Caption = 'Subject Version'; | ||
| } | ||
| field(policySystemId; Rec."Policy System Id") | ||
| { | ||
| Caption = 'Policy System Id'; | ||
| } | ||
| field(policyLineNo; Rec."Policy Line No.") | ||
| { | ||
| Caption = 'Policy Line No.'; | ||
| } | ||
| field(policyVersion; Rec."Policy Version") | ||
| { | ||
| Caption = 'Policy Version'; | ||
| } | ||
| field(expenseCategoryCode; Rec."Expense Category Code") | ||
| { | ||
| Caption = 'Expense Category Code'; | ||
| } | ||
| field(description; Rec."Description") | ||
| { | ||
| Caption = 'Description'; | ||
| } | ||
| field(policyText; Rec."Policy Text") | ||
| { | ||
| Caption = 'Policy Text'; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| var | ||
| Builder: Codeunit "Exp. Policies To Eval Builder"; | ||
| BuiltSubjectFilter: Text; | ||
| HasBuilt: Boolean; | ||
|
|
||
| trigger OnInit() | ||
| var | ||
| ExpenseAgentAPIValidation: Codeunit "Expense Agent API Validation"; | ||
| begin | ||
| ExpenseAgentAPIValidation.VerifyAgentAccess(); | ||
| end; | ||
|
|
||
| trigger OnFindRecord(Which: Text): Boolean | ||
| var | ||
| SubjectFilter: Text; | ||
| FilterView: Text; | ||
| begin | ||
| SubjectFilter := Rec.GetFilter("Subject System Id"); | ||
| // Rebuild whenever the parent subject changes so $expand across many lines stays correct. | ||
| if (not HasBuilt) or (SubjectFilter <> BuiltSubjectFilter) then begin | ||
| FilterView := Rec.GetView(); | ||
| Builder.Build(Rec, SubjectFilter); | ||
| Rec.SetView(FilterView); | ||
| BuiltSubjectFilter := SubjectFilter; | ||
| HasBuilt := true; | ||
| end; | ||
| exit(Rec.Find(Which)); | ||
| end; | ||
|
|
||
| trigger OnNextRecord(Steps: Integer): Integer | ||
| begin | ||
| exit(Rec.Next(Steps)); | ||
| end; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.