@@ -290,7 +290,8 @@ def AutorizarComprobante(self):
290
290
}
291
291
292
292
res = self .client .autorizarComprobante (
293
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
293
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
294
+ 'cuitRepresentada' : self .Cuit },
294
295
comprobanteRequest = fact ,
295
296
)
296
297
ret = res .get ('autorizarComprobanteReturn' , {})
@@ -303,7 +304,8 @@ def AutorizarComprobante(self):
303
304
# guardo los mensajes xml originales
304
305
xml_request = self .client .xml_request
305
306
xml_response = self .client .xml_response
306
- cae = self .ConsultarComprobante (f ['tipo_cbte' ], f ['punto_vta' ], f ['cbt_desde' ], reproceso = True )
307
+ cae = self .ConsultarComprobante (
308
+ f ['tipo_cbte' ], f ['punto_vta' ], f ['cbt_desde' ], reproceso = True )
307
309
if cae and self .EmisionTipo == 'CAE' :
308
310
self .Reproceso = 'S'
309
311
self .Resultado = 'A' # verificar O
@@ -321,7 +323,8 @@ def AutorizarComprobante(self):
321
323
self .PuntoVenta = cbteresp ['numeroPuntoVenta' ] # 4000
322
324
# self. = cbteresp['cuit'] # 20267565393L
323
325
# self. = cbteresp['codigoTipoComprobante']
324
- self .Vencimiento = cbteresp ['fechaVencimientoCAE' ].strftime ("%Y/%m/%d" )
326
+ self .Vencimiento = cbteresp ['fechaVencimientoCAE' ].strftime (
327
+ "%Y/%m/%d" )
325
328
self .CAE = str (cbteresp ['CAE' ]) # 60423794871430L
326
329
self .__analizar_errores (ret )
327
330
@@ -348,7 +351,8 @@ def CAESolicitar(self):
348
351
@inicializar_y_capturar_excepciones
349
352
def ConsultarUltimoComprobanteAutorizado (self , tipo_cbte , punto_vta ):
350
353
res = self .client .consultarUltimoComprobanteAutorizado (
351
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
354
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
355
+ 'cuitRepresentada' : self .Cuit },
352
356
codigoTipoComprobante = tipo_cbte ,
353
357
numeroPuntoVenta = punto_vta ,
354
358
)
@@ -364,7 +368,8 @@ def ConsultarUltimoComprobanteAutorizado(self, tipo_cbte, punto_vta):
364
368
def ConsultarComprobante (self , tipo_cbte , punto_vta , cbte_nro , reproceso = False ):
365
369
"Recuperar los datos completos de un comprobante ya autorizado"
366
370
res = self .client .consultarComprobanteTipoPVentaNro (
367
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
371
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
372
+ 'cuitRepresentada' : self .Cuit },
368
373
codigoTipoComprobante = tipo_cbte ,
369
374
numeroPuntoVenta = punto_vta ,
370
375
numeroComprobante = cbte_nro ,
@@ -437,7 +442,8 @@ def ConsultarComprobante(self, tipo_cbte, punto_vta, cbte_nro, reproceso=False):
437
442
self .FechaCbte = cbteresp ['fechaEmision' ].strftime ("%Y/%m/%d" )
438
443
self .CbteNro = cbteresp ['numeroComprobante' ] # 1L
439
444
self .PuntoVenta = cbteresp ['numeroPuntoVenta' ] # 4000
440
- self .Vencimiento = cbteresp ['fechaVencimiento' ].strftime ("%Y/%m/%d" )
445
+ self .Vencimiento = cbteresp ['fechaVencimiento' ].strftime (
446
+ "%Y/%m/%d" )
441
447
self .ImpTotal = str (cbteresp ['importeTotal' ])
442
448
self .CAE = str (cbteresp ['codigoAutorizacion' ]) # 60423794871430L
443
449
self .EmisionTipo = cbteresp ['codigoTipoAutorizacion' ] == 'A' and 'CAEA' or 'CAE'
@@ -449,7 +455,8 @@ def ConsultarComprobante(self, tipo_cbte, punto_vta, cbte_nro, reproceso=False):
449
455
def ConsultarTiposComprobante (self ):
450
456
"Este método permite consultar los tipos de comprobantes habilitados en este WS"
451
457
res = self .client .consultarTiposComprobantes (
452
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
458
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
459
+ 'cuitRepresentada' : self .Cuit },
453
460
)
454
461
ret = res ['consultarTiposComprobantesReturn' ]
455
462
return ["%(codigo)s: %(descripcion)s" % p ['codigoDescripcion' ]
@@ -458,7 +465,8 @@ def ConsultarTiposComprobante(self):
458
465
@inicializar_y_capturar_excepciones
459
466
def ConsultarTiposDocumento (self ):
460
467
res = self .client .consultarTiposDocumento (
461
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
468
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
469
+ 'cuitRepresentada' : self .Cuit },
462
470
)
463
471
ret = res ['consultarTiposDocumentoReturn' ]
464
472
return ["%(codigo)s: %(descripcion)s" % p ['codigoDescripcion' ]
@@ -468,7 +476,8 @@ def ConsultarTiposDocumento(self):
468
476
def ConsultarTiposIVA (self ):
469
477
"Este método permite consultar los tipos de IVA habilitados en este ws"
470
478
res = self .client .consultarTiposIVA (
471
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
479
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
480
+ 'cuitRepresentada' : self .Cuit },
472
481
)
473
482
ret = res ['consultarTiposIVAReturn' ]
474
483
return ["%(codigo)s: %(descripcion)s" % p ['codigoDescripcionString' ]
@@ -478,7 +487,8 @@ def ConsultarTiposIVA(self):
478
487
def ConsultarCondicionesIVA (self ):
479
488
"Este método permite consultar los tipos de comprobantes habilitados en este WS"
480
489
res = self .client .consultarCondicionesIVA (
481
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
490
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
491
+ 'cuitRepresentada' : self .Cuit },
482
492
)
483
493
ret = res ['consultarCondicionesIVAReturn' ]
484
494
return ["%(codigo)s: %(descripcion)s" % p ['codigoDescripcionString' ]
@@ -488,7 +498,8 @@ def ConsultarCondicionesIVA(self):
488
498
def ConsultarMonedas (self ):
489
499
"Este método permite consultar los tipos de comprobantes habilitados en este WS"
490
500
res = self .client .consultarMonedas (
491
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
501
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
502
+ 'cuitRepresentada' : self .Cuit },
492
503
)
493
504
ret = res ['consultarMonedasReturn' ]
494
505
return ["%(codigo)s: %(descripcion)s" % p ['codigoDescripcionString' ]
@@ -498,7 +509,8 @@ def ConsultarMonedas(self):
498
509
def ConsultarTiposItem (self ):
499
510
"Este método permite consultar los tipos de comprobantes habilitados en este WS"
500
511
res = self .client .consultarTiposItem (
501
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
512
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
513
+ 'cuitRepresentada' : self .Cuit },
502
514
)
503
515
ret = res ['consultarTiposItemReturn' ]
504
516
return ["%(codigo)s: %(descripcion)s" % p ['codigoDescripcion' ]
@@ -508,7 +520,8 @@ def ConsultarTiposItem(self):
508
520
def ConsultarCodigosItemTurismo (self ):
509
521
"Este método permite consultar los códigos de los ítems de Turismo"
510
522
res = self .client .consultarCodigosItemTurismo (
511
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
523
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
524
+ 'cuitRepresentada' : self .Cuit },
512
525
)
513
526
ret = res ['consultarCodigosItemTurismoReturn' ]
514
527
return ["%(codigo)s: %(descripcion)s" % p ['codigoDescripcion' ]
@@ -518,7 +531,8 @@ def ConsultarCodigosItemTurismo(self):
518
531
def ConsultarTiposTributo (self ):
519
532
"Este método permite consultar los tipos de comprobantes habilitados en este WS"
520
533
res = self .client .consultarTiposTributo (
521
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
534
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
535
+ 'cuitRepresentada' : self .Cuit },
522
536
)
523
537
ret = res ['consultarTiposTributoReturn' ]
524
538
return ["%(codigo)s: %(descripcion)s" % p ['codigoDescripcionString' ]
@@ -527,10 +541,12 @@ def ConsultarTiposTributo(self):
527
541
@inicializar_y_capturar_excepciones
528
542
def ConsultarCotizacion (self , moneda_id ):
529
543
"Este método permite consultar los tipos de comprobantes habilitados en este WS"
530
- ret = self .client .consultarCotizacion (
531
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
544
+ res = self .client .consultarCotizacion (
545
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
546
+ 'cuitRepresentada' : self .Cuit },
532
547
codigoMoneda = moneda_id ,
533
548
)
549
+ ret = res ['consultarCotizacionReturn' ]
534
550
self .__analizar_errores (ret )
535
551
if 'cotizacionMoneda' in ret :
536
552
return str (ret ['cotizacionMoneda' ])
@@ -539,16 +555,21 @@ def ConsultarCotizacion(self, moneda_id):
539
555
def ConsultarPuntosVenta (self , fmt = "%(numeroPuntoVenta)s: bloqueado=%(bloqueado)s baja=%(fechaBaja)s" ):
540
556
"Este método permite consultar los puntos de venta habilitados para CAE en este WS"
541
557
res = self .client .consultarPuntosVenta (
542
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit },
558
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
559
+ 'cuitRepresentada' : self .Cuit },
543
560
)
561
+ result = res ['consultarPuntosVentaReturn' ]
562
+ self .__analizar_errores (result )
544
563
ret = []
545
- self .__analizar_errores (ret )
546
- for p in res ['consultarPuntosVentaReturn' ].get ("arrayPuntosVenta" , {}):
564
+ for p in result .get ("arrayPuntosVenta" , {}):
547
565
p = p ['puntoVenta' ]
548
566
if 'fechaBaja' not in p :
549
567
p ['fechaBaja' ] = ""
550
568
ret .append (fmt % p if fmt else p )
551
- return ret
569
+ if ret :
570
+ return ret
571
+ else :
572
+ return self .ErrMsg
552
573
553
574
@inicializar_y_capturar_excepciones
554
575
def ConsultarPaises (self , sep = "|" ):
@@ -630,7 +651,8 @@ def ConsultarFomasPago(self, sep="|"):
630
651
def ConsultarTiposTarjeta (self , forma_pago = None , sep = "|" ):
631
652
"Recuperar lista de los tipos de tarjeta habilitados"
632
653
ret = self .client .consultarTiposTarjeta (
633
- authRequest = {'token' : self .Token , 'sign' : self .Sign , 'cuitRepresentada' : self .Cuit , },
654
+ authRequest = {'token' : self .Token , 'sign' : self .Sign ,
655
+ 'cuitRepresentada' : self .Cuit , },
634
656
formaPago = forma_pago )
635
657
result = ret ['consultarTiposTarjetaReturn' ]
636
658
self .__analizar_errores (result )
@@ -692,7 +714,8 @@ def main():
692
714
try :
693
715
tipo_cbte = 195
694
716
punto_vta = 4000
695
- cbte_nro = wsct .ConsultarUltimoComprobanteAutorizado (tipo_cbte , punto_vta )
717
+ cbte_nro = wsct .ConsultarUltimoComprobanteAutorizado (
718
+ tipo_cbte , punto_vta )
696
719
fecha = datetime .datetime .now ().strftime ("%Y-%m-%d" )
697
720
tipo_doc = 80
698
721
nro_doc = "50000000059"
@@ -770,12 +793,15 @@ def main():
770
793
wsct .ConsultarComprobante (tipo_cbte , punto_vta , cbte_nro )
771
794
print ("CAE consulta" , wsct .CAE , wsct .CAE == cae )
772
795
print ("NRO consulta" , wsct .CbteNro , wsct .CbteNro == cbte_nro )
773
- print ("TOTAL consulta" , wsct .ImpTotal , wsct .ImpTotal == imp_total )
796
+ print ("TOTAL consulta" , wsct .ImpTotal ,
797
+ wsct .ImpTotal == imp_total )
774
798
775
799
wsct .AnalizarXml ("XmlResponse" )
776
- assert wsct .ObtenerTagXml ('codigoAutorizacion' ) == str (wsct .CAE )
800
+ assert wsct .ObtenerTagXml (
801
+ 'codigoAutorizacion' ) == str (wsct .CAE )
777
802
assert wsct .ObtenerTagXml ('codigoConcepto' ) == str (concepto )
778
- assert wsct .ObtenerTagXml ('arrayItems' , 0 , 'item' , 'unidadesMtx' ) == '123456'
803
+ assert wsct .ObtenerTagXml (
804
+ 'arrayItems' , 0 , 'item' , 'unidadesMtx' ) == '123456'
779
805
780
806
except BaseException :
781
807
print (wsct .XmlRequest )
0 commit comments