1app.controller('reportsController', [ 2 '$scope', 3 '$rootScope', 4 '$http', 5 '$timeout', 6 '$state', 7 '$interval', 8 '$anchorScroll', 9 '$location', 10 '$stateParams', 11 'ReportService', 12 '$filter', 13 'AccountSummaryService', 14 'PayeeNewEditService', 15 'CommonService', 16 'UserNewEditService', 17 function($scope, $rootScope, $http, $timeout, $state, $interval, 18 $anchorScroll, $location, $stateParams, ReportService, $filter, 19 AccountSummaryService,PayeeNewEditService,CommonService,UserNewEditService) { 20 $scope.reportCriteria={}; 21 var _user = angular.copy($rootScope.currentUser); 22 var statusMap = { 23 "RejectedBySystem": "Rejected By System", 24 "RejectedByTrader": "Rejected By Trader", 25 "PriceInFuture": "Scheduled", 26 "Declined": "Cancelled" 27 }; 28 function resetCriteriaConfig() 29 { 30 $scope.criteriaFieldConfig = [ 31 {listName:"Available",items:[], dragging: false}, 32 {listName:"Selected",items:[], dragging: false} 33 ]; 34 $scope.reportFieldConfig = [ 35 {listName:"Available",items:[], dragging: false}, 36 {listName:"Selected",items:[], dragging: false} 37 ]; 38 $scope.criteriaUsersConfig = [ 39 {listName:"Available",items:[], dragging: false}, 40 {listName:"Selected",items:[], dragging: false} 41 ]; 42 } 43 resetCriteriaConfig(); 44 45 $scope.loading=true; 46 /** This method will be used for both add criteria and view criteria pages**/ 47 $scope.getReportTypes=function(){ 48 ReportService.getReportTypes().then(function(response){ 49 if(response.success){ 50 $scope.reportTypes=response.responseObj.reportTypes; 51 $scope.accessTypes=response.responseObj.accessTypes; 52 $scope.counterpartList=response.responseObj.counterpartList; 53 54 $scope.counterPartyMap = {}; 55 for (var i = 0; i < $scope.counterpartList.length; i++) { 56 var counterParty = $scope.counterpartList[i]; 57 $scope.counterPartyMap[counterParty.id] = counterParty; 58 } 59 60 $scope.channelList=response.responseObj.channelList; 61 $scope.enumList={"Payment Status":response.responseObj.paymentStatusList}; 62 } 63 64 if($stateParams.reportId){ 65 $scope.populateEditReport(); 66 } 67 }); 68 }; 69 70 $scope.loadReportList=function(){ 71 $scope.loadingTable1=true; 72 ReportService.loadReportList(0).then(function(response){ 73 if(response.success){ 74 let reportlist=[] 75 angular.forEach(response.responseObj, function(item) { 76 if(item.accessType=="Company"){ 77 if(item.companyId==_user.entityId){ 78 //item.reportType = angular.copy(reportType); 79 reportlist.push(item); 80 } 81 }else if(item.accessType=="User"){ 82 if (item.reportUser && item.reportUser.some(user => user.toLowerCase() === _user.userId.toLowerCase())) { 83 reportlist.push(item); 84 } 85 }else{ 86 //item.reportType = angular.copy(reportType); 87 reportlist.push(item); 88 } 89 }); 90 91 $scope.reports=angular.copy(reportlist); 92 } 93 $scope.loadAccounts(); 94 $scope.loadingTable1=false; 95 }); 96 }; 97 $scope.canViewReport = true; 98 $scope.populateEditReport=function(){ 99 ReportService.getReportAndOptions($stateParams.reportId).then(function(response){ 100 let selectedReport=response.responseObj; 101 if(selectedReport && selectedReport.report){ 102 var _report = selectedReport.report; 103 if(_report.accessType=="User"){ 104 var isUserPresent = null; 105 if(_report.reportUser){ 106 isUserPresent = _report.reportUser.map(function(userId) { 107 return userId.toLowerCase(); 108 }).includes(_user.userId.toLowerCase()); 109 } 110 if(!_report.reportUser || !isUserPresent){ 111 return; 112 } 113 } 114 $scope.selectedReport=_report; 115 let reportType=$scope.selectedReport.reportTypeView.id; 116 $scope.reportCriteria.reportType=reportType; 117 $scope.reportCriteria.accessType=$scope.selectedReport.accessType; 118 $scope.reportCriteria.reportName=$scope.selectedReport.reportName; 119 if($scope.selectedReport.reportFields){ 120 $scope.reportFieldConfig[1].items=$scope.selectedReport.reportFields; 121 $scope.criteriaFieldConfig[1].items=$scope.selectedReport.searchCriteria; 122 } 123 $scope.changeReportType(); 124 }else{ 125 $scope.canViewReport = false;
126 $scope.noDataErrorMsg = "Report with id: "+$stateParams.reportId +" not found"; 127 } 128 }); 129 } 130 131 $scope.getReportTypes(); 132 $scope.loadAccounts=function(loadOnlyPayee,search,includeCustomerId,isObjectIdExists){ 133 PayeeNewEditService.payee_list().then(function(response) { 134 $scope.filterUserActivePayees(response); 135 if(!loadOnlyPayee){ 136 AccountSummaryService.getAllAccounts().then(function(response) { 137 $scope.filterUserActiveAccounts(response); 138 loadUserList(); 139 }); 140 }else{ 141 if (isObjectIdExists) { 142 const existingCondition = search.conditions.find(condition => condition.field === "objectId"); 143 if (!existingCondition) { 144 search.conditions.push({ condition: "in", value: $scope.payeeIdList.join(","), field: "objectId" }); 145 } 146 } 147 search.conditions.push({ condition: "is", value: "TransactionAccount", field: "objectType" }); 148 $scope.searchReportsByCriteria(search, includeCustomerId); 149 } 150 }); 151 } 152 /** 153 * Load User List for this particular Entity. 154 */ 155 function loadUserList(){ 156 UserNewEditService.getUserList().then(function(data){ 157 $scope.loading=false; 158 var responseObj = data.responseObj; 159 var _userList = []; 160 for(var i in responseObj){ 161 responseObj[i]["isActive"] = (responseObj[i].status=="Active")?true:false 162 _userList.push(responseObj[i]); 163 } 164 $scope.userList = _userList; 165 $scope.criteriaUsersConfig[0].items=JSON.parse(JSON.stringify($scope.userList)); 166 if($stateParams.reportId){ 167 angular.forEach($scope.selectedReport.reportUser, function(_reportuserId,index) { 168 var foundItem = $filter('filter')($scope.criteriaUsersConfig[0].items, function (item) { 169 return item.userId.toLowerCase() === _reportuserId.toLowerCase(); 170 }, true); 171 if(foundItem && foundItem.length>0){ 172 let idx = $scope.criteriaUsersConfig[0].items.indexOf(foundItem[0]); 173 if(idx!=-1){ 174 $scope.criteriaUsersConfig[1].items.push($scope.criteriaUsersConfig[0].items[idx]); 175 $scope.criteriaUsersConfig[0].items.splice(idx,1); 176 } 177 } 178 }); 179 } 180 }); 181 } 182 183 $scope.changeReportType=function(){ 184 $scope.loadingTable1=true; 185 let reportType=null; 186 if(!$stateParams.reportId){ 187 resetCriteriaConfig(); 188 $scope.resetSearchCriteria(); 189 $scope.reports=[]; 190 $scope.inputCriterias=undefined; 191 $scope.searchResults=[]; 192 $scope.hideCriteria=false; 193 } 194 reportType=$scope.reportTypes.filter(function(item) { return item.id==$scope.reportCriteria.reportType; }); 195 if(reportType!=null && reportType.length>0) 196 ReportService.getReportType(reportType[0].id).then(function(data){ 197 reportType=data.responseObj; 198 if(!$stateParams.reportId){ 199 $timeout(function(){ 200 $scope.reportCriteria.accessType=undefined; 201 if(reportType){ 202 var searchableFields=reportType.reportFields.filter(function(item) { return item.searchable; }); 203 $scope.criteriaFieldConfig[0].items=JSON.parse(JSON.stringify(searchableFields)); 204 $scope.criteriaFieldConfig[1].items=[]; 205 $scope.reportFieldConfig[0].items=JSON.parse(JSON.stringify(reportType.reportFields)); 206 $scope.reportFieldConfig[1].items=[]; 207 } 208 }); 209 }else{ 210 if(reportType){ 211 var reportFields=reportType.reportFields.filter(function(item) { return item.searchable; }); 212 $scope.criteriaFieldConfig[0].items=JSON.parse(JSON.stringify(reportFields)); 213 $scope.reportFieldConfig[0].items=JSON.parse(JSON.stringify(reportType.reportFields)); 214 angular.forEach($scope.criteriaFieldConfig[1].items, function(item,index) { 215 var foundItem = $filter('filter')($scope.criteriaFieldConfig[0].items, { id: item.id }, true)[0]; 216 let idx = $scope.criteriaFieldConfig[0].items.indexOf(foundItem ); 217 if(idx!=-1){ 218 $scope.criteriaFieldConfig[0].items.splice(idx,1); 219 } 220 }); 221 222 angular.forEach($scope.reportFieldConfig[1].items, function(item,index) { 223 var foundItem = $filter('filter')($scope.reportFieldConfig[0].items, { id: item.id }, true)[0]; 224 let idx = $scope.reportFieldConfig[0].items.indexOf(foundItem ); 225 if(idx!=-1){ 226 $scope.reportFieldConfig[0].items.splice(idx,1); 227 } 228 }); 229 } 230 } 231 $scope.loadingTable1=false; 232 }); 233 loadUserList(); 234 }; 235 236 $scope.changeAccessType=function(){ 237 $scope.formError=undefined; 238 $scope.criteriaUsersConfig[1].items=[]; 239 } 240
241 $scope.saveOrUpdateCriteria=function(){ 242 let reportType=$scope.reportTypes.filter(function(item) { return item.id==$scope.reportCriteria.reportType; }); 243 $scope.reportCriteria.searchCriteria=$scope.criteriaFieldConfig[1].items; 244 $scope.reportCriteria.reportFields=$scope.reportFieldConfig[1].items; 245 if($stateParams.reportId)$scope.reportCriteria.id=$stateParams.reportId 246 var existingTemplates = null; 247 if (!$stateParams.reportId && $scope.reports && $scope.reports.length > 0) { 248 existingTemplates = $scope.reports.filter(function(item) { return item.reportName == $scope.reportCriteria.reportName; }); 249 } 250 if(!$scope.reportCriteria.reportName){ 251 $scope.formError="Please enter the Template Name."; 252 return false; 253 } 254 if(existingTemplates!=null && existingTemplates.length>0){ 255 $scope.formError="Template Name already exists."; 256 return false; 257 } 258 if($scope.reportCriteria.accessType=="User"){ 259 if($scope.criteriaUsersConfig[1].items.length>0){ 260 $scope.reportCriteria.reportUser=$scope.criteriaUsersConfig[1].items.map(function(item) { return item.userId; }); 261 }else{ 262 $scope.formError="Please select one or more Users."; 263 return false; 264 } 265 }else if(!$scope.reportCriteria.accessType){ 266 $scope.formError="Please select Access type."; 267 return false; 268 } 269 if($scope.reportFieldConfig[1].items.length==0){ 270 $scope.formError="Please select one or more Report fields."; 271 return false; 272 } 273 if($scope.criteriaFieldConfig[1].items.length==0){ 274 $scope.formError="Please select one or more Criteria fields."; 275 return false; 276 } 277 if(reportType && reportType.length>0) 278 $scope.reportCriteria.reportType=reportType[0]; 279 280 $scope.disableSubmit=true; 281 ReportService.saveOrUpdateCriteria($scope.reportCriteria).then(function(response){ 282 if(response.success){ 283 $state.go("home.reports.viewReports",{}); 284 }else{ 285 $scope.reportCriteria.reportType=JSON.stringify(reportType); 286 $scope.formError=response.errorResponse; 287 $scope.disableSubmit=false; 288 } 289 }); 290 }; 291 292 /** criteriaFieldConfig[0] -> Available Fields 293 criteriaFieldConfig[1] -> Selected Fields**/ 294 $scope.addField=function(field,actionName,index){ 295 $scope.formError=undefined; 296 $scope.criteriaFieldConfig[0].items.splice(index,1); 297 $scope.criteriaFieldConfig[1].items.push(field); 298 }; 299 300 $scope.removeField=function(field,actionName,index){ 301 $scope.criteriaFieldConfig[1].items.splice(index,1); 302 $scope.criteriaFieldConfig[0].items.push(field); 303 }; 304 305 /** reportFieldConfig[0] -> Available Fields 306 reportFieldConfig[1] -> Selected Fields**/ 307 $scope.addColumn=function(field,actionName,index){ 308 $scope.formError=undefined; 309 $scope.reportFieldConfig[0].items.splice(index,1); 310 $scope.reportFieldConfig[1].items.push(field); 311 }; 312 313 $scope.removeColumn=function(field,actionName,index){ 314 $scope.reportFieldConfig[1].items.splice(index,1); 315 $scope.reportFieldConfig[0].items.push(field); 316 }; 317 318 /** criteriaUsersConfig[0] -> Available Fields 319 criteriaUsersConfig[1] -> Selected Fields**/ 320 $scope.addUser=function(field,actionName,index){ 321 $scope.formError=undefined; 322 $scope.criteriaUsersConfig[0].items.splice(index,1); 323 $scope.criteriaUsersConfig[1].items.push(field); 324 }; 325 326 $scope.removeUser=function(field,actionName,index){ 327 $scope.criteriaUsersConfig[1].items.splice(index,1); 328 $scope.criteriaUsersConfig[0].items.push(field); 329 }; 330 331 $scope.getSelectedItemsIncluding = function(list, item) { 332 $scope.formError=undefined; 333 item.selected = true; 334 return list.items.filter(function(item) { return item.selected; }); 335 }; 336 337 $scope.onDragstart = function(list, event,source) { 338 $scope.source=source; 339 list.dragging = true; 340 }; 341 342 $scope.onDrop = function(list, items, index,target) { 343 if($scope.source==target){ 344 angular.forEach(items, function(item) { item.selected = false; }); 345 list.items = list.items.slice(0, index) 346 .concat(items) 347 .concat(list.items.slice(index)); 348 return true; 349 } 350 $.jGrowl("Sorry, Invalid drop location!.", {
351 sticky: false, 352 position: 'top-right', 353 theme: 'notification-size notification-error' 354 }); 355 } 356 357 $scope.onMoved = function(list) { 358 list.items = list.items.filter(function(item) { return !item.selected; }); 359 }; 360 361 /***** Starts View Criteria Page ****/ 362 $scope.inputConfig={ 363 "String": { 364 "type": "text", 365 "options": [ 366 "is", 367 "contains" 368 ], 369 "maxLength": 250 370 }, 371 "Decimal": { 372 "type": "number", 373 "options": [ 374 "is", 375 "greater than", 376 "less than", 377 "between" 378 ], 379 "step": ".01" 380 }, 381 "Date": { 382 "type": "date", 383 "options": [ 384 "is", 385 "from", 386 "to", 387 "between" 388 ] 389 }, 390 "Account": { 391 "type": "List", 392 "options": [ 393 "is" 394 ] 395 } 396 , 397 "Enum": { 398 "type": "Enum", 399 "options": [ 400 "List item" 401 ] 402 }, 403 "Option": { 404 "type": "Option", 405 "options": [ 406 "is" 407 ] 408 }, 409 "Number": { 410 "type": "number", 411 "options": [ 412 "is", 413 "greater than", 414 "less than", 415 "between" 416 ] 417 }, 418 "List": { 419 "type": "List", 420 "options": [ 421 "is" 422 ] 423 }, 424 "MultiSelect": { 425 "type": "MultiSelect", 426 "options": [ 427 "in" 428 ] 429 } 430 }; 431 $scope.viewSearchCriteria={}; 432 $scope.changeTemplate=function(template){ 433 $scope.viewSearchCriteria={}; 434 $scope.loadingTable1=true; 435 var selectedTemplate=angular.isObject(template)?template:JSON.parse(template); 436 ReportService.getReportAndOptions(selectedTemplate.id).then(function(response){ 437 selectedTemplate=JSON.parse(JSON.stringify(response.responseObj.report)); 438 var _reportType=selectedTemplate.reportTypeView; 439 $scope.reportSource=_reportType.reportSource; 440 $scope.clazzName=_reportType.clazzName; 441 $scope.leIdFieldName=_reportType.leIdFieldName; 442 $scope.reportTypeName=_reportType.reportType; 443 delete response.responseObj.report; 444 $scope.listOptions=response.responseObj; 445 var filteredCriteria = $filter('filter')(selectedTemplate.searchCriteria, { fieldName: "!customerName" }, true); 446 if (!$rootScope.emulationUser) { 447 $scope.inputCriterias = filteredCriteria; 448 } else { 449 $scope.inputCriterias = selectedTemplate.searchCriteria; 450 } 451 $scope.gridColumns=selectedTemplate.reportFields; 452 $scope.reportName=selectedTemplate.reportName; 453 $scope.reportId=selectedTemplate.id; 454 $scope.toggleCriteria(false); 455 $scope.searchResults=[]; 456 $scope.loadingTable1=false; 457 }); 458 } 459 460 $scope.searchReports=function(){ 461 var search={}; 462 search.reportId=$scope.reportId; 463 search.reportSource=$scope.reportSource; 464 search.clazzName=$scope.clazzName; 465 search.conditions=[]; 466 $scope.loadingTable1=true; 467 let viewCriteria=angular.copy($scope.viewSearchCriteria); 468 let includeCustomerId=true; 469 let isObjectIdExists =false; 470 angular.forEach(viewCriteria, function(val,key) { 471 var condition=val; 472 condition.field=key; 473 if(condition.field == "objectId"){ 474 isObjectIdExists = true; 475 } 476 if(condition.valueDate){ 477 condition.valueDate=extractDate(condition.valueDate); 478 } 479 if(condition.fromDate){ 480 condition.fromDate=extractDate(condition.fromDate); 481 } 482 if(condition.toDate){ 483 condition.toDate=extractDate(condition.toDate); 484 } 485 var keys = Object.keys(condition); 486 var propCount=0; 487 if(keys.length>=3){ 488 angular.forEach(condition, function(propVal,propKey) { 489 if(propVal || propVal == 0) 490 propCount++; 491 }); 492 493 if(condition.condition && (condition.condition=='between' &&propCount>=4 || condition.condition!='between' &&propCount>=3)){ 494 if(condition.condition=="List item"){ 495 _val=$scope[condition.field+"_map"]; 496 condition.value=_val[condition.value].join(","); 497 condition.enumClazzName=$scope[condition.field+"_clazz"]; 498 } 499 if (condition.condition == "in" && (condition.field == "customerName" || condition.field == "channel")) { 500 condition.value = condition.value.join(","); 501 includeCustomerId = false;
502 } 503 search.conditions.push(condition); 504 } 505 } 506 }); 507 $scope.criteriaErroeMsg=false; 508 if(search.conditions.length==0){ 509 $scope.loadingTable1=false; 510 $scope.criteriaErroeMsg=true; 511 return false; 512 } 513 $scope.searchResults=[]; 514 $scope.hideCriteria=true; 515 var _user = angular.copy($rootScope.currentUser); 516 search.conditions.push({ condition: "is", value: _user.entityId, field: $scope.leIdFieldName }); 517 if ($scope.reportTypeName == "Bene REPORT") { 518 $scope.loadAccounts(true,search,includeCustomerId,isObjectIdExists); 519 }else{ 520 $scope.searchReportsByCriteria(search,includeCustomerId); 521 } 522 523 function extractDate(date){ 524 var userTimezoneOffset = date.getTimezoneOffset() * 60000; 525 date= new Date(date.getTime() - userTimezoneOffset); 526 return JSON.stringify(date).split("T")[0].replace('"',""); 527 } 528 } 529 530 //This function is Used Reorder the columns based on the configuration 531 function sortByKey(array, key) { 532 return array.sort(function(a, b) { 533 var x = a[key]; var y = b[key]; 534 return ((x < y) ? -1 : ((x > y) ? 1 : 0)); 535 }); 536 } 537 538 $scope.searchReportsByCriteria = function(search,includeCustomerId){ 539 ReportService.searchReportByCriteria(search,includeCustomerId).then(function(response){ 540 if(response.success){ 541 $scope.searchResults=response.responseObj; 542 $scope.tableViewby = "10"; 543 $scope.tableTotalItems = $scope.searchResults.length; 544 $scope.tableCurrentPage = 1; 545 $scope.tableItemsPerPage = $scope.tableViewby; 546 $scope.setTableItemsPerPage = function(num) { 547 $scope.tableItemsPerPage = num; 548 $scope.tableCurrentPage = 1; //reset to first page 549 } 550 $scope.hideCriteria=true; 551 $scope.exportDataList=[]; 552 var th={}; 553 var colList=$filter('orderBy')($scope.gridColumns, 'orderBy'); 554 angular.forEach(colList, function(value, key){ 555 if(!th.hasOwnProperty(value.fieldName)){ 556 th[value.fieldName]=value.fieldLabel; 557 } 558 else{ 559 th[value.fieldName] = [th[value.fieldName], value.fieldLabel]; 560 } 561 }); 562 $scope.exportDataList.push(th); 563 564 }else{ 565 $scope.formError=response.errorResponse; 566 } 567 $scope.loadingTable1=false; 568 }); 569 } 570
571 $scope.exportToExcel = function() { 572 if ($scope.searchResults && $scope.searchResults.length > 0) { 573 var i = 0; 574 var gridData = []; 575 var orderedColumns = sortByKey($scope.gridColumns, "orderBy"); 576 577 angular.forEach($scope.searchResults, function(row, key) { 578 gridRow = {}; 579 angular.forEach(orderedColumns, function(col, key) { 580 gridRow[col.fieldLabel] = $scope.getColumnValue(row, col, i, false); 581 }); 582 i++; 583 gridData.push(angular.copy(gridRow)); 584 }); 585 586 filename = $scope.reportName + '.xlsx'; 587 var ws = XLSX.utils.json_to_sheet(gridData); 588 ws["!cols"] = setColumnWidth(gridData); 589 var wb = XLSX.utils.book_new(); 590 XLSX.utils.book_append_sheet(wb, ws, "Payment Report"); 591 XLSX.writeFile(wb, filename); 592 } 593 }; 594 595 //This function is used to set the column width on the downloading excel file 596 function setColumnWidth(gridData) { 597 const header = Object.keys(gridData[0]); 598 var wscols = []; 599 for (var i = 0; i < header.length; i++) { 600 wscols.push({ wch: header[i].length + 5 }) 601 } 602 return wscols; 603 } 604 605 /** 606 * Date picker selector. 607 */ 608 $scope.config = { 609 openDateFromCal: false, 610 openDateToCal: false 611 612 }; 613 614 $scope.openDatePicker = function($event,col,val) { 615 $event.preventDefault(); 616 $event.stopPropagation(); 617 if($scope.config[col]){ 618 $scope.config[col][val] = true; 619 }else{ 620 $scope.config[col]={}; 621 $scope.config[col][val] = true; 622 } 623 } 624 625 $scope.getCSVData=function(){ 626 $scope.csvFileName=$scope.reportName+".csv"; 627 var th=angular.copy($scope.exportDataList[0]); 628 $scope.exportDataList=[]; 629 $scope.exportDataList.push(th); 630 631 var colList=$filter('orderBy')($scope.gridColumns, 'orderBy'); 632 angular.forEach($scope.searchResults, function(row, key){ 633 angular.forEach(colList, function(col, index){ 634 $scope.getColumnValue(row,col,key); 635 }); 636 }); 637 return $scope.exportDataList; 638 } 639 640 /****** 641 ** Filter active from accountlist by user 642 */ 643 $scope.filterUserActiveAccounts =function(response) 644 { 645 $scope.stageAccountList = angular.copy(response.responseObj); 646 $scope.accountList = CommonService.maskAccountNumber($scope.stageAccountList); 647 } 648 649 /****** 650 ** Filter active payee list by user 651 */ 652 $scope.filterUserActivePayees =function(response) 653 { 654 var userPayeeList=[]; 655 var payeeIdList=[]; 656 angular.forEach(response.responseObj, function(account) { 657 payeeIdList.push(account.id); 658 userPayeeList.push(account) 659 }); 660 $scope.payeeList = CommonService.maskAccountNumber(userPayeeList); 661 $scope.payeeIdList = payeeIdList; 662 } 663 664 $scope.getColumnValue=function(row,col,index,isExportExcel){ 665 var colValue=""; 666 if(col.fieldType=="Account"){ 667 var account=$filter('filter')($scope.accountList, { id:row[col.fieldName]} , true)[0]; 668 if(account){ 669 colValue= account.accountName; 670 }else{ 671 var payee=$filter('filter')($scope.payeeList, { id:row[col.fieldName]} , true)[0]; 672 colValue= payee?payee.legalName:""; 673 if(col.fieldLabel=="Bene Template Name"){ 674 colValue= payee?payee.aliasName:""; 675 } 676 } 677 }else if(!$rootScope.isUndefined(col.parentName)){ 678 if(col.parentName.indexOf(".")!=-1){ 679 //Nested object support 680 angular.forEach(col.parentName.split("."), function(item) { 681 if(colValue){ 682 colValue=colValue[item]; 683 }else{ 684 colValue=row[item]; 685 } 686 }); 687 colValue=getCustColVal(col,row,colValue); 688 } 689 else{ 690 colValue= row[col.parentName]; 691 colValue=getCustColVal(col,row,colValue); 692 } 693 }else if(!$rootScope.isUndefined(col.childName)){ 694 colValue= row[col.fieldName][col.childName]; 695 if(col.fieldName=="status" ){ 696 var mappedValue = statusMap[row["pricingStatus"]["id"]]; 697 if (mappedValue) { 698 colValue= mappedValue; 699 } 700 } 701 }else if(col.fieldLabel=="Legal Entity Full Name"){ 702 var id= row[col.fieldName];
703 var le=$scope.counterPartyMap[id]; 704 colValue = le["fullName"]; 705 } 706 else{ 707 colValue=getCustColVal(col,row,colValue); 708 } 709 710 var exportVal = angular.copy(colValue) 711 if (col.fieldType == "Date") { 712 if (col.parentName) { 713 colValue = getValueFromNestedField(col.parentName + "." + col.fieldName, row, ":") 714 } 715 else { 716 colValue = getValueFromNestedField(col.fieldName, row, ":") 717 } 718 if (colValue) { 719 if (row.book != "SWAP") 720 if (col.displayFormat) { 721 colValue = formateDateField(angular.copy(colValue), col.displayFormat); 722 } 723 else if (isExportExcel) { 724 colValue = formatDateYYYYMMDD(angular.copy(colValue)); 725 } else { 726 colValue = formatDateMMDDYYYY(angular.copy(colValue)); 727 } 728 } else { 729 colValue = ""; 730 } 731 exportVal = '"' + colValue + '"'; 732 } else if (col.fieldType == "Decimal") { 733 if (!colValue) { 734 colValue = "0.00" 735 } 736 } 737 index=index+1; 738 if($scope.exportDataList.length>0){ 739 if($scope.exportDataList[index]){ 740 if(!$scope.exportDataList[index].hasOwnProperty(col.fieldName)){ 741 $scope.exportDataList[index][col.fieldName]=exportVal; 742 } 743 else{ 744 $scope.exportDataList[index][col.fieldName] = [$scope.exportDataList[index][col.fieldName], exportVal]; 745 } 746 }else{ 747 $scope.exportDataList[index]={}; 748 $scope.exportDataList[index][col.fieldName]=exportVal; 749 } 750 }else{ 751 $scope.exportDataList[index]={}; 752 $scope.exportDataList[index][col.fieldName]=exportVal; 753 } 754 if(colValue==="" || colValue===undefined || colValue===null) 755 { 756 colValue=""; 757 }else if(!colValue){ 758 colValue="false"; 759 } 760 if(col.fieldType=="Boolean") 761 colValue=colValue?colValue:"false"; 762 return colValue?colValue:""; 763 } 764 765 function getCustColVal(col,row,colValue){ 766 let existData=angular.copy(colValue); 767 if(!$rootScope.isUndefined(existData)){ 768 row=angular.copy(existData); 769 } 770 if(col.fieldName.indexOf(":")!=-1){ 771 //Supporting to display multiple columns combined 772 angular.forEach(col.fieldName.split(":"), function(item,idx) { 773 if(idx==0){ 774 colValue=getValueFromNestedField(item, row); 775 }else{ 776 colValue+=" - "+getValueFromNestedField(item, row);; 777 } 778 }); 779 780 }else{ 781 colValue = getValueFromNestedField(col.fieldName, row); 782 } 783 if(col.fieldType != "Date"){ 784 785 if(col.displayFormat && colValue){ 786 var commaFormat={2:/\B(?=(\d{2})+(?!\d))/g,3:/\B(?=(\d{3})+(?!\d))/g}; 787 var decimals=col.displayFormat.split(".")[1].length; 788 var commaSize=col.displayFormat.split(",")[0].length; 789 if ((colValue.toString()).includes('/')) { 790 var valuesArray = colValue.split('/'); 791 var formattedValue = ""; 792 valuesArray.forEach(function (value) { 793 if (value) { 794 formattedValue += $scope.getCommaFormatNumbers(parseFloat(value).toFixed(decimals), commaFormat[commaSize]) + "/"; 795 } 796 else { 797 formattedValue += ""; 798 } 799 }); 800 formattedValue = formattedValue.endsWith('/') ? formattedValue.slice(0, -1) : formattedValue; 801 return formattedValue; 802 } 803 else { 804 return $scope.getCommaFormatNumbers(colValue.toFixed(decimals), commaFormat[commaSize]); 805 } 806 } 807 } 808 return colValue?colValue:""; 809 } 810 811 function getValueFromNestedField(key, row, divider) { 812 if (key.includes(".")) { 813 var tempVal = null; 814 angular.forEach(key.split("."), function(item, idx) { 815 if (tempVal) { 816 if (tempVal["nearLeg"]) { 817 divider = divider ? divider : "/"; 818 if (tempVal["nearLeg"][item] && tempVal["farLeg"][item]) { 819 tempVal = tempVal["nearLeg"][item] + divider + tempVal["farLeg"][item]; 820 } else if (tempVal["nearLeg"][item]) { 821 tempVal = tempVal["nearLeg"][item] + divider; 822 } else if (tempVal["farLeg"][item]) { 823 tempVal = divider + tempVal["farLeg"][item]; 824 } else { 825 tempVal = ""; 826 } 827 } else { 828 tempVal = tempVal[item]; 829 } 830 } else { 831 tempVal = row[item]; 832 } 833 }); 834 return tempVal; 835 } else if (key === "status") { 836 var mappedValue = statusMap[row.pricingStatus]; 837 if (mappedValue) { 838 row[key] = mappedValue; 839 return mappedValue; 840 } 841 else { 842 return row[key]; 843 } 844 } 845 else { 846 return row[key]; 847 } 848 } 849 function formatDateMMDDYYYY(date){ 850 let _date = new Date(date); 851 return $filter('date')(_date, "MM/dd/yyyy"); 852 } 853 854 function formatDateYYYYMMDD(date){ 855 let _date = new Date(date); 856 return $filter('date')(_date, "yyyy-MM-dd"); 857 } 858 859 function formateDateField(date, displayFormat) { 860 let _date = new Date(date); 861 var formatArray = displayFormat.split(" "); 862 let dateFormat = formatArray[0]; 863 var saparator = dateFormat.indexOf("-")!= -1 ? "-" : "/"; 864 var formattedDate = null; 865 var dateMap = {}; 866 dateMap["MM"] = String(_date.getMonth() + 1).padStart(2, "0"); 867 dateMap["DD"] = String(_date.getDate()).padStart(2, "0"); 868 dateMap["YYYY"] = _date.getFullYear(); 869 dateFormat = dateFormat.split(saparator); 870 angular.forEach(dateFormat, function (val, key) { 871 if (key == 0) { 872 formattedDate = dateMap[val]; 873 } else { 874 formattedDate += saparator + dateMap[val]; 875 } 876 }); 877 if (formatArray.length > 1) { 878 formattedDate += " " + String(_date.getHours()).padStart(2, "0") + ":" + String(_date.getMinutes()).padStart(2, "0") + ":" + String(_date.getSeconds()).padStart(2, "0"); 879 } 880 881 return formattedDate; 882 } 883 884 885 $scope.toggleCriteria=function(isTrue){ 886 $scope.hideCriteria=isTrue; 887 } 888 889 $scope.resetSearchCriteria=function(isTrue){ 890 var original=angular.copy($scope.inputCriterias); 891 $scope.inputCriterias=undefined; 892 $scope.viewSearchCriteria={}; 893 $scope.inputCriterias=angular.copy(original); 894 } 895 896 $scope.changeCriteriaOption=function(criteria){ 897 if(criteria.condition==""){//Reset field value 898 angular.forEach(criteria, function(val,key) { 899 criteria[key]=undefined; 900 }); 901 } 902 } 903 904 $scope.getListOptions=function(field){ 905 var mapName=field.listLabel+'_'+field.listValue; 906 if($scope.listOptions && $scope.listOptions[mapName]){ 907 return $scope.listOptions[mapName]; 908 } 909 else{ 910 return []; 911 } 912 } 913 914 $scope.getMultiSelectOptions=function(field){ 915 if(field.fieldName=="customerName"){ 916 return $scope.counterpartList?$scope.counterpartList:[]; 917 }else if(field.fieldName=="channel"){ 918 return $scope.channelList?$scope.channelList:[]; 919 } 920 } 921 922 $scope.getCustomLabel=function(item,field){ 923 var labelList=field.split(":"); 924 var labelTxt=null; 925 angular.forEach(labelList, function(val,key) { 926 var splitCol=val.split("."); 927 var value=angular.copy(item); 928 angular.forEach(splitCol, function(v,i) { 929 value=value?value[v]:value; 930 }); 931 if(labelTxt)labelTxt+=" - "+value; 932 else if(value)labelTxt=value; 933 }); 934 return labelTxt?labelTxt:""; 935 } 936 937 $scope.getEnumOptions=function(field){ 938 var mapName=field.fieldName; 939 var enumList=[]; 940 if($scope.listOptions && $scope.listOptions[mapName]){ 941 var map={}; 942 angular.forEach($scope.listOptions[mapName], function(val,key) { 943 if(!$rootScope.isUndefined(field.listLabel)){ 944 if(map[val[field.listLabel]]){ 945 map[val[field.listLabel]].push(val[field.listValue]); 946 }else{ 947 map[val[field.listLabel]]=[val[field.listValue]] 948 } 949 if(!enumList.indexOf(val[field.listLabel])!=-1) 950 enumList.push(val[field.listLabel]) 951 }else{ 952 if(map[field.fieldName]){ 953 map[val[field.fieldName]].push(val[field.fieldName]); 954 }else{ 955 map[val[field.fieldName]]=[val[field.fieldName]] 956 } 957 if(!enumList.indexOf(val[field.fieldName])!=-1) 958 enumList.push(val[field.fieldName]) 959 } 960 }); 961 $scope[mapName+"_map"]=map; 962 $scope[mapName+"_clazz"]=field.listSource; 963 return enumList; 964 } 965 else{ 966 return []; 967 } 968 } 969 970 $scope.getCustomEnumLabel=function(item,field){ 971 var labelList=field.listLabel; 972 return item[labelTxt]; 973 } 974 975 $scope.cancelCriteria=function(){ 976 $state.go("home.reports.viewReports"); 977 } 978 979 $scope.getConfigLabels=function(label){ 980 var labelConfig={}; 981 labelConfig.between="range" 982 labelConfig.is="equals" 983 labelConfig["List item"]="equals" 984 labelConfig.to="until" 985 return labelConfig[label]?labelConfig[label]:label; 986 } 987 988 $scope.getOptionList= function(field){ 989 return field.optionList.split(","); 990 } 991 992 $scope.getCommaFormatNumbers=function(number,format){ 993 number=number.toString(); 994 var afterPoint = ''; 995 if(number.indexOf('.') > 0) 996 afterPoint = number.substring(number.indexOf('.'),number.length); 997 number = Math.floor(number); 998 number=number.toString(); 999 var lastThree = number.substring(number.length-3); 1000 var otherNumbers = number.substring(0,number.length-3); 1001 if(otherNumbers != '') 1002 lastThree = ',' + lastThree; 1003 var res = otherNumbers.replace(format, ",") + lastThree + afterPoint; 1004 return res; 1005 } 1006 1007 $scope.initModelObj=function(criteria,field){ 1008 criteria[field]={}; 1009 } 1010 1011 $scope.validateNumberKeyPress = function (event) { 1012 var keyCode = event.which || event.keyCode; 1013 if (keyCode < 48 || keyCode > 57) { 1014 event.preventDefault(); 1015 } 1016 } 1017} ]);
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.