Coverage for apps/proxy_models/serializers.py: 90%
55 statements
« prev ^ index » next coverage.py v6.4.4, created at 2024-03-27 17:43 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2024-03-27 17:43 -0600
1from rest_framework.serializers import ModelSerializer, CharField, DecimalField, IntegerField, DateField
3from api.proscai.client import create_client, update_client
4from .models import Client, Store, Salesman
7class ClientSerializer(ModelSerializer):
8 class Meta:
9 model = Client
10 fields = [
11 'proscai_id', 'name', 'email', 'curp', 'rfc',
12 'mobile', 'date_of_birth', 'zip_code', 'neighborhood', 'state', 'city', 'street', 'county', 'country',
13 'external_number', 'internal_number', 'store', 'loan_days', 'loan_rate', 'loan_amount', 'loan_periods', 'phone',
14 'reference_name_1', 'reference_phone_1', 'reference_relationship_1',
15 'reference_name_2', 'reference_phone_2', 'reference_relationship_2',
16 ]
18 proscai_id = CharField(source='clicod', read_only=True)
19 name = CharField(source='clinom')
20 email = CharField(source='clitel3', required=False)
21 curp = CharField(source='clicurp')
22 rfc = CharField(source='clirfc', required=False)
23 mobile = CharField(source='clicelular')
24 phone = CharField(source='clitel')
25 date_of_birth = DateField(source='clinacimiento')
26 zip_code = CharField(source='clicp')
27 neighborhood = CharField(source='clicolonia')
28 state = CharField(source='cliedo')
29 city = CharField(source='clicd', required=False)
30 street = CharField(source='clidir')
31 county = CharField(source='clidelegacion')
32 external_number = CharField(source='clinumext', required=False)
33 internal_number = CharField(source='clinumint', required=False)
34 country = CharField(source='clipais', default="MEX")
35 store = CharField(source='clisucursal')
36 loan_days = IntegerField(source='cliplazo0', default=90)
37 loan_amount = IntegerField(source='clicredit', required=False, default=0)
38 loan_rate = DecimalField(source='clivarios13', decimal_places=2, max_digits=5)
39 loan_periods = IntegerField(source='clivarios7', default=6)
42 reference_name_1 = CharField(required=False)
43 reference_phone_1 = CharField(required=False)
44 reference_relationship_1 = CharField(required=False)
45 reference_name_2 = CharField(required=False)
46 reference_phone_2 = CharField(required=False)
47 reference_relationship_2 = CharField(required=False)
50 def create(self, validated_data):
51 clicod = create_client(**validated_data)
52 if clicod:
53 obj = Client.objects.get(clicod=clicod)
54 else:
55 obj = Client.objects.none()
56 return obj
60class StoreSerializer(ModelSerializer):
61 class Meta:
62 model = Store
63 fields = [
64 'proscai_id', 'name', 'email'
66 ]
68 proscai_id = CharField(source='catalm')
69 name = CharField(source='catdescr')
70 email = CharField()
73class SalesmanSerializer(ModelSerializer):
74 class Meta:
75 model = Salesman
76 fields = [
77 'proscai_id', 'name'
79 ]
81 proscai_id = CharField(source='agnum')
82 name = CharField(source='agdescr')
85"""
86Tienda
87Vendedor
88tiket
89documento
90"""