zakat

Crates.iozakat
lib.rszakat
version1.4.0
created_at2025-12-24 11:17:58.781788+00
updated_at2026-01-05 15:02:07.917151+00
descriptionA type-safe, comprehensive, and Fiqh-compliant Zakat calculation library. Supports Gold, Silver, Business, Agriculture, Livestock, Professional Income, and Modern Assets (Crypto/Stocks).
homepage
repositoryhttps://github.com/IRedDragonICY/zakatrs
max_upload_size
id2002998
size153,663
Ndik (IRedDragonICY)

documentation

README

zakat

A comprehensive, type-safe, and Fiqh-compliant Zakat calculation library for Rust.

Overview

This crate provides a complete solution for calculating Islamic Zakat obligations across all asset classes. It implements classical Fiqh rules with support for multiple schools of thought (Madhabs).

Features

  • Type-safe calculations using rust_decimal for financial precision
  • Support for Gold, Silver, Business, Agriculture, Livestock, Income, and Modern Assets
  • Madhab-aware calculation strategies (Hanafi, Shafi'i, Maliki, Hanbali)
  • Internationalization with RTL language support
  • Hawl (lunar year) tracking
  • Live metal pricing integration
  • Multiple platform targets: Native, WASM, Python, Dart, Kotlin

Installation

[dependencies]
zakat = "1.0"

Quick Start

use zakat::prelude::*;

fn main() -> Result<(), ZakatError> {
    // Configure with Hanafi rules
    let config = ZakatConfig::hanafi()
        .gold_price_per_gram(65.0)
        .silver_price_per_gram(0.80)
        .build()?;

    // Calculate gold zakat
    let gold = PreciousMetals::gold(100.0)
        .purity(24)
        .calculate_zakat(&config)?;

    println!("Zakat due: {}", gold.zakat_due);

    // Portfolio calculation
    let mut portfolio = ZakatPortfolio::new();
    portfolio.add(PreciousMetals::gold(100.0));
    portfolio.add(BusinessZakat::new().cash(50000.0).inventory(25000.0));

    let total = portfolio.calculate_total(&config)?;
    println!("Total Zakat: {}", total.total_zakat);

    Ok(())
}

Asset Types

Type Description
PreciousMetals Gold and silver with purity calculations
BusinessZakat Trade goods, cash, receivables, inventory
AgricultureAssets Crops with irrigation differentiation
LivestockAssets Camels, cattle, sheep with Nisab tables
IncomeZakatCalculator Professional income (gross/net)
InvestmentAssets Stocks, bonds, cryptocurrency
MiningAssets Minerals and Rikaz (buried treasure)

Feature Flags

Feature Description Default
i18n Localization support Yes
ledger Hawl tracking and timeline Yes
providers Live price fetching Yes
async Async calculation support Yes
sqlite SQLite persistence No
wasm WebAssembly bindings No
python Python bindings No

Crate Structure

This is a facade crate that re-exports functionality from:

Crate Purpose
zakat-core Core calculations and types
zakat-i18n Internationalization
zakat-ledger Hawl and timeline tracking
zakat-providers Live pricing
zakat-sqlite Database persistence

Platform Support

Platform Status
Linux / macOS / Windows Supported
WebAssembly (Browser) Supported
Python 3.8+ Supported
Dart / Flutter Supported
Kotlin / Android Supported

Documentation

License

MIT

Commit count: 0

cargo fmt