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.

470 lines
20 KiB

1 year ago
  1. ALTER PROC mobile_proc_customerMaster_V2
  2. (
  3. @flag VARCHAR(20)
  4. , @username VARCHAR(100) = NULL
  5. , @type VARCHAR(100) = NULL
  6. , @sourceOfFund VARCHAR(100) = NULL
  7. , @monthlyIncome VARCHAR(100) = NULL
  8. , @businessType VARCHAR(100) = NULL
  9. , @mobile VARCHAR(100) = NULL
  10. , @email VARCHAR(100) = NULL
  11. , @additionalAddress NVARCHAR(100) = NULL
  12. , @idType VARCHAR(100) = NULL
  13. , @additionalIdType VARCHAR(100) = NULL
  14. , @idFront VARCHAR(100) = NULL
  15. , @idBack VARCHAR(100) = NULL
  16. , @occupation VARCHAR(100) = NULL
  17. , @idSide VARCHAR(100) = NULL
  18. , @additionalId VARCHAR(100) = NULL
  19. , @additionalIdBack VARCHAR(100) = NULL
  20. , @facePicture VARCHAR(100) = NULL
  21. , @currentPin VARCHAR(20) = NULL
  22. , @NewPassword VARCHAR(50) = NULL
  23. , @newPin VARCHAR(20) = NULL
  24. , @currentPassword VARCHAR(50) = NULL
  25. , @confirmNewPin VARCHAR(20) = NULL
  26. , @ConfirmNewPassword VARCHAR(50) = NULL
  27. , @employeerName VARCHAR(100) = NULL
  28. , @visaStatus VARCHAR(50) = NULL
  29. , @occupationOther VARCHAR(150) = NULL
  30. , @otherIdType VARCHAR(150) = NULL
  31. , @otherOccupation VARCHAR(150) = NULL
  32. , @otherSourceOfFund VARCHAR(150) = NULL
  33. , @purposeOfRegistration INT = NULL
  34. , @SettingType VARCHAR(30) = NULL
  35. , @customerPassword NVARCHAR (20) = NULL
  36. , @token VARCHAR(MAX) = NULL
  37. )
  38. AS;
  39. ------------------------------------------------------------------------------------------------------------
  40. -- Task #225 - Create Token For Bioemtric - flag = 'update-settings' , insert for mobiletoken
  41. --#101 Mobile changes for multi lingual
  42. ------------------------------------------------------------------------------------------------------------
  43. SET NOCOUNT ON;
  44. SET XACT_ABORT ON;
  45. BEGIN
  46. DECLARE @customerId BIGINT, @cust BIGINT ,@errorMsg VARCHAR(MAX)
  47. SELECT @customerId = customerId
  48. FROM customerMaster WITH(nolock)
  49. WHERE username = @userName
  50. IF @flag = 'id-update'
  51. BEGIN
  52. SELECT @customerId = customerId
  53. FROM CUSTOMERMASTER (NOLOCK)
  54. WHERE USERNAME = @username
  55. IF ISNULL(@idFront, '') <> ''
  56. INSERT INTO customerDocumentTmp (customerId, fileName, createdBy, createdDate, documentType)
  57. SELECT @customerId, @idFront, @username, GETDATE(), 11394
  58. IF ISNULL(@idBack, '') <> ''
  59. INSERT INTO customerDocumentTmp (customerId, fileName, createdBy, createdDate, documentType)
  60. SELECT @customerId, @idBack, @username, GETDATE(), 11395
  61. EXEC proc_errorHandler 0, 'Document uploaded successfully!', @userName
  62. RETURN
  63. END
  64. ELSE IF @flag = 'update-settings'
  65. BEGIN
  66. IF NOT EXISTS(SELECT * FROM customerMaster (NOLOCK) WHERE USERNAME = @username) OR
  67. NOT EXISTS(SELECT * FROM mobile_userRegistration (NOLOCK) WHERE USERNAME = @username)
  68. BEGIN
  69. EXEC proc_errorHandler 1, 'Invalid customer data!', @userName
  70. RETURN
  71. END
  72. IF @SettingType NOT IN('FINGER_PRINT_LOGIN')
  73. BEGIN
  74. EXEC proc_errorHandler 1, 'Invalid data!', @userName
  75. RETURN
  76. END
  77. IF @type NOT IN ('True', 'False')
  78. BEGIN
  79. EXEC proc_errorHandler 1, 'Invalid data!', @userName
  80. RETURN
  81. END
  82. IF NOT EXISTS (SELECT * FROM customerMaster WHERE customerPassword = dbo.FNAEncryptString(@customerPassword) AND username = @username)
  83. BEGIN
  84. EXEC proc_errorHandler 1, 'Invalid Username/Password.', @userName
  85. RETURN
  86. END
  87. --IF @type = 'True'
  88. --BEGIN
  89. -- IF EXISTS(SELECT TOP 1 * FROM mobile_userRegistration (NOLOCK) WHERE USERNAME = @username AND isbiometricLogin = 1)
  90. -- BEGIN
  91. -- SELECT @errorMsg = @SettingType + ' is already enabled'
  92. -- EXEC proc_errorHandler 1, @errorMsg ,''
  93. -- RETURN
  94. -- END
  95. --END
  96. --IF @type = 'False'
  97. --BEGIN
  98. -- IF EXISTS(SELECT TOP 1 * FROM mobile_userRegistration (NOLOCK) WHERE USERNAME = @username AND isbiometricLogin = 0)
  99. -- BEGIN
  100. -- SELECT @errorMsg = @SettingType + ' is already disabled'
  101. -- EXEC proc_errorHandler 1, @errorMsg ,''
  102. -- RETURN
  103. -- END
  104. --END
  105. UPDATE mr
  106. SET BiometricLoginType = @SettingType, IsBiometricLogin = CASE WHEN @type = 'True' THEN 1 ELSE 0 END
  107. FROM mobile_userRegistration mr
  108. INNER JOIN customerMaster cm WITH (NOLOCK) ON mr.username = cm.email
  109. WHERE mr.username = @username
  110. UPDATE MobileToken SET activeStatus = 'N' WHERE userName = @username
  111. IF @type = 'True'
  112. BEGIN
  113. INSERT INTO MobileToken (username, activeStatus, token , loginType,createdOn)
  114. SELECT @userName, 'Y' , @token, @SettingType ,GETDATE()
  115. EXEC proc_errorHandler 0, 'Settings updated successfully!', @token
  116. RETURN
  117. END
  118. EXEC proc_errorHandler 0, 'Settings updated successfully!', ''
  119. RETURN
  120. END
  121. ELSE IF @flag = 'c-pin-pwd'
  122. BEGIN
  123. IF ISNULL(@newPin, 'A') <> ISNULL(@confirmNewPin, 'B')
  124. BEGIN
  125. EXEC proc_errorHandler 1, 'New pin and Confirm pin are not same!', @userName
  126. RETURN
  127. END
  128. IF ISNULL(@NewPassword, 'A') <> ISNULL(@ConfirmNewPassword, 'B')
  129. BEGIN
  130. EXEC proc_errorHandler 2, 'New password and Confirm password are not same!', @userName
  131. RETURN
  132. END
  133. IF DBO.FNAencryptstring(@currentPassword) = DBO.FNAencryptstring(@NewPassword)
  134. BEGIN
  135. EXEC proc_errorHandler 1, 'New Password can not be same as your old password, Please try again!', @userName
  136. RETURN;
  137. END
  138. IF DBO.FNAencryptstring(@currentPin) = DBO.FNAencryptstring(@newPin)
  139. BEGIN
  140. EXEC proc_errorHandler 1, 'New pin can not be same as your old pin, Please try again!', @userName
  141. RETURN;
  142. END
  143. IF NOT EXISTS(SELECT 'A' FROM customerMaster (NOLOCK) WHERE username = @username)
  144. BEGIN
  145. EXEC proc_errorHandler 3, 'Invalid customer found!', @userName
  146. RETURN
  147. END
  148. IF NOT EXISTS(SELECT 'A' FROM customerMaster (NOLOCK) WHERE username = @username AND txnPin = @currentPin)
  149. BEGIN
  150. EXEC proc_errorHandler 4, 'Invalid pin number!', @userName
  151. RETURN
  152. END
  153. IF NOT EXISTS(SELECT 'A' FROM customerMaster (NOLOCK) WHERE username = @username AND customerPassword = dbo.FNAEncryptString(@currentPassword))
  154. BEGIN
  155. EXEC proc_errorHandler 5, 'Invalid password!', @userName
  156. RETURN
  157. END
  158. UPDATE customerMaster SET txnPin = @newPin, customerPassword = dbo.FNAEncryptString(@NewPassword), isForcedPwdChange = 0
  159. WHERE username = @username
  160. UPDATE mobile_userRegistration SET isForcePassChange = 0 where username = @username
  161. EXEC proc_errorHandler 0, 'You have successfully changed your pin and password' , @username
  162. RETURN
  163. END
  164. ELSE IF @flag = 'c-pin'
  165. BEGIN
  166. IF ISNULL(@newPin, 'A') <> ISNULL(@confirmNewPin, 'B')
  167. BEGIN
  168. EXEC proc_errorHandler 1, 'New pin and Confirm pin are not same!', @userName
  169. RETURN
  170. END
  171. IF EXISTS(SELECT 'A' FROM customerMaster (NOLOCK) WHERE username = @username AND @currentPin = @newPin)
  172. BEGIN
  173. EXEC proc_errorHandler 2, 'Old pin and new pin cannot be same!', @userName
  174. RETURN
  175. END
  176. IF NOT EXISTS(SELECT 'A' FROM customerMaster (NOLOCK) WHERE username = @username)
  177. BEGIN
  178. EXEC proc_errorHandler 3, 'Invalid customer found!', @userName
  179. RETURN
  180. END
  181. IF NOT EXISTS(SELECT 'A' FROM customerMaster (NOLOCK) WHERE username = @username AND txnPin = @currentPin)
  182. BEGIN
  183. EXEC proc_errorHandler 4, 'Invalid pin number!', @userName
  184. RETURN
  185. END
  186. UPDATE customerMaster SET txnPin = @newPin, isForcedPwdChange = 0 WHERE username = @username AND txnPin = @currentPin
  187. EXEC proc_errorHandler 0, 'You have successfully changed your pin', @userName
  188. RETURN
  189. END
  190. ELSE IF @flag = 'i'
  191. BEGIN
  192. IF NOT EXISTS(SELECT * FROM StaticDataValue(nolock) WHERE typeID = 2000 AND isActive='Y' AND CAST(valueid AS VARCHAR) = @occupation)
  193. BEGIN
  194. SET @occupationOther = @occupation
  195. SELECT @occupation = valueId
  196. FROM StaticDataValue(nolock) WHERE typeID = 2000 AND isActive='Y' AND detailTitle = 'Other (Please specify)'
  197. END
  198. IF EXISTS(SELECT TOP 1 'A' FROM customerMaster(NOLOCK) WHERE username = @userName) AND EXISTS(SELECT TOP 1 'A' FROM customerMasterTemp(NOLOCK) WHERE username = @userName)
  199. BEGIN
  200. EXEC proc_errorHandler 1, 'Username already taken, please select new username!', @userName
  201. RETURN
  202. END
  203. IF EXISTS(SELECT 'X' FROM customerMaster with (nolock) WHERE mobile = @mobile and ISNULL(onlineUser, 'N')='Y' and isnull(isDeleted,'N')='N' and customerId <> @customerId)
  204. BEGIN
  205. SELECT @errorMsg = 'Customer with mobile number ' + @mobile + ' already exist.'
  206. EXEC proc_errorHandler 2, @errorMsg, @customerId
  207. RETURN
  208. END
  209. IF @idType IS NULL AND @otherIdType IS NOT NULL
  210. SET @idType = 11402
  211. IF @occupation IS NULL AND @otherOccupation IS NOT NULL
  212. SET @occupation = 11383
  213. --alter table customerMasterTemp add documentType varchar(20)
  214. BEGIN TRANSACTION
  215. IF @type IN ('0', '1')
  216. BEGIN
  217. IF EXISTS (SELECT 'X' FROM dbo.customerMasterTemp (NOLOCK) WHERE username = @userName)
  218. BEGIN
  219. UPDATE dbo.customerMasterTemp SET
  220. occupation = ISNULL(@occupation, occupation),
  221. monthlyIncome= ISNULL(@monthlyIncome, monthlyIncome),
  222. employeeBusinessType=ISNULL(@businessType, employeeBusinessType),
  223. mobile = ISNULL(@mobile, mobile),
  224. ADDITIONALADDRESS = ISNULL(@additionalAddress, ADDITIONALADDRESS),
  225. idType = ISNULL(@idType, idType),
  226. documentType = ISNULL(@additionalIdType, documentType),
  227. nameOfEmployeer = ISNULL(@employeerName, nameOfEmployeer),
  228. otherIdNumber = @otherIdType,
  229. occupationOther = @otherOccupation,
  230. purposeOfRegistration = ISNULL(@purposeOfRegistration, purposeOfRegistration)
  231. WHERE username = @userName
  232. INSERT INTO dbo.customerMaster
  233. (
  234. fullName,firstName,mobile,gender,dob,occupation,nativeCountry,country,bankName,bankAccountNo,idType,idNumber,homePhone,idIssueDate
  235. ,idExpiryDate,verifyDoc1,verifyDoc2,verifyDoc3,SelfieDoc,referelCode,createdBy,createdDate,isActive,onlineUser,customerPassword,[address]
  236. ,city,state2,customerType,ADDITIONALADDRESS,monthlyIncome,organizationType,username,anotherIdType,employeeBusinessType,documentType,remittanceallowed
  237. ,txnPin, nameOfEmployeer,isExistingCustomer, HasDeclare, createdFrom, occupationOther, purposeOfRegistration, email, customerEmail, otherIdNumber, isEmailVerified
  238. )
  239. SELECT fullName,CMT.firstName,mobile,gender,dob,CMT.occupation,nativeCountry,113,bankName,bankAccountNo,idType,idNumber,CMT.homePhone,CMT.idIssueDate
  240. ,idExpiryDate,verifyDoc1,verifyDoc2,verifyDoc3,CMT.selfie,CMT.referelCode,CMT.createdBy,createdDate,'Y','Y',customerPassword,[address]
  241. ,city,state2,4700, ADDITIONALADDRESS,monthlyIncome,organizationType,username,anotherIdType,employeeBusinessType,documentType,1
  242. ,null, nameOfEmployeer,0, 0, 'M', @occupationOther, @purposeOfRegistration,email, customerEmail, otherIdNumber, isEmailVerified
  243. FROM dbo.CustomerMasterTemp AS CMT(NOLOCK)
  244. WHERE CMT.username = @userName
  245. SET @cust = @@IDENTITY
  246. UPDATE dbo.mobile_userRegistration SET customerId = @cust WHERE username = @userName
  247. DELETE FROM customerMasterTemp WHERE username = @userName
  248. END
  249. ELSE
  250. BEGIN
  251. IF EXISTS(SELECT 'x' FROM dbo.customerMaster (NOLOCK) WHERE username = @userName)
  252. BEGIN
  253. UPDATE dbo.customerMaster SET
  254. occupation = ISNULL(@occupation, occupation),
  255. monthlyIncome= ISNULL(@monthlyIncome, monthlyIncome),
  256. employeeBusinessType=ISNULL(@businessType, employeeBusinessType),
  257. mobile = ISNULL(@mobile, mobile),
  258. ADDITIONALADDRESS = ISNULL(@additionalAddress, ADDITIONALADDRESS),
  259. idType = ISNULL(@idType, idType),
  260. documentType = ISNULL(@additionalIdType, documentType),
  261. nameOfEmployeer = ISNULL(@employeerName, nameOfEmployeer),
  262. otherIdNumber = @otherIdType,
  263. occupationOther = @otherOccupation,
  264. purposeOfRegistration = ISNULL(@purposeOfRegistration, purposeOfRegistration)
  265. WHERE username = @userName
  266. END
  267. END
  268. END
  269. IF @type = '1'
  270. BEGIN
  271. IF ISNULL(@idFront, '') <> ''
  272. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  273. SELECT ISNULL(@customerId, @cust), @idFront, 'idFrontCustUpload', @userName, GETDATE(), 11394, 'Y'
  274. IF ISNULL(@idBack, '') <> ''
  275. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  276. SELECT ISNULL(@customerId, @cust), @idBack, 'idBackCustUpload', @userName, GETDATE(), 11395, 'Y'
  277. IF ISNULL(@idSide, '') <> ''
  278. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  279. SELECT ISNULL(@customerId, @cust), @idSide, 'idSideCustUpload', @userName, GETDATE(), 11388, 'Y'
  280. IF ISNULL(@additionalId, '') <> ''
  281. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  282. SELECT ISNULL(@customerId, @cust), @additionalId, 'additionalIdCustUpload', @userName, GETDATE(), 11396, 'Y'
  283. IF ISNULL(@additionalIdBack, '') <> ''
  284. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  285. SELECT ISNULL(@customerId, @cust), @additionalIdBack, 'additionalIdBackCustUpload', @userName, GETDATE(), 11397, 'Y'
  286. IF ISNULL(@facePicture, '') <> ''
  287. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  288. SELECT ISNULL(@customerId, @cust), @facePicture, 'facePictureCustUpload', @userName, GETDATE(), 11385, 'Y'
  289. UPDATE dbo.customerMaster SET
  290. HasDeclare = 1
  291. WHERE customerId = @customerId
  292. END
  293. COMMIT TRANSACTION
  294. IF @@TRANCOUNT=0
  295. BEGIN
  296. SELECT 0 as ERRORCODE, 'KYC Submitted successfully' AS MSG, @userName AS ID,@cust AS EXTRA
  297. RETURN
  298. END
  299. EXEC proc_errorHandler 1, 'Failed to Submit KYC', @userName
  300. RETURN
  301. END
  302. ELSE IF @flag = 'i-existing'
  303. BEGIN
  304. IF NOT EXISTS(SELECT TOP 1 'A' FROM customerMaster(NOLOCK) WHERE username = @userName)
  305. BEGIN
  306. EXEC proc_errorHandler 1, 'Invalid user supplied!', @userName
  307. RETURN
  308. END
  309. --IF EXISTS(SELECT 'X' FROM customerMaster with (nolock)
  310. -- WHERE mobile = @mobile
  311. -- and ISNULL(onlineUser, 'N')='Y'
  312. -- AND isnull(isDeleted,'N')='N'
  313. -- AND customerId <> @customerId)
  314. --BEGIN
  315. -- SELECT @errorMsg = 'Customer with mobile number ' + @mobile + ' already exist.'
  316. -- EXEC proc_errorHandler 1, @errorMsg, @customerId
  317. -- RETURN
  318. --END
  319. IF @idType IS NULL AND @otherIdType IS NOT NULL
  320. SET @idType = 11402
  321. IF @occupation IS NULL AND @otherOccupation IS NOT NULL
  322. SET @occupation = 11383
  323. --alter table customerMasterTemp add documentType varchar(20)
  324. BEGIN TRANSACTION
  325. IF @type IN ('0', '1')
  326. BEGIN
  327. IF EXISTS (SELECT 'X' FROM dbo.customerMasterTemp (NOLOCK) WHERE username = @userName)
  328. BEGIN
  329. UPDATE dbo.customerMasterTemp SET
  330. occupation = ISNULL(@occupation, occupation),
  331. monthlyIncome= ISNULL(@monthlyIncome, monthlyIncome),
  332. employeeBusinessType=ISNULL(@businessType, employeeBusinessType),
  333. mobile = ISNULL(@mobile, mobile),
  334. ADDITIONALADDRESS = ISNULL(@additionalAddress, ADDITIONALADDRESS),
  335. idType = ISNULL(@idType, idType),
  336. documentType = ISNULL(@additionalIdType, documentType),
  337. nameOfEmployeer = ISNULL(@employeerName, nameOfEmployeer),
  338. otherIdNumber = @otherIdType,
  339. occupationOther = @otherOccupation,
  340. purposeOfRegistration = ISNULL(@purposeOfRegistration, purposeOfRegistration)
  341. WHERE username = @userName
  342. INSERT INTO dbo.customerMaster
  343. (
  344. fullName,firstName,mobile,gender,dob,occupation,nativeCountry,country,bankName,bankAccountNo,idType,idNumber,homePhone,idIssueDate
  345. ,idExpiryDate,verifyDoc1,verifyDoc2,verifyDoc3,SelfieDoc,referelCode,createdBy,createdDate,isActive,onlineUser,customerPassword,[address]
  346. ,city,state2,customerType,ADDITIONALADDRESS,monthlyIncome,organizationType,username,anotherIdType,employeeBusinessType,documentType,remittanceallowed
  347. ,txnPin, nameOfEmployeer, visaStatus, occupationOther, purposeOfRegistration
  348. )
  349. SELECT fullName,CMT.firstName,mobile,gender,dob,CMT.occupation,nativeCountry,113,bankName,bankAccountNo,idType,idNumber,CMT.homePhone,
  350. CMT.idIssueDate,idExpiryDate,verifyDoc1,verifyDoc2,verifyDoc3,CMT.selfie,CMT.referelCode,CMT.createdBy,createdDate,'Y','Y',customerPassword,[address]
  351. ,city,state2,4700, ADDITIONALADDRESS,monthlyIncome,organizationType,username,anotherIdType,employeeBusinessType,documentType,1
  352. ,null, nameOfEmployeer, visaStatus, @occupationOther, @purposeOfRegistration
  353. FROM dbo.CustomerMasterTemp AS CMT(NOLOCK)
  354. WHERE CMT.username = @userName
  355. SET @cust = @@IDENTITY
  356. UPDATE dbo.mobile_userRegistration SET customerId = @cust WHERE username = @userName
  357. DELETE FROM customerMasterTemp WHERE username = @userName
  358. END
  359. ELSE
  360. BEGIN
  361. SELECT @customerId = customerId
  362. FROM customerMaster WITH(nolock)
  363. WHERE username = @userName
  364. IF EXISTS(SELECT 'x' FROM dbo.customerMaster (NOLOCK) WHERE username = @userName)
  365. BEGIN
  366. UPDATE dbo.customerMaster SET
  367. occupation = ISNULL(@occupation, occupation),
  368. monthlyIncome= ISNULL(@monthlyIncome, monthlyIncome),
  369. employeeBusinessType=ISNULL(@businessType, employeeBusinessType),
  370. mobile = ISNULL(@mobile, mobile),
  371. ADDITIONALADDRESS = ISNULL(@additionalAddress, ADDITIONALADDRESS),
  372. idType = ISNULL(@idType, idType),
  373. documentType = ISNULL(@additionalIdType, documentType),
  374. nameOfEmployeer = ISNULL(@employeerName, nameOfEmployeer),
  375. visaStatus = ISNULL(@visaStatus, visaStatus),
  376. otherIdNumber = @otherIdType,
  377. occupationOther = @otherOccupation,
  378. purposeOfRegistration = ISNULL(@purposeOfRegistration, purposeOfRegistration)
  379. WHERE username = @userName
  380. END
  381. END
  382. END
  383. IF @type = '1'
  384. BEGIN
  385. IF ISNULL(@idFront, '') <> ''
  386. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  387. SELECT ISNULL(@customerId, @cust), @idFront, 'idFrontCustUpload', @userName, GETDATE(), 11394, 'Y'
  388. IF ISNULL(@idBack, '') <> ''
  389. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  390. SELECT ISNULL(@customerId, @cust), @idBack, 'idBackCustUpload', @userName, GETDATE(), 11395, 'Y'
  391. IF ISNULL(@idSide, '') <> ''
  392. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  393. SELECT ISNULL(@customerId, @cust), @idSide, 'idSideCustUpload', @userName, GETDATE(), 11388, 'Y'
  394. IF ISNULL(@additionalId, '') <> ''
  395. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  396. SELECT ISNULL(@customerId, @cust), @additionalId, 'additionalIdCustUpload', @userName, GETDATE(), 11396, 'Y'
  397. IF ISNULL(@additionalIdBack, '') <> ''
  398. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  399. SELECT ISNULL(@customerId, @cust), @additionalIdBack, 'additionalIdBackCustUpload', @userName, GETDATE(), 11397, 'Y'
  400. IF ISNULL(@facePicture, '') <> ''
  401. INSERT INTO customerDocument (customerId, fileName, fileDescription, createdBy, createdDate, documentType, isOnlineDoc)
  402. SELECT ISNULL(@customerId, @cust), @facePicture, 'facePictureCustUpload', @userName, GETDATE(), 11385, 'Y'
  403. UPDATE dbo.customerMaster SET
  404. HasDeclare = 1
  405. WHERE customerId = @customerId
  406. END
  407. COMMIT TRANSACTION
  408. IF @@TRANCOUNT=0
  409. BEGIN
  410. SELECT 0 as ERRORCODE, 'KYC Submitted successfully' AS MSG, @userName AS ID,@cust AS EXTRA
  411. RETURN
  412. END
  413. EXEC proc_errorHandler 2, 'Failed to Submit KYC', @userName
  414. RETURN
  415. END
  416. END