

/****** Object:  View [dbo].[ApiDocumentsBaseView]    Script Date: 13.09.2021 14:23:01 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO






CREATE VIEW [dbo].[ApiDocumentsBaseView] as
select TrN_TrNID Id, TrN_TrNID DocId, TrN_TrNID ErpId, TrN_PodID CustId, TrN_PodID CustCustId,
TrN_OdbID CustLocId, TrN_OdbID CustLocLocId, TrN_NumerPelny NumberString, TrN_NumerPelny ErpNumberString, TrN_NumerNr Number,
MONTH(TrN_DataDok) Month, YEAR(TrN_DataDok) Year, '' Series,
TrN_DDfId DefId, TrN_DataDok Date, TrN_DataWys Date2, TrN_Opis Description, 0 [State],
TrN_NumerPelny BarCode, TrN_Waluta Currency , 
TrN_RazemNetto Value,ISNULL(TrN_MagZrdId,0) RepositoryId ,
TrN_PodNazwa1 Info, DDf_KierunekOrg FlowDirection, 
TrN_NumerObcy ForeginNumber, '' Category,
TrN_RazemNetto Netto, TrN_RazemBrutto Brutto,cast(TrN_TypNB  as int) NettoBrutto,
0 SaveTS, 0 as Lines, cast(0 as bit) VeryfiedDoc,
0 PrecedentDoc, '' PrecedentDocNumber, 0 ConfirmTransfer,
CURRENT_TIMESTAMP TS, '' DeviceUid,
0 VendorId
,0 StateDoc, 0 OperatorId, 0 ReservationResource, 0 ReservationType, '' LinesInfo
from CDN.TraNag dok
JOIN   CDN.DokDefinicje def ON def.DDf_DDfID = TrN_DDfId
--where def.DDf_DDfID=30



GO


