fix(Sale): allow decimal on quantity products.
This commit is contained in:
		| @@ -34,6 +34,25 @@ class TestAPI(APITestCase): | ||||
|             content['id'] | ||||
|         ) | ||||
|  | ||||
|     def test_create_sale_with_decimal(self): | ||||
|         response = self._create_sale_with_decimal() | ||||
|         content = json.loads(response.content.decode('utf-8')) | ||||
|         self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||||
|         self.assertEqual(Sale.objects.count(), 1) | ||||
|         sale = Sale.objects.all()[0] | ||||
|         self.assertEqual( | ||||
|             sale.customer.name, | ||||
|             self.customer.name | ||||
|         ) | ||||
|         self.assertEqual( | ||||
|             sale.id, | ||||
|             content['id'] | ||||
|         ) | ||||
|         self.assertEqual( | ||||
|             sale.get_total(), | ||||
|             16500.00 | ||||
|         ) | ||||
|  | ||||
|     def test_get_products(self): | ||||
|         url = '/don_confiao/api/products/' | ||||
|         response = self.client.get(url) | ||||
| @@ -90,10 +109,10 @@ class TestAPI(APITestCase): | ||||
|         expected_rows = [ | ||||
|             [self.customer.name, self.customer.name, self.customer.name, "", | ||||
|              "", "2024-09-02 00:00:00+00:00", "Contado", "Almacén", | ||||
|              "Peso colombiano", self.product.name, "2", "3000.00", "Unidad", | ||||
|              "Peso colombiano", self.product.name, "2.00", "3000.00", "Unidad", | ||||
|              "TIENDA LA ILUSIÓN", "Tienda La Ilusion", "La Ilusion", "True", "" | ||||
|              ], | ||||
|             ["", "", "", "", "", "", "", "", "", self.product.name, "3", | ||||
|             ["", "", "", "", "", "", "", "", "", self.product.name, "3.00", | ||||
|              "5000.00", "Unidad", "", "", "", "", "" | ||||
|              ], | ||||
|         ] | ||||
| @@ -112,3 +131,24 @@ class TestAPI(APITestCase): | ||||
|             ], | ||||
|         } | ||||
|         return self.client.post(url, data, format='json') | ||||
|  | ||||
|     def _create_sale_with_decimal(self): | ||||
|         url = '/don_confiao/api/sales/' | ||||
|         data = { | ||||
|             'customer': self.customer.id, | ||||
|             'date': '2024-09-02', | ||||
|             'payment_method': 'CASH', | ||||
|             'saleline_set': [ | ||||
|                 { | ||||
|                     'product': self.product.id, | ||||
|                     'quantity': 0.5, | ||||
|                     'unit_price': 3000 | ||||
|                 }, | ||||
|                 { | ||||
|                     'product': self.product.id, | ||||
|                     'quantity': 3, | ||||
|                     'unit_price': 5000 | ||||
|                 } | ||||
|             ], | ||||
|         } | ||||
|         return self.client.post(url, data, format='json') | ||||
|   | ||||
| @@ -65,8 +65,8 @@ class TestExportarVentasParaTryton(TestCase): | ||||
|         self.assertEqual(next(csv_reader), expected_header) | ||||
|  | ||||
|         expected_rows = [ | ||||
|             ["Camilo", "Camilo", "Camilo", "", "", "2024-09-02 00:00:00+00:00", "Contado", "Almacén", "Peso colombiano", "Panela", "2", "3000.00", "Unidad", "TIENDA LA ILUSIÓN", "Tienda La Ilusion", "La Ilusion", "True", ""], | ||||
|             ["", "", "", "", "", "", "", "", "", "Panela", "3", "5000.00", "Unidad", "", "", "", "", ""], | ||||
|             ["Camilo", "Camilo", "Camilo", "", "", "2024-09-02 00:00:00+00:00", "Contado", "Almacén", "Peso colombiano", "Panela", "2.00", "3000.00", "Unidad", "TIENDA LA ILUSIÓN", "Tienda La Ilusion", "La Ilusion", "True", ""], | ||||
|             ["", "", "", "", "", "", "", "", "", "Panela", "3.00", "5000.00", "Unidad", "", "", "", "", ""], | ||||
|         ] | ||||
|         csv_rows = list(csv_reader) | ||||
|         self.assertEqual(csv_rows[0], expected_rows[0]) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user