Товарный отчет не сходится — различия между версиями
Agk (обсуждение | вклад) (Новая страница: «==Попробуйте выполнить скрипт== <nowiki> update doc_detail dd set price = (select price from parts p where p.id = dd.part_id) where abs(…») |
Agk (обсуждение | вклад) (→Попробуйте выполнить скрипт) |
||
Строка 4: | Строка 4: | ||
set price = (select price from parts p where p.id = dd.part_id) | 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; | where abs(price -(select price from parts p where p.id = dd.part_id))>0.01; | ||
+ | </nowiki> | ||
+ | <nowiki> | ||
update doc_detail | update doc_detail | ||
set summa = (price*quant+sum_dsc) | set summa = (price*quant+sum_dsc) | ||
where abs(summa-(price*quant+sum_dsc))>0.01; | where abs(summa-(price*quant+sum_dsc))>0.01; | ||
+ | </nowiki> | ||
+ | <nowiki> | ||
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) | 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; | 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; | ||
+ | </nowiki> | ||
+ | <nowiki> | ||
update doc_detail dd1 | 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) | 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; | 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; | ||
+ | </nowiki> | ||
+ | <nowiki> | ||
update docs d | 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) | 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; | 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; | ||
</nowiki> | </nowiki> |
Версия 14:56, 21 января 2015
Попробуйте выполнить скрипт
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;