feat: streamlined booking number property
This commit is contained in:
@@ -16,15 +16,15 @@ namespace App\BusProNet\Model;
|
||||
class BookingResponse
|
||||
{
|
||||
/**
|
||||
* @param string $status Booking status (möglich|erfolgt)
|
||||
* @param string|null $transactionNumber Transaction number (vorgang)
|
||||
* @param array<int, PriceItem> $priceItems Individual price items from response
|
||||
* @param float|null $totalPrice Total price (gesamtpreis)
|
||||
* @param PaymentTerms|null $paymentTerms Payment terms (anzahlung/restzahlung)
|
||||
* @param string $status Booking status (möglich|erfolgt)
|
||||
* @param int|null $bookingNumber Booking number (BPN XML: vorgang)
|
||||
* @param array<int, PriceItem> $priceItems Individual price items from response
|
||||
* @param float|null $totalPrice Total price (gesamtpreis)
|
||||
* @param PaymentTerms|null $paymentTerms Payment terms (anzahlung/restzahlung)
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $status,
|
||||
public readonly ?string $transactionNumber = null,
|
||||
public readonly ?int $bookingNumber = null,
|
||||
public readonly array $priceItems = [],
|
||||
public readonly ?float $totalPrice = null,
|
||||
public readonly ?PaymentTerms $paymentTerms = null,
|
||||
|
||||
@@ -33,7 +33,7 @@ class BookingResponseParser extends AbstractParser
|
||||
public function parse(Crawler $node): BookingResponse
|
||||
{
|
||||
$status = $node->filterXPath('//buchung')->text();
|
||||
$transactionNumber = $this->getStringOrNullValue($node->filterXPath('//vorgang'));
|
||||
$bookingNumber = $this->getIntOrNullValue($node->filterXPath('//vorgang'));
|
||||
$totalPrice = $this->getFloatOrNullValue($node->filterXPath('//gesamtpreis'));
|
||||
$message = $this->getStringOrNullValue($node->filterXPath('//hinweis'));
|
||||
|
||||
@@ -42,7 +42,7 @@ class BookingResponseParser extends AbstractParser
|
||||
|
||||
return new BookingResponse(
|
||||
status: $status,
|
||||
transactionNumber: $transactionNumber,
|
||||
bookingNumber: $bookingNumber,
|
||||
priceItems: $priceItems,
|
||||
totalPrice: $totalPrice,
|
||||
paymentTerms: $paymentTerms,
|
||||
|
||||
+13
-12
@@ -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],
|
||||
]
|
||||
);
|
||||
|
||||
@@ -93,14 +93,14 @@ class Step4Controller extends AbstractController
|
||||
}
|
||||
|
||||
// Success: Store booking number in flash and clear session
|
||||
$this->addFlash('booking_number', $bookingResponse->transactionNumber);
|
||||
$this->addFlash('booking_number', $bookingResponse->bookingNumber);
|
||||
$this->clearTravelDataCache($bookingCreateDto);
|
||||
$this->bookingService->clearBookingDto($request, BookingDto::MODE_CREATE);
|
||||
|
||||
$this->logger->info('Booking successfully created.', [
|
||||
'date_id' => $bookingCreateDto->travel->id,
|
||||
'hotel_id' => $bookingCreateDto->hotelId,
|
||||
'booking_number' => $bookingResponse->transactionNumber,
|
||||
'booking_number' => $bookingResponse->bookingNumber,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_booking_create_success');
|
||||
|
||||
@@ -22,9 +22,18 @@ class BookingEditDraft
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
||||
private User $user;
|
||||
|
||||
/**
|
||||
* Internal database ID (BPN XML: idbuchung).
|
||||
*/
|
||||
#[ORM\Column(type: 'integer')]
|
||||
private int $bookingId;
|
||||
|
||||
/**
|
||||
* User-facing transaction number (BPN XML: vorgang).
|
||||
*/
|
||||
#[ORM\Column(type: 'integer', nullable: true)]
|
||||
private ?int $bookingNumber = null;
|
||||
|
||||
#[ORM\Column(type: 'date_immutable')]
|
||||
private \DateTimeImmutable $travelDate;
|
||||
|
||||
@@ -62,6 +71,18 @@ class BookingEditDraft
|
||||
return $this->bookingId;
|
||||
}
|
||||
|
||||
public function getBookingNumber(): ?int
|
||||
{
|
||||
return $this->bookingNumber;
|
||||
}
|
||||
|
||||
public function setBookingNumber(?int $bookingNumber): static
|
||||
{
|
||||
$this->bookingNumber = $bookingNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTravelDate(): \DateTimeImmutable
|
||||
{
|
||||
return $this->travelDate;
|
||||
|
||||
Reference in New Issue
Block a user