I'm almost at the end of my final project in the university, I'm trying to control my inStock with my current Stock of articles.
My stock contains the following attributes:
int idMercaderia;
int cantidad;
int idSucursal;
I have two lists that contains Inventario
type POJO
s:
List <Inventario> stock = new InventarioDAO().findAll();
List <Inventario> inStock = new ArrayList <Inventario>();
Before persist in the database, I want to compare the attribute idMercaderia
in both of 'em, if they're the same don't create another entry and just add the quantity cantidad
to the current stock and do a saveOrUpdate()
if not just create another entry.
I'm really stuck in this part and currently run out of ideas after trying iterate both Lists but I can't figure out the stock thingy.
Any help/code will be really appreciated.