# Features — stock_control (RGBC Stock Control)

Evidence date: 2026-10-02.

Source: `git@bitbucket.org:overdrive/stock_control.git`, `master` at `02bce8c` (2026-03-16).

Status meanings: **Current** is on `master` and reachable from code. **Deprecated** is still compiled but commented out or bypassed. **Planned** means a comment or script describes work that is not the running path. Nothing in the tree is marked in progress.

## Current features

### Login and shell

- Windows logon lookup and usage log. `index.aspx.vb`.
- Master shell with logo `rgbc_logo.jpg`, menu, logout link (the link targets `index.aspx`), group label, footer "Version 2.0.0 / 1 January 2026". `Admin.Master`.
- `Default.aspx` redirects to `index.aspx`.
- `Home.aspx` only sets `strPage` to `Home`. The menu item labelled Home opens `ProductPeriod.aspx`, not `Home.aspx`.

### Planning grid

- Brand, period, product, varietal, and category filters. Comp products and inactive products are excluded in the `SqlDataSource` commands on `ProductPeriod.aspx`. Brand-group users see only their brands (`ProductPeriod.aspx.vb` `Page_Load`).
- Fifteen-month grid: previous sales (two years), average sales, opening, QF, BMA, actual, orders, receipts, exports, damages, repack, closing, months cover, last user and stamp for BMA and for orders. `ProductPeriod.aspx`.
- Direct sales row. Documents in `dwfSales` whose `refDocumentNo` starts with `Y`. `sql_get_DirectSales`, `sql_get_DirectSalesAll`. Added 2021-03-08 (`68021e4` and following). The on-screen balance subtracts that quantity with actuals (`closingDifference` in `reTotal`).
- All-products view in 9-litre cases when the product code is `0`, with varietal and category filters (comment v1.2.8c, 2009-10-06).
- Principal fiscal-year 9-litre actuals, rebuilt into `stk9L` on load.
- Show decimals. Calculate (screen only). Save. Excel export and pivot export (`ExportToExcel`, comment v1.2.8b).
- "Use Projected Figures for the current month" (`chkUseQF`, comment v1.2.8a). When checked, the current month can use QF instead of actuals in `reTotal`.
- Deep link `ProductPeriod.aspx?B=&P=&PC=`.
- Confirm action writing `stkConfirm` (brand) or `stkConfirmSM` (shipping) and an HTML SKU table. `btnEmail_Click`, `LoadSKUReport`.

### Import

