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 rest_framework import serializers
|
||||||
|
|
||||||
from apps.authentication.exceptions import UserExistException, OrganizationNationalUniqueIDException, \
|
from apps.authentication.exceptions import UserExistException, OrganizationNationalUniqueIDException, \
|
||||||
OrganizationTypeRepeatableException, BankAccountExistException, BankAccountNumberAccountException, \
|
OrganizationTypeRepeatableException
|
||||||
BankAccountCardException, BankAccountShebaException
|
|
||||||
from apps.authentication.models import (
|
from apps.authentication.models import (
|
||||||
User,
|
User,
|
||||||
City,
|
City,
|
||||||
@@ -57,21 +56,21 @@ class BankAccountSerializer(serializers.ModelSerializer):
|
|||||||
card = attrs['card']
|
card = attrs['card']
|
||||||
sheba = attrs['sheba']
|
sheba = attrs['sheba']
|
||||||
|
|
||||||
if not self.instance:
|
# if not self.instance:
|
||||||
if self.Meta.model.objects.filter(Q(account=account) | Q(card=card) | Q(sheba=sheba)).exists():
|
# if self.Meta.model.objects.filter(Q(account=account) | Q(card=card) | Q(sheba=sheba)).exists():
|
||||||
raise BankAccountExistException()
|
# raise BankAccountExistException()
|
||||||
elif self.instance:
|
# elif self.instance:
|
||||||
if self.instance.account != account:
|
# if self.instance.account != account:
|
||||||
if self.Meta.model.objects.filter(Q(account=account)).exists():
|
# if self.Meta.model.objects.filter(Q(account=account)).exists():
|
||||||
raise BankAccountNumberAccountException()
|
# raise BankAccountNumberAccountException()
|
||||||
|
#
|
||||||
elif self.instance.card != card:
|
# elif self.instance.card != card:
|
||||||
if self.Meta.model.objects.filter(Q(card=card)).exists():
|
# if self.Meta.model.objects.filter(Q(card=card)).exists():
|
||||||
raise BankAccountCardException()
|
# raise BankAccountCardException()
|
||||||
|
#
|
||||||
elif self.instance.sheba != sheba:
|
# elif self.instance.sheba != sheba:
|
||||||
if self.Meta.model.objects.filter(Q(sheba=sheba)).exists():
|
# if self.Meta.model.objects.filter(Q(sheba=sheba)).exists():
|
||||||
raise BankAccountShebaException()
|
# raise BankAccountShebaException()
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.utils.timezone import now
|
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 import viewsets
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.exceptions import APIException
|
from rest_framework.exceptions import APIException
|
||||||
@@ -70,7 +70,7 @@ class ProviderCompanyViewSet(SoftDeleteMixin, viewsets.ModelViewSet): # noqa
|
|||||||
class DeviceViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, AdminFilterMixin):
|
class DeviceViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, AdminFilterMixin):
|
||||||
queryset = pos_models.Device.objects.all()
|
queryset = pos_models.Device.objects.all()
|
||||||
serializer_class = device_serializer.DeviceSerializer
|
serializer_class = device_serializer.DeviceSerializer
|
||||||
filter_backends = [filters.SearchFilter]
|
# filter_backends = [filters.SearchFilter]
|
||||||
search_fields = [
|
search_fields = [
|
||||||
'device_identity',
|
'device_identity',
|
||||||
'acceptor',
|
'acceptor',
|
||||||
@@ -78,6 +78,7 @@ class DeviceViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, AdminFi
|
|||||||
'mac',
|
'mac',
|
||||||
'serial',
|
'serial',
|
||||||
'organization__name',
|
'organization__name',
|
||||||
|
'assignment__client__organization__name'
|
||||||
]
|
]
|
||||||
|
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class InventoryEntryViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet,
|
|||||||
class InventoryQuotaSaleTransactionViewSet(BaseViewSet, SoftDeleteMixin, DynamicSearchMixin, viewsets.ModelViewSet):
|
class InventoryQuotaSaleTransactionViewSet(BaseViewSet, SoftDeleteMixin, DynamicSearchMixin, viewsets.ModelViewSet):
|
||||||
queryset = warehouse_models.InventoryQuotaSaleTransaction.objects.all()
|
queryset = warehouse_models.InventoryQuotaSaleTransaction.objects.all()
|
||||||
serializer_class = warehouse_serializers.InventoryQuotaSaleTransactionSerializer
|
serializer_class = warehouse_serializers.InventoryQuotaSaleTransactionSerializer
|
||||||
filter_backends = [filters.SearchFilter]
|
# filter_backends = [filters.SearchFilter]
|
||||||
search_fields = [
|
search_fields = [
|
||||||
'rancher_fullname', 'rancher_mobile', 'pos_device__device_identity',
|
'rancher_fullname', 'rancher_mobile', 'pos_device__device_identity',
|
||||||
'pos_device__acceptor', 'pos_device__terminal', 'pos_device__serial',
|
'pos_device__acceptor', 'pos_device__terminal', 'pos_device__serial',
|
||||||
|
|||||||
Reference in New Issue
Block a user