Aunty Val is right as always.
This is what our regular legal contributor Raymundo had to say:
The AEAT is unconcerned on whether there has been a loss or not. It works following its own rateable values for properties which, only in my opinion, may in some cases be detached from the market’s reality.
By the same token they charge a buyer a ‘complementaria’ when they deem the buying price is too low (explained in detail in my article on buying property in Spain) likewise they will also charge a seller what they think he should be paying according to their own values; regardless whether this is true or not.
Which is why in many cases Hacienda withholds in full the 3% practiced as a retention (and will not refund it) to a buyer on account of the seller’s CGT liability. This helps to offset any potential ‘shortfall’ on the seller’s CGT as non-residents are prone to leave the country shortly after a sale is concluded.