USE [Inversiones_20190711]
GO
/****** Object:  StoredProcedure [dbo].[SP_PROPIN_PRINT]    Script Date: 7/15/2019 12:15:06 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Bladimir Cortez
-- Create date: 
-- Description:	
-- =============================================
ALTER PROCEDURE [dbo].[SP_PROPIN_PRINT] 
	-- Add the parameters for the stored procedure here
	@IdPropuesta as int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
SELECT
	T0.[DocId]
	,T0.[CodInv] 'CodigoPropuesta'
	,T0.[CodEmis] 'CodigoEmisor'
	,(SELECT S0.Descrip FROM [dbo].[EMIS] S0 WHERE S0.CodEmis=T0.[CodEmis]) 'NombreEmisor'
	,T0.[CodCalRi] 'CodigoCalificacionDeRiesgo'
	,(SELECT S0.Descrip FROM [dbo].[CALRI] S0 WHERE S0.CodCalRi=T0.[CodCalRi]) 'CalificacionDeRiesgo'
	,T0.[CodECalRi] 'CodigoEmpresaCalificadora'
	,(SELECT S0.Descrip FROM [dbo].[ECALRI] S0 WHERE S0.CodECalRi=T0.[CodECalRi]) 'NombreEmpresaCalificadora'
	,T0.[Asunto] 'Asunto'
	,T0.[CodIF] 'CodigoInstrumentoFinanciero'
	,(SELECT S0.Descrip FROM [dbo].[INFI] S0 WHERE S0.CodIF=T0.[CodIF]) 'InstrumentoFinanciero'
	,T0.[CodEmpr] 'CodigoEmpresa'
	,(SELECT S0.Descrip FROM EMPR S0 WHERE S0.CodEmpr=T0.[CodEmpr]) 'NombreEmpresa'
	,T0.[CodPais] 'CodigoPais'
	,(SELECT S0.Descrip FROM PAIS S0 WHERE S0.CodPais=T0.[CodPais]) 'NombrePais'
	,T0.[OFon] 'OrigenDeFondos'
	,T0.[Plazo] 'PlazoNumero'
	,T0.[PlazoFact] 'PlazoFactor'
	,NULL 'AnioBase'
	,T0.[MontoInv] 'MontoInversion'
	,T0.[Precio] 'PrecioInversion'
	,T0.[Rendimiento] 'Rendimiento'
	,T0.[Ingresos] 'Ingresos'
	,T0.[TipoOper] 'TipoOperacion'
	,T0.[DocEst] 'EstadoDocumento'
	,T0.[FechaDoc] 'FechaOperacion'
	,T0.[FechaDoc] 'FechaVencimiento'
	,T0.[Just] 'Justificacion'
	,T0.[Coment] 'Comentarios'
FROM [dbo].[PIN0] T0 
WHERE T0.DocId = @IdPropuesta


END



