Phase F: Add Invoice Write-Off, Fixed Assets, Period Locking, and 1099 Tracking

- Invoice Write-Off: WriteOff POST action in InvoicesController posts bad-debt JE
  (DR bad debt expense / CR AR), reduces customer balance, marks invoice WrittenOff;
  write-off modal added to Invoice Details view with expense account selector
- Fixed Assets: FixedAsset + FixedAssetDepreciationEntry entities with straight-line
  depreciation; FixedAssetsController (Index/Create/Edit/Details/PostDepreciation/Delete);
  PostDepreciation auto-generates one JE per asset per period, skips already-posted,
  fully-depreciated, and disposed assets; full CRUD views + nav link
- Period Locking: Company.BookLockedThrough field; AccountingPeriodValidator static helper;
  lock check added to JE Post and Bill Create (blocks backdating into closed periods);
  SetPeriodLock action + date picker UI in Company Settings Accounting section
- 1099 Tracking: Is1099Vendor flag on Vendor entity + DTOs; checkbox in Create/Edit views;
  TaxReporting1099 report action + view lists payments by year, flags vendors >= $600;
  report card added to Reports Landing
- Migration AddFixedAssetsLockAnd1099 applied

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-10 12:19:32 -04:00
parent a255893ada
commit fde24b09c9
29 changed files with 12520 additions and 3 deletions
@@ -0,0 +1,125 @@
@{
ViewData["Title"] = "Add Fixed Asset";
ViewData["PageIcon"] = "bi-plus-circle";
}
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="mb-4">
<a asp-action="Index" class="btn btn-outline-secondary btn-sm">
<i class="bi bi-arrow-left me-1"></i>Back to Asset Register
</a>
</div>
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-building-gear me-2 text-primary"></i>New Fixed Asset</h5>
</div>
<div class="card-body">
<form asp-action="Create" method="post">
@Html.AntiForgeryToken()
<!-- Asset Info -->
<h6 class="border-bottom pb-2 mb-3 text-muted">Asset Information</h6>
<div class="row g-3 mb-4">
<div class="col-12">
<label class="form-label">Asset Name <span class="text-danger">*</span></label>
<input type="text" name="Name" class="form-control" maxlength="200" required placeholder="e.g., Blast Cabinet #2, Paint Oven A" />
</div>
<div class="col-12">
<label class="form-label">Description</label>
<input type="text" name="Description" class="form-control" maxlength="1000" placeholder="Optional notes about this asset" />
</div>
<div class="col-md-4">
<label class="form-label">Purchase Date <span class="text-danger">*</span></label>
<input type="date" name="PurchaseDate" class="form-control" value="@DateTime.Today.ToString("yyyy-MM-dd")" required />
</div>
<div class="col-md-4">
<label class="form-label">Purchase Cost <span class="text-danger">*</span></label>
<div class="input-group">
<span class="input-group-text">$</span>
<input type="number" name="PurchaseCost" class="form-control" step="0.01" min="0.01" required placeholder="0.00" />
</div>
</div>
<div class="col-md-4">
<label class="form-label">Salvage Value</label>
<div class="input-group">
<span class="input-group-text">$</span>
<input type="number" name="SalvageValue" class="form-control" step="0.01" min="0" value="0" placeholder="0.00" />
</div>
<div class="form-text">Estimated residual value at end of useful life.</div>
</div>
<div class="col-md-4">
<label class="form-label">Useful Life (months) <span class="text-danger">*</span></label>
<input type="number" name="UsefulLifeMonths" class="form-control" min="1" max="600" value="60" required />
<div class="form-text">60 = 5 years, 120 = 10 years, etc.</div>
</div>
<div class="col-md-4">
<label class="form-label">Prior Accumulated Depreciation</label>
<div class="input-group">
<span class="input-group-text">$</span>
<input type="number" name="AccumulatedDepreciation" class="form-control" step="0.01" min="0" value="0" placeholder="0.00" />
</div>
<div class="form-text">Set if the asset was partially depreciated before being added here.</div>
</div>
</div>
<!-- GL Accounts -->
<h6 class="border-bottom pb-2 mb-3 text-muted">GL Account Mapping</h6>
<div class="row g-3 mb-4">
<div class="col-md-4">
<label class="form-label">Asset Account</label>
<select name="AssetAccountId" class="form-select">
<option value="">— None —</option>
@if (ViewBag.AssetAccounts != null)
{
@foreach (var item in (IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)ViewBag.AssetAccounts)
{
<option value="@item.Value">@item.Text</option>
}
}
</select>
<div class="form-text">Balance sheet asset account (e.g., 1500 Equipment).</div>
</div>
<div class="col-md-4">
<label class="form-label">Depreciation Expense Account</label>
<select name="DepreciationExpenseAccountId" class="form-select">
<option value="">— None —</option>
@if (ViewBag.ExpenseAccounts != null)
{
@foreach (var item in (IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)ViewBag.ExpenseAccounts)
{
<option value="@item.Value">@item.Text</option>
}
}
</select>
<div class="form-text">P&amp;L expense account (e.g., 6200 Depreciation Expense).</div>
</div>
<div class="col-md-4">
<label class="form-label">Accumulated Depreciation Account</label>
<select name="AccumDepreciationAccountId" class="form-select">
<option value="">— None —</option>
@if (ViewBag.AccumDeprecAccounts != null)
{
@foreach (var item in (IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)ViewBag.AccumDeprecAccounts)
{
<option value="@item.Value">@item.Text</option>
}
}
</select>
<div class="form-text">Contra-asset account (e.g., 1510 Accum. Depreciation — Equipment).</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>Add Asset
</button>
<a asp-action="Index" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
@@ -0,0 +1,222 @@
@using PowderCoating.Core.Entities
@model FixedAsset
@{
ViewData["Title"] = Model.Name;
ViewData["PageIcon"] = "bi-building-gear";
var fullyDeprec = Model.AccumulatedDepreciation >= (Model.PurchaseCost - Model.SalvageValue);
var depreciableBase = Model.PurchaseCost - Model.SalvageValue;
var progress = depreciableBase > 0
? (double)(Model.AccumulatedDepreciation / depreciableBase) * 100
: 100;
var entries = ViewBag.Entries as List<FixedAssetDepreciationEntry> ?? new();
var monthsRemaining = (int)(ViewBag.MonthsRemaining ?? 0);
}
<div class="d-flex justify-content-between align-items-center mb-4">
<a asp-action="Index" class="btn btn-outline-secondary btn-sm">
<i class="bi bi-arrow-left me-1"></i>Asset Register
</a>
<div class="d-flex gap-2">
@if (!Model.IsDisposed)
{
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-outline-primary btn-sm">
<i class="bi bi-pencil me-1"></i>Edit
</a>
}
<form asp-action="Delete" asp-route-id="@Model.Id" method="post"
onsubmit="return confirm('Delete this asset? This cannot be undone. Assets with depreciation history cannot be deleted.')">
@Html.AntiForgeryToken()
<button type="submit" class="btn btn-outline-danger btn-sm">
<i class="bi bi-trash me-1"></i>Delete
</button>
</form>
</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>
}
<div class="row g-4">
<!-- Left Column -->
<div class="col-lg-4">
<!-- Asset Details Card -->
<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-building-gear me-2 text-primary"></i>@Model.Name
</h5>
</div>
<div class="card-body">
@if (!string.IsNullOrWhiteSpace(Model.Description))
{
<p class="text-muted">@Model.Description</p>
}
<div class="mb-3">
@if (Model.IsDisposed)
{
<span class="badge bg-secondary fs-6">Disposed</span>
@if (Model.DisposalDate.HasValue)
{
<div class="text-muted small mt-1">Disposed @Model.DisposalDate.Value.ToLocalTime().ToString("MM/dd/yyyy")</div>
}
}
else if (fullyDeprec)
{
<span class="badge bg-light text-dark border fs-6">Fully Depreciated</span>
}
else
{
<span class="badge bg-success fs-6">Active</span>
<div class="text-muted small mt-1">@monthsRemaining month@(monthsRemaining == 1 ? "" : "s") remaining</div>
}
</div>
<table class="table table-sm table-borderless mb-0">
<tr>
<td class="text-muted ps-0">Purchase Date</td>
<td class="text-end fw-semibold">@Model.PurchaseDate.ToLocalTime().ToString("MM/dd/yyyy")</td>
</tr>
<tr>
<td class="text-muted ps-0">Purchase Cost</td>
<td class="text-end fw-semibold">@Model.PurchaseCost.ToString("C")</td>
</tr>
<tr>
<td class="text-muted ps-0">Salvage Value</td>
<td class="text-end">@Model.SalvageValue.ToString("C")</td>
</tr>
<tr>
<td class="text-muted ps-0">Useful Life</td>
<td class="text-end">@Model.UsefulLifeMonths months</td>
</tr>
<tr>
<td class="text-muted ps-0">Monthly Depreciation</td>
<td class="text-end">@Model.MonthlyDepreciation.ToString("C")</td>
</tr>
</table>
</div>
</div>
<!-- Book Value Card -->
<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-bar-chart me-2 text-primary"></i>Book Value</h5>
</div>
<div class="card-body">
<div class="d-flex justify-content-between mb-1">
<span class="text-muted">Accumulated Depreciation</span>
<span class="text-danger fw-semibold">@Model.AccumulatedDepreciation.ToString("C")</span>
</div>
<div class="progress mb-3" style="height:8px;">
<div class="progress-bar bg-danger" style="width: @progress.ToString("F1")%"></div>
</div>
<div class="d-flex justify-content-between border-top pt-2">
<span class="fw-semibold">Book Value</span>
<span class="fw-bold fs-5 @(Model.BookValue <= 0 ? "text-muted" : "text-success")">@Model.BookValue.ToString("C")</span>
</div>
</div>
</div>
<!-- GL Accounts Card -->
@if (Model.AssetAccount != null || Model.DepreciationExpenseAccount != null || Model.AccumDepreciationAccount != null)
{
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-diagram-3 me-2 text-primary"></i>GL Accounts</h5>
</div>
<div class="card-body">
@if (Model.AssetAccount != null)
{
<div class="mb-2">
<div class="text-muted small">Asset Account</div>
<div class="fw-semibold">@Model.AssetAccount.AccountNumber @Model.AssetAccount.Name</div>
</div>
}
@if (Model.DepreciationExpenseAccount != null)
{
<div class="mb-2">
<div class="text-muted small">Depreciation Expense</div>
<div class="fw-semibold">@Model.DepreciationExpenseAccount.AccountNumber @Model.DepreciationExpenseAccount.Name</div>
</div>
}
@if (Model.AccumDepreciationAccount != null)
{
<div>
<div class="text-muted small">Accumulated Depreciation</div>
<div class="fw-semibold">@Model.AccumDepreciationAccount.AccountNumber @Model.AccumDepreciationAccount.Name</div>
</div>
}
</div>
</div>
}
</div>
<!-- Right Column: Depreciation History -->
<div class="col-lg-8">
<div class="card border-0 shadow-sm">
<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-clock-history me-2 text-primary"></i>Depreciation History</h5>
<span class="badge bg-light text-dark border">@entries.Count period@(entries.Count == 1 ? "" : "s") posted</span>
</div>
<div class="card-body p-0">
@if (!entries.Any())
{
<div class="text-center text-muted py-5">
<i class="bi bi-calendar-x display-4 d-block mb-3 opacity-25"></i>
<p>No depreciation posted yet. Use the <strong>Post Monthly Depreciation</strong> button on the <a asp-action="Index">Asset Register</a>.</p>
</div>
}
else
{
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light">
<tr>
<th>Period</th>
<th class="text-end">Amount</th>
<th>Journal Entry</th>
<th>Posted</th>
</tr>
</thead>
<tbody>
@foreach (var e in entries)
{
<tr>
<td>@(new DateTime(e.PeriodYear, e.PeriodMonth, 1).ToString("MMMM yyyy"))</td>
<td class="text-end text-danger">@e.Amount.ToString("C")</td>
<td>
@if (e.JournalEntry != null)
{
<a asp-controller="JournalEntries" asp-action="Details" asp-route-id="@e.JournalEntryId">
@e.JournalEntry.EntryNumber
</a>
}
else
{
<span class="text-muted">—</span>
}
</td>
<td class="text-muted small">@e.CreatedAt.ToLocalTime().ToString("MM/dd/yyyy")</td>
</tr>
}
</tbody>
</table>
</div>
}
</div>
</div>
</div>
</div>
@@ -0,0 +1,145 @@
@model PowderCoating.Web.Controllers.FixedAssetVm
@{
ViewData["Title"] = "Edit Fixed Asset";
ViewData["PageIcon"] = "bi-pencil";
}
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="mb-4">
<a asp-action="Details" asp-route-id="@Model.Id" class="btn btn-outline-secondary btn-sm">
<i class="bi bi-arrow-left me-1"></i>Back to Asset
</a>
</div>
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-pencil me-2 text-primary"></i>Edit @Model.Name</h5>
</div>
<div class="card-body">
<form asp-action="Edit" asp-route-id="@Model.Id" method="post">
@Html.AntiForgeryToken()
<input type="hidden" asp-for="Id" />
<!-- Asset Info -->
<h6 class="border-bottom pb-2 mb-3 text-muted">Asset Information</h6>
<div class="row g-3 mb-4">
<div class="col-12">
<label asp-for="Name" class="form-label">Asset Name <span class="text-danger">*</span></label>
<input asp-for="Name" class="form-control" maxlength="200" required />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<div class="col-12">
<label asp-for="Description" class="form-label">Description</label>
<input asp-for="Description" class="form-control" maxlength="1000" />
</div>
<div class="col-md-4">
<label asp-for="PurchaseDate" class="form-label">Purchase Date <span class="text-danger">*</span></label>
<input asp-for="PurchaseDate" type="date" class="form-control" required />
<span asp-validation-for="PurchaseDate" class="text-danger"></span>
</div>
<div class="col-md-4">
<label asp-for="PurchaseCost" class="form-label">Purchase Cost <span class="text-danger">*</span></label>
<div class="input-group">
<span class="input-group-text">$</span>
<input asp-for="PurchaseCost" type="number" step="0.01" min="0.01" class="form-control" />
</div>
<span asp-validation-for="PurchaseCost" class="text-danger"></span>
</div>
<div class="col-md-4">
<label asp-for="SalvageValue" class="form-label">Salvage Value</label>
<div class="input-group">
<span class="input-group-text">$</span>
<input asp-for="SalvageValue" type="number" step="0.01" min="0" class="form-control" />
</div>
</div>
<div class="col-md-4">
<label asp-for="UsefulLifeMonths" class="form-label">Useful Life (months) <span class="text-danger">*</span></label>
<input asp-for="UsefulLifeMonths" type="number" min="1" max="600" class="form-control" />
<span asp-validation-for="UsefulLifeMonths" class="text-danger"></span>
</div>
<div class="col-md-4">
<label asp-for="AccumulatedDepreciation" class="form-label">Accumulated Depreciation</label>
<div class="input-group">
<span class="input-group-text">$</span>
<input asp-for="AccumulatedDepreciation" type="number" step="0.01" min="0" class="form-control" />
</div>
</div>
</div>
<!-- GL Accounts -->
<h6 class="border-bottom pb-2 mb-3 text-muted">GL Account Mapping</h6>
<div class="row g-3 mb-4">
<div class="col-md-4">
<label asp-for="AssetAccountId" class="form-label">Asset Account</label>
<select asp-for="AssetAccountId" class="form-select">
<option value="">— None —</option>
@if (ViewBag.AssetAccounts != null)
{
@foreach (var item in (IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)ViewBag.AssetAccounts)
{
<option value="@item.Value" selected="@(item.Value == Model.AssetAccountId?.ToString() ? "selected" : null)">@item.Text</option>
}
}
</select>
</div>
<div class="col-md-4">
<label asp-for="DepreciationExpenseAccountId" class="form-label">Depreciation Expense Account</label>
<select asp-for="DepreciationExpenseAccountId" class="form-select">
<option value="">— None —</option>
@if (ViewBag.ExpenseAccounts != null)
{
@foreach (var item in (IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)ViewBag.ExpenseAccounts)
{
<option value="@item.Value" selected="@(item.Value == Model.DepreciationExpenseAccountId?.ToString() ? "selected" : null)">@item.Text</option>
}
}
</select>
</div>
<div class="col-md-4">
<label asp-for="AccumDepreciationAccountId" class="form-label">Accumulated Depreciation Account</label>
<select asp-for="AccumDepreciationAccountId" class="form-select">
<option value="">— None —</option>
@if (ViewBag.AccumDeprecAccounts != null)
{
@foreach (var item in (IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)ViewBag.AccumDeprecAccounts)
{
<option value="@item.Value" selected="@(item.Value == Model.AccumDepreciationAccountId?.ToString() ? "selected" : null)">@item.Text</option>
}
}
</select>
</div>
</div>
<!-- Disposal -->
<h6 class="border-bottom pb-2 mb-3 text-muted">Disposal</h6>
<div class="row g-3 mb-4">
<div class="col-md-4">
<div class="form-check form-switch mt-2">
<input asp-for="IsDisposed" class="form-check-input" type="checkbox" id="isDisposed" />
<label asp-for="IsDisposed" class="form-check-label">Mark as Disposed</label>
</div>
</div>
<div class="col-md-4" id="disposalDateField" style="@(Model.IsDisposed ? "" : "display:none")">
<label asp-for="DisposalDate" class="form-label">Disposal Date</label>
<input asp-for="DisposalDate" type="date" class="form-control" />
</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="Details" asp-route-id="@Model.Id" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
@section Scripts {
<script src="~/js/fixed-asset-edit.js" asp-append-version="true"></script>
}
@@ -0,0 +1,186 @@
@using PowderCoating.Core.Entities
@model List<FixedAsset>
@{
ViewData["Title"] = "Fixed Assets";
ViewData["PageIcon"] = "bi-building-gear";
var now = DateTime.Now;
}
<div class="d-flex justify-content-between align-items-center mb-4">
<div></div>
<div class="d-flex gap-2">
<a asp-action="Create" class="btn btn-primary">
<i class="bi bi-plus-circle me-2"></i>Add Asset
</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>
}
<!-- Summary Cards -->
<div class="row g-3 mb-4">
<div class="col-md-3">
<div class="card border-0 shadow-sm text-center">
<div class="card-body py-3">
<div class="text-muted small">Active Assets</div>
<div class="fs-3 fw-bold text-primary">@ViewBag.ActiveCount</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-0 shadow-sm text-center">
<div class="card-body py-3">
<div class="text-muted small">Total Cost</div>
<div class="fs-3 fw-bold">@((ViewBag.TotalCost as decimal? ?? 0).ToString("C"))</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-0 shadow-sm text-center">
<div class="card-body py-3">
<div class="text-muted small">Accum. Depreciation</div>
<div class="fs-3 fw-bold text-danger">@((ViewBag.TotalAccumDeprec as decimal? ?? 0).ToString("C"))</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-0 shadow-sm text-center">
<div class="card-body py-3">
<div class="text-muted small">Total Book Value</div>
<div class="fs-3 fw-bold text-success">@((ViewBag.TotalBookValue as decimal? ?? 0).ToString("C"))</div>
</div>
</div>
</div>
</div>
<!-- Post Depreciation -->
<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-calendar-check me-2 text-primary"></i>Post Monthly Depreciation</h5>
</div>
<div class="card-body">
<form asp-action="PostDepreciation" method="post" class="row g-3 align-items-end">
@Html.AntiForgeryToken()
<div class="col-md-3">
<label class="form-label">Year</label>
<input type="number" name="year" class="form-control" value="@now.Year" min="2000" max="2099" required />
</div>
<div class="col-md-3">
<label class="form-label">Month</label>
<select name="month" class="form-select">
@for (int m = 1; m <= 12; m++)
{
<option value="@m" selected="@(m == now.Month ? "selected" : null)">
@(new DateTime(now.Year, m, 1).ToString("MMMM"))
</option>
}
</select>
</div>
<div class="col-md-3">
<button type="submit" class="btn btn-outline-primary"
onclick="return confirm('Post straight-line depreciation for all active assets for this period? Assets already posted for the period will be skipped.')">
<i class="bi bi-send me-2"></i>Post Depreciation
</button>
</div>
<div class="col-md-3 text-muted small">
Creates one Journal Entry per asset. Fully-depreciated and disposed assets are skipped.
</div>
</form>
</div>
</div>
<!-- Asset Table -->
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 fw-semibold"><i class="bi bi-table me-2 text-primary"></i>Asset Register</h5>
</div>
<div class="card-body p-0">
@if (!Model.Any())
{
<div class="text-center text-muted py-5">
<i class="bi bi-building-gear display-4 d-block mb-3 opacity-25"></i>
<p>No fixed assets yet. <a asp-action="Create">Add your first asset</a> to start tracking depreciation.</p>
</div>
}
else
{
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light">
<tr>
<th>Asset</th>
<th>Purchase Date</th>
<th class="text-end">Cost</th>
<th class="text-end">Salvage Value</th>
<th class="text-center">Life (mo.)</th>
<th class="text-end">Monthly Depr.</th>
<th class="text-end">Accum. Depr.</th>
<th class="text-end">Book Value</th>
<th class="text-center">Status</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var a in Model)
{
var fullyDeprec = a.AccumulatedDepreciation >= (a.PurchaseCost - a.SalvageValue);
<tr>
<td>
<a asp-action="Details" asp-route-id="@a.Id" class="fw-semibold text-decoration-none">
@a.Name
</a>
@if (!string.IsNullOrWhiteSpace(a.Description))
{
<div class="text-muted small">@a.Description</div>
}
</td>
<td>@a.PurchaseDate.ToLocalTime().ToString("MM/dd/yyyy")</td>
<td class="text-end">@a.PurchaseCost.ToString("C")</td>
<td class="text-end">@a.SalvageValue.ToString("C")</td>
<td class="text-center">@a.UsefulLifeMonths</td>
<td class="text-end">@a.MonthlyDepreciation.ToString("C")</td>
<td class="text-end text-danger">@a.AccumulatedDepreciation.ToString("C")</td>
<td class="text-end @(a.BookValue <= 0 ? "text-muted" : "text-success fw-semibold")">
@a.BookValue.ToString("C")
</td>
<td class="text-center">
@if (a.IsDisposed)
{
<span class="badge bg-secondary">Disposed</span>
}
else if (fullyDeprec)
{
<span class="badge bg-light text-dark border">Fully Depreciated</span>
}
else
{
<span class="badge bg-success">Active</span>
}
</td>
<td>
<a asp-action="Details" asp-route-id="@a.Id" class="btn btn-sm btn-outline-secondary">
<i class="bi bi-eye"></i>
</a>
</td>
</tr>
}
</tbody>
</table>
</div>
}
</div>
</div>