Skip to content

Commit

Permalink
إضافة وثائق تشرح دوالة معدل الصرف بين الحسابات
Browse files Browse the repository at this point in the history
  • Loading branch information
vzool committed Jun 26, 2024
1 parent 089367d commit bf44f05
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
13 changes: 7 additions & 6 deletions zakat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""
_____ _ _ _____ _
|__ /__ _| | ____ _| |_ |_ _| __ __ _ ___| | _____ _ __
/ // _` | |/ / _` | __| | || '__/ _` |/ __| |/ / _ \ '__|
/ /| (_| | < (_| | |_ | || | | (_| | (__| < __/ |
/____\__,_|_|\_\__,_|\__| |_||_| \__,_|\___|_|\_\___|_|
_____ _ _ _ _ _
|__ /__ _| | ____ _| |_ | | (_) |__ _ __ __ _ _ __ _ _
/ // _` | |/ / _` | __| | | | | '_ \| '__/ _` | '__| | | |
/ /| (_| | < (_| | |_ | |___| | |_) | | | (_| | | | |_| |
/____\__,_|_|\_\__,_|\__| |_____|_|_.__/|_| \__,_|_| \__, |
|___/
"رَبَّنَا افْتَحْ بَيْنَنَا وَبَيْنَ قَوْمِنَا بِالْحَقِّ وَأَنتَ خَيْرُ الْفَاتِحِينَ (89)" -- سورة الأعراف
... Never Trust, Always Verify ...
This module provides the ZakatTracker class for tracking and calculating Zakat.
This file provides the ZakatLibrary classes, functions for tracking and calculating Zakat.
"""
# Importing necessary classes and functions from the main module
from .zakat_tracker import (
Expand Down
40 changes: 39 additions & 1 deletion zakat/zakat_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,19 @@ def _log(self, value: int, desc: str = '', account: str = 1, created: int = None
return created

def exchange(self, account, created: int = None, rate: float = None, description: str = None) -> dict:
"""
This method is used to record or retrieve exchange rates for a specific account.
Parameters:
- account (str): The account number for which the exchange rate is being recorded or retrieved.
- created (int): The timestamp of the exchange rate. If not provided, the current timestamp will be used.
- rate (float): The exchange rate to be recorded. If not provided, the method will retrieve the latest exchange rate.
- description (str): A description of the exchange rate.
Returns:
- dict: A dictionary containing the latest exchange rate and its description. If no exchange rate is found,
it returns a dictionary with default values for the rate and description.
"""
if rate is not None:
if rate <= 1:
return None
Expand All @@ -607,6 +620,17 @@ def exchange(self, account, created: int = None, rate: float = None, description
return {"rate": 1, "description": None} # إرجاع القيمة الافتراضية مع وصف فارغ

def exchanges(self) -> dict:
"""
Retrieve the recorded exchange rates for all accounts.
Parameters:
None
Returns:
dict: A dictionary containing all recorded exchange rates.
The keys are account names or numbers, and the values are dictionaries containing the exchange rates.
Each exchange rate dictionary has timestamps as keys and exchange rate details as values.
"""
return self._vault['exchange'].copy()

def accounts(self) -> dict:
Expand Down Expand Up @@ -1194,7 +1218,21 @@ def DurationFromNanoSeconds(ns: int) -> tuple:
return TIMELAPSED, SPOKENTIME

@staticmethod
def day_to_time(day: int, month: int = 6, year: int = 2024) -> int: # افتراض أن الشهر هو يونيو والسنة 2024
def day_to_time(day: int, month: int = 6, year: int = 2024) -> int: # افتراض أن الشهر هو يونيو والسنة 2024
"""
Convert a specific day, month, and year into a timestamp.
Parameters:
day (int): The day of the month.
month (int): The month of the year. Default is 6 (June).
year (int): The year. Default is 2024.
Returns:
int: The timestamp representing the given day, month, and year.
Note:
This method assumes the default month and year if not provided.
"""
return ZakatTracker.time(datetime.datetime(year, month, day))

@staticmethod
Expand Down

0 comments on commit bf44f05

Please sign in to comment.