|
1
|
1 |
|
from collections.abc import Sequence |
|
2
|
1 |
|
from datetime import datetime |
|
3
|
1 |
|
from typing import Literal |
|
4
|
|
|
|
|
5
|
1 |
|
from ..w3.signature import signature_c14n_sha1 |
|
6
|
1 |
|
from ...models import Signer |
|
7
|
1 |
|
from ...utils import ScalarMap |
|
8
|
1 |
|
from ...xelement import XElement |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
1 |
|
class Folios(ScalarMap): |
|
12
|
1 |
|
def __init__(self, respuesta: Literal["Aceptacion", "Rechazo"], uuid: str = None): |
|
13
|
|
|
""" |
|
14
|
|
|
|
|
15
|
|
|
:param respuesta: "Rechazo" o "Aceptacion" |
|
16
|
|
|
:param uuid: El UUID del documento que se desea aceptar o rechazar |
|
17
|
|
|
""" |
|
18
|
1 |
|
if respuesta not in ["Aceptacion", "Rechazo"]: |
|
19
|
|
|
msg = f'respuesta must be "Aceptacion" or "Rechazo", found {respuesta} instead' |
|
20
|
|
|
raise ValueError(msg) |
|
21
|
|
|
|
|
22
|
1 |
|
super().__init__( |
|
23
|
|
|
{ |
|
24
|
|
|
"Respuesta": respuesta, |
|
25
|
|
|
"UUID": uuid, |
|
26
|
|
|
} |
|
27
|
|
|
) |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
1 |
|
class SolicitudAceptacionRechazo(XElement): |
|
31
|
|
|
""" |
|
32
|
|
|
Elemento raíz para realizar la aceptacion o rechazo de una solicitud de cancelacion. |
|
33
|
|
|
""" |
|
34
|
1 |
|
tag = '{http://cancelacfd.sat.gob.mx}SolicitudAceptacionRechazo' |
|
35
|
|
|
|
|
36
|
1 |
|
def __init__( |
|
37
|
|
|
self, |
|
38
|
|
|
rfc_receptor: Signer = None, |
|
39
|
|
|
rfc_pac_envia_solicitud: str = None, |
|
40
|
|
|
folios: Folios | Sequence[Folios | dict] = None, |
|
41
|
|
|
fecha: datetime = None, |
|
42
|
|
|
): |
|
43
|
|
|
""" |
|
44
|
|
|
Elemento raíz para realizar la aceptacion o rechazo de una solicitud de cancelacion. |
|
45
|
|
|
|
|
46
|
|
|
:param fecha: |
|
47
|
|
|
:param rfc_receptor: |
|
48
|
|
|
:param rfc_pac_envia_solicitud: |
|
49
|
|
|
:param folios: |
|
50
|
|
|
:return: objeto CFDI |
|
51
|
|
|
""" |
|
52
|
|
|
|
|
53
|
1 |
|
super().__init__({ |
|
54
|
|
|
'Fecha': fecha or datetime.now(), |
|
55
|
|
|
'RfcReceptor': rfc_receptor.rfc, |
|
56
|
|
|
'RfcPacEnviaSolicitud': rfc_pac_envia_solicitud, |
|
57
|
|
|
'Folios': folios, |
|
58
|
|
|
}) |
|
59
|
1 |
|
self["_nsmap"] = { |
|
60
|
|
|
None: "http://cancelacfd.sat.gob.mx", |
|
61
|
|
|
"xsd": "http://www.w3.org/2001/XMLSchema", |
|
62
|
|
|
"xsi": "http://www.w3.org/2001/XMLSchema-instance" |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
1 |
|
sig = signature_c14n_sha1( |
|
66
|
|
|
signer=rfc_receptor, |
|
67
|
|
|
element=self.to_xml(), |
|
68
|
|
|
nsmap={ |
|
69
|
|
|
None: 'http://www.w3.org/2000/09/xmldsig#', |
|
70
|
|
|
"xsd": "http://www.w3.org/2001/XMLSchema", |
|
71
|
|
|
"xsi": "http://www.w3.org/2001/XMLSchema-instance", |
|
72
|
|
|
} |
|
73
|
|
|
) |
|
74
|
|
|
self['Signature'] = sig |
|
75
|
|
|
|