UFN_SALESORDER_VALIDATEDELIVERY
Determines if the delivery method and information on an order are valid
Return
Return Type |
---|
bit |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ORDERID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_SALESORDER_VALIDATEDELIVERY
(
@ORDERID uniqueidentifier
)
returns bit
as begin
if exists (
select *
from dbo.SALESORDER as SO with (nolock)
inner join dbo.DELIVERYMETHOD as DM on SO.DELIVERYMETHODID = DM.ID
where
SO.ID = @ORDERID
and (DM.NAMEREQUIRED = 0 or SO.RECIPIENTID is not null)
and (
DM.ADDRESSREQUIRED = 0
or exists (
select *
from dbo.ADDRESS A with (nolock)
where
A.ID = SO.ADDRESSID and
A.ADDRESSBLOCK <> '' and
A.CITY <> ''
)
)
and (DM.PHONEREQUIRED = 0 or SO.PHONEID is not null)
and (DM.EMAILREQUIRED = 0 or SO.EMAILADDRESSID is not null)
)
return 1;
return 0;
end