Skip to content

Commit

Permalink
Merge branch 'main' into coverage_receb1
Browse files Browse the repository at this point in the history
  • Loading branch information
reingart authored Mar 24, 2022
2 parents c3f0fb5 + 3a18835 commit 9000cf8
Show file tree
Hide file tree
Showing 184 changed files with 22,154 additions and 167 deletions.
8 changes: 1 addition & 7 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ omit =
*iibb*
*nsis*
*/padron.py
*pyemail*
*pyfepdf*
*pyi25*
*pyqr*
*rece1*
*recem*
*recet*
*recex1*
*formatos*
*rg3685*
*setup_win*
*sired*
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,20 @@ jobs:
python setup.py install
- name: Download certificate and private key
run: |
wget https://www.sistemasagiles.com.ar/soft/pyafipws/reingart2019.zip
wget "https://www.sistemasagiles.com.ar/soft/pyafipws/reingart2021.zip" -O reingart2019.zip
unzip reingart2019.zip
- name: Fix OpenSSL "dh key too small"
run: |
sudo cp .github/openssl.cnf /etc/ssl/openssl.cnf
- name: Copy rece.ini file
run: |
sudo cp conf/rece.ini rece.ini
- name: Copy wsltv.ini file
run: |
sudo cp conf/wsltv.ini wsltv.ini
- name: Copy wslsp.ini file
run: |
sudo cp conf/wslsp.ini wslsp.ini
- name: Test with pytest
run: |
pytest --html=report.html --self-contained-html
Expand Down
8 changes: 7 additions & 1 deletion conf/rece.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ ENTRADA=entrada.txt
SALIDA=salida.txt
##URL=https://servicios1.afip.gov.ar/wsfe/service.asmx

[WSFEXv1]
CUIT=20267565393
ENTRADA=entrada.txt
SALIDA=salida.txt
##URL=https://servicios1.afip.gov.ar/wsfe/service.asmx

[WSCT]
CUIT=20267565393
ENTRADA=entrada.txt
Expand Down Expand Up @@ -78,7 +84,7 @@ LOCALE=Spanish_Argentina.1252
FMT_CANTIDAD=0.4
FMT_PRECIO=0.3
CANT_POS=izq
ENTRADA=factura.txt
ENTRADA=facturas.txt
SALIDA=factura.pdf

[PDF]
Expand Down
12 changes: 12 additions & 0 deletions conf/wslsp.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[WSAA]
CERT = reingart.crt
PRIVATEKEY = reingart.key
## URL = https: //wsaa.afip.gov.ar/ws/services/LoginCms

[WSLSP]
CUIT = 20267565393
INPUT = invoices.csv
OUTPUT = OUTPUT.txt
ENTRADA=entrada.txt
SALIDA=salida.txt
## URL = https: //serviciosjava.afip.gob.ar/wslsp/LumService? Wsdl
12 changes: 12 additions & 0 deletions conf/wsltv.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[WSAA]
CERT = reingart.crt
PRIVATEKEY = reingart.key
## URL = https: //wsaa.afip.gov.ar/ws/services/LoginCms

[WSLTV]
CUIT = 20267565393
INPUT = invoices.csv
OUTPUT = OUTPUT.txt
ENTRADA=entrada.txt
SALIDA=salida.txt
## URL = https: //serviciosjava.afip.gob.ar/wsltv/LtvService? Wsdl
17 changes: 17 additions & 0 deletions formatos/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/python
# -*- coding: utf8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
# for more details.

"""Módulo para acceder a web services de la afip
"""
__author__ = "Mariano Reingart ([email protected])"
__copyright__ = "Copyright (C) 2008-2021 Mariano Reingart"
__license__ = "LGPL-3.0-or-later"
2 changes: 1 addition & 1 deletion formatos/formato_dbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

# definición del formato del archivo de intercambio:

