feat: streamlined booking number property

This commit is contained in:
Björn Fromme
2026-01-10 12:12:54 +01:00
parent 6fca40963d
commit d95d0a8930
7 changed files with 71 additions and 23 deletions
@@ -16,10 +16,10 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand(
name: 'app:draft:backfill-travel-date',
description: 'Backfill travel dates for existing drafts from API',
name: 'app:draft:backfill-booking-number',
description: 'Backfill booking numbers (vorgang) for existing drafts from API',
)]
class DraftBackfillTravelDateCommand extends Command
class DraftBackfillBookingNumberCommand extends Command
{
public function __construct(
private readonly BookingEditDraftRepository $draftRepository,
@@ -43,10 +43,10 @@ class DraftBackfillTravelDateCommand extends Command
$io = new SymfonyStyle($input, $output);
$dryRun = $input->getOption('dry-run');
$drafts = $this->draftRepository->findAll();
$drafts = $this->draftRepository->findBy(['bookingNumber' => null]);
if (0 === \count($drafts)) {
$io->success('No drafts found.');
$io->success('No drafts without booking number found.');
return Command::SUCCESS;
}
@@ -70,10 +70,11 @@ class DraftBackfillTravelDateCommand extends Command
continue;
}
$travelDate = $bookingData->travelDate;
// bookingNumber maps to BPN XML vorgang
$bookingNumber = $bookingData->bookingNumber;
if (null === $travelDate) {
$io->warning(sprintf('No travel date found for booking %d', $bookingId));
if (null === $bookingNumber) {
$io->warning(sprintf('No booking number (vorgang) found for booking %d', $bookingId));
++$skipped;
continue;
@@ -81,13 +82,13 @@ class DraftBackfillTravelDateCommand extends Command
if ($dryRun) {
$io->text(sprintf(
'[DRY RUN] Would set travel date %s for draft %d (booking %d)',
$travelDate->format('Y-m-d'),
'[DRY RUN] Would set booking number %d for draft %d (bookingId %d)',
$bookingNumber,
$draft->getId(),
$bookingId
));
} else {
$draft->setTravelDate($travelDate);
$draft->setBookingNumber($bookingNumber);
}
++$updated;
@@ -103,7 +104,7 @@ class DraftBackfillTravelDateCommand extends Command
[
['Updated', $updated],
['Failed (API error)', $failed],
['Skipped (no date)', $skipped],
['Skipped (no booking number)', $skipped],
]
);