@@ -198,7 +198,7 @@ def autorizar(ws, entrada, salida):
198
198
if DEBUG :
199
199
print ("\n " .join (["%s='%s'" % (k , v ) for k , v in list (ws .factura .items ())]))
200
200
print ("id:" , encabezado ["id" ])
201
- if not DEBUG or input ( "Facturar?" ) == "S" :
201
+ if not DEBUG :
202
202
cae = ws .Authorize (encabezado ["id" ])
203
203
dic = ws .factura
204
204
dic .update (
@@ -248,12 +248,12 @@ def depurar_xml(client):
248
248
f .write (client .xml_request )
249
249
f .close ()
250
250
f = open ("response-%s.xml" % fecha , "w" )
251
- f .write (client .xml_response )
251
+ f .write (client .xml_response . decode () )
252
252
f .close ()
253
253
254
254
255
255
def main ():
256
- global HOMO , DEBUG , XML , CONFIG_FILE
256
+ global HOMO , DEBUG , XML , CONFIG_FILE , wsaa
257
257
if "/ayuda" in sys .argv :
258
258
print (LICENCIA )
259
259
print ()
@@ -274,7 +274,7 @@ def main():
274
274
print (" /dbf: lee y almacena la información en tablas DBF" )
275
275
print ()
276
276
print ("Ver rece.ini para parámetros de configuración (URL, certificados, etc.)" )
277
- sys . exit ( 0 )
277
+ return
278
278
279
279
if "/debug" in sys .argv :
280
280
DEBUG = True
@@ -290,7 +290,7 @@ def main():
290
290
if config .has_option ("WSAA" , "URL" ) and not HOMO :
291
291
wsaa_url = config .get ("WSAA" , "URL" )
292
292
else :
293
- wsaa_url = wsaa . WSAAURL
293
+ wsaa_url = None
294
294
if config .has_option ("WSBFE" , "URL" ) and not HOMO :
295
295
wsbfe_url = config .get ("WSBFE" , "URL" )
296
296
else :
@@ -320,7 +320,7 @@ def main():
320
320
if "/dummy" in sys .argv :
321
321
print ("Consultando estado de servidores..." )
322
322
print (ws .Dummy ())
323
- sys . exit ( 0 )
323
+ return
324
324
325
325
if "/formato" in sys .argv :
326
326
print ("Formato:" )
@@ -333,7 +333,7 @@ def main():
333
333
% (clave , comienzo , longitud , tipo )
334
334
)
335
335
comienzo += longitud
336
- sys . exit ( 0 )
336
+ return
337
337
338
338
# obteniendo el TA
339
339
from .wsaa import WSAA
@@ -393,25 +393,36 @@ def main():
393
393
394
394
if "/ult" in sys .argv :
395
395
print ("Consultar ultimo numero:" )
396
- tipo_cbte = int (input ("Tipo de comprobante: " ))
397
- punto_vta = int (input ("Punto de venta: " ))
396
+ i = sys .argv .index ("/ult" )
397
+ if i + 2 < len (sys .argv ):
398
+ tipo_cbte = int (sys .argv [i + 1 ])
399
+ punto_vta = int (sys .argv [i + 2 ])
400
+ else :
401
+ tipo_cbte = int (input ("Tipo de comprobante: " ))
402
+ punto_vta = int (input ("Punto de venta: " ))
398
403
ult_cbte = ws .GetLastCMP (tipo_cbte , punto_vta )
399
404
print ("Ultimo numero: " , ult_cbte )
400
405
print ("Fecha: " , ws .FechaCbte )
401
406
depurar_xml (ws .client )
402
- sys . exit ( 0 )
407
+ return
403
408
404
409
if "/id" in sys .argv :
405
410
ult_id = ws .GetLastID ()
406
411
print ("ID: " , ult_id )
407
412
depurar_xml (ws .client )
408
- sys . exit ( 0 )
413
+ return
409
414
410
415
if "/get" in sys .argv :
411
416
print ("Recuperar comprobante:" )
412
- tipo_cbte = int (input ("Tipo de comprobante: " ))
413
- punto_vta = int (input ("Punto de venta: " ))
414
- cbte_nro = int (input ("Numero de comprobante: " ))
417
+ i = sys .argv .index ("/get" )
418
+ if i + 3 < len (sys .argv ):
419
+ tipo_cbte = int (sys .argv [i + 1 ])
420
+ punto_vta = int (sys .argv [i + 2 ])
421
+ cbte_nro = int (sys .argv [i + 3 ])
422
+ else :
423
+ tipo_cbte = int (input ("Tipo de comprobante: " ))
424
+ punto_vta = int (input ("Punto de venta: " ))
425
+ cbte_nro = int (input ("Numero de comprobante: " ))
415
426
cae = ws .GetCMP (tipo_cbte , punto_vta , cbte_nro )
416
427
cbt = {
417
428
"fecha_cbte" : ws .FechaCbte ,
@@ -427,7 +438,7 @@ def main():
427
438
for k , v in list (cbt .items ()):
428
439
print ("%s = %s" % (k , v ))
429
440
depurar_xml (ws .client )
430
- sys . exit ( 0 )
441
+ return
431
442
432
443
f_entrada = f_salida = None
433
444
try :
@@ -445,7 +456,7 @@ def main():
445
456
f_salida .close ()
446
457
if XML :
447
458
depurar_xml (ws .client )
448
- sys . exit ( 0 )
459
+ return
449
460
450
461
except Exception as e :
451
462
print (str (e ).encode ("ascii" , "ignore" ))
0 commit comments