
    659 P.2d 160
    Keith R. CHADDERDON and Marjorie Chadderdon, husband and wife, Plaintiffs-Appellants, v. Matthew T. KING and Janet F. King, husband and wife, Defendants-Respondents.
    No. 14060.
    Court of Appeals of Idaho.
    Feb. 22, 1983.
    Rehearing Denied Feb. 22, 1983.
    Petition for Review Denied April 27, 1983.
    
      David A. Frazier, Coeur d’Alene, for plaintiffs-appellants.
    Scott W. Reed, Coeur d’Alene, for defendants-respondents.
   WALTERS, Chief Judge.

This dispute arose following the completion of a commercial building that the contractor, King, had agreed to construct for the Chadderdons, the owners. The owners sued the contractor for alleged breach of the construction agreement, and the contractor counterclaimed to recover amounts expended over and above the price. expressed in the construction agreement. A jury denied recovery to both parties, and judgment was entered accordingly.

Thereafter, the contractor applied for an award of attorney fees and costs. The owners filed an objection to such allowance, and also moved for a new trial. The trial court denied the motion for new trial, overruled the objection to costs and fees, and entered an order making an award to the contractor.

The owners appeal from the order denying the motion for new trial and from the order awarding costs and fees. They raise two issues: (1) Did the trial court abuse its discretion by permitting the contractor’s counterclaim to be considered by the jury, thereby committing reversible error which would entitle the owners to a new trial? (2) Was it error for the trial court to award attorney fees to the contractor as a “prevailing party” in the suit? We answer the owners’ questions in the negative. We uphold the orders denying a new trial and awarding costs and attorney fees at trial. The contractor has not cross-appealed but does request an award of attorney fees for responding to this appeal. We grant this request.

In 1975, the parties signed a contract to construct the building. After the construction was completed in 1976, a dispute arose between the parties due to claims of unsatisfactory workmanship, and alleged defects in the building. The owners filed suit for breach of the contract in January, 1977.

Having received no responsive pleading to their complaint within the period allowed by the Idaho Rules of Civil Procedure, see I.R.C.P. 12(a), the owners moved for default judgment in April, 1978. Within two days thereafter, the contractor filed an answer denying the claim. •

In November, 1978, without first obtaining leave of the court, the contractor filed the counterclaim concerned in this appeal. He alleged in the counterclaim that he had been required, at the request and instance of the owners, to incur expenditures for extra labor and material during construction of the building. The contractor sought to recover the costs of the additional work and materials. An exhibit attached to the counterclaim specifically listed the items of additional work and materials and the cost of each item.

The owners did not reply, at that time, to the counterclaim; nor did they then object to the filing of the counterclaim. However, twenty-two months later, after the jury had been selected for trial but before any evidence was presented, the owners moved to strike the counterclaim. They argued that the counterclaim was a nullity because it had been filed without first obtaining leave of the court, and the owners had consciously chosen to disregard it at the time. The motion was denied by the court. After the court’s ruling, the owners orally denied the allegations of the counterclaim, and, later that day, filed a written reply. The trial proceeded, with the result — as noted above — that judgment was entered denying the relief sought in both the complaint and the counterclaim.

I. Counterclaim Issue

The first issue we address is whether the trial court abused its discretion and committed reversible error by permitting the contractor’s counterclaim to be litigated. Preliminarily, we note that a “counterclaim” is not a listed pleading under I.R. C.P. 7(a). Thus, a counterclaim cannot be asserted as an independent pleading. See I.R.C.P. 7(a); C. Lewis, Idaho Pre-Trial Civil Procedure VI-3 (1982). A counterclaim may only be raised as a part of one of the listed pleadings. See I.R.C.P. 13(a), 13(b). Here, the contractor originally filed the counterclaim independent of any listed pleading. As such, it was not properly pleaded and was functionally equivalent to an omitted counterclaim.

