In will wholeheartedly agree that regardless of when the asset is sold, receipt or inital purchase cannot and should not ever be a consideration.
That said, whatever you received in shares must have had value, so wouldn't it be earned income and not unrealized capital gains? Or does that work differently in Spain?