-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jcs/txn report #411
Merged
Merged
Jcs/txn report #411
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f8b4ee1
Downloadable report
jSylvestre 7f99330
WIP
jSylvestre ee4b784
wip
jSylvestre 80c949e
cleanup
jSylvestre 83e5b6b
wip
jSylvestre 87257ef
Add a shortened COA method
jSylvestre 4cbab9f
buttons and columns
jSylvestre a14c7ea
Cleanup
jSylvestre db93502
cleanup
jSylvestre 0643d84
comment
jSylvestre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Sloth.Web.Models.TransactionViewModels; | ||
using System; | ||
|
||
namespace Sloth.Web.Helpers | ||
{ | ||
public class FilterHelpers | ||
{ | ||
public static void SanitizeTransactionsFilter(TransactionsFilterModel model) | ||
{ | ||
var fromUtc = (model.From ?? DateTime.Now.AddMonths(-1)).ToUniversalTime().Date; | ||
var throughUtc = (model.To ?? DateTime.Now).ToUniversalTime().AddDays(1).Date; | ||
|
||
if (fromUtc > DateTime.UtcNow || fromUtc < DateTime.UtcNow.AddYears(-100)) | ||
{ | ||
// invalid, so default to filtering from one month ago | ||
var from = DateTime.Now.AddMonths((-1)).Date; | ||
model.From = from; | ||
fromUtc = from.ToUniversalTime(); | ||
} | ||
else | ||
{ | ||
model.From = fromUtc.ToLocalTime(); | ||
} | ||
|
||
if (fromUtc >= throughUtc) | ||
{ | ||
// invalid, so default to filtering through one month after fromUtc | ||
throughUtc = fromUtc.AddMonths(1).AddDays(1).Date; | ||
model.To = throughUtc.AddDays(-1).ToLocalTime(); | ||
} | ||
else | ||
{ | ||
model.To = throughUtc.ToLocalTime(); | ||
} | ||
} | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
Sloth.Web/Models/ReportViewModels/TransfersReportViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System; | ||
using System.ComponentModel; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using Sloth.Core.Models; | ||
using System.Collections.Generic; | ||
using Sloth.Web.Models.TransactionViewModels; | ||
using System.Linq.Expressions; | ||
using System.Linq; | ||
|
||
namespace Sloth.Web.Models.ReportViewModels | ||
{ | ||
public class TransfersReportViewModel | ||
{ | ||
public TransactionsFilterModel Filter { get; set; } | ||
|
||
public IList<TransactionWithTransfers> Transactions { get; set; } | ||
} | ||
|
||
public class TransactionWithTransfers | ||
{ | ||
[DisplayName("Txn Id")] | ||
public string Id { get; set; } | ||
[DisplayName("Txn Id")] | ||
public string DisplayId => $"...{Id[^4..]}"; // last 4 characters of the id | ||
|
||
public string Status { get; set; } | ||
|
||
[DisplayName("Transaction Date")] | ||
public DateTime TransactionDate { get; set; } | ||
|
||
[DisplayName("Kfs Tracking Number")] | ||
public string KfsTrackingNumber { get; set; } | ||
[DisplayName("Document Number")] | ||
public string DocumentNumber { get; set; } | ||
|
||
[DisplayName("Processor Tracking Number")] | ||
public string ProcessorTrackingNumber { get; set; } | ||
|
||
[DisplayName("Merchant Tracking Number")] | ||
public string MerchantTrackingNumber { get; set; } | ||
[DisplayName("Transaction Description")] | ||
public string TxnDescription { get; set; } | ||
|
||
public string MetaDataString { get; set; } | ||
|
||
[DisplayName("Transaction Amount")] | ||
public decimal Amount { get; set; } | ||
|
||
[DisplayName("Transfer Count")] | ||
public int TransferCount { get; set; } | ||
|
||
public IList<Transfer> Transfers { get; set; } // don't need all the info in here, but it shouldn't be too big. | ||
|
||
public static Expression<Func<Transaction, TransactionWithTransfers>> Projection() | ||
{ | ||
|
||
return txn => new TransactionWithTransfers | ||
{ | ||
Id = txn.Id, | ||
Status = txn.Status, | ||
TransactionDate = txn.TransactionDate, | ||
KfsTrackingNumber = txn.KfsTrackingNumber, | ||
DocumentNumber = txn.DocumentNumber, | ||
ProcessorTrackingNumber = txn.ProcessorTrackingNumber, | ||
MerchantTrackingNumber = txn.MerchantTrackingNumber, | ||
TxnDescription = txn.Description, | ||
MetaDataString = string.Join(", ", txn.Metadata.Select(kv => $"{kv.Name}: {kv.Value}")), | ||
Amount = txn.Transfers.Where(a => a.Direction == Transfer.CreditDebit.Credit).Sum(a => a.Amount), | ||
TransferCount = txn.Transfers.Count, | ||
Transfers = txn.Transfers.OrderBy(a => a.Direction).ToList(), | ||
}; | ||
|
||
} | ||
} | ||
} |
128 changes: 128 additions & 0 deletions
128
Sloth.Web/Views/Reports/DownloadableTransactions.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
@using Humanizer | ||
@using Sloth.Core.Extensions | ||
@using Sloth.Core.Resources | ||
@model Sloth.Web.Models.ReportViewModels.TransfersReportViewModel | ||
|
||
<div class="container"> | ||
<h2>@ViewBag.Title</h2> | ||
|
||
<h3>Filters</h3> | ||
<form class="row" id="transactionFilterForm" asp-controller="Reports" asp-action="DownloadableTransactions" method="get"> | ||
<div class="row justify-content-between filters-wrapper"> | ||
<div class="col-8 col-md-5"> | ||
<div id="filter-date-range" class="input-group"> | ||
<input name="from" type="text" class="form-control" placeholder="MM/DD/YYYY" asp-for="Filter.From" asp-format="{0:MM/dd/yyyy}" aria-label="" /> | ||
<span class="input-group-text">to</span> | ||
<input name="to" type="text" class="form-control" placeholder="MM/DD/YYYY" asp-for="Filter.To" asp-format="{0:MM/dd/yyyy}" aria-label="" /> | ||
</div> | ||
|
||
<button type="submit" class="btn btn-link mt-1">Apply filter</button> | ||
</div> | ||
|
||
</div> | ||
</form> | ||
|
||
<div class="responsive-table"> | ||
<table id="transactionsTable" class="table sloth-table active-table"> | ||
<thead> | ||
<tr> | ||
<th>@Html.DisplayNameFor(x => x.Transactions.FirstOrDefault().Id)</th> | ||
<th>@Html.DisplayNameFor(x => x.Transactions.FirstOrDefault().DisplayId)</th> | ||
<th>@Html.DisplayNameFor(x => x.Transactions.FirstOrDefault().Status)</th> | ||
<th>@Html.DisplayNameFor(x => x.Transactions.FirstOrDefault().TransactionDate)</th> | ||
<th>@Html.DisplayNameFor(x => x.Transactions.FirstOrDefault().KfsTrackingNumber)</th> | ||
<th>@Html.DisplayNameFor(x => x.Transactions.FirstOrDefault().DocumentNumber)</th> | ||
<th>@Html.DisplayNameFor(x => x.Transactions.FirstOrDefault().ProcessorTrackingNumber)</th> | ||
<th>@Html.DisplayNameFor(x => x.Transactions.FirstOrDefault().MerchantTrackingNumber)</th> | ||
<th>@Html.DisplayNameFor(x => x.Transactions.FirstOrDefault().TxnDescription)</th> | ||
<th>@Html.DisplayNameFor(x => x.Transactions.FirstOrDefault().MetaDataString)</th> | ||
<th>@Html.DisplayNameFor(x => x.Transactions.FirstOrDefault().TransferCount)</th> | ||
<th>Total Amount</th> | ||
<th>Direction</th> | ||
<th>Description</th> | ||
<th>Amount</th> | ||
<th>Chart String</th> | ||
<th>Chart String</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var txn in Model.Transactions) | ||
{ | ||
@foreach (var transfer in txn.Transfers) | ||
{ | ||
<tr> | ||
<td>@txn.Id</td> | ||
<td>@txn.DisplayId</td> | ||
<td><span class="badge @(TransactionStatuses.GetBadgeClass(txn.Status))">@txn.Status.Humanize(LetterCasing.Title)</span></td> | ||
<td>@txn.TransactionDate.ToPacificTime()</td> | ||
<td>@txn.KfsTrackingNumber</td> | ||
<td>@txn.DocumentNumber</td> | ||
<td>@txn.ProcessorTrackingNumber</td> | ||
<td>@txn.MerchantTrackingNumber</td> | ||
<td>@txn.TxnDescription</td> | ||
<td>@txn.MetaDataString</td> | ||
<td>@txn.TransferCount</td> | ||
<td>@txn.Amount</td> | ||
<td><span class="badge @(Transfer.GetDirectionBadgeClass(transfer.Direction))">@transfer.Direction</span></td> | ||
<td>@transfer.Description</td> | ||
<td>@transfer.Amount</td> | ||
<td>@transfer.ShortFinancialSegmentString</td> | ||
<td>@transfer.FinancialSegmentString</td> | ||
</tr> | ||
} | ||
} | ||
</tbody> | ||
</table> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
@section AdditionalScripts { | ||
<script> | ||
//setup datepickers | ||
$('#filter-date-range').datepicker({ | ||
inputs: $('#filter-date-range input'), | ||
keepEmptyValues: true, | ||
}); | ||
</script> | ||
|
||
<script> | ||
$('#transactionsTable').dataTable({ | ||
"dom": 'Bfrtip', | ||
"columnDefs": [ | ||
{ | ||
"targets": [0, 5, 6, 7, 9, 16], | ||
"visible": false, | ||
}, | ||
{ "type": "date", "targets": [3] }, | ||
], | ||
order: false, | ||
"buttons": [ | ||
{ | ||
extend: 'copyHtml5', | ||
exportOptions: { | ||
columns: [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16] | ||
} | ||
}, | ||
{ | ||
extend: 'excelHtml5', | ||
exportOptions: { | ||
columns: [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16] | ||
} | ||
}, | ||
{ | ||
extend: 'csvHtml5', | ||
exportOptions: { | ||
columns: [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16] | ||
} | ||
}, | ||
], | ||
language: { | ||
searchPlaceholder: "Search Table", | ||
search: "", | ||
}, | ||
}); | ||
|
||
</script> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never seen this w/o using
string.substr()
but if this works it's ok to me. clear enough what's happening.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it takes the first 13 characters of the string. I'll add a comment