Skip to content

Commit

Permalink
تحديث القيود اليومية بحيث تحتوي حالة التحويل فيما بين الحسابات
Browse files Browse the repository at this point in the history
  • Loading branch information
vzool committed Aug 3, 2024
1 parent ce157a1 commit 24cac52
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = 'zakat'
version = '0.2.89'
version = '0.2.9'
authors = [
{ name='Abdelaziz Elrashed Elshaikh Mohamed', email='aeemh.sdn@gmail.com' },
]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='zakat',
version='0.2.89',
version='0.2.9',
description='A Python Library for Islamic Financial Management.',
author='Abdelaziz Elrashed Elshaikh Mohamed',
author_email='aeemh.sdn@gmail.com',
Expand Down
34 changes: 24 additions & 10 deletions zakat/zakat_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def Version() -> str:
Returns:
str: The current version of the software.
"""
return '0.2.89'
return '0.2.9'

@staticmethod
def ZakatCut(x: float) -> float:
Expand Down Expand Up @@ -1056,6 +1056,8 @@ def _log(self, value: float, desc: str = '', account: str = 1, created: int = No
desc (str): The description of the transaction.
account (str): The account to log the transaction into. Default is '1'.
created (int): The timestamp of the transaction. If not provided, it will be generated.
ref (int): The reference of the object.
debug (bool): Whether to print debug information. Default is False.
Returns:
int: The timestamp of the logged transaction.
Expand Down Expand Up @@ -1100,6 +1102,7 @@ def exchange(self, account, created: int = None, rate: float = None, description
- 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.
- debug (bool): Whether to print debug information. Default is False.
Returns:
- dict: A dictionary containing the latest exchange rate and its description. If no exchange rate is found,
Expand Down Expand Up @@ -1215,7 +1218,7 @@ def logs(self, account) -> dict:
return self._vault['account'][account]['log']
return {}

def daily_logs(self):
def daily_logs(self, debug: bool = False):
"""
Retrieve the daily logs (transactions) from all accounts.
Expand All @@ -1224,7 +1227,7 @@ def daily_logs(self):
and the values are dictionaries containing the total value and the logs for that group.
Parameters:
None
debug (bool): Whether to print debug information. Default is False.
Returns:
dict: A dictionary containing the daily logs.
Expand All @@ -1237,31 +1240,42 @@ def daily_logs(self):
{
1632057600: {
'total': 151,
'transfer': False,
'rows': [
{'value': 51, 'account': 'account1', 'file': {}, 'ref': 1690977015000000000, 'desc': 'desc'},
{'value': 100, 'account': 'account2', 'file': {}, 'ref': 1690977015000000000, 'desc': 'desc'}
]
}
}
"""
x = {}
logs = {}
for account in self.accounts():
logs = {}
for k, v in self.logs(account).items():
v['time'] = k
v['account'] = account
logs[k] = v
x.update(logs)
if k not in logs:
logs[k] = []
logs[k].append(v)
if debug:
print('logs', logs)
y = {}
for i in sorted(x, reverse=True):
for i in sorted(logs, reverse=True):
dt = self.time_to_datetime(i)
group = self.day_to_time(dt.day, dt.month, dt.year)
if group not in y:
y[group] = {
'total': 0,
'rows': [],
}
y[group]['total'] += x[i]['value']
y[group]['rows'].append(x[i])
y[group]['transfer'] = len(logs[i]) > 1
if debug:
print('logs[i]', logs[i])
for z in logs[i]:
print('z', z)
y[group]['total'] += z['value']
y[group]['rows'].append(z)
if debug:
print('y', y)
return y

def add_file(self, account: str, ref: int, path: str) -> int:
Expand Down

0 comments on commit 24cac52

Please sign in to comment.