Skip to content

Commit 486a9c3

Browse files
authored
Merge pull request #121 from PyAr/main-dev-jun-2023
Cumulative updates from develop (python3 conversion): Changelog: * WSPadron: agrego es_sucesion * WSRemHarina: ajustes acumulados * WSFEXv1: actividades (cambios acumulados) * WSMTX: actividades (cambios acumulados) * WSFEv1: actividades (cambios acumulados 28-Mar) * PyRECE: agrego campos WSFEXv1 Commands used to convert from python 2.7 and fix coding style / unicode: * 2to3 -w file.py * python -m black file.py * iconv -f iso-8859-1 -t utf-8 < file_new.py > file.py
2 parents e08c9d1 + 01c50ef commit 486a9c3

File tree

10 files changed

+264
-105
lines changed

10 files changed

+264
-105
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: [2.7, 3.9, 3.11]
19+
python-version: [3.9, 3.11]
2020

2121
steps:
2222
- uses: actions/checkout@v2

.github/workflows/windows-installer.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ jobs:
156156
run: |
157157
cat dist-64/.env >> $GITHUB_ENV
158158
- uses: "marvinpinto/action-automatic-releases@latest"
159+
if: github.actor != 'dependabot[bot]'
159160
with:
160161
repo_token: "${{ secrets.GITHUB_TOKEN }}"
161162
automatic_release_tag: ${{ (github.ref_name != 'main') && 'beta' || 'latest' }}

formatos/formato_xml.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"numero_cotizacion": str,
5050
"numero_remito": str,
5151
"ape": str,
52+
"permiso_existente": str,
5253
"incoterms": str,
5354
"detalleincoterms": str,
5455
"destinocmp": int,
@@ -188,6 +189,12 @@
188189
"fecha_serv_desde": "fechaservdesde",
189190
"fecha_serv_hasta": "fechaservhasta",
190191
"fecha_venc_pago": "fechavencpago",
192+
"tipo_expo": "concepto",
193+
"incoterms": "incoterms",
194+
"incoterms_ds": "detalleincoterms",
195+
"pais_dst_cmp": "destinocmp",
196+
"idioma_cbte": "idioma",
197+
"permiso_existente": "permiso_existente",
191198
"obs_generales": "otrosdatosgenerales",
192199
"obs_comerciales": "otrosdatoscomerciales",
193200
"resultado": "resultado",

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ Pillow>=2.0.0
1010
tabulate==0.8.5
1111
certifi>=2020.4.5.1
1212
qrcode==6.1
13-
future==0.18.2
13+
future==0.18.3

ws_sr_padron.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
from builtins import next
2424

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

3030
import csv
3131
import datetime
@@ -42,6 +42,7 @@
4242
abrir_conf,
4343
norm,
4444
SoapFault,
45+
safe_console,
4546
)
4647
from configparser import SafeConfigParser
4748
from pyafipws.padron import TIPO_CLAVE, PROVINCIAS
@@ -97,6 +98,7 @@ class WSSrPadronA4(BaseWS):
9798
"nro_doc",
9899
"tipo_persona",
99100
"estado",
101+
"es_sucesion",
100102
"impuestos",
101103
"actividades",
102104
"direccion",
@@ -125,6 +127,7 @@ def inicializar(self):
125127
self.tipo_persona = "" # FISICA o JURIDICA
126128
self.tipo_doc = self.nro_doc = 0
127129
self.estado = "" # ACTIVO
130+
self.es_sucesion = ""
128131
self.denominacion = ""
129132
self.direccion = self.localidad = self.provincia = self.cod_postal = ""
130133
self.domicilios = []
@@ -274,6 +277,7 @@ def Consultar(self, id_persona):
274277
self.nro_doc = data.get("idPersona")
275278
self.cuit = self.nro_doc
276279
self.estado = data.get("estadoClave")
280+
self.es_sucesion = data.get("esSucesion")
277281
if not "razonSocial" in data:
278282
self.denominacion = ", ".join(
279283
[data.get("apellido", ""), data.get("nombre", "")]
@@ -320,6 +324,7 @@ def main():
320324
global CONFIG_FILE
321325

322326
DEBUG = "--debug" in sys.argv
327+
safe_console()
323328

324329
if "--constancia" in sys.argv:
325330
padron = WSSrPadronA5()
@@ -427,6 +432,7 @@ def main():
427432
print("Denominacion:", padron.denominacion)
428433
print("Tipo:", padron.tipo_persona, padron.tipo_doc, padron.nro_doc)
429434
print("Estado:", padron.estado)
435+
print("Es Sucesion:", padron.es_sucesion)
430436
print("Direccion:", padron.direccion)
431437
print("Localidad:", padron.localidad)
432438
print("Provincia:", padron.provincia)

wsfev1.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
from past.builtins import basestring
3030

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

3636
import datetime
3737
import decimal
@@ -140,9 +140,10 @@ class WSFEv1(BaseWS):
140140
_reg_class_spec_ = "pyafipws.wsfev1.WSFEv1"
141141

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

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

330331
def AgregarActividad(self, actividad_id=0, **kwarg):
331332
"Agrego actividad a una factura (interna)"
332-
op = { 'actividad_id': actividad_id }
333-
self.factura['actividades'].append(op)
333+
act = {"actividad_id": actividad_id}
334+
self.factura["actividades"].append(act)
334335
return True
335336

336337
def ObtenerCampoFactura(self, *campos):
@@ -381,9 +382,6 @@ def CAESolicitar(self):
381382
"FchServDesde": f.get("fecha_serv_desde"),
382383
"FchServHasta": f.get("fecha_serv_hasta"),
383384
"FchVtoPago": f.get("fecha_venc_pago"),
384-
"FchServDesde": f.get("fecha_serv_desde"),
385-
"FchServHasta": f.get("fecha_serv_hasta"),
386-
"FchVtoPago": f["fecha_venc_pago"],
387385
"MonId": f["moneda_id"],
388386
"MonCotiz": f["moneda_ctz"],
389387
"PeriodoAsoc": {
@@ -456,7 +454,7 @@ def CAESolicitar(self):
456454
"Actividades": [
457455
{
458456
"Actividad": {
459-
'Id': actividad['actividad_id'],
457+
"Id": actividad["actividad_id"],
460458
}
461459
}
462460
for actividad in f["actividades"]
@@ -638,9 +636,9 @@ def CompConsultar(self, tipo_cbte, punto_vta, cbte_nro, reproceso=False):
638636
}
639637
copia = resultget.copy()
640638
# TODO: ordenar / convertir opcionales (por ahora no se verifican)
641-
del verificaciones['Opcionales']
642-
if 'Opcionales' in copia:
643-
del copia['Opcionales']
639+
del verificaciones["Opcionales"]
640+
if "Opcionales" in copia:
641+
del copia["Opcionales"]
644642
verifica(verificaciones, copia, difs)
645643
if difs:
646644
print("Diferencias:", difs)
@@ -802,9 +800,6 @@ def CAESolicitarX(self):
802800
"FchServDesde": f.get("fecha_serv_desde"),
803801
"FchServHasta": f.get("fecha_serv_hasta"),
804802
"FchVtoPago": f.get("fecha_venc_pago"),
805-
"FchServDesde": f.get("fecha_serv_desde"),
806-
"FchServHasta": f.get("fecha_serv_hasta"),
807-
"FchVtoPago": f["fecha_venc_pago"],
808803
"MonId": f["moneda_id"],
809804
"MonCotiz": f["moneda_ctz"],
810805
"PeriodoAsoc": {
@@ -1034,9 +1029,6 @@ def CAEARegInformativo(self):
10341029
"FchServDesde": f.get("fecha_serv_desde"),
10351030
"FchServHasta": f.get("fecha_serv_hasta"),
10361031
"FchVtoPago": f.get("fecha_venc_pago"),
1037-
"FchServDesde": f.get("fecha_serv_desde"),
1038-
"FchServHasta": f.get("fecha_serv_hasta"),
1039-
"FchVtoPago": f["fecha_venc_pago"],
10401032
"MonId": f["moneda_id"],
10411033
"MonCotiz": f["moneda_ctz"],
10421034
"PeriodoAsoc": {
@@ -1095,6 +1087,15 @@ def CAEARegInformativo(self):
10951087
for opcional in f["opcionales"]
10961088
]
10971089
or None,
1090+
"Actividades": [
1091+
{
1092+
"Actividad": {
1093+
"Id": actividad["actividad_id"],
1094+
}
1095+
}
1096+
for actividad in f["actividades"]
1097+
]
1098+
or None,
10981099
"CAEA": f["caea"],
10991100
"CbteFchHsGen": f.get("fecha_hs_gen"),
11001101
}
@@ -1301,13 +1302,15 @@ def ParamGetPtosVenta(self, sep="|"):
13011302

13021303
@inicializar_y_capturar_excepciones
13031304
def ParamGetActividades(self, sep="|"):
1304-
"Recuperador de valores referenciales de códigos de Actividades"
1305+
"Recuperador de valores referenciales de c�digos de Actividades"
13051306
ret = self.client.FEParamGetActividades(
1306-
Auth={'Token': self.Token, 'Sign': self.Sign, 'Cuit': self.Cuit},
1307-
)
1308-
res = ret['FEParamGetActividades']
1309-
return [(u"%(Id)s\t%(Orden)s\t%(Desc)s" % p['ActividadesTipo']).replace("\t", sep)
1310-
for p in res['ResultGet']]
1307+
Auth={"Token": self.Token, "Sign": self.Sign, "Cuit": self.Cuit},
1308+
)
1309+
res = ret["FEParamGetActividadesResult"]
1310+
return [
1311+
("%(Id)s\t%(Orden)s\t%(Desc)s" % p["ActividadesTipo"]).replace("\t", sep)
1312+
for p in res["ResultGet"]
1313+
]
13111314

13121315

13131316
def p_assert_eq(a, b):
@@ -1500,7 +1503,7 @@ def main():
15001503
if "--rg4540" in sys.argv:
15011504
wsfev1.AgregarPeriodoComprobantesAsociados("20200101", "20200131")
15021505

1503-
if '--rg5259' in sys.argv:
1506+
if "--rg5259" in sys.argv:
15041507
wsfev1.AgregarActividad(960990)
15051508

15061509
# agregar la factura creada internamente para solicitud múltiple:

wsfexv1.py

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
from builtins import str
2222

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

2828
import datetime
2929
import decimal
@@ -44,6 +44,7 @@ class WSFEXv1(BaseWS):
4444
"GetCMP",
4545
"AgregarPermiso",
4646
"AgregarCmpAsoc",
47+
"AgregarActividad",
4748
"GetParamMon",
4849
"GetParamTipoCbte",
4950
"GetParamTipoExpo",
@@ -67,6 +68,7 @@ class WSFEXv1(BaseWS):
6768
"GetParametro",
6869
"GetLastCMP",
6970
"GetLastID",
71+
"GetParamActividades",
7072
"Dummy",
7173
"Conectar",
7274
"SetTicketAcceso",
@@ -192,6 +194,7 @@ def CrearFactura(
192194
"cbtes_asoc": [],
193195
"permisos": [],
194196
"detalles": [],
197+
"actividades": [],
195198
}
196199
self.factura = fact
197200

@@ -237,6 +240,12 @@ def AgregarCmpAsoc(
237240
)
238241
return True
239242

243+
def AgregarActividad(self, actividad_id=0, **kwarg):
244+
"Agrego actividad a una factura (interna)"
245+
act = {"actividad_id": actividad_id}
246+
self.factura["actividades"].append(act)
247+
return True
248+
240249
@inicializar_y_capturar_excepciones
241250
def Authorize(self, id):
242251
"Autoriza la factura cargada en memoria"
@@ -304,6 +313,16 @@ def Authorize(self, id):
304313
}
305314
for d in f["detalles"]
306315
],
316+
"Actividades": f["actividades"]
317+
and [
318+
{
319+
"Actividad": {
320+
"Id": a["actividad_id"],
321+
}
322+
}
323+
for a in f["actividades"]
324+
]
325+
or None,
307326
},
308327
)
309328

@@ -748,23 +767,57 @@ def GetParamPtosVenta(self, sep="|"):
748767
res = ret["FEXGetPARAM_PtoVentaResult"].get("FEXResultGet")
749768
ret = []
750769
for pu in res:
751-
u = pu["ClsFEXResponse_PtoVenta"]
770+
p = pu["ClsFEXResponse_PtoVenta"]
752771
try:
753772
r = {
754-
"nro": u.get("Pve_Nro"),
755-
"baja": u.get("Pve_FchBaj"),
756-
"bloqueado": u.get("Pve_Bloqueado"),
773+
"nro": p.get("Pve_Nro"),
774+
"baja": p.get("Pve_FchBaj"),
775+
"bloqueado": p.get("Pve_Bloqueado"),
757776
}
758777
except Exception as e:
759778
print(e)
760779
ret.append(r)
761780
return [
762-
(u"%(nro)s\tBloqueado:%(bloqueado)s\tFchBaja:%(baja)s" % r).replace(
781+
("%(nro)s\tBloqueado:%(bloqueado)s\tFchBaja:%(baja)s" % r).replace(
763782
"\t", sep
764783
)
765784
for r in ret
766785
]
767786

787+
@inicializar_y_capturar_excepciones
788+
def GetParamActividades(self, sep="|"):
789+
"Recuperar lista de valores referenciales de códigos de Idiomas"
790+
ret = self.client.FEXGetPARAM_Actividades(
791+
Auth={
792+
"Token": self.Token,
793+
"Sign": self.Sign,
794+
"Cuit": self.Cuit,
795+
}
796+
)
797+
result = ret["FEXGetPARAM_ActividadesResult"]
798+
self.__analizar_errores(result)
799+
800+
ret = []
801+
for u in result.get("FEXResultGet", []):
802+
u = u["ClsFEXResponse_ActividadTipo"]
803+
try:
804+
r = {
805+
"codigo": u.get("Id"),
806+
"ds": u.get("Desc"),
807+
"orden": u.get("Orden"),
808+
}
809+
except Exception as e:
810+
print(e)
811+
812+
ret.append(r)
813+
if sep:
814+
return [
815+
("\t%(codigo)s\t%(ds)s\t%(orden)s\t" % it).replace("\t", sep)
816+
for it in ret
817+
]
818+
else:
819+
return ret
820+
768821

769822
class WSFEX(WSFEXv1):
770823
"Wrapper para retrocompatibilidad con WSFEX"
@@ -936,6 +989,8 @@ def main():
936989
cbteasoc_tipo, cbteasoc_pto_vta, cbteasoc_nro, cbteasoc_cuit
937990
)
938991

992+
ok = wsfexv1.AgregarActividad(1234)
993+
939994
##id = "99000000000100" # número propio de transacción
940995
# obtengo el último ID y le adiciono 1
941996
# (advertencia: evitar overflow y almacenar!)
@@ -1039,6 +1094,12 @@ def main():
10391094
for r in ret:
10401095
print("||%(codigo)s||%(ds)s||" % r)
10411096

1097+
if "--rg5259" in sys.argv:
1098+
print("=== Actividades ===")
1099+
ret = wsfexv1.GetParamActividades(sep=False)
1100+
for r in ret:
1101+
print("||%(codigo)s||%(ds)s||" % r)
1102+
10421103
if "--ctz" in sys.argv:
10431104
print(wsfexv1.GetParamCtz("DOL"))
10441105

0 commit comments

Comments
 (0)