
336 S.E.2d 694 (1985)
TRUSTEES OF the GARDEN OF PRAYER BAPTIST CHURCH
v.
GERALDCO BUILDERS, INC., Ruby Byers and her husband, James A. Byers, William Thomas and his wife, Janet G. Thomas, Waddell Pearson and Greensboro National Bank.
No. 8518SC402.
Court of Appeals of North Carolina.
December 3, 1985.
*695 Smith, Patterson, Follin, Curtis, James & Harkavy by Norman B. Smith, Greensboro, for plaintiff-appellees.
Hunter, Hodgman, Greene & Donaldson by Richard M. Greene, Greensboro, for defendant-appellants.
MARTIN, Judge.
This action is the third in a series of lawsuits arising out of a contract between plaintiffs and defendant Geraldco for the construction of an addition to the Trustees' church. The contract price, including subsequent modifications, was $96,541.06. The Trustees had arranged permanent financing for the project, but were unable to arrange for a construction loan because Geraldco had no performance bond. Geraldco applied to GNB for a construction loan in the amount of $40,000.00. As an inducement for GNB to make the loan, the Trustees and the permanent lender agreed to disburse directly to GNB, at the time of closing the permanent loan upon completion of construction, funds sufficient to pay any outstanding balance due GNB in its loan to Geraldco. GNB made the $40,000 loan to Geraldco. The loan was secured by a deed of trust on Geraldco's property and, additionally, by guaranty agreements signed by the individual defendants.
After the addition was completed, in early September 1983, the Trustees refused to pay Geraldco the full amount of the contract *696 price, claiming that Geraldco had materially breached the contract. On 24 October 1983 the Trustees filed a complaint (83CvD7533) seeking a declaratory judgment to determine "what amount of indebtedness [Trustees] have to [Geraldco], and what provisions are to be required to protect [Trustees] from lien claims of [Geraldco's] creditors...." Judgment was entered in that action on 9 December 1983. The trial court found and concluded that Geraldco had materially breached the contract and that due to the breach, the amount due from the Trustees to Geraldco was only $70,906.06. The court also found that the Trustees had agreed to disburse to GNB from the proceeds of the permanent loan on the building, $40,000.00 to repay Geraldco's construction loan. In addition, the court found that six of Geraldco's suppliers or subcontractors were unpaid and had filed liens totalling $27,278.12. The court entered judgment as follows:
1. Plaintiffs are justly indebted to defendant in the amount of $70,906.06.
2. From the foregoing amount, plaintiffs are entitled to disburse directly to Greensboro National Bank the sum of $40,000, and directly to all lien claimants of record the respective amounts due by virtue of their liens on the construction project in question.
There was no appeal from the judgment, which was entered prior to the expiration of the period within which Geraldco's suppliers and subcontractors could file labor and material liens pursuant to G.S. 44A-12(b).
On 6 December 1983 (three days before the judgment was entered in 83CvD7533), GNB filed an action (83CvS8501) against Geraldco and Ruby Byers, James A. Byers, William Thomas, Janet G. Thomas and Waddell Pearson, alleging, inter alia, that Geraldco had failed to pay the indebtedness evidenced by the $40,000.00 note when it became due on 30 August 1983, and that the individual defendants, who were guarantors, had likewise refused to pay after demand had been made on them. The Trustees moved to be permitted to intervene pursuant to G.S. 1A-1, Rule 24, and filed a notice of lis pendens with respect to the property of Geraldco which was subject to the deed of trust securing Geraldco's note to GNB. The Trustees' motion to intervene was denied and the notice of lis pendens was cancelled. On 29 March 1984, judgment was entered in favor of GNB against Geraldco and the individual defendants in the amount of $45,295.34.
On the same day, the Trustees filed this action against Geraldco, the individual defendants and GNB. The Trustees alleged that pursuant to the judgment in the first lawsuit 83CvD7533, it was determined that they owed Geraldco $70,906.06; that in order to discharge all liens filed by creditors of Geraldco the Trustees were required to pay $41,192.88; and that by reason of the defendants' failure to satisfy Geraldco's note to GNB, the Trustees were required to pay GNB the sum of $43,990.84. They alleged that the total amount of payments made by them on behalf of Geraldco and the individual defendants exceeded the amount which they owed Geraldco by $14,277.66. Therefore, the Trustees alleged, they are entitled to be subrogated to all rights of GNB against Geraldco and the individual defendants to the extent of the overpayment. The Trustees prayed for judgment against Geraldco and the individual defendants, jointly and severally, in the amount of $14,277.66 and for the right to foreclose on the deed of trust securing Geraldco's note to GNB. The Trustees also filed notice of lis pendens asserting an interest in the property described in the deed of trust.
Defendants answered, alleging that the declaratory judgment action (83CvD7533) was res judicata as to all claims which the Trustees had against Geraldco. They also filed a motion to cancel the notice of lis pendens, which was allowed.
Both sides moved for summary judgment. At the hearing on the motions for summary judgment, the parties stipulated that Geraldco's subcontractors and material suppliers were paid $36,935.02 out of the proceeds of the Trustees' permanent loan *697 for work done and materials provided on the construction project. The Trustees also presented evidence that they had paid $44,236.26 to GNB in payment of principal and accrued interest, but exclusive of attorneys' fees and court costs, due on Geraldco's note. The trial court entered summary judgment for the Trustees against Geraldco and the individual defendants, jointly and severally, in the amount of $14,277.66. The judgment did not address the Trustees' claim for foreclosure on the deed of trust held by GNB.
Defendants initially argue that the Trustees' claim in this action is barred by the doctrine of res judicata. A final adjudication of an action, on its merits, by a court of competent jurisdiction is conclusive, as to the parties, of the issues raised therein and the doctrine of res judicata bars subsequent actions involving the same issues and parties and those in privity with them. Kabatnik v. Westminster Co., 63 N.C.App. 708, 306 S.E.2d 513 (1983). Strict identity of issues is not required; the doctrine of res judicata also applies to issues which could have been, but were not, raised in the prior action. Id. However, where subsequent to the rendition of judgment in the prior action, new facts have occurred which may alter the legal rights of the parties, the former judgment will not operate as a bar to the later action. Flynt v. Flynt, 237 N.C. 754, 75 S.E.2d 901 (1953); Dawson v. Wood, 177 N.C. 158, 98 S.E. 459 (1919).
Applying these principles to the case before us, we hold that the present action is not barred by the declaratory judgment in 83CvD7533. It is true that both actions arose out of the relationship created by the construction contract between the Trustees and Geraldco. The issues before the court in the prior action were (1) whether Geraldco had constructed the building in conformity with the plans and specifications, (2) what amount was owed by the Trustees to Geraldco for the construction and (3) what provision was to be made by the Trustees to protect themselves from liens filed by Geraldco's sub-contractors. The court determined that Geraldco had breached the contract and, in consequence thereof, the Trustees were not obligated to pay the full contract price. As to the final issue, the court determined that liens had been filed and that the Trustees had also obligated themselves to pay GNB any outstanding indebtedness owed GNB by Geraldco by reason of the $40,000 construction loan. Based upon the evidence before the court, the total amount due the lien claimants as of the date of the declaratory judgment, together with the principal amount of GNB's loan to Geraldco, was less than the amount due from the Trustees to Geraldco. The court authorized the Trustees to pay GNB and the lien claimants directly.
In the present action, the Trustees allege that subsequent to the entry of the earlier judgment, but before the expiration of the time within which Geraldco's subcontractors could file liens, additional liens were filed. As a result, they allege that they were obligated to pay, in satisfaction of the claims of lien creditors and GNB, an amount in excess of that owed by them to Geraldco. The issue before the court in the second action, therefore, is whether the Trustees are entitled to the equitable remedy of subrogation to the extent that they were legally obligated to pay, on behalf of defendants, amounts in excess of that which the court in the earlier action had determined to be due Geraldco. The answer to the issue depends, in part, on facts unknown to the Trustees and the court at the time of the prior judgment. Since the issue and the facts upon which it arises were not before the court in the earlier action, the declaratory judgment in that action does not bar the present action.
Having determined that the present action is not barred by res judicata, we must next consider whether, in the absence of an assignment of rights by GNB, the plaintiffs are entitled to reimbursement from defendants on the basis of legal subrogation. Legal subrogation, also referred to as equitable subrogation, is an equitable remedy which arises when one person has *698 been compelled to pay a debt which ought to have been paid by another and for which the other was primarily liable. Beam v. Wright, 224 N.C. 677, 32 S.E.2d 213 (1944). Its purpose is "to compel the ultimate discharge of an obligation by him who in good conscience ought to pay it." Id. at 683, 32 S.E.2d at 218. Where the equitable right to subrogation arises, the party in whose favor it exists is entitled to all of the remedies and security which the creditor had against the person whose debt was paid. 73 Am.Jur.2d Subrogation § 3, at 600 (1974). The remedy is highly favored and liberally applied; it may be invoked whenever the party claiming the benefit of subrogation pays the obligation of another for the purpose of protecting some real or supposed interest of his own. Boney, Insurance Commissioner v. Insurance Co., 213 N.C. 563, 197 S.E. 122 (1938). However, the doctrine of subrogation will not be applied in favor of a volunteer, who, being under no legal or moral obligation and having no right or interest of his own to protect, discharges the debt of another. Id.
Defendants contend that the Trustees are not entitled to the benefit of subrogation because they had no obligation to pay GNB and the lien claimants any more than the contract price due Geraldco as determined by the declaratory judgment. They argue that since the funds remaining in the hands of the Trustees, after payment of Geraldco's note to GNB, were insufficient to pay all of the lien claimants, then the lien claimants were entitled only to share the remaining funds on a pro-rata basis. According to defendants, any payments by the Trustees in excess of the balance due Geraldco were purely voluntary. We disagree.
Defendants' argument is flawed in that it incorrectly assumes that the lien claimants were entitled to payment only from those funds remaining in the hands of the Trustees after payment of the GNB note. Chapter 44A, Article 2, Part 2 of the North Carolina General Statutes provides for liens of laborers and materialmen dealing with a contractor who contracts with an owner to improve real property. Upon compliance with the notice provisions of the statutes, subcontractors are entitled to a lien upon funds owed to the contractor by the owner, G.S. 44A-18(1), up to the total amount of the lien claims for which notice is given. G.S. 44A-20(a). In the event the funds owed by the owner to the contractor are insufficient to satisfy the full amount of the valid lien claims, the lien claimants are entitled to share the funds on a pro rata basis. G.S. 44A-21. However, labor and material liens which have been properly perfected have priority over all other claims created in the funds by the person against whose interest the lien is asserted. G.S. 44A-22. Thus, the Trustees were obligated to discharge the lien claimants from the funds held by them and owed to Geraldco before paying Geraldco's note to GNB. Since the amount due from the Trustees to Geraldco was more than the aggregate amount of lien claims, each of the claimants was entitled to full payment. Thus, the Trustees, being legally obligated to pay the lien claimants in full, were not acting as mere volunteers in satisfying Geraldco's obligations to its subcontractors.
Neither can the Trustees be held to have been acting as volunteers in paying Geraldco's obligation to GNB. The Trustees' payment to GNB was made as a result of their promise to permit disbursement, from the proceeds of their permanent loan, of an amount sufficient to "pay all of the outstanding indebtedness which [Geraldco] owes [GNB] arising out of the said $40,000 construction loan." A payment made on behalf of another, under either a legal or moral obligation to pay, is not a voluntary payment so as to defeat one's claim to equitable subrogation. Boney, Insurance Commissioner v. Insurance Co., supra.
To the extent that the Trustees paid GNB with funds which the Trustees owed Geraldco as a part of their primary obligation to pay for the construction, clearly the Trustees are not entitled to be subrogated to the rights of GNB. Payments *699 made with the debtor's money are considered payments by the debtor. 60 Am. Jur.2d Payment § 70, at 659 (1974). However, to the extent that the Trustees paid GNB an amount in excess of that which they owed Geraldco, the Trustees paid a debt for which Geraldco, as maker of the note, and the individual defendants, as guarantors, were liable. The Trustees, therefore, are entitled to reimbursement from Geraldco and to be subrogated to GNB's rights against Geraldco and the individual defendants, as guarantors on Geraldco's note, for any amount which the Trustees paid GNB which was in excess of the contract balance due from the Trustees to Geraldco after satisfaction of the valid lien claims.
The parties stipulated that the Trustees paid $36,935.02 to lien claimants, however the record before us discloses no evidence, nor any stipulation, that all of these claimants gave timely notice of their claims of lien so that the Trustees were legally obligated to pay them. We are therefore unable to determine the amount by which the Trustees' payment to GNB exceeded the balance of the contract price due Geraldco from the Trustees, after satisfaction of valid lien claims. Moreover, the trial court entered judgment for the Trustees in the amount of $14,277.66, while the evidence in the record before us discloses that the total funds paid by the Trustees on behalf of Geraldco exceeded the amount due on the contract by only $10,265.22. Accordingly, although we conclude that the Trustees were entitled to summary judgment establishing their right to recover of the defendants by way of subrogation, we must vacate that portion of the judgment setting the amount due and remand this case to the Superior Court of Guilford County for further proceedings to determine the amount which the Trustees are entitled to recover of defendants.
By cross-assignment of error, the Trustees contend that the trial court erred in cancelling the notice of lis pendens, filed simultaneously with their complaint in the action. They argue that since they were subrogated to GNB's rights to security under the deed of trust securing Geraldco's note and requested the right to foreclose thereon, they were entitled, pursuant to G.S. 1-116, to protect their interest in the property subject to the deed of trust by filing a notice of lis pendens. We find, however, that the complaint was insufficient to support the Trustees' claim to a right of foreclosure because the trustee in the deed of trust was not made a party to the action. In addition, the Trustees submitted to a voluntary dismissal with prejudice as to GNB, the holder of the note secured by the deed of trust. It is well established that a mortgagee or trustee in a deed of trust is a necessary party to an action for foreclosure. Underwood v. Otwell, 269 N.C. 571, 153 S.E.2d 40 (1967). Plaintiffs' cross-assignment of error is overruled.
Affirmed in part; vacated in part, and
Remanded.
HEDRICK, C.J., and EAGLES, J., concur.
