Merge remote-tracking branch 'origin' into development
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):
|
||||
|
||||
@@ -59,7 +59,10 @@ class POSDeviceViewSet(viewsets.ModelViewSet, POSDeviceMixin):
|
||||
organization = pos_models.Organization.objects.get(en_name=psp_name)
|
||||
|
||||
# device version
|
||||
device_version = pos_models.DeviceVersion.objects.filter(organization=organization).order_by('-code')
|
||||
device_version = pos_models.DeviceVersion.objects.filter(
|
||||
organization=organization,
|
||||
enable=True
|
||||
).order_by('-code')
|
||||
|
||||
device = self.device_queryset.filter(serial=serial).first()
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -46,7 +46,10 @@ class POSFreeProductSerializer(serializers.ModelSerializer):
|
||||
national_unique_id='1111111111'
|
||||
)
|
||||
main_company_bank_account = main_company.bank_information.first()
|
||||
representation['company_shaba'] = "IR" + main_company_bank_account.sheba # noqa
|
||||
if instance.company_fee != 0:
|
||||
representation['company_shaba'] = "IR" + main_company_bank_account.sheba # noqa
|
||||
else:
|
||||
representation['company_shaba'] = "" # noqa
|
||||
|
||||
return representation
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ class InventoryQuotaSaleTransactionViewSet(
|
||||
):
|
||||
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