Skip to content

Commit

Permalink
Merge pull request #998 from bcgov/feature/AB#26991-DefaultSite
Browse files Browse the repository at this point in the history
Feature/ab#26991 default site
  • Loading branch information
samsaravillo authored Jan 20, 2025
2 parents d9407fd + c4510b0 commit 6afcf40
Show file tree
Hide file tree
Showing 33 changed files with 7,207 additions and 336 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ The codebase is being roughed out, but finer details are likely to change.
├── Unity.ApplicantPortal/ - Applicant Information solution
├── Unity.AutoUI/ - Automated User Interface testing
├── Unity.GrantManager/ - Grant manager and adjudication solution
├── Unity.Orchestrator/ - Workflow orchestrator solution
├── Unity.RabbitMQ/ - Messaging and streaming broker configuration
├── Unity.Tools/ - DevOps tools
database/ - Database configuration files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class CreatePaymentRequestDto
public string PayeeName { get; set; }
public string ContractNumber { get; set; }
public string SupplierNumber { get; set; }
public string SupplierName { get; set; }
public string CorrelationProvider { get; set; } = string.Empty;
public string BatchName { get; set; }
public decimal BatchNumber { get; set; } = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public class PaymentRequestDto : AuditedEntityDto<Guid>
public string PayeeName { get; set; }
public string ContractNumber { get; set; }
public string SupplierNumber { get; set; }
public string CorrelationProvider { get; set; } = string.Empty;
public string SupplierName { get; set; } = string.Empty;
public string CorrelationProvider { get; set; } = string.Empty;
public string? CasResponse { get; set; }
public string BatchName { get; set; }
public decimal BatchNumber { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ public class SiteDto : AuditedEntityDto<Guid>
public string? ProviderId { get; set; }
public string? Status { get; set; }
public string? SiteProtected { get; set; }
public string? BankAccount { get; set; }
public DateTime? LastUpdatedInCas { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
using System;
namespace Unity.Payments.Suppliers;

[Serializable]
public class SiteEto
{
public string SupplierSiteCode { get; set; } = null!;
public string? AddressLine1 { get; set; }
public string? AddressLine2 { get; set; }
public string? AddressLine3 { get; set; }
public string? City { get; set; }
public string? Province { get; set; }
public string? Country { get; set; }
public string? PostalCode { get; set; }
public string? EmailAddress { get; set; }
public string? EFTAdvicePref { get; set; }
public string? ProviderId { get; set; }
public string? Status { get; set; }
public string? SiteProtected { get; set; }
using System;
namespace Unity.Payments.Suppliers;

[Serializable]
public class SiteEto
{
public Guid Id { get; set; } = Guid.Empty;
public string SupplierSiteCode { get; set; } = null!;
public string? AddressLine1 { get; set; }
public string? AddressLine2 { get; set; }
public string? AddressLine3 { get; set; }
public string? City { get; set; }
public string? Province { get; set; }
public string? Country { get; set; }
public string? PostalCode { get; set; }
public string? EmailAddress { get; set; }
public string? EFTAdvicePref { get; set; }
public string? BankAccount { get; set; }
public string? ProviderId { get; set; }
public string? Status { get; set; }
public string? SiteProtected { get; set; }
public DateTime? LastUpdated { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public virtual Site Site
// Payee Info
public virtual string PayeeName { get; private set; } = string.Empty;
public virtual string ContractNumber { get; private set; } = string.Empty;
public virtual string? SupplierName { get; private set; } = string.Empty;
public virtual string SupplierNumber { get; private set; } = string.Empty;
public virtual string RequesterName { get; private set; } = string.Empty;
public virtual string BatchName { get; private set; } = string.Empty;
Expand Down Expand Up @@ -86,6 +87,7 @@ public PaymentRequest(Guid id, CreatePaymentRequestDto createPaymentRequestDto)
PayeeName = createPaymentRequestDto.PayeeName;
ContractNumber = createPaymentRequestDto.ContractNumber;
SupplierNumber = createPaymentRequestDto.SupplierNumber;
SupplierName = createPaymentRequestDto.SupplierName;
SiteId = createPaymentRequestDto.SiteId;
Description = createPaymentRequestDto.Description;
CorrelationId = createPaymentRequestDto.CorrelationId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
using System;
using Unity.Payments.Domain.Suppliers.ValueObjects;
using Unity.Payments.Enums;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace Unity.Payments.Domain.Suppliers
{
public class Site : FullAuditedEntity<Guid>, IMultiTenant
{
public Guid? TenantId { get; set; }
public virtual string Number { get; set; } = string.Empty;
public virtual PaymentGroup PaymentGroup { get; set; }

/* Address */
public virtual string? AddressLine1 { get; set; }
public virtual string? AddressLine2 { get; set; }
public virtual string? AddressLine3 { get; set; }
public virtual string? City { get; set; }
public virtual string? Province { get; set; }
using System;
using Unity.Payments.Domain.Suppliers.ValueObjects;
using Unity.Payments.Enums;
using Unity.Payments.Suppliers;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace Unity.Payments.Domain.Suppliers
{
public class Site : FullAuditedEntity<Guid>, IMultiTenant
{
public Guid? TenantId { get; set; }
public virtual string Number { get; set; } = string.Empty;
public virtual PaymentGroup PaymentGroup { get; set; }

/* Address */
public virtual string? AddressLine1 { get; set; }
public virtual string? AddressLine2 { get; set; }
public virtual string? AddressLine3 { get; set; }
public virtual string? City { get; set; }
public virtual string? Province { get; set; }
public virtual string? PostalCode { get; set; }
public virtual string? Country { get; set; }

/* CAS Information */
public virtual string? EmailAddress { get; set; }
public virtual string? EFTAdvicePref { get; set; }
public virtual string? BankAccount { get; set; }
public virtual string? ProviderId { get; set; }
public virtual string? Status { get; set; }
public virtual string? SiteProtected { get; set; }
public DateTime? LastUpdatedInCas { get; set; }

/* Supplier */
public virtual Supplier? Supplier { get; set; }
public virtual Guid SupplierId { get; set; }

protected Site()
{
/* This constructor is for ORMs to be used while getting the entity from the database. */
public DateTime? LastUpdatedInCas { get; set; }

/* Supplier */
public virtual Supplier? Supplier { get; set; }
public virtual Guid SupplierId { get; set; }

protected Site()
{
/* This constructor is for ORMs to be used while getting the entity from the database. */
}

public Site(Guid id,
Expand All @@ -46,68 +48,59 @@ public Site(Guid id,
{
Number = number;
PaymentGroup = paymentMethod;
AddressLine1 = address?.AddressLine1;
AddressLine2 = address?.AddressLine2;
AddressLine3 = address?.AddressLine3;
Country = address?.Country;
City = address?.City;
Province = address?.Province;
AddressLine1 = address?.AddressLine1;
AddressLine2 = address?.AddressLine2;
AddressLine3 = address?.AddressLine3;
Country = address?.Country;
City = address?.City;
Province = address?.Province;
PostalCode = address?.PostalCode;
}

public Site(
string number,
PaymentGroup paymentMethod,
string? emailAddress = default,
string? etfAdvise = default,
string? providerId = default,
string? status = default,
string? siteProtected = default,
Address? address = default,
Guid supplierId = default,
DateTime? lastUpdatedInCas = default)
{
Number = number;
SupplierId = supplierId;
EmailAddress = emailAddress;
EFTAdvicePref = etfAdvise;
ProviderId = providerId;
Status = status;
SiteProtected = siteProtected;
PaymentGroup = paymentMethod;
AddressLine1 = address?.AddressLine1;
AddressLine2 = address?.AddressLine2;
AddressLine3 = address?.AddressLine3;
Country = address?.Country;
City = address?.City;
Province = address?.Province;
PostalCode = address?.PostalCode;
LastUpdatedInCas = lastUpdatedInCas;
}

public void SetNumber(string number)
{
Number = number;
}

public void SetPaymentGroup(PaymentGroup paymentGroup)
{
PaymentGroup = paymentGroup;
}

public void SetAddress(string? addressLine1,
string? addressLine2,
string? addressLine3,
string? city,
string? province,
string? postalCode)
{
AddressLine1 = addressLine1;
AddressLine2 = addressLine2;
AddressLine3 = addressLine3;
City = city;
Province = province;
PostalCode = postalCode;
}
}
}

public Site(SiteDto siteDto)
{
Number = siteDto.Number;
SupplierId = siteDto.SupplierId;
EmailAddress = siteDto.EmailAddress;
EFTAdvicePref = siteDto.EFTAdvicePref;
BankAccount = siteDto.BankAccount;
ProviderId = siteDto.ProviderId;
Status = siteDto.Status;
SiteProtected = siteDto.SiteProtected;
PaymentGroup = siteDto.PaymentGroup;
AddressLine1 = siteDto.AddressLine1;
AddressLine2 = siteDto?.AddressLine2;
AddressLine3 = siteDto?.AddressLine3;
Country = siteDto?.Country;
City = siteDto?.City;
Province = siteDto?.Province;
PostalCode = siteDto?.PostalCode;
LastUpdatedInCas = siteDto?.LastUpdatedInCas;
}

public void SetNumber(string number)
{
Number = number;
}

public void SetPaymentGroup(PaymentGroup paymentGroup)
{
PaymentGroup = paymentGroup;
}

public void SetAddress(string? addressLine1,
string? addressLine2,
string? addressLine3,
string? city,
string? province,
string? postalCode)
{
AddressLine1 = addressLine1;
AddressLine2 = addressLine2;
AddressLine3 = addressLine3;
City = city;
Province = province;
PostalCode = postalCode;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Unity.Payments.Codes;
using Unity.Payments.Domain.PaymentRequests;
using Unity.Payments.EntityFrameworkCore;
using Unity.Payments.Enums;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;

Expand Down Expand Up @@ -45,8 +46,7 @@ public async Task<decimal> GetTotalPaymentRequestAmountByCorrelationIdAsync(Guid
var dbSet = await GetDbSetAsync();
decimal applicationPaymentRequestsTotal = dbSet
.Where(p => p.CorrelationId.Equals(correlationId))
// Need to define a where clause on the Status
// Don't include declined - right now we don't know how to set status
.Where(p => p.Status != PaymentRequestStatus.L1Declined && p.Status != PaymentRequestStatus.L2Declined && p.Status != PaymentRequestStatus.L3Declined)
.GroupBy(p => p.CorrelationId)
.Select(p => p.Sum(q => q.Amount))
.FirstOrDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Unity.Payments.Events
[Serializable]
public class ApplicantSupplierEto
{
public Guid? SiteId { get; set; }
public Guid SupplierId { get; set; }
public Guid ApplicantId { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.Payments.Domain.Suppliers;
using Unity.Payments.Events;
using Unity.Payments.Suppliers;
using Volo.Abp.DependencyInjection;
Expand Down Expand Up @@ -31,7 +33,7 @@ await localEventBus.PublishAsync(
private async Task<SupplierDto> GetSupplierFromEvent(UpsertSupplierEto eventData) {
var existing = await supplierAppService.GetBySupplierNumberAsync(eventData.Number);

// This is subject to some business rules and a domain implmentation
// This is subject to some business rules and a domain implementation
if (existing != null)
{
existing.Number = eventData.Number;
Expand All @@ -54,9 +56,6 @@ private async Task<SupplierDto> GetSupplierFromEvent(UpsertSupplierEto eventData
City = existing.City,
});

// Delete the current sites
await siteAppService.DeleteBySupplierIdAsync(updatedSupplierDto.Id);

return updatedSupplierDto;
}

Expand All @@ -80,6 +79,18 @@ private async Task<SupplierDto> GetSupplierFromEvent(UpsertSupplierEto eventData

protected virtual async Task InsertSitesFromEventDtoAsync(Guid supplierId, UpsertSupplierEto upsertSupplierEto)
{
// If sites are being inserted from a lookup then potentially the CAS data has brought back different data
// Did any sites already exist for the current supplier?
List<Site>? existingSites = await siteAppService.GetSitesBySupplierIdAsync(supplierId);
if(existingSites != null && existingSites.Count > 0)
{
// Where any defaulted in the applicants?
// If so then we need - re-associate ? or delete the existing site from the applicant?

// Delete the current sites
await siteAppService.DeleteBySupplierIdAsync(supplierId);
}

foreach(SiteEto siteEto in upsertSupplierEto.SiteEtos)
{
SiteDto siteDto = new()
Expand All @@ -96,6 +107,7 @@ protected virtual async Task InsertSitesFromEventDtoAsync(Guid supplierId, Upser
Country = siteEto.Country,
EmailAddress = siteEto.EmailAddress,
EFTAdvicePref = siteEto.EFTAdvicePref,
BankAccount = siteEto.BankAccount,
ProviderId = siteEto.ProviderId,
Status = siteEto.Status,
SiteProtected = siteEto.SiteProtected,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Unity.Payments.Domain.Suppliers;

namespace Unity.Payments.Suppliers
{
public interface ISiteAppService : IApplicationService
{
Task<SiteDto> GetAsync(Guid id);

Task InsertAsync(SiteDto siteDto);
Task<Guid> InsertAsync(SiteDto siteDto);

Task DeleteBySupplierIdAsync(Guid supplierId);
Task<List<Site>> GetSitesBySupplierIdAsync(Guid supplierId);
}
}
Loading

0 comments on commit 6afcf40

Please sign in to comment.