diff --git a/src/Http/MunicipalParametersClient.php b/src/Http/MunicipalParametersClient.php index ad838d9..8553c82 100644 --- a/src/Http/MunicipalParametersClient.php +++ b/src/Http/MunicipalParametersClient.php @@ -148,7 +148,7 @@ private function serviceCode(string $codigoServico): string if (preg_match('/^\\d{9}$/', $value) !== 1) { throw new \InvalidArgumentException( - 'Municipal parameters service code must be a 9-digit NBS code.', + 'Municipal parameters service code must contain exactly 9 digits (6-digit national service code plus 3-digit municipal subdivision, or 000 when there is no subdivision).', ); } diff --git a/tests/Unit/Http/MunicipalParametersClientTest.php b/tests/Unit/Http/MunicipalParametersClientTest.php index 4a3b15a..9f483cf 100644 --- a/tests/Unit/Http/MunicipalParametersClientTest.php +++ b/tests/Unit/Http/MunicipalParametersClientTest.php @@ -50,15 +50,15 @@ public function testConvenioUsesOfficialPath(): void public function testAliquotaNormalizesServiceCodeAndPreservesCompetence(): void { self::$server->setResponseOfPath( - '/parametrizacao/3303302/115022000/2026-10-03/aliquota', + '/parametrizacao/3303302/010101000/2026-10-03/aliquota', new Response('{"aliquotas":[{"Aliq":5.0}]}', ['Content-Type' => 'application/json'], 200), ); - $result = $this->client()->aliquota('3303302', '1.1502.20.00', '2026-10-03'); + $result = $this->client()->aliquota('3303302', '01.01.01.000', '2026-10-03'); self::assertSame(5.0, $result['aliquotas'][0]['Aliq'] ?? null); self::assertSame( - '/parametrizacao/3303302/115022000/2026-10-03/aliquota', + '/parametrizacao/3303302/010101000/2026-10-03/aliquota', self::$server->getLastRequest()?->getRequestUri(), ); } @@ -66,12 +66,12 @@ public function testAliquotaNormalizesServiceCodeAndPreservesCompetence(): void public function testRegimesRetencoesAndBenefitUseOfficialPaths(): void { self::$server->setResponseOfPath( - '/parametrizacao/3303302/115022000/2026-10-03/regimes_especiais', + '/parametrizacao/3303302/010101000/2026-10-03/regimes_especiais', new Response('{"regimes":[]}', ['Content-Type' => 'application/json'], 200), ); - $this->client()->regimesEspeciais('3303302', '115022000', '2026-10-03'); + $this->client()->regimesEspeciais('3303302', '010101000', '2026-10-03'); self::assertSame( - '/parametrizacao/3303302/115022000/2026-10-03/regimes_especiais', + '/parametrizacao/3303302/010101000/2026-10-03/regimes_especiais', self::$server->getLastRequest()?->getRequestUri(), );