Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the list of payment types #218

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,19 @@ pt-BR:
'02': "Cheque"
'03': "Cartão de Crédito"
'04': "Cartão de Débito"
'05': "Crédito Loja"
'05': "Cartão da Loja (Private Label), Crediário Digital, Outros Crediários"
'10': "Vale Alimentação"
'11': "Vale Refeição"
'12': "Vale Presente"
'13': "Vale Combustível"
'14': "Duplicata Mercanti"
'14': "Duplicata Mercantil"
'15': "Boleto Bancário"
'16': "Depósito Bancário"
'17': "Pagamento Instantâneo (PIX)"
'17': "Pagamento Instantâneo (PIX) - Dinâmico"
'18': "Transferência bancária, Carteira Digital"
'19': "Programa de fidelidade, Cashback, Crédito Virtual"
'20': "Pagamento Instantâneo (PIX) - Estático"
'21': "Crédito em Loja"
'22': "Pagamento Eletrônico não Informado - falha de hardware do sistema emissor"
'90': "Sem Pagamento"
'99': "Outros"
14 changes: 13 additions & 1 deletion lib/br_danfe/danfe_lib/nfce_lib/total_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def totals
print_text(BrDanfe::Helper.numerify(@xml['ICMSTot > vNF'].to_f), cursor, size: 10, align: :right, style: :bold)
end

# rubocop:disable Metrics/MethodLength
def payment_methods
payments = {}
without_payment = '90'
Expand All @@ -65,17 +66,28 @@ def payment_methods

payments.each do |key, value|
cursor = @pdf.cursor
print_text(I18n.t("nfce.payment_methods.#{key}"), cursor, size: 9, align: :left)

payment_description = prepare_payment_description(I18n.t("nfce.payment_methods.#{key}"))
print_text(payment_description, cursor, size: 9, align: :left)
print_text(BrDanfe::Helper.numerify(value.to_f), cursor, size: 9, align: :right)
end
end
end
# rubocop:enable Metrics/MethodLength

def print_text(text, cursor, options)
@pdf.bounding_box [0, cursor], width: 6.7.cm, height: 0.35.cm do
@pdf.text text, options
end
end

def prepare_payment_description(description)
maximum_size_for_description = 40

return "#{description[0..maximum_size_for_description - 3]}..." if description.length > maximum_size_for_description

description
end
end
end
end
Expand Down
Binary file modified spec/fixtures/nfce/lib/total_list#render-without_payment.pdf
Binary file not shown.
Binary file modified spec/fixtures/nfce/lib/total_list#render.pdf
Binary file not shown.
Binary file modified spec/fixtures/nfce/v4.00/multiples_xmls_on_the_same_pdf.pdf
Binary file not shown.
Binary file modified spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf
Binary file not shown.
Binary file modified spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf
Binary file not shown.
Binary file modified spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf
Binary file not shown.
Binary file modified spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf
Binary file not shown.
Loading