Skip to content

Commit 5e69897

Browse files
authored
Merge pull request #106 from reingart/ro
RG5259 - RG5264/22 (Actividades)
2 parents 7a6d8e5 + 1fa7252 commit 5e69897

File tree

2 files changed

+93
-2
lines changed

2 files changed

+93
-2
lines changed

wsfev1.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class WSFEv1(BaseWS):
5959
"AgregarOpcional",
6060
"AgregarComprador",
6161
"AgregarPeriodoComprobantesAsociados",
62+
"AgregarActividad",
6263
"CompUltimoAutorizado",
6364
"CompConsultar",
6465
"CAEASolicitar",
@@ -80,6 +81,7 @@ class WSFEv1(BaseWS):
8081
"ParamGetTiposPaises",
8182
"ParamGetCotizacion",
8283
"ParamGetPtosVenta",
84+
"ParamGetActividades",
8385
"AnalizarXml",
8486
"ObtenerTagXml",
8587
"LoadTestXML",
@@ -247,6 +249,7 @@ def CrearFactura(
247249
"iva": [],
248250
"opcionales": [],
249251
"compradores": [],
252+
"actividades": [],
250253
}
251254
if fecha_serv_desde:
252255
fact["fecha_serv_desde"] = fecha_serv_desde
@@ -324,6 +327,12 @@ def AgregarComprador(self, doc_tipo=80, doc_nro=0, porcentaje=100.00, **kwarg):
324327
self.factura["compradores"].append(comp)
325328
return True
326329

330+
def AgregarActividad(self, actividad_id=0, **kwarg):
331+
"Agrego actividad a una factura (interna)"
332+
op = { 'actividad_id': actividad_id }
333+
self.factura['actividades'].append(op)
334+
return True
335+
327336
def ObtenerCampoFactura(self, *campos):
328337
"Obtener el valor devuelto de AFIP para un campo de factura"
329338
# cada campo puede ser una clave string (dict) o una posición (list)
@@ -444,6 +453,15 @@ def CAESolicitar(self):
444453
for comprador in f["compradores"]
445454
]
446455
or None,
456+
"Actividades": [
457+
{
458+
"Actividad": {
459+
'Id': actividad['actividad_id'],
460+
}
461+
}
462+
for actividad in f["actividades"]
463+
]
464+
or None,
447465
}
448466
}
449467
],
@@ -609,6 +627,14 @@ def CompConsultar(self, tipo_cbte, punto_vta, cbte_nro, reproceso=False):
609627
}
610628
for comprador in f["compradores"]
611629
],
630+
"Actividades": [
631+
{
632+
"Actividad": {
633+
"Id": actividad["actividad_id"],
634+
}
635+
}
636+
for actividad in f["actividades"]
637+
],
612638
}
613639
copia = resultget.copy()
614640
# TODO: ordenar / convertir opcionales (por ahora no se verifican)
@@ -684,6 +710,12 @@ def CompConsultar(self, tipo_cbte, punto_vta, cbte_nro, reproceso=False):
684710
}
685711
for comp in resultget.get("Compradores", [])
686712
],
713+
"actividades": [
714+
{
715+
"actividad_id": act["Actividad"]["Id"],
716+
}
717+
for act in resultget.get("Actividades", [])
718+
],
687719
"cae": resultget.get("CodAutorizacion"),
688720
"resultado": resultget.get("Resultado"),
689721
"fch_venc_cae": resultget.get("FchVto"),
@@ -828,6 +860,15 @@ def CAESolicitarX(self):
828860
for opcional in f["opcionales"]
829861
]
830862
or None,
863+
"Actividades": [
864+
{
865+
"Actividad": {
866+
"Id": actividad["actividad_id"],
867+
}
868+
}
869+
for actividad in f["actividades"]
870+
]
871+
or None,
831872
}
832873
}
833874
for f in self.facturas
@@ -1258,6 +1299,16 @@ def ParamGetPtosVenta(self, sep="|"):
12581299
for p in res.get("ResultGet", [])
12591300
]
12601301

1302+
@inicializar_y_capturar_excepciones
1303+
def ParamGetActividades(self, sep="|"):
1304+
"Recuperador de valores referenciales de códigos de Actividades"
1305+
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']]
1311+
12611312

12621313
def p_assert_eq(a, b):
12631314
print(a, a == b and "==" or "!=", b)
@@ -1449,6 +1500,9 @@ def main():
14491500
if "--rg4540" in sys.argv:
14501501
wsfev1.AgregarPeriodoComprobantesAsociados("20200101", "20200131")
14511502

1503+
if '--rg5259' in sys.argv:
1504+
wsfev1.AgregarActividad(960990)
1505+
14521506
# agregar la factura creada internamente para solicitud múltiple:
14531507
if "--multiple" in sys.argv:
14541508
wsfev1.AgregarFacturaX()
@@ -1575,6 +1629,9 @@ def main():
15751629
# print(u"\n".join(wsfev1.ParamGetTiposPaises()))
15761630
print("=== Puntos de Venta ===")
15771631
print(u"\n".join(wsfev1.ParamGetPtosVenta()))
1632+
if '--rg5259' in sys.argv:
1633+
print("=== Actividades ===")
1634+
print(u'\n'.join(wsfev1.ParamGetActividades()))
15781635

15791636
if "--cotizacion" in sys.argv:
15801637
print(wsfev1.ParamGetCotizacion("DOL"))

wsmtx.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
__author__ = "Mariano Reingart <[email protected]>"
2323
__copyright__ = "Copyright (C) 2010-2021 Mariano Reingart"
2424
__license__ = "LGPL-3.0-or-later"
25-
__version__ = "3.15d"
25+
__version__ = "3.16a"
2626

2727
import datetime
2828
import decimal
@@ -47,6 +47,7 @@ class WSMTXCA(BaseWS):
4747
"EstablecerCampoItem",
4848
"AgregarOpcional",
4949
"AgregarPeriodoComprobantesAsociados",
50+
"AgregarActividad",
5051
"AutorizarComprobante",
5152
"CAESolicitar",
5253
"AutorizarAjusteIVA",
@@ -67,6 +68,7 @@ class WSMTXCA(BaseWS):
6768
"ConsultarCondicionesIVA",
6869
"ConsultarMonedas",
6970
"ConsultarUnidadesMedida",
71+
"ConsultarActividadesVigentes",
7072
"ConsultarTiposTributo",
7173
"ConsultarTiposDatosAdicionales",
7274
"ConsultarCotizacionMoneda",
@@ -223,6 +225,7 @@ def CrearFactura(
223225
"iva": [],
224226
"detalles": [],
225227
"opcionales": [],
228+
"actividades": [],
226229
}
227230
if fecha_serv_desde:
228231
fact["fecha_serv_desde"] = fecha_serv_desde
@@ -359,6 +362,13 @@ def AgregarOpcional(
359362
self.factura["opcionales"].append(op)
360363
return True
361364

365+
@inicializar_y_capturar_excepciones
366+
def AgregarActividad(self, actividad_id=0, **kwarg):
367+
"Agrego actividades a una factura (interna)"
368+
act = { 'actividad_id': actividad_id}
369+
self.factura['actividades'].append(act)
370+
return True
371+
362372
@inicializar_y_capturar_excepciones
363373
def AutorizarComprobante(self):
364374
f = self.factura
@@ -468,6 +478,16 @@ def AutorizarComprobante(self):
468478
for dato in f["opcionales"]
469479
]
470480
or None,
481+
"arrayActividades": f["actividades"]
482+
and [
483+
{
484+
"actividad": {
485+
"codigo": act["actividad_id"],
486+
}
487+
}
488+
for act in f["actividades"]
489+
]
490+
or None,
471491
}
472492

473493
ret = self.client.autorizarComprobante(
@@ -1436,6 +1456,15 @@ def ConsultarPtosVtaCAEANoInformados(self, caea):
14361456
for p in ret["arrayPuntosVenta"]
14371457
]
14381458

1459+
@inicializar_y_capturar_excepciones
1460+
def ConsultarActividadesVigentes(self):
1461+
"Este método permite consultar las actividades vigentes para el contribuyente"
1462+
ret = self.client.consultarActividadesVigentes(
1463+
authRequest={'token': self.Token, 'sign': self.Sign, 'cuitRepresentada': self.Cuit},
1464+
)
1465+
return ["%(codigo)s: %(orden)s %(descripcion)s" % p['actividad']
1466+
for p in ret['arrayActividades']]
1467+
14391468

14401469
def main():
14411470
"Función principal de pruebas (obtener CAE)"
@@ -1469,7 +1498,7 @@ def main():
14691498
if "--prueba" in sys.argv:
14701499
##print wsmtxca.client.help("autorizarComprobante").encode("latin1")
14711500
try:
1472-
tipo_cbte = 201
1501+
tipo_cbte = 1
14731502
punto_vta = 4000
14741503
cbte_nro = wsmtxca.ConsultarUltimoComprobanteAutorizado(
14751504
tipo_cbte, punto_vta
@@ -1584,6 +1613,9 @@ def main():
15841613
if "--rg4540" in sys.argv:
15851614
wsmtxca.AgregarPeriodoComprobantesAsociados("2020-01-01", "2020-01-31")
15861615

1616+
if '--rg5259' in sys.argv:
1617+
wsmtxca.AgregarActividad(960990)
1618+
15871619
print(wsmtxca.factura)
15881620

15891621
if "--caea" in sys.argv:
@@ -1740,6 +1772,8 @@ def main():
17401772
print(wsmtxca.ConsultarUnidadesMedida())
17411773
print(wsmtxca.ConsultarTiposTributo())
17421774
print(wsmtxca.ConsultarTiposDatosAdicionales())
1775+
if '--rg5259' in sys.argv:
1776+
print(wsmtxca.ConsultarActividadesVigentes())
17431777

17441778
if "--puntosventa" in sys.argv:
17451779
print(wsmtxca.ConsultarPuntosVentaCAE())

0 commit comments

Comments
 (0)