
104 Cal.Rptr.2d 239 (2001)
86 Cal.App.4th 1443
Henry HOLLAND, Plaintiff and Appellant,
v.
MORSE DIESEL INTERNATIONAL, INC., et al., Defendants and Respondents.
No. A088941.
Court of Appeal, First District, Division Three.
February 13, 2001.
*241 Moore and Moore, Howard Moore, Jr., Oakland, and Marc J. Days, San Jose, for Plaintiff and Appellant.
Thelen Reid & Priest, David Buoncristiani, Kevin O'Brien and Jeffrey S. Bosley, San Francisco, for Defendants and Respondents.
*240 PARRILLI, J.
Business and Professions Code section 7031 bars unlicensed contractors from bringing suit to recover compensation for work requiring a license. In this case, we hold that an unlicensed contractor may pursue an action under 42 United States Code section 1981 for racial discrimination during the performance of his contract, but may not seek damages for the defendant's failure to pay sums due under the contract.
Henry Holland appeals from a judgment of dismissal entered after the trial court sustained a demurrer to Holland's second amended complaint without leave to amend.[1] Holland challenges the court's ruling that his status as an unlicensed contractor foreclosed his civil rights claims. Holland also contends he alleged facts sufficient to exempt him from the license requirement. We disagree with Holland regarding the license requirement. However, we agree that his civil rights claims are viable, though they are subject to the limitation on damages imposed by Business and Professions Code section 7031. Therefore, we reverse.

BACKGROUND
Holland's original complaint included causes of action for breach of contract, enforcement of a stop notice, recovery on a public works payment bond, breach of the covenant of good faith and fair dealing, negligent and intentional misrepresentation, and civil rights damages under state law (Civ.Code, §§ 51.5, 52, & 52.1; Lab. Code, § 1735). It named as defendants a general contractor, Morse Diesel International, Inc. (MDI), two MDI supervisors, the Regents of the University of California, and two surety companies, Seabord and American Home Assurance. Holland, an African American, alleged that he had a contract with MDI to provide clean-up services at a university construction project. During the job, he complained about incidents of racial discrimination against himself and his laborers that created a hostile work environment. After this complaint, MDI informed Holland for the first time that he was required to pay his laborers a prevailing wage rate. It then asked him to perform services beyond those specified in his written contract, which he did. However, when Holland complained again about racial discrimination, MDI retaliated by preventing him from completing the job, refusing to pay him for work already done, and charging him for incomplete performance that was caused by MDI's own refusal to honor the contract. MDI *242 did not breach its contracts with White subcontractors.
MDI and its sureties demurred on the ground that Holland was an unlicensed subcontractor, and therefore Business and Professions Code section 7031 precluded him from recovering any compensation. The trial court rejected Holland's claim that the alleged facts showed he was a supplier of labor and materials rather than a contractor. It sustained the demurrer, giving Holland leave to amend only his civil rights claims. The first amended complaint repeated Holland's original civil rights causes of action and added claims under federal statute (42 U.S.C. § 1981), the California Constitution (art. I, § 8), and the Government Code (§§ 12920, 12921, and 12940, subd (a)). The only named defendants were MDI and its supervisors. The alleged facts were essentially the same, though Holland added a claim that MDI's project superintendent had intentionally ridiculed him in front of contractors and laborers. Holland also included the claim that when MDI asked him to provide further labor, it agreed to compensate him at the prevailing rate.
MDI and the individual defendants demurred again, contending that "[a]ll of Plaintiffs causes of action are thinly veiled attempts to obtain compensation to which he is not entitled as an unlicensed contractor." (Underlining in original.) The court sustained the demurrer with leave to amend the original civil rights claims and analogous claims under federal statute. It struck the other claims because Holland had not sought leave to add them.
Holland's second amended complaint named only MDI as a defendant, and included only claims under 42 United States Code section 1981, for race discrimination in contract terms and conditions and for retaliation. Holland added factual allegations that he had complained to MDI about not being regularly compensated, while similarly situated non-African Americans were receiving payment; that after retaliating against him MDI had compensated an unlicensed non-African American for providing clean-up labor; that MDI did not discover Holland's lack of a license until after its retaliatory refusal to compensate him; and that MDI had a policy of contracting with non-Caucasian persons for clean-up labor and discriminating against these laborers by paying them less than the prevailing wage it paid to Caucasian suppliers of labor. The court sustained MDI's demurrer to the second amended complaint, on the ground that Holland's action was barred by Business and Professions Code section 7031.

