# Features — shipment_document_system

Evidence date: 2026-10-04.

Source: `main` at `6f61b57` (2026-04-24). Status values below mean:

- **Current** — present and wired on this revision.
- **Present but inactive** — code or views exist and are not on the live path.
- **Removed or commented** — was started and is now commented or unused.
- **Not in the repository** — named by an older snapshot or a comment, and not in git.

No feature flag file was found. "Planned" items are only comments and TODOs, not an approved backlog.

## Current

### F-01 — Windows-identity login screen

Login page with the RGBC logo and a single Login button. Post reads `User.Identity.Name` and matches `mstUser.strDomainLogin`.

- `Controllers/AccountController.cs`
- `Views/Account/Login.cshtml`
- `Views/Shared/_LoginLayout.cshtml`
- `Services/UserService.cs` `ValidateUser`

Role session values: `ADMIN`, `VIEWER`, `LOGISTICS` from `Enums/RoleEnum.cs`.

### F-02 — Shipment register

List, indent search, status filter, detail, create, update.

- `Controllers/Shipment/ShipmentController.cs`
- `Services/ShipmentService.cs`
- `Views/Shipment/ShipmentList.cshtml`
- `Views/Shipment/AddShipment.cshtml`
- `Views/Shipment/UpdateShipment.cshtml`
- Entity `DB/sdsShipment.cs`

Captured fields: supplier, indent number, shipshape number, mother vessel, ETA, bill of entry number, container number, offloading port, container received, number of flatcases, voyage, M/BL number, redirect to SACD.

### F-03 — Shipment status actions

Create stores `SAVED`. Submit stores `SUBMITTED` when `CheckShipmentSubmitStatus` is true. Cancel stores `CANCELLED` plus `cancel_reason`.

List filter labels are Saved, Submitted, Cancelled (`PopulateShipmentStatus`).

### F-04 — Checklist files in SharePoint

Sixteen document slots. Upload, replace, preview link, and delete. Indent change renames the SharePoint folder and file names.

- `Services/SharePointService.cs`
- Folder `/Shipment Checklist/{indent number}`
- File name `{indent}_{uploaded name}`
- Certificate-of-origin delete posts `CertificateOfOrigin`. The controller case is spelled `CerificateOfOrigin`, so that delete hits `default` and does not remove the file.

Graph auth is client credentials. Settings are environment variables listed in `1. website/.env.example`.

### F-05 — Role-shaped shipment screen

On the update view:

- Admin: Save, Submit (when the checklist check passes and status is not `SUBMITTED`), Cancel (when status is not `CANCELLED` and not `COMPLETE`), View, and Delete on each file.
- Logistics: Save (when status is not `CANCELLED` and not `COMPLETE`), Submit under the same check as admin, View on files. No Delete and no Cancel.
- Viewer: View on files. No Save, Submit, or Cancel.

The list page does not apply this split. Add, Import, and Export render for every role. Controllers do not repeat the checks.

### F-06 — Excel export

`GET shipment/exportshipments`. Workbook sheet "Shipments", fourteen columns, maroon header.

- `ShipmentController.ExportShipments`
- EPPlus 7.0.9

### F-07 — Excel import with staging

Upload, template, preview, errors, execute, cancel session, history.

- `Controllers/Import/ImportController.cs`
- `Services/ImportService.cs`
- `Views/Import/` (`Upload`, `Preview`, `Errors`, `Execute`, `Results`, `History`)
- Tables `sdsImportSessions`, `sdsStagingShipments`, `sdsImportErrorLogs`
- SQL scripts in `sql files/`

Legacy routes `shipment/import` and `shipment/importshipments` redirect to `import/upload` (commit `fc6f1b5`).

### F-08 — Supplier maintenance

List, name filter, active filter, add (button only for admin), update, soft delete.

- `Controllers/Suppliers/SupplierController.cs`
- `Services/SupplierService.cs`
- `Views/Maintenance/Suppliers/`
- Entity `DB/sdsSupplier.cs`
- Nav link in `Views/Shared/_Layout.cshtml`

### F-09 — Shell and session display

Header, logo, nav (Shipments, Suppliers, Logout). Logout label is rewritten to include the signed-in name.

- `Views/Shared/_Layout.cshtml`
- Session idle timeout registered as 10 minutes (see PRD FR-002 for the double `AddSession` call).

### F-10 — Secret loading from the environment

Commit `6f61b57`. `SecureConfig` reads a `.env` file without overriding variables already set. Startup throws if the SQL connection string or SharePoint keys are missing. `appsettings.json` keeps logging and `AllowedHosts` only.

### F-11 — SonarQube pipeline

