Just thinking out loud...
If you have a field (last payment) in the SalesOrders table set to Max(Payments::Date) through a relationship to appropriate payments...
then you use this 'last payment' field AND the primary key to relate to another occurrence of Payments, you can get the appropriate AccountName through the relationship.
haven't tried this specifically...just thinking out loud.
Yup, that worked a treat.