When you use the payment selection to pay several invoices with one payment the value of the BusinessPartner field TotalOpenBalance is not calculated the right way. The paid value is subtracted two times.
Reproducing this issue: For example I created a new businesspartner (as a vendor). It has a TOB of 0,00. Then I create one Invoice (Vendor) with an amount of 20,- and one with 30,00 . The TOB of the businesspartner is - 50,00. Now I go to the Payment Selection. I use the "Create From" Button and the the "Prepare Payment" to create one single prepared payment (check) for both invoices. Then I use the "Payment print/export" window to export the payment. After that a payment is created and the TOP field of the Business Partner is 50,00 (not 0,00 as it should be).
For me it seems that the MAllocationHdr updates the TotalOpenBalance value while completing (completeIt() calls updateBP() which recalculates this). But the Payment also updates TotalOpenBalance (in completeIt()). That seems a double update. I am not sure which one of these two updates is the right and which the wrong.