
7 Cal.App.4th 1375 (1992)
10 Cal. Rptr.2d 1
FOUR STAR ELECTRIC, INC., Plaintiff and Appellant,
v.
F & H CONSTRUCTION, Defendant and Respondent.
Docket No. C009168.
Court of Appeals of California, Third District.
July 8, 1992.
*1377 COUNSEL
Howard M. Hoffman for Plaintiff and Appellant.
Macey & Macey and Richard E. Macey for Defendant and Respondent.
OPINION
SCOTLAND, Acting P.J.
In June 1987, the California Department of Corrections (CDC) contracted with F & H Construction (F & H) for a construction project at CDC's Jamestown facility. In October of that year, *1378 F & H subcontracted with Four Star Electric, Inc. (Four Star) for electrical work on the prison project.
The subcontract contained an indemnification clause which provided in pertinent part: "The Sub-Contractor ... agrees to protect and fully indemnify the Owner and Contractor against all liability for claims and liens for labor, materials, equipment and supplies, including attorneys fees, resulting therefrom which may accrue from labor employed by, or materials, equipment and supplies ordered by the Sub-Contractor."
Four Star failed to pay three of its suppliers, who then filed stop notices with CDC and filed superior court actions against both Four Star and F & H.[1] In each supplier's action, F & H cross-complained against Four Star for indemnification. The cross-complaints alleged that F & H "has complied with all the terms, covenants and conditions of its Subcontract with [Four Star] and has paid [Four Star] any and all monies due [Four Star] on account of any work, labor or material supplied by [Four Star] in accordance with the Contract between [F & H] and [Four Star]."
Four Star did not defend itself, and F & H obtained a default judgment in each case.
In February 1990, Four Star filed the action which is now before us. The complaint alleged that Four Star had fully performed the subcontract but that F & H had paid only a portion of the compensation called for by the subcontract.[2] F & H demurred, claiming the action is precluded by the collateral estoppel effect of the default judgments in the aforesaid indemnification actions wherein F & H alleged it had complied with the subcontract in its entirety and had paid Four Star all monies due under the subcontract.
The trial court agreed, sustaining the demurrer on the ground "the Complaint does not state facts sufficient to constitute a cause of action in that the material issues alleged in the Complaint of Plaintiff have been determined in previous legal proceedings between the parties hereto adverse to Plaintiff resulting in Judgments in favor of Defendant and as such are Res Judicata." A judgment of dismissal was entered.
On appeal, Four Star contends the allegations that F & H fully performed the subcontract are not entitled to collateral estoppel effect because they *1379 were neither material nor necessary to the indemnification judgments. We agree and reverse the judgment of dismissal.
As we shall explain, an indemnitee seeking to recover on an agreement for indemnification must allege the parties' contractual relationship, the indemnitee's performance of that portion of the contract which gives rise to the indemnification claim, the facts showing a loss within the meaning of the parties' indemnification agreement, and the amount of damages sustained. The indemnitee need not allege the underlying contract had been performed in its entirety, i.e., that the indemnitee owed no indebtedness to the indemnitor which would act as a setoff against the request for indemnification, because setoff is a defense which the indemnitor must plead and prove.
Since its cross-complaints for indemnification did not have to anticipate and negate a defense of setoff, F & H's allegation that it had performed the subcontract in its entirety and had paid Four Star all monies due under the subcontract was surplusage. Hence, the allegation was not material to the cross-complaint for indemnification and was not entitled to collateral estoppel effect.

