Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 1 min read

How to calculate zakat on gold and silver: the nisab formula with a JavaScript example

Zakat is 2.5% of eligible wealth that stays above the nisab for one lunar year. The nisab is the minimum threshold, and it is tied to either gold or silver, so the first step is always picking a reference and getting a c

Zakat is 2.5% of eligible wealth that stays above the nisab for one lunar year. The nisab is the minimum threshold, and it is tied to either gold or silver, so the first step is always picking a reference and getting a current price.

The nisab values

  • Gold nisab: 87.48 grams (about 3 troy ounces)
  • Silver nisab: 612.36 grams (about 21 troy ounces)

Silver gives a much lower threshold, so many scholars and calculators let you choose. Use whichever your local scholar recommends.

The formula

  1. Add up zakatable assets: cash, savings, gold and silver, business stock, money owed to you.
  2. Subtract short-term debts you must pay now.
  3. Compare the total with the nisab (nisab grams x price per gram).
  4. If it is at or above the nisab, you owe 2.5% of the total.

A small JavaScript example

function zakat({ cash, goldGrams, goldPricePerGram, silverGrams, silverPricePerGram, debts, nisabGrams, nisabPricePerGram }) {
  const assets = cash + goldGrams * goldPricePerGram + silverGrams * silverPricePerGram;
  const net = assets - debts;
  const nisab = nisabGrams * nisabPricePerGram;
  return net >= nisab ? net * 0.025 : 0;
}

// gold nisab: 87.48 g, price per gram is an example value
console.log(zakat({
  cash: 5000, goldGrams: 50, goldPricePerGram: 85,
  silverGrams: 0, silverPricePerGram: 1,
  debts: 500, nisabGrams: 87.48, nisabPricePerGram: 85
}));

The gold price must be live, otherwise the result is wrong. Currency also matters, because the nisab is a different number in each currency.

Notes

  • Personal-use jewellery is treated differently by different schools of thought, so check with a scholar.
  • Wealth must be held for a full lunar year (hawl) before zakat is due.
  • This is a calculation aid, not a fatwa.

If you just want the result without writing code, I built a free tool with live nisab and auto currency: zakatcalculator.live.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.