Skip to content

Commit b6309f9

Browse files
authored
Merge pull request #1487 from bcgov/dev
Dev
2 parents db036fe + 6088f47 commit b6309f9

87 files changed

Lines changed: 9913 additions & 4606 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Application/Domain/Services/WorksheetsManager.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,13 @@ private async Task<WorksheetInstance> CreateNewWorksheetInstanceAsync(IWorksheet
179179

180180
if (worksheet != null)
181181
{
182-
var worksheetLink = await worksheetLinkRepository.GetExistingLinkAsync(worksheet.Id, eventData.SheetCorrelationId, eventData.SheetCorrelationProvider);
182+
var worksheetLink = await worksheetLinkRepository.GetExistingLinkAsync(worksheet.Id,
183+
eventData.SheetCorrelationId,
184+
eventData.SheetCorrelationProvider);
183185

184-
if (worksheetLink != null)
186+
// Make sure we do not create an instance if it already exists
187+
if (worksheetLink != null
188+
&& !(await WorksheetInstanceAlreadyExists(worksheet.Id, eventData, worksheetLink.UiAnchor)))
185189
{
186190
var newInstance = new WorksheetInstance(Guid.NewGuid(),
187191
worksheet.Id,
@@ -210,6 +214,18 @@ private async Task<WorksheetInstance> CreateNewWorksheetInstanceAsync(IWorksheet
210214
return newWorksheetInstances;
211215
}
212216

217+
private async Task<bool> WorksheetInstanceAlreadyExists(Guid worksheetId,
218+
CreateWorksheetInstanceByFieldValuesEto eventData,
219+
string uiAnchor)
220+
{
221+
return await worksheetInstanceRepository.ExistsAsync(worksheetId,
222+
eventData.InstanceCorrelationId,
223+
eventData.InstanceCorrelationProvider,
224+
eventData.SheetCorrelationId,
225+
eventData.SheetCorrelationProvider,
226+
uiAnchor);
227+
}
228+
213229
public async Task<Worksheet> CloneWorksheetAsync(Guid id)
214230
{
215231
var worksheet = await worksheetRepository.GetAsync(id, true);

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Application/Domain/WorksheetInstances/IWorksheetInstanceRepository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ public interface IWorksheetInstanceRepository : IBasicRepository<WorksheetInstan
1111
Task<WorksheetInstance?> GetByCorrelationAnchorAsync(Guid correlationId, string correlationProvider, string uiAnchor, bool includeDetails);
1212
Task<List<WorksheetInstance>> GetByWorksheetCorrelationAsync(Guid worksheetId, string uiAnchor, Guid worksheetCorrelationId, string worksheetCorrelationProvider);
1313
Task<WorksheetInstance?> GetWithValuesAsync(Guid worksheetInstanceId);
14+
Task<bool> ExistsAsync(Guid worksheetId, Guid instanceCorrelationId, string instanceCorrelationProvider, Guid sheetCorrelationId, string sheetCorrelationProvider, string? uiAnchor);
1415
}
1516
}

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Application/EntityFrameworkCore/Repositories/WorksheetInstanceRepository.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,23 @@ public async Task<List<WorksheetInstance>> GetByWorksheetCorrelationAsync(Guid w
6262
.Include(wi => wi.Values)
6363
.FirstOrDefaultAsync(wi => wi.Id == worksheetInstanceId);
6464
}
65+
66+
public async Task<bool> ExistsAsync(Guid worksheetId,
67+
Guid instanceCorrelationId,
68+
string instanceCorrelationProvider,
69+
Guid sheetCorrelationId,
70+
string sheetCorrelationProvider,
71+
string? uiAnchor)
72+
{
73+
var dbSet = await GetDbSetAsync();
74+
75+
return await dbSet
76+
.AnyAsync(s => s.WorksheetId == worksheetId
77+
&& s.CorrelationId == instanceCorrelationId
78+
&& s.CorrelationProvider == instanceCorrelationProvider
79+
&& s.WorksheetCorrelationId == sheetCorrelationId
80+
&& s.WorksheetCorrelationProvider == sheetCorrelationProvider
81+
&& s.UiAnchor == uiAnchor);
82+
}
6583
}
6684
}

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Application/Handlers/CreateWorksheetInstanceByFieldValuesHandler.cs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,44 @@
99
using Unity.Flex.Worksheets.Collectors;
1010
using Volo.Abp.DependencyInjection;
1111
using Volo.Abp.EventBus;
12+
using Volo.Abp.MultiTenancy;
1213

1314
namespace Unity.Flex.Handlers
1415
{
15-
public class CreateWorksheetInstanceByFieldValuesHandler(WorksheetsManager worksheetsManager, IServiceProvider serviceProvider) : ILocalEventHandler<CreateWorksheetInstanceByFieldValuesEto>, ITransientDependency
16+
/// <summary>
17+
/// Handles creating worksheet instances from field values.
18+
///
19+
/// Tenant context handling:
20+
/// - If the request comes through a route with {__tenant} parameter, ABP automatically sets the tenant context
21+
/// - If the request is processed via an ABP background job, tenant context is preserved automatically
22+
/// - If TenantId is explicitly set on the CreateWorksheetInstanceByFieldValuesEto, it will be used when current tenant is null
23+
/// </summary>
24+
public class CreateWorksheetInstanceByFieldValuesHandler(WorksheetsManager worksheetsManager,
25+
IServiceProvider serviceProvider,
26+
ICurrentTenant currentTenant)
27+
: ILocalEventHandler<CreateWorksheetInstanceByFieldValuesEto>, ITransientDependency
1628
{
1729
public async Task HandleEventAsync(CreateWorksheetInstanceByFieldValuesEto eventData)
1830
{
19-
List<(Worksheet worksheet, WorksheetInstance worksheetIntance)> workSheetInstancePairs = await worksheetsManager.CreateWorksheetDataByFields(eventData);
31+
// If current tenant is null but eventData provides a TenantId, use it
32+
if (currentTenant.Id == null && eventData.TenantId.HasValue)
33+
{
34+
using (currentTenant.Change(eventData.TenantId))
35+
{
36+
await ProcessWorksheetInstancesAsync(eventData);
37+
}
38+
}
39+
else
40+
{
41+
// Continue with current tenant context (could be null/host or already set)
42+
await ProcessWorksheetInstancesAsync(eventData);
43+
}
44+
}
45+
46+
private async Task ProcessWorksheetInstancesAsync(CreateWorksheetInstanceByFieldValuesEto eventData)
47+
{
48+
List<(Worksheet worksheet, WorksheetInstance worksheetIntance)> workSheetInstancePairs =
49+
await worksheetsManager.CreateWorksheetDataByFields(eventData);
2050

2151
foreach (var (worksheet, worksheetIntance) in workSheetInstancePairs.Where(s => s.worksheet.RequiresCollection()))
2252
{

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Shared/Worksheets/Events/CreateWorksheetInstanceByFieldValuesEto.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ public class CreateWorksheetInstanceByFieldValuesEto
1313
public List<(string fieldName, string chefsPropertyName, object? value)> CustomFields { get; set; } = [];
1414
public Guid? VersionId { get; set; }
1515
public string? VersionData { get; set; }
16+
public Guid? TenantId { get; set; }
1617
}
1718
}

applications/Unity.GrantManager/modules/Unity.Payments/src/Unity.Payments.Application.Contracts/Enums/PaymentGroup.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
public enum PaymentGroup
44
{
55
EFT = 1,
6-
Cheque = 2,
7-
GLP = 3
6+
Cheque = 2
87
}
98
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Volo.Abp.Application.Dtos;
4+
5+
namespace Unity.Payments.PaymentTags;
6+
7+
[Serializable]
8+
public class AssignPaymentTagDto : AuditedEntityDto<Guid>
9+
{
10+
public Guid PaymentRequestId { get; set; }
11+
public List<GlobalTagDto>? Tags { get; set; }
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using Volo.Abp.Application.Dtos;
3+
4+
namespace Unity.Payments.PaymentTags
5+
{
6+
[Serializable]
7+
public class GlobalTagDto : EntityDto<Guid>
8+
{
9+
public string Name { get; set; } = string.Empty;
10+
}
11+
}
12+

applications/Unity.GrantManager/modules/Unity.Payments/src/Unity.Payments.Application.Contracts/PaymentTags/IPaymentTagAppService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ public interface IPaymentTagAppService : IApplicationService
1010
{
1111
Task<IList<PaymentTagDto>> GetListAsync();
1212
Task<IList<PaymentTagDto>> GetListWithPaymentRequestIdsAsync(List<Guid> ids);
13-
Task<PaymentTagDto> CreateorUpdateTagsAsync(Guid id, PaymentTagDto input);
13+
Task<List<PaymentTagDto>> AssignTagsAsync(AssignPaymentTagDto input);
1414
Task<PaymentTagDto?> GetPaymentTagsAsync(Guid id);
1515

1616
Task<PagedResultDto<TagSummaryCountDto>> GetTagSummaryAsync();
17-
Task<int> GetMaxRenameLengthAsync(string originalTag);
1817
Task<List<Guid>> RenameTagAsync(string originalTag, string replacementTag);
19-
Task DeleteTagAsync(string deleteTag);
18+
Task DeleteTagAsync(Guid id);
19+
Task DeleteTagWithTagIdAsync(Guid tagId);
2020
}
2121
}

applications/Unity.GrantManager/modules/Unity.Payments/src/Unity.Payments.Application.Contracts/PaymentTags/PaymentTagDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ namespace Unity.Payments.PaymentTags;
77
public class PaymentTagDto : AuditedEntityDto<Guid>
88
{
99
public Guid PaymentRequestId { get; set; }
10-
public string Text { get; set; } = string.Empty;
10+
public GlobalTagDto? Tag { get; set; }
1111
}

0 commit comments

Comments
 (0)