Cari hesap bakiyeleri ile muhasebe deki bakiyelerini kontrol etmek için aşağıdaki sorgudan faydalanıyorum. Ancak; sorguda açılış rakamları ve sadece 1. ay bakiye kontrolü yapılabilyor. 12 ay bakiye kontolünün yapılabilmesi için sorguda neyi değiştirmeliyim veya ilave etmeliyim. Yardımlarınız bekliyorum. Şimdiden teşekkürler.
SELECT CariKod, CariHesap, MuhasebeKod, MuhasebeHesap, ISNULL
((SELECT SUM(F.DEBIT - F.CREDIT)
FROM LG_013_01_EMFLINE F
WHERE F.CANCELLED = 0 AND MONTH(F.DATE_) = 1 AND F.TRCODE = 1 AND F.ACCOUNTCODE = A.MuhasebeKod), 0) AS MuhasebeAcilis,
ISNULL
((SELECT SUM(F.DEBIT - F.CREDIT)
FROM LG_013_01_EMFLINE F
WHERE F.CANCELLED = 0 AND MONTH(F.DATE_) = 1 AND F.ACCOUNTCODE = A.MuhasebeKod), 0) AS MuhasebeBakiye, isNULL
((SELECT SUM(CASE C.SIGN WHEN 0 THEN C.AMOUNT ELSE C.AMOUNT * - 1 END)
FROM LG_013_01_CLFLINE C
WHERE C.CANCELLED = 0 AND MONTH(C.DATE_) = 1 AND C.CLIENTREF = A.LOGICALREF AND C.TRCODE = 14), 0) AS CariAcilis, isNULL
((SELECT SUM(CASE C.SIGN WHEN 0 THEN C.AMOUNT ELSE C.AMOUNT * - 1 END)
FROM LG_013_01_CLFLINE C
WHERE C.CANCELLED = 0 AND MONTH(C.DATE_) = 1 AND C.CLIENTREF = A.LOGICALREF), 0) AS CariBakiye
FROM (SELECT LOGICALREF, CODE AS CariKod, DEFINITION_ AS CariHesap,
(SELECT MK.CODE
FROM LG_013_EMUHACC MK
WHERE MK.LOGICALREF =
(SELECT B.ACCOUNTREF
FROM LG_013_CRDACREF B
WHERE (B.TRCODE = 5) AND CK.LOGICALREF = B.CARDREF)) AS MuhasebeKod,
(SELECT MK.DEFINITION_
FROM LG_013_EMUHACC MK
WHERE MK.LOGICALREF =
(SELECT B.ACCOUNTREF
FROM LG_013_CRDACREF B
WHERE (B.TRCODE = 5) AND CK.LOGICALREF = B.CARDREF)) AS MuhasebeHesap
FROM LG_013_CLCARD CK) A