CREATE OR ALTER VIEW V_Plasiyer_Raporu
AS
select sipdb.IslemNo,sipdb.SiparisTarihi,sipdb.IslemTuru,siph.CariKodu,siph.CariAdi,siph.StokKodu, siph.StokAdi,siph.Miktar,siph.KalanMiktar,siph.Birim,siph.BirimFiyat,siph.Kdv,siph.KdvTutari,
	   (siph.SonTutar/Miktar) * KalanMiktar KalanSiparisTutar,siph.Satici,(select SaticiAdi from Satici s where s.SaticiKodu = siph.Satici) SaticiAdi,sipdb.KULNO
  from SIPARISHARDETBAG sipdb,
       SIPARISHAR siph
 where sipdb.IslemNo = siph.IslemNo and sipdb.AcikKapali = 'A'
   and KalanMiktar > 0
   and sipdb.IslemTuru = 'Alınan'
union all
select sdb.IslemNo,sdb.FaturaTarihi, sdb.IslemTuru, sdb.CariKodu,sdb.CariAdi,sh.StokKodu, sh.StokAdi,sh.Miktar,Miktar,sh.Birim,sh.BirimFiyat,sh.Kdv,sh.KdvTutari,
	   SonTutar,sh.Satici,(select SaticiAdi from Satici s where s.SaticiKodu = sh.Satici) SaticiAdi,sdb.KULNO
  from STOKHARDETBAG sdb,
       STOKHAR sh
 where sdb.IslemNo = sh.IslemNo
   and sh.GC in ('G','C')
   and sdb.IslemTuru <> 'Bakım'

  
   
