From ed371456e3eacc39c8e6e64d8113ff73cf567207 Mon Sep 17 00:00:00 2001 From: Lauro Correa Junior Date: Mon, 18 Mar 2024 07:36:36 -0300 Subject: [PATCH] Ajusta consulta R4020 --- src/Tools.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Tools.php b/src/Tools.php index f7bed38..8d6eb3f 100755 --- a/src/Tools.php +++ b/src/Tools.php @@ -1144,12 +1144,12 @@ private static function urlR4020(stdClass $std): string { $required = [ 'perapur' => '/^20([0-9][0-9])-(0[1-9]|1[0-2])$/', - 'tpinscestab' => '/^(1|4)$/', - 'nrinscestab' => '/^[0-9]{12}|[0-9]{14}$/', + 'tpinscestab' => '/^(1|2|3)$/', + 'nrinscestab' => '/^[0-9]{11}|[0-9]{14}$/', ]; $std = self::propertiesToLower($std); - if (!empty($std->cpfbenef)) { - $required['cpfbenef'] = '/^[0-9]{11}$/'; + if (!empty($std->cnpjbenef)) { + $required['cnpjbenef'] = '/^[0-9]{14}$/'; } $val = self::validateConsultData($required, $std); if (!$val['status']) { @@ -1157,10 +1157,10 @@ private static function urlR4020(stdClass $std): string throw new \RuntimeException('Campos foram passados com erro para a consulta. ' . $message); } $base = self::urlbase($std); - if (!empty($std->cpfbenef)) { - return "{$base}/{$std->perapur}/{$std->tpinscestab}/{$std->nrinscestab}/{$std->cpfbenef}"; + if (!empty($std->cnpjbenef)) { + return "{$base}/{$std->perapur}/{$std->tpinscestab}/{$std->nrinscestab}/{$std->cnpjbenef}"; } - return "{$std->baseurl}/R4020/semCpfBeneficiario/{$std->tpinsc}/{$std->nrinsc}/{$std->perapur}" + return "{$std->baseurl}/R4020/semCnpjBeneficiario/{$std->tpinsc}/{$std->nrinsc}/{$std->perapur}" . "/{$std->tpinscestab}/{$std->nrinscestab}"; }