Skip to content

Commit

Permalink
تحسين رسالة الخطأ في سجل العمليات في جميع النماذج
Browse files Browse the repository at this point in the history
  • Loading branch information
vzool committed Nov 19, 2024
1 parent 4588a59 commit 4364259
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions zakat/zakat_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def sub(self, unscaled_value: float | int | Decimal, desc: str = '', account: in
Raises:
ValueError: The box transaction happened again in the same time.
ValueError: The log transaction happened again in the same time.
ValueError: The log transaction('xxx') happened again in the same time.
ValueError: The created must be a str, <class 'xxx'> was provided.
"""

Expand All @@ -198,7 +198,7 @@ def track(self, unscaled_value: float | int | Decimal = 0, desc: str = '', accou
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 time.
ValueError: The log transaction('xxx') happened again in the same time.
ValueError: The box transaction happened again in the same time.
ValueError: The created must be a str, <class 'xxx'> was provided.
"""
Expand Down Expand Up @@ -417,7 +417,7 @@ def transfer(self, unscaled_amount: float | int | Decimal, from_account: int, to
Raises:
ValueError: Transfer to the same account is forbidden.
ValueError: The box transaction happened again in the same time.
ValueError: The log transaction happened again in the same time.
ValueError: The log transaction('xxx') happened again in the same time.
ValueError: The created must be a str, <class 'xxx'> was provided.
"""

Expand Down Expand Up @@ -831,7 +831,7 @@ def log(self, value: float, desc: str = '', account_id: int = 1, created: str =
This method updates the account's balance, count, and log with the transaction details.
Raises:
ValueError: The log transaction happened again in the same time.
ValueError: The log transaction('xxx') happened again in the same time.
ValueError: The created must be a str, <class 'xxx'> was provided.
"""

Expand Down Expand Up @@ -1972,7 +1972,7 @@ def log(self, value: float, desc: str = '', account_id: int = 1, created: str =
if debug:
print('create-log', created)
if self.log_exists(account_id, created):
raise ValueError(f"The log transaction happened again in the same time({created}).")
raise ValueError(f"The log transaction('{desc}') happened again in the same time({created}).")
if debug:
print('created-log', created)
self._vault['account'][account_id]['log'][created] = {
Expand Down Expand Up @@ -3583,10 +3583,7 @@ def daily_logs(self, weekday: WeekDay = WeekDay.Friday, debug: bool = False):

def export_json(self, path: str = "data.json") -> bool:
with open(path, "w") as file:
vault = self.vault()
if self.debug:
print('vault', vault)
json.dump(vault, file, indent=4, cls=JSONEncoder)
json.dump(self.vault(), file, indent=4, cls=JSONEncoder)
return True

@pony.db_session()
Expand Down Expand Up @@ -3683,7 +3680,7 @@ def _log(self, value: float, desc: str = '', account_id: int = 1, created: str =
if debug:
print('create-log', created)
if self._log_exists(account_id, created):
raise ValueError(f"The log transaction happened again in the same time({created}).")
raise ValueError(f"The log transaction('{desc}') happened again in the same time({created}).")
if debug:
print('created-log', created)
if self.raw_sql:
Expand Down

0 comments on commit 4364259

Please sign in to comment.