
81 Cal.App.3d 554 (1978)
146 Cal. Rptr. 741
SHELDON E. GROSSMAN et al., Plaintiffs and Respondents,
v.
JERRY H. LIPPSON, Defendant and Appellant.
Docket No. 51154.
Court of Appeals of California, Second District, Division Two.
June 2, 1978.
*556 COUNSEL
Holden & Bevins and Daniel W. Holden for Defendant and Appellant.
Johnston & Wilson and Hunter Wilson for Plaintiffs and Respondents.
OPINION
FLEMING, Acting P.J.
Lippson appeals a money judgment against him for $303,000 in favor of plaintiff Grossman.[1]

FACTS
In March 1970 Grossman operated the Mediterranean Car Wash in Torrance on leased premises. Grossman owned the business, the building and fixtures, and the carwash equipment, the last, however, subject to a lien by Tarlov and Weber, his predecessors in interest. In March 1970 Grossman, through escrow, simultaneously, (1) sold the business to Miller for $405,000, (2) subleased the premises to him; and (3) leased the building and carwash equipment to him for $67,000 payable in monthly installments of $530.[2] On the $405,000 purchase price Miller paid $85,000 in cash and gave a promissory note for $320,000, which note specifically declared: "This note is secured by a security agreement." Under the escrow instructions, the financing statement, and the equipment lease, the promissory note was secured by the equipment lease and the leasehold improvements.
The equipment lease required the lessee to keep the leased property in serviceable condition and good repair, and gave the lessee an option to purchase the leased equipment on the expiration of the lease for its then depreciated value, not to exceed $500. The various documents used to execute the transaction specified that default in payment of the promissory note could be considered default in payment under the equipment lease, and vice versa, and that default in the sublease of the real property could be considered default under the equipment lease, and vice versa.
*557 In August 1970 Miller sold the carwash business to defendant Lippson. Lippson assumed the sublease of the premises, took an assignment of and assumed the equipment lease, assumed and agreed to pay the promissory note, and agreed to indemnify Grossman for his costs and expenses, including attorney's fees, if he failed to perform his obligations.
In March 1972 Lippson sold the carwash business to codefendant Pratt. With the consent of Grossman he assigned the equipment lease and the premises sublease to Pratt, who assumed these obligations. In October 1973 Lippson failed to pay the installment of $3,470 due on the promissory note and made no further payments on the note. Likewise in October Pratt failed to make the payment due on the carwash equipment lease and made no further payments on the equipment lease. In November defendants failed to pay the rent due under the premises sublease and made no further payments on the sublease. Grossman gave written notices of default to Miller, Lippson, and Pratt, declared the equipment lease and the premises sublease terminated, and accelerated the unpaid principal balance of $221,000 on the promissory note. His various notices made no mention of any disposition of the security given for the promissory note. Pratt apparently abandoned the premises in late October or early November, and thereupon Grossman took possession of the carwash business, equipment, and premises, spent $21,000 to resurface the asphalt ground cover and repair the carwash equipment, and thereafter operated the business at a profit for his own account under the name it had always carried, Mediterranean Car Wash.
In December Grossman filed suit against Lippson and Pratt for $221,000, the amount of the unpaid balance on the $320,000 promissory note, and for $21,000, the cost of repairs. Defendants resisted on the ground that plaintiff was attempting to secure a deficiency judgment on a secured debt without complying with the provisions of the California Commercial Code that require a sale of the security with the proceeds credited to the debtor. The trial court, however, reasoned that the promissory note was secured only by the equipment lease and not by the equipment itself; that on default, the equipment lease had been properly terminated by Grossman, the creditor; that termination of the equipment lease extinguished the security for the promissory note; that consequently the note became an unsecured note, and the creditor was not required by the Commercial Code to foreclose on nonexistent security. The court concluded that on default of the promissory note and Grossman's election to accelerate, the entire unpaid balance of the note became due and payable. Judgment was rendered against Lippson for $221,000, plus *558 interest, attorney's fees, and costs. For breach of the covenants in the premises sublease and in the equipment lease to keep premises and equipment in good repair, the court gave a further judgment against Lippson and Pratt for $21,000, plus interest and attorney's fees.[3]

DISCUSSION
On appeal, Lippson, the debtor, contends the notice requirements of the Commercial Code's regulation of secured transactions were not met, that Grossman as creditor was not entitled to repossess the carwash business, and collect in full the unpaid balance of the purchase price, and obtain judgment for the cost of repairs. He argues that in a secured transaction as is this the right to a deficiency judgment on the debt depends upon compliance with the statutory requirements governing the disposition of, and credit for, the security. (Atlas Thrift Co. v. Horan (1972) 27 Cal. App.3d 999, 1009 [104 Cal. Rptr. 315, 59 A.L.R.3d 389]; see also, J.T. Jenkins Co. v. Kennedy (1975) 45 Cal. App.3d 474, 481 [119 Cal. Rptr. 578]; Barber v. LeRoy (1974) 40 Cal. App.3d 336, 341 [115 Cal. Rptr. 272].) In this case, he argues, the creditor not only took and kept possession of the collateral, i.e., the carwash business, the carwash equipment, and the subleased premises, but obtained a deficiency judgment for the balance due on the promissory note without crediting defendant with the value of the collateral repossessed. This was erroneous, he asserts, because in a secured transaction the creditor must either accept the collateral as discharge of the obligation (Cal. U. Com. Code, § 9505) or sell it on proper notice to obtain a deficiency judgment. (Cal. U. Com. Code, § 9504.)
In opposition, Grossman, the creditor, argues that the Commercial Code does not apply, because the note was no longer secured after he terminated the equipment lease. The only security for the promissory note was the lease itself  not the equipment, not the carwash business  and when he terminated the equipment lease because of default the collateral for the promissory note ceased to exist. Since the law does not require a useless act, he was not required to give notice of sale of a nonexistent lease. Therefore, he never obtained a deficiency judgment against Lippson, he was never unjustly enriched, and he was legally entitled to judgment for the balance of the promissory note and the cost of repairs.


*559 I
(1) As with so many other legal controversies the solution to conflicting claims lies in a realistic evaluation of the facts. Once we untangle the essentials of the parties' transaction, substance and form can combine to produce a suitable legal pattern. Factual evaluation is particularly helpful in a case arising under the California Uniform Commercial Code  Secured Transactions (Cal. U. Com. Code, § 9101 et seq.), where we are instructed as a matter of policy to put substance above form. (Cal. U. Com. Code, § 9102, subds. (1)(a) and (1)(c).)
(2a) We deal here with repetitions of a single theme  the transfer of a carwash business at a particular location together with the facilities needed to conduct that business. The transfer took the form of a sublease of the underlying real property; a lease-purchase of carwash equipment, and a sale of the goodwill, trade name, and other intangible assets of the business. If the buyer had not defaulted, the substance of the transaction would have resulted in the purchase and sale of everything connected with the carwash business. The sale of the business, originally for $450,000, was restructured into a sale of the business for $405,000 and a lease-purchase of carwash equipment for $67,000 in monthly payments. Yet what was sold was a package  one that included goodwill, trade name, intangibles, improvements, fixtures, premises, and carwash equipment, all the elements needed to conduct the business. On default, the seller repossessed the entire package  premises, equipment, and business  and resumed operations for his own account. Is he entitled to recapture everything he sold, and at the same time secure a judgment for the unpaid balance of the sales price?
The seller argues the unpaid balance of the sales price was secured only by an equipment lease (not equipment), and when he terminated the equipment lease he terminated the security, and as an unsecured creditor he became entitled to judgment on the promissory note without further ado. (3) In essence, he seeks to differentiate the security of an equipment lease as collateral from the security of equipment as collateral. But we must ask ourselves the significance of using a lease-purchase as security for the lessee's related promissory note. What interest does a lessee own as a result of a lease-purchase? He owns the right to uninterrupted possession and use of the equipment so long as he pays the rent. But he also owns the right to purchase legal title to the equipment by paying a nominal sum at the expiration of the lease. Essentially, that ownership right is what makes the lease-purchase a security interest (Cal. *560 U. Com. Code, § 1201, subd. (37)) and is what is given as security for a related promissory note. If lessee defaults on the note, what remedy does lessor have in order to realize on the "security" given for the note? He has the right to take possession of the collateral, which is the right to possess the equipment, i.e., to take back the equipment if the note is in default, even if payments on the equipment lease itself remain current. Accordingly, lessor takes possession of, i.e., repossesses, the physical equipment in place. Whether he presents a paper that says he is repossessing because of default on the lease, or one that says he is repossessing because of default on the note, the result is the same. He is entitled to possess the physical equipment because of the buyer's default on related interconnected transactions: note and lease. There is no essential difference between the repossession that occurred here and one that would have occurred under a note secured by equipment which a creditor was authorized to seize on default.
(2b) The interconnection between equipment lease and promissory note was spelled out in the equipment lease itself, which declared that in the event of lessor's (Grossman's) default in satisfying prior liens on the carwash equipment lessee could cure the default and deduct the sums so paid from payments due on the promissory note or payments due on the lease itself. The equipment lease further declared, "Notwithstanding anything above, it is understood by all parties to this lease that this lease becomes collateral for the note and the note becomes collateral for this lease so that any default in either instrument by Lessee, that is, default in payment of the note or the terms thereof or default in the payment of this lease or any condition thereof, immediately accelerates the note and creates a default in this lease so that Lessor may immediately avail himself of his remedies." Suppose the debtor defaulted on the promissory note but kept up his payments on the equipment lease. Clearly, under the terms of the transaction the creditor would have the right to take possession of the carwash equipment and realize on its equity.
At bench, we have the sale on credit of an operating business whose three constituent elements  land, carwash equipment, and ongoing business  were tied together by a rudimentary form of cross-collateralization. When the business fell on hard times, land, equipment, and ongoing business were all simultaneously repossessed by the seller-creditor. In such a transaction if the seller-creditor wishes to obtain a deficiency judgment on a promissory note given by the buyer-debtor as part of the purchase price, he must sell the collateral on proper notice and credit the debtor with its proceeds. (Cal. U. Com. Code, § 9504.)
*561 Some comment bearing on the problem is found in Puritan Leasing Co. v. August (1976) 16 Cal.3d 451 [128 Cal. Rptr. 175, 546 P.2d 679], a case involving repossession and resale of leased equipment pursuant to the terms of a lease. In explaining why plaintiff lessor had not been unjustly enriched, the court pointed out that he "does not thereby obtain both the property and the rent. To the extent plaintiff disposes of the property, or obtains value for its use, plaintiff must credit appropriately such sums received against the amounts due from defendants." (16 Cal.3d at p. 461.) Presumably, there would have been unjust enrichment if such credit had not been given. The court in Puritan Leasing noted that the "modern chattel leasing transaction is a valuable commercial financing device.... This lease therefore appears to have served a commercial function closely analogous to such other common financing methods as conditional sales and chattel mortgages. The latter instruments as `security interests' covered by division 9 of the California Uniform Commercial Code, do permit repossession and resale of the security and recovery of any deficiency. [Citations omitted.] It has been suggested that a lease for the entire useful life of a chattel constitutes a `lease intended as a security device' under California Uniform Commercial Code section 1201, subdivision (37), and is itself therefore a `security interest' giving rise to the remedies provided in division 9." (16 Cal.3d at pp. 461-462.)
If, as suggested by the foregoing language, a lease standing by itself may constitute a security device, a fortiori, a lease expressly given as security for the buyer's note in the purchase and sale of a business constitutes a security device, and repossession thereunder is subject to division 9 of the Commercial Code, as in the case of any other secured transaction. Under the provisions of the Uniform Commercial Code the debtor is entitled to a setoff for the value of equipment repossessed. (Cal. U. Com. Code, §§ 9102, subd. (1)(a), 9107, 9207, 9504, subd. (2), 9504, subd. (3).) In short, the secured creditor must account to the debtor for the proceeds.
To hold that the note became "unsecured" when the creditor terminated the equipment lease is to render meaningless the action of the parties in giving the equipment lease as security for the note. Such a contract, if not nonsensical, must contemplate that the right to the equipment accrues upon default of the lease or of the note. The physical equipment provides security for both lease and note, and such an arrangement presents the quintessence of a secured transaction.


*562 II
Even if the specific provisions of the Commercial Code were not in effect, under general mercantile law the creditor in an integrated secured transaction may not recover both the collateral and the unpaid balance of his debt. In an action on a promissory note, the court's function is to award judgment for the balance owed. To ascertain what is owed, it is necessary to inquire what has been paid. What has been paid consists not only of cash payments made by the debtor before default, but also items of value which have moved from the debtor to the creditor as a direct result of default on the debt. Prior California law governing such secured transactions as trust receipts, conditional sales, and pledges restricted the creditor's right of repossession in order to prevent his unjust enrichment at the debtor's expense. (See, e.g., former Civ. Code, §§ 3008, 3016.2; and general discussion in McCall, The Past as Prologue: A History of the Right to Repossess (1973) 47 So.Cal.L.Rev. 58, 78-79.) The principle of equitable setoff clearly applies to the case at bench to prevent the creditor from recovering more than he is owed. (For discussion of various procedural problems in asserting rights of setoff, recoupment and counterclaim; see, e.g., Hauger v. Gates (1954) 42 Cal.2d 752, 755 [269 P.2d 609]; Harrison v. Adams (1942) 20 Cal.2d 646, 648-649 [128 P.2d 9]; St. Louis National Bank v. Gay (1894) 101 Cal. 286, 288-290 [35 P. 876]; 3 Witkin, Cal. Procedure (2d ed. 1971) § 976, at pp. 2552-2553.) In brief, not only the Commercial Code but also the established principles of mercantile law that supplement the Commercial Code support defendants' position. (Cal. U. Com. Code, § 1103.)

III
(4) Thus far we have not discussed the significance of the default of the sublease and the creditor's repossession of the real property carried out simultaneously with repossession of the business and the equipment. Under Civil Code section 3046 the seller of real property has a vendor's lien thereon.[4] We see no reason why this section cannot apply to the sale of a lease or sublease, where the interest in real property had been sold for a premium that exceeds the rent payable under the lease or sublease  i.e., where the value of the leasehold commands a premium in the market. (2c) If such was the case here, then the creditor's note was also secured by the premium value of the sublease, whose value on *563 repossession should be accounted for to the debtor, together with the value of other property repossessed, and the total credited against any judgment for the unpaid balance of the debt. The premises sublease, like the equipment lease and like the promissory note, was part of an integrated package which comprised the sale of the carwash business and became part of the security for the purchase price. This interconnection was specified in the sublease itself, which provided that default in either sublease or equipment lease could be considered as a default on both instruments. Accordingly, when the creditor repossessed all three components of the enterprise (premises, equipment, and ongoing business) the debtor became entitled to receive credit against the unpaid balance of the promissory note for the value of each of the three components repossessed, which together constituted the security for the debt. Grossman himself testified that before his declarations of default and his repossession, the leasehold, the equipment, and the building, each had value. Normally, the amount of credit for such value would be determined by a contemporaneous sale, after due notice of the business, equipment, and leasehold premises to the highest bidder. Absent the possibilities of such a sale, reliance must be placed on expert testimony.
Under the view of the case we have taken, the cost of necessary repairs is not chargeable to defendants but is relevant only to determine the value of the repossessed property at the time of repossession. Here again, the creditor cannot have both the full sales price and the repossessed property rehabilitated at the debtor's expense.
The judgment is reversed, and the cause is remanded to the trial court with directions to determine the value of the repossessed business, equipment, and sublease at the time of repossession, to credit that value against the amount owing on the promissory note, and enter a new and different judgment for the deficiency, if any, on the note.
Compton, J., and Beach, J., concurred.
A petition for a rehearing was denied June 30, 1978.
NOTES
[1]  Husband and wife litigants are collectively referred to in the singular. Money amounts are rounded.
[2]  The initial escrow instructions specified a $450,000 sales price, which included the sale of the carwash equipment. However, Tarlov and Weber would not consent to a sale of the equipment, and, accordingly, the transaction was revised into its present form.
[3]  The judgment against Pratt has not been appealed.
[4]  Section 3046: "One who sells real property has a vendor's lien thereon, independent of possession, for so much of the price as remains unpaid and unsecured otherwise than by the personal obligation of the buyer."