from formato_txt import (
from .formato_txt import (
A,
N,
I,
Expand Down
4 changes: 2 additions & 2 deletions formatos/formato_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def leer(fn="entrada.json"):
return regs


def escribir(filas, fn="salida.json"):
def escribir(filas, fn="salida.json", **kwargs):
"Dado una lista de comprobantes (diccionarios), escribe JSON"
import codecs

Expand All @@ -46,6 +46,6 @@ def escribir(filas, fn="salida.json"):
jsonfile,
sort_keys=True,
indent=4,
encoding="utf-8",
**kwargs
)
jsonfile.close()
10 changes: 6 additions & 4 deletions formatos/formato_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
__license__ = "LGPL-3.0-or-later"

from decimal import Decimal
import sys

CHARSET = "latin1"

Expand Down Expand Up @@ -117,7 +118,7 @@
("imp_iva", 15, I),
("despacho", 20, A),
("u_mtx", 10, N),
("cod_mtx", 30, A),
("cod_mtx", 30, N),
("dato_a", 15, A),
("dato_b", 15, A),
("dato_c", 15, A),
Expand Down Expand Up @@ -229,8 +230,9 @@ def escribir_linea_txt(dic, formato):
valor = dic.get(clave, "")
if not isinstance(valor, basestring):
valor = str(valor)
if isinstance(valor, str):
valor = valor.encode(CHARSET, "replace")
if sys.version_info[0] < 3 :
if isinstance(valor, str):
valor = valor.encode(CHARSET, "replace")
if valor == "None":
valor = ""
if tipo == N and valor and valor != "NULL":
Expand All @@ -257,7 +259,7 @@ def escribir_linea_txt(dic, formato):

def leer(fn="entrada.txt"):
"Analiza un archivo TXT y devuelve un diccionario"
f_entrada = open(fn, "r")
f_entrada = open(fn, "rb")
try:
regs = []
reg = None
Expand Down
23 changes: 14 additions & 9 deletions pyemail.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ def Conectar(self, servidor, usuario=None, clave=None, puerto=25):
# inicio una sesión segura (TLS)
self.smtp.starttls()
if usuario and clave:
# convertir a string (hmac necesita string "bytes")
if isinstance(usuario, str):
usuario = usuario.encode("utf8")
if isinstance(clave, str):
clave = clave.encode("utf8")
if sys.version_info[0] < 3:
#convertir a string (hmac necesita string "bytes")
if isinstance(usuario, str):
usuario = usuario.encode("utf8")
if isinstance(clave, str):
clave = clave.encode("utf8")
self.smtp.login(usuario, clave)
return True
except Exception as e:
Expand Down Expand Up @@ -275,10 +276,14 @@ def main():
elif "/prueba" in sys.argv:
pyemail = PyEmail()
import getpass

usuario = input("usuario:")
clave = getpass.getpass("clave:")
ok = pyemail.Conectar("smtp.gmail.com", "reingart", clave, 587)
i = sys.argv.index("/prueba")
if i + 2 < len(sys.argv):
usuario = sys.argv[sys.argv.index("/prueba") + 1]
clave = sys.argv[sys.argv.index("/prueba") + 2]
else:
usuario = input("usuario:")
clave = getpass.getpass("clave:")
ok = pyemail.Conectar("smtp.gmail.com", usuario=usuario, clave=clave, puerto=587)
print("login ok?", ok, pyemail.Excepcion)
print(pyemail.Traceback)
ok = pyemail.Enviar(usuario, "prueba", usuario, "prueba!", None)
Expand Down
11 changes: 8 additions & 3 deletions pyfepdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ def GenerarPDF(self, archivo=""):

@utils.inicializar_y_capturar_excepciones_simple
def MostrarPDF(self, archivo, imprimir=False):
if sys.platform.startswith(("linux2", "java")):
if sys.platform.startswith(("linux2", "java", "linux")):
os.system("evince " "%s" "" % archivo)
else:
operation = imprimir and "print" or ""
Expand Down Expand Up @@ -1812,7 +1812,7 @@ def main():
# datos generales del encabezado:
tipo_cbte = 19 if "--expo" in sys.argv else 201
punto_vta = 4000
fecha = datetime.datetime.now().strftime("%Y%m%d")
fecha = '20210805' if "--fecha_prueba" in sys.argv else datetime.datetime.now().strftime("%Y%m%d")
concepto = 3
tipo_doc = 80
nro_doc = "30000000007"
Expand Down Expand Up @@ -2040,7 +2040,10 @@ def main():
archivo = conf_fact.get("entrada", "entrada.txt")
if DEBUG:
print("Escribiendo", archivo)
regs = formato_json.escribir([reg], archivo)
if sys.version_info[0] < 3:
regs = formato_json.escribir([reg], archivo, encoding='utf-8')
else:
regs = formato_json.escribir([reg], archivo)
else:
from .formatos import formato_txt

Expand Down Expand Up @@ -2096,5 +2099,7 @@ def main():
if "--mostrar" in sys.argv:
fepdf.MostrarPDF(archivo=salida, imprimir="--imprimir" in sys.argv)

return fepdf

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion pyi25.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def main():

if not "--mostrar" in sys.argv:
pass
elif sys.platform == "linux2":
elif sys.platform == "linux2" or sys.platform == "linux":
os.system("eog " "%s" "" % archivo)
else:
os.startfile(archivo)
Expand Down
12 changes: 7 additions & 5 deletions pyqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

"Módulo para generar códigos QR"
from __future__ import print_function

from __future__ import unicode_literals
from builtins import object

__author__ = "Mariano Reingart <[email protected]>"
Expand Down Expand Up @@ -120,7 +120,7 @@ def GenerarImagen(

# convertir a representación json y codificar en base64:
datos_cmp_json = json.dumps(datos_cmp)
url = self.URL % (base64.b64encode(datos_cmp_json))
url = self.URL % (base64.b64encode(datos_cmp_json.encode('ascii')).decode('ascii'))

qr = qrcode.QRCode(
version=self.qr_ver,
Expand Down Expand Up @@ -171,7 +171,7 @@ def main():
tipo_doc_rec,
nro_doc_rec,
tipo_cod_aut,
cod_aut,
cod_aut
) = args
else:
ver = 1
Expand Down Expand Up @@ -257,10 +257,12 @@ def main():

if not "--mostrar" in sys.argv:
pass
elif sys.platform == "linux2":
elif sys.platform == "linux2" or sys.platform == "linux":
os.system("eog " "%s" "" % pyqr.Archivo)
else:
os.startfile(pyqr.archivo)
os.startfile(pyqr.Archivo)

return url

if __name__ == "__main__":
main()
Loading

0 comments on commit 9000cf8

Please sign in to comment.