Have a look at this example:

It will look kind of ugly but the idea is that general ledger transactions posted to accounts receivable are grouped by sales invoice and then by SalesInvoiceAsTransaction
Now you can see two amounts for each invoice.
- Invoice total
- Payment (or other credits) total against invoice
See? No cash-basis complication required.