If money is left over, apply to the next available item via (logic).
Unless money is sent twice, for two separate sub-items on the same item, in which case if the first amount is insufficient to cover the entirety of the first sub-item, the excess (if any) from the second amount, after being applied to the second sub-item, must be applied to the remainder of the first sub-item.
There are legal ramifications of doing the first way, without the second. And only the actual in-the-trenches people were able to tell us about the second.
Using outsourced process documentation is @&$&ing useless.
In reality, there's one edge case where things needs to be applied in a different, distinct, and very specific order, otherwise (legal consequences).
That said, if I get requirements like that I always have a strong feeling the case can be generalized. Laws generally aren’t as specific as that.