Skip to content

Commit

Permalink
تنسيق البرمجة المصدرية
Browse files Browse the repository at this point in the history
  • Loading branch information
vzool committed Nov 21, 2024
1 parent 10e8be9 commit a6734c8
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions zakat/zakat_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,10 @@ def check(self,

@abstractmethod
def zakat(
self,
report: tuple,
parts: dict[str, dict[str, dict[str, float]] | bool | int | float] = None,
debug: bool = False,
self,
report: tuple,
parts: dict[str, dict[str, dict[str, float]] | bool | int | float] = None,
debug: bool = False,
) -> bool:
"""
Perform Zakat calculation based on the given report and optional parts.
Expand Down Expand Up @@ -1243,8 +1243,8 @@ def Nisab(gram_price: float, gram_quantity: float = 595) -> float:

@staticmethod
def check_payment_parts(
parts: dict[str, dict[str, dict[str, float]] | bool | int | float],
debug: bool = False,
parts: dict[str, dict[str, dict[str, float]] | bool | int | float],
debug: bool = False,
) -> int:
"""
Checks the validity of payment parts.
Expand Down Expand Up @@ -2499,10 +2499,10 @@ def check(self,
return valid, brief, plan

def zakat(
self,
report: tuple,
parts: dict[str, dict[str, dict[str, float]] | bool | int | float] = None,
debug: bool = False,
self,
report: tuple,
parts: dict[str, dict[str, dict[str, float]] | bool | int | float] = None,
debug: bool = False,
) -> bool:
if debug:
print('zakat', f'debug={debug}')
Expand Down Expand Up @@ -3490,16 +3490,16 @@ def _check(self,

@pony.db_session
def zakat(
self,
report: tuple, parts: dict[str, dict[str, dict[str, float]] | bool | int | float] = None,
debug: bool = False,
self,
report: tuple, parts: dict[str, dict[str, dict[str, float]] | bool | int | float] = None,
debug: bool = False,
) -> bool:
return self._zakat(report, parts, debug)

def _zakat(
self,
report: tuple, parts: dict[str, dict[str, dict[str, float]] | bool | int | float] = None,
debug: bool = False,
self,
report: tuple, parts: dict[str, dict[str, dict[str, float]] | bool | int | float] = None,
debug: bool = False,
) -> bool:
if debug:
print('zakat', f'debug={debug}')
Expand Down Expand Up @@ -3547,7 +3547,8 @@ def _zakat(
SET rest = rest - {box['box_rest']}
WHERE id = {box['ref']};
''')
self.log(-float(amount), desc='zakat-زكاة', account_id=x, created=None, ref=box['box_time'], debug=debug)
self.log(-float(amount), desc='zakat-زكاة', account_id=x, created=None, ref=box['box_time'],
debug=debug)
if parts_exist:
for account, part in parts['account'].items():
if part['part'] == 0:
Expand Down Expand Up @@ -3832,10 +3833,10 @@ def __init__(self, model: Model):
self.db = model

def build_payment_parts(
self,
scaled_demand: int,
positive_only: bool = True,
debug: bool = False,
self,
scaled_demand: int,
positive_only: bool = True,
debug: bool = False,
) -> dict[str, dict[str, dict[str, float]] | bool | int | float]:
"""
Build payment parts for the Zakat distribution.
Expand Down Expand Up @@ -4784,9 +4785,7 @@ def test(self, debug: bool = False) -> bool:
suite.append(cp)
if debug:
print('suite', len(suite))
# vault = self._vault.copy()
for case in suite:
# self._vault = vault.copy()
if debug:
print('case', case)
result = Helper.check_payment_parts(case)
Expand Down Expand Up @@ -5010,6 +5009,7 @@ def test(self, debug: bool = False) -> bool:
(valid, brief, plan) = report
if debug:
print('brief', brief)
print('case', case)
assert valid == case[4]
assert case[5] == brief[0]
assert case[5] == brief[1]
Expand All @@ -5036,7 +5036,6 @@ def test(self, debug: bool = False) -> bool:
assert valid is False
return True
except Exception as e:
# pp().pprint(self._vault)
assert self.db.export_json("test-snapshot.json")
assert self.db.save(f"test-snapshot.{self.db.ext()}")
raise e
Expand Down

0 comments on commit a6734c8

Please sign in to comment.