Diclaimer: Not a tax expert, but have a decent understanding.
Tl;dr Your visa does not determine your tax situation. They are connected but not in the simplistic way of if you have this visa, you pay tax here.
Tax rules are like Magic The Gathering rules. There are base rules and then countries have their own overriding rules and then some countries have synergies aka DTAA (Double Taxation avoidance agreement)
Base rules.
1. You owe tax where you are a resident. Most countries like Spain define this as a stay of 183 days in a year. So if you stay below that, you do not owe any taxes.
2. You owe tax where your income is sourced. This is not straight forward as it depends on the kind of income. For salaried employee, your tax will be deducted by the country where your company is based in. For contracts, there will be no deduction in the country of the client. For other incomes like interest or dividends, they get taxed in the source country. After this tax deducted, you might still owe tax in the source country and your current resident country depending on your income as a whole.
3. If you do not qualify as a resident anywhere, you owe taxes to your home country.
But there are additional considerations. Some examples.
1. Some countries like US, as a citizen you owe tax on global income irrespective of where you live.
2. Some countries have multiple residency requirements. Like in India, if you spend more than 60 days in the current year plus have spent 365 days in the past 4 years, you are a tax resident.
Synergies or the lack of these.
1. Many countries have a DTAA agreement with other countries. So you do not get taxed twice. But be careful to check if it is the case for your pair of countries.
2. Some countries have different tax years. In India, financial year starts in April and goes to March, while Spain and US, it runs from Jan to December. So it creates a pain for income earned during Jan to March. ๐
To summarise, even if you are on a DNV, if you limit your stay to below 183 days than you might not owe any taxes to Spain and just your home country. If not, then you might owe only taxes to your home country. Hope this helps.
Another disclaimer: This is not an exhaustive explanation but just a glimpse into the world of international taxes. I am still learning and if any of this is incorrect, please feel free to rectify.