spei-python 0.44.0__tar.gz → 0.45.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.44.0 → spei_python-0.45.0}/PKG-INFO +1 -1
- {spei_python-0.44.0 → spei_python-0.45.0}/pyproject.toml +2 -2
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/checksum/factory.py +11 -5
- spei_python-0.45.0/spei/checksum/generator.py +182 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/checksum/types.py +12 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/client.py +3 -3
- spei_python-0.44.0/spei/checksum/generator.py +0 -165
- {spei_python-0.44.0 → spei_python-0.45.0}/README.md +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/README.md +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/__init__.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/cep_generator.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/checksum/__init__.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/errors/__init__.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/errors/sice.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/errors/spei.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/exceptions.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/mappings.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/requests/__init__.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/requests/acuse.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/requests/cda.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/requests/orden.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/requests/respuesta.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/resources/__init__.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/resources/acuse.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/resources/cda.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/resources/mensaje.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/resources/orden.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/resources/payments.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/resources/respuesta.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/responses/__init__.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/responses/acuse.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/responses/orden.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/responses/respuesta.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/sice.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/types/__init__.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/types/sice.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/types/spei.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/utils.py +0 -0
- {spei_python-0.44.0 → spei_python-0.45.0}/spei/validators.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "spei-python"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.45.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 = "0.45.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 = [
|
|
@@ -4,18 +4,21 @@ from spei.checksum.generator import (
|
|
|
4
4
|
ChecksumGeneratorBeneficiaryAndAdditionalBeneficiary,
|
|
5
5
|
ChecksumGeneratorDefault,
|
|
6
6
|
ChecksumGeneratorEveryField,
|
|
7
|
+
ChecksumGeneratorIndirect,
|
|
8
|
+
ChecksumGeneratorIndirectToParticipant,
|
|
7
9
|
ChecksumGeneratorOrigin,
|
|
8
10
|
ChecksumGeneratorOriginAndBeneficiary,
|
|
9
|
-
|
|
10
|
-
ChecksumGeneratorOriginBeneficiaryWithoutAccountAndParticipant,
|
|
11
|
+
ChecksumGeneratorRemittance,
|
|
11
12
|
)
|
|
12
13
|
from spei.checksum.types import (
|
|
14
|
+
INDIRECT_PAYMENT_TYPES,
|
|
13
15
|
PAYMENT_TYPES_WITH_BENEFICIARY_ACCOUNT,
|
|
14
16
|
PAYMENT_TYPES_WITH_BENEFICIARY_AND_ADDITIONAL_BENEFICIARY_ACCOUNT,
|
|
15
17
|
PAYMENT_TYPES_WITH_DEFAULT_FIELDS,
|
|
16
18
|
PAYMENT_TYPES_WITH_ORIGIN_ACCOUNT,
|
|
17
19
|
PAYMENT_TYPES_WITH_ORIGIN_AND_BENEFICIARY_ACCOUNT,
|
|
18
20
|
PAYMENT_TYPES_WITH_ORIGIN_BENEFICIARY_AND_ADDITIONAL_BENEFICIARY_ACCOUNT,
|
|
21
|
+
REMITTANCE_PAYMENT_TYPES,
|
|
19
22
|
)
|
|
20
23
|
from spei.types import TipoPagoOrdenPago
|
|
21
24
|
|
|
@@ -36,11 +39,14 @@ def get_checksum_generator(payment_type: TipoPagoOrdenPago) -> ChecksumGenerator
|
|
|
36
39
|
if payment_type in PAYMENT_TYPES_WITH_BENEFICIARY_AND_ADDITIONAL_BENEFICIARY_ACCOUNT: # noqa: E501
|
|
37
40
|
return ChecksumGeneratorBeneficiaryAndAdditionalBeneficiary()
|
|
38
41
|
|
|
39
|
-
if payment_type
|
|
40
|
-
return
|
|
42
|
+
if payment_type in REMITTANCE_PAYMENT_TYPES:
|
|
43
|
+
return ChecksumGeneratorRemittance()
|
|
44
|
+
|
|
45
|
+
if payment_type in INDIRECT_PAYMENT_TYPES:
|
|
46
|
+
return ChecksumGeneratorIndirect()
|
|
41
47
|
|
|
42
48
|
if payment_type == TipoPagoOrdenPago.tercero_indirecto_a_participante:
|
|
43
|
-
return
|
|
49
|
+
return ChecksumGeneratorIndirectToParticipant()
|
|
44
50
|
|
|
45
51
|
if payment_type in PAYMENT_TYPES_WITH_ORIGIN_BENEFICIARY_AND_ADDITIONAL_BENEFICIARY_ACCOUNT: # noqa: E501
|
|
46
52
|
return ChecksumGeneratorEveryField()
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from decimal import Decimal
|
|
3
|
+
from typing import Any, List
|
|
4
|
+
|
|
5
|
+
from spei.resources import Orden
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ChecksumGenerator(object):
|
|
9
|
+
def format_data(self):
|
|
10
|
+
raise NotImplementedError
|
|
11
|
+
|
|
12
|
+
def split_amount(self, amount):
|
|
13
|
+
amount_as_cents = int(Decimal(str(amount)) * 100)
|
|
14
|
+
high = 0
|
|
15
|
+
low = amount_as_cents
|
|
16
|
+
tens_of_millons = amount_as_cents // 10**9
|
|
17
|
+
if tens_of_millons:
|
|
18
|
+
high = tens_of_millons
|
|
19
|
+
low = amount_as_cents - (tens_of_millons * 10**9)
|
|
20
|
+
return high, low
|
|
21
|
+
|
|
22
|
+
def _fecha_to_bytearray(self, fecha_operacion: int) -> bytearray:
|
|
23
|
+
fecha_operacion = datetime.strptime(str(fecha_operacion), '%Y%m%d')
|
|
24
|
+
|
|
25
|
+
day = int.to_bytes(int(fecha_operacion.day), 1, 'big')
|
|
26
|
+
month = int.to_bytes(int(fecha_operacion.month), 1, 'big')
|
|
27
|
+
year = int.to_bytes(int(fecha_operacion.year), 2, 'big')
|
|
28
|
+
return day + month + year
|
|
29
|
+
|
|
30
|
+
def _clave_to_bytearray(self, clave: str) -> bytearray:
|
|
31
|
+
if not clave:
|
|
32
|
+
clave = ''
|
|
33
|
+
return int.to_bytes(int(clave), 4, 'big')
|
|
34
|
+
|
|
35
|
+
def _monto_to_bytearray(self, amount: int) -> bytearray:
|
|
36
|
+
high, low = self.split_amount(amount)
|
|
37
|
+
high = int.to_bytes(int(high), 4, 'big')
|
|
38
|
+
low = int.to_bytes(int(low), 4, 'big')
|
|
39
|
+
return high + low
|
|
40
|
+
|
|
41
|
+
def _to_byte_array(
|
|
42
|
+
self,
|
|
43
|
+
value: str, # noqa: WPS110
|
|
44
|
+
add_zero_byte: bool = False,
|
|
45
|
+
) -> bytearray:
|
|
46
|
+
encoded = value.encode('utf-8')
|
|
47
|
+
bytes_ = bytearray(encoded)
|
|
48
|
+
if add_zero_byte:
|
|
49
|
+
bytes_.append(0)
|
|
50
|
+
return bytes_
|
|
51
|
+
|
|
52
|
+
def _list_to_bytes(self, message_data: List[Any]) -> bytes:
|
|
53
|
+
res = bytearray()
|
|
54
|
+
for field in message_data:
|
|
55
|
+
for element in field:
|
|
56
|
+
res.append(element)
|
|
57
|
+
return bytes(res)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class ChecksumGeneratorRemittance(ChecksumGenerator):
|
|
61
|
+
def format_data(self, orden: Orden):
|
|
62
|
+
message_data = (
|
|
63
|
+
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
64
|
+
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
65
|
+
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
66
|
+
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
67
|
+
self._monto_to_bytearray(orden.op_monto),
|
|
68
|
+
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
69
|
+
self._to_byte_array(orden.op_cuenta_ben, add_zero_byte=True),
|
|
70
|
+
self._to_byte_array(orden.op_cuenta_participante_ord, add_zero_byte=True), # noqa: E501
|
|
71
|
+
)
|
|
72
|
+
return self._list_to_bytes(message_data)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class ChecksumGeneratorDefault(ChecksumGenerator):
|
|
76
|
+
def format_data(self, orden: Orden):
|
|
77
|
+
message_data = (
|
|
78
|
+
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
79
|
+
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
80
|
+
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
81
|
+
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
82
|
+
self._monto_to_bytearray(orden.op_monto),
|
|
83
|
+
)
|
|
84
|
+
return self._list_to_bytes(message_data)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class ChecksumGeneratorOrigin(ChecksumGenerator):
|
|
88
|
+
def format_data(self, orden: Orden):
|
|
89
|
+
message_data = (
|
|
90
|
+
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
91
|
+
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
92
|
+
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
93
|
+
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
94
|
+
self._monto_to_bytearray(orden.op_monto),
|
|
95
|
+
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
96
|
+
)
|
|
97
|
+
return self._list_to_bytes(message_data)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class ChecksumGeneratorBeneficiary(ChecksumGenerator):
|
|
101
|
+
def format_data(self, orden: Orden):
|
|
102
|
+
message_data = (
|
|
103
|
+
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
104
|
+
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
105
|
+
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
106
|
+
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
107
|
+
self._monto_to_bytearray(orden.op_monto),
|
|
108
|
+
self._to_byte_array(orden.op_cuenta_ben, add_zero_byte=True),
|
|
109
|
+
)
|
|
110
|
+
return self._list_to_bytes(message_data)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class ChecksumGeneratorOriginAndBeneficiary(ChecksumGenerator):
|
|
114
|
+
def format_data(self, orden: Orden):
|
|
115
|
+
message_data = (
|
|
116
|
+
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
117
|
+
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
118
|
+
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
119
|
+
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
120
|
+
self._monto_to_bytearray(orden.op_monto),
|
|
121
|
+
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
122
|
+
self._to_byte_array(orden.op_cuenta_ben, add_zero_byte=True),
|
|
123
|
+
)
|
|
124
|
+
return self._list_to_bytes(message_data)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class ChecksumGeneratorBeneficiaryAndAdditionalBeneficiary(ChecksumGenerator):
|
|
128
|
+
def format_data(self, orden: Orden):
|
|
129
|
+
message_data = (
|
|
130
|
+
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
131
|
+
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
132
|
+
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
133
|
+
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
134
|
+
self._monto_to_bytearray(orden.op_monto),
|
|
135
|
+
self._to_byte_array(orden.op_cuenta_ben, add_zero_byte=True),
|
|
136
|
+
self._to_byte_array(orden.op_cuenta_ben_2, add_zero_byte=True),
|
|
137
|
+
)
|
|
138
|
+
return self._list_to_bytes(message_data)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class ChecksumGeneratorIndirectToParticipant(ChecksumGenerator):
|
|
142
|
+
def format_data(self, orden: Orden):
|
|
143
|
+
message_data = (
|
|
144
|
+
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
145
|
+
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
146
|
+
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
147
|
+
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
148
|
+
self._monto_to_bytearray(orden.op_monto),
|
|
149
|
+
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
150
|
+
self._to_byte_array(orden.op_cuenta_participante_ord, add_zero_byte=True), # noqa: E501
|
|
151
|
+
)
|
|
152
|
+
return self._list_to_bytes(message_data)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class ChecksumGeneratorIndirect(ChecksumGenerator):
|
|
156
|
+
def format_data(self, orden: Orden):
|
|
157
|
+
message_data = (
|
|
158
|
+
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
159
|
+
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
160
|
+
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
161
|
+
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
162
|
+
self._monto_to_bytearray(orden.op_monto),
|
|
163
|
+
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
164
|
+
self._to_byte_array(orden.op_cuenta_ben, add_zero_byte=True),
|
|
165
|
+
self._to_byte_array(orden.op_cuenta_participante_ord, add_zero_byte=True), # noqa: E501
|
|
166
|
+
)
|
|
167
|
+
return self._list_to_bytes(message_data)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class ChecksumGeneratorEveryField(ChecksumGenerator):
|
|
171
|
+
def format_data(self, orden: Orden):
|
|
172
|
+
message_data = (
|
|
173
|
+
self._fecha_to_bytearray(orden.op_fecha_oper),
|
|
174
|
+
self._clave_to_bytearray(orden.op_ins_clave_ord),
|
|
175
|
+
self._clave_to_bytearray(orden.op_ins_clave_ben),
|
|
176
|
+
self._to_byte_array(orden.op_cve_rastreo, add_zero_byte=True),
|
|
177
|
+
self._monto_to_bytearray(orden.op_monto),
|
|
178
|
+
self._to_byte_array(orden.op_cuenta_ord, add_zero_byte=True),
|
|
179
|
+
self._to_byte_array(orden.op_cuenta_ben, add_zero_byte=True),
|
|
180
|
+
self._to_byte_array(orden.op_cuenta_ben_2, add_zero_byte=True),
|
|
181
|
+
)
|
|
182
|
+
return self._list_to_bytes(message_data)
|
|
@@ -40,3 +40,15 @@ PAYMENT_TYPES_WITH_ORIGIN_BENEFICIARY_AND_ADDITIONAL_BENEFICIARY_ACCOUNT = (
|
|
|
40
40
|
TipoPagoOrdenPago.tercero_a_tercero_vostro,
|
|
41
41
|
TipoPagoOrdenPago.tercero_a_tercero_vostro_fsw,
|
|
42
42
|
)
|
|
43
|
+
|
|
44
|
+
REMITTANCE_PAYMENT_TYPES = (
|
|
45
|
+
TipoPagoOrdenPago.remesa_entrante,
|
|
46
|
+
TipoPagoOrdenPago.remesa_saliente,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
INDIRECT_PAYMENT_TYPES = (
|
|
50
|
+
TipoPagoOrdenPago.tercero_indirecto_a_tercero,
|
|
51
|
+
TipoPagoOrdenPago.presencial_de_una_ocasion_indirecto,
|
|
52
|
+
TipoPagoOrdenPago.no_presencial_de_una_ocasion_indirecto,
|
|
53
|
+
TipoPagoOrdenPago.no_presencial_recurrente_indirecto,
|
|
54
|
+
)
|
|
@@ -50,9 +50,9 @@ class BaseClient(object):
|
|
|
50
50
|
self.checksum_generator_factory = checksum_generator_factory
|
|
51
51
|
|
|
52
52
|
def generate_checksum(self, message_data):
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
message_as_bytes = generator.format_data(
|
|
53
|
+
orden = Orden(**message_data, op_firma_dig='')
|
|
54
|
+
generator = self.checksum_generator_factory(orden.op_tp_clave)
|
|
55
|
+
message_as_bytes = generator.format_data(orden)
|
|
56
56
|
|
|
57
57
|
signed_message = self.pkey.sign(
|
|
58
58
|
message_as_bytes,
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
|
-
from decimal import Decimal
|
|
3
|
-
from typing import Any, AnyStr, Dict, List
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class ChecksumGenerator(object):
|
|
7
|
-
def format_data(self):
|
|
8
|
-
raise NotImplementedError
|
|
9
|
-
|
|
10
|
-
def split_amount(self, amount):
|
|
11
|
-
amount_as_cents = int(Decimal(str(amount)) * 100)
|
|
12
|
-
high = 0
|
|
13
|
-
low = amount_as_cents
|
|
14
|
-
tens_of_millons = amount_as_cents // 10**9
|
|
15
|
-
if tens_of_millons:
|
|
16
|
-
high = tens_of_millons
|
|
17
|
-
low = amount_as_cents - (tens_of_millons * 10**9)
|
|
18
|
-
return high, low
|
|
19
|
-
|
|
20
|
-
def _fecha_to_bytearray(self, fecha_operacion: int) -> bytearray:
|
|
21
|
-
fecha_operacion = datetime.strptime(str(fecha_operacion), '%Y%m%d')
|
|
22
|
-
|
|
23
|
-
day = int.to_bytes(int(fecha_operacion.day), 1, 'big')
|
|
24
|
-
month = int.to_bytes(int(fecha_operacion.month), 1, 'big')
|
|
25
|
-
year = int.to_bytes(int(fecha_operacion.year), 2, 'big')
|
|
26
|
-
return day + month + year
|
|
27
|
-
|
|
28
|
-
def _clave_to_bytearray(self, clave: str) -> bytearray:
|
|
29
|
-
if not clave:
|
|
30
|
-
clave = ''
|
|
31
|
-
return int.to_bytes(int(clave), 4, 'big')
|
|
32
|
-
|
|
33
|
-
def _monto_to_bytearray(self, amount: int) -> bytearray:
|
|
34
|
-
high, low = self.split_amount(amount)
|
|
35
|
-
high = int.to_bytes(int(high), 4, 'big')
|
|
36
|
-
low = int.to_bytes(int(low), 4, 'big')
|
|
37
|
-
return high + low
|
|
38
|
-
|
|
39
|
-
def _to_byte_array(
|
|
40
|
-
self,
|
|
41
|
-
value: str, # noqa: WPS110
|
|
42
|
-
add_zero_byte: bool = False,
|
|
43
|
-
) -> bytearray:
|
|
44
|
-
encoded = value.encode('utf-8')
|
|
45
|
-
bytes_ = bytearray(encoded)
|
|
46
|
-
if add_zero_byte:
|
|
47
|
-
bytes_.append(0)
|
|
48
|
-
return bytes_
|
|
49
|
-
|
|
50
|
-
def _list_to_bytes(self, message_data: List[Any]) -> bytes:
|
|
51
|
-
res = bytearray()
|
|
52
|
-
for field in message_data:
|
|
53
|
-
for element in field:
|
|
54
|
-
res.append(element)
|
|
55
|
-
return bytes(res)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
class ChecksumGeneratorDefault(ChecksumGenerator):
|
|
59
|
-
def format_data(self, message: Dict[AnyStr, Any]):
|
|
60
|
-
message_data = (
|
|
61
|
-
self._fecha_to_bytearray(message['op_fecha_oper']),
|
|
62
|
-
self._clave_to_bytearray(message['op_ins_clave_ord']),
|
|
63
|
-
self._clave_to_bytearray(message['op_ins_clave_ben']),
|
|
64
|
-
self._to_byte_array(message['op_cve_rastreo'], add_zero_byte=True),
|
|
65
|
-
self._monto_to_bytearray(message['op_monto']),
|
|
66
|
-
)
|
|
67
|
-
return self._list_to_bytes(message_data)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
class ChecksumGeneratorOrigin(ChecksumGenerator):
|
|
71
|
-
def format_data(self, message: Dict[AnyStr, Any]):
|
|
72
|
-
message_data = (
|
|
73
|
-
self._fecha_to_bytearray(message['op_fecha_oper']),
|
|
74
|
-
self._clave_to_bytearray(message['op_ins_clave_ord']),
|
|
75
|
-
self._clave_to_bytearray(message['op_ins_clave_ben']),
|
|
76
|
-
self._to_byte_array(message['op_cve_rastreo'], add_zero_byte=True),
|
|
77
|
-
self._monto_to_bytearray(message['op_monto']),
|
|
78
|
-
self._to_byte_array(message['op_cuenta_ord'], add_zero_byte=True),
|
|
79
|
-
)
|
|
80
|
-
return self._list_to_bytes(message_data)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
class ChecksumGeneratorBeneficiary(ChecksumGenerator):
|
|
84
|
-
def format_data(self, message: Dict[AnyStr, Any]):
|
|
85
|
-
message_data = (
|
|
86
|
-
self._fecha_to_bytearray(message['op_fecha_oper']),
|
|
87
|
-
self._clave_to_bytearray(message['op_ins_clave_ord']),
|
|
88
|
-
self._clave_to_bytearray(message['op_ins_clave_ben']),
|
|
89
|
-
self._to_byte_array(message['op_cve_rastreo'], add_zero_byte=True),
|
|
90
|
-
self._monto_to_bytearray(message['op_monto']),
|
|
91
|
-
self._to_byte_array(message['op_cuenta_ben'], add_zero_byte=True),
|
|
92
|
-
)
|
|
93
|
-
return self._list_to_bytes(message_data)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
class ChecksumGeneratorOriginAndBeneficiary(ChecksumGenerator):
|
|
97
|
-
def format_data(self, message: Dict[AnyStr, Any]):
|
|
98
|
-
message_data = (
|
|
99
|
-
self._fecha_to_bytearray(message['op_fecha_oper']),
|
|
100
|
-
self._clave_to_bytearray(message['op_ins_clave_ord']),
|
|
101
|
-
self._clave_to_bytearray(message['op_ins_clave_ben']),
|
|
102
|
-
self._to_byte_array(message['op_cve_rastreo'], add_zero_byte=True),
|
|
103
|
-
self._monto_to_bytearray(message['op_monto']),
|
|
104
|
-
self._to_byte_array(message['op_cuenta_ord'], add_zero_byte=True),
|
|
105
|
-
self._to_byte_array(message['op_cuenta_ben'], add_zero_byte=True),
|
|
106
|
-
)
|
|
107
|
-
return self._list_to_bytes(message_data)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
class ChecksumGeneratorBeneficiaryAndAdditionalBeneficiary(ChecksumGenerator):
|
|
111
|
-
def format_data(self, message: Dict[AnyStr, Any]):
|
|
112
|
-
message_data = (
|
|
113
|
-
self._fecha_to_bytearray(message['op_fecha_oper']),
|
|
114
|
-
self._clave_to_bytearray(message['op_ins_clave_ord']),
|
|
115
|
-
self._clave_to_bytearray(message['op_ins_clave_ben']),
|
|
116
|
-
self._to_byte_array(message['op_cve_rastreo'], add_zero_byte=True),
|
|
117
|
-
self._monto_to_bytearray(message['op_monto']),
|
|
118
|
-
self._to_byte_array(message['op_cuenta_ben'], add_zero_byte=True),
|
|
119
|
-
self._to_byte_array(message['op_cuenta_ben_2'], add_zero_byte=True),
|
|
120
|
-
)
|
|
121
|
-
return self._list_to_bytes(message_data)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
class ChecksumGeneratorOriginBeneficiaryWithoutAccountAndParticipant(ChecksumGenerator):
|
|
125
|
-
def format_data(self, message: Dict[AnyStr, Any]):
|
|
126
|
-
message_data = (
|
|
127
|
-
self._fecha_to_bytearray(message['op_fecha_oper']),
|
|
128
|
-
self._clave_to_bytearray(message['op_ins_clave_ord']),
|
|
129
|
-
self._clave_to_bytearray(message['op_ins_clave_ben']),
|
|
130
|
-
self._to_byte_array(message['op_cve_rastreo'], add_zero_byte=True),
|
|
131
|
-
self._monto_to_bytearray(message['op_monto']),
|
|
132
|
-
self._to_byte_array(message['op_cuenta_ord'], add_zero_byte=True),
|
|
133
|
-
self._to_byte_array(message['op_cuenta_participante_ord'], add_zero_byte=True), # noqa: E501
|
|
134
|
-
)
|
|
135
|
-
return self._list_to_bytes(message_data)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
class ChecksumGeneratorOriginBeneficiaryAndParticipant(ChecksumGenerator):
|
|
139
|
-
def format_data(self, message: Dict[AnyStr, Any]):
|
|
140
|
-
message_data = (
|
|
141
|
-
self._fecha_to_bytearray(message['op_fecha_oper']),
|
|
142
|
-
self._clave_to_bytearray(message['op_ins_clave_ord']),
|
|
143
|
-
self._clave_to_bytearray(message['op_ins_clave_ben']),
|
|
144
|
-
self._to_byte_array(message['op_cve_rastreo'], add_zero_byte=True),
|
|
145
|
-
self._monto_to_bytearray(message['op_monto']),
|
|
146
|
-
self._to_byte_array(message['op_cuenta_ord'], add_zero_byte=True),
|
|
147
|
-
self._to_byte_array(message['op_cuenta_ben'], add_zero_byte=True),
|
|
148
|
-
self._to_byte_array(message['op_cuenta_participante_ord'], add_zero_byte=True), # noqa: E501
|
|
149
|
-
)
|
|
150
|
-
return self._list_to_bytes(message_data)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
class ChecksumGeneratorEveryField(ChecksumGenerator):
|
|
154
|
-
def format_data(self, message: Dict[AnyStr, Any]):
|
|
155
|
-
message_data = (
|
|
156
|
-
self._fecha_to_bytearray(message['op_fecha_oper']),
|
|
157
|
-
self._clave_to_bytearray(message['op_ins_clave_ord']),
|
|
158
|
-
self._clave_to_bytearray(message['op_ins_clave_ben']),
|
|
159
|
-
self._to_byte_array(message['op_cve_rastreo'], add_zero_byte=True),
|
|
160
|
-
self._monto_to_bytearray(message['op_monto']),
|
|
161
|
-
self._to_byte_array(message['op_cuenta_ord'], add_zero_byte=True),
|
|
162
|
-
self._to_byte_array(message['op_cuenta_ben'], add_zero_byte=True),
|
|
163
|
-
self._to_byte_array(message['op_cuenta_ben_2'], add_zero_byte=True),
|
|
164
|
-
)
|
|
165
|
-
return self._list_to_bytes(message_data)
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|