Ahmed, I'm not sure I fully understand your question. But it sounds like you are asking this: You have an invoiced Sales Order, and then are processing a Sales Return Order against it. Maybe your user has used the ribbon button "Get Posted Document Lines to Reverse" to pull from posted sales order lines to create the return lines. However, they must apply the return/credit in one of two ways:
First they could use the "Apply Entries" button (and then click the Set Applies-to-ID) to apply the return against a specific sales order prior to posting the Sales Return.
Second, they could post the Sales Return Order, then go to the Customer Ledger and use Apply Entries to apply the return credit against the original Sales Invoice.
Does this make sense?
Chuck