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
@@ -211,6 +211,48 @@
</div>
</div>
<!-- Period Lock -->
<div class="row mb-4">
<div class="col-12">
<h6 class="border-bottom pb-2 mb-3 text-muted">Period Locking</h6>
</div>
<div class="col-md-4">
@{
var lockThrough = ViewBag.BookLockedThrough as DateTime?;
}
<label class="form-label">Books Locked Through</label>
@if (lockThrough.HasValue)
{
<div class="input-group">
<span class="input-group-text"><i class="bi bi-lock-fill text-warning"></i></span>
<input type="text" class="form-control" value="@lockThrough.Value.ToString("MMMM d, yyyy")" readonly />
<form asp-action="SetPeriodLock" method="post" class="d-inline">
@Html.AntiForgeryToken()
<button type="submit" class="btn btn-outline-secondary" title="Clear lock">
<i class="bi bi-unlock"></i> Clear
</button>
</form>
</div>
<div class="form-text text-warning">Entries dated on or before this date are blocked.</div>
}
else
{
<div class="text-muted small mb-2">No period lock set — all dates are open.</div>
}
</div>
<div class="col-md-4">
<label class="form-label">Set New Lock Date</label>
<form asp-action="SetPeriodLock" method="post" class="d-flex gap-2">
@Html.AntiForgeryToken()
<input type="date" name="lockThrough" class="form-control" />
<button type="submit" class="btn btn-warning" onclick="return confirm('Lock all accounting periods on or before this date? Users will not be able to post or edit entries in those periods.')">
<i class="bi bi-lock me-1"></i>Lock
</button>
</form>
<div class="form-text">Prevents backdating any GL entry (bills, JEs) into closed periods.</div>
</div>
</div>
<div class="mb-3">
<label for="address" class="form-label">Address</label>
<input type="text" class="form-control" id="address" name="Address" value="@Model.Address" maxlength="200">
@@ -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>
@@ -679,6 +679,13 @@
</button>
</form>
}
@if (!isVoided && Model.BalanceDue > 0)
{
<button type="button" class="btn btn-outline-danger w-100"
data-bs-toggle="modal" data-bs-target="#writeOffModal">
<i class="bi bi-journal-x me-2"></i>Write Off
</button>
}
@if (isDraft)
{
<form asp-action="Delete" asp-route-id="@Model.Id" method="post"
@@ -1308,6 +1315,55 @@
</div>
}
<!-- Write-Off Modal -->
@if (!isVoided && Model.BalanceDue > 0)
{
<div class="modal fade" id="writeOffModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><i class="bi bi-journal-x me-2 text-danger"></i>Write Off Invoice</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<form asp-action="WriteOff" asp-route-id="@Model.Id" method="post">
@Html.AntiForgeryToken()
<div class="modal-body">
<div class="alert alert-warning py-2 mb-3">
<i class="bi bi-exclamation-triangle me-2"></i>
This will write off the remaining balance of <strong>@Model.BalanceDue.ToString("C")</strong>
as bad debt. A GL journal entry will be posted. This action cannot be undone.
</div>
<div class="mb-3">
<label class="form-label">Bad Debt Expense Account</label>
<select name="expenseAccountId" class="form-select">
<option value="">— Use default bad debt account —</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">If blank, the system selects the first account with "bad" or "debt" in the name, or falls back to the first expense account.</div>
</div>
<div class="mb-3">
<label class="form-label">Notes</label>
<textarea name="notes" class="form-control" rows="2" placeholder="Reason for write-off (optional)"></textarea>
</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-danger">
<i class="bi bi-journal-x me-2"></i>Write Off @Model.BalanceDue.ToString("C")
</button>
</div>
</form>
</div>
</div>
</div>
}
@section Scripts {
<script>
function openEditPaymentModal(paymentId, invoiceId, paymentDate, paymentMethod, reference, notes, depositAccountId) {
@@ -212,6 +212,14 @@
<p>Track actual cash in/out across operating, investing, and financing activities with beginning and ending cash balance.</p>
<div class="report-arrow">Open report <i class="bi bi-arrow-right"></i></div>
</a>
<a asp-controller="Reports" asp-action="TaxReporting1099" class="report-card">
<div class="report-card-icon" style="background:#fdf2f8;color:#86198f;">
<i class="bi bi-file-earmark-text"></i>
</div>
<h5>1099-NEC Report</h5>
<p>Payments to 1099-eligible vendors by calendar year — flags those exceeding the $600 reporting threshold.</p>
<div class="report-arrow">Open report <i class="bi bi-arrow-right"></i></div>
</a>
</div>
</div>
}
@@ -0,0 +1,156 @@
@using PowderCoating.Web.Controllers
@model List<Vendor1099Row>
@{
ViewData["Title"] = "1099-NEC Report";
ViewData["PageIcon"] = "bi-file-earmark-text";
var reportYear = (int)ViewBag.ReportYear;
var availableYears = ViewBag.AvailableYears as List<int> ?? new List<int>();
var vendorsOver600 = (int)(ViewBag.VendorsOver600 ?? 0);
}
<!-- Year Selector -->
<div class="d-flex justify-content-between align-items-center mb-4">
<form method="get" asp-action="TaxReporting1099" class="d-flex align-items-center gap-2">
<label class="form-label mb-0 fw-semibold">Year:</label>
<select name="year" class="form-select form-select-sm" style="width:auto;" onchange="this.form.submit()">
@foreach (var y in availableYears)
{
<option value="@y" selected="@(y == reportYear ? "selected" : null)">@y</option>
}
</select>
</form>
<a asp-action="Landing" class="btn btn-outline-secondary btn-sm">
<i class="bi bi-arrow-left me-1"></i>Reports
</a>
</div>
@if (TempData["Error"] != null)
{
<div class="alert alert-danger alert-permanent alert-dismissible fade show">
<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-4">
<div class="card border-0 shadow-sm text-center">
<div class="card-body py-3">
<div class="text-muted small">1099-Eligible Vendors</div>
<div class="fs-3 fw-bold text-primary">@Model.Count</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card border-0 shadow-sm text-center">
<div class="card-body py-3">
<div class="text-muted small">Need 1099-NEC (≥ $600)</div>
<div class="fs-3 fw-bold text-danger">@vendorsOver600</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card border-0 shadow-sm text-center">
<div class="card-body py-3">
<div class="text-muted small">Total Paid to 1099 Vendors</div>
<div class="fs-3 fw-bold">@Model.Sum(r => r.TotalPaid).ToString("C")</div>
</div>
</div>
</div>
</div>
<div class="alert alert-info py-2 mb-4">
<i class="bi bi-info-circle me-2"></i>
This report shows payments to vendors marked as <strong>1099 Vendor</strong> during <strong>@reportYear</strong>.
IRS rules require a 1099-NEC for non-incorporated contractors, attorneys, and service providers paid <strong>$600 or more</strong> in the calendar year.
To flag a vendor, edit them in <a asp-controller="Vendors" asp-action="Index">Vendors</a> and check the "1099 Vendor" box.
</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-file-earmark-text display-4 d-block mb-3 opacity-25"></i>
<p>No vendors are marked as 1099 vendors. <a asp-controller="Vendors" asp-action="Index">Edit a vendor</a> and check the "1099 Vendor" checkbox to include them here.</p>
</div>
</div>
}
else
{
<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>1099-NEC Summary — @reportYear</h5>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light">
<tr>
<th>Vendor</th>
<th>Tax ID / EIN</th>
<th>Address</th>
<th class="text-end">Bills Paid</th>
<th class="text-end">Expenses Paid</th>
<th class="text-end">Total Paid</th>
<th class="text-center">1099-NEC Required?</th>
</tr>
</thead>
<tbody>
@foreach (var row in Model)
{
<tr class="@(row.NeedsForm ? "" : "text-muted")">
<td>
<a asp-controller="Vendors" asp-action="Details" asp-route-id="@row.VendorId"
class="fw-semibold text-decoration-none">
@row.VendorName
</a>
</td>
<td>
@if (!string.IsNullOrWhiteSpace(row.TaxId))
{
<span class="font-monospace">@row.TaxId</span>
}
else
{
<span class="text-danger small"><i class="bi bi-exclamation-triangle me-1"></i>Missing</span>
}
</td>
<td class="small">@(row.Address ?? "—")</td>
<td class="text-end">@row.BillsPaid.ToString("C")</td>
<td class="text-end">@row.ExpensesPaid.ToString("C")</td>
<td class="text-end fw-bold @(row.NeedsForm ? "text-danger" : "")">@row.TotalPaid.ToString("C")</td>
<td class="text-center">
@if (row.NeedsForm)
{
<span class="badge bg-danger">Yes — File Required</span>
}
else
{
<span class="badge bg-light text-dark border">No (under $600)</span>
}
</td>
</tr>
}
</tbody>
<tfoot class="table-light fw-semibold">
<tr>
<td colspan="3">Total</td>
<td class="text-end">@Model.Sum(r => r.BillsPaid).ToString("C")</td>
<td class="text-end">@Model.Sum(r => r.ExpensesPaid).ToString("C")</td>
<td class="text-end">@Model.Sum(r => r.TotalPaid).ToString("C")</td>
<td></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div class="mt-3 text-muted small">
<i class="bi bi-info-circle me-1"></i>
1099-NEC forms are due to recipients by <strong>January 31</strong> and to the IRS by <strong>January 31</strong> (paper or e-file).
Missing Tax IDs should be collected via <strong>IRS Form W-9</strong> before payments are made.
</div>
}
@@ -1146,6 +1146,10 @@
<i class="bi bi-bank2"></i>
<span>Bank Reconciliation</span>
</a>
<a asp-controller="FixedAssets" asp-action="Index" class="nav-link">
<i class="bi bi-building-gear"></i>
<span>Fixed Assets</span>
</a>
<a asp-controller="RecurringTemplates" asp-action="Index" class="nav-link">
<i class="bi bi-arrow-repeat"></i>
<span>Recurring Transactions</span>
@@ -186,6 +186,11 @@
<input asp-for="IsActive" class="form-check-input" type="checkbox" checked />
<label asp-for="IsActive" class="form-check-label">Active Vendor</label>
</div>
<div class="form-check form-switch mt-2">
<input asp-for="Is1099Vendor" class="form-check-input" type="checkbox" />
<label asp-for="Is1099Vendor" class="form-check-label">1099 Vendor</label>
</div>
<div class="form-text">Check if this vendor requires a 1099-NEC at year end (typically non-incorporated service providers paid ≥ $600).</div>
</div>
</div>
</div>
@@ -188,6 +188,13 @@
</div>
<span asp-validation-for="CreditLimit" class="text-danger"></span>
</div>
<div class="col-md-6">
<div class="form-check form-switch mt-4">
<input asp-for="Is1099Vendor" class="form-check-input" type="checkbox" />
<label asp-for="Is1099Vendor" class="form-check-label">1099 Vendor</label>
</div>
<div class="form-text">Check if this vendor requires a 1099-NEC at year end (typically non-incorporated service providers paid ≥ $600).</div>
</div>
</div>
</div>