miraath-calculator
v1.0.0
Published
🧮 Islamic inheritance calculator based on Quranic shares (علم المواريث) — حساب أنصبة الميراث الشرعية حسب القرآن. Part of Adwatak (adwatak.cloud).
Maintainers
Readme
miraath-calculator 🧮
Islamic inheritance calculator based on Quranic shares. حاسبة أنصبة الميراث الشرعية حسب سورة النساء.
🔗 Live demo: adwatak.cloud/tools/inheritance-calculator 🏠 Platform: Adwatak — free online Arabic tools (80+ tools)
Features
- ✅ 16 heir types: husband, wives, sons, daughters, father, mother, grandparents, full/paternal/maternal siblings
- ✅ Quranic fixed shares (أصحاب الفروض) — ½, ¼, ⅛, ⅙, ⅓, ⅔
- ✅ Asabah (العصبة) — remainder distribution with male:female 2:1 ratio
- ✅ Awl (العول) — proportional reduction when shares exceed the estate
- ✅ Radd (الرد) — surplus return to Quranic heirs (excluding spouse)
- ✅ Pure TypeScript — zero dependencies, works in Node, browser, React, etc.
- ✅ Arabic & English output names
- ✅ No API calls — all logic runs locally
Install
npm install miraath-calculatorQuick start
import { getDefaultHeirs, calculateInheritance } from 'miraath-calculator';
const heirs = getDefaultHeirs();
heirs.husband = true;
heirs.mother = true;
heirs.sons = 2;
heirs.daughters = 1;
const results = calculateInheritance(heirs, 500_000);
results.forEach(r => {
console.log(`${r.icon} ${r.name}: ${r.percentage.toFixed(1)}% = ${r.amount.toFixed(0)} SAR`);
});
// 👨 الزوج: 25.0% = 125000 SAR
// 👩🦳 الأم: 12.5% = 62500 SAR
// 👦 الابن 1: 20.8% = 104167 SAR
// 👦 الابن 2: 20.8% = 104167 SAR
// 👧 البنت: 10.4% = 52083 SAR
// ...API
getDefaultHeirs(): HeirSelection
Returns a fresh HeirSelection with all heirs deselected and counts set to 0.
calculateInheritance(heirs: HeirSelection, estateAmount: number): HeirResult[]
Calculates shares for the given heirs. Returns results sorted by share size (largest first).
Types
interface HeirSelection {
husband: boolean;
wife: boolean;
wifeCount: number; // 1–4
sons: number; // 0–20
daughters: number; // 0–20
father: boolean;
mother: boolean;
grandfather: boolean;
grandmotherPaternal: boolean;
grandmotherMaternal: boolean;
fullBrothers: number;
fullSisters: number;
paternalBrothers: number;
paternalSisters: number;
maternalBrothers: number;
maternalSisters: number;
}
interface HeirResult {
name: string; // Arabic name
nameEn: string; // English name
icon: string; // Emoji icon
share: number; // Fraction of estate (0..1)
amount: number; // share * estateAmount
percentage: number; // share * 100
color: string; // Hex color for UI
group: 'spouse' | 'parents' | 'children' | 'siblings' | 'asabah';
}🕌 Islamic inheritance rules implemented
The calculation follows the Quranic rulings from Surah An-Nisa (النساء):
| Heir | Condition | Share | |------|-----------|-------| | Husband | No children | ½ | | Husband | With children | ¼ | | Wife(s) | No children | ¼ (divided equally) | | Wife(s) | With children | ⅛ (divided equally) | | Father | With children | ⅙ (+ asabah) | | Father | No children | Asabah (remainder) | | Mother | No children, <2 siblings | ⅓ | | Mother | With children or ≥2 siblings | ⅙ | | Daughter(s) | Only one, no son | ½ | | Daughters (2+) | No son | ⅔ (divided equally) | | Sons | — | Asabah (male gets 2x female) | | Full sister | One, no male blocker | ½ | | Full sisters (2+) | No male blocker | ⅔ | | Paternal sister | No full sister, no blocker | ½ | | Maternal sibling | No child/father/grandfather | ⅙ (capped at ⅓ total) |
Plus: Awl (proportional reduction), Radd (surplus return), and Hajb (blocking rules).
Browser usage (CDN)
<script type="module">
import { calculateInheritance, getDefaultHeirs } from 'https://cdn.jsdelivr.net/npm/miraath-calculator/dist/index.js';
const heirs = getDefaultHeirs();
heirs.husband = true;
heirs.mother = true;
heirs.sons = 2;
const result = calculateInheritance(heirs, 500000);
console.log(result);
</script>📜 License
MIT — Free to use, modify, and share.
Built by Adwatak — your free online tools platform in Arabic.
Explore 80+ tools at adwatak.cloud 🚀
