public cp_rpt_nota_credito_Info Get_Info_rpt_nota_credito(int IdEmpresa, decimal IdProveedor, decimal IdCbteCble_NotaC, int IdTipoCbte_NotaC) { try { cp_rpt_nota_credito_Info Datos = new cp_rpt_nota_credito_Info(); tb_Empresa_Data Empresa_D = new tb_Empresa_Data(); cp_proveedor_Data Proveedor_D = new cp_proveedor_Data(); cp_nota_DebCre_Data NotaCr_D = new cp_nota_DebCre_Data(); //cp_orden_giro_pagos_Data PagosOG_D = new cp_orden_giro_pagos_Data(); tb_persona_data Persona_D = new tb_persona_data(); cp_proveedor_Info Proveedor_I = new cp_proveedor_Info(); Proveedor_I = Proveedor_D.Get_Info_Proveedor(IdEmpresa, IdProveedor); Datos.Empresa = Empresa_D.Get_Info_Empresa(IdEmpresa); Datos.Proveedor = Proveedor_I; Datos.NotaCr = NotaCr_D.Get_Info_nota_DebCre(IdEmpresa, IdCbteCble_NotaC, IdTipoCbte_NotaC); Datos.Persona = Persona_D.Get_Info_Persona(Proveedor_I.IdPersona); return(Datos); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.ToString()); } }
public bool EliminarDB_Todos(int IdEmpresa, ref string message) { try { cp_proveedor_Data data = new cp_proveedor_Data(); return(data.EliminarDB_Todos(IdEmpresa, ref message)); } 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("", "EliminarDB", ex.Message), ex) { EntityType = typeof(cp_proveedor_Bus) }; } }
public bool ModificarDB(in_Consignacion_Info info) { try { in_Ing_Egr_Inven_Data data_inv = new in_Ing_Egr_Inven_Data(); cp_proveedor_Data data_proveedor = new cp_proveedor_Data(); using (Entities_inventario db = new Entities_inventario()) { in_Consignacion Entity = db.in_Consignacion.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdConsignacion == info.IdConsignacion).FirstOrDefault(); if (Entity == null) { return(false); } Entity.IdProveedor = info.IdProveedor; Entity.IdBodega = info.IdBodega; Entity.Fecha = info.Fecha; Entity.Observacion = info.Observacion; Entity.IdUsuarioUltMod = info.IdUsuarioUltMod; Entity.Fecha_UltMod = DateTime.Now; var lst_det_consignacion = db.in_ConsignacionDet.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdConsignacion == info.IdConsignacion).ToList(); db.in_ConsignacionDet.RemoveRange(lst_det_consignacion); if (info.lst_producto_consignacion != null) { int Secuencia = 1; foreach (var item in info.lst_producto_consignacion) { db.in_ConsignacionDet.Add(new in_ConsignacionDet { IdEmpresa = info.IdEmpresa, IdConsignacion = info.IdConsignacion, Secuencia = Secuencia++, IdProducto = item.IdProducto, IdUnidadMedida = item.IdUnidadMedida, Cantidad = item.Cantidad, Costo = item.Costo, Observacion = item.Observacion }); } } #region Ingreso egreso inventario var parametro = db.in_parametro.Where(q => q.IdEmpresa == info.IdEmpresa).FirstOrDefault(); info.IdMovi_inven_tipo = parametro.IdMovi_inven_tipo_Consignacion; cp_proveedor_Info dato_proveedor = data_proveedor.get_info(info.IdEmpresa, info.IdProveedor); var nomContacto = dato_proveedor.info_persona.pe_nombreCompleto; in_Ing_Egr_Inven_Info movimiento = armar_movi_inven(info, nomContacto); if (movimiento != null) { movimiento.IdNumMovi = info.IdNumMovi; data_inv.modificarDB(movimiento); } #endregion db.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool GuardarBD(in_Consignacion_Info info) { try { in_Ing_Egr_Inven_Data data_inv = new in_Ing_Egr_Inven_Data(); cp_proveedor_Data data_proveedor = new cp_proveedor_Data(); using (Entities_inventario db = new Entities_inventario()) { var parametro = db.in_parametro.Where(q => q.IdEmpresa == info.IdEmpresa).FirstOrDefault(); info.IdMovi_inven_tipo = parametro.IdMovi_inven_tipo_Consignacion; cp_proveedor_Info dato_proveedor = data_proveedor.get_info(info.IdEmpresa, info.IdProveedor); var nomContacto = dato_proveedor.info_persona.pe_nombreCompleto; in_Ing_Egr_Inven_Info movimiento = armar_movi_inven(info, nomContacto); if (data_inv.guardarDB(movimiento, "+")) { #region Consignacion db.in_Consignacion.Add(new in_Consignacion { IdEmpresa = info.IdEmpresa, IdConsignacion = info.IdConsignacion = GetId(info.IdEmpresa), IdSucursal = info.IdSucursal, IdBodega = info.IdBodega, Fecha = info.Fecha, IdProveedor = info.IdProveedor, Observacion = info.Observacion, Estado = true, IdUsuario = info.IdUsuario, Fecha_Transac = DateTime.Now, IdMovi_inven_tipo = movimiento.IdMovi_inven_tipo, IdNumMovi = movimiento.IdNumMovi, }); #endregion #region Consignacion detalle if (info.lst_producto_consignacion != null) { int Secuencia = 1; foreach (var item in info.lst_producto_consignacion) { db.in_ConsignacionDet.Add(new in_ConsignacionDet { IdEmpresa = info.IdEmpresa, IdConsignacion = info.IdConsignacion, Secuencia = Secuencia++, IdProducto = item.IdProducto, IdUnidadMedida = item.IdUnidadMedida, Cantidad = item.Cantidad, Costo = item.Costo, Observacion = item.Observacion }); } } #endregion } db.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public Boolean Liquidar(imp_ordencompra_ext_Info Obj, ref string mensaje, Cl_Enumeradores.eTipo_action accion) { try { decimal IdCbteLiquidacion = 0; ct_Cbtecble_det_Info _detCbteCble_Info = new ct_Cbtecble_det_Info(); List <ct_Cbtecble_det_Info> LstCbteCble = new List <ct_Cbtecble_det_Info>(); ct_Cbtecble_Info CbteCble_I = new ct_Cbtecble_Info(); imp_ordencompra_ext_det_Bus ImporDet_bus = new imp_ordencompra_ext_det_Bus(); List <imp_ordencompra_ext_det_Info> ListInfo_det_Impor = new List <imp_ordencompra_ext_det_Info>(); in_categorias_data dataCategoria = new in_categorias_data(); ct_Periodo_Bus Per_B = new ct_Periodo_Bus(); ct_Periodo_Info Per_I = new ct_Periodo_Info(); in_Parametro_Data dataInParametro = new in_Parametro_Data(); imp_ordencompra_ext_Bus BusImportacion = new imp_ordencompra_ext_Bus(); ct_Cbtecble_Bus Buscbte = new ct_Cbtecble_Bus(); imp_ordencompra_ext_x_ct_cbtecble_Bus BusOrdxCbt = new imp_ordencompra_ext_x_ct_cbtecble_Bus(); ct_cbtecble_Reversado_Bus BusReverso = new ct_cbtecble_Reversado_Bus(); imp_Parametros_Info tip = new imp_Parametros_Info(); imp_Parametros_Bus Data_parametros = new imp_Parametros_Bus(); cl_parametrosGenerales_Bus param = cl_parametrosGenerales_Bus.Instance; imp_ordencompra_ext_x_ct_cbtecble_Info ordCompraxCbte_info = new imp_ordencompra_ext_x_ct_cbtecble_Info(); tip = Data_parametros.Get_Info_Parametros(param.IdEmpresa); ordCompraxCbte_info.ct_IdEmpresa = ordCompraxCbte_info.imp_IdEmpresa = param.IdEmpresa; ordCompraxCbte_info.imp_IdOrdenCompraExt = Obj.IdOrdenCompraExt; ordCompraxCbte_info.imp_IdSucusal = Obj.IdSucusal; // var DiarioLiqui = BusImportacion.consultaDiariosxImportacion(param.IdEmpresa, Obj.IdSucusal, Obj.IdOrdenCompraExt).Last(var => var.TipoReg == "LQUI") // var CobteLiquidacion = Buscbte.ObtenerObjeto(param.IdEmpresa, DiarioLiqui.ct_IdTipoCbte, DiarioLiqui.IdCbte); switch (accion) { case Cl_Enumeradores.eTipo_action.grabar: if (Obj.ci_tonelaje == null || Obj.ci_tonelaje == 0) { mensaje = "Error al generar Diario de Importación ya que no se puede dividir el total de liquidación para un valor de tonelaje = 0 "; } else { string cod_CbteCble = ""; decimal idCbteCble = 0; string MensajeError = ""; cp_proveedor_Data _Prove_D = new cp_proveedor_Data(); var proveedor = _Prove_D.Get_Info_Proveedor(param.IdEmpresa, Obj.IdProveedor); Per_I = Per_B.Get_Info_Periodo(Obj.IdEmpresa, Obj.ci_fecha_liquidacion, ref MensajeError); string Observacion = "Cont. x Imp. #" + Obj.CodOrdenCompraExt + "'\'" + Obj.IdOrdenCompraExt + " Liquidacion de Importacion :" + proveedor.pr_nombre + "//" + Obj.ci_Observacion; ListInfo_det_Impor = ImporDet_bus.Get_List_ordencompra_ext_det(Obj); int contItems = ListInfo_det_Impor.Count(); foreach (var item in ListInfo_det_Impor) { _detCbteCble_Info = new ct_Cbtecble_det_Info(); var Categoria = dataCategoria.Get_Info_categorias(param.IdEmpresa, item.IdCategoria); if (Categoria.IdCtaCtble_Inve == null) { in_Parametro_Info Info_InParametro = new in_Parametro_Info(); Info_InParametro = dataInParametro.Get_Info_Parametro(param.IdEmpresa); _detCbteCble_Info.IdCtaCble = Info_InParametro.IdCtaCble_Inven; _detCbteCble_Info.dc_Observacion = "Cta. Ctble tomada de los parámetros de inventario / " + Observacion; } else { _detCbteCble_Info.IdCtaCble = Categoria.IdCtaCtble_Inve; _detCbteCble_Info.dc_Observacion = Observacion; } _detCbteCble_Info.IdEmpresa = param.IdEmpresa; _detCbteCble_Info.IdTipoCbte = tip.IdTipoCbte_DiarioLiquidacion; _detCbteCble_Info.dc_Valor = Convert.ToDouble(item.di_subtotal) + (Obj.TotGastosImp / contItems); // debe LstCbteCble.Add(_detCbteCble_Info); } ct_Cbtecble_det_Info obj2 = new ct_Cbtecble_det_Info(); obj2.IdCtaCble = Obj.IdCtaCble_import; obj2.dc_Observacion = Observacion;//"Contabilizacion por Importacion Diario Importacion FOB" + Obj.ci_Observacion; obj2.IdCtaCble = Obj.IdCtaCble_import; obj2.IdTipoCbte = tip.IdTipoCbte_DiarioLiquidacion; obj2.IdEmpresa = Obj.IdEmpresa; obj2.dc_Valor = Obj.TotalLiquidacion * -1; //haber LstCbteCble.Add(obj2); // cabecer ade diario CbteCble_I.IdEmpresa = param.IdEmpresa; CbteCble_I.IdTipoCbte = tip.IdTipoCbte_DiarioLiquidacion; CbteCble_I.CodCbteCble = "IM"; CbteCble_I.IdPeriodo = Per_I.IdPeriodo; CbteCble_I.cb_Fecha = Obj.ci_fecha_liquidacion; CbteCble_I.cb_Observacion = Observacion;// "Cont. de la Importacion #" + Obj.CodOrdenCompraExt + " Diario FOB" + Obj.ci_Observacion + Categoria.ca_Categoria; CbteCble_I.Secuencia = 0; CbteCble_I.Estado = "A"; CbteCble_I.Anio = Obj.ci_fecha.Year; CbteCble_I.Mes = Obj.ci_fecha.Month; CbteCble_I.IdUsuario = param.IdUsuario; CbteCble_I.IdUsuarioUltModi = param.IdUsuario; CbteCble_I.cb_FechaTransac = param.GetDateServer(); CbteCble_I.cb_FechaUltModi = param.GetDateServer(); CbteCble_I.Mayorizado = "N"; CbteCble_I.cb_Valor = Obj.TotalLiquidacion; CbteCble_I._cbteCble_det_lista_info = LstCbteCble; Buscbte.GrabarDB(CbteCble_I, ref idCbteCble, ref MensajeError); IdCbteLiquidacion = idCbteCble; ordCompraxCbte_info.ct_IdTipoCbte = tip.IdTipoCbte_DiarioLiquidacion; ordCompraxCbte_info.ct_IdCbteCble = idCbteCble; ordCompraxCbte_info.TipoReg = "LQUI"; BusOrdxCbt.GuardarDB(ordCompraxCbte_info, ref MensajeError); var DiarioLiqui = BusImportacion.Get_List_DiariosxImportacion(param.IdEmpresa, Obj.IdSucusal, Obj.IdOrdenCompraExt).Last(var => var.TipoReg == "LQUI"); var Diario_Reverso = BusReverso.Get_Info_cbtecble_Reversado(param.IdEmpresa, DiarioLiqui.ct_IdTipoCbte, DiarioLiqui.IdCbte); var CobteLiquidacion = Buscbte.Get_Info_CbteCble(param.IdEmpresa, DiarioLiqui.ct_IdTipoCbte, DiarioLiqui.IdCbte, ref mensaje); Obj.CodCbteCble = CobteLiquidacion.CodCbteCble.ToString(); return(oData.Liquidar(Obj, ref mensaje)); } break; case Cl_Enumeradores.eTipo_action.Anular: decimal IdComprobanteAnulado = 0; string msj = ""; if (IdCbteLiquidacion == 0) { var DiarioLiqui = BusImportacion.Get_List_DiariosxImportacion(param.IdEmpresa, Obj.IdSucusal, Obj.IdOrdenCompraExt).Last(var => var.TipoReg == "LQUI"); var CobteLiquidacion = Buscbte.Get_Info_CbteCble(param.IdEmpresa, DiarioLiqui.ct_IdTipoCbte, DiarioLiqui.IdCbte, ref mensaje); IdCbteLiquidacion = CobteLiquidacion.IdCbteCble; } string motiAnulacion = Obj.motiAnulacion; if (Buscbte.ReversoCbteCble(param.IdEmpresa, IdCbteLiquidacion, tip.IdTipoCbte_DiarioLiquidacion, tip.IdTipoCbte_DiarioLiquidacion_Anul, ref IdComprobanteAnulado, ref msj, param.IdUsuario, motiAnulacion)) { // MessageBox.Show("Anulado"); mensaje = "*** Anulado ***"; ordCompraxCbte_info.ct_IdTipoCbte = tip.IdTipoCbte_DiarioLiquidacion_Anul; ordCompraxCbte_info.ct_IdCbteCble = IdComprobanteAnulado; ordCompraxCbte_info.TipoReg = "ALQUI"; BusOrdxCbt.GuardarDB(ordCompraxCbte_info, ref msj); var DiarioLiqui = BusImportacion.Get_List_DiariosxImportacion(param.IdEmpresa, Obj.IdSucusal, Obj.IdOrdenCompraExt).Last(var => var.TipoReg == "LQUI"); var CobteLiquidacion = Buscbte.Get_Info_CbteCble(param.IdEmpresa, DiarioLiqui.ct_IdTipoCbte, DiarioLiqui.IdCbte, ref mensaje); var Diario_Reverso = BusReverso.Get_Info_cbtecble_Reversado(param.IdEmpresa, DiarioLiqui.ct_IdTipoCbte, DiarioLiqui.IdCbte); if (Diario_Reverso.IdTipoCbte_Anu != 0) { var CobteLiquidacionAnulado = Buscbte.Get_Info_CbteCble(param.IdEmpresa, Diario_Reverso.IdTipoCbte_Anu, Diario_Reverso.IdCbteCble_Anu, ref mensaje); Obj.msgAnuladoReverso = "**Anulado ** Reversado Con diario" + "\n" + CobteLiquidacionAnulado.CodCbteCble; } return(oData.Liquidar(Obj, ref mensaje)); } break; default: break; } 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("", "Liquidar", ex.Message), ex) { EntityType = typeof(imp_ordencompra_ext_Bus) }; } }
public Boolean GenerarDiarioFOB(int IdEmpresa, int IdSucursal, decimal IdImportacion, ref string msg, ref decimal idCbteCble, string idCbteCble_Proveedor) { try { imp_ordencompra_ext_x_ct_cbtecble_Info ordCompraxCbte_info = new imp_ordencompra_ext_x_ct_cbtecble_Info(); ct_Periodo_Info Per_I = new ct_Periodo_Info(); ct_Cbtecble_Info CbteCble_I = new ct_Cbtecble_Info(); List <imp_ordencompra_ext_x_imp_gastosxImport_Det_Info> ListaDetalle = new List <imp_ordencompra_ext_x_imp_gastosxImport_Det_Info>(); imp_gastosximport_x_empresa_Data BusGastosXEmpresa = new imp_gastosximport_x_empresa_Data(); List <imp_gastosximport_x_empresa_Info> lstGastosXEmpresa = new List <imp_gastosximport_x_empresa_Info>(); List <imp_ordencompra_ext_x_imp_gastosxImport_Info> Lst = new List <imp_ordencompra_ext_x_imp_gastosxImport_Info>(); ba_Cbte_Ban_Bus BusCbteBanco = new ba_Cbte_Ban_Bus(); ct_Periodo_Data Per_B = new ct_Periodo_Data(); List <ct_Cbtecble_det_Info> LstCbteCble = new List <ct_Cbtecble_det_Info>(); cl_parametrosGenerales_Bus param = cl_parametrosGenerales_Bus.Instance; ba_Cbte_Ban_Info CbteBan_I = new ba_Cbte_Ban_Info(); imp_Parametros_Data Data_parametros = new imp_Parametros_Data(); var tip = Data_parametros.Get_Info_Parametros(IdEmpresa); imp_ordencompra_ext_x_ct_cbtecble_Data DataOrdxCbt = new imp_ordencompra_ext_x_ct_cbtecble_Data(); cp_proveedor_Data _Prove_D = new cp_proveedor_Data(); imp_ordencompra_ext_Info _Info = oData.Get_Info_ordencompra_ext(IdEmpresa, IdSucursal, IdImportacion); string MensajeError = ""; var proveedor = _Prove_D.Get_Info_Proveedor(param.IdEmpresa, _Info.IdProveedor); Per_I = Per_B.Get_Info_Periodo(_Info.IdEmpresa, _Info.ci_fecha, ref MensajeError); ct_Cbtecble_det_Info _CbteCble_I = new ct_Cbtecble_det_Info(); in_categorias_data producto_data = new in_categorias_data(); //var producto = producto_data.ObtenerObjeto(param.IdEmpresa, _Info.IdCategoria).ca_Categoria; var producto = producto_data.Get_List_categorias(0); string Observacion = _CbteCble_I.dc_Observacion = proveedor.pr_nombre + ".: " + _Info.CodOrdenCompraExt + ": //" + IdImportacion + "//" + "Cont. de la Importacion #" + IdImportacion + @"'\'" + _Info.CodOrdenCompraExt + " Diario FOB" + _Info.ci_Observacion + " : " + producto + ". " + _Info.ci_tonelaje + " T"; _CbteCble_I.IdCtaCble = _Info.IdCtaCble_import; _CbteCble_I.IdEmpresa = IdEmpresa; _CbteCble_I.IdTipoCbte = tip.IdTipoCbte_DiarioFob; _CbteCble_I.dc_Valor = _Info.FOB; LstCbteCble.Add(_CbteCble_I); ct_Cbtecble_det_Info obj2 = new ct_Cbtecble_det_Info(); obj2.IdCtaCble = _Info.IdCtaCble_import; obj2.dc_Observacion = Observacion;// "Cont. de la Importacion #" + IdImportacion + @"'\'" + _Info.CodOrdenCompraExt + " Diario FOB" + _Info.ci_Observacion; obj2.IdCtaCble = idCbteCble_Proveedor; obj2.IdTipoCbte = tip.IdTipoCbte_DiarioFob; obj2.IdEmpresa = _Info.IdEmpresa; obj2.dc_Valor = _Info.FOB * -1; LstCbteCble.Add(obj2); CbteCble_I.IdEmpresa = _Info.IdEmpresa; CbteCble_I.IdTipoCbte = tip.IdTipoCbte_DiarioFob; CbteCble_I.CodCbteCble = "IM"; CbteCble_I.IdPeriodo = Per_I.IdPeriodo; CbteCble_I.cb_Fecha = Convert.ToDateTime(_Info.ci_fecha.ToShortDateString()); CbteCble_I.cb_Valor = _Info.FOB; if (_Info.CodOrdenCompraExt == null || _Info.CodOrdenCompraExt == "") { _Info.CodOrdenCompraExt = "IMP" + IdImportacion; } CbteCble_I.cb_Observacion = Observacion; CbteCble_I.Secuencia = 0; CbteCble_I.Estado = "A"; CbteCble_I.Anio = _Info.ci_fecha.Year; CbteCble_I.Mes = _Info.ci_fecha.Month; CbteCble_I.IdUsuario = param.IdUsuario; CbteCble_I.IdUsuarioUltModi = param.IdUsuario; CbteCble_I.cb_FechaTransac = param.GetDateServer(); CbteCble_I.cb_FechaUltModi = param.GetDateServer(); CbteCble_I.Mayorizado = "N"; CbteCble_I._cbteCble_det_lista_info = LstCbteCble; ct_Cbtecble_Bus CbteCble_B = new ct_Cbtecble_Bus(); string cod_CbteCble = ""; if (CbteCble_B.GrabarDB(CbteCble_I, ref idCbteCble, ref msg) == false) { return(false); } ordCompraxCbte_info.ct_IdEmpresa = ordCompraxCbte_info.imp_IdEmpresa = _Info.IdEmpresa; ordCompraxCbte_info.imp_IdOrdenCompraExt = _Info.IdOrdenCompraExt; ordCompraxCbte_info.imp_IdSucusal = _Info.IdSucusal; ordCompraxCbte_info.ct_IdTipoCbte = tip.IdTipoCbte_DiarioFob; ordCompraxCbte_info.ct_IdCbteCble = idCbteCble; ordCompraxCbte_info.TipoReg = "FOB"; DataOrdxCbt.GuardarDB(ordCompraxCbte_info, ref mensaje); 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("", "consultaDiariosxImportacion", ex.Message), ex) { EntityType = typeof(imp_ordencompra_ext_Bus) }; } }