DISCUSSION
(1) Ordinarily, a demurrer tests the sufficiency of the complaint alone and not the evidence or other extrinsic matters. "However, a complaint may be read as if it included matters judicially noticed. (Code Civ. Proc., § 430.30, subd. (a); see 5 Witkin, Cal. Procedure [(3d ed. 1985) Pleading], § 896, p. 337.) Such matters may show the complaint fails to state a cause of action though its bare allegations do not disclose the defect." (Lazzarone v. Bank of America (1986) 181 Cal. App.3d 581, 590 [226 Cal. Rptr. 855].)
Here, F & H requested the trial court to take judicial notice of pertinent portions of court files in the prior actions. The trial court was required to do so upon request (Evid. Code, §§ 452, subd. (d), 453), and we must do likewise on appeal. (Evid. Code, § 459, subd. (a)(1); Lazzarone, supra, 181 Cal. App.3d at p. 590). If the collateral estoppel bar appears on the face of the documents judicially noticed, the defense is properly considered in reviewing the demurrer. (Code Civ. Proc., § 430.30; Lazzarone, supra, at p. 590.)
(2) "Collateral estoppel precludes parties from litigating an issue previously determined in another cause of action between them or their privities. As a prerequisite for asserting this doctrine, it must be shown that the issue was, in fact, litigated and decided in the prior action." (Hulsey v. Koehler (1990) 218 Cal. App.3d 1150, 1156 [267 Cal. Rptr. 523], citations omitted.) A *1380 second prerequisite is that the issue must have been necessary to the prior judgment. (Code Civ. Proc., § 1911; Stanson v. Mott (1976) 17 Cal.3d 206, 213 [130 Cal. Rptr. 697, 551 P.2d 1]; Albertson v. Raboff (1956) 46 Cal.2d 375, 384-385 [295 P.2d 405]; Bronco Wine Co. v. Frank A. Logoluso Farms (1989) 214 Cal. App.3d 699, 712 [262 Cal. Rptr. 899]; In re Marriage of Rabkin (1986) 179 Cal. App.3d 1071, 1082-1083 [225 Cal. Rptr. 219]; 7 Witkin, Cal. Procedure (3d ed. 1985) Judgment, § 268, pp. 710-711.) For example, a trial court's finding that parties intended to create a valid lien was unnecessary to its decision that the writing was insufficient to create a lien; thus, the finding regarding the parties' intent and understanding did not preclude a later proceeding alleging that the lien had not been asserted in good faith. (Albertson, supra, at pp. 384-385.)
(3) Four Star does not challenge the general principle that the doctrine of collateral estoppel may be applied based upon a prior default judgment. (See, e.g., English v. English (1937) 9 Cal.2d 358, 363-364 [70 P.2d 625, 128 A.L.R. 467]; Brown v. Brown (1915) 170 Cal. 1, 5 [147 P. 1168]; Mitchell v. Jones (1959) 172 Cal. App.2d 580, 586-587 [147 P. 1168]; O'Brien v. Appling (1955) 133 Cal. App.2d 40, 42 [283 P.2d 289].) "[A] default judgment conclusively establishes, between the parties so far as subsequent proceedings on a different cause of action are concerned, the truth of all material allegations contained in the complaint in the first action, and every fact necessary to uphold the default judgment; but such judgment is not conclusive as to any defense or issue which was not raised and is not necessary to uphold the judgment." (Mitchell, supra, at pp. 586-587.)
(4a) Rather, Four Star argues the three default judgments entered against it should not be given collateral estoppel effect because the allegations that F & H had paid Four Star "any and all monies due" under the subcontract were not "material allegations" of the cross-complaints for indemnification and, thus, were not necessary to the default judgments. (Mitchell, supra, 172 Cal. App.2d at pp. 586-587.) We agree.
(5) An indemnitee seeking to recover on an agreement for indemnification must allege the parties' contractual relationship, the indemnitee's performance of that portion of the contract which gives rise to the indemnification claim, the facts showing a loss within the meaning of the parties' indemnification agreement, and the amount of damages sustained. (Piggly Wiggly Yuma Co. v. Indemnity Co. (1931) 116 Cal. App. 541, 544 [3 P.2d 15]; Civ. Code, § 1439; Code Civ. Proc., § 457; 4 Witkin, Cal. Procedure (3d ed. 1985) Pleading, §§ 479-482, pp. 515-519; 14 Cal.Jur.3d, Contribution and Indemnification, § 65, p. 727.)
(4b) To show the parties' contractual relationship, F & H appended the subcontract to its cross-complaints for indemnification and alleged in substance that it had performed the subcontract to the extent it paid Four Star *1381 sufficient funds to pay the suppliers.[3] To show a loss within the meaning of the indemnification agreement, F & H alleged that Four Star failed to compensate the suppliers and, as a consequence, the suppliers filed stop notices requiring CDC to withhold funds from F & H and to pay the suppliers directly. Because F & H would not be paid by CDC, F & H was entitled to reimbursement of the funds it had paid to Four Star. The cross-complaints' allegations were "material" and "necessary to uphold the judgment" to the extent they established these facts.
However, the pleadings went beyond this by alleging that F & H paid Four Star all sums due to Four Star under the subcontract, which would include the monies presently at issue (monies assertedly owed by F & H for subcontract work performed after the indemnification action). Claiming this greater allegation was necessary for the default judgments, F & H asserts it "could not have obtained a judgment in any of the three cases referred to herein if it owed any monies to [Four Star]...." "[T]here is no way ... that the three Superior Courts that granted a judgment to [F & H] could have awarded [F & H] a judgment without making a determination that between [Four Star] and [F & H] there were no monies owed from [F & H] to [Four Star] but only from [Four Star] to [F & H]. Any monies awarded [F & H] would have had to have been in excess of any monies owed by [F & H] to [Four Star]...." F & H is wrong.
A concurrent indebtedness or setoff is a "new matter constituting a defense" (i.e., an affirmative defense) which the indemnitor, Four Star, would be obligated to plead in an answer to the cross-complaint for indemnification and prove at trial. (Cf. Temple St. Cable Ry. v. Hellman (1894) 103 Cal. 634, 639 [37 P. 530]; see Interstate Group Administrators, Inc. v. Cravens, Dargan & Co. (1985) 174 Cal. App.3d 700, 706 [220 Cal. Rptr. 250]; Space Properties, Inc. v. Tool Research Co. (1962) 203 Cal. App.2d 819, 827 [22 Cal. Rptr. 166]; 5 Witkin, Cal. Procedure, op. cit. supra, Pleading, § 1004, at pp. 425-426; 14 Cal.Jur.3d, § 69, p. 734; Code Civ. Proc., § 431.30, subd. (b)(2).) Because the existence of a concurrent indebtedness would not deny the "truth of all the essential allegations of the complaint which show a cause of action, but [is a fact] from which it results that, notwithstanding the truth of the allegations of the complaint, no cause of action existed in the plaintiff at the time the action was brought, [the concurrent indebtedness would be] new matter." (Goddard v. Fulton (1863) 21 Cal. 430, 436.)
*1382 (6) It is well settled that allegations of a complaint which anticipate or negate new matter are superfluous. "The only allegations essential to a complaint are those required in stating the cause of action, and allegations inserted for the purpose of intercepting and cutting off a defense are superfluous and immaterial. The matter alleged may be material in the case, but immaterial in the complaint, and a plaintiff cannot by pleading such matter at the outset call upon the defendant to answer it." (Canfield v. Tobias (1863) 21 Cal. 349, 350; 4 Witkin, Cal. Procedure, op. cit. supra, Pleading, § 374, p. 426.)
(4c) To the extent it established Four Star's indebtedness to F & H, the allegation that F & H paid Four Star "any and all monies due" was material and necessary to the cross-complaints for indemnification. However, to the extent it anticipated and negated a possible defense of setoff by alleging, in effect, that F & H had paid all sums due on the subcontract and thus had no concurrent indebtedness to Four Star, the allegation was immaterial and not entitled to collateral estoppel effect. (Mitchell, supra, 172 Cal. App.2d at pp. 586-587.)
F & H's contention that it was required to allege full performance of its part of the subcontract finds no support in the language of the indemnification clause which requires Four Star to indemnify F & H for any liabilities which "accrue" during the life of the agreement. The contractual language indicates the indemnity obligation was ongoing and could be asserted as such obligations arise, not just at the conclusion of the contract. Thus, the indemnification agreement did not require F & H to allege in its cross-complaint in each supplier's action that F & H had fully performed the subcontract.
Our conclusion comports with the practical realities of this case. The suppliers' actions purportedly arose during Four Star's performance of the subcontract before the full scope of its work, including any requested modifications and change orders, could be determined. As a practical matter, Four Star rationally could have concluded that it had no defense to the suppliers' actions and F & H's cross-actions and that Four Star's most economical course would be to permit default judgments to be entered against it. If, however, the default judgments were to collaterally estop Four Star from seeking compensation for other work yet to be performed, Four Star would be compelled to appear in each action and cross-action in order to preserve rights having nothing whatsoever to do with those actions. The result, an increase rather than a decrease in litigation, is precisely what the doctrine of res judicata seeks to avoid. (See gen. 7 Witkin, Cal. Procedure, op. cit. supra, Judgment, § 188, pp. 621-622, and cases cited therein.)
*1383 (7) F & H retorts that, if it was Four Star's burden to assert a claim for monies owed by F & H, Four Star should have done so by cross-complaints in the suppliers' actions rather than by bringing the instant action for breach of contract. F & H relies on Code of Civil Procedure former sections 438 and 439 which provided that a defendant who fails to assert a counterclaim arising out of the transaction set forth in the complaint may not thereafter maintain an action on that claim. (Stats. 1941, ch. 454, § 2, p. 1751.) F & H's reliance on former sections 438 and 439 is misplaced, because they were repealed in 1971. (Stats. 1971, ch. 244, §§ 41, 42, p. 389.) The current statute on compulsory cross-complaints provides that a subsequent complaint is not barred where, as here, "[t]he person who failed to plead the related cause of action did not file an answer to the complaint against him." (Code Civ. Proc., § 426.30, subd. (b)(2).) Accordingly, Four Star's defaults did not preclude it from bringing the present action.
In sum, Four Star's action is not barred by collateral estoppel, and the trial court erroneously sustained F & H's demurrer which so asserted. On remand, the trial court shall have an opportunity to rule on F & H's special demurrer to Four Star's first cause of action on the ground of uncertainty.

DISPOSITION
The judgment (order of dismissal) is reversed. The trial court is directed to vacate its order sustaining F & H's general demurrer without leave to amend and to issue a new order overruling that demurrer. Four Star is awarded its costs on appeal.
Nicholson, J., and Raye, J., concurred.
A petition for a rehearing was denied August 4, 1992, and the opinion was modified to read as printed above. Respondent's petition for review by the Supreme Court was denied October 16, 1992.
NOTES
[1]  In those actions, Brown Wholesale Electric Company sought $73,320.84 plus interest, fees and costs; Union Line Construction, Inc., sought $29,248.41 plus interest, fees and costs; and Capital Wholesale Electric Company, Inc., sought $43,370.21 plus interest, fees and costs.
[2]  The complaint did not identify any particular work for which F & H had not paid Four Star. On appeal, Four Star contends the unpaid portion of the contract involves "breach of contract, modifications, extra work and change orders," and does not involve the suppliers who had filed the prior actions.
[3]  F & H did not allege explicitly that it paid Four Star sufficient funds to pay the suppliers. Rather, F & H alleged it "has complied with all the terms, covenants and conditions of its Subcontract with [Four Star] and has paid [Four Star] any and all monies due [Four Star] on account of any work, labor or material supplied by [Four Star] in accordance with the Contract...." This necessarily includes an allegation that F & H paid Four Star sufficient funds to pay the suppliers. (Civ. Code, §§ 3536, 3537 [the greater contains the less; superfluity does not vitiate].)
