USE [GizaDb]
GO

/****** Object:  View [dbo].[_Giza_AlacakRaporu]    Script Date: 06.10.2023 14:53:29 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO






ALTER VIEW [dbo].[_Giza_AlacakRaporu] AS

SELECT 'DEMOSIRKET' AS SIRKET,
       A.CARI_KOD,
       dbo.TRK(B.CARI_ISIM) AS CARI_ISIM,
       dbo.TRK(P.PLASIYER_ACIKLAMA) AS PLASIYER_ACIKLAMA,
	   dbo._Brk_Tml_HaritaIl(B.CARI_IL) AS CARI_IL,
       CAST(SUM(A.BORC - A.ALACAK) AS MONEY) AS TUTAR
FROM SIRKETDB..TBLCAHAR A WITH (NOLOCK)
    INNER JOIN SIRKETDB..TBLCASABIT B WITH (NOLOCK)
        ON (A.CARI_KOD = B.CARI_KOD)
    LEFT JOIN SIRKETDB..TBLCARIPLASIYER P WITH (NOLOCK)
        ON (B.PLASIYER_KODU = P.PLASIYER_KODU)
WHERE A.SUBE_KODU <> '2'

GROUP BY A.CARI_KOD,
         B.CARI_ISIM,
         P.PLASIYER_ACIKLAMA,
		 B.CARI_IL

HAVING SUM(A.BORC - A.ALACAK) > 0

GO


