███████╗ █████╗ ██╗ ██╗ █████╗ ████████╗
╚══███╔╝██╔══██╗██║ ██╔╝██╔══██╗╚══██╔══╝
███╔╝ ███████║█████╔╝ ███████║ ██║
███╔╝ ██╔══██║██╔═██╗ ██╔══██║ ██║
███████╗██║ ██║██║ ██╗██║ ██║ ██║
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
Zakat
Rust library for Islamic Zakat calculation. Uses rust_decimal for precision.
Features
- Gold, Silver, Business, Agriculture, Livestock, Mining & Rikaz
- Stocks, Mutual Funds, Crypto (as liquid assets)
- Professional Income (Gross/Net)
- Zakat Fitrah
- Configurable Nisab thresholds
- Portfolio aggregation (Dam' al-Amwal)
- Asset Labeling (e.g., "Main Store", "Crypto Wallet")
- Input Sanitization & Validation (Rejects negative values, ensures safe configuration)
- Flexible Configuration (Env Vars, JSON, Fluent Builder)
- Fiqh Compliance (Jewelry exemptions, Madhab-specific rules, Hawl requirements)
- Async Support (Optional integration with
tokioandasync-trait) - Live Pricing Interface (e.g. for API integration)
- Detailed Reporting (Livestock in-kind details, calculation traces, metadata support)
Install
With Async Support (Default):
[]
= "0.4.1"
= "1.39"
= { = "1", = ["full"] } # Required if using async features
Synchronous Only (Lighter weight):
[]
= { = "0.4.1", = false }
= "1.39"
Usage
Business Zakat
Note: You can pass standard Rust types (
i32,f64,&str) directly to all constructors for ease of use.
use *;
Advanced Usage (Builder Pattern)
For complex scenarios involving debts and receivables:
let assets = default
.cash_on_hand
.inventory_value
.receivables
.short_term_liabilities
.liabilities_due_now // Deductible immediate debt
.label
.hawl_satisfied
.build?;
Portfolio Management
Handles multiple assets with "Dam' al-Amwal" (Wealth Aggregation) logic.
use *;
use PortfolioStatus;
Async & Live Pricing (Optional)
Enable the async feature to use these capabilities.
use *;
use ;
;
async
Configuration
Refactored to be flexible and safe.
use *;
// Load from Environment Variables (ZAKAT_GOLD_PRICE, etc.)
let config = from_env?;
// Or load from JSON
let config = try_from_json?;
// Or using Fluent Builder (with Validation)
let config = default
.gold_price
.silver_price
.madhab
// Validates that adequate prices are set for the chosen Madhab/Standard
.build?;
Advanced Assets (Jewelry & Livestock)
use *;
// Personal Jewelry (Exempt in Shafi/Maliki, Payable in Hanafi)
let necklace = new?
.with_usage
.with_label;
// Livestock Reporting
let prices = default
.sheep_price
.cow_price
.camel_price
.build?;
let camels = new;
let result = camels.calculate_zakat?;
if result.is_payable
Modules
| Module | Nisab |
|---|---|
maal::precious_metals |
85g Gold / 595g Silver |
maal::business |
85g Gold |
maal::income |
85g Gold |
maal::investments |
85g Gold |
maal::agriculture |
653 kg |
maal::livestock |
Count-based |
maal::mining |
Rikaz: None / Mines: 85g Gold |
fitrah |
N/A |
Contributing
- Add tests
- Use
rust_decimal - If adding async features, ensure they are gated behind
#[cfg(feature = "async")] - Run
cargo testandcargo check --no-default-features
Support
"Those who spend their wealth in the cause of Allah..." — Al-Baqarah 2:262
License
MIT