diff --git a/EVENTOS_S_1_2.md b/EVENTOS_S_1_2.md new file mode 100644 index 00000000..4ba359dc --- /dev/null +++ b/EVENTOS_S_1_2.md @@ -0,0 +1,56 @@ +# Eventos versão S 1.2 + +- S-1000 - Informações do Empregador/Contribuinte/Órgão Público +- S-1005 - Tabela de Estabelecimentos, Obras ou Unidades de Órgãos Públicos +- S-1010 - Tabela de Rubricas +- S-1020 - Tabela de Lotações Tributárias +- S-1070 - Tabela de Processos Administrativos/Judiciais +- S-1200 - Remuneração de Trabalhador vinculado ao Regime Geral de Previd. Social +- S-1202 - Remuneração de Servidor vinculado ao Regime Próprio de Previd. Social +- S-1207 - Benefícios - Entes Públicos +- S-1210 - Pagamentos de Rendimentos do Trabalho +- S-1260 - Comercialização da Produção Rural Pessoa Física +- S-1270 - Contratação de Trabalhadores Avulsos Não Portuários +- S-1280 - Informações Complementares aos Eventos Periódicos +- S-1298 - Reabertura dos Eventos Periódicos +- S-1299 - Fechamento dos Eventos Periódicos +- S-2190 - Registro Preliminar de Trabalhador +- S-2200 - Cadastramento Inicial do Vínculo e Admissão/Ingresso de Trabalhador +- S-2205 - Alteração de Dados Cadastrais do Trabalhador +- S-2206 - Alteração de Contrato de Trabalho/Relação Estatutária +- S-2210 - Comunicação de Acidente de Trabalho +- S-2220 - Monitoramento da Saúde do Trabalhador +- S-2230 - Afastamento Temporário +- S-2231 - Cessão/Exercício em Outro Órgão +- S-2240 - Condições Ambientais do Trabalho - Agentes Nocivos +- S-2298 - Reintegração/Outros Provimentos +- S-2299 - Desligamento +- S-2300 - Trabalhador Sem Vínculo de Emprego/Estatutário - Início +- S-2306 - Trabalhador Sem Vínculo de Emprego/Estatutário - Alteração Contratual +- S-2399 - Trabalhador Sem Vínculo de Emprego/Estatutário - Término +- S-2400 - Cadastro de Beneficiário - Entes Públicos - Início +- S-2405 - Cadastro de Beneficiário - Entes Públicos - Alteração +- S-2410 - Cadastro de Benefício - Entes Públicos - Início +- S-2416 - Cadastro de Benefício - Entes Públicos - Alteração +- S-2418 - Reativação de Benefício - Entes Públicos +- S-2420 - Cadastro de Benefício - Entes Públicos - Término +- S-2500 - Processo Trabalhista +- S-2501 - Informações de Tributos Decorrentes de Processo Trabalhista +- S-3000 - Exclusão de Eventos +- S-3500 - Exclusão de Eventos - Processo Trabalhista + +## Eventos retornados pela Receita Federal + +- S-5001 - Informações das Contribuições Sociais por Trabalhador +- S-5002 - Imposto de Renda Retido na Fonte por Trabalhador +- S-5003 - Informações do FGTS por Trabalhador +- S-5011 - Informações das Contribuições Sociais Consolidadas por Contribuinte +- S-5012 - Imposto de Renda Retido na Fonte Consolidado por Contribuinte +- S-5013 - Informações do FGTS Consolidadas por Contribuinte +- S-5501 - Informações Consolidadas de Tributos Decorrentes de Processo Trabalhista +- S-5503 - Informações do FGTS por Trabalhador em Processo Trabalhista + +## Eventos de uso exclusivo do Poder Judiciário + +- S-8200 - Anotação Judicial do Vínculo +- S-8299 - Baixa Judicial do Vínculo diff --git a/README.md b/README.md index f284ff51..af1c0a86 100755 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Este pacote é aderente com os [PSR-1], [PSR-2] e [PSR-4]. Se você observar neg ## Layout S-1.1 (a partir de 19/03/2023) -## Layout S-1.2 (a partir de 20/11/2023) +## [Layout S-1.2 (a partir de 20/11/2023)](EVENTOS_S_1_2.md) ## CRONOGRAMA PREVISTO diff --git a/examples/Fake/v_S_01_02_00/Fake_s2501_EvtContProc.php b/examples/Fake/v_S_01_02_00/Fake_s2501_EvtContProc.php new file mode 100644 index 00000000..ed27fd95 --- /dev/null +++ b/examples/Fake/v_S_01_02_00/Fake_s2501_EvtContProc.php @@ -0,0 +1,137 @@ + 2, + //tipo de ambiente 1 - Produção; 2 - Produção restrita - dados reais;3 - Produção restrita - dados fictícios. + 'verProc' => 'S_1.2.0', + //Versão do processo de emissão do evento. Informar a versão do aplicativo emissor do evento. + 'eventoVersion' => 'S.1.2.0', + //versão do layout do evento + 'serviceVersion' => '1.5.0', + //versão do webservice + 'empregador' => [ + 'tpInsc' => 1, //1-CNPJ, 2-CPF + 'nrInsc' => '99999999', //numero do documento + 'nmRazao' => 'Razao Social', + ], + 'transmissor' => [ + 'tpInsc' => 1, //1-CNPJ, 2-CPF + 'nrInsc' => '99999999999999' //numero do documento + ], +]; +$configJson = json_encode($config, JSON_PRETTY_PRINT); + +$std = new \stdClass(); +$std->sequencial = 1; +$std->indretif = 1; //obrigatorio +$std->nrrecibo = '1.4.1234567890123456789'; //opcional + +$std->nrproctrab = '12345678901234567890'; //obrigatório +$std->perapurpgto = '2023-10'; +$std->obs = 'Bla bla bla'; //opcional + +$std->idetrab[0] = new \stdClass(); //obrigatório 1-n +$std->idetrab[0]->cpftrab = '12345678901'; + +$std->idetrab[0]->calctrib[0] = new \stdClass(); //opcional 0-999 +$std->idetrab[0]->calctrib[0]->perref = '2023-10'; +$std->idetrab[0]->calctrib[0]->vrbccpmensal = 2555.34; +$std->idetrab[0]->calctrib[0]->vrbccp13 = 2555.34; + +$std->idetrab[0]->calctrib[0]->infocrcontrib[0] = new \stdClass(); //opcional 0-99 +$std->idetrab[0]->calctrib[0]->infocrcontrib[0]->tpcr = '113851'; +$std->idetrab[0]->calctrib[0]->infocrcontrib[0]->vrcr = 325.87; + +$std->idetrab[0]->infocrirrf[0] = new \stdClass(); //opcional 0-99 +$std->idetrab[0]->infocrirrf[0]->tpcr = '593656'; //593656 - IRRF - Decisão da Justiça do Trabalho 188951 - IRRF - RRA - Decisão da Justiça do Trabalho +$std->idetrab[0]->infocrirrf[0]->vrcr = 326.91; + +$std->idetrab[0]->infocrirrf[0]->infoir = new \stdClass(); //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrrendtrib = 2555.34; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrrendtrib13 = 2555.34; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrrendmolegrave = 2000; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrrendisen65 = 2000; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrjurosmora = 32.48; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrrendisenntrib = 2000; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->descisenntrib = 'Bla bla bla'; //opcional 1-60 +$std->idetrab[0]->infocrirrf[0]->infoir->vrprevoficial = 800; //opcional + +$std->idetrab[0]->infocrirrf[0]->inforra = new \stdClass(); //opcional +$std->idetrab[0]->infocrirrf[0]->inforra->descrra = 'bla bla bla'; // 1-50 +$std->idetrab[0]->infocrirrf[0]->inforra->qtdmesesrra = 4; + +$std->idetrab[0]->infocrirrf[0]->inforra->despprocjud = new \stdClass(); //opcional +$std->idetrab[0]->infocrirrf[0]->inforra->despprocjud->vlrdespcustas = 200; +$std->idetrab[0]->infocrirrf[0]->inforra->despprocjud->vlrdespadvogados = 12000; + +$std->idetrab[0]->infocrirrf[0]->inforra->ideadv[0] = new \stdClass(); //opcional 0-99 +$std->idetrab[0]->infocrirrf[0]->inforra->ideadv[0]->tpisnc = 1; +$std->idetrab[0]->infocrirrf[0]->inforra->ideadv[0]->nrisnc = '12345678901234'; +$std->idetrab[0]->infocrirrf[0]->inforra->ideadv[0]->vlradv = 12000; + +$std->idetrab[0]->infocrirrf[0]->deddepen[0] = new \stdClass(); //opcional 0-999 +$std->idetrab[0]->infocrirrf[0]->deddepen[0]->tprend = '11'; +$std->idetrab[0]->infocrirrf[0]->deddepen[0]->cpfdep = '12345678901'; +$std->idetrab[0]->infocrirrf[0]->deddepen[0]->vlrdeducao = 300; + +$std->idetrab[0]->infocrirrf[0]->penalim[0] = new \stdClass(); //opcional 0-99 +$std->idetrab[0]->infocrirrf[0]->penalim[0]->tprend = '11'; +$std->idetrab[0]->infocrirrf[0]->penalim[0]->cpfdep = '12345678901'; +$std->idetrab[0]->infocrirrf[0]->penalim[0]->vlrpensao = 1000; + +$std->idetrab[0]->infocrirrf[0]->infoprocret[0] = new \stdClass(); //opcional 0-50 +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->tpprocret = 1; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->nrprocret = '12345678901234567'; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->codsusp = '123'; //opcional + +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0] = new \stdClass(); //opcional 0-2 +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->indapuracao = 1; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->vlrnretido = 100; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->vlrdepjud = 20; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->vlrcmpanocal = 300; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->vlrcmpanoant = 20; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->vlrrendsusp = 400; + +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0] = new \stdClass(); //opcional 0-25 +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0]->indtpdeducao = '1'; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0]->vlrdedsusp = 300; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0]->benefpen[0] = new \stdClass(); //opcional 0-99 +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0]->benefpen[0]->cpfdep = '12345678901'; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0]->benefpen[0]->vlrdepensusp = 300; + +$std->idetrab[0]->infoircomplem = new \stdClass(); //opcional +$std->idetrab[0]->infoircomplem->dtlaudo = '2023-10-31'; +$std->idetrab[0]->infoircomplem->infodep[0] = new \stdClass(); //opcional 0-999 +$std->idetrab[0]->infoircomplem->infodep[0]->cpfdep = '12345678901'; +$std->idetrab[0]->infoircomplem->infodep[0]->dtnascto = '2020-12-01'; +$std->idetrab[0]->infoircomplem->infodep[0]->nome = 'Chica da Silva'; +$std->idetrab[0]->infoircomplem->infodep[0]->depirrf = 'S'; +$std->idetrab[0]->infoircomplem->infodep[0]->tpdep = '03'; +$std->idetrab[0]->infoircomplem->infodep[0]->descrdep = 'bla bla bla'; + +try { + //carrega a classe responsavel por lidar com os certificados + $content = file_get_contents('expired_certificate.pfx'); + $password = 'associacao'; + $certificate = Certificate::readPfx($content, $password); + + //cria o evento e retorna o XML assinado + $xml = Event::evtContProc( + $configJson, + $std, + $certificate, + '2017-08-03 10:37:00' //opcional data e hora + )->toXml(); + + header('Content-type: text/xml; charset=UTF-8'); + echo $xml; +} catch (\Exception $e) { + echo $e->getMessage(); +} diff --git a/examples/schemes/v_S_01_02_00/s2501_JsonSchemaEvtContProc.php b/examples/schemes/v_S_01_02_00/s2501_JsonSchemaEvtContProc.php new file mode 100644 index 00000000..37f5c56a --- /dev/null +++ b/examples/schemes/v_S_01_02_00/s2501_JsonSchemaEvtContProc.php @@ -0,0 +1,575 @@ +sequencial = 1; +$std->indretif = 1; //obrigatorio +$std->nrrecibo = '1.4.1234567890123456789'; //opcional + +$std->nrproctrab = '12345678901234567890'; //obrigatório +$std->perapurpgto = '2023-10'; +$std->obs = 'Bla bla bla'; //opcional + +$std->idetrab[0] = new \stdClass(); //obrigatório 1-n +$std->idetrab[0]->cpftrab = '12345678901'; + +$std->idetrab[0]->calctrib[0] = new \stdClass(); //opcional 0-999 +$std->idetrab[0]->calctrib[0]->perref = '2023-10'; +$std->idetrab[0]->calctrib[0]->vrbccpmensal = 2555.34; +$std->idetrab[0]->calctrib[0]->vrbccp13 = 2555.34; + +$std->idetrab[0]->calctrib[0]->infocrcontrib[0] = new \stdClass(); //opcional 0-99 +$std->idetrab[0]->calctrib[0]->infocrcontrib[0]->tpcr = '113851'; +$std->idetrab[0]->calctrib[0]->infocrcontrib[0]->vrcr = 325.87; + +$std->idetrab[0]->infocrirrf[0] = new \stdClass(); //opcional 0-99 +$std->idetrab[0]->infocrirrf[0]->tpcr = '593656'; //593656 - IRRF - Decisão da Justiça do Trabalho 188951 - IRRF - RRA - Decisão da Justiça do Trabalho +$std->idetrab[0]->infocrirrf[0]->vrcr = 326.91; + +$std->idetrab[0]->infocrirrf[0]->infoir = new \stdClass(); //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrrendtrib = 2555.34; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrrendtrib13 = 2555.34; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrrendmolegrave = 2000; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrrendisen65 = 2000; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrjurosmora = 32.48; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->vrrendisenntrib = 2000; //opcional +$std->idetrab[0]->infocrirrf[0]->infoir->descisenntrib = 'Bla bla bla'; //opcional 1-60 +$std->idetrab[0]->infocrirrf[0]->infoir->vrprevoficial = 800; //opcional + +$std->idetrab[0]->infocrirrf[0]->inforra = new \stdClass(); //opcional +$std->idetrab[0]->infocrirrf[0]->inforra->descrra = 'bla bla bla'; // 1-50 +$std->idetrab[0]->infocrirrf[0]->inforra->qtdmesesrra = 4; + +$std->idetrab[0]->infocrirrf[0]->inforra->despprocjud = new \stdClass(); //opcional +$std->idetrab[0]->infocrirrf[0]->inforra->despprocjud->vlrdespcustas = 200; +$std->idetrab[0]->infocrirrf[0]->inforra->despprocjud->vlrdespadvogados = 12000; + +$std->idetrab[0]->infocrirrf[0]->inforra->ideadv[0] = new \stdClass(); //opcional 0-99 +$std->idetrab[0]->infocrirrf[0]->inforra->ideadv[0]->tpisnc = 1; +$std->idetrab[0]->infocrirrf[0]->inforra->ideadv[0]->nrisnc = '12345678901234'; +$std->idetrab[0]->infocrirrf[0]->inforra->ideadv[0]->vlradv = 12000; + +$std->idetrab[0]->infocrirrf[0]->deddepen[0] = new \stdClass(); //opcional 0-999 +$std->idetrab[0]->infocrirrf[0]->deddepen[0]->tprend = '11'; +$std->idetrab[0]->infocrirrf[0]->deddepen[0]->cpfdep = '12345678901'; +$std->idetrab[0]->infocrirrf[0]->deddepen[0]->vlrdeducao = 300; + +$std->idetrab[0]->infocrirrf[0]->penalim[0] = new \stdClass(); //opcional 0-99 +$std->idetrab[0]->infocrirrf[0]->penalim[0]->tprend = '11'; +$std->idetrab[0]->infocrirrf[0]->penalim[0]->cpfdep = '12345678901'; +$std->idetrab[0]->infocrirrf[0]->penalim[0]->vlrpensao = 1000; + +$std->idetrab[0]->infocrirrf[0]->infoprocret[0] = new \stdClass(); //opcional 0-50 +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->tpprocret = 1; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->nrprocret = '12345678901234567'; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->codsusp = '123'; //opcional + +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0] = new \stdClass(); //opcional 0-2 +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->indapuracao = 1; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->vlrnretido = 100; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->vlrdepjud = 20; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->vlrcmpanocal = 300; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->vlrcmpanoant = 20; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->vlrrendsusp = 400; + +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0] = new \stdClass(); //opcional 0-25 +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0]->indtpdeducao = '1'; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0]->vlrdedsusp = 300; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0]->benefpen[0] = new \stdClass(); //opcional 0-99 +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0]->benefpen[0]->cpfdep = '12345678901'; +$std->idetrab[0]->infocrirrf[0]->infoprocret[0]->infovalores[0]->dedsusp[0]->benefpen[0]->vlrdepensusp = 300; + +$std->idetrab[0]->infoircomplem = new \stdClass(); //opcional +$std->idetrab[0]->infoircomplem->dtlaudo = '2023-10-31'; +$std->idetrab[0]->infoircomplem->infodep[0] = new \stdClass(); //opcional 0-999 +$std->idetrab[0]->infoircomplem->infodep[0]->cpfdep = '12345678901'; +$std->idetrab[0]->infoircomplem->infodep[0]->dtnascto = '2020-12-01'; +$std->idetrab[0]->infoircomplem->infodep[0]->nome = 'Chica da Silva'; +$std->idetrab[0]->infoircomplem->infodep[0]->depirrf = 'S'; +$std->idetrab[0]->infoircomplem->infodep[0]->tpdep = '03'; +$std->idetrab[0]->infoircomplem->infodep[0]->descrdep = 'bla bla bla'; + + + + + +// Schema must be decoded before it can be used for validation +$jsonSchemaObject = json_decode($jsonSchema); +if (empty($jsonSchemaObject)) { + echo "

Erro de digitação no schema ! Revise

"; + echo "
";
+    print_r($jsonSchema);
+    echo "
"; + die(); +} + +// The SchemaStorage can resolve references, loading additional schemas from file as needed, etc. +$schemaStorage = new SchemaStorage(); + +// This does two things: +// 1) Mutates $jsonSchemaObject to normalize the references (to file://mySchema#/definitions/integerData, etc) +// 2) Tells $schemaStorage that references to file://mySchema... should be resolved by looking in $jsonSchemaObject +$definitions = realpath(__DIR__."/../../../jsonSchemes/definitions.schema"); +$schemaStorage->addSchema("file:{$definitions}", $jsonSchemaObject); + +// Provide $schemaStorage to the Validator so that references can be resolved during validation +$jsonValidator = new Validator(new Factory($schemaStorage)); + +// Do validation (use isValid() and getErrors() to check the result) +$jsonValidator->validate( + $std, + $jsonSchemaObject, + Constraint::CHECK_MODE_COERCE_TYPES //tenta converter o dado no tipo indicado no schema +); + +if ($jsonValidator->isValid()) { + echo "The supplied JSON validates against the schema.
"; +} else { + echo "JSON does not validate. Violations:
"; + foreach ($jsonValidator->getErrors() as $error) { + echo sprintf("[%s] %s
", $error['property'], $error['message']); + } + die; +} +//salva se sucesso +file_put_contents("../../../jsonSchemes/v_$version/$evento.schema", $jsonSchema); + + diff --git a/jsonSchemes/v_S_01_02_00/evtContProc.schema b/jsonSchemes/v_S_01_02_00/evtContProc.schema new file mode 100644 index 00000000..1299d66b --- /dev/null +++ b/jsonSchemes/v_S_01_02_00/evtContProc.schema @@ -0,0 +1,424 @@ +{ + "title": "evtContProc", + "type": "object", + "properties": { + "sequencial": { + "required": false, + "type": ["integer","null"], + "minimum": 1, + "maximum": 99999 + }, + "indretif": { + "required": true, + "type": "integer", + "minimum": 1, + "maximum": 2 + }, + "nrrecibo": { + "required": false, + "type": ["string","null"], + "$ref": "#/definitions/recibo" + }, + "nrproctrab": { + "required": true, + "type": "string", + "pattern": "^(.{15}|.{20})$" + }, + "perapurpgto": { + "required": true, + "type": "string", + "$ref": "#/definitions/periodo" + }, + "obs": { + "required": false, + "type": ["string","null"], + "minLength": 1, + "maxLength": 999 + }, + "idetrab": { + "required": true, + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "properties": { + "cpftrab": { + "required": true, + "type": "string", + "pattern": "^[0-9]{11}$" + }, + "calctrib": { + "required": false, + "type": ["array","null"], + "minItems": 0, + "maxItems": 999, + "items": { + "type": "object", + "properties": { + "perref": { + "required": true, + "type": "string", + "$ref": "#/definitions/periodo" + }, + "vrbccpmensal": { + "required": true, + "type": "number" + }, + "vrbccp13": { + "required": true, + "type": "number" + }, + "infocrcontrib": { + "required": false, + "type": ["array","null"], + "minItems": 0, + "maxItems": 99, + "items": { + "type": "object", + "properties": { + "tpcr": { + "required": true, + "type": "string", + "pattewrn": "^[0-9]{6}$" + }, + "vrcr": { + "required": true, + "type": "number" + } + } + } + } + } + } + }, + "infocrirrf": { + "required": false, + "type": ["array","null"], + "minItems": 0, + "maxItems": 99, + "items": { + "type": "object", + "properties": { + "tpcr": { + "required": true, + "type": "string", + "pattern": "^(593656|188951)$" + }, + "vrcr": { + "required": true, + "type": "number" + }, + "infoir": { + "required": false, + "type": ["object","null"], + "properties": { + "vrrendtrib": { + "required": false, + "type": ["number","null"] + }, + "vrrendtrib13": { + "required": false, + "type": ["number","null"] + }, + "vrrendmolegrave": { + "required": false, + "type": ["number","null"] + }, + "vrrendisen65": { + "required": false, + "type": ["number","null"] + }, + "vrjurosmora": { + "required": false, + "type": ["number","null"] + }, + "vrrendisenntrib": { + "required": false, + "type": ["number","null"] + }, + "descisenntrib": { + "required": false, + "type": ["string","null"], + "minLength": 1, + "maxLength": 60 + }, + "vrprevoficial": { + "required": false, + "type": ["number","null"] + } + } + }, + "inforra": { + "required": false, + "type": ["object","null"], + "properties": { + "descrra": { + "required": true, + "type": "string", + "minLength": 1, + "maxLength": 50 + }, + "qtdmesesrra": { + "required": true, + "type": "integer", + "minimum": 1, + "maximum": 9999 + }, + "despprocjud": { + "required": false, + "type": ["object","null"], + "properties": { + "vlrdespcustas": { + "required": true, + "type": "number" + }, + "vlrdespadvogados": { + "required": true, + "type": "number" + }, + "ideadv": { + "required": false, + "type": ["array","null"], + "minItems": 0, + "maxItems": 99, + "items": { + "type": "object", + "properties": { + "tpinsc": { + "required": true, + "type": "integer", + "minimum": 1, + "maximum": 2 + }, + "nrinsc": { + "required": true, + "type": "string", + "pattern": "^[0-9]{11,14}$" + }, + "vlradv": { + "required": false, + "type": ["number","null"] + } + } + } + } + } + } + } + }, + "deddepen": { + "required": false, + "type": ["array","null"], + "minItems": 0, + "maxItems": 999, + "items": { + "type": "object", + "properties": { + "tprend": { + "required": true, + "type": "string", + "pattern": "^(11|12)$" + }, + "cpfdep": { + "required": true, + "type": "string", + "pattern": "^[0-9]{11}$" + }, + "vlrdeducao": { + "required": true, + "type": "number" + } + } + } + }, + "penalim": { + "required": false, + "type": ["array","null"], + "minItems": 0, + "maxItems": 99, + "items": { + "type": "object", + "properties": { + "tprend": { + "required": true, + "type": "string", + "pattern": "^(11|12|18|79)$" + }, + "cpfdep": { + "required": true, + "type": "string", + "pattern": "^[0-9]{11}$" + }, + "vlrpensao": { + "required": true, + "type": "number" + } + } + } + }, + "infoprocret": { + "required": false, + "type": ["array","null"], + "minItems": 0, + "maxItems": 50, + "items": { + "type": "object", + "properties": { + "tpprocret": { + "required": true, + "type": "integer", + "minimum": 1, + "maximum": 2 + }, + "nrprocret": { + "required": true, + "type": "string", + "pattern": "^(.{17}|.{20}|.{21})$" + }, + "codsusp": { + "required": true, + "type": "string", + "pattern": "^(.{1,14})$" + }, + "infovalores": { + "required": false, + "type": ["array","null"], + "minItems": 0, + "maxItems": 2, + "items": { + "type": "object", + "properties": { + "indapuracao": { + "required": true, + "type": "integer", + "minimum": 1, + "maximum": 2 + }, + "vlrnretido": { + "required": false, + "type": ["number","null"] + }, + "vlrdepjud": { + "required": false, + "type": ["number","null"] + }, + "vlrcmpanocal": { + "required": false, + "type": ["number","null"] + }, + "vlrcmpanoant": { + "required": false, + "type": ["number","null"] + }, + "vlrrendsusp": { + "required": false, + "type": ["number","null"] + }, + "dedsusp": { + "required": false, + "type": ["array","null"], + "minItems": 0, + "maxItems": 25, + "items": { + "type": "object", + "properties": { + "indtpdeducao": { + "required": true, + "type": "string", + "pattern": "^(1|5|7)$" + }, + "vlrdedsusp": { + "required": false, + "type": ["number","null"] + }, + "benefpen": { + "required": false, + "type": ["array","null"], + "minItems": 0, + "maxItems": 99, + "items": { + "type": "object", + "properties": { + "cpfdep": { + "required": true, + "type": "string", + "pattern": "^[0-9]{11}$" + }, + "vlrdepensusp": { + "required": true, + "type": "number" + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }, + "infoircomplem": { + "required": false, + "type": ["object","null"], + "properties": { + "dtlaudo": { + "required": false, + "type": ["string","null"], + "$ref": "#/definitions/data" + }, + "infodep": { + "required": false, + "type": ["array","null"], + "minItems": 0, + "maxItems": 999, + "items": { + "type": "object", + "properties": { + "cpfdep": { + "required": true, + "type": "string", + "pattern": "^[0-9]{11}$" + }, + "dtnascto": { + "required": false, + "type": ["string","null"], + "$ref": "#/definitions/data" + }, + "nome": { + "required": false, + "type": ["string","null"], + "minLength": 2, + "maxLength": 70 + }, + "depirrf": { + "required": false, + "type": ["string","null"], + "pattern": "^(S)$" + }, + "tpdep": { + "required": false, + "type": ["string","null"], + "pattern": "^[0-9]{2}$" + }, + "descrdep": { + "required": false, + "type": ["string","null"], + "minLength": 1, + "maxLength": 100 + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/Factories/Traits/TraitS2501.php b/src/Factories/Traits/TraitS2501.php index 32187607..9489917b 100644 --- a/src/Factories/Traits/TraitS2501.php +++ b/src/Factories/Traits/TraitS2501.php @@ -128,4 +128,194 @@ protected function toNodeS110() //$this->xml = $this->dom->saveXML($this->eSocial); $this->sign(); } + + /** + * builder for version S.1.2.0 + */ + protected function toNodeS120() + { + $ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); + //o idEvento pode variar de evento para evento + //então cada factory individualmente terá de construir o seu + $ideEvento = $this->dom->createElement("ideEvento"); + $this->dom->addChild( + $ideEvento, + "indRetif", + $this->std->indretif, + true + ); + if ($this->std->indretif == 2) { + $this->dom->addChild( + $ideEvento, + "nrRecibo", + $this->std->nrrecibo, + true + ); + } + $this->dom->addChild( + $ideEvento, + "tpAmb", + $this->tpAmb, + true + ); + $this->dom->addChild( + $ideEvento, + "procEmi", + $this->procEmi, + true + ); + $this->dom->addChild( + $ideEvento, + "verProc", + $this->verProc, + true + ); + $this->node->insertBefore($ideEvento, $ideEmpregador); + $ideproc = $this->dom->createElement("ideProc"); + $this->dom->addChild( + $ideproc, + "nrProcTrab", + $this->std->nrproctrab, + true + ); + $this->dom->addChild( + $ideproc, + "perApurPgto", + $this->std->perapurpgto, + true + ); + $this->dom->addChild( + $ideproc, + "obs", + $this->std->obs ?? null, + false + ); + $this->node->appendChild($ideproc); + foreach ($this->std->idetrab as $ide) { + $idetrab = $this->dom->createElement("ideTrab"); + $this->dom->addAttribute($idetrab, 'cpfTrab', $ide->cpftrab); + if (!empty($ide->calctrib)) {} + if (!empty($ide->infocrirrf)) { + foreach ($ide->infocrirrf as $cr) { + $infocrirrf = $this->dom->createElement("infoCRIRRF"); + $this->dom->addAttribute($infocrirrf, 'tpCR', $cr->tpcr ?? null); + $this->dom->addAttribute($infocrirrf, 'vrCR', $cr->vrcr ?? null); + if (!empty($cr->infoir)) { + $iir = $cr->infoir; + $infoir = $this->dom->createElement("infoIR"); + $this->dom->addAttribute($infoir, 'vrRendTrib', $iir->vrrendtrib ?? null); + $this->dom->addAttribute($infoir, 'vrRendTrib13', $iir->vrrendtrib13 ?? null); + $this->dom->addAttribute($infoir, 'vrRendMoleGrave', $iir->vrrendmolegrave ?? null); + $this->dom->addAttribute($infoir, 'vrRendIsen65', $iir->vrrendisen65 ?? null); + $this->dom->addAttribute($infoir, 'vrJurosMora', $iir->vrjurosmora ?? null); + $this->dom->addAttribute($infoir, 'vrRendIsenNTrib', $iir->vrrendisenntrib ?? null); + $this->dom->addAttribute($infoir, 'descIsenNTrib', $iir->descisenntrib ?? null); + $this->dom->addAttribute($infoir, 'vrPrevOficial', $iir->vrprevoficial ?? null); + $infocrirrf->appendChild($infoir); + } + if (!empty($cr->inforra)) { + $rra = $cr->inforra; + $inforra = $this->dom->createElement("infoRRA"); + $this->dom->addAttribute($inforra, 'descRRA', $rra->descrra ?? null); + $this->dom->addAttribute($inforra, 'qtdMesesRRA', $rra->qtdmesesrra ?? null); + if (!empty($rra->despprocjud)) { + $des = $rra->despprocjud; + $despprocjud = $this->dom->createElement("despProcJud"); + $this->dom->addAttribute($despprocjud, 'vlrDespCustas', $des->vlrdespcustas ?? null); + $this->dom->addAttribute($despprocjud, 'vlrDespAdvogados', $des->vlrdespadvogados ?? null); + $inforra->appendChild($despprocjud); + } + if (!empty($rra->ideadv)) { + foreach($rra->ideadv as $adv) { + $ideadv = $this->dom->createElement("ideAdv"); + $this->dom->addAttribute($ideadv, 'tpInsc', $adv->tpinsc ?? null); + $this->dom->addAttribute($ideadv, 'nrInsc', $adv->nrinsc ?? null); + $this->dom->addAttribute($ideadv, 'vlrAdv', $adv->vlradv ?? null); + $inforra->appendChild($ideadv); + } + } + $infocrirrf->appendChild($inforra); + } + if (!empty($cr->deddepen)) { + foreach ($cr->deddepen as $ded) { + $deddepen = $this->dom->createElement("dedDepen"); + $this->dom->addAttribute($deddepen, 'tpRend', $ded->tprend ?? null); + $this->dom->addAttribute($deddepen, 'cpfDep', $ded->cpfdep ?? null); + $this->dom->addAttribute($deddepen, 'vlrDeducao', $ded->vlrdeducao ?? null); + $infocrirrf->appendChild($deddepen); + } + } + if (!empty($cr->penalim)) { + foreach($cr->penalim as $pen) { + $penalim = $this->dom->createElement("penAlim"); + $this->dom->addAttribute($penalim, 'tpRend', $pen->tprend ?? null); + $this->dom->addAttribute($penalim, 'cpfDep', $pen->cpfdep ?? null); + $this->dom->addAttribute($penalim, 'vlrPensao', $pen->vlrpensao ?? null); + $infocrirrf->appendChild($penalim); + } + } + if (!empty($cr->infoprocret)) { + foreach ($cr->infoprocret as $ret) { + $infoprocret = $this->dom->createElement("infoProcRet"); + $this->dom->addAttribute($infoprocret, 'tpProcRet', $ret->tpprocret ?? null); + $this->dom->addAttribute($infoprocret, 'nrProcRet', $ret->nrprocret ?? null); + $this->dom->addAttribute($infoprocret, 'codSusp', $ret->codsusp ?? null); + if (!empty($ret->infovalores)) { + foreach($ret->infovalores as $val) { + $infovalores = $this->dom->createElement("infoValores"); + $this->dom->addAttribute($infovalores, 'indApuracao', $val->indapuracao ?? null); + $this->dom->addAttribute($infovalores, 'vlrNRetido', $val->vlrnretido ?? null); + $this->dom->addAttribute($infovalores, 'vlrDepJud', $val->vlrdepjud ?? null); + $this->dom->addAttribute($infovalores, 'vlrCmpAnoCal', $val->vlrcmpanocal ?? null); + $this->dom->addAttribute($infovalores, 'vlrCmpAnoAnt', $val->vlrcmpanoant ?? null); + $this->dom->addAttribute($infovalores, 'vlrRendSusp', $val->vlrrendsusp ?? null); + if (!empty($val->dedsusp)) { + foreach($val->dedsusp as $sus) { + $dedsusp = $this->dom->createElement("dedSusp"); + $this->dom->addAttribute($dedsusp, 'indTpDeducao', $sus->indtpdeducao ?? null); + $this->dom->addAttribute($dedsusp, 'vlrDedSusp', $sus->vlrdedsusp ?? null); + if (!empty($sus->benefpen)) { + foreach($sus->benefpen as $ben) { + $benefpen = $this->dom->createElement("benefPen"); + $this->dom->addAttribute($benefpen, 'cpfDep', $ben->cpfdep ?? null); + $this->dom->addAttribute($benefpen, 'vlrDepenSusp', $ben->vlrdepensusp ?? null); + $dedsusp->appendChild($benefpen); + } + } + $infovalores->appendChild($dedsusp); + } + } + $infoprocret->appendChild($infovalores); + } + } + $infocrirrf->appendChild($infoprocret); + } + } + $idetrab->appendChild($infocrirrf); + } + } + if (!empty($ide->infoircomplem)) { + $infoircomplem = $this->dom->createElement("infoIRComplem"); + $this->dom->addAttribute($infoircomplem, 'dtLaudo', $ide->infoircomplem->dtlaudo ?? null); + if (!empty($ide->infoircomplem->infodep)) { + foreach($ide->infoircomplem->infodep as $dep) { + $infodep = $this->dom->createElement("infoDep"); + $this->dom->addAttribute($infodep, 'cpfDep', $dep->cpfdep ?? null); + $this->dom->addAttribute($infodep, 'dtNascto', $dep->dtnascto ?? null); + $this->dom->addAttribute($infodep, 'nome', $dep->nome ?? null); + $this->dom->addAttribute($infodep, 'depIRRF', $dep->depirrf ?? null); + $this->dom->addAttribute($infodep, 'tpDep', $dep->tpdep ?? null); + $this->dom->addAttribute($infodep, 'descrDep', $dep->descrdep ?? null); + $infoircomplem->appendChild($infodep); + } + } + $idetrab->appendChild($infoircomplem); + } + } + $this->node->appendChild($idetrab); + //finalização do xml + $this->eSocial->appendChild($this->node); + //$this->xml = $this->dom->saveXML($this->eSocial); + $this->sign(); + } }