When the action is against the person for whom the taxes were assessed or the owner of the land at the time of the sale, his or her heir, devisee, vendee or mortgagee, the court shall, on motion of the defendant made at any time before the trial of the action, ascertain (i) the amount paid by the purchaser at the sale and of the taxes subsequently paid by the purchaser, together with 12 percent per annum thereon, subject to the limitations set forth in Section 40-10-122(a); (ii) with respect to property located within an urban renewal or urban redevelopment project area designated pursuant to Chapters 2 or 3 of Title 24, all insurance premiums paid or owed by the purchaser for casualty loss coverage on insurable structures and the value of all permanent improvements made by the purchaser determined in accordance with Section 40-10-122, together with 12 percent per annum thereon; (iii) with respect to any property which contains a residential structure at the time of the sale regardless of its location, all insurance premiums paid or owed by the purchaser for casualty loss coverage on the residential structure and the value of all preservation improvements made by the purchaser determined in accordance with Section 40-10-122, together with 12 percent per annum thereon, subject to the limitations set forth in Section 40-10-122(a); and (iv) a reasonable attorney's fee for the plaintiff's attorney for bringing the action. The court shall also determine the right, if any, of the defendant to recover any excess pursuant to Section 40-10-28 and shall apply a credit and direct the payment of the same as set forth in subsection (b) of Section 40-10-78. Upon such determination the court shall enter judgment for the amount so ascertained in favor of the plaintiff against the defendant, and the judgment shall be a lien on the land sued for. Upon the payment into court of the amount of the judgment and costs, the court shall enter judgment for the defendant for the land, and all title and interest in the land shall by such judgment be divested out of the owner of the tax deed.
Ala. Code § 40-10-83 (1975)