Found the issue why this Bug happens

in our case it’s Because if the Journal Entry has the following Entries shown below:

if the accounting entries have a payable entry credited on a party. but has also an entry debited on the same party.
when we set them as references in the payment entry the system will calculated the outstanding by subtracting the debited entry on the credited entry despite the accounts of those entry clearly being different. so the payment entry will only show the difference as the outstanding show below

image