DISCUSSION
MDI's demurrer admits all material facts properly pleaded by Holland. If those facts support a cause of action under any valid theory, the complaint survives the demurrer. (Mac v. Bank of America (1999) 76 Cal.App.4th 562, 564, 90 Cal. ` Rptr.2d 476.) If the second amended complaint contradicts or omits facts pleaded in Holland's first two complaints, we will take judicial notice of the earlier complaints and disregard inconsistent allegations, absent an explanation for the inconsistency. (Cantu v. Resolution Trust Corp. (1992) 4 Cal.App.4th 857, 877, 6 Cal.Rptr.2d 151; Colapinto v. County of Riverside (1991) 230 Cal.App.3d 147, 151, 281 Cal.Rptr. 191.) We may also take notice of exhibits attached to the complaints. If facts appearing in the exhibits contradict those alleged, the facts in the exhibits take precedence. (Mead v. Samoa Bank California (1998) 61 Cal.App.4th 561, 567-568, 71 Cal.Rptr.2d 625.) address Holland's claims on the license requirement first, since if he was not an unlicensed subcontractor Business and Professions Code section 7031 would not apply.[2]


*243 1. The Complaints Establish Holland's Status as a Contractor

The Business and Professions Code specifically includes "the cleaning of grounds or structures" as among the functions performed by contractors, and provides that "[t]he term contractor includes subcontractor." (Bus. & Prof.Code, § 7026.) Holland, however, argues that that he was merely a supplier of labor, not a contractor. He relies on the following distinction drawn in Contractors Labor Pool, Inc. v. Westway Contractors, Inc. (1997) 53 Cal.App.4th 152, 61 Cal.Rptr.2d 715: "[T]he [licensing] law need apply only to those who actually perform or supervise the performance of construction services; it need not apply to those who only supply materials to be used by others or laborers who will be supervised by others. Thus, a person or company in the business of supplying equipment or hiring out laborers to be supervised by others is not deemed to act in the capacity of a contractor and is not required to have a license. [Citations.]" (Id. at p. 165, 61 Cal.Rptr.2d 715.) The court held that Contractors Labor Pool, which supplied a variety of temporary construction workers on an hourly basis to a subcontractor on a railway project, did not act as a contractor but merely furnished labor for the project. (Id. at pp. 156-157, 167, 61 Cal.Rptr.2d 715.)
Holland's second amended complaint is carefully couched in terms of "furnishing labor and material." Nevertheless, certain factual allegations strongly suggest that he was performing construction services rather than simply providing laborers to MDI. The complaint states that when Holland told MDI's project manager he was paying his laborers $8 per hour, the manager informed him for the first time that the prevailing wage of $35 per hour was required. If Holland were merely providing labor at an agreed rate, rather than performing a job for a fixed bid, this scenario would have been impossible. The second amended complaint also alleges that the project superintendent at one point asked Holland "to supply additional labor and reclean the third level corridor." The superintendent would not have directed Holland to have his laborers perform this task if Holland were only furnishing laborers to be supervised by MDI.
The earlier complaints clearly establish that Holland was a subcontractor. The original complaint alleged that Holland contracted "to perform a certain specified portion of the original contract" between MDI and the university, an unmistakable description of a subcontract. The contract attached as an exhibit to this complaint confirms that Holland agreed to perform clean-up services for a fixed price, not on an hourly basis. In the first amended complaint, Holland alleged that he had "performed his work for Defendant MDI in a completely satisfactory manner." This claim is inconsistent with the contention that he merely provided laborers for MDI's use. The first amended complaint further alleges that MDI breached Holland's contract but "did not breach the contracts of white subcontracts [sic] and paid white subcontractors the prevailing *244 wage." Such an allegation as part of a discrimination complaint is tantamount to an assertion that Holland too was a subcontractor.
Holland alternately contends he might be considered an employee of MDI, within the holdings of Cargill v. Achziger (1958) 165 Cal.App.2d 220, 331 P.2d 774, and Jackson v. Pancake (1968) 266 Cal.App.2d 307, 72 Cal.Rptr. 111. However, none of Holland's complaints includes the allegation that he was an employee, or any facts supporting such a conclusion.
Finally, Holland argues he should be allowed to amend his complaint to cure its defects on the question of his status as a subcontractor. He proposes amendments alleging that MDI failed to comply with statutes requiring general contractors to list subcontractors on public projects. Such a showing would be insufficient to alter the factual setting established by the first three complaints. Holland's pleadings firmly identify him as a subcontractor.

