All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad, sallallaahu 'alayhi wa sallam, is His slave and Messenger.
There is a difference of opinion among scholars as to whether debts should be deducted from wealth subject to Zakah. Some scholars view that it should always be deducted, while others hold that it is never to be deducted. The opinion we choose and adhere to aligns with that of the Maliki school. According to this opinion, if you possess an asset exempt from Zakah (and is in surplus of your need) then you should allocate it against your debt, then the debt should not be deducted from the Zakah-liable wealth. Conversely, if no such asset exists to cover the debt, the amount owed should be deducted from the Zakah-liable wealth.
Concerning the valuation of goods, a merchant should calculate Zakah based on the selling price of the goods at the time Zakah is due. If the value fluctuates, the lowest valuation should be considered, as the principle is that he is clear of liability to pay more. If there is a variation in value between wholesale and retail, then Zakah should be calculated based on the method of sale.
Allah knows best.