From d3574646864699c1ad84e9f8c0ac6b0bc58f8d87 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 7 Oct 2026 00:20:30 +0000 Subject: [PATCH] fix: format municipal service code in ADN paths Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- src/Http/MunicipalParametersClient.php | 5 ++++- tests/Unit/Http/MunicipalParametersClientTest.php | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Http/MunicipalParametersClient.php b/src/Http/MunicipalParametersClient.php index 8553c82..e2fead6 100644 --- a/src/Http/MunicipalParametersClient.php +++ b/src/Http/MunicipalParametersClient.php @@ -152,7 +152,10 @@ private function serviceCode(string $codigoServico): string ); } - return $value; + return substr($value, 0, 2) + . '.' . substr($value, 2, 2) + . '.' . substr($value, 4, 2) + . '.' . substr($value, 6, 3); } private function competence(string $competencia): string diff --git a/tests/Unit/Http/MunicipalParametersClientTest.php b/tests/Unit/Http/MunicipalParametersClientTest.php index 9f483cf..2f59544 100644 --- a/tests/Unit/Http/MunicipalParametersClientTest.php +++ b/tests/Unit/Http/MunicipalParametersClientTest.php @@ -50,7 +50,7 @@ public function testConvenioUsesOfficialPath(): void public function testAliquotaNormalizesServiceCodeAndPreservesCompetence(): void { self::$server->setResponseOfPath( - '/parametrizacao/3303302/010101000/2026-10-03/aliquota', + '/parametrizacao/3303302/01.01.01.000/2026-10-03/aliquota', new Response('{"aliquotas":[{"Aliq":5.0}]}', ['Content-Type' => 'application/json'], 200), ); @@ -58,7 +58,7 @@ public function testAliquotaNormalizesServiceCodeAndPreservesCompetence(): void self::assertSame(5.0, $result['aliquotas'][0]['Aliq'] ?? null); self::assertSame( - '/parametrizacao/3303302/010101000/2026-10-03/aliquota', + '/parametrizacao/3303302/01.01.01.000/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/010101000/2026-10-03/regimes_especiais', + '/parametrizacao/3303302/01.01.01.000/2026-10-03/regimes_especiais', new Response('{"regimes":[]}', ['Content-Type' => 'application/json'], 200), ); $this->client()->regimesEspeciais('3303302', '010101000', '2026-10-03'); self::assertSame( - '/parametrizacao/3303302/010101000/2026-10-03/regimes_especiais', + '/parametrizacao/3303302/01.01.01.000/2026-10-03/regimes_especiais', self::$server->getLastRequest()?->getRequestUri(), );