spei-python 0.53.1__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {spei_python-0.53.1 → spei_python-1.0.0}/PKG-INFO +1 -1
- {spei_python-0.53.1 → spei_python-1.0.0}/pyproject.toml +2 -2
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/checksum/generator.py +18 -18
- spei_python-1.0.0/spei/errors/__init__.py +3 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/errors/spei.py +39 -8
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/requests/cda.py +1 -3
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/resources/acuse.py +10 -16
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/resources/cda.py +12 -11
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/resources/ensesion.py +2 -2
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/resources/mensaje.py +2 -4
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/resources/orden.py +46 -30
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/resources/payments.py +26 -25
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/resources/respuesta.py +10 -10
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/types/__init__.py +13 -13
- spei_python-1.0.0/spei/types/common.py +41 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/types/spei.py +2 -7
- spei_python-0.53.1/spei/errors/__init__.py +0 -3
- spei_python-0.53.1/spei/validators.py +0 -30
- {spei_python-0.53.1 → spei_python-1.0.0}/README.md +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/README.md +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/__init__.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/cep_generator.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/checksum/__init__.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/checksum/factory.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/checksum/types.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/client.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/errors/sice.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/exceptions.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/mappings.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/requests/__init__.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/requests/acuse.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/requests/orden.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/requests/respuesta.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/resources/__init__.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/resources/validators.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/responses/__init__.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/responses/acuse.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/responses/orden.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/responses/respuesta.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/sice.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/types/sice.py +0 -0
- {spei_python-0.53.1 → spei_python-1.0.0}/spei/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "spei-python"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "1.0.0"
|
|
4
4
|
description = ""
|
|
5
5
|
authors = ["tech <tech@fondeadora.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -32,7 +32,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
32
32
|
|
|
33
33
|
[tool.commitizen]
|
|
34
34
|
name = "cz_conventional_commits"
|
|
35
|
-
version = "0.
|
|
35
|
+
version = "1.0.0"
|
|
36
36
|
tag_format = "v$version"
|
|
37
37
|
bump_message = "bump: Semantic Release Bot: Release Version: $new_version 🤖🚀 [skip ci]"
|
|
38
38
|
version_files = [
|
|
@@ -70,8 +70,8 @@ class ChecksumGeneratorRemittance(ChecksumGenerator):
|
|
|
70
70
|
def format_data(self, orden: Orden):
|
|
71
71
|
message_data = (
|
|
72
72
|
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
73
|
-
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
74
|
-
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
73
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ord)),
|
|
74
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ben)),
|
|
75
75
|
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
76
76
|
self._monto_to_bytearray(orden.op_monto),
|
|
77
77
|
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
@@ -85,8 +85,8 @@ class ChecksumGeneratorDefault(ChecksumGenerator):
|
|
|
85
85
|
def format_data(self, orden: Orden):
|
|
86
86
|
message_data = (
|
|
87
87
|
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
88
|
-
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
89
|
-
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
88
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ord)),
|
|
89
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ben)),
|
|
90
90
|
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
91
91
|
self._monto_to_bytearray(orden.op_monto),
|
|
92
92
|
)
|
|
@@ -97,8 +97,8 @@ class ChecksumGeneratorOrigin(ChecksumGenerator):
|
|
|
97
97
|
def format_data(self, orden: Orden):
|
|
98
98
|
message_data = (
|
|
99
99
|
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
100
|
-
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
101
|
-
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
100
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ord)),
|
|
101
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ben)),
|
|
102
102
|
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
103
103
|
self._monto_to_bytearray(orden.op_monto),
|
|
104
104
|
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
@@ -110,8 +110,8 @@ class ChecksumGeneratorBeneficiary(ChecksumGenerator):
|
|
|
110
110
|
def format_data(self, orden: Orden):
|
|
111
111
|
message_data = (
|
|
112
112
|
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
113
|
-
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
114
|
-
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
113
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ord)),
|
|
114
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ben)),
|
|
115
115
|
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
116
116
|
self._monto_to_bytearray(orden.op_monto),
|
|
117
117
|
self._to_byte_array(orden.op_cuenta_ben, add_zero_byte=True),
|
|
@@ -123,8 +123,8 @@ class ChecksumGeneratorOriginAndBeneficiary(ChecksumGenerator):
|
|
|
123
123
|
def format_data(self, orden: Orden):
|
|
124
124
|
message_data = (
|
|
125
125
|
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
126
|
-
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
127
|
-
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
126
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ord)),
|
|
127
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ben)),
|
|
128
128
|
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
129
129
|
self._monto_to_bytearray(orden.op_monto),
|
|
130
130
|
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
@@ -137,8 +137,8 @@ class ChecksumGeneratorBeneficiaryAndAdditionalBeneficiary(ChecksumGenerator):
|
|
|
137
137
|
def format_data(self, orden: Orden):
|
|
138
138
|
message_data = (
|
|
139
139
|
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
140
|
-
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
141
|
-
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
140
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ord)),
|
|
141
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ben)),
|
|
142
142
|
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
143
143
|
self._monto_to_bytearray(orden.op_monto),
|
|
144
144
|
self._to_byte_array(orden.op_cuenta_ben, add_zero_byte=True),
|
|
@@ -151,8 +151,8 @@ class ChecksumGeneratorIndirectToParticipant(ChecksumGenerator):
|
|
|
151
151
|
def format_data(self, orden: Orden):
|
|
152
152
|
message_data = (
|
|
153
153
|
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
154
|
-
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
155
|
-
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
154
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ord)),
|
|
155
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ben)),
|
|
156
156
|
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
157
157
|
self._monto_to_bytearray(orden.op_monto),
|
|
158
158
|
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
@@ -165,8 +165,8 @@ class ChecksumGeneratorIndirect(ChecksumGenerator):
|
|
|
165
165
|
def format_data(self, orden: Orden):
|
|
166
166
|
message_data = (
|
|
167
167
|
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
168
|
-
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
169
|
-
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
168
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ord)),
|
|
169
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ben)),
|
|
170
170
|
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
171
171
|
self._monto_to_bytearray(orden.op_monto),
|
|
172
172
|
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
@@ -180,8 +180,8 @@ class ChecksumGeneratorEveryField(ChecksumGenerator):
|
|
|
180
180
|
def format_data(self, orden: Orden):
|
|
181
181
|
message_data = (
|
|
182
182
|
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
183
|
-
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
184
|
-
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
183
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ord)),
|
|
184
|
+
self._clave_to_bytearray(str(orden.op_ins_clave_ben)),
|
|
185
185
|
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
186
186
|
self._monto_to_bytearray(orden.op_monto),
|
|
187
187
|
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from enum import Enum
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import Dict, Optional
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class GenericoCodigoError(str, Enum):
|
|
@@ -445,10 +445,41 @@ ERROR_CODES = (
|
|
|
445
445
|
)
|
|
446
446
|
|
|
447
447
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
448
|
+
# Generate all members for CodigoError
|
|
449
|
+
_members = {}
|
|
450
|
+
for error_enum in ERROR_CODES:
|
|
451
|
+
_members.update(
|
|
452
|
+
{name: member.value for name, member in error_enum.__members__.items()},
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
class CodigoError(str, Enum):
|
|
457
|
+
"""Unified error codes enum that combines all SPEI error codes.
|
|
458
|
+
|
|
459
|
+
This implementation provides better type hints and is more
|
|
460
|
+
maintainable.
|
|
461
|
+
"""
|
|
462
|
+
|
|
463
|
+
# Add all enum members
|
|
464
|
+
locals().update(_members) # noqa: WPS421, WPS604
|
|
465
|
+
|
|
466
|
+
@classmethod
|
|
467
|
+
def get_all_errors(cls) -> Dict[str, int]:
|
|
468
|
+
"""Returns a dictionary of all error codes and their values."""
|
|
469
|
+
return {name: member.value for name, member in cls.__members__.items()}
|
|
470
|
+
|
|
471
|
+
@classmethod
|
|
472
|
+
def get_error_by_value(cls, value: int) -> Optional[str]: # noqa: WPS110
|
|
473
|
+
"""Get error name by its value."""
|
|
474
|
+
for member in cls.__members__.values():
|
|
475
|
+
if member.value == value:
|
|
476
|
+
return member.name
|
|
477
|
+
return None
|
|
478
|
+
|
|
479
|
+
@classmethod
|
|
480
|
+
def get_error_by_name(cls, name: str) -> Optional[int]:
|
|
481
|
+
"""Get error value by its name."""
|
|
482
|
+
try:
|
|
483
|
+
return cls[name].value
|
|
484
|
+
except KeyError:
|
|
485
|
+
return None
|
|
@@ -45,7 +45,5 @@ class CDARequest(object):
|
|
|
45
45
|
return self._envelope
|
|
46
46
|
|
|
47
47
|
def to_string(self) -> bytes:
|
|
48
|
-
"""
|
|
49
|
-
Returns the SOAP request as a string encoded in cp850 (bytes).
|
|
50
|
-
"""
|
|
48
|
+
"""Returns the SOAP request as a string encoded in cp850 (bytes)."""
|
|
51
49
|
return etree.tostring(self._envelope, encoding='cp850', xml_declaration=True)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Any, Optional, Union
|
|
2
2
|
|
|
3
3
|
from lxml import etree
|
|
4
|
-
from pydantic
|
|
4
|
+
from pydantic import BaseModel, ConfigDict
|
|
5
5
|
|
|
6
6
|
from spei.errors.sice import CodigoErrorAcuseBanxico, CodigoErrorAcuseServidor
|
|
7
7
|
from spei.types.sice import CodigoRespuestaAcuse, TipoRespuestaAcuse
|
|
@@ -11,22 +11,18 @@ from spei.utils import to_snake_case # noqa: WPS347
|
|
|
11
11
|
class ResultadoBanxico(BaseModel):
|
|
12
12
|
codigo: Optional[CodigoErrorAcuseBanxico] = None
|
|
13
13
|
descripcion: str = 'ND'
|
|
14
|
-
|
|
15
|
-
class Config: # noqa: WPS306, WPS431
|
|
16
|
-
use_enum_values = True
|
|
14
|
+
model_config = ConfigDict(use_enum_values=True)
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
class ResultadoServidor(BaseModel):
|
|
20
18
|
codigo: Union[CodigoErrorAcuseServidor, CodigoRespuestaAcuse]
|
|
21
19
|
descripcion: str = 'ND'
|
|
22
|
-
|
|
23
|
-
class Config: # noqa: WPS306, WPS431
|
|
24
|
-
use_enum_values = True
|
|
20
|
+
model_config = ConfigDict(use_enum_values=True)
|
|
25
21
|
|
|
26
22
|
|
|
27
23
|
class MensajeRespuesta(BaseModel):
|
|
28
24
|
tipo_respuesta: TipoRespuestaAcuse
|
|
29
|
-
respuesta: Any
|
|
25
|
+
respuesta: Any = None
|
|
30
26
|
|
|
31
27
|
@classmethod
|
|
32
28
|
def parse_xml(cls, mensaje):
|
|
@@ -57,14 +53,12 @@ class MensajeRespuesta(BaseModel):
|
|
|
57
53
|
|
|
58
54
|
|
|
59
55
|
class Acuse(BaseModel):
|
|
60
|
-
cda_id:
|
|
56
|
+
cda_id: int
|
|
61
57
|
mensaje_id: Any = None
|
|
62
58
|
tipo_respuesta: TipoRespuestaAcuse
|
|
63
59
|
resultado_enlace_cep: ResultadoServidor
|
|
64
60
|
resultado_banxico: Optional[ResultadoBanxico] = None
|
|
65
|
-
|
|
66
|
-
class Config: # noqa: WPS306, WPS431
|
|
67
|
-
use_enum_values = True
|
|
61
|
+
model_config = ConfigDict(use_enum_values=True)
|
|
68
62
|
|
|
69
63
|
@classmethod
|
|
70
64
|
def parse_synchronous_xml(cls, mensaje_element):
|
|
@@ -90,13 +84,13 @@ class Acuse(BaseModel):
|
|
|
90
84
|
if self.mensaje_id:
|
|
91
85
|
acuse = etree.Element(
|
|
92
86
|
'acuse',
|
|
93
|
-
idCda=self.cda_id,
|
|
94
|
-
idMensaje=self.mensaje_id,
|
|
87
|
+
idCda=str(self.cda_id),
|
|
88
|
+
idMensaje=str(self.mensaje_id),
|
|
95
89
|
)
|
|
96
90
|
else:
|
|
97
91
|
acuse = etree.Element(
|
|
98
92
|
'acuse',
|
|
99
|
-
idCda=self.cda_id,
|
|
93
|
+
idCda=str(self.cda_id),
|
|
100
94
|
)
|
|
101
95
|
|
|
102
96
|
etree.SubElement(
|
|
@@ -165,7 +159,7 @@ class Acuse(BaseModel):
|
|
|
165
159
|
if tag == 'resultado_banxico':
|
|
166
160
|
cda_data[tag] = ResultadoBanxico(**banxico_data)
|
|
167
161
|
continue
|
|
168
|
-
if tag in cls.
|
|
162
|
+
if tag in cls.model_fields:
|
|
169
163
|
cda_data[tag] = element.text
|
|
170
164
|
|
|
171
165
|
return cls(**cda_data)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
|
|
3
3
|
from lxml import etree
|
|
4
|
-
from pydantic
|
|
4
|
+
from pydantic import BaseModel, ConfigDict
|
|
5
5
|
|
|
6
6
|
from spei import types
|
|
7
|
+
from spei.types.common import DateInt, InstitutionCode
|
|
7
8
|
from spei.utils import to_pascal_case, to_snake_case # noqa: WPS347
|
|
8
9
|
|
|
9
10
|
SOAP_NS = 'http://schemas.xmlsoap.org/soap/envelope/'
|
|
@@ -12,18 +13,20 @@ ENVIO_PRAXIS_NS = 'http://www.praxis.com.mx/EnvioCda/'
|
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class CDA(BaseModel):
|
|
16
|
+
model_config = ConfigDict(strict=False, coerce_numbers_to_str=True)
|
|
17
|
+
|
|
15
18
|
id: int
|
|
16
19
|
mensaje_id: int
|
|
17
|
-
op_fecha_oper:
|
|
18
|
-
op_fecha_abono:
|
|
19
|
-
op_hora_abono:
|
|
20
|
+
op_fecha_oper: DateInt
|
|
21
|
+
op_fecha_abono: DateInt
|
|
22
|
+
op_hora_abono: int
|
|
20
23
|
|
|
21
24
|
op_cve_rastreo: str
|
|
22
25
|
|
|
23
26
|
op_folio_orig_odp: int
|
|
24
27
|
op_folio_orig_paq: int
|
|
25
28
|
|
|
26
|
-
op_clave_emisor:
|
|
29
|
+
op_clave_emisor: InstitutionCode
|
|
27
30
|
op_nombre_emisor: str
|
|
28
31
|
|
|
29
32
|
op_tipo_pag: types.TipoPagoOrdenPago
|
|
@@ -46,7 +49,7 @@ class CDA(BaseModel):
|
|
|
46
49
|
op_rfc_curp_ben: Optional[str] = None
|
|
47
50
|
|
|
48
51
|
op_iva: Optional[str] = None
|
|
49
|
-
op_hora_00: Optional[
|
|
52
|
+
op_hora_00: Optional[int] = None
|
|
50
53
|
|
|
51
54
|
op_nom_part_indirecto_ord: Optional[str] = None
|
|
52
55
|
op_cta_part_indirecto_ord: Optional[str] = None
|
|
@@ -64,9 +67,7 @@ class CDA(BaseModel):
|
|
|
64
67
|
op_rfc_curp_ben_rem: Optional[str] = None
|
|
65
68
|
op_nom_prov_rem_ext: Optional[str] = None
|
|
66
69
|
op_nom_prov_rem_nac: Optional[str] = None
|
|
67
|
-
|
|
68
|
-
class Config: # noqa: WPS306, WPS431
|
|
69
|
-
use_enum_values = True
|
|
70
|
+
model_config = ConfigDict(use_enum_values=True)
|
|
70
71
|
|
|
71
72
|
def build_xml(self) -> etree._Element: # noqa: WPS437
|
|
72
73
|
mensaje = etree.Element(
|
|
@@ -79,7 +80,7 @@ class CDA(BaseModel):
|
|
|
79
80
|
elements = self.dict(exclude_none=True, exclude={'id', 'mensaje_id'})
|
|
80
81
|
|
|
81
82
|
for element, value in elements.items(): # noqa: WPS110
|
|
82
|
-
if element in self.
|
|
83
|
+
if element in self.model_fields:
|
|
83
84
|
upper_camel_case_element = to_pascal_case(element)
|
|
84
85
|
subelement = etree.SubElement(
|
|
85
86
|
mensaje,
|
|
@@ -101,7 +102,7 @@ class CDA(BaseModel):
|
|
|
101
102
|
|
|
102
103
|
for element in datos_cta.getchildren():
|
|
103
104
|
tag = to_snake_case(element.tag)
|
|
104
|
-
if tag in cls.
|
|
105
|
+
if tag in cls.model_fields:
|
|
105
106
|
cda_data[tag] = element.text
|
|
106
107
|
|
|
107
108
|
return cls(**cda_data)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from typing import List
|
|
2
2
|
|
|
3
|
-
from pydantic
|
|
3
|
+
from pydantic import BaseModel
|
|
4
4
|
|
|
5
5
|
from spei import types
|
|
6
6
|
from spei.utils import to_snake_case # noqa: WPS347
|
|
@@ -44,7 +44,7 @@ class Ensesion(BaseModel):
|
|
|
44
44
|
institucion = Institucion.parse_xml(institucion_info)
|
|
45
45
|
ensesion_data['inst_bancarias'].append(institucion)
|
|
46
46
|
continue
|
|
47
|
-
if tag in cls.
|
|
47
|
+
if tag in cls.model_fields:
|
|
48
48
|
ensesion_data[tag] = element.text
|
|
49
49
|
|
|
50
50
|
return cls(**ensesion_data)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Any, Optional
|
|
2
2
|
|
|
3
3
|
from lxml import etree
|
|
4
|
-
from pydantic
|
|
4
|
+
from pydantic import BaseModel, ConfigDict
|
|
5
5
|
|
|
6
6
|
from spei.types import CategoriaOrdenPago
|
|
7
7
|
|
|
@@ -11,9 +11,7 @@ class Mensaje(BaseModel):
|
|
|
11
11
|
ordenpago: Optional[Any] = None
|
|
12
12
|
respuesta: Optional[Any] = None
|
|
13
13
|
ensesion: Optional[Any] = None
|
|
14
|
-
|
|
15
|
-
class Config: # noqa: WPS306, WPS431
|
|
16
|
-
extra = Extra.allow
|
|
14
|
+
model_config = ConfigDict(extra='allow')
|
|
17
15
|
|
|
18
16
|
@classmethod
|
|
19
17
|
def parse_xml(cls, mensaje: bytes): # noqa: WPS210
|
|
@@ -3,16 +3,15 @@ from typing import Any, Dict, Optional
|
|
|
3
3
|
|
|
4
4
|
from lxml import etree
|
|
5
5
|
from lxml.etree import _Element # noqa: WPS450, WPS458
|
|
6
|
-
from pydantic
|
|
6
|
+
from pydantic import BaseModel, ConfigDict, field_validator
|
|
7
7
|
|
|
8
8
|
from spei import types
|
|
9
9
|
from spei.resources.validators import validate_alphanumeric
|
|
10
|
+
from spei.types.common import DateInt, InstitutionCode
|
|
10
11
|
from spei.utils import to_camel_case, to_pascal_case, to_snake_case # noqa: WPS347
|
|
11
|
-
from spei.validators import digits
|
|
12
12
|
|
|
13
13
|
SOAP_NS = 'http://schemas.xmlsoap.org/soap/envelope/'
|
|
14
14
|
PRAXIS_NS = 'http://www.praxis.com.mx/'
|
|
15
|
-
_DATE_PATTERN = re.compile(r'^\d{4}(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])$')
|
|
16
15
|
_WHITESPACE_PATTERN = re.compile(r'\s+')
|
|
17
16
|
_CAMEL_CASE_FIELDS = frozenset(
|
|
18
17
|
(
|
|
@@ -26,10 +25,12 @@ _CAMEL_CASE_FIELDS = frozenset(
|
|
|
26
25
|
|
|
27
26
|
|
|
28
27
|
class Orden(BaseModel):
|
|
28
|
+
model_config = ConfigDict(strict=False, coerce_numbers_to_str=True)
|
|
29
|
+
|
|
29
30
|
id: int
|
|
30
31
|
categoria: types.CategoriaOrdenPago
|
|
31
|
-
op_fecha_oper:
|
|
32
|
-
op_folio:
|
|
32
|
+
op_fecha_oper: DateInt
|
|
33
|
+
op_folio: int
|
|
33
34
|
op_monto: str
|
|
34
35
|
op_tp_clave: types.TipoPagoOrdenPago
|
|
35
36
|
op_cve_rastreo: str
|
|
@@ -53,13 +54,13 @@ class Orden(BaseModel):
|
|
|
53
54
|
# For deposits, it is the other institution.
|
|
54
55
|
# For transfers, it is Fondeadora.
|
|
55
56
|
# Here we use OpInsClaveOrd and OpInsClaveBen to differentiate between them.
|
|
56
|
-
op_ins_clave_ord: Optional[
|
|
57
|
+
op_ins_clave_ord: Optional[InstitutionCode] = None
|
|
57
58
|
# destination info
|
|
58
59
|
op_nom_ben: Optional[str] = None
|
|
59
60
|
op_tc_clave_ben: Optional[types.TipoCuentaOrdenPago] = None
|
|
60
61
|
op_cuenta_ben: Optional[str] = None
|
|
61
62
|
op_rfc_curp_ben: Optional[str] = None
|
|
62
|
-
op_ins_clave_ben: Optional[
|
|
63
|
+
op_ins_clave_ben: Optional[InstitutionCode] = None
|
|
63
64
|
# participant info
|
|
64
65
|
op_cuenta_participante_ord: Optional[str] = None
|
|
65
66
|
op_nom_participante_ord: Optional[str] = None
|
|
@@ -74,8 +75,8 @@ class Orden(BaseModel):
|
|
|
74
75
|
op_concepto_pag_2: Optional[str] = None
|
|
75
76
|
# additional general info
|
|
76
77
|
op_iva: Optional[float] = None
|
|
77
|
-
op_ref_numerica: Optional[
|
|
78
|
-
op_ref_cobranza: Optional[
|
|
78
|
+
op_ref_numerica: Optional[int] = None
|
|
79
|
+
op_ref_cobranza: Optional[int] = None
|
|
79
80
|
op_clave_pago: Optional[str] = None
|
|
80
81
|
# refunds info
|
|
81
82
|
op_to_clave: Optional[int] = None
|
|
@@ -85,7 +86,7 @@ class Orden(BaseModel):
|
|
|
85
86
|
# original info
|
|
86
87
|
op_folio_ori: Optional[int] = None
|
|
87
88
|
paq_folio_ori: Optional[int] = None
|
|
88
|
-
op_fecha_oper_ori: Optional[
|
|
89
|
+
op_fecha_oper_ori: Optional[DateInt] = None
|
|
89
90
|
op_rastreo_ori: Optional[str] = None
|
|
90
91
|
op_monto_intereses: Optional[float] = None
|
|
91
92
|
op_monto_ori: Optional[float] = None
|
|
@@ -105,7 +106,7 @@ class Orden(BaseModel):
|
|
|
105
106
|
op_cert_comer_env: Optional[int] = None
|
|
106
107
|
op_digito_ver_comer: Optional[int] = None
|
|
107
108
|
# karpay system info
|
|
108
|
-
op_fecha_cap: Optional[
|
|
109
|
+
op_fecha_cap: Optional[DateInt] = None
|
|
109
110
|
op_folio_servidor: Optional[int] = None
|
|
110
111
|
op_usu_autoriza: Optional[str] = None
|
|
111
112
|
op_err_clave: Optional[types.CodigoError] = None
|
|
@@ -135,24 +136,19 @@ class Orden(BaseModel):
|
|
|
135
136
|
op_nom_prov_remesa_extranjera: Optional[str] = None
|
|
136
137
|
op_nom_prov_remesa_nacional: Optional[str] = None
|
|
137
138
|
op_nom_ben_indirecto_receptor: Optional[str] = None
|
|
139
|
+
model_config = ConfigDict(use_enum_values=True)
|
|
138
140
|
|
|
139
|
-
|
|
140
|
-
use_enum_values = True
|
|
141
|
-
|
|
142
|
-
@validator('op_monto', always=True)
|
|
141
|
+
@field_validator('op_monto', mode='before')
|
|
143
142
|
def set_amount(cls, value): # noqa: WPS110, N805
|
|
144
143
|
amount = float(value)
|
|
145
144
|
return '{amount:.2f}'.format(amount=amount)
|
|
146
145
|
|
|
147
|
-
@validator('op_fecha_oper')
|
|
148
|
-
def op_fecha_oper_must_be_iso_format(cls, value): # noqa: WPS110, N805
|
|
149
|
-
if _DATE_PATTERN.findall(str(value)):
|
|
150
|
-
return value
|
|
151
|
-
|
|
152
|
-
raise ValueError('must be in YYYYMMDD format')
|
|
153
|
-
|
|
154
146
|
def build_xml(self) -> _Element: # noqa: WPS231, C901
|
|
155
|
-
ordenpago: _Element = etree.Element(
|
|
147
|
+
ordenpago: _Element = etree.Element(
|
|
148
|
+
'ordenpago',
|
|
149
|
+
attrib={'Id': str(self.id)},
|
|
150
|
+
nsmap=None,
|
|
151
|
+
)
|
|
156
152
|
|
|
157
153
|
elements = self.dict(
|
|
158
154
|
exclude_none=True,
|
|
@@ -160,25 +156,45 @@ class Orden(BaseModel):
|
|
|
160
156
|
)
|
|
161
157
|
|
|
162
158
|
for element, value in elements.items(): # noqa: WPS110
|
|
163
|
-
if element in self.
|
|
164
|
-
if element == 'op_ins_clave_ben':
|
|
165
|
-
subelement = etree.SubElement(
|
|
159
|
+
if element in self.model_fields:
|
|
160
|
+
if element == 'op_ins_clave_ben':
|
|
161
|
+
subelement = etree.SubElement(
|
|
162
|
+
ordenpago,
|
|
163
|
+
'OpInsClave',
|
|
164
|
+
attrib={},
|
|
165
|
+
nsmap=None,
|
|
166
|
+
)
|
|
166
167
|
subelement.text = str(value)
|
|
167
168
|
continue
|
|
168
169
|
|
|
169
170
|
if element == 'op_firma_dig': # Lower case o in op
|
|
170
|
-
subelement = etree.SubElement(
|
|
171
|
+
subelement = etree.SubElement(
|
|
172
|
+
ordenpago,
|
|
173
|
+
'opFirmaDig',
|
|
174
|
+
attrib={},
|
|
175
|
+
nsmap=None,
|
|
176
|
+
)
|
|
171
177
|
subelement.text = str(value)
|
|
172
178
|
continue
|
|
173
179
|
|
|
174
180
|
text = self._process_text(str(value), element)
|
|
175
181
|
|
|
176
182
|
if element in _CAMEL_CASE_FIELDS:
|
|
177
|
-
subelement = etree.SubElement(
|
|
183
|
+
subelement = etree.SubElement(
|
|
184
|
+
ordenpago,
|
|
185
|
+
to_camel_case(element),
|
|
186
|
+
attrib={},
|
|
187
|
+
nsmap=None,
|
|
188
|
+
)
|
|
178
189
|
subelement.text = text
|
|
179
190
|
continue
|
|
180
191
|
|
|
181
|
-
subelement = etree.SubElement(
|
|
192
|
+
subelement = etree.SubElement(
|
|
193
|
+
ordenpago,
|
|
194
|
+
to_pascal_case(element),
|
|
195
|
+
attrib={},
|
|
196
|
+
nsmap=None,
|
|
197
|
+
)
|
|
182
198
|
subelement.text = text
|
|
183
199
|
|
|
184
200
|
return ordenpago
|
|
@@ -217,7 +233,7 @@ class Orden(BaseModel):
|
|
|
217
233
|
orden_data['op_firma_dig'] = stripped
|
|
218
234
|
return
|
|
219
235
|
|
|
220
|
-
if tag in cls.
|
|
236
|
+
if tag in cls.model_fields:
|
|
221
237
|
orden_data[tag] = cls._process_text(stripped, tag)
|
|
222
238
|
|
|
223
239
|
@classmethod
|
|
@@ -4,6 +4,7 @@ from typing import Optional
|
|
|
4
4
|
|
|
5
5
|
from spei import types
|
|
6
6
|
from spei.resources.orden import Orden
|
|
7
|
+
from spei.types.common import DateInt
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
class TerceroATercero(Orden):
|
|
@@ -19,8 +20,8 @@ class TerceroATercero(Orden):
|
|
|
19
20
|
|
|
20
21
|
op_concepto_pag_2: str
|
|
21
22
|
op_iva: Optional[float] = None
|
|
22
|
-
op_ref_numerica:
|
|
23
|
-
op_ref_cobranza: Optional[
|
|
23
|
+
op_ref_numerica: int
|
|
24
|
+
op_ref_cobranza: Optional[int] = None
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
class TerceroAVentilla(Orden):
|
|
@@ -54,7 +55,7 @@ class TerceroATerceroVostro(Orden):
|
|
|
54
55
|
op_concepto_pago: str
|
|
55
56
|
op_concepto_pag_2: Optional[str] = None
|
|
56
57
|
op_iva: Optional[float] = None
|
|
57
|
-
op_ref_numerica:
|
|
58
|
+
op_ref_numerica: int
|
|
58
59
|
|
|
59
60
|
|
|
60
61
|
class TerceroAParticipante(Orden):
|
|
@@ -65,7 +66,7 @@ class TerceroAParticipante(Orden):
|
|
|
65
66
|
|
|
66
67
|
op_concepto_pago: str
|
|
67
68
|
op_iva: Optional[float] = None
|
|
68
|
-
op_ref_numerica:
|
|
69
|
+
op_ref_numerica: int
|
|
69
70
|
|
|
70
71
|
op_to_clave: int
|
|
71
72
|
|
|
@@ -78,7 +79,7 @@ class ParticipanteATercero(Orden):
|
|
|
78
79
|
|
|
79
80
|
op_concepto_pag_2: str
|
|
80
81
|
op_iva: Optional[float] = None
|
|
81
|
-
op_ref_numerica:
|
|
82
|
+
op_ref_numerica: int
|
|
82
83
|
|
|
83
84
|
|
|
84
85
|
class ParticipanteATerceroVostro(Orden):
|
|
@@ -94,13 +95,13 @@ class ParticipanteATerceroVostro(Orden):
|
|
|
94
95
|
op_concepto_pago: str
|
|
95
96
|
op_concepto_pag_2: Optional[str] = None
|
|
96
97
|
op_iva: Optional[float] = None
|
|
97
|
-
op_ref_numerica:
|
|
98
|
+
op_ref_numerica: int
|
|
98
99
|
|
|
99
100
|
|
|
100
101
|
class ParticipanteAParticipante(Orden):
|
|
101
102
|
op_concepto_pago: str
|
|
102
103
|
op_iva: Optional[float] = None
|
|
103
|
-
op_ref_numerica:
|
|
104
|
+
op_ref_numerica: int
|
|
104
105
|
|
|
105
106
|
op_to_clave: int
|
|
106
107
|
|
|
@@ -118,8 +119,8 @@ class TerceroATerceroFSW(Orden):
|
|
|
118
119
|
|
|
119
120
|
op_concepto_pag_2: str
|
|
120
121
|
op_iva: Optional[float] = None
|
|
121
|
-
op_ref_numerica:
|
|
122
|
-
op_ref_cobranza: Optional[
|
|
122
|
+
op_ref_numerica: int
|
|
123
|
+
op_ref_cobranza: Optional[int] = None
|
|
123
124
|
|
|
124
125
|
|
|
125
126
|
class TerceroATerceroVostroFSW(Orden):
|
|
@@ -140,7 +141,7 @@ class TerceroATerceroVostroFSW(Orden):
|
|
|
140
141
|
op_concepto_pago: str
|
|
141
142
|
op_concepto_pag_2: Optional[str] = None
|
|
142
143
|
op_iva: Optional[float] = None
|
|
143
|
-
op_ref_numerica:
|
|
144
|
+
op_ref_numerica: int
|
|
144
145
|
|
|
145
146
|
|
|
146
147
|
class ParticipanteATerceroFSW(Orden):
|
|
@@ -151,7 +152,7 @@ class ParticipanteATerceroFSW(Orden):
|
|
|
151
152
|
|
|
152
153
|
op_concepto_pag_2: str
|
|
153
154
|
op_iva: Optional[float] = None
|
|
154
|
-
op_ref_numerica:
|
|
155
|
+
op_ref_numerica: int
|
|
155
156
|
|
|
156
157
|
|
|
157
158
|
class ParticipanteATerceroVostroFSW(Orden):
|
|
@@ -167,7 +168,7 @@ class ParticipanteATerceroVostroFSW(Orden):
|
|
|
167
168
|
op_concepto_pago: Optional[str] = None
|
|
168
169
|
op_concepto_pag_2: Optional[str] = None
|
|
169
170
|
op_iva: Optional[float] = None
|
|
170
|
-
op_ref_numerica: Optional[
|
|
171
|
+
op_ref_numerica: Optional[int] = None
|
|
171
172
|
|
|
172
173
|
|
|
173
174
|
class Nomina(Orden):
|
|
@@ -183,8 +184,8 @@ class Nomina(Orden):
|
|
|
183
184
|
|
|
184
185
|
op_concepto_pag_2: str
|
|
185
186
|
op_iva: Optional[float] = None
|
|
186
|
-
op_ref_numerica:
|
|
187
|
-
op_ref_cobranza: Optional[
|
|
187
|
+
op_ref_numerica: int
|
|
188
|
+
op_ref_cobranza: Optional[int] = None
|
|
188
189
|
|
|
189
190
|
|
|
190
191
|
class PagoFactura(Orden):
|
|
@@ -199,7 +200,7 @@ class PagoFactura(Orden):
|
|
|
199
200
|
op_rfc_curp_ben: Optional[str] = None
|
|
200
201
|
|
|
201
202
|
op_concepto_pag_2: str
|
|
202
|
-
op_ref_numerica:
|
|
203
|
+
op_ref_numerica: int
|
|
203
204
|
|
|
204
205
|
op_info_factura: str
|
|
205
206
|
|
|
@@ -216,7 +217,7 @@ class CobrosPresencialesUnaOcasion(Orden):
|
|
|
216
217
|
op_rfc_curp_ben: Optional[str] = None
|
|
217
218
|
|
|
218
219
|
op_concepto_pag_2: str
|
|
219
|
-
op_ref_numerica:
|
|
220
|
+
op_ref_numerica: int
|
|
220
221
|
|
|
221
222
|
op_num_cel_ord: int
|
|
222
223
|
op_digito_ver_ord: int
|
|
@@ -241,7 +242,7 @@ class CobrosNoPresencialesUnaOcasion(Orden):
|
|
|
241
242
|
op_rfc_curp_ben: Optional[str] = None
|
|
242
243
|
|
|
243
244
|
op_concepto_pag_2: str
|
|
244
|
-
op_ref_numerica:
|
|
245
|
+
op_ref_numerica: int
|
|
245
246
|
|
|
246
247
|
op_num_cel_ord: int
|
|
247
248
|
op_digito_ver_ord: int
|
|
@@ -266,7 +267,7 @@ class CobrosNoPresencialesRecurrentes(Orden):
|
|
|
266
267
|
op_rfc_curp_ben: Optional[str] = None
|
|
267
268
|
|
|
268
269
|
op_concepto_pag_2: str
|
|
269
|
-
op_ref_numerica:
|
|
270
|
+
op_ref_numerica: int
|
|
270
271
|
|
|
271
272
|
op_num_cel_ord: int
|
|
272
273
|
op_digito_ver_ord: int
|
|
@@ -296,7 +297,7 @@ class CobrosNoPresencialesNoRecurrentesTercero(Orden):
|
|
|
296
297
|
op_rfc_curp_ben_2: Optional[str] = None
|
|
297
298
|
|
|
298
299
|
op_concepto_pag_2: str
|
|
299
|
-
op_ref_numerica:
|
|
300
|
+
op_ref_numerica: int
|
|
300
301
|
|
|
301
302
|
op_num_cel_ord: int
|
|
302
303
|
op_digito_ver_ord: int
|
|
@@ -318,14 +319,14 @@ class DevolucionExtemporaneaNoAcreditada(Orden):
|
|
|
318
319
|
op_cuenta_ord: str
|
|
319
320
|
|
|
320
321
|
op_concepto_pag_2: str
|
|
321
|
-
op_ref_numerica:
|
|
322
|
+
op_ref_numerica: int
|
|
322
323
|
|
|
323
324
|
op_cd_clave: types.TipoDevolucionOrdenPago
|
|
324
325
|
|
|
325
326
|
op_folio_ori: Optional[int] = None
|
|
326
327
|
paq_folio_ori: Optional[int] = None
|
|
327
328
|
|
|
328
|
-
op_fecha_oper_ori:
|
|
329
|
+
op_fecha_oper_ori: DateInt
|
|
329
330
|
op_rastreo_ori: str
|
|
330
331
|
op_monto_intereses: float
|
|
331
332
|
op_monto_ori: float
|
|
@@ -339,12 +340,12 @@ class DevolucionExtemporaneaAcreditada(Orden):
|
|
|
339
340
|
op_cuenta_ord: str
|
|
340
341
|
|
|
341
342
|
op_concepto_pag_2: str
|
|
342
|
-
op_ref_numerica:
|
|
343
|
+
op_ref_numerica: int
|
|
343
344
|
|
|
344
345
|
op_folio_ori: Optional[int] = None
|
|
345
346
|
paq_folio_ori: Optional[int] = None
|
|
346
347
|
|
|
347
|
-
op_fecha_oper_ori:
|
|
348
|
+
op_fecha_oper_ori: DateInt
|
|
348
349
|
op_rastreo_ori: str
|
|
349
350
|
op_monto_ori: float
|
|
350
351
|
|
|
@@ -361,12 +362,12 @@ class DevolucionExtemporaneaEspecialAcreditada(Orden):
|
|
|
361
362
|
op_cuenta_ord: str
|
|
362
363
|
|
|
363
364
|
op_concepto_pag_2: str
|
|
364
|
-
op_ref_numerica:
|
|
365
|
+
op_ref_numerica: int
|
|
365
366
|
|
|
366
367
|
op_folio_ori: Optional[int] = None
|
|
367
368
|
paq_folio_ori: Optional[int] = None
|
|
368
369
|
|
|
369
|
-
op_fecha_oper_ori:
|
|
370
|
+
op_fecha_oper_ori: DateInt
|
|
370
371
|
op_rastreo_ori: str
|
|
371
372
|
op_monto_ori: float
|
|
372
373
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Optional, TypedDict
|
|
2
2
|
|
|
3
3
|
from lxml import etree
|
|
4
|
-
from pydantic
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
5
5
|
|
|
6
6
|
from spei import types
|
|
7
7
|
from spei.utils import to_pascal_case, to_snake_case # noqa: WPS347
|
|
@@ -16,20 +16,20 @@ class DataDict(TypedDict, total=False):
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class Respuesta(BaseModel):
|
|
19
|
-
|
|
20
|
-
categoria: types.CategoriaOrdenPago
|
|
21
|
-
id: Optional[str]
|
|
22
|
-
fecha_oper: Optional[int]
|
|
23
|
-
err_descripcion: Optional[str]
|
|
19
|
+
model_config = ConfigDict(strict=False, coerce_numbers_to_str=True)
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
categoria: types.CategoriaOrdenPago
|
|
22
|
+
err_codigo: Optional[types.CodigoError] = Field(default=None, validate_default=True)
|
|
23
|
+
id: Optional[int] = None
|
|
24
|
+
fecha_oper: Optional[int] = None
|
|
25
|
+
err_descripcion: Optional[str] = None
|
|
26
|
+
model_config = ConfigDict(use_enum_values=True)
|
|
27
27
|
|
|
28
28
|
def build_xml(self):
|
|
29
29
|
respuesta = etree.Element('respuesta')
|
|
30
30
|
|
|
31
31
|
for element, value in self.dict(exclude={'categoria'}).items(): # noqa: WPS110
|
|
32
|
-
if element in self.
|
|
32
|
+
if element in self.model_fields:
|
|
33
33
|
upper_camel_case_element = to_pascal_case(element)
|
|
34
34
|
subelement = etree.SubElement(respuesta, upper_camel_case_element)
|
|
35
35
|
subelement.text = str(value)
|
|
@@ -46,4 +46,4 @@ class Respuesta(BaseModel):
|
|
|
46
46
|
tag = to_snake_case(sub_element.tag)
|
|
47
47
|
respuesta_data[tag] = sub_element.text # type: ignore
|
|
48
48
|
|
|
49
|
-
return cls(
|
|
49
|
+
return cls.model_validate(respuesta_data)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
from spei.errors import CodigoError
|
|
1
2
|
from spei.types.spei import ( # noqa: WPS235
|
|
2
3
|
CategoriaOrdenPago,
|
|
3
4
|
ClaveOrdenanteOrdenPago,
|
|
4
|
-
CodigoError,
|
|
5
5
|
EstadoOrdenPago,
|
|
6
6
|
FolioOrdenPago,
|
|
7
7
|
MedioEntregaOrdenPago,
|
|
@@ -14,16 +14,16 @@ from spei.types.spei import ( # noqa: WPS235
|
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
__all__ = [ # noqa: WPS410
|
|
17
|
-
CategoriaOrdenPago,
|
|
18
|
-
ClaveOrdenanteOrdenPago,
|
|
19
|
-
EstadoOrdenPago,
|
|
20
|
-
FolioOrdenPago,
|
|
21
|
-
MedioEntregaOrdenPago,
|
|
22
|
-
PrioridadOrdenPago,
|
|
23
|
-
TipoCuentaOrdenPago,
|
|
24
|
-
TipoDevolucionOrdenPago,
|
|
25
|
-
TipoOrdenPago,
|
|
26
|
-
TipoPagoOrdenPago,
|
|
27
|
-
CodigoError,
|
|
28
|
-
TopologiaOrdenPago,
|
|
17
|
+
'CategoriaOrdenPago',
|
|
18
|
+
'ClaveOrdenanteOrdenPago',
|
|
19
|
+
'EstadoOrdenPago',
|
|
20
|
+
'FolioOrdenPago',
|
|
21
|
+
'MedioEntregaOrdenPago',
|
|
22
|
+
'PrioridadOrdenPago',
|
|
23
|
+
'TipoCuentaOrdenPago',
|
|
24
|
+
'TipoDevolucionOrdenPago',
|
|
25
|
+
'TipoOrdenPago',
|
|
26
|
+
'TipoPagoOrdenPago',
|
|
27
|
+
'CodigoError',
|
|
28
|
+
'TopologiaOrdenPago',
|
|
29
29
|
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# spei/types.py (or wherever you keep your custom types)
|
|
2
|
+
import re
|
|
3
|
+
from typing import Union
|
|
4
|
+
|
|
5
|
+
from pydantic import BeforeValidator
|
|
6
|
+
from typing_extensions import Annotated
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def validate_date_int(value: int) -> int: # noqa: WPS110
|
|
10
|
+
"""Validates and converts a date value to YYYYMMDD string format."""
|
|
11
|
+
value_str = str(value)
|
|
12
|
+
if not re.match(r'^\d{8}$', value_str):
|
|
13
|
+
raise ValueError('must be 8 digits in YYYYMMDD format')
|
|
14
|
+
|
|
15
|
+
# Additional date validation if needed
|
|
16
|
+
year = int(value_str[:4])
|
|
17
|
+
month = int(value_str[4:6])
|
|
18
|
+
day = int(value_str[6:8])
|
|
19
|
+
|
|
20
|
+
if year < 1900: # noqa: WPS432
|
|
21
|
+
raise ValueError('invalid year')
|
|
22
|
+
|
|
23
|
+
if not (1 <= month <= 12 and 1 <= day <= 31): # noqa: WPS432
|
|
24
|
+
raise ValueError('invalid date')
|
|
25
|
+
|
|
26
|
+
return int(value_str)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
DateInt = Annotated[int, BeforeValidator(validate_date_int)]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def validate_institution_code(value: Union[str, int]) -> int:
|
|
33
|
+
"""Validates and converts an institution code to a 3 or 5-digit integer."""
|
|
34
|
+
value_str = str(value)
|
|
35
|
+
if not re.match(r'^\d{3,5}$', value_str):
|
|
36
|
+
raise ValueError('must be exactly 3 or 5 digits')
|
|
37
|
+
|
|
38
|
+
return int(value_str)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
InstitutionCode = Annotated[int, BeforeValidator(validate_institution_code)]
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
from enum import Enum
|
|
2
2
|
|
|
3
|
-
from spei.errors import generate_error_codes
|
|
4
|
-
|
|
5
3
|
|
|
6
4
|
class TipoPagoOrdenPago(str, Enum):
|
|
7
5
|
devolucion_no_acreditada = '0'
|
|
@@ -103,8 +101,8 @@ class ClaveOrdenanteOrdenPago(int, Enum):
|
|
|
103
101
|
GEMELA = 699
|
|
104
102
|
|
|
105
103
|
|
|
106
|
-
class FolioOrdenPago(
|
|
107
|
-
cargar_odp =
|
|
104
|
+
class FolioOrdenPago(int, Enum):
|
|
105
|
+
cargar_odp = -1
|
|
108
106
|
|
|
109
107
|
|
|
110
108
|
class MedioEntregaOrdenPago(str, Enum):
|
|
@@ -167,6 +165,3 @@ class TipoDevolucionOrdenPago(str, Enum):
|
|
|
167
165
|
codi_payment_notification_timeout = 28
|
|
168
166
|
duplicated_tracking_code = 30
|
|
169
167
|
origin_institution_certificate_expired = 31
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
CodigoError = generate_error_codes()
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
from typing import TYPE_CHECKING, Optional, Type
|
|
2
|
-
|
|
3
|
-
from pydantic.v1 import ConstrainedStr, errors
|
|
4
|
-
|
|
5
|
-
if TYPE_CHECKING:
|
|
6
|
-
from pydantic.typing import CallableGenerator
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def digits(
|
|
10
|
-
min_length: Optional[int] = None,
|
|
11
|
-
max_length: Optional[int] = None,
|
|
12
|
-
) -> Type[str]:
|
|
13
|
-
namespace = {
|
|
14
|
-
'min_length': min_length,
|
|
15
|
-
'max_length': max_length,
|
|
16
|
-
}
|
|
17
|
-
return type('DigitsValue', (Digits,), namespace)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class Digits(ConstrainedStr):
|
|
21
|
-
@classmethod
|
|
22
|
-
def __get_validators__(cls) -> 'CallableGenerator':
|
|
23
|
-
yield from ConstrainedStr.__get_validators__()
|
|
24
|
-
yield validate_digits
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def validate_digits(value: str) -> str: # noqa: WPS110
|
|
28
|
-
if not value.isdigit():
|
|
29
|
-
raise errors.NotDigitError
|
|
30
|
-
return value
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|