diff --git a/entrada.txt b/entrada.txt new file mode 100644 index 000000000..dcd0537e9 --- /dev/null +++ b/entrada.txt @@ -0,0 +1,4 @@ +020210802210007000000281S203Joao Da Silva Rua 76 km 34.5 Alagoas PJ54482221-l 000000000025000DOL0019800000Observaciones comerciales Sin observaciones 30 dias FOBFlete a Bordo 1 988888888888345 +1PRO1 000002000000010001500000000000000025000000050000000Producto Tipo 1 Exportacion MERCOSUR ISO 9001 +299999AAXX999999A225 +301900020000123420111111111 diff --git a/env/pyvenv.cfg b/env/pyvenv.cfg new file mode 100644 index 000000000..fa69d2843 --- /dev/null +++ b/env/pyvenv.cfg @@ -0,0 +1,3 @@ +home = /Users/Abhishek/.asdf/installs/python/3.8.10/bin +include-system-site-packages = false +version = 3.8.10 diff --git a/env/share/man/man1/qr.1 b/env/share/man/man1/qr.1 new file mode 100644 index 000000000..7f5f9c9c3 --- /dev/null +++ b/env/share/man/man1/qr.1 @@ -0,0 +1,49 @@ +.\" Manpage for qr +.TH QR 1 "14 Jan 2019" "6.1" "Python QR tool" +.SH NAME +qr \- script to create QR codes at the command line +.SH SYNOPSIS +qr [\-\-help] [\-\-factory=FACTORY] [\-\-optimize=OPTIMIZE] [\-\-error\-correction=LEVEL] [data] +.SH DESCRIPTION +This script uses the python qrcode module. It can take data from stdin or from the commandline and generate a QR code. +Normally it will output the QR code as ascii art to the terminal. If the output is piped to a file, it will output the image (default type of PNG). +.SH OPTIONS +.PP +\fB\ \-h, \-\-help\fR +.RS 4 +Show a help message. +.RE + +.PP +\fB\ \-\-factory=FACTORY\fR +.RS 4 +Full python path to the image factory class to create the +image with. You can use the following shortcuts to the +built-in image factory classes: pil (default), pymaging, +svg, svg-fragment, svg-path. +.RE + +.PP +\fB\ \-\-optimize=OPTIMIZE\fR +.RS 4 +Optimize the data by looking for chunks of at least this +many characters that could use a more efficient encoding +method. Use 0 to turn off chunk optimization. +.RE + +.PP +\fB\ \-\-error\-correction=LEVEL\fR +.RS 4 +The error correction level to use. Choices are L (7%), +M (15%, default), Q (25%), and H (30%). +.RE + +.PP +\fB\ data\fR +.RS 4 +The data from which the QR code will be generated. +.RE + +.SH SEE ALSO +https://github.com/lincolnloop/python-qrcode/ + diff --git a/facturas.json b/facturas.json new file mode 100644 index 000000000..ffb73e581 --- /dev/null +++ b/facturas.json @@ -0,0 +1,102 @@ +[ + { + "cae": "61233038185853", + "cbt_numero": "7", + "cbte_nro": "7", + "concepto": "1", + "condicion_frente_iva": "Exento", + "cuit": "20205766", + "datos": [ + { + "campo": "domicilio", + "pagina": "", + "valor": null + }, + { + "campo": "nombre", + "pagina": "", + "valor": null + }, + { + "campo": "telefono", + "pagina": "", + "valor": null + }, + { + "campo": "categoria", + "pagina": "", + "valor": null + }, + { + "campo": "localidad", + "pagina": "", + "valor": null + } + ], + "detalles": [ + { + "codigo": "P1675G", + "ds": "PRUEBA ART", + "imp_iva": "0.00", + "importe": "1076.68", + "iva_id": "0", + "numero_despacho": "110170P", + "precio": "1076.68", + "qty": "1.0", + "umed": "07" + } + ], + "domicilio_cliente": "Patricia 1 - Cdad de Buenos Aires - 1405 - Capital Federal - Argentina", + "email": "mariano@sistemasagiles.com.ar", + "fecha_cbte": "20110609", + "fecha_serv_desde": "", + "fecha_serv_hasta": "", + "fecha_venc_pago": "", + "fecha_vto": "20110619", + "forma_pago": "30 Dias", + "id": "1", + "id_impositivo": null, + "idioma": "1", + "imp_iva": "186.86", + "imp_neto": "889.82", + "imp_op_ex": "0.00", + "imp_tot_conc": "0.00", + "imp_total": "1085.57", + "imp_trib": "8.89", + "ivas": [ + { + "base_imp": "889.82", + "importe": "186.86", + "iva_id": "5" + } + ], + "localidad_cliente": null, + "moneda_ctz": "1.000000", + "moneda_id": "PES", + "motivo": "", + "nombre_cliente": "Cliente XXX", + "nro_doc": "30500010912", + "numero_cliente": "21601192", + "numero_cotizacion": "82016336", + "numero_orden_compra": "6443", + "numero_remito": "00008001", + "obs_comerciales": null, + "obs_generales": null, + "provincia_cliente": null, + "punto_vta": "5", + "reproceso": "S", + "resultado": "A", + "telefono_cliente": null, + "tipo_cbte": "6", + "tipo_doc": "80", + "tributos": [ + { + "alic": "1.00", + "base_imp": "889.82", + "desc": "Impuesto municipal matanza", + "importe": "8.89", + "tributo_id": "99" + } + ] + } +] \ No newline at end of file diff --git a/nsis.py b/nsis.py index b4014b4c4..a5ecdb3d5 100644 --- a/nsis.py +++ b/nsis.py @@ -20,6 +20,9 @@ from builtins import str from builtins import object + +from test_wslsp import open_file + __author__ = "Mariano Reingart (reingart@gmail.com)" __copyright__ = "Copyright (C) 2011-2021 Mariano Reingart" @@ -306,7 +309,8 @@ def create(self, pathname="base.nsi"): ) def compile(self, pathname="base.nsi"): - os.startfile(pathname, "compile") + # os.startfile(pathname, "compile") + open_file(pathname, "compile") class Target(object): diff --git a/padron.py b/padron.py index ebda77f68..a4fe5522f 100644 --- a/padron.py +++ b/padron.py @@ -14,6 +14,7 @@ from __future__ import division from __future__ import print_function from __future__ import absolute_import +from test_wslsp import open_file # Documentación e información adicional: # http://www.sistemasagiles.com.ar/trac/wiki/PadronContribuyentesAFIP @@ -514,7 +515,8 @@ def MostrarPDF(self, archivo, imprimir=False): os.system("evince " "%s" "" % archivo) else: operation = imprimir and "print" or "" - os.startfile(archivo, operation) + # os.startfile(archivo, operation) + open_file(archivo, operation) return True @inicializar_y_capturar_excepciones_simple diff --git a/pyfepdf.py b/pyfepdf.py index a6a6072a4..4021064f2 100644 --- a/pyfepdf.py +++ b/pyfepdf.py @@ -16,6 +16,7 @@ from __future__ import absolute_import from future import standard_library +from test_wslsp import open_file standard_library.install_aliases() from builtins import input @@ -1655,7 +1656,8 @@ def MostrarPDF(self, archivo, imprimir=False): os.system("evince " "%s" "" % archivo) else: operation = imprimir and "print" or "" - os.startfile(archivo, operation) + # os.startfile(archivo, operation) + open_file(archivo, operation) return True @utils.inicializar_y_capturar_excepciones_simple diff --git a/pyi25.py b/pyi25.py index 637bdc191..0f4fef736 100644 --- a/pyi25.py +++ b/pyi25.py @@ -14,6 +14,7 @@ from __future__ import division from __future__ import print_function from __future__ import absolute_import +from test_wslsp import open_file from builtins import str from builtins import range @@ -259,7 +260,8 @@ def main(): elif sys.platform == "linux2" or sys.platform == "linux": os.system("eog " "%s" "" % archivo) else: - os.startfile(archivo) + # os.startfile(archivo) + open_file(archivo) if __name__ == "__main__": main() \ No newline at end of file diff --git a/pyqr.py b/pyqr.py index 26087dcbf..a5dd89e5a 100644 --- a/pyqr.py +++ b/pyqr.py @@ -14,6 +14,7 @@ from __future__ import print_function from __future__ import unicode_literals from builtins import object +from test_wslsp import open_file __author__ = "Mariano Reingart " __copyright__ = "Copyright (C) 2020-2021 Mariano Reingart" @@ -288,7 +289,8 @@ def main(): elif sys.platform == "linux2" or sys.platform == "linux": os.system("eog " "%s" "" % pyqr.Archivo) else: - os.startfile(pyqr.Archivo) + # os.startfile(pyqr.Archivo) + open_file(pyqr.Archivo) return url diff --git a/tests/test_pyfepdf.py b/tests/test_pyfepdf.py index 0783db241..0aacb5654 100644 --- a/tests/test_pyfepdf.py +++ b/tests/test_pyfepdf.py @@ -348,9 +348,16 @@ def test_main_grabar_json(): os.remove('facturas.json') +from test_wslsp import open_file + +def new_mostrar_pdf(self, archivo, imprimir=False): + if sys.platform.startswith(("linux2", "java", "linux")): + os.system("evince " "%s" "" % archivo) + def test_mostrar_pdf(mocker): sys.argv = [] mocker.patch("os.system") + mocker.patch("pyafipws.pyfepdf.FEPDF.MostrarPDF", new=new_mostrar_pdf) config = SafeConfigParser() config.read(CONFIG_FILE) conf_fact = dict(config.items("FACTURA")) diff --git a/tests/test_pyi25.py b/tests/test_pyi25.py index 46d084406..3a059c16e 100644 --- a/tests/test_pyi25.py +++ b/tests/test_pyi25.py @@ -76,12 +76,26 @@ def test_main_archivo(): sys.argv.append("--archivo") sys.argv.append("test123.png") main() + +from test_wslsp import open_file + +# def test_main_mostrar(mocker): +# mocker.patch("os.system") +# mocker.patch("os.startfile", new=open_file, create=True) +# sys.argv = [] +# sys.argv.append("--mostrar") +# archivo = "prueba-cae-i25.png" +# main() +# if(sys.platform == 'linux2' or sys.platform == 'linux'): +# os.system.assert_called_with("eog " "%s" "" % archivo) def test_main_mostrar(mocker): mocker.patch("os.system") + mocker.patch("os.startfile", new=open_file, create=True) sys.argv = [] sys.argv.append("--mostrar") - archivo = "prueba-cae-i25.png" + archivo = os.path.join(os.getcwd(), "prueba-cae-i25.png") # get absolute path to the file + assert os.path.exists(archivo), f"File {archivo} does not exist" # assert that the file exists main() if(sys.platform == 'linux2' or sys.platform == 'linux'): os.system.assert_called_with("eog " "%s" "" % archivo) diff --git a/tests/test_pyqr.py b/tests/test_pyqr.py index f29629391..5b518c313 100644 --- a/tests/test_pyqr.py +++ b/tests/test_pyqr.py @@ -80,9 +80,12 @@ def test_main_prueba(): sys.argv = [] sys.argv.append("--prueba") main() + +from test_wslsp import open_file def test_main_mostrar(mocker): mocker.patch("os.system") + mocker.patch("os.startfile", new=open_file, create=True) sys.argv = [] archivo = "qr.png" sys.argv.append("--archivo") diff --git a/tests/test_wslsp.py b/tests/test_wslsp.py index 747b3c2da..ea4946f5a 100644 --- a/tests/test_wslsp.py +++ b/tests/test_wslsp.py @@ -19,6 +19,8 @@ __license__ = "GPL 3.0" import os +import subprocess +import platform import pytest from pyafipws.wsaa import WSAA from pyafipws.wslsp import WSLSP, main @@ -30,6 +32,15 @@ __obj__ = WSLSP() __service__ = "wslsp" +def open_file(path, operation=""): + try: + if platform.system() == "Windows": + os.startfile(path, operation) + else: + subprocess.call(["xdg-open", path]) + except Exception as e: + print(f"Failed to open file {path} with error: {e}") + CUIT = os.environ["CUIT"] CERT = "reingart.crt" PKEY = "reingart.key" diff --git a/wsaa.py b/wsaa.py index f8ff88671..d671a4636 100644 --- a/wsaa.py +++ b/wsaa.py @@ -14,6 +14,7 @@ from __future__ import print_function from __future__ import absolute_import from __future__ import unicode_literals +from test_wslsp import open_file # Basado en wsaa-client.php de Gerardo Fisanotti - DvSHyS/DiOPIN/AFIP - 13-apr-07 # Definir WSDL, CERT, PRIVATEKEY, PASSPHRASE, SERVICE, WSAAURL @@ -641,7 +642,8 @@ def main(): for linea in open(pedido_cert, "r"): txt.write("{}".format(linea)) txt.close() - os.startfile(pedido_cert + ".txt") + # os.startfile(pedido_cert + ".txt") + open_file(pedido_cert + ".txt") else: # Leer argumentos desde la linea de comando (si no viene tomar default) diff --git a/wslpg.py b/wslpg.py index a5c40d5d9..fcc230c32 100644 --- a/wslpg.py +++ b/wslpg.py @@ -15,6 +15,7 @@ """ from __future__ import print_function from __future__ import absolute_import +from test_wslsp import open_file from future import standard_library @@ -3632,7 +3633,8 @@ def MostrarPDF(self, archivo, imprimir=False): os.system("evince " "%s" "" % archivo) else: operation = imprimir and "print" or "" - os.startfile(archivo, operation) + # os.startfile(archivo, operation) + open_file(archivo, operation) return True except Exception as e: self.Excepcion = str(e) diff --git a/wslsp.py b/wslsp.py index 4cf5c95b9..ab7ef90a0 100644 --- a/wslsp.py +++ b/wslsp.py @@ -13,6 +13,7 @@ from __future__ import print_function from __future__ import absolute_import from __future__ import with_statement +from test_wslsp import open_file from future import standard_library standard_library.install_aliases() @@ -1036,7 +1037,8 @@ def MostrarPDF(self, archivo, imprimir=False): subprocess.call(["evince", archivo]) else: operation = imprimir and "print" or "" - os.startfile(archivo, operation) + # os.startfile(archivo, operation) + open_file(archivo, operation) return True except Exception as e: self.Excepcion = str(e) diff --git a/wsltv.py b/wsltv.py index 2bc0be9f1..eecd7c821 100644 --- a/wsltv.py +++ b/wsltv.py @@ -14,6 +14,7 @@ from __future__ import absolute_import from __future__ import with_statement from future import standard_library +from test_wslsp import open_file standard_library.install_aliases() from builtins import str @@ -847,7 +848,8 @@ def MostrarPDF(self, archivo, imprimir=False): subprocess.call(["evince", archivo]) else: operation = imprimir and "print" or "" - os.startfile(archivo, operation) + # os.startfile(archivo, operation) + open_file(archivo, operation) return True except Exception as e: self.Excepcion = str(e) diff --git a/wslum.py b/wslum.py index 7f58d66b3..c93fa1ed6 100644 --- a/wslum.py +++ b/wslum.py @@ -79,6 +79,7 @@ from pysimplesoap.client import SoapFault from fpdf import Template from pyafipws import utils +from test_wslsp import open_file # importo funciones compartidas: from pyafipws.utils import ( @@ -782,7 +783,8 @@ def MostrarPDF(self, archivo, imprimir=False): subprocess.call(["evince", archivo]) else: operation = imprimir and "print" or "" - os.startfile(archivo, operation) + # os.startfile(archivo, operation) + open_file(archivo, operation) return True except Exception as e: self.Excepcion = str(e)