-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbcfc20
commit 8c182c7
Showing
18 changed files
with
5,573 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
31 changes: 31 additions & 0 deletions
31
...Features/ManagementInformation/IntegrationEventHandlers/RecordPreReleaseSupportPayment.cs
This file contains 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,31 @@ | ||
using Cfo.Cats.Application.Features.PRIs.IntegrationEvents; | ||
using MassTransit; | ||
|
||
namespace Cfo.Cats.Application.Features.ManagementInformation.IntegrationEventHandlers; | ||
|
||
public class RecordPreReleaseSupportPayment(IUnitOfWork unitOfWork) : IConsumer<PRIAssignedIntegrationEvent> | ||
{ | ||
private static class IneligibilityReasons | ||
{ | ||
public const string AlreadyPaid = "A wing induction has already been claimed under this contract"; | ||
public const string NotYetApproved = "The enrolment for this participant has not yet been approved"; | ||
public const string BeforeConsent = "This occurred before the consent date"; | ||
} | ||
|
||
public async Task Consume(ConsumeContext<PRIAssignedIntegrationEvent> context) | ||
{ | ||
var db = unitOfWork.DbContext; | ||
|
||
var query = from pri in db.PRIs | ||
join u in db.Users on pri.CreatedBy equals u.Id | ||
where pri.Id == context.Message.PRIId | ||
select new | ||
{ | ||
pri.Id, | ||
pri.ParticipantId | ||
}; | ||
|
||
await Task.CompletedTask; | ||
|
||
} | ||
} |
This file contains 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
This file contains 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
14 changes: 14 additions & 0 deletions
14
src/Application/Features/PRIs/EventHandlers/RaisePRIAssignedIntegrationEvent.cs
This file contains 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,14 @@ | ||
using Cfo.Cats.Application.Features.PRIs.IntegrationEvents; | ||
using Cfo.Cats.Application.Outbox; | ||
using Cfo.Cats.Domain.Events; | ||
|
||
namespace Cfo.Cats.Application.Features.PRIs.EventHandlers; | ||
|
||
public class RaisePRIAssignedIntegrationEvent(IUnitOfWork unitOfWork) : INotificationHandler<PRIAssignedDomainEvent> | ||
{ | ||
public async Task Handle(PRIAssignedDomainEvent notification, CancellationToken cancellationToken) | ||
{ | ||
var @event = new PRIAssignedIntegrationEvent(notification.Item.Id, notification.DateOccurred.DateTime); | ||
await unitOfWork.DbContext.InsertOutboxMessage(@event); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/Application/Features/PRIs/IntegrationEvents/PRIAssignedIntegrationEvent.cs
This file contains 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,3 @@ | ||
namespace Cfo.Cats.Application.Features.PRIs.IntegrationEvents; | ||
|
||
public record PRIAssignedIntegrationEvent(Guid PRIId, DateTime OccurredOn); |
135 changes: 135 additions & 0 deletions
135
src/Domain/Entities/ManagementInformation/SupportAndReferralPayment.cs
This file contains 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,135 @@ | ||
using Cfo.Cats.Domain.Common.Enums; | ||
|
||
namespace Cfo.Cats.Domain.Entities.ManagementInformation; | ||
|
||
public class SupportAndReferralPayment | ||
{ | ||
#pragma warning disable CS8618 | ||
internal SupportAndReferralPayment() | ||
{ | ||
} | ||
|
||
#pragma warning restore CS8618 | ||
|
||
public Guid Id { get; set; } = Guid.CreateVersion7(); | ||
|
||
public Guid PriId { get; set; } | ||
|
||
public string SupportType { get; set; } | ||
|
||
public DateTime CreatedOn { get; set; } = DateTime.UtcNow; | ||
|
||
public DateTime Approved { get; set; } | ||
|
||
public string ParticipantId { get; set; } | ||
|
||
public string SupportWorker { get; set; } | ||
|
||
public string ContractId { get; set; } | ||
|
||
public int LocationId { get; set; } | ||
|
||
public string LocationType { get; set; } | ||
|
||
public string TenantId { get; set; } | ||
|
||
public bool EligibleForPayment { get; set; } | ||
|
||
public string? IneligibilityReason { get; set; } | ||
|
||
} | ||
|
||
public class SupportAndReferralBuilder | ||
{ | ||
private Guid? _priId; | ||
private string? _supportType; | ||
private string? _participantId; | ||
private string? _contractId; | ||
private DateTime? _approved; | ||
private int? _locationId; | ||
private string? _locationType; | ||
private string? _tenantId; | ||
private bool? _eligibleForPayment; | ||
private string? _ineligibilityReason; | ||
|
||
public SupportAndReferralBuilder WithPri(Guid priId) | ||
{ | ||
_priId = priId; | ||
return this; | ||
} | ||
|
||
public SupportAndReferralBuilder WithSupportType(string supportType) | ||
{ | ||
_supportType = supportType; | ||
return this; | ||
} | ||
|
||
public SupportAndReferralBuilder WithParticipantId(string participantId) | ||
{ | ||
_participantId = participantId; | ||
return this; | ||
} | ||
|
||
public SupportAndReferralBuilder WithContractId(string contractId) | ||
{ | ||
_contractId = contractId; | ||
return this; | ||
} | ||
|
||
public SupportAndReferralBuilder WithApproved(DateTime approved) | ||
{ | ||
_approved = approved; | ||
return this; | ||
} | ||
|
||
public SupportAndReferralBuilder WithLocationId(int locationId) | ||
{ | ||
_locationId = locationId; | ||
return this; | ||
} | ||
|
||
public SupportAndReferralBuilder WithLocationType(string locationType) | ||
{ | ||
_locationType = locationType; | ||
return this; | ||
} | ||
|
||
public SupportAndReferralBuilder WithTenantId(string tenantId) | ||
{ | ||
_tenantId = tenantId; | ||
return this; | ||
} | ||
|
||
public SupportAndReferralBuilder WithEligibleForPayment(bool eligibleForPayment) | ||
{ | ||
_eligibleForPayment = eligibleForPayment; | ||
return this; | ||
} | ||
|
||
public SupportAndReferralBuilder WithIneligibilityReason(string? ineligibilityReason) | ||
{ | ||
_ineligibilityReason = ineligibilityReason; | ||
return this; | ||
} | ||
|
||
public SupportAndReferralPayment Build() | ||
{ | ||
var payment = new SupportAndReferralPayment() | ||
{ | ||
PriId = _priId ?? throw new ApplicationException("PriId must be set before calling build"), | ||
Approved = _approved ?? throw new ApplicationException("Approved must be set before calling build"), | ||
SupportType = _supportType ?? throw new ApplicationException("SupportType must be set before calling build"), | ||
ContractId = _contractId ?? throw new ApplicationException("ContractId must be set before calling build"), | ||
EligibleForPayment = _eligibleForPayment ?? throw new ApplicationException("EligibleForPayment must be set before calling build"), | ||
IneligibilityReason = _eligibleForPayment == false && _ineligibilityReason == null | ||
? throw new ApplicationException("IneligibilityReason must be set before calling build") | ||
: _ineligibilityReason, | ||
LocationId = _locationId ?? throw new ApplicationException("LocationId must be set before calling build"), | ||
LocationType = _locationType ?? throw new ApplicationException("LocationType must be set before calling build"), | ||
ParticipantId = _participantId ?? throw new ApplicationException("ParticipantId must be set before calling build"), | ||
TenantId = _tenantId ?? throw new ApplicationException("TenantId must be set before calling build"), | ||
}; | ||
return payment; | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
61 changes: 61 additions & 0 deletions
61
.../Configurations/ManagementInformation/SupportAndReferralPaymentEntityTypeConfiguration.cs
This file contains 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,61 @@ | ||
using Cfo.Cats.Domain.Entities.ManagementInformation; | ||
using Cfo.Cats.Infrastructure.Constants.Database; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Cfo.Cats.Infrastructure.Persistence.Configurations.ManagementInformation; | ||
|
||
public class SupportAndReferralPaymentEntityTypeConfiguration | ||
: IEntityTypeConfiguration<SupportAndReferralPayment> | ||
{ | ||
public void Configure(EntityTypeBuilder<SupportAndReferralPayment> builder) | ||
{ | ||
builder.ToTable(nameof(SupportAndReferralPayment), DatabaseConstants.Schemas.Mi); | ||
|
||
builder.HasKey(x => x.Id); | ||
|
||
builder.Property(x => x.PriId) | ||
.IsRequired(); | ||
|
||
builder.Property(x => x.SupportType) | ||
.IsRequired() | ||
.HasMaxLength(20); | ||
|
||
builder.Property(x => x.CreatedOn) | ||
.IsRequired(); | ||
|
||
builder.Property(x => x.Approved) | ||
.IsRequired() | ||
.HasColumnType("date"); | ||
|
||
builder.Property(x => x.ContractId) | ||
.IsRequired() | ||
.HasMaxLength(12); | ||
|
||
builder.Property(x => x.LocationType) | ||
.IsRequired() | ||
.HasMaxLength(25); | ||
|
||
builder.Property(x => x.TenantId) | ||
.IsRequired() | ||
.HasMaxLength(DatabaseConstants.FieldLengths.TenantId); | ||
|
||
builder.Property(x => x.EligibleForPayment) | ||
.IsRequired(); | ||
|
||
builder.Property(x => x.IneligibilityReason) | ||
.HasMaxLength(250); | ||
|
||
builder.Property(x => x.ParticipantId) | ||
.IsRequired() | ||
.HasMaxLength(DatabaseConstants.FieldLengths.ParticipantId); | ||
|
||
builder.HasIndex(x => new { | ||
x.ParticipantId, | ||
x.ContractId, | ||
x.SupportType, | ||
x.Approved | ||
}) | ||
.HasDatabaseName("ix_ActivityPayment_ParticipantId"); | ||
|
||
} | ||
} |
This file contains 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
Oops, something went wrong.