diff --git a/accounting/api/account.py b/accounting/api/account.py index e843e61..ad34ea1 100644 --- a/accounting/api/account.py +++ b/accounting/api/account.py @@ -59,29 +59,5 @@ def get_account_balances(request): -class Balance: - def __init__(self, balances): - balance1 = balances[0] - balance2 = balances[1] - - if balance1['currency'] == 'USD': - balanceUSD = balance1['sum'] - balanceIQD = balance2['sum'] - else: - balanceIQD = balance1['sum'] - balanceUSD = balance2['sum'] - - self.balanceUSD = balanceUSD - self.balanceIQD = balanceIQD - - def __add__(self, other): - self.balanceIQD += other.balanceIQD - self.balanceUSD += other.balanceUSD - return [{ - 'currency': 'USD', - 'sum': self.balanceUSD - }, { - 'currency': 'IQD', - 'sum': self.balanceIQD - }] + diff --git a/accounting/services.py b/accounting/services.py index 7ecff81..76c73f1 100644 --- a/accounting/services.py +++ b/accounting/services.py @@ -32,4 +32,37 @@ def account_transfer(data): # t.delete() # return status.HTTP_400_BAD_REQUEST, {'detail': 'transaction is not valid'} return t + + + + def __gt__(self, other): + + if self.balanceUSD > other.balanceUSD : + StaUSD = True + else: + StaUSD = False + if self.balanceIQD > other.balanceIQD : + StaIQD = True + else: + StaIQD = False + return {'USD':StaUSD},{'IQD':StaIQD} + + + def __lt__(self,other): + + if self.balanceUSD < other.balanceUSD : + StaUSD = True + else: + StaUSD = False + if self.balanceIQD < other.balanceIQD : + StaIQD = True + else: + StaIQD = False + return {'USD':StaUSD},{'IQD':StaIQD} + + def is_zero(self): + if self.balanceIQD == 0 and self.balanceUSD == 0 : + return True + else: + return False