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,164 @@
|
||||
@using PowderCoating.Web.Controllers
|
||||
@model BudgetCreateVm
|
||||
|
||||
@{
|
||||
ViewData["Title"] = $"Edit Budget — {Model.Name}";
|
||||
ViewData["PageIcon"] = "bi-pencil";
|
||||
var months = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||
}
|
||||
|
||||
<div class="mb-4 d-flex justify-content-between align-items-center">
|
||||
<a asp-action="Index" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left me-1"></i>Back to Budgets
|
||||
</a>
|
||||
<a asp-controller="Reports" asp-action="BudgetVsActual" asp-route-budgetId="@Model.Id" class="btn btn-outline-primary btn-sm">
|
||||
<i class="bi bi-bar-chart-line me-1"></i>View Budget vs. Actual
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<form asp-action="Edit" asp-route-id="@Model.Id" method="post" id="budgetForm">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<input type="hidden" asp-for="FiscalYear" />
|
||||
|
||||
<div class="card border-0 shadow-sm mb-4">
|
||||
<div class="card-header bg-white border-0 py-3">
|
||||
<h5 class="mb-0 fw-semibold">
|
||||
<i class="bi bi-pie-chart me-2 text-primary"></i>@Model.Name — @Model.FiscalYear
|
||||
</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-5">
|
||||
<label class="form-label">Budget Name <span class="text-danger">*</span></label>
|
||||
<input asp-for="Name" class="form-control" required />
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Notes</label>
|
||||
<input asp-for="Notes" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-3 d-flex align-items-end">
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input asp-for="IsDefault" class="form-check-input" type="checkbox" />
|
||||
<label asp-for="IsDefault" class="form-check-label">Make this the default budget for @Model.FiscalYear</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card border-0 shadow-sm mb-4">
|
||||
<div class="card-header bg-white border-0 py-3 d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0 fw-semibold"><i class="bi bi-table me-2 text-primary"></i>Monthly Amounts by Account</h5>
|
||||
<div class="d-flex gap-2">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="fillEvenlyBtn">
|
||||
<i class="bi bi-distribute-horizontal me-1"></i>Spread Annual Evenly
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-info alert-permanent py-2 mx-3 mt-3 mb-0 small">
|
||||
<i class="bi bi-info-circle me-1"></i>
|
||||
Enter monthly amounts for each Revenue and Expense account. Leave a row at zero to exclude that account from the budget. Amounts represent expected <strong>activity</strong> for the period (not running totals).
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-hover align-middle mb-0" id="budgetTable">
|
||||
<thead class="table-light sticky-top">
|
||||
<tr>
|
||||
<th style="min-width:200px">Account</th>
|
||||
<th class="text-end" style="min-width:80px">Annual</th>
|
||||
@foreach (var m in months)
|
||||
{
|
||||
<th class="text-end" style="min-width:75px">@m</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@{
|
||||
var revLines = Model.Lines.Where(l => l.AccountType == PowderCoating.Core.Enums.AccountType.Revenue).ToList();
|
||||
var expLines = Model.Lines.Where(l => l.AccountType != PowderCoating.Core.Enums.AccountType.Revenue).ToList();
|
||||
var fieldNames = new[] { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" };
|
||||
}
|
||||
|
||||
@if (revLines.Any())
|
||||
{
|
||||
<tr class="table-success">
|
||||
<td colspan="14" class="fw-semibold py-1 ps-3 small">REVENUE</td>
|
||||
</tr>
|
||||
@for (int i = 0; i < Model.Lines.Count; i++)
|
||||
{
|
||||
var line = Model.Lines[i];
|
||||
if (line.AccountType != PowderCoating.Core.Enums.AccountType.Revenue) continue;
|
||||
var values = new decimal[] { line.Jan, line.Feb, line.Mar, line.Apr, line.May, line.Jun, line.Jul, line.Aug, line.Sep, line.Oct, line.Nov, line.Dec };
|
||||
<tr data-row-idx="@i">
|
||||
<td>
|
||||
<input type="hidden" name="Lines[@i].AccountId" value="@line.AccountId" />
|
||||
<input type="hidden" name="Lines[@i].AccountNumber" value="@line.AccountNumber" />
|
||||
<input type="hidden" name="Lines[@i].AccountName" value="@line.AccountName" />
|
||||
<input type="hidden" name="Lines[@i].AccountType" value="@((int)line.AccountType)" />
|
||||
<span class="fw-semibold text-nowrap">@line.AccountNumber</span>
|
||||
<span class="text-muted ms-1">@line.AccountName</span>
|
||||
</td>
|
||||
<td class="text-end"><span class="annual-total fw-semibold text-success" data-row="@i">@line.Annual.ToString("N2")</span></td>
|
||||
@for (int m = 0; m < 12; m++)
|
||||
{
|
||||
<td class="text-end p-0">
|
||||
<input type="number" name="Lines[@i].@fieldNames[m]"
|
||||
value="@values[m].ToString("F2", System.Globalization.CultureInfo.InvariantCulture)"
|
||||
class="form-control form-control-sm text-end border-0 budget-cell"
|
||||
step="0.01" min="0" data-row="@i" style="min-width:70px" />
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
|
||||
@if (expLines.Any())
|
||||
{
|
||||
<tr class="table-danger">
|
||||
<td colspan="14" class="fw-semibold py-1 ps-3 small">EXPENSE</td>
|
||||
</tr>
|
||||
@for (int i = 0; i < Model.Lines.Count; i++)
|
||||
{
|
||||
var line = Model.Lines[i];
|
||||
if (line.AccountType == PowderCoating.Core.Enums.AccountType.Revenue) continue;
|
||||
var values = new decimal[] { line.Jan, line.Feb, line.Mar, line.Apr, line.May, line.Jun, line.Jul, line.Aug, line.Sep, line.Oct, line.Nov, line.Dec };
|
||||
<tr data-row-idx="@i">
|
||||
<td>
|
||||
<input type="hidden" name="Lines[@i].AccountId" value="@line.AccountId" />
|
||||
<input type="hidden" name="Lines[@i].AccountNumber" value="@line.AccountNumber" />
|
||||
<input type="hidden" name="Lines[@i].AccountName" value="@line.AccountName" />
|
||||
<input type="hidden" name="Lines[@i].AccountType" value="@((int)line.AccountType)" />
|
||||
<span class="fw-semibold text-nowrap">@line.AccountNumber</span>
|
||||
<span class="text-muted ms-1">@line.AccountName</span>
|
||||
</td>
|
||||
<td class="text-end"><span class="annual-total fw-semibold text-danger" data-row="@i">@line.Annual.ToString("N2")</span></td>
|
||||
@for (int m = 0; m < 12; m++)
|
||||
{
|
||||
<td class="text-end p-0">
|
||||
<input type="number" name="Lines[@i].@fieldNames[m]"
|
||||
value="@values[m].ToString("F2", System.Globalization.CultureInfo.InvariantCulture)"
|
||||
class="form-control form-control-sm text-end border-0 budget-cell"
|
||||
step="0.01" min="0" data-row="@i" style="min-width:70px" />
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-check-lg me-2"></i>Save Changes
|
||||
</button>
|
||||
<a asp-action="Index" class="btn btn-outline-secondary">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
<script src="~/js/budget-edit.js" asp-append-version="true"></script>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
@using PowderCoating.Core.Entities
|
||||
@model List<Budget>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Budgets";
|
||||
ViewData["PageIcon"] = "bi-pie-chart";
|
||||
var byYear = Model.GroupBy(b => b.FiscalYear).OrderByDescending(g => g.Key).ToList();
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div></div>
|
||||
<div class="d-flex gap-2">
|
||||
<a asp-controller="Reports" asp-action="BudgetVsActual" class="btn btn-outline-primary">
|
||||
<i class="bi bi-bar-chart-line me-2"></i>Budget vs. Actual Report
|
||||
</a>
|
||||
<a asp-action="Create" class="btn btn-primary">
|
||||
<i class="bi bi-plus-circle me-2"></i>New Budget
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (TempData["Success"] != null)
|
||||
{
|
||||
<div class="alert alert-success alert-permanent alert-dismissible fade show" role="alert">
|
||||
<i class="bi bi-check-circle me-2"></i>@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" role="alert">
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>@TempData["Error"]
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!Model.Any())
|
||||
{
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-body text-center text-muted py-5">
|
||||
<i class="bi bi-pie-chart display-4 d-block mb-3 opacity-25"></i>
|
||||
<p class="mb-0">No budgets yet. <a asp-action="Create">Create your first budget</a> to start tracking variance against actual results.</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
@foreach (var group in byYear)
|
||||
{
|
||||
<div class="card border-0 shadow-sm mb-4">
|
||||
<div class="card-header bg-white border-0 py-3 d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0 fw-semibold"><i class="bi bi-calendar3 me-2 text-primary"></i>Fiscal Year @group.Key</h5>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Budget Name</th>
|
||||
<th class="text-center">Lines</th>
|
||||
<th class="text-end">Total Revenue Budget</th>
|
||||
<th class="text-end">Total Expense Budget</th>
|
||||
<th class="text-center">Default</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var b in group.OrderBy(b => b.Name))
|
||||
{
|
||||
var revLines = b.Lines.Where(l => l.Account?.AccountType == PowderCoating.Core.Enums.AccountType.Revenue);
|
||||
var expLines = b.Lines.Where(l => l.Account?.AccountType == PowderCoating.Core.Enums.AccountType.Expense);
|
||||
<tr>
|
||||
<td class="fw-semibold">
|
||||
@b.Name
|
||||
@if (!string.IsNullOrWhiteSpace(b.Notes))
|
||||
{
|
||||
<div class="text-muted small">@b.Notes</div>
|
||||
}
|
||||
</td>
|
||||
<td class="text-center">@b.Lines.Count</td>
|
||||
<td class="text-end text-success">@b.Lines.Sum(l => l.Annual).ToString("C")</td>
|
||||
<td class="text-end text-danger">—</td>
|
||||
<td class="text-center">
|
||||
@if (b.IsDefault)
|
||||
{
|
||||
<span class="badge bg-primary">Default</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form asp-action="SetDefault" asp-route-id="@b.Id" method="post" class="d-inline">
|
||||
@Html.AntiForgeryToken()
|
||||
<button type="submit" class="btn btn-sm btn-outline-secondary">Set Default</button>
|
||||
</form>
|
||||
}
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<div class="d-flex gap-1 justify-content-end">
|
||||
<a asp-action="Edit" asp-route-id="@b.Id" class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary"
|
||||
data-bs-toggle="modal" data-bs-target="#copyModal"
|
||||
data-budget-id="@b.Id" data-budget-name="@b.Name">
|
||||
<i class="bi bi-copy"></i>
|
||||
</button>
|
||||
<form asp-action="Delete" asp-route-id="@b.Id" method="post" class="d-inline"
|
||||
onsubmit="return confirm('Delete budget "@b.Name"? This cannot be undone.')">
|
||||
@Html.AntiForgeryToken()
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
<!-- Copy Modal -->
|
||||
<div class="modal fade" id="copyModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="bi bi-copy me-2"></i>Copy Budget</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<form asp-action="Copy" method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" name="id" id="copyBudgetId" />
|
||||
<div class="modal-body">
|
||||
<p>Copy <strong id="copyBudgetName"></strong> to a new fiscal year as a starting point.</p>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">New Fiscal Year</label>
|
||||
<input type="number" name="newYear" class="form-control" value="@(DateTime.Now.Year + 1)" min="2000" max="2099" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary"><i class="bi bi-copy me-2"></i>Copy Budget</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script src="~/js/budget-index.js" asp-append-version="true"></script>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user