Skip to content

Commit 3363632

Browse files
authored
Merge pull request #1717 from bcgov/dev
Dev
2 parents c69ed2c + 02be7ea commit 3363632

3 files changed

Lines changed: 85 additions & 81 deletions

File tree

applications/Unity.GrantManager/modules/Unity.Payments/src/Unity.Payments.Application/Integrations/Cas/SupplierService.cs

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ public class SupplierService : ApplicationService, ISupplierService
2929
private readonly ILocalEventBus localEventBus;
3030
private readonly IResilientHttpRequest resilientHttpRequest;
3131
private readonly ICasTokenService iTokenService;
32-
public SupplierService (ILocalEventBus localEventBus,
32+
public SupplierService(ILocalEventBus localEventBus,
3333
IEndpointManagementAppService endpointManagementAppService,
3434
IResilientHttpRequest resilientHttpRequest,
3535
ICasTokenService iTokenService)
3636
{
37-
this.localEventBus = localEventBus;
38-
this.resilientHttpRequest = resilientHttpRequest;
39-
this.iTokenService = iTokenService;
37+
this.localEventBus = localEventBus;
38+
this.resilientHttpRequest = resilientHttpRequest;
39+
this.iTokenService = iTokenService;
4040

41-
// Initialize the base API URL once during construction
42-
casBaseApiTask = InitializeBaseApiAsync(endpointManagementAppService);
41+
// Initialize the base API URL once during construction
42+
casBaseApiTask = InitializeBaseApiAsync(endpointManagementAppService);
4343
}
4444

4545
private static async Task<string> InitializeBaseApiAsync(IEndpointManagementAppService endpointManagementAppService)
@@ -159,47 +159,42 @@ string GetProp(string name) =>
159159
}
160160

161161

