
340 P.2d 840 (1959)
66 N.M. 4
Pat TERRY, Plaintiff-Appellant
v.
Sid PIPKIN, Defendant-Appellee.
No. 6547.
Supreme Court of New Mexico.
June 11, 1959.
*841 Smith & Smith, George M. Murphy, Clovis, for appellant.
Wesley Quinn, Clovis, for appellee.
MOISE, Justice.
This case involves the question of whether or not a judgment entered in an action on account due for goods, wares and merchandise sold by plaintiff to defendant is res judicata in a subsequent action in quantum meruit or in an action for restitution between the same parties for the same goods, wares and merchandise.
The facts are these: Plaintiff (appellant) is in the business of installing pumps. Defendant (appellee) had a pump on his property in Curry County, New Mexico, which was not functioning properly. Plaintiff pulled the pump, made certain repairs thereto and replaced it in defendant's well. Defendant paid him for pulling the pump and replacing it, but refused to pay for the repairs and plaintiff then filed a materialman's lien claim. Thereupon plaintiff sued in contract for the amount claimed to be due for the repairs and to foreclose the materialman's lien. Defendant answered by way of denial, and filed a cross-complaint for damages, to which plaintiff answered.
On the trial of this action the court found the issues in favor of defendant on the main suit and against defendant on his counterclaim, and made findings of fact and conclusions of law, of which we consider Findings 3, 5, 9 and 10 material. We quote them, as follows:
"3. That in the latter part of July of 1957, the defendant, Sid Pipkin, lost the use of an irrigation well situated upon his property due to mechanical failure of the well equipment and that he called one Murrel Jay, the Clovis distributor for Western Pump Company, who had sold him said irrigation well equipment; that the said Murrel Jay secured the service of the plaintiff, Pat Terry, of Bovina, Texas, for the purpose of removing the equipment from said irrigation well to examine it and determine the cause of its failure to operate.
"5. That at the time said machinery was taken to Friona, Texas, by the plaintiff, the defendant agreed to pay plaintiff for the removal of said machinery from the well and for the reinstalling of the same after it had been repaired.
"9. That as soon as the pump and pipe had been re-set the defendant paid the plaintiff for his work in pulling and resetting the pump and pipe.
"10. That this defendant has paid to this plaintiff all that he contracted to pay for and is not now indebted to the plaintiff."
Judgment was entered dismissing plaintiff's complaint and defendant's counterclaim. Thereafter, plaintiff filed the present action, alleging that he was entitled to the reasonable value of his services in making the repairs to the pump (being almost the identical amount sued for before) and in a second alternative count asked for the return of the parts replaced together with reasonable rental thereon and expenses expended in connection therewith and tendered back all the parts removed by him, or the salvage value of parts which he could not return, and again sought foreclosure of the materialman's lien. Defendant filed a motion to dismiss setting forth three grounds, the one material to this appeal being a plea of res judicata, in that the issues in this case had been determined in the previous case. From an order sustaining the motion to dismiss on the ground *842 of res judicata and dismissing plaintiff's complaint this appeal is prosecuted.
This appeal is argued under two points. Both points, however, raise the single question of the correctness of the court's conclusion that the first suit between the parties was res judicata of the issues raised by each of the two counts in the second action.
In our opinion we need to look no further than our decision in the case of Paulos v. Janetakos, 46 N.M. 390, 129 P.2d 636, 638, 142 A.L.R. 1237, for the answer to the problem here presented. A reading of the decision in that case will disclose the close similarity in the two cases.
In Paulos v. Janetakos, supra, we stated that "a prior judgment in a different cause of action between the same parties operates as an estoppel only as to questions, points or matters of fact in issue in that cause which were essential to a decision, and which were decided in support of the judgment." An issue of fact as used in the decision is then defined as one "the determination of which is material, relevant, and necessary to a decision of the case upon its merits." It is further defined as "an ultimate fact, such as is required in allegations of fact in good pleadings, or in findings of fact in cases tried to the court. It is the ultimate fact, the fact without which the judgment would lack support in an essential particular."
We need only inquire as to whether the action in the instant case is on a different cause of action, and if so, whether or not the facts found in deciding the first case and which must be decided differently in the second case in order for the plaintiff to prevail were "matters of fact in issue (in the first case) which were essential to a decision." It is clear that an action in quantum meruit is a different cause of action, from one on contract, and is not barred by a prior suit on contract. Bassis v. Rutenberg, 177 Pa.Super. 339, 110 A.2d 897; Zawada v. Pennsylvania System Board of Adjustment, 392 Pa. 207, 140 A.2d 335; Lorang v. Flathead Commercial Co., 112 Mont. 146, 119 P.2d 273.
To the same effect is the law where a plaintiff is not entitled to recover for breach of contract, but is entitled to restitution, a judgment against him in the breach of contract action does not bar a subsequent action for restitution. Meirick v. Witteman Lewis Aircraft Co., 98 N.J.L. 531, 121 A. 670; 56 Harvard L.R. 26.
Since this suit is based on a different cause of action from the first one, were the ultimate facts decided in the first case determinative of the issues in the second case? As we conceive it, the only finding that could possibly be argued as having such effect is Finding No. 10 quoted above. When the court found that defendant "is not indebted to the plaintiff" did it intend to find that he was not indebted for any cause or under any circumstances? Such could not have been the intention because it was outside the issues of a contract case to determine anything beyond whether or not the defendant was indebted on his contract. The court must have intended to limit its finding to the fact that defendant had paid "plaintiff all that he contracted to pay for and is not now indebted to the plaintiff" for any amount on the contract. This is an ultimate fact and is the full limit to which the finding could go in the first case. Evidence on quantum meruit would not have been admissible in a case based on express contract. Campbell v. Hollywood Race Ass'n, 54 N.M. 260, 221 P.2d 558.
Insofar as any attempt is made to have the finding foreclose indebtedness for any reason, it would be beyond the issues in the case, and not be binding to estop the relitigation of the same issue in a different case. Paulos v. Janetakos, supra. With this finding eliminated as a bar to the second case, we do not perceive of anything else to prevent the prosecution of the same.
Defendant quotes from Freeman on Judgments in an effort to support his position. That Freeman in his work does not *843 agree with defendant's position is evident from the following quotation from Vol. 2, p. 1552, Sec. 736, of his work (Fifth Edition):
"Failure to recover in an action on an express contract does not bar an action on an implied contract arising from the same transaction. * * * An action based upon the existence of an express contract involves a different cause of action from an action of quantum meruit, though founded upon the same transaction."
To like effect is Restatement of Law of Judgments, Sec. 65(2), Example (j).
In support of the lower court's decision, the defendant cites the cases of Armijo v. Mountain Electric Co., 11 N.M. 235, 67 P. 726, and State ex rel. Sofeico v. Hefferman, 41 N.M. 219, 67 P.2d 240, to the effect that a judgment concludes parties and privies not only as to any matter which was offered in evidence, but as to any that might have been offered, and also not only as to matters directly adjudicated, but those necessarily involved. Noting a similar argument in the case of McCarthy v. Kay, 52 N.M. 5, 189 P.2d 450, this Court pointed out that in the case of Paulos v. Janetakos, supra, the authorities had been assembled and the rule as hereinabove set forth in that case adopted as the correct one.
Town of Atrisco v. Monohan, 56 N.M. 70, 240 P.2d 216, is also cited in support of defendant's position. In that case Paulos v. Janetakos, supra, was noted and quoted from extensively. We consider the two cases to be in accord with each other and with the holding herein.
Defendant would also get some comfort from the quotation from 30 Am.Jur. (Judgments) 174, contained in Newbold v. Florance, 54 N.M. 296, 222 P.2d 1085. We do not agree that the quotation supports his position, or that there is any conflict with anything therein contained and our conclusions here.
Defendant argues that since it appears from Finding No. 3 that plaintiff's services were procured by a third party, the benefit therefrom was officiously thrust upon defendant, and accordingly the receipt of the same is not unjust enrichment permitting restitution. We do not pass upon the merits of this argument since the same is defensive matter to be determined upon proper pleadings and trial in the case, and not upon consideration of a defense of res judicata here presented.
Defendant also argues that the rule in Paulos v. Janetakos, supra, has been modified by the subsequent adoption of Rule 13-A of Rules of Civil Procedure (§ 21-1-1 (13(a) N.M.S.A. 1953), and cites the case of Biaett v. Phoenix Title & Trust Co., 70 Ariz. 164, 217 P.2d 923, 22 A.L.R.2d 615, in support of his position. The rule merely requires, and the decision supports the proposition that a party failing to plead any mandatory counterclaim that he has to a cause of action cannot raise the same in a second and separate action. Evidently it is defendant's position that since defendant filed a counterclaim in the first suit, any claim of the plaintiff for recovery on a quantum meruit would have to be pleaded as a counterclaim to the counterclaim of defendant. We do not conceive that this is the intention or purpose of the rule. It is not reasonable to assume that a party who sues on contract, when met with a counterclaim, must then assert by way of defense a new and different cause of action for quantum meruit, if indeed he can. We know of no provision for filing a counterclaim to a counterclaim, or mandatory requirement to amend a complaint to include additional theories as a result of the filing of a counterclaim. See 56 Harv. L.R. 26. There is nothing in Rule 13(a) or any of the other rules which requires a modification of the long standing right to sue on one theory, and when it has been determined that the wrong remedy has been adopted, to then sue on another theory. Nothing therein requires a change in the rule hereinabove stated that upon an adverse result in a suit on contract plaintiff is not barred or estopped from filing *844 a new suit on quantum meruit or for restitution.
One other argument of defendant must be noticed. He contends that since foreclosure of the materialman's lien is sought in both actions it is evident that the two actions involve the same cause of action. The lower court made no pertinent findings of fact concerning the lien beyond those findings quoted above, and its decision merely concluded "that the plaintiff's complaint should be dismissed and materialman's lien stand for naught." In the judgment entered in the cause it was ordered that the "claim of lien * * * be and it hereby is expunged from the records of Curry County, New Mexico * * *." The answer to the argument, in our opinion, lies in the fact that the claim of lien shows on its face that there is a fatal variance between the lien as filed and the claim as alleged in the present suit. The first suit was on an express contract, an account for labor and materials furnished, and the lien was filed on the same theory. The plaintiff having failed to establish his claim on express contract, he has the right to sue on a theory of quantum meruit, but the lien based on a theory of express contract varies so materially that it cannot be foreclosed thereunder. Chavez v. Sedillo, 59 N.M. 357, 284 P.2d 1026. An examination of the lien claim discloses that "an itemized statement of account is attached" as Exhibit "A" and also sets forth the payment terms for the work as "cash on the first day of the following month." Exhibit "A" is denominated a "Verified Statement of Account." The account theory and express contract were the basis of the first action, which having been decided adverse to plaintiff's claim, the lien based on the same theory was extinguished. It could not be foreclosed in an action on quantum meruit. Campbell v. Hollywood Race Ass'n, supra.
This does not mean, however, that plaintiff is not entitled under his complaint to pursue his action on quantum meruit for a money judgment, or for restitution even though there is no lien to foreclose. See Chavez v. Sedillo, supra.
The trial court having erred in sustaining defendant's motion to dismiss on the grounds of res judicata, and in dismissing plaintiff's complaint, its judgment is reversed, with instructions to reinstate the cause on the docket and proceed in a manner not inconsistent herewith.
It is so ordered.
LUJAN, C. J., and McGHEE, COMPTON, and CARMODY, JJ., concur.
