|
| 1 | +# This program is free software; you can redistribute it and/or modify |
| 2 | +# it under the terms of the GNU General Public License as published by the |
| 3 | +# Free Software Foundation; either version 3, or (at your option) any later |
| 4 | +# version. |
| 5 | +# |
| 6 | +# This program is distributed in the hope that it will be useful, but |
| 7 | +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY |
| 8 | +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 9 | +# for more details. |
| 10 | + |
| 11 | +"""Test para Módulo WSLSP |
| 12 | +Liquidación Sector Pecuario (hacienda/carne). |
| 13 | +""" |
| 14 | + |
| 15 | +__author__ = "Mariano Reingart <reingart@gmail.com>" |
| 16 | +__copyright__ = "Copyright (C) 2010-2019 Mariano Reingart" |
| 17 | +__license__ = "GPL 3.0" |
| 18 | + |
| 19 | +import os |
| 20 | + |
| 21 | +from pyafipws.wsaa import WSAA |
| 22 | +from pyafipws.wslsp import WSLSP |
| 23 | + |
| 24 | + |
| 25 | +WSDL = "https://fwshomo.afip.gov.ar/wslsp/LspService?wsdl" |
| 26 | +CUIT = os.environ['CUIT'] |
| 27 | +CERT = 'rei.crt' |
| 28 | +PKEY = 'rei.key' |
| 29 | +CACHE = "" |
| 30 | + |
| 31 | +# obteniendo el TA para pruebas |
| 32 | +wsaa = WSAA() |
| 33 | +wslsp = WSLSP() |
| 34 | +ta = wsaa.Autenticar("wslsp", CERT, PKEY) |
| 35 | +wslsp.Cuit = CUIT |
| 36 | +wslsp.SetTicketAcceso(ta) |
| 37 | + |
| 38 | + |
| 39 | +def test_conectar(): |
| 40 | + """Conectar con servidor.""" |
| 41 | + conexion = wslsp.Conectar(CACHE, WSDL) |
| 42 | + assert conexion |
| 43 | + |
| 44 | + |
| 45 | +def test_server_status(): |
| 46 | + """Test de estado de servidores.""" |
| 47 | + wslsp.Dummy() |
| 48 | + assert wslsp.AppServerStatus == 'OK' |
| 49 | + assert wslsp.DbServerStatus == 'OK' |
| 50 | + assert wslsp.AuthServerStatus == 'OK' |
| 51 | + |
| 52 | + |
| 53 | +def test_inicializar(): |
| 54 | + """Test inicializar variables de BaseWS.""" |
| 55 | + wslsp.inicializar() |
| 56 | + assert wslsp.ImporteTotalNeto is None |
| 57 | + assert wslsp.FechaProcesoAFIP == '' |
| 58 | + assert wslsp.datos == {} |
| 59 | + |
| 60 | + |
| 61 | +def test_analizar_errores(): |
| 62 | + """Test Analizar si se encuentran errores.""" |
| 63 | + ret = {'numeroComprobante': 286} |
| 64 | + wslsp._WSLSP__analizar_errores(ret) |
| 65 | + # devuelve '' si no encuentra errores |
| 66 | + assert wslsp.ErrMsg == '' |
| 67 | + |
| 68 | + |
| 69 | +def test_crear_liquidacion(): |
| 70 | + """Test crear liquidacion.""" |
| 71 | + cod_operacion = 1 |
| 72 | + fecha_cbte = '2019-04-23' |
| 73 | + fecha_op = '2019-04-23' |
| 74 | + cod_motivo = 6 |
| 75 | + cod_localidad_procedencia = 8274 |
| 76 | + cod_provincia_procedencia = 1 |
| 77 | + cod_localidad_destino = 8274 |
| 78 | + cod_provincia_destino = 1 |
| 79 | + lugar_realizacion = 'CORONEL SUAREZ' |
| 80 | + fecha_recepcion = None |
| 81 | + fecha_faena = None |
| 82 | + datos_adicionales = None |
| 83 | + liquidacion = wslsp.CrearLiquidacion(cod_operacion, |
| 84 | + fecha_cbte, |
| 85 | + fecha_op, |
| 86 | + cod_motivo, |
| 87 | + cod_localidad_procedencia, |
| 88 | + cod_provincia_procedencia, |
| 89 | + cod_localidad_destino, |
| 90 | + cod_provincia_destino, |
| 91 | + lugar_realizacion, |
| 92 | + fecha_recepcion, fecha_faena, |
| 93 | + datos_adicionales) |
| 94 | + assert liquidacion |
| 95 | + |
| 96 | + |
| 97 | +def test_agregar_frigorifico(): |
| 98 | + """Test agregar frigorifico.""" |
| 99 | + cuit = 20160000156 |
| 100 | + nro_planta = 1 |
| 101 | + agregado = wslsp.AgregarFrigorifico(cuit, nro_planta) |
| 102 | + assert agregado |
| 103 | + |
| 104 | + |
| 105 | +def test_agregar_emisor(): |
| 106 | + """Test agregar emisor.""" |
| 107 | + tipo_cbte = 180 |
| 108 | + pto_vta = 3000 |
| 109 | + nro_cbte = 64 |
| 110 | + cod_caracter = 5 |
| 111 | + fecha_inicio_act = '2016-01-01', |
| 112 | + iibb = '123456789' |
| 113 | + nro_ruca = 305 |
| 114 | + nro_renspa = None |
| 115 | + agregado = wslsp.AgregarEmisor( |
| 116 | + tipo_cbte, pto_vta, nro_cbte, |
| 117 | + cod_caracter, fecha_inicio_act, |
| 118 | + iibb, nro_ruca, nro_renspa) |
| 119 | + assert agregado |
| 120 | + |
| 121 | + |
| 122 | +def test_agregar_receptor(): |
| 123 | + """Test agregar receptor.""" |
| 124 | + agregado = wslsp.AgregarReceptor(cod_caracter=3) |
| 125 | + assert agregado |
| 126 | + |
| 127 | + |
| 128 | +def test_agregar_operador(): |
| 129 | + """Test agregar operador.""" |
| 130 | + cuit = 30160000011 |
| 131 | + iibb = 3456 |
| 132 | + nro_renspa = '22.123.1.12345/A4' |
| 133 | + agregado = wslsp.AgregarOperador(cuit, iibb, nro_renspa) |
| 134 | + assert agregado |
| 135 | + |
| 136 | + |
| 137 | +def test_agregar_item_detalle(): |
| 138 | + """Test agregar item detalle.""" |
| 139 | + cuit_cliente = "20160000199" |
| 140 | + cod_categoria = 51020102 |
| 141 | + tipo_liquidacion = 1 |
| 142 | + cantidad = 2 |
| 143 | + precio_unitario = 10.0 |
| 144 | + alicuota_iva = 10.5 |
| 145 | + cod_raza = 1 |
| 146 | + cantidad_cabezas = None |
| 147 | + nro_tropa = None |
| 148 | + cod_corte = None |
| 149 | + cantidad_kg_vivo = None |
| 150 | + precio_recupero = None |
| 151 | + detalle_raza = None |
| 152 | + nro_item = 1 |
| 153 | + agregado = wslsp.AgregarItemDetalle(cuit_cliente, |
| 154 | + cod_categoria, |
| 155 | + tipo_liquidacion, |
| 156 | + cantidad, |
| 157 | + precio_unitario, |
| 158 | + alicuota_iva, |
| 159 | + cod_raza, |
| 160 | + cantidad_cabezas, |
| 161 | + nro_tropa, |
| 162 | + cod_corte, |
| 163 | + cantidad_kg_vivo, |
| 164 | + precio_recupero, |
| 165 | + detalle_raza, |
| 166 | + nro_item) |
| 167 | + |
| 168 | + assert agregado |
| 169 | + |
| 170 | + |
| 171 | +def test_agregar_compra_asociada(): |
| 172 | + """Test agregar compra asociada.""" |
| 173 | + tipo_cbte = 185 |
| 174 | + pto_vta = 3000 |
| 175 | + nro_cbte = 33 |
| 176 | + cant_asoc = 2 |
| 177 | + nro_item = 1 |
| 178 | + agregado = wslsp.AgregarCompraAsociada(tipo_cbte, pto_vta, |
| 179 | + nro_cbte, cant_asoc, |
| 180 | + nro_item) |
| 181 | + assert agregado |
| 182 | + |
| 183 | + |
| 184 | +def test_agregar_gasto(): |
| 185 | + """Test agregar gasto.""" |
| 186 | + cod_gasto = 99 |
| 187 | + base_imponible = None |
| 188 | + alicuota = 1 |
| 189 | + alicuota_iva = 0, |
| 190 | + descripcion = "Exento WSLSPv1.4.1" |
| 191 | + tipo_iva_nulo = "EX" |
| 192 | + agregado = wslsp.AgregarGasto(cod_gasto, base_imponible, |
| 193 | + alicuota, alicuota_iva, |
| 194 | + descripcion, |
| 195 | + tipo_iva_nulo) |
| 196 | + assert agregado |
| 197 | + |
| 198 | + |
| 199 | +def test_agregar_tributo(): |
| 200 | + """Test agregar tributo.""" |
| 201 | + cod_tributo = 5 |
| 202 | + base_imponible = 230520.60 |
| 203 | + alicuota = 2.5 |
| 204 | + agregado = wslsp.AgregarTributo(cod_tributo, base_imponible, |
| 205 | + alicuota) |
| 206 | + assert agregado |
| 207 | + |
| 208 | + |
| 209 | +def test_agregar_dte(): |
| 210 | + """Test agregar dte.""" |
| 211 | + nro_dte = "418-3" |
| 212 | + nro_renspa = None |
| 213 | + agregado = wslsp.AgregarDTE(nro_dte, nro_renspa) |
| 214 | + assert agregado |
| 215 | + |
| 216 | + |
| 217 | +def test_agregar_guia(): |
| 218 | + """Test agregar guia.""" |
| 219 | + agregado = wslsp.AgregarGuia(nro_guia=1) |
| 220 | + assert agregado |
| 221 | + |
| 222 | + |
| 223 | +def test_autorizar_liquidacion(): |
| 224 | + """Test autorizar liquidacion.""" |
| 225 | + # autorizado = wslsp.AutorizarLiquidacion() |
| 226 | + # assert autorizado |
| 227 | + # afip esta pidiendo DTe validos |
| 228 | + pass |
| 229 | + |
| 230 | + |
| 231 | +def test_analizar_liquidacion(): |
| 232 | + """Test analizar liquidacion.""" |
| 233 | + # assert |
| 234 | + # Metodo utilizado con Autorizar liquidacion |
| 235 | + pass |
| 236 | + |
| 237 | + |
| 238 | +def test_consultar_liquidacion(): |
| 239 | + """Test consultar liquidacion.""" |
| 240 | + tipo_cbte = 180 |
| 241 | + pto_vta = 3000 |
| 242 | + nro_cbte = 1 |
| 243 | + cuit = None |
| 244 | + consulta = wslsp.ConsultarLiquidacion(tipo_cbte, pto_vta, nro_cbte, |
| 245 | + cuit_comprador=cuit) |
| 246 | + assert consulta |
| 247 | + |
| 248 | + |
| 249 | +def test_consultar_ultimo_comprobante(): |
| 250 | + """Test consultar ultimo comprobante.""" |
| 251 | + tipo_cbte = 27 |
| 252 | + pto_vta = 1 |
| 253 | + consulta = wslsp.ConsultarUltimoComprobante(tipo_cbte, pto_vta) |
| 254 | + assert consulta |
| 255 | + |
| 256 | + |
| 257 | +def test_crear_ajuste(): |
| 258 | + """Test crear ajuste.""" |
| 259 | + tipo_ajuste = 'C' |
| 260 | + fecha_cbte = '2019-01-06' |
| 261 | + datos_adicionales = 'Ajuste sobre liquidacion de compra directa' |
| 262 | + ajuste = wslsp.CrearAjuste(tipo_ajuste, fecha_cbte, |
| 263 | + datos_adicionales) |
| 264 | + assert ajuste |
| 265 | + |
| 266 | + |
| 267 | +def test_agregar_comprobante_a_ajustar(): |
| 268 | + """Test agregar comprobante a ajustar.""" |
| 269 | + tipo_cbte = 186 |
| 270 | + pto_vta = 2000 |
| 271 | + nro_cbte = 4 |
| 272 | + agregado = wslsp.AgregarComprobanteAAjustar(tipo_cbte, pto_vta, nro_cbte) |
| 273 | + assert agregado |
| 274 | + |
| 275 | + |
| 276 | +def test_agregar_item_detalle_ajuste(): |
| 277 | + """Test agregar item detalle ajuste .""" |
| 278 | + agregado = wslsp.AgregarItemDetalleAjuste(nro_item_ajustar=1) |
| 279 | + assert agregado |
| 280 | + |
| 281 | + |
| 282 | +def test_agregar_ajuste_fisico(): |
| 283 | + """Test agregar ajuste fisico.""" |
| 284 | + cantidad = 1 |
| 285 | + cantidad_cabezas = None |
| 286 | + cantidad_kg_vivo = None |
| 287 | + agregado = wslsp.AgregarAjusteFisico(cantidad, |
| 288 | + cantidad_cabezas, |
| 289 | + cantidad_kg_vivo) |
| 290 | + assert agregado |
| 291 | + |
| 292 | + |
| 293 | +def test_agregar_ajuste_monetario(): |
| 294 | + """Test agregar ajuste monetario.""" |
| 295 | + precio_unitario = 15.995 |
| 296 | + precio_recupero = None |
| 297 | + agregado = wslsp.AgregarAjusteMonetario(precio_unitario, |
| 298 | + precio_recupero) |
| 299 | + assert agregado |
| 300 | + |
| 301 | + |
| 302 | +def test_agregar_ajuste_financiero(): |
| 303 | + """Test agregar ajuste financiero.""" |
| 304 | + agregado = wslsp.AgregarAjusteFinanciero() |
| 305 | + assert agregado |
| 306 | + |
| 307 | + |
| 308 | +def test_ajustar_liquidacion(): |
| 309 | + """Test ajustar liquidacion.""" |
| 310 | + ajuste = wslsp.AjustarLiquidacion() |
| 311 | + assert ajuste |
| 312 | + |
| 313 | + |
| 314 | +def test_consultar_provincias(): |
| 315 | + """Test consultar provincias.""" |
| 316 | + consulta = wslsp.ConsultarProvincias() |
| 317 | + assert consulta |
| 318 | + |
| 319 | + |
| 320 | +def test_consultar_localidades(): |
| 321 | + """Test consultar localidades.""" |
| 322 | + consulta = wslsp.ConsultarLocalidades(cod_provincia=1) |
| 323 | + assert consulta |
| 324 | + |
| 325 | + |
| 326 | +def test_consultar_operaciones(): |
| 327 | + """Test consultar operaciones.""" |
| 328 | + consulta = wslsp.ConsultarOperaciones() |
| 329 | + assert consulta |
| 330 | + |
| 331 | + |
| 332 | +def test_consultar_tributos(): |
| 333 | + """Test consultar tributos.""" |
| 334 | + consulta = wslsp.ConsultarTributos() |
| 335 | + assert consulta |
| 336 | + |
| 337 | + |
| 338 | +def test_consultar_gastos(): |
| 339 | + """Test consultar gastos.""" |
| 340 | + consulta = wslsp.ConsultarGastos() |
| 341 | + assert consulta |
| 342 | + |
| 343 | + |
| 344 | +def test_consultar_tipos_comprobante(): |
| 345 | + """Test consultar tipos comprobantes.""" |
| 346 | + consulta = wslsp.ConsultarTiposComprobante() |
| 347 | + assert consulta |
| 348 | + |
| 349 | + |
| 350 | +def test_consultar_tipos_liquidacion(): |
| 351 | + """Test consultar tipoe liquidacion.""" |
| 352 | + consulta = wslsp.ConsultarTiposLiquidacion() |
| 353 | + assert consulta |
| 354 | + |
| 355 | + |
| 356 | +def test_consultar_caracteres(): |
| 357 | + """Test consultar caracteres.""" |
| 358 | + consulta = wslsp.ConsultarCaracteres() |
| 359 | + assert consulta |
| 360 | + |
| 361 | + |
| 362 | +def test_consultar_categorias(): |
| 363 | + """Test consultar categorias.""" |
| 364 | + consulta = wslsp.ConsultarCategorias() |
| 365 | + assert consulta |
| 366 | + |
| 367 | + |
| 368 | +def test_consultar_motivos(): |
| 369 | + """Test consultar motivos.""" |
| 370 | + consulta = wslsp.ConsultarMotivos() |
| 371 | + assert consulta |
| 372 | + |
| 373 | + |
| 374 | +def test_consultar_razas(): |
| 375 | + """Test consultar razas.""" |
| 376 | + consulta = wslsp.ConsultarRazas() |
| 377 | + assert consulta |
| 378 | + |
| 379 | + |
| 380 | +def test_consultar_cortes(): |
| 381 | + """Test consultar cortes.""" |
| 382 | + consulta = wslsp.ConsultarCortes() |
| 383 | + assert consulta |
| 384 | + |
| 385 | + |
| 386 | +def test_consultar_puntos_ventas(): |
| 387 | + """Test consultar puntos de venta.""" |
| 388 | + consulta = wslsp.ConsultarPuntosVentas() |
| 389 | + assert consulta |
| 390 | + |
| 391 | + |
| 392 | +def test_mostrar_pdf(): |
| 393 | + """Test mostrar pdf.""" |
| 394 | + show = wslsp.MostrarPDF(archivo='liq.pdf', |
| 395 | + imprimir=True) |
| 396 | + assert show is False |
0 commit comments