If you call up a Payment in Dynamics Payables Transaction Inquiry, you'll get the Payables Payments Zoom window.
On that window is a button that says 'Re-create check stub'. A client recently asked me to recreate this for an integration
The task was MUCH harder than I thought it would be. It turns out that you have to recursively add in credits, then related invoices, and loop until you've got all the data. In testing we had to loop as many as three times.
Finally, we needed to bring in related invoices at the end.
Hope this is useful to you.
Here's the output that we were trying to mimic: