Skip to content

Commit

Permalink
تحسين دالة تخزين واسترجاع معدل الصرف للحسابات المختلفة.
Browse files Browse the repository at this point in the history
  • Loading branch information
vzool committed Jul 1, 2024
1 parent 0385d22 commit 229eef3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zakat/zakat_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,12 @@ def exchange(self, account, created: int = None, rate: float = None, description
no_lock = self.nolock()
self.lock()
if rate is not None:
if rate <= 1:
if rate <= 0:
return dict()
if account not in self._vault['exchange']:
self._vault['exchange'][account] = {}
if len(self._vault['exchange'][account]) == 0 and rate <= 1:
return {"rate": 1, "description": None}
self._vault['exchange'][account][created] = {"rate": rate, "description": description}
self._step(Action.EXCHANGE, account, ref=created, value=rate)
if no_lock:
Expand Down Expand Up @@ -2007,7 +2009,7 @@ def test(self, debug: bool = False) -> bool:
self.exchange("cash", ZakatTracker.day_to_time(10), 3.66)

for i in [x * 0.12 for x in range(-15, 21)]:
if i <= 1:
if i <= 0:
assert len(self.exchange("test", ZakatTracker.time(), i, f"range({i})")) == 0
else:
assert len(self.exchange("test", ZakatTracker.time(), i, f"range({i})")) > 0
Expand Down

0 comments on commit 229eef3

Please sign in to comment.