Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cumulative updates from develop (python3 conversion) #110

Merged
merged 6 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [2.7, 3.9, 3.11]
python-version: [3.9, 3.11]

steps:
- uses: actions/checkout@v2
Expand Down
7 changes: 7 additions & 0 deletions formatos/formato_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"numero_cotizacion": str,
"numero_remito": str,
"ape": str,
"permiso_existente": str,
"incoterms": str,
"detalleincoterms": str,
"destinocmp": int,
Expand Down Expand Up @@ -188,6 +189,12 @@
"fecha_serv_desde": "fechaservdesde",
"fecha_serv_hasta": "fechaservhasta",
"fecha_venc_pago": "fechavencpago",
"tipo_expo": "concepto",
"incoterms": "incoterms",
"incoterms_ds": "detalleincoterms",
"pais_dst_cmp": "destinocmp",
"idioma_cbte": "idioma",
"permiso_existente": "permiso_existente",
"obs_generales": "otrosdatosgenerales",
"obs_comerciales": "otrosdatoscomerciales",
"resultado": "resultado",
Expand Down
12 changes: 9 additions & 3 deletions ws_sr_padron.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
from builtins import next

__author__ = "Mariano Reingart <[email protected]>"
__copyright__ = "Copyright (C) 2017 Mariano Reingart"
__license__ = "GPL 3.0"
__version__ = "3.04e"
__copyright__ = "Copyright (C) 2017-2023 Mariano Reingart"
__license__ = "LGPL-3.0-or-later"
__version__ = "3.05a"

import csv
import datetime
Expand All @@ -42,6 +42,7 @@
abrir_conf,
norm,
SoapFault,
safe_console,
)
from configparser import SafeConfigParser
from pyafipws.padron import TIPO_CLAVE, PROVINCIAS
Expand Down Expand Up @@ -97,6 +98,7 @@ class WSSrPadronA4(BaseWS):
"nro_doc",
"tipo_persona",
"estado",
"es_sucesion",
"impuestos",
"actividades",
"direccion",
Expand Down Expand Up @@ -125,6 +127,7 @@ def inicializar(self):
self.tipo_persona = "" # FISICA o JURIDICA
self.tipo_doc = self.nro_doc = 0
self.estado = "" # ACTIVO
self.es_sucesion = ""
self.denominacion = ""
self.direccion = self.localidad = self.provincia = self.cod_postal = ""
self.domicilios = []
Expand Down Expand Up @@ -274,6 +277,7 @@ def Consultar(self, id_persona):
self.nro_doc = data.get("idPersona")
self.cuit = self.nro_doc
self.estado = data.get("estadoClave")
self.es_sucesion = data.get("esSucesion")
if not "razonSocial" in data:
self.denominacion = ", ".join(
[data.get("apellido", ""), data.get("nombre", "")]
Expand Down Expand Up @@ -320,6 +324,7 @@ def main():
global CONFIG_FILE

DEBUG = "--debug" in sys.argv
safe_console()

if "--constancia" in sys.argv:
padron = WSSrPadronA5()
Expand Down Expand Up @@ -427,6 +432,7 @@ def main():
print("Denominacion:", padron.denominacion)
print("Tipo:", padron.tipo_persona, padron.tipo_doc, padron.nro_doc)
print("Estado:", padron.estado)
print("Es Sucesion:", padron.es_sucesion)
print("Direccion:", padron.direccion)
print("Localidad:", padron.localidad)
print("Provincia:", padron.provincia)
Expand Down
55 changes: 29 additions & 26 deletions wsfev1.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
from past.builtins import basestring

__author__ = "Mariano Reingart <[email protected]>"
__copyright__ = "Copyright (C) 2010-2021 Mariano Reingart"
__copyright__ = "Copyright (C) 2010-2023 Mariano Reingart"
__license__ = "LGPL-3.0-or-later"
__version__ = "3.26a"
__version__ = "3.27c"

import datetime
import decimal
Expand Down Expand Up @@ -140,9 +140,10 @@ class WSFEv1(BaseWS):
_reg_class_spec_ = "pyafipws.wsfev1.WSFEv1"

if TYPELIB:
_typelib_guid_ = '{8AE2BD1D-A216-4E98-95DB-24A11225EF67}'
_typelib_guid_ = "{8AE2BD1D-A216-4E98-95DB-24A11225EF67}"
_typelib_version_ = 1, 26
_com_interfaces_ = ['IWSFEv1']
_com_interfaces_ = ["IWSFEv1"]
##_reg_class_spec_ = "wsfev1.WSFEv1"

# Variables globales para BaseWS:
HOMO = HOMO
Expand Down Expand Up @@ -329,8 +330,8 @@ def AgregarComprador(self, doc_tipo=80, doc_nro=0, porcentaje=100.00, **kwarg):

def AgregarActividad(self, actividad_id=0, **kwarg):
"Agrego actividad a una factura (interna)"
op = { 'actividad_id': actividad_id }
self.factura['actividades'].append(op)
act = {"actividad_id": actividad_id}
self.factura["actividades"].append(act)
return True

def ObtenerCampoFactura(self, *campos):
Expand Down Expand Up @@ -381,9 +382,6 @@ def CAESolicitar(self):
"FchServDesde": f.get("fecha_serv_desde"),
"FchServHasta": f.get("fecha_serv_hasta"),
"FchVtoPago": f.get("fecha_venc_pago"),
"FchServDesde": f.get("fecha_serv_desde"),
"FchServHasta": f.get("fecha_serv_hasta"),
"FchVtoPago": f["fecha_venc_pago"],
"MonId": f["moneda_id"],
"MonCotiz": f["moneda_ctz"],
"PeriodoAsoc": {
Expand Down Expand Up @@ -456,7 +454,7 @@ def CAESolicitar(self):
"Actividades": [
{
"Actividad": {
'Id': actividad['actividad_id'],
"Id": actividad["actividad_id"],
}
}
for actividad in f["actividades"]
Expand Down Expand Up @@ -638,9 +636,9 @@ def CompConsultar(self, tipo_cbte, punto_vta, cbte_nro, reproceso=False):
}
copia = resultget.copy()
# TODO: ordenar / convertir opcionales (por ahora no se verifican)
del verificaciones['Opcionales']
if 'Opcionales' in copia:
del copia['Opcionales']
del verificaciones["Opcionales"]
if "Opcionales" in copia:
del copia["Opcionales"]
verifica(verificaciones, copia, difs)
if difs:
print("Diferencias:", difs)
Expand Down Expand Up @@ -802,9 +800,6 @@ def CAESolicitarX(self):
"FchServDesde": f.get("fecha_serv_desde"),
"FchServHasta": f.get("fecha_serv_hasta"),
"FchVtoPago": f.get("fecha_venc_pago"),
"FchServDesde": f.get("fecha_serv_desde"),
"FchServHasta": f.get("fecha_serv_hasta"),
"FchVtoPago": f["fecha_venc_pago"],
"MonId": f["moneda_id"],
"MonCotiz": f["moneda_ctz"],
"PeriodoAsoc": {
Expand Down Expand Up @@ -1034,9 +1029,6 @@ def CAEARegInformativo(self):
"FchServDesde": f.get("fecha_serv_desde"),
"FchServHasta": f.get("fecha_serv_hasta"),
"FchVtoPago": f.get("fecha_venc_pago"),
"FchServDesde": f.get("fecha_serv_desde"),
"FchServHasta": f.get("fecha_serv_hasta"),
"FchVtoPago": f["fecha_venc_pago"],
"MonId": f["moneda_id"],
"MonCotiz": f["moneda_ctz"],
"PeriodoAsoc": {
Expand Down Expand Up @@ -1095,6 +1087,15 @@ def CAEARegInformativo(self):
for opcional in f["opcionales"]
]
or None,
"Actividades": [
{
"Actividad": {
"Id": actividad["actividad_id"],
}
}
for actividad in f["actividades"]
]
or None,
"CAEA": f["caea"],
"CbteFchHsGen": f.get("fecha_hs_gen"),
}
Expand Down Expand Up @@ -1301,13 +1302,15 @@ def ParamGetPtosVenta(self, sep="|"):

@inicializar_y_capturar_excepciones
def ParamGetActividades(self, sep="|"):
"Recuperador de valores referenciales de códigos de Actividades"
"Recuperador de valores referenciales de c�digos de Actividades"
ret = self.client.FEParamGetActividades(
Auth={'Token': self.Token, 'Sign': self.Sign, 'Cuit': self.Cuit},
)
res = ret['FEParamGetActividades']
return [(u"%(Id)s\t%(Orden)s\t%(Desc)s" % p['ActividadesTipo']).replace("\t", sep)
for p in res['ResultGet']]
Auth={"Token": self.Token, "Sign": self.Sign, "Cuit": self.Cuit},
)
res = ret["FEParamGetActividadesResult"]
return [
("%(Id)s\t%(Orden)s\t%(Desc)s" % p["ActividadesTipo"]).replace("\t", sep)
for p in res["ResultGet"]
]


def p_assert_eq(a, b):
Expand Down Expand Up @@ -1500,7 +1503,7 @@ def main():
if "--rg4540" in sys.argv:
wsfev1.AgregarPeriodoComprobantesAsociados("20200101", "20200131")

if '--rg5259' in sys.argv:
if "--rg5259" in sys.argv:
wsfev1.AgregarActividad(960990)

# agregar la factura creada internamente para solicitud múltiple:
Expand Down
75 changes: 68 additions & 7 deletions wsfexv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
from builtins import str

__author__ = "Mariano Reingart ([email protected])"
__copyright__ = "Copyright (C) 2011-2021 Mariano Reingart"
__copyright__ = "Copyright (C) 2011-2023 Mariano Reingart"
__license__ = "LGPL-3.0-or-later"
__version__ = "3.10a"
__version__ = "3.11a"

import datetime
import decimal
Expand All @@ -44,6 +44,7 @@ class WSFEXv1(BaseWS):
"GetCMP",
"AgregarPermiso",
"AgregarCmpAsoc",
"AgregarActividad",
"GetParamMon",
"GetParamTipoCbte",
"GetParamTipoExpo",
Expand All @@ -67,6 +68,7 @@ class WSFEXv1(BaseWS):
"GetParametro",
"GetLastCMP",
"GetLastID",
"GetParamActividades",
"Dummy",
"Conectar",
"SetTicketAcceso",
Expand Down Expand Up @@ -192,6 +194,7 @@ def CrearFactura(
"cbtes_asoc": [],
"permisos": [],
"detalles": [],
"actividades": [],
}
self.factura = fact

Expand Down Expand Up @@ -237,6 +240,12 @@ def AgregarCmpAsoc(
)
return True

def AgregarActividad(self, actividad_id=0, **kwarg):
"Agrego actividad a una factura (interna)"
act = {"actividad_id": actividad_id}
self.factura["actividades"].append(act)
return True

@inicializar_y_capturar_excepciones
def Authorize(self, id):
"Autoriza la factura cargada en memoria"
Expand Down Expand Up @@ -304,6 +313,16 @@ def Authorize(self, id):
}
for d in f["detalles"]
],
"Actividades": f["actividades"]
and [
{
"Actividad": {
"Id": a["actividad_id"],
}
}
for a in f["actividades"]
]
or None,
},
)

Expand Down Expand Up @@ -748,23 +767,57 @@ def GetParamPtosVenta(self, sep="|"):
res = ret["FEXGetPARAM_PtoVentaResult"].get("FEXResultGet")
ret = []
for pu in res:
u = pu["ClsFEXResponse_PtoVenta"]
p = pu["ClsFEXResponse_PtoVenta"]
try:
r = {
"nro": u.get("Pve_Nro"),
"baja": u.get("Pve_FchBaj"),
"bloqueado": u.get("Pve_Bloqueado"),
"nro": p.get("Pve_Nro"),
"baja": p.get("Pve_FchBaj"),
"bloqueado": p.get("Pve_Bloqueado"),
}
except Exception as e:
print(e)
ret.append(r)
return [
(u"%(nro)s\tBloqueado:%(bloqueado)s\tFchBaja:%(baja)s" % r).replace(
("%(nro)s\tBloqueado:%(bloqueado)s\tFchBaja:%(baja)s" % r).replace(
"\t", sep
)
for r in ret
]

@inicializar_y_capturar_excepciones
def GetParamActividades(self, sep="|"):
"Recuperar lista de valores referenciales de códigos de Idiomas"
ret = self.client.FEXGetPARAM_Actividades(
Auth={
"Token": self.Token,
"Sign": self.Sign,
"Cuit": self.Cuit,
}
)
result = ret["FEXGetPARAM_ActividadesResult"]
self.__analizar_errores(result)

ret = []
for u in result.get("FEXResultGet", []):
u = u["ClsFEXResponse_ActividadTipo"]
try:
r = {
"codigo": u.get("Id"),
"ds": u.get("Desc"),
"orden": u.get("Orden"),
}
except Exception as e:
print(e)

ret.append(r)
if sep:
return [
("\t%(codigo)s\t%(ds)s\t%(orden)s\t" % it).replace("\t", sep)
for it in ret
]
else:
return ret


class WSFEX(WSFEXv1):
"Wrapper para retrocompatibilidad con WSFEX"
Expand Down Expand Up @@ -936,6 +989,8 @@ def main():
cbteasoc_tipo, cbteasoc_pto_vta, cbteasoc_nro, cbteasoc_cuit
)

ok = wsfexv1.AgregarActividad(1234)

##id = "99000000000100" # número propio de transacción
# obtengo el último ID y le adiciono 1
# (advertencia: evitar overflow y almacenar!)
Expand Down Expand Up @@ -1039,6 +1094,12 @@ def main():
for r in ret:
print("||%(codigo)s||%(ds)s||" % r)

if "--rg5259" in sys.argv:
print("=== Actividades ===")
ret = wsfexv1.GetParamActividades(sep=False)
for r in ret:
print("||%(codigo)s||%(ds)s||" % r)

if "--ctz" in sys.argv:
print(wsfexv1.GetParamCtz("DOL"))

Expand Down
Loading
Loading