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