CREATE VIEW [dbo].[ApiDocLinesBaseView] as
select 
TrE_TrEId Id, TrE_TrEID lineId,TrE_TrEId ErpId,  TrE_Lp lp, 
TrE_TrNId documentId, TrE_TrNId IdDocId,
TrE_TwrId itemId, TrE_TwrKod itemCode, TrE_TwrNazwa itemName, TrE_TwrOpis itemDescription,
TrE_CenaW itemPrice, TrE_Cena0 itemOrgPrice, TrE_Rabat discount, TrE_Ilosc quantity, TrE_WartoscNetto  value ,
TrE_TwrEAN itemEAN, TrE_Jm itemUM, TrE_JmZ itemUM2, cast(0 as decimal) veryfiedQuantity,
'' LocationName, 0 BatchId, '' Batch, '' BatchEAN,
0 CategoryId, '' CategoryName, '' CategoryName2, 0 as VendorId, 0 as Status,
0 ItemStatus, '' lineStatus, 0 lineChance, '' lineType, 
TrE_WartoscNetto Netto, TrE_WartoscBrutto Brutto, TrE_Stawka TaxRate, '' TaxDesc,
0 [ReservationType] , 0 [Direction], 0 [RepositoryId]

from CDN.TraElem 

