Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Http/MunicipalParametersClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).',
);
}

Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Http/MunicipalParametersClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,28 @@ 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(),
);
}

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(),
);

Expand Down
Loading