diff --git a/tienda_ilusion/don_confiao/serializers.py b/tienda_ilusion/don_confiao/serializers.py index 8c68dd4..923befe 100644 --- a/tienda_ilusion/don_confiao/serializers.py +++ b/tienda_ilusion/don_confiao/serializers.py @@ -15,7 +15,7 @@ class SaleSerializer(serializers.ModelSerializer): class Meta: model = Sale fields = ['id', 'customer', 'date', 'saleline_set', - 'total', 'payment_method'] + 'total', 'payment_method', 'external_id'] class ProductSerializer(serializers.ModelSerializer): @@ -27,7 +27,7 @@ class ProductSerializer(serializers.ModelSerializer): class CustomerSerializer(serializers.ModelSerializer): class Meta: model = Customer - fields = ['id', 'name', 'address', 'email', 'phone'] + fields = ['id', 'name', 'address', 'email', 'phone', 'external_id'] class ReconciliationJarSerializer(serializers.ModelSerializer): diff --git a/tienda_ilusion/don_confiao/tests/test_api.py b/tienda_ilusion/don_confiao/tests/test_api.py index 30bd4e0..e9c59dc 100644 --- a/tienda_ilusion/don_confiao/tests/test_api.py +++ b/tienda_ilusion/don_confiao/tests/test_api.py @@ -16,7 +16,8 @@ class TestAPI(APITestCase): measuring_unit='UNIT' ) self.customer = Customer.objects.create( - name='Camilo' + name='Camilo', + external_id='18' ) def test_create_sale(self): @@ -67,6 +68,23 @@ class TestAPI(APITestCase): json_response = json.loads(response.content.decode('utf-8')) self.assertEqual(response.status_code, 200) self.assertEqual(self.customer.name, json_response[0]['name']) + self.assertEqual( + self.customer.external_id, + json_response[0]['external_id'] + ) + + def test_get_sales(self): + url = '/don_confiao/api/sales/' + self._create_sale() + + response = self.client.get(url) + json_response = json.loads(response.content.decode('utf-8')) + self.assertEqual(response.status_code, 200) + self.assertEqual(self.customer.id, json_response[0]['customer']) + self.assertEqual( + None, + json_response[0]['external_id'] + ) def test_get_sales_for_tryton(self): url = '/don_confiao/api/sales/for_tryton'