Reversing a purchase invoice sometimes caused incorrect batch transactions

After reversing a purchase invoice, it could happen that the linked quantity on a purchase order line and the associated batch transactions were incorrect. When reversing, the quantity was added to the total instead of being subtracted, causing the total to be incorrect after reentering.