From 1961320bedeb6fd04cd47d99a489293c11031584 Mon Sep 17 00:00:00 2001 From: Hans Dahle Date: Mon, 2 Dec 2024 16:28:23 +0100 Subject: [PATCH] fix: Direct requests assigned to incorrect org unit (#729) - [x] New feature - [x] Bug fix - [ ] High impact **Description of work:** After change to the departments for managers all direct requests are now added to incorrect org unit. This means the manager of the inteded manager is now getting notifications about requests. **Testing:** - [ ] Can be tested - [ ] Automatic tests created / updated - [ ] Local tests are passing TBD **Checklist:** - [ ] Considered automated tests - [ ] Considered updating specification / documentation - [ ] Considered work items - [ ] Considered security - [ ] Performed developer testing - [ ] Checklist finalized / ready for review Hotfix, needed as we keep generating error in prod. --- .../ApiModels/ApiPersonAllocationRequestStatus.cs | 12 ++++++++++++ .../Controllers/Person/PersonController.cs | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Person/ApiModels/ApiPersonAllocationRequestStatus.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Person/ApiModels/ApiPersonAllocationRequestStatus.cs index 32b6319ebe..24c3c60580 100644 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Person/ApiModels/ApiPersonAllocationRequestStatus.cs +++ b/src/backend/api/Fusion.Resources.Api/Controllers/Person/ApiModels/ApiPersonAllocationRequestStatus.cs @@ -2,7 +2,19 @@ { public class ApiPersonAllocationRequestStatus { + /// + /// Should the request be auto approved? + /// public bool AutoApproval { get; set; } + + /// + /// Applicable manager for the user. This is based on who is set as manager in Entra ID. + /// public ApiPerson? Manager { get; set; } + + /// + /// The relevant org unit requests should be assigned to. + /// + public Services.LineOrg.ApiModels.ApiOrgUnit? RequestOrgUnit { get; set; } } } \ No newline at end of file diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Person/PersonController.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Person/PersonController.cs index 4753d1665b..375f992428 100644 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Person/PersonController.cs +++ b/src/backend/api/Fusion.Resources.Api/Controllers/Person/PersonController.cs @@ -15,6 +15,7 @@ using Fusion.AspNetCore.OData; using Microsoft.VisualBasic; using NodaTime.TimeZones; +using Fusion.Services.LineOrg.ApiModels; namespace Fusion.Resources.Api.Controllers { @@ -327,10 +328,13 @@ public async Task> GetPersonReque var autoApproval = await DispatchAsync(new Domain.Queries.GetPersonAutoApprovalStatus(user.azureId)); var manager = await DispatchAsync(new Domain.Queries.GetResourceOwner(user.azureId)); + var orgUnit = await DispatchAsync(new ResolveLineOrgUnit(user.fullDepartment)); + return new ApiPersonAllocationRequestStatus { AutoApproval = autoApproval.GetValueOrDefault(false), - Manager = manager is not null ? new ApiPerson(manager) : null + Manager = manager is not null ? new ApiPerson(manager) : null, + RequestOrgUnit = orgUnit }; }