| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace NFePHP\EFD\Elements\ICMSIPI; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use NFePHP\EFD\Common\Element; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use NFePHP\EFD\Common\ElementInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use \stdClass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * REGISTRO C112: DOCUMENTO DE ARRECADAÇÃO REFERENCIADO | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * Este registro deve ser apresentado, obrigatoriamente, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * quando no campo – “Informações Complementares” da nota | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * fiscal - constar a identificação de um documento de arrecadação. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @package NFePHP\EFD\Elements\ICMSIPI | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 15 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  | class C112 extends Element implements ElementInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |     const REG = 'C112'; | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |     const LEVEL = 4; | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |     const PARENT = 'C110'; | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     protected $parameters = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |         'COD_DA' => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |             'type' => 'string', | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |             'regex' => '^(0|1)$', | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |             'required' => true, | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |             'info' => 'Código do modelo do documento de arrecadação', | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |             'format' => '' | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |         ], | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |         'UF' => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |             'type' => 'string', | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |             'regex' => '^[A-z]{2}$', | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |             'required' => true, | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |             'info' => 'Unidade federada beneficiária do recolhimento', | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |             'format' => '' | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         ], | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |         'NUM_DA' => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |             'type' => 'Número do documento de arrecadação', | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |             'regex' => '^(.*)$', | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |             'required' => false, | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |             'info' => 'Número do documento de arrecadação', | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |             'format' => '' | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |         ], | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |         'COD_AUT' => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |             'type' => 'string', | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |             'regex' => '^(.*)$', | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |             'required' => true, | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |             'info' => 'Código completo da autenticação bancária', | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |             'format' => '' | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         ], | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         'VL_DA' => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |             'type' => 'numeric', | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |             'regex' => '^\d+(\.\d*)?|\.\d+$', | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |             'required' => false, | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |             'info' => 'Valor do total do documento de arrecadação', | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |             'format' => '15v2' | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |         ], | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |         'DT_VCTO' => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |             'type' => 'string', | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |             'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$', | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |             'required' => false, | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |             'info' => 'Data de vencimento do documento de arrecadação', | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |             'format' => '' | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |         ], | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |         'DT_PGTO' => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |             'type' => 'string', | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |             'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$', | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |             'required' => true, | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |             'info' => "Data de pagamento do documento de arrecadação, ou data do vencimento", | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |             'format' => '' | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |         ], | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |     ]; | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |      * Constructor | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |      * @param \stdClass $std | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     public function __construct(\stdClass $std) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         parent::__construct(self::REG); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $this->std = $this->standarize($std); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $this->postValidation(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     public function postValidation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         if (!$this->std->num_da xor $this->std->cod_aut) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |             throw new \InvalidArgumentException("[" . self::REG . "] " . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |                 "Preencha o número da arrecadação (NUM_DA) ou o Código completo da autenticação bancária (COD_AUT"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         if ($this->std->vl_da <= 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |             throw new \InvalidArgumentException("[" . self::REG . "] " . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                 "O valor total da arrecadação (VAL_DA) deve ser maior do que zero '0' "); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 95 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 96 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 97 |  |  |  |