Товарный отчет не сходится

Материал из wiki.standart-n.ru
Перейти к: навигация, поиск

Попробуйте выполнить скрипт

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;


1. Выявление чеков у которы сумма чека по программе не совпадает с суммой отбитой по ККМ

select * from docs where abs(summ1+summ2-summa)>0.01 and status=1 and doc_type in (3,9)

2. Выявление чеков сумма которого не совпадает с детализацией документа

select * from docs d where abs(summa-(select sum(dd.summa) from doc_detail dd where dd.doc_id=d.id))>0.01 and status=1 and doc_type in (3,9)

3. Поочередно проверяем каждый документ и смотрим каие позиции прохидили по некорректным чекам

select * from doc_detail_active_log where doc_id=:doc_id

4. Расхождение суммы чеков и суммы z отчета

select -sum(u.summa) as summa_ch,u.device_num,u.vshift, u.date_z, (select sum(summ2) from docs d1 where d1.doc_type=13 and d1.commitdate=u.date_z) as summa_z, (select sum(summ2) from docs d1 where d1.doc_type=13 and d1.commitdate=u.date_z)+sum(u.summa) as razn_summa from (select summa,device_num,vshift,(select d1.commitdate from docs d1 where d1.doc_type=13 and d1.commitdate between d.commitdate-2 and d.commitdate+2 and d1.device_num=d.device_num and d1.vshift=d.vshift) as date_z from docs d where status=1 and doc_type in (3,9)) u

group by u.device_num,u.vshift, u.date_z having abs((select sum(summ2) from docs d1 where d1.doc_type=13 and d1.commitdate=u.date_z)+sum(u.summa))>0.011