Using tuple for payments partial model

This commit is contained in:
rockstardev
2020-03-01 19:46:05 -06:00
parent 56380a5fb3
commit f8520201ce
3 changed files with 14 additions and 47 deletions

View File

@@ -183,47 +183,7 @@
</div>
}
<div class="row">
<div class="col-md-12 invoice-payments">
<h3>Paid summary</h3>
<table class="table table-sm table-responsive-md">
<thead class="thead-inverse">
<tr>
<th>Payment method</th>
<th class="text-right">Rate</th>
<th class="text-right">Paid</th>
<th class="text-right">Due</th>
@if (Model.StatusException == InvoiceExceptionStatus.PaidOver)
{
<th class="text-right">Overpaid</th>
}
</tr>
</thead>
<tbody>
@foreach (var payment in Model.CryptoPayments)
{
<tr>
<td>@payment.PaymentMethod</td>
<td class="text-right">@payment.Rate</td>
<td class="text-right">@payment.Paid</td>
<td class="text-right">@payment.Due</td>
@if (Model.StatusException == InvoiceExceptionStatus.PaidOver)
{
<td class="text-right">@payment.Overpaid</td>
}
</tr>
}
</tbody>
</table>
</div>
</div>
@{
var grouped = Model.Payments.GroupBy(payment => payment.GetPaymentMethodId().PaymentType);
}
@foreach (var paymentGroup in grouped)
{
<partial name="@paymentGroup.Key.InvoiceViewPaymentPartialName" model="@paymentGroup.ToList()" />
}
<partial name="ListInvoicesPaymentsPartial" model="(Model, false)" />
<div class="row">

View File

@@ -275,7 +275,7 @@
<td colspan="99">
<div style="margin-left: 15px; margin-bottom: 0;">
@* Leaving this as partial because it abstracts complexity of Invoice Payments *@
<partial name="ListInvoicesPaymentsPartial" model="invoice.Details" />
<partial name="ListInvoicesPaymentsPartial" model="(invoice.Details, true)" />
</div>
</td>
</tr>

View File

@@ -1,4 +1,5 @@
@model InvoiceDetailsModel
@model (InvoiceDetailsModel Invoice, bool ShowAddress)
@{ var invoice = Model.Invoice; }
@inject PaymentMethodHandlerDictionary PaymentMethodHandlerDictionary
<div class="row">
@@ -8,28 +9,34 @@
<thead class="thead-inverse">
<tr>
<th>Payment method</th>
@if (Model.ShowAddress)
{
<th>Address</th>
}
<th class="text-right">Rate</th>
<th class="text-right">Paid</th>
<th class="text-right">Due</th>
@if (Model.StatusException == InvoiceExceptionStatus.PaidOver)
@if (invoice.StatusException == InvoiceExceptionStatus.PaidOver)
{
<th class="text-right">Overpaid</th>
}
</tr>
</thead>
<tbody>
@foreach (var payment in Model.CryptoPayments)
@foreach (var payment in invoice.CryptoPayments)
{
<tr>
<td>@payment.PaymentMethod</td>
@if (Model.ShowAddress)
{
<td title="@payment.Address">
<span class="text-truncate d-block" style="max-width: 400px">@payment.Address</span>
</td>
}
<td class="text-right">@payment.Rate</td>
<td class="text-right">@payment.Paid</td>
<td class="text-right">@payment.Due</td>
@if (Model.StatusException == InvoiceExceptionStatus.PaidOver)
@if (invoice.StatusException == InvoiceExceptionStatus.PaidOver)
{
<td class="text-right">@payment.Overpaid</td>
}
@@ -40,7 +47,7 @@
</div>
</div>
@{
var grouped = Model.Payments.GroupBy(payment => payment.GetPaymentMethodId().PaymentType);
var grouped = invoice.Payments.GroupBy(payment => payment.GetPaymentMethodId().PaymentType);
}
@foreach (var paymentGroup in grouped)
{