Two possible causes: 1) the deposit is linked to an open sales order, in which case it can only be applied to invoices linked to the same SO; or 2) the deposit is in a different currency to the customer's open invoices. In the first case, you can close the sales order (assuming it's no longer active). Alternatively, in both cases you can refund the deposit via a clearing account, and then create a payment for the same amount into the clearing account. This will move funds from customer deposits > clearing > accounts receivable.