Sha256: 5b4e4c442e0f444a3becfe96f4253259dc17223f844ec0cbaca3943bcfc6a98f

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 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)
        @xmls.each do |xml|
          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
          BrDanfe::QrCode.new(pdf: @document, xml: xml, qr_code_tag: xml['qrCode'], box_size: 3.cm).render
          NfceLib::Footer.new(@document, xml).render(footer_info)

          render_no_fiscal_value(xml)
          resize_page_height
        end
      end

      def render_no_fiscal_value(xml)
        @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

1 entries across 1 versions & 1 rubygems

Version Path
br_danfe-0.16.0 lib/br_danfe/danfe_lib/nfce.rb