SELECT
TOP
100 PERCENT
cha_evrakno_seri AS
[#SERİ NO]
,cha_evrakno_sira AS
[#SIRA NO]
,cha_belge_no AS
[#BELGE NO]
,ISNULL(F.[efd_gib_seri]
+
REPLACE(STR(F.[efd_gib_sira],9),SPACE(1),'0'),'')
AS
[FATURA NO]
,cha_tarihi AS
[FATURA TARİHİ]
,cha_kod AS
[#FİRMA KODU]
,dbo.fn_CarininIsminiBul(cha_cari_cins,cha_kod)
AS
[FİRMA]
,cha_EXIMkodu AS
[#İHRACAT KODU]
,(SELECT TOP
1 dbo.fn_DatePart(est_beyannametarihi)
FROM
dbo.STOK_HAREKETLERI WITH (NOLOCK)
LEFT OUTER
JOIN
dbo.EDI_TCGB_KALEMLERI WITH(NOLOCK,
INDEX=NDX_EDI_TCGB_KALEMLERI_02)
ON (est_DRECid_DBCno=sth_RECid_DBCno
AND
est_DRECid_RECno=sth_RECid_RECno)
WHERE
sth_fat_recid_recno=cha_RECid_RECno)
AS
[GB TARİHİ]
,gumruk_gumrukadi AS
[GÜMRÜK MD.]
,(SELECT TOP
1 est_beyannameno
FROM
dbo.STOK_HAREKETLERI WITH (NOLOCK)
LEFT OUTER
JOIN
dbo.EDI_TCGB_KALEMLERI WITH (NOLOCK,
INDEX
=
NDX_EDI_TCGB_KALEMLERI_02)
ON (est_DRECid_DBCno=sth_RECid_DBCno
AND
est_DRECid_RECno=sth_RECid_RECno)
WHERE
sth_fat_recid_recno=cha_RECid_RECno)
AS
[GB NO]
,IHR.ihr_Intac_Tarihi
AS
[İNTAÇ TARİHİ]
,cha_meblag AS
[DÖVİZ]
,dbo.fn_DovizSembolu(cha_d_cins)
AS
[CİNSİ]
,cha_d_kur AS
[KURU]
,cha_meblag *
cha_d_kur AS [TUTAR]
,ROW_NUMBER()
over(ORDER
by
cha_belge_no ASC) AS
[SIRA NO]
FROM
dbo.CARI_HESAP_HAREKETLERI WITH (NOLOCK,
INDEX
=
NDX_CARI_HESAP_HAREKETLERI_04)
LEFT OUTER
JOIN
dbo.IHRACAT_DOSYALARI IHR WITH(NOLOCK)
ON
(ihr_kodu
=
cha_EXIMkodu)
LEFT OUTER
JOIN
MikroDB_V15.dbo.GUMRUK_TANIMLARI
WITH(NOLOCK)
ON
(gumruk_gumrukkodu
=
ihr_GumrukKodu)
LEFT OUTER
JOIN
E_FATURA_DETAYLARI AS F WITH (NOLOCK)
ON (F.efd_fat_recid_dbcno=cha_RECid_DBCno AND F.efd_fat_recid_recno=cha_RECid_RECno)
WHERE cha_tip=0 AND cha_cinsi=29 AND cha_evrak_tip=63