FEFO vs FIFO in 15 lines: allocating stock by expiry date
Most stock code picks batches by arrival date. For anything with an expiry date that is the wrong key: the batch that arrived first is not always the batch that runs out first. The allocator function allocate(batches, qty, rule) { const order = [...batches].s…


