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
@@ -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>
}