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):
|
||||
|
||||
@@ -4,7 +4,7 @@ from datetime import timedelta
|
||||
|
||||
from django.db import transaction
|
||||
from django.utils.timezone import now
|
||||
from rest_framework import status, filters
|
||||
from rest_framework import status
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.exceptions import APIException
|
||||
@@ -70,7 +70,7 @@ class ProviderCompanyViewSet(SoftDeleteMixin, viewsets.ModelViewSet): # noqa
|
||||
class DeviceViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, AdminFilterMixin):
|
||||
queryset = pos_models.Device.objects.all()
|
||||
serializer_class = device_serializer.DeviceSerializer
|
||||
filter_backends = [filters.SearchFilter]
|
||||
# filter_backends = [filters.SearchFilter]
|
||||
search_fields = [
|
||||
'device_identity',
|
||||
'acceptor',
|
||||
@@ -78,6 +78,7 @@ class DeviceViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, AdminFi
|
||||
'mac',
|
||||
'serial',
|
||||
'organization__name',
|
||||
'assignment__client__organization__name'
|
||||
]
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
|
||||
@@ -131,7 +131,7 @@ class InventoryEntryViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet,
|
||||
class InventoryQuotaSaleTransactionViewSet(BaseViewSet, SoftDeleteMixin, DynamicSearchMixin, viewsets.ModelViewSet):
|
||||
queryset = warehouse_models.InventoryQuotaSaleTransaction.objects.all()
|
||||
serializer_class = warehouse_serializers.InventoryQuotaSaleTransactionSerializer
|
||||
filter_backends = [filters.SearchFilter]
|
||||
# filter_backends = [filters.SearchFilter]
|
||||
search_fields = [
|
||||
'rancher_fullname', 'rancher_mobile', 'pos_device__device_identity',
|
||||
'pos_device__acceptor', 'pos_device__terminal', 'pos_device__serial',
|
||||
|
||||
Reference in New Issue
Block a user