███████╗ █████╗ ██╗ ██╗ █████╗ ████████╗
╚══███╔╝██╔══██╗██║ ██╔╝██╔══██╗╚══██╔══╝
███╔╝ ███████║█████╔╝ ███████║ ██║
███╔╝ ██╔══██║██╔═██╗ ██╔══██║ ██║
███████╗██║ ██║██║ ██╗██║ ██║ ██║
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
Zakat: The Definitive Islamic Alms Calculation Library
Zakat is a production-grade, type-safe Rust library designed to bridge Classical Fiqh with Modern Finance. It provides mathematically precise calculations for essentially all major wealth types, including cryptocurrencies, stocks, livestock, and professional income, while handling currency precision flawlessly using rust_decimal.
Features
- Type-Safe Precision: Zero floating-point errors. All calculations use
rust_decimal. - Comprehensive Coverage:
- Maal (Wealth): Gold, Silver, Business/Trade, Agriculture, Livestock (Camels, Cows, Sheep), Mining & Rikaz.
- Modern Assets: Stocks, Mutual Funds, and Cryptocurrencies (treated as liquid assets).
- Income: Professional Income calculation (Gross & Net support).
- Fitrah: Per-capita food staple calculation.
- Fiqh Compliant & Flexible:
- Built-in default Nisab thresholds (e.g., 85g Gold).
- Fully Configurable: Override thresholds to match specific Fatwa or regional standards.
- Debt Deduction: Flexible logic to deduct liabilities before or after Nisab checks as per config.
- Portfolio Management: Builder pattern to aggregate diverse assets and calculate total Zakat due in one go.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= "1.39"
= "1.39"
Quick Start
1. Simple Business Calculation
use ;
use ;
use dec;
2. Portfolio Management (The "Enterprise" Way)
Handling a complex user scenario (e.g., "Mr. Ahmad") who has income, gold, investments, and debts.
use ;
use PreciousMetal;
use ;
use ;
use dec;
Advanced Configuration (Custom Nisab)
Different regions or scholar councils may have different standards for Nisab. You can override defaults easily:
use ZakatConfig;
use dec;
let mut config = new;
// Override Gold Nisab to 87g (some opinions) instead of default 85g
config.nisab_gold_grams = Some;
// Override Agriculture Nisab
config.nisab_agriculture_kg = Some;
Supported Modules
| Module | Features | Nisab Basis |
|---|---|---|
maal::precious_metals |
Gold, Silver | 85g Gold / 595g Silver |
maal::business |
Cash, Inventory, Receivables | 85g Gold Equiv |
maal::income |
Professional Income (Gross/Net) | 85g Gold Equiv |
maal::investments |
Stocks, Crypto, Mutual Funds | 85g Gold Equiv |
maal::agriculture |
Rain (10%), Irrigated (5%), Mixed | 5 Wasq (~653 kg) |
maal::livestock |
Camels, Cows, Sheep (Tiered logic) | Count-based (e.g. 40 Sheep) |
maal::mining |
Rikaz (20% flat), Mines (2.5%) | None (Rikaz) / 85g Gold |
fitrah |
Per person food staple | N/A |
Contributing
Contributions are welcome! Please ensure you:
- Add unit tests for any new logic.
- Maintain
rust_decimalusage for precision. - Run
cargo testbefore submitting.
💖 Support This Project
If you find this library helpful for your zakat calculations or Islamic finance applications, please consider supporting its development. Your support helps maintain and improve this project.
"Those who spend their wealth in the cause of Allah and do not follow their charity with reminders of their generosity or hurtful words—they will have their reward with their Lord." — Al-Baqarah 2:262
License
This project is licensed under the MIT License - see the LICENSE file for details.