enverdersin
Yeni Üye
- Katılım
- 8 Şub 2019
- Mesajlar
- 163
- En iyi yanıt
- 0
- Puanları
- 18
- Yaş
- 46
- Konum
- istanbul
- Ad Soyad
- ENVER DERSİN
Aşağıdaki sorgu ile Ba-Bs raporunu çekebiliyorum ancak. ihraç kayıtlı faturaların matrahını yanlış geitiriyor ve smmm makbuzu ile kur farkı faturasını getirmiyor. Bunları doğru olarak nasılçekebiliriz
SELECT (CLNTC.TCKNO + CLNTC.TAXNR) AS [TC / VERGI NO], CLNTC.DEFINITION_ AS [SATICI UNVANI], FLOOR(SUM(XXX.LNETSUM2)) AS [KDV HARIC TUTAR],
SUM(XXX.FICHECOUNT2) AS BELGE_ADETI, CLNTC.TAXNR AS [VERGI NO], CLNTC.TCKNO AS [TC NO], CLNTC.TAXOFFICE AS [VERGI DAIRESI], AY, YIL,CLNTC.COUNTRY AS [ÜLKESİ]
FROM (SELECT CLIENTREF, AY = MONTH(DATE_), YIL = YEAR(DATE_), COUNT(DISTINCT LOGICALREF) AS FICHECOUNT2, SUM(NETTOTAL - TOTALVAT)
AS LNETSUM2
FROM dbo.LG_020_04_INVOICE AS INVFC WITH (NOLOCK)
WHERE ((TRCODE IN (1, 2, 3, 4, 12,33)) AND (NETTOTAL <> 0) AND (CLIENTREF <> 0) AND (CANCELLED = 0) OR
(NETTOTAL <> 0) AND (CLIENTREF <> 0) AND (CANCELLED = 0) AND (TRCODE = 13) AND (DECPRDIFF = 0) OR
(NETTOTAL <> 0) AND (CLIENTREF <> 0) AND (CANCELLED = 0) AND (TRCODE = 14) AND (DECPRDIFF = 1)) AND YEAR(DATE_)=2019
GROUP BY CLIENTREF, MONTH(DATE_), YEAR(DATE_)
UNION ALL
SELECT CLIENTREF, COUNT(DISTINCT LOGICALREF) AS FICHECOUNT2, SUM((AMOUNT * 100) / (100 + VATRATE)) AS LNETSUM2, MONTH(DATE_), YEAR(DATE_)
FROM dbo.LG_020_04_CLFLINE AS CTRNS WITH (NOLOCK)
WHERE (CLIENTREF <> 0) AND TRCODE IN (42,46)
GROUP BY CLIENTREF, YEAR(DATE_), MONTH(DATE_)) AS XXX LEFT OUTER JOIN
dbo.LG_020_CLCARD AS CLNTC WITH (NOLOCK) ON XXX.CLIENTREF = CLNTC.LOGICALREF
GROUP BY CLNTC.DEFINITION_, CLNTC.TAXNR, CLNTC.TCKNO, CLNTC.TAXOFFICE, AY, YIL,CLNTC.COUNTRY
HAVING (SUM(XXX.LNETSUM2) >= 5000)
SELECT (CLNTC.TCKNO + CLNTC.TAXNR) AS [TC / VERGI NO], CLNTC.DEFINITION_ AS [SATICI UNVANI], FLOOR(SUM(XXX.LNETSUM2)) AS [KDV HARIC TUTAR],
SUM(XXX.FICHECOUNT2) AS BELGE_ADETI, CLNTC.TAXNR AS [VERGI NO], CLNTC.TCKNO AS [TC NO], CLNTC.TAXOFFICE AS [VERGI DAIRESI], AY, YIL,CLNTC.COUNTRY AS [ÜLKESİ]
FROM (SELECT CLIENTREF, AY = MONTH(DATE_), YIL = YEAR(DATE_), COUNT(DISTINCT LOGICALREF) AS FICHECOUNT2, SUM(NETTOTAL - TOTALVAT)
AS LNETSUM2
FROM dbo.LG_020_04_INVOICE AS INVFC WITH (NOLOCK)
WHERE ((TRCODE IN (1, 2, 3, 4, 12,33)) AND (NETTOTAL <> 0) AND (CLIENTREF <> 0) AND (CANCELLED = 0) OR
(NETTOTAL <> 0) AND (CLIENTREF <> 0) AND (CANCELLED = 0) AND (TRCODE = 13) AND (DECPRDIFF = 0) OR
(NETTOTAL <> 0) AND (CLIENTREF <> 0) AND (CANCELLED = 0) AND (TRCODE = 14) AND (DECPRDIFF = 1)) AND YEAR(DATE_)=2019
GROUP BY CLIENTREF, MONTH(DATE_), YEAR(DATE_)
UNION ALL
SELECT CLIENTREF, COUNT(DISTINCT LOGICALREF) AS FICHECOUNT2, SUM((AMOUNT * 100) / (100 + VATRATE)) AS LNETSUM2, MONTH(DATE_), YEAR(DATE_)
FROM dbo.LG_020_04_CLFLINE AS CTRNS WITH (NOLOCK)
WHERE (CLIENTREF <> 0) AND TRCODE IN (42,46)
GROUP BY CLIENTREF, YEAR(DATE_), MONTH(DATE_)) AS XXX LEFT OUTER JOIN
dbo.LG_020_CLCARD AS CLNTC WITH (NOLOCK) ON XXX.CLIENTREF = CLNTC.LOGICALREF
GROUP BY CLNTC.DEFINITION_, CLNTC.TAXNR, CLNTC.TCKNO, CLNTC.TAXOFFICE, AY, YIL,CLNTC.COUNTRY
HAVING (SUM(XXX.LNETSUM2) >= 5000)