Incorrect batch transactions after reversing a purchase invoice

After reversing a purchase invoice, incorrect batch transactions of type '02 Purchase' were created with quantity 0, when a packing slip was created where the receipt was split into multiple batches.