
414 P.2d 460 (1966)
BURLEY NEWSPAPERS, INC., a Corporation, Plaintiff-Respondent,
v.
MIST PUBLISHING COMPANY, a Corporation, Defendant-Appellant, and
Jessica L. Longston, Defendant.
No. 9723.
Supreme Court of Idaho.
May 12, 1966.
Rehearing Denied June 2, 1966.
Duffin & Duff, Rupert, for appellant.
Parsons, Smith & Snow, Burley, for respondent.
McQUADE, Justice.
In 1961 Mist Publishing Company, a foreign corporation incorporated under the laws of Oregon, contracted to sell to Dean and Kathryn Lesher the "Burley Herald-Bulletin," a newspaper it owned and operated for 17 years in Idaho. The Leshers and their assignee, Burley Newspapers, Inc., executed promissory notes to Mist Publishing Company for the purchase price. The notes were secured by a chattel mortgage upon the property transferred to the buyers.
In 1963 plaintiff-respondent Burley Newspapers, Inc., instituted this action to rescind the contract because of alleged misrepresentations and breaches by the seller of warranties contained in the contract. It also sought attorney fees as provided in the agreement and, in addition or as an alternative to rescission, money damages.
*461 Mist Publishing Company, defendant-appellant, counterclaimed to foreclose the chattel mortgage because of plaintiff's nonpayment on the promissory notes. The plaintiff moved for summary judgment in its favor on the ground that Mist Publishing Company, as a matter of law, lacked capacity to maintain its counterclaim in an Idaho court. The trial court granted the motion for summary judgment and Mist has appealed therefrom.
At the time the contract was consummated, Mist, by reason of its failure to comply with I.C. § 30-501[1] and I.C. § 30-502,[2] had not qualified to do business in Idaho. Respondent contends that appellant comes within the prohibition of I.C. § 30-504:
"Noncompliance  Effect on contracts.  No contract or agreement made in the name of, or for the use or benefit of, such corporation prior to the making of such filings as provided in sections 30-501 and 30-502 can be sued upon or enforced in any court of this state by such corporation."
The precise question presented is whether I.C. § 30-504 prohibits a counterclaim by a corporation when the contract, entered into at a time when it was in noncompliance, is sought to be enforced by the other party *462 to that contract and such counterclaim arises out of the subject matter of the plaintiff's action.
Katz v. Herrick, 12 Idaho 1, aff'd on rehearing 12 Idaho 24, 86 P. 873 (1906), one of the earliest Idaho cases interpreting former provisions of I.C. §§ 30-501, 30-502 and 30-504, lucidly explains the purpose of the provisions in question:
"A failure to comply with these requirements and obtain the legal right to transact business is not in fact so much of an invasion or violation of the sovereignty of the state as it is a violation of the private and property rights of the citizens with whom it does business. At the time of the adoption of the Constitution, as well as now, it was the practice of many tramp, predatory, and rapacious foreign corporations organized under the laws of  nobody knew where  to come into this jurisdiction, and, without appointing an agent or establishing a place of business, make contracts and transact business, and, after having violated their contracts or committed injuries and depredations upon the rights of the citizen, avoid the process of the state courts, which practically amounted, in many instances, to complete protection and immunity from the consequences of their unlawful acts. In the great majority of instances, if the citizen be unable to prosecute his action and secure redress for his grievances in the state courts and in the county where he resides, it amounts to denying him redress at all. * * * We have never held, and never intended so to do, that such contracts are entirely and absolutely void. On the contrary, we intimated in the original opinion that they are enforceable on the side of the party with whom they have assumed to contract. We did say, however, that the corporation should be without any remedy in the courts on an action to enforce contracts made by them while in default of compliance with the requirements of law. The evil does not exist so much in the contract as in the legal existence of one of the contracting parties. * * * here the hazard and risk is admitted  hazard and risk of being unable to get service of process on the noncomplying corporation." 12 Idaho at 26-30, 86 P. at 879-880.
Two important principles were established in the Katz case which are vital to the decision herein. First, contracts made by a noncomplying corporation are not void or voidable by the other party nor against public policy. Second, the primary purpose of the former provisions of I.C. §§ 30-501, 30-502 and 30-504 was to ensure Idaho citizens who deal with foreign corporations in Idaho a local forum if there is a claim against the corporation arising out of such transactions. The aim of the provisions is to protect the right of Idaho citizens to sue foreign corporations in Idaho. They are not intended to prohibit or discourage foreign corporations from doing business in this state. In fact the legislature has declared the policy to be the encouragement of foreign corporations to engage in business in Idaho. I.C. § 30-518. Bearing in mind the purposes of the entire statute relating to foreign corporations transacting business in Idaho, we conclude that the statute does not preclude appellant from asserting its counterclaim in this action.
Equity requires that if part of a contract is to be enforced, as respondent is seeking to do in its action, the entire contract, which is valid, also should be enforced, including the obligations of the plaintiff. The respondent, after obtaining the benefits of the contract and possession of the newspaper and physical facilities connected therewith, operated the newspaper for almost two years prior to instituting this action. The contract was wholly executed except for respondent's obligations on the promissory notes. It would be both inequitable and against the public policy of this state to permit one party to a contract, voluntarily made, to seek relief from an executed contract after receiving the benefits thereunder and not permit the *463 other party similarly to enforce the contractual obligations. Stearns v. Williams, 72 Idaho 276, 240 P.2d 833 (1952); Keating v. Keating Mining Co., 18 Idaho 660, 112 P. 206 (1910); Anno. 7 A.L.R.2d 256.
Our conclusion that I.C. § 30-504 does not bar appellant's counterclaim is in accord with the decisions of other jurisdictions having similar statutes and which have passed on this issue.
In James Howden & Co. of America v. American C. & E. Corp., 194 App.Div. 164, 185 N.Y.S. 159 (1920), aff'd mem. dec. 231 N.Y. 627, 132 N.E. 915 (1921), the court, in interpreting the New York statutes,[3] stated:
"* * * the provision in this section that no action shall be maintained has been construed not to prohibit the assertion of a counterclaim by a defendant sued in this state, although the defendant has not complied with section 15 of the General Corporation Law." 185 N.Y.S. at 161.
In quoting from J. R. Alsing Co. v. New England Quartz & Spar Co., 66 App.Div. 473, 73 N.Y.S. 347 (1901), aff'd without opinion 174 N.Y. 536, 66 N.E. 1110 (1903), the court continued:
"* * * a foreign corporation which has been made a party in an action in our courts has a right, in addition to contesting the claim made against it, to recover upon a counterclaim based upon the same transaction. The defendant, having been brought into court and thus made to defend, should be allowed, unless there is a distinct provision to the contrary, not only to defend, but also to litigate any question arising out of the transaction that has been made the basis of the plaintiff's complaint." 73 N.Y.S. at 350.
See also American Ink Co. v. Riegel Sack Co., 79 Misc. 421, 140 N.Y.S. 107 (1913), in which that court stated the General Corporation Law did not prohibit the noncomplying corporation's counterclaim if it arose out of the same transaction on which the plaintiff sued.
In Smith v. Kincade, 232 F.2d 306 (5th Cir. 1956), the federal court of appeals interpreted the Mississippi statute[4] and stated:
"The Mississippi statutory prohibition against bringing or maintaining actions or suits does not prevent a defendant from interposing defenses when sued nor preclude the asserting and recovering upon a counterclaim."
In Flakne v. Metropolitan Life Ins. Co., 198 Minn. 465, 270 N.W. 566 (1936), although the statutory provisions were not set forth and there were other facts, not present here, which may have influenced the court, it appears that a foreign corporation failing to obtain a license or authorization to do business in the state "was not entitled to sue or maintain an action in the courts of this state to foreclose its mortgage," but nevertheless the Minnesota court held that it was entitled to defend its rights under the contract.
"The statute here referred to is highly penal in its nature and should receive a strict construction * * *.
"The policy of this state has been to protect and encourage, rather than discourage, foreign corporations and individuals in making loans and investing money within this state. * * * *464 "It is settled in this state that * * * a mortgage or contract entered into, even by a foreign corporation having no license of any kind to do business in this state, is not a void contract, and, as between the parties, the only result, so far as the contract is concerned, is that the corporation cannot bring an action in court to enforce the contract. * * *
"The defendant here has not sued or maintained any action, at law or otherwise, in court. The suit was commenced and has been maintained by the plaintiffs and the intervener. Defendant was compelled to come into court and defend its rights under the mortgage. In that situation, defendant is not violating any statute by setting up, by answer and cross-complaint, its rights to foreclose this mortgage. In 14a C.J., p. 1312, § 4016, the general rule is stated that a statute such as ours `does not prevent a foreign corporation which has not complied with the statute from defending a suit brought against it, interposing and recovering upon a counter-claim arising out of the transaction in suit, or prosecuting an appeal or writ of error from a judgment recovered against it.' * * *
"* * * the appellants, by bringing this action against defendant, cannot prevent it from defending and pleading its mortgage and the defaults thereunder to entitle it to a foreclosure sale. By bringing it into court, the appellants are estopped from claiming that defendant has no right to be in court." 270 N.W. at 568-569.
Supportive of the cases cited above are reference works which also support the conclusion reached herein.
In 20 C.J.S. Corporations § 1859 it is said:
"A statute merely prohibiting the commencement or maintenance of an action does not prevent a noncomplying foreign corporation from interposing and recovering on a counterclaim arising out of the transaction in suit."
So also 23 Am.Jur. Foreign Corp. § 335 (p. 313) states:
"As a general rule, a counterclaim arising out of a contract sued on, * * * may be asserted by the corporation; * * *."
The only case found to the contrary, where the statute was similar to I.C. § 30-504, is a decision of a Texas intermediate appellate court, Hightower Petroleum Corp. v. Story, 236 S.W.2d 679 (Ct.Civ.App. Texas 1951). In that case the plaintiff sued and the noncomplying corporation counterclaimed on a theory in tort. The court denied the counterclaim without a discussion of the issue.
Tarr v. Western Loan and Savings Co., 15 Idaho 741, 99 P. 1049, 21 L.R.A.,N.S., 707 (1909), is cited by respondent. There, the plaintiff did not sue on the contract, but rather sued to rescind the mortgage solely because the defendant had failed to comply with the statutory filing requirements. The defendant cross-complained to foreclose the mortgage. We therein held that the defendant could not maintain its counterclaim action. That decision is not in conflict with the holding herein.
There are other cases which hold that noncomplying corporations may not counterclaim in circumstances similar to those herein. However, those decisions are based on statutes which explicitly deem such contracts void or which explicitly prohibit counterclaims by noncomplying corporations and, therefore, are not comparable to the Idaho provisions.[5]
The judgment is reversed and remanded for further proceedings.
Costs to appellant.
McFADDEN, C. J., and TAYLOR, SMITH and SPEAR, JJ., concur.
NOTES
[1]  I.C. § 30-501 (as in effect at that time):

"Filing of evidence of incorporation  Prerequisite to doing business.  Every corporation not created under the laws of this state or of the United States must, before doing business in this state, file for record with the secretary of state a copy of the articles of incorporation of said corporation, duly certified to by the secretary of state of the state in which said corporation was organized, or such other legal custodian of the corporation records of said state as is qualified under its laws to make such certified copy, and file for record a copy of such articles of incorporation, duly certified by the secretary of state of this state and bearing the endorsement of the fact and time of filing for record in his office, in the office of the county recorder of the county in this state in which is designated its principal place of business in this state. The secretary of state shall not file the articles of incorporation of any such corporation whose corporate name does not conform to the requirements set forth for the names of domestic corporations in paragraph 2, 3 and 4 of section 30-107. The provisions of paragraph 5 of said section 30-107 shall also be applicable. The use of a name in violation of this section shall not affect the privileges accorded a foreign corporation complying with the provisions of this chapter but the courts of this state, having equity jurisdiction, may, upon the application of the state, or of any person, unincorporated association, or corporation interested or affected, enjoin such corporation from doing business under a name used in violation of this section, although its articles of incorporation may have been filed by the secretary of state."
[2]  I.C. § 30-502: "Designation of statutory agent.  Such corporation must also within three months from the time of commencement to do business in this state, designate some person or persons in the county in which the principal place of business of such corporation in the state is situated, upon whom process issued by authority of or under any law of this state may be served, and within the time aforesaid must file such designation for record in the office of the secretary of state, and file for record in the office of the county recorder of such county a copy of such designation, duly certified by such secretary of state, and bearing the indorsement of the fact and time of filing for record in the office of the secretary of state. A copy of such designation, certified by either of said officers, shall be conclusive evidence, in all courts and elsewhere, of the fact of such designation.

"It is lawful to serve on any of such persons so designated any process issued as aforesaid, and such service must be deemed a valid service thereof.
"Such notice and designation of any agent on whom process may be served, shall run from the time of filing the same for record as herein provided, until his successor is appointed by such filing, or said office becomes vacant by resignation filed for record by such agent in the offices in which his appointment is filed for record, or by his death or removal from such county, and in case of such vacancy, if there be no other designated agent, said corporation shall, within sixty days thereafter, refill said office in the manner above provided for the designation of such agent."
[3]  General Corporation Law § 15 (Consol. Laws, c. 23): "No foreign stock corporation doing business in this state shall maintain any action in this state upon any contract made by it in this state, unless prior to the making of such contract it shall have procured such certificate." Tax Law § 181 (Consol.Laws, c. 60): "No action shall be maintained or recovery had in any of the courts in this state by such foreign corporation * * * without obtaining a receipt * * * for the payment of the license fee * * *."
[4]  Miss.Code 1942, Ann. § 5319. "* * * Any foreign corporation failing to comply with the above provisions shall not be permitted to bring or maintain any action or suit in any of the courts of this state."
[5]  See, e. g., Dunn v. Utah Serum Co., 65 Utah 527, 238 P. 245 (1925); Roberts v. Cat-Nak Mfg. Co., 216 Ill.App. 245 (1919); Rib Falls Lumber Co. v. Lesh & Mathews Lumber Co., 144 Wis. 362, 129 N.W. 595 (1911).
