Module — Logistics¶
A self-contained inventory and fixed-asset system on its own database (NKO_DB_Warehouse). It
tracks consumable stock (entry, internal / external release via Stock Release Requests and
Waybills, centre-to-centre transfers) and serialised assets (registration approval, hand-out to
employees / offices / centres, maintenance, return-to-store via GRN reports, and disposal /
destruction), with per-category permissioned warehouses and its own reporting suite.
Source: NKO.Main/NKO.Main/WarehouseControllers/*.cs, NKO.Main/NKO.Main/WareBAL/*.cs,
NKO.Lib/NKO.Warehouse.DataAccess/DbModel/,
NKO.Main/NKO.Main/Helpers/OperationConstants.cs (the warehouse workflow constants),
NKO.Main/NKO.Main/Startup.cs (the second DbContext).
Purpose & scope¶
- In scope: warehouses and categories, the stock catalogue and on-hand balances, stock movements and releases, waybills, centre transfers, the asset register and its status history, asset dispatch, maintenance requests, asset-return GRN reports, destruction reports, the evidence library, and the warehouse reports.
- Out of scope: purchasing the goods (Procurement) — a procurement GRN can
push items into this module via
GRN → Transfer to Warehouse. - Database:
NKO_DB_Warehouse, contextWarehouseDBContext, connection stringWareConnection. Identity, signatures, notifications, permissions and org data are read from the coreNKO_DB.
Database wiring¶
Startup.csregistersAddDbContext<WarehouseDBContext>(GetConnectionString("WareConnection"))immediately after the core context;WarehouseDBContextmaps 21DbSets, every FKDeleteBehavior.NoAction,Computer↔Assetone-to-one. There are 5 migrations.- WareBAL classes are all
AddTransientand each takeWarehouseDBContext; they reuse the coreBUser,BSign,BNotification,EmailManager,NextUserHelper,CurrentRequestData,PermissionChecker,ExportHelper,RealTimeNotifier. - Link to Procurement:
BGRN.TransfareToWarehouse(id, userId)(core) resolvesBWarehouse.CurrentWarehouseand writesCenterStock+StockDetails{Entry, RealEntry}(consumables) orAssetrows (assets) directly intoNKO_DB_Warehouse, then setsGoodReceivedNote.IsTransfareToWarehouseon the core record. - Visibility:
BUser.GetPermission(SharedPermissions.{Stocks = 10, Assets = 11, GDO = 12})returnsAllor project-scoped; category-level scope isEmpCat1Permission(employee ↔CatL1) plusCatL1.StockManager.
Key features¶
- Warehouses — per branch, two kinds: consumable (
IsAsset = false) and asset (IsAsset = true), each with aManager(guard) and optionalSRRNoter. - Stock master —
CatL1(category,IsAsset,StockManager,Code) →Stock(item,ItemCode,UnitId) →StockSpecification(variant; auto "عام" if none) →CenterStock(the physical on-hand row keyed by warehouse + stock + spec + project + donor, withCurrentAmount). - Stock entry —
StockDetailsrows with anOpType(Entry / Release / PendingRelease) and aStockTransferType; entry can be manual or fed from a procurement GRN. - Stock Release Request (SRR / GD order) —
StockReleaseReq+StockReleaseReqDetail;TransferType= Employee / Centre / Office / Distribution area, orIsExternalwith a free-text destination + recipient. Flow:Draft → Pending(programme/branch approver)→ WaitingRelease → Released; plus Refused / Cancelled / transfer states. Sending writesPendingReleaseStockDetailsrows; releasing flips them toRelease; refusing / cancelling deletes them. - Waybill —
Waybill+WaybillDetail(consignee, transporter, plate, departure date, batch no, weight), attached to an SRR for physical dispatch. - Centre-to-centre transfer — request / accept / refuse on an SRR of
TransferType.Centre, movingCenterStockbetween warehouses. - Assets — serialised (
Asset: spec, project / donor, purchase price / currency / date, PO / invoice / supplier, account code, BIS licence,OriginTypeBuying / Donation) with an append-onlyAssetDetailstatus history and denormalisedCStatusId/CWarehouse/CUserId; an optional 1:1Computerextension when the spec is the computer type. - Asset registration approval —
Send(Draft → AwaitingFinance, requires a serial no) →FinanceApprove(adds the account code, → AwaitingLogistic) →LogisticApprove(→ Repo). - Asset dispatch (ADO) — assets attached to an SRR;
ChangeStatus/TransferToUser/TransferToWaremove an asset to an employee (PendingDelivered→Deliveredon release), back to store (Repo), or between centres. - Maintenance — a
MaintenanceReqper asset;Draft → AwaitingLogistic → AwaitingStockManager → AwaitingLogistic2 → Accepted;Sendsets the asset toMaintenance,LogisticApprove2returns it toDelivered. - Asset return GRN report ("ARR") —
GRNReport+AssetsReturnreturn previously-issued assets into store;Draft → AwaitingWarhouseResponsible → AwaitingSC → Closed; on approval callsBAsset.TransferToWarefor each asset (→Repo). - Destruction / disposal —
Destruction+Asset.DestructionId;Draft → WaitingForManagement → WaitingForProcurement → WaitingForGM → Accepted;SetSentmarks assetsPendingDestructed,SetGMApprovemarks themDestructed. - Evidence library —
WarehouseEvidence: uploaded scans (S3) categorised (GRN & invoice, GDN, SRR, waybill, destroy, donation) with GRN / invoice numbers. - Reporting — asset report, general stock report, per-stock report, SRR / waybill /
entry-release monthly reports, employee asset card, entries report — all with Excel export driven
by
RealTimeNotifierprogress. - Admin — warehouse CRUD, CatL1 CRUD, Stock + StockSpecification CRUD, and bulk Excel importers (stock data, SRR data, recipients, centre data, specifications).
Screens¶
Warehouse controllers live in namespace NKO.Warehouse.Controllers but are reached at
/{Controller}/{Action} like any other. Primary screens only.
StockController — /Stock/* · AssetController — /Asset/*¶
| Feature | Route | Permission key |
|---|---|---|
| Consumable stock grid | / |
Stock |
| Stock item detail | / |
Stock |
| Add / edit / release a stock movement | /, /, / |
Stock, Stock |
| SRR list / create / detail | /, /, / |
Stock, Stock, Stock |
| Waybills list / create / detail | /, /, / |
Stock, Stock, Stock |
| SRR / asset-SRR workflow transition | /, / |
Stock |
| Asset register | / |
Asset |
| Asset detail | / |
Asset |
| Register a new asset | / |
Asset |
| Warehouse list (per branch) | / |
Asset |
| Move asset to store / user | /, /, / |
Asset, Asset |
| Asset registration transition | / |
Asset |
| Asset export | / |
Asset |
Maintenance · GRN report · Destruction · Reports · Admin¶
| Feature | Route | Permission key |
|---|---|---|
| Maintenance requests | /, /, / |
Asset, Asset, Asset |
| Maintenance transition | / |
Asset |
| Asset-return GRN report | /, /, / |
Ware, Ware, Ware |
| GRN report transition | / |
Ware |
| Destruction reports | /, /, /, / |
Destruction, Destruction, Destruction |
| Reporting suite | /, /, / |
Report, Ware |
| Warehouse / category / stock admin + importers | /, /, /, / |
Stock, Stock, Stock |
| Evidence library | /, / |
Warehouse |
WareBaseController (/WareBase/*) is a standalone AJAX helper (GetStocks, GetStockSpecs,
GetImage, Thumbnail, Download) — it is not an abstract base and carries no permission key.
EvidencesController (/Evidences/*) exposes only Index and GetRefrenceCode (no key).
Business logic¶
| Class | File | Responsibility & notable logic |
|---|---|---|
BWarehouse |
Ware (~115 ln) |
Warehouse master CRUD + lookups. Current (manager match), Current, Search. |
BStock |
Ware (~4020 ln — largest) |
Masters (Create + child specs, Create, Create). Entry — Create finds/creates the Center (warehouse + stock + spec + project; donor via _common.) and adds Stock. SRR — Create, Create (duplicate-line guard), Get. Waybills — Create, Get. Availability — Is, Get. Workflow — Set (validate each detail's availability; Status; Approver; next via _next; write Pending Stock rows), Set (→ WaitingRelease), Set (→ Refused; delete pending rows + soft-delete Asset), Set (flip Pending → Release, Pending assets → Delivered), Request / Accept / Refuse. |
BAsset |
Ware (~4205 ln) |
Create — loops Count; CStatus; seeds one Asset; creates a Computer row if the spec is the computer type. Registration — Send(id, (Draft → AwaitingFinance), Finance (→ AwaitingLogistic), Logistic (→ Repo). Movement — Transfer (→ Repo; with a grnId records From + GRNId), Transfer (→ PendingDelivered, sets Pernding), Change. Asset-SRR workflow (Set / Set / Set / Set / …). Queries — Get (filter by status / category / stock / spec / donor / project / user), Get, Export. |
BMaintenance |
Ware (~565 ln) |
Get (permission via Get — All else Logistic), Create (Status), Send (asset → Maintenance, Asset, → AwaitingLogistic), Logistic (→ AwaitingStockManager, Stock), Stock (→ AwaitingLogistic2), Logistic (→ Accepted, asset → Delivered), Add (asset back to Delivered on any refuse). |
Destruction |
Ware (~625 ln) |
Create (sets Asset. for each existing asset). Workflow — Set (assets → Pending; → WaitingForManagement; next via Get), Set, Set, Set (assets Pending → Destructed, status → Accepted). |
GRNHandler |
Ware (~640 ln) |
Asset-return GRN report. Create (acting asset-warehouse by branch; Status; adds Assets per asset), Set (→ AwaitingWarhouseResponsible; next via Get), Warhouse (→ AwaitingSC), Auhtorize (→ Closed; calls BAsset. per asset), Cancel (needs the GRNCancel key; reversing Asset rows if already warehouse-approved). |
BReport |
Ware (~1030 ln) |
Get / Get / Get (drill-down), Get, Get, Get, Export. |
Warehouse |
Ware (~215 ln) |
Get (permission via Get), Add (resolves the acting warehouse, uploads to S3 Functionality.), Edit. |
Data¶
The WarehouseDBContext maps 21 entities (15 in DbModel/ + 6 in DbModel/Assets/):
| Group | Entities |
|---|---|
| Warehouses & categories | Warehouse, Cat, Emp |
| Stock catalogue & on-hand | Stock, Stock, Center |
| Stock movements & release | Stock, Stock, Stock, Waybill, Waybill |
| Assets | Asset, Asset, Asset, Assets, Computer, GRNReport |
| Maintenance & disposal | Maintenance, Destruction |
| Evidence & files | Warehouse, Ware |
Full column detail: Warehouse database.
Permissions¶
Distinct keys: AssetIndex, AssetExport, AssetDetails, AssetAddAsset, AssetEditAsset,
AssetDeleteAsset, AssetDeleteAssetDetail, AssetTransferToWare, AssetTransferToUser,
AssetCancelAsset, AssetMaintenanceIndex, AssetMaintenanceCreate, AssetMaintenanceDetails,
AssetMaintenanceEdit, AssetMaintenanceDelete, StockIndex, StockDetails, StockSRR,
StockSRRDetails, StockWaybills, StockWaybillDetails, StockCreateSRR, StockCreateWaybill,
StockAddStockDetail, StockEditWaybillDetail, StockDeleteStockDetail, StockContextActions,
StockGetStocks, StockGetCenters, StockAdmin, StockAdminAdvance, StockAdminImportData,
WareGRNIndex, WareGRNDetails, WareGRNCreate, WareGRNEdit, WareGRNDelete, DestructionIndex,
DestructionCreate, DestructionDetails, ReportIndex, WareReportEmployeeCard,
WarehouseAttachments, plus GRNCancel (checked in code). Data scoping:
SharedPermissions.{Stocks = 10, Assets = 11, GDO = 12} + EmpCat1Permission / CatL1.StockManager.
Screenshots¶
Consumable stock — /Stock (category / warehouse / project filter panel; the grid is empty for an
account without EmpCat1Permission on any category):

Fixed-asset register — /Asset (status / category / holder columns; category-scoped like Stock):

Warehouse control panel — /WareAdmin (stock categories CatL1):

Related¶
- Procurement module —
GRN → Transfer to Warehousefeeds stock/assets in; the coreGoodReceivedNoteis a different document from the warehouseGRNReport(asset return). - Administration module — warehouse users, signatures and notifications come
from the core
NKO_DB. - Logistics API · Warehouse database.