feat: extended price mismatch diagnostics in logs

This commit is contained in:
Björn Fromme
2026-03-18 15:24:52 +01:00
parent 02ff28acdd
commit ca7d0b6965
3 changed files with 244 additions and 0 deletions
@@ -14,6 +14,7 @@ use App\Form\BookingCreateStep3Type;
use App\Form\Model\BookingDto;
use App\Htmx\HxTrait;
use App\Service\BookingPriceCalculatorService;
use App\Service\BookingPriceMismatchDiagnosticsService;
use App\Service\BookingService;
use App\Service\BookingSummaryDataService;
use Psr\Log\LoggerInterface;
@@ -36,6 +37,7 @@ class Step3Controller extends AbstractController
private readonly BookingService $bookingService,
private readonly BookingSummaryDataService $summaryDataService,
private readonly BookingPriceCalculatorService $priceCalculator,
private readonly BookingPriceMismatchDiagnosticsService $priceMismatchDiagnostics,
private readonly ApiClient $apiClient,
private readonly LoggerInterface $logger,
) {
@@ -126,6 +128,9 @@ class Step3Controller extends AbstractController
$expectedTotal = round($calculatedSubtotal - $promoGoodwillDiscount - $apiAppliedDiscount, 2);
if ((int) round($apiTotal * 100) !== (int) round($expectedTotal * 100)) {
$diagnostics = $this->priceMismatchDiagnostics->buildDiagnostics($bookingCreateDto, $inquiryResponse);
$deltaBreakdown = $diagnostics['deltaBreakdown'] ?? [];
return $this->handleApiError(
'Price mismatch detected - payload incomplete',
[
@@ -135,6 +140,11 @@ class Step3Controller extends AbstractController
'apiAppliedDiscount' => $apiAppliedDiscount,
'expectedTotal' => $expectedTotal,
'difference' => abs($apiTotal - $expectedTotal),
'deltaTotal' => $deltaBreakdown['deltaTotal'] ?? null,
'deltaRoom' => $deltaBreakdown['deltaRoom'] ?? null,
'deltaService' => $deltaBreakdown['deltaService'] ?? null,
'deltaInsurance' => $deltaBreakdown['deltaInsurance'] ?? null,
'diagnostics' => $diagnostics,
],
'Preisabweichung festgestellt. Bitte wende dich an den Kundenservice.',
$bookingCreateDto,