Calculation Methodology
Rafiq's calculation engine covers 500+ rules across 5 madhabs. Every number comes with the specific ruling applied, the threshold used, and scholarly citations. This page documents the exact constants, formulas, and decision logic we use.
94% accuracy on held-out test set
Validated against 150+ real-world edge cases including RSU vesting schedules, crypto staking yields, mixed halal/haram portfolios, and per-category Ja'fari nisab calculations.
1. Zakat Calculation
Core Constants
Ja'fari nisab weights sourced from: al-Sistani, Tawdih al-Masa'il, Mas'alah 1863.
Asset Categories
Rafiq supports 10 asset categories for zakat calculation:
- Cash & bank accounts — full value zakatable
- Gold — valued at live spot price per gram
- Silver — valued at live spot price per gram
- Investments (stocks, ETFs, mutual funds) — 1/3 zakatable ratio applied
- Business inventory — full value zakatable
- Cryptocurrency — full market value zakatable
- Livestock — USD value zakatable
- Agricultural produce — USD value zakatable
- Personal jewelry — madhab-dependent (see below)
- Retirement accounts (401k, IRA, Roth) — madhab-dependent, 1/3 ratio when applicable
Madhab-Specific Rules
| Rule | Hanafi | Shafi'i | Maliki | Hanbali | Ja'fari |
|---|---|---|---|---|---|
| Nisab Standard | Silver (enforced) | Gold (default, user choice) | Gold | Gold or silver (user choice) | Gold (enforced) |
| Debt Deduction | Yes + living expenses | No (gross assets) | Yes (debts only) | Yes (debts only) | Yes (debts only) |
| Jewelry | Always included | Opt-in | Never included | Opt-in | Excluded |
| Retirement | ON by default (FCNA) | Opt-in | Not zakatable | Opt-in | Under Khums |
| Cash Zakatable | Yes | Yes | Yes | Yes | No (under Khums) |
| Nisab Check | Combined total | Combined total | Combined total | Combined total | Per-category |
Ja'fari Per-Category Nisab
In the Ja'fari school, gold and silver are checked independently against their own nisab thresholds. Unlike Sunni schools where all assets are combined, each Ja'fari category must independently meet its threshold before zakat is due on that category. Deductions are distributed proportionally across categories based on their relative values.
Formula
For Sunni schools:
Zakat Due = (Total Zakatable Assets − Applicable Deductions) × 2.5%
(only if net amount ≥ nisab threshold)
For Ja'fari:
Gold Zakat = Gold Value × 2.5% (if gold value ≥ 69.12g × gold price)
Silver Zakat = Silver Value × 2.5% (if silver value ≥ 483.84g × silver price)
2. Khums Calculation
Income Sources (Taxable)
- New savings accumulated this khums year
- Cash on hand
- Investment gains
- Business profits
- Rental income
- Gifts received (remaining unused at year-end)
Exempt: Expected inheritance from close relatives.
Property Subject to Khums
- Gold and silver purchased
- Jewelry beyond personal use
- Unused goods and surplus items
Deductions
- Annual living expenses
- Debt payments (for living necessities)
- Business reinvestment
Advanced Categories
These are taxed independently at 20%, regardless of surplus/deductions:
- Kanz — Buried treasure or hidden wealth
- Ma'dan — Minerals extracted from the earth
- Ghaws — Valuables retrieved from the sea
- Property Appreciation — Gains on investment property (excludes primary residence)
- Mixed Halal/Haram — Wealth with inseparable halal/haram portions (owner unknown)
Formula
Net Surplus = (Total Income + Total Property) − Total Deductions
Standard Khums = Net Surplus × 20%
Advanced Khums = Sum of (each advanced category × 20%)
Total Khums = Standard + Advanced
Sahm al-Imam = Total Khums × 50%
Sahm al-Sadat = Total Khums × 50%
3. Halal Stock Screening (AAOIFI)
Rafiq screens stocks against AAOIFI (Accounting and Auditing Organization for Islamic Financial Institutions) Shariah standards for equity investment.
Screening Criteria
| Criterion | Threshold | What It Measures |
|---|---|---|
| Debt Ratio | < 33% of market cap | Total interest-bearing debt relative to company valuation |
| Interest Income | < 5% of revenue | Revenue from interest-bearing instruments |
| Cash & Securities | < 33% of market cap | Cash and interest-bearing securities held |
| Business Activity | Pass / Fail | Primary business must not be in a prohibited industry |
Status Classifications
- HALAL — Passes all 4 criteria
- NOT HALAL — Fails one or more criteria, or is in a prohibited industry
- QUESTIONABLE — Borderline on one or more ratios; scholars may differ
Data Sources
- Pre-screened index: 2,127 stocks from the Dow Jones Islamic Market (DJIM) and S&P 500 Shariah indices
- Live screening: Financial Modeling Prep (FMP) API for real-time financial ratios
- Curated detail set: 45 stocks with manually verified AAOIFI ratios and compliance status
4. Tatheer (Dividend Purification)
Formula
Purification Amount = Dividend Income × Non-Compliant Revenue Ratio
The non-compliant ratio is derived from the company's income statement: interest income and interest expense as a percentage of total revenue. This ratio represents the portion of company earnings from impermissible sources.
Haram Stock Detection
Stocks in inherently prohibited industries (conventional banking, alcohol, tobacco, gambling, conventional insurance) are flagged as haram. For these stocks, 100% of dividends should be donated to charity, plus any unrealized capital gains.
Data Flow
- User enters stock ticker and number of shares
- Rafiq resolves ticker via 3-layer lookup: client Shariah index → DJIM stocks → FMP API search
- FMP API provides: company profile, dividend history, income statement
- Non-compliant ratio calculated from income statement interest fields
- Purification amount = dividends × non-compliant ratio
5. Validation & Accuracy
Rafiq's calculation engine is validated through automated testing covering:
- Per-madhab nisab enforcement (Sunni vs Ja'fari thresholds)
- Ja'fari per-category nisab independence
- Madhab-specific deduction rules (Shafi'i gross vs Hanafi net)
- Jewelry inclusion/exclusion per madhab
- Retirement account treatment per madhab
- Stock zakatable ratio (1/3) application
- Khums surplus and advanced category calculations
- Edge cases: RSU vesting, crypto staking, mixed portfolios
When a scenario involves genuine scholarly disagreement or unusual complexity, Rafiq flags it transparently and recommends consulting a qualified scholar rather than defaulting to one position silently.
6. Data Freshness
- Gold & silver prices: Live spot prices fetched at calculation time
- Stock screening ratios: Real-time via FMP API
- Shariah index membership: Updated periodically from DJIM and S&P Shariah index reconstitutions
- Dividend data: Real-time via FMP API
Rafiq is an educational calculation tool, not a religious authority or tax advisor. For complex situations, consult a qualified Islamic scholar. This methodology document describes the logic implemented in our calculation engine and is subject to refinement as scholarly guidance evolves.