Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
l10n_mx
Facturacion
Commits
c8c10c4e
Commit
c8c10c4e
authored
6 years ago
by
Cuauhtémoc Díaz Minor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(xpd_tu_factura): se verifica si el status_code de la respuesta es diferente de 200
parent
dfa9cd39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
l10n_mx_params_pac/pacs/expide_tu_factura.py
l10n_mx_params_pac/pacs/expide_tu_factura.py
+22
-6
No files found.
l10n_mx_params_pac/pacs/expide_tu_factura.py
View file @
c8c10c4e
...
...
@@ -78,6 +78,14 @@ class ParamsPac(models.Model):
"Content-Type"
:
"text/xml;charset=UTF-8"
,
}
@
classmethod
def
validate_response
(
cls
,
soap_response
):
"""if response.status_code not 200 then raise Exception"""
if
str
(
soap_response
.
status_code
)
not
in
"200"
:
raise
Exception
(
"Bad response: "
+
str
(
soap_response
.
status_code
)
+
","
+
soap_response
.
content
)
@
api
.
one
def
sign_file
(
self
,
fdata
=
None
):
"""
...
...
@@ -103,12 +111,14 @@ class ParamsPac(models.Model):
try
:
# Timbrar factura
response
=
s
.
send
(
prepped
,
timeout
=
TIMEOUT
)
res
=
xmltodict
.
parse
(
response
.
text
)
_logger
.
debug
(
res
)
except
Exception
as
e
:
# Error al establecer comunicación con el PAC
_logger
.
debug
(
e
)
raise
e
else
:
self
.
validate_response
(
response
)
res
=
xmltodict
.
parse
(
response
.
text
)
_logger
.
debug
(
res
)
# Procesar los resultados obtenidos del PAC
try
:
resultado
=
res
[
"soapenv:Envelope"
][
"soapenv:Body"
][
"ser:timbrarResponse"
][
...
...
@@ -184,12 +194,15 @@ class ParamsPac(models.Model):
try
:
# Timbrar factura
response
=
s
.
send
(
prepped
,
timeout
=
TIMEOUT
)
res
=
xmltodict
.
parse
(
response
.
text
)
_logger
.
debug
(
res
)
except
Exception
as
e
:
# Error al establecer comunicación con el PAC
_logger
.
debug
(
e
)
raise
e
else
:
self
.
validate_response
(
response
)
res
=
xmltodict
.
parse
(
response
.
text
)
_logger
.
debug
(
res
)
# Procesar los resultados obtenidos del PAC
try
:
resultado
=
res
[
"soapenv:Envelope"
][
"soapenv:Body"
][
...
...
@@ -250,12 +263,15 @@ class ParamsPac(models.Model):
try
:
# Timbrar factura
response
=
s
.
send
(
prepped
,
timeout
=
TIMEOUT
)
res
=
xmltodict
.
parse
(
response
.
text
)
_logger
.
debug
(
res
)
except
Exception
as
e
:
# Error al establecer comunicación con el PAC
_logger
.
debug
(
e
)
raise
e
else
:
self
.
validate_response
(
response
)
_logger
.
debug
(
response
.
text
)
res
=
xmltodict
.
parse
(
response
.
text
)
_logger
.
debug
(
res
)
# Procesar los resultados obtenidos del PAC
try
:
resultado
=
res
[
"soapenv:Envelope"
][
"soapenv:Body"
][
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment