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.

85 lines
6.6 KiB

  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: UserDefinedFunction [dbo].[FNAGetCustomerAddress] Script Date: 11/10/2023 1:15:27 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. ALTER FUNCTION [dbo].[FNAGetCustomerAddress]
  9. (
  10. @customerOrTranId BIGINT
  11. , @addressFor VARCHAR(20) = NULL
  12. )
  13. RETURNS NVARCHAR(250)
  14. AS
  15. ------------------------------------------
  16. --#134 -> Allow edit option of address in Town Area
  17. --#180 -> SHOW KANJI AND ROMAN TEXT IN ADDRESS STATE AND CITY
  18. -- ADDED NEW IF CLAUSE 'CUST-SEARCH-DETAILS'
  19. --#474 -> Remove Kanji character from SOA ma statement
  20. -- #1320 Remove khanji character from search transaction
  21. ------------------------------------------------------------------------
  22. BEGIN
  23. DECLARE @customerAddress NVARCHAR(250)
  24. IF ISNULL(@addressFor, '') = ''
  25. SET @addressFor = 'CUST-SEARCH'
  26. IF @addressFor IN ('TXN-RECEIPT', 'TXN-SEARCH')
  27. BEGIN
  28. SELECT @customerAddress = ISNULL(substring(s.zipcode,1,3),'')+'-'+ ISNULL(substring(s.zipcode,4,7),'')
  29. + isnull(', ' + ss.statename, '')
  30. + isnull(', ' + s.address, '')
  31. +ISNULL( ', '+ s.address2, '')
  32. FROM VWTRANSENDERS S(NOLOCK)
  33. LEFT JOIN dbo.countryStateMaster SS(NOLOCK) ON CAST(SS.stateId AS VARCHAR) = s.state
  34. WHERE S.TRANID = @customerOrTranId
  35. END
  36. ELSE IF @addressFor IN ('CUST-SEARCH')
  37. BEGIN
  38. SELECT @customerAddress = ISNULL(CM.zipcode,'')
  39. + isnull(', ' + CM.address, '')
  40. + ISNULL( ', '+ UPPER(CM.ADDITIONALADDRESS), '')
  41. FROM CUSTOMERMASTER CM(NOLOCK)
  42. --INNER JOIN tbl_japan_address_detail detail WITH (NOLOCK) ON detail.zip_code = CM.zipcode
  43. WHERE CM.CUSTOMERID = @customerOrTranId
  44. END
  45. ELSE IF @addressFor IN ('CUST-SEARCH-NEW')
  46. BEGIN
  47. SELECT @customerAddress = ISNULL(substring(CM.zipcode,1,3),'')+'-'+ ISNULL(substring(CM.zipcode,4,7),'')
  48. + isnull(', ' + detail.STATE_ENG, '')
  49. + isnull(', ' + detail.city_name, '')
  50. + isnull( ', ' + detail.street_name, '')
  51. + ISNULL( ', '+ UPPER(CM.ADDITIONALADDRESS), '')
  52. FROM CUSTOMERMASTER CM(NOLOCK)
  53. INNER JOIN tbl_japan_address_detail detail WITH (NOLOCK) ON detail.zip_code = CM.zipcode
  54. WHERE CM.CUSTOMERID = @customerOrTranId
  55. END
  56. ELSE IF @addressFor IN ('CUST-SEARCH-DETAILS')
  57. BEGIN
  58. SELECT @customerAddress = ISNULL(substring(CM.zipcode,1,3),'')+'-'+ ISNULL(substring(CM.zipcode,4,7),'')
  59. + isnull(', ' + detail.STATE_ENG, '') + ISNULL(', ' + STATE_JAPANESE, '')
  60. + isnull(', ' + detail.city_name, '') + ISNULL(', ' + CITY_JAPANESE, '')
  61. + isnull(', ' + CM.STREETUNICODE, ', ' + detail.street_name)
  62. + ISNULL( ', '+ UPPER(CM.ADDITIONALADDRESS), '')
  63. FROM CUSTOMERMASTER CM(NOLOCK)
  64. INNER JOIN tbl_japan_address_detail detail WITH (NOLOCK) ON detail.zip_code = CM.zipcode
  65. WHERE CM.CUSTOMERID = @customerOrTranId
  66. END
  67. ELSE IF @addressFor IN ('SEARCH-TXN')
  68. BEGIN
  69. SELECT @customerAddress = ISNULL(substring(CM.zipcode,1,3),'')+'-'+ ISNULL(substring(CM.zipcode,4,7),'')
  70. + isnull(', ' + detail.STATE_ENG, '')
  71. + isnull(', ' + detail.city_name, '')
  72. + isnull(', ' + CM.street,'')
  73. + ISNULL( ', '+ UPPER(CM.ADDITIONALADDRESS), '')
  74. FROM CUSTOMERMASTER CM(NOLOCK)
  75. INNER JOIN tbl_japan_address_detail detail WITH (NOLOCK) ON detail.zip_code = CM.zipcode
  76. WHERE CM.CUSTOMERID = @customerOrTranId
  77. END
  78. RETURN @customerAddress
  79. END