You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

81 lines
5.3 KiB

USE [FastMoneyPro_Remit]
GO
/****** Object: StoredProcedure [dbo].[proc_Inbound_BokReport] Script Date: 9/27/2019 1:30:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[proc_Inbound_BokReport]
(
@flag varchar(50)
,@user varchar(100) = null
,@asOnDate varchar(20) = null
,@pageSize varchar(20) = null
,@pageNumber varchar(20) = null
)
as
set nocount on;
set xact_abort on;
begin
declare @table varchar(max), @sql varchar(max);
if @flag = 'get-BokReport'
begin
set @table =
'select
irt.id
,[Creation Date] = Format(irt.CreatedDate,''yyyyMMdd'')
,[No of Transmissions] = ''''
,[Transfer Delimiter Code] = ''''
,[Processing No] = ''''
,[Serial No] = ts.idNumber
,[Form of Remittance] = ''''
,[Payment Date] = Format(irt.paidDate, ''yyyyMMdd'')
,[Payment Time] = CONVERT(varchar, irt.paidDate, 108)
,[Remittance Currency Code] = irt.payoutCurr
,[Remittance Foreign Currency Amount] = pAmt
,[USD ExchangeRate] = irt.pCurrCostRate
,[Remittance Receipt USD Balance] = irt.UsdAmount
,[Transfer Fee in KRW] = ''''
,[Beneficiary Name] = tr.fullName
,[Recipient''s Id] = tr.idNumber
,[Recipient''s RealName Verification] = ''''
,[Recipient Country Code] = ''KR''
,[Accumulate Amount] = irt.UsdAmount
,[Sender Name] = ts.fullName
,[Sender Country Code] = cmas.countryCode
from INBOUND_REMIT_TRAN(nolock) irt
inner join INBOUND_TRAN_SENDERS(nolock) ts on irt.id = ts.tranId
inner join INBOUND_TRAN_RECEIVERS(nolock) tr on irt.id = tr.tranId
inner join countryMaster(nolock) cmas on cmas.countryName = irt.sCountry'
IF @asOnDate IS NOT NULL
BEGIN
SET @table = @table + ' AND irt.createdDate BETWEEN ''' + @asOnDate + ''' AND ''' + @asOnDate + ' 23:59:59'''
END
SET @sql='
SELECT COUNT(''x'') AS TXNCOUNT,'+@pageSize+' PAGESIZE,'+@pageNumber+' PAGENUMBER FROM ('+ @table+') AS tmp;
SELECT * FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY [id] DESC) AS [S.N.],*
FROM
(
'+ @table +'
)A
)B WHERE 1 = 1 AND B.[S.N.] BETWEEN (('+@pageNumber+' - 1) * '+@pageSize+' + 1) AND '+@pageNumber+' * '+@pageSize+'
'
PRINT(@sql)
EXEC(@sql)
EXEC proc_errorHandler '0', 'Report has been prepared successfully.', NULL
SELECT 'As On Date' head, @asOnDate value union all
SELECT 'To Date' head, @asOnDate + ' 23:59:59' value
SELECT 'Inbound BOK Report' title
end
end
GO