Skip to content

Commit

Permalink
Cumulative updates f/ develop (python3 conversion)
Browse files Browse the repository at this point in the history
* 2to3 -w file.py
* python -m black file.py
* iconv -f iso-8859-1 -t utf-8 < file_new.py > file.py
  • Loading branch information
reingart committed Jun 28, 2023
1 parent 66c7aba commit 2b5875a
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 76 deletions.
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
11 changes: 9 additions & 2 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"
__copyright__ = "Copyright (C) 2017-2022 Mariano Reingart"
__license__ = "GPL 3.0"
__version__ = "3.04e"
__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 All @@ -54,6 +55,7 @@


class WSSrPadronA4(BaseWS):
<<<<<<< HEAD
"Interfaz para el WebService de Consulta Padrón Contribuyentes Alcance 4"
_public_methods_ = [
"Consultar",
Expand Down Expand Up @@ -97,6 +99,7 @@ class WSSrPadronA4(BaseWS):
"nro_doc",
"tipo_persona",
"estado",
"es_sucesion",
"impuestos",
"actividades",
"direccion",
Expand Down Expand Up @@ -125,6 +128,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 +278,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 +325,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 +433,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
74 changes: 67 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,11 @@ def main():
for r in ret:
print("||%(codigo)s||%(ds)s||" % r)

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
50 changes: 25 additions & 25 deletions wslpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from past.builtins import basestring

__author__ = "Mariano Reingart <[email protected]>"
__copyright__ = "Copyright (C) 2013-2021 Mariano Reingart"
__copyright__ = "Copyright (C) 2013-2022 Mariano Reingart"
__license__ = "LGPL-3.0-or-later"
__version__ = "3.35b"
__version__ = "3.35e"

LICENCIA = """
wslpg.py: Interfaz para generar Código de Operación Electrónica para
Expand Down Expand Up @@ -160,11 +160,11 @@
("nro_ing_bruto_corredor", 15, N),
("comision_corredor", 5, I, 2), # 3.2
("fecha_precio_operacion", 10, A), # 26/02/2013
("precio_ref_tn", 8, I, 3), # 4.3
("precio_ref_tn", 17, I, 3), # 4.3
("cod_grado_ref", 2, A),
("cod_grado_ent", 2, A),
("factor_ent", 6, I, 3), # 3.3
("precio_flete_tn", 7, I, 2), # 5.2
("precio_flete_tn", 17, I, 2), # 5.2
("cont_proteico", 6, I, 3), # 3.3
("alic_iva_operacion", 5, I, 2), # 3.2
("campania_ppal", 4, N),
Expand Down Expand Up @@ -237,7 +237,7 @@
("tipo_reg", 1, A), # 2: Retencion
("codigo_concepto", 2, A),
("detalle_aclaratorio", 30, A),
("base_calculo", 10, I, 2), # 8.2
("base_calculo", 17, I, 2), # 8.2
("alicuota", 6, I, 2), # 3.2
("nro_certificado_retencion", 14, N),
("fecha_certificado_retencion", 10, A),
Expand All @@ -252,17 +252,17 @@
("dias_almacenaje", 4, N),
("reservado1", 6, I, 3),
("comision_gastos_adm", 5, I, 2), # 3.2
("base_calculo", 10, I, 2), # 8.2
("base_calculo", 17, I, 2), # 8.2
("alicuota", 6, I, 2), # 3.2
("importe_iva", 17, I, 2), # 17.2
("importe_deduccion", 17, I, 2), # 17.2
("precio_pkg_diario", 11, I, 8), # 3.8, ajustado WSLPGv1.2
("precio_pkg_diario", 17, I, 8), # 3.8, ajustado WSLPGv1.2
]

PERCEPCION = [
("tipo_reg", 1, A), # P: Percepcion
("detalle_aclaratoria", 50, A), # max 50 por WSLPGv1.8
("base_calculo", 10, I, 2), # 8.2
("base_calculo", 17, I, 2), # 8.2
("alicuota", 6, I, 2), # 3.2
("importe_final", 19, I, 2), # 17.2 (LPG WSLPGv1.16)
]
Expand Down Expand Up @@ -348,10 +348,10 @@
("servicios_otros", 7, I, 3),
("servicios_forma_de_pago", 20, A),
# campos para cgAutorizarRetiroTransferencia (WSLPGv1.6):
('cuit_receptor', 11, N),
('fecha', 10, A), # no usado WSLPGv1.8
('nro_carta_porte_a_utilizar', 13, N), # obligatorio para retiro
('cee_carta_porte_a_utilizar', 10, N), # no usado WSLPGv1.8
("cuit_receptor", 11, N),
("fecha", 10, A), # no usado WSLPGv1.8
("nro_carta_porte_a_utilizar", 13, N), # obligatorio para retiro
("cee_carta_porte_a_utilizar", 10, N), # no usado WSLPGv1.8
# para cgAutorizarPreexistente (WSLPGv1.6):
("tipo_certificado_deposito_preexistente", 1, N), # "R": Retiro "T": Tra.
("nro_certificado_deposito_preexistente", 12, N),
Expand Down Expand Up @@ -386,18 +386,18 @@
("servicios_otras_percepciones", 10, I, 2),
]

CTG = [ # para cgAutorizarDeposito (WSLPGv1.6)
('tipo_reg', 1, A), # C: CTG
('nro_ctg', 12, A),
('nro_carta_porte', 13, A),
('porcentaje_secado_humedad', 5, I, 2),
('importe_secado', 10, I, 2),
('peso_neto_merma_secado', 10, I, 2),
('tarifa_secado', 10, I, 2),
('importe_zarandeo', 10, I, 2),
('peso_neto_merma_zarandeo', 10, I, 2),
('tarifa_zarandeo', 10, I, 2),
('peso_neto_confirmado_definitivo', 10, I, 2),
CTG = [ # para cgAutorizarDeposito (WSLPGv1.6)
("tipo_reg", 1, A), # C: CTG
("nro_ctg", 12, A),
("nro_carta_porte", 13, A),
("porcentaje_secado_humedad", 5, I, 2),
("importe_secado", 10, I, 2),
("peso_neto_merma_secado", 10, I, 2),
("tarifa_secado", 10, I, 2),
("importe_zarandeo", 10, I, 2),
("peso_neto_merma_zarandeo", 10, I, 2),
("tarifa_zarandeo", 10, I, 2),
("peso_neto_confirmado_definitivo", 10, I, 2),
]

DET_MUESTRA_ANALISIS = [ # para cgAutorizarDeposito (WSLPGv1.6)
Expand Down Expand Up @@ -4593,7 +4593,7 @@ def main():

if "--lsg" in sys.argv:
print("Anulando COE LSG", coe)
ret = wslpg.AnularLiquidacionSecundaria(coe)
ret = wslpg.AnularLiquidacionSecundaria(pto_emision, nro_orden, coe)
if "--cg" in sys.argv:
print("Anulando COE CG", coe)
ret = wslpg.AnularCertificacion(coe)
Expand Down
Loading

0 comments on commit 2b5875a

Please sign in to comment.