USE [befri_Goldhoo]
GO

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

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [replenish].[V_ReplenishOrder]
AS
SELECT ro.ReplenishOrderId, ro.OrderNumber, ro.OrderedOn, ro.RequiredOn, ro.ShopId, ro.CreditType, ro.ShippingMode, 
                  ro.ReceiptedAt, ro.PreparedBy, ro.PreparedOn, ro.OrderStatus, 
                  ro.VersionNumber, ro.CreatedBy, ro.CreatedOn, ro.ModifiedBy, ro.ModifiedOn, ro.Description, 
                  creType.Text AS CreditTypeText, stus.Text AS OrderStatusText
FROM     replenish.ReplenishOrder AS ro LEFT OUTER JOIN
                  dbo.ValueTextMap AS creType ON creType.Value = ro.CreditType AND creType.TableName = 'sales.SalesOrder' AND 
                  creType.FieldName = 'CreType' LEFT OUTER JOIN
                  dbo.ValueTextMap AS stus ON stus.Value = ro.OrderStatus AND 
                  stus.TableName = 'replenish.ReplenishOrderLine' AND stus.FieldName = 'LineStatus'

GO


