Skip to content

Commit 3ccd06d

Browse files
committed
only create order rounds automatically in the future
1 parent a38151a commit 3ccd06d

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

webapp/ordering/core.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,24 +301,25 @@ def create_orderround_batch():
301301
# This will be the last day of the next quarter
302302
order_rounds = []
303303
while start_date <= end_date:
304-
open_datetime, close_datetime, collect_datetime = calculate_next_orderround_dates(start_date)
304+
if start_date > current_date:
305+
open_datetime, close_datetime, collect_datetime = calculate_next_orderround_dates(start_date)
305306

306-
# Get default pickup location and transport coordinator
307-
pickup_location = models.PickupLocation.objects.filter(is_default=True).first()
308-
transport_coordinator = VokoUser.objects.filter(pk=config.ORDERROUND_TRANSPORT_COORDINATOR).first()
307+
# Get default pickup location and transport coordinator
308+
pickup_location = models.PickupLocation.objects.filter(is_default=True).first()
309+
transport_coordinator = VokoUser.objects.filter(pk=config.ORDERROUND_TRANSPORT_COORDINATOR).first()
309310

310-
order_round = models.OrderRound.objects.create(
311-
open_for_orders=open_datetime,
312-
closed_for_orders=close_datetime,
313-
collect_datetime=collect_datetime,
314-
markup_percentage=config.MARKUP_PERCENTAGE,
315-
pickup_location=pickup_location,
316-
transport_coordinator=transport_coordinator,
317-
)
311+
order_round = models.OrderRound.objects.create(
312+
open_for_orders=open_datetime,
313+
closed_for_orders=close_datetime,
314+
collect_datetime=collect_datetime,
315+
markup_percentage=config.MARKUP_PERCENTAGE,
316+
pickup_location=pickup_location,
317+
transport_coordinator=transport_coordinator,
318+
)
318319

319-
order_rounds.append(order_round)
320+
order_rounds.append(order_round)
320321

321-
log_event(event="Auto-created order round #%d" % order_round.pk)
322+
log_event(event="Auto-created order round #%d" % order_round.pk)
322323

323324
start_date += timedelta(weeks=config.ORDERROUND_INTERVAL_WEEKS)
324325

0 commit comments

Comments
 (0)