@@ -233,53 +233,92 @@ def handle(self, *args, **options):
233233 loading_stops = [s for s in stops if s .stop_type == 'loading' ]
234234 unloading_stops = [s for s in stops if s .stop_type == 'unloading' ]
235235
236- orders_data = [
236+ # Create orders for the specific stops that will be used in trips
237+ # This ensures that trip stops will have associated orders
238+ trip_specific_orders = [
239+ # Order for Trip 1 (Paris to Marseille Export Route)
240+ # stops[0], stops[3], stops[9] -> Rungis, Marseille Port, Retail
237241 {
238242 'customer_name' : 'ACME Manufacturing' ,
239243 'customer_company' : 'ACME Corp' ,
240244 'customer_email' : 'logistics@acme.com' ,
241245 'customer_phone' : '+33-1-42-00-1234' ,
242- 'pickup_stop' : loading_stops [0 ], # Rungis
243- 'delivery_stop' : unloading_stops [ 0 ], # Carrefour Paris
246+ 'pickup_stop' : stops [0 ], # Rungis (loading)
247+ 'delivery_stop' : stops [ 9 ], # A retail location (should be unloading)
244248 'goods_description' : 'Fresh produce and dairy products' ,
245249 'goods_weight' : 2500.0 ,
246250 'goods_volume' : 15.0 ,
247251 'goods_type' : 'refrigerated' ,
248252 'special_instructions' : 'Keep temperature at 2-4°C throughout transport'
249253 },
254+ # Order for Trip 2 (Lyon Industrial Supply)
255+ # stops[2], stops[10], stops[12] -> Lyon Hub, Auchan, Casino
250256 {
251257 'customer_name' : 'TechCorp Europe' ,
252258 'customer_company' : 'TechCorp Ltd' ,
253259 'customer_email' : 'supply@techcorp.eu' ,
254260 'customer_phone' : '+33-1-45-67-8900' ,
255- 'pickup_stop' : loading_stops [ 4 ], # Toulouse Aerospace
256- 'delivery_stop' : unloading_stops [ 7 ], # Frankfurt
257- 'goods_description' : 'Aerospace electronic components' ,
261+ 'pickup_stop' : stops [ 2 ], # Lyon Hub (loading)
262+ 'delivery_stop' : stops [ 10 ], # Auchan (unloading)
263+ 'goods_description' : 'Industrial electronic components' ,
258264 'goods_weight' : 850.0 ,
259265 'goods_volume' : 5.2 ,
260266 'goods_type' : 'fragile' ,
261267 'special_instructions' : 'Handle with extreme care - sensitive electronics'
262268 },
269+ # Order for Trip 3 (Le Havre to Brussels)
270+ # stops[1], stops[16] -> Le Havre, Brussels
263271 {
264272 'customer_name' : 'EuroConstruction' ,
265273 'customer_company' : 'EuroConstruction SA' ,
266274 'customer_email' : 'orders@euroconstruct.fr' ,
267275 'customer_phone' : '+33-4-78-90-1234' ,
268- 'pickup_stop' : loading_stops [ 8 ], # Saint-Gobain Melun
269- 'delivery_stop' : unloading_stops [ 4 ], # Brussels
276+ 'pickup_stop' : stops [ 1 ], # Le Havre (loading)
277+ 'delivery_stop' : stops [ 16 ], # Brussels (unloading)
270278 'goods_description' : 'Construction materials and tools' ,
271279 'goods_weight' : 4200.0 ,
272280 'goods_volume' : 28.0 ,
273281 'goods_type' : 'standard' ,
274282 'special_instructions' : 'Delivery to construction site - crane available'
275283 },
284+ # Order for Trip 4 (Toulouse Aerospace Delivery)
285+ # stops[4], stops[19], stops[21] -> Toulouse, Airbus, Tech
286+ {
287+ 'customer_name' : 'AeroSupply International' ,
288+ 'customer_company' : 'AeroSupply Ltd' ,
289+ 'customer_email' : 'urgent@aerosupply.com' ,
290+ 'customer_phone' : '+33-5-61-00-1234' ,
291+ 'pickup_stop' : stops [4 ], # Toulouse Aerospace (loading)
292+ 'delivery_stop' : stops [19 ], # Airbus (unloading)
293+ 'goods_description' : 'Aerospace manufacturing components' ,
294+ 'goods_weight' : 1200.0 ,
295+ 'goods_volume' : 8.5 ,
296+ 'goods_type' : 'standard' ,
297+ 'special_instructions' : 'Time-critical delivery for production line'
298+ },
299+ # Order for Trip 5 (Rhine Valley Route)
300+ # stops[5], stops[18], stops[22] -> Strasbourg, Frankfurt, Luxembourg
301+ {
302+ 'customer_name' : 'Rhine Logistics' ,
303+ 'customer_company' : 'Rhine Transport GmbH' ,
304+ 'customer_email' : 'operations@rhinetransport.de' ,
305+ 'customer_phone' : '+33-3-88-00-5678' ,
306+ 'pickup_stop' : stops [5 ], # Strasbourg Rhine Port (loading)
307+ 'delivery_stop' : stops [18 ], # Frankfurt (unloading)
308+ 'goods_description' : 'Industrial machinery parts' ,
309+ 'goods_weight' : 3200.0 ,
310+ 'goods_volume' : 18.0 ,
311+ 'goods_type' : 'oversized' ,
312+ 'special_instructions' : 'Requires special handling equipment'
313+ },
314+ # Additional orders for variety
276315 {
277316 'customer_name' : 'PharmaLogistics' ,
278317 'customer_company' : 'PharmaDistrib' ,
279318 'customer_email' : 'urgent@pharmadistrib.com' ,
280319 'customer_phone' : '+33-1-56-78-9012' ,
281- 'pickup_stop' : loading_stops [9 ], # Sanofi
282- 'delivery_stop' : unloading_stops [8 ], # Milan
320+ 'pickup_stop' : loading_stops [9 ] if len ( loading_stops ) > 9 else loading_stops [ 0 ] , # Fallback to first if not enough
321+ 'delivery_stop' : unloading_stops [8 ] if len ( unloading_stops ) > 8 else unloading_stops [ 0 ],
283322 'goods_description' : 'Pharmaceutical supplies and medications' ,
284323 'goods_weight' : 320.0 ,
285324 'goods_volume' : 2.8 ,
@@ -291,8 +330,8 @@ def handle(self, *args, **options):
291330 'customer_company' : 'EliteStores International' ,
292331 'customer_email' : 'procurement@elitestores.com' ,
293332 'customer_phone' : '+33-1-44-55-6677' ,
294- 'pickup_stop' : loading_stops [10 ], # LVMH Logistics
295- 'delivery_stop' : unloading_stops [10 ], # Zurich
333+ 'pickup_stop' : loading_stops [10 ] if len ( loading_stops ) > 10 else loading_stops [ 1 ],
334+ 'delivery_stop' : unloading_stops [10 ] if len ( unloading_stops ) > 10 else unloading_stops [ 1 ],
296335 'goods_description' : 'Luxury fashion and accessories' ,
297336 'goods_weight' : 180.0 ,
298337 'goods_volume' : 8.5 ,
@@ -302,7 +341,7 @@ def handle(self, *args, **options):
302341 ]
303342
304343 orders = []
305- for o_data in orders_data :
344+ for o_data in trip_specific_orders :
306345 order = Order .objects .create (
307346 customer_name = o_data ['customer_name' ],
308347 customer_company = o_data ['customer_company' ],
@@ -498,7 +537,8 @@ def handle(self, *args, **options):
498537 self .stdout .write (f'Positions: { Position .objects .count ()} ' )
499538 self .stdout .write ('\n Test data includes:' )
500539 self .stdout .write ('• Dashmove company with 20 heavy trucks (18-40 tons capacity)' )
501- self .stdout .write ('• 5 sample orders with customer details, pickup/delivery locations, and goods information' )
540+ self .stdout .write ('• 7 sample orders with customer details, pickup/delivery locations, and goods information' )
541+ self .stdout .write ('• Orders specifically created to match trip stops for testing order linking' )
502542 self .stdout .write ('• 10 sample trips with different statuses' )
503543 self .stdout .write ('• 48 hours of position data for 10 vehicles across European routes' )
504544 self .stdout .write ('• Realistic heavy truck logistics operations' )
0 commit comments