What happens to stock when an analyze runs
Running a test is the one moment where the paperwork and the physical inventory have to agree. Here is the chain of writes behind a single execution.
An analyze knows what it consumes
A test in Labnize is defined with the chemicals it needs and the quantity of each. That definition is the link between the work the laboratory does and the stock the work eats.
Executing it is one action. Nobody opens the inventory afterwards to subtract anything, which is precisely the step that gets skipped on a busy day and produces a count that does not match.
Choosing the batch
For each required chemical, the execution picks batches according to the organisation consumption policy: FIFO to clear the oldest stock first, or LIFO where that is the house rule. Where one lot cannot cover the requirement, the draw spans several.
This is a policy, not a preference. It is set once per organisation and it applies to every execution, which is what makes the resulting cost figures comparable across labs.
What gets written down
Each affected batch has its quantity decremented, and each decrement writes a stock log entry of type CONSUMED, carrying the user, the batch, the quantity and the execution it belongs to.
A batch drained to zero moves to the finished state rather than disappearing. The history that led there stays queryable, which is the whole point of keeping it.
Why this shows up in three reports
Because the consumption is recorded against both the batch and the analyze, the same event feeds consumption analysis, test analysis and cost analysis without anyone reconciling anything.
That is the argument for doing the write at execution time rather than at month end. The numbers agree because there is only one number.