-- =============================================
-- Author:		Marian Zaki
-- Create date: 29/11/2010
-- Description:	Checks for data validation 
-- =============================================
-- C6MartPeriodico].[CHECK_GET_S10_Negative_BankAccount] 'f','LGGRRT61R13L736R'
CREATE PROCEDURE [C6MartPeriodico].[CHECK_GET_S10_Negative_BankAccount]
@Rete char(1), 
@CodiceFiscale varchar(16)
AS
BEGIN
SELECT
NOMEPATRIMONIO,
ORDINAMENTO,
ASSETCLASSNAME,
CONTROVALORE,
PERCENTUALE,
TOTALE
FROM
(
		SELECT 
				'BF' AS NOMEPATRIMONIO, 
			9999 AS ORDINAMENTO ,
			'' AS ASSETCLASSID ,
			'' AS ASSETCLASSNAME,
			sum(saldo) as CONTROVALORE,
			0.00 AS PERCENTUALE ,
			sum(saldo) as totale 
		  FROM [C6STAMPECENTRALIZZATE].[C6MARTPERIODICO].anag_cc
		  WHERE
		  RETE= @Rete
		  AND COD_FISCALE= @CodiceFiscale
) K
WHERE TOTALE < 0
END