Sha256: ea9412bc087b548ea8e523eaf6fa5ba0a8f0b47718260d7d6c2fb860673a49ad

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

module BrDanfe
  module DanfeLib
    class Nfce < Base
      PAGE_WIDTH = 8.cm
      PAGE_HEIGHT = 100.cm

      private

      def document
        NfceLib::Document.new(PAGE_WIDTH, PAGE_HEIGHT)
      end

      def create_watermark
        @document.create_stamp('has_no_fiscal_value') do
          @document.fill_color '7d7d7d'
          @document.text_box I18n.t('danfe.others.has_no_fiscal_value'),
                    size: 0.8.cm,
                    width: 10.cm,
                    height: 1.2.cm,
                    at: [0, PAGE_HEIGHT - 3.8.cm],
                    rotate: 45,
                    rotate_around: :center
        end
      end

      def generate(footer_info)
        NfceLib::Header.new(@document, @xml, @options.logo, @options.logo_dimensions).render
        NfceLib::ProductList.new(@document, @xml).render
        NfceLib::TotalList.new(@document, @xml).render
        NfceLib::Key.new(@document, @xml).render
        NfceLib::Recipient.new(@document, @xml).render
        NfceLib::NfceIdentification.new(@document, @xml).render
        NfceLib::QrCode.new(@document, @xml).render
        NfceLib::Footer.new(@document, @xml).render(footer_info)

        render_no_fiscal_value
        resize_page_height
      end

      def render_no_fiscal_value
        @document.stamp('has_no_fiscal_value') if BrDanfe::Helper.unauthorized?(@xml)
      end

      def resize_page_height
        @document.page.dictionary.data[:MediaBox] = [0, @document.y - 10, PAGE_WIDTH, PAGE_HEIGHT]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
br_danfe-0.14.5 lib/br_danfe/danfe_lib/nfce.rb
br_danfe-0.14.4 lib/br_danfe/danfe_lib/nfce.rb
br_danfe-0.14.3 lib/br_danfe/danfe_lib/nfce.rb
br_danfe-0.14.2 lib/br_danfe/danfe_lib/nfce.rb
br_danfe-0.14.0 lib/br_danfe/danfe_lib/nfce.rb
br_danfe-0.13.3 lib/br_danfe/danfe_lib/nfce.rb
br_danfe-0.13.2 lib/br_danfe/danfe_lib/nfce.rb
br_danfe-0.13.1 lib/br_danfe/danfe_lib/nfce.rb
br_danfe-0.13.0 lib/br_danfe/danfe_lib/nfce.rb