I'm working on a project where I came across a problem where I do not know what would be the most efficient way to do it.
My project has a product registration in which I want to control by batch, for example:
Product - Rubber
Lot 1 - I bought a lot of 100 rubbers for R $ 50 reais and I will sell the real R $ 1 each for a total of R $ 100.
Lot 2 - I bought a lot of 100 rubbers for R $ 70 reais and I will sell at R $ 1.70. increase due to purchase period
My bank has 2 tables so far, Product and Product_lote in which I will leave below as is. My question is: how to drop the quantity of each lot when there is a sale and automatically the system move to the next lot without there being any change in the quantity field so that it will serve as a history in the future.