> For the complete documentation index, see [llms.txt](https://docs.digit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digit.org/health/v2.1/deploy/configuration/hcm-ui-configuration/commodity-management.md).

# Commodity Management

### Overview

Commodity Management is a new module introduced in HCM v2.1 for tracking warehouse stock across health campaigns. Program managers can monitor stock levels, review pending and historical transactions, create shipments, and upload bulk stock data — all scoped to the selected campaign and boundary.

The module is accessible from the campaign home screen via a new dashboard card, visible only for commodity-type campaigns.

Commodity data is pulled from **Kibana / Elasticsearch** via the analytics dashboard API. All stock operations are scoped to the campaign and boundary selected by the user.

> **Before enabling:** Commodity Management reads its campaign and stock configuration from MDMS at runtime. The required MDMS masters must be configured before enabling the commodity screens — otherwise the screens will not work correctly.

***

### What's New

#### Commodity Dashboard

The main dashboard (`CommodityCampaigns`) is the central hub for all commodity activity. It has three tabs:

<table><thead><tr><th width="228.4375">Tab</th><th>What it shows</th></tr></thead><tbody><tr><td>Stock Summary</td><td>Current stock levels across all warehouses for the selected campaign</td></tr><tr><td>Pending Transactions</td><td>Stock transactions that are awaiting processing</td></tr><tr><td>Transaction Summary</td><td>Historical summary of all stock transactions</td></tr></tbody></table>

<figure><img src="https://2077406040-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FI0KFbSBTySIQ7TCOKnJF%2Fuploads%2F4TGaoX4f7GQMzlxezRka%2Fimage.png?alt=media&amp;token=2b0dccc3-7524-471b-9ee9-ce5357d73c6d" alt=""><figcaption></figcaption></figure>

**How to reach it:**

```
Campaign home → Commodity dashboard card → Select campaign → Commodity dashboard
  → Stock Summary / Pending Transactions / Transaction Summary  (tabs)
```

***

#### Bulk Stock Upload

Upload multiple stock transactions at once using a file. Useful for recording large volumes of stock movements in one go rather than entering them one by one.

<figure><img src="https://2077406040-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FI0KFbSBTySIQ7TCOKnJF%2Fuploads%2FFluq49VOcvpZR9hbyZAv%2Fimage.png?alt=media&amp;token=1fc98dc5-7dce-4449-918b-8ef3bb7bf1ea" alt=""><figcaption></figcaption></figure>

***

#### Shipment Management

Create and manage shipments scoped to a specific warehouse directly from the commodity dashboard.

| Action          | What it does                                                      |
| --------------- | ----------------------------------------------------------------- |
| Create shipment | Opens a popup to define a new shipment for the selected warehouse |
| Edit shipment   | Opens a popup to modify an existing shipment                      |

<figure><img src="https://2077406040-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FI0KFbSBTySIQ7TCOKnJF%2Fuploads%2FMHgJZyHauQWzSm0eo9Qb%2Fimage.png?alt=media&amp;token=f4d34358-0821-4608-b435-a074ad4cb1fd" alt=""><figcaption></figcaption></figure>

***

### New API Integrations

| Endpoint                                    | Method | Hook                                              | Purpose                                                  |
| ------------------------------------------- | ------ | ------------------------------------------------- | -------------------------------------------------------- |
| `/dashboard-analytics/dashboard/getChartV2` | POST   | `useKibanaStockSearch`, `useWarehouseManagerSync` | Fetch stock balances and warehouse sync data from Kibana |
| `/stock/v1/_search`                         | POST   | `useStockSearch`, `useBatchStockCreation`         | Search stock records and verify bulk stock creation      |
| `/stock/v1/bulk/_create`                    | POST   | `useBatchStockCreation`                           | Batch-create stock transaction records                   |

***

### New Components

| Component / Hook             | What it is                                                        |
| ---------------------------- | ----------------------------------------------------------------- |
| `CommodityCampaigns.js`      | Main commodity dashboard page                                     |
| `StockSummaryTab.js`         | Stock summary tab                                                 |
| `PendingTransactionsTab.js`  | Pending transactions tab                                          |
| `TransactionSummaryTab.js`   | Transaction summary tab                                           |
| `BulkStockUpload.js`         | Bulk stock upload screen                                          |
| `NewShipmentPopup.js`        | Create shipment popup                                             |
| `CommodityShipmentPopup.js`  | Edit shipment popup                                               |
| `HCMCommodityRowCard`        | Campaign home card — entry point to commodity dashboard           |
| `CommodityProjectContext.js` | Scopes all stock operations to the selected campaign and boundary |
| `stockDataProcessor.js`      | Handles stock data transformation                                 |
| `useKibanaStockSearch`       | Queries Kibana / Elasticsearch for stock data                     |
| `useStockData`               | Fetches stock data for dashboard tabs                             |
| `useStockSearch`             | Stock search hook                                                 |
| `useBatchStockCreation`      | Handles bulk stock record creation                                |
| `useCommodityProjectSearch`  | Campaign search scoped to commodity projects                      |
| `useWarehouseManagerSync`    | Syncs warehouse state with the backend                            |

All commodity components are in `src/components/CommodityManagement/`.

***

### MDMS Configuration

| MDMS Module                          | What it configures                                                            |
| ------------------------------------ | ----------------------------------------------------------------------------- |
| Campaign-specific (by `projectType`) | Stock and commodity config — payment rules, allowed statuses, rate structures |

> All commodity rules are read from MDMS at runtime. Configure these masters before enabling the Commodity Management screens.

***

### Localisation

New translation keys for all Commodity Management screens have been added under `I18N_KEYS.COMMODITY_MANAGEMENT` in `src/utils/i18nKeyConstants.js`.

***

### Access and Permissions

| Role                  | What they can do                                                    |
| --------------------- | ------------------------------------------------------------------- |
| Campaign-scoped users | View commodity dashboard and stock data within their boundary scope |
| Campaign-scoped users | Create and edit shipments within their boundary scope               |
| Campaign-scoped users | Perform bulk stock uploads                                          |

> The commodity dashboard card only appears on the campaign home screen for campaigns that are of a commodity type. Users assigned to non-commodity campaigns will not see this card.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.digit.org/health/v2.1/deploy/configuration/hcm-ui-configuration/commodity-management.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
