
682 P.2d 640 (1984)
106 Idaho 687
William P. CHENERY, Plaintiff-Respondent Cross Appellant,
v.
AGRI-LINES CORPORATION, a Nevada Corporation, Defendant-Appellant Cross Respondent, and
David C. SPENCER and Lois N. SPENCER, husband and wife, Plaintiffs-Respondents, Cross Appellants.
v.
AGRI-LINES CORPORATION, a corporation, Def-App, Cross Resp.
No. 13763.
Court of Appeals of Idaho.
May 15, 1984.
Petition for Review Denied August 8, 1984.
*641 Max A. Eiden, Jr. of Clemons, Cosho & Humphrey, Boise, for defendant-appellant.
Jay R. Friedly of Hall & Friedly, Mountain Home, Daniel T. Eismann, Homedale, for plaintiffs-respondents.
SWANSTROM, Judge.
Farm owner William Chenery and his tenants, David and Lois Spencer, sued a farm equipment company, Agri-Lines Corporation, for crop losses and other damages. Just before the scheduled trial, offers of judgment were made by Agri-Lines. Both plaintiffs accepted the offers and judgments were entered accordingly. Later the district court awarded attorney fees to both plaintiffs as prevailing parties under I.C. § 12-120(2). Agri-Lines has appealed those awards. Both Chenery and the Spencers have cross-appealed, contending a greater fee award should have been made.
Because this case never went to trial, no findings of fact and conclusions of law were entered by the district court. However, the following facts can be gleaned from the record. In the summer of 1975, Chenery employed Agri-Lines to repair a turbine pump in a deep well on the farm Chenery leased to the Spencers. The Spencers had experienced a loss of water pressure from the well and concluded that the pump "bowls" were bad and needed replacement. The bowls were suspended deep within the well at the end of a long drive shaft and pipe column. To replace the bowls, it was necessary to disassemble the pump apparatus and motor and remove over 460 feet of shaft and pipe column from the well. To accomplish this, the column had to be lifted from the well with a winch and disassembled section by section.
On July 30, 1975, Agri-Lines sent a crew of three men to the farm to perform this task. Since the column and the pump apparatus weighed over seventeen tons, the well was equipped with a one and one-quarter inch steel lifting plate located beneath the discharge head of the pump. Proper procedure to follow in pulling the assembly from the well apparently would have been to attach the winch cables to the lifting plate. Instead the Agri-Lines crew attached the cables to "lifting ears" which were cast into the iron pump head. When the assembly had been lifted about three feet, one of these ears broke off and the entire column of pipe, together with the bowl assembly, fell to the bottom of the 700-foot well. A well driller then had to be hired to fish the column of pipe out of the well. By November 1975, he had retrieved the pipe and shaft, but the bowls were left in the bottom of the well. The well was *642 useless for the remainder of the 1975 irrigation season. The Spencers and Chenery both claimed that the loss of water from the well due to the accident contributed to severe crop losses in 1975.
In the spring of 1976, Agri-Lines repaired and reinstalled the pump in the Spencers' well, but the pump failed to operate. Agri-Lines attempted further repairs but was unable to get the well operating. Agri-Lines then discontinued its efforts and the job was finished by another company.
In 1977, the Spencers and Chenery filed complaints against Agri-Lines. Both complaints charged that Agri-Lines, in attempting to make the necessary repairs to the pump bowls, negligently allowed the column of pipe and pump apparatus to drop to the bottom of the well. The complaints also asserted that Agri-Lines had expressly and impliedly warranted that it was skilled in repairing pumps and that it breached this warranty in failing to use proper equipment and to employ skilled workmen. Both complaints sought damages for crop losses in 1975 and 1976. Agri-Lines filed a counterclaim seeking compensation for the reasonable value of services furnished to the plaintiffs in repairing the pump.
These two cases were consolidated for trial which was scheduled to start on January 2, 1980. In December 1979, however, Agri-Lines made separate offers of judgment to the plaintiffs. These offers were accepted. Pursuant to the offers, the court then entered judgment for the Spencers for $110,000 and for Chenery for $67,000, exclusive of costs and attorney fees. As part of the agreed settlement Agri-Lines dismissed its counterclaim. The plaintiffs filed memoranda of costs seeking substantial attorney fees. After hearing oral argument, the court entered an order on May 12, 1980 awarding the Spencers attorney fees of $27,500 and Chenery attorney fees of $22,333. The court made this award under I.C. § 12-120(2). The court declined to base its award of attorney fees upon I.C. § 12-121 because it found that Agri-Lines had not defended the action frivolously, unreasonably or without foundation. Both Agri-Lines' appeal and Chenery's and the Spencers' cross-appeals are taken from the order dated May 12, 1980.
Several issues need to be resolved in this appeal: (1) Were the claims made by the Spencers and Chenery, as prevailing parties in the main action, within the subject matter scope of I.C. § 12-120(2)? (2) If not, did the district court err in failing to award attorney fees to the Spencers and Chenery under I.C. § 12-121? In addition, Chenery raises a further issue in his appeal: (3) Was he entitled to attorney fees under I.C. § 12-120(2) as the prevailing party in regard to Agri-Lines' counterclaim?
The central issue in this case is whether the Spencers and Chenery were entitled to recover attorney fees under I.C. § 12-120(2). That statute provides:

