CREATE VIEW [dbo].[TTransactionSplitView]
AS
-- nb20160205: Rollback Folio needed field added
-- nb20120827: Created
SELECT
 T.DateStamp AS Date
, T.TextOverwrite AS Text
, FLOOR(T.Pieces) As Pcs
, CAST(T.PriceOverwrite/FLOOR(T.Pieces) AS MONEY) AS Price 
, CAST(T.PriceOverwrite/FLOOR(T.Pieces)*ABS(FLOOR(T.Pieces)) AS MONEY) As Total
, P.UserIdCode AS UserID
, C.LastName AS Hotel--Do not use unless several hotels in domino
, T.FolioNumber
, T.MovedDeleted
, T.OriginalGlobalTransactionNumber AS MGTN
, T.ProductWareLinkNumber AS PWLN
, T.TransactionNumber
, T.Payment AS PaymentType
, T.HotelCustomerNumber
, T.WareNumber --4 delete
FROM FOLIOS F1 WITH (NOLOCK) 
  INNER JOIN TRANSACTIONS T WITH (NOLOCK) ON T.Folionumber = F1.Folionumber
  LEFT JOIN Personel P WITH (NOLOCK) ON P.UserIdNumber = T.UserIdNumber
  LEFT JOIN Customer C WITH (NOLOCK) ON C.CustomerNumber = T.HotelCustomerNumber
WHERE T.ShowOnBillFlag = 1 AND T.MovedDeleted = 0
