*498Opinion
WIENER, J.Plaintiff Executive Landscape Corporation (Executive) appeals the judgment of dismissal entered after defendants’ (collectively, San Vicente) demurrer was sustained without leave to amend. The basis of the court’s ruling was that Executive failed to possess the license required under Business and Professions Code section 70311 at the time it entered into a written contract with San Vicente for the management and maintenance of the common areas of San Vicente’s condominium complex. We reverse.
Section 7031 provides a contractor cannot bring or maintain an action to recover for work performed unless he alleges and proves he was duly licensed at all times during performance. In denying recovery to unlicensed contractors courts have rationalized the harsh impact on some competent, but unlicensed, persons by deferring to the legislative determination that deterrence outweighs the cumulative effect of the penalty suffered by the contractor and the unjust enrichment obtained by the property owner. (Lewis & Queen v. N. M. Ball Sons (1957) 48 Cal.2d 141, 151 [308 P.2d 713].) Although unlicensed plaintiffs may obtain some relief from the blanket application of section 7031 through the judicially declared doctrine of substantial compliance (see Latipac, Inc. v. Superior Court (1966) 64 Cal.2d 278 [49 Cal.Rptr. 676, 411 P.2d 564]), the general rule remains essentially unmodified, resulting in favorable and even windfall decisions for those persons against whom unlicensed contractors have sought recovery.
Our research of the reported decisions on whether section 7031 bars recovery indicates the determination of liability or nonliability is almost always made in a factual context either through trial or by summary judgment.2 The case before us is thus procedurally different from most, reaching *499us by appeal from the judgment entered following defendants’ successful demurrer. We are therefore governed by the following well established rules.
We must accept as true all facts pleaded in the complaint. (Tameny v. Atlantic Richfield Co. (1980) 27 Cal.3d 167, 170 [164 Cal.Rptr. 839, 610 P.2d 1330, 9 A.L.R.4th 314].) “We ignore allegations of conclusion of law, and where the allegations in the body of the complaint are contrary to documents incorporated by reference in it, we treat the documents as controlling over their characterization in the pleading.” (Hollister Park Inv. Co. v. Goleta County Water Dist. (1978) 82 Cal.App.3d 290, 292 [147 Cal.Rptr. 91].) The demurrer tests the pleading alone and not the evidence or other extrinsic matters which do not appear on the face of the pleading or cannot be properly inferred from the factual allegations of the complaint. (Childs v. State of California (1983) 144 Cal.App.3d 155 [192 Cal.Rptr. 526]; Ramsden v. Western Union (1977) 71 Cal.App.3d 873, 879 [138 Cal.Rptr. 426]; see Code Civ. Proc., § 430.30; 3 Witkin, Cal. Procedure (2d ed. 1971) Pleading, § 797, p. 2410.) This principle means that if the pleading sufficiently states a cause of action the demurrer cannot be granted on the basis of a showing of extrinsic matters by inference from attached exhibits, affidavits or otherwise except those matters which are subject to judicial notice. (See Childs v. State of California, supra, 144 Cal.App.3d 155; Ramsden v. Western Union, supra, 71 Cal.App.3d at p. 879; see also 3 Witkin, Cal. Procedure, supra, at p. 2410.)
Here, the parties sought to buttress their respective arguments in the demurrer by submitting declarations on the nature of the work actually performed and to be performed in the future. Executive also submitted a dec*500laration from an employee of the Contractors State License Board explaining that in his opinion Executive did not need a license to do maintenance of lawns and shrubs. In the absence of a stipulation agreeing the demurrer could be treated as a motion for summary judgment, the court was precluded from weighing the disputed facts to determine the nature of Executive’s services.
Executive’s complaint incorporated by reference the contract the parties signed in July 1980 which describes the range of services Executive was to perform. The bulk of those services included landscaping and general maintenance.3 Even under the regulations adopted by the Contractors State License Board, a license is not required of those who, for example, mow, water and edge lawns.4 Because a party’s entitlement to compensation under a contract is geared to the nature of his performance rather than his status when the contract is signed (see J. B. Gaines v. Eastern Pacific (1982) 136 Cal.App.3d 679, 682 [186 Cal.Rptr. 421]; Vitek, Inc. v. Alvarado Ice Palace, Inc. (1973) 34 Cal.App.3d 586, 590 [110 Cal.Rptr. 86]), it is factually possible, even likely, for Executive to perform all or substantially all of the *501services covered by the contract without coming within the scope of section 7031.
The purpose of the statute is hardly served when a person who is not required to have a contractor’s license is denied legal redress solely because the form of the contract indicates the likelihood that some, perhaps minimal, services requiring a license may be performed under it. A contractual clause calling for hybrid services does not on its face render the contract unenforceable. The converse is also true. Unlicensed persons may not finesse the statute by drafting contracts calling solely for unlicensed services where in reality other services requiring a license will be performed. In each case, the court must examine the substance rather than the form of the bargain and must make all reasonable inferences in support of plaintiff’s position. (See Scientific Cages, Inc. v. Banks, supra, 81 Cal.App.3d at p. 888.) The contract here can reasonably be interpreted to require Executive to perform work for which no license was required. The court accordingly erred in granting San Vicente’s demurrer.
Disposition
Judgment reversed.
Brown (Gerald), P. J., and Work, J., concurred.
All statutory references are to the Business and Professions Code unless otherwise specified.
Section 7031 provides: “No person engaged in the business or acting in the capacity of a contractor, may bring or maintain 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 and proving that he was a duly licensed contractor at all times during the performance of such act or contract, except that such prohibition shall not apply to contractors who are each individually licensed under this chapter but who fail to comply with Section 7029.”
Taking advantage of the computerized wizardry of the day, our electronic research reveals 78 published opinions discussing section 7031. Fifty-one of these were appeals from trials'; ten others were appeals from grants or denials of summary judgment motions. Of the remaining 17, 13 involve demurrers, nonsuits, or judgments on the pleadings. In these cases a common issue was whether the plaintiff was an independent contractor or an employee (see § 7053) (Skipper v. Gilbert J. Martin Constr. Co. (1957) 156 Cal.App.2d 82 [318 P.2d 732]; Albaugh v. Moss Construction Co. (1954) 125 Cal.App.2d 126 [269 P.2d 936]; Phillips v. McIntosh (1942) 51 Cal.App.2d 340 [124 P.2d 835]), whether the construction took place on farm or agricultural land (see § 7049) (Fraenkel v. Bank of America (1953) 40 *499Cal.2d 845 [256 P.2d 569]), whether a contractor could enjoin the state from prosecuting him for contracting without a license {Howard v. State of California (1948) 85 Cal.App.2d 361 [193 P.2d 11]), or whether he could obtain a judicial declaration of his rights {Chas. L. Harney, Inc. v. Contractors’Bd. (1952) 39 Cal.2d 561 [247 P.2d 913]). Vacating default judgments and confirming arbitrators’ awards comprised the other four decisions.
We do not hold a challenge to plaintiff’s status under section 7031 can never be made by demurrer. If the plaintiff’s pleadings admit the contract accurately describes the services to be performed, the court may conclude as a matter of law those services require license. (See Proffitt & Durnell Plumbing, Inc. v. David H. Baer Co. (1966) 247 Cal.App.2d 518 [55 Cal.Rptr. 764]; Sheble v. Turner (1941) 46 Cal.App.2d 762 [117 P.2d 23]; cf. Johnson v. Mattox (1968) 257 Cal.App.2d 714 [65 Cal.Rptr. 185] [dismissal]; Leonard v. Hermreck (1959) 168 Cal.App.2d 142 [335 P.2d 515] [nonsuit]; Harrison v. Butte Steel Buildings, Inc, (1957) 150 Cal.App.2d 296 [310 P.2d 126] [nonsuit]; see also Brunzell Constr. Co. v. Barton Development Co. (1966) 240 Cal.App.2d 442 [49 Cal.Rptr. 667] [unlicensed plaintiff may not recover for defendant’s anticipatory breach where he could not recover had he been able to perform]; compare Scientific Cages, Inc. v. Banks (1978) 81 Cal.App.3d 885 [146 Cal.Rptr. 780] [contract could reasonably be interpreted to find plaintiff did not need a licepse].)
The landscaping services Executive was obligated to perform included the following: mowing, edging and weeding all lawns as required; cultivating, weeding and trimming all ground covers, shrubs and flower beds as needed; fertilizing all lawns and flower beds at least four times a year; reseeding all lawns, trimming and pruning trees and shrubs as necessary; inspecting the sprinkler system and performing minor repairs upon it; treating the lawns, shrubs and other landscape areas with pesticides for insects and controlling disease as required; replacing shrubs, plants and trees as necessary; removing all clippings and trimmings, raking all fallen leaves and hosing down and cleaning the walkways immediately after mowing and trimming; replacing flower plants four times a year in various areas; furnishing and applying fertilizers, insecticides, weed killers, and other chemicals as necessary; and rehabilitating and renovating all areas which, when the agreement was signed, were lawn burnouts or areas needing replanting or reseeding. Executive also had a number of duties not directly related to landscaping. These included cleaning and sweeping side streets, parking areas, sidewalks and bike paths; washing down sidewalks; cleaning storm drains, gutters, and down spouts twice a year; and performing additional similar services in the event of a natural occurrence creating debris, such as winds or rainstorms; overhauling, maintaining and repairing exterior light fixtures and replacing light bulbs as necessary; inspecting all buildings, storm drains, gutters, down spouts, and grounds for areas requiring repairs, and making minor repairs.
The board has defined a landscape contractor as “. . . a specialty contractor whose principal contracting business is the execution of contracts, usually subcontracts, requiring the art, ability, experience, knowledge, science and skill to install, plant, repair and maintain gardens, lawns, shrubs, vines, bushes, trees and other decorative vegetation including the grading and preparation of plots and areas of land for such architectural horticulture, decorative treatment and arrangement; construct pools, tanks, fountains, pavilions, conservatories, hot and green houses, retaining walls, fences, walks, drainage and sprinkler systems; arrange, fabricate and place garden furniture, statuary and monuments, in connection therewith, or to do any part or any combination of any thereof in such a manner that, under an agreed specification, acceptable landscaping projects can be executed.” (Cal. Admin. Code, tit. 16, § 747.)