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

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_Inbound_BokReport] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. CREATE proc [dbo].[proc_Inbound_BokReport]
  9. (
  10. @flag varchar(50)
  11. ,@user varchar(100) = null
  12. ,@asOnDate varchar(20) = null
  13. ,@pageSize varchar(20) = null
  14. ,@pageNumber varchar(20) = null
  15. )
  16. as
  17. set nocount on;
  18. set xact_abort on;
  19. begin
  20. declare @table varchar(max), @sql varchar(max);
  21. if @flag = 'get-BokReport'
  22. begin
  23. set @table =
  24. 'select
  25. irt.id
  26. ,[Creation Date] = Format(irt.CreatedDate,''yyyyMMdd'')
  27. ,[No of Transmissions] = ''''
  28. ,[Transfer Delimiter Code] = ''''
  29. ,[Processing No] = ''''
  30. ,[Serial No] = ts.idNumber
  31. ,[Form of Remittance] = ''''
  32. ,[Payment Date] = Format(irt.paidDate, ''yyyyMMdd'')
  33. ,[Payment Time] = CONVERT(varchar, irt.paidDate, 108)
  34. ,[Remittance Currency Code] = irt.payoutCurr
  35. ,[Remittance Foreign Currency Amount] = pAmt
  36. ,[USD ExchangeRate] = irt.pCurrCostRate
  37. ,[Remittance Receipt USD Balance] = irt.UsdAmount
  38. ,[Transfer Fee in KRW] = ''''
  39. ,[Beneficiary Name] = tr.fullName
  40. ,[Recipient''s Id] = tr.idNumber
  41. ,[Recipient''s RealName Verification] = ''''
  42. ,[Recipient Country Code] = ''KR''
  43. ,[Accumulate Amount] = irt.UsdAmount
  44. ,[Sender Name] = ts.fullName
  45. ,[Sender Country Code] = cmas.countryCode
  46. from INBOUND_REMIT_TRAN(nolock) irt
  47. inner join INBOUND_TRAN_SENDERS(nolock) ts on irt.id = ts.tranId
  48. inner join INBOUND_TRAN_RECEIVERS(nolock) tr on irt.id = tr.tranId
  49. inner join countryMaster(nolock) cmas on cmas.countryName = irt.sCountry'
  50. IF @asOnDate IS NOT NULL
  51. BEGIN
  52. SET @table = @table + ' AND irt.createdDate BETWEEN ''' + @asOnDate + ''' AND ''' + @asOnDate + ' 23:59:59'''
  53. END
  54. SET @sql='
  55. SELECT COUNT(''x'') AS TXNCOUNT,'+@pageSize+' PAGESIZE,'+@pageNumber+' PAGENUMBER FROM ('+ @table+') AS tmp;
  56. SELECT * FROM
  57. (
  58. SELECT ROW_NUMBER() OVER (ORDER BY [id] DESC) AS [S.N.],*
  59. FROM
  60. (
  61. '+ @table +'
  62. )A
  63. )B WHERE 1 = 1 AND B.[S.N.] BETWEEN (('+@pageNumber+' - 1) * '+@pageSize+' + 1) AND '+@pageNumber+' * '+@pageSize+'
  64. '
  65. PRINT(@sql)
  66. EXEC(@sql)
  67. EXEC proc_errorHandler '0', 'Report has been prepared successfully.', NULL
  68. SELECT 'As On Date' head, @asOnDate value union all
  69. SELECT 'To Date' head, @asOnDate + ' 23:59:59' value
  70. SELECT 'Inbound BOK Report' title
  71. end
  72. end
  73. GO