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.8 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.7 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb
br_invoices_pdf-0.2.6.alpha.19 lib/br_invoices_pdf/cfe/renderer/payment_forms.rb