Invoice payments do not follow date sequence of invoices

It has happened several times that when I add a payment from a client that covers several invoices the credited amount is associated to newer invoices rather then older.

For example, this is the situation with one of our clients:

When I receive the payment of 2 541 720 for the oldest two invoices however, this is what happens:

To receive the payment I chose the oldest invoice and received money, but also removed the number of the invoice. I would expect invoice 180183 to be fully paid and like invoice 180165, but instead Manager does not pay anything related to invoice 180165 and instead pays part of the newest invoice 180185.

This is not the first time this happens.

Any ideas?

Automatic allocations go the the unpaid invoice with the oldest due date first, not the oldest issue date. 180185 was due “Today.” 180183 is not due until 8 days from now.

OK that makes sense. Thank you