PageSourceSearch

https://fxboss.firstcitizens.com/app/components/payees/add_new_payee.js?v=31082026-1758

js firstcitizens.com collected 2026-09-24 21:51:23 UTC 14,602 bytes, 430 lines download raw bytes

1var app = angular.module('bossApp');
2app.controller('addNewDomesticPayeeCtrl', ['$scope', '$http', '$state','$window','$anchorScroll','BankService','StaticDataService','$rootScope','$stateParams','PayeeNewEditService','LegalEntityService','CacheFactory','limitToFilter', 
3function($scope,$http,$state,$window,$anchorScroll,BankService,StaticDataService,$rootScope,$stateParams,PayeeNewEditService,LegalEntityService,CacheFactory,limitToFilter) {
4	$scope.loading 			= true;
5	$scope.pinVerified 		= false;
6	$scope.lookupBy			= "Swift";
7	$scope.confirmPayeeInfo = false;
8	$scope.savingPayee = false;
9	$rootScope.isNewPayee = true;
10	var jGrowlLife=20000;
11	LegalEntityService.getLE().then(function(data){
12		$scope.le = angular.copy(data.legalEntity);
13		$scope.twoFARequired = $scope.le.is2FARequiredForNewVendor && !$stateParams.payeeId;
14		
15		// Moved here from down to top
16		if($stateParams.payeeId != undefined){
17			$rootScope.isNewPayee = false;
18			// parameter lcId,PayeeId
19			$scope.noDataErrorMsg = '';
20			PayeeNewEditService.newedit("leId",$stateParams.payeeId).then(function(data){
21				if(!data.success){
22					$scope.noDataErrorMsg = data.errorResponse ? data.errorResponse: 'Beneficiary Not Found';
23					$scope.loading=false;
24					return;
25				}
26				$scope.populatePayeeData(data.responseObj);
27			});
28			var checkExist = setInterval(function() {
29				if($('#addEditBeneficiaryLabel').length){
30					clearInterval(checkExist);
31					var myEl = angular.element(document.querySelector('#addEditBeneficiaryLabel'));
32					myEl.text('Edit Domestic Beneficiary');
33					$scope.addEditBeneficiaryIcon= "glyph-icon icon-pencil-square-o";
34				}
35			}, 100);
36		}else{
37			$rootScope.isNewPayee = true;
38			var payee = {
39			isInternational : false,
40			recipientType : "Individual",
41			legalName : "",
42			aliasName : "",
43			legalAddress : {
44				address1: "",
45				address2: "",
46				city: "",
47				state:"",
48				country: domesticCountryIsoCode,
49				postalCode: "",
50			},
51			phoneNumber : "",
52			emailAddress : "",
53			accountWithBank: "",
54			accountNumber: "",
55			accountCcy : $rootScope.domesticCountryAccCcy,
56			};
57			$scope.payee = payee;
58			$scope.wtfReqd = false;
59			$scope.loading = false;
60			var checkExist = setInterval(function() {
61				if($('#addEditBeneficiaryLabel').length){
62					clearInterval(checkExist);
63					var myEl = angular.element(document.querySelector('#addEditBeneficiaryLabel'));
64					myEl.text('Add Domestic Beneficiary');
65					$scope.addEditBeneficiaryIcon= "glyph-icon icon-plus-square-o";
66				}
67			}, 100);
68		}
69		$scope.loading = false;
70    });
71	$scope.isAllowedToApprove = false;
72	var _user = angular.copy($rootScope.currentUser);
73	var domesticCountryIsoCode = $rootScope.domesticCountryIsoCode
74	
75	/***********************************************
76	|     Populate payee data for Edit Payee	   |
77	***********************************************/		
78	$scope.populatePayeeData = function(_payee){
79			$scope.payee = _payee;
80			$scope.payee.reAccountNumber = $scope.payee.accountNumber;
81			$scope.payee.bankCountry = $scope.payee.accountWithBank.countryName;
82			$scope.payee.isInternational = false;
83			$scope.lookupBy ='BY SWIFT';
84			$scope.is2FARequiredToApprovePayee=false;
85			$scope.isAllowedToApprovePayee($scope.payee);
86			
87			PayeeNewEditService.getWireTransferFields($scope.payee.accountWithBank.isoCountryCode).then(function(data){
88					$scope.WireTransferFields = data.responseObj;
89					if($scope.WireTransferFields != null && $scope.WireTransferFields.length == 0){
90						$scope.wtfReqd = false;
91					}else{
92						$scope.wtfReqd = true;
93					}
94				});
95			var beneficiaryPhoneNumber=$scope.payee.legalAddress.phoneNumber;
96			/*if(beneficiaryPhoneNumber){
97				if(beneficiaryPhoneNumber.indexOf("+")==-1){
98					if(beneficiaryPhoneNumber.indexOf("+")==-1){
99						beneficiaryPhoneNumber="+"+beneficiaryPhoneNumber;
100					}
101					if (!beneficiaryPhoneNumber.startsWith($scope.payee.legalAddress.phoneCountryCode)) {
102						beneficiaryPhoneNumber = $scope.payee.legalAddress.phoneCountryCode + $scope.payee.legalAddress.phoneNumber;
103					}
104				}
105			}*/
106			$scope.payee.phoneNumber = beneficiaryPhoneNumber;
107			$timeout(function(){
108				intlInput.setCountry('');
109				intlInput.setNumber(beneficiaryPhoneNumber?beneficiaryPhoneNumber:"");
110			},200);
111	}	
112
113	/***********************************************
114	| Confirm box if user navigates away from form |
115	***********************************************/
116	let bypassStateRecurrsion;
117	$scope.$on('$stateChangeStart', function( event, toState, toParams, fromState ) {
118		if (bypassStateRecurrsion) return;
119	    if(event.currentScope.payeeForm.$dirty && !event.currentScope.payeeForm.$valid ){
120	    	event.preventDefault();
121			bootbox.confirm({
122				title: "Discard Changes?",
123				message: "All changes will be lost. Do you want to continue?",
124				swapButtonOrder : true,
125				buttons: {
126					confirm: { label: 'Yes', className: 'btn-primary' },
127					cancel:  { label: 'No', className: 'btn-danger' }
128				},
129				callback: function (result) {
130					if( result ){
131						bypassStateRecurrsion = true;
132						$state.go(toState, toParams, { notify: true });
133						return result;
134					}
135				}
136			}); // End confirm box
137	    }// End IF
138	});
139	
140
141	$scope.addPayee = function(){
142		var errors=$scope.payeeForm.$error;
143		if(!errors.required && !errors.swiftValidate && !$scope.payeeForm.$invalid){
144			$scope.payee.phoneNumber = intlInput.getNumber();
145			//Call validation method to validate payeeForm 
146			var payee = angular.copy($scope.payee);
147			payee.legalAddress.emailAddress=payee.emailAddress;
148			if(payee){
149				if (payee.phoneNumber && !payee.phoneNumber.startsWith("+")) {
150					bootbox.confirm({
151						title: "Warning Message",
152						message: "Mobile numbers outside the US must be prefixed with +Country Code (e.g. +49 for Germany). For US numbers this is not mandatory. Do you want to proceed?",
153						swapButtonOrder: true,
154						buttons: {
155							confirm: { label: 'Yes', className: 'btn-primary' },
156							cancel: { label: 'No', className: 'btn-danger' }
157						},
158						callback: function (result) {
159							if (result) {
160								$scope.proceedValidatePayee(payee);
161								return result;
162							}
163						}
164					});
165				}else{
166					$scope.proceedValidatePayee(payee);
167				}
168			}
169		}else{
170			$anchorScroll(); // <-- scrolls to the top
171		    // Show invlaid form data notificaiton using jGrowl.
172		    $.jGrowl("Form contains invalid data. Please verify and try again.", {
173		      life:jGrowlLife,
174              sticky: false,
175              position: 'top-right',
176              theme: 'notification-size notification-warning'
177		    });
178		}
179	}
180	$scope.proceedValidatePayee = function(payee){
181		PayeeNewEditService.validatePayee(payee,$scope).then(function(response){
182			$location.hash('payee_confirm_div');
183		});
184	}
185	
186	/***********************************************
187	|     Populate wtf based on bank selection	   |
188	***********************************************/		
189	$scope.populateBankDetail = function(bank){
190		$scope.payee.accountWithBank = bank;
191
192		PayeeNewEditService.getWireTransferFields(domesticCountryIsoCode).then(function(data){
193			$scope.WireTransferFields = data.responseObj;
194			if($scope.WireTransferFields != null && $scope.WireTransferFields.length == 0){
195				$scope.wtfReqd = false;
196			}else{
197				$scope.wtfReqd = true;
198			}
199		});
200	}
201	
202	/***********************************************
203	|			Bank lookup based on SWIFT	   	   |
204	***********************************************/		
205	$scope.searchBanksWithRoutingNo = function(nbidChar) {
206		
207		return BankService.searchBanksWithNBID("US", nbidChar).then(function(response){
208			if(response.success ){
209				if(response.responseObj.length > 0){
210					if(response.responseObj.length==1 && response.responseObj[0].nationalId==nbidChar){
211						$scope.populateBankDetail(response.responseObj[0]);
212						return false;
213					}
214					return limitToFilter(response.responseObj, 10);
215				}else{
216					$scope.payeeForm.nationalId.$error.required = true;
217				}
218			}else{
219				// TODO : Handle if request failed 
220			}	
221		});
222	};
223	/***********************************************
224	|			Country List typeahead list   	   |
225	***********************************************/
226	StaticDataService.newCountryList().then(function(response){
227    	if(response.responseObj == undefined || response.responseObj == null){
228    		$scope.countryObjList = response;
229    	}else{
230    		$scope.countryObjList = response.responseObj;
231    	}
232	});
233	/***********************************************
234	| Populate Country details on country select   |
235	***********************************************/
236	$scope.populateCountryDetails = function(selectedCountry){
237		// set the lookup method list and currency list for that country 
238		var tempLookupList = selectedCountry.lookupMethods;
239		if(tempLookupList){
240			$scope.lookupMethodList = tempLookupList.split(',');
241		}
242		
243		var tempCcyList = selectedCountry.paymentCurrencies;
244		if(tempCcyList){
245			$scope.ccyList = tempCcyList.split(',');
246		}
247		$scope.NBIDLabel = selectedCountry.nationalBankIdentifierLabel;
248		$scope.payee.bankIsoCountryCode = selectedCountry.code;
249		$scope.payee.nationalBankIdentifierLabel = selectedCountry.nationalBankIdentifierLabel;
250	}
251	
252	/*
253	*  Cancel Adding payee
254	*/
255	$scope.cancelAddingPayee = function(){
256		$scope.confirmPayeeInfo = false;
257	}
258	/*
259	* Confirm payee and add
260	*/
261	$scope.confirmPayee = function(){
262		$anchorScroll();
263		var payee = $scope.payee; 
264		$scope.savingPayee = true;
265		payee.legalAddress.isoCountryCode=payee.accountWithBank.isoCountryCode;
266		payee.legalAddress.emailAddress=payee.emailAddress;
267		PayeeNewEditService.savePayee(payee).then(function(response){
268			var starResponse = response; 
269			if(starResponse.success){
270				// Change to differentiate Add and Edit succcess msgs 
271				$.jGrowl("Beneficiary saved successfully", {
272				life:jGrowlLife,
273		        sticky: false,
274		        position: 'top-right',
275		        theme: 'notification-size notification-success'
276			    });
277				var payeeCache = CacheFactory.get('payeeCache');  
278				payeeCache.removeAll(); // All Caching should be gandled in **Service.js
279				$state.go("home.payee.managePayees");
280			}else{
281				$.jGrowl("Error while saving Beneficiary. Error:["+ starResponse.errorCode + "] : " +starResponse.errorResponse, {
282					life:jGrowlLife,
283			        sticky: false,
284			        position: 'top-right',
285			        theme: 'notification-size notification-error'
286				    });
287			}
288			$scope.savingPayee = false;
289		});
290	}
291	/**
292		Two-Factor
293	**/
294	$scope.sendVerificationCode = function(method){
295		//service call
296		$scope.enterVerficationCode = true;
297		$scope.pendingVerification = true;
298	}
299	$scope.verifyPin = function(pin){
300		//service call
301		$scope.pinVerified = true;
302	}
303	$scope.validateReAccountNo = function(){
304		if($scope.payee.accountNumber !== $scope.payee.reAccountNumber){
305			$scope.payee.accountNoMismatch = true;
306			$scope.payeeForm.reAccountNumber.$setValidity("same",false);
307			}else{
308			$scope.payeeForm.reAccountNumber.$setValidity("same",true);
309		}
310	}
311	/**
312	* Function to disable paste.
313	*/
314	 $scope.paste = function(e){
315		e.preventDefault();
316       return false
317    }
318	
319	/*
320	* Function To Approve Payee.
321	* GT-477	
322	*/
323	 $scope.isAllowedToApprovePayee= function(payee){
324		var result = true;
325		let _payee = payee;
326		if($scope.le.noOfRequiredBeneAuth > 0 && _payee.status ){
327			if(_user.userId.toLowerCase() == _payee.lastUpdatedBy.toLowerCase()){
328				result = false;
329			}
330		}
331		// Add Validation Based On Entitlement if User does not have add/suspend user entitlement display appropriate error message.
332		let _allowedToApprove = $rootScope.entitlements.filter(function (key,value) {return (key == "FXWEB_AUTHORIZE_BENEFICIARY");});
333		let _allowedToSuspend = $rootScope.entitlements.filter(function (key,value) {return (key == "FXWEB_SUSPEND_BENEFICIARY");});
334		if(_allowedToApprove.length==0 && _payee.status!='Active'){
335			result = false;
336		}
337		if((_allowedToSuspend.length>0 && _payee.status=='Active')){
338			$scope.isAllowedToSuspend = true;
339		}
340		//check if 2FA Required for Approval.
341		if(_payee.status && result){
342			$scope.is2FARequiredToApprovePayee = $scope.le.is2FARequiredToApproveVendor;
343		}
344		$scope.isAllowedToApprove = result;
345	}
346	
347/**
348	 * Authorize Payee
349	 */
350	$scope.authorizePayee = function(_payeeId){
351		PayeeNewEditService.authorizePayee(_payeeId).then(function(response){
352			if(response.success){
353				$.jGrowl("Payee Authorized successfully", {
354					life:jGrowlLife,
355			        sticky: false,
356			        position: 'top-right',
357			        theme: 'notification-size notification-success'
358				    });
359					$state.go('home.payee.managePayees',{});
360			}else{
361				$.jGrowl("Payee Authorization failed", {
362					life:jGrowlLife,
363			        sticky: false,
364			        position: 'top-right',
365			        theme: 'notification-size notification-error'
366				    });
367			}
368		});
369	}
370	
371	/**
372	 * Suspend Payee
373	 */
374	$scope.suspendPayee = function(_payeeId){
375		PayeeNewEditService.suspendPayee(_payeeId).then(function(response){
376			if(response.success){
377				$.jGrowl("Payee suspended successfully", {
378					life:jGrowlLife,
379			        sticky: false,
380			        position: 'top-right',
381			        theme: 'notification-size notification-success'
382				    });
383					$state.go('home.payee.managePayees',{});
384			}else{
385				$.jGrowl("Payee suspension failed", {
386					life:jGrowlLife,
387			        sticky: false,
388			        position: 'top-right',
389			        theme: 'notification-size notification-error'
390				    });
391			}
392		});
393	}
394
395	$scope.toggleStatus=function(isActivationRequest, payeeId){
396		 if(isActivationRequest){
397				//call activate/approve method
398			 	$scope.authorizePayee(payeeId);
399			}
400			else{
401				//call suspend method
402				$scope.suspendPayee(payeeId);
403			}
404	 }	
405	 $scope.beneIntlTelInput = function(id){
406		var input = document.querySelector("#"+id);
407		var formname=$("#"+id).closest("form").attr("name");
408		var iti = window.intlTelInput(input, {
409		utilsScript: "app/assets/intl/intl-utils.js",
410		});
411		var handleChange = function() {
412			if (iti.isValidNumber()) {
413				$scope[formname][id].$setValidity(id, true);
414				var number = iti.getNumber();
415				$scope[id] = number;
416				iti.setNumber(number);
417			} else if(iti.getNumber()){
418				  $scope[formname][id].$setValidity(id, false);
419				}else{
420					$scope[formname][id].$setValidity(id, true);
421				}
422			$scope.$apply();
423		};
424		document.querySelector("#"+id).addEventListener('countrychange', handleChange);
425		document.querySelector("#"+id).addEventListener('change', handleChange);
426		document.querySelector("#"+id).addEventListener('keyup', handleChange);
427		return iti;
428	}
429	var intlInput = $scope.beneIntlTelInput("phoneNumber");
430}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.