Payment term template calculation error


I have put the amounts and calculations correctly.
But I received above when I apply advance payment to invoice.

Can we apply advance payment when we have payment term template selected?

I am using V13

I have the same issue. sometimes it works, oftentimes is not