Update expense VAT specification source - #10312
Merged
Alexander Yakunin (Alexander-Ya) merged 40 commits intoAug 31, 2026
Merged
Update expense VAT specification source#10312Alexander Yakunin (Alexander-Ya) merged 40 commits into
Alexander Yakunin (Alexander-Ya) merged 40 commits into
Conversation
Alexander Yakunin (Alexander-Ya)
temporarily deployed
to
triage
August 17, 2026 16:33 — with
GitHub Actions
Inactive
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
…Update-Expense-VAT-Specification-Source
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
MonicaPAhuja
approved these changes
Aug 30, 2026
Bardur Knudsen (BardurKnudsen)
approved these changes
Aug 30, 2026
Rishukla90
approved these changes
Aug 30, 2026
Joshua (mynjj)
approved these changes
Aug 30, 2026
Joshua (mynjj)
left a comment
Contributor
There was a problem hiding this comment.
Consider hardening the upgrade
Sun Haoran (haoranpb)
approved these changes
Aug 31, 2026
Alexander Yakunin (Alexander-Ya)
deleted the
bugs/Update-Expense-VAT-Specification-Source
branch
August 31, 2026 07:40
Alexander Yakunin (Alexander-Ya)
added a commit
that referenced
this pull request
Sep 1, 2026
This pull request backports #10312 to releases/29.x Fixes [AB#648452](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/648452) --------- Co-authored-by: Claudiu Ciumedean <cciumedean@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI
pushed a commit
that referenced
this pull request
Sep 2, 2026
This pull request introduces several important changes to the Expense Agent application, focusing on enforcing stricter controls over the creation and modification of VAT specification records, improving data integrity, and enhancing error handling and reporting. The changes ensure that records created via the Expense Agent API are clearly distinguished and protected from modification, and that error messages during expense report posting are more informative and actionable. **Key changes include:** * Added logic to set the `Source` field to `Agent` when VAT specifications are created via the API, and to `Manual` when created through the UI. This distinction is enforced in both the API and page triggers (`OnNewRecord`, `OnInsertRecord`). [[1]](diffhunk://#diff-bb08e5737d916802a07fe0b53c9e007bba3dcd3849e39a1b1c998b9adf10c672R108-R131) [[2]](diffhunk://#diff-9262d4cc9dead274e2f614199b52dab823f01302d8cb8886ef3d593db9924ffbR69-R74) * Made the `Source` field non-editable and added system metadata classification in the `Expense VAT Specification` table. * Added validation logic throughout the `Expense VAT Specification` table to skip certain field validations and calculations if the `Source` is `Agent`, ensuring agent-created records are handled differently from manual entries. [[1]](diffhunk://#diff-975ae126b7573570554253f501e44ef04cc551aae729dffb01d849f6ef47e0e4R37-R43) [[2]](diffhunk://#diff-975ae126b7573570554253f501e44ef04cc551aae729dffb01d849f6ef47e0e4R62-R70) [[3]](diffhunk://#diff-975ae126b7573570554253f501e44ef04cc551aae729dffb01d849f6ef47e0e4R98) [[4]](diffhunk://#diff-975ae126b7573570554253f501e44ef04cc551aae729dffb01d849f6ef47e0e4R159-R170) [[5]](diffhunk://#diff-975ae126b7573570554253f501e44ef04cc551aae729dffb01d849f6ef47e0e4R182) [[6]](diffhunk://#diff-975ae126b7573570554253f501e44ef04cc551aae729dffb01d849f6ef47e0e4R193) [[7]](diffhunk://#diff-975ae126b7573570554253f501e44ef04cc551aae729dffb01d849f6ef47e0e4R206-R208) * Introduced triggers to block modifications and deletions of VAT specification records created by the Expense Agent API, with clear error messages. [[1]](diffhunk://#diff-975ae126b7573570554253f501e44ef04cc551aae729dffb01d849f6ef47e0e4R264-R281) [[2]](diffhunk://#diff-242f0f782d0eaacabf61a7043b9b871c54d90db8d36abd1a0d5e8cc53d4c2036R791) * Updated the `UpdateVATSpecification` procedure to prevent overwriting or deleting agent-created VAT specification lines, enforcing immutability for API-generated records. * Improved logic for generating VAT specification lines, ensuring that manual and agent-created lines are handled separately and that the correct `Source` is set during creation. [[1]](diffhunk://#diff-242f0f782d0eaacabf61a7043b9b871c54d90db8d36abd1a0d5e8cc53d4c2036L1334-R1347) [[2]](diffhunk://#diff-242f0f782d0eaacabf61a7043b9b871c54d90db8d36abd1a0d5e8cc53d4c2036R1358-R1375) * Ensured that the correct category and subcategory fields are validated and set only for manual entries, not for agent-created lines. [[1]](diffhunk://#diff-975ae126b7573570554253f501e44ef04cc551aae729dffb01d849f6ef47e0e4R37-R43) [[2]](diffhunk://#diff-975ae126b7573570554253f501e44ef04cc551aae729dffb01d849f6ef47e0e4R182) [[3]](diffhunk://#diff-975ae126b7573570554253f501e44ef04cc551aae729dffb01d849f6ef47e0e4R206-R208) * Improved error reporting during expense report posting by introducing more specific error messages and navigation actions when VAT reclaim status is pending, making it easier for users to resolve issues. [[1]](diffhunk://#diff-8e8ca750ce38e56ef3c6273fd62f5334be1c20ab032f988c1e7db28b32b8e642R74-R76) [[2]](diffhunk://#diff-8e8ca750ce38e56ef3c6273fd62f5334be1c20ab032f988c1e7db28b32b8e642L247-R267) * Added a helper procedure to generate detailed `ErrorInfo` objects for pending VAT reclaim statuses, including navigation actions for user convenience. * Ensured that string values (e.g., `Expense Location`) are properly truncated to fit field length constraints, preventing data errors. * When creating expense report lines from VAT specs, now copies currency code and factor from the expense, and updates reimbursement amounts for accuracy. [[1]](diffhunk://#diff-f396a74c30e7dd3192138ba8ce28f30e32d62301e595bf6475d527b52dae60e7R330-R331) [[2]](diffhunk://#diff-f396a74c30e7dd3192138ba8ce28f30e32d62301e595bf6475d527b52dae60e7R345) * Adjusted rounding difference logic to handle both amount and local currency amount, improving accuracy in posting. [[1]](diffhunk://#diff-8e8ca750ce38e56ef3c6273fd62f5334be1c20ab032f988c1e7db28b32b8e642L431-R448) [[2]](diffhunk://#diff-8e8ca750ce38e56ef3c6273fd62f5334be1c20ab032f988c1e7db28b32b8e642L474-R495) These changes collectively improve the robustness, security, and usability of the Expense Agent's VAT specification handling and expense report posting workflows.<!-- Thanks for contributing to BCApps! A few things before you hit "Create pull request": - Your PR must link to an approved issue. New here? See CONTRIBUTING.md. - You must have built and run your change yourself. CI is a safety net, not a substitute. - If you used AI or an agent to write this PR, you are still the author. Read the diff, build it, and try it before requesting review. Contributing guide: https://github.com/microsoft/BCApps/blob/main/CONTRIBUTING.md Local dev environment: https://github.com/microsoft/BCApps/blob/main/LOCAL_DEV_ENV.md --> <!-- A few sentences: what does this change do, and what problem does it solve? --> <!-- Required: link an approved GitHub issue using "Fixes #<number>". Microsoft contributors: also link the ADO work item with "AB#<number>" if you have one. --> Fixes [AB#626087](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/626087) - [x] I read the full diff and it contains only changes I intended. - [x] I built the affected app(s) locally with no new analyzer warnings. - [x] I ran the change in Business Central and confirmed it behaves as expected. - [x] I added or updated tests for the new behavior, or explained below why none are needed. **What I tested and the outcome** *(required — be specific: scenarios, commands, screenshots for UI changes)* <!-- Example: - Ran the new "Post and Send" action on a sales invoice in a fresh container; document posted and email queued (see screenshot). - New unit tests in MyFeatureTest.Codeunit.al pass locally; full module test suite green. - No tests added because change is comment-only / refactor with existing coverage. --> <!-- Anything reviewers should watch for: breaking changes, upgrade/data impact, permissions, telemetry, feature flags, follow-up work. Write "None" if there's nothing to call out. --> --------- Co-authored-by: Claudiu Ciumedean <cciumedean@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit aebad9c) Co-authored-by: Alexander-Ya <179119309+Alexander-Ya@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces several important changes to the Expense Agent application, focusing on enforcing stricter controls over the creation and modification of VAT specification records, improving data integrity, and enhancing error handling and reporting. The changes ensure that records created via the Expense Agent API are clearly distinguished and protected from modification, and that error messages during expense report posting are more informative and actionable.
Key changes include:
1. Enforcing Source-based Controls and Data Integrity
Sourcefield toAgentwhen VAT specifications are created via the API, and toManualwhen created through the UI. This distinction is enforced in both the API and page triggers (OnNewRecord,OnInsertRecord). [1] [2]Sourcefield non-editable and added system metadata classification in theExpense VAT Specificationtable.Expense VAT Specificationtable to skip certain field validations and calculations if theSourceisAgent, ensuring agent-created records are handled differently from manual entries. [1] [2] [3] [4] [5] [6] [7]2. Preventing Unauthorized Modifications
UpdateVATSpecificationprocedure to prevent overwriting or deleting agent-created VAT specification lines, enforcing immutability for API-generated records.3. Expense VAT Specification Generation and Categorization
Sourceis set during creation. [1] [2]4. Enhanced Error Handling and User Feedback
ErrorInfoobjects for pending VAT reclaim statuses, including navigation actions for user convenience.5. Miscellaneous Improvements
Expense Location) are properly truncated to fit field length constraints, preventing data errors.These changes collectively improve the robustness, security, and usability of the Expense Agent's VAT specification handling and expense report posting workflows.<!--
Thanks for contributing to BCApps!
A few things before you hit "Create pull request":
build it, and try it before requesting review.
Contributing guide: https://github.com/microsoft/BCApps/blob/main/CONTRIBUTING.md
Local dev environment: https://github.com/microsoft/BCApps/blob/main/LOCAL_DEV_ENV.md
-->
What & why
Linked work
Fixes AB#626087
How I validated this
What I tested and the outcome (required — be specific: scenarios, commands, screenshots for UI changes)
Risk & compatibility