combining different charges to equal particular sum
I work in Accounts Receivable. Often we receive checks for particular payments that don’t reflect total amount due on the statement. The example below shows a payment for $7871.38. Which is the sum of the following charges, $123.66, $2.36, & $7745.36. Now the challenge is figuring out what combination of charges equal what the check was made out for. Right now we are using trial & error. Needless to say that is very time consuming. Is there an equation that exists that I could plug in all the numbers, do some math and figure this out more logically than trial an error?