@@ -198,7 +198,7 @@ def autorizar(ws, entrada, salida):
198198 if DEBUG :
199199 print ("\n " .join (["%s='%s'" % (k , v ) for k , v in list (ws .factura .items ())]))
200200 print ("id:" , encabezado ["id" ])
201- if not DEBUG or input ( "Facturar?" ) == "S" :
201+ if not DEBUG :
202202 cae = ws .Authorize (encabezado ["id" ])
203203 dic = ws .factura
204204 dic .update (
@@ -248,12 +248,12 @@ def depurar_xml(client):
248248 f .write (client .xml_request )
249249 f .close ()
250250 f = open ("response-%s.xml" % fecha , "w" )
251- f .write (client .xml_response )
251+ f .write (client .xml_response . decode () )
252252 f .close ()
253253
254254
255255def main ():
256- global HOMO , DEBUG , XML , CONFIG_FILE
256+ global HOMO , DEBUG , XML , CONFIG_FILE , wsaa
257257 if "/ayuda" in sys .argv :
258258 print (LICENCIA )
259259 print ()
@@ -274,7 +274,7 @@ def main():
274274 print (" /dbf: lee y almacena la información en tablas DBF" )
275275 print ()
276276 print ("Ver rece.ini para parámetros de configuración (URL, certificados, etc.)" )
277- sys . exit ( 0 )
277+ return
278278
279279 if "/debug" in sys .argv :
280280 DEBUG = True
@@ -290,7 +290,7 @@ def main():
290290 if config .has_option ("WSAA" , "URL" ) and not HOMO :
291291 wsaa_url = config .get ("WSAA" , "URL" )
292292 else :
293- wsaa_url = wsaa . WSAAURL
293+ wsaa_url = None
294294 if config .has_option ("WSBFE" , "URL" ) and not HOMO :
295295 wsbfe_url = config .get ("WSBFE" , "URL" )
296296 else :
@@ -320,7 +320,7 @@ def main():
320320 if "/dummy" in sys .argv :
321321 print ("Consultando estado de servidores..." )
322322 print (ws .Dummy ())
323- sys . exit ( 0 )
323+ return
324324
325325 if "/formato" in sys .argv :
326326 print ("Formato:" )
@@ -333,7 +333,7 @@ def main():
333333 % (clave , comienzo , longitud , tipo )
334334 )
335335 comienzo += longitud
336- sys . exit ( 0 )
336+ return
337337
338338 # obteniendo el TA
339339 from .wsaa import WSAA
@@ -393,25 +393,36 @@ def main():
393393
394394 if "/ult" in sys .argv :
395395 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: " ))
398403 ult_cbte = ws .GetLastCMP (tipo_cbte , punto_vta )
399404 print ("Ultimo numero: " , ult_cbte )
400405 print ("Fecha: " , ws .FechaCbte )
401406 depurar_xml (ws .client )
402- sys . exit ( 0 )
407+ return
403408
404409 if "/id" in sys .argv :
405410 ult_id = ws .GetLastID ()
406411 print ("ID: " , ult_id )
407412 depurar_xml (ws .client )
408- sys . exit ( 0 )
413+ return
409414
410415 if "/get" in sys .argv :
411416 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: " ))
415426 cae = ws .GetCMP (tipo_cbte , punto_vta , cbte_nro )
416427 cbt = {
417428 "fecha_cbte" : ws .FechaCbte ,
@@ -427,7 +438,7 @@ def main():
427438 for k , v in list (cbt .items ()):
428439 print ("%s = %s" % (k , v ))
429440 depurar_xml (ws .client )
430- sys . exit ( 0 )
441+ return
431442
432443 f_entrada = f_salida = None
433444 try :
@@ -445,7 +456,7 @@ def main():
445456 f_salida .close ()
446457 if XML :
447458 depurar_xml (ws .client )
448- sys . exit ( 0 )
459+ return
449460
450461 except Exception as e :
451462 print (str (e ).encode ("ascii" , "ignore" ))
0 commit comments