IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_VergiTutar]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
BEGIN 
DECLARE @SQL VARCHAR(4000) = '
create function [dbo].[fn_VergiTutar]
( @VergiMatrah float = 0.0,
  @VergiOran   float = 0.0
) RETURNS float 

as

BEGIN

  /* NULL Kontrol */
  set @VergiMatrah = IsNull( @VergiMatrah,
                             0
                           )

  set @VergiOran   = IsNull( @VergiOran,
                             0
                           )

  /* Vergi Tutarı   = Vergi Matrahı * ( Vergi Oranı (%) / 100 )        */

                           /* Noktadan Sonra 2 Haneye Yuvarla     */
   return dbo.FN_RoundBanker( @VergiMatrah * ( @VergiOran  / 100 ),
                              2 
                            ) 

END
'

EXEC(@SQL)
END
