Despite section 36, the court may, if it considers it just to do so having regard to all the circumstances of the case, allow a party to a discharged contract—
(a) to whom amounts were paid or are payable under that contract before the time of discharge; and
(b) who has incurred expenses before the time of discharge in or for the purpose of the performance of that contract—
to retain or recover (as the case may be) the whole or any part of the amounts paid or payable to that party under the contract in an amount not exceeding the expenses incurred.