If judgment is rendered for the plaintiff, the amount of the judgment shall first be credited on any taxes due from the plaintiff under this part, Part 3 (commencing with Section 8601), and Part 31 (commencing with Section 60001), and the balance of the judgment shall be refunded to the plaintiff.