Yes, you are paid the difference for the upgrades, hence the minus figure for some purchases.
Slightly OT, I would love to be able to buy ships with certain upgrades already installed. E.g., if I sold my tooled up Cobra, then someone could purchase it. Even better, if I have a ship in a hanger somewhere, I could put it on the market and make cash that way.