br_nfe 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (495) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +12 -2
  5. data/README.markdown +3 -1
  6. data/Rakefile +20 -1
  7. data/lib/br_nfe/active_model/associations.rb +11 -0
  8. data/lib/br_nfe/active_model/has_many.rb +65 -0
  9. data/lib/br_nfe/active_model/has_one.rb +57 -0
  10. data/lib/br_nfe/active_model_base.rb +38 -1
  11. data/lib/br_nfe/base.rb +9 -0
  12. data/lib/br_nfe/calculos/fatores_de_multiplicacao.rb +67 -0
  13. data/lib/br_nfe/calculos/modulo11.rb +54 -0
  14. data/lib/br_nfe/calculos/modulo11_fator_de2a9.rb +83 -0
  15. data/lib/br_nfe/calculos/modulo11_fator_de2a9_resto_zero.rb +29 -0
  16. data/lib/br_nfe/constants.rb +46 -1
  17. data/lib/br_nfe/endereco.rb +6 -2
  18. data/lib/br_nfe/helper/cpf_cnpj.rb +8 -1
  19. data/lib/br_nfe/person.rb +32 -3
  20. data/lib/br_nfe/product/destinatario.rb +45 -0
  21. data/lib/br_nfe/product/emitente.rb +14 -1
  22. data/lib/br_nfe/product/evento/base.rb +146 -0
  23. data/lib/br_nfe/product/evento/cancelamento.rb +46 -0
  24. data/lib/br_nfe/product/gateway/base.rb +16 -43
  25. data/lib/br_nfe/product/gateway/web_service_am.rb +140 -0
  26. data/lib/br_nfe/product/gateway/web_service_ba.rb +140 -0
  27. data/lib/br_nfe/product/gateway/web_service_ce.rb +162 -0
  28. data/lib/br_nfe/product/gateway/web_service_go.rb +140 -0
  29. data/lib/br_nfe/product/gateway/web_service_mg.rb +140 -0
  30. data/lib/br_nfe/product/gateway/web_service_ms.rb +140 -0
  31. data/lib/br_nfe/product/gateway/web_service_mt.rb +140 -0
  32. data/lib/br_nfe/product/gateway/web_service_pe.rb +140 -0
  33. data/lib/br_nfe/product/gateway/web_service_pr.rb +140 -0
  34. data/lib/br_nfe/product/gateway/web_service_rs.rb +140 -0
  35. data/lib/br_nfe/product/gateway/web_service_sp.rb +140 -0
  36. data/lib/br_nfe/product/gateway/web_service_svan.rb +162 -0
  37. data/lib/br_nfe/product/gateway/web_service_svc_an.rb +131 -0
  38. data/lib/br_nfe/product/gateway/web_service_svc_rs.rb +20 -0
  39. data/lib/br_nfe/product/gateway/web_service_svrs.rb +111 -10
  40. data/lib/br_nfe/product/nf_xml_value.rb +278 -0
  41. data/lib/br_nfe/product/nfe/adicao_importacao.rb +76 -0
  42. data/lib/br_nfe/product/nfe/cobranca/duplicata.rb +44 -0
  43. data/lib/br_nfe/product/nfe/cobranca/fatura.rb +64 -0
  44. data/lib/br_nfe/product/nfe/cobranca/pagamento.rb +99 -0
  45. data/lib/br_nfe/product/nfe/declaracao_importacao.rb +221 -0
  46. data/lib/br_nfe/product/nfe/detalhe_exportacao.rb +89 -0
  47. data/lib/br_nfe/product/nfe/item.rb +678 -0
  48. data/lib/br_nfe/product/nfe/item_tax/cofins.rb +138 -0
  49. data/lib/br_nfe/product/nfe/item_tax/cofins_st.rb +68 -0
  50. data/lib/br_nfe/product/nfe/item_tax/icms.rb +593 -0
  51. data/lib/br_nfe/product/nfe/item_tax/icms_uf_destino.rb +169 -0
  52. data/lib/br_nfe/product/nfe/item_tax/importacao.rb +62 -0
  53. data/lib/br_nfe/product/nfe/item_tax/ipi.rb +179 -0
  54. data/lib/br_nfe/product/nfe/item_tax/issqn.rb +256 -0
  55. data/lib/br_nfe/product/nfe/item_tax/pis.rb +138 -0
  56. data/lib/br_nfe/product/nfe/item_tax/pis_st.rb +68 -0
  57. data/lib/br_nfe/product/nfe/processo_referencia.rb +48 -0
  58. data/lib/br_nfe/product/nfe/transporte/base.rb +264 -0
  59. data/lib/br_nfe/product/nfe/transporte/transportador.rb +15 -0
  60. data/lib/br_nfe/product/nfe/transporte/veiculo.rb +53 -0
  61. data/lib/br_nfe/product/nfe/transporte/volume.rb +89 -0
  62. data/lib/br_nfe/product/nota_fiscal.rb +1173 -0
  63. data/lib/br_nfe/product/operation/base.rb +255 -0
  64. data/lib/br_nfe/product/operation/nfe_autorizacao.rb +118 -0
  65. data/lib/br_nfe/product/operation/nfe_consulta_protocolo.rb +61 -0
  66. data/lib/br_nfe/product/operation/nfe_download_nf.rb +86 -0
  67. data/lib/br_nfe/product/operation/nfe_inutilizacao.rb +168 -0
  68. data/lib/br_nfe/product/operation/nfe_recepcao_evento.rb +70 -0
  69. data/lib/br_nfe/product/operation/nfe_ret_autorizacao.rb +63 -0
  70. data/lib/br_nfe/product/operation/nfe_status_servico.rb +46 -0
  71. data/lib/br_nfe/product/response/base.rb +97 -0
  72. data/lib/br_nfe/product/response/build/base.rb +287 -0
  73. data/lib/br_nfe/product/response/build/nfe_autorizacao.rb +102 -0
  74. data/lib/br_nfe/product/response/build/nfe_consulta_protocolo.rb +133 -0
  75. data/lib/br_nfe/product/response/build/nfe_inutilizacao.rb +53 -0
  76. data/lib/br_nfe/product/response/build/nfe_ret_autorizacao.rb +65 -0
  77. data/lib/br_nfe/product/response/build/nfe_status_servico.rb +43 -0
  78. data/lib/br_nfe/product/response/event.rb +89 -0
  79. data/lib/br_nfe/product/response/nfe_autorizacao.rb +12 -0
  80. data/lib/br_nfe/product/response/nfe_consulta_protocolo.rb +13 -0
  81. data/lib/br_nfe/product/response/nfe_inutilizacao.rb +89 -0
  82. data/lib/br_nfe/product/response/nfe_ret_autorizacao.rb +9 -0
  83. data/lib/br_nfe/product/response/nfe_status_servico.rb +31 -0
  84. data/lib/br_nfe/product/xml/_signed_info_sh1.xml.slim +9 -0
  85. data/lib/br_nfe/product/xml/_tc_cpf_cnpj.xml.slim +7 -0
  86. data/lib/br_nfe/product/xml/signature_sh1.xml.slim +12 -0
  87. data/lib/br_nfe/product/xml/v1_00/evento/infEventoCancelamento.xml.slim +19 -0
  88. data/lib/br_nfe/product/xml/v1_00/root/NfeDownloadNf.xml.slim +5 -0
  89. data/lib/br_nfe/product/xml/v1_00/root/NfeRecepcaoEvento.xml.slim +7 -0
  90. data/lib/br_nfe/product/xml/v2_00/_tc_endereco.xml.slim +19 -0
  91. data/lib/br_nfe/product/xml/v2_00/_tc_infNFe.xml.slim +39 -0
  92. data/lib/br_nfe/product/xml/v2_00/infInut.xml.slim +12 -0
  93. data/lib/br_nfe/product/xml/v2_00/infNFe/NFe.xml.slim +4 -0
  94. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_cobr.xml.slim +19 -0
  95. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_dest.xml.slim +14 -0
  96. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_det.xml.slim +7 -0
  97. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_emit.xml.slim +19 -0
  98. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_entrega.xml.slim +11 -0
  99. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_exporta.xml.slim +2 -0
  100. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_ide.xml.slim +24 -0
  101. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_infAdic.xml.slim +13 -0
  102. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_retirada.xml.slim +11 -0
  103. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_total.xml.slim +50 -0
  104. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_transp.xml.slim +35 -0
  105. data/lib/br_nfe/product/xml/v2_00/infNFe/det/_tc_imposto.xml.slim +31 -0
  106. data/lib/br_nfe/product/xml/v2_00/infNFe/det/_tc_prod.xml.slim +37 -0
  107. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS00.xml.slim +6 -0
  108. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS10.xml.slim +16 -0
  109. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS101.xml.slim +4 -0
  110. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS102.xml.slim +3 -0
  111. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS20.xml.slim +6 -0
  112. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS201.xml.slim +15 -0
  113. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS202.xml.slim +14 -0
  114. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS30.xml.slim +12 -0
  115. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS40.xml.slim +7 -0
  116. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS500.xml.slim +6 -0
  117. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS51.xml.slim +13 -0
  118. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS60.xml.slim +5 -0
  119. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS70.xml.slim +18 -0
  120. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS90.xml.slim +21 -0
  121. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS900.xml.slim +25 -0
  122. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_COFINS.xml.slim +26 -0
  123. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_COFINS_ST.xml.slim +7 -0
  124. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_ICMS.xml.slim +45 -0
  125. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_II.xml.slim +4 -0
  126. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_IPI.xml.slim +30 -0
  127. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_PIS.xml.slim +26 -0
  128. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_PIS_ST.xml.slim +7 -0
  129. data/lib/br_nfe/product/xml/v2_00/infNFe/det/prod/_tc_di.xml.slim +13 -0
  130. data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_retTransp.xml.slim +6 -0
  131. data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_transporta.xml.slim +17 -0
  132. data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_vol.xml.slim +15 -0
  133. data/lib/br_nfe/product/xml/v2_00/infNFe.xml.slim +3 -0
  134. data/lib/br_nfe/product/xml/v2_00/root/NfeAutorizacao.xml.slim +5 -0
  135. data/lib/br_nfe/product/xml/v2_00/root/NfeInutilizacao.xml.slim +4 -0
  136. data/lib/br_nfe/product/xml/v2_00/root/NfeRetAutorizacao.xml.slim +3 -0
  137. data/lib/br_nfe/product/xml/v2_00/root/NfeStatusServico.xml.slim +4 -0
  138. data/lib/br_nfe/product/xml/v2_01/root/NfeConsultaProtocolo.xml.slim +4 -0
  139. data/lib/br_nfe/product/xml/v3_10/_tc_infNFe.xml.slim +44 -0
  140. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_dest.xml.slim +25 -0
  141. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_det.xml.slim +14 -0
  142. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_exporta.xml.slim +4 -0
  143. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_ide.xml.slim +26 -0
  144. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_pag.xml.slim +7 -0
  145. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_total.xml.slim +78 -0
  146. data/lib/br_nfe/product/xml/v3_10/infNFe/det/_tc_imposto.xml.slim +37 -0
  147. data/lib/br_nfe/product/xml/v3_10/infNFe/det/_tc_prod.xml.slim +48 -0
  148. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS20.xml.slim +12 -0
  149. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS30.xml.slim +17 -0
  150. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS40.xml.slim +7 -0
  151. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS51.xml.slim +19 -0
  152. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS70.xml.slim +23 -0
  153. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS90.xml.slim +26 -0
  154. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/_tc_ICMSUFDest.xml.slim +8 -0
  155. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/_tc_ISSQN.xml.slim +35 -0
  156. data/lib/br_nfe/product/xml/v3_10/infNFe/det/prod/_tc_det_export.xml.slim +8 -0
  157. data/lib/br_nfe/product/xml/v3_10/infNFe/det/prod/_tc_di.xml.slim +28 -0
  158. data/lib/br_nfe/product/xml/v3_10/root/NfeAutorizacao.xml.slim +6 -0
  159. data/lib/br_nfe/service/base.rb +1 -105
  160. data/lib/br_nfe/service/betha/v1/cancela_nfse.rb +1 -1
  161. data/lib/br_nfe/service/response/default.rb +1 -1
  162. data/lib/br_nfe/service/simpliss/v1/base.rb +2 -0
  163. data/lib/br_nfe/version.rb +2 -2
  164. data/lib/br_nfe.rb +180 -22
  165. data/lib/config/locales/br_nfe/en/product/nfe/cobranca/fatura.yml +6 -0
  166. data/lib/config/locales/br_nfe/en/product/nfe/declaracao_importacao.yml +10 -0
  167. data/lib/config/locales/br_nfe/en/product/nfe/item.yml +20 -0
  168. data/lib/config/locales/br_nfe/en/product/nfe/item_tax/icms_uf_destino.yml +8 -0
  169. data/lib/config/locales/br_nfe/en/product/nfe/transporte/base.yml +9 -0
  170. data/lib/config/locales/br_nfe/en/product/nota_fiscal.yml +21 -0
  171. data/lib/config/locales/br_nfe/en/product/operation/nfe_autorizacao.yml +10 -0
  172. data/lib/config/locales/br_nfe/en/product/operation/nfe_recepcao_evento.yml +6 -0
  173. data/lib/config/locales/br_nfe/pt-BR/product/nfe/cobranca/fatura.yml +6 -0
  174. data/lib/config/locales/br_nfe/pt-BR/product/nfe/declaracao_importacao.yml +10 -0
  175. data/lib/config/locales/br_nfe/pt-BR/product/nfe/item.yml +20 -0
  176. data/lib/config/locales/br_nfe/pt-BR/product/nfe/item_tax/icms_uf_destino.yml +8 -0
  177. data/lib/config/locales/br_nfe/pt-BR/product/nfe/transporte/base.yml +9 -0
  178. data/lib/config/locales/br_nfe/pt-BR/product/nota_fiscal.yml +21 -0
  179. data/lib/config/locales/br_nfe/pt-BR/product/operation/nfe_autorizacao.yml +10 -0
  180. data/lib/config/locales/br_nfe/pt-BR/product/operation/nfe_recepcao_evento.yml +6 -0
  181. data/test/br_nfe/association/have_destinatario_test.rb +8 -8
  182. data/test/br_nfe/association/have_emitente_test.rb +6 -6
  183. data/test/br_nfe/base_test.rb +15 -4
  184. data/test/br_nfe/endereco_test.rb +15 -0
  185. data/test/br_nfe/person_test.rb +55 -6
  186. data/test/br_nfe/product/destinatario_test.rb +26 -0
  187. data/test/br_nfe/product/emitente_test.rb +1 -2
  188. data/test/br_nfe/product/evento/base_test.rb +58 -0
  189. data/test/br_nfe/product/evento/cancelamento_test.rb +32 -0
  190. data/test/br_nfe/product/gateway/web_service_am_test.rb +242 -0
  191. data/test/br_nfe/product/gateway/web_service_ba_test.rb +242 -0
  192. data/test/br_nfe/product/gateway/web_service_ce_test.rb +242 -0
  193. data/test/br_nfe/product/gateway/web_service_go_test.rb +242 -0
  194. data/test/br_nfe/product/gateway/web_service_mg_test.rb +242 -0
  195. data/test/br_nfe/product/gateway/web_service_ms_test.rb +242 -0
  196. data/test/br_nfe/product/gateway/web_service_mt_test.rb +408 -0
  197. data/test/br_nfe/product/gateway/web_service_pe_test.rb +408 -0
  198. data/test/br_nfe/product/gateway/web_service_pr_test.rb +408 -0
  199. data/test/br_nfe/product/gateway/web_service_rs_test.rb +407 -0
  200. data/test/br_nfe/product/gateway/web_service_sp_test.rb +408 -0
  201. data/test/br_nfe/product/gateway/web_service_svan_test.rb +242 -0
  202. data/test/br_nfe/product/gateway/web_service_svc_an_test.rb +185 -0
  203. data/test/br_nfe/product/gateway/web_service_svc_rs_test.rb +185 -0
  204. data/test/br_nfe/product/gateway/web_service_svrs_test.rb +208 -2
  205. data/test/br_nfe/product/nfe/adicao_importacao_test.rb +19 -0
  206. data/test/br_nfe/product/nfe/cobranca/duplicata_test.rb +19 -0
  207. data/test/br_nfe/product/nfe/cobranca/fatura_test.rb +32 -0
  208. data/test/br_nfe/product/nfe/cobranca/pagamento_test.rb +105 -0
  209. data/test/br_nfe/product/nfe/declaracao_importacao_test.rb +116 -0
  210. data/test/br_nfe/product/nfe/detalhe_exportacao_test.rb +97 -0
  211. data/test/br_nfe/product/nfe/item_tax/cofins_st_test.rb +22 -0
  212. data/test/br_nfe/product/nfe/item_tax/cofins_test.rb +113 -0
  213. data/test/br_nfe/product/nfe/item_tax/icms_test.rb +1011 -0
  214. data/test/br_nfe/product/nfe/item_tax/icms_uf_destino_test.rb +99 -0
  215. data/test/br_nfe/product/nfe/item_tax/importacao_test.rb +23 -0
  216. data/test/br_nfe/product/nfe/item_tax/ipi_test.rb +160 -0
  217. data/test/br_nfe/product/nfe/item_tax/issqn_test.rb +84 -0
  218. data/test/br_nfe/product/nfe/item_tax/pis_st_test.rb +22 -0
  219. data/test/br_nfe/product/nfe/item_tax/pis_test.rb +113 -0
  220. data/test/br_nfe/product/nfe/item_test.rb +381 -0
  221. data/test/br_nfe/product/nfe/processo_referencia_test.rb +30 -0
  222. data/test/br_nfe/product/nfe/transporte/base_test.rb +182 -0
  223. data/test/br_nfe/product/nfe/transporte/transportador_test.rb +13 -0
  224. data/test/br_nfe/product/nfe/transporte/veiculo_test.rb +13 -0
  225. data/test/br_nfe/product/nfe/transporte/volume_test.rb +42 -0
  226. data/test/br_nfe/product/nota_fiscal_test.rb +662 -0
  227. data/test/br_nfe/product/operation/base_test.rb +538 -0
  228. data/test/br_nfe/product/operation/nfe_autorizacao_test.rb +378 -0
  229. data/test/br_nfe/product/operation/nfe_consulta_protocolo_test.rb +349 -0
  230. data/test/br_nfe/product/operation/nfe_download_nf_test.rb +93 -0
  231. data/test/br_nfe/product/operation/nfe_inutilizacao_test.rb +210 -0
  232. data/test/br_nfe/product/operation/nfe_recepcao_evento_test.rb +84 -0
  233. data/test/br_nfe/product/operation/nfe_ret_autorizacao_test.rb +309 -0
  234. data/test/br_nfe/product/operation/nfe_status_servico_test.rb +122 -0
  235. data/test/br_nfe/product/response/base_test.rb +75 -0
  236. data/test/br_nfe/product/response/build/base_test.rb +34 -0
  237. data/test/br_nfe/product/response/nfe_ret_autorizacao_test.rb +14 -0
  238. data/test/br_nfe/service/association/have_intermediario_test.rb +10 -10
  239. data/test/br_nfe/service/base_test.rb +9 -206
  240. data/test/br_nfe/service/betha/v1/cancela_nfse_test.rb +8 -6
  241. data/test/br_nfe/service/betha/v1/consulta_lote_rps_test.rb +6 -3
  242. data/test/br_nfe/service/betha/v1/consulta_nfs_por_rps_test.rb +6 -3
  243. data/test/br_nfe/service/betha/v1/consulta_nfse_test.rb +7 -4
  244. data/test/br_nfe/service/betha/v1/consulta_situacao_lote_rps_test.rb +12 -9
  245. data/test/br_nfe/service/betha/v1/recepcao_lote_rps_test.rb +6 -3
  246. data/test/br_nfe/service/rps_test.rb +2 -2
  247. data/test/br_nfe/service/simpliss/v1/cancela_nfse_test.rb +6 -3
  248. data/test/br_nfe/service/simpliss/v1/consulta_lote_rps_test.rb +7 -4
  249. data/test/br_nfe/service/simpliss/v1/consulta_nfs_por_rps_test.rb +7 -4
  250. data/test/br_nfe/service/simpliss/v1/consulta_nfse_test.rb +8 -5
  251. data/test/br_nfe/service/simpliss/v1/consulta_situacao_lote_rps_test.rb +9 -6
  252. data/test/br_nfe/service/simpliss/v1/recepcao_lote_rps_test.rb +6 -3
  253. data/test/br_nfe/service/thema/v1/cancela_nfse_test.rb +6 -3
  254. data/test/br_nfe/service/thema/v1/consulta_lote_rps_test.rb +6 -3
  255. data/test/br_nfe/service/thema/v1/consulta_nfs_por_rps_test.rb +6 -3
  256. data/test/br_nfe/service/thema/v1/consulta_nfse_test.rb +8 -5
  257. data/test/br_nfe/service/thema/v1/consulta_situacao_lote_rps_test.rb +9 -6
  258. data/test/br_nfe/service/thema/v1/recepcao_lote_rps_limitado_test.rb +6 -3
  259. data/test/br_nfe/service/thema/v1/recepcao_lote_rps_test.rb +6 -3
  260. data/test/factories/person.rb +1 -1
  261. data/test/factories/product/destinatario.rb +11 -0
  262. data/test/factories/product/emitente.rb +1 -1
  263. data/test/factories/product/evento/base.rb +9 -0
  264. data/test/factories/product/evento/cancelamento.rb +10 -0
  265. data/test/factories/product/gateway/web_service_am.rb +5 -0
  266. data/test/factories/product/gateway/web_service_ba.rb +5 -0
  267. data/test/factories/product/nfe/adicao_importacao.rb +7 -0
  268. data/test/factories/product/nfe/cobranca/duplicata.rb +7 -0
  269. data/test/factories/product/nfe/cobranca/fatura.rb +8 -0
  270. data/test/factories/product/nfe/cobranca/pagamento.rb +9 -0
  271. data/test/factories/product/nfe/declaracao_importacao.rb +10 -0
  272. data/test/factories/product/nfe/detalhe_exportacao.rb +5 -0
  273. data/test/factories/product/nfe/item.rb +24 -0
  274. data/test/factories/product/nfe/item_tax/cofins.rb +5 -0
  275. data/test/factories/product/nfe/item_tax/cofins_st.rb +5 -0
  276. data/test/factories/product/nfe/item_tax/icms.rb +9 -0
  277. data/test/factories/product/nfe/item_tax/icms_uf_destino.rb +11 -0
  278. data/test/factories/product/nfe/item_tax/importacao.rb +8 -0
  279. data/test/factories/product/nfe/item_tax/ipi.rb +6 -0
  280. data/test/factories/product/nfe/item_tax/issqn.rb +9 -0
  281. data/test/factories/product/nfe/item_tax/pis.rb +5 -0
  282. data/test/factories/product/nfe/item_tax/pis_st.rb +5 -0
  283. data/test/factories/product/nfe/processo_referencia.rb +6 -0
  284. data/test/factories/product/nfe/transporte/base.rb +5 -0
  285. data/test/factories/product/nfe/transporte/transportador.rb +7 -0
  286. data/test/factories/product/nfe/transporte/veiculo.rb +7 -0
  287. data/test/factories/product/nfe/transporte/volume.rb +5 -0
  288. data/test/factories/product/nota_fiscal.rb +22 -0
  289. data/test/factories/product/{base.rb → operation/base.rb} +1 -1
  290. data/test/factories/product/operation/nfe_autorizacao.rb +590 -0
  291. data/test/factories/product/operation/nfe_consulta_protocolo.rb +13 -0
  292. data/test/factories/product/operation/nfe_download_nf.rb +15 -0
  293. data/test/factories/product/operation/nfe_inutilizacao.rb +19 -0
  294. data/test/factories/product/operation/nfe_recepcao_evento.rb +14 -0
  295. data/test/factories/product/operation/nfe_ret_autorizacao.rb +13 -0
  296. data/test/factories/product/{consulta_status_servico.rb → operation/nfe_status_servico.rb} +1 -1
  297. data/test/factories/product/response/base.rb +12 -0
  298. data/test/factories/product/response/build/base.rb +6 -0
  299. data/test/factories/product/response/nfe_ret_autorizacao.rb +13 -0
  300. data/test/factories/service/emitente.rb +1 -1
  301. data/test/fixtures/product/operation/nfe_autorizacao/nfe_signed.xml +1 -0
  302. data/test/fixtures/product/response/v3.10/nfe_autorizacao/async_fail.xml +21 -0
  303. data/test/fixtures/product/response/v3.10/nfe_autorizacao/async_success.xml +25 -0
  304. data/test/fixtures/product/response/v3.10/nfe_autorizacao/nfe/with_proc.xml +1 -0
  305. data/test/fixtures/product/response/v3.10/nfe_autorizacao/nfe/without_proc.xml +1 -0
  306. data/test/fixtures/product/response/v3.10/nfe_autorizacao/original_xml.xml +1 -0
  307. data/test/fixtures/product/response/v3.10/nfe_autorizacao/sync_fail.xml +32 -0
  308. data/test/fixtures/product/response/v3.10/nfe_autorizacao/sync_success.xml +33 -0
  309. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_1.xml +1 -0
  310. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_2.xml +1 -0
  311. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_3.xml +1 -0
  312. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_cancel.xml +1 -0
  313. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/one_event.xml +1 -0
  314. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/fail.xml +22 -0
  315. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/nfe_original/with_proc.xml +1 -0
  316. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/nfe_original/without_proc.xml +1 -0
  317. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_many_with_cancel.xml +198 -0
  318. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_many_without_cancel.xml +199 -0
  319. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_one.xml +89 -0
  320. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_without.xml +34 -0
  321. data/test/fixtures/product/response/v3.10/nfe_inutilizacao/fail.xml +29 -0
  322. data/test/fixtures/product/response/v3.10/nfe_inutilizacao/success.xml +30 -0
  323. data/test/fixtures/product/response/v3.10/nfe_recepcao_evento/cancelamento/fail.xml +34 -0
  324. data/test/fixtures/product/response/v3.10/nfe_recepcao_evento/cancelamento/success.xml +36 -0
  325. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_fail.xml +22 -0
  326. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_fail.xml +33 -0
  327. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_fail_and_one_ok.xml +46 -0
  328. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_ok.xml +34 -0
  329. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_two_invoice_fail.xml +46 -0
  330. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_two_invoice_ok.xml +46 -0
  331. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_2_with_protocol.xml +1 -0
  332. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_2_without_protocol.xml +1 -0
  333. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_3_with_protocol.xml +1 -0
  334. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_3_without_protocol.xml +1 -0
  335. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/lot.xml +2 -0
  336. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/nfe.xml +2 -0
  337. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/nfeProc.xml +4 -0
  338. data/test/fixtures/product/response/v3.10/nfe_status_servico/fail.xml +23 -0
  339. data/test/fixtures/product/response/v3.10/nfe_status_servico/success.xml +22 -0
  340. data/test/fixtures/product/schemas/CCe_v1.00.xsd +11 -0
  341. data/test/fixtures/product/schemas/EPEC_v1.00.xsd +9 -0
  342. data/test/fixtures/product/schemas/LeiauteCadastroEmissorDFe_v1.01.xsd +234 -0
  343. data/test/fixtures/product/schemas/SuframaInternaliza_v1.00.xsd +9 -0
  344. data/test/fixtures/product/schemas/SuframaVistoria_v1.00.xsd +9 -0
  345. data/test/fixtures/product/schemas/atuCadEmiDFe_v1.01.xsd +9 -0
  346. data/test/fixtures/product/schemas/cabecMsg_v1.02.xsd +29 -0
  347. data/test/fixtures/product/schemas/cadEmiDFe_v1.01.xsd +9 -0
  348. data/test/fixtures/product/schemas/cancNFe_v2.00.xsd +9 -0
  349. data/test/fixtures/product/schemas/confRecebto_v1.00.xsd +9 -0
  350. data/test/fixtures/product/schemas/consCad_v2.00.xsd +9 -0
  351. data/test/fixtures/product/schemas/consDPEC_v1.01.xsd +9 -0
  352. data/test/fixtures/product/schemas/consNFeDest_v1.01.xsd +10 -0
  353. data/test/fixtures/product/schemas/consReciNFe_v2.00.xsd +9 -0
  354. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consReciNFe_v3.10.xsd +8 -8
  355. data/test/fixtures/product/schemas/consSitNFe_v2.01.xsd +10 -0
  356. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consSitNFe_v3.10.xsd +8 -8
  357. data/test/fixtures/product/schemas/consStatServ_v2.00.xsd +9 -0
  358. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consStatServ_v3.10.xsd +8 -8
  359. data/test/fixtures/product/schemas/distDFeInt_v1.00.xsd +71 -0
  360. data/test/fixtures/product/schemas/downloadNFe_v1.00.xsd +10 -0
  361. data/test/fixtures/product/schemas/e110110_v1.00.xsd +58 -0
  362. data/test/fixtures/product/schemas/e110111_v1.00.xsd +42 -0
  363. data/test/fixtures/product/schemas/e110140_v1.00.xsd +124 -0
  364. data/test/fixtures/product/schemas/e111500_v1.00.xsd +69 -0
  365. data/test/fixtures/product/schemas/e111501_v1.00.xsd +69 -0
  366. data/test/fixtures/product/schemas/e111502_v1.00.xsd +50 -0
  367. data/test/fixtures/product/schemas/e111503_v1.00.xsd +50 -0
  368. data/test/fixtures/product/schemas/e210200_v1.00.xsd +32 -0
  369. data/test/fixtures/product/schemas/e210210_v1.00.xsd +32 -0
  370. data/test/fixtures/product/schemas/e210220_v1.00.xsd +45 -0
  371. data/test/fixtures/product/schemas/e210240_v1.00.xsd +44 -0
  372. data/test/fixtures/product/schemas/e411500_v1.00.xsd +134 -0
  373. data/test/fixtures/product/schemas/e411501_v1.00.xsd +134 -0
  374. data/test/fixtures/product/schemas/e411502_v1.00.xsd +95 -0
  375. data/test/fixtures/product/schemas/e411503_v1.00.xsd +95 -0
  376. data/test/fixtures/product/schemas/e990900_v1.00.xsd +87 -0
  377. data/test/fixtures/product/schemas/e990910_v1.00.xsd +81 -0
  378. data/test/fixtures/product/schemas/envCCe_v1.00.xsd +10 -0
  379. data/test/fixtures/product/schemas/envCancelPProrrogNFe_v1.0.xsd +50 -0
  380. data/test/fixtures/product/schemas/envConfRecebto_v1.00.xsd +9 -0
  381. data/test/fixtures/product/schemas/envDPEC_v1.01.xsd +9 -0
  382. data/test/fixtures/product/schemas/envEPEC_v1.00.xsd +9 -0
  383. data/test/fixtures/product/schemas/envEventoCancNFe_v1.00.xsd +9 -0
  384. data/test/fixtures/product/schemas/envEvento_v1.00.xsd +9 -0
  385. data/test/fixtures/product/schemas/envFiscoNfe_v1.0.xsd +179 -0
  386. data/test/fixtures/product/schemas/envPProrrogNFe_v1.0.xsd +65 -0
  387. data/test/fixtures/product/schemas/envRemIndus_v1.00.xsd +9 -0
  388. data/test/fixtures/product/schemas/envSuframaInternaliza_v1.00.xsd +10 -0
  389. data/test/fixtures/product/schemas/envSuframaVistoria_v1.00.xsd +10 -0
  390. data/test/fixtures/product/schemas/enviNFe_v2.00.xsd +9 -0
  391. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/enviNFe_v3.10.xsd +8 -8
  392. data/test/fixtures/product/schemas/eventoCancNFe_v1.00.xsd +9 -0
  393. data/test/fixtures/product/schemas/eventoEPEC_v0.01.xsd +267 -0
  394. data/test/fixtures/product/schemas/eventoEPEC_v1.00.xsd +267 -0
  395. data/test/fixtures/product/schemas/eventoRemIndus_v1.00.xsd +9 -0
  396. data/test/fixtures/product/schemas/inutNFe_v2.00.xsd +9 -0
  397. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/inutNFe_v3.10.xsd +8 -8
  398. data/test/fixtures/product/schemas/leiauteCCe_v1.00.xsd +418 -0
  399. data/test/fixtures/product/schemas/leiauteCancNFe_v2.00.xsd +143 -0
  400. data/test/fixtures/product/schemas/leiauteConfRecebto_v1.00.xsd +406 -0
  401. data/test/fixtures/product/schemas/leiauteConsNFeDest_v1.01.xsd +483 -0
  402. data/test/fixtures/product/schemas/leiauteConsSitNFe_v2.01.xsd +548 -0
  403. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteConsSitNFe_v3.10.xsd +502 -502
  404. data/test/fixtures/product/schemas/leiauteConsStatServ_v2.00.xsd +98 -0
  405. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteConsStatServ_v3.10.xsd +97 -97
  406. data/test/fixtures/product/schemas/leiauteConsultaCadastro_v1.01.xsd +355 -0
  407. data/test/fixtures/product/schemas/leiauteConsultaCadastro_v2.00.xsd +404 -0
  408. data/test/fixtures/product/schemas/leiauteDPEC_v1.01.xsd +464 -0
  409. data/test/fixtures/product/schemas/leiauteDownloadNFe_v1.00.xsd +149 -0
  410. data/test/fixtures/product/schemas/leiauteEPEC_v1.00.xsd +459 -0
  411. data/test/fixtures/product/schemas/leiauteEventoCancNFe_v1.00.xsd +394 -0
  412. data/test/fixtures/product/schemas/leiauteEvento_v1.00.xsd +373 -0
  413. data/test/fixtures/product/schemas/leiauteInutNFe_v2.00.xsd +193 -0
  414. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteInutNFe_v3.10.xsd +192 -192
  415. data/test/fixtures/product/schemas/leiauteNFe_v2.00.xsd +6661 -0
  416. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteNFe_v3.10.xsd +6060 -6060
  417. data/test/fixtures/product/schemas/leiauteRemIndus_v1.00.xsd +382 -0
  418. data/test/fixtures/product/schemas/leiauteSRE_v1.00.xsd +372 -0
  419. data/test/fixtures/product/schemas/leiauteSuframaInternaliza_v1.00.xsd +642 -0
  420. data/test/fixtures/product/schemas/leiauteSuframaVistoria_v1.00.xsd +648 -0
  421. data/test/fixtures/product/schemas/nfe_v2.00.xsd +9 -0
  422. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/nfe_v3.10.xsd +8 -8
  423. data/test/fixtures/product/schemas/procCCeNFe_v1.00.xsd +10 -0
  424. data/test/fixtures/product/schemas/procCancNFe_v2.00.xsd +9 -0
  425. data/test/fixtures/product/schemas/procConfRecebtoNFe_v1.00.xsd +9 -0
  426. data/test/fixtures/product/schemas/procEPEC_v1.00.xsd +9 -0
  427. data/test/fixtures/product/schemas/procEventoCancNFe_v1.00.xsd +9 -0
  428. data/test/fixtures/product/schemas/procEventoNFe_v1.00.xsd +9 -0
  429. data/test/fixtures/product/schemas/procEventoNFe_v99.99.xsd +37 -0
  430. data/test/fixtures/product/schemas/procInutNFe_v2.00.xsd +9 -0
  431. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/procInutNFe_v3.10.xsd +8 -8
  432. data/test/fixtures/product/schemas/procNFe_v2.00.xsd +9 -0
  433. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/procNFe_v3.10.xsd +8 -8
  434. data/test/fixtures/product/schemas/procRemIndus_v1.00.xsd +9 -0
  435. data/test/fixtures/product/schemas/resEvento_v1.00.xsd +94 -0
  436. data/test/fixtures/product/schemas/resNFe_v1.00.xsd +110 -0
  437. data/test/fixtures/product/schemas/retAtuCadEmiDFe_v1.01.xsd +9 -0
  438. data/test/fixtures/product/schemas/retCancNFe_v2.00.xsd +9 -0
  439. data/test/fixtures/product/schemas/retConsCad_v2.00.xsd +9 -0
  440. data/test/fixtures/product/schemas/retConsDPEC_v1.01.xsd +9 -0
  441. data/test/fixtures/product/schemas/retConsReciNFe_v2.00.xsd +9 -0
  442. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsReciNFe_v3.10.xsd +8 -8
  443. data/test/fixtures/product/schemas/retConsSitNFe_v2.01.xsd +10 -0
  444. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsSitNFe_v3.10.xsd +8 -8
  445. data/test/fixtures/product/schemas/retConsStatServ_v2.00.xsd +9 -0
  446. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsStatServ_v3.10.xsd +8 -8
  447. data/test/fixtures/product/schemas/retDPEC_v1.01.xsd +9 -0
  448. data/test/fixtures/product/schemas/retDistDFeInt_v1.00.xsd +84 -0
  449. data/test/fixtures/product/schemas/retDownloadNFe_v1.00.xsd +9 -0
  450. data/test/fixtures/product/schemas/retEnvCCe_v1.00.xsd +10 -0
  451. data/test/fixtures/product/schemas/retEnvCancelPProrrogNFe_v1.0.xsd +231 -0
  452. data/test/fixtures/product/schemas/retEnvConfRecebto_v1.00.xsd +9 -0
  453. data/test/fixtures/product/schemas/retEnvEPEC_v1.00.xsd +9 -0
  454. data/test/fixtures/product/schemas/retEnvEventoCancNFe_v1.00.xsd +9 -0
  455. data/test/fixtures/product/schemas/retEnvEvento_v1.00.xsd +9 -0
  456. data/test/fixtures/product/schemas/retEnvFiscoNFe_v1.0.xsd +234 -0
  457. data/test/fixtures/product/schemas/retEnvRemIndus_v1.00.xsd +9 -0
  458. data/test/fixtures/product/schemas/retEnvSuframaInternaliza_v1.00.xsd +9 -0
  459. data/test/fixtures/product/schemas/retEnvSuframaVistoria_v1.00.xsd +9 -0
  460. data/test/fixtures/product/schemas/retEnviNFe_v2.00.xsd +9 -0
  461. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retEnviNFe_v3.10.xsd +8 -8
  462. data/test/fixtures/product/schemas/retEventoEPEC_v0.01.xsd +207 -0
  463. data/test/fixtures/product/schemas/retInutNFe_v2.00.xsd +9 -0
  464. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retInutNFe_v3.10.xsd +8 -8
  465. data/test/fixtures/product/schemas/retPProrrogNFe_v1.0.xsd +233 -0
  466. data/test/fixtures/product/schemas/retconsNFeDest_v1.01.xsd +9 -0
  467. data/test/fixtures/product/schemas/tiposBasico_v1.03.xsd +816 -0
  468. data/test/fixtures/product/schemas/tiposBasico_v1.03_OPENSSL.xsd +816 -0
  469. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/tiposBasico_v3.10.xsd +571 -571
  470. data/test/fixtures/product/schemas/tiposBasico_v3.10_OPENSSL.xsd +877 -0
  471. data/test/fixtures/product/schemas/tiposDistDFe_v1.00.xsd +217 -0
  472. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/xmldsig-core-schema_v1.01.xsd +97 -97
  473. data/test/fixtures/product/wsdl/NFeRetAutorizacao.xml +80 -0
  474. data/test/fixtures/product/wsdl/NfeAutorizacao.xml +107 -0
  475. data/test/fixtures/product/wsdl/NfeConsulta2.xml +80 -0
  476. data/test/fixtures/product/wsdl/NfeStatusServico2.xml +70 -0
  477. data/test/fixtures/product/wsdl/nfeinutilizacao2.xml +80 -0
  478. data/test/fixtures/service/wsdl/betha/v1/cancelar_nfse.xml +178 -0
  479. data/test/fixtures/service/wsdl/betha/v1/consultar_lote_rps.xml +339 -0
  480. data/test/fixtures/service/wsdl/betha/v1/consultar_nfse.xml +348 -0
  481. data/test/fixtures/service/wsdl/betha/v1/consultar_nfse_por_rps.xml +365 -0
  482. data/test/fixtures/service/wsdl/betha/v1/consultar_situacao_lote_rps.xml +74 -0
  483. data/test/fixtures/service/wsdl/betha/v1/recepcionar_lote_rps.xml +299 -0
  484. data/test/fixtures/service/wsdl/simpliss/v1/nfseservice.xml +1 -0
  485. data/test/fixtures/service/wsdl/thema/v1/nfse_cancelamento.xml +82 -0
  486. data/test/fixtures/service/wsdl/thema/v1/nfse_consulta.xml +235 -0
  487. data/test/fixtures/service/wsdl/thema/v1/nfse_remessa.xml +185 -0
  488. data/test/test_helper.rb +369 -1
  489. metadata +711 -33
  490. data/lib/br_nfe/product/base.rb +0 -82
  491. data/lib/br_nfe/product/consulta_status_servico.rb +0 -35
  492. data/lib/br_nfe/product/value_nf.rb +0 -9
  493. data/lib/br_nfe/product/xml/v3_10/consulta_status_servico.xml.slim +0 -4
  494. data/test/br_nfe/product/base_test.rb +0 -150
  495. data/test/br_nfe/product/consulta_status_servico_test.rb +0 -59
@@ -0,0 +1,1011 @@
1
+ require 'test_helper'
2
+
3
+ describe BrNfe::Product::Nfe::ItemTax::Icms do
4
+ subject { FactoryGirl.build(:product_item_tax_icms) }
5
+
6
+ describe 'Alias attributes' do
7
+ it { must_have_alias_attribute :orig, :origem }
8
+ it { must_have_alias_attribute :CST, :codigo_cst, '01' }
9
+ it { must_have_alias_attribute :CSOSN, :codigo_cst, '01' }
10
+ it { must_have_alias_attribute :modBC, :modalidade_base_calculo }
11
+ it { must_have_alias_attribute :pRedBC, :reducao_base_calculo }
12
+ it { must_have_alias_attribute :vBC, :total_base_calculo }
13
+ it { must_have_alias_attribute :pICMS, :aliquota }
14
+ it { must_have_alias_attribute :vICMS, :total }
15
+ it { must_have_alias_attribute :modBCST, :modalidade_base_calculo_st }
16
+ it { must_have_alias_attribute :pMVAST, :mva_st }
17
+ it { must_have_alias_attribute :pRedBCST, :reducao_base_calculo_st }
18
+ it { must_have_alias_attribute :vBCST, :total_base_calculo_st }
19
+ it { must_have_alias_attribute :pICMSST, :aliquota_st }
20
+ it { must_have_alias_attribute :vICMSST, :total_st }
21
+ it { must_have_alias_attribute :vICMSDeson, :total_desoneracao }
22
+ it { must_have_alias_attribute :motDesICMS, :motivo_desoneracao }
23
+ it { must_have_alias_attribute :vICMSOp, :total_icms_operacao }
24
+ it { must_have_alias_attribute :pDif, :percentual_diferimento }
25
+ it { must_have_alias_attribute :vICMSDif, :total_icms_diferido }
26
+ it { must_have_alias_attribute :vBCSTRet, :total_base_calculo_st_retido }
27
+ it { must_have_alias_attribute :vICMSSTRet, :total_st_retido }
28
+ it { must_have_alias_attribute :pCredSN, :aliquota_credito_sn }
29
+ it { must_have_alias_attribute :vCredICMSSN, :total_credito_sn }
30
+ end
31
+
32
+ describe 'Validations' do
33
+ context '#origem' do
34
+ it { wont allow_value(9).for(:origem) }
35
+ it { must validate_inclusion_of(:origem).in_array([0, 1, 2, 3, 4, 5, 6, 7, 8]) }
36
+ end
37
+ context '#codigo_cst' do
38
+ it { must validate_presence_of(:codigo_cst) }
39
+ it { must validate_inclusion_of(:codigo_cst).in_array(%w[00 10 20 30 40 41 50 51 60 70 90 101 102 103 201 202 203 300 400 500 900]) }
40
+ end
41
+ context "CST 00" do
42
+ before { subject.codigo_cst = '00' }
43
+ it { must validate_presence_of(:modalidade_base_calculo) }
44
+ it { must validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
45
+ it { must validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
46
+ it { must validate_presence_of(:total_base_calculo) }
47
+ it { must validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
48
+ it { must validate_presence_of(:aliquota) }
49
+ it { wont validate_presence_of(:modalidade_base_calculo_st) }
50
+ it { wont validate_inclusion_of(:modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
51
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
52
+ it { must validate_numericality_of(:reducao_base_calculo_st).
53
+ is_greater_than_or_equal_to(0.0).
54
+ is_less_than_or_equal_to(100.0).
55
+ allow_nil
56
+ }
57
+ it { must validate_numericality_of(:reducao_base_calculo).
58
+ is_greater_than_or_equal_to(0.0).
59
+ is_less_than_or_equal_to(100.0).
60
+ allow_nil
61
+ }
62
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
63
+ it { wont validate_presence_of(:total_base_calculo_st) }
64
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
65
+ it { wont validate_presence_of(:aliquota_st) }
66
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
67
+ it { wont validate_presence_of(:total_st) }
68
+ it { wont validate_presence_of(:reducao_base_calculo) }
69
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
70
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
71
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
72
+ context 'Não deve aplicar as regras para desoneracao' do
73
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
74
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
75
+ it { wont validate_presence_of(:motivo_desoneracao) }
76
+ end
77
+ end
78
+ context "CST 10" do
79
+ before { subject.codigo_cst = '10' }
80
+ it { must validate_presence_of(:modalidade_base_calculo) }
81
+ it { must validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
82
+ it { must validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
83
+ it { must validate_presence_of(:total_base_calculo) }
84
+ it { must validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
85
+ it { must validate_presence_of(:aliquota) }
86
+ it { must validate_presence_of(:modalidade_base_calculo_st) }
87
+ it { must validate_inclusion_of(:modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
88
+ it { must validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0).allow_nil }
89
+ it { must validate_numericality_of(:reducao_base_calculo_st).
90
+ is_greater_than_or_equal_to(0.0).
91
+ is_less_than_or_equal_to(100.0).
92
+ allow_nil
93
+ }
94
+ it { must validate_numericality_of(:reducao_base_calculo).
95
+ is_greater_than_or_equal_to(0.0).
96
+ is_less_than_or_equal_to(100.0).
97
+ allow_nil
98
+ }
99
+ it { must validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
100
+ it { must validate_presence_of(:total_base_calculo_st) }
101
+ it { must validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
102
+ it { must validate_presence_of(:aliquota_st) }
103
+ it { must validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
104
+ it { must validate_presence_of(:total_st) }
105
+ it { wont validate_presence_of(:reducao_base_calculo) }
106
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
107
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
108
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
109
+ context 'Não deve aplicar as regras para desoneracao' do
110
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
111
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
112
+ it { wont validate_presence_of(:motivo_desoneracao) }
113
+ end
114
+ end
115
+ context "CST 20" do
116
+ before { subject.codigo_cst = '20' }
117
+ it { must validate_presence_of(:modalidade_base_calculo) }
118
+ it { must validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
119
+ it { must validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
120
+ it { must validate_presence_of(:total_base_calculo) }
121
+ it { must validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
122
+ it { must validate_presence_of(:aliquota) }
123
+ it { wont validate_presence_of(:modalidade_base_calculo_st) }
124
+ it { wont validate_inclusion_of(:modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
125
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
126
+ it { must validate_numericality_of(:reducao_base_calculo_st).
127
+ is_greater_than_or_equal_to(0.0).
128
+ is_less_than_or_equal_to(100.0).
129
+ allow_nil
130
+ }
131
+ it { must validate_numericality_of(:reducao_base_calculo).
132
+ is_greater_than_or_equal_to(0.0).
133
+ is_less_than_or_equal_to(100.0).
134
+ allow_nil
135
+ }
136
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
137
+ it { wont validate_presence_of(:total_base_calculo_st) }
138
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
139
+ it { wont validate_presence_of(:aliquota_st) }
140
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
141
+ it { wont validate_presence_of(:total_st) }
142
+ it { must validate_presence_of(:reducao_base_calculo) }
143
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
144
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
145
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
146
+ context 'Deve aplicar as regras para desoneracao' do
147
+ it { must validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
148
+ it "motivo_desoneracao não deve ser obrigatório se não tiver total_desoneracao" do
149
+ subject.total_desoneracao = nil
150
+ wont validate_presence_of(:motivo_desoneracao)
151
+ end
152
+ it "motivo_desoneracao deve ser obrigatório mesmo se tiver total_desoneracao" do
153
+ subject.total_desoneracao = 50.0
154
+ must validate_presence_of(:motivo_desoneracao)
155
+ end
156
+ it 'motivo_desoneracao deve validar os valores permitidos' do
157
+ subject.total_desoneracao = nil
158
+ must validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12])
159
+ must allow_value('').for(:motivo_desoneracao)
160
+ end
161
+ end
162
+ end
163
+ context "CST 30" do
164
+ before { subject.codigo_cst = '30' }
165
+ it { wont validate_presence_of(:modalidade_base_calculo) }
166
+ it { wont validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
167
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
168
+ it { wont validate_presence_of(:total_base_calculo) }
169
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
170
+ it { wont validate_presence_of(:aliquota) }
171
+ it { must validate_presence_of(:modalidade_base_calculo_st) }
172
+ it { must validate_inclusion_of(:modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
173
+ it { must validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
174
+ it { must validate_numericality_of(:reducao_base_calculo_st).
175
+ is_greater_than_or_equal_to(0.0).
176
+ is_less_than_or_equal_to(100.0).
177
+ allow_nil
178
+ }
179
+ it { must validate_numericality_of(:reducao_base_calculo).
180
+ is_greater_than_or_equal_to(0.0).
181
+ is_less_than_or_equal_to(100.0).
182
+ allow_nil
183
+ }
184
+ it { must validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
185
+ it { must validate_presence_of(:total_base_calculo_st) }
186
+ it { must validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
187
+ it { must validate_presence_of(:aliquota_st) }
188
+ it { must validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
189
+ it { must validate_presence_of(:total_st) }
190
+ it { wont validate_presence_of(:reducao_base_calculo) }
191
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
192
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
193
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
194
+ context 'Deve aplicar as regras para desoneracao' do
195
+ it { must validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
196
+ it "motivo_desoneracao não deve ser obrigatório se não tiver total_desoneracao" do
197
+ subject.total_desoneracao = nil
198
+ wont validate_presence_of(:motivo_desoneracao)
199
+ end
200
+ it "motivo_desoneracao deve ser obrigatório mesmo se tiver total_desoneracao" do
201
+ subject.total_desoneracao = 50.0
202
+ must validate_presence_of(:motivo_desoneracao)
203
+ end
204
+ it 'motivo_desoneracao deve validar os valores permitidos' do
205
+ subject.total_desoneracao = nil
206
+ must validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12])
207
+ must allow_value('').for(:motivo_desoneracao)
208
+ end
209
+ end
210
+ end
211
+ context "CST 40" do
212
+ before { subject.codigo_cst = '40' }
213
+ it { wont validate_presence_of(:modalidade_base_calculo) }
214
+ it { wont validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
215
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
216
+ it { wont validate_presence_of(:total_base_calculo) }
217
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
218
+ it { wont validate_presence_of(:aliquota) }
219
+ it { wont validate_presence_of(:modalidade_base_calculo_st) }
220
+ it { wont validate_inclusion_of(:modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
221
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
222
+ it { must validate_numericality_of(:reducao_base_calculo_st).
223
+ is_greater_than_or_equal_to(0.0).
224
+ is_less_than_or_equal_to(100.0).
225
+ allow_nil
226
+ }
227
+ it { must validate_numericality_of(:reducao_base_calculo).
228
+ is_greater_than_or_equal_to(0.0).
229
+ is_less_than_or_equal_to(100.0).
230
+ allow_nil
231
+ }
232
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
233
+ it { wont validate_presence_of(:total_base_calculo_st) }
234
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
235
+ it { wont validate_presence_of(:aliquota_st) }
236
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
237
+ it { wont validate_presence_of(:total_st) }
238
+ it { wont validate_presence_of(:reducao_base_calculo) }
239
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
240
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
241
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
242
+ context 'Deve aplicar as regras para desoneracao' do
243
+ it { must validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
244
+ it "motivo_desoneracao não deve ser obrigatório se não tiver total_desoneracao" do
245
+ subject.total_desoneracao = nil
246
+ wont validate_presence_of(:motivo_desoneracao)
247
+ end
248
+ it "motivo_desoneracao deve ser obrigatório mesmo se tiver total_desoneracao" do
249
+ subject.total_desoneracao = 50.0
250
+ must validate_presence_of(:motivo_desoneracao)
251
+ end
252
+ it 'motivo_desoneracao deve validar os valores permitidos' do
253
+ subject.total_desoneracao = nil
254
+ must validate_inclusion_of(:motivo_desoneracao).in_array([1,2,3,4,5,6,7,8,9,10,11])
255
+ must allow_value('').for(:motivo_desoneracao)
256
+ end
257
+ end
258
+ end
259
+ context "CST 41" do
260
+ before { subject.codigo_cst = '41' }
261
+ it { wont validate_presence_of(:modalidade_base_calculo) }
262
+ it { wont validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
263
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
264
+ it { wont validate_presence_of(:total_base_calculo) }
265
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
266
+ it { wont validate_presence_of(:aliquota) }
267
+ it { wont validate_presence_of(:modalidade_base_calculo_st) }
268
+ it { wont validate_inclusion_of(:modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
269
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
270
+ it { must validate_numericality_of(:reducao_base_calculo_st).
271
+ is_greater_than_or_equal_to(0.0).
272
+ is_less_than_or_equal_to(100.0).
273
+ allow_nil
274
+ }
275
+ it { must validate_numericality_of(:reducao_base_calculo).
276
+ is_greater_than_or_equal_to(0.0).
277
+ is_less_than_or_equal_to(100.0).
278
+ allow_nil
279
+ }
280
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
281
+ it { wont validate_presence_of(:total_base_calculo_st) }
282
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
283
+ it { wont validate_presence_of(:aliquota_st) }
284
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
285
+ it { wont validate_presence_of(:total_st) }
286
+ it { wont validate_presence_of(:reducao_base_calculo) }
287
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
288
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
289
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
290
+ context 'Deve aplicar as regras para desoneracao' do
291
+ it { must validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
292
+ it "motivo_desoneracao não deve ser obrigatório se não tiver total_desoneracao" do
293
+ subject.total_desoneracao = nil
294
+ wont validate_presence_of(:motivo_desoneracao)
295
+ end
296
+ it "motivo_desoneracao deve ser obrigatório mesmo se tiver total_desoneracao" do
297
+ subject.total_desoneracao = 50.0
298
+ must validate_presence_of(:motivo_desoneracao)
299
+ end
300
+ it 'motivo_desoneracao deve validar os valores permitidos' do
301
+ subject.total_desoneracao = nil
302
+ must validate_inclusion_of(:motivo_desoneracao).in_array([1,2,3,4,5,6,7,8,9,10,11])
303
+ must allow_value('').for(:motivo_desoneracao)
304
+ end
305
+ end
306
+ end
307
+ context "CST 50" do
308
+ before { subject.codigo_cst = '50' }
309
+ it { wont validate_presence_of(:modalidade_base_calculo) }
310
+ it { wont validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
311
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
312
+ it { wont validate_presence_of(:total_base_calculo) }
313
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
314
+ it { wont validate_presence_of(:aliquota) }
315
+ it { wont validate_presence_of(:modalidade_base_calculo_st) }
316
+ it { wont validate_inclusion_of(:modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
317
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
318
+ it { must validate_numericality_of(:reducao_base_calculo_st).
319
+ is_greater_than_or_equal_to(0.0).
320
+ is_less_than_or_equal_to(100.0).
321
+ allow_nil
322
+ }
323
+ it { must validate_numericality_of(:reducao_base_calculo).
324
+ is_greater_than_or_equal_to(0.0).
325
+ is_less_than_or_equal_to(100.0).
326
+ allow_nil
327
+ }
328
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
329
+ it { wont validate_presence_of(:total_base_calculo_st) }
330
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
331
+ it { wont validate_presence_of(:aliquota_st) }
332
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
333
+ it { wont validate_presence_of(:total_st) }
334
+ it { wont validate_presence_of(:reducao_base_calculo) }
335
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
336
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
337
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
338
+ context 'Deve aplicar as regras para desoneracao' do
339
+ it { must validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
340
+ it "motivo_desoneracao não deve ser obrigatório se não tiver total_desoneracao" do
341
+ subject.total_desoneracao = nil
342
+ wont validate_presence_of(:motivo_desoneracao)
343
+ end
344
+ it "motivo_desoneracao deve ser obrigatório mesmo se tiver total_desoneracao" do
345
+ subject.total_desoneracao = 50.0
346
+ must validate_presence_of(:motivo_desoneracao)
347
+ end
348
+ it 'motivo_desoneracao deve validar os valores permitidos' do
349
+ subject.total_desoneracao = nil
350
+ must validate_inclusion_of(:motivo_desoneracao).in_array([1,2,3,4,5,6,7,8,9,10,11])
351
+ must allow_value('').for(:motivo_desoneracao)
352
+ end
353
+ end
354
+ end
355
+ context "CST 51" do
356
+ before { subject.codigo_cst = '51' }
357
+ it { wont validate_presence_of(:modalidade_base_calculo) }
358
+ it { must allow_value('').for(:modalidade_base_calculo) }
359
+ it { must validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
360
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
361
+ it { wont validate_presence_of(:total_base_calculo) }
362
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
363
+ it { wont validate_presence_of(:aliquota) }
364
+ it { wont validate_presence_of(:modalidade_base_calculo_st) }
365
+ it { wont validate_inclusion_of(:modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
366
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
367
+ it { must validate_numericality_of(:reducao_base_calculo_st).
368
+ is_greater_than_or_equal_to(0.0).
369
+ is_less_than_or_equal_to(100.0).
370
+ allow_nil
371
+ }
372
+ it { must validate_numericality_of(:reducao_base_calculo).
373
+ is_greater_than_or_equal_to(0.0).
374
+ is_less_than_or_equal_to(100.0).
375
+ allow_nil
376
+ }
377
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
378
+ it { wont validate_presence_of(:total_base_calculo_st) }
379
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
380
+ it { wont validate_presence_of(:aliquota_st) }
381
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
382
+ it { wont validate_presence_of(:total_st) }
383
+ it { wont validate_presence_of(:reducao_base_calculo) }
384
+
385
+ it { must validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
386
+ it { must validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
387
+ it { must validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
388
+ context 'Não deve aplicar as regras para desoneracao' do
389
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
390
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
391
+ it { wont validate_presence_of(:motivo_desoneracao) }
392
+ end
393
+ end
394
+ context "CST 60" do
395
+ before { subject.codigo_cst = '60' }
396
+ describe "ICMS ST Retido" do
397
+ context "Deve validar o total_st_retido se total_base_calculo_st_retido for > que zero" do
398
+ before { subject.total_base_calculo_st_retido = 0.1 }
399
+ it { must validate_numericality_of(:total_st_retido).is_greater_than_or_equal_to(0.0).allow_nil }
400
+ it { must validate_presence_of(:total_st_retido) }
401
+ end
402
+ context "Não deve validar o total_st_retido se total_base_calculo_st_retido for zero" do
403
+ before { subject.total_base_calculo_st_retido = 0.0 }
404
+ it { wont validate_numericality_of(:total_st_retido).is_greater_than_or_equal_to(0.0).allow_nil }
405
+ it { wont validate_presence_of(:total_st_retido) }
406
+ end
407
+ context "Não deve validar o total_st_retido se total_base_calculo_st_retido for nil" do
408
+ before { subject.total_base_calculo_st_retido = nil }
409
+ it { wont validate_numericality_of(:total_st_retido).is_greater_than_or_equal_to(0.0).allow_nil }
410
+ it { wont validate_presence_of(:total_st_retido) }
411
+ end
412
+ end
413
+ it { wont validate_presence_of(:modalidade_base_calculo) }
414
+ it { wont validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
415
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
416
+ it { wont validate_presence_of(:total_base_calculo) }
417
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
418
+ it { wont validate_presence_of(:aliquota) }
419
+ it { wont validate_presence_of(:modalidade_base_calculo_st) }
420
+ it { wont validate_inclusion_of(:modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
421
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
422
+ it { must validate_numericality_of(:reducao_base_calculo_st).
423
+ is_greater_than_or_equal_to(0.0).
424
+ is_less_than_or_equal_to(100.0).
425
+ allow_nil
426
+ }
427
+ it { must validate_numericality_of(:reducao_base_calculo).
428
+ is_greater_than_or_equal_to(0.0).
429
+ is_less_than_or_equal_to(100.0).
430
+ allow_nil
431
+ }
432
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
433
+ it { wont validate_presence_of(:total_base_calculo_st) }
434
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
435
+ it { wont validate_presence_of(:aliquota_st) }
436
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
437
+ it { wont validate_presence_of(:total_st) }
438
+ it { wont validate_presence_of(:reducao_base_calculo) }
439
+
440
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
441
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
442
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
443
+ context 'Não deve aplicar as regras para desoneracao' do
444
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
445
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
446
+ it { wont validate_presence_of(:motivo_desoneracao) }
447
+ end
448
+ end
449
+ context "CST 70" do
450
+ before { subject.codigo_cst = '70' }
451
+ it { must validate_presence_of(:modalidade_base_calculo) }
452
+ it { must validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
453
+ it { must validate_numericality_of(:reducao_base_calculo).
454
+ is_greater_than_or_equal_to(0.0).
455
+ is_less_than_or_equal_to(100.0).
456
+ allow_nil
457
+ }
458
+ it { must validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
459
+ it { must validate_presence_of( :total_base_calculo) }
460
+ it { must validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
461
+ it { must validate_presence_of( :aliquota) }
462
+ it { must validate_presence_of( :modalidade_base_calculo_st) }
463
+ it { must validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
464
+ it { must validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
465
+ it { must validate_numericality_of(:reducao_base_calculo_st).
466
+ is_greater_than_or_equal_to(0.0).
467
+ is_less_than_or_equal_to(100.0).
468
+ allow_nil
469
+ }
470
+ it { must validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
471
+ it { must validate_presence_of( :total_base_calculo_st) }
472
+ it { must validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
473
+ it { must validate_presence_of( :aliquota_st) }
474
+ it { must validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
475
+ it { must validate_presence_of( :total_st) }
476
+
477
+
478
+ it { wont validate_presence_of(:reducao_base_calculo) }
479
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
480
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
481
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
482
+
483
+ context 'Deve aplicar as regras para desoneracao' do
484
+ it { must validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
485
+ it "motivo_desoneracao não deve ser obrigatório se não tiver total_desoneracao" do
486
+ subject.total_desoneracao = ''
487
+ must allow_value('').for(:motivo_desoneracao)
488
+ end
489
+ it "motivo_desoneracao deve ser obrigatório mesmo se tiver total_desoneracao" do
490
+ subject.total_desoneracao = 50.0
491
+ must validate_presence_of(:motivo_desoneracao)
492
+ end
493
+ it 'motivo_desoneracao deve validar os valores permitidos' do
494
+ subject.total_desoneracao = nil
495
+ must validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12])
496
+ end
497
+ end
498
+ end
499
+ context "CST 90" do
500
+ before { subject.codigo_cst = '90' }
501
+ it { must validate_presence_of(:modalidade_base_calculo) }
502
+ it { must validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
503
+
504
+ it { must validate_numericality_of(:reducao_base_calculo).
505
+ is_greater_than_or_equal_to(0.0).
506
+ is_less_than_or_equal_to(100.0).
507
+ allow_nil
508
+ }
509
+ it { must validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
510
+ it { must validate_presence_of( :total_base_calculo) }
511
+ it { must validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
512
+ it { must validate_presence_of( :aliquota) }
513
+ it { must validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0).allow_nil }
514
+ it { wont validate_presence_of( :aliquota_st) }
515
+ describe "quando a aliquota_st for preenchida" do
516
+ before { subject.aliquota_st = 7.5 }
517
+ it { must validate_presence_of( :modalidade_base_calculo_st) }
518
+ it { must validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
519
+ it { must validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
520
+ it { must validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
521
+ it { must validate_presence_of( :total_base_calculo_st) }
522
+ it { must validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
523
+ it { must validate_presence_of( :total_st) }
524
+ end
525
+ describe "quando a aliquota_st não for preenchida" do
526
+ before { subject.aliquota_st = nil }
527
+ it { wont validate_presence_of( :modalidade_base_calculo_st) }
528
+ it { wont validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
529
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
530
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
531
+ it { wont validate_presence_of( :total_base_calculo_st) }
532
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
533
+ it { wont validate_presence_of( :total_st) }
534
+ end
535
+ context 'Deve aplicar as regras para desoneracao' do
536
+ it { must validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
537
+ it "motivo_desoneracao não deve ser obrigatório se não tiver total_desoneracao" do
538
+ subject.total_desoneracao = ''
539
+ must allow_value('').for(:motivo_desoneracao)
540
+ end
541
+ it "motivo_desoneracao deve ser obrigatório mesmo se tiver total_desoneracao" do
542
+ subject.total_desoneracao = 50.0
543
+ must validate_presence_of(:motivo_desoneracao)
544
+ end
545
+ it 'motivo_desoneracao deve validar os valores permitidos' do
546
+ subject.total_desoneracao = nil
547
+ must validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12])
548
+ end
549
+ end
550
+ end
551
+ context "CST 101 - CSOSN" do
552
+ before { subject.codigo_cst = '101' }
553
+ it { must validate_numericality_of(:aliquota_credito_sn).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
554
+ it { must validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
555
+ it { must validate_presence_of(:aliquota_credito_sn) }
556
+ it { must validate_presence_of(:total_credito_sn) }
557
+
558
+ it { wont validate_presence_of(:modalidade_base_calculo) }
559
+ it { wont validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
560
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
561
+ it { wont validate_presence_of( :total_base_calculo) }
562
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
563
+ it { wont validate_presence_of( :aliquota) }
564
+ it { wont validate_presence_of( :modalidade_base_calculo_st) }
565
+ it { wont validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
566
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
567
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
568
+ it { wont validate_presence_of( :total_base_calculo_st) }
569
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
570
+ it { wont validate_presence_of( :aliquota_st) }
571
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
572
+ it { wont validate_presence_of( :total_st) }
573
+ it { wont validate_presence_of(:reducao_base_calculo) }
574
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
575
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
576
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
577
+ context 'Não deve aplicar as regras para desoneracao' do
578
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
579
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
580
+ it { wont validate_presence_of(:motivo_desoneracao) }
581
+ end
582
+ end
583
+ context "CST 102 - CSOSN" do
584
+ before { subject.codigo_cst = '102' }
585
+ it { wont validate_numericality_of(:aliquota_credito_sn).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
586
+ it { wont validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
587
+ it { wont validate_presence_of(:aliquota_credito_sn) }
588
+ it { wont validate_presence_of(:total_credito_sn) }
589
+ it { wont validate_presence_of(:modalidade_base_calculo) }
590
+ it { wont validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
591
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
592
+ it { wont validate_presence_of( :total_base_calculo) }
593
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
594
+ it { wont validate_presence_of( :aliquota) }
595
+ it { wont validate_presence_of( :modalidade_base_calculo_st) }
596
+ it { wont validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
597
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
598
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
599
+ it { wont validate_presence_of( :total_base_calculo_st) }
600
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
601
+ it { wont validate_presence_of( :aliquota_st) }
602
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
603
+ it { wont validate_presence_of( :total_st) }
604
+ it { wont validate_presence_of(:reducao_base_calculo) }
605
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
606
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
607
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
608
+ context 'Não deve aplicar as regras para desoneracao' do
609
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
610
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
611
+ it { wont validate_presence_of(:motivo_desoneracao) }
612
+ end
613
+ end
614
+ context "CST 103 - CSOSN" do
615
+ before { subject.codigo_cst = '103' }
616
+ it { wont validate_numericality_of(:aliquota_credito_sn).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
617
+ it { wont validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
618
+ it { wont validate_presence_of(:aliquota_credito_sn) }
619
+ it { wont validate_presence_of(:total_credito_sn) }
620
+ it { wont validate_presence_of(:modalidade_base_calculo) }
621
+ it { wont validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
622
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
623
+ it { wont validate_presence_of( :total_base_calculo) }
624
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
625
+ it { wont validate_presence_of( :aliquota) }
626
+ it { wont validate_presence_of( :modalidade_base_calculo_st) }
627
+ it { wont validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
628
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
629
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
630
+ it { wont validate_presence_of( :total_base_calculo_st) }
631
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
632
+ it { wont validate_presence_of( :aliquota_st) }
633
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
634
+ it { wont validate_presence_of( :total_st) }
635
+ it { wont validate_presence_of(:reducao_base_calculo) }
636
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
637
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
638
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
639
+ context 'Não deve aplicar as regras para desoneracao' do
640
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
641
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
642
+ it { wont validate_presence_of(:motivo_desoneracao) }
643
+ end
644
+ end
645
+ context "CST 300 - CSOSN" do
646
+ before { subject.codigo_cst = '300' }
647
+ it { wont validate_numericality_of(:aliquota_credito_sn).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
648
+ it { wont validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
649
+ it { wont validate_presence_of(:aliquota_credito_sn) }
650
+ it { wont validate_presence_of(:total_credito_sn) }
651
+ it { wont validate_presence_of(:modalidade_base_calculo) }
652
+ it { wont validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
653
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
654
+ it { wont validate_presence_of( :total_base_calculo) }
655
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
656
+ it { wont validate_presence_of( :aliquota) }
657
+ it { wont validate_presence_of( :modalidade_base_calculo_st) }
658
+ it { wont validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
659
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
660
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
661
+ it { wont validate_presence_of( :total_base_calculo_st) }
662
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
663
+ it { wont validate_presence_of( :aliquota_st) }
664
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
665
+ it { wont validate_presence_of( :total_st) }
666
+ it { wont validate_presence_of(:reducao_base_calculo) }
667
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
668
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
669
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
670
+ context 'Não deve aplicar as regras para desoneracao' do
671
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
672
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
673
+ it { wont validate_presence_of(:motivo_desoneracao) }
674
+ end
675
+ end
676
+ context "CST 400 - CSOSN" do
677
+ before { subject.codigo_cst = '400' }
678
+ it { wont validate_numericality_of(:aliquota_credito_sn).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
679
+ it { wont validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
680
+ it { wont validate_presence_of(:aliquota_credito_sn) }
681
+ it { wont validate_presence_of(:total_credito_sn) }
682
+ it { wont validate_presence_of(:modalidade_base_calculo) }
683
+ it { wont validate_inclusion_of(:modalidade_base_calculo).in_array([0,1,2,3]) }
684
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
685
+ it { wont validate_presence_of( :total_base_calculo) }
686
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
687
+ it { wont validate_presence_of( :aliquota) }
688
+ it { wont validate_presence_of( :modalidade_base_calculo_st) }
689
+ it { wont validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
690
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0) }
691
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
692
+ it { wont validate_presence_of( :total_base_calculo_st) }
693
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
694
+ it { wont validate_presence_of( :aliquota_st) }
695
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
696
+ it { wont validate_presence_of( :total_st) }
697
+ it { wont validate_presence_of(:reducao_base_calculo) }
698
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
699
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
700
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
701
+ context 'Não deve aplicar as regras para desoneracao' do
702
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
703
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
704
+ it { wont validate_presence_of(:motivo_desoneracao) }
705
+ end
706
+ end
707
+ context "CST 201 - CSOSN" do
708
+ before { subject.codigo_cst = '201' }
709
+ it { must validate_presence_of( :modalidade_base_calculo_st) }
710
+ it { must validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
711
+ it { must validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0).allow_nil }
712
+ it { must validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
713
+ it { must validate_presence_of( :total_base_calculo_st) }
714
+ it { must validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
715
+ it { must validate_presence_of( :total_st) }
716
+ it { must validate_numericality_of(:aliquota_credito_sn).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
717
+ it { must validate_presence_of( :aliquota_credito_sn) }
718
+ it { must validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
719
+ it { must validate_presence_of(:total_credito_sn) }
720
+ it { must validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
721
+ it { must validate_presence_of( :aliquota_st) }
722
+
723
+
724
+ it { wont validate_presence_of( :modalidade_base_calculo) }
725
+ it { wont validate_inclusion_of( :modalidade_base_calculo).in_array([0,1,2,3]) }
726
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
727
+ it { wont validate_presence_of( :total_base_calculo) }
728
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
729
+ it { wont validate_presence_of( :aliquota) }
730
+ it { wont validate_presence_of(:reducao_base_calculo) }
731
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
732
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
733
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
734
+ context 'Não deve aplicar as regras para desoneracao' do
735
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
736
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
737
+ it { wont validate_presence_of(:motivo_desoneracao) }
738
+ end
739
+ end
740
+ context "CST 202 - CSOSN" do
741
+ before { subject.codigo_cst = '202' }
742
+ it { must validate_presence_of( :modalidade_base_calculo_st) }
743
+ it { must validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
744
+ it { must validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0).allow_nil }
745
+ it { must validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
746
+ it { must validate_presence_of( :total_base_calculo_st) }
747
+ it { must validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
748
+ it { must validate_presence_of( :total_st) }
749
+ it { must validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
750
+ it { must validate_presence_of( :aliquota_st) }
751
+
752
+
753
+ it { wont validate_numericality_of(:aliquota_credito_sn).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
754
+ it { wont validate_presence_of( :aliquota_credito_sn) }
755
+ it { wont validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
756
+ it { wont validate_presence_of(:total_credito_sn) }
757
+ it { wont validate_presence_of( :modalidade_base_calculo) }
758
+ it { wont validate_inclusion_of( :modalidade_base_calculo).in_array([0,1,2,3]) }
759
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
760
+ it { wont validate_presence_of( :total_base_calculo) }
761
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
762
+ it { wont validate_presence_of( :aliquota) }
763
+ it { wont validate_presence_of(:reducao_base_calculo) }
764
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
765
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
766
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
767
+ context 'Não deve aplicar as regras para desoneracao' do
768
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
769
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
770
+ it { wont validate_presence_of(:motivo_desoneracao) }
771
+ end
772
+ end
773
+ context "CST 203 - CSOSN" do
774
+ before { subject.codigo_cst = '203' }
775
+ it { must validate_presence_of( :modalidade_base_calculo_st) }
776
+ it { must validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
777
+ it { must validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0).allow_nil }
778
+ it { must validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
779
+ it { must validate_presence_of( :total_base_calculo_st) }
780
+ it { must validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
781
+ it { must validate_presence_of( :total_st) }
782
+ it { must validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
783
+ it { must validate_presence_of( :aliquota_st) }
784
+
785
+
786
+ it { wont validate_numericality_of(:aliquota_credito_sn).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
787
+ it { wont validate_presence_of( :aliquota_credito_sn) }
788
+ it { wont validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
789
+ it { wont validate_presence_of(:total_credito_sn) }
790
+ it { wont validate_presence_of( :modalidade_base_calculo) }
791
+ it { wont validate_inclusion_of( :modalidade_base_calculo).in_array([0,1,2,3]) }
792
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
793
+ it { wont validate_presence_of( :total_base_calculo) }
794
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
795
+ it { wont validate_presence_of( :aliquota) }
796
+ it { wont validate_presence_of(:reducao_base_calculo) }
797
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
798
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
799
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
800
+ context 'Não deve aplicar as regras para desoneracao' do
801
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
802
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
803
+ it { wont validate_presence_of(:motivo_desoneracao) }
804
+ end
805
+ end
806
+ context "CST 500 - CSOSN" do
807
+ before { subject.codigo_cst = '500' }
808
+ describe "ICMS ST Retido" do
809
+ context "Deve validar o total_st_retido se total_base_calculo_st_retido for > que zero" do
810
+ before { subject.total_base_calculo_st_retido = 0.1 }
811
+ it { must validate_numericality_of(:total_st_retido).is_greater_than_or_equal_to(0.0).allow_nil }
812
+ it { must validate_presence_of(:total_st_retido) }
813
+ end
814
+ context "Não deve validar o total_st_retido se total_base_calculo_st_retido for zero" do
815
+ before { subject.total_base_calculo_st_retido = 0.0 }
816
+ it { wont validate_numericality_of(:total_st_retido).is_greater_than_or_equal_to(0.0).allow_nil }
817
+ it { wont validate_presence_of(:total_st_retido) }
818
+ end
819
+ context "Não deve validar o total_st_retido se total_base_calculo_st_retido for nil" do
820
+ before { subject.total_base_calculo_st_retido = nil }
821
+ it { wont validate_numericality_of(:total_st_retido).is_greater_than_or_equal_to(0.0).allow_nil }
822
+ it { wont validate_presence_of(:total_st_retido) }
823
+ end
824
+ end
825
+ it { wont validate_presence_of( :modalidade_base_calculo_st) }
826
+ it { wont validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
827
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0).allow_nil }
828
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0) }
829
+ it { wont validate_presence_of( :total_base_calculo_st) }
830
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0) }
831
+ it { wont validate_presence_of( :total_st) }
832
+ it { wont validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0) }
833
+ it { wont validate_presence_of( :aliquota_st) }
834
+ it { wont validate_numericality_of(:aliquota_credito_sn).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
835
+ it { wont validate_presence_of( :aliquota_credito_sn) }
836
+ it { wont validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
837
+ it { wont validate_presence_of(:total_credito_sn) }
838
+ it { wont validate_presence_of( :modalidade_base_calculo) }
839
+ it { wont validate_inclusion_of( :modalidade_base_calculo).in_array([0,1,2,3]) }
840
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0) }
841
+ it { wont validate_presence_of( :total_base_calculo) }
842
+ it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0) }
843
+ it { wont validate_presence_of( :aliquota) }
844
+ it { wont validate_presence_of(:reducao_base_calculo) }
845
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
846
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
847
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
848
+ context 'Não deve aplicar as regras para desoneracao' do
849
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
850
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
851
+ it { wont validate_presence_of(:motivo_desoneracao) }
852
+ end
853
+ end
854
+ context "CST 900 - CSOSN" do
855
+ before { subject.codigo_cst = '900' }
856
+ describe "ICMS Normal" do
857
+ it { must validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
858
+ it { wont validate_presence_of(:aliquota) }
859
+ context "Deve validar os dados do ICMS normal se aliquota for > que zero" do
860
+ before { subject.aliquota = 0.1 }
861
+ it { must validate_presence_of( :modalidade_base_calculo) }
862
+ it { must validate_inclusion_of( :modalidade_base_calculo).in_array([0,1,2,3]) }
863
+ it { must validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0).allow_nil }
864
+ it { must validate_presence_of( :total_base_calculo) }
865
+ it { must validate_numericality_of(:total).is_greater_than_or_equal_to(0.0).allow_nil }
866
+ end
867
+ context "Deve validar os dados do ICMS normal se aliquota for zero" do
868
+ before { subject.aliquota = 0.0 }
869
+ it { wont validate_presence_of( :modalidade_base_calculo) }
870
+ it { wont validate_inclusion_of( :modalidade_base_calculo).in_array([0,1,2,3]) }
871
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0).allow_nil }
872
+ it { wont validate_presence_of( :total_base_calculo) }
873
+ it { wont validate_numericality_of(:total).is_greater_than_or_equal_to(0.0).allow_nil }
874
+ it { wont validate_presence_of( :total) }
875
+ end
876
+ context "Deve validar os dados do ICMS normal se aliquota for nil" do
877
+ before { subject.aliquota = nil }
878
+ it { wont validate_presence_of( :modalidade_base_calculo) }
879
+ it { wont validate_inclusion_of( :modalidade_base_calculo).in_array([0,1,2,3]) }
880
+ it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0).allow_nil }
881
+ it { wont validate_presence_of( :total_base_calculo) }
882
+ it { wont validate_numericality_of(:total).is_greater_than_or_equal_to(0.0).allow_nil }
883
+ it { wont validate_presence_of( :total) }
884
+ end
885
+ end
886
+ describe "ICMS ST" do
887
+ it { must validate_numericality_of(:aliquota_st).is_greater_than_or_equal_to(0.0).allow_nil }
888
+ it { wont validate_presence_of(:aliquota_st) }
889
+ context "Deve validar os dados do ICMS normal se aliquota_st for > que zero" do
890
+ before { subject.aliquota_st = 0.1 }
891
+ it { must validate_presence_of( :modalidade_base_calculo_st) }
892
+ it { must validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
893
+ it { must validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0).allow_nil }
894
+ it { must validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0).allow_nil }
895
+ it { must validate_presence_of( :total_base_calculo_st) }
896
+ it { must validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0).allow_nil }
897
+ it { must validate_presence_of( :total_st) }
898
+ end
899
+ context "Deve validar os dados do ICMS normal se aliquota_st for zero" do
900
+ before { subject.aliquota_st = 0.0 }
901
+ it { wont validate_presence_of( :modalidade_base_calculo_st) }
902
+ it { wont validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
903
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0).allow_nil }
904
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0).allow_nil }
905
+ it { wont validate_presence_of( :total_base_calculo_st) }
906
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0).allow_nil }
907
+ it { wont validate_presence_of( :total_st) }
908
+ end
909
+ context "Deve validar os dados do ICMS normal se aliquota_st for nil" do
910
+ before { subject.aliquota_st = nil }
911
+ it { wont validate_presence_of( :modalidade_base_calculo_st) }
912
+ it { wont validate_inclusion_of( :modalidade_base_calculo_st).in_array([0,1,2,3,4,5]) }
913
+ it { wont validate_numericality_of(:mva_st).is_greater_than_or_equal_to(0.0).allow_nil }
914
+ it { wont validate_numericality_of(:total_base_calculo_st).is_greater_than_or_equal_to(0.0).allow_nil }
915
+ it { wont validate_presence_of( :total_base_calculo_st) }
916
+ it { wont validate_numericality_of(:total_st).is_greater_than_or_equal_to(0.0).allow_nil }
917
+ it { wont validate_presence_of( :total_st) }
918
+ end
919
+ end
920
+
921
+ describe "Aliquota de crédito" do
922
+ it { must validate_numericality_of(:aliquota_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
923
+ it { wont validate_presence_of(:aliquota_credito_sn) }
924
+ context "Deve validar os dados do ICMS normal se aliquota_credito_sn for > que zero" do
925
+ before { subject.aliquota_credito_sn = 0.1 }
926
+ it { must validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
927
+ it { must validate_presence_of(:total_credito_sn) }
928
+ end
929
+ context "Deve validar os dados do ICMS normal se aliquota_credito_sn for zero" do
930
+ before { subject.aliquota_credito_sn = 0.0 }
931
+ it { wont validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
932
+ it { wont validate_presence_of(:total_credito_sn) }
933
+ end
934
+ context "Deve validar os dados do ICMS normal se aliquota_credito_sn for nil" do
935
+ before { subject.aliquota_credito_sn = nil }
936
+ it { wont validate_numericality_of(:total_credito_sn).is_greater_than_or_equal_to(0.0).allow_nil }
937
+ it { wont validate_presence_of(:total_credito_sn) }
938
+ end
939
+ end
940
+ it { wont validate_presence_of(:reducao_base_calculo) }
941
+ it { wont validate_numericality_of(:total_icms_operacao).is_greater_than_or_equal_to(0.0).allow_nil }
942
+ it { wont validate_numericality_of(:total_icms_diferido).is_greater_than_or_equal_to(0.0).allow_nil }
943
+ it { wont validate_numericality_of(:percentual_diferimento).is_greater_than_or_equal_to(0.0).is_less_than_or_equal_to(100.0).allow_nil }
944
+ context 'Não deve aplicar as regras para desoneracao' do
945
+ it { wont validate_numericality_of(:total_desoneracao).is_greater_than_or_equal_to(0.0).allow_nil }
946
+ it { wont validate_inclusion_of(:motivo_desoneracao).in_array([3,9,12]) }
947
+ it { wont validate_presence_of(:motivo_desoneracao) }
948
+ end
949
+ end
950
+ end
951
+
952
+ describe '#origem' do
953
+ it "se setar um valor nil deve retornar 0" do
954
+ subject.origem = nil
955
+ subject.origem.must_equal 0
956
+ end
957
+ it "deve sempre retornar um valor inteiro" do
958
+ subject.origem = '1'
959
+ subject.origem.must_equal 1
960
+ subject.origem = '02'
961
+ subject.origem.must_equal 2
962
+ subject.origem = '04'
963
+ subject.origem.must_equal 4
964
+ end
965
+ end
966
+
967
+ describe '#motivo_desoneracao' do
968
+ it "se setar um valor nil deve retornar nil" do
969
+ subject.motivo_desoneracao = nil
970
+ subject.motivo_desoneracao.must_be_nil
971
+ end
972
+ it "deve sempre retornar um valor inteiro" do
973
+ subject.motivo_desoneracao = '1'
974
+ subject.motivo_desoneracao.must_equal 1
975
+ subject.motivo_desoneracao = '02'
976
+ subject.motivo_desoneracao.must_equal 2
977
+ subject.motivo_desoneracao = '04'
978
+ subject.motivo_desoneracao.must_equal 4
979
+ end
980
+ end
981
+
982
+ describe '#codigo_cst' do
983
+ it "deve sempre retornar uam string" do
984
+ subject.codigo_cst = 100
985
+ subject.codigo_cst.must_equal '100'
986
+ end
987
+ it "deve ajustar o valor para 2 posições adicionando zeros" do
988
+ subject.codigo_cst = 0
989
+ subject.codigo_cst.must_equal '00'
990
+ end
991
+ it "se não tiver valor setado deve retornar nil" do
992
+ subject.codigo_cst = ''
993
+ subject.codigo_cst.must_be_nil
994
+ end
995
+ end
996
+
997
+ describe '#total' do
998
+ it "Se não setar um valor deve calcular automaticamente" do
999
+ subject.assign_attributes(total_base_calculo: 171.58, aliquota: 18.0, total: nil)
1000
+ subject.instance_variable_get(:@total).must_be_nil
1001
+ subject.total.must_equal 30.88
1002
+ subject.instance_variable_get(:@total).must_equal 30.88
1003
+ end
1004
+ it "se tiver um valor setado manualmente não deve calcular" do
1005
+ subject.assign_attributes(total_base_calculo: 171.58, aliquota: 18.0, total: 20.0)
1006
+ subject.total.must_equal 20.0
1007
+ end
1008
+ end
1009
+
1010
+
1011
+ end