— Defendants, appeal from a judgment for plaintiff in this action arising out of a contract for the per*390formance of work on a state highway project. As grounds for reversal, defendants contend: (1) that plaintiff is precluded from maintaining this action because of failure to comply with the state licensing requirements (Bus. & Prof. Code, §§ 7025-7031); (2) that a prior judgment which has now become final is res judicata on the claim here asserted; and (3) that plaintiff’s present action is barred by section 439 of the Code of Civil Procedure. Since defendants’ third point is well taken and is determinative of this appeal, it will be unnecessary to consider the first two contentions above recited.
On January 29, 1948, plaintiff Flickinger, a licensed contractor, entered into a written contract with defendant Swed-low Engineering Company, Inc., to perform a portion of the latter’s contract with the state for the construction of a public highway. Defendant Firemen’s Fund Indemnity Company is the surety on Swedlow’s contractor’s bond. (Gov. Code, §§ 4204, 14371 et seq.) By an oral agreement on March 15, 1948, Flickinger assigned the benefits of the contract to a partnership composed of himself and another licensed contractor, Ralph Welker. Thereafter the partnership entered upon the performance of Flickinger’s obligations under the contract, except that portion of the work that Swedlow, the general contractor, thereafter agreed to complete. Periodic payments were made to the partnership of Flickinger and Welker as the work progressed. The partnership at no time during performance of the contract obtained a contractor’s license. All of the work under the contract between Swedlow and the state was officially accepted by the state on October 27, 1948.
After the contract was completed a controversy arose between Swedlow and Flickinger concerning the work under their contract; and Swedlow sued (April 9, 1949) Flickinger and Welker, individually and as copartners, for a sum in excess of $60,000 as damages for breach of contract. Flickinger and Welker answered and, in addition, filed a counterclaim alleging that there was a sum of money owing to them and that an account had been stated for some $11,000 between the parties. In that action judgment was entered (February 3, 1953) that neither party take anything on their opposing claims. That judgment became final.
The present action was brought (May 12, 1949) by Flickinger, individually and as assignee of the partnership, against Swedlow, the general contractor, and the surety, Fireman’s *391Fund, setting forth a claim for work performed under the contract and for payment alleged to be due under the terms of defendants’ bonds. (Formerly Code Civ. Proc., § 1184e; now Code Civ. Proc., § 1192.1.) The same amount asserted in the prior action as a counterclaim by defendants Flickinger and Welker, plus one additional charge for certain blasting material furnished for the construction project, constitutes the sum sought in this action. The parties agreed that the present action should be ordered off calendar pending disposition of the prior action, and it was reset for trial on January 8, 1954. By stipulation, the pleadings in the prior action were introduced in evidence in this action.
Flickinger sought recovery here in his own name, alleging that at all times he had been a licensed contractor; that he had assigned the “benefits” of his individual contract to the partnership (Flickinger and Welker) ; that the partnership and Welker had agreed to do the work under his control and direction; that he (Flickinger) duly performed all the conditions agreed to be performed; and that prior to the commencement of suit the partnership and Welker had assigned to him all their right and interest in the money here sought for the work performed. However, at the trial Flickinger testified that following the oral assignment of the Swedlow contract to the partnership, the partnership did the work; and the court generally found that “plaintiff and said partnership duly performed all” the agreed conditions and work for defendant Swedlow. The court further found that “during all of the time mentioned in plaintiff’s . . . complaint, plaintiff was and now is a duly licensed contractor . . . ; that Ralph Welker at all times since November 24, 1947, has been and now is a duly licensed contractor . . . ; and that at all times since May 9, 1949, the said partnership of Flickinger & Welker has been and now is a duly licensed contractor . . . ,” which date was some six months after the work was completed and three days before the filing of the complaint in this action. The court concluded that Flickinger and Welker individually and as partners had “substantially complied with the licensing provisions of the Business and Professions Code,” and that “the cause of action . . . [was] not barred by . . . section 7031 or any section of [that] code.” It further determined that the prior decision was not res judicata, and that this action was not barred by the provisions of section 439 of the Code of Civil Procedure. Accordingly, judgment was entered on plaintiff’s alleged claim.
*392Defendants moved for a new trial, which was denied. However, at that time, in response to defendants’ request for a “more detailed and comprehensive finding of fact with reference to [their] sixth affirmative defense” (the alleged bar of section 439 of the Code of Civil Procedure), the court made these additional findings (Code Civ. Proc., § 662): That the same highway construction project was the subject matter of both actions, involving the same basic contract between Swedlow and the state and the same subcontract between Swedlow and Fliekinger; and that “the work and labor for which plaintiff herein seeks to recover upon defendants’ labor and material bond arose out of said agreement (subcontract) between . . . Fliekinger and . . . Swedlow . . . upon which Swedlow . . . brought suit as plaintiff in [the prior] action.” Upon the basis of this finding, defendants properly challenge the propriety of the trial court’s conclusion that the statutory bar (Code Civ. Proc., § 439) does not apply; and accordingly, they seek reversal of the judgment.
Section 439 provides: “If the defendant omits to set up a counterclaim upon a cause arising out of the transaction set forth in the complaint as the foundation of the plaintiff’s claim, neither he nor his assignee can afterwards maintain an action against the plaintiff therefor.” A counterclaim “must tend to diminish or defeat the plaintiff’s recovery and must exist in favor of a defendant and against a plaintiff between whom a several judgment might be had. . .” (Code Civ. Proc., § 438; Tomales Bay etc. Corp. v. Superior Court, 35 Cal.2d 389, 393 [217 P.2d 968] ; Case v. Kadota Fig. Assn., 35 Cal.2d 596, 603-604 [220 P.2d 912].)
Any claim which Fliekinger, Welker or the partnership may have had against Swedlow arising out of the contract between Fliekinger and Swedlow could and should have been presented by them by way of counterclaim in the prior action. Such counterclaim came precisely within the terms of said section 439. It was “upon a cause arising out of the transaction” set forth in Swedlow’s complaint in that action “as the foundation of plaintiff’s (Swedlow’s) claim”; it would have tended “to diminish or defeat” Swedlow’s recovery; and it existed, if it could be sustained by any defendant in that action, “in favor of a defendant and against a plaintiff between whom a several judgment might be had. ’ ’ Therefore, the defendants in the prior action, including Flickinger, were required to assert any counterclaim which they *393may have had against Swedlow or be forever barred. (Code Civ. Proe., §439.)
Apparently recognizing the necessity for filing a counterclaim in the prior action, defendants therein attempted to establish such counterclaim in the form of an account stated. They omitted, however, to urge directly any counterclaim which they may have had under the terms of Flickinger’s contract with Swedlow. A final judgment on the merits was entered against them upon their counterclaim in the form in which it was stated, and they now take the position that they are not barred in this action either upon the theory of res judicata or upon the theory that said section 439 is applicable. They rely on cases indicating that an action upon an account stated is a different form of action from an action upon the original obligation. (Jones v. Wilton, 10 Cal.2d 493, 498 [75 P.2d 593] ; Young v. LoPresti, 95 Cal. App. 79, 82 [272 P 310] ; Hallford v. Baird, 27 Cal.App.2d 384, 389 [80 P.2d 1040].) We are of the view, however, that such cases are not helpful to plaintiff here; and that to sustain plaintiff’s claim would defeat the salutary purpose and policy of the compulsory counterclaim requirement.
The law abhors a multiplicity of actions, and the obvious intent of the Legislature in enacting the counterclaim statutes (Code Civ. Proc., §§438-439) was to provide for the settlement, in a single action, of all conflicting claims between the parties arising out of the same transaction. (23 Cal.Jur. § 4, pp 221-222.) Thus, a party cannot by negligence or design withhold issues and litigate them in successive actions ; he may not split his demands or defenses; he may not submit his case in piecemeal fashion. (Brunswick Drug Co v. Springer, 55 Cal.App.2d 444, 449-450 [130 P.2d 758].) If by an attempt at artful pleading, a party could assert his cause in one form in one action and, after an adverse decision on the merits, reassert it in another form in a subsequent action, there would be no end to litigation; and, of course, the mere fact that Flickinger may have seen fit to counterclaim in the prior action in the form of an account stated cannot place him in any better position than if he had omitted to file a counterclaim of any kind in that action.
Plaintiff contends, however, that he is not barred from relitigating his rights under his contract with Swedlow as this is an action on Swedlow’s bond; that the defendant surety company was not a party to the prior action and could not have been made a party except by way of cross-*394complaint; and that plaintiff was not required to file a cross-complaint in the prior action. The fallacy underlying this contention is that any right which plaintiff might have had to recover upon the bond was necessarily dependent upon plaintiff's right to recover upon his contract with Swedlow. While he had the option to file a cross-complaint on the bond and thereby bring in the surety as a party in the prior action (Code Civ. Proc., § 389), he was clearly compelled to assert by way of counterclaim, in said prior action, any right which he had against Swedlow under the contract which was the basis of Swedlow's prior action. (Schrader v. Neville, 34 Cal.2d 112, 115 [207 P.2d 1057].) Having omitted to assert directly in that action his alleged rights under the contract, but having elected to assert his alleged rights upon an alleged account stated with the resulting adverse final judgment on the merits, plaintiff is now barred from re-litigating his alleged rights under the contract as the basis for an action against Swedlow as the principal on the bond. And as such defense to this action is available to Swedlow as the principal, it is likewise available to defendant Fireman's Fund, as the surety on the bond. “Sureties on a bond have a legal right to avail themselves of all defenses that would be allowed the principal and are generally in no worse position than he would be if sued separately ’’ (8 Cal.Jur.2d § 82, p, 691; County of Sonoma v. Hall, 132 Cal. 589, 593-594 [62 P. 257, 312, 65 P. 12, 459].)
Nor does the record support plaintiff’s claim that by reason of loches, waiver or estoppel, defendants may not rely on the statutory bar of section 439 of the Code of Civil Procedure. In answer to plaintiff’s original complaint in this action, defendants urged as an affirmative defense the pendency of the prior action. At that time and apparently until the entry of judgment in that action on February 3, 1953, defendants believed that the issue herein as to the liability of the parties on their conflicting claims arising out of their basic agreement was being litigated in the prior action. Then, when plaintiff indicated his intent to bring the present action to trial, defendants were granted leave to amend their answer by adding the further defenses of res judicata and the statutory bar of the compulsory counterclaim. (Code Civ. Proc., §439.) Plaintiff offered no evidence showing any loches, waiver or estoppel chargeable against defendants in so amending their answer; and to the contrary, the record indicates that defendants acted with reasonable *395promptness in filing their amendment on December 30, 1953, after the parties had submitted arguments thereon, and prior to the trial herein.
The judgment is reversed.
Gibson, C. J., Shenk, J., Edmonds, J., Carter, J., Traynor, J., and Schauer, J., concurred.
Respondent’s petition for a rehearing was denied November 23, 1955.