示例#1
0
        private void Generar_inventario(in_transferencia_Info info, ref decimal _idTransferencia)
        {
            try
            {
                in_Ing_Egr_Inven_Info in_Ing_Egr_Info_Origen  = new in_Ing_Egr_Inven_Info();
                in_Ing_Egr_Inven_Info in_Ing_Egr_Info_Destino = new in_Ing_Egr_Inven_Info();
                string  mensaje       = "";
                decimal IdNumMovi_Egr = 0;
                decimal IdNumMovi_Ing = 0;

                //EGRESO POR TRANSFERENCIA
                in_Ing_Egr_Info_Origen = Get_Info_Ing_Egr_Inven(info, "-");
                if (info.IdNumMovi_Ing_Egr_Inven_Origen == null || info.IdNumMovi_Ing_Egr_Inven_Origen == 0)
                {
                    bus_Ing_Egr_Inv.GuardarDB(in_Ing_Egr_Info_Origen, ref IdNumMovi_Egr, ref mensaje);
                }
                else
                {
                    in_Ing_Egr_Info_Origen.IdNumMovi = Convert.ToDecimal(info.IdNumMovi_Ing_Egr_Inven_Origen);
                    IdNumMovi_Egr = Convert.ToDecimal(info.IdNumMovi_Ing_Egr_Inven_Origen);
                    bus_Ing_Egr_Inv.ModificarDB(in_Ing_Egr_Info_Origen, ref mensaje);
                }

                //INGRESO POR TRANSFERENCIA
                in_Ing_Egr_Info_Destino = Get_Info_Ing_Egr_Inven(info, "+");
                if (info.IdNumMovi_Ing_Egr_Inven_Destino == null || info.IdNumMovi_Ing_Egr_Inven_Destino == 0)
                {
                    bus_Ing_Egr_Inv.GuardarDB(in_Ing_Egr_Info_Destino, ref IdNumMovi_Ing, ref mensaje);
                }
                else
                {
                    in_Ing_Egr_Info_Destino.IdNumMovi = Convert.ToDecimal(info.IdNumMovi_Ing_Egr_Inven_Destino);
                    IdNumMovi_Ing = Convert.ToDecimal(info.IdNumMovi_Ing_Egr_Inven_Destino);
                    bus_Ing_Egr_Inv.ModificarDB(in_Ing_Egr_Info_Destino, ref mensaje);
                }
                ///actualizando los idde movi inven en cab de transf
                oData_Transferencia.Modificar_IdMovi_Inven_x_Transf(info, in_Ing_Egr_Info_Origen.IdEmpresa, in_Ing_Egr_Info_Origen.IdSucursal,
                                                                    IdNumMovi_Egr, in_Ing_Egr_Info_Destino.IdEmpresa, in_Ing_Egr_Info_Destino.IdSucursal, IdNumMovi_Ing);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "Generar_inventario", ex.Message), ex)
                      {
                          EntityType = typeof(in_transferencia_bus)
                      };
            }
        }
示例#2
0
        private bool Generar_info_ing_egr(in_ajusteFisico_Info info_ajuste, ref decimal IdNumMovi_ing, ref decimal IdNumMovi_egr)
        {
            try
            {
                in_Ing_Egr_Inven_Info info_ing_egr = new in_Ing_Egr_Inven_Info();

                bool HayIngresos = false;
                bool HayEgresos  = false;

                var TIngreso = (from q in info_ajuste.list_det_AjusteFisico
                                where q.CantidadAjustada > 0
                                select q).Count();


                var TEgresos = (from q in info_ajuste.list_det_AjusteFisico
                                where q.CantidadAjustada < 0
                                select q).Count();


                HayIngresos = (Convert.ToDouble(TIngreso) > 0) ? true : false;

                #region HayIngreso

                if (HayIngresos == true)
                {
                    info_ing_egr = new in_Ing_Egr_Inven_Info();

                    info_ing_egr.IdEmpresa         = info_ajuste.IdEmpresa;
                    info_ing_egr.IdSucursal        = info_ajuste.IdSucursal;
                    info_ing_egr.IdBodega          = info_ajuste.IdBodega;
                    info_ing_egr.IdMovi_inven_tipo = info_ajuste.IdMovi_inven_tipo_Ing;
                    info_ing_egr.signo             = "+";
                    info_ing_egr.cm_observacion    = info_ajuste.Observacion;
                    info_ing_egr.IdUsuario         = info_ajuste.IdUsuario;
                    info_ing_egr.nom_pc            = info_ajuste.nom_pc;
                    info_ing_egr.ip           = info_ajuste.ip;
                    info_ing_egr.Estado       = "A";
                    info_ing_egr.cm_fecha     = info_ajuste.Fecha;
                    info_ing_egr.CodMoviInven = "AJU";
                    info_ing_egr.IdMotivo_Inv = 1;

                    /// obteniendo el detalle del movimiento de invetario
                    var SelectDetMoviIng = from q in info_ajuste.list_det_AjusteFisico
                                           where q.CantidadAjustada > 0
                                           select q;
                    int c = 1;
                    foreach (var item in SelectDetMoviIng)
                    {
                        info_costo_historico = bus_costo_historico.get_UltimoCosto_x_Producto_Bodega(info_ajuste.IdEmpresa, info_ajuste.IdSucursal, info_ajuste.IdBodega, item.IdProducto, info_ing_egr.cm_fecha);


                        in_Ing_Egr_Inven_det_Info detMovInfo = new in_Ing_Egr_Inven_det_Info();
                        //detMovInfo.dm_peso = item.p;
                        detMovInfo.dm_cantidad = Convert.ToDouble(item.CantidadAjustada);
                        detMovInfo.dm_cantidad_sinConversion = Convert.ToDouble(item.CantidadAjustada);
                        detMovInfo.IdProducto        = item.IdProducto;
                        detMovInfo.Secuencia         = c;
                        detMovInfo.IdEmpresa         = info_ajuste.IdEmpresa;
                        detMovInfo.IdBodega          = info_ing_egr.IdBodega;
                        detMovInfo.IdSucursal        = info_ing_egr.IdSucursal;
                        detMovInfo.IdMovi_inven_tipo = info_ing_egr.IdMovi_inven_tipo;
                        detMovInfo.IdNumMovi         = 0;//Nuevo
                        detMovInfo.signo             = info_ing_egr.signo;
                        detMovInfo.dm_observacion    = info_ajuste.Observacion;
                        //Costo historico
                        detMovInfo.mv_costo = info_costo_historico.costo;
                        detMovInfo.mv_costo_sinConversion = info_costo_historico.costo;
                        detMovInfo.IdCentroCosto          = item.IdCentroCosto;
                        info_ing_egr.listIng_Egr.Add(detMovInfo);
                        c++;
                    }
                    bus_ing_egr.GuardarDB(info_ing_egr, ref IdNumMovi_ing, ref mensaje);
                }


                #endregion
                #region HayEgreso
                HayEgresos = (Convert.ToDouble(TEgresos) > 0) ? true : false;

                if (HayEgresos == true)
                {
                    info_ing_egr = new in_Ing_Egr_Inven_Info();

                    info_ing_egr.IdEmpresa         = info_ajuste.IdEmpresa;
                    info_ing_egr.IdSucursal        = info_ajuste.IdSucursal;
                    info_ing_egr.IdBodega          = info_ajuste.IdBodega;
                    info_ing_egr.IdMovi_inven_tipo = info_ajuste.IdMovi_inven_tipo_Egr;
                    info_ing_egr.signo             = "-";
                    info_ing_egr.cm_observacion    = info_ajuste.Observacion;
                    info_ing_egr.IdUsuario         = info_ajuste.IdUsuario;
                    info_ing_egr.nom_pc            = info_ajuste.nom_pc;
                    info_ing_egr.ip           = info_ajuste.ip;
                    info_ing_egr.Estado       = "A";
                    info_ing_egr.cm_fecha     = info_ajuste.Fecha;
                    info_ing_egr.CodMoviInven = "AJU";
                    info_ing_egr.IdMotivo_Inv = 1;
                    /// encontrando el detalle de inventario
                    ///
                    var SelectDetMoviEgre = from q in info_ajuste.list_det_AjusteFisico
                                            where q.CantidadAjustada < 0
                                            select q;

                    int c = 1;

                    foreach (var item in SelectDetMoviEgre)
                    {
                        info_costo_historico = bus_costo_historico.get_UltimoCosto_x_Producto_Bodega(info_ajuste.IdEmpresa, info_ajuste.IdSucursal, info_ajuste.IdBodega, item.IdProducto, info_ing_egr.cm_fecha);

                        in_Ing_Egr_Inven_det_Info detMovInfo = new in_Ing_Egr_Inven_det_Info();
                        detMovInfo.IdEmpresa         = info_ing_egr.IdEmpresa;
                        detMovInfo.IdBodega          = info_ing_egr.IdBodega;
                        detMovInfo.IdSucursal        = info_ing_egr.IdSucursal;
                        detMovInfo.IdMovi_inven_tipo = info_ing_egr.IdMovi_inven_tipo;
                        detMovInfo.IdNumMovi         = 0;//Nuevo
                        //detMovInfo.peso = item.pr_peso;
                        detMovInfo.Secuencia = c;
                        c++;
                        detMovInfo.signo       = info_ing_egr.signo;
                        detMovInfo.IdProducto  = item.IdProducto;
                        detMovInfo.dm_cantidad = Convert.ToDouble(item.CantidadAjustada) * -1;
                        detMovInfo.dm_cantidad_sinConversion = Convert.ToDouble(item.CantidadAjustada) * -1;
                        detMovInfo.dm_observacion            = info_ing_egr.cm_observacion;
                        //Costo historico
                        detMovInfo.mv_costo = info_costo_historico.costo;
                        detMovInfo.mv_costo_sinConversion = info_costo_historico.costo;
                        detMovInfo.IdCentroCosto          = item.IdCentroCosto;

                        info_ing_egr.listIng_Egr.Add(detMovInfo);
                    }
                    bus_ing_egr.GuardarDB(info_ing_egr, ref IdNumMovi_egr, ref mensaje);
                }
                #endregion

                return(true);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "Armar_info_ing_egr", ex.Message), ex)
                      {
                          EntityType = typeof(in_AjusteFisico_Bus)
                      };
            }
        }
        public Boolean GuardarDB(in_devolucion_inven_Info info, ref decimal IdDev_Inven, ref string mensaje)
        {
            Boolean Respuesta = false;

            try
            {
                int c = 0;
                Respuesta = oDat.GuardarDB(info, ref IdDev_Inven, ref mensaje);
                if (Respuesta)
                {
                    c = 0;
                    foreach (var item in info.lista_detalle)
                    {
                        item.IdDev_Inven = IdDev_Inven;
                        c++;
                        item.secuencia = c;
                    }
                    in_devolucion_inven_det_Bus BusDev_inv_det = new in_devolucion_inven_det_Bus();
                    Respuesta = BusDev_inv_det.GuardarDB(info.lista_detalle, ref mensaje);


                    in_Parametro_Bus  BusParametro  = new in_Parametro_Bus();
                    in_Parametro_Info InfoParametro = new in_Parametro_Info();
                    InfoParametro = BusParametro.Get_Info_Parametro(info.IdEmpresa);
                    in_movi_inven_tipo_Info InfoMovi_tipo = new in_movi_inven_tipo_Info();
                    in_movi_inven_tipo_Bus  BusMovi_tipo  = new in_movi_inven_tipo_Bus();


                    InfoMovi_tipo = BusMovi_tipo.Get_Info_movi_inven_tipo(info.IdEmpresa, info.IdMovi_inven_tipo);

                    //                    in_movi_inve_Bus BusMovi_Inven = new in_movi_inve_Bus();
                    //                    in_movi_inve_Info InfoMovi_Inven = new in_movi_inve_Info();

                    //InfoMovi_Inven  = BusMovi_Inven.Get_Info_Movi_inven(info.IdEmpresa, info.IdSucursal_movi_inven, info.IdBodega_movi_inven, info.IdMovi_inven_tipo, info.IdNumMovi);

                    in_Ing_Egr_Inven_Bus  Bus_Ing_Egre = new in_Ing_Egr_Inven_Bus();
                    in_Ing_Egr_Inven_Info Info_Ing_Egr = new in_Ing_Egr_Inven_Info();

                    Info_Ing_Egr = Bus_Ing_Egre.Get_Info_Ing_Egr_Inven(info.IdEmpresa, info.IdSucursal_movi_inven, info.IdMovi_inven_tipo, info.IdNumMovi);

                    Info_Ing_Egr.IdNumMovi    = 0;
                    Info_Ing_Egr.IdMotivo_Inv = 1;
                    if (InfoMovi_tipo.cm_tipo_movi == "-")// si es positivo hacer un egreso
                    {
                        Info_Ing_Egr.IdMovi_inven_tipo = Convert.ToInt32(InfoParametro.IdMovi_Inven_tipo_x_Dev_Inv_x_Erg);
                        Info_Ing_Egr.signo             = "+";
                    }
                    else
                    {
                        Info_Ing_Egr.IdMovi_inven_tipo = Convert.ToInt32(InfoParametro.IdMovi_Inven_tipo_x_Dev_Inv_x_Ing);
                        Info_Ing_Egr.signo             = "-";
                    }

                    Info_Ing_Egr.CodMoviInven   = "";
                    Info_Ing_Egr.cm_observacion = "Ing x Dev/Inv. " + info.observacion;
                    Info_Ing_Egr.cm_fecha       = info.Fecha.Date;//La fecha de devolución
                    Info_Ing_Egr.IdUsuario      = param.IdUsuario;
                    Info_Ing_Egr.Estado         = "A";

                    c = 0;


                    foreach (var item in info.lista_detalle)
                    {
                        c = c + 1;
                        in_movi_inve_detalle_Info info_det_movi = new in_movi_inve_detalle_Info();
                        in_movi_inve_detalle_Bus  bus_det_movi  = new in_movi_inve_detalle_Bus();
                        info_det_movi = bus_det_movi.Get_info_Movi_inven_det(item.IdEmpresa_movi_inv, item.IdSucursal_movi_inv, item.IdBodega_movi_inv, item.IdMovi_inven_tipo_movi_inv, item.IdNumMovi_movi_inv, item.Secuencia_movi_inv);

                        in_Ing_Egr_Inven_det_Info InfoDet_Ing_Egr = new in_Ing_Egr_Inven_det_Info();

                        InfoDet_Ing_Egr.IdEmpresa  = item.IdEmpresa;
                        InfoDet_Ing_Egr.IdSucursal = item.IdSucursal_movi_inv;
                        InfoDet_Ing_Egr.IdNumMovi  = 0;
                        InfoDet_Ing_Egr.Secuencia  = c;
                        InfoDet_Ing_Egr.IdBodega   = item.IdBodega_movi_inv;
                        InfoDet_Ing_Egr.IdProducto = info_det_movi.IdProducto;
                        if (Info_Ing_Egr.signo == "+")// si es positivo hacer un egreso
                        {
                            InfoDet_Ing_Egr.dm_cantidad_sinConversion = Math.Abs(item.cantidad_a_devolver);
                            InfoDet_Ing_Egr.dm_cantidad    = Math.Abs(item.cantidad_a_devolver);
                            InfoDet_Ing_Egr.IdEstadoAproba = "APRO";//Debe ir directamente aprobado para poder vincularlo al ing/egr que se va a devolver por cuestiones del recosteo
                        }
                        else
                        {
                            InfoDet_Ing_Egr.dm_cantidad_sinConversion = Math.Abs(item.cantidad_a_devolver);
                            InfoDet_Ing_Egr.dm_cantidad    = Math.Abs(item.cantidad_a_devolver) * -1;
                            InfoDet_Ing_Egr.IdEstadoAproba = "APRO";//Debe ir directamente aprobado para poder vincularlo al ing/egr que se va a devolver por cuestiones del recosteo
                        }

                        //Se pasa directamente el costo y unidad de medida convertido
                        InfoDet_Ing_Egr.mv_costo_sinConversion = (info_det_movi.mv_costo == null) ? 0 : Convert.ToDouble(info_det_movi.mv_costo);
                        InfoDet_Ing_Egr.mv_costo                     = (info_det_movi.mv_costo == null) ? 0 : Convert.ToDouble(info_det_movi.mv_costo);
                        InfoDet_Ing_Egr.IdUnidadMedida               = info_det_movi.IdUnidadMedida;
                        InfoDet_Ing_Egr.IdUnidadMedida_Consumo       = info_det_movi.IdUnidadMedida;
                        InfoDet_Ing_Egr.IdUnidadMedida_sinConversion = info_det_movi.IdUnidadMedida;

                        //Ingreso los id del detalle que esta devolviendo
                        InfoDet_Ing_Egr.IdEmpresa_dev         = item.IdEmpresa_movi_inv;
                        InfoDet_Ing_Egr.IdSucursal_dev        = item.IdSucursal_movi_inv;
                        InfoDet_Ing_Egr.IdBodega_dev          = item.IdBodega_movi_inv;
                        InfoDet_Ing_Egr.IdMovi_inven_tipo_dev = item.IdMovi_inven_tipo_movi_inv;
                        InfoDet_Ing_Egr.IdNumMovi_dev         = item.IdNumMovi_movi_inv;
                        InfoDet_Ing_Egr.Secuencia_dev         = item.Secuencia_movi_inv;

                        //Campos de egresos
                        InfoDet_Ing_Egr.IdPunto_cargo                  = info_det_movi.IdPunto_Cargo;
                        InfoDet_Ing_Egr.IdPunto_cargo_grupo            = info_det_movi.IdPunto_cargo_grupo;
                        InfoDet_Ing_Egr.IdCentroCosto                  = info_det_movi.IdCentroCosto;
                        InfoDet_Ing_Egr.IdCentroCosto_sub_centro_costo = info_det_movi.IdCentroCosto_sub_centro_costo;

                        Info_Ing_Egr.listIng_Egr.Add(InfoDet_Ing_Egr);
                    }

                    decimal IdNumMovi = 0;

                    Respuesta = Bus_Ing_Egre.GuardarDB(Info_Ing_Egr, ref IdNumMovi, ref mensaje);
                }


                return(Respuesta);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "GuardarDB", ex.Message), ex)
                      {
                          EntityType = typeof(in_devolucion_inven_Bus)
                      };
            }
        }