# Inventory

> Stock per catalog variant and location in a unit with decimals: movements posted to the ledger block, lots, serial numbers, expiry, bins, weighted average cost, reservations with expiry, allocations with backorders, transfers, purchase requisitions with approval, and purchase orders with partial receiving into goods receipts.

- Category: Billing & commerce
- Module: `inventory`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/inventory
- Page: https://bettersupabase.com/blocks/inventory

## Install

```bash
npx better-supabase add inventory
```

The command also installs `updated-at`, `memberships`, `permissions`, `catalog`, `ledger`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by inventory; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    catalog: {},
    ledger: {},
    // Modes: "managed", "custom". The default is "managed".
    inventory: { mode: "managed" },
  },
});
```

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/inventory`.

## Events

- `allocation.created`
- `allocation.filled`
- `allocation.released`
- `allocation.transferred`
- `inventory_receipt.created`
- `purchase_order.cancelled`
- `purchase_order.line_cancelled`
- `purchase_order.placed`
- `purchase_order.received`
- `purchase_requisition.approved`
- `purchase_requisition.created`
- `reservation.committed`
- `reservation.created`
- `reservation.released`
- `stock.adjusted`
- `stock.reorder_point_reached`
- `transfer.cancelled`
- `transfer.received`
- `transfer.shipped`

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md), [catalog](https://bettersupabase.com/blocks/catalog.md), [ledger](https://bettersupabase.com/blocks/ledger.md)

Works with: [outbox](https://bettersupabase.com/blocks/outbox.md), [assets](https://bettersupabase.com/blocks/assets.md), [accounting](https://bettersupabase.com/blocks/accounting.md), [contacts](https://bettersupabase.com/blocks/contacts.md), [approvals](https://bettersupabase.com/blocks/approvals.md), [inspections](https://bettersupabase.com/blocks/inspections.md), [templates](https://bettersupabase.com/blocks/templates.md), [imports](https://bettersupabase.com/blocks/imports.md)

## Recipes

- [Inventory table](https://bettersupabase.com/recipes/inventory-table.md): Stock levels per product and location, with a form to adjust a count.
