Module: BrInvoicesPdf::Nfce::Renderer::PaymentForms
- Extended by:
- BaseRenderer, Util::BaseRenderer
- Defined in:
- lib/br_invoices_pdf/nfce/renderer/payment_forms.rb
Constant Summary collapse
- PAYMENTS_TABLE_BASE_DATA =
[['FORMA DE PAGAMENTO', 'VALOR']].freeze
- PAYMENTS_TABLE_BASE_DATA_WITH_CASHBACK =
[['FORMA DE PAGAMENTO', 'VALOR', 'TROCO']].freeze
Constants included from Util::BaseRenderer
Util::BaseRenderer::CNPJ_FORMAT, Util::BaseRenderer::CPF_FORMAT
Constants included from BaseRenderer
Class Method Summary collapse
- .cashback?(data) ⇒ Boolean
- .choose_table_data(data) ⇒ Object
- .execute(pdf, data) ⇒ Object
-
.payments_table_data_with_cashback(data) ⇒ Object
:reek:FeatureEnvy.
Methods included from Util::BaseRenderer
box, format_cnpj, format_cpf, format_currency, format_number, page_content_width, page_paper_width, pdf_setup
Methods included from BaseRenderer
Class Method Details
.cashback?(data) ⇒ Boolean
20 21 22 |
# File 'lib/br_invoices_pdf/nfce/renderer/payment_forms.rb', line 20 def cashback?(data) !data[:payments].map { |payment| payment[:cashback] }.compact.empty? end |
.choose_table_data(data) ⇒ Object
16 17 18 |
# File 'lib/br_invoices_pdf/nfce/renderer/payment_forms.rb', line 16 def choose_table_data(data) cashback?(data) ? payments_table_data_with_cashback(data) : payments_table_data(data) end |
.execute(pdf, data) ⇒ Object
12 13 14 |
# File 'lib/br_invoices_pdf/nfce/renderer/payment_forms.rb', line 12 def execute(pdf, data) execute_payment_form(pdf, choose_table_data(data)) end |
.payments_table_data_with_cashback(data) ⇒ Object
:reek:FeatureEnvy
51 52 53 54 55 56 57 |
# File 'lib/br_invoices_pdf/nfce/renderer/payment_forms.rb', line 51 def payments_table_data_with_cashback(data) payments_data = data[:payments].reduce(PAYMENTS_TABLE_BASE_DATA_WITH_CASHBACK) do |result, cur| result + [[cur[:type], format_currency(cur[:amount]), cur[:cashback]]] end add_default_values(payments_data, data) end |