|
1 | | -# -*- coding: utf-8 -*- |
2 | 1 | import base64 |
3 | 2 | import datetime |
4 | 3 | import os |
|
9 | 8 | from cfdiclient import Fiel |
10 | 9 | from cfdiclient import SolicitaDescarga |
11 | 10 | from cfdiclient import VerificaSolicitudDescarga |
12 | | - |
13 | 11 | ## |
14 | | -## Constantes de Loggin |
| 12 | +# Constantes de Loggin |
15 | 13 | ## |
16 | 14 | RFC = 'ESI920427886' |
17 | 15 | FIEL_CER = 'ejemploCer.cer' |
|
22 | 20 | cer_der = open(os.path.join(PATH, FIEL_CER), 'rb').read() |
23 | 21 | key_der = open(os.path.join(PATH, FIEL_KEY), 'rb').read() |
24 | 22 |
|
25 | | -FECHA_INICIAL = datetime.date(2020, 1, 1) |
26 | | -FECHA_FINAL = datetime.date(2020, 6, 24) |
| 23 | +FECHA_INICIAL = datetime.datetime(2024, 3, 1) |
| 24 | +FECHA_FINAL = datetime.datetime(2024, 3, 30) |
27 | 25 |
|
28 | 26 | fiel = Fiel(cer_der, key_der, FIEL_PAS) |
29 | 27 |
|
|
37 | 35 |
|
38 | 36 | # EMITIDOS |
39 | 37 | # solicitud = descarga.solicitar_descarga( |
40 | | -# token, RFC, FECHA_INICIAL, FECHA_FINAL, rfc_emisor=RFC, tipo_solicitud='CFDI' |
| 38 | +# token, RFC, FECHA_INICIAL, FECHA_FINAL, rfc_emisor=RFC, tipo_solicitud='CFDI', |
41 | 39 | # ) |
42 | 40 |
|
43 | 41 | # RECIBIDOS |
44 | 42 | solicitud = descarga.solicitar_descarga( |
45 | | - token, RFC, FECHA_INICIAL, FECHA_FINAL, rfc_receptor=RFC, tipo_solicitud='CFDI' |
| 43 | + token, RFC, FECHA_INICIAL, FECHA_FINAL, rfc_receptor=RFC, tipo_solicitud='CFDI', |
46 | 44 | ) |
| 45 | +print('solicitar_descarga:', solicitud) |
47 | 46 |
|
48 | | -print('SOLICITUD:', solicitud) |
| 47 | +if solicitud['cod_estatus'] != '5000': |
| 48 | + exit(1) |
49 | 49 |
|
50 | 50 | while True: |
51 | 51 |
|
|
58 | 58 | verificacion = verificacion.verificar_descarga( |
59 | 59 | token, RFC, solicitud['id_solicitud']) |
60 | 60 |
|
61 | | - print('SOLICITUD:', verificacion) |
| 61 | + print('verificar_descarga:', verificacion) |
62 | 62 |
|
63 | 63 | estado_solicitud = int(verificacion['estado_solicitud']) |
64 | 64 |
|
| 65 | + # 0, Token invalido. |
65 | 66 | # 1, Aceptada |
66 | 67 | # 2, En proceso |
67 | 68 | # 3, Terminada |
|
73 | 74 |
|
74 | 75 | # Si el estado de solicitud esta Aceptado o en proceso el programa espera |
75 | 76 | # 60 segundos y vuelve a tratar de verificar |
76 | | - time.sleep(60) |
| 77 | + time.sleep(10) |
77 | 78 |
|
78 | 79 | continue |
79 | 80 |
|
|
97 | 98 | with open('{}.zip'.format(paquete), 'wb') as fp: |
98 | 99 |
|
99 | 100 | fp.write(base64.b64decode(descarga['paquete_b64'])) |
100 | | - |
| 101 | + |
101 | 102 | break |
0 commit comments