Hi all,
My title is probably not as helpful as I would like, but what I am trying to achieve is a stock management system, whereby the user can receive stock in, then track its usage and will also be able to see live, the stock on hand etc.
In the system, the user might receive say 10 different types of stock, and each stock item will have batchcodes that will differ over time. So after a few weeks or months, the data representing what has been ordered/received would look like this:
| StockItem | BatchCode | DeliveryDate | Quantity | Barcode |
| Juice | A12351 | 10/05/2020 | 10 | Z-0001 |
| Sugar | S12375 | 10/05/2020 | 5 | Z-0022 |
| Ice Cream | DD5501 | 11/05/2020 | 12 | Z-0012 |
| Bread | CB401 | 15/05/2020 | 50 | Z-0044 |
| Juice | A12351 | 15/05/2020 | 8 | Z-0001 |
| Bread | CB401 | 18/05/2020 | 75 | Z-0055 |
| Juice | A14559 | 18/05/2020 | 25 | Z-0002 |
| Sugar | S23245 | 18/05/2020 | 9 | Z-0025 |
What I need to do is Sum the data so that I can get the total quantity per BatchCode, so the data would then look like:
| StockItem | BatchCode | Quantity | Barcode |
| Juice | A12351 | 18 | Z-0001 |
| Sugar | S12375 | 5 | Z-0022 |
| Ice Cream | DD5501 | 12 | Z-0012 |
| Bread | CB401 | 125 | Z-0044 |
| Juice | A14559 | 75 | Z-0002 |
| Sugar | S23245 | 9 | Z-0025 |
On the flip side, I also have the Stock Usage, which tracks against the batchcode/barcode so that ultimately I have the same system working for stock usage as I do stock receival. Then with the totals set against them, I should be able to determine stock on hand:
StockReceivalTotal - StockUsageTotal = X
At the moment I have tried gathering this information via a Flow, but haven't been able to build a successfully working one, and I have since tried GroupBy function with a collection. The latter, I have been able to get a gallery showing the BatchCode and the total stock received against it, and patched to a SharePoint list. But I have been unable to get the patch to work so that it either updates existing records, or uses the Defaults property to create a new record if it doesn't exist.
Lastly, even if I can achieve this, I can't get my head around how I can then ensure that the StockUsage data is compared against the right StockReceival data.
I guess what I am after is some guidance on how I can use Powerapps and SharePoint lists to bring this to life, and if there are any tricks to being able to group data (in this case by BatchCode) and be able to reference a unique ID that can be matched against when it comes to the stock usage data.....
Thanks for any feedback or suggestions.