We have had some customers ask why they can not reconcile inventory exactly. The total available is in sync, but the volumes are not. This is because we do the calculations a bit differently as explained below.
RunSignup: We keep track of two numbers we’ll call them A and B, “A” the total amount ever put in inventory, and “B” the number we have ever sold. For example:
Put 100 in stock A:100, B:0
Sell 75 A:100, B:75
Put 100 more in stock A:200, B:75
Sell 10 A:200, B:85
The number available for sale is then A minus B.
Shopify: One inventory number that is incremented and decremented as items are added or sold. We are sure their system is more complex than that, but that is what is exposed through the Shopify Inventory API.
So we have to map between these two. When a new Add-on is linked, we have to initially get the inventory from Shopify and assign that to A. Then we keep track of how many sold on our end in B. Then, when we poll Shopify for inventory periodically, we have to see if our (A minus B) number matches the Shopify inventory number. If the numbers match, we don’t update anything on the RunSignup side. If Shopify is more, then items were added on the Shopify side, and we have to update A on our side. If the Shopify number is lower, then items were sold outside of RunSignup (perhaps through a Shopify store, or otherwise removed from inventory), and we have to update B.