Skip to content

Commit

Permalink
[RFC] l10n_br_nfe: rename method _processador
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelsavegnago committed Oct 23, 2024
1 parent 110ebb6 commit fb0a93e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions l10n_br_nfe/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,9 +906,9 @@ def _serialize(self, edocs):
edocs.append(nfe)
return edocs

def _processador(self):
def _edoc_processor(self):
if not self.filtered(filter_processador_edoc_nfe):
return super()._processador()
return super()._edoc_processor()

Check warning on line 911 in l10n_br_nfe/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_nfe/models/document.py#L911

Added line #L911 was not covered by tests

self._check_nfe_environment()
certificado = self.company_id._get_br_ecertificate()
Expand Down Expand Up @@ -952,7 +952,7 @@ def _document_export(self, pretty_print=True):
result = super()._document_export()
for record in self.filtered(filter_processador_edoc_nfe):
edoc = record.serialize()[0]
processador = record._processador()
processador = record._edoc_processor()
xml_file = processador.render_edoc_xsdata(edoc, pretty_print=pretty_print)[
0
]
Expand Down Expand Up @@ -1117,7 +1117,7 @@ def _generate_key(self):

def _nfe_consult_receipt(self):
self.ensure_one()
processor = self._processador()
processor = self._edoc_processor()
# Consult receipt and process the response
rec_num = self.authorization_event_id.lot_receipt_number
receipt_process = processor.consulta_recibo(numero=rec_num)
Expand Down Expand Up @@ -1170,7 +1170,7 @@ def _nfe_create_proc(self, prot_nfe_element):
)
return None

processor = self._processador()
processor = self._edoc_processor()

# Extract the <NFe> tag from the `enviNFe` message, which represents the NF-e
nfe_send_xml = base64.b64decode(self.send_file_id.datas)
Expand Down Expand Up @@ -1209,7 +1209,7 @@ def _is_nfe_found(c_stat):
"""
return c_stat in ["100", "101", "110"]

nfe_manager = self._processador()
nfe_manager = self._edoc_processor()
check_response = nfe_manager.consulta_documento(chave=self.document_key)
status = check_response.resposta.xMotivo

Expand Down Expand Up @@ -1251,7 +1251,7 @@ def _nfe_send_for_authorization(self):
Serialize and send a NFe for authorizaion
"""
serialized_nfe = self.serialize()[0]
nfe_manager = self._processador()
nfe_manager = self._edoc_processor()
authorization_response = None
for service_response in nfe_manager.processar_documento(serialized_nfe):
if service_response.webservice not in [
Expand Down Expand Up @@ -1396,7 +1396,7 @@ def _need_compute_nfe_tags(self):

def _nfe_cancel(self):
self.ensure_one()
processador = self._processador()
processador = self._edoc_processor()

if not self.authorization_protocol:
raise UserError(_("Authorization Protocol Not Found!"))
Expand Down Expand Up @@ -1452,7 +1452,7 @@ def _document_correction(self, justificative):

def _nfe_correction(self, justificative):
self.ensure_one()
processador = self._processador()
processador = self._edoc_processor()

Check warning on line 1455 in l10n_br_nfe/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_nfe/models/document.py#L1455

Added line #L1455 was not covered by tests

numeros = self.event_ids.filtered(
lambda e: e.type == "14" and e.state == "done"
Expand Down Expand Up @@ -1512,7 +1512,7 @@ def _update_nfce_for_offline_contingency(self):
def get_nfce_qrcode(self):
if self.document_type != MODELO_FISCAL_NFCE:
return
processador = self._processador()
processador = self._edoc_processor()
if self.nfe_transmission == "1":
return processador.monta_qrcode(self.document_key)

Expand All @@ -1524,7 +1524,7 @@ def get_nfce_qrcode_url(self):
if self.document_type != MODELO_FISCAL_NFCE:
return

return self._processador().consulta_qrcode_url
return self._edoc_processor().consulta_qrcode_url

def _prepare_payments_for_nfce(self):
for rec in self.filtered(lambda d: d.document_type == MODELO_FISCAL_NFCE):
Expand Down
4 changes: 2 additions & 2 deletions l10n_br_nfe/models/invalidate_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class InvalidateNumber(models.Model):
_inherit = "l10n_br_fiscal.invalidate.number"

def _processador(self):
def _edoc_processor(self):
certificado = self.env.company._get_br_ecertificate()
session = Session()
session.verify = False
Expand All @@ -38,7 +38,7 @@ def _processador(self):
return edoc_nfe(**params)

def _invalidate(self, document_id=False):
processador = self._processador()
processador = self._edoc_processor()
evento = processador.inutilizacao(
cnpj=punctuation_rm(self.company_id.cnpj_cpf),
mod=self.document_type_id.code,
Expand Down

0 comments on commit fb0a93e

Please sign in to comment.