You need to take a look at the aging format. That’s what dictates how the totals get applied to what bucket.
It does depend on how in depth the requirement is, but I’d start with using the apply date for each transaction to evaluate what bucket it needs to go into.
This post from the venerable @gpayne may help you with some examples