@@ -178,9 +178,53 @@ private function buildToma(\DOMDocument $doc, DpsData $dps): \DOMElement
178178 $ toma ->appendChild ($ doc ->createElement ('xNome ' , htmlspecialchars ($ dps ->nomeTomador , ENT_XML1 )));
179179 }
180180
181+ if ($ dps ->tomadorInscricaoMunicipal !== '' ) {
182+ $ toma ->appendChild ($ doc ->createElement ('IM ' , $ dps ->tomadorInscricaoMunicipal ));
183+ }
184+
185+ if ($ this ->hasTomadorAddress ($ dps )) {
186+ $ end = $ doc ->createElement ('end ' );
187+ $ endNac = $ doc ->createElement ('endNac ' );
188+ $ endNac ->appendChild ($ doc ->createElement ('cMun ' , $ dps ->tomadorCodigoMunicipio ));
189+ $ endNac ->appendChild ($ doc ->createElement ('CEP ' , $ dps ->tomadorCep ));
190+ $ end ->appendChild ($ endNac );
191+
192+ if ($ dps ->tomadorLogradouro !== '' ) {
193+ $ end ->appendChild ($ doc ->createElement ('xLgr ' , htmlspecialchars ($ dps ->tomadorLogradouro , ENT_XML1 )));
194+ }
195+
196+ if ($ dps ->tomadorNumero !== '' ) {
197+ $ end ->appendChild ($ doc ->createElement ('nro ' , htmlspecialchars ($ dps ->tomadorNumero , ENT_XML1 )));
198+ }
199+
200+ if ($ dps ->tomadorComplemento !== '' ) {
201+ $ end ->appendChild ($ doc ->createElement ('xCpl ' , htmlspecialchars ($ dps ->tomadorComplemento , ENT_XML1 )));
202+ }
203+
204+ if ($ dps ->tomadorBairro !== '' ) {
205+ $ end ->appendChild ($ doc ->createElement ('xBairro ' , htmlspecialchars ($ dps ->tomadorBairro , ENT_XML1 )));
206+ }
207+
208+ $ toma ->appendChild ($ end );
209+ }
210+
211+ if ($ dps ->tomadorTelefone !== '' ) {
212+ $ toma ->appendChild ($ doc ->createElement ('fone ' , $ dps ->tomadorTelefone ));
213+ }
214+
215+ if ($ dps ->tomadorEmail !== '' ) {
216+ $ toma ->appendChild ($ doc ->createElement ('email ' , htmlspecialchars ($ dps ->tomadorEmail , ENT_XML1 )));
217+ }
218+
181219 return $ toma ;
182220 }
183221
222+ private function hasTomadorAddress (DpsData $ dps ): bool
223+ {
224+ return $ dps ->tomadorCodigoMunicipio !== ''
225+ && $ dps ->tomadorCep !== '' ;
226+ }
227+
184228 private function buildTribFederal (\DOMDocument $ doc , DpsData $ dps ): \DOMElement
185229 {
186230 $ tribFed = $ doc ->createElement ('tribFed ' );
0 commit comments