
398 S.W.2d 143 (1965)
CHEM-GAS ENGINEERS, INC., Appellant,
v.
TEXAS ASPHALT & REFINING COMPANY et al., Appellees.
No. 4445.
Court of Civil Appeals of Texas, Waco.
December 27, 1965.
Rehearing Denied January 6, 1966.
*144 Nowlin Randolph, Houston, for appellant.
Brown, Kronzer, Abraham, Watkins & Steely, Curtiss Brown, Houston, for appellees.
WILSON, Justice.
The question in this case is whether the trial court correctly sustained defendant's plea in abatement asserting pendency of a prior action. In our opinion the plea was properly sustained, and we affirm the consequent order of dismissal.
Appellant Chem-Gas Engineers, Inc., was the plaintiff in the present suit in which Texas Asphalt & Refining Company was defendant. The petition alleged plaintiff agreed by written contract to furnish to defendant labor and material to rebuild defendant's existing refinery facilities and to construct three additional units. Judgment was sought for the sum alleged to be due under the contract and for foreclosure of lien. Alternatively, plaintiff sued in quantum meruit for debt. It also prayed that its lien be accorded superiority over that of another defendant. This suit was filed in the 125th District Court of Harris County January 14, 1965. Citation was issued and served on appellee the following day.
The plea in abatement of defendant-appellee, Texas Asphalt & Refining Company, alleged that previously, on January 13, 1965, it had filed in the 151st District Court of Harris County its petition in a suit against Chem-Gas Engineers, Inc. Citation in this prior case was issued January 14, and served January 15, 1965.
The petition in this first filed case also alleged the contract between Chem-Gas and Texas Asphalt by which the former was to build and revamp refinery facilities of the latter. It averred, however, that Chem-Gas failed to properly perform the contract in a good and workmanlike manner, and within the time required. The Texas Asphalt pleading alleged the work was completed about November 12, 1964; the Chem-Gas petition alleged the plant was not ready for acceptance until that date. Texas Asphalt sued for damages alleged to have resulted from breach of the contract, joining the surety on the contractor's performance bond.
The general precept in determining whether the subsequent suit should be abated because of pendency of a prior action between the same parties is stated in Cleveland v. Ward, 116 Tex. 1, 285 S.W. 1063, 1070: the court which first acquires jurisdiction "may exercise it to dispose of the whole subject-matter of the litigation and adjust all the equities between the parties, and is entitled to do so." In that case the first suit was for cancellation of instruments; the second was for recovery on them.
Appellant insists that the exclusive test prescribed by Cleveland v. Ward for determining whether to abate the suit last instituted is whether judgment in the prior *145 action would be res judicata as to that last filed. This was only one of the grounds of decision. The authorities there cited supporting the rule quoted above are to the effect that the first court has power to fully adjudicate "all the matters at issue between the parties incident to" the contract involved in the suit.
In McCurdy v. Gage, 123 Tex. 558, 69 S. W.2d 56, 59, the basis of decision was that of comity in avoiding conflict of jurisdiction. The test adopted was whether the two actions "involve the same subject matter," and as to the court of first filing it was held: "its power being adequate to administer full justice to the rights of all concerned," it should "retain such jurisdiction, undisturbed by the interference of any other court, and dispose of the whole controversy." It was further said, "If the two cases involve the same subject-matter when a plea in abatement is properly and seasonably filed in the case last filed, the latter court should sustain such plea."
If the res judicata test is applied, nevertheless, it also requires affirmance. In Texas the rule of res judicata bars litigation of issues connected with a cause of action or defense "which, with the use of diligence, might have been tried in a former trial, as well as those which were actually tried." Ogletree v. Crates (Tex.Civ.App. 1963), 363 S.W.2d 431, 435.
The rights and duties of the parties to a contract in controversy are conclusively fixed by the judgment insofar as such rights and duties are within the issues adjudicated by necessary inference in determination of the prior action, "although the immediate subject matter of the two actions may be different." 50 C.J.S. Judgments § 736a. See Cockburn v. Noxon, Tex.Civ. App., 135 S.W.2d 516, 518, writ ref.; Dixon v. Watson, 52 Tex.Civ.App. 412, 115 S.W. 100, 102, writ dism.; Connell v. Spires, Tex. Civ.App., 264 S.W.2d 458.
Confusion in divergent earlier Texas cases collated in 118 A.L.R. 1249 (1939) has been dispelled by Rule 97(a) Texas Rules of Civil Procedure, making it mandatory that a party state as a counterclaim "any claim within the jurisdiction of the court, not the subject of a pending action, which at the time of filing the pleading the pleader has against any opposing party, if it arises out of the transaction" which is the subject of the opposing party's claim.
A prime purpose of this Rule is to prevent multiplicity of actions and achieve resolution in one suit of all disputes arising out of common matters. Southern Const. Co. v. United States for Use of Pickard (1962) 371 U.S. 57, 83 S.Ct. 108, 9 L. Ed.2d 31. The decisions interpreting original Federal Rule 13, from which Texas Rule 97(a) is derived, hold that a claim for debt under a contract is a mandatory counterclaim in the suit alleging damages for breach of that contract, and the principle of res judicata applies. Platt & Munk Co. v. Republic Graphics, Inc. (C.A.N.Y.1963), 315 F.2d 847; Ryan Ready Mixed Concrete Corp. v. Franki Foundation Co. (C.A.Tex. 1955), 229 F.2d 289. See 22 A.L.R.2d 627, 629. Under such a provision "an action will generally be abated if the claim on which it is based could have been pleaded in a pending action." 1 Am.Jur.2d, Abatement, Sec. 28, p. 67; 30A Am.Jur., Sec. 386, p. 435. Appellant argues that its subsequent suit made its claim the "subject of a pending action" so that it was no longer a compulsory counterclaim in the prior suit under the proviso of Rule 97(a). To so construe the quoted phrase would have the practical effect of nullifying the Rule, for a defendant in the first case could, by the simple expedient of promptly filing a second suit, uniformly preclude application of the Rule. The second suit was properly abated. Affirmed.
TIREY, J., not participating.
