ALTER PROCEDURE [dbo].[sp_MBT_SaveClientFiche] ( @cha_evrakno_seri nvarchar(8), @cha_evrakno_sira int, @cha_belge_no NVARCHAR(16), @TahsilatTipi nvarChar(10),--NAKIT =101 KREDIKARTI = 22 CEK = 61 SENET = 62, CHLACAK = 4 --NAKIT KREDIKARTI CEK SENET OLARAK DEGISTIRDIK @cha_srmrkkodu nvarchar(10), @cha_tarih datetime, @cha_satirno int, @cha_belge_tarih datetime, @cha_satici_kod nvarchar(25), @cha_musteri_kod nvarchar(25), @cha_meblag float, @cha_aciklama nvarchar(50), @cha_stok_sormerk nvarchar(25), @cha_doviz_kodu nvarchar(5), @cha_kasa_hizkod nvarchar(50), @cha_vade_tarihi datetime, @cha_banka nvarchar(25), @cha_sube nvarchar(25), @cha_cekno nvarchar(25), @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; DECLARE @yeniEvrakMi int DECLARE @cha_doviz_cinsi tinyint DECLARE @cha_tip tinyint DECLARE @cha_cinsi tinyint DECLARE @cha_normal_Iade tinyint DECLARE @cha_evrak_tip tinyint DECLARE @cha_kasa_hizmet tinyint DECLARE @cha_sntcek_poz tinyint DECLARE @cha_vade nvarchar(8) SELECT @cha_vade=CONVERT(NVARCHAR,@cha_vade_tarihi,112) DECLARE @cha_senet_cek_ref nvarchar(50) SELECT @cha_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@cha_doviz_kodu --NAKIT =101 KREDIKARTI = 22 CEK = 61 SENET = 62 IF @TahsilatTipi='NAKIT' BEGIN SET @cha_tip=1 SET @cha_cinsi=0 SET @cha_normal_Iade=0 SET @cha_evrak_tip =1 SET @cha_kasa_hizmet=4 SET @cha_sntcek_poz=0 SET @cha_senet_cek_ref ='' END ELSE IF @TahsilatTipi='KREDIKARTI' BEGIN SET @cha_tip=1 SET @cha_cinsi=19 SET @cha_normal_Iade=0 SET @cha_evrak_tip =1 SET @cha_kasa_hizmet=2 SET @cha_sntcek_poz=2 SELECT @cha_senet_cek_ref=[dbo].[mbt_nvarcharToInt](MAX(sck_refno)) FROM ODEME_EMIRLERI where sck_refno LIKE 'MK-000-%' END ELSE IF @TahsilatTipi='CEK' BEGIN SET @cha_tip=1 SET @cha_cinsi=1 SET @cha_normal_Iade=0 SET @cha_evrak_tip =1 SET @cha_kasa_hizmet=4 SET @cha_sntcek_poz=0 SELECT @cha_senet_cek_ref=[dbo].[mbt_nvarcharToInt](MAX(sck_refno)) FROM ODEME_EMIRLERI where sck_refno LIKE 'MC-000-%' END else if @TahsilatTipi='SENET' BEGIN SET @cha_tip=1 SET @cha_cinsi=2 SET @cha_normal_Iade=0 SET @cha_evrak_tip =1 SET @cha_kasa_hizmet=4 SET @cha_sntcek_poz=0 SELECT @cha_senet_cek_ref=[dbo].[mbt_nvarcharToInt](MAX(sck_refno)) FROM ODEME_EMIRLERI where sck_refno LIKE 'MS-000-%' END SELECT @yeniEvrakMi=COUNT(*) FROM CARI_HESAP_HAREKETLERI WHERE cha_evrakno_seri=@cha_evrakno_seri and cha_cinsi=@cha_cinsi and cha_tip=@cha_tip and cha_normal_Iade=@cha_normal_Iade and cha_evrak_tip=@cha_evrak_tip and cha_evrakno_seri=@cha_evrakno_seri and cha_evrakno_sira=@cha_evrakno_sira --burasi calismadi iyi bir kontrol den sonra burayı revize edelim --SELECT @cha_satirno=(ISNULL(MAX(cha_satir_no),-1)+1) FROM CARI_HESAP_HAREKETLERI WHERE cha_evrakno_seri=@cha_evrakno_seri and cha_cinsi=@cha_cinsi and cha_tip=@cha_tip and cha_normal_Iade=@cha_normal_Iade and cha_evrak_tip=@cha_evrak_tip and cha_evrakno_seri=@cha_evrakno_seri and cha_evrakno_sira=@cha_evrakno_sira DECLARE @cha_alt_doviz_kuru float DECLARE @cha_vergi_pntr_yeni int set @cha_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,1) DECLARE @guid uniqueidentifier = NEWID(); INSERT INTO [dbo].[CARI_HESAP_HAREKETLERI] ([cha_Guid] ,[cha_DBCno] ,[cha_SpecRecNo] ,[cha_iptal] ,[cha_fileid] ,[cha_hidden] ,[cha_kilitli] ,[cha_degisti] ,[cha_CheckSum] ,[cha_create_user] ,[cha_create_date] ,[cha_lastup_user] ,[cha_lastup_date] ,[cha_special1] ,[cha_special2] ,[cha_special3] ,[cha_firmano] ,[cha_subeno] ,[cha_evrak_tip] ,[cha_evrakno_seri]--20 ,[cha_evrakno_sira] ,[cha_satir_no] ,[cha_tarihi] ,[cha_tip] ,[cha_cinsi] ,[cha_normal_Iade] ,[cha_tpoz] ,[cha_ticaret_turu] ,[cha_belge_no] ,[cha_belge_tarih]--30 ,[cha_aciklama] ,[cha_satici_kodu] ,[cha_EXIMkodu] ,[cha_projekodu] ,[cha_yat_tes_kodu] ,[cha_cari_cins] ,[cha_kod] ,[cha_ciro_cari_kodu] ,[cha_d_cins] ,[cha_d_kur]--40 ,[cha_altd_kur] ,[cha_grupno] ,[cha_srmrkkodu] ,[cha_kasa_hizmet] ,[cha_kasa_hizkod] ,[cha_karsidcinsi] ,[cha_karsid_kur] ,[cha_karsidgrupno] ,[cha_karsisrmrkkodu] ,[cha_miktari]--50 ,[cha_meblag] ,[cha_aratoplam] ,[cha_vade] ,[cha_Vade_Farki_Yuz] ,[cha_ft_iskonto1] ,[cha_ft_iskonto2] ,[cha_ft_iskonto3] ,[cha_ft_iskonto4] ,[cha_ft_iskonto5] ,[cha_ft_iskonto6]--60 ,[cha_ft_masraf1] ,[cha_ft_masraf2] ,[cha_ft_masraf3] ,[cha_ft_masraf4] ,[cha_isk_mas1] ,[cha_isk_mas2] ,[cha_isk_mas3] ,[cha_isk_mas4] ,[cha_isk_mas5] ,[cha_isk_mas6]--70 ,[cha_isk_mas7] ,[cha_isk_mas8] ,[cha_isk_mas9] ,[cha_isk_mas10] ,[cha_sat_iskmas1] ,[cha_sat_iskmas2] ,[cha_sat_iskmas3] ,[cha_sat_iskmas4] ,[cha_sat_iskmas5] ,[cha_sat_iskmas6]--80 ,[cha_sat_iskmas7] ,[cha_sat_iskmas8] ,[cha_sat_iskmas9] ,[cha_sat_iskmas10] ,[cha_yuvarlama] ,[cha_StFonPntr] ,[cha_stopaj] ,[cha_savsandesfonu] ,[cha_avansmak_damgapul] ,[cha_vergipntr]--90 ,[cha_vergi1] ,[cha_vergi2] ,[cha_vergi3] ,[cha_vergi4] ,[cha_vergi5] ,[cha_vergi6] ,[cha_vergi7] ,[cha_vergi8] ,[cha_vergi9] ,[cha_vergi10]--100 ,[cha_vergisiz_fl] ,[cha_otvtutari] ,[cha_otvvergisiz_fl] ,[cha_oiv_pntr] ,[cha_oivtutari] ,[cha_oiv_vergi] ,[cha_oivergisiz_fl] ,[cha_fis_tarih] ,[cha_fis_sirano] ,[cha_trefno]--110 ,[cha_sntck_poz] ,[cha_reftarihi] ,[cha_istisnakodu] ,[cha_pos_hareketi] ,[cha_meblag_ana_doviz_icin_gecersiz_fl] ,[cha_meblag_alt_doviz_icin_gecersiz_fl] ,[cha_meblag_orj_doviz_icin_gecersiz_fl] ,[cha_sip_uid]--118 ,[cha_kirahar_uid]--119 ,[cha_vardiya_tarihi]--120 ,[cha_vardiya_no] ,[cha_vardiya_evrak_ti] ,[cha_ebelge_turu] ,[cha_tevkifat_toplam] ,[cha_ilave_edilecek_kdv1] ,[cha_ilave_edilecek_kdv2] ,[cha_ilave_edilecek_kdv3] ,[cha_ilave_edilecek_kdv4] ,[cha_ilave_edilecek_kdv5] ,[cha_ilave_edilecek_kdv6]--130 ,[cha_ilave_edilecek_kdv7] ,[cha_ilave_edilecek_kdv8] ,[cha_ilave_edilecek_kdv9] ,[cha_ilave_edilecek_kdv10] ,[cha_e_islem_turu]--135 ,[cha_fatura_belge_turu] ,[cha_diger_belge_adi] ,[cha_uuid]--138 ,[cha_adres_no] ,[cha_vergifon_toplam] ,cha_ilk_belge_tarihi,cha_ilk_belge_doviz_kuru,cha_HareketGrupKodu1,cha_HareketGrupKodu2,cha_HareketGrupKodu3,cha_ebelgeno_seri,cha_ebelgeno_sira,cha_hubid,cha_hubglbid,cha_disyazilimid)--140 VALUES ( @guid ,0 ,0 ,0 ,51 ,0 ,0 ,0 ,0 ,1--10 ,GETDATE() ,1 ,GETDATE() ,'' ,'' ,'' ,0 ,0 ,@cha_evrak_tip ,@cha_evrakno_seri--20 ,@cha_evrakno_sira ,@cha_satirno ,CONVERT(date,@cha_tarih,104) ,@cha_tip ,@cha_cinsi ,@cha_normal_Iade ,0 ,0 ,@cha_belge_no ,CONVERT(date,@cha_belge_tarih,104) ,@cha_aciklama ,@cha_satici_kod ,'' ,'' ,'' ,0 ,@cha_musteri_kod ,'' ,@cha_doviz_cinsi ,1--40 ,@cha_alt_doviz_kuru ,0 ,@cha_srmrkkodu ,@cha_kasa_hizmet ,@cha_kasa_hizkod ,0 ,1 ,0 ,@cha_srmrkkodu ,0--50 ,@cha_meblag ,@cha_meblag ,@cha_vade ,0 ,0 ,0 ,0 ,0 ,0 ,0--60 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0--70 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0--80 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0--90 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0--100 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,CONVERT(datetime,'30-12-1899',104) ,0 ,@cha_senet_cek_ref--110 ,@cha_sntcek_poz --[cha_sntck_poz] ,CONVERT(datetime,'30-12-1899',104)--[cha_reftarihi] ,0--[cha_istisnakodu] ,0--[cha_pos_hareketi] ,0--[cha_meblag_ana_doviz_icin_gecersiz_fl] ,0--[cha_meblag_alt_doviz_icin_gecersiz_fl] ,0--[cha_meblag_orj_doviz_icin_gecersiz_fl] ,'00000000-0000-0000-0000-000000000000'--118 --[cha_sip_uid] ,'00000000-0000-0000-0000-000000000000'--119 --[cha_kirahar_uid] ,CONVERT(datetime,'30-12-1899',104) --[cha_vardiya_tarihi] --120 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0--128 ,0 ,0--130 ,0 ,0 ,0 ,0 ,0 ,0 ,''--137 ,'' ,0 ,0 ,CONVERT(datetime,'30-12-1899',104) --cha_ilk_belge_tarihi ,0--cha_ilk_belge_doviz_kuru ,''--cha_HareketGrupKodu1 ,''--cha_HareketGrupKodu2 ,''--cha_HareketGrupKodu3 ,''--cha_ebelgeno_seri ,0--cha_ebelgeno_sira ,''--cha_hubid ,''--cha_hubglbid ,''--cha_disyazilimid ) DECLARE @cha_RECno uniqueidentifier SET @cha_RECno=@guid --UPDATE CARI_HESAP_HAREKETLERI SET cha_RECid_RECno=cha_RECno where cha_RECid_RECno<>cha_RECno SELECT @KeyFieldValue=@cha_RECno --ODEME EMIRLERI KAYIT ETME ISLEMI DECLARE @sck_tip tinyint DECLARE @sck_sahip_cari_cins tinyint DECLARE @sck_nerede_cari_cins tinyint DECLARE @sck_nerede_cari_kodu nvarchar(10) DECLARE @sck_nerede_cari_grupno tinyint --NAKIT =101 KREDIKARTI = 22 CEK = 61 SENET = 62 IF @TahsilatTipi='KREDIKARTI' BEGIN SET @sck_tip=6 SET @sck_sahip_cari_cins=0 SET @sck_nerede_cari_cins=2 SET @sck_nerede_cari_kodu=@cha_kasa_hizkod SET @sck_nerede_cari_grupno =7 END ELSE IF @TahsilatTipi='CEK' BEGIN SET @sck_tip=0 SET @sck_sahip_cari_cins=0 SET @sck_nerede_cari_cins=4 SET @sck_nerede_cari_kodu=@cha_kasa_hizkod SET @sck_nerede_cari_grupno =0 END ELSE IF @TahsilatTipi='SENET' BEGIN SET @sck_tip=1 SET @sck_sahip_cari_cins=0 SET @sck_nerede_cari_cins=4 SET @sck_nerede_cari_kodu=@cha_kasa_hizkod SET @sck_nerede_cari_grupno =0 END IF @TahsilatTipi='KREDIKARTI' or @TahsilatTipi='CEK' or @TahsilatTipi='SENET' BEGIN DECLARE @sckguid uniqueidentifier = NEWID(); INSERT INTO [dbo].[ODEME_EMIRLERI] ( [sck_Guid] ,[sck_DBCno] ,[sck_SpecRECno] ,[sck_iptal] ,[sck_fileid] ,[sck_hidden] ,[sck_kilitli] ,[sck_degisti] ,[sck_checksum] ,[sck_create_user] ,[sck_create_date] ,[sck_lastup_user] ,[sck_lastup_date] ,[sck_special1] ,[sck_special2] ,[sck_special3] ,[sck_firmano] -- ,[sck_subeno] -- ,[sck_tip] -- ,[sck_refno] -- ,[sck_bankano] -- ,[sck_borclu]-- ,[sck_vdaire_no] -- ,[sck_vade] -- ,[sck_tutar] -- ,[sck_doviz] -- ,[sck_odenen] -- ,[sck_degerleme_islendi] -- ,[sck_banka_adres1] -- ,[sck_sube_adres2]-- ,[sck_borclu_tel]-- ,[sck_hesapno_sehir] -- ,[sck_no] -- ,[sck_duzen_tarih] -- ,[sck_sahip_cari_cins]-- ,[sck_sahip_cari_kodu] -- ,[sck_sahip_cari_grupno]-- ,[sck_nerede_cari_cins] -- ,[sck_nerede_cari_kodu] -- ,[sck_nerede_cari_grupno] -- ,[sck_ilk_hareket_tarihi] -- ,[sck_ilk_evrak_seri]-- ,[sck_ilk_evrak_sira_no] -- ,[sck_ilk_evrak_satir_no] -- ,[sck_son_hareket_tarihi] -- ,[sck_doviz_kur] ,[sck_sonpoz] ,[sck_imza] ,[sck_srmmrk] ,[sck_kesideyeri] ,[Sck_TCMB_Banka_kodu] ,[Sck_TCMB_Sube_kodu] ,[Sck_TCMB_il_kodu] ,[SckTasra_fl] ,[sck_projekodu] ,[sck_masraf1] ,[sck_masraf1_isleme] ,[sck_masraf2] ,[sck_masraf2_isleme] ,[sck_odul_katkisi_tutari] ,[sck_servis_komisyon_tutari] ,[sck_erken_odeme_faiz_tutari] ,[sck_odul_katkisi_tutari_islendi_fl] ,[sck_servis_komisyon_tutari_islendi_fl] ,[sck_erken_odeme_faiz_tutari_islendi_fl] ,[sck_kredi_karti_tipi] ,[sck_taksit_sayisi] ,[sck_kacinci_taksit] ,[sck_uye_isyeri_no] ,[sck_kredi_karti_no] ,[sck_provizyon_kodu]) VALUES (@sckguid ,0 ,0 --[sck_SpecRECno] ,0 ,54 ,0 ,0 ,0 ,0 ,1 ,GETDATE() ,1 ,GETDATE() ,'' ,'' ,'' ,0 --[sck_firmano] ,0 --[sck_subeno] ,@sck_tip --[sck_tip] ,@cha_senet_cek_ref --[sck_refno] ,@cha_banka --[sck_bankano] ,'' --[sck_borclu] ,'' --[sck_vdaire_no] ,@cha_vade_tarihi --[sck_vade] ,@cha_meblag --[sck_tutar] ,@cha_doviz_cinsi --[sck_doviz] ,0 --[sck_odenen] ,0 --[sck_degerleme_islendi] ,'' --[sck_banka_adres1] ,'' --[sck_sube_adres2] ,'' --[sck_borclu_tel] ,'' --[sck_hesapno_sehir] ,@cha_cekno -- [sck_no] ,CONVERT(datetime,'30-12-1899',104) --[sck_duzen_tarih] ,@sck_sahip_cari_cins --[sck_sahip_cari_cins] ,@cha_musteri_kod --[sck_sahip_cari_kodu] ,0 --[sck_sahip_cari_grupno] ,@sck_nerede_cari_cins -- [sck_nerede_cari_cins] ,@sck_nerede_cari_kodu --[sck_nerede_cari_kodu] --KASA KODU ,@sck_nerede_cari_grupno -- [sck_nerede_cari_grupno] ,GETDATE() -- [sck_ilk_hareket_tarihi] ,@cha_evrakno_seri -- [sck_ilk_evrak_seri] ,@cha_evrakno_sira --[sck_ilk_evrak_sira] ,@cha_satirno --[sck_ilk_evrak_satir_no] ,GETDATE() -- [sck_son_hareket_tarihi] ,1 ,0 ,0 ,@cha_srmrkkodu ,'' ,'' ,'' ,'' ,0 ,'' ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,'' ,'' ,'') DECLARE @sck_RECno nvarchar(100) SET @sck_RECno=Cast(@sckguid as nvarchar(100)) --UPDATE ODEME_EMIRLERI SET sck_RECid_RECno=sck_RECno where sck_RECno<>sck_RECid_RECno END Select @KeyFieldValue =@cha_RECno SELECT @KeyFieldValue as KeyFieldValue,@cha_evrakno_seri as DocumentSerial,@cha_evrakno_sira as DocumentNumber,1 As LineNumber END GO /****** Object: StoredProcedure [dbo].[sp_MBT_SaveDispatch] Script Date: 10.07.2023 12:16:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_MBT_SaveDispatch] ( @sth_belgeno nvarchar(16), @sth_evrakno_seri nvarchar(8), @sth_evrakno_sira int, @sth_tarih datetime, @sth_satirno int,--SIFIRDAN ARTARAK GIDIYOR MIKRODA @sth_belge_tarih datetime, @sth_plasiyer_kodu nvarchar(25), @sth_cari_kodu nvarchar(25), @sth_stok_kod nvarchar(25), @sth_b_fiyat float, @sth_miktar float, @sth_birim_pntr tinyint,--BIRIM FIYAT @sth_tutar float,--ISKONTOSUZ ARA TOPLAM @sth_iskonto1 float,--ISKONTO 1 TOPLAMI @sth_iskonto2 float,--ISKONTO 2 TOPLAMI @sth_iskonto3 float,--ISKONTO 3 TOPLAMI @sth_iskonto4 float,--ISKONTO 4 TOPLAMI @sth_iskonto5 float,--ISKONTO 5 TOPLAMI @sth_iskonto6 float,--ISKONTO 6 TOPLAMI @sth_vergi_pntr tinyint,-- 0 8 18 @sth_vergi float,-- ISKONTO DUSULDUKTEN SONRAKI KDV TOPLAMI @sth_aciklama nvarchar(50), @sth_aciklama2 nvarchar(50), @sth_cikis_depo_no int,--ZORUNLU GELMESI LAZIM @sth_doviz_kodu nvarchar(5),--TL USD EUR @sth_stok_sormerk nvarchar(25),-- YOKSA BOS GONDERILECEK @sth_adres_no int, @NormalIade int, @AlisSatis int, @sip_Guid nvarchar(50), @sth_parti_kodu nvarchar(25), @sth_lot_no int, @sth_disticaret_turu int, @ChHar_SeriNo nvarchar(25), @MbtTakipNoAna nvarchar(50), @MbtTakipNoDetay nvarchar(50), @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT --İlk once Carihareket Kayıt edilmeli Çünkü ID si stok hareketlerine yazılacak --yada en son update edilebilir. --ben ikinisini tercih edecegim. --07 12 2020 5 ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- gelen fis Numarasına göre evrak aktaracagız.... --sth_tip Tinyint Hareket Tipi 0:Giriş 1:Çıkış 2:Depo Transfer /* --sth_cins Tinyint Hareket Cinsi 0:Toptan 1:Perakende 2:Dış Ticaret 3:Stok Virman 4:Fire 5:Sarf 6:Transfer 7:Üretim 8:Fason 9:Değer Farkı 10:Sayım 11:Stok Açılış 12:İthalat-İhracat 13:Hal 14:Müstahsil 15:Müstahsil Değer Farkı 14:Kabzımal 15:Gider Pusulası **/ -- sth_normal_iade Tinyint Normal/Iade? 0:Normal 1:İade /* sth_evraktip Tinyint Evrak Tipi 0:Depo Çıkış Fişi 1:Çıkış İrsaliyesi 2:Depo Transfer Fişi 3:Giriş Faturası 4:Çıkış Faturası 5:Stoklara İthalat Masraf Yansıtma Dekontu 6:Stok Virman Fişi 7:Üretim Fişi 8:İlave Enflasyon Maliyet Fişi 9:Stoklara İlave Maliyet Yedirme Fişi 10:Antrepolardan Mal Millileştirme Fişi 11:Antrepolar Arası Transfer Fişi 12:Depo Giriş Fişi 13:Giriş İrsaliyesi 14:Fason Giriş Çıkış Fişi 15:Depolar Arası Satış Fişi 16:Stok Gider Pusulası Fişi 17:Depolar Arası Nakliye Fişi **/ declare @subeliCalismaVarmi int declare @sth_subeno int SET @sth_subeno=0 SELECT @subeliCalismaVarmi=COUNT(*) FROM MBTSISTEMPARAMETRELERI WHERE PARAMETREADI='SUBELICALISMA' AND DEGER='EVET' if @subeliCalismaVarmi=1 BEGIN select @sth_subeno=@sth_cikis_depo_no END else BEGIN set @sth_subeno=0 END DECLARE @sth_doviz_cinsi tinyint SELECT @sth_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu --SATIŞ FATURASI İÇİN DECLARE @sth_normal_iade int DECLARE @sth_evraktip int declare @sth_cins int declare @sth_tip int set @sth_normal_iade =@NormalIade if @AlisSatis=1 BEGIN --ALIS SATIS set @sth_evraktip = 1 set @sth_cins = 0 set @sth_tip = 1 -- SATIS FATURASI ICIN TIPLER BUNLAR END if @AlisSatis=0 BEGIN set @sth_evraktip = 3 set @sth_cins = 0 set @sth_tip = 0 -- SATIS FATURASI ICIN TIPLER BUNLAR END -- ALIS SATIS BITTI if @sth_normal_iade=1 BEGIN -- NORMAL IADE SET @sth_tip=0 END -- NORMAL IADE BITI DECLARE @sth_alt_doviz_kuru float DECLARE @sth_vergi_pntr_yeni int set @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,1) SELECT TOP 1 @sth_vergi_pntr_yeni=T1.VERGIPNTR FROM ( SELECT 0 AS VERGIPNTR,dbo.fn_VergiIsim(0) AS KDVADI,dbo.fn_VergiYuzde(0) AS KDVORANI UNION SELECT 1 AS VERGIPNTR,dbo.fn_VergiIsim(1) AS KDVADI,dbo.fn_VergiYuzde(1) AS KDVORANI UNION SELECT 2 AS VERGIPNTR,dbo.fn_VergiIsim(2) AS KDVADI,dbo.fn_VergiYuzde(2) AS KDVORANI UNION SELECT 3 AS VERGIPNTR,dbo.fn_VergiIsim(3) AS KDVADI,dbo.fn_VergiYuzde(3) AS KDVORANI UNION SELECT 4 AS VERGIPNTR,dbo.fn_VergiIsim(4) AS KDVADI,dbo.fn_VergiYuzde(4) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 7 AS VERGIPNTR,dbo.fn_VergiIsim(7) AS KDVADI,dbo.fn_VergiYuzde(7) AS KDVORANI UNION SELECT 8 AS VERGIPNTR,dbo.fn_VergiIsim(8) AS KDVADI,dbo.fn_VergiYuzde(8) AS KDVORANI UNION SELECT 9 AS VERGIPNTR,dbo.fn_VergiIsim(9) AS KDVADI,dbo.fn_VergiYuzde(9) AS KDVORANI UNION SELECT 10 AS VERGIPNTR,dbo.fn_VergiIsim(10) AS KDVADI,dbo.fn_VergiYuzde(10) AS KDVORANI UNION SELECT 11 AS VERGIPNTR,dbo.fn_VergiIsim(11) AS KDVADI,dbo.fn_VergiYuzde(11) AS KDVORANI UNION SELECT 12 AS VERGIPNTR,dbo.fn_VergiIsim(12) AS KDVADI,dbo.fn_VergiYuzde(12) AS KDVORANI UNION SELECT 13 AS VERGIPNTR,dbo.fn_VergiIsim(13) AS KDVADI,dbo.fn_VergiYuzde(13) AS KDVORANI UNION SELECT 14 AS VERGIPNTR,dbo.fn_VergiIsim(14) AS KDVADI,dbo.fn_VergiYuzde(14) AS KDVORANI UNION SELECT 15 AS VERGIPNTR,dbo.fn_VergiIsim(15) AS KDVADI,dbo.fn_VergiYuzde(15) AS KDVORANI UNION SELECT 16 AS VERGIPNTR,dbo.fn_VergiIsim(16) AS KDVADI,dbo.fn_VergiYuzde(16) AS KDVORANI UNION SELECT 17 AS VERGIPNTR,dbo.fn_VergiIsim(17) AS KDVADI,dbo.fn_VergiYuzde(17) AS KDVORANI UNION SELECT 18 AS VERGIPNTR,dbo.fn_VergiIsim(18) AS KDVADI,dbo.fn_VergiYuzde(18) AS KDVORANI UNION SELECT 19 AS VERGIPNTR,dbo.fn_VergiIsim(19) AS KDVADI,dbo.fn_VergiYuzde(19) AS KDVORANI UNION SELECT 20 AS VERGIPNTR,dbo.fn_VergiIsim(20) AS KDVADI,dbo.fn_VergiYuzde(20) AS KDVORANI ) T1 WHERE T1.KDVORANI=@sth_vergi_pntr ORDER BY VERGIPNTR ASC SET @sth_vergi_pntr=@sth_vergi_pntr_yeni SET @sip_Guid='00000000-0000-0000-0000-000000000000' -- Insert statements for procedure here INSERT INTO [dbo].[STOK_HAREKETLERI] ([sth_DBCno] ,[sth_SpecRECno] ,[sth_iptal] ,[sth_fileid] ,[sth_hidden] ,[sth_kilitli] ,[sth_degisti] ,[sth_checksum] ,[sth_create_user] ,[sth_create_date] ,[sth_lastup_user] ,[sth_lastup_date] ,[sth_special1] ,[sth_special2] ,[sth_special3] ,[sth_firmano] ,[sth_subeno] ,[sth_tarih] ,[sth_tip] ,[sth_cins] ,[sth_normal_iade] ,[sth_evraktip] ,[sth_evrakno_seri] ,[sth_evrakno_sira] ,[sth_satirno] ,[sth_belge_no] ,[sth_belge_tarih] ,[sth_stok_kod] ,[sth_isk_mas1] ,[sth_isk_mas2] ,[sth_isk_mas3] ,[sth_isk_mas4] ,[sth_isk_mas5] ,[sth_isk_mas6] ,[sth_isk_mas7] ,[sth_isk_mas8] ,[sth_isk_mas9] ,[sth_isk_mas10] ,[sth_sat_iskmas1] ,[sth_sat_iskmas2] ,[sth_sat_iskmas3] ,[sth_sat_iskmas4] ,[sth_sat_iskmas5] ,[sth_sat_iskmas6] ,[sth_sat_iskmas7] ,[sth_sat_iskmas8] ,[sth_sat_iskmas9] ,[sth_sat_iskmas10] ,[sth_pos_satis] ,[sth_promosyon_fl] ,[sth_cari_cinsi] ,[sth_cari_kodu] ,[sth_cari_grup_no] ,[sth_isemri_gider_kodu] ,[sth_plasiyer_kodu] ,[sth_har_doviz_cinsi] ,[sth_har_doviz_kuru] ,[sth_alt_doviz_kuru] ,[sth_stok_doviz_cinsi] ,[sth_stok_doviz_kuru] ,[sth_miktar] ,[sth_miktar2] ,[sth_birim_pntr] ,[sth_tutar] ,[sth_iskonto1] ,[sth_iskonto2] ,[sth_iskonto3] ,[sth_iskonto4] ,[sth_iskonto5] ,[sth_iskonto6] ,[sth_masraf1] ,[sth_masraf2] ,[sth_masraf3] ,[sth_masraf4] ,[sth_vergi_pntr] ,[sth_vergi] ,[sth_masraf_vergi_pntr] ,[sth_masraf_vergi] ,[sth_netagirlik] ,[sth_odeme_op] ,[sth_aciklama] ,[sth_sip_uid] ,[sth_fat_uid] ,[sth_giris_depo_no] ,[sth_cikis_depo_no] ,[sth_malkbl_sevk_tarihi] ,[sth_cari_srm_merkezi] ,[sth_stok_srm_merkezi] ,[sth_fis_tarihi] ,[sth_fis_sirano] ,[sth_vergisiz_fl] ,[sth_maliyet_ana] ,[sth_maliyet_alternatif] ,[sth_maliyet_orjinal] ,[sth_adres_no] ,[sth_parti_kodu] ,[sth_lot_no] ,[sth_kons_uid] ,[sth_proje_kodu] ,[sth_exim_kodu] ,[sth_otv_pntr] ,[sth_otv_vergi] ,[sth_brutagirlik] ,[sth_disticaret_turu] ,[sth_otvtutari] ,[sth_otvvergisiz_fl] ,[sth_oiv_pntr] ,[sth_oiv_vergi] ,[sth_oivvergisiz_fl] ,[sth_fiyat_liste_no] ,[sth_oivtutari] ,[sth_Tevkifat_turu] ,[sth_nakliyedeposu] ,[sth_nakliyedurumu] ,[sth_yetkili_uid] ,[sth_taxfree_fl]) VALUES (0-- ,0-- ,0-- ,16-- ,0-- ,0-- ,0-- ,0-- ,1-- ,getdate() -- ,1-- ,getdate()-- ,'mbt'-- ,''-- ,''-- ,0-- ,@sth_subeno-- ,@sth_tarih -- ,@sth_tip-- ,@sth_cins-- ,@sth_normal_iade-- ,@sth_evraktip-- ,@sth_evrakno_seri -- ,@sth_evrakno_sira -- ,@sth_satirno-- ,@sth_belgeno-- ,@sth_tarih-- ,@sth_stok_kod-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@sth_cari_kodu-- ,0-- ,''-- ,@sth_plasiyer_kodu -- ,@sth_doviz_cinsi -- ,1-- ,1-- ,@sth_doviz_cinsi-- ,1-- ,@sth_miktar-- ,@sth_miktar-- ,@sth_birim_pntr-- ,@sth_tutar-- ,@sth_iskonto1-- ,@sth_iskonto2-- ,@sth_iskonto3-- ,@sth_iskonto4-- ,@sth_iskonto5-- ,@sth_iskonto6-- ,0-- ,0-- ,0-- ,0-- ,@sth_vergi_pntr-- ,@sth_vergi -- ,0-- ,0-- ,0-- ,0-- ,@sth_aciklama -- ,@sip_Guid-- ,'00000000-0000-0000-0000-000000000000'-- ,@sth_cikis_depo_no -- ,@sth_cikis_depo_no-- ,@sth_tarih-- ,@sth_stok_sormerk-- ,@sth_stok_sormerk-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_adres_no-- ,@sth_parti_kodu -- ,@sth_lot_no -- ,'00000000-0000-0000-0000-000000000000'-- ,''-- ,''-- ,0-- ,0-- ,0-- ,@sth_disticaret_turu -- ,0-- ,0-- ,0-- ,0-- ,0-- ,1-- ,0-- ,0-- ,0-- ,0-- ,'00000000-0000-0000-0000-000000000000'-- ,0-- ) DECLARE @sth_Guid nvarchar(50) DECLARE @sth_RECno int SELECT @sth_Guid=sth_Guid FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_satirno= @sth_satirno and sth_tip=@sth_tip and sth_cins= @sth_cins and sth_evraktip=@sth_evraktip and sth_normal_iade= @sth_normal_iade --eksik kolonlar guncelle update STOK_HAREKETLERI set sth_ilave_edilecek_kdv=0,sth_HareketGrupKodu1='',sth_HareketGrupKodu2='',sth_HareketGrupKodu3='',sth_Olcu1=0,sth_Olcu2=0,sth_Olcu3=0,sth_Olcu4=0,sth_Olcu5=0,sth_FormulMiktar=0,sth_eirs_senaryo=0,sth_eirs_tipi=0,sth_teslim_tarihi=@sth_tarih,sth_matbu_fl=0,sth_satis_fiyat_doviz_cinsi=0,sth_satis_fiyat_doviz_kuru=0,sth_lastup_user=1,sth_odeme_op=0,sth_FormulMiktarNo=0,sth_eticaret_kanal_kodu='' Where sth_Guid=@sth_Guid SET @KeyFieldValue=@sth_Guid SET @LineNumber=@sth_satirno SELECT @KeyFieldValue AS KeyFieldValue,@sth_satirno as LineNumber END GO /****** Object: StoredProcedure [dbo].[sp_MBT_SaveDispatchAllTypes] Script Date: 10.07.2023 12:16:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_MBT_SaveDispatchAllTypes] ( @sth_belgeno nvarchar(16), @sth_evrakno_seri nvarchar(8), @sth_evrakno_sira int, @sth_tarih datetime, @sth_satirno int,--SIFIRDAN ARTARAK GIDIYOR MIKRODA @sth_belge_tarih datetime, @sth_plasiyer_kodu nvarchar(25), @sth_cari_kodu nvarchar(25), @sth_stok_kod nvarchar(25), @sth_b_fiyat float, @sth_miktar float, @sth_birim_pntr tinyint,--BIRIM FIYAT @sth_tutar float,--ISKONTOSUZ ARA TOPLAM @sth_iskonto1 float,--ISKONTO 1 TOPLAMI @sth_iskonto2 float,--ISKONTO 2 TOPLAMI @sth_iskonto3 float,--ISKONTO 3 TOPLAMI @sth_iskonto4 float,--ISKONTO 4 TOPLAMI @sth_iskonto5 float,--ISKONTO 5 TOPLAMI @sth_iskonto6 float,--ISKONTO 6 TOPLAMI @sth_vergi_pntr tinyint,-- 0 8 18 @sth_vergi float,-- ISKONTO DUSULDUKTEN SONRAKI KDV TOPLAMI @sth_aciklama nvarchar(50), @sth_aciklama2 nvarchar(50), @sth_cikis_depo_no int,--ZORUNLU GELMESI LAZIM @sth_doviz_kodu nvarchar(5),--TL USD EUR @sth_stok_sormerk nvarchar(25),-- YOKSA BOS GONDERILECEK @sth_adres_no int, @sip_Guid nvarchar(50), @sth_parti_kodu nvarchar(25), @sth_lot_no int, @sth_disticaret_turu int, @ChHar_SeriNo nvarchar(25), @MbtTakipNoAna nvarchar(50), @MbtTakipNoDetay nvarchar(50), @sth_tip int, @sth_cins int, @sth_evraktip int, @sth_normal_iade int, @sth_fileid int, @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT --İlk once Carihareket Kayıt edilmeli Çünkü ID si stok hareketlerine yazılacak --yada en son update edilebilir. --ben ikinisini tercih edecegim. ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- gelen fis Numarasına göre evrak aktaracagız.... --sth_tip Tinyint Hareket Tipi 0:Giriş 1:Çıkış 2:Depo Transfer /* --sth_cins Tinyint Hareket Cinsi 0:Toptan 1:Perakende 2:Dış Ticaret 3:Stok Virman 4:Fire 5:Sarf 6:Transfer 7:Üretim 8:Fason 9:Değer Farkı 10:Sayım 11:Stok Açılış 12:İthalat-İhracat 13:Hal 14:Müstahsil 15:Müstahsil Değer Farkı 14:Kabzımal 15:Gider Pusulası **/ -- sth_normal_iade Tinyint Normal/Iade? 0:Normal 1:İade --07 12 2020 11 /* sth_evraktip Tinyint Evrak Tipi 0:Depo Çıkış Fişi 1:Çıkış İrsaliyesi 2:Depo Transfer Fişi 3:Giriş Faturası 4:Çıkış Faturası 5:Stoklara İthalat Masraf Yansıtma Dekontu 6:Stok Virman Fişi 7:Üretim Fişi 8:İlave Enflasyon Maliyet Fişi 9:Stoklara İlave Maliyet Yedirme Fişi 10:Antrepolardan Mal Millileştirme Fişi 11:Antrepolar Arası Transfer Fişi 12:Depo Giriş Fişi 13:Giriş İrsaliyesi 14:Fason Giriş Çıkış Fişi 15:Depolar Arası Satış Fişi 16:Stok Gider Pusulası Fişi 17:Depolar Arası Nakliye Fişi **/ declare @subeliCalismaVarmi int declare @sth_subeno int SET @sth_subeno=0 SELECT @subeliCalismaVarmi=COUNT(*) FROM MBTSISTEMPARAMETRELERI WHERE PARAMETREADI='SUBELICALISMA' AND DEGER='EVET' if @subeliCalismaVarmi=1 BEGIN select @sth_subeno=@sth_cikis_depo_no END else BEGIN set @sth_subeno=0 END DECLARE @sth_doviz_cinsi tinyint SELECT @sth_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu DECLARE @sth_alt_doviz_kuru float DECLARE @sth_vergi_pntr_yeni int set @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,1) SELECT TOP 1 @sth_vergi_pntr_yeni=T1.VERGIPNTR FROM ( SELECT 0 AS VERGIPNTR,dbo.fn_VergiIsim(0) AS KDVADI,dbo.fn_VergiYuzde(0) AS KDVORANI UNION SELECT 1 AS VERGIPNTR,dbo.fn_VergiIsim(1) AS KDVADI,dbo.fn_VergiYuzde(1) AS KDVORANI UNION SELECT 2 AS VERGIPNTR,dbo.fn_VergiIsim(2) AS KDVADI,dbo.fn_VergiYuzde(2) AS KDVORANI UNION SELECT 3 AS VERGIPNTR,dbo.fn_VergiIsim(3) AS KDVADI,dbo.fn_VergiYuzde(3) AS KDVORANI UNION SELECT 4 AS VERGIPNTR,dbo.fn_VergiIsim(4) AS KDVADI,dbo.fn_VergiYuzde(4) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 7 AS VERGIPNTR,dbo.fn_VergiIsim(7) AS KDVADI,dbo.fn_VergiYuzde(7) AS KDVORANI UNION SELECT 8 AS VERGIPNTR,dbo.fn_VergiIsim(8) AS KDVADI,dbo.fn_VergiYuzde(8) AS KDVORANI UNION SELECT 9 AS VERGIPNTR,dbo.fn_VergiIsim(9) AS KDVADI,dbo.fn_VergiYuzde(9) AS KDVORANI UNION SELECT 10 AS VERGIPNTR,dbo.fn_VergiIsim(10) AS KDVADI,dbo.fn_VergiYuzde(10) AS KDVORANI UNION SELECT 11 AS VERGIPNTR,dbo.fn_VergiIsim(11) AS KDVADI,dbo.fn_VergiYuzde(11) AS KDVORANI UNION SELECT 12 AS VERGIPNTR,dbo.fn_VergiIsim(12) AS KDVADI,dbo.fn_VergiYuzde(12) AS KDVORANI UNION SELECT 13 AS VERGIPNTR,dbo.fn_VergiIsim(13) AS KDVADI,dbo.fn_VergiYuzde(13) AS KDVORANI UNION SELECT 14 AS VERGIPNTR,dbo.fn_VergiIsim(14) AS KDVADI,dbo.fn_VergiYuzde(14) AS KDVORANI UNION SELECT 15 AS VERGIPNTR,dbo.fn_VergiIsim(15) AS KDVADI,dbo.fn_VergiYuzde(15) AS KDVORANI UNION SELECT 16 AS VERGIPNTR,dbo.fn_VergiIsim(16) AS KDVADI,dbo.fn_VergiYuzde(16) AS KDVORANI UNION SELECT 17 AS VERGIPNTR,dbo.fn_VergiIsim(17) AS KDVADI,dbo.fn_VergiYuzde(17) AS KDVORANI UNION SELECT 18 AS VERGIPNTR,dbo.fn_VergiIsim(18) AS KDVADI,dbo.fn_VergiYuzde(18) AS KDVORANI UNION SELECT 19 AS VERGIPNTR,dbo.fn_VergiIsim(19) AS KDVADI,dbo.fn_VergiYuzde(19) AS KDVORANI UNION SELECT 20 AS VERGIPNTR,dbo.fn_VergiIsim(20) AS KDVADI,dbo.fn_VergiYuzde(20) AS KDVORANI ) T1 WHERE T1.KDVORANI=@sth_vergi_pntr ORDER BY VERGIPNTR ASC SET @sth_vergi_pntr=@sth_vergi_pntr_yeni if @sip_Guid='0' set @sip_Guid='00000000-0000-0000-0000-000000000000' -- Insert statements for procedure here INSERT INTO [dbo].[STOK_HAREKETLERI] ([sth_DBCno] ,[sth_SpecRECno] ,[sth_iptal] ,[sth_fileid] ,[sth_hidden] ,[sth_kilitli] ,[sth_degisti] ,[sth_checksum] ,[sth_create_user] ,[sth_create_date] ,[sth_lastup_user] ,[sth_lastup_date] ,[sth_special1] ,[sth_special2] ,[sth_special3] ,[sth_firmano] ,[sth_subeno] ,[sth_tarih] ,[sth_tip] ,[sth_cins] ,[sth_normal_iade] ,[sth_evraktip] ,[sth_evrakno_seri] ,[sth_evrakno_sira] ,[sth_satirno] ,[sth_belge_no] ,[sth_belge_tarih] ,[sth_stok_kod] ,[sth_isk_mas1] ,[sth_isk_mas2] ,[sth_isk_mas3] ,[sth_isk_mas4] ,[sth_isk_mas5] ,[sth_isk_mas6] ,[sth_isk_mas7] ,[sth_isk_mas8] ,[sth_isk_mas9] ,[sth_isk_mas10] ,[sth_sat_iskmas1] ,[sth_sat_iskmas2] ,[sth_sat_iskmas3] ,[sth_sat_iskmas4] ,[sth_sat_iskmas5] ,[sth_sat_iskmas6] ,[sth_sat_iskmas7] ,[sth_sat_iskmas8] ,[sth_sat_iskmas9] ,[sth_sat_iskmas10] ,[sth_pos_satis] ,[sth_promosyon_fl] ,[sth_cari_cinsi] ,[sth_cari_kodu] ,[sth_cari_grup_no] ,[sth_isemri_gider_kodu] ,[sth_plasiyer_kodu] ,[sth_har_doviz_cinsi] ,[sth_har_doviz_kuru] ,[sth_alt_doviz_kuru] ,[sth_stok_doviz_cinsi] ,[sth_stok_doviz_kuru] ,[sth_miktar] ,[sth_miktar2] ,[sth_birim_pntr] ,[sth_tutar] ,[sth_iskonto1] ,[sth_iskonto2] ,[sth_iskonto3] ,[sth_iskonto4] ,[sth_iskonto5] ,[sth_iskonto6] ,[sth_masraf1] ,[sth_masraf2] ,[sth_masraf3] ,[sth_masraf4] ,[sth_vergi_pntr] ,[sth_vergi] ,[sth_masraf_vergi_pntr] ,[sth_masraf_vergi] ,[sth_netagirlik] ,[sth_odeme_op] ,[sth_aciklama] ,[sth_sip_uid] ,[sth_fat_uid] ,[sth_giris_depo_no] ,[sth_cikis_depo_no] ,[sth_malkbl_sevk_tarihi] ,[sth_cari_srm_merkezi] ,[sth_stok_srm_merkezi] ,[sth_fis_tarihi] ,[sth_fis_sirano] ,[sth_vergisiz_fl] ,[sth_maliyet_ana] ,[sth_maliyet_alternatif] ,[sth_maliyet_orjinal] ,[sth_adres_no] ,[sth_parti_kodu] ,[sth_lot_no] ,[sth_kons_uid] ,[sth_proje_kodu] ,[sth_exim_kodu] ,[sth_otv_pntr] ,[sth_otv_vergi] ,[sth_brutagirlik] ,[sth_disticaret_turu] ,[sth_otvtutari] ,[sth_otvvergisiz_fl] ,[sth_oiv_pntr] ,[sth_oiv_vergi] ,[sth_oivvergisiz_fl] ,[sth_fiyat_liste_no] ,[sth_oivtutari] ,[sth_Tevkifat_turu] ,[sth_nakliyedeposu] ,[sth_nakliyedurumu] ,[sth_yetkili_uid] ,[sth_taxfree_fl]) VALUES (0-- ,0-- ,0-- ,@sth_fileid-- ,0-- ,0-- ,0-- ,0-- ,1-- ,getdate() -- ,1-- ,getdate()-- ,'mbt'-- ,''-- ,''-- ,0-- ,@sth_subeno-- ,@sth_tarih -- ,@sth_tip-- ,@sth_cins-- ,@sth_normal_iade-- ,@sth_evraktip-- ,@sth_evrakno_seri -- ,@sth_evrakno_sira -- ,@sth_satirno-- ,@sth_belgeno-- ,@sth_tarih-- ,@sth_stok_kod-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@sth_cari_kodu-- ,0-- ,''-- ,@sth_plasiyer_kodu -- ,@sth_doviz_cinsi -- ,1-- ,1-- ,@sth_doviz_cinsi-- ,1-- ,@sth_miktar-- ,@sth_miktar-- ,@sth_birim_pntr-- ,@sth_tutar-- ,@sth_iskonto1-- ,@sth_iskonto2-- ,@sth_iskonto3-- ,@sth_iskonto4-- ,@sth_iskonto5-- ,@sth_iskonto6-- ,0-- ,0-- ,0-- ,0-- ,@sth_vergi_pntr-- ,@sth_vergi -- ,0-- ,0-- ,0-- ,0-- ,@sth_aciklama -- ,@sip_Guid-- ,'00000000-0000-0000-0000-000000000000'-- ,@sth_cikis_depo_no -- ,@sth_cikis_depo_no-- ,@sth_tarih-- ,@sth_stok_sormerk-- ,@sth_stok_sormerk-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_adres_no-- ,@sth_parti_kodu -- ,@sth_lot_no -- ,'00000000-0000-0000-0000-000000000000'-- ,''-- ,''-- ,0-- ,0-- ,0-- ,@sth_disticaret_turu -- ,0-- ,0-- ,0-- ,0-- ,0-- ,1-- ,0-- ,0-- ,0-- ,0-- ,'00000000-0000-0000-0000-000000000000'-- ,0-- ) DECLARE @sth_Guid nvarchar(50) DECLARE @sth_RECno int SELECT @sth_Guid=sth_Guid FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_satirno= @sth_satirno and sth_tip=@sth_tip and sth_cins= @sth_cins and sth_evraktip=@sth_evraktip and sth_normal_iade= @sth_normal_iade --eksik kolonlar guncelle update STOK_HAREKETLERI set sth_ilave_edilecek_kdv=0,sth_HareketGrupKodu1='',sth_HareketGrupKodu2='',sth_HareketGrupKodu3='',sth_Olcu1=0,sth_Olcu2=0,sth_Olcu3=0,sth_Olcu4=0,sth_Olcu5=0,sth_FormulMiktar=0,sth_eirs_senaryo=0,sth_eirs_tipi=0,sth_teslim_tarihi=@sth_tarih,sth_matbu_fl=0,sth_satis_fiyat_doviz_cinsi=0,sth_satis_fiyat_doviz_kuru=0,sth_lastup_user=1,sth_odeme_op=0,sth_FormulMiktarNo=0,sth_eticaret_kanal_kodu='' Where sth_Guid=@sth_Guid if @sip_Guid<>'00000000-0000-0000-0000-000000000000' BEGIN UPDATE SIPARISLER SET sip_teslim_miktar=(select SUM(SH.sth_miktar) FROM STOK_HAREKETLERI SH WHERE SH.sth_sip_uid=@sip_Guid) where sip_Guid=@sip_Guid END SET @KeyFieldValue=@sth_Guid SET @LineNumber=@sth_satirno SELECT @KeyFieldValue AS KeyFieldValue,@sth_satirno as LineNumber END GO /****** Object: StoredProcedure [dbo].[sp_MBT_SaveDispatchAllTypesV2] Script Date: 10.07.2023 12:16:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_MBT_SaveDispatchAllTypesV2] ( @sth_belgeno nvarchar(16), @sth_evrakno_seri nvarchar(8), @sth_evrakno_sira int, @sth_tarih datetime, @sth_satirno int,--SIFIRDAN ARTARAK GIDIYOR MIKRODA @sth_belge_tarih datetime, @sth_plasiyer_kodu nvarchar(25), @sth_cari_kodu nvarchar(25), @sth_stok_kod nvarchar(25), @sth_b_fiyat float, @sth_miktar float, @sth_birim_pntr tinyint,--BIRIM FIYAT @sth_tutar float,--ISKONTOSUZ ARA TOPLAM @sth_iskonto1 float,--ISKONTO 1 TOPLAMI @sth_iskonto2 float,--ISKONTO 2 TOPLAMI @sth_iskonto3 float,--ISKONTO 3 TOPLAMI @sth_iskonto4 float,--ISKONTO 4 TOPLAMI @sth_iskonto5 float,--ISKONTO 5 TOPLAMI @sth_iskonto6 float,--ISKONTO 6 TOPLAMI @sth_vergi_pntr tinyint,-- 0 8 18 @sth_vergi float,-- ISKONTO DUSULDUKTEN SONRAKI KDV TOPLAMI @sth_aciklama nvarchar(50), @sth_aciklama2 nvarchar(50), @sth_giris_depo_no int,--ZORUNLU GELMESI LAZIM @sth_cikis_depo_no int,--ZORUNLU GELMESI LAZIM @sth_doviz_kodu nvarchar(5),--TL USD EUR @sth_stok_sormerk nvarchar(25),-- YOKSA BOS GONDERILECEK @sth_adres_no int, @sip_Guid nvarchar(50), @sth_parti_kodu nvarchar(25), @sth_lot_no int, @sth_disticaret_turu int, @ChHar_SeriNo nvarchar(25), @MbtTakipNoAna nvarchar(50), @MbtTakipNoDetay nvarchar(50), @sth_tip int, @sth_cins int, @sth_evraktip int, @sth_normal_iade int, @sth_fileid int, @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT --İlk once Carihareket Kayıt edilmeli Çünkü ID si stok hareketlerine yazılacak --yada en son update edilebilir. --ben ikinisini tercih edecegim. --07 12 2020 10 ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- gelen fis Numarasına göre evrak aktaracagız.... --sth_tip Tinyint Hareket Tipi 0:Giriş 1:Çıkış 2:Depo Transfer /* --sth_cins Tinyint Hareket Cinsi 0:Toptan 1:Perakende 2:Dış Ticaret 3:Stok Virman 4:Fire 5:Sarf 6:Transfer 7:Üretim 8:Fason 9:Değer Farkı 10:Sayım 11:Stok Açılış 12:İthalat-İhracat 13:Hal 14:Müstahsil 15:Müstahsil Değer Farkı 14:Kabzımal 15:Gider Pusulası **/ -- sth_normal_iade Tinyint Normal/Iade? 0:Normal 1:İade --07 12 2020 /* sth_evraktip Tinyint Evrak Tipi 0:Depo Çıkış Fişi 1:Çıkış İrsaliyesi 2:Depo Transfer Fişi 3:Giriş Faturası 4:Çıkış Faturası 5:Stoklara İthalat Masraf Yansıtma Dekontu 6:Stok Virman Fişi 7:Üretim Fişi 8:İlave Enflasyon Maliyet Fişi 9:Stoklara İlave Maliyet Yedirme Fişi 10:Antrepolardan Mal Millileştirme Fişi 11:Antrepolar Arası Transfer Fişi 12:Depo Giriş Fişi 13:Giriş İrsaliyesi 14:Fason Giriş Çıkış Fişi 15:Depolar Arası Satış Fişi 16:Stok Gider Pusulası Fişi 17:Depolar Arası Nakliye Fişi **/ declare @subeliCalismaVarmi int declare @sth_subeno int SET @sth_subeno=0 SELECT @subeliCalismaVarmi=COUNT(*) FROM MBTSISTEMPARAMETRELERI WHERE PARAMETREADI='SUBELICALISMA' AND DEGER='EVET' if @subeliCalismaVarmi=1 BEGIN select @sth_subeno=@sth_cikis_depo_no END else BEGIN set @sth_subeno=0 END DECLARE @sth_doviz_cinsi tinyint SELECT @sth_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu DECLARE @sth_alt_doviz_kuru float DECLARE @sth_vergi_pntr_yeni int set @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,1) SELECT TOP 1 @sth_vergi_pntr_yeni=T1.VERGIPNTR FROM ( SELECT 0 AS VERGIPNTR,dbo.fn_VergiIsim(0) AS KDVADI,dbo.fn_VergiYuzde(0) AS KDVORANI UNION SELECT 1 AS VERGIPNTR,dbo.fn_VergiIsim(1) AS KDVADI,dbo.fn_VergiYuzde(1) AS KDVORANI UNION SELECT 2 AS VERGIPNTR,dbo.fn_VergiIsim(2) AS KDVADI,dbo.fn_VergiYuzde(2) AS KDVORANI UNION SELECT 3 AS VERGIPNTR,dbo.fn_VergiIsim(3) AS KDVADI,dbo.fn_VergiYuzde(3) AS KDVORANI UNION SELECT 4 AS VERGIPNTR,dbo.fn_VergiIsim(4) AS KDVADI,dbo.fn_VergiYuzde(4) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 7 AS VERGIPNTR,dbo.fn_VergiIsim(7) AS KDVADI,dbo.fn_VergiYuzde(7) AS KDVORANI UNION SELECT 8 AS VERGIPNTR,dbo.fn_VergiIsim(8) AS KDVADI,dbo.fn_VergiYuzde(8) AS KDVORANI UNION SELECT 9 AS VERGIPNTR,dbo.fn_VergiIsim(9) AS KDVADI,dbo.fn_VergiYuzde(9) AS KDVORANI UNION SELECT 10 AS VERGIPNTR,dbo.fn_VergiIsim(10) AS KDVADI,dbo.fn_VergiYuzde(10) AS KDVORANI UNION SELECT 11 AS VERGIPNTR,dbo.fn_VergiIsim(11) AS KDVADI,dbo.fn_VergiYuzde(11) AS KDVORANI UNION SELECT 12 AS VERGIPNTR,dbo.fn_VergiIsim(12) AS KDVADI,dbo.fn_VergiYuzde(12) AS KDVORANI UNION SELECT 13 AS VERGIPNTR,dbo.fn_VergiIsim(13) AS KDVADI,dbo.fn_VergiYuzde(13) AS KDVORANI UNION SELECT 14 AS VERGIPNTR,dbo.fn_VergiIsim(14) AS KDVADI,dbo.fn_VergiYuzde(14) AS KDVORANI UNION SELECT 15 AS VERGIPNTR,dbo.fn_VergiIsim(15) AS KDVADI,dbo.fn_VergiYuzde(15) AS KDVORANI UNION SELECT 16 AS VERGIPNTR,dbo.fn_VergiIsim(16) AS KDVADI,dbo.fn_VergiYuzde(16) AS KDVORANI UNION SELECT 17 AS VERGIPNTR,dbo.fn_VergiIsim(17) AS KDVADI,dbo.fn_VergiYuzde(17) AS KDVORANI UNION SELECT 18 AS VERGIPNTR,dbo.fn_VergiIsim(18) AS KDVADI,dbo.fn_VergiYuzde(18) AS KDVORANI UNION SELECT 19 AS VERGIPNTR,dbo.fn_VergiIsim(19) AS KDVADI,dbo.fn_VergiYuzde(19) AS KDVORANI UNION SELECT 20 AS VERGIPNTR,dbo.fn_VergiIsim(20) AS KDVADI,dbo.fn_VergiYuzde(20) AS KDVORANI ) T1 WHERE T1.KDVORANI=@sth_vergi_pntr ORDER BY VERGIPNTR ASC SET @sth_vergi_pntr=@sth_vergi_pntr_yeni if @sip_Guid='0' set @sip_Guid='00000000-0000-0000-0000-000000000000' -- Insert statements for procedure here INSERT INTO [dbo].[STOK_HAREKETLERI] ([sth_DBCno] ,[sth_SpecRECno] ,[sth_iptal] ,[sth_fileid] ,[sth_hidden] ,[sth_kilitli] ,[sth_degisti] ,[sth_checksum] ,[sth_create_user] ,[sth_create_date] ,[sth_lastup_user] ,[sth_lastup_date] ,[sth_special1] ,[sth_special2] ,[sth_special3] ,[sth_firmano] ,[sth_subeno] ,[sth_tarih] ,[sth_tip] ,[sth_cins] ,[sth_normal_iade] ,[sth_evraktip] ,[sth_evrakno_seri] ,[sth_evrakno_sira] ,[sth_satirno] ,[sth_belge_no] ,[sth_belge_tarih] ,[sth_stok_kod] ,[sth_isk_mas1] ,[sth_isk_mas2] ,[sth_isk_mas3] ,[sth_isk_mas4] ,[sth_isk_mas5] ,[sth_isk_mas6] ,[sth_isk_mas7] ,[sth_isk_mas8] ,[sth_isk_mas9] ,[sth_isk_mas10] ,[sth_sat_iskmas1] ,[sth_sat_iskmas2] ,[sth_sat_iskmas3] ,[sth_sat_iskmas4] ,[sth_sat_iskmas5] ,[sth_sat_iskmas6] ,[sth_sat_iskmas7] ,[sth_sat_iskmas8] ,[sth_sat_iskmas9] ,[sth_sat_iskmas10] ,[sth_pos_satis] ,[sth_promosyon_fl] ,[sth_cari_cinsi] ,[sth_cari_kodu] ,[sth_cari_grup_no] ,[sth_isemri_gider_kodu] ,[sth_plasiyer_kodu] ,[sth_har_doviz_cinsi] ,[sth_har_doviz_kuru] ,[sth_alt_doviz_kuru] ,[sth_stok_doviz_cinsi] ,[sth_stok_doviz_kuru] ,[sth_miktar] ,[sth_miktar2] ,[sth_birim_pntr] ,[sth_tutar] ,[sth_iskonto1] ,[sth_iskonto2] ,[sth_iskonto3] ,[sth_iskonto4] ,[sth_iskonto5] ,[sth_iskonto6] ,[sth_masraf1] ,[sth_masraf2] ,[sth_masraf3] ,[sth_masraf4] ,[sth_vergi_pntr] ,[sth_vergi] ,[sth_masraf_vergi_pntr] ,[sth_masraf_vergi] ,[sth_netagirlik] ,[sth_odeme_op] ,[sth_aciklama] ,[sth_sip_uid] ,[sth_fat_uid] ,[sth_giris_depo_no] ,[sth_cikis_depo_no] ,[sth_malkbl_sevk_tarihi] ,[sth_cari_srm_merkezi] ,[sth_stok_srm_merkezi] ,[sth_fis_tarihi] ,[sth_fis_sirano] ,[sth_vergisiz_fl] ,[sth_maliyet_ana] ,[sth_maliyet_alternatif] ,[sth_maliyet_orjinal] ,[sth_adres_no] ,[sth_parti_kodu] ,[sth_lot_no] ,[sth_kons_uid] ,[sth_proje_kodu] ,[sth_exim_kodu] ,[sth_otv_pntr] ,[sth_otv_vergi] ,[sth_brutagirlik] ,[sth_disticaret_turu] ,[sth_otvtutari] ,[sth_otvvergisiz_fl] ,[sth_oiv_pntr] ,[sth_oiv_vergi] ,[sth_oivvergisiz_fl] ,[sth_fiyat_liste_no] ,[sth_oivtutari] ,[sth_Tevkifat_turu] ,[sth_nakliyedeposu] ,[sth_nakliyedurumu] ,[sth_yetkili_uid] ,[sth_taxfree_fl]) VALUES (0-- ,0-- ,0-- ,@sth_fileid-- ,0-- ,0-- ,0-- ,0-- ,1-- ,getdate() -- ,1-- ,getdate()-- ,'mbt'-- ,''-- ,''-- ,0-- ,@sth_subeno-- ,@sth_tarih -- ,@sth_tip-- ,@sth_cins-- ,@sth_normal_iade-- ,@sth_evraktip-- ,@sth_evrakno_seri -- ,@sth_evrakno_sira -- ,@sth_satirno-- ,@sth_belgeno-- ,@sth_tarih-- ,@sth_stok_kod-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@sth_cari_kodu-- ,0-- ,''-- ,@sth_plasiyer_kodu -- ,@sth_doviz_cinsi -- ,1-- ,1-- ,@sth_doviz_cinsi-- ,1-- ,@sth_miktar-- ,@sth_miktar-- ,@sth_birim_pntr-- ,@sth_tutar-- ,@sth_iskonto1-- ,@sth_iskonto2-- ,@sth_iskonto3-- ,@sth_iskonto4-- ,@sth_iskonto5-- ,@sth_iskonto6-- ,0-- ,0-- ,0-- ,0-- ,@sth_vergi_pntr-- ,@sth_vergi -- ,0-- ,0-- ,0-- ,0-- ,@sth_aciklama -- ,@sip_Guid-- ,'00000000-0000-0000-0000-000000000000'-- ,@sth_giris_depo_no -- ,@sth_cikis_depo_no-- ,@sth_tarih-- ,@sth_stok_sormerk-- ,@sth_stok_sormerk-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_adres_no-- ,@sth_parti_kodu -- ,@sth_lot_no -- ,'00000000-0000-0000-0000-000000000000'-- ,''-- ,''-- ,0-- ,0-- ,0-- ,@sth_disticaret_turu -- ,0-- ,0-- ,0-- ,0-- ,0-- ,1-- ,0-- ,0-- ,0-- ,0-- ,'00000000-0000-0000-0000-000000000000'-- ,0-- ) DECLARE @sth_Guid nvarchar(50) DECLARE @sth_RECno int SELECT @sth_Guid=sth_Guid FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_satirno= @sth_satirno and sth_tip=@sth_tip and sth_cins= @sth_cins and sth_evraktip=@sth_evraktip and sth_normal_iade= @sth_normal_iade --eksik kolonlar guncelle update STOK_HAREKETLERI set sth_ilave_edilecek_kdv=0,sth_HareketGrupKodu1='',sth_HareketGrupKodu2='',sth_HareketGrupKodu3='',sth_Olcu1=0,sth_Olcu2=0,sth_Olcu3=0,sth_Olcu4=0,sth_Olcu5=0,sth_FormulMiktar=0,sth_eirs_senaryo=0,sth_eirs_tipi=0,sth_teslim_tarihi=@sth_tarih,sth_matbu_fl=0,sth_satis_fiyat_doviz_cinsi=0,sth_satis_fiyat_doviz_kuru=0,sth_lastup_user=1,sth_odeme_op=0,sth_FormulMiktarNo=0,sth_eticaret_kanal_kodu='' Where sth_Guid=@sth_Guid if @sip_Guid<>'00000000-0000-0000-0000-000000000000' BEGIN UPDATE SIPARISLER SET sip_teslim_miktar=(select SUM(SH.sth_miktar) FROM STOK_HAREKETLERI SH WHERE SH.sth_sip_uid=@sip_Guid) where sip_Guid=@sip_Guid END SET @KeyFieldValue=@sth_Guid SET @LineNumber=@sth_satirno SELECT @KeyFieldValue AS KeyFieldValue,@sth_satirno as LineNumber END GO /****** Object: StoredProcedure [dbo].[sp_MBT_SaveDispatchAllTypesWithDAT] Script Date: 10.07.2023 12:16:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_MBT_SaveDispatchAllTypesWithDAT] ( @sth_belgeno nvarchar(16), @sth_evrakno_seri nvarchar(8), @sth_evrakno_sira int, @sth_tarih datetime, @sth_satirno int,--SIFIRDAN ARTARAK GIDIYOR MIKRODA @sth_belge_tarih datetime, @sth_plasiyer_kodu nvarchar(25), @sth_cari_kodu nvarchar(25), @sth_stok_kod nvarchar(25), @sth_b_fiyat float, @sth_miktar float, @sth_birim_pntr tinyint,--BIRIM FIYAT @sth_tutar float,--ISKONTOSUZ ARA TOPLAM @sth_iskonto1 float,--ISKONTO 1 TOPLAMI @sth_iskonto2 float,--ISKONTO 2 TOPLAMI @sth_iskonto3 float,--ISKONTO 3 TOPLAMI @sth_iskonto4 float,--ISKONTO 4 TOPLAMI @sth_iskonto5 float,--ISKONTO 5 TOPLAMI @sth_iskonto6 float,--ISKONTO 6 TOPLAMI @sth_vergi_pntr tinyint,-- 0 8 18 @sth_vergi float,-- ISKONTO DUSULDUKTEN SONRAKI KDV TOPLAMI @sth_aciklama nvarchar(50), @sth_aciklama2 nvarchar(50), @sth_giris_depo_no int,--ZORUNLU GELMESI LAZIM @sth_cikis_depo_no int,--ZORUNLU GELMESI LAZIM @sth_doviz_kodu nvarchar(5),--TL USD EUR @sth_stok_doviz_cinsi int,--0 tl 1 usd 2 eur @sth_stok_sormerk nvarchar(25),-- YOKSA BOS GONDERILECEK @sth_adres_no int, @sip_Guid nvarchar(50),--SIPARIS @ssip_Guid nvarchar(50),--DEPOLAR ARASI SIPARIS @sth_parti_kodu nvarchar(25), @sth_lot_no int, @sth_disticaret_turu int, @ChHar_SeriNo nvarchar(25), @MbtTakipNoAna nvarchar(50), @MbtTakipNoDetay nvarchar(50), @sth_tip int, @sth_cins int, @sth_evraktip int, @sth_normal_iade int, @sth_fileid int, @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT --İlk once Carihareket Kayıt edilmeli Çünkü ID si stok hareketlerine yazılacak --yada en son update edilebilir. --ben ikinisini tercih edecegim. --07 12 2020 12 ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- gelen fis Numarasına göre evrak aktaracagız.... --sth_tip Tinyint Hareket Tipi 0:Giriş 1:Çıkış 2:Depo Transfer /* --sth_cins Tinyint Hareket Cinsi 0:Toptan 1:Perakende 2:Dış Ticaret 3:Stok Virman 4:Fire 5:Sarf 6:Transfer 7:Üretim 8:Fason 9:Değer Farkı 10:Sayım 11:Stok Açılış 12:İthalat-İhracat 13:Hal 14:Müstahsil 15:Müstahsil Değer Farkı 14:Kabzımal 15:Gider Pusulası **/ -- sth_normal_iade Tinyint Normal/Iade? 0:Normal 1:İade /* sth_evraktip Tinyint Evrak Tipi 0:Depo Çıkış Fişi 1:Çıkış İrsaliyesi 2:Depo Transfer Fişi 3:Giriş Faturası 4:Çıkış Faturası 5:Stoklara İthalat Masraf Yansıtma Dekontu 6:Stok Virman Fişi 7:Üretim Fişi 8:İlave Enflasyon Maliyet Fişi 9:Stoklara İlave Maliyet Yedirme Fişi 10:Antrepolardan Mal Millileştirme Fişi 11:Antrepolar Arası Transfer Fişi 12:Depo Giriş Fişi 13:Giriş İrsaliyesi 14:Fason Giriş Çıkış Fişi 15:Depolar Arası Satış Fişi 16:Stok Gider Pusulası Fişi 17:Depolar Arası Nakliye Fişi **/ declare @subeliCalismaVarmi int declare @sth_subeno int SET @sth_subeno=0 SELECT @subeliCalismaVarmi=COUNT(*) FROM MBTSISTEMPARAMETRELERI WHERE PARAMETREADI='SUBELICALISMA' AND DEGER='EVET' if @subeliCalismaVarmi=1 BEGIN select @sth_subeno=@sth_cikis_depo_no END else BEGIN set @sth_subeno=0 END DECLARE @sth_doviz_cinsi tinyint DECLARE @sth_doviz_kuru float DECLARE @sth_stok_doviz_kuru float DECLARE @sorumluluk_merkezi nvarchar(25) set @sorumluluk_merkezi='' if @sip_Guid<>'00000000-0000-0000-0000-000000000000' BEGIN SELECT @sorumluluk_merkezi=sip_cari_sormerk FROM SIPARISLER WHERE sip_Guid=@sip_Guid END DECLARE @sip_opno nvarchar(10) BEGIN SELECT @sip_opno=sip_opno FROM SIPARISLER WHERE sip_Guid=@sip_Guid END IF @sth_aciklama='' BEGIN DECLARE @sip_aciklama nvarchar(50) SELECT @sip_aciklama=sip_aciklama FROM SIPARISLER WHERE sip_Guid=@sip_Guid set @sth_aciklama = @sip_aciklama END -- if @sip_Guid<>'00000000-0000-0000-0000-000000000000' BEGIN if @sth_stok_sormerk='' set @sth_stok_sormerk=@sorumluluk_merkezi END -- SELECT @sth_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu --sth_doviz_cinsi=sth_stok_doviz_cinsi ne eşitlenecek ve o kura göre kur alınacak. set @sth_stok_doviz_cinsi=@sth_doviz_cinsi DECLARE @cari_KurHesapSekli tinyint SELECT @cari_KurHesapSekli=cari_KurHesapSekli FROM CARI_HESAPLAR WHERE cari_kod=@sth_cari_kodu if @cari_KurHesapSekli =0 set @cari_KurHesapSekli=2 DECLARE @sth_alt_doviz_kuru float DECLARE @sth_har_doviz_kuru float -- evrak doviz cinsinin doviz kuru DECLARE @sth_vergi_pntr_yeni int DECLARE @TESLIMMIKTAR FLOAT DECLARE @TESLIMMIKTAR2 FLOAT DECLARE @sth_isk_mas1 int DECLARE @sth_isk_mas2 int DECLARE @sth_isk_mas3 int DECLARE @sth_isk_mas4 int DECLARE @sth_isk_mas5 int DECLARE @sth_isk_mas6 int SELECT @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,@cari_KurHesapSekli) SELECT @sth_har_doviz_kuru=dbo.fn_KurBul(GetDate(),@sth_doviz_cinsi,@cari_KurHesapSekli) SELECT @sth_stok_doviz_kuru=dbo.fn_KurBul(GetDate(),@sth_stok_doviz_cinsi,@cari_KurHesapSekli) --CARIYE TANIMLI KUR VARMI /* DECLARE @cariyeTanimliOzelKurVarmi FLOAT SET @cariyeTanimliOzelKurVarmi=0 if @sth_doviz_cinsi='USD' BEGIN SELECT @cariyeTanimliOzelKurVarmi=ISNULL(USDKURU,0) FROM MBTDOVIZKURLARI WHERE MUSTERIKODU=@sth_cari_kodu and YIL=YEAR(GETDATE()) AND AY=MONTH(GETDATE()) END if @sth_doviz_cinsi='EUR' BEGIN SELECT @cariyeTanimliOzelKurVarmi=ISNULL(EURKURU,0) FROM MBTDOVIZKURLARI WHERE MUSTERIKODU=@sth_cari_kodu and YIL=YEAR(GETDATE()) AND AY=MONTH(GETDATE()) END if @cariyeTanimliOzelKurVarmi>0 BEGIN SET @sth_alt_doviz_kuru =@cariyeTanimliOzelKurVarmi SET @sth_har_doviz_kuru =@cariyeTanimliOzelKurVarmi SET @sth_stok_doviz_kuru =@cariyeTanimliOzelKurVarmi END */ --SELECT @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,2) SELECT TOP 1 @sth_vergi_pntr_yeni=T1.VERGIPNTR FROM ( SELECT 0 AS VERGIPNTR,dbo.fn_VergiIsim(0) AS KDVADI,dbo.fn_VergiYuzde(0) AS KDVORANI UNION SELECT 1 AS VERGIPNTR,dbo.fn_VergiIsim(1) AS KDVADI,dbo.fn_VergiYuzde(1) AS KDVORANI UNION SELECT 2 AS VERGIPNTR,dbo.fn_VergiIsim(2) AS KDVADI,dbo.fn_VergiYuzde(2) AS KDVORANI UNION SELECT 3 AS VERGIPNTR,dbo.fn_VergiIsim(3) AS KDVADI,dbo.fn_VergiYuzde(3) AS KDVORANI UNION SELECT 4 AS VERGIPNTR,dbo.fn_VergiIsim(4) AS KDVADI,dbo.fn_VergiYuzde(4) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 7 AS VERGIPNTR,dbo.fn_VergiIsim(7) AS KDVADI,dbo.fn_VergiYuzde(7) AS KDVORANI UNION SELECT 8 AS VERGIPNTR,dbo.fn_VergiIsim(8) AS KDVADI,dbo.fn_VergiYuzde(8) AS KDVORANI UNION SELECT 9 AS VERGIPNTR,dbo.fn_VergiIsim(9) AS KDVADI,dbo.fn_VergiYuzde(9) AS KDVORANI UNION SELECT 10 AS VERGIPNTR,dbo.fn_VergiIsim(10) AS KDVADI,dbo.fn_VergiYuzde(10) AS KDVORANI UNION SELECT 11 AS VERGIPNTR,dbo.fn_VergiIsim(11) AS KDVADI,dbo.fn_VergiYuzde(11) AS KDVORANI UNION SELECT 12 AS VERGIPNTR,dbo.fn_VergiIsim(12) AS KDVADI,dbo.fn_VergiYuzde(12) AS KDVORANI UNION SELECT 13 AS VERGIPNTR,dbo.fn_VergiIsim(13) AS KDVADI,dbo.fn_VergiYuzde(13) AS KDVORANI UNION SELECT 14 AS VERGIPNTR,dbo.fn_VergiIsim(14) AS KDVADI,dbo.fn_VergiYuzde(14) AS KDVORANI UNION SELECT 15 AS VERGIPNTR,dbo.fn_VergiIsim(15) AS KDVADI,dbo.fn_VergiYuzde(15) AS KDVORANI UNION SELECT 16 AS VERGIPNTR,dbo.fn_VergiIsim(16) AS KDVADI,dbo.fn_VergiYuzde(16) AS KDVORANI UNION SELECT 17 AS VERGIPNTR,dbo.fn_VergiIsim(17) AS KDVADI,dbo.fn_VergiYuzde(17) AS KDVORANI UNION SELECT 18 AS VERGIPNTR,dbo.fn_VergiIsim(18) AS KDVADI,dbo.fn_VergiYuzde(18) AS KDVORANI UNION SELECT 19 AS VERGIPNTR,dbo.fn_VergiIsim(19) AS KDVADI,dbo.fn_VergiYuzde(19) AS KDVORANI UNION SELECT 20 AS VERGIPNTR,dbo.fn_VergiIsim(20) AS KDVADI,dbo.fn_VergiYuzde(20) AS KDVORANI ) T1 WHERE T1.KDVORANI=@sth_vergi_pntr ORDER BY VERGIPNTR ASC SET @sth_vergi_pntr=@sth_vergi_pntr_yeni SET @sth_isk_mas1=0 SET @sth_isk_mas2=0 SET @sth_isk_mas3=0 SET @sth_isk_mas4=0 SET @sth_isk_mas5=0 SET @sth_isk_mas6=0 if @sth_iskonto1>0 set @sth_isk_mas1=1 if @sth_iskonto2>0 set @sth_isk_mas2=1 if @sth_iskonto3>0 set @sth_isk_mas3=1 if @sth_iskonto4>0 set @sth_isk_mas4=1 if @sth_iskonto5>0 set @sth_isk_mas5=1 if @sth_iskonto6>0 set @sth_isk_mas6=1 --if @sip_Guid='0' set @sip_Guid='00000000-0000-0000-0000-000000000000' --if @ssip_Guid='0' set @ssip_Guid='00000000-0000-0000-0000-000000000000' declare @sth_netagirlik float declare @sth_dara float declare @sth_brutagirlik float declare @sth_FormulMiktarNo int SELECT @sth_netagirlik=sto_birim1_agirlik FROM STOKLAR WHERE sto_kod=@sth_stok_kod SELECT @sth_dara=sto_birim1_dara FROM STOKLAR WHERE sto_kod=@sth_stok_kod set @sth_brutagirlik=@sth_dara+ @sth_netagirlik -- Insert statements for procedure here INSERT INTO [dbo].[STOK_HAREKETLERI] ([sth_DBCno] ,[sth_SpecRECno] ,[sth_iptal] ,[sth_fileid] ,[sth_hidden] ,[sth_kilitli] ,[sth_degisti] ,[sth_checksum] ,[sth_create_user] ,[sth_create_date] ,[sth_lastup_user] ,[sth_lastup_date] ,[sth_special1] ,[sth_special2] ,[sth_special3] ,[sth_firmano] ,[sth_subeno] ,[sth_tarih] ,[sth_tip] ,[sth_cins] ,[sth_normal_iade] ,[sth_evraktip] ,[sth_evrakno_seri] ,[sth_evrakno_sira] ,[sth_satirno] ,[sth_belge_no] ,[sth_belge_tarih] ,[sth_stok_kod] ,[sth_isk_mas1] ,[sth_isk_mas2] ,[sth_isk_mas3] ,[sth_isk_mas4] ,[sth_isk_mas5] ,[sth_isk_mas6] ,[sth_isk_mas7] ,[sth_isk_mas8] ,[sth_isk_mas9] ,[sth_isk_mas10] ,[sth_sat_iskmas1] ,[sth_sat_iskmas2] ,[sth_sat_iskmas3] ,[sth_sat_iskmas4] ,[sth_sat_iskmas5] ,[sth_sat_iskmas6] ,[sth_sat_iskmas7] ,[sth_sat_iskmas8] ,[sth_sat_iskmas9] ,[sth_sat_iskmas10] ,[sth_pos_satis] ,[sth_promosyon_fl] ,[sth_cari_cinsi] ,[sth_cari_kodu] ,[sth_cari_grup_no] ,[sth_isemri_gider_kodu] ,[sth_plasiyer_kodu] ,[sth_har_doviz_cinsi] ,[sth_har_doviz_kuru] ,[sth_alt_doviz_kuru] ,[sth_stok_doviz_cinsi] ,[sth_stok_doviz_kuru] ,[sth_miktar] ,[sth_miktar2] ,[sth_birim_pntr] ,[sth_tutar] ,[sth_iskonto1] ,[sth_iskonto2] ,[sth_iskonto3] ,[sth_iskonto4] ,[sth_iskonto5] ,[sth_iskonto6] ,[sth_masraf1] ,[sth_masraf2] ,[sth_masraf3] ,[sth_masraf4] ,[sth_vergi_pntr] ,[sth_vergi] ,[sth_masraf_vergi_pntr] ,[sth_masraf_vergi] ,[sth_netagirlik] ,[sth_odeme_op] ,[sth_aciklama] ,[sth_sip_uid] ,[sth_fat_uid] ,[sth_giris_depo_no] ,[sth_cikis_depo_no] ,[sth_malkbl_sevk_tarihi] ,[sth_cari_srm_merkezi] ,[sth_stok_srm_merkezi] ,[sth_fis_tarihi] ,[sth_fis_sirano] ,[sth_vergisiz_fl] ,[sth_maliyet_ana] ,[sth_maliyet_alternatif] ,[sth_maliyet_orjinal] ,[sth_adres_no] ,[sth_parti_kodu] ,[sth_lot_no] ,[sth_kons_uid] ,[sth_proje_kodu] ,[sth_exim_kodu] ,[sth_otv_pntr] ,[sth_otv_vergi] ,[sth_brutagirlik] ,[sth_disticaret_turu] ,[sth_otvtutari] ,[sth_otvvergisiz_fl] ,[sth_oiv_pntr] ,[sth_oiv_vergi] ,[sth_oivvergisiz_fl] ,[sth_fiyat_liste_no] ,[sth_oivtutari] ,[sth_Tevkifat_turu] ,[sth_nakliyedeposu] ,[sth_nakliyedurumu] ,[sth_yetkili_uid] ,[sth_taxfree_fl] ,sth_ilave_edilecek_kdv ,sth_ismerkezi_kodu) VALUES (0-- ,0-- ,0-- ,@sth_fileid-- ,0-- ,0-- ,0-- ,0-- ,1-- ,getdate() -- ,1-- ,getdate()-- ,'mbt'-- ,''-- ,''-- ,0-- ,@sth_subeno-- ,@sth_tarih -- ,@sth_tip-- ,@sth_cins-- ,@sth_normal_iade-- ,@sth_evraktip-- ,@sth_evrakno_seri -- ,@sth_evrakno_sira -- ,@sth_satirno-- ,@sth_belgeno-- ,@sth_tarih-- ,@sth_stok_kod-- ,@sth_isk_mas1-- ,@sth_isk_mas2-- ,@sth_isk_mas3-- ,@sth_isk_mas4-- ,@sth_isk_mas5-- ,@sth_isk_mas6-- ,1-- ,1-- ,1-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@sth_cari_kodu-- ,0-- ,''-- ,@sth_plasiyer_kodu -- ,@sth_doviz_cinsi -- ,@sth_har_doviz_kuru-- ,@sth_alt_doviz_kuru-- ,@sth_stok_doviz_cinsi-- ,@sth_stok_doviz_kuru-- ,@sth_miktar-- ,@sth_miktar-- ,@sth_birim_pntr-- ,@sth_tutar-- ,@sth_iskonto1-- ,@sth_iskonto2-- ,@sth_iskonto3-- ,@sth_iskonto4-- ,@sth_iskonto5-- ,@sth_iskonto6-- ,0-- ,0-- ,0-- ,0-- ,@sth_vergi_pntr-- ,@sth_vergi -- ,0-- ,0-- ,@sth_netagirlik-- ,@sip_opno-- ,@sth_aciklama -- ,@sip_Guid-- ,'00000000-0000-0000-0000-000000000000'-- ,@sth_giris_depo_no -- ,@sth_cikis_depo_no-- ,@sth_tarih-- ,@sth_stok_sormerk-- ,@sth_stok_sormerk-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_adres_no-- ,@sth_parti_kodu -- ,@sth_lot_no -- ,'00000000-0000-0000-0000-000000000000'-- ,''-- ,''-- ,0-- ,0-- ,@sth_brutagirlik-- ,@sth_disticaret_turu -- ,0-- ,0-- ,0-- ,0-- ,0-- ,1-- ,0-- ,0-- ,0-- ,0-- ,'00000000-0000-0000-0000-000000000000'-- ,0-- ,0--sth_ilave_edilecek_kdv ,0--sth_ismerkezi_kodu ) DECLARE @sth_Guid nvarchar(50) DECLARE @sth_RECno int SELECT @sth_Guid=sth_Guid FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_satirno= @sth_satirno and sth_tip=@sth_tip and sth_cins= @sth_cins and sth_evraktip=@sth_evraktip and sth_normal_iade= @sth_normal_iade --eksik kolonlar guncelle update STOK_HAREKETLERI set sth_ilave_edilecek_kdv=0,sth_HareketGrupKodu1='',sth_HareketGrupKodu2='',sth_HareketGrupKodu3='',sth_Olcu1=0,sth_Olcu2=0,sth_Olcu3=0,sth_Olcu4=0,sth_Olcu5=0,sth_FormulMiktar=0,sth_eirs_senaryo=0,sth_eirs_tipi=0,sth_teslim_tarihi=@sth_tarih,sth_matbu_fl=0,sth_satis_fiyat_doviz_cinsi=0,sth_satis_fiyat_doviz_kuru=0,sth_lastup_user=1,sth_FormulMiktarNo=0,sth_eticaret_kanal_kodu='' Where sth_Guid=@sth_Guid declare @sip_evrakno_seri nvarchar(25) declare @sip_evrakno_sira int if @sip_Guid<>'00000000-0000-0000-0000-000000000000' BEGIN SELECT @sip_evrakno_seri=sip_evrakno_seri from SIPARISLER where sip_Guid=@sip_Guid SELECT @sip_evrakno_sira=sip_evrakno_sira from SIPARISLER where sip_Guid=@sip_Guid END if @sip_Guid<>'00000000-0000-0000-0000-000000000000' BEGIN declare @sipEvrakAciklamalariAktarildimi int SELECT @sipEvrakAciklamalariAktarildimi=COUNT(*) FROM EVRAK_ACIKLAMALARI WHERE egk_evr_seri=@sth_evrakno_seri and egk_evr_sira=@sth_evrakno_sira AND egk_hareket_tip=1 and egk_evr_tip=1 and egk_dosyano=16 IF @sipEvrakAciklamalariAktarildimi=0 BEGIN --EVRAK ACIKLAMALARI AKTARIMI INSERT INTO [dbo].[EVRAK_ACIKLAMALARI] ([egk_Guid] ,[egk_DBCno] ,[egk_SpecRECno] ,[egk_iptal] ,[egk_fileid] ,[egk_hidden] ,[egk_kilitli] ,[egk_degisti] ,[egk_checksum] ,[egk_create_user] ,[egk_create_date] ,[egk_lastup_user] ,[egk_lastup_date] ,[egk_special1] ,[egk_special2] ,[egk_special3] ,[egk_dosyano] ,[egk_hareket_tip] ,[egk_evr_tip] ,[egk_evr_seri] ,[egk_evr_sira] ,[egk_evr_ustkod] ,[egk_evr_doksayisi] ,[egk_evracik1] ,[egk_evracik2] ,[egk_evracik3] ,[egk_evracik4] ,[egk_evracik5] ,[egk_evracik6] ,[egk_evracik7] ,[egk_evracik8] ,[egk_evracik9] ,[egk_evracik10] ,[egk_sipgenkarorani] ,[egk_kargokodu] ,[egk_kargono] ,[egk_tesaltarihi] ,[egk_tesalkisi] ,[egk_prevwiewsayisi] ,[egk_emailsayisi] ,[egk_Evrakopno_verildi_fl]) SELECT NEWID() ,egk_DBCno ,egk_SpecRECno ,egk_iptal ,egk_fileid ,egk_hidden ,egk_kilitli ,egk_degisti ,egk_checksum ,egk_create_user ,egk_create_date ,egk_lastup_user ,egk_lastup_date ,egk_special1 ,egk_special2 ,egk_special3 ,16--egk_dosyano ,1--egk_hareket_tip ,1--egk_evr_tip ,@sth_evrakno_seri --egk_evr_seri ,@sth_evrakno_sira --egk_evr_sira ,egk_evr_ustkod ,egk_evr_doksayisi ,egk_evracik1 ,egk_evracik2 ,egk_evracik3 ,egk_evracik4 ,egk_evracik5 ,egk_evracik6 ,egk_evracik7 ,egk_evracik8 ,egk_evracik9 ,egk_evracik10 ,egk_sipgenkarorani ,egk_kargokodu ,egk_kargono ,egk_tesaltarihi ,egk_tesalkisi ,egk_prevwiewsayisi ,egk_emailsayisi ,egk_Evrakopno_verildi_fl from EVRAK_ACIKLAMALARI where egk_evr_seri=@sip_evrakno_seri and egk_evr_sira=@sip_evrakno_sira and egk_hareket_tip=0 and egk_evr_tip=0 and egk_dosyano=21 --EVRAK ACIKLAMALARI AKTARIMI BITTI END END SET @KeyFieldValue=@sth_Guid SET @LineNumber=@sth_satirno SELECT @KeyFieldValue AS KeyFieldValue,@sth_satirno as LineNumber END GO /****** Object: StoredProcedure [dbo].[sp_MBT_SaveDispatchAllTypesWithDATNakliye] Script Date: 10.07.2023 12:16:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_MBT_SaveDispatchAllTypesWithDATNakliye] ( @sth_belgeno nvarchar(16), @sth_evrakno_seri nvarchar(8), @sth_evrakno_sira int, @sth_tarih datetime, @sth_satirno int,--SIFIRDAN ARTARAK GIDIYOR MIKRODA @sth_belge_tarih datetime, @sth_plasiyer_kodu nvarchar(25), @sth_cari_kodu nvarchar(25), @sth_stok_kod nvarchar(25), @sth_b_fiyat float, @sth_miktar float, @sth_birim_pntr tinyint,--BIRIM FIYAT @sth_tutar float,--ISKONTOSUZ ARA TOPLAM @sth_iskonto1 float,--ISKONTO 1 TOPLAMI @sth_iskonto2 float,--ISKONTO 2 TOPLAMI @sth_iskonto3 float,--ISKONTO 3 TOPLAMI @sth_iskonto4 float,--ISKONTO 4 TOPLAMI @sth_iskonto5 float,--ISKONTO 5 TOPLAMI @sth_iskonto6 float,--ISKONTO 6 TOPLAMI @sth_vergi_pntr tinyint,-- 0 8 18 @sth_vergi float,-- ISKONTO DUSULDUKTEN SONRAKI KDV TOPLAMI @sth_aciklama nvarchar(50), @sth_aciklama2 nvarchar(50), @sth_giris_depo_no int,--ZORUNLU GELMESI LAZIM @sth_cikis_depo_no int,--ZORUNLU GELMESI LAZIM @sth_doviz_kodu nvarchar(5),--TL USD EUR @sth_stok_doviz_cinsi int,--0 tl 1 usd 2 eur @sth_stok_sormerk nvarchar(25),-- YOKSA BOS GONDERILECEK @sth_adres_no int, @sip_Guid nvarchar(50),--SIPARIS @ssip_Guid nvarchar(50),--DEPOLAR ARASI SIPARIS @sth_parti_kodu nvarchar(25), @sth_lot_no int, @sth_disticaret_turu int, @ChHar_SeriNo nvarchar(25), @MbtTakipNoAna nvarchar(50), @MbtTakipNoDetay nvarchar(50), @sth_tip int, @sth_cins int, @sth_evraktip int, @sth_normal_iade int, @sth_nakliyedeposu int, @sth_fileid int, @sth_nakliyedurumu int, @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT --İlk once Carihareket Kayıt edilmeli Çünkü ID si stok hareketlerine yazılacak --yada en son update edilebilir. --ben ikinisini tercih edecegim. --07 12 2020 8 ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- gelen fis Numarasına göre evrak aktaracagız.... --sth_tip Tinyint Hareket Tipi 0:Giriş 1:Çıkış 2:Depo Transfer /* --sth_cins Tinyint Hareket Cinsi 0:Toptan 1:Perakende 2:Dış Ticaret 3:Stok Virman 4:Fire 5:Sarf 6:Transfer 7:Üretim 8:Fason 9:Değer Farkı 10:Sayım 11:Stok Açılış 12:İthalat-İhracat 13:Hal 14:Müstahsil 15:Müstahsil Değer Farkı 14:Kabzımal 15:Gider Pusulası **/ -- sth_normal_iade Tinyint Normal/Iade? 0:Normal 1:İade /* sth_evraktip Tinyint Evrak Tipi 0:Depo Çıkış Fişi 1:Çıkış İrsaliyesi 2:Depo Transfer Fişi 3:Giriş Faturası 4:Çıkış Faturası 5:Stoklara İthalat Masraf Yansıtma Dekontu 6:Stok Virman Fişi 7:Üretim Fişi 8:İlave Enflasyon Maliyet Fişi 9:Stoklara İlave Maliyet Yedirme Fişi 10:Antrepolardan Mal Millileştirme Fişi 11:Antrepolar Arası Transfer Fişi 12:Depo Giriş Fişi 13:Giriş İrsaliyesi 14:Fason Giriş Çıkış Fişi 15:Depolar Arası Satış Fişi 16:Stok Gider Pusulası Fişi 17:Depolar Arası Nakliye Fişi **/ declare @subeliCalismaVarmi int declare @sth_subeno int SET @sth_subeno=0 SELECT @subeliCalismaVarmi=COUNT(*) FROM MBTSISTEMPARAMETRELERI WHERE PARAMETREADI='SUBELICALISMA' AND DEGER='EVET' if @subeliCalismaVarmi=1 BEGIN select @sth_subeno=@sth_cikis_depo_no END else BEGIN set @sth_subeno=0 END DECLARE @sth_doviz_cinsi tinyint DECLARE @sth_doviz_kuru float DECLARE @sth_stok_doviz_kuru float DECLARE @sorumluluk_merkezi nvarchar(25) /* boş olamaz @sth_plasiyer_kodu='', @sth_cari_kodu ='', @sth_stok_sormerk='', @ChHar_SeriNo ='', **/ set @sorumluluk_merkezi='' SET @sth_stok_sormerk ='' IF @sth_plasiyer_kodu IS NULL SET @sth_plasiyer_kodu='' IF @sth_cari_kodu IS NULL SET @sth_cari_kodu='' IF @ChHar_SeriNo IS NULL SET @ChHar_SeriNo='' if @sip_Guid<>'0' BEGIN SELECT @sorumluluk_merkezi=sip_cari_sormerk FROM SIPARISLER WHERE sip_Guid=@sip_Guid END -- if @sip_Guid<>'0' BEGIN if @sth_stok_sormerk='' set @sth_stok_sormerk=@sorumluluk_merkezi END -- SELECT @sth_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu --sth_doviz_cinsi=sth_stok_doviz_cinsi ne eşitlenecek ve o kura göre kur alınacak. set @sth_stok_doviz_cinsi=@sth_doviz_cinsi DECLARE @cari_KurHesapSekli tinyint SELECT @cari_KurHesapSekli=cari_KurHesapSekli FROM CARI_HESAPLAR WHERE cari_kod=@sth_cari_kodu if @cari_KurHesapSekli =0 set @cari_KurHesapSekli=2 DECLARE @sth_alt_doviz_kuru float DECLARE @sth_har_doviz_kuru float -- evrak doviz cinsinin doviz kuru DECLARE @sth_vergi_pntr_yeni int DECLARE @TESLIMMIKTAR FLOAT DECLARE @TESLIMMIKTAR2 FLOAT DECLARE @sth_isk_mas1 int DECLARE @sth_isk_mas2 int DECLARE @sth_isk_mas3 int DECLARE @sth_isk_mas4 int DECLARE @sth_isk_mas5 int DECLARE @sth_isk_mas6 int SELECT @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,@cari_KurHesapSekli) SELECT @sth_har_doviz_kuru=dbo.fn_KurBul(GetDate(),@sth_doviz_cinsi,@cari_KurHesapSekli) SELECT @sth_stok_doviz_kuru=dbo.fn_KurBul(GetDate(),@sth_stok_doviz_cinsi,@cari_KurHesapSekli) --CARIYE TANIMLI KUR VARMI /* DECLARE @cariyeTanimliOzelKurVarmi FLOAT SET @cariyeTanimliOzelKurVarmi=0 if @sth_doviz_cinsi='USD' BEGIN SELECT @cariyeTanimliOzelKurVarmi=ISNULL(USDKURU,0) FROM MBTDOVIZKURLARI WHERE MUSTERIKODU=@sth_cari_kodu and YIL=YEAR(GETDATE()) AND AY=MONTH(GETDATE()) END if @sth_doviz_cinsi='EUR' BEGIN SELECT @cariyeTanimliOzelKurVarmi=ISNULL(EURKURU,0) FROM MBTDOVIZKURLARI WHERE MUSTERIKODU=@sth_cari_kodu and YIL=YEAR(GETDATE()) AND AY=MONTH(GETDATE()) END if @cariyeTanimliOzelKurVarmi>0 BEGIN SET @sth_alt_doviz_kuru =@cariyeTanimliOzelKurVarmi SET @sth_har_doviz_kuru =@cariyeTanimliOzelKurVarmi SET @sth_stok_doviz_kuru =@cariyeTanimliOzelKurVarmi END */ --SELECT @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,2) SELECT TOP 1 @sth_vergi_pntr_yeni=T1.VERGIPNTR FROM ( SELECT 0 AS VERGIPNTR,dbo.fn_VergiIsim(0) AS KDVADI,dbo.fn_VergiYuzde(0) AS KDVORANI UNION SELECT 1 AS VERGIPNTR,dbo.fn_VergiIsim(1) AS KDVADI,dbo.fn_VergiYuzde(1) AS KDVORANI UNION SELECT 2 AS VERGIPNTR,dbo.fn_VergiIsim(2) AS KDVADI,dbo.fn_VergiYuzde(2) AS KDVORANI UNION SELECT 3 AS VERGIPNTR,dbo.fn_VergiIsim(3) AS KDVADI,dbo.fn_VergiYuzde(3) AS KDVORANI UNION SELECT 4 AS VERGIPNTR,dbo.fn_VergiIsim(4) AS KDVADI,dbo.fn_VergiYuzde(4) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 7 AS VERGIPNTR,dbo.fn_VergiIsim(7) AS KDVADI,dbo.fn_VergiYuzde(7) AS KDVORANI UNION SELECT 8 AS VERGIPNTR,dbo.fn_VergiIsim(8) AS KDVADI,dbo.fn_VergiYuzde(8) AS KDVORANI UNION SELECT 9 AS VERGIPNTR,dbo.fn_VergiIsim(9) AS KDVADI,dbo.fn_VergiYuzde(9) AS KDVORANI UNION SELECT 10 AS VERGIPNTR,dbo.fn_VergiIsim(10) AS KDVADI,dbo.fn_VergiYuzde(10) AS KDVORANI UNION SELECT 11 AS VERGIPNTR,dbo.fn_VergiIsim(11) AS KDVADI,dbo.fn_VergiYuzde(11) AS KDVORANI UNION SELECT 12 AS VERGIPNTR,dbo.fn_VergiIsim(12) AS KDVADI,dbo.fn_VergiYuzde(12) AS KDVORANI UNION SELECT 13 AS VERGIPNTR,dbo.fn_VergiIsim(13) AS KDVADI,dbo.fn_VergiYuzde(13) AS KDVORANI UNION SELECT 14 AS VERGIPNTR,dbo.fn_VergiIsim(14) AS KDVADI,dbo.fn_VergiYuzde(14) AS KDVORANI UNION SELECT 15 AS VERGIPNTR,dbo.fn_VergiIsim(15) AS KDVADI,dbo.fn_VergiYuzde(15) AS KDVORANI UNION SELECT 16 AS VERGIPNTR,dbo.fn_VergiIsim(16) AS KDVADI,dbo.fn_VergiYuzde(16) AS KDVORANI UNION SELECT 17 AS VERGIPNTR,dbo.fn_VergiIsim(17) AS KDVADI,dbo.fn_VergiYuzde(17) AS KDVORANI UNION SELECT 18 AS VERGIPNTR,dbo.fn_VergiIsim(18) AS KDVADI,dbo.fn_VergiYuzde(18) AS KDVORANI UNION SELECT 19 AS VERGIPNTR,dbo.fn_VergiIsim(19) AS KDVADI,dbo.fn_VergiYuzde(19) AS KDVORANI UNION SELECT 20 AS VERGIPNTR,dbo.fn_VergiIsim(20) AS KDVADI,dbo.fn_VergiYuzde(20) AS KDVORANI ) T1 WHERE T1.KDVORANI=@sth_vergi_pntr ORDER BY VERGIPNTR ASC SET @sth_vergi_pntr=@sth_vergi_pntr_yeni SET @sth_isk_mas1=0 SET @sth_isk_mas2=1 SET @sth_isk_mas3=1 SET @sth_isk_mas4=1 SET @sth_isk_mas5=1 SET @sth_isk_mas6=1 if @sth_iskonto1>0 set @sth_isk_mas1=0 if @sth_iskonto2>0 set @sth_isk_mas2=0 if @sth_iskonto3>0 set @sth_isk_mas3=0 if @sth_iskonto4>0 set @sth_isk_mas4=0 if @sth_iskonto5>0 set @sth_isk_mas5=0 if @sth_iskonto6>0 set @sth_isk_mas6=0 if @sip_Guid='0' set @sip_Guid='00000000-0000-0000-0000-000000000000' if @ssip_Guid='0' set @ssip_Guid='00000000-0000-0000-0000-000000000000' -- Insert statements for procedure here INSERT INTO [dbo].[STOK_HAREKETLERI] ([sth_Guid],[sth_DBCno] ,[sth_SpecRECno] ,[sth_iptal] ,[sth_fileid] ,[sth_hidden] ,[sth_kilitli] ,[sth_degisti] ,[sth_checksum] ,[sth_create_user] ,[sth_create_date] ,[sth_lastup_user] ,[sth_lastup_date] ,[sth_special1] ,[sth_special2] ,[sth_special3] ,[sth_firmano] ,[sth_subeno] ,[sth_tarih] ,[sth_tip] ,[sth_cins] ,[sth_normal_iade] ,[sth_evraktip] ,[sth_evrakno_seri] ,[sth_evrakno_sira] ,[sth_satirno] ,[sth_belge_no] ,[sth_belge_tarih] ,[sth_stok_kod] ,[sth_isk_mas1] ,[sth_isk_mas2] ,[sth_isk_mas3] ,[sth_isk_mas4] ,[sth_isk_mas5] ,[sth_isk_mas6] ,[sth_isk_mas7] ,[sth_isk_mas8] ,[sth_isk_mas9] ,[sth_isk_mas10] ,[sth_sat_iskmas1] ,[sth_sat_iskmas2] ,[sth_sat_iskmas3] ,[sth_sat_iskmas4] ,[sth_sat_iskmas5] ,[sth_sat_iskmas6] ,[sth_sat_iskmas7] ,[sth_sat_iskmas8] ,[sth_sat_iskmas9] ,[sth_sat_iskmas10] ,[sth_pos_satis] ,[sth_promosyon_fl] ,[sth_cari_cinsi] ,[sth_cari_kodu] ,[sth_cari_grup_no] ,[sth_isemri_gider_kodu] ,[sth_plasiyer_kodu] ,[sth_har_doviz_cinsi] ,[sth_har_doviz_kuru] ,[sth_alt_doviz_kuru] ,[sth_stok_doviz_cinsi] ,[sth_stok_doviz_kuru] ,[sth_miktar] ,[sth_miktar2] ,[sth_birim_pntr] ,[sth_tutar] ,[sth_iskonto1] ,[sth_iskonto2] ,[sth_iskonto3] ,[sth_iskonto4] ,[sth_iskonto5] ,[sth_iskonto6] ,[sth_masraf1] ,[sth_masraf2] ,[sth_masraf3] ,[sth_masraf4] ,[sth_vergi_pntr] ,[sth_vergi] ,[sth_masraf_vergi_pntr] ,[sth_masraf_vergi] ,[sth_netagirlik] ,[sth_odeme_op] ,[sth_aciklama] ,[sth_sip_uid] ,[sth_fat_uid] ,[sth_giris_depo_no] ,[sth_cikis_depo_no] ,[sth_malkbl_sevk_tarihi] ,[sth_cari_srm_merkezi] ,[sth_stok_srm_merkezi] ,[sth_fis_tarihi] ,[sth_fis_sirano] ,[sth_vergisiz_fl] ,[sth_maliyet_ana] ,[sth_maliyet_alternatif] ,[sth_maliyet_orjinal] ,[sth_adres_no] ,[sth_parti_kodu] ,[sth_lot_no] ,[sth_kons_uid] ,[sth_proje_kodu] ,[sth_exim_kodu] ,[sth_otv_pntr] ,[sth_otv_vergi] ,[sth_brutagirlik] ,[sth_disticaret_turu] ,[sth_otvtutari] ,[sth_otvvergisiz_fl] ,[sth_oiv_pntr] ,[sth_oiv_vergi] ,[sth_oivvergisiz_fl] ,[sth_fiyat_liste_no] ,[sth_oivtutari] ,[sth_Tevkifat_turu] ,[sth_nakliyedeposu] ,[sth_nakliyedurumu] ,[sth_yetkili_uid] ,[sth_taxfree_fl] ,sth_ilave_edilecek_kdv ,sth_ismerkezi_kodu ,sth_HareketGrupKodu1,sth_HareketGrupKodu2,sth_HareketGrupKodu3,sth_Olcu1,sth_Olcu2,sth_Olcu3,sth_Olcu4,sth_Olcu5,sth_FormulMiktar,sth_eirs_senaryo,sth_eirs_tipi,sth_teslim_tarihi,sth_matbu_fl,sth_satis_fiyat_doviz_cinsi,sth_satis_fiyat_doviz_kuru) VALUES (NEWID(),0-- ,0-- ,0-- ,@sth_fileid-- ,0-- ,0-- ,0-- ,0-- ,1-- ,getdate() -- ,1-- ,getdate()-- ,'mbt'-- ,''-- ,''-- ,0-- ,@sth_subeno-- ,@sth_tarih -- ,@sth_tip-- ,@sth_cins-- ,@sth_normal_iade-- ,@sth_evraktip-- ,@sth_evrakno_seri -- ,@sth_evrakno_sira -- ,@sth_satirno-- ,@sth_belgeno-- ,@sth_tarih-- ,@sth_stok_kod-- ,@sth_isk_mas1-- ,@sth_isk_mas2-- ,@sth_isk_mas3-- ,@sth_isk_mas4-- ,@sth_isk_mas5-- ,@sth_isk_mas6-- ,1-- ,1-- ,1-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@sth_cari_kodu-- ,0-- ,''-- ,@sth_plasiyer_kodu -- ,@sth_doviz_cinsi -- ,@sth_har_doviz_kuru-- ,@sth_alt_doviz_kuru-- ,@sth_stok_doviz_cinsi-- ,@sth_stok_doviz_kuru-- ,@sth_miktar-- ,@sth_miktar-- ,@sth_birim_pntr-- ,@sth_tutar-- ,@sth_iskonto1-- ,@sth_iskonto2-- ,@sth_iskonto3-- ,@sth_iskonto4-- ,@sth_iskonto5-- ,@sth_iskonto6-- ,0-- ,0-- ,0-- ,0-- ,@sth_vergi_pntr-- ,@sth_vergi -- ,0-- ,0-- ,0-- ,0-- ,@sth_aciklama -- ,@sip_Guid-- ,'00000000-0000-0000-0000-000000000000'-- ,@sth_giris_depo_no -- ,@sth_cikis_depo_no-- ,@sth_tarih-- ,@sth_stok_sormerk-- ,@sth_stok_sormerk-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_adres_no-- ,@sth_parti_kodu -- ,@sth_lot_no -- ,'00000000-0000-0000-0000-000000000000'-- ,''-- ,''-- ,0-- ,0-- ,0-- ,@sth_disticaret_turu -- ,0-- ,0-- ,0-- ,0-- ,0-- ,1-- ,0-- ,0-- ,@sth_nakliyedeposu -- ,@sth_nakliyedurumu -- ,'00000000-0000-0000-0000-000000000000'-- ,0-- ,0--sth_ilave_edilecek_kdv ,0--sth_ismerkezi_kodu ,'' --sth_HareketGrupKodu1 ,'' --sth_HareketGrupKodu2 ,'' --sth_HareketGrupKodu3 ,0--sth_Olcu1 ,0--sth_Olcu2 ,0--sth_Olcu3 ,0--sth_Olcu4 ,0--sth_Olcu5 ,0--sth_FormulMiktar ,0--sth_eirs_senaryo ,0 --sth_eirs_tipi ,@sth_tarih -- sth_teslim_tarihi ,0 --sth_matbu_fl ,0 --sth_satis_fiyat_doviz_cinsi ,0 -- sth_satis_fiyat_doviz_kuru ) DECLARE @sth_Guid nvarchar(50) DECLARE @sth_RECno int SELECT @sth_Guid=sth_Guid FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_satirno= @sth_satirno and sth_tip=@sth_tip and sth_cins= @sth_cins and sth_evraktip=@sth_evraktip and sth_normal_iade= @sth_normal_iade SET @KeyFieldValue=@sth_Guid SET @LineNumber=@sth_satirno SELECT @KeyFieldValue AS KeyFieldValue,@sth_satirno as LineNumber END GO /****** Object: StoredProcedure [dbo].[sp_MBT_SaveDispatchAllTypesWithDATNakliyeV2] Script Date: 10.07.2023 12:16:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_MBT_SaveDispatchAllTypesWithDATNakliyeV2] ( @sth_belgeno nvarchar(16), @sth_evrakno_seri nvarchar(8), @sth_evrakno_sira int, @sth_tarih datetime, @sth_satirno int,--SIFIRDAN ARTARAK GIDIYOR MIKRODA @sth_belge_tarih datetime, @sth_plasiyer_kodu nvarchar(25), @sth_cari_kodu nvarchar(25), @sth_stok_kod nvarchar(25), @sth_b_fiyat float, @sth_miktar float, @sth_birim_pntr tinyint,--BIRIM FIYAT @sth_tutar float,--ISKONTOSUZ ARA TOPLAM @sth_iskonto1 float,--ISKONTO 1 TOPLAMI @sth_iskonto2 float,--ISKONTO 2 TOPLAMI @sth_iskonto3 float,--ISKONTO 3 TOPLAMI @sth_iskonto4 float,--ISKONTO 4 TOPLAMI @sth_iskonto5 float,--ISKONTO 5 TOPLAMI @sth_iskonto6 float,--ISKONTO 6 TOPLAMI @sth_vergi_pntr tinyint,-- 0 8 18 @sth_vergi float,-- ISKONTO DUSULDUKTEN SONRAKI KDV TOPLAMI @sth_aciklama nvarchar(50), @sth_aciklama2 nvarchar(50), @sth_giris_depo_no int,--ZORUNLU GELMESI LAZIM @sth_cikis_depo_no int,--ZORUNLU GELMESI LAZIM @sth_doviz_kodu nvarchar(5),--TL USD EUR @sth_stok_doviz_cinsi int,--0 tl 1 usd 2 eur @sth_stok_sormerk nvarchar(25),-- YOKSA BOS GONDERILECEK @sth_adres_no int, @sip_Guid nvarchar(50),--SIPARIS @ssip_Guid nvarchar(50),--DEPOLAR ARASI SIPARIS @sth_parti_kodu nvarchar(25), @sth_lot_no int, @sth_disticaret_turu int, @ChHar_SeriNo nvarchar(25), @MbtTakipNoAna nvarchar(50), @MbtTakipNoDetay nvarchar(50), @sth_tip int, @sth_cins int, @sth_evraktip int, @sth_normal_iade int, @sth_nakliyedeposu int, @sth_fileid int, @sth_nakliyedurumu int, @sth_create_user int, @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT --İlk once Carihareket Kayıt edilmeli Çünkü ID si stok hareketlerine yazılacak --yada en son update edilebilir. --ben ikinisini tercih edecegim. --07 12 2020 8 ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- gelen fis Numarasına göre evrak aktaracagız.... --sth_tip Tinyint Hareket Tipi 0:Giriş 1:Çıkış 2:Depo Transfer /* --sth_cins Tinyint Hareket Cinsi 0:Toptan 1:Perakende 2:Dış Ticaret 3:Stok Virman 4:Fire 5:Sarf 6:Transfer 7:Üretim 8:Fason 9:Değer Farkı 10:Sayım 11:Stok Açılış 12:İthalat-İhracat 13:Hal 14:Müstahsil 15:Müstahsil Değer Farkı 14:Kabzımal 15:Gider Pusulası **/ -- sth_normal_iade Tinyint Normal/Iade? 0:Normal 1:İade /* sth_evraktip Tinyint Evrak Tipi 0:Depo Çıkış Fişi 1:Çıkış İrsaliyesi 2:Depo Transfer Fişi 3:Giriş Faturası 4:Çıkış Faturası 5:Stoklara İthalat Masraf Yansıtma Dekontu 6:Stok Virman Fişi 7:Üretim Fişi 8:İlave Enflasyon Maliyet Fişi 9:Stoklara İlave Maliyet Yedirme Fişi 10:Antrepolardan Mal Millileştirme Fişi 11:Antrepolar Arası Transfer Fişi 12:Depo Giriş Fişi 13:Giriş İrsaliyesi 14:Fason Giriş Çıkış Fişi 15:Depolar Arası Satış Fişi 16:Stok Gider Pusulası Fişi 17:Depolar Arası Nakliye Fişi **/ declare @subeliCalismaVarmi int declare @sth_subeno int SET @sth_subeno=0 SELECT @subeliCalismaVarmi=COUNT(*) FROM MBTSISTEMPARAMETRELERI WHERE PARAMETREADI='SUBELICALISMA' AND DEGER='EVET' if @subeliCalismaVarmi=1 BEGIN select @sth_subeno=@sth_cikis_depo_no END else BEGIN set @sth_subeno=0 END DECLARE @sth_doviz_cinsi tinyint DECLARE @sth_doviz_kuru float DECLARE @sth_stok_doviz_kuru float DECLARE @sorumluluk_merkezi nvarchar(25) /* boş olamaz @sth_plasiyer_kodu='', @sth_cari_kodu ='', @sth_stok_sormerk='', @ChHar_SeriNo ='', **/ set @sorumluluk_merkezi='' SET @sth_stok_sormerk ='' IF @sth_plasiyer_kodu IS NULL SET @sth_plasiyer_kodu='' IF @sth_cari_kodu IS NULL SET @sth_cari_kodu='' IF @ChHar_SeriNo IS NULL SET @ChHar_SeriNo='' if @sip_Guid<>'0' BEGIN SELECT @sorumluluk_merkezi=sip_cari_sormerk FROM SIPARISLER WHERE sip_Guid=@sip_Guid END -- if @sip_Guid<>'0' BEGIN if @sth_stok_sormerk='' set @sth_stok_sormerk=@sorumluluk_merkezi END -- SELECT @sth_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu --sth_doviz_cinsi=sth_stok_doviz_cinsi ne eşitlenecek ve o kura göre kur alınacak. set @sth_stok_doviz_cinsi=@sth_doviz_cinsi DECLARE @cari_KurHesapSekli tinyint SELECT @cari_KurHesapSekli=cari_KurHesapSekli FROM CARI_HESAPLAR WHERE cari_kod=@sth_cari_kodu if @cari_KurHesapSekli =0 set @cari_KurHesapSekli=2 DECLARE @sth_alt_doviz_kuru float DECLARE @sth_har_doviz_kuru float -- evrak doviz cinsinin doviz kuru DECLARE @sth_vergi_pntr_yeni int DECLARE @TESLIMMIKTAR FLOAT DECLARE @TESLIMMIKTAR2 FLOAT DECLARE @sth_isk_mas1 int DECLARE @sth_isk_mas2 int DECLARE @sth_isk_mas3 int DECLARE @sth_isk_mas4 int DECLARE @sth_isk_mas5 int DECLARE @sth_isk_mas6 int SELECT @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,@cari_KurHesapSekli) SELECT @sth_har_doviz_kuru=dbo.fn_KurBul(GetDate(),@sth_doviz_cinsi,@cari_KurHesapSekli) SELECT @sth_stok_doviz_kuru=dbo.fn_KurBul(GetDate(),@sth_stok_doviz_cinsi,@cari_KurHesapSekli) SELECT TOP 1 @sth_vergi_pntr_yeni=T1.VERGIPNTR FROM ( SELECT 0 AS VERGIPNTR,dbo.fn_VergiIsim(0) AS KDVADI,dbo.fn_VergiYuzde(0) AS KDVORANI UNION SELECT 1 AS VERGIPNTR,dbo.fn_VergiIsim(1) AS KDVADI,dbo.fn_VergiYuzde(1) AS KDVORANI UNION SELECT 2 AS VERGIPNTR,dbo.fn_VergiIsim(2) AS KDVADI,dbo.fn_VergiYuzde(2) AS KDVORANI UNION SELECT 3 AS VERGIPNTR,dbo.fn_VergiIsim(3) AS KDVADI,dbo.fn_VergiYuzde(3) AS KDVORANI UNION SELECT 4 AS VERGIPNTR,dbo.fn_VergiIsim(4) AS KDVADI,dbo.fn_VergiYuzde(4) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 7 AS VERGIPNTR,dbo.fn_VergiIsim(7) AS KDVADI,dbo.fn_VergiYuzde(7) AS KDVORANI UNION SELECT 8 AS VERGIPNTR,dbo.fn_VergiIsim(8) AS KDVADI,dbo.fn_VergiYuzde(8) AS KDVORANI UNION SELECT 9 AS VERGIPNTR,dbo.fn_VergiIsim(9) AS KDVADI,dbo.fn_VergiYuzde(9) AS KDVORANI UNION SELECT 10 AS VERGIPNTR,dbo.fn_VergiIsim(10) AS KDVADI,dbo.fn_VergiYuzde(10) AS KDVORANI UNION SELECT 11 AS VERGIPNTR,dbo.fn_VergiIsim(11) AS KDVADI,dbo.fn_VergiYuzde(11) AS KDVORANI UNION SELECT 12 AS VERGIPNTR,dbo.fn_VergiIsim(12) AS KDVADI,dbo.fn_VergiYuzde(12) AS KDVORANI UNION SELECT 13 AS VERGIPNTR,dbo.fn_VergiIsim(13) AS KDVADI,dbo.fn_VergiYuzde(13) AS KDVORANI UNION SELECT 14 AS VERGIPNTR,dbo.fn_VergiIsim(14) AS KDVADI,dbo.fn_VergiYuzde(14) AS KDVORANI UNION SELECT 15 AS VERGIPNTR,dbo.fn_VergiIsim(15) AS KDVADI,dbo.fn_VergiYuzde(15) AS KDVORANI UNION SELECT 16 AS VERGIPNTR,dbo.fn_VergiIsim(16) AS KDVADI,dbo.fn_VergiYuzde(16) AS KDVORANI UNION SELECT 17 AS VERGIPNTR,dbo.fn_VergiIsim(17) AS KDVADI,dbo.fn_VergiYuzde(17) AS KDVORANI UNION SELECT 18 AS VERGIPNTR,dbo.fn_VergiIsim(18) AS KDVADI,dbo.fn_VergiYuzde(18) AS KDVORANI UNION SELECT 19 AS VERGIPNTR,dbo.fn_VergiIsim(19) AS KDVADI,dbo.fn_VergiYuzde(19) AS KDVORANI UNION SELECT 20 AS VERGIPNTR,dbo.fn_VergiIsim(20) AS KDVADI,dbo.fn_VergiYuzde(20) AS KDVORANI ) T1 WHERE T1.KDVORANI=@sth_vergi_pntr ORDER BY VERGIPNTR ASC SET @sth_vergi_pntr=@sth_vergi_pntr_yeni SET @sth_isk_mas1=0 SET @sth_isk_mas2=1 SET @sth_isk_mas3=1 SET @sth_isk_mas4=1 SET @sth_isk_mas5=1 SET @sth_isk_mas6=1 if @sth_iskonto1>0 set @sth_isk_mas1=0 if @sth_iskonto2>0 set @sth_isk_mas2=0 if @sth_iskonto3>0 set @sth_isk_mas3=0 if @sth_iskonto4>0 set @sth_isk_mas4=0 if @sth_iskonto5>0 set @sth_isk_mas5=0 if @sth_iskonto6>0 set @sth_isk_mas6=0 if @sip_Guid='0' set @sip_Guid='00000000-0000-0000-0000-000000000000' if @ssip_Guid='0' set @ssip_Guid='00000000-0000-0000-0000-000000000000' -- Insert statements for procedure here INSERT INTO [dbo].[STOK_HAREKETLERI] ([sth_DBCno] ,[sth_SpecRECno] ,[sth_iptal] ,[sth_fileid] ,[sth_hidden] ,[sth_kilitli] ,[sth_degisti] ,[sth_checksum] ,[sth_create_user] ,[sth_create_date] ,[sth_lastup_user] ,[sth_lastup_date] ,[sth_special1] ,[sth_special2] ,[sth_special3] ,[sth_firmano] ,[sth_subeno] ,[sth_tarih] ,[sth_tip] ,[sth_cins] ,[sth_normal_iade] ,[sth_evraktip] ,[sth_evrakno_seri] ,[sth_evrakno_sira] ,[sth_satirno] ,[sth_belge_no] ,[sth_belge_tarih] ,[sth_stok_kod] ,[sth_isk_mas1] ,[sth_isk_mas2] ,[sth_isk_mas3] ,[sth_isk_mas4] ,[sth_isk_mas5] ,[sth_isk_mas6] ,[sth_isk_mas7] ,[sth_isk_mas8] ,[sth_isk_mas9] ,[sth_isk_mas10] ,[sth_sat_iskmas1] ,[sth_sat_iskmas2] ,[sth_sat_iskmas3] ,[sth_sat_iskmas4] ,[sth_sat_iskmas5] ,[sth_sat_iskmas6] ,[sth_sat_iskmas7] ,[sth_sat_iskmas8] ,[sth_sat_iskmas9] ,[sth_sat_iskmas10] ,[sth_pos_satis] ,[sth_promosyon_fl] ,[sth_cari_cinsi] ,[sth_cari_kodu] ,[sth_cari_grup_no] ,[sth_isemri_gider_kodu] ,[sth_plasiyer_kodu] ,[sth_har_doviz_cinsi] ,[sth_har_doviz_kuru] ,[sth_alt_doviz_kuru] ,[sth_stok_doviz_cinsi] ,[sth_stok_doviz_kuru] ,[sth_miktar] ,[sth_miktar2] ,[sth_birim_pntr] ,[sth_tutar] ,[sth_iskonto1] ,[sth_iskonto2] ,[sth_iskonto3] ,[sth_iskonto4] ,[sth_iskonto5] ,[sth_iskonto6] ,[sth_masraf1] ,[sth_masraf2] ,[sth_masraf3] ,[sth_masraf4] ,[sth_vergi_pntr] ,[sth_vergi] ,[sth_masraf_vergi_pntr] ,[sth_masraf_vergi] ,[sth_netagirlik] ,[sth_odeme_op] ,[sth_aciklama] ,[sth_sip_uid] ,[sth_fat_uid] ,[sth_giris_depo_no] ,[sth_cikis_depo_no] ,[sth_malkbl_sevk_tarihi] ,[sth_cari_srm_merkezi] ,[sth_stok_srm_merkezi] ,[sth_fis_tarihi] ,[sth_fis_sirano] ,[sth_vergisiz_fl] ,[sth_maliyet_ana] ,[sth_maliyet_alternatif] ,[sth_maliyet_orjinal] ,[sth_adres_no] ,[sth_parti_kodu] ,[sth_lot_no] ,[sth_kons_uid] ,[sth_proje_kodu] ,[sth_exim_kodu] ,[sth_otv_pntr] ,[sth_otv_vergi] ,[sth_brutagirlik] ,[sth_disticaret_turu] ,[sth_otvtutari] ,[sth_otvvergisiz_fl] ,[sth_oiv_pntr] ,[sth_oiv_vergi] ,[sth_oivvergisiz_fl] ,[sth_fiyat_liste_no] ,[sth_oivtutari] ,[sth_Tevkifat_turu] ,[sth_nakliyedeposu] ,[sth_nakliyedurumu] ,[sth_yetkili_uid] ,[sth_taxfree_fl] ,sth_ilave_edilecek_kdv ,sth_ismerkezi_kodu ,sth_HareketGrupKodu1,sth_HareketGrupKodu2,sth_HareketGrupKodu3,sth_Olcu1,sth_Olcu2,sth_Olcu3,sth_Olcu4,sth_Olcu5,sth_FormulMiktar,sth_eirs_senaryo,sth_eirs_tipi,sth_teslim_tarihi,sth_matbu_fl,sth_satis_fiyat_doviz_cinsi,sth_satis_fiyat_doviz_kuru) VALUES (0-- ,0-- ,0-- ,@sth_fileid-- ,0-- ,0-- ,0-- ,0-- ,@sth_create_user-- ,getdate() -- ,@sth_create_user-- ,getdate()-- ,'mbt'-- ,''-- ,''-- ,0-- ,@sth_subeno-- ,@sth_tarih -- ,@sth_tip-- ,@sth_cins-- ,@sth_normal_iade-- ,@sth_evraktip-- ,@sth_evrakno_seri -- ,@sth_evrakno_sira -- ,@sth_satirno-- ,@sth_belgeno-- ,@sth_tarih-- ,@sth_stok_kod-- ,@sth_isk_mas1-- ,@sth_isk_mas2-- ,@sth_isk_mas3-- ,@sth_isk_mas4-- ,@sth_isk_mas5-- ,@sth_isk_mas6-- ,1-- ,1-- ,1-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@sth_cari_kodu-- ,0-- ,''-- ,@sth_plasiyer_kodu -- ,@sth_doviz_cinsi -- ,@sth_har_doviz_kuru-- ,@sth_alt_doviz_kuru-- ,@sth_stok_doviz_cinsi-- ,@sth_stok_doviz_kuru-- ,@sth_miktar-- ,@sth_miktar-- ,@sth_birim_pntr-- ,@sth_tutar-- ,@sth_iskonto1-- ,@sth_iskonto2-- ,@sth_iskonto3-- ,@sth_iskonto4-- ,@sth_iskonto5-- ,@sth_iskonto6-- ,0-- ,0-- ,0-- ,0-- ,@sth_vergi_pntr-- ,@sth_vergi -- ,0-- ,0-- ,0-- ,0-- ,@sth_aciklama -- ,@sip_Guid-- ,'00000000-0000-0000-0000-000000000000'-- ,@sth_giris_depo_no -- ,@sth_cikis_depo_no-- ,@sth_tarih-- ,@sth_stok_sormerk-- ,@sth_stok_sormerk-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_adres_no-- ,@sth_parti_kodu -- ,@sth_lot_no -- ,'00000000-0000-0000-0000-000000000000'-- ,'MBT'-- ,''-- ,0-- ,0-- ,0-- ,@sth_disticaret_turu -- ,0-- ,0-- ,0-- ,0-- ,0-- ,1-- ,0-- ,0-- ,@sth_nakliyedeposu -- ,@sth_nakliyedurumu -- ,'00000000-0000-0000-0000-000000000000'-- ,0-- ,0--sth_ilave_edilecek_kdv ,0--sth_ismerkezi_kodu ,'' --sth_HareketGrupKodu1 ,'' --sth_HareketGrupKodu2 ,'' --sth_HareketGrupKodu3 ,0--sth_Olcu1 ,0--sth_Olcu2 ,0--sth_Olcu3 ,0--sth_Olcu4 ,0--sth_Olcu5 ,0--sth_FormulMiktar ,0--sth_eirs_senaryo ,0 --sth_eirs_tipi ,@sth_tarih -- sth_teslim_tarihi ,0 --sth_matbu_fl ,0 --sth_satis_fiyat_doviz_cinsi ,0 -- sth_satis_fiyat_doviz_kuru ) DECLARE @sth_Guid nvarchar(50) DECLARE @sth_RECno int SELECT @sth_Guid=sth_Guid FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_satirno= @sth_satirno and sth_tip=@sth_tip and sth_cins= @sth_cins and sth_evraktip=@sth_evraktip and sth_normal_iade= @sth_normal_iade SET @KeyFieldValue=@sth_Guid SET @LineNumber=@sth_satirno SELECT @KeyFieldValue AS KeyFieldValue,@sth_satirno as LineNumber END GO /****** Object: StoredProcedure [dbo].[sp_MBT_SaveDispatchAllTypesWithDATWithProject] Script Date: 10.07.2023 12:16:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_MBT_SaveDispatchAllTypesWithDATWithProject] ( @sth_belgeno nvarchar(16), @sth_evrakno_seri nvarchar(8), @sth_evrakno_sira int, @sth_tarih datetime, @sth_satirno int,--SIFIRDAN ARTARAK GIDIYOR MIKRODA @sth_belge_tarih datetime, @sth_plasiyer_kodu nvarchar(25), @sth_cari_kodu nvarchar(25), @sth_stok_kod nvarchar(25), @sth_b_fiyat float, @sth_miktar float, @sth_birim_pntr tinyint,--BIRIM FIYAT @sth_tutar float,--ISKONTOSUZ ARA TOPLAM @sth_iskonto1 float,--ISKONTO 1 TOPLAMI @sth_iskonto2 float,--ISKONTO 2 TOPLAMI @sth_iskonto3 float,--ISKONTO 3 TOPLAMI @sth_iskonto4 float,--ISKONTO 4 TOPLAMI @sth_iskonto5 float,--ISKONTO 5 TOPLAMI @sth_iskonto6 float,--ISKONTO 6 TOPLAMI @sth_vergi_pntr tinyint,-- 0 8 18 @sth_vergi float,-- ISKONTO DUSULDUKTEN SONRAKI KDV TOPLAMI @sth_aciklama nvarchar(50), @sth_aciklama2 nvarchar(50), @sth_giris_depo_no int,--ZORUNLU GELMESI LAZIM @sth_cikis_depo_no int,--ZORUNLU GELMESI LAZIM @sth_doviz_kodu nvarchar(5),--TL USD EUR @sth_stok_doviz_cinsi int,--0 tl 1 usd 2 eur @sth_stok_sormerk nvarchar(25),-- YOKSA BOS GONDERILECEK @sth_adres_no int, @sip_Guid nvarchar(50),--SIPARIS @ssip_Guid nvarchar(50),--DEPOLAR ARASI SIPARIS @sth_parti_kodu nvarchar(25), @sth_lot_no int, @sth_disticaret_turu int, @ChHar_SeriNo nvarchar(25), @MbtTakipNoAna nvarchar(50), @MbtTakipNoDetay nvarchar(50), @sth_tip int, @sth_cins int, @sth_evraktip int, @sth_normal_iade int, @sth_fileid int, @sth_isemri_gider_kodu nvarchar(50), @sth_proje_kodu nvarchar(50), @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT --İlk once Carihareket Kayıt edilmeli Çünkü ID si stok hareketlerine yazılacak --yada en son update edilebilir. --ben ikinisini tercih edecegim. --07 12 2020 12 ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- gelen fis Numarasına göre evrak aktaracagız.... --sth_tip Tinyint Hareket Tipi 0:Giriş 1:Çıkış 2:Depo Transfer /* --sth_cins Tinyint Hareket Cinsi 0:Toptan 1:Perakende 2:Dış Ticaret 3:Stok Virman 4:Fire 5:Sarf 6:Transfer 7:Üretim 8:Fason 9:Değer Farkı 10:Sayım 11:Stok Açılış 12:İthalat-İhracat 13:Hal 14:Müstahsil 15:Müstahsil Değer Farkı 14:Kabzımal 15:Gider Pusulası **/ -- sth_normal_iade Tinyint Normal/Iade? 0:Normal 1:İade /* sth_evraktip Tinyint Evrak Tipi 0:Depo Çıkış Fişi 1:Çıkış İrsaliyesi 2:Depo Transfer Fişi 3:Giriş Faturası 4:Çıkış Faturası 5:Stoklara İthalat Masraf Yansıtma Dekontu 6:Stok Virman Fişi 7:Üretim Fişi 8:İlave Enflasyon Maliyet Fişi 9:Stoklara İlave Maliyet Yedirme Fişi 10:Antrepolardan Mal Millileştirme Fişi 11:Antrepolar Arası Transfer Fişi 12:Depo Giriş Fişi 13:Giriş İrsaliyesi 14:Fason Giriş Çıkış Fişi 15:Depolar Arası Satış Fişi 16:Stok Gider Pusulası Fişi 17:Depolar Arası Nakliye Fişi **/ declare @subeliCalismaVarmi int declare @sth_subeno int SET @sth_subeno=0 SELECT @subeliCalismaVarmi=COUNT(*) FROM MBTSISTEMPARAMETRELERI WHERE PARAMETREADI='SUBELICALISMA' AND DEGER='EVET' if @subeliCalismaVarmi=1 BEGIN select @sth_subeno=@sth_cikis_depo_no END else BEGIN set @sth_subeno=0 END DECLARE @sth_doviz_cinsi tinyint DECLARE @sth_doviz_kuru float DECLARE @sth_stok_doviz_kuru float DECLARE @sorumluluk_merkezi nvarchar(25) set @sorumluluk_merkezi='' if @sip_Guid<>'00000000-0000-0000-0000-000000000000' BEGIN SELECT @sorumluluk_merkezi=sip_cari_sormerk FROM SIPARISLER WHERE sip_Guid=@sip_Guid END DECLARE @sip_opno nvarchar(10) BEGIN SELECT @sip_opno=sip_opno FROM SIPARISLER WHERE sip_Guid=@sip_Guid END IF @sth_aciklama='' BEGIN DECLARE @sip_aciklama nvarchar(50) SELECT @sip_aciklama=sip_aciklama FROM SIPARISLER WHERE sip_Guid=@sip_Guid set @sth_aciklama = @sip_aciklama END -- if @sip_Guid<>'00000000-0000-0000-0000-000000000000' BEGIN if @sth_stok_sormerk='' set @sth_stok_sormerk=@sorumluluk_merkezi END -- SELECT @sth_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu --sth_doviz_cinsi=sth_stok_doviz_cinsi ne eşitlenecek ve o kura göre kur alınacak. set @sth_stok_doviz_cinsi=@sth_doviz_cinsi DECLARE @cari_KurHesapSekli tinyint SELECT @cari_KurHesapSekli=cari_KurHesapSekli FROM CARI_HESAPLAR WHERE cari_kod=@sth_cari_kodu if @cari_KurHesapSekli =0 set @cari_KurHesapSekli=2 DECLARE @sth_alt_doviz_kuru float DECLARE @sth_har_doviz_kuru float -- evrak doviz cinsinin doviz kuru DECLARE @sth_vergi_pntr_yeni int DECLARE @TESLIMMIKTAR FLOAT DECLARE @TESLIMMIKTAR2 FLOAT DECLARE @sth_isk_mas1 int DECLARE @sth_isk_mas2 int DECLARE @sth_isk_mas3 int DECLARE @sth_isk_mas4 int DECLARE @sth_isk_mas5 int DECLARE @sth_isk_mas6 int SELECT @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,@cari_KurHesapSekli) SELECT @sth_har_doviz_kuru=dbo.fn_KurBul(GetDate(),@sth_doviz_cinsi,@cari_KurHesapSekli) SELECT @sth_stok_doviz_kuru=dbo.fn_KurBul(GetDate(),@sth_stok_doviz_cinsi,@cari_KurHesapSekli) --CARIYE TANIMLI KUR VARMI /* DECLARE @cariyeTanimliOzelKurVarmi FLOAT SET @cariyeTanimliOzelKurVarmi=0 if @sth_doviz_cinsi='USD' BEGIN SELECT @cariyeTanimliOzelKurVarmi=ISNULL(USDKURU,0) FROM MBTDOVIZKURLARI WHERE MUSTERIKODU=@sth_cari_kodu and YIL=YEAR(GETDATE()) AND AY=MONTH(GETDATE()) END if @sth_doviz_cinsi='EUR' BEGIN SELECT @cariyeTanimliOzelKurVarmi=ISNULL(EURKURU,0) FROM MBTDOVIZKURLARI WHERE MUSTERIKODU=@sth_cari_kodu and YIL=YEAR(GETDATE()) AND AY=MONTH(GETDATE()) END if @cariyeTanimliOzelKurVarmi>0 BEGIN SET @sth_alt_doviz_kuru =@cariyeTanimliOzelKurVarmi SET @sth_har_doviz_kuru =@cariyeTanimliOzelKurVarmi SET @sth_stok_doviz_kuru =@cariyeTanimliOzelKurVarmi END */ --SELECT @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,2) SELECT TOP 1 @sth_vergi_pntr_yeni=T1.VERGIPNTR FROM ( SELECT 0 AS VERGIPNTR,dbo.fn_VergiIsim(0) AS KDVADI,dbo.fn_VergiYuzde(0) AS KDVORANI UNION SELECT 1 AS VERGIPNTR,dbo.fn_VergiIsim(1) AS KDVADI,dbo.fn_VergiYuzde(1) AS KDVORANI UNION SELECT 2 AS VERGIPNTR,dbo.fn_VergiIsim(2) AS KDVADI,dbo.fn_VergiYuzde(2) AS KDVORANI UNION SELECT 3 AS VERGIPNTR,dbo.fn_VergiIsim(3) AS KDVADI,dbo.fn_VergiYuzde(3) AS KDVORANI UNION SELECT 4 AS VERGIPNTR,dbo.fn_VergiIsim(4) AS KDVADI,dbo.fn_VergiYuzde(4) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 7 AS VERGIPNTR,dbo.fn_VergiIsim(7) AS KDVADI,dbo.fn_VergiYuzde(7) AS KDVORANI UNION SELECT 8 AS VERGIPNTR,dbo.fn_VergiIsim(8) AS KDVADI,dbo.fn_VergiYuzde(8) AS KDVORANI UNION SELECT 9 AS VERGIPNTR,dbo.fn_VergiIsim(9) AS KDVADI,dbo.fn_VergiYuzde(9) AS KDVORANI UNION SELECT 10 AS VERGIPNTR,dbo.fn_VergiIsim(10) AS KDVADI,dbo.fn_VergiYuzde(10) AS KDVORANI UNION SELECT 11 AS VERGIPNTR,dbo.fn_VergiIsim(11) AS KDVADI,dbo.fn_VergiYuzde(11) AS KDVORANI UNION SELECT 12 AS VERGIPNTR,dbo.fn_VergiIsim(12) AS KDVADI,dbo.fn_VergiYuzde(12) AS KDVORANI UNION SELECT 13 AS VERGIPNTR,dbo.fn_VergiIsim(13) AS KDVADI,dbo.fn_VergiYuzde(13) AS KDVORANI UNION SELECT 14 AS VERGIPNTR,dbo.fn_VergiIsim(14) AS KDVADI,dbo.fn_VergiYuzde(14) AS KDVORANI UNION SELECT 15 AS VERGIPNTR,dbo.fn_VergiIsim(15) AS KDVADI,dbo.fn_VergiYuzde(15) AS KDVORANI UNION SELECT 16 AS VERGIPNTR,dbo.fn_VergiIsim(16) AS KDVADI,dbo.fn_VergiYuzde(16) AS KDVORANI UNION SELECT 17 AS VERGIPNTR,dbo.fn_VergiIsim(17) AS KDVADI,dbo.fn_VergiYuzde(17) AS KDVORANI UNION SELECT 18 AS VERGIPNTR,dbo.fn_VergiIsim(18) AS KDVADI,dbo.fn_VergiYuzde(18) AS KDVORANI UNION SELECT 19 AS VERGIPNTR,dbo.fn_VergiIsim(19) AS KDVADI,dbo.fn_VergiYuzde(19) AS KDVORANI UNION SELECT 20 AS VERGIPNTR,dbo.fn_VergiIsim(20) AS KDVADI,dbo.fn_VergiYuzde(20) AS KDVORANI ) T1 WHERE T1.KDVORANI=@sth_vergi_pntr ORDER BY VERGIPNTR ASC SET @sth_vergi_pntr=@sth_vergi_pntr_yeni SET @sth_isk_mas1=0 SET @sth_isk_mas2=0 SET @sth_isk_mas3=0 SET @sth_isk_mas4=0 SET @sth_isk_mas5=0 SET @sth_isk_mas6=0 if @sth_iskonto1>0 set @sth_isk_mas1=1 if @sth_iskonto2>0 set @sth_isk_mas2=1 if @sth_iskonto3>0 set @sth_isk_mas3=1 if @sth_iskonto4>0 set @sth_isk_mas4=1 if @sth_iskonto5>0 set @sth_isk_mas5=1 if @sth_iskonto6>0 set @sth_isk_mas6=1 --if @sip_Guid='0' set @sip_Guid='00000000-0000-0000-0000-000000000000' --if @ssip_Guid='0' set @ssip_Guid='00000000-0000-0000-0000-000000000000' declare @sth_netagirlik float declare @sth_dara float declare @sth_brutagirlik float declare @sth_FormulMiktarNo int SELECT @sth_netagirlik=sto_birim1_agirlik FROM STOKLAR WHERE sto_kod=@sth_stok_kod SELECT @sth_dara=sto_birim1_dara FROM STOKLAR WHERE sto_kod=@sth_stok_kod set @sth_brutagirlik=@sth_dara+ @sth_netagirlik -- Insert statements for procedure here INSERT INTO [dbo].[STOK_HAREKETLERI] ([sth_DBCno] ,[sth_SpecRECno] ,[sth_iptal] ,[sth_fileid] ,[sth_hidden] ,[sth_kilitli] ,[sth_degisti] ,[sth_checksum] ,[sth_create_user] ,[sth_create_date] ,[sth_lastup_user] ,[sth_lastup_date] ,[sth_special1] ,[sth_special2] ,[sth_special3] ,[sth_firmano] ,[sth_subeno] ,[sth_tarih] ,[sth_tip] ,[sth_cins] ,[sth_normal_iade] ,[sth_evraktip] ,[sth_evrakno_seri] ,[sth_evrakno_sira] ,[sth_satirno] ,[sth_belge_no] ,[sth_belge_tarih] ,[sth_stok_kod] ,[sth_isk_mas1] ,[sth_isk_mas2] ,[sth_isk_mas3] ,[sth_isk_mas4] ,[sth_isk_mas5] ,[sth_isk_mas6] ,[sth_isk_mas7] ,[sth_isk_mas8] ,[sth_isk_mas9] ,[sth_isk_mas10] ,[sth_sat_iskmas1] ,[sth_sat_iskmas2] ,[sth_sat_iskmas3] ,[sth_sat_iskmas4] ,[sth_sat_iskmas5] ,[sth_sat_iskmas6] ,[sth_sat_iskmas7] ,[sth_sat_iskmas8] ,[sth_sat_iskmas9] ,[sth_sat_iskmas10] ,[sth_pos_satis] ,[sth_promosyon_fl] ,[sth_cari_cinsi] ,[sth_cari_kodu] ,[sth_cari_grup_no] ,[sth_isemri_gider_kodu] ,[sth_plasiyer_kodu] ,[sth_har_doviz_cinsi] ,[sth_har_doviz_kuru] ,[sth_alt_doviz_kuru] ,[sth_stok_doviz_cinsi] ,[sth_stok_doviz_kuru] ,[sth_miktar] ,[sth_miktar2] ,[sth_birim_pntr] ,[sth_tutar] ,[sth_iskonto1] ,[sth_iskonto2] ,[sth_iskonto3] ,[sth_iskonto4] ,[sth_iskonto5] ,[sth_iskonto6] ,[sth_masraf1] ,[sth_masraf2] ,[sth_masraf3] ,[sth_masraf4] ,[sth_vergi_pntr] ,[sth_vergi] ,[sth_masraf_vergi_pntr] ,[sth_masraf_vergi] ,[sth_netagirlik] ,[sth_odeme_op] ,[sth_aciklama] ,[sth_sip_uid] ,[sth_fat_uid] ,[sth_giris_depo_no] ,[sth_cikis_depo_no] ,[sth_malkbl_sevk_tarihi] ,[sth_cari_srm_merkezi] ,[sth_stok_srm_merkezi] ,[sth_fis_tarihi] ,[sth_fis_sirano] ,[sth_vergisiz_fl] ,[sth_maliyet_ana] ,[sth_maliyet_alternatif] ,[sth_maliyet_orjinal] ,[sth_adres_no] ,[sth_parti_kodu] ,[sth_lot_no] ,[sth_kons_uid] ,[sth_proje_kodu] ,[sth_exim_kodu] ,[sth_otv_pntr] ,[sth_otv_vergi] ,[sth_brutagirlik] ,[sth_disticaret_turu] ,[sth_otvtutari] ,[sth_otvvergisiz_fl] ,[sth_oiv_pntr] ,[sth_oiv_vergi] ,[sth_oivvergisiz_fl] ,[sth_fiyat_liste_no] ,[sth_oivtutari] ,[sth_Tevkifat_turu] ,[sth_nakliyedeposu] ,[sth_nakliyedurumu] ,[sth_yetkili_uid] ,[sth_taxfree_fl] ,sth_ilave_edilecek_kdv ,sth_ismerkezi_kodu) VALUES (0-- ,0-- ,0-- ,@sth_fileid-- ,0-- ,0-- ,0-- ,0-- ,1-- ,getdate() -- ,1-- ,getdate()-- ,'mbt'-- ,''-- ,''-- ,0-- ,@sth_subeno-- ,@sth_tarih -- ,@sth_tip-- ,@sth_cins-- ,@sth_normal_iade-- ,@sth_evraktip-- ,@sth_evrakno_seri -- ,@sth_evrakno_sira -- ,@sth_satirno-- ,@sth_belgeno-- ,@sth_tarih-- ,@sth_stok_kod-- ,@sth_isk_mas1-- ,@sth_isk_mas2-- ,@sth_isk_mas3-- ,@sth_isk_mas4-- ,@sth_isk_mas5-- ,@sth_isk_mas6-- ,1-- ,1-- ,1-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@sth_cari_kodu-- ,0-- ,@sth_isemri_gider_kodu-- ,@sth_plasiyer_kodu -- ,@sth_doviz_cinsi -- ,@sth_har_doviz_kuru-- ,@sth_alt_doviz_kuru-- ,@sth_stok_doviz_cinsi-- ,@sth_stok_doviz_kuru-- ,@sth_miktar-- ,@sth_miktar-- ,@sth_birim_pntr-- ,@sth_tutar-- ,@sth_iskonto1-- ,@sth_iskonto2-- ,@sth_iskonto3-- ,@sth_iskonto4-- ,@sth_iskonto5-- ,@sth_iskonto6-- ,0-- ,0-- ,0-- ,0-- ,@sth_vergi_pntr-- ,@sth_vergi -- ,0-- ,0-- ,@sth_netagirlik-- ,@sip_opno-- ,@sth_aciklama -- ,@sip_Guid-- ,'00000000-0000-0000-0000-000000000000'-- ,@sth_giris_depo_no -- ,@sth_cikis_depo_no-- ,@sth_tarih-- ,@sth_stok_sormerk-- ,@sth_stok_sormerk-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_adres_no-- ,@sth_parti_kodu -- ,@sth_lot_no -- ,'00000000-0000-0000-0000-000000000000'-- ,@sth_proje_kodu-- ,''-- ,0-- ,0-- ,@sth_brutagirlik-- ,@sth_disticaret_turu -- ,0-- ,0-- ,0-- ,0-- ,0-- ,1-- ,0-- ,0-- ,0-- ,0-- ,'00000000-0000-0000-0000-000000000000'-- ,0-- ,0--sth_ilave_edilecek_kdv ,0--sth_ismerkezi_kodu ) DECLARE @sth_Guid nvarchar(50) DECLARE @sth_RECno int SELECT @sth_Guid=sth_Guid FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_satirno= @sth_satirno and sth_tip=@sth_tip and sth_cins= @sth_cins and sth_evraktip=@sth_evraktip and sth_normal_iade= @sth_normal_iade --eksik kolonlar guncelle update STOK_HAREKETLERI set sth_ilave_edilecek_kdv=0,sth_HareketGrupKodu1='',sth_HareketGrupKodu2='',sth_HareketGrupKodu3='',sth_Olcu1=0,sth_Olcu2=0,sth_Olcu3=0,sth_Olcu4=0,sth_Olcu5=0,sth_FormulMiktar=0,sth_eirs_senaryo=0,sth_eirs_tipi=0,sth_teslim_tarihi=@sth_tarih,sth_matbu_fl=0,sth_satis_fiyat_doviz_cinsi=0,sth_satis_fiyat_doviz_kuru=0,sth_lastup_user=1,sth_odeme_op=0,sth_FormulMiktarNo=0,sth_eticaret_kanal_kodu='' Where sth_Guid=@sth_Guid declare @sip_evrakno_seri nvarchar(25) declare @sip_evrakno_sira int if @sip_Guid<>'00000000-0000-0000-0000-000000000000' BEGIN SELECT @sip_evrakno_seri=sip_evrakno_seri from SIPARISLER where sip_Guid=@sip_Guid SELECT @sip_evrakno_sira=sip_evrakno_sira from SIPARISLER where sip_Guid=@sip_Guid END if @sip_Guid<>'00000000-0000-0000-0000-000000000000' BEGIN declare @sipEvrakAciklamalariAktarildimi int SELECT @sipEvrakAciklamalariAktarildimi=COUNT(*) FROM EVRAK_ACIKLAMALARI WHERE egk_evr_seri=@sth_evrakno_seri and egk_evr_sira=@sth_evrakno_sira AND egk_hareket_tip=1 and egk_evr_tip=1 and egk_dosyano=16 IF @sipEvrakAciklamalariAktarildimi=0 BEGIN --EVRAK ACIKLAMALARI AKTARIMI INSERT INTO [dbo].[EVRAK_ACIKLAMALARI] ([egk_Guid] ,[egk_DBCno] ,[egk_SpecRECno] ,[egk_iptal] ,[egk_fileid] ,[egk_hidden] ,[egk_kilitli] ,[egk_degisti] ,[egk_checksum] ,[egk_create_user] ,[egk_create_date] ,[egk_lastup_user] ,[egk_lastup_date] ,[egk_special1] ,[egk_special2] ,[egk_special3] ,[egk_dosyano] ,[egk_hareket_tip] ,[egk_evr_tip] ,[egk_evr_seri] ,[egk_evr_sira] ,[egk_evr_ustkod] ,[egk_evr_doksayisi] ,[egk_evracik1] ,[egk_evracik2] ,[egk_evracik3] ,[egk_evracik4] ,[egk_evracik5] ,[egk_evracik6] ,[egk_evracik7] ,[egk_evracik8] ,[egk_evracik9] ,[egk_evracik10] ,[egk_sipgenkarorani] ,[egk_kargokodu] ,[egk_kargono] ,[egk_tesaltarihi] ,[egk_tesalkisi] ,[egk_prevwiewsayisi] ,[egk_emailsayisi] ,[egk_Evrakopno_verildi_fl]) SELECT NEWID() ,egk_DBCno ,egk_SpecRECno ,egk_iptal ,egk_fileid ,egk_hidden ,egk_kilitli ,egk_degisti ,egk_checksum ,egk_create_user ,egk_create_date ,egk_lastup_user ,egk_lastup_date ,egk_special1 ,egk_special2 ,egk_special3 ,16--egk_dosyano ,1--egk_hareket_tip ,1--egk_evr_tip ,@sth_evrakno_seri --egk_evr_seri ,@sth_evrakno_sira --egk_evr_sira ,egk_evr_ustkod ,egk_evr_doksayisi ,egk_evracik1 ,egk_evracik2 ,egk_evracik3 ,egk_evracik4 ,egk_evracik5 ,egk_evracik6 ,egk_evracik7 ,egk_evracik8 ,egk_evracik9 ,egk_evracik10 ,egk_sipgenkarorani ,egk_kargokodu ,egk_kargono ,egk_tesaltarihi ,egk_tesalkisi ,egk_prevwiewsayisi ,egk_emailsayisi ,egk_Evrakopno_verildi_fl from EVRAK_ACIKLAMALARI where egk_evr_seri=@sip_evrakno_seri and egk_evr_sira=@sip_evrakno_sira and egk_hareket_tip=0 and egk_evr_tip=0 and egk_dosyano=21 --EVRAK ACIKLAMALARI AKTARIMI BITTI END END SET @KeyFieldValue=@sth_Guid SET @LineNumber=@sth_satirno SELECT @KeyFieldValue AS KeyFieldValue,@sth_satirno as LineNumber END GO /****** Object: StoredProcedure [dbo].[sp_mbt_SaveInvoice] Script Date: 10.07.2023 12:16:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_mbt_SaveInvoice] ( @sth_belgeno nvarchar(16), @sth_evrakno_seri nvarchar(8), @sth_evrakno_sira int, @sth_tarih datetime, @sth_satirno int,--SIFIRDAN ARTARAK GIDIYOR MIKRODA @sth_belge_tarih datetime, @sth_plasiyer_kodu nvarchar(25), @sth_cari_kodu nvarchar(25), @sth_stok_kod nvarchar(25), @sth_b_fiyat float, @sth_miktar float, @sth_birim_pntr tinyint,--BIRIM FIYAT @sth_tutar float,--ISKONTOSUZ ARA TOPLAM @sth_iskonto1 float,--ISKONTO 1 TOPLAMI @sth_iskonto2 float,--ISKONTO 2 TOPLAMI @sth_iskonto3 float,--ISKONTO 3 TOPLAMI @sth_iskonto4 float,--ISKONTO 4 TOPLAMI @sth_iskonto5 float,--ISKONTO 5 TOPLAMI @sth_iskonto6 float,--ISKONTO 6 TOPLAMI @sth_vergi_pntr tinyint,-- 0 8 18 @sth_vergi float,-- ISKONTO DUSULDUKTEN SONRAKI KDV TOPLAMI @sth_aciklama nvarchar(50), @sth_aciklama2 nvarchar(50), @sth_cikis_depo_no int,--ZORUNLU GELMESI LAZIM @sth_doviz_kodu nvarchar(5),--TL USD EUR @sth_stok_sormerk nvarchar(25),-- YOKSA BOS GONDERILECEK @sth_adres_no int, @NormalIade int,--0 NORMAL 1 IADE @AlisSatis int, -- 1 SATIS 0 ALIS @ORDERFICHENO nvarchar(50), @ORDERLINENUMBER int, @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT --İlk once Carihareket Kayıt edilmeli Çünkü ID si stok hareketlerine yazılacak --yada en son update edilebilir. --ben ikinisini tercih edecegim. ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- gelen fis Numarasına göre evrak aktaracagız.... --sth_tip Tinyint Hareket Tipi 0:Giriş 1:Çıkış 2:Depo Transfer /* --sth_cins Tinyint Hareket Cinsi 0:Toptan 1:Perakende 2:Dış Ticaret 3:Stok Virman 4:Fire 5:Sarf 6:Transfer 7:Üretim 8:Fason 9:Değer Farkı 10:Sayım 11:Stok Açılış 12:İthalat-İhracat 13:Hal 14:Müstahsil 15:Müstahsil Değer Farkı 14:Kabzımal 15:Gider Pusulası **/ -- sth_normal_iade Tinyint Normal/Iade? 0:Normal 1:İade /* sth_evraktip Tinyint Evrak Tipi 0:Depo Çıkış Fişi 1:Çıkış İrsaliyesi 2:Depo Transfer Fişi 3:Giriş Faturası 4:Çıkış Faturası 5:Stoklara İthalat Masraf Yansıtma Dekontu 6:Stok Virman Fişi 7:Üretim Fişi 8:İlave Enflasyon Maliyet Fişi 9:Stoklara İlave Maliyet Yedirme Fişi 10:Antrepolardan Mal Millileştirme Fişi 11:Antrepolar Arası Transfer Fişi 12:Depo Giriş Fişi 13:Giriş İrsaliyesi 14:Fason Giriş Çıkış Fişi 15:Depolar Arası Satış Fişi 16:Stok Gider Pusulası Fişi 17:Depolar Arası Nakliye Fişi **/ --DECLARE @KeyFieldValue nvarchar(100) DECLARE @yeniEvrakSiraNo int DECLARE @yeniEvrakMi int DECLARE @sth_doviz_cinsi tinyint SELECT @sth_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu --SATIŞ FATURASI İÇİN DECLARE @sth_normal_iade int DECLARE @sth_evraktip int declare @sth_cins int declare @sth_tip int set @sth_normal_iade =@NormalIade if @AlisSatis=1 BEGIN set @sth_evraktip = 4 set @sth_cins = 0 set @sth_tip = 1 --SET @sth_evrakno_seri='SMNSF' -- SATIS FATURASI ICIN TIPLER BUNLAR END if @AlisSatis=0 BEGIN set @sth_evraktip = 3 set @sth_cins = 0 set @sth_tip = 0 --SET @sth_evrakno_seri='SMNAF' -- ALIS FATURASI ICIN TIPLER BUNLAR END if @sth_normal_iade=1 BEGIN SET @sth_tip=0 --SET @sth_evrakno_seri='SMNIF' END declare @subeliCalismaVarmi int declare @sth_subeno int SET @sth_subeno=0 SELECT @subeliCalismaVarmi=COUNT(*) FROM MBTSISTEMPARAMETRELERI WHERE PARAMETREADI='SUBELICALISMA' AND DEGER='EVET' if @subeliCalismaVarmi=1 BEGIN select @sth_subeno=@sth_cikis_depo_no END else BEGIN set @sth_subeno=0 END DECLARE @sth_alt_doviz_kuru float DECLARE @sth_vergi_pntr_yeni int set @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,1) SELECT @sth_vergi_pntr_yeni=T1.VERGIPNTR FROM ( SELECT 0 AS VERGIPNTR,dbo.fn_VergiIsim(0) AS KDVADI,dbo.fn_VergiYuzde(0) AS KDVORANI UNION SELECT 1 AS VERGIPNTR,dbo.fn_VergiIsim(1) AS KDVADI,dbo.fn_VergiYuzde(1) AS KDVORANI UNION SELECT 2 AS VERGIPNTR,dbo.fn_VergiIsim(2) AS KDVADI,dbo.fn_VergiYuzde(2) AS KDVORANI UNION SELECT 3 AS VERGIPNTR,dbo.fn_VergiIsim(3) AS KDVADI,dbo.fn_VergiYuzde(3) AS KDVORANI UNION SELECT 4 AS VERGIPNTR,dbo.fn_VergiIsim(4) AS KDVADI,dbo.fn_VergiYuzde(4) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 7 AS VERGIPNTR,dbo.fn_VergiIsim(7) AS KDVADI,dbo.fn_VergiYuzde(7) AS KDVORANI UNION SELECT 8 AS VERGIPNTR,dbo.fn_VergiIsim(8) AS KDVADI,dbo.fn_VergiYuzde(8) AS KDVORANI UNION SELECT 9 AS VERGIPNTR,dbo.fn_VergiIsim(9) AS KDVADI,dbo.fn_VergiYuzde(9) AS KDVORANI UNION SELECT 10 AS VERGIPNTR,dbo.fn_VergiIsim(10) AS KDVADI,dbo.fn_VergiYuzde(10) AS KDVORANI UNION SELECT 11 AS VERGIPNTR,dbo.fn_VergiIsim(11) AS KDVADI,dbo.fn_VergiYuzde(11) AS KDVORANI UNION SELECT 12 AS VERGIPNTR,dbo.fn_VergiIsim(12) AS KDVADI,dbo.fn_VergiYuzde(12) AS KDVORANI UNION SELECT 13 AS VERGIPNTR,dbo.fn_VergiIsim(13) AS KDVADI,dbo.fn_VergiYuzde(13) AS KDVORANI UNION SELECT 14 AS VERGIPNTR,dbo.fn_VergiIsim(14) AS KDVADI,dbo.fn_VergiYuzde(14) AS KDVORANI UNION SELECT 15 AS VERGIPNTR,dbo.fn_VergiIsim(15) AS KDVADI,dbo.fn_VergiYuzde(15) AS KDVORANI UNION SELECT 16 AS VERGIPNTR,dbo.fn_VergiIsim(16) AS KDVADI,dbo.fn_VergiYuzde(16) AS KDVORANI UNION SELECT 17 AS VERGIPNTR,dbo.fn_VergiIsim(17) AS KDVADI,dbo.fn_VergiYuzde(17) AS KDVORANI UNION SELECT 18 AS VERGIPNTR,dbo.fn_VergiIsim(18) AS KDVADI,dbo.fn_VergiYuzde(18) AS KDVORANI UNION SELECT 19 AS VERGIPNTR,dbo.fn_VergiIsim(19) AS KDVADI,dbo.fn_VergiYuzde(19) AS KDVORANI UNION SELECT 20 AS VERGIPNTR,dbo.fn_VergiIsim(20) AS KDVADI,dbo.fn_VergiYuzde(20) AS KDVORANI ) T1 WHERE T1.KDVORANI=@sth_vergi_pntr SET @sth_vergi_pntr=@sth_vergi_pntr_yeni DECLARE @sip_RECno uniqueidentifier SET @sip_RECno='00000000-0000-0000-0000-000000000000' if @ORDERFICHENO<>NULL BEGIN Select @sip_RECno=ISNULL(sip_Guid,'00000000-0000-0000-0000-000000000000') from SIPARISLER WHERE sip_belgeno=@ORDERFICHENO AND sip_satirno=@ORDERLINENUMBER and sip_musteri_kod=@sth_cari_kodu END -- Insert statements for procedure here DECLARE @guid uniqueidentifier = NEWID(); INSERT INTO [dbo].[STOK_HAREKETLERI] ([sth_Guid] ,[sth_DBCno] ,[sth_SpecRECno] ,[sth_iptal] ,[sth_fileid] ,[sth_hidden] ,[sth_kilitli] ,[sth_degisti] ,[sth_checksum] ,[sth_create_user] ,[sth_create_date] ,[sth_lastup_user] ,[sth_lastup_date] ,[sth_special1] ,[sth_special2] ,[sth_special3] ,[sth_firmano] ,[sth_subeno] ,[sth_tarih] ,[sth_tip] ,[sth_cins] ,[sth_normal_iade] ,[sth_evraktip] ,[sth_evrakno_seri] ,[sth_evrakno_sira] ,[sth_satirno] ,[sth_belge_no] ,[sth_belge_tarih] ,[sth_stok_kod] ,[sth_isk_mas1] ,[sth_isk_mas2] ,[sth_isk_mas3] ,[sth_isk_mas4] ,[sth_isk_mas5] ,[sth_isk_mas6] ,[sth_isk_mas7] ,[sth_isk_mas8] ,[sth_isk_mas9] ,[sth_isk_mas10] ,[sth_sat_iskmas1] ,[sth_sat_iskmas2] ,[sth_sat_iskmas3] ,[sth_sat_iskmas4] ,[sth_sat_iskmas5] ,[sth_sat_iskmas6] ,[sth_sat_iskmas7] ,[sth_sat_iskmas8] ,[sth_sat_iskmas9] ,[sth_sat_iskmas10] ,[sth_pos_satis] ,[sth_promosyon_fl] ,[sth_cari_cinsi] ,[sth_cari_kodu] ,[sth_cari_grup_no] ,[sth_isemri_gider_kodu] ,[sth_plasiyer_kodu] ,[sth_har_doviz_cinsi] ,[sth_har_doviz_kuru] ,[sth_alt_doviz_kuru] ,[sth_stok_doviz_cinsi] ,[sth_stok_doviz_kuru] ,[sth_miktar] ,[sth_miktar2] ,[sth_birim_pntr] ,[sth_tutar] ,[sth_iskonto1] ,[sth_iskonto2] ,[sth_iskonto3] ,[sth_iskonto4] ,[sth_iskonto5] ,[sth_iskonto6] ,[sth_masraf1] ,[sth_masraf2] ,[sth_masraf3] ,[sth_masraf4] ,[sth_vergi_pntr] ,[sth_vergi] ,[sth_masraf_vergi_pntr] ,[sth_masraf_vergi] ,[sth_netagirlik] ,[sth_odeme_op] ,[sth_aciklama] --,[sth_sip_recid_dbcno] ,[sth_sip_uid] --,[sth_fat_recid_dbcno] ,[sth_fat_uid] ,[sth_giris_depo_no] ,[sth_cikis_depo_no] ,[sth_malkbl_sevk_tarihi] ,[sth_cari_srm_merkezi] ,[sth_stok_srm_merkezi] ,[sth_fis_tarihi] ,[sth_fis_sirano] ,[sth_vergisiz_fl] ,[sth_maliyet_ana] ,[sth_maliyet_alternatif] ,[sth_maliyet_orjinal] ,[sth_adres_no] ,[sth_parti_kodu] ,[sth_lot_no] --,[sth_kons_recid_dbcno] ,[sth_kons_uid] ,[sth_proje_kodu] ,[sth_exim_kodu] ,[sth_otv_pntr] ,[sth_otv_vergi] ,[sth_brutagirlik] ,[sth_disticaret_turu] ,[sth_otvtutari] ,[sth_otvvergisiz_fl] ,[sth_oiv_pntr] ,[sth_oiv_vergi] ,[sth_oivvergisiz_fl] ,[sth_fiyat_liste_no] ,[sth_oivtutari] ,[sth_Tevkifat_turu] ,[sth_nakliyedeposu] ,[sth_nakliyedurumu] ,[sth_yetkili_uid] ,[sth_taxfree_fl] ,sth_ilave_edilecek_kdv ,sth_ismerkezi_kodu) VALUES (@guid ,0-- ,0-- ,0-- ,16-- ,0-- ,0-- ,0-- ,0-- ,1-- ,getdate() -- ,1-- ,getdate()-- ,''-- ,''-- ,''-- ,0-- ,0-- ,@sth_tarih -- ,@sth_tip-- ,@sth_cins-- ,@sth_normal_iade-- ,@sth_evraktip-- ,@sth_evrakno_seri -- ,@sth_evrakno_sira -- ,@sth_satirno-- ,@sth_belgeno-- ,@sth_tarih-- ,@sth_stok_kod-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@sth_cari_kodu-- ,0-- ,''-- ,@sth_plasiyer_kodu -- ,@sth_doviz_cinsi -- ,1-- ,1-- ,@sth_doviz_cinsi-- ,1-- ,@sth_miktar-- ,@sth_miktar-- ,@sth_birim_pntr-- ,@sth_tutar-- ,@sth_iskonto1-- ,@sth_iskonto2-- ,@sth_iskonto3-- ,@sth_iskonto4-- ,@sth_iskonto5-- ,@sth_iskonto6-- ,0-- ,0-- ,0-- ,0-- ,@sth_vergi_pntr-- ,@sth_vergi -- ,0-- ,0-- ,0-- ,0-- ,@sth_aciklama -- --,0-- ,@sip_RECno-- --,0-- ,'00000000-0000-0000-0000-000000000000'-- ,@sth_cikis_depo_no -- ,@sth_cikis_depo_no-- ,@sth_tarih-- ,''-- ,''-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_adres_no-- ,''-- ,0-- --,0-- ,'00000000-0000-0000-0000-000000000000'-- ,''-- ,''-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,1-- ,0-- ,0-- ,0-- ,0-- --,0-- ,'00000000-0000-0000-0000-000000000000'-- ,0-- ,0--sth_ilave_edilecek_kdv ,0--sth_ismerkezi_kodu ) DECLARE @sth_RECno uniqueidentifier SET @sth_RECno=NEWID(); --PRINT CONVERT(NVARCHAR(20),@sth_RECno) --UPDATE STOK_HAREKETLERI SET sth_SpecRECno=@sth_RECno where sth_Guid<>sth_SpecRECno SELECT @KeyFieldValue=@sth_RECno SELECT @KeyFieldValue AS KeyFieldValue,@sth_evrakno_seri as DocumentSerial,@sth_evrakno_sira as DocumentNumber,@sth_satirno as LineNumber --CARI HAREKET TABLOSUNA KAYIT DECLARE @yeniEvrakMiCariHareket int DECLARE @cha_doviz_cinsi tinyint DECLARE @cha_tip tinyint DECLARE @cha_cinsi tinyint DECLARE @cha_normal_Iade tinyint DECLARE @cha_evrak_tip tinyint DECLARE @cha_kasa_hizmet tinyint DECLARE @cha_sntcek_poz tinyint DECLARE @cha_vade nvarchar(8) SELECT @cha_vade=0--CONVERT(NVARCHAR,@sth_tarih,112) DECLARE @cha_senet_cek_ref nvarchar(50) SELECT @cha_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu DECLARE @cha_evrakno_seri NVARCHAR(8) DECLARE @cha_evrakno_sira int SET @cha_evrakno_seri=@sth_evrakno_seri SET @cha_evrakno_sira=@sth_evrakno_sira SET @cha_normal_Iade=@NormalIade if @AlisSatis = 1 BEGIN SET @cha_tip=0 SET @cha_cinsi=6 SET @cha_evrak_tip =63 END if @AlisSatis = 0 BEGIN SET @cha_tip=0 SET @cha_cinsi=6 SET @cha_evrak_tip =0 END if @NormalIade=1 BEGIN SET @cha_tip=1 END SET @cha_kasa_hizmet=0 SET @cha_sntcek_poz=0 SET @cha_senet_cek_ref ='' DECLARE @cha_alt_doviz_kuru float DECLARE @cha_vergi_pntr_yeni int set @cha_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,1) DECLARE @cha_meblag float DECLARE @cha_aratoplam float DECLARE @cha_vergi1 float DECLARE @cha_vergi2 float DECLARE @cha_vergi3 float DECLARE @cha_vergi4 float DECLARE @cha_vergi5 float DECLARE @cha_iskonto1 float DECLARE @cha_iskonto2 float DECLARE @cha_iskonto3 float DECLARE @cha_iskonto4 float DECLARE @cha_iskonto5 float DECLARE @cha_iskonto6 float -- SELECT @cha_aratoplam=ISNULL(SUM(sth_tutar),0),@cha_iskonto1=ISNULL(SUM(sth_iskonto1),0),@cha_iskonto2=ISNULL(SUM(sth_iskonto2),0),@cha_iskonto3=ISNULL(SUM(sth_iskonto3),0),@cha_iskonto4=ISNULL(SUM(sth_iskonto4),0),@cha_iskonto5=ISNULL(SUM(sth_iskonto5),0),@cha_iskonto6=ISNULL(SUM(sth_iskonto6),0),@cha_meblag=ISNULL(SUM(sth_tutar-sth_iskonto1-sth_iskonto2-sth_iskonto3-sth_iskonto4-sth_iskonto5-sth_iskonto6),0) from STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno SELECT @cha_vergi1=ISNULL(SUM(sth_vergi),0) FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno and sth_vergi_pntr=1 SELECT @cha_vergi2=ISNULL(SUM(sth_vergi),0) FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno and sth_vergi_pntr=2 SELECT @cha_vergi3=ISNULL(SUM(sth_vergi),0) FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno and sth_vergi_pntr=3 SELECT @cha_vergi4=ISNULL(SUM(sth_vergi),0) FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno and sth_vergi_pntr=4 SELECT @cha_vergi5=ISNULL(SUM(sth_vergi),0) FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno and sth_vergi_pntr=5 SELECT @yeniEvrakMiCariHareket=COUNT(*) FROM CARI_HESAP_HAREKETLERI WHERE cha_evrakno_seri=@cha_evrakno_seri and cha_evrakno_sira=@cha_evrakno_sira and cha_cinsi=@cha_cinsi and cha_tip=@cha_tip and cha_normal_Iade=@cha_normal_Iade and cha_evrak_tip=@cha_evrak_tip and cha_belge_no=@sth_belgeno -- DECLARE @cha_Recno_Bul uniqueidentifier SELECT @cha_Recno_Bul=cha_Guid FROM CARI_HESAP_HAREKETLERI WHERE cha_evrakno_seri=@cha_evrakno_seri and cha_evrakno_sira=@cha_evrakno_sira and cha_cinsi=@cha_cinsi and cha_tip=@cha_tip and cha_normal_Iade=@cha_normal_Iade and cha_evrak_tip=@cha_evrak_tip and cha_belge_no=@sth_belgeno DECLARE @chaguid uniqueidentifier = NEWID(); IF @yeniEvrakMiCariHareket=0 --eklenecek yoksa update BEGIN INSERT INTO [dbo].[CARI_HESAP_HAREKETLERI] ([cha_Guid] ,[cha_DBCno] ,[cha_SpecRecNo] ,[cha_iptal] ,[cha_fileid] ,[cha_hidden] ,[cha_kilitli] ,[cha_degisti] ,[cha_CheckSum] ,[cha_create_user] ,[cha_create_date] ,[cha_lastup_user] ,[cha_lastup_date] ,[cha_special1] ,[cha_special2] ,[cha_special3] ,[cha_firmano] ,[cha_subeno] ,[cha_evrak_tip] ,[cha_evrakno_seri] ,[cha_evrakno_sira] ,[cha_satir_no] ,[cha_tarihi] ,[cha_tip] ,[cha_cinsi] ,[cha_normal_Iade] ,[cha_tpoz] ,[cha_ticaret_turu] ,[cha_belge_no] ,[cha_belge_tarih] ,[cha_aciklama] ,[cha_satici_kodu] ,[cha_EXIMkodu] ,[cha_projekodu] ,[cha_yat_tes_kodu] ,[cha_cari_cins] ,[cha_kod] ,[cha_ciro_cari_kodu] ,[cha_d_cins] ,[cha_d_kur] ,[cha_altd_kur] ,[cha_grupno] ,[cha_srmrkkodu] ,[cha_kasa_hizmet] ,[cha_kasa_hizkod] ,[cha_karsidcinsi] ,[cha_karsid_kur] ,[cha_karsidgrupno] ,[cha_karsisrmrkkodu] ,[cha_miktari] ,[cha_meblag] ,[cha_aratoplam] ,[cha_vade] ,[cha_Vade_Farki_Yuz] ,[cha_ft_iskonto1] ,[cha_ft_iskonto2] ,[cha_ft_iskonto3] ,[cha_ft_iskonto4] ,[cha_ft_iskonto5] ,[cha_ft_iskonto6] ,[cha_ft_masraf1] ,[cha_ft_masraf2] ,[cha_ft_masraf3] ,[cha_ft_masraf4] ,[cha_isk_mas1] ,[cha_isk_mas2] ,[cha_isk_mas3] ,[cha_isk_mas4] ,[cha_isk_mas5] ,[cha_isk_mas6] ,[cha_isk_mas7] ,[cha_isk_mas8] ,[cha_isk_mas9] ,[cha_isk_mas10] ,[cha_sat_iskmas1] ,[cha_sat_iskmas2] ,[cha_sat_iskmas3] ,[cha_sat_iskmas4] ,[cha_sat_iskmas5] ,[cha_sat_iskmas6] ,[cha_sat_iskmas7] ,[cha_sat_iskmas8] ,[cha_sat_iskmas9] ,[cha_sat_iskmas10] ,[cha_yuvarlama] ,[cha_StFonPntr] ,[cha_stopaj] ,[cha_savsandesfonu] ,[cha_avansmak_damgapul] ,[cha_vergipntr] ,[cha_vergi1] ,[cha_vergi2] ,[cha_vergi3] ,[cha_vergi4] ,[cha_vergi5] ,[cha_vergi6] ,[cha_vergi7] ,[cha_vergi8] ,[cha_vergi9] ,[cha_vergi10] ,[cha_vergisiz_fl] ,[cha_otvtutari] ,[cha_otvvergisiz_fl] ,[cha_oiv_pntr] ,[cha_oivtutari] ,[cha_oiv_vergi] ,[cha_oivergisiz_fl] ,[cha_fis_tarih] ,[cha_fis_sirano] ,[cha_trefno] ,[cha_sntck_poz] ,[cha_reftarihi] ,[cha_istisnakodu] ,[cha_pos_hareketi] ,[cha_meblag_ana_doviz_icin_gecersiz_fl] ,[cha_meblag_alt_doviz_icin_gecersiz_fl] ,[cha_meblag_orj_doviz_icin_gecersiz_fl] --,[cha_sip_recid_dbcno] ,[cha_sip_uid] --,[cha_kirahar_recid_dbcno] ,[cha_kirahar_uid] ,[cha_vardiya_tarihi] ,[cha_vardiya_no] ,[cha_vardiya_evrak_ti] ,[cha_ebelge_turu] ,[cha_tevkifat_toplam] ,[cha_ilave_edilecek_kdv1] ,[cha_ilave_edilecek_kdv2] ,[cha_ilave_edilecek_kdv3] ,[cha_ilave_edilecek_kdv4] ,[cha_ilave_edilecek_kdv5] ,[cha_ilave_edilecek_kdv6] ,[cha_ilave_edilecek_kdv7] ,[cha_ilave_edilecek_kdv8] ,[cha_ilave_edilecek_kdv9] ,[cha_ilave_edilecek_kdv10] ,[cha_e_islem_turu] ,[cha_fatura_belge_turu] ,[cha_diger_belge_adi] ,[cha_uuid] ,[cha_adres_no] ,[cha_vergifon_toplam]) VALUES ( @chaguid ,0-- ,0-- ,0-- ,51-- ,0-- ,0-- ,0-- ,0-- ,1-- ,getdate()-- ,1-- ,getdate()-- ,''-- ,''-- ,''-- ,0-- ,0-- ,@cha_evrak_tip-- ,@sth_evrakno_seri-- ,@sth_evrakno_sira-- ,0-- ,getdate()-- ,@cha_tip-- ,@cha_cinsi -- ,@sth_normal_iade-- ,0-- ,0-- ,@sth_belgeno-- ,@sth_tarih -- ,''-- ,@sth_plasiyer_kodu -- ,''-- ,''-- ,''-- ,0-- ,@sth_cari_kodu -- ,@sth_cari_kodu-- ,0-- ,1-- ,@sth_alt_doviz_kuru-- ,0-- ,''-- ,0-- ,''-- ,0-- ,@sth_alt_doviz_kuru-- ,0-- ,''-- ,0-- ,@cha_meblag-- ,@cha_aratoplam-- ,0-- ,0-- ,@cha_iskonto1-- ,@cha_iskonto2-- ,@cha_iskonto3-- ,@cha_iskonto4-- ,@cha_iskonto5-- ,@cha_iskonto6-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@cha_vergi1-- ,@cha_vergi2-- ,@cha_vergi3-- ,@cha_vergi4-- ,@cha_vergi5-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,''-- ,0-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,0-- ,0-- ,0-- --,0-- ,'00000000-0000-0000-0000-000000000000'-- --,0-- ,'00000000-0000-0000-0000-000000000000'-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,''-- ,''-- ,@sth_adres_no-- ,0-- ) DECLARE @cha_RECno nvarchar(100) SET @cha_RECno=CAST(@chaguid AS nvarchar(100)) --UPDATE CARI_HESAP_HAREKETLERI SET cha_RECid_RECno=@cha_RECno where cha_RECno<>cha_RECid_RECno UPDATE STOK_HAREKETLERI SET sth_fat_uid=@chaguid WHERE sth_Guid=@guid SELECT @KeyFieldValue=@cha_RECno END IF @yeniEvrakMiCariHareket>0 BEGIN UPDATE [dbo].[CARI_HESAP_HAREKETLERI] SET [cha_meblag] = @cha_meblag -- ,[cha_aratoplam] = @cha_aratoplam -- ,[cha_ft_iskonto1] = @cha_iskonto1 -- ,[cha_ft_iskonto2] = @cha_iskonto2-- ,[cha_ft_iskonto3] = @cha_iskonto3-- ,[cha_ft_iskonto4] = @cha_iskonto4-- ,[cha_ft_iskonto5] = @cha_iskonto5-- ,[cha_ft_iskonto6] = @cha_iskonto6-- ,[cha_vergi1] = @cha_vergi1 -- ,[cha_vergi2] = @cha_vergi2 -- ,[cha_vergi3] = @cha_vergi3 -- ,[cha_vergi4] = @cha_vergi4 -- ,[cha_vergi5] = @cha_vergi5 -- WHERE cha_Guid=@cha_RECno_bul UPDATE STOK_HAREKETLERI SET sth_fat_uid=@cha_Recno_Bul WHERE sth_Guid=@guid END SET @KeyFieldValue=@guid SET @LineNumber=@sth_satirno SELECT @KeyFieldValue AS KeyFieldValue,@sth_satirno as LineNumber END GO /****** Object: StoredProcedure [dbo].[sp_mbt_SaveInvoiceAll] Script Date: 10.07.2023 12:16:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_mbt_SaveInvoiceAll] ( @sth_belgeno nvarchar(16), @sth_evrakno_seri nvarchar(8), @sth_evrakno_sira int, @sth_tarih datetime, @sth_satirno int,--SIFIRDAN ARTARAK GIDIYOR MIKRODA @sth_belge_tarih datetime, @sth_plasiyer_kodu nvarchar(25), @sth_cari_kodu nvarchar(25), @sth_stok_kod nvarchar(25), @sth_b_fiyat float, @sth_miktar float, @sth_birim_pntr tinyint,--BIRIM FIYAT @sth_tutar float,--ISKONTOSUZ ARA TOPLAM @sth_iskonto1 float,--ISKONTO 1 TOPLAMI @sth_iskonto2 float,--ISKONTO 2 TOPLAMI @sth_iskonto3 float,--ISKONTO 3 TOPLAMI @sth_iskonto4 float,--ISKONTO 4 TOPLAMI @sth_iskonto5 float,--ISKONTO 5 TOPLAMI @sth_iskonto6 float,--ISKONTO 6 TOPLAMI @sth_vergi_pntr tinyint,-- 0 8 18 @sth_vergi float,-- ISKONTO DUSULDUKTEN SONRAKI KDV TOPLAMI @sth_aciklama nvarchar(50), @sth_aciklama2 nvarchar(50), @sth_cikis_depo_no int,--ZORUNLU GELMESI LAZIM @sth_doviz_kodu nvarchar(5),--TL USD EUR @sth_stok_sormerk nvarchar(25),-- YOKSA BOS GONDERILECEK @sth_adres_no int, @NormalIade int,--0 NORMAL 1 IADE @AlisSatis int, -- 1 SATIS 0 ALIS @sth_tip int, --0 Giriş 1 Çıkış 2 Dat @sth_cins int, --0:Toptan 1:Perakende 2:Dış Ticaret 3:Stok Virman 4:Fire 5:Sarf 6:Transfer 7:Üretim 8:Fason 9:Değer Farkı 10:Sayım 11:Stok Açılış 12:İthalat-İhracat 13:Hal 14:Müstahsil 15:Müstahsil Değer Farkı 14:Kabzımal 15:Gider Pusulas @sth_evraktip int,--0:Depo Çıkış Fişi 1:Çıkış İrsaliyesi 2:Depo Transfer Fişi 3:Giriş Faturası 4:Çıkış Faturası 5:Stoklara İthalat Masraf Yansıtma Dekontu 6:Stok Virman Fişi 7:Üretim Fişi 8:İlave Enflasyon Maliyet Fişi 9:Stoklara İlave Maliyet Yedirme Fişi 10:Antrepolardan Mal Millileştirme Fişi 11:Antrepolar Arası Transfer Fişi 12:Depo Giriş Fişi 13:Giriş İrsaliyesi 14:Fason Giriş Çıkış Fişi 15:Depolar Arası Satış Fişi 16:Stok Gider Pusulası Fişi 17:Depolar Arası Nakliye Fişi @ORDERFICHENO nvarchar(50), @ORDERLINENUMBER int, @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT --İlk once Carihareket Kayıt edilmeli Çünkü ID si stok hareketlerine yazılacak --yada en son update edilebilir. --ben ikinisini tercih edecegim. ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- gelen fis Numarasına göre evrak aktaracagız.... --sth_tip Tinyint Hareket Tipi 0:Giriş 1:Çıkış 2:Depo Transfer /* --sth_cins Tinyint Hareket Cinsi 0:Toptan 1:Perakende 2:Dış Ticaret 3:Stok Virman 4:Fire 5:Sarf 6:Transfer 7:Üretim 8:Fason 9:Değer Farkı 10:Sayım 11:Stok Açılış 12:İthalat-İhracat 13:Hal 14:Müstahsil 15:Müstahsil Değer Farkı 14:Kabzımal 15:Gider Pusulası **/ -- sth_normal_iade Tinyint Normal/Iade? 0:Normal 1:İade /* sth_evraktip Tinyint Evrak Tipi 0:Depo Çıkış Fişi 1:Çıkış İrsaliyesi 2:Depo Transfer Fişi 3:Giriş Faturası 4:Çıkış Faturası 5:Stoklara İthalat Masraf Yansıtma Dekontu 6:Stok Virman Fişi 7:Üretim Fişi 8:İlave Enflasyon Maliyet Fişi 9:Stoklara İlave Maliyet Yedirme Fişi 10:Antrepolardan Mal Millileştirme Fişi 11:Antrepolar Arası Transfer Fişi 12:Depo Giriş Fişi 13:Giriş İrsaliyesi 14:Fason Giriş Çıkış Fişi 15:Depolar Arası Satış Fişi 16:Stok Gider Pusulası Fişi 17:Depolar Arası Nakliye Fişi **/ --DECLARE @KeyFieldValue nvarchar(100) DECLARE @yeniEvrakSiraNo int DECLARE @yeniEvrakMi int DECLARE @sth_doviz_cinsi tinyint SELECT @sth_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu --SATIŞ FATURASI İÇİN DECLARE @sth_normal_iade int set @sth_normal_iade =@NormalIade declare @subeliCalismaVarmi int declare @sth_subeno int SET @sth_subeno=0 SELECT @subeliCalismaVarmi=COUNT(*) FROM MBTSISTEMPARAMETRELERI WHERE PARAMETREADI='SUBELICALISMA' AND DEGER='EVET' if @subeliCalismaVarmi=1 BEGIN select @sth_subeno=@sth_cikis_depo_no END else BEGIN set @sth_subeno=0 END DECLARE @sth_alt_doviz_kuru float DECLARE @sth_vergi_pntr_yeni int set @sth_alt_doviz_kuru=dbo.fn_FirmaAlternatifDovizKuru() SELECT @sth_vergi_pntr_yeni=T1.VERGIPNTR FROM ( SELECT 0 AS VERGIPNTR,dbo.fn_VergiIsim(0) AS KDVADI,dbo.fn_VergiYuzde(0) AS KDVORANI UNION SELECT 1 AS VERGIPNTR,dbo.fn_VergiIsim(1) AS KDVADI,dbo.fn_VergiYuzde(1) AS KDVORANI UNION SELECT 2 AS VERGIPNTR,dbo.fn_VergiIsim(2) AS KDVADI,dbo.fn_VergiYuzde(2) AS KDVORANI UNION SELECT 3 AS VERGIPNTR,dbo.fn_VergiIsim(3) AS KDVADI,dbo.fn_VergiYuzde(3) AS KDVORANI UNION SELECT 4 AS VERGIPNTR,dbo.fn_VergiIsim(4) AS KDVADI,dbo.fn_VergiYuzde(4) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 7 AS VERGIPNTR,dbo.fn_VergiIsim(7) AS KDVADI,dbo.fn_VergiYuzde(7) AS KDVORANI UNION SELECT 8 AS VERGIPNTR,dbo.fn_VergiIsim(8) AS KDVADI,dbo.fn_VergiYuzde(8) AS KDVORANI UNION SELECT 9 AS VERGIPNTR,dbo.fn_VergiIsim(9) AS KDVADI,dbo.fn_VergiYuzde(9) AS KDVORANI UNION SELECT 10 AS VERGIPNTR,dbo.fn_VergiIsim(10) AS KDVADI,dbo.fn_VergiYuzde(10) AS KDVORANI UNION SELECT 11 AS VERGIPNTR,dbo.fn_VergiIsim(11) AS KDVADI,dbo.fn_VergiYuzde(11) AS KDVORANI UNION SELECT 12 AS VERGIPNTR,dbo.fn_VergiIsim(12) AS KDVADI,dbo.fn_VergiYuzde(12) AS KDVORANI UNION SELECT 13 AS VERGIPNTR,dbo.fn_VergiIsim(13) AS KDVADI,dbo.fn_VergiYuzde(13) AS KDVORANI UNION SELECT 14 AS VERGIPNTR,dbo.fn_VergiIsim(14) AS KDVADI,dbo.fn_VergiYuzde(14) AS KDVORANI UNION SELECT 15 AS VERGIPNTR,dbo.fn_VergiIsim(15) AS KDVADI,dbo.fn_VergiYuzde(15) AS KDVORANI UNION SELECT 16 AS VERGIPNTR,dbo.fn_VergiIsim(16) AS KDVADI,dbo.fn_VergiYuzde(16) AS KDVORANI UNION SELECT 17 AS VERGIPNTR,dbo.fn_VergiIsim(17) AS KDVADI,dbo.fn_VergiYuzde(17) AS KDVORANI UNION SELECT 18 AS VERGIPNTR,dbo.fn_VergiIsim(18) AS KDVADI,dbo.fn_VergiYuzde(18) AS KDVORANI UNION SELECT 19 AS VERGIPNTR,dbo.fn_VergiIsim(19) AS KDVADI,dbo.fn_VergiYuzde(19) AS KDVORANI UNION SELECT 20 AS VERGIPNTR,dbo.fn_VergiIsim(20) AS KDVADI,dbo.fn_VergiYuzde(20) AS KDVORANI ) T1 WHERE T1.KDVORANI=@sth_vergi_pntr SET @sth_vergi_pntr=@sth_vergi_pntr_yeni DECLARE @sip_RECno uniqueidentifier SET @sip_RECno='00000000-0000-0000-0000-000000000000' if @ORDERFICHENO<>NULL BEGIN Select @sip_RECno=ISNULL(sip_Guid,'00000000-0000-0000-0000-000000000000') from SIPARISLER WHERE sip_belgeno=@ORDERFICHENO AND sip_satirno=@ORDERLINENUMBER and sip_musteri_kod=@sth_cari_kodu END -- Insert statements for procedure here DECLARE @guid uniqueidentifier = NEWID(); INSERT INTO [dbo].[STOK_HAREKETLERI] ([sth_Guid] ,[sth_DBCno] ,[sth_SpecRECno] ,[sth_iptal] ,[sth_fileid] ,[sth_hidden] ,[sth_kilitli] ,[sth_degisti] ,[sth_checksum] ,[sth_create_user] ,[sth_create_date] ,[sth_lastup_user] ,[sth_lastup_date] ,[sth_special1] ,[sth_special2] ,[sth_special3] ,[sth_firmano] ,[sth_subeno] ,[sth_tarih] ,[sth_tip] ,[sth_cins] ,[sth_normal_iade] ,[sth_evraktip] ,[sth_evrakno_seri] ,[sth_evrakno_sira] ,[sth_satirno] ,[sth_belge_no] ,[sth_belge_tarih] ,[sth_stok_kod] ,[sth_isk_mas1] ,[sth_isk_mas2] ,[sth_isk_mas3] ,[sth_isk_mas4] ,[sth_isk_mas5] ,[sth_isk_mas6] ,[sth_isk_mas7] ,[sth_isk_mas8] ,[sth_isk_mas9] ,[sth_isk_mas10] ,[sth_sat_iskmas1] ,[sth_sat_iskmas2] ,[sth_sat_iskmas3] ,[sth_sat_iskmas4] ,[sth_sat_iskmas5] ,[sth_sat_iskmas6] ,[sth_sat_iskmas7] ,[sth_sat_iskmas8] ,[sth_sat_iskmas9] ,[sth_sat_iskmas10] ,[sth_pos_satis] ,[sth_promosyon_fl] ,[sth_cari_cinsi] ,[sth_cari_kodu] ,[sth_cari_grup_no] ,[sth_isemri_gider_kodu] ,[sth_plasiyer_kodu] ,[sth_har_doviz_cinsi] ,[sth_har_doviz_kuru] ,[sth_alt_doviz_kuru] ,[sth_stok_doviz_cinsi] ,[sth_stok_doviz_kuru] ,[sth_miktar] ,[sth_miktar2] ,[sth_birim_pntr] ,[sth_tutar] ,[sth_iskonto1] ,[sth_iskonto2] ,[sth_iskonto3] ,[sth_iskonto4] ,[sth_iskonto5] ,[sth_iskonto6] ,[sth_masraf1] ,[sth_masraf2] ,[sth_masraf3] ,[sth_masraf4] ,[sth_vergi_pntr] ,[sth_vergi] ,[sth_masraf_vergi_pntr] ,[sth_masraf_vergi] ,[sth_netagirlik] ,[sth_odeme_op] ,[sth_aciklama] --,[sth_sip_recid_dbcno] ,[sth_sip_uid] --,[sth_fat_recid_dbcno] ,[sth_fat_uid] ,[sth_giris_depo_no] ,[sth_cikis_depo_no] ,[sth_malkbl_sevk_tarihi] ,[sth_cari_srm_merkezi] ,[sth_stok_srm_merkezi] ,[sth_fis_tarihi] ,[sth_fis_sirano] ,[sth_vergisiz_fl] ,[sth_maliyet_ana] ,[sth_maliyet_alternatif] ,[sth_maliyet_orjinal] ,[sth_adres_no] ,[sth_parti_kodu] ,[sth_lot_no] --,[sth_kons_recid_dbcno] ,[sth_kons_uid] ,[sth_proje_kodu] ,[sth_exim_kodu] ,[sth_otv_pntr] ,[sth_otv_vergi] ,[sth_brutagirlik] ,[sth_disticaret_turu] ,[sth_otvtutari] ,[sth_otvvergisiz_fl] ,[sth_oiv_pntr] ,[sth_oiv_vergi] ,[sth_oivvergisiz_fl] ,[sth_fiyat_liste_no] ,[sth_oivtutari] ,[sth_Tevkifat_turu] ,[sth_nakliyedeposu] ,[sth_nakliyedurumu] ,[sth_yetkili_uid] ,[sth_taxfree_fl] ,sth_ilave_edilecek_kdv ,sth_ismerkezi_kodu) VALUES (@guid ,0-- ,0-- ,0-- ,16-- ,0-- ,0-- ,0-- ,0-- ,1-- ,getdate() -- ,1-- ,getdate()-- ,''-- ,''-- ,''-- ,0-- ,0-- ,@sth_tarih -- ,@sth_tip-- ,@sth_cins-- ,@sth_normal_iade-- ,@sth_evraktip-- ,@sth_evrakno_seri -- ,@sth_evrakno_sira -- ,@sth_satirno-- ,@sth_belgeno-- ,@sth_tarih-- ,@sth_stok_kod-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@sth_cari_kodu-- ,0-- ,''-- ,@sth_plasiyer_kodu -- ,@sth_doviz_cinsi -- ,1-- ,1-- ,@sth_doviz_cinsi-- ,1-- ,@sth_miktar-- ,@sth_miktar-- ,@sth_birim_pntr-- ,@sth_tutar-- ,@sth_iskonto1-- ,@sth_iskonto2-- ,@sth_iskonto3-- ,@sth_iskonto4-- ,@sth_iskonto5-- ,@sth_iskonto6-- ,0-- ,0-- ,0-- ,0-- ,@sth_vergi_pntr-- ,@sth_vergi -- ,0-- ,0-- ,0-- ,0-- ,@sth_aciklama -- --,0-- ,@sip_RECno-- --,0-- ,'00000000-0000-0000-0000-000000000000'-- ,@sth_cikis_depo_no -- ,@sth_cikis_depo_no-- ,@sth_tarih-- ,''-- ,''-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_adres_no-- ,''-- ,0-- --,0-- ,'00000000-0000-0000-0000-000000000000'-- ,''-- ,''-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,1-- ,0-- ,0-- ,0-- ,0-- --,0-- ,'00000000-0000-0000-0000-000000000000'-- ,0-- ,0--sth_ilave_edilecek_kdv ,0--sth_ismerkezi_kodu ) DECLARE @sth_RECno uniqueidentifier SET @sth_RECno=NEWID(); --PRINT CONVERT(NVARCHAR(20),@sth_RECno) --UPDATE STOK_HAREKETLERI SET sth_SpecRECno=@sth_RECno where sth_Guid<>sth_SpecRECno SELECT @KeyFieldValue=@sth_RECno SELECT @KeyFieldValue AS KeyFieldValue,@sth_evrakno_seri as DocumentSerial,@sth_evrakno_sira as DocumentNumber,@sth_satirno as LineNumber --CARI HAREKET TABLOSUNA KAYIT DECLARE @yeniEvrakMiCariHareket int DECLARE @cha_doviz_cinsi tinyint DECLARE @cha_tip tinyint DECLARE @cha_cinsi tinyint DECLARE @cha_normal_Iade tinyint DECLARE @cha_evrak_tip tinyint DECLARE @cha_kasa_hizmet tinyint DECLARE @cha_sntcek_poz tinyint DECLARE @cha_vade nvarchar(8) SELECT @cha_vade=0--CONVERT(NVARCHAR,@sth_tarih,112) DECLARE @cha_senet_cek_ref nvarchar(50) SELECT @cha_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu DECLARE @cha_evrakno_seri NVARCHAR(8) DECLARE @cha_evrakno_sira int SET @cha_evrakno_seri=@sth_evrakno_seri SET @cha_evrakno_sira=@sth_evrakno_sira SET @cha_normal_Iade=@NormalIade if @sth_cins=0 SET @cha_cinsi=6 else SET @cha_cinsi=6 if @AlisSatis = 1 BEGIN SET @cha_tip=0 SET @cha_evrak_tip =63 END if @AlisSatis = 0 BEGIN SET @cha_tip=1 SET @cha_evrak_tip =0 END if @NormalIade=1 BEGIN SET @cha_tip=1 END SET @cha_kasa_hizmet=0 SET @cha_sntcek_poz=0 SET @cha_senet_cek_ref ='' DECLARE @cha_alt_doviz_kuru float DECLARE @cha_vergi_pntr_yeni int set @cha_alt_doviz_kuru=dbo.fn_FirmaAlternatifDovizKuru() DECLARE @cha_meblag float DECLARE @cha_aratoplam float DECLARE @cha_vergi1 float DECLARE @cha_vergi2 float DECLARE @cha_vergi3 float DECLARE @cha_vergi4 float DECLARE @cha_vergi5 float DECLARE @cha_iskonto1 float DECLARE @cha_iskonto2 float DECLARE @cha_iskonto3 float DECLARE @cha_iskonto4 float DECLARE @cha_iskonto5 float DECLARE @cha_iskonto6 float -- SELECT @cha_aratoplam=ISNULL(SUM(sth_tutar),0),@cha_iskonto1=ISNULL(SUM(sth_iskonto1),0),@cha_iskonto2=ISNULL(SUM(sth_iskonto2),0),@cha_iskonto3=ISNULL(SUM(sth_iskonto3),0),@cha_iskonto4=ISNULL(SUM(sth_iskonto4),0),@cha_iskonto5=ISNULL(SUM(sth_iskonto5),0),@cha_iskonto6=ISNULL(SUM(sth_iskonto6),0),@cha_meblag=ISNULL(SUM(sth_tutar-sth_iskonto1-sth_iskonto2-sth_iskonto3-sth_iskonto4-sth_iskonto5-sth_iskonto6 + sth_vergi ),0) from STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno SELECT @cha_vergi1=ISNULL(SUM(sth_vergi),0) FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno and sth_vergi_pntr=1 SELECT @cha_vergi2=ISNULL(SUM(sth_vergi),0) FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno and sth_vergi_pntr=2 SELECT @cha_vergi3=ISNULL(SUM(sth_vergi),0) FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno and sth_vergi_pntr=3 SELECT @cha_vergi4=ISNULL(SUM(sth_vergi),0) FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_evrakno_sira=@sth_evrakno_sira and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno and sth_vergi_pntr=4 SELECT @cha_vergi5=ISNULL(SUM(sth_vergi),0) FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_cins=@sth_cins and sth_tip=@sth_tip and sth_normal_iade=@sth_normal_iade and sth_evraktip=@sth_evraktip and sth_belge_no=@sth_belgeno and sth_vergi_pntr=5 SELECT @yeniEvrakMiCariHareket=COUNT(*) FROM CARI_HESAP_HAREKETLERI WHERE cha_evrakno_seri=@cha_evrakno_seri and cha_evrakno_sira=@cha_evrakno_sira and cha_cinsi=@cha_cinsi and cha_tip=@cha_tip and cha_normal_Iade=@cha_normal_Iade and cha_evrak_tip=@cha_evrak_tip and cha_belge_no=@sth_belgeno -- DECLARE @cha_Recno_Bul uniqueidentifier SELECT @cha_Recno_Bul=cha_Guid FROM CARI_HESAP_HAREKETLERI WHERE cha_evrakno_seri=@cha_evrakno_seri and cha_evrakno_sira=@cha_evrakno_sira and cha_cinsi=@cha_cinsi and cha_tip=@cha_tip and cha_normal_Iade=@cha_normal_Iade and cha_evrak_tip=@cha_evrak_tip and cha_belge_no=@sth_belgeno DECLARE @chaguid uniqueidentifier = NEWID(); IF @yeniEvrakMiCariHareket=0 --eklenecek yoksa update BEGIN INSERT INTO [dbo].[CARI_HESAP_HAREKETLERI] ([cha_Guid] ,[cha_DBCno] ,[cha_SpecRecNo] ,[cha_iptal] ,[cha_fileid] ,[cha_hidden] ,[cha_kilitli] ,[cha_degisti] ,[cha_CheckSum] ,[cha_create_user] ,[cha_create_date] ,[cha_lastup_user] ,[cha_lastup_date] ,[cha_special1] ,[cha_special2] ,[cha_special3] ,[cha_firmano] ,[cha_subeno] ,[cha_evrak_tip] ,[cha_evrakno_seri] ,[cha_evrakno_sira] ,[cha_satir_no] ,[cha_tarihi] ,[cha_tip] ,[cha_cinsi] ,[cha_normal_Iade] ,[cha_tpoz] ,[cha_ticaret_turu] ,[cha_belge_no] ,[cha_belge_tarih] ,[cha_aciklama] ,[cha_satici_kodu] ,[cha_EXIMkodu] ,[cha_projekodu] ,[cha_yat_tes_kodu] ,[cha_cari_cins] ,[cha_kod] ,[cha_ciro_cari_kodu] ,[cha_d_cins] ,[cha_d_kur] ,[cha_altd_kur] ,[cha_grupno] ,[cha_srmrkkodu] ,[cha_kasa_hizmet] ,[cha_kasa_hizkod] ,[cha_karsidcinsi] ,[cha_karsid_kur] ,[cha_karsidgrupno] ,[cha_karsisrmrkkodu] ,[cha_miktari] ,[cha_meblag] ,[cha_aratoplam] ,[cha_vade] ,[cha_Vade_Farki_Yuz] ,[cha_ft_iskonto1] ,[cha_ft_iskonto2] ,[cha_ft_iskonto3] ,[cha_ft_iskonto4] ,[cha_ft_iskonto5] ,[cha_ft_iskonto6] ,[cha_ft_masraf1] ,[cha_ft_masraf2] ,[cha_ft_masraf3] ,[cha_ft_masraf4] ,[cha_isk_mas1] ,[cha_isk_mas2] ,[cha_isk_mas3] ,[cha_isk_mas4] ,[cha_isk_mas5] ,[cha_isk_mas6] ,[cha_isk_mas7] ,[cha_isk_mas8] ,[cha_isk_mas9] ,[cha_isk_mas10] ,[cha_sat_iskmas1] ,[cha_sat_iskmas2] ,[cha_sat_iskmas3] ,[cha_sat_iskmas4] ,[cha_sat_iskmas5] ,[cha_sat_iskmas6] ,[cha_sat_iskmas7] ,[cha_sat_iskmas8] ,[cha_sat_iskmas9] ,[cha_sat_iskmas10] ,[cha_yuvarlama] ,[cha_StFonPntr] ,[cha_stopaj] ,[cha_savsandesfonu] ,[cha_avansmak_damgapul] ,[cha_vergipntr] ,[cha_vergi1] ,[cha_vergi2] ,[cha_vergi3] ,[cha_vergi4] ,[cha_vergi5] ,[cha_vergi6] ,[cha_vergi7] ,[cha_vergi8] ,[cha_vergi9] ,[cha_vergi10] ,[cha_vergisiz_fl] ,[cha_otvtutari] ,[cha_otvvergisiz_fl] ,[cha_oiv_pntr] ,[cha_oivtutari] ,[cha_oiv_vergi] ,[cha_oivergisiz_fl] ,[cha_fis_tarih] ,[cha_fis_sirano] ,[cha_trefno] ,[cha_sntck_poz] ,[cha_reftarihi] ,[cha_istisnakodu] ,[cha_pos_hareketi] ,[cha_meblag_ana_doviz_icin_gecersiz_fl] ,[cha_meblag_alt_doviz_icin_gecersiz_fl] ,[cha_meblag_orj_doviz_icin_gecersiz_fl] --,[cha_sip_recid_dbcno] ,[cha_sip_uid] --,[cha_kirahar_recid_dbcno] ,[cha_kirahar_uid] ,[cha_vardiya_tarihi] ,[cha_vardiya_no] ,[cha_vardiya_evrak_ti] ,[cha_ebelge_turu] ,[cha_tevkifat_toplam] ,[cha_ilave_edilecek_kdv1] ,[cha_ilave_edilecek_kdv2] ,[cha_ilave_edilecek_kdv3] ,[cha_ilave_edilecek_kdv4] ,[cha_ilave_edilecek_kdv5] ,[cha_ilave_edilecek_kdv6] ,[cha_ilave_edilecek_kdv7] ,[cha_ilave_edilecek_kdv8] ,[cha_ilave_edilecek_kdv9] ,[cha_ilave_edilecek_kdv10] ,[cha_e_islem_turu] ,[cha_fatura_belge_turu] ,[cha_diger_belge_adi] ,[cha_uuid] ,[cha_adres_no] ,[cha_vergifon_toplam]) VALUES ( @chaguid ,0-- ,0-- ,0-- ,51-- ,0-- ,0-- ,0-- ,0-- ,1-- ,getdate()-- ,1-- ,getdate()-- ,''-- ,''-- ,''-- ,0-- ,0-- ,@cha_evrak_tip-- ,@sth_evrakno_seri-- ,@sth_evrakno_sira-- ,0-- ,@sth_tarih-- ,@cha_tip-- ,@cha_cinsi -- ,@sth_normal_iade-- ,0-- ,0-- ,@sth_belgeno-- ,@sth_tarih -- ,''-- ,@sth_plasiyer_kodu -- ,''-- ,''-- ,''-- ,0-- ,@sth_cari_kodu -- ,@sth_cari_kodu-- ,@cha_doviz_cinsi-- ,dbo.fn_KurBul(GETDATE(),@cha_doviz_cinsi,1)-- ,@sth_alt_doviz_kuru-- ,0-- ,''-- ,0-- ,''-- ,0-- ,@sth_alt_doviz_kuru-- ,0-- ,''-- ,0-- ,@cha_meblag-- ,@cha_aratoplam-- ,0-- ,0-- ,@cha_iskonto1-- ,@cha_iskonto2-- ,@cha_iskonto3-- ,@cha_iskonto4-- ,@cha_iskonto5-- ,@cha_iskonto6-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@cha_vergi1-- ,@cha_vergi2-- ,@cha_vergi3-- ,@cha_vergi4-- ,@cha_vergi5-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,''-- ,0-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,0-- ,0-- ,0-- --,0-- ,'00000000-0000-0000-0000-000000000000'-- --,0-- ,'00000000-0000-0000-0000-000000000000'-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,''-- ,''-- ,@sth_adres_no-- ,0-- ) DECLARE @cha_RECno nvarchar(100) SET @cha_RECno=CAST(@chaguid AS nvarchar(100)) --UPDATE CARI_HESAP_HAREKETLERI SET cha_RECid_RECno=@cha_RECno where cha_RECno<>cha_RECid_RECno UPDATE STOK_HAREKETLERI SET sth_fat_uid=@chaguid WHERE sth_Guid=@guid SELECT @KeyFieldValue=@cha_RECno END IF @yeniEvrakMiCariHareket>0 BEGIN UPDATE [dbo].[CARI_HESAP_HAREKETLERI] SET [cha_meblag] = @cha_meblag -- ,[cha_aratoplam] = @cha_aratoplam -- ,[cha_ft_iskonto1] = @cha_iskonto1 -- ,[cha_ft_iskonto2] = @cha_iskonto2-- ,[cha_ft_iskonto3] = @cha_iskonto3-- ,[cha_ft_iskonto4] = @cha_iskonto4-- ,[cha_ft_iskonto5] = @cha_iskonto5-- ,[cha_ft_iskonto6] = @cha_iskonto6-- ,[cha_vergi1] = @cha_vergi1 -- ,[cha_vergi2] = @cha_vergi2 -- ,[cha_vergi3] = @cha_vergi3 -- ,[cha_vergi4] = @cha_vergi4 -- ,[cha_vergi5] = @cha_vergi5 -- WHERE cha_Guid=@cha_RECno_bul UPDATE STOK_HAREKETLERI SET sth_fat_uid=@cha_Recno_Bul WHERE sth_Guid=@guid END ELSE BEGIN UPDATE [dbo].[CARI_HESAP_HAREKETLERI] SET [cha_meblag] = @cha_meblag -- ,[cha_aratoplam] = @cha_aratoplam -- ,[cha_ft_iskonto1] = @cha_iskonto1 -- ,[cha_ft_iskonto2] = @cha_iskonto2-- ,[cha_ft_iskonto3] = @cha_iskonto3-- ,[cha_ft_iskonto4] = @cha_iskonto4-- ,[cha_ft_iskonto5] = @cha_iskonto5-- ,[cha_ft_iskonto6] = @cha_iskonto6-- ,[cha_vergi1] = @cha_vergi1 -- ,[cha_vergi2] = @cha_vergi2 -- ,[cha_vergi3] = @cha_vergi3 -- ,[cha_vergi4] = @cha_vergi4 -- ,[cha_vergi5] = @cha_vergi5 -- WHERE cha_Guid=@cha_RECno UPDATE STOK_HAREKETLERI SET sth_fat_uid=@cha_RECno WHERE sth_Guid=@guid END SET @KeyFieldValue=@guid SET @LineNumber=@sth_satirno SELECT @KeyFieldValue AS KeyFieldValue,@sth_satirno as LineNumber END GO /****** Object: StoredProcedure [dbo].[sp_MBT_SaveOrder] Script Date: 10.07.2023 12:16:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_MBT_SaveOrder] ( @sip_belgeno NVARCHAR(16), @sip_evrakno_seri NVARCHAR(8) , @sip_evrakno_sira int, @sip_tarih datetime, @sip_teslim_tarih datetime, @sip_tip int,@sip_cins int, @sip_satirno int,--SIFIRDA ARTARAK GIDIYOR MIKRODA @sip_belge_tarih datetime, @sip_satici_kod nvarchar(25), @sip_musteri_kod nvarchar(25), @sip_stok_kod nvarchar(25), @sip_b_fiyat float, @sip_miktar float, @sip_birim_pntr tinyint,--BIRIM FIYAT @sip_tutar float,--ISKONTOSUZ ARA TOPLAM @sip_iskonto_1 float,--ISKONTO 1 TOPLAMI @sip_iskonto_2 float,--ISKONTO 2 TOPLAMI @sip_iskonto_3 float,--ISKONTO 3 TOPLAMI @sip_iskonto_4 float,--ISKONTO 4 TOPLAMI @sip_iskonto_5 float,--ISKONTO 5 TOPLAMI @sip_iskonto_6 float,--ISKONTO 6 TOPLAMI @sip_vergi_pntr tinyint,-- 0 8 18 @sip_vergi float,-- ISKONTO DUSULDUKTEN SONRAKI KDV TOPLAMI @sip_aciklama nvarchar(50), @sip_aciklama2 nvarchar(50), @sip_depono int,--ZORUNLU GELMESI LAZIM @sip_doviz_kodu nvarchar(5),--TL USD EUR @sip_stok_sormerk nvarchar(25),-- YOKSA BOS GONDERILECEK @sip_adresno int, @MbtTakipNoAna nvarchar(50), @MbtTakipNoDetay nvarchar(50), @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- gelen fis Numarasına göre evrak aktaracagız.... --07 12 2020 2 declare @subeliCalismaVarmi int declare @sth_subeno int SET @sth_subeno=0 SELECT @subeliCalismaVarmi=COUNT(*) FROM MBTSISTEMPARAMETRELERI WHERE PARAMETREADI='SUBELICALISMA' AND DEGER='EVET' if @subeliCalismaVarmi=1 BEGIN select @sth_subeno=@sip_depono END else BEGIN set @sth_subeno=0 END DECLARE @sip_doviz_cinsi tinyint SELECT @sip_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sip_doviz_kodu DECLARE @sip_alt_doviz_kuru float DECLARE @sip_vergi_pntr_yeni int set @sip_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,1) SELECT @sip_vergi_pntr_yeni=T1.VERGIPNTR FROM ( SELECT 1 AS VERGIPNTR,dbo.fn_VergiIsim(1) AS KDVADI,dbo.fn_VergiYuzde(1) AS KDVORANI UNION SELECT 2 AS VERGIPNTR,dbo.fn_VergiIsim(2) AS KDVADI,dbo.fn_VergiYuzde(2) AS KDVORANI UNION SELECT 3 AS VERGIPNTR,dbo.fn_VergiIsim(3) AS KDVADI,dbo.fn_VergiYuzde(3) AS KDVORANI UNION SELECT 4 AS VERGIPNTR,dbo.fn_VergiIsim(4) AS KDVADI,dbo.fn_VergiYuzde(4) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 7 AS VERGIPNTR,dbo.fn_VergiIsim(7) AS KDVADI,dbo.fn_VergiYuzde(7) AS KDVORANI UNION SELECT 8 AS VERGIPNTR,dbo.fn_VergiIsim(8) AS KDVADI,dbo.fn_VergiYuzde(8) AS KDVORANI UNION SELECT 9 AS VERGIPNTR,dbo.fn_VergiIsim(9) AS KDVADI,dbo.fn_VergiYuzde(9) AS KDVORANI UNION SELECT 10 AS VERGIPNTR,dbo.fn_VergiIsim(10) AS KDVADI,dbo.fn_VergiYuzde(10) AS KDVORANI UNION SELECT 11 AS VERGIPNTR,dbo.fn_VergiIsim(11) AS KDVADI,dbo.fn_VergiYuzde(11) AS KDVORANI UNION SELECT 12 AS VERGIPNTR,dbo.fn_VergiIsim(12) AS KDVADI,dbo.fn_VergiYuzde(12) AS KDVORANI UNION SELECT 13 AS VERGIPNTR,dbo.fn_VergiIsim(13) AS KDVADI,dbo.fn_VergiYuzde(13) AS KDVORANI UNION SELECT 14 AS VERGIPNTR,dbo.fn_VergiIsim(14) AS KDVADI,dbo.fn_VergiYuzde(14) AS KDVORANI UNION SELECT 15 AS VERGIPNTR,dbo.fn_VergiIsim(15) AS KDVADI,dbo.fn_VergiYuzde(15) AS KDVORANI UNION SELECT 16 AS VERGIPNTR,dbo.fn_VergiIsim(16) AS KDVADI,dbo.fn_VergiYuzde(16) AS KDVORANI UNION SELECT 17 AS VERGIPNTR,dbo.fn_VergiIsim(17) AS KDVADI,dbo.fn_VergiYuzde(17) AS KDVORANI UNION SELECT 18 AS VERGIPNTR,dbo.fn_VergiIsim(18) AS KDVADI,dbo.fn_VergiYuzde(18) AS KDVORANI UNION SELECT 19 AS VERGIPNTR,dbo.fn_VergiIsim(19) AS KDVADI,dbo.fn_VergiYuzde(19) AS KDVORANI UNION SELECT 20 AS VERGIPNTR,dbo.fn_VergiIsim(20) AS KDVADI,dbo.fn_VergiYuzde(20) AS KDVORANI ) T1 WHERE T1.KDVORANI=@sip_vergi_pntr -- Insert statements for procedure here INSERT INTO [dbo].[SIPARISLER] ([sip_DBCno] ,[sip_SpecRECno] ,[sip_iptal] ,[sip_fileid] ,[sip_hidden] ,[sip_kilitli] ,[sip_degisti] ,[sip_checksum] ,[sip_create_user] ,[sip_create_date] ,[sip_lastup_user] ,[sip_lastup_date] ,[sip_special1] ,[sip_special2] ,[sip_special3] ,[sip_firmano] ,[sip_subeno] ,[sip_tarih] ,[sip_teslim_tarih] ,[sip_tip] ,[sip_cins] ,[sip_evrakno_seri] ,[sip_evrakno_sira] ,[sip_satirno] ,[sip_belgeno] ,[sip_belge_tarih] ,[sip_satici_kod] ,[sip_musteri_kod] ,[sip_stok_kod] ,[sip_b_fiyat] ,[sip_miktar] ,[sip_birim_pntr] ,[sip_teslim_miktar] ,[sip_tutar] ,[sip_iskonto_1] ,[sip_iskonto_2] ,[sip_iskonto_3] ,[sip_iskonto_4] ,[sip_iskonto_5] ,[sip_iskonto_6] ,[sip_masraf_1] ,[sip_masraf_2] ,[sip_masraf_3] ,[sip_masraf_4] ,[sip_vergi_pntr] ,[sip_vergi] ,[sip_masvergi_pntr] ,[sip_masvergi] ,[sip_opno] ,[sip_aciklama] ,[sip_aciklama2] ,[sip_depono] ,[sip_OnaylayanKulNo] ,[sip_vergisiz_fl] ,[sip_kapat_fl] ,[sip_promosyon_fl] ,[sip_cari_sormerk] ,[sip_stok_sormerk] ,[sip_cari_grupno] ,[sip_doviz_cinsi] ,[sip_doviz_kuru] ,[sip_alt_doviz_kuru] ,[sip_adresno] ,[sip_teslimturu] ,[sip_cagrilabilir_fl] ,[sip_prosip_uid] ,[sip_iskonto1] ,[sip_iskonto2] ,[sip_iskonto3] ,[sip_iskonto4] ,[sip_iskonto5] ,[sip_iskonto6] ,[sip_masraf1] ,[sip_masraf2] ,[sip_masraf3] ,[sip_masraf4] ,[sip_isk1] ,[sip_isk2] ,[sip_isk3] ,[sip_isk4] ,[sip_isk5] ,[sip_isk6] ,[sip_mas1] ,[sip_mas2] ,[sip_mas3] ,[sip_mas4] ,[sip_Exp_Imp_Kodu] ,[sip_kar_orani] ,[sip_durumu] ,[sip_stal_uid] ,[sip_planlananmiktar] ,[sip_teklif_uid] ,[sip_parti_kodu] ,[sip_lot_no] ,[sip_projekodu] ,[sip_fiyat_liste_no] ,[sip_Otv_Pntr] ,[sip_Otv_Vergi] ,[sip_otvtutari] ,[sip_OtvVergisiz_Fl] ,[sip_paket_kod] ,[sip_Rez_uid] ,[sip_harekettipi] ,[sip_yetkili_uid] ,[sip_kapatmanedenkod] ,[sip_gecerlilik_tarihi] ,[sip_onodeme_evrak_tip] ,[sip_onodeme_evrak_seri] ,[sip_onodeme_evrak_sira] ,[sip_rezervasyon_miktari] ,[sip_rezerveden_teslim_edilen]) VALUES (0 ,0 ,0 ,21 ,0 ,0 ,0 ,0 ,1 ,GETDATE() ,1 ,GETDATE() ,'mbt' ,'' ,'' ,0 ,@sth_subeno ,@sip_tarih --CONVERT(datetime,@sip_tarih,104) --@sip_tarih ,@sip_teslim_tarih --CONVERT(datetime,@sip_teslim_tarih,104)--@sip_teslim_tarih ,@sip_tip ,@sip_cins ,@sip_evrakno_seri ,@sip_evrakno_sira ,@sip_satirno ,@sip_belgeno ,@sip_belge_tarih --CONVERT(datetime,@sip_belge_tarih,104) -- @sip_belge_tarih ,@sip_satici_kod ,@sip_musteri_kod ,@sip_stok_kod ,@sip_b_fiyat ,@sip_miktar ,@sip_birim_pntr ,0 ,@sip_tutar ,@sip_iskonto_1 --ISKONTO1 TOPLAMI ,@sip_iskonto_2 --ISKONTO2 TOPLAMI ,@sip_iskonto_3 --ISKONTO3 TOPLAMI ,@sip_iskonto_4 --ISKONTO4 TOPLAMI ,@sip_iskonto_5 --ISKONTO5 TOPLAMI ,@sip_iskonto_6 --ISKONTO6 TOPLAMI ,0 ,0 ,0 ,0 ,@sip_vergi_pntr_yeni ,@sip_vergi ,0 ,0 ,0 ,@sip_aciklama ,@sip_aciklama2 ,@sip_depono ,0 ,0 ,0 ,0 ,'' ,@sip_stok_sormerk ,0 ,@sip_doviz_cinsi ,1 ,@sip_alt_doviz_kuru ,@sip_adresno ,'' ,1 ,'00000000-0000-0000-0000-000000000000' ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,'' ,0 ,0 ,'00000000-0000-0000-0000-000000000000' ,0 ,'00000000-0000-0000-0000-000000000000' ,'' ,0 ,'' ,1 ,0 ,0 ,0 ,0 ,'' ,'00000000-0000-0000-0000-000000000000' ,0 ,'00000000-0000-0000-0000-000000000000' ,'' ,CONVERT(datetime,'30-12-1899',104) -- '1899-12-30 00:00:00.000' ,0 ,'' ,0 ,0 ,0) DECLARE @sip_Guid nvarchar(50) DECLARE @sip_RECno nvarchar(50) SELECT @sip_Guid=sip_Guid FROM SIPARISLER where sip_evrakno_seri=@sip_evrakno_seri and sip_evrakno_sira=@sip_evrakno_sira and sip_satirno= @sip_satirno and sip_tip=@sip_tip and sip_cins= @sip_cins SET @KeyFieldValue=@sip_Guid SET @LineNumber=@sip_satirno SELECT @KeyFieldValue AS KeyFieldValue,@sip_satirno as LineNumber END GO /****** Object: StoredProcedure [dbo].[sp_MBT_SaveWarehouseTransfer] Script Date: 10.07.2023 12:16:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_MBT_SaveWarehouseTransfer] ( @sth_belge_no nvarchar(16), @sth_evrakno_seri nvarchar(8), @sth_evrakno_sira int, @sth_tarih datetime, @sth_vergi_pntr float, @sth_doviz_kodu nvarchar(3), @sth_satirno int, @sth_stok_kod nvarchar(25), @sth_plasiyer_kodu nvarchar(50), @sth_miktar float, @sth_birim_pntr int, @sth_tutar float, @sth_vergi float, @sth_aciklama nvarchar(50), @sth_giris_depo_no int, @sth_cikis_depo_no int, @sth_parti_kodu nvarchar(25), @sth_lot_no int, @ChHar_SeriNo nvarchar(25), @MbtTakipNoAna nvarchar(50), @MbtTakipNoDetay nvarchar(50), @KeyFieldValue uniqueidentifier OUTPUT, @LineNumber int OUTPUT ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- gelen fis Numarasına göre evrak aktaracagız.... --07 12 2020 1 declare @subeliCalismaVarmi int declare @sth_subeno int SET @sth_subeno=0 SELECT @subeliCalismaVarmi=COUNT(*) FROM MBTSISTEMPARAMETRELERI WHERE PARAMETREADI='SUBELICALISMA' AND DEGER='EVET' if @subeliCalismaVarmi=1 BEGIN select @sth_subeno=@sth_cikis_depo_no END else BEGIN set @sth_subeno=0 END DECLARE @yeniEvrakSiraNo int --DECLARE @yeniEvrakMi int DECLARE @sth_doviz_cinsi tinyint SELECT @sth_doviz_cinsi=Kur_No FROM MikroDB_V16.dbo.KUR_ISIMLERI where Kur_sembol=@sth_doviz_kodu SET @sth_evrakno_seri=@sth_evrakno_seri --SELECT @yeniEvrakMi=COUNT(*) FROM STOK_HAREKETLERI WHERE sth_evrakno_seri=@sth_evrakno_seri and sth_cins=6 and sth_tip=2 and sth_normal_iade=0 and sth_evraktip=2 and sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira = @sth_evrakno_sira DECLARE @sth_alt_doviz_kuru float DECLARE @sth_vergi_pntr_yeni int set @sth_alt_doviz_kuru=dbo.fn_KurBul(GetDate(),1,1) SELECT TOP 1 @sth_vergi_pntr_yeni=T1.VERGIPNTR FROM ( SELECT 0 AS VERGIPNTR,dbo.fn_VergiIsim(0) AS KDVADI,dbo.fn_VergiYuzde(0) AS KDVORANI UNION SELECT 1 AS VERGIPNTR,dbo.fn_VergiIsim(1) AS KDVADI,dbo.fn_VergiYuzde(1) AS KDVORANI UNION SELECT 2 AS VERGIPNTR,dbo.fn_VergiIsim(2) AS KDVADI,dbo.fn_VergiYuzde(2) AS KDVORANI UNION SELECT 3 AS VERGIPNTR,dbo.fn_VergiIsim(3) AS KDVADI,dbo.fn_VergiYuzde(3) AS KDVORANI UNION SELECT 4 AS VERGIPNTR,dbo.fn_VergiIsim(4) AS KDVADI,dbo.fn_VergiYuzde(4) AS KDVORANI UNION SELECT 5 AS VERGIPNTR,dbo.fn_VergiIsim(5) AS KDVADI,dbo.fn_VergiYuzde(5) AS KDVORANI UNION SELECT 6 AS VERGIPNTR,dbo.fn_VergiIsim(6) AS KDVADI,dbo.fn_VergiYuzde(6) AS KDVORANI UNION SELECT 7 AS VERGIPNTR,dbo.fn_VergiIsim(7) AS KDVADI,dbo.fn_VergiYuzde(7) AS KDVORANI UNION SELECT 8 AS VERGIPNTR,dbo.fn_VergiIsim(8) AS KDVADI,dbo.fn_VergiYuzde(8) AS KDVORANI UNION SELECT 9 AS VERGIPNTR,dbo.fn_VergiIsim(9) AS KDVADI,dbo.fn_VergiYuzde(9) AS KDVORANI UNION SELECT 10 AS VERGIPNTR,dbo.fn_VergiIsim(10) AS KDVADI,dbo.fn_VergiYuzde(10) AS KDVORANI UNION SELECT 11 AS VERGIPNTR,dbo.fn_VergiIsim(11) AS KDVADI,dbo.fn_VergiYuzde(11) AS KDVORANI UNION SELECT 12 AS VERGIPNTR,dbo.fn_VergiIsim(12) AS KDVADI,dbo.fn_VergiYuzde(12) AS KDVORANI UNION SELECT 13 AS VERGIPNTR,dbo.fn_VergiIsim(13) AS KDVADI,dbo.fn_VergiYuzde(13) AS KDVORANI UNION SELECT 14 AS VERGIPNTR,dbo.fn_VergiIsim(14) AS KDVADI,dbo.fn_VergiYuzde(14) AS KDVORANI UNION SELECT 15 AS VERGIPNTR,dbo.fn_VergiIsim(15) AS KDVADI,dbo.fn_VergiYuzde(15) AS KDVORANI UNION SELECT 16 AS VERGIPNTR,dbo.fn_VergiIsim(16) AS KDVADI,dbo.fn_VergiYuzde(16) AS KDVORANI UNION SELECT 17 AS VERGIPNTR,dbo.fn_VergiIsim(17) AS KDVADI,dbo.fn_VergiYuzde(17) AS KDVORANI UNION SELECT 18 AS VERGIPNTR,dbo.fn_VergiIsim(18) AS KDVADI,dbo.fn_VergiYuzde(18) AS KDVORANI UNION SELECT 19 AS VERGIPNTR,dbo.fn_VergiIsim(19) AS KDVADI,dbo.fn_VergiYuzde(19) AS KDVORANI UNION SELECT 20 AS VERGIPNTR,dbo.fn_VergiIsim(20) AS KDVADI,dbo.fn_VergiYuzde(20) AS KDVORANI ) T1 WHERE T1.KDVORANI=@sth_vergi_pntr ORDER BY VERGIPNTR ASC SET @sth_vergi_pntr=@sth_vergi_pntr_yeni -- Insert statements for procedure here INSERT INTO [dbo].[STOK_HAREKETLERI] ([sth_DBCno] ,[sth_SpecRECno] ,[sth_iptal] ,[sth_fileid] ,[sth_hidden] ,[sth_kilitli] ,[sth_degisti] ,[sth_checksum] ,[sth_create_user] ,[sth_create_date] ,[sth_lastup_user] ,[sth_lastup_date] ,[sth_special1] ,[sth_special2] ,[sth_special3] ,[sth_firmano] ,[sth_subeno] ,[sth_tarih] ,[sth_tip] ,[sth_cins] ,[sth_normal_iade] ,[sth_evraktip] ,[sth_evrakno_seri] ,[sth_evrakno_sira] ,[sth_satirno] ,[sth_belge_no] ,[sth_belge_tarih] ,[sth_stok_kod] ,[sth_isk_mas1] ,[sth_isk_mas2] ,[sth_isk_mas3] ,[sth_isk_mas4] ,[sth_isk_mas5] ,[sth_isk_mas6] ,[sth_isk_mas7] ,[sth_isk_mas8] ,[sth_isk_mas9] ,[sth_isk_mas10] ,[sth_sat_iskmas1] ,[sth_sat_iskmas2] ,[sth_sat_iskmas3] ,[sth_sat_iskmas4] ,[sth_sat_iskmas5] ,[sth_sat_iskmas6] ,[sth_sat_iskmas7] ,[sth_sat_iskmas8] ,[sth_sat_iskmas9] ,[sth_sat_iskmas10] ,[sth_pos_satis] ,[sth_promosyon_fl] ,[sth_cari_cinsi] ,[sth_cari_kodu] ,[sth_cari_grup_no] ,[sth_isemri_gider_kodu] ,[sth_plasiyer_kodu] ,[sth_har_doviz_cinsi] ,[sth_har_doviz_kuru] ,[sth_alt_doviz_kuru] ,[sth_stok_doviz_cinsi] ,[sth_stok_doviz_kuru] ,[sth_miktar] ,[sth_miktar2] ,[sth_birim_pntr] ,[sth_tutar] ,[sth_iskonto1] ,[sth_iskonto2] ,[sth_iskonto3] ,[sth_iskonto4] ,[sth_iskonto5] ,[sth_iskonto6] ,[sth_masraf1] ,[sth_masraf2] ,[sth_masraf3] ,[sth_masraf4] ,[sth_vergi_pntr] ,[sth_vergi] ,[sth_masraf_vergi_pntr] ,[sth_masraf_vergi] ,[sth_netagirlik] ,[sth_odeme_op] ,[sth_aciklama] ,[sth_sip_uid] ,[sth_fat_uid] ,[sth_giris_depo_no] ,[sth_cikis_depo_no] ,[sth_malkbl_sevk_tarihi] ,[sth_cari_srm_merkezi] ,[sth_stok_srm_merkezi] ,[sth_fis_tarihi] ,[sth_fis_sirano] ,[sth_vergisiz_fl] ,[sth_maliyet_ana] ,[sth_maliyet_alternatif] ,[sth_maliyet_orjinal] ,[sth_adres_no] ,[sth_parti_kodu] ,[sth_lot_no] ,[sth_kons_uid] ,[sth_proje_kodu] ,[sth_exim_kodu] ,[sth_otv_pntr] ,[sth_otv_vergi] ,[sth_brutagirlik] ,[sth_disticaret_turu] ,[sth_otvtutari] ,[sth_otvvergisiz_fl] ,[sth_oiv_pntr] ,[sth_oiv_vergi] ,[sth_oivvergisiz_fl] ,[sth_fiyat_liste_no] ,[sth_oivtutari] ,[sth_Tevkifat_turu] ,[sth_nakliyedeposu] ,[sth_nakliyedurumu] ,[sth_yetkili_uid] ,[sth_taxfree_fl]) VALUES (0-- ,0-- ,0-- ,16-- ,0-- ,0-- ,0-- ,0-- ,1-- ,getdate() -- ,1-- ,getdate()-- ,'mbt'-- ,''-- ,''-- ,0-- ,@sth_subeno-- ,@sth_tarih -- ,2-- ,6-- ,0-- ,2-- ,@sth_evrakno_seri -- ,@sth_evrakno_sira -- ,@sth_satirno-- ,@sth_belge_no-- ,@sth_tarih-- ,@sth_stok_kod-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,1-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,''-- ,0-- ,''-- ,@sth_plasiyer_kodu -- ,@sth_doviz_cinsi -- ,1-- ,1-- ,@sth_doviz_cinsi-- ,1-- ,@sth_miktar-- ,@sth_miktar-- ,@sth_birim_pntr-- ,@sth_tutar-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,@sth_vergi_pntr-- ,@sth_vergi -- ,0-- ,0-- ,0-- ,0-- ,@sth_aciklama -- ,'00000000-0000-0000-0000-000000000000'-- ,'00000000-0000-0000-0000-000000000000'-- ,@sth_giris_depo_no -- ,@sth_cikis_depo_no -- ,@sth_tarih -- ,''-- ,''-- ,CONVERT(datetime,'30-12-1899',104)--'1899-12-30 00:00:00.000'-- ,0-- ,0-- ,@sth_tutar-- ,@sth_tutar-- ,@sth_tutar-- ,1-- ,@sth_parti_kodu-- ,@sth_lot_no -- ,'00000000-0000-0000-0000-000000000000'-- ,''-- ,''-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,0-- ,1-- ,0-- ,0-- ,0-- ,0-- ,'00000000-0000-0000-0000-000000000000'-- ,0-- ) DECLARE @sth_Guid nvarchar(50) DECLARE @sth_RECno int SELECT @sth_Guid=sth_Guid FROM STOK_HAREKETLERI where sth_evrakno_seri=@sth_evrakno_seri and sth_evrakno_sira=@sth_evrakno_sira and sth_satirno= @sth_satirno and sth_tip=2 and sth_cins= 6 and sth_evraktip=2 and sth_normal_iade= 0 SET @KeyFieldValue=@sth_Guid SET @LineNumber=@sth_satirno SELECT @KeyFieldValue AS KeyFieldValue,@sth_satirno as LineNumber END GO