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:
2026-05-14 20:09:22 -04:00
parent 3eda91f170
commit 4ec55e7290
240 changed files with 73116 additions and 0 deletions
@@ -0,0 +1,203 @@
@model PowderCoating.Core.Entities.JournalEntry
@using PowderCoating.Core.Enums
@{
ViewData["Title"] = $"Journal Entry {Model.EntryNumber}";
var accountMap = ViewBag.AccountMap as Dictionary<int, string> ?? new Dictionary<int, string>();
bool isPosted = Model.Status == JournalEntryStatus.Posted;
bool isDraft = Model.Status == JournalEntryStatus.Draft;
bool isReversed = Model.Status == JournalEntryStatus.Reversed;
bool alreadyReversed = ViewBag.ReversalEntryNumber != null;
}
<div class="d-flex align-items-center mb-3 gap-2 flex-wrap">
<a asp-action="Index" class="btn btn-sm btn-outline-secondary">
<i class="bi bi-arrow-left me-1"></i>Back
</a>
<h4 class="mb-0 fw-semibold ms-2">@Model.EntryNumber</h4>
@if (isDraft)
{
<span class="badge bg-warning text-dark ms-1 fs-6">Draft</span>
}
else if (isPosted)
{
<span class="badge bg-success ms-1 fs-6">Posted</span>
}
else
{
<span class="badge bg-secondary ms-1 fs-6">Reversed</span>
}
@if (Model.IsReversal)
{
<span class="badge bg-secondary ms-1">Reversal of @ViewBag.ReversalOfNumber</span>
}
<div class="ms-auto d-flex gap-2">
@if (isDraft)
{
<form asp-action="Post" asp-route-id="@Model.Id" method="post" class="d-inline">
@Html.AntiForgeryToken()
<button type="submit" class="btn btn-sm btn-success"
onclick="return confirm('Post this journal entry to the GL? This cannot be undone.')">
<i class="bi bi-check-circle me-1"></i>Post to GL
</button>
</form>
<form asp-action="Delete" asp-route-id="@Model.Id" method="post" class="d-inline">
@Html.AntiForgeryToken()
<button type="submit" class="btn btn-sm btn-outline-danger"
onclick="return confirm('Delete this draft entry?')">
<i class="bi bi-trash me-1"></i>Delete
</button>
</form>
}
@if (isPosted && !alreadyReversed)
{
<form asp-action="Reverse" asp-route-id="@Model.Id" method="post" class="d-inline">
@Html.AntiForgeryToken()
<button type="submit" class="btn btn-sm btn-outline-warning"
onclick="return confirm('Create a reversal entry for @Model.EntryNumber? This will immediately post the reversal.')">
<i class="bi bi-arrow-counterclockwise me-1"></i>Reverse
</button>
</form>
}
@if (alreadyReversed)
{
<a asp-action="Details" asp-route-id="@ViewBag.ReversalEntryId" class="btn btn-sm btn-outline-secondary">
View Reversal (@ViewBag.ReversalEntryNumber)
</a>
}
</div>
</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>
}
<div class="row g-3 mb-3">
<div class="col-md-8">
<div class="card shadow-sm h-100">
<div class="card-body">
<dl class="row mb-0">
<dt class="col-4 text-muted">Entry Number</dt>
<dd class="col-8 fw-semibold">@Model.EntryNumber</dd>
<dt class="col-4 text-muted">Date</dt>
<dd class="col-8">@Model.EntryDate.ToString("MMMM d, yyyy")</dd>
@if (!string.IsNullOrWhiteSpace(Model.Reference))
{
<dt class="col-4 text-muted">Reference</dt>
<dd class="col-8">@Model.Reference</dd>
}
@if (!string.IsNullOrWhiteSpace(Model.Description))
{
<dt class="col-4 text-muted">Description</dt>
<dd class="col-8">@Model.Description</dd>
}
</dl>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card shadow-sm h-100">
<div class="card-body">
<dl class="row mb-0">
@if (isPosted && Model.PostedAt.HasValue)
{
<dt class="col-5 text-muted">Posted</dt>
<dd class="col-7 small">
@Model.PostedAt.Value.ToLocalTime().ToString("MMM d, yyyy h:mm tt")<br />
<span class="text-muted">by @(Model.PostedBy ?? "—")</span>
</dd>
}
<dt class="col-5 text-muted">Created</dt>
<dd class="col-7 small">@Model.CreatedAt.ToLocalTime().ToString("MMM d, yyyy")</dd>
</dl>
</div>
</div>
</div>
</div>
<div class="card shadow-sm">
<div class="card-header d-flex align-items-center">
<span class="fw-semibold">Lines</span>
@{
var totalDebits = Model.Lines.Sum(l => l.DebitAmount);
var totalCredits = Model.Lines.Sum(l => l.CreditAmount);
bool balanced = totalDebits == totalCredits;
}
<div class="ms-auto small">
<span class="me-3">Debits: <strong>@totalDebits.ToString("C")</strong></span>
<span class="me-3">Credits: <strong>@totalCredits.ToString("C")</strong></span>
@if (balanced)
{
<span class="badge bg-success">Balanced</span>
}
else
{
<span class="badge bg-danger">Out of Balance</span>
}
</div>
</div>
<div class="card-body p-0">
<table class="table table-sm mb-0">
<thead class="table-light">
<tr>
<th>Account</th>
<th>Description</th>
<th class="text-end">Debit</th>
<th class="text-end">Credit</th>
</tr>
</thead>
<tbody>
@foreach (var line in Model.Lines.OrderBy(l => l.LineOrder))
{
<tr>
<td>
@if (accountMap.TryGetValue(line.AccountId, out var accountName))
{
@accountName
}
else
{
<span class="text-muted">#@line.AccountId</span>
}
</td>
<td class="text-muted small">@line.Description</td>
<td class="text-end">
@if (line.DebitAmount > 0)
{
@line.DebitAmount.ToString("C")
}
</td>
<td class="text-end">
@if (line.CreditAmount > 0)
{
@line.CreditAmount.ToString("C")
}
</td>
</tr>
}
</tbody>
<tfoot class="table-light fw-semibold">
<tr>
<td colspan="2" class="text-end">Totals</td>
<td class="text-end">@totalDebits.ToString("C")</td>
<td class="text-end">@totalCredits.ToString("C")</td>
</tr>
</tfoot>
</table>
</div>
</div>