Phase G: Add Budgeting and Year-End Close

Budgeting:
- Budget + BudgetLine entities with Jan–Dec monthly columns per GL account
- BudgetsController: Index, Create, Edit, SetDefault, Copy, Delete
- Copy action rolls a budget forward to a new fiscal year
- Budget vs. Actual report (BudgetVsActual): compares monthly budget amounts to
  real P&L by calling GetProfitAndLossAsync once per month; variance shown as
  favorable/unfavorable; year + budget selectors in header
- Views: Budgets/Index, Create, Edit with inline annual totals via budget-edit.js
- Nav link + report card on Landing

Year-End Close:
- YearEndClose entity records each closed year + JE reference for audit trail
- AccountsController.YearEndClose GET (history + form) + CloseYear POST
- Close zeroes all Revenue and Expense/COGS account balances into Retained Earnings
  via IAccountBalanceService and posts a supporting JE dated Dec 31
- Idempotency: rejects attempt to close an already-closed year
- Pre-close checklist in view to guide the workflow
- Nav link under Finance

Migration AddBudgetsAndYearEndClose applied

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-10 13:01:56 -04:00
parent fde24b09c9
commit 4fd9c52aaf
19 changed files with 12527 additions and 3 deletions
@@ -161,6 +161,9 @@ public class UnitOfWork : IUnitOfWork
private IRepository<RecurringTemplate>? _recurringTemplates;
private IRepository<FixedAsset>? _fixedAssets;
private IRepository<FixedAssetDepreciationEntry>? _fixedAssetDepreciationEntries;
private IRepository<Budget>? _budgets;
private IRepository<BudgetLine>? _budgetLines;
private IRepository<YearEndClose>? _yearEndCloses;
/// <summary>
/// Initialises the unit of work with the scoped <paramref name="context"/>.
@@ -573,6 +576,12 @@ public class UnitOfWork : IUnitOfWork
_fixedAssets ??= new Repository<FixedAsset>(_context);
public IRepository<FixedAssetDepreciationEntry> FixedAssetDepreciationEntries =>
_fixedAssetDepreciationEntries ??= new Repository<FixedAssetDepreciationEntry>(_context);
public IRepository<Budget> Budgets =>
_budgets ??= new Repository<Budget>(_context);
public IRepository<BudgetLine> BudgetLines =>
_budgetLines ??= new Repository<BudgetLine>(_context);
public IRepository<YearEndClose> YearEndCloses =>
_yearEndCloses ??= new Repository<YearEndClose>(_context);
/// <summary>
/// Flushes all pending changes in the EF Core change tracker to the database.