| @@ 8-87 (lines=80) @@ | ||
| 5 | use NFePHP\EFD\Common\Element; |
|
| 6 | use NFePHP\EFD\Common\ElementInterface; |
|
| 7 | ||
| 8 | class D501 extends Element implements ElementInterface |
|
| 9 | { |
|
| 10 | const REG = 'D501'; |
|
| 11 | const LEVEL = 4; |
|
| 12 | const PARENT = 'D500'; |
|
| 13 | ||
| 14 | protected $parameters = [ |
|
| 15 | 'CST_PIS' => [ |
|
| 16 | 'type' => 'string', |
|
| 17 | 'regex' => '^((5[0-6])|(6[0-6])|(7[0-5])|98|99)$', |
|
| 18 | 'required' => false, |
|
| 19 | 'info' => 'Código da Situação Tributária referente ao PIS/PASEP ', |
|
| 20 | 'format' => '' |
|
| 21 | ], |
|
| 22 | 'VL_ITEM' => [ |
|
| 23 | 'type' => 'numeric', |
|
| 24 | 'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
| 25 | 'required' => false, |
|
| 26 | 'info' => 'Valor Total dos Itens (Serviços) ', |
|
| 27 | 'format' => '15v2' |
|
| 28 | ], |
|
| 29 | 'NAT_BC_CRED' => [ |
|
| 30 | 'type' => 'string', |
|
| 31 | 'regex' => '^(03|13)$', |
|
| 32 | 'required' => false, |
|
| 33 | 'info' => 'Código da Base de Cálculo do Crédito, conforme a Tabela indicada no item 4.3.7. ', |
|
| 34 | 'format' => '' |
|
| 35 | ], |
|
| 36 | 'VL_BC_PIS' => [ |
|
| 37 | 'type' => 'numeric', |
|
| 38 | 'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
| 39 | 'required' => false, |
|
| 40 | 'info' => 'Valor da base de cálculo do PIS/PASEP ', |
|
| 41 | 'format' => '15v2' |
|
| 42 | ], |
|
| 43 | 'ALIQ_PIS' => [ |
|
| 44 | 'type' => 'numeric', |
|
| 45 | 'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
| 46 | 'required' => false, |
|
| 47 | 'info' => 'Alíquota do PIS/PASEP (em percentual) ', |
|
| 48 | 'format' => '8v4' |
|
| 49 | ], |
|
| 50 | 'VL_PIS' => [ |
|
| 51 | 'type' => 'numeric', |
|
| 52 | 'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
| 53 | 'required' => false, |
|
| 54 | 'info' => 'Valor do PIS/PASEP ', |
|
| 55 | 'format' => '15v2' |
|
| 56 | ], |
|
| 57 | 'COD_CTA' => [ |
|
| 58 | 'type' => 'string', |
|
| 59 | 'regex' => '^.{0,255}$', |
|
| 60 | 'required' => false, |
|
| 61 | 'info' => 'Código da conta analítica contábil debitada/creditada ', |
|
| 62 | 'format' => '' |
|
| 63 | ], |
|
| 64 | ||
| 65 | ]; |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Constructor |
|
| 69 | * @param \stdClass $std |
|
| 70 | */ |
|
| 71 | public function __construct(\stdClass $std) |
|
| 72 | { |
|
| 73 | parent::__construct(self::REG); |
|
| 74 | $this->std = $this->standarize($std); |
|
| 75 | $this->postValidation(); |
|
| 76 | } |
|
| 77 | ||
| 78 | public function postValidation() |
|
| 79 | { |
|
| 80 | $multiplicacao = $this->values->vl_bc_pis * $this->values->aliq_pis; |
|
| 81 | if (number_format($this->values->vl_pis, 2) != number_format($multiplicacao / 100, 2)) { |
|
| 82 | throw new \InvalidArgumentException("[" . self::REG . "] " . |
|
| 83 | "O campo VL_PIS deve de ser o calculo da multiplicacao " . |
|
| 84 | "da base de calculo do PIS com a aliquota do PIS, o resultado dividido por 100"); |
|
| 85 | } |
|
| 86 | } |
|
| 87 | } |
|
| 88 | ||
| @@ 8-87 (lines=80) @@ | ||
| 5 | use NFePHP\EFD\Common\Element; |
|
| 6 | use NFePHP\EFD\Common\ElementInterface; |
|
| 7 | ||
| 8 | class D505 extends Element implements ElementInterface |
|
| 9 | { |
|
| 10 | const REG = 'D505'; |
|
| 11 | const LEVEL = 4; |
|
| 12 | const PARENT = 'D500'; |
|
| 13 | ||
| 14 | protected $parameters = [ |
|
| 15 | 'CST_COFINS' => [ |
|
| 16 | 'type' => 'string', |
|
| 17 | 'regex' => '^((5[0-6])|(6[0-6])|(7[0-5])|98|99)$', |
|
| 18 | 'required' => false, |
|
| 19 | 'info' => 'Código da Situação Tributária referente a COFINS ', |
|
| 20 | 'format' => '' |
|
| 21 | ], |
|
| 22 | 'VL_ITEM' => [ |
|
| 23 | 'type' => 'numeric', |
|
| 24 | 'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
| 25 | 'required' => false, |
|
| 26 | 'info' => 'Valor Total dos Itens ', |
|
| 27 | 'format' => '15v2' |
|
| 28 | ], |
|
| 29 | 'NAT_BC_CRED' => [ |
|
| 30 | 'type' => 'string', |
|
| 31 | 'regex' => '^.{2}$', |
|
| 32 | 'required' => false, |
|
| 33 | 'info' => 'Código da Base de Cálculo do Crédito, conforme a Tabela indicada no item 4.3.7. ', |
|
| 34 | 'format' => '' |
|
| 35 | ], |
|
| 36 | 'VL_BC_COFINS' => [ |
|
| 37 | 'type' => 'numeric', |
|
| 38 | 'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
| 39 | 'required' => false, |
|
| 40 | 'info' => 'Valor da base de cálculo da COFINS ', |
|
| 41 | 'format' => '15v2' |
|
| 42 | ], |
|
| 43 | 'ALIQ_COFINS' => [ |
|
| 44 | 'type' => 'numeric', |
|
| 45 | 'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
| 46 | 'required' => false, |
|
| 47 | 'info' => 'Alíquota da COFINS (em percentual) ', |
|
| 48 | 'format' => '8v4' |
|
| 49 | ], |
|
| 50 | 'VL_COFINS' => [ |
|
| 51 | 'type' => 'numeric', |
|
| 52 | 'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
| 53 | 'required' => false, |
|
| 54 | 'info' => 'Valor da COFINS ', |
|
| 55 | 'format' => '15v2' |
|
| 56 | ], |
|
| 57 | 'COD_CTA' => [ |
|
| 58 | 'type' => 'string', |
|
| 59 | 'regex' => '^.{0,255}$', |
|
| 60 | 'required' => false, |
|
| 61 | 'info' => 'Código da conta analítica contábil debitada/creditada ', |
|
| 62 | 'format' => '' |
|
| 63 | ], |
|
| 64 | ||
| 65 | ]; |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Constructor |
|
| 69 | * @param \stdClass $std |
|
| 70 | */ |
|
| 71 | public function __construct(\stdClass $std) |
|
| 72 | { |
|
| 73 | parent::__construct(self::REG); |
|
| 74 | $this->std = $this->standarize($std); |
|
| 75 | $this->postValidation(); |
|
| 76 | } |
|
| 77 | ||
| 78 | public function postValidation() |
|
| 79 | { |
|
| 80 | $multiplicacao = $this->values->vl_bc_cofins * $this->values->aliq_cofins; |
|
| 81 | if (number_format($this->values->vl_cofins, 2) != number_format($multiplicacao / 100, 2)) { |
|
| 82 | throw new \InvalidArgumentException("[" . self::REG . "] " . |
|
| 83 | "O campo VL_COFINS deve de ser o calculo da multiplicacao " . |
|
| 84 | "da base de calculo do cofins com a aliquota do cofins, o resultado dividido por 100"); |
|
| 85 | } |
|
| 86 | } |
|
| 87 | } |
|
| 88 | ||