- Import log grid from `stkImportLog`. `ImportList.aspx.vb`.
- File discovery in `Imports\` for `OpeningYYYYMM.xls` (3 columns), `ForecastYYYYMM.xls`, `Direct ReceiptsYYYYMM.xls`, `CustomerReps.xls`, `BM AdjustmentsYYYYMM.xls`, and `cognos14.txt`. Instructions are hard-coded in `Import.MyLoadPage`.
- Opening import writes `dblOpening` and `dblOpeningImports`, nulls existing `dblOpeningImports` for the period first (comment v1.3.0, 2018-01-08).
- Forecast, direct receipts, and BM adjustments update `stkProductPeriod` columns. BM adjustments added in comment v1.2.10 (2016-11-09). `b5d2a20` (2024-06-19) is "change to save BM Adj".
- Cognos 14 text load into `stgCognos14`, sign flip when `doctype` is null, empty, `-`, or `C`, then sum into `dblActual`. Column swap noted as v1.2.7.
- Comp-product skip on import (`IsCompProductCode` and product queries). Commits `f3a9158`, `d5bf3ba`, `95ff378` (2026-01-27 to 2026-02-04).
- Post-import balance pass `updatePPBalance`.
- Customer rep workbook path (`CustomerReps`, type 7) and `LoadCustomers` for `Customers.xls`. `LoadCustomers` is a private method. A caller inside `btnImport_Click` was not re-read line by line past the Cognos and BM sections. Treat customer-rep import as **Implemented** at the file-detection layer. The full write path for customer reps is **Requires Confirmation** if a tester needs the exact tables updated.

### Reports

- Variance report: months of cover versus brand `dblVariance` (default 2.5), highlight band ± 0.5, optional "all rows", HTML-as-xls export. `BMAReport.aspx.vb`.
- Stock control report: chosen numeric column across the forward window, total and average, February window fix. `SCReport.aspx.vb`, commit `d2bf192` (2026-02-12).

### Administration pages present in the project

- User list, search, add, edit, delete. `UserList.aspx`, `UserDetails.aspx`.
- Brand list, search, status filter, add, edit. `BrandList.aspx`, `BrandDetails.aspx`. Lead months 0–12, variance ≥ 0, two managers, active flag.

### Security configuration

- Connection string from `.env` or the environment, not from a populated `Web.config` connection string. `SecureConfig.vb`, `EnvConnectionStringsExpressionBuilder.vb`, `sqlDB.GetConnectionString`. Commits on 2026-02-03 to 2026-02-05.
- `.env` gitignored. `.env.example` committed.

### Quota forecast allocation

- `RepQF` deletes `dwfQF` for the range and inserts customer-level 9-litre budget and percentage. Formula comment: customer share of historical sales times the SKU QF. Branches whose code contains `x` or `y` are excluded. The button on `ImportList.aspx` calls it with start `200807` and end `200906`.

### One-off scripts

- `Scripts/Recalc_stkProductPeriod_OpeningClosing.sql` — documented as matching v1.3.2. See deprecated section.
- `Scripts/Recalc_stkProductPeriod_PreV131132.sql` — name says it is the pre-v1.3.1/v1.3.2 variant. Not compared line by line to `updatePPBalance`.
- `Scripts/Set_Zero_Opening_Feb2026.sql` — sets opening and opening-imports to 0 and recomputes closing for a fixed product list for period `202602`.

## Recently changed

| When | Change | Evidence |
|---|---|---|
| 2026-03-16 | Reverted "allow zero opening stock" and "always use previous period's closing" | `02bce8c`. Running method is `Import.updatePPBalance` |
| 2026-02-26 | Those two behaviours were introduced | `6550ac6`, no longer the tip of `master` |
| 2026-02-12 | Stock control report: February end period is January next year | `SCReport.aspx.vb` |
| 2026-02-12 | `.gitignore` updated to ignore `.env` | `278b576`, `.gitignore` |
| 2026-02-05 | Env-based connection string and styling | `Web.config`, `SecureConfig.vb`, `1d856ae` |
| 2026-02-04 | Comp products excluded from import | `IsCompProductCode`, `d5bf3ba` |
| 2026-01-29 | Comp products excluded from dropdowns | `ProductPeriod.aspx`, `SCReport.aspx`, `sql_insert_9L` |
| 2024-06-19 | `sql_get_PP` uses `ISNULL` so null BMA, actual, orders, receipts, exports, damages, and repack become 0 | `sqlDB.vb` comment `[DS20240619]`, commit `7854d52` |

## Deprecated or removed from the live path

- **Cognos 24** file `cognos24.txt` and `stgCognos24` processing. Commented out in `Import.aspx.vb`. The import log renderer still prints whatever columns exist on `stkImportLog`, so a `blnCognos24` column would still show if the table has it.
- **Excel imports** for Receipts, Damages, and Repack. File-name branches commented out in `CheckValidFile`. The grid and balance formula still have those fields. **Inferred:** they are now fed by another path (Cognos or direct receipts) or left as stored values. **Requires Confirmation.**
- **Password on `mstUser`.** Insert and update functions with `strPassword` are suffixed `_OLD_WITH_PASSWORD` and have no caller in the pages that were read.
- **Receipts editing on the grid.** `setSecurity` contains a comment "removed: Receipts are not editable" and the text boxes stay read-only.
- **v1.3.2 previous-period closing as the application algorithm.** Reverted by `02bce8c`. The SQL script and `Scripts/README.md` still describe it. **Planned** is the wrong word. It is a **superseded** behaviour that the script still documents.
- **Forms membership.** `BrandDetails.aspx.vb` declares a commented `MembershipUser`. No membership provider is configured in `Web.config`.

## Not in the menu

`UserList.aspx`, `UserDetails.aspx`, `BrandList.aspx`, `BrandDetails.aspx`, `Home.aspx`, and `Import.aspx` (opened from the import list, not from the menu). They ship in `Stock_Control.vbproj`.

## Planned

No backlog, TODO issue list, or feature flag for future work was found.

The recalc script's header says "Use after deploying the v1.3.2 fix". That deployment was reverted. Do not treat the script as a planned feature. Treat it as documentation that disagrees with `master`.

## Not found

- Automated tests.
- A public HTTP API.
- Mobile or SPA client.
- SonarQube project file inside git. The onboarding ticket recorded `sonar-project.properties` and `sonarqube_scan.bat` on the scan host. They are absent at `02bce8c`.
