UFN_SALESDEPOSITTEMPLATE_CURRENCY_TOITEMLISTXML
Return
Return Type |
---|
xml |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@SALESDEPOSITTEMPLATEID | uniqueidentifier | IN | |
@PDACCOUNTSYSTEMID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_SALESDEPOSITTEMPLATE_CURRENCY_TOITEMLISTXML
(
@SALESDEPOSITTEMPLATEID uniqueidentifier = null,
@PDACCOUNTSYSTEMID uniqueidentifier = null
)
returns xml
as begin
declare @XML xml
set @XML = (
select
SDTC.ID
,case when @SALESDEPOSITTEMPLATEID is null then 1 else case when SDTC.ID is null then 0 else 1 end end as [INCLUDE]
,C.ID as CURRENCYID
,dbo.UFN_CURRENCY_GETDESCRIPTION(C.ID) as CURRENCY
,PDACCOUNTSYSTEM.ID as PDACCOUNTSYSTEMID
from dbo.CURRENCY C
left join dbo.CURRENCYSETTRANSACTIONCURRENCY CSTC on CSTC.CURRENCYID = C.ID
left join dbo.PDACCOUNTSYSTEM on PDACCOUNTSYSTEM.CURRENCYSETID = CSTC.CURRENCYSETID
left join dbo.SALESDEPOSITTEMPLATECURRENCY SDTC
on @SALESDEPOSITTEMPLATEID is not null
and C.ID = SDTC.CURRENCYID
and SDTC.SALESDEPOSITTEMPLATEID = @SALESDEPOSITTEMPLATEID
where (PDACCOUNTSYSTEM.ID = @PDACCOUNTSYSTEMID or @PDACCOUNTSYSTEMID is null)
order by C.NAME
for xml raw('ITEM'), type, elements, root('CURRENCY'), BINARY BASE64
)
return @XML
end