select
'034' FIRMANO,
CASE BNC.CARDTYPE WHEN 1 THEN '(TH) TİCARİ HESAP'
WHEN 2 THEN '(KH) KREDİ HESABI'
WHEN 3 THEN '(DT) DÖVİZLİ TİCARİ HESAP'
WHEN 4 THEN '(DK) DÖVİZLİ KREDİ HESABI'
WHEN 5 THEN '(KK) KREADİ KARTI HESABI'
WHEN 6 THEN '(KD) DÖVİZLİ KREADİ KARTI HESABI'
END 'TÜR'
,BN.CODE 'BANKA KODU'
,BN.DEFINITION_ 'BANKA ADI'
,BNC.CODE 'BANKA HESAP KODU'
,BNC.DEFINITION_ 'BANKA HESAP ADI'
,ISNULL((SELECT ROUND(SUM(DEBIT),2) FROM LG_034_01_BNTOTFIL WHERE CARDREF=BNC.LOGICALREF AND TOTTYP IN(1,4)),0) 'BORÇ'
,ISNULL((SELECT ROUND(SUM(CREDIT),2) FROM LG_034_01_BNTOTFIL WHERE CARDREF=BNC.LOGICALREF AND TOTTYP IN(1,4)),0) 'ALACAK'
,ISNULL((SELECT ROUND(SUM(DEBIT-CREDIT),2) FROM LG_034_01_BNTOTFIL WHERE CARDREF=BNC.LOGICALREF AND TOTTYP IN(1,4)),0) 'BAKIYE',
ISNULL(EMU.CODE,'-') MUHASEBE_KODU,
ISNULL((SELECT SUM(DEBIT) FROM LV_034_01_EMUHTOTV1 EMH WHERE EMH.ACCOUNTREF=EMU.LOGICALREF),0) MUHASEBE_BORÇ,
ISNULL((SELECT SUM(CREDIT)FROM LV_034_01_EMUHTOTV1 EMH WHERE EMH.ACCOUNTREF=EMU.LOGICALREF),0) MUHASEBE_ALACAK,
ISNULL((SELECT SUM(DEBIT) FROM LV_034_01_EMUHTOTV1 EMH WHERE EMH.ACCOUNTREF=EMU.LOGICALREF),0)-ISNULL((SELECT SUM(CREDIT)FROM LV_034_01_EMUHTOTV1 EMH WHERE EMH.ACCOUNTREF=EMU.LOGICALREF),0) MUH_BAKİYE
FROM LG_034_BNCARD BN
LEFT JOIN LG_034_BANKACC BNC ON BNC.BANKREF=BN.LOGICALREF
LEFT JOIN LG_034_CRDACREF CRD ON CRD.CARDREF = BNC.LOGICALREF AND TRCODE=6 AND TYP=1
LEFT JOIN LG_034_EMUHACC EMU ON EMU.LOGICALREF=CRD.ACCOUNTREF
WHERE BNC.ACTIVE=0
Post Views: 504