# Restaurant stock control: lots and FEFO

> Stock in the system is kept by lots. Every receipt creates a lot. A lot has: - a warehouse; - a supplier batch; - an expiry date ("best before" or…

> Machine translation, editorial review pending.

Source: https://docs.smaklad.pl/en/guide/warehouse/

Stock in the system is kept **by lots**. Every receipt creates a lot. A lot has:
- a warehouse;
- a supplier batch;
- an expiry date ("best before" or "use by");
- a unit cost in PLN.

Issues draw down lots by the **FEFO** rule (first expired, first out): the lot that expires soonest goes first. Every movement is recorded with a **warehouse document**: PZ, WZ, RW, PW, MM, ZW, INW, PS, KOR.

## 6.1. Who can do what

| Action | admin | manager | accountant | kitchen |
|---|:-:|:-:|:-:|:-:|
| Stock on hand, expiry dates: view | ✔ | ✔ | ✔ | ✔ |
| Lot list and lot details: view | ✔ | ✔ | ✔ | ✔ |
| Warehouse list: view | ✔ | ✔ | ✔ | ✔ |
| Set the default warehouse (`System → Locations`) | ✔ | ✔ | — | — |
| Warehouse documents and stocktakes: view | ✔ | ✔ | ✔ | ✔ |
| Stock value (summary) | ✔ | ✔ | ✔ | — |
| Manual receipt (PZ), lot adjustment, write-off | ✔ | ✔ | — | — |
| Post a draft document | ✔ | ✔ | — | RW only |
| Delete a draft document | ✔ | ✔ | — | RW and PS only |
| Reverse a posted document (KOR) | ✔ | ✔ | — | — |
| Run the expiry check manually, approve a draft PS | ✔ | ✔ | — | — |

Notes:
- In the "Operations" section the accountant can only view: "Warehouse" (stock on hand and stock value), "Lots", "Documents", "Stocktakes", "Expiry dates" and "Production". They do not see receipts, adjustments or write-offs; the adjustment page does not let them in via a direct link, and the server refuses too (403).
- A cook can prepare and post only issues to production (RW — internal issue). They can prepare or delete a loss report (PS), including a draft from the nightly expiry check, but a manager approves it. The cook sees the "Post" / "Approve" buttons only where they will work.
- The warehouse list can be read by admin, manager, kitchen and accountant; the "Warehouse" filter works for everyone. The cook does not see the "Receipt" and "Adjustment" buttons, nor the stock value summary.

## 6.2. Stock on hand and lots

![Stock on hand](https://docs.smaklad.pl/img/warehouse-01-stock.png)

**Operations → Warehouse** (`/en/admin/operations/inventory`):
- **Value summary** (admin, manager, accountant): stock value in PLN by warehouse.
- **Stock table** by product and lot. Filters:
  - warehouse;
  - "expires before" (date);
  - supplier batch;
  - "sellable only".
- The list is paginated; the server returns no more than 200 rows at a time.

Quantities are shown with their unit: kg, l, t and g with three decimal places, pieces as whole numbers. Amounts are shown in złoty with two decimals. Dates are shown in Warsaw time.

**Lots** (`/en/admin/operations/inventory/lots`) — a list of lots with their status:
- available;
- in quarantine;
- expired;
- depleted.

It can be filtered by warehouse, status and text (product or lot). The lot number is a link to the **lot details**.

![Lot list](https://docs.smaklad.pl/img/warehouse-06-lots.png)

The system assigns the lot number itself: `SKU-YYYYMMDD-NNNNNN`, for example `SUR-ZIEMN-20261202-000500`. The supplier batch (for example `ZM-IRGA-1201`) is stored separately, and you can search stock by it (the "Supplier batch" filter).

> **Known issue (December 2026).** The lot details page currently does not open: instead it shows "This page could not be loaded. HTTP 500". Where a lot came from can be seen in the supplier invoice (the invoice line) and in the PZ warehouse document (goods receipt).

**Lot details** (`/en/admin/operations/inventory/lots/{id}`) shows:
- the lot data: status, warehouse, quantity and reservation, supplier batch, dates of receipt, production and expiry, temperature zone, price (the price is not shown to the kitchen);
- **"Where it came from"** — the supplier and the invoice/receipt (PZ; a link to the purchase invoice for admin, manager, accountant), the production order (PW — internal receipt) or the source lots (transfer, split);
- **"Where it went"** — the production orders that consumed it (RW), sales orders (WZ — goods issue) and derived lots;
- warehouse documents and all movements of the lot with links to documents and orders.

Links from the production order details (consumed and output lots) and from the HACCP lot map also lead here.

**Default warehouse.** In `System → Locations` an active warehouse has a **"Make default"** button (admin, manager). There is one default warehouse for the whole installation: when a new one is set, the previous one is unset; an inactive warehouse cannot be the default, and when the default warehouse is deactivated the mark is removed. The production order, manual receipt, receiving wizard and purchase invoice forms fill in this warehouse themselves (it is marked "default" in the list). The server also uses it for receipts and production when no warehouse is specified in the request (then the default-warehouse variable in the server configuration, then the previous selection rule). **Sales (the stock issue for a completed POS / online shop order) do not use this mark**: an order without a warehouse is still issued from the default warehouse in the server configuration (otherwise by the previous selection rule), so that making, for example, the central production kitchen the default does not move the shop's sales to a different warehouse.

## 6.3. Manual receipt (PZ without an invoice)

![Manual receipt](https://docs.smaklad.pl/img/warehouse-02-receipt.png)

**Operations → Movements → Receipt** (`/en/admin/operations/movements/receive`). Used when goods arrived without an invoice: samples, a customer return, entering opening stock. Deliveries with an invoice are better posted through the [receiving wizard](https://docs.smaklad.pl/en/guide/purchasing/): that way the invoice and the stock stay linked.

1. Choose the warehouse (the default warehouse or the only active one is filled in), the date (today by default) and, optionally, the supplier and the number of the source document.
2. Add lines. In each one:
   - product, quantity and unit;
   - unit price in PLN;
   - for products with expiry tracking — the expiry date;
   - optionally the production date and the supplier batch.
3. If the remaining shelf life is shorter than the minimum required on receipt, the system asks for a **reason for accepting short shelf life**.
4. **"Post receipt"**.

The quantity of a product counted in pieces (`szt`, `opak`, `kpl` etc.) can only be entered as a whole number: the system rejects "11,553 pcs of eggs" with the message "Piece goods are accepted only in whole quantities" (`FRACTIONAL_COUNT_QUANTITY`). The same rule applies in MM, WZ, RW, PW, PS, in adjustments, in INW and in count sheets. There is one exception: you may take **exactly the entire** remaining quantity of an old lot, even if it is fractional (this is how balances left over from earlier mistakes are closed). Documents that the system creates itself (recipe-based consumption, receipt from an invoice) are not affected by this rule: a recipe may consume 2,5 eggs per batch.

A PZ document (numbered `PZ/YYYY/MM/NNNN/WAREHOUSE`) and the lots are created **automatically**.

Example: entering opening stock for the kitchen. Onions 2,500 kg × 2,90 = 7,25 zł and cola 12 pcs × 2,40 = 28,80 zł, source document `BO-KUCH/2026-12-02`. After posting, the form shows the PZ number and a total of 36,05 zł. Clicking the button again does not create a second PZ.

The form sends the request with an **idempotency key**. If the same form is submitted again, for example after a network drop, there will be no second receipt. After a successful receipt the form gets a new key ("New receipt").

## 6.4. Lot adjustment

![Lot adjustment](https://docs.smaklad.pl/img/warehouse-03-adjust.png)

**Movements → Adjustment** (admin and manager only):
1. Choose the warehouse and the lot. Empty lots are shown too, so that a surplus found can be booked in.
2. Choose the mode:
   - **"New quantity"** (recommended): you enter how much is actually there;
   - **"Change by ±"**.
3. Choose a **reason** from the list:
   - count correction;
   - surplus found;
   - unexplained shortage;
   - data entry error;
   - other (for "Other" a note is required).
4. For an expired lot or a lot in quarantine you can tick "make available again".
5. Confirm in the dialog.

Example: according to the records, the potato sacks of lot `SUR-ZIEMN-20261202-000500` hold 40,000 kg; the count found 39,200 kg. Mode "New quantity", value `39,2`, reason "Count correction". Below the field you immediately see "Book quantity: 40,000 kg · Δ -0,800 kg". After confirmation the system creates an INW document (stocktake) (`INW/2026/12/NNNN/…`) and shows the change in value: −0,800 × 2,10 = −1,68 zł.

## 6.5. Write-off

**Movements → Write-off**: a list of lots with filters (warehouse, status, search). Expired lots are shown by default; to write off damaged goods, choose the status "Available". The search also finds a lot by its supplier batch. Tick the lots, click **"Write off"**, enter a reason and confirm. The entire free quantity of each selected lot is written off. If some lots could not be written off, the system shows which ones.

![Lot write-off](https://docs.smaklad.pl/img/warehouse-08-writeoff.png)

## 6.6. Warehouse documents

![Warehouse documents](https://docs.smaklad.pl/img/warehouse-04-documents.png)

**Operations → Documents** (`/en/admin/operations/documents`). Filters:
- type (PZ, WZ, RW, PW, MM, ZW, INW, PS, KOR);
- status (draft, posted, voided);
- warehouse;
- dates;
- search by number.

The document page shows the header and the lines (lot, quantity, value). Available actions:

| Action | When | What happens |
|---|---|---|
| **Post** | draft | the document gets a number; stock and lots change; accounting posts the operation. Numbers are issued without gaps: if there is an error, the number is not used up |
| **Delete** | draft | the draft is deleted |
| **Reversal (KOR)** | posted (admin, manager) | a reason is required. A posted KOR correction document is created that reverses the movement. The original document becomes "voided" |
| **Print** | always | the printable form of the document |

All actions except printing require confirmation in a dialog.

### Draft documents

In the header of the documents page there are **"Drafts"** (a list of drafts only) and **"New draft"** (`/en/admin/operations/documents/new`) buttons. On its page, a draft has an **"Edit draft"** button.

Who can prepare drafts: admin and manager — all types (PZ, WZ, RW, PW, MM, ZW, INW, PS); kitchen — RW and PS only. The accountant can only view drafts.

1. Choose the **type** (it cannot be changed after saving) and the **warehouse**. For MM (inter-warehouse transfer), also the **destination warehouse**, which must differ from the source.
2. **Document date** and **operation date**: not in the future, and the operation date no later than the document date (for example, a document dated 03.12 for an issue on 28.11).
3. For RW you can specify the **purpose** ("Production" goes to 501, "Consumption" to 711); for WZ, "Sale" or "Donation (food bank)".
4. For PZ, WZ, ZW (return) — the counterparty and NIP; for all — the source document number, reason and note.
5. Add lines:
   - **INW and PS** — only by a specific lot (chosen from the warehouse's lots); in INW you enter the **counted** quantity (0 is allowed);
   - **PZ, PW, ZW** — by product: quantity, unit price, for PZ the VAT rate, expiry date and supplier batch;
   - **WZ, RW, MM** — either **by product** (lots are picked by FEFO on posting) or **by a specific lot**.
6. **"Save draft"**. The draft is saved without a number and **changes nothing in the warehouse**.

While a draft is open for editing, it is locked by the current user (a lock banner, as with other documents). A draft is posted on the document page with the **"Post"** button — at that point the dates, closed month, stocktakes and stock levels are checked again.

Example: transferring 12 pcs of cola from the main warehouse to the bar. "New draft" → type MM, warehouse "Główny", destination "Bar", dates today, a line "by product" Coca-Cola 0,5 l, quantity `12` → "Save draft" → "Post". The system will not accept a quantity of `11,5` (piece goods).

**A posted document is immutable.** This is guaranteed by the database: an attempt to change it returns error 409. A posted document can only be corrected with a reversal (KOR) and, if needed, a new correct document. Back-dated editing is not possible.

![Document reversal dialog](https://docs.smaklad.pl/img/warehouse-07-document-storno.png)

**Transfer between warehouses (MM).** A draft MM is prepared in the draft editor (see above: "New draft", type MM, source and destination warehouses). It is posted on the document page with the **"Post"** button, like any draft. The document gets its number `MM/YYYY/MM/NNNN/WAREHOUSE` only on posting; a draft has no number. A transfer does not change the stock value: the lot leaves the source warehouse and appears in the destination warehouse at the same unit cost.

![Posted MM transfer](https://docs.smaklad.pl/img/warehouse-11-mm-posted.png)

In the document header, the "Issued by" and "Approved" fields currently show the user's internal code instead of their name (a known issue).

## 6.7. Expiry dates

![Expiry dates](https://docs.smaklad.pl/img/warehouse-05-expiry.png)

**Operations → Expiry dates** (`/en/admin/operations/expiry`):
- The **report** shows lots that are about to expire. Each product has its own warning window: a quarter of the shelf life from the product record (no more than 30 days); "critical" is roughly a tenth of the shelf life (no more than 7 days). If no shelf life is set in the product record, the general settings apply (by default a warning 7 days ahead, critical 3 days ahead). Example: for a product with a 5-day shelf life the warning appears 2 days before expiry, not 7.
- **Every night** (Warsaw time) the system itself:
  - marks lots past their expiry date as "Expired". Such lots are not issued, not transferred and not picked by FEFO. Exception: a lot with a "best before" date can be given to charity with a WZ document with the purpose "donation";
  - creates **one draft PS (write-off of expired stock) per warehouse**.
- **Stock is written off only when a manager posts the draft PS.** The drafts are shown in a table on the same page with "Post" and "Delete" buttons.
- The **"Run check now"** button (admin, manager) does the same as the nightly check.

All warehouse operations are collected on the **Operations → Movements** page:

![Stock movements](https://docs.smaklad.pl/img/warehouse-09-movements.png)

## 6.8. Stocktake

Stocktakes are kept in the **Operations → Stocktakes** section (`/en/admin/operations/stocktakes`):
1. Create a stocktake: warehouse, date, type, committee.
2. Fill in the count sheets; in a "blind" count the book quantities are not shown.
3. If necessary, carry out a second count.
4. Approve the stocktake. The system creates an INW document and posts the surpluses and shortages.

**The warehouse is "frozen" during the count.** From the moment the count starts (statuses "Counting", "Second count" and "Review") until the stocktake is approved or cancelled, no warehouse document of that warehouse can be posted: no receipt, no issue, no transfer (including into this warehouse), no reversal. The system responds "A stocktake of this warehouse is in progress…" (`STOCKTAKE_IN_PROGRESS`, 409). This follows the practice of stocktaking procedures (Accounting Act, Art. 26–27): during the physical count (spis z natury) the warehouse neither receives nor issues goods, otherwise the counted quantity would no longer match the book snapshot and approval would be impossible.

What to do in the meantime:
- prepare documents as **drafts** — they can be saved and edited; post them after approval;
- a sale completed during the count is not issued from stock: the order line is flagged and the system creates a draft WZ; after approval the manager decides whether to post it (the goods left before the count and were not counted) or delete it (the goods are already reflected in the shortage);
- supplier invoice lines that arrive during the count will be "not received"; after approval, retry them (the "Retry" button on the invoice);
- if the warehouse has to be opened urgently, the manager **cancels** the stocktake and starts a new one.

A draft stocktake (count not yet started) does not lock the warehouse.

### New stocktake

The **"New stocktake"** button on the list page opens the form `/en/admin/operations/stocktakes/new`. Only admin or manager can create a stocktake: the button is not shown to the kitchen or the accountant, and the direct link to the form does not let them in. The warehouse marked as default is pre-selected in the form (if there is only one active warehouse, that one); otherwise choose the warehouse yourself.

**General details:**

| Field | What to enter |
|---|---|
| **Warehouse** | the warehouse being counted. Only one stocktake can be open per warehouse |
| **Stocktake date (as of)** | the date for which stock is counted and with which the INW will be dated. Defaults to today's business day. A date in a closed month is not accepted |
| **Type** | "Periodic" (default), "Year-end", "Handover", "Extraordinary", "Ad hoc" |
| **Items per sheet** | how many lines there will be on one numbered count sheet: from 5 to 200, 40 by default |
| **Order (number)** | the number of the internal order under which the stocktake is carried out (optional) |
| **Person materially responsible** | optional. This person cannot be on the committee |
| **"Blind" count** | on by default: the counters do not see the book quantities until all sheets are handed in |
| **Recount of discrepancies** | on by default: items that differ from the books are counted again before review |
| **Notes** | up to 2000 characters |

**Stocktake committee.** Each row has: full name, position (optional) and the role "Chair" or "Member". You need **exactly one chair** and **at least one other member**, from 2 to 10 people in total, all with different names. If you make another person the chair, the previous chair automatically becomes a member. The **"Add member"** button adds a row, the bin icon deletes it (you cannot leave fewer than two rows).

The **"Create stocktake"** button is active only when the committee is filled in correctly. After creation, "Stocktake created" appears and the stocktake details open with the status "Draft" and the number `SPIS/YYYY/NNNN/WAREHOUSE`. Until the count has started, the draft can be edited and cancelled, and the warehouse works as usual.

Example: a year-end stocktake of the cold room as of 31.12. Type "Year-end", 40 items per sheet, order "Zarządzenie 7/2026", person materially responsible Marek Zieliński. Committee: Anna Nowak (Chair), Piotr Wiśniewski (Member). The system will not let you add Marek Zieliński as a committee member as well.

### A delivery invoice that arrives after the stocktake

A real-life example: goods were delivered on 27.11, the warehouse stocktake was posted on 30.11, and the invoice (FZ — purchase invoice) was entered on 01.12 with a delivery date of 27.11. Accounting posts the invoice with the delivery date (Dr 330 / Cr 210), but the warehouse cannot receive the goods dated 27.11: that date is before the posted stocktake ("A stocktake was posted after this date", `STOCKTAKE_AFTER_DATE`).

The system handles it like this:

1. **The stocktake found no surplus of this product** — so the goods were not counted (they were stored separately or were not in the warehouse). The PZ receipt is dated **the day after the stocktake** (01.12 in the example; not earlier than the delivery date, not later than today; if that day falls in a closed month, today's date is used). The PZ note says: "Dostawa z dnia 27.11.2026 (FZ/…), przyjęta po spisie z natury INW/… z dnia 30.11.2026 — towar nieujęty w spisie" (delivery of 27.11.2026, received after the stocktake, goods not included in the count). The warehouse and account 330 agree from the PZ date onwards.
2. **The stocktake found a surplus of this product** — most likely the goods were on the shelf and were counted as a surplus. Receiving them again would double the stock. So the invoice line gets the status "not received" with the code `LATE_DELIVERY_STOCKTAKE_SURPLUS`, and the manager decides when retrying the line (**Finance → Supplier invoices → invoice → "Retry"**, the field "Goods delivered before the stocktake"):
   - **"Counted in the stocktake"** — the surplus is this delivery. In one operation the system posts a **KOR of the surplus** (a partial reversal of the INW for the line quantity; in accounting Dr 769 / Cr 330 — the income from the surplus is removed) and a **PZ** at the invoice price, both documents dated after the stocktake. Result: the goods are in stock once, at the invoice price; 330 = stock on hand. If the surplus has already been used up, the system refuses — then choose the second option;
   - **"Not counted"** — a PZ dated after the stocktake, as in item 1; the surplus remains and will show up in the next stocktake.

Why not "with the delivery date": a posted stocktake closes the warehouse records for its day; changing the stock before it would mean rewriting a result that has already been counted and posted. Why not "just today": a document should be as close as possible to the actual operation, so the first day after the count is used.

The old "Movements → Stocktake" page (`/en/admin/operations/movements/stocktake`) is no longer used and redirects to this section (`/operations/stocktakes`).

![Stocktake list](https://docs.smaklad.pl/img/warehouse-10-stocktakes.png)

## 6.9. What is locked and how to correct it

- **Posted documents** (PZ, WZ, …, INW, PS): immutable, corrected only through KOR.
- **Expired lots and lots in quarantine** do not take part in issues. A lot can be returned to circulation with an adjustment ticking "make available again" (admin, manager), if there are grounds for it.
- **A receipt from a supplier invoice** is corrected on the invoice (retrying the line or voiding the invoice), not in the warehouse.
- **While a stocktake count is in progress, the warehouse is frozen**: documents of this warehouse are not posted (409 `STOCKTAKE_IN_PROGRESS`); prepare drafts. Separately, count sheets are locked against simultaneous editing (423).
- **The quantity of piece goods** must be a whole number (400 `FRACTIONAL_COUNT_QUANTITY`).

## 6.10. Common errors

| Message | Cause | What to do |
|---|---|---|
| "This receipt was already booked with different data" (`IDEMPOTENCY_KEY_REUSED`) | after a successful receipt the form was changed and submitted again | open the PZ documents and check; for a new delivery click "New receipt" |
| "Some lines cannot be received: …" | no expiry date, short shelf life without a reason, unknown product | correct the lines indicated in the message |
| "Insufficient free quantity" | the issue exceeds the stock on hand (taking FEFO and expired stock into account) | check stock and lots |
| "The document is posted and immutable" (409) | an attempt to change a posted document | a reversal (KOR) and a new document |
| "The document is being edited by …" (423) | another user is editing the document or lot | wait, or ask your colleague to close the window |
| "Insufficient permissions" (403) | the action is not allowed for the role | contact a manager |
| "A stocktake of this warehouse is in progress…" (`STOCKTAKE_IN_PROGRESS`) | the warehouse is being counted | save a draft, post it after the stocktake is approved |
| "Piece goods are accepted only in whole quantities" (`FRACTIONAL_COUNT_QUANTITY`) | a fractional quantity for `szt`/`opak` | enter a whole number |
| "The goods were delivered before a posted stocktake…" (`LATE_DELIVERY_STOCKTAKE_SURPLUS`) | a late invoice, and the stocktake found a surplus of this product | retry the invoice line, choosing "Counted" or "Not counted" |
| "Stocktake SPIS/… is already open for this warehouse" (409) | the warehouse already has an unfinished stocktake | complete or cancel it |
| "The committee needs exactly one chair…" / "…at least two persons…" / "Committee members must be distinct persons" | the committee is filled in incorrectly | one chair, at least one member, different names |
| "The person materially responsible for the stock cannot be a member of the stocktake committee" | the person materially responsible is also listed on the committee | replace the committee member |
