Abu Hurairah reported,

Whenever a funeral procession was brought to the Messenger of Allah ﷺ or passed by him, he would ask, "Did he leave behind any debt?"If they said yes, he would ask, "Did he leave behind enough to settle it?"If they said yes, he would pray over him. But if they said no, he would say, "Pray over your companion yourselves."

Ahmad 9185

Sahih

حدثنا معاوية قال حدثنا أبو إسحاق عن الأعمش عن أبي صالح

عن أبي هريرة قال

كان رسول الله ﷺ إذا أتي أو مر عليه بجنازة سألهم هل ترك دينا فإن قالوا نعم قال هل ترك وفاء فإن قالوا نعم صلى عليه وإن قالوا لا قال صلوا على صاحبكم

أحمد 9185صحيح
Contents
Reference
Commentary
Ayat
Collection
Musnad Ahmad
Book
Abu Hurairah
Numbering
Darussalam 9185
Ahmad 9185