You need not make it a purely legal agreement, add one line in the salary advance application form itself stating that "I hereby agree to repay the amount of salary advance of Rs ....../- (Rupees -------) and authorise the company to deduct the same from my salary in six equated monthly instalments starting from the salary payable for the next month." It is not right to state that the employee cannot leave the job in the meanwhile, however you can add a clause that "In the event of my leaving the services of the company before the recovery of advance is completed, I authorise the company to deduct the remaining amount alongwith --% interest on the salary advance amount from my full and final settlement amount."