162-
protected static SiteEto GetSiteEto(dynamic site)
162+
protected static SiteEto GetSiteEto(JsonElement site)
163163
{
164-
string supplierSiteCode = site["suppliersitecode"].ToString();
165-
string addressLine1 = site["addressline1"].ToString();
166-
string addressLine2 = site["addressline2"].ToString();
167-
string city = site["city"].ToString();
168-
string province = site["province"].ToString();
169-
string country = site["country"].ToString();
170-
string postalCode = site["postalcode"].ToString();
171-
string emailAddress = site["emailaddress"].ToString();
172-
string eftAdvicePref = site["eftadvicepref"].ToString();
173-
string accountNumber = site["accountnumber"].ToString();
164+
string accountNumber = GetJsonProperty("accountnumber", site);
174165
string maskedAccountNumber = accountNumber.Length > 4
175166
? new string('*', accountNumber.Length - 4) + accountNumber[^4..]
176167
: accountNumber;
177-
string bankAccount = maskedAccountNumber;
178-
string providerId = site["providerid"].ToString();
179-
string siteStatus = site["status"].ToString();
180-
string siteProtected = site["siteprotected"].ToString();
181-
string siteLastUpdated = site["lastupdated"].ToString();
182-
168+
string siteLastUpdated = GetJsonProperty("lastupdated", site);
183169
_ = DateTime.TryParse(siteLastUpdated, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out DateTime siteLastUpdatedDate);
170+
184171
return new SiteEto
185172
{
186-
SupplierSiteCode = supplierSiteCode,
187-
AddressLine1 = addressLine1,
188-
AddressLine2 = addressLine2,
189-
AddressLine3 = addressLine2,
190-
City = city,
191-
Province = province,
192-
Country = country,
193-
PostalCode = postalCode,
194-
EmailAddress = emailAddress,
195-
EFTAdvicePref = eftAdvicePref,
196-
BankAccount = bankAccount,
197-
ProviderId = providerId,
198-
Status = siteStatus,
199-
SiteProtected = siteProtected,
173+
SupplierSiteCode = GetJsonProperty("suppliersitecode", site),
174+
AddressLine1 = GetJsonProperty("addressline1", site),
175+
AddressLine2 = GetJsonProperty("addressline2", site),
176+
AddressLine3 = GetJsonProperty("addressline2", site),
177+
City = GetJsonProperty("city", site),
178+
Province = GetJsonProperty("province", site),
179+
Country = GetJsonProperty("country", site),
180+
PostalCode = GetJsonProperty("postalcode", site),
181+
EmailAddress = GetJsonProperty("emailaddress", site),
182+
EFTAdvicePref = GetJsonProperty("eftadvicepref", site),
183+
BankAccount = maskedAccountNumber,
184+
ProviderId = GetJsonProperty("providerid", site),
185+
Status = GetJsonProperty("status", site),
186+
SiteProtected = GetJsonProperty("siteprotected", site),
200187
LastUpdated = siteLastUpdatedDate
201188
};
202189
}
190+
191+
private static string GetJsonProperty(string name, JsonElement jsonElement)
192+
{
193+
return jsonElement.TryGetProperty(name, out var prop) && prop.ValueKind != JsonValueKind.Null
194+
? prop.ToString()
195+
: string.Empty;
196+
}
197+
203198
public async Task<dynamic> GetCasSupplierInformationAsync(string? supplierNumber)
204199
{
205200
if (!string.IsNullOrEmpty(supplierNumber))
@@ -236,7 +231,7 @@ private async Task<dynamic> GetCasSupplierInformationByResourceAsync(string? res
236231
var authToken = await iTokenService.GetAuthTokenAsync();
237232
try
238233
{
239-
using var response = await resilientHttpRequest.HttpAsync(HttpMethod.Get, resource, authToken);
234+
using var response = await resilientHttpRequest.HttpAsync(HttpMethod.Get, resource, body: null, authToken);
240235
if (response != null)
241236
{
242237
if (response.Content != null && response.StatusCode != HttpStatusCode.NotFound)

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ public async Task<List<HistoryDto>> GetPaymentHistoryList(Guid? entityId)
2727
{
2828
string origninalValue = CleanValue(propertyChange.OriginalValue);
2929
string newValue = CleanValue(propertyChange.NewValue);
30+
string displayNewValue = MapFsbToDisplayText(newValue);
3031
DateTime utcDateTime = DateTime.SpecifyKind(entityChange.EntityChange.ChangeTime, DateTimeKind.Utc);
3132
HistoryDto historyDto = new()
3233
{
3334
EntityName = GetShortEntityName(entityChange.EntityChange.EntityTypeFullName),
3435
PropertyName = propertyChange.PropertyName, // The name of the property on the entity class.
3536
OriginalValue = origninalValue,
36-
NewValue = newValue,
37+
NewValue = displayNewValue,
3738
ChangeTime = utcDateTime.ToLocalTime(),
3839
UserName = entityChange.UserName
3940
};
@@ -43,6 +44,11 @@ public async Task<List<HistoryDto>> GetPaymentHistoryList(Guid? entityId)
4344
return historyList;
4445
}
4546

47+
private static string MapFsbToDisplayText(string value)
48+
{
49+
return value == "FSB" ? "Sent to Account Payable" : value;
50+
}
51+
4652
private static string GetShortEntityName(string fullEntityName)
4753
{
4854
string pattern = @"[^.]+$";

applications/Unity.GrantManager/src/Unity.GrantManager.Web/Pages/PaymentHistory/Details.js

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,31 @@
66
let actionButtons = [...commonTableActionButtons('Payment History')];
77

88
let responseCallback = function (result) {
9-
if (result + "" == "undefined") {
9+
if (result + '' == 'undefined') {
1010
return {
1111
recordsTotal: 0,
1212
recordsFiltered: 0,
13-
data: {}
13+
data: {},
1414
};
1515
}
1616
return {
1717
recordsTotal: result.length,
1818
recordsFiltered: result.length,
19-
data: formatItems(result)
19+
data: formatItems(result),
2020
};
2121
};
2222

2323
let inputAction = function () {
24-
return document.getElementById('paymentId').value
24+
return document.getElementById('paymentId').value;
2525
};
2626

2727
dataTable = initializeDataTable({
2828
dt,
2929
listColumns,
3030
maxRowsPerPage: 20,
3131
defaultSortColumn: 0,
32-
dataEndpoint: unity.grantManager.history.paymentHistory.getPaymentHistoryList,
32+
dataEndpoint:
33+
unity.grantManager.history.paymentHistory.getPaymentHistoryList,
3334
data: inputAction,
3435
responseCallback,
3536
actionButtons,
@@ -49,8 +50,12 @@
4950
getOriginalValueColumn(),
5051
getNewValueColumn(),
5152
getChangeTimeColumn(),
52-
getUserNameColumn()
53-
].map((column) => ({ ...column, targets: [column.index], orderData: [column.index, 0] }));
53+
getUserNameColumn(),
54+
].map((column) => ({
55+
...column,
56+
targets: [column.index],
57+
orderData: [column.index, 0],
58+
}));
5459
}
5560

5661
function getEntityNameColumn() {
@@ -59,8 +64,8 @@
5964
data: 'entityName',
6065
name: 'entityName',
6166
className: 'data-table-header',
62-
index: 0
63-
}
67+
index: 0,
68+
};
6469
}
6570

6671
function getPropertyNameColumn() {
@@ -69,8 +74,8 @@
6974
data: 'propertyName',
7075
name: 'propertyName',
7176
className: 'data-table-header',
72-
index: 1
73-
}
77+
index: 1,
78+
};
7479
}
7580

7681
function getOriginalValueColumn() {
@@ -79,8 +84,8 @@
7984
data: 'originalValue',
8085
name: 'originalValue',
8186
className: 'data-table-header',
82-
index: 2
83-
}
87+
index: 2,
88+
};
8489
}
8590

8691
function getNewValueColumn() {
@@ -89,8 +94,8 @@
8994
data: 'newValue',
9095
name: 'newValue',
9196
className: 'data-table-header',
92-
index: 3
93-
}
97+
index: 3,
98+
};
9499
}
95100

96101
function getChangeTimeColumn() {
@@ -102,51 +107,49 @@
102107
index: 4,
103108
render: function (data) {
104109
return formatLuxonDate(data);
105-
}
106-
}
110+
},
111+
};
107112
}
108-
113+
109114
function getUserNameColumn() {
110115
return {
111116
title: 'User Name',
112117
data: 'userName',
113118
name: 'userName',
114119
className: 'data-table-header',
115-
index: 5
116-
}
120+
index: 5,
121+
};
117122
}
118123

119124
function formatLuxonDate(data) {
120-
return data != null ? luxon.DateTime.fromISO(data, {
121-
locale: abp.localization.currentCulture.name,
122-
}).toLocaleString({
123-
day: "numeric",
124-
year: "numeric",
125-
month: "numeric",
126-
hour: "numeric",
127-
minute: "numeric",
128-
second: "numeric"
129-
}) : '';
125+
return data != null
126+
? luxon.DateTime.fromISO(data, {
127+
locale: abp.localization.currentCulture.name,
128+
}).toLocaleString({
129+
day: 'numeric',
130+
year: 'numeric',
131+
month: 'numeric',
132+
hour: 'numeric',
133+
minute: 'numeric',
134+
second: 'numeric',
135+
})
136+
: '';
130137
}
131138
let formatItems = function (items) {
132139
const newData = items.map((item, index) => {
133140
return {
134141
...item,
135-
rowCount: index
142+
rowCount: index,
136143
};
137144
});
138145
return newData;
139-
}
146+
};
140147

141-
window.addEventListener('resize', () => {
142-
});
148+
window.addEventListener('resize', () => {});
143149

144-
PubSub.subscribe(
145-
'refresh_application_list',
146-
(msg, data) => {
147-
dataTable.ajax.reload(null, false);
148-
$(".select-all-applications").prop("checked", false);
149-
PubSub.publish('clear_selected_application');
150-
}
151-
);
150+
PubSub.subscribe('refresh_application_list', (msg, data) => {
151+
dataTable.ajax.reload(null, false);
152+
$('.select-all-applications').prop('checked', false);
153+
PubSub.publish('clear_selected_application');
154+
});
152155
});

0 commit comments

Comments
 (0)