Popravek podatkov za naročila


select so.id, so.count_code, so.customer_order, so.doc_date, so.validation_error, so.partner_text, rpn.id, rpn.partner_naslov_text, rpn.sticker_uri, rpn.created_ts, u.EMAIL, al.id, al.app_assignment_id
, rpn.tracking_code
, concat('delete from dispatch_app_order_assignments_list where id = ',al.id,';')
, concat('update racuni_prodaja_nabava set tracking_code = null where company_id = 2856 and id = ',rpn.id,';')
from sales_order so
   left join dispatch_app_order_assignments_list al on (al.company_id = so.company_id and al.sales_order_id = so.id)
   left join dispatch_app_order_assignments a on (a.company_id = al.company_id and a.id = al.app_assignment_id)
   left join mk_users u on (u.user_id = a.assigned_user_id and u.company_id = a.company_id)
, document_links dl, racuni_prodaja_nabava rpn
where so.company_id = 2856 and so.status_id = 285600000063 and so.vrsta_dostave_id = 285600014872
and dl.dest_doc_id = so.id and dl.company_id = so.company_id and rpn.id = dl.source_doc_id and rpn.company_id = dl.company_id
and a.id = 781;


select * from dispatch_app_order_assignments order by id desc;
select * from dispatch_app_order_assignments_list order by id desc;