Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions accounting/api/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}]


33 changes: 33 additions & 0 deletions accounting/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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