Proszę o zmianę kontrahenta w dokumencie "PZ/98/300/1121" z W01311
PLASTIXAL KOŁAKOWSKI MARIUSZ na X48110 PLASTIXAL SPÓŁKA Z OGRANICZONĄ
ODPOWIEDZIALNOŚCIĄ
Zmiana kontrahenta na dokumencie magazynowym wymaga jedynie zmiany firmid w nagłowku - document.document
Dodatkowo zmiana na fakturze powiązanej wymaga jedynie zmiany issuerid,
Begintransactiondeclare@documentIDuniqueidentifierdeclare@invoiceIDuniqueidentifierdeclare@newfirmIDuniqueidentifierdeclare@oldfirmIDuniqueidentifierdeclare@documentfullnrvarchar(20)='PZ/98/300/1121'--<<<<<wypelnijselecttop1@oldfirmID=firmidfromfirm.firmwherefirmnr='W01311'andstatus>-1--<<<<<wypelnijselecttop1@newfirmID=firmidfromfirm.firmwherefirmnr='X48110'andstatus>-1--<<<<<wypelnijselect@documentid=documentidfromdocument.documentwheredocumentfullnr=@documentfullnrandfirmid=@oldfirmidif(@documentidisnullor@oldfirmIDisnullor@newfirmIDisnull)Beginraiserror('Dokument nieistnieje ',16,1);Endif(@oldfirmIDisnull)Beginraiserror('stara firma nie istnieje nieistnieje ',16,1);Endif(@newfirmIDisnull)Beginraiserror('nowa firma nieistnieje ',16,1);End--dokument magazynowyupdatedocument.documentsetfirmid=@newfirmIDwheredocumentid=@documentidrollbacktransaction--FZ--update document.invoice set issuerID=@newfirmID where invoiceid=@invoiceid