Restore all zeroed views + add bulk gift certificate creation
The HTML entity sweep script had a bug where it wrote empty files for any
view that contained no target Unicode characters, zeroing out 215 view files.
All views restored from the pre-sweep commit (cefdf3e).
Bulk gift certificate feature:
- BulkCreateGiftCertificateDto with Quantity (1-500), Amount, Reason, Expiry, Notes
- GenerateBulkGiftCertificatePdfAsync on IPdfService / PdfService: one Letter page
per cert, reusing the same purple/gold branded ComposeGiftCertificateContent helper
- GiftCertificatesController: BulkCreate GET/POST, BulkResult GET, BulkDownloadPdf POST
- Views: BulkCreate.cshtml (form with live total preview), BulkResult.cshtml (table +
Download All PDF button that POSTs cert IDs to avoid URL length limits)
- gift-certificate-bulk.js: live preview + spinner/disable on submit
- Index.cshtml: Bulk Create button added alongside New Certificate
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
@model List<PowderCoating.Core.Entities.CreditMemo>
|
||||
@using PowderCoating.Core.Enums
|
||||
@{
|
||||
ViewData["Title"] = "Credit Memos";
|
||||
var status = ViewBag.Status as string ?? "";
|
||||
var search = ViewBag.Search as string ?? "";
|
||||
int activeCount = ViewBag.ActiveCount;
|
||||
decimal outstanding = ViewBag.OutstandingBalance;
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h4 class="mb-0"><i class="bi bi-journal-minus me-2 text-primary"></i>Credit Memos</h4>
|
||||
<a asp-action="Create" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg me-1"></i>Issue Credit Memo
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@if (TempData["Success"] != null)
|
||||
{
|
||||
<div class="alert alert-success alert-permanent alert-dismissible fade show">
|
||||
@TempData["Success"]
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
}
|
||||
@if (TempData["Error"] != null)
|
||||
{
|
||||
<div class="alert alert-danger alert-permanent alert-dismissible fade show">
|
||||
@TempData["Error"]
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
}
|
||||
|
||||
@* ── Stats bar ─────────────────────────────────────────────────── *@
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card border-0 bg-primary-subtle h-100">
|
||||
<div class="card-body">
|
||||
<div class="text-primary fw-semibold small">Active Memos</div>
|
||||
<div class="fs-3 fw-bold">@activeCount</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card border-0 bg-warning-subtle h-100">
|
||||
<div class="card-body">
|
||||
<div class="text-warning fw-semibold small">Outstanding Credit</div>
|
||||
<div class="fs-3 fw-bold">@outstanding.ToString("C")</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card border-0 bg-success-subtle h-100">
|
||||
<div class="card-body">
|
||||
<div class="text-success fw-semibold small">Total Memos</div>
|
||||
<div class="fs-3 fw-bold">@Model.Count</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card border-0 bg-secondary-subtle h-100">
|
||||
<div class="card-body">
|
||||
<div class="text-secondary fw-semibold small">Total Issued</div>
|
||||
<div class="fs-3 fw-bold">@Model.Sum(m => m.Amount).ToString("C")</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* ── Filters ──────────────────────────────────────────────────── *@
|
||||
<div class="card mb-3">
|
||||
<div class="card-body py-2">
|
||||
<form method="get" class="row g-2 align-items-end">
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small mb-1">Search</label>
|
||||
<input name="search" value="@search" class="form-control form-control-sm"
|
||||
placeholder="Customer, memo #, or reason…" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label small mb-1">Status</label>
|
||||
<select name="status" class="form-select form-select-sm">
|
||||
<option value="" selected="@(status == "")">All Statuses</option>
|
||||
<option value="Active" selected="@(status == "Active")">Active</option>
|
||||
<option value="PartiallyApplied" selected="@(status == "PartiallyApplied")">Partially Applied</option>
|
||||
<option value="FullyApplied" selected="@(status == "FullyApplied")">Fully Applied</option>
|
||||
<option value="Voided" selected="@(status == "Voided")">Voided</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-auto">
|
||||
<button type="submit" class="btn btn-sm btn-primary">Filter</button>
|
||||
<a asp-action="Index" class="btn btn-sm btn-outline-secondary ms-1">Clear</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* ── Table ────────────────────────────────────────────────────── *@
|
||||
@if (!Model.Any())
|
||||
{
|
||||
<div class="alert alert-info alert-permanent">No credit memos found.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Memo #</th>
|
||||
<th>Customer</th>
|
||||
<th class="text-end">Amount</th>
|
||||
<th class="text-end">Applied</th>
|
||||
<th class="text-end">Remaining</th>
|
||||
<th>Issue Date</th>
|
||||
<th>Expires</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var m in Model)
|
||||
{
|
||||
var rowClass = m.Status == CreditMemoStatus.Voided ? "text-muted" : "";
|
||||
var expired = m.ExpiryDate.HasValue && m.ExpiryDate.Value < DateTime.UtcNow
|
||||
&& m.Status != CreditMemoStatus.FullyApplied
|
||||
&& m.Status != CreditMemoStatus.Voided;
|
||||
<tr class="@rowClass">
|
||||
<td>
|
||||
<a asp-action="Details" asp-route-id="@m.Id" class="fw-semibold text-decoration-none">
|
||||
@m.MemoNumber
|
||||
</a>
|
||||
</td>
|
||||
<td>@(string.IsNullOrWhiteSpace(m.Customer?.CompanyName) ? $"{m.Customer?.ContactFirstName} {m.Customer?.ContactLastName}".Trim() : m.Customer.CompanyName)</td>
|
||||
<td class="text-end">@m.Amount.ToString("C")</td>
|
||||
<td class="text-end">@m.AmountApplied.ToString("C")</td>
|
||||
<td class="text-end @(m.RemainingBalance > 0 && m.Status != CreditMemoStatus.Voided ? "text-success fw-semibold" : "")">
|
||||
@m.RemainingBalance.ToString("C")
|
||||
</td>
|
||||
<td>@m.IssueDate.ToLocalTime().ToString("MM/dd/yyyy")</td>
|
||||
<td class="@(expired ? "text-danger fw-semibold" : "")">
|
||||
@(m.ExpiryDate.HasValue ? m.ExpiryDate.Value.ToLocalTime().ToString("MM/dd/yyyy") : "—")
|
||||
@if (expired) { <small>(Expired)</small> }
|
||||
</td>
|
||||
<td>
|
||||
@{
|
||||
var (badgeClass, badgeLabel) = m.Status switch
|
||||
{
|
||||
CreditMemoStatus.Active => ("bg-success-subtle text-success", "Active"),
|
||||
CreditMemoStatus.PartiallyApplied => ("bg-warning-subtle text-warning", "Partial"),
|
||||
CreditMemoStatus.FullyApplied => ("bg-secondary-subtle text-secondary", "Applied"),
|
||||
CreditMemoStatus.Voided => ("bg-danger-subtle text-danger", "Voided"),
|
||||
_ => ("bg-secondary-subtle text-secondary", m.Status.ToString())
|
||||
};
|
||||
}
|
||||
<span class="badge @badgeClass">@badgeLabel</span>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<a asp-action="Details" asp-route-id="@m.Id"
|
||||
class="btn btn-sm btn-outline-primary">Details</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user