Sha256: 02e7acc66c94d61ff4ab7b276e5a34b589efa00f9807225b22e8b1f621123826

Contents?: true

Size: 1.45 KB

Versions: 12

Compression:

Stored size: 1.45 KB

Contents

module BrInvoicesPdf
  module Cfe
    module Renderer
      module Totals
        extend BaseRenderer

        module_function

        def execute(pdf, data)
          insert_box_info(pdf, data)

          pdf.move_down(5)
        end

        def insert_box_info(pdf, data, xpos = 0)
          third_width = page_content_width(pdf) * 0.333333333
          ypos = pdf.cursor
          box_info(data[:payment]).each do |(title, value)|
            insert_box(pdf, title: title, value: value, xpos: xpos, ypos: ypos, third_width: third_width)
            xpos += third_width
          end
        end
        private_class_method :insert_box_info

        # :reek:FeatureEnvy
        def insert_box(pdf, params)
          box(pdf, [params[:xpos], params[:ypos]], params[:third_width]) do
            insert_texts(pdf, params[:title], params[:value])
          end
        end
        private_class_method :insert_box

        def insert_texts(pdf, title, value)
          pdf.text(title, style: :italic)
          pdf.text(value, align: :right)
        end
        private_class_method :insert_texts

        def box_info(data_payment)
          [
            ['Total bruto dos itens', format_currency(BigDecimal(data_payment[:total_price]))],
            ['Desconto', format_currency(BigDecimal(data_payment[:discount]))],
            ['Total', format_currency(BigDecimal(data_payment[:total]))]
          ]
        end
        private_class_method :box_info
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.5.alpha.17 lib/br_invoices_pdf/cfe/renderer/totals.rb
br_invoices_pdf-0.2.5 lib/br_invoices_pdf/cfe/renderer/totals.rb
br_invoices_pdf-0.2.5.alpha.16 lib/br_invoices_pdf/cfe/renderer/totals.rb
br_invoices_pdf-0.2.4 lib/br_invoices_pdf/cfe/renderer/totals.rb
br_invoices_pdf-0.2.4.alpha.15 lib/br_invoices_pdf/cfe/renderer/totals.rb
br_invoices_pdf-0.2.4.alpha.14 lib/br_invoices_pdf/cfe/renderer/totals.rb
br_invoices_pdf-0.2.3 lib/br_invoices_pdf/cfe/renderer/totals.rb
br_invoices_pdf-0.2.2 lib/br_invoices_pdf/cfe/renderer/totals.rb
br_invoices_pdf-0.2.1 lib/br_invoices_pdf/cfe/renderer/totals.rb
br_invoices_pdf-0.2.0 lib/br_invoices_pdf/cfe/renderer/totals.rb
br_invoices_pdf-0.2.0.alpha.13 lib/br_invoices_pdf/cfe/renderer/totals.rb
br_invoices_pdf-0.2.0.alpha.12 lib/br_invoices_pdf/cfe/renderer/totals.rb