# Stock and purchasing dashboard — Dynamics NAV / Business Central 14

Reads your purchase orders, items, suppliers and item ledger entries over OData V4, then tells you
what to order, what to stop ordering, what to move between branches, who to chase, and where cash is stuck.

It is **read only**. It never writes to your ERP, and nothing leaves your computer.

---

## 1. Start it

1. Install **Node.js LTS** once, from <https://nodejs.org> (needed only on the computer that runs the dashboard).
2. **Windows:** double-click `start.bat`. **Mac or Linux:** run `./start.sh` in a terminal.
3. Your browser opens at <http://localhost:8787>. If not, open that address yourself.

To stop it, close the window or press `Ctrl+C`.

Port 8787 busy? Windows: `set PORT=8788` then `node server.js`. Mac/Linux: `PORT=8788 ./start.sh`.

**If the Connect button is greyed out or says the connector is not running:** you opened `public/index.html`
by double-clicking it. Close that tab, run `start.bat` (or `./start.sh`) first, and use
<http://localhost:8787> instead. The page finds the connector by itself within a few seconds of it starting.

## 2. Sign in

Paste an OData link, or fill in server, port, service instance and company.

```
https://erp.alamer-market.com:7048/BC140/ODataV4/Company('Al Amer Market Live')/Purchase_Order
```

* **NavUserPassword** — the password is the **Web Service Access Key** on the NAV user card, not the Windows password.
* **Windows (NTLM)** — write the user as `DOMAIN\user`. The connector retries with NTLM by itself.
* Internal server with a self-signed certificate? Tick the SSL box on the sign-in page.

No server at hand? Press **See it with demo data** — the full dashboard on realistic sample data.

## 3. Publish these pages in NAV (Web Services)

| Page | Name | Service name | What it unlocks |
|---|---|---|---|
| 50 | Purchase Order | `Purchase_Order` | Orders, lines, dates, quantities. **Required** |
| 38 | Item Ledger Entries | `Item_Ledger_Entries` | Stock by location, sales history, waste |
| 30 | Item Card | `Item_Card` | Descriptions, costs, reorder points, lead times |
| 26 | Vendor Card | `Vendor_Card` | Supplier names, phone, lead time |
| 15 | Location List | `Location_Card` | Branch and warehouse names |
| 5404 | Item Units of Measure | `Item_Units_of_Measure` | Carton to piece conversion |

In the NAV/BC Administration tool: enable **OData Services** and the **OData V4 endpoint**, note the port (7048)
and the credential type, then restart the service instance. If a service has a different name in your system,
change it on the **Choose what to load** screen or in **Settings → Data sources**.

---

## What each screen gives you

* **Overview** — money on order, overdue, stock value, dead stock, plus a ranked brief of what matters today.
* **Action center** — eight worked lists: order now, chase suppliers, expedite, move stock, stop ordering,
  dead stock, PO clean-up, price checks. Every row opens the detail and the exact next step. *Copy list as text*
  gives you something to paste into WhatsApp or email.
* **Deliveries** — every open order by when it should arrive, as a timeline and a board.
* **Purchase orders / Suppliers / Products / Locations** — sortable, searchable, exportable to CSV.
* **Data explorer** — the raw rows from the server, to check field names.
* **Settings** — the planning rules. Change one and the whole analysis recalculates.

## How the advice is worked out

| Term | Meaning |
|---|---|
| Sells per day | Sales quantity in the history window ÷ days in the window |
| Cover | Stock on hand ÷ sells per day = days before it runs out |
| Reorder point | Sells per day × (lead time + safety days) |
| Order now | Stock + on order is under the reorder point; suggested quantity lifts cover to the target days |
| Stop ordering | Cover including open orders is above the overstock limit |
| Transfer | One branch is under the trigger days while another (or the warehouse) holds surplus |
| Dead stock | No sales in the history window but stock value on hand |
| Supplier score | Fill rate 45%, on-time 35%, average delay up to 20% → A, B or C |

Lead time comes from the item, then the supplier, then the default in Settings.

## Privacy

Your password stays in the connector's memory and is never written to disk. The connector only talks to the
server you signed in to, and only with GET requests. The browser page loads no fonts, scripts or images from
the internet. Close the window and the credentials are gone.
