DSYB Bilgi Yönetim Sisteminde Kullanmış olduğım Cari hesap özetinin SQL Kodları
ALTER FUNCTION [dbo].[GET_LOGO_EKSTRE] ( -- Add the parameters for the function here
@REF INTEGER )
RETURNS TABLE
AS
RETURN
(
SELECT DATE_ AS TARIH ,
TRANNO AS BELGENO ,
LINEEXP ,
DEBIT AS BORC ,
CREDIT AS ALACAK
FROM BDSYB2014.dbo.LV_001_01_CLEKSTRE
WHERE CLIENTREF = @REF
AND TRCODE NOT IN ( 38, 39 )
UNION ALL
SELECT BDSYB2014.dbo.LV_001_01_CLEKSTRE.DATE_ ,
BDSYB2014.dbo.LV_001_01_CLEKSTRE.TRANNO ,
CONVERT(VARCHAR, BDSYB2014.dbo.LV_001_01_STLINE.AMOUNT, 102)
+ '- Ad. ' + BDSYB2014.dbo.LV_001_01_STLINE.LINEEXP AS ACIKLAMA ,
( SELECT VATAMNT + VATMATRAH
FROM BDSYB2014.dbo.LG_001_01_STLINE
WHERE BDSYB2014.dbo.LG_001_01_STLINE.LOGICALREF = BDSYB2014.dbo.LV_001_01_STLINE.LOGICALREF
) AS BORC ,
CASE ( SELECT TOP 1
PAIDINCASH
FROM BDSYB2014.dbo.LG_001_01_INVOICE
WHERE LOGICALREF = BDSYB2014.dbo.LV_001_01_CLEKSTRE.SOURCEFREF
)
WHEN 1
THEN ( SELECT VATAMNT + VATMATRAH
FROM BDSYB2014.dbo.LG_001_01_STLINE
WHERE BDSYB2014.dbo.LG_001_01_STLINE.LOGICALREF = BDSYB2014.dbo.LV_001_01_STLINE.LOGICALREF
)
ELSE 0
END AS ALACAK
FROM BDSYB2014.dbo.LV_001_01_CLEKSTRE
INNER JOIN BDSYB2014.dbo.LV_001_01_STLINE ON BDSYB2014.dbo.LV_001_01_CLEKSTRE.SOURCEFREF = BDSYB2014.dbo.LV_001_01_STLINE.INVOICEREF
WHERE ( BDSYB2014.dbo.LV_001_01_CLEKSTRE.CLIENTREF = @REF )
AND ( BDSYB2014.dbo.LV_001_01_CLEKSTRE.TRCODE IN ( 38, 39 ) )
)