Skip to content

Commit aed4e2f

Browse files
authored
Merge pull request #2081 from bcgov/feature/AB#31620-SentToFSB-LookupStatus
feature/AB#31620-SentToFSB
2 parents 48f1685 + 9b85676 commit aed4e2f

6 files changed

Lines changed: 54 additions & 15 deletions

File tree

applications/Unity.GrantManager/modules/Unity.Payments/src/Unity.Payments.Application.Contracts/Codes/CasPaymentRequestStatus.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public static class CasPaymentRequestStatus
44
{
55
// Unity Status
66
public const string SentToCas = "SentToCas";
7+
public const string SentToAccountsPayable = "SentToAccountsPayable";
78

89
// CAS INVOICE STATUS
910
public const string ErrorFromCas = "Error";

applications/Unity.GrantManager/modules/Unity.Payments/src/Unity.Payments.Application/Domain/Services/PaymentsManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Unity.Payments.Domain.Shared;
1010
using Unity.Payments.Domain.Workflow;
1111
using Unity.Payments.Enums;
12+
using Unity.Payments.Codes;
1213
using Unity.Payments.PaymentRequests;
1314
using Unity.Payments.Permissions;
1415
using Volo.Abp.Authorization.Permissions;
@@ -150,6 +151,7 @@ public async Task<PaymentRequest> TriggerAction(Guid paymentRequestsId, PaymentA
150151
if (preventPayment)
151152
{
152153
statusChangedTo = PaymentRequestStatus.FSB;
154+
paymentRequest.SetInvoiceStatus(CasPaymentRequestStatus.SentToAccountsPayable);
153155
}
154156
else
155157
{

applications/Unity.GrantManager/modules/Unity.Payments/src/Unity.Payments.Application/EntityFrameworkCore/Repositories/PaymentRequestRepository.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public PaymentRequestRepository(IDbContextProvider<PaymentsDbContext> dbContextP
2222
{
2323
ReCheckStatusList.Add(CasPaymentRequestStatus.ServiceUnavailable);
2424
ReCheckStatusList.Add(CasPaymentRequestStatus.SentToCas);
25+
ReCheckStatusList.Add(CasPaymentRequestStatus.NotFound);
26+
ReCheckStatusList.Add(CasPaymentRequestStatus.SentToAccountsPayable);
2527
ReCheckStatusList.Add(CasPaymentRequestStatus.NeverValidated);
2628

2729
FailedStatusList.Add(CasPaymentRequestStatus.ServiceUnavailable);

applications/Unity.GrantManager/modules/Unity.Payments/src/Unity.Payments.Application/PaymentRequests/CasPaymentRequestCoordinator.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
using System.Threading.Tasks;
22
using Unity.Payments.Domain.PaymentRequests;
33
using System;
4+
using System.Linq;
45
using Volo.Abp.Application.Services;
56
using System.Collections.Generic;
67
using Volo.Abp.TenantManagement;
78
using Volo.Abp.MultiTenancy;
89
using Volo.Abp.Uow;
910
using Microsoft.Extensions.Logging;
1011
using Unity.Payments.Integrations.Cas;
11-
using System.Linq;
12+
using Unity.Payments.Codes;
1213
using Unity.Payments.RabbitMQ.QueueMessages;
1314
using Unity.Notifications.Integrations.RabbitMQ;
1415

@@ -138,6 +139,11 @@ public async Task AddPaymentRequestsToReconciliationQueue()
138139
paymentReqeust = await _paymentRequestsRepository.GetAsync(PaymentRequestId);
139140
if (paymentReqeust != null)
140141
{
142+
if(paymentReqeust.InvoiceStatus == CasPaymentRequestStatus.NotFound && result.InvoiceStatus == CasPaymentRequestStatus.NotFound)
143+
{
144+
result.InvoiceStatus = CasPaymentRequestStatus.NotFound+"2";
145+
}
146+
141147
paymentReqeust.SetInvoiceStatus(result.InvoiceStatus ?? "");
142148
paymentReqeust.SetPaymentStatus(result.PaymentStatus ?? "");
143149
paymentReqeust.SetPaymentDate(result.PaymentDate ?? "");

applications/Unity.GrantManager/modules/Unity.Payments/src/Unity.Payments.Web/Pages/PaymentRequests/Index.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,16 @@ $(function () {
186186

187187
payment_approve_buttons.disable();
188188
payment_check_status_buttons.disable();
189+
history_button.disable();
189190
dataTable.on('search.dt', () => handleSearch());
190191

191-
function checkAllRowsHaveState(state) {
192-
return dataTable.rows('.selected').data().toArray().every(row => row.status === state);
192+
function checkAllRowsHaveState(states) {
193+
const allowedStates = Array.isArray(states) ? states : [states];
194+
return dataTable
195+
.rows('.selected')
196+
.data()
197+
.toArray()
198+
.every(row => allowedStates.includes(row.status));
193199
}
194200

195201
$('#PaymentRequestListTable').on('click', 'tr td', function (e) {
@@ -256,13 +262,13 @@ $(function () {
256262
}
257263

258264
function checkActionButtons() {
259-
let isOnlySubmittedToCas = checkAllRowsHaveState('Submitted');
260-
if (isOnlySubmittedToCas) {
265+
let isInSentState = checkAllRowsHaveState(['Submitted', 'FSB']);
266+
if (isInSentState) {
261267
payment_check_status_buttons.enable();
262268
} else {
263269
payment_check_status_buttons.disable();
264270
}
265-
if (dataTable.rows({ selected: true }).indexes().length > 0 && !isOnlySubmittedToCas) {
271+
if (dataTable.rows({ selected: true }).indexes().length > 0 && !isInSentState) {
266272
if (abp.auth.isGranted('PaymentsPermissions.Payments.L1ApproveOrDecline')
267273
|| abp.auth.isGranted('PaymentsPermissions.Payments.L2ApproveOrDecline')
268274
|| abp.auth.isGranted('PaymentsPermissions.Payments.L3ApproveOrDecline')) {
@@ -272,15 +278,11 @@ $(function () {
272278
payment_approve_buttons.disable();
273279
}
274280

275-
if (dataTable.rows({ selected: true }).indexes().length == 1) {
276-
history_button.enable();
277-
} else {
278-
history_button.disable();
279-
}
281+
checkEnableHistoryButton(dataTable, history_button);
280282
}
281283
else {
282284
payment_approve_buttons.disable();
283-
history_button.enable();
285+
checkEnableHistoryButton(dataTable, history_button);
284286
}
285287
}
286288

@@ -792,6 +794,14 @@ let casPaymentResponseModal = new abp.ModalManager({
792794
viewUrl: '../PaymentRequests/CasPaymentRequestResponse'
793795
});
794796

797+
function checkEnableHistoryButton(dataTable, history_button) {
798+
if (dataTable.rows({ selected: true }).indexes().length == 1) {
799+
history_button.enable();
800+
} else {
801+
history_button.disable();
802+
}
803+
}
804+
795805
function openCasResponseModal(casResponse) {
796806
casPaymentResponseModal.open({
797807
casResponse: casResponse

applications/Unity.GrantManager/src/Unity.GrantManager.Application/History/PaymentHistoryAppService.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ public async Task<List<HistoryDto>> GetPaymentHistoryList(Guid? entityId)
1515
{
1616
List<HistoryDto> historyList = [];
1717
CancellationToken cancellationToken = default;
18+
19+
if (entityId == null || entityId == Guid.Empty)
20+
{
21+
return historyList;
22+
}
23+
1824
var entityChanges = await extendedAuditLogRepository.GetEntityChangeByTypeWithUsernameAsync(
1925
entityId,
2026
HistoryConsts.PaymentEntityTypeFullNames,
@@ -23,18 +29,30 @@ public async Task<List<HistoryDto>> GetPaymentHistoryList(Guid? entityId)
2329

2430
foreach (var entityChange in entityChanges)
2531
{
32+
// Add explicit filter to ensure only matching entityId records
33+
if (entityChange.EntityChange.EntityId != entityId.ToString())
34+
{
35+
continue;
36+
}
37+
2638
foreach (var propertyChange in entityChange.EntityChange.PropertyChanges)
2739
{
28-
string origninalValue = CleanValue(propertyChange.OriginalValue);
40+
string originalValue = CleanValue(propertyChange.OriginalValue);
2941
string newValue = CleanValue(propertyChange.NewValue);
3042
string displayNewValue = MapFsbToDisplayText(newValue);
43+
44+
// Don't display history if both original and new values are empty, as it doesn't provide useful information and may clutter the history with irrelevant entries.
45+
if (string.IsNullOrEmpty(originalValue) && string.IsNullOrEmpty(newValue))
46+
{
47+
continue;
48+
}
3149
int changeType = (int)entityChange.EntityChange.ChangeType;
3250
DateTime utcDateTime = DateTime.SpecifyKind(entityChange.EntityChange.ChangeTime, DateTimeKind.Utc);
3351
HistoryDto historyDto = new()
3452
{
3553
EntityName = GetShortEntityName(entityChange.EntityChange.EntityTypeFullName),
36-
PropertyName = propertyChange.PropertyName, // The name of the property on the entity class.
37-
OriginalValue = origninalValue,
54+
PropertyName = propertyChange.PropertyName,
55+
OriginalValue = originalValue,
3856
NewValue = displayNewValue,
3957
ChangeTime = utcDateTime.ToLocalTime(),
4058
UserName = entityChange.UserName,

0 commit comments

Comments
 (0)