PageSourceSearch

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

js firstcitizens.com collected 2026-09-24 21:51:22 UTC 11,866 bytes, 348 lines download raw bytes

1var app = angular.module('bossApp');
2app.controller('managePayeeCtrl', ['$scope', '$http', 'PayeeNewEditService','LegalEntityService','SearchService', '$state','$rootScope','$location', '$timeout','CommonService', function($scope, $http, PayeeNewEditService, LegalEntityService,SearchService, $state, $rootScope,$location, $timeout, CommonService) {
3	$rootScope.isNewPayee = true;
4    $scope.loadingTable = true;
5    $scope.loggedInUser = angular.copy($rootScope.currentUser);
6    var myEl = angular.element(document.querySelector('#addEditBeneficiaryLabel'));
7	myEl.text('Add Beneficiary');
8	$scope.addEditBeneficiaryIcon= "glyph-icon icon-plus-pencil-square-o ";
9	
10	 LegalEntityService.getLE().then(function(data){
11		$scope.le = angular.copy(data.legalEntity);
12		payee_list();
13    });
14	
15    function payee_list(){
16	    PayeeNewEditService.payee_list().then(function(data) {
17			$scope.loadData(data);
18	    });
19	}
20    
21	$scope.loadData= function(data){
22		//$scope.payeeList = angular.copy(response.responseObj);
23		///$scope.loadingTable = false;
24		var responseObj = data.responseObj;
25		var accounts=CommonService.maskAccountNumber(responseObj);
26		var _payeeList = [];
27		for(var i in accounts){
28			accounts[i]["isActive"] = (accounts[i].status=="Active")?true:false
29			_payeeList.push(accounts[i]);
30		}
31		$scope.payeeList = _payeeList;
32		//pagination
33		$scope.tableViewby = "10";
34		$scope.tableTotalItems = ($scope.payeeList!=undefined)?$scope.payeeList.length:0; 
35		$scope.tableCurrentPage = 1;
36		$scope.tableItemsPerPage = $scope.tableViewby;
37		$scope.loadingTable = false;
38    }
39	
40	
41	/**
42	* Edit Payee on edit click
43	*/
44	$scope.editInternationalPayee = function(_payeeId) {
45		$rootScope.isNewPayee = false;
46		$state.go("home.payee.addAPayee.editInternationalPayee", { 'payeeId': _payeeId });
47	}
48	
49	$scope.editDomesticPayee = function(_payeeId) {
50		$rootScope.isNewPayee = false;
51		$state.go("home.payee.addAPayee.editDomesticPayee", { 'payeeId': _payeeId });
52	}
53	
54	/**
55	* Delete Payee
56	*/
57	$scope.deletePayee = function(_payeeId){
58		PayeeNewEditService.deletePayee(_payeeId).then(function(response){
59			if(response.success){
60				$.jGrowl("Payee Deleted successfully", {
61			        sticky: false,
62			        position: 'top-right',
63			        theme: 'notification-size notification-success'
64				    });
65			}else{
66				$.jGrowl("Payee deletion failed", {
67			        sticky: false,
68			        position: 'top-right',
69			        theme: 'notification-size notification-error'
70				    });
71			}
72			payee_list();
73		});
74	}
75
76	
77	/***
78	* Enable 2FA for Approval.
79	*/
80	$scope.isTwoFARequiredForApproval = function(_payee,index,actionSource) {
81		
82		let isActivationRequest = (_payee.status !== 'Active');
83		let payeeId = _payee.id;
84		if(!isActivationRequest){
85			// If dual aproval is false toggle the Btn.
86			toggleStatus(isActivationRequest, payeeId);
87		}else if($scope.le.is2FARequiredToApproveVendor){
88				// If 2fa is set to true enable 2fa component.
89				_payee.enableTwoFAComponent = angular.copy(!_payee.enableTwoFAComponent);
90				if("Cancel" != actionSource)
91					_payee.isActive = angular.copy(!$scope.payeeList[index].isActive);
92		}else{
93			// If 2fa is set to false save the user.
94			toggleStatus(isActivationRequest, payeeId);
95		}
96		
97	}
98	
99	$scope.isAllowedToApprove = function(_payee){
100		var result = false;
101		if($scope.le.noOfRequiredBeneAuth == 1){
102			if($scope.loggedInUser.userId.toLowerCase() == _payee.lastUpdatedBy.toLowerCase()){
103				_payee.disabledMsg = "Same user is not allowed to ";
104				if(_payee.status != 'Active'){
105					_payee.disabledMsg += "Approve";
106				}else{
107					_payee.disabledMsg += "Suspend";
108				}
109				result = true;
110			}
111		}else{
112			_payee.disabledMsg = "";
113		}
114	
115			// Add Validation Based On Entitlement if User does not have add/suspend user entitlement display appropriate error message.
116			let _allowedToApprove = $rootScope.entitlements.filter(function (key,value) {return (key == "FXWEB_AUTHORIZE_BENEFICIARY");});
117			let _allowedToSuspend = $rootScope.entitlements.filter(function (key,value) {return (key == "FXWEB_SUSPEND_BENEFICIARY");});
118			if(_allowedToApprove.length==0 && _payee.status!='Active'){
119				_payee.disabledMsg = "You are not allowed to approve..";
120				result = true;
121			}
122			if((_allowedToSuspend.length==0 && _payee.status=='Active')){
123				_payee.disabledMsg = "You are not allowed to suspend.";
124				result = true;
125			}
126
127		return result;
128	}
129	
130	$scope.twoFAComponentCallBack = function(_sourceObject){
131		console.log("_sourceObject",_sourceObject);
132		let isActive = (_sourceObject.status !== 'Active');
133		toggleStatus(isActive, _sourceObject.id);
134	}
135	
136	/***
137	* Smart-Simple Toggle ng-repeat.
138	*/
139	$scope.toggleFilter = function(item) {
140      item.toggle = angular.copy(!item.toggle);
141    }
142	
143	/*
144	//pagination
145	$scope.tableViewby = "10";
146	$scope.tableTotalItems = ($scope.payeeList!=undefined)?$scope.payeeList.length:0; 
147	$scope.tableCurrentPage = 1;
148	$scope.tableItemsPerPage = $scope.tableViewby;
149
150	 */
151	
152	$scope.setTableItemsPerPage = function(num) {
153	$scope.tableItemsPerPage = num;
154	$scope.tableCurrentPage = 1; //reset to first paghe
155	}
156	
157
158	
159	/**
160	* Advanced Search Filter.
161	*/
162	$scope.toggleSmartSearch = false;
163	$scope.searchTooltipText = "Open Advanced Search.";
164	$scope.displayAdvancedSearch = function(){
165		$scope.toggleSmartSearch = angular.copy(!$scope.toggleSmartSearch);
166		var _toggle = angular.copy($scope.toggleSmartSearch);
167		$scope.searchTooltipText = (_toggle)?"Close Advanced Search.":"Open Advanced Search.";
168		
169	}
170	$scope.advancedSearch = function(search){
171		$scope.advancedSearchVal = search; // used for export data by search option
172		if(isSearchFieldsValid(search)){
173			SearchService.searchPayee(search).then(function(response){
174				$scope.loadData(response);
175			});
176		}else{
177			payee_list(); // load user data from cache.
178		}
179	}
180	$scope.resetSearchCriteria = function(){
181		$scope.search = undefined; // remove all search criteria.
182		$scope.advancedSearchVal = undefined; // reset advancedSearchVal
183		payee_list(); // load user data from cache.
184	}
185	function isSearchFieldsValid(search){
186		var isValid = false;
187		if(search){
188			if(search.aliasName || search.legalName || search.accountNumber || search.institutionName || search.accountCcy){
189				isValid = true;	
190			}
191		}
192		return isValid;
193	}
194	
195	$scope.displayAddress = function(bank) {
196		var str="";
197		if(bank.city){
198			str+=bank.city;
199		}
200		if(bank.zipCode){
201			if(str)str+=",";
202			str+=bank.zipCode;
203		}
204		if(bank.countryName){
205			if(str)str+=",";
206			str+=bank.countryName;
207		}
208		return str;
209	}
210	
211	$scope.downloadCSV = function (csv, filename) {
212		var csvFile;
213		var downloadLink;
214
215		// Create CSV file
216		// For IE
217		if (window.navigator.msSaveOrOpenBlob) {
218			var blob = new Blob([decodeURIComponent(encodeURI(csv))], {
219				type: "text/csv;charset=utf-8;"
220			});
221			navigator.msSaveBlob(blob, filename + ".csv");
222		 }else{
223			csvFile = new Blob([csv], {type: "text/csv;charset=utf-8"});
224			// Download link
225			downloadLink = document.createElement("a");
226			// File name
227			downloadLink.download = filename + ".csv";
228			// Create a link to the file
229			downloadLink.href = window.URL.createObjectURL(csvFile);
230			// Hide download link
231			downloadLink.style.display = "none";
232			// Add the link to DOM
233			document.body.appendChild(downloadLink);
234			// Click download link
235			downloadLink.click();
236			// Cleanup the DOM
237			document.body.removeChild(downloadLink);
238			delete downloadLink;
239		}
240	}
241	$scope.exportToCSV = function (filename) {
242		var colHeaders = [];
243		var csv = [];
244		var columnsList = document.querySelectorAll("#datatable-tabletools tr th");
245		angular.forEach(columnsList, function(obj, key){
246			if( obj.innerHTML != "Action"){
247				colHeaders.push( obj.innerHTML );
248			}
249		});
250
251		var bic = "SWIFT/BIC"
252		colHeaders.push(bic);
253
254		csv.push(colHeaders.join(",")); 
255		
256		SearchService.searchPayee( $scope.advancedSearchVal ? $scope.advancedSearchVal : "" ).then(function(data){
257			var rows = angular.copy( data.responseObj );
258			for (var i = 0; i < rows.length; i++) {
259				var row = [];
260				row.push($scope.sanitizeCsvValue(rows[i].aliasName));
261				row.push($scope.sanitizeCsvValue(rows[i].legalName));
262				row.push($scope.sanitizeCsvValue(rows[i].accountNumber));
263				row.push($scope.sanitizeCsvValue(rows[i].accountWithBank.institutionName));
264				row.push($scope.sanitizeCsvValue(rows[i].accountCcy + " / " + rows[i].accountWithBank.countryName));
265				row.push($scope.sanitizeCsvValue(rows[i].lastPaymentAmount && rows[i].lastPaymentDate ? rows[i].lastPaymentAmount + " " + rows[i].accountCcy + " on " + rows[i].lastPaymentDate : ""));
266				row.push($scope.sanitizeCsvValue(rows[i].status));
267				row.push($scope.sanitizeCsvValue(rows[i].accountWithBank.bic));
268
269				csv.push(row.join(","));
270			}
271			// Download CSV file
272			$scope.downloadCSV(csv.join("\n"), filename);
273		}).catch(function(fallback) {
274			console.error( fallback );
275		});
276	}
277	$scope.exportToMSExcel = function (filename) {
278		$scope.exportExcel = true;
279		$scope.colHeadersForExcel = [];
280		var columnsList = document.querySelectorAll("#datatable-tabletools tr th");
281		angular.forEach(columnsList, function(obj, key){
282			if( obj.innerHTML != "Action"){
283				$scope.colHeadersForExcel.push( obj.innerHTML );
284			}
285		});
286
287		var bic = "SWIFT/BIC"
288		$scope.colHeadersForExcel.push(bic);
289
290		SearchService.searchPayee( $scope.advancedSearchVal ? $scope.advancedSearchVal : "" ).then(function(data){
291			$scope.exportBenTemplateRows = data.responseObj;
292			$timeout(function(){
293				downloadMSExcel("ben_template_excel", filename);
294			}, 300);
295		});
296	}
297
298	$scope.formatPayment = function (lastPaymentAmount, accountCcy, lastPaymentDate) {
299		if (lastPaymentAmount && lastPaymentDate && !isNaN(lastPaymentAmount)) {
300			var formatedAmount = parseFloat(lastPaymentAmount.toString().replace(/[^0-9.-]+/g, ""));
301			return formatedAmount.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
302				+ " " + accountCcy + " on " + lastPaymentDate;
303		}
304		return "";
305	};
306	
307
308	var downloadMSExcel = (function() {
309     var uri = 'data:application/vnd.ms-excel;charset=utf-8;base64,' // this for .xls
310        , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
311        , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
312        , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
313      return function(table, name) {
314        if (!table.nodeType) table = document.getElementById(table);
315        var ctx = {worksheet: name || 'Sheet1', table: table.innerHTML}
316		if (window.navigator.msSaveOrOpenBlob) {
317			var blob = new Blob([format(template, ctx)], { type: 'application/vnd.ms-excel', endings: 'native' });
318			navigator.msSaveBlob(blob, name + ".xls");
319		 }else{
320			var downloadLink = document.createElement("a");
321			downloadLink.download = name + ".xls"; // download file name
322			downloadLink.href = uri + base64(format(template, ctx));
323			downloadLink.style.display = "none";
324			document.body.appendChild(downloadLink);
325			downloadLink.click();
326			document.body.removeChild(downloadLink);
327			delete downloadLink;
328		 }
329		$scope.exportExcel = false;
330      }
331    })();
332    
333	$scope.sanitizeCsvValue = function (value) {
334		if (value === null || value === undefined) {
335			return "";
336		}
337		value = value.toString();
338		if (/^[=+\-@]/.test(value)) {
339			value = "'" + value;
340		}
341		value = value.replace(/"/g, '""');
342		if (/[",\n]/.test(value)) {
343			value = '"' + value + '"';
344		}
345		return value;
346	}; 
347	
348}]);

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.