 	, lastaction.lastuser LastActionUser
 	, case when oreceived.received = 1 then 'Yes' else 'No' end Received
 	, case when opaid.paid = 1 then 'Yes' else 'No' end Paid 
-	, ot.id ordertypeid, ot.name ordertype
-	, approvers.approver, AccountManagers.AccountManager, Purchasers.Purchaser
+	, ot.id OrderTypeId, ot.name OrderType
+	, approvers.approver Approver, AccountManagers.AccountManager, Purchasers.Purchaser
 	, case when o.FpdCompleted = 1 then 'Yes'else 'No' end FpdCompleted
 from orders o
 	inner join workgroups w on o.WorkgroupId = w.id

﻿CREATE VIEW dbo.vOrderHistory
AS
select row_number() over (order by o.id) id, o.id orderid,  o.RequestNumber
	, w.id workgroupid, w.name workgroupname
	, case 
		when o.WorkgroupVendorId is null then '-- Unspecified --'
		when o.WorkgroupVendorId is not null and wv.line1 = 'N/A' and url is null then wv.name + '(No Adddress)' 

	, creator.id CreatorId
	, o.DateCreated
	, osc.id StatusId, osc.name [Status], osc.IsComplete
	, totals.totalamount TotalAmount
	, o.LineItemSummary as LineItems
	, accounts.accountsubaccountsummary AccountSummary
	, cast(CASE WHEN isnull(charindex(',', accounts.accountsubaccountsummary), 0) <> 0 THEN 1 ELSE 0 END AS bit) HasAccountSplit
	, o.DeliverTo ShipTo
