Here we explain ERPNext sales invoice adjustments.
This can be applied to Purchases also. Here a customer returns an invoice fully or partially and makes another purchase and asks the company to adjust the second invoice with the first.
Make invoice for $1000 (Say INV0001)
Make payment entry for $1000
Make credit note against the first invoice, to log return
Then make another Sales Invoice of $1000 (say INV0002)
Then use Journal Entry to knock-off new invoice (#2) against the old invoice (#1).
Watch it here