Running an API flow on API flow not working as expected

This is the final piece of the app and it has held me and our whole business up for weeks I desperately need help figuring this out. Thank you to anyone who tries helping!

My app adds flavors to a drink and calculates how much you have to add to weigh it out for a final beverage. this is all using parts per million (PPM)

All flavors work fine but the reason I made this app mostly was to create “blends” or collections of flavors that are in a ratio to give us more precise control of what flavors make up a final beverage.

Instead of adding 100ppm of a fruit punch, adding 100ppm of a fruit blend that includes:

  • 500ppm Fruit Punch
  • 100ppm Strawberry
  • 100ppm Blueberry

The app is designed to take this information and calculate the amount of each flavor you actually end up adding to the final beverage into the “blendFactor” in grams.

I have this working perfectly when the user only adds one blend, but whenever there are more than one blend the logic is completely messes up and nothing ends up calculating correctly. I see no reason why and have done multiple forms of troubleshooting to figure out the issue.

Here is the workflow:
all blendFactors for the whole drink are set to 0.
an API is scheduled on a list of every flavor in the drink.

(Each Flavor Workflow)
an API is scheduled on a list of every blend that is in the drink and that the ingredient is found in. For this example it is the two blends highlighted in the first table.

(Each Blend Workflow)
It adds the current blend factor the parts per million of the flavor in the blend and multiplies it by the PPM size of the blend in the flavor. Which seems like its 0, but its just a very low decimal because it is out of a million.

Then it repeats this process for each blend Fruit punch is found in. The result should be a continually additive number adding each calculated amount to the previous finally showing exactly how much fruit punch each blend in the drink is adding total.

As you can see the grams and blend factor are right, but it only ever calculates for one blend. I can never get it to add all of them together for each ingredient. Is there a better way to debug than server logs because I barely get any information out of it.