In any civil action to recover on an open account, account stated, note, bill, negotiable instrument, or contract relating to the purchase or sale of goods, wares or merchandise, unless otherwise provided by law, the prevailing party shall be allowed a reasonable attorney fee to be set by the court, to be taxed and collected as costs. [Emphasis added.]
The district court awarded fees under this statute after concluding "that essentially the suits by both Plaintiffs here were to recover for the breach of a contract relating to the purchase, sale and installation of new pump bowls." The Spencers and Chenery contend this was proper because their transaction with Agri-Lines was primarily a contract for the purchase or sale of goods, viz., new pump bowls, and only secondarily a contract for services. To support this contention they emphasize that the cost of the new bowls was several times greater than the estimated cost of installation. Agri-Lines, on the other hand, contends that the Spencers' and Chenery's suits were not actions to recover "on a contract," but were tort actions based upon the claim that Agri-Lines was negligent in repairing the pump and in installing the *643 pump bowls. We believe that Agri-Lines' position is correct.
For attorney fees to be recoverable under I.C. § 12-120(2) the action must be one "to recover on ... [a] contract relating to the purchase or sale of goods, wares or merchandise." It is not enough that the transaction between the parties relate to the purchase or sale of goods. The action itself must be one "to recover ... on [the] contract."
Our Supreme Court has recognized this distinction in the case of Idah-Best, Inc. v. First Security Bank of Idaho, 99 Idaho 517, 584 P.2d 1242 (1978). In that case Idah-Best was the payee of a $33,000 check drawn on the Hailey branch of First Security. Idah-Best deposited the check in its bank in Twin Falls, and the check was processed through the normal banking channels for collection. After the check was dishonored by First Security due to insufficient funds, Idah-Best filed suit against the Hailey branch of First Security claiming that the bank was liable for the amount of the check under I.C. § 28-4-302.[1] The Supreme Court reversed a judgment for Idah-Best, and thus it was not necessary to decide Idah-Best's claim for attorney fees under I.C. § 12-120(2). To provide guidance for district courts in future cases, the court, by way of dictum, nevertheless commented on that section. The court noted that a suit of the type brought by Idah-Best "is not an action to recover on the instrument itself but is a suit for the wrongful manner in which the instrument was handled by the payor bank." Id. at 528, 584 P.2d at 1253. The court thus concluded that the action was not an action "`on a negotiable instrument' within the meaning of I.C. § 12-120(2)... . Accordingly, I.C. § 12-120 cannot form the basis of an award of attorney fees to the prevailing party in this case." Id.
While the facts in Idah-Best are different from those in the instant case, the interpretation of I.C. § 12-120(2) embraced by the Supreme Court in that case is applicable here. Attorney fees can be awarded under I.C. § 12-120(2) only when the action is one to "recover ... on [a] contract relating to the purchase or sale of goods, wares or merchandise." In Idah-Best the Supreme Court noted that attorney fees could not be recovered even though the action involved a negotiable instrument. In the case at bar, even though the contract between Agri-Lines and the Spencers and Chenery related to the purchase and sale of goods, the actions brought by the Spencers and Chenery were not to recover upon that contract, but to recover damages for breach of another legal duty  the duty to exercise reasonable care.
The test for determining whether the claim sounds in tort or contract was articulated by the Supreme Court of the State of Washington in Yeager v. Dunnavan, 26 Wash.2d 559, 174 P.2d 755, 757 (1946) as follows:
"`Whether an action is in contract or in tort should be determined in the first place from the pleadings, and by an examination and consideration of the essential allegations of the complaint rather than the form adopted by the pleader, what the pleader calls it, the understanding of counsel or of the trial court, and the question must be determined by reference to the complaint as a whole, and not by particular words or allegations considered apart from the context. 1 C.J.S. 1100, Actions, § 46. We think a good test to be used in determining whether a pleading sets up a case in contract or in tort may be stated as follows. When an act complained of is a breach of specific terms of the contract, without any reference to the legal duties imposed by law upon the relationship created thereby, the action is in contract, *644 but where there is a contract for services which places the parties in such a relation to each other that, in attempting to perform the promised service, a duty imposed by law as a result of the contractual relationship between the parties is violated through an act which incidentally prevents the performance of the contract, then the gravamen of the action is a breach of the legal duty, and not of the contract itself, and in such case allegations of the latter are considered mere inducement, showing the relationship which furnishes the right of action for the tort, but not the basis of recovery for it, and in such cases the remedy is an action ex delicto.'" Compton v. Evans, 200 Wash. 125, 93 P.2d 341, 344 [1939]. [Emphasis original.]
Similar statements of the test have been announced in Idaho in Taylor v. Herbold, 94 Idaho 133, 483 P.2d 664 (1971) and in Galbraith v. Vangas, Inc., 103 Idaho 912, 655 P.2d 119 (Ct.App. 1982). See also DCR Inc. v. Peak Alarm Co., 663 P.2d 433 (Utah 1983); Tate v. Mountain States Tel. & Tel. Co., 647 P.2d 58 (Wyo. 1982).
In the present case the Spencers' amended complaint alleged that
Agri-Lines was employed to make repairs to the pumping equipment ... [and that in] performing said work said defendant negligently, recklessly and carelessly allowed the pump, driving column and bowls to drop, thereby damaging the pumping equipment to such an extent that it was unusable for the balance of the 1975 cropping season.
Spencers further alleged that as "a result of the negligence of the defendant" they suffered damages because of crop losses in 1975. A second count in the complaint alleged that Agri-Lines performed the work of making "repairs to the pump, motor and shaft ... in ... an unskillful and unworkmanlike manner." A similar allegation was made in respect to further repairs Agri-Lines was employed to make in 1976 after dropping the pump.
The amended complaint of Chenery also characterized the 1975 contract with Agri-Lines as one "to pull, inspect and make any needed repairs to the pump." Chenery alleged that in performing the work, Agri-Lines breached warranties it had made to do the work with proper equipment and with skilled workmen. It was also alleged that Agri-Lines "negligently dropped the pump." Thus, none of the plaintiffs in this case characterized their cause of action as one to "recover on [a] breach of contract relating to the purchase or sale of goods, wares or merchandise." We hold that the action brought by the Spencers and Chenery was essentially a tort action, not an action to recover on a contract for the purchase or sale of goods. Therefore, the district court erred in awarding attorney fees under I.C. § 12-120(2).
Next we consider whether the district court properly denied the Spencers' and Chenery's request for attorney fees under I.C. § 12-121. This statute allows a court to award attorney fees to any prevailing party in a civil action. However, our Supreme Court has qualified this discretionary authority by adopting I.R.C.P. 54(e)(1) which provides that courts may only award attorney fees under § 12-121 where the action has been "brought, pursued or defended frivolously, unreasonably or without foundation." In Barnes v. Hinton, 103 Idaho 619, 651 P.2d 553 (Ct.App. 1982), we held that I.R.C.P. 54(e)(1) does not apply to actions filed before the effective date of the rule, March 1, 1979. However, we also held that as a guide to the exercise of their discretion, courts are free to apply rule 54(e)(1) to actions filed before the effective date. The actions here were filed before March 1, 1979, and thus the court was not bound to apply rule 54(e)(1). The record discloses, however, that the district judge decided to apply the rule "within the discretionary power of the Court." This was a proper exercise of the district court's discretion.
The district court determined that Agri-Lines did not defend the actions brought by the Spencers and Chenery frivolously, unreasonably *645 or without foundation. The court thus declined to base any fee award upon I.C. § 12-121. We have reviewed the record and conclude that the district court did not abuse its discretion in making this determination. Therefore, the district court's denial of attorney fees under § 12-121 must be upheld.
Finally, in his cross-appeal Chenery contends that the district court should have awarded him additional attorney fees under I.C. § 12-120(2) for successfully defending against Agri-Lines' counterclaim. The counterclaim was asserted against both Chenery and the Spencers for the value of parts, labor and services used in the repairs made to the pump and well by Agri-Lines in 1975 and again in 1976. As part of its offer of settlement Agri-Lines agreed to dismiss its counterclaim. Since we have held that § 12-120(2) does not permit an award of attorney fees upon the plaintiffs' claims against Agri-Lines, we no longer need decide whether Chenery is entitled to "additional" attorney fees. However, the question remains whether Chenery is nevertheless entitled to some award of attorney fees under this section because he "prevailed" below against Agri-Lines' counterclaim.
As noted previously, Agri-Lines made efforts to repair the well after the accident with the pump. Exactly what was done is not shown, but the record does indicate Chenery paid $10,584 to Agri-Lines on December 16, 1975 for that work. After a well driller was hired to fish the remainder of the broken equipment from the well, Agri-Lines, in 1976, completed repairs which it asserts were to the "shaft, column and various parts which were fished out of the well," including "labor, equipment, time and materials." Agri-Lines reinstalled the pump, with new bowls, in the well. For this work Agri-Lines sought the additional amount of $13,167 from Chenery and the Spencers. The counterclaim in Chenery's suit also alleged that Chenery had been unjustly enriched in the sum of $13,167.32 as a result of Agri-Lines' services. In reply, plaintiffs asserted that Agri-Lines did not perform this work properly and that it had to be redone by other contractors at additional expense. We can agree, in this instance, that Agri-Lines' counterclaim was brought to recover on a "contract relating to the purchase or sale of goods, wares or merchandise."
The first question to be decided is whether Chenery is a prevailing party on the counterclaim. Normally this is a factual question to be determined by the trial court. I.R.C.P. 54(d)(1)(B); Chadderdon v. King, 104 Idaho 406, 659 P.2d 160 (Ct.App. 1983). No such specific finding was made by the court below, although it found that both plaintiffs were prevailing parties in the action overall.
Mere dismissal of a claim without a trial does not necessarily mean that the party against whom the claim was made is a prevailing party for the purpose of awarding costs and fees. Dismissal of a claim may be but one of many factors to consider. When the claim was dismissed may be another. Here, Agri-Lines dismissed its counterclaim against Chenery as part of an overall settlement on the eve of trial. The judgment entered against Agri-Lines in favor of Chenery recited that Agri-Lines would take nothing on its counterclaim. On the other hand, the Spencers' brief acknowledges that the counterclaim asserted against the Spencers was voluntarily dropped by Agri-Lines early in the lawsuit. If the Spencers were also asserting a claim for attorney fees because of having to defend against the counterclaim, its early dismissal would be a factor to consider in determining whether the Spencers were prevailing parties.
We recognize that under some circumstances an appellate court may properly say, as a matter of law, that a party is a prevailing party as to a particular claim. We cannot make such a ruling in this instance. Accordingly, we will remand to the trial court to determine, in its discretion, whether Chenery was a prevailing party on the counterclaim.
*646 Where, as here, there are claims, counterclaims and cross-claims, the mere fact that a party is successful in asserting or defeating a single claim does not mandate an award of fees to the prevailing party on that claim. The rule does not require that. It mandates an award of fees only to the party or parties who prevail "in the action." Rule 54(d)(1)(B) I.R.C.P. says:
In determining which party to an action is a prevailing party and entitled to costs, the trial court shall in its sound discretion consider the final judgment or result of the action in relation to the relief sought by the respective parties, whether there were multiple claims, multiple issues, counterclaims, third party claims, cross-claims, or other multiple or cross issues between the parties, and the extent to which each party prevailed upon each of such issue or claims. The trial court in its sound discretion may determine that a party to an action prevailed in part and did not prevail in part, and upon so finding may apportion the costs between and among the parties in a fair and equitable manner after considering all of the issues and claims involved in the action and the resultant judgment or judgments obtained.
Thus, while the judge in his sound discretion must consider "the final judgment or result of the action in relation to the relief sought by the respective parties ... and the extent to which each party prevailed upon each of such issue or claims," he is not compelled to make a discrete award of fees on each claim.
In summary, the district court's order awarding attorney fees under I.C. § 12-120(2) to the respondents as the prevailing parties on their claims is reversed. The decision of the district court not to award attorney fees to the respondents under I.C. § 12-121 is affirmed. The cause is remanded for the district court to determine whether Chenery prevailed on the counterclaim and for the court to determine, in its discretion, whether Chenery should be awarded fees under § 12-120(2) for successfully defending against the counterclaim. No costs or fees awarded on this appeal.
WALTERS, C.J., and BURNETT, J., concur.
NOTES
[1]  That section provides in part:

[I]f an item is presented on and received by a payor bank, the bank is accountable for the amount of ... a demand item ... if the bank ... retains the item beyond midnight of the banking day of receipt without settling for it or, ... does not pay or return the item or send notice of dishonor until after its midnight deadline.
