This ticket is related to JIRA https://idempiere.atlassian.net/browse/IDEMPIERE-4006 - Wrong matched PO quantity for vendor credit memo.
There should be a matched invoice document for a credit memo quantity and the corresponding invoice quantity for the following reasons:
The invoice quantities will show as unmatched in window Matching PO-Receipt-Invoice for as long as there is no matched invoice between the credit memo qty and corresponding invoice.
If a foreign currency invoice was recorded in a different period and with a different conversion rate than the credit memo, GL account “Inventory Clearing” will not be zero in schema currency and the difference has to be dealt with.
The preferred solution is to generate the matched invoice document automatically where any difference is written off directly to Realized gain/loss because when offsetting Invoice AP and Credit memo AP, it will also go to realized gain/loss.