
235 Or. 579 (1963)
385 P.2d 336
JARVY
v.
MOWREY
Supreme Court of Oregon.
Argued June 28, 1963.
Affirmed September 25, 1963.
Petition for rehearing denied November 5, 1963.
*580 Joseph D. St. Martin, Portland, argued the cause for appellant. With him on the briefs was G.A. Heikkila, Portland.
George G. Van Natta, St. Helens, argued the cause for respondent. With him on the brief was John L. Foote, St. Helens.
Before McALLISTER, Chief Justice, and ROSSMAN, SLOAN, GOODWIN and LUSK, Justices.
AFFIRMED.
GOODWIN, J.
This is an action for work and labor. Plaintiff received a verdict for $7,000 which was set aside. He appeals from the judgment entered for the defendant n.o.v.
The plaintiff, Jarvy, is the personal representative of Daisy Randall, deceased. Mowrey is the personal representative of Guy Lillich, deceased. Lillich and Randall were brother and sister. It has been established in a prior case that Randall, without any express promise that she be paid, performed valuable services for Lillich, and that Lillich died without paying for said services. Lillich did transfer certain jointly-held bank accounts to Randall. See Mowrey v. Jarvy, 228 *581 Or 96, 363 P2d 733 (1961). There is no serious dispute about the relevant facts. The issue is whether the former decree between the same parties in their same representative capacities is a bar to the present action upon an implied contract.
The first case necessarily decided that the bank account Lillich transferred to Randall was not transferred as a payment to Randall. If the trial court in the first case had determined that the transfer was intended to be a payment to Randall for services rendered, the case would have gone the other way. An amended answer had alleged as an affirmative defense that the money in the hands of Daisy Randall at her death had been paid to her by Guy Lillich in satisfaction of an indebtedness for services rendered. The evidence in the first case proved that valuable services had been rendered, but there was a failure of proof that the services had been rendered in expectation of payment. There was also a failure of proof that the parties had treated the transfer as a payment. The trial court found that the money in question belonged to Guy Lillich and impressed a trust upon it. While the theory of a payment of a pre-existing debt was not urged on appeal, the issue was available in the record and could have been urged in this court. In affirming the trial court's decree (with modifications not here material), this court affirmed a decree that could not have been entered if the present plaintiff had established his contention that the money in question was owed to his decedent or had been paid in satisfaction of a debt. If such had been the case, there would have been no trust impressed upon the funds in the hands of Randall's administrator for the benefit of Lillich's estate.
1. In determining what is res judicata, this court *582 has characterized the vital element as "the same claim, demand, and cause of action." Wagner v. Savage, as Adm'r, 195 Or 128, 147, 244 P2d 161 (1952). See, e.g., Morgan v. Portland Traction Co., 222 Or 614, 634, 331 P2d 344 (1958). If the two cases involve the same "claim, demand and cause of action," and the other elements of res judicata are present, then, according to the Wagner decision, the judgment in the first suit not only bars all matters actually determined therein, but also every other matter which might have been litigated and decided as incident to or essentially connected therewith, either as a claim or a defense. See also ORS 43.130, 43.160.
The initial problem, then, is to determine whether the same "cause of action" is involved in the two Jarvy-Mowrey cases. The identity of the parties is conceded. It was ultimately decided by this court in the first Jarvy case that, although the pleadings were unclear (see Mowrey v. Jarvy, 228 Or at 99), the suit was one in equity to impose a trust upon certain funds. In his amended answer in the first case Jarvy alleged:
"That on or about May 25, 1959, Guy E. Lillich * * * for the purpose of paying an indebtedness to his sister, Daisy Randall, for nursing care previously rendered to him, signed and delivered to the payee two checks, one in the sum of $833.38 and the other in the sum of $6,242.50, payable to Daisy Randall, or order, and drawn on two joint accounts * * * standing in the names of Guy E. Lillich and Daisy Randall."
In the first trial, as noted, the foregoing allegation was not proved. The parties treated the issue as properly in the case, however, and put on substantial testimony in regard to it.
*583 2, 3. Granting the force of the rule that the burden of proving res judicata is upon the asserter, the principle of res judicata was formulated in the interest of putting an end to litigation, and should be construed so as to carry out its function in a proper case. See Safety Seal Corporation v. Bond Electric Corporation, 3 F Supp 507 (D Del 1933), and Bruszewski v. United States, 181 F2d 419 (3d Cir), cert. den. 340 US 865, 71 S Ct 87, 95 L Ed 632 (1950). Further the philosophy underlying modern code pleading is that the party having a cause of action or a defense should plead all the pertinent facts in one case and permit the court, in one trial, to dispose of all contentions that can be maintained. See Note, Developments in the Law  Res Judicata, 65 Harv L Rev 820, 826, 827 (1956); Note, Problems of Res Judicata Created by Expanding "Cause of Action" under Code Pleading, 104 U Pa L Rev 955, 962 (1956); and Note, 1955 U Ill L F 627, 628.
4. The principle of res judicata can apply to matters pleaded originally as a defense when used subsequently as a basis for affirmative relief. See, e.g., Mitchell v. Federal Intermediate Credit Bank, 165 SC 457, 164 SE 136, 83 ALR 629 (1932); Restatement, Judgments § 58 (1942). One "* * * cannot use the same defence, first as a shield, then as a sword." O'Connor v. Varney, 76 Mass 231 (10 Gray) (1857).
5. Likewise, with reference to matters in defense, it has been said:
"* * * A party cannot split up his defenses, and present them by piecemeal in successive suits arising out of the same transaction, nor can he relitigate matters which he might have interposed, but failed to do, in a prior action between the same parties about the same subject-matter; and this rule holds true whether the matter that might have *584 been litigated in the former trial would have been therein a ground of action or a defense to the action then pending * * *." Bierer v. Fretz, 37 Kan 27, 30, 14 P 558 (1887).
The difficulty in the present case lies in determining the nature of the defensive claim asserted by Jarvy in the first case. If the defense found in the amended answer is construed as one alleging only an express contract, as the present plaintiff now apparently contends, then a later action upon an implied contract would not necessarily be barred. See, e.g., Pillsbury v. Early, 324 Ill 562, 155 NE 475 (1927); Smith v. Kirkpatrick, 305 NY 66, 111 NE2d 209 (1953); Roberts v. Lee, 72 Ohio App 235, 51 NE2d 108 (1942); 2 Freeman, Judgments 1552, § 736 (5th ed 1925); Schopflocher, What Is a Single Cause of Action for the Purpose of the Doctrine of Res Judicata?, 21 Or L Rev 319, 338 (1942). But see Golden v. Mascari, 63 Ohio App 139, 25 NE2d 462 (1939); Note, Developments in the Law  Res Judicata, 65 Harv L Rev, supra at 826. The cases generally note that the evidence necessary to establish an express contract may be different from that needed to prove a right to recover in quantum meruit. See, e.g., Buddress v. Schafer, 12 Wash 310, 312, 41 P 43 (1895). Accordingly, the failure to prove an express contract will not always bar an action upon an implied contract where no court has ever passed upon the facts necessary to prove the existence of the implied obligation. Smith v. Kirkpatrick, supra. The question remains whether a final judgment rejecting a defense that there was a payment of "an indebtedness," not alleged to arise out of either an express or an implied contract, bars relitigation of the ultimate right of the parties in this case to the sum in controversy.
*585 6. Here the ambiguity was the work of the party (Randall's representative), who seeks after one defeat to rehabilitate his case upon a different theory. The situation is analogous to that in Bryan v. Jones, 138 Ga 719, 75 SE 1117 (1912). Bryan sued for the reasonable value of services he had performed for a decedent. In its defense, the decedent's estate alleged that the claim was res judicata because, when it had earlier sued Bryan to recover certain assets of the estate in Bryan's hands, Bryan had asserted that the property had been turned over to him in payment for the same services, and also that he had received the property as a gift. In the later case, after having failed to prevail in the first case on either theory of his defense, Bryan contended that the trial jury in the first case might not have passed upon the issue of payment because the pleading was ambiguous. The reviewing court made short work of the argument, pointing out that if there had been an ambiguity in the pleading in the first case it was of Bryan's own creation and could not be relied upon to get him back into court on another theory in a later case.
In the first litigation between Jarvy and Mowrey, the trial court settled accounts, as it were, concerning the right to the money then in controversy. The decree, as modified in this court, decided that the money in the hands of Randall at the time of her death reverted to Lillich as an incident of survivorship, and then allowed Randall's administrator to deduct Randall's last illness and funeral expenses. In so deciding the case, the trial court necessarily rejected the theory that Randall was entitled to keep the money as a payment of a debt, express or implied.
Jarvy argues now that the only question tendered by his affirmative defense was the alleged payment *586 of an indebtedness, and not the validity of the indebtedness itself. It has been held that a defendant who pleads payment under a contract in, for example, an action for money had and received has the burden of showing "the nature and extent of that debt." Blake v. Corcoran, 211 Mass 406, 407, 97 NE 1002 (1912); Smith v. Wigton, 35 Neb 460, 53 NW 374 (1892); 58 CJS 944, Money Received § 31. The few authorities cited in support of the contrary rule in Washington v. Beselin, 141 Neb 638, 4 NW2d 753 (1942), are not in point, since they have to do with the affirmative defense of payment when the alleged debtor claims to have paid his creditor. Where, as here, the suit is to impress a trust on funds, the pleader who admits receiving the funds of another has the burden of proving the existence and the validity of the alleged contract upon which he bases his right to retain the money. Jarvy would have prevailed in the first litigation if he could have proved that there was a pre-existing indebtedness and that it motivated the transfer of funds. Indeed, the transcript of the first trial reveals that the court and the parties were aware of the issue, since much of the evidence was relevant solely to prove that Jarvy's decedent had earned the money from Mowrey's decedent.
The evidence produced in the two cases drew the trial court's attention to the factual raw material upon which first the claim of receipt of payment of a debt and now the claim that there was an implied contract must equally be based. The only element that is significantly different between the two cases is the pleader's theory of what those facts meant. It is true that upon the second trial there was some circumstantial evidence that had been omitted in the first case, but that fact does not essentially change the *587 situation. Upon this state of affairs we hold that the first litigation disposed of all the claims that were made or could have been made by Randall's estate against the Lillich estate, and that the case at bar should have been disposed of upon a directed verdict. Accordingly, the judgment entered n.o.v. is affirmed.
