How to do First-In-First-Out?

So I have a situation where I simply want to calculate cost-of-goods sold. Allocation is done based on FIFO, however I could only find one reference to a script here: https://community.airtable.com/t/fifo-script-help/35234

Does anyone have a working script? Or is there a non-script way to do this that I’m just not getting it (admittedly I’m new to Airtable). I’m surprised this is not an extremely common problem–I don’t see much in the forums or other websites.

Any help would be appreciated :). Many thanks :pray: