CREATE VIEW [dbo].[ApiLabelImportView] as
select p.Id, w.Id ObjectId, 40 ObjectType, p.LabelPath , p.Status, p.courier_package_nr from dbo.ApiWmsDocuments w JOIN dbo.DokHandlowe d ON w.ErpId = d.ID
JOIN dbo.Features order_id ON order_id.Name='bl_order_id' and order_id.Parent = d.ID and order_id.Lp =0 and order_id.ParentType='DokHandlowe'
JOIN dbo.blPackages p ON p.Status in(0,-1) and p.LabelPath<>'' and p.order_id = order_id.DataKey
GO