2. An Unlicensed Contractor May Pursue a Civil Rights Claim

Holland's civil rights claims are based on 42 United States Code section 1981(a), which provides: "All persons within the jurisdiction of the United States shall have the same right in every State and Territory to make and enforce contracts, to sue, be parties, give evidence, and to the full and equal benefit of all laws and proceedings for the security of persons and property as is enjoyed by white citizens, and shall be subject to like punishment, pains, penalties, taxes, licenses, and exactions of every kind, and to no other." Congress has specified that the term "make and enforce contracts" "includes the making, performance, modification, and termination of contracts, and the enjoyment of all benefits, privileges, terms, and conditions of the contractual relationship." (42 U.S.C. § 1981(b).) Congress has also declared that "[t]he rights protected by this section are protected against impairment by nongovernmental discrimination." (42 U.S.C. § 1981(c).)
The trial court dismissed this action based on the following provisions of Business and Professions Code section 7031: "[N]o person engaged in the business or acting in the capacity of a contractor, may bring or maintain any action, or recover in law or equity in any action, in any court of this state for the collection of compensation for the performance of any act or contract for which a license is required by this chapter without alleging that he or she was a duly licensed contractor at all times during the performance of that act or contract, regardless of the merits of the cause of action...."
MDI emphasizes the categorical character of the statutory bar, which our Supreme Court discussed in Hydrotech Systems, Ltd v. Oasis Waterpark (1991) 52 Cal.3d 988, 277 Cal.Rptr. 517, 803 P.2d 370 (Hydrotech ): "The purpose of the licensing law is to protect the public from incompetence and dishonesty in those who provide building and construction services. [Citation.] The licensing requirements provide minimal assurance that all persons offering such services in California have the requisite skill and character, understand applicable local laws and codes, and know the rudiments of administering a contracting business. [Citations.] [¶] Section 7031 advances this purpose by withholding judicial aid from those who seek compensation for unlicensed contract work. The obvious statutory intent is to discourage persons who have failed to comply with the licensing law from offering or providing their unlicensed services for pay. [¶] Because of the strength and clarity of this policy, it is well settled that section 7031 applies despite injustice to the unlicensed contractor. `Section 7031 represents a legislative determination that the importance of deterring unlicensed persons from engaging in the contracting business outweighs any harshness between the parties, and that such deterrence can best be realized by denying violators the right to maintain any action for compensation in the courts of this state. [Citation.] *245 ...' [Citations.]" (52 Cal.3d at p. 995, 277 Cal.Rptr. 517, 803 P.2d 370.)
In Hydrotech, the plaintiff alleged that because it was concerned about licensing problems, it had wanted to provide only equipment for the defendant's project. However, the plaintiff was defrauded by the defendants' false promises that a licensed contractor would work with it on any activities requiring a license, and that it would be paid in full for both equipment and services. (Hydrotech, supra, 52 Cal.3d at p. 993, 277 Cal.Rptr. 517, 803 P.2d 370.) Our Supreme Court rejected the argument that the fraud claim survived the statutory bar: "Regardless of the equities, section 7031 bars all actions, however they are characterized, which effectively seek `compensation' for illegal unlicensed contract work. [Citation.] Thus, an unlicensed contractor cannot recover either for the agreed contract price or for the reasonable value of labor and materials. [Citations.] The statutory prohibition operates even where the person for whom the work was performed knew the contractor was unlicensed. [Citations.] [¶] It follows that an unlicensed contractor may not circumvent the clear provisions and purposes of section 7031 simply by alleging that when the illegal contract was made, the other party had no intention of performing." (52 Cal.3d at pp. 997-998, 277 Cal. Rptr. 517, 803 P.2d 370.)
However, the high court did not foreclose all claims arising out of unlicensed contract work. It declined to overrule Court of Appeal cases permitting fraud claims to go forward when "the plaintiffs involvement as an unlicensed contractor was incidental to the overall agreement or transaction between the parties. By the same token, the primary fraud alleged in each case was external to the arrangement for construction work as such, and was thus unrelated to any protective concern of the licensing law. Under these extraordinary circumstances, the Courts of Appeal understandably concluded that the peripheral involvement of unlicensed contract work did not shield defendants from all tort liability." (Hydrotech, supra, 52 Cal.3d at p. 1001, 277 Cal.Rptr. 517, 803 P.2d 370, italics in original.) The court stated its holding as follows: "In a gardenvariety dispute over money owed an unlicensed contractor, the contractor cannot evade section 7031 by alleging that the express or implied promise to pay for the contractor's work was fraudulent. [Fn. omitted.] However artful the pleadings, if the primary fraud alleged is a false promise to pay for unlicensed construction work, and the primary relief sought is compensation for the work, section 7031 bars the action. [Fn. omitted.]" (52 Cal.3d at p. 1002, 277 Cal.Rptr. 517, 803 P.2d 370.)
Thus, causes of action that do not seek "the collection of compensation for the performance of any act or contract for which a license is required" are beyond the scope of Business and Professions Code section 7031. For instance, in Ranchwood Communities Limited Partnership v. Jim Beat Construction Co. (1996) 49 Cal. App.4th 1397, 57 Cal.Rptr.2d 386, the court held that while contractual indemnity claims were barred by the statute, equitable indemnity and negligence claims were not. (Id. at pp. 1418-1421, 57 Cal.Rptr.2d 386.) Holland's claims of racial discrimination in the form of derogatory comments on the jobsite and retaliation for complaining about those comments are "external to the arrangement for construction work as such, and [ ] thus unrelated to any protective concern of the licensing law." (Hydrotech, supra, 52 Cal.3d at p. 1001, 277 Cal.Rptr. 517, 803 P.2d 370.) The same cannot be said, however, for Holland's allegations that he was not properly compensated, as Caucasian contractors were. These claims directly implicate the statutory proscription against recovery of compensation by unlicensed contractors. Nevertheless, they raise a question of appropriate remedy, not a bar to maintenance of a civil rights cause of action.
*246 The situation presented by Holland's complaint is analogous to the circumstance of a wrongful termination plaintiff who asserts racial discrimination, but is faced with the employer's post-termination discovery of independent grounds for the discharge. In Edwards v. Jewish Hosp. of St. Louis (8th Cir.1988) 855 F.2d 1345, the court held that a plaintiff who would have been discharged even in the absence of racial discrimination could pursue his claim under 42 United States Code section 1981, if he demonstrated that race was a substantial or motivating factor in his discharge. However, the court limited the damages the plaintiff could recover to avoid placing him in a better position because of his race than he otherwise would have occupied. (Edwards, 855 F.2d at pp. 1349-1350; see also McKennon v. Nashville Banner Publishing Co. (1995) 513 U.S. 352, 358-361, 115 S.Ct. 879, 130 L.Ed.2d 852 [evidence of employee wrongdoing discovered after termination does not bar age discrimination claim, but affects available remedy].)
MDI, however, argues that Holland has no viable claim under 42 United States Code section 1981 because his contract was invalid and unenforceable. For this proposition, MDI relies on Fair Employ. Council v. BMC Marketing Corp. (D.C.Cir.1994) 307 App.D.C. 401, 28 F.3d 1268 (BMC). In BMC, testers seeking to uncover employment discrimination sought referrals from an employment agency, armed with fictitious credentials. Suit was filed under 42 United States Code section 1981 when referrals were provided to White testers but not to Black testers. (28 F.3d at p. 1270.) The court held that no cause of action was stated because "BMC did not deny the testers the opportunity to enter into a contract that they could have enforced. [¶] ... the loss of the opportunity to enter into a contract voidable at the other party's will is not cognizable under § 1981." (28 F.3d at p. 1271.)
BMC, and other cases involving mere loss of opportunity to enter into a voidable contract, are inapposite. (See, e.g., Kyles v. J.K. Guardian Sec. Services, Inc. (7th Cir.2000) 222 F.3d 289, 302-304 [employment testers lacked standing under 42 U.S.C. § 1981]; Addisu v. Fred Meyer, Inc. (9th Cir.2000) 198 F.3d 1130, 1138 [agents of resellers who misrepresented themselves as consumers suffered no cognizable injury when denied privilege of entering voidable contract].) Unlike the plaintiffs in those cases, Holland alleges discrimination during a functioning contractual relationship. While he could not enforce the compensation terms of his contract, MDI was certainly entitled to enforce the contract against him, and was in fact using his services. Nothing in either the licensing law or 42 United States Code section 1981 supports the notion that MDI was free to discriminate racially against Holland during the performance of the contract simply because he was unlicensed. Holland's claims that MDI treated him differently on the job than it did Caucasian subcontractors, including an unlicensed Caucasian subcontractor, come within the scope of the protection Congress has provided against discrimination in "the enjoyment of all benefits, privileges, terms, and conditions of the contractual relationship." (42 U.S.C. § 1981(b).)
It is important to note that a contract with an unlicensed contractor, while illegal, "is not malum in se but merely malum prohibitum." (S & Q Construction Co. v. Palma Ceia Development Organization (1960) 179 Cal.App.2d 364, 367, 3 Cal.Rptr. 690; accord, Ranchwood Communities Limited Partnership v. Jim Beat Construction Co., supra, 49 Cal.App.4th at p. 1409, 57 Cal.Rptr.2d 386.) For that reason, California courts have refrained from imposing penalties for noncompliance beyond those provided by Business and Professions Code section 7031. For example, in many cases unlicensed contractors have been permitted to raise sums due to them as an offset in defense of an action against them. (S & Q Construction Co. v. Palma Ceia Development Organization, *247 supra, 179 Cal.App.2d at pp. 367-368, 3 Cal.Rptr. 690; see Ranchwood Communities Limited Partnership v. Jim Beat Construction Co., supra, 49 Cal.App.4th at pp. 1411-1412, 57 Cal.Rptr.2d 386 [citing and discussing cases].) Barring Holland from recovering compensation on his contract with MDI fully serves the purpose of public protection underlying the contractor's licensing law. Barring him from holding MDI responsible for racial discrimination would serve no legitimate purpose.
Accordingly, we conclude that Business and Professions Code section 7031 precludes Holland from seeking damages for sums due on his contract with MDI. He may, however, pursue nominal damages, emotional distress damages, and punitive damages on his claims under 42 United States Code section 1981. (See, e.g., Roberts v. Roadway Exp., Inc. (10 Cir.1998) 149 F.3d 1098, 1105 [emotional distress]; Edwards v. Jewish Hosp. of St. Louis, supra, 855 F.2d 1345, 1352 [nominal and punitive damages].) This rule furthers both the policies of the state licensing law and those of the federal civil rights statute.

