Sprawdzenia wszystkich dokumentów powiązanych z partia która jest korygowana
select d.documentFullNR,d.documentdate from document.documentline dl inner join document.document d on d.documentID =dl.documentID
where initialIncomeSourceLineID ='C6774A52-1206-EA11-8424-7ED30A52F64F' --<<partia ktorej dotyczy documentlineid
order by d.documentdate
BEGINTRANSACTIONdeclare@documentiduniqueidentifier='114ca0e5-9d8d-e911-80d8-9c8e994dc647'declare@itemiduniqueidentifierdeclare@documentLineToRemovetable(documentLineIDuniqueidentifier,sourceDocumentLineIDuniqueidentifier,itemIDuniqueidentifier,itemQuantitydecimal(18,3),sysItemValuedecimal(18,2))insertinto@documentLineToRemoveselectdocumentLineID,sourceDocumentLineID,itemID,itemQuantity,sysItemValuefromdocument.documentLinewhere[status]=1anddocumentID=@documentid--Kasowanie naglowkaupdatedocument.documentsetstatus=-1wheredocumentid=@documentid;--Kasowanie pozycjiupdatedocument.documentlinesetstatus=-1wheredocumentid=@documentid;-- Przeliczenie stanowwhileexists(select*from@documentLineToRemove)beginselecttop1@itemid=itemIDfrom@documentLineToRemovedeletefrom@documentLineToRemovewhereitemID=@itemidsetnocountoffexecwms.stockBalanceFix@username='admin.admin',@itemID=@itemidsetnocountonend-- UWAGA Jesli pw trzeba cofnac ilosc na zleceniu-- UWAGA jesli rozchod trzeba cofnac ilosci z dostawy-- UWAGa numerator trzeba cofnac-- delete from common.numerator where remotesource = 'document' and series like 'wz3000619%'ROLLBACKTRANSACTION--COMMIT TRANSACTIONKROK2-- Cofniecie numeracjiselect*fromcommon.numeratorwhereserieslike'MM+13001119%'