Cal. Civ. Code § 1717
(a) In any action on a contract, where the contract specifically provides that attorney’s fees and costs, which are incurred to enforce that contract, shall be awarded either to one of the parties or to the prevailing party, then the party who is determined to be the party prevailing on the contract, whether he or she is the party specified in the contract or not, shall be entitled to reasonable attorney’s fees in addition to other costs.
Where a contract provides for attorney’s fees, as set forth above, that provision shall be construed as applying to the entire contract, unless each party was represented by counsel in the negotiation and execution of the contract, and the fact of that representation is specified in the contract.
Reasonable attorney’s fees shall be fixed by the court, and shall be an element of the costs of suit.
Attorney’s fees provided for by this section shall not be subject to waiver by the parties to any contract which is entered into after the effective date of this section. Any provision in any such contract which provides for a waiver of attorney’s fees is void.
(b)
(2) 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.
Where the defendant alleges in his or her answer that he or she tendered to the plaintiff the full amount to which he or she was entitled, and thereupon deposits in court for the plaintiff, the amount so tendered, and the allegation is found to be true, then the defendant is deemed to be a party prevailing on the contract within the meaning of this section.
Where a deposit has been made pursuant to this section, the court shall, on the application of any party to the action, order the deposit to be invested in an insured, interest-bearing account. Interest on the amount shall be allocated to the parties in the same proportion as the original funds are allocated.