As shown in below image, I need to Pull the tokens based on below mentioned logic
When token id:4 enters into list the cumulative sum of Value is 12 which is >=8. So I need to order first three token whose cumulative Value is <=8. i.e. first three tokens.
In similar way When id:5 enters into list the cumulative sum of Value is 10 which is >=8. So I need to order only id:4 token whose cumulative Value is <=8 i.e only one token.
So in Request number and Require Number in first situation it should be 3 and in second situation it should be 1 and so. How can I achieve this.
Is there any other way if the above mentioned is not possible or any other best way to do.
I'm attaching my model for reference.