DISPOSITION
The judgment is reversed. Holland shall recover his costs on appeal.
McGUINESS, P.J., and CORRIGAN, J., concur.
NOTES
[1]  The notice of appeal, though it refers to the final judgment of dismissal, was filed before the judgment was rendered. We deem the premature notice to have been timely, under California Rules of Court, rule 2(c).
[2]  MDI argues that Holland is collaterally estopped from disputing the license requirement. It bases this claim on a judgment of dismissal obtained by the sureties, after the first demurrer was sustained without leave to amend the claim for recovery on a public works bond. MDI contends this was a separate, appealable judgment that was necessarily based on Holland's status as an unlicensed subcontractor. It reasons that because the court granted leave to amend only for claims that were not based on contract, the unity of interest between MDI and its sureties had come to an end. Therefore, according to MDI, Holland was required to appeal from the judgment obtained by the sureties if he wanted this court to review whether he was subject to the license requirement.

We disagree. Holland's right to appeal from the court's ruling for MDI on the license requirement was preserved by Code of Civil Procedure section 472c, subdivision (b). It is well settled that in an action against a principal and a surety, a judgment determining the rights or duties of only one those parties is not appealable until the rights of the other have been resolved by final judgment. (T & R Painting Construction, Inc. v. St. Paul Fire & Marine Ins. Co. (1994) 23 Cal.App.4th 738, 743, 29 Cal.Rptr.2d 199.) Therefore, the judgment obtained by the sureties was not final and has no preclusive effect on this appeal.
