#### Jack D. JONES*, Trustee of Republic Financial Corporation, and Marian B. Howard, Appellees, v. Collis B. ENGLAND and Evelyn A. England, husband and wife, Curtis G. Holsted and Martha Lou Holsted and Gene C. Howard, Appellants.

No. 66841.

Supreme Court of Oklahoma.

Oct. 31, 1989.

*120Lewis N. Carter, Tulsa, for appellees.

H. Gregory Maddux, Tulsa, for appellants.

*

 The only parties participating in this court on certiorari are Jack D. Jones, Trustee of Republic Financial Corporation and Gene C. Howard.

SUMMERS, Justice.

Trustee in Bankruptcy of the failed Republic Financial Corporation has sued three guarantors of a loan also secured by a real estate mortgage. The trial court gave plaintiff judgment by default against the makers of the note and also summary judgment against the guarantors. The guarantors appealed. After the Court of Appeals summarily affirmed, one of the guarantors, Gene C. Howard, petitioned this court for certiorari. We have granted his petition, and now reverse the judgment of the lower court insofar as it pertains to Howard.

Howard’s only complaint on appeal is that the summary judgment was inappropriate in light of his pending defenses and counterclaims, all of which, he contends, were sufficient to present controverted issues of material fact. Upon examination of the pleadings and affidavits submitted in response to the motion for summary judgment, we agree.

The facts on which the Trustee relies are (1) that the Englands executed a note and mortgage to Republic, (2) that Howard and the Holsteds (the other guarantors) executed their personal guarantees of the note, and (3) that the note is unpaid according to records of the failed lender. Based on these the trial court rendered summary judgment against Howard for $200,197.36 plus interest and attorney fees. The Trustee successfully relied on the automatic stay from the U.S. Court in Bankruptcy to avoid any consideration of Howard’s counterclaims.

Affidavits submitted by the guarantors in response to the motion for summary judgment indicate that they took issue with the amount due. Howard, consistent with material pled in his counterclaims, therein avers that his dealing with Republic through its president Wesly McKinney went back some 15 years. The affidavits describe in some detail an ongoing financial relationship culminating in the England transaction as follows:

> *121“That in approximately June of 1983, Howard and Hoisted entered into and negotiated a sale of additional real estate to Collis England and Evelyn England which is the subject of this litigation. That said Collis England and Evelyn England borrowed in excess of $200,-000.00 which they were to pay Howard and Hoisted for the said property.

> That on or about August 5, 1983, Republic Financial closed the loan to Collis and Evelyn England and withheld all of the funds due to Howard and Hoisted, but agreed that a sum of approximately $26,-000.00 was due to Howard and Hoisted from said transaction after paying off all the indebtedness of Howard and Hoisted to Republic Financial Corporation.”

> That on a total indebtedness of $237,-542.32, that Republic Financial Corporation, since May 26, 1978, has collected in excess of $700,000.00 in payments, credits and property and has failed, neglected and refused to account for the proceeds and at this time there is a substantial balance due to Howard and Hoisted from Republic Financial Corporation.” (O.R. at 88, 89, 90).

In granting judgment against Howard in the amounts mentioned the trial court added the following:

> ... provided that said judgment shall be without prejudice to Defendant, Gene C. Howard to challenge any amounts sought to be recovered against him by way of a deficiency judgment.

Plaintiff urges that the trial court has thus preserved Howard’s rights to present his claims prior to entry of “deficiency judgment”, and that apparently is what the trial court endeavored to do. We believe, however, that in doing so the lower court misperceived the office of deficiency judgment. In mortgage foreclosure practice “a personal judgment or judgments shall be rendered *for the amount or amounts due*... to the plaintiff,” 12 O.S. 1981 § 686 (emphasis added). An order of foreclosure that determines the amount due is the final order for the purpose of an appeal. See, 3 L. Jones, *A Treatise on the Law of Mortgages of Real Property,*§ 2052 at 504 (8th ed 1928). Cf. *Myers v. Carr,*173 Okl. 335, 47 P.2d 156, 161 (1935), where we stated that “it is the settled law that correctness of a foreclosure decree cannot be considered on an appeal from an order of confirmation” and *McCredie et al. v. Dubuque Fire & Marine Ins. Co.,*49 Okl. 496, 153 P. 846 (1915), holding that an order of confirmation is made upon summary application *after judgment.*

A “deficiency” in foreclosure practice is that part of a debt secured by mortgage not realized from the sale of the mortgaged property. *Blacks Law Dictionary,*510 (4th ed. 1951). A judgment for the amount of such deficiency is called a deficiency judgment. Its creation is actually a new judgment occurring in a post-judgment proceeding. *Baker v. Martin,*538 P.2d 1048 (Okl.1975).

In granting personal summary judgment against guarantor Howard for the amount due on his guaranty the court has considered only the factual assertions of the plaintiff, and disregarded those of Howard which take issue with plaintiff’s version of the amounts due. Affidavits relied on by Howard in opposition to the Motion for Summary Judgment clearly show that he claimed credit for at least $26,000.00 due after the England transaction, and perhaps a set-off for more than $400,000.00 on alleged overpayments.

Howard’s counterclaim based on amounts previously paid to Republic is an argument that he has satisfied the guaranty by payment. He alleges that his over-payments on other obligations should be credited to his obligation arising from the guaranty. His counterclaim rests on Republic’s duty to apply Howard’s payments to Republic on the obligation arising from the guaranty. Is he entitled to such a set-off in the Trustee’s suit?

In Roman jurisprudence mutual obligations were setoff by operation of law, and “debts were extinguished so far as the amount due on the smaller debt could rightfully compensate the larger”. *Blount v. Windley,*95 U.S. (5 Otto) 173, 178, 24 *122L.Ed. 424 (1877). Generally, the common-law provides otherwise, that mutual debts are not automatically setoff by operation of law. *Gilliland v. Jones,*274 S.C. 497, 265 S.E.2d 263, 264 (1980); *Green v. Farmer,*4 Burr. 2214, 1 Wm Bl. 651; 98 E.R. 154 (1768). (Lord Mansfield in the latter case did observe that “[n]atural equity says that cross-demands should compensate each other, by deducting the less sum from the greater and that the difference is the only sum which can be justly due”.)

Insolvency, however, may allow for a different result. Insolvency of one of the parties may create an equity, or at least strengthen it, sufficient to allow a setoff of the mutual obligations. 3 J. Story, *Commentaries on Equity Jurisprudence,*§ 1872 (14th ed 1918). This equitable principle has been applied for the benefit of borrowers in cases involving insolvent national banks. *Scott v. Armstrong,*146 U.S. 499, 13 S.Ct. 148, 36 L.Ed. 1059 (1892); *Hibernia National Bank v. Federal Deposit Ins. Corp.,*733 F.2d 1403, 1407-1408 (10th Cir.1984); *Seattle-First Nat. Bank v. F.D.I.C.,*619 F.Supp. 1351, 1358 (W.D.Okl.1985). It has also been applied to Republic in a recent bankruptcy proceeding, *In re Republic Financial Corporation,*47 B.R. 766 (Bankr.N.D.Okl.1985). In that case the court addressed the equities of a setoff of a Thrift Certificate against a Promissory Note, and stated:

> “[TJhis Court orders that stay granted Republic Finance Corporation and Republic Trust and Savings Corporation be modified so as to allow Movants to setoff their claim against RFC with their obligation owed to RT & SC pursuant to 11 U.S.C. § 553.” *Id.*47 B.R. at 768.

> “It would be a grave injustice and cause substantial hardship and monetary loss to Movants to deny setoff of the mutual claims and obligations by virtue of the acts and activities of the debtor corporations.” *Id.*47 B.R. at 770.

The grave injustice of denying a setoff as described above is no less an injustice when an insolvent plaintiff is bringing suit on a guaranty agreement and the defendant desires to setoff the guaranty obligation with payments allegedly made to the plaintiff. Thus, we hold that Howard’s counterclaim raises a permissible defense to the action on the guaranty.

Summary judgment is appropriate only when it is clear that there is no substantial controversy to any material fact. *Northrip v. Montgomery Ward,*529 P.2d 489 (Okl.1974); *Weaver v. Pryor Jeffersonian,*569 P.2d 967 (Okl.1977). The trial court’s summary judgment against Howard fixing the amount due on the guaranty was not proper with Howard’s defenses and counterclaims unresolved.

The opinion of the Court of Appeals is vacated and the summary judgment against Howard is reversed. The cause is remanded to the District Court’ of Tulsa County for further proceedings consistent herewith at such time as the automatic stay of proceedings from the U.S. Bankruptcy Court shall not bar litigation of the counterclaims.

HARGRAVE, C.J., HODGES, LAVENDER, SIMMS, DOOLIN, ALMA WILSON and KAUGER, JJ., and GARY L. LUMPKIN, S.J. (Appointed in place of OPALA, V.C.J., who disqualified), concur.