Where do I pay tax under NHR 2022

I will apply for NHR from 7 th July ( bought appartment in Lisboa and got atestado ( residence declaration on that date)
I paid tax in China up to 30th June ( left China 1st July)
I holiday and work online in Portugal until 31st August and retire on 1st September ( salary and retirement pension paid from home company in Spain)
China tax office say no tax payment possible there as I am not resident after 1st July
I am also non resident in Spain and hope therefore to pay all remaining 2022 tax in Portugal at lower rate ? Any comments or warnings appreciated

If you are truly non resident in Spain then you need to check if you are resident in Portugal

If not resident in any country you are world non resident and pay no tax

However you then need to check your country of domicile recognizes this. Some allow it. Others have a catch all that if you are not resident in another country you become resident in your country of domicile

Sorry but you need to check each possible country

Many thanks , I applied this week online for NHR in Portugal as seems best fiscal option as I have personal NIF address there