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

Criação de transferência em lotes pelo PIX #54

Open
wants to merge 142 commits into
base: main
Choose a base branch
from
Open

Criação de transferência em lotes pelo PIX #54

wants to merge 142 commits into from

Conversation

peidrao
Copy link
Contributor

@peidrao peidrao commented Apr 20, 2023

Resumo

Relacionado aos issues/prs:

Este PR adiciona a função de transferência em lote via pix

As novas ações permitem fazer a transferência por todos os meios (chave, email, documento, dados bancários)

Alterações de models

  • Sim
  • Não

Alterações de services

  • Sim
  • Não

Alterações de wrappers

  • Sim
  • Não
  • Foram adicionados dois novos wrappers um para criação de transferência via chave, documento cpf/cnpj (criar_transferencia_por_chave_pix) e outro para dados bancários (criar_transferencia_por_dados_bancarios_pix)

@peidrao
Copy link
Contributor Author

peidrao commented Apr 20, 2023

Sera preciso criar exemplos para todos os casos? E-mail, chave aleatória, telefone e CPF/CNPJ

@codecov
Copy link

codecov bot commented Apr 20, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (f048de5) 89.26% compared to head (a81a5b3) 91.45%.
Report is 1 commits behind head on main.

❗ Current head a81a5b3 differs from pull request most recent head 45f0277. Consider uploading reports for the commit 45f0277 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #54      +/-   ##
==========================================
+ Coverage   89.26%   91.45%   +2.18%     
==========================================
  Files          23       24       +1     
  Lines        1062     1158      +96     
==========================================
+ Hits          948     1059     +111     
+ Misses        114       99      -15     
Files Coverage Δ
bb_wrapper/services/document.py 100.00% <100.00%> (+16.66%) ⬆️
bb_wrapper/services/pix.py 97.22% <100.00%> (ø)
bb_wrapper/wrapper/pagamento_lote.py 96.15% <100.00%> (+0.87%) ⬆️
bb_wrapper/wrapper/pix_cob.py 52.54% <ø> (ø)
bb_wrapper/models/pagamentos.py 97.56% <93.75%> (+16.87%) ⬆️
Files Coverage Δ
bb_wrapper/services/document.py 100.00% <100.00%> (+16.66%) ⬆️
bb_wrapper/services/pix.py 97.22% <100.00%> (ø)
bb_wrapper/wrapper/pagamento_lote.py 96.15% <100.00%> (+0.87%) ⬆️
bb_wrapper/wrapper/pix_cob.py 52.54% <ø> (ø)
bb_wrapper/models/pagamentos.py 97.56% <93.75%> (+16.87%) ⬆️

Copy link
Contributor

@brenomfviana brenomfviana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Faltou rodar make fmt, faz também testes com os outros tipos de chaves.

bb_wrapper/wrapper/pagamento_lote.py Show resolved Hide resolved
bb_wrapper/wrapper/pagamento_lote.py Outdated Show resolved Hide resolved
tests/wrapper/test_pagamentos.py Outdated Show resolved Hide resolved
tests/wrapper/test_pagamentos.py Show resolved Hide resolved
tests/wrapper/test_pagamentos.py Outdated Show resolved Hide resolved
tests/wrapper/test_pagamentos.py Outdated Show resolved Hide resolved
@peidrao
Copy link
Contributor Author

peidrao commented Apr 20, 2023

Seria preciso criar algum modelo?

@brenomfviana brenomfviana self-requested a review April 20, 2023 19:10
@brenomfviana
Copy link
Contributor

Modelo de quê?

@peidrao
Copy link
Contributor Author

peidrao commented Apr 20, 2023

Modelo de quê?

Na tarefa do clickup fala sobre criação de modelos e services, mas imagino que não seja necessário.

@peidrao peidrao closed this Apr 20, 2023
@peidrao peidrao reopened this Apr 20, 2023
@brenomfviana
Copy link
Contributor

Na tarefa do clickup fala sobre criação de modelos e services, mas imagino que não seja necessário.

Acho que não é necessário criar pra lib funcionar, mas é legal ter.

Copy link
Member

@rodrigondec rodrigondec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alguns detalhes sobre os argumentos e simplificações mais inteligentes

bb_wrapper/wrapper/pagamento_lote.py Outdated Show resolved Hide resolved
bb_wrapper/wrapper/pagamento_lote.py Outdated Show resolved Hide resolved
bb_wrapper/wrapper/pagamento_lote.py Outdated Show resolved Hide resolved
bb_wrapper/wrapper/pagamento_lote.py Outdated Show resolved Hide resolved
bb_wrapper/models/pagamentos.py Show resolved Hide resolved
bb_wrapper/models/pagamentos.py Outdated Show resolved Hide resolved
bb_wrapper/models/pagamentos.py Outdated Show resolved Hide resolved
Comment on lines 73 to 74
cpf: Optional[str]
cnpj: Optional[str]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

se não me engano tem que ser int mesmo!

Sim, a API BB é horrível nesse nível. Precisa transformar em int mesmo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ainda está como "str"!

bb_wrapper/models/pagamentos.py Outdated Show resolved Hide resolved
bb_wrapper/models/pagamentos.py Outdated Show resolved Hide resolved
bb_wrapper/models/pagamentos.py Outdated Show resolved Hide resolved
bb_wrapper/models/pagamentos.py Outdated Show resolved Hide resolved
bb_wrapper/models/pagamentos.py Outdated Show resolved Hide resolved
bb_wrapper/wrapper/pagamento_lote.py Outdated Show resolved Hide resolved
Sugestões feitas por rodrigo

Co-authored-by: Rodrigo Castro <[email protected]>
@peidrao peidrao requested a review from rodrigondec January 31, 2024 01:41
Comment on lines 73 to 74
cpf: Optional[str]
cnpj: Optional[str]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ainda está como "str"!

bb_wrapper/models/pagamentos.py Outdated Show resolved Hide resolved
bb_wrapper/models/pagamentos.py Outdated Show resolved Hide resolved
tests/wrapper/test_pagamentos.py Outdated Show resolved Hide resolved
tests/wrapper/test_pagamentos.py Outdated Show resolved Hide resolved
Copy link
Member

@rodrigondec rodrigondec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O envio do PIX por dados bancários

Não deveria mandar o valor "cnpj" com dados vazio! Deveria enviar apenas um ou outro, e não os dois.

Rodei o exemplo com python -m examples.lotes_pagamento.transferencia_pix_dados_bancarios

DEBUG:urllib3.connectionpool:https://api.sandbox.bb.com.br:443 "POST /pagamentos-lote/v1/lotes-transferencias-pix?gw-dev-app-key=d27b377907ffabd01369e17df0050056b9f1a5b9 HTTP/1.1" 200 699
DEBUG:bb_wrapper.requests:response.request.body=b'{"numeroRequisicao": 9499946, "agenciaDebito": 1607, "contaCorrenteDebito": 99738672, "digitoVerificadorContaCorrente": "X", "tipoPagamento": 128, "listaTransferencias": [{"data": 1022024, "valor": 15.5, "tipoConta": 1, "agencia": 1234, "conta": 12345, "digitoVerificadorConta": "X", "formaIdentificacao": 5, "descricaoPagamento": "Uma transfer\\u00eancia via dados banc\\u00e1rios", "cpf": 28779295827, "cnpj": null, "numeroISPB": 360305}]}'


DEBUG:bb_wrapper.requests:{'numeroRequisicao': 9499946, 'estadoRequisicao': 1, 'quantidadeTransferencias': 1, 'valorTransferencias': 15.5, 'quantidadeTransferenciasValidas': 1, 'valorTransferenciasValidas': 15.5, 'listaTransferencias': [{'identificadorPagamento': 99499946731030000, 'data': 1022024, 'valor': 15.5, 'documentoDebito': 0, 'documentoCredito': 0, 'descricaoPagamento': 'Uma transferýncia via dados bancýrios', 'descricaoPagamentoInstantaneo': '', 'formaIdentificacao': 5, 'dddTelefone': 0, 'telefone': 0, 'email': '', 'cpf': 28779295827, 'cnpj': 0, 'identificacaoAleatoria': '', 'numeroCOMPE': 0, 'numeroISPB': 360305, 'tipoConta': 1, 'agencia': 1234, 'conta': 12345, 'digitoVerificadorConta': 'X', 'contaPagamento': '', 'indicadorMovimentoAceito': 'S', 'erros': []}]}

Copy link
Member

@rodrigondec rodrigondec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PIX por chave

Estão sendo enviados todos os outros campos de chave como vazios também. "email", "cnpj", "identificacaoAleatoria", "telefone" + "dddTelefone"...

rodei com python -m examples.lotes_pagamento.transferencia_pix_cpf

DEBUG:bb_wrapper.requests:response.request.body=b'{"numeroRequisicao": 9499944, "agenciaDebito": 1607, "contaCorrenteDebito": 99738672, "digitoVerificadorContaCorrente": "X", "tipoPagamento": 128, "listaTransferencias": [{"data": 1022024, "valor": 7999.99, "formaIdentificacao": 3, "descricaoPagamento": "transferencia CPF", "dddTelefone": null, "telefone": null, "email": null, "cpf": 28779295827, "cnpj": null, "identificacaoAleatoria": null}]}'


DEBUG:bb_wrapper.requests:{'numeroRequisicao': 9499944, 'estadoRequisicao': 1, 'quantidadeTransferencias': 1, 'valorTransferencias': 7999.99, 'quantidadeTransferenciasValidas': 1, 'valorTransferenciasValidas': 7999.99, 'listaTransferencias': [{'identificadorPagamento': 99499944731030000, 'data': 1022024, 'valor': 7999.99, 'documentoDebito': 0, 'documentoCredito': 0, 'descricaoPagamento': 'transferencia CPF', 'descricaoPagamentoInstantaneo': '', 'formaIdentificacao': 3, 'dddTelefone': 0, 'telefone': 0, 'email': '', 'cpf': 28779295827, 'cnpj': 0, 'identificacaoAleatoria': '', 'numeroCOMPE': 0, 'numeroISPB': 0, 'tipoConta': 0, 'agencia': 0, 'conta': 0, 'digitoVerificadorConta': '', 'contaPagamento': '', 'indicadorMovimentoAceito': 'S', 'erros': []}]}

@peidrao peidrao requested a review from rodrigondec February 1, 2024 20:33
PixService().remove_null_values(values)
if "cnpj" not in values and "cpf" not in values:
raise ValueError("É necessário inserir o CNPj ou CPF")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise ValueError("É necessário inserir o CNPj ou CPF")
raise ValueError("É necessário inserir o CNPJ ou CPF")

Comment on lines +607 to +608
from bb_wrapper.services.document import DocumentoService, TipoInscricaoEnum
tipo_documento = DocumentoService().identifica_tipo(documento_favorecido)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt

Comment on lines +237 to +239
):

expected = {"cnpj": 3794722000153}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
):
expected = {"cnpj": 3794722000153}
):
expected = {"cnpj": 3794722000153}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants