Accounts receivable partial payment, control over how it is applied

If I receive a partial payment to an invoice, I’d like to be able to say that the payment first apply to late fees before applying to the base amount. This doesn’t matter most of the year, as long as the invoice eventually gets paid in full. But if an invoice is only partially paid at the end of the year I need to make sure that the cash basis of the amounts is correct. Right now it is saying that I am still owed a late fee and the customer paid interest, but according to the structure of how my contract is, they paid the late fee but not the interest. It matters for tax purposes.