I want to know whats the best approach to take on an algorithm. I have 2 tables, one that has products (name, stock_qty) and other works as a log for inventory movement (in, out, created_at, and product.id) What i need to do is to create a report of inventory movement, so i need to add every single log with the same product.id on a certain amount of time (selected from a datepicker), i was thinking in starting a counter for each product.id, but the number of products will vary on the time selected, maybe i could do a @products.count to get the number of products on that search, and then create a loop to create the amount of counters based on the number provided...
Maybe there is a gem to do this, or an easier way...
What do you think? any suggestions will be greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire