Sha256: 19c6047fbc39af6947433fc4bc6d5fb351d7d19eab3ece43fb71cfd341fbb039
Contents?: true
Size: 1.89 KB
Versions: 3
Compression:
Stored size: 1.89 KB
Contents
module BrDanfe module DanfeLib class Xprod def initialize(det) @det = det end def render xprod = "#{@det.css('prod/xProd').text}" xprod += infAdProd if has_infAdProd? xprod += fci if has_fci? xprod += st if has_st? xprod += difal if has_difal? xprod end private def has_infAdProd? !@det.css("infAdProd").text.empty? end def has_fci? !@det.css("prod/nFCI").text.empty? end def has_st? @det.css("ICMS/*/vBCST").text.to_i > 0 end def has_difal? @det.css("ICMSUFDest").present? end def infAdProd "\n" + @det.css("infAdProd").text end def fci "\n" + I18n.t("danfe.det.prod.xProdFCI", nFCI: @det.css('prod/nFCI').text) end def st "\n" + I18n.t("danfe.det.prod.xProdST", pMVAST: Helper.numerify(@det.css('ICMS/*/pMVAST').text, 2), pICMSST: Helper.numerify(@det.css('ICMS/*/pICMSST').text, 2), vBCST: Helper.numerify(@det.css('ICMS/*/vBCST').text, 2), vICMSST: Helper.numerify(@det.css('ICMS/*/vICMSST').text, 2)) end def difal "\n" + I18n.t("danfe.det.prod.xProdDIFAL", vBCUFDest: Helper.numerify(@det.css('ICMSUFDest/vBCUFDest').text, 2), pFCPUFDest: Helper.numerify(@det.css('ICMSUFDest/pFCPUFDest').text, 2), pICMSUFDest: Helper.numerify(@det.css('ICMSUFDest/pICMSUFDest').text, 2), pICMSInter: Helper.numerify(@det.css('ICMSUFDest/pICMSInter').text, 2), pICMSInterPart: @det.css('ICMSUFDest/pICMSInterPart').text, vFCPUFDest: Helper.numerify(@det.css('ICMSUFDest/vFCPUFDest').text, 2), vICMSUFDest: Helper.numerify(@det.css('ICMSUFDest/vICMSUFDest').text, 2), vICMSUFRemet: Helper.numerify(@det.css('ICMSUFDest/vICMSUFRemet').text, 2)) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
br_danfe-0.4.2 | lib/br_danfe/danfe_lib/xprod.rb |
br_danfe-0.4.1 | lib/br_danfe/danfe_lib/xprod.rb |
br_danfe-0.4.0 | lib/br_danfe/danfe_lib/xprod.rb |