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.

107 lines
5.8 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_tranReportDetail] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. /*
  9. EXEC proc_tranReportDetail @flag = 'details', @tranId = '501'
  10. EXEC proc_tranReportDetail @flag = 'details', @user = 'admin', @tranId = '501'
  11. */
  12. CREATE proc [dbo].[proc_tranReportDetail] (
  13. @flag VARCHAR(50)
  14. ,@controlNo VARCHAR(20) = NULL
  15. ,@user VARCHAR(30) = NULL
  16. ,@tranId INT = NULL
  17. ,@sortBy VARCHAR(50) = NULL
  18. ,@sortOrder VARCHAR(5) = NULL
  19. ,@pageSize INT = NULL
  20. ,@pageNumber INT = NULL
  21. )
  22. AS
  23. DECLARE
  24. @select_field_list VARCHAR(MAX)
  25. ,@extra_field_list VARCHAR(MAX)
  26. ,@table VARCHAR(MAX)
  27. ,@sql_filter VARCHAR(MAX)
  28. SET NOCOUNT ON
  29. SET XACT_ABORT ON
  30. --select * from customers
  31. IF @flag = 'details'
  32. BEGIN
  33. SELECT
  34. trn.id
  35. ,trn.controlNo
  36. ,sMemId = sen.membershipId
  37. ,sCustomerId = sen.customerId
  38. ,sName = sen.firstName + ISNULL( ' ' + sen.middleName, '') + ISNULL( ' ' + sen.lastName1, '') + ISNULL( ' ' + sen.lastName2, '')
  39. ,sCountryName = trn.sCountry
  40. ,sStateName = sen.[state]
  41. ,sCity = sen.city
  42. ,sAddress = sen.[address]
  43. ,sContactNo = COALESCE(sen.mobile, sen.homePhone, sen.workPhone)
  44. ,rMemId = rec.membershipId
  45. ,rCustomerId = rec.customerId
  46. ,rName = rec.firstName + ISNULL( ' ' + rec.middleName, '') + ISNULL( ' ' + rec.lastName1, '') + ISNULL( ' ' + rec.lastName2, '')
  47. ,rCountryName = rec.country
  48. ,rStateName = rec.[state]
  49. ,rCity = rec.city
  50. ,rAddress = rec.[address]
  51. ,rContactNo = COALESCE(rec.mobile, rec.homePhone, rec.workPhone)
  52. ,senAgentName = sa.agentName
  53. ,senCountryName = trn.sCountry
  54. ,senLocation = sd.districtName
  55. ,senAddress = sa.agentAddress
  56. ,pAgentName = ISNULL(pa.agentName, '[Any]')
  57. ,pCountryName = trn.pCountry
  58. ,pStateName = trn.pState
  59. ,pLocation = pd.districtName
  60. ,pAddress = pa.agentAddress
  61. ,relationship = trn.relWithSender
  62. ,purpose = trn.purposeOfRemit
  63. ,trn.tAmt
  64. ,trn.serviceCharge
  65. ,trn.handlingFee
  66. ,trn.cAmt
  67. ,trn.collCurr
  68. ,exRate = 1
  69. ,trn.pAmt
  70. ,trn.payoutCurr
  71. ,collMode = trn.collMode
  72. ,paymentMethod = trn.paymentMethod
  73. ,trn.payoutCurr
  74. ,tranStatus = trn.tranStatus
  75. ,payStatus = trn.payStatus
  76. ,pMessage = ISNULL(trn.pMessage, 'N/A')
  77. FROM remitTran trn WITH(NOLOCK)
  78. LEFT JOIN tranSenders sen WITH(NOLOCK) ON trn.id = sen.tranId
  79. LEFT JOIN tranReceivers rec WITH(NOLOCK) ON trn.id = rec.tranId
  80. LEFT JOIN agentMaster sa WITH(NOLOCK) ON trn.sAgent = sa.agentId
  81. LEFT JOIN api_districtList sd WITH(NOLOCK) ON sa.agentLocation = sd.districtCode
  82. LEFT JOIN agentMaster pa WITH(NOLOCK) ON trn.pAgent = pa.agentId
  83. LEFT JOIN api_districtList pd WITH(NOLOCK) ON pa.agentLocation = pd.districtCode
  84. WHERE trn.id = @tranId
  85. END
  86. GO