I am implementing a database of a Book Store.
The inventory is controled by this process:
1. An order (sales/purchase) is generated and the order can have many items of inventory.
2. If is an sale order, then the items of the order is charged to the "Item sale order" table and discounted from the "Item inventory" table, and register into "Variance item inventory sale".
3. 2. If is an purchase order, then the items of the order is charged to the "Item inventory" table and discounted from the "Item inventory sale" table, and register into "Variance item inventory".
The question is, how I can do for automatic update the process. Actually I can register and order and the items of the order, but I dont know how to update de Variance of Inventory every time that I generate and order.
Let me know if I'm not clear in my request. Thanks.