Sha256: 8bb0d7cbe9fe98b06d000d3c33a7ed4343205a7be58677bd550013e6a91fdeef

Contents?: true

Size: 636 Bytes

Versions: 3

Compression:

Stored size: 636 Bytes

Contents

module BrDanfe
  module DanfeLib
    class Cst
      def self.to_danfe(xml)
        value = origin(xml)

        if csosn?(xml)
          value += xml.css('ICMS/*/CSOSN').text
        elsif cst?(xml)
          value += xml.css('ICMS/*/CST').text
        end

        value
      end

      def self.origin(xml)
        xml.css('ICMS/*/orig').text
      end
      private_class_method :origin

      def self.cst?(xml)
        xml.css('ICMS/*/CST').text != ''
      end
      private_class_method :cst?

      def self.csosn?(xml)
        xml.css('ICMS/*/CSOSN').text != ''
      end
      private_class_method :csosn?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
br_danfe-0.12.1 lib/br_danfe/danfe_lib/cst.rb
br_danfe-0.12.0 lib/br_danfe/danfe_lib/cst.rb
br_danfe-0.11.2 lib/br_danfe/danfe_lib/cst.rb