However, an omitted counterclaim may be added, on leave of the court, when the omission is a result of oversight, inadvertence, or excusable neglect, or when justice otherwise requires addition of the counterclaim. I.R.C.P. 13(f). In Cox v. Mountain Vistas, Inc., 102 Idaho 714, 717, 639 P.2d 12, 15 (1981), our Supreme Court, quoting from 3 J. Moore, Moore’s Federal Practice, § 13.13, at 13-846 (2d ed. 1982), stated the purpose of Rule 13(f) as follows:

[Rule 13(f)] will find its most useful application in the case of compulsory counterclaims. Inasmuch as a party could later be met successfully with a plea of res judicata in a suit on a claim within [Rule 13(a) ] which he had failed to plead, the courts should be very liberal in allowing amendments to include compulsory counterclaims, and even permissive counterclaims where no prejudice would result, where the pleader has not been guilty of inexcusable neglect, or has not by reprehensible conduct deprived himself of any claim to special consideration by the court.

The court further said:

Consonant with the above statement concerning Rule 13(f), are this court’s repeated statements that “great liberality should be exercised in permitting amendments to pleadings in furtherance of justice between the parties” ... and that this matter is entrusted to the sound discretion of the trial court [Citations omitted.].

In the treatise, C. Wright, Wright’s Federal Practice and Procedure, § 1430, at page 155 (1971), the author notes that

[t]he clause in Rule 13(f) permitting amendments “when justice requires” is especially flexible and enables the court to exercise its discretion and permit amendments whenever it seems desirable to do so.

As with other discretionary functions of a trial court, the decision whether to allow an amendment can be reversed on appeal only if an aggrieved party can demonstrate that the court abused its discretion. Vollmer Clearwater Co., Ltd. v. Union Warehouse & Supply Co., 43 Idaho 37, 248 P. 865 (1926); Powers v. Security Savings & Trust Co., 38 Idaho 289, 222 P. 779 (1923).

The record here discloses that the contractor did not explicitly request leave to add the counterclaim because he felt his claim had already been filed and properly was before the court. However, the question of whether leave should be granted, to add the counterclaim, was not raised by the court sua sponte. The question, in effect, was presented to the court by the owners’ motion to strike the counterclaim.

The trial court had two choices in dealing with this motion. The judge could have granted the motion, thereby removing the counterclaim from consideration by the jury. Or, he could have denied the motion, thus approving the filing of the counterclaim, after the fact. The latter choice constituted a grant of leave to file the counterclaim. In exercising his discretion, the judge chose the latter course. The court observed that the counterclaim had been filed about two years earlier; that it pertained to the transaction in litigation between the parties; that striking the counterclaim could put a burden on the contractor in regard to filing another lawsuit; and that the contractor’s claim might otherwise have been barred by the statute of limitations. In his closing comments, the court said:

“I don’t find there is strict prohibition if permission isn’t gained from the Court that your counterclaim is waived or void, held for nought or anything of that nature. ... I will grant permission to file a counterclaim, if you need it, because it looks like it pertains to this transaction between these parties and we might as well settle everything right here and now if it’s going to be settled.”

Although not explicit, the court’s ruling is consistent with the provision of I.R.C.P. 13(f) which allows the filing of a previously omitted counterclaim when justice so requires.

The owners were unable to show that any prejudice, in the form of surprise or lack of time to prepare, would result from granting leave, after the fact, to file the counterclaim. Nothing in Rule 13(f) prohibits, and we are cited no authority disapproving, such a grant of leave after the counterclaim has been physically filed. Under these circumstances, we are not persuaded that the judge abused his discretion by denying the owner’s motion to strike, thereby effectively granting leave to the filing of the counterclaim.

The owners argue that the contractor waived reliance on Rule 13 when he asserted, incorrectly, that leave was not required. This argument is not supported by the record. The record indicates only that counsel was not relying on oversight, inadvertence, or excusable neglect under Rule 13(f), in view of the fact that the counterclaim had been physically filed long before the issue of leave to file was raised. There is no indication of any waiver to rely on the ground that “when justice requires,” a pleader may set up a counterclaim by amendment.

