One of the most important elements when applying for a mortgage in Spain is INCOME and DEBT. The relation between these two is important, as it gives the bank information on how much you are able to pay per month towards a mortgage.
The bank will only allow your total debt to represent a certain percentage of your income (typically they will base their calculation on your net income).
The percentage will vary on a case by case basis, but for residents the banks will usually accept a debt ratio of 30-35% (up to 40% in special cases). For non-residents, the accepted debt ratio is set to 25-35%, depending on the loan to value.