Quantity in = Quantity Waiting + Quantity out
Quantity Waiting = Quantity In - Quantity out
Quantity Waiting = Unit Pending

Below image showing that there have pending 4 unit to transact.
User facing error message not enough quantity to transact.
In this case is because the user already transact 4 unit before but user try to cancel 2 units and re-transact again.
Solution: Re-transact 2 units.
User only allow to
re-transact 2 units as there have 2 unit complete transact .