feat(params.pac): soporte del cron task de los cfdi's pendientes de cancelar

se sigue el mismo patron que el timbrado y la cancelacion para mandar a
llamar la funcion que consulta el estado de cancelacion de un cfdi de
los pac.
parent fd7bc845
# -*- coding: utf-8 -*-
from . import pac_answer
from . import xpd_envelopes
\ No newline at end of file
<<<<<<< HEAD
from . import xpd_envelopes
=======
from . import xpd_envelopes
from . import finkok_envelopes
>>>>>>> 63a507f... feat:
......@@ -2,13 +2,14 @@
# Lista con los mensajes de respuesta de cancelacion pendiente de los PAC
wait_cancel = [
'En proceso', # Finkok
'En proceso', # Finkok, xpd
'211', # Solucion factible
]
negation_cancel = [
'no_cancelable', # Finkok
'213', # Solucion factible
"no_cancelable", # Finkok
"213", # Solucion factible
"vigente," # xpd'
]
class PacAnswer(object):
......@@ -32,8 +33,16 @@ class PacCancelAnswer(PacAnswer):
cancelacion = True
return cancelacion
class PacConsultAnswer(PacAnswer):
class PacConsultAnswer(PacCancelAnswer):
"""This class is use to homogenize the PAC's consult answer"""
def __init__(self, uuid, estatus, estatus_cancelacion):
PacAnswer.__init__(self, uuid, estatus)
self.estatus_cancelacion = estatus_cancelacion
\ No newline at end of file
PacCancelAnswer.__init__(self, uuid, estatus, estatus_cancelacion)
def check_cancel_status(self):
if self.estatus in wait_cancel:
cancelacion = None
elif self.estatus in negation_cancel:
cancelacion = False
else:
cancelacion = True
return cancelacion
\ No newline at end of file
......@@ -16,16 +16,18 @@ class ParamsPac(models.Model):
_name = "params.pac"
_order = "sequence ASC"
def get_driver_fc_sign(self):
@classmethod
def get_driver_fc_sign(cls):
"""function to inherit from custom PAC module"""
return {}
def get_driver_fc_cancel(self):
@classmethod
def get_driver_fc_cancel(cls):
"""function to inherit from custom PAC module"""
return {}
@api.multi
def _get_pac_type(self):
@classmethod
def _get_pac_type(cls):
# From module of PAC inherit this function and add new available PAC
types = []
return types
......@@ -153,14 +155,7 @@ class ParamsPac(models.Model):
@param data (string): data to sign in base64 encoding
@return: Dictionary
"""
if not len(self):
raise ValidationError(
_(
"No PAC have being selected.\nGo to Configuration "
">> Accounting >> Electronic invoicing (MX) and select "
"a PAC."
)
)
self.check_pacs()
result = self.fire_connection(data, "get_driver_fc_sign")
return result
......@@ -171,16 +166,32 @@ class ParamsPac(models.Model):
Both connect to PAC, if PAC fails code messages are the same
and so on.
@param self : All possible PACs to be used
@param uuid: uuid of cfdi to cancel
@return: Return true if the cfdi can be canceled or false if it must wait
to be canceled
:param self : All possible PACs to be used
:param uuid: uuid of cfdi to cancel
:type uuid: string
:return: Return true if the cfdi can be canceled, false if it can't be canceled
and None if must wait to cancel
"""
self.check_pacs()
cancel_estatus = self.fire_connection(uuid, "get_driver_fc_cancel")
return cancel_estatus.check_cancel_status()
@api.multi
def consult_cfdi_cancellation_status(self, uuid):
"""Connect to PAC to consult cfdi cancel status
:param uuid: uuid to consult
:type uuid: string
"""
self.check_pacs()
consult_estatus = self.fire_connection(uuid, "get_driver_fc_consult")
return consult_estatus.check_cancel_status()
@api.multi
def check_pacs(self):
"""Verify if there are pacs selected"""
if not len(self):
raise ValidationError(
_("No PAC have being selected.\nGo to Configuration "
">> Accounting >> Electronic invoicing (MX) and select "
"a PAC."),
)
cancel_estatus = self.fire_connection(uuid, "get_driver_fc_cancel")
return cancel_estatus.check_cancel_status()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment