5
from app.inventory.location.enums import PutawayStrategy
6
from app.inventory.order.models import OrderClass, BackOrderAction, ReservationMethod
9
async def test_crud_order_type(async_inventory_client, headers, stores, companies, products, locations, token, ):
11
Проверяем rруд вокруг товаров
14
'company_id': companies[0].id.__str__(),
17
'order_class': 'incoming',
18
'allowed_location_src_ids': [locations['partner'].id.__str__(),],
19
'exclusive_location_src_ids': None,
20
'allowed_location_dest_ids': [locations['place'].id.__str__(),],
21
'exclusive_location_dest_ids': None,
22
'backorder_order_type_id': None,
23
'backorder_action_type': 'ask',
26
'reservation_method': 'at_confirm',
27
'reservation_time_before': 0,
28
'allowed_package_ids': [locations['package'].id.__str__(),],
29
'exclusive_package_ids': None,
30
'is_homogeneity': False,
31
'is_allow_create_package': True,
32
'is_can_create_order_manualy': True,
33
'is_overdelivery': False,
34
'created_by': token['user_admin']['user_id'].__str__(),
35
'edited_by': token['user_admin']['user_id'].__str__(),
36
'barcode': '2132132131231',
39
response = await async_inventory_client.post("/api/inventory/order_type", json=create_data, headers=headers['superadmin'])
40
assert response.status_code == 200
41
data = response.json()
42
order_type_id_1 = data['id']
43
#--------------------------------
48
'order_class': 'outgoing',
49
'allowed_location_src_ids': [locations['partner'].id.__str__(),],
50
'exclusive_location_src_ids': None,
51
'allowed_location_dest_ids': [locations['place'].id.__str__(),],
52
'exclusive_location_dest_ids': None,
53
'backorder_order_type_id': None,
54
'backorder_action_type': 'ask',
57
'reservation_method': 'manual',
58
'reservation_time_before': 5,
59
'allowed_package_ids': [],
60
'exclusive_package_ids': None,
61
'is_homogeneity': False,
62
'is_allow_create_package': True,
63
'is_can_create_order_manualy': True,
64
'is_overdelivery': False,
65
'created_by': token['user_admin']['user_id'].__str__(),
66
'edited_by': token['user_admin']['user_id'].__str__(),
67
'barcode': '2132132131231',
70
response = await async_inventory_client.put(f"/api/inventory/order_type/{order_type_id_1}", json=update_data, headers=headers['superadmin'], )
71
assert response.status_code == 200
72
# --------------------------------
74
response = await async_inventory_client.get("/api/inventory/order_type", headers=headers['superadmin'], params={'size': 100, 'search': 'title'}
76
assert response.status_code == 200
77
data = response.json()
78
assert len(data.get('data')) == 1
80
response = await async_inventory_client.delete(f"/api/inventory/order_type/{order_type_id_1}", headers=headers['superadmin'], )
81
assert response.status_code == 200
85
async def test_crud_order(async_inventory_client, token, headers, stores, companies, locations, order_types):
87
Проверяем rруд вокруг товаров
90
'company_id': companies[0].id.__str__(),
91
'order_type_id': order_types['inbound'].id.__str__(),
93
'external_number': 'external id',
94
'store_id': stores[0].id.__str__(),
97
'origin_type': 'Purchase Order',
98
'origin_number': 'Some Purchase Order Number',
99
'planned_date': datetime.datetime.now().isoformat(),
101
'created_by': token['user_admin']['user_id'].__str__(),
102
'edited_by': token['user_admin']['user_id'].__str__(),
103
'expiration_datetime': datetime.datetime.now().isoformat(),
105
'description': 'description',
109
response = await async_inventory_client.post("/api/inventory/order", json=create_data, headers=headers['superadmin'])
110
assert response.status_code == 200
111
data = response.json()
112
order_id_1 = data['id']
113
#--------------------------------
116
'order_type_id': order_types['inbound'].id.__str__(),
118
'external_number': 'external id',
119
'store_id': stores[0].id.__str__(),
122
'origin_type': 'Purchase Order',
123
'origin_number': 'Some Purchase Order Number',
124
'planned_date': datetime.datetime.now().isoformat(),
126
'created_by': token['user_admin']['user_id'].__str__(),
127
'edited_by': token['user_admin']['user_id'].__str__(),
128
'expiration_datetime': datetime.datetime.now().isoformat(),
130
'description': 'description',
133
response = await async_inventory_client.put(f"/api/inventory/order/{order_id_1}", json=update_data, headers=headers['superadmin'], )
134
assert response.status_code == 200
135
# --------------------------------
137
response = await async_inventory_client.get("/api/inventory/order", headers=headers['superadmin'], params={'size': 100, 'search': 'external id'}
139
assert response.status_code == 200
140
data = response.json()
141
assert len(data.get('data')) == 1
143
response = await async_inventory_client.delete(f"/api/inventory/order/{order_id_1}", headers=headers['superadmin'], )
144
assert response.status_code == 200
147
async def test_crud_move(async_inventory_client, token, headers, stores, companies, locations, order_types):
149
Перед созданием Move нужно обязятельно создать Order
152
'company_id': companies[0].id.__str__(),
153
'order_type_id': order_types['inbound'].id.__str__(),
155
'external_number': 'external id 1',
156
'store_id': stores[0].id.__str__(),
159
'origin_type': 'Purchase Order',
160
'origin_number': 'Some Purchase Order Number',
161
'planned_date': datetime.datetime.now().isoformat(),
163
'created_by': token['user_admin']['user_id'].__str__(),
164
'edited_by': token['user_admin']['user_id'].__str__(),
165
'expiration_datetime': datetime.datetime.now().isoformat(),
167
'description': 'description',
171
response = await async_inventory_client.post("/api/inventory/order", json=create_data, headers=headers['superadmin'])
172
assert response.status_code == 200
173
data = response.json()
174
order_id_1 = data['id']
176
#--Перед созданием Move нужно обязятельно создать Order
178
'company_id': companies[0].id.__str__(),
179
'order_type_id': order_types['inbound'].id.__str__(),
181
'external_number': 'external id 2',
182
'store_id': stores[0].id.__str__(),
185
'origin_type': 'Purchase Order',
186
'origin_number': 'Some Purchase Order Number',
187
'planned_date': datetime.datetime.now().isoformat(),
189
'created_by': token['user_admin']['user_id'].__str__(),
190
'edited_by': token['user_admin']['user_id'].__str__(),
191
'expiration_datetime': datetime.datetime.now().isoformat(),
193
'description': 'description',
197
response = await async_inventory_client.post("/api/inventory/order", json=create_data,
198
headers=headers['superadmin'])
199
assert response.status_code == 200
200
data = response.json()
201
order_id_1 = data['id']
202
# --------------------------------
206
'order_type_id': order_types['inbound'].id.__str__(),
208
'external_number': 'external id 3',
209
'store_id': stores[0].id.__str__(),
212
'origin_type': 'Purchase Order',
213
'origin_number': 'Some Purchase Order Number',
214
'planned_date': datetime.datetime.now().isoformat(),
216
'created_by': token['user_admin']['user_id'].__str__(),
217
'edited_by': token['user_admin']['user_id'].__str__(),
218
'expiration_datetime': datetime.datetime.now().isoformat(),
220
'description': 'description',
223
response = await async_inventory_client.put(f"/api/inventory/order/{order_id_1}", json=update_data, headers=headers['superadmin'], )
224
assert response.status_code == 200
225
# --------------------------------
227
response = await async_inventory_client.get("/api/inventory/order", headers=headers['superadmin'], params={'size': 100, 'search': 'external id'}
229
assert response.status_code == 200
230
data = response.json()
231
assert len(data.get('data')) == 2
233
response = await async_inventory_client.delete(f"/api/inventory/order/{order_id_1}", headers=headers['superadmin'], )
234
assert response.status_code == 200