<?xml version="1.0" encoding="iso-8859-9" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>ERP Nedir? | T&#252;rkiye'nin ERP Forum Platformu : Fatura vade izleme hk.</title>
  <link>http://www.erpne.org/</link>
  <description><![CDATA[XML içerik linki; ERP Nedir? | T&#252;rkiye'nin ERP Forum Platformu : ERP ve Excel : Fatura vade izleme hk.]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Fri, 17 Apr 2026 18:08:43 +0000</pubDate>
  <lastBuildDate>Fri, 02 Sep 2016 14:40:14 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 11.10</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.erpne.org/RSS_post_feed.asp?TID=4396</WebWizForums:feedURL>
  <image>
   <title><![CDATA[ERP Nedir? | T&#252;rkiye'nin ERP Forum Platformu]]></title>
   <url>http://www.erpne.org/forum_images/logotype.png</url>
   <link>http://www.erpne.org/</link>
  </image>
  <item>
   <title><![CDATA[Fatura vade izleme hk. : bu g&#252;ncellemeyi Cahar tablosunda...]]></title>
   <link>http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23153.html#23153</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="http://www.erpne.org/member_profile.asp?PF=4803">dbicer83</a><br /><strong>Konu:</strong> 4396<br /><strong>Gönderim Zamanı:</strong> 02&nbsp;Eylül&nbsp;2016 Saat 14:40<br /><br />bu güncellemeyi Cahar tablosunda mi yapiyor. Söyle ki örnegin yilin baslarinda farkli plasiyer ilerleyen zamanlarda farkli plasiyer sorumlulugundadir. Bu kod yardimiyla tamamini guncellemis mi olackatir.<div>Tesekkürler&nbsp;</div>]]>
   </description>
   <pubDate>Fri, 02 Sep 2016 14:40:14 +0000</pubDate>
   <guid isPermaLink="true">http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23153.html#23153</guid>
  </item> 
  <item>
   <title><![CDATA[Fatura vade izleme hk. : UPDATE PLASIYER_DUZENLEMESET HP...]]></title>
   <link>http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23152.html#23152</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="http://www.erpne.org/member_profile.asp?PF=1592">rhan</a><br /><strong>Konu:</strong> 4396<br /><strong>Gönderim Zamanı:</strong> 02&nbsp;Eylül&nbsp;2016 Saat 13:04<br /><br /><br>UPDATE PLASIYER_DUZENLEME<br>SET HP = SP<br>FROM (<br>SELECT CH.PLASIYER_KODU HP , CS.PLASIYER_KODU SP, CH.ACIKLAMA<br>FROM TBLCAHAR CH WITH (NOLOCK)<br>INNER JOIN TBLCASABIT CS WITH (NOLOCK) ON CS.CARI_KOD = CH.CARI_KOD <br>WHERE 1=1 AND CH.HAREKET_TURU = 'B'<br>AND CH.PLASIYER_KODU &lt;&gt; CS.PLASIYER_KODU<br>) PLASIYER_DUZENLEME<br><br>UPDATE PLASIYER_DUZENLEME<br>SET HP = SP<br>FROM (<br>SELECT CH.PLASIYER_KODU HP , CS.PLASIYER_KODU SP, CH.STHAR_ACIKLAMA<br>FROM TBLSTHAR CH WITH (NOLOCK)<br>INNER JOIN TBLCASABIT CS WITH (NOLOCK) ON CS.CARI_KOD = CH.STHAR_ACIKLAMA <br>WHERE 1=1 AND CH.STHAR_HTUR IN ('I', 'J', 'K', 'L', 'M')<br>AND CH.PLASIYER_KODU &lt;&gt; CS.PLASIYER_KODU<br>) PLASIYER_DUZENLEME<br><br>UPDATE PLASIYER_DUZENLEME<br>SET HP = SP<br>FROM (<br>SELECT CH.PLA_KODU HP , CS.PLASIYER_KODU SP, CH.CARI_KODU<br>FROM TBLFATUIRS CH WITH (NOLOCK)<br>INNER JOIN TBLCASABIT CS WITH (NOLOCK) ON CS.CARI_KOD = CH.CARI_KODU <br>WHERE 1=1 AND CH.FTIRSIP IN ('1', '3')<br>AND CH.PLA_KODU &lt;&gt; CS.PLASIYER_KODU<br>) PLASIYER_DUZENLEME<br><br><br><br>karta göre hareketleri güncelliyor.<br>]]>
   </description>
   <pubDate>Fri, 02 Sep 2016 13:04:00 +0000</pubDate>
   <guid isPermaLink="true">http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23152.html#23152</guid>
  </item> 
  <item>
   <title><![CDATA[Fatura vade izleme hk. : Konu hakkinda yorum yapabilecek...]]></title>
   <link>http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23151.html#23151</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="http://www.erpne.org/member_profile.asp?PF=4803">dbicer83</a><br /><strong>Konu:</strong> 4396<br /><strong>Gönderim Zamanı:</strong> 01&nbsp;Eylül&nbsp;2016 Saat 23:48<br /><br />Konu hakkinda yorum yapabilecek var mi&nbsp;<div>Tesekkürler&nbsp;</div>]]>
   </description>
   <pubDate>Thu, 01 Sep 2016 23:48:49 +0000</pubDate>
   <guid isPermaLink="true">http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23151.html#23151</guid>
  </item> 
  <item>
   <title><![CDATA[Fatura vade izleme hk. : plasiyer kodunu &#231;atar &#252;zerinden...]]></title>
   <link>http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23149.html#23149</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="http://www.erpne.org/member_profile.asp?PF=4803">dbicer83</a><br /><strong>Konu:</strong> 4396<br /><strong>Gönderim Zamanı:</strong> 30&nbsp;Ağustos&nbsp;2016 Saat 22:58<br /><br />plasiyer kodunu çatar üzerinden degilde casabit üzerinden alsin istiyorum&nbsp;<div>Yardimci olabilirseniz çok memnun olurum.</div><div>Tesekkürler&nbsp;</div>]]>
   </description>
   <pubDate>Tue, 30 Aug 2016 22:58:53 +0000</pubDate>
   <guid isPermaLink="true">http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23149.html#23149</guid>
  </item> 
  <item>
   <title><![CDATA[Fatura vade izleme hk. : Merhabalar,M&#252;steriye faturayi...]]></title>
   <link>http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23148.html#23148</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="http://www.erpne.org/member_profile.asp?PF=4803">dbicer83</a><br /><strong>Konu:</strong> 4396<br /><strong>Gönderim Zamanı:</strong> 30&nbsp;Ağustos&nbsp;2016 Saat 11:15<br /><br />Merhabalar,<div>Müsteriye faturayi X plasiyer kesmis fakat müsteri Y müsterinin sorumlulugundadir.</div><div>X in kestigi faturayi Y nin listesinde görmek istiyoruz.</div><div>Nasil bir güncelleme yapabiliriz?</div><div>tsekkürler.</div><div><br></div>]]>
   </description>
   <pubDate>Tue, 30 Aug 2016 11:15:59 +0000</pubDate>
   <guid isPermaLink="true">http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23148.html#23148</guid>
  </item> 
  <item>
   <title><![CDATA[Fatura vade izleme hk. :  Elinize saglik. &#199;ok harika olmus,Cari...]]></title>
   <link>http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23138.html#23138</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="http://www.erpne.org/member_profile.asp?PF=4803">dbicer83</a><br /><strong>Konu:</strong> 4396<br /><strong>Gönderim Zamanı:</strong> 28&nbsp;Ağustos&nbsp;2016 Saat 00:34<br /><br /><div>Elinize saglik. Çok harika olmus,</div><div>Cari grup kodu maskesi yapmak isitiyorum.</div><div>ne eklemeliyim.</div><div>Tsk.</div>]]>
   </description>
   <pubDate>Sun, 28 Aug 2016 00:34:23 +0000</pubDate>
   <guid isPermaLink="true">http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23138.html#23138</guid>
  </item> 
  <item>
   <title><![CDATA[Fatura vade izleme hk. : select * from .(&amp;#039;&amp;#039;,...]]></title>
   <link>http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23137.html#23137</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="http://www.erpne.org/member_profile.asp?PF=1592">rhan</a><br /><strong>Konu:</strong> 4396<br /><strong>Gönderim Zamanı:</strong> 27&nbsp;Ağustos&nbsp;2016 Saat 23:32<br /><br />select * from &#091;dbo&#093;.&#091;OZELYASLANDIR&#093;('', 'H')<br>]]>
   </description>
   <pubDate>Sat, 27 Aug 2016 23:32:37 +0000</pubDate>
   <guid isPermaLink="true">http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23137.html#23137</guid>
  </item> 
  <item>
   <title><![CDATA[Fatura vade izleme hk. : calistiramadim ama nerede hata...]]></title>
   <link>http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23136.html#23136</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="http://www.erpne.org/member_profile.asp?PF=4803">dbicer83</a><br /><strong>Konu:</strong> 4396<br /><strong>Gönderim Zamanı:</strong> 27&nbsp;Ağustos&nbsp;2016 Saat 22:36<br /><br />calistiramadim ama nerede hata yapiyor olabilirim&nbsp;<div>Tesekkürler&nbsp;</div>]]>
   </description>
   <pubDate>Sat, 27 Aug 2016 22:36:49 +0000</pubDate>
   <guid isPermaLink="true">http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23136.html#23136</guid>
  </item> 
  <item>
   <title><![CDATA[Fatura vade izleme hk. : CREATE FUNCTION .(@CARIKODU TDBCARIKOD,@DOVIZLIMI...]]></title>
   <link>http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23135.html#23135</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="http://www.erpne.org/member_profile.asp?PF=1592">rhan</a><br /><strong>Konu:</strong> 4396<br /><strong>Gönderim Zamanı:</strong> 27&nbsp;Ağustos&nbsp;2016 Saat 13:41<br /><br />CREATE FUNCTION &#091;dbo&#093;.&#091;OZELYASLANDIR&#093;(@CARIKODU TDBCARIKOD,@DOVIZLIMI VARCHAR(1))<br>RETURNS <br>--DECLARE <br>@TEMP TABLE ( CARIKOD VARCHAR(35),CARIISIM VARCHAR(100),BELGENO VARCHAR(20),BELGETARIHI SMALLDATETIME,ACIKLAMA VARCHAR(50),TAHSILAT FLOAT,ODEME FLOAT,<br>VADEGUNU SMALLDATETIME,ASILTUTAR FLOAT,DOVIZTUR INT,DOVIZTUTAR FLOAT,PLASIYERKODU VARCHAR(50),PLASIYERISMI VARCHAR(100),PROJE VARCHAR(15),INCKEYNO INT)<br>AS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>BEGIN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br><br><br>IF @CARIKODU = '' <br>&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @CARIKODU = '%'<br>&nbsp;&nbsp; &nbsp;END<br><br>DECLARE @CKOD VARCHAR(100),@DOVTIP INT,@TB FLOAT,@TA FLOAT,@DB FLOAT,@DA FLOAT,@KURISIM VARCHAR(100),@HESAPTUTMASEKLI VARCHAR(100)<br>DECLARE @CARI_KOD VARCHAR(100),@CARI_ISIM VARCHAR(100),@BELGE_NO VARCHAR(100),@TARIH SMALLDATETIME ,@ACIKLAMA VARCHAR(100),@VADE_TARIHI SMALLDATETIME,@PROJE_KODU VARCHAR(100),@DOVIZ_TURU INT,@SUBE_KODU INT,@HAREKET_TURU VARCHAR(100),@BORC FLOAT,@ALACAK FLOAT,@DOVIZ_TUTAR FLOAT,@KAPATILMIS_TUTAR FLOAT,@INC_KEY_NUMBER FLOAT,@FIRMA_DOVIZ_TIPI FLOAT,@FIRMA_DOVIZ_TUTARI FLOAT,@PLASIYER_KODU VARCHAR(100),@PLASIYER_ACIKLAMA VARCHAR(100)<br>DECLARE @CKODU VARCHAR(100),@CARIISIM VARCHAR(100),@BELGENO VARCHAR(100),@BELGETARIHI SMALLDATETIME,@TMP_ACIKLAMA VARCHAR(100),@TMP_BORC FLOAT,@TMP_ALACAK FLOAT,@VADE SMALLDATETIME,@SONALACAK FLOAT,@ASILTUTAR FLOAT,@DOVIZTUR INT,@DOVIZTUTAR FLOAT,@MODUL VARCHAR(100),@KA VARCHAR(100)<br>DECLARE @BAKIYE FLOAT,@TOPLAM FLOAT<br><br><br>IF @DOVIZLIMI='E'<br>&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DECLARE CURCARI CURSOR FOR <br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SELECT TRA.CARI_KOD,TRA.DOVIZ_TURU DOVIZTIP,TRA.BORC BORC, TRA.ALACAK ALACAK,TRA.BDOVTOP, TRA.ADOVTOP,ISNULL(KUR.ISIM,'YTL') KURISIM,HESAPTUTMASEKLI<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FROM TBLCASABIT CARIANA<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;LEFT OUTER JOIN(<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SELECT CARI_KOD,CAHAR.DOVIZ_TURU,SUM(BORC) BORC ,SUM(ALACAK) ALACAK,SUM(CASE WHEN BORC&gt;0 THEN DOVIZ_TUTAR ELSE 0 END) BDOVTOP,SUM(CASE WHEN ALACAK&gt;0 THEN DOVIZ_TUTAR ELSE 0 END) ADOVTOP<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FROM TBLCAHAR CAHAR<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;WHERE (HAREKET_TURU BETWEEN 'A' AND 'L')<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;AND CAHAR.DOVIZ_TURU&gt;=0<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;AND CAHAR.DOVIZ_TURU&lt;=99<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;GROUP BY CARI_KOD,DOVIZ_TURU<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; ) TRA <br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; ON ( CARIANA.CARI_KOD = TRA.CARI_KOD )<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;LEFT OUTER JOIN NETSIS..KUR KUR ON ( KUR.SIRA = TRA.DOVIZ_TURU )<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;WHERE (CARIANA.CM_BORCT + CARIANA.CM_ALACT &lt;&gt; 0) AND TRA.CARI_KOD LIKE @CARIKODU ORDER BY&nbsp; CARIANA.CARI_KOD&nbsp; ASC ,TRA.DOVIZ_TURU<br><br><br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;OPEN CURCARI<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FETCH NEXT FROM CURCARI INTO @CKOD,@DOVTIP,@TB,@TA,@DB,@DA,@KURISIM,@HESAPTUTMASEKLI<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;WHILE @@FETCH_STATUS &lt;&gt; -1<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN <br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @DOVTIP&lt;&gt;0<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @HESAPTUTMASEKLI='K'<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DECLARE HAREKET CURSOR FOR <br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SELECT CARI_KOD,(SELECT CARI_ISIM FROM TBLCASABIT WITH (NOLOCK) WHERE TBLCASABIT.CARI_KOD = TBLCAHAR.CARI_KOD),BELGE_NO,TARIH,ACIKLAMA,VADE_TARIHI,TBLCAHAR.PROJE_KODU,DOVIZ_TURU,TBLCAHAR.SUBE_KODU,HAREKET_TURU,(CASE WHEN BORC&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE BORC END),(CASE WHEN ALACAK&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE ALACAK END),DOVIZ_TUTAR,KAPATILMIS_TUTAR,TBLCAHAR.PLASIYER_KODU,PLASIYER_ACIKLAMA,INC_KEY_NUMBER FROM TBLCAHAR WITH (NOLOCK) &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;LEFT OUTER JOIN TBLCARIPLASIYER WITH (NOLOCK) ON (TBLCAHAR.PLASIYER_KODU = TBLCARIPLASIYER.PLASIYER_KODU) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;WHERE DOVIZ_TUTAR&nbsp; &lt;&gt; KAPATILMIS_TUTAR AND (CARI_KOD=@CKOD) AND DOVIZ_TURU = @DOVTIP<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ORDER BY VADE_TARIHI DESC<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;OPEN HAREKET<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FETCH NEXT FROM HAREKET INTO @CARI_KOD,@CARI_ISIM,@BELGE_NO,@TARIH,@ACIKLAMA,@VADE_TARIHI,@PROJE_KODU,@DOVIZ_TURU,@SUBE_KODU,@HAREKET_TURU,@BORC,@ALACAK,@DOVIZ_TUTAR,@KAPATILMIS_TUTAR,@PLASIYER_KODU,@PLASIYER_ACIKLAMA,@INC_KEY_NUMBER<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;WHILE @@FETCH_STATUS &lt;&gt; -1<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @SONALACAK = (@BORC + @ALACAK) &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @ASILTUTAR = (@BORC + @ALACAK) &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @BORC &gt; 0&nbsp; SET @BORC = @BORC - @KAPATILMIS_TUTAR<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @ALACAK &gt; 0&nbsp; SET @ALACAK = @ALACAK&nbsp;&nbsp; - @KAPATILMIS_TUTAR<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;INSERT INTO @TEMP VALUES (@CARI_KOD,@CARI_ISIM,@BELGE_NO,@TARIH,@ACIKLAMA,@BORC,@ALACAK,@VADE_TARIHI,@ASILTUTAR,@DOVIZ_TURU,@DOVIZ_TUTAR,@P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&nbsp;&nbsp;&nbsp; &nbsp;IF @HESAPTUTMASEKLI = 'Y ' AND @DB &lt; @DA<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @BAKIYE = @DA-@DB&nbsp;&nbsp;&nbsp; -- ALACAK<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DECLARE HAREKET CURSOR FOR SELECT CARI_KOD,(SELECT CARI_ISIM FROM TBLCASABIT WITH (NOLOCK) WHERE TBLCASABIT.CARI_KOD = TBLCAHAR.CARI_KOD), BELGE_NO,TARIH,ACIKLAMA,VADE_TARIHI,TBLCAHAR.PROJE_KODU,DOVIZ_TURU,TBLCAHAR.SUBE_KODU,(CASE WHEN BORC&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE BORC END),(CASE WHEN ALACAK&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE ALACAK END),INC_KEY_NUMBER,DOVIZ_TUTAR,FIRMA_DOVIZ_TIPI,FIRMA_DOVIZ_TUTARI,KAPATILMIS_TUTAR,TBLCAHAR.PLASIYER_KODU,PLASIYER_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&nbsp;&nbsp; &nbsp;INSERT INTO @TEMP VALUES (@CARI_KOD,@CARI_ISIM,@BELGE_NO,@TARIH,@ACIKLAMA,@BORC,@ALACAK,@VADE_TARIHI,@ASILTUTAR,@DOVIZ_TURU,@DOVIZ_TUTAR,@PLASIYER_KODU,@PLASIYER_ACIKLAMA,@PROJE_KODU,@INC_KEY_NUMBER)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FETCH NEXT FROM HAREKET INTO @CARI_KOD,@CARI_ISIM,@BELGE_NO,@TARIH,@ACIKLAMA,@VADE_TARIHI,@PROJE_KODU,@DOVIZ_TURU,@SUBE_KODU,@BORC,@ALACAK,@INC_KEY_NUMBER,@DOVIZ_TUTAR,@FIRMA_DOVIZ_TIPI,@FIRMA_DOVIZ_TUTARI,@KAPATILMIS_TUTAR,@PLASIYER_KODU,@PLASIYER_ACIKLAMA<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; END<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; CLOSE HAREKET<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; DEALLOCATE HAREKET<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;END<br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @HESAPTUTMASEKLI = 'Y ' AND @DA &lt; @DB<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @BAKIYE = @DB-@DA&nbsp;&nbsp;&nbsp; -- BORC<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DECLARE HAREKET CURSOR FOR SELECT CARI_KOD,(SELECT CARI_ISIM FROM TBLCASABIT WITH (NOLOCK) WHERE TBLCASABIT.CARI_KOD = TBLCAHAR.CARI_KOD), BELGE_NO,TARIH,ACIKLAMA,VADE_TARIHI,TBLCAHAR.PROJE_KODU,DOVIZ_TURU,TBLCAHAR.SUBE_KODU,(CASE WHEN BORC&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE BORC END),(CASE WHEN ALACAK&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE ALACAK END),INC_KEY_NUMBER,DOVIZ_TUTAR,FIRMA_DOVIZ_TIPI,FIRMA_DOVIZ_TUTARI,KAPATILMIS_TUTAR,TBLCAHAR.PLASIYER_KODU,PLASIYER_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; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SELECT CARI_KOD,(SELECT CARI_ISIM FROM TBLCASABIT WITH (NOLOCK) WHERE TBLCASABIT.CARI_KOD = TBLCAHAR.CARI_KOD),BELGE_NO,TARIH,ACIKLAMA,VADE_TARIHI,TBLCAHAR.PROJE_KODU,DOVIZ_TURU,TBLCAHAR.SUBE_KODU,HAREKET_TURU,(CASE WHEN BORC&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE BORC END),(CASE WHEN ALACAK&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE ALACAK END),DOVIZ_TUTAR,KAPATILMIS_TUTAR,TBLCAHAR.PLASIYER_KODU,PLASIYER_ACIKLAMA,INC_KEY_NUMBER FROM TBLCAHAR WITH (NOLOCK) &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;LEFT OUTER JOIN TBLCARIPLASIYER WITH (NOLOCK) ON (TBLCAHAR.PLASIYER_KODU = TBLCARIPLASIYER.PLASIYER_KODU) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;WHERE BORC+ALACAK&nbsp; &lt;&gt; KAPATILMIS_TUTAR AND (CARI_KOD=@CKOD) AND DOVIZ_TURU = @DOVTIP<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;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p;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @SONALACAK = (@BORC + @ALACAK) &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @ASILTUTAR = (@BORC + @ALACAK) &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @BORC &gt; 0&nbsp; SET @BORC = @BORC - @KAPATILMIS_TUTAR<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @ALACAK &gt; 0&nbsp; SET @ALACAK = @ALACAK&nbsp;&nbsp; - @KAPATILMIS_TUTAR<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;INSERT INTO @TEMP VALUES (@CARI_KOD,@CARI_ISIM,@BELGE_NO,@TARIH,@ACIKLAMA,@BORC,@ALACAK,@VADE_TARIHI,@ASILTUTAR,@DOVIZ_TURU,@DOVIZ_TUTAR,@PLASIYER_KODU,@PLASIYER_ACIKLAMA,@PROJE_KODU,@INC_KEY_NUMBER)<br>&nbsp;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&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @HESAPTUTMASEKLI = 'Y ' AND @TB &lt; @TA<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @BAKIYE = @TA-@TB&nbsp;&nbsp;&nbsp; -- ALACAK<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DECLARE HAREKET CURSOR FOR SELECT CARI_KOD,(SELECT CARI_ISIM FROM TBLCASABIT WITH (NOLOCK) WHERE TBLCASABIT.CARI_KOD = TBLCAHAR.CARI_KOD), BELGE_NO,TARIH,ACIKLAMA,VADE_TARIHI,TBLCAHAR.PROJE_KODU,DOVIZ_TURU,TBLCAHAR.SUBE_KODU,(CASE WHEN BORC&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE BORC END),(CASE WHEN ALACAK&g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&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;END<br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @HESAPTUTMASEKLI = 'Y ' AND @TA &lt; @TB<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @BAKIYE = @TB-@TA&nbsp;&nbsp;&nbsp; -- BORC<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DECLARE HAREKET CURSOR FOR SELECT CARI_KOD,(SELECT CARI_ISIM FROM TBLCASABIT WITH (NOLOCK) WHERE TBLCASABIT.CARI_KOD = TBLCAHAR.CARI_KOD), BELGE_NO,TARIH,ACIKLAMA,VADE_TARIHI,TBLCAHAR.PROJE_KODU,DOVIZ_TURU,TBLCAHAR.SUBE_KODU,(CASE WHEN BORC&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE BORC END),(CASE WHEN ALACAK&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE ALACAK END),INC_KEY_NUMBER,DOVIZ_TUTAR,FIRMA_DOVIZ_TIPI,FIRMA_DOVIZ_TUTARI,KAPATILMIS_TUTAR,TBLCAHAR.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p;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; DEALLOCATE HAREKET<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;END<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;END<br><br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FETCH NEXT FROM CURCARI INTO @CKOD,@DOVTIP,@TB,@TA,@DB,@DA,@KURISIM,@HESAPTUTMASEKLI<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;END<br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;CLOSE CURCARI<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DEALLOCATE CURCARI<br><br>&nbsp;&nbsp; &nbsp;END<br><br>IF @DOVIZLIMI='H'<br>&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DECLARE CURCARI CURSOR FOR <br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SELECT CARI_KOD,0,CM_BORCT,CM_ALACT,0,0,'YTL',HESAPTUTMASEKLI FROM TBLCASABIT WHERE CARI_KOD LIKE @CARIKODU ORDER BY CARI_KOD<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;OPEN CURCARI<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FETCH NEXT FROM CURCARI INTO @CKOD,@DOVTIP,@TB,@TA,@DB,@DA,@KURISIM,@HESAPTUTMASEKLI<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;WHILE @@FETCH_STATUS &lt;&gt; -1<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN <br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @HESAPTUTMASEKLI='K'<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DECLARE HAREKET CURSOR FOR <br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SELECT CARI_KOD,(SELECT CARI_ISIM FROM TBLCASABIT WITH (NOLOCK) WHERE TBLCASABIT.CARI_KOD = TBLCAHAR.CARI_KOD),BELGE_NO,TARIH,ACIKLAMA,VADE_TARIHI,TBLCAHAR.PROJE_KODU,DOVIZ_TURU,TBLCAHAR.SUBE_KODU,HAREKET_TURU,(CASE WHEN BORC&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE BORC END),(CASE WHEN ALACAK&gt;0 AND DOVIZ_TURU &lt;&gt; 0 THEN DOVIZ_TUTAR ELSE ALACAK END),DOVIZ_TUTAR,KAPATILMIS_TUTAR,TBLCAHAR.PLASIYER_KODU,PLASIYER_ACIKLAMA,INC_KEY_NUMBER FROM TBLCAHAR WITH (NOLOCK) &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;LEFT OUTER JOIN TBLCARIPLASIYER WITH (NOLOCK) ON (TBLCAHAR.PLASIYER_KODU = TBLCARIPLASIYER.PLASIYER_KODU) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;WHERE BORC+ALACAK&nbsp; &lt;&gt; KAPATILMIS_TUTAR AND (CARI_KOD=@CKOD) AND DOVIZ_TURU = @DOVTIP<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ORDER BY VADE_TARIHI DESC<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;OPEN HAREKET<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FETCH NEXT FROM HAREKET INTO @CARI_KOD,@CARI_ISIM,@BELGE_NO,@TARIH,@ACIKLAMA,@VADE_TARIHI,@PROJE_KODU,@DOVIZ_TURU,@SUBE_KODU,@HAREKET_TURU,@BORC,@ALACAK,@DOVIZ_TUTAR,@KAPATILMIS_TUTAR,@PLASIYER_KODU,@PLASIYER_ACIKLAMA,@INC_KEY_NUMBER<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;WHILE @@FETCH_STATUS &lt;&gt; -1<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @SONALACAK = (@BORC + @ALACAK) &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @ASILTUTAR = (@BORC + @ALACAK) &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @BORC &gt; 0&nbsp; SET @BORC = @BORC - @KAPATILMIS_TUTAR<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @ALACAK &gt; 0&nbsp; SET @ALACAK = @ALACAK&nbsp;&nbsp; - @KAPATILMIS_TUTAR<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;INSERT INTO @TEMP VALUES (@CARI_KOD,@CARI_ISIM,@BELGE_NO,@TARIH,@ACIKLAMA,@BORC,@ALACAK,@VADE_TARIHI,@ASILTUTAR,@DOVIZ_TURU,@DOVIZ_TUTAR,@PLASIYER_KODU,@PLASIYER_ACIKLAMA,@PROJE_KODU,@INC_KEY_NUMBER)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FETCH NEXT FROM HAREKET INTO @CARI_KOD,@CARI_ISIM,@BELGE_NO,@TARIH,@ACIKLAMA,@VADE_TARIHI,@PROJE_KODU,@DOVIZ_TURU,@SUBE_KODU,@HAREKET_TURU,@BORC,@ALACAK,@DOVIZ_TUTAR,@KAPATILMIS_TUTAR,@PLASIYER_KODU,@PLASIYER_ACIKLAMA,@INC_KEY_NUMBER<br>&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; END<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;CLOSE HAREKET<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; DEALLOCATE HAREKET<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;END<br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @HESAPTUTMASEKLI = 'Y ' AND @TB &lt; @TA<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @BAKIYE = @TA-@TB&nbsp;&nbsp;&nbsp; -- ALACAK<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DECLARE HAREKET CURSOR FOR SELECT CARI_KOD,(SELECT CARI_ISIM FROM TBLCASABIT WITH (NOLOCK) WHERE TBLCASABIT.CARI_KOD = TBLCAHAR.CARI_KOD), BELGE_NO,TARIH,ACIKLAMA,VADE_TARIHI,TBLCAHAR.PROJE_KODU,DOVIZ_TURU,TBLCAHAR.SUBE_KODU,BORC,ALACAK,INC_KEY_NUMBER,DOVIZ_TUTAR,FIRMA_DOVIZ_TIPI,FIRMA_DOVIZ_TUTARI,KAPATILMIS_TUTAR,TBLCAHAR.PLASIYER_KODU,PLASIYER_ACIKLAMA FROM TBLCAHAR WITH (NOLOCK) &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;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&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; SET @SONALACAK = @ALACAK<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; SET @ALACAK = (@TOPLAM - @BAKIYE - @ALACAK) * -1<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; IF&nbsp; @SONALACAK = @ALACAK SET @SONALACAK = @ALACAK<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ELSE<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; SET @SONALACAK = @ALACAK<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nb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bsp;&nbsp; &nbsp;&nbsp; CLOSE HAREKET<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; DEALLOCATE HAREKET<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;END<br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IF @HESAPTUTMASEKLI = 'Y ' AND @TA &lt; @TB<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;BEGIN<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SET @BAKIYE = @TB-@TA&nbsp;&nbsp;&nbsp; -- BORC<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DECLARE HAREKET CURSOR FOR SELECT CARI_KOD,(SELECT CARI_ISIM FROM TBLCASABIT WITH (NOLOCK) WHERE TBLCASABIT.CARI_KOD = TBLCAHAR.CARI_KOD), BELGE_NO,TARIH,ACIKLAMA,VADE_TARIHI,TBLCAHAR.PROJE_KODU,DOVIZ_TURU,TBLCAHAR.SUBE_KODU,BORC,ALACAK,INC_KEY_NUMBER,DOVIZ_TUTAR,FIRMA_DOVIZ_TIPI,FIRMA_DOVIZ_TUTARI,KAPATILMIS_TUTAR,TBLCAHAR.PLASIYER_KODU,PLASIYER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sp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; SET @SONALACAK = @BORC<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; END<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;INSERT INTO @TEMP VALUES (@CARI_KOD,@CARI_ISIM,@BELGE_NO,@TARIH,@ACIKLAMA,@BORC,@ALACAK,@VADE_TARIHI,@ASILTUTAR,@DOVIZ_TURU,@DOVIZ_TUTAR,@PLASIYER_KODU,@PLASIYER_ACIKLAMA,@PROJE_KODU,@INC_KEY_NUMBER)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FETCH NEXT FROM HAREKET INTO @CARI_KOD,@CARI_ISIM,@BELGE_NO,@TARIH,@ACIKLAMA,@VADE_TARIHI,@PROJE_KODU,@DOVIZ_TURU,@SUBE_KODU,@BORC,@ALACAK,@INC_KEY_NUMBER,@DOVIZ_TUTAR,@FIRMA_DOVIZ_TIPI,@FIRMA_DOVIZ_TUTARI,@KAPATILMIS_TUTAR,@PLASIYER_KODU,@PLASIYER_ACIKLAMA<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; END<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; CLOSE HAREKET<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; DEALLOCATE HAREKET<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;END<br><br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;FETCH NEXT FROM CURCARI INTO @CKOD,@DOVTIP,@TB,@TA,@DB,@DA,@KURISIM,@HESAPTUTMASEKLI<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;END<br><br><br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;CLOSE CURCARI<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DEALLOCATE CURCARI<br><br><br><br>&nbsp;&nbsp; &nbsp;END<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;<br><br>RETURN<br><br>END]]>
   </description>
   <pubDate>Sat, 27 Aug 2016 13:41:00 +0000</pubDate>
   <guid isPermaLink="true">http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23135.html#23135</guid>
  </item> 
  <item>
   <title><![CDATA[Fatura vade izleme hk. :   rhan Yazd&#305;:Cari - Ek listeler,...]]></title>
   <link>http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23134.html#23134</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="http://www.erpne.org/member_profile.asp?PF=4803">dbicer83</a><br /><strong>Konu:</strong> 4396<br /><strong>Gönderim Zamanı:</strong> 27&nbsp;Ağustos&nbsp;2016 Saat 12:04<br /><br /><div><table width="99%"><tr><td class="BBquote"><img src="forum_images/quote_box.png" title="Orjinalini yazan: rhan" alt="Orjinalini yazan: rhan" style="vertical-align: text-bottom;" /> <strong>rhan Yazdı:</strong><br /><br />Cari - Ek listeler, tarih arali yaslandirma listesi isini görür.<br></td></tr></table></div><div>Mevcutta bu raporu kullaniyorum.</div><div>Fakat liste haline getirmek için çok zaman aliyor.</div><div>SQL üzerinde birseyler yapilabilir mi?</div>]]>
   </description>
   <pubDate>Sat, 27 Aug 2016 12:04:49 +0000</pubDate>
   <guid isPermaLink="true">http://www.erpne.org/fatura-vade-izleme-hk_topic4396_post23134.html#23134</guid>
  </item> 
 </channel>
</rss>