Skip to content

Zmiana powiazan wz zs

Przykład zgłoszenia:

Prośba o zmianę powiązania WZ poz 4: Zamiast ZS001/202108 poz 4 powinno być ZS002/202108 poz 1

Rozwiązanie

  1. Odnalezc odpowiednie numery id

    SQL
    select o.orderid,ol.orderlineid from document.[order] o
    inner join document.orderline ol
    on o.orderid = ol.orderid where
    orderFullNR='ZS001/202108' --zamiast ZS001/202108 poz 4  powinno byc ZS002/202108    poz 1
    and ol.orderOrdinalNumber =4
    
    select dl.* from document.document d inner join document.documentline dl
    on d.documentid =dl.documentid
    where d.documentid = '99c6a549-e337-ec11-957c-d89d6719e0ca'
    and d.status >-1
    and dl.status >-1
    

  2. wykonac zmiane

SQL
1
2
3
4
5
6
7
8
update document.documentline set
  orderlineid = 'F71863A9-FBF8-EB11-9578-D89D6719E0CB'
where documentLineID='3C9C755F-E337-EC11-9BF1-2C768A5328B2'

update document.orderLine set
    orderLineStatus =3,  --zrealizowane
    itemquantityleft=0   --zrealizowane
where orderlineid ='NOWY'
  1. na starym ustawic status niezrealizwoane
SQL
1
2
3
4
update document.orderLine set
    orderLineStatus =0,
    itemquantityleft=itemquantity
where orderlineid ='STARY'