示例#1
0
        public Boolean AnularFacturaProveedor(cp_orden_giro_Info ordenGiro_I, 
            List<cp_orden_giro_x_com_ordencompra_local_Info> LstImportacionOC, ref decimal IdCbteCbleRev, ref string msg2)
        {
            Boolean res = true;
            try
            {
                if (CbteCble_B.ReversoCbteCble(ordenGiro_I.IdEmpresa, ordenGiro_I.IdCbteCble_Ogiro, ordenGiro_I.IdTipoCbte_Ogiro,
                    Convert.ToInt32(ordenGiro_I.IdTipoCbte_Anulacion), ref IdCbteCbleRev, ref msg2, ordenGiro_I.IdUsuarioUltAnu))
                {
                    ordenGiro_I.IdCbteCble_Anulacion = IdCbteCbleRev;
                    if (data.EliminarDB(ordenGiro_I, ref msg2))
                    {

                        #region Anula Retención
                        decimal idrev = 0;
                        cp_retencion_Info Info_retencion = Bus_Retencion.Get_Info_retencion(ordenGiro_I.IdEmpresa, ordenGiro_I.IdCbteCble_Ogiro, ordenGiro_I.IdTipoCbte_Ogiro);

                        //cp_retencion_x_ct_cbtecble_Info ret_x_dia = ret_B.ObtenerObjetoRetXCbteCble(ordenGiro_I.IdEmpresa, ordenGiro_I.IdCbteCble_Ogiro,
                        //    ordenGiro_I.IdTipoCbte_Ogiro);

                        if (Info_retencion.IdRetencion != 0)
                        {
                            if (!Bus_Retencion.AnularDB(Info_retencion,ref idrev, ref msg2))
                                return false;
                        }
                        #endregion

                        #region Eliminar Aprobación de ing a bodega x OC

                        cp_Aprobacion_Ing_Bod_x_OC_Bus bus_aprob_ing_bod_x_OC = new cp_Aprobacion_Ing_Bod_x_OC_Bus();
                        cp_Aprobacion_Ing_Bod_x_OC_Info info_aprob_ing_bod_x_OC = new cp_Aprobacion_Ing_Bod_x_OC_Info();

                        info_aprob_ing_bod_x_OC = bus_aprob_ing_bod_x_OC.Get_Info_Aprobacion_Ing_Bod_x_OC(ordenGiro_I.IdEmpresa, ordenGiro_I.IdTipoCbte_Ogiro, ordenGiro_I.IdCbteCble_Ogiro);
                        if (info_aprob_ing_bod_x_OC.IdAprobacion!=0)
                        {
                            bus_aprob_ing_bod_x_OC.EliminarDB(info_aprob_ing_bod_x_OC.IdEmpresa, info_aprob_ing_bod_x_OC.IdAprobacion, ordenGiro_I.IdUsuarioUltAnu, ordenGiro_I.MotivoAnu, ref mensaje);
                        }

                        #endregion

                        ocXgastosxImp_B.AnularXOG(ordenGiro_I.IdEmpresa, ordenGiro_I.IdTipoCbte_Ogiro, ordenGiro_I.IdCbteCble_Ogiro,
                            Convert.ToInt32(ordenGiro_I.IdTipoCbte_Anulacion), Convert.ToDecimal(ordenGiro_I.IdCbteCble_Anulacion));

                        Importacion_B.EliminarDB(ordenGiro_I.IdEmpresa, ordenGiro_I.IdCbteCble_Ogiro, ordenGiro_I.IdTipoCbte_Ogiro);
                        
                        OC_B.EliminarLista(LstImportacionOC);
                    }
                    else return false;

                }
                else return false;
            }
            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("", "AnularFacturaProveedor", ex.Message), ex) { EntityType = typeof(cp_orden_giro_Bus) };
            } 
            return  res;

        }