Stock Maintenance
Stock Maintenance rebuilds IMS on-hand quantities from the transaction history. It starts from each item/store opening quantity and reapplies purchases, purchase returns, stock transfers, sales, sales returns, stock adjustments and stock depreciation to restore the calculated stock balance.
Select one store or all stores
Enter a Store ID to rebuild one location. IMS validates the ID and displays the store name beside it.
Leave the Store field blank to run Stock Maintenance for all stores. This is the broader maintenance operation and can take longer because IMS recalculates every applicable item/store balance.
Run Stock Maintenance
- Choose a Store, or leave Store blank for all stores.
- Click Run.
- Review the warning that the targeted store(s) will be unavailable for transactions during maintenance.
- Click Yes to continue.
- Follow the progress messages while IMS recalculates the stock balances.
- Wait for the Done confirmation before resuming normal activity.
The screen prevents a new run when IMS Autos/maintenance blocking rules are active or when the IMS database connection is unavailable.
What IMS recalculates
IMS rebuilds quantity from the underlying inventory transactions rather than simply trusting the current balance stored in item_prods.qty.
| Stock source | Effect on quantity |
|---|---|
| Opening / First Quantity | Starting balance for the item/store. |
| Purchases | Adds received quantity. |
| Purchase Returns | Subtracts returned quantity. |
| Stock Transfer In | Adds quantity received by the destination store. |
| Stock Transfer Out | Subtracts quantity sent from the source store. |
| Cash / Credit Sales | Subtracts inventory-item sales. |
| Cash / Credit Returns | Adds returned inventory quantity. |
| Stock Adjustments | Applies the signed adjustment quantity. |
| Stock Depreciation | Subtracts depreciated/write-off quantity. |
Maintenance process
The progress indicator represents the main stages of the rebuild:
| Stage | What happens |
|---|---|
| Preparing Stock Maintenance | IMS temporarily disables transaction processing for the targeted store scope and records which stores should be active again afterward. |
| Calculating Stock Movements | IMS combines the applicable inventory movements into a temporary recalculation table by Item Code and Store. |
| Adding Missing Item Store Rows | If a transaction exists for an Item/Store combination that does not yet exist in the stock-balance table, IMS creates the missing row using the item's current cost. |
| Adding Opening Balance | The current quantity is reset to the stored opening/first quantity for the selected scope. |
| Applying Stock Movements | The summed transaction movements are applied to the opening quantity. |
| Finalizing | IMS restores the targeted stores to their operational transaction state and completes the maintenance. |
Missing item/store balances
Stock Maintenance also repairs a specific structural case: a valid transaction history can exist for an Item Code and Store even when the corresponding item_prods balance row is missing. IMS creates that missing Item/Store record before it reapplies the opening quantity and transaction movements.
Transaction safety and rollback
The recalculation is performed as one database transaction. If an error occurs during the maintenance process, IMS rolls the maintenance transaction back rather than leaving a partially recalculated stock balance.
After a successful run, IMS writes a Stock Maintenance entry to the IMS activity log identifying either the selected store or an All Stores maintenance run.
IMS Autos
The Stock Maintenance screen itself is the manual maintenance tool. Where IMS Autos is implemented and configured, the same stock-maintenance requirement can be scheduled as part of the regular automated maintenance process, reducing the need to run it manually as a routine task.