In some cases it is possible (and desirable) to adjust matched invoices with a negative quantity.
This can be done by using the VMatch form, when for instance selecting many rows where some are "overmatched" and some are "undermatched" but it all equals out.
The root of the problem is that it's possible to "overmatch" meaning that one receipt is matched to more invoice lines than the total quantity of the receipt.
If an overmatch has happened a corresponding negative match can be made using the VMatch form and a MatchInv with a negative quantity is created.
When this MatchInv is accounted, the accounting is NOT reversed due to .abs() calls on lines 158 and 192 in file Doc_MatchInv.
The commitment release also gets wrong with wrong multiplications and sign. This bug creates serious accounting differences for the NotInvoiceReceipt and InventoryClearing accounts.
But, as said, the root of the problem is that it's possible to "overmatch", and there's probably a lot of ADempiere systems out there with overmatched MatchInv.
This seems to be a bigger problem than I first anticipated.
The reason why .abs() is present is because I suspect that's supposed to work with matching of Vendor Credit Notes and Vendor Returns.
However, in the Matching Form, Vendor Returns and Vendor Credit Notes are presented as positive numbers and can as such be matched to Vendor Receipts and Vendor Invoices... which is wrong.
I'm working on a solution for this and I will post as I resolve.
Hi Daniel, it sounds like the .abs() must take into account the docbasetype?
We have added validation in iDempiere to prevent over matching. Please reopen this issue if it still happen in your testing.