Basically if you have accumulated money (savings), and you also have debt, and you don't use your savings to pay off your debt, resulting in you having that accumulated money for a complete lunar year which is more than nisab, you pay zakaat.
If you use the accumulated money to pay off the debt before zakaat is due, you only pay zakat on what you have left, so if what you have left is less than nisab, you don't pay zakat.
So if you have had that 400 for 1 complete lunar year, you pay 10 for zakat. If you have a total of 400 now, but only 300 of that has been in your possession for a complete lunar year, you pay 7.5.
Praise be to Allaah.
The one who has any “zakatable” wealth must pay zakaah on it, when one
year has passed since he acquired it, even if he has debts, according
to the more correct of the two scholarly opinions, because of the
general meaning of the evidence that zakaah is obligatory upon
everyone who has wealth on which zakaah is due, if one year has passed
since he acquired it, even if he has debts.
The Prophet (peace and blessings of Allaah be upon him) used to
command his agents to take zakaah from those who owed zakaah, and he
did not tell them to ask them whether they had any debts or not. If
having debts meant that one did not have to pay zakaah, the Prophet
(peace and blessings of Allaah be upon him) would have told his agents
to ask the people who were paying zakaah whether they had any debts or
not.
Majmoo’ Fataawa wa Maqalaat Mutanawwi’ah by Shaykh ‘Abd al-‘Azeez ibn
Baaz, 14/51
“… But if you pay off the debt with cash in hand before one year has
passed, there is no zakaah on what you have spent to pay off the debt;
rather zakaah is due on whatever is left, if one year has passed and
it reaches the minimum threshold (nisaab).”
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) was asked about a
person who has capital worth two hundred thousand riyals and owed a
debt of two hundred thousand riyals, and was paying it off at a rate
of ten thousand per year – does he have to pay zakaah?
He replied:
Yes, he has to pay zakaah on the wealth that is in his possession,
because the texts which speak of the obligation of zakaah are general
in meaning, and do not make any exceptions. No exception is made for
one who is in debt. As the texts are general in meaning, we have to
follow them.
Moreover, zakaah must be paid on wealth, because Allaah says
(interpretation of the meaning):
“Take Sadaqah (alms) from their wealth in order to purify them and
sanctify them with it, and invoke Allaah for them. Verily, your
invocations are a source of security for them; and Allaah is
All-Hearer, All-Knower”
[al-Tawbah 9:103]
And according to the hadeeth narrated by al-Bukhaari from Ibn ‘Abbaas
(may Allaah be pleased with him), when the Prophet (peace and
blessings of Allaah be upon him) sent Mu’aadh to Yemen he said: “Tell
them that Allaah has enjoined zakaah from their wealth.” So Allaah and
His Messenger have stated that zakaah has to do with the wealth
itself, not with the person’s obligations towards others; debt has to
do with personal obligations towards others. They are two separate
issues, so zakaah must be paid from the wealth that is in your
possession, and the debt is a personal responsibility.
Each person must fear his Lord and pay zakaah on the wealth that is in
his possession, and seek the help of Allaah to pay the debt that he
owes, saying: O Allaah, pay off the debt that I owe and make me
independent of means.
Perhaps if he pays zakaah on the wealth that is in his possession,
that may be a means of bringing blessing to this wealth and causing it
to grow, so that he may discharge his duty of paying his debts. If he
withholds zakaah, however, that may be a cause of his becoming poor,
so that he always sees himself as being in need and not able to pay
zakaah. Praise Allaah if He makes you one of the givers and not one of
the takers.
Majmoo’ Fataawa al-Shaykh Ibn ‘Uthaymeen, 18/39
And he said, in another Fatwa on the same issue (18/38):
If the debt is currently due and repayment is being demanded, and he
wants to pay it off, in that case we say: Pay off the debt, then pay
zakaah on what is left after that if it reaches the minimum threshold
at which zakaah becomes due.
That is supported by what the Hanbali fuqaha’ said about zakaat
al-fitr. They said that being in debt does not mean that one should
not pay it.
Similarly, it is reported that ‘Uthmaan (may Allaah be pleased with
him) used to say during the month of Ramadaan: “This is the month of
your zakaah, but whoever is in debt, let him pay it off.” This
indicates that if a debt is currently due to be paid, and the debtor
wants to pay it off, that should take precedence over zakaah. But if a
debt is not yet due to be paid off, the zakaah must still be paid,
beyond a doubt.
And it says in Fataawa al-Lajnah al-Daa’imah, 9/189:
The correct scholarly view is that being in debt does not mean that
zakaah should not be paid. The Prophet (peace and blessings of Allaah
be upon him) used to send his agents to collect the zakaah, and he did
not tell them to see if the people were in debt or not.