I'm fairly certain the easiest coding of value would be to take the current mech condition when you traded it in, so if it was missing an arm, low on ammor etc at that time then the price would be reduced accordingly.
So if you sold it damaged, or repaired it then sold it, you would get the same value. I don't see this working any other way.