Year-end stocktaking in Comarch Optima: AI and AIP sheets, the 10,000-item limit, PW/RW valuation and the documents that block the run
The sheet is not the stocktake
The most common misunderstanding about stocktaking in Comarch ERP Optima is that approving the sheet does something to stock. It doesn't. The inventory sheet (AI, arkusz inwentaryzacyjny) is a list of goods with counted quantities next to book quantities. It blocks those goods from moving in that warehouse. That's all it does. Stock quantity and value change only in the third stage, when you run Wykonaj inwentaryzację and Optima generates PW documents for surpluses and RW documents for shortages.
And the third stage is exactly where year-end stocktaking falls over. The run refuses to start while the warehouse has open documents for the goods on the sheet, and on 31 December that's every invoice someone left in the bufor before going home.
I connect Optima to B2B portals, bank statements and AI agents for accounting offices, so I see the stocktake from the data side: which documents block it, which prices end up on the PW and RW, and why the inventory value on the printout differs from the one on the sheet header.
This post is based on Comarch's 2026 help page for the Inwentaryzacja function, the Optima Online article "Jak przeliczyć inwentaryzację?" from August 2026, and Comarch's guide for running a stocktake in large databases. It is the trade-module counterpart of the KPiR stock count guide, and it pairs with the Optima year-end close, because the closing stock feeds the balance sheet.
Three stages, three different documents
| Stage | What you do | Path in Optima | What changes in stock |
|---|---|---|---|
| 1. Prepare sheets | Create an AI for one warehouse, empty or filled with goods | Handel / Inne / Inwentaryzacja, plus button | Nothing. Goods on the approved AI are blocked from transactions in that warehouse |
| 2. Enter counts | Type quantities into the AI, or into per-person auxiliary sheets (AIP) and sum them | AI list, AIP button; lightning icon on the AI sums the AIPs | Nothing. "Różnica" = counted minus book stock is shown per item |
| 3. Execute | Wykonaj inwentaryzację on one or several approved sheets | AI list, lightning button or context menu; in Optima Online also "Zapisz i oznacz jako wykonany" | PWAI for surpluses, RWAI for shortages; the sheet becomes read-only |
The help pages contain a few rules that catch people out in practice:
- One AI covers one warehouse, but one warehouse can have several AI sheets. An item can appear only once across all AI sheets of the same warehouse. If you leave the warehouse field empty, Optima creates one sheet per warehouse.
- Quantities on a new AI are always 0. While the sheet is in the bufor you can add and remove goods but not edit quantities. After you approve it, the list of goods is fixed and the quantities become editable.
- AIP sheets can only contain goods that are already on the AI. The same item may appear many times on each AIP, which is how two people counting the same shelf from both ends works. Once any AIP exists, you can no longer type the AI quantity by hand; the lightning icon sums the AIPs, converting auxiliary units to the base unit from the item card. The sum runs again when the inventory is executed.
- Collector data goes into the AIP, through the import button on the auxiliary sheet.
The 10,000-item rule and the test behind it
Comarch's guide for large databases recommends AI sheets with no more than 10,000 items, split by product group. It also suggests the parameter "bez atrybutów" when generating a filled sheet, because attributes slow the generation down.
The guide publishes its own test: a database with 147,000 price-list items, one workstation with a local SQL Server 2008 R2 Express, 4 GB of RAM. The timings it reports:
| Operation on a 10,000-item sheet | Time in Comarch's test |
|---|---|
| Generate a filled AI (counted quantity = 0) on one warehouse | 2–3 minutes |
| Save the sheet permanently (out of the bufor) | 1–2 minutes |
| Change quantity on one item | a few seconds (about 5) |
| Execute the inventory, warehouse documents to bufor | 1–2 minutes |
| Save the inventory warehouse documents permanently | 3–4 minutes |
That hardware dates from 2013, the year in the guide's screenshots. A current server will be faster. Does that mean you can skip the split? No. The reason behind it hasn't changed: one sheet with 60,000 items is one bufor save that locks the database for a long time, and one problem item holds up the entire warehouse. Comarch adds that stocktaking operations put a heavy load on the system and should run when the server and workstation aren't busy.
What blocks Wykonaj inwentaryzację
Before generating PW and RW, Optima checks the warehouse on the sheet for documents that could still change the stock of the goods being counted. The Optima Online article lists them:
- sales and purchase documents in the bufor: FS, PA, FZ, plus RO, ZD and corrections;
- approved commercial documents with no warehouse document behind them (an FS without a WZ, an FZ without a PZ);
- reservations (RO) and orders (ZD) that haven't been converted;
- open service orders with assigned delivery lots.
The check applies to goods only. A service invoice in the bufor doesn't block. When something does block, the run stops with a window titled "Nie można wykonać inwentaryzacji" and no PWAI or RWAI is created. In a batch the sheets are processed one by one, and the 2026 help says a sheet that can't be closed stops the batch, so later sheets aren't converted either. An operator with a ban on the warehouse gets "Operator ma ustawiony zakaz na magazyn [symbol]".
Reservations are the ones that catch offices out, because they don't look like stock documents. A reservation for an order collected in January blocks a stocktake on 31 December. If you're not sure how they work, I explained it in how customer reservations behave in Optima.
There is a way round the check: the parameter "Inwentaryzacja bez kontroli poprawności dokumentów" in Konfiguracja / Firma / Magazyn / Parametry / Inwentaryzacja. With it on, Optima asks for confirmation and creates PW and RW "unconditionally". I'd use it only after deciding that every listed document is irrelevant to the count, never as a way to make the error go away. The 2026 help also warns about the opposite trap: warehouse documents dated before the sheet date but saved after the count will make the sheet disagree with stock on that date.
Stock on the sheet goes stale
"Stan bieżący" on the sheet is a snapshot from when the sheet was approved or last refreshed. It doesn't follow later changes. The Optima Online article shows what that means: book stock 10 from two receipts, PW1 for 4 and PW2 for 6. After approval PW2 is cancelled. Real stock is now 4, but the sheet still shows 10 and calculates the difference against 10.
The fix is "Aktualizuj stan bieżący", available on approved sheets before execution. It re-reads book stock and recalculates the difference without touching the counted quantities. Run it after you've cleared the blocking documents and right before execution, every time.
How PW and RW are valued
| Document | When | Price used |
|---|---|---|
| PWAI (przyjęcie wewnętrzne, surplus) | counted > book | Last purchase price from the item card |
| RWAI (rozchód wewnętrzny, shortage), module Handel | counted < book | Warehouse costing method, FIFO or LIFO |
| RWAI, module Handel Plus | counted < book | The delivery lots chosen on the document |
The help's example: a FIFO warehouse holds 80 pieces bought at 3 zł and 50 at 5 zł, but only 30 pieces are on the shelf. The 100-piece shortage gives an RW worth 340 zł: 80 × 3 zł plus 20 × 5 zł.
Two parameters decide whether these documents land in the bufor. "Przyjęcie inwentaryzacyjne do bufora" lets you correct the price on the PW before it's final, which is useful when the last purchase price is two years old. "Rozchód inwentaryzacyjny do bufora" lets Handel Plus users pick the lots for the RW. Once saved, PW and RW linked to an AI can't be deleted: Optima answers "Dokument nie może zostać skasowany. Nie można kasować dokumentów PW powiązanych z AI".
The value in the sheet header is simulated from purchase prices. The real inventory value comes from the Spis z natury printout: Handel / Zasoby, set the date, then Wydruk danych / Spis z natury (or the variant split by deliveries). That printout, not the sheet, goes into the year-end file.
Two version notes. In desktop Optima, an executed sheet shows status "I" in the list. In Optima Online, it stays "Zatwierdzony" and the Status column shows "Wykonano". Comarch's older PDF guide also swaps PW and RW in one caption. The help pages are right: PW for surpluses, RW for shortages.
Checklist for 30 December
- Split goods into sheets of up to 10,000 items, by group or location, one warehouse per sheet.
- List every FS, PA, FZ, RO and ZD in the bufor, and every invoice without a WZ or PZ, for the warehouses being counted. Approve, convert or cancel them before the count starts.
- Check the last purchase prices of goods likely to show surpluses, or set PW to go to the bufor.
- Make a database backup before the run. Comarch's guide puts the backup right after it, and I'd do both.
- After the count: AIP sums, Aktualizuj stan bieżący, Wykonaj inwentaryzację, approve PW/RW from the bufor, Spis z natury at 31 December.
Where an agent helps
Step 2 is pure data work. It's also the one that eats half a day per client in an accounting office. An agent with read-only access to Optima, through the Optima API or a SQL view, can list the blocking documents per warehouse on the morning of 30 December, flag items whose last purchase price is older than a year, and compare the Spis z natury total with the stock account in the ledger after posting. It doesn't approve documents or run the stocktake. People do that.
If you want that pre-stocktake check running for your clients before the end of December, write to me.
Let’s talk about your project
Free 30-minute consultation. We’ll figure out if and how I can help.



