SELECT dbo.STHAR.SUBE_KODU, dbo.STHAR.STOK_KODU, dbo.STSABIT.STOK_ADI, dbo.STSABIT.GRUP_KODU AS SGRUP_KODU, dbo.STGRUP.GRUP_ISIM AS SGRUP_ISIM, dbo.STSABIT.KOD_1 AS SKOD_1, dbo.STOKKOD1.GRUP_ISIM AS SKOD1_ISIM, dbo.STSABIT.KOD_2 AS SKOD_2, dbo.STOKKOD2.GRUP_ISIM AS SKOD2_ISIM, dbo.STSABIT.SATICI_KODU, dbo.STHAR.STHAR_ACIKLAMA, dbo.CASABIT.CARI_ISIM, dbo.CASABIT.CARI_TIP, dbo.CASABIT.GRUP_KODU AS CGRUP_KODU, dbo.CASABIT.RAPOR_KODU1 AS CKOD_1, dbo.CARIKOD1.GRUP_ISIM AS CKOD1_ISIM, dbo.CASABIT.RAPOR_KODU2 AS CKOD_2, dbo.CASABIT.CARI_IL, dbo.CASABIT.CARI_ILCE, dbo.STHAR.STHAR_HTUR, dbo.STHAR.STHAR_KOD1, dbo.STHAR.STHAR_KOD2, dbo.STHAR.STHAR_TARIH, dbo.STHAR.FISNO AS STHAR_FISNO, dbo.STHAR.AMBAR_KABULNO, dbo.STHAR.IRSALIYE_NO, dbo.STHAR.STHAR_ODEGUN, dbo.STHAR.STHAR_BF, dbo.STHAR.STHAR_NF, dbo.STHAR.STHAR_IAF, (dbo.STHAR.STHAR_BF - dbo.STHAR.STHAR_NF * (CASE WHEN FATUIRS.KDV_DAHILMI = 'E' THEN (1 + STHAR.STHAR_KDV / 100) ELSE 1 END)) * dbo.STHAR.STHAR_GCMIK AS ISKONTOTUT, CASE WHEN STHAR.STHAR_SATISK < 0.00100 THEN STHAR.STHAR_SATISK * 100000 ELSE STHAR.STHAR_SATISK END AS STHAR_SATISK, dbo.STHAR.STHAR_MALFISK, dbo.STSABIT.OLCU_BR1, dbo.STSABIT.OLCU_BR2, dbo.STSABIT.OLCU_BR3, (CASE WHEN STHAR.STHAR_GCKOD = 'G' THEN STHAR.STHAR_GCMIK ELSE 0 END) AS GIRISM, (CASE WHEN STHAR.STHAR_GCKOD = 'G' THEN STHAR.STHAR_GCMIK ELSE 0 END) * (CASE WHEN STSABIT.PAYDA_1 = 0 THEN 0 ELSE (STSABIT.PAY_1 / STSABIT.PAYDA_1) END) AS GRISIM2, (CASE WHEN STHAR.STHAR_GCKOD = 'G' THEN STHAR.STHAR_GCMIK ELSE 0 END) * (CASE WHEN STSABIT.PAYDA2 = 0 THEN 0 ELSE (STSABIT.PAY2 / STSABIT.PAYDA2) END) AS GIRISM3, (CASE WHEN STHAR.STHAR_GCKOD = 'G' THEN STHAR.STHAR_GCMIK ELSE 0 END) * dbo.STHAR.STHAR_NF AS NETGIRISTUT, (CASE WHEN STHAR.STHAR_GCKOD = 'G' THEN STHAR.STHAR_GCMIK ELSE 0 END) * dbo.STHAR.STHAR_BF AS BRUTGIRISTUT, (CASE WHEN STHAR.STHAR_GCKOD = 'G' THEN STHAR.STHAR_GCMIK ELSE 0 END) * dbo.STHAR.STHAR_IAF AS IADEGIRISTUT, (CASE WHEN STHAR.STHAR_GCKOD = 'C' THEN STHAR.STHAR_GCMIK ELSE 0 END) AS CIKISM, (CASE WHEN STHAR.STHAR_GCKOD = 'C' THEN STHAR.STHAR_GCMIK ELSE 0 END) * (CASE WHEN STSABIT.PAYDA_1 = 0 THEN 0 ELSE (STSABIT.PAY_1 / STSABIT.PAYDA_1) END) AS CIKISM2, (CASE WHEN STHAR.STHAR_GCKOD = 'C' THEN STHAR.STHAR_GCMIK ELSE 0 END) * (CASE WHEN STSABIT.PAYDA2 = 0 THEN 0 ELSE (STSABIT.PAY2 / STSABIT.PAYDA2) END) AS CIKISM3, (CASE WHEN STHAR.STHAR_GCKOD = 'C' THEN STHAR.STHAR_GCMIK ELSE 0 END) * dbo.STHAR.STHAR_NF AS NETCIKISTUT, (CASE WHEN STHAR.STHAR_GCKOD = 'C' THEN STHAR.STHAR_GCMIK ELSE 0 END) * dbo.STHAR.STHAR_BF AS BRUTCIKISTUT, dbo.STHAR.STHAR_KDV, dbo.STHAR.STHAR_GCMIK * dbo.STHAR.STHAR_NF * dbo.STHAR.STHAR_KDV / 100 AS KDV_TUT, dbo.STHAR.STHAR_SIPNUM, dbo.STHAR.STHAR_DOVTIP, dbo.STHAR.STHAR_DOVFIAT, dbo.STHAR.STHAR_GCMIK * dbo.STHAR.STHAR_DOVFIAT AS DOVIZ_TUTARI, (CASE WHEN STHAR.STHAR_GCKOD = 'G' THEN STHAR.STHAR_GCMIK2 ELSE 0 END) AS IKINCI_GIRIS_MIKTAR, (CASE WHEN STHAR.STHAR_GCKOD = 'C' THEN STHAR.STHAR_GCMIK2 ELSE 0 END) AS IKINCI_CIKIS_MIKTAR, (CASE WHEN STHAR.STHAR_GCKOD = 'G' THEN STHAR.STHAR_GCMIK ELSE 0 END) * dbo.STHAR.STHAR_NF + (CASE WHEN STHAR.STHAR_GCKOD = 'G' THEN STHAR.STHAR_GCMIK ELSE 0 END) * dbo.STHAR.STHAR_NF * dbo.STHAR.STHAR_KDV / 100 AS ALIS_TOPLAM, (CASE WHEN STHAR.STHAR_GCKOD = 'C' THEN STHAR.STHAR_GCMIK ELSE 0 END) * dbo.STHAR.STHAR_NF + (CASE WHEN STHAR.STHAR_GCKOD = 'C' THEN STHAR.STHAR_GCMIK ELSE 0 END) * dbo.STHAR.STHAR_NF * dbo.STHAR.STHAR_KDV / 100 AS SATIS_TOPLAM, dbo.STHAR.CEVRIM, (CASE WHEN STHAR.STHAR_GCKOD = 'C' THEN (STHAR.CEVRIM * STHAR.STHAR_GCMIK * STHAR.STHAR_NF) ELSE 0 END) AS BEKLEME_ADATI, dbo.STSABITEK.TUR, dbo.STSABITEK.MGRUP AS MRUP, dbo.STSABITEK.INGISIM, dbo.STSABITEK.KULL1N, dbo.STSABITEK.KULL2N, dbo.STSABITEK.KULL1S, dbo.STSABITEK.KULL2S, dbo.STHAR.DEPO_KODU, dbo.STHAR.PROMASYON_KODU, dbo.STHAR.BAGLANTI_NO, dbo.STHAR.VADE_TARIHI, dbo.STHAR.LISTE_NO, dbo.STHAR.LISTE_FIAT, dbo.CARIKOD2.GRUP_ISIM AS CKOD2_ISIM, dbo.STHAR.PLASIYER_KODU AS PLAS_KOD, dbo.STHAR.PROJE_KODU, dbo.STHAR.EKALAN_NEDEN, dbo.STHAR.EKALAN, dbo.STHAR.EKALAN1 AS EKALAN2, dbo.STHAR.MUH_KODU AS MUHKODU, dbo.PROJE.PROJE_ACIKLAMA, ISKONTIP1.ACIKLAMA AS ISKONTO1_ACIKLAMA, ISKONTIP2.ACIKLAMA AS ISKONTO2_ACIKLAMA, ISKONTIP3.ACIKLAMA AS ISKONTO3_ACIKLAMA, (CASE WHEN (STSABIT.B_YEDEK7 = 1) OR (STSABIT.B_YEDEK7 = 2) THEN 'E' ELSE 'H' END) AS KITSTOGU, (CASE WHEN STHAR.L_YEDEK9 = - 1 THEN 'K' ELSE (CASE WHEN STHAR.L_YEDEK9 > 0 THEN 'B' ELSE 'N' END) END) AS KITHAREKETI, dbo.STSABIT.KOD_3 AS KOD3, dbo.STSABIT.KOD_4 AS KOD4, dbo.STSABIT.KOD_5 AS KOD5, dbo.CASABIT.RAPOR_KODU3 AS CKOD_3, dbo.CASABIT.RAPOR_KODU4 AS CKOD_4, dbo.CASABIT.RAPOR_KODU5 AS CKOD_5, dbo.STHAR.YAPKOD, CASE WHEN STSABIT.YAPILANDIR = 'E' THEN DBO.NSF_YAPACIK(STHAR.YAPKOD, STOKPARAM.C_YEDEK8, ESNYAPMAS.YAPACIK) ELSE NULL END AS YAPACIK, dbo.TBLCARIPLASIYER.PLASIYER_ACIKLAMA, dbo.TBLCARIPLASIYER.ISIM, dbo.TBLCARIPLASIYER.GRUPKODU, dbo.FATUIRS.CARI_KODU, (CASE WHEN STHAR.STHAR_GCKOD = 'C' THEN STHAR.STHAR_GCMIK ELSE 0 END) * dbo.STHAR.STHAR_NF + dbo.STHAR.STHAR_GCMIK * dbo.STHAR.STHAR_NF * dbo.STHAR.STHAR_KDV / 100 AS TOPLAM FROM dbo.STHAR INNER JOIN dbo.STSABIT ON dbo.STHAR.STOK_KODU = dbo.STSABIT.STOK_KODU INNER JOIN dbo.NETCONTEXT ON 1 = 1 INNER JOIN dbo.TBLSTOKPARAM AS STOKPARAM WITH (NOLOCK) ON STOKPARAM.ISLETME_KODU = dbo.NETCONTEXT.V$ISLETME_KODU LEFT OUTER JOIN dbo.STGRUP ON dbo.STSABIT.GRUP_KODU = dbo.STGRUP.GRUP_KOD LEFT OUTER JOIN dbo.CASABIT ON dbo.STHAR.STHAR_ACIKLAMA = dbo.CASABIT.CARI_KOD INNER JOIN dbo.STSABITEK ON dbo.STSABIT.STOK_KODU = dbo.STSABITEK.STOK_KODU INNER JOIN dbo.TBLCARIPLASIYER ON dbo.STHAR.PLASIYER_KODU = dbo.TBLCARIPLASIYER.PLASIYER_KODU RIGHT OUTER JOIN dbo.FATUIRS ON dbo.TBLCARIPLASIYER.PLASIYER_KODU = dbo.FATUIRS.PLA_KODU AND dbo.FATUIRS.CARI_KODU = dbo.STHAR.STHAR_ACIKLAMA AND dbo.STHAR.STHAR_FTIRSIP = dbo.FATUIRS.FTIRSIP AND dbo.STHAR.FISNO = dbo.FATUIRS.FATIRS_NO LEFT OUTER JOIN dbo.STOKKOD1 ON dbo.STSABIT.KOD_1 = dbo.STOKKOD1.GRUP_KOD LEFT OUTER JOIN dbo.CARIKOD1 ON dbo.CASABIT.RAPOR_KODU1 = dbo.CARIKOD1.GRUP_KOD LEFT OUTER JOIN dbo.CARIKOD2 ON dbo.CASABIT.RAPOR_KODU2 = dbo.CARIKOD2.GRUP_KOD LEFT OUTER JOIN dbo.STOKKOD2 ON dbo.STSABIT.KOD_2 = dbo.STOKKOD2.GRUP_KOD LEFT OUTER JOIN dbo.PROJE ON dbo.STHAR.PROJE_KODU = dbo.PROJE.PROJE_KODU LEFT OUTER JOIN dbo.ISKONTIP AS ISKONTIP1 ON dbo.STHAR.SATISK1TIP = ISKONTIP1.ISKONTOTIP LEFT OUTER JOIN dbo.ISKONTIP AS ISKONTIP2 ON dbo.STHAR.SATISK2TIP = ISKONTIP2.ISKONTOTIP LEFT OUTER JOIN dbo.ISKONTIP AS ISKONTIP3 ON dbo.STHAR.SATISK3TIP = ISKONTIP3.ISKONTOTIP LEFT OUTER JOIN dbo.TBLESNYAPMAS AS ESNYAPMAS WITH (NOLOCK) ON ESNYAPMAS.YAPKOD = dbo.STHAR.YAPKOD
|