
62 Cal.Rptr.3d 614 (2007)
41 Cal.4th 859
161 P.3d 1168
CITY OF DINUBA et al. Plaintiffs and Appellants,
v.
COUNTY OF TULARE et al., Defendants and Respondents.
No. S143326.
Supreme Court of California.
July 19, 2007.
*616 Meyers, Nave, Riback, Silver & Wilson, Steven R. Meyers, Andrea J. Saltzman, Joseph M. Quinn, San Francisco; Tuttle & McCloskey and Daniel T. McCloskey, for Plaintiffs and Appellants.
McDonough Holland & Allen, T. Brent Hawkins and Daniel M. Wolk, Sacramento, for California Redevelopment Association as Amicus Curiae on behalf of Plaintiffs and Appellants.
Jarvis, Fay & Doporto and Benjamin P. Fay, Oakland, for League of California Cities as Amicus Curiae on behalf of Plaintiffs and Appellants.
Brown, Winfield & Canzoneri, Thomas F. Winfield III and Michael H. Wallenstein, Los Angeles, for Defendants and Respondents.
MORENO, J.
Counties are statutorily required to collect property taxes on behalf of local taxing entities and then allocate and distribute the revenue to these entities pursuant to a complex statutory scheme. (Rev. & Tax.Code, § 95 et seq.; Health & Saf. Code, § 33000 et seq.) The County of Tulare (County) improperly computed the portion of tax revenue to which the City of Dinuba Redevelopment Agency (Agency) was statutorily entitled and Agency now seeks to recover the misallocated revenue.
We granted review to consider whether County is immune from suit under Government Code section 860.2.[1] We conclude that, because Agency does not seek money damages for an "injury" as defined by the Tort Claims Act (Act),[2] section 810 et seq., section 860.2 does not bar Agency's action. We further conclude that because Agency is seeking to enforce a mandatory duty imposed by statute, the remedy of mandamus is available. (Code Civ. Proa, § 1085.) Accordingly, we affirm the judgment of the Court of Appeal.

I. Background
In 2002, Agency retained a private consultant to audit County's property tax assessment *617 and allocation procedures.[3] The audit discovered County had failed to assign the proper tax rate code to certain parcels within the redevelopment project, which resulted in Agency not receiving tax increment revenue to which it was entitled for 2002 and the previous four years (1998-1999 tax year through 2001-2002 tax year). Those funds were instead divided up among other entities in the area. When Agency brought these errors to County's attention, County made the appropriate corrections to the current assessment roll. However, County refused to correct the miscoding retroactively and pay previously misallocated tax increment revenue that had been distributed to other entities.
In November 2002, Agency and the City of Dinuba (City) (collectively, plaintiffs) filed a formal tort claim with County for payment of the full amount of the tax increment funds Agency had been entitled to for the previous four years. When County did not act on the claim, plaintiffs sued County, Tulare County Board of Supervisors, Tulare County Assessor Gregory Hardcastle, and Tulare County Auditor-Controller Jimmy Allen (collectively, defendants). The petition and complaint, as amended, sought a writ of mandate compelling defendants to (1) calculate and distribute the unpaid and underpaid tax increment funds for fiscal years 1997-1998 through 2003-2004; (2) correct the tax rolls for all prior fiscal years in which defendants miscoded and/or failed to properly code parcels; and (3) pay plaintiffs their respective shares of tax increment unlawfully withheld. Plaintiffs also requested a declaration and determination that defendants were required to (1) correct all previous fiscal year tax rolls in which defendants either failed to code or miscoded certain parcels and deprived plaintiffs of their respective share of tax increment revenue; and (2) calculate and pay to plaintiffs their respective share of tax increment funds as corrected.
Defendants demurred to the petition and complaint on the grounds that: (1) the disputed tax revenue had already been distributed to other taxing agencies and defendants could not be required to either recover the funds or pay plaintiffs out of County's general fund; and (2) defendants were immune from liability under section 860.2, which states: "Neither a public entity nor a public employee is liable for an injury caused by: [¶] ... [¶] (b) An act or omission in the interpretation or application of any law relating to a tax."
In their opposition, plaintiffs argued that if the trial court were to grant the demurrer, "Petitioners should be granted leave to amend to put forth further causes of action supported by the allegations for constructive trust, breach of contract, and other non-tort causes of action." At the hearing on defendants' motion, plaintiffs' counsel discussed amending the complaint to add claims for "breach of contract or the imposition of some type of equitable remedy, the constructive trust type theory."
The trial court sustained defendants' demurrer on both grounds. The court ruled that plaintiffs had "not stated a statutory basis to impose liability upon these public entities and their employees, and/or stated a case on point to overcome the immunity afforded the public entities and their employees under Government Code section 860.2." However, the court granted leave to amend, noting that, because plaintiffs were not required to file a tort claim under section 905, subdivision (i), the "new theories for recovery" were not barred.
*618 Rather than appeal the trial court's ruling, plaintiffs filed their second amended complaint. The second amended complaint dropped the claim for a writ of mandate and instead asserted claims for imposition of a constructive trust and for money had and received against defendants and the nine taxing entities that had been mistakenly allocated a portion of the tax increment due to Agency.[4]
Defendants again demurred. The court sustained the demurrer without leave to amend. The court stated: "No matter how Plaintiffs attempt to plead this case, the facts are that the public entity and its officers have immunity under Government Code section 860.2 for any act or omission in the interpretation or application of any law relating to a tax. Plaintiffs have plead [sic] that the Defendants miscoded the tax rate areas and collected taxes and failed to give them the proper credit for their fair share of the tax increment revenue. Plaintiffs have attempted to allege causes of action for money had and received and for a constructive trust, but these fail as a matter of law.... [C]learly[,] the facts are that the Defendants' acts were either an interpretation or application of a law relating to a tax, and thus the Defendants would have immunity for Plaintiffs injury. Therefore, no further leave to amend is granted." Judgment was entered dismissing defendants from the action with prejudice.[5]
Plaintiffs appealed from the judgment of the trial court, contending that their claims for relief are not encompassed by the Act (§ 810 et seq.). In reversing the trial court, the Court of Appeal concluded that plaintiffs' claims do not arise from defendants' breach of their statutory duty, but rather, are "based on breach of a contractual duty. Accordingly, [defendants are] not immune under Government Code section 820.6."[6] We granted defendants' petition for review.

II. Discussion

A. Standard of Review
On appeal from a judgment dismissing an action after sustaining a demurrer without leave to amend, the standard of review is well settled. We give the complaint a reasonable interpretation, reading it as a whole and its parts in their context. (Zelig v. County of Los Angeles (2002) 27 Cal.4th 1112, 1126, 119 Cal. Rptr.2d 709, 45 P.3d 1171.) Further, we treat the demurrer as admitting all material facts properly pleaded, but do not assume the truth of contentions, deductions or conclusions of law. (Ibid.; Aubry v. Tri-City Hospital Dist. (1992) 2 Cal.4th 962, 966-967, 9 Cal.Rptr.2d 92, 831 P.2d 317 (Aubry).) When a demurrer is sustained, we determine whether the complaint states facts sufficient to constitute a cause of action. (Zelig, supra, 27 Cal.4th at p. 1126, 119 Cal.Rptr.2d 709, 45 P.3d 1171.) And when it is sustained without leave to amend, we decide whether there is a reasonable possibility that the defect can be cured by amendment: if it can be, the trial court has abused its discretion and we reverse. (Ibid.)


*619 B. Tax Increment Financing and County's Obligations
As defendants acknowledge, counties have a mandatory duty to collect property taxes, then allocate and distribute the appropriate amounts to various taxing entities pursuant to a complex statutory scheme. (Rev. & Tax.Code, § 95 et seq.) Allocation and distribution of property tax revenue is further subject to the Community Redevelopment Law (CRL). (Health & Saf.Code, § 33000 et seq.) The CRL sets forth the procedures for financing redevelopment projects. (Health & Saf. Code, § 33670.) Under the CRL, such projects are financed by "`tax increment financing.'" (Redevelopment Agency v. County of Los Angeles (1999) 75 Cal. App.4th 68, 71, 89 Cal.Rptr.2d 10.)[7]
Under tax increment financing, "[a]ll taxable property within the area to be redeveloped is subject to ad valorem property taxes. The properties lying within a redevelopment area have a certain assessed value as of the date a redevelopment plan ordinance is adopted. A local taxing agency, such as a city or county, continues in future years to receive property taxes on the redevelopment area properties, but may only claim the taxes allocable to the base year value. If the taxable properties within the redevelopment area increase in value after the base year, the taxes on the increment of value over and above the base year value are assigned to a special fund for the redevelopment agency.
"Once the redevelopment plan is adopted, the redevelopment agency may issue bonds to raise funds for the project. As the renewal and redevelopment is completed, the property values in the redevelopment area are expected to rise. The taxes attributable to the increase in assessed value above the base year value are assigned to the redevelopment agency, which then uses the funds to retire the bonds. The local taxing agencies still receive taxes attributable to the base year assessed value of the properties within the redevelopment area. This way, the redevelopment project in effect pays for itself." (Redevelopment Agency v. County of Los Angeles, supra, 75 Cal.App.4th at p. 71, 89 Cal.Rptr.2d 10; Redevelopment Agency v. County of San Bernardino (1978) 21 Cal.3d 255, 259, 145 Cal.Rptr. 886, 578 P.2d 133; Health & Saf.Code, § 33670 et seq.)
To determine which local entities are entitled to the tax revenue collected from any given parcel of property, the county assigns each parcel to a certain tax rate area. (Cal.Code Regs., tit. 18, § 252.) A tax rate area is "a specific geographic area all of which is within the jurisdiction of the same combination of local agencies and school entities for the current fiscal year." (Rev. & Tax.Code, § 95, subd. (g).) Property tax revenue from parcels assigned to a certain tax rate area is allocated by the county to the local agencies having jurisdiction in the tax rate area. (See id., § 96.1, subd. (a)(1).) Thus, if a particular parcel of property is assigned to a tax rate area that does not include a particular entity, no allocation is made for that entity and it will not receive any of the tax revenue collected from that parcel.
With the statutory scheme in mind, we consider the scope of governmental immunity under the Act and whether relief is available.


*620 1. Government Code Section 860.2 Does Not Bar Recovery

Defendants argue plaintiffs' action to recover misallocated tax revenue is barred by the Act. (§ 810 et seq.) Specifically, defendants contend section 860.2, which states, "Neither a public entity nor a public employee is liable for an injury caused by: [¶] ... [¶] (b) An act or omission in the interpretation or application of any law relating to a tax," immunizes County from having to pay defendants previously misallocated revenue. We disagree.
First, section 860.2 is concerned with limiting governmental liability for an injury, which is defined in section 810.8 as "death, injury to a person, damage to or loss of property, or any other injury that a person may suffer to his person, reputation, character, feelings or estate, of such nature that it would be actionable if inflicted by a private person." Defendants' failure to comply with their statutory duty to correctly allocate and distribute tax revenue to other public entities does not constitute an "injury" within the narrow meaning of sections 810.8 and 860.2. (Aubry, supra, 2 Cal.4th at pp. 968-970, 9 Cal. Rptr.2d 92, 831 P.2d 317; see Forbes v. County of San Bernardino (2002) 101 Cal. App.4th 48, 55, 123 Cal.Rptr.2d 721.) The wrong plaintiffs complain of "is one which by its very nature could not exist in an action between private persons .... [a]s a result, the injury alleged in this case is not included within the Tort Claims Act's definition of injury." (Aubry, supra, 2 Cal.4th at p. 968, 9 Cal.Rptr.2d 92, 831 P.2d 317.) Accordingly, section 860.2, which only provides immunity from liability for an "injury" as defined by the Act, does not apply here.
Second, the immunity provisions of the Act are only concerned with shielding public entities from having to pay money damages for torts. (Schooler v. State of California (2000) 85 Cal.App.4th 1004, 1013, 102 Cal.Rptr.2d 343.) Section 814 explicitly provides that liability based on contract or the right to obtain relief other than money damages is unaffected by the Act. Plaintiffs do not seek damages; they seek only to compel defendants to perform their express statutory duty. While compliance with the duty may result in the payment of money, that is distinct from seeking damages. (Board of Administration v. Wilson (1997) 52 Cal.App.4th 1109, 1125-1126, 61 Cal.Rptr.2d 207 [mandamus to compel transfer of payments is not equivalent to seeking money damages].) For example, had plaintiffs sought compensatory damages for a downgraded bond rating or increased interest rates as a result of defendants' failure to disburse the funds to which plaintiffs were entitled, such damages would likely be precluded. But plaintiffs do not seek such damages and thus section 860.2 does not bar their action.[8]

2. Mandamus is Available to Compel Compliance With Duty
A party may seek a writ of mandate "to compel the performance of an act which the law specially enjoins, as a duty resulting from an office, trust or station...." (Code Civ. Proa, § 1085, subd. (a).) In order to obtain writ relief, a party must establish "`(1) A clear, present and usually ministerial duty on the part of the respondent ...; and (2) a clear, present and beneficial right in the petitioner to the *621 performance of that duty....'" (Santa Clara County Counsel Attys. Assn. v. Woodside (1994) 7 Cal.4th 525, 539-540, 28 Cal.Rptr.2d 617, 869 P.2d 1142 (Woodside).) It is undisputed that defendants had a duty to correctly calculate and distribute the tax revenue. Nor can it be disputed that plaintiffs had a beneficial right in defendants doing so. It follows then that mandamus provides an appropriate remedy for defendants' failure to comply with their statutory duty.
Courts have frequently found mandamus to be available in cases similar to the one at bar, where one public entity seeks to force another to release funds in accordance with a statutory duty. In Lackner, the county sued the director of the state agency administering the Medi-Cal program seeking to force the release of reimbursement monies allegedly withheld in violation of statute. The state agency argued that the county's failure to properly present a tort claim for damages prevented the trial court from awarding payment of the funds. (Lackner, supra, 97 Cal. App.3d at pp. 586-587, 159 Cal.Rptr. 1.) Rejecting the state agency's contention, the Court of Appeal explained that "[a]n action in traditional mandamus, which seeks an order compelling an official to perform a mandatory duty, is not an action against the state for money, even though the result compels the public official to release money wrongfully detained." (Id. at p. 587, 159 Cal.Rptr. 1; accord, County of Los Angeles v. Riley (1942) 20 Cal.2d 652, 128 P.2d 537 [mandamus appropriate to force state to recalculate credit for aid payments]; County of L.A. v. State Dept. Pub. Health (1958) 158 Cal.App.2d 425, 322 P.2d 968 [mandamus appropriate to force state agency to release tuberculosis subsidies].)[9]
Defendants argue that being forced to correct their mistake and pay plaintiffs misallocated revenue would "inject uncertainty in the public fisc" and have a "detrimental impact." "It appears elementary that courts may not frustrate the creation of a statutory duty by refusing to enforce it through the normal judicial means. What public policy reasons there are against enforcement of a statutory duty are reasons against the creation of the duty ab initio, and should be addressed to the Legislature." (Woodside, supra, 7 Cal.4th at p. 540, 28 Cal.Rptr.2d 617, 869 P.2d 1142.) Indeed, as both parties note, the Legislature has on occasion enacted statutes forgiving counties' misallocations in exchange for prospective compliance. (E.g., Rev. & Tax.Code, §§ 96.18, 96.19, 96.27.) Defendants may similarly seek the Legislature's intervention here; courts, however, cannot refuse to enforce the statutory duty simply because of an alleged hardship it would pose to a county.
Additionally, several provisions of the Revenue and Taxation Code appear to limit any hardship. Revenue and Taxation Code section 96.1, subdivision (c)(3), curtails the amount County would have to pay in a single year by providing that if "it is determined that ... a reallocation is required for previous fiscal years, the cumulative reallocation or adjustment may not exceed 1 percent of the total amount levied at a 1 percent rate of the current year's original secured tax roll. The reallocation *622 shall be completed in equal increments within the following three fiscal years. . . ."[10] Revenue and Taxation Code section 4831, subdivision (a), contains a four-year statute of limitations for the correction of the rolls. Defendants also have available to them any appropriate defenses such as laches and unclean hands. (8 Witkin, Cal. Procedure, supra, Extraordinary Writs, §§ 148, 153, pp. 943-946, 950-951.)
We also note plaintiffs added as named defendants the taxing entities that received misallocated revenue and which continue to be parties in this action. Should plaintiffs succeed, County's obligation may be offset by voluntary repayment by the taxing entities or by direct recourse against them by plaintiffs or by County itself.[11] Alternatively, as suggested during oral argument, County may correct the tax rolls that resulted in overpayments to the entities and explore offsetting future payments to recover any amounts now owed to plaintiffs. (See Rev. & Tax. Code, § 4831; Health & Saf.Code, § 33677.) Whatever County does, it is clear that what it may not do is refuse to comply with its statutory duty to correctly allocate and distribute revenue owed to plaintiffs.
Accordingly, we conclude mandamus may issue to compel a county to comply with its duty to calculate and distribute tax revenue. In light of our holding, we need not resolve whether plaintiffs could have maintained claims for quasi-contract or constructive trust had mandamus not been available.

C. Plaintiffs May Amend Their Complaint to Seek Writ of Mandate
In assessing whether plaintiffs should be allowed leave to amend, we determine de novo whether the complaint states facts sufficient to state a cause of action under any possible legal theory. (Leonte v. ACS State & Local Solutions, Inc. (2004) 123 Cal.App.4th 521, 525, 19 Cal.Rptr.3d 879.) We are not limited to plaintiffs' theory of recovery or "form of action" pled in testing the sufficiency of the complaint. (Barquis v. Merchants Collection Assn. (1972) 7 Cal.3d 94, 103, 101 Cal.Rptr. 745, 496 P.2d 817.) It is clear that plaintiffs' complaint states facts sufficient to state a claim for a writ of mandate.
It is true that plaintiffs sought mandamus in their first amended complaint, but failed to seek it in their second amended complaint after the trial court granted defendants' demurrer. In general, plaintiffs who amend a complaint rather than appeal the trial court's order waive the right to appeal any error in sustaining the first demurrer. (Aubry, supra, 2 Cal.4th at p. 966, fn. 2, 9 Cal.Rptr.2d 92, 831 P.2d 317.) However, that rule does not apply if the trial court denied plaintiffs leave to include those causes of action in an amended complaint. (Committee on Children's Television, Inc. v. General Foods Corp. (1983) 35 Cal.3d 197, 209, 197 Cal.Rptr. 783, 673 P.2d 660 (Children's Television).) We conclude this exception applies here.
When the trial court sustained defendants' demurrer to the first amended complaint (including the request for mandamus) and granted plaintiffs leave to add "new theories for recovery," it made clear that it believed plaintiffs could not "state a *623 cause of action for mandate." Considering plaintiffs' pleadings, the discussion at the hearing, and the trial court's order, it is clear that the trial court granted plaintiffs leave to add contractual and equitable claims, not to reassert mandamus. Accordingly, we conclude that plaintiffs' failure to seek writ relief in the second amended complaint or to appeal the trial court's dismissal of the first amended petition does not now preclude them from amending the complaint to seek mandamus. (Children's Television, supra, 35 Cal.3d at p. 209, 197 Cal.Rptr. 783, 673 P.2d 660.)

III. Disposition
The judgment of the Court of Appeal is affirmed.
GEORGE, C.J., KENNARD, BAXTER, WERDEGAR, CHIN, CORRIGAN, JJ., concur.
NOTES
[1]  All further unlabeled statutory references are to the Government Code.
[2]  The statutory scheme has also been referred to as the Government Claims Act. (See e.g., Baines Pickwick v. City of Los Angeles (1999) 72 Cal.App.4th 298, 309-310, 85 Cal.Rptr.2d 74; Trend Homes, Inc. v. Central Unified School Dist. (1990) 220 Cal.App.3d 102, 113, 269 Cal.Rptr. 349.)
[3]  The factual and procedural history is largely taken from the Court of Appeal's opinion.
[4]  Those entities are: Dinuba Unified School District, State Center Community College District, Tulare County Office of Education, Tulare County Air Pollution Control District, Tulare County Library Fund, Alta Healthcare District, Tulare County Flood Control District, Alta Cemetery District, and Dinuba Memorial District.
[5]  Dismissal was not entered as to the nine taxing entities, which were substituted in the place of Doe defendants.
[6]  The intended citation is to section 860.2, not section 820.6.
[7]  The CRL was first adopted in 1951. After voter approval, it was made a part of the California Constitution in 1952 as section 19 of article XIII, since renumbered as article XVI, section 16. (Bell Community Redevelopment Agency v. Woosley (1985) 169 Cal.App.3d 24, 27, fn. 1, 214 Cal.Rptr. 788.)
[8]  The routine reference to "damages" in plaintiffs' pleadings does not control whether the action seeks money damages or simply the release of funds as required by statute. (See County of Sacramento v. Lackner (1979) 97 Cal.App.3d 576, 588, 159 Cal.Rptr. 1 (Lackner).)
[9]  Mandamus has frequently been issued to compel assessors and other taxing officials to perform duties required by tax laws. (8 Witkin, Cal. Procedure (4th ed. 1997) Extraordinary Writs, § 85, p. 873, and cases cited therein.) Indeed, writs have issued specifically in the context of redevelopment agencies seeking to compel taxing officials to perform their statutory functions. (E.g., Redevelopment Agency v. County of San Bernardino, supra, 21 Cal.3d 255, 145 Cal.Rptr. 886, 578 P.2d 133 [agency sought to compel county to recalculate tax allocation].)
[10]  This provision also seems to belie defendants' contention that the Legislature intended to shield counties from having to repay previously misallocated revenue.
[11]  Indeed, plaintiffs indicated at oral argument that several taxing entities have entered into settlement agreements.
