fix - change bank account validations / my devices search / transactions search
This commit is contained in:
@@ -5,8 +5,7 @@ from django.db.models import Q
|
||||
from rest_framework import serializers
|
||||
|
||||
from apps.authentication.exceptions import UserExistException, OrganizationNationalUniqueIDException, \
|
||||
OrganizationTypeRepeatableException, BankAccountExistException, BankAccountNumberAccountException, \
|
||||
BankAccountCardException, BankAccountShebaException
|
||||
OrganizationTypeRepeatableException
|
||||
from apps.authentication.models import (
|
||||
User,
|
||||
City,
|
||||
@@ -57,21 +56,21 @@ class BankAccountSerializer(serializers.ModelSerializer):
|
||||
card = attrs['card']
|
||||
sheba = attrs['sheba']
|
||||
|
||||
if not self.instance:
|
||||
if self.Meta.model.objects.filter(Q(account=account) | Q(card=card) | Q(sheba=sheba)).exists():
|
||||
raise BankAccountExistException()
|
||||
elif self.instance:
|
||||
if self.instance.account != account:
|
||||
if self.Meta.model.objects.filter(Q(account=account)).exists():
|
||||
raise BankAccountNumberAccountException()
|
||||
|
||||
elif self.instance.card != card:
|
||||
if self.Meta.model.objects.filter(Q(card=card)).exists():
|
||||
raise BankAccountCardException()
|
||||
|
||||
elif self.instance.sheba != sheba:
|
||||
if self.Meta.model.objects.filter(Q(sheba=sheba)).exists():
|
||||
raise BankAccountShebaException()
|
||||
# if not self.instance:
|
||||
# if self.Meta.model.objects.filter(Q(account=account) | Q(card=card) | Q(sheba=sheba)).exists():
|
||||
# raise BankAccountExistException()
|
||||
# elif self.instance:
|
||||
# if self.instance.account != account:
|
||||
# if self.Meta.model.objects.filter(Q(account=account)).exists():
|
||||
# raise BankAccountNumberAccountException()
|
||||
#
|
||||
# elif self.instance.card != card:
|
||||
# if self.Meta.model.objects.filter(Q(card=card)).exists():
|
||||
# raise BankAccountCardException()
|
||||
#
|
||||
# elif self.instance.sheba != sheba:
|
||||
# if self.Meta.model.objects.filter(Q(sheba=sheba)).exists():
|
||||
# raise BankAccountShebaException()
|
||||
return attrs
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
|
||||
Reference in New Issue
Block a user