|
@@ -1,8 +1,10 @@
|
|
|
SELECT t3.itemno,
|
|
|
- SUM(t1.qty-ifnull(t1.outwarehouseqty,0)) qty
|
|
|
+ SUM(t1.qty-ifnull(t7.qty,0)) qty
|
|
|
FROM sa_dispatch_items t1
|
|
|
inner join sa_dispatch t2 on t1.siteid = t2.siteid and t1.sa_dispatchid = t2.sa_dispatchid
|
|
|
inner join plm_item t3 on t1.siteid = t3.siteid and t1.itemid = t3.itemid
|
|
|
left join sys_enterprise t5 on t2.sys_enterpriseid=t5.sys_enterpriseid and t2.siteid=t5.siteid
|
|
|
left join sa_agents t6 on t6.sys_enterpriseid=t2.sys_enterpriseid and t2.siteid=t6.siteid
|
|
|
-WHERE t2.STATUS in ('审核','复核') and t1.siteid=$siteid$ and $where$ group by t3.itemno
|
|
|
+ inner join st_stockbill_items t7 on t1.sa_dispatch_itemsid=t7.sa_dispatch_itemsid and t1.siteid=t7.siteid
|
|
|
+ inner join st_stockbill t8 on t7.st_stockbillid=t8.st_stockbillid and t7.siteid=t8.siteid
|
|
|
+WHERE t2.STATUS in ('审核','复核') and t8.status='审核' and t1.siteid=$siteid$ and $where$ group by t3.itemno
|