Leviticus 25:50-54

NHEB(i) 50 He shall reckon with him who bought him from the year that he sold himself to him to the Year of Jubilee: and the price of his sale shall be according to the number of years; according to the time of a hired servant shall he be with him. 51 If there are yet many years, according to them he shall give back the price of his redemption out of the money that he was bought for. 52 If there remain but a few years to the year of jubilee, then he shall reckon with him; according to his years of service he shall give back the price of his redemption. 53 As a servant hired year by year shall he be with him: he shall not rule with harshness over him in your sight. 54 If he isn't redeemed by these means, then he shall be released in the Year of Jubilee, he, and his children with him.