`bitbucket-pipelines.yml` runs on branch `main`: install JDK 17, `dotnet-sonarscanner`, build `rgbc_sds.sln`, end the scan. Project key `overdrive_shipment_document_system_dccdf710-08f7-47e7-bc1c-d390c06b0c7f`. Image is the .NET 7 SDK. There is no test step and no deploy step.

## Present but inactive

### F-12 — User maintenance UI

Add, update, and list views under `Views/Maintenance/Users/`. `UserController` calls `UserService`, whose body is commented out. Nav link is commented out in the layout. Actions have no `[Route]`.

### F-13 — SharePoint upload page

`SharePointController.UploadFile` and `Views/SharePoint/UploadFile.cshtml`. The post copies the file into memory and returns OK. The Graph upload line is commented out. Nav link is commented out.

### F-14 — Home and privacy pages

`HomeController.Index`, `Privacy`, `Error`, and matching views. No `[Route]`. The production exception handler points at `/Home/Error`. The default MVC route that would serve `Home` is commented out in `Program.cs`.

### F-15 — FileUploadService

`Services/FileUploadService.cs` can request a Graph token and list sites. `ShipmentController` constructs it and never calls it. Live Graph calls are in `SharePointService`.

### F-16 — Import cleanup and SQL procedures

`ImportService.CleanupOldImportSessionsAsync` (30-day default) has no controller caller.

`sql files/3. CreateStoredProcedures.sql` defines procedures such as `sp_GetImportSessionSummary` and `sp_GetStagingDataForPreview`. `sql files/4. CreateViews.sql` defines `vw_ImportSessionOverview` and further views. No C# reference to those procedure or view names was found. The application uses EF queries instead.

### F-17 — ShipmentService.SubmitShipment

Writes status `COMPLETED`. The controller submit action does not call it. It writes `SUBMITTED`.

### F-18 — ShipmentStatusEnum

`Saved = 1`, `Complete = 2`, `Cancelled = 3`. Shipment rows store the strings `SAVED`, `SUBMITTED`, and `CANCELLED`. The enum is not used by the shipment controller.

## Removed or commented

### F-19 — Password and local username on the login form

Login view posts with no credential fields. A hard-coded local username in `AccountController` is commented and marked LOCAL.

### F-20 — Numeric M/BL validation

The integer check on M/BL in `ValidateScreen` is commented out. Commit `5d06fdb` (2024-08-29) describes container number and M/BL as alphanumeric.

### F-21 — In-app user table

`UserService` comments refer to a `users` entity (`first_name`, `last_name`, `email`, `role_id`, `is_active`). That entity is not in `rgbc_sdsContext`. The generated user entity is `mstUser`.

### F-22 — Credentials inside appsettings

`6f61b57` deletes the SharePoint credential block from `appsettings.json` (21 lines removed from that file). Values are not reproduced in Silicon Ark.

## Recently changed

Relative to the scan snapshot `fc6f1b5` (2025-08-28), the only later commit is `6f61b57` (2026-04-24, "Security Enhancements"):

- `.env.example` and `Configuration/SecureConfig.cs` added.
- Startup validates connection string and SharePoint settings.
- `appsettings.json` reduced to logging and `AllowedHosts`.
- Layout, login, shipment, supplier, user, and import views adjusted (markup and script integrity attributes). Behaviour of shipment save and import execute was not changed in that diff's file list; those files are views plus `Program.cs` and `appsettings.json`.

August 2025, still the functional baseline under that security commit:

- `cf1e648` export.
- `7edc72d` bulk import, history, logging.
- `00cf5a6` offloading-port validation on import.
- `fc6f1b5` import routes redirected onto `ImportController`.

## Not in the repository

- `sonar-project.properties` and `sonarqube_scan.bat`, named in the onboarding snapshot. `git log --all` for those paths is empty.
- README, test project, Docker, publish profile (publish profiles are gitignored).
- A database project or EF migration history for `sdsShipment` and `sdsSupplier`. Those two tables plus `mstUser` are reverse-engineered (`efpt.config.json`). Import tables are hand-written entities plus SQL scripts.

## Deprecated vocabulary

Do not treat these as the live status values:

| Source | Values | Used by the running submit path? |
|---|---|---|
| `ShipmentStatusEnum` | Saved, Complete, Cancelled | No |
| `ShipmentService.SubmitShipment` | writes `COMPLETED` | No |
| Update view cancel guard | compares to `COMPLETE` | The guard runs; stored submit value is `SUBMITTED`, so this comparison does not match a submitted row |
| Controller submit | writes `SUBMITTED` | Yes |
| List filter | Saved / Submitted / Cancelled mapped to `SAVED` / `SUBMITTED` / `CANCELLED` | Yes |
