Inventory in a store or warehouse is the process of comparing the actual availability of goods with the data in the computer inventory system in order to identify and eliminate discrepancies. The final stage is closing the inventory statement, during which the software records the counting results, calculates the financial totals, and adjusts the stock balances in the software to match the actual stock.
Business owners most often ask the following questions: why the shortage amount in the statement differs from the amount in the write-off document or is equal to zero; what the statement status «Amounts need to be recalculated» means; why closing the statement takes hours and blocks the software; and what to do if database system errors occur during closing.
Automatic Warehouse Documents and Cost Calculation
After the actual quantity of goods has been counted, the inventory statement must be closed. At this point, Torgsoft automatically creates a receipt document for goods for which a surplus has been recorded and a write-off document for goods for which a shortage has been recorded. The quantity of goods in the warehouse is adjusted automatically.
In the receipt invoice created from inventory, the product price is set as the latest purchase cost, which consists of the purchase price and the additional cost of the product. Business owners sometimes notice that the amount in the created write-off document does not match the amount in the shortage report in the inventory statement. This is completely normal system logic: the inventory statement report uses the cost based on the current warehouse status, while the write-off document records the actual cost of goods according to the FIFO principle (first in — first out).
Calculation of Shortage, Surplus, and Misgrading Amounts
A common question from users is why the shortage amount in the statement totals is shown as zero even though write-off documents for the goods were actually created.
This happens because of the misgrading offset mechanism. The software defines misgrading as a simultaneous surplus and shortage of the same product model but of a different grade, color, or size. Torgsoft automatically offsets such surpluses and shortages against each other. The shortage amount is calculated using the formula: the total amount of all write-offs minus the misgrading amount. Accordingly, the shortage amount becomes positive only when the amount of write-offs exceeds the amount of receipts. If the resulting value is less than zero, the shortage amount in the inventory is set to zero.
A Specific Technical Case: «Amounts Need to Be Recalculated» Status
Special attention should be paid to situations where the process of closing the inventory statement is interrupted for some reason. When closing the statement, the system performs complex calculations, including recalculation of the cost of goods in the disposal document.
If the user cancels this process, closes the software through Task Manager, or an unexpected shutdown occurs, the inventory statement will receive the «Amounts need to be recalculated» status. A corresponding icon will appear in the «Number» column of the statements table, and an informational message will be displayed to the user in the status panel indicating that the process was interrupted.
It is not advisable to ignore this status because it directly affects the financial analytics of the business. Consequences of an interrupted calculation:
-
Profit for the period may be calculated incorrectly and may be overstated.
-
The automatically created inventory write-off in the «Analysis - Period» form will be recognized by the system as a regular manual write-off, which will distort the breakdown of the merchandise profit calculation formula.
To correct this situation, select the corresponding statement and click the «Recalculate Amounts» button on the panel. After successful recalculation, the software will change the document status and the warning icon will disappear. An additional protection mechanism is available to optimize this process: if the inventory totals calculation was interrupted, the software will automatically calculate these totals during the next nightly (or manual) cost calculation for all goods in the database.

Optimizing Lengthy Inventory Statement Closing
Sometimes business owners encounter a situation where an inventory statement takes too long to close (from several minutes to many hours), which causes database tables to be locked and stops cashiers from working across the entire retail network. Most of the closing time is spent retrieving the latest purchase prices and calculating cost.
The following optimization tools are used to speed up statement closing:
-
Reorganizing indexes and statistics. Before closing large statements, it is critically important to perform the «Rebuild and reorganize indexes and update statistics» action (in the File menu or Settings - Parameters - Service).
-
Reducing the load during working hours. The developers optimized the process so that, by default, a full cost calculation for the disposal document is no longer performed when an inventory statement is closed. These totals will be calculated later. It is recommended to schedule automatic cost calculation at night through «Scheduled Tasks» so that the system is not overloaded during the day.
-
Algorithm optimization. In newer versions of Torgsoft, purchase price retrieval has been optimized: prices are now requested not for all goods in the statement, but only for those for which a receipt invoice will be created (where the actual quantity is greater than the recorded quantity). Full locking of the goods tables during price retrieval has also been removed, allowing other users to continue working.
System Errors During Closing
Sometimes closing the statement is interrupted by an SQL Server error message. The two most common causes are:
-
Data type conversion error (Arithmetic overflow error converting expression to data type int). This occurs if, in previous periods, a user accidentally scanned a product barcode into the «Quantity» field in warehouse documents (receipt invoices, etc.). The software then attempts to write off or process quantities in the billions, which causes an error. Solution: with the help of technical support, find the document containing the abnormal quantity and correct it.
-
Division by zero error (Divide by zero error encountered). This occurs when closing a statement if the settings specify calculation of the latest purchase price by accounting centers and the product movement history contains initial balance receipt invoices with a negative quantity that were later brought to zero. The solution is to temporarily deactivate the problematic receipt invoice while the inventory statement is being closed.
Comparison Table: Typical Situations, System Logic, and Solutions When Closing Inventory
|
Situation (Business Owner’s Question) |
Cause (Torgsoft Logic) |
Solution and Consequences |
|
The amount in the write-off document does not match the shortage report |
The statement report uses the cost based on the current warehouse status, while the write-off document records the actual cost according to the FIFO principle. |
This is standard software logic. The discrepancy is financially justified, and no additional corrections are required. |
|
The shortage amount is zero even though write-off documents have been created |
Automatic misgrading offset has been applied. The software offset surpluses and shortages against each other, and the receipt amount covered the write-off amount. |
This is normal operation of the offset mechanism. The shortage is set to zero because it is financially covered by the identified surplus. |
|
The «Amounts need to be recalculated» status appears |
The statement closing process (calculation of totals and cost) was forcibly interrupted by the user or a system failure occurred. |
Consequence: distorted financial analytics and overstated profit. Solution: select the statement and click «Recalculate Amounts» manually, or wait for the automatic nightly cost calculation. |
|
The statement takes hours to close and cash register operations are blocked |
Outdated database indexes and statistics. Another possible cause is performing a full cost calculation during working hours when processing a large volume of data. |
Solution: regularly perform the service action «Rebuild and reorganize indexes and update statistics». Schedule cost calculation for nighttime through «Scheduled Tasks». |
|
Database error: Arithmetic overflow error converting... |
In previous documents (for example, receipt invoices), the user accidentally scanned a product barcode directly into the «Quantity» field. |
Solution: contact technical support to locate the warehouse document containing abnormal (billion-level) quantity values and correct it, or find it yourself through product movement and correct the quantity in the document. |
|
Database error: Divide by zero error encountered |
Calculation of the latest purchase price by accounting centers is enabled, while the history contains initial balance receipt invoices with negative quantities that were later brought to zero. |
Solution: temporarily deactivate the problematic receipt invoice with the negative quantity while closing the inventory statement. |









Go back to the previous step