Error when attaching open/posted invoice to payment entry

When trying to attach a posted open invoice to its vendor on a payment entry I get an error message. This is actually happens on multiple vendors.

Business Layer Exception

A valid invoice is required.

Exception caught in: Epicor.ServiceModel

Error Detail

Description: A valid invoice is required.
Program: Erp.Services.BO.PaymentEntry.dll
Method: OnChangeInvoiceNum
Line Number: 8187
Column Number: 29
Table: ApInvHed
Field: InvoiceNum

Client Stack Trace

at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet dataSets)
at Erp.Proxy.BO.PaymentEntryImpl.OnChangeInvoiceNum(String pcInvoiceNum, String pcChangeExchangeRateResponse, PaymentEntryDataSet ds, String& pcQuestion)
at Erp.Adapters.PaymentEntryAdapter.OnChangeInvoiceNum(String pcInvoiceNum, String pcChangeExchangeRateResponse, String& pcQuestion)