fix(wallet): adapt submit and verify process to new wallet, account concept
adapt submit and verify process to new wallet, account concept notice: add WALLET_RIAL_CATEGORY to .env
This commit is contained in:
parent
a84d93a25c
commit
db798dd348
7 changed files with 203 additions and 217 deletions
|
|
@ -237,7 +237,7 @@ class Transaction(BaseModel):
|
||||||
if not self.payee_account:
|
if not self.payee_account:
|
||||||
raise APIException('payee identification error')
|
raise APIException('payee identification error')
|
||||||
|
|
||||||
if not self.payer_wallet == self.payee_wallet:
|
if not self.payer_account.wallet.currency == self.payee_account.wallet.currency:
|
||||||
self.change_state(from_state=self.state, to_state=StateChoices.FAILED)
|
self.change_state(from_state=self.state, to_state=StateChoices.FAILED)
|
||||||
raise APIException('payer and payee account currency not equal')
|
raise APIException('payer and payee account currency not equal')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ from ..users.models import User
|
||||||
class TransactionSerializer(serializers.ModelSerializer):
|
class TransactionSerializer(serializers.ModelSerializer):
|
||||||
payee = serializers.UUIDField(read_only=True)
|
payee = serializers.UUIDField(read_only=True)
|
||||||
payee_type = serializers.IntegerField(read_only=True)
|
payee_type = serializers.IntegerField(read_only=True)
|
||||||
# payee_wallet = serializers.UUIDField(source='payee_wallet_category', read_only=True)
|
# payee_wallet = serializers.UUIDField(source='payee_wallet', read_only=True)
|
||||||
# payer_wallet = serializers.UUIDField(source='payer_wallet_category', read_only=True)
|
# payer_wallet = serializers.UUIDField(source='payer_wallet', read_only=True)
|
||||||
role = serializers.SerializerMethodField()
|
role = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
@ -170,8 +170,8 @@ class ApplicationDepositSerializer(serializers.ModelSerializer):
|
||||||
uuid = serializers.UUIDField(required=False, validators=[])
|
uuid = serializers.UUIDField(required=False, validators=[])
|
||||||
payee = serializers.UUIDField(required=True)
|
payee = serializers.UUIDField(required=True)
|
||||||
payee_type = serializers.IntegerField(required=True)
|
payee_type = serializers.IntegerField(required=True)
|
||||||
# payee_wallet = serializers.UUIDField(source='payee_wallet', required=False) # TODO: required True
|
payee_wallet = serializers.UUIDField(required=True)
|
||||||
# payer_wallet = serializers.UUIDField(source='payer_wallet', read_only=True)
|
payer_wallet = serializers.UUIDField(read_only=True)
|
||||||
amount = serializers.IntegerField(required=True, validators=[MinValueValidator(1)])
|
amount = serializers.IntegerField(required=True, validators=[MinValueValidator(1)])
|
||||||
# TODO: details as fields
|
# TODO: details as fields
|
||||||
|
|
||||||
|
|
@ -193,7 +193,7 @@ class ApplicationDepositSerializer(serializers.ModelSerializer):
|
||||||
'details',
|
'details',
|
||||||
)
|
)
|
||||||
|
|
||||||
read_only_fields = ['updated_at', 'state', 'created_at', 'payer_id', 'payer_type', 'payer_wallet']
|
read_only_fields = ['updated_at', 'state', 'created_at', 'payer', 'payer_type', 'payer_wallet']
|
||||||
|
|
||||||
|
|
||||||
class ApplicationWithdrawSerializer(serializers.ModelSerializer):
|
class ApplicationWithdrawSerializer(serializers.ModelSerializer):
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from rest_framework.test import APITestCase, override_settings
|
||||||
from apps.users.models import User
|
from apps.users.models import User
|
||||||
from apps.wallet.constans import TypeChoices
|
from apps.wallet.constans import TypeChoices
|
||||||
from apps.wallet.models import Account
|
from apps.wallet.models import Account
|
||||||
from apps.wallet.models import Category
|
from apps.wallet.models import Wallet
|
||||||
|
|
||||||
AccessToken = get_access_token_model()
|
AccessToken = get_access_token_model()
|
||||||
Application = get_application_model()
|
Application = get_application_model()
|
||||||
|
|
@ -22,8 +22,9 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
payer_access_token = '24naVsdKCbKNOhnElPyXcrwSnqqFbm'
|
payer_access_token = '24naVsdKCbKNOhnElPyXcrwSnqqFbm'
|
||||||
payer_uuid = uuid.UUID('b14e8b86-8f4a-44d9-b29d-badceb470051')
|
payer_uuid = uuid.UUID('b14e8b86-8f4a-44d9-b29d-badceb470051')
|
||||||
payee_uuid = uuid.UUID('b14e8b86-8f4a-44d9-b29d-badceb470052')
|
payee_uuid = uuid.UUID('b14e8b86-8f4a-44d9-b29d-badceb470052')
|
||||||
wallet_category1_uuid = uuid.UUID('114e8b86-8f4a-44d9-b29d-badceb470051')
|
# wallet_rial_uuid = uuid.UUID('114e8b86-8f4a-44d9-b29d-badceb470051')
|
||||||
wallet_category2_uuid = uuid.UUID('214e8b86-8f4a-44d9-b29d-badceb470051')
|
wallet_rial_uuid = uuid.UUID('114e8b86-8f4a-44d9-b29d-badceb470051')
|
||||||
|
wallet_reward_uuid = uuid.UUID('214e8b86-8f4a-44d9-b29d-badceb470051')
|
||||||
# application, _ = Application.objects.get_or_create(client_id=client_id, uuid=application_uuid)
|
# application, _ = Application.objects.get_or_create(client_id=client_id, uuid=application_uuid)
|
||||||
|
|
||||||
scopes = [
|
scopes = [
|
||||||
|
|
@ -41,9 +42,9 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.application_user, _ = User.objects.get_or_create(pk=self.application_uuid)
|
self.application_user, _ = User.objects.get_or_create(pk=self.application_uuid)
|
||||||
self.payer_user, _ = User.objects.get_or_create(pk=self.payer_uuid)
|
self.payer_user, _ = User.objects.get_or_create(pk=self.payer_uuid)
|
||||||
self.application_wallet, _ = Account.objects.get_or_create(owner_uuid=self.application_uuid, owner_type=TypeChoices.APPLICATION, balance=300)
|
self.application_account, _ = Account.objects.get_or_create(owner_uuid=self.application_uuid, owner_type=TypeChoices.APPLICATION, balance=300)
|
||||||
self.payee_wallet, _ = Account.objects.get_or_create(owner_uuid=self.payee_uuid, owner_type=TypeChoices.USER)
|
self.payee_account, _ = Account.objects.get_or_create(owner_uuid=self.payee_uuid, owner_type=TypeChoices.USER)
|
||||||
self.payer_wallet, _ = Account.objects.get_or_create(owner_uuid=self.payer_uuid, owner_type=TypeChoices.USER, balance=300)
|
self.payer_account, _ = Account.objects.get_or_create(owner_uuid=self.payer_uuid, owner_type=TypeChoices.USER, balance=300)
|
||||||
expire_datetime = timezone.now() + timedelta(seconds=3600)
|
expire_datetime = timezone.now() + timedelta(seconds=3600)
|
||||||
expire_datetime.isoformat()
|
expire_datetime.isoformat()
|
||||||
|
|
||||||
|
|
@ -75,14 +76,14 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
client_id=self.client_id,
|
client_id=self.client_id,
|
||||||
uuid=self.application_uuid,
|
uuid=self.application_uuid,
|
||||||
)
|
)
|
||||||
self.wallet_category1, _ = Category.objects.get_or_create(application=self.application, uuid=self.wallet_category1_uuid)
|
self.wallet_rial, _ = Wallet.objects.get_or_create(application=self.application, uuid=self.wallet_rial_uuid)
|
||||||
self.wallet_category2, _ = Category.objects.get_or_create(application=self.application, uuid=self.wallet_category2_uuid)
|
self.wallet_reward, _ = Wallet.objects.get_or_create(application=self.application, uuid=self.wallet_reward_uuid)
|
||||||
self.application_wallet1, _ = Account.objects.get_or_create(owner_uuid=self.application_uuid, owner_type=TypeChoices.APPLICATION, balance=300, category=self.wallet_category1)
|
self.application_account1, _ = Account.objects.get_or_create(owner_uuid=self.application_uuid, owner_type=TypeChoices.APPLICATION, balance=300, wallet=self.wallet_rial)
|
||||||
self.application_wallet2, _ = Account.objects.get_or_create(owner_uuid=self.application_uuid, owner_type=TypeChoices.APPLICATION, balance=300, category=self.wallet_category2)
|
self.application_account2, _ = Account.objects.get_or_create(owner_uuid=self.application_uuid, owner_type=TypeChoices.APPLICATION, balance=300, wallet=self.wallet_reward)
|
||||||
self.payee_wallet1, _ = Account.objects.get_or_create(owner_uuid=self.payee_uuid, owner_type=TypeChoices.USER, category=self.wallet_category1)
|
self.payee_account1, _ = Account.objects.get_or_create(owner_uuid=self.payee_uuid, owner_type=TypeChoices.USER, wallet=self.wallet_rial)
|
||||||
self.payee_wallet2, _ = Account.objects.get_or_create(owner_uuid=self.payee_uuid, owner_type=TypeChoices.USER, category=self.wallet_category2)
|
self.payee_account2, _ = Account.objects.get_or_create(owner_uuid=self.payee_uuid, owner_type=TypeChoices.USER, wallet=self.wallet_reward)
|
||||||
self.payer_wallet1, _ = Account.objects.get_or_create(owner_uuid=self.payer_uuid, owner_type=TypeChoices.USER, balance=300, category=self.wallet_category1)
|
self.payer_account1, _ = Account.objects.get_or_create(owner_uuid=self.payer_uuid, owner_type=TypeChoices.USER, balance=300, wallet=self.wallet_rial)
|
||||||
self.payer_wallet2, _ = Account.objects.get_or_create(owner_uuid=self.payer_uuid, owner_type=TypeChoices.USER, balance=300, category=self.wallet_category2)
|
self.payer_account2, _ = Account.objects.get_or_create(owner_uuid=self.payer_uuid, owner_type=TypeChoices.USER, balance=300, wallet=self.wallet_reward)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
|
|
@ -122,67 +123,70 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
auth = self._create_authorization_header(self.application_access_token.token)
|
auth = self._create_authorization_header(self.application_access_token.token)
|
||||||
|
|
||||||
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api'), HTTP_AUTHORIZATION=auth)
|
wallets = [self.wallet_rial_uuid.hex, self.wallet_reward_uuid.hex]
|
||||||
self.assertContains(response, 'balance')
|
response = self.client.get(reverse('wallet:application_account_balance_api'), query_params={'wallet': ','.join(wallets)}, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.json()['balance'], 300)
|
self.assertGreater(response.json()['count'], 1)
|
||||||
|
from_wallet = response.json()['results'][0]
|
||||||
|
self.assertEqual(from_wallet['balance'], 300)
|
||||||
params = {
|
params = {
|
||||||
'uuid': self.payee_uuid,
|
'user': self.payee_uuid,
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_account_api', kwargs=params), query_params={'wallet': ','.join(wallets)}, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertGreater(response.json()['count'], 1)
|
||||||
self.assertEqual(response.json()['balance'], 0)
|
to_wallet = response.json()['results'][0]
|
||||||
|
self.assertEqual(to_wallet['balance'], 0)
|
||||||
|
|
||||||
# Deposit process
|
# Deposit process
|
||||||
data = {
|
data = {
|
||||||
'amount': 100,
|
'amount': 100,
|
||||||
'payee': self.payee_uuid,
|
'payee': self.payee_uuid,
|
||||||
'payee_type': TypeChoices.USER,
|
'payee_type': TypeChoices.USER,
|
||||||
'payee_wallet': self.wallet_category1_uuid,
|
'payee_wallet': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
kwargs_category_uuid_payee_uuid = {
|
kwargs_payer_wallet = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'payer_wallet': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_category_uuid_payee_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_payer_wallet), data=data, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 201)
|
self.assertEqual(response.status_code, 201)
|
||||||
json_response = response.json()
|
json_response = response.json()
|
||||||
|
|
||||||
params = {
|
kwargs_verify = {
|
||||||
'uuid': json_response['uuid'],
|
'uuid': json_response['uuid'],
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'payer_wallet': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_deposit_verify_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_deposit_verify_api', kwargs=kwargs_verify), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response.json()['state'], 5)
|
self.assertEqual(response.json()['state'], 5)
|
||||||
|
|
||||||
# Desired results
|
# Desired results
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api', kwargs=kwargs_category_uuid_payee_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_account_balance_api'), query_params={'wallet': ','.join(wallets)}, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertGreater(response.json()['count'], 1)
|
||||||
self.assertEqual(response.json()['balance'], 200)
|
from_wallet = response.json()['results'][0]
|
||||||
|
self.assertEqual(from_wallet['balance'], 200)
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'uuid': self.payee_uuid,
|
'user': self.payee_uuid,
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_account_api', kwargs=params), query_params={'wallet': ','.join(wallets)}, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertGreater(response.json()['count'], 1)
|
||||||
self.assertEqual(response.json()['balance'], 100)
|
to_wallet = response.json()['results'][0]
|
||||||
|
self.assertEqual(to_wallet['balance'], 100)
|
||||||
|
|
||||||
def test_deposit_flow_category_success(self):
|
def test_deposit_flow_wallet_success(self):
|
||||||
auth = self._create_authorization_header(self.application_access_token.token)
|
auth = self._create_authorization_header(self.application_access_token.token)
|
||||||
|
|
||||||
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
||||||
kwargs_category_uuid = {
|
kwargs_wallet_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid
|
'wallet_uuid': self.wallet_rial_uuid
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api', kwargs=kwargs_category_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_account_balance_api', kwargs=kwargs_wallet_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 300)
|
self.assertEqual(response.json()['balance'], 300)
|
||||||
kwargs_category_uuid_payee_uuid = {
|
kwargs_wallet_uuid_payee_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
'uuid': self.payee_uuid,
|
'uuid': self.payee_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_category_uuid_payee_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_wallet_uuid_payee_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 0)
|
self.assertEqual(response.json()['balance'], 0)
|
||||||
|
|
||||||
|
|
@ -191,47 +195,49 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
'amount': 100,
|
'amount': 100,
|
||||||
'payee': self.payee_uuid,
|
'payee': self.payee_uuid,
|
||||||
'payee_type': TypeChoices.USER,
|
'payee_type': TypeChoices.USER,
|
||||||
'payee_wallet': self.wallet_category1_uuid
|
'payee_account': self.wallet_rial_uuid
|
||||||
}
|
}
|
||||||
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_category_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_wallet_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 201)
|
self.assertEqual(response.status_code, 201)
|
||||||
json_response = response.json()
|
json_response = response.json()
|
||||||
|
|
||||||
kwargs_category_uuid_transaction_uuid = {
|
kwargs_wallet_uuid_transaction_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
'uuid': json_response['uuid'],
|
'uuid': json_response['uuid'],
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_deposit_verify_api', kwargs=kwargs_category_uuid_transaction_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_deposit_verify_api', kwargs=kwargs_wallet_uuid_transaction_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response.json()['state'], 5)
|
self.assertEqual(response.json()['state'], 5)
|
||||||
|
|
||||||
# Desired results
|
# Desired results
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api', kwargs=kwargs_category_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_account_balance_api', kwargs=kwargs_wallet_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 200)
|
self.assertEqual(response.json()['balance'], 200)
|
||||||
|
|
||||||
kwargs_category_uuid_payee_uuid = {
|
kwargs_wallet_uuid_payee_uuid = {
|
||||||
'category_uuid': self.wallet_category2_uuid,
|
'wallet_uuid': self.wallet_reward_uuid,
|
||||||
'uuid': self.payee_uuid,
|
'uuid': self.payee_uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_category_uuid_payee_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_wallet_uuid_payee_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertGreater(response.json()['count'], 1)
|
||||||
self.assertEqual(response.json()['balance'], 0)
|
to_wallet = response.json()['results'][0]
|
||||||
|
self.assertEqual(to_wallet['balance'], 100)
|
||||||
|
|
||||||
|
|
||||||
def test_deposit_flow_insufficient_balance(self):
|
def test_deposit_flow_insufficient_balance(self):
|
||||||
auth = self._create_authorization_header(self.application_access_token.token)
|
auth = self._create_authorization_header(self.application_access_token.token)
|
||||||
|
|
||||||
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api'), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_account_balance_api'), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 300)
|
self.assertEqual(response.json()['balance'], 300)
|
||||||
params = {
|
params = {
|
||||||
'uuid': self.payee_uuid,
|
'uuid': self.payee_uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
kwargs_category_uuid_payee_uuid = {
|
kwargs_wallet_uuid_payee_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
||||||
|
|
@ -243,9 +249,9 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
'amount': 500,
|
'amount': 500,
|
||||||
'payee': self.payee_uuid,
|
'payee': self.payee_uuid,
|
||||||
'payee_type': TypeChoices.USER,
|
'payee_type': TypeChoices.USER,
|
||||||
'payee_wallet': self.wallet_category1_uuid
|
'payee_account': self.wallet_rial_uuid
|
||||||
}
|
}
|
||||||
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_category_uuid_payee_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_wallet_uuid_payee_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 422)
|
self.assertEqual(response.status_code, 422)
|
||||||
|
|
||||||
@override_settings(ALLOWED_NEGATIVE_BALANCE_APPLICATIONS=['b14e8b86-8f4a-44d9-b29d-badceb470053'])
|
@override_settings(ALLOWED_NEGATIVE_BALANCE_APPLICATIONS=['b14e8b86-8f4a-44d9-b29d-badceb470053'])
|
||||||
|
|
@ -253,12 +259,12 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
auth = self._create_authorization_header(self.application_access_token.token)
|
auth = self._create_authorization_header(self.application_access_token.token)
|
||||||
|
|
||||||
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api'), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_account_balance_api'), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 300)
|
self.assertEqual(response.json()['balance'], 300)
|
||||||
params = {
|
params = {
|
||||||
'uuid': self.payee_uuid,
|
'uuid': self.payee_uuid,
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
|
|
@ -269,18 +275,18 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
'amount': 500,
|
'amount': 500,
|
||||||
'payee': self.payee_uuid,
|
'payee': self.payee_uuid,
|
||||||
'payee_type': TypeChoices.USER,
|
'payee_type': TypeChoices.USER,
|
||||||
'payee_wallet': self.wallet_category1_uuid,
|
'payee_account': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
kwargs_category_uuid_payee_uuid = {
|
kwargs_wallet_uuid_payee_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_category_uuid_payee_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_wallet_uuid_payee_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 201)
|
self.assertEqual(response.status_code, 201)
|
||||||
|
|
||||||
def test_deposit_flow_zero_amount(self):
|
def test_deposit_flow_zero_amount(self):
|
||||||
# TODO: category
|
# TODO: wallet
|
||||||
auth = self._create_authorization_header(self.application_access_token.token)
|
auth = self._create_authorization_header(self.application_access_token.token)
|
||||||
|
|
||||||
# Deposit process
|
# Deposit process
|
||||||
|
|
@ -293,7 +299,7 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
self.assertEqual(response.status_code, 400)
|
self.assertEqual(response.status_code, 400)
|
||||||
|
|
||||||
def test_deposit_flow_negative_amount(self):
|
def test_deposit_flow_negative_amount(self):
|
||||||
# TODO: category
|
# TODO: wallet
|
||||||
auth = self._create_authorization_header(self.application_access_token.token)
|
auth = self._create_authorization_header(self.application_access_token.token)
|
||||||
|
|
||||||
# Deposit process
|
# Deposit process
|
||||||
|
|
@ -310,12 +316,12 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
auth = self._create_authorization_header(self.application_access_token.token)
|
auth = self._create_authorization_header(self.application_access_token.token)
|
||||||
|
|
||||||
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api'), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_account_balance_api'), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 300)
|
self.assertEqual(response.json()['balance'], 300)
|
||||||
params = {
|
params = {
|
||||||
'uuid': self.payee_uuid,
|
'uuid': self.payee_uuid,
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
|
|
@ -327,17 +333,17 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
'amount': 200,
|
'amount': 200,
|
||||||
'payee': self.payee_uuid,
|
'payee': self.payee_uuid,
|
||||||
'payee_type': TypeChoices.USER,
|
'payee_type': TypeChoices.USER,
|
||||||
'payee_wallet': self.wallet_category1_uuid,
|
'payee_account': self.wallet_rial_uuid,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kwargs_category_uuid_payee_uuid = {
|
kwargs_wallet_uuid_payee_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_category_uuid_payee_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_wallet_uuid_payee_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 201)
|
self.assertEqual(response.status_code, 201)
|
||||||
|
|
||||||
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_category_uuid_payee_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
response = self.client.post(reverse('wallet:application_deposit_submit_api', kwargs=kwargs_wallet_uuid_payee_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
||||||
# self.assertEqual(response.status_code, 422)
|
# self.assertEqual(response.status_code, 422)
|
||||||
self.assertEqual(response.status_code, 201)
|
self.assertEqual(response.status_code, 201)
|
||||||
|
|
||||||
|
|
@ -345,12 +351,12 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
auth = self._create_authorization_header(self.payer_access_token.token)
|
auth = self._create_authorization_header(self.payer_access_token.token)
|
||||||
|
|
||||||
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api'), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_account_balance_api'), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 300)
|
self.assertEqual(response.json()['balance'], 300)
|
||||||
params = {
|
params = {
|
||||||
'uuid': self.payer_uuid,
|
'uuid': self.payer_uuid,
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
|
|
@ -361,53 +367,53 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
'amount': 100,
|
'amount': 100,
|
||||||
'payer': self.payer_uuid,
|
'payer': self.payer_uuid,
|
||||||
'payer_type': TypeChoices.USER,
|
'payer_type': TypeChoices.USER,
|
||||||
'payer_wallet': self.wallet_category1_uuid,
|
'payer_account': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
kwargs_category_uuid = {
|
kwargs_wallet_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.post(reverse('wallet:application_withdraw_submit_api', kwargs=kwargs_category_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
response = self.client.post(reverse('wallet:application_withdraw_submit_api', kwargs=kwargs_wallet_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 201)
|
self.assertEqual(response.status_code, 201)
|
||||||
json_response = response.json()
|
json_response = response.json()
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'uuid': json_response['uuid'],
|
'uuid': json_response['uuid'],
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_withdraw_verify_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_withdraw_verify_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response.json()['state'], 5)
|
self.assertEqual(response.json()['state'], 5)
|
||||||
|
|
||||||
# Desired results
|
# Desired results
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api', kwargs=kwargs_category_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_account_balance_api', kwargs=kwargs_wallet_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 400)
|
self.assertEqual(response.json()['balance'], 400)
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'uuid': self.payer_uuid,
|
'uuid': self.payer_uuid,
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 200)
|
self.assertEqual(response.json()['balance'], 200)
|
||||||
|
|
||||||
def test_withdraw_flow_category_success(self):
|
def test_withdraw_flow_wallet_success(self):
|
||||||
auth = self._create_authorization_header(self.payer_access_token.token)
|
auth = self._create_authorization_header(self.payer_access_token.token)
|
||||||
|
|
||||||
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
||||||
kwargs_category_uuid = {
|
kwargs_wallet_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid
|
'wallet_uuid': self.wallet_rial_uuid
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api', kwargs=kwargs_category_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_account_balance_api', kwargs=kwargs_wallet_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 300)
|
self.assertEqual(response.json()['balance'], 300)
|
||||||
kwargs_category_uuid_payer_uuid = {
|
kwargs_wallet_uuid_payer_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
'uuid': self.payer_uuid,
|
'uuid': self.payer_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_category_uuid_payer_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_wallet_uuid_payer_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 300)
|
self.assertEqual(response.json()['balance'], 300)
|
||||||
|
|
||||||
|
|
@ -416,35 +422,35 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
'amount': 100,
|
'amount': 100,
|
||||||
'payer': self.payer_uuid,
|
'payer': self.payer_uuid,
|
||||||
'payer_type': TypeChoices.USER,
|
'payer_type': TypeChoices.USER,
|
||||||
'payer_wallet': self.wallet_category1_uuid,
|
'payer_account': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.post(reverse('wallet:application_withdraw_submit_api', kwargs=kwargs_category_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
response = self.client.post(reverse('wallet:application_withdraw_submit_api', kwargs=kwargs_wallet_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 201)
|
self.assertEqual(response.status_code, 201)
|
||||||
json_response = response.json()
|
json_response = response.json()
|
||||||
|
|
||||||
kwargs_category_uuid_transaction_uuid = {
|
kwargs_wallet_uuid_transaction_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
'uuid': json_response['uuid'],
|
'uuid': json_response['uuid'],
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_withdraw_verify_api', kwargs=kwargs_category_uuid_transaction_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_withdraw_verify_api', kwargs=kwargs_wallet_uuid_transaction_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response.json()['state'], 5)
|
self.assertEqual(response.json()['state'], 5)
|
||||||
|
|
||||||
# Desired results
|
# Desired results
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api', kwargs=kwargs_category_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_account_balance_api', kwargs=kwargs_wallet_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 400)
|
self.assertEqual(response.json()['balance'], 400)
|
||||||
|
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_category_uuid_payer_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_wallet_uuid_payer_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 200)
|
self.assertEqual(response.json()['balance'], 200)
|
||||||
|
|
||||||
kwargs_category_uuid_payer_uuid = {
|
kwargs_wallet_uuid_payer_uuid = {
|
||||||
'category_uuid': self.wallet_category2_uuid,
|
'wallet_uuid': self.wallet_reward_uuid,
|
||||||
'uuid': self.payer_uuid,
|
'uuid': self.payer_uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_category_uuid_payer_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_wallet_uuid_payer_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 300)
|
self.assertEqual(response.json()['balance'], 300)
|
||||||
|
|
||||||
|
|
@ -456,12 +462,12 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
'amount': 0,
|
'amount': 0,
|
||||||
'payer': self.payer_uuid,
|
'payer': self.payer_uuid,
|
||||||
'payer_type': TypeChoices.USER,
|
'payer_type': TypeChoices.USER,
|
||||||
'payer_wallet': self.wallet_category1_uuid,
|
'payer_account': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
kwargs_category_uuid = {
|
kwargs_wallet_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.post(reverse('wallet:application_withdraw_submit_api', kwargs=kwargs_category_uuid), data=data,
|
response = self.client.post(reverse('wallet:application_withdraw_submit_api', kwargs=kwargs_wallet_uuid), data=data,
|
||||||
HTTP_AUTHORIZATION=auth)
|
HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 400)
|
self.assertEqual(response.status_code, 400)
|
||||||
|
|
||||||
|
|
@ -481,16 +487,16 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
def test_withdraw_flow_prevent_double_spending(self):
|
def test_withdraw_flow_prevent_double_spending(self):
|
||||||
auth = self._create_authorization_header(self.payer_access_token.token)
|
auth = self._create_authorization_header(self.payer_access_token.token)
|
||||||
|
|
||||||
kwargs_category_uuid = {
|
kwargs_wallet_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
||||||
response = self.client.get(reverse('wallet:application_wallet_balance_api', kwargs=kwargs_category_uuid), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_account_balance_api', kwargs=kwargs_wallet_uuid), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
self.assertEqual(response.json()['balance'], 300)
|
self.assertEqual(response.json()['balance'], 300)
|
||||||
params = {
|
params = {
|
||||||
'uuid': self.payer_uuid,
|
'uuid': self.payer_uuid,
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=params), HTTP_AUTHORIZATION=auth)
|
||||||
self.assertContains(response, 'balance')
|
self.assertContains(response, 'balance')
|
||||||
|
|
@ -502,16 +508,16 @@ class ApplicationApiFlowsTests(APITestCase):
|
||||||
'amount': 200,
|
'amount': 200,
|
||||||
'payer': self.payer_uuid,
|
'payer': self.payer_uuid,
|
||||||
'payer_type': TypeChoices.USER,
|
'payer_type': TypeChoices.USER,
|
||||||
'payer_wallet': self.wallet_category1_uuid,
|
'payer_account': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
kwargs_category_uuid = {
|
kwargs_wallet_uuid = {
|
||||||
'category_uuid': self.wallet_category1_uuid,
|
'wallet_uuid': self.wallet_rial_uuid,
|
||||||
}
|
}
|
||||||
response = self.client.post(reverse('wallet:application_withdraw_submit_api', kwargs=kwargs_category_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
response = self.client.post(reverse('wallet:application_withdraw_submit_api', kwargs=kwargs_wallet_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 201)
|
self.assertEqual(response.status_code, 201)
|
||||||
|
|
||||||
response = self.client.post(reverse('wallet:application_withdraw_submit_api', kwargs=kwargs_category_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
response = self.client.post(reverse('wallet:application_withdraw_submit_api', kwargs=kwargs_wallet_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
||||||
self.assertEqual(response.status_code, 201)
|
self.assertEqual(response.status_code, 201)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,29 +11,29 @@ user_urlpatterns = [
|
||||||
# path('api/wallet/balance', user_views.WalletMyAccountBalanceView.as_view(), name='user_wallet_balance_api'),
|
# path('api/wallet/balance', user_views.WalletMyAccountBalanceView.as_view(), name='user_wallet_balance_api'),
|
||||||
path('api/transactions/', user_views.TransactionListAPIView.as_view(), name='transaction_list_api'),
|
path('api/transactions/', user_views.TransactionListAPIView.as_view(), name='transaction_list_api'),
|
||||||
|
|
||||||
# path('api/user/<category_uuid>/balance', user_views.WalletMyAccountBalanceView.as_view(), name='user_wallet_balance_api'),
|
# path('api/user/<wallet_uuid>/balance', user_views.WalletMyAccountBalanceView.as_view(), name='user_wallet_balance_api'),
|
||||||
path('api/user/<category_uuid>/transactions/', user_views.CategoryTransactionListView.as_view(), name='transaction_list_api'),
|
path('api/user/<wallet_uuid>/transactions/', user_views.WalletTransactionListView.as_view(), name='transaction_list_api'),
|
||||||
]
|
]
|
||||||
|
|
||||||
application_urlpatterns = [
|
application_urlpatterns = [
|
||||||
path('api/application/accounts/', application_views.AccountListAPIView.as_view(), name='application_accounts_balance_api'),
|
path('api/application/accounts/', application_views.AccountListAPIView.as_view(), name='application_account_balance_api'),
|
||||||
path('api/application/user/<user_uuid>/accounts/', application_views.UserAccountListAPIView.as_view(), name='application_user_account_api'),
|
path('api/application/user/<user>/accounts/', application_views.UserAccountListAPIView.as_view(), name='application_user_account_api'),
|
||||||
|
|
||||||
# path('api/application/', application_views.TransactionListAPIView.as_view(), name='application_transaction_list_api'),
|
# path('api/application/', application_views.TransactionListAPIView.as_view(), name='application_transaction_list_api'),
|
||||||
# path('api/application/<uuid>/', application_views.TransactionDetailAPIView.as_view(), name='application_transaction_detail'),
|
# path('api/application/<uuid>/', application_views.TransactionDetailAPIView.as_view(), name='application_transaction_detail'),
|
||||||
|
|
||||||
|
|
||||||
# path('api/application/<category_uuid>/wallet', application_views.BalanceAPIView.as_view(), name='application_wallet_balance_api'),
|
# path('api/application/<wallet_uuid>/wallet', application_views.BalanceAPIView.as_view(), name='application_wallet_balance_api'),
|
||||||
# path('api/application/<category_uuid>/user/<user_uuid>/wallet', application_views.UserBalanceAPIView.as_view(), name='application_user_wallet_balance_api'),
|
# path('api/application/<wallet_uuid>/user/<user_uuid>/wallet', application_views.UserBalanceAPIView.as_view(), name='application_user_wallet_balance_api'),
|
||||||
|
|
||||||
path('api/application/<category_uuid>/deposit/', application_views.DepositSubmitAPIView.as_view(), name='application_deposit_submit_api'),
|
path('api/application/<payer_wallet>/deposit/', application_views.DepositSubmitAPIView.as_view(), name='application_deposit_submit_api'),
|
||||||
path('api/application/<category_uuid>/deposit/<uuid>/verify', application_views.DepositVerifyAPIView.as_view(), name='application_deposit_verify_api'),
|
path('api/application/<payer_wallet>/deposit/<uuid>/verify', application_views.DepositVerifyAPIView.as_view(), name='application_deposit_verify_api'),
|
||||||
|
|
||||||
path('api/application/<category_uuid>/withdraw/', application_views.WithdrawSubmitAPIView.as_view(), name='application_withdraw_submit_api'),
|
path('api/application/<wallet_uuid>/withdraw/', application_views.WithdrawSubmitAPIView.as_view(), name='application_withdraw_submit_api'),
|
||||||
path('api/application/<category_uuid>/withdraw/<uuid>/verify', application_views.WithdrawVerifyAPIView.as_view(), name='application_withdraw_verify_api'),
|
path('api/application/<wallet_uuid>/withdraw/<uuid>/verify', application_views.WithdrawVerifyAPIView.as_view(), name='application_withdraw_verify_api'),
|
||||||
|
|
||||||
path('api/application/<category_uuid>/', application_views.CategoryTransactionListAPIView.as_view(), name='application_transaction_list_api'),
|
path('api/application/<wallet_uuid>/', application_views.WalletTransactionListAPIView.as_view(), name='application_transaction_list_api'),
|
||||||
path('api/application/<category_uuid>/<uuid>/', application_views.CategoryTransactionDetailAPIView.as_view(), name='application_transaction_detail'),
|
path('api/application/<wallet_uuid>/<uuid>/', application_views.WalletTransactionDetailAPIView.as_view(), name='application_transaction_detail'),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,26 +40,19 @@ class AccountListAPIView(generics.ListAPIView):
|
||||||
required_scopes = ['wallet.application:get_balance']
|
required_scopes = ['wallet.application:get_balance']
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
category_uuid = self.kwargs.get('category_uuid')
|
wallet_uuid = self.kwargs.get('wallet')
|
||||||
if category_uuid:
|
if wallet_uuid:
|
||||||
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
|
wallet = get_object_or_404(Wallet.objects.all(), uuid=wallet_uuid)
|
||||||
else:
|
else:
|
||||||
category = None
|
wallet = None
|
||||||
|
|
||||||
application = get_application(self.request)
|
application = get_application(self.request)
|
||||||
account, created = Account.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION,
|
account, created = Account.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION,
|
||||||
category=category)
|
wallet=wallet)
|
||||||
return account
|
return account
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
category_uuid = self.kwargs.get('category_uuid')
|
|
||||||
if category_uuid:
|
|
||||||
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
|
|
||||||
else:
|
|
||||||
category = None
|
|
||||||
application = get_application(self.request)
|
application = get_application(self.request)
|
||||||
wallet, created = Account.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION,
|
|
||||||
category=category)
|
|
||||||
return Account.objects.filter(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION).all()
|
return Account.objects.filter(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION).all()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -77,15 +70,8 @@ class UserAccountListAPIView(generics.ListAPIView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
qs = super().get_queryset()
|
qs = super().get_queryset()
|
||||||
category_uuid = self.kwargs.get('category_uuid')
|
user_uuid = self.kwargs.get('user')
|
||||||
user_uuid = self.kwargs.get('user_uuid')
|
|
||||||
if category_uuid:
|
|
||||||
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
|
|
||||||
else:
|
|
||||||
category = None
|
|
||||||
user, created = User.objects.get_or_create(uuid=self.kwargs.get('uuid'))
|
user, created = User.objects.get_or_create(uuid=self.kwargs.get('uuid'))
|
||||||
wallet, created = Account.objects.get_or_create(owner_uuid=user_uuid, owner_type=TypeChoices.USER,
|
|
||||||
category=category)
|
|
||||||
return qs.filter(owner_uuid=user_uuid, owner_type=TypeChoices.USER).all()
|
return qs.filter(owner_uuid=user_uuid, owner_type=TypeChoices.USER).all()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -133,7 +119,7 @@ class TransactionListAPIView(generics.ListAPIView):
|
||||||
)
|
)
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
class CategoryTransactionDetailAPIView(generics.RetrieveAPIView):
|
class WalletTransactionDetailAPIView(generics.RetrieveAPIView):
|
||||||
permission_classes = [TokenHasScope]
|
permission_classes = [TokenHasScope]
|
||||||
serializer_class = TransactionSerializer
|
serializer_class = TransactionSerializer
|
||||||
lookup_field = 'uuid'
|
lookup_field = 'uuid'
|
||||||
|
|
@ -143,24 +129,24 @@ class CategoryTransactionDetailAPIView(generics.RetrieveAPIView):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
qs = super().get_queryset()
|
qs = super().get_queryset()
|
||||||
|
|
||||||
category_uuid = self.kwargs.get('category_uuid')
|
wallet_uuid = self.kwargs.get('wallet_uuid')
|
||||||
if category_uuid:
|
if wallet_uuid:
|
||||||
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
|
wallet = get_object_or_404(Wallet.objects.all(), uuid=wallet_uuid)
|
||||||
else:
|
else:
|
||||||
category = None
|
wallet = None
|
||||||
|
|
||||||
application = get_application(self.request)
|
application = get_application(self.request)
|
||||||
return Transaction.objects.filter(Q(application=application) |
|
return Transaction.objects.filter(Q(application=application) |
|
||||||
Q(payer_account__owner_uuid=application.pk,
|
Q(payer_account__owner_uuid=application.pk,
|
||||||
payer_account__owner_type=TypeChoices.APPLICATION,
|
payer_account__owner_type=TypeChoices.APPLICATION,
|
||||||
payer_account__category=category) |
|
payer_account__wallet=wallet) |
|
||||||
Q(payee_account__owner_uuid=application.pk,
|
Q(payee_account__owner_uuid=application.pk,
|
||||||
payee_account__owner_type=TypeChoices.APPLICATION,
|
payee_account__owner_type=TypeChoices.APPLICATION,
|
||||||
payee_account__category=category)
|
payee_account__wallet=wallet)
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
|
|
||||||
class CategoryTransactionListAPIView(generics.ListAPIView):
|
class WalletTransactionListAPIView(generics.ListAPIView):
|
||||||
permission_classes = [TokenHasScope]
|
permission_classes = [TokenHasScope]
|
||||||
serializer_class = TransactionSerializer
|
serializer_class = TransactionSerializer
|
||||||
lookup_field = 'uuid'
|
lookup_field = 'uuid'
|
||||||
|
|
@ -170,20 +156,20 @@ class CategoryTransactionListAPIView(generics.ListAPIView):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
qs = super().get_queryset()
|
qs = super().get_queryset()
|
||||||
|
|
||||||
category_uuid = self.kwargs.get('category_uuid')
|
wallet_uuid = self.kwargs.get('wallet_uuid')
|
||||||
if category_uuid:
|
if wallet_uuid:
|
||||||
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
|
wallet = get_object_or_404(Wallet.objects.all(), uuid=wallet_uuid)
|
||||||
else:
|
else:
|
||||||
category = None
|
wallet = None
|
||||||
|
|
||||||
application = get_application(self.request)
|
application = get_application(self.request)
|
||||||
return qs.filter(Q(application=application) |
|
return qs.filter(Q(application=application) |
|
||||||
Q(payer_account__owner_uuid=application.pk,
|
Q(payer_account__owner_uuid=application.pk,
|
||||||
payer_account__owner_type=TypeChoices.APPLICATION,
|
payer_account__owner_type=TypeChoices.APPLICATION,
|
||||||
payer_account__category=category) |
|
payer_account__wallet=wallet) |
|
||||||
Q(payee_account__owner_uuid=application.pk,
|
Q(payee_account__owner_uuid=application.pk,
|
||||||
payee_account__owner_type=TypeChoices.APPLICATION,
|
payee_account__owner_type=TypeChoices.APPLICATION,
|
||||||
payee_account__category=category)
|
payee_account__wallet=wallet)
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -195,14 +181,14 @@ class DepositSubmitAPIView(generics.CreateAPIView):
|
||||||
required_scopes = ['wallet.application.deposit:submit']
|
required_scopes = ['wallet.application.deposit:submit']
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
category_uuid = self.kwargs.get('category_uuid')
|
wallet_uuid = self.kwargs.get('wallet_uuid')
|
||||||
if category_uuid:
|
if wallet_uuid:
|
||||||
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
|
wallet = get_object_or_404(Wallet.objects.all(), uuid=wallet_uuid)
|
||||||
else:
|
else:
|
||||||
category = None
|
wallet = None
|
||||||
application = get_application(self.request)
|
application = get_application(self.request)
|
||||||
payer_account, created = Account.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION,
|
payer_account, created = Account.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION,
|
||||||
category=category)
|
wallet=wallet)
|
||||||
return Transaction.objects.filter(application=application, payer_account=payer_account).all()
|
return Transaction.objects.filter(application=application, payer_account=payer_account).all()
|
||||||
|
|
||||||
def perform_create(self, serializer):
|
def perform_create(self, serializer):
|
||||||
|
|
@ -211,29 +197,23 @@ class DepositSubmitAPIView(generics.CreateAPIView):
|
||||||
logger.info("Starting perform_create for Transaction")
|
logger.info("Starting perform_create for Transaction")
|
||||||
application = get_application(self.request)
|
application = get_application(self.request)
|
||||||
logger.debug(f"Application UUID: {application.uuid}")
|
logger.debug(f"Application UUID: {application.uuid}")
|
||||||
|
payer_wallet_uuid = self.kwargs.get('payer_wallet')
|
||||||
payee_wallet_uuid = serializer.validated_data.pop('payee_wallet')
|
|
||||||
payee_wallet_uuid = payee_wallet_uuid and str(payee_wallet_uuid)
|
|
||||||
|
|
||||||
payer_wallet_uuid = self.kwargs.get('wallet_uuid')
|
|
||||||
|
|
||||||
if payer_wallet_uuid:
|
if payer_wallet_uuid:
|
||||||
payer_wallet = get_object_or_404(Category.objects.all(), uuid=payer_wallet_uuid)
|
payer_wallet = get_object_or_404(Wallet.objects.all(), uuid=payer_wallet_uuid)
|
||||||
else:
|
else:
|
||||||
payer_wallet = None
|
payer_wallet = None
|
||||||
|
payee_wallet_uuid = serializer.validated_data.pop('payee_wallet')
|
||||||
payee_wallet = get_object_or_404(Category.objects.all(), uuid=payee_wallet_uuid)
|
payee_wallet_uuid = payee_wallet_uuid and str(payee_wallet_uuid)
|
||||||
|
payee_wallet = get_object_or_404(Wallet.objects.all(), uuid=payee_wallet_uuid)
|
||||||
if not (payee_wallet and payee_wallet.currency == payer_wallet.currency):
|
if not (payee_wallet and payee_wallet.currency == payer_wallet.currency):
|
||||||
raise UnprocessableEntity('payer and payee wallet currency not equal')
|
raise UnprocessableEntity('payer and payee wallet currency not equal')
|
||||||
|
|
||||||
payee_id = serializer.validated_data.pop('payee')
|
payee_id = serializer.validated_data.pop('payee')
|
||||||
payee_type = serializer.validated_data.pop('payee_type')
|
payee_type = serializer.validated_data.pop('payee_type')
|
||||||
payer_account, _ = Account.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION,
|
payer_account, _ = Account.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION,
|
||||||
category=payer_wallet)
|
wallet=payer_wallet)
|
||||||
logger.debug(f"Payer account: {payer_account.uuid}")
|
logger.debug(f"Payer account: {payer_account.uuid}")
|
||||||
payee_account, _ = Account.objects.get_or_create(owner_uuid=payee_id, owner_type=payee_type,
|
payee_account, _ = Account.objects.get_or_create(owner_uuid=payee_id, owner_type=payee_type,
|
||||||
category=payee_wallet)
|
wallet=payee_wallet)
|
||||||
logger.debug(f"Payee account: {payee_account.uuid}")
|
logger.debug(f"Payee account: {payee_account.uuid}")
|
||||||
uuid = serializer.validated_data.pop('uuid', None)
|
uuid = serializer.validated_data.pop('uuid', None)
|
||||||
|
|
||||||
|
|
@ -278,12 +258,12 @@ class DepositVerifyAPIView(generics.RetrieveAPIView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
application = get_application(self.request)
|
application = get_application(self.request)
|
||||||
category_uuid = self.kwargs.get('category_uuid')
|
payer_wallet_uuid = self.kwargs.get('payer_wallet')
|
||||||
if category_uuid:
|
if payer_wallet_uuid:
|
||||||
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
|
wallet = get_object_or_404(Wallet.objects.all(), uuid=payer_wallet_uuid)
|
||||||
else:
|
else:
|
||||||
category = None
|
wallet = None
|
||||||
account = Account.objects.get(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION, category=category)
|
account = Account.objects.get(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION, wallet=wallet)
|
||||||
return Transaction.objects.filter(application=application, payer_account=account).all()
|
return Transaction.objects.filter(application=application, payer_account=account).all()
|
||||||
|
|
||||||
def retrieve(self, request, *args, **kwargs):
|
def retrieve(self, request, *args, **kwargs):
|
||||||
|
|
@ -302,14 +282,14 @@ class WithdrawSubmitAPIView(generics.CreateAPIView):
|
||||||
required_scopes = ['wallet.application.withdraw:submit']
|
required_scopes = ['wallet.application.withdraw:submit']
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
category_uuid = self.kwargs.get('category_uuid')
|
wallet_uuid = self.kwargs.get('wallet_uuid')
|
||||||
if category_uuid:
|
if wallet_uuid:
|
||||||
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
|
wallet = get_object_or_404(Wallet.objects.all(), uuid=wallet_uuid)
|
||||||
else:
|
else:
|
||||||
category = None
|
wallet = None
|
||||||
application = get_application(self.request)
|
application = get_application(self.request)
|
||||||
payee_account, created = Account.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION,
|
payee_account, created = Account.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION,
|
||||||
category=category)
|
wallet=wallet)
|
||||||
return Transaction.objects.filter(application=application, payee_account=payee_account).all()
|
return Transaction.objects.filter(application=application, payee_account=payee_account).all()
|
||||||
|
|
||||||
def perform_create(self, serializer):
|
def perform_create(self, serializer):
|
||||||
|
|
@ -322,14 +302,14 @@ class WithdrawSubmitAPIView(generics.CreateAPIView):
|
||||||
payer_wallet_uuid = serializer.validated_data.pop('payer_wallet')
|
payer_wallet_uuid = serializer.validated_data.pop('payer_wallet')
|
||||||
payer_wallet_uuid = payer_wallet_uuid and str(payer_wallet_uuid)
|
payer_wallet_uuid = payer_wallet_uuid and str(payer_wallet_uuid)
|
||||||
|
|
||||||
payee_wallet_uuid = self.kwargs.get('category_uuid')
|
payee_wallet_uuid = self.kwargs.get('wallet_uuid')
|
||||||
|
|
||||||
if payee_wallet_uuid:
|
if payee_wallet_uuid:
|
||||||
payee_wallet = get_object_or_404(Category.objects.all(), uuid=payee_wallet_uuid)
|
payee_wallet = get_object_or_404(Wallet.objects.all(), uuid=payee_wallet_uuid)
|
||||||
else:
|
else:
|
||||||
payee_wallet = None
|
payee_wallet = None
|
||||||
|
|
||||||
payer_wallet = get_object_or_404(Category.objects.all(), uuid=payer_wallet_uuid)
|
payer_wallet = get_object_or_404(Wallet.objects.all(), uuid=payer_wallet_uuid)
|
||||||
|
|
||||||
if not (payer_wallet and payer_wallet.currency == payee_wallet.currency):
|
if not (payer_wallet and payer_wallet.currency == payee_wallet.currency):
|
||||||
raise UnprocessableEntity('payer and payee wallet currency not equal')
|
raise UnprocessableEntity('payer and payee wallet currency not equal')
|
||||||
|
|
@ -337,10 +317,10 @@ class WithdrawSubmitAPIView(generics.CreateAPIView):
|
||||||
payer_id = serializer.validated_data.pop('payer')
|
payer_id = serializer.validated_data.pop('payer')
|
||||||
payer_type = serializer.validated_data.pop('payer_type')
|
payer_type = serializer.validated_data.pop('payer_type')
|
||||||
payee_account, _ = Account.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION,
|
payee_account, _ = Account.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION,
|
||||||
category=payee_wallet)
|
wallet=payee_wallet)
|
||||||
logger.debug(f"Payee account: {payee_account.uuid}")
|
logger.debug(f"Payee account: {payee_account.uuid}")
|
||||||
payer_account, _ = Account.objects.get_or_create(owner_uuid=payer_id, owner_type=payer_type,
|
payer_account, _ = Account.objects.get_or_create(owner_uuid=payer_id, owner_type=payer_type,
|
||||||
category=payer_wallet)
|
wallet=payer_wallet)
|
||||||
logger.debug(f"Payer account: {payer_account.uuid}")
|
logger.debug(f"Payer account: {payer_account.uuid}")
|
||||||
|
|
||||||
uuid = serializer.validated_data.pop('uuid', None)
|
uuid = serializer.validated_data.pop('uuid', None)
|
||||||
|
|
@ -388,12 +368,12 @@ class WithdrawVerifyAPIView(generics.RetrieveAPIView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
application = get_application(self.request)
|
application = get_application(self.request)
|
||||||
category_uuid = self.kwargs.get('category_uuid')
|
wallet_uuid = self.kwargs.get('wallet_uuid')
|
||||||
if category_uuid:
|
if wallet_uuid:
|
||||||
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
|
wallet = get_object_or_404(Wallet.objects.all(), uuid=wallet_uuid)
|
||||||
else:
|
else:
|
||||||
category = None
|
wallet = None
|
||||||
payee_account = Account.objects.get(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION, category=category)
|
payee_account = Account.objects.get(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION, wallet=wallet)
|
||||||
return Transaction.objects.filter(application=application, payee_wallet=payee_account).all()
|
return Transaction.objects.filter(application=application, payee_wallet=payee_account).all()
|
||||||
|
|
||||||
def retrieve(self, request, *args, **kwargs):
|
def retrieve(self, request, *args, **kwargs):
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ class TransactionDetailView(UpdateView):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CategoryMyAccountBalanceView(generics.RetrieveAPIView):
|
class WalletMyAccountBalanceView(generics.RetrieveAPIView):
|
||||||
'''
|
'''
|
||||||
API for getting authenticated user balance.
|
API for getting authenticated user balance.
|
||||||
'''
|
'''
|
||||||
|
|
@ -237,14 +237,14 @@ class CategoryMyAccountBalanceView(generics.RetrieveAPIView):
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
user = self.request.user
|
user = self.request.user
|
||||||
category_uuid = self.kwargs.get('category_uuid')
|
wallet_uuid = self.kwargs.get('wallet_uuid')
|
||||||
if category_uuid:
|
if wallet_uuid:
|
||||||
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
|
wallet = get_object_or_404(Wallet.objects.all(), uuid=wallet_uuid)
|
||||||
else:
|
else:
|
||||||
category = None
|
wallet = None
|
||||||
|
|
||||||
wallet, created = Account.objects.get_or_create(owner_uuid=user.uuid, owner_type=TypeChoices.USER,
|
wallet, created = Account.objects.get_or_create(owner_uuid=user.uuid, owner_type=TypeChoices.USER,
|
||||||
category=category)
|
wallet=wallet)
|
||||||
return wallet
|
return wallet
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -275,7 +275,7 @@ class TransactionListAPIView(generics.ListAPIView):
|
||||||
Q(payer_wallet__owner_uuid=user.uuid)).all()
|
Q(payer_wallet__owner_uuid=user.uuid)).all()
|
||||||
|
|
||||||
|
|
||||||
class CategoryTransactionListView(generics.ListAPIView):
|
class WalletTransactionListView(generics.ListAPIView):
|
||||||
'''
|
'''
|
||||||
GET: API for getting list of transactions for authenticated user
|
GET: API for getting list of transactions for authenticated user
|
||||||
POST: API for creating transaction for transferring funds from authenticated user to application owner. (deprecated)
|
POST: API for creating transaction for transferring funds from authenticated user to application owner. (deprecated)
|
||||||
|
|
@ -295,14 +295,14 @@ class CategoryTransactionListView(generics.ListAPIView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
user = self.request.user
|
user = self.request.user
|
||||||
category_uuid = self.kwargs.get('category_uuid')
|
wallet_uuid = self.kwargs.get('wallet_uuid')
|
||||||
if category_uuid:
|
if wallet_uuid:
|
||||||
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
|
wallet = get_object_or_404(Wallet.objects.all(), uuid=wallet_uuid)
|
||||||
else:
|
else:
|
||||||
category = None
|
wallet = None
|
||||||
|
|
||||||
wallet, created = Account.objects.get_or_create(owner_uuid=user.uuid, owner_type=TypeChoices.USER,
|
wallet, created = Account.objects.get_or_create(owner_uuid=user.uuid, owner_type=TypeChoices.USER,
|
||||||
category=category)
|
wallet=wallet)
|
||||||
|
|
||||||
return Transaction.objects.filter(Q(payee_wallet=wallet) |
|
return Transaction.objects.filter(Q(payee_wallet=wallet) |
|
||||||
Q(payer_wallet=wallet)).all()
|
Q(payer_wallet=wallet)).all()
|
||||||
|
|
|
||||||
2
static/admin/js/vendor/jquery/jquery.js
vendored
2
static/admin/js/vendor/jquery/jquery.js
vendored
|
|
@ -1031,7 +1031,7 @@ function createDisabledPseudo( disabled ) {
|
||||||
|
|
||||||
// Check for inherited disabledness on relevant non-disabled elements:
|
// Check for inherited disabledness on relevant non-disabled elements:
|
||||||
// * listed form-associated elements in a disabled fieldset
|
// * listed form-associated elements in a disabled fieldset
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
|
// https://html.spec.whatwg.org/multipage/forms.html#wallet-listed
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
|
// https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
|
||||||
// * option elements in a disabled optgroup
|
// * option elements in a disabled optgroup
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
|
// https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue