Skip to content

Commit

Permalink
Merge pull request #493 from ucdavis/JCS/RequireSlothApprovalStep
Browse files Browse the repository at this point in the history
Never Auto Approve sloth
  • Loading branch information
jSylvestre authored Oct 8, 2024
2 parents 0057add + 14e1c2e commit ffa99b4
Showing 4 changed files with 9 additions and 26 deletions.
12 changes: 5 additions & 7 deletions Hippo.Core/Services/PaymentsService.cs
Original file line number Diff line number Diff line change
@@ -235,20 +235,18 @@ public async Task<bool> NotifyAboutFailedPayments()
}
if (invalidOrderIdsInCluster.Count > 0)
{
//Get lists of cluster admins
//Send email to cluster admins with list of orders that have failed payments
//https://localhost:44371/caesfarm/order/details/46
//Send email to cluster admins / financial admins with list of orders that have failed payments

var clusterAdmins = await _dbContext.Users.AsNoTracking().Where(u => u.Permissions.Any(p => p.Cluster.Id == orderGroup.Key && p.Role.Name == Role.Codes.ClusterAdmin)).Select(a => a.Email).ToArrayAsync();
//TODO: Notify the cluster admins with a single email
var notificationList = await _dbContext.Users.AsNoTracking().Where(a => a.Permissions.Any(p => p.Cluster.Id == orderGroup.Key && (p.Role.Name == Role.Codes.ClusterAdmin || p.Role.Name == Role.Codes.FinancialAdmin))).Select(a => a.Email).Distinct().ToArrayAsync();

try
{
await _notificationService.AdminPaymentFailureNotification(clusterAdmins, cluster.Name, invalidOrderIdsInCluster.ToArray());
await _notificationService.AdminPaymentFailureNotification(notificationList, cluster.Name, invalidOrderIdsInCluster.ToArray());
}
catch (Exception ex)
{
Log.Error(ex, "Failed to notify cluster admins for cluster {0}", cluster.Id);

Log.Error(ex, "Failed to notify cluster admins/financial for cluster {0}", cluster.Id);
}

}
2 changes: 1 addition & 1 deletion Hippo.Core/Services/SlothService.cs
Original file line number Diff line number Diff line change
@@ -174,7 +174,7 @@ private TransactionViewModel CreateTransaction(FinancialDetail financialDetail,
{
var slothTransaction = new TransactionViewModel
{
AutoApprove = financialDetail.AutoApprove,
AutoApprove = false, //financialDetail.AutoApprove,
MerchantTrackingNumber = $"{payment.OrderId}-{payment.Id}",
ProcessorTrackingNumber = $"{payment.OrderId}-{payment.Id}",
ValidateFinancialSegmentStrings = true,
15 changes: 0 additions & 15 deletions Hippo.Web/ClientApp/src/components/Financial/FinancialDetail.tsx
Original file line number Diff line number Diff line change
@@ -163,21 +163,6 @@ export const FinancialDetail = () => {
/>
</div>

<div className="form-group">
<label htmlFor="autoApprove">Auto Approve:</label>{" "}
<input
type="checkbox"
id="autoApprove"
name="autoApprove"
checked={financialDetail.autoApprove}
onChange={(e) =>
setFinancialDetail((prevFinancialDetail) => ({
...prevFinancialDetail,
autoApprove: e.target.checked,
}))
}
/>
</div>
<div className="form-group">
<label htmlFor="chartString">Chart String:</label>{" "}
{financialDetail.chartString && (
6 changes: 3 additions & 3 deletions Hippo.Web/Controllers/FinancialController.cs
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ public async Task<IActionResult> FinancialDetails()
FinancialSystemApiKey = string.Empty,
FinancialSystemApiSource = existingFinancialDetail?.FinancialSystemApiSource,
ChartString = existingFinancialDetail?.ChartString,
AutoApprove = existingFinancialDetail?.AutoApprove ?? false,
AutoApprove = false, // existingFinancialDetail?.AutoApprove ?? false,
MaskedApiKey = "NOT SET"
};

@@ -103,7 +103,7 @@ public async Task<IActionResult> UpdateFinancialDetails([FromBody] FinancialDeta
//var xxx = await _secretsService.GetSecret(existingFinancialDetail.SecretAccessKey);
existingFinancialDetail.FinancialSystemApiSource = model.FinancialSystemApiSource;
existingFinancialDetail.ChartString = validateChartString.ChartString;
existingFinancialDetail.AutoApprove = model.AutoApprove;
existingFinancialDetail.AutoApprove = false; // model.AutoApprove;

if (existingFinancialDetail.Id == 0)
{
@@ -121,7 +121,7 @@ public async Task<IActionResult> UpdateFinancialDetails([FromBody] FinancialDeta
FinancialSystemApiKey = string.Empty,
FinancialSystemApiSource = existingFinancialDetail?.FinancialSystemApiSource,
ChartString = existingFinancialDetail?.ChartString,
AutoApprove = existingFinancialDetail?.AutoApprove ?? false,
AutoApprove = false, //existingFinancialDetail?.AutoApprove ?? false,
MaskedApiKey = "NOT SET"
};
var apiKey = await _secretsService.GetSecret(existingFinancialDetail?.SecretAccessKey);

0 comments on commit ffa99b4

Please sign in to comment.