Товарный отчет не сходится
Попробуйте выполнить скрипт
update doc_detail dd set price = (select price from parts p where p.id = dd.part_id) where abs(price -(select price from parts p where p.id = dd.part_id))>0.01;
update doc_detail set summa = (price*quant+sum_dsc) where abs(summa-(price*quant+sum_dsc))>0.01;
update docs d set d.summa = (select sum(dd.quant*p.price+dd.sum_dsc) from doc_detail dd left join parts p on dd.part_id = p.id where dd.doc_id = d.id) where abs(d.summa - (select sum(dd.quant*p.price+dd.sum_dsc) from doc_detail dd left join parts p on dd.part_id = p.id where dd.doc_id = d.id)) > 0.01;
update doc_detail dd1 set dd1.summa_o = (select p.price_o*dd.quant from doc_detail dd left join parts p on dd.part_id = p.id where dd.id = dd1.id) where abs(dd1.summa_o - (select p.price_o*dd.quant from doc_detail dd left join parts p on dd.part_id = p.id where dd.id = dd1.id)) > 0.01;
update docs d set d.summa_o = (select sum(dd.quant*p.price_o) from doc_detail dd left join parts p on dd.part_id = p.id where dd.doc_id = d.id) where abs(summa_o - (select sum(dd.quant*p.price_o) from doc_detail dd left join parts p on dd.part_id = p.id where dd.doc_id = d.id)) > 0.01;