Skip to content

Commit

Permalink
إضافة توثيق عدد من الاستثناءات في بعض الدوال
Browse files Browse the repository at this point in the history
  • Loading branch information
vzool committed Jun 30, 2024
1 parent 6615433 commit 83a9cc7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions zakat/zakat_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ def track(self, value: float = 0, desc: str = '', account: str = 1, logging: boo
This function creates a new account if it doesn't exist, logs the transaction if logging is True, and updates the account's balance and box.
Raises:
ValueError: The log transaction happened again in the same nanosecond time.
ValueError: The box transaction happened again in the same nanosecond time.
"""
if created is None:
Expand Down Expand Up @@ -646,7 +647,7 @@ def _log(self, value: float, desc: str = '', account: str = 1, created: int = No
It also creates a step in the history of the transaction.
Raises:
ValueError: The box transaction happened again in the same nanosecond time.
ValueError: The log transaction happened again in the same nanosecond time.
"""
if created is None:
created = self.time()
Expand All @@ -655,7 +656,7 @@ def _log(self, value: float, desc: str = '', account: str = 1, created: int = No
if debug:
print('create-log', created)
if self.log_exists(account, created):
raise ValueError(f"The box transaction happened again in the same nanosecond time({created}).")
raise ValueError(f"The log transaction happened again in the same nanosecond time({created}).")
if debug:
print('created-log', created)
self._vault['account'][account]['log'][created] = {
Expand Down Expand Up @@ -904,6 +905,7 @@ def sub(self, x: float, desc: str = '', account: str = 1, created: int = None, d
Raises:
ValueError: The box transaction happened again in the same nanosecond time.
ValueError: The log transaction happened again in the same nanosecond time.
"""
if x < 0:
return tuple()
Expand Down Expand Up @@ -966,6 +968,7 @@ def transfer(self, amount: int, from_account: str, to_account: str, desc: str =
Raises:
ValueError: The box transaction happened again in the same nanosecond time.
ValueError: The log transaction happened again in the same nanosecond time.
"""
if amount <= 0:
return []
Expand Down Expand Up @@ -1305,8 +1308,8 @@ def import_csv(self, path: str = 'file.csv') -> tuple:
The function reads the CSV file, checks for duplicate transactions, and creates the transactions in the system.
"""
cache = []
tmp = "tmp"
cache: list[int] = []
tmp: str = "tmp"
try:
with open(tmp, "rb") as f:
cache = pickle.load(f)
Expand Down

0 comments on commit 83a9cc7

Please sign in to comment.