diff --git a/services/nginx/app/classes/invoice_period_flag_service.php b/services/nginx/app/classes/invoice_period_flag_service.php index 9625d80b..6e683b5d 100644 --- a/services/nginx/app/classes/invoice_period_flag_service.php +++ b/services/nginx/app/classes/invoice_period_flag_service.php @@ -525,20 +525,11 @@ class invoice_period_flag_service try { $flags = (new redis())->get_invoice_period_automatic_flags($dateFrom, $dateTo); } catch (Throwable) { - $flags = null; + return []; } if (!is_array($flags)) { - // Cache miss — warm on demand and re-fetch - $this->warmAutomaticFlagsForPeriod($dateFrom, $dateTo); - try { - $flags = (new redis())->get_invoice_period_automatic_flags($dateFrom, $dateTo); - } catch (Throwable) { - return []; - } - if (!is_array($flags)) { - return []; - } + return []; } if ($onlyCustomerNumbers === null) { @@ -610,16 +601,11 @@ class invoice_period_flag_service try { $rows = (new redis())->get_invoice_period_order_item_rows($dateFrom, $dateTo); } catch (Throwable) { - $rows = null; + return []; } if (!is_array($rows)) { - // Cache miss — fetch from DB and cache for next request - $rows = $this->fetchOrderItemRowsFromDb($dateFrom, $dateTo); - try { - (new redis())->cache_invoice_period_order_item_rows($dateFrom, $dateTo, $rows); - } catch (Throwable) { - } + return []; } $this->seedOrderItemsPreviewCacheFromRows($rows); @@ -1733,9 +1719,21 @@ class invoice_period_flag_service $currentVehicleType = $this->normalizePrimaryVehicleProductName($currentProductName); $expectedVehicleType = $this->normalizePrimaryVehicleProductName($expectedProductName); - return $currentVehicleType !== '' - && $expectedVehicleType !== '' - && $currentVehicleType === $expectedVehicleType; + if ($currentVehicleType === '' || $expectedVehicleType === '') { + return false; + } + if ($currentVehicleType === $expectedVehicleType) { + return true; + } + // Allow a match if one normalized name's tokens are a subset of the other. + // E.g. "Indvendig vask Kassevogn" → "kassevogn" is a subset of + // "Kassevogn/varevogn" → "kassevogn varevogn", meaning the same vehicle type. + $currentTokens = explode(' ', $currentVehicleType); + $expectedTokens = explode(' ', $expectedVehicleType); + if (count($currentTokens) <= count($expectedTokens)) { + return array_diff($currentTokens, $expectedTokens) === []; + } + return array_diff($expectedTokens, $currentTokens) === []; } private function normalizePrimaryVehicleProductName(string $productName): string diff --git a/services/nginx/app/modules/economic/economic_m.php b/services/nginx/app/modules/economic/economic_m.php index 88c27c3c..5a8594c7 100644 --- a/services/nginx/app/modules/economic/economic_m.php +++ b/services/nginx/app/modules/economic/economic_m.php @@ -93,7 +93,7 @@ class economic_m CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_CONNECTTIMEOUT => 3, - CURLOPT_TIMEOUT => 10, + CURLOPT_TIMEOUT => 30, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => $method, diff --git a/services/nginx/app/tests/Unit/Invoicing/EconomicAuthTokenFallbackTest.php b/services/nginx/app/tests/Unit/Invoicing/EconomicAuthTokenFallbackTest.php index 6bf7f9e7..08f5a822 100644 --- a/services/nginx/app/tests/Unit/Invoicing/EconomicAuthTokenFallbackTest.php +++ b/services/nginx/app/tests/Unit/Invoicing/EconomicAuthTokenFallbackTest.php @@ -186,7 +186,7 @@ it('bounds e-conomic curl calls below the PHP request timeout', function (): voi foreach ([(string)$legacyContent, (string)$endpointContent] as $content) { expect($content)->toContain('CURLOPT_CONNECTTIMEOUT => 3') - ->and($content)->toContain('CURLOPT_TIMEOUT => 10') + ->and($content)->toContain('CURLOPT_TIMEOUT => 30') ->and($content)->not->toContain('CURLOPT_TIMEOUT => 0'); } });