Skip to content

Commit

Permalink
Merge pull request #431 from ucdavis/JCS/Resubmit
Browse files Browse the repository at this point in the history
Resubmit rejected txn
  • Loading branch information
jSylvestre authored Aug 20, 2024
2 parents fc58640 + adca42a commit f4c81c7
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
28 changes: 28 additions & 0 deletions Sloth.Web/Controllers/TransactionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,34 @@ public async Task<IActionResult> ScheduleTransaction(string id)
return RedirectToAction("Index");
}

[HttpPost]
public async Task<IActionResult> ResubmitTransaction(string id)
{
var transaction = await DbContext.Transactions
.Where(t => t.Source.Team.Slug == TeamSlug)
.Include(t => t.Scrubber)
.Include(t => t.Transfers)
.FirstOrDefaultAsync(t => t.Id == id);

if (transaction == null)
{
ErrorMessage = "Transaction not found";
return RedirectToAction(nameof(Index));
}

if (transaction.Status != TransactionStatuses.Rejected)
{
ErrorMessage = "Transaction is not Rejected";
return RedirectToAction(nameof(Details), new { id });
}

transaction.SetStatus(TransactionStatuses.Scheduled, details: $"Resubmitted by {User.Identity.Name}");

await DbContext.SaveChangesAsync();

return RedirectToAction("Index");
}

[HttpPost]
[Authorize(Policy = PolicyCodes.TeamManager)]
public async Task<IActionResult> CreateReversal(string id, decimal reversalAmount)
Expand Down
31 changes: 31 additions & 0 deletions Sloth.Web/Views/Transactions/Details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,31 @@ else
</div>
}

@if (Model.Transaction.Status == TransactionStatuses.Rejected)
{
<div id="resubmit-txn-modal" class="modal fade">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Resubmit Transaction?</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
</button>
</div>
<div class="modal-body">
<form id="resubmit-txn-modal-form" method="post" action="@Url.Action("ResubmitTransaction")">
<input name="id" type="hidden" value="@Model.Transaction.Id" />
<div>Please ensure the Chart String that caused this to be rejected is now valid before resubmitting</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" id="resubmit-txn-modal-action" class="btn btn-primary">Resubmit Transaction</button>
</div>
</div>
</div>
</div>
}

@section AdditionalScripts {
<script src="~/js/prism.js"></script>
<script>
Expand All @@ -115,6 +140,12 @@ else
});
</script>

<script>
$('#resubmit-txn-modal-action').click(function () {
$('#resubmit-txn-modal-form').submit();
});
</script>

@if (Model.Transaction.Metadata.Any())
{
<partial name="_MetadataTableScript" />
Expand Down
7 changes: 6 additions & 1 deletion Sloth.Web/Views/Transactions/_AeDetails.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
|| Model.Transaction.IsStale())
{
var isTeamManager = Context.HasTeamRole(TeamRole.Manager);
var isTeamAdmin = Context.HasTeamRole(TeamRole.Admin);
var isTeamAdmin = Context.HasTeamRole(TeamRole.Admin);

<form asp-controller="Transactions" asp-action="Edit" asp-route-id="@Model.Transaction.Id" method="get">
<div>
Expand All @@ -187,6 +187,11 @@
</form>
<button type="submit" class="btn btn-warning" @(!isTeamManager ? "Disabled" : "") data-bs-toggle="modal" data-bs-target="#cancel-txn-modal">Cancel Transaction</button>
}
@if(Model.Transaction.Status == TransactionStatuses.Rejected)
{

<button type="submit" class="btn btn-info" data-bs-toggle="modal" data-bs-target="#resubmit-txn-modal">Resubmit Transaction</button>
}
</div>
</div>

Expand Down

0 comments on commit f4c81c7

Please sign in to comment.