Hi Phlaaps…
You have to register as autonomo, pay the Eu350pcm Social Security REGARDLESS OF YOUR INCOME/amount you earn.. and pay any tax due at end of tax year (Declaracion de la renta usually submitted in May of following year)...
You can go ‘Baja’ (de-register) for months when you are not working, so likewise, you will not pay any social security payments for these months.
However, be sure you can prove you have a min of Eu5,000 income in a year and private medical cover for months when not on state system.
See the new rules regarding ex pat (eu) residency requirements in Spain!