Sayyiduna Abu Hurayrah (may Allah be pleased with him) says that the Messenger of Allah (peace and blessings be upon him) said: "Whoever makes two sales in one sale, he gets the lesser of the two, or else it is usury (riba)."
(b) The Shaykh (may Allah have mercy on him) said: I read in the book of Abu Sulayman the explanation of this hadith: It seems to be a ruling about a specific case, as if someone paid a dinar in advance for a qafiz of wheat due in one month. When the term came due, he demanded the wheat, and the one who had taken it said: Sell me the qafiz of wheat that I owe you for two qafiz due in two months. This is a second sale that has entered into the first sale, so these are two sales in one sale. They are to be returned to the lesser of the two, that is, to the original. If they conclude the second sale before cancelling the first sale, both of them are dealing in usury.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب البيوع / 10879