select H.outbill_no,--出货单号
H.source_bill_no,--订单号
c.order_type_name,--订单类型
to_date(fn_get_order_outdate(oh.order_no) ,"dd-mm-yy")as old_out_date,--原需求日期
oh.out_date,--现需求日期
H.OUTBILL_DATE,--出货日期
CRM_CUST.Short_Name,--客户简称
ci.item_code,--物料编码
ci.Draw_Id,--机型
case when getItemStatWithQtyLmt(oh.factory_id,0,oh.draw_id,'''',0)=2 then "已认定已认定" else "未认定未认定" end as item_stat,
(case
when H.source_bill_type =1then "销售出货"
else
case
when H.source_bill_type =2then "退货入库"
else
case
when H.source_bill_type =3then "调拨出库"
else
case
when H.source_bill_type =14then "账面出库"
else
end
end
end
end ),
from crm_outbill_header H,
CRM_CUST,
crm_saleorder_header oh,
Crm_SaleOrder_Type c,
crm_item ci
WHERE H.CUST_ID = CRM_CUST.CUST_ID
and h.source_bill_no=oh.order_no
and oh.order_type=c.order_type
and h.item_id=ci.item_id
and H.stat <> 5
and H.source_bill_type in(1,14)
and H.warehouse_id = 1
and H.item_id = 1