Qatadah said: I said to Sa'id bin al-Musayyab (may Allah have mercy on him) that Qadi Shurayh (may Allah have mercy on him) used to say: The kitabah is to be paid first and then the debt, or both are to be shared together. Shu'bah was in doubt. Ibn al-Musayyab (may Allah have mercy on him) said: Qadi Shurayh (may Allah have mercy on him) erred, even though he is a judge. Zayd bin Thabit (may Allah be pleased with him) says: The debt will be paid first.
The Shaykh (may Allah have mercy on him) says: It has also been narrated from Qadi Shurayh (may Allah have mercy on him) that he said: The debt is to be paid first.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب المكاتب / 21690