Add migration to include AccruedExpensesCode in gl_account_config table
- Introduced a new column 'AccruedExpensesCode' of type varchar(20) to the 'gl_account_config' table. - Added SQL command to update existing records with a default value of '2300' for the 'AccruedExpensesCode' where it is currently null.
This commit is contained in:
@@ -648,3 +648,16 @@ Spec: `docs/30-BACKEND-PHASE2.md` (model + rules **and** API — one doc, unlike
|
||||
- **Running balance is now computed on read** (`StockService.GetLedgerAsync`): the sum of every movement of the same item + warehouse up to that row (In adds, Out subtracts). The stored `RunningBalance` column was wrong for sales issues (`SalesPostingService` posts `0`), so those rows showed 0; the read-time value is right for old rows, later pages and any filter. The column is no longer read.
|
||||
- **Rows carry** `itemSku`, `itemName`, `categoryName`, `brandName`; the endpoint takes `categoryId` and `brandId` (items in them). The page shows the item NAME with SKU, category and brand underneath, signed quantities (+In / −Out), unit cost with up to 4 decimals, Out values negative, and Category / Brand / searchable Item (SKU — name) / Warehouse filters; the item picker follows the category and brand.
|
||||
- **Tests:** `StockLedgerTests` (4). Suite 218/218. Not changed: `SalesPostingService` still writes `RunningBalance = 0` to the stored column (nothing reads it).
|
||||
|
||||
### 2026-10-18 (6) — Wastage reduces stock again; wastage approval is a setting
|
||||
- **Why stock stopped reducing:** wastage is a stock adjustment, and the dual-approval engine seeds `StockAdjustmentLevels = 2`, so every wastage was only a pending request (no FIFO consume, ledger row or GL journal) until two other users approved it.
|
||||
- **Setting:** `approval_config.WastageLevels` (0 = none, default; 2 = two approvers). Settings -> Approvals has a *Wastage needs dual approval* switch. Wastage = Adjustment reason DMG / THEFT / EXP with every line a decrease (`WastageReasonCodes`); everything else (manual adjustments, count variances, wastage *gains*) keeps the stock-adjustment levels and threshold. Migration `AddWastageApprovalSetting` (additive, default 0, **not applied**).
|
||||
- **List:** `GET /stock-adjustments?wastage=true` filters server-side; the Wastage page uses it, counts posted wastage in its totals, shows pending requests apart ("Waiting for approval") with no value, and loads every item so names resolve past the first 200. Record Wastage shows whether it reduces stock now or needs approval.
|
||||
- **Not touched:** requests already pending stay pending (approve them in the Approval Queue or withdraw and re-record).
|
||||
- **Tests:** 5 new in `DualApprovalTests` (switch off posts at once; on stays pending until two approvers; the two settings don't affect each other; list filter; default). The existing adjustment tests now use an ordinary reason (VAR) instead of DMG. Suite 223/223.
|
||||
|
||||
### 2026-10-18 (7) — Expense posting: "Account 5200-01 / 2300 not found"
|
||||
- **Cause:** the GL used by this deployment had none of the accounts the Expense module posts to: the four expense accounts the seeded titles point at (`5200-01`..`5200-04`, children of an "Operating Expenses" `5200` control account) and the **Accrued Expenses** liability (`2300`) that every expense is credited to. The expense-title accounts are editable on Accounts -> Expense Setup; the accrued account was **only in appsettings** (`Expense:GlAccruedExpensesCode`), invisible and unchecked.
|
||||
- **Fix in code:** `GlAccountRole.AccruedExpenses` + `gl_account_config.AccruedExpensesCode` (migration `AddAccruedExpensesGlRole`, **not applied**, fills existing config with `2300`; fresh databases seed it from the old appsettings key). `ExpenseService` / `ExpensePaymentService` read the mapped role, so it is edited, validated (must exist and be postable) and checked at startup like every other GL role, on Settings -> GL Accounts.
|
||||
- **GL data (done through the GL's own API, not SQL):** created `5200 Operating Expenses` (header) with `5200-01` Utility, `5200-02` Rental, `5200-03` Salaries and Wages, `5200-04` Other Expenses, and `2300 Accrued Expenses`.
|
||||
- **Still true for a brand-new GL:** the chart of accounts itself is created in the GL service, not in the ERP; the ERP only maps roles to existing accounts and now tells you which are missing.
|
||||
|
||||
Reference in New Issue
Block a user