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 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):
|
||||||
|
|||||||
@@ -59,7 +59,10 @@ class POSDeviceViewSet(viewsets.ModelViewSet, POSDeviceMixin):
|
|||||||
organization = pos_models.Organization.objects.get(en_name=psp_name)
|
organization = pos_models.Organization.objects.get(en_name=psp_name)
|
||||||
|
|
||||||
# device version
|
# 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()
|
device = self.device_queryset.filter(serial=serial).first()
|
||||||
|
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -46,7 +46,10 @@ class POSFreeProductSerializer(serializers.ModelSerializer):
|
|||||||
national_unique_id='1111111111'
|
national_unique_id='1111111111'
|
||||||
)
|
)
|
||||||
main_company_bank_account = main_company.bank_information.first()
|
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
|
return representation
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ class InventoryQuotaSaleTransactionViewSet(
|
|||||||
):
|
):
|
||||||
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