-- select * from vw_salidas_productos sp where sp.docstatus = 'CO';
-- drop view vw_salidas_productos;
create view vw_salidas_productos
as
select
s.m_inventory_id as id_salida,
s.ad_client_id,
s.ad_org_id,
s.isactive,
s.created,
s.createdby,
s.updated,
s.updatedby,
s.documentno as num_salida,
s.description as descripcion,
w.m_warehouse_id as id_almacen,
w.name as almacen,
s.movementdate as fecha_salida,
s.posted,
s.processed,
s.processing,
s.updateqty,
s.generatelist,
s.isapproved,
s.docstatus,
s.docaction,
s.approvalamt,
dt.c_doctype_id as id_tipo_documento,
dt.name as tipo_documento,
s.processedon,
cast(to_timestamp(s.processedon/1000) as date) as fecha_proceso
from m_inventory s
join m_warehouse w
on s.m_warehouse_id = w.m_warehouse_id
join c_doctype dt
on s.c_doctype_id = dt.c_doctype_id
where s.ad_client_id = 1000001
and (select count(ds.m_inventoryline_id) from m_inventoryline ds
where ds.m_inventory_id = s.m_inventory_id
and ds.qtyinternaluse <> 0) > 0;
No hay comentarios:
Publicar un comentario