"When XYZ pays for the repair, it is done by credit memo. Then, I must balance the books by applying it to the repair invoice and the bill for the parts ordered and purchased through XYZ company. thus my vender is also a customer. How do I do that?"
Is there a reason you need to use a credit memo? What about using a bank Clearing Account from the solved solution? Does that not work in your case? That way, you don't have to worry about projects/customer/sub-customers/vendors - you just pay the vendor bills with the Clearing Account and receive payment into the Clearing Account on the customer invoice. That applies the amount you owe XYZ (A/P) to reduce the amount due on the customer's invoice (A/R).