The owners cite several cases which, they argue, support their position that the district court erred in granting leave to file the counterclaim. The first is Cougar Bay Co., Inc. v. Bristol, 100 Idaho 380, 597 P.2d 1070 (1979). In that case the Idaho Supreme Court held that a district court did not abuse its discretion in refusing to permit amendment of an answer two days before trial to set forth a counterclaim in excess of $600,000. The district court there concluded that allowing the amended answer would change the issues presented, delay the trial, and provide a great injustice to the other parties. Cougar Bay is distinguishable because in the present case, in the exercise of his discretion, the trial judge implicitly found the opposite — that to strike the counterclaim would create an injustice. Moreover, there was no showing that any prejudice, surprise, or lack of time to prepare an adequate defense would result from the court’s decision to allow a counterclaim that had been on file for twenty-two months.

The second case upon which the owners rely is Lake v. Stewart, 117 Ariz. 520, 573 P.2d 920 (Ariz.App.1977). Reversing a trial court judgment, the Arizona Court of Appeals there held that the trial court erred in allowing a defendant to assert a counterclaim for the first time by oral motion at trial, after the plaintiff had rested his case. (The trial court took the motion to amend under advisement and did not rule upon it until three months after the trial, when it ruled in favor of the defendant on the counterclaim.)

The present case is distinguishable from Lake. Here the counterclaim was filed nearly two years before the start of the actual trial. Thus, the owners had ample knowledge of the action in time to prepare an adequate defense. Also, the owners did not assert or show any prejudice, surprise, or lack of time to prepare a defense caused by the district court’s decision granting leave to file the counterclaim. The court did not take the matter under advisement pending completion of the trial and thereby leave the parties in a state of uncertainty as to the status of the counterclaim. Nor did the owners request a continuance to prepare to meet the issues raised by the counterclaim.

The owners next cite Walker v. Idaho Board of Highway Directors, 96 Idaho 41, 524 P.2d 169 (1974), for the proposition that a motion is necessary “where amendments to pleadings require leave of court.” Walker does not support such a proposition. Rather, in an isolated passage, our Supreme Court simply said that in “the absence of [a motion to amend a complaint] we find no error in the action of the district court [dismissing the action].” 96 Idaho at 45, 524 P.2d at 173. The owners also cite Dairy Equipment Co. of Utah v. Boehme, 92 Idaho 301, 442 P.2d 437 (1968), and Idaho Farm Dev. Co. v. Brackett, 44 Idaho 272, 257 P. 35 (1927), for the proposition that an appropriate motion must be made before a district court may exercise its discretion. These cases do not support that proposition. Nor do they involve an interpretation of a district court’s authority under Rule 13(f) to allow the amendment of pleadings in the interest of justice.

While the premise asserted by the owner seems elementary, i.e., that there is no occasion for the trial court to make a discretionary ruling absent a motion or request therefor, the premise is inapposite here. There was a motion pending before the court — the owner’s motion to strike the counterclaim. In our view, the exercise of the court’s discretion to allow the counterclaim to be litigated was appropriately prompted by the owners’ motion to strike. We conclude that the owners have failed to show an abuse of the trial court’s discretion which would warrant a new trial.

II. Costs and Attorney Fees at Trial

The next issue is whether the trial court erred by awarding costs and attorney fees to the contractor as the “prevailing party.” In their complaint, the owners sought nearly $60,000 in damages for an alleged breach of contract. The contractor sought $9,588 in the counterclaim. After the jury denied the affirmative relief sought by both parties, the contractor applied for costs of $440; attorney fees of $5,950 for defending the action; and attorney fees of $840 for defending the motion for new trial.

In addressing the request for costs and attorney fees, the trial court first noted the existence of the written contract between the parties, upon which the owners’ claim for breach was predicated, particularly the provision therein relating to recovery of attorney fees and costs. The court then considered I.R.C.P. 54(d)(1)(A), regarding costs. That rule provides:

Except when otherwise limited by these rules, costs shall be allowed as a matter of right to the prevailing party or parties, unless otherwise ordered by the court.

The court next considered I.R.C.P. 54(e)(1), regarding the award of attorney fees. That rule provides in pertinent part:

In any civil action the court may award reasonable attorney fees to the prevailing party or parties as defined in Rule 54(d)(1)(B), when provided for by any statute or contract.

Finally, to determine which party was the prevailing party and entitled to costs and attorney fees, the court considered I.R.C.P. 54(d)(1)(B), which recites:

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.

Applying these rules, the trial judge determined that both parties had prevailed in part (as to the claims asserted by each against the other), but that the contractor had prevailed on the “main issue of the case which consumed the majority of the trial,” i.e., the owners’ cause of action against the contractor. The court then concluded that the contractor was entitled to recover all of his costs and, because he prevailed on the main issue presented to the jury, he should be awarded a “proportionate” share of his claim for attorney fees.

The owners maintain that the trial court abused its discretion in awarding costs and attorney fees to the contractor. They argue that unless a party is awarded affirmative relief in the litigation he cannot be a “prevailing” party. We disagree with their contention. The contract between the parties imposes no such limitation. Moreover, in our view, the owners’ position places an unwarranted restriction on the exercise of discretion contemplated by Rule 54(d)(1)(B). We hold that it was permissible for the trial court to consult that rule in determining who was a prevailing party within the meaning of the construction contract.

In reaching the decision as to whether a party “prevailed,” Rule 54(d)(1)(B) requires the court to consider three areas of inquiry: (a) the final judgment or result obtained in the action in relation to the relief sought by the respective parties; (b) whether there were multiple claims or issues between the parties; and (c) the extent to which each of the parties prevailed on each of the issues or claims. If the court determines that a party prevailed only in part, it may apportion the costs and attorney fees 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.

Under Rule 54(dXl)(B), a trial court, in the exercise of its discretion, may consider both the presence and absence of awards of affirmative relief, in determining which party prevailed either in whole or in part. We decline to interfere with this determination by limiting the scope of the inquiry available to trial courts in fulfilling their discretionary functions under the rule, except by the established test of whether an abuse of discretion has occurred. In Hutchinson v. Kelton, 99 Idaho 866, 590 P.2d 1012 (1979), our Supreme Court reviewed a discretionary determination under I.R.C.P. 54(d)(1)(B), and applied the test announced in Lisher v. Krasselt, 96 Idaho 854, 538 P.2d 783 (1975). We deem that test applicable here. In Lisher the court said:

[W]here the trial court has exercised such discretion after a careful consideration of the relevant factual circumstances and principles of law, and without arbitrary disregard for those facts and principles of justice, we will not disturb that action.

Id. at 857, 538 P.2d at 786.

Viewing the trial court’s ruling on the costs and attorney fees issue in this case in light of Lisher, we conclude that the judge did not abuse his discretion in determining that the contractor prevailed. From that determination, the contractor was entitled, under the contract, to recover costs and reasonable attorney fees.

III. Attorney Fees on Appeal

The contractor has prevailed in this appeal by successfully responding to the issues raised by the owners. The construction contract, footnoted supra, mandates an award of attorney fees to the prevailing party. Accordingly, we hold that the contractor is entitled to reasonable attorney fees in this appeal. The amount of the fees shall be determined in conformance with Idaho Appellate Rule 41(d). See, e.g., Industrial Investment Corp. v. Rocca, 102 Idaho 920, 643 P.2d 1090 (Ct.App.1982); Vaughn v. Vaughn, 91 Idaho 544, 428 P.2d 50 (1967).

The orders appealed from are affirmed. Costs and attorney fees to respondents, King.

SWANSTROM and BURNETT, JJ., concur. 
      
      . In his brief on appeal, the contractor also contends that he should have been awarded additional attorney fees by the trial court for successfully resisting the owners’ motion for new trial, and asks us to make that award. However, the contractor did not cross-appeal from the order of the trial court disallowing such relief. That issue, therefore, is not properly before this Court and will not be addressed further.
     
      
      . Paragraph number 13 of the contract provides:
      Should it become necessary for either party to commence legal action to enforce the terms of this Contract, or for violation thereof, the prevailing party shall be entitled to recover, in addition to all other rights hereunder, reasonable attorney’s fees, including court costs.
     