Sha256: f97775d6cbe517325cc28649b1d970d56f934ca578de5244c8fb8bf1265574c1

Contents?: true

Size: 1.37 KB

Versions: 23

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module BrInvoicesPdf
  module Cfe
    module Renderer
      module PaymentForms
        extend Util::BaseRenderer
        extend BaseRenderer

        module_function

        def execute(pdf, data)
          execute_payment_form(pdf, payments_table_data(data))
        end

        def render_table(pdf, table_data, width)
          pdf.table(table_data, width: width) do |table|
            format_table(table, table_data)
          end
        end
        private_class_method :render_table

        # :reek:FeatureEnvy
        def format_table(table, table_data)
          table.columns([0, 1]).valign = :center
          table.columns(1).align = :right
          table_size = table_data.size
          table.row([0, table_size - 1]).font_style = :bold
          table.row([0, table_size - 2]).font_style = :bold
        end
        private_class_method :format_table

        def payments_table_data(data)
          payments_data = mount_payment_data(data)

          add_default_values(payments_data, data[:totals])
        end
        private_class_method :payments_table_data

        def add_default_values(payments_data, data)
          payments_data.push(['TROCO', format_currency(data[:cashback])])
          payments_data.push(['TOTAL', format_currency(data[:paid])])
        end
        private_class_method :add_default_values
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.24 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.23 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.22 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.21 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.20 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.19 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.18 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.17 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.16 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.15 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.14 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.14.alpha.23 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.13 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.13.alpha.22 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.12.alpha.21 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.12.alpha.20 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.12 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.11 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.10 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.9 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb