
56 Cal.Rptr.3d 780 (2001)
149 Cal.App.4th 170
Richard Sang KIM, Plaintiff and Appellant,
v.
EUROMOTORS WEST/THE AUTO GALLERY et al., Defendants and Respondents.
No. B189277.
Court of Appeal of California, Second District, Division Eight.
April 2, 2007.
*781 Consumer Legal Services, N. Nicholas Nita and David N. Barry, for Plaintiff and Appellant Richard Sang Kim.
Whitwell Jacoby Emhoff, Aaron H. Jacoby, Peter S. Kravitz, and Melanie S. Joo, Los Angeles, for Defendant and Respondent Euromotors West/The Auto Gallery.
RUBIN, J.
This appeal arises out of an action brought by plaintiff and appellant Richard Sang Kim against defendant and respondent Euromotors West/The Auto Gallery (TAG) for, among other things, violation of the Consumer Legal Remedies Act (CLRA). Kim appeals from the January 10, 2006, order denying his motion for attorneys' fees following entry of a stipulated judgment pursuant to a settlement agreement. Kim contends the trial court erred in finding that, because the matter was resolved by settlement agreement prior to trial, there could be no prevailing *782 party. We reverse and remand with instructions.

FACTUAL AND PROCEDURAL BACKGROUND
The complaint alleges that, on September 8, 2003, Kim traded in his 2001 Porsche Boxster to lease a used 2001 Porsche 996 Turbo (the vehicle) from TAG. According to the lease agreement, the "gross capitalized cost" of the vehicle at lease signing was $88,366.51 and the total amount Kim would have to pay on the lease by the end of the 48 month lease term would be $66,844.[1] In addition, the estimated amount Kim would have to pay for official fees and taxes was $4,533.38. Along with the lease, Kim received a written warranty. Over the next year, Kim brought the vehicle back to TAG for various repairs as a result of which the vehicle was out of service for over 78 days.
In separate letters on September 21, 2004, Kim's attorney notified Porsche and TAG that Kim was revoking his acceptance of the vehicle under Commercial Code section 2608 [revocation of nonconforming goods] and demanding a refund pursuant to the CLRA (Civ.Code, §§ 1750 et seq.).[2] Specifically, the letter to TAG stated: "[P]ursuant to [the CLRA] [Kim] demands that, in order to put the client in the same position he was in prior to the formation of the contract, you correct, repair, replace or otherwise rectify said violations of [the CLRA] by canceling the sale of the subject vehicle, by accepting the return of the subject vehicle, and by refunding all monies expended." Porsche and TAG refused Kim's demands.
On November 2, 2004, Kim filed this action against Porsche and TAG.[3] The complaint stated causes of action for breach of written contract; revocation; rescission; breach of express warranty; breach of implied warranty of merchantability; violations of the Song-Beverly Consumer Warranty Act (Song-Beverly Act) (§§ 1790 et seq.); violations of the Magnuson-Moss Warranty Act (15 U.S.C. §§ 2301 et seq.); as well as violations of the CLRA. By the complaint, Kim sought the following relief: actual, incidental and consequential damages; a civil penalty pursuant to the Song-Beverly Act; an order enjoining the defendants' unlawful methods, acts, and/or practices; return of Kim's down payment and all payments made by Kim under the lease; an order of restitution; on order of rescission of the lease agreement including refund of all monies paid by Kim and termination of the lease, requiring defendants to pay off the balance of the lease and ordering Kim to return the vehicle; cost of suit and expenses; pre-judgment interest; attorney's fees; and exemplary damages.
In September 2005 the parties reached a partial settlement: Kim dismissed with prejudice the First through Fifth Causes of Action, and Eighth and Ninth Causes of Action in their entirety, and the Tenth Cause of Action against Porsche, only. In exchange, Porsche and TAG both agreed to waive "any and all attorney's and costs associated with the dismissed causes of action." Thus, following the dismissal, the Sixth and Seventh Causes of Action for violation of the Song-Beverly Act alleged against Porsche and TAG, and the Tenth *783 Cause of Action for violation of the CLRA as to TAG only, remained outstanding.
Kim settled with TAG a few months later. According to the Mutual General Release and Settlement Agreement entered into by Kim and TAG (the settlement agreement), the consideration for settlement was the following: (1) Kim agreed to turn over the vehicle to TAG, and to execute all documents necessary to transfer his interest in the vehicle to TAG; (2) TAG agreed to pay Kim an amount equivalent to the remaining lease obligation ($69,818.78) and to take steps necessary to terminate the lease agreement; and (3) TAG agreed to pay Kim "the lump sum settlement amount of $10,000." Regarding attorney's fees, paragraph 2 of the settlement agreement, entitled "Consideration," states that the $10,000 payment to Kim was "made in full and final settlement and satisfaction of any and all claims Kim has or may have against TAG, excluding attorney's fees and costs (the attorney's fees and costs are discussed below)." (Italics added.) Paragraph 3 of the settlement agreement, entitled "No Admissions," states that neither party was admitting liability and "neither party agrees that the other is the prevailing party. A determination of which, if any, party is the prevailing party will be made by the court as part of [Kim's] motion for attorney's fees and costs...." Paragraph 19 of the settlement agreement, entitled "Kim's Attorney's Fees and Costs," states: "Kim hereby reserves his right to make an application to the Court in an attempt to recover his reasonable attorneys' fees and costs with respect to TAG in connection with his CRLA claim. TAG reserves the right to oppose the motion on grounds it deems appropriate." Finally, paragraph 22 of the settlement agreement, entitled "Enforcement of Agreement," provides that "[t]he Parties agree that, pursuant to California Code of Civil Procedure section 664.6, the Court may retain jurisdiction over the Parties to enforce the settlement until performance in full of the terms of this Agreement."
On November 23, 2005, Kim filed a motion for attorney's fees and costs under section 1780, subdivision (d) (§ 1780(d)) of the CLRA. TAG opposed the motion on the grounds that Kim was not the prevailing party, that Kim was improperly seeking attorney's fees attributable to the litigation against Porsche and that the amount of fees being sought was unreasonable.
On January 10, 2006, the parties appeared for an OSC re Dismissal and hearing on Kim's attorney's fee motion. (Exhibit A to Appellant's Opening Brief and Respondent's Brief.) At the hearing, the trial court asked the following rhetorical question: "How is it that this court is expected to determine who the prevailing party is when there is a settlement? That is what I don't understand." The court concluded that the fact the matter was settled pursuant to an agreement made it impossible to determine whether there was a prevailing party and, based on this reasoning, denied the motion. At this hearing, the trial court also dismissed the action. (Exhibit A.)
Kim filed a timely notice of appeal.

DISCUSSION
Kim contends the trial court erred in denying his motion for attorney's fees on the grounds that there was no prevailing party. As we understand his argument, it is that the trial court's determination that there was no prevailing party was based entirely on an incorrect belief that there could be none because the matter was settled by agreement of the parties *784 prior to trial.[4] We agree with Kim.

1. Standard of Review

The parties disagree on the standard of review. Kim maintains the standard is de novo and TAG argues abuse of discretion. Kim is correct.
Generally, the trial court's determination of the prevailing party for purposes of awarding attorney's fees is an exercise of discretion which should not be disturbed on appeal absent a clear showing of abuse of discretion. (Jackson v. Homeowners Association Monte Vista Estates-East (2001) 93 Cal.App.4th 773, 789, 113 Cal.Rptr.2d 363 (Jackson), quoting Reveles v. Toyota by the Bay (1997) 57 Cal. App.4th 1139, 1153, 67 Cal.Rptr.2d 543, (Reveles) disapproved of on another point in Snukal v. Flightways Mfg., Inc. (2000) 23 Cal.4th 754, 775, fn. 6, 98 Cal.Rptr.2d 1, 3 P.3d 286.) But the determination of the legal basis for an attorney's fee award is subject to independent review. (Corbett v. Hayward Dodge, Inc. (2004) 119 Cal. App.4th 915, 921, 14 Cal.Rptr.3d 741 [independent review of interpretation of statute allowing attorney's fees to defendant upon finding that plaintiff prosecuted the action "not in good faith"].) In such a case, the issue involves the application of the law to undisputed facts. (See Damian v. Tamondong (1998) 65 Cal.App.4th 1115, 1119, 77 Cal.Rptr.2d 262 (Damian) [independent review of whether defendant in action brought under Rees-Levering Automobile Sales Finance Act can be "prevailing party" for purposes of attorney's fee award after voluntary dismissal].)
Here, it is undisputed that Kim's complaint alleged, among other things, a cause of action under the CLRA; the action was dismissed prior to trial pursuant to the terms of a written settlement agreement; and in that settlement agreement, Kim expressly reserved the right to make application to the court for recovery of his attorney's fees and costs in connection with his CRLA claim. Thus, the issue here involves applying the relevant law relating to the legal basis of an attorney's fees award to these undisputed facts. Under these circumstances, we independently review the trial court's expressed belief that there was no legal basis to find Kim to be a prevailing plaintiff because the parties entered into a settlement agreement. As we shall explain, that finding was contrary to the law.
We would come to the same conclusion under the more lenient abuse of discretion standard. This is because "`discretion may not be exercised whimsically and, accordingly, reversal is appropriate "where no reasonable basis for the action is shown." [Citation.]' [Citation.]" (Common Cause v. Stirling (1983) 147 Cal. App.3d 518, 522, 195 Cal.Rptr. 163 [trial court abused discretion in denying attorney's fees to plaintiff in action brought under the Brown Act (Gov.Code, § 54950 et seq.)].) A failure to exercise discretion is an abuse of discretion. (People v. Orabuena (2004) 116 Cal.App.4th 84, 99, 10 Cal. Rptr.3d 99.) "`"`Action that transgresses *785 the confines of the applicable legal principals of law is outside the scope of discretion and we call such an action an "abuse" of discretion.'"' [Citation.]" (Graciano v. Robinson Ford Sales, Inc. (2006) 144 Cal.App.4th 140, 148, 50 Cal.Rptr.3d 273 (Graciano).) Here, because it incorrectly believed that there can be no prevailing party when the parties agree to a pre-trial settlement, the trial court failed to exercise its discretion to determine whether or not Kim was a prevailing plaintiff.

2. Civil Code section 1717

Known as the "American rule," each party to a lawsuit must ordinarily pay his or her own attorney fees. (Flannery v. California Highway Patrol (1998) 61 Cal. App.4th 629, 633, 71 Cal.Rptr.2d 632.) The rule is codified at Code of Civil Procedure section 1021, which provides: "Except as attorney's fees are specifically provided for by statute, the measure and mode of compensation of attorneys ... is left to the agreement, express or implied, of the parties...."
The availability of attorney's fees authorized by an agreement between the parties is governed by section 1717 which, in pertinent part, provides: "Where an action has been voluntarily dismissed or dismissed pursuant to a settlement of the case, there shall be no prevailing party for purposes of this section." (§ 1717, subd. (b)(2).) Thus, where attorney's fees are a matter of contract, pre-trial settlement of the action precludes an award of those fees.
But the mere existence of an attorney fee provision in the parties' contract does not necessarily bring the issue of attorney's fees within section 1717, subdivision (b)(2). There are two theoretically applicable exceptions. First, the parties may waive application of section 1717, subdivision (b)(2) and submit the question of attorney's fees to the trial court for resolution. (Jackson, supra, 93 Cal.App.4th at p. 782, 113 Cal.Rptr.2d 363; see also Reveles, supra, 57 Cal.App.4th at p. 1149, 67 Cal.Rptr.2d 543.) In Jackson, the court held that "a settlement agreement which provides that the trial court will determine the prevailing party in the action, and the amount of the attorney fee award, if any, is valid and enforceable." (93 Cal.App.4th at p. 776, 113 Cal.Rptr.2d 363.) However, this exception applies only where the dismissal is not filed before the attorney's fee issue issue is resolved. (See Id. at pp. 784-785, 113 Cal.Rptr.2d 363 [distinguishing Reveles, supra, at p. 1150, 67 Cal. Rptr.2d 543 [attorney's fee issue preserved where no dismissal filed] from Exxess Electronixx v. Heger Realty Corp. (1998) 64 Cal.App.4th 698, 707-708, 75 Cal. Rptr.2d 376 [attorney's fee issue waived where dismissal filed].) Here, because the dismissal was filed before the attorney's fee issue was resolved, the exception does not apply. This does not end our inquiry, however, because of the second exception.
Section 1717, subdivision (b)(2) does not bar a fee award where the prevailing party's right to recover fees arises under a fee-shifting statute. (See e.g. Graham, v. DaimlerChrysler Corp. (2004) 34 Cal.4th 553, 565, 21 Cal.Rptr.3d 331, 101 P.3d 140 (Graham) [American rule not applicable where attorney's fees sought pursuant to § 1021.5]; Parrott v. Mooring Townhomes Ass'n, Inc. (2003) 112 Cal.App.4th 873, 878-879, 6 Cal. Rptr.3d 116 [§ 1717, subd. (b)(2) not applicable where attorney's fees sought pursuant to § 1354, subd. (f)]; Damian, supra, 65 Cal.App.4th at p. 1124, 77 Cal.Rptr.2d 262 [same where attorney's fees sought pursuant to § 2983.4]; Reveles, supra, 57 Cal.App.4th at pp. 1150-1151, 67 Cal. Rptr.2d 543 [same where attorney's fees sought pursuant to § 1021.5]; Elster v. *786 Friedman (1989) 211 Cal.App.3d 1439, 1443-1444, 260 Cal.Rptr. 148 (Ulster) [same where attorney's fees sought pursuant to Code Civ. Proc., § 527.6, subd. (h).) The CLRA includes a fee-shifting statute at section 1780(d).

3. Section 1780(d)

Section 1780(d) provides: "The court shall award court costs and attorney's fees to a prevailing plaintiff in litigation filed pursuant to this section. Reasonable attorney's fees may be awarded to a prevailing defendant upon a finding by the court that the plaintiffs prosecution of the action was not in good faith." (Italics added.)
"The word `shall' is usually deemed mandatory, unless a mandatory construction would not be consistent with the legislative purpose underlying the statute." (West Shield Investigations and Sec. Consultants v. Superior Court (2000) 82 Cal.App.4th 935, 949, 98 Cal.Rptr.2d 612.) Our Supreme Court has observed that "the availability of costs and attorneys fees to prevailing plaintiffs is integral to making the CLRA an effective piece of consumer legislation, increasing the financial feasibility of bringing suits under the statute." (Broughton v. Cigna Healthplans (1999) 21 Cal.4th 1066, 1085, 90 Cal. Rptr.2d 334, 988 P.2d 67.) Thus, a mandatory construction of the word "shall" in section 1780(d) is consistent with the legislative purpose underlying the statute.
Accordingly, an award of attorney's fees to "a prevailing plaintiff in an action brought pursuant to the CLRA is mandatory, even where the litigation is resolved by a pre-trial settlement agreement, absent an enforceable agreement to the contrary. Obviously a plaintiff who is not prevailing is not entitled to attorneys fees. We turn to the phrase "prevailing plaintiff."

4. Definition of "Prevailing Plaintiff"

The CRLA does not define "prevailing plaintiff." In Reveles, supra, 57 Cal. App.4th 1139, 67 Cal.Rptr.2d 543, the court applied the general definition of "prevailing party" found in Code of Civil Procedure section 1032.[5] It concluded that a plaintiff is the prevailing party under section 1780(d) "if he obtained a `net monetary recovery' on his [CLRA] claim." (Id. at p. 1154, 67 Cal.Rptr.2d 543.) More recently, the court in Graciano, supra, 144 Cal.App.4th at page 150, 50 Cal.Rptr.3d 273, held that, in deciding prevailing party status under the CLRA, "the court should adopt a pragmatic approach, determining prevailing party status based on which party succeeded on a practical level. [Citations.] Under that approach, the court exercises its discretion to determine `the prevailing party by analyzing which party realized its litigation objectives.' [Citation.]?'
Other cases which define the term "prevailing party" in the context of different fee-shifting statutes are also instructive. For example, in Elster, supra, 211 Cal. App.3d 1439, 260 Cal.Rptr. 148, the appellate court affirmed an award of attorney's *787 fees to the plaintiff pursuant to Code of Civil Procedure section 527.6, subdivision (h), which gives the trial court discretion to award attorney's fees to the prevailing party in any action for an injunction prohibiting harassment.[6] Noting that the statute did not define "prevailing party," the court in Elster, like the court in Reveles, looked to the definition contained in the more general Code of Civil Procedure section 1032. (Elster, supra, at p. 1443, 260 Cal.Rptr. 148.) Applying that definition, the Elster court concluded that even though the injunction there imposed reciprocal duties on both sides, the plaintiffs legally could be entitled to prevailing party status. "A plaintiff prevails, in essence, when he gets most or all of what he wanted by filing the action." (Id. at pp. 1443-1444, 260 Cal.Rptr. 148.) In Elster, the plaintiffs were the prevailing party because "what they wanted" was to enjoin the defendant from harassing them and that is the relief they obtained.
In Coltrain v. Shewalter (1998) 66 Cal. App.4th 94, 77 Cal.Rptr.2d 600, the court held that the critical issue for the prevailing party under Code of Civil Procedure section 425.16, subdivision (c) [anti-SLAPP statute] "is which party realized its objectives in the litigation." In cases concluding by way of dismissal, that is usually the defendant. "Since the defendant's goal is to make the plaintiff go away with its tail between its legs, ordinarily the prevailing party will be the defendant. The plaintiff, however, may try to show it actually dismissed because it had substantially achieved its goals through a settlement or other means...." (Id. at p. 107, 77 Cal. Rptr.2d 600; see also Graham, supra, 34 Cal.4th at p. 571, 21 Cal.Rptr.3d 331, 101 P.3d 140 [within the context of the private attorney general statute (§ 1021.5), the term "prevailing party" means the party that achieves its objectives].)

5. Application to Present Case

Here, the trial court believed that Kim could not be a prevailing plaintiff solely because the matter was resolved prior to trial by a settlement agreement: "My question is, you settled. How is the court supposed to determine who the prevailing party is? How do I do that?" "What you all are asking the court to do here, and this is what I have a problem with, in asking me to determine the prevailing party, in light of the fact that you have settled, you're asking me to say financially that you ended up in a situation that was better than he did, is basically what it comes down to. [¶] And so you're asking me as a judge to step in as an expert witness and to evaluate the value of the Porsche, the value of what it meant to the defense not to have to try it and what their legal fees would have been had they gone to trial and what the potential downside was and to take into consideration all kinds of things that I, as a court, don't believe that I should do. [¶] ... I have never been asked to determine, after the parties have agreed in a written settlement agreement, who the prevailing party is. [¶] To me that is just like an antithetical request. It's a non sequitur. How can I do that? [¶] The answer is this court does not believe that it can. All right? I cannot make a determination of prevailing party irrespective of the [CLRA]." "I just *788 think that it really strikes against the concept of settling a case and ending it and then coming back and saying, `Now, Judge, tell us who is the winner.' I can't do that. And I am not going to. [¶] I'm trying to give you a really good record so that if you decide to take this up on appeal, that the Court of Appeal is very clear on why I'm doing this. All right? And that is because there is no case that allows this. There is no case that says that this is the way that it is to be handled, [¶] So if they decide they want to carve out a place in the law whereby after a settlement agreement they want to put into effect a mechanism whereby a court can give me guidance on how I can determine a prevailing party, well, then, when it comes right back down, I will just do exactly what they say. But right now I don't think that is what the law is. [¶] And queen's gambit decline, I'm not going to. [¶] So the motion for attorney's fees and costs is denied. [¶] [COUNSEL FOR TAG]: Thank you, Your Honor. [¶] THE COURT: The court finds there is no prevailing party."
Although we appreciate the trial court's dilemma, it still has an obligation to determine whether or not plaintiff is a "prevailing plaintiff under law. A plaintiffs request for attorney's fees under the CLRA is not inherently antithetical to a pre-trial settlement agreement. Because Kim's right to attorney's fees arises not from contract, but under section 1780(d), Kim is not precluded from obtaining an award of attorney's fees even though the litigation was resolved by a settlement agreement. Moreover, the express language of section 1780(d) makes such an award mandatory, not discretionary, if Kim shows that he was the "prevailing plaintiff."
Determinations of whether Kim is a "prevailing plaintiff and the amount to be awarded, if any, are matters to be made, in the first instance, by the trial court in the sound exercise of its discretion. This is because, while TAG obtained a dismissal in the settlement agreement, Kim obtained many of his litigation objectives including return of the car, cancellation of the lease and a monetary recovery. By analogy to Code of Civil Procedure section 1032, this case therefore falls within the category of "situations other than as specified" in which "the `prevailing party' shall be as determined by the court." Accordingly, we remand the matter to the trial court to determine whether Kim is a prevailing plaintiff either because he obtained a net monetary recovery or because he achieved most or all of what he wanted by filing the action or a combination of the two. If the trial court determines that Kim is a prevailing plaintiff, it shall also determine the amount of attorney's fees to be awarded to him. (Glendora Community Redevelopment Agency v. Demeter (1984) 155 Cal. App.3d 465, 474, 202 Cal.Rptr. 389 [the amount to be awarded as attorney's fees is left to the sound discretion of the trial court because it is in the best position to evaluate the services rendered by an attorney in it's courtroom].) We do not intend by this opinion that the trial court must determine that plaintiff is a prevailing plaintiff; only that it must make the decision.

DISPOSITION
The judgment is reversed and remanded for the limited purpose of allowing the trial court to exercise its discretion to determine whether Kim was the prevailing plaintiff within the meaning of section 1780(d), and if so, the amount of attorney's fees he shall recover. Kim shall recover his costs on appeal.
WE CONCUR: COOPER, P.J., and BOLAND, J.
NOTES
[1]  This amount was comprised of: $10,000 due at lease signing; plus a total of $57,969.00 in lease payments; plus a $350 termination fee; minus the $1,202.00 first monthly lease payment (which was included as part of the initial $10,000 payment).
[2]  All further undesignated section references are to the Civil Code.
[3]  Porsche is not a party to this appeal.
[4]  TAG argues that Kim waived his right to appeal because the settlement agreement required Kim to file a request for dismissal with prejudice within seven calendar days of the ruling on Kim's attorney's fee motion. The contention is not well taken. The right of appeal should not be considered waived or abandoned except where the record clearly establishes it. (People v. Vargas (1993) 13 Cal.App.4th 1653, 1661-1662, 17 Cal.Rptr.2d 445.) Here, the record does not demonstrate any knowing waiver of the right to appeal. The only reasonable interpretation of the attorney's fees provision in the settlement agreement is that Kim reserved the right to apply to the trial court for attorney's fees and to appeal an unfavorable ruling.
[5]  For purposes of an award of costs pursuant to Code of Civil Procedure, section 1021, section 1032, subdivision (a)(4) defines "prevailing party" as "the party with a net monetary recovery, a defendant in whose favor a dismissal is entered, a defendant where neither plaintiff nor defendant obtains any relief, and a defendant as against those plaintiffs who do not recover any relief against that defendant. When any party recovers other than monetary relief and in situations other than as specified, the `prevailing party' shall be as determined by the court, and under those circumstances, the court, in its discretion, may allow costs or not and, if allowed may apportion costs between the parties on the same or adverse sides pursuant to rules adopted under Section 1034."
[6]  In Elster, the plaintiffs brought an action seeking to enjoin their downstairs neighbors from further harassing them. The trial court brokered a stipulated judgment in which both sides agreed to refrain from harassing or annoying the other. a few months later, the plaintiffs filed a memorandum of costs including attorney fees, which the trial court awarded over the defendant's objection that they, too, were prevailing parties. The appellate court affirmed.
