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,18 @@
namespace PowderCoating.Web.Helpers;
/// <summary>
/// Checks whether an accounting entry date falls within a locked period.
/// The lock date is stored on the Company as BookLockedThrough and is set by CompanyAdmin
/// users to prevent backdating entries into periods that have already been closed.
/// </summary>
public static class AccountingPeriodValidator
{
/// <summary>Returns true when the entry date is on or before the lock date (period is closed).</summary>
public static bool IsLocked(DateTime entryDate, DateTime? lockedThrough) =>
lockedThrough.HasValue && entryDate.Date <= lockedThrough.Value.Date;
/// <summary>User-facing message to display when a write is blocked by period locking.</summary>
public static string LockedMessage(DateTime? lockedThrough) =>
$"This period is locked — books are closed through {lockedThrough!.Value:MMMM d, yyyy}. " +
"Unlock the period in Company Settings → Accounting to make changes.";
}