From 3bb0c4349dacb60719d6695d90b7da17634c94fd Mon Sep 17 00:00:00 2001 From: murtada666 <91660848+murtada666@users.noreply.github.com> Date: Tue, 16 Aug 2022 10:53:27 +0300 Subject: [PATCH 1/2] Update services.py --- accounting/services.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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 From e7ce598b3b5a8c99e82f4151d8cf8751a4fa9021 Mon Sep 17 00:00:00 2001 From: murtada666 <91660848+murtada666@users.noreply.github.com> Date: Tue, 16 Aug 2022 10:54:02 +0300 Subject: [PATCH 2/2] Update account.py --- accounting/api/account.py | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) 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 - }] +