diff --git a/examples/Fake/v_S_01_01_00/Fake_s1207_EvtBenPrRP.php b/examples/Fake/v_S_01_01_00/Fake_s1207_EvtBenPrRP.php index 2b794012..1bd7f860 100644 --- a/examples/Fake/v_S_01_01_00/Fake_s1207_EvtBenPrRP.php +++ b/examples/Fake/v_S_01_01_00/Fake_s1207_EvtBenPrRP.php @@ -41,6 +41,19 @@ $std->dmdev[0]->idedmdev = '11111111111111111111'; //Obrigatório $std->dmdev[0]->nrbeneficio = '11111111111111111111'; //Obrigatório +$std->dmdev[0]->indrra = 'S'; //S ou null +$std->dmdev[0]->inforra = new \stdClass(); //Opcional se indRRA for NULL +$std->dmdev[0]->inforra->tpprocrra = 1; //Obrigatorio 1 -Administrativo ou 2 - judicial +$std->dmdev[0]->inforra->nrprocrra = '12345678901234567'; //Obrigatório +$std->dmdev[0]->inforra->descrra = 'Descrição do RRA'; //Obrigatório até 50 caracteres +$std->dmdev[0]->inforra->qtdmesesrra = 1; //Obrigatório de 9 atá 999.9 +$std->dmdev[0]->inforra->despprocjud = new \stdClass(); //Opcional +$std->dmdev[0]->inforra->despprocjud->vlrdespcustas = 100.00; //Obrigatório +$std->dmdev[0]->inforra->despprocjud->vlrdespadvogados = 5000.00; //Obrigatório +$std->dmdev[0]->inforra->ideadv[0] = new \stdClass(); //Opcional até 1 até 99 +$std->dmdev[0]->inforra->ideadv[0]->tpinsc = 1; //Obrigatório 1-CNPJ ou 2-CPF +$std->dmdev[0]->inforra->ideadv[0]->nrinsc = '12345678901234'; //Obrigatório + //Informações relativas ao período de apuração. $std->dmdev[0]->infoperapur = new \stdClass(); //Opcional diff --git a/examples/schemes/v_S_01_01_00/s1207_JsonSchemaEvtBenPrRP.php b/examples/schemes/v_S_01_01_00/s1207_JsonSchemaEvtBenPrRP.php index b2d470b5..f1b0a944 100644 --- a/examples/schemes/v_S_01_01_00/s1207_JsonSchemaEvtBenPrRP.php +++ b/examples/schemes/v_S_01_01_00/s1207_JsonSchemaEvtBenPrRP.php @@ -73,9 +73,79 @@ "minLength": 1, "maxLength": 20 }, + "indrra": { + "required": false, + "type": ["string","null"], + "pattern": "^(S)$" + }, + "inforra": { + "required": false, + "type": ["object","null"], + "properties": { + "tpprocrra": { + "required": true, + "type": "integer", + "minimum": 1, + "maximum": 2 + }, + "nrprocrra": { + "required": true, + "type": "string", + "pattern": "^[0-9]{17}|[0-9]{20}|[0-9]{21}$" + }, + "descrra": { + "required": true, + "type": "string", + "minLength": 1, + "maxLength": 50 + }, + "qtdmesesrra": { + "required": true, + "type": "number", + "minimum": 0, + "maximum": 999.9 + }, + "despprocjud": { + "required": false, + "type": ["object","null"], + "properties": { + "vlrdespcustas": { + "required": true, + "type": "number" + }, + "vlrdespadvogados": { + "required": true, + "type": "number" + } + } + }, + "ideadv": { + "required": false, + "type": ["array","null"], + "minItems": 1, + "maxItems": 99, + "items": { + "type": "object", + "properties": { + "tpinsc": { + "required": true, + "type": "integer", + "minimum": 1, + "maximum": 2 + }, + "nrinsc": { + "required": true, + "type": "string", + "pattern": "^([0-9]{11}|[0-9]{14})$" + } + } + } + } + } + }, "infoperapur": { "required": false, - "type": "object", + "type": ["object","null"], "properties": { "ideestab": { "required": true, @@ -97,7 +167,7 @@ "pattern": "^[0-9]{14}$" }, "itensremun": { - "codrubr": { + "codrubr": { "required": true, "type": "string", "minLength": 1, @@ -228,6 +298,20 @@ $std->dmdev[0]->idedmdev = '11111111111111111111'; //Obrigatório $std->dmdev[0]->nrbeneficio = '11111111111111111111'; //Obrigatório +$std->dmdev[0]->indrra = 'S'; //S ou null +$std->dmdev[0]->inforra = new \stdClass(); //Opcional se indRRA for NULL +$std->dmdev[0]->inforra->tpprocrra = 1; //Obrigatorio 1 -Administrativo ou 2 - judicial +$std->dmdev[0]->inforra->nrprocrra = '12345678901234567'; //Obrigatório +$std->dmdev[0]->inforra->descrra = 'Descrição do RRA'; //Obrigatório até 50 caracteres +$std->dmdev[0]->inforra->qtdmesesrra = 1; //Obrigatório de 9 atá 999.9 +$std->dmdev[0]->inforra->despprocjud = new \stdClass(); //Opcional +$std->dmdev[0]->inforra->despprocjud->vlrdespcustas = 100.00; //Obrigatório +$std->dmdev[0]->inforra->despprocjud->vlrdespadvogados = 5000.00; //Obrigatório +$std->dmdev[0]->inforra->ideadv[0] = new \stdClass(); //Opcional até 1 até 99 +$std->dmdev[0]->inforra->ideadv[0]->tpinsc = 1; //Obrigatório 1-CNPJ ou 2-CPF +$std->dmdev[0]->inforra->ideadv[0]->nrinsc = '12345678901234'; //Obrigatório + + //Informações relativas ao período de apuração. $std->dmdev[0]->infoperapur = new \stdClass(); //Opcional diff --git a/jsonSchemes/v_S_01_01_00/evtBenPrRP.schema b/jsonSchemes/v_S_01_01_00/evtBenPrRP.schema index 9bf21c07..26c6e54c 100644 --- a/jsonSchemes/v_S_01_01_00/evtBenPrRP.schema +++ b/jsonSchemes/v_S_01_01_00/evtBenPrRP.schema @@ -56,9 +56,79 @@ "minLength": 1, "maxLength": 20 }, + "indrra": { + "required": false, + "type": ["string","null"], + "pattern": "^(S)$" + }, + "inforra": { + "required": false, + "type": ["object","null"], + "properties": { + "tpprocrra": { + "required": true, + "type": "integer", + "minimum": 1, + "maximum": 2 + }, + "nrprocrra": { + "required": true, + "type": "string", + "pattern": "^[0-9]{17}|[0-9]{20}|[0-9]{21}$" + }, + "descrra": { + "required": true, + "type": "string", + "minLength": 1, + "maxLength": 50 + }, + "qtdmesesrra": { + "required": true, + "type": "number", + "minimum": 0, + "maximum": 999.9 + }, + "despprocjud": { + "required": false, + "type": ["object","null"], + "properties": { + "vlrdespcustas": { + "required": true, + "type": "number" + }, + "vlrdespadvogados": { + "required": true, + "type": "number" + } + } + }, + "ideadv": { + "required": false, + "type": ["array","null"], + "minItems": 1, + "maxItems": 99, + "items": { + "type": "object", + "properties": { + "tpinsc": { + "required": true, + "type": "integer", + "minimum": 1, + "maximum": 2 + }, + "nrinsc": { + "required": true, + "type": "string", + "pattern": "^([0-9]{11}|[0-9]{14})$" + } + } + } + } + } + }, "infoperapur": { "required": false, - "type": "object", + "type": ["object","null"], "properties": { "ideestab": { "required": true, @@ -80,7 +150,7 @@ "pattern": "^[0-9]{14}$" }, "itensremun": { - "codrubr": { + "codrubr": { "required": true, "type": "string", "minLength": 1, diff --git a/src/Factories/Traits/TraitS1207.php b/src/Factories/Traits/TraitS1207.php index b7eba881..d4ed901e 100644 --- a/src/Factories/Traits/TraitS1207.php +++ b/src/Factories/Traits/TraitS1207.php @@ -334,6 +334,279 @@ protected function toNodeS100() */ protected function toNodeS110() { - return $this->toNodeS100(); + $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 + ); + $this->dom->addChild( + $ideEvento, + "nrRecibo", + !empty($this->std->nrrecibo) ? $this->std->nrrecibo : null, + false + ); + $this->dom->addChild( + $ideEvento, + "indApuracao", + $this->std->indapuracao, + true + ); + $this->dom->addChild( + $ideEvento, + "perApur", + $this->std->perapur, + 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); + $ideBenef = $this->dom->createElement("ideBenef"); + $this->dom->addChild( + $ideBenef, + "cpfBenef", + $this->std->cpfbenef, + true + ); + $this->node->appendChild($ideBenef); + + foreach ($this->std->dmdev as $dev) { + $dmDev = $this->dom->createElement("dmDev"); + $this->dom->addChild( + $dmDev, + "ideDmDev", + $dev->idedmdev, + true + ); + $this->dom->addChild( + $dmDev, + "nrBeneficio", + $dev->nrbeneficio, + true + ); + $this->dom->addChild( + $dmDev, + "indRRA", + $dev->indrra ?? null, + false + ); + if (!empty($dev->inforra)) { + $irra = $dev->inforra; + $rra = $this->dom->createElement("infoRRA"); + $this->dom->addChild( + $rra, + "tpProcRRA", + $irra->tpprocrra, + true + ); + $this->dom->addChild( + $rra, + "nrProcRRA", + $irra->nrprocrra, + true + ); + $this->dom->addChild( + $rra, + "descRRA", + $irra->descrra, + true + ); + $this->dom->addChild( + $rra, + "qtdMesesRRA", + $irra->qtdmesesrra, + true + ); + if (!empty($irra->despprocjud)) { + $jud = $this->dom->createElement("despProcJud"); + $this->dom->addChild( + $jud, + "vlrDespCustas", + $irra->despprocjud->vlrdespcustas, + true + ); + $this->dom->addChild( + $jud, + "vlrDespAdvogados", + $irra->despprocjud->vlrdespadvogados, + true + ); + $rra->appendChild($jud); + } + if (!empty($irra->ideadv)) { + foreach($irra->ideadv as $adv) { + $ideadv = $this->dom->createElement("ideAdv"); + $this->dom->addChild( + $ideadv, + "tpInsc", + $adv->tpinsc, + true + ); + $this->dom->addChild( + $ideadv, + "nrInsc", + $adv->nrinsc, + true + ); + $rra->appendChild($ideadv); + } + } + $dmDev->appendChild($rra); + } + if (!empty($dev->infoperapur)) { + $perapur = $this->dom->createElement("infoPerApur"); + foreach ($dev->infoperapur->ideestab as $ide) { + $ideestab = $this->dom->createElement("ideEstab"); + $this->dom->addChild( + $ideestab, + "tpInsc", + $ide->tpinsc, + true + ); + $this->dom->addChild( + $ideestab, + "nrInsc", + $ide->nrinsc, + true + ); + foreach ($ide->itensremun as $rem) { + $item = $this->dom->createElement("itensRemun"); + $this->dom->addChild( + $item, + "codRubr", + $rem->codrubr, + true + ); + $this->dom->addChild( + $item, + "ideTabRubr", + $rem->idetabrubr, + true + ); + $this->dom->addChild( + $item, + "qtdRubr", + !empty($rem->qtdrubr) ? $rem->qtdrubr : null, + false + ); + $this->dom->addChild( + $item, + "fatorRubr", + !empty($rem->fatorrubr) ? $rem->fatorrubr : null, + false + ); + $this->dom->addChild( + $item, + "vrRubr", + $rem->vrrubr, + true + ); + $this->dom->addChild( + $item, + "indApurIR", + $rem->indapurir, + true + ); + $ideestab->appendChild($item); + } + $perapur->appendChild($ideestab); + } + $dmDev->appendChild($perapur); + } + if (!empty($dev->infoperant)) { + $perant = $this->dom->createElement("infoPerAnt"); + foreach ($dev->infoperant->ideperiodo as $per) { + $periodo = $this->dom->createElement("idePeriodo"); + $this->dom->addChild( + $periodo, + "perRef", + $per->perref, + true + ); + foreach ($per->ideestab as $ide) { + $ideestab = $this->dom->createElement("ideEstab"); + $this->dom->addChild( + $ideestab, + "tpInsc", + $ide->tpinsc, + true + ); + $this->dom->addChild( + $ideestab, + "nrInsc", + $ide->nrinsc, + true + ); + foreach ($ide->itensremun as $rem) { + $item = $this->dom->createElement("itensRemun"); + $this->dom->addChild( + $item, + "codRubr", + $rem->codrubr, + true + ); + $this->dom->addChild( + $item, + "ideTabRubr", + $rem->idetabrubr, + true + ); + $this->dom->addChild( + $item, + "qtdRubr", + !empty($rem->qtdrubr) ? $rem->qtdrubr : null, + false + ); + $this->dom->addChild( + $item, + "fatorRubr", + !empty($rem->fatorrubr) ? $rem->fatorrubr : null, + false + ); + $this->dom->addChild( + $item, + "vrRubr", + $rem->vrrubr, + true + ); + $this->dom->addChild( + $item, + "indApurIR", + $rem->indapurir, + true + ); + $ideestab->appendChild($item); + } + $periodo->appendChild($ideestab); + } + $perant->appendChild($periodo); + } + $dmDev->appendChild($perant); + } + $this->node->appendChild($dmDev); + } + $this->eSocial->appendChild($this->node); + //$this->xml = $this->dom->saveXML($this->eSocial); + $this->sign(); } }