Apply Open Credits to an Invoice during Invoice Entry

How to apply open credits e.g. prepayments, open credit notes etc directly to an Invoice in A/R while entering the Invoice.

The Invoice amount should reduce with the credits amount.