Hello! I'm hoping someone can advice what im doing wrong or if there could be a better way of achieving the outcome im after.
Essentially I have a submit button that calculates a new weighted unit cost.
For example, I have 25 items in stock with a unit cost of 2. I want to restock the item by 75 however the new unit cost is 5, therefore my calculating needs to work out a weighted unit cost for the item. In this scenario, the unit cost should be 4.25.
Total cost / total quantity
425 / 100 = 4.25
I have just tested this twice, the first time it worked, the second time it calculated it at 0.5.
So, how i've currently setup the process. OnVisible for the screen I set the current quantity and the current cost.
Then on the submit button, I have this calculation, which I then use to patch the selected item with the new values. The sum for stock works, just not the new unit cost.
I'm hoping there is just a more simple way to achieve this, as I really can't understand how it sometimes works and sometimes doesnt.
Thanks all