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
@@ -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) {