Beispiel #1
0
            public static PD.RespuestaAccion MODIFICA_IFRS(int batch_id, decimal valor_residual, int vida_util, int metod_val, decimal[] preparacion, decimal[] transporte, decimal[] montaje, decimal[] desmantelamiento, decimal[] honorarios)
            {
                var result = new PD.RespuestaAccion();

                try
                {
                    using (var cServ = new ServiceProcess.ServiceAFN2())
                    {
                        var parte_id     = cServ.Repo.Partes.ByLotePart(batch_id, 0).id;
                        var IFRS_systems = cServ.Repo.sistemas.IFRS();
                        var HeadId       = cServ.Repo.cabeceras.ByParteFirst(parte_id).id;
                        //metod_val
                        result = cServ.Repo.MODIF_PURCHASE_HEAD_MethodVal(HeadId, metod_val);


                        foreach (var currSystem in IFRS_systems)
                        {
                            int index = ((currSystem.CURRENCY == "CLP")?0:1);

                            PD.SV_PARAMETER CurrParam;
                            //valor_residual
                            CurrParam = cServ.Repo.parametros.ValorResidual;
                            if (valor_residual == 0)
                            {
                                result = cServ.Repo.DELETE_PURCHASE_PARAM(HeadId, currSystem, CurrParam);
                            }
                            else
                            {
                                result = cServ.Repo.MODIF_PURCHASE_PARAM(HeadId, currSystem, CurrParam, valor_residual, false);
                            }
                            if (result.codigo < 0)
                            {
                                return(result);
                            }
                            //vida_util
                            CurrParam = cServ.Repo.parametros.VidaUtil;
                            if (vida_util == 0)
                            {
                                result = cServ.Repo.DELETE_PURCHASE_PARAM(HeadId, currSystem, CurrParam);
                            }
                            else
                            {
                                result = cServ.Repo.MODIF_PURCHASE_PARAM(HeadId, currSystem, CurrParam, vida_util, false);
                            }
                            if (result.codigo < 0)
                            {
                                return(result);
                            }
                            //decimal valor_procesar;
                            //preparacion
                            CurrParam = cServ.Repo.parametros.Preparacion;

                            if (preparacion[index] == 0)
                            {
                                result = cServ.Repo.DELETE_PURCHASE_PARAM(HeadId, currSystem, CurrParam);
                            }
                            else
                            {
                                result = cServ.Repo.MODIF_PURCHASE_PARAM(HeadId, currSystem, CurrParam, preparacion[index], false);
                            }
                            if (result.codigo < 0)
                            {
                                return(result);
                            }
                            //transporte
                            CurrParam = cServ.Repo.parametros.Transporte;
                            if (transporte[index] == 0)
                            {
                                result = cServ.Repo.DELETE_PURCHASE_PARAM(HeadId, currSystem, CurrParam);
                            }
                            else
                            {
                                result = cServ.Repo.MODIF_PURCHASE_PARAM(HeadId, currSystem, CurrParam, transporte[index], false);
                            }
                            if (result.codigo < 0)
                            {
                                return(result);
                            }
                            //montaje
                            CurrParam = cServ.Repo.parametros.Montaje;
                            if (montaje[index] == 0)
                            {
                                result = cServ.Repo.DELETE_PURCHASE_PARAM(HeadId, currSystem, CurrParam);
                            }
                            else
                            {
                                result = cServ.Repo.MODIF_PURCHASE_PARAM(HeadId, currSystem, CurrParam, montaje[index], false);
                            }
                            if (result.codigo < 0)
                            {
                                return(result);
                            }
                            //desmantelamiento
                            CurrParam = cServ.Repo.parametros.Desmantelamiento;
                            if (desmantelamiento[index] == 0)
                            {
                                result = cServ.Repo.DELETE_PURCHASE_PARAM(HeadId, currSystem, CurrParam);
                            }
                            else
                            {
                                result = cServ.Repo.MODIF_PURCHASE_PARAM(HeadId, currSystem, CurrParam, desmantelamiento[index], false);
                            }
                            if (result.codigo < 0)
                            {
                                return(result);
                            }
                            //honorarios
                            CurrParam = cServ.Repo.parametros.Honorario;
                            if (honorarios[index] == 0)
                            {
                                result = cServ.Repo.DELETE_PURCHASE_PARAM(HeadId, currSystem, CurrParam);
                            }
                            else
                            {
                                result = cServ.Repo.MODIF_PURCHASE_PARAM(HeadId, currSystem, CurrParam, honorarios[index], false);
                            }
                            if (result.codigo < 0)
                            {
                                return(result);
                            }
                        }
                    }
                    result.set_ok();
                }
                catch (Exception ex)
                {
                    result.set(-1, ex.StackTrace);
                }

                return(result);
            }