|
|
@@ -0,0 +1,19 @@
|
|
|
+select t1.sa_orderitemsid,t2.itemid,t2.sa_orderid,t6.sa_agentsid,t5.enterprisename,t3.type,t3.billdate,t3.checkdate,t3.submitdate,t6.agentnum,t7.abbreviation,t4.marketingcategory,
|
|
|
+ t3.sonum,t4.itemno,t4.itemname,t4.model,t4.spec,t1.undeliqty,t1.willoutqty,(t1.undeliqty-t1.willoutqty) sendqty,t4.outplace from
|
|
|
+ (select t.sa_orderitemsid,sum(t.undeliqty)undeliqty,sum(t.willoutqty)willoutqty from
|
|
|
+ (select sa_orderitemsid,undeliqty,0 willoutqty from sa_orderitems t1
|
|
|
+ inner join sa_order t2 on t2.sa_orderid=t1.sa_orderid and t1.siteid=t2.siteid
|
|
|
+ where t1.isclose=0 and t1.undeliqty>0 and
|
|
|
+ t2.status='审核' and t1.siteid=$siteid$
|
|
|
+ union all
|
|
|
+ select t2.sa_orderitemsid,0,sum(qty) willoutfqty from st_stockbill t1
|
|
|
+ inner join st_stockbill_items t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid
|
|
|
+ where t1.status='新建'and t1.type='销售出库'and ifnull(t2.sa_orderitemsid,0)!=0 and t1.siteid=$siteid$
|
|
|
+ group by t2.sa_orderitemsid) t
|
|
|
+ group by t.sa_orderitemsid) t1
|
|
|
+ inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid
|
|
|
+ inner join sa_order t3 on t2.sa_orderid=t3.sa_orderid
|
|
|
+ inner join plm_item t4 on t2.itemid=t4.itemid
|
|
|
+ left join sys_enterprise_finance t5 on t3.sys_enterprise_financeid=t5.sys_enterprise_financeid and t3.siteid=t5.siteid
|
|
|
+ left join sa_agents t6 on t3.sys_enterpriseid=t6.sys_enterpriseid and t3.siteid=t6.siteid
|
|
|
+ left join sys_enterprise t7 on t3.sys_enterpriseid=t7.sys_enterpriseid and t3.siteid=t7.siteid where $where$ order by t2.itemid,t2.sa_orderid desc;
|