He assumed
Ah, there's your problem, in two words.
You're far from being alone. There are a lot of people out there who believe - incorrectly - that just because they're paying for someone's time, they automatically own the rights to any creative work that's produced during that time.
It can be very hard to make it clear to a customer that this isn't the case, and even if you get a lawyer involved (which isn't a bad idea at all), there's no guarantee that your contract will be interpreted the same way by your customer as you intended.
My standard T&C's do actually grant customers access to source materials, and include a fairly broad licence to make use of them. I figure that if I do a good job, they'll come back to me anyway, but they'll also have the peace of mind of knowing that if I get run over by a bus, they already have everything they need to take a job elsewhere.
That's a purely commercial decision which I made early on, having seen what happens when a company is refused access to source materials, and is held hostage to the original supplier. It's a crappy trick that some suppliers pull, which only ever works on a given customer once.
Providing source code is not the same thing as granting outright ownership of the IP, though. If a customer wants full ownership of a design, then I first make it clear that if I'm going to lose ownership of the finished project, then I'll have to start from a completely blank sheet, and so their job will cost more purely in terms of the number of hours required.
Any royalties over and above that are up for negotiation. A good starting point is to look at the relative value of your contribution as a proportion of the finished product. If the finished item is a PCB you've designed, using software you've written, then a 50/50 split of the profits might not be at all unreasonable. If it's a small part of a bigger system, adjust accordingly.