I'm not sure I want to track item quality. Most pen&paper roleplaying games do not. I'm also not sure if the trade-in item should appear in your inventory or not. Maybe just discard it for half value as a simulation for selling it to one of those 2nd hand item shops that no respectable trader wants to have anything to do with...