public in_categorias_Info Get_Info_categorias(int IdEmpresa, string IdCategoria) { try { return(cd.Get_Info_categorias(IdEmpresa, IdCategoria)); } 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("", "ObtenerObjeto", ex.Message), ex) { EntityType = typeof(in_categorias_bus) }; } }
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) }; } }