USE [befri_Goldhoo]
GO

/****** Object:  View [replenish].[V_ReplenishOrderLine]    Script Date: 2021/3/17 16:19:45 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [replenish].[V_ReplenishOrderLine]
AS
SELECT rol.ReplenishOrderLineId, rol.ReplenishOrderId, rol.CusRepNumber, rol.InventoryId, rol.InventoryNumber, 
                  rol.InventoryName, rol.Spec, rol.ReplenishType, rol.ReplenishId, rol.ReplenishName, rol.ReplenishCycle, 
                  rol.ReplenishReasonId, rol.ReplenishReasonMemo, rol.RepPosition, rol.RepMemo, rol.Quantity, rol.BearPrice, rol.IsFree, 
                  rol.ApprovedBy, rol.ApprovedOn, rol.ApprovedIdea, rol.ProduceReceivingBy, rol.ProduceReceivingOn, 
                  rol.ExpFinishOn, rol.FinishOnBy, rol.FinishOn, rol.LineStatus, rol.Memo, repType.Text AS ReplenishTypeText, 
                  linstu.Text AS LineStatusText
FROM     replenish.ReplenishOrderLine AS rol LEFT OUTER JOIN
                  dbo.ValueTextMap AS repType ON repType.TableName = 'replenish.ReplenishOrderLine' AND 
                  repType.FieldName = 'ReplenishType' AND repType.Value = rol.ReplenishType LEFT OUTER JOIN
                  dbo.ValueTextMap AS linstu ON linstu.TableName = 'replenish.ReplenishOrderLine' AND 
                  linstu.FieldName = 'LineStatus' AND linstu.Value = rol.LineStatus

GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'replenish', @level1type=N'VIEW',@level1name=N'V_ReplenishOrderLine'
GO