Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Payments.Jobs.AutoApprove/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static void Main(string[] args)
dbContext.Invoices.Update(invoice);
_log.Information("Auto-approved invoice {invoiceId}", invoice.Id);

dbContext.SaveChangesAsync();
dbContext.SaveChanges();
}
}
catch (Exception ex)
Expand Down
23 changes: 5 additions & 18 deletions src/Payments.Mvc/Controllers/RechargeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ public async Task<IActionResult> Preview(int id)

var model = CreateRechargeInvoiceViewModel(invoice);

//var model = CreateRechargePaymentViewModel(invoice);

if (invoice.Status != Invoice.StatusCodes.Sent)
{
//This is valid status to pay, but I think we want to allow the other statuses through so it can be viewed, but not edited.
}

ViewBag.Id = id;

return View(model);
Expand Down Expand Up @@ -151,10 +144,6 @@ public async Task<IActionResult> Pay(string id)

var model = CreateRechargeInvoiceViewModel(invoice);

if (invoice.Status == Invoice.StatusCodes.Sent)
{
//This is valid status to pay, but I think we want to allow the other statuses through so it can be viewed, but not edited.
}

ViewBag.Id = id;

Expand Down Expand Up @@ -345,12 +334,10 @@ public async Task<IActionResult> Pay(string id, [FromBody] RechargeAccount[] mod

await _dbContext.SaveChangesAsync(); //Maybe wait for all changes?



//Need to notify the approvers. This will require a new email template.
//TODO: The logic below will have to be duplicated if we allow this step to be skipped from the invoice details page.

invoice.PaidAt = DateTime.UtcNow;
//TODO: Also set the paid flag? Or.... probably better, wait for the financial approve step. Then I can use the PaidAt to determine auto pay, and the Paid flag for the PaymentController download (receipt)
//Answered: Also set the paid flag? - NO. Or.... probably better, wait for the financial approve step. Then I can use the PaidAt to determine auto pay, and the Paid flag for the PaymentController download (receipt)

invoice.Status = Invoice.StatusCodes.PendingApproval;

Expand All @@ -367,7 +354,7 @@ public async Task<IActionResult> Pay(string id, [FromBody] RechargeAccount[] mod
await _invoiceService.SendFinancialApproverEmail(invoice, new SendApprovalModel()
{
emails = emails.ToArray(),
bccEmails = "" //TODO: Add any BCC emails if needed. Note customer is CC'd by default in the service.
bccEmails = "" // Add any BCC emails if needed. Note customer is CC'd by default in the service.
});

var notificationAction = new History()
Expand All @@ -387,7 +374,6 @@ public async Task<IActionResult> Pay(string id, [FromBody] RechargeAccount[] mod

invoice.History.Add(notificationAction);

//_dbContext.Invoices.Update(invoice);
await _dbContext.SaveChangesAsync();


Expand All @@ -405,14 +391,15 @@ public async Task<IActionResult> FinancialApprove(string id)
.Include(i => i.Attachments)
.Include(i => i.RechargeAccounts.Where(ra => ra.Direction == RechargeAccount.CreditDebit.Debit))
.FirstOrDefaultAsync(i => i.LinkId == id);
//I think his is ok.
//I think this is ok.
if (invoice == null)
{
return PublicNotFound();
}

if (invoice.Status == Invoice.StatusCodes.Draft || invoice.Status == Invoice.StatusCodes.Cancelled || invoice.Status == Invoice.StatusCodes.Sent)
{
//Includes sent, because they can't approve it yet.
return PublicNotFound();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Payments.Mvc/Views/Invoices/Details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@
<a href="@paymentPageHref">@(paymentPageHref) <i class="fas fa-arrow-right ms-3"></i></a>
</dd>
</dl>
if(Model.Status == Invoice.StatusCodes.PendingApproval)
if(Model.Status == Invoice.StatusCodes.PendingApproval || Model.Status == Invoice.StatusCodes.Approved || Model.Status == Invoice.StatusCodes.Completed)
{
<dl class="row">
<dt class="col-2 text-end">Recharge Financial Approval page</dt>
Expand Down
Loading