select tInv.IDInv, tInv.IDStockDist, tInv.IDDist, tInv.IDUser, tInv.IDDate, tInv.Price,
tDist.Code as DistCode, tDist.Code as SellerDistCode, tDist.Name as DistName, tDist.Email as DistMail, tUser.Name as UserName,
tCust.IDCust, tCust.Code as CustCode, tCust.Name as CustName, tCustShape.Name as CustShape,
tSeller.Code as SellerCode, tSeller.Name as SellerName, t.Onay, SUM(tInvItem.Amount) as Amount,
REPLACE(tStock1.Code, 'ASM-','') StockCode1, REPLACE(tStock2.Code, 'ASM-','') StockCode2, tSellerTree.Code SellerTreeCode, tSellerTree.Name SellerTreeName
from tInv (nolock)
inner join tDist (nolock) on tInv.IDStockDist=tDist.IDDist
inner join tUser (nolock) on tInv.IDDist=tUser.IDDist and tInv.IDUser=tUser.IDUser
inner join tCust (nolock) on tInv.IDCust2=tCust.IDCust
inner join tCustShape (nolock) on tCust.IDCustShape=tCustShape.IDCustShape
inner join tSeller (nolock) on tInv.IDSellerDist=tSeller.IDDist and tInv.IDSeller=tSeller.IDSeller
inner join (
select t.IDInv, t.IDDist, t.IDUser, t.IDDate, 1 as Onay from (
select tInv.IDInv, tInv.IDDist, tInv.IDUser, tInv.IDDate, tInv.IDStockDist, tInv.IDCust,
SUM(tInvItem.Amount) as Amount
from tInv (nolock)
inner join tInvItem (nolock) on tInv.IDInv=tInvItem.IDInv
where tInv.IDInvShape=4 and tInv.Dir=0 and tInv.InvType=0 and tInv.IDInvOp=4 and tInv.DocStatus=2 and tInv.IDInv= 253636257
group by tInv.IDInv, tInv.IDDist, tInv.IDUser, tInv.IDDate, tInv.IDStockDist, tInv.IDCust
) t
left join tCustProp (nolock) on t.IDCust=tCustProp.IDCust and tCustProp.IDProp=27
group by t.IDInv, t.IDDist, t.IDUser, t.IDDate
) t on tInv.IDInv=t.IDInv
inner join tInvItem (nolock) on tInv.IDInv=tInvItem.IDInv
left join tStock tStock1 (nolock) on tStock1.IDDist=tInv.IDStockDist and tStock1.IDStock=tInv.IDStock
left join tStock tStock2 (nolock) on tStock2.IDDist=tInv.IDStockDist and tStock2.IDStock=tInv.IDStock2
inner join tSellerTree (nolock) on tSellerTree.IDSellerTreeShape=1 and tSellerTree.Code=REPLACE(tStock1.Code, 'ASM-','')
where tInv.IDInvShape=4 and tInv.Dir=0 and tInv.InvType=0 and tInv.IDInvOp=4 and tInv.DocStatus=2 and tInv.IDInv= 253636257
group by tInv.IDInv, tInv.IDStockDist, tInv.IDDist, tInv.IDUser, tInv.IDDate, tInv.Price,
tDist.Code, tDist.Code, tDist.Name, tDist.Email, tUser.Name,
tCust.IDCust, tCust.Code, tCust.Name, tCustShape.Name, tSeller.Code, tSeller.Name, t.Onay, tStock1.Code, tStock2.Code, tSellerTree.Code, tSellerTree.Name
order by tInv.IDDist, tInv.IDUser, tInv.IDDate
option(force order)
-- Onay 1 olduğu zaman iş onaya gidiyor.
-- Onay 0 olduğu zaman otomatik onaylıyor. Editing=0, DocStatus=3, WFStatus=1
--select tSubject.Name,tJob.IDJob,tJob.IDFirm,tJob.IDSubject,SGOCode,ReqName,ReqMail,Header,SepCode,Degree,Status,tJob.Note,Sent,ImagePath,IsPrinted,DistCode,ConfirmDate,CDate,IDConfirmUser,OldJob
--from WORKFLOW..tJob (nolock)
--inner join WORKFLOW..tSubject on tSubject.IDSubject=tJob.IDSubject where tJob.IDSubject=37 and CDate>='2024-10-01'
--and SGOCODE=253636257
--exec WORKFLOW.dbo.spJobSearchUser '253636257'
select * from WorkFlow..tUser (nolock) where Name like '%Mustafa Ahmet Aydogan%'
select * from tSubject
select * from tSchema where IDSchema=114
select tSubject.Name,tJob.IDJob,tJob.IDFirm,tJob.IDSubject,SGOCode,ReqName,ReqMail,Header,SepCode,Degree,Status,tJob.Note,Sent,ImagePath,IsPrinted,DistCode,ConfirmDate,CDate,IDConfirmUser,OldJob
from tJob (nolock)
inner join tSubject on tSubject.IDSubject=tJob.IDSubject where tJob.IDSubject=37 and CDate>='2024-10-01'
and SGOCODE=253636257
--select * from Voyage..tInvOp (nolock) where Name='Promosyonel Depo Transferi'
select * from Voyage..tInv(nolock) where IDInvShape=4 and Dir=0 and InvType=0 and IDInvOp=4 and IDDate>='2024-10-01' and IDInv=253636257
select * from Voyage..tUSer where IDdist=218 and IDUSer=45
Kayoka ID:269858