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