How to calculate how many of a top level part can be built based on current inventory

,

I would tell you to review @timshuwy’s bom_explode baq which does this in reverse as in can I build X, maybe it can help you.