') + $scope.writeLabel( value, 'buttonLabel' );\r\n }\r\n ctr++;\r\n }\r\n }); \r\n\r\n if ( $scope.more === true ) {\r\n // https://github.com/isteven/angular-multi-select/pull/16\r\n if (tempMaxLabels > 0) {\r\n $scope.varButtonLabel += ', ... ';\r\n }\r\n $scope.varButtonLabel += '(' + $scope.outputModel.length + ')'; \r\n }\r\n }\r\n $scope.varButtonLabel = $sce.trustAsHtml( $scope.varButtonLabel + '
' ); \r\n }\r\n\r\n // Check if a checkbox is disabled or enabled. It will check the granular control (disableProperty) and global control (isDisabled)\r\n // Take note that the granular control has higher priority.\r\n $scope.itemIsDisabled = function( item ) {\r\n \r\n if ( typeof attrs.disableProperty !== 'undefined' && item[ attrs.disableProperty ] === true ) { \r\n return true;\r\n }\r\n else { \r\n if ( $scope.isDisabled === true ) { \r\n return true;\r\n }\r\n else {\r\n return false;\r\n }\r\n }\r\n \r\n }\r\n\r\n // A simple function to parse the item label settings. Used on the buttons and checkbox labels.\r\n $scope.writeLabel = function( item, type ) {\r\n \r\n // type is either 'itemLabel' or 'buttonLabel'\r\n var temp = attrs[ type ].split( ' ' ); \r\n var label = ''; \r\n\r\n angular.forEach( temp, function( value, key ) { \r\n item[ value ] && ( label += ' ' + value.split( '.' ).reduce( function( prev, current ) {\r\n return prev[ current ]; \r\n }, item )); \r\n });\r\n \r\n if ( type.toUpperCase() === 'BUTTONLABEL' ) { \r\n return label;\r\n }\r\n return $sce.trustAsHtml( label );\r\n } \r\n\r\n // UI operations to show/hide checkboxes based on click event..\r\n $scope.toggleCheckboxes = function( e ) { \r\n \r\n // We grab the button\r\n var clickedEl = element.children()[0];\r\n\r\n // Just to make sure.. had a bug where key events were recorded twice\r\n angular.element( document ).off( 'click', $scope.externalClickListener );\r\n angular.element( document ).off( 'keydown', $scope.keyboardListener ); \r\n\r\n // The idea below was taken from another multi-select directive - https://github.com/amitava82/angular-multiselect \r\n // His version is awesome if you need a more simple multi-select approach. \r\n\r\n // close\r\n if ( angular.element( checkBoxLayer ).hasClass( 'show' )) { \r\n\r\n angular.element( checkBoxLayer ).removeClass( 'show' ); \r\n angular.element( clickedEl ).removeClass( 'buttonClicked' ); \r\n angular.element( document ).off( 'click', $scope.externalClickListener );\r\n angular.element( document ).off( 'keydown', $scope.keyboardListener ); \r\n\r\n // clear the focused element;\r\n $scope.removeFocusStyle( $scope.tabIndex );\r\n if ( typeof formElements[ $scope.tabIndex ] !== 'undefined' ) {\r\n formElements[ $scope.tabIndex ].blur();\r\n }\r\n\r\n // close callback\r\n $timeout( function() {\r\n $scope.onClose();\r\n }, 0 );\r\n\r\n // set focus on button again\r\n element.children().children()[ 0 ].focus();\r\n } \r\n // open\r\n else \r\n { \r\n // clear filter\r\n $scope.inputLabel.labelFilter = ''; \r\n $scope.updateFilter(); \r\n\r\n helperItems = [];\r\n helperItemsLength = 0;\r\n\r\n angular.element( checkBoxLayer ).addClass( 'show' );\r\n angular.element( clickedEl ).addClass( 'buttonClicked' ); \r\n\r\n // Attach change event listener on the input filter. \r\n // We need this because ng-change is apparently not an event listener. \r\n angular.element( document ).on( 'click', $scope.externalClickListener );\r\n angular.element( document ).on( 'keydown', $scope.keyboardListener ); \r\n\r\n // to get the initial tab index, depending on how many helper elements we have. \r\n // priority is to always focus it on the input filter \r\n $scope.getFormElements();\r\n $scope.tabIndex = 0;\r\n\r\n var helperContainer = angular.element( element[ 0 ].querySelector( '.helperContainer' ) )[0]; \r\n \r\n if ( typeof helperContainer !== 'undefined' ) {\r\n for ( var i = 0; i < helperContainer.getElementsByTagName( 'BUTTON' ).length ; i++ ) {\r\n helperItems[ i ] = helperContainer.getElementsByTagName( 'BUTTON' )[ i ];\r\n }\r\n helperItemsLength = helperItems.length + helperContainer.getElementsByTagName( 'INPUT' ).length;\r\n }\r\n \r\n // focus on the filter element on open. \r\n if ( element[ 0 ].querySelector( '.inputFilter' ) ) { \r\n element[ 0 ].querySelector( '.inputFilter' ).focus(); \r\n $scope.tabIndex = $scope.tabIndex + helperItemsLength - 2;\r\n // blur button in vain\r\n angular.element( element ).children()[ 0 ].blur();\r\n }\r\n // if there's no filter then just focus on the first checkbox item\r\n else { \r\n if ( !$scope.isDisabled ) { \r\n $scope.tabIndex = $scope.tabIndex + helperItemsLength;\r\n if ( $scope.inputModel.length > 0 ) {\r\n formElements[ $scope.tabIndex ].focus();\r\n $scope.setFocusStyle( $scope.tabIndex );\r\n // blur button in vain\r\n angular.element( element ).children()[ 0 ].blur();\r\n } \r\n }\r\n } \r\n\r\n // open callback\r\n $scope.onOpen();\r\n } \r\n }\r\n \r\n // handle clicks outside the button / multi select layer\r\n $scope.externalClickListener = function( e ) { \r\n\r\n var targetsArr = element.find( e.target.tagName );\r\n for (var i = 0; i < targetsArr.length; i++) { \r\n if ( e.target == targetsArr[i] ) {\r\n return;\r\n }\r\n }\r\n\r\n angular.element( checkBoxLayer.previousSibling ).removeClass( 'buttonClicked' ); \r\n angular.element( checkBoxLayer ).removeClass( 'show' );\r\n angular.element( document ).off( 'click', $scope.externalClickListener ); \r\n angular.element( document ).off( 'keydown', $scope.keyboardListener ); \r\n \r\n // close callback \r\n $timeout( function() {\r\n $scope.onClose();\r\n }, 0 );\r\n\r\n // set focus on button again\r\n element.children().children()[ 0 ].focus();\r\n }\r\n \r\n // select All / select None / reset buttons\r\n $scope.select = function( type, e ) {\r\n\r\n var helperIndex = helperItems.indexOf( e.target );\r\n $scope.tabIndex = helperIndex;\r\n\r\n switch( type.toUpperCase() ) {\r\n case 'ALL':\r\n angular.forEach( $scope.filteredModel, function( value, key ) { \r\n if ( typeof value !== 'undefined' && value[ attrs.disableProperty ] !== true ) { \r\n if ( typeof value[ attrs.groupProperty ] === 'undefined' ) { \r\n value[ $scope.tickProperty ] = true;\r\n }\r\n }\r\n }); \r\n $scope.refreshOutputModel(); \r\n $scope.refreshButton(); \r\n $scope.onSelectAll(); \r\n break;\r\n case 'NONE':\r\n angular.forEach( $scope.filteredModel, function( value, key ) {\r\n if ( typeof value !== 'undefined' && value[ attrs.disableProperty ] !== true ) { \r\n if ( typeof value[ attrs.groupProperty ] === 'undefined' ) { \r\n value[ $scope.tickProperty ] = false;\r\n }\r\n }\r\n }); \r\n $scope.refreshOutputModel(); \r\n $scope.refreshButton(); \r\n $scope.onSelectNone(); \r\n break;\r\n case 'RESET': \r\n angular.forEach( $scope.filteredModel, function( value, key ) { \r\n if ( typeof value[ attrs.groupProperty ] === 'undefined' && typeof value !== 'undefined' && value[ attrs.disableProperty ] !== true ) { \r\n var temp = value[ $scope.indexProperty ]; \r\n value[ $scope.tickProperty ] = $scope.backUp[ temp ][ $scope.tickProperty ];\r\n }\r\n }); \r\n $scope.refreshOutputModel(); \r\n $scope.refreshButton(); \r\n $scope.onReset(); \r\n break;\r\n case 'CLEAR':\r\n $scope.tabIndex = $scope.tabIndex + 1;\r\n $scope.onClear(); \r\n break;\r\n case 'FILTER': \r\n $scope.tabIndex = helperItems.length - 1;\r\n break;\r\n default: \r\n } \r\n } \r\n\r\n // just to create a random variable name \r\n function genRandomString( length ) { \r\n var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\r\n var temp = '';\r\n for( var i=0; i < length; i++ ) {\r\n temp += possible.charAt( Math.floor( Math.random() * possible.length ));\r\n }\r\n return temp;\r\n }\r\n\r\n // count leading spaces\r\n $scope.prepareGrouping = function() {\r\n var spacing = 0; \r\n angular.forEach( $scope.filteredModel, function( value, key ) {\r\n value[ $scope.spacingProperty ] = spacing; \r\n if ( value[ attrs.groupProperty ] === true ) {\r\n spacing+=2;\r\n } \r\n else if ( value[ attrs.groupProperty ] === false ) {\r\n spacing-=2;\r\n } \r\n });\r\n }\r\n\r\n // prepare original index\r\n $scope.prepareIndex = function() {\r\n var ctr = 0;\r\n angular.forEach( $scope.filteredModel, function( value, key ) {\r\n value[ $scope.indexProperty ] = ctr;\r\n ctr++;\r\n });\r\n }\r\n\r\n // navigate using up and down arrow\r\n $scope.keyboardListener = function( e ) { \r\n \r\n var key = e.keyCode ? e.keyCode : e.which; \r\n var isNavigationKey = false; \r\n\r\n // ESC key (close)\r\n if ( key === 27 ) {\r\n e.preventDefault(); \r\n e.stopPropagation();\r\n $scope.toggleCheckboxes( e );\r\n } \r\n \r\n \r\n // next element ( tab, down & right key ) \r\n else if ( key === 40 || key === 39 || ( !e.shiftKey && key == 9 ) ) { \r\n \r\n isNavigationKey = true;\r\n prevTabIndex = $scope.tabIndex; \r\n $scope.tabIndex++; \r\n if ( $scope.tabIndex > formElements.length - 1 ) {\r\n $scope.tabIndex = 0;\r\n prevTabIndex = formElements.length - 1; \r\n } \r\n while ( formElements[ $scope.tabIndex ].disabled === true ) {\r\n $scope.tabIndex++;\r\n if ( $scope.tabIndex > formElements.length - 1 ) {\r\n $scope.tabIndex = 0; \r\n } \r\n if ( $scope.tabIndex === prevTabIndex ) {\r\n break;\r\n }\r\n } \r\n }\r\n \r\n // prev element ( shift+tab, up & left key )\r\n else if ( key === 38 || key === 37 || ( e.shiftKey && key == 9 ) ) { \r\n isNavigationKey = true;\r\n prevTabIndex = $scope.tabIndex; \r\n $scope.tabIndex--; \r\n if ( $scope.tabIndex < 0 ) {\r\n $scope.tabIndex = formElements.length - 1;\r\n prevTabIndex = 0;\r\n } \r\n while ( formElements[ $scope.tabIndex ].disabled === true ) { \r\n $scope.tabIndex--;\r\n if ( $scope.tabIndex === prevTabIndex ) {\r\n break;\r\n } \r\n if ( $scope.tabIndex < 0 ) {\r\n $scope.tabIndex = formElements.length - 1;\r\n } \r\n } \r\n } \r\n\r\n if ( isNavigationKey === true ) { \r\n \r\n e.preventDefault();\r\n\r\n // set focus on the checkbox \r\n formElements[ $scope.tabIndex ].focus(); \r\n var actEl = document.activeElement; \r\n \r\n if ( actEl.type.toUpperCase() === 'CHECKBOX' ) { \r\n $scope.setFocusStyle( $scope.tabIndex );\r\n $scope.removeFocusStyle( prevTabIndex );\r\n } \r\n else {\r\n $scope.removeFocusStyle( prevTabIndex );\r\n $scope.removeFocusStyle( helperItemsLength );\r\n $scope.removeFocusStyle( formElements.length - 1 );\r\n } \r\n } \r\n\r\n isNavigationKey = false;\r\n }\r\n\r\n // set (add) CSS style on selected row\r\n $scope.setFocusStyle = function( tabIndex ) { \r\n angular.element( formElements[ tabIndex ] ).parent().parent().parent().addClass( 'multiSelectFocus' ); \r\n }\r\n\r\n // remove CSS style on selected row\r\n $scope.removeFocusStyle = function( tabIndex ) { \r\n angular.element( formElements[ tabIndex ] ).parent().parent().parent().removeClass( 'multiSelectFocus' );\r\n }\r\n\r\n /*********************\r\n ********************* \r\n *\r\n * 1) Initializations\r\n *\r\n *********************\r\n *********************/\r\n\r\n // attrs to $scope - attrs-$scope - attrs - $scope\r\n // Copy some properties that will be used on the template. They need to be in the $scope.\r\n $scope.groupProperty = attrs.groupProperty; \r\n $scope.tickProperty = attrs.tickProperty;\r\n $scope.directiveId = attrs.directiveId;\r\n \r\n // Unfortunately I need to add these grouping properties into the input model\r\n var tempStr = genRandomString( 5 );\r\n $scope.indexProperty = 'idx_' + tempStr;\r\n $scope.spacingProperty = 'spc_' + tempStr; \r\n\r\n // set orientation css \r\n if ( typeof attrs.orientation !== 'undefined' ) {\r\n\r\n if ( attrs.orientation.toUpperCase() === 'HORIZONTAL' ) { \r\n $scope.orientationH = true;\r\n $scope.orientationV = false;\r\n }\r\n else \r\n {\r\n $scope.orientationH = false;\r\n $scope.orientationV = true;\r\n }\r\n } \r\n\r\n // get elements required for DOM operation\r\n checkBoxLayer = element.children().children().next()[0];\r\n\r\n // set max-height property if provided\r\n if ( typeof attrs.maxHeight !== 'undefined' ) { \r\n var layer = element.children().children().children()[0];\r\n angular.element( layer ).attr( \"style\", \"height:\" + attrs.maxHeight + \"; overflow-y:scroll;\" ); \r\n }\r\n\r\n // some flags for easier checking \r\n for ( var property in $scope.helperStatus ) {\r\n if ( $scope.helperStatus.hasOwnProperty( property )) { \r\n if ( \r\n typeof attrs.helperElements !== 'undefined' \r\n && attrs.helperElements.toUpperCase().indexOf( property.toUpperCase() ) === -1 \r\n ) {\r\n $scope.helperStatus[ property ] = false;\r\n }\r\n }\r\n }\r\n if ( typeof attrs.selectionMode !== 'undefined' && attrs.selectionMode.toUpperCase() === 'SINGLE' ) {\r\n $scope.helperStatus[ 'all' ] = false;\r\n $scope.helperStatus[ 'none' ] = false;\r\n }\r\n\r\n // helper button icons.. I guess you can use html tag here if you want to. \r\n $scope.icon = {}; \r\n $scope.icon.selectAll = '✓'; // a tick icon\r\n $scope.icon.selectNone = '×'; // x icon\r\n $scope.icon.reset = '↶'; // undo icon \r\n // this one is for the selected items\r\n $scope.icon.tickMark = '✓'; // a tick icon \r\n\r\n // configurable button labels \r\n if ( typeof attrs.translation !== 'undefined' ) {\r\n $scope.lang.selectAll = $sce.trustAsHtml( $scope.icon.selectAll + ' ' + $scope.translation.selectAll );\r\n $scope.lang.selectNone = $sce.trustAsHtml( $scope.icon.selectNone + ' ' + $scope.translation.selectNone );\r\n $scope.lang.reset = $sce.trustAsHtml( $scope.icon.reset + ' ' + $scope.translation.reset );\r\n $scope.lang.search = $scope.translation.search; \r\n $scope.lang.nothingSelected = $sce.trustAsHtml( $scope.translation.nothingSelected ); \r\n }\r\n else {\r\n $scope.lang.selectAll = $sce.trustAsHtml( $scope.icon.selectAll + ' Select All' ); \r\n $scope.lang.selectNone = $sce.trustAsHtml( $scope.icon.selectNone + ' Select None' );\r\n $scope.lang.reset = $sce.trustAsHtml( $scope.icon.reset + ' Reset' );\r\n $scope.lang.search = 'Search...';\r\n $scope.lang.nothingSelected = 'None Selected'; \r\n }\r\n $scope.icon.tickMark = $sce.trustAsHtml( $scope.icon.tickMark );\r\n \r\n // min length of keyword to trigger the filter function\r\n if ( typeof attrs.MinSearchLength !== 'undefined' && parseInt( attrs.MinSearchLength ) > 0 ) {\r\n vMinSearchLength = Math.floor( parseInt( attrs.MinSearchLength ) );\r\n }\r\n\r\n /*******************************************************\r\n *******************************************************\r\n *\r\n * 2) Logic starts here, initiated by watch 1 & watch 2\r\n *\r\n *******************************************************\r\n *******************************************************/\r\n \r\n // watch1, for changes in input model property\r\n // updates multi-select when user select/deselect a single checkbox programatically\r\n // https://github.com/isteven/angular-multi-select/issues/8 \r\n $scope.$watch( 'inputModel' , function( newVal ) { \r\n if ( newVal ) { \r\n $scope.refreshOutputModel(); \r\n $scope.refreshButton(); \r\n }\r\n }, true );\r\n \r\n // watch2 for changes in input model as a whole\r\n // this on updates the multi-select when a user load a whole new input-model. We also update the $scope.backUp variable\r\n $scope.$watch( 'inputModel' , function( newVal ) { \r\n if ( newVal ) {\r\n $scope.backUp = angular.copy( $scope.inputModel ); \r\n $scope.updateFilter();\r\n $scope.prepareGrouping();\r\n $scope.prepareIndex(); \r\n $scope.refreshOutputModel(); \r\n $scope.refreshButton(); \r\n }\r\n }); \r\n\r\n // watch for changes in directive state (disabled or enabled)\r\n $scope.$watch( 'isDisabled' , function( newVal ) { \r\n $scope.isDisabled = newVal; \r\n }); \r\n \r\n // this is for touch enabled devices. We don't want to hide checkboxes on scroll. \r\n var onTouchStart = function( e ) { \r\n \t$scope.$apply( function() {\r\n \t\t$scope.scrolled = false;\r\n \t}); \r\n };\r\n angular.element( document ).bind( 'touchstart', onTouchStart);\r\n var onTouchMove = function( e ) { \r\n \t$scope.$apply( function() {\r\n \t\t$scope.scrolled = true; \r\n \t});\r\n };\r\n angular.element( document ).bind( 'touchmove', onTouchMove); \r\n\r\n // unbind document events to prevent memory leaks\r\n $scope.$on( '$destroy', function () {\r\n\t\t\t angular.element( document ).unbind( 'touchstart', onTouchStart);\r\n \tangular.element( document ).unbind( 'touchmove', onTouchMove);\r\n });\r\n }\r\n }\r\n}]).run( [ '$templateCache' , function( $templateCache ) {\r\n var template = \r\n '
' +\r\n // main button\r\n '' +\r\n // overlay layer\r\n '' +\r\n // container of the helper elements\r\n '
' +\r\n // container of the first 3 buttons, select all, none and reset\r\n '
' +\r\n // select all\r\n ''+\r\n // select none\r\n ''+\r\n // reset\r\n '' +\r\n '
' +\r\n // the search box\r\n '
'+\r\n // textfield \r\n ''+\r\n // clear button\r\n ' '+\r\n '
'+\r\n '
'+\r\n // selection items\r\n '
'+\r\n '
'+\r\n // this is the spacing for grouped items\r\n '
0\" ng-repeat=\"i in numberToArray( item[ spacingProperty ] ) track by $index\">'+ \r\n '
'+ \r\n '
'+\r\n ''+\r\n '
'+\r\n // the tick/check mark\r\n '
'+\r\n '
'+\r\n '
'+\r\n '
'+\r\n '';\r\n\t$templateCache.put( 'isteven-multi-select.htm' , template );\r\n}]); \r\n","authInterceptor.$inject = [\"$rootScope\", \"$q\", \"$location\", \"$cookies\"];\r\n\r\nexport function authInterceptor(\r\n $rootScope: ng.IRootScopeService,\r\n $q: ng.IQService,\r\n $location: ng.ILocationService,\r\n $cookies: ng.cookies.ICookiesService,\r\n) {\r\n return {\r\n // intercept every request for Amazon AWS\r\n request: function (config: any) {\r\n var foreignUrl = config.url.indexOf(\"amazonaws\") > -1;\r\n if (foreignUrl) {\r\n config.headers[\"Authorization\"] = undefined;\r\n }\r\n return config;\r\n },\r\n\r\n // Intercept every response. If it's 401, we need to go to login.\r\n response: (response: any) => {\r\n if (response.status === 401) {\r\n $cookies.remove(\"access_token\");\r\n $cookies.remove(\"access_token_expires\");\r\n $cookies.remove(\"profile\");\r\n\r\n localStorage.clear();\r\n\r\n $location.path(\"/login\");\r\n }\r\n\r\n // Otherwise return our response. (q helps us pass back promises)\r\n return response || $q.when(response);\r\n },\r\n\r\n // Intercept http error responses. If it's 401, we need to go to login.\r\n responseError: (response: any) => {\r\n if (response.status === 401) {\r\n $cookies.remove(\"access_token\");\r\n $cookies.remove(\"access_token_expires\");\r\n $cookies.remove(\"profile\");\r\n\r\n localStorage.clear();\r\n\r\n $location.path(\"/login\");\r\n }\r\n\r\n // Otherwise just pass on the error (could be a 500/etc we want to handle gracefully.)\r\n //return $q.reject(rejection);\r\n return $q.reject(response);\r\n },\r\n };\r\n}\r\n","export class BroadcastService {\r\n public static $inject = [\"$rootScope\", \"$q\"];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $q: ng.IQService,\r\n ) {}\r\n\r\n public broadcastError(screen: string, message: string): void {\r\n this.$rootScope.$broadcast(\"error\", {\r\n page: screen,\r\n severity: \"error\",\r\n error: message,\r\n });\r\n }\r\n\r\n public broadcastWarning(screen: string, message: string): void {\r\n this.$rootScope.$broadcast(\"error\", {\r\n page: screen,\r\n severity: \"warning\",\r\n error: message,\r\n });\r\n }\r\n\r\n public broadcastInfo(screen: string, message: string): void {\r\n this.$rootScope.$broadcast(\"error\", {\r\n page: screen,\r\n severity: \"info\",\r\n error: message,\r\n });\r\n }\r\n}\r\n","import angular from \"angular\";\r\n\r\nexport function registerAppTermDirective() {\r\n const ccqdirectives = angular.module(\"Ccq.directives\");\r\n\r\n ccqdirectives.directive(\"applicationName\", [\r\n \"$rootScope\",\r\n ($rootScope: ng.IRootScopeService) => {\r\n return {\r\n restrict: \"E\",\r\n controller: function ($scope, $element, $attrs) {\r\n if (sessionStorage.getItem(\"applicationName\") != null) {\r\n $scope.applicationName = sessionStorage.getItem(\"applicationName\");\r\n } else {\r\n $scope.applicationName = \"Brickflow\";\r\n }\r\n\r\n $rootScope.$on(\r\n \"applicationNameChanged\",\r\n (event, newApplicationName) => {\r\n $scope.applicationName = newApplicationName;\r\n },\r\n );\r\n },\r\n template: \"{{applicationName}}\",\r\n };\r\n },\r\n ]);\r\n\r\n ccqdirectives.directive(\"applicationConsultant\", [\r\n \"$rootScope\",\r\n ($rootScope: ng.IRootScopeService) => {\r\n return {\r\n restrict: \"A\",\r\n controller: function ($scope, $element, $attrs) {\r\n if (sessionStorage.getItem(\"applicationName\") != null) {\r\n $scope.applicationName = sessionStorage.getItem(\"applicationName\");\r\n } else {\r\n $scope.applicationName = \"Brickflow\";\r\n }\r\n\r\n $rootScope.$on(\r\n \"applicationNameChanged\",\r\n (event, newApplicationName) => {\r\n $scope.applicationName = newApplicationName;\r\n },\r\n );\r\n },\r\n template: \"{{applicationName}} consultant \",\r\n };\r\n },\r\n ]);\r\n}\r\n","export const enum LicenseMasterStatusEnum {\r\n None = 0,\r\n PaidUp = 1,\r\n PayFailure = 2,\r\n Unpaid = 3,\r\n Cancelled = 4,\r\n PreCancel = 5,\r\n PreSubscription = 6,\r\n PaymentProcessing = 7,\r\n Trial = 8,\r\n Offered = 9,\r\n}\r\n","import angular from \"angular\";\r\nimport { UserService } from \"./services/UserService\";\r\nimport { LicenseMasterStatusEnum } from \"./models/enum/LicenseMasterStatusEnum.cs.d\";\r\n\r\ninterface RequiredOption {\r\n name: string;\r\n disable: boolean;\r\n hide: boolean;\r\n}\r\n\r\nexport function registerRequiresAllDirective() {\r\n const ccqdirectives = angular.module(\"Ccq.directives\");\r\n\r\n ccqdirectives.directive(\"requiresAll\", [\r\n \"UserService\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n (\r\n userService: UserService,\r\n $rootScope: ng.IRootScopeService,\r\n $cookies: ng.cookies.ICookiesService,\r\n ) => {\r\n return {\r\n restrict: \"A\",\r\n controller: function ($scope, $element, $attrs) {\r\n $scope.userService = userService;\r\n //console.log($rootScope)\r\n },\r\n scope: false,\r\n link: function (\r\n scope: angular.IScope,\r\n element: JQLite,\r\n attr: angular.IAttributes,\r\n ctrls: angular.IController[],\r\n ) {\r\n const el: HTMLElement = angular.element(element)[0];\r\n const $rootScope = scope.$root;\r\n const $userService = (scope as any)?.userService;\r\n\r\n const statusRequirementId =\r\n ($rootScope as any)?.statusRequirementId ?? null;\r\n const statusRequirementEventName =\r\n (ctrls[0] as any)?.statusRequirementEventName ?? null;\r\n\r\n // dictate behaviour if requirement not met ( || default values if not provided)\r\n const hideIfNotInState: Boolean =\r\n scope.$parent.$eval(attr.hideIfNotInState) || false;\r\n const disableIfNotInRole: Boolean =\r\n scope.$parent.$eval(attr.disableIfNotInRole) || false;\r\n const matchAllRoles: Boolean =\r\n scope.$parent.$eval(attr.matchAllRoles) || false;\r\n const disableIfNotInFeatures: Boolean =\r\n scope.$parent.$eval(attr.disableIfNotInFeatures) || false;\r\n const hideIfInvalidSubscription: Boolean =\r\n scope.$parent.$eval(attr.hideIfInvalidSubscription) || false;\r\n\r\n // requirements are fetched from the elements attributes\r\n const requiredStates: string[] | string = scope.$parent.$eval(\r\n attr.requiredStates,\r\n );\r\n const requiredRoles: string[] | string = scope.$parent.$eval(\r\n attr.requiredRoles,\r\n );\r\n const requiredFeatures: string[] | string = scope.$parent.$eval(\r\n attr.requiredFeatures,\r\n );\r\n\r\n // providing 'required features' will override value if set to false or not provided\r\n // in order to check features there must be a valid license\r\n const requiresActiveSubscription: Boolean =\r\n scope.$parent.$eval(attr.requiresActiveSubscription) ||\r\n !!requiredFeatures;\r\n const allowIfInvited: Boolean =\r\n scope.$parent.$eval(attr.allowIfInvited) || false;\r\n\r\n //override options - allows specific outcomes to be set for specific values, overuling the required... values and default behaviour\r\n const requiredRolesOptions: RequiredOption[] = scope.$parent.$eval(\r\n attr.requiredRolesOptions,\r\n );\r\n const requiredStatesOptions: RequiredOption[] = scope.$parent.$eval(\r\n attr.requiredStatesOptions,\r\n );\r\n const requiredFeaturesOptions: RequiredOption[] = scope.$parent.$eval(\r\n attr.requiredFeaturesOptions,\r\n );\r\n\r\n // define callback scope with initial values\r\n // required for async functions to use values after function has ended and values are destroyed\r\n var callbackScope = {\r\n parentScope: scope,\r\n requiredStates: requiredStates,\r\n requiredStatesOptions: requiredStatesOptions,\r\n statusRequirementId: statusRequirementId,\r\n requiredRoles: requiredRoles,\r\n requiredRolesOptions: requiredRolesOptions,\r\n requiredFeatures: requiredFeatures,\r\n requiredFeaturesOptions: requiredFeaturesOptions,\r\n requiresActiveSubscription: requiresActiveSubscription,\r\n };\r\n\r\n // if the status requirement id changes, we update the value in callbackScope\r\n $rootScope.$watch(\r\n \"statusRequirementId\",\r\n function () {\r\n this.callbackScope.statusRequirementId = ($rootScope as any)\r\n ?.statusRequirementId;\r\n if (!!this.callbackScope.statusRequirementId) {\r\n let roles =\r\n (($rootScope as any)?.currentUser?.Roles as string[]) ?? null;\r\n let status =\r\n this.callbackScope.statusRequirementId > 0\r\n ? (($rootScope as any)?.caseStateChange[\r\n this.callbackScope.statusRequirementId\r\n ] as string)\r\n : null;\r\n let features =\r\n ($rootScope as any)?.currentUser?.Features ?? null;\r\n let subscriptionStatus =\r\n (($rootScope as any)?.currentUser\r\n ?.SubscriptionStatus as number) ?? null;\r\n\r\n updateAll(\r\n this.callbackScope.requiredStates,\r\n status,\r\n this.callbackScope.requiredStatesOptions,\r\n this.callbackScope.requiredRoles,\r\n roles,\r\n this.callbackScope.requiredRolesOptions,\r\n this.callbackScope.requiredFeatures,\r\n features,\r\n this.callbackScope.requiredFeaturesOptions,\r\n this.callbackScope.requiresActiveSubscription,\r\n subscriptionStatus,\r\n ($rootScope as any)?.isInvitedToCase as boolean,\r\n ($rootScope as any)?.isInvitedAndHasReadonlyAccess as boolean,\r\n );\r\n }\r\n }.bind({ callbackScope: callbackScope }),\r\n );\r\n\r\n const originalStyles = {\r\n cursor: el.style.cursor,\r\n pointerEvents: el.style.pointerEvents,\r\n opacity: el.style.opacity,\r\n display: el.style.display,\r\n };\r\n\r\n //Styling Functions\r\n const disable = () => {\r\n el.style.cursor = \"not-allowed\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.opacity = \"0.8\";\r\n };\r\n const hide = () => {\r\n el.style.display = \"none\";\r\n };\r\n const enable = () => {\r\n el.style.cursor = originalStyles.cursor;\r\n el.style.pointerEvents = originalStyles.pointerEvents;\r\n el.style.opacity = originalStyles.opacity;\r\n };\r\n const show = () => {\r\n el.style.display = originalStyles.display;\r\n };\r\n const applyStyle = (showElement: boolean, enableElement: boolean) => {\r\n if (showElement) {\r\n show();\r\n if (enableElement) {\r\n enable();\r\n } else {\r\n disable();\r\n }\r\n } else {\r\n hide();\r\n }\r\n };\r\n\r\n //Helper Functions\r\n const isLenderOrAdmin = (roles: string[]): boolean => {\r\n if (!roles) return false;\r\n let res = roles.find(\r\n (role) =>\r\n role.toLowerCase() === \"lender\" ||\r\n role.toLowerCase() === \"admin\",\r\n );\r\n return !!res;\r\n };\r\n\r\n const checkRolesMatch = (\r\n currentRoles: string[],\r\n requiredRoles: string[],\r\n matchAllRoles: Boolean,\r\n ): boolean => {\r\n let roleMatch = false;\r\n // set rolematch based on requiredRoles, currentRoles and matchAllRoles\r\n for (let i = 0; i < requiredRoles.length; i++) {\r\n var matchingGroup = currentRoles.find(\r\n (group) =>\r\n group.toLowerCase() === requiredRoles[i].toLowerCase(),\r\n );\r\n if (matchingGroup && !matchAllRoles) {\r\n roleMatch = true;\r\n break;\r\n } else if (matchingGroup && matchAllRoles) {\r\n roleMatch = true;\r\n } // needed since we start rolematch as false\r\n else if (!matchingGroup && matchAllRoles) {\r\n roleMatch = false;\r\n break;\r\n }\r\n }\r\n\r\n return roleMatch;\r\n };\r\n\r\n const checkFeaturesMatch = (\r\n currentFeatures: string[],\r\n requiredFeatures: string[],\r\n ): boolean => {\r\n let matchingFeatures = false;\r\n for (let i = 0; i < requiredFeatures.length; i++) {\r\n let match = currentFeatures.find(\r\n (feature) =>\r\n feature.toLowerCase() === requiredFeatures[i].toLowerCase(),\r\n );\r\n if (!!match) {\r\n matchingFeatures = true;\r\n break;\r\n }\r\n }\r\n return matchingFeatures;\r\n };\r\n\r\n const checkCaseStateMatch = (\r\n currentState: string,\r\n requiredStates: string[],\r\n ): boolean => {\r\n let matchingState = requiredStates.find(\r\n (state) => state.toLowerCase() === currentState.toLowerCase(),\r\n );\r\n let stateMatch = !!matchingState;\r\n return stateMatch;\r\n };\r\n\r\n // Main function containing logic\r\n const updateAll = (\r\n requiredStates: string[] | string,\r\n currentState: string,\r\n requiredStatesOptions: RequiredOption[],\r\n requiredRoles: string[] | string,\r\n currentRoles: string[],\r\n requiredRolesOptions: RequiredOption[],\r\n requiredFeatures: string[] | string,\r\n currentFeatures: string[],\r\n requiredFeaturesOptions: RequiredOption[],\r\n requiresActiveSubscription: Boolean,\r\n subscriptionStatus: number,\r\n isInvited: Boolean,\r\n isInvitedAndHasReadonlyAccess: Boolean,\r\n ): void => {\r\n if (typeof requiredStates === \"string\") {\r\n requiredStates = [requiredStates];\r\n }\r\n if (typeof requiredRoles === \"string\") {\r\n requiredRoles = [requiredRoles];\r\n }\r\n if (typeof requiredFeatures === \"string\") {\r\n requiredFeatures = [requiredFeatures] as string[];\r\n }\r\n\r\n //defaults\r\n disable();\r\n hide();\r\n\r\n var showState = false;\r\n var enableState = false;\r\n //maintain state within each criteria - needed for override options\r\n var showTmp = showState;\r\n var enableTmp = enableState;\r\n\r\n /* Order or Priority\r\n - subscription status\r\n - feature access\r\n - correct role\r\n - correct case status\r\n \r\n Exceptions\r\n - invited users don't require an active subscription\r\n - admins and lenders don't need active subscriptions\r\n \r\n Required options\r\n - can only override changes made by respective criteria\r\n - requiredRoleOption cannot enable a button is invalid subscription status has disabled it\r\n */\r\n\r\n if (\r\n (isLenderOrAdmin(currentRoles) && requiresActiveSubscription) ||\r\n (allowIfInvited == true && isInvited == true)\r\n ) {\r\n showTmp = showState = true;\r\n enableTmp = enableState = true;\r\n }\r\n // check if active subscription required\r\n else if (requiresActiveSubscription) {\r\n const activeSubscription =\r\n subscriptionStatus == LicenseMasterStatusEnum.PaidUp ||\r\n subscriptionStatus ==\r\n LicenseMasterStatusEnum.PaymentProcessing ||\r\n subscriptionStatus == LicenseMasterStatusEnum.PreCancel;\r\n\r\n // valid subscription\r\n if (activeSubscription) {\r\n showTmp = true;\r\n enableTmp = true;\r\n }\r\n // invalid subscription\r\n else {\r\n if (hideIfInvalidSubscription) {\r\n showTmp = false;\r\n } else {\r\n showTmp = true;\r\n enableTmp = false;\r\n }\r\n }\r\n\r\n showState = showTmp;\r\n enableState = enableTmp;\r\n //stop eval if hidden\r\n if (!showState) {\r\n hide();\r\n return;\r\n }\r\n\r\n if (requiredFeatures && currentFeatures) {\r\n const matchingFeatures = checkFeaturesMatch(\r\n currentFeatures,\r\n requiredFeatures as string[],\r\n );\r\n\r\n if (!matchingFeatures) {\r\n if (disableIfNotInFeatures && showState && enableState) {\r\n //only disable if it hasn't been hidden or disabled by inactive subscription\r\n enableTmp = false;\r\n } else {\r\n showTmp = false;\r\n }\r\n }\r\n //right feature is same as result from subscription so no need to disable/hide again\r\n\r\n if (currentFeatures && requiredFeaturesOptions) {\r\n for (let i = 0; i < requiredFeaturesOptions.length; i++) {\r\n const option = requiredFeaturesOptions[i];\r\n const matchingGroup = currentFeatures.find(\r\n (group) =>\r\n group.toLowerCase() === option.name.toLowerCase(),\r\n );\r\n\r\n if (!!matchingGroup) {\r\n // don't change if been disabled by previous requirement\r\n if (enableState == true) {\r\n if (option.disable) {\r\n disable();\r\n show();\r\n showTmp = true;\r\n enableTmp = false;\r\n } else {\r\n enable();\r\n show();\r\n showTmp = true;\r\n enableTmp = true;\r\n }\r\n }\r\n\r\n if (option.hide) {\r\n showTmp = false;\r\n } else {\r\n show();\r\n showTmp = true;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n showState = showTmp;\r\n enableState = enableTmp;\r\n //stop eval if hidden\r\n if (!showState) {\r\n hide();\r\n return;\r\n }\r\n }\r\n\r\n // At this stage, element is either visible or doesn't require subscription\r\n // element is not hidden or required roles is most important criteria\r\n if (requiredRoles && currentRoles) {\r\n const roleMatch = checkRolesMatch(\r\n currentRoles,\r\n requiredRoles,\r\n matchAllRoles,\r\n );\r\n if (!roleMatch) {\r\n if (disableIfNotInRole) {\r\n showTmp = true;\r\n enableTmp = false;\r\n } else {\r\n showTmp = false;\r\n }\r\n }\r\n //only allowed to enable if it is the most important criteria so not to override prev changes\r\n else if (roleMatch && !requiresActiveSubscription) {\r\n showTmp = true;\r\n enableTmp = true;\r\n }\r\n if (currentRoles && requiredRolesOptions) {\r\n for (let i = 0; i < requiredRolesOptions.length; i++) {\r\n const option = requiredRolesOptions[i];\r\n\r\n const matchingGroup = currentRoles.find(\r\n (group) =>\r\n group.toLowerCase() === option.name.toLowerCase(),\r\n );\r\n\r\n if (!!matchingGroup) {\r\n if (enableState == true) {\r\n if (option.disable) {\r\n showTmp = true;\r\n enableTmp = false;\r\n } else {\r\n showTmp = true;\r\n enableTmp = true;\r\n }\r\n }\r\n if (option.hide) {\r\n showTmp = false;\r\n } else {\r\n showTmp = true;\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n showState = showTmp;\r\n enableState = enableTmp;\r\n if (!showState) {\r\n hide();\r\n return;\r\n }\r\n }\r\n\r\n // if element is not hidden or state is most important requirement\r\n if (requiredStates && currentState) {\r\n let stateMatch = checkCaseStateMatch(\r\n currentState,\r\n requiredStates,\r\n );\r\n\r\n if (!stateMatch) {\r\n if (hideIfNotInState) {\r\n showTmp = false;\r\n } else {\r\n showTmp = true;\r\n enableTmp = false;\r\n }\r\n }\r\n //only allowed to enable if it is the most important criteria so not to override prev changes\r\n else if (\r\n stateMatch &&\r\n !(\r\n requiresActiveSubscription ||\r\n requiredFeatures ||\r\n requiredRoles\r\n )\r\n ) {\r\n showTmp = true;\r\n enableTmp = true;\r\n }\r\n\r\n if (currentState && requiredStatesOptions) {\r\n for (let i = 0; i < requiredStatesOptions.length; i++) {\r\n let option = requiredStatesOptions[i];\r\n let matchingState =\r\n option.name.toLowerCase() === currentState.toLowerCase();\r\n\r\n if (matchingState) {\r\n if (enableState == true) {\r\n if (option.disable) {\r\n showTmp = true;\r\n enableTmp = false;\r\n } else {\r\n showTmp = true;\r\n enableTmp = true;\r\n }\r\n }\r\n if (option.hide) {\r\n showTmp = false;\r\n } else {\r\n showTmp = true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n showState = showTmp;\r\n enableState = enableTmp;\r\n if (!showState) {\r\n hide();\r\n return;\r\n }\r\n }\r\n\r\n // apply styling\r\n\r\n if (isInvitedAndHasReadonlyAccess) {\r\n applyStyle(showState, false);\r\n } else {\r\n applyStyle(showState, enableState);\r\n }\r\n };\r\n\r\n // test removing event listener\r\n $rootScope.$on(\r\n statusRequirementEventName,\r\n function (event, statusUpdate: { id: number; status: string }) {\r\n if (statusUpdate.id === this.statusRequirementId) {\r\n let currentRoles =\r\n (($rootScope as any)?.currentUser?.Roles as string[]) ?? null;\r\n let features =\r\n (($rootScope as any)?.currentUser?.Features as string[]) ??\r\n null;\r\n let subscriptionStatus =\r\n (($rootScope as any)?.currentUser\r\n ?.SubscriptionStatus as number) ?? null;\r\n\r\n updateAll(\r\n this.requiredStates,\r\n statusUpdate.status,\r\n this.requiredStatesOptions,\r\n this.requiredRoles,\r\n currentRoles,\r\n this.requiredRolesOptions,\r\n this.requiredFeatures,\r\n features,\r\n this.requiredFeaturesOptions,\r\n this.requiresActiveSubscription,\r\n subscriptionStatus,\r\n ($rootScope as any)?.isInvitedToCase as boolean,\r\n ($rootScope as any)?.isInvitedAndHasReadonlyAccess as boolean,\r\n );\r\n }\r\n }.bind(callbackScope),\r\n );\r\n\r\n $rootScope.$on(\r\n \"userRolesChange\",\r\n function (event, userRoles: string[]) {\r\n let status = this.statusRequirementId\r\n ? (($rootScope as any)?.caseStateChange[\r\n this.statusRequirementId\r\n ] as string)\r\n : null;\r\n let features =\r\n (($rootScope as any)?.currentUser?.Features as string[]) ??\r\n null;\r\n let subscriptionStatus =\r\n (($rootScope as any)?.currentUser\r\n ?.SubscriptionStatus as number) ?? null;\r\n\r\n updateAll(\r\n this.requiredStates,\r\n status,\r\n this.requiredStatesOptions,\r\n this.requiredRoles,\r\n userRoles,\r\n this.requiredRolesOptions,\r\n this.requiredFeatures,\r\n features,\r\n this.requiredFeaturesOptions,\r\n this.requiresActiveSubscription,\r\n subscriptionStatus,\r\n ($rootScope as any)?.isInvitedToCase as boolean,\r\n ($rootScope as any)?.isInvitedAndHasReadonlyAccess as boolean,\r\n );\r\n }.bind(callbackScope),\r\n );\r\n\r\n $rootScope.$on(\r\n \"invitedStatusChange\",\r\n function () {\r\n let roles = ($rootScope as any)?.currentUser?.Roles;\r\n let status = this.statusRequirementId\r\n ? (($rootScope as any)?.caseStateChange[\r\n this.statusRequirementId\r\n ] as string)\r\n : null;\r\n let features =\r\n (($rootScope as any)?.currentUser?.Features as string[]) ??\r\n null;\r\n let subscriptionStatus =\r\n (($rootScope as any)?.currentUser\r\n ?.SubscriptionStatus as number) ?? null;\r\n\r\n updateAll(\r\n this.requiredStates,\r\n status,\r\n this.requiredStatesOptions,\r\n this.requiredRoles,\r\n roles,\r\n this.requiredRolesOptions,\r\n this.requiredFeatures,\r\n features,\r\n this.requiredFeaturesOptions,\r\n this.requiresActiveSubscription,\r\n subscriptionStatus,\r\n ($rootScope as any)?.isInvitedToCase as boolean,\r\n ($rootScope as any)?.isInvitedAndHasReadonlyAccess as boolean,\r\n );\r\n }.bind(callbackScope),\r\n );\r\n\r\n if (\r\n ($rootScope as any)?.currentUser &&\r\n $cookies.get(\"access_token\")\r\n ) {\r\n let roles = ($rootScope as any)?.currentUser?.Roles;\r\n let status = statusRequirementId\r\n ? (($rootScope as any)?.caseStateChange[\r\n statusRequirementId\r\n ] as string)\r\n : null;\r\n let features =\r\n (($rootScope as any)?.currentUser?.Features as string[]) ?? null;\r\n let subscriptionStatus =\r\n (($rootScope as any)?.currentUser\r\n ?.SubscriptionStatus as number) ?? null;\r\n\r\n updateAll(\r\n requiredStates,\r\n status,\r\n requiredStatesOptions,\r\n requiredRoles,\r\n roles,\r\n requiredRolesOptions,\r\n requiredFeatures,\r\n features,\r\n requiredFeaturesOptions,\r\n requiresActiveSubscription,\r\n subscriptionStatus,\r\n ($rootScope as any)?.isInvitedToCase as boolean,\r\n ($rootScope as any)?.isInvitedAndHasReadonlyAccess as boolean,\r\n );\r\n } else if ($cookies.get(\"access_token\")) {\r\n $userService.getcurentuserrecord().then(\r\n function (response) {\r\n ($rootScope as any).currentUser = response;\r\n\r\n let roles = ($rootScope as any)?.currentUser?.Roles;\r\n let status = this.statusRequirementId\r\n ? (($rootScope as any)?.caseStateChange[\r\n this.statusRequirementId\r\n ] as string)\r\n : null;\r\n let features =\r\n (($rootScope as any)?.currentUser?.Features as string[]) ??\r\n null;\r\n let subscriptionStatus =\r\n (($rootScope as any)?.currentUser\r\n ?.SubscriptionStatus as number) ?? null;\r\n\r\n updateAll(\r\n this.requiredStates,\r\n status,\r\n this.requiredStatesOptions,\r\n this.requiredRoles,\r\n roles,\r\n this.requiredRolesOptions,\r\n this.requiredFeatures,\r\n features,\r\n this.requiredFeaturesOptions,\r\n this.requiresActiveSubscription,\r\n subscriptionStatus,\r\n ($rootScope as any)?.isInvitedToCase as boolean,\r\n ($rootScope as any)?.isInvitedAndHasReadonlyAccess as boolean,\r\n );\r\n }.bind(callbackScope),\r\n );\r\n }\r\n },\r\n };\r\n },\r\n ]);\r\n /*\r\n * ======================================================================================\r\n *\r\n * use state variables to set values right at the end and not call functions every time\r\n * break out of evaluation as soon as show state is set to false. - no need to eval as can't override hidden in later eval\r\n * must evaluate ...options first\r\n *\r\n * make use of object pass by reference to reuse code\r\n *\r\n * extract function to get values from root scope\r\n *\r\n */\r\n}\r\n","import angular from \"angular\";\r\nimport { UserService } from \"./services/UserService\";\r\nimport { CaseStatusEnum } from \"./models/enum/CaseStatusEnum.cs.d\";\r\n\r\ninterface RequiresRolesOption {\r\n name: string;\r\n disable: boolean;\r\n hide: boolean;\r\n}\r\n\r\nexport function registerRequireRoleDirective() {\r\n const ccqdirectives = angular.module(\"Ccq.directives\");\r\n\r\n ccqdirectives.directive(\"requiresRolesTERMINATED\", [\r\n \"UserService\",\r\n \"$rootScope\",\r\n (userService: UserService, $rootScope: ng.IRootScopeService) => {\r\n return {\r\n restrict: \"A\",\r\n controller: function ($scope, $element, $attrs) {\r\n $scope.userService = userService;\r\n this.requiresRoles = ($scope as any).requiresRoles;\r\n this.requiresRolesOptions = ($scope as any).requiresRolesOptions;\r\n },\r\n scope: {\r\n requiresRoles: \"=\",\r\n matchAllRoles: \"=\",\r\n minimumStateRequired: \"=\",\r\n clickedEvent: \"@\",\r\n disableIfNotInRole: \"=\",\r\n requiresRolesOptions: \"=\",\r\n },\r\n link: function (\r\n scope: angular.IScope,\r\n element: JQLite,\r\n attr: angular.IAttributes,\r\n ctrl: angular.IController,\r\n ) {\r\n const el: HTMLElement = angular.element(element)[0];\r\n const $rootScope = scope.$root;\r\n const $userService = (scope as any).userService;\r\n\r\n let requiresRoles: string[] | string = (scope as any).requiresRoles;\r\n let requiresRolesOptions: RequiresRolesOption[] = (scope as any)\r\n .requiresRolesOptions;\r\n const matchAllRoles: Boolean = (scope as any).matchAllRoles || false;\r\n let disableIfNotInRole: Boolean =\r\n (scope as any).disableIfNotInRole || false; // defines a behaviour - ability to be disabled\r\n\r\n let originalStyles = {\r\n cursor: el.style.cursor,\r\n pointerEvents: el.style.pointerEvents,\r\n opacity: el.style.opacity,\r\n display: el.style.display,\r\n };\r\n\r\n const permitted = function (): void {\r\n if (disableIfNotInRole) {\r\n performPermitted(false, true); // enable - if permitted and can be disabled\r\n } else {\r\n performPermitted(); // show button - if permitted and can be hidden\r\n }\r\n };\r\n\r\n const notPermitted = function (): void {\r\n if (disableIfNotInRole) {\r\n performNotPermitted(false, true); //button disabled - if permitted and can be disabled\r\n } else {\r\n performNotPermitted(); // hidden - if permitted and can be hidden\r\n }\r\n };\r\n\r\n const performPermitted = function (\r\n hideIfNotPermitted: Boolean = true,\r\n disableIfNotPermitted: Boolean = false,\r\n ): void {\r\n if (disableIfNotPermitted) {\r\n //enable\r\n el.style.cursor = originalStyles.cursor;\r\n el.style.pointerEvents = originalStyles.pointerEvents;\r\n el.style.opacity = originalStyles.opacity;\r\n }\r\n\r\n if (hideIfNotPermitted) {\r\n //show\r\n el.style.display = originalStyles.display;\r\n }\r\n };\r\n\r\n const performNotPermitted = function (\r\n hideIfNotPermitted: Boolean = true,\r\n disableIfNotPermitted: Boolean = false,\r\n ): void {\r\n if (disableIfNotPermitted) {\r\n //disable\r\n el.style.cursor = \"not-allowed\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.opacity = \"0.8\";\r\n }\r\n\r\n if (hideIfNotPermitted) {\r\n //hide\r\n el.style.display = \"none\";\r\n }\r\n };\r\n\r\n const executeOptions = function (option: RequiresRolesOption): void {\r\n if (option.disable) {\r\n el.style.cursor = \"not-allowed\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.opacity = \"0.8\";\r\n el.style.display = originalStyles.display;\r\n }\r\n\r\n if (option.hide) {\r\n el.style.display = originalStyles.display;\r\n }\r\n };\r\n\r\n const updateRoles = (\r\n requiresRoles: string[] | string,\r\n requiresRolesOptions: RequiresRolesOption[],\r\n currentUserRoles: string[],\r\n ): void => {\r\n // We may pass in a string or an array of strings. If it's jsut a single string, let's put it into an array so we can use the same handling either way.\r\n if (typeof requiresRoles === \"string\") {\r\n const role = requiresRoles;\r\n requiresRoles = [requiresRoles];\r\n }\r\n\r\n if (requiresRoles && currentUserRoles) {\r\n if (!matchAllRoles) {\r\n let matchFound = false;\r\n for (let i = 0; i < requiresRoles.length; i++) {\r\n let role = requiresRoles[i];\r\n var matchingGroup = currentUserRoles.find(\r\n (group) => group.toLowerCase() === role.toLowerCase(),\r\n );\r\n if (matchingGroup) {\r\n permitted();\r\n matchFound = true;\r\n break;\r\n }\r\n if (!matchFound) {\r\n notPermitted();\r\n }\r\n }\r\n } else {\r\n let matchFound = true;\r\n for (let i = 0; i < requiresRoles.length; i++) {\r\n let role = requiresRoles[i];\r\n var matchingGroup = currentUserRoles.find(\r\n (group) => group === role,\r\n );\r\n if (!matchingGroup) {\r\n matchFound = false;\r\n notPermitted();\r\n break;\r\n }\r\n }\r\n if (matchFound) {\r\n permitted();\r\n }\r\n }\r\n }\r\n\r\n // requiresRolesOptions will always override anything applied as part of requiresRoles\r\n if (requiresRolesOptions && currentUserRoles) {\r\n for (let i = 0; i < requiresRolesOptions.length; i++) {\r\n let roleOption = requiresRolesOptions[i];\r\n var matchingGroup = currentUserRoles.find(\r\n (group) =>\r\n group.toLowerCase() === roleOption.name.toLowerCase(),\r\n );\r\n\r\n if (matchingGroup) {\r\n executeOptions(roleOption);\r\n break;\r\n }\r\n }\r\n }\r\n };\r\n\r\n // Setup defaults; we should assume we don't have access then grant it if we find we do.\r\n notPermitted();\r\n\r\n // Listen for updates to status.\r\n $rootScope.$on(\r\n \"caseStateChange\",\r\n function (\r\n event,\r\n statusUpdate: { caseId: number; caseStatus: CaseStatusEnum },\r\n ) {},\r\n );\r\n\r\n // Listen for updates to user roles.\r\n $rootScope.$on(\r\n \"userRolesChange\",\r\n function (event, userRoles: string[]) {\r\n updateRoles(requiresRoles, requiresRolesOptions, userRoles);\r\n },\r\n );\r\n\r\n if (($rootScope as any).currentUser) {\r\n updateRoles(\r\n requiresRoles,\r\n requiresRolesOptions,\r\n ($rootScope as any).currentUser.Roles,\r\n );\r\n } else {\r\n $userService.getcurentuserrecord().then(\r\n function (response) {\r\n ($rootScope as any).currentUser = response;\r\n updateRoles(\r\n this.requiresRoles,\r\n this.requiresRolesOptions,\r\n ($rootScope as any).currentUser.Roles,\r\n );\r\n }.bind({\r\n requiresRoles: (scope as any).requiresRoles,\r\n requiresRolesOptions: (scope as any).requiresRolesOptions,\r\n }),\r\n );\r\n }\r\n\r\n //el.onclick = (event: Event) => {\r\n // if (clickPermitted) {\r\n // event.preventDefault();\r\n // event.stopPropagation();\r\n // return false;\r\n // }\r\n //};\r\n },\r\n };\r\n },\r\n ]);\r\n}\r\n","import angular from \"angular\";\r\nimport { UserService } from \"./services/UserService\";\r\n\r\ninterface RequiredStatesOption {\r\n name: string;\r\n disable: boolean;\r\n hide: boolean;\r\n}\r\n\r\nexport function registerRequiresStateDirective() {\r\n const ccqdirectives = angular.module(\"Ccq.directives\");\r\n\r\n ccqdirectives.directive(\"statusRequirementId\", [\r\n \"$rootScope\",\r\n ($rootScope: ng.IRootScopeService) => {\r\n return {\r\n restrict: \"A\",\r\n controller: function ($scope, $element, $attrs) {\r\n // Expose the scope.\r\n this.$scope = $scope;\r\n // This is set asynchronously, so we need to watch for changes.\r\n $scope.$watch(\"statusRequirementId\", function () {\r\n this.statusRequirementId = ($scope as any).statusRequirementId;\r\n });\r\n // This is a static string, so we can set it immediately.\r\n this.statusRequirementEventName = (\r\n $scope as any\r\n ).statusRequirementEventName;\r\n },\r\n scope: {\r\n statusRequirementId: \"=\", // status of current case id, need to check this against required states 'after it is loaded async-ly'\r\n statusRequirementEventName: \"@\",\r\n hideIfNotInState: \"=\",\r\n requiredStatesOptions: \"=\",\r\n },\r\n };\r\n },\r\n ]);\r\n\r\n ccqdirectives.directive(\"requiredStatesTERMINATED\", [\r\n \"UserService\",\r\n \"$rootScope\",\r\n (userService: UserService, $rootScope: ng.IRootScopeService) => {\r\n return {\r\n restrict: \"A\",\r\n require: [\"^statusRequirementId\"],\r\n controller: function ($scope, $element, $attrs) {\r\n $scope.userService = userService;\r\n },\r\n scope: false,\r\n link: function (\r\n scope: angular.IScope,\r\n element: JQLite,\r\n attr: angular.IAttributes,\r\n ctrls: angular.IController[],\r\n ) {\r\n const el: HTMLElement = angular.element(element)[0];\r\n const $rootScope = scope.$root;\r\n const $userService = (scope as any).userService;\r\n\r\n let statusRequirementId = (ctrls[0] as any).statusRequirementId;\r\n const statusRequirementEventName = (ctrls[0] as any)\r\n .statusRequirementEventName;\r\n let requiredStatesOptions: RequiredStatesOption[] =\r\n scope.$parent.$eval(attr.requiredStatesOptions);\r\n let hideIfNotInState: Boolean =\r\n scope.$parent.$eval(attr.hideIfNotInState) || false;\r\n\r\n let requiredStates: string[] | string = scope.$parent.$eval(\r\n attr.requiredStates,\r\n ); // get the value of the javascript attribute required-states\r\n\r\n //define callback scope with initial values\r\n let callbackScope = {\r\n parentScope: scope,\r\n requiredStates: requiredStates,\r\n statusRequirementId: statusRequirementId,\r\n };\r\n\r\n // if the status requirement id changes, we update the value in callbackScope\r\n (ctrls[0] as any).$scope.$watch(\r\n \"statusRequirementId\",\r\n function () {\r\n this.callbackScope.statusRequirementId = (\r\n ctrls[0] as any\r\n ).$scope.statusRequirementId;\r\n if (!!this.callbackScope.statusRequirementId) {\r\n let status = ($rootScope as any).caseStateChange[\r\n this.callbackScope.statusRequirementId\r\n ] as string; // current state\r\n updateState(requiredStates, requiredStatesOptions, status);\r\n }\r\n }.bind({ callbackScope: callbackScope }),\r\n );\r\n\r\n let originalStyles = {\r\n cursor: el.style.cursor,\r\n pointerEvents: el.style.pointerEvents,\r\n opacity: el.style.opacity,\r\n display: el.style.display,\r\n };\r\n\r\n const permitted = function (): void {\r\n if (hideIfNotInState) {\r\n performPermitted(true, false); //show\r\n } else {\r\n performPermitted(); //enable\r\n }\r\n };\r\n\r\n const notPermitted = function (): void {\r\n if (hideIfNotInState) {\r\n performNotPermitted(true, false); //hidden\r\n } else {\r\n performNotPermitted(); //disabled\r\n }\r\n };\r\n\r\n const performPermitted = function (\r\n hideIfNotPermitted: Boolean = false,\r\n disableIfNotPermitted: Boolean = true,\r\n ): void {\r\n if (disableIfNotPermitted) {\r\n el.style.cursor = originalStyles.cursor;\r\n el.style.pointerEvents = originalStyles.pointerEvents;\r\n el.style.opacity = originalStyles.opacity;\r\n }\r\n\r\n if (hideIfNotPermitted) {\r\n el.style.display = originalStyles.display;\r\n }\r\n };\r\n\r\n const performNotPermitted = function (\r\n hideIfNotPermitted: Boolean = false,\r\n disableIfNotPermitted: Boolean = true,\r\n ): void {\r\n if (disableIfNotPermitted) {\r\n el.style.cursor = \"not-allowed\";\r\n el.style.pointerEvents = \"none\";\r\n el.style.opacity = \"0.8\";\r\n }\r\n\r\n if (hideIfNotPermitted) {\r\n el.style.display = \"none\";\r\n }\r\n };\r\n\r\n const executeOptions = function (option: RequiredStatesOption): void {\r\n // if state option is disabled or required it is hidden\r\n if (option.disable) {\r\n el.style.cursor = originalStyles.cursor;\r\n el.style.pointerEvents = originalStyles.pointerEvents;\r\n el.style.opacity = originalStyles.opacity;\r\n el.style.display = \"none\";\r\n }\r\n\r\n if (option.hide) {\r\n el.style.display = \"none\";\r\n }\r\n };\r\n\r\n const updateState = (\r\n requiredStates: string[] | string,\r\n requiredStatesOptions: RequiredStatesOption[],\r\n currentState: string,\r\n ): void => {\r\n // We may pass in a string or an array of strings. If it's jsut a single string, let's put it into an array so we can use the same handling either way.\r\n if (typeof requiredStates === \"string\") {\r\n requiredStates = [requiredStates];\r\n }\r\n\r\n if (requiredStates && currentState) {\r\n let matchingState = requiredStates.find(\r\n (state) => state.toLowerCase() === currentState.toLowerCase(),\r\n );\r\n if (!!matchingState) {\r\n permitted();\r\n } else {\r\n notPermitted();\r\n }\r\n }\r\n\r\n // requiredStatesOptions will always override anything applied as part of requiredStates\r\n if (requiredStatesOptions && currentState) {\r\n for (let i = 0; i < requiredStatesOptions.length; i++) {\r\n let stateOption = requiredStatesOptions[i];\r\n var matchingState =\r\n currentState.toLowerCase() === stateOption.name.toLowerCase();\r\n\r\n if (!matchingState) {\r\n executeOptions(stateOption);\r\n break;\r\n }\r\n }\r\n }\r\n };\r\n\r\n // Setup defaults; we should assume we don't have access then grant it if we find we do.\r\n notPermitted();\r\n\r\n // Listen for updates to status.\r\n\r\n let testy = $rootScope.$on(\r\n statusRequirementEventName,\r\n function (event, statusUpdate: { id: number; status: string }) {\r\n if (statusUpdate.id === this.statusRequirementId) {\r\n updateState(\r\n this.requiredStates,\r\n this.requiredStatesOptions,\r\n statusUpdate.status,\r\n );\r\n }\r\n }.bind(callbackScope),\r\n ); //uses updated values\r\n },\r\n };\r\n },\r\n ]);\r\n}\r\n","import angular from \"angular\";\r\nimport { UserService } from \"./services/UserService\";\r\n\r\nexport function registerWhiteLabelledDirective() {\r\n const ccqdirectives = angular.module(\"Ccq.directives\");\r\n\r\n ccqdirectives.directive(\"whiteLabelOnly\", [\r\n \"UserService\",\r\n \"$rootScope\",\r\n (userService: UserService, $rootScope: ng.IRootScopeService) => {\r\n return {\r\n restrict: \"A\",\r\n controller: function ($scope, $element, $attrs) {},\r\n link: function (\r\n scope: angular.IScope,\r\n element: JQLite,\r\n attr: angular.IAttributes,\r\n ctrl: angular.IController,\r\n ) {\r\n const el: HTMLElement = angular.element(element)[0];\r\n const $rootScope = scope.$root;\r\n\r\n let originalStyles = {\r\n display: el.style.display,\r\n };\r\n\r\n const permitted = function (): void {\r\n el.style.display = originalStyles.display;\r\n };\r\n\r\n const notPermitted = function (): void {\r\n el.style.display = \"none\";\r\n };\r\n\r\n const updateWhiteLabel = (isWhiteLabelled: boolean): void => {\r\n if (isWhiteLabelled == true) {\r\n permitted();\r\n } else {\r\n notPermitted();\r\n }\r\n };\r\n\r\n // Setup defaults; we should assume we don't have access then grant it if we find we do.\r\n notPermitted();\r\n\r\n if (($rootScope as any).isWhiteLabelled) {\r\n updateWhiteLabel(($rootScope as any).isWhiteLabelled);\r\n } else {\r\n userService.IsWhiteLabelled().then(\r\n function (response: boolean) {\r\n ($rootScope as any).isWhiteLabelled = response;\r\n updateWhiteLabel(($rootScope as any).isWhiteLabelled);\r\n }.bind({ requiresRoles: (scope as any).requiresRoles }),\r\n );\r\n }\r\n },\r\n };\r\n },\r\n ]);\r\n}\r\n","import angular from \"angular\";\r\n\r\nexport function registerClickOutsideDirective() {\r\n const ccqdirectives = angular.module(\"Ccq.directives\");\r\n\r\n ccqdirectives.directive('clickOutside', ['$document', function ($document) {\r\n return {\r\n restrict: 'A',\r\n scope: {\r\n clickOutside: '&'\r\n },\r\n link: function (scope, element) {\r\n // Function to check if the click is outside the HTML element\r\n const onClick = (event) => {\r\n \r\n // Check if the clicked target is inside the element or any ancestor has the click-outside directive\r\n const closestDropdown = event.target.closest('[click-outside]');\r\n\r\n // If the closest dropdown is not the current element, it means we clicked outside\r\n // const isInside = closestDropdown === element[0];\r\n\r\n \r\n // If the click is outside, trigger the clickOutside handler\r\n if (!element[0].contains(event.target) && !closestDropdown) {\r\n scope.$apply(function () {\r\n (scope as any).clickOutside();\r\n });\r\n }\r\n }\r\n // Listen for click events on the document\r\n $document.on('click', onClick);\r\n\r\n // Cleanup listener when the directive is destroyed\r\n scope.$on('$destroy', function () {\r\n $document.off('click', onClick);\r\n });\r\n }\r\n };\r\n }]);\r\n}\r\n","import { registerAppTermDirective } from \"@js/apptermdirective\";\r\nimport { registerRequiresAllDirective } from \"@js/requiresalldirective\";\r\nimport { registerRequireRoleDirective } from \"@js/requiresroledirective\";\r\nimport { registerRequiresStateDirective } from \"@js/requiresstatedirective\";\r\nimport { registerWhiteLabelledDirective } from \"@js/whitelabelleddirective\";\r\nimport { registerClickOutsideDirective } from \"@js/clickOutsideDirective\";\r\nimport angular from \"angular\";\r\n\r\nexport interface IpdfdownlaodScope extends angular.IScope {\r\n downloadPdf: any;\r\n name: string;\r\n icon: string;\r\n}\r\n\r\nexport function instantiateCcqDirectives() {\r\n angular\r\n .module(\"Ccq.directives\", [])\r\n\r\n .directive(\"scrollBottom\", function ($document) {\r\n return {\r\n restrict: \"A\",\r\n link: function (scope, element, attrs) {\r\n var el = element[0];\r\n element.bind(\"scroll\", function () {\r\n if (el.scrollTop + el.offsetHeight >= el.scrollHeight) {\r\n scope.$apply(attrs.scrollBottom);\r\n }\r\n });\r\n },\r\n };\r\n })\r\n\r\n .directive(\"ngConfirmClick\", [\r\n function () {\r\n return {\r\n link: function (scope, element, attr) {\r\n var msg = attr.ngConfirmClick || \"Are you sure?\";\r\n var clickAction = attr.confirmedClick;\r\n element.bind(\"click\", function (event) {\r\n if (window.confirm(msg)) {\r\n scope.$eval(clickAction);\r\n }\r\n });\r\n },\r\n };\r\n },\r\n ])\r\n\r\n .directive(\"convertToBoolean\", function () {\r\n return {\r\n require: \"ngModel\",\r\n link: function (scope, element, attrs, ngModel) {\r\n (ngModel as any).$parsers.push(function (val: any) {\r\n if (val === undefined) {\r\n return undefined;\r\n }\r\n\r\n return val === \"true\";\r\n });\r\n (ngModel as any).$formatters.push(function (val: any) {\r\n return \"\" + val;\r\n });\r\n },\r\n };\r\n })\r\n\r\n .directive(\"convertToNumber\", function () {\r\n return {\r\n require: \"ngModel\",\r\n link: function (scope, element, attrs, ngModel) {\r\n (ngModel as any).$parsers.push(function (val: any) {\r\n return parseInt(val, 10);\r\n });\r\n (ngModel as any).$formatters.push(function (val: any) {\r\n //chek if flagged\r\n\r\n return \"\" + val;\r\n });\r\n },\r\n };\r\n })\r\n //this is used for enums set with flags with mulit option ability\r\n .directive(\"convertToNumberm\", function () {\r\n return {\r\n require: \"ngModel\",\r\n link: function (scope, element, attrs, ngModel) {\r\n (ngModel as any).$parsers.push(function (val: any) {\r\n if (Array.isArray(val)) {\r\n var res: number = parseInt(val[0], 10);\r\n\r\n //if an array multi select enum\r\n val.forEach((x) => (res = parseInt(x, 10) | res));\r\n return res;\r\n } else {\r\n return parseInt(val, 10);\r\n }\r\n });\r\n (ngModel as any).$formatters.push(function (val: any) {\r\n //chek if flagged\r\n var ret: string[] = [];\r\n //deal with top 0 being selected\r\n if (val == 0) {\r\n ret.push(\"0\");\r\n return ret;\r\n }\r\n\r\n var res: string = parseInt(val, 10).toString(2);\r\n var currentenumval: number = 1;\r\n for (var i = res.length - 1; i >= 0; i--) {\r\n if (res.charAt(i) == \"1\") {\r\n ret.push(currentenumval.toString());\r\n }\r\n currentenumval = currentenumval * 2;\r\n }\r\n return ret;\r\n });\r\n },\r\n };\r\n })\r\n .directive(\"moveNext\", function () {\r\n return {\r\n require: \"ngModel\",\r\n link: function (scope, element, attrs, ngModel) {\r\n element.bind(\"keyup\", (e) => {\r\n if (\r\n (element.val() as string).length === parseInt(attrs[\"moveNext\"])\r\n ) {\r\n (element.next()[0] as any).focus();\r\n }\r\n });\r\n },\r\n };\r\n })\r\n .directive(\"currency\", [\r\n \"$filter\",\r\n function ($filter) {\r\n return {\r\n require: \"?ngModel\",\r\n link: function (scope, elem, attrs, ctrl: any) {\r\n if (!ctrl) return;\r\n\r\n ctrl.$formatters.unshift(function (a: any) {\r\n return $filter(\"currency\")(ctrl.$modelValue, \"\");\r\n });\r\n },\r\n };\r\n },\r\n ])\r\n .directive(\"decimalPlace\", [\r\n \"$filter\",\r\n function ($filter) {\r\n return {\r\n require: \"?ngModel\",\r\n link: function (scope, elem, attrs, ctrl: any) {\r\n if (!ctrl) return;\r\n\r\n ctrl.$formatters.push(function (a: any) {\r\n if (!a || a.length == 0) {\r\n return a;\r\n }\r\n const value = parseFloat(a);\r\n return value.toFixed(attrs.decimalPlace);\r\n });\r\n elem.bind(\"blur\", function (e) {\r\n const value = parseFloat(ctrl.$modelValue);\r\n elem.val(value.toFixed(attrs.decimalPlace));\r\n elem.triggerHandler(\"input\");\r\n });\r\n },\r\n };\r\n },\r\n ])\r\n\r\n .directive(\"currencyMask\", function () {\r\n return {\r\n restrict: \"A\",\r\n require: \"ngModel\",\r\n link: function (scope, element, attrs, ngModelController: any) {\r\n // Run formatting on keyup\r\n var numberWithCommas = function (value: any, addExtraZero: any) {\r\n if (addExtraZero == undefined) addExtraZero = false;\r\n value = value.toString();\r\n value = value.replace(/[^0-9\\.]/g, \"\");\r\n var parts = value.split(\".\");\r\n parts[0] = parts[0].replace(/\\d{1,3}(?=(\\d{3})+(?!\\d))/g, \"$&,\");\r\n if (parts[1] && parts[1].length > 2) {\r\n parts[1] = parts[1].substring(0, 2);\r\n }\r\n if (addExtraZero && parts[1] && parts[1].length === 1) {\r\n parts[1] = parts[1] + \"0\";\r\n }\r\n return parts.join(\".\");\r\n };\r\n var applyFormatting = function () {\r\n var value = element.val();\r\n var original = value;\r\n if (!value || (value as string).length == 0) {\r\n return;\r\n }\r\n value = numberWithCommas(value, false);\r\n if (value != original) {\r\n element.val(value);\r\n element.triggerHandler(\"input\");\r\n }\r\n };\r\n element.bind(\"keyup\", (e: any) => {\r\n var keycode = e.keyCode;\r\n let originalPosition = (e.target as HTMLInputElement)\r\n .selectionStart;\r\n var isTextInputKey =\r\n (keycode > 47 && keycode < 58) || // number keys\r\n keycode == 32 ||\r\n keycode == 8 ||\r\n keycode == 46 ||\r\n keycode == 229 || // spacebar or backspace/delete (or android)\r\n (keycode > 64 && keycode < 91) || // letter keys\r\n (keycode > 95 && keycode < 112) || // numpad keys\r\n (keycode > 185 && keycode < 193) || // ;=,-./` (in order)\r\n (keycode > 218 && keycode < 223); // [\\]' (in order)\r\n if (isTextInputKey) {\r\n let originalLength = (element.val() as string).length;\r\n applyFormatting();\r\n // If our length changed (due to commas being added), we need to adjust our position.\r\n originalPosition =\r\n originalPosition +\r\n ((element.val() as string).length - originalLength);\r\n if (originalPosition < 0) {\r\n originalPosition = 0;\r\n }\r\n (e.target as HTMLInputElement).selectionStart = originalPosition;\r\n (e.target as HTMLInputElement).selectionEnd = originalPosition;\r\n }\r\n });\r\n ngModelController.$parsers.push(function (value: any) {\r\n if (!value || value.length == 0) {\r\n return value;\r\n }\r\n value = value.toString();\r\n value = value.replace(/[^0-9\\.]/g, \"\");\r\n return value;\r\n });\r\n ngModelController.$formatters.push(function (value: any) {\r\n if (!value || value.length == 0) {\r\n return value;\r\n }\r\n value = numberWithCommas(value, true);\r\n return value;\r\n });\r\n },\r\n };\r\n })\r\n // .filter('percentage', ['$filter', function ($filter) {\r\n // return function (input, decimals) {\r\n\r\n // return $filter('number')(input * 100, decimals);\r\n // };\r\n\r\n // }])\r\n .directive(\"pdfDownload\", function () {\r\n return {\r\n restrict: \"E\",\r\n templateUrl: \"/views/partials/pdfdownload.html\",\r\n scope: true,\r\n link: function (scope: IpdfdownlaodScope, element, attr) {\r\n var anchor = element.children()[0];\r\n scope.name = attr.controlname;\r\n // When the download starts, do nothing at moment but maybe display somthing\r\n scope.$on(\"download-start\", function () { });\r\n\r\n // When the download finishes, attach the data to the link. and init the click event\r\n scope.$on(\"downloaded\", function (event, data, filename) {\r\n var fileURL = window.URL.createObjectURL(data);\r\n var a = document.createElement(\"a\");\r\n document.body.appendChild(a);\r\n a.href = fileURL;\r\n if (attr.filename && attr.filename.length > 0) {\r\n a.download = attr.filename;\r\n } else {\r\n a.download = filename;\r\n }\r\n a.click();\r\n });\r\n },\r\n controller: [\r\n \"$scope\",\r\n \"$attrs\",\r\n \"$http\",\r\n function ($scope, $attrs, $http) {\r\n $scope.downloadPdf = () => {\r\n $scope.$emit(\"download-start\");\r\n $http\r\n .get($attrs.url, {\r\n responseType: \"arraybuffer\",\r\n })\r\n .then((response: any) => {\r\n var filename = \"\";\r\n var disposition = response.headers()[\"content-disposition\"];\r\n if (disposition && disposition.indexOf(\"attachment\") !== -1) {\r\n var filenameRegex =\r\n /filename[^;=\\n]*=((['\"]).*?\\2|[^;\\n]*)/;\r\n var matches = filenameRegex.exec(disposition);\r\n if (matches != null && matches[1]) {\r\n filename = matches[1].replace(/['\"]/g, \"\");\r\n }\r\n }\r\n var dispostype = response.headers()[\"content-type\"];\r\n if (!dispostype) {\r\n dispostype = \"octet/stream\";\r\n }\r\n var blob = new Blob([response.data], {\r\n type: dispostype,\r\n });\r\n $scope.$emit(\"downloaded\", blob, filename);\r\n });\r\n };\r\n },\r\n ],\r\n };\r\n });\r\n\r\n registerAppTermDirective();\r\n registerRequireRoleDirective();\r\n registerRequiresStateDirective();\r\n registerRequiresAllDirective();\r\n registerWhiteLabelledDirective();\r\n registerClickOutsideDirective();\r\n}\r\n","/**\r\n * Version: 1.0 Alpha-1 \r\n * Build Date: 13-Nov-2007\r\n * Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved.\r\n * License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. \r\n * Website: http://www.datejs.com/ or http://www.coolite.com/datejs/\r\n */\r\nDate.CultureInfo={name:\"en-US\",englishName:\"English (United States)\",nativeName:\"English (United States)\",dayNames:[\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\"],abbreviatedDayNames:[\"Sun\",\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\"],shortestDayNames:[\"Su\",\"Mo\",\"Tu\",\"We\",\"Th\",\"Fr\",\"Sa\"],firstLetterDayNames:[\"S\",\"M\",\"T\",\"W\",\"T\",\"F\",\"S\"],monthNames:[\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"],abbreviatedMonthNames:[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"],amDesignator:\"AM\",pmDesignator:\"PM\",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:\"mdy\",formatPatterns:{shortDate:\"M/d/yyyy\",longDate:\"dddd, MMMM dd, yyyy\",shortTime:\"h:mm tt\",longTime:\"h:mm:ss tt\",fullDateTime:\"dddd, MMMM dd, yyyy h:mm:ss tt\",sortableDateTime:\"yyyy-MM-ddTHH:mm:ss\",universalSortableDateTime:\"yyyy-MM-dd HH:mm:ssZ\",rfc1123:\"ddd, dd MMM yyyy HH:mm:ss GMT\",monthDay:\"MMMM dd\",yearMonth:\"MMMM, yyyy\"},regexPatterns:{jan:/^jan(uary)?/i,feb:/^feb(ruary)?/i,mar:/^mar(ch)?/i,apr:/^apr(il)?/i,may:/^may/i,jun:/^jun(e)?/i,jul:/^jul(y)?/i,aug:/^aug(ust)?/i,sep:/^sep(t(ember)?)?/i,oct:/^oct(ober)?/i,nov:/^nov(ember)?/i,dec:/^dec(ember)?/i,sun:/^su(n(day)?)?/i,mon:/^mo(n(day)?)?/i,tue:/^tu(e(s(day)?)?)?/i,wed:/^we(d(nesday)?)?/i,thu:/^th(u(r(s(day)?)?)?)?/i,fri:/^fr(i(day)?)?/i,sat:/^sa(t(urday)?)?/i,future:/^next/i,past:/^last|past|prev(ious)?/i,add:/^(\\+|after|from)/i,subtract:/^(\\-|before|ago)/i,yesterday:/^yesterday/i,today:/^t(oday)?/i,tomorrow:/^tomorrow/i,now:/^n(ow)?/i,millisecond:/^ms|milli(second)?s?/i,second:/^sec(ond)?s?/i,minute:/^min(ute)?s?/i,hour:/^h(ou)?rs?/i,week:/^w(ee)?k/i,month:/^m(o(nth)?s?)?/i,day:/^d(ays?)?/i,year:/^y((ea)?rs?)?/i,shortMeridian:/^(a|p)/i,longMeridian:/^(a\\.?m?\\.?|p\\.?m?\\.?)/i,timezone:/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt)/i,ordinalSuffix:/^\\s*(st|nd|rd|th)/i,timeContext:/^\\s*(\\:|a|p)/i},abbreviatedTimeZoneStandard:{GMT:\"-000\",EST:\"-0400\",CST:\"-0500\",MST:\"-0600\",PST:\"-0700\"},abbreviatedTimeZoneDST:{GMT:\"-000\",EDT:\"-0500\",CDT:\"-0600\",MDT:\"-0700\",PDT:\"-0800\"}};\r\nDate.getMonthNumberFromName=function(name){var n=Date.CultureInfo.monthNames,m=Date.CultureInfo.abbreviatedMonthNames,s=name.toLowerCase();for(var i=0;i
date)?1:(this=start.getTime()&&t<=end.getTime();};Date.prototype.addMilliseconds=function(value){this.setMilliseconds(this.getMilliseconds()+value);return this;};Date.prototype.addSeconds=function(value){return this.addMilliseconds(value*1000);};Date.prototype.addMinutes=function(value){return this.addMilliseconds(value*60000);};Date.prototype.addHours=function(value){return this.addMilliseconds(value*3600000);};Date.prototype.addDays=function(value){return this.addMilliseconds(value*86400000);};Date.prototype.addWeeks=function(value){return this.addMilliseconds(value*604800000);};Date.prototype.addMonths=function(value){var n=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+value);this.setDate(Math.min(n,this.getDaysInMonth()));return this;};Date.prototype.addYears=function(value){return this.addMonths(value*12);};Date.prototype.add=function(config){if(typeof config==\"number\"){this._orient=config;return this;}\r\nvar x=config;if(x.millisecond||x.milliseconds){this.addMilliseconds(x.millisecond||x.milliseconds);}\r\nif(x.second||x.seconds){this.addSeconds(x.second||x.seconds);}\r\nif(x.minute||x.minutes){this.addMinutes(x.minute||x.minutes);}\r\nif(x.hour||x.hours){this.addHours(x.hour||x.hours);}\r\nif(x.month||x.months){this.addMonths(x.month||x.months);}\r\nif(x.year||x.years){this.addYears(x.year||x.years);}\r\nif(x.day||x.days){this.addDays(x.day||x.days);}\r\nreturn this;};Date._validate=function(value,min,max,name){if(typeof value!=\"number\"){throw new TypeError(value+\" is not a Number.\");}else if(valuemax){throw new RangeError(value+\" is not a valid value for \"+name+\".\");}\r\nreturn true;};Date.validateMillisecond=function(n){return Date._validate(n,0,999,\"milliseconds\");};Date.validateSecond=function(n){return Date._validate(n,0,59,\"seconds\");};Date.validateMinute=function(n){return Date._validate(n,0,59,\"minutes\");};Date.validateHour=function(n){return Date._validate(n,0,23,\"hours\");};Date.validateDay=function(n,year,month){return Date._validate(n,1,Date.getDaysInMonth(year,month),\"days\");};Date.validateMonth=function(n){return Date._validate(n,0,11,\"months\");};Date.validateYear=function(n){return Date._validate(n,1,9999,\"seconds\");};Date.prototype.set=function(config){var x=config;if(!x.millisecond&&x.millisecond!==0){x.millisecond=-1;}\r\nif(!x.second&&x.second!==0){x.second=-1;}\r\nif(!x.minute&&x.minute!==0){x.minute=-1;}\r\nif(!x.hour&&x.hour!==0){x.hour=-1;}\r\nif(!x.day&&x.day!==0){x.day=-1;}\r\nif(!x.month&&x.month!==0){x.month=-1;}\r\nif(!x.year&&x.year!==0){x.year=-1;}\r\nif(x.millisecond!=-1&&Date.validateMillisecond(x.millisecond)){this.addMilliseconds(x.millisecond-this.getMilliseconds());}\r\nif(x.second!=-1&&Date.validateSecond(x.second)){this.addSeconds(x.second-this.getSeconds());}\r\nif(x.minute!=-1&&Date.validateMinute(x.minute)){this.addMinutes(x.minute-this.getMinutes());}\r\nif(x.hour!=-1&&Date.validateHour(x.hour)){this.addHours(x.hour-this.getHours());}\r\nif(x.month!==-1&&Date.validateMonth(x.month)){this.addMonths(x.month-this.getMonth());}\r\nif(x.year!=-1&&Date.validateYear(x.year)){this.addYears(x.year-this.getFullYear());}\r\nif(x.day!=-1&&Date.validateDay(x.day,this.getFullYear(),this.getMonth())){this.addDays(x.day-this.getDate());}\r\nif(x.timezone){this.setTimezone(x.timezone);}\r\nif(x.timezoneOffset){this.setTimezoneOffset(x.timezoneOffset);}\r\nreturn this;};Date.prototype.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this;};Date.prototype.isLeapYear=function(){var y=this.getFullYear();return(((y%4===0)&&(y%100!==0))||(y%400===0));};Date.prototype.isWeekday=function(){return!(this.is().sat()||this.is().sun());};Date.prototype.getDaysInMonth=function(){return Date.getDaysInMonth(this.getFullYear(),this.getMonth());};Date.prototype.moveToFirstDayOfMonth=function(){return this.set({day:1});};Date.prototype.moveToLastDayOfMonth=function(){return this.set({day:this.getDaysInMonth()});};Date.prototype.moveToDayOfWeek=function(day,orient){var diff=(day-this.getDay()+7*(orient||+1))%7;return this.addDays((diff===0)?diff+=7*(orient||+1):diff);};Date.prototype.moveToMonth=function(month,orient){var diff=(month-this.getMonth()+12*(orient||+1))%12;return this.addMonths((diff===0)?diff+=12*(orient||+1):diff);};Date.prototype.getDayOfYear=function(){return Math.floor((this-new Date(this.getFullYear(),0,1))/86400000);};Date.prototype.getWeekOfYear=function(firstDayOfWeek){var y=this.getFullYear(),m=this.getMonth(),d=this.getDate();var dow=firstDayOfWeek||Date.CultureInfo.firstDayOfWeek;var offset=7+1-new Date(y,0,1).getDay();if(offset==8){offset=1;}\r\nvar daynum=((Date.UTC(y,m,d,0,0,0)-Date.UTC(y,0,1,0,0,0))/86400000)+1;var w=Math.floor((daynum-offset+7)/7);if(w===dow){y--;var prevOffset=7+1-new Date(y,0,1).getDay();if(prevOffset==2||prevOffset==8){w=53;}else{w=52;}}\r\nreturn w;};Date.prototype.isDST=function(){console.log('isDST');return this.toString().match(/(E|C|M|P)(S|D)T/)[2]==\"D\";};Date.prototype.getTimezone=function(){return Date.getTimezoneAbbreviation(this.getUTCOffset,this.isDST());};Date.prototype.setTimezoneOffset=function(s){var here=this.getTimezoneOffset(),there=Number(s)*-6/10;this.addMinutes(there-here);return this;};Date.prototype.setTimezone=function(s){return this.setTimezoneOffset(Date.getTimezoneOffset(s));};Date.prototype.getUTCOffset=function(){var n=this.getTimezoneOffset()*-10/6,r;if(n<0){r=(n-10000).toString();return r[0]+r.substr(2);}else{r=(n+10000).toString();return\"+\"+r.substr(1);}};Date.prototype.getDayName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedDayNames[this.getDay()]:Date.CultureInfo.dayNames[this.getDay()];};Date.prototype.getMonthName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedMonthNames[this.getMonth()]:Date.CultureInfo.monthNames[this.getMonth()];};Date.prototype._toString=Date.prototype.toString;Date.prototype.toString=function(format){var self=this;var p=function p(s){return(s.toString().length==1)?\"0\"+s:s;};return format?format.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g,function(format){switch(format){case\"hh\":return p(self.getHours()<13?self.getHours():(self.getHours()-12));case\"h\":return self.getHours()<13?self.getHours():(self.getHours()-12);case\"HH\":return p(self.getHours());case\"H\":return self.getHours();case\"mm\":return p(self.getMinutes());case\"m\":return self.getMinutes();case\"ss\":return p(self.getSeconds());case\"s\":return self.getSeconds();case\"yyyy\":return self.getFullYear();case\"yy\":return self.getFullYear().toString().substring(2,4);case\"dddd\":return self.getDayName();case\"ddd\":return self.getDayName(true);case\"dd\":return p(self.getDate());case\"d\":return self.getDate().toString();case\"MMMM\":return self.getMonthName();case\"MMM\":return self.getMonthName(true);case\"MM\":return p((self.getMonth()+1));case\"M\":return self.getMonth()+1;case\"t\":return self.getHours()<12?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case\"tt\":return self.getHours()<12?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case\"zzz\":case\"zz\":case\"z\":return\"\";}}):this._toString();};\r\nDate.now=function(){return new Date();};Date.today=function(){return Date.now().clearTime();};Date.prototype._orient=+1;Date.prototype.next=function(){this._orient=+1;return this;};Date.prototype.last=Date.prototype.prev=Date.prototype.previous=function(){this._orient=-1;return this;};Date.prototype._is=false;Date.prototype.is=function(){this._is=true;return this;};Number.prototype._dateElement=\"day\";Number.prototype.fromNow=function(){var c={};c[this._dateElement]=this;return Date.now().add(c);};Number.prototype.ago=function(){var c={};c[this._dateElement]=this*-1;return Date.now().add(c);};(function(){var $D=Date.prototype,$N=Number.prototype;var dx=(\"sunday monday tuesday wednesday thursday friday saturday\").split(/\\s/),mx=(\"january february march april may june july august september october november december\").split(/\\s/),px=(\"Millisecond Second Minute Hour Day Week Month Year\").split(/\\s/),de;var df=function(n){return function(){if(this._is){this._is=false;return this.getDay()==n;}\r\nreturn this.moveToDayOfWeek(n,this._orient);};};for(var i=0;i0&&!last){try{q=d.call(this,r[1]);}catch(ex){last=true;}}else{last=true;}\r\nif(!last&&q[1].length===0){last=true;}\r\nif(!last){var qx=[];for(var j=0;j0){rx[0]=rx[0].concat(p[0]);rx[1]=p[1];}}\r\nif(rx[1].length1){args=Array.prototype.slice.call(arguments);}else if(arguments[0]instanceof Array){args=arguments[0];}\r\nif(args){for(var i=0,px=args.shift();i2)?n:(n+(((n+2000)Date.getDaysInMonth(this.year,this.month)){throw new RangeError(this.day+\" is not a valid value for days.\");}\r\nvar r=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second);if(this.timezone){r.set({timezone:this.timezone});}else if(this.timezoneOffset){r.set({timezoneOffset:this.timezoneOffset});}\r\nreturn r;},finish:function(x){x=(x instanceof Array)?flattenAndCompact(x):[x];if(x.length===0){return null;}\r\nfor(var i=0;i ng.IPromise;\r\n\r\n public uploading: boolean;\r\n\r\n public error: boolean;\r\n\r\n\r\n static $inject = ['$scope', '$http'];\r\n constructor(private $scope: ng.IScope, public $http: ng.IHttpService) {\r\n\r\n }\r\n\r\n uploadFile(file: File) {\r\n this.uploading = true;\r\n if (!file) {\r\n return;\r\n }\r\n\r\n this.$http.get(this.uploadRequestUrl, { params: { fileName: this.folderPath + file.name, fileType: file.type } }).then((response) => {\r\n\r\n this.$http.put(response.data as string, file, { headers: { 'Content-Type': file.type } })\r\n .then((response) => {\r\n this.uploadComplete({ filename: file.name });\r\n })\r\n .catch((response) => {\r\n\r\n }).finally(() => {\r\n this.uploading = false;\r\n });\r\n });\r\n };\r\n\r\n}\r\n","export class CcqGlobalSearchBarComponent implements ng.IComponentOptions {\r\n\r\n public transclude: boolean = true;\r\n\r\n public bindings: any;\r\n public controller: any;\r\n public templateUrl: string;\r\n\r\n constructor() {\r\n this.bindings = {\r\n placeholder: '@',\r\n search: '&',\r\n selectItem: '&'\r\n\r\n };\r\n this.controller = CcqGlobalSearchBarController;\r\n this.templateUrl = 'js/dist/components/globalsearchbar/globalsearchbar.html';\r\n }\r\n}\r\n\r\nexport class CcqGlobalSearchBarController {\r\n public placeholder: string;\r\n public search: (any) => ng.IPromise;\r\n public selectItem: (any) => ng.IPromise;\r\n\r\n public needle: string;\r\n public items: any[];\r\n public selectedItem: any;\r\n public selectedIndex: number;\r\n\r\n public meterCount: number = 0;\r\n public customerCount: number = 0;\r\n public agencyCount: number = 0;\r\n public siteCount: number = 0;\r\n\r\n\r\n static $inject = ['$parse'];\r\n constructor(private $parse: ng.IParseService) {\r\n\r\n }\r\n\r\n highlightItem(index: number) {\r\n if (!this.items) {\r\n return;\r\n }\r\n }\r\n\r\n keyUp($event: KeyboardEvent) {\r\n if ($event.keyCode === 13) {\r\n this.selectByIndex();\r\n }\r\n else if ($event.keyCode === 38) {\r\n if (this.selectedIndex > 0) {\r\n this.selectedIndex--;\r\n }\r\n }\r\n else if ($event.keyCode === 40) {\r\n if (this.selectedIndex === undefined) {\r\n this.selectedIndex = 0;\r\n }\r\n\r\n }\r\n\r\n this.highlightItem(this.selectedIndex);\r\n }\r\n\r\n updateSearch() {\r\n if (!this.needle) {\r\n delete this.items;\r\n return;\r\n }\r\n\r\n this.search({ needle: this.needle }).then((response) => {\r\n this.items = response;\r\n\r\n });\r\n }\r\n\r\n selectByIndex() {\r\n\r\n }\r\n\r\n select(item: any, type: string) {\r\n delete this.items;\r\n this.selectItem({ item: item });\r\n }\r\n}\r\n\r\n\r\n","export class LazyLoadListComponent implements ng.IComponentOptions {\r\n public transclude: boolean = true;\r\n public bindings: any;\r\n public controller: any;\r\n public templateUrl: string;\r\n\r\n constructor() {\r\n this.bindings = {\r\n getItems: \"&\",\r\n selectItem: \"&\",\r\n frontendFiltering: \"<\",\r\n };\r\n\r\n this.controller = LazyLoadListController;\r\n this.templateUrl = \"js/components/lazyloadlist/lazyloadlist.html\";\r\n }\r\n}\r\n\r\nexport class LazyLoadListController implements ng.IComponentController {\r\n public items: any[] = [];\r\n public getItems: (query: any) => ng.IPromise;\r\n public selectItem: (item: any) => ng.IPromise;\r\n public page: number = 1;\r\n public itemFormat: any;\r\n public scrollPercent: number = 0;\r\n public limitHit: boolean = false;\r\n public fetchingItems: boolean = false;\r\n public needle: string = \"\";\r\n public frontendFiltering: boolean = false;\r\n\r\n static $inject = [\"$scope\"];\r\n constructor(private $scope: ng.IScope) {}\r\n\r\n $postLink() {\r\n this.doGetItems();\r\n }\r\n\r\n doGetItems() {\r\n if (!this.limitHit) {\r\n this.fetchingItems = true;\r\n this.getItems({ page: this.page, needle: this.needle })\r\n .then((response) => {\r\n if (response.TotalPageCount >= this.page) {\r\n this.items = [...this.items, ...response.List];\r\n this.page++;\r\n } else {\r\n this.limitHit = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.fetchingItems = false;\r\n });\r\n }\r\n }\r\n\r\n doSelectItem(item: any) {\r\n this.selectItem({ item: item });\r\n }\r\n\r\n resetListAndSearch() {\r\n this.items = [];\r\n this.page = 1;\r\n this.limitHit = false;\r\n this.doGetItems();\r\n }\r\n\r\n filterItems() {\r\n if (this.frontendFiltering) {\r\n return this.needle;\r\n } else {\r\n return \"\";\r\n }\r\n }\r\n}\r\n","import angular from \"angular\";\r\nimport {\r\n CcqFileUploadComponent,\r\n CcqFileUploadController,\r\n} from \"./filesfromccqbase/Components/fileupload/fileupload\";\r\nimport {\r\n CcqGlobalSearchBarComponent,\r\n CcqGlobalSearchBarController,\r\n} from \"./filesfromccqbase/Components/globalsearchbar/globalsearchbar\";\r\nimport {\r\n LazyLoadListComponent,\r\n LazyLoadListController,\r\n} from \"./filesfromccqbase/Components/lazyloadlist/lazyloadlist\";\r\n\r\nexport function registerCCQBaseComponents() {\r\n angular\r\n .module(\"ccqapp\")\r\n .controller(\"FileUploadController\", CcqFileUploadController)\r\n .component(\"fileupload\", new CcqFileUploadComponent())\r\n .controller(\"GlobalSearchBarController\", CcqGlobalSearchBarController)\r\n .component(\"globalSearchBar\", new CcqGlobalSearchBarComponent())\r\n .controller(\"LazyLoadListController\", LazyLoadListController)\r\n .component(\"lazyLoadList\", new LazyLoadListComponent());\r\n}\r\n","import { LenderService } from \"@js/services/LenderService\";\r\n\r\nexport class AssistanceSliderComponentController {\r\n\r\n public assistanceSlider: boolean = false;\r\n public accordionShow: boolean[] = [];\r\n public applicationName: string;\r\n public totalLenderCount: number;\r\n\r\n constructor(public $location, private lenderService: LenderService) {\r\n this.lenderService.getTotalLenders().then((result: number) => {\r\n this.totalLenderCount = result;\r\n });\r\n }\r\n\r\n public toggleAccordion(id: number) {\r\n if (!this.accordionShow[id]) {\r\n this.accordionShow[id] = true;\r\n } else {\r\n this.accordionShow[id] = !this.accordionShow[id];\r\n }\r\n\r\n }\r\n\r\n public getApplicationName() {\r\n let lsd = sessionStorage.getItem('applicationName');\r\n if (lsd != null) {\r\n this.applicationName = lsd;\r\n } else {\r\n this.applicationName = 'Brickflow';\r\n }\r\n }\r\n\r\n}\r\n","export class BreadcrumbTabsComponentController {\r\n\r\n public links: string[] = [];\r\n\r\n constructor(private $window: ng.IWindowService) {\r\n }\r\n\r\n\r\n}\r\n","export class CarouselComponentController {\r\n\r\n public carouselData: string[] = [];\r\n public totalSteps: number=0;\r\n public carouselStep: number = 0;\r\n public autoCycle: boolean = true;\r\n\r\n constructor(public $interval) { }\r\n\r\n $postLink() {\r\n this.totalSteps = this.carouselData.length - 1;\r\n this.$interval(() => {\r\n if (this.autoCycle) {\r\n this.carouselNext();\r\n }\r\n }, 7000);\r\n }\r\n\r\n $doCheck() {\r\n if (this.carouselStep > this.totalSteps) {\r\n this.carouselStep = 0;\r\n }\r\n if (this.carouselStep < 0) {\r\n this.carouselStep = this.totalSteps;\r\n }\r\n }\r\n\r\n public carouselNext() {\r\n //Just before stepping, make the opacity of the text 0\r\n this.carouselStep++;\r\n }\r\n\r\n public carouselBack() {\r\n this.carouselStep--;\r\n }\r\n\r\n}\r\n\r\n","export class ModalPopupComponentController {\r\n\r\n public toggleModal: boolean = false;\r\n public prevToggleModalVal: boolean = false;\r\n public loading: boolean = false;\r\n public formSectionNames: [] = [];\r\n public step: number;\r\n\r\n // Configures whether the modal closes when the user clicks outside of the modal - by default (true/undefined) the modal will close\r\n public closeOnBlur: boolean = true;\r\n\r\n constructor(private $element: ng.IAugmentedJQuery, private $scope: ng.IScope) {\r\n }\r\n\r\n sum(a: number, b: number): number {\r\n return a + b;\r\n }\r\n\r\n}\r\n","\r\n//JS Not in use, when used as a component as the code is currently, the ng-model is not updating before the ng-change\r\n\r\nexport class PaymentToggleController {\r\n\r\n constructor(private $rootScope, private $element) { }\r\n\r\n}\r\n","export class RegInfoPanelController {\r\n public heading: string;\r\n public subtext: string;\r\n public mainheading: string;\r\n public subheading: string;\r\n public logoUrl: string = '';\r\n public isWhiteLabelled: boolean = false;\r\n\r\n constructor(private $rootScope, private $element) {\r\n }\r\n\r\n public getLogo() {\r\n if (sessionStorage.getItem('companyLogoUrl') != null) {\r\n this.isWhiteLabelled = true;\r\n return sessionStorage.getItem('companyLogoUrl');\r\n } else {\r\n this.isWhiteLabelled = false;\r\n return '../../img/BrickFlow_Logo_RGB_Blue_Icon.svg';\r\n }\r\n }\r\n}\r\n","\r\n\r\n export class SpinnerController {\r\n public minValue: number;\r\n public maxValue: number;\r\n public value: number;\r\n \r\n constructor(private $rootScope, private $element) { }\r\n\r\n public next() {\r\n if (this.value == this.maxValue) {\r\n return;\r\n }\r\n this.value++;\r\n }\r\n\r\n public prev() {\r\n if (this.value == this.minValue) {\r\n return;\r\n }\r\n this.value--;\r\n }\r\n }\r\n","\r\n\r\n export class TourPopupComponentController {\r\n\r\n public tourOrder: number;\r\n public tourState: any;\r\n public stepEnabled: boolean = true;\r\n public repeatStop: number;\r\n\r\n constructor(private $rootScope, private $element) { }\r\n\r\n $postLink() {\r\n // Update the total steps by adding ourself.\r\n this.tourState.tourTotalSteps = this.tourState.tourTotalSteps + 1;\r\n }\r\n\r\n $onDestroy() {\r\n // Update the total steps by removing ourself.\r\n this.tourState.tourTotalSteps = this.tourState.tourTotalSteps - 1;\r\n }\r\n\r\n $doCheck() {\r\n\r\n // See if we're the next step...\r\n if ((this.tourState.tourStep == this.tourOrder) && (this.tourOrder != this.$rootScope.repeatStop)) {\r\n\r\n if (!this.stepEnabled && this.stepEnabled !== undefined) {\r\n // If we're disabled, we want to move to the next step immediately.\r\n this.next();\r\n } else {\r\n if (this.tourOrder != 1) {\r\n let element = document.getElementById('tourStep' + this.tourState.tourStep);\r\n if (element) {\r\n element.scrollIntoView({ behavior: 'smooth', block: 'center' });\r\n }\r\n }\r\n }\r\n\r\n //suppress repeat calls for this step\r\n this.$rootScope.repeatStop = this.tourOrder;\r\n }\r\n }\r\n\r\n public next() {\r\n this.$rootScope.$broadcast('nextTour');\r\n }\r\n\r\n public back() {\r\n this.$rootScope.$broadcast('backTour');\r\n }\r\n\r\n public skip() {\r\n this.$rootScope.$broadcast('skipTour');\r\n }\r\n\r\n }\r\n\r\n","export class VerticalProgressBarController {\r\n public nodes: { step: number, label: string, active: boolean, complete: boolean }[];\r\n public currentStep: number;\r\n \r\n constructor(private $rootScope, private $element) {}\r\n}\r\n","import { BridgingDealDTO } from \"@js/DTO/Deal/BridgingDealDTO.cs.d\";\r\nimport { CommercialDealDTO } from \"@js/DTO/Deal/CommercialDealDTO.cs.d\";\r\nimport { DevelopmentFinanceDealDTO } from \"@js/DTO/Deal/DevelopmentFinanceDealDTO.cs.d\";\r\nimport { LocationEnum } from \"@js/models/enum/LocationEnum.cs.d\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\n\r\nexport class CriteriaController<\r\n T extends BridgingDealDTO | CommercialDealDTO | DevelopmentFinanceDealDTO,\r\n> {\r\n dealDto: T;\r\n dataLoading: boolean = false;\r\n\r\n //Postcode properties\r\n showPostcodeErrorMessage: boolean = false;\r\n postcodeErrorMsg: string;\r\n previouslySelectedLocation: LocationEnum;\r\n\r\n static $inject = [\"DealService\"];\r\n\r\n constructor(public dealService: DealService) {}\r\n\r\n getRegionByPostcode() {\r\n if (\r\n this.dealDto.PostcodeSearchString &&\r\n this.dealDto.PostcodeSearchString.replace(\" \", \"\").length >= 2\r\n ) {\r\n if (\r\n this.dealService.isValidPostcodeString(\r\n this.dealDto.PostcodeSearchString,\r\n )\r\n ) {\r\n this.dataLoading = true;\r\n this.dealService\r\n .getRegionByPostcode(this.dealDto.PostcodeSearchString)\r\n .then((response) => {\r\n if (response.Location != null) {\r\n this.dealDto.Locations = response.Location;\r\n this.showPostcodeErrorMessage = false;\r\n } else {\r\n this.postcodeErrorMsg = response.PostCodeErrorMessage;\r\n this.showPostcodeErrorMessage = true;\r\n if (this.dealDto.Locations) this.dealDto.Locations = null;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.postcodeErrorMsg =\r\n \"At least one letter and one number must be entered e.g. SW1.\";\r\n this.showPostcodeErrorMessage = true;\r\n if (this.dealDto.Locations) this.dealDto.Locations = null;\r\n }\r\n } else {\r\n if (this.dealDto.Locations) this.dealDto.Locations = null;\r\n }\r\n }\r\n\r\n onHasPostcodeChange() {\r\n if (!this.dealDto.hasPostcode) {\r\n this.showPostcodeErrorMessage = false;\r\n this.dealDto.PostcodeSearchString = null;\r\n this.dealDto.Locations = this.previouslySelectedLocation;\r\n } else {\r\n this.previouslySelectedLocation = this.dealDto.Locations;\r\n this.dealDto.Locations = null;\r\n }\r\n }\r\n}\r\n","export const enum CaseStatusEnum {\r\n Search = 999,\r\n NewCase = 0,\r\n InProgress = 1,\r\n UnderReview = 2,\r\n ReadyToSubmit = 3,\r\n SubmittedToLendersForHoT = 4,\r\n ReadyToReSubmit = 12,\r\n Applied = 5,\r\n CreditApproved = 10,\r\n WithProfessionals = 11,\r\n Completed = 6,\r\n Dormant = 7,\r\n SubmittedToLendersPendingReview = 9,\r\n SentToPackager = 13,\r\n\r\n}\r\n","export const enum DealSourceTypeEnum {\r\n Unknown = 0,\r\n Application = 1,\r\n WhitelabelApplication = 2,\r\n IFrameEnterprise = 3,\r\n IFrameUniqueLink = 4,\r\n UniqueLink = 5,\r\n Enterprise = 6,\r\n Api = 7,\r\n WidgetUniqueLink = 8,\r\n WidgetEnterprise = 9,\r\n}\r\n","export const enum LandOrPropertyEnum {\r\n None = 0,\r\n Land = 1,\r\n Property = 2,\r\n}\r\n","export const enum LinkTypeEnum {\r\n Development = 1,\r\n Bridging = 2,\r\n AllLoans = 3,\r\n Commercial = 4,\r\n}\r\n","export const enum LoanCompletionTypeEnum {\r\n AsSoonAsPossible = 1,\r\n JustCheckingMyOptions = 2,\r\n WithinNextFewWeeks = 3,\r\n WithinNext2to3Months = 4,\r\n}\r\n","export const enum LocationEnum {\r\n None = 0,\r\n London = 1,\r\n NorthWest = 2,\r\n Midlands = 4,\r\n EastofEngland = 8,\r\n SouthEast = 16,\r\n SouthWest = 32,\r\n NorthEast = 64,\r\n Wales = 128,\r\n Scotland = 256,\r\n NorthernIreland = 512,\r\n ChannelIsland = 1024,\r\n Any,\r\n}\r\n","export const enum OriginatorRoleTypeEnum {\r\n Unknown = 0,\r\n Admin = 1,\r\n Broker = 2,\r\n Lender = 3,\r\n Borrower = 4,\r\n}\r\n","export const enum OwnOrPurchaseEnum {\r\n Own = 1,\r\n Purchasing = 2,\r\n}\r\n","export const enum PlanningPermissionTypeEnum {\r\n None = 0,\r\n NoPlanning = 1,\r\n DetailedPlanning = 2,\r\n OutlinePlanning = 3,\r\n NoPlanningRequired = 4,\r\n PermittedDevelopment = 5,\r\n NoOutlinePlanning = 6,\r\n VaryPlanningonExistingBuilding = 7,\r\n NewPlanningOnAnotherPartOfSite = 8,\r\n VaryPlanningOnExistingAndNewPlanningOnAnotherPartOfSite = 9,\r\n NewPlanningApplicationOrDemolishExistingBuilding = 10,\r\n}\r\n","export const enum ProductFamilyEnum {\r\n None = 0,\r\n Development = 1,\r\n Bridging = 2,\r\n Commercial = 3,\r\n}\r\n","export const enum ProductTypeEnum {\r\n None = 0,\r\n Development = 1,\r\n BridgingPreconstruction = 2,\r\n BridgingPurchaseOrRefinance = 4,\r\n BridgingRefurb = 8,\r\n BridgingDeveloperExit = 16,\r\n CommercialInvestment = 32,\r\n CommercialOwnerOccupied = 64,\r\n /** IMPORTANT NOTE JSAny changes to the above enums (including additions) must be reflected below.Issue with the MadsKristensen.TypeScriptDefinitionGenerator being used since the generated file does not calculate the composite value,and will just increment 1 to the previous item in the list. Therefore the below commented code would not work.Bridging = BridgingPreconstruction | BridgingPurchaseOrRefinance | BridgingRefurb | BridgingDeveloperExitCommercialAll = CommercialInvestment | CommercialOwnerOccupied */\r\n Bridging = 30,\r\n CommercialAll = 96,\r\n}\r\n","export const enum PropertyTypeEnum {\r\n None = 0,\r\n Residential = 1,\r\n MixedUse = 2,\r\n Hotel = 4,\r\n Leisure = 8,\r\n CareRetirement = 16,\r\n Medical = 32,\r\n Office = 64,\r\n Retail = 128,\r\n LightIndustrial = 256,\r\n Student = 512,\r\n HeavyIndustrial = 1024,\r\n HMO = 2048,\r\n LandWithoutPlanning = 4096,\r\n Education = 8192,\r\n Retirement = 16384,\r\n AllCommercialMixedUse = 32768,\r\n MultiUnitFreeholdBlock = 65536,\r\n}\r\n","export const enum RefurbishmentLevelEnum {\r\n None = 0,\r\n Light = 1,\r\n Medium = 2,\r\n Heavy = 3,\r\n}\r\n","export const enum YesNoMaybe {\r\n NotfilledIn = 0,\r\n Yes = 1,\r\n No = 2,\r\n Maybe = 3,\r\n}\r\n","export const enum UserRoleEnum {\r\n None = 0,\r\n Admin = 1,\r\n Broker = 2,\r\n Lender = 3,\r\n Client = 4,\r\n Introducer = 5,\r\n}\r\n","import { CriteriaController } from \"@js/controllers/CriteriaController\";\r\nimport { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { BridgingDealDTO } from \"@js/DTO/Deal/BridgingDealDTO.cs.d\";\r\nimport { ShareDealDTO } from \"@js/DTO/Deal/SearchDealDTO.cs.d\";\r\nimport { SaveBridgingSearchRequest } from \"@js/DTO/Messages/Deal/SaveBridgingSearchMessage.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { OrganisationLinkDTO } from \"@js/DTO/OrgnisationLinkDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { DealSourceTypeEnum } from \"@js/models/enum/DealSourceTypeEnum.cs.d\";\r\nimport { LandOrPropertyEnum } from \"@js/models/enum/LandOrPropertyEnum.cs.d\";\r\nimport { LinkTypeEnum } from \"@js/models/enum/LinkTypeEnum.cs.d\";\r\nimport { LoanCompletionTypeEnum } from \"@js/models/enum/LoanCompletionTypeEnum.cs.d\";\r\nimport { LocationEnum } from \"@js/models/enum/LocationEnum.cs.d\";\r\nimport { OriginatorRoleTypeEnum } from \"@js/models/enum/OriginatorRoleTypeEnum.cs.d\";\r\nimport { OwnOrPurchaseEnum } from \"@js/models/enum/OwnOrPurchaseEnum.cs.d\";\r\nimport { PlanningPermissionTypeEnum } from \"@js/models/enum/PlanningPermissionTypeEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { PropertyTypeEnum } from \"@js/models/enum/PropertyTypeEnum.cs.d\";\r\nimport { RefurbishmentLevelEnum } from \"@js/models/enum/RefurbishmentLevelEnum.cs.d\";\r\nimport { YesNoMaybe } from \"@js/models/enum/YesNoMaybeEnum.cs.d\";\r\nimport { SaveSearchReturnUniqueRefResponse } from \"@js/models/SaveSearchReturnUniqueRef.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { ClientService } from \"@js/services/ClientService\";\r\nimport { BridgingDealService } from \"@js/services/Deal/BridgingDealService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { SharedCriteriaService } from \"@js/services/Deal/SharedCriteriaService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationLinkService } from \"@js/services/OrganisationLinkService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { EnterpriseService } from \"@js/services/EnterpriseService\";\r\nimport { UserRoleEnum } from \"@js/models/enum/UserRoleEnum.cs.d\";\r\n\r\nexport class BridgingCriteriaController extends CriteriaController {\r\n isSaving: boolean = false;\r\n hasError: boolean = false;\r\n\r\n productType: ProductTypeEnum;\r\n\r\n dealDto: BridgingDealDTO;\r\n tempDealDto: BridgingDealDTO;\r\n snapshotDealDto: BridgingDealDTO;\r\n classUses: {} = {};\r\n yesNoOptions = [];\r\n siteTypeOptions = [];\r\n propertyTypeOptions = [];\r\n showResidual: boolean = false;\r\n showSummary: boolean = false;\r\n showKeyMatrix: boolean = false;\r\n isLoggedInUser: boolean = false;\r\n isSearchStarted: boolean = false;\r\n totalLenders: number;\r\n buildingConditionOptions = [];\r\n buildStageOptions = [];\r\n locationOptions = [];\r\n loanCompletionTypeOptions = [];\r\n refurbishmentLevelOptions = [];\r\n planningOptions = [];\r\n multiPartForm1: ng.IFormController;\r\n multiPartForm2: ng.IFormController;\r\n multiPartForm3: ng.IFormController;\r\n propertyForm: ng.IFormController;\r\n\r\n isBorrower: boolean = false;\r\n organisation: OrganisationDTO;\r\n moveContactBrokerBtnInMiddle: boolean = false;\r\n user: ApplicationUserDTO = null;\r\n initialRegistrationClient: ClientDTO;\r\n orgCode: string;\r\n\r\n //Share a search modal\r\n showShareSearchtoClientModal: boolean = false;\r\n isResultScreen: boolean = false;\r\n existingUsers: UserSimpleDTO[];\r\n existingborrower: boolean;\r\n shareDealDto: ShareDealDTO = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n showClientDetails: boolean = false;\r\n profitBeforeCosts: number = 0;\r\n ROCE: number = 0;\r\n purchasePrice: number = 0;\r\n purchaseCosts: number = 0;\r\n GDV: number = 0;\r\n isSubmitted: boolean = false;\r\n showAutofill: boolean = false;\r\n error: string;\r\n\r\n //share search modal\r\n isBridging: boolean = true;\r\n\r\n guidanceCheckbox: boolean = true;\r\n maxPurchaseDate: Date = new Date();\r\n minPurchaseDate: Date = new Date(\"Jan 01 1900\");\r\n minCompletionDate: Date;\r\n hasPurchasecostChanged: boolean = false;\r\n hasLandcostChanged: boolean = false;\r\n userRole: string = \"\";\r\n userDetails: string = null;\r\n projectName: string = null;\r\n clientId: string = null;\r\n //dataLoading: boolean = false;\r\n\r\n isFamilyInResidence: boolean = false;\r\n ownOrPurchase: boolean = false;\r\n landOrProperty: boolean = false;\r\n\r\n headingAdjustment: string;\r\n\r\n //Enterprise\r\n organisationLink: OrganisationLinkDTO;\r\n noPermissionErrorMsg: string = \"\";\r\n\r\n contingencyAmount: number = null;\r\n\r\n //Postcode properties\r\n //showPostcodeErrorMessage: boolean = false;\r\n // postcodeErrorMsg: string;\r\n //previouslySelectedLocation: LocationEnum;\r\n\r\n isAdmin: boolean = false;\r\n isBroker: boolean = false;\r\n isLender: boolean = false;\r\n\r\n isUniqueLink: boolean = false;\r\n\r\n //enterprise widget journey\r\n isMobileView: boolean = false;\r\n showHelpModal: boolean = false;\r\n loanInfoText: string;\r\n progressAmount: string = \"50%\";\r\n progressSection: number = 1;\r\n totalSections: number = 2;\r\n enterpriseLinkLogo: string;\r\n isWidget: boolean = false;\r\n\r\n //This propert is used to show only postcode ot location field on critera for mobile view\r\n isCriteria: boolean = true;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$cookies\",\r\n \"DevelopmentInputService\",\r\n \"$location\",\r\n \"$q\",\r\n \"CaseService\",\r\n \"UserService\",\r\n \"RoleService\",\r\n \"OrganisationService\",\r\n \"SelectListService\",\r\n \"LenderService\",\r\n \"BridgingDealService\",\r\n \"ClientService\",\r\n \"ProductService\",\r\n \"AuthService\",\r\n \"OrganisationLinkService\",\r\n \"EventLogService\",\r\n \"SharedCriteriaService\",\r\n \"DealService\",\r\n \"EnterpriseService\"\r\n ].concat(CriteriaController.$inject);\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $DevelopmentInputservice: DevelopmentInputService,\r\n private $location: ng.ILocationService,\r\n protected $q: ng.IQService,\r\n private caseService: CaseService,\r\n private userService: UserService,\r\n private roleService: RoleService,\r\n private organisationService: OrganisationService,\r\n private selectListService: SelectListService,\r\n private lenderService: LenderService,\r\n private bridgingDealService: BridgingDealService,\r\n private clientService: ClientService,\r\n private productService: ProductService,\r\n private $auth: AuthService,\r\n private organisationLinkService: OrganisationLinkService,\r\n private eventLogService: EventLogService,\r\n private sharedCriteriaService: SharedCriteriaService,\r\n dealService: DealService,\r\n private enterpriseService: EnterpriseService\r\n ) {\r\n super(dealService);\r\n try {\r\n\r\n if (this.$routeParams.context == 'widget' && window.self != window.top) {\r\n this.isWidget = true;\r\n } else {\r\n if (window.innerWidth <= 480)\r\n this.isMobileView = true\r\n }\r\n\r\n\r\n if (this.dealDto == null) {\r\n this.dealDto = {} as BridgingDealDTO;\r\n }\r\n\r\n //Enteprise journey code\r\n if (!$cookies.get(\"access_token\") &&\r\n (this.$location.path().startsWith(\"/e/bridgingcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\"))\r\n ) {\r\n this.isBorrower = true;\r\n\r\n if (this.$location.path().startsWith(\"/e/bridgingcriteria\")) {\r\n var imgs = document.getElementsByTagName(\"img\");\r\n this.enterpriseLinkLogo = imgs[0].src;\r\n this.sharedCriteriaService.storeEnterpriseLinkType(LinkTypeEnum.Bridging.toString());\r\n }\r\n\r\n if (this.isWidget) {\r\n // document.getElementById(\"footer\").style.display = \"none\";\r\n this.organisationService.sendDataToParent(\"height\", \"745px\");\r\n }\r\n\r\n if (!this.$routeParams.DealUniqueRef) {\r\n if (window.self == window.top) {\r\n this.orgCode = this.$cookies.get(\"org_code\");\r\n sessionStorage.setItem(\"userRole\", UserRoleEnum.Client.toString());\r\n } else {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n this.organisationService.sendDataToParent(\"userRole\", UserRoleEnum.Client.toString());\r\n }\r\n\r\n this.logEventWithoutDealData();\r\n\r\n }\r\n\r\n\r\n this.organisationService\r\n .getOrgByUrlIfOrgHasEnterpriseSearchPermission(\r\n this.orgCode,\r\n ProductFamilyEnum.Bridging,\r\n this.$routeParams.linkId,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n this.organisation = response;\r\n this.orgCode = response.OrganisationCode;\r\n\r\n if (this.$routeParams.linkId) {\r\n if (this.$location.path().startsWith(\"/e/bridgingcriteria\")) {\r\n this.organisationLinkService\r\n .getOrganisationLinkLogoByLinkIdAndLogPageLoadEvent(\r\n this.$routeParams.linkId\r\n )\r\n .then((logoUrl) => {\r\n if (logoUrl) this.enterpriseLinkLogo = imgs[0].src = logoUrl;\r\n });\r\n }\r\n }\r\n\r\n } else {\r\n this.logEvent(\"BRIDGINGCRITERIA-NO-PERMISSION-TO-SEARCH\");\r\n this.noPermissionErrorMsg =\r\n \"We are unable to compare loans right now. Please contact your broker.\";\r\n }\r\n })\r\n .finally(() => { });\r\n }\r\n\r\n if (window.self == window.top && $cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n\r\n this.userService.getUserAutofill().then((response) => {\r\n this.showAutofill = response;\r\n });\r\n\r\n this.roleService.GetUserRoles().then((result) => {\r\n if (result.filter((x) => x.toLowerCase() == \"admin\").length > 0) {\r\n this.isAdmin = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"broker\").length > 0) {\r\n this.isBroker = true;\r\n //This block is to navigate a broker to userdashboard when they do not have a license.\r\n if (this.isBroker) {\r\n if (sessionStorage.getItem(\"isValidLicense\") == \"false\") {\r\n this.gotoDashboard();\r\n }\r\n }\r\n }\r\n if (\r\n result.filter((x) => x.toLowerCase() == \"lender\").length > 0 &&\r\n !this.isAdmin\r\n ) {\r\n this.isLender = true;\r\n }\r\n\r\n if (\r\n result.filter((x) => x.toLowerCase() == \"client\").length > 0 &&\r\n !this.isAdmin\r\n ) {\r\n this.isBorrower = true;\r\n }\r\n }).finally(() => {\r\n if (this.$auth.getHasValidStatustoShowShareSearchModal()) {\r\n if (sessionStorage.getItem(\"skip\")) {\r\n //This will hide's a share search to client modal\r\n this.showShareSearchtoClientModal = false;\r\n } else {\r\n //getting a previously entered DealName and Client data \r\n if (this.dealService.getShowSearchNameAndUserSelectionModal()) {\r\n this.showShareSearchtoClientModal = true;\r\n this.getUsersBelongToBrokerOrAdmin();\r\n } else {\r\n this.shareDealDto.ClientDto = this.dealService.getClient();\r\n this.shareDealDto.DealName = this.dealService.getDealName();\r\n }\r\n }\r\n }\r\n this.getOriginatorInfoForUser();\r\n });\r\n } else {\r\n if (!this.$routeParams.DealUniqueRef) {\r\n if (window.self == window.top) {\r\n this.clientId = sessionStorage.getItem(\"clientId\");\r\n } else {\r\n Promise.all([\r\n this.organisationService.getData(\"clientId\").then((clientId) => {\r\n if (clientId) {\r\n this.clientId = clientId;\r\n }\r\n }),\r\n ]);\r\n }\r\n }\r\n }\r\n\r\n if (this.$routeParams.DealUniqueRef && this.$routeParams.DealUniqueRef != '0') {\r\n this.dataLoading = true;\r\n this.dealService\r\n .fetchByUniqueRef(this.$routeParams.DealUniqueRef)\r\n .then((response) => {\r\n this.postRetrieveProcessing(response);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n else if (this.$routeParams.SearchId > 0) {\r\n this.dataLoading = true;\r\n this.bridgingDealService\r\n .fetch(this.$routeParams.SearchId)\r\n .then((response) => {\r\n this.postRetrieveProcessing(response);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.bridgingTypeChanged(ProductTypeEnum.BridgingPurchaseOrRefinance);\r\n }\r\n\r\n // if (window.self == window.top) {\r\n // this.updateGuidanceState();\r\n\r\n // $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n // this.updateGuidanceState();\r\n // });\r\n // }\r\n\r\n this.caseService.updateTubeMap(CaseStatusEnum.Search);\r\n this.buildStageOptions = this.selectListService.GetBuildStageOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n this.loanCompletionTypeOptions = this.selectListService.GetLoanCompletionOptions();\r\n this.refurbishmentLevelOptions = this.selectListService.GetRefurbishmentLevelOptions();\r\n this.planningOptions = this.selectListService.GetPlanningPermissionTypesOfBridging();\r\n } catch (e) {\r\n console.error(\"Error: \", e);\r\n }\r\n }\r\n\r\n getRequiredRoles(isCaseDashboard: boolean) {\r\n if (isCaseDashboard) return `['Admin', 'Client', 'Broker', 'Introducer']`;\r\n return `['Admin', 'Client', 'Broker', 'Introducer', 'Lender']`;\r\n }\r\n\r\n getBuildCosts() {\r\n var buildCosts =\r\n +this.dealDto.EstimatedSpending + +this.dealDto.PurchasePrice;\r\n if (isNaN(buildCosts) || buildCosts == undefined) {\r\n buildCosts = 0;\r\n }\r\n return buildCosts;\r\n }\r\n\r\n getProfitBeforeCosts() {\r\n this.profitBeforeCosts =\r\n this.dealDto.GDV -\r\n this.dealDto.PurchasePrice -\r\n this.dealDto.EstimatedSpending -\r\n this.dealDto.PurchaseCosts;\r\n if (isNaN(this.profitBeforeCosts)) {\r\n this.profitBeforeCosts = 0;\r\n }\r\n return this.profitBeforeCosts;\r\n }\r\n\r\n /* // updateGuidanceState() {\r\n // this.guidanceCheckbox =\r\n // this.$cookies.get(\"guidance\") === \"on\" ||\r\n // this.$cookies.get(\"guidance\") === undefined;\r\n // // Update tour settings\r\n // }\r\n \r\n // getGuidanceSwitchState() {\r\n // if (!this.$cookies.get(\"guidance\")) {\r\n // this.guidanceCheckbox = true;\r\n // } else if (this.$cookies.get(\"guidance\") === \"on\") {\r\n // this.guidanceCheckbox = true;\r\n // } else if (this.$cookies.get(\"guidance\") === \"off\") {\r\n // this.guidanceCheckbox = false;\r\n // } else {\r\n // this.guidanceCheckbox = true;\r\n // }\r\n // return this.guidanceCheckbox;\r\n // }\r\n \r\n // recordGuidanceCookie() {\r\n // var guidanceSwitchState: string;\r\n // var expiryDate = new Date();\r\n // expiryDate.setDate(expiryDate.getDate() + 365);\r\n // if (this.guidanceCheckbox == true) {\r\n // guidanceSwitchState = \"on\";\r\n // } else {\r\n // guidanceSwitchState = \"off\";\r\n // }\r\n // this.$cookies.put(\"guidance\", guidanceSwitchState, { expires: expiryDate });\r\n // this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n // }\r\n \r\n //getROCE() {\r\n // this.ROCE = (this.dealDto.GDV / this.totalCosts) * 100;\r\n // if (isNaN(this.ROCE)) {\r\n // this.ROCE = 0;\r\n // }\r\n // return this.ROCE.toFixed(2);\r\n //}\r\n \r\n //getPurchasePrice() {\r\n // this.purchasePrice = this.dealDto.PurchasePrice;\r\n // if (isNaN(this.purchasePrice)) {\r\n // this.purchasePrice = 0;\r\n // }\r\n // return this.purchasePrice;\r\n //}\r\n \r\n //getPurchaseCosts() {\r\n // this.purchaseCosts = this.dealDto.PurchaseCosts;\r\n // if (isNaN(this.purchaseCosts)) {\r\n // this.purchaseCosts = 0;\r\n // }\r\n // return this.purchaseCosts;\r\n //}\r\n \r\n //getGDV() {\r\n // if (isNaN(this.dealDto.GDV) || this.dealDto.GDV == undefined) {\r\n // this.dealDto.GDV = 0;\r\n // } else {\r\n // this.dealDto.GDV = this.dealDto.GDV;\r\n // }\r\n // return this.dealDto.GDV;\r\n //}\r\n */\r\n goToSearchResults() {\r\n this.hasError = false;\r\n this.error = null;\r\n this.isSubmitted = true;\r\n this.enterpriseService.setProductFamily(this.dealDto.ProductFamily);\r\n // If enterprise\r\n this.isSearchStarted = true;\r\n if (\r\n !this.isLoggedInUser &&\r\n this.isBorrower &&\r\n (this.$location.path().startsWith(\"/e/bridgingcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\"))\r\n ) {\r\n this.saveCriteriaReturnUniqueRef().then((response) => {\r\n if (!this.hasError) {\r\n this.sharedCriteriaService.setIsDataLoading(false);\r\n var response = response as SaveSearchReturnUniqueRefResponse;\r\n if (window.self == window.top)\r\n sessionStorage.removeItem(\"productType\");\r\n\r\n if (response.HasDealClient) {\r\n //The purpose of the route check is to ensure navigation to the correct route when the user lands on the criteria page by clicking 'Change Search' in the side panel.\r\n if (sessionStorage.getItem('previousRoute') == 'referredsearchdeal') {\r\n this.$location.path(`/referredsearchdeal/${response.DealClientUniqueRef}/false`);\r\n sessionStorage.removeItem('previousRoute');\r\n } else {\r\n this.$location.path(`/e/bridgingresults/${response.DealUniqueRef}`);\r\n }\r\n } else {\r\n var leadCaptureUrl = `/e/enterpriseleadcapture/${response.DealUniqueRef}`;\r\n leadCaptureUrl = this.isWidget ? `${leadCaptureUrl}/widget` : leadCaptureUrl;\r\n\r\n this.$location.path(leadCaptureUrl);\r\n }\r\n }\r\n });\r\n } else {\r\n this.saveCriteriaReturnId().then((response) => {\r\n if (!this.hasError) {\r\n var dealId = response as number;\r\n if (window.self == window.top)\r\n sessionStorage.removeItem(\"productType\");\r\n\r\n if (this.isAdmin || this.isBroker) this.dealService.setShowSearchNameAndUserSelectionModal(true);\r\n this.$location.path(\"/bridgingresults/\" + dealId);\r\n }\r\n });\r\n }\r\n }\r\n\r\n getTubeMapValue() {\r\n return this.caseService.getTubeMap();\r\n }\r\n\r\n getNumberOfLenders() {\r\n if (this.dealDto && this.dealDto.ProductType) {\r\n //TODO Bridging JS: replacing ProductTypeEnum.BridgingPreconstruction with this.productType assuming that preconstruction products will not apply to all product types.\r\n this.lenderService\r\n .getTotalLenders(ProductFamilyEnum.Bridging)\r\n .then((response: number) => {\r\n this.totalLenders = Math.floor(response);\r\n });\r\n } else {\r\n //TODO what should it default to?\r\n }\r\n }\r\n\r\n go(path: string): void {\r\n this.$location.path(path);\r\n }\r\n\r\n saveCriteriaReturnId(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.dataSetUpForSave();\r\n\r\n var clientDto = null;\r\n\r\n var request: SaveBridgingSearchRequest = {\r\n DealDto: this.dealDto,\r\n ShareDealDto: this.shareDealDto,\r\n OrgCode: this.isLoggedInUser ? \"\" : this.orgCode,\r\n ClientId:\r\n !this.isLoggedInUser &&\r\n this.clientId &&\r\n !this.user &&\r\n (this.$location.path().startsWith(\"/e/bridgingcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\"))\r\n ? Number(this.clientId)\r\n : 0,\r\n EnterpriseClientDto: clientDto,\r\n };\r\n\r\n this.bridgingDealService\r\n .saveBridgingSearchReturnsId(request)\r\n .then((response) => {\r\n this.dealDto.Id = response;\r\n this.isSaving = false;\r\n\r\n defer.resolve(response as number);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n if (response.status === 500) {\r\n this.error = response.data.message;\r\n } else {\r\n this.error = 'Something went wrong while searching for loans. Please try again.';\r\n }\r\n this.hasError = true;\r\n this.isSearchStarted = false;\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n saveCriteriaReturnUniqueRef(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.sharedCriteriaService.setIsDataLoading(true);\r\n this.dataSetUpForSave();\r\n\r\n var clientDto = null;\r\n\r\n var request: SaveBridgingSearchRequest = {\r\n DealDto: this.dealDto,\r\n ShareDealDto: this.shareDealDto,\r\n OrgCode: this.isLoggedInUser ? \"\" : this.orgCode,\r\n ClientId: !this.isWidget &&\r\n !this.isLoggedInUser &&\r\n this.clientId &&\r\n !this.user &&\r\n (this.$location.path().startsWith(\"/e/bridgingcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\"))\r\n ? Number(this.clientId)\r\n : 0,\r\n EnterpriseClientDto: clientDto,\r\n };\r\n\r\n this.bridgingDealService\r\n .saveBridgingSearchReturnsUniqueRef(request)\r\n .then((response) => {\r\n this.dealDto.UniqueRef = response.DealUniqueRef;\r\n this.isSaving = false;\r\n\r\n defer.resolve(response as SaveSearchReturnUniqueRefResponse);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n this.sharedCriteriaService.setIsDataLoading(false);\r\n if (response.status === 500) {\r\n this.error = response.data.message;\r\n } else {\r\n this.error = 'Something went wrong while searching for loans. Please try again.';\r\n }\r\n this.hasError = true;\r\n this.isSearchStarted = false;\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n dataSetUpForSave() {\r\n this.sharedCriteriaService.setNewSearch(this.dealDto, this.snapshotDealDto);\r\n\r\n if (this.dealDto.Id == null) {\r\n this.dealDto.Status = CaseStatusEnum.Search;\r\n }\r\n\r\n if (\r\n this.dealDto.Name == null ||\r\n this.dealDto.Name == \"\" ||\r\n this.dealDto.Name == undefined\r\n ) {\r\n this.dealDto.Name = this.sharedCriteriaService.defaultSearchName(\r\n this.dealDto.ProductType,\r\n this.dealDto.HasIsFamilyInResidence &&\r\n (this.dealDto.ProductType ==\r\n ProductTypeEnum.BridgingPurchaseOrRefinance ||\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingRefurb),\r\n );\r\n }\r\n\r\n if (\r\n !this.isLoggedInUser &&\r\n (this.$location.path().startsWith(\"/e/bridgingcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\")) &&\r\n this.isBorrower\r\n ) {\r\n this.dealDto.HowManyFlats = this.dealDto.HowManyFlats\r\n ? this.dealDto.HowManyFlats\r\n : 0;\r\n this.dealDto.HowManyHouses = this.dealDto.HowManyHouses\r\n ? this.dealDto.HowManyHouses\r\n : 0;\r\n }\r\n\r\n if (!this.shareDealDto) {\r\n this.shareDealDto = {\r\n DealName: this.sharedCriteriaService.defaultSearchName(\r\n this.dealDto.ProductType,\r\n this.dealDto.HasIsFamilyInResidence &&\r\n (this.dealDto.ProductType ==\r\n ProductTypeEnum.BridgingPurchaseOrRefinance ||\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingRefurb),\r\n ),\r\n } as ShareDealDTO;\r\n }\r\n }\r\n\r\n getUsersBelongToBrokerOrAdmin() {\r\n this.userService\r\n .getUserSummariesForBrokerOrAdmin()\r\n .then((response) => {\r\n this.existingUsers = response;\r\n })\r\n .finally(() => { });\r\n }\r\n\r\n viewClientsDashboardForNewSearch(userName: string) {\r\n this.shareDealDto =\r\n this.sharedCriteriaService.attachSelectedClientToShareDealDto(\r\n this.existingUsers,\r\n this.shareDealDto,\r\n userName,\r\n );\r\n this.showClientDetails = true;\r\n }\r\n\r\n onClickOfNext() {\r\n this.showShareSearchtoClientModal = false;\r\n if (this.$location.path().startsWith(\"/allloans\") && (this.isAdmin || this.isBroker)) {\r\n this.dealService.setShowSearchNameAndUserSelectionModal(false);\r\n this.dealService.setClient(this.shareDealDto.ClientDto);\r\n this.dealService.setDealName(this.shareDealDto.DealName);\r\n }\r\n }\r\n\r\n OnClickOfSkip() {\r\n this.showShareSearchtoClientModal = false;\r\n if (this.$location.path().startsWith(\"/allloans\") && (this.isAdmin || this.isBroker)) {\r\n this.dealService.setShowSearchNameAndUserSelectionModal(false);\r\n }\r\n }\r\n\r\n gotoDashboard() {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n goToUserDashboard() {\r\n this.gotoDashboard();\r\n }\r\n\r\n searchDisabledPrecon() {\r\n\r\n var commonFields = [\r\n this.dealDto.OwnOrPurchase,\r\n this.dealDto.Locations,\r\n this.dealDto.IsFamilyInResidence,\r\n this.dealDto.LandOrProperty,\r\n ];\r\n\r\n if (this.progressSection == 1) {\r\n this.progressAmount = \"0%\";\r\n if (this.dealDto.LandOrProperty == LandOrPropertyEnum.Property)\r\n commonFields = [...commonFields, this.dealDto.EndPropertyType];\r\n\r\n if (this.dealDto.hasPostcode && !this.dealDto.PostcodeSearchString) {\r\n return true;\r\n }\r\n\r\n if (!this.dealDto.hasPostcode && !this.dealDto.Locations) {\r\n return true;\r\n }\r\n\r\n if (this.multiPartForm1 && this.multiPartForm1.$invalid) return true;\r\n\r\n if (\r\n this.dealDto.IsFamilyInResidence == 0 ||\r\n this.dealDto.IsFamilyInResidence == YesNoMaybe.Yes\r\n )\r\n return true;\r\n\r\n if (\r\n this.dealDto.PlanningPermissionType == null ||\r\n this.dealDto.PlanningPermissionType < 1\r\n ) {\r\n return true;\r\n }\r\n\r\n for (let i = 0; i < commonFields.length; i++) {\r\n if (commonFields[i] == null || commonFields[i] == \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n this.progressAmount = \"50%\";\r\n\r\n }\r\n\r\n if (this.progressSection == 2) {\r\n\r\n this.progressAmount = \"50%\";\r\n\r\n if (!this.dealService.showBasedOnMainResidence(this.dealDto) || this.hasValidNetLoanRequiredValue()) {\r\n return true;\r\n }\r\n\r\n commonFields = [\r\n ...commonFields,\r\n this.dealDto.PurchasePrice,\r\n this.dealDto.LoanTermReq,\r\n ];\r\n\r\n\r\n if (this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Own) {\r\n let commonOwnFields = [\r\n this.dealDto.OriginalPurchaseDate,\r\n this.dealDto.Currentvalue,\r\n this.dealDto.LandTotalOtherCosts\r\n ]\r\n for (let i = 0; i < commonOwnFields.length; i++) {\r\n if (commonOwnFields[i] == null) {\r\n return true;\r\n }\r\n }\r\n if (this.dealDto.LandOrProperty == LandOrPropertyEnum.Land && this.dealDto.OwnOrPurchase != OwnOrPurchaseEnum.Own) {\r\n let commonLandFields = [\r\n this.dealDto.PurchaseCosts,\r\n this.dealDto.EstimatedSpending\r\n ]\r\n for (let i = 0; i < commonLandFields.length; i++) {\r\n if (commonLandFields[i] == null) {\r\n return true;\r\n }\r\n }\r\n if (this.dealDto.IsMortgaged) {\r\n if (this.dealDto.MortgageCurrentLender == null || this.dealDto.MortgageCurrentLender == '') {\r\n return true;\r\n }\r\n }\r\n }\r\n else if (this.dealDto.OwnOrPurchase != OwnOrPurchaseEnum.Own) {\r\n let commonPropFields = [\r\n this.dealDto.EndPropertyType\r\n ]\r\n for (let i = 0; i < commonPropFields.length; i++) {\r\n if (commonPropFields[i] == null || commonPropFields[i] == '0') {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Purchasing) {\r\n let commonPurchFields = [\r\n this.dealDto.PurchaseCosts\r\n //this.dealDto.EstimatedSpending\r\n ]\r\n for (let i = 0; i < commonPurchFields.length; i++) {\r\n if (commonPurchFields[i] == null) {\r\n return true;\r\n }\r\n }\r\n if (this.dealDto.LandOrProperty == LandOrPropertyEnum.Property) {\r\n let commonPropFields = [\r\n this.dealDto.EndPropertyType\r\n ]\r\n for (let i = 0; i < commonPropFields.length; i++) {\r\n if (commonPropFields[i] == null || commonPropFields[i] == '0') {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n for (let i = 0; i < commonFields.length; i++) {\r\n if (commonFields[i] == null || commonFields[i] == \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n if (this.multiPartForm1 && this.multiPartForm1.$invalid) return true;\r\n\r\n this.progressAmount = \"100%\";\r\n }\r\n\r\n\r\n return false;\r\n }\r\n\r\n\r\n\r\n searchDisabledPurchaseOrRefinance() {\r\n this.progressAmount = \"50%\";\r\n\r\n let commonFields = [\r\n this.dealDto.OwnOrPurchase,\r\n this.dealDto.Locations,\r\n this.dealDto.IsFamilyInResidence,\r\n this.dealDto.LandOrProperty,\r\n this.dealDto.EndPropertyType,\r\n ];\r\n\r\n if (this.progressSection == 1) {\r\n this.progressAmount = \"0%\";\r\n\r\n if (this.dealDto.hasPostcode && !this.dealDto.PostcodeSearchString) {\r\n return true;\r\n }\r\n\r\n if (!this.dealDto.hasPostcode && !this.dealDto.Locations) {\r\n return true;\r\n }\r\n\r\n for (let i = 0; i < commonFields.length; i++) {\r\n if (commonFields[i] == null || commonFields[i] == \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n if (this.multiPartForm1 && this.multiPartForm1.$invalid) return true;\r\n\r\n this.progressAmount = \"50%\";\r\n\r\n }\r\n\r\n if (this.progressSection == 2) {\r\n this.progressAmount = \"50%\";\r\n if (!this.dealService.showBasedOnMainResidence(this.dealDto) || this.hasValidNetLoanRequiredValue()) {\r\n return true;\r\n }\r\n\r\n commonFields = [\r\n ...commonFields,\r\n this.dealDto.PurchasePrice,\r\n this.dealDto.LoanTermReq,\r\n ];\r\n\r\n if (this.dealDto.PurchaseCosts == null) {\r\n return true;\r\n }\r\n\r\n if (this.dealDto.IsPropertyImprovementDuringLoanTerm) {\r\n let commonImprovementFields = [\r\n this.dealDto.EstimatedSpending,\r\n this.dealDto.GDV,\r\n ];\r\n for (let i = 0; i < commonImprovementFields.length; i++) {\r\n if (commonImprovementFields[i] == null) {\r\n return true;\r\n }\r\n }\r\n }\r\n\r\n if (this.dealDto.IsMortgaged) {\r\n if (\r\n this.dealDto.MortgageCurrentLender == null ||\r\n this.dealDto.MortgageCurrentLender == \"\"\r\n ) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!this.dealDto.MaxLoanRequired) {\r\n if (this.dealDto.NetLoanRequired == null) {\r\n return true;\r\n }\r\n }\r\n\r\n for (let i = 0; i < commonFields.length; i++) {\r\n if (commonFields[i] == null || commonFields[i] == \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n if (this.multiPartForm1 && this.multiPartForm1.$invalid) return true;\r\n\r\n this.progressAmount = \"100%\";\r\n }\r\n\r\n }\r\n\r\n searchDisabledBridgingDeveloperExit() {\r\n var commonFields = [\r\n this.dealDto.Locations,\r\n this.dealDto.IsFamilyInResidence,\r\n this.dealDto.EndPropertyType,\r\n this.dealDto.RefinancedUnits,\r\n ];\r\n\r\n if (this.progressSection == 1) {\r\n this.progressAmount = \"0%\";\r\n\r\n if (this.dealDto.hasPostcode && !this.dealDto.PostcodeSearchString) {\r\n return true;\r\n }\r\n\r\n if (!this.dealDto.hasPostcode && !this.dealDto.Locations) {\r\n return true;\r\n }\r\n\r\n if (this.multiPartForm1 && this.multiPartForm1.$invalid) return true;\r\n\r\n if (\r\n this.dealDto.IsFamilyInResidence == 0 ||\r\n this.dealDto.IsFamilyInResidence == YesNoMaybe.Yes\r\n )\r\n return true;\r\n\r\n for (let i = 0; i < commonFields.length; i++) {\r\n if (commonFields[i] == null || commonFields[i] == \"0\") {\r\n return true;\r\n }\r\n }\r\n this.progressAmount = \"50%\";\r\n\r\n }\r\n\r\n if (this.progressSection == 2) {\r\n\r\n this.progressAmount = \"50%\";\r\n\r\n\r\n if (!this.dealService.showBasedOnMainResidence(this.dealDto) || this.hasValidNetLoanRequiredValue()) {\r\n return true;\r\n }\r\n commonFields = [\r\n ...commonFields,\r\n this.dealDto.Currentvalue,\r\n this.dealDto.LoanTermReq,\r\n ];\r\n\r\n if (!this.dealDto.MaxLoanRequired) {\r\n if (this.dealDto.NetLoanRequired == null) {\r\n return true;\r\n }\r\n }\r\n\r\n if (this.multiPartForm1 && this.multiPartForm1.$invalid) return true;\r\n\r\n for (let i = 0; i < commonFields.length; i++) {\r\n if (commonFields[i] == null || commonFields[i] == \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n this.progressAmount = \"100%\";\r\n\r\n }\r\n\r\n\r\n return false;\r\n }\r\n\r\n searchDisabledRefurb() {\r\n this.progressAmount = \"50%\";\r\n\r\n let commonFields = [\r\n this.dealDto.OwnOrPurchase,\r\n this.dealDto.Locations,\r\n this.dealDto.IsFamilyInResidence,\r\n this.dealDto.LandOrProperty,\r\n this.dealDto.EndPropertyType, // TODO - will \"Current use of building\" be a different property to this one???\r\n this.dealDto.PurchasePrice,\r\n this.dealDto.RefurbishmentLevel,\r\n ];\r\n\r\n if (this.progressSection == 1) {\r\n this.progressAmount = \"0%\";\r\n\r\n if (this.dealDto.hasPostcode && !this.dealDto.PostcodeSearchString) {\r\n return true;\r\n }\r\n\r\n if (!this.dealDto.hasPostcode && !this.dealDto.Locations) {\r\n return true;\r\n }\r\n\r\n if (this.multiPartForm1 && this.multiPartForm1.$invalid) return true;\r\n\r\n\r\n if (this.dealDto.LandOrProperty == LandOrPropertyEnum.Land) {\r\n return true;\r\n }\r\n\r\n if (this.dealDto.PurchaseCosts == null) {\r\n return true;\r\n }\r\n\r\n for (let i = 0; i < commonFields.length; i++) {\r\n if (commonFields[i] == null || commonFields[i] == \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n this.progressAmount = \"50%\";\r\n\r\n }\r\n\r\n ////TODO current value when owned\r\n ////TODO purchase price when not owned ??? all the time?\r\n\r\n if (this.progressSection == 2) {\r\n\r\n this.progressAmount = \"50%\";\r\n\r\n if (this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Own) {\r\n if (this.dealDto.Currentvalue == null) return true;\r\n if (this.dealDto.OriginalPurchaseDate == null) return true;\r\n }\r\n\r\n\r\n if (!this.dealService.showBasedOnMainResidence(this.dealDto) || this.hasValidNetLoanRequiredValue()) {\r\n return true;\r\n }\r\n\r\n commonFields = [\r\n ...commonFields,\r\n this.dealDto.BuildCosts,\r\n this.dealDto.LoanTermReq,\r\n this.dealDto.GDV,\r\n ];\r\n\r\n if (!this.dealDto.MaxLoanRequired) {\r\n if (this.dealDto.NetLoanRequired == null) {\r\n return true;\r\n }\r\n }\r\n\r\n if (this.multiPartForm1 && this.multiPartForm1.$invalid) return true;\r\n\r\n\r\n for (let i = 0; i < commonFields.length; i++) {\r\n if (commonFields[i] == null || commonFields[i] == \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n this.progressAmount = \"100%\";\r\n\r\n }\r\n\r\n\r\n return false;\r\n }\r\n\r\n searchDisabled() {\r\n switch (this.dealDto.ProductType) {\r\n case ProductTypeEnum.BridgingPreconstruction:\r\n return this.searchDisabledPrecon();\r\n case ProductTypeEnum.BridgingPurchaseOrRefinance:\r\n return this.searchDisabledPurchaseOrRefinance();\r\n case ProductTypeEnum.BridgingDeveloperExit:\r\n return this.searchDisabledBridgingDeveloperExit();\r\n case ProductTypeEnum.BridgingRefurb:\r\n return this.searchDisabledRefurb();\r\n default:\r\n return true;\r\n }\r\n }\r\n\r\n dummysearch() {\r\n let date = new Date();\r\n date.setDate(date.getDate() - 1);\r\n\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.No;\r\n this.dealDto.HasIsFamilyInResidence = false;\r\n\r\n this.dealDto.hasPostcode =\r\n this.sharedCriteriaService.getRandomIntInclusive(0, 1) == 1\r\n ? true\r\n : false;\r\n\r\n if (this.dealDto.hasPostcode) {\r\n this.dealDto.PostcodeSearchString =\r\n this.sharedCriteriaService.getRandomPostcode();\r\n this.getRegionByPostcode();\r\n } else {\r\n this.dealDto.Locations = LocationEnum.London;\r\n }\r\n\r\n this.dealDto.OwnOrPurchase = OwnOrPurchaseEnum.Own;\r\n this.dealDto.LandOrProperty =\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingRefurb\r\n ? LandOrPropertyEnum.Property\r\n : LandOrPropertyEnum.Land;\r\n\r\n //this.getPlanningOptions();\r\n this.dealDto.PlanningPermissionType =\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingPreconstruction\r\n ? PlanningPermissionTypeEnum.NoPlanning\r\n : PlanningPermissionTypeEnum.None;\r\n\r\n this.dealDto.LoanTermReq = this.sharedCriteriaService.getRandomIntInclusive(\r\n 6,\r\n 18,\r\n );\r\n this.dealDto.MaxLoanRequired =\r\n this.sharedCriteriaService.getRandomIntInclusive(0, 1) == 1\r\n ? true\r\n : false;\r\n\r\n switch (this.dealDto.ProductType) {\r\n case ProductTypeEnum.BridgingPreconstruction:\r\n this.dealDto.OriginalPurchaseDate = date;\r\n this.dealDto.LandTotalOtherCosts =\r\n this.sharedCriteriaService.getRandomIntInclusive(10000, 20000);\r\n this.dealDto.PurchasePrice =\r\n this.sharedCriteriaService.getRandomIntInclusive(5000000, 10000000);\r\n this.dealDto.Currentvalue =\r\n this.dealDto.PurchasePrice +\r\n this.sharedCriteriaService.getRandomIntInclusive(-2000000, 2000000);\r\n this.dealDto.NetLoanRequired = !this.dealDto.MaxLoanRequired\r\n ? this.dealDto.PurchasePrice +\r\n this.dealDto.PurchaseCosts +\r\n this.sharedCriteriaService.getRandomIntInclusive(100000, 4000000)\r\n : null;\r\n this.dealDto.PurchaseCosts =\r\n this.sharedCriteriaService.getRandomIntInclusive(100000, 1000000);\r\n break;\r\n\r\n case ProductTypeEnum.BridgingPurchaseOrRefinance:\r\n this.dealDto.HasLandOrProperty = true;\r\n this.onLandOrPropertyChange();\r\n this.dealDto.OriginalPurchaseDate = date;\r\n this.dealDto.LandTotalOtherCosts =\r\n this.sharedCriteriaService.getRandomIntInclusive(10000, 20000);\r\n this.dealDto.PurchasePrice =\r\n this.sharedCriteriaService.getRandomIntInclusive(5000000, 10000000);\r\n this.dealDto.Currentvalue =\r\n this.dealDto.PurchasePrice +\r\n this.sharedCriteriaService.getRandomIntInclusive(-2000000, 2000000);\r\n this.dealDto.NetLoanRequired = !this.dealDto.MaxLoanRequired\r\n ? this.dealDto.PurchasePrice +\r\n this.dealDto.PurchaseCosts +\r\n this.sharedCriteriaService.getRandomIntInclusive(100000, 4000000)\r\n : null;\r\n this.dealDto.PurchaseCosts =\r\n this.sharedCriteriaService.getRandomIntInclusive(100000, 1000000);\r\n break;\r\n\r\n case ProductTypeEnum.BridgingDeveloperExit:\r\n this.dealDto.RefinancedUnits =\r\n this.sharedCriteriaService.getRandomIntInclusive(1, 5);\r\n this.dealDto.LandOrProperty = LandOrPropertyEnum.Property;\r\n this.dealDto.Currentvalue =\r\n this.sharedCriteriaService.getRandomIntInclusive(1000000, 5000000);\r\n this.dealDto.NetLoanRequired =\r\n this.dealDto.Currentvalue +\r\n this.sharedCriteriaService.getRandomIntInclusive(-100000, 100000);\r\n break;\r\n case ProductTypeEnum.BridgingRefurb:\r\n this.dealDto.RefurbishmentLevel = RefurbishmentLevelEnum.Light;\r\n this.dealDto.BuildCosts =\r\n this.sharedCriteriaService.getRandomIntInclusive(100000, 1000000);\r\n this.dealDto.PurchasePrice =\r\n this.sharedCriteriaService.getRandomIntInclusive(5000000, 10000000);\r\n this.dealDto.OriginalPurchaseDate = date;\r\n this.dealDto.Currentvalue =\r\n this.dealDto.PurchasePrice +\r\n this.sharedCriteriaService.getRandomIntInclusive(-2000000, 2000000);\r\n this.dealDto.PurchaseCosts =\r\n this.sharedCriteriaService.getRandomIntInclusive(100000, 1000000);\r\n this.dealDto.GDV =\r\n this.dealDto.Currentvalue +\r\n this.sharedCriteriaService.getRandomIntInclusive(2000000, 4000000);\r\n this.dealDto.NetLoanRequired = !this.dealDto.MaxLoanRequired\r\n ? this.dealDto.PurchasePrice +\r\n this.dealDto.PurchaseCosts +\r\n this.sharedCriteriaService.getRandomIntInclusive(100000, 4000000)\r\n : null;\r\n }\r\n }\r\n\r\n debugSearch() {\r\n const stringJSON = JSON.stringify(this.dealDto);\r\n navigator.clipboard\r\n .writeText(stringJSON)\r\n .then()\r\n .catch((e) => console.log(e));\r\n }\r\n\r\n //Clears the previously selected existing client data on share search modal\r\n clearInputFields() {\r\n this.shareDealDto =\r\n this.sharedCriteriaService.clearExistingUserOnShareDealDto(\r\n this.shareDealDto,\r\n );\r\n this.showClientDetails = false;\r\n }\r\n\r\n // Setting the dependent data when option are changed\r\n clearSearchdata() {\r\n this.dealDto = this.bridgingDealService.clearSearchdata(this.dealDto);\r\n }\r\n\r\n isFieldEmpty(fieldName, isEnum = false) {\r\n if (this.isSubmitted && this.dealDto) {\r\n const fieldValue = this.dealDto[fieldName];\r\n if (fieldName == \"PlanningPermissionType\") {\r\n if (fieldValue == null || fieldValue < 1) {\r\n return true;\r\n }\r\n }\r\n if (fieldValue == null || (isEnum && fieldValue === \"0\")) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n isFieldZero(fieldName) {\r\n if (this.isSubmitted && this.dealDto) {\r\n const fieldValue = this.dealDto[fieldName];\r\n if (fieldValue == null || fieldValue === \"0\" || fieldValue === 0) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n datasetupOnOwnOrPurchaseChange() {\r\n this.dealDto = this.bridgingDealService.datasetupOnOwnOrPurchaseChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnLandorPropertyChange() {\r\n this.dealDto = this.bridgingDealService.datasetupOnLandorPropertyChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnInterestServiceChange() {\r\n this.dealDto = this.bridgingDealService.datasetupOnInterestServiceChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnIsTenantedBuildingChange() {\r\n this.dealDto = this.bridgingDealService.datasetupOnIsTenantedBuildingChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnEndPropertyTypeChange() {\r\n if (\r\n this.dealDto.EndPropertyType != PropertyTypeEnum.MixedUse &&\r\n this.dealDto.EndPropertyType != PropertyTypeEnum.Residential\r\n ) {\r\n this.classUses = {};\r\n }\r\n this.dealDto = this.bridgingDealService.datasetupOnEndPropertyTypeChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnHasCompletionDateChange() {\r\n this.dealDto = this.bridgingDealService.datasetupOnHasCompletionDateChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnMaxLoanRequiredChange() {\r\n this.dealDto = this.dealService.dataSetupOnMaxLoanRequiredChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n\r\n initClassUses() {\r\n let classUses: {} = {};\r\n for (let i = 1; i >= 0; i *= 2) {\r\n if (this.dealDto.ClassUses >= i) {\r\n //number is in enum sum, add it to object\r\n if (this.dealDto.ClassUses & i) {\r\n classUses[i] = true;\r\n }\r\n } else {\r\n this.classUses = classUses;\r\n\r\n //watch and update classuses\r\n this.$scope.$watchCollection(\"ctrl.classUses\", (newVal: {}) => {\r\n let valuesList = Object.keys(newVal);\r\n let total: number = 0;\r\n //tot up all the numeric keys (class use enums)\r\n valuesList.forEach((v, i) => {\r\n let keyToNum = Number(v);\r\n if (newVal[keyToNum]) {\r\n total += keyToNum;\r\n }\r\n });\r\n this.dealDto.ClassUses = total;\r\n });\r\n\r\n return;\r\n }\r\n }\r\n }\r\n\r\n onPurchaseDateChange() {\r\n this.minCompletionDate = this.dealDto.OriginalPurchaseDate;\r\n }\r\n\r\n\r\n getProductRoute(): string {\r\n switch (this.dealDto.ProductType) {\r\n case ProductTypeEnum.BridgingPreconstruction:\r\n return \"\";\r\n case ProductTypeEnum.BridgingPurchaseOrRefinance:\r\n return \"/PurchaseRefinance\";\r\n case ProductTypeEnum.BridgingDeveloperExit:\r\n return \"/DeveloperExit\";\r\n case ProductTypeEnum.BridgingRefurb:\r\n return \"/Refurbishment\";\r\n default:\r\n return \"\";\r\n }\r\n }\r\n\r\n bridgingTypeChanged(productType: ProductTypeEnum) {\r\n this.progressSection = 1;\r\n this.dealDto = {} as BridgingDealDTO;\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.getOriginatorInfoForUser();\r\n } else {\r\n this.getOriginatorInfoForAnonymousUsers();\r\n }\r\n this.dealDto.MaxLoanRequired = true;\r\n this.dealDto.ProductType = productType;\r\n this.dealDto.ProductFamily = ProductFamilyEnum.Bridging;\r\n this.getLoanInfoText();\r\n this.dealDto.HasIsFamilyInResidence = false;\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.No;\r\n this.dealDto.HasOwnOrPurchase = false;\r\n this.dealDto.OwnOrPurchase = OwnOrPurchaseEnum.Purchasing;\r\n this.dealDto.LandOrProperty =\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingPreconstruction\r\n ? LandOrPropertyEnum.Land\r\n : LandOrPropertyEnum.Property;\r\n this.dealDto.HasLandOrProperty =\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingPurchaseOrRefinance ||\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingRefurb\r\n ? true\r\n : false;\r\n //this.getPlanningOptions();\r\n this.dealDto.PlanningPermissionType =\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingPreconstruction\r\n ? PlanningPermissionTypeEnum.DetailedPlanning\r\n : PlanningPermissionTypeEnum.None;\r\n this.dealDto.LoanCompletionType =\r\n LoanCompletionTypeEnum.JustCheckingMyOptions;\r\n this.dealDto.RefurbishmentLevel =\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingRefurb\r\n ? RefurbishmentLevelEnum.Light\r\n : null;\r\n this.dealDto.ShowLenderInfoBrokerOverride = true;\r\n this.dealDto.hasPostcode = true;\r\n this.hasPurchasecostChanged = false;\r\n this.hasLandcostChanged = false;\r\n if (\r\n this.$location.path().startsWith(\"/e/bridgingcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\")\r\n ) {\r\n if (this.$routeParams.linkId && this.$routeParams.linkId != \"0\") {\r\n this.dealDto.OrganisationLinkId = this.$routeParams.linkId;\r\n }\r\n\r\n this.logEvent(\"BRIDGINGCRITERIA-PAGE1\");\r\n }\r\n }\r\n\r\n async getOriginatorInfoForUser() {\r\n if (this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Admin;\r\n this.dealDto.SourceType = DealSourceTypeEnum.Application;\r\n } else if (this.isBroker && !this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Broker;\r\n } else if (this.isBorrower && !this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Borrower;\r\n } else if (this.isLender && !this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Lender;\r\n this.dealDto.SourceType = DealSourceTypeEnum.Application;\r\n }\r\n\r\n if (window.self == window.top) {\r\n\r\n if (this.isLender) {\r\n this.userService.getCurrentUserLender().then((response) => {\r\n this.dealDto.OriginatorLenderId = response;\r\n });\r\n }\r\n\r\n if (this.isBroker || this.isBorrower) {\r\n this.organisationService.getOrganisation().then((org) => {\r\n if (org != null) {\r\n if (org.Id != 0) this.dealDto.OriginatorOrganisationId = org.Id;\r\n this.dealDto.SourceType = org.IsWhiteLabelled\r\n ? DealSourceTypeEnum.WhitelabelApplication\r\n : DealSourceTypeEnum.Application;\r\n }\r\n });\r\n }\r\n\r\n\r\n }\r\n }\r\n\r\n getOriginatorInfoForAnonymousUsers() {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Borrower;\r\n\r\n if (window.self == window.top) {\r\n this.dealDto.SourceType = DealSourceTypeEnum.Enterprise;\r\n } else {\r\n this.dealDto.SourceType = this.isWidget ? DealSourceTypeEnum.WidgetEnterprise : DealSourceTypeEnum.IFrameEnterprise;\r\n }\r\n\r\n if (this.$routeParams.linkId) {\r\n if (window.self == window.top) {\r\n this.dealDto.SourceType = DealSourceTypeEnum.UniqueLink;\r\n } else {\r\n this.dealDto.SourceType = this.isWidget ? this.$routeParams.linkId == \"0\"? DealSourceTypeEnum.WidgetEnterprise: DealSourceTypeEnum.WidgetUniqueLink : DealSourceTypeEnum.IFrameUniqueLink;\r\n }\r\n }\r\n }\r\n\r\n calculatePurchaseOrLandCost() {\r\n if (this.dealDto.ProductType == ProductTypeEnum.BridgingPreconstruction) {\r\n if (this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Own) {\r\n if (this.dealDto.PurchasePrice && !this.hasLandcostChanged) {\r\n this.dealDto.LandTotalOtherCosts =\r\n (this.dealDto.PurchasePrice * 5) / 100;\r\n }\r\n } else if (this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Purchasing) {\r\n if (this.dealDto.PurchasePrice && !this.hasPurchasecostChanged) {\r\n this.dealDto.PurchaseCosts = (this.dealDto.PurchasePrice * 5) / 100;\r\n }\r\n }\r\n } else if (\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingPurchaseOrRefinance ||\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingRefurb\r\n ) {\r\n if (this.dealDto.PurchasePrice && !this.hasPurchasecostChanged) {\r\n this.dealDto.PurchaseCosts = (this.dealDto.PurchasePrice * 5) / 100;\r\n }\r\n }\r\n }\r\n\r\n onPurchaseCostChange() {\r\n var purchaseCost = (this.dealDto.PurchasePrice * 5) / 100;\r\n if (this.dealDto.PurchaseCosts != purchaseCost) {\r\n this.hasPurchasecostChanged = true;\r\n }\r\n }\r\n\r\n onLandCostChange() {\r\n var landCost = (this.dealDto.PurchasePrice * 5) / 100;\r\n if (this.dealDto.PurchaseCosts != landCost) {\r\n this.hasLandcostChanged = true;\r\n }\r\n }\r\n\r\n onOwnOrPurchaseChange(OwnOrPurchase: boolean) {\r\n this.dealDto.OwnOrPurchase = this.dealDto.HasOwnOrPurchase\r\n ? OwnOrPurchaseEnum.Own\r\n : OwnOrPurchaseEnum.Purchasing;\r\n //this.getPlanningOptions();\r\n this.datasetupOnOwnOrPurchaseChange();\r\n }\r\n\r\n onLandOrPropertyChange() {\r\n this.dealDto.LandOrProperty = this.dealDto.HasLandOrProperty\r\n ? LandOrPropertyEnum.Property\r\n : LandOrPropertyEnum.Land;\r\n //this.getPlanningOptions();\r\n this.datasetupOnLandorPropertyChange();\r\n }\r\n\r\n onIsFamilyInResidenceChange() {\r\n this.dealDto.IsFamilyInResidence = this.dealDto.HasIsFamilyInResidence\r\n ? YesNoMaybe.Yes\r\n : YesNoMaybe.No;\r\n }\r\n\r\n initialDataSetupForIsFamilyInResidence() {\r\n if (this.dealDto.HasIsFamilyInResidence) {\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.Yes;\r\n this.dealDto.HasIsFamilyInResidence = true;\r\n } else {\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.No;\r\n this.dealDto.HasIsFamilyInResidence = false;\r\n }\r\n }\r\n\r\n goToLoanTypeSelectionPage() {\r\n if (this.isLoggedInUser) {\r\n this.$auth.setHasValidStatustoShowShareSearchModal(\r\n true,\r\n );\r\n }\r\n\r\n this.$location.path(\"/allloans\");\r\n\r\n }\r\n\r\n goToDevFinanceCriteria() {\r\n if (this.$location.path().startsWith(\"/allloans\")) {\r\n this.$scope.$emit(\"productFamilySelection\", 1);\r\n }\r\n else if (this.isLoggedInUser) {\r\n this.$location.path(\"/devfinancecriteria\");\r\n } else {\r\n this.$location.path(\"/e/devfinancecriteria\");\r\n }\r\n }\r\n\r\n calculateMonthsSinceOrigPurchase() {\r\n let date1 = new Date(this.dealDto.OriginalPurchaseDate);\r\n let date2 = new Date();\r\n let months;\r\n months = (date2.getFullYear() - date1.getFullYear()) * 12;\r\n months -= date1.getMonth();\r\n months += date2.getMonth();\r\n return months;\r\n }\r\n\r\n async logEvent(identifier: string) {\r\n var orgCode;\r\n if (window.self == window.top) {\r\n if (sessionStorage.getItem(\"clientId\")) {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto?.OrganisationLinkId,\r\n this.dealDto.ProductType,\r\n \"\",\r\n this.dealDto.Id,\r\n sessionStorage.getItem(\"clientId\"),\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto?.OrganisationLinkId,\r\n this.dealDto.ProductType,\r\n );\r\n }\r\n } else {\r\n var clientId: string = null;\r\n clientId = await this.organisationService.getData(\"clientId\");\r\n if (clientId) {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto.OrganisationLinkId,\r\n this.dealDto.ProductType,\r\n \"\",\r\n this.dealDto.Id,\r\n clientId,\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto.OrganisationLinkId,\r\n this.dealDto.ProductType,\r\n );\r\n }\r\n }\r\n }\r\n\r\n\r\n calcContingencyAmount() {\r\n if (this.dealDto.Contingency && this.dealDto.BuildCosts) {\r\n this.contingencyAmount =\r\n this.dealDto.Contingency * this.dealDto.BuildCosts;\r\n } else {\r\n this.contingencyAmount = null;\r\n }\r\n }\r\n\r\n hasValidNetLoanRequiredValue() {\r\n if (\r\n !this.dealDto.MaxLoanRequired &&\r\n (this.dealDto.NetLoanRequired == null ||\r\n isNaN(this.dealDto.NetLoanRequired) ||\r\n this.dealDto.NetLoanRequired <= 0)\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n /*getRegionByPostcode() {\r\n if (this.dealDto.PostcodeSearchString && this.dealDto.PostcodeSearchString.replace(\" \", \"\").length >= 2) {\r\n if (this.dealService.isValidPostcodeString(this.dealDto.PostcodeSearchString)) {\r\n this.dataLoading = true;\r\n this.dealService.getRegionByPostcode(this.dealDto.PostcodeSearchString).then((response) => {\r\n if (response.Location != null) {\r\n this.dealDto.Locations = response.Location;\r\n this.showPostcodeErrorMessage = false;\r\n } else {\r\n this.postcodeErrorMsg = response.PostCodeErrorMessage;\r\n this.showPostcodeErrorMessage = true;\r\n if (this.dealDto.Locations) this.dealDto.Locations = null;\r\n }\r\n }).finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.postcodeErrorMsg = \"At least one letter and one number must be entered e.g. SW1.\";\r\n this.showPostcodeErrorMessage = true;\r\n if (this.dealDto.Locations) this.dealDto.Locations = null;\r\n }\r\n } else {\r\n if (this.dealDto.Locations) this.dealDto.Locations = null;\r\n }\r\n }*/\r\n\r\n showBasedOnMainResidence() {\r\n return this.dealService.showBasedOnMainResidence(this.dealDto);\r\n }\r\n\r\n\r\n getLoanInfoText() {\r\n switch (this.dealDto.ProductType) {\r\n case ProductTypeEnum.BridgingDeveloperExit:\r\n this.loanInfoText =\r\n \"For properties that are at practical completion, but need more time to sell or refinance\";\r\n break;\r\n case ProductTypeEnum.BridgingPurchaseOrRefinance:\r\n this.loanInfoText =\r\n \"Loans against the property value only. Any improvement works need to be self-funded\";\r\n break;\r\n case ProductTypeEnum.BridgingRefurb:\r\n this.loanInfoText =\r\n \"Loans available against the property and the refurbishment works.\";\r\n break;\r\n case ProductTypeEnum.BridgingPreconstruction:\r\n this.loanInfoText =\r\n \"Loans for gaining planning or to amend existing planning\";\r\n break;\r\n default:\r\n this.loanInfoText = \"\";\r\n break;\r\n }\r\n }\r\n\r\n clickNextButton() {\r\n if (!this.isLoggedInUser && (this.$location.path().startsWith(\"/e/bridgingcriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n this.logEvent(\"BRIDGINGCRITERIA-PAGE2\");\r\n }\r\n this.progressSection = 2;\r\n this.progressAmount = \"50%\";\r\n }\r\n\r\n clickBackButton() {\r\n if (!this.isLoggedInUser && (this.$location.path().startsWith(\"/e/bridgingcriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n this.logEvent(\"BRIDGINGCRITERIA-PAGE1\");\r\n }\r\n this.progressSection = 1;\r\n }\r\n\r\n async logEventWithoutDealData() {\r\n if (window.self == window.top) {\r\n if (sessionStorage.getItem(\"clientId\")) {\r\n this.eventLogService.logPageLoad(\r\n \"BRIDGINGCRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.Bridging,\r\n \"\",\r\n 0,\r\n sessionStorage.getItem(\"clientId\"),\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n \"BRIDGINGCRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.Bridging,\r\n );\r\n }\r\n } else {\r\n var clientId: string = null;\r\n clientId = await this.organisationService.getData(\"clientId\");\r\n\r\n if (clientId) {\r\n this.eventLogService.logPageLoad(\r\n \"BRIDGINGCRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.Bridging,\r\n \"\",\r\n 0,\r\n clientId,\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n \"BRIDGINGCRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.Bridging,\r\n );\r\n }\r\n }\r\n }\r\n\r\n postRetrieveProcessing(response) {\r\n this.dealDto = { ...response };\r\n this.getLoanInfoText();\r\n this.snapshotDealDto = { ...response };\r\n this.isFamilyInResidence =\r\n this.dealDto.IsFamilyInResidence == YesNoMaybe.Yes ? true : false;\r\n this.ownOrPurchase =\r\n this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Own\r\n ? true\r\n : false;\r\n this.landOrProperty =\r\n this.dealDto.LandOrProperty == LandOrPropertyEnum.Property\r\n ? true\r\n : false;\r\n //this.initClassUses();\r\n this.calcContingencyAmount();\r\n }\r\n\r\n getRequiredRolesOptions(){\r\n return this.dealService.getRequiredRolesOptions();\r\n }\r\n}\r\n","export const enum LoanRepaymentTypeEnum {\r\n None = 0,\r\n InterestOnly = 1,\r\n Repayment = 2,\r\n}\r\n","import { CriteriaController } from \"@js/controllers/CriteriaController\";\r\nimport { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { CommercialDealDTO } from \"@js/DTO/Deal/CommercialDealDTO.cs.d\";\r\nimport { ShareDealDTO } from \"@js/DTO/Deal/SearchDealDTO.cs.d\";\r\nimport { SaveCommercialSearchRequest } from \"@js/DTO/Messages/Deal/SaveCommercialSearchMessage.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { DealSourceTypeEnum } from \"@js/models/enum/DealSourceTypeEnum.cs.d\";\r\nimport { LinkTypeEnum } from \"@js/models/enum/LinkTypeEnum.cs.d\";\r\nimport { LoanRepaymentTypeEnum } from \"@js/models/enum/LoanRepaymentTypeEnum.cs.d\";\r\nimport { LocationEnum } from \"@js/models/enum/LocationEnum.cs.d\";\r\nimport { OriginatorRoleTypeEnum } from \"@js/models/enum/OriginatorRoleTypeEnum.cs.d\";\r\nimport { OwnOrPurchaseEnum } from \"@js/models/enum/OwnOrPurchaseEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { YesNoMaybe } from \"@js/models/enum/YesNoMaybeEnum.cs.d\";\r\nimport { SaveSearchReturnUniqueRefResponse } from \"@js/models/SaveSearchReturnUniqueRef.cs\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CommercialDealService } from \"@js/services/Deal/CommercialDealService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { SharedCriteriaService } from \"@js/services/Deal/SharedCriteriaService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { OrganisationLinkService } from \"@js/services/OrganisationLinkService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { EnterpriseService } from \"@js/services/EnterpriseService\";\r\nimport { UserRoleEnum } from \"@js/models/enum/UserRoleEnum.cs.d\";\r\n\r\nexport class CommercialCriteriaController extends CriteriaController {\r\n dealDto: CommercialDealDTO;\r\n tempDealDto: CommercialDealDTO;\r\n snapshotDealDto: CommercialDealDTO;\r\n productType: ProductTypeEnum;\r\n\r\n maxPurchaseDate: Date = new Date();\r\n minPurchaseDate: Date = new Date(\"Jan 01 1900\");\r\n isLoggedInUser: boolean = false;\r\n // dataLoading: boolean = false;\r\n isSearchStarted: boolean = false;\r\n hasError: boolean = false;\r\n mortgageTerm: number = 0;\r\n\r\n multiPartForm1: ng.IFormController;\r\n\r\n //Share a search modal\r\n showShareSearchtoClientModal: boolean = false;\r\n existingUsers: UserSimpleDTO[];\r\n existingborrower: boolean;\r\n\r\n //Message to show when Enterprise url does not have valid lead gen license status or whitelabel add on is not paid or whitelabel setting is not on.\r\n noPermissionErrorMsg: string = \"\";\r\n\r\n //Enterprise user clientId\r\n clientId: string = null;\r\n enterpriseUser: ApplicationUserDTO = null;\r\n\r\n currentUseofBuildingOptions = [];\r\n locationOptions = [];\r\n borrowingEntityTypeOptions = [];\r\n\r\n hasPurchasecostChanged: boolean = false;\r\n\r\n guidanceCheckbox: boolean = true;\r\n shareDealDto: ShareDealDTO = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n //shows the selected existing client data on share modal\r\n showClientDetails: boolean = false;\r\n\r\n isDeal: boolean = true;\r\n\r\n isBorrower: boolean = false;\r\n organisation: OrganisationDTO;\r\n moveContactBrokerBtnInMiddle: boolean = false;\r\n initialRegistrationClient: ClientDTO;\r\n orgCode: string;\r\n\r\n //Postcode properties\r\n //showPostcodeErrorMessage: boolean = false;\r\n //postcodeErrorMsg: string;\r\n //previouslySelectedLocation: LocationEnum;\r\n\r\n isAdmin: boolean = false;\r\n isBroker: boolean = false;\r\n isLender: boolean = false;\r\n\r\n isCommercialOwnerOccupiedActive: boolean = false;\r\n showAutofill: boolean = false;\r\n isSubmitted: boolean = false;\r\n\r\n //enterprise widget journey\r\n isMobileView: boolean = false;\r\n enterpriseLinkLogo: string;\r\n showHelpModal: boolean = false;\r\n loanInfoText: string;\r\n progressAmount: string = \"50%\";\r\n progressSection: number = 1;\r\n totalSections: number = 3;\r\n loanRepaymentTypeOptions = [];\r\n fixedrateTermOptions = [];\r\n loanCompletionTypeOptions = [];\r\n productTypeOptions = [];\r\n timeLeftOnLeaseOptions = [];\r\n\r\n isWidget: boolean = false;\r\n //This propert is used to show only postcode ot location field on critera for mobile view\r\n isCriteria: boolean = true;\r\n\r\n error: string;\r\n showAdjustedAnnualEBITDAHelpertext: boolean = false;\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$q\",\r\n \"UserService\",\r\n \"RoleService\",\r\n \"OrganisationService\",\r\n \"SelectListService\",\r\n \"DevelopmentInputService\",\r\n \"CommercialDealService\",\r\n \"SharedCriteriaService\",\r\n \"EventLogService\",\r\n \"AuthService\",\r\n \"OrganisationLinkService\",\r\n \"DealService\",\r\n \"EnterpriseService\"\r\n ].concat(CriteriaController.$inject);\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n protected $q: ng.IQService,\r\n private userService: UserService,\r\n private roleService: RoleService,\r\n private organisationService: OrganisationService,\r\n private selectListService: SelectListService,\r\n private $DevelopmentInputservice: DevelopmentInputService,\r\n private commercialDealService: CommercialDealService,\r\n private sharedCriteriaService: SharedCriteriaService,\r\n private eventLogService: EventLogService,\r\n private $auth: AuthService,\r\n private organisationLinkService: OrganisationLinkService,\r\n dealService: DealService,\r\n private enterpriseService: EnterpriseService\r\n ) {\r\n super(dealService);\r\n try {\r\n\r\n if (this.$routeParams.context == 'widget' && window.self != window.top) {\r\n this.isWidget = true;\r\n } else {\r\n if (window.innerWidth <= 480)\r\n this.isMobileView = true\r\n }\r\n\r\n\r\n this.$auth.isCommercialOwnerOccupiedActive().then((response) => {\r\n this.isCommercialOwnerOccupiedActive = response;\r\n });\r\n\r\n //Initial data setup for a commercial deal\r\n if (this.dealDto == null) {\r\n this.dealDto = {} as CommercialDealDTO;\r\n }\r\n\r\n //Enteprise journey code\r\n if (!$cookies.get(\"access_token\") &&\r\n (this.$location.path().startsWith(\"/e/commercialcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\"))\r\n ) {\r\n this.isBorrower = true;\r\n if (this.$location.path().startsWith(\"/e/commercialcriteria\")) {\r\n var imgs = document.getElementsByTagName(\"img\");\r\n this.enterpriseLinkLogo = imgs[0].src;\r\n this.sharedCriteriaService.storeEnterpriseLinkType(LinkTypeEnum.Commercial.toString());\r\n }\r\n\r\n if (this.isWidget) {\r\n //document.getElementById(\"footer\").style.display = \"none\";\r\n this.organisationService.sendDataToParent(\"height\", \"745px\");\r\n }\r\n\r\n if (!this.$routeParams.DealUniqueRef) {\r\n\r\n if (window.self == window.top) {\r\n this.orgCode = this.$cookies.get(\"org_code\");\r\n sessionStorage.setItem(\"userRole\", UserRoleEnum.Client.toString());\r\n } else {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n this.organisationService.sendDataToParent(\"userRole\", UserRoleEnum.Client.toString());\r\n }\r\n\r\n this.logEventWithoutDealData();\r\n }\r\n\r\n this.organisationService\r\n .getOrgByUrlIfOrgHasEnterpriseSearchPermission(\r\n this.orgCode,\r\n ProductFamilyEnum.Commercial,\r\n this.$routeParams.linkId,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n this.organisation = response;\r\n this.orgCode = response.OrganisationCode;\r\n if (this.$routeParams.linkId) {\r\n if (this.$location.path().startsWith(\"/e/commercialcriteria\")) {\r\n this.organisationLinkService\r\n .getOrganisationLinkLogoByLinkIdAndLogPageLoadEvent(\r\n this.$routeParams.linkId\r\n )\r\n .then((logoUrl) => {\r\n if (logoUrl) this.enterpriseLinkLogo = imgs[0].src = logoUrl;\r\n });\r\n }\r\n }\r\n\r\n } else {\r\n this.logEvent(\"COMMERCIALCRITERIA-NO-PERMISSION-TO-SEARCH\");\r\n this.noPermissionErrorMsg =\r\n \"We are unable to compare loans right now. Please contact your broker.\";\r\n }\r\n });\r\n }\r\n\r\n if (window.self == window.top && $cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n\r\n this.userService.getUserAutofill().then((response) => {\r\n this.showAutofill = response;\r\n });\r\n\r\n this.roleService.GetUserRoles().then((result) => {\r\n if (result.filter((x) => x.toLowerCase() == \"admin\").length > 0) {\r\n this.isAdmin = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"broker\").length > 0) {\r\n this.isBroker = true;\r\n if (!this.isAdmin)\r\n //This block is to navigate a broker to userdashboard when they do not have a license.\r\n if (this.isBroker) {\r\n if (sessionStorage.getItem(\"isValidLicense\") == \"false\") {\r\n this.gotoDashboard();\r\n }\r\n }\r\n }\r\n if (\r\n result.filter((x) => x.toLowerCase() == \"lender\").length > 0 &&\r\n !this.isAdmin\r\n ) {\r\n this.isLender = true;\r\n }\r\n\r\n if (\r\n result.filter((x) => x.toLowerCase() == \"client\").length > 0 &&\r\n !this.isAdmin\r\n ) {\r\n this.isBorrower = true;\r\n }\r\n }).finally(() => {\r\n if (\r\n this.$auth.getHasValidStatustoShowShareSearchModal()\r\n ) {\r\n if (sessionStorage.getItem(\"skip\")) {\r\n //This will hide's a share search to client modal\r\n this.showShareSearchtoClientModal = false;\r\n } else {\r\n //getting a previously entered DealName and Client data \r\n if (this.dealService.getShowSearchNameAndUserSelectionModal()) {\r\n this.showShareSearchtoClientModal = true;\r\n this.getUsersBelongToBrokerOrAdmin();\r\n } else {\r\n this.shareDealDto.ClientDto = this.dealService.getClient();\r\n this.shareDealDto.DealName = this.dealService.getDealName();\r\n }\r\n }\r\n }\r\n this.getOriginatorInfoForUser();\r\n });\r\n } else {\r\n if (!this.$routeParams.DealUniqueRef) {\r\n if (window.self == window.top) {\r\n this.clientId = sessionStorage.getItem(\"clientId\");\r\n } else {\r\n Promise.all([\r\n this.organisationService.getData(\"clientId\").then((clientId) => {\r\n if (clientId) {\r\n this.clientId = clientId;\r\n }\r\n }),\r\n ]);\r\n }\r\n }\r\n }\r\n\r\n if (this.$routeParams.DealUniqueRef && this.$routeParams.DealUniqueRef != '0') {\r\n this.dataLoading = true;\r\n this.dealService\r\n .fetchByUniqueRef(this.$routeParams.DealUniqueRef)\r\n .then((response) => {\r\n this.postRetrieveProcessing(response);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n else if (this.$routeParams.SearchId > 0) {\r\n this.dataLoading = true;\r\n this.commercialDealService\r\n .fetch(this.$routeParams.SearchId)\r\n .then((response) => {\r\n this.postRetrieveProcessing(response)\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.dealDto.MaxLoanRequired = true;\r\n this.dealDto.ShowLenderInfoBrokerOverride = true;\r\n this.commercialTypeChanged(ProductTypeEnum.CommercialInvestment);\r\n }\r\n\r\n if (window.self == window.top) {\r\n this.updateGuidanceState();\r\n\r\n $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n this.updateGuidanceState();\r\n });\r\n }\r\n\r\n this.locationOptions = this.selectListService.GetLocations();\r\n this.borrowingEntityTypeOptions =\r\n this.selectListService.GetBorrowingEntityTypeOptions(\r\n ProductTypeEnum.CommercialOwnerOccupied,\r\n );\r\n //iFrame agent\r\n this.loanRepaymentTypeOptions =\r\n this.selectListService.GetLoanRepaymentTypeOptions();\r\n this.fixedrateTermOptions =\r\n this.selectListService.GetFixedRateTermOptions();\r\n this.loanCompletionTypeOptions =\r\n this.selectListService.GetLoanCompletionOptions();\r\n this.productTypeOptions = this.selectListService.GetInterestRateType();\r\n this.timeLeftOnLeaseOptions =\r\n this.selectListService.GetTimeLeftOnLeaseOptions();\r\n } catch (e) {\r\n console.error(\"Error: \", e);\r\n }\r\n }\r\n\r\n getRequiredRoles(isCaseDashboard: boolean) {\r\n if (isCaseDashboard) return `['Admin', 'Client', 'Broker', 'Introducer']`;\r\n return `['Admin', 'Client', 'Broker', 'Introducer', 'Lender']`;\r\n }\r\n\r\n updateGuidanceState() {\r\n this.guidanceCheckbox =\r\n this.$cookies.get(\"guidance\") === \"on\" ||\r\n this.$cookies.get(\"guidance\") === undefined;\r\n }\r\n\r\n // Start of Share a modal functions\r\n viewClientsDashboardForNewSearch(userName: string) {\r\n this.shareDealDto =\r\n this.sharedCriteriaService.attachSelectedClientToShareDealDto(\r\n this.existingUsers,\r\n this.shareDealDto,\r\n userName,\r\n );\r\n this.showClientDetails = true;\r\n }\r\n\r\n //Clears the previously selected existing client data on share search modal\r\n clearInputFields() {\r\n this.shareDealDto =\r\n this.sharedCriteriaService.clearExistingUserOnShareDealDto(\r\n this.shareDealDto,\r\n );\r\n this.showClientDetails = false;\r\n }\r\n\r\n getUsersBelongToBrokerOrAdmin() {\r\n this.userService\r\n .getUserSummariesForBrokerOrAdmin()\r\n .then((response) => {\r\n this.existingUsers = response;\r\n })\r\n .finally(() => { });\r\n }\r\n\r\n gotoDashboard() {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n //new search share modal close btn function\r\n OnClickOfSkip() {\r\n this.showShareSearchtoClientModal = false;\r\n if (this.$location.path().startsWith(\"/allloans\") && (this.isAdmin || this.isBroker)) {\r\n this.dealService.setShowSearchNameAndUserSelectionModal(false);\r\n }\r\n }\r\n\r\n //new search share modal next btn function\r\n onClickOfNext() {\r\n this.showShareSearchtoClientModal = false;\r\n if (this.$location.path().startsWith(\"/allloans\") && (this.isAdmin || this.isBroker)) {\r\n this.dealService.setShowSearchNameAndUserSelectionModal(false);\r\n this.dealService.setClient(this.shareDealDto.ClientDto);\r\n this.dealService.setDealName(this.shareDealDto.DealName);\r\n }\r\n }\r\n\r\n // End of Share a modal functions\r\n\r\n goToLoanSelectionOptions() {\r\n this.$auth.setHasValidStatustoShowShareSearchModal(\r\n true,\r\n );\r\n this.$location.path(\"/allloans\");\r\n }\r\n\r\n calculatePurchaseOrLandCost() {\r\n if (this.dealDto.PurchasePrice && !this.hasPurchasecostChanged) {\r\n this.dealDto.PurchaseCosts = (this.dealDto.PurchasePrice * 5) / 100;\r\n }\r\n }\r\n\r\n datasetupOnOwnOrPurchaseChange() {\r\n this.dealDto = this.commercialDealService.datasetupOnOwnOrPurchaseChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnMaxLoanRequiredChange() {\r\n this.dealDto = this.dealService.dataSetupOnMaxLoanRequiredChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n onOwnOrPurchaseChange(OwnOrPurchase: boolean) {\r\n this.dealDto.OwnOrPurchase = this.dealDto.HasOwnOrPurchase\r\n ? OwnOrPurchaseEnum.Own\r\n : OwnOrPurchaseEnum.Purchasing;\r\n this.datasetupOnOwnOrPurchaseChange();\r\n }\r\n\r\n onCurrentUseOfBuilding() {\r\n if (this.dealDto.ProductType == ProductTypeEnum.CommercialInvestment) {\r\n this.dealDto = this.commercialDealService.datasetupOnCurrentUseOfBuilding(\r\n this.dealDto,\r\n );\r\n }\r\n }\r\n\r\n onIsFamilyInResidenceChange() {\r\n this.dealDto.IsFamilyInResidence = this.dealDto.HasIsFamilyInResidence\r\n ? YesNoMaybe.Yes\r\n : YesNoMaybe.No;\r\n }\r\n\r\n initialDataSetupForIsFamilyInResidence() {\r\n if (this.dealDto.HasIsFamilyInResidence) {\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.Yes;\r\n this.dealDto.HasIsFamilyInResidence = true;\r\n } else {\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.No;\r\n this.dealDto.HasIsFamilyInResidence = false;\r\n }\r\n }\r\n\r\n\r\n async logEvent(identifier: string) {\r\n var orgCode;\r\n if (window.self == window.top) {\r\n if (sessionStorage.getItem(\"clientId\")) {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto?.OrganisationLinkId,\r\n this.dealDto.ProductType,\r\n \"\",\r\n this.dealDto.Id,\r\n sessionStorage.getItem(\"clientId\"),\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto?.OrganisationLinkId,\r\n this.dealDto.ProductType,\r\n );\r\n }\r\n } else {\r\n var clientId: string = null;\r\n clientId = await this.organisationService.getData(\"clientId\");\r\n if (clientId) {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto.OrganisationLinkId,\r\n this.dealDto.ProductType,\r\n \"\",\r\n this.dealDto.Id,\r\n clientId,\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto.OrganisationLinkId,\r\n this.dealDto.ProductType,\r\n );\r\n }\r\n }\r\n }\r\n\r\n goToSearchResults() {\r\n this.isSubmitted = true;\r\n this.isSearchStarted = true;\r\n this.hasError = false;\r\n this.error = null;\r\n // If enterprise\r\n if (\r\n !this.isLoggedInUser &&\r\n this.isBorrower &&\r\n (this.$location.path().startsWith(\"/e/commercialcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\"))\r\n ) {\r\n this.enterpriseService.setProductFamily(this.dealDto.ProductFamily);\r\n\r\n this.saveCriteriaReturnUniqueRef().then((response) => {\r\n if (!this.hasError) {\r\n this.sharedCriteriaService.setIsDataLoading(false);\r\n var uniqueRef = response as SaveSearchReturnUniqueRefResponse;\r\n if (window.self == window.top)\r\n sessionStorage.removeItem(\"productType\");\r\n if (response.HasDealClient) {\r\n //The purpose of the route check is to ensure navigation to the correct route when the user lands on the criteria page by clicking 'Change Search' in the side panel.\r\n if (sessionStorage.getItem('previousRoute') == 'referredsearchdeal') {\r\n this.$location.path(`/referredsearchdeal/${response.DealClientUniqueRef}/false`);\r\n sessionStorage.removeItem('previousRoute');\r\n } else {\r\n this.$location.path(`/e/commercialresults/${response.DealUniqueRef}`);\r\n }\r\n } else {\r\n var leadCaptureUrl = `/e/enterpriseleadcapture/${response.DealUniqueRef}`;\r\n leadCaptureUrl = this.isWidget ? `${leadCaptureUrl}/widget` : leadCaptureUrl;\r\n\r\n this.$location.path(leadCaptureUrl);\r\n }\r\n }\r\n });\r\n } else {\r\n this.saveCriteriaReturnId().then((response) => {\r\n if (!this.hasError) {\r\n var dealId = response as number;\r\n if (window.self == window.top)\r\n sessionStorage.removeItem(\"productType\");\r\n if (this.isAdmin || this.isBroker) this.dealService.setShowSearchNameAndUserSelectionModal(true);\r\n this.$location.path(\"/commercialresults/\" + dealId);\r\n }\r\n });\r\n }\r\n }\r\n\r\n searchDisabled() {\r\n\r\n if (this.progressSection == 1) {\r\n this.progressAmount = \"0%\";\r\n\r\n if (\r\n this.dealDto.IsFamilyInResidence == 1 ||\r\n this.dealDto.Locations == null ||\r\n this.dealDto.Locations <= 0 ||\r\n this.showPostcodeErrorMessage\r\n ) {\r\n return true;\r\n }\r\n\r\n if (this.multiPartForm1.$invalid) {\r\n return true;\r\n }\r\n\r\n this.progressAmount = \"33%\";\r\n }\r\n\r\n\r\n\r\n if (this.progressSection == 2) {\r\n this.progressAmount = \"33%\";\r\n\r\n if (\r\n this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Purchasing &&\r\n (this.dealDto.PurchasePrice == null || this.dealDto.PurchasePrice == 0)\r\n ) {\r\n return true;\r\n }\r\n\r\n if (\r\n this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Own &&\r\n (this.dealDto.Currentvalue == null || this.dealDto.Currentvalue == 0)\r\n ) {\r\n return true;\r\n }\r\n\r\n if (this.dealDto.IsFamilyInResidence == 1 || this.hasValidNetLoanRequiredValue()) {\r\n return true;\r\n }\r\n\r\n if (this.multiPartForm1.$invalid) {\r\n return true;\r\n }\r\n\r\n this.progressAmount = \"66%\";\r\n\r\n }\r\n\r\n\r\n if (this.progressSection == 3) {\r\n this.progressAmount = \"66%\";\r\n\r\n if (this.multiPartForm1.$invalid) {\r\n return true;\r\n }\r\n\r\n this.progressAmount = \"100%\";\r\n }\r\n\r\n return false;\r\n }\r\n\r\n saveCriteriaReturnId(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.dataSetUpForSave();\r\n\r\n var clientDto = null;\r\n /* if (!this.isLoggedInUser && this.enterpriseUser && (this.$location.path().startsWith(\"/e/commercialcriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n clientDto = this.sharedCriteriaService.setClientDtoDataForEnterpriseSearch(this.enterpriseUser, this.brokerageOrg.Id, clientDto);\r\n }*/\r\n\r\n var request: SaveCommercialSearchRequest = {\r\n DealDto: this.dealDto,\r\n ShareDealDto: this.shareDealDto,\r\n OrgCode: this.isLoggedInUser ? \"\" : this.orgCode,\r\n ClientId:\r\n !this.isLoggedInUser &&\r\n this.clientId &&\r\n !this.enterpriseUser &&\r\n (this.$location.path().startsWith(\"/e/commercialcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\"))\r\n ? Number(this.clientId)\r\n : 0,\r\n EnterpriseClientDto: clientDto,\r\n };\r\n\r\n this.commercialDealService\r\n .saveCommercialSearchReturnsId(request)\r\n .then((response) => {\r\n this.dealDto.Id = response;\r\n\r\n defer.resolve(response as number);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n if (response.status === 500) {\r\n this.error = response.data.message;\r\n } else {\r\n this.error = 'Something went wrong while searching for loans. Please try again.';\r\n }\r\n this.hasError = true;\r\n this.isSearchStarted = false;\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n saveCriteriaReturnUniqueRef(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.sharedCriteriaService.setIsDataLoading(true);\r\n\r\n this.dataSetUpForSave();\r\n\r\n var clientDto = null;\r\n /* if (!this.isLoggedInUser && this.enterpriseUser && (this.$location.path().startsWith(\"/e/commercialcriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n clientDto = this.sharedCriteriaService.setClientDtoDataForEnterpriseSearch(this.enterpriseUser, this.brokerageOrg.Id, clientDto);\r\n }*/\r\n\r\n var request: SaveCommercialSearchRequest = {\r\n DealDto: this.dealDto,\r\n ShareDealDto: this.shareDealDto,\r\n OrgCode: this.isLoggedInUser ? \"\" : this.orgCode,\r\n ClientId: !this.isWidget &&\r\n !this.isLoggedInUser &&\r\n this.clientId &&\r\n !this.enterpriseUser &&\r\n (this.$location.path().startsWith(\"/e/commercialcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\"))\r\n ? Number(this.clientId)\r\n : 0,\r\n EnterpriseClientDto: clientDto,\r\n };\r\n\r\n this.commercialDealService\r\n .saveCommercialSearchReturnsUniqueRef(request)\r\n .then((response) => {\r\n this.dealDto.UniqueRef = response.DealUniqueRef;\r\n\r\n defer.resolve(response as SaveSearchReturnUniqueRefResponse);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n this.sharedCriteriaService.setIsDataLoading(false);\r\n if (response.status === 500) {\r\n this.error = response.data.message;\r\n } else {\r\n this.error = 'Something went wrong while searching for loans. Please try again.';\r\n }\r\n this.hasError = true;\r\n this.isSearchStarted = false;\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n dataSetUpForSave() {\r\n this.sharedCriteriaService.setNewSearch(this.dealDto, this.snapshotDealDto);\r\n\r\n if (this.dealDto.Id == null) {\r\n this.dealDto.Status = CaseStatusEnum.Search;\r\n }\r\n\r\n if (\r\n this.dealDto.Name == null ||\r\n this.dealDto.Name == \"\" ||\r\n this.dealDto.Name == undefined\r\n ) {\r\n this.dealDto.Name = this.sharedCriteriaService.defaultSearchName(\r\n this.dealDto.ProductType,\r\n );\r\n }\r\n\r\n if (\r\n !this.isLoggedInUser &&\r\n (this.$location.path().startsWith(\"/e/commercialcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\")) &&\r\n this.isBorrower\r\n ) {\r\n this.dealDto.HowManyFlats = this.dealDto.HowManyFlats\r\n ? this.dealDto.HowManyFlats\r\n : 0;\r\n this.dealDto.HowManyHouses = this.dealDto.HowManyHouses\r\n ? this.dealDto.HowManyHouses\r\n : 0;\r\n }\r\n\r\n if (!this.shareDealDto) {\r\n this.shareDealDto = {\r\n DealName: this.sharedCriteriaService.defaultSearchName(\r\n this.dealDto.ProductType,\r\n ),\r\n } as ShareDealDTO;\r\n }\r\n\r\n if (this.dealDto.PurchasePrice == null) {\r\n this.dealDto.PurchasePrice = 0;\r\n }\r\n\r\n if (this.dealDto.PurchaseCosts == null) {\r\n this.dealDto.PurchaseCosts = 0;\r\n }\r\n }\r\n\r\n dummysearch() {\r\n if (this.dealDto.hasPostcode) {\r\n this.dealDto.PostcodeSearchString =\r\n this.sharedCriteriaService.getRandomPostcode();\r\n this.getRegionByPostcode();\r\n } else {\r\n this.dealDto.Locations = LocationEnum.London;\r\n }\r\n\r\n this.mortgageTerm = this.sharedCriteriaService.getRandomIntInclusive(\r\n 10,\r\n 30,\r\n );\r\n this.mortgageTermToLoanTerm();\r\n this.dealDto.MaxLoanRequired =\r\n this.sharedCriteriaService.getRandomIntInclusive(0, 1) == 1\r\n ? true\r\n : false;\r\n if (!this.dealDto.MaxLoanRequired) {\r\n this.dealDto.NetLoanRequired =\r\n this.sharedCriteriaService.getRandomIntInclusive(400000, 2000000);\r\n }\r\n\r\n if (this.dealDto.ProductType == ProductTypeEnum.CommercialInvestment) {\r\n this.dealDto.GrossMonthlyRentalIncome =\r\n this.sharedCriteriaService.getRandomIntInclusive(10000, 20000);\r\n } else {\r\n this.dealDto.AdjustedAnnualEBITDA =\r\n this.sharedCriteriaService.getRandomIntInclusive(500000, 1000000);\r\n }\r\n\r\n this.dealDto.PurchasePrice =\r\n this.sharedCriteriaService.getRandomIntInclusive(5000000, 10000000);\r\n this.dealDto.PurchaseCosts =\r\n this.sharedCriteriaService.getRandomIntInclusive(100000, 1000000);\r\n }\r\n\r\n initMortgageTerm() {\r\n this.dealDto.LoanTermReq = this.dealDto.LoanTermReq || 240;\r\n this.mortgageTerm = this.dealDto.LoanTermReq / 12;\r\n }\r\n\r\n mortgageTermToLoanTerm() {\r\n this.dealDto.LoanTermReq = this.mortgageTerm * 12;\r\n }\r\n\r\n onLoanRepaymentTypeChange() {\r\n if (this.dealDto.LoanRepaymentType == LoanRepaymentTypeEnum.Repayment) {\r\n this.mortgageTerm = 20;\r\n } else if (\r\n this.dealDto.LoanRepaymentType == LoanRepaymentTypeEnum.InterestOnly\r\n ) {\r\n this.mortgageTerm = 10;\r\n }\r\n this.mortgageTermToLoanTerm();\r\n }\r\n\r\n hasValidNetLoanRequiredValue() {\r\n if (\r\n !this.dealDto.MaxLoanRequired &&\r\n (this.dealDto.NetLoanRequired == null ||\r\n isNaN(this.dealDto.NetLoanRequired) ||\r\n this.dealDto.NetLoanRequired <= 0)\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n getRegionByPostcode() {\r\n if (\r\n this.dealDto.PostcodeSearchString &&\r\n this.dealDto.PostcodeSearchString.replace(\" \", \"\").length >= 2\r\n ) {\r\n if (\r\n this.dealService.isValidPostcodeString(\r\n this.dealDto.PostcodeSearchString,\r\n )\r\n ) {\r\n this.dataLoading = true;\r\n this.dealService\r\n .getRegionByPostcode(this.dealDto.PostcodeSearchString)\r\n .then((response) => {\r\n if (response.Location != null) {\r\n this.dealDto.Locations = response.Location;\r\n this.showPostcodeErrorMessage = false;\r\n } else {\r\n this.postcodeErrorMsg = response.PostCodeErrorMessage;\r\n this.showPostcodeErrorMessage = true;\r\n if (this.dealDto.Locations) this.dealDto.Locations = null;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.postcodeErrorMsg =\r\n \"At least one letter and one number must be entered e.g. SW1.\";\r\n this.showPostcodeErrorMessage = true;\r\n if (this.dealDto.Locations) this.dealDto.Locations = null;\r\n }\r\n } else {\r\n if (this.dealDto.Locations) this.dealDto.Locations = null;\r\n }\r\n }\r\n\r\n onHasPostcodeChange() {\r\n if (!this.dealDto.hasPostcode) {\r\n this.showPostcodeErrorMessage = false;\r\n this.dealDto.PostcodeSearchString = null;\r\n this.dealDto.Locations = this.previouslySelectedLocation;\r\n } else {\r\n this.previouslySelectedLocation = this.dealDto.Locations;\r\n this.dealDto.Locations = null;\r\n }\r\n }\r\n\r\n isCriteriaFormInValid() {\r\n if (\r\n this.isSearchStarted ||\r\n this.multiPartForm1.$invalid ||\r\n this.dealDto.IsFamilyInResidence == 1 ||\r\n this.dealDto.Locations == null ||\r\n this.dealDto.Locations <= 0 ||\r\n this.hasValidNetLoanRequiredValue() ||\r\n this.showPostcodeErrorMessage\r\n ) {\r\n if (this.isSearchStarted) {\r\n this.progressAmount = \"100%\";\r\n } else {\r\n this.progressAmount = \"66%\";\r\n }\r\n return true;\r\n } else {\r\n this.progressAmount = \"100%\";\r\n return false;\r\n }\r\n }\r\n\r\n commercialTypeChanged(productType: ProductTypeEnum) {\r\n this.progressSection = 1;\r\n this.getLoanInfoText(productType);\r\n this.dealDto = {} as CommercialDealDTO;\r\n this.commercialDealService.initialDataSetUp(this.dealDto, productType);\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.getOriginatorInfoForUser();\r\n } else {\r\n this.getOriginatorInfoForAnonymousUsers();\r\n }\r\n this.currentUseofBuildingOptions =\r\n this.selectListService.GetCommercialCurrentUseOfBuildingOptions(\r\n this.dealDto.ProductType,\r\n );\r\n this.onLoanRepaymentTypeChange();\r\n\r\n this.hasPurchasecostChanged = false; \r\n if (!this.isLoggedInUser &&\r\n (this.$location.path().startsWith(\"/e/commercialcriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\"))\r\n ) {\r\n if (this.$routeParams.linkId && this.$routeParams.linkId != \"0\") {\r\n this.dealDto.OrganisationLinkId = this.$routeParams.linkId;\r\n }\r\n\r\n this.logEvent(\"COMMERCIALCRITERIA-PAGE1\");\r\n }\r\n }\r\n\r\n showBasedOnMainResidence() {\r\n return this.dealService.showBasedOnMainResidence(this.dealDto);\r\n }\r\n\r\n isFieldEmpty(fieldName, isEnum = false) {\r\n if (this.isSubmitted && this.dealDto) {\r\n const fieldValue = this.dealDto[fieldName];\r\n if (fieldName == \"PlanningPermissionType\") {\r\n if (fieldValue == null || fieldValue < 1) {\r\n return true;\r\n }\r\n }\r\n if (fieldValue == null || (isEnum && fieldValue === \"0\")) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n isFieldZero(fieldName) {\r\n if (this.isSubmitted && this.dealDto) {\r\n const fieldValue = this.dealDto[fieldName];\r\n if (fieldValue == null || fieldValue === '0' || fieldValue === 0) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n clickNextButton() {\r\n if (this.progressSection == 1) {\r\n if (!this.isLoggedInUser && (this.$location.path().startsWith(\"/e/commercialcriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n this.logEvent(\"COMMERCIALCRITERIA-PAGE2\");\r\n }\r\n this.progressSection = 2;\r\n } else {\r\n if (!this.isLoggedInUser && (this.$location.path().startsWith(\"/e/commercialcriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n this.logEvent(\"COMMERCIALCRITERIA-PAGE3\");\r\n }\r\n this.progressSection = 3;\r\n }\r\n }\r\n\r\n clickBackButton() {\r\n if (this.progressSection == 3) {\r\n if (!this.isLoggedInUser && (this.$location.path().startsWith(\"/e/commercialcriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n this.logEvent(\"COMMERCIALCRITERIA-PAGE2\");\r\n }\r\n this.progressSection = 2;\r\n } else {\r\n if (!this.isLoggedInUser && (this.$location.path().startsWith(\"/e/commercialcriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n this.logEvent(\"COMMERCIALCRITERIA-PAGE1\");\r\n }\r\n this.progressSection = 1;\r\n }\r\n }\r\n\r\n getLoanInfoText(productType) {\r\n switch (productType) {\r\n case ProductTypeEnum.CommercialInvestment:\r\n this.loanInfoText =\r\n \"For landlords and investors that let to unrelated third parties\";\r\n break;\r\n case ProductTypeEnum.CommercialOwnerOccupied:\r\n this.loanInfoText =\r\n \"For businesses that own and operate out of their own premises\";\r\n break;\r\n default:\r\n this.loanInfoText = \"\";\r\n break;\r\n }\r\n }\r\n async logEventWithoutDealData() {\r\n if (window.self == window.top) {\r\n if (sessionStorage.getItem(\"clientId\")) {\r\n this.eventLogService.logPageLoad(\r\n \"COMMERCIALCRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.CommercialAll,\r\n \"\",\r\n this.dealDto.Id,\r\n sessionStorage.getItem(\"clientId\"),\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n \"COMMERCIALCRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.CommercialAll,\r\n \"\",\r\n this.dealDto.Id,\r\n );\r\n }\r\n } else {\r\n var clientId: string = null;\r\n clientId = await this.organisationService.getData(\"clientId\");\r\n\r\n if (clientId) {\r\n this.eventLogService.logPageLoad(\r\n \"COMMERCIALCRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.CommercialAll,\r\n \"\",\r\n this.dealDto.Id,\r\n clientId,\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n \"COMMERCIALCRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.CommercialAll,\r\n \"\",\r\n this.dealDto.Id,\r\n );\r\n }\r\n }\r\n }\r\n\r\n getOriginatorInfoForUser() {\r\n if (this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Admin;\r\n this.dealDto.SourceType = DealSourceTypeEnum.Application;\r\n } else if (this.isBroker && !this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Broker;\r\n } else if (this.isBorrower && !this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Borrower;\r\n } else if (this.isLender && !this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Lender;\r\n this.dealDto.SourceType = DealSourceTypeEnum.Application;\r\n }\r\n\r\n if (window.self == window.top) {\r\n\r\n if (this.isLender) {\r\n this.userService.getCurrentUserLender().then((response) => {\r\n this.dealDto.OriginatorLenderId = response;\r\n });\r\n }\r\n\r\n if (this.isBroker || this.isBorrower) {\r\n this.organisationService.getOrganisation().then((org) => {\r\n if (org != null) {\r\n if (org.Id != 0) this.dealDto.OriginatorOrganisationId = org.Id;\r\n this.dealDto.SourceType = org.IsWhiteLabelled\r\n ? DealSourceTypeEnum.WhitelabelApplication\r\n : DealSourceTypeEnum.Application;\r\n }\r\n });\r\n }\r\n\r\n\r\n }\r\n }\r\n\r\n getOriginatorInfoForAnonymousUsers() {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Borrower;\r\n\r\n if (window.self == window.top) {\r\n this.dealDto.SourceType = DealSourceTypeEnum.Enterprise;\r\n } else {\r\n this.dealDto.SourceType = this.isWidget ? DealSourceTypeEnum.WidgetEnterprise : DealSourceTypeEnum.IFrameEnterprise;\r\n }\r\n\r\n if (this.$routeParams.linkId) {\r\n if (window.self == window.top) {\r\n this.dealDto.SourceType = DealSourceTypeEnum.UniqueLink;\r\n } else {\r\n this.dealDto.SourceType = this.isWidget ? this.$routeParams.linkId == \"0\"? DealSourceTypeEnum.WidgetEnterprise: DealSourceTypeEnum.WidgetUniqueLink : DealSourceTypeEnum.IFrameUniqueLink;\r\n }\r\n }\r\n }\r\n\r\n postRetrieveProcessing(response) {\r\n this.dealDto = { ...response };\r\n this.getLoanInfoText(this.dealDto.ProductType);\r\n this.currentUseofBuildingOptions =\r\n this.selectListService.GetCommercialCurrentUseOfBuildingOptions(\r\n this.dealDto.ProductType,\r\n );\r\n this.mortgageTerm = this.dealDto.LoanTermReq / 12;\r\n this.snapshotDealDto = { ...response };\r\n }\r\n\r\n getRequiredRolesOptions(){\r\n return this.dealService.getRequiredRolesOptions();\r\n }\r\n}\r\n","export const enum AreaUnitEnum {\r\n SquareMeters = 0,\r\n SquareFeet = 1,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { DevelopmentFinanceDealDTO } from \"@js/DTO/Deal/DevelopmentFinanceDealDTO.cs.d\";\r\nimport { ShareDealDTO } from \"@js/DTO/Deal/SearchDealDTO.cs.d\";\r\nimport { SaveDevFinanceSearchRequest } from \"@js/DTO/Messages/Deal/SaveDevFinanceSearchMessage.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { AreaUnitEnum } from \"@js/models/enum/AreaUnitEnum.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { DealSourceTypeEnum } from \"@js/models/enum/DealSourceTypeEnum.cs.d\";\r\nimport { LinkTypeEnum } from \"@js/models/enum/LinkTypeEnum.cs.d\";\r\nimport { LocationEnum } from \"@js/models/enum/LocationEnum.cs.d\";\r\nimport { OriginatorRoleTypeEnum } from \"@js/models/enum/OriginatorRoleTypeEnum.cs.d\";\r\nimport { OwnOrPurchaseEnum } from \"@js/models/enum/OwnOrPurchaseEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { PropertyTypeEnum } from \"@js/models/enum/PropertyTypeEnum.cs.d\";\r\nimport { YesNoMaybe } from \"@js/models/enum/YesNoMaybeEnum.cs.d\";\r\nimport { SaveSearchReturnUniqueRefResponse } from \"@js/models/SaveSearchReturnUniqueRef.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { DevFinanceDealService } from \"@js/services/Deal/DevFinanceDealService\";\r\nimport { SharedCriteriaService } from \"@js/services/Deal/SharedCriteriaService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { OrganisationLinkService } from \"@js/services/OrganisationLinkService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { CriteriaController } from \"./CriteriaController\";\r\nimport { EnterpriseService } from \"@js/services/EnterpriseService\";\r\nimport { UserRoleEnum } from \"@js/models/enum/UserRoleEnum.cs.d\";\r\n\r\nexport class DevFinanceCriteriaController extends CriteriaController {\r\n dealDto: DevelopmentFinanceDealDTO;\r\n tempDealDto: DevelopmentFinanceDealDTO;\r\n snapshotDealDto: DevelopmentFinanceDealDTO;\r\n productType: ProductTypeEnum;\r\n\r\n maxPurchaseDate: string;\r\n minPurchaseDate: Date = new Date(\"Jan 01 1900\");\r\n isLoggedInUser: boolean = false;\r\n dataLoading: boolean = false;\r\n isSearchStarted: boolean = false;\r\n hasError: boolean = false;\r\n isSubmitted: boolean = false;\r\n error: string;\r\n\r\n multiPartForm1: ng.IFormController;\r\n\r\n //Share a search modal\r\n showShareSearchtoClientModal: boolean = false;\r\n existingUsers: UserSimpleDTO[];\r\n existingborrower: boolean;\r\n\r\n //Message to show when Enterprise url does not have valid lead gen license status or whitelabel add on is not paid or whitelabel setting is not on.\r\n noPermissionErrorMsg: string = \"\";\r\n\r\n //Enterprise user clientId\r\n clientId: string = null;\r\n enterpriseUser: ApplicationUserDTO = null;\r\n\r\n currentUseofBuildingOptions = [];\r\n locationOptions = [];\r\n loanCompletionTypeOptions = [];\r\n\r\n hasPurchaseCostChanged: boolean = false;\r\n\r\n guidanceCheckbox: boolean = true;\r\n shareDealDto: ShareDealDTO = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n //shows the selected existing client data on share modal\r\n showClientDetails: boolean = false;\r\n\r\n isDeal: boolean = true;\r\n\r\n isBorrower: boolean = false;\r\n isAdmin: boolean = false;\r\n isBroker: boolean = false;\r\n isLender: boolean = false;\r\n organisation: OrganisationDTO;\r\n moveContactBrokerBtnInMiddle: boolean = false;\r\n initialRegistrationClient: ClientDTO;\r\n orgCode: string;\r\n buildCostPerSqFt: number;\r\n buildCostPerSqM: number;\r\n buildCostIntermediary: number;\r\n areaConversionFactor: number = 10.7639;\r\n contingencyValue: number;\r\n totalBuildCosts: number;\r\n defaultProfessionalCosts: number = 0.1;\r\n showAutofill: boolean = false;\r\n\r\n //Postcode properties\r\n // showPostcodeErrorMessage: boolean = false;\r\n //postcodeErrorMsg: string;\r\n //previouslySelectedLocation: LocationEnum;\r\n isCaseDashboard: boolean = false;\r\n\r\n isMobileView: boolean = false;\r\n showHelpModal: boolean = false;\r\n loanInfoText: string;\r\n progressAmount: string = \"33%\";\r\n progressSection: number = 1;\r\n totalSections: number = 3;\r\n enterpriseLinkLogo: string;\r\n\r\n isWidget: boolean = false;\r\n //This propert is used to show only postcode ot location field on critera for mobile view\r\n isCriteria: boolean = true;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$q\",\r\n \"UserService\",\r\n \"RoleService\",\r\n \"OrganisationService\",\r\n \"SelectListService\",\r\n \"DevFinanceDealService\",\r\n \"SharedCriteriaService\",\r\n \"EventLogService\",\r\n \"AuthService\",\r\n \"DevelopmentInputService\",\r\n \"DealService\",\r\n \"OrganisationLinkService\",\r\n \"EnterpriseService\"\r\n ].concat(CriteriaController.$inject);\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n protected $q: ng.IQService,\r\n private userService: UserService,\r\n private roleService: RoleService,\r\n private organisationService: OrganisationService,\r\n private selectListService: SelectListService,\r\n private devFinanceDealService: DevFinanceDealService,\r\n private sharedCriteriaService: SharedCriteriaService,\r\n private eventLogService: EventLogService,\r\n private $auth: AuthService,\r\n private $DevelopmentInputservice: DevelopmentInputService,\r\n dealService: DealService,\r\n private organisationLinkService: OrganisationLinkService,\r\n private enterpriseService: EnterpriseService\r\n ) {\r\n super(dealService);\r\n\r\n try {\r\n if (this.$routeParams.context == 'widget' && window.self != window.top) {\r\n this.isWidget = true;\r\n } else {\r\n if (window.innerWidth <= 480)\r\n this.isMobileView = true\r\n }\r\n\r\n\r\n this.maxPurchaseDate = new Date().toISOString().split(\"T\")[0];\r\n\r\n //Initial data setup for a dev finance deal\r\n if (this.dealDto == null) {\r\n this.dealDto = {} as DevelopmentFinanceDealDTO;\r\n this.loanInfoText =\r\n \"For all new-build, conversion or larger refurbishment projects\";\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.No;\r\n this.dealDto = this.devFinanceDealService.initialDataSetUpForDeal(\r\n this.dealDto,\r\n );\r\n this.dealDto.GrossInternalAreaKnown = true;\r\n this.dealDto.AreaUnit = AreaUnitEnum.SquareFeet;\r\n this.dealDto.IncludesContingency = false;\r\n if (this.$routeParams.linkId && this.$routeParams.linkId != \"0\") {\r\n this.dealDto.OrganisationLinkId = this.$routeParams.linkId;\r\n }\r\n }\r\n\r\n //Enteprise journey code\r\n if (!$cookies.get(\"access_token\") &&\r\n (this.$location.path().startsWith(\"/e/devfinancecriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\"))\r\n ) {\r\n this.isBorrower = true;\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Borrower;\r\n\r\n if (this.$location.path().startsWith(\"/e/devfinancecriteria\")) {\r\n var imgs = document.getElementsByTagName(\"img\");\r\n this.enterpriseLinkLogo = imgs[0].src;\r\n this.sharedCriteriaService.storeEnterpriseLinkType(LinkTypeEnum.Development.toString());\r\n }\r\n\r\n if (this.isWidget) {\r\n //document.getElementById(\"footer\").style.display = \"none\";\r\n this.organisationService.sendDataToParent(\"height\", \"745px\");\r\n }\r\n\r\n if (!this.$routeParams.DealUniqueRef) {\r\n\r\n if (window.self == window.top) {\r\n this.orgCode = this.$cookies.get(\"org_code\");\r\n sessionStorage.setItem(\"userRole\", UserRoleEnum.Client.toString());\r\n } else {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n this.organisationService.sendDataToParent(\"userRole\", UserRoleEnum.Client.toString());\r\n }\r\n\r\n this.logEventWithoutDealData();\r\n this.getOriginatorInfoForAnonymousUsers();\r\n }\r\n\r\n this.dataLoading = true;\r\n this.organisationService\r\n .getOrgByUrlIfOrgHasEnterpriseSearchPermission(\r\n this.orgCode,\r\n ProductFamilyEnum.Development,\r\n this.$routeParams.linkId,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n this.organisation = response;\r\n this.orgCode = response.OrganisationCode;\r\n this.logEvent(\"DEVFINANCECRITERIA-PAGE1\");\r\n\r\n if (this.$routeParams.linkId) {\r\n if (this.$location.path().startsWith(\"/e/devfinancecriteria\")) {\r\n this.organisationLinkService\r\n .getOrganisationLinkLogoByLinkIdAndLogPageLoadEvent(\r\n this.$routeParams.linkId\r\n )\r\n .then((logoUrl) => {\r\n if (logoUrl) this.enterpriseLinkLogo = imgs[0].src = logoUrl;\r\n });\r\n }\r\n\r\n }\r\n } else {\r\n this.logEvent(\"DEVFINANCECRITERIA-NO-PERMISSION-TO-SEARCH\");\r\n this.noPermissionErrorMsg =\r\n \"We are unable to compare loans right now. Please contact your broker.\";\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n if (window.self == window.top && $cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n\r\n this.userService.getUserAutofill().then((response) => {\r\n this.showAutofill = response;\r\n });\r\n\r\n this.roleService.GetUserRoles().then((result) => {\r\n if (result.filter((x) => x.toLowerCase() == \"admin\").length > 0) {\r\n this.isAdmin = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"broker\").length > 0) {\r\n this.isBroker = true;\r\n if (!this.isAdmin)\r\n // this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Broker;\r\n //This block is to navigate a broker to userdashboard when they do not have a license.\r\n if (this.isBroker) {\r\n if (sessionStorage.getItem(\"isValidLicense\") == \"false\") {\r\n this.gotoDashboard();\r\n }\r\n }\r\n }\r\n if (\r\n result.filter((x) => x.toLowerCase() == \"lender\").length > 0 &&\r\n !this.isAdmin\r\n ) {\r\n this.isLender = true;\r\n }\r\n\r\n if (\r\n result.filter((x) => x.toLowerCase() == \"client\").length > 0 &&\r\n !this.isAdmin\r\n ) {\r\n this.isBorrower = true;\r\n }\r\n\r\n }).finally(() => {\r\n if (\r\n this.$auth.getHasValidStatustoShowShareSearchModal()\r\n ) {\r\n if (sessionStorage.getItem(\"skip\")) {\r\n //This will hide's a share search to client modal\r\n this.showShareSearchtoClientModal = false;\r\n } else {\r\n //getting a previously entered DealName and Client data \r\n if (this.dealService.getShowSearchNameAndUserSelectionModal()) {\r\n this.showShareSearchtoClientModal = true;\r\n this.getUsersBelongToBrokerOrAdmin();\r\n } else {\r\n this.shareDealDto.ClientDto = this.dealService.getClient();\r\n this.shareDealDto.DealName = this.dealService.getDealName();\r\n }\r\n }\r\n this.getOriginatorInfoForUser();\r\n }\r\n });\r\n\r\n //This block is to navigate a broker to userdashboard when they do not have a license.\r\n if (sessionStorage.getItem(\"isValidLicense\") == \"false\") {\r\n this.gotoDashboard();\r\n }\r\n } else {\r\n if (!this.$routeParams.DealUniqueRef) {\r\n if (window.self == window.top) {\r\n this.clientId = sessionStorage.getItem(\"clientId\");\r\n } else {\r\n Promise.all([\r\n this.organisationService.getData(\"clientId\").then((clientId) => {\r\n if (clientId) {\r\n this.clientId = clientId;\r\n }\r\n }),\r\n ]);\r\n }\r\n }\r\n }\r\n\r\n\r\n\r\n if (this.$routeParams.DealUniqueRef && this.$routeParams.DealUniqueRef != '0') {\r\n this.dataLoading = true;\r\n this.dealService\r\n .fetchByUniqueRef(this.$routeParams.DealUniqueRef)\r\n .then((response) => {\r\n this.dealDto = { ...response };\r\n this.snapshotDealDto = { ...response };\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.updateCalculatedFields();\r\n });\r\n }\r\n else if (this.$routeParams.SearchId > 0) {\r\n this.dataLoading = true;\r\n this.devFinanceDealService\r\n .fetch(this.$routeParams.SearchId)\r\n .then((response) => {\r\n this.dealDto = { ...response };\r\n this.snapshotDealDto = { ...response };\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.updateCalculatedFields();\r\n });\r\n } else {\r\n this.dealDto.MaxLoanRequired = true;\r\n this.dealDto.ShowLenderInfoBrokerOverride = true;\r\n }\r\n\r\n if (window.self == window.top) {\r\n this.updateGuidanceState();\r\n\r\n $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n this.updateGuidanceState();\r\n });\r\n }\r\n\r\n this.currentUseofBuildingOptions = this.selectListService.GetCurrentUseOfBuildingOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n this.loanCompletionTypeOptions = this.selectListService.GetLoanCompletionOptions();\r\n } catch (e) {\r\n console.error(\"Error: \", e);\r\n }\r\n }\r\n\r\n updateGuidanceState() {\r\n this.guidanceCheckbox =\r\n this.$cookies.get(\"guidance\") === \"on\" ||\r\n this.$cookies.get(\"guidance\") === undefined;\r\n }\r\n\r\n // Start of Share a modal functions\r\n viewClientsDashboardForNewSearch(userName: string) {\r\n this.shareDealDto =\r\n this.sharedCriteriaService.attachSelectedClientToShareDealDto(\r\n this.existingUsers,\r\n this.shareDealDto,\r\n userName,\r\n );\r\n this.showClientDetails = true;\r\n }\r\n\r\n //Clears the previously selected existing client data on share search modal\r\n clearInputFields() {\r\n this.shareDealDto =\r\n this.sharedCriteriaService.clearExistingUserOnShareDealDto(\r\n this.shareDealDto,\r\n );\r\n this.showClientDetails = false;\r\n }\r\n\r\n getUsersBelongToBrokerOrAdmin() {\r\n this.userService\r\n .getUserSummariesForBrokerOrAdmin()\r\n .then((response) => {\r\n this.existingUsers = response;\r\n })\r\n .finally(() => { });\r\n }\r\n\r\n gotoDashboard() {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n //new search share modal close btn function\r\n OnClickOfSkip() {\r\n this.showShareSearchtoClientModal = false;\r\n if (this.$location.path().startsWith(\"/allloans\") && (this.isAdmin || this.isBroker)) {\r\n this.dealService.setShowSearchNameAndUserSelectionModal(false);\r\n }\r\n }\r\n\r\n //new search share modal next btn function\r\n onClickOfNext() {\r\n this.showShareSearchtoClientModal = false;\r\n if (this.$location.path().startsWith(\"/allloans\") && (this.isAdmin || this.isBroker)) {\r\n this.dealService.setShowSearchNameAndUserSelectionModal(false);\r\n this.dealService.setClient(this.shareDealDto.ClientDto);\r\n this.dealService.setDealName(this.shareDealDto.DealName);\r\n }\r\n }\r\n // End of Share a modal functions\r\n\r\n goToLoanSelectionOptions() {\r\n this.$auth.setHasValidStatustoShowShareSearchModal(\r\n true,\r\n );\r\n this.$location.path(\"/allloans\");\r\n\r\n }\r\n\r\n calculatePurchaseOrLandCost() {\r\n if (this.dealDto.PurchasePrice && !this.hasPurchaseCostChanged) {\r\n this.dealDto.PurchaseCosts = (this.dealDto.PurchasePrice * 5) / 100;\r\n }\r\n }\r\n\r\n onPurchaseCostChange() {\r\n var purchaseCost = (this.dealDto.PurchasePrice * 5) / 100;\r\n if (this.dealDto.PurchaseCosts != purchaseCost) {\r\n this.hasPurchaseCostChanged = true;\r\n }\r\n }\r\n\r\n datasetupOnOwnOrPurchaseChange() {\r\n this.dealDto = this.devFinanceDealService.datasetupOnOwnOrPurchaseChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnMaxLoanRequiredChange() {\r\n this.dealDto = this.dealService.dataSetupOnMaxLoanRequiredChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n onOwnOrPurchaseChange(OwnOrPurchase: boolean) {\r\n this.dealDto.OwnOrPurchase = this.dealDto.HasOwnOrPurchase\r\n ? OwnOrPurchaseEnum.Own\r\n : OwnOrPurchaseEnum.Purchasing;\r\n this.datasetupOnOwnOrPurchaseChange();\r\n }\r\n\r\n onCurrentUseOfBuilding() {\r\n this.dealDto = this.devFinanceDealService.datasetupOnCurrentUseOfBuilding(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n onIsFamilyInResidenceChange() {\r\n this.dealDto.IsFamilyInResidence = this.dealDto.HasIsFamilyInResidence\r\n ? YesNoMaybe.Yes\r\n : YesNoMaybe.No;\r\n this.clearSearchdata();\r\n }\r\n\r\n initialDataSetupForIsFamilyInResidence() {\r\n if (this.dealDto.HasIsFamilyInResidence) {\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.Yes;\r\n this.dealDto.HasIsFamilyInResidence = true;\r\n } else {\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.No;\r\n this.dealDto.HasIsFamilyInResidence = false;\r\n }\r\n }\r\n\r\n clearSearchdata() {\r\n this.dealDto = this.devFinanceDealService.clearSearchdata(this.dealDto);\r\n }\r\n\r\n async logEvent(identifier: string) {\r\n if (window.self == window.top) {\r\n if (sessionStorage.getItem(\"clientId\")) {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto.OrganisationLinkId,\r\n ProductTypeEnum.Development,\r\n \"\",\r\n this.dealDto.Id,\r\n sessionStorage.getItem(\"clientId\"),\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto.OrganisationLinkId,\r\n ProductTypeEnum.Development,\r\n \"\",\r\n this.dealDto.Id,\r\n );\r\n }\r\n } else {\r\n var clientId: string = null;\r\n clientId = await this.organisationService.getData(\"clientId\");\r\n\r\n if (clientId) {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto.OrganisationLinkId,\r\n ProductTypeEnum.Development,\r\n \"\",\r\n this.dealDto.Id,\r\n clientId,\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n identifier,\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.dealDto.OrganisationLinkId,\r\n ProductTypeEnum.Development,\r\n \"\",\r\n this.dealDto.Id,\r\n );\r\n }\r\n }\r\n }\r\n\r\n goToSearchResults() {\r\n this.error = null;\r\n this.isSubmitted = true;\r\n this.isSearchStarted = true;\r\n this.hasError = false;\r\n // If enterprise\r\n if (\r\n !this.isLoggedInUser &&\r\n this.isBorrower &&\r\n (this.$location.path().startsWith(\"/e/devfinancecriteria\") || this.$location.path().startsWith(\"/allloans\"))\r\n ) {\r\n this.enterpriseService.setProductFamily(this.dealDto.ProductFamily);\r\n\r\n this.saveCriteriaReturnUniqueRef().then((response) => {\r\n if (!this.hasError) {\r\n this.sharedCriteriaService.setIsDataLoading(false);\r\n var uniqueRef = response as SaveSearchReturnUniqueRefResponse;\r\n if (window.self == window.top)\r\n sessionStorage.removeItem(\"productType\");\r\n if (response.HasDealClient) {\r\n //The purpose of the route check is to ensure navigation to the correct route when the user lands on the criteria page by clicking 'Change Search' in the side panel.\r\n if (sessionStorage.getItem('previousRoute') == 'referredsearchdeal') {\r\n this.$location.path(`/referredsearchdeal/${response.DealClientUniqueRef}/false`);\r\n sessionStorage.removeItem('previousRoute');\r\n } else {\r\n this.$location.path(`/e/devfinanceresults/${response.DealUniqueRef}`);\r\n }\r\n\r\n } else {\r\n var leadCaptureUrl = `/e/enterpriseleadcapture/${response.DealUniqueRef}`;\r\n leadCaptureUrl = this.isWidget ? `${leadCaptureUrl}/widget` : leadCaptureUrl;\r\n\r\n this.$location.path(leadCaptureUrl);\r\n }\r\n }\r\n });\r\n } else {\r\n this.saveCriteriaReturnId().then((response) => {\r\n if (!this.hasError) {\r\n var dealId = response as number;\r\n if (window.self == window.top)\r\n sessionStorage.removeItem(\"productType\");\r\n if (this.isAdmin || this.isBroker) this.dealService.setShowSearchNameAndUserSelectionModal(true);\r\n this.$location.path(\"/devfinanceresults/\" + dealId);\r\n }\r\n });\r\n }\r\n\r\n }\r\n\r\n searchDisabled() {\r\n\r\n if (this.progressSection == 1) {\r\n this.progressAmount = \"0%\";\r\n if (\r\n this.dealDto.Locations == null ||\r\n this.dealDto.Locations <= 0 ||\r\n this.showPostcodeErrorMessage\r\n ) {\r\n return true;\r\n }\r\n\r\n if (this.multiPartForm1.$invalid) {\r\n return true;\r\n }\r\n\r\n this.progressAmount = \"33%\";\r\n }\r\n\r\n\r\n\r\n if (this.progressSection == 2) {\r\n\r\n this.progressAmount = \"33%\";\r\n\r\n if (this.multiPartForm1.$invalid) {\r\n return true;\r\n }\r\n\r\n this.progressAmount = \"66%\";\r\n }\r\n\r\n\r\n\r\n if (this.progressSection == 3) {\r\n this.progressAmount = \"66%\";\r\n\r\n if (this.multiPartForm1.$invalid) {\r\n return true;\r\n }\r\n this.progressAmount = \"100%\";\r\n }\r\n\r\n return false;\r\n }\r\n\r\n saveCriteriaReturnId(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.dataSetUpForSave();\r\n\r\n var clientDto = null;\r\n /* if (\r\n !this.isLoggedInUser &&\r\n this.enterpriseUser &&\r\n this.$location.path().startsWith(\"/e/devfinancecriteria\")\r\n ) {\r\n clientDto =\r\n this.sharedCriteriaService.setClientDtoDataForEnterpriseSearch(\r\n this.enterpriseUser,\r\n this.organisation.Id,\r\n clientDto,\r\n );\r\n }*/\r\n\r\n var request: SaveDevFinanceSearchRequest = {\r\n DealDto: this.dealDto,\r\n ShareDealDto: this.shareDealDto,\r\n OrgCode: this.isLoggedInUser ? \"\" : this.orgCode,\r\n ClientId:\r\n !this.isLoggedInUser &&\r\n this.clientId &&\r\n !this.enterpriseUser &&\r\n this.$location.path().startsWith(\"/e/devfinancecriteria\")\r\n ? Number(this.clientId)\r\n : 0,\r\n EnterpriseClientDto: clientDto,\r\n };\r\n\r\n this.devFinanceDealService\r\n .saveDevFinanceSearchReturnsId(request)\r\n .then((response) => {\r\n this.dealDto.Id = response;\r\n\r\n defer.resolve(response as number);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n if (response.status === 500) {\r\n this.error = response.data.message;\r\n } else {\r\n this.error = 'Something went wrong while searching for loans. Please try again.';\r\n }\r\n this.hasError = true;\r\n this.isSearchStarted = false;\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n saveCriteriaReturnUniqueRef(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.sharedCriteriaService.setIsDataLoading(true);\r\n this.dataSetUpForSave();\r\n\r\n var clientDto = null;\r\n /* if (!this.isLoggedInUser && this.enterpriseUser && this.$location.path().startsWith(\"/e/devfinancecriteria\")) {\r\n clientDto = this.sharedCriteriaService.setClientDtoDataForEnterpriseSearch(this.enterpriseUser, this.brokerageOrg.Id, clientDto);\r\n }*/\r\n\r\n var request: SaveDevFinanceSearchRequest = {\r\n DealDto: this.dealDto,\r\n ShareDealDto: this.shareDealDto,\r\n OrgCode: this.isLoggedInUser ? \"\" : this.orgCode,\r\n ClientId: !this.isWidget &&\r\n !this.isLoggedInUser &&\r\n this.clientId &&\r\n !this.enterpriseUser &&\r\n this.$location.path().startsWith(\"/e/devfinancecriteria\")\r\n ? Number(this.clientId)\r\n : 0,\r\n EnterpriseClientDto: clientDto,\r\n };\r\n\r\n this.devFinanceDealService\r\n .saveDevFinanceSearchReturnsUniqueRef(request)\r\n .then((response) => {\r\n this.dealDto.UniqueRef = response.DealUniqueRef;\r\n\r\n defer.resolve(response as SaveSearchReturnUniqueRefResponse);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n this.sharedCriteriaService.setIsDataLoading(false);\r\n if (response.status === 500) {\r\n this.error = response.data.message;\r\n } else {\r\n this.error = 'Something went wrong while searching for loans. Please try again.';\r\n }\r\n this.hasError = true;\r\n this.isSearchStarted = false;\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n dataSetUpForSave() {\r\n this.sharedCriteriaService.setNewSearch(this.dealDto, this.snapshotDealDto);\r\n\r\n if (this.dealDto.Id == null) {\r\n this.dealDto.Status = CaseStatusEnum.Search;\r\n }\r\n\r\n if (\r\n this.dealDto.Name == null ||\r\n this.dealDto.Name == \"\" ||\r\n this.dealDto.Name == undefined\r\n ) {\r\n this.dealDto.Name = this.sharedCriteriaService.defaultSearchName(\r\n this.dealDto.ProductType,\r\n );\r\n }\r\n\r\n if (\r\n !this.isLoggedInUser &&\r\n this.$location.path().startsWith(\"/e/devfinancecriteria\") &&\r\n this.isBorrower\r\n ) {\r\n this.dealDto.HowManyFlats = this.dealDto.HowManyFlats\r\n ? this.dealDto.HowManyFlats\r\n : 0;\r\n this.dealDto.HowManyHouses = this.dealDto.HowManyHouses\r\n ? this.dealDto.HowManyHouses\r\n : 0;\r\n }\r\n\r\n if (!this.shareDealDto) {\r\n this.shareDealDto = {\r\n DealName: this.sharedCriteriaService.defaultSearchName(\r\n this.dealDto.ProductType,\r\n ),\r\n } as ShareDealDTO;\r\n }\r\n }\r\n\r\n dummysearch() {\r\n this.dealDto.hasPostcode =\r\n this.sharedCriteriaService.getRandomIntInclusive(0, 1) == 1\r\n ? true\r\n : false;\r\n\r\n if (this.dealDto.hasPostcode) {\r\n this.dealDto.PostcodeSearchString =\r\n this.sharedCriteriaService.getRandomPostcode();\r\n this.getRegionByPostcode();\r\n } else {\r\n this.dealDto.Locations = LocationEnum.London;\r\n }\r\n\r\n this.dealDto.OwnOrPurchase =\r\n this.sharedCriteriaService.getRandomIntInclusive(0, 1) == 0\r\n ? OwnOrPurchaseEnum.Own\r\n : OwnOrPurchaseEnum.Purchasing;\r\n\r\n this.dealDto.PurchasePrice =\r\n this.sharedCriteriaService.getRandomIntInclusive(5000000, 10000000);\r\n\r\n if (this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Own) {\r\n this.dealDto.HasOwnOrPurchase = true;\r\n\r\n let date = new Date();\r\n date.setDate(\r\n date.getDate() -\r\n this.sharedCriteriaService.getRandomIntInclusive(1, 1000),\r\n );\r\n\r\n this.dealDto.OriginalPurchaseDate = date;\r\n this.dealDto.LandTotalOtherCosts =\r\n this.sharedCriteriaService.getRandomIntInclusive(10000, 100000);\r\n this.dealDto.Currentvalue =\r\n this.dealDto.PurchasePrice +\r\n this.sharedCriteriaService.getRandomIntInclusive(-10000, 5000000);\r\n } else {\r\n this.dealDto.HasOwnOrPurchase = false;\r\n this.dealDto.PurchaseCosts =\r\n this.sharedCriteriaService.getRandomIntInclusive(100000, 1000000);\r\n }\r\n\r\n this.dealDto.EndPropertyType =\r\n this.sharedCriteriaService.getRandomIntInclusive(0, 1) == 0\r\n ? PropertyTypeEnum.Residential\r\n : PropertyTypeEnum.MixedUse;\r\n\r\n if (this.dealDto.EndPropertyType == PropertyTypeEnum.MixedUse) {\r\n this.dealDto.CommercialGDV =\r\n this.sharedCriteriaService.getRandomIntInclusive(100000, 10000000);\r\n }\r\n\r\n this.dealDto.GrossInternalAreaKnown =\r\n this.sharedCriteriaService.getRandomIntInclusive(0, 1) == 0;\r\n\r\n if (this.dealDto.GrossInternalAreaKnown) {\r\n this.dealDto.AreaUnit =\r\n this.sharedCriteriaService.getRandomIntInclusive(0, 1) == 0\r\n ? AreaUnitEnum.SquareFeet\r\n : AreaUnitEnum.SquareMeters;\r\n var areaMultiplier =\r\n this.dealDto.AreaUnit == AreaUnitEnum.SquareMeters\r\n ? 1\r\n : this.areaConversionFactor;\r\n this.dealDto.AreaAcquisition =\r\n this.sharedCriteriaService.getRandomIntInclusive(\r\n 100 * areaMultiplier,\r\n 10000 * areaMultiplier,\r\n );\r\n this.dealDto.BuildCostPerArea =\r\n this.sharedCriteriaService.getRandomIntInclusive(\r\n 1000 / areaMultiplier,\r\n 10000 / areaMultiplier,\r\n );\r\n\r\n if (this.dealDto.AreaUnit == AreaUnitEnum.SquareFeet) {\r\n this.buildCostPerSqFt = this.dealDto.BuildCostPerArea;\r\n } else {\r\n this.buildCostPerSqM = this.dealDto.BuildCostPerArea;\r\n }\r\n\r\n this.updateBuildArea();\r\n } else {\r\n this.buildCostIntermediary =\r\n this.sharedCriteriaService.getRandomIntInclusive(100000, 100000000);\r\n }\r\n\r\n this.dealDto.IncludesContingency =\r\n this.sharedCriteriaService.getRandomIntInclusive(0, 1) == 0;\r\n this.dealDto.Contingency =\r\n this.sharedCriteriaService.getRandomIntInclusive(1, 30) / 100;\r\n this.updateContingency();\r\n\r\n this.dealDto.LoanTermReq = this.sharedCriteriaService.getRandomIntInclusive(\r\n 24,\r\n 100,\r\n );\r\n this.dealDto.GDV =\r\n this.dealDto.PurchasePrice +\r\n this.sharedCriteriaService.getRandomIntInclusive(-10000, 100000000);\r\n this.dealDto.MaxLoanRequired =\r\n this.sharedCriteriaService.getRandomIntInclusive(0, 1) == 0;\r\n\r\n if (this.dealDto.MaxLoanRequired == false) {\r\n this.dealDto.NetLoanRequired =\r\n this.sharedCriteriaService.getRandomIntInclusive(10000, 5000000);\r\n }\r\n }\r\n\r\n hasValidNetLoanRequiredValue() {\r\n if (\r\n !this.dealDto.MaxLoanRequired &&\r\n (this.dealDto.NetLoanRequired == null ||\r\n isNaN(this.dealDto.NetLoanRequired) ||\r\n this.dealDto.NetLoanRequired <= 0)\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n /*getRegionByPostcode() {\r\n if (\r\n /[a-zA-Z]/.test(this.dealDto.PostcodeSearchString) &&\r\n /[0-9]/.test(this.dealDto.PostcodeSearchString)\r\n ) {\r\n if (this.dealDto.PostcodeSearchString.replace(\" \", \"\").length <= 7) {\r\n this.dataLoading = true;\r\n this.dealService\r\n .getRegionByPostcode(this.dealDto.PostcodeSearchString)\r\n .then((response) => {\r\n if (response.Location != null) {\r\n this.dealDto.Locations = response.Location;\r\n this.showPostcodeErrorMessage = false;\r\n } else {\r\n this.postcodeErrorMsg = response.PostCodeErrorMessage;\r\n this.showPostcodeErrorMessage = true;\r\n this.dealDto.Locations = null;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.postcodeErrorMsg =\r\n \"Please enter a more specific postcode to identify the location\";\r\n this.showPostcodeErrorMessage = true;\r\n }\r\n } else {\r\n this.postcodeErrorMsg =\r\n \"At least one letter and one number must be entered e.g. SW1.\";\r\n this.showPostcodeErrorMessage = true;\r\n }\r\n }*/\r\n\r\n updateBuildArea(initial: boolean = false) {\r\n if (this.dealDto.AreaUnit == AreaUnitEnum.SquareFeet) {\r\n this.dealDto.BuildCostPerArea = this.buildCostPerSqFt;\r\n this.buildCostPerSqM = this.convertSqFtToSqM(this.buildCostPerSqFt);\r\n } else {\r\n this.dealDto.BuildCostPerArea = this.buildCostPerSqM;\r\n this.buildCostPerSqFt = this.convertSqMToSqFt(this.buildCostPerSqM);\r\n }\r\n\r\n if (!initial) {\r\n this.calculateBuildCostIntermediary();\r\n }\r\n }\r\n\r\n convertSqMToSqFt(costPerSqM: number): number {\r\n return costPerSqM / this.areaConversionFactor;\r\n }\r\n\r\n convertSqFtToSqM(costPerSqFt: number): number {\r\n return costPerSqFt * this.areaConversionFactor;\r\n }\r\n\r\n calculateBuildCostIntermediary() {\r\n if (\r\n this.dealDto.GrossInternalAreaKnown &&\r\n this.dealDto.BuildCostPerArea > 0 &&\r\n this.dealDto.AreaAcquisition > 0\r\n ) {\r\n this.buildCostIntermediary =\r\n this.dealDto.AreaAcquisition * this.dealDto.BuildCostPerArea;\r\n }\r\n this.calculateContingency();\r\n }\r\n\r\n calculateContingency() {\r\n if (this.dealDto.IncludesContingency) {\r\n this.contingencyValue =\r\n this.buildCostIntermediary -\r\n this.buildCostIntermediary / (1 + Number(this.dealDto.Contingency));\r\n } else {\r\n this.contingencyValue =\r\n this.buildCostIntermediary * this.dealDto.Contingency;\r\n }\r\n this.calculateTotalBuildCost();\r\n }\r\n\r\n calculateTotalBuildCost() {\r\n if (this.dealDto.IncludesContingency) {\r\n this.totalBuildCosts = this.buildCostIntermediary;\r\n this.dealDto.BuildCosts =\r\n Number(this.buildCostIntermediary) - this.contingencyValue;\r\n } else {\r\n this.totalBuildCosts =\r\n Number(this.buildCostIntermediary) + this.contingencyValue;\r\n this.dealDto.BuildCosts = Number(this.buildCostIntermediary);\r\n }\r\n\r\n this.calculateProfessionalCosts();\r\n }\r\n\r\n calculateProfessionalCosts() {\r\n if (this.multiPartForm1?.professionalCosts?.$dirty == false) {\r\n this.dealDto.AdditionalOngoingCosts =\r\n this.totalBuildCosts * this.defaultProfessionalCosts;\r\n }\r\n\r\n this.calculateTotalProjectCosts();\r\n }\r\n\r\n calculateTotalProjectCosts() {\r\n var totalCosts = 0;\r\n\r\n if (isNaN(Number(this.dealDto.AdditionalOngoingCosts)) == false) {\r\n totalCosts += Number(this.dealDto.AdditionalOngoingCosts);\r\n }\r\n\r\n if (isNaN(Number(this.totalBuildCosts)) == false) {\r\n totalCosts += Number(this.totalBuildCosts);\r\n }\r\n\r\n if (\r\n this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Own &&\r\n isNaN(Number(this.dealDto.LandTotalOtherCosts)) == false\r\n ) {\r\n totalCosts += Number(this.dealDto.LandTotalOtherCosts);\r\n }\r\n\r\n if (isNaN(Number(this.dealDto.PurchasePrice)) == false) {\r\n totalCosts += Number(this.dealDto.PurchasePrice);\r\n }\r\n\r\n if (\r\n this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Purchasing &&\r\n isNaN(Number(this.dealDto.PurchaseCosts)) == false\r\n ) {\r\n totalCosts += Number(this.dealDto.PurchaseCosts);\r\n }\r\n\r\n this.dealDto.TotalProjectCosts = totalCosts;\r\n }\r\n\r\n updateGIA() {\r\n this.calculateBuildCostIntermediary();\r\n }\r\n\r\n updateContingency() {\r\n this.calculateContingency();\r\n }\r\n\r\n toggleKnowsGIA() {\r\n this.dealDto.GrossInternalAreaKnown = !this.dealDto.GrossInternalAreaKnown;\r\n if (this.dealDto.GrossInternalAreaKnown == true) {\r\n this.dealDto.AreaUnit = AreaUnitEnum.SquareFeet;\r\n } else {\r\n this.dealDto.AreaAcquisition = null;\r\n this.dealDto.AreaUnit = null;\r\n this.buildCostPerSqFt = null;\r\n this.buildCostPerSqM = null;\r\n this.dealDto.BuildCostPerArea = null;\r\n }\r\n\r\n this.buildCostIntermediary = null;\r\n this.multiPartForm1.buildCostIntermediary.$setUntouched();\r\n this.updateContingency();\r\n }\r\n\r\n updateCalculatedFields() {\r\n this.reverseBuildCost();\r\n this.reverseBuildCostPerArea();\r\n this.updateBuildArea(true);\r\n this.updateContingency();\r\n }\r\n\r\n reverseBuildCostPerArea() {\r\n if (this.dealDto.AreaUnit == AreaUnitEnum.SquareFeet) {\r\n this.buildCostPerSqFt = this.dealDto.BuildCostPerArea;\r\n } else {\r\n this.buildCostPerSqM = this.dealDto.BuildCostPerArea;\r\n }\r\n }\r\n\r\n reverseBuildCost() {\r\n if (this.dealDto.IncludesContingency == true) {\r\n this.buildCostIntermediary =\r\n Math.round(\r\n this.dealDto.BuildCosts * (1 + this.dealDto.Contingency) * 100,\r\n ) / 100;\r\n } else {\r\n this.buildCostIntermediary = this.dealDto.BuildCosts;\r\n }\r\n }\r\n\r\n getRequiredRoles(isCaseDashboard: boolean) {\r\n if (isCaseDashboard) return `['Admin', 'Client', 'Broker', 'Introducer']`;\r\n return `['Admin', 'Client', 'Broker', 'Introducer', 'Lender']`;\r\n }\r\n\r\n /*onHasPostcodeChange() {\r\n if (!this.dealDto.hasPostcode) {\r\n this.showPostcodeErrorMessage = false;\r\n this.dealDto.PostcodeSearchString = null;\r\n this.dealDto.Locations = this.previouslySelectedLocation;\r\n } else {\r\n this.previouslySelectedLocation = this.dealDto.Locations;\r\n this.dealDto.Locations = null;\r\n }\r\n }*/\r\n\r\n isFieldEmpty(fieldName, isEnum = false) {\r\n if (this.isSubmitted && this.dealDto) {\r\n const fieldValue = this.dealDto[fieldName];\r\n if (fieldName == \"PlanningPermissionType\") {\r\n if (fieldValue == null || fieldValue < 1) {\r\n return true;\r\n }\r\n }\r\n if (fieldValue == null || (isEnum && fieldValue === \"0\")) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n isFieldZero(fieldName) {\r\n if (this.isSubmitted && this.dealDto) {\r\n const fieldValue = this.dealDto[fieldName];\r\n if (fieldValue == null || fieldValue === \"0\" || fieldValue === 0) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n showBasedOnMainResidence() {\r\n return this.dealService.showBasedOnMainResidence(this.dealDto);\r\n }\r\n\r\n clickNextButton() {\r\n if (this.progressSection == 1) {\r\n if (!this.isLoggedInUser && (this.$location.path().startsWith(\"/e/devfinancecriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n this.logEvent(\"DEVFINANCECRITERIA-PAGE2\");\r\n }\r\n this.progressSection = 2;\r\n } else {\r\n if (!this.isLoggedInUser && (this.$location.path().startsWith(\"/e/devfinancecriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n this.logEvent(\"DEVFINANCECRITERIA-PAGE3\");\r\n }\r\n this.progressSection = 3;\r\n }\r\n }\r\n\r\n clickBackButton() {\r\n if (this.progressSection == 3) {\r\n if (!this.isLoggedInUser && (this.$location.path().startsWith(\"/e/devfinancecriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n this.logEvent(\"DEVFINANCECRITERIA-PAGE2\");\r\n }\r\n this.progressSection = 2;\r\n } else {\r\n if (!this.isLoggedInUser && (this.$location.path().startsWith(\"/e/devfinancecriteria\") || this.$location.path().startsWith(\"/allloans\"))) {\r\n this.logEvent(\"DEVFINANCECRITERIA-PAGE1\");\r\n }\r\n this.progressSection = 1;\r\n }\r\n }\r\n\r\n isCriteriaFormInValid() {\r\n if (\r\n this.isSearchStarted ||\r\n this.multiPartForm1.$invalid ||\r\n this.dealDto.Locations == null ||\r\n this.dealDto.Locations <= 0 ||\r\n this.hasValidNetLoanRequiredValue() ||\r\n this.showPostcodeErrorMessage ||\r\n this.dealDto.GDV == null ||\r\n this.dealDto.GDV == 0\r\n ) {\r\n if (this.isSearchStarted) {\r\n this.progressAmount = \"100%\";\r\n } else {\r\n this.progressAmount = \"66%\";\r\n }\r\n return true;\r\n } else {\r\n this.progressAmount = \"100%\";\r\n return false;\r\n }\r\n }\r\n\r\n async logEventWithoutDealData() {\r\n if (window.self == window.top) {\r\n if (sessionStorage.getItem(\"clientId\")) {\r\n this.eventLogService.logPageLoad(\r\n \"DEVFINANCECRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.Development,\r\n \"\",\r\n 0,\r\n sessionStorage.getItem(\"clientId\"),\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n \"DEVFINANCECRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.Development,\r\n );\r\n }\r\n } else {\r\n var clientId: string = null;\r\n clientId = await this.organisationService.getData(\"clientId\");\r\n\r\n if (clientId) {\r\n this.eventLogService.logPageLoad(\r\n \"DEVFINANCECRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.Development,\r\n \"\",\r\n 0,\r\n clientId,\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n \"DEVFINANCECRITERIA\",\r\n this.orgCode,\r\n \"\",\r\n \"Client\",\r\n this.$routeParams.linkId ? this.$routeParams.linkId : null,\r\n ProductTypeEnum.Development,\r\n );\r\n }\r\n }\r\n }\r\n\r\n getOriginatorInfoForUser() {\r\n if (this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Admin;\r\n this.dealDto.SourceType = DealSourceTypeEnum.Application;\r\n } else if (this.isBroker && !this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Broker;\r\n } else if (this.isBorrower && !this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Borrower;\r\n } else if (this.isLender && !this.isAdmin) {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Lender;\r\n this.dealDto.SourceType = DealSourceTypeEnum.Application;\r\n }\r\n\r\n if (window.self == window.top) {\r\n\r\n if (this.isLender) {\r\n this.userService.getCurrentUserLender().then((response) => {\r\n this.dealDto.OriginatorLenderId = response;\r\n });\r\n }\r\n\r\n if (this.isBroker || this.isBorrower) {\r\n this.organisationService.getOrganisation().then((org) => {\r\n if (org != null) {\r\n if (org.Id != 0) this.dealDto.OriginatorOrganisationId = org.Id;\r\n this.dealDto.SourceType = org.IsWhiteLabelled\r\n ? DealSourceTypeEnum.WhitelabelApplication\r\n : DealSourceTypeEnum.Application;\r\n }\r\n });\r\n }\r\n\r\n\r\n }\r\n }\r\n\r\n getOriginatorInfoForAnonymousUsers() {\r\n this.dealDto.OriginatorRoleType = OriginatorRoleTypeEnum.Borrower;\r\n\r\n if (window.self == window.top) {\r\n this.dealDto.SourceType = DealSourceTypeEnum.Enterprise;\r\n } else {\r\n this.dealDto.SourceType = this.isWidget ? DealSourceTypeEnum.WidgetEnterprise : DealSourceTypeEnum.IFrameEnterprise;\r\n }\r\n\r\n if (this.$routeParams.linkId) {\r\n if (window.self == window.top) {\r\n this.dealDto.SourceType = DealSourceTypeEnum.UniqueLink;\r\n } else {\r\n this.dealDto.SourceType = this.isWidget ? this.$routeParams.linkId == \"0\"? DealSourceTypeEnum.WidgetEnterprise: DealSourceTypeEnum.WidgetUniqueLink : DealSourceTypeEnum.IFrameUniqueLink;\r\n }\r\n }\r\n }\r\n\r\n getRequiredRolesOptions(){\r\n return this.dealService.getRequiredRolesOptions();\r\n }\r\n}\r\n","import { AssistanceSliderComponentController } from \"../components/assistance-slider/assistance-slider\";\r\nimport { BreadcrumbTabsComponentController } from \"../components/breadcrumb-tabs/breadcrumb-tabs\";\r\nimport { CarouselComponentController } from \"../components/carousel/carousel\";\r\nimport { ModalPopupComponentController } from \"../components/modal-popup/modal-popup\";\r\nimport { PaymentToggleController } from \"../components/payment-toggle/payment-toggle\";\r\nimport { RegInfoPanelController } from \"../components/registration-info-panel/reg-info-panel\";\r\nimport { SpinnerController } from \"../components/spinner/spinner\";\r\nimport { TourPopupComponentController } from \"../components/tour-popup/tour-popup\";\r\nimport { VerticalProgressBarController } from \"../components/vertical-progress-bar/vertical-progress-bar\";\r\nimport { BridgingCriteriaController } from \"./controllers/BridgingCriteriaController\";\r\nimport { CommercialCriteriaController } from \"./controllers/CommercialCriteriaController\";\r\nimport { DevFinanceCriteriaController } from \"./controllers/DevFinanceCriteriaController\";\r\n\r\nexport function registerComponents() {\r\n angular\r\n .module(\"ccqapp\")\r\n .component(\"assistanceSlider\", {\r\n bindings: {},\r\n controller: [\r\n \"$location\",\r\n \"LenderService\",\r\n AssistanceSliderComponentController,\r\n ],\r\n templateUrl: \"components/assistance-slider/assistance-slider.html\",\r\n transclude: true,\r\n })\r\n .component(\"breadcrumbTabs\", {\r\n bindings: {\r\n toggleModal: \"=\",\r\n loading: \"=\",\r\n },\r\n controller: [\"$window\", BreadcrumbTabsComponentController],\r\n templateUrl: \"components/breadcrumb-tabs/breadcrumb-tabs.html\",\r\n transclude: true,\r\n })\r\n .component(\"carousel\", {\r\n bindings: {\r\n carouselData: \"<\",\r\n carouselStep: \"<\",\r\n },\r\n controller: [\"$interval\", CarouselComponentController],\r\n templateUrl: \"components/carousel/carousel.html\",\r\n transclude: true,\r\n })\r\n .component(\"modalPopup\", {\r\n bindings: {\r\n toggleModal: \"=\",\r\n loading: \"=\",\r\n formSectionNames: \"<\",\r\n step: \"=\",\r\n closeOnBlur: \"=\",\r\n },\r\n controller: [\"$element\", \"$scope\", ModalPopupComponentController],\r\n templateUrl: \"components/modal-popup/modal-popup.html\",\r\n transclude: true,\r\n })\r\n .component(\"paymentToggle\", {\r\n bindings: {\r\n ngModel: \"=\",\r\n ngChange: \"&\",\r\n },\r\n controller: [\"$rootScope\", \"$element\", PaymentToggleController],\r\n templateUrl: \"components/payment-toggle/payment-toggle.html\",\r\n transclude: true,\r\n })\r\n .component(\"regInfoPanel\", {\r\n bindings: {\r\n heading: \"@\",\r\n subheading: \"@\",\r\n mainheading: \"@\",\r\n },\r\n controller: [\"$rootScope\", \"$element\", RegInfoPanelController],\r\n templateUrl: \"components/registration-info-panel/reg-info-panel.html\",\r\n transclude: true,\r\n })\r\n .component(\"spinner\", {\r\n bindings: {\r\n minValue: \"@\",\r\n maxValue: \"@\",\r\n value: \"=\",\r\n },\r\n controller: [\"$rootScope\", \"$element\", SpinnerController],\r\n templateUrl: \"components/spinner/spinner.html\",\r\n transclude: true,\r\n })\r\n .component(\"tourPopup\", {\r\n bindings: {\r\n tourOrder: \"@\",\r\n tourState: \"<\",\r\n stepEnabled: \"<\",\r\n },\r\n controller: [\"$rootScope\", \"$element\", TourPopupComponentController],\r\n templateUrl: \"components/tour-popup/tour-popup.html\",\r\n transclude: true,\r\n })\r\n .component(\"verticalProgressBar\", {\r\n bindings: {\r\n nodes: \"=\",\r\n currentStep: \"@\",\r\n },\r\n controller: [\"$rootScope\", \"$element\", VerticalProgressBarController],\r\n templateUrl:\r\n \"components/vertical-progress-bar/vertical-progress-bar.html\",\r\n transclude: true,\r\n })\r\n .component(\"bridgingCriteria\", {\r\n controller: BridgingCriteriaController,\r\n templateUrl: \"components/bridging-criteria/bridging-criteria.html\",\r\n transclude: true,\r\n controllerAs: \"ctrl\",\r\n })\r\n .component(\"commercialCriteria\", {\r\n controller: CommercialCriteriaController,\r\n templateUrl: \"components/commercial-criteria/commercial-criteria.html\",\r\n transclude: true,\r\n controllerAs: \"ctrl\",\r\n })\r\n .component(\"devfinanceCriteria\", {\r\n controller: DevFinanceCriteriaController,\r\n templateUrl: \"components/devfinance-criteria/devfinance-criteria.html\",\r\n transclude: true,\r\n controllerAs: \"ctrl\",\r\n });\r\n}\r\n","import { AccountDTO } from \"@js/DTO/AccountDTO.cs.d\";\r\nimport { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AccountService } from \"@js/services/AccountService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\n\r\nexport class AccountsController {\r\n user: ApplicationUserDTO;\r\n performingAction: boolean;\r\n selectedAccount: AccountDTO;\r\n accounts: AccountDTO[];\r\n account: AccountDTO;\r\n photoUploadProgress: number;\r\n import1Message: string = null;\r\n import2Message: string = null;\r\n uploadingPhoto: boolean;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"AuthService\",\r\n \"AccountService\",\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private $auth: AuthService,\r\n private $account: AccountService,\r\n ) {\r\n this.performingAction = false;\r\n\r\n this.selectedAccount = null;\r\n\r\n //get all the accounts back\r\n this.FetchAccounts();\r\n }\r\n selectAccount(account: AccountDTO) {\r\n this.selectedAccount = account;\r\n }\r\n\r\n createAccount(): void {\r\n this.selectedAccount = { AccountName: \"New Account\" };\r\n }\r\n\r\n FetchAccounts(): void {\r\n this.performingAction = true;\r\n this.$account\r\n .fetchAll()\r\n .then((response) => {\r\n this.accounts = response;\r\n this.performingAction = false;\r\n })\r\n .catch((response) => {\r\n this.performingAction = false;\r\n });\r\n }\r\n\r\n deleteAccount(): void {\r\n this.$account.delete(this.selectedAccount.Id).then((result: boolean) => {\r\n this.accounts.splice(this.accounts.indexOf(this.selectedAccount), 1);\r\n // this.$toaster.pop('success', \"Deleted account!\", \"The account has been removed from the system.\");\r\n delete this.selectedAccount;\r\n });\r\n }\r\n\r\n updateAccount(): void {\r\n this.performingAction = true;\r\n\r\n this.$account\r\n .addUpdatereturnonlyid(this.selectedAccount)\r\n .then((recID: number) => {\r\n this.performingAction = false;\r\n this.selectedAccount.Id = recID;\r\n if (this.selectedAccount.Id === undefined) {\r\n this.accounts.push(this.selectedAccount);\r\n // this.$toaster.pop('success', \"Created new account!\", this.selectedAccount.AccountName + \" has been added to the system.\");\r\n } else {\r\n // this.$toaster.pop('success', \"Updated account!\", this.selectedAccount.AccountName + \" has been updated.\");\r\n }\r\n });\r\n }\r\n}\r\n","export const enum BillingFrequencyEnum {\r\n Monthly = 1,\r\n Yearly = 2,\r\n OneOff = 3,\r\n None = 4,\r\n}\r\n","export const enum ContractLengthEnum {\r\n None = 0,\r\n Yearly = 1,\r\n TwoYearly = 2,\r\n}\r\n","export const enum PricingFrequencyEnum {\r\n Monthly = 1,\r\n Yearly = 2,\r\n OneOff = 3,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AppPackagePricingDTO } from \"@js/DTO/AppPackagePricingDTO.cs.d\";\r\nimport { LicenseAppPackageDTO } from \"@js/DTO/LicenseAppPackageDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { BillingFrequencyEnum } from \"@js/models/enum/BillingFrequencyEnum.cs.d\";\r\nimport { ContractLengthEnum } from \"@js/models/enum/ContractLengthEnum.cs.d\";\r\nimport { LicenseMasterStatusEnum } from \"@js/models/enum/LicenseMasterStatusEnum.cs.d\";\r\nimport { PricingFrequencyEnum } from \"@js/models/enum/PricingFrequencyEnum.cs.d\";\r\nimport { TeamSizeEnum } from \"@js/models/enum/TeamSizeEnum.cs.d\";\r\nimport { UserRoleEnum } from \"@js/models/enum/UserRoleEnum.cs.d\";\r\nimport { AccountSettingService } from \"@js/services/AccountSettingsService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class AccountSettingsController {\r\n selectedTab: string;\r\n noMoreMails: boolean;\r\n\r\n //Brokers\r\n organisationAdminId: string;\r\n organisationAdmin: ApplicationUserDTO;\r\n organisationAdminUsername: string;\r\n organisationUsers: ApplicationUserDTO[];\r\n organisationUsersExceptAdmin: ApplicationUserDTO[] = [];\r\n userOrganisation: OrganisationDTO;\r\n selectedBroker: ApplicationUserDTO;\r\n currentPassword: string;\r\n newPassword: string;\r\n repeatPassword: string;\r\n\r\n newEmail: string;\r\n repeatEmail: string;\r\n\r\n passwordUpdated: boolean;\r\n emailUpdated: boolean;\r\n allActiveAppPackagePrices: AppPackagePricingDTO[];\r\n allActiveAppPackagePricesForFrequency: AppPackagePricingDTO[];\r\n selectedLicenseAppPackagePrice: LicenseAppPackageDTO;\r\n selectedProduct: AppPackagePricingDTO = null;\r\n\r\n assignedLicense: AppPackagePricingDTO = null;\r\n\r\n isBroker: boolean;\r\n message: string;\r\n showMsgModal: boolean = false;\r\n showBrokerUsers: boolean = false;\r\n addBrokerUsers: boolean = false;\r\n addCustomPrice: boolean = false;\r\n changeInQuantity: boolean = false;\r\n isSelected: boolean = false;\r\n showAssignLicense: boolean = false;\r\n numberOfAssignedLicenses: number = 1;\r\n selectedPricingFrequency: boolean = false;\r\n selectedPricingFrequencyEnum: PricingFrequencyEnum =\r\n PricingFrequencyEnum.Monthly;\r\n showAlertmsg: boolean = false;\r\n showCancelModel: boolean = false;\r\n newBrokerUser: ApplicationUserDTO = {\r\n Id: \"\",\r\n Roles: [\"Introducer\", \"Broker\"],\r\n } as ApplicationUserDTO;\r\n assignLicenseForm: ng.IFormController;\r\n assignCustompriceForm: ng.IFormController;\r\n remaningLicense: number = 0;\r\n dataLoading: boolean = false;\r\n isUpdateClicked: boolean = false;\r\n isSignUpClicked: boolean = false;\r\n selectedUserRole: UserRoleEnum = UserRoleEnum.None;\r\n isAdmin: boolean = false;\r\n selectedOrganisationId: number;\r\n selectedUser: ApplicationUserDTO;\r\n selectedUserName: string = \"\";\r\n currentUser: ApplicationUserDTO;\r\n\r\n //Additional info\r\n additionalInfoText: string;\r\n CurrentTotalAmountToPay: number = 0;\r\n totalAmountToPay: number = 0;\r\n showIncreasingQuantityModal: boolean = false;\r\n showdescringQuantityModal: boolean = false;\r\n customePrice: string;\r\n numberOfLicense: number = 0;\r\n showCustomePricesuccessModal: boolean = false;\r\n newAmountInfoText: string;\r\n showNewAmount: boolean = false;\r\n isCustomPriceApplied: boolean = false;\r\n orderButtonText: string = \"Update\";\r\n orderButtonDisabled: boolean = false;\r\n showOrderButton: boolean = false;\r\n showCancelButton: boolean = false;\r\n billingCycle: PricingFrequencyEnum.Monthly;\r\n\r\n billingFrequencyOptions = [];\r\n teamSizeOptions = [];\r\n leadGenPackage: LicenseAppPackageDTO;\r\n selectedleadGenPackage: LicenseAppPackageDTO;\r\n isAddOnPaid: boolean = false;\r\n isContractChanged: boolean = false;\r\n alertMsg: string;\r\n isAddOnSelected: boolean = false;\r\n whitelabelPrice: number = 0;\r\n showWhiteLabelModal: boolean = false;\r\n newTotalPayment: number = 0;\r\n isSettingPage: boolean = true;\r\n endDate: Date;\r\n\r\n showLeadGenUrlModal: boolean = false;\r\n showLeadGenCancellationModal: boolean = false;\r\n leadGeneratorName: string;\r\n isLegacyLicense: boolean = false;\r\n licenseStatusText: string;\r\n reloadPage: boolean = false;\r\n whiteLabelledUrl: string = \"\";\r\n isMonthlySubscription: boolean = true;\r\n isPageReloadAfterCustomePrice: boolean = false;\r\n\r\n copyPaymentlink: boolean = false;\r\n companyEmailAddress: string;\r\n static $inject = [\r\n \"$http\",\r\n \"$cookies\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n \"PaymentService\",\r\n \"AccountSettingService\",\r\n \"UserService\",\r\n \"OrganisationService\",\r\n \"$routeParams\",\r\n \"$location\",\r\n \"SelectListService\",\r\n ];\r\n\r\n constructor(\r\n private $http: ng.IHttpService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $auth: AuthService,\r\n private $roleService: RoleService,\r\n private $paymentService: PaymentService,\r\n private $accountSettingService: AccountSettingService,\r\n private userService: UserService,\r\n private $organisationService: OrganisationService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private selectListService: SelectListService,\r\n ) {\r\n this.billingFrequencyOptions =\r\n this.selectListService.GetBillingFrequencyOptions();\r\n this.teamSizeOptions = this.selectListService.GetTeamSizeOptions();\r\n this.getWhiteLabelledUrl();\r\n\r\n this.$auth.getCompanyContactUsEmailAddresss().then((response) => {\r\n this.companyEmailAddress = response;\r\n });\r\n\r\n this.$roleService.isAdminUser().then((response) => {\r\n this.isAdmin = response;\r\n\r\n if (this.$routeParams.userId && this.isAdmin) {\r\n this.userService\r\n .getUserByUserId(this.$routeParams.userId)\r\n .then((response) => {\r\n this.selectedUser = response;\r\n this.selectedUserName = this.selectedUser.UserName;\r\n this.getSelectedPackagesForCurrentuser(this.selectedUserName);\r\n\r\n if (this.selectedUser.IsOrganisationAdmin) {\r\n this.selectedOrganisationId = this.selectedUser.OrganisationId;\r\n this.organisationAdminUsername = this.selectedUser.UserName;\r\n this.$organisationService\r\n .fetch(this.selectedUser.OrganisationId)\r\n .then((organisation) => {\r\n this.userOrganisation = organisation;\r\n this.isAddOnSelected\r\n ? (this.isAddOnPaid = organisation.HasWhiteLabelAddOnPaid)\r\n : (this.isAddOnPaid = this.isAddOnSelected =\r\n organisation.HasWhiteLabelAddOnPaid);\r\n })\r\n .then(() => {\r\n this.getLicenseStatusText();\r\n this.getBrokerUsers(this.selectedOrganisationId);\r\n });\r\n\r\n this.selectedUserRole = UserRoleEnum.Broker;\r\n } else {\r\n this.selectedUserRole = UserRoleEnum.Client;\r\n }\r\n });\r\n } else {\r\n this.$auth.getUpdatedProfile().then((response) => {\r\n this.currentUser = this.selectedUser = response;\r\n this.selectedUserName = this.currentUser.UserName;\r\n this.getSelectedPackagesForCurrentuser(this.currentUser.UserName);\r\n this.getCurrentOrganisation();\r\n });\r\n }\r\n });\r\n\r\n this.selectedTab = this.$routeParams.selectedTab\r\n ? this.$routeParams.selectedTab\r\n : \"license\";\r\n this.leadGeneratorName = this.$cookies.get(\"leadgeneratorname\");\r\n }\r\n\r\n getCurrentOrganisation() {\r\n this.$organisationService.getOrganisation().then((response) => {\r\n this.userOrganisation = response;\r\n this.isAddOnSelected\r\n ? (this.isAddOnPaid = response.HasWhiteLabelAddOnPaid)\r\n : (this.isAddOnPaid = this.isAddOnSelected =\r\n response.HasWhiteLabelAddOnPaid);\r\n this.selectedOrganisationId = this.userOrganisation.Id;\r\n this.getBrokerUsers(this.selectedOrganisationId);\r\n });\r\n }\r\n\r\n getBrokerUsers(orgId): void {\r\n this.userService.getAllOrganisationMembers(orgId).then((response) => {\r\n this.organisationUsers = response;\r\n this.numberOfAssignedLicenses = this.organisationUsers.filter(\r\n (e) => e.SubscriptionStatus > 0,\r\n ).length;\r\n if (\r\n this.selectedLicenseAppPackagePrice &&\r\n this.selectedLicenseAppPackagePrice.Status !=\r\n LicenseMasterStatusEnum.PreSubscription &&\r\n this.selectedLicenseAppPackagePrice.Status !=\r\n LicenseMasterStatusEnum.None\r\n )\r\n this.remaningLicense =\r\n this.selectedLicenseAppPackagePrice.TotalQuantity -\r\n this.numberOfAssignedLicenses;\r\n });\r\n this.userService.getOrganisationNonAdminUsers(orgId).then((response) => {\r\n this.organisationUsersExceptAdmin = response;\r\n });\r\n }\r\n\r\n applyEmailChange() {\r\n if (\r\n this.newEmail &&\r\n this.repeatEmail &&\r\n this.newEmail === this.repeatEmail\r\n ) {\r\n this.$auth.changeEmail(this.newEmail).then((response) => {\r\n delete this.newEmail;\r\n delete this.repeatEmail;\r\n this.emailUpdated = true;\r\n this.$roleService.goHomeBasedOnUser();\r\n });\r\n }\r\n }\r\n applyPasswordChange() {\r\n if (\r\n this.newPassword &&\r\n this.repeatPassword &&\r\n this.newPassword === this.repeatPassword\r\n ) {\r\n this.$auth\r\n .changePassword(this.currentPassword, this.newPassword)\r\n .then((response) => {\r\n delete this.currentPassword;\r\n delete this.newPassword;\r\n delete this.repeatPassword;\r\n this.passwordUpdated = true;\r\n this.$roleService.goHomeBasedOnUser();\r\n });\r\n }\r\n }\r\n\r\n getAssignedPackage(userName) {\r\n this.$paymentService\r\n .getAllActivePackagePrices(userName)\r\n .then((response) => {\r\n this.allActiveAppPackagePrices = response;\r\n if (\r\n this.selectedLicenseAppPackagePrice &&\r\n this.selectedLicenseAppPackagePrice.Status !=\r\n LicenseMasterStatusEnum.PreSubscription &&\r\n this.selectedLicenseAppPackagePrice.Status !=\r\n LicenseMasterStatusEnum.None\r\n ) {\r\n var selectedProduct = this.allActiveAppPackagePrices.filter(\r\n (o1) =>\r\n o1.AppPackageId ===\r\n this.selectedLicenseAppPackagePrice.AppPackageId &&\r\n o1.PricingFrequency ===\r\n this.selectedLicenseAppPackagePrice.BillingFrequency &&\r\n o1.ContractLength ==\r\n this.selectedLicenseAppPackagePrice.ContractLength,\r\n );\r\n if (selectedProduct.length > 0) {\r\n this.selectedProduct = selectedProduct.map(\r\n (e) => ((e.Quantity = this.quantity(e.AppPackageId)), e),\r\n )[0];\r\n\r\n this.isMonthlySubscription =\r\n this.selectedProduct.PricingFrequency ==\r\n PricingFrequencyEnum.Monthly\r\n ? true\r\n : false;\r\n\r\n if (this.hasLegacyLicense()) {\r\n this.selectedProduct.PriceAmount =\r\n this.selectedProduct.PricingFrequency ==\r\n PricingFrequencyEnum.Monthly\r\n ? 35\r\n : 350;\r\n this.isLegacyLicense = true;\r\n }\r\n\r\n this.getAddOnPrice(this.selectedProduct.PricingFrequency);\r\n this.getEndDate(this.selectedLicenseAppPackagePrice.ActiveFromDate);\r\n\r\n if (\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaidUp ||\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaymentProcessing ||\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PreCancel\r\n ) {\r\n this.assignedLicense = JSON.parse(\r\n JSON.stringify(this.selectedProduct),\r\n );\r\n }\r\n }\r\n } else {\r\n this.selectedProduct = this.allActiveAppPackagePrices[0];\r\n }\r\n });\r\n }\r\n\r\n getSelectedPackagesForCurrentuser(userName: string = \"\") {\r\n this.$accountSettingService\r\n .getSelectedPackagesForCurrentuser(userName)\r\n .then((response) => {\r\n if (response != null) {\r\n this.selectedLicenseAppPackagePrice = response.find(\r\n (p) => !p.AppPackageDto.IsLeadGenerator,\r\n );\r\n this.selectedleadGenPackage = response.find(\r\n (p) => p.AppPackageDto.IsLeadGenerator,\r\n );\r\n }\r\n //Code Review\r\n if (\r\n this.selectedLicenseAppPackagePrice != null &&\r\n this.selectedLicenseAppPackagePrice.PricePerLicense != 0 &&\r\n this.selectedLicenseAppPackagePrice.Status !=\r\n LicenseMasterStatusEnum.None\r\n ) {\r\n if (\r\n this.selectedLicenseAppPackagePrice.TotalPricePerCycle >\r\n this.selectedLicenseAppPackagePrice.PricePerLicense *\r\n this.selectedLicenseAppPackagePrice.TotalQuantity\r\n ) {\r\n this.isAddOnSelected = true;\r\n }\r\n }\r\n\r\n this.getAssignedPackage(userName);\r\n var pricingFrequency = this.selectedLicenseAppPackagePrice\r\n ? this.selectedLicenseAppPackagePrice.BillingFrequency\r\n : PricingFrequencyEnum.Monthly;\r\n\r\n if (this.selectedLicenseAppPackagePrice != null) {\r\n this.selectedPricingFrequency =\r\n this.selectedLicenseAppPackagePrice &&\r\n this.selectedLicenseAppPackagePrice?.BillingFrequency ==\r\n BillingFrequencyEnum.Monthly\r\n ? false\r\n : true;\r\n if (this.selectedLicenseAppPackagePrice.IsCustomPriceApplied) {\r\n this.isCustomPriceApplied = true;\r\n }\r\n }\r\n\r\n this.getActivePackagePricesForFrequency(pricingFrequency);\r\n });\r\n }\r\n\r\n getActivePackagePricesForFrequency(pricingFrequency) {\r\n this.$paymentService\r\n .getActivePackagePricesForFrequency(\r\n pricingFrequency,\r\n this.selectedUserRole,\r\n )\r\n .then((response) => {\r\n if (\r\n this.selectedLicenseAppPackagePrice &&\r\n this.selectedLicenseAppPackagePrice.Status !=\r\n LicenseMasterStatusEnum.None &&\r\n this.selectedLicenseAppPackagePrice.Status !=\r\n LicenseMasterStatusEnum.PreSubscription &&\r\n this.selectedLicenseAppPackagePrice.Status !=\r\n LicenseMasterStatusEnum.Cancelled\r\n ) {\r\n this.allActiveAppPackagePricesForFrequency = response.filter(\r\n (al) =>\r\n this.returnContractLength(al.ContractLength) >=\r\n this.returnContractLength(\r\n this.selectedLicenseAppPackagePrice.ContractLength,\r\n ),\r\n );\r\n this.getAddOnPrice(pricingFrequency);\r\n } else {\r\n this.allActiveAppPackagePricesForFrequency = response;\r\n this.getAddOnPrice(\r\n this.selectedPricingFrequency == false\r\n ? PricingFrequencyEnum.Monthly\r\n : PricingFrequencyEnum.Yearly,\r\n );\r\n }\r\n });\r\n }\r\n\r\n callGetActivePackagePricesForFrequency() {\r\n var pricingFrequency: PricingFrequencyEnum =\r\n this.selectedPricingFrequency == false\r\n ? PricingFrequencyEnum.Monthly\r\n : PricingFrequencyEnum.Yearly;\r\n this.getActivePackagePricesForFrequency(pricingFrequency);\r\n }\r\n\r\n quantity(packageId) {\r\n var found = this.selectedLicenseAppPackagePrice.AppPackageId == packageId;\r\n\r\n if (found) {\r\n return this.selectedLicenseAppPackagePrice.TotalQuantity;\r\n } else {\r\n return 1;\r\n }\r\n }\r\n\r\n convertEnumToString(value) {\r\n switch (value) {\r\n case PricingFrequencyEnum.Monthly:\r\n return \"month\";\r\n case PricingFrequencyEnum.Yearly:\r\n return \"year\";\r\n default:\r\n return \"\";\r\n }\r\n }\r\n\r\n returnSubscriptionStatus(value) {\r\n switch (value) {\r\n case LicenseMasterStatusEnum.PaidUp:\r\n case LicenseMasterStatusEnum.PreCancel:\r\n return \"Paid Up\";\r\n case LicenseMasterStatusEnum.PayFailure:\r\n return \"Pay Failure\";\r\n case LicenseMasterStatusEnum.Cancelled:\r\n return \"Cancelled\";\r\n case LicenseMasterStatusEnum.Unpaid:\r\n return \"Unpaid\";\r\n case LicenseMasterStatusEnum.PaymentProcessing:\r\n return \"Payment Processing\";\r\n case LicenseMasterStatusEnum.Trial:\r\n return \"Trial\";\r\n default:\r\n return \"Unsubscribed\";\r\n }\r\n }\r\n\r\n /*isUpdateRequired() {\r\n if (this.isBroker) {\r\n if (this.selectedProduct && this.oldProduct) {\r\n if (this.selectedProduct != this.oldProduct) {\r\n return this.changeInProduct(true);\r\n } else {\r\n if (this.selectedProduct[0].AppPackageId != this.oldProduct[0].AppPackageId) {\r\n return true;\r\n } else {\r\n if (this.selectedProduct[0].Quantity != this.oldProduct[0].Quantity) {\r\n return this.changeInProduct(true);\r\n } else {\r\n return this.changeInProduct(false);\r\n }\r\n }\r\n\r\n }\r\n } else if (this.selectedProduct != this.oldProduct) {\r\n return this.changeInProduct(true);\r\n }\r\n }\r\n }*/\r\n\r\n managePayment() {\r\n this.$paymentService.createPortalSession().then((response) => {\r\n window.open(response);\r\n });\r\n }\r\n\r\n onClickOfCancel() {\r\n if (\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaymentProcessing &&\r\n !this.isDirectDebitActive(\r\n this.selectedLicenseAppPackagePrice.ActiveFromDate,\r\n )\r\n ) {\r\n return;\r\n }\r\n\r\n this.$paymentService\r\n .isSubscriptionCancelable(\r\n this.selectedLicenseAppPackagePrice.ExternalSubscriptionRef,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n this.showCancelModel = true;\r\n } else {\r\n this.showAlertmsg = true;\r\n this.alertMsg =\r\n \"Sorry, you can not cancel your subscription at this time since you have committed to a \" +\r\n this.getContractLengthText(\r\n this.assignedLicense.PricingFrequency,\r\n this.assignedLicense.ContractLength,\r\n );\r\n }\r\n });\r\n }\r\n\r\n cancelSubscription(subscriptionId, isLeadGeneratorLicense = false) {\r\n this.dataLoading = true;\r\n this.showCancelModel = false;\r\n this.showLeadGenCancellationModal = false;\r\n this.$paymentService\r\n .cancelSubscription(subscriptionId)\r\n .then((response) => {\r\n this.message = `Your subscription has been successfully cancelled however, you can continue to enjoy using the application until ${response}`;\r\n if (isLeadGeneratorLicense) {\r\n this.selectedleadGenPackage.Status =\r\n LicenseMasterStatusEnum.PreCancel;\r\n } else {\r\n this.selectedLicenseAppPackagePrice.Status =\r\n LicenseMasterStatusEnum.PreCancel;\r\n }\r\n })\r\n .catch(() => {\r\n this.message =\r\n \"There is problem cancelling the subscription, Please try later.\";\r\n })\r\n .finally(() => {\r\n this.showMsgModal = true;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n unCancelSubscription(subscriptionId, isLeadGeneratorLicense = false) {\r\n this.dataLoading = true;\r\n this.$paymentService\r\n .unCancelSubscription(subscriptionId)\r\n .then((response) => {\r\n this.message = `You have successfully renewed your subscription.`;\r\n if (isLeadGeneratorLicense) {\r\n this.selectedleadGenPackage.Status = LicenseMasterStatusEnum.PaidUp;\r\n } else {\r\n this.selectedLicenseAppPackagePrice.Status =\r\n LicenseMasterStatusEnum.PaidUp;\r\n }\r\n })\r\n .catch(() => {\r\n this.message =\r\n \"There is problem renewing your subscription, Please try later.\";\r\n })\r\n .finally(() => {\r\n this.showMsgModal = true;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n /*getLicense(selectedUserName) {\r\n this.$paymentService.getLicense(selectedUserName).then((response) => {\r\n this.licenseData = response;\r\n });\r\n }*/\r\n\r\n isPackageSelected(selectedProduct) {\r\n if (selectedProduct && this.selectedProduct) {\r\n var found = this.selectedProduct.Id == selectedProduct.Id;\r\n\r\n if (found) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n isAssignedproduct(product) {\r\n if (product && this.assignedLicense) {\r\n var found = this.assignedLicense.Id == product.Id;\r\n\r\n if (found) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n confirmUpdateSubscription() {\r\n this.message = ``;\r\n if (this.isAddOnPaid && !this.isAddOnSelected) {\r\n if (this.assignedLicense.Quantity == this.selectedProduct.Quantity) {\r\n this.onClickOfAddOnRemove();\r\n return;\r\n } else {\r\n this.message += `You are removing whitelabelling from your subscription. `;\r\n }\r\n } else if (!this.isAddOnPaid && this.isAddOnSelected) {\r\n this.message += `You are adding whitelabelling to your subscription. `;\r\n }\r\n if (this.assignedLicense.Quantity < this.selectedProduct.Quantity) {\r\n this.message += `You are increasing the number of licenses from ${\r\n this.assignedLicense.Quantity\r\n } to ${this.selectedProduct.Quantity} and your ${\r\n this.selectedProduct.PricingFrequency == PricingFrequencyEnum.Monthly\r\n ? \"Monthly\"\r\n : \"Yearly\"\r\n } payment will increase from £${\r\n this.assignedLicense.Quantity * this.assignedLicense.PriceAmount\r\n } to £${\r\n this.selectedProduct.Quantity * this.selectedProduct.PriceAmount\r\n }. Click Proceed to apply this change.`;\r\n this.showIncreasingQuantityModal = true;\r\n } else if (this.assignedLicense.Quantity > this.selectedProduct.Quantity) {\r\n this.message += `You are decreasing the number of licenses from ${this.assignedLicense.Quantity} to ${this.selectedProduct.Quantity}. Are you sure you wish to continue?`;\r\n this.showdescringQuantityModal = true;\r\n } else {\r\n this.showIncreasingQuantityModal = true;\r\n }\r\n }\r\n\r\n updateSubscription() {\r\n this.dataLoading = true;\r\n this.isUpdateClicked = true;\r\n\r\n const updateSubscriptionPromise =\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PreCancel\r\n ? this.$accountSettingService.updatePreCancelSubscription(\r\n [this.selectedProduct],\r\n this.selectedUserName,\r\n this.isAddOnSelected,\r\n true,\r\n )\r\n : this.$accountSettingService.updateSubscription(\r\n [this.selectedProduct],\r\n this.selectedUserName,\r\n this.isAddOnSelected,\r\n );\r\n\r\n updateSubscriptionPromise\r\n .then((response) => {\r\n this.assignedLicense = JSON.parse(JSON.stringify(this.selectedProduct));\r\n if (this.isLegacyLicense) {\r\n if (this.assignedLicense.ContractLength != ContractLengthEnum.None) {\r\n this.isLegacyLicense = false;\r\n }\r\n }\r\n this.numberOfLicense = this.assignedLicense.Quantity;\r\n this.remaningLicense =\r\n this.assignedLicense.Quantity - this.numberOfAssignedLicenses;\r\n // this.getLicense(this.selectedUserName);\r\n this.message = \"Your subscription has been updated successfully.\";\r\n this.isUpdateClicked = false;\r\n this.getEndDate(this.selectedLicenseAppPackagePrice.ActiveFromDate);\r\n this.selectedLicenseAppPackagePrice.ContractLength =\r\n this.selectedProduct.ContractLength;\r\n })\r\n .catch(() => {\r\n this.message =\r\n \"There is problem updating the subscription, Please try later.\";\r\n this.isUpdateClicked = false;\r\n if (this.selectedUserName.length > 0) {\r\n this.getSelectedPackagesForCurrentuser(this.selectedUserName);\r\n } else {\r\n this.getSelectedPackagesForCurrentuser(this.currentUser.UserName);\r\n }\r\n })\r\n .then(() => {\r\n //Check whether addOn needs to be added or removed\r\n /* if (this.isAddOnSelected && !this.isAddOnPaid) {\r\n this.addAddOnToLicense();\r\n } else if (!this.isAddOnSelected && this.isAddOnPaid) {\r\n this.removeAddOnFromLicense();\r\n }*/\r\n })\r\n .finally(() => {\r\n this.callGetActivePackagePricesForFrequency();\r\n this.showMsgModal = true;\r\n this.dataLoading = false;\r\n this.showIncreasingQuantityModal = false;\r\n this.showdescringQuantityModal = false;\r\n this.showWhiteLabelModal = false;\r\n this.showNewAmount = false;\r\n this.isContractChanged = false;\r\n this.changeInProduct(false);\r\n this.isAddOnSelected\r\n ? (this.isAddOnPaid = this.isAddOnSelected = true)\r\n : (this.isAddOnPaid = this.isAddOnSelected = false);\r\n });\r\n }\r\n\r\n closeModal() {\r\n this.showMsgModal = false;\r\n this.message = null;\r\n if (\r\n this.reloadPage ||\r\n this.selectedLicenseAppPackagePrice == null ||\r\n this.isPageReloadAfterCustomePrice\r\n ) {\r\n if (\r\n this.$routeParams.selectedTab ||\r\n this.selectedLicenseAppPackagePrice == null ||\r\n this.isPageReloadAfterCustomePrice\r\n ) {\r\n window.location.reload();\r\n } else {\r\n this.$location.path(\r\n \"/settings/\" + this.$routeParams.userId + \"/leadgenerator\",\r\n );\r\n }\r\n }\r\n }\r\n\r\n createCheckoutSession() {\r\n this.isSignUpClicked = true;\r\n this.$paymentService\r\n .createCheckoutSession(\r\n this.selectedProduct,\r\n this.isAddOnSelected,\r\n this.selectedUserName,\r\n null,\r\n )\r\n .then((response) => {\r\n window.location.assign(response.SessionUrl);\r\n })\r\n .catch(() => {\r\n this.message = \"There is problem signing up, Please try later.\";\r\n this.isSignUpClicked = false;\r\n this.showMsgModal = true;\r\n })\r\n .finally(() => {\r\n this.isSignUpClicked = false;\r\n });\r\n }\r\n\r\n assignLicense(broker) {\r\n this.dataLoading = true;\r\n this.selectedBroker = broker;\r\n this.$accountSettingService\r\n .assignLicense(this.selectedBroker.Id, this.selectedBroker.OrganisationId)\r\n .then((response) => {\r\n if (response) {\r\n this.selectedBroker.SubscriptionStatus =\r\n LicenseMasterStatusEnum.PaidUp;\r\n this.numberOfAssignedLicenses += 1;\r\n this.remaningLicense =\r\n this.assignedLicense.Quantity - this.numberOfAssignedLicenses;\r\n this.message = `Subscription is successfully assigned to ${this.selectedBroker.FullName}.`;\r\n this.showMsgModal = true;\r\n } else {\r\n this.message =\r\n \"There is problem assigning the subscription, Please try later.\";\r\n this.showMsgModal = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.showAlertmsg = false;\r\n });\r\n }\r\n\r\n unAssignLicense(broker) {\r\n this.dataLoading = true;\r\n this.$accountSettingService\r\n .unAssignLicense(broker.Id)\r\n .then((response) => {\r\n if (response) {\r\n broker.SubscriptionStatus = null;\r\n this.numberOfAssignedLicenses -= 1;\r\n this.remaningLicense =\r\n this.assignedLicense.Quantity - this.numberOfAssignedLicenses;\r\n this.message = `Subscription is successfully unassigned to ${broker.FullName}.`;\r\n this.showMsgModal = true;\r\n } else {\r\n this.message =\r\n \"There is problem unassigning the subscription, Please try later.\";\r\n this.showMsgModal = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.showAlertmsg = false;\r\n });\r\n }\r\n\r\n onUpdatingLiceseQuantity() {\r\n if (\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaymentProcessing &&\r\n !this.isDirectDebitActive(\r\n this.selectedLicenseAppPackagePrice.ActiveFromDate,\r\n )\r\n ) {\r\n this.selectedProduct.Quantity =\r\n this.selectedLicenseAppPackagePrice.TotalQuantity;\r\n return;\r\n }\r\n\r\n if (\r\n this.selectedProduct.Quantity > this.assignedLicense?.Quantity ||\r\n this.selectedProduct.Quantity < this.assignedLicense?.Quantity ||\r\n this.selectedProduct.Id != this.assignedLicense?.Id\r\n ) {\r\n if (this.numberOfAssignedLicenses > this.selectedProduct.Quantity) {\r\n this.showAlertmsg = true;\r\n this.alertMsg = `You are attempting to downgrade your total number of licences when they are already in use. In order to downgrade, please first unassign licenses via the \"Company broker users\" menu. You can then reduce your total number of licenses and update your subscription.`;\r\n this.selectedProduct.Quantity = this.numberOfAssignedLicenses;\r\n } else {\r\n this.showNewAmount = true;\r\n this.changeInProduct(true);\r\n this.changeInQuantity = true;\r\n this.showAlertmsg = false;\r\n this.alertMsg = null;\r\n this.setTotalAmount();\r\n }\r\n } else if (\r\n this.selectedProduct.Quantity == this.assignedLicense?.Quantity\r\n ) {\r\n this.setTotalAmount();\r\n this.showOrderButton = false;\r\n this.changeInQuantity = false;\r\n this.changeInProduct(false);\r\n this.showAlertmsg = false;\r\n this.alertMsg = null;\r\n }\r\n }\r\n\r\n assignLicenses() {\r\n var assignedLicenseusers = [];\r\n assignedLicenseusers.push(this.newBrokerUser);\r\n this.dataLoading = true;\r\n\r\n this.userService\r\n .registerBrokerUsers(assignedLicenseusers, this.selectedUserName)\r\n .then((response: string) => {\r\n if (response.length == 0) {\r\n this.message = `Successfully added and assigned a license to ${assignedLicenseusers[0].FirstName} ${assignedLicenseusers[0].LastName}`;\r\n this.showMsgModal = true;\r\n this.newBrokerUser = {\r\n Id: \"\",\r\n Roles: [\"Introducer\", \"Broker\"],\r\n } as ApplicationUserDTO;\r\n this.assignLicenseForm.$setPristine();\r\n this.assignLicenseForm.$setUntouched();\r\n this.getBrokerUsers(this.selectedOrganisationId);\r\n } else {\r\n this.message = response;\r\n this.showMsgModal = true;\r\n this.newBrokerUser = {\r\n Id: \"\",\r\n Roles: [\"Introducer\", \"Broker\"],\r\n } as ApplicationUserDTO;\r\n this.assignLicenseForm.$setPristine();\r\n this.assignLicenseForm.$setUntouched();\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n cancelChanges() {\r\n this.changeInProduct(false);\r\n this.selectedProduct = JSON.parse(JSON.stringify(this.assignedLicense));\r\n if (this.hasLegacyLicense()) {\r\n this.selectedProduct.PriceAmount =\r\n this.selectedProduct.PricingFrequency == PricingFrequencyEnum.Monthly\r\n ? 35\r\n : 350;\r\n this.isLegacyLicense = true;\r\n this.whitelabelPrice = 0;\r\n }\r\n this.isAddOnSelected = this.isAddOnPaid;\r\n this.showAlertmsg = false;\r\n this.showdescringQuantityModal = false;\r\n this.showIncreasingQuantityModal = false;\r\n this.showWhiteLabelModal = false;\r\n this.showNewAmount = false;\r\n this.isContractChanged = false;\r\n }\r\n\r\n setTotalAmount() {\r\n this.newTotalPayment =\r\n this.selectedProduct.PriceAmount * this.selectedProduct.Quantity;\r\n }\r\n\r\n goToCompanySettings() {\r\n this.$location.path(\"/Organisations\");\r\n }\r\n\r\n assignCustomPrice() {\r\n this.dataLoading = true;\r\n this.isCustomPriceApplied = true;\r\n\r\n if (\r\n this.selectedLicenseAppPackagePrice != null &&\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PayFailure\r\n ) {\r\n this.message = `Custom price can't be applied for license with status 'Incomplete'.`;\r\n this.dataLoading = false;\r\n this.showMsgModal = true;\r\n return;\r\n }\r\n\r\n const customPricePromise =\r\n this.selectedLicenseAppPackagePrice != null &&\r\n (this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaidUp ||\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaymentProcessing ||\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PreCancel ||\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.Unpaid)\r\n ? this.$accountSettingService.assignCustomePrice(\r\n this.customePrice,\r\n this.selectedProduct.Quantity,\r\n this.selectedUser.OrganisationId,\r\n this.isAddOnSelected,\r\n this.isMonthlySubscription,\r\n )\r\n : this.$accountSettingService.offerCustomPrice(\r\n this.customePrice,\r\n this.selectedProduct.Quantity,\r\n this.selectedUser.OrganisationId,\r\n this.isAddOnSelected,\r\n this.isMonthlySubscription,\r\n );\r\n\r\n customPricePromise\r\n .then((response) => {\r\n if (response) {\r\n this.message = `Custom price has been applied successfully.`;\r\n this.showMsgModal = true;\r\n this.selectedLicenseAppPackagePrice.TotalPricePerCycle = Number(\r\n this.customePrice,\r\n );\r\n } else {\r\n this.message =\r\n \"There is problem assigning the custom price, Please try later.\";\r\n this.showMsgModal = true;\r\n this.isCustomPriceApplied = false;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.customePrice = null;\r\n this.assignCustompriceForm.$setPristine();\r\n this.assignCustompriceForm.$setUntouched();\r\n this.isPageReloadAfterCustomePrice = true;\r\n });\r\n }\r\n\r\n assignStandardPrice() {\r\n this.dataLoading = true;\r\n this.$accountSettingService\r\n .assignStandardPrice(this.selectedUser.OrganisationId)\r\n .then((response) => {\r\n if (response) {\r\n this.message = `Standard price has been applied successfully.`;\r\n this.showMsgModal = true;\r\n this.isCustomPriceApplied = false;\r\n } else {\r\n this.message =\r\n \"There is problem assigning the standard price, Please try later.\";\r\n this.showMsgModal = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n changeInProduct(value) {\r\n if (\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaidUp ||\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PreCancel ||\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaymentProcessing\r\n ) {\r\n this.showOrderButton = value;\r\n this.showCancelButton = value;\r\n }\r\n }\r\n\r\n orderButton() {\r\n if (this.isContractChanged) {\r\n this.confirmContractLengthChange();\r\n } else {\r\n this.confirmUpdateSubscription();\r\n }\r\n }\r\n\r\n cancelButton() {\r\n this.cancelChanges();\r\n }\r\n\r\n offerLeadGeneratorLicense() {\r\n this.dataLoading = true;\r\n if (this.userOrganisation != null) {\r\n this.leadGenPackage.LicenseMasterId =\r\n this.userOrganisation.LicenseMasterId;\r\n }\r\n this.$accountSettingService\r\n .offerLeadGeneratorLicense(this.leadGenPackage)\r\n .then((response) => {\r\n if (response) {\r\n this.message =\r\n this.leadGeneratorName +\r\n ` license offer email has been sent to ${this.userOrganisation.Name} admin.`;\r\n this.showMsgModal = true;\r\n this.reloadPage = true;\r\n } else {\r\n this.message =\r\n \"There is problem assigning the offer for \" +\r\n this.leadGeneratorName +\r\n \". Please contact Brickflow.\";\r\n this.showMsgModal = true;\r\n }\r\n })\r\n .then(() => {\r\n return this.$organisationService.saveOrganisation(\r\n this.userOrganisation,\r\n );\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n onSelectingAddon(selected: boolean) {\r\n if (\r\n this.selectedLicenseAppPackagePrice != null &&\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaymentProcessing &&\r\n !this.isDirectDebitActive(\r\n this.selectedLicenseAppPackagePrice.ActiveFromDate,\r\n )\r\n ) {\r\n return;\r\n }\r\n\r\n this.isAddOnSelected = selected;\r\n this.changeInProduct(\r\n this.isAddOnPaid != this.isAddOnSelected ||\r\n this.assignedLicense.Quantity != this.selectedProduct.Quantity,\r\n );\r\n }\r\n\r\n onClickOfAddOnRemove() {\r\n if (\r\n this.selectedLicenseAppPackagePrice != null &&\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaymentProcessing &&\r\n !this.isDirectDebitActive(\r\n this.selectedLicenseAppPackagePrice.ActiveFromDate,\r\n )\r\n ) {\r\n return;\r\n }\r\n this.showWhiteLabelModal = true;\r\n }\r\n\r\n /* addAddOnToLicense() {\r\n if ((this.selectedLicenseAppPackagePrice == null) || (this.selectedLicenseAppPackagePrice != null && (this.selectedLicenseAppPackagePrice.Status == LicenseMasterStatusEnum.PreSubscription || this.selectedLicenseAppPackagePrice.Status == LicenseMasterStatusEnum.None || this.selectedLicenseAppPackagePrice.Status == LicenseMasterStatusEnum.Cancelled))) {\r\n this.isAddOnSelected = true;\r\n } else if (this.selectedLicenseAppPackagePrice.Status == LicenseMasterStatusEnum.PayFailure) {\r\n this.alertMsg = \"Please pay your pending payment to update subscription.\"\r\n this.showAlertmsg = true;\r\n this.changeInQuantity = false;\r\n this.isContractChanged = true;\r\n }\r\n else {\r\n this.dataLoading = true;\r\n this.$accountSettingService.addAddOnToLicense(this.userOrganisation.Id).then((response) => {\r\n if (response) {\r\n this.isAddOnPaid = this.isAddOnSelected = true;\r\n } else {\r\n this.message += \"\\nThere is problem adding Add-on, Please try later.\"\r\n }\r\n }).finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n removeAddOnFromLicense() {\r\n if ((this.selectedLicenseAppPackagePrice == null) || (this.selectedLicenseAppPackagePrice != null && (this.selectedLicenseAppPackagePrice.Status == LicenseMasterStatusEnum.PreSubscription || this.selectedLicenseAppPackagePrice.Status == LicenseMasterStatusEnum.None || this.selectedLicenseAppPackagePrice.Status == LicenseMasterStatusEnum.Cancelled ))) {\r\n this.isAddOnSelected = false;\r\n this.showWhiteLabelModal = false;\r\n } else if (this.selectedLicenseAppPackagePrice.Status == LicenseMasterStatusEnum.PayFailure) {\r\n this.alertMsg = \"Please pay your pending payment to update subscription.\"\r\n this.showAlertmsg = true;\r\n this.changeInQuantity = false;\r\n this.isContractChanged = true;\r\n }\r\n else {\r\n this.dataLoading = true;\r\n this.$accountSettingService.removeAddOnFromLicense(this.userOrganisation.Id).then((response) => {\r\n if (response) {\r\n this.isAddOnPaid = this.isAddOnSelected = false;\r\n } else {\r\n this.message += \"\\nThere is problem removing a Add-on, Please try later.\"\r\n this.showMsgModal = true;\r\n }\r\n }).finally(() => {\r\n this.dataLoading = false;\r\n this.showWhiteLabelModal = false;\r\n });\r\n }\r\n }*/\r\n\r\n onSelectingPackage(product: AppPackagePricingDTO) {\r\n if (\r\n this.selectedLicenseAppPackagePrice != null &&\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaymentProcessing &&\r\n !this.isDirectDebitActive(\r\n this.selectedLicenseAppPackagePrice.ActiveFromDate,\r\n )\r\n ) {\r\n return;\r\n }\r\n\r\n if (\r\n this.selectedLicenseAppPackagePrice == null ||\r\n this.selectedLicenseAppPackagePrice.Status !=\r\n LicenseMasterStatusEnum.PayFailure\r\n ) {\r\n this.selectedProduct = product;\r\n if (this.assignedLicense)\r\n this.selectedProduct.Quantity = this.assignedLicense.Quantity;\r\n if (\r\n !this.assignedLicense ||\r\n this.selectedProduct.Id != this.assignedLicense.Id\r\n ) {\r\n if (\r\n this.selectedProduct.Id != this.assignedLicense.Id &&\r\n this.isLegacyLicense\r\n ) {\r\n this.getAddOnPrice(this.selectedProduct.PricingFrequency);\r\n }\r\n this.isContractChanged = true;\r\n this.changeInProduct(true);\r\n this.showAlertmsg = false;\r\n this.alertMsg = null;\r\n } else {\r\n this.isContractChanged = false;\r\n if (this.hasLegacyLicense()) {\r\n this.selectedProduct.PriceAmount =\r\n this.selectedProduct.PricingFrequency ==\r\n PricingFrequencyEnum.Monthly\r\n ? 35\r\n : 350;\r\n this.whitelabelPrice = 0;\r\n this.isLegacyLicense = true;\r\n this.isAddOnSelected = true;\r\n }\r\n this.changeInProduct(false);\r\n this.showAlertmsg = false;\r\n this.alertMsg = null;\r\n }\r\n } else {\r\n this.alertMsg = \"Please pay your pending payment to change the contract.\";\r\n this.showAlertmsg = true;\r\n this.changeInQuantity = false;\r\n this.isContractChanged = true;\r\n }\r\n }\r\n\r\n confirmContractLengthChange() {\r\n this.message = `Are you sure you wish to continue?`;\r\n this.showMsgModal = true;\r\n }\r\n\r\n returnContractLength(value) {\r\n switch (value) {\r\n case ContractLengthEnum.TwoYearly:\r\n return 2;\r\n case ContractLengthEnum.Yearly:\r\n return 1;\r\n default:\r\n return 0;\r\n }\r\n }\r\n\r\n getAddOnPrice(frequency: PricingFrequencyEnum) {\r\n if (this.hasLegacyLicense()) {\r\n this.whitelabelPrice = 0;\r\n } else {\r\n this.$paymentService.getWhitelabelPrice(frequency).then((response) => {\r\n this.whitelabelPrice = response;\r\n });\r\n }\r\n }\r\n\r\n convertEnumToStringForLeadGenerator(value) {\r\n switch (value) {\r\n case PricingFrequencyEnum.Monthly:\r\n return \"Monthly\";\r\n case PricingFrequencyEnum.Monthly:\r\n return \"Monthly\";\r\n default:\r\n return \"\";\r\n }\r\n }\r\n\r\n calculateTotal(\r\n product: AppPackagePricingDTO,\r\n isUpdated: boolean = false,\r\n ): number {\r\n var total = Number(product ? product?.Quantity * product?.PriceAmount : 0);\r\n\r\n if (!isUpdated) {\r\n if (!this.isLegacyLicense) {\r\n total += Number(this.isAddOnPaid ? this.whitelabelPrice : 0);\r\n }\r\n }\r\n\r\n if (isUpdated) {\r\n total += Number(this.isAddOnSelected ? this.whitelabelPrice : 0);\r\n }\r\n\r\n return total;\r\n }\r\n\r\n showLeadeGeneratorForm() {\r\n if (\r\n this.selectedleadGenPackage &&\r\n this.selectedleadGenPackage.Status == LicenseMasterStatusEnum.Offered\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n showLeadeGeneratorPackage() {\r\n if (\r\n this.selectedleadGenPackage &&\r\n this.selectedleadGenPackage.Status != LicenseMasterStatusEnum.Offered\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n acceptLeadGenLicense() {\r\n this.dataLoading = true;\r\n this.$paymentService\r\n .createCheckoutSessionForLeadGen(this.selectedleadGenPackage)\r\n .then((response) => {\r\n window.location.assign(response.SessionUrl);\r\n })\r\n .catch(() => {\r\n this.message = \"There is problem signing up, Please try later.\";\r\n this.showMsgModal = true;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n createCheckoutForCustomPrice() {\r\n this.dataLoading = true;\r\n this.isSignUpClicked = true;\r\n this.$paymentService\r\n .createCheckoutSessionForCustomPrice(\r\n this.selectedLicenseAppPackagePrice,\r\n this.isAddOnSelected,\r\n this.selectedUserName,\r\n null,\r\n )\r\n .then((response) => {\r\n if (this.copyPaymentlink) {\r\n navigator.clipboard.writeText(response.SessionUrl);\r\n this.message = \"Code has been copied to the clipboard\";\r\n this.showMsgModal = true;\r\n this.copyPaymentlink = false;\r\n } else {\r\n window.location.assign(response.SessionUrl);\r\n }\r\n })\r\n .catch(() => {\r\n this.message = \"There is problem signing up, Please try later.\";\r\n this.isSignUpClicked = false;\r\n this.showMsgModal = true;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.isSignUpClicked = false;\r\n });\r\n }\r\n\r\n cancelLeadGeneratorOffer() {\r\n this.$accountSettingService\r\n .cancelLeadGeneratorOffer(this.selectedleadGenPackage.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.message = this.leadGeneratorName + ` offer has been cancelled.`;\r\n this.showMsgModal = true;\r\n this.leadGenPackage = null;\r\n this.reloadPage = true;\r\n } else {\r\n this.message =\r\n \"There is problem canceling the offer, Please try later.\";\r\n this.showMsgModal = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n showAssignLicenseSection() {\r\n if (\r\n (this.remaningLicense >= 1 &&\r\n this.selectedLicenseAppPackagePrice &&\r\n (this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaidUp ||\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PreCancel ||\r\n this.selectedLicenseAppPackagePrice.Status ==\r\n LicenseMasterStatusEnum.PaymentProcessing)) ||\r\n this.userOrganisation?.IsOnFreeTrial\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n getContractLengthText(\r\n frequency: PricingFrequencyEnum,\r\n contractLength: number,\r\n ) {\r\n if (contractLength == 1) {\r\n return \"1 Year Plan\";\r\n } else if (contractLength == 2) {\r\n return \"2 Year Plan\";\r\n } else {\r\n return frequency == PricingFrequencyEnum.Monthly\r\n ? \"Monthly Plan\"\r\n : \"Annual Plan\";\r\n }\r\n }\r\n\r\n returnNumberOfLicenseText(product) {\r\n return this.selectedProduct.Quantity > 1\r\n ? `${this.selectedProduct.Quantity} licenses`\r\n : `${this.selectedProduct.Quantity} license`;\r\n }\r\n\r\n isDirectDebitActive(activeFromDate) {\r\n var currentDate = new Date();\r\n var newDate = new Date(\r\n activeFromDate.getFullYear(),\r\n activeFromDate.getMonth(),\r\n activeFromDate.getDate() + 7,\r\n );\r\n\r\n return currentDate > newDate;\r\n }\r\n\r\n getTeamSizeDescription(teamSizeEnum: TeamSizeEnum) {\r\n var teamSizeOptions = this.selectListService.GetTeamSizeOptions();\r\n\r\n var teamSizeInfo = teamSizeOptions.find(\r\n (option) => option.key == teamSizeEnum,\r\n );\r\n if (teamSizeInfo) {\r\n return teamSizeInfo.displayName;\r\n }\r\n\r\n return \"\";\r\n }\r\n\r\n generateButtonCode() {\r\n if (\r\n this.$organisationService.hasValidWhitelabelProperties(\r\n this.userOrganisation,\r\n )\r\n ) {\r\n this.message = `${this.whiteLabelledUrl}${this.userOrganisation.OrganisationCode}#!/e/devfinancecriteria/`;\r\n this.showLeadGenUrlModal = true;\r\n } else {\r\n this.message =\r\n \"To access your \" +\r\n this.leadGeneratorName +\r\n \" URL please ensure you have an active White Label add-on and you have completed the URL Company Code in your company settings (under White Label)\";\r\n this.showMsgModal = true;\r\n }\r\n }\r\n\r\n generateButtonAllLoanCode() {\r\n if (\r\n this.$organisationService.hasValidWhitelabelProperties(\r\n this.userOrganisation,\r\n )\r\n ) {\r\n this.message = `${this.whiteLabelledUrl}${this.userOrganisation.OrganisationCode}#!/allloans`;\r\n this.showLeadGenUrlModal = true;\r\n } else {\r\n this.showMsgModal = true;\r\n this.message =\r\n \"To access your \" +\r\n this.leadGeneratorName +\r\n \" URL please ensure you have an active White Label add-on and you have completed the URL Company Code in your company settings (under White Label)\";\r\n }\r\n }\r\n\r\n generateButtonBridgingLoanCode() {\r\n if (\r\n this.$organisationService.hasValidWhitelabelProperties(\r\n this.userOrganisation,\r\n )\r\n ) {\r\n this.message = `${this.whiteLabelledUrl}${this.userOrganisation.OrganisationCode}#!/e/bridgingcriteria`;\r\n this.showLeadGenUrlModal = true;\r\n } else {\r\n this.showMsgModal = true;\r\n this.message =\r\n \"To access your \" +\r\n this.leadGeneratorName +\r\n \" URL please ensure you have an active White Label add-on and you have completed the URL Company Code in your company settings (under White Label)\";\r\n }\r\n }\r\n\r\n generateButtonCommercialLoanCode() {\r\n if (\r\n this.$organisationService.hasValidWhitelabelProperties(\r\n this.userOrganisation,\r\n )\r\n ) {\r\n this.message = `${this.whiteLabelledUrl}${this.userOrganisation.OrganisationCode}#!/e/commercialcriteria`;\r\n this.showLeadGenUrlModal = true;\r\n } else {\r\n this.showMsgModal = true;\r\n this.message =\r\n \"To access your \" +\r\n this.leadGeneratorName +\r\n \" URL please ensure you have an active White Label add-on and you have completed the URL Company Code in your company settings (under White Label)\";\r\n }\r\n }\r\n\r\n copyButtonCodeToClipBoard() {\r\n this.showLeadGenUrlModal = false;\r\n navigator.clipboard.writeText(this.message);\r\n this.message = \"Code has been copied to the clipboard\";\r\n this.showMsgModal = true;\r\n }\r\n\r\n getEndDate(startDate: Date) {\r\n const startDateCopy: Date = new Date(startDate.getTime());\r\n\r\n switch (this.selectedProduct.ContractLength) {\r\n case ContractLengthEnum.Yearly:\r\n startDateCopy.setFullYear(startDateCopy.getFullYear() + 1);\r\n this.endDate = startDateCopy;\r\n break;\r\n case ContractLengthEnum.TwoYearly:\r\n startDateCopy.setFullYear(startDateCopy.getFullYear() + 2);\r\n this.endDate = startDateCopy;\r\n break;\r\n default:\r\n this.endDate = null;\r\n break;\r\n }\r\n }\r\n\r\n showPaymentDetailsButton() {\r\n if (\r\n (this.selectedLicenseAppPackagePrice != null &&\r\n this.selectedLicenseAppPackagePrice.Status !=\r\n LicenseMasterStatusEnum.PreSubscription &&\r\n this.selectedLicenseAppPackagePrice.Status !=\r\n LicenseMasterStatusEnum.None) ||\r\n (this.selectedleadGenPackage != null &&\r\n this.selectedleadGenPackage.Status !=\r\n LicenseMasterStatusEnum.PreSubscription &&\r\n this.selectedleadGenPackage.Status != LicenseMasterStatusEnum.None &&\r\n this.selectedleadGenPackage.Status != LicenseMasterStatusEnum.Offered)\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n bookCall() {\r\n window.open(\r\n \"https://brickflow.com/brokers/brickflow-enterprise/book-a-demo\",\r\n );\r\n }\r\n\r\n hasLegacyLicense() {\r\n if (\r\n (this.isLegacyLicense &&\r\n this.selectedProduct &&\r\n this.selectedProduct.ContractLength == ContractLengthEnum.None) ||\r\n (this.userOrganisation &&\r\n this.selectedLicenseAppPackagePrice &&\r\n this.userOrganisation.IsLegacyLicense &&\r\n this.selectedLicenseAppPackagePrice.ContractLength ==\r\n ContractLengthEnum.None &&\r\n (!this.assignedLicense ||\r\n this.selectedProduct.Id == this.assignedLicense.Id))\r\n ) {\r\n return true;\r\n } else {\r\n false;\r\n }\r\n }\r\n\r\n getLicenseStatusText() {\r\n this.allActiveAppPackagePrices = [];\r\n this.userService\r\n .getLicenseStatusText(this.organisationAdminUsername)\r\n .then((response) => {\r\n this.licenseStatusText = response;\r\n });\r\n }\r\n\r\n getWhiteLabelledUrl() {\r\n this.$auth.getWhiteLabelledUrl().then((response) => {\r\n this.whiteLabelledUrl = response;\r\n });\r\n }\r\n\r\n gotoBrickflowPricingPrice() {\r\n window.open(\"https://brickflow.com/pricing\");\r\n }\r\n}\r\n","import { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\n\r\nexport class AgentLandingController {\r\n caseId: number;\r\n case: CaseDTO;\r\n disablepayment: boolean = false;\r\n message: string = \"\";\r\n modal: boolean = false;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$scope\",\r\n \"$location\",\r\n \"$cookies\",\r\n \"RoleService\",\r\n \"$window\",\r\n ];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $scope: ng.IScope,\r\n private $location: ng.ILocationService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private roleService: RoleService,\r\n private $window: ng.IWindowService,\r\n ) {\r\n //Check if the user is logged in\r\n if (\r\n this.$cookies.get(\"access_token\") != null ||\r\n this.$cookies.get(\"access_token\") != undefined\r\n ) {\r\n if (this.roleService.isAdminUser) {\r\n this.$location.path(\"/dashboard\");\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n }\r\n }\r\n\r\n goToRegistrationPage() {\r\n this.$location.path(\"/registerintroducer\");\r\n }\r\n\r\n goToCriteriaPage() {\r\n this.$location.path(\"/criteria/0/0/1\");\r\n }\r\n\r\n goToLoginPage() {\r\n this.$location.path(\"/login\");\r\n }\r\n\r\n mailForMarketing() {\r\n this.$window.location.assign(\"mailto:john@brickflow.com\");\r\n }\r\n}\r\n","import { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { OrganisationLinkDTO } from \"@js/DTO/OrgnisationLinkDTO.cs.d\";\r\nimport { LinkTypeEnum } from \"@js/models/enum/LinkTypeEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { SharedCriteriaService } from \"@js/services/Deal/SharedCriteriaService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationLinkService } from \"@js/services/OrganisationLinkService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\n\r\nexport class AllLoansLandingController {\r\n isLoggedInUser: boolean = false;\r\n totalLenders: number = 0;\r\n isBorrower: boolean = false;\r\n orgCode: string;\r\n organisationLink: OrganisationLinkDTO;\r\n previewContent: boolean = false;\r\n organisation: OrganisationDTO;\r\n\r\n //error message to enterprise client when organisation does not have a valid permission\r\n noPermissionErrorMsg: string = \"\";\r\n dataLoading: boolean = false;\r\n\r\n isCommercialOwnerOccupiedActive: boolean = false;\r\n\r\n showHelpModal: boolean = false;\r\n headerProductFamily: ProductFamilyEnum = ProductFamilyEnum.None;\r\n enterpriseLinkLogo: string;\r\n showBridgingOption: boolean = false;\r\n showCommercialOption: boolean = false;\r\n showDevFinaceOption: boolean = true;\r\n isBridgingDisabled: boolean = false;\r\n isCommercialDisabled: boolean = false;\r\n\r\n isWidget: boolean = false;\r\n showCriteriaSection: boolean = false;\r\n isMobileView: boolean = false;\r\n\r\n productFamilyType = ProductFamilyEnum.None;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$routeParams\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$q\",\r\n \"AuthService\",\r\n \"OrganisationService\",\r\n \"LenderService\",\r\n \"EventLogService\",\r\n \"OrganisationLinkService\",\r\n \"SharedCriteriaService\",\r\n \"UserService\",\r\n \"$rootScope\",\r\n \"RoleService\"\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n protected $q: ng.IQService,\r\n private $auth: AuthService,\r\n private organisationService: OrganisationService,\r\n private lenderService: LenderService,\r\n private eventLogService: EventLogService,\r\n private organisationLinkService: OrganisationLinkService,\r\n private sharedCriteriaService: SharedCriteriaService,\r\n private userService: UserService,\r\n public $rootScope: ng.IRootScopeService,\r\n public roleService: RoleService\r\n ) {\r\n\r\n if (window.self == window.top) {\r\n this.orgCode = this.$cookies.get(\"org_code\");\r\n } else {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n }\r\n\r\n if ($cookies.get(\"access_token\")) {\r\n this.roleService.isClientUser().then((isClient: boolean) => {\r\n if (isClient && this.orgCode && this.orgCode != 'undefined' && this.orgCode != '') {\r\n this.userService.GetDefaultBrokerOrganisation().then((userDefaultBrokerOrg: OrganisationDTO) => {\r\n if (userDefaultBrokerOrg && userDefaultBrokerOrg.OrganisationCode != this.orgCode) {\r\n let broadcastResult = this.$rootScope.$broadcast(\"logout\");\r\n\r\n if (broadcastResult.defaultPrevented) return;\r\n\r\n this.$auth.logout(false);\r\n window.location.reload();\r\n }\r\n });\r\n }\r\n })\r\n\r\n }\r\n\r\n if (!$cookies.get(\"access_token\") && this.$routeParams.linkType)\r\n this.productFamilyType = this.getProductFamilyByLinkType();\r\n\r\n\r\n if (this.productFamilyType == ProductFamilyEnum.None || this.productFamilyType == ProductFamilyEnum.Commercial) {\r\n this.$auth.isCommercialOwnerOccupiedActive().then((response) => {\r\n this.isCommercialOwnerOccupiedActive = response;\r\n });\r\n }\r\n\r\n if (this.$routeParams.context == 'widget' && window.self != window.top) {\r\n if (!(this.$rootScope as any).previousRoute.startsWith(\"/e/enterpriseleadcapture\")) {\r\n this.organisationService.sendDataToParent(\"height\", \"170px\");\r\n }\r\n this.isWidget = true;\r\n } else if (window.innerWidth <= 480 && window.self == window.top) {\r\n this.isMobileView = true;\r\n }\r\n\r\n if ($cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n this.setProductButtonStateAndVisibility();\r\n\r\n } else if (this.$location.path().startsWith(\"/allloans\") && !$cookies.get(\"access_token\")) {\r\n this.sharedCriteriaService.storeEnterpriseLinkType(this.$routeParams.linkType ? this.$routeParams.linkType.toString() : LinkTypeEnum.AllLoans.toString());\r\n\r\n\r\n this.organisationService\r\n .getOrgByUrlIfOrgHasEnterpriseSearchPermission(\r\n this.orgCode,\r\n this.productFamilyType,\r\n this.$routeParams.linkId,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n this.organisation = response;\r\n this.getNumberOfLenders(this.organisation.Id);\r\n this.orgCode = response.OrganisationCode;\r\n this.showBridgingOption = response.HasBridging;\r\n this.showCommercialOption = response.HasCommercialMortgage;\r\n\r\n if ((this.isWidget && this.organisation.HasWidget) || !this.isWidget) {\r\n if (!this.isWidget || ((this.$rootScope as any).previousRoute.startsWith(\"/e/enterpriseleadcapture\") && this.isWidget)) this.selectDefaultProductFamily();\r\n this.logEvent();\r\n var imgs = document.getElementsByTagName(\"img\");\r\n\r\n if (this.$routeParams.linkId && this.$routeParams.linkId != \"0\") {\r\n this.organisationLinkService\r\n .getOrganisationLinkLogoByLinkIdAndLogPageLoadEvent(\r\n this.$routeParams.linkId\r\n )\r\n .then((logoUrl) => {\r\n if (logoUrl) imgs[0].src = this.enterpriseLinkLogo = logoUrl;\r\n });\r\n } else {\r\n this.enterpriseLinkLogo = imgs[0].src;\r\n }\r\n } else {\r\n this.organisationService.getOrganisationAdminByOrgCode(this.orgCode).then((admin) => {\r\n this.noPermissionErrorMsg = admin ? `We are unable to compare loans right now. Please contact your broker: ${admin.Email}.` :\r\n \"We are unable to compare loans right now. Please contact your broker.\";\r\n })\r\n }\r\n } else {\r\n this.noPermissionErrorMsg =\r\n \"We are unable to compare loans right now. Please contact your broker.\";\r\n }\r\n });\r\n }\r\n\r\n //This event is added to navigate user to devfinance critera on click of devfinance link from helper text, when user is on Bare Land path for purchase/refinance search.\r\n let productFamilySelectionUnregister = $scope.$on(\"productFamilySelection\", (event: ng.IAngularEvent, newValue) => {\r\n this.updateProdcutFamilyOption(newValue);\r\n });\r\n\r\n $scope.$on(\"$destroy\", productFamilySelectionUnregister);\r\n }\r\n\r\n getNumberOfLenders(orgId) {\r\n this.lenderService\r\n .getTotalLenders(ProductFamilyEnum.None, orgId)\r\n .then((totalLenders: number) => {\r\n this.totalLenders = Math.floor(totalLenders / 5) * 5;\r\n });\r\n }\r\n\r\n updateProdcutFamilyOption(val) {\r\n this.headerProductFamily = val;\r\n }\r\n\r\n\r\n async initialRegisterEventLog(orgCode, organisationLinkId = null) {\r\n if (window.self == window.top) {\r\n if (sessionStorage.getItem(\"clientId\")) {\r\n this.eventLogService.logPageLoad(\r\n \"ALLLOANS\",\r\n orgCode,\r\n \"\",\r\n \"Client\",\r\n organisationLinkId,\r\n ProductTypeEnum.None,\r\n undefined,\r\n undefined,\r\n sessionStorage.getItem(\"clientId\"),\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n \"ALLLOANS\",\r\n orgCode,\r\n \"\",\r\n \"Client\",\r\n organisationLinkId,\r\n ProductTypeEnum.None,\r\n );\r\n }\r\n } else {\r\n var clientId: string = null;\r\n clientId = await this.organisationService.getData(\"clientId\");\r\n if (clientId) {\r\n this.eventLogService.logPageLoad(\r\n this.productFamilyType == ProductFamilyEnum.None ? \"ALLLOANS\" : `${this.getProducFamilyText().toUpperCase()}ALLLOANS`,\r\n orgCode,\r\n \"\",\r\n \"Client\",\r\n organisationLinkId,\r\n ProductTypeEnum.None,\r\n undefined,\r\n undefined,\r\n clientId,\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n this.productFamilyType == ProductFamilyEnum.None ? \"ALLLOANS\" : `${this.getProducFamilyText().toUpperCase()}ALLLOANS`,\r\n orgCode,\r\n \"\",\r\n \"Client\",\r\n organisationLinkId,\r\n ProductTypeEnum.None,\r\n );\r\n }\r\n }\r\n }\r\n\r\n logEvent() {\r\n if (this.$routeParams.linkId) {\r\n if (this.orgCode) {\r\n this.initialRegisterEventLog(\r\n this.orgCode,\r\n Number(this.$routeParams.linkId),\r\n );\r\n } else {\r\n this.initialRegisterEventLog(\"\", Number(this.$routeParams.linkId));\r\n }\r\n } else {\r\n if (this.orgCode) {\r\n this.initialRegisterEventLog(this.orgCode);\r\n } else {\r\n this.initialRegisterEventLog(\"\");\r\n }\r\n }\r\n }\r\n\r\n\r\n onClickShowHelpModal() {\r\n this.showHelpModal = true;\r\n if (this.isWidget && !this.showCriteriaSection)\r\n this.organisationService.sendDataToParent(\"height\", \"745px\");\r\n }\r\n\r\n closeHelpModal() {\r\n if (this.isWidget && !this.showCriteriaSection)\r\n this.organisationService.sendDataToParent(\"height\", \"170px\");\r\n this.showHelpModal = false;\r\n }\r\n\r\n selectDefaultProductFamily() {\r\n if (this.showBridgingOption && !this.isBridgingDisabled && (this.productFamilyType == ProductFamilyEnum.None || this.productFamilyType == ProductFamilyEnum.Bridging)) {\r\n this.headerProductFamily = ProductFamilyEnum.Bridging;\r\n } else if (this.showCommercialOption && !this.isCommercialDisabled && (this.productFamilyType == ProductFamilyEnum.None || this.productFamilyType == ProductFamilyEnum.Commercial)) {\r\n this.headerProductFamily = ProductFamilyEnum.Commercial;\r\n } else {\r\n this.headerProductFamily = ProductFamilyEnum.Development;\r\n }\r\n this.showCriteriaSection = true;\r\n }\r\n\r\n setProductButtonStateAndVisibility() {\r\n this.userService\r\n .getCurrentUserPermissionForProductSearch(\r\n )\r\n .then((response) => {\r\n if (response) {\r\n if (response.IsLender) {\r\n this.showBridgingOption = response.HasBridgingSearchPermission;\r\n this.showDevFinaceOption = response.HasDevFinanceSearchPermission;\r\n this.showCommercialOption = response.HasCommercialSearchPermission;\r\n } else {\r\n this.isBridgingDisabled = !response.HasBridgingSearchPermission;\r\n this.isCommercialDisabled = !response.HasCommercialSearchPermission;\r\n this.showBridgingOption = true;\r\n this.showDevFinaceOption = true;\r\n this.showCommercialOption = true;\r\n }\r\n this.getNumberOfLenders(response.OrgId);\r\n this.selectDefaultProductFamily();\r\n\r\n } else {\r\n //This is to navigate a user to userdashboard when they try to access path directly\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n });\r\n\r\n }\r\n\r\n\r\n showorHideCriteriaSection() {\r\n if (this.showCriteriaSection) {\r\n this.organisationService.sendDataToParent(\"height\", \"170px\");\r\n }\r\n this.showCriteriaSection = !this.showCriteriaSection;\r\n }\r\n\r\n footerSignInClicked() {\r\n var baseUrl = window.location.href.split(\"#!\")[0] + '#!';\r\n var newUrl = `${baseUrl}/login`;\r\n window.open(newUrl, \"_blank\");\r\n }\r\n\r\n getProductFamilyByLinkType() {\r\n var productFamilyType = ProductFamilyEnum.None;\r\n switch (Number(this.$routeParams.linkType)) {\r\n case LinkTypeEnum.Development:\r\n productFamilyType = ProductFamilyEnum.Development;\r\n break;\r\n case LinkTypeEnum.Bridging:\r\n productFamilyType = ProductFamilyEnum.Bridging;\r\n break;\r\n case LinkTypeEnum.Commercial:\r\n productFamilyType = ProductFamilyEnum.Commercial;\r\n break;\r\n default:\r\n break;\r\n }\r\n return productFamilyType;\r\n }\r\n\r\n\r\n onStartSearchButtonClick() {\r\n switch (this.productFamilyType) {\r\n case ProductFamilyEnum.Development:\r\n this.headerProductFamily = ProductFamilyEnum.Development;\r\n break;\r\n case ProductFamilyEnum.Bridging:\r\n this.headerProductFamily = ProductFamilyEnum.Bridging;\r\n break;\r\n case ProductFamilyEnum.Commercial:\r\n this.headerProductFamily = ProductFamilyEnum.Commercial;\r\n break;\r\n default:\r\n break;\r\n }\r\n this.showCriteriaSection = true;\r\n }\r\n\r\n getProducFamilyText() {\r\n switch (this.productFamilyType) {\r\n case ProductFamilyEnum.Development:\r\n return \"Development\";\r\n case ProductFamilyEnum.Bridging:\r\n return \"Bridging\";\r\n case ProductFamilyEnum.Commercial:\r\n return \"Commercial\";\r\n default:\r\n return \"\";\r\n }\r\n }\r\n}\r\n","import { CaseMemberDTO } from \"@js/DTO/CaseMemberDTO.cs.d\";\r\nimport { ApplicantService } from \"@js/services/ApplicantService\";\r\n\r\nexport class ApplicantController {\r\n selectedSection: string;\r\n\r\n objects: CaseMemberDTO[];\r\n selectedObject: CaseMemberDTO;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n //addingSubobject: boolean;\r\n\r\n //subobjects: SubobjectDTO[];\r\n //selectedSubobject: SubobjectDTO;\r\n\r\n //fetchingSubobjects: boolean;\r\n //fetchingSubobject: boolean;\r\n\r\n applicantForm: ng.IFormController;\r\n //subapplicantForm: ng.IFormController;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"ApplicantService\",\r\n\r\n //'SubobjectService',\r\n ];\r\n //private $subobjectservice: App.Services.SubobjectService\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $applicantservice: ApplicantService,\r\n ) {\r\n this.updateObjects();\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n\r\n // Fetch all objects.\r\n this.$applicantservice\r\n .fetchAll()\r\n .then((response) => {\r\n this.objects = response;\r\n this.preSelectedItem();\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n });\r\n }\r\n\r\n private preSelectedItem() {\r\n if (this.$routeParams.Id) {\r\n let selectedObject = this.objects.find((value, index) => {\r\n return value.Id === parseInt(this.$routeParams.objectId);\r\n });\r\n\r\n this.selectObject(selectedObject);\r\n }\r\n }\r\n\r\n selectObject(object: CaseMemberDTO) {\r\n this.selectedObject = object;\r\n\r\n //this.fetchingSubobjects = true;\r\n //this.$subobjectservice.fetchSubobjectsForObject(object.Id).then((response) => {\r\n // this.subobjects = response;\r\n // this.fetchingSubobjects = false;\r\n //}).catch((response) => {\r\n // this.fetchingSubobjects = false;\r\n //});\r\n\r\n this.selectedSection = \"details\";\r\n }\r\n\r\n createObject() {\r\n this.selectedSection = \"details\";\r\n this.selectedObject = {} as CaseMemberDTO;\r\n }\r\n\r\n save() {\r\n this.$applicantservice\r\n .addUpdatereturnonlyid(this.selectedObject)\r\n .then((response) => {\r\n this.selectedObject.Id = response;\r\n if (!this.objects) {\r\n this.objects = [];\r\n }\r\n\r\n let matches: CaseMemberDTO[] = this.objects.filter((value, index) => {\r\n return value.Id == response;\r\n });\r\n\r\n if (!matches || matches.length === 0) {\r\n this.objects.push(this.selectedObject);\r\n }\r\n\r\n this.applicantForm.$setPristine();\r\n this.updateObjects();\r\n });\r\n }\r\n\r\n delete() {\r\n this.$applicantservice.delete(this.selectedObject.Id).then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.applicantForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n });\r\n }\r\n\r\n //addSubobject() {\r\n // this.selectedSubobject = {\r\n // AssociatedObjectId: this.selectedObject.Id,\r\n // AssociatedObjectName: this.selectedObject.Name\r\n // } as SubobjectDTO;\r\n //}\r\n\r\n //removeSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.deleteSubobject(subobject.Id).then((response) => {\r\n // this.subobjects.splice(this.subobjects.indexOf(this.selectedSubobject), 1);\r\n // delete this.selectedSubobject;\r\n // });\r\n //}\r\n\r\n //cancelUpdateSubobject() {\r\n // delete this.selectedSubobject;\r\n //}\r\n\r\n //updateSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.addUpdateSubobject(subobject).then((response) => {\r\n // if (this.subobjects.indexOf(subobject) === -1) {\r\n // this.subobjects.push(subobject);\r\n // }\r\n // delete this.selectedSubobject;\r\n // }).catch((response) => {\r\n // delete this.selectedSubobject;\r\n // });\r\n\r\n //}\r\n}\r\n","export const enum ALItemTypeEnum {\r\n Other = 0,\r\n ResidentialProperty = 1,\r\n BTLProperty = 2,\r\n CommercialProperty = 3,\r\n OverseasProperty = 4,\r\n CashDeposits = 5,\r\n StocksShares = 6,\r\n VehicleBoat = 7,\r\n BusinessEquipment = 8,\r\n ArtJewellryAntique = 9,\r\n ResidentialPropertyLoan = 30,\r\n BTLPropertyLoan = 31,\r\n CommercialPropertyLoan = 32,\r\n OverseasPropertyLoan = 33,\r\n HPLease = 34,\r\n Overdraft = 35,\r\n OtherLoan = 36,\r\n PersonalGuarantee = 60,\r\n}\r\n","export const enum ALTypeEnum {\r\n Asset = 0,\r\n Liability = 1,\r\n PersonalGuarantee = 2,\r\n}\r\n","import { AddressHistoryDTO } from \"@js/DTO/AddressHistoryDTO.cs.d\";\r\nimport { AddressLookupDTO } from \"@js/DTO/AddressLookupDTO.cs.d\";\r\nimport { AssetLiabilityItemDTO } from \"@js/DTO/AssetLiabilityItemDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { CaseMemberDTO } from \"@js/DTO/CaseMemberDTO.cs.d\";\r\nimport { ProjectOwnershipDTO } from \"@js/DTO/DevelopmentFinance/ProjectOwnershipDTO.cs.d\";\r\nimport { QualificationsDTO } from \"@js/DTO/QualificationsDTO.cs.d\";\r\nimport { ALItemTypeEnum } from \"@js/models/enum/ALItemTypeEnum.cs.d\";\r\nimport { ALTypeEnum } from \"@js/models/enum/ALTypeEnum.cs.d\";\r\nimport { PostalAddress } from \"@js/models/PostalAddress.cs.d\";\r\nimport { ApplicantService } from \"@js/services/ApplicantService\";\r\nimport { AssetLiabilityItemService } from \"@js/services/AssetLiabilityItemService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DevelopmentTrackRecordService } from \"@js/services/DevelopmentTrackRecordService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { QualificationsService } from \"@js/services/QualificationsService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { StreetAddressService } from \"@js/services/StreetAddressService\";\r\n\r\nexport class ApplicantDetailsController {\r\n //navigate for pages\r\n step: number = 1;\r\n applicantNo: number = 0;\r\n devexperienceId: number;\r\n\r\n //current case\r\n case: CaseDTO;\r\n caseTitle: string;\r\n\r\n //current shareholder\r\n currentShareholder: CaseMemberDTO;\r\n\r\n //case id\r\n caseid: number;\r\n\r\n development: ProjectOwnershipDTO;\r\n developmentTrackRecordType: {}[] = [];\r\n\r\n //qualifications\r\n newQualification: string[] = [];\r\n newSkill: string[] = [];\r\n duplicate: number[] = [];\r\n\r\n //address\r\n previousAddressSearchTerm: string;\r\n searchingForPreviousAddress: boolean = false;\r\n previousAddressPostCodeOptions: PostalAddress[] = [];\r\n showAddHistoryConfirmDelete: boolean = false;\r\n addressHistoryIdToDelete: number;\r\n showAddressHistoryModal: boolean = false;\r\n shareholderAddressHistory: AddressHistoryDTO[] = [];\r\n addressHistoryItem: AddressHistoryDTO;\r\n previousAddressSearchResults: string[];\r\n searchpostcode: string[];\r\n searchterm: string[];\r\n searchresults: string[];\r\n PostCodeOptions: PostalAddress[][] = [];\r\n searchingForAddress: boolean = false;\r\n\r\n error: boolean = false;\r\n saving: boolean = false;\r\n dataLoading: boolean = false;\r\n saved: boolean = false;\r\n\r\n //modal\r\n message: string = \"\";\r\n modal: boolean = false;\r\n openModal: boolean = false;\r\n\r\n //to edit input on A&L\r\n newDescription: string;\r\n newValue: number;\r\n newStartDate: Date;\r\n newEndDate: Date;\r\n ALItemType: ALItemTypeEnum;\r\n item: AssetLiabilityItemDTO;\r\n applicant: CaseMemberDTO;\r\n renamingItem: AssetLiabilityItemDTO;\r\n confirmationDelete: boolean = false;\r\n\r\n //validation dates\r\n maxDateOfBirth: Date = new Date();\r\n minDateOfBirth: Date = new Date(\"Jan 01 1900\");\r\n maxDateForDateField: Date = new Date(\"Jan 01 3000\");\r\n isAddFormInvalid: boolean = true;\r\n isEditFormInvalid: boolean = true;\r\n\r\n //forms\r\n multiPartForm1: ng.IFormController;\r\n multiPartForm2: ng.IFormController;\r\n multiPartForm3: ng.IFormController;\r\n multiPartForm4: ng.IFormController;\r\n multiPartForm7: ng.IFormController;\r\n\r\n formattedAcquisitionDate: any[] = [];\r\n\r\n YearsWorkedInProfessionsListArchitectCheckbox: boolean[] = [];\r\n YearsWorkedInProfessionsListBuilderCheckbox: boolean[] = [];\r\n YearsWorkedInProfessionsListCarpenterCheckbox: boolean[] = [];\r\n YearsWorkedInProfessionsListElectricianCheckbox: boolean[] = [];\r\n YearsWorkedInProfessionsListEstateAgencyCheckbox: boolean[] = [];\r\n YearsWorkedInProfessionsListPlannerCheckbox: boolean[] = [];\r\n YearsWorkedInProfessionsListProjectManagerCheckbox: boolean[] = [];\r\n YearsWorkedInProfessionsListPropertySurveyorCheckbox: boolean[] = [];\r\n YearsWorkedInProfessionsListQuantitySurveyorCheckbox: boolean[] = [];\r\n YearsWorkedInProfessionsListStructuralEngineerCheckbox: boolean[] = [];\r\n\r\n professionsList: string[] = [\r\n \"Architect\",\r\n \"Builder\",\r\n \"Carpenter\",\r\n \"Electrician\",\r\n \"EstateAgency\",\r\n \"Planner\",\r\n \"ProjectManager\",\r\n \"PropertySurveyor\",\r\n \"QuantitySurveyor\",\r\n \"StructuralEngineer\",\r\n ];\r\n\r\n applicantDetailsFormSectionNames = [\r\n {\r\n label: \"Applicant Details\",\r\n visible: true,\r\n },\r\n ];\r\n\r\n asset = {};\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$q\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"ApplicantService\",\r\n \"RoleService\",\r\n \"CaseMemberService\",\r\n \"AssetLiabilityItemService\",\r\n \"CaseService\",\r\n \"FileAttachmentService\",\r\n \"DevelopmentTrackRecordService\",\r\n \"StreetAddressService\",\r\n \"QualificationsService\",\r\n \"AuthService\",\r\n ];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n protected $q: ng.IQService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private $applicantservice: ApplicantService,\r\n private roleService: RoleService,\r\n private caseMemberService: CaseMemberService,\r\n private assetLiabilityItemService: AssetLiabilityItemService,\r\n private caseService: CaseService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private developmenttrackrecordservice: DevelopmentTrackRecordService,\r\n private streetAddressService: StreetAddressService,\r\n private qualificationsService: QualificationsService,\r\n private authService: AuthService,\r\n ) {\r\n this.onInit();\r\n }\r\n\r\n onInit() {\r\n //Get step number\r\n if (this.$routeParams.StepNumber) {\r\n this.step =\r\n this.$routeParams.StepNumber > 8 || this.$routeParams.StepNumber < 1\r\n ? 1\r\n : this.$routeParams.StepNumber;\r\n }\r\n\r\n if (this.$routeParams.CaseId) {\r\n this.caseid = this.$routeParams.CaseId;\r\n\r\n this.caseService.fetch(this.caseid).then((result) => {\r\n this.case = result;\r\n this.caseTitle = result.DevelopmentInput.SearchName;\r\n });\r\n }\r\n\r\n if (this.$routeParams.shareholderId) {\r\n this.applicantNo = this.$routeParams.shareholderId;\r\n\r\n this.$applicantservice.fetch(this.applicantNo).then((result) => {\r\n this.currentShareholder = result;\r\n if (\r\n this.currentShareholder.AddressHistory &&\r\n this.currentShareholder.AddressHistory.length > 0\r\n ) {\r\n this.parseAddressHistory(this.currentShareholder.AddressHistory);\r\n }\r\n });\r\n }\r\n\r\n if (this.$routeParams.Id && this.$routeParams.Id > 0) {\r\n this.devexperienceId = this.$routeParams.Id;\r\n }\r\n }\r\n\r\n goToCaseDashboard(blockSave?: boolean): void {\r\n if (this.roleService.IsLender == true) {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n } else {\r\n if (blockSave) {\r\n this.save(true).then((response) => {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n (this.$rootScope as any).formSaved = true;\r\n });\r\n } else {\r\n this.save(false).then(() => {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n });\r\n }\r\n }\r\n }\r\n\r\n goToShareholders(blockSave?: boolean): void {\r\n if (this.roleService.IsLender == true) {\r\n this.$location.path(\r\n \"/devexperience/\" + this.caseid + \"/\" + this.devexperienceId + \"/2\",\r\n );\r\n } else {\r\n if (blockSave) {\r\n this.save(true).then((response) => {\r\n this.$location.path(\r\n \"/devexperience/\" + this.caseid + \"/\" + this.devexperienceId + \"/2\",\r\n );\r\n (this.$rootScope as any).formSaved = true;\r\n });\r\n } else {\r\n this.save(false).then(() => {\r\n this.$location.path(\r\n \"/devexperience/\" + this.caseid + \"/\" + this.devexperienceId + \"/2\",\r\n );\r\n });\r\n }\r\n }\r\n }\r\n\r\n //save\r\n save(isFormComplete: boolean): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.saving = true;\r\n\r\n this.caseMemberService\r\n .addUpdatereturnonlyid(this.currentShareholder)\r\n .then((response) => {\r\n this.setAllFormsPristine();\r\n defer.resolve(response as number);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n this.error = true;\r\n })\r\n .finally(() => {\r\n this.saving = false;\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n //resent forms\r\n setAllFormsPristine(): void {\r\n if (this.multiPartForm1) {\r\n this.multiPartForm1.$setPristine();\r\n }\r\n if (this.multiPartForm2) {\r\n this.multiPartForm2.$setPristine();\r\n }\r\n if (this.multiPartForm3) {\r\n this.multiPartForm3.$setPristine();\r\n }\r\n if (this.multiPartForm4) {\r\n this.multiPartForm4.$setPristine();\r\n }\r\n if (this.multiPartForm7) {\r\n this.multiPartForm7.$setPristine();\r\n }\r\n }\r\n\r\n //Navigate for tabs\r\n\r\n navigateTabs(index: number) {\r\n this.profileGo(\r\n \"/applicantdetails/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.devexperienceId +\r\n \"/\" +\r\n this.applicantNo +\r\n \"/\" +\r\n this.sum(index, 1),\r\n );\r\n (this.$rootScope as any).formSaved = true;\r\n }\r\n\r\n sum(a: number, b: number): number {\r\n return a + b;\r\n }\r\n\r\n go(path): void {\r\n // Only need to save if user is NOT a lender (everything is in read-only mode for lender)\r\n if (this.roleService.IsLender == true) {\r\n this.$location.path(path);\r\n } else {\r\n this.save(false).then((response) => {\r\n this.devexperienceId = response;\r\n this.$location.path(path);\r\n });\r\n }\r\n }\r\n\r\n profileGo(path): void {\r\n if (this.roleService.IsLender == true) {\r\n this.$location.path(path);\r\n } else {\r\n this.save(false).then((response) => {\r\n this.$location.path(path);\r\n });\r\n }\r\n }\r\n\r\n next(): void {\r\n if (this.step == 1 && this.step < 2) {\r\n this.step++;\r\n this.profileGo(\r\n \"/applicantdetails/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.devexperienceId +\r\n \"/\" +\r\n this.$routeParams.shareholderId +\r\n \"/\" +\r\n this.step,\r\n );\r\n (this.$rootScope as any).formSaved = true;\r\n }\r\n }\r\n\r\n backApplicantDetails(): void {\r\n if (this.step >= 1 && this.step < 3) {\r\n this.step--;\r\n this.profileGo(\r\n \"/applicantdetails/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.devexperienceId +\r\n \"/\" +\r\n this.$routeParams.shareholderId +\r\n \"/\" +\r\n this.step,\r\n );\r\n (this.$rootScope as any).formSaved = true;\r\n }\r\n }\r\n\r\n updateProfessionsCheckboxes(\r\n applicant: CaseMemberDTO,\r\n index: number,\r\n ): boolean {\r\n if (applicant) {\r\n this.professionsList.forEach((p) => {\r\n if (applicant[\"YearsWorkedInProfessionsList\" + p] > 0) {\r\n this[\"YearsWorkedInProfessionsList\" + p + \"Checkbox\"][index] = true;\r\n }\r\n });\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n finish(): void {\r\n this.$location.path(\r\n \"/devexperience/\" + this.caseid + \"/\" + this.devexperienceId + \"/2\",\r\n );\r\n (this.$rootScope as any).formSaved = true;\r\n }\r\n\r\n addAssetLiabilityItem(\r\n currentApplicant: CaseMemberDTO,\r\n ALTtype,\r\n AlTItem,\r\n description,\r\n value,\r\n startDate = null,\r\n endDate = null,\r\n ) {\r\n if (value === null || value === undefined) {\r\n value = 0;\r\n }\r\n\r\n var newAssetLiabilityItem: AssetLiabilityItemDTO = {\r\n ALType: ALTtype,\r\n ALItemType: AlTItem,\r\n Description: description,\r\n Value: value,\r\n StartDate: startDate,\r\n EndDate: endDate,\r\n CaseMemberId: currentApplicant.Id,\r\n Id: 0,\r\n IsDeleted: false,\r\n CreatedDateTime: null,\r\n LastUpdatedDateTime: null,\r\n } as AssetLiabilityItemDTO;\r\n currentApplicant.AssetLiabilityItems.push(newAssetLiabilityItem);\r\n this.assetLiabilityItemService\r\n .addUpdatelistreturnonlyids(currentApplicant.AssetLiabilityItems)\r\n .then((response) => {\r\n //update IDs\r\n currentApplicant.AssetLiabilityItems.forEach((x, index) => {\r\n x.Id = response[index];\r\n });\r\n this.asset = {};\r\n })\r\n .catch((error) => {\r\n this.error = true;\r\n })\r\n .finally(() => {\r\n delete this.asset;\r\n });\r\n }\r\n\r\n //Calculations\r\n\r\n CalculateTotalAssets(currentApplicant: CaseMemberDTO): number {\r\n var totalAssets: number = 0;\r\n if (currentApplicant && currentApplicant.AssetLiabilityItems) {\r\n for (let i = 0; i < currentApplicant.AssetLiabilityItems.length; i++) {\r\n if (\r\n currentApplicant.AssetLiabilityItems[i].ALType === ALTypeEnum.Asset\r\n ) {\r\n totalAssets += Number(currentApplicant.AssetLiabilityItems[i].Value);\r\n }\r\n }\r\n }\r\n return totalAssets;\r\n }\r\n\r\n CalculateTotalLiabilities(currentApplicant: CaseMemberDTO): number {\r\n var totalLiabilities: number = 0;\r\n if (currentApplicant && currentApplicant.AssetLiabilityItems) {\r\n for (let i = 0; i < currentApplicant.AssetLiabilityItems.length; i++) {\r\n if (\r\n currentApplicant.AssetLiabilityItems[i].ALType ===\r\n ALTypeEnum.Liability\r\n ) {\r\n totalLiabilities += Number(\r\n currentApplicant.AssetLiabilityItems[i].Value,\r\n );\r\n }\r\n }\r\n }\r\n return totalLiabilities;\r\n }\r\n\r\n CalculateTotalOutstandingPersonalGuarantees(\r\n currentApplicant: CaseMemberDTO,\r\n ): number {\r\n var totalPersonalGuarantees: number = 0;\r\n if (currentApplicant && currentApplicant.AssetLiabilityItems) {\r\n for (let i = 0; i < currentApplicant.AssetLiabilityItems.length; i++) {\r\n if (\r\n currentApplicant.AssetLiabilityItems[i].ALType ===\r\n ALTypeEnum.PersonalGuarantee\r\n ) {\r\n totalPersonalGuarantees += Number(\r\n currentApplicant.AssetLiabilityItems[i].Value,\r\n );\r\n }\r\n }\r\n }\r\n return totalPersonalGuarantees;\r\n }\r\n\r\n CalculateTotalNetAssets(currentApplicant: CaseMemberDTO): number {\r\n var totalNetAssets: number;\r\n\r\n if (currentApplicant && currentApplicant.AssetLiabilityItems) {\r\n totalNetAssets =\r\n this.CalculateTotalAssets(currentApplicant) -\r\n this.CalculateTotalLiabilities(currentApplicant);\r\n }\r\n return totalNetAssets;\r\n }\r\n\r\n cancelDelete() {\r\n this.confirmationDelete = false;\r\n }\r\n\r\n deleteConfirmationMessage(\r\n applicant: CaseMemberDTO,\r\n item: AssetLiabilityItemDTO,\r\n ) {\r\n this.item = item;\r\n this.applicant = applicant;\r\n this.confirmationDelete = true;\r\n }\r\n\r\n removeAssetLiabilityItem() {\r\n this.confirmationDelete = false;\r\n let index = this.applicant.AssetLiabilityItems.indexOf(this.item);\r\n this.applicant.AssetLiabilityItems.splice(index, 1);\r\n }\r\n\r\n renameItem(item: AssetLiabilityItemDTO) {\r\n this.ALItemType = item.ALItemType;\r\n this.newDescription = item.Description;\r\n this.newValue = item.Value;\r\n this.newStartDate = item.StartDate;\r\n this.newEndDate = item.EndDate;\r\n\r\n if (this.renamingItem === undefined) {\r\n this.renamingItem = item;\r\n } else {\r\n delete this.renamingItem;\r\n }\r\n }\r\n\r\n renamingItemComplete(\r\n currentApplicant: CaseMemberDTO,\r\n item: AssetLiabilityItemDTO,\r\n index: number,\r\n ) {\r\n this.assetLiabilityItemService\r\n .addUpdatelistreturnonlyids(currentApplicant.AssetLiabilityItems)\r\n .then((response) => {\r\n //update IDs\r\n currentApplicant.AssetLiabilityItems.forEach((x, index) => {\r\n x.Id = response[index];\r\n });\r\n this.asset = {};\r\n })\r\n .catch((error) => {\r\n this.error = true;\r\n })\r\n .finally(() => {});\r\n\r\n delete this.renamingItem;\r\n }\r\n\r\n cancelSaveItem(item: AssetLiabilityItemDTO, index: number) {\r\n item.ALItemType = this.ALItemType;\r\n item.Description = this.newDescription;\r\n item.Value = this.newValue;\r\n item.StartDate = this.newStartDate;\r\n item.EndDate = this.newEndDate;\r\n delete this.renamingItem;\r\n }\r\n\r\n showprofession(enumVal: number) {\r\n if (this.currentShareholder) {\r\n return (\r\n this.currentShareholder.DevelopedPropertyBefore &&\r\n (this.currentShareholder.ProfessionsWorkedIn & enumVal) == enumVal\r\n );\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n resetDuplicateMessage(index: number) {\r\n this.duplicate[index] = 0;\r\n }\r\n\r\n addQualification(\r\n currentApplicant: CaseMemberDTO,\r\n index,\r\n isQualification,\r\n qualificationOrSkill,\r\n ) {\r\n this.saving = true;\r\n if (\r\n currentApplicant.Qualifications === null ||\r\n !currentApplicant.Qualifications\r\n ) {\r\n currentApplicant.Qualifications = [];\r\n }\r\n if (\r\n !currentApplicant.Qualifications.find(\r\n (x) =>\r\n x.QualificationOrSkill === qualificationOrSkill ||\r\n x.QualificationOrSkill === qualificationOrSkill,\r\n )\r\n ) {\r\n var qual = {\r\n CaseMemberId: currentApplicant.Id,\r\n QualificationOrSkill: qualificationOrSkill,\r\n IsQualification: isQualification,\r\n Id: 0,\r\n IsDeleted: false,\r\n } as QualificationsDTO;\r\n currentApplicant.Qualifications.push(qual);\r\n\r\n this.qualificationsService\r\n .addUpdatelistreturnonlyids(currentApplicant.Qualifications)\r\n .then((response) => {\r\n //update IDs\r\n currentApplicant.Qualifications.forEach((x, index) => {\r\n x.Id = response[index];\r\n });\r\n })\r\n .catch((error) => {\r\n this.error = true;\r\n })\r\n .finally(() => {\r\n delete this.newQualification[index];\r\n delete this.newSkill[index];\r\n this.saving = false;\r\n });\r\n } else {\r\n //Qualification already present\r\n if (isQualification) {\r\n //Qual entered already on list\r\n this.duplicate[index] = 1;\r\n } else {\r\n //Skill entered already on list\r\n this.duplicate[index] = 2;\r\n }\r\n this.saving = false;\r\n delete this.newQualification[index];\r\n delete this.newSkill[index];\r\n }\r\n }\r\n\r\n removeSkillOrQualification(\r\n currentApplicant: CaseMemberDTO,\r\n item: QualificationsDTO,\r\n ) {\r\n let index = currentApplicant.Qualifications.indexOf(item);\r\n currentApplicant.Qualifications.splice(index, 1);\r\n }\r\n\r\n getALItemType(ALItemType) {\r\n ALItemType = parseInt(ALItemType);\r\n var ALItemTypeValue = \"\";\r\n switch (ALItemType) {\r\n case ALItemTypeEnum.Other: {\r\n ALItemTypeValue = \"Other\";\r\n break;\r\n }\r\n case ALItemTypeEnum.ResidentialProperty: {\r\n ALItemTypeValue = \"Residential Property\";\r\n break;\r\n }\r\n case ALItemTypeEnum.OverseasProperty: {\r\n ALItemTypeValue = \"Overseas Property\";\r\n break;\r\n }\r\n case ALItemTypeEnum.BTLProperty: {\r\n ALItemTypeValue = \"BTL Property\";\r\n break;\r\n }\r\n case ALItemTypeEnum.CommercialProperty: {\r\n ALItemTypeValue = \"Commercial Property\";\r\n break;\r\n }\r\n case ALItemTypeEnum.ArtJewellryAntique: {\r\n ALItemTypeValue = \"Art Jewellry Antique\";\r\n break;\r\n }\r\n case ALItemTypeEnum.CashDeposits: {\r\n ALItemTypeValue = \"Cash / Deposits\";\r\n break;\r\n }\r\n case ALItemTypeEnum.StocksShares: {\r\n ALItemTypeValue = \"Stocks & Shares\";\r\n break;\r\n }\r\n case ALItemTypeEnum.VehicleBoat: {\r\n ALItemTypeValue = \"Vehicle / Boats\";\r\n break;\r\n }\r\n case 8: {\r\n ALItemTypeValue = \"Business Equipment / Plant & Machinery\";\r\n break;\r\n }\r\n case 9: {\r\n ALItemTypeValue = \"Art / Jewellery / Antiques\";\r\n break;\r\n }\r\n case ALItemTypeEnum.ResidentialPropertyLoan: {\r\n ALItemTypeValue = \"Residential Property Loan\";\r\n break;\r\n }\r\n case ALItemTypeEnum.OverseasPropertyLoan: {\r\n ALItemTypeValue = \"Overseas Property Loan\";\r\n break;\r\n }\r\n case ALItemTypeEnum.BTLPropertyLoan: {\r\n ALItemTypeValue = \"BTL Property Loan\";\r\n break;\r\n }\r\n case ALItemTypeEnum.CommercialPropertyLoan: {\r\n ALItemTypeValue = \"Commercial Property Loan\";\r\n break;\r\n }\r\n case ALItemTypeEnum.Overdraft: {\r\n ALItemTypeValue = \"Overdraft\";\r\n break;\r\n }\r\n case ALItemTypeEnum.HPLease: {\r\n ALItemTypeValue = \"HP / Leasing\";\r\n break;\r\n }\r\n case ALItemTypeEnum.Overdraft: {\r\n ALItemTypeValue = \"HP / Leasing\";\r\n break;\r\n }\r\n case 35: {\r\n ALItemTypeValue = \"Overdraft\";\r\n break;\r\n }\r\n case 36: {\r\n ALItemTypeValue = \"Other Bank / Finance Loans\";\r\n break;\r\n }\r\n case ALItemTypeEnum.PersonalGuarantee: {\r\n ALItemTypeValue = \"Outstanding Personal Guarantee\";\r\n break;\r\n }\r\n\r\n default: {\r\n ALItemTypeValue = \"Unknown\";\r\n break;\r\n }\r\n }\r\n return ALItemTypeValue;\r\n }\r\n\r\n proprtyTypeFilter(property) {\r\n if (property.ALType == ALTypeEnum.Asset) {\r\n return (\r\n property.ALItemType == ALItemTypeEnum.ResidentialProperty ||\r\n property.ALItemType == ALItemTypeEnum.OverseasProperty ||\r\n property.ALItemType == ALItemTypeEnum.BTLProperty ||\r\n property.ALItemType == ALItemTypeEnum.CommercialProperty\r\n );\r\n }\r\n }\r\n\r\n otherProprtyTypeFilter(property) {\r\n if (property.ALType == ALTypeEnum.Asset) {\r\n return (\r\n property.ALItemType == ALItemTypeEnum.CashDeposits ||\r\n property.ALItemType == ALItemTypeEnum.StocksShares ||\r\n property.ALItemType == ALItemTypeEnum.VehicleBoat ||\r\n property.ALItemType == ALItemTypeEnum.BusinessEquipment ||\r\n property.ALItemType == ALItemTypeEnum.ArtJewellryAntique ||\r\n property.ALItemType == ALItemTypeEnum.Other\r\n );\r\n }\r\n }\r\n\r\n liabilitiesFilter(property) {\r\n if (property.ALType == ALTypeEnum.Liability) {\r\n return (\r\n property.ALItemType == ALItemTypeEnum.ResidentialPropertyLoan ||\r\n property.ALItemType == ALItemTypeEnum.OverseasPropertyLoan ||\r\n property.ALItemType == ALItemTypeEnum.BTLPropertyLoan ||\r\n property.ALItemType == ALItemTypeEnum.CommercialPropertyLoan\r\n );\r\n }\r\n }\r\n\r\n otherliabilitiesFilter(property) {\r\n if (property.ALType == ALTypeEnum.Liability) {\r\n return (\r\n property.ALItemType == ALItemTypeEnum.HPLease ||\r\n property.ALItemType == ALItemTypeEnum.Overdraft ||\r\n property.ALItemType == ALItemTypeEnum.OtherLoan ||\r\n property.ALItemType == ALItemTypeEnum.Other\r\n );\r\n }\r\n }\r\n\r\n isInvalidForm(\r\n description: string,\r\n value: number,\r\n startDate: Date,\r\n endDate: Date,\r\n prefix: string,\r\n ) {\r\n if (!description || !value) {\r\n return true;\r\n }\r\n\r\n var validStartDate = document\r\n .getElementById(prefix + \"-startDate\")\r\n .className.search(\"ng-valid\");\r\n var validEndDate = document\r\n .getElementById(prefix + \"-endDate\")\r\n .className.search(\"ng-valid\");\r\n\r\n if (validStartDate < 0 || validEndDate < 0) {\r\n return true;\r\n }\r\n\r\n if (startDate && !this.isValidDate(startDate)) {\r\n return true;\r\n }\r\n\r\n if (endDate && !this.isValidDate(endDate)) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n isAddFormValid(\r\n description: string,\r\n value: number,\r\n startDate: Date,\r\n endDate: Date,\r\n ) {\r\n this.isAddFormInvalid = this.isInvalidForm(\r\n description,\r\n value,\r\n startDate,\r\n endDate,\r\n \"add\",\r\n );\r\n }\r\n\r\n isEditFormValid(\r\n description: string,\r\n value: number,\r\n startDate: Date,\r\n endDate: Date,\r\n ) {\r\n this.isEditFormInvalid = this.isInvalidForm(\r\n description,\r\n value,\r\n startDate,\r\n endDate,\r\n \"edit\",\r\n );\r\n }\r\n\r\n isValidDate(date: Date) {\r\n if (date.getFullYear() > 1900 && date.getFullYear() < 2900) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Save a new PostAddress history item\r\n * @param shareholder\r\n */\r\n saveAddressHistory(shareholder: CaseMemberDTO) {\r\n var id: number = 0;\r\n\r\n if (!this.shareholderAddressHistory) {\r\n this.shareholderAddressHistory = [];\r\n }\r\n\r\n // If the Id hasn't been set then this is a new previous address\r\n if (this.addressHistoryItem.Id == null) {\r\n id = this.getNextAddressHistoryId();\r\n this.addressHistoryItem.Id = id;\r\n this.shareholderAddressHistory.push(this.addressHistoryItem);\r\n } else {\r\n var foundIndex = this.shareholderAddressHistory\r\n .map(function (a) {\r\n return a.Id;\r\n })\r\n .indexOf(this.addressHistoryItem.Id);\r\n if (foundIndex > -1) {\r\n this.shareholderAddressHistory.splice(\r\n foundIndex,\r\n 1,\r\n this.addressHistoryItem,\r\n ); // removed previous entry and adds the updated one in its place\r\n }\r\n }\r\n\r\n this.caseMemberService\r\n .saveAddressHistory(\r\n shareholder.Id,\r\n JSON.stringify(this.shareholderAddressHistory),\r\n )\r\n .then((addressHistory: string) => {\r\n shareholder.AddressHistory = addressHistory;\r\n this.parseAddressHistory(addressHistory);\r\n this.showAddressHistoryModal = false;\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem saving the address history. Please try again later.\";\r\n })\r\n .finally(() => {\r\n this.showAddressHistoryModal = false;\r\n });\r\n }\r\n\r\n getNextAddressHistoryId(): number {\r\n if (this.shareholderAddressHistory.length == 0) {\r\n return 1;\r\n } else {\r\n // Get the current maximum Id and add one to it for the next ID\r\n var id = Math.max.apply(\r\n Math,\r\n this.shareholderAddressHistory.map(function (a) {\r\n return a.Id;\r\n }),\r\n );\r\n id++;\r\n return id;\r\n }\r\n }\r\n\r\n /**\r\n * Convert addres history JSON back to an array of PostalAddress objects\r\n * @param addressHistoryJson\r\n */\r\n parseAddressHistory(addressHistoryJson: string) {\r\n // JSON doesn't understand date types so therefore user the reviver function to manually convert them back to dates as opposed to strings\r\n this.shareholderAddressHistory = JSON.parse(\r\n addressHistoryJson,\r\n this.reviver,\r\n );\r\n\r\n // Order the address histories by the from date (ascending)\r\n this.shareholderAddressHistory.sort(\r\n (a: AddressHistoryDTO, b: AddressHistoryDTO) => {\r\n return this.getTime(a.FromDate) - this.getTime(b.FromDate);\r\n },\r\n );\r\n }\r\n\r\n getTime(date?: Date) {\r\n return date != null ? date.getTime() : 0;\r\n }\r\n\r\n /**\r\n * Tests whether a string is a date and converts it if so - used in JSON.parse\r\n * @param key\r\n * @param value\r\n */\r\n reviver(key, value) {\r\n var a;\r\n if ((typeof value === \"string\" && key == \"ToDate\") || key == \"FromDate\") {\r\n a = Date.parse(value);\r\n if (a) {\r\n return new Date(a);\r\n }\r\n }\r\n return value;\r\n }\r\n\r\n getAddressAsString(address: PostalAddress) {\r\n var addressAsString: string = \"\";\r\n\r\n addressAsString = this.concatenateAddressLine(\r\n address.AddressLine1,\r\n addressAsString,\r\n );\r\n addressAsString = this.concatenateAddressLine(\r\n address.AddressLine2,\r\n addressAsString,\r\n );\r\n addressAsString = this.concatenateAddressLine(\r\n address.AddressLine3,\r\n addressAsString,\r\n );\r\n addressAsString = this.concatenateAddressLine(\r\n address.AddressLine4,\r\n addressAsString,\r\n );\r\n\r\n return addressAsString;\r\n }\r\n\r\n concatenateAddressLine(addressLine: string, concatenatedAddress: string) {\r\n if (addressLine != null && addressLine.length > 0) {\r\n if (concatenatedAddress.length > 0) {\r\n concatenatedAddress = concatenatedAddress.concat(\", \", addressLine);\r\n } else {\r\n concatenatedAddress = concatenatedAddress.concat(addressLine);\r\n }\r\n }\r\n\r\n return concatenatedAddress;\r\n }\r\n\r\n openAddressHistoryModal(addressHistory: AddressHistoryDTO = null) {\r\n this.previousAddressSearchResults = [];\r\n this.previousAddressPostCodeOptions = [];\r\n\r\n if (addressHistory) {\r\n this.addressHistoryItem = addressHistory;\r\n } else {\r\n this.addressHistoryItem = null;\r\n }\r\n\r\n this.showAddressHistoryModal = true;\r\n }\r\n\r\n showConfirmAddressDelete(addressHistoryId: number) {\r\n this.showAddHistoryConfirmDelete = true;\r\n this.addressHistoryIdToDelete = addressHistoryId;\r\n }\r\n\r\n deleteAddressHistory() {\r\n this.showAddHistoryConfirmDelete = false;\r\n\r\n var foundIndex = this.shareholderAddressHistory\r\n .map(function (a) {\r\n return a.Id;\r\n })\r\n .indexOf(this.addressHistoryIdToDelete);\r\n\r\n if (foundIndex > -1) {\r\n this.shareholderAddressHistory.splice(foundIndex, 1);\r\n\r\n this.caseMemberService\r\n .saveAddressHistory(\r\n this.currentShareholder.Id,\r\n JSON.stringify(this.shareholderAddressHistory),\r\n )\r\n .then((addressHistory: string) => {\r\n this.currentShareholder.AddressHistory = addressHistory;\r\n this.parseAddressHistory(addressHistory);\r\n this.showAddressHistoryModal = false;\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem deleting the address history item. Please try again later.\";\r\n });\r\n }\r\n }\r\n\r\n formatDate(unformattedDate) {\r\n if (unformattedDate) {\r\n var formattedDate = new Date(\r\n unformattedDate.getTime() - unformattedDate.getTimezoneOffset() * 60000,\r\n )\r\n .toISOString()\r\n .split(\"T\")[0];\r\n\r\n return formattedDate;\r\n }\r\n }\r\n\r\n getAddressList(app: CaseMemberDTO, index: number, searchTerm: string) {\r\n let foundMatch = false;\r\n\r\n if (\r\n this.PostCodeOptions &&\r\n this.PostCodeOptions[index] &&\r\n this.PostCodeOptions[index].length > 0\r\n ) {\r\n let addressLookup = this.PostCodeOptions[index].find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n\r\n // We've selected an address!\r\n this.streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n this.currentShareholder.StreetAddress = address;\r\n this.searchterm[index] = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n this.currentShareholder.StreetAddress.AddressLine1 =\r\n addressLookup.AddressLine2;\r\n this.currentShareholder.StreetAddress.AddressLine2 =\r\n addressLookup.AddressLine3;\r\n this.currentShareholder.StreetAddress.AddressLine3 =\r\n addressLookup.AddressLine4;\r\n this.currentShareholder.StreetAddress.AddressLine4 =\r\n addressLookup.PostCode;\r\n this.currentShareholder.StreetAddress.PostCode =\r\n addressLookup.AddressLine1;\r\n this.searchterm[index] = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n // Initial search term\r\n this.PostCodeOptions[index] = [];\r\n\r\n this.streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.PostCodeOptions[index] = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n getAddressListArray(app: CaseMemberDTO, index: number, searchTerm: string) {\r\n let foundMatch = false;\r\n\r\n if (\r\n this.PostCodeOptions &&\r\n this.PostCodeOptions[index] &&\r\n this.PostCodeOptions[index].length > 0\r\n ) {\r\n let addressLookup = this.PostCodeOptions[index].find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n\r\n // We've selected an address!\r\n this.streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n app.StreetAddress = address;\r\n this.searchterm[index] = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n this.development.DevelopmentTrackRecords[\r\n index\r\n ].StreetAddress.AddressLine1 = addressLookup.AddressLine2;\r\n this.development.DevelopmentTrackRecords[\r\n index\r\n ].StreetAddress.AddressLine2 = addressLookup.AddressLine3;\r\n this.development.DevelopmentTrackRecords[\r\n index\r\n ].StreetAddress.AddressLine3 = addressLookup.AddressLine4;\r\n this.development.DevelopmentTrackRecords[\r\n index\r\n ].StreetAddress.AddressLine4 = addressLookup.PostCode;\r\n this.development.DevelopmentTrackRecords[index].StreetAddress.PostCode =\r\n addressLookup.AddressLine1;\r\n this.searchterm[index] = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n // Initial search term\r\n this.PostCodeOptions[index] = [];\r\n\r\n this.streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.PostCodeOptions[index] = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n lookupPreviousAddress(searchTerm: string) {\r\n let foundMatch = false;\r\n\r\n if (\r\n this.previousAddressPostCodeOptions &&\r\n this.previousAddressPostCodeOptions &&\r\n this.previousAddressPostCodeOptions.length > 0\r\n ) {\r\n let addressLookup = this.previousAddressPostCodeOptions.find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n\r\n // We've selected an address!\r\n this.streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n this.addressHistoryItem = {\r\n AddressLine1: address.AddressLine1,\r\n AddressLine2: address.AddressLine2,\r\n AddressLine3: address.AddressLine3,\r\n AddressLine4: address.AddressLine4,\r\n PostCode: address.PostCode,\r\n };\r\n\r\n this.previousAddressSearchTerm = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n this.addressHistoryItem = {\r\n AddressLine1: addressLookup.AddressLine2,\r\n AddressLine2: addressLookup.AddressLine3,\r\n AddressLine3: addressLookup.AddressLine4,\r\n AddressLine4: addressLookup.PostCode,\r\n PostCode: addressLookup.AddressLine1,\r\n };\r\n\r\n this.previousAddressSearchTerm = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n // Initial search term\r\n this.previousAddressPostCodeOptions = [];\r\n\r\n this.streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.previousAddressPostCodeOptions = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n autofillShareholderInfo() {\r\n this.currentShareholder.DevelopedPropertyBefore = true;\r\n this.currentShareholder.LengthOfTimeBeenDeveloper = 10;\r\n this.currentShareholder.DevelopedPropertyBeforeNumber = 7;\r\n this.currentShareholder.DevelopedResidentialPropertyCompletedNumber = 7;\r\n // this.YearsWorkedInProfessionsListProjectManagerCheckbox[1] = true;\r\n this.currentShareholder.YearsWorkedInProfessionsListProjectManager = 7;\r\n this.addAssetLiabilityItem(\r\n this.currentShareholder,\r\n ALTypeEnum.Asset,\r\n ALItemTypeEnum.ResidentialProperty,\r\n \"32 Brookside Road\",\r\n 900000,\r\n null,\r\n null,\r\n );\r\n this.addAssetLiabilityItem(\r\n this.currentShareholder,\r\n ALTypeEnum.Asset,\r\n ALItemTypeEnum.BTLProperty,\r\n \"10 Brookside Road\",\r\n 100000,\r\n null,\r\n null,\r\n );\r\n this.addAssetLiabilityItem(\r\n this.currentShareholder,\r\n ALTypeEnum.Asset,\r\n ALItemTypeEnum.CommercialProperty,\r\n \"King Street, York\",\r\n 2300000,\r\n null,\r\n null,\r\n );\r\n this.addAssetLiabilityItem(\r\n this.currentShareholder,\r\n ALTypeEnum.Asset,\r\n ALItemTypeEnum.CashDeposits,\r\n \"Savings\",\r\n 1000000,\r\n null,\r\n null,\r\n );\r\n this.addAssetLiabilityItem(\r\n this.currentShareholder,\r\n ALTypeEnum.Asset,\r\n ALItemTypeEnum.StocksShares,\r\n \"Barclays Bank\",\r\n 450000,\r\n null,\r\n null,\r\n );\r\n this.addAssetLiabilityItem(\r\n this.currentShareholder,\r\n ALTypeEnum.Liability,\r\n ALItemTypeEnum.ResidentialPropertyLoan,\r\n \"32 Brookside\",\r\n 450000,\r\n null,\r\n null,\r\n );\r\n const maxDate = Date.now();\r\n const timestamp = Math.floor(Math.random() * maxDate);\r\n const timestamp2 = timestamp + 20;\r\n this.addAssetLiabilityItem(\r\n this.currentShareholder,\r\n 2,\r\n 60,\r\n \"Example lender\",\r\n 400000,\r\n new Date(timestamp),\r\n new Date(timestamp2),\r\n );\r\n }\r\n}\r\n","import { AddressLookupDTO } from \"@js/DTO/AddressLookupDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { ContactDetailsDTO } from \"@js/DTO/ContactDetailsDTO.cs.d\";\r\nimport { DealDTO } from \"@js/DTO/Deal/DealDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { PostalAddress } from \"@js/models/PostalAddress.cs.d\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { StreetAddressService } from \"@js/services/StreetAddressService\";\r\n\r\nexport class ApplicationDetailsController {\r\n //Search address\r\n searchresults: string;\r\n PostCodeOptions: PostalAddress[] = [];\r\n searchterm: string;\r\n searchingForAddress: boolean = false;\r\n\r\n //Case info\r\n loanCriteria: DevelopmentInputDTO;\r\n case: CaseDTO;\r\n deal: DealDTO;\r\n siteDetails: ContactDetailsDTO;\r\n accountantDetails: ContactDetailsDTO;\r\n solicitorDetails: ContactDetailsDTO;\r\n\r\n //Sections\r\n site: boolean = false;\r\n accountant: boolean = false;\r\n solicitors: boolean = false;\r\n\r\n isDeal: boolean = false;\r\n\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"CaseService\",\r\n \"$location\",\r\n \"StreetAddressService\",\r\n \"$q\",\r\n \"RoleService\",\r\n \"DealService\",\r\n ];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private caseService: CaseService,\r\n private $location: ng.ILocationService,\r\n private $streetAddressService: StreetAddressService,\r\n protected $q: ng.IQService,\r\n private roleService: RoleService,\r\n private dealService: DealService,\r\n ) {\r\n if (this.$routeParams.DealId) {\r\n this.isDeal = true;\r\n }\r\n\r\n if (this.isDeal) {\r\n this.dealService.fetch(this.$routeParams.DealId).then((result) => {\r\n this.deal = result;\r\n this.siteDetails = this.parseContactDetails(this.deal.SiteDetails);\r\n this.accountantDetails = this.parseContactDetails(\r\n this.deal.AccountantDetails,\r\n );\r\n this.solicitorDetails = this.parseContactDetails(\r\n this.deal.SolicitorDetails,\r\n );\r\n });\r\n } else {\r\n this.caseService.fetch(this.$routeParams.CaseId).then((result) => {\r\n this.case = result;\r\n this.siteDetails = this.parseContactDetails(this.case.SiteDetails);\r\n this.accountantDetails = this.parseContactDetails(\r\n this.case.AccountantDetails,\r\n );\r\n this.solicitorDetails = this.parseContactDetails(\r\n this.case.SolicitorDetails,\r\n );\r\n });\r\n }\r\n }\r\n\r\n goToCaseDashboard(saveChanges: boolean): void {\r\n if (saveChanges && !this.roleService.IsLender) {\r\n this.save().then((response) => {\r\n (this.$rootScope as any).formSaved = true;\r\n this.dealService.goToCaseDashboard(\r\n this.deal.Id,\r\n this.deal.ProductFamily,\r\n );\r\n });\r\n } else {\r\n this.dealService.goToCaseDashboard(this.deal.Id, this.deal.ProductFamily);\r\n }\r\n }\r\n\r\n goToDealForum(saveChanges: boolean): void {\r\n if (saveChanges && !this.roleService.IsLender) {\r\n this.save().then((response) => {\r\n (this.$rootScope as any).formSaved = true;\r\n this.isDeal\r\n ? this.$location.path(\"/dealforum/\" + this.deal.Id)\r\n : this.$location.path(\"/lending/\" + this.case.Id);\r\n });\r\n } else {\r\n this.isDeal\r\n ? this.$location.path(\"/dealforum/\" + this.deal.Id)\r\n : this.$location.path(\"/lending/\" + this.case.Id);\r\n }\r\n }\r\n\r\n expandOrCollapse(value: boolean) {\r\n this.site = value;\r\n this.accountant = value;\r\n this.solicitors = value;\r\n return value;\r\n }\r\n\r\n save(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n if (this.isDeal) {\r\n this.deal.SiteDetails = JSON.stringify(this.siteDetails);\r\n this.deal.AccountantDetails = JSON.stringify(this.accountantDetails);\r\n this.deal.SolicitorDetails = JSON.stringify(this.solicitorDetails);\r\n\r\n this.dealService\r\n .addUpdatereturnonlyid(this.deal)\r\n .then((response) => {\r\n defer.resolve(response as number);\r\n if (\r\n this.siteDetails.FirstName != null &&\r\n this.siteDetails.Email != null &&\r\n this.siteDetails.Role != null &&\r\n this.siteDetails.LastName != null &&\r\n this.solicitorDetails.FirstName != null &&\r\n this.solicitorDetails.LastName != null &&\r\n this.solicitorDetails.Email != null &&\r\n this.accountantDetails.FirstName != null &&\r\n this.accountantDetails.LastName != null &&\r\n this.accountantDetails.Email != null\r\n ) {\r\n this.dealService.setIsSupplimentInfoFilled(true);\r\n } else {\r\n this.dealService.setIsSupplimentInfoFilled(false);\r\n }\r\n this.goToDealForum(false);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n } else {\r\n this.case.SiteDetails = JSON.stringify(this.siteDetails);\r\n this.case.AccountantDetails = JSON.stringify(this.accountantDetails);\r\n this.case.SolicitorDetails = JSON.stringify(this.solicitorDetails);\r\n\r\n this.caseService\r\n .addUpdatereturnonlyid(this.case)\r\n .then((response) => {\r\n defer.resolve(response as number);\r\n if (\r\n this.siteDetails.FirstName != null &&\r\n this.siteDetails.Email != null &&\r\n this.siteDetails.Role != null &&\r\n this.siteDetails.LastName != null &&\r\n this.solicitorDetails.FirstName != null &&\r\n this.solicitorDetails.LastName != null &&\r\n this.solicitorDetails.Email != null &&\r\n this.accountantDetails.FirstName != null &&\r\n this.accountantDetails.LastName != null &&\r\n this.accountantDetails.Email != null\r\n ) {\r\n this.caseService.setIsSupplimentInfoFilled(true);\r\n } else {\r\n this.caseService.setIsSupplimentInfoFilled(false);\r\n }\r\n this.goToDealForum(false);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n }\r\n\r\n return defer.promise;\r\n }\r\n\r\n getAddressList(searchTerm: string) {\r\n let foundMatch = false;\r\n\r\n if (\r\n this.PostCodeOptions &&\r\n this.PostCodeOptions &&\r\n this.PostCodeOptions.length > 0\r\n ) {\r\n let addressLookup = this.PostCodeOptions.find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n\r\n // We've selected an address!\r\n this.$streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n this.siteDetails.AddressLine1 = address.AddressLine1;\r\n this.siteDetails.AddressLine2 = address.AddressLine2;\r\n this.siteDetails.AddressLine3 = address.AddressLine3;\r\n this.siteDetails.AddressLine4 = address.AddressLine4;\r\n this.siteDetails.PostCode = address.PostCode;\r\n\r\n this.searchterm = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n\r\n this.siteDetails.AddressLine1 = addressLookup.AddressLine1;\r\n this.siteDetails.AddressLine2 = addressLookup.AddressLine2;\r\n this.siteDetails.AddressLine3 = addressLookup.AddressLine3;\r\n this.siteDetails.AddressLine4 = addressLookup.AddressLine4;\r\n this.siteDetails.PostCode = addressLookup.PostCode;\r\n this.searchterm = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n // Initial search term\r\n this.PostCodeOptions = [];\r\n\r\n this.$streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.PostCodeOptions = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n parseContactDetails(contactHistoryJson: string): ContactDetailsDTO {\r\n return JSON.parse(contactHistoryJson);\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { LicenseAppPackageDTO } from \"@js/DTO/LicenseAppPackageDTO.cs.d\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class AssignLicensesController {\r\n step: number = 4;\r\n licenseData: LicenseAppPackageDTO;\r\n totalNoOfLicense: number = 0;\r\n unassignedLicenses: number = 0;\r\n load: boolean = false;\r\n user: ApplicationUserDTO[] = [];\r\n isUserDisabled: boolean[] = [];\r\n error: string = \"\";\r\n assignLicenseForm: ng.IFormController;\r\n progressBar: {\r\n step: number;\r\n label: string;\r\n active: boolean;\r\n complete: boolean;\r\n }[] = [\r\n { step: 1, label: \"About you\", active: false, complete: true },\r\n { step: 2, label: \"About your business\", active: false, complete: true },\r\n {\r\n step: 3,\r\n label: \"More about your business\",\r\n active: false,\r\n complete: true,\r\n },\r\n { step: 4, label: \"Assign licenses\", active: false, complete: false },\r\n ];\r\n displayMsg: string = \"\";\r\n showMsg: boolean = false;\r\n assignLaterClicked: boolean = false;\r\n\r\n static $inject = [\r\n \"$location\",\r\n \"PaymentService\",\r\n \"UserService\",\r\n \"OrganisationService\",\r\n ];\r\n\r\n constructor(\r\n private $location: ng.ILocationService,\r\n private $paymentService: PaymentService,\r\n private userService: UserService,\r\n private organisationService: OrganisationService,\r\n ) {\r\n this.getLicense();\r\n }\r\n getLicense() {\r\n this.$paymentService.getLicense().then((response) => {\r\n this.licenseData = response;\r\n this.totalNoOfLicense = this.licenseData.TotalQuantity;\r\n if (this.totalNoOfLicense - 1 > 0) {\r\n this.$paymentService.getTotalUnassignedLicenses().then((response) => {\r\n this.unassignedLicenses = response;\r\n for (let i = 1; i <= this.unassignedLicenses; i++) {\r\n var newUser: ApplicationUserDTO = {\r\n Id: \"\",\r\n Roles: [\"Introducer\", \"Broker\"],\r\n } as ApplicationUserDTO;\r\n this.user.push(newUser);\r\n this.isUserDisabled.push(false);\r\n }\r\n });\r\n } else {\r\n this.progressBar[3].complete = true;\r\n }\r\n\r\n this.load = true;\r\n });\r\n }\r\n\r\n getNumber = function (num) {\r\n return new Array(num);\r\n };\r\n\r\n assignLicenses(user: ApplicationUserDTO, index: number) {\r\n var assignedLicenseusers = [];\r\n user.Roles = [\"Introducer\", \"Broker\"];\r\n assignedLicenseusers.push(user);\r\n this.userService\r\n .registerBrokerUsers(assignedLicenseusers)\r\n .then((response: string) => {\r\n if (response.length == 0) {\r\n this.displayMsg = `Successfully assigned a license to ${assignedLicenseusers[0].FirstName} ${assignedLicenseusers[0].LastName}`;\r\n this.isUserDisabled[index] = true;\r\n this.showMsg = true;\r\n this.unassignedLicenses -= 1;\r\n } else {\r\n this.displayMsg = response;\r\n this.showMsg = true;\r\n }\r\n });\r\n }\r\n\r\n goToUserDashboard() {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n isFormValid() {\r\n if (this.unassignedLicenses > 0) {\r\n if (!this.assignLicenseForm.$invalid) {\r\n this.progressBar[3].complete = true;\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n } else {\r\n this.progressBar[3].complete = true;\r\n return true;\r\n }\r\n }\r\n\r\n assignLater() {\r\n if (this.unassignedLicenses > 0 && this.assignLaterClicked) {\r\n this.organisationService.brokerSignUpJourneyG5Email().then((response) => {\r\n this.$location.path(\"/userdashboard\");\r\n this.user = [];\r\n });\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n this.user = [];\r\n }\r\n }\r\n}\r\n","export class BorrowerTermsController {\r\n static $inject = [\"$routeParams\", \"$scope\", \"$location\"];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $scope: ng.IScope,\r\n private $location: ng.ILocationService,\r\n ) {}\r\n}\r\n","export const enum CaseAccessLevelEnum {\r\n Hidden = 0,\r\n ReadOnly = 1,\r\n FullAccess = 10,\r\n}\r\n","export const enum CaseLenderStateEnum {\r\n Shortlisted = 0,\r\n Received = 1,\r\n Offered = 2,\r\n Rejected = 3,\r\n Withdrawn = 4,\r\n Cancelled = 5,\r\n Applied = 10,\r\n SentToPackager = 11\r\n}\r\n","export const enum ExistingPlanningChangeTypeEnum {\r\n None = 0,\r\n EnhancedPlanningOnExistingBuilding = 1,\r\n PermittedDevelopmentOnExistingBuilding = 2,\r\n BrandNewPlanningApplication = 3,\r\n}\r\n","export const enum ExitStrategyEnum {\r\n None = 0,\r\n Sale = 1,\r\n Refinance = 2,\r\n PartSalePartRefinance = 8,\r\n SaleOfAlternativeAsset = 16,\r\n Other = 4,\r\n}\r\n","export const enum LenderProductTypeEnum {\r\n None = 0,\r\n All = 1,\r\n DevelopmentFinance = 2,\r\n BridgingFinance = 4,\r\n CommercialMortgages = 8,\r\n}\r\n","export const enum LoanPurposeEnum {\r\n Speed = 1,\r\n DepositForAnotherPurchase = 2,\r\n Rebridge = 3,\r\n Other = 4,\r\n ChainBreak = 5,\r\n AuctionPurchase = 6,\r\n Refurbishment = 7,\r\n AnyOtherLegalPurpose = 8,\r\n}\r\n","export const enum ModuleEnum {\r\n CaseOverview = 0,\r\n DeveloperProfile = 1,\r\n DevelopmentAppraisal = 2,\r\n DevelopmentSchedule = 3,\r\n Planning = 4,\r\n ProfessionalTeam = 5,\r\n ComparableProperties = 6,\r\n Case = 7,\r\n Track = 8,\r\n AssetsLiabilities = 9,\r\n ProofOfIncome = 10,\r\n ApplicantDetails = 11,\r\n Images = 12,\r\n DIP = 13,\r\n Property = 14,\r\n BuildCosts = 15,\r\n}\r\n","export const enum OwnNewDevelopmentEnum {\r\n UKLimitedCompany = 1,\r\n UKLimitedLiabilityPartnership = 2,\r\n PersonalNames = 3,\r\n OverseasLimitedCompany = 4,\r\n PensionFund = 5,\r\n Other = 6,\r\n}\r\n","export const enum PropertyTypeDetailEnum {\r\n None = 0,\r\n Houses = 1,\r\n Flats = 2,\r\n HousesAndFlats = 4,\r\n}\r\n","export const enum TenureEnum {\r\n Freehold = 0,\r\n Leasehold = 1,\r\n Other = 2,\r\n ShareOfFreehold = 3,\r\n CommonholdOwnership = 4,\r\n JointOwnershipJointTenants = 5,\r\n JointOwnershipTenantsInCommon = 6,\r\n}\r\n","export const enum TitleEnum {\r\n None = 0,\r\n Mr = 1,\r\n Mrs = 2,\r\n Miss = 3,\r\n Ms = 4,\r\n Other = 5,\r\n}\r\n","export const enum EventLogEnum {\r\n None = 0,\r\n PageLoad = 1,\r\n Save = 2,\r\n Shortlisting = 3,\r\n Export = 4,\r\n LenderReferral = 5,\r\n EnterpriseUserRegistration = 6,\r\n EnterpriseUserLogin = 7,\r\n}\r\n","import { AddressHistoryDTO } from \"@js/DTO/AddressHistoryDTO.cs.d\";\r\nimport { AddressLookupDTO } from \"@js/DTO/AddressLookupDTO.cs.d\";\r\nimport { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CaseChangedMessageDTO } from \"@js/DTO/CaseChangedMessageDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { BridgingDealDTO } from \"@js/DTO/Deal/BridgingDealDTO.cs.d\";\r\nimport { DealClientDTO } from \"@js/DTO/Deal/DealClientDTO.cs.d\";\r\nimport { DealDTO } from \"@js/DTO/Deal/DealDTO.cs.d\";\r\nimport { DealFileAttachmentDTO } from \"@js/DTO/Deal/DealFileAttachmentDTO.cs.d\";\r\nimport { DealLenderDTO } from \"@js/DTO/Deal/DealLenderDTO.cs.d\";\r\nimport { DealNoteDTO } from \"@js/DTO/Deal/DealNoteDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { ExternalLinksDTO } from \"@js/DTO/ExternalLinksDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { LenderDTO } from \"@js/DTO/LenderDTO.cs.d\";\r\nimport { InvitedUserResponse } from \"@js/DTO/Messages/Deal/InvitedUserMessage.cs.d\";\r\nimport { LenderInfo } from \"@js/DTO/Messages/Deal/LendersInfoForSubmitToLenderMessage.cs.d\";\r\nimport { PromoteSearchToCaseResponse } from \"@js/DTO/Messages/Deal/PromoteSearchToCaseMessage.cs.d\";\r\nimport { SaveBridgingSearchRequest } from \"@js/DTO/Messages/Deal/SaveBridgingSearchMessage.cs.d\";\r\nimport { ShareModuleRequest } from \"@js/DTO/Messages/Deal/ShareModuleMessage.cs.d\";\r\nimport { SubmitToLendersRequest } from \"@js/DTO/Messages/Deal/SubmitToLendersMessage.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { AppraisalModuleEnum } from \"@js/models/enum/AppraisalModuleEnum.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { ExistingPlanningChangeTypeEnum } from \"@js/models/enum/ExistingPlanningChangeTypeEnum.cs.d\";\r\nimport { ExitStrategyEnum } from \"@js/models/enum/ExitStrategyEnum.cs.d\";\r\nimport { LandOrPropertyEnum } from \"@js/models/enum/LandOrPropertyEnum.cs.d\";\r\nimport { LenderProductTypeEnum } from \"@js/models/enum/LenderProductTypeEnum.cs.d\";\r\nimport { LicenseMasterStatusEnum } from \"@js/models/enum/LicenseMasterStatusEnum.cs.d\";\r\nimport { LoanPurposeEnum } from \"@js/models/enum/LoanPurposeEnum.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { OwnNewDevelopmentEnum } from \"@js/models/enum/OwnNewDevelopmentEnum.cs.d\";\r\nimport { OwnOrPurchaseEnum } from \"@js/models/enum/OwnOrPurchaseEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { PropertyTypeDetailEnum } from \"@js/models/enum/PropertyTypeDetailEnum.cs.d\";\r\nimport { PropertyTypeEnum } from \"@js/models/enum/PropertyTypeEnum.cs.d\";\r\nimport { TenureEnum } from \"@js/models/enum/TenureEnum.cs.d\";\r\nimport { TitleEnum } from \"@js/models/enum/TitleEnum.cs.d\";\r\nimport { YesNoMaybe } from \"@js/models/enum/YesNoMaybeEnum.cs.d\";\r\nimport { PostalAddress } from \"@js/models/PostalAddress.cs.d\";\r\nimport { AccountService } from \"@js/services/AccountService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { BridgingDealService } from \"@js/services/Deal/BridgingDealService\";\r\nimport { DealLenderService } from \"@js/services/Deal/DealLenderService\";\r\nimport { DealNoteService } from \"@js/services/Deal/DealNoteService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { SharedDealService } from \"@js/services/Deal/SharedDealService\";\r\nimport { DealClientService } from \"@js/services/DealClientService\";\r\nimport { DealFileAttachmentService } from \"@js/services/DealFileAttachmentService\";\r\nimport { ExternalLinksService } from \"@js/services/ExternalLinksService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { StreetAddressService } from \"@js/services/StreetAddressService\";\r\nimport angular from \"angular\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { EventLogEnum } from \"@js/models/enum/EventLogEnum.cs.d\";\r\n\r\nexport class BridgingCaseController {\r\n isCaseDashboard: boolean = true;\r\n\r\n dataLoading: boolean;\r\n currentUser: ApplicationUserDTO;\r\n dealId: number;\r\n dealDto: BridgingDealDTO;\r\n tempDealDto: BridgingDealDTO;\r\n orgName: string;\r\n orgId: number;\r\n org: OrganisationDTO;\r\n fileNamePrefix: string = \"Brickflow\";\r\n newNote: DealNoteDTO = {} as DealNoteDTO;\r\n\r\n BridgingCaseDashboardTypeEnum = {\r\n Overview: 0,\r\n Borrower: 1,\r\n Property: 2,\r\n Loan: 3,\r\n };\r\n\r\n CountryList = [];\r\n NationalityList = [];\r\n\r\n selectedNavMenu: number = 0;\r\n\r\n dealForm: ng.IFormController;\r\n ownershipForm: ng.IFormController;\r\n companyDetailsForm: ng.IFormController;\r\n propertyDetailsForm: ng.IFormController;\r\n loanDetailsForm: ng.IFormController;\r\n lenderDetailsForm: ng.IFormController;\r\n\r\n personalDetailsForm: ng.IFormController;\r\n contactForm: ng.IFormController;\r\n occupationForm: ng.IFormController;\r\n creditForm: ng.IFormController;\r\n\r\n qualificationComplete: boolean = false;\r\n showAddressHistoryModal: boolean = false;\r\n\r\n tabs = {\r\n tabOpen: false,\r\n ownership: false,\r\n companyDetails: false,\r\n personalDetails: false,\r\n contactDetails: false,\r\n occupation: false,\r\n credit: false,\r\n };\r\n\r\n purchaseSelected: boolean = false;\r\n ownershipType: string = \"\";\r\n\r\n currentApplicant: DealClientDTO;\r\n tempApplicant: DealClientDTO;\r\n applicantList: DealClientDTO[] = [];\r\n appName: string;\r\n\r\n deal: DealDTO;\r\n\r\n searchterm: string;\r\n previousAddressSearchTerm: string;\r\n PostCodeOptions: PostalAddress[] = [];\r\n previousAddressPostCodeOptions: PostalAddress[] = [];\r\n address: PostalAddress;\r\n searchingForAddress: boolean = false;\r\n searchingForPreviousAddress: boolean = false;\r\n searchresults: string = \"\";\r\n previousAddressSearchResults: string[];\r\n addressHistoryItem: AddressHistoryDTO;\r\n applicantAddressHistory: AddressHistoryDTO[] = [];\r\n\r\n propertyTypeOptions = [];\r\n exitStrategyOptions = [];\r\n interestServiceOrRoll = [];\r\n tenureTypes = [];\r\n maritalStatusOptions = [];\r\n ownOrPurchaseOptions = [];\r\n chargeTypeOptions = [];\r\n ownNewDevelopmentOptions = [];\r\n yesNoOptions = [];\r\n siteTypeOptions = [];\r\n buildingConditionOptions = [];\r\n sourceOfIncomeOptions = [];\r\n loanPurposeOptions = [];\r\n projectCompletionOptions = [];\r\n planningStatusAtStartOfDevOptions = [];\r\n planningStatusAtEndOfDevOptions = [];\r\n planningOptions = [];\r\n titleOptions = [];\r\n existingPlanningChangeTypeOptions = [];\r\n buildStageOptions = [];\r\n ownershipRoleOptions = [];\r\n\r\n countryList = [];\r\n nationalityList = [];\r\n\r\n countryOfBirthList = [];\r\n countryOfResidenceList = [];\r\n loanCompletionTypeOptions = [];\r\n refurbishmentLevelOptions = [];\r\n locationOptions = [];\r\n\r\n //modal\r\n message: string = \"\";\r\n modal: boolean = false;\r\n showErrorMessage: boolean = false;\r\n\r\n uploadingFiles: FileUploadProgressDTO[];\r\n fileUpload: DealFileAttachmentDTO[];\r\n total: number = 0;\r\n renamingFile: DealFileAttachmentDTO;\r\n\r\n // Number of note shown on the casedashboard\r\n maxNotes: number = 4;\r\n\r\n // Controls showing Ts & Cs when a borrower/broker submits to lenders\r\n showTsAndCs: boolean = false;\r\n showApplyTsAndCs: boolean = false;\r\n showRequestEmailForm: boolean = false;\r\n requestMessageReason: string = \"\";\r\n showTsAndCsForm: boolean = false;\r\n sendingMessage: boolean = false;\r\n messagebool: boolean = false;\r\n invalidEmail: boolean = false;\r\n\r\n isBroker: boolean = false;\r\n isAdmin: boolean = false;\r\n isLender: boolean = false;\r\n isClient: boolean = false;\r\n isSubmitted: boolean = false;\r\n\r\n isSubmittedToLenders: boolean = false;\r\n messageContent: string;\r\n dealLender: DealLenderDTO;\r\n\r\n //Boolean to enable a re-submit button\r\n hasShortlistedDealLenders: boolean = false;\r\n\r\n caseStatusOptions = [];\r\n caseStatusText: string = \"\";\r\n caseOverview: string;\r\n\r\n selectedLendersName: string = \"\";\r\n shortlistedLendersName: string = \"\";\r\n\r\n //Sharing case\r\n shareContext: AppraisalModuleEnum = null;\r\n caseMembersWithAccess: ClientDTO[];\r\n showShare: boolean = false;\r\n selectedClientToShareWith: ClientDTO;\r\n shareNote: string;\r\n showModuleShareConfirmation: boolean;\r\n\r\n //show profile view\r\n showAppraisalPermission: boolean = false;\r\n\r\n //profile\r\n newApplicant: DealClientDTO;\r\n\r\n maxDateOfBirth: Date = new Date();\r\n minDateOfBirth: Date = new Date(\"Jan 01 1900\");\r\n maxDateForDateField: Date = new Date(\"Jan 01 3000\");\r\n showAddorEdit: boolean = false;\r\n disableQuickEditSave: boolean = false;\r\n applicantForm: ng.IFormController;\r\n isAddShareholder: boolean;\r\n showDelete: boolean = false;\r\n confirmDeleteApplicant: DealClientDTO;\r\n\r\n showExport: boolean = false;\r\n updatingName: boolean = false;\r\n orginalDealName: string;\r\n\r\n showAddHistoryConfirmDelete: boolean = false;\r\n addressHistoryIdToDelete: number;\r\n\r\n isLoggedInUser: boolean = false;\r\n\r\n showDeal: boolean = true;\r\n classUses: {} = {};\r\n\r\n tinymceOptions: any;\r\n tinymceReadonlyOptions: any;\r\n missingAddressGaps: string[];\r\n\r\n ownOrPurchase: boolean;\r\n landOrProperty: boolean;\r\n isFamilyInResidence: boolean;\r\n totalCosts: number = 0;\r\n\r\n dateProperties = [\"ExpiryDate\"];\r\n\r\n profileDateProperties = [\r\n \"DateOfBirth\",\r\n \"CurrentAddressFrom\",\r\n \"UkResidenceIssueDate\",\r\n \"CurrentEmploymentStartDate\",\r\n \"AddressStartDate\",\r\n ];\r\n\r\n dealDateProperties = [\"OriginalPurchaseDate\", \"CompletionDate\"];\r\n\r\n clientDateProperties = [\"DateOfBirth\"];\r\n\r\n maxPurchaseDate: Date = new Date();\r\n minPurchaseDate: Date = new Date(\"Jan 01 1900\");\r\n\r\n minCompletionDate: Date;\r\n dealProductTypeDisplayText: string;\r\n isInActiveLender: boolean = false;\r\n\r\n contingencyAmount: number = null;\r\n lendersDetailsForSubmittoLenders: LenderInfo[];\r\n shortListedLendersId: Number[];\r\n //SubmitToLender modal\r\n brokerPreferredContact: string;\r\n isBrokerPhoneNumberUpdated: boolean = false;\r\n brokerCommission: number;\r\n dealBrokerUser: ApplicationUserDTO;\r\n totalUnreadDealLenderMessages: number = null;\r\n\r\n //Lender Portal Links\r\n dealLenders: DealLenderDTO[];\r\n dealLendersWithPortalLinkEnabled: DealLenderDTO[];\r\n lendersWithPortalLinkEnabled: LenderDTO[];\r\n showLenderPortalLinks: boolean = false;\r\n portalLinks: {} = {};\r\n borrowerDetails: UserSimpleDTO;\r\n applicationForm: ng.IFormController;\r\n portalLinkDetailsAdded: {} = {};\r\n showMaximumApplicantsMessage: boolean = false;\r\n //property for roles directive to handle referred readonly view for broker/connect broker\r\n isReadOnlyDeal: boolean = true;\r\n hasFirstLoadOccurred: boolean = false;\r\n\r\n referredPackagerText: string;\r\n\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$location\",\r\n \"$cookies\",\r\n \"AccountService\",\r\n \"StreetAddressService\",\r\n \"BridgingDealService\",\r\n \"DealNoteService\",\r\n \"AuthService\",\r\n \"SelectListService\",\r\n \"RoleService\",\r\n \"LenderService\",\r\n \"CaseService\",\r\n \"DealLenderService\",\r\n \"DealFileAttachmentService\",\r\n \"$window\",\r\n \"ExternalLinksService\",\r\n \"DealClientService\",\r\n \"OrganisationService\",\r\n \"$scope\",\r\n \"$sce\",\r\n \"ProductService\",\r\n \"DealService\",\r\n \"SharedDealService\",\r\n \"EventLogService\"\r\n ];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $accountservice: AccountService,\r\n private $streetAddressService: StreetAddressService,\r\n private bridgingDealService: BridgingDealService,\r\n private dealNoteService: DealNoteService,\r\n private authService: AuthService,\r\n private selectListService: SelectListService,\r\n private roleService: RoleService,\r\n private $lenderService: LenderService,\r\n private caseService: CaseService,\r\n private dealLenderService: DealLenderService,\r\n private dealFileAttachmentService: DealFileAttachmentService,\r\n private $window: ng.IWindowService,\r\n private $externalLinksService: ExternalLinksService,\r\n private dealClientService: DealClientService,\r\n private organisationService: OrganisationService,\r\n private $scope: ng.IScope,\r\n private $sce: ng.ISCEService,\r\n private productService: ProductService,\r\n private dealService: DealService,\r\n private sharedDealService: SharedDealService,\r\n private eventLogService: EventLogService\r\n ) {\r\n if ($cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n }\r\n\r\n this.tinymceOptions = this.sharedDealService.tinymceOptions;\r\n this.tinymceReadonlyOptions = angular.copy(this.tinymceOptions);\r\n this.tinymceReadonlyOptions.readonly = 1;\r\n\r\n this.roleService.GetUserRoles().then((result) => {\r\n if (result.filter((x) => x.toLowerCase() == \"client\").length > 0) {\r\n this.isClient = true;\r\n } else {\r\n this.isClient = false;\r\n }\r\n });\r\n\r\n if (this.$routeParams.DealId) {\r\n this.dataLoading = true;\r\n\r\n this.dealId = this.$routeParams.DealId;\r\n if (\r\n this.$routeParams.Promote &&\r\n this.$routeParams.Promote != \"null\" &&\r\n !this.dealDto\r\n ) {\r\n var promote = this.$routeParams.Promote as boolean;\r\n this.isReadOnlyDeal = false;\r\n this.hasFirstLoadOccurred = true;\r\n if (promote) {\r\n this.promoteSearchToCase();\r\n }\r\n } else {\r\n this.dealService.fetchByDealId(this.$routeParams.DealId, ProductFamilyEnum.Bridging, true)\r\n .then((response) => {\r\n // The case was a pre-existing case when the broker org became a member of Connect and therefore was archived.\r\n if (response.BridgingDealDto.IsPreConnectArchived) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n\r\n //Below properties are very imp for view roles directive \r\n this.isReadOnlyDeal = response.IsReadOnlyDealForBroker;\r\n this.referredPackagerText = response.ReferredPackagerText;\r\n this.hasFirstLoadOccurred = true;\r\n if (response.HideBridgingDeal) {\r\n this.showDeal = false;\r\n } else {\r\n this.dealDto = response.BridgingDealDto;\r\n this.shortlistedLendersName = response.ShortlistedLendersName;\r\n this.selectedLendersName = response.SelectedLendersName;\r\n this.shortListedLendersId = response.ShortlistedLendersId;\r\n if (this.dealDto) {\r\n this.orgId = this.dealDto.BrokerOrganisationId;\r\n if (this.dealDto.ProjectDescription) {\r\n this.caseOverview = this.dealDto.ProjectDescription;\r\n }\r\n this.totalUnreadDealLenderMessages =\r\n response.TotalUnreadDealLenderMessages;\r\n this.postRetrieveProcessing();\r\n\r\n var newShortlist = this.$routeParams.NewShortlist as boolean;\r\n if (newShortlist) this.getLenderPortalLinks();\r\n } else {\r\n // If no case is returned, this could be that the logged in user has been removed from the case\r\n // - only do this if there is a logged in user, otherwise let the routing sort out where the redirect should go\r\n if ((this.$rootScope as any).selectedUser) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n this.countryOfBirthList = this.countryOfResidenceList =\r\n this.selectListService.GetCountries();\r\n\r\n this.nationalityList = this.selectListService.GetNationalities();\r\n\r\n this.chargeTypeOptions = this.selectListService.GetChargeType();\r\n this.ownOrPurchaseOptions = this.selectListService.GetOwnOrPurchase();\r\n this.maritalStatusOptions =\r\n this.selectListService.GetMaritalStatusOptions();\r\n this.propertyTypeOptions = this.selectListService.GetPropertyType();\r\n this.exitStrategyOptions = this.selectListService.GetExitStrategy(false);\r\n this.interestServiceOrRoll =\r\n this.selectListService.GetInterestServiceOrRoll();\r\n this.ownNewDevelopmentOptions =\r\n this.selectListService.GetOwnNewDevelopmentOptions();\r\n\r\n this.yesNoOptions = this.selectListService.GetYesNoForBridging();\r\n this.siteTypeOptions = this.selectListService.GetSiteType();\r\n this.buildingConditionOptions =\r\n this.selectListService.GetBuildingConditionType();\r\n this.sourceOfIncomeOptions =\r\n this.selectListService.GetSourceOfIncomeOptions();\r\n this.projectCompletionOptions =\r\n this.selectListService.GetCompletionOptions();\r\n this.planningStatusAtStartOfDevOptions =\r\n this.selectListService.GetPlanningStatusAtStartOfDevelopmentOptions();\r\n this.planningStatusAtEndOfDevOptions =\r\n this.selectListService.GetPlanningStatusAtEndOfDevelopmentOptions();\r\n this.titleOptions = this.selectListService.GetTitleOptions();\r\n this.existingPlanningChangeTypeOptions =\r\n this.selectListService.GetExistingPlanningChangeTypeOptions();\r\n this.loanCompletionTypeOptions =\r\n this.selectListService.GetLoanCompletionOptions();\r\n this.buildStageOptions = this.selectListService.GetBuildStageOptions();\r\n this.ownershipRoleOptions =\r\n this.selectListService.GetOwnershipRoleOptions();\r\n this.refurbishmentLevelOptions =\r\n this.selectListService.GetRefurbishmentLevelOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n\r\n this.getAppName();\r\n }\r\n\r\n getRequiredRoles(isCaseDashboard: boolean) {\r\n if (isCaseDashboard) {\r\n if (this.isReadOnlyDeal) {\r\n return `['Admin', 'Client']`;\r\n } else {\r\n return `['Admin', 'Client', 'Broker', 'Introducer']`;\r\n }\r\n }\r\n return `['Admin', 'Client', 'Broker', 'Introducer', 'Lender']`;\r\n }\r\n\r\n editDealName() {\r\n var name = this.dealDto.Name;\r\n this.orginalDealName = name;\r\n this.updatingName = true;\r\n }\r\n cancelEditDealName() {\r\n this.updatingName = false;\r\n this.dealDto.Name = this.orginalDealName;\r\n }\r\n\r\n /**Gets the Case Status display text */\r\n getCaseStatusDisplayText() {\r\n var statusItem = null;\r\n\r\n if (this.isLender) {\r\n statusItem = this.caseStatusOptions.find(\r\n (statusOption) => this.dealLender.Status == statusOption.key,\r\n );\r\n } else {\r\n statusItem = this.caseStatusOptions.find(\r\n (statusOption) => this.dealDto.Status == statusOption.key,\r\n );\r\n }\r\n\r\n this.caseStatusText = statusItem.displayName;\r\n }\r\n\r\n postRetrieveProcessing() {\r\n if (this.$routeParams.selectedNavMenu) {\r\n this.selectedNavMenu = this.$routeParams.selectedNavMenu;\r\n }\r\n\r\n this.dealLenderService\r\n .fetchByDealId(this.$routeParams.DealId)\r\n .then((dls: DealLenderDTO[]) => {\r\n this.hasShortlistedDealLenders = dls.some(\r\n (dl) => dl.Status == CaseLenderStateEnum.Shortlisted,\r\n );\r\n });\r\n\r\n //These are used for directive.\r\n (this.$rootScope as any).statusRequirementId = this.dealDto.Id;\r\n this.caseService.updateCaseState(this.dealDto.Id, this.dealDto.Status);\r\n this.getCurrentUserAndRoles();\r\n this.fileUpload = this.dealDto.Attachments;\r\n this.applicantList = this.dealDto.DealClients;\r\n this.loanPurposeOptions = this.selectListService.GetLoanPurposeOptions(\r\n this.isRegulatedBridging(),\r\n );\r\n this.getPlanningOptions();\r\n this.updateClassUses();\r\n this.tenureTypes = this.selectListService.GetTenureTypes(\r\n this.dealDto.ProductType,\r\n );\r\n this.dealProductTypeDisplayText =\r\n this.productService.getProductTypeDisplayText(\r\n this.dealDto.ProductType,\r\n this.isRegulatedBridging(),\r\n );\r\n\r\n this.calcContingencyAmount();\r\n\r\n if (this.dealDto.BrokerOrganisationId) {\r\n this.getOrganisationbyDealId();\r\n }\r\n }\r\n\r\n keyPressEvent(event) {\r\n if (event.key === \"Enter\") {\r\n this.updatingName = false;\r\n this.submitForm(this.dealForm);\r\n }\r\n if (event.key === \"Escape\") {\r\n this.updatingName = false;\r\n }\r\n }\r\n\r\n submitForm(form: ng.IFormController) {\r\n this.dataLoading = true;\r\n\r\n var request: SaveBridgingSearchRequest = {\r\n DealDto: this.dealDto,\r\n ShareDealDto: null,\r\n OrgCode: \"\",\r\n EnterpriseClientDto: null,\r\n };\r\n\r\n this.bridgingDealService\r\n .saveBridgingSearchReturnsId(request)\r\n .then((response) => {\r\n if (response != null) {\r\n this.closeTabs();\r\n form.$setPristine();\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n closeModalAndGoToDasboard() {\r\n this.showTsAndCs = false;\r\n this.authService.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n closeModalAndGoToDealForum() {\r\n this.showTsAndCs = false;\r\n this.$location.path(\"/dealforum/\" + this.dealDto.Id);\r\n }\r\n\r\n closeModal(test: number) {\r\n this.messagebool = false;\r\n }\r\n\r\n closeTabs(currentTab: string = \"\") {\r\n for (let key in this.tabs) {\r\n if (currentTab.length == 0 || currentTab != key) {\r\n this.tabs[key] = false;\r\n }\r\n }\r\n }\r\n\r\n discardOwnership() {\r\n this.dealDto.HowWillYouOwnNewDevelopment = null;\r\n //this.companyDetails.temp = null;\r\n this.dealDto.ExcludedLenders = null;\r\n this.dealDto.HasTheCompanyOrPensionBeenFormedYet = null;\r\n }\r\n\r\n gotoApplicant(applicant?: DealClientDTO) {\r\n this.currentApplicant = applicant || null;\r\n this.PostCodeOptions = null;\r\n\r\n if (\r\n this.currentApplicant &&\r\n this.currentApplicant.Profile &&\r\n this.currentApplicant.Profile.AddressHistory &&\r\n this.currentApplicant.Profile.AddressHistory.length > 0\r\n ) {\r\n this.parseAddressHistory(this.currentApplicant.Profile.AddressHistory);\r\n } else {\r\n this.applicantAddressHistory = [];\r\n }\r\n\r\n this.selectedNavMenu = 4;\r\n this.closeTabs();\r\n }\r\n\r\n getOwnershipTypeText(): string {\r\n var ownershipTypeText;\r\n\r\n if (this.dealDto && this.dealDto.HowWillYouOwnNewDevelopment) {\r\n switch (this.dealDto.HowWillYouOwnNewDevelopment) {\r\n case OwnNewDevelopmentEnum.UKLimitedCompany:\r\n this.ownershipType = ownershipTypeText = \"Company\";\r\n break;\r\n case OwnNewDevelopmentEnum.OverseasLimitedCompany:\r\n this.ownershipType = ownershipTypeText = \"Overseas Company\";\r\n break;\r\n case OwnNewDevelopmentEnum.PensionFund:\r\n this.ownershipType = ownershipTypeText = \"Pension Fund\";\r\n break;\r\n case OwnNewDevelopmentEnum.UKLimitedLiabilityPartnership:\r\n ownershipTypeText = \"Limited Liability Partnership\";\r\n this.ownershipType = \"Partnership\";\r\n break;\r\n default:\r\n ownershipTypeText = \"\";\r\n }\r\n return ownershipTypeText;\r\n }\r\n return \"\";\r\n }\r\n\r\n openAddressHistoryModal(addressHistory: AddressHistoryDTO = null) {\r\n this.previousAddressSearchResults = [];\r\n this.previousAddressPostCodeOptions = [];\r\n\r\n if (addressHistory) {\r\n this.addressHistoryItem = addressHistory;\r\n } else {\r\n this.addressHistoryItem = null;\r\n }\r\n\r\n this.showAddressHistoryModal = true;\r\n }\r\n\r\n addressHistoryComplete() {\r\n return this.sharedDealService.addressHistoryComplete(\r\n this.currentApplicant,\r\n this.applicantAddressHistory,\r\n this.missingAddressGaps,\r\n );\r\n }\r\n\r\n getAddressList(searchTerm: string, postalAddress: PostalAddress) {\r\n let foundMatch = false;\r\n\r\n if (this.PostCodeOptions && this.PostCodeOptions.length > 0) {\r\n let addressLookup = this.PostCodeOptions.find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n this.$streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n for (let prop in address) {\r\n if (address.hasOwnProperty(prop)) {\r\n postalAddress[prop] = address[prop];\r\n }\r\n }\r\n this.searchterm = \"\";\r\n this.searchresults = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n postalAddress.AddressLine1 = addressLookup.AddressLine2.replace(\r\n addressLookup.AddressLine2.substring(\r\n addressLookup.AddressLine2.indexOf(\"-\") - 1,\r\n ),\r\n \"\",\r\n );\r\n postalAddress.AddressLine2 = addressLookup.AddressLine3;\r\n postalAddress.PostCode = addressLookup.AddressLine1;\r\n this.searchterm = \"\";\r\n this.searchresults = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n this.PostCodeOptions = [];\r\n\r\n this.$streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.PostCodeOptions = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n lookupPreviousAddress(searchTerm: string) {\r\n let foundMatch = false;\r\n\r\n if (\r\n this.previousAddressPostCodeOptions &&\r\n this.previousAddressPostCodeOptions &&\r\n this.previousAddressPostCodeOptions.length > 0\r\n ) {\r\n let addressLookup = this.previousAddressPostCodeOptions.find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n\r\n // We've selected an address!\r\n this.$streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n this.addressHistoryItem = {\r\n AddressLine1: address.AddressLine1,\r\n AddressLine2: address.AddressLine2,\r\n AddressLine3: address.AddressLine3,\r\n AddressLine4: address.AddressLine4,\r\n PostCode: address.PostCode,\r\n };\r\n\r\n this.previousAddressSearchTerm = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n this.addressHistoryItem = {\r\n AddressLine1: addressLookup.AddressLine2,\r\n AddressLine2: addressLookup.AddressLine3,\r\n AddressLine3: addressLookup.AddressLine4,\r\n AddressLine4: addressLookup.PostCode,\r\n PostCode: addressLookup.AddressLine1,\r\n };\r\n\r\n this.previousAddressSearchTerm = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n // Initial search term\r\n this.previousAddressPostCodeOptions = [];\r\n\r\n this.$streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.previousAddressPostCodeOptions = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n saveAddressHistory(selectedApplicant: DealClientDTO) {\r\n var id: number = 0;\r\n\r\n if (!this.applicantAddressHistory) {\r\n this.applicantAddressHistory = [];\r\n }\r\n\r\n // If the Id hasn't been set then this is a new previous address\r\n if (this.addressHistoryItem.Id == null) {\r\n id = this.getNextAddressHistoryId();\r\n this.addressHistoryItem.Id = id;\r\n this.applicantAddressHistory.push(this.addressHistoryItem);\r\n } else {\r\n var foundIndex = this.applicantAddressHistory\r\n .map(function (a) {\r\n return a.Id;\r\n })\r\n .indexOf(this.addressHistoryItem.Id);\r\n if (foundIndex > -1) {\r\n this.applicantAddressHistory.splice(\r\n foundIndex,\r\n 1,\r\n this.addressHistoryItem,\r\n ); // removed previous entry and adds the updated one in its place\r\n }\r\n }\r\n\r\n this.dealClientService\r\n .saveAddressHistory(\r\n selectedApplicant.Id,\r\n JSON.stringify(this.applicantAddressHistory),\r\n )\r\n .then((addressHistory: string) => {\r\n selectedApplicant.Profile.AddressHistory = addressHistory;\r\n this.parseAddressHistory(addressHistory);\r\n this.showAddressHistoryModal = false;\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem saving the address history. Please try again later.\";\r\n })\r\n .finally(() => {\r\n this.showAddressHistoryModal = false;\r\n });\r\n }\r\n\r\n /**\r\n * Convert addres history JSON back to an array of PostalAddress objects\r\n * @param addressHistoryJson\r\n */\r\n parseAddressHistory(addressHistoryJson: string) {\r\n // JSON doesn't understand date types so therefore user the reviver function to manually convert them back to dates as opposed to strings\r\n this.applicantAddressHistory = JSON.parse(addressHistoryJson, this.sharedDealService.reviver);\r\n\r\n // Order the address histories by the from date (ascending)\r\n this.applicantAddressHistory.sort(\r\n (a: AddressHistoryDTO, b: AddressHistoryDTO) => {\r\n return this.sharedDealService.getTime(a.FromDate) - this.sharedDealService.getTime(b.FromDate);\r\n },\r\n );\r\n }\r\n\r\n getAddressAsString(address: PostalAddress) {\r\n return this.sharedDealService.getAddressAsString(address);\r\n }\r\n\r\n concatenateAddressLine(addressLine: string, concatenatedAddress: string) {\r\n if (addressLine != null && addressLine.length > 0) {\r\n if (concatenatedAddress.length > 0) {\r\n concatenatedAddress = concatenatedAddress.concat(\", \", addressLine);\r\n } else {\r\n concatenatedAddress = concatenatedAddress.concat(addressLine);\r\n }\r\n }\r\n\r\n return concatenatedAddress;\r\n }\r\n\r\n showConfirmAddressDelete(addressHistoryId: number) {\r\n this.showAddHistoryConfirmDelete = true;\r\n this.addressHistoryIdToDelete = addressHistoryId;\r\n }\r\n\r\n deleteAddressHistory() {\r\n this.showAddHistoryConfirmDelete = false;\r\n\r\n var foundIndex = this.applicantAddressHistory\r\n .map(function (a) {\r\n return a.Id;\r\n })\r\n .indexOf(this.addressHistoryIdToDelete);\r\n\r\n if (foundIndex > -1) {\r\n this.applicantAddressHistory.splice(foundIndex, 1);\r\n\r\n this.dealClientService\r\n .saveAddressHistory(\r\n this.currentApplicant.Id,\r\n JSON.stringify(this.applicantAddressHistory),\r\n )\r\n .then((addressHistory: string) => {\r\n this.currentApplicant.Profile.AddressHistory = addressHistory;\r\n this.parseAddressHistory(addressHistory);\r\n this.showAddressHistoryModal = false;\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem deleting the address history item. Please try again later.\";\r\n });\r\n }\r\n }\r\n\r\n getNextAddressHistoryId(): number {\r\n return this.sharedDealService.getNextAddressHistoryId(\r\n this.applicantAddressHistory,\r\n );\r\n }\r\n\r\n /** Promotes/converts a search to a case */\r\n promoteSearchToCase() {\r\n this.dealService\r\n .promoteSearchToCase(this.dealId, ProductFamilyEnum.Bridging)\r\n .then((response: PromoteSearchToCaseResponse) => {\r\n if (response != null && response.BridgingDealDto != null) {\r\n this.dealDto = response.BridgingDealDto;\r\n this.shortlistedLendersName = response.ShortlistedLendersName;\r\n this.selectedLendersName = response.SelectedLendersName;\r\n this.shortListedLendersId = response.ShortlistedLendersId;\r\n this.postRetrieveProcessing();\r\n this.getCurrentUserAndRoles();\r\n } else {\r\n this.message =\r\n \"Problem while promoting a search to case, please try after some time.\";\r\n this.showErrorMessage = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.getLenderPortalLinks();\r\n });\r\n }\r\n\r\n getLenderPortalLinks() {\r\n this.dealLenderService\r\n .fetchByDealId(this.$routeParams.DealId)\r\n .then((dls: DealLenderDTO[]) => {\r\n this.dealLenders = dls;\r\n var searchChanged = this.$routeParams.SearchChanged;\r\n const lenderIds = dls\r\n .filter(\r\n (dl) =>\r\n !dl.HasAppliedInLenderPortal &&\r\n (dl.Status === CaseLenderStateEnum.Shortlisted ||\r\n searchChanged == \"true\"),\r\n )\r\n .map((dl) => dl.LenderId);\r\n return this.$lenderService.getLenderPortalLinks(lenderIds);\r\n })\r\n .then((links) => {\r\n this.portalLinks = links;\r\n })\r\n .catch((error) => {\r\n this.message = \"Error fetching lender portal links: \" + error;\r\n this.portalLinks = null;\r\n })\r\n .finally(() => {\r\n this.showLenderPortalLinks = Object.keys(this.portalLinks).length > 0;\r\n });\r\n }\r\n\r\n openPortalLink(dealLenderId: number, url: string) {\r\n if (!this.portalLinkDetailsAdded[dealLenderId]) {\r\n this.dealLenderService\r\n .addLenderPortalLinkDetails(dealLenderId, this.borrowerDetails)\r\n .then(() => {\r\n this.portalLinkDetailsAdded[dealLenderId] = true;\r\n this.openUrl(url);\r\n })\r\n .catch((error) => {\r\n console.error(\"Error adding lender portal link details:\", error);\r\n });\r\n } else {\r\n this.openUrl(url);\r\n }\r\n }\r\n\r\n private openUrl(url: string) {\r\n if (!/^https?:\\/\\//i.test(url)) {\r\n url = \"http://\" + url;\r\n }\r\n window.open(url, \"_blank\");\r\n }\r\n\r\n saveNote(): void {\r\n this.newNote.DealId = this.dealDto.Id;\r\n this.newNote.UserId = this.currentUser.Id;\r\n\r\n this.dataLoading = true;\r\n this.dealNoteService\r\n .addUpdate(this.newNote)\r\n .then((response) => {\r\n this.dealDto.DealNotes.push(response);\r\n this.newNote = {\r\n DealId: this.dealDto.Id,\r\n UserId: this.currentUser.Id,\r\n } as DealNoteDTO;\r\n this.dealForm.$setPristine();\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n saveOverview(): void {\r\n this.dealDto.ProjectDescription = this.caseOverview;\r\n this.submitForm(this.dealForm);\r\n }\r\n\r\n gotoResultpage() {\r\n this.showErrorMessage = false;\r\n this.$location.path(\"/bridgingresults/\" + this.dealId);\r\n }\r\n\r\n onFileSelect(files) {\r\n var module = ModuleEnum.Case;\r\n\r\n this.dealFileAttachmentService\r\n .UploadFileListInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.dealDto.Id,\r\n this.fileUpload,\r\n module,\r\n )\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n calculateTotalFilesRemoving(filter: number) {\r\n if (this.fileUpload) {\r\n this.total = this.fileUpload.filter(\r\n (item) => item.Module != filter,\r\n ).length;\r\n }\r\n return this.total;\r\n }\r\n\r\n EnumToString(item: ModuleEnum) {\r\n switch (item) {\r\n case 0:\r\n return \"Case Overview\";\r\n case 1:\r\n return \"Developer Profile\";\r\n case 2:\r\n return \"Development Appraisal\";\r\n case 3:\r\n return \"Development Schedule\";\r\n case 4:\r\n return \"Planning\";\r\n case 5:\r\n return \"Professional Team\";\r\n case 6:\r\n return \"Comparable Properties\";\r\n case 7:\r\n return \"General\";\r\n case 8:\r\n return \"Track Record\";\r\n case 9:\r\n return \"Assets & Liabilities\";\r\n case 10:\r\n return \"Proof Of Income\";\r\n case 11:\r\n return \"Applicant Details\";\r\n case 12:\r\n return \"Pictures\";\r\n default:\r\n return \"General\";\r\n }\r\n }\r\n\r\n downloadFile(file: DealFileAttachmentDTO, downloadFile: boolean = false) {\r\n this.dataLoading = true;\r\n this.dealFileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n if (downloadFile) {\r\n this.sharedDealService.downloadFile(uri, file.FileName);\r\n } else {\r\n this.$window.open(uri);\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n renameFile(file: DealFileAttachmentDTO) {\r\n if (this.renamingFile === undefined) {\r\n // if renaming this file will dirty the case, we'll want to set it back to pristine when we're done.\r\n // this.renamingFileDirties = !$scope.caseForm.$dirty;\r\n this.renamingFile = file;\r\n } else {\r\n delete this.renamingFile;\r\n }\r\n }\r\n renamingFileComplete(file: DealFileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.dealFileAttachmentService\r\n .renameFile(file)\r\n .then((response) => {\r\n file.TempURL = response.TempURL;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n delete this.renamingFile;\r\n }\r\n\r\n renamingLinkCompleted(link: ExternalLinksDTO) {\r\n this.dataLoading = true;\r\n this.$externalLinksService\r\n .addUpdate(link)\r\n .then((response) => {\r\n link.Link = response.Link;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n delete this.renamingFile;\r\n }\r\n\r\n deleteFile(file: DealFileAttachmentDTO) {\r\n this.dealDto.Attachments.splice(this.dealDto.Attachments.indexOf(file), 1);\r\n this.dealFileAttachmentService.markasdeleted(file.Id).then((result) => { }); //remove on the server\r\n }\r\n\r\n markSectionAsComplete(propertyName: string) {\r\n if (this.dataLoading == false) {\r\n this.dataLoading = true;\r\n\r\n this.dealDto.IsLoanSectionComplete;\r\n\r\n this.dealService\r\n .markSectionAsComplete(\r\n this.dealDto.Id,\r\n propertyName,\r\n ProductFamilyEnum.Bridging,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n this.dealDto.DealNotes.push(response.NewDealNote);\r\n this.dealDto = response.BridgingDealDto;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n allFormsComplete(): boolean {\r\n if (this.dealDto) {\r\n if (\r\n this.dealDto.IsBorrowerSectionComplete &&\r\n this.dealDto.IsPropertySectionComplete &&\r\n this.dealDto.IsLoanSectionComplete\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /** Opens the Terms and Conditions popup when the Submit to Lenders button is clicked*/\r\n showTermsAndConditionsForBorrower() {\r\n this.showApplyTsAndCs = true;\r\n this.requestMessageReason = \"a review\";\r\n this.showTsAndCs = true;\r\n }\r\n\r\n /** Opens the Terms and Conditions popup when the Submit to Lenders HoT button is clicked (borrower/broker) */\r\n showTermsAndConditions() {\r\n this.$lenderService\r\n .getShortlistedLendersInfoForSubmitToLenders(\r\n this.shortListedLendersId,\r\n LenderProductTypeEnum.BridgingFinance,\r\n )\r\n .then((response) => {\r\n this.lendersDetailsForSubmittoLenders = response;\r\n })\r\n .finally(() => {\r\n this.showTsAndCs = true;\r\n this.showTsAndCsForm = true;\r\n this.dealDto.SubmitTsAndCs = false;\r\n this.invalidEmail = false;\r\n });\r\n }\r\n\r\n gotoLendingPage() {\r\n (this.$rootScope as any).isLender = false;\r\n this.$location.path(\"/dealforum/\" + this.dealDto.Id);\r\n }\r\n\r\n checkBrokerDeal() {\r\n return this.dealDto?.BrokerUserId != null && this.isClient ? true : false;\r\n }\r\n\r\n /** Submits a case to lenders */\r\n submitCaseToLenders() {\r\n this.showTsAndCsForm = false;\r\n this.sendingMessage = true;\r\n this.dataLoading = true;\r\n var isResubmitting = false;\r\n\r\n if (this.dealDto.Status == CaseStatusEnum.ReadyToReSubmit) {\r\n isResubmitting = true;\r\n }\r\n\r\n var request = {\r\n DealId: this.dealId,\r\n ProductType: this.dealDto.ProductType,\r\n ResubmitToLenders: isResubmitting,\r\n BrokerCommission: Number(this.brokerCommission),\r\n LendersInfo: this.lendersDetailsForSubmittoLenders,\r\n BrokerPhoneNumber: this.brokerPreferredContact,\r\n IsBrokerPhoneNumberUpdated: this.isBrokerPhoneNumberUpdated,\r\n } as SubmitToLendersRequest;\r\n\r\n this.dealService\r\n .submitToLenders(request)\r\n .then((response: CaseChangedMessageDTO) => {\r\n this.dealDto.Status = response.CaseState;\r\n this.caseService.updateCaseState(this.dealDto.Id, response.CaseState);\r\n this.showMessage(\r\n \"You have requested a Decision in Principle from each lender.\",\r\n );\r\n this.isSubmittedToLenders = true;\r\n })\r\n .catch((error) => {\r\n this.showMessage(\"Sorry, something went wrong. Please try again.\");\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n validateEmails() {\r\n this.invalidEmail = false;\r\n\r\n angular.forEach(\r\n this.lendersDetailsForSubmittoLenders,\r\n (lenderdetails, index) => {\r\n var emailField = this.lenderDetailsForm[\"email\" + index];\r\n\r\n if (emailField && emailField.$invalid) {\r\n this.invalidEmail = true;\r\n }\r\n },\r\n );\r\n }\r\n\r\n showMessage(message: string) {\r\n this.messageContent = message;\r\n }\r\n\r\n requestEmail(reason): void {\r\n this.showRequestEmailForm = true;\r\n this.requestMessageReason = reason;\r\n this.messagebool = true;\r\n this.messageContent = \"\";\r\n }\r\n\r\n sendRequestEmail() {\r\n this.showRequestEmailForm = false;\r\n this.sendingMessage = true;\r\n this.dataLoading = true;\r\n this.$accountservice\r\n .RequestAssistanceReview(\r\n this.requestMessageReason,\r\n this.dealDto.Id,\r\n this.dealDto.ProductFamily,\r\n )\r\n .then((response) => {\r\n this.showMessage(\r\n `${this.appName} have been notified that you require assistance and will be in touch shortly to help.`,\r\n );\r\n\r\n let dealNote = {\r\n DealId: this.dealDto.Id,\r\n UserId: this.currentUser.Id,\r\n NoteText: \"You have requested \" + this.requestMessageReason + \".\",\r\n /*ExpandNote: false*/\r\n } as DealNoteDTO;\r\n this.dealNoteService.addUpdate(dealNote).then((caseNoteResponse) => {\r\n this.dealDto.DealNotes.push(caseNoteResponse);\r\n });\r\n })\r\n .catch((error) => {\r\n this.showMessage(\r\n \"Sorry, something went wrong while sending your email. Please try again.\",\r\n );\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n getAppName() {\r\n let lsd = sessionStorage.getItem(\"applicationName\");\r\n if (lsd != null) {\r\n this.appName = lsd;\r\n } else {\r\n this.appName = \"Brickflow\";\r\n }\r\n }\r\n\r\n closeConfirmationModal() {\r\n if (this.isSubmittedToLenders) {\r\n if (this.$routeParams.Promote) {\r\n this.$location.path(\"/bridgingcasedashboard/\" + this.dealDto.Id);\r\n } else {\r\n window.location.reload();\r\n }\r\n }\r\n this.showTsAndCs = false;\r\n }\r\n\r\n viewResults(loanCriteria: DevelopmentInputDTO) {\r\n this.$location.path(\"/bridgingresults/\" + this.dealDto.Id);\r\n }\r\n\r\n /** Process the Heads of Terms button being clicked */\r\n headsOfTermsClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"terms\");\r\n this.$location.path(\r\n \"/bridgingheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n /** Lender rejects the case*/\r\n rejectButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"reject\");\r\n this.$location.path(\r\n \"/bridgingheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n withDrawButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"withdraw\");\r\n this.$location.path(\r\n \"/bridgingheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n feedbackButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"feedback\");\r\n this.$location.path(\r\n \"/bridgingheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n getCurrentUserAndRoles() {\r\n this.roleService.GetUserRoles().then((result) => {\r\n if (result.filter((x) => x.toLowerCase() == \"admin\").length > 0) {\r\n this.isAdmin = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"broker\").length > 0) {\r\n this.isBroker = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"client\").length > 0) {\r\n this.isClient = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"lender\").length > 0) {\r\n this.isLender = true;\r\n\r\n this.dealLenderService\r\n .fetchDealLender(this.dealDto.Id)\r\n .then((response) => {\r\n this.dealLender = response;\r\n this.isInActiveLender = response.IsLenderInActive;\r\n this.generateCaseStatusText();\r\n });\r\n }\r\n\r\n this.authService\r\n .getUpdatedProfile()\r\n .then((prof) => {\r\n this.currentUser = prof;\r\n })\r\n .then(() => {\r\n this.checkIfUserIsInvited();\r\n this.updateRequestAssitanceDealNoteMessage();\r\n if (!this.isLender) this.generateCaseStatusText();\r\n });\r\n\r\n /* this.$lenderService\r\n .getSelectedDealLenderNames(this.dealDto.Id)\r\n .then((response) => {\r\n this.selectedLendersText = response.LendersName;\r\n if (this.dealDto.Status == CaseStatusEnum.NewCase) {\r\n this.shortListedLendersId = response.LendersId;\r\n }\r\n });\r\n \r\n this.$lenderService\r\n .getShortlistedDealLenderNames(this.dealDto.Id)\r\n .then((response) => {\r\n this.shortlistedLendersText = response.LendersName;\r\n if (this.dealDto.Status != CaseStatusEnum.NewCase) {\r\n this.shortListedLendersId = response.LendersId;\r\n }\r\n });*/\r\n });\r\n }\r\n\r\n //Share module functions\r\n openShareModuleModal(contextToShare: AppraisalModuleEnum) {\r\n this.shareContext = contextToShare;\r\n this.constructShareNoteMessage();\r\n\r\n this.dealClientService\r\n .fetchDealMembersWithAccess(this.dealDto.Id)\r\n .then((response: ClientDTO[]) => {\r\n this.caseMembersWithAccess = response;\r\n\r\n this.showShare = true;\r\n });\r\n }\r\n\r\n constructShareNoteMessage() {\r\n this.shareNote = this.sharedDealService.constructShareNoteMessage(\r\n this.shareContext,\r\n this.currentUser,\r\n );\r\n }\r\n\r\n sendToBorrower() {\r\n this.dataLoading = true;\r\n\r\n var request = {\r\n ClientFirstName: this.selectedClientToShareWith.FirstName,\r\n ClientLastName: this.selectedClientToShareWith.LastName,\r\n ClientEmail: this.selectedClientToShareWith.Email,\r\n Note: this.shareNote,\r\n DealId: this.dealDto.Id,\r\n Section: this.shareContext,\r\n ProductFamily: ProductFamilyEnum.Bridging,\r\n } as ShareModuleRequest;\r\n\r\n this.dealService.shareModuleToBorrower(request).then((success) => {\r\n if (success) {\r\n this.showShare = false;\r\n this.dataLoading = false;\r\n this.showModuleShareConfirmation = true;\r\n this.selectedClientToShareWith = null;\r\n } else {\r\n this.showShare = false;\r\n this.showMessage(\"Sorry, something went wrong. Please try again.\");\r\n }\r\n });\r\n }\r\n\r\n isShareNoteFormComplete(): boolean {\r\n return this.selectedClientToShareWith &&\r\n this.shareNote &&\r\n this.shareNote.length > 0\r\n ? true\r\n : false;\r\n }\r\n\r\n //End of Share module functions\r\n\r\n // Profile view functions\r\n\r\n /**\r\n * Show the Add/Edit permissions profile modal\r\n * @param applicant\r\n */\r\n showPermissionsProfileModal(\r\n profile: DealClientDTO = null,\r\n isEdit: boolean = false,\r\n ): void {\r\n this.showMaximumApplicantsMessage = false;\r\n if (isEdit) {\r\n this.dealClientService.fetch(profile.Id).then((response) => {\r\n this.newApplicant = response;\r\n this.isAddShareholder = false;\r\n this.showAddorEdit = true;\r\n\r\n })\r\n\r\n } else {\r\n this.newApplicant = {} as DealClientDTO;\r\n this.isAddShareholder = true;\r\n this.newApplicant.AccessLevel = CaseAccessLevelEnum.Hidden;\r\n this.showAddorEdit = true;\r\n }\r\n }\r\n\r\n resetApplicant() {\r\n this.applicantForm.$setPristine();\r\n this.applicantForm.$setUntouched();\r\n this.newApplicant = {} as DealClientDTO;\r\n this.showAddorEdit = false;\r\n }\r\n\r\n /**\r\n * Saves the applicant being added/edited\r\n */\r\n saveApplicant(formController, currentTab: string = \"\") {\r\n this.dataLoading = true;\r\n\r\n if (!(this.currentApplicant.Id > 0)) {\r\n this.currentApplicant.IsApplicant = true;\r\n this.currentApplicant.DealId = this.dealDto.Id;\r\n this.currentApplicant.AccessLevel = CaseAccessLevelEnum.Hidden;\r\n }\r\n\r\n this.saveUpdatedApplicant(\r\n this.currentApplicant,\r\n false,\r\n formController,\r\n currentTab,\r\n );\r\n }\r\n\r\n /**\r\n * Add or update a applicant\r\n * @param applicant\r\n */\r\n saveUpdatedApplicant(\r\n applicant: DealClientDTO,\r\n isPermissionsProfile: boolean = false,\r\n formController = null,\r\n currentTab: string = \"\",\r\n ): void {\r\n this.dataLoading = true;\r\n\r\n this.disableQuickEditSave = true; // this is just because sometimes the save takes a little while and the user could click the save button again\r\n applicant.DealId = this.dealDto.Id;\r\n\r\n if (applicant) {\r\n this.dateProperties.forEach((property) => {\r\n let val = applicant[property];\r\n if (val) {\r\n applicant[property] = this.modifyDateForBackend(val);\r\n }\r\n });\r\n }\r\n\r\n if (applicant.Profile) {\r\n this.profileDateProperties.forEach((property) => {\r\n let val = applicant.Profile[property];\r\n if (val) {\r\n applicant.Profile[property] = this.modifyDateForBackend(val);\r\n }\r\n });\r\n }\r\n\r\n if (applicant.Client) {\r\n this.clientDateProperties.forEach((property) => {\r\n let val = applicant.Client[property];\r\n if (val) {\r\n applicant.Client[property] = this.modifyDateForBackend(val);\r\n }\r\n });\r\n }\r\n\r\n if (!applicant.Client.PostalAddress && isPermissionsProfile) {\r\n applicant.Client.PostalAddress = {\r\n AddressLine1: \"\",\r\n AddressLine2: \"\",\r\n AddressLine3: \"\",\r\n AddressLine4: \"\",\r\n PostCode: \"\",\r\n } as PostalAddress;\r\n }\r\n\r\n this.dealClientService\r\n .addorUpdateApplicant(applicant, this.isAddShareholder)\r\n .then((response) => {\r\n this.dataLoading = true;\r\n\r\n if (response) {\r\n this.dateProperties.forEach((property) => {\r\n let val = response[property];\r\n if (val) {\r\n response[property] = this.modifyDateForFrontend(val);\r\n }\r\n });\r\n }\r\n\r\n if (response.Profile) {\r\n this.profileDateProperties.forEach((property) => {\r\n let val = response.Profile[property];\r\n if (val) {\r\n response.Profile[property] = this.modifyDateForFrontend(val);\r\n }\r\n });\r\n }\r\n\r\n if (response.Client) {\r\n this.clientDateProperties.forEach((property) => {\r\n let val = response.Client[property];\r\n if (val) {\r\n response.Client[property] = this.modifyDateForFrontend(val);\r\n }\r\n });\r\n }\r\n\r\n const existingShareholder = this.applicantList.find(\r\n (s) => s.Id == response.Id,\r\n );\r\n\r\n // If found then we're updating\r\n if (existingShareholder) {\r\n this.applicantList = this.applicantList.filter(\r\n (member) => member.Id != applicant.Id,\r\n );\r\n this.applicantList.push(response);\r\n } else {\r\n this.applicantList.push(response);\r\n }\r\n if (!isPermissionsProfile) {\r\n this.currentApplicant = response;\r\n //This closes all the tab\r\n //this.closeTabs(currentTab);\r\n formController.$setPristine();\r\n }\r\n })\r\n .finally(() => {\r\n delete this.newApplicant;\r\n this.showAddorEdit = false;\r\n this.disableQuickEditSave = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n cancelUpdateApplicant() {\r\n this.showAddorEdit = false;\r\n this.applicantList = this.applicantList.filter(\r\n (applicant) => applicant.Id != this.newApplicant?.Id,\r\n );\r\n this.applicantList.push(this.newApplicant); // Resets anything that is changed using the original data object\r\n }\r\n\r\n deleteApplicant(): void {\r\n this.dataLoading = true;\r\n this.dealClientService\r\n .markAsDeleteAndSetNextApplicantAsPrimary(\r\n this.dealDto.Id,\r\n this.confirmDeleteApplicant.Id,\r\n )\r\n .then((response) => {\r\n this.applicantList = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.confirmDeleteApplicant = {} as DealClientDTO;\r\n this.showDelete = false;\r\n });\r\n }\r\n\r\n deleteConfirmApplicant(applicant: DealClientDTO) {\r\n this.showDelete = true;\r\n this.confirmDeleteApplicant = { ...applicant };\r\n }\r\n\r\n nonUkWarningVisible(): boolean {\r\n return this.sharedDealService.nonUkWarningVisible(this.currentApplicant);\r\n }\r\n\r\n showInviteButton(shareholder: DealClientDTO) {\r\n return this.sharedDealService.showInviteButton(shareholder);\r\n }\r\n\r\n invite(applicant: DealClientDTO) {\r\n this.dataLoading = true;\r\n\r\n this.dealClientService\r\n .inviteApplicant(applicant.UniqueRef)\r\n .then((i) => {\r\n this.modal = true;\r\n this.message =\r\n \"A request has been sent to \" +\r\n applicant.Client.FirstName +\r\n \" \" +\r\n applicant.Client.LastName +\r\n \" complete their shareholder profile.\";\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem sending the invite request to \" +\r\n applicant.Client.FirstName +\r\n \" \" +\r\n applicant.Client.LastName +\r\n \". Please try again later.\";\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n //End of Profile view functions\r\n\r\n /** Show and hide the export menu */\r\n showAndHideExport() {\r\n this.showExport = !this.showExport;\r\n }\r\n\r\n /**Get planning options based on Own/Purchase and land/property selections */\r\n getPlanningOptions() {\r\n if (\r\n this.dealDto.OwnOrPurchase == null ||\r\n this.dealDto.LandOrProperty == null\r\n ) {\r\n return;\r\n }\r\n\r\n if (\r\n this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Purchasing &&\r\n this.dealDto.LandOrProperty == LandOrPropertyEnum.Property\r\n ) {\r\n this.planningOptions =\r\n this.selectListService.GetPurchasingExistingBuildingPlanningTypeOptions(\r\n this.dealDto.LandOrProperty == LandOrPropertyEnum.Property,\r\n );\r\n } else {\r\n this.planningOptions = this.selectListService.GetPlanningOptions(\r\n this.dealDto.OwnOrPurchase,\r\n this.dealDto.LandOrProperty,\r\n this.dealDto.LandOrProperty == LandOrPropertyEnum.Property,\r\n );\r\n }\r\n //this.planningOptions = this.selectListService.GetPlanningOptions(this.dealDto.OwnOrPurchase, this.dealDto.LandOrProperty);\r\n }\r\n\r\n propertySaveDisabled() {\r\n var commonFields = [\r\n this.dealDto.OwnOrPurchase,\r\n this.dealDto.Locations,\r\n this.dealDto.IsFamilyInResidence,\r\n this.dealDto.LandOrProperty,\r\n this.dealDto.PropertyAddress.AddressLine1,\r\n this.dealDto.PropertyAddress.PostCode,\r\n ];\r\n\r\n if (\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingPurchaseOrRefinance\r\n ) {\r\n let purchaseOrRefinanceFields = [\r\n this.dealDto.PurchasePrice,\r\n this.dealDto.PurchaseCosts,\r\n ];\r\n\r\n commonFields.push(...purchaseOrRefinanceFields);\r\n } else if (\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingDeveloperExit\r\n ) {\r\n let developerExitFields = [this.dealDto.BuildingCostTodate];\r\n\r\n commonFields.push(...developerExitFields);\r\n } else {\r\n let preConstructionFields = [\r\n this.dealDto.PurchasePrice,\r\n this.dealDto.GDV,\r\n this.dealDto.LoanTermReq,\r\n ];\r\n\r\n commonFields.push(...preConstructionFields);\r\n }\r\n\r\n if (this.propertyDetailsForm && this.propertyDetailsForm.$invalid)\r\n return true;\r\n\r\n //TODO: Not sure why this is used\r\n if (this.dealForm && this.dealForm.$invalid) return true;\r\n\r\n if (\r\n this.dealDto.IsFamilyInResidence == 0 ||\r\n (this.dealDto.IsFamilyInResidence == YesNoMaybe.Yes &&\r\n this.dealDto.ProductType !=\r\n ProductTypeEnum.BridgingPurchaseOrRefinance &&\r\n this.dealDto.ProductType != ProductTypeEnum.BridgingRefurb)\r\n )\r\n return true;\r\n\r\n if (\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingPreconstruction &&\r\n (this.dealDto.PlanningPermissionType == null ||\r\n this.dealDto.PlanningPermissionType < 1)\r\n ) {\r\n return true;\r\n }\r\n\r\n for (let i = 0; i < commonFields.length; i++) {\r\n if (\r\n commonFields[i] == null ||\r\n commonFields[i] == \"0\" ||\r\n commonFields[i] == \"\"\r\n ) {\r\n return true;\r\n }\r\n }\r\n\r\n if (this.dealDto.ProductType == ProductTypeEnum.BridgingPreconstruction) {\r\n if (this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Own) {\r\n let commonOwnFields = [\r\n this.dealDto.OriginalPurchaseDate,\r\n this.dealDto.Currentvalue,\r\n this.dealDto.LandTotalOtherCosts,\r\n ];\r\n for (let i = 0; i < commonOwnFields.length; i++) {\r\n if (commonOwnFields[i] == null) {\r\n return true;\r\n }\r\n }\r\n if (this.dealDto.LandOrProperty == LandOrPropertyEnum.Land) {\r\n let commonLandFields = [\r\n this.dealDto.PurchaseCosts,\r\n this.dealDto.EstimatedSpending,\r\n ];\r\n for (let i = 0; i < commonLandFields.length; i++) {\r\n if (commonLandFields[i] == null) {\r\n return true;\r\n }\r\n }\r\n if (this.dealDto.IsMortgaged) {\r\n if (\r\n this.dealDto.MortgageCurrentLender == null ||\r\n this.dealDto.MortgageCurrentLender == \"\"\r\n ) {\r\n return true;\r\n }\r\n }\r\n } else {\r\n let commonPropFields = [\r\n this.dealDto.EndPropertyType,\r\n this.dealDto.BuildingCondition,\r\n ];\r\n for (let i = 0; i < commonPropFields.length; i++) {\r\n if (commonPropFields[i] == null || commonPropFields[i] == \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n if (this.dealDto.EndPropertyType == PropertyTypeEnum.Residential) {\r\n if (\r\n this.dealDto.PropertyTypeDetail == null ||\r\n this.dealDto.PropertyTypeDetail == 0\r\n ) {\r\n return true;\r\n } else if (\r\n this.dealDto.PropertyTypeDetail ==\r\n PropertyTypeDetailEnum.Houses &&\r\n this.dealDto.HowManyHouses == null\r\n ) {\r\n return true;\r\n } else if (\r\n this.dealDto.PropertyTypeDetail == PropertyTypeDetailEnum.Flats &&\r\n this.dealDto.HowManyFlats == null\r\n ) {\r\n return true;\r\n } else if (\r\n this.dealDto.PropertyTypeDetail ==\r\n PropertyTypeDetailEnum.HousesAndFlats &&\r\n (this.dealDto.HowManyHouses == null ||\r\n this.dealDto.HowManyFlats == null)\r\n ) {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Purchasing) {\r\n let commonPurchFields = [\r\n this.dealDto.PurchaseCosts,\r\n this.dealDto.EstimatedSpending,\r\n ];\r\n for (let i = 0; i < commonPurchFields.length; i++) {\r\n if (commonPurchFields[i] == null) {\r\n return true;\r\n }\r\n }\r\n if (this.dealDto.LandOrProperty == LandOrPropertyEnum.Property) {\r\n let commonPropFields = [\r\n this.dealDto.EndPropertyType,\r\n this.dealDto.BuildingCondition,\r\n ];\r\n for (let i = 0; i < commonPropFields.length; i++) {\r\n if (commonPropFields[i] == null || commonPropFields[i] == \"0\") {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingPurchaseOrRefinance\r\n ) {\r\n if (this.dealDto.LandOrProperty == LandOrPropertyEnum.Land) {\r\n return true;\r\n } else {\r\n if (this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Own) {\r\n if (\r\n this.dealDto.BuildingCostTodate == null ||\r\n this.dealDto.BuildingCostTodate == 0\r\n )\r\n return true;\r\n }\r\n\r\n if (\r\n this.dealDto.IsPropertyImprovementDuringLoanTerm &&\r\n this.dealDto.IsExistingPlanChange\r\n ) {\r\n if (\r\n this.dealDto.ExistingPlanningChangeType == null ||\r\n this.dealDto.ExistingPlanningChangeType == 0\r\n )\r\n return true;\r\n }\r\n\r\n if (\r\n this.dealDto.EndPropertyType == null ||\r\n this.dealDto.EndPropertyType == \"0\"\r\n )\r\n return true;\r\n\r\n if (this.dealDto.PropertyTenure == null) return true;\r\n\r\n if (\r\n this.dealDto.IsTenantedBuilding != null &&\r\n this.dealDto.IsTenantedBuilding\r\n ) {\r\n if (\r\n this.dealDto.BuildingCondition == null ||\r\n this.dealDto.BuildingCondition == \"0\"\r\n )\r\n return true;\r\n }\r\n }\r\n }\r\n\r\n if (this.dealDto.ProductType == ProductTypeEnum.BridgingDeveloperExit) {\r\n if (this.dealDto.PropertyTenure == null) return true;\r\n }\r\n\r\n if (\r\n (this.dealDto.ProductType == ProductTypeEnum.BridgingPreconstruction ||\r\n this.dealDto.ProductType ==\r\n ProductTypeEnum.BridgingPurchaseOrRefinance) &&\r\n this.dealDto.PropertyTenure == TenureEnum.Leasehold\r\n ) {\r\n if (\r\n this.dealDto.YearsLeftOnLease < 0 ||\r\n this.dealDto.YearsLeftOnLease == null\r\n )\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n loanSaveDisabled() {\r\n var selectFields = [];\r\n if (\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingPurchaseOrRefinance\r\n ) {\r\n selectFields = [\r\n this.dealDto.AdditionalSecurity,\r\n this.dealDto.ExitStrategy,\r\n this.dealDto.InterestService,\r\n this.dealDto.LoanTermReq,\r\n this.dealDto.LoanPurpose,\r\n ];\r\n } else {\r\n selectFields = [\r\n this.dealDto.AdditionalSecurity,\r\n this.dealDto.ExitStrategy,\r\n this.dealDto.InterestService,\r\n this.dealDto.SourceOfIncome,\r\n this.dealDto.LoanPurpose,\r\n this.dealDto.PlanningStatusAtStartOfLoan,\r\n this.dealDto.PlanningStatusAtEndOfLoan,\r\n ];\r\n }\r\n\r\n if (this.loanDetailsForm.$invalid) return true;\r\n\r\n if (\r\n this.dealDto.LoanPurpose &&\r\n this.dealDto.LoanPurpose == LoanPurposeEnum.Other &&\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingPreconstruction\r\n ) {\r\n if (\r\n !this.dealDto.LoanPurposeDescription ||\r\n this.dealDto.LoanPurposeDescription.length == 0\r\n ) {\r\n return true;\r\n }\r\n }\r\n\r\n for (let i = 0; i < selectFields.length; i++) {\r\n if (selectFields[i] === 0 || selectFields[i] === \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n checkIfUserIsInvited() {\r\n //added to scope for directive\r\n this.dealService\r\n .checkIfUserIsInvited(this.currentUser.Id, this.dealId)\r\n .then((response: InvitedUserResponse) => {\r\n // if user has no active subscription (and are not a lender or admin) then they should be redirected back to the dashboard\r\n if (\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PaidUp &&\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PreCancel &&\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PaymentProcessing &&\r\n !response.IsInvited &&\r\n !this.isAdmin &&\r\n !this.isLender\r\n ) {\r\n this.$location.path(\"/dashboard\");\r\n return;\r\n }\r\n\r\n (this.$rootScope as any).isInvitedToCase = response.IsInvited;\r\n\r\n if (response.IsInvited) {\r\n if (response.DealAccessLevel == CaseAccessLevelEnum.ReadOnly) {\r\n (this.$rootScope as any).isInvitedAndHasReadonlyAccess = true;\r\n }\r\n }\r\n\r\n this.$rootScope.$broadcast(\"invitedStatusChange\");\r\n });\r\n }\r\n\r\n modifyDateForBackend(property: Date) {\r\n return this.sharedDealService.modifyDateForBackend(property);\r\n }\r\n\r\n modifyDateForFrontend(property: Date) {\r\n return this.sharedDealService.modifyDateForFrontend(property);\r\n }\r\n\r\n disablePersonalDetails() {\r\n return this.sharedDealService.disablePersonalDetails(\r\n this.currentApplicant,\r\n this.personalDetailsForm,\r\n );\r\n }\r\n\r\n goToUserDashboard() {\r\n this.authService.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n // Setting the dependent data when option are changed\r\n clearSearchdata() {\r\n this.dealDto = this.bridgingDealService.clearSearchdata(this.dealDto);\r\n }\r\n\r\n datasetupOnOwnOrPurchaseChange() {\r\n this.dealDto = this.bridgingDealService.datasetupOnOwnOrPurchaseChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnLandorPropertyChange() {\r\n this.dealDto = this.bridgingDealService.datasetupOnLandorPropertyChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnInterestServiceChange() {\r\n this.dealDto = this.bridgingDealService.datasetupOnInterestServiceChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnIsTenantedBuildingChange() {\r\n this.dealDto = this.bridgingDealService.datasetupOnIsTenantedBuildingChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnEndPropertyTypeChange() {\r\n this.dealDto = this.bridgingDealService.datasetupOnEndPropertyTypeChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnHasCompletionDateChange() {\r\n this.dealDto = this.bridgingDealService.datasetupOnHasCompletionDateChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnMaxLoanRequiredChange() {\r\n this.dealDto = this.dealService.dataSetupOnMaxLoanRequiredChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n updateClassUses() {\r\n if (this.dealDto.ClassUses > 0) {\r\n for (let i = 1; i < this.dealDto.ClassUses; i *= 2) {\r\n if (this.dealDto.ClassUses >= i) {\r\n //number is in enum sum, add it to object\r\n if (this.dealDto.ClassUses & i) {\r\n this.classUses[i] = true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n //watch and update classuses\r\n this.$scope.$watchCollection(\"ctrl.classUses\", (newVal: {}) => {\r\n let valuesList = Object.keys(newVal);\r\n let total: number = 0;\r\n //tot up all the numeric keys (class use enums)\r\n valuesList.forEach((v, i) => {\r\n let keyToNum = Number(v);\r\n if (newVal[keyToNum]) {\r\n total += keyToNum;\r\n }\r\n });\r\n this.dealDto.ClassUses = total;\r\n });\r\n }\r\n\r\n onPropertyTabSelection() {\r\n if (this.dealDto) {\r\n this.selectedNavMenu = this.BridgingCaseDashboardTypeEnum.Property;\r\n this.onTabSelection();\r\n }\r\n }\r\n\r\n discardDealData(form: ng.IFormController = null) {\r\n event.stopPropagation();\r\n if (form == this.propertyDetailsForm) {\r\n this.dealDto = JSON.parse(JSON.stringify(this.tempDealDto));\r\n this.PostCodeOptions = [];\r\n this.searchterm = null;\r\n } else {\r\n this.dealDto = JSON.parse(JSON.stringify(this.tempDealDto));\r\n }\r\n\r\n if (form) {\r\n form.$setPristine();\r\n form.$setUntouched();\r\n }\r\n }\r\n\r\n onLoanTabSelection() {\r\n if (this.dealDto) {\r\n this.selectedNavMenu = this.BridgingCaseDashboardTypeEnum.Loan;\r\n this.onTabSelection();\r\n }\r\n }\r\n\r\n onTabSelection() {\r\n this.tempDealDto = JSON.parse(JSON.stringify(this.dealDto));\r\n }\r\n\r\n discardApplicantData(form: ng.IFormController) {\r\n event.stopPropagation();\r\n this.currentApplicant = JSON.parse(JSON.stringify(this.tempApplicant));\r\n form.$setPristine();\r\n form.$setUntouched();\r\n }\r\n\r\n onApplicantTabSelection(tab) {\r\n const str = tab;\r\n this.tabs[str] = !this.tabs[str];\r\n\r\n this.tempApplicant = JSON.parse(JSON.stringify(this.currentApplicant));\r\n }\r\n\r\n carriageReturnCheck(event) {\r\n if (event.key === \"Enter\") {\r\n let position = event.target.selectionStart;\r\n if (this.newNote.NoteText) {\r\n this.newNote.NoteText = [\r\n this.newNote.NoteText.slice(0, position),\r\n \"\\n\",\r\n this.newNote.NoteText.slice(position),\r\n ].join(\"\");\r\n\r\n setTimeout(() => {\r\n event.target.setSelectionRange(position + 1, position + 1);\r\n }, 0);\r\n } else {\r\n this.newNote.NoteText = \"\\n\";\r\n }\r\n }\r\n }\r\n\r\n trustedHtml(plainText) {\r\n if (this.isClient && plainText.startsWith(\"Project submitted to lenders\")) {\r\n return this.$sce.trustAsHtml(\"Project submitted to lenders\");\r\n } else {\r\n return this.$sce.trustAsHtml(plainText);\r\n }\r\n }\r\n\r\n initialiseTitleAndTitleOption() {\r\n if (this.currentApplicant?.Profile) {\r\n const { Title, TitleOption } = this.currentApplicant.Profile;\r\n\r\n // If TitleOption has a value greater than 0, set Title to null\r\n if (\r\n (TitleOption > TitleEnum.None && TitleOption != TitleEnum.Other) ||\r\n Title == null\r\n ) {\r\n this.currentApplicant.Profile.Title = \"\";\r\n }\r\n // If Title exists and TitleOption is not set, set TitleOption to Other\r\n else if (Title && !TitleOption) {\r\n this.currentApplicant.Profile.TitleOption = TitleEnum.Other;\r\n }\r\n }\r\n }\r\n\r\n onTitleOptionChange() {\r\n const { TitleOption } = this.currentApplicant.Profile;\r\n\r\n if (TitleOption > 0 && TitleOption != TitleEnum.Other) {\r\n this.currentApplicant.Profile.Title = \"\";\r\n }\r\n }\r\n\r\n getTotalCosts() {\r\n this.totalCosts =\r\n Number(this.dealDto.PurchasePrice) +\r\n Number(this.dealDto.PurchaseCosts) +\r\n Number(this.dealDto.EstimatedSpending);\r\n if (isNaN(this.totalCosts)) {\r\n this.totalCosts = 0;\r\n }\r\n return this.totalCosts;\r\n }\r\n\r\n totalWarningVisible(): boolean {\r\n if (!this.dealDto.GDV) return false;\r\n this.getTotalCosts();\r\n\r\n return this.totalCosts > this.dealDto.GDV;\r\n }\r\n\r\n onPurchaseDateChange() {\r\n this.minCompletionDate = this.dealDto.OriginalPurchaseDate;\r\n }\r\n\r\n getProductRoute(): string {\r\n switch (this.dealDto.ProductType) {\r\n case ProductTypeEnum.BridgingPreconstruction:\r\n return \"\";\r\n case ProductTypeEnum.BridgingPurchaseOrRefinance:\r\n return \"/PurchaseRefinance\";\r\n case ProductTypeEnum.BridgingDeveloperExit:\r\n return \"/DeveloperExit\";\r\n case ProductTypeEnum.BridgingRefurb:\r\n return \"/Refurbishment\";\r\n default:\r\n return \"\";\r\n }\r\n }\r\n\r\n onOwnOrPurchaseChange(OwnOrPurchase: boolean) {\r\n this.dealDto.OwnOrPurchase = this.dealDto.HasOwnOrPurchase\r\n ? OwnOrPurchaseEnum.Own\r\n : OwnOrPurchaseEnum.Purchasing;\r\n this.getPlanningOptions();\r\n this.datasetupOnOwnOrPurchaseChange();\r\n }\r\n\r\n onLandOrPropertyChange() {\r\n this.dealDto.LandOrProperty = this.dealDto.HasLandOrProperty\r\n ? LandOrPropertyEnum.Property\r\n : LandOrPropertyEnum.Land;\r\n this.getPlanningOptions();\r\n this.datasetupOnLandorPropertyChange();\r\n }\r\n\r\n onIsFamilyInResidenceChange() {\r\n this.dealDto.IsFamilyInResidence = this.dealDto.HasIsFamilyInResidence\r\n ? YesNoMaybe.Yes\r\n : YesNoMaybe.No;\r\n if (this.isRegulatedBridging()) {\r\n this.loanPurposeOptions =\r\n this.selectListService.GetLoanPurposeOptions(true);\r\n }\r\n }\r\n\r\n initialDataSetupForIsFamilyInResidence() {\r\n if (this.dealDto.HasIsFamilyInResidence) {\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.Yes;\r\n this.dealDto.HasIsFamilyInResidence = true;\r\n } else {\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.No;\r\n this.dealDto.HasIsFamilyInResidence = false;\r\n }\r\n }\r\n\r\n onExistingPlanChange() {\r\n if (!this.dealDto.IsExistingPlanChange) {\r\n this.dealDto.ExistingPlanningChangeType =\r\n ExistingPlanningChangeTypeEnum.None;\r\n }\r\n }\r\n\r\n onPropertyImprovementDuringLoanTermChange() {\r\n if (!this.dealDto.IsPropertyImprovementDuringLoanTerm) {\r\n this.dealDto.IsExistingPlanChange = false;\r\n this.dealDto.ExistingPlanningChangeType =\r\n ExistingPlanningChangeTypeEnum.None;\r\n }\r\n }\r\n\r\n onLoanPurposeChange() {\r\n if (this.dealDto.LoanPurpose != LoanPurposeEnum.Other) {\r\n this.dealDto.LoanPurposeDescription = null;\r\n }\r\n }\r\n\r\n onExitStrategyChange() {\r\n if (this.dealDto.ExitStrategy != ExitStrategyEnum.Other) {\r\n this.dealDto.ExitStrategyOther = null;\r\n }\r\n }\r\n\r\n onAdditionalSecurityChange() {\r\n if (!this.dealDto.AdditionalSecurity) {\r\n this.dealDto.AdditionalSecurityInfo = null;\r\n }\r\n }\r\n\r\n onIsMortgagedChange() {\r\n if (!this.dealDto.IsMortgaged) {\r\n this.dealDto.MortgageCurrentLender = null;\r\n this.dealDto.MortgageCurrentBalance = 0;\r\n }\r\n }\r\n\r\n onExistingPlanningChangeType() {\r\n if (\r\n this.dealDto.ExistingPlanningChangeType ==\r\n ExistingPlanningChangeTypeEnum.BrandNewPlanningApplication\r\n ) {\r\n this.dealDto.PurchasePrice = 0;\r\n this.dealDto.PurchaseCosts = 0;\r\n this.dealDto.HasCompletionDate = YesNoMaybe.No;\r\n this.dealDto.CompletionDate = null;\r\n this.dealDto.Currentvalue = 0;\r\n }\r\n }\r\n\r\n goToLoanTypeSelectionPage() {\r\n if (this.isLoggedInUser) {\r\n this.authService.setHasValidStatustoShowShareSearchModal(\r\n true,\r\n );\r\n }\r\n this.$location.path(\"/allloans\");\r\n }\r\n\r\n goToDevFinanceCriteria() {\r\n if (this.isLoggedInUser) {\r\n this.$location.path(\"/devfinancecriteria\");\r\n } else {\r\n this.$location.path(\"/e/devfinancecriteria\");\r\n }\r\n }\r\n\r\n calcContingencyAmount() {\r\n if (this.dealDto.Contingency && this.dealDto.BuildCosts) {\r\n this.contingencyAmount =\r\n this.dealDto.Contingency * this.dealDto.BuildCosts;\r\n } else {\r\n this.contingencyAmount = null;\r\n }\r\n }\r\n\r\n calculateTotalShareholding(currentapplicant: DealClientDTO) {\r\n return this.sharedDealService.calculateTotalShareholding(\r\n currentapplicant,\r\n this.applicantList,\r\n );\r\n }\r\n\r\n getOrganisationbyDealId() {\r\n this.organisationService\r\n .getOrganisationAndBrokerByDealId(this.dealDto.Id)\r\n .then((response) => {\r\n this.org = response.Organisation;\r\n this.dealBrokerUser = response.Broker;\r\n this.brokerCommission =\r\n this.dealDto.Status == CaseStatusEnum.NewCase\r\n ? this.org?.CommissionPercent\r\n : this.dealDto.BrokerCommissionPercent;\r\n this.brokerPreferredContact =\r\n this.dealDto.Status == CaseStatusEnum.NewCase\r\n ? response.Broker.PhoneNumber\r\n : this.dealDto.BrokerPhoneNumber;\r\n if (this.org.IsWhiteLabelled) {\r\n this.fileNamePrefix = this.org.Name.replace(/ /g, \"_\");\r\n } else {\r\n this.fileNamePrefix = \"Brickflow\";\r\n }\r\n });\r\n }\r\n\r\n updateRequestAssitanceDealNoteMessage() {\r\n if (this.dealDto?.DealNotes != null && this.currentUser != null) {\r\n this.dealDto.DealNotes = this.dealDto.DealNotes.map((d) => {\r\n if (\r\n d.UserId != this.currentUser.Id &&\r\n (d.NoteText == \"Your have requested for assistance.\" ||\r\n d.NoteText == \"You have requested assistance.\")\r\n ) {\r\n return { ...d, NoteText: `${d.UserFullName} requested assistance.` };\r\n }\r\n\r\n return d;\r\n });\r\n }\r\n }\r\n\r\n getOwnershipPercentageText() {\r\n if (this.dealDto != null) {\r\n return this.sharedDealService.getOwnershipPercentageText(\r\n this.currentApplicant,\r\n this.dealDto.ProductType,\r\n );\r\n }\r\n return \"Shareholding\";\r\n }\r\n\r\n closeSubmitToLenderModal() {\r\n this.showTsAndCs = false;\r\n this.brokerCommission =\r\n this.dealDto.Status == CaseStatusEnum.NewCase\r\n ? this.org?.CommissionPercent\r\n : this.dealDto.BrokerCommissionPercent;\r\n this.brokerPreferredContact =\r\n this.dealDto.Status == CaseStatusEnum.NewCase\r\n ? this.dealBrokerUser?.PhoneNumber\r\n : this.dealDto.BrokerPhoneNumber;\r\n this.isBrokerPhoneNumberUpdated = false;\r\n }\r\n\r\n showBasedOnMainResidence() {\r\n return this.dealService.showBasedOnMainResidence(this.dealDto);\r\n }\r\n\r\n isRegulatedBridging() {\r\n if (\r\n this.dealDto.IsFamilyInResidence == YesNoMaybe.Yes &&\r\n (this.dealDto.ProductType ==\r\n ProductTypeEnum.BridgingPurchaseOrRefinance ||\r\n this.dealDto.ProductType == ProductTypeEnum.BridgingRefurb)\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n isCompanyAndOwnershipSaveDisabled() {\r\n if (this.isRegulatedBridging()) {\r\n return false;\r\n } else {\r\n return this.dealDto.HowWillYouOwnNewDevelopment == null ||\r\n this.dealDto.HowWillYouOwnNewDevelopment <= 0\r\n ? true\r\n : false;\r\n }\r\n }\r\n\r\n hasMaximumApplicants() {\r\n\r\n return this.applicantList.filter(a => a.IsApplicant).length >= 4 ? true : false;;\r\n }\r\n\r\n getRequiredRolesOptions() {\r\n return this.dealService.getRequiredRolesOptions(true, this.isReadOnlyDeal);\r\n }\r\n\r\n generateCaseStatusText() {\r\n if (this.isLender) {\r\n this.caseStatusOptions = this.selectListService.GetCaseLenderStateOptionsForLenders();\r\n }\r\n else {\r\n this.caseStatusOptions = this.selectListService.GetCaseStatusOptions(this.currentUser && this.currentUser.IsConnectUser);\r\n }\r\n this.getCaseStatusDisplayText();\r\n\r\n }\r\n\r\n showEditDealNameButton() {\r\n if (!this.isReadOnlyDeal && (!this.currentUser?.IsConnectUser || (this.currentUser?.IsConnectUser && !this.dealDto.IsReferredToConnect))) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n logExportDownload(eventName) {\r\n this.eventLogService.logEvent(\r\n eventName,\r\n EventLogEnum.Export,\r\n this.dealDto.ProductType,\r\n this.dealDto.Id,\r\n );\r\n }\r\n\r\n getTinymceOptions = function () {\r\n return this.isLender || this.isReadOnlyDeal ? this.tinymceReadonlyOptions : this.tinymceOptions;\r\n };\r\n}\r\n","export const enum InterestRateBasis {\r\n None = 0,\r\n BaseRate = 1,\r\n LendersOwnSVR = 2,\r\n Sonia = 3,\r\n}\r\n","export const enum InterestRateTypeEnum {\r\n None = 0,\r\n Fixed = 1,\r\n Variable = 2,\r\n}\r\n","export const enum MessageRoleEnum {\r\n None = 0,\r\n Admin = 1,\r\n Broker = 2,\r\n Lender = 4,\r\n Client = 8,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { BridgingDealDTO } from \"@js/DTO/Deal/BridgingDealDTO.cs.d\";\r\nimport { DealFileAttachmentDTO } from \"@js/DTO/Deal/DealFileAttachmentDTO.cs.d\";\r\nimport { DealLenderDTO } from \"@js/DTO/Deal/DealLenderDTO.cs.d\";\r\nimport { DealLenderMessageDTO } from \"@js/DTO/Deal/DealLenderMessageDTO.cs.d\";\r\nimport { FeedBackDTO } from \"@js/DTO/FeedBackDTO.cs.d\";\r\nimport { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { BridgingSubmitOfferRequest } from \"@js/DTO/Messages/Deal/BridgingSubmitOfferMessage.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { InterestRateBasis } from \"@js/models/enum/InterestRateBasisEnum.cs.d\";\r\nimport { InterestRateTypeEnum } from \"@js/models/enum/InterestRateTypeEnum.cs.d\";\r\nimport { MessageRoleEnum } from \"@js/models/enum/MessageRoleEnum.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { OwnOrPurchaseEnum } from \"@js/models/enum/OwnOrPurchaseEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { BridgingDealService } from \"@js/services/Deal/BridgingDealService\";\r\nimport { DealLenderMessageService } from \"@js/services/Deal/DealLenderMessageService\";\r\nimport { DealLenderService } from \"@js/services/Deal/DealLenderService\";\r\nimport { DealFileAttachmentService } from \"@js/services/DealFileAttachmentService\";\r\nimport { FeedBackService } from \"@js/services/FeedBackService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { SharedHeadsOfTermsService } from \"@js/services/Deal/SharedHeadsOfTermsService\";\r\n\r\nexport class BridgingHeadsOfTermsController {\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"LenderService\",\r\n \"RoleService\",\r\n \"DealLenderMessageService\",\r\n \"DealFileAttachmentService\",\r\n \"$window\",\r\n \"BridgingDealService\",\r\n \"DealLenderService\",\r\n \"SelectListService\",\r\n \"FeedBackService\",\r\n \"OrganisationService\",\r\n \"UserService\",\r\n \"AuthService\",\r\n \"ProductService\",\r\n \"SharedHeadsOfTermsService\"\r\n ];\r\n\r\n dataLoading: boolean = false; // Controls showing the data loading \"spinner\"\r\n dealLenders: DealLenderDTO[];\r\n showInformationMessage: boolean = false;\r\n messageContent: string;\r\n feedbackMessageToLender: string;\r\n\r\n showDirection: boolean = false;\r\n\r\n toggleFeedbackSection: boolean = false;\r\n toggleHoTDetailSection: boolean = false;\r\n toggleRejectSection: boolean = false;\r\n toggleWithdrawSection: boolean = false;\r\n\r\n isLender: boolean = false;\r\n isBroker: boolean = false;\r\n isAdmin: boolean = false;\r\n isClient: boolean = false;\r\n\r\n // show different sections to Lender based on which button clicked on Case Dashboard\r\n showFeedbackSectionLender: boolean = false;\r\n showHoTDetailSectionLender: boolean = false;\r\n showRejectSectionLender: boolean = false;\r\n showWithdrawSectionLender: boolean = false;\r\n\r\n showTsAndCsModal: boolean = false;\r\n showTsAndCsForm: boolean = false;\r\n sendingMessage: boolean = false;\r\n goToUserDashboard: boolean = false;\r\n\r\n currentDeal: BridgingDealDTO;\r\n currentCaseLender: DealLenderDTO;\r\n grossLoanCalcVal: number = 0;\r\n builLoanCalcVal: number = 0;\r\n landLoanCalcVal: number = 0;\r\n monetaryLAFee: number = 0;\r\n monetaryLEFee: number = 0;\r\n lenderTask: string = \"\";\r\n\r\n isRejectClicked: boolean = false;\r\n isWithdrawClicked: boolean = false;\r\n isConfirmClicked: boolean = false;\r\n isSubmitClicked: boolean = false;\r\n\r\n //Lender Message\r\n newChatMessage: string = \"\";\r\n showFullMessageId: number;\r\n\r\n //files\r\n fileUpload: DealFileAttachmentDTO[];\r\n uploadingFiles: FileUploadProgressDTO[];\r\n openModal: boolean = false;\r\n module = ModuleEnum.DIP;\r\n\r\n showFullLenderMessage = false;\r\n showFullBorrowerMessage = false;\r\n monthlyInterestRate: number = 0;\r\n\r\n isBridging: boolean = true;\r\n BasisOfInterestRateOptions = [];\r\n InterestRateTypeOptions = [];\r\n\r\n showLenderFeedBackModal: boolean = false;\r\n showBrokerFeedBackModal: boolean = false;\r\n feedBackDTO: FeedBackDTO;\r\n prevPath: string;\r\n showAutofill: boolean = false;\r\n\r\n brokerName: string;\r\n brokerOrganisationName: string;\r\n lendingForm: ng.IFormController;\r\n\r\n //Deleteing a chat message\r\n selectedDealLenderMessageDto: DealLenderMessageDTO;\r\n showdeleteChatMessageModal: boolean = false;\r\n showConfirmDeleteButton: boolean = false;\r\n\r\n currentUser: ApplicationUserDTO = {} as ApplicationUserDTO;\r\n productTypeText: string = null;\r\n noLenderOrMoreLenderError:boolean = false;\r\n \r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private lenderService: LenderService,\r\n private roleService: RoleService,\r\n private dealLenderMessageService: DealLenderMessageService,\r\n private dealFileAttachmentService: DealFileAttachmentService,\r\n private $window: ng.IWindowService,\r\n private bridgingDealService: BridgingDealService,\r\n private dealLenderService: DealLenderService,\r\n private selectListService: SelectListService,\r\n private feedBackService: FeedBackService,\r\n private organisationService: OrganisationService,\r\n private userService: UserService,\r\n private $auth: AuthService,\r\n private productService: ProductService,\r\n private sharedHeadsOfTermsService :SharedHeadsOfTermsService\r\n ) {\r\n this.feedBackDTO = {} as FeedBackDTO;\r\n if (\r\n this.$routeParams.openModule &&\r\n this.$routeParams.openModule == \"withdraw\"\r\n ) {\r\n this.toggleWithdrawSection = true;\r\n } else if (\r\n this.$routeParams.openModule &&\r\n this.$routeParams.openModule == \"reject\"\r\n ) {\r\n this.toggleRejectSection = true;\r\n } else if (this.$routeParams.openModule) {\r\n this.toggleFeedbackSection = true;\r\n }\r\n\r\n /*this.userService.getUserAutofill().then(response => {\r\n this.showAutofill = response;\r\n });*/\r\n\r\n if (this.$routeParams.DealId && this.$routeParams.DealLenderId) {\r\n this.dataLoading = true;\r\n\r\n this.bridgingDealService\r\n .fetch(this.$routeParams.DealId)\r\n .then((response) => {\r\n this.currentDeal = response;\r\n if (this.currentDeal) {\r\n this.dealLenderService\r\n .fetchByDealId(\r\n this.$routeParams.DealId,\r\n this.roleService.getIsLenderVisible(),\r\n this.$routeParams.DealLenderId,\r\n )\r\n .then((response) => {\r\n this.dealLenders = response;\r\n if (this.$routeParams.DealLenderId) {\r\n if (this.dealLenders.length != 1) {\r\n this.noLenderOrMoreLenderError = true;\r\n return;\r\n }\r\n this.currentCaseLender = this.dealLenders[0];\r\n this.fileUpload = this.currentDeal.Attachments.filter((f) => {\r\n return f.DealLenderId == this.$routeParams.DealLenderId;\r\n });\r\n this.calculateGrossLoanValVal();\r\n this.calculateBuildLoadCalcVal();\r\n this.calculateMonthlyInterestRate();\r\n this.calculateGrossLandLoanCalcVal();\r\n }\r\n }).finally(() => {\r\n this.populateLenderInformation(this.currentUser)\r\n });\r\n // this.caseService.updateCaseState(this.currentDeal.Id, this.currentDeal.Status);\r\n this.lenderTask = sessionStorage.getItem(\"lenderTask\");\r\n if (this.lenderTask != null && this.lenderTask.length > 0) {\r\n switch (this.lenderTask) {\r\n case \"reject\":\r\n this.showRejectSectionLender = true;\r\n break;\r\n case \"withdraw\":\r\n this.showWithdrawSectionLender = true;\r\n break;\r\n case \"feedback\":\r\n this.showFeedbackSectionLender = true;\r\n this.updateCaseLenderMessageReadDatetime();\r\n break;\r\n case \"terms\":\r\n this.showHoTDetailSectionLender = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n this.productTypeText = this.productService.getProductTypeFullName(\r\n this.currentDeal.ProductType,\r\n );\r\n } else {\r\n if ((this.$rootScope as any).selectedUser) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.getCurrentUserAndRoles();\r\n });\r\n }\r\n\r\n this.BasisOfInterestRateOptions =\r\n this.selectListService.GetInterestRateBasis();\r\n this.InterestRateTypeOptions = this.selectListService.GetInterestRateType();\r\n }\r\n\r\n checkingIfUserIsLender() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isLenderUser()\r\n .then((response) => {\r\n this.isLender = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkingIfUserIsBroker() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isBroker()\r\n .then((response) => {\r\n this.isBroker = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkingIfUserIsAdmin() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isAdminUser()\r\n .then((response) => {\r\n this.isAdmin = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkingIfUserIsClient() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isClientUser()\r\n .then((response) => {\r\n this.isClient = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n /** Redirects to the case dashboard */\r\n goToCaseDashboard() {\r\n this.showFeedbackSectionLender = false;\r\n this.showHoTDetailSectionLender = false;\r\n this.showRejectSectionLender = false;\r\n this.showWithdrawSectionLender = false;\r\n if (\r\n this.isBroker && this.currentCaseLender && \r\n !this.currentCaseLender.IsLenderReviewComplete &&\r\n (this.currentCaseLender.Status == CaseLenderStateEnum.Offered ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Rejected ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Withdrawn)\r\n ) {\r\n this.prevPath = \"bridgingcasedashboard\";\r\n this.feedBackDTO.IsLenderFeedback = true;\r\n this.showLenderFeedBackModal = true;\r\n } else {\r\n this.$location.path(\"/bridgingcasedashboard/\" + this.currentDeal.Id);\r\n }\r\n }\r\n\r\n /** Close modal after send feedback */\r\n closeModal() {\r\n this.showDirection = false;\r\n this.showTsAndCsModal = false;\r\n this.showInformationMessage = false;\r\n this.isConfirmClicked = false;\r\n this.showdeleteChatMessageModal = false;\r\n if (this.goToUserDashboard) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n this.goToUserDashboard = false;\r\n this.showFeedbackSectionLender = false;\r\n this.showHoTDetailSectionLender = false;\r\n this.showRejectSectionLender = false;\r\n this.showWithdrawSectionLender = false;\r\n }\r\n\r\n if (this.prevPath) {\r\n if (this.isLender) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n } else {\r\n this.$location.path(`/${this.prevPath}/${this.currentDeal.Id}`);\r\n }\r\n }\r\n }\r\n\r\n goToLending() {\r\n if (\r\n this.isBroker && this.currentCaseLender && \r\n !this.currentCaseLender.IsLenderReviewComplete &&\r\n (this.currentCaseLender.Status == CaseLenderStateEnum.Offered ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Rejected ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Withdrawn)\r\n ) {\r\n this.prevPath = \"dealforum\";\r\n this.feedBackDTO.IsLenderFeedback = true;\r\n this.showLenderFeedBackModal = true;\r\n } else {\r\n this.$location.path(\"/dealforum/\" + this.currentDeal.Id);\r\n }\r\n }\r\n\r\n saveUpdatedCaseLender(): void {\r\n this.dealLenderService\r\n .addUpdate(this.currentCaseLender)\r\n .then((response) => {\r\n this.currentCaseLender = response;\r\n this.messageContent = \"Your changes have been saved.\";\r\n this.showInformationMessage = true;\r\n });\r\n }\r\n\r\n dummyDIP() {\r\n this.dealLenderService.dummyDIP(this);\r\n }\r\n\r\n /** Process the Lender button being clicked*/\r\n lenderClicked() {\r\n (this.$rootScope as any).isLender = false; // TODO JLH why is this being set to false? What if the user is a lender?\r\n this.$location.path(\"/lending/\" + this.currentDeal.Id);\r\n }\r\n\r\n /** Process the Reject button being clicked*/\r\n rejectClicked(): void {\r\n this.isRejectClicked = true;\r\n this.dealLenderService\r\n .rejectCase(this.currentCaseLender)\r\n .then((response) => {\r\n this.currentCaseLender.Status = response.CaseLenderState;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.messageContent =\r\n \"The borrower has been notified you have rejected their application.\";\r\n })\r\n .catch((error) => {\r\n this.messageContent = \"Sorry, something went wrong. Please try again.\";\r\n this.isRejectClicked = false;\r\n })\r\n .finally(() => {\r\n this.goToUserDashboard = true;\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentDeal.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n });\r\n }\r\n\r\n ///**Process the Withdraw button being clicked */\r\n withdrawClicked(): void {\r\n this.isWithdrawClicked = true;\r\n this.dealLenderService\r\n .withdrawHoT(this.currentCaseLender)\r\n .then((response) => {\r\n this.currentCaseLender.Status = response.CaseLenderState;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.messageContent =\r\n \"The borrower has been notified you have withdrawn terms for their application.\";\r\n })\r\n .catch((error) => {\r\n this.messageContent = \"Sorry, something went wrong. Please try again.\";\r\n this.isWithdrawClicked = false;\r\n })\r\n .finally(() => {\r\n this.goToUserDashboard = true;\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentDeal.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n });\r\n }\r\n\r\n ///**Process the Submit button being clicked */\r\n submitClicked() {\r\n this.isConfirmClicked = true;\r\n this.showTsAndCsModal = true;\r\n }\r\n\r\n ///**Heads of Terms Submit button clicked event */\r\n submitHoTClicked() {\r\n // Close the Heads of Terms' Terms and Conditions modal\r\n this.showTsAndCsModal = false;\r\n this.sendingMessage = true;\r\n\r\n var request = {\r\n dealLender: this.currentCaseLender,\r\n dealLenderStatus: this.currentCaseLender.Status,\r\n } as BridgingSubmitOfferRequest;\r\n\r\n // Submit the Heads of Terms\r\n this.dealLenderService\r\n .submitOffer(request)\r\n .then((response) => {\r\n this.currentCaseLender.Status = response.dealLenderStatus;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.messageContent =\r\n \"Thank you for submitting a Decision in Principle.\";\r\n this.goToUserDashboard = true;\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while submitting your Decision in Principle. Please try again.\";\r\n this.isConfirmClicked = false;\r\n })\r\n .finally(() => {\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentDeal.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n this.sendingMessage = false;\r\n });\r\n }\r\n\r\n showBrokerFeedBack() {\r\n this.feedBackDTO.IsBrokerFeedback = true;\r\n this.showBrokerFeedBackModal = true;\r\n }\r\n\r\n /**\r\n * Process the Send Feedback button being clicked\r\n * @param message\r\n */\r\n sendChatMessage() {\r\n this.dataLoading = true;\r\n\r\n let DealChatMessage = {\r\n Message: this.newChatMessage,\r\n DealId: this.$routeParams.DealId,\r\n DealLenderId: this.$routeParams.DealLenderId,\r\n SenderRole: this.getSenderMessageRole(),\r\n RecipientRoles: this.isLender ? 10 : 4,\r\n } as DealLenderMessageDTO;\r\n\r\n this.dealLenderMessageService\r\n .addUpdate(DealChatMessage)\r\n .then((dealChatMessageResponse) => {\r\n this.currentCaseLender.DealLenderMessage.push(dealChatMessageResponse);\r\n this.newChatMessage = null;\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while sending feedback. Please try again.\";\r\n }).finally(() =>{\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n showFullChatMessage(index) {\r\n this.showFullMessageId = index;\r\n }\r\n\r\n updateCaseLenderMessageReadDatetime() {\r\n this.dealLenderMessageService\r\n .updateDealLenderMessageReadDatetime(this.$routeParams.DealLenderId)\r\n .then((caseLenderMessageResponse) => { });\r\n }\r\n\r\n onFileSelect(files: FileAttachmentDTO[], module: ModuleEnum) {\r\n if (files.length > 0) {\r\n this.dealFileAttachmentService\r\n .UploadFileListInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.$routeParams.DealId,\r\n this.fileUpload,\r\n module,\r\n this.$routeParams.DealLenderId,\r\n )\r\n .then((result) => {\r\n this.openModal = false;\r\n });\r\n }\r\n }\r\n\r\n downloadFile(file: DealFileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.dealFileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n this.$window.open(uri);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n deleteFile(file: DealFileAttachmentDTO) {\r\n this.fileUpload.splice(this.fileUpload.indexOf(file), 1);\r\n this.dealFileAttachmentService.markasdeleted(file.Id).then((result) => { }); //remove on the server\r\n }\r\n\r\n showActionButtons() {\r\n if (this.currentCaseLender && (this.currentCaseLender.Status == CaseLenderStateEnum.Received || this.currentCaseLender.Status == CaseLenderStateEnum.Rejected || this.currentCaseLender.Status == CaseLenderStateEnum.Offered || this.currentCaseLender.Status == CaseLenderStateEnum.Cancelled || this.currentCaseLender.Status == CaseLenderStateEnum.Withdrawn)) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n calculateGrossLoanValVal() {\r\n\r\n var value = 0;\r\n\r\n // for dev exit there is no GDV therefore use either current value or purchase price depending on whether it's owned or being purchased\r\n if (this.currentDeal.ProductType == ProductTypeEnum.BridgingDeveloperExit) {\r\n value = this.currentDeal.Currentvalue;\r\n } else {\r\n value = this.currentDeal.GDV;\r\n }\r\n\r\n if (\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan >= 0 &&\r\n value != null &&\r\n value >= 0\r\n ) {\r\n this.grossLoanCalcVal = parseFloat(\r\n (\r\n (this.currentCaseLender.TotalGrossLoan / value) *\r\n 100\r\n ).toFixed(2),\r\n );\r\n }\r\n\r\n\r\n if (\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n if (\r\n this.currentCaseLender.LenderArrangementFeePercent != null &&\r\n this.currentCaseLender.LenderArrangementFeePercent > 0\r\n ) {\r\n this.calculatemonetaryLAFee();\r\n } else {\r\n if (\r\n this.currentCaseLender.LenderArrangementFee != null &&\r\n this.currentCaseLender.LenderArrangementFee > 0\r\n ) {\r\n this.calculatemonetaryLAPercent();\r\n }\r\n }\r\n\r\n if (\r\n this.currentCaseLender.LenderExitFeePercent != null &&\r\n this.currentCaseLender.LenderExitFeePercent > 0\r\n ) {\r\n this.calculatemonetaryLEFee();\r\n } else {\r\n if (\r\n this.currentCaseLender.LenderExitFee != null &&\r\n this.currentCaseLender.LenderExitFee > 0\r\n ) {\r\n this.calculatemonetaryLEPercent();\r\n }\r\n }\r\n }\r\n }\r\n\r\n calculatemonetaryLAFee() {\r\n if (\r\n this.currentCaseLender.LenderArrangementFeePercent != null &&\r\n this.currentCaseLender.LenderArrangementFeePercent > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderArrangementFee =\r\n Math.round(\r\n this.currentCaseLender.TotalGrossLoan *\r\n this.currentCaseLender.LenderArrangementFeePercent *\r\n 100,\r\n ) / 100;\r\n }\r\n }\r\n\r\n calculatemonetaryLAPercent() {\r\n if (\r\n this.currentCaseLender.LenderArrangementFee != null &&\r\n this.currentCaseLender.LenderArrangementFee > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderArrangementFeePercent =\r\n this.currentCaseLender.LenderArrangementFee /\r\n this.currentCaseLender.TotalGrossLoan;\r\n\r\n this.currentCaseLender.LenderArrangementFeePercent = parseFloat(\r\n this.currentCaseLender.LenderArrangementFeePercent.toFixed(4),\r\n );\r\n }\r\n }\r\n\r\n calculatemonetaryLEFee() {\r\n if (\r\n this.currentCaseLender.LenderExitFeePercent != null &&\r\n this.currentCaseLender.LenderExitFeePercent > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderExitFee =\r\n Math.round(\r\n this.currentCaseLender.TotalGrossLoan *\r\n this.currentCaseLender.LenderExitFeePercent *\r\n 100,\r\n ) / 100;\r\n }\r\n }\r\n\r\n calculatemonetaryLEPercent() {\r\n if (\r\n this.currentCaseLender.LenderExitFee != null &&\r\n this.currentCaseLender.LenderExitFee > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderExitFeePercent =\r\n this.currentCaseLender.LenderExitFee /\r\n this.currentCaseLender.TotalGrossLoan;\r\n this.currentCaseLender.LenderExitFeePercent = parseFloat(\r\n this.currentCaseLender.LenderExitFeePercent.toFixed(4),\r\n );\r\n }\r\n }\r\n\r\n /**Calculate borrower equity\r\n */\r\n calculateBorrowerEquity() {\r\n var borrowerEquity: number = 0;\r\n\r\n if (this.currentDeal && this.currentCaseLender) {\r\n if (\r\n this.currentDeal.ProductType == ProductTypeEnum.BridgingPreconstruction\r\n ) {\r\n borrowerEquity =\r\n this.currentDeal.PropertyValue - this.currentCaseLender.TotalNetLoan;\r\n } else if (\r\n this.currentDeal.ProductType == ProductTypeEnum.BridgingDeveloperExit\r\n ) {\r\n borrowerEquity =\r\n this.currentDeal.PropertyValue -\r\n this.currentCaseLender.TotalGrossLoan;\r\n } else if (\r\n this.currentDeal.ProductType == ProductTypeEnum.BridgingRefurb\r\n ) {\r\n borrowerEquity =\r\n this.currentDeal.PropertyValue - this.currentCaseLender.LandLoan;\r\n } else if (\r\n this.currentDeal.ProductType ==\r\n ProductTypeEnum.BridgingPurchaseOrRefinance\r\n ) {\r\n borrowerEquity =\r\n this.currentDeal.PropertyValue -\r\n this.currentCaseLender.TotalGrossLoan;\r\n } else {\r\n borrowerEquity =\r\n this.currentDeal.PropertyValue -\r\n this.currentCaseLender.TotalGrossLoan;\r\n }\r\n }\r\n return Number(borrowerEquity);\r\n }\r\n\r\n /**Calculate true cost */\r\n calculateTrueCost(): number {\r\n if (this.currentCaseLender) {\r\n var trueCost: number =\r\n +this.currentCaseLender.InterestRate / 12 +\r\n (+this.currentCaseLender.LenderArrangementFeePercent +\r\n +this.currentCaseLender.LenderExitFeePercent) /\r\n +this.currentDeal.LoanTermReq;\r\n return trueCost;\r\n }\r\n }\r\n\r\n calculatInterestRate() {\r\n if (this.monthlyInterestRate) {\r\n this.currentCaseLender.InterestRate = this.monthlyInterestRate * 12;\r\n }\r\n }\r\n\r\n calculateMonthlyInterestRate() {\r\n if (this.currentCaseLender.InterestRate) {\r\n this.monthlyInterestRate = parseFloat(\r\n (this.currentCaseLender.InterestRate / 12).toFixed(4),\r\n );\r\n }\r\n }\r\n\r\n calculateAnnualInterestRate() {\r\n if (this.monthlyInterestRate) {\r\n this.currentCaseLender.InterestRate = parseFloat(\r\n (this.monthlyInterestRate * 12).toFixed(4),\r\n );\r\n }\r\n }\r\n\r\n calculateGrossLandLoanCalcVal() {\r\n if (\r\n this.currentCaseLender.LandLoan != null &&\r\n this.currentCaseLender.LandLoan >= 0\r\n ) {\r\n this.landLoanCalcVal = parseFloat(\r\n (\r\n (this.currentCaseLender.LandLoan / this.currentDeal.PurchasePrice) *\r\n 100\r\n ).toFixed(2),\r\n );\r\n }\r\n }\r\n\r\n calculateBuildLoadCalcVal() {\r\n if (\r\n this.currentCaseLender.BuildLoan != null &&\r\n this.currentCaseLender.BuildLoan >= 0\r\n ) {\r\n this.builLoanCalcVal = parseFloat(\r\n (\r\n (this.currentCaseLender.BuildLoan / this.currentDeal.BuildCosts) *\r\n 100\r\n ).toFixed(2),\r\n );\r\n }\r\n }\r\n\r\n /**Calculate the Total Net Loan */\r\n calculateTotalNetLoan() {\r\n var totalNetLoan: number = 0;\r\n if (\r\n this.currentCaseLender &&\r\n this.currentCaseLender.BuildLoan &&\r\n this.currentCaseLender.LandLoan\r\n ) {\r\n totalNetLoan =\r\n +this.currentCaseLender.BuildLoan + +this.currentCaseLender.LandLoan;\r\n totalNetLoan = Math.round(totalNetLoan * 100) / 100;\r\n }\r\n return totalNetLoan;\r\n }\r\n\r\n getRateTypeText(e: InterestRateTypeEnum) {\r\n switch (e) {\r\n case InterestRateTypeEnum.Fixed:\r\n return \"Fixed\";\r\n case InterestRateTypeEnum.Variable:\r\n return \"Variable\";\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n getBasisInterestRateText(e: InterestRateBasis) {\r\n switch (e) {\r\n case InterestRateBasis.BaseRate:\r\n return \"Base rate\";\r\n case InterestRateBasis.LendersOwnSVR:\r\n return \"own SVR\";\r\n case InterestRateBasis.Sonia:\r\n return \"Sonia\";\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n addClass(star: number, id: string) {\r\n this.feedBackService.addClass(star, id);\r\n }\r\n\r\n removeClass(star: number, id: string, rating) {\r\n this.feedBackService.removeClass(star, id, rating);\r\n }\r\n\r\n isFeedBackFormDisabled() {\r\n return this.feedBackService.isFeedBackFormDisabled(\r\n this.isLender,\r\n this.feedBackDTO,\r\n );\r\n }\r\n\r\n updateRating(star, rating) {\r\n this.feedBackDTO = this.feedBackService.updateRating(\r\n star,\r\n rating,\r\n this.feedBackDTO,\r\n );\r\n }\r\n\r\n submitFeedBack() {\r\n if (this.isLender) {\r\n this.feedBackDTO.OrganisationId = this.currentDeal.BrokerOrganisationId;\r\n this.feedBackDTO.BrokerUserId = this.currentDeal.BrokerUserId;\r\n } else {\r\n this.feedBackDTO.LenderId = this.currentCaseLender.LenderId;\r\n }\r\n\r\n this.feedBackService\r\n .addFeedBack(this.feedBackDTO, this.currentCaseLender.Id, true)\r\n .then((response) => {\r\n if (this.isLender) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n } else {\r\n this.$location.path(`/${this.prevPath}/${this.currentDeal.Id}`);\r\n }\r\n });\r\n }\r\n\r\n onClickDeleteMessageButton(message: DealLenderMessageDTO) {\r\n this.showdeleteChatMessageModal = true;\r\n this.messageContent = \"Are you sure you want to delete a selected message?\";\r\n this.selectedDealLenderMessageDto = message;\r\n this.showConfirmDeleteButton = true;\r\n }\r\n\r\n deleteChatMessage() {\r\n this.dataLoading = true;\r\n this.dealLenderMessageService\r\n .markasdeleted(this.selectedDealLenderMessageDto.Id)\r\n .then((response) => {\r\n this.currentCaseLender.DealLenderMessage =\r\n this.currentCaseLender.DealLenderMessage.filter(\r\n (x) => x.Id != this.selectedDealLenderMessageDto.Id,\r\n );\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while deleting message. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.showdeleteChatMessageModal = false;\r\n delete this.selectedDealLenderMessageDto;\r\n this.showConfirmDeleteButton = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n getSenderMessageRole() {\r\n if (this.isLender) {\r\n return MessageRoleEnum.Lender;\r\n } else if (this.isBroker) {\r\n return MessageRoleEnum.Broker;\r\n } else if (this.isAdmin) {\r\n return MessageRoleEnum.Admin;\r\n } else if (this.isClient) {\r\n return MessageRoleEnum.Client;\r\n }\r\n }\r\n\r\n getCurrentUserAndRoles() {\r\n this.dataLoading = true;\r\n this.userService\r\n .getcurentuserrecord()\r\n .then((result) => {\r\n this.currentUser = result;\r\n\r\n this.roleService.isClientUser().then((response) => {\r\n this.isClient = response;\r\n });\r\n\r\n this.roleService.isAdminUser().then((response) => {\r\n this.isAdmin = response;\r\n });\r\n\r\n this.roleService.isBroker().then((response) => {\r\n this.isBroker = response;\r\n });\r\n\r\n this.roleService.isLenderUser().then((response) => {\r\n this.isLender = response;\r\n if (!this.isLender) {\r\n this.toggleFeedbackSection = true;\r\n this.updateCaseLenderMessageReadDatetime();\r\n }\r\n });\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n populateLenderInformation(user: ApplicationUserDTO) {\r\n if (this.isLender) {\r\n this.currentCaseLender.ContactName = user.FullName;\r\n this.currentCaseLender.ContactEmail = user.Email;\r\n this.currentCaseLender.ContactMobilePhoneNumber = user.PhoneNumber;\r\n }\r\n }\r\n\r\n isCurrentUserAllowedToSendChat(){\r\n if(this.currentUser && this.currentDeal && (this.toggleFeedbackSection||this.showFeedbackSectionLender)){\r\n return this.sharedHeadsOfTermsService.isCurrentUserAllowedToSendChat(this.isBroker,this.currentDeal.Status,this.currentDeal.IsReferredToConnect, this.currentUser)\r\n }\r\n return false;\r\n }\r\n}\r\n","export const enum BridgingPersonalGuaranteeLevelEnum {\r\n None = 0,\r\n OneToTwentyFivePercent = 1,\r\n TwentySixToFiftyPercent = 2,\r\n FiftyOneToOneHundredPercent = 3,\r\n}\r\n","export const enum MaxFlatUnitPriceEnum {\r\n None,\r\n NoMax = 0,\r\n UpTo1Million = 1,\r\n UpTo2Million = 2,\r\n UpTo3Million = 3,\r\n}\r\n","export const enum MaxHouseSalePriceEnum {\r\n None,\r\n NoMax = 0,\r\n UpTo1Million = 1,\r\n UpTo2Million = 2,\r\n UpTo5Million = 3,\r\n}\r\n","export const enum MaxSqFtSalePriceEnum {\r\n None = 0,\r\n UpTo850 = 1,\r\n UpTo1000 = 2,\r\n UpTo1500 = 3,\r\n NoMax = 4,\r\n}\r\n","export const enum PreviousDevelopmentsEnum {\r\n None = 0,\r\n One = 1,\r\n Two = 2,\r\n Three = 3,\r\n FourOrMore = 4,\r\n OneOrTwo = 5,\r\n ThreeOrMore = 6,\r\n}\r\n","export const enum SortByEnum {\r\n None = 0,\r\n ROCE = 1,\r\n TrueMonthlyCost = 2,\r\n NetLoanSize = 3,\r\n LenderCosts = 4,\r\n LenderName = 5,\r\n InterestRate = 6,\r\n ArrangementFee = 7,\r\n MonthlyPayment = 8,\r\n DepositEquity = 9,\r\n LTGDV = 10,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { CaseLenderDTO } from \"@js/DTO/CaseLenderDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { BridgingDealDTO } from \"@js/DTO/Deal/BridgingDealDTO.cs.d\";\r\nimport { DealLenderDTO } from \"@js/DTO/Deal/DealLenderDTO.cs.d\";\r\nimport { ShareDealDTO } from \"@js/DTO/Deal/SearchDealDTO.cs.d\";\r\nimport { LenderResultDTO } from \"@js/DTO/DevelopmentFinance/LenderResultDTO.cs.d\";\r\nimport { LenderProductPairDTO } from \"@js/DTO/LenderProductPairDTO.cs\";\r\nimport { LenderResultMinimalDTO } from \"@js/DTO/DevelopmentFinance/LenderResultMinimalDTO.cs.d\";\r\nimport { BridgingSearchResultsResponse } from \"@js/DTO/Messages/BridgingSearchResultMessage.cs.d\";\r\nimport { SaveAsSearchRequest } from \"@js/DTO/Messages/Deal/SaveAsSearchMessage.cs.d\";\r\nimport { SaveBridgingSearchRequest } from \"@js/DTO/Messages/Deal/SaveBridgingSearchMessage.cs.d\";\r\nimport { UpdateBridgingSearchGetResultResponse } from \"@js/DTO/Messages/Deal/UpdateBridgingSearchGetResultMessage.cs.d\";\r\nimport { MakeReferralMessageRequest } from \"@js/DTO/Messages/MakeReferralMessage.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { BridgingLenderResultSummaryDTO } from \"@js/DTO/SearchResults/BridgingLenderResultSummaryDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { BridgingPersonalGuaranteeLevelEnum } from \"@js/models/enum/BridgingPersonalGuaranteeLevelEnum.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { EventLogEnum } from \"@js/models/enum/EventLogEnum.cs.d\";\r\nimport { MaxFlatUnitPriceEnum } from \"@js/models/enum/MaxFlatUnitPriceEnum.cs.d\";\r\nimport { MaxHouseSalePriceEnum } from \"@js/models/enum/MaxHouseSalePriceEnum.cs.d\";\r\nimport { MaxPercCommercialForMixedUseEnum } from \"@js/models/enum/MaxPercCommercialForMixedUseEnum.cs.d\";\r\nimport { MaxSqFtSalePriceEnum } from \"@js/models/enum/MaxSqFtSalePriceEnum.cs.d\";\r\nimport { OwnOrPurchaseEnum } from \"@js/models/enum/OwnOrPurchaseEnum.cs.d\";\r\nimport { PreviousDevelopmentsEnum } from \"@js/models/enum/PreviousDevelopmentsEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { SortByEnum } from \"@js/models/enum/SortByEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { BridgingSearchService } from \"@js/services/BridgingSearchService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { BridgingDealService } from \"@js/services/Deal/BridgingDealService\";\r\nimport { DealLenderService } from \"@js/services/Deal/DealLenderService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { SharedSearchResultsService } from \"@js/services/Deal/SharedSearchResultsService\";\r\nimport { DealClientService } from \"@js/services/DealClientService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationLinkService } from \"@js/services/OrganisationLinkService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { SharedDataService } from \"@js/services/SharedDataService\";\r\n\r\ndeclare const window: Window & { dataLayer: any[] };\r\n\r\nexport class BridgingLenderResultScreenController {\r\n loadingData: boolean = false;\r\n searchPanelForm: ng.IFormController;\r\n\r\n // tourState: any = {\r\n // tourStep: 1,\r\n // tourTotalSteps: 0,\r\n // };\r\n guidanceCheckbox: boolean = true;\r\n // tourEnabled: boolean = false;\r\n\r\n totalLender: number = 0;\r\n isSearch: boolean = true;\r\n\r\n debug1: boolean = false;\r\n\r\n loanCriteria: BridgingDealDTO;\r\n summarySearchResults: BridgingLenderResultSummaryDTO[];\r\n initialSummarySearchResults: BridgingLenderResultSummaryDTO[];\r\n productLastVerifiedDates = {};\r\n deletedDealLenders: LenderProductPairDTO[];\r\n offer: BridgingLenderResultSummaryDTO;\r\n comparisonList: BridgingLenderResultSummaryDTO[] = [];\r\n\r\n selectedResult: LenderResultDTO;\r\n\r\n selectedUser: ApplicationUserDTO = {} as ApplicationUserDTO;\r\n searchid: number = null;\r\n dealClientUniqueRef: string = null;\r\n dealUniqueRef: string = null;\r\n hideCaseCreation: boolean = false;\r\n\r\n loanLabel: string;\r\n showSaveResults: number;\r\n warningOff: boolean = false;\r\n currentCase: CaseDTO;\r\n productResultList: number;\r\n productId: number;\r\n caseLenders: CaseLenderDTO[];\r\n dealLenders: DealLenderDTO[];\r\n caseLendersNotInResults: DealLenderDTO[];\r\n filterLenderNames: string[] = [];\r\n\r\n sliderShown: boolean;\r\n searchNameCache: string;\r\n\r\n notifyBorrower: boolean = true;\r\n\r\n showProductNote: boolean = false;\r\n productNote: string;\r\n\r\n savePressed: boolean = false;\r\n\r\n //Capture name and email address & send results to unregistered searcher\r\n newUser: ApplicationUserDTO = {} as ApplicationUserDTO;\r\n error: string = \"\";\r\n\r\n // Flag to disable or enable the Save as button depending on the click.\r\n isClicked: boolean = false;\r\n showContactBrokerModal: boolean = false;\r\n\r\n //For admins accessing client accounts\r\n //clientUsernameBeingAccessed: string;\r\n toggleEditSearchName: boolean = false;\r\n // isBlankSearch: boolean = false;\r\n isAdmin: boolean = false;\r\n showActionPanel: boolean = false;\r\n\r\n isLoggedInUser: boolean = false;\r\n isLegacyUser: boolean = false;\r\n tempSearchName: string = null;\r\n isLoggingOut: boolean = false;\r\n\r\n //These are added for new search functinality\r\n existingUsers: UserSimpleDTO[];\r\n newSearch: boolean = false;\r\n existingborrower: boolean;\r\n showClientDetails: boolean = false;\r\n\r\n clientId: string = null;\r\n isIntroducer: boolean = false;\r\n isIntroduceronly: boolean = false;\r\n isLender: boolean = false;\r\n isBroker: boolean = false;\r\n appName: string;\r\n isSaveorSaveAsClicked: boolean = false;\r\n noOfShortlistAllowed: number = 5;\r\n displayMsg: string = null;\r\n showMsg: boolean = false;\r\n showMsgToAdminOrBroker: boolean = false;\r\n ShowdeleteSearch: boolean = false;\r\n isProceedClicked: boolean = false;\r\n\r\n isResultScreen: boolean = true;\r\n selecteduserName: string;\r\n isClient: boolean = false;\r\n tempLoanCriteria = null;\r\n showFilters: boolean = false;\r\n isFilterUpdate: boolean = false;\r\n isShortlistingMore: boolean = false;\r\n showSortBy: boolean = false;\r\n\r\n showContactLender: boolean = false;\r\n shareForm: ng.IFormController;\r\n\r\n lenderEmail: string;\r\n shareEmailSubject: string;\r\n sharedSearch: boolean = false;\r\n dataLoading: boolean = false;\r\n\r\n orgCode: string;\r\n orgName: string;\r\n orgNameUnderscore: string;\r\n brokerDetail: string = \"\";\r\n brokerageOrg: OrganisationDTO;\r\n brokerageOrgFilename: string = \"Brickflow\";\r\n showMessageToborrower: boolean = false;\r\n borrowerMessage: string = \"\";\r\n user: ApplicationUserDTO;\r\n moveContactBrokerBtnInMiddle: boolean = false;\r\n clientOrganisationPhoneNumber: string;\r\n isBridging: boolean = true;\r\n isMaximumLoanRequired: boolean = false;\r\n userLenderId: number = null;\r\n\r\n carouselData: string[] = [];\r\n numberOfPreviousDevelopmentsOptions = [];\r\n\r\n personalGuaranteeLevelOptions = [];\r\n maxHouseSalePriceOptions = [];\r\n maxFlatUnitPriceOptions = [];\r\n maxSqFtSalePriceOptions = [];\r\n maxPercCommercialForMixedUseOptions = [];\r\n locationOptions = [];\r\n valuationMethodOptions = [];\r\n maxCommercialFloorspaceOptions = [];\r\n\r\n personalGuaranteeLevel = null;\r\n maxHouseSalesPrice = null;\r\n maxFlatUnitPrice = null;\r\n maxSqFtSalePrice = null;\r\n maxPercCommercialForMixedUse = null;\r\n maxSqFtSalePriceFlats = null;\r\n previousDevelopments = null;\r\n\r\n shareDealDto: ShareDealDTO = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n hasSearchChanged: boolean = false;\r\n inActiveDealLender: number = 0;\r\n hasAccessToDeal: boolean = true;\r\n tempLoanRequired: number = null;\r\n\r\n showEligibility: boolean = false;\r\n showLenderSnapshot: boolean = false;\r\n showLenderNamesAndLogosOverride: boolean = false;\r\n isAssigned = false;\r\n userRole: string = null;\r\n\r\n dealProductTypeDisplayText: string;\r\n\r\n showEnterpriseRegistrationModal: boolean = false;\r\n projectName: string = \"\";\r\n registrationForm: ng.IFormController;\r\n emailExistsError: boolean = false;\r\n\r\n snapshotNewSearch: boolean = false;\r\n showPostcodeErrorMessage: boolean = false;\r\n postcodeErrorMsg: string;\r\n isPostcodeChange: boolean = false;\r\n\r\n noAccessToDealMsg: string;\r\n\r\n //This boolean is used in the shareedmodal.html for all the deals\r\n isDeal: boolean = true;\r\n\r\n //LenderReferralSearch\r\n lenderReferralData: MakeReferralMessageRequest = {} as MakeReferralMessageRequest;\r\n isLenderReferredSearch: boolean = false;\r\n isLenderReferringSearch: boolean = false;\r\n\r\n hasResultsProcessed: boolean = false;\r\n\r\n //SaveAs functionality\r\n isSaveAsClicked: boolean = false;\r\n saveAsSearchName: string;\r\n reloadSearch: boolean = false;\r\n\r\n //Enterprise journey\r\n showRegisterModal: boolean = false;\r\n showLoginSection: boolean = false;\r\n enterpriseClient: ApplicationUserDTO = {\r\n Id: \"\",\r\n AgreedToTermsAndPP: true,\r\n Roles: [\"Client\"],\r\n } as ApplicationUserDTO;\r\n\r\n // Previously shortlisted/submitted lenders which are not visible on current results because of criteria change\r\n HiddenDealLenderList: DealLenderDTO[] = [];\r\n showExportOptions: boolean = false;\r\n\r\n hasLiveSearch: boolean = true;\r\n\r\n\r\n //Confirm phone number for new client, when they register through enterprise journey from results page\r\n showClientPhoneNumberConfirmationModal: boolean = false;\r\n clientUpdatedContact: string;\r\n confirmClientPhoneNumberForm: ng.IFormController;\r\n clientUpdatedContactErrorMessage: string;\r\n\r\n // Logging in/resetting password\r\n isLoginError: boolean = false;\r\n isResetPasswordSubmitted: boolean = false;\r\n registrationLoginError: string = null;\r\n \r\n filterProperties = [\r\n \"F_IsFirstTimeDeveloper\",\r\n \"F_NumberOfPreviousDevelopments\",\r\n \"F_IsPersonalName\",\r\n \"F_IsOffshoreCompany\",\r\n \"F_IsMainShareholderOverseas\",\r\n \"F_PersonalGuaranteeMax\",\r\n \"F_HasAdverseCredit\",\r\n \"F_IsBelowMarketValue\",\r\n \"F_IsAutomatedValuationModel\",\r\n \"F_IsAuctionPurchase\",\r\n \"F_ValuationMethod\",\r\n \"F_MaxCommercialFloorspace\",\r\n \"F_IsShariaLoan\",\r\n \"F_IsGradeOneListed\",\r\n \"F_IsGradeTwoListed\",\r\n \"F_MaxHouseSalesPrice\",\r\n \"F_MaxFlatUnitPrice\",\r\n \"F_MaxNumberOfUnits\",\r\n \"F_MaxSqFtSalePrice\",\r\n \"F_MaxSqFtSalePriceFlats\",\r\n \"F_IsChargeOnAdditionalProperty\",\r\n \"F_IsFixedRate\",\r\n \"F_IsReBridge\",\r\n \"F_IsServicedInterest\",\r\n \"F_IsTitleInsurance\",\r\n \"F_IsIndemnityInsurance\",\r\n \"F_IsRetypedValuation\",\r\n \"F_IsTimberFrameConstruction\",\r\n \"F_IsConcreteConstruction\",\r\n ];\r\n\r\n static $inject = [\r\n \"$route\",\r\n \"$routeParams\",\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"$cookies\",\r\n \"UserService\",\r\n \"CaseService\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n \"LenderService\",\r\n \"OrganisationService\",\r\n \"SelectListService\",\r\n \"UserService\",\r\n \"BridgingSearchService\",\r\n \"BridgingDealService\",\r\n \"DealService\",\r\n \"DealLenderService\",\r\n \"ProductService\",\r\n \"EventLogService\",\r\n \"SharedSearchResultsService\",\r\n \"DealClientService\",\r\n 'OrganisationLinkService',\r\n 'SharedDataService'\r\n ];\r\n\r\n constructor(\r\n private $route: ng.route.IRouteService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $scope: ng.IScope,\r\n public $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $user: UserService,\r\n private $CaseService: CaseService,\r\n private $auth: AuthService,\r\n private roleService: RoleService,\r\n private lenderService: LenderService,\r\n private organisationService: OrganisationService,\r\n private selectListService: SelectListService,\r\n private userService: UserService,\r\n private bridgingSearchService: BridgingSearchService,\r\n private bridgingDealService: BridgingDealService,\r\n private dealService: DealService,\r\n private dealLenderService: DealLenderService,\r\n private productService: ProductService,\r\n private eventLogService: EventLogService,\r\n private sharedSearchResultsService: SharedSearchResultsService,\r\n private dealClientService: DealClientService,\r\n private organisationLinkService: OrganisationLinkService,\r\n private sharedDataService: SharedDataService\r\n ) {\r\n this.$auth.getShowBridgingEligibility().then((response) => {\r\n this.showEligibility = response;\r\n });\r\n\r\n this.$auth.getShowBridgingLenderSnapshot().then((response) => {\r\n this.showLenderSnapshot = response;\r\n });\r\n\r\n if (this.$location.path().startsWith(\"/bridgingshortlistmore\")) {\r\n this.isShortlistingMore = true;\r\n }\r\n\r\n\r\n if (this.$routeParams.SearchId) {\r\n if (/^\\d+$/.test(this.$routeParams.SearchId)) {\r\n // Treat the reference as an ID (e.g., fetch data using the ID)\r\n this.searchid = Number(this.$routeParams.SearchId);\r\n } else {\r\n // Treat the reference as a unique string (e.g., fetch data using the string)\r\n this.dealUniqueRef = this.$routeParams.SearchId;\r\n }\r\n } /*else {\r\n this.$CaseService.updateTubeMap(null);\r\n }*/\r\n\r\n if (this.$routeParams.dealclientuniqueref) {\r\n this.dealClientUniqueRef = this.$routeParams.dealclientuniqueref;\r\n }\r\n\r\n if (window.self == window.top && $cookies.get(\"access_token\")) {\r\n //This block is to navigate a broker to userdashboard when they do not have a license.\r\n if (sessionStorage.getItem(\"isValidLicense\") == \"false\") {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n this.isLoggedInUser = true;\r\n this.loadingData = true;\r\n this.organisationService\r\n .getOrganisation()\r\n .then((organisation) => {\r\n if (organisation) {\r\n if (!organisation.IsBrickflow) {\r\n //Getting organisation phone number to display on the screen with other text, when there are no results.\r\n this.clientOrganisationPhoneNumber = organisation.PhoneNumber;\r\n }\r\n this.orgCode = organisation.IsWhiteLabelled\r\n ? organisation.OrganisationCode\r\n : \"\";\r\n this.showLenderNamesAndLogosOverride =\r\n organisation.ShowLenderNames ?? false;\r\n\r\n if (organisation.IsWhiteLabelled) {\r\n this.orgName = organisation.Name.replace(/ /g, \"_\");\r\n } else {\r\n this.orgName = \"Brickflow\";\r\n }\r\n }\r\n })\r\n .catch((error) => {\r\n this.loadingData = false;\r\n })\r\n .finally(() => {\r\n //this.loadingData = false;\r\n });\r\n } else {\r\n if (window.self == window.top) {\r\n //this.userRole = sessionStorage.getItem('userRole');\r\n this.isClient = this.userRole == \"borrower\";\r\n this.orgCode = this.$cookies.get(\"org_code\");\r\n //this.clientId = sessionStorage.getItem('clientId');\r\n this.getSearchCriteriaAndResults();\r\n } else {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n this.guidanceCheckbox = false;\r\n Promise.all([\r\n this.organisationService.getData(\"userRole\").then((userRole) => {\r\n if (userRole) {\r\n this.userRole = userRole;\r\n this.isClient = this.userRole == \"borrower\";\r\n }\r\n }) /*,\r\n this.organisationService.getData('clientId').then(clientId => {\r\n if (clientId) {\r\n this.clientId = clientId;\r\n }\r\n })*/,\r\n //Try get session storage if running in iframe before getting results\r\n this.organisationService.getData(\"newSearch\").then((newSearch) => {\r\n if (newSearch) {\r\n this.snapshotNewSearch = newSearch == \"true\";\r\n }\r\n }),\r\n ])\r\n .then(() => {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n this.organisationService.sendDataToParent(\"newSearch\", \"false\");\r\n this.getSearchCriteriaAndResults();\r\n })\r\n .catch((error) => {\r\n // One or both of the promises were rejected, handle the error\r\n console.error(\"Failed to get user data: \", error);\r\n });\r\n }\r\n }\r\n\r\n if (window.self == window.top) {\r\n // let cookieTourStep = this.$cookies.get(\"tourStep\");\r\n // if (cookieTourStep) {\r\n // this.tourState.tourStep = cookieTourStep;\r\n // }\r\n\r\n //if user is logged in, get profile\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.$user.getcurentuserrecord().then((result) => {\r\n this.selectedUser = result;\r\n this.isLegacyUser = this.selectedUser.IsLegacyUser;\r\n\r\n this.roleService.isClientUser().then((response) => {\r\n this.isClient = response;\r\n\r\n if (this.clientOrganisationPhoneNumber && !this.isClient) {\r\n this.clientOrganisationPhoneNumber = null;\r\n }\r\n });\r\n\r\n this.roleService.isAdminUser().then((response) => {\r\n this.isAdmin = response;\r\n if (this.isAdmin) {\r\n this.getUsersBelongToBrokerOrAdmin();\r\n }\r\n });\r\n\r\n this.roleService.isBroker().then((response) => {\r\n this.isBroker = response;\r\n if (this.isBroker) {\r\n this.getUsersBelongToBrokerOrAdmin();\r\n }\r\n });\r\n\r\n this.roleService.isIntroducer().then((response) => {\r\n this.isIntroducer = response;\r\n });\r\n\r\n this.roleService.isIntroducerOnly().then((response) => {\r\n this.isIntroduceronly = response;\r\n });\r\n\r\n this.roleService.isLenderUser().then((response) => {\r\n this.isLender = response;\r\n if (this.isLender) {\r\n this.hasLiveSearch = false;\r\n this.lenderService.getUserLenderDetails().then((lender) => {\r\n if (lender.HasLiveMarketSearch) {\r\n this.hasLiveSearch = true;\r\n }\r\n });\r\n\r\n //Lender referred search\r\n if (sessionStorage.getItem(\"lenderReferralClient\")) {\r\n this.lenderReferralData.ClientDTO = JSON.parse(\r\n sessionStorage.getItem(\"lenderReferralClient\"),\r\n );\r\n this.isLenderReferringSearch = true;\r\n }\r\n this.userService.getCurrentUserLender().then((response) => {\r\n this.userLenderId = response;\r\n });\r\n }\r\n });\r\n if (this.isShortlistingMore) {\r\n this.lenderService.getDealDeletedLenderIds(this.searchid).then(response => {\r\n this.deletedDealLenders = response;\r\n }).finally(() => {\r\n this.getSearchCriteriaAndResults();\r\n });\r\n } else {\r\n this.getSearchCriteriaAndResults();\r\n }\r\n });\r\n } else {\r\n this.isClient = true; // if the user isn't logged in then this is the enterprise journey and should be treated as a borrower/client\r\n }\r\n\r\n // this.updateGuidanceState();\r\n\r\n // $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n // this.updateGuidanceState();\r\n // });\r\n\r\n let logoutUnregister = $rootScope.$on(\r\n \"logout\",\r\n (event: ng.IAngularEvent) => {\r\n this.isLoggingOut = true;\r\n },\r\n );\r\n\r\n $scope.$on(\"$destroy\", logoutUnregister);\r\n\r\n // $rootScope.$on(\"nextTour\", (event: ng.IAngularEvent) => {\r\n // this.tourNext();\r\n // });\r\n // $rootScope.$on(\"backTour\", (event: ng.IAngularEvent) => {\r\n // this.tourBack();\r\n // });\r\n // $rootScope.$on(\"skipTour\", (event: ng.IAngularEvent) => {\r\n // this.tourSkip();\r\n // });\r\n }\r\n\r\n this.getAppName();\r\n\r\n this.numberOfPreviousDevelopmentsOptions =\r\n this.selectListService.GetNumberOfPreviousDevelopmentsForBridging();\r\n this.personalGuaranteeLevelOptions =\r\n this.selectListService.GetBridgingPersonalGuaranteeLevels();\r\n this.maxHouseSalePriceOptions =\r\n this.selectListService.GetMaxHouseSalePrices();\r\n this.maxFlatUnitPriceOptions =\r\n this.selectListService.GetMaxFlatUnitPrices();\r\n this.maxSqFtSalePriceOptions =\r\n this.selectListService.GetMaxSqFtSalePrices();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n this.valuationMethodOptions = this.selectListService.GetValuationMethodOptions();\r\n this.maxCommercialFloorspaceOptions = this.selectListService.GetMaxCommercialFloorspaceOptions();\r\n }\r\n\r\n getRequiredRoles(isCaseDashboard: boolean) {\r\n if (isCaseDashboard) return `['Admin', 'Client', 'Broker', 'Introducer']`;\r\n return `['Admin', 'Client', 'Broker', 'Introducer', 'Lender']`;\r\n }\r\n\r\n onPersonalGuaranteeLevelOptionsChange(e: BridgingPersonalGuaranteeLevelEnum) {\r\n switch (e) {\r\n case BridgingPersonalGuaranteeLevelEnum.None:\r\n this.loanCriteria.F_PersonalGuaranteeMin = 0.0;\r\n this.loanCriteria.F_PersonalGuaranteeMax = 0.0;\r\n break;\r\n case BridgingPersonalGuaranteeLevelEnum.OneToTwentyFivePercent:\r\n this.loanCriteria.F_PersonalGuaranteeMin = 0.01;\r\n this.loanCriteria.F_PersonalGuaranteeMax = 0.25;\r\n break;\r\n case BridgingPersonalGuaranteeLevelEnum.TwentySixToFiftyPercent:\r\n this.loanCriteria.F_PersonalGuaranteeMin = 0.26;\r\n this.loanCriteria.F_PersonalGuaranteeMax = 0.5;\r\n break;\r\n case BridgingPersonalGuaranteeLevelEnum.FiftyOneToOneHundredPercent:\r\n this.loanCriteria.F_PersonalGuaranteeMin = 0.51;\r\n this.loanCriteria.F_PersonalGuaranteeMax = 1.0;\r\n break;\r\n default:\r\n this.loanCriteria.F_PersonalGuaranteeMin = null;\r\n this.loanCriteria.F_PersonalGuaranteeMax = null;\r\n break;\r\n }\r\n }\r\n\r\n getPersonalGuaranteeLevelOptions() {\r\n return this.sharedSearchResultsService.getPersonalGuaranteeLevelOptions(\r\n this.tempLoanCriteria.F_PersonalGuaranteeMax,\r\n );\r\n }\r\n\r\n getPreviousDevelopments() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_NumberOfPreviousDevelopments) {\r\n case 0:\r\n value = PreviousDevelopmentsEnum.None;\r\n break;\r\n case 5:\r\n value = PreviousDevelopmentsEnum.OneOrTwo;\r\n break;\r\n case 6:\r\n value = PreviousDevelopmentsEnum.ThreeOrMore;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n onMaxHouseSalesPriceChange(e: MaxHouseSalePriceEnum) {\r\n switch (e) {\r\n case MaxHouseSalePriceEnum.UpTo1Million:\r\n this.loanCriteria.F_MaxHouseSalesPrice = 1000000;\r\n break;\r\n case MaxHouseSalePriceEnum.UpTo2Million:\r\n this.loanCriteria.F_MaxHouseSalesPrice = 2000000;\r\n break;\r\n case MaxHouseSalePriceEnum.UpTo5Million:\r\n this.loanCriteria.F_MaxHouseSalesPrice = 5000000;\r\n break;\r\n case MaxHouseSalePriceEnum.NoMax:\r\n this.loanCriteria.F_MaxHouseSalesPrice = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxHouseSalesPrice = null;\r\n break;\r\n }\r\n }\r\n\r\n getMaxHouseSalesPrice() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_MaxHouseSalesPrice) {\r\n case 1000000:\r\n value = MaxHouseSalePriceEnum.UpTo1Million;\r\n break;\r\n case 2000000:\r\n value = MaxHouseSalePriceEnum.UpTo2Million;\r\n break;\r\n case 5000000:\r\n value = MaxHouseSalePriceEnum.UpTo5Million;\r\n break;\r\n case -999:\r\n value = MaxHouseSalePriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n onMaxFlatUnitPriceChange(e: MaxFlatUnitPriceEnum) {\r\n switch (e) {\r\n case MaxFlatUnitPriceEnum.UpTo1Million:\r\n this.loanCriteria.F_MaxFlatUnitPrice = 1000000;\r\n break;\r\n case MaxFlatUnitPriceEnum.UpTo2Million:\r\n this.loanCriteria.F_MaxFlatUnitPrice = 2000000;\r\n break;\r\n case MaxFlatUnitPriceEnum.UpTo3Million:\r\n this.loanCriteria.F_MaxFlatUnitPrice = 3000000;\r\n break;\r\n case MaxFlatUnitPriceEnum.NoMax:\r\n this.loanCriteria.F_MaxFlatUnitPrice = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxFlatUnitPrice = null;\r\n break;\r\n }\r\n }\r\n\r\n getMaxFlatUnitPrice() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_MaxFlatUnitPrice) {\r\n case 1000000:\r\n value = MaxFlatUnitPriceEnum.UpTo1Million;\r\n break;\r\n case 2000000:\r\n value = MaxFlatUnitPriceEnum.UpTo2Million;\r\n break;\r\n case 3000000:\r\n value = MaxFlatUnitPriceEnum.UpTo3Million;\r\n break;\r\n case -999:\r\n value = MaxFlatUnitPriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n onMaxSqFtSalePriceChange(e: MaxSqFtSalePriceEnum) {\r\n switch (e) {\r\n case MaxSqFtSalePriceEnum.UpTo850:\r\n this.loanCriteria.F_MaxSqFtSalePrice = 850;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1000:\r\n this.loanCriteria.F_MaxSqFtSalePrice = 1000;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1500:\r\n this.loanCriteria.F_MaxSqFtSalePrice = 1500;\r\n break;\r\n case MaxSqFtSalePriceEnum.NoMax:\r\n this.loanCriteria.F_MaxSqFtSalePrice = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxSqFtSalePrice = null;\r\n break;\r\n }\r\n }\r\n\r\n onMaxSqFtFlatsSalePriceChange(e: MaxSqFtSalePriceEnum) {\r\n switch (e) {\r\n case MaxSqFtSalePriceEnum.UpTo850:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = 850;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1000:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = 1000;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1500:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = 1500;\r\n break;\r\n case MaxSqFtSalePriceEnum.NoMax:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = null;\r\n break;\r\n }\r\n }\r\n\r\n getMaxSqFtSalePrice() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_MaxSqFtSalePrice) {\r\n case 850:\r\n value = MaxSqFtSalePriceEnum.UpTo850;\r\n break;\r\n case 1000:\r\n value = MaxSqFtSalePriceEnum.UpTo1000;\r\n break;\r\n case 1500:\r\n value = MaxSqFtSalePriceEnum.UpTo1500;\r\n break;\r\n case -999:\r\n value = MaxSqFtSalePriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n getMaxSqFtSalePriceFlats() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_MaxSqFtSalePriceFlats) {\r\n case 850:\r\n value = MaxSqFtSalePriceEnum.UpTo850;\r\n break;\r\n case 1000:\r\n value = MaxSqFtSalePriceEnum.UpTo1000;\r\n break;\r\n case 1500:\r\n value = MaxSqFtSalePriceEnum.UpTo1500;\r\n break;\r\n case -999:\r\n value = MaxSqFtSalePriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n clearSelected() {\r\n if (this.isShortlistingMore) {\r\n this.comparisonList = this.comparisonList.filter(item =>\r\n this.summarySearchResults.some(result => result.ProductID == item.ProductID)\r\n );\r\n\r\n const dealLenders = this.initialSummarySearchResults.filter(result =>\r\n result.IsDealLender && !result.IsDeleted\r\n );\r\n\r\n dealLenders.forEach(dealLender => {\r\n if (!this.comparisonList.some(item => item.ProductID === dealLender.ProductID)) {\r\n this.comparisonList.push(dealLender);\r\n }\r\n });\r\n } else {\r\n this.comparisonList = this.comparisonList.filter(item =>\r\n this.summarySearchResults.some(result => result.ProductID == item.ProductID)\r\n );\r\n }\r\n }\r\n\r\n applyFilters() {\r\n this.loadingData = true;\r\n this.showFilters = false;\r\n this.isFilterUpdate = true;\r\n\r\n if (this.loanCriteria.F_IsFirstTimeDeveloper) {\r\n this.loanCriteria.F_NumberOfPreviousDevelopments = null;\r\n }\r\n\r\n this.updateCriteriaAndGetResults(false);\r\n }\r\n\r\n clearClientFilters() {\r\n event.stopPropagation();\r\n this.loanCriteria.F_IsFirstTimeDeveloper = null;\r\n this.loanCriteria.F_NumberOfPreviousDevelopments = null;\r\n this.loanCriteria.F_IsPersonalName = null;\r\n this.loanCriteria.F_IsOffshoreCompany = null;\r\n this.loanCriteria.F_IsMainShareholderOverseas = null;\r\n\r\n this.loanCriteria.F_PersonalGuaranteeLevel = null;\r\n this.personalGuaranteeLevel = null;\r\n this.previousDevelopments = null;\r\n\r\n this.loanCriteria.F_PersonalGuaranteeMin = null;\r\n this.loanCriteria.F_PersonalGuaranteeMax = null;\r\n this.loanCriteria.F_HasAdverseCredit = null;\r\n this.loanCriteria.F_IsBelowMarketValue = null;\r\n this.loanCriteria.F_IsAutomatedValuationModel = null;\r\n this.loanCriteria.F_IsAuctionPurchase = null;\r\n this.loanCriteria.F_ValuationMethod = null;\r\n }\r\n\r\n showClearForClientFilters() {\r\n if (\r\n this.loanCriteria.F_IsFirstTimeDeveloper != null ||\r\n this.loanCriteria.F_NumberOfPreviousDevelopments != null ||\r\n this.loanCriteria.F_IsPersonalName != null ||\r\n this.loanCriteria.F_IsOffshoreCompany != null ||\r\n this.loanCriteria.F_IsMainShareholderOverseas != null ||\r\n this.loanCriteria.F_PersonalGuaranteeLevel != null ||\r\n this.loanCriteria.F_PersonalGuaranteeMin != null ||\r\n this.loanCriteria.F_PersonalGuaranteeMax != null ||\r\n this.loanCriteria.F_HasAdverseCredit != null ||\r\n this.loanCriteria.F_IsBelowMarketValue != null ||\r\n this.loanCriteria.F_IsAutomatedValuationModel != null ||\r\n this.loanCriteria.F_IsAuctionPurchase != null ||\r\n this.loanCriteria.F_ValuationMethod != null\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n toggleCheckbox(variableName) {\r\n if (\r\n this.loanCriteria[variableName] === null ||\r\n this.loanCriteria[variableName] === false\r\n ) {\r\n this.loanCriteria[variableName] = true;\r\n } else {\r\n this.loanCriteria[variableName] = null;\r\n }\r\n }\r\n\r\n clearPropertyFilters() {\r\n event.stopPropagation();\r\n //this.loanCriteria.F_IsAirRights = null;\r\n //this.loanCriteria.F_IsModular = null;\r\n //this.loanCriteria.F_IsPermittedDevelopmentScheme = null;\r\n this.loanCriteria.F_IsGradeOneListed = null;\r\n this.loanCriteria.F_IsGradeTwoListed = null;\r\n this.loanCriteria.F_MaxHouseSalesPrice = null;\r\n this.loanCriteria.F_MaxFlatUnitPrice = null;\r\n this.loanCriteria.F_MaxNumberOfUnits = null;\r\n this.loanCriteria.F_MaxPercCommercialForMixedUse = null;\r\n this.loanCriteria.F_MaxSqFtSalePrice = null;\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = null;\r\n\r\n //this.loanCriteria.F_IsWorkStarted = null;\r\n this.maxHouseSalesPrice = null;\r\n this.maxFlatUnitPrice = null;\r\n this.maxSqFtSalePrice = null;\r\n this.maxSqFtSalePriceFlats = null;\r\n this.loanCriteria.F_IsTimberFrameConstruction = null;\r\n this.loanCriteria.F_IsConcreteConstruction = null;\r\n this.loanCriteria.F_MaxCommercialFloorspace = null;\r\n }\r\n\r\n showClearForPropertyFilters() {\r\n if (\r\n this.loanCriteria.F_IsGradeOneListed != null ||\r\n this.loanCriteria.F_IsGradeTwoListed != null ||\r\n this.loanCriteria.F_MaxHouseSalesPrice != null ||\r\n this.loanCriteria.F_MaxFlatUnitPrice != null ||\r\n this.loanCriteria.F_MaxNumberOfUnits != null ||\r\n this.loanCriteria.F_MaxSqFtSalePrice != null ||\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats != null ||\r\n this.loanCriteria.F_IsTimberFrameConstruction != null ||\r\n this.loanCriteria.F_IsConcreteConstruction != null ||\r\n this.loanCriteria.F_MaxCommercialFloorspace != null\r\n\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n clearFinanceFilters() {\r\n event.stopPropagation();\r\n this.loanCriteria.F_IsChargeOnAdditionalProperty = null;\r\n this.loanCriteria.F_IsFixedRate = null;\r\n this.loanCriteria.F_IsShariaLoan = null;\r\n this.loanCriteria.F_IsRetypedValuation = null;\r\n this.loanCriteria.F_IsIndemnityInsurance = null;\r\n this.loanCriteria.F_IsTitleInsurance = null;\r\n this.loanCriteria.F_IsServicedInterest = null;\r\n this.loanCriteria.F_IsReBridge = null;\r\n }\r\n\r\n showClearForFinanceFilters() {\r\n if (\r\n this.loanCriteria.F_IsChargeOnAdditionalProperty != null ||\r\n this.loanCriteria.F_IsFixedRate != null ||\r\n this.loanCriteria.F_IsRetypedValuation != null ||\r\n this.loanCriteria.F_IsIndemnityInsurance != null ||\r\n this.loanCriteria.F_IsTitleInsurance != null ||\r\n this.loanCriteria.F_IsServicedInterest != null ||\r\n this.loanCriteria.F_IsReBridge != null ||\r\n this.loanCriteria.F_IsShariaLoan != null\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n clearAllFilters() {\r\n this.clearClientFilters();\r\n this.clearPropertyFilters();\r\n this.clearFinanceFilters();\r\n }\r\n\r\n debugSearch() {\r\n const stringJSON = JSON.stringify(this.loanCriteria);\r\n navigator.clipboard\r\n .writeText(stringJSON)\r\n .then()\r\n .catch((e) => console.log(e));\r\n }\r\n\r\n onClickFilterCancel() {\r\n this.filterProperties.forEach(\r\n (e) => (this.loanCriteria[e] = this.tempLoanCriteria[e]),\r\n );\r\n\r\n this.personalGuaranteeLevel = null;\r\n this.maxHouseSalesPrice = null;\r\n this.maxFlatUnitPrice = null;\r\n }\r\n\r\n filterPropertyToText(property: string) {\r\n let value = this.tempLoanCriteria[property];\r\n if (typeof value == \"boolean\" && value == true) {\r\n return;\r\n } else if (value != null && typeof value != \"boolean\") {\r\n return `: ${this.getPropertyValue(property)}`;\r\n } else if (value == null) {\r\n return;\r\n }\r\n return false;\r\n }\r\n\r\n checkFilterSelected(property: string) {\r\n return this.sharedSearchResultsService.checkFilterSelected(\r\n property,\r\n this.tempLoanCriteria,\r\n );\r\n }\r\n\r\n getPropertyValue(property) {\r\n let propertyValue = this.tempLoanCriteria[property];\r\n switch (property) {\r\n case \"F_PersonalGuaranteeMax\":\r\n return this.selectListService\r\n .GetBridgingPersonalGuaranteeLevels()\r\n .find((item) => item.key === this.getPersonalGuaranteeLevelOptions())\r\n ?.displayName;\r\n case \"F_MaxHouseSalesPrice\":\r\n return this.selectListService\r\n .GetMaxHouseSalePrices()\r\n .find((item) => item.key === this.getMaxHouseSalesPrice())\r\n ?.displayName;\r\n case \"F_MaxFlatUnitPrice\":\r\n return this.selectListService\r\n .GetMaxFlatUnitPrices()\r\n .find((item) => item.key === this.getMaxFlatUnitPrice())?.displayName;\r\n case \"F_MaxSqFtSalePrice\":\r\n return this.selectListService\r\n .GetMaxSqFtSalePrices()\r\n .find((item) => item.key === this.getMaxSqFtSalePrice())?.displayName;\r\n case \"F_MaxSqFtSalePriceFlats\":\r\n return this.selectListService\r\n .GetMaxSqFtSalePrices()\r\n .find((item) => item.key === this.getMaxSqFtSalePriceFlats())\r\n ?.displayName;\r\n case \"F_NumberOfPreviousDevelopments\":\r\n return this.selectListService\r\n .GetNumberOfPreviousDevelopmentsForBridging()\r\n .find((item) => item.key === this.getPreviousDevelopments())\r\n ?.displayName;\r\n case \"F_MaxNumberOfUnits\":\r\n return propertyValue;\r\n case \"F_ValuationMethod\":\r\n return this.selectListService\r\n .GetValuationMethodOptions()\r\n .find((item) => item.key === this.tempLoanCriteria.F_ValuationMethod)\r\n ?.displayName;\r\n case \"F_MaxCommercialFloorspace\":\r\n return this.selectListService\r\n .GetMaxCommercialFloorspaceOptions()\r\n .find((item) => item.key === this.tempLoanCriteria.F_MaxCommercialFloorspace)\r\n ?.displayName;\r\n default:\r\n return propertyValue;\r\n }\r\n }\r\n\r\n countFiltersSelected() {\r\n let count = 0;\r\n count = this.sharedSearchResultsService.countFiltersSelected(\r\n this.tempLoanCriteria,\r\n this.filterProperties,\r\n );\r\n return count;\r\n }\r\n\r\n getDisplayTextForProperty(property) {\r\n return this.sharedSearchResultsService.getDisplayTextForProperty(property);\r\n }\r\n\r\n splitCamelCase(str) {\r\n return str\r\n .replace(/([a-z])([A-Z])/g, \"$1 $2\")\r\n .replace(/([A-Z])([A-Z][a-z])/g, \"$1 $2\");\r\n }\r\n\r\n updateCriteriaAndGetResults(\r\n criteriaChanged: boolean,\r\n updateLoanLabels: boolean = false,\r\n ) {\r\n this.bridgingDealService\r\n .updateSearchCriteriaAndGetResults(\r\n this.loanCriteria,\r\n criteriaChanged,\r\n this.debug1,\r\n this.isPostcodeChange,\r\n this.isShortlistingMore\r\n )\r\n .then((results: UpdateBridgingSearchGetResultResponse) => {\r\n if (this.isPostcodeChange) {\r\n if (results.CriteriaLocation != null) {\r\n this.loanCriteria.Locations = results.CriteriaLocation;\r\n this.summarySearchResults = results.Results;\r\n } else {\r\n this.postcodeErrorMsg = results.PostCodeErrorMessage;\r\n this.showPostcodeErrorMessage = true;\r\n }\r\n } else {\r\n this.summarySearchResults = results.Results;\r\n this.sortSummaryResults();\r\n }\r\n })\r\n .catch((error) => { })\r\n .finally(() => {\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.clearSelected();\r\n this.isPostcodeChange = false;\r\n\r\n if (updateLoanLabels) {\r\n this.updateLoanLabels();\r\n }\r\n\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n /**Update the loan label in the comparison results based on the loan label returned in the results\r\n * Primary purpose is to update the loan label when the show lender names button is toggled\r\n * */\r\n updateLoanLabels() {\r\n for (var i = 0; i < this.comparisonList.length; i++) {\r\n let resultIndex = this.summarySearchResults.findIndex(\r\n (item) => item.ProductID == this.comparisonList[i].ProductID,\r\n );\r\n\r\n if (resultIndex > -1) {\r\n this.comparisonList[i].LoanLabel =\r\n this.summarySearchResults[resultIndex].LoanLabel;\r\n }\r\n }\r\n\r\n //This is used in shortlisting pdf\r\n this.prepareDataForShortlistPdf();\r\n }\r\n\r\n changeSearch() {\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n this.warningOff = true;\r\n sessionStorage.setItem(\"skip\", \"true\");\r\n if (!this.isLoggedInUser && (this.dealUniqueRef || this.dealClientUniqueRef)) {\r\n if (this.dealClientUniqueRef) sessionStorage.setItem('previousRoute', 'referredsearchdeal')\r\n var url = `/e/bridgingcriteria/${this.loanCriteria.UniqueRef}`;\r\n if (this.loanCriteria.OrganisationLinkId > 0) {\r\n url = `${url}/${this.loanCriteria.OrganisationLinkId}`;\r\n }\r\n this.go(url);\r\n }\r\n else if (this.searchid) {\r\n this.go(\"/bridgingcriteria/\" + this.searchid);\r\n } else {\r\n this.go(\"/bridgingcriteria\");\r\n }\r\n }\r\n\r\n newloan() {\r\n (this.$rootScope as any).loanCriteria = null;\r\n this.$location.path(\"/bridgingcriteria/0\");\r\n }\r\n\r\n getSearchResultCount() {\r\n return this.sharedSearchResultsService.getSearchResultCount(\r\n this.summarySearchResults,\r\n );\r\n }\r\n\r\n checkDeletedLender(lenderId: string, productId: string): boolean {\r\n if (this.isShortlistingMore && this.deletedDealLenders) {\r\n const deletedLender = this.deletedDealLenders.find(deletedLender => deletedLender.LenderId === String(lenderId));\r\n\r\n if (deletedLender) {\r\n return deletedLender.ProductId === String(productId);\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n getSearchLenderCount() {\r\n this.lenderService\r\n .getTotalLenders(ProductFamilyEnum.Bridging, this.loanCriteria.BrokerOrganisationId)\r\n .then((result: number) => {\r\n this.totalLender = result;\r\n });\r\n }\r\n\r\n getUsersBelongToBrokerOrAdmin() {\r\n this.loadingData = true;\r\n this.$user\r\n .getUserSummariesForBrokerOrAdmin()\r\n .then((response) => {\r\n this.existingUsers = response;\r\n });\r\n }\r\n\r\n // updateGuidanceState() {\r\n // this.tourEnabled = this.sharedSearchResultsService.updateGuidanceState(\r\n // this.guidanceCheckbox,\r\n // );\r\n // }\r\n\r\n // getGuidanceSwitchState() {\r\n // return this.sharedSearchResultsService.getGuidanceSwitchState();\r\n // }\r\n\r\n // recordGuidanceCookie() {\r\n // this.sharedSearchResultsService.recordGuidanceCookie(this.guidanceCheckbox);\r\n // this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n // }\r\n\r\n // tourNext(): void {\r\n // this.tourState.tourStep++;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // }\r\n\r\n // tourBack(): void {\r\n // this.tourState.tourStep--;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // }\r\n\r\n // tourSkip(): void {\r\n // this.tourEnabled = false;\r\n // this.$cookies.put(\"tourEnabled\", \"false\");\r\n // this.$cookies.remove(\"tourStep\");\r\n // }\r\n\r\n // startTour(): void {\r\n // this.tourState.tourStep = 1;\r\n // this.tourState.tourTotalSteps = 0;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // this.tourEnabled = true;\r\n // this.$cookies.put(\"tourEnabled\", \"true\");\r\n // }\r\n\r\n /**\r\n * Saves the new search name on the edit.\r\n * @param none\r\n */\r\n doRenameSearch() {\r\n var request: SaveBridgingSearchRequest = {\r\n DealDto: this.loanCriteria,\r\n ShareDealDto: this.shareDealDto,\r\n OrgCode: this.orgCode,\r\n EnterpriseClientDto: null,\r\n };\r\n\r\n if (this.searchid) {\r\n this.bridgingDealService\r\n .saveBridgingSearchReturnsId(request)\r\n .then((response) => {\r\n this.toggleEditSearchName = false;\r\n });\r\n } else if (this.dealUniqueRef) {\r\n if (this.isLoggedInUser) {\r\n this.bridgingDealService.saveBridgingSearchReturnsUniqueRef(request)\r\n .then((response) => {\r\n this.toggleEditSearchName = false;\r\n });\r\n } else {\r\n this.dealService.renameDeal(this.dealUniqueRef, this.loanCriteria.Name)\r\n .then((response) => {\r\n this.toggleEditSearchName = false;\r\n });\r\n }\r\n }\r\n else {\r\n this.toggleEditSearchName = false;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the search results and criteria for selected search\r\n * @param none\r\n */\r\n getSearchCriteriaAndResults() {\r\n if (window.self == window.top) {\r\n this.snapshotNewSearch = sessionStorage.getItem(\"newSearch\") == \"true\";\r\n sessionStorage.setItem(\"newSearch\", \"false\");\r\n }\r\n\r\n if (this.searchid) {\r\n this.loadingData = true;\r\n this.bridgingSearchService\r\n .getSearchCriteriaAndResultsByDealId(\r\n this.searchid,\r\n this.snapshotNewSearch,\r\n )\r\n .then((results) => {\r\n this.postResultsProcessing(results);\r\n })\r\n .then(() => {\r\n if (this.summarySearchResults != null) {\r\n const productIds = this.summarySearchResults.map((product) => product.ProductID);\r\n this.getProductLastVerifiedDates(productIds);\r\n }\r\n })\r\n .then(() => {\r\n this.getSearchLenderCount();\r\n if (this.isLoggedInUser) this.getSelectedProducts();\r\n this.updateLoanLabels();\r\n })\r\n .catch((error) => {\r\n console.log(error);\r\n })\r\n .finally(() => {\r\n if (this.loanCriteria) {\r\n this.isMaximumLoanRequired = this.loanCriteria.MaxLoanRequired;\r\n this.isSearch =\r\n this.loanCriteria &&\r\n this.loanCriteria.Status == CaseStatusEnum.Search;\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.$CaseService.updateTubeMap(this.loanCriteria.Status);\r\n this.loadingData = false;\r\n this.hasResultsProcessed = true;\r\n }\r\n });\r\n } else if (this.dealUniqueRef) {\r\n this.loadingData = true;\r\n this.bridgingSearchService\r\n .getSearchCriteriaAndResultsByDealUniqueRef(\r\n this.dealUniqueRef,\r\n this.snapshotNewSearch,\r\n )\r\n .then((results) => {\r\n this.postResultsProcessing(results);\r\n })\r\n .then(() => {\r\n if (this.summarySearchResults != null) {\r\n const productIds = this.summarySearchResults.map((product) => product.ProductID);\r\n this.getProductLastVerifiedDates(productIds);\r\n }\r\n })\r\n .then(() => {\r\n this.getSearchLenderCount();\r\n if (this.loanCriteria) this.getSelectedProducts();\r\n this.updateLoanLabels();\r\n })\r\n .catch((error) => {\r\n console.log(error);\r\n })\r\n .finally(() => {\r\n if (this.loanCriteria) {\r\n this.isMaximumLoanRequired = this.loanCriteria.MaxLoanRequired;\r\n this.isSearch =\r\n this.loanCriteria &&\r\n this.loanCriteria.Status == CaseStatusEnum.Search;\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n //this.$CaseService.updateTubeMap(this.loanCriteria.Status);\r\n this.loadingData = false;\r\n this.hasResultsProcessed = true;\r\n }\r\n });\r\n } else if (this.dealClientUniqueRef) {\r\n this.loadingData = true;\r\n this.bridgingSearchService\r\n .getSearchCriteriaAndResultsByDealClientUniqueRef(\r\n this.dealClientUniqueRef,\r\n this.snapshotNewSearch,\r\n )\r\n .then((results) => {\r\n this.postResultsProcessing(results);\r\n })\r\n .then(() => {\r\n if (this.loanCriteria) this.getSelectedProducts();\r\n this.getSearchLenderCount();\r\n if (\r\n sessionStorage.getItem(\"LoanCriteria\") &&\r\n (this.$rootScope as any).previousRoute.startsWith(\"/compare\")\r\n ) {\r\n this.comparisonList = JSON.parse(\r\n sessionStorage.getItem(\"ComparisonList\"),\r\n );\r\n //Removing lsd data saved for compare view.\r\n sessionStorage.removeItem(\"LoanCriteria\");\r\n sessionStorage.removeItem(\"ComparisonList\");\r\n }\r\n })\r\n .finally(() => {\r\n this.isMaximumLoanRequired = this.loanCriteria.MaxLoanRequired;\r\n this.isSearch =\r\n this.loanCriteria &&\r\n this.loanCriteria.Status == CaseStatusEnum.Search;\r\n //this.$CaseService.updateTubeMap(this.loanCriteria.Status);\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.loadingData = false;\r\n this.hasResultsProcessed = true;\r\n });\r\n }\r\n }\r\n\r\n postResultsProcessing(results: BridgingSearchResultsResponse) {\r\n if (results.HideDeal || results.HasNoAccessToDeal) {\r\n if (results.HasNoAccessToDeal) {\r\n if (this.isClient) {\r\n this.noAccessToDealMsg =\r\n \"Please contact your broker in order to access this case.\";\r\n } else {\r\n this.noAccessToDealMsg = \"Error retrieving deal.\";\r\n }\r\n }\r\n\r\n if (results.HideDeal) {\r\n this.noAccessToDealMsg =\r\n \"You cannot access Bridging search results. Please contact your admin for more details.\";\r\n }\r\n\r\n this.hasAccessToDeal = false;\r\n } else {\r\n this.summarySearchResults = this.initialSummarySearchResults = results.Results;\r\n this.loanCriteria = results.CriteriaDto;\r\n \r\n if(this.isLoggedInUser ){\r\n this.validateAccessAndRedirect();\r\n }\r\n \r\n this.sortSummaryResults();\r\n\r\n if (this.isLoggedInUser) {\r\n if (this.dealClientUniqueRef) {\r\n if (this.isClient) {\r\n this.eventLogService.logPageLoad(\r\n \"AFTER-ENTERPRISE-LEAD-REGISTRATION-USING-EMAIL-LINK\",\r\n this.orgCode,\r\n this.selectedUser.UserName,\r\n \"Client\",\r\n this.loanCriteria?.OrganisationLinkId,\r\n this.loanCriteria.ProductType,\r\n \"\",\r\n this.loanCriteria?.Id,\r\n );\r\n }\r\n } else {\r\n if (this.loanCriteria.LenderReferralLenderId) this.isLenderReferredSearch = true;\r\n\r\n // Showing confirm client phone number modal once client register through result page\r\n if (this.isClient && sessionStorage.getItem('showConfirmClientPhoneNo') == 'true') {\r\n this.showClientPhoneNumberConfirmationModal = true;\r\n this.clientUpdatedContact = this.loanCriteria?.DealClients[0].Client.PhoneNumber;\r\n }\r\n\r\n this.dealProductTypeDisplayText = this.productService.getProductTypeDisplayText(this.loanCriteria.ProductType,);\r\n\r\n // Expanding a 'new search' panel for first time search execution\r\n if (\r\n window.self == window.top &&\r\n sessionStorage.getItem(\"newSearch\")\r\n ) {\r\n this.sliderShown = (this.$rootScope as any).previousRoute.startsWith(\"/compare\") || this.showClientPhoneNumberConfirmationModal ? false : true;\r\n sessionStorage.removeItem(\"newSearch\");\r\n }\r\n }\r\n } else {\r\n if (this.$location.path().startsWith(\"/e/bridgingresults\")) {\r\n this.populateEnterpriseClientValue(\"LENDERRESULTS\");\r\n }\r\n\r\n if (this.dealClientUniqueRef) {\r\n if (this.$routeParams.showOnlyRegister == \"false\")\r\n this.isClient = true;\r\n this.populateEnterpriseClientValue(\"LENDERRESULTS-USING-EMAIL-LINK\");\r\n }\r\n }\r\n\r\n var owner = this.loanCriteria.DealClients.find((dc) => dc.IsPrimary);\r\n\r\n if (owner) {\r\n this.isAssigned = true;\r\n }\r\n }\r\n }\r\n\r\n populateEnterpriseClientValue(eventType) {\r\n if (this.loanCriteria.DealClients[0] != null) {\r\n this.enterpriseClient.FirstName =\r\n this.loanCriteria.DealClients[0].Client.FirstName;\r\n this.enterpriseClient.LastName =\r\n this.loanCriteria.DealClients[0].Client.LastName;\r\n this.enterpriseClient.Email =\r\n this.loanCriteria.DealClients[0].Client.Email;\r\n this.enterpriseClient.UserName =\r\n this.loanCriteria.DealClients[0].Client.Email;\r\n this.enterpriseClient.DealClientUniqueRef = this.loanCriteria.DealClients[0].UniqueRef;\r\n this.enterpriseClient.OrgCode = this.orgCode;\r\n this.enterpriseClient.PhoneNumber =\r\n this.loanCriteria.DealClients[0].Client.PhoneNumber;\r\n if (this.loanCriteria.DealClients[0].Client.ClientUserId) {\r\n this.showRegisterModal = true;\r\n this.showLoginSection = true;\r\n }\r\n\r\n if (this.loanCriteria.OrganisationLinkId) {\r\n this.organisationLinkService\r\n .getOrganisationLinkLogoByLinkIdAndLogPageLoadEvent(Number(this.loanCriteria.OrganisationLinkId), eventType, this.loanCriteria.Id, this.loanCriteria.ProductType, this.loanCriteria.DealClients[0]?.Client?.Email, this.loanCriteria.DealClients[0]?.Client?.Id.toString())\r\n .then((logoUrl) => {\r\n if (logoUrl) {\r\n var imgs = document.getElementsByTagName(\"img\");\r\n imgs[0].src = logoUrl\r\n }\r\n });\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n eventType,\r\n this.orgCode,\r\n this.loanCriteria.DealClients.length > 0\r\n ? this.loanCriteria.DealClients[0].Client.Email\r\n : \"\",\r\n \"Client\",\r\n this.loanCriteria.OrganisationLinkId != null\r\n ? this.loanCriteria.OrganisationLinkId\r\n : null,\r\n this.loanCriteria?.ProductType,\r\n \"\",\r\n this.loanCriteria?.Id,\r\n this.loanCriteria.DealClients.length > 0\r\n ? this.loanCriteria.DealClients[0].Client.Id.toString()\r\n : null,\r\n );\r\n }\r\n //Todo Roopa: do we need a broker details?\r\n this.getOrganisationAndBrokerDetails();\r\n }\r\n }\r\n\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n\r\n toggleLenderComparisonSelection(\r\n item: BridgingLenderResultSummaryDTO,\r\n index: number,\r\n ) {\r\n\r\n let comparisonMatches: BridgingLenderResultSummaryDTO[] =\r\n this.comparisonList.filter((result, index) => {\r\n return result.ProductID === item.ProductID;\r\n });\r\n\r\n if (!comparisonMatches || comparisonMatches.length === 0) {\r\n this.comparisonList.push(item);\r\n this.eventLogService.logEvent(\r\n `SHORTLISTING-RESULT`,\r\n EventLogEnum.Shortlisting,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n \"\",\r\n item.ProductID.toString(),\r\n \"\"\r\n );\r\n } else {\r\n\r\n if (this.isShortlistingMore && item.IsDealLender && (this.loanCriteria.Status != CaseStatusEnum.Search && this.loanCriteria.Status != CaseStatusEnum.NewCase))\r\n return;\r\n comparisonMatches.forEach((value, index) => {\r\n this.comparisonList.splice(this.comparisonList.indexOf(value), 1);\r\n });\r\n this.eventLogService.logEvent(\r\n `DESELECTING-SHORTLISTED-RESULT`,\r\n EventLogEnum.Shortlisting,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n \"\",\r\n item.ProductID.toString(),\r\n \"\"\r\n );\r\n }\r\n //This is user for shortlisting pdf\r\n this.prepareDataForShortlistPdf();\r\n }\r\n\r\n comparisonContains(item: BridgingLenderResultSummaryDTO): boolean {\r\n return !!this.comparisonList.find((result, index) => {\r\n return result.ProductID === item.ProductID;\r\n });\r\n }\r\n\r\n checkLender(item: BridgingLenderResultSummaryDTO): boolean {\r\n if (this.userLenderId == item.LenderID) return true;\r\n return false;\r\n }\r\n\r\n selectionOrderNumber(item: BridgingLenderResultSummaryDTO) {\r\n\r\n\r\n var activeProductList = this.comparisonList.filter(\r\n (cl) =>\r\n cl.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n cl.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n\r\n var hiddenProduct = this.HiddenDealLenderList.filter(hl => hl.Status != CaseLenderStateEnum.Rejected && hl.Status != CaseLenderStateEnum.Withdrawn);\r\n var hiddenProductLength = this.isShortlistingMore ? hiddenProduct.length : 0;\r\n\r\n var order =\r\n activeProductList.map((item) => item.ProductID).indexOf(item.ProductID) + hiddenProductLength +\r\n 1;\r\n if (order === 0) {\r\n return \" \";\r\n }\r\n\r\n return order;\r\n }\r\n\r\n /**\r\n * Processes the clicking of the \"View Eligibility\" anchor/button and index to show on the row number\r\n * @param item BridgingLenderResultSummaryDTO\r\n */\r\n viewEligibility(item: BridgingLenderResultSummaryDTO) {\r\n event.preventDefault(); // prevents default behaviour of href\r\n this.showProductNote = true;\r\n this.offer = item;\r\n this.loanLabel = item.LoanLabel;\r\n this.productNote = item.AdditionalProductInfo;\r\n }\r\n\r\n /**\r\n *Marks a selected search as a deleted\r\n * @param\r\n */\r\n deleteSearch() {\r\n if (this.$routeParams.SearchId) {\r\n this.dealService\r\n .markasdeleted(this.$routeParams.SearchId)\r\n .then((response) => {\r\n this.displayMsg = \"Search is successfully deleted\";\r\n this.showMsg = true;\r\n this.ShowdeleteSearch = true;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n this.showMsg = true;\r\n });\r\n }\r\n }\r\n\r\n closeDeleteModal() {\r\n this.showMsg = false;\r\n this.displayMsg = null;\r\n this.ShowdeleteSearch = false;\r\n this.warningOff = true;\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.go(\"/userdashboard\");\r\n }\r\n\r\n viewSingleLoan(item: BridgingLenderResultSummaryDTO) {\r\n event.preventDefault(); // prevents default behaviour of href\r\n this.warningOff = true;\r\n //Storing the actual comparisonList to local storage so that to recover it later when we comeback to result screen from compare screen.\r\n sessionStorage.setItem(\r\n \"actualcomparisonList\",\r\n JSON.stringify(this.comparisonList),\r\n );\r\n this.comparisonList = [];\r\n\r\n this.comparisonList.push(item);\r\n this.goCompare();\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n }\r\n\r\n goCompare() {\r\n this.warningOff = true;\r\n\r\n this.sharedSearchResultsService.clearStorageDataForCompareView();\r\n let comparisonList = this.comparisonList.filter(\r\n (cl) =>\r\n cl.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n cl.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n\r\n sessionStorage.setItem(\"ComparisonList\", JSON.stringify(comparisonList));\r\n sessionStorage.setItem(\"LoanCriteria\", JSON.stringify(this.loanCriteria));\r\n\r\n\r\n // temporarily put all results into saved results so the comparison controller can use them.\r\n let allResults: BridgingLenderResultSummaryDTO[] = [];\r\n this.summarySearchResults.forEach((result) => {\r\n allResults.push(result);\r\n });\r\n\r\n sessionStorage.setItem(\"TempSavedResults\", JSON.stringify(allResults));\r\n\r\n if (this.dealClientUniqueRef) {\r\n if (!this.isLoggedInUser) {\r\n this.dealUniqueRef = this.loanCriteria.UniqueRef;\r\n //This property is used in compare view controller to find previous route \r\n sessionStorage.setItem(\"DealClientUniqueRef\", this.dealClientUniqueRef);\r\n } else {\r\n this.searchid = this.loanCriteria.Id;\r\n }\r\n }\r\n\r\n if (this.searchid) {\r\n this.$location.path(\"compare/\" + this.searchid + \"/\" + 0 + \"/\" + true);\r\n } else {\r\n this.$location.path(\"compare/\" + this.dealUniqueRef + \"/\" + 0 + \"/\" + true);\r\n }\r\n\r\n }\r\n\r\n /**\r\n * Opens the modal to enter new name or calls 'register' method to svae and promote search to case.\r\n */\r\n\r\n applyForLoan() {\r\n this.isProceedClicked = true;\r\n this.register(true, this.productResultList);\r\n //if (this.searchid && this.loanCriteria.SearchName.startsWith('My Loan Search')) {\r\n // this.showSaveResults = 2;\r\n //} else if (this.searchid) {\r\n // this.register(true, this.productResultList)\r\n //}\r\n }\r\n\r\n getDealLenders(selectedLenders: BridgingLenderResultSummaryDTO[]) {\r\n var lendersList: DealLenderDTO[] = [];\r\n\r\n if (this.dealClientUniqueRef || this.dealUniqueRef) {\r\n this.searchid = this.loanCriteria.Id;\r\n }\r\n\r\n selectedLenders.forEach(({ ProductID, LenderID, GrossLoan }) => {\r\n var dealLender: DealLenderDTO;\r\n\r\n if (this.dealLenders) {\r\n dealLender = this.dealLenders.find(\r\n (dl) =>\r\n dl.DealId === this.searchid &&\r\n dl.ProductId === ProductID &&\r\n dl.LenderId === LenderID,\r\n );\r\n }\r\n\r\n if (!dealLender) {\r\n dealLender = {\r\n DealId: this.searchid,\r\n ProductId: ProductID,\r\n LenderId: LenderID,\r\n Status: CaseLenderStateEnum.Shortlisted,\r\n OriginalTotalGrossLoan: GrossLoan,\r\n } as DealLenderDTO;\r\n }\r\n\r\n lendersList.push(dealLender);\r\n });\r\n\r\n\r\n var unselecteLenderList = [];\r\n\r\n if (this.dealLenders) {\r\n unselecteLenderList = this.dealLenders.filter(dl => !lendersList.some(ll => ll.ProductId === dl.ProductId && ll.LenderId === dl.LenderId) && (dl.Status == CaseLenderStateEnum.Rejected || dl.Status == CaseLenderStateEnum.Withdrawn));\r\n }\r\n\r\n if (unselecteLenderList.length > 0) {\r\n unselecteLenderList.forEach((l) => {\r\n l.IsDeleted = true;\r\n lendersList.push(l);\r\n });\r\n }\r\n\r\n return lendersList;\r\n }\r\n\r\n\r\n getSelectedProducts() {\r\n\r\n if (this.summarySearchResults && this.summarySearchResults.length > 0) {\r\n this.dealLenderService\r\n .fetchDealLendersByDealId(this.dealClientUniqueRef || this.dealUniqueRef ? this.loanCriteria.Id : this.searchid)\r\n .then((results) => {\r\n this.dealLenders = results;\r\n })\r\n .then(() => {\r\n this.comparisonList = this.summarySearchResults.filter((result) => {\r\n const isDealLender = this.dealLenders.find(\r\n (dealLender) => dealLender.ProductId === result.ProductID,\r\n );\r\n if (isDealLender) {\r\n result.DealLenderStatus = isDealLender.Status;\r\n }\r\n return (result.IsDealLender = Boolean(isDealLender));\r\n });\r\n\r\n // Previously shortlisted/submitted lenders which are not visible on current results because of criteria change\r\n this.HiddenDealLenderList = this.dealLenders.filter(l =>\r\n !this.summarySearchResults.some(s => l.ProductId === s.ProductID)\r\n );\r\n\r\n if (this.comparisonList.length > 0) {\r\n var inActiveDealLenderList = this.comparisonList.filter(\r\n (ia) =>\r\n ia.DealLenderStatus == CaseLenderStateEnum.Rejected ||\r\n ia.DealLenderStatus == CaseLenderStateEnum.Withdrawn,\r\n );\r\n this.inActiveDealLender = inActiveDealLenderList.length;\r\n }\r\n\r\n if (\r\n sessionStorage.getItem(\"LoanCriteria\") &&\r\n (this.$rootScope as any).previousRoute.startsWith(\"/compare\")\r\n ) {\r\n if (sessionStorage.getItem(\"actualcomparisonList\")) {\r\n var selectedProducts = sessionStorage.getItem(\r\n \"actualcomparisonList\",\r\n );\r\n this.comparisonList = JSON.parse(selectedProducts);\r\n sessionStorage.removeItem(\"actualcomparisonList\");\r\n } else {\r\n this.comparisonList = JSON.parse(\r\n sessionStorage.getItem(\"ComparisonList\"),\r\n );\r\n }\r\n if (this.inActiveDealLender > 0) {\r\n this.comparisonList = this.comparisonList.concat(\r\n inActiveDealLenderList,\r\n );\r\n }\r\n\r\n //Removing lsd data saved for compare view.\r\n sessionStorage.removeItem(\"LoanCriteria\");\r\n sessionStorage.removeItem(\"ComparisonList\");\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Saves the search or saves the search and create a case.\r\n * @param createCase (boolean set to true when promoting search to case)\r\n */\r\n register(createCase: boolean = false, productResultList: number) {\r\n this.loadingData = true;\r\n\r\n if (this.isShortlistingMore) {\r\n if (this.validateAllLendersUnique(this.comparisonList) == true) {\r\n this.dealLenderService.shortlistMoreLenders(this.loanCriteria.Id, this.getDealLenders(this.comparisonList), this.hasSearchChanged).then((response) => {\r\n }).then(() => {\r\n this.getSelectedProducts();\r\n }).finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n this.loadingData = false;\r\n }\r\n } else {\r\n if (\r\n this.shareDealDto &&\r\n this.shareDealDto.DealName &&\r\n this.shareDealDto.DealName.length > 0\r\n ) {\r\n this.loanCriteria.Name = this.shareDealDto.DealName;\r\n }\r\n\r\n var request: SaveBridgingSearchRequest = {\r\n DealDto: this.loanCriteria,\r\n ShareDealDto: null,\r\n OrgCode: \"\",\r\n EnterpriseClientDto: null,\r\n };\r\n\r\n this.bridgingDealService\r\n .saveBridgingSearchReturnsId(request)\r\n .then((response) => {\r\n this.loanCriteria.Id = response as number;\r\n this.loadingData = false;\r\n\r\n // Creating the case is done on the casedashboard for deals\r\n if (createCase) {\r\n this.$location.path(\r\n \"/bridgingcasedashboard/\" + this.loanCriteria.Id + \"/\" + true,\r\n );\r\n }\r\n\r\n var shortlistDealLenders = this.getDealLenders(this.comparisonList);\r\n\r\n this.dealLenderService\r\n .addUpdatelistreturnonlyids(shortlistDealLenders)\r\n .then((response) => {\r\n let deallenders = this.dealLenders.filter(\r\n (lender) => response.indexOf(lender.Id) === -1,\r\n );\r\n\r\n deallenders.forEach((lender) =>\r\n this.dealLenderService.markasdeleted(lender.Id),\r\n );\r\n }).finally(() => {\r\n this.getSelectedProducts();\r\n this.isClicked = false;\r\n this.newSearch = false;\r\n this.isProceedClicked = false;\r\n this.showSaveResults = null;\r\n this.loadingData = false;\r\n });\r\n })\r\n .catch((response) => {\r\n //TODO BRIDGING - capture if an error has occurred and process it\r\n //this.isError = true;\r\n this.isProceedClicked = false;\r\n })\r\n .finally(() => { });\r\n }\r\n }\r\n\r\n /*onClickSaveAs() {\r\n this.showSaveResults = 3;\r\n this.tempSearchName = this.loanCriteria.Name;\r\n this.loanCriteria.Name = '';\r\n }\r\n\r\n saveAs() {\r\n\r\n this.isSaveorSaveAsClicked = true;\r\n this.register(false, this.productResultList);\r\n }*/\r\n\r\n onClickSaveAs() {\r\n this.isSaveAsClicked = true;\r\n if (this.isAdmin || this.isBroker) {\r\n if (!this.shareDealDto) {\r\n this.shareDealDto = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n }\r\n this.shareDealDto.DealName = \"\";\r\n this.showShareSearchModal();\r\n } else {\r\n this.showSaveResults = 3;\r\n }\r\n }\r\n\r\n saveSaveAsSearch(attachClient = false) {\r\n this.loadingData = true;\r\n let newSearchName = this.isBroker || this.isAdmin ? this.shareDealDto.DealName : this.saveAsSearchName;\r\n\r\n if (newSearchName.length == 0) {\r\n newSearchName = this.loanCriteria.Name + ' (Copy)';\r\n }\r\n\r\n var request: SaveAsSearchRequest = {\r\n ShareDealDto: attachClient ? this.shareDealDto : null,\r\n ProductFamily: this.loanCriteria.ProductFamily,\r\n SearchId: this.loanCriteria.Id,\r\n NewSearchName: newSearchName,\r\n };\r\n\r\n this.dealService\r\n .saveSaveAsSearch(request)\r\n .then((result) => {\r\n this.displayMsg = `${newSearchName} search has been saved to your dashboard.`;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.cancelNewSearch();\r\n this.loadingData = false;\r\n this.isSaveAsClicked = false;\r\n this.shareDealDto = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n this.saveAsSearchName = \"\";\r\n this.showSaveResults = null;\r\n this.showMsg = true;\r\n });\r\n }\r\n\r\n openSendResultsToBorrowerModal() {\r\n var client = this.loanCriteria.DealClients[0][\"Client\"]; // TODO BRIDGING FUTURE- always want to assume there's one for now until there's a redesign of sharing\r\n this.shareDealDto.DealId = this.loanCriteria.Id;\r\n this.shareDealDto.DealName = this.loanCriteria.Name;\r\n this.shareDealDto.IsApplicant = true;\r\n this.shareDealDto.IsPrimary = true;\r\n this.shareDealDto.ClientDto = {\r\n FirstName: client.FirstName,\r\n LastName: client.LastName,\r\n Email: client.Email,\r\n PhoneNumber: client.PhoneNumber,\r\n ClientUserId: client.ClientUserId,\r\n } as ClientDTO;\r\n this.existingborrower = null;\r\n this.newSearch = true;\r\n this.sharedSearch = true;\r\n }\r\n\r\n /** closes share results modal*/\r\n cancelNewSearch() {\r\n this.newSearch = false;\r\n this.shareDealDto.ClientDto = null;\r\n this.existingborrower = null;\r\n this.showClientDetails = false;\r\n this.selecteduserName = null;\r\n this.isSaveAsClicked = false;\r\n this.sharedSearch = false;\r\n if (this.tempSearchName) {\r\n this.loanCriteria.Name = this.tempSearchName;\r\n this.tempSearchName = \"\";\r\n }\r\n }\r\n\r\n /**\r\n * Sends email to client attached to the search\r\n */\r\n sendShareSearchEmailToClient() {\r\n this.dataLoading = true;\r\n this.shareDealDto.EmailLinkToClient = true;\r\n this.dealService\r\n .shareDealWithClient(this.shareDealDto)\r\n .then(() => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.shareDealDto.ClientDto.FirstName +\r\n \" \" +\r\n this.shareDealDto.ClientDto.LastName;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.newSearch = false;\r\n this.showMsg = true;\r\n this.dataLoading = false;\r\n this.sharedSearch = false;\r\n });\r\n }\r\n\r\n /**\r\n * Opens a 'share a search with client' modal if search do not have client attached to.\r\n * @param none\r\n */\r\n /* saveAsWthOutIntroducee() {\r\n this.isSaveAsWthOutIntroducee = true;\r\n this.tempSearchName = this.loanCriteria?.Name;\r\n //this.loanCriteria.Name = '';\r\n this.showShareSearchModal()\r\n }*/\r\n\r\n /**\r\n * Opens a 'share a search with client' modal if search do not have client attached to.\r\n * @param none\r\n */\r\n saveResultsForShareSearchToClient() {\r\n if (!this.isSaveAsClicked) {\r\n this.register(false, this.productResultList);\r\n } else {\r\n this.saveSaveAsSearch();\r\n }\r\n this.newSearch = false;\r\n }\r\n\r\n showShareSearchModal() {\r\n this.newSearch = true;\r\n\r\n this.shareDealDto = {\r\n DealId: this.searchid,\r\n DealName: this.isSaveAsClicked ? \"\" : this.loanCriteria?.Name,\r\n ShowLenderNamesAndLogos: this.loanCriteria?.ShowLenderInfoBrokerOverride,\r\n EmailLinkToClient: false,\r\n AccessLevel: CaseAccessLevelEnum.FullAccess,\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n\r\n this.shareDealDto.ClientDto = {\r\n FirstName: \"\",\r\n LastName: \"\",\r\n Email: \"\",\r\n PhoneNumber: \"\",\r\n } as ClientDTO;\r\n }\r\n\r\n /**\r\n * updates a seach with introducee details and saves it and sends emil to client if 'notifyBorrower' is set to true.\r\n * @param notifyBorrower\r\n */\r\n\r\n sendResultsToClient(notifyBorrower) {\r\n if (this.isSaveAsClicked) {\r\n this.saveSaveAsSearch(true);\r\n } else {\r\n this.loadingData = true;\r\n this.dealService\r\n .shareDealWithClient(this.shareDealDto)\r\n .then(() => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.shareDealDto.ClientDto.FirstName +\r\n \" \" +\r\n this.shareDealDto.ClientDto.LastName;\r\n //this.loanCriteria.DealClients[0] = this.shareDealDto.ClientDto;\r\n this.loanCriteria.Name = this.shareDealDto.DealName;\r\n this.newSearch = false;\r\n this.showMsg = true;\r\n this.reloadSearch = true;\r\n this.loadingData = false;\r\n this.isAssigned = true;\r\n })\r\n .finally(() => {\r\n delete this.shareDealDto;\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n\r\n cancelSavePopup() {\r\n this.showSaveResults = null;\r\n this.loanCriteria.Name = this.searchNameCache;\r\n }\r\n\r\n showBookMeetingButton() {\r\n return (\r\n !this.isLoggedInUser &&\r\n this.isClient &&\r\n this.brokerDetail == \"\" &&\r\n this.brokerageOrg != null\r\n );\r\n }\r\n\r\n bookMeeting() {\r\n this.$auth\r\n .getHubspotDeveloperBookMeetingWithSearch()\r\n .then((hubSpotUrl: string) => {\r\n window.open(hubSpotUrl);\r\n });\r\n }\r\n\r\n sendMessageToBroker(message) {\r\n this.loadingData = true;\r\n this.borrowerMessage = null;\r\n this.organisationService\r\n .sendBorrowerMessageToSearchBroker(\r\n this.loanCriteria.Id,\r\n message,\r\n this.loanCriteria.DealClients[0].Client.FirstName,\r\n this.loanCriteria.DealClients[0].Client.LastName,\r\n this.loanCriteria.DealClients[0].Client.Email,\r\n this.loanCriteria.ProductType,\r\n \"BRIDGINGRESULTSSCREEN\",\r\n )\r\n .then((results) => {\r\n if (results) {\r\n this.displayMsg = `Message has been sent successfully.`;\r\n this.showMessageToborrower = true;\r\n } else {\r\n this.displayMsg = `There is problem sending a message, Please try later.`;\r\n this.showMessageToborrower = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n closeContactBrokerModal() {\r\n this.showContactBrokerModal = false;\r\n this.showMessageToborrower = false;\r\n this.displayMsg = null;\r\n }\r\n\r\n getTotalShortlistedLenders() {\r\n var activeDealLenders = this.comparisonList.filter(\r\n (al) =>\r\n al.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n al.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n var hiddenProduct = this.HiddenDealLenderList.filter(hl => hl.Status != CaseLenderStateEnum.Rejected && hl.Status != CaseLenderStateEnum.Withdrawn);\r\n var hiddenProductLength = this.isShortlistingMore ? hiddenProduct.length : 0;\r\n\r\n return activeDealLenders.length + hiddenProductLength;\r\n }\r\n\r\n isLendersFiltered(): boolean {\r\n //If the search is empty return true\r\n if (!this.summarySearchResults && this.caseLenders) return true;\r\n\r\n if (!this.caseLenders) return false;\r\n\r\n //For all products that have been submitted for DIP and active, check if in the search\r\n return !this.caseLenders.every((lender) => {\r\n if (\r\n lender.CaseLenderState !== CaseLenderStateEnum.Withdrawn &&\r\n lender.CaseLenderState !== CaseLenderStateEnum.Rejected\r\n ) {\r\n const match = this.summarySearchResults.some(\r\n (summarySearchResult) =>\r\n lender.ProductID === summarySearchResult.ProductID,\r\n );\r\n if (!match) {\r\n if (this.filterLenderNames.indexOf(lender.LenderName) === -1) {\r\n this.filterLenderNames.push(lender.LenderName);\r\n }\r\n }\r\n return match;\r\n }\r\n return true;\r\n });\r\n }\r\n\r\n getLenderNames(): string {\r\n if (this.filterLenderNames.length === 1) {\r\n return \"lender \" + this.filterLenderNames[0];\r\n } else {\r\n return \"lenders \" + this.filterLenderNames.join(\", \");\r\n }\r\n }\r\n\r\n viewClientsDashboardForNewSearch(userName: string) {\r\n this.loadingData = true;\r\n this.shareDealDto.IsApplicant = true;\r\n this.shareDealDto.IsPrimary = true;\r\n //Look up client's account details\r\n this.$user.searchByEmail(userName).then((users) => {\r\n this.shareDealDto.ClientDto.FirstName = users[0].FirstName;\r\n this.shareDealDto.ClientDto.Email = users[0].Email;\r\n this.shareDealDto.ClientDto.LastName = users[0].LastName;\r\n this.shareDealDto.ClientDto.PhoneNumber = users[0].PhoneNumber;\r\n this.shareDealDto.ClientDto.ClientUserId = users[0].Id;\r\n this.showClientDetails = true;\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n returnToCase() {\r\n if (this.isShortlistingMore) {\r\n // copy newly selected products/lenders to caselender\r\n this.dealLenderService\r\n .shortlistMoreLenders(\r\n this.loanCriteria.Id,\r\n this.getDealLenders(this.comparisonList),\r\n this.hasSearchChanged,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n //sending 'Promote' as true if search has changed & 'NewShortlist' as true if isShortlistingMore\r\n this.$location.path(\r\n \"/bridgingcasedashboard/\" +\r\n this.loanCriteria.Id +\r\n \"/\" +\r\n null +\r\n \"/\" +\r\n true +\r\n \"/\" +\r\n this.hasSearchChanged,\r\n );\r\n }\r\n });\r\n } else {\r\n this.dealLenderService\r\n .updateShortlistedLenders(this.getDealLenders(this.comparisonList))\r\n .then((response) => {\r\n this.$location.path(\"/bridgingcasedashboard/\" + this.loanCriteria.Id);\r\n });\r\n }\r\n }\r\n\r\n updateSearchViaSlider(isAdminDebugValueChanged: boolean = false): void {\r\n if (this.searchPanelForm.$valid && !this.showPostcodeErrorMessage) {\r\n if (\r\n this.loanCriteria.ProductType !=\r\n ProductTypeEnum.BridgingDeveloperExit &&\r\n !(\r\n this.loanCriteria.OwnOrPurchase == OwnOrPurchaseEnum.Own &&\r\n this.loanCriteria.ProductType ==\r\n ProductTypeEnum.BridgingPurchaseOrRefinance\r\n ) &&\r\n !(\r\n this.loanCriteria.OwnOrPurchase == 1 &&\r\n this.loanCriteria.ProductType == ProductTypeEnum.BridgingRefurb\r\n )\r\n ) {\r\n if (this.loanCriteria.PurchasePrice <= 0) return;\r\n }\r\n\r\n if (\r\n this.loanCriteria.ProductType ==\r\n ProductTypeEnum.BridgingDeveloperExit ||\r\n (this.loanCriteria.OwnOrPurchase == OwnOrPurchaseEnum.Own &&\r\n this.loanCriteria.ProductType ==\r\n ProductTypeEnum.BridgingPurchaseOrRefinance) ||\r\n (this.loanCriteria.OwnOrPurchase == 1 &&\r\n this.loanCriteria.ProductType == ProductTypeEnum.BridgingRefurb)\r\n ) {\r\n if (this.loanCriteria.Currentvalue <= 0) return;\r\n }\r\n\r\n if (this.loanCriteria.ProductType == ProductTypeEnum.BridgingRefurb) {\r\n if (this.loanCriteria.GDV <= 0) return;\r\n }\r\n this.loadingData = true;\r\n\r\n this.hasSearchChanged = true;\r\n\r\n this.clearSelected();\r\n\r\n this.updateCriteriaAndGetResults(\r\n isAdminDebugValueChanged && this.isAdmin ? false : true,\r\n );\r\n }\r\n }\r\n\r\n //Clears the client data on share search modal\r\n clearInputFields() {\r\n this.shareDealDto.ClientDto.FirstName = null;\r\n this.shareDealDto.ClientDto.LastName = null;\r\n this.shareDealDto.ClientDto.Email = null;\r\n this.shareDealDto.ClientDto.PhoneNumber = null;\r\n this.shareDealDto.IsApplicant = true;\r\n this.shareDealDto.IsPrimary = true;\r\n this.showClientDetails = false;\r\n this.selecteduserName = null;\r\n }\r\n\r\n /** Redirects to the user dashboard */\r\n goToUserDashboard() {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n getTubeMapValue() {\r\n return this.$CaseService.getTubeMap();\r\n }\r\n\r\n updateLoanRequiredValue() {\r\n this.loanCriteria.MaxLoanRequired = this.isMaximumLoanRequired;\r\n\r\n if (this.isMaximumLoanRequired) {\r\n if (this.loanCriteria.NetLoanRequired) {\r\n this.tempLoanRequired = this.loanCriteria.NetLoanRequired;\r\n }\r\n this.loanCriteria.NetLoanRequired = 0;\r\n this.updateSearchViaSlider();\r\n } else {\r\n this.loanCriteria.NetLoanRequired = this.tempLoanRequired;\r\n this.updateSearchViaSlider();\r\n }\r\n }\r\n\r\n calculateMonthsSinceOrigPurchase() {\r\n let date1 = new Date(this.loanCriteria.OriginalPurchaseDate);\r\n let date2 = new Date();\r\n let months;\r\n months = (date2.getFullYear() - date1.getFullYear()) * 12;\r\n months -= date1.getMonth();\r\n months += date2.getMonth();\r\n return months;\r\n }\r\n\r\n datasetupOnEndPropertyTypeChange() {\r\n this.updateSearchViaSlider();\r\n }\r\n\r\n logPdfDownload(eventName) {\r\n this.eventLogService.logEvent(\r\n eventName,\r\n EventLogEnum.Export,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n );\r\n }\r\n\r\n /* saveEnterpriseClientAndRenameDeal() {\r\n this.loadingData = true;\r\n\r\n this.userService.checkEmailExists(this.user.Email).then((response) => {\r\n if (!response) {\r\n let userFullName = this.user.FullName;\r\n let spaceIndex = userFullName.indexOf(' ');\r\n\r\n let firstName = '';\r\n let lastName = '';\r\n\r\n // if not space has been added to the name then put the whole name in the first name field\r\n if (spaceIndex == -1) {\r\n firstName = userFullName;\r\n } else {\r\n firstName = userFullName.substring(0, userFullName.indexOf(' '));\r\n lastName = userFullName.substring(userFullName.indexOf(' ') + 1);\r\n }\r\n\r\n // Set up Client dto\r\n var clientDto = {\r\n FirstName: firstName,\r\n LastName: lastName,\r\n PhoneNumber: this.user.PhoneNumber,\r\n Email: this.user.Email,\r\n BrokerOrganisationId: this.brokerageOrg.Id,\r\n PostalAddress: {\r\n AddressLine1: '',\r\n AddressLine2: '',\r\n AddressLine3: '',\r\n AddressLine4: '',\r\n PostCode: ''\r\n } as PostalAddress\r\n } as ClientDTO;\r\n\r\n\r\n\r\n var currentDate = new Date();\r\n this.loanCriteria.Name = this.projectName ? this.projectName : firstName + ' ' + lastName + ' Loan Search ' + currentDate.getDate() + \"/\" + (currentDate.getMonth() + 1) + \"/\" + currentDate.getFullYear()\r\n\r\n var request: SaveEnterpriseClientAndRenameSearchRequest = {\r\n // BridgingDealDto: this.loanCriteria,\r\n ClientDto: clientDto,\r\n //ProductFamily: ProductFamilyEnum.Bridging,\r\n CommercialDealDto: null,\r\n DevFinanceDealDto: null\r\n }\r\n\r\n this.dealService.saveEnterpriseClientAndRenameDeal(request).then((response) => {\r\n if (response) {\r\n document.getElementById('body').style.overflow = \"auto\";\r\n this.showEnterpriseRegistrationModal = false;\r\n this.loanCriteria = response.BridgingDealDto;\r\n if (window.self == window.top) {\r\n sessionStorage.setItem('clientId', this.loanCriteria.DealClients[0].Client.Id.toString());\r\n } else {\r\n this.organisationService.sendDataToParent('clientId', this.loanCriteria.DealClients[0].Client.Id.toString());\r\n }\r\n\r\n this.userService.sendEventToHubspot(this.user, \"ENTERPRISE-CONTACT-REGISTERED\", false, this.orgCode, this.userRole, this.loanCriteria && this.loanCriteria.OrganisationLinkId != null ? this.loanCriteria.OrganisationLinkId : 0, this.loanCriteria.ProductType, this.loanCriteria ? this.loanCriteria.Id : 0);\r\n\r\n // For Google analytics tracking\r\n window.dataLayer = window.dataLayer || [];\r\n window.dataLayer.push({\r\n 'event': 'results_gating_form',\r\n 'loan_product_family': this.productService.getProductFamilyTextForGa(this.loanCriteria.ProductFamily),\r\n 'loan_product_type': this.productService.getProductTypeTextForGa(this.loanCriteria.ProductType, this.loanCriteria.IsFamilyInResidence)\r\n });\r\n }\r\n \r\n }).finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n this.emailExistsError = true;\r\n this.loadingData = false;\r\n }\r\n });\r\n\r\n \r\n }*/\r\n\r\n gotoSignInPage() {\r\n this.$location.path(\"/login\");\r\n }\r\n\r\n goToLink(url) {\r\n var baseUrl = window.location.href.split(\"#!\")[0] + \"#!\";\r\n var newUrl = baseUrl + url;\r\n window.open(newUrl, \"_blank\");\r\n }\r\n\r\n toggleShowLenderNamesBrokerOverride() {\r\n // this.loanCriteria.ShowLenderInfoBrokerOverride = !this.loanCriteria.ShowLenderInfoBrokerOverride;\r\n if (this.searchPanelForm.$valid && !this.showPostcodeErrorMessage) {\r\n this.updateCriteriaAndGetResults(false, true);\r\n }\r\n }\r\n\r\n getAppName() {\r\n let lsd = null;\r\n if (window.self == window.top)\r\n lsd = sessionStorage.getItem(\"applicationName\");\r\n if (lsd != null) {\r\n this.appName = lsd;\r\n } else {\r\n this.appName = \"Brickflow\";\r\n }\r\n }\r\n\r\n onSelectingExportShortlist(eventName) {\r\n let comparisonList = this.comparisonList.filter(\r\n (cl) =>\r\n cl.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n cl.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n this.loanCriteria.ComparisonList = comparisonList;\r\n this.eventLogService.logEvent(\r\n eventName,\r\n EventLogEnum.Export,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n );\r\n }\r\n\r\n showContactBrokerAndExportButton() {\r\n if (\r\n this.brokerageOrg != null &&\r\n this.loanCriteria != null &&\r\n this.loanCriteria.DealClients != null &&\r\n this.loanCriteria.DealClients.length > 0 &&\r\n this.loanCriteria.DealClients[0]?.Client != null &&\r\n this.loanCriteria.DealClients[0].Client.Email.length > 0\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n //This is used in shortlisting pdf\r\n prepareDataForShortlistPdf() {\r\n this.loanCriteria.ComparisonList = this.comparisonList.filter(\r\n (cl) =>\r\n cl.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n cl.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n }\r\n\r\n getRegionByPostcode() {\r\n if (\r\n this.loanCriteria.PostcodeSearchString &&\r\n this.loanCriteria.PostcodeSearchString.replace(\" \", \"\").length >= 2\r\n ) {\r\n if (\r\n this.dealService.isValidPostcodeString(\r\n this.loanCriteria.PostcodeSearchString,\r\n )\r\n ) {\r\n this.showPostcodeErrorMessage = false;\r\n this.isPostcodeChange = true;\r\n this.updateSearchViaSlider();\r\n } else {\r\n this.postcodeErrorMsg =\r\n \"At least one letter and one number must be entered e.g. SW1.\";\r\n this.showPostcodeErrorMessage = true;\r\n }\r\n }\r\n }\r\n\r\n getOrganisationAndBrokerDetails() {\r\n this.loadingData = true;\r\n if (!this.isLoggedInUser && !this.isAdmin && !this.isBroker) {\r\n this.loadingData = true;\r\n this.organisationService\r\n .getOrganisationAndBrokerByDealId(this.loanCriteria.Id)\r\n .then((response) => {\r\n if (response && response.Organisation != null) {\r\n this.brokerageOrg = response.Organisation;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n\r\n sortByField(field) {\r\n this.loanCriteria.SortBy = field;\r\n this.updateCriteriaAndGetResults(false, false);\r\n this.showSortBy = !this.showSortBy;\r\n }\r\n\r\n sortSummaryResults() {\r\n switch (this.loanCriteria.SortBy) {\r\n case SortByEnum.TrueMonthlyCost:\r\n this.summarySearchResults.sort(\r\n (a, b) => a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.NetLoanSize:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n b.NetLoan - a.NetLoan || a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.LenderCosts:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.LenderCosts - b.LenderCosts ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.LenderName:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.LenderName.localeCompare(b.LenderName) ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.InterestRate:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.AnnualInterest - b.AnnualInterest ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.ArrangementFee:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.ArrangementFee - b.ArrangementFee ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.DepositEquity:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.EquityOrDeposit - b.EquityOrDeposit ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n default:\r\n this.summarySearchResults.sort((a, b) => {\r\n if (a.NetLoan < b.NetLoan) return 1;\r\n if (a.NetLoan > b.NetLoan) return -1;\r\n\r\n if (a.TrueMonthlyCost > b.TrueMonthlyCost) return 1;\r\n if (a.TrueMonthlyCost < b.TrueMonthlyCost) return -1;\r\n\r\n return 0;\r\n });\r\n this.loanCriteria.SortBy = SortByEnum.NetLoanSize;\r\n }\r\n\r\n for (var i = 0; i < this.summarySearchResults.length; i++) {\r\n this.summarySearchResults[i].SelectedRowNumber = i + 1;\r\n }\r\n }\r\n\r\n isFieldZero(fieldName) {\r\n if (this.loanCriteria) {\r\n const fieldValue = this.loanCriteria[fieldName];\r\n if (fieldValue == null || fieldValue === \"0\" || fieldValue === 0) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n submitLenderReferral() {\r\n this.loadingData = true;\r\n this.lenderReferralData.DealId = this.loanCriteria.Id;\r\n this.dealClientService\r\n .submitLenderReferral(this.lenderReferralData)\r\n .then((response) => {\r\n if (response) {\r\n this.displayMsg = \"Your referral has been submitted.\";\r\n this.showMsg = true;\r\n this.isLenderReferredSearch = true;\r\n } else {\r\n this.displayMsg = \"Error while making a referral, please try later.\";\r\n this.showMsg = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n this.lenderReferralData = null;\r\n sessionStorage.removeItem(\"lenderReferralData\");\r\n });\r\n }\r\n\r\n showBasedOnMainResidence() {\r\n return this.dealService.showBasedOnMainResidence(this.loanCriteria);\r\n }\r\n\r\n reloadPage() {\r\n if (this.reloadSearch) {\r\n window.location.reload();\r\n }\r\n }\r\n\r\n openRegisterModal() {\r\n\r\n this.showRegisterModal = true;\r\n\r\n }\r\n\r\n onEditSearchNameClick() {\r\n this.toggleEditSearchName = !this.toggleEditSearchName;\r\n }\r\n\r\n\r\n onSortbyClick() {\r\n //event.stopPropagation();\r\n this.closeFilterOptions();\r\n this.closeExportDropdown();\r\n this.showSortBy = !this.showSortBy;\r\n }\r\n\r\n onFilterClick() {\r\n // event.stopPropagation();\r\n this.closeSortByDropdown();\r\n this.closeExportDropdown();\r\n this.showFilters = !this.showFilters;\r\n }\r\n\r\n onExportClick() {\r\n this.prepareDataForShortlistPdf();\r\n this.closeSortByDropdown();\r\n this.closeFilterOptions();\r\n this.showExportOptions = !this.showExportOptions;\r\n }\r\n\r\n getSelectedSortByOptionText() {\r\n if (this.loanCriteria) {\r\n switch (this.loanCriteria.SortBy) {\r\n case SortByEnum.TrueMonthlyCost:\r\n return \"True Monthly Cost\";\r\n case SortByEnum.NetLoanSize:\r\n return \"Net Loan Size\";\r\n case SortByEnum.LenderCosts:\r\n return \"Lender Costs (Est.)\";\r\n case SortByEnum.LenderName:\r\n return \"Lender Name (A-Z)\";\r\n case SortByEnum.InterestRate:\r\n return \"Interest Rate\";\r\n case SortByEnum.ArrangementFee:\r\n return \"Arrangement Fee\";\r\n case SortByEnum.DepositEquity:\r\n return \"Est. Deposit/Equity\";\r\n case SortByEnum.ROCE:\r\n return \"ROCE\";\r\n default:\r\n return \"\";\r\n }\r\n } else {\r\n return \"\";\r\n }\r\n }\r\n\r\n createAccount() {\r\n this.dataLoading = true;\r\n this.enterpriseClient.OrgUniqueRef = this.brokerageOrg.UniqueRef;\r\n this.$user\r\n .registerEnterpriseUserAndSaveShortlisteResults(this.enterpriseClient, this.getDealLenders(this.comparisonList))\r\n .then((user) => {\r\n // clean up session storage\r\n if (window.self == window.top) {\r\n sessionStorage.removeItem(\"clientId\");\r\n sessionStorage.removeItem(\"userRole\");\r\n } else {\r\n this.organisationService.sendDataToParent(\"clientId\", \"\");\r\n this.organisationService.sendDataToParent(\"userRole\", \"\");\r\n }\r\n this.login(\"ENTERPRISE-LEAD-REGISTERED-FROM-RESULTS-PAGE\", EventLogEnum.EnterpriseUserRegistration);\r\n })\r\n .catch((response) => {\r\n this.error = \"Error while registering an account, please try again later.\";\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n login(eventIdentifier: string = \"ENTERPRISE-CONTACT-LOGGEDIN-FROM-RESULTS-PAGE\", eventType: EventLogEnum = EventLogEnum.EnterpriseUserLogin) {\r\n this.dataLoading = true;\r\n if (!this.$cookies.get(\"access_token\")) {\r\n this.$auth\r\n .login(\r\n this.enterpriseClient.UserName,\r\n this.enterpriseClient.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n this.error =\"\";\r\n let expiry: Date = response;\r\n\r\n this.$user.getcurentuserrecord().then((response) => {\r\n this.eventLogService.logEvent(\r\n eventIdentifier,\r\n eventType,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n \"\",\r\n \"\",\r\n this.loanCriteria.DealClients[0]?.Client.Id?.toString()\r\n );\r\n\r\n (this.$rootScope as any).currentUser = response;\r\n this.$cookies.put(\"user_firstname\", response.FirstName, {\r\n expires: expiry,\r\n });\r\n (this.$rootScope as any).selectedUser = response;\r\n this.$rootScope.$broadcast(\"login\"); //tell everyone you have logged in\r\n if (eventType == EventLogEnum.EnterpriseUserRegistration) sessionStorage.setItem('showConfirmClientPhoneNo', 'true');\r\n this.$location.path(`/bridgingresults/${this.loanCriteria.Id}`);\r\n });\r\n }).catch((response) => {\r\n this.isLoginError = true;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n onClickLogin() {\r\n this.saveShortlistedLenders();\r\n this.login();\r\n }\r\n\r\n saveShortlistedLenders() {\r\n var shortlistDealLenders = this.getDealLenders(this.comparisonList);\r\n this.dealLenderService\r\n .updateShortlistedLenders(shortlistDealLenders)\r\n .then((response) => { });\r\n }\r\n\r\n\r\n returnShortlistedDealLenderStatusText(item: BridgingLenderResultSummaryDTO) {\r\n if (this.checkDeletedLender(item.LenderID.toString(), item.ProductID.toString())) {\r\n return \"Previously Deleted\";\r\n }\r\n\r\n if (item.IsDealLender && (this.loanCriteria.Status != CaseStatusEnum.Search && this.loanCriteria.Status != CaseStatusEnum.NewCase && this.loanCriteria.Status != CaseStatusEnum.ReadyToSubmit)) {\r\n\r\n switch (item.DealLenderStatus) {\r\n case CaseLenderStateEnum.Shortlisted:\r\n return \"Shortlisted\";\r\n case CaseLenderStateEnum.Received:\r\n return \"Awaiting DIP\";\r\n case CaseLenderStateEnum.Offered:\r\n return \"DIP Received\";\r\n case CaseLenderStateEnum.Rejected:\r\n return \"Lender Rejected\";\r\n case CaseLenderStateEnum.Withdrawn:\r\n return \"Lender Withdrawn\";\r\n default:\r\n break\r\n }\r\n }\r\n }\r\n\r\n isProceedButtonDisabled(): boolean {\r\n if (this.validateAllLendersUnique(this.comparisonList) == false) {\r\n return true;\r\n }\r\n\r\n const validLenders = this.comparisonList?.filter(\r\n (item) =>\r\n item.DealLenderStatus !== CaseLenderStateEnum.Rejected &&\r\n item.DealLenderStatus !== CaseLenderStateEnum.Withdrawn\r\n ) || [];\r\n \r\n if (\r\n !validLenders ||\r\n validLenders.length < 1 ||\r\n validLenders.length > this.noOfShortlistAllowed ||\r\n this.isProceedClicked == true\r\n ) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n onSaveClick() {\r\n if (this.isAssigned) {\r\n this.isSaveorSaveAsClicked = true;\r\n this.register(false, this.productResultList);\r\n } else {\r\n this.showShareSearchModal();\r\n }\r\n }\r\n\r\n getProductLastVerifiedDates(productIds: number[]) {\r\n this.productService.getLastVerifiedDates(productIds).then((response) => {\r\n productIds.forEach(id => {\r\n if (response[id] != null) {\r\n this.productLastVerifiedDates[id] = this.formatDate(response[id]);\r\n }\r\n })\r\n });\r\n }\r\n\r\n formatDate = (dateString) => {\r\n const date = new Date(dateString);\r\n return date.toLocaleDateString('en-GB');\r\n };\r\n\r\n\r\n validateAllLendersUnique(\r\n comparisonList: BridgingLenderResultSummaryDTO[],\r\n ): boolean {\r\n\r\n if (this.isShortlistingMore) {\r\n const matchingItems = this.HiddenDealLenderList.filter(item1 =>\r\n this.comparisonList.some(item2 => item1.LenderId === item2.LenderID)\r\n );\r\n\r\n if (matchingItems.length > 0) return false;\r\n\r\n const numberOfUniqueLenderIds: number = new Set(\r\n this.comparisonList.map((item) => item.LenderID),\r\n ).size;\r\n\r\n return numberOfUniqueLenderIds == this.comparisonList.length;\r\n }\r\n\r\n return true;\r\n\r\n }\r\n\r\n /**Closes all context menus */\r\n closeContextMenus() {\r\n var myevent = event;\r\n this.closeFilterOptions();\r\n this.closeSortByDropdown();\r\n }\r\n\r\n closeFilterOptions() {\r\n this.showFilters = false;\r\n }\r\n\r\n closeSortByDropdown() {\r\n this.showSortBy = false;\r\n }\r\n\r\n closeExportDropdown() {\r\n this.showExportOptions = false;\r\n }\r\n\r\n goToNewSearch() {\r\n this.sharedDataService.cleanLenderReferralSessionStorage();\r\n // If the current user is a broker and doesn't have a subscription then don't allow them to create a new search\r\n if (this.isBroker && !this.selectedUser.HasActiveSubscription) {\r\n return;\r\n }\r\n\r\n if (!this.loadingData) {\r\n (this.$rootScope as any).loanCriteria = null;\r\n\r\n this.$location.path(\"/allloans\");\r\n }\r\n }\r\n\r\n updateClientContactInfoAndNotifyBroker(){\r\n if(this.loanCriteria !=null && this.loanCriteria.DealClients != null){\r\n this.dealClientService.UpdateClientContactInfoAndNotifyBroker(this.clientUpdatedContact, this.loanCriteria?.Id,this.loanCriteria.DealClients[0].Client.Id).then((response) => {\r\n this.showClientPhoneNumberConfirmationModal = false;\r\n this.sliderShown = true;\r\n }).catch((response) => {\r\n this.error = \"There was an error updating the contact. Please try again later.\"\r\n })\r\n .finally(() => {\r\n sessionStorage.removeItem('showConfirmClientPhoneNo');\r\n });\r\n } else {\r\n sessionStorage.removeItem('showConfirmClientPhoneNo');\r\n this.showClientPhoneNumberConfirmationModal = false;\r\n this.sliderShown = true;\r\n }\r\n }\r\n\r\n getOrgName(){\r\n if(this.orgName){\r\n return this.orgName.replace(/_/g, \" \");\r\n }\r\n return \"\";\r\n }\r\n\r\n /**Sends an email to the email address for the user to reset their password */\r\n sendResetPasswordEmail() {\r\n this.loadingData = true;\r\n this.$auth\r\n .resetPassword(this.enterpriseClient.Email)\r\n .then((response) => {\r\n this.isLoginError = false;\r\n this.isResetPasswordSubmitted = true;\r\n this.registrationLoginError = null;\r\n })\r\n .catch((error) => {\r\n this.registrationLoginError = \"There was an error sending the password reset email. Please try again later.\";\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n getRequiredRolesOptions(){\r\n return this.dealService.getRequiredRolesOptions();\r\n }\r\n\r\n validateAccessAndRedirect(){\r\n //Do not allow the connect user to access the deal\r\n if(this.loanCriteria.IsReferredToConnect && this.selectedUser.IsConnectUser){\r\n this.$location.path(`/bridgingcasedashboard/${this.loanCriteria.Id}`)\r\n }else{\r\n if(this.loanCriteria.Status != CaseStatusEnum.NewCase && this.loanCriteria.Status != CaseStatusEnum.Search && !this.isShortlistingMore){\r\n this.dealLenderService\r\n .fetchDealLendersByDealId( this.loanCriteria.Id)\r\n .then((results) => {\r\n if(results && results.filter(dl => !dl.IsDeleted && dl.Status != CaseLenderStateEnum.Withdrawn && dl.Status != CaseLenderStateEnum.Rejected).length >= 5 && results.filter(dl => !dl.IsDeleted && dl.IsBidAccepted)){\r\n if (this.isAdmin || this.isBroker) {\r\n this.$location.path(\"/dealforum/\" + this.loanCriteria.Id)\r\n }\r\n else {\r\n this.$location.path(`/userdashboard`)\r\n }\r\n }else{\r\n this.$location.path(`/bridgingshortlistmore/${this.loanCriteria.Id}`)\r\n }\r\n })\r\n }\r\n }\r\n }\r\n}\r\n","export const enum BuildProcurementTypeEnum {\r\n DesignAndBuildContract = 1,\r\n TraditionalContract = 2,\r\n SelfManaged = 3,\r\n}\r\n","export const enum ExternalLinksEnum {\r\n Misc = 0,\r\n Youtube = 1,\r\n}\r\n","export const enum PlanningResponsibilityEnum {\r\n Borrower = 1,\r\n PreviousOwner = 2,\r\n SomebodyElse = 3,\r\n NA = 4,\r\n}\r\n","export const enum PurchaseProcessTypeEnum {\r\n RegularPurchase = 1,\r\n Option = 2,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AppPackagePricingDTO } from \"@js/DTO/AppPackagePricingDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { CaseLenderDTO } from \"@js/DTO/CaseLenderDTO.cs.d\";\r\nimport { CaseMemberDTO } from \"@js/DTO/CaseMemberDTO.cs.d\";\r\nimport { CaseNoteDTO } from \"@js/DTO/CaseNoteDTO.cs.d\";\r\nimport { ComparablePropertyDTO } from \"@js/DTO/ComparablePropertyDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { LenderResultMinimalDTO } from \"@js/DTO/DevelopmentFinance/LenderResultMinimalDTO.cs.d\";\r\nimport { ExternalLinksDTO } from \"@js/DTO/ExternalLinksDTO.cs.d\";\r\nimport { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { LenderInfo } from \"@js/DTO/Messages/Deal/LendersInfoForSubmitToLenderMessage.cs.d\";\r\nimport { ModuleAppFeatureDTO } from \"@js/DTO/ModuleAppFeatureDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { ProductDTO } from \"@js/DTO/ProductDTO.cs.d\";\r\nimport { TeamMemberDTO } from \"@js/DTO/TeamMemberDTO.cs.d\";\r\nimport { BuildProcurementTypeEnum } from \"@js/models/enum/BuildProcurementTypeEnum.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { EventLogEnum } from \"@js/models/enum/EventLogEnum.cs.d\";\r\nimport { ExitStrategyEnum } from \"@js/models/enum/ExitStrategyEnum.cs.d\";\r\nimport { ExternalLinksEnum } from \"@js/models/enum/ExternalLinksEnum.cs.d\";\r\nimport { LenderProductTypeEnum } from \"@js/models/enum/LenderProductTypeEnum.cs.d\";\r\nimport { LicenseMasterStatusEnum } from \"@js/models/enum/LicenseMasterStatusEnum.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { PlanningPermissionTypeEnum } from \"@js/models/enum/PlanningPermissionTypeEnum.cs.d\";\r\nimport { PlanningResponsibilityEnum } from \"@js/models/enum/PlanningResponsibilityEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { PurchaseProcessTypeEnum } from \"@js/models/enum/PurchaseProcessTypeEnum.cs.d\";\r\nimport { AccountService } from \"@js/services/AccountService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseLenderService } from \"@js/services/CaseLenderService\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseNoteService } from \"@js/services/CaseNoteService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { ComparablePropertyService } from \"@js/services/ComparablePropertyService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { ExternalLinksService } from \"@js/services/ExternalLinksService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { InviteService } from \"@js/services/InviteService\";\r\nimport { LenderResultService } from \"@js/services/LenderResultService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { TeamMemberService } from \"@js/services/TeamMemberService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport angular from \"angular\";\r\n\r\nexport class CaseController {\r\n dataLoading: boolean = false;\r\n\r\n assistanceSlider: boolean = false;\r\n totalLender: number = 0;\r\n\r\n selectedSection: string;\r\n\r\n thisModuleSection: ModuleEnum;\r\n fileUpload: FileAttachmentDTO[];\r\n fileUploadPlaning: FileAttachmentDTO[];\r\n fileUploadTeam: FileAttachmentDTO[];\r\n fileUploadProperties: FileAttachmentDTO[];\r\n selectedProduct: ProductDTO;\r\n selectedResult: LenderResultMinimalDTO;\r\n total: number = 0;\r\n openModal: boolean = false;\r\n objects: CaseDTO[]; //TODO JLH rename this to something meaningful but look into what it is used for\r\n case: CaseDTO;\r\n toggleEditSearchName: boolean = false;\r\n orgName: string;\r\n orgId: number;\r\n org: OrganisationDTO;\r\n fileNamePrefix: string = \"Brickflow\";\r\n\r\n caseLenders: CaseLenderDTO[];\r\n // indicates whether a bid has been accepted on the case\r\n hasBidAccepted: boolean = false;\r\n selectedCaseLender: CaseLenderDTO;\r\n\r\n ShowProceed: boolean = false;\r\n showEdit: boolean = false;\r\n confirmationDelete: boolean = false;\r\n\r\n uploadingFiles: FileUploadProgressDTO[];\r\n renamingFile: FileAttachmentDTO;\r\n currentUser: ApplicationUserDTO;\r\n\r\n //to populate the full login details\r\n showSetPasswordModal: boolean = false;\r\n verifyNewPassword: string;\r\n passwordSetSuccess: boolean = false;\r\n registrationForm: FormData;\r\n modal: ng.IFormController;\r\n\r\n newNote: CaseNoteDTO;\r\n newExternalLink: ExternalLinksDTO;\r\n newTeamMember: TeamMemberDTO;\r\n editTeamMember: TeamMemberDTO;\r\n tempTeamMember: TeamMemberDTO;\r\n confirmDeleteTeamMember: TeamMemberDTO;\r\n newComparable: ComparablePropertyDTO;\r\n editComparable: ComparablePropertyDTO;\r\n tempComparable: ComparablePropertyDTO;\r\n confirmDeleteComparable: ComparablePropertyDTO;\r\n appName: string;\r\n\r\n clickRequestReview: boolean = false;\r\n\r\n //check Payment Status and show modal\r\n paymentStatus: string;\r\n\r\n IsOnlyBroker: boolean = false;\r\n isAdminBroker: boolean = false;\r\n isBroker: boolean = false;\r\n isAdmin: boolean = false;\r\n isLender: boolean = false;\r\n isClient: boolean = false;\r\n showVideo: boolean = false;\r\n showShare: boolean = false;\r\n shareContext: number = null;\r\n shareSuplId: number = null;\r\n shareNote: string;\r\n userFirstName: string;\r\n showAdd: boolean = false;\r\n showDelete: boolean = false;\r\n showReject: boolean = false;\r\n showWithdraw: boolean = false;\r\n showStatusMessage: boolean = false;\r\n isCaseMember: boolean = false;\r\n redactSensitiveInfo: boolean = false;\r\n invalidEmail: boolean = false;\r\n\r\n caseForm: ng.IFormController;\r\n externalLinkForm: ng.IFormController;\r\n teamMemberForm: ng.IFormController;\r\n editTeamMemberForm: ng.IFormController;\r\n comparableForm: ng.IFormController;\r\n editComparableForm: ng.IFormController;\r\n planningForm: ng.IFormController;\r\n shareForm: ng.IFormController;\r\n lenderDetailsForm: ng.IFormController;\r\n\r\n showExport: boolean = false;\r\n //case overview\r\n caseOverviewTempBackup: string;\r\n //planning\r\n planningURLTempBackup: string;\r\n planningLocalAuthorityTempBackup: string;\r\n planningReferenceTempBackup: string;\r\n planningDescriptionTempBackup: string;\r\n lenderDetails: CaseLenderDTO;\r\n\r\n caseMembersWithAccess: CaseMemberDTO[];\r\n selectedClientToShareWith: CaseMemberDTO;\r\n\r\n isInActiveLender: boolean = false;\r\n brokerCommission: number;\r\n caseBrokerUser: ApplicationUserDTO;\r\n\r\n //carousel\r\n carouselData: string[] = [\r\n \"Brickflow is the quickest and easiest way to apply for development finance.\",\r\n \"To get a Decision in Principle (DIP) from a Lender please complete the Appraisal modules below.\",\r\n \"The Decision in Principle may be different to the estimates you saw on the results screen.\\nThe Decision in Principle is an accurate quote directly from the lender. \",\r\n \"The lender is basing their Decision in Principle only on the information provided below in the Appraisal,\\nso be sure to really showcase you and your project.\",\r\n \"The Decision in Principle should be provided to you within 48 - 72 hours of you completing the Appraisal.\\nNo credit scores will be carried out to provide a Decision in Principle.\",\r\n \"The loan still needs to be approved by Credit Committee, but providing a Decision in Principle means the lender is confident in getting approval (but it's not guaranteed)\",\r\n \"Select 'Complete' against each Module once you're happy.\\nOnce all modules are complete click 'Submit to Lenders'.\",\r\n \"A Brickflow Team Member will review your Case and then when they're happy,\\nyour Case will be sent to the chosen lender(s) for review.\",\r\n \"Your Developer Profile is like a CV. It will be saved and updated as you complete loans in the platform. Complete it once and never have to do it again.\",\r\n \"When you're ready to start, click module 1 'Case Overview'\",\r\n ];\r\n carouselStep: number = 0;\r\n\r\n caseLandingSeen: boolean = true;\r\n\r\n message: boolean = false;\r\n messageContent: string;\r\n sendingMessage: boolean = false;\r\n\r\n maxNotes: number = 3;\r\n showAllNotes: boolean = false;\r\n\r\n showRequestEmailForm: boolean = false;\r\n requestMessageReason: string = \"\";\r\n enquiryTelephone: string = \"\";\r\n\r\n // Controls showing Ts & Cs when a borrower/broker submits to lenders\r\n showTsAndCs: boolean = false;\r\n showTsAndCsForm: boolean = false;\r\n showApplyTsAndCs: boolean = false;\r\n acceptTerms: boolean = false;\r\n\r\n youtubeLinkToAdd: string;\r\n currentYoutubeVideo: string = \"\";\r\n\r\n //For build costs calculation\r\n totalBuild: number;\r\n additionalBuild: number;\r\n contingencyTotal: number;\r\n totalPurchaseCostsNotOwning: number;\r\n totalPurchaseCostsOwning: number;\r\n\r\n shareholders: CaseMemberDTO;\r\n\r\n //Accordion\r\n\r\n accordionShow: boolean[] = [];\r\n\r\n //Admin viewing on behalf\r\n\r\n proxyViewer: boolean = false;\r\n\r\n selectedUser: ApplicationUserDTO;\r\n clientUsernameBeingAccessed: string;\r\n tinymceOptions: any;\r\n //Guidance\r\n guidanceCheckbox: boolean = true;\r\n tourState: any = {\r\n tourStep: 1,\r\n tourTotalSteps: 0,\r\n };\r\n tourEnabled: boolean = false;\r\n brokerOrganisations: OrganisationDTO[];\r\n brokerUsers: ApplicationUserDTO[];\r\n\r\n seeFiles: boolean = false;\r\n\r\n isLoggedInUser: boolean = false;\r\n\r\n primaryShareholder: CaseMemberDTO;\r\n brokerEmail: string;\r\n\r\n isSelected: boolean = false;\r\n selectedPaymentProduct: AppPackagePricingDTO = null;\r\n showPaymentModal: boolean = false;\r\n moduleAppFeatures: ModuleAppFeatureDTO[];\r\n moduleFeatureCount: number = 0;\r\n selecteFeatureCount: number = 0;\r\n appPackagePrices: AppPackagePricingDTO[];\r\n selectedProductList: AppPackagePricingDTO[] = [];\r\n billingFrequency: Array<{ id: number; value: string }> = [\r\n { id: 1, value: \"Monthly\" },\r\n { id: 2, value: \"Yearly\" },\r\n ];\r\n selectedBillingFrequency: number;\r\n isSubmittedToLenders: boolean = false;\r\n\r\n selectedLendersText: string = \"\";\r\n shortlistedLendersText: string = \"\";\r\n lendersDetailsForSubmittoLenders: LenderInfo[];\r\n shortListedLendersId: Number[];\r\n\r\n referrerOptions = [];\r\n locationOptions = [];\r\n\r\n hasShortlistedCaseLenders: boolean;\r\n\r\n showModuleShareConfirmation: boolean;\r\n\r\n productTypeDisplayText: string;\r\n\r\n brokerPreferredContact: string;\r\n isBrokerPhoneNumberUpdated: boolean = false;\r\n showAutofill: boolean = false;\r\n\r\n totalUnreadCaseLenderMessages: number = 0;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$rootScope\",\r\n \"CaseService\",\r\n \"DevelopmentInputService\",\r\n \"$location\",\r\n \"FileAttachmentService\",\r\n \"CaseNoteService\",\r\n \"RoleService\",\r\n \"AuthService\",\r\n \"$cookies\",\r\n \"AccountService\",\r\n \"ProductService\",\r\n \"LenderResultService\",\r\n \"ExternalLinksService\",\r\n \"$interval\",\r\n \"$q\",\r\n \"$window\",\r\n \"UserService\",\r\n \"TeamMemberService\",\r\n \"ComparablePropertyService\",\r\n \"CaseLenderService\",\r\n \"LenderService\",\r\n \"OrganisationService\",\r\n \"CaseMemberService\",\r\n \"InviteService\",\r\n \"PaymentService\",\r\n \"SelectListService\",\r\n \"EventLogService\",\r\n ];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $rootScope: ng.IRootScopeService,\r\n private caseService: CaseService,\r\n private developmentInputService: DevelopmentInputService,\r\n private $location: ng.ILocationService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private caseNoteService: CaseNoteService,\r\n private roleService: RoleService,\r\n private authService: AuthService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $accountservice: AccountService,\r\n private productService: ProductService,\r\n private $lenderresultservice: LenderResultService,\r\n private $externalLinksService: ExternalLinksService,\r\n private $interval: ng.IIntervalService,\r\n protected $q: ng.IQService,\r\n private $window: ng.IWindowService,\r\n private userService: UserService,\r\n private $teamMemberService: TeamMemberService,\r\n private comparablePropertyService: ComparablePropertyService,\r\n private caseLenderService: CaseLenderService,\r\n private $lenderService: LenderService,\r\n private organisationService: OrganisationService,\r\n private caseMemberService: CaseMemberService,\r\n private inviteService: InviteService,\r\n private $paymentService: PaymentService,\r\n private selectListService: SelectListService,\r\n private eventLogService: EventLogService,\r\n ) {\r\n if ($cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n\r\n this.userService.getUserAutofill().then((response) => {\r\n this.showAutofill = response;\r\n });\r\n }\r\n\r\n this.productTypeDisplayText = this.productService.getProductTypeDisplayText(\r\n ProductTypeEnum.Development,\r\n );\r\n\r\n sessionStorage.removeItem(\"lenderTask\");\r\n\r\n //TOUR\r\n $rootScope.$on(\"nextTour\", (event: ng.IAngularEvent) => {\r\n this.tourNext();\r\n });\r\n $rootScope.$on(\"backTour\", (event: ng.IAngularEvent) => {\r\n this.tourBack();\r\n });\r\n $rootScope.$on(\"skipTour\", (event: ng.IAngularEvent) => {\r\n this.tourSkip();\r\n });\r\n\r\n this.tinymceOptions = {\r\n content_style:\r\n \"body {color: #304b9a;font:300 13.33px Roboto,sans-serif;}\",\r\n menubar: false,\r\n height: 300,\r\n branding: false,\r\n statusbar: false,\r\n plugins: [\r\n \"advlist autolink lists link image charmap print preview anchor\",\r\n \"searchreplace visualblocks code fullscreen\",\r\n \"insertdatetime media table paste code help wordcount\",\r\n ],\r\n toolbar:\r\n \"undo redo | formatselect | \" +\r\n \"bold italic backcolor forecolor | alignleft aligncenter \" +\r\n \"alignright alignjustify | bullist numlist outdent indent | preview fullscreen |\" +\r\n \"removeformat | help\",\r\n };\r\n\r\n if ((this.$rootScope as any).acceptTerms) {\r\n this.showRequestEmailForm = false;\r\n this.requestMessageReason =\r\n \"Thank you for accepting the Decision in Principle\";\r\n this.message = true;\r\n this.messageContent =\r\n \"Once you have made the application payment you will need to review the information in the Application Details module. Once this has been completed you will be able to submit your application to the lender\";\r\n }\r\n\r\n if (this.$routeParams.PaymentStatus) {\r\n this.paymentStatus = this.$routeParams.PaymentStatus;\r\n }\r\n\r\n this.getTubeMapValue();\r\n\r\n this.checkForClient();\r\n\r\n if (this.$routeParams.CaseId) {\r\n this.dataLoading = true;\r\n\r\n this.organisationService.fetchAll().then((response) => {\r\n this.brokerOrganisations = response;\r\n });\r\n\r\n this.caseLenderService\r\n .fetchByCaseId(this.$routeParams.CaseId)\r\n .then((cls: CaseLenderDTO[]) => {\r\n this.hasShortlistedCaseLenders = cls.some(\r\n (cl) => cl.CaseLenderState == CaseLenderStateEnum.Shortlisted,\r\n );\r\n this.totalUnreadCaseLenderMessages = cls\r\n .filter((cls) => cls.TotalUnreadCaseLenderMessages != null)\r\n .reduce((a, b) => a + b.TotalUnreadCaseLenderMessages, 0);\r\n });\r\n\r\n this.caseService\r\n .fetch(this.$routeParams.CaseId)\r\n .then((response) => {\r\n\r\n // The case was a pre-existing case when the broker org became a member of Connect and therefore was archived.\r\n if (response.DevelopmentInput?.IsPreConnectArchived) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n\r\n this.case = response;\r\n this.orgId = this.case.BrokerOrganisationId;\r\n if (this.orgId) {\r\n this.organisationService.fetch(this.orgId).then((response) => {\r\n this.org = response;\r\n this.brokerCommission =\r\n this.case.CaseStatus == CaseStatusEnum.NewCase\r\n ? response.CommissionPercent\r\n : this.case.BrokerCommissionPercent;\r\n if (this.org.IsWhiteLabelled) {\r\n this.fileNamePrefix = this.org.Name.replace(/ /g, \"_\");\r\n } else {\r\n this.fileNamePrefix = \"Brickflow\";\r\n }\r\n });\r\n }\r\n\r\n if (this.case) {\r\n this.fileUpload = this.case.Attachments;\r\n // UpdateCaseState is essential to the RequiredState directive functionality\r\n //TODO JNG refactor to put within the caseservice fetch\r\n if (this.case) {\r\n ($rootScope as any).statusRequirementId = this.case.Id;\r\n\r\n this.caseService.updateCaseState(\r\n this.case.Id,\r\n this.case.CaseStatus,\r\n );\r\n\r\n if (this.case.CaseStatus == 0 || this.case.CaseStatus == 1) {\r\n this.caseService.updateTubeMap(CaseStatusEnum.InProgress);\r\n } else {\r\n this.caseService.updateTubeMap(this.case.CaseStatus);\r\n }\r\n\r\n this.CalcTotalBuild();\r\n\r\n if (this.case.DevelopmentInput.CI_Dev_DoYouOwnTheProperty) {\r\n this.CalcTotalPurchaseCostsOwning();\r\n } else {\r\n this.CalcTotalPurchaseCostsNotOwning();\r\n }\r\n\r\n //External links object initialisation\r\n this.newExternalLink = {\r\n CaseId: this.case.Id,\r\n LinkType: ExternalLinksEnum.Misc,\r\n Link: \"https://\",\r\n } as ExternalLinksDTO;\r\n }\r\n\r\n // doesn't use cookies to get updated subscription status\r\n this.authService.getUpdatedProfile().then((prof) => {\r\n this.currentUser = prof;\r\n this.isAdminBroker = this.currentUser.IsOrganisationAdmin;\r\n this.checkForAdmin();\r\n this.checkForBroker();\r\n this.checkForLender();\r\n this.checkIfOnlyBroker();\r\n this.checkForClient();\r\n this.updateRequestAssitanceCaseNoteMessage();\r\n //If half-registered user hasn't set a password, then prompt them to set one\r\n if (this.currentUser.TemporaryAccount === true) {\r\n this.showSetPasswordModal = true;\r\n }\r\n\r\n this.newTeamMember = {\r\n UserId: this.currentUser.Id,\r\n CaseId: this.case.Id,\r\n Website: \"https://\",\r\n } as TeamMemberDTO;\r\n this.newNote = {\r\n CaseId: this.case.Id,\r\n UserId: this.currentUser.Id,\r\n ExpandNote: false,\r\n } as CaseNoteDTO;\r\n this.newComparable = {\r\n CaseId: this.case.Id,\r\n URL: \"https://\",\r\n } as ComparablePropertyDTO;\r\n });\r\n\r\n this.clientAccountAccessCheck();\r\n } else if (\r\n (this.$rootScope as any).loginRedirectPath.includes(\r\n \"/casedashboard\",\r\n )\r\n ) {\r\n } else {\r\n // If no case is returned, this could be that the logged in user has been removed from the case\r\n // - only do this if there is a logged in user, otherwise let the routing sort out where the redirect should go\r\n if ((this.$rootScope as any).selectedUser) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n }\r\n })\r\n .catch((error) => {\r\n this.$location.path(\"/dashboard\");\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n this.updateCaseLandingSeenState();\r\n\r\n //Tour & Guidance logic\r\n let cookieTourStep = this.$cookies.get(\"tourStepPreapp\");\r\n if (cookieTourStep) {\r\n this.tourState.tourStep = cookieTourStep;\r\n }\r\n $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n this.updateGuidanceState();\r\n });\r\n this.updateGuidanceState();\r\n this.getAppName();\r\n\r\n this.getLenderCount();\r\n\r\n this.referrerOptions = this.selectListService.GetReferrerOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n }\r\n\r\n updateGuidanceState() {\r\n this.guidanceCheckbox =\r\n this.$cookies.get(\"guidance\") === \"on\" ||\r\n this.$cookies.get(\"guidance\") === undefined;\r\n\r\n // Update tour settings\r\n let tourEnabled = this.$cookies.get(\"tourEnabledPreapp\");\r\n if (\r\n (tourEnabled == \"true\" || tourEnabled === undefined) &&\r\n this.guidanceCheckbox\r\n ) {\r\n this.tourEnabled = true;\r\n } else {\r\n this.tourEnabled = false;\r\n }\r\n }\r\n\r\n getTubeMapValue() {\r\n return this.caseService.getTubeMap();\r\n }\r\n\r\n closeModal(test: number) {\r\n this.message = false;\r\n }\r\n\r\n /**\r\n * Process the Accept/Cancel Application button being clicked\r\n */\r\n acceptCancelTerms() {\r\n this.caseLenderService\r\n .applyToLender(this.selectedCaseLender.CaseId, this.selectedCaseLender.Id)\r\n .then((response) => {\r\n this.selectedCaseLender.CaseLenderState = response.CaseLenderState;\r\n this.caseLenders = this.caseLenders.filter(\r\n (lender) => lender.Id != this.selectedCaseLender.Id,\r\n );\r\n this.caseLenders.push(this.selectedCaseLender);\r\n })\r\n .finally(() => {\r\n this.messageContent =\r\n \"Thank you for submitting an application with this lender.\";\r\n this.message = true;\r\n });\r\n\r\n this.showApplyTsAndCs = false;\r\n }\r\n\r\n turnOffGuidance() {\r\n this.guidanceCheckbox = false;\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 365);\r\n this.$cookies.put(\"guidance\", \"off\", { expires: expiryDate });\r\n this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n }\r\n\r\n getGuidanceSwitchState() {\r\n if (!this.$cookies.get(\"guidance\")) {\r\n this.guidanceCheckbox = true;\r\n } else if (this.$cookies.get(\"guidance\") === \"on\") {\r\n this.guidanceCheckbox = true;\r\n } else if (this.$cookies.get(\"guidance\") === \"off\") {\r\n this.guidanceCheckbox = false;\r\n } else {\r\n this.guidanceCheckbox = true;\r\n }\r\n return this.guidanceCheckbox;\r\n }\r\n\r\n recordGuidanceCookie() {\r\n var guidanceSwitchState: string;\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 365);\r\n if (this.guidanceCheckbox == true) {\r\n guidanceSwitchState = \"on\";\r\n } else {\r\n guidanceSwitchState = \"off\";\r\n }\r\n this.$cookies.put(\"guidance\", guidanceSwitchState, { expires: expiryDate });\r\n this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n }\r\n\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n\r\n backToClientSearches(): void {\r\n (this.$rootScope as any).clientUsernameBeingViewed =\r\n this.case.DevelopmentInput.OwnerUser;\r\n this.authService.clearSelectedNavMenuAndFilterStorageData();\r\n this.go(\"/userdashboard\");\r\n }\r\n\r\n clientAccountAccessCheck(): void {\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.userService.getcurentuserrecord().then((result) => {\r\n this.selectedUser = result;\r\n\r\n this.caseMemberService\r\n .fetchByCaseId(this.$routeParams.CaseId)\r\n .then((response) => {\r\n this.shareholders = response.find(\r\n (x) => x.UserId == this.selectedUser.Id,\r\n );\r\n this.primaryShareholder = response.find((x) => x.IsPrimary == true);\r\n\r\n if (\r\n (this.selectedUser.UserName !==\r\n this.case.DevelopmentInput.OwnerUser &&\r\n !this.shareholders) ||\r\n (this.selectedUser.UserName !==\r\n this.case.DevelopmentInput.OwnerUser &&\r\n this.isAdmin)\r\n ) {\r\n this.clientUsernameBeingAccessed =\r\n this.case.DevelopmentInput.OwnerUser;\r\n }\r\n });\r\n });\r\n }\r\n }\r\n\r\n paymentStatusClose() {\r\n this.go(\"/casedashboard/\" + this.$routeParams.CaseId);\r\n this.paymentStatus = \"\";\r\n }\r\n\r\n carriageReturnCheck(event) {\r\n if (event.key === \"Enter\") {\r\n let position = event.target.selectionStart;\r\n if (this.case.CaseOverview) {\r\n this.case.CaseOverview = [\r\n this.case.CaseOverview.slice(0, position),\r\n \"\\n\",\r\n this.case.CaseOverview.slice(position),\r\n ].join(\"\");\r\n\r\n setTimeout(() => {\r\n event.target.setSelectionRange(position + 1, position + 1);\r\n }, 0);\r\n } else {\r\n this.case.CaseOverview = \"\\n\";\r\n }\r\n }\r\n }\r\n\r\n toggleAccordion(id: number) {\r\n if (!this.accordionShow[id]) {\r\n this.accordionShow[id] = true;\r\n } else {\r\n this.accordionShow[id] = !this.accordionShow[id];\r\n }\r\n }\r\n\r\n formChanged(): void {\r\n (this.$rootScope as any).formSaved = false;\r\n }\r\n checkForAdmin(): void {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isAdminUser()\r\n .then((response) => {\r\n this.isAdmin = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkForLender(): void {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isLenderUser()\r\n .then((response) => {\r\n this.isLender = response;\r\n if (this.isLender) {\r\n this.caseLenderService\r\n .fetchCaseLender(this.case.Id)\r\n .then((response) => {\r\n this.lenderDetails = response;\r\n this.isInActiveLender = response.IsLenderInActive;\r\n });\r\n } else {\r\n if (this.case.DevelopmentInput.SelectedResults.length > 0) {\r\n this.$lenderService\r\n .getSelectedLendersName(\r\n this.case.DevelopmentInput.SelectedResults,\r\n )\r\n .then((response) => {\r\n this.selectedLendersText = response.LendersName;\r\n if (this.case.CaseStatus == CaseStatusEnum.NewCase) {\r\n this.shortListedLendersId = response.LendersId;\r\n }\r\n });\r\n this.$lenderService\r\n .getShortlistedLendersName(\r\n this.case.DevelopmentInput.SelectedResults,\r\n )\r\n .then((response) => {\r\n this.shortlistedLendersText = response.LendersName;\r\n if (this.case.CaseStatus != CaseStatusEnum.NewCase) {\r\n this.shortListedLendersId = response.LendersId;\r\n }\r\n });\r\n }\r\n }\r\n this.getBrokerUsers();\r\n this.checkIfUserIsInvited();\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkIfOnlyBroker() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isBroker()\r\n .then((response) => {\r\n this.IsOnlyBroker = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkForBroker(): void {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isBrokerOrABove()\r\n .then((response) => {\r\n this.isBroker = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkForClient(): void {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isClientUser()\r\n .then((response) => {\r\n this.isClient = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n // Gets the List of brokers belonging to broker organisation for admin or broker, and broker email to client or lender.\r\n getBrokerUsers(): void {\r\n this.dataLoading = true;\r\n if ((this.isAdmin || this.isBroker) && this.case.BrokerOrganisationId) {\r\n this.userService\r\n .getAllOrganisationMembers(this.case.BrokerOrganisationId)\r\n .then((response) => {\r\n if (this.case.BrokerUserId != null) {\r\n this.caseBrokerUser = response.find(\r\n (x) => x.Id == this.case.BrokerUserId,\r\n );\r\n this.brokerPreferredContact = this.caseBrokerUser?.PhoneNumber;\r\n }\r\n this.brokerUsers = response.filter(\r\n (x) => x.SubscriptionStatus > 0 || x.IsOrganisationAdmin,\r\n );\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else if (\r\n this.case.BrokerUserId != null &&\r\n !this.isAdmin &&\r\n !this.isBroker\r\n ) {\r\n this.userService\r\n .getUserEmail(this.case.BrokerUserId)\r\n .then((response) => {\r\n this.brokerEmail = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n completeAccount() {\r\n this.currentUser.TemporaryAccount = false;\r\n this.currentUser.Roles = [];\r\n this.currentUser.Roles.push(\"Client\");\r\n if (this.currentUser.ApplicantDefinedRole == 0) {\r\n this.currentUser.NewUserEmailJourneyStarted = true;\r\n }\r\n this.userService.addUpdate(this.currentUser).then((response) => {\r\n this.passwordSetSuccess = true;\r\n });\r\n }\r\n\r\n afterSetPasswordContinue() {\r\n //User needs to be logged out and logged in again\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.authService.logout(false);\r\n }\r\n this.authService\r\n .login(\r\n this.currentUser.Email,\r\n this.currentUser.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n let expiry: Date = response;\r\n this.$cookies.put(\"user_firstname\", this.currentUser.FirstName, {\r\n expires: expiry,\r\n });\r\n });\r\n\r\n this.showSetPasswordModal = false;\r\n }\r\n\r\n saveLink(link: ExternalLinksDTO): void {\r\n this.dataLoading = true;\r\n\r\n this.$externalLinksService\r\n .addUpdate(this.newExternalLink)\r\n .then((response) => {\r\n this.case.Links.push(response);\r\n\r\n this.newExternalLink = {\r\n CaseId: this.case.Id,\r\n LinkType: ExternalLinksEnum.Misc,\r\n Link: \"https://\",\r\n } as ExternalLinksDTO;\r\n\r\n this.externalLinkForm.$setPristine();\r\n this.externalLinkForm.$setUntouched();\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n removeLink(link: ExternalLinksDTO): void {\r\n this.dataLoading = true;\r\n this.$externalLinksService\r\n .delete(link.Id)\r\n .then((response) => {\r\n let index = this.case.Links.indexOf(link);\r\n this.case.Links.splice(index, 1);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n saveTeamMember(teamMember: TeamMemberDTO): void {\r\n this.newTeamMember.Website =\r\n this.newTeamMember.Website == \"https://\"\r\n ? \"\"\r\n : this.newTeamMember.Website;\r\n this.$teamMemberService.addUpdate(this.newTeamMember).then((response) => {\r\n this.case.TeamMembers.push(response);\r\n this.newTeamMember = {\r\n CaseId: this.case.Id,\r\n UserId: this.currentUser.Id,\r\n Website: \"https://\",\r\n } as TeamMemberDTO;\r\n this.teamMemberForm.$setPristine();\r\n this.teamMemberForm.$setUntouched();\r\n this.showAdd = false;\r\n });\r\n }\r\n\r\n addTeamMemberPopUp() {\r\n if (this.teamMemberForm) {\r\n this.teamMemberForm.$setPristine();\r\n this.teamMemberForm.$setUntouched();\r\n }\r\n\r\n this.showAdd = true;\r\n }\r\n\r\n resetTeamMember() {\r\n this.teamMemberForm.$setPristine();\r\n this.teamMemberForm.$setUntouched();\r\n this.newTeamMember = {\r\n CaseId: this.case.Id,\r\n UserId: this.currentUser.Id,\r\n Website: \"https://\",\r\n } as TeamMemberDTO;\r\n this.showAdd = false;\r\n }\r\n\r\n deleteTeamMember(): void {\r\n this.$teamMemberService\r\n .delete(this.confirmDeleteTeamMember.Id)\r\n .then((response) => {\r\n let index = this.case.TeamMembers.indexOf(this.confirmDeleteTeamMember);\r\n this.case.TeamMembers.splice(index, 1);\r\n });\r\n this.confirmDeleteTeamMember = {} as TeamMemberDTO;\r\n this.showDelete = false;\r\n }\r\n\r\n updateTeamMember(teamMember: TeamMemberDTO): void {\r\n this.editTeamMember = teamMember;\r\n this.tempTeamMember = { ...this.editTeamMember };\r\n this.editTeamMember.Website = this.editTeamMember.Website\r\n ? this.editTeamMember.Website\r\n : \"https://\";\r\n this.showEdit = true;\r\n }\r\n\r\n saveUpdatedTeamMember(teamMember: TeamMemberDTO): void {\r\n this.editTeamMember.Website =\r\n this.editTeamMember.Website == \"https://\"\r\n ? \"\"\r\n : this.editTeamMember.Website;\r\n\r\n this.$teamMemberService\r\n .addUpdate(this.editTeamMember)\r\n .then((response) => {\r\n this.case.TeamMembers = this.case.TeamMembers.filter(\r\n (member) => member.Id != this.editTeamMember.Id,\r\n );\r\n this.case.TeamMembers.push(response);\r\n })\r\n .finally(() => {\r\n this.showEdit = false;\r\n });\r\n }\r\n\r\n cancelUpdateTeamMember() {\r\n this.showEdit = false;\r\n this.case.TeamMembers = this.case.TeamMembers.filter(\r\n (member) => member.Id != this.tempTeamMember.Id,\r\n );\r\n this.case.TeamMembers.push(this.tempTeamMember);\r\n }\r\n\r\n deleteConfirmTeamMember(teamMember: TeamMemberDTO) {\r\n this.showDelete = true;\r\n this.confirmDeleteTeamMember = { ...teamMember };\r\n }\r\n\r\n saveComparable(comparable: ComparablePropertyDTO): void {\r\n this.newComparable.URL =\r\n this.newComparable.URL == \"https://\" ? \"\" : this.newComparable.URL;\r\n this.comparablePropertyService\r\n .addUpdate(this.newComparable)\r\n .then((response) => {\r\n this.case.Comparables.push(response);\r\n this.newComparable = {\r\n CaseId: this.case.Id,\r\n URL: \"https://\",\r\n } as ComparablePropertyDTO;\r\n this.comparableForm.$setPristine();\r\n this.comparableForm.$setUntouched();\r\n this.showAdd = false;\r\n });\r\n }\r\n\r\n resetComparable() {\r\n this.newComparable = {\r\n CaseId: this.case.Id,\r\n URL: \"https://\",\r\n } as ComparablePropertyDTO;\r\n this.comparableForm.$setPristine();\r\n this.comparableForm.$setUntouched();\r\n this.showAdd = false;\r\n }\r\n\r\n deleteComparable(): void {\r\n this.comparablePropertyService\r\n .delete(this.confirmDeleteComparable.Id)\r\n .then((response) => {\r\n let index = this.case.Comparables.indexOf(this.confirmDeleteComparable);\r\n this.case.Comparables.splice(index, 1);\r\n });\r\n this.confirmDeleteComparable = {} as ComparablePropertyDTO;\r\n this.confirmationDelete = false;\r\n }\r\n\r\n updateComparable(comparable: ComparablePropertyDTO): void {\r\n this.editComparable = comparable;\r\n this.tempComparable = { ...this.editComparable };\r\n this.editComparable.URL = this.editComparable.URL\r\n ? this.editComparable.URL\r\n : \"https://\";\r\n this.showEdit = true;\r\n }\r\n\r\n saveUpdatedComparable(comparable: ComparablePropertyDTO): void {\r\n this.editComparable.URL =\r\n this.editComparable.URL == \"https://\" ? \"\" : this.editComparable.URL;\r\n this.comparablePropertyService\r\n .addUpdate(this.editComparable)\r\n .then((response) => {\r\n this.case.Comparables = this.case.Comparables.filter(\r\n (member) => member.Id != this.editComparable.Id,\r\n );\r\n this.case.Comparables.push(response);\r\n })\r\n .finally(() => {\r\n this.showEdit = false;\r\n });\r\n }\r\n\r\n cancelDelete() {\r\n this.confirmationDelete = false;\r\n }\r\n\r\n deleteConfirmationMessage(row) {\r\n this.confirmationDelete = true;\r\n this.confirmDeleteComparable = { ...row };\r\n }\r\n\r\n cancelUpdateComparable() {\r\n this.showEdit = false;\r\n this.case.Comparables = this.case.Comparables.filter(\r\n (member) => member.Id != this.tempComparable.Id,\r\n );\r\n this.case.Comparables.push(this.tempComparable);\r\n }\r\n\r\n rejectOrWithdrawConfirmation(rejectorwithdraw: string) {\r\n rejectorwithdraw === \"Withdraw\"\r\n ? (this.showWithdraw = true)\r\n : (this.showReject = true);\r\n }\r\n\r\n goToCaseDashboard() {\r\n this.$location.path(\"/casedashboard/\" + this.case.Id);\r\n }\r\n\r\n updateCaseLandingSeenState() {\r\n this.caseLandingSeen =\r\n this.$cookies.get(\"caseLandingDontShowAgain\") === \"yes\";\r\n }\r\n\r\n caseLandingSeenClicked() {\r\n this.caseLandingSeen = true;\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 365);\r\n this.$cookies.put(\"caseLandingDontShowAgain\", \"yes\", {\r\n expires: expiryDate,\r\n });\r\n }\r\n\r\n viewResults(loanCriteria: DevelopmentInputDTO) {\r\n this.$location.path(\r\n \"/results/\" + this.case.DevelopmentInputID + \"/\" + this.case.Id,\r\n );\r\n }\r\n\r\n CreateDeveloperExperience() {\r\n this.$location.path(\"/devexperience/\" + this.case.Id + \"/-1\");\r\n }\r\n EditDeveloperExperience() {\r\n if (this.case.DevelopmentExperienceID) {\r\n this.$location.path(\r\n \"/devexperience/\" +\r\n this.case.Id +\r\n \"/\" +\r\n this.case.DevelopmentExperienceID,\r\n );\r\n } else {\r\n this.CreateDeveloperExperience();\r\n }\r\n }\r\n\r\n EditProfiles() {\r\n if (this.case.DevelopmentExperienceID) {\r\n this.$location.path(\r\n \"/profiles/\" + this.case.Id + \"/\" + this.case.DevelopmentExperienceID,\r\n );\r\n } else {\r\n this.CreateDeveloperExperience();\r\n }\r\n }\r\n\r\n UpdateDeveloperInformation() {\r\n this.$location.path(\r\n \"/criteriaappraisal/\" +\r\n this.case.Id +\r\n \"/\" +\r\n this.case.DevelopmentInput.Id,\r\n );\r\n }\r\n\r\n EditDeveloperSchedule() {\r\n this.$location.path(\r\n \"/devschedule/\" + this.case.Id + \"/\" + this.case.DevelopmentInput.Id,\r\n );\r\n }\r\n\r\n save() {\r\n this.dataLoading = true;\r\n this.caseService\r\n .addUpdatereturnonlyid(this.case)\r\n .then((response) => {\r\n this.case.Id = response;\r\n if (!this.objects) {\r\n this.objects = [];\r\n }\r\n\r\n let matches: CaseDTO[] = this.objects.filter((value, index) => {\r\n return value.Id == response;\r\n });\r\n\r\n if (!matches || matches.length === 0) {\r\n this.objects.push(this.case);\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n doRenameSearch() {\r\n this.developmentInputService\r\n .addUpdate(this.case.DevelopmentInput)\r\n .then((response) => {\r\n this.toggleEditSearchName = false;\r\n });\r\n }\r\n\r\n saveCase(): ng.IPromise {\r\n this.dataLoading = true;\r\n let defer = this.$q.defer();\r\n this.caseService\r\n .addUpdatereturnonlyid(this.case)\r\n .then((response) => {\r\n defer.resolve(response as number);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n return defer.promise;\r\n }\r\n\r\n delete() {\r\n this.dataLoading = true;\r\n this.caseService\r\n .delete(this.case.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.case), 1);\r\n this.caseForm.$setPristine();\r\n delete this.case;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n getdevelopmentinput(id: number) {\r\n this.dataLoading = true;\r\n this.developmentInputService\r\n .fetch(id)\r\n .then((response) => {\r\n this.case.DevelopmentInput = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n //File upload\r\n\r\n //calculateFilesForThisModule() {\r\n // this.fileUploadPlaning = this.fileUpload.filter(file => file.Module === ModuleEnum.Planning);\r\n //this.fileUploadTeam = this.fileUpload.filter(file => file.Module === ModuleEnum.ProfessionalTeam);\r\n //this.fileUploadProperties = this.fileUpload.filter(file => file.Module === ModuleEnum.ComparableProperties);\r\n //}\r\n\r\n calculateTotalFiles(filter: number) {\r\n if (this.fileUpload) {\r\n this.total = this.fileUpload.filter(\r\n (item) => item.Module === filter,\r\n ).length;\r\n }\r\n return this.total;\r\n }\r\n\r\n calculateTotalFilesRemoving(filter: number) {\r\n if (this.fileUpload) {\r\n this.total = this.fileUpload.filter(\r\n (item) => item.Module != filter,\r\n ).length;\r\n }\r\n return this.total;\r\n }\r\n\r\n onFileSelect(files, moduleSelected) {\r\n var module = ModuleEnum.Case;\r\n if (moduleSelected === \"Planning\") {\r\n module = ModuleEnum.Planning;\r\n } else if (moduleSelected === \"teammember\") {\r\n module = ModuleEnum.ProfessionalTeam;\r\n } else if (moduleSelected === \"properties\") {\r\n module = ModuleEnum.ComparableProperties;\r\n } else if (moduleSelected === \"images\") {\r\n module = ModuleEnum.Images;\r\n }\r\n\r\n this.openModal = false;\r\n\r\n if (files.length > 0) {\r\n //if case has no id it must be saved first\r\n if (this.case.Id < 1) {\r\n this.dataLoading = true;\r\n\r\n this.caseService\r\n .addUpdate(this.case)\r\n .then((response) => {\r\n this.case = response;\r\n this.onFileSelect(files, module); //call itself and then exit as should now be saved so should be able to run\r\n return;\r\n })\r\n .catch((e) => { })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.openModal = false;\r\n });\r\n //return;\r\n }\r\n\r\n this.fileAttachmentService\r\n .UploadFileLstInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.case.Id,\r\n this.fileUpload,\r\n module,\r\n )\r\n .finally(() => {\r\n this.openModal = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n downloadFile(file: FileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.fileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n this.$window.open(uri);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n downloadFilesAsZip(files: FileAttachmentDTO) {\r\n var keys: string[] = [];\r\n for (var file in files) {\r\n if (files[file].FileLocation) {\r\n keys.push(files[file].FileLocation);\r\n }\r\n }\r\n this.fileAttachmentService.downloadZip(keys);\r\n }\r\n\r\n deleteFile(file: FileAttachmentDTO) {\r\n this.case.Attachments.splice(this.case.Attachments.indexOf(file), 1);\r\n this.fileAttachmentService.markasdeleted(file.Id).then((result) => { }); //remove on the server\r\n }\r\n\r\n renameFile(file: FileAttachmentDTO) {\r\n if (this.renamingFile === undefined) {\r\n // if renaming this file will dirty the case, we'll want to set it back to pristine when we're done.\r\n // this.renamingFileDirties = !$scope.caseForm.$dirty;\r\n this.renamingFile = file;\r\n } else {\r\n delete this.renamingFile;\r\n }\r\n }\r\n renamingFileComplete(file: FileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.fileAttachmentService\r\n .renameFile(file)\r\n .then((response) => {\r\n file.TempURL = response.TempURL;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n delete this.renamingFile;\r\n }\r\n\r\n renamingLinkCompleted(link: ExternalLinksDTO) {\r\n this.dataLoading = true;\r\n this.$externalLinksService\r\n .addUpdate(link)\r\n .then((response) => {\r\n link.Link = response.Link;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n delete this.renamingFile;\r\n }\r\n\r\n //TODO: this will probably need to be deleted once apply button is put on lendings page\r\n ProcessApplication() {\r\n let result = this.$location.path(\"/payment/\" + this.case.Id);\r\n\r\n if (result) {\r\n this.setApplyStatus();\r\n }\r\n\r\n this.showTsAndCsForm = true;\r\n this.showTsAndCs = true;\r\n }\r\n\r\n //TOUR\r\n\r\n tourNext(): void {\r\n this.tourState.tourStep++;\r\n this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n }\r\n tourBack(): void {\r\n this.tourState.tourStep--;\r\n this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n }\r\n\r\n tourSkip(): void {\r\n this.tourEnabled = false;\r\n this.$cookies.put(\"tourEnabledPreapp\", \"false\");\r\n this.$cookies.remove(\"tourStep\");\r\n }\r\n\r\n startTour(): void {\r\n this.tourState.tourStep = 1;\r\n this.tourState.tourTotalSteps = 0;\r\n this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n this.tourEnabled = true;\r\n this.$cookies.put(\"tourEnabledPreapp\", \"true\");\r\n }\r\n\r\n removeNote(note: CaseNoteDTO): void {\r\n this.dataLoading = true;\r\n this.caseNoteService\r\n .delete(note.Id)\r\n .then((response) => {\r\n let index = this.case.CaseNotes.indexOf(note);\r\n this.case.CaseNotes.splice(index, 1);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n saveNote(): void {\r\n this.dataLoading = true;\r\n this.caseNoteService\r\n .addUpdate(this.newNote)\r\n .then((response) => {\r\n this.case.CaseNotes.push(response);\r\n this.newNote = {\r\n CaseId: this.case.Id,\r\n UserId: this.currentUser.Id,\r\n ExpandNote: false,\r\n } as CaseNoteDTO;\r\n this.caseForm.$setPristine();\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n statusMap = [\r\n { status: 0, label: \"New Case\" },\r\n { status: 1, label: \"Pre App\" },\r\n { status: 2, label: \"Decision in Principle\" },\r\n { status: 3, label: \"App Made\" },\r\n { status: 4, label: \"Credit Approval\" },\r\n { status: 5, label: \"With Professionals\" },\r\n { status: 6, label: \"Completed\" },\r\n { status: 7, label: \"Dormant\" },\r\n { status: 9, label: \"Submitted To Lenders Pending Review\" },\r\n ];\r\n\r\n setStatus(newCaseStatus: CaseStatusEnum) {\r\n let statusText = this.statusMap.find((status) => {\r\n return status.status === newCaseStatus;\r\n });\r\n this.dataLoading = true;\r\n this.caseService\r\n .setStatusOnCase(this.case.Id, newCaseStatus)\r\n .then((statusUpdateResponse) => {\r\n this.caseService.updateTubeMap(newCaseStatus);\r\n let caseNote = {\r\n CaseId: this.case.Id,\r\n UserId: this.currentUser.Id,\r\n NoteText: \"Status changed to: \" + statusText.label,\r\n ExpandNote: false,\r\n } as CaseNoteDTO;\r\n this.caseNoteService.addUpdate(caseNote).then((caseNoteResponse) => {\r\n this.case.CaseNotes.push(caseNoteResponse);\r\n });\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n markSectionAsComplete(propertyName: string, noteText: string) {\r\n this.case[propertyName] = !this.case[propertyName];\r\n // TODO JNG this should probably not save the entire case.\r\n this.dataLoading = true;\r\n this.caseService\r\n .addUpdatereturnonlyid(this.case)\r\n .then((response) => {\r\n let caseNote = {\r\n CaseId: this.case.Id,\r\n UserId: this.currentUser.Id,\r\n NoteText:\r\n noteText +\r\n \" marked as \" +\r\n (this.case[propertyName] ? \"complete\" : \"incomplete\") +\r\n \".\",\r\n ExpandNote: false,\r\n } as CaseNoteDTO;\r\n\r\n this.caseNoteService.addUpdate(caseNote).then((caseNoteResponse) => {\r\n this.case.CaseNotes.push(caseNoteResponse);\r\n });\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n showMessage(message: string) {\r\n this.messageContent = message;\r\n }\r\n\r\n requestEmail(reason): void {\r\n this.showRequestEmailForm = true;\r\n this.requestMessageReason = reason;\r\n this.message = true;\r\n this.messageContent = \"\";\r\n }\r\n\r\n sendRequestEmail() {\r\n this.showRequestEmailForm = false;\r\n this.sendingMessage = true;\r\n this.dataLoading = true;\r\n this.$accountservice\r\n .RequestAssistanceReview(this.requestMessageReason, this.case.Id)\r\n .then((response) => {\r\n this.showMessage(\r\n `${this.appName} have been notified that you require assistance and will be in touch shortly to help.`,\r\n );\r\n\r\n let caseNote = {\r\n CaseId: this.case.Id,\r\n UserId: this.currentUser.Id,\r\n NoteText: \"You have requested \" + this.requestMessageReason + \".\",\r\n ExpandNote: false,\r\n } as CaseNoteDTO;\r\n this.caseNoteService.addUpdate(caseNote).then((caseNoteResponse) => {\r\n this.case.CaseNotes.push(caseNoteResponse);\r\n });\r\n })\r\n .catch((error) => {\r\n this.showMessage(\r\n \"Sorry, something went wrong while sending your email. Please try again.\",\r\n );\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n /** Opens the Terms and Conditions popup when the Submit to Lenders button is clicked*/\r\n showTermsAndConditionsForBorrower() {\r\n this.showApplyTsAndCs = true;\r\n this.requestMessageReason = \"a review\";\r\n this.showTsAndCs = true;\r\n }\r\n\r\n /** Request a Review button clicked */\r\n requestReview() {\r\n this.showTsAndCsForm = false;\r\n this.sendingMessage = true;\r\n this.dataLoading = true;\r\n this.requestMessageReason = \"a review\";\r\n this.caseService\r\n .requestReview(\r\n this.case.Id,\r\n this.currentUser.PhoneNumber,\r\n this.requestMessageReason,\r\n )\r\n .then((response) => {\r\n this.case.CaseStatus = response.CaseState;\r\n this.showMessage(\r\n `Thank you for accepting the terms and conditions. ${this.appName} have been notified that you require a review and will be in touch shortly to help.`,\r\n );\r\n })\r\n .catch((error) => {\r\n this.showMessage(\r\n \"Sorry, something went wrong while sending your email. Please try again.\",\r\n );\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.dataLoading = false;\r\n this.showApplyTsAndCs = false;\r\n });\r\n }\r\n\r\n sendPreAppEmail() {\r\n this.showTsAndCsForm = false;\r\n this.sendingMessage = true;\r\n this.dataLoading = true;\r\n this.caseService\r\n .SendPreAppEmail(this.case.Id)\r\n .then((response) => {\r\n this.showMessage(\r\n `${this.appName} have been notified that you have submitted your Appraisal and will be in touch shortly.`,\r\n );\r\n this.case.PreAppSubmitted = true;\r\n this.caseService.addUpdatereturnonlyid(this.case).then((response) => {\r\n let caseNote = {\r\n CaseId: this.case.Id,\r\n UserId: this.currentUser.Id,\r\n NoteText: \"Your Appraisal has been submitted.\",\r\n ExpandNote: false,\r\n } as CaseNoteDTO;\r\n\r\n this.caseNoteService.addUpdate(caseNote).then((caseNoteResponse) => {\r\n this.case.CaseNotes.push(caseNoteResponse);\r\n });\r\n });\r\n })\r\n .catch((error) => {\r\n this.showMessage(\r\n \"Sorry, something went wrong while sending your email. Please try again.\",\r\n );\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n /** Opens the Terms and Conditions popup when the Submit to Lenders HoT button is clicked (borrower/broker) */\r\n showTermsAndConditions() {\r\n this.dataLoading = true;\r\n this.$lenderService\r\n .getShortlistedLendersInfoForSubmitToLenders(\r\n this.shortListedLendersId,\r\n LenderProductTypeEnum.DevelopmentFinance,\r\n false,\r\n )\r\n .then((response) => {\r\n this.lendersDetailsForSubmittoLenders = response;\r\n })\r\n .finally(() => {\r\n this.showTsAndCs = true;\r\n this.showTsAndCsForm = true;\r\n this.case.SubmitTsAndCs = false;\r\n this.invalidEmail = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n /** Submit button clicked (on Terms and Conditions popup) */\r\n submitToLenders() {\r\n this.showTsAndCsForm = false;\r\n this.sendingMessage = true;\r\n this.dataLoading = true;\r\n\r\n this.caseService.addUpdatereturnonlyid(this.case);\r\n\r\n if (this.case.CaseStatus == CaseStatusEnum.ReadyToReSubmit) {\r\n this.caseService\r\n .resubmitToLenders(\r\n this.case.Id,\r\n this.brokerCommission,\r\n this.lendersDetailsForSubmittoLenders,\r\n this.brokerPreferredContact,\r\n this.isBrokerPhoneNumberUpdated,\r\n )\r\n .then((response) => {\r\n this.case.CaseStatus = response.CaseState;\r\n this.showMessage(\r\n \"This case has been re-submitted to Lenders to request a Decision in Principle.\",\r\n );\r\n this.isSubmittedToLenders = true;\r\n })\r\n .catch((error) => {\r\n this.showMessage(\"Sorry, something went wrong. Please try again.\");\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.dataLoading = false;\r\n this.caseService.updateTubeMap(this.case.CaseStatus);\r\n });\r\n } else {\r\n this.caseService\r\n .submitToLenders(\r\n this.case.Id,\r\n this.brokerCommission,\r\n this.lendersDetailsForSubmittoLenders,\r\n this.brokerPreferredContact,\r\n this.isBrokerPhoneNumberUpdated,\r\n )\r\n .then((response) => {\r\n this.case.CaseStatus = response.CaseState;\r\n this.showMessage(\r\n \"You have requested a Decision in Principle from each lender.\",\r\n );\r\n this.isSubmittedToLenders = true;\r\n })\r\n .catch((error) => {\r\n this.showMessage(\"Sorry, something went wrong. Please try again.\");\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.dataLoading = false;\r\n this.caseService.updateTubeMap(this.case.CaseStatus);\r\n });\r\n }\r\n }\r\n\r\n setApplyStatus() {\r\n this.dataLoading = true;\r\n this.showStatusMessage = true;\r\n this.caseService\r\n .setApplyStatus(this.case.Id)\r\n .then((statusUpdateResponse) => {\r\n this.case.CaseStatus = statusUpdateResponse;\r\n let caseNote = {\r\n CaseId: this.case.Id,\r\n UserId: this.currentUser.Id,\r\n NoteText: \"User has moved application to app made stage\",\r\n ExpandNote: false,\r\n } as CaseNoteDTO;\r\n this.caseNoteService.addUpdate(caseNote).then((caseNoteResponse) => {\r\n this.case.CaseNotes.push(caseNoteResponse);\r\n });\r\n })\r\n .catch((error) => { })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n allFormsComplete(): boolean {\r\n if (this.case) {\r\n if (\r\n this.case.CaseOverviewComplete &&\r\n this.case.DeveloperExperienceComplete &&\r\n this.case.DevelopmentAppraisalComplete &&\r\n this.case.DevelopmentScheduleComplete\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n //case overview\r\n editCaseOverview() {\r\n //take a temp backup of what is in case overview in case they hit cancel\r\n this.caseOverviewTempBackup = this.case.CaseOverview;\r\n this.$location.path(\"/caseoverview/\" + this.case.Id);\r\n }\r\n\r\n //Planning Module\r\n editPlanning() {\r\n //take a temp backup of what is in Planning Module in case they hit cancel\r\n this.planningURLTempBackup = this.case.PlanningURL;\r\n this.planningLocalAuthorityTempBackup = this.case.PlanningLocalAuthority;\r\n this.planningReferenceTempBackup = this.case.PlanningReference;\r\n this.planningDescriptionTempBackup = this.case.PlanningDescription;\r\n this.$location.path(\"/planning/\" + this.case.Id);\r\n this.planningURLTempBackup = this.case.PlanningURL;\r\n this.planningLocalAuthorityTempBackup = this.case.PlanningLocalAuthority;\r\n this.planningReferenceTempBackup = this.case.PlanningReference;\r\n this.planningDescriptionTempBackup = this.case.PlanningDescription;\r\n this.$location.path(\"/planning/\" + this.case.Id);\r\n }\r\n\r\n //Comparables Module\r\n editComparableProperties() {\r\n this.$location.path(\"/comparableproperties/\" + this.case.Id);\r\n }\r\n\r\n editProfessionalTeam() {\r\n this.$location.path(\"/teammember/\" + this.case.Id);\r\n }\r\n\r\n returnToPreApp(saveBefore: boolean): void {\r\n if (saveBefore) {\r\n this.saveCase().then((success) => {\r\n this.caseOverviewTempBackup = this.case.CaseOverview;\r\n this.$location.path(\"/casedashboard/\" + this.case.Id);\r\n });\r\n } else {\r\n this.case.CaseOverview = this.caseOverviewTempBackup;\r\n this.$location.path(\"/casedashboard/\" + this.case.Id);\r\n }\r\n (this.$rootScope as any).formSaved = true;\r\n }\r\n\r\n returnToCase(saveBefore: boolean): void {\r\n if (saveBefore) {\r\n this.saveCase().then((success) => {\r\n this.planningURLTempBackup = this.case.PlanningURL;\r\n this.planningLocalAuthorityTempBackup =\r\n this.case.PlanningLocalAuthority;\r\n this.planningReferenceTempBackup = this.case.PlanningReference;\r\n this.planningDescriptionTempBackup = this.case.PlanningDescription;\r\n this.$location.path(\"/casedashboard/\" + this.case.Id);\r\n });\r\n } else {\r\n this.case.PlanningURL = this.planningURLTempBackup;\r\n this.case.PlanningLocalAuthority = this.planningLocalAuthorityTempBackup;\r\n this.case.PlanningReference = this.planningReferenceTempBackup;\r\n this.case.PlanningDescription = this.planningDescriptionTempBackup;\r\n this.$location.path(\"/casedashboard/\" + this.case.Id);\r\n }\r\n (this.$rootScope as any).formSaved = true;\r\n }\r\n\r\n openSendToBorrower(contextToShare: number) {\r\n this.shareContext = contextToShare;\r\n this.shareSuplId = 0;\r\n if (this.selectedUser.UserName !== this.case.DevelopmentInput.OwnerUser) {\r\n this.userFirstName = \"\";\r\n } else {\r\n this.userFirstName = this.selectedUser.FirstName;\r\n }\r\n\r\n this.constructShareNoteMessage();\r\n\r\n this.caseMemberService\r\n .fetchcasememberswithaccess(this.case.Id)\r\n .then((response: CaseMemberDTO[]) => {\r\n this.caseMembersWithAccess = response;\r\n\r\n this.showShare = true;\r\n });\r\n }\r\n\r\n sendToBorrower() {\r\n this.dataLoading = true;\r\n this.caseService\r\n .sendNoteToBorrower(\r\n this.selectedClientToShareWith.FirstName,\r\n this.selectedClientToShareWith.Surname,\r\n this.selectedClientToShareWith.Email,\r\n this.shareNote,\r\n this.case.Id,\r\n this.shareContext,\r\n this.shareSuplId,\r\n this.case.DevelopmentExperienceID,\r\n )\r\n .then((success) => {\r\n this.showShare = false;\r\n this.dataLoading = false;\r\n this.showModuleShareConfirmation = true;\r\n });\r\n }\r\n\r\n closeModuleShareConfirmationModal() {\r\n this.selectedClientToShareWith = null;\r\n this.showModuleShareConfirmation = false;\r\n }\r\n\r\n CalcTotalPurchaseCostsNotOwning(): number {\r\n var res: number = 0;\r\n if (this.case.DevelopmentInput.CI_Dev_OrigPP) {\r\n res += Number(this.case.DevelopmentInput.CI_Dev_OrigPP);\r\n }\r\n if (this.case.DevelopmentInput.CI_Dev_SDLT) {\r\n res += Number(this.case.DevelopmentInput.CI_Dev_SDLT);\r\n }\r\n if (this.case.DevelopmentInput.DI_PurchaseAgentFees) {\r\n res += Number(this.case.DevelopmentInput.DI_PurchaseAgentFees);\r\n }\r\n if (this.case.DevelopmentInput.DI_PurchaseLegalFees) {\r\n res += Number(this.case.DevelopmentInput.DI_PurchaseLegalFees);\r\n }\r\n if (this.case.DevelopmentInput.DI_PurchaseOtherFees) {\r\n res += Number(this.case.DevelopmentInput.DI_PurchaseOtherFees);\r\n }\r\n this.totalPurchaseCostsNotOwning = res;\r\n return res;\r\n }\r\n\r\n CalcTotalPurchaseCostsOwning(): number {\r\n var res: number = 0;\r\n if (this.case.DevelopmentInput.CI_Dev_OrigPP) {\r\n res += Number(this.case.DevelopmentInput.CI_Dev_OrigPP);\r\n }\r\n if (this.case.DevelopmentInput.CI_Dev_SDLT) {\r\n res += Number(this.case.DevelopmentInput.CI_Dev_SDLT);\r\n }\r\n if (this.case.DevelopmentInput.DI_PurchaseAgentFees) {\r\n res += Number(this.case.DevelopmentInput.DI_PurchaseAgentFees);\r\n }\r\n if (this.case.DevelopmentInput.DI_PurchaseLegalFees) {\r\n res += Number(this.case.DevelopmentInput.DI_PurchaseLegalFees);\r\n }\r\n if (this.case.DevelopmentInput.DI_PurchaseOtherFees) {\r\n res += Number(this.case.DevelopmentInput.DI_PurchaseOtherFees);\r\n }\r\n this.totalPurchaseCostsOwning = res;\r\n return res;\r\n }\r\n\r\n CalcTotalBuild(): number {\r\n var res: number = this.CalcAdditionalBuild();\r\n if (this.case.DevelopmentInput.CI_Dev_BuildCosts) {\r\n res += Number(this.case.DevelopmentInput.CI_Dev_BuildCosts);\r\n }\r\n var res: number = this.CalcAdditionalBuild();\r\n if (this.case && this.case.DevelopmentInput.CI_Dev_BuildCosts) {\r\n res += Number(this.case.DevelopmentInput.CI_Dev_BuildCosts);\r\n }\r\n\r\n res += this.calcContingencyCost();\r\n this.totalBuild = res;\r\n return res;\r\n }\r\n\r\n calcContingencyCost(): number {\r\n var res: number = 0;\r\n if (\r\n this.case.DevelopmentInput.CI_Dev_Contingency &&\r\n this.case.DevelopmentInput.CI_Dev_BuildCosts\r\n ) {\r\n res =\r\n this.case.DevelopmentInput.CI_Dev_Contingency *\r\n this.case.DevelopmentInput.CI_Dev_BuildCosts;\r\n this.contingencyTotal = res;\r\n return res;\r\n }\r\n return res;\r\n }\r\n\r\n CalcAdditionalBuild(): number {\r\n var res: number = 0;\r\n if (this.case.DevelopmentInput.DI_BreakDownBuildCosts) {\r\n if (this.case.DevelopmentInput.CI_Dev_ProfPlanning) {\r\n res += Number(this.case.DevelopmentInput.CI_Dev_ProfPlanning);\r\n }\r\n if (this.case.DevelopmentInput.CI_Dev_ProfQS) {\r\n res += Number(this.case.DevelopmentInput.CI_Dev_ProfQS);\r\n }\r\n if (this.case.DevelopmentInput.DI_BuildProjectManag) {\r\n res += Number(this.case.DevelopmentInput.DI_BuildProjectManag);\r\n }\r\n if (this.case.DevelopmentInput.CI_Dev_S106CIL) {\r\n res += Number(this.case.DevelopmentInput.CI_Dev_S106CIL);\r\n }\r\n if (this.case.DevelopmentInput.DI_BuildMechEng) {\r\n res += Number(this.case.DevelopmentInput.DI_BuildMechEng);\r\n }\r\n if (this.case.DevelopmentInput.DI_BuildStrucEng) {\r\n res += Number(this.case.DevelopmentInput.DI_BuildStrucEng);\r\n }\r\n if (this.case.DevelopmentInput.DI_BuildPartyWall) {\r\n res += Number(this.case.DevelopmentInput.DI_BuildPartyWall);\r\n }\r\n if (this.case.DevelopmentInput.DI_BuildLandscaping) {\r\n res += Number(this.case.DevelopmentInput.DI_BuildLandscaping);\r\n }\r\n if (this.case.DevelopmentInput.DI_BuildWarranty) {\r\n res += Number(this.case.DevelopmentInput.DI_BuildWarranty);\r\n }\r\n if (this.case.DevelopmentInput.DI_BuildDemolition) {\r\n res += Number(this.case.DevelopmentInput.DI_BuildDemolition);\r\n }\r\n if (this.case.DevelopmentInput.DI_BuildOtherCosts) {\r\n res += Number(this.case.DevelopmentInput.DI_BuildOtherCosts);\r\n }\r\n } else {\r\n if (this.case.DevelopmentInput.CI_Dev_AdditionalOngoingCosts) {\r\n res += Number(this.case.DevelopmentInput.CI_Dev_AdditionalOngoingCosts);\r\n }\r\n }\r\n this.additionalBuild = res;\r\n return res;\r\n }\r\n\r\n videotour() {\r\n this.showVideo = true;\r\n }\r\n\r\n videopause(id) {\r\n this.showVideo = false;\r\n let containerElement = document.getElementById(id);\r\n let iframe_tag = containerElement.querySelector(\"iframe\");\r\n if (iframe_tag) {\r\n let iframeSrc = iframe_tag.src;\r\n iframe_tag.src = iframeSrc;\r\n }\r\n }\r\n\r\n addTeamRoleOption(e) {\r\n this.newTeamMember.TeamRole = \"\";\r\n e.target.value = \"\";\r\n }\r\n\r\n editTeamRoleOption(e) {\r\n this.editTeamMember.TeamRole = \"\";\r\n e.target.value = \"\";\r\n }\r\n\r\n EnumToString(item: ModuleEnum) {\r\n switch (item) {\r\n case 0:\r\n return \"Case Overview\";\r\n case 1:\r\n return \"Developer Profile\";\r\n case 2:\r\n return \"Development Appraisal\";\r\n case 3:\r\n return \"Development Schedule\";\r\n case 4:\r\n return \"Planning\";\r\n case 5:\r\n return \"Professional Team\";\r\n case 6:\r\n return \"Comparable Properties\";\r\n case 7:\r\n return \"General\";\r\n case 8:\r\n return \"Track Record\";\r\n case 9:\r\n return \"Assets & Liabilities\";\r\n case 10:\r\n return \"Proof Of Income\";\r\n case 11:\r\n return \"Applicant Details\";\r\n case 12:\r\n return \"Pictures\";\r\n default:\r\n return \"General\";\r\n }\r\n }\r\n\r\n gotoLendingPage() {\r\n (this.$rootScope as any).isLender = false;\r\n this.$location.path(\"/lending/\" + this.case.Id);\r\n }\r\n\r\n checkBrokerDeal() {\r\n return this.case?.BrokerUserId != null && this.isClient ? true : false;\r\n }\r\n\r\n /* gotoPaymentPage() {\r\n this.$location.path(\"/payment/\" + this.case.Id);\r\n }*/\r\n\r\n gotoHeadsOfTermsPage() {\r\n this.$location.path(\"/headsofterm/\" + this.case.Id);\r\n }\r\n\r\n /** Approve button clicked (This functionality has been removed from the process)\r\n approve() {\r\n this.dataLoading = true;\r\n this.caseService.approve(this.case.Id).then((response) => {\r\n this.case.CaseStatus = response.CaseState;\r\n this.caseService.updateTubeMap(response.CaseState);\r\n this.showMessage(\"Your case has been approved.\");\r\n this.showStatusMessage = true;\r\n }).catch((error) => {\r\n this.showMessage(\"Sorry, something went wrong while approving your case. Please try again.\");\r\n }).finally(() => {\r\n this.dataLoading = false;\r\n });;\r\n }*/\r\n\r\n setBrokerOrganisation(value: number) {\r\n // TODO JNG this should probably not save the entire case.\r\n this.dataLoading = true;\r\n this.case.BrokerUserId = null;\r\n\r\n this.caseService\r\n .changeBrokerOrganisation(this.case.Id, this.case.BrokerOrganisationId)\r\n .then((response: CaseNoteDTO) => {\r\n //populating the users related to selected new organisation.\r\n this.getBrokerUsers();\r\n\r\n this.case.CaseNotes.push(response);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n setBrokerUser(value: string) {\r\n this.dataLoading = true;\r\n this.caseService\r\n .changeBrokerUser(this.case.Id, this.case.BrokerUserId)\r\n .then((response: CaseNoteDTO) => {\r\n this.case.CaseNotes.push(response);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n goToLending() {\r\n this.$location.path(\"/lending/\" + this.case.Id);\r\n this.caseService.setIsProceed(false);\r\n }\r\n\r\n isShareNoteFormComplete(): boolean {\r\n if (!this.selectedClientToShareWith) {\r\n return false;\r\n }\r\n\r\n if (\r\n this.shareNote == \"undefined\" ||\r\n this.shareNote == null ||\r\n this.shareNote.length == 0\r\n ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n constructShareNoteMessage() {\r\n var message: string;\r\n var messageStart: string = `Please take a look at the `;\r\n var messageEnd: string =\r\n ` section in your Smart Appraisal™ and complete as much as you can.\\n\\nIf you would like our help or want us to complete this module with you, please do give me a call on ` +\r\n this.currentUser.PhoneNumber +\r\n `.`;\r\n\r\n switch (this.shareContext) {\r\n case 1: //overview\r\n message =\r\n `Please take a look at the case overview I have started for you and add to it where you can.\\n\\nThis section provides the lender with an overview about you, your team and your project. Lenders approve just 1 in 4 applications due to poor presentation, so we need to make it as impactful as possible.\\n\\nIf you would like to call me so we can add the notes together, my number is ` +\r\n this.currentUser.PhoneNumber +\r\n `.`;\r\n break;\r\n case 2: //dev experience\r\n this.shareSuplId = this.case.DevelopmentExperienceID\r\n ? this.case.DevelopmentExperienceID\r\n : -1;\r\n message = messageStart + `ownership` + messageEnd;\r\n break;\r\n case 3: //dev appraisal\r\n this.shareSuplId = this.case.DevelopmentInput.Id;\r\n message = messageStart + `development appraisal` + messageEnd;\r\n break;\r\n case 4: //schedule\r\n this.shareSuplId = this.case.DevelopmentInput.Id;\r\n message = messageStart + `development schedule` + messageEnd;\r\n break;\r\n case 5: //files\r\n message = `Please upload the supporting documents associated with your project.\\n\\nAdding supporting documents helps lenders make quicker and more reliable decisions.`;\r\n break;\r\n case 6: //planning module\r\n this.shareSuplId = this.case.DevelopmentInput.Id;\r\n message = messageStart + `planning section` + messageEnd;\r\n break;\r\n case 7: //Professional Team\r\n this.shareSuplId = this.case.DevelopmentInput.Id;\r\n message = messageStart + `professional team` + messageEnd;\r\n break;\r\n case 8: //comparable properties module\r\n message = messageStart + `comparable properties` + messageEnd;\r\n break;\r\n case 9: //profiles module\r\n message = messageStart + `profiles` + messageEnd;\r\n break;\r\n }\r\n\r\n this.shareNote = message;\r\n }\r\n\r\n /** Process the Heads of Terms button being clicked */\r\n headsOfTermsClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"terms\");\r\n this.$location.path(\r\n \"/headsofterm/\" + this.case.Id + \"/\" + this.lenderDetails.Id,\r\n );\r\n }\r\n\r\n showAndHideExport() {\r\n this.showExport = !this.showExport;\r\n }\r\n\r\n /** Lender rejects the case*/\r\n rejectButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"reject\");\r\n this.$location.path(\r\n \"/headsofterm/\" + this.case.Id + \"/\" + this.lenderDetails.Id,\r\n );\r\n }\r\n\r\n withDrawButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"withdraw\");\r\n this.$location.path(\r\n \"/headsofterm/\" + this.case.Id + \"/\" + this.lenderDetails.Id,\r\n );\r\n }\r\n\r\n feedbackButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"feedback\");\r\n this.$location.path(\r\n \"/headsofterm/\" + this.case.Id + \"/\" + this.lenderDetails.Id,\r\n );\r\n }\r\n\r\n getAppName() {\r\n let lsd = sessionStorage.getItem(\"applicationName\");\r\n if (lsd != null) {\r\n this.appName = lsd;\r\n } else {\r\n this.appName = \"Brickflow\";\r\n }\r\n }\r\n\r\n closeModalAndGoToDasboard() {\r\n this.showTsAndCs = false;\r\n this.authService.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n closeModalAndGoToDealForum() {\r\n this.showTsAndCs = false;\r\n this.$location.path(\"/lending/\" + this.case.Id);\r\n }\r\n\r\n checkIfUserIsInvited() {\r\n //added to scope for directive\r\n this.caseService\r\n .checkIfUserIsInvited(this.currentUser.Id, this.$routeParams.CaseId)\r\n .then((isInvited: boolean) => {\r\n // if user has no active subscription (and are not a lender or admin) then they should be redirected back to the dashboard\r\n if (\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PaidUp &&\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PreCancel &&\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PaymentProcessing &&\r\n !isInvited &&\r\n !this.isAdmin &&\r\n !this.isLender\r\n ) {\r\n this.$location.path(\"/dashboard\");\r\n return;\r\n }\r\n\r\n (this.$rootScope as any).isInvitedToCase = isInvited;\r\n if (isInvited) {\r\n this.caseMemberService\r\n .fetchByCaseId(this.$routeParams.CaseId)\r\n .then((response) => {\r\n if (response != null && response.length > 0) {\r\n var currentShareholder = response.find(\r\n (x) => x.UserId == this.currentUser.Id,\r\n );\r\n\r\n if (\r\n currentShareholder != null &&\r\n currentShareholder.AccessLevel == CaseAccessLevelEnum.ReadOnly\r\n ) {\r\n (this.$rootScope as any).isInvitedAndHasReadonlyAccess = true;\r\n }\r\n }\r\n this.$rootScope.$broadcast(\"invitedStatusChange\");\r\n });\r\n } else {\r\n this.$rootScope.$broadcast(\"invitedStatusChange\");\r\n }\r\n });\r\n }\r\n\r\n getLenderCount() {\r\n this.$lenderService\r\n .getTotalLenders(ProductFamilyEnum.Development)\r\n .then((result) => {\r\n this.totalLender = result;\r\n });\r\n }\r\n\r\n closeConfirmationModal() {\r\n if (this.isSubmittedToLenders) {\r\n window.location.reload();\r\n }\r\n this.showTsAndCs = false;\r\n }\r\n\r\n getSelectedLenderName() {\r\n if (\r\n this.isBroker &&\r\n this.case.DevelopmentInput &&\r\n this.case.DevelopmentInput.SelectedResults.length == 1\r\n ) {\r\n this.productService\r\n .fetch(this.case.DevelopmentInput.SelectedResults[0].ProductId)\r\n .then((product: ProductDTO) => {\r\n this.selectedLendersText = product.LenderName;\r\n });\r\n }\r\n }\r\n\r\n redactInfo() {\r\n this.eventLogService.logEvent(\r\n \"EXPORTCASEPDFCLICKED\",\r\n EventLogEnum.Export,\r\n ProductTypeEnum.Development,\r\n this.case.Id,\r\n );\r\n if (this.isClient) {\r\n this.redactSensitiveInfo = true;\r\n }\r\n }\r\n\r\n autoFillComparable(save: boolean = true) {\r\n this.newTeamMember;\r\n this.newComparable = {\r\n CaseId: this.case.Id,\r\n URL: \"https://www.rightmove.co.uk/properties/118409864#/?channel=RES_BUY\",\r\n PropType: \"4 bed detached house\",\r\n Value: 1100000,\r\n IsGoodComparable: true,\r\n Comments:\r\n \"It is a very similar spec and layout to our property and is in the same side of the road - south-facing\",\r\n } as ComparablePropertyDTO;\r\n\r\n if (save) {\r\n this.saveComparable(this.newComparable);\r\n } else {\r\n this.case.Comparables.push(this.newComparable);\r\n }\r\n\r\n this.newComparable = {\r\n CaseId: this.case.Id,\r\n URL: \"https://www.rightmove.co.uk/properties/119098043#/?channel=RES_BUY\",\r\n PropType: \"4 bed detached house\",\r\n Value: 1510000,\r\n IsGoodComparable: true,\r\n Comments: \"Similar property - different street\",\r\n } as ComparablePropertyDTO;\r\n\r\n if (save) {\r\n this.saveComparable(this.newComparable);\r\n } else {\r\n this.case.Comparables.push(this.newComparable);\r\n }\r\n }\r\n\r\n autoFillTeammember(save: boolean = true) {\r\n this.newTeamMember = {\r\n UserId: this.currentUser.Id,\r\n CaseId: this.case.Id,\r\n TeamRole: \"TeamRole\",\r\n Name: \"Jane Doe\",\r\n Email: \"jane@jdarchitects.com\",\r\n Website: \"https://janedoearchitects.com/\",\r\n WorkedWithBefore: true,\r\n PreviousProjects: \"Worked with them on our project in Soho Square\",\r\n } as TeamMemberDTO;\r\n\r\n if (save) {\r\n this.saveTeamMember(this.newTeamMember);\r\n } else {\r\n this.case.TeamMembers.push(this.newTeamMember);\r\n }\r\n\r\n this.newTeamMember = {\r\n UserId: this.currentUser.Id,\r\n CaseId: this.case.Id,\r\n TeamRole: \"Main Contractor \",\r\n Name: \"JS Build & Design\",\r\n Email: \"JS Build & Design\",\r\n Website: \"https://jsbuildanddesign.com/\",\r\n WorkedWithBefore: true,\r\n PreviousProjects: \"https://jsbuildanddesign.com/\",\r\n } as TeamMemberDTO;\r\n\r\n if (save) {\r\n this.saveTeamMember(this.newTeamMember);\r\n } else {\r\n this.case.TeamMembers.push(this.newTeamMember);\r\n }\r\n }\r\n\r\n autofillCase() {\r\n this.autoFillComparable(false);\r\n this.autoFillTeammember(false);\r\n this.case.PurchaseProcessType = PurchaseProcessTypeEnum.RegularPurchase;\r\n this.case.PlanningPermissionType =\r\n PlanningPermissionTypeEnum.DetailedPlanning;\r\n this.case.PlanningResponsibility = PlanningResponsibilityEnum.Borrower;\r\n this.case.PlanningDescription =\r\n \"We purchased the site with outline planning 6 months ago, with a bridging loan.We havenow dealt with all reserved matters, and have detailed planning permission for 26x 3 & 4 bed houses.\";\r\n this.case.SiteDescriptionOnCompletion =\r\n \"The site will be bare land at completion.\";\r\n this.case.BuildProcurementType = BuildProcurementTypeEnum.SelfManaged;\r\n this.case.BuildProcurementDescription =\r\n \"We are managing the build ourselves and will tender the individual packages. We have worked this way on 3x previous personal projects. Prior to that one of our shareholders worked as a PM for 10 years at a regional house builder, managing projects of up to 150 houses. \";\r\n this.case.DepositDescription =\r\n \"50% of the deposit will come from the shareholders and 50% will come from investors. The investors are family and friends and their investment will be secured as a 2nd charge.\";\r\n this.case.GuaranteeDescription = \"This is the dummy text\";\r\n this.case.DevelopmentInput.CI_Dev_ExitStrategy =\r\n ExitStrategyEnum.PartSalePartRefinance;\r\n this.case.HasSetCompletionDate = true;\r\n let maxDate = Date.now();\r\n const timestamp = Math.floor(Math.random() * maxDate);\r\n this.case.CompletionDate = new Date(timestamp);\r\n this.case.DevelopmentInput.SearchPreferenceLoanSize = 1;\r\n this.case.DevelopmentInput.SearchPreferencePricing = 2;\r\n this.case.DevelopmentInput.SearchPreferenceCompletionSpeed = 3;\r\n this.case.DevelopmentInput.SearchPreferenceCustomerService = 4;\r\n this.case.DevelopmentInput.HowManyHouses = 2;\r\n this.caseService.autofillCase(this.case).then((response) => {\r\n window.location.reload();\r\n });\r\n }\r\n\r\n getNoteText(text: string) {\r\n if (this.isClient && text.startsWith(\"Project submitted to lenders\")) {\r\n return \"Project submitted to lenders\";\r\n } else {\r\n return text;\r\n }\r\n }\r\n\r\n updateRequestAssitanceCaseNoteMessage() {\r\n if (this.case?.CaseNotes != null && this.currentUser != null) {\r\n this.case.CaseNotes = this.case.CaseNotes.map((d) => {\r\n if (\r\n d.UserId != this.currentUser.Id &&\r\n (d.NoteText == \"Your have requested for assistance.\" ||\r\n d.NoteText == \"You have requested assistance.\")\r\n ) {\r\n return { ...d, NoteText: `${d.UserName} requested assistance.` };\r\n }\r\n return d;\r\n });\r\n }\r\n }\r\n\r\n closeSubmitToLenderModal() {\r\n this.showTsAndCs = false;\r\n this.brokerCommission =\r\n this.case.CaseStatus == CaseStatusEnum.NewCase\r\n ? this.org?.CommissionPercent\r\n : this.case.BrokerCommissionPercent;\r\n this.brokerPreferredContact =\r\n this.case.CaseStatus == CaseStatusEnum.NewCase\r\n ? this.caseBrokerUser?.PhoneNumber\r\n : this.case.BrokerPhoneNumber;\r\n this.isBrokerPhoneNumberUpdated = false;\r\n }\r\n\r\n validateEmails() {\r\n this.invalidEmail = false;\r\n\r\n angular.forEach(\r\n this.lendersDetailsForSubmittoLenders,\r\n (lenderdetails, index) => {\r\n var emailField = this.lenderDetailsForm[\"email\" + index];\r\n\r\n if (emailField && emailField.$invalid) {\r\n this.invalidEmail = true;\r\n }\r\n },\r\n );\r\n }\r\n}\r\n","import { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { CaseLenderDTO } from \"@js/DTO/CaseLenderDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { EventLogEnum } from \"@js/models/enum/EventLogEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { CaseLenderService } from \"@js/services/CaseLenderService\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class CaseLenderController {\r\n static $inject = [\r\n \"$routeParams\",\r\n \"LenderService\",\r\n \"$location\",\r\n \"CaseMemberService\",\r\n \"CaseService\",\r\n \"CaseLenderService\",\r\n \"RoleService\",\r\n \"UserService\",\r\n \"OrganisationService\",\r\n \"EventLogService\",\r\n \"$sce\",\r\n ];\r\n\r\n // have todays date\r\n todaysDate: Date = new Date();\r\n //To save url for Lender Logo Image\r\n lenderLogos: string[] = [];\r\n //To save the Lender Id and request Lender URL\r\n lenderId: number[] = [];\r\n // Controls showing the data loading \"spinner\"\r\n dataLoading: boolean = false;\r\n //Show lender names or Lender Generic Name\r\n showLenders: boolean = false;\r\n\r\n //get development Input Id\r\n developmentInputId: number;\r\n\r\n currentCase: CaseDTO;\r\n caseLenders: CaseLenderDTO[];\r\n // The lender the user has clicked apply/heads of terms/feedback for\r\n selectedCaseLender: CaseLenderDTO;\r\n // Controls showing the Application Terms and Conditions modal\r\n showApplyTsAndCs: boolean = false;\r\n // Controls showing the Preferred Lenders modal\r\n showPreferredPackagers: boolean = false;\r\n // Controls showing the application confirmation message\r\n showApplicationConfirmation: boolean = false;\r\n // Show the feedback modal\r\n showFeedbackModal: boolean = false;\r\n // Show the Information modal\r\n showInformationMessage: boolean = false;\r\n // show the button to confirm deleting the case lender\r\n showConfirmDeleteButton: boolean = false;\r\n // case to remove\r\n caseLender: CaseLenderDTO;\r\n // indicates whether a bid has been accepted on the case\r\n hasBidAccepted: boolean = false;\r\n\r\n // Message to be displayed in the message modal\r\n messageContent: string;\r\n\r\n showProceedModal: boolean = false;\r\n\r\n IsSupplimentInfoFilled: boolean = false;\r\n\r\n currentLenderPreferredBrokers: OrganisationDTO[];\r\n currentLenderPreferredPackagersText: string;\r\n hasLenderPreferredBrokers: boolean = false;\r\n emailCache = {};\r\n\r\n //Export Modal\r\n selectedLenders: { [lenderId: number]: boolean } = {};\r\n showExport: boolean = false;\r\n showExportButton: boolean = false;\r\n seeLenderNames: boolean = false;\r\n showLenderNames: boolean = true;\r\n\r\n currentUserOrg: OrganisationDTO;\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private lenderService: LenderService,\r\n private $location: ng.ILocationService,\r\n private caseMemberService: CaseMemberService,\r\n private caseService: CaseService,\r\n private caseLenderService: CaseLenderService,\r\n private roleService: RoleService,\r\n private userService: UserService,\r\n private organisationService: OrganisationService,\r\n private eventLogService: EventLogService,\r\n private $sce: ng.ISCEService,\r\n ) {\r\n this.lenderDisplayName();\r\n\r\n if (this.$routeParams.CaseId) {\r\n this.dataLoading = true;\r\n\r\n this.caseService\r\n .fetch(this.$routeParams.CaseId)\r\n .then((response) => {\r\n this.currentCase = response;\r\n this.developmentInputId = response.DevelopmentInputID;\r\n this.userService.GetDefaultBrokerOrganisation().then((result) => {\r\n this.currentUserOrg = result;\r\n this.seeLenderNames = result?.ShowLenderNames;\r\n this.caseLenderService\r\n .fetchByCaseId(this.$routeParams.CaseId, this.seeLenderNames)\r\n .then((response) => {\r\n this.caseLenders = response;\r\n\r\n for (var i = 0; i < this.caseLenders.length; i++) {\r\n this.lenderId[i] = this.caseLenders[i].LenderId;\r\n this.toggleLender(this.caseLenders[i]);\r\n }\r\n /*this.getAllLenderLogos(this.lenderId);*/\r\n\r\n var bidAccepted = this.caseLenders.find(\r\n (x) => x.IsBidAccepted == true,\r\n );\r\n\r\n if (bidAccepted) {\r\n this.hasBidAccepted = true;\r\n }\r\n this.dipRecieved();\r\n });\r\n });\r\n\r\n //TODO JLH - why is this being done??\r\n //this.caseService.setStatusOnCase(this.currentCase.Id, this.currentCase.CaseStatus);\r\n\r\n this.IsSupplimentInfoFilled =\r\n this.caseService.getIsSupplimentInfoFilled();\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n ////Get URL for the specific lender\r\n //getLenderLogos(index: number) {\r\n // return this.lenderLogos[index];\r\n //}\r\n\r\n //// Get all URL for all Lender result\r\n //getAllLenderLogos(lenderId: number[]) {\r\n // this.lenderService.getAllLenderLogos(lenderId).then(result => {\r\n // this.lenderLogos = result;\r\n\r\n // })\r\n //}\r\n\r\n /** Redirects to the case dashboard */\r\n goToCaseDashboard() {\r\n this.$location.path(\"/casedashboard/\" + this.currentCase.Id);\r\n }\r\n\r\n /** Redirects to the user dashboard */\r\n goToUserDashboard() {\r\n this.userService.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n /** Process the Heads of Terms button being clicked */\r\n headsOfTermsClicked(selectedCaseLender: CaseLenderDTO, index) {\r\n this.selectedCaseLender = selectedCaseLender;\r\n this.$location.path(\r\n \"/headsofterm/\" + this.currentCase.Id + \"/\" + this.selectedCaseLender.Id,\r\n );\r\n }\r\n /**\r\n * Process the feedback button being clicked\r\n * @param selectedCaseLender The lender associated with the button's row\r\n */\r\n feedbackButtonClicked(selectedCaseLender: CaseLenderDTO) {\r\n this.selectedCaseLender = selectedCaseLender;\r\n\r\n // Show the Feedback Modal\r\n this.showFeedbackModal = true;\r\n }\r\n\r\n lenderDisplayName() {\r\n this.organisationService.showLenderNamesAndLogos().then((result) => {\r\n this.showLenders = result;\r\n });\r\n }\r\n\r\n /**Process the Submit Terms and Conditions button being clicked */\r\n submitTsAndCsClicked() {\r\n this.showApplyTsAndCs = false;\r\n this.selectedCaseLender.IsBidAccepted = true;\r\n\r\n this.caseLenderService\r\n .addUpdate(this.selectedCaseLender)\r\n .then((response) => {\r\n this.selectedCaseLender.IsBidAccepted = response.IsBidAccepted;\r\n this.hasBidAccepted = response.IsBidAccepted;\r\n\r\n return this.caseLenderService.applyToLender(\r\n this.selectedCaseLender.CaseId,\r\n this.selectedCaseLender.Id,\r\n this.hasLenderPreferredBrokers,\r\n );\r\n })\r\n .then((response) => {\r\n this.selectedCaseLender.CaseLenderState = response.CaseLenderState;\r\n this.caseLenders = this.caseLenders.map((cl) =>\r\n cl.Id !== this.selectedCaseLender.Id ? cl : this.selectedCaseLender,\r\n );\r\n })\r\n .finally(() => {\r\n this.messageContent =\r\n \"Thank you for submitting an application with this lender.\";\r\n if (this.hasLenderPreferredBrokers) {\r\n this.showPreferredPackagers = true;\r\n } else {\r\n this.showInformationMessage = true;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Process the Apply button being clicked\r\n */\r\n submit(lender: CaseLenderDTO) {\r\n this.selectedCaseLender = lender;\r\n\r\n this.lenderService\r\n .getSelectedLenderPreferredOrgs(this.selectedCaseLender.LenderId)\r\n .then((response) => {\r\n this.currentLenderPreferredBrokers = response;\r\n\r\n return this.userService.getBrokerOrganisationId();\r\n })\r\n .then((response) => {\r\n //checks if broker that applies is not part of the preferred brokers list\r\n\r\n this.hasLenderPreferredBrokers =\r\n this.currentLenderPreferredBrokers != null &&\r\n this.currentLenderPreferredBrokers.length > 0 &&\r\n !this.currentLenderPreferredBrokers.some(\r\n (org) => org.Id === response,\r\n );\r\n\r\n if (this.hasLenderPreferredBrokers) {\r\n this.currentLenderPreferredBrokers.forEach((org) => {\r\n this.getBrokerAdminEmail(org);\r\n });\r\n }\r\n\r\n return this.lenderService.getLenderPreferredPackagersText(\r\n this.selectedCaseLender.LenderId,\r\n );\r\n })\r\n .then((response) => {\r\n this.currentLenderPreferredPackagersText = response;\r\n })\r\n .finally(() => {\r\n this.showApplyTsAndCs = true;\r\n });\r\n }\r\n\r\n /**\r\n * Process the Send Feedback button being clicked\r\n * @param message\r\n */\r\n sendFeedbackClicked() {\r\n this.caseLenderService\r\n .sendFeedbackToLender(this.selectedCaseLender)\r\n .then((response) => {\r\n this.messageContent = \"Your feedback has been sent to the lender.\";\r\n this.showInformationMessage = true;\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while sending feedback to lender. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.showFeedbackModal = false;\r\n });\r\n }\r\n\r\n /**\r\n * Process the Apply button being clicked\r\n * @param currentCaseLender\r\n */\r\n applyClicked(selectedCaseLender: CaseLenderDTO) {\r\n this.selectedCaseLender = selectedCaseLender;\r\n\r\n // Show the Terms and Conditions modal\r\n this.showApplyTsAndCs = true;\r\n }\r\n /**\r\n * Process the Cancel Application button being clicked\r\n * @param currentCaseLender\r\n */\r\n\r\n cancelTerms(selectedCaseLender: CaseLenderDTO) {\r\n this.caseLenderService\r\n .getSelectedCaseLender(selectedCaseLender.Id, this.seeLenderNames)\r\n .then((response) => {\r\n this.selectedCaseLender = response;\r\n })\r\n .then(() => {\r\n if (\r\n this.selectedCaseLender.CaseLenderState == CaseLenderStateEnum.Applied\r\n ) {\r\n this.selectedCaseLender.IsBidAccepted = false;\r\n this.caseLenderService\r\n .addUpdate(this.selectedCaseLender)\r\n .then((response) => {\r\n this.selectedCaseLender.IsBidAccepted = response.IsBidAccepted;\r\n this.hasBidAccepted = response.IsBidAccepted;\r\n\r\n return this.caseLenderService.cancelApplication(\r\n this.selectedCaseLender.CaseId,\r\n this.selectedCaseLender.Id,\r\n );\r\n })\r\n .then((response) => {\r\n this.selectedCaseLender.CaseLenderState =\r\n response.CaseLenderState;\r\n this.caseLenders = this.caseLenders.map((cl) =>\r\n cl.Id !== this.selectedCaseLender.Id\r\n ? cl\r\n : this.selectedCaseLender,\r\n );\r\n })\r\n .finally(() => {\r\n this.messageContent =\r\n \"Application with this lender has been cancelled.\";\r\n this.showInformationMessage = true;\r\n });\r\n } else {\r\n this.messageContent =\r\n \"There was a problem with cancelling this application. Please refresh and try again.\";\r\n this.showInformationMessage = true;\r\n }\r\n });\r\n\r\n //this.showProceedModal = true;\r\n }\r\n\r\n getStatusText(selectedCaseLender: CaseLenderDTO): string {\r\n var statusText = \"\";\r\n\r\n if (this.roleService.IsLender) {\r\n statusText = this.caseLenderService.getStatusTextForLender(\r\n selectedCaseLender.CaseLenderState,\r\n selectedCaseLender.IsBidAccepted,\r\n );\r\n } else {\r\n switch (selectedCaseLender.CaseLenderState) {\r\n case CaseLenderStateEnum.Offered: {\r\n if (this.hasBidAccepted) {\r\n statusText = selectedCaseLender.IsBidAccepted\r\n ? \"DIP received and accepted\"\r\n : \"DIP received but applying to another lender\";\r\n } else {\r\n statusText = \"DIP received\";\r\n }\r\n break;\r\n }\r\n case CaseLenderStateEnum.Received: {\r\n statusText = \"Awaiting DIP\";\r\n if (this.hasBidAccepted) {\r\n statusText = \"Awaiting DIP but applying to another lender\";\r\n } else {\r\n statusText = \"Awaiting DIP\";\r\n }\r\n break;\r\n }\r\n case CaseLenderStateEnum.Cancelled: {\r\n if (this.hasBidAccepted) {\r\n statusText = \"Application cancelled but applying to another lender\";\r\n } else {\r\n statusText = \"Application cancelled\";\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return statusText;\r\n }\r\n\r\n editApplicationDetails() {\r\n this.$location.path(\"/applicationdetails/\" + this.currentCase.Id);\r\n }\r\n\r\n deleteButton(caseLender: CaseLenderDTO) {\r\n this.showConfirmDeleteButton = true;\r\n this.showInformationMessage = true;\r\n this.messageContent =\r\n \"Are you sure you want to remove \" + caseLender.LenderName + \"?\";\r\n this.caseLender = caseLender;\r\n }\r\n\r\n delete() {\r\n this.caseLenderService\r\n .markasdeleted(this.caseLender.Id)\r\n .then((result) => {\r\n this.caseLenders = this.caseLenders.filter(\r\n (x) => x.Id != this.caseLender.Id,\r\n );\r\n })\r\n .finally(() => {\r\n this.showInformationMessage = false;\r\n delete this.caseLender;\r\n this.showConfirmDeleteButton = false;\r\n });\r\n }\r\n\r\n /**\r\n * Determines whether to show the Shortlist More Lenders button.\r\n * Should be shown if there are less than 3 \"active\" shortlisted lenders i.e. haven't rejected/withdrawn\r\n * and no DIP is accepted\r\n * */\r\n showShortlistMoreLendersButton(): boolean {\r\n var showButton: boolean = false;\r\n if (this.caseLenders) {\r\n var activeShortlistCount = this.caseLenders.filter(\r\n (lender) =>\r\n lender.CaseLenderState != CaseLenderStateEnum.Withdrawn &&\r\n lender.CaseLenderState != CaseLenderStateEnum.Rejected,\r\n ).length;\r\n\r\n showButton = activeShortlistCount < 5 ? true : false;\r\n }\r\n\r\n //Hide button if DIP accepted\r\n if (this.hasBidAccepted) {\r\n showButton = false;\r\n }\r\n\r\n return showButton;\r\n }\r\n\r\n shortlistMoreLenders() {\r\n this.$location.path(\r\n \"/shortlistmore/\" +\r\n this.currentCase.DevelopmentInputID +\r\n \"/\" +\r\n this.currentCase.Id,\r\n );\r\n }\r\n\r\n toggleLender(lender: CaseLenderDTO) {\r\n this.selectedLenders[lender.Id] = !this.selectedLenders[lender.Id];\r\n }\r\n\r\n stateFilter(lender: CaseLenderDTO) {\r\n return (\r\n !lender.IsDeleted &&\r\n (lender.CaseLenderState === 2 || lender.CaseLenderState === 10)\r\n );\r\n }\r\n\r\n showAndHideExport() {\r\n this.showExport = !this.showExport;\r\n }\r\n\r\n getSelectedCaseLenders() {\r\n const selectedCaseLenders = this.caseLenders.filter(\r\n (lender) => this.selectedLenders[lender.Id],\r\n );\r\n return selectedCaseLenders;\r\n }\r\n\r\n areLendersSelected() {\r\n for (var lenderId in this.selectedLenders) {\r\n if (this.selectedLenders[lenderId]) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n dipRecieved() {\r\n this.showExportButton = this.caseLenders.some(\r\n (lender) => lender.CaseLenderState === 2 || lender.CaseLenderState === 10,\r\n );\r\n }\r\n\r\n logPdfDownload() {\r\n this.eventLogService.logEvent(\r\n \"EXPORTDIPPDFCLICKED\",\r\n EventLogEnum.Export,\r\n ProductTypeEnum.Development,\r\n );\r\n }\r\n\r\n trustedHtml(plainText) {\r\n return this.$sce.trustAsHtml(plainText);\r\n }\r\n\r\n getBrokerAdminEmail(org: OrganisationDTO) {\r\n if (this.emailCache && this.emailCache[org.Id]) {\r\n return;\r\n }\r\n\r\n if (!org.PreferredPackagerEmail) {\r\n this.userService.getOrganisationAdminEmail(org.Id).then((response) => {\r\n this.emailCache[org.Id] = response;\r\n });\r\n } else {\r\n this.emailCache[org.Id] = org.PreferredPackagerEmail;\r\n }\r\n }\r\n\r\n showApplyButton(lender){\r\n if((this.hasBidAccepted == false || this.hasBidAccepted == null ) && (lender.CaseLenderState == CaseLenderStateEnum.Offered || lender.CaseLenderState == CaseLenderStateEnum.Cancelled)){\r\n return true;\r\n }\r\n \r\n return false;\r\n }\r\n \r\n showCancelApplicationButton(lender){\r\n if(lender.IsBidAccepted == true && lender.CaseLenderState == CaseLenderStateEnum.Applied){\r\n return true;\r\n }\r\n return false;\r\n\r\n }\r\n\r\n // We need this as deal and case shares the same view.\r\n showSendToPackagerButton(lender){\r\n return false;\r\n }\r\n}\r\n","import { AddressLookupDTO } from \"@js/DTO/AddressLookupDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { CaseMemberDTO } from \"@js/DTO/CaseMemberDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { LenderResultMinimalDTO } from \"@js/DTO/DevelopmentFinance/LenderResultMinimalDTO.cs.d\";\r\nimport { ProjectOwnershipDTO } from \"@js/DTO/DevelopmentFinance/ProjectOwnershipDTO.cs.d\";\r\nimport { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { ProductDTO } from \"@js/DTO/ProductDTO.cs.d\";\r\nimport { BuildProcurementTypeEnum } from \"@js/models/enum/BuildProcurementTypeEnum.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs.d\";\r\nimport { ExitStrategyEnum } from \"@js/models/enum/ExitStrategyEnum.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { OwnNewDevelopmentEnum } from \"@js/models/enum/OwnNewDevelopmentEnum.cs.d\";\r\nimport { PlanningPermissionTypeEnum } from \"@js/models/enum/PlanningPermissionTypeEnum.cs.d\";\r\nimport { PlanningResponsibilityEnum } from \"@js/models/enum/PlanningResponsibilityEnum.cs.d\";\r\nimport { PurchaseProcessTypeEnum } from \"@js/models/enum/PurchaseProcessTypeEnum.cs.d\";\r\nimport { PostalAddress } from \"@js/models/PostalAddress.cs.d\";\r\nimport { ApplicantService } from \"@js/services/ApplicantService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DevelopmentExperienceService } from \"@js/services/DevelopmentExperienceService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { LenderResultService } from \"@js/services/LenderResultService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { StreetAddressService } from \"@js/services/StreetAddressService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class CaseOverviewController {\r\n dataLoading: boolean = false;\r\n\r\n //Applicants displayed\r\n shareholders: CaseMemberDTO[];\r\n currentApplicant: CaseMemberDTO;\r\n applicantForm: ng.IFormController;\r\n addEditApplicant: CaseMemberDTO;\r\n confirmDeleteApplicant: CaseMemberDTO;\r\n tempApplicant: CaseMemberDTO;\r\n showQuickEditModal: boolean = false;\r\n showDelete: boolean = false;\r\n confirmationDelete: boolean = false;\r\n maxDateOfBirth: Date = new Date();\r\n minDateOfBirth: Date = new Date(\"Jan 01 1900\");\r\n maxDateForDateField: Date = new Date(\"Jan 01 3000\");\r\n message: string = \"\";\r\n modal: boolean = false;\r\n disableQuickEditSave: boolean = false;\r\n isAddShareholder: boolean;\r\n\r\n isAdmin: boolean;\r\n isBroker: boolean;\r\n shareholder: CaseMemberDTO;\r\n isPrimaryApplicant: boolean;\r\n\r\n //Open / close the sections\r\n ownership: boolean = false;\r\n siteDetails: boolean = false;\r\n planning: boolean = false;\r\n procurement: boolean = false;\r\n deposit: boolean = false;\r\n guarantees: boolean = false;\r\n exitStrategy: boolean = false;\r\n completion: boolean = false;\r\n mezzanine: boolean = false;\r\n preferences: boolean = false;\r\n existingRelationships: boolean = false;\r\n caseOverview: boolean = false;\r\n isExpanded: boolean = false;\r\n executiveSummary: boolean = false;\r\n\r\n //File Section\r\n\r\n thisModuleSection: ModuleEnum.Planning;\r\n fileUpload: FileAttachmentDTO[];\r\n fileUploadPlaning: FileAttachmentDTO[];\r\n fileUploadTeam: FileAttachmentDTO[];\r\n fileUploadProperties: FileAttachmentDTO[];\r\n selectedProduct: ProductDTO;\r\n selectedResult: LenderResultMinimalDTO;\r\n total: number = 0;\r\n openModal: boolean = false;\r\n uploadingFiles: FileUploadProgressDTO[];\r\n renamingFile: FileAttachmentDTO;\r\n\r\n //Case info\r\n loanCriteria: DevelopmentInputDTO;\r\n dateOfOrigPurchMonth: number;\r\n dateOfOrigPurchYear: number;\r\n case: CaseDTO;\r\n\r\n //Search address\r\n searchresults: string;\r\n PostCodeOptions: PostalAddress[] = [];\r\n searchterm: string;\r\n searchingForAddress: boolean = false;\r\n\r\n //Development Experience info\r\n companyDetails: ProjectOwnershipDTO;\r\n\r\n tinymceOptions: any;\r\n multiPartForm1: ng.IFormController;\r\n showAutofill: boolean;\r\n\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"CaseMemberService\",\r\n \"CaseService\",\r\n \"DevelopmentInputService\",\r\n \"$location\",\r\n \"StreetAddressService\",\r\n \"$q\",\r\n \"LenderResultService\",\r\n \"ApplicantService\",\r\n \"DevelopmentExperienceService\",\r\n \"FileAttachmentService\",\r\n \"$window\",\r\n \"RoleService\",\r\n \"AuthService\",\r\n \"UserService\",\r\n ];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $caseMemberService: CaseMemberService,\r\n private caseService: CaseService,\r\n private developmentInputService: DevelopmentInputService,\r\n private $location: ng.ILocationService,\r\n private $streetAddressService: StreetAddressService,\r\n protected $q: ng.IQService,\r\n private $lenderresultservice: LenderResultService,\r\n private $applicantservice: ApplicantService,\r\n private $developmentexperienceservice: DevelopmentExperienceService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private $window: ng.IWindowService,\r\n private roleService: RoleService,\r\n private $auth: AuthService,\r\n private userService: UserService,\r\n ) {\r\n this.tinymceOptions = {\r\n content_style:\r\n \"body {color: #304b9a;font:300 13.33px Roboto,sans-serif;}\",\r\n menubar: false,\r\n height: 300,\r\n branding: false,\r\n statusbar: false,\r\n plugins: [\r\n \"advlist autolink lists link image charmap print preview anchor\",\r\n \"searchreplace visualblocks code fullscreen\",\r\n \"insertdatetime media table paste code help wordcount\",\r\n ],\r\n toolbar:\r\n \"undo redo | formatselect | \" +\r\n \"bold italic backcolor forecolor | alignleft aligncenter \" +\r\n \"alignright alignjustify | bullist numlist outdent indent | preview fullscreen |\" +\r\n \"removeformat | help\",\r\n };\r\n\r\n this.userService.getUserAutofill().then((response) => {\r\n this.showAutofill = response;\r\n });\r\n\r\n if (this.$routeParams.CaseId) {\r\n this.dataLoading = true;\r\n\r\n //case is needed to get loanCriteria information\r\n this.caseService\r\n .fetch(this.$routeParams.CaseId)\r\n .then((response) => {\r\n this.case = response;\r\n\r\n if (this.$routeParams.Planning) {\r\n this.planning = true;\r\n }\r\n\r\n if (this.case) {\r\n this.fileUpload = this.case.Attachments;\r\n\r\n this.$developmentexperienceservice\r\n .fetch(this.case.DevelopmentExperienceID)\r\n .then((response) => {\r\n this.companyDetails = response;\r\n });\r\n\r\n this.developmentInputService\r\n .fetch(this.case.DevelopmentInputID)\r\n .then((response) => {\r\n this.loanCriteria = response;\r\n\r\n if (this.loanCriteria) {\r\n if (this.loanCriteria.CI_Dev_DateOfOrigPurch) {\r\n this.dateOfOrigPurchMonth =\r\n this.loanCriteria.CI_Dev_DateOfOrigPurch.getMonth() + 1;\r\n this.dateOfOrigPurchYear =\r\n this.loanCriteria.CI_Dev_DateOfOrigPurch.getFullYear() %\r\n 100;\r\n }\r\n if (!this.loanCriteria.DI_PurchaseAgentFees) {\r\n this.loanCriteria.DI_PurchaseAgentFees = 0;\r\n }\r\n if (!this.loanCriteria.DI_PurchaseLegalFees) {\r\n this.loanCriteria.DI_PurchaseLegalFees = 0;\r\n }\r\n if (!this.loanCriteria.DI_PurchaseOtherFees) {\r\n this.loanCriteria.DI_PurchaseOtherFees = 0;\r\n }\r\n } else {\r\n // If there's no loan criteria then something has gone wrong\r\n this.$location.path(\"/dashboard\");\r\n }\r\n })\r\n .catch((error) => {\r\n this.$location.path(\"/dashboard\");\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n // If no case is returned, this could be that the logged in user has been removed from the case\r\n // - only do this if there is a logged in user, otherwise let the routing sort out where the redirect should go\r\n if ((this.$rootScope as any).selectedUser) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n }\r\n })\r\n .catch((error) => {\r\n this.$location.path(\"/dashboard\");\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n\r\n this.checkForAdmin();\r\n this.checkForBroker();\r\n this.checkForPrimaryUser();\r\n\r\n this.$caseMemberService\r\n .fetchByCaseId(this.$routeParams.CaseId)\r\n .then((response) => {\r\n this.shareholders = response;\r\n });\r\n }\r\n }\r\n\r\n checkForAdmin(): void {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isAdminUser()\r\n .then((response) => {\r\n this.isAdmin = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkForBroker(): void {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isBroker()\r\n .then((response) => {\r\n this.isBroker = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkForPrimaryUser(): boolean {\r\n if (\r\n (this.$rootScope as any).selectedUser &&\r\n this.case &&\r\n (this.$rootScope as any).selectedUser.UserName == this.case.OwnerUser\r\n ) {\r\n this.isPrimaryApplicant = true;\r\n return true;\r\n }\r\n\r\n this.isPrimaryApplicant = false;\r\n return false;\r\n }\r\n\r\n clientAccountAccessCheck(shareholder: CaseMemberDTO): boolean {\r\n if (this.shareholders) {\r\n this.shareholder = this.shareholders.find(\r\n (x) => x.UserId == shareholder.UserId,\r\n );\r\n }\r\n\r\n if (this.shareholder.UserId == (this.$rootScope as any).selectedUser.Id) {\r\n return true;\r\n }\r\n\r\n if (this.checkForPrimaryUser()) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n getAddressList(app, searchTerm: string) {\r\n let foundMatch = false;\r\n\r\n if (\r\n this.PostCodeOptions &&\r\n this.PostCodeOptions &&\r\n this.PostCodeOptions.length > 0\r\n ) {\r\n let addressLookup = this.PostCodeOptions.find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n\r\n // We've selected an address!\r\n this.$streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n app.DI_StreetAddress = address;\r\n this.searchterm = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n this.loanCriteria.DI_StreetAddress.AddressLine1 =\r\n addressLookup.AddressLine2.replace(\r\n addressLookup.AddressLine2.substring(\r\n addressLookup.AddressLine2.indexOf(\"-\") - 1,\r\n ),\r\n \"\",\r\n );\r\n this.loanCriteria.DI_StreetAddress.AddressLine2 =\r\n addressLookup.AddressLine3;\r\n this.loanCriteria.DI_StreetAddress.AddressLine3 =\r\n addressLookup.AddressLine4;\r\n this.loanCriteria.DI_StreetAddress.AddressLine4 =\r\n addressLookup.PostCode;\r\n this.loanCriteria.DI_StreetAddress.PostCode =\r\n addressLookup.AddressLine1;\r\n this.searchterm = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n // Initial search term\r\n this.PostCodeOptions = [];\r\n\r\n this.$streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.PostCodeOptions = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n save(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n if (!this.loanCriteria) {\r\n return defer.promise;\r\n }\r\n\r\n this.developmentInputService\r\n .addUpdatereturnonlyid(this.loanCriteria)\r\n .then((response) => {\r\n this.$lenderresultservice\r\n .fetchMatchingResults(\r\n this.loanCriteria,\r\n true,\r\n true,\r\n 20,\r\n false,\r\n \"\",\r\n \"\",\r\n \"\",\r\n this.loanCriteria.SearchName,\r\n )\r\n .then((results) => {});\r\n defer.resolve(response as number);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n if (this.case.CompletionDate) {\r\n var completionDate = new Date();\r\n completionDate.setHours(0, 0, 0, 0);\r\n this.case.CompletionDate = new Date(\r\n completionDate.setUTCFullYear(\r\n this.case.CompletionDate.getFullYear(),\r\n this.case.CompletionDate.getMonth(),\r\n this.case.CompletionDate.getDate(),\r\n ),\r\n );\r\n }\r\n\r\n this.caseService.addUpdatereturnonlyid(this.case).then((response) => {});\r\n\r\n this.$developmentexperienceservice\r\n .addUpdatereturnonlyid(this.companyDetails)\r\n .then((response) => {\r\n //set ID of selectedobject\r\n this.companyDetails.Id = response;\r\n //after save take out saving assoication each time\r\n this.companyDetails.parentCaseToAssoicateWithOnCreation = null;\r\n defer.resolve(response as number);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n this.goToCaseDashboard(false);\r\n\r\n return defer.promise;\r\n }\r\n\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n\r\n /**\r\n * Calculates the order number of all the preferences when one is toggled\r\n * @param toggledPreference\r\n */\r\n calculatePreferenceOrder(toggledPreference: string) {\r\n const preferenceNames = [\r\n \"SearchPreferenceLoanSize\",\r\n \"SearchPreferencePricing\",\r\n \"SearchPreferenceCompletionSpeed\",\r\n \"SearchPreferenceCustomerService\",\r\n ];\r\n // Finds the highest preference order of all preferences\r\n const maxPreferenceOrder = Math.max(\r\n this.loanCriteria.SearchPreferenceCompletionSpeed,\r\n this.loanCriteria.SearchPreferenceCustomerService,\r\n this.loanCriteria.SearchPreferenceLoanSize,\r\n this.loanCriteria.SearchPreferencePricing,\r\n );\r\n\r\n // If the preference that has been toggled already has a value greater than 0 then it is being turned OFF\r\n if (this.loanCriteria[toggledPreference] > 0) {\r\n // Find any preferences that have a higher preference number and decrease their order number by 1\r\n for (let preference of preferenceNames) {\r\n if (preference == toggledPreference) {\r\n continue;\r\n } else {\r\n if (\r\n this.loanCriteria[preference] > this.loanCriteria[toggledPreference]\r\n ) {\r\n this.loanCriteria[preference]--;\r\n }\r\n }\r\n }\r\n\r\n this.loanCriteria[toggledPreference] = 0;\r\n } else {\r\n // Preference is being turned ON\r\n // Use the highest preference order number and increase by 1\r\n this.loanCriteria[toggledPreference] = maxPreferenceOrder + 1;\r\n }\r\n }\r\n\r\n goToCaseDashboard(saveChanges: boolean): void {\r\n if (saveChanges && !this.roleService.IsLender) {\r\n this.save().then((response) => {\r\n (this.$rootScope as any).formSaved = true;\r\n this.$location.path(\"/casedashboard/\" + this.case.Id);\r\n });\r\n } else {\r\n this.$location.path(\"/casedashboard/\" + this.case.Id);\r\n }\r\n }\r\n\r\n /** Initialise the CaseMemberDTO for adding a new Shareholder/Applicant */\r\n initialiseNewApplicant() {\r\n this.addEditApplicant = {\r\n AccessLevel: CaseAccessLevelEnum.FullAccess,\r\n CaseId: this.$routeParams.CaseId,\r\n IsApplicant: true,\r\n Order:\r\n this.shareholders && this.shareholders.length > 0\r\n ? this.shareholders.length + 1\r\n : 1,\r\n StreetAddress: {\r\n AddressLine1: \"\",\r\n AddressLine2: \"\",\r\n AddressLine3: \"\",\r\n AddressLine4: \"\",\r\n PostCode: \"\",\r\n } as PostalAddress,\r\n } as CaseMemberDTO;\r\n }\r\n\r\n deleteApplicant(): void {\r\n var id = this.confirmDeleteApplicant.Id;\r\n\r\n this.$applicantservice.delete(id).then((response) => {\r\n var index = this.shareholders\r\n .map(function (s) {\r\n return s.Id;\r\n })\r\n .indexOf(id);\r\n\r\n //let index = this.shareholders.indexOf(this.confirmDeleteApplicant);\r\n this.shareholders.splice(index, 1);\r\n });\r\n this.confirmDeleteApplicant = {} as CaseMemberDTO;\r\n this.showDelete = false;\r\n }\r\n\r\n deleteConfirmApplicant(applicant: CaseMemberDTO) {\r\n this.showDelete = true;\r\n this.confirmDeleteApplicant = { ...applicant };\r\n }\r\n\r\n /**\r\n * Open the Shareholder/Applicant quick edit\r\n * @param applicant\r\n */\r\n openShareholderQuickEdit(applicant: CaseMemberDTO) {\r\n if (applicant) {\r\n this.isAddShareholder = false;\r\n this.addEditApplicant = applicant;\r\n this.tempApplicant = { ...this.addEditApplicant };\r\n } else {\r\n this.isAddShareholder = true;\r\n if (this.applicantForm) {\r\n this.applicantForm.$setPristine();\r\n this.applicantForm.$setUntouched();\r\n }\r\n\r\n this.initialiseNewApplicant();\r\n }\r\n\r\n this.showQuickEditModal = true;\r\n }\r\n\r\n /** Cancel any adding or editing of a Shareholder/Applicant */\r\n cancelShareholderQuickEdit() {\r\n if (this.tempApplicant && this.tempApplicant.Id > 0) {\r\n this.shareholders = this.shareholders.filter(\r\n (applicant) => applicant.Id != this.tempApplicant.Id,\r\n );\r\n this.shareholders.push(this.tempApplicant);\r\n }\r\n\r\n this.closeShareholderQuickEdit();\r\n }\r\n\r\n /** Save a new or updated Shareholder/Applicant */\r\n saveApplicant(): void {\r\n this.disableQuickEditSave = true; // this is just because sometimes the save takes a little while and the user could click the save button again\r\n\r\n this.$applicantservice\r\n .addOrUpdateCaseMember(this.addEditApplicant, this.isAddShareholder)\r\n .then((response) => {\r\n response.DateOfBirth = this.addEditApplicant.DateOfBirth; // TODO should try to parse the response.DOB as it's being returned as a string\r\n\r\n const existingShareholder = this.shareholders.find(\r\n (s) => s.Id == response.Id,\r\n );\r\n\r\n // If found then we're updating\r\n if (existingShareholder) {\r\n this.shareholders = this.shareholders.filter(\r\n (member) => member.Id != this.addEditApplicant.Id,\r\n );\r\n this.shareholders.push(response);\r\n } else {\r\n this.shareholders.push(response);\r\n }\r\n })\r\n .finally(() => {\r\n this.closeShareholderQuickEdit();\r\n this.disableQuickEditSave = false;\r\n });\r\n }\r\n\r\n goToApplicantDetails(applicant: CaseMemberDTO): void {\r\n //change applicant.id to index (use a for loop to iterate through dto)\r\n var applicantId;\r\n\r\n for (let i = 0; i <= this.shareholders.length - 1; i++) {\r\n if (this.shareholders[i].Id == applicant.Id) {\r\n applicantId = i;\r\n }\r\n }\r\n if (applicantId || applicantId == 0) {\r\n this.go(\r\n \"/applicantdetails/\" +\r\n this.case.Id +\r\n \"/\" +\r\n this.case.DevelopmentExperienceID +\r\n \"/4/\" +\r\n applicantId,\r\n );\r\n }\r\n }\r\n\r\n closeShareholderQuickEdit() {\r\n this.showQuickEditModal = false;\r\n this.applicantForm.$setPristine();\r\n this.applicantForm.$setUntouched();\r\n this.tempApplicant = {} as CaseMemberDTO;\r\n this.addEditApplicant = {} as CaseMemberDTO;\r\n }\r\n\r\n /** Get the text to display based on the ownership type selected */\r\n getOwnershipTypeText(): string {\r\n var ownershipTypeText;\r\n\r\n if (\r\n this.companyDetails &&\r\n this.companyDetails.HowWillYouOwnNewDevelopment\r\n ) {\r\n switch (this.companyDetails.HowWillYouOwnNewDevelopment) {\r\n case OwnNewDevelopmentEnum.UKLimitedCompany:\r\n ownershipTypeText = \"UK Limited Company\";\r\n break;\r\n case OwnNewDevelopmentEnum.OverseasLimitedCompany:\r\n ownershipTypeText = \"Overseas Limited Company\";\r\n break;\r\n case OwnNewDevelopmentEnum.PensionFund:\r\n ownershipTypeText = \"Pension Fund\";\r\n break;\r\n case OwnNewDevelopmentEnum.UKLimitedLiabilityPartnership:\r\n ownershipTypeText = \"UK Limited Liability Partnership\";\r\n break;\r\n default:\r\n ownershipTypeText = \"\";\r\n }\r\n return ownershipTypeText;\r\n }\r\n return \"\";\r\n }\r\n\r\n /**Determine whether to show CompanyOrPartnershipName */\r\n showCompanyOrPartnershipName(): boolean {\r\n if (\r\n this.companyDetails &&\r\n this.companyDetails.HowWillYouOwnNewDevelopment !=\r\n OwnNewDevelopmentEnum.PersonalNames &&\r\n this.companyDetails.HasTheCompanyOrPensionBeenFormedYet\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**Determine whether to show CompanyOrPartnershipNumber */\r\n showCompanyOrPartnershipNumber(): boolean {\r\n if (\r\n this.companyDetails &&\r\n this.companyDetails.HowWillYouOwnNewDevelopment !=\r\n OwnNewDevelopmentEnum.PersonalNames &&\r\n this.companyDetails.HasTheCompanyOrPensionBeenFormedYet\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**Determine whether to show PensionType */\r\n showPensionType(): boolean {\r\n if (\r\n this.companyDetails &&\r\n this.companyDetails.HowWillYouOwnNewDevelopment ==\r\n OwnNewDevelopmentEnum.PensionFund &&\r\n this.companyDetails.HasTheCompanyOrPensionBeenFormedYet\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** Determing whether to show the Tell us more fields */\r\n showTellUsMoreFields(): boolean {\r\n if (\r\n this.companyDetails &&\r\n this.companyDetails.HowWillYouOwnNewDevelopment !=\r\n OwnNewDevelopmentEnum.PersonalNames &&\r\n this.companyDetails.HowWillYouOwnNewDevelopment !=\r\n OwnNewDevelopmentEnum.Other\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n setDate(dateToUpdate: Date, month: number, year: number) {\r\n // Two digit years!\r\n var fullYear: number;\r\n var today = new Date();\r\n if (today.getFullYear() < 2000 + year) {\r\n // If it's after this year, we probably mean 19xx.\r\n fullYear = 1900 + year;\r\n } else {\r\n // Otherwise it's probably in the 2000s.\r\n fullYear = 2000 + year;\r\n }\r\n dateToUpdate.setUTCFullYear(fullYear);\r\n // Note: Months are 0 based.\r\n dateToUpdate.setUTCMonth(month - 1);\r\n }\r\n\r\n invite(applicant: CaseMemberDTO) {\r\n this.$caseMemberService\r\n .inviteApplicant(applicant.UniqueRef)\r\n .then((i) => {\r\n this.modal = true;\r\n this.message = \"Your email was successfully sent.\";\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"there was a problem on sending the email. Please try again later.\";\r\n });\r\n }\r\n\r\n //File upload\r\n\r\n //calculateFilesForThisModule() {\r\n // this.fileUploadPlaning = this.fileUpload.filter(file => file.Module === ModuleEnum.Planning);\r\n //this.fileUploadTeam = this.fileUpload.filter(file => file.Module === ModuleEnum.ProfessionalTeam);\r\n //this.fileUploadProperties = this.fileUpload.filter(file => file.Module === ModuleEnum.ComparableProperties);\r\n //}\r\n\r\n calculateTotalFiles(filter: number) {\r\n if (this.fileUpload) {\r\n this.total = this.fileUpload.filter(\r\n (item) => item.Module === filter,\r\n ).length;\r\n }\r\n return this.total;\r\n }\r\n\r\n onFileSelect(\r\n files: FileAttachmentDTO[],\r\n module: ModuleEnum = this.thisModuleSection,\r\n ) {\r\n if (files.length > 0) {\r\n //if case has no id it must be saved first\r\n if (this.case.Id < 1) {\r\n this.caseService\r\n .addUpdate(this.case)\r\n .then((response) => {\r\n this.case = response;\r\n this.onFileSelect(files, module); //call itself and then exit as should now be saved so should be able to run\r\n return;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n return;\r\n }\r\n this.fileAttachmentService\r\n .UploadFileLstInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.case.Id,\r\n this.fileUpload,\r\n module,\r\n )\r\n .then((result) => {\r\n this.openModal = false;\r\n });\r\n }\r\n }\r\n\r\n downloadFile(file: FileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.fileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n this.$window.open(uri);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n downloadFilesAsZip(files: FileAttachmentDTO) {\r\n var keys: string[] = [];\r\n for (var file in files) {\r\n if (files[file].FileLocation) {\r\n keys.push(files[file].FileLocation);\r\n }\r\n }\r\n this.fileAttachmentService.downloadZip(keys);\r\n }\r\n\r\n deleteFile(file: FileAttachmentDTO) {\r\n this.case.Attachments.splice(this.case.Attachments.indexOf(file), 1);\r\n this.fileAttachmentService.markasdeleted(file.Id).then((result) => {\r\n // code for file upload\r\n //this.calculateFilesForThisModule();\r\n }); //remove on the server\r\n // this.$rootScope.$apply();\r\n }\r\n renameFile(file: FileAttachmentDTO) {\r\n if (this.renamingFile === undefined) {\r\n // if renaming this file will dirty the case, we'll want to set it back to pristine when we're done.\r\n // this.renamingFileDirties = !$scope.caseForm.$dirty;\r\n this.renamingFile = file;\r\n } else {\r\n delete this.renamingFile;\r\n }\r\n }\r\n renamingFileComplete(file: FileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.fileAttachmentService\r\n .renameFile(file)\r\n .then((response) => {\r\n file.TempURL = response.TempURL;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n delete this.renamingFile;\r\n }\r\n\r\n expandOrCollapse(value: boolean) {\r\n this.ownership = value;\r\n this.siteDetails = value;\r\n this.planning = value;\r\n this.procurement = value;\r\n this.deposit = value;\r\n this.guarantees = value;\r\n this.exitStrategy = value;\r\n this.completion = value;\r\n this.mezzanine = value;\r\n this.preferences = value;\r\n this.existingRelationships = value;\r\n this.caseOverview = value;\r\n return value;\r\n }\r\n\r\n /**\r\n * Determines when to show/hide the Invite button\r\n * @param shareholder\r\n */\r\n showInviteButton(shareholder: CaseMemberDTO) {\r\n // If the shareholder has already been verified then don't show the button\r\n if (shareholder.IsVerified) {\r\n return false;\r\n }\r\n\r\n // At least 2 of the security questions should be answered\r\n var count = 0;\r\n\r\n if (shareholder.PhoneNumber) {\r\n count++;\r\n }\r\n\r\n if (shareholder.StreetAddress.PostCode) {\r\n count++;\r\n }\r\n\r\n if (shareholder.DateOfBirth) {\r\n count++;\r\n }\r\n\r\n if (count >= 2) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n autoFillCaseOverview() {\r\n this.loanCriteria.DI_StreetAddress.AddressLine1 = \"10 Kings Road\";\r\n this.loanCriteria.DI_StreetAddress.AddressLine2 = \"York\";\r\n this.loanCriteria.DI_StreetAddress.AddressLine3 = \"\";\r\n this.loanCriteria.DI_StreetAddress.AddressLine4 = \"\";\r\n this.loanCriteria.DI_StreetAddress.PostCode = \"YO1 1ET\";\r\n this.loanCriteria.DI_AreaSalesAreaResidential = 1000;\r\n this.case.PurchaseProcessType = PurchaseProcessTypeEnum.RegularPurchase;\r\n this.case.PlanningPermissionType = PlanningPermissionTypeEnum.NoPlanning;\r\n this.case.PlanningResponsibility = PlanningResponsibilityEnum.Borrower;\r\n this.case.PlanningDescription =\r\n \"We purchased the site with outline planning 6 months ago, with a bridging loan.We havenow dealt with all reserved matters, and have detailed planning permission for 26x 3 & 4 bed houses.\";\r\n this.case.SiteDescriptionOnCompletion =\r\n \"The site will be bare land at completion.\";\r\n this.case.BuildProcurementType =\r\n BuildProcurementTypeEnum.DesignAndBuildContract;\r\n this.case.DepositDescription =\r\n \"50% of the deposit will come from the shareholders and 50% will come from investors. The investors are family and friends and their investment will be secured as a 2nd charge.\";\r\n this.case.GuaranteeDescription = \"This is the dummy text\";\r\n this.loanCriteria.CI_Dev_ExitStrategy =\r\n ExitStrategyEnum.PartSalePartRefinance;\r\n this.case.HasSetCompletionDate = true;\r\n const maxDate = Date.now();\r\n const timestamp = Math.floor(Math.random() * maxDate);\r\n this.case.CompletionDate = new Date(timestamp);\r\n this.loanCriteria.SearchPreferenceLoanSize = 1;\r\n this.loanCriteria.SearchPreferencePricing = 2;\r\n this.loanCriteria.SearchPreferenceCompletionSpeed = 3;\r\n this.loanCriteria.SearchPreferenceCustomerService = 4;\r\n this.companyDetails.ExcludedLenders = \"Example Lenders\";\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CaseSummaryDTO } from \"@js/DTO/CaseSummaryDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { DevelopmentWithNoLoginDTO } from \"@js/DTO/DevelopmentWithNoLoginDTO.cs.d\";\r\nimport { IntroducerSimpleDTO } from \"@js/DTO/IntroducerSimpleDTO.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { CaseSummaryService } from \"@js/services/CaseSummaryService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { DevelopmentInputWithNoLoginService } from \"@js/services/DevelopmentInputWithNoLoginService\";\r\nimport { IntroducerService } from \"@js/services/IntroducerService\";\r\nimport { IntroducerSimpleService } from \"@js/services/IntroducerSimpleService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class ClientDashboardController {\r\n dataLoading: boolean = false;\r\n\r\n //Introducers\r\n introducerFirstLogin: boolean = false;\r\n introduceClientModal: number = null;\r\n clientFirstName: string;\r\n clientSurname: string;\r\n clientEmail: string;\r\n clientPhoneNumber: string;\r\n notifyBorrower: boolean = true;\r\n introducedUsers: ApplicationUserDTO[];\r\n hideCaseCreation: boolean = false;\r\n fetchingResults: boolean;\r\n savedResults: DevelopmentInputDTO[];\r\n unsavedIntroducedSearches: DevelopmentWithNoLoginDTO[];\r\n savedIntroducedSearches: DevelopmentInputDTO[] = [];\r\n savedCases: DevelopmentInputDTO[];\r\n allResults: DevelopmentInputDTO[];\r\n selectedResult: DevelopmentInputDTO;\r\n\r\n shareEmails: string = \"\";\r\n multipleEmails: boolean = false;\r\n\r\n shareEmailsArray: string[];\r\n\r\n caseSummaryList: CaseSummaryDTO[];\r\n myCaseSummaryList: CaseSummaryDTO[];\r\n allCaseSummaryList: CaseSummaryDTO[];\r\n selectedUser: ApplicationUserDTO;\r\n userSearchResults: ApplicationUserDTO[];\r\n adminUser: boolean = false;\r\n isBroker: boolean = false;\r\n isLender: boolean = false;\r\n currentUser: ApplicationUserDTO = null;\r\n selecteduserName: string = null;\r\n OtherUsers: string[] = null;\r\n newSearchName: string;\r\n link: string;\r\n\r\n introducerSimpleDetails: IntroducerSimpleDTO;\r\n\r\n introducerId: number;\r\n\r\n clientAdminTools: boolean = false;\r\n\r\n showSetPasswordModal: boolean = false;\r\n verifyNewPassword: string;\r\n passwordSetSuccess: boolean = false;\r\n registrationForm: FormData;\r\n\r\n introducerErrorDisplayed: boolean = false;\r\n\r\n referrerOptions = [];\r\n\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$location\",\r\n \"DevelopmentInputService\",\r\n \"DevelopmentInputWithNoLoginService\",\r\n \"UserService\",\r\n \"CaseService\",\r\n \"RoleService\",\r\n \"AuthService\",\r\n \"IntroducerService\",\r\n \"IntroducerSimpleService\",\r\n \"CaseSummaryService\",\r\n \"$cookies\",\r\n \"SelectListService\",\r\n ];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private $DevelopmentInputservice: DevelopmentInputService,\r\n private $DevelopmentInputWithNoLoginService: DevelopmentInputWithNoLoginService,\r\n private $user: UserService,\r\n private $CaseService: CaseService,\r\n private roleService: RoleService,\r\n private authService: AuthService,\r\n private $IntroducerService: IntroducerService,\r\n private $IntroducerSimpleService: IntroducerSimpleService,\r\n private $CaseSummaryService: CaseSummaryService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private selectListService: SelectListService,\r\n ) {\r\n this.initialise();\r\n this.referrerOptions = this.selectListService.GetReferrerOptions();\r\n }\r\n\r\n initialise() {\r\n //Introducers\r\n this.introducerFirstLogin = (this.$rootScope as any).introducerFirstLogin;\r\n //get type of user\r\n this.roleService.isBrokerOrABove().then((response) => {\r\n this.adminUser = response;\r\n this.authService.getProfile().then((prof) => {\r\n this.currentUser = prof;\r\n //If half-registered user hasn't set a password, then prompt them to set one\r\n if (this.currentUser.TemporaryAccount === true) {\r\n this.showSetPasswordModal = true;\r\n }\r\n\r\n //Get my introducer's details\r\n this.$IntroducerSimpleService.getintroducerdetails().then((i) => {\r\n this.introducerSimpleDetails = i;\r\n });\r\n\r\n this.introducerId = prof.RegisteredIntroducerId;\r\n if (prof.RegisteredIntroducerId) {\r\n this.updateIntroducedSearches(prof.RegisteredIntroducerId);\r\n //this.updateIntroducedClientList(prof.RegisteredIntroducerId);\r\n }\r\n this.updateResults();\r\n });\r\n });\r\n }\r\n\r\n isValidEmail() {\r\n var regex = /^([\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4})?$/;\r\n this.shareEmailsArray = this.shareEmails.replace(/\\s/g, \"\").split(/,|;/);\r\n for (var i = 0; i < this.shareEmailsArray.length; i++) {\r\n if (!regex.test(this.shareEmailsArray[i])) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n viewClientsDashboard(userName: string) {\r\n //Look up client's account details\r\n this.dataLoading = true;\r\n this.$user.searchByEmail(userName).then((users) => {\r\n this.selectedUser = users[0];\r\n this.selecteduserName = users[0].Email;\r\n (this.$rootScope as any).clientUsernameBeingViewed = users[0].Email;\r\n this.updateResults();\r\n this.clientAdminTools = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n exitClientView(): void {\r\n (this.$rootScope as any).clientUsernameBeingViewed = null;\r\n this.selecteduserName = this.currentUser.UserName;\r\n this.updateResults();\r\n this.clientAdminTools = true;\r\n }\r\n\r\n userLookup(userSearchTerm: string) {\r\n this.fetchingResults = true;\r\n this.$user\r\n .searchByEmail(userSearchTerm)\r\n .then((response) => {\r\n this.userSearchResults = response;\r\n })\r\n .finally(() => {\r\n this.fetchingResults = false;\r\n });\r\n }\r\n\r\n saveBlankSearch() {\r\n this.fetchingResults = true;\r\n let newDTO = {} as DevelopmentInputDTO;\r\n newDTO.OwnerUser = this.selecteduserName;\r\n newDTO.UserId = this.selectedUser.Id;\r\n newDTO.SaveQueryAndResults = true;\r\n newDTO.SearchName = this.newSearchName;\r\n newDTO.CI_Dev_Contingency = 0.05;\r\n this.$DevelopmentInputservice\r\n .addBlankSearch(newDTO)\r\n .then((response) => {\r\n this.$location.path(\"/criteria/\" + response.Id);\r\n })\r\n .finally(() => {\r\n this.fetchingResults = false;\r\n });\r\n }\r\n\r\n newBlankCase() {\r\n var currentdate = new Date();\r\n\r\n var SearchName =\r\n \"My Loan Search \" +\r\n currentdate.getDate() +\r\n \"/\" +\r\n (currentdate.getMonth() + 1) +\r\n \"/\" +\r\n currentdate.getFullYear();\r\n\r\n this.fetchingResults = true;\r\n let newDTO = {} as DevelopmentInputDTO;\r\n newDTO.OwnerUser = this.currentUser.UserName;\r\n newDTO.UserId = this.currentUser.Id;\r\n newDTO.SaveQueryAndResults = true;\r\n newDTO.SearchName = SearchName;\r\n newDTO.CI_Dev_Contingency = 0.05;\r\n this.$DevelopmentInputservice\r\n .saveSearch(newDTO)\r\n .then((response) => {\r\n newDTO.Id = response;\r\n this.makeCase(newDTO);\r\n })\r\n .finally(() => {\r\n this.fetchingResults = false;\r\n });\r\n }\r\n\r\n updateResults() {\r\n this.fetchingResults = true;\r\n let userForResults: string;\r\n if (this.selecteduserName) {\r\n userForResults = this.selecteduserName;\r\n } else if ((this.$rootScope as any).clientUsernameBeingViewed) {\r\n userForResults = (this.$rootScope as any).clientUsernameBeingViewed;\r\n } else {\r\n userForResults = this.currentUser.UserName;\r\n }\r\n this.selecteduserName = userForResults;\r\n if (this.selecteduserName !== this.currentUser.UserName) {\r\n this.$user.searchByEmail(this.selecteduserName).then((users) => {\r\n this.selectedUser = users[0];\r\n });\r\n }\r\n this.$DevelopmentInputservice\r\n .listbyusername(userForResults)\r\n .then((results) => {\r\n if (this.adminUser) {\r\n this.allResults = results;\r\n const distinct = (value: string, index: number, self: string[]) => {\r\n return self.indexOf(value) === index;\r\n };\r\n this.OtherUsers = this.allResults\r\n .map((s) => s.OwnerUser)\r\n .filter(distinct)\r\n .sort();\r\n this.allResults.map((s) => s.UserId);\r\n\r\n this.ApplyFilterOnUsers();\r\n } else {\r\n this.savedResults = results.filter((x) => !x.IsFullCase);\r\n this.savedCases = results.filter((x) => x.IsFullCase);\r\n }\r\n })\r\n .catch((error) => {})\r\n .finally(() => {\r\n this.fetchingResults = false;\r\n });\r\n }\r\n\r\n updateIntroducedSearches(RegisteredIntroducerId: number) {\r\n if (!RegisteredIntroducerId) {\r\n return;\r\n }\r\n this.$DevelopmentInputWithNoLoginService\r\n .fetchByIntroducerId(RegisteredIntroducerId)\r\n .then((results) => {\r\n this.unsavedIntroducedSearches = results.filter(\r\n (r) => r.IntroducedSearchStatus < 2,\r\n );\r\n let savedIntroducedSearchesIdentified = results.filter(\r\n (r) => r.IntroducedSearchStatus >= 2,\r\n );\r\n if (savedIntroducedSearchesIdentified.length > 0) {\r\n this.$DevelopmentInputservice\r\n .fetchByIntroducerId(RegisteredIntroducerId)\r\n .then((devInputResults) => {\r\n this.savedIntroducedSearches = devInputResults;\r\n });\r\n }\r\n\r\n this.updateIntroducedClientList();\r\n });\r\n }\r\n\r\n updateIntroducedClientList() {\r\n this.$user.getintroducees(this.currentUser.Id).then((introducedUsers) => {\r\n this.introducedUsers = introducedUsers;\r\n });\r\n }\r\n ApplyFilterOnUsers() {\r\n this.clientAdminTools = false;\r\n this.savedResults = this.allResults.filter(\r\n (x) => !x.IsFullCase && x.OwnerUser == this.selecteduserName,\r\n );\r\n this.savedCases = this.allResults.filter(\r\n (x) => x.IsFullCase && x.OwnerUser == this.selecteduserName,\r\n );\r\n (this.$rootScope as any).clientUsernameBeingViewed = this.selecteduserName;\r\n }\r\n\r\n makeCase(loanCriteria: DevelopmentInputDTO) {\r\n this.$CaseService\r\n .promotesearchtocase(loanCriteria.Id, null, null)\r\n .then((result: number) => {\r\n if (result) {\r\n loanCriteria.CaseId = result;\r\n this.savedCases.push(loanCriteria);\r\n this.savedResults.splice(this.savedResults.indexOf(loanCriteria), 1);\r\n loanCriteria.IsFullCase = true;\r\n }\r\n this.viewCase(loanCriteria);\r\n });\r\n }\r\n delete(loanCriteriaId: number, loanType: number, index: number) {\r\n switch (loanType) {\r\n case 0:\r\n //Full case\r\n this.$DevelopmentInputservice\r\n .markasdeleted(loanCriteriaId)\r\n .then((success) => {\r\n this.savedCases.splice(index, 1);\r\n });\r\n break;\r\n case 1:\r\n //Saved search\r\n this.$DevelopmentInputservice\r\n .markasdeleted(loanCriteriaId)\r\n .then((success) => {\r\n this.savedResults.splice(index, 1);\r\n });\r\n break;\r\n case 2:\r\n //Introducer: Referred search, not claimed by introducee yet\r\n this.$DevelopmentInputWithNoLoginService\r\n .markasdeleted(loanCriteriaId)\r\n .then((success) => {\r\n this.unsavedIntroducedSearches.splice(index, 1);\r\n });\r\n break;\r\n case 3:\r\n //Introducer: Referred search, claimed by introducee\r\n this.$DevelopmentInputservice\r\n .markasdeleted(loanCriteriaId)\r\n .then((success) => {\r\n this.savedIntroducedSearches.splice(index, 1);\r\n });\r\n break;\r\n }\r\n }\r\n viewCase(loanCriteria: DevelopmentInputDTO) {\r\n //this.$CaseService.getcasefromsearch(loanCriteria.Id).then((result) => {\r\n if (loanCriteria.IsFullCase && loanCriteria.CaseId) {\r\n this.$location.path(\"/casedashboard/\" + loanCriteria.CaseId);\r\n } else if (loanCriteria.Id) {\r\n this.$location.path(\"/results/\" + loanCriteria.Id);\r\n }\r\n //});\r\n }\r\n\r\n viewResults(loanCriteria: DevelopmentInputDTO) {\r\n if (loanCriteria.IsFullCase && loanCriteria.CaseId) {\r\n // this.$CaseService.getcasefromsearch(loanCriteria.Id).then((result) => {\r\n //need to tweak a bit when we have all the case status.\r\n this.$CaseService.updateTubeMap(loanCriteria.CaseStatus);\r\n this.$location.path(\r\n \"/results/\" + loanCriteria.Id + \"/\" + loanCriteria.CaseId,\r\n );\r\n //});\r\n } else if (loanCriteria.Id) {\r\n this.$location.path(\"/results/\" + loanCriteria.Id);\r\n }\r\n }\r\n viewIntroducedResults(loanCriteria: DevelopmentWithNoLoginDTO) {\r\n this.$location.path(\"/referredSearch/\" + loanCriteria.UniqueRef);\r\n }\r\n\r\n copy(developmentInputId: DevelopmentInputDTO) {\r\n this.$DevelopmentInputservice\r\n .copyCase(developmentInputId.Id, \"\")\r\n .then((response) => {\r\n let newDevelopmentInputId = response;\r\n if (newDevelopmentInputId) {\r\n this.viewCaseByDIId(newDevelopmentInputId);\r\n }\r\n })\r\n .finally(() => {\r\n this.fetchingResults = false;\r\n });\r\n }\r\n\r\n viewCaseByDIId(developmentInputId: number) {\r\n this.$CaseService.getcasefromsearch(developmentInputId).then((result) => {\r\n if (result) this.$location.path(\"/casedashboard/\" + result.Id);\r\n });\r\n }\r\n\r\n newloan() {\r\n (this.$rootScope as any).loanCriteria = null;\r\n this.$location.path(\"/criteria\");\r\n }\r\n\r\n registerIntroducer() {\r\n this.$location.path(\"/registerintroducer\");\r\n }\r\n\r\n //introduceClient() {\r\n // this.$IntroducerService.introduceClient(this.clientFirstName, this.clientEmail, this.clientSurname, this.clientPhoneNumber).then((success) => {\r\n // this.introduceClientModal = 2;\r\n // this.dataLoading = false;\r\n // });\r\n //}\r\n\r\n sendLinkToUser() {\r\n this.$IntroducerService\r\n .sendLinkToUser(\r\n this.currentUser.FirstName,\r\n this.currentUser.Email,\r\n this.currentUser.Id,\r\n )\r\n .then((success) => {\r\n this.introduceClientModal = 6;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n copyLinkToClipboard() {\r\n this.$IntroducerService\r\n .copyLinkToClipboard(this.currentUser.Id)\r\n .then((response) => {\r\n this.link = response.toString();\r\n navigator.clipboard.writeText(this.link);\r\n this.introduceClientModal = 7;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n /// changed the result type as number to avoid compilation error (sevice code has been changed for newdashboard)\r\n introducerSendResultsToClient(\r\n result: DevelopmentInputDTO,\r\n notifyBorrower: boolean = false,\r\n ) {\r\n this.dataLoading = true;\r\n this.$IntroducerService\r\n .sendResultsToClient(\r\n result,\r\n this.clientFirstName,\r\n this.clientSurname,\r\n this.clientEmail,\r\n notifyBorrower,\r\n )\r\n .then((success) => {\r\n this.introduceClientModal = 4;\r\n })\r\n .catch((reason) => {\r\n this.introducerErrorDisplayed = true;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n introducerSendResultsToMultipleClient(\r\n result: DevelopmentInputDTO,\r\n notifyBorrower: boolean = false,\r\n ) {\r\n for (let i = 0; i < this.shareEmailsArray.length; i++) {\r\n this.dataLoading = true;\r\n this.$IntroducerService\r\n .sendResultsToClient(\r\n result,\r\n \"\",\r\n \"\",\r\n this.shareEmailsArray[i],\r\n notifyBorrower,\r\n )\r\n .then((success) => {\r\n this.introduceClientModal = 4;\r\n })\r\n .catch((reason) => {\r\n this.introducerErrorDisplayed = true;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n delete this.shareEmails;\r\n });\r\n }\r\n }\r\n\r\n introducerRefreshSearchesAndClients() {\r\n //Trigger a refresh to show results\r\n this.updateIntroducedSearches(this.introducerId);\r\n this.clientAdminTools = true;\r\n }\r\n\r\n completeAccount() {\r\n this.currentUser.TemporaryAccount = false;\r\n this.currentUser.Roles = [];\r\n this.currentUser.Roles.push(\"Client\");\r\n if (this.currentUser.ApplicantDefinedRole == 0) {\r\n this.currentUser.NewUserEmailJourneyStarted = true;\r\n }\r\n this.$user.addUpdate(this.currentUser).then((response) => {\r\n this.passwordSetSuccess = true;\r\n });\r\n }\r\n\r\n afterSetPasswordContinue() {\r\n //User needs to be logged out and logged in again\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.authService.logout(false);\r\n }\r\n this.authService\r\n .login(\r\n this.currentUser.Email,\r\n this.currentUser.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n let expiry: Date = response;\r\n this.$cookies.put(\"user_firstname\", this.currentUser.FirstName, {\r\n expires: expiry,\r\n });\r\n this.showSetPasswordModal = false;\r\n this.initialise();\r\n });\r\n }\r\n}\r\n","export const enum FixedRateTermEnum {\r\n None = 0,\r\n TwoYear = 1,\r\n FiveYear = 2,\r\n TenYear = 3,\r\n}\r\n","import { AddressHistoryDTO } from \"@js/DTO/AddressHistoryDTO.cs.d\";\r\nimport { AddressLookupDTO } from \"@js/DTO/AddressLookupDTO.cs.d\";\r\nimport { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CaseChangedMessageDTO } from \"@js/DTO/CaseChangedMessageDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { CommercialDealDTO } from \"@js/DTO/Deal/CommercialDealDTO.cs.d\";\r\nimport { DealClientDTO } from \"@js/DTO/Deal/DealClientDTO.cs.d\";\r\nimport { DealFileAttachmentDTO } from \"@js/DTO/Deal/DealFileAttachmentDTO.cs.d\";\r\nimport { DealLenderDTO } from \"@js/DTO/Deal/DealLenderDTO.cs.d\";\r\nimport { DealNoteDTO } from \"@js/DTO/Deal/DealNoteDTO.cs.d\";\r\nimport { ExternalLinksDTO } from \"@js/DTO/ExternalLinksDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { LenderDTO } from \"@js/DTO/LenderDTO.cs.d\";\r\nimport { InvitedUserResponse } from \"@js/DTO/Messages/Deal/InvitedUserMessage.cs.d\";\r\nimport { LenderInfo } from \"@js/DTO/Messages/Deal/LendersInfoForSubmitToLenderMessage.cs.d\";\r\nimport { PromoteSearchToCaseResponse } from \"@js/DTO/Messages/Deal/PromoteSearchToCaseMessage.cs.d\";\r\nimport { SaveCommercialSearchRequest } from \"@js/DTO/Messages/Deal/SaveCommercialSearchMessage.cs.d\";\r\nimport { ShareModuleRequest } from \"@js/DTO/Messages/Deal/ShareModuleMessage.cs.d\";\r\nimport { SubmitToLendersRequest } from \"@js/DTO/Messages/Deal/SubmitToLendersMessage.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { AppraisalModuleEnum } from \"@js/models/enum/AppraisalModuleEnum.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { FixedRateTermEnum } from \"@js/models/enum/FixedRateTermEnum.cs.d\";\r\nimport { InterestRateTypeEnum } from \"@js/models/enum/InterestRateTypeEnum.cs.d\";\r\nimport { LenderProductTypeEnum } from \"@js/models/enum/LenderProductTypeEnum.cs.d\";\r\nimport { LicenseMasterStatusEnum } from \"@js/models/enum/LicenseMasterStatusEnum.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { OwnNewDevelopmentEnum } from \"@js/models/enum/OwnNewDevelopmentEnum.cs.d\";\r\nimport { OwnOrPurchaseEnum } from \"@js/models/enum/OwnOrPurchaseEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { TenureEnum } from \"@js/models/enum/TenureEnum.cs.d\";\r\nimport { TitleEnum } from \"@js/models/enum/TitleEnum.cs.d\";\r\nimport { YesNoMaybe } from \"@js/models/enum/YesNoMaybeEnum.cs.d\";\r\nimport { PostalAddress } from \"@js/models/PostalAddress.cs.d\";\r\nimport { AccountService } from \"@js/services/AccountService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { CommercialDealService } from \"@js/services/Deal/CommercialDealService\";\r\nimport { DealLenderService } from \"@js/services/Deal/DealLenderService\";\r\nimport { DealNoteService } from \"@js/services/Deal/DealNoteService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { SharedDealService } from \"@js/services/Deal/SharedDealService\";\r\nimport { DealClientService } from \"@js/services/DealClientService\";\r\nimport { DealFileAttachmentService } from \"@js/services/DealFileAttachmentService\";\r\nimport { ExternalLinksService } from \"@js/services/ExternalLinksService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { StreetAddressService } from \"@js/services/StreetAddressService\";\r\nimport angular from \"angular\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { EventLogEnum } from \"@js/models/enum/EventLogEnum.cs.d\";\r\n\r\ninterface LeaseItemDetails {\r\n TimeLeftOnLeaseYears?: number;\r\n TimeLeftOnLeaseMonths?: number;\r\n GrossMonthlyRentalIncome: \"\";\r\n}\r\n\r\nexport class CommercialCaseController {\r\n isCaseDashboard: boolean = true;\r\n\r\n dataLoading: boolean;\r\n currentUser: ApplicationUserDTO;\r\n dealId: number;\r\n dealDto: CommercialDealDTO;\r\n tempDealDto: CommercialDealDTO;\r\n orgName: string;\r\n orgId: number;\r\n org: OrganisationDTO;\r\n fileNamePrefix: string = \"Brickflow\";\r\n newNote: DealNoteDTO = {} as DealNoteDTO;\r\n mortgageTerm: number = 0;\r\n\r\n CaseDashboardTypeEnum = {\r\n Overview: 0,\r\n Borrower: 1,\r\n Property: 2,\r\n Loan: 3,\r\n };\r\n\r\n selectedNavMenu: number = 0;\r\n\r\n dealForm: ng.IFormController;\r\n ownershipForm: ng.IFormController;\r\n companyDetailsForm: ng.IFormController;\r\n propertyDetailsForm: ng.IFormController;\r\n loanDetailsForm: ng.IFormController;\r\n personalDetailsForm: ng.IFormController;\r\n contactForm: ng.IFormController;\r\n occupationForm: ng.IFormController;\r\n creditForm: ng.IFormController;\r\n lenderDetailsForm: ng.IFormController;\r\n\r\n showAddressHistoryModal: boolean = false;\r\n\r\n tabs = {\r\n tabOpen: false,\r\n ownership: false,\r\n companyDetails: false,\r\n personalDetails: false,\r\n contactDetails: false,\r\n occupation: false,\r\n credit: false,\r\n };\r\n\r\n ownershipType: string = \"\";\r\n\r\n leaseItems: LeaseItemDetails[] = [];\r\n\r\n currentApplicant: DealClientDTO;\r\n tempApplicant: DealClientDTO;\r\n applicantList: DealClientDTO[] = [];\r\n appName: string;\r\n\r\n searchterm: string;\r\n previousAddressSearchTerm: string;\r\n PostCodeOptions: PostalAddress[] = [];\r\n previousAddressPostCodeOptions: PostalAddress[] = [];\r\n address: PostalAddress;\r\n searchingForAddress: boolean = false;\r\n searchingForPreviousAddress: boolean = false;\r\n searchresults: string = \"\";\r\n previousAddressSearchResults: string[];\r\n addressHistoryItem: AddressHistoryDTO;\r\n applicantAddressHistory: AddressHistoryDTO[] = [];\r\n\r\n propertyTypeOptions = [];\r\n tenureTypes = [];\r\n maritalStatusOptions = [];\r\n ownOrPurchaseOptions = [];\r\n ownNewDevelopmentOptions = [];\r\n yesNoOptions = [];\r\n planningOptions = [];\r\n titleOptions = [];\r\n ownershipRoleOptions = [];\r\n countryList = [];\r\n nationalityList = [];\r\n countryOfBirthList = [];\r\n countryOfResidenceList = [];\r\n loanCompletionTypeOptions = [];\r\n currentUseofBuildingOptions = [];\r\n loanRepaymentTypeOptions = [];\r\n productTypeOptions = [];\r\n fixedrateTermOptions = [];\r\n locationOptions = [];\r\n borrowingEntityTypeOptions = [];\r\n //modal\r\n message: string = \"\";\r\n modal: boolean = false;\r\n showErrorMessage: boolean = false;\r\n\r\n uploadingFiles: FileUploadProgressDTO[];\r\n fileUpload: DealFileAttachmentDTO[];\r\n total: number = 0;\r\n renamingFile: DealFileAttachmentDTO;\r\n\r\n // Number of note shown on the casedashboard\r\n maxNotes: number = 4;\r\n\r\n // Controls showing Ts & Cs when a borrower/broker submits to lenders\r\n showTsAndCs: boolean = false;\r\n showApplyTsAndCs: boolean = false;\r\n showRequestEmailForm: boolean = false;\r\n requestMessageReason: string = \"\";\r\n showTsAndCsForm: boolean = false;\r\n sendingMessage: boolean = false;\r\n messagebool: boolean = false;\r\n invalidEmail: boolean = false;\r\n\r\n isBroker: boolean = false;\r\n isAdmin: boolean = false;\r\n isLender: boolean = false;\r\n isClient: boolean = false;\r\n isSubmitted: boolean = false;\r\n\r\n isSubmittedToLenders: boolean = false;\r\n messageContent: string;\r\n dealLender: DealLenderDTO;\r\n\r\n //Boolean to enable a re-submit button\r\n hasShortlistedDealLenders: boolean = false;\r\n\r\n caseStatusOptions = [];\r\n caseStatusText: string = \"\";\r\n caseOverview: string;\r\n\r\n selectedLendersName: string = \"\";\r\n shortlistedLendersName: string = \"\";\r\n lendersDetailsForSubmittoLenders: LenderInfo[];\r\n shortListedLendersId: Number[];\r\n\r\n //Sharing case\r\n shareContext: AppraisalModuleEnum = null;\r\n caseMembersWithAccess: ClientDTO[];\r\n showShare: boolean = false;\r\n selectedClientToShareWith: ClientDTO;\r\n shareNote: string;\r\n showModuleShareConfirmation: boolean;\r\n\r\n //show profile view\r\n showAppraisalPermission: boolean = false;\r\n\r\n //profile\r\n newApplicant: DealClientDTO;\r\n\r\n maxDateOfBirth: Date = new Date();\r\n minDateOfBirth: Date = new Date(\"Jan 01 1900\");\r\n maxDateForDateField: Date = new Date(\"Jan 01 3000\");\r\n showAddorEdit: boolean = false;\r\n disableQuickEditSave: boolean = false;\r\n applicantForm: ng.IFormController;\r\n isAddShareholder: boolean;\r\n showDelete: boolean = false;\r\n confirmDeleteApplicant: DealClientDTO;\r\n\r\n showExport: boolean = false;\r\n updatingName: boolean = false;\r\n orginalDealName: string;\r\n\r\n showAddHistoryConfirmDelete: boolean = false;\r\n addressHistoryIdToDelete: number;\r\n\r\n isLoggedInUser: boolean = false;\r\n\r\n showDeal: boolean = true;\r\n classUses: {} = {};\r\n\r\n tinymceOptions: any;\r\n tinymceReadonlyOptions: any;\r\n missingAddressGaps: string[];\r\n\r\n ownOrPurchase: boolean;\r\n isFamilyInResidence: boolean;\r\n\r\n dateProperties = [\"ExpiryDate\"];\r\n\r\n profileDateProperties = [\r\n \"DateOfBirth\",\r\n \"CurrentAddressFrom\",\r\n \"UkResidenceIssueDate\",\r\n \"CurrentEmploymentStartDate\",\r\n \"AddressStartDate\",\r\n ];\r\n\r\n dealDateProperties = [\r\n \"OriginalPurchaseDate\",\r\n \"CompletionDate\",\r\n \"TradingStartDate\",\r\n ];\r\n\r\n clientDateProperties = [\"DateOfBirth\"];\r\n\r\n maxPurchaseDate: Date = new Date();\r\n minPurchaseDate: Date = new Date(\"Jan 01 1900\");\r\n dealProductTypeDisplayText: string;\r\n isInActiveLender: boolean = false;\r\n totalGrossMonthlyRentalIncome: number = 0;\r\n isGrossMonthlyRentalIncomeMatch: boolean = true;\r\n\r\n //SubmitToLender modal\r\n brokerCommission: number;\r\n brokerPreferredContact: string;\r\n isBrokerPhoneNumberUpdated: boolean = false;\r\n dealBrokerUser: ApplicationUserDTO;\r\n\r\n totalUnreadDealLenderMessages: number = null;\r\n\r\n //Lender Portal Links\r\n dealLenders: DealLenderDTO[];\r\n dealLendersWithPortalLinkEnabled: DealLenderDTO[];\r\n lendersWithPortalLinkEnabled: LenderDTO[];\r\n showLenderPortalLinks: boolean = false;\r\n portalLinks: {} = {};\r\n borrowerDetails: UserSimpleDTO;\r\n applicationForm: ng.IFormController;\r\n portalLinkDetailsAdded: {} = {};\r\n\r\n //property for roles directive to handle referred readonly view for broker/connect broker\r\n isReadOnlyDeal: boolean = true;\r\n hasFirstLoadOccurred: boolean = false;\r\n referredPackagerText: string;\r\n\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$location\",\r\n \"$cookies\",\r\n \"AccountService\",\r\n \"StreetAddressService\",\r\n \"CommercialDealService\",\r\n \"DealNoteService\",\r\n \"AuthService\",\r\n \"SelectListService\",\r\n \"RoleService\",\r\n \"LenderService\",\r\n \"CaseService\",\r\n \"DealLenderService\",\r\n \"DealFileAttachmentService\",\r\n \"$window\",\r\n \"ExternalLinksService\",\r\n \"DealClientService\",\r\n \"OrganisationService\",\r\n \"$scope\",\r\n \"$sce\",\r\n \"DealService\",\r\n \"SharedDealService\",\r\n \"ProductService\",\r\n \"EventLogService\"\r\n ];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $accountservice: AccountService,\r\n private $streetAddressService: StreetAddressService,\r\n private commercialDealService: CommercialDealService,\r\n private dealNoteService: DealNoteService,\r\n private authService: AuthService,\r\n private selectListService: SelectListService,\r\n private roleService: RoleService,\r\n private $lenderService: LenderService,\r\n private caseService: CaseService,\r\n private dealLenderService: DealLenderService,\r\n private dealFileAttachmentService: DealFileAttachmentService,\r\n private $window: ng.IWindowService,\r\n private $externalLinksService: ExternalLinksService,\r\n private dealClientService: DealClientService,\r\n private organisationService: OrganisationService,\r\n private $scope: ng.IScope,\r\n private $sce: ng.ISCEService,\r\n private dealService: DealService,\r\n private sharedDealService: SharedDealService,\r\n private productService: ProductService,\r\n private eventLogService: EventLogService\r\n ) {\r\n if ($cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n }\r\n this.tinymceOptions = this.sharedDealService.tinymceOptions;\r\n this.tinymceReadonlyOptions = angular.copy(this.tinymceOptions);\r\n this.tinymceReadonlyOptions.readonly = 1;\r\n this.roleService.GetUserRoles().then((result) => {\r\n if (result.filter((x) => x.toLowerCase() == \"client\").length > 0) {\r\n this.isClient = true;\r\n } else {\r\n this.isClient = false;\r\n }\r\n });\r\n\r\n if (this.$routeParams.DealId) {\r\n this.dataLoading = true;\r\n\r\n this.dealId = this.$routeParams.DealId;\r\n if (\r\n this.$routeParams.Promote &&\r\n this.$routeParams.Promote != \"null\" &&\r\n !this.dealDto\r\n ) {\r\n var promote = this.$routeParams.Promote as boolean;\r\n this.isReadOnlyDeal = false;\r\n this.hasFirstLoadOccurred = true;\r\n if (promote) {\r\n this.promoteSearchToCase();\r\n }\r\n } else {\r\n this.dealService\r\n .fetchByDealId(this.$routeParams.DealId, ProductFamilyEnum.Commercial, true)\r\n .then((response) => {\r\n\r\n // The case was a pre-existing case when the broker org became a member of Connect and therefore was archived.\r\n if (response.CommercialDealDto.IsPreConnectArchived) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n\r\n //Below properties are very imp for view roles directive \r\n this.isReadOnlyDeal = response.IsReadOnlyDealForBroker;\r\n this.referredPackagerText = response.ReferredPackagerText;\r\n\r\n this.hasFirstLoadOccurred = true;\r\n if (response.HideCommercialDeal) {\r\n this.showDeal = false;\r\n } else {\r\n this.dealDto = response.CommercialDealDto;\r\n this.shortlistedLendersName = response.ShortlistedLendersName;\r\n this.selectedLendersName = response.SelectedLendersName;\r\n this.shortListedLendersId = response.ShortlistedLendersId;\r\n this.parseLeaseDetails(this.dealDto.LeaseDetails);\r\n this.totalUnreadDealLenderMessages =\r\n response.TotalUnreadDealLenderMessages;\r\n\r\n if (this.dealDto) {\r\n this.orgId = this.dealDto.BrokerOrganisationId;\r\n\r\n if (this.dealDto.ProjectDescription) {\r\n this.caseOverview = this.dealDto.ProjectDescription;\r\n }\r\n\r\n this.postRetrieveProcessing();\r\n\r\n var newShortlist = this.$routeParams.NewShortlist as boolean;\r\n if (newShortlist) this.getLenderPortalLinks();\r\n } else {\r\n // If no case is returned, this could be that the logged in user has been removed from the case\r\n // - only do this if there is a logged in user, otherwise let the routing sort out where the redirect should go\r\n if ((this.$rootScope as any).selectedUser) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n this.countryOfBirthList = this.countryOfResidenceList =\r\n this.selectListService.GetCountries();\r\n this.nationalityList = this.selectListService.GetNationalities();\r\n this.ownOrPurchaseOptions = this.selectListService.GetOwnOrPurchase();\r\n this.maritalStatusOptions =\r\n this.selectListService.GetMaritalStatusOptions();\r\n this.propertyTypeOptions = this.selectListService.GetPropertyType();\r\n this.ownNewDevelopmentOptions =\r\n this.selectListService.GetCommercialOwnNewDevelopmentOptions();\r\n this.yesNoOptions = this.selectListService.GetYesNoForBridging();\r\n this.titleOptions = this.selectListService.GetTitleOptions();\r\n this.loanCompletionTypeOptions =\r\n this.selectListService.GetLoanCompletionOptions();\r\n this.loanRepaymentTypeOptions =\r\n this.selectListService.GetLoanRepaymentTypeOptions();\r\n this.productTypeOptions = this.selectListService.GetInterestRateType();\r\n this.fixedrateTermOptions =\r\n this.selectListService.GetFixedRateTermOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n this.getAppName();\r\n }\r\n\r\n\r\n getRequiredRoles(isCaseDashboard: boolean) {\r\n if (isCaseDashboard) {\r\n if (this.isReadOnlyDeal) {\r\n return `['Admin', 'Client']`;\r\n } else {\r\n return `['Admin', 'Client', 'Broker', 'Introducer']`;\r\n }\r\n }\r\n return `['Admin', 'Client', 'Broker', 'Introducer', 'Lender']`;\r\n }\r\n\r\n editDealName() {\r\n var name = this.dealDto.Name;\r\n this.orginalDealName = name;\r\n this.updatingName = true;\r\n }\r\n\r\n cancelEditDealName() {\r\n this.updatingName = false;\r\n this.dealDto.Name = this.orginalDealName;\r\n }\r\n\r\n /**Gets the Case Status display text */\r\n getCaseStatusDisplayText() {\r\n var statusItem = null;\r\n\r\n if (this.isLender) {\r\n statusItem = this.caseStatusOptions.find(\r\n (statusOption) => this.dealLender.Status == statusOption.key,\r\n );\r\n } else {\r\n statusItem = this.caseStatusOptions.find(\r\n (statusOption) => this.dealDto.Status == statusOption.key,\r\n );\r\n }\r\n\r\n this.caseStatusText = statusItem.displayName;\r\n }\r\n\r\n postRetrieveProcessing() {\r\n if (this.$routeParams.selectedNavMenu) {\r\n this.selectedNavMenu = this.$routeParams.selectedNavMenu;\r\n }\r\n\r\n this.dealLenderService\r\n .fetchByDealId(this.$routeParams.DealId)\r\n .then((dls: DealLenderDTO[]) => {\r\n this.hasShortlistedDealLenders = dls.some(\r\n (dl) => dl.Status == CaseLenderStateEnum.Shortlisted,\r\n );\r\n });\r\n\r\n //These are used for directive.\r\n (this.$rootScope as any).statusRequirementId = this.dealDto.Id;\r\n this.caseService.updateCaseState(this.dealDto.Id, this.dealDto.Status);\r\n this.getCurrentUserAndRoles();\r\n this.fileUpload = this.dealDto.Attachments;\r\n this.applicantList = this.dealDto.DealClients;\r\n\r\n this.dealProductTypeDisplayText =\r\n this.productService.getProductTypeDisplayText(this.dealDto.ProductType);\r\n this.tenureTypes = this.selectListService.GetTenureTypes(\r\n this.dealDto.ProductType,\r\n );\r\n this.currentUseofBuildingOptions =\r\n this.selectListService.GetCommercialCurrentUseOfBuildingOptions(\r\n this.dealDto.ProductType,\r\n );\r\n this.borrowingEntityTypeOptions =\r\n this.selectListService.GetBorrowingEntityTypeOptions(\r\n this.dealDto.ProductType,\r\n );\r\n this.ownershipRoleOptions = this.selectListService.GetOwnershipRoleOptions(\r\n this.dealDto.ProductType,\r\n );\r\n\r\n if (this.dealDto.BrokerOrganisationId) {\r\n this.getOrganisationbyDealId();\r\n }\r\n }\r\n\r\n keyPressEvent(event) {\r\n if (event.key === \"Enter\") {\r\n this.updatingName = false;\r\n this.submitForm(this.dealForm);\r\n }\r\n if (event.key === \"Escape\") {\r\n this.updatingName = false;\r\n }\r\n }\r\n\r\n submitForm(form: ng.IFormController) {\r\n this.dataLoading = true;\r\n\r\n var request: SaveCommercialSearchRequest = {\r\n DealDto: this.dealDto,\r\n ShareDealDto: null,\r\n OrgCode: \"\",\r\n EnterpriseClientDto: null,\r\n };\r\n\r\n if (this.leaseItems != null && this.leaseItems.length > 0) {\r\n this.dealDto.LeaseDetails = JSON.stringify(this.leaseItems);\r\n } else {\r\n this.dealDto.LeaseDetails = \"\";\r\n }\r\n\r\n this.commercialDealService\r\n .saveCommercialSearchReturnsId(request)\r\n .then((response) => {\r\n if (response != null) {\r\n this.closeTabs();\r\n form.$setPristine();\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n onTradingStartDateChange() {\r\n this.dealDto.TradingStartDate = this.modifyDateForBackend(\r\n this.dealDto.TradingStartDate,\r\n );\r\n }\r\n\r\n closeModalAndGoToDasboard() {\r\n this.showTsAndCs = false;\r\n this.authService.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n closeModalAndGoToDealForum() {\r\n this.showTsAndCs = false;\r\n this.$location.path(\"/dealforum/\" + this.dealDto.Id);\r\n }\r\n\r\n closeModal(test: number) {\r\n this.messagebool = false;\r\n }\r\n\r\n closeTabs() {\r\n for (let key in this.tabs) {\r\n this.tabs[key] = false;\r\n }\r\n }\r\n\r\n discardOwnership() {\r\n this.dealDto.HowWillYouOwnNewDevelopment = null;\r\n //this.companyDetails.temp = null;\r\n this.dealDto.ExcludedLenders = null;\r\n this.dealDto.HasTheCompanyOrPensionBeenFormedYet = null;\r\n }\r\n\r\n gotoApplicant(applicant?: DealClientDTO) {\r\n this.currentApplicant = applicant || null;\r\n this.PostCodeOptions = null;\r\n\r\n if (\r\n this.currentApplicant &&\r\n this.currentApplicant.Profile &&\r\n this.currentApplicant.Profile.AddressHistory &&\r\n this.currentApplicant.Profile.AddressHistory.length > 0\r\n ) {\r\n this.parseAddressHistory(this.currentApplicant.Profile.AddressHistory);\r\n } else {\r\n this.applicantAddressHistory = [];\r\n }\r\n\r\n this.selectedNavMenu = 4;\r\n this.closeTabs();\r\n }\r\n\r\n getOwnershipTypeText(): string {\r\n var ownershipTypeText;\r\n\r\n if (this.dealDto && this.dealDto.HowWillYouOwnNewDevelopment) {\r\n switch (this.dealDto.HowWillYouOwnNewDevelopment) {\r\n case OwnNewDevelopmentEnum.UKLimitedCompany:\r\n this.ownershipType = ownershipTypeText = \"Company\";\r\n break;\r\n case OwnNewDevelopmentEnum.OverseasLimitedCompany:\r\n this.ownershipType = ownershipTypeText = \"Overseas Company\";\r\n break;\r\n case OwnNewDevelopmentEnum.PensionFund:\r\n this.ownershipType = ownershipTypeText = \"Pension Fund\";\r\n break;\r\n case OwnNewDevelopmentEnum.UKLimitedLiabilityPartnership:\r\n ownershipTypeText = \"Limited Liability Partnership\";\r\n this.ownershipType = \"Partnership\";\r\n break;\r\n default:\r\n ownershipTypeText = \"\";\r\n }\r\n return ownershipTypeText;\r\n }\r\n return \"\";\r\n }\r\n\r\n openAddressHistoryModal(addressHistory: AddressHistoryDTO = null) {\r\n this.previousAddressSearchResults = [];\r\n this.previousAddressPostCodeOptions = [];\r\n\r\n if (addressHistory) {\r\n this.addressHistoryItem = addressHistory;\r\n } else {\r\n this.addressHistoryItem = null;\r\n }\r\n\r\n this.showAddressHistoryModal = true;\r\n }\r\n\r\n addressHistoryComplete() {\r\n return this.sharedDealService.addressHistoryComplete(\r\n this.currentApplicant,\r\n this.applicantAddressHistory,\r\n this.missingAddressGaps,\r\n );\r\n }\r\n\r\n getAddressList(searchTerm: string, postalAddress: PostalAddress) {\r\n let foundMatch = false;\r\n\r\n if (this.PostCodeOptions && this.PostCodeOptions.length > 0) {\r\n let addressLookup = this.PostCodeOptions.find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n this.$streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n for (let prop in address) {\r\n if (address.hasOwnProperty(prop)) {\r\n postalAddress[prop] = address[prop];\r\n }\r\n }\r\n this.searchterm = \"\";\r\n this.searchresults = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n postalAddress.AddressLine1 = addressLookup.AddressLine2.replace(\r\n addressLookup.AddressLine2.substring(\r\n addressLookup.AddressLine2.indexOf(\"-\") - 1,\r\n ),\r\n \"\",\r\n );\r\n postalAddress.AddressLine2 = addressLookup.AddressLine3;\r\n postalAddress.PostCode = addressLookup.AddressLine1;\r\n this.searchterm = \"\";\r\n this.searchresults = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n this.PostCodeOptions = [];\r\n\r\n this.$streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.PostCodeOptions = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n lookupPreviousAddress(searchTerm: string) {\r\n let foundMatch = false;\r\n\r\n if (\r\n this.previousAddressPostCodeOptions &&\r\n this.previousAddressPostCodeOptions &&\r\n this.previousAddressPostCodeOptions.length > 0\r\n ) {\r\n let addressLookup = this.previousAddressPostCodeOptions.find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n\r\n // We've selected an address!\r\n this.$streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n this.addressHistoryItem = {\r\n AddressLine1: address.AddressLine1,\r\n AddressLine2: address.AddressLine2,\r\n AddressLine3: address.AddressLine3,\r\n AddressLine4: address.AddressLine4,\r\n PostCode: address.PostCode,\r\n };\r\n\r\n this.previousAddressSearchTerm = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n this.addressHistoryItem = {\r\n AddressLine1: addressLookup.AddressLine2,\r\n AddressLine2: addressLookup.AddressLine3,\r\n AddressLine3: addressLookup.AddressLine4,\r\n AddressLine4: addressLookup.PostCode,\r\n PostCode: addressLookup.AddressLine1,\r\n };\r\n\r\n this.previousAddressSearchTerm = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n // Initial search term\r\n this.previousAddressPostCodeOptions = [];\r\n\r\n this.$streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.previousAddressPostCodeOptions = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n saveAddressHistory(selectedApplicant: DealClientDTO) {\r\n var id: number = 0;\r\n\r\n if (!this.applicantAddressHistory) {\r\n this.applicantAddressHistory = [];\r\n }\r\n\r\n // If the Id hasn't been set then this is a new previous address\r\n if (this.addressHistoryItem.Id == null) {\r\n id = this.getNextAddressHistoryId();\r\n this.addressHistoryItem.Id = id;\r\n this.applicantAddressHistory.push(this.addressHistoryItem);\r\n } else {\r\n var foundIndex = this.applicantAddressHistory\r\n .map(function (a) {\r\n return a.Id;\r\n })\r\n .indexOf(this.addressHistoryItem.Id);\r\n if (foundIndex > -1) {\r\n this.applicantAddressHistory.splice(\r\n foundIndex,\r\n 1,\r\n this.addressHistoryItem,\r\n ); // removed previous entry and adds the updated one in its place\r\n }\r\n }\r\n\r\n this.dealClientService\r\n .saveAddressHistory(\r\n selectedApplicant.Id,\r\n JSON.stringify(this.applicantAddressHistory),\r\n )\r\n .then((addressHistory: string) => {\r\n selectedApplicant.Profile.AddressHistory = addressHistory;\r\n this.parseAddressHistory(addressHistory);\r\n this.showAddressHistoryModal = false;\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem saving the address history. Please try again later.\";\r\n })\r\n .finally(() => {\r\n this.showAddressHistoryModal = false;\r\n });\r\n }\r\n\r\n /**\r\n * Convert addres history JSON back to an array of PostalAddress objects\r\n * @param addressHistoryJson\r\n */\r\n parseAddressHistory(addressHistoryJson: string) {\r\n // JSON doesn't understand date types so therefore user the reviver function to manually convert them back to dates as opposed to strings\r\n this.applicantAddressHistory = JSON.parse(addressHistoryJson, this.sharedDealService.reviver);\r\n\r\n // Order the address histories by the from date (ascending)\r\n this.applicantAddressHistory.sort(\r\n (a: AddressHistoryDTO, b: AddressHistoryDTO) => {\r\n return this.sharedDealService.getTime(a.FromDate) - this.sharedDealService.getTime(b.FromDate);\r\n },\r\n );\r\n }\r\n\r\n getAddressAsString(address: PostalAddress) {\r\n return this.sharedDealService.getAddressAsString(address);\r\n }\r\n\r\n showConfirmAddressDelete(addressHistoryId: number) {\r\n this.showAddHistoryConfirmDelete = true;\r\n this.addressHistoryIdToDelete = addressHistoryId;\r\n }\r\n\r\n deleteAddressHistory() {\r\n this.showAddHistoryConfirmDelete = false;\r\n\r\n var foundIndex = this.applicantAddressHistory\r\n .map(function (a) {\r\n return a.Id;\r\n })\r\n .indexOf(this.addressHistoryIdToDelete);\r\n\r\n if (foundIndex > -1) {\r\n this.applicantAddressHistory.splice(foundIndex, 1);\r\n\r\n this.dealClientService\r\n .saveAddressHistory(\r\n this.currentApplicant.Id,\r\n JSON.stringify(this.applicantAddressHistory),\r\n )\r\n .then((addressHistory: string) => {\r\n this.currentApplicant.Profile.AddressHistory = addressHistory;\r\n this.parseAddressHistory(addressHistory);\r\n this.showAddressHistoryModal = false;\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem deleting the address history item. Please try again later.\";\r\n });\r\n }\r\n }\r\n\r\n getNextAddressHistoryId(): number {\r\n return this.sharedDealService.getNextAddressHistoryId(\r\n this.applicantAddressHistory,\r\n );\r\n }\r\n\r\n /** Promotes/converts a search to a case */\r\n promoteSearchToCase() {\r\n this.dealService\r\n .promoteSearchToCase(this.dealId, ProductFamilyEnum.Commercial)\r\n .then((response: PromoteSearchToCaseResponse) => {\r\n if (response != null && response.CommercialDealDto != null) {\r\n this.dealDto = response.CommercialDealDto;\r\n this.shortlistedLendersName = response.ShortlistedLendersName;\r\n this.selectedLendersName = response.SelectedLendersName;\r\n this.shortListedLendersId = response.ShortlistedLendersId;\r\n this.postRetrieveProcessing();\r\n this.getCurrentUserAndRoles();\r\n } else {\r\n this.message =\r\n \"Problem while promoting a search to case, please try after some time.\";\r\n this.showErrorMessage = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.getLenderPortalLinks();\r\n });\r\n }\r\n\r\n getLenderPortalLinks() {\r\n this.dealLenderService\r\n .fetchByDealId(this.$routeParams.DealId)\r\n .then((dls: DealLenderDTO[]) => {\r\n this.dealLenders = dls;\r\n var searchChanged = this.$routeParams.SearchChanged;\r\n const lenderIds = dls\r\n .filter(\r\n (dl) =>\r\n !dl.HasAppliedInLenderPortal &&\r\n (dl.Status === CaseLenderStateEnum.Shortlisted ||\r\n searchChanged == \"true\"),\r\n )\r\n .map((dl) => dl.LenderId);\r\n return this.$lenderService.getLenderPortalLinks(lenderIds);\r\n })\r\n .then((links) => {\r\n this.portalLinks = links;\r\n })\r\n .catch((error) => {\r\n this.message = \"Error fetching lender portal links: \" + error;\r\n this.portalLinks = null;\r\n })\r\n .finally(() => {\r\n this.showLenderPortalLinks = Object.keys(this.portalLinks).length > 0;\r\n });\r\n }\r\n\r\n openPortalLink(dealLenderId: number, url: string) {\r\n if (!this.portalLinkDetailsAdded[dealLenderId]) {\r\n this.dealLenderService\r\n .addLenderPortalLinkDetails(dealLenderId, this.borrowerDetails)\r\n .then(() => {\r\n this.portalLinkDetailsAdded[dealLenderId] = true;\r\n this.openUrl(url);\r\n })\r\n .catch((error) => {\r\n console.error(\"Error adding lender portal link details:\", error);\r\n });\r\n } else {\r\n this.openUrl(url);\r\n }\r\n }\r\n\r\n private openUrl(url: string) {\r\n if (!/^https?:\\/\\//i.test(url)) {\r\n url = \"http://\" + url;\r\n }\r\n window.open(url, \"_blank\");\r\n }\r\n\r\n saveNote(): void {\r\n this.newNote.DealId = this.dealDto.Id;\r\n this.newNote.UserId = this.currentUser.Id;\r\n\r\n this.dataLoading = true;\r\n this.dealNoteService\r\n .addUpdate(this.newNote)\r\n .then((response) => {\r\n this.dealDto.DealNotes.push(response);\r\n this.newNote = {\r\n DealId: this.dealDto.Id,\r\n UserId: this.currentUser.Id,\r\n } as DealNoteDTO;\r\n this.dealForm.$setPristine();\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n saveOverview(): void {\r\n this.dealDto.ProjectDescription = this.caseOverview;\r\n this.submitForm(this.dealForm);\r\n }\r\n\r\n gotoResultpage() {\r\n this.showErrorMessage = false;\r\n this.$location.path(\"/commercialresults/\" + this.dealId);\r\n }\r\n\r\n onFileSelect(files) {\r\n var module = ModuleEnum.Case;\r\n\r\n this.dealFileAttachmentService\r\n .UploadFileListInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.dealDto.Id,\r\n this.fileUpload,\r\n module,\r\n )\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n calculateTotalFilesRemoving(filter: number) {\r\n if (this.fileUpload) {\r\n this.total = this.fileUpload.filter(\r\n (item) => item.Module != filter,\r\n ).length;\r\n }\r\n return this.total;\r\n }\r\n\r\n downloadFile(file: DealFileAttachmentDTO, downloadFile: boolean = false) {\r\n this.dataLoading = true;\r\n this.dealFileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n if (downloadFile) {\r\n this.sharedDealService.downloadFile(uri, file.FileName);\r\n } else {\r\n this.$window.open(uri);\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n renameFile(file: DealFileAttachmentDTO) {\r\n if (this.renamingFile === undefined) {\r\n // if renaming this file will dirty the case, we'll want to set it back to pristine when we're done.\r\n // this.renamingFileDirties = !$scope.caseForm.$dirty;\r\n this.renamingFile = file;\r\n } else {\r\n delete this.renamingFile;\r\n }\r\n }\r\n renamingFileComplete(file: DealFileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.dealFileAttachmentService\r\n .renameFile(file)\r\n .then((response) => {\r\n file.TempURL = response.TempURL;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n delete this.renamingFile;\r\n }\r\n\r\n renamingLinkCompleted(link: ExternalLinksDTO) {\r\n this.dataLoading = true;\r\n this.$externalLinksService\r\n .addUpdate(link)\r\n .then((response) => {\r\n link.Link = response.Link;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n delete this.renamingFile;\r\n }\r\n\r\n deleteFile(file: DealFileAttachmentDTO) {\r\n this.dealDto.Attachments.splice(this.dealDto.Attachments.indexOf(file), 1);\r\n this.dealFileAttachmentService.markasdeleted(file.Id).then((result) => { }); //remove on the server\r\n }\r\n\r\n markSectionAsComplete(propertyName: string) {\r\n if (this.dataLoading == false) {\r\n this.dataLoading = true;\r\n\r\n this.dealDto.IsLoanSectionComplete;\r\n\r\n this.dealService\r\n .markSectionAsComplete(\r\n this.dealDto.Id,\r\n propertyName,\r\n ProductFamilyEnum.Commercial,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n this.dealDto.DealNotes.push(response.NewDealNote);\r\n this.dealDto = response.CommercialDealDto;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n allFormsComplete(): boolean {\r\n if (this.dealDto) {\r\n if (\r\n this.dealDto.IsBorrowerSectionComplete &&\r\n this.dealDto.IsPropertySectionComplete &&\r\n this.dealDto.IsLoanSectionComplete\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /** Opens the Terms and Conditions popup when the Submit to Lenders button is clicked*/\r\n showTermsAndConditionsForBorrower() {\r\n this.showApplyTsAndCs = true;\r\n this.requestMessageReason = \"a review\";\r\n this.showTsAndCs = true;\r\n }\r\n\r\n /** Opens the Terms and Conditions popup when the Submit to Lenders HoT button is clicked (borrower/broker) */\r\n showTermsAndConditions() {\r\n this.dataLoading = true;\r\n this.$lenderService\r\n .getShortlistedLendersInfoForSubmitToLenders(\r\n this.shortListedLendersId,\r\n LenderProductTypeEnum.CommercialMortgages,\r\n )\r\n .then((response) => {\r\n this.lendersDetailsForSubmittoLenders = response;\r\n })\r\n .finally(() => {\r\n this.showTsAndCs = true;\r\n this.showTsAndCsForm = true;\r\n this.dealDto.SubmitTsAndCs = false;\r\n this.invalidEmail = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n gotoLendingPage() {\r\n (this.$rootScope as any).isLender = false;\r\n this.$location.path(\"/dealforum/\" + this.dealDto.Id);\r\n }\r\n\r\n checkBrokerDeal() {\r\n return this.dealDto?.BrokerUserId != null && this.isClient ? true : false;\r\n }\r\n\r\n /** Submits a case to lenders */\r\n submitCaseToLenders() {\r\n this.showTsAndCsForm = false;\r\n this.sendingMessage = true;\r\n this.dataLoading = true;\r\n var isResubmitting = false;\r\n\r\n if (this.dealDto.Status == CaseStatusEnum.ReadyToReSubmit) {\r\n isResubmitting = true;\r\n }\r\n\r\n var request = {\r\n DealId: this.dealId,\r\n ProductType: this.dealDto.ProductType,\r\n ResubmitToLenders: isResubmitting,\r\n //BrokerCommission: Number(this.brokerCommission),\r\n LendersInfo: this.lendersDetailsForSubmittoLenders,\r\n BrokerPhoneNumber: this.brokerPreferredContact,\r\n IsBrokerPhoneNumberUpdated: this.isBrokerPhoneNumberUpdated,\r\n } as SubmitToLendersRequest;\r\n\r\n this.dealService\r\n .submitToLenders(request)\r\n .then((response: CaseChangedMessageDTO) => {\r\n this.dealDto.Status = response.CaseState;\r\n this.caseService.updateCaseState(this.dealDto.Id, response.CaseState);\r\n this.showMessage(\r\n \"You have requested a Decision in Principle from each lender.\",\r\n );\r\n this.isSubmittedToLenders = true;\r\n })\r\n .catch((error) => {\r\n this.showMessage(\"Sorry, something went wrong. Please try again.\");\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n validateEmails() {\r\n this.invalidEmail = false;\r\n\r\n angular.forEach(\r\n this.lendersDetailsForSubmittoLenders,\r\n (lenderdetails, index) => {\r\n var emailField = this.lenderDetailsForm[\"email\" + index];\r\n\r\n if (emailField && emailField.$invalid) {\r\n this.invalidEmail = true;\r\n }\r\n },\r\n );\r\n }\r\n\r\n showMessage(message: string) {\r\n this.messageContent = message;\r\n }\r\n\r\n requestEmail(reason): void {\r\n this.showRequestEmailForm = true;\r\n this.requestMessageReason = reason;\r\n this.messagebool = true;\r\n this.messageContent = \"\";\r\n }\r\n\r\n sendRequestEmail() {\r\n this.showRequestEmailForm = false;\r\n this.sendingMessage = true;\r\n this.dataLoading = true;\r\n this.$accountservice\r\n .RequestAssistanceReview(\r\n this.requestMessageReason,\r\n this.dealDto.Id,\r\n this.dealDto.ProductFamily,\r\n )\r\n .then((response) => {\r\n this.showMessage(\r\n `${this.appName} have been notified that you require assistance and will be in touch shortly to help.`,\r\n );\r\n\r\n let dealNote = {\r\n DealId: this.dealDto.Id,\r\n UserId: this.currentUser.Id,\r\n NoteText: \"You have requested \" + this.requestMessageReason + \".\",\r\n /*ExpandNote: false*/\r\n } as DealNoteDTO;\r\n this.dealNoteService.addUpdate(dealNote).then((caseNoteResponse) => {\r\n this.dealDto.DealNotes.push(caseNoteResponse);\r\n });\r\n })\r\n .catch((error) => {\r\n this.showMessage(\r\n \"Sorry, something went wrong while sending your email. Please try again.\",\r\n );\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n getAppName() {\r\n let lsd = sessionStorage.getItem(\"applicationName\");\r\n if (lsd != null) {\r\n this.appName = lsd;\r\n } else {\r\n this.appName = \"Brickflow\";\r\n }\r\n }\r\n\r\n closeConfirmationModal() {\r\n if (this.isSubmittedToLenders) {\r\n if (this.$routeParams.Promote) {\r\n this.$location.path(\"/commercialcasedashboard/\" + this.dealDto.Id);\r\n } else {\r\n window.location.reload();\r\n }\r\n }\r\n this.showTsAndCs = false;\r\n }\r\n\r\n viewResults() {\r\n this.$location.path(\"/commercialresults/\" + this.dealDto.Id);\r\n }\r\n\r\n /** Process the Heads of Terms button being clicked */\r\n headsOfTermsClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"terms\");\r\n this.$location.path(\r\n \"/commercialheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n /** Lender rejects the case*/\r\n rejectButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"reject\");\r\n this.$location.path(\r\n \"/commercialheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n withDrawButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"withdraw\");\r\n this.$location.path(\r\n \"/commercialheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n feedbackButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"feedback\");\r\n this.$location.path(\r\n \"/commercialheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n getCurrentUserAndRoles() {\r\n this.roleService.GetUserRoles().then((result) => {\r\n if (result.filter((x) => x.toLowerCase() == \"admin\").length > 0) {\r\n this.isAdmin = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"broker\").length > 0) {\r\n this.isBroker = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"client\").length > 0) {\r\n this.isClient = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"lender\").length > 0) {\r\n this.isLender = true;\r\n\r\n this.dealLenderService\r\n .fetchDealLender(this.dealDto.Id)\r\n .then((response) => {\r\n this.dealLender = response;\r\n this.isInActiveLender = response.IsLenderInActive;\r\n this.generateCaseStatusText();\r\n });\r\n }\r\n\r\n this.authService\r\n .getUpdatedProfile()\r\n .then((prof) => {\r\n this.currentUser = prof;\r\n this.updateRequestAssitanceDealNoteMessage();\r\n })\r\n .then(() => {\r\n this.checkIfUserIsInvited();\r\n this.generateCaseStatusText();\r\n });\r\n\r\n /*this.$lenderService\r\n .getSelectedDealLenderNames(this.dealDto.Id)\r\n .then((response) => {\r\n this.selectedLendersText = response.LendersName;\r\n if (this.dealDto.Status == CaseStatusEnum.NewCase) {\r\n this.shortListedLendersId = response.LendersId;\r\n }\r\n });\r\n\r\n this.$lenderService\r\n .getShortlistedDealLenderNames(this.dealDto.Id)\r\n .then((response) => {\r\n this.shortlistedLendersText = response.LendersName;\r\n if (this.dealDto.Status != CaseStatusEnum.NewCase) {\r\n this.shortListedLendersId = response.LendersId;\r\n }\r\n });*/\r\n });\r\n }\r\n\r\n //Share module functions\r\n openShareModuleModal(contextToShare: AppraisalModuleEnum) {\r\n this.shareContext = contextToShare;\r\n this.constructShareNoteMessage();\r\n\r\n this.dealClientService\r\n .fetchDealMembersWithAccess(this.dealDto.Id)\r\n .then((response: ClientDTO[]) => {\r\n this.caseMembersWithAccess = response;\r\n\r\n this.showShare = true;\r\n });\r\n }\r\n\r\n constructShareNoteMessage() {\r\n this.shareNote = this.sharedDealService.constructShareNoteMessage(\r\n this.shareContext,\r\n this.currentUser,\r\n );\r\n }\r\n\r\n sendToBorrower() {\r\n this.dataLoading = true;\r\n\r\n var request = {\r\n ClientFirstName: this.selectedClientToShareWith.FirstName,\r\n ClientLastName: this.selectedClientToShareWith.LastName,\r\n ClientEmail: this.selectedClientToShareWith.Email,\r\n Note: this.shareNote,\r\n DealId: this.dealDto.Id,\r\n Section: this.shareContext,\r\n ProductFamily: ProductFamilyEnum.Commercial,\r\n } as ShareModuleRequest;\r\n\r\n this.dealService.shareModuleToBorrower(request).then((success) => {\r\n if (success) {\r\n this.showShare = false;\r\n this.dataLoading = false;\r\n this.showModuleShareConfirmation = true;\r\n this.selectedClientToShareWith = null;\r\n } else {\r\n this.showShare = false;\r\n this.showMessage(\"Sorry, something went wrong. Please try again.\");\r\n }\r\n });\r\n }\r\n\r\n isShareNoteFormComplete(): boolean {\r\n return this.selectedClientToShareWith &&\r\n this.shareNote &&\r\n this.shareNote.length > 0\r\n ? true\r\n : false;\r\n }\r\n\r\n //End of Share module functions\r\n\r\n // Profile view functions\r\n\r\n /**\r\n * Show the Add/Edit permissions profile modal\r\n * @param applicant\r\n */\r\n showPermissionsProfileModal(\r\n profile: DealClientDTO = null,\r\n isEdit: boolean = false,\r\n ): void {\r\n if (isEdit) {\r\n this.dealClientService.fetch(profile.Id).then((response) => {\r\n this.newApplicant = response;\r\n this.isAddShareholder = false;\r\n this.showAddorEdit = true;\r\n\r\n })\r\n\r\n } else {\r\n this.newApplicant = {} as DealClientDTO;\r\n this.isAddShareholder = true;\r\n this.newApplicant.AccessLevel = CaseAccessLevelEnum.Hidden;\r\n this.showAddorEdit = true;\r\n }\r\n }\r\n\r\n resetApplicant() {\r\n this.applicantForm.$setPristine();\r\n this.applicantForm.$setUntouched();\r\n this.newApplicant = {} as DealClientDTO;\r\n this.showAddorEdit = false;\r\n }\r\n\r\n /**\r\n * Saves the applicant being added/edited\r\n */\r\n saveApplicant(formController) {\r\n this.dataLoading = true;\r\n\r\n if (!(this.currentApplicant.Id > 0)) {\r\n this.currentApplicant.IsApplicant = true;\r\n this.currentApplicant.DealId = this.dealDto.Id;\r\n this.currentApplicant.AccessLevel = CaseAccessLevelEnum.Hidden;\r\n }\r\n\r\n this.saveUpdatedApplicant(this.currentApplicant, false, formController);\r\n }\r\n\r\n /**\r\n * Add or update a applicant\r\n * @param applicant\r\n */\r\n saveUpdatedApplicant(\r\n applicant: DealClientDTO,\r\n isPermissionsProfile: boolean = false,\r\n formController = null,\r\n ): void {\r\n this.dataLoading = true;\r\n\r\n this.disableQuickEditSave = true; // this is just because sometimes the save takes a little while and the user could click the save button again\r\n applicant.DealId = this.dealDto.Id;\r\n\r\n if (applicant) {\r\n this.dateProperties.forEach((property) => {\r\n let val = applicant[property];\r\n if (val) {\r\n applicant[property] = this.modifyDateForBackend(val);\r\n }\r\n });\r\n }\r\n\r\n if (applicant.Profile) {\r\n this.profileDateProperties.forEach((property) => {\r\n let val = applicant.Profile[property];\r\n if (val) {\r\n applicant.Profile[property] = this.modifyDateForBackend(val);\r\n }\r\n });\r\n }\r\n\r\n if (applicant.Client) {\r\n this.clientDateProperties.forEach((property) => {\r\n let val = applicant.Client[property];\r\n if (val) {\r\n applicant.Client[property] = this.modifyDateForBackend(val);\r\n }\r\n });\r\n }\r\n\r\n if (!applicant.Client.PostalAddress && isPermissionsProfile) {\r\n applicant.Client.PostalAddress = {\r\n AddressLine1: \"\",\r\n AddressLine2: \"\",\r\n AddressLine3: \"\",\r\n AddressLine4: \"\",\r\n PostCode: \"\",\r\n } as PostalAddress;\r\n }\r\n\r\n this.dealClientService\r\n .addorUpdateApplicant(applicant, this.isAddShareholder)\r\n .then((response) => {\r\n this.dataLoading = true;\r\n\r\n if (response) {\r\n this.dateProperties.forEach((property) => {\r\n let val = response[property];\r\n if (val) {\r\n response[property] = this.modifyDateForFrontend(val);\r\n }\r\n });\r\n }\r\n\r\n if (response.Profile) {\r\n this.profileDateProperties.forEach((property) => {\r\n let val = response.Profile[property];\r\n if (val) {\r\n response.Profile[property] = this.modifyDateForFrontend(val);\r\n }\r\n });\r\n }\r\n\r\n if (response.Client) {\r\n this.clientDateProperties.forEach((property) => {\r\n let val = response.Client[property];\r\n if (val) {\r\n response.Client[property] = this.modifyDateForFrontend(val);\r\n }\r\n });\r\n }\r\n\r\n const existingShareholder = this.applicantList.find(\r\n (s) => s.Id == response.Id,\r\n );\r\n\r\n // If found then we're updating\r\n if (existingShareholder) {\r\n this.applicantList = this.applicantList.filter(\r\n (member) => member.Id != applicant.Id,\r\n );\r\n this.applicantList.push(response);\r\n } else {\r\n this.applicantList.push(response);\r\n }\r\n if (!isPermissionsProfile) {\r\n this.currentApplicant = response;\r\n //This closes all the tab\r\n //this.closeTabs();\r\n formController.$setPristine();\r\n }\r\n })\r\n .finally(() => {\r\n delete this.newApplicant;\r\n this.showAddorEdit = false;\r\n this.disableQuickEditSave = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n cancelUpdateApplicant() {\r\n this.showAddorEdit = false;\r\n this.applicantList = this.applicantList.filter(\r\n (applicant) => applicant.Id != this.newApplicant?.Id,\r\n );\r\n this.applicantList.push(this.newApplicant); // Resets anything that is changed using the original data object\r\n }\r\n\r\n deleteApplicant(): void {\r\n this.dataLoading = true;\r\n this.dealClientService\r\n .markAsDeleteAndSetNextApplicantAsPrimary(\r\n this.dealDto.Id,\r\n this.confirmDeleteApplicant.Id,\r\n )\r\n .then((response) => {\r\n this.applicantList = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.confirmDeleteApplicant = {} as DealClientDTO;\r\n this.showDelete = false;\r\n });\r\n }\r\n\r\n deleteConfirmApplicant(applicant: DealClientDTO) {\r\n this.showDelete = true;\r\n this.confirmDeleteApplicant = { ...applicant };\r\n }\r\n\r\n nonUkWarningVisible(): boolean {\r\n return this.sharedDealService.nonUkWarningVisible(this.currentApplicant);\r\n }\r\n\r\n showInviteButton(shareholder: DealClientDTO) {\r\n return this.sharedDealService.showInviteButton(shareholder);\r\n }\r\n\r\n invite(applicant: DealClientDTO) {\r\n this.dataLoading = true;\r\n\r\n this.dealClientService\r\n .inviteApplicant(applicant.UniqueRef)\r\n .then((i) => {\r\n this.modal = true;\r\n this.message =\r\n \"A request has been sent to \" +\r\n applicant.Client.FirstName +\r\n \" \" +\r\n applicant.Client.LastName +\r\n \" complete their shareholder profile.\";\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem sending the invite request to \" +\r\n applicant.Client.FirstName +\r\n \" \" +\r\n applicant.Client.LastName +\r\n \". Please try again later.\";\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n //End of Profile view functions\r\n\r\n /** Show and hide the export menu */\r\n showAndHideExport() {\r\n this.showExport = !this.showExport;\r\n }\r\n\r\n //loanSaveDisabled() {\r\n\r\n // var selectFields = [];\r\n // if (this.dealDto.ProductType == ProductTypeEnum.BridgingPurchaseOrRefinance) {\r\n // selectFields = [\r\n // this.dealDto.AdditionalSecurity,\r\n // this.dealDto.ExitStrategy,\r\n // this.dealDto.InterestService,\r\n // this.dealDto.LoanTermReq,\r\n // this.dealDto.LoanPurpose,\r\n // ];\r\n // } else {\r\n // selectFields = [\r\n // this.dealDto.AdditionalSecurity,\r\n // this.dealDto.ExitStrategy,\r\n // this.dealDto.InterestService,\r\n // this.dealDto.SourceOfIncome,\r\n // this.dealDto.LoanPurpose,\r\n // this.dealDto.PlanningStatusAtStartOfLoan,\r\n // this.dealDto.PlanningStatusAtEndOfLoan\r\n // ];\r\n // }\r\n\r\n // if (this.loanDetailsForm.$invalid) return true;\r\n\r\n // if (this.dealDto.LoanPurpose && this.dealDto.LoanPurpose == LoanPurposeEnum.Other && this.dealDto.ProductType == ProductTypeEnum.BridgingPreconstruction) {\r\n // if (!this.dealDto.LoanPurposeDescription || this.dealDto.LoanPurposeDescription.length == 0) {\r\n // return true;\r\n // }\r\n // }\r\n\r\n // for (let i = 0; i < selectFields.length; i++) {\r\n // if (selectFields[i] === 0 || selectFields[i] === '0') {\r\n // return true;\r\n // }\r\n // }\r\n\r\n // return false;\r\n //}\r\n\r\n checkIfUserIsInvited() {\r\n //added to scope for directive\r\n this.dealService\r\n .checkIfUserIsInvited(this.currentUser.Id, this.dealId)\r\n .then((response: InvitedUserResponse) => {\r\n // if user has no active subscription (and are not a lender or admin) then they should be redirected back to the dashboard\r\n if (\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PaidUp &&\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PreCancel &&\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PaymentProcessing &&\r\n !response.IsInvited &&\r\n !this.isAdmin &&\r\n !this.isLender\r\n ) {\r\n this.$location.path(\"/dashboard\");\r\n return;\r\n }\r\n\r\n (this.$rootScope as any).isInvitedToCase = response.IsInvited;\r\n\r\n if (response.IsInvited) {\r\n if (response.DealAccessLevel == CaseAccessLevelEnum.ReadOnly) {\r\n (this.$rootScope as any).isInvitedAndHasReadonlyAccess = true;\r\n }\r\n }\r\n\r\n this.$rootScope.$broadcast(\"invitedStatusChange\");\r\n });\r\n }\r\n\r\n modifyDateForBackend(property: Date) {\r\n return this.sharedDealService.modifyDateForBackend(property);\r\n }\r\n\r\n modifyDateForFrontend(property: Date) {\r\n return this.sharedDealService.modifyDateForFrontend(property);\r\n }\r\n\r\n disablePersonalDetails() {\r\n return this.sharedDealService.disablePersonalDetails(\r\n this.currentApplicant,\r\n this.personalDetailsForm,\r\n );\r\n }\r\n\r\n goToUserDashboard() {\r\n this.authService.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n datasetupOnOwnOrPurchaseChange() {\r\n this.dealDto = this.commercialDealService.datasetupOnOwnOrPurchaseChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnIsTenantedBuildingChange() {\r\n if (!this.dealDto.IsTenantedBuilding) this.leaseItems = null;\r\n this.dealDto =\r\n this.commercialDealService.datasetupOnIsTenantedBuildingChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnMaxLoanRequiredChange() {\r\n this.dealDto = this.dealService.dataSetupOnMaxLoanRequiredChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n onPropertyTabSelection() {\r\n if (this.dealDto) {\r\n this.selectedNavMenu = this.CaseDashboardTypeEnum.Property;\r\n this.onTabSelection();\r\n }\r\n }\r\n\r\n discardDealData(form: ng.IFormController = null) {\r\n event.stopPropagation();\r\n if (form == this.propertyDetailsForm) {\r\n this.dealDto = JSON.parse(JSON.stringify(this.tempDealDto));\r\n this.PostCodeOptions = [];\r\n this.searchterm = null;\r\n } else {\r\n this.dealDto = JSON.parse(JSON.stringify(this.tempDealDto));\r\n }\r\n\r\n if (form) {\r\n form.$setPristine();\r\n form.$setUntouched();\r\n }\r\n }\r\n\r\n onLoanTabSelection() {\r\n if (this.dealDto) {\r\n this.selectedNavMenu = this.CaseDashboardTypeEnum.Loan;\r\n this.onTabSelection();\r\n }\r\n }\r\n\r\n onTabSelection() {\r\n this.tempDealDto = JSON.parse(JSON.stringify(this.dealDto));\r\n }\r\n\r\n discardApplicantData(form: ng.IFormController) {\r\n event.stopPropagation();\r\n this.currentApplicant = JSON.parse(JSON.stringify(this.tempApplicant));\r\n form.$setPristine();\r\n form.$setUntouched();\r\n }\r\n\r\n onApplicantTabSelection(tab) {\r\n const str = tab;\r\n this.tabs[str] = !this.tabs[str];\r\n\r\n this.tempApplicant = JSON.parse(JSON.stringify(this.currentApplicant));\r\n }\r\n\r\n carriageReturnCheck(event) {\r\n if (event.key === \"Enter\") {\r\n let position = event.target.selectionStart;\r\n if (this.newNote.NoteText) {\r\n this.newNote.NoteText = [\r\n this.newNote.NoteText.slice(0, position),\r\n \"\\n\",\r\n this.newNote.NoteText.slice(position),\r\n ].join(\"\");\r\n\r\n setTimeout(() => {\r\n event.target.setSelectionRange(position + 1, position + 1);\r\n }, 0);\r\n } else {\r\n this.newNote.NoteText = \"\\n\";\r\n }\r\n }\r\n }\r\n\r\n trustedHtml(plainText) {\r\n if (this.isClient && plainText.startsWith(\"Project submitted to lenders\")) {\r\n return this.$sce.trustAsHtml(\"Project submitted to lenders\");\r\n } else {\r\n return this.$sce.trustAsHtml(plainText);\r\n }\r\n }\r\n\r\n initialiseTitleAndTitleOption() {\r\n if (this.currentApplicant?.Profile) {\r\n const { Title, TitleOption } = this.currentApplicant.Profile;\r\n\r\n // If TitleOption has a value greater than 0, set Title to null\r\n if (\r\n (TitleOption > TitleEnum.None && TitleOption != TitleEnum.Other) ||\r\n Title == null\r\n ) {\r\n this.currentApplicant.Profile.Title = \"\";\r\n }\r\n // If Title exists and TitleOption is not set, set TitleOption to Other\r\n else if (Title && !TitleOption) {\r\n this.currentApplicant.Profile.TitleOption = TitleEnum.Other;\r\n }\r\n }\r\n }\r\n\r\n onTitleOptionChange() {\r\n const { TitleOption } = this.currentApplicant.Profile;\r\n\r\n if (TitleOption > 0 && TitleOption != TitleEnum.Other) {\r\n this.currentApplicant.Profile.Title = \"\";\r\n }\r\n }\r\n\r\n onOwnOrPurchaseChange(OwnOrPurchase: boolean) {\r\n this.dealDto.OwnOrPurchase = this.dealDto.HasOwnOrPurchase\r\n ? OwnOrPurchaseEnum.Own\r\n : OwnOrPurchaseEnum.Purchasing;\r\n this.datasetupOnOwnOrPurchaseChange();\r\n }\r\n\r\n onIsFamilyInResidenceChange() {\r\n this.dealDto.IsFamilyInResidence = this.dealDto.HasIsFamilyInResidence\r\n ? YesNoMaybe.Yes\r\n : YesNoMaybe.No;\r\n }\r\n\r\n initialDataSetupForIsFamilyInResidence() {\r\n if (this.dealDto.HasIsFamilyInResidence) {\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.Yes;\r\n this.dealDto.HasIsFamilyInResidence = true;\r\n } else {\r\n this.dealDto.IsFamilyInResidence = YesNoMaybe.No;\r\n this.dealDto.HasIsFamilyInResidence = false;\r\n }\r\n }\r\n\r\n onIsMortgagedChange() {\r\n if (!this.dealDto.IsMortgaged) {\r\n this.dealDto.MortgageCurrentLender = null;\r\n this.dealDto.MortgageCurrentBalance = 0;\r\n }\r\n }\r\n\r\n goToLoanTypeSelectionPage() {\r\n if (this.isLoggedInUser) {\r\n this.authService.setHasValidStatustoShowShareSearchModal(\r\n true,\r\n );\r\n }\r\n this.$location.path(\"/allloans\");\r\n\r\n }\r\n\r\n onNumberOfTenanciesChange() {\r\n if (this.dealDto.NumberOfTenancies && this.dealDto.NumberOfTenancies > 1) {\r\n this.leaseItems = [];\r\n for (let i = 0; i < this.dealDto.NumberOfTenancies; i++) {\r\n var leaseItem = {\r\n TimeLeftOnLeaseYears: null,\r\n TimeLeftOnLeaseMonths: null,\r\n GrossMonthlyRentalIncome: \"\",\r\n } as LeaseItemDetails;\r\n this.leaseItems.push(leaseItem);\r\n }\r\n this.onGrossMonthlyRentalIncomeChange();\r\n } else if (\r\n this.dealDto.NumberOfTenancies &&\r\n this.dealDto.NumberOfTenancies == 1\r\n ) {\r\n this.leaseItems = [];\r\n var leaseItem = {\r\n TimeLeftOnLeaseYears: null,\r\n TimeLeftOnLeaseMonths: null,\r\n GrossMonthlyRentalIncome: \"\",\r\n } as LeaseItemDetails;\r\n this.leaseItems.push(leaseItem);\r\n this.isGrossMonthlyRentalIncomeMatch = true;\r\n } else {\r\n this.leaseItems = [];\r\n this.isGrossMonthlyRentalIncomeMatch = true;\r\n }\r\n }\r\n\r\n onGrossMonthlyRentalIncomeChange() {\r\n this.totalGrossMonthlyRentalIncome = this.leaseItems.reduce(function (\r\n a,\r\n b,\r\n ) {\r\n return (\r\n a +\r\n Number.parseInt(\r\n b.GrossMonthlyRentalIncome != \"\" ? b.GrossMonthlyRentalIncome : \"0\",\r\n )\r\n );\r\n }, 0);\r\n\r\n this.isGrossMonthlyRentalIncomeMatch =\r\n this.totalGrossMonthlyRentalIncome !=\r\n this.dealDto.GrossMonthlyRentalIncome\r\n ? false\r\n : true;\r\n }\r\n\r\n propertySaveDisabled() {\r\n var commonFields = [\r\n this.dealDto.OwnOrPurchase,\r\n this.dealDto.Locations,\r\n this.dealDto.IsFamilyInResidence,\r\n this.dealDto.PropertyAddress.AddressLine1,\r\n this.dealDto.PropertyAddress.PostCode,\r\n ];\r\n\r\n if (this.dealDto.ProductType == ProductTypeEnum.CommercialInvestment) {\r\n commonFields.push(this.dealDto.GrossMonthlyRentalIncome);\r\n }\r\n\r\n if (this.dealDto.IsTenantedBuilding) {\r\n if (\r\n this.dealDto.NumberOfTenancies == null ||\r\n this.dealDto.NumberOfTenancies == 0\r\n ) {\r\n return true;\r\n } else if (this.dealDto.NumberOfTenancies > 1) {\r\n for (let i = 0; i < this.leaseItems.length; i++) {\r\n if (\r\n this.leaseItems[i].GrossMonthlyRentalIncome == null ||\r\n this.leaseItems[i].TimeLeftOnLeaseMonths == null ||\r\n this.leaseItems[i].TimeLeftOnLeaseYears == null\r\n ) {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (this.propertyDetailsForm && this.propertyDetailsForm.$invalid)\r\n return true;\r\n\r\n if (this.dealDto.PropertyTenure == null) return true;\r\n\r\n if (\r\n this.dealDto.PropertyTenure &&\r\n this.dealDto.PropertyTenure == TenureEnum.Leasehold\r\n ) {\r\n if (this.dealDto.YearsLeftOnLease == null) return true;\r\n }\r\n\r\n if (\r\n this.dealDto.IsFamilyInResidence == 0 ||\r\n this.dealDto.IsFamilyInResidence == YesNoMaybe.Yes\r\n )\r\n return true;\r\n\r\n for (let i = 0; i < commonFields.length; i++) {\r\n if (\r\n commonFields[i] == null ||\r\n commonFields[i] == \"0\" ||\r\n commonFields[i] == \"\"\r\n ) {\r\n return true;\r\n }\r\n }\r\n\r\n if (this.leaseItems.length > 1) {\r\n if (\r\n this.leaseItems.find(\r\n (l) =>\r\n l.GrossMonthlyRentalIncome == null ||\r\n l.GrossMonthlyRentalIncome == \"\",\r\n )\r\n )\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n loanSaveDisabled() {\r\n var selectFields = [\r\n this.dealDto.LoanRepaymentType,\r\n this.dealDto.CurrentPropertyType,\r\n this.dealDto.FixedRateTerm,\r\n this.dealDto.LoanCompletionType,\r\n ];\r\n\r\n if (this.loanDetailsForm.$invalid) return true;\r\n\r\n for (let i = 0; i < selectFields.length; i++) {\r\n if (selectFields[i] === 0 || selectFields[i] === \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Convert LeaseDeatails JSON back to an array of LeaseDeatails objects\r\n * @param leaseItemsJson\r\n */\r\n parseLeaseDetails(leaseItems: string) {\r\n if (leaseItems != null && leaseItems.length > 0) {\r\n // JSON doesn't understand date types so therefore user the reviver function to manually convert them back to dates as opposed to strings\r\n this.leaseItems = JSON.parse(leaseItems, this.sharedDealService.reviver);\r\n }\r\n\r\n if (this.leaseItems != null && this.leaseItems.length > 1) {\r\n this.onGrossMonthlyRentalIncomeChange();\r\n }\r\n }\r\n\r\n initMortgageTerm() {\r\n this.dealDto.LoanTermReq = this.dealDto.LoanTermReq || 240;\r\n this.mortgageTerm = this.dealDto.LoanTermReq / 12;\r\n }\r\n\r\n mortgageTermToLoanTerm() {\r\n this.dealDto.LoanTermReq = this.mortgageTerm * 12;\r\n }\r\n\r\n onCurrentUseOfBuilding() {\r\n this.dealDto = this.commercialDealService.datasetupOnCurrentUseOfBuilding(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n onMortgageProductChange() {\r\n if (this.dealDto.MortgageInterestType == InterestRateTypeEnum.Variable) {\r\n this.dealDto.FixedRateTerm = null;\r\n } else if (\r\n this.dealDto.MortgageInterestType == InterestRateTypeEnum.Fixed\r\n ) {\r\n this.dealDto.FixedRateTerm = FixedRateTermEnum.FiveYear;\r\n }\r\n }\r\n\r\n onPropertyTenureChange() {\r\n if (this.dealDto.PropertyTenure == TenureEnum.Freehold) {\r\n this.dealDto.YearsLeftOnLease = 0;\r\n }\r\n }\r\n\r\n onOriginalGrossMonthlyRentalIncomeChange() {\r\n if (\r\n this.dealDto.GrossMonthlyRentalIncome != null &&\r\n this.totalGrossMonthlyRentalIncome ==\r\n this.dealDto.GrossMonthlyRentalIncome\r\n ) {\r\n this.isGrossMonthlyRentalIncomeMatch = true;\r\n }\r\n }\r\n\r\n calculateTotalShareholding(currentapplicant: DealClientDTO) {\r\n return this.sharedDealService.calculateTotalShareholding(\r\n currentapplicant,\r\n this.applicantList,\r\n );\r\n }\r\n\r\n getOrganisationbyDealId() {\r\n this.organisationService\r\n .getOrganisationAndBrokerByDealId(this.dealDto.Id)\r\n .then((response) => {\r\n this.org = response.Organisation;\r\n this.dealBrokerUser = response.Broker;\r\n //this.brokerCommission = this.dealDto.Status == CaseStatusEnum.NewCase ? this.org?.CommissionPercent : this.dealDto.BrokerCommissionPercent;\r\n this.brokerPreferredContact =\r\n this.dealDto.Status == CaseStatusEnum.NewCase\r\n ? this.dealBrokerUser?.PhoneNumber\r\n : this.dealDto.BrokerPhoneNumber;\r\n if (this.org.IsWhiteLabelled) {\r\n this.fileNamePrefix = this.org.Name.replace(/ /g, \"_\");\r\n } else {\r\n this.fileNamePrefix = \"Brickflow\";\r\n }\r\n });\r\n }\r\n\r\n updateRequestAssitanceDealNoteMessage() {\r\n if (this.dealDto?.DealNotes != null && this.currentUser != null) {\r\n this.dealDto.DealNotes = this.dealDto.DealNotes.map((d) => {\r\n if (\r\n d.UserId != this.currentUser.Id &&\r\n (d.NoteText == \"Your have requested for assistance.\" ||\r\n d.NoteText == \"You have requested assistance.\")\r\n ) {\r\n return { ...d, NoteText: `${d.UserFullName} requested assistance.` };\r\n }\r\n\r\n return d;\r\n });\r\n }\r\n }\r\n\r\n getOwnershipPercentageText() {\r\n if (this.dealDto != null) {\r\n return this.sharedDealService.getOwnershipPercentageText(\r\n this.currentApplicant,\r\n this.dealDto.ProductType,\r\n );\r\n }\r\n return \"Shareholding\";\r\n }\r\n\r\n closeSubmitToLenderModal() {\r\n this.showTsAndCs = false;\r\n // this.brokerCommission = this.dealDto.Status == CaseStatusEnum.NewCase ? this.org?.CommissionPercent : this.dealDto.BrokerCommissionPercent;\r\n this.brokerPreferredContact =\r\n this.dealDto.Status == CaseStatusEnum.NewCase\r\n ? this.dealBrokerUser?.PhoneNumber\r\n : this.dealDto.BrokerPhoneNumber;\r\n this.isBrokerPhoneNumberUpdated = false;\r\n }\r\n\r\n isCompanyAndOwnershipSaveDisabled() {\r\n return this.dealDto.HowWillYouOwnNewDevelopment == null ||\r\n this.dealDto.HowWillYouOwnNewDevelopment <= 0\r\n ? true\r\n : false;\r\n }\r\n\r\n showBasedOnMainResidence() {\r\n return this.dealService.showBasedOnMainResidence(this.dealDto);\r\n }\r\n\r\n getRequiredRolesOptions() {\r\n return this.dealService.getRequiredRolesOptions(true, this.isReadOnlyDeal);\r\n }\r\n\r\n generateCaseStatusText() {\r\n if (this.isLender) {\r\n this.caseStatusOptions = this.selectListService.GetCaseLenderStateOptionsForLenders();\r\n }\r\n else {\r\n this.caseStatusOptions = this.selectListService.GetCaseStatusOptions(this.currentUser && this.currentUser.IsConnectUser);\r\n }\r\n this.getCaseStatusDisplayText();\r\n\r\n }\r\n\r\n showEditDealNameButton() {\r\n if (!this.isReadOnlyDeal && (!this.currentUser?.IsConnectUser || (this.currentUser?.IsConnectUser && !this.dealDto.IsReferredToConnect))) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n logExportDownload(eventName) {\r\n this.eventLogService.logEvent(\r\n eventName,\r\n EventLogEnum.Export,\r\n this.dealDto.ProductType,\r\n this.dealDto.Id,\r\n );\r\n }\r\n\r\n getTinymceOptions = function () {\r\n return this.isLender || this.isReadOnlyDeal ? this.tinymceReadonlyOptions : this.tinymceOptions;\r\n };\r\n}\r\n","import { CommercialLenderResultSummaryDTO } from \"@js/DTO/SearchResults/CommercialLenderResultSummaryDTO.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { CommercialDealService } from \"@js/services/Deal/CommercialDealService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\n\r\nexport class CommercialComparisonController {\r\n isLoading: boolean;\r\n selectedCandidates: CommercialLenderResultSummaryDTO[];\r\n\r\n //Lender Logos\r\n showLenderLogo: boolean = false;\r\n\r\n dealId: number;\r\n uniqueid: string;\r\n criteria: {} = {};\r\n\r\n //This needs to be set to true as we are using a same view.\r\n isDeal: boolean = true;\r\n\r\n productLastVerifiedDates = {};\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"$http\",\r\n \"OrganisationService\",\r\n \"CommercialDealService\",\r\n \"$routeParams\",\r\n \"ProductService\"\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private organisationService: OrganisationService,\r\n private commercialDealService: CommercialDealService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private productService: ProductService\r\n ) {\r\n this.showOrHideLenderLogo();\r\n\r\n if (this.$routeParams.DealId) {\r\n this.dealId = this.$routeParams.DealId;\r\n }\r\n\r\n //if ((this.$rootScope as any).selectedUser || sessionStorage.getItem('SelectedUser')) {\r\n // if ((this.$rootScope as any).selectedUser) {\r\n // this.selectedUser = (this.$rootScope as any).selectedUser;\r\n // sessionStorage.setItem('SelectedUser', JSON.stringify(this.selectedUser));\r\n // } else if (sessionStorage.getItem('SelectedUser')) {\r\n // this.selectedUser = JSON.parse(sessionStorage.getItem('SelectedUser'));\r\n // }\r\n //}\r\n\r\n if (\r\n sessionStorage.getItem(\"ComparisonList\") &&\r\n sessionStorage.getItem(\"LoanCriteria\")\r\n ) {\r\n this.selectedCandidates = JSON.parse(\r\n sessionStorage.getItem(\"ComparisonList\"),\r\n );\r\n this.criteria = JSON.parse(sessionStorage.getItem(\"LoanCriteria\"));\r\n const productIds = this.selectedCandidates.map((product) => product.ProductID);\r\n this.getProductLastVerifiedDates(productIds);\r\n } else {\r\n this.goToResults();\r\n }\r\n }\r\n\r\n showOrHideLenderLogo() {\r\n this.organisationService.showLenderNamesAndLogos().then((result) => {\r\n this.showLenderLogo = result;\r\n });\r\n }\r\n\r\n goToResults(): void {\r\n sessionStorage.setItem(\r\n \"ComparisonList\",\r\n JSON.stringify(this.selectedCandidates),\r\n );\r\n\r\n this.commercialDealService.fetch(this.dealId).then((result) => {\r\n if (\r\n result.Status == CaseStatusEnum.ReadyToReSubmit ||\r\n result.Status == CaseStatusEnum.SubmittedToLendersForHoT\r\n ) {\r\n this.$location.path(\"/commercialshortlistmore/\" + this.dealId);\r\n } else {\r\n this.$location.path(\"/commercialresults/\" + this.dealId);\r\n }\r\n });\r\n }\r\n\r\n getProductLastVerifiedDates(productIds: number[]) {\r\n this.productService.getLastVerifiedDates(productIds).then((response) => {\r\n productIds.forEach(id => {\r\n if (response[id] != null) {\r\n this.productLastVerifiedDates[id] = this.formatDate(response[id]);\r\n } \r\n })\r\n });\r\n }\r\n\r\n formatDate = (dateString) => {\r\n const date = new Date(dateString);\r\n return date.toLocaleDateString('en-GB');\r\n };\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CommercialDealDTO } from \"@js/DTO/Deal/CommercialDealDTO.cs.d\";\r\nimport { DealFileAttachmentDTO } from \"@js/DTO/Deal/DealFileAttachmentDTO.cs.d\";\r\nimport { DealLenderDTO } from \"@js/DTO/Deal/DealLenderDTO.cs.d\";\r\nimport { DealLenderMessageDTO } from \"@js/DTO/Deal/DealLenderMessageDTO.cs.d\";\r\nimport { FeedBackDTO } from \"@js/DTO/FeedBackDTO.cs.d\";\r\nimport { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { BridgingSubmitOfferRequest } from \"@js/DTO/Messages/Deal/BridgingSubmitOfferMessage.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { InterestRateTypeEnum } from \"@js/models/enum/InterestRateTypeEnum.cs.d\";\r\nimport { LoanRepaymentTypeEnum } from \"@js/models/enum/LoanRepaymentTypeEnum.cs.d\";\r\nimport { MessageRoleEnum } from \"@js/models/enum/MessageRoleEnum.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CommercialDealService } from \"@js/services/Deal/CommercialDealService\";\r\nimport { DealLenderMessageService } from \"@js/services/Deal/DealLenderMessageService\";\r\nimport { DealLenderService } from \"@js/services/Deal/DealLenderService\";\r\nimport { SharedHeadsOfTermsService } from \"@js/services/Deal/SharedHeadsOfTermsService\";\r\nimport { DealFileAttachmentService } from \"@js/services/DealFileAttachmentService\";\r\nimport { FeedBackService } from \"@js/services/FeedBackService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class CommercialHeadsOfTermsController {\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"RoleService\",\r\n \"DealLenderMessageService\",\r\n \"DealFileAttachmentService\",\r\n \"$window\",\r\n \"CommercialDealService\",\r\n \"DealLenderService\",\r\n \"SelectListService\",\r\n \"FeedBackService\",\r\n \"UserService\",\r\n \"AuthService\",\r\n \"ProductService\",\r\n \"SharedHeadsOfTermsService\"\r\n ];\r\n\r\n isCommercial: boolean = true;\r\n dataLoading: boolean = false; // Controls showing the data loading \"spinner\"\r\n dealLenders: DealLenderDTO[];\r\n showInformationMessage: boolean = false;\r\n messageContent: string;\r\n\r\n showDirection: boolean = false;\r\n\r\n toggleFeedbackSection: boolean = false;\r\n toggleHoTDetailSection: boolean = false;\r\n toggleRejectSection: boolean = false;\r\n toggleWithdrawSection: boolean = false;\r\n currentUser: ApplicationUserDTO = {} as ApplicationUserDTO;\r\n isLender: boolean = false;\r\n isBroker: boolean = false;\r\n isAdmin: boolean = false;\r\n isClient: boolean = false;\r\n\r\n // show different sections to Lender based on which button clicked on Case Dashboard\r\n showFeedbackSectionLender: boolean = false;\r\n showHoTDetailSectionLender: boolean = false;\r\n showRejectSectionLender: boolean = false;\r\n showWithdrawSectionLender: boolean = false;\r\n\r\n showTsAndCsModal: boolean = false;\r\n showTsAndCsForm: boolean = false;\r\n sendingMessage: boolean = false;\r\n goToUserDashboard: boolean = false;\r\n\r\n currentDeal: CommercialDealDTO;\r\n currentCaseLender: DealLenderDTO;\r\n\r\n grossLoanCalcVal: number = 0;\r\n builLoanCalcVal: number = 0;\r\n landLoanCalcVal: number = 0;\r\n monetaryLAFee: number = 0;\r\n monetaryLEFee: number = 0;\r\n lenderTask: string = \"\";\r\n\r\n isRejectClicked: boolean = false;\r\n isWithdrawClicked: boolean = false;\r\n isConfirmClicked: boolean = false;\r\n isSubmitClicked: boolean = false;\r\n\r\n //Lender Message\r\n newChatMessage: string = \"\";\r\n showFullMessageId: number;\r\n\r\n //files\r\n fileUpload: DealFileAttachmentDTO[];\r\n uploadingFiles: FileUploadProgressDTO[];\r\n openModal: boolean = false;\r\n module = ModuleEnum.DIP;\r\n\r\n showFullLenderMessage = false;\r\n showFullBorrowerMessage = false;\r\n monthlyInterestRate: number = 0;\r\n showAutofill: boolean = false;\r\n\r\n mortgageProductType = [];\r\n loanRepaymentType = [];\r\n\r\n //Lender/Broker feedback properties\r\n showLenderFeedBackModal: boolean = false;\r\n showBrokerFeedBackModal: boolean = false;\r\n feedBackDTO: FeedBackDTO;\r\n prevPath: string;\r\n brokerName: string;\r\n brokerOrganisationName: string;\r\n lendingForm: ng.IFormController;\r\n\r\n //Deleteing a chat message\r\n selectedDealLenderMessageDto: DealLenderMessageDTO;\r\n showdeleteChatMessageModal: boolean = false;\r\n showConfirmDeleteButton: boolean = false;\r\n productTypeText: string = null;\r\n\r\n noLenderOrMoreLenderError:boolean = false;\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private roleService: RoleService,\r\n private dealLenderMessageService: DealLenderMessageService,\r\n private dealFileAttachmentService: DealFileAttachmentService,\r\n private $window: ng.IWindowService,\r\n private commercialDealService: CommercialDealService,\r\n private dealLenderService: DealLenderService,\r\n private selectListService: SelectListService,\r\n private feedBackService: FeedBackService,\r\n private userService: UserService,\r\n private $auth: AuthService,\r\n private productService: ProductService,\r\n private sharedHeadsOfTermsService :SharedHeadsOfTermsService\r\n\r\n ) {\r\n this.userService.getUserAutofill().then((response) => {\r\n this.showAutofill = response;\r\n });\r\n\r\n this.feedBackDTO = {} as FeedBackDTO;\r\n\r\n if (\r\n this.$routeParams.openModule &&\r\n this.$routeParams.openModule == \"withdraw\"\r\n ) {\r\n this.toggleWithdrawSection = true;\r\n } else if (\r\n this.$routeParams.openModule &&\r\n this.$routeParams.openModule == \"reject\"\r\n ) {\r\n this.toggleRejectSection = true;\r\n } else if (this.$routeParams.openModule) {\r\n this.toggleFeedbackSection = true;\r\n }\r\n\r\n if (this.$routeParams.DealId && this.$routeParams.DealLenderId) {\r\n this.dataLoading = true;\r\n\r\n this.commercialDealService\r\n .fetch(this.$routeParams.DealId)\r\n .then((response) => {\r\n this.currentDeal = response;\r\n if (this.currentDeal) {\r\n this.dealLenderService\r\n .fetchByDealId(\r\n this.$routeParams.DealId,\r\n this.roleService.getIsLenderVisible(),\r\n this.$routeParams.DealLenderId,\r\n )\r\n .then((response) => {\r\n this.dealLenders = response;\r\n if (this.$routeParams.DealLenderId) {\r\n if (this.dealLenders.length != 1) {\r\n this.noLenderOrMoreLenderError = true;\r\n return;\r\n }\r\n this.currentCaseLender = this.dealLenders[0];\r\n\r\n this.fileUpload = this.currentDeal.Attachments.filter((f) => {\r\n return f.DealLenderId == this.$routeParams.DealLenderId;\r\n });\r\n }\r\n }).finally(() => {\r\n this.populateLenderInformation(this.currentUser)\r\n });\r\n\r\n this.lenderTask = sessionStorage.getItem(\"lenderTask\");\r\n if (this.lenderTask != null && this.lenderTask.length > 0) {\r\n switch (this.lenderTask) {\r\n case \"reject\":\r\n this.showRejectSectionLender = true;\r\n break;\r\n case \"withdraw\":\r\n this.showWithdrawSectionLender = true;\r\n break;\r\n case \"feedback\":\r\n this.showFeedbackSectionLender = true;\r\n this.updateCaseLenderMessageReadDatetime();\r\n break;\r\n case \"terms\":\r\n this.showHoTDetailSectionLender = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n this.productTypeText = this.productService.getProductTypeFullName(\r\n this.currentDeal.ProductType,\r\n );\r\n } else {\r\n if ((this.$rootScope as any).selectedUser) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.getCurrentUserAndRoles();\r\n });\r\n }\r\n\r\n // this.BasisOfInterestRateOptions = this.selectListService.GetInterestRateBasis();\r\n // this.InterestRateTypeOptions = this.selectListService.GetInterestRateType();\r\n this.mortgageProductType = this.selectListService.GetInterestRateType();\r\n this.loanRepaymentType =\r\n this.selectListService.GetLoanRepaymentTypeOptions();\r\n }\r\n\r\n checkingIfUserIsLender() {\r\n this.roleService.isLenderUser().then((response) => {\r\n this.isLender = response;\r\n });\r\n }\r\n\r\n checkingIfUerIsBroker() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isBroker()\r\n .then((response) => {\r\n this.isBroker = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkingIfUserIsAdmin() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isAdminUser()\r\n .then((response) => {\r\n this.isAdmin = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkingIfUserIsClient() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isClientUser()\r\n .then((response) => {\r\n this.isClient = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n /** Redirects to the case dashboard */\r\n goToCaseDashboard() {\r\n this.showFeedbackSectionLender = false;\r\n this.showHoTDetailSectionLender = false;\r\n this.showRejectSectionLender = false;\r\n this.showWithdrawSectionLender = false;\r\n if (\r\n this.isBroker && this.currentCaseLender &&\r\n !this.currentCaseLender.IsLenderReviewComplete &&\r\n (this.currentCaseLender.Status == CaseLenderStateEnum.Offered ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Rejected ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Withdrawn)\r\n ) {\r\n this.prevPath = \"commercialcasedashboard\";\r\n this.feedBackDTO.IsLenderFeedback = true;\r\n this.showLenderFeedBackModal = true;\r\n } else {\r\n this.$location.path(\"/commercialcasedashboard/\" + this.currentDeal.Id);\r\n }\r\n }\r\n\r\n /** Close modal after send feedback */\r\n closeModal() {\r\n this.showDirection = false;\r\n this.showTsAndCsModal = false;\r\n this.showInformationMessage = false;\r\n this.isConfirmClicked = false;\r\n this.showdeleteChatMessageModal = false;\r\n if (this.goToUserDashboard) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n this.goToUserDashboard = false;\r\n this.showFeedbackSectionLender = false;\r\n this.showHoTDetailSectionLender = false;\r\n this.showRejectSectionLender = false;\r\n this.showWithdrawSectionLender = false;\r\n }\r\n\r\n if (this.prevPath) {\r\n if (this.isLender) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n } else {\r\n this.$location.path(`/${this.prevPath}/${this.currentDeal.Id}`);\r\n }\r\n }\r\n }\r\n\r\n goToLending() {\r\n if (\r\n this.isBroker && this.currentCaseLender &&\r\n !this.currentCaseLender.IsLenderReviewComplete &&\r\n (this.currentCaseLender.Status == CaseLenderStateEnum.Offered ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Rejected ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Withdrawn)\r\n ) {\r\n this.prevPath = \"dealforum\";\r\n this.feedBackDTO.IsLenderFeedback = true;\r\n this.showLenderFeedBackModal = true;\r\n } else {\r\n this.$location.path(\"/dealforum/\" + this.currentDeal.Id);\r\n }\r\n }\r\n\r\n saveUpdatedCaseLender(): void {\r\n this.dealLenderService\r\n .addUpdate(this.currentCaseLender)\r\n .then((response) => {\r\n this.currentCaseLender = response;\r\n this.messageContent = \"Your changes have been saved.\";\r\n this.showInformationMessage = true;\r\n });\r\n }\r\n\r\n dummyDIP() {\r\n this.dealLenderService.dummyDIP(this);\r\n }\r\n\r\n /** Process the Reject button being clicked*/\r\n rejectClicked(): void {\r\n this.isRejectClicked = true;\r\n this.dealLenderService\r\n .rejectCase(this.currentCaseLender)\r\n .then((response) => {\r\n this.currentCaseLender.Status = response.CaseLenderState;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.messageContent =\r\n \"The borrower has been notified you have rejected their application.\";\r\n })\r\n .catch((error) => {\r\n this.messageContent = \"Sorry, something went wrong. Please try again.\";\r\n this.isRejectClicked = false;\r\n })\r\n .finally(() => {\r\n this.goToUserDashboard = true;\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentDeal.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n });\r\n }\r\n\r\n ///**Process the Withdraw button being clicked */\r\n withdrawClicked(): void {\r\n this.isWithdrawClicked = true;\r\n this.dealLenderService\r\n .withdrawHoT(this.currentCaseLender)\r\n .then((response) => {\r\n this.currentCaseLender.Status = response.CaseLenderState;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.messageContent =\r\n \"The borrower has been notified you have withdrawn terms for their application.\";\r\n })\r\n .catch((error) => {\r\n this.messageContent = \"Sorry, something went wrong. Please try again.\";\r\n this.isWithdrawClicked = false;\r\n })\r\n .finally(() => {\r\n this.goToUserDashboard = true;\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentDeal.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n });\r\n }\r\n\r\n ///**Process the Submit button being clicked */\r\n submitClicked() {\r\n this.isConfirmClicked = true;\r\n this.showTsAndCsModal = true;\r\n }\r\n\r\n ///**Heads of Terms Submit button clicked event */\r\n submitHoTClicked() {\r\n // Close the Heads of Terms' Terms and Conditions modal\r\n this.showTsAndCsModal = false;\r\n this.sendingMessage = true;\r\n\r\n var request = {\r\n dealLender: this.currentCaseLender,\r\n dealLenderStatus: this.currentCaseLender.Status,\r\n } as BridgingSubmitOfferRequest;\r\n\r\n // Submit the Heads of Terms\r\n this.dealLenderService\r\n .submitOffer(request)\r\n .then((response) => {\r\n this.currentCaseLender.Status = response.dealLenderStatus;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.messageContent =\r\n \"Thank you for submitting a Decision in Principle.\";\r\n this.goToUserDashboard = true;\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while submitting your Decision in Principle. Please try again.\";\r\n this.isConfirmClicked = false;\r\n })\r\n .finally(() => {\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentDeal.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n this.sendingMessage = false;\r\n });\r\n }\r\n\r\n /**\r\n * Process the Send Feedback button being clicked\r\n * @param message\r\n */\r\n sendChatMessage() {\r\n \r\n this.dataLoading = true;\r\n let DealChatMessage = {\r\n Message: this.newChatMessage,\r\n DealId: this.$routeParams.DealId,\r\n DealLenderId: this.$routeParams.DealLenderId,\r\n SenderRole: this.getSenderMessageRole(),\r\n RecipientRoles: this.isLender ? 10 : 4,\r\n } as DealLenderMessageDTO;\r\n\r\n this.dealLenderMessageService\r\n .addUpdate(DealChatMessage)\r\n .then((dealChatMessageResponse) => {\r\n this.currentCaseLender.DealLenderMessage.push(dealChatMessageResponse);\r\n this.newChatMessage = null;\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while sending feedback. Please try again.\";\r\n }).finally(() =>{\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n showFullChatMessage(index) {\r\n this.showFullMessageId = index;\r\n }\r\n\r\n updateCaseLenderMessageReadDatetime() {\r\n this.dealLenderMessageService\r\n .updateDealLenderMessageReadDatetime(this.$routeParams.DealLenderId)\r\n .then((caseLenderMessageResponse) => { });\r\n }\r\n\r\n onFileSelect(files: FileAttachmentDTO[], module: ModuleEnum) {\r\n if (files.length > 0) {\r\n this.dealFileAttachmentService\r\n .UploadFileListInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.$routeParams.DealId,\r\n this.fileUpload,\r\n module,\r\n this.$routeParams.DealLenderId,\r\n )\r\n .then((result) => {\r\n this.openModal = false;\r\n });\r\n }\r\n }\r\n\r\n downloadFile(file: DealFileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.dealFileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n this.$window.open(uri);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n deleteFile(file: DealFileAttachmentDTO) {\r\n this.fileUpload.splice(this.fileUpload.indexOf(file), 1);\r\n this.dealFileAttachmentService.markasdeleted(file.Id).then((result) => { }); //remove on the server\r\n }\r\n\r\n showActionButtons() {\r\n if (this.currentCaseLender && (this.currentCaseLender.Status == CaseLenderStateEnum.Received || this.currentCaseLender.Status == CaseLenderStateEnum.Rejected || this.currentCaseLender.Status == CaseLenderStateEnum.Offered || this.currentCaseLender.Status == CaseLenderStateEnum.Cancelled || this.currentCaseLender.Status == CaseLenderStateEnum.Withdrawn)) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n calculatemonetaryLAFee() {\r\n if (\r\n this.currentCaseLender.LenderArrangementFeePercent != null &&\r\n this.currentCaseLender.LenderArrangementFeePercent > 0 &&\r\n this.currentCaseLender.TotalNetLoan != null &&\r\n this.currentCaseLender.TotalNetLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderArrangementFee =\r\n Math.round(\r\n this.currentCaseLender.TotalNetLoan *\r\n this.currentCaseLender.LenderArrangementFeePercent *\r\n 100,\r\n ) / 100;\r\n } else {\r\n this.currentCaseLender.LenderArrangementFee = 0;\r\n }\r\n }\r\n\r\n calculatemonetaryLAPercent() {\r\n if (\r\n this.currentCaseLender.LenderArrangementFee != null &&\r\n this.currentCaseLender.LenderArrangementFee > 0 &&\r\n this.currentCaseLender.TotalNetLoan != null &&\r\n this.currentCaseLender.TotalNetLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderArrangementFeePercent =\r\n this.currentCaseLender.LenderArrangementFee /\r\n this.currentCaseLender.TotalNetLoan;\r\n\r\n this.currentCaseLender.LenderArrangementFeePercent = parseFloat(\r\n this.currentCaseLender.LenderArrangementFeePercent.toFixed(4),\r\n );\r\n } else {\r\n this.currentCaseLender.LenderArrangementFeePercent = 0;\r\n }\r\n }\r\n\r\n getMortgageInterestTypeText(e: InterestRateTypeEnum) {\r\n switch (e) {\r\n case InterestRateTypeEnum.Fixed:\r\n return \"Fixed\";\r\n case InterestRateTypeEnum.Variable:\r\n return \"Variable\";\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n getRepaymentTypeText(e: LoanRepaymentTypeEnum) {\r\n switch (e) {\r\n case LoanRepaymentTypeEnum.InterestOnly:\r\n return \"Interest only\";\r\n case LoanRepaymentTypeEnum.Repayment:\r\n return \"Capital & Interest\";\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n addClass(star: number, id: string) {\r\n this.feedBackService.addClass(star, id);\r\n }\r\n\r\n removeClass(star: number, id: string, rating) {\r\n this.feedBackService.removeClass(star, id, rating);\r\n }\r\n\r\n isFeedBackFormDisabled() {\r\n return this.feedBackService.isFeedBackFormDisabled(\r\n this.isLender,\r\n this.feedBackDTO,\r\n );\r\n }\r\n\r\n updateRating(star, rating) {\r\n this.feedBackDTO = this.feedBackService.updateRating(\r\n star,\r\n rating,\r\n this.feedBackDTO,\r\n );\r\n }\r\n\r\n submitFeedBack() {\r\n if (this.isLender) {\r\n this.feedBackDTO.OrganisationId = this.currentDeal.BrokerOrganisationId;\r\n this.feedBackDTO.BrokerUserId = this.currentDeal.BrokerUserId;\r\n } else {\r\n this.feedBackDTO.LenderId = this.currentCaseLender.LenderId;\r\n }\r\n\r\n this.feedBackService\r\n .addFeedBack(this.feedBackDTO, this.currentCaseLender.Id, true)\r\n .then((response) => {\r\n if (this.isLender) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n } else {\r\n this.$location.path(`/${this.prevPath}/${this.currentDeal.Id}`);\r\n }\r\n });\r\n }\r\n\r\n showBrokerFeedBack() {\r\n this.feedBackDTO.IsBrokerFeedback = true;\r\n this.showBrokerFeedBackModal = true;\r\n }\r\n\r\n onClickDeleteMessageButton(message: DealLenderMessageDTO) {\r\n this.showdeleteChatMessageModal = true;\r\n this.messageContent = \"Are you sure you want to delete a selected message?\";\r\n this.selectedDealLenderMessageDto = message;\r\n this.showConfirmDeleteButton = true;\r\n }\r\n\r\n deleteChatMessage() {\r\n this.dataLoading = true;\r\n this.dealLenderMessageService\r\n .markasdeleted(this.selectedDealLenderMessageDto.Id)\r\n .then((response) => {\r\n this.currentCaseLender.DealLenderMessage =\r\n this.currentCaseLender.DealLenderMessage.filter(\r\n (x) => x.Id != this.selectedDealLenderMessageDto.Id,\r\n );\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while deleting message. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.showdeleteChatMessageModal = false;\r\n delete this.selectedDealLenderMessageDto;\r\n this.showConfirmDeleteButton = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n getCurrentUserAndRoles() {\r\n this.dataLoading = true;\r\n this.userService\r\n .getcurentuserrecord()\r\n .then((result) => {\r\n this.currentUser = result;\r\n\r\n this.roleService.isClientUser().then((response) => {\r\n this.isClient = response;\r\n });\r\n\r\n this.roleService.isAdminUser().then((response) => {\r\n this.isAdmin = response;\r\n });\r\n\r\n this.roleService.isBroker().then((response) => {\r\n this.isBroker = response;\r\n });\r\n\r\n this.roleService.isLenderUser().then((response) => {\r\n this.isLender = response;\r\n if (!this.isLender) {\r\n this.toggleFeedbackSection = true;\r\n this.updateCaseLenderMessageReadDatetime();\r\n }\r\n });\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n getSenderMessageRole() {\r\n if (this.isLender) {\r\n return MessageRoleEnum.Lender;\r\n } else if (this.isBroker) {\r\n return MessageRoleEnum.Broker;\r\n } else if (this.isAdmin) {\r\n return MessageRoleEnum.Admin;\r\n } else if (this.isClient) {\r\n return MessageRoleEnum.Client;\r\n }\r\n }\r\n\r\n populateLenderInformation(user: ApplicationUserDTO) {\r\n if (this.isLender) {\r\n this.currentCaseLender.ContactName = user.FullName;\r\n this.currentCaseLender.ContactEmail = user.Email;\r\n this.currentCaseLender.ContactMobilePhoneNumber = user.PhoneNumber;\r\n } \r\n }\r\n\r\n isCurrentUserAllowedToSendChat(){\r\n if(this.currentUser && this.currentDeal && (this.toggleFeedbackSection||this.showFeedbackSectionLender)){\r\n return this.sharedHeadsOfTermsService.isCurrentUserAllowedToSendChat(this.isBroker,this.currentDeal.Status,this.currentDeal.IsReferredToConnect,this.currentUser)\r\n }\r\n return false;\r\n }\r\n}\r\n","export const enum EPCRatingTypeEnum {\r\n None = 0,\r\n A = 1,\r\n B = 2,\r\n C = 4,\r\n D = 8,\r\n E = 16,\r\n AboveE = 32,\r\n AtoC = 7,\r\n DtoE = 24,\r\n}\r\n","export const enum EWS1GradeTypeEnum {\r\n None = 0,\r\n A = 1,\r\n B = 2,\r\n}\r\n","export const enum MaxIndividualUnitPriceEnum {\r\n None,\r\n NoMax = 0,\r\n UpTo1Million = 1,\r\n UpTo2Million = 2,\r\n UpTo5Million = 3,\r\n}\r\n","export const enum TimeLeftOnLeaseEnum {\r\n None = 0,\r\n LessThanYear = 1,\r\n OneToThreeYears = 2,\r\n MoreThanThreeYears = 3,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { CommercialDealDTO } from \"@js/DTO/Deal/CommercialDealDTO.cs.d\";\r\nimport { DealLenderDTO } from \"@js/DTO/Deal/DealLenderDTO.cs.d\";\r\nimport { ShareDealDTO } from \"@js/DTO/Deal/SearchDealDTO.cs.d\";\r\nimport { LenderProductPairDTO } from \"@js/DTO/LenderProductPairDTO.cs\";\r\nimport { SaveAsSearchRequest } from \"@js/DTO/Messages/Deal/SaveAsSearchMessage.cs.d\";\r\nimport { SaveCommercialSearchRequest } from \"@js/DTO/Messages/Deal/SaveCommercialSearchMessage.cs.d\";\r\nimport { MakeReferralMessageRequest } from \"@js/DTO/Messages/MakeReferralMessage.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { CommercialLenderResultSummaryDTO } from \"@js/DTO/SearchResults/CommercialLenderResultSummaryDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { BridgingPersonalGuaranteeLevelEnum } from \"@js/models/enum/BridgingPersonalGuaranteeLevelEnum.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { EPCRatingTypeEnum } from \"@js/models/enum/EPCRatingTypeEnum.cs.d\";\r\nimport { EventLogEnum } from \"@js/models/enum/EventLogEnum.cs.d\";\r\nimport { EWS1GradeTypeEnum } from \"@js/models/enum/EWS1GradeTypeEnum.cs.d\";\r\nimport { FixedRateTermEnum } from \"@js/models/enum/FixedRateTermEnum.cs.d\";\r\nimport { InterestRateTypeEnum } from \"@js/models/enum/InterestRateTypeEnum.cs.d\";\r\nimport { MaxIndividualUnitPriceEnum } from \"@js/models/enum/MaxIndividualUnitPriceEnum.cs.d\";\r\nimport { OwnOrPurchaseEnum } from \"@js/models/enum/OwnOrPurchaseEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { PropertyTypeEnum } from \"@js/models/enum/PropertyTypeEnum.cs.d\";\r\nimport { SortByEnum } from \"@js/models/enum/SortByEnum.cs.d\";\r\nimport { TimeLeftOnLeaseEnum } from \"@js/models/enum/TimeLeftOnLeaseEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CommercialDealService } from \"@js/services/Deal/CommercialDealService\";\r\nimport { CommercialSearchResultsService } from \"@js/services/Deal/CommercialSearchResultsService\";\r\nimport { DealLenderService } from \"@js/services/Deal/DealLenderService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { SharedSearchResultsService } from \"@js/services/Deal/SharedSearchResultsService\";\r\nimport { DealClientService } from \"@js/services/DealClientService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationLinkService } from \"@js/services/OrganisationLinkService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { SharedDataService } from \"@js/services/SharedDataService\";\r\n\r\ndeclare const window: Window & { dataLayer: any[] };\r\n\r\nexport class CommercialLenderResultScreenController {\r\n loadingData: boolean = false;\r\n // tourState: any = {\r\n // tourStep: 1,\r\n // tourTotalSteps: 0,\r\n // };\r\n guidanceCheckbox: boolean = true;\r\n // tourEnabled: boolean = false;\r\n totalLender: number = 0;\r\n isSearch: boolean = true;\r\n debug1: boolean = false;\r\n loanCriteria: CommercialDealDTO;\r\n dealLenders: DealLenderDTO[];\r\n tempLoanCriteria = null;\r\n comparisonList: CommercialLenderResultSummaryDTO[] = [];\r\n snapshotNewSearch: boolean = false;\r\n isShortlistingMore: boolean = false;\r\n isLoggedInUser: boolean = false;\r\n showLenderNamesAndLogosOverride: boolean = false;\r\n searchid: number = null;\r\n dealUniqueRef: string = null;\r\n dealClientUniqueRef: string = null;\r\n orgCode: string;\r\n orgName: string = \"Brickflow\";\r\n mortgageTerm: number = 0;\r\n userLenderId: number = null;\r\n\r\n //session storage values for enterprise journey\r\n userRole: string = null;\r\n clientId: string = null;\r\n isClient: boolean = false;\r\n\r\n //Enterprise user\r\n user: ApplicationUserDTO;\r\n showEnterpriseRegistrationModal: boolean = false;\r\n projectName: string = \"\";\r\n hasAccessToDeal: boolean = true;\r\n summarySearchResults: CommercialLenderResultSummaryDTO[];\r\n initialSummarySearchResults: CommercialLenderResultSummaryDTO[];\r\n productLastVerifiedDates = {};\r\n deletedDealLenders: LenderProductPairDTO[];\r\n sliderShown: boolean;\r\n isAssigned: boolean = false;\r\n inActiveDealLender: number = 0;\r\n brokerageOrg: OrganisationDTO;\r\n moveContactBrokerBtnInMiddle: boolean = false;\r\n brokerDetail: string = \"\";\r\n brokerageOrgFilename: string;\r\n selectedUser: ApplicationUserDTO = {} as ApplicationUserDTO;\r\n isAdmin: boolean = false;\r\n isLender: boolean = false;\r\n isBroker: boolean = false;\r\n\r\n //These are added for new search functinality\r\n existingUsers: UserSimpleDTO[];\r\n newSearch: boolean = false;\r\n existingborrower: boolean;\r\n showClientDetails: boolean = false;\r\n\r\n isLoggingOut: boolean = false;\r\n appName: string;\r\n shareDealDto: ShareDealDTO = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n\r\n toggleEditSearchName: boolean = false;\r\n showProductNote: boolean = false;\r\n productNote: string;\r\n offer: CommercialLenderResultSummaryDTO;\r\n loanLabel: string;\r\n displayMsg: string = null;\r\n showMsg: boolean = false;\r\n ShowdeleteSearch: boolean = false;\r\n warningOff: boolean = false;\r\n emailExistsError: boolean = false;\r\n noOfShortlistAllowed: number = 5;\r\n showMessageToborrower: boolean = false;\r\n borrowerMessage: string = \"\";\r\n showContactBrokerModal: boolean = false;\r\n\r\n borrowingEntityTypeOptions = [];\r\n interestRateTypeOptions = [];\r\n loanRepaymentTypeOptions = [];\r\n timeLeftOnLeaseOptions = [];\r\n numberOfPreviousDevelopmentsOptions = [];\r\n personalGuaranteeLevelOptions = [];\r\n maxIndividualUnitPriceOptions = [];\r\n acceptableEPCRatingOptions = [];\r\n acceptableEWS1GradeTypeOptions = [];\r\n currentUseofBuildingOptions = [];\r\n tradingPeriodOptions = [];\r\n fixedrateTermOptions = [];\r\n locationOptions = [];\r\n yearsTradingOptions = [];\r\n maxIndividualUnitPrice = null;\r\n acceptableEPCRating = null;\r\n maxCommercialFloorspaceOptions = [];\r\n\r\n hasSearchChanged: boolean = false;\r\n showFilters: boolean = false;\r\n personalGuaranteeLevel = null;\r\n\r\n isProceedClicked: boolean = false;\r\n isSaveorSaveAsClicked: boolean = false;\r\n productResultList: number;\r\n isSaveAsWthOutIntroducee: boolean = false;\r\n tempSearchName: string = null;\r\n // Flag to disable or enable the Save as button depending on the click.\r\n isClicked: boolean = false;\r\n showSaveResults: number;\r\n //This boolean is used in the shareedmodal.html for all the deals\r\n isDeal: boolean = true;\r\n showSortBy: boolean = false;\r\n\r\n isResultScreen: boolean = true;\r\n selecteduserName: string;\r\n sharedSearch: boolean = false;\r\n searchPanelForm: ng.IFormController;\r\n\r\n showPostcodeErrorMessage: boolean = false;\r\n postcodeErrorMsg: string;\r\n isPostcodeChange: boolean = false;\r\n noAccessToDealMsg: string;\r\n //LenderReferralSearch\r\n lenderReferralData: MakeReferralMessageRequest =\r\n {} as MakeReferralMessageRequest;\r\n isLenderReferredSearch: boolean = false;\r\n isLenderReferringSearch: boolean = false;\r\n\r\n hasResultsProcessed: boolean = false;\r\n\r\n //SaveAs functionality\r\n isSaveAsClicked: boolean = false;\r\n saveAsSearchName: string;\r\n reloadSearch: boolean = false;\r\n\r\n //Enterprise journey\r\n showRegisterModal: boolean = false;\r\n showLoginSection: boolean = false;\r\n enterpriseClient: ApplicationUserDTO = {\r\n Id: \"\",\r\n AgreedToTermsAndPP: true,\r\n Roles: [\"Client\"],\r\n } as ApplicationUserDTO;\r\n error: string = \"\";\r\n\r\n isCommercial: boolean = true;\r\n\r\n // Previously shortlisted/submitted lenders which are not visible on current results because of criteria change\r\n HiddenDealLenderList: DealLenderDTO[] = [];\r\n\r\n showExportOptions: boolean = false;\r\n\r\n hasLiveSearch: boolean = true;\r\n\r\n //Confirm phone number for new client, when they register through enterprise journey from results page\r\n showClientPhoneNumberConfirmationModal: boolean = false;\r\n clientUpdatedContact: string;\r\n confirmClientPhoneNumberForm: ng.IFormController;\r\n clientUpdatedContactErrorMessage: string;\r\n // Logging in/resetting password\r\n isLoginError: boolean = false;\r\n isResetPasswordSubmitted: boolean = false;\r\n registrationLoginError: string = null;\r\n\r\n filterProperties = [\r\n \"F_IsFirstTimeDeveloper\",\r\n \"F_IsPersonalName\",\r\n \"F_IsOffshoreCompany\",\r\n \"F_IsMainShareholderOverseas\",\r\n \"F_PersonalGuaranteeMax\",\r\n \"F_MinOwnershipPeriod\",\r\n \"F_HasAdverseCredit\",\r\n \"F_MaxCommercialFloorspace\",\r\n \"F_IsGradeOneListed\",\r\n \"F_IsGradeTwoListed\",\r\n \"F_IsTimberFrameConstruction\",\r\n \"F_IsConcreteConstruction\",\r\n \"F_MaxIndividualUnitPrice\",\r\n \"F_AcceptableEPCRating\",\r\n \"F_IsFixedRate\",\r\n \"F_IsRetypedValuation\",\r\n \"F_IsChargeOnAdditionalProperty\",\r\n \"F_IsInterestOnly\",\r\n \"F_IsCapitalAndRepayment\",\r\n \"F_EWS1AcceptableType\",\r\n \"F_MaxAgeAtStartOfMortgageTerm\",\r\n \"F_MaxAgeAtEndOfMortgageTerm\"\r\n ];\r\n\r\n static $inject = [\r\n \"$route\",\r\n \"$routeParams\",\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"$cookies\",\r\n \"OrganisationService\",\r\n \"CommercialSearchResultsService\",\r\n \"SelectListService\",\r\n \"EventLogService\",\r\n \"LenderService\",\r\n \"DealLenderService\",\r\n \"RoleService\",\r\n \"UserService\",\r\n \"SharedSearchResultsService\",\r\n \"CommercialDealService\",\r\n \"DealService\",\r\n \"AuthService\",\r\n \"DealClientService\",\r\n \"ProductService\",\r\n 'OrganisationLinkService',\r\n 'SharedDataService'\r\n ];\r\n\r\n constructor(\r\n private $route: ng.route.IRouteService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $scope: ng.IScope,\r\n public $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private organisationService: OrganisationService,\r\n private commercialSearchResultsService: CommercialSearchResultsService,\r\n private selectListService: SelectListService,\r\n private eventLogService: EventLogService,\r\n private lenderService: LenderService,\r\n private dealLenderService: DealLenderService,\r\n private roleService: RoleService,\r\n private $user: UserService,\r\n private sharedSearchResultsService: SharedSearchResultsService,\r\n private commercialDealService: CommercialDealService,\r\n private dealService: DealService,\r\n private $auth: AuthService,\r\n private dealClientService: DealClientService,\r\n private productService: ProductService,\r\n private organisationLinkService: OrganisationLinkService,\r\n private sharedDataService: SharedDataService\r\n ) {\r\n if (this.$location.path().startsWith(\"/commercialshortlistmore\")) {\r\n this.isShortlistingMore = true;\r\n }\r\n\r\n //Hide header for borrower on page header\r\n /* if (\r\n window.self == window.top &&\r\n sessionStorage.getItem(\"userRole\") &&\r\n sessionStorage.getItem(\"userRole\") == \"borrower\" &&\r\n !$cookies.get(\"access_token\")\r\n ) {\r\n document.getElementById(\"header\").style.display = \"none\";\r\n }*/\r\n\r\n if (this.$routeParams.DealId) {\r\n if (/^\\d+$/.test(this.$routeParams.DealId)) {\r\n // Treat the reference as an ID (e.g., fetch data using the ID)\r\n this.searchid = Number(this.$routeParams.DealId);\r\n } else {\r\n // Treat the reference as a unique string (e.g., fetch data using the string)\r\n this.dealUniqueRef = this.$routeParams.DealId;\r\n }\r\n }\r\n\r\n if (this.$routeParams.dealclientuniqueref) {\r\n this.dealClientUniqueRef = this.$routeParams.dealclientuniqueref;\r\n }\r\n\r\n if (window.self == window.top && $cookies.get(\"access_token\")) {\r\n //This block is to navigate a broker to userdashboard when they do not have a license.\r\n if (sessionStorage.getItem(\"isValidLicense\") == \"false\") {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n this.isLoggedInUser = true;\r\n this.loadingData = true;\r\n this.organisationService\r\n .getOrganisation()\r\n .then((organisation) => {\r\n if (organisation) {\r\n this.orgCode = organisation.IsWhiteLabelled\r\n ? organisation.OrganisationCode\r\n : \"\";\r\n this.showLenderNamesAndLogosOverride =\r\n organisation.ShowLenderNames ?? false;\r\n if (organisation.IsWhiteLabelled) {\r\n this.orgName = organisation.Name.replace(/ /g, \"_\");\r\n }\r\n }\r\n })\r\n .catch((error) => {\r\n this.loadingData = false;\r\n })\r\n .finally(() => {\r\n // this.loadingData = false;\r\n });\r\n } else {\r\n if (window.self == window.top) {\r\n //this.userRole = sessionStorage.getItem('userRole');\r\n this.isClient = this.userRole == \"borrower\";\r\n this.orgCode = this.$cookies.get(\"org_code\");\r\n // this.clientId = sessionStorage.getItem('clientId');\r\n this.getSearchCriteriaAndResults();\r\n } else {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n this.guidanceCheckbox = false;\r\n Promise.all([\r\n this.organisationService.getData(\"userRole\").then((userRole) => {\r\n if (userRole) {\r\n this.userRole = userRole;\r\n this.isClient = this.userRole == \"borrower\";\r\n }\r\n }) /*,\r\n this.organisationService.getData('clientId').then(clientId => {\r\n if (clientId) {\r\n this.clientId = clientId;\r\n }\r\n })*/,\r\n //Try get session storage if running in iframe before getting results\r\n this.organisationService.getData(\"newSearch\").then((newSearch) => {\r\n if (newSearch) {\r\n this.snapshotNewSearch = newSearch == \"true\";\r\n }\r\n }),\r\n ])\r\n .then(() => {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n this.organisationService.sendDataToParent(\"newSearch\", \"false\");\r\n this.getSearchCriteriaAndResults();\r\n })\r\n .catch((error) => {\r\n // One or both of the promises were rejected, handle the error\r\n console.error(\"Failed to get user data: \", error);\r\n });\r\n }\r\n }\r\n\r\n if (window.self == window.top) {\r\n // let cookieTourStep = this.$cookies.get(\"tourStep\");\r\n // if (cookieTourStep) {\r\n // this.tourState.tourStep = cookieTourStep;\r\n // }\r\n\r\n //if user is logged in, get profile\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.$user.getcurentuserrecord().then((result) => {\r\n this.selectedUser = result;\r\n\r\n this.roleService.isClientUser().then((response) => {\r\n this.isClient = response;\r\n });\r\n\r\n this.roleService.isAdminUser().then((response) => {\r\n this.isAdmin = response;\r\n if (this.isAdmin) {\r\n this.getUsersBelongToBrokerOrAdmin();\r\n }\r\n });\r\n\r\n this.roleService.isBroker().then((response) => {\r\n this.isBroker = response;\r\n if (this.isBroker) {\r\n this.getUsersBelongToBrokerOrAdmin();\r\n }\r\n });\r\n\r\n this.roleService.isLenderUser().then((response) => {\r\n this.isLender = response;\r\n this.updateLoanLabels();\r\n if (this.isLender) {\r\n this.hasLiveSearch = false;\r\n this.lenderService.getUserLenderDetails().then((lender) => {\r\n if (lender.HasLiveMarketSearch) {\r\n this.hasLiveSearch = true;\r\n }\r\n });\r\n\r\n //Lender referred search\r\n if (sessionStorage.getItem(\"lenderReferralClient\")) {\r\n this.lenderReferralData.ClientDTO = JSON.parse(\r\n sessionStorage.getItem(\"lenderReferralClient\"),\r\n );\r\n this.isLenderReferringSearch = true;\r\n }\r\n this.$user.getCurrentUserLender().then((response) => {\r\n this.userLenderId = response;\r\n });\r\n }\r\n });\r\n\r\n if (this.isShortlistingMore) {\r\n this.lenderService.getDealDeletedLenderIds(this.searchid).then(response => {\r\n this.deletedDealLenders = response;\r\n }).finally(() => {\r\n this.getSearchCriteriaAndResults();\r\n });\r\n } else {\r\n this.getSearchCriteriaAndResults();\r\n }\r\n\r\n }).catch((error) => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n this.isClient = true; // if the user isn't logged in then this is the enterprise journey and should be treated as a borrower/client\r\n }\r\n\r\n // this.updateGuidanceState();\r\n\r\n // $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n // this.updateGuidanceState();\r\n // });\r\n\r\n let logoutUnregister = $rootScope.$on(\r\n \"logout\",\r\n (event: ng.IAngularEvent) => {\r\n this.isLoggingOut = true;\r\n },\r\n );\r\n\r\n $scope.$on(\"$destroy\", logoutUnregister);\r\n\r\n // $rootScope.$on(\"nextTour\", (event: ng.IAngularEvent) => {\r\n // this.tourNext();\r\n // });\r\n // $rootScope.$on(\"backTour\", (event: ng.IAngularEvent) => {\r\n // this.tourBack();\r\n // });\r\n // $rootScope.$on(\"skipTour\", (event: ng.IAngularEvent) => {\r\n // this.tourSkip();\r\n // });\r\n }\r\n\r\n this.interestRateTypeOptions = this.selectListService.GetInterestRateType();\r\n this.loanRepaymentTypeOptions =\r\n this.selectListService.GetLoanRepaymentTypeOptions();\r\n this.timeLeftOnLeaseOptions =\r\n this.selectListService.GetTimeLeftOnLeaseOptions();\r\n this.personalGuaranteeLevelOptions =\r\n this.selectListService.GetBridgingPersonalGuaranteeLevels();\r\n this.maxIndividualUnitPriceOptions =\r\n this.selectListService.GetMaxIndividualUnitPrices();\r\n this.acceptableEPCRatingOptions =\r\n this.selectListService.GetAcceptableEPCRating();\r\n this.acceptableEWS1GradeTypeOptions =\r\n this.selectListService.GetEWS1GradeType();\r\n this.fixedrateTermOptions =\r\n this.selectListService.GetFixedRateTermOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n this.tradingPeriodOptions = this.selectListService.GetTradingPeriodTypes();\r\n this.maxCommercialFloorspaceOptions = this.selectListService.GetMaxCommercialFloorspaceOptions();\r\n }\r\n\r\n getRequiredRoles(isCaseDashboard: boolean) {\r\n if (isCaseDashboard) return `['Admin', 'Client', 'Broker', 'Introducer']`;\r\n return `['Admin', 'Client', 'Broker', 'Introducer', 'Lender']`;\r\n }\r\n\r\n /**\r\n * Gets the search results and criteria for selected search\r\n * @param none\r\n */\r\n getSearchCriteriaAndResults() {\r\n if (window.self == window.top) {\r\n this.snapshotNewSearch = sessionStorage.getItem(\"newSearch\") == \"true\";\r\n sessionStorage.setItem(\"newSearch\", \"false\");\r\n }\r\n\r\n if (this.searchid) {\r\n this.loadingData = true;\r\n this.commercialSearchResultsService\r\n .getSearchCriteriaAndResultsByDealId(\r\n this.searchid,\r\n this.snapshotNewSearch,\r\n )\r\n .then((results) => {\r\n this.postResultsProcessing(results);\r\n })\r\n .then(() => {\r\n this.getSearchLenderCount();\r\n if (this.isLoggedInUser) this.getSelectedProducts();\r\n })\r\n .catch((error) => {\r\n console.log(error);\r\n })\r\n .finally(() => {\r\n if (this.loanCriteria) {\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.isSearch =\r\n this.loanCriteria &&\r\n this.loanCriteria.Status == CaseStatusEnum.Search;\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.currentUseofBuildingOptions =\r\n this.selectListService.GetCommercialCurrentUseOfBuildingOptions(\r\n this.loanCriteria.ProductType,\r\n );\r\n this.borrowingEntityTypeOptions =\r\n this.selectListService.GetBorrowingEntityTypeOptions(\r\n this.loanCriteria.ProductType,\r\n );\r\n this.loadingData = false;\r\n this.hasResultsProcessed = true;\r\n }\r\n });\r\n } else if (this.dealUniqueRef) {\r\n this.loadingData = true;\r\n this.commercialSearchResultsService\r\n .getSearchCriteriaAndResultsByDealUniqueRef(\r\n this.dealUniqueRef,\r\n this.snapshotNewSearch,\r\n )\r\n .then((results) => {\r\n this.postResultsProcessing(results);\r\n })\r\n .then(() => {\r\n if (this.summarySearchResults != null) {\r\n const productIds = this.summarySearchResults.map((product) => product.ProductID);\r\n this.getProductLastVerifiedDates(productIds);\r\n }\r\n })\r\n .then(() => {\r\n this.getSearchLenderCount();\r\n if (this.loanCriteria) this.getSelectedProducts();\r\n\r\n })\r\n .catch((error) => {\r\n console.log(error);\r\n })\r\n .finally(() => {\r\n if (this.loanCriteria) {\r\n this.isSearch =\r\n this.loanCriteria &&\r\n this.loanCriteria.Status == CaseStatusEnum.Search;\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.currentUseofBuildingOptions =\r\n this.selectListService.GetCommercialCurrentUseOfBuildingOptions(\r\n this.loanCriteria.ProductType,\r\n );\r\n this.borrowingEntityTypeOptions =\r\n this.selectListService.GetBorrowingEntityTypeOptions(\r\n this.loanCriteria.ProductType,\r\n );\r\n this.loadingData = false;\r\n this.hasResultsProcessed = true;\r\n }\r\n });\r\n } else if (this.dealClientUniqueRef) {\r\n this.loadingData = true;\r\n this.commercialSearchResultsService\r\n .getSearchCriteriaAndResultsByDealClientUniqueRef(\r\n this.dealClientUniqueRef,\r\n this.snapshotNewSearch,\r\n )\r\n .then((results) => {\r\n this.postResultsProcessing(results);\r\n })\r\n .then(() => {\r\n if (this.summarySearchResults != null) {\r\n const productIds = this.summarySearchResults.map((product) => product.ProductID);\r\n this.getProductLastVerifiedDates(productIds);\r\n }\r\n })\r\n .then(() => {\r\n if (this.loanCriteria) this.getSelectedProducts();\r\n this.getSearchLenderCount();\r\n if (\r\n sessionStorage.getItem(\"LoanCriteria\") &&\r\n (this.$rootScope as any).previousRoute.startsWith(\"/compare\")\r\n ) {\r\n this.comparisonList = JSON.parse(\r\n sessionStorage.getItem(\"ComparisonList\"),\r\n );\r\n\r\n //Removing lsd data saved for compare view.\r\n sessionStorage.removeItem(\"LoanCriteria\");\r\n sessionStorage.removeItem(\"ComparisonList\");\r\n }\r\n })\r\n .catch((error) => { })\r\n .finally(() => {\r\n this.isSearch =\r\n this.loanCriteria &&\r\n this.loanCriteria.Status == CaseStatusEnum.Search;\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.currentUseofBuildingOptions =\r\n this.selectListService.GetCommercialCurrentUseOfBuildingOptions(\r\n this.loanCriteria?.ProductType,\r\n );\r\n this.borrowingEntityTypeOptions =\r\n this.selectListService.GetBorrowingEntityTypeOptions(\r\n this.loanCriteria.ProductType,\r\n );\r\n this.loadingData = false;\r\n this.hasResultsProcessed = true;\r\n });\r\n }\r\n }\r\n\r\n postResultsProcessing(results) {\r\n if (results.HideDeal || results.HasNoAccessToDeal) {\r\n if (results.HasNoAccessToDeal) {\r\n if (this.isClient) {\r\n this.noAccessToDealMsg =\r\n \"Please contact your broker in order to access this case.\";\r\n } else {\r\n this.noAccessToDealMsg = \"Error retrieving deal.\";\r\n }\r\n } else {\r\n this.noAccessToDealMsg =\r\n \"You cannot access commercial search results. Please contact your admin for more details.\";\r\n }\r\n this.hasAccessToDeal = false;\r\n } else {\r\n this.summarySearchResults = this.initialSummarySearchResults = results.Results;\r\n this.loanCriteria = results.CriteriaDto;\r\n\r\n if(this.isLoggedInUser ){\r\n this.validateAccessAndRedirect();\r\n }\r\n\r\n this.sortSummaryResults();\r\n\r\n if (this.loanCriteria.LoanTermReq && this.loanCriteria.LoanTermReq > 0) {\r\n this.mortgageTerm = this.loanCriteria.LoanTermReq / 12;\r\n }\r\n\r\n if (this.isLoggedInUser) {\r\n if (this.dealClientUniqueRef) {\r\n if (this.isClient) {\r\n this.eventLogService.logPageLoad(\r\n \"AFTER-ENTERPRISE-LEAD-REGISTRATION-USING-EMAIL-LINK\",\r\n this.orgCode,\r\n this.selectedUser.UserName,\r\n \"Client\",\r\n this.loanCriteria?.OrganisationLinkId,\r\n this.loanCriteria.ProductType,\r\n \"\",\r\n this.loanCriteria?.Id,\r\n );\r\n }\r\n } else {\r\n if (this.loanCriteria.LenderReferralLenderId)\r\n this.isLenderReferredSearch = true;\r\n\r\n // Showing confirm client phone number modal once client register through result page\r\n if (this.isClient && sessionStorage.getItem('showConfirmClientPhoneNo') == 'true') {\r\n this.showClientPhoneNumberConfirmationModal = true;\r\n this.clientUpdatedContact = this.loanCriteria?.DealClients[0].Client.PhoneNumber;\r\n }\r\n // Expanding a 'new search' panel for first time search execution\r\n if (\r\n window.self == window.top &&\r\n sessionStorage.getItem(\"newSearch\")\r\n ) {\r\n this.sliderShown = (this.$rootScope as any).previousRoute.startsWith(\"/compare\") || this.showClientPhoneNumberConfirmationModal ? false : true;\r\n sessionStorage.removeItem(\"newSearch\");\r\n }\r\n }\r\n } else {\r\n if (this.$location.path().startsWith(\"/e/commercialresults\")) {\r\n this.populateEnterpriseClientValue(\"LENDERRESULTS\");\r\n }\r\n\r\n if (this.dealClientUniqueRef) {\r\n if (this.$routeParams.showOnlyRegister == \"false\")\r\n this.isClient = true;\r\n this.populateEnterpriseClientValue(\"LENDERRESULTS-USING-EMAIL-LINK\");\r\n }\r\n }\r\n\r\n var owner = this.loanCriteria.DealClients.find((dc) => dc.IsPrimary);\r\n\r\n if (owner) {\r\n this.isAssigned = true;\r\n }\r\n }\r\n }\r\n\r\n populateEnterpriseClientValue(eventType) {\r\n if (this.loanCriteria.DealClients[0] != null) {\r\n this.enterpriseClient.FirstName =\r\n this.loanCriteria.DealClients[0].Client.FirstName;\r\n this.enterpriseClient.LastName =\r\n this.loanCriteria.DealClients[0].Client.LastName;\r\n this.enterpriseClient.Email =\r\n this.loanCriteria.DealClients[0].Client.Email;\r\n this.enterpriseClient.UserName =\r\n this.loanCriteria.DealClients[0].Client.Email;\r\n this.enterpriseClient.DealClientUniqueRef = this.loanCriteria.DealClients[0].UniqueRef;\r\n this.enterpriseClient.OrgCode = this.orgCode;\r\n this.enterpriseClient.PhoneNumber =\r\n this.loanCriteria.DealClients[0].Client.PhoneNumber;\r\n if (this.loanCriteria.DealClients[0].Client.ClientUserId) {\r\n this.showRegisterModal = true;\r\n this.showLoginSection = true;\r\n }\r\n\r\n if (this.loanCriteria.OrganisationLinkId) {\r\n this.organisationLinkService\r\n .getOrganisationLinkLogoByLinkIdAndLogPageLoadEvent(Number(this.loanCriteria.OrganisationLinkId), eventType, this.loanCriteria.Id, this.loanCriteria.ProductType, this.loanCriteria.DealClients[0]?.Client?.Email, this.loanCriteria.DealClients[0]?.Client?.Id.toString())\r\n .then((logoUrl) => {\r\n if (logoUrl) {\r\n var imgs = document.getElementsByTagName(\"img\");\r\n imgs[0].src = logoUrl\r\n }\r\n });\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n eventType,\r\n this.orgCode,\r\n this.loanCriteria.DealClients.length > 0\r\n ? this.loanCriteria.DealClients[0].Client.Email\r\n : null,\r\n \"Client\",\r\n this.loanCriteria.OrganisationLinkId != null\r\n ? this.loanCriteria.OrganisationLinkId\r\n : null,\r\n this.loanCriteria?.ProductType,\r\n null,\r\n this.loanCriteria?.Id,\r\n this.loanCriteria.DealClients.length > 0\r\n ? this.loanCriteria.DealClients[0].Client.Id.toString()\r\n : null\r\n );\r\n }\r\n\r\n //Todo Roopa: do we need a broker details?\r\n this.getOrganisationAndBrokerDetails();\r\n }\r\n }\r\n\r\n checkDeletedLender(lenderId: string, productId: string): boolean {\r\n if (this.isShortlistingMore && this.deletedDealLenders) {\r\n const deletedLender = this.deletedDealLenders.find(deletedLender => deletedLender.LenderId === String(lenderId));\r\n\r\n if (deletedLender) {\r\n return deletedLender.ProductId === String(productId);\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n getSearchLenderCount() {\r\n this.lenderService\r\n .getTotalLenders(ProductFamilyEnum.Commercial, this.loanCriteria.BrokerOrganisationId)\r\n .then((result: number) => {\r\n this.totalLender = result;\r\n });\r\n }\r\n\r\n getSelectedProducts() {\r\n if (this.summarySearchResults && this.summarySearchResults.length > 0) {\r\n this.dealLenderService\r\n .fetchDealLendersByDealId(this.dealClientUniqueRef || this.dealUniqueRef ? this.loanCriteria.Id : this.searchid)\r\n .then((results) => {\r\n this.dealLenders = results;\r\n })\r\n .then(() => {\r\n this.comparisonList = this.summarySearchResults.filter((result) => {\r\n const isDealLender = this.dealLenders.find(\r\n (dealLender) => dealLender.ProductId === result.ProductID,\r\n );\r\n if (isDealLender) {\r\n result.DealLenderStatus = isDealLender.Status;\r\n }\r\n return (result.IsDealLender = Boolean(isDealLender));\r\n });\r\n\r\n // Previously shortlisted/submitted lenders which are not visible on current results because of criteria change\r\n this.HiddenDealLenderList = this.dealLenders.filter(l =>\r\n !this.summarySearchResults.some(s => l.ProductId === s.ProductID)\r\n );\r\n\r\n if (this.comparisonList.length > 0) {\r\n var inActiveDealLenderList = this.comparisonList.filter(\r\n (ia) =>\r\n ia.DealLenderStatus == CaseLenderStateEnum.Rejected ||\r\n ia.DealLenderStatus == CaseLenderStateEnum.Withdrawn,\r\n );\r\n this.inActiveDealLender = inActiveDealLenderList.length;\r\n }\r\n\r\n if (\r\n sessionStorage.getItem(\"LoanCriteria\") &&\r\n (this.$rootScope as any).previousRoute.startsWith(\"/compare\")\r\n ) {\r\n if (sessionStorage.getItem(\"actualcomparisonList\")) {\r\n var selectedProducts = sessionStorage.getItem(\r\n \"actualcomparisonList\",\r\n );\r\n this.comparisonList = JSON.parse(selectedProducts);\r\n sessionStorage.removeItem(\"actualcomparisonList\");\r\n } else {\r\n this.comparisonList = JSON.parse(\r\n sessionStorage.getItem(\"ComparisonList\"),\r\n );\r\n }\r\n if (this.inActiveDealLender > 0) {\r\n this.comparisonList = this.comparisonList.concat(\r\n inActiveDealLenderList,\r\n );\r\n }\r\n\r\n //Removing lsd data saved for compare view.\r\n sessionStorage.removeItem(\"LoanCriteria\");\r\n sessionStorage.removeItem(\"ComparisonList\");\r\n }\r\n });\r\n }\r\n }\r\n\r\n getUsersBelongToBrokerOrAdmin() {\r\n this.loadingData = true;\r\n this.$user\r\n .getUserSummariesForBrokerOrAdmin()\r\n .then((response) => {\r\n this.existingUsers = response;\r\n });\r\n }\r\n\r\n // updateGuidanceState() {\r\n // this.tourEnabled = this.sharedSearchResultsService.updateGuidanceState(\r\n // this.guidanceCheckbox,\r\n // );\r\n // }\r\n\r\n // getGuidanceSwitchState() {\r\n // return this.sharedSearchResultsService.getGuidanceSwitchState();\r\n // }\r\n\r\n // recordGuidanceCookie() {\r\n // this.sharedSearchResultsService.recordGuidanceCookie(this.guidanceCheckbox);\r\n // this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n // }\r\n\r\n // tourNext(): void {\r\n // this.tourState.tourStep++;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // }\r\n\r\n // tourBack(): void {\r\n // this.tourState.tourStep--;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // }\r\n\r\n // tourSkip(): void {\r\n // this.tourEnabled = false;\r\n // this.$cookies.put(\"tourEnabled\", \"false\");\r\n // this.$cookies.remove(\"tourStep\");\r\n // }\r\n\r\n // startTour(): void {\r\n // this.tourState.tourStep = 1;\r\n // this.tourState.tourTotalSteps = 0;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // this.tourEnabled = true;\r\n // this.$cookies.put(\"tourEnabled\", \"true\");\r\n // }\r\n\r\n /**\r\n * Saves the new search name on the edit.\r\n * @param none\r\n */\r\n doRenameSearch() {\r\n var request: SaveCommercialSearchRequest = {\r\n DealDto: this.loanCriteria,\r\n ShareDealDto: this.shareDealDto,\r\n OrgCode: this.orgCode,\r\n EnterpriseClientDto: null,\r\n };\r\n\r\n if (this.searchid) {\r\n this.commercialDealService.saveCommercialSearchReturnsId(request)\r\n .then((response) => {\r\n this.toggleEditSearchName = false;\r\n });\r\n } else if (this.dealUniqueRef) {\r\n if (this.isLoggedInUser) {\r\n this.commercialDealService.saveCommercialSearchReturnsUniqueRef(request)\r\n .then((response) => {\r\n this.toggleEditSearchName = false;\r\n });\r\n } else {\r\n this.dealService.renameDeal(this.dealUniqueRef, this.loanCriteria.Name)\r\n .then((response) => {\r\n this.toggleEditSearchName = false;\r\n });\r\n }\r\n } else {\r\n this.toggleEditSearchName = false;\r\n }\r\n }\r\n\r\n toggleLenderComparisonSelection(\r\n item: CommercialLenderResultSummaryDTO,\r\n index: number,\r\n ) {\r\n\r\n let comparisonMatches: CommercialLenderResultSummaryDTO[] =\r\n this.comparisonList.filter((result, index) => {\r\n return result.ProductID === item.ProductID;\r\n });\r\n\r\n if (!comparisonMatches || comparisonMatches.length === 0) {\r\n this.comparisonList.push(item);\r\n this.eventLogService.logEvent(\r\n `SHORTLISTING-RESULT`,\r\n EventLogEnum.Shortlisting,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n \"\",\r\n item.ProductID.toString(),\r\n \"\"\r\n );\r\n } else {\r\n if (this.isShortlistingMore && item.IsDealLender && (this.loanCriteria.Status != CaseStatusEnum.Search && this.loanCriteria.Status != CaseStatusEnum.NewCase))\r\n return;\r\n comparisonMatches.forEach((value, index) => {\r\n this.comparisonList.splice(this.comparisonList.indexOf(value), 1);\r\n });\r\n this.eventLogService.logEvent(\r\n `DESELECTING-SHORTLISTED-RESULT`,\r\n EventLogEnum.Shortlisting,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n \"\",\r\n item.ProductID.toString(),\r\n \"\"\r\n );\r\n }\r\n\r\n\r\n //This is user for shortlisting pdf\r\n this.prepareDataForShortlistPdf();\r\n }\r\n\r\n comparisonContains(item: CommercialLenderResultSummaryDTO): boolean {\r\n return !!this.comparisonList.find((result, index) => {\r\n return result.ProductID === item.ProductID;\r\n });\r\n }\r\n\r\n checkLender(item: CommercialLenderResultSummaryDTO): boolean {\r\n if (this.userLenderId == item.LenderID) return true;\r\n return false;\r\n }\r\n\r\n selectionOrderNumber(item: CommercialLenderResultSummaryDTO) {\r\n var activeProductList = this.comparisonList.filter(\r\n (cl) =>\r\n cl.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n cl.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n\r\n var hiddenProduct = this.HiddenDealLenderList.filter(hl => hl.Status != CaseLenderStateEnum.Rejected && hl.Status != CaseLenderStateEnum.Withdrawn);\r\n var hiddenProductLength = this.isShortlistingMore ? hiddenProduct.length : 0;\r\n var order =\r\n activeProductList.map((item) => item.ProductID).indexOf(item.ProductID) + hiddenProductLength + 1;\r\n if (order === 0) {\r\n return \" \";\r\n }\r\n\r\n return order;\r\n }\r\n\r\n /**\r\n * Processes the clicking of the \"View Eligibility\" anchor/button and index to show on the row number\r\n * @param item BridgingLenderResultSummaryDTO\r\n */\r\n viewEligibility(item: CommercialLenderResultSummaryDTO) {\r\n event.preventDefault(); // prevents default behaviour of href\r\n this.showProductNote = true;\r\n this.offer = item;\r\n this.loanLabel = item.LoanLabel;\r\n this.productNote = item.AdditionalProductInfo;\r\n }\r\n\r\n /**\r\n *Marks a selected search as a deleted\r\n * @param\r\n */\r\n deleteSearch() {\r\n if (this.$routeParams.DealId) {\r\n this.dealService\r\n .markasdeleted(this.$routeParams.DealId)\r\n .then((response) => {\r\n this.displayMsg = \"Search is successfully deleted\";\r\n this.showMsg = true;\r\n this.ShowdeleteSearch = true;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n this.showMsg = true;\r\n });\r\n }\r\n }\r\n\r\n closeDeleteModal() {\r\n this.showMsg = false;\r\n this.displayMsg = null;\r\n this.ShowdeleteSearch = false;\r\n this.warningOff = true;\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n viewSingleLoan(item: CommercialLenderResultSummaryDTO) {\r\n event.preventDefault(); // prevents default behaviour of href\r\n this.warningOff = true;\r\n //Storing the actual comparisonList to local storage so that to recover it later when we comeback to result screen from compare screen.\r\n sessionStorage.setItem(\r\n \"actualcomparisonList\",\r\n JSON.stringify(this.comparisonList),\r\n );\r\n this.comparisonList = [];\r\n\r\n this.comparisonList.push(item);\r\n this.goCompare();\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n }\r\n\r\n goCompare() {\r\n this.warningOff = true;\r\n\r\n this.sharedSearchResultsService.clearStorageDataForCompareView();\r\n\r\n let comparisonList = this.comparisonList.filter(\r\n (cl) =>\r\n cl.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n cl.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n\r\n sessionStorage.setItem(\"ComparisonList\", JSON.stringify(comparisonList));\r\n sessionStorage.setItem(\"LoanCriteria\", JSON.stringify(this.loanCriteria));\r\n\r\n if (this.dealClientUniqueRef) {\r\n if (!this.isLoggedInUser) {\r\n this.dealUniqueRef = this.loanCriteria.UniqueRef;\r\n //This property is used in compare view controller to find previous route \r\n sessionStorage.setItem(\"DealClientUniqueRef\", this.dealClientUniqueRef);\r\n } else {\r\n this.searchid = this.loanCriteria.Id;\r\n }\r\n }\r\n\r\n if (this.searchid) {\r\n this.$location.path(\"compare/\" + this.searchid + \"/\" + 0 + \"/\" + true);\r\n } else {\r\n this.$location.path(\"compare/\" + this.dealUniqueRef + \"/\" + 0 + \"/\" + true);\r\n }\r\n }\r\n\r\n showBookMeetingButton() {\r\n return (\r\n !this.isLoggedInUser &&\r\n this.isClient &&\r\n this.brokerDetail == \"\" &&\r\n this.brokerageOrg != null\r\n );\r\n }\r\n\r\n bookMeeting() {\r\n this.$auth\r\n .getHubspotDeveloperBookMeetingWithSearch()\r\n .then((hubSpotUrl: string) => {\r\n window.open(hubSpotUrl);\r\n });\r\n }\r\n\r\n sendMessageToBroker(message) {\r\n this.loadingData = true;\r\n this.borrowerMessage = null;\r\n this.organisationService\r\n .sendBorrowerMessageToSearchBroker(\r\n this.loanCriteria.Id,\r\n message,\r\n this.loanCriteria.DealClients[0].Client.FirstName,\r\n this.loanCriteria.DealClients[0].Client.LastName,\r\n this.loanCriteria.DealClients[0].Client.Email,\r\n this.loanCriteria.ProductType,\r\n \"Results\",\r\n )\r\n .then((results) => {\r\n if (results) {\r\n this.displayMsg = `Message has been sent successfully.`;\r\n this.showMessageToborrower = true;\r\n } else {\r\n this.displayMsg = `There is problem sending a message, Please try later.`;\r\n this.showMessageToborrower = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n closeContactBrokerModal() {\r\n this.showContactBrokerModal = false;\r\n this.showMessageToborrower = false;\r\n this.displayMsg = null;\r\n }\r\n\r\n getTotalShortlistedLenders() {\r\n var activeDealLenders = this.comparisonList.filter(\r\n (al) =>\r\n al.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n al.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n\r\n var hiddenProduct = this.HiddenDealLenderList.filter(hl => hl.Status != CaseLenderStateEnum.Rejected && hl.Status != CaseLenderStateEnum.Withdrawn);\r\n var hiddenProductLength = this.isShortlistingMore ? hiddenProduct.length : 0;\r\n\r\n return activeDealLenders.length + hiddenProductLength;\r\n }\r\n\r\n logPdfDownload(eventName) {\r\n this.eventLogService.logEvent(\r\n eventName,\r\n EventLogEnum.Export,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n );\r\n }\r\n\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n\r\n changeSearch() {\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n this.warningOff = true;\r\n sessionStorage.setItem(\"skip\", \"true\");\r\n if (!this.isLoggedInUser && (this.dealUniqueRef || this.dealClientUniqueRef)) {\r\n if (this.dealClientUniqueRef) sessionStorage.setItem('previousRoute', 'referredsearchdeal')\r\n var url = `/e/commercialcriteria/${this.loanCriteria.UniqueRef}`;\r\n if (this.loanCriteria.OrganisationLinkId > 0) {\r\n url = `${url}/${this.loanCriteria.OrganisationLinkId}`;\r\n }\r\n this.go(url);\r\n }\r\n else if (this.searchid) {\r\n this.go(\"/commercialcriteria/\" + this.searchid);\r\n } else {\r\n this.go(\"/commercialcriteria\");\r\n }\r\n }\r\n\r\n newloan() {\r\n (this.$rootScope as any).loanCriteria = null;\r\n this.$location.path(\"/commercialcriteria/0\");\r\n }\r\n\r\n updateSearchViaSlider(isAdminDebugValueChanged: boolean = false): void {\r\n if (this.searchPanelForm.$valid && !this.showPostcodeErrorMessage) {\r\n if (this.loanCriteria.OwnOrPurchase == OwnOrPurchaseEnum.Purchasing) {\r\n if (this.loanCriteria.PurchasePrice <= 0) return;\r\n }\r\n\r\n if (this.loanCriteria.OwnOrPurchase == OwnOrPurchaseEnum.Own) {\r\n if (this.loanCriteria.Currentvalue <= 0) return;\r\n }\r\n this.loadingData = true;\r\n this.hasSearchChanged = true;\r\n\r\n this.clearSelected();\r\n\r\n this.updateCriteriaAndGetResults(\r\n isAdminDebugValueChanged && this.isAdmin ? false : true,\r\n );\r\n }\r\n }\r\n\r\n clearSelected() {\r\n if (this.isShortlistingMore) {\r\n this.comparisonList = this.comparisonList.filter(item =>\r\n this.summarySearchResults.some(result => result.ProductID == item.ProductID)\r\n );\r\n\r\n const dealLenders = this.initialSummarySearchResults.filter(result =>\r\n result.IsDealLender && !result.IsDeleted\r\n );\r\n\r\n dealLenders.forEach(dealLender => {\r\n if (!this.comparisonList.some(item => item.ProductID === dealLender.ProductID)) {\r\n this.comparisonList.push(dealLender);\r\n }\r\n });\r\n } else {\r\n this.comparisonList = this.comparisonList.filter(item =>\r\n this.summarySearchResults.some(result => result.ProductID == item.ProductID)\r\n );\r\n }\r\n }\r\n\r\n updateCriteriaAndGetResults(\r\n criteriaChanged: boolean,\r\n updateLoanLabels: boolean = false,\r\n ) {\r\n this.commercialDealService\r\n .updateSearchCriteriaAndGetResults(\r\n this.loanCriteria,\r\n criteriaChanged,\r\n this.debug1,\r\n this.isPostcodeChange,\r\n this.isShortlistingMore\r\n )\r\n .then((results) => {\r\n if (this.isPostcodeChange) {\r\n if (results.CriteriaLocation != null) {\r\n this.loanCriteria.Locations = results.CriteriaLocation;\r\n this.summarySearchResults = results.Results;\r\n } else {\r\n this.postcodeErrorMsg = results.PostCodeErrorMessage;\r\n this.showPostcodeErrorMessage = true;\r\n }\r\n } else {\r\n this.summarySearchResults = results.Results;\r\n this.sortSummaryResults();\r\n }\r\n })\r\n .catch((error) => { })\r\n .finally(() => {\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.clearSelected();\r\n if (updateLoanLabels) {\r\n this.updateLoanLabels();\r\n }\r\n\r\n this.isPostcodeChange = false;\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n getSearchResultCount() {\r\n return this.sharedSearchResultsService.getSearchResultCount(\r\n this.summarySearchResults,\r\n );\r\n }\r\n\r\n onPersonalGuaranteeLevelOptionsChange(e: BridgingPersonalGuaranteeLevelEnum) {\r\n switch (e) {\r\n case BridgingPersonalGuaranteeLevelEnum.None:\r\n this.loanCriteria.F_PersonalGuaranteeMin = 0.0;\r\n this.loanCriteria.F_PersonalGuaranteeMax = 0.0;\r\n break;\r\n case BridgingPersonalGuaranteeLevelEnum.OneToTwentyFivePercent:\r\n this.loanCriteria.F_PersonalGuaranteeMin = 0.0;\r\n this.loanCriteria.F_PersonalGuaranteeMax = 0.25;\r\n break;\r\n case BridgingPersonalGuaranteeLevelEnum.TwentySixToFiftyPercent:\r\n this.loanCriteria.F_PersonalGuaranteeMin = 0.25;\r\n this.loanCriteria.F_PersonalGuaranteeMax = 0.5;\r\n break;\r\n case BridgingPersonalGuaranteeLevelEnum.FiftyOneToOneHundredPercent:\r\n this.loanCriteria.F_PersonalGuaranteeMin = 0.5;\r\n this.loanCriteria.F_PersonalGuaranteeMax = 1.0;\r\n break;\r\n default:\r\n this.loanCriteria.F_PersonalGuaranteeMin = null;\r\n this.loanCriteria.F_PersonalGuaranteeMax = null;\r\n break;\r\n }\r\n }\r\n\r\n getPersonalGuaranteeLevelOptions() {\r\n return this.sharedSearchResultsService.getPersonalGuaranteeLevelOptions(\r\n this.tempLoanCriteria.F_PersonalGuaranteeMax,\r\n );\r\n }\r\n\r\n applyFilters() {\r\n this.loadingData = true;\r\n this.showFilters = false;\r\n this.updateCriteriaAndGetResults(false);\r\n }\r\n\r\n clearClientFilters() {\r\n this.loanCriteria.F_IsFirstTimeDeveloper = null;\r\n this.loanCriteria.F_IsPersonalName = null;\r\n this.loanCriteria.F_IsOffshoreCompany = null;\r\n this.loanCriteria.F_IsMainShareholderOverseas = null;\r\n this.loanCriteria.F_MinOwnershipPeriod = null;\r\n this.personalGuaranteeLevel = null;\r\n this.loanCriteria.F_PersonalGuaranteeMin = null;\r\n this.loanCriteria.F_PersonalGuaranteeMax = null;\r\n this.loanCriteria.F_HasAdverseCredit = null;\r\n this.loanCriteria.F_MaxAgeAtEndOfMortgageTerm = null;\r\n this.loanCriteria.F_MaxAgeAtStartOfMortgageTerm = null;\r\n\r\n }\r\n\r\n showClearForClientFilters() {\r\n if (\r\n this.loanCriteria.F_IsFirstTimeDeveloper != null ||\r\n this.loanCriteria.F_IsPersonalName != null ||\r\n this.loanCriteria.F_MinOwnershipPeriod != null ||\r\n this.loanCriteria.F_IsOffshoreCompany != null ||\r\n this.loanCriteria.F_IsMainShareholderOverseas != null ||\r\n this.loanCriteria.F_PersonalGuaranteeMin != null ||\r\n this.loanCriteria.F_PersonalGuaranteeMax != null ||\r\n this.loanCriteria.F_HasAdverseCredit != null ||\r\n this.loanCriteria.F_MaxAgeAtEndOfMortgageTerm != null ||\r\n this.loanCriteria.F_MaxAgeAtStartOfMortgageTerm != null\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n toggleCheckbox(variableName) {\r\n if (\r\n this.loanCriteria[variableName] === null ||\r\n this.loanCriteria[variableName] === false\r\n ) {\r\n this.loanCriteria[variableName] = true;\r\n } else {\r\n this.loanCriteria[variableName] = null;\r\n }\r\n }\r\n\r\n clearPropertyFilters() {\r\n this.loanCriteria.F_IsGradeOneListed = null;\r\n this.loanCriteria.F_IsGradeTwoListed = null;\r\n this.loanCriteria.F_IsTimberFrameConstruction = null;\r\n this.loanCriteria.F_IsConcreteConstruction = null;\r\n this.maxIndividualUnitPrice = null;\r\n this.loanCriteria.F_AcceptableEPCRating = null;\r\n this.loanCriteria.F_EWS1AcceptableType = null;\r\n this.loanCriteria.F_MaxIndividualUnitPrice = null;\r\n this.loanCriteria.F_MaxCommercialFloorspace = null;\r\n }\r\n\r\n showClearForPropertyFilters() {\r\n if (\r\n this.loanCriteria.F_IsGradeOneListed != null ||\r\n this.loanCriteria.F_IsGradeTwoListed != null ||\r\n this.loanCriteria.F_IsTimberFrameConstruction != null ||\r\n this.loanCriteria.F_IsConcreteConstruction != null ||\r\n this.maxIndividualUnitPrice != null ||\r\n this.loanCriteria.F_AcceptableEPCRating != null ||\r\n this.loanCriteria.F_EWS1AcceptableType != null ||\r\n this.loanCriteria.F_MaxIndividualUnitPrice != null ||\r\n this.loanCriteria.F_MaxCommercialFloorspace != null\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n clearAllFilters() {\r\n this.clearClientFilters();\r\n this.clearPropertyFilters();\r\n }\r\n\r\n debugSearch() {\r\n const stringJSON = JSON.stringify(this.loanCriteria);\r\n navigator.clipboard\r\n .writeText(stringJSON)\r\n .then()\r\n .catch((e) => console.log(e));\r\n }\r\n\r\n onClickFilterCancel() {\r\n this.filterProperties.forEach(\r\n (e) => (this.loanCriteria[e] = this.tempLoanCriteria[e]),\r\n );\r\n this.maxIndividualUnitPrice = null;\r\n this.personalGuaranteeLevel = null;\r\n }\r\n\r\n getDisplayTextForProperty(property) {\r\n return this.sharedSearchResultsService.getDisplayTextForProperty(property);\r\n }\r\n\r\n getPropertyValue(property) {\r\n let propertyValue = this.tempLoanCriteria[property];\r\n switch (property) {\r\n case \"F_PersonalGuaranteeMax\":\r\n return this.selectListService\r\n .GetBridgingPersonalGuaranteeLevels()\r\n .find((item) => item.key === this.getPersonalGuaranteeLevelOptions())\r\n ?.displayName;\r\n case \"F_MaxIndividualUnitPrice\":\r\n return this.selectListService\r\n .GetMaxHouseSalePrices()\r\n .find((item) => item.key === this.getMaxIndividualUnitPrice())\r\n ?.displayName;\r\n case \"F_AcceptableEPCRating\":\r\n return this.selectListService\r\n .GetAcceptableEPCRating()\r\n .find((item) => item.key === this.getAcceptableEPCRating())\r\n ?.displayName;\r\n case \"F_EWS1AcceptableType\":\r\n return this.selectListService\r\n .GetEWS1GradeType()\r\n .find((item) => item.key === this.getEWS1GradeType())?.displayName;\r\n case \"F_MaxCommercialFloorspace\":\r\n return this.selectListService\r\n .GetMaxCommercialFloorspaceOptions()\r\n .find((item) => item.key === this.tempLoanCriteria.F_MaxCommercialFloorspace)\r\n ?.displayName;\r\n default:\r\n return propertyValue;\r\n }\r\n }\r\n\r\n filterPropertyToText(property: string) {\r\n let value = this.tempLoanCriteria[property];\r\n if (typeof value == \"boolean\" && value == true) {\r\n return;\r\n } else if (value != null && typeof value != \"boolean\") {\r\n return `: ${this.getPropertyValue(property)}`;\r\n } else if (value == null) {\r\n return;\r\n }\r\n return false;\r\n }\r\n\r\n countFiltersSelected() {\r\n let count = 0;\r\n count = this.sharedSearchResultsService.countFiltersSelected(\r\n this.tempLoanCriteria,\r\n this.filterProperties,\r\n );\r\n return count;\r\n }\r\n\r\n checkFilterSelected(property: string) {\r\n return this.sharedSearchResultsService.checkFilterSelected(\r\n property,\r\n this.tempLoanCriteria,\r\n );\r\n }\r\n\r\n onMaxIndividualUnitPriceChange(e: MaxIndividualUnitPriceEnum) {\r\n switch (e) {\r\n case MaxIndividualUnitPriceEnum.UpTo1Million:\r\n this.loanCriteria.F_MaxIndividualUnitPrice = 1000000;\r\n break;\r\n case MaxIndividualUnitPriceEnum.UpTo2Million:\r\n this.loanCriteria.F_MaxIndividualUnitPrice = 2000000;\r\n break;\r\n case MaxIndividualUnitPriceEnum.UpTo5Million:\r\n this.loanCriteria.F_MaxIndividualUnitPrice = 5000000;\r\n break;\r\n case MaxIndividualUnitPriceEnum.NoMax:\r\n this.loanCriteria.F_MaxIndividualUnitPrice = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxIndividualUnitPrice = null;\r\n break;\r\n }\r\n }\r\n\r\n getMaxIndividualUnitPrice() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_MaxIndividualUnitPrice) {\r\n case 1000000:\r\n value = MaxIndividualUnitPriceEnum.UpTo1Million;\r\n break;\r\n case 2000000:\r\n value = MaxIndividualUnitPriceEnum.UpTo2Million;\r\n break;\r\n case 5000000:\r\n value = MaxIndividualUnitPriceEnum.UpTo5Million;\r\n break;\r\n case -999:\r\n value = MaxIndividualUnitPriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n getAcceptableEPCRating() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_AcceptableEPCRating) {\r\n case EPCRatingTypeEnum.A:\r\n case EPCRatingTypeEnum.B:\r\n case EPCRatingTypeEnum.C:\r\n case EPCRatingTypeEnum.AtoC:\r\n value = EPCRatingTypeEnum.AtoC;\r\n break;\r\n case EPCRatingTypeEnum.D:\r\n case EPCRatingTypeEnum.E:\r\n case EPCRatingTypeEnum.DtoE:\r\n value = EPCRatingTypeEnum.DtoE;\r\n break;\r\n case EPCRatingTypeEnum.AboveE:\r\n value = EPCRatingTypeEnum.AboveE;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n getEWS1GradeType() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_EWS1AcceptableType) {\r\n case EWS1GradeTypeEnum.A:\r\n value = EWS1GradeTypeEnum.A;\r\n break;\r\n case EWS1GradeTypeEnum.B:\r\n value = EWS1GradeTypeEnum.B;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n /*saveEnterpriseClientAndRenameDeal() {\r\n this.loadingData = true;\r\n\r\n this.$user.checkEmailExists(this.user.Email).then((response) => {\r\n if (!response) {\r\n let userFullName = this.user.FullName;\r\n let spaceIndex = userFullName.indexOf(' ');\r\n\r\n let firstName = '';\r\n let lastName = '';\r\n\r\n // if not space has been added to the name then put the whole name in the first name field\r\n if (spaceIndex == -1) {\r\n firstName = userFullName;\r\n } else {\r\n firstName = userFullName.substring(0, userFullName.indexOf(' '));\r\n lastName = userFullName.substring(userFullName.indexOf(' ') + 1);\r\n }\r\n\r\n // Set up Client dto\r\n var clientDto = {\r\n FirstName: firstName,\r\n LastName: lastName,\r\n PhoneNumber: this.user.PhoneNumber,\r\n Email: this.user.Email,\r\n BrokerOrganisationId: this.brokerageOrg.Id,\r\n PostalAddress: {\r\n AddressLine1: '',\r\n AddressLine2: '',\r\n AddressLine3: '',\r\n AddressLine4: '',\r\n PostCode: ''\r\n } as PostalAddress\r\n } as ClientDTO;\r\n\r\n var currentDate = new Date();\r\n this.loanCriteria.Name = this.projectName ? this.projectName : firstName + ' ' + lastName + ' Loan Search ' + currentDate.getDate() + \"/\" + (currentDate.getMonth() + 1) + \"/\" + currentDate.getFullYear()\r\n\r\n var request: SaveEnterpriseClientAndRenameSearchRequest = {\r\n BridgingDealDto: null,\r\n ClientDto: clientDto,\r\n ProductFamily: ProductFamilyEnum.Commercial,\r\n CommercialDealDto: this.loanCriteria,\r\n DevFinanceDealDto: null\r\n }\r\n\r\n this.dealService.saveEnterpriseClientAndRenameDeal(request).then((response) => {\r\n if (response) {\r\n document.getElementById('body').style.overflow = \"auto\";\r\n this.showEnterpriseRegistrationModal = false;\r\n this.loanCriteria = response.CommercialDealDto;\r\n if (window.self == window.top) {\r\n sessionStorage.setItem('clientId', this.loanCriteria.DealClients[0].Client.Id.toString());\r\n } else {\r\n this.organisationService.sendDataToParent('clientId', this.loanCriteria.DealClients[0].Client.Id.toString());\r\n }\r\n\r\n this.$user.sendEventToHubspot(this.user, \"ENTERPRISE-CONTACT-REGISTERED\", false, this.orgCode, this.userRole, this.loanCriteria && this.loanCriteria.OrganisationLinkId != null ? this.loanCriteria.OrganisationLinkId : 0, this.loanCriteria.ProductType, this.loanCriteria ? this.loanCriteria.Id : 0);\r\n\r\n // For Google analytics tracking\r\n window.dataLayer = window.dataLayer || [];\r\n window.dataLayer.push({\r\n 'event': 'results_gating_form',\r\n 'loan_product_family': this.productService.getProductFamilyTextForGa(this.loanCriteria.ProductFamily),\r\n 'loan_product_type': this.productService.getProductTypeTextForGa(this.loanCriteria.ProductType, this.loanCriteria.IsFamilyInResidence)\r\n });\r\n }\r\n\r\n }).finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n this.emailExistsError = true;\r\n this.loadingData = false;\r\n }\r\n });\r\n\r\n\r\n }*/\r\n\r\n gotoSignInPage() {\r\n this.$location.path(\"/login\");\r\n }\r\n\r\n goToLink(url) {\r\n var baseUrl = window.location.href.split(\"#!\")[0] + \"#!\";\r\n var newUrl = baseUrl + url;\r\n window.open(newUrl, \"_blank\");\r\n }\r\n\r\n /**\r\n * Opens a 'share a search with client' modal if search do not have client attached to.\r\n * @param none\r\n */\r\n saveResultsForShareSearchToClient() {\r\n if (!this.isSaveAsClicked) {\r\n this.register(false, this.productResultList);\r\n } else {\r\n this.saveSaveAsSearch();\r\n }\r\n this.newSearch = false;\r\n }\r\n\r\n showShareSearchModal() {\r\n this.newSearch = true;\r\n\r\n this.shareDealDto = {\r\n DealId: this.searchid,\r\n DealName: this.isSaveAsClicked ? \"\" : this.loanCriteria?.Name,\r\n ShowLenderNamesAndLogos: this.loanCriteria?.ShowLenderInfoBrokerOverride,\r\n EmailLinkToClient: false,\r\n AccessLevel: CaseAccessLevelEnum.FullAccess,\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n\r\n this.shareDealDto.ClientDto = {\r\n FirstName: \"\",\r\n LastName: \"\",\r\n Email: \"\",\r\n PhoneNumber: \"\",\r\n } as ClientDTO;\r\n }\r\n\r\n onClickSaveAs() {\r\n this.isSaveAsClicked = true;\r\n if (this.isAdmin || this.isBroker) {\r\n if (!this.shareDealDto) {\r\n this.shareDealDto = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n }\r\n this.shareDealDto.DealName = \"\";\r\n this.showShareSearchModal();\r\n } else {\r\n this.showSaveResults = 3;\r\n }\r\n }\r\n\r\n saveSaveAsSearch(attachClient = false) {\r\n this.loadingData = true;\r\n let newSearchName = this.isBroker || this.isAdmin ? this.shareDealDto.DealName : this.saveAsSearchName;\r\n\r\n if (newSearchName.length == 0) {\r\n newSearchName = this.loanCriteria.Name + ' (Copy)';\r\n }\r\n\r\n var request: SaveAsSearchRequest = {\r\n ShareDealDto: attachClient ? this.shareDealDto : null,\r\n ProductFamily: this.loanCriteria.ProductFamily,\r\n SearchId: this.loanCriteria.Id,\r\n NewSearchName: newSearchName,\r\n };\r\n\r\n this.dealService\r\n .saveSaveAsSearch(request)\r\n .then((result) => {\r\n this.displayMsg = `${newSearchName} search has been saved to your dashboard.`;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.cancelNewSearch();\r\n this.loadingData = false;\r\n this.isSaveAsClicked = false;\r\n this.shareDealDto = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n this.saveAsSearchName = \"\";\r\n this.showSaveResults = null;\r\n this.showMsg = true;\r\n });\r\n }\r\n\r\n /**\r\n * Saves the search or saves the search and create a case.\r\n * @param createCase (boolean set to true when promoting search to case)\r\n */\r\n\r\n //TODO: this functon does not need a productResultList parameter but as views have been shared with devfinance we are passing it\r\n register(createCase: boolean = false, productResultList: number) {\r\n this.loadingData = true;\r\n if (this.isShortlistingMore) {\r\n if (this.validateAllLendersUnique(this.comparisonList) == true) {\r\n this.dealLenderService.shortlistMoreLenders(this.loanCriteria.Id, this.getDealLenders(this.comparisonList), this.hasSearchChanged).then((response) => {\r\n }).then(() => {\r\n this.getSelectedProducts();\r\n }).finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n this.loadingData = false;\r\n }\r\n } else {\r\n if (\r\n this.shareDealDto &&\r\n this.shareDealDto.DealName &&\r\n this.shareDealDto.DealName.length > 0\r\n ) {\r\n this.loanCriteria.Name = this.shareDealDto.DealName;\r\n }\r\n\r\n var request: SaveCommercialSearchRequest = {\r\n DealDto: this.loanCriteria,\r\n ShareDealDto: null,\r\n OrgCode: \"\",\r\n EnterpriseClientDto: null,\r\n };\r\n\r\n this.commercialDealService\r\n .saveCommercialSearchReturnsId(request)\r\n .then((response) => {\r\n this.loanCriteria.Id = response as number;\r\n this.loadingData = false;\r\n\r\n // Creating the case is done on the casedashboard for deals\r\n if (createCase) {\r\n this.$location.path(\r\n \"/commercialcasedashboard/\" + this.loanCriteria.Id + \"/\" + true,\r\n );\r\n }\r\n\r\n var shortlistDealLenders = this.getDealLenders(this.comparisonList);\r\n\r\n this.dealLenderService\r\n .addUpdatelistreturnonlyids(shortlistDealLenders)\r\n .then((response) => {\r\n if (this.dealLenders != null) {\r\n let deallenders = this.dealLenders.filter(\r\n (lender) => response.indexOf(lender.Id) === -1,\r\n );\r\n\r\n deallenders.forEach((lender) =>\r\n this.dealLenderService.markasdeleted(lender.Id),\r\n );\r\n }\r\n })\r\n .finally(() => {\r\n this.getSelectedProducts();\r\n this.isClicked = false;\r\n this.newSearch = false;\r\n this.isProceedClicked = false;\r\n this.showSaveResults = null;\r\n this.loadingData = false;\r\n });\r\n })\r\n .catch((response) => {\r\n //TODO BRIDGING - capture if an error has occurred and process it\r\n //this.isError = true;\r\n this.isProceedClicked = false;\r\n })\r\n .finally(() => { });\r\n }\r\n }\r\n\r\n /**\r\n * updates a seach with introducee details and saves it and sends emil to client if 'notifyBorrower' is set to true.\r\n * @param notifyBorrower\r\n */\r\n\r\n sendResultsToClient(notifyBorrower) {\r\n if (this.isSaveAsClicked) {\r\n this.saveSaveAsSearch(true);\r\n } else {\r\n this.loadingData = true;\r\n this.dealService\r\n .shareDealWithClient(this.shareDealDto)\r\n .then(() => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.shareDealDto.ClientDto.FirstName +\r\n \" \" +\r\n this.shareDealDto.ClientDto.LastName;\r\n //this.loanCriteria.DealClients[0] = this.shareDealDto.ClientDto;\r\n this.loanCriteria.Name = this.shareDealDto.DealName;\r\n this.newSearch = false;\r\n this.showMsg = true;\r\n this.loadingData = false;\r\n this.isAssigned = true;\r\n this.reloadSearch = true;\r\n })\r\n .finally(() => {\r\n delete this.shareDealDto;\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n\r\n getDealLenders(selectedLenders: CommercialLenderResultSummaryDTO[]) {\r\n var lendersList: DealLenderDTO[] = [];\r\n\r\n if (this.dealClientUniqueRef || this.dealUniqueRef) {\r\n this.searchid = this.loanCriteria.Id;\r\n }\r\n\r\n selectedLenders.forEach(({ ProductID, LenderID, NetLoan }) => {\r\n var dealLender: DealLenderDTO;\r\n\r\n if (this.dealLenders) {\r\n dealLender = this.dealLenders.find(\r\n (dl) =>\r\n dl.DealId === this.searchid &&\r\n dl.ProductId === ProductID &&\r\n dl.LenderId === LenderID,\r\n );\r\n }\r\n\r\n if (!dealLender) {\r\n dealLender = {\r\n DealId: this.searchid,\r\n ProductId: ProductID,\r\n LenderId: LenderID,\r\n Status: CaseLenderStateEnum.Shortlisted,\r\n OriginalNetLoan: NetLoan,\r\n } as DealLenderDTO;\r\n }\r\n\r\n lendersList.push(dealLender);\r\n });\r\n\r\n var unselecteLenderList = [];\r\n\r\n if (this.dealLenders) {\r\n unselecteLenderList = this.dealLenders.filter(dl => !lendersList.some(ll => ll.ProductId === dl.ProductId && ll.LenderId === dl.LenderId) && (dl.Status == CaseLenderStateEnum.Rejected || dl.Status == CaseLenderStateEnum.Withdrawn));\r\n }\r\n\r\n if (unselecteLenderList.length > 0) {\r\n unselecteLenderList.forEach((l) => {\r\n l.IsDeleted = true;\r\n lendersList.push(l);\r\n });\r\n }\r\n\r\n return lendersList;\r\n }\r\n\r\n /** closes share results modal*/\r\n cancelNewSearch() {\r\n this.newSearch = false;\r\n this.shareDealDto.ClientDto = null;\r\n this.existingborrower = null;\r\n this.showClientDetails = false;\r\n this.selecteduserName = null;\r\n this.isSaveAsClicked = false;\r\n this.sharedSearch = false;\r\n if (this.tempSearchName) {\r\n this.loanCriteria.Name = this.tempSearchName;\r\n this.tempSearchName = \"\";\r\n }\r\n }\r\n\r\n openSendResultsToBorrowerModal() {\r\n var client = this.loanCriteria.DealClients[0][\"Client\"]; // TODO Deal FUTURE- always want to assume there's one for now until there's a redesign of sharing\r\n this.shareDealDto.DealId = this.loanCriteria.Id;\r\n this.shareDealDto.DealName = this.loanCriteria.Name;\r\n this.shareDealDto.IsApplicant = true;\r\n this.shareDealDto.IsPrimary = true;\r\n this.shareDealDto.ClientDto = {\r\n FirstName: client.FirstName,\r\n LastName: client.LastName,\r\n Email: client.Email,\r\n PhoneNumber: client.PhoneNumber,\r\n ClientUserId: client.ClientUserId,\r\n } as ClientDTO;\r\n this.existingborrower = null;\r\n this.newSearch = true;\r\n this.sharedSearch = true;\r\n }\r\n\r\n //TODO:Roopa need to move to shared service\r\n viewClientsDashboardForNewSearch(userName: string) {\r\n this.loadingData = true;\r\n this.shareDealDto.IsApplicant = true;\r\n this.shareDealDto.IsPrimary = true;\r\n //Look up client's account details\r\n this.$user.searchByEmail(userName).then((users) => {\r\n this.shareDealDto.ClientDto.FirstName = users[0].FirstName;\r\n this.shareDealDto.ClientDto.Email = users[0].Email;\r\n this.shareDealDto.ClientDto.LastName = users[0].LastName;\r\n this.shareDealDto.ClientDto.PhoneNumber = users[0].PhoneNumber;\r\n this.shareDealDto.ClientDto.ClientUserId = users[0].Id;\r\n this.showClientDetails = true;\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n /**\r\n * Sends email to client attached to the search\r\n */\r\n sendShareSearchEmailToClient() {\r\n this.loadingData = true;\r\n this.shareDealDto.EmailLinkToClient = true;\r\n this.dealService\r\n .shareDealWithClient(this.shareDealDto)\r\n .then(() => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.shareDealDto.ClientDto.FirstName +\r\n \" \" +\r\n this.shareDealDto.ClientDto.LastName;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.newSearch = false;\r\n this.showMsg = true;\r\n this.loadingData = false;\r\n this.sharedSearch = false;\r\n });\r\n }\r\n\r\n applyForLoan() {\r\n this.isProceedClicked = true;\r\n this.register(true, this.productResultList);\r\n }\r\n\r\n returnToCase() {\r\n if (this.isShortlistingMore) {\r\n // copy newly selected products/lenders to caselender\r\n this.dealLenderService\r\n .shortlistMoreLenders(\r\n this.loanCriteria.Id,\r\n this.getDealLenders(this.comparisonList),\r\n this.hasSearchChanged,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n //sending 'Promote' as true if search has changed & 'NewShortlist' as true if isShortlistingMore\r\n this.$location.path(\r\n \"/commercialcasedashboard/\" +\r\n this.loanCriteria.Id +\r\n \"/\" +\r\n null +\r\n \"/\" +\r\n true +\r\n \"/\" +\r\n this.hasSearchChanged,\r\n );\r\n }\r\n });\r\n } else {\r\n this.dealLenderService\r\n .updateShortlistedLenders(this.getDealLenders(this.comparisonList))\r\n .then((response) => {\r\n this.$location.path(\r\n \"/commercialcasedashboard/\" + this.loanCriteria.Id,\r\n );\r\n });\r\n }\r\n }\r\n\r\n toggleShowLenderNamesBrokerOverride() {\r\n // this.loanCriteria.ShowLenderInfoBrokerOverride = !this.loanCriteria.ShowLenderInfoBrokerOverride;\r\n if (this.searchPanelForm.$valid && !this.showPostcodeErrorMessage) {\r\n this.updateCriteriaAndGetResults(false, true);\r\n }\r\n }\r\n\r\n onMortgageProductChange() {\r\n if (\r\n this.loanCriteria.MortgageInterestType == InterestRateTypeEnum.Variable\r\n ) {\r\n this.loanCriteria.FixedRateTerm = null;\r\n } else if (\r\n this.loanCriteria.MortgageInterestType == InterestRateTypeEnum.Fixed\r\n ) {\r\n this.loanCriteria.FixedRateTerm = FixedRateTermEnum.FiveYear;\r\n }\r\n }\r\n\r\n mortgageTermToLoanTerm(): void {\r\n this.loanCriteria.LoanTermReq = this.mortgageTerm * 12;\r\n }\r\n\r\n /**Update the loan label in the comparison results based on the loan label returned in the results\r\n * Primary purpose is to update the loan label when the show lender names button is toggled\r\n * */\r\n updateLoanLabels() {\r\n for (var i = 0; i < this.comparisonList.length; i++) {\r\n let resultIndex = this.summarySearchResults.findIndex(\r\n (item) => item.ProductID == this.comparisonList[i].ProductID,\r\n );\r\n\r\n if (resultIndex > -1) {\r\n this.comparisonList[i].LoanLabel =\r\n this.summarySearchResults[resultIndex].LoanLabel;\r\n }\r\n }\r\n\r\n //This is used for shortlisting pdf\r\n this.prepareDataForShortlistPdf();\r\n }\r\n\r\n onCurrentUseOfBuilding() {\r\n if (\r\n this.loanCriteria.CurrentPropertyType != null &&\r\n this.loanCriteria.CurrentPropertyType == PropertyTypeEnum.HMO\r\n ) {\r\n this.loanCriteria.UnitCount = null;\r\n this.loanCriteria.TimeLeftOnLease = TimeLeftOnLeaseEnum.OneToThreeYears;\r\n } else if (\r\n this.loanCriteria.CurrentPropertyType != null &&\r\n this.loanCriteria.CurrentPropertyType ==\r\n PropertyTypeEnum.MultiUnitFreeholdBlock\r\n ) {\r\n this.loanCriteria.BedroomCount = null;\r\n this.loanCriteria.TimeLeftOnLease = TimeLeftOnLeaseEnum.OneToThreeYears;\r\n } else if (\r\n this.loanCriteria.CurrentPropertyType != null &&\r\n this.loanCriteria.CurrentPropertyType !=\r\n PropertyTypeEnum.MultiUnitFreeholdBlock &&\r\n this.loanCriteria.CurrentPropertyType != PropertyTypeEnum.HMO\r\n ) {\r\n this.loanCriteria.BedroomCount = null;\r\n this.loanCriteria.UnitCount = null;\r\n }\r\n\r\n this.updateSearchViaSlider();\r\n }\r\n\r\n datasetupOnMaxLoanRequiredChange() {\r\n this.loanCriteria = this.dealService.dataSetupOnMaxLoanRequiredChange(\r\n this.loanCriteria,\r\n );\r\n\r\n this.updateSearchViaSlider();\r\n }\r\n\r\n showContactBrokerAndExportButton() {\r\n if (\r\n this.brokerageOrg != null &&\r\n this.loanCriteria != null &&\r\n this.loanCriteria.DealClients != null &&\r\n this.loanCriteria.DealClients.length > 0 &&\r\n this.loanCriteria.DealClients[0]?.Client != null &&\r\n this.loanCriteria.DealClients[0].Client.Email.length > 0\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n //This is used in shortlisting pdf\r\n prepareDataForShortlistPdf() {\r\n this.loanCriteria.ComparisonList = this.comparisonList.filter(\r\n (cl) =>\r\n cl.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n cl.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n }\r\n\r\n isProceedButtonDisabled(): boolean {\r\n if (this.validateAllLendersUnique(this.comparisonList) == false) {\r\n return true;\r\n }\r\n\r\n const validLenders = this.comparisonList?.filter(\r\n (item) =>\r\n item.DealLenderStatus !== CaseLenderStateEnum.Rejected &&\r\n item.DealLenderStatus !== CaseLenderStateEnum.Withdrawn\r\n ) || [];\r\n \r\n if (\r\n !validLenders ||\r\n validLenders.length < 1 ||\r\n validLenders.length > this.noOfShortlistAllowed ||\r\n this.isProceedClicked == true\r\n ) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n validateAllLendersUnique(\r\n comparisonList: CommercialLenderResultSummaryDTO[],\r\n ): boolean {\r\n\r\n if (this.isShortlistingMore) {\r\n const matchingItems = this.HiddenDealLenderList.filter(item1 =>\r\n this.comparisonList.some(item2 => item1.LenderId === item2.LenderID)\r\n );\r\n\r\n if (matchingItems.length > 0) return false;\r\n }\r\n\r\n const numberOfUniqueLenderIds: number = new Set(\r\n this.comparisonList.map((item) => item.LenderID),\r\n ).size;\r\n\r\n return numberOfUniqueLenderIds == this.comparisonList.length;\r\n }\r\n\r\n getRegionByPostcode() {\r\n if (\r\n this.loanCriteria.PostcodeSearchString &&\r\n this.loanCriteria.PostcodeSearchString.replace(\" \", \"\").length >= 2\r\n ) {\r\n if (\r\n this.dealService.isValidPostcodeString(\r\n this.loanCriteria.PostcodeSearchString,\r\n )\r\n ) {\r\n this.showPostcodeErrorMessage = false;\r\n this.isPostcodeChange = true;\r\n this.updateSearchViaSlider();\r\n } else {\r\n this.postcodeErrorMsg =\r\n \"At least one letter and one number must be entered e.g. SW1.\";\r\n this.showPostcodeErrorMessage = true;\r\n }\r\n }\r\n }\r\n\r\n getOrganisationAndBrokerDetails() {\r\n if (!this.isLoggedInUser && !this.isAdmin && !this.isBroker) {\r\n this.loadingData = true;\r\n this.organisationService\r\n .getOrganisationAndBrokerByDealId(this.loanCriteria.Id)\r\n .then((response) => {\r\n if (response && response.Organisation != null) {\r\n this.brokerageOrg = response.Organisation;\r\n\r\n if (response.Organisation.IsBrickflow) {\r\n this.moveContactBrokerBtnInMiddle = true;\r\n } else {\r\n if (response.Broker != null) {\r\n this.brokerDetail = `${response.Broker.FullName} (${response.Broker.Email})`;\r\n }\r\n\r\n if (this.brokerageOrg.IsWhiteLabelled) {\r\n this.orgName = this.brokerageOrg.Name.replace(/ /g, \"_\");\r\n }\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n\r\n sortByField(field) {\r\n this.loanCriteria.SortBy = field;\r\n this.updateCriteriaAndGetResults(false, false);\r\n this.showSortBy = !this.showSortBy;\r\n }\r\n\r\n sortSummaryResults() {\r\n switch (this.loanCriteria.SortBy) {\r\n case SortByEnum.NetLoanSize:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n b.NetLoan - a.NetLoan || a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.LenderCosts:\r\n this.summarySearchResults.sort(\r\n (a, b) => a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.LenderName:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.LenderName.localeCompare(b.LenderName) ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.InterestRate:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.Interest - b.Interest || a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.ArrangementFee:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.ArrangementFee - b.ArrangementFee ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.DepositEquity:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.EquityOrDeposit - b.EquityOrDeposit ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.MonthlyPayment:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.MonthlyPayment - b.MonthlyPayment ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n default:\r\n this.summarySearchResults.sort((a, b) => {\r\n if (a.NetLoan < b.NetLoan) return 1;\r\n if (a.NetLoan > b.NetLoan) return -1;\r\n\r\n if (a.TrueMonthlyCost > b.TrueMonthlyCost) return 1;\r\n if (a.TrueMonthlyCost < b.TrueMonthlyCost) return -1;\r\n\r\n return 0;\r\n });\r\n this.loanCriteria.SortBy = SortByEnum.NetLoanSize;\r\n }\r\n\r\n for (var i = 0; i < this.summarySearchResults.length; i++) {\r\n this.summarySearchResults[i].SelectedRowNumber = i + 1;\r\n }\r\n }\r\n\r\n /** Redirects to the user dashboard */\r\n goToUserDashboard() {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n submitLenderReferral() {\r\n this.loadingData = true;\r\n this.lenderReferralData.DealId = this.loanCriteria.Id;\r\n this.dealClientService\r\n .submitLenderReferral(this.lenderReferralData)\r\n .then((response) => {\r\n if (response) {\r\n this.displayMsg = \"Your referral has been submitted.\";\r\n this.showMsg = true;\r\n this.isLenderReferredSearch = true;\r\n } else {\r\n this.displayMsg = \"Error while making a referral, please try later.\";\r\n this.showMsg = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n this.lenderReferralData = null;\r\n sessionStorage.removeItem(\"lenderReferralData\");\r\n });\r\n }\r\n\r\n reloadPage() {\r\n if (this.reloadSearch) {\r\n window.location.reload();\r\n }\r\n }\r\n\r\n openRegisterModal() {\r\n this.showRegisterModal = true;\r\n }\r\n\r\n onEditSearchNameClick() {\r\n this.toggleEditSearchName = !this.toggleEditSearchName;\r\n }\r\n\r\n /* onClickEligibleConfirm() {\r\n this.loadingData = true;\r\n this.loanCriteria.DealClients[0].Client.PhoneNumber =\r\n this.enterpriseClient.PhoneNumber;\r\n this.clientService\r\n .addUpdatereturnonlyid(this.loanCriteria.DealClients[0].Client)\r\n .then((response) => {\r\n this.showEligibleModal = false;\r\n window.scrollTo(0, 0);\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }*/\r\n\r\n onSortbyClick() {\r\n this.closeFilterOptions();\r\n this.closeExportDropdown();\r\n this.showSortBy = !this.showSortBy;\r\n }\r\n\r\n onFilterClick() {\r\n this.closeSortByDropdown();\r\n this.closeExportDropdown();\r\n this.showFilters = !this.showFilters;\r\n }\r\n\r\n onExportClick() {\r\n this.prepareDataForShortlistPdf();\r\n this.closeSortByDropdown();\r\n this.closeFilterOptions();\r\n this.showExportOptions = !this.showExportOptions;\r\n }\r\n\r\n getSelectedSortByOptionText() {\r\n if (this.loanCriteria) {\r\n switch (this.loanCriteria.SortBy) {\r\n case SortByEnum.TrueMonthlyCost:\r\n return \"True Monthly Cost\";\r\n case SortByEnum.NetLoanSize:\r\n return \"Net Loan Size\";\r\n case SortByEnum.LenderCosts:\r\n return \"Total Loan Costs\";\r\n case SortByEnum.LenderName:\r\n return \"Lender Name (A-Z)\";\r\n case SortByEnum.InterestRate:\r\n return \"Interest Rate\";\r\n case SortByEnum.ArrangementFee:\r\n return \"Arrangement Fee\";\r\n case SortByEnum.DepositEquity:\r\n return \"Equity\";\r\n case SortByEnum.ROCE:\r\n return \"ROCE\";\r\n case SortByEnum.MonthlyPayment:\r\n return \"Monthly Payment\";\r\n default:\r\n return \"\";\r\n }\r\n } else {\r\n return \"\";\r\n }\r\n }\r\n\r\n createAccount() {\r\n this.loadingData = true;\r\n this.enterpriseClient.OrgUniqueRef = this.brokerageOrg.UniqueRef;\r\n this.$user\r\n .registerEnterpriseUserAndSaveShortlisteResults(this.enterpriseClient, this.getDealLenders(this.comparisonList))\r\n .then((response) => {\r\n // clean up session storage\r\n if (window.self == window.top) {\r\n sessionStorage.removeItem(\"clientId\");\r\n sessionStorage.removeItem(\"userRole\");\r\n } else {\r\n this.organisationService.sendDataToParent(\"clientId\", \"\");\r\n this.organisationService.sendDataToParent(\"userRole\", \"\");\r\n }\r\n this.login(\"ENTERPRISE-LEAD-REGISTERED-FROM-RESULTS-PAGE\", EventLogEnum.EnterpriseUserRegistration);\r\n })\r\n .catch((response) => {\r\n this.error = \"Error while registering an account, please try again later.\";\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n login(eventIdentifier: string = \"ENTERPRISE-CONTACT-LOGGEDIN-FROM-RESULTS-PAGE\", eventType: EventLogEnum = EventLogEnum.EnterpriseUserLogin) {\r\n this.loadingData = true;\r\n if (!this.$cookies.get(\"access_token\")) {\r\n this.$auth\r\n .login(\r\n this.enterpriseClient.UserName,\r\n this.enterpriseClient.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n this.error =\"\";\r\n let expiry: Date = response;\r\n this.$user.getcurentuserrecord().then((response) => {\r\n this.eventLogService.logEvent(\r\n eventIdentifier,\r\n eventType,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n \"\",\r\n \"\",\r\n this.loanCriteria.DealClients[0]?.Client.Id?.toString()\r\n );\r\n\r\n (this.$rootScope as any).currentUser = response;\r\n this.$cookies.put(\"user_firstname\", response.FirstName, {\r\n expires: expiry,\r\n });\r\n (this.$rootScope as any).selectedUser = response;\r\n this.$rootScope.$broadcast(\"login\"); //tell everyone you have logged in\r\n if (eventType == EventLogEnum.EnterpriseUserRegistration) sessionStorage.setItem('showConfirmClientPhoneNo', 'true');\r\n this.$location.path(`/commercialresults/${this.loanCriteria.Id}`);\r\n });\r\n }).catch((response) => {\r\n this.isLoginError = true;\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n\r\n onClickLogin() {\r\n this.saveShortlistedLenders();\r\n this.login();\r\n }\r\n\r\n saveShortlistedLenders() {\r\n var shortlistDealLenders = this.getDealLenders(this.comparisonList);\r\n this.dealLenderService\r\n .updateShortlistedLenders(shortlistDealLenders)\r\n .then((response) => { });\r\n }\r\n\r\n returnShortlistedDealLenderStatusText(item: CommercialLenderResultSummaryDTO) {\r\n if (this.checkDeletedLender(item.LenderID.toString(), item.ProductID.toString())) {\r\n return \"Previously Deleted\";\r\n }\r\n\r\n if (item.IsDealLender && (this.loanCriteria.Status != CaseStatusEnum.Search && this.loanCriteria.Status != CaseStatusEnum.NewCase && this.loanCriteria.Status != CaseStatusEnum.ReadyToSubmit)) {\r\n switch (item.DealLenderStatus) {\r\n case CaseLenderStateEnum.Shortlisted:\r\n return \"Shortlisted\";\r\n case CaseLenderStateEnum.Received:\r\n return \"Awaiting DIP\";\r\n case CaseLenderStateEnum.Offered:\r\n return \"DIP Received\";\r\n case CaseLenderStateEnum.Rejected:\r\n return \"Lender Rejected\";\r\n case CaseLenderStateEnum.Withdrawn:\r\n return \"Lender Withdrawn\";\r\n default:\r\n break\r\n }\r\n }\r\n }\r\n\r\n onSaveClick() {\r\n if (this.isAssigned) {\r\n this.isSaveorSaveAsClicked = true;\r\n this.register(false, this.productResultList);\r\n } else {\r\n this.showShareSearchModal();\r\n }\r\n }\r\n\r\n getProductLastVerifiedDates(productIds: number[]) {\r\n this.productService.getLastVerifiedDates(productIds).then((response) => {\r\n productIds.forEach(id => {\r\n if (response[id] != null) {\r\n this.productLastVerifiedDates[id] = this.formatDate(response[id]);\r\n }\r\n })\r\n });\r\n }\r\n\r\n formatDate = (dateString) => {\r\n const date = new Date(dateString);\r\n return date.toLocaleDateString('en-GB');\r\n };\r\n\r\n closeFilterOptions() {\r\n this.showFilters = false;\r\n }\r\n\r\n closeSortByDropdown() {\r\n this.showSortBy = false;\r\n }\r\n\r\n closeExportDropdown() {\r\n this.showExportOptions = false;\r\n }\r\n\r\n goToNewSearch() {\r\n this.sharedDataService.cleanLenderReferralSessionStorage();\r\n // If the current user is a broker and doesn't have a subscription then don't allow them to create a new search\r\n if (this.isBroker && !this.selectedUser.HasActiveSubscription) {\r\n return;\r\n }\r\n\r\n if (!this.loadingData) {\r\n (this.$rootScope as any).loanCriteria = null;\r\n\r\n this.$location.path(\"/allloans\");\r\n }\r\n }\r\n\r\n updateClientContactInfoAndNotifyBroker(){\r\n if(this.loanCriteria !=null && this.loanCriteria.DealClients != null){\r\n this.dealClientService.UpdateClientContactInfoAndNotifyBroker(this.clientUpdatedContact, this.loanCriteria?.Id,this.loanCriteria.DealClients[0].Client.Id).then((response) => {\r\n this.showClientPhoneNumberConfirmationModal = false;\r\n this.sliderShown = true;\r\n }).catch((response) => {\r\n this.error = \"There was an error updating the contact. Please try again later.\"\r\n })\r\n .finally(() => {\r\n sessionStorage.removeItem('showConfirmClientPhoneNo');\r\n });\r\n } else {\r\n sessionStorage.removeItem('showConfirmClientPhoneNo');\r\n this.showClientPhoneNumberConfirmationModal = false;\r\n this.sliderShown = true;\r\n }\r\n }\r\n\r\n getOrgName(){\r\n if(this.orgName){\r\n return this.orgName.replace(/_/g, \" \");\r\n }\r\n return \"\";\r\n }\r\n\r\n /**Sends an email to the email address for the user to reset their password */\r\n sendResetPasswordEmail() {\r\n this.loadingData = true;\r\n this.$auth\r\n .resetPassword(this.enterpriseClient.Email)\r\n .then((response) => {\r\n this.isLoginError = false;\r\n this.isResetPasswordSubmitted = true;\r\n this.registrationLoginError = null;\r\n })\r\n .catch((error) => {\r\n this.registrationLoginError = \"There was an error sending the password reset email. Please try again later.\";\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n getRequiredRolesOptions(){\r\n return this.dealService.getRequiredRolesOptions();\r\n }\r\n\r\n validateAccessAndRedirect(){\r\n //Do not allow the connect user to access the deal\r\n if(this.isLoggedInUser && this.loanCriteria.IsReferredToConnect && this.selectedUser.IsConnectUser){\r\n this.$location.path(`/commercialcasedashboard/${this.loanCriteria.Id}`)\r\n }else{\r\n if(this.isLoggedInUser && (this.loanCriteria.Status != CaseStatusEnum.NewCase && this.loanCriteria.Status != CaseStatusEnum.Search && !this.isShortlistingMore)){\r\n this.dealLenderService\r\n .fetchDealLendersByDealId( this.loanCriteria.Id)\r\n .then((results) => {\r\n if(results && results.filter(dl => !dl.IsDeleted && dl.Status != CaseLenderStateEnum.Withdrawn && dl.Status != CaseLenderStateEnum.Rejected).length >= 5 && results.filter(dl => !dl.IsDeleted && dl.IsBidAccepted)){\r\n if (this.isAdmin || this.isBroker) {\r\n this.$location.path(\"/dealforum/\" + this.loanCriteria.Id)\r\n }\r\n else {\r\n this.$location.path(`/userdashboard`)\r\n }\r\n }else{\r\n this.$location.path(`/commercialshortlistmore/${this.loanCriteria.Id}`)\r\n }\r\n })\r\n }\r\n }\r\n \r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { DealDTO } from \"@js/DTO/Deal/DealDTO.cs.d\";\r\nimport { LenderResultDTO } from \"@js/DTO/DevelopmentFinance/LenderResultDTO.cs.d\";\r\nimport { LenderResultSummaryDTO } from \"@js/DTO/DevelopmentFinance/LenderResultSummaryDTO.cs.d\";\r\nimport { LenderLogoDTO } from \"@js/DTO/LenderLogoDTO.cs.d\";\r\nimport { BridgingLenderResultSummaryDTO } from \"@js/DTO/SearchResults/BridgingLenderResultSummaryDTO.cs.d\";\r\nimport { CommercialLenderResultSummaryDTO } from \"@js/DTO/SearchResults/CommercialLenderResultSummaryDTO.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\n\r\nexport class ComparisonController {\r\n isLoading: boolean;\r\n\r\n selectedCandidates: (\r\n | LenderResultSummaryDTO\r\n | CommercialLenderResultSummaryDTO\r\n | BridgingLenderResultSummaryDTO\r\n )[];\r\n allResults: (\r\n | LenderResultSummaryDTO\r\n | CommercialLenderResultSummaryDTO\r\n | BridgingLenderResultSummaryDTO\r\n )[];\r\n rowSelected: number[] = [];\r\n\r\n //Lender Logos\r\n showLenderLogo: boolean = false;\r\n lenderIds: number[] = [];\r\n urlLenders: LenderLogoDTO[] = [];\r\n\r\n selectedUser: ApplicationUserDTO;\r\n\r\n enquiryOpen: boolean;\r\n enquiryEmail: string;\r\n enquiryBody: string;\r\n\r\n isBroker: boolean = false;\r\n\r\n isIntroducer: boolean = false;\r\n\r\n searchid: number;\r\n caseid: number;\r\n uniqueid: string;\r\n isLenderVisible: boolean;\r\n showAdditionalProductInfoModal: LenderResultDTO;\r\n case: CaseDTO;\r\n isDeal: boolean = false;\r\n\r\n criteria: {} = {};\r\n\r\n productTypeOptions = [];\r\n productLastVerifiedDates = {};\r\n\r\n isLoggedInUser: boolean = false;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"CaseMemberService\",\r\n \"RoleService\",\r\n \"FileAttachmentService\",\r\n \"OrganisationService\",\r\n \"CaseService\",\r\n \"DealService\",\r\n \"$routeParams\",\r\n \"SelectListService\",\r\n \"ProductService\"\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private caseMemberService: CaseMemberService,\r\n private roleService: RoleService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private organisationService: OrganisationService,\r\n private caseService: CaseService,\r\n private dealService: DealService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private selectListService: SelectListService,\r\n private productService: ProductService\r\n ) {\r\n this.isDeal = this.$routeParams.isDeal ? true : false;\r\n\r\n if (this.$routeParams.SearchId) {\r\n this.searchid = this.$routeParams.SearchId;\r\n }\r\n this.showOrHideLenderLogo();\r\n this.productTypeOptions = this.selectListService.GetProductTypeOptions();\r\n\r\n if ($cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n }\r\n\r\n if (sessionStorage.getItem(\"UniqueId\")) {\r\n this.uniqueid = sessionStorage.getItem(\"UniqueId\");\r\n }\r\n\r\n this.allResults = JSON.parse(sessionStorage.getItem(\"TempSavedResults\"));\r\n\r\n //We are sending caseId has 0 for bridging\r\n if (this.$routeParams.CaseId && this.$routeParams.CaseId > 0) {\r\n this.caseid = this.$routeParams.CaseId;\r\n }\r\n\r\n if (\r\n (this.$rootScope as any).selectedUser ||\r\n sessionStorage.getItem(\"SelectedUser\")\r\n ) {\r\n if ((this.$rootScope as any).selectedUser) {\r\n this.selectedUser = (this.$rootScope as any).selectedUser;\r\n sessionStorage.setItem(\r\n \"SelectedUser\",\r\n JSON.stringify(this.selectedUser),\r\n );\r\n } else if (sessionStorage.getItem(\"SelectedUser\")) {\r\n this.selectedUser = JSON.parse(sessionStorage.getItem(\"SelectedUser\"));\r\n }\r\n\r\n this.checkForBrokerOrIntroducer();\r\n }\r\n\r\n if (\r\n sessionStorage.getItem(\"ComparisonList\") &&\r\n sessionStorage.getItem(\"LoanCriteria\")\r\n ) {\r\n this.selectedCandidates = JSON.parse(\r\n sessionStorage.getItem(\"ComparisonList\"),\r\n );\r\n\r\n if (this.selectedCandidates) {\r\n for (var i = 0; i < this.selectedCandidates.length; i++) {\r\n this.getUrls(\r\n this.selectedCandidates[i].Id,\r\n this.selectedCandidates[i].LogoURL,\r\n );\r\n }\r\n const productIds = this.selectedCandidates.map((product) => product.ProductID);\r\n this.getProductLastVerifiedDates(productIds);\r\n }\r\n\r\n this.criteria = JSON.parse(sessionStorage.getItem(\"LoanCriteria\"));\r\n } else {\r\n this.goToResults();\r\n }\r\n }\r\n\r\n getUrls(id: number, url: string) {\r\n if (url == null) return null;\r\n\r\n this.fileAttachmentService.getFileUri(url).then((response) => {\r\n var LenderLogoDTO = {\r\n Id: id,\r\n LogoURL: response,\r\n } as LenderLogoDTO;\r\n\r\n this.urlLenders.push(LenderLogoDTO);\r\n });\r\n }\r\n\r\n checkForBrokerOrIntroducer(): void {\r\n //Check if broker\r\n this.roleService.isBrokerOrABove().then((response) => {\r\n this.isBroker = response;\r\n });\r\n this.roleService.isIntroducer().then((response) => {\r\n this.isIntroducer = response;\r\n });\r\n }\r\n\r\n showOrHideLenderLogo() {\r\n this.organisationService.showLenderNamesAndLogos(this.searchid, this.isDeal).then((result) => {\r\n this.showLenderLogo = result;\r\n });\r\n }\r\n\r\n getLogoURL(id: number) {\r\n var found = this.urlLenders.find((x) => x.Id == id);\r\n\r\n if (found) {\r\n return found.LogoURL;\r\n } else {\r\n return \"\";\r\n }\r\n }\r\n\r\n sendEnquiry(): void {\r\n this.enquiryOpen = false;\r\n }\r\n\r\n goToDealResults(dealCriteria: DealDTO, shortlistingMore: boolean = false) {\r\n var route = shortlistingMore ? \"shortlistmore\" : \"results\";\r\n var enterpriseRoute = !this.isLoggedInUser && !shortlistingMore ? '/e' : '';\r\n\r\n if (this.dealService.isDevelopmentFinanceDealDto(dealCriteria)) {\r\n this.$location.path(enterpriseRoute + \"/devfinance\" + route + \"/\" + this.searchid);\r\n }\r\n\r\n if (this.dealService.isBridgingDealDto(dealCriteria)) {\r\n console.log(enterpriseRoute + \"/bridging\" + route + \"/\" + this.searchid);\r\n this.$location.path(enterpriseRoute + \"/bridging\" + route + \"/\" + this.searchid);\r\n }\r\n\r\n if (this.dealService.isCommercialDealDto(dealCriteria)) {\r\n this.$location.path(enterpriseRoute + \"/commercial\" + route + \"/\" + this.searchid);\r\n }\r\n }\r\n\r\n goToResults(): void {\r\n //Clearing the all lsd data(except 'LoanCriteria') saved for this view.\r\n sessionStorage.removeItem(\"TempSavedResults\");\r\n sessionStorage.removeItem(\"SelectedUser\");\r\n sessionStorage.removeItem(\"UniqueId\");\r\n\r\n if (this.caseid && this.searchid) {\r\n this.caseService.fetch(this.caseid).then((result) => {\r\n if (\r\n result.CaseStatus == CaseStatusEnum.ReadyToReSubmit ||\r\n result.CaseStatus == CaseStatusEnum.SubmittedToLendersForHoT\r\n ) {\r\n this.$location.path(\r\n \"/shortlistmore/\" + this.searchid + \"/\" + this.caseid,\r\n );\r\n } else {\r\n if (this.isDeal) {\r\n this.goToDealResults(this.criteria as DealDTO);\r\n } else {\r\n this.$location.path(\r\n \"/results/\" + this.searchid + \"/\" + this.caseid,\r\n );\r\n }\r\n }\r\n });\r\n } else if (this.searchid || this.isDeal) {\r\n if (this.isDeal) {\r\n sessionStorage.setItem(\r\n \"ComparisonList\",\r\n JSON.stringify(this.selectedCandidates),\r\n );\r\n\r\n if (sessionStorage.getItem(\"DealClientUniqueRef\")) {\r\n this.$location.path(\r\n \"/referredsearchdeal/\" +\r\n sessionStorage.getItem(\"DealClientUniqueRef\") + \"/false\",\r\n );\r\n sessionStorage.removeItem(\"DealClientUniqueRef\");\r\n } else {\r\n const dealCriteria = this.criteria as DealDTO;\r\n if (\r\n dealCriteria.Status == CaseStatusEnum.ReadyToReSubmit ||\r\n dealCriteria.Status == CaseStatusEnum.SubmittedToLendersForHoT\r\n ) {\r\n var shortlistingMore = true;\r\n this.goToDealResults(dealCriteria, shortlistingMore);\r\n } else {\r\n this.goToDealResults(dealCriteria);\r\n }\r\n }\r\n } else {\r\n this.$location.path(\"/results/\" + this.searchid);\r\n }\r\n } else {\r\n if (this.uniqueid) {\r\n this.$location.path(\"/referredSearch/\" + this.uniqueid);\r\n } else {\r\n this.$location.path(\"/results\");\r\n }\r\n }\r\n }\r\n\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n\r\n hideLenderName(label) {\r\n let newLabel = label.replace(/ *\\([^)]*\\) */g, \"\");\r\n return newLabel;\r\n }\r\n\r\n getProductLastVerifiedDates(productIds: number[]) {\r\n this.productService.getLastVerifiedDates(productIds).then((response) => {\r\n productIds.forEach(id => {\r\n if (response[id] != null) {\r\n this.productLastVerifiedDates[id] = this.formatDate(response[id]);\r\n }\r\n })\r\n });\r\n }\r\n\r\n formatDate = (dateString) => {\r\n const date = new Date(dateString);\r\n return date.toLocaleDateString('en-GB');\r\n };\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport {UserService} from \"@js/services/UserService\";\r\n\r\nexport class DashboardController {\r\n $scope: any;\r\n $cookies: any;\r\n $location: ng.ILocationService;\r\n $http: ng.IHttpService;\r\n user: ApplicationUserDTO;\r\n webServer: boolean = false;\r\n isLenderVisible: boolean;\r\n isTestBannerHidden: boolean;\r\n cardColours: string[] = [\r\n \"card-colour-1\",\r\n \"card-colour-2\",\r\n \"card-colour-3\",\r\n \"card-colour-4\",\r\n \"card-colour-5\",\r\n \"card-colour-6\",\r\n ];\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"$rootScope\",\r\n \"RoleService\",\r\n \"CaseMemberService\",\r\n \"AuthService\",\r\n \"UserService\"\r\n ];\r\n\r\n constructor(\r\n scope: ng.IScope,\r\n cookies: any,\r\n location: ng.ILocationService,\r\n http: ng.IHttpService,\r\n private $rootScope: ng.IRootScopeService,\r\n protected roleService: RoleService,\r\n private caseMember: CaseMemberService,\r\n private $auth: AuthService,\r\n private userService: UserService\r\n ) {\r\n this.$scope = scope;\r\n this.$cookies = cookies;\r\n this.$location = location;\r\n this.$http = http;\r\n this.isLenderVisible = this.roleService.getIsLenderVisible();\r\n\r\n // Used for test site to keep banner hidden\r\n if (localStorage.getItem(\"isTestBannerHidden\")) {\r\n if (localStorage.getItem(\"isTestBannerHidden\") == \"true\") {\r\n this.isTestBannerHidden = true;\r\n } else {\r\n this.isTestBannerHidden = false;\r\n }\r\n } else {\r\n this.isTestBannerHidden = false;\r\n }\r\n\r\n if (!this.roleService.IsAdminUser) {\r\n this.go(\"/userdashboard\");\r\n }\r\n\r\n this.caseMember.getWebConfigValue().then((result) => {\r\n this.webServer = result;\r\n });\r\n }\r\n\r\n toggleHidden() {\r\n localStorage.setItem(\r\n \"isTestBannerHidden\",\r\n this.isTestBannerHidden.toString(),\r\n );\r\n if (this.isTestBannerHidden) {\r\n this.roleService.isTestBannerHidden = true;\r\n } else {\r\n this.roleService.isTestBannerHidden = false;\r\n }\r\n }\r\n\r\n logout() {\r\n delete this.$cookies.token;\r\n delete this.$cookies.loggedUser;\r\n delete this.$cookies.loggedUserID;\r\n delete this.$cookies.tokenValidTo;\r\n this.$location.path(\"/login\");\r\n }\r\n\r\n newloan() {\r\n (this.$rootScope as any).loanCriteria = null;\r\n this.$location.path(\"/criteria/0/0/1\");\r\n }\r\n go(path) {\r\n this.$location.path(path);\r\n }\r\n\r\n hideLenderName(isLenderVisible: boolean) {\r\n this.roleService.setIsLenderVisible(isLenderVisible);\r\n }\r\n\r\n sendTestEmail() {\r\n this.userService.sendTestEmailToUsers();\r\n }\r\n\r\n}\r\n","import { DealSummaryDTO } from \"@js/DTO/Deal/DealSummaryDTO.cs.d\";\r\nimport { DealLenderDTO } from \"@js/DTO/Deal/DealLenderDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { CaseLenderService } from \"@js/services/CaseLenderService\";\r\nimport { BridgingDealService } from \"@js/services/Deal/BridgingDealService\";\r\nimport { DealLenderService } from \"@js/services/Deal/DealLenderService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs\";\r\n\r\nexport class DealLenderController {\r\n static $inject = [\r\n \"$routeParams\",\r\n \"LenderService\",\r\n \"$location\",\r\n \"RoleService\",\r\n \"UserService\",\r\n \"OrganisationService\",\r\n \"BridgingDealService\",\r\n \"DealLenderService\",\r\n \"CaseLenderService\",\r\n \"DealService\",\r\n \"$sce\",\r\n ];\r\n\r\n //To save url for Lender Logo Image\r\n lenderLogos: string[] = [];\r\n //To save the Lender Id and request Lender URL\r\n lenderId: number[] = [];\r\n // Controls showing the data loading \"spinner\"\r\n dataLoading: boolean = false;\r\n //Show lender names or Lender Generic Name\r\n showLenders: boolean = false;\r\n\r\n currentDeal: DealSummaryDTO;\r\n caseLenders: DealLenderDTO[];\r\n // The lender the user has clicked apply/heads of terms/feedback for\r\n selectedCaseLender: DealLenderDTO;\r\n // Controls showing the Application Terms and Conditions modal\r\n showApplyTsAndCs: boolean = false;\r\n // Controls showing the Preferred Lenders modal\r\n showPreferredPackagers: boolean = false;\r\n // Controls showing the application confirmation message\r\n showApplicationConfirmation: boolean = false;\r\n // Show the feedback modal\r\n showFeedbackModal: boolean = false;\r\n // Show the Information modal\r\n showInformationMessage: boolean = false;\r\n // show the button to confirm deleting the case lender\r\n showConfirmDeleteButton: boolean = false;\r\n // case to remove\r\n dealLender: DealLenderDTO;\r\n // indicates whether a bid has been accepted on the case\r\n hasBidAccepted: boolean = false;\r\n\r\n // Message to be displayed in the message modal\r\n messageContent: string;\r\n\r\n showProceedModal: boolean = false;\r\n\r\n IsSupplimentInfoFilled: boolean = false;\r\n\r\n currentLenderPreferredBrokers: OrganisationDTO[];\r\n currentLenderPreferredPackagersText: string;\r\n hasLenderPreferredBrokers: boolean = false;\r\n isPreferredBrokerBrickflow: boolean = false;\r\n emailCache = {};\r\n\r\n //Export Modal\r\n selectedLenders: { [lenderId: number]: boolean } = {};\r\n showExport: boolean = false;\r\n showExportButton: boolean = false;\r\n seeLenderNames: boolean = false;\r\n showLenderNames: boolean = true;\r\n\r\n isBridging: boolean = true;\r\n\r\n portalLinks: {} = {};\r\n\r\n isDeallockerIntegrationEnabled: boolean = false;\r\n showDeallockerModal: boolean = false;\r\n isDeallockerTermsAccepted: boolean = false;\r\n isSubmittingToDeallocker: boolean = false;\r\n deallockerTabSelected: number = 1;\r\n hasEnterpriseLicense: boolean = false;\r\n\r\n isConnectMember: boolean = false;\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private lenderService: LenderService,\r\n private $location: ng.ILocationService,\r\n private roleService: RoleService,\r\n private userService: UserService,\r\n private organisationService: OrganisationService,\r\n private bridgingDealService: BridgingDealService,\r\n private dealLenderService: DealLenderService,\r\n private caseLenderService: CaseLenderService,\r\n private dealService: DealService,\r\n private $sce: ng.ISCEService,\r\n ) {\r\n this.lenderDisplayName();\r\n\r\n this.userService.getCurrentUserGotEnterpriseLicense().then((response) => {\r\n this.hasEnterpriseLicense = response;\r\n });\r\n\r\n if (this.$routeParams.DealId) {\r\n this.dataLoading = true;\r\n\r\n this.organisationService.getOrganisationProductAccess().then((response) => {\r\n this.isDeallockerIntegrationEnabled = response.IsDeallockerIntegrationEnabled;\r\n this.isConnectMember = response.IsConnectMember;\r\n });\r\n\r\n this.dealService\r\n .getDealSummary(this.$routeParams.DealId)\r\n .then((response) => {\r\n this.currentDeal = response;\r\n\r\n this.userService.GetDefaultBrokerOrganisation().then((result) => {\r\n this.seeLenderNames = result?.ShowLenderNames;\r\n this.dealLenderService\r\n .fetchByDealId(this.$routeParams.DealId, this.seeLenderNames)\r\n .then((response) => {\r\n this.caseLenders = response.filter((dl) => dl.isPrimaryProduct);\r\n\r\n for (var i = 0; i < this.caseLenders.length; i++) {\r\n this.lenderId[i] = this.caseLenders[i].LenderId;\r\n this.toggleLender(this.caseLenders[i]);\r\n }\r\n /* this.getAllLenderLogos(this.lenderId);*/\r\n\r\n var bidAccepted = this.caseLenders.find(\r\n (x) => x.IsBidAccepted == true,\r\n );\r\n\r\n if (bidAccepted) {\r\n this.hasBidAccepted = true;\r\n }\r\n this.dipRecieved();\r\n })\r\n .then(() => {\r\n this.getLenderPortalLinks();\r\n });\r\n });\r\n\r\n this.IsSupplimentInfoFilled =\r\n this.dealService.getIsSupplimentInfoFilled();\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n ////Get URL for the specific lender\r\n //getLenderLogos(index: number) {\r\n // return this.lenderLogos[index];\r\n //}\r\n\r\n //// Get all URL for all Lender result\r\n //getAllLenderLogos(lenderId: number[]) {\r\n // this.lenderService.getAllLenderLogos(lenderId).then(result => {\r\n // this.lenderLogos = result;\r\n\r\n // })\r\n //}\r\n\r\n /** Redirects to the case dashboard */\r\n goToCaseDashboard() {\r\n this.dealService.goToCaseDashboard(\r\n this.currentDeal.Id,\r\n this.currentDeal.ProductFamily,\r\n );\r\n }\r\n\r\n /** Redirects to the user dashboard */\r\n goToUserDashboard() {\r\n this.userService.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n lenderDisplayName() {\r\n this.organisationService.showLenderNamesAndLogos().then((result) => {\r\n this.showLenders = result;\r\n });\r\n }\r\n\r\n /**Process the Submit Terms and Conditions button being clicked */\r\n submitTsAndCsClicked() {\r\n this.showApplyTsAndCs = false;\r\n this.selectedCaseLender.IsBidAccepted = true;\r\n\r\n this.dealLenderService\r\n .addUpdate(this.selectedCaseLender)\r\n .then((response) => {\r\n this.selectedCaseLender.IsBidAccepted = response.IsBidAccepted;\r\n this.hasBidAccepted = response.IsBidAccepted;\r\n\r\n return this.dealLenderService.applyToLender(this.selectedCaseLender.DealId, this.selectedCaseLender.Id);\r\n })\r\n .then((response) => {\r\n this.selectedCaseLender.Status = response.CaseLenderState;\r\n this.caseLenders = this.caseLenders.map(cl => cl.Id !== this.selectedCaseLender.Id ? cl : this.selectedCaseLender);\r\n })\r\n .finally(() => {\r\n this.dealLenderService.sendProceedDipEmails(this.currentDeal.Id, this.selectedCaseLender.Id);\r\n this.messageContent = 'Thank you for submitting an application with this lender.';\r\n if (this.hasLenderPreferredBrokers && !this.currentDeal.IsConnectUser && !this.isConnectMember) {\r\n this.showPreferredPackagers = true;\r\n }\r\n else {\r\n this.showInformationMessage = true;\r\n }\r\n });\r\n }\r\n\r\n\r\n /**\r\n * Process the Apply button being clicked\r\n */\r\n submit(lender) {\r\n this.selectedCaseLender = lender;\r\n\r\n this.lenderService\r\n .getSelectedLenderPreferredOrgs(this.selectedCaseLender.LenderId)\r\n .then((response) => {\r\n this.currentLenderPreferredBrokers = response;\r\n\r\n return this.userService.getBrokerOrganisationId();\r\n })\r\n .then((response) => {\r\n //checks if broker that applies is not part of the preferred brokers list\r\n\r\n this.hasLenderPreferredBrokers =\r\n this.currentLenderPreferredBrokers != null &&\r\n this.currentLenderPreferredBrokers.length > 0 &&\r\n !this.currentLenderPreferredBrokers.some(\r\n (org) => org.Id === response,\r\n );\r\n\r\n if (this.hasLenderPreferredBrokers) {\r\n this.currentLenderPreferredBrokers.forEach((org) => {\r\n this.getBrokerAdminEmail(org);\r\n });\r\n }\r\n\r\n // Determine if any of the preferred brokers are IsBrickflow = true\r\n this.isPreferredBrokerBrickflow = this.currentLenderPreferredBrokers.some(org => org.IsBrickflow);\r\n\r\n return this.lenderService.getLenderPreferredPackagersText(\r\n this.selectedCaseLender.LenderId,\r\n );\r\n })\r\n .then((response) => {\r\n this.currentLenderPreferredPackagersText = response;\r\n })\r\n .finally(() => {\r\n this.showApplyTsAndCs = true;\r\n });\r\n }\r\n\r\n /**\r\n * Process the Apply button being clicked\r\n * @param currentCaseLender\r\n */\r\n applyClicked(selectedCaseLender: DealLenderDTO) {\r\n this.selectedCaseLender = selectedCaseLender;\r\n\r\n // Show the Terms and Conditions modal\r\n this.showApplyTsAndCs = true;\r\n }\r\n /**\r\n * Process the cancel Application button being clicked\r\n * @param currentCaseLender\r\n */\r\n cancelTerms(selectedCaseLender: DealLenderDTO) {\r\n this.dealLenderService\r\n .getSelectedCaseLender(selectedCaseLender.Id)\r\n .then((response) => {\r\n this.selectedCaseLender = response;\r\n })\r\n .then(() => {\r\n if (this.selectedCaseLender.Status == CaseLenderStateEnum.Applied) {\r\n this.selectedCaseLender.IsBidAccepted = false;\r\n this.dealLenderService\r\n .addUpdate(this.selectedCaseLender)\r\n .then((response) => {\r\n this.selectedCaseLender.IsBidAccepted = response.IsBidAccepted;\r\n this.hasBidAccepted = response.IsBidAccepted;\r\n\r\n return this.dealLenderService.cancelApplication(\r\n this.selectedCaseLender.DealId,\r\n this.selectedCaseLender.Id,\r\n );\r\n })\r\n .then((response) => {\r\n this.selectedCaseLender.Status = response.CaseLenderState;\r\n this.caseLenders = this.caseLenders.map((cl) =>\r\n cl.Id !== this.selectedCaseLender.Id\r\n ? cl\r\n : this.selectedCaseLender,\r\n );\r\n })\r\n .finally(() => {\r\n this.messageContent =\r\n \"Application with this lender has been cancelled.\";\r\n this.showInformationMessage = true;\r\n });\r\n } else {\r\n this.messageContent =\r\n \"There was a problem with cancelling this application. Please refresh and try again.\";\r\n this.showInformationMessage = true;\r\n }\r\n });\r\n\r\n //this.showProceedModal = true;\r\n }\r\n\r\n getStatusText(selectedCaseLender): string {\r\n var statusText = \"\";\r\n\r\n if (this.roleService.IsLender) {\r\n statusText = this.caseLenderService.getStatusTextForLender(\r\n selectedCaseLender.Status,\r\n selectedCaseLender.IsBidAccepted,\r\n );\r\n } else {\r\n switch (selectedCaseLender.Status) {\r\n case CaseLenderStateEnum.Offered: {\r\n if (this.hasBidAccepted) {\r\n statusText = selectedCaseLender.IsBidAccepted\r\n ? \"DIP received and accepted\"\r\n : \"DIP received but applying to another lender\";\r\n } else {\r\n statusText = \"DIP received\";\r\n }\r\n break;\r\n }\r\n case CaseLenderStateEnum.Received: {\r\n statusText = \"Awaiting DIP\";\r\n if (this.hasBidAccepted) {\r\n statusText = \"Awaiting DIP but applying to another lender\";\r\n } else {\r\n statusText = \"Awaiting DIP\";\r\n }\r\n break;\r\n }\r\n case CaseLenderStateEnum.Cancelled: {\r\n if (this.hasBidAccepted) {\r\n statusText = \"Application cancelled but applying to another lender\";\r\n } else {\r\n statusText = \"Application cancelled\";\r\n }\r\n break;\r\n }\r\n case CaseLenderStateEnum.SentToPackager: {\r\n if (this.currentDeal.IsConnectUser) {\r\n statusText = \"Case to Review\";\r\n } else {\r\n statusText = \"Sent to Packager\";\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return statusText;\r\n }\r\n\r\n editApplicationDetails() {\r\n this.$location.path(\"/dealapplicationdetails/\" + this.currentDeal.Id);\r\n }\r\n\r\n deleteButton(dealLender: DealLenderDTO) {\r\n this.showConfirmDeleteButton = true;\r\n this.showInformationMessage = true;\r\n this.messageContent =\r\n \"Are you sure you want to remove \" + dealLender.LenderName + \"?\";\r\n this.dealLender = dealLender;\r\n }\r\n\r\n delete() {\r\n this.dealLenderService\r\n .markasdeleted(this.dealLender.Id)\r\n .then((result) => {\r\n this.caseLenders = this.caseLenders.filter(\r\n (x) => x.Id != this.dealLender.Id,\r\n );\r\n })\r\n .finally(() => {\r\n this.showInformationMessage = false;\r\n delete this.dealLender;\r\n this.showConfirmDeleteButton = false;\r\n });\r\n }\r\n\r\n /**\r\n * Determines whether to show the Shortlist More Lenders button.\r\n * Should be shown if there are less than 3 \"active\" shortlisted lenders i.e. haven't rejected/withdrawn\r\n * and no DIP is accepted\r\n * */\r\n showShortlistMoreLendersButton(): boolean {\r\n var showButton: boolean = false;\r\n if (this.caseLenders) {\r\n var activeShortlistCount = this.caseLenders.filter(\r\n (lender) =>\r\n lender.Status != CaseLenderStateEnum.Withdrawn &&\r\n lender.Status != CaseLenderStateEnum.Rejected,\r\n ).length;\r\n\r\n showButton = activeShortlistCount < 5 ? true : false;\r\n }\r\n\r\n //Hide button if DIP accepted\r\n if (this.hasBidAccepted) {\r\n showButton = false;\r\n }\r\n \r\n if(this.currentDeal != null && this.currentDeal.IsReferredToConnect && !this.currentDeal.IsConnectUser && (this.currentDeal.Status == CaseStatusEnum.SentToPackager || this.currentDeal.Status == CaseStatusEnum.Applied)){\r\n showButton = false;\r\n }\r\n\r\n if(this.currentDeal != null && this.currentDeal.IsReferredToConnect && this.currentDeal.IsConnectUser){\r\n showButton = false;\r\n }\r\n\r\n return showButton;\r\n }\r\n\r\n shortlistMoreLenders() {\r\n if (this.currentDeal.ProductFamily == ProductFamilyEnum.Commercial) {\r\n this.$location.path(\"/commercialshortlistmore/\" + this.currentDeal.Id);\r\n } else if (this.currentDeal.ProductFamily == ProductFamilyEnum.Bridging) {\r\n this.$location.path(\"/bridgingshortlistmore/\" + this.currentDeal.Id);\r\n } else if (\r\n this.currentDeal.ProductFamily == ProductFamilyEnum.Development\r\n ) {\r\n this.$location.path(\"/devfinanceshortlistmore/\" + this.currentDeal.Id);\r\n }\r\n }\r\n\r\n toggleLender(lender: DealLenderDTO) {\r\n this.selectedLenders[lender.Id] = !this.selectedLenders[lender.Id];\r\n }\r\n\r\n stateFilter(lender: DealLenderDTO) {\r\n return !lender.IsDeleted && (lender.Status === 2 || lender.Status === 10);\r\n }\r\n\r\n showAndHideExport() {\r\n this.showExport = !this.showExport;\r\n }\r\n\r\n getSelectedCaseLenders() {\r\n const selectedCaseLenders = this.caseLenders.filter(\r\n (lender) => this.selectedLenders[lender.Id],\r\n );\r\n return selectedCaseLenders;\r\n }\r\n\r\n areLendersSelected() {\r\n for (var lenderId in this.selectedLenders) {\r\n if (this.selectedLenders[lenderId]) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n dipRecieved() {\r\n this.showExportButton = this.caseLenders.some(\r\n (lender) => lender.Status === CaseLenderStateEnum.Offered || lender.Status === CaseLenderStateEnum.Applied || lender.Status === CaseLenderStateEnum.SentToPackager,\r\n );\r\n }\r\n\r\n /** Process the Heads of Terms button being clicked */\r\n headsOfTermsClicked(selectedCaseLender: DealLenderDTO, index) {\r\n this.selectedCaseLender = selectedCaseLender;\r\n if (this.currentDeal.ProductFamily == ProductFamilyEnum.Commercial) {\r\n this.$location.path(\r\n \"/commercialheadsofterm/\" +\r\n this.currentDeal.Id +\r\n \"/\" +\r\n this.selectedCaseLender.Id,\r\n );\r\n } else if (this.currentDeal.ProductType == ProductTypeEnum.Development) {\r\n this.$location.path(\r\n \"/devfinanceheadsofterm/\" +\r\n this.currentDeal.Id +\r\n \"/\" +\r\n this.selectedCaseLender.Id,\r\n );\r\n } else {\r\n this.$location.path(\r\n \"/bridgingheadsofterm/\" +\r\n this.currentDeal.Id +\r\n \"/\" +\r\n this.selectedCaseLender.Id,\r\n );\r\n }\r\n }\r\n\r\n trustedHtml(plainText) {\r\n return this.$sce.trustAsHtml(plainText);\r\n }\r\n\r\n getBrokerAdminEmail(org: OrganisationDTO) {\r\n if (this.emailCache && this.emailCache[org.Id]) {\r\n return;\r\n }\r\n\r\n if (!org.PreferredPackagerEmail) {\r\n this.userService.getOrganisationAdminEmail(org.Id).then((response) => {\r\n this.emailCache[org.Id] = response;\r\n });\r\n } else {\r\n this.emailCache[org.Id] = org.PreferredPackagerEmail;\r\n }\r\n }\r\n\r\n getLenderPortalLinks() {\r\n const lenderIds = this.caseLenders\r\n .filter((dl) => dl.HasAppliedInLenderPortal)\r\n .map((dl) => dl.LenderId);\r\n\r\n this.lenderService\r\n .getLenderPortalLinks(lenderIds)\r\n .then((links) => {\r\n this.portalLinks = links;\r\n })\r\n .catch((error) => {\r\n this.portalLinks = null;\r\n });\r\n }\r\n\r\n openPortalLink(portalLink: string) {\r\n if (!/^https?:\\/\\//i.test(portalLink)) {\r\n portalLink = \"http://\" + portalLink;\r\n }\r\n window.open(portalLink, \"_blank\");\r\n }\r\n\r\n submitToDealocker() {\r\n this.isSubmittingToDeallocker = true;\r\n //TODO call deallocker API end point\r\n this.dealLenderService.submitToDeallocker(this.dealLender.Id).then(response => {\r\n return response;\r\n }).then(response => {\r\n if (response) {\r\n return this.dealLenderService.getSelectedCaseLender(this.dealLender.Id).then(caseLender => {\r\n if (caseLender && caseLender.Id) {\r\n this.caseLenders = [...this.caseLenders.map(lender =>\r\n lender.Id === caseLender.Id ? caseLender : lender\r\n )];\r\n }\r\n this.showInformationMessage = true;\r\n this.messageContent = 'Your case information has been sent to Deallocker. They\\'ll confirm receipt via email.';\r\n return caseLender;\r\n });\r\n }\r\n }).catch(() => {\r\n // TODO do something if it fails?\r\n }).finally(() => {\r\n this.showDeallockerModal = false;\r\n this.isSubmittingToDeallocker = false;\r\n this.isDeallockerTermsAccepted = false;\r\n this.dealLender = null;\r\n });\r\n\r\n }\r\n\r\n\r\n sendDealToPackagerForReview(selectedCaseLender: DealLenderDTO) {\r\n this.selectedCaseLender = selectedCaseLender;\r\n\r\n this.dealLenderService\r\n .sendDealToPackagerForReview(this.selectedCaseLender.DealId,this.selectedCaseLender.Id)\r\n .then((response) => {\r\n this.selectedCaseLender.Status = response.CaseLenderState;\r\n this.currentDeal.Status = response.DealStatus;\r\n this.currentDeal.IsReferredToConnect = response.IsReferredToConnect;\r\n this.caseLenders = this.caseLenders.map(cl => cl.Id !== this.selectedCaseLender.Id ? cl : this.selectedCaseLender);\r\n }).catch(() => {\r\n this.messageContent = 'Error while sending case information to Connect Packager, please try later.';\r\n this.showInformationMessage = true;\r\n })\r\n .finally(() => {\r\n this.messageContent = 'Your case information has been sent to Connect Packager';\r\n this.showInformationMessage = true;\r\n });\r\n }\r\n\r\n showApplyButton(lender){\r\n if((!(lender.IsConnectReferralOnly && this.isConnectMember) && !(this.isConnectMember && this.currentDeal.IsReferredToConnect && (this.currentDeal.Status == CaseStatusEnum.Applied || this.currentDeal.Status == CaseStatusEnum.SentToPackager)) ) && (this.hasBidAccepted == false || this.hasBidAccepted == null ) && (lender.Status == CaseLenderStateEnum.Offered || lender.Status == CaseLenderStateEnum.Cancelled || lender.Status == CaseLenderStateEnum.SentToPackager)){\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n showCancelApplicationButton(lender){\r\n if((!(lender.IsConnectReferralOnly && this.isConnectMember) && !(this.isConnectMember && this.currentDeal.IsReferredToConnect && (this.currentDeal.Status == CaseStatusEnum.Applied || this.currentDeal.Status == CaseStatusEnum.SentToPackager))) && lender.IsBidAccepted == true && lender.Status == CaseLenderStateEnum.Applied){\r\n return true;\r\n }\r\n\r\n return false;\r\n\r\n }\r\n\r\n showSendToPackagerButton(lender){\r\n if((lender.IsConnectReferralOnly && this.isConnectMember) && (this.hasBidAccepted == false || this.hasBidAccepted == null ) && (lender.Status == CaseLenderStateEnum.Offered || lender.Status == CaseLenderStateEnum.Cancelled)){\r\n return true;\r\n }\r\n\r\n return false;\r\n\r\n }\r\n}\r\n","export const enum SecurityQuestionEnum {\r\n None = 0,\r\n PhoneNumber = 1,\r\n PostCode = 2,\r\n DateOfBirth = 4,\r\n}\r\n","import { SecurityQuestionEnum } from \"@js/models/enum/SecurityQuestionEnum.cs.d\";\r\nimport { DealClientService } from \"@js/services/DealClientService\";\r\n\r\nexport class DealSecurityCheckController {\r\n dateOfBirth: Date;\r\n email: string;\r\n phone: string;\r\n postcode: string;\r\n answers: number;\r\n error: boolean = false;\r\n\r\n securityValidation: ng.IFormController;\r\n maxDateOfBirth: Date = new Date();\r\n minDateOfBirth: Date = new Date(\"Jan 01 1900\");\r\n uniqueId: string;\r\n showDob: boolean = false;\r\n showPhone: boolean = false;\r\n showPostCode: boolean = false;\r\n\r\n orgUniqueRef: string;\r\n brokerUserId: string;\r\n\r\n static $inject = [\"$routeParams\", \"$location\", \"DealClientService\"];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private dealClientService: DealClientService,\r\n ) {\r\n this.uniqueId = this.$routeParams.uniqueId;\r\n if (this.$routeParams.orgUniqueRef && this.$routeParams.brokerUserId) {\r\n this.orgUniqueRef = this.$routeParams.orgUniqueRef;\r\n this.brokerUserId = this.$routeParams.brokerUserId;\r\n }\r\n\r\n if (this.uniqueId) {\r\n this.dealClientService\r\n .getShareholderEmailAndSecurityQuestions(this.uniqueId)\r\n .then((response) => {\r\n this.email = response?.Email;\r\n var securityQuestions = response?.SecurityQuestions;\r\n\r\n this.showDob =\r\n SecurityQuestionEnum.DateOfBirth ===\r\n (securityQuestions & SecurityQuestionEnum.DateOfBirth);\r\n this.showPostCode =\r\n SecurityQuestionEnum.PostCode ===\r\n (securityQuestions & SecurityQuestionEnum.PostCode);\r\n this.showPhone =\r\n SecurityQuestionEnum.PhoneNumber ===\r\n (securityQuestions & SecurityQuestionEnum.PhoneNumber);\r\n });\r\n }\r\n }\r\n\r\n isValidAnswer() {\r\n this.answers = 0;\r\n\r\n if (this.dateOfBirth) {\r\n this.answers++;\r\n }\r\n\r\n if (this.phone) {\r\n this.answers++;\r\n }\r\n\r\n if (this.postcode) {\r\n this.answers++;\r\n }\r\n\r\n if (\r\n this.answers >= 2 &&\r\n this.securityValidation.$valid &&\r\n !this.securityValidation.$pristine\r\n ) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n }\r\n\r\n send() {\r\n if (this.uniqueId) {\r\n this.dealClientService\r\n .securityCheck(\r\n this.uniqueId,\r\n this.phone ? this.phone : null,\r\n this.postcode ? this.postcode : null,\r\n this.dateOfBirth ? this.dateOfBirth : null,\r\n this.orgUniqueRef,\r\n this.brokerUserId,\r\n )\r\n .then((i) => {\r\n var targeturl = this.$location.search().targeturl;\r\n\r\n if (targeturl) {\r\n this.$location.search({});\r\n this.$location.path(targeturl);\r\n } else {\r\n this.$location.path(i);\r\n }\r\n })\r\n .catch(() => {\r\n this.error = true;\r\n });\r\n }\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { DeveloperExitFinanceInputSetDTO } from \"@js/DTO/DevelopmentExitFinance/DeveloperExitFinanceInputSetDTO.cs.d\";\r\nimport { DeveloperExitFinanceResultDTO } from \"@js/DTO/DevelopmentExitFinance/DeveloperExitFinanceResultDTO.cs.d\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\n\r\nexport class DeveloperExitFinanceComparisonController {\r\n isLoading: boolean;\r\n\r\n exitLoanCriteria: DeveloperExitFinanceInputSetDTO;\r\n\r\n selectedCandidates: DeveloperExitFinanceResultDTO[];\r\n\r\n selectedUser: ApplicationUserDTO;\r\n\r\n enquiryOpen: boolean;\r\n enquiryEmail: string;\r\n enquiryBody: string;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"DevelopmentInputService\",\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private $DevelopmentInputService: DevelopmentInputService,\r\n ) {\r\n this.selectedUser = (this.$rootScope as any).selectedUser;\r\n\r\n this.selectedCandidates = (this.$rootScope as any).comparisonList;\r\n this.exitLoanCriteria = (this.$rootScope as any).exitLoanCriteria;\r\n\r\n if (!this.selectedCandidates || !this.exitLoanCriteria) {\r\n this.$location.path(\"/\");\r\n }\r\n }\r\n\r\n sendEnquiry(): void {\r\n this.enquiryOpen = false;\r\n }\r\n\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n}\r\n","import { DeveloperExitFinanceDevelopmentInputDTO } from \"@js/DTO/DevelopmentExitFinance/DeveloperExitFinanceDevelopmentInputDTO.cs.d\";\r\nimport { DeveloperExitFinanceDevelopmentInputService } from \"@js/services/DevExitFinance/DeveloperExitFinanceDevelopmentInputService\";\r\n\r\nexport class DeveloperExitFinanceDevelopmentInputController {\r\n selectedSection: string;\r\n\r\n objects: DeveloperExitFinanceDevelopmentInputDTO[];\r\n selectedObject: DeveloperExitFinanceDevelopmentInputDTO;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n //addingSubobject: boolean;\r\n\r\n //subobjects: SubobjectDTO[];\r\n //selectedSubobject: SubobjectDTO;\r\n\r\n //fetchingSubobjects: boolean;\r\n //fetchingSubobject: boolean;\r\n\r\n developerexitfinancedevelopmentinputForm: ng.IFormController;\r\n //subdeveloperexitfinancedevelopmentinputForm: ng.IFormController;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"DeveloperExitFinanceDevelopmentInputService\",\r\n\r\n //'SubobjectService',\r\n ];\r\n //private $subobjectservice: App.Services.SubobjectService\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $developerexitfinancedevelopmentinputservice: DeveloperExitFinanceDevelopmentInputService,\r\n ) {\r\n this.updateObjects();\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n\r\n // Fetch all objects.\r\n this.$developerexitfinancedevelopmentinputservice\r\n .fetchAll()\r\n .then((response) => {\r\n this.objects = response;\r\n this.preSelectedItem();\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n });\r\n }\r\n\r\n private preSelectedItem() {\r\n if (this.$routeParams.Id) {\r\n let selectedObject = this.objects.find((value, index) => {\r\n return value.Id === parseInt(this.$routeParams.objectId);\r\n });\r\n\r\n this.selectObject(selectedObject);\r\n }\r\n }\r\n\r\n selectObject(object: DeveloperExitFinanceDevelopmentInputDTO) {\r\n this.selectedObject = object;\r\n\r\n //this.fetchingSubobjects = true;\r\n //this.$subobjectservice.fetchSubobjectsForObject(object.Id).then((response) => {\r\n // this.subobjects = response;\r\n // this.fetchingSubobjects = false;\r\n //}).catch((response) => {\r\n // this.fetchingSubobjects = false;\r\n //});\r\n\r\n this.selectedSection = \"details\";\r\n }\r\n\r\n createObject() {\r\n this.selectedSection = \"details\";\r\n this.selectedObject = {} as DeveloperExitFinanceDevelopmentInputDTO;\r\n }\r\n\r\n save() {\r\n this.$developerexitfinancedevelopmentinputservice\r\n .addUpdatereturnonlyid(this.selectedObject)\r\n .then((response) => {\r\n this.selectedObject.Id = response;\r\n if (!this.objects) {\r\n this.objects = [];\r\n }\r\n\r\n let matches: DeveloperExitFinanceDevelopmentInputDTO[] =\r\n this.objects.filter((value, index) => {\r\n return value.Id == response;\r\n });\r\n\r\n if (!matches || matches.length === 0) {\r\n this.objects.push(this.selectedObject);\r\n }\r\n\r\n this.developerexitfinancedevelopmentinputForm.$setPristine();\r\n this.updateObjects();\r\n });\r\n }\r\n\r\n delete() {\r\n this.$developerexitfinancedevelopmentinputservice\r\n .delete(this.selectedObject.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.developerexitfinancedevelopmentinputForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n });\r\n }\r\n\r\n //addSubobject() {\r\n // this.selectedSubobject = {\r\n // AssociatedObjectId: this.selectedObject.Id,\r\n // AssociatedObjectName: this.selectedObject.Name\r\n // } as SubobjectDTO;\r\n //}\r\n\r\n //removeSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.deleteSubobject(subobject.Id).then((response) => {\r\n // this.subobjects.splice(this.subobjects.indexOf(this.selectedSubobject), 1);\r\n // delete this.selectedSubobject;\r\n // });\r\n //}\r\n\r\n //cancelUpdateSubobject() {\r\n // delete this.selectedSubobject;\r\n //}\r\n\r\n //updateSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.addUpdateSubobject(subobject).then((response) => {\r\n // if (this.subobjects.indexOf(subobject) === -1) {\r\n // this.subobjects.push(subobject);\r\n // }\r\n // delete this.selectedSubobject;\r\n // }).catch((response) => {\r\n // delete this.selectedSubobject;\r\n // });\r\n\r\n //}\r\n}\r\n","import { DeveloperExitFinanceDevelopmentInputDTO } from \"@js/DTO/DevelopmentExitFinance/DeveloperExitFinanceDevelopmentInputDTO.cs.d\";\r\nimport { DeveloperExitFinanceDevScheduleInputDTO } from \"@js/DTO/DevelopmentExitFinance/DeveloperExitFinanceDevScheduleInputDTO.cs.d\";\r\nimport { DeveloperExitFinanceInputSetDTO } from \"@js/DTO/DevelopmentExitFinance/DeveloperExitFinanceInputSetDTO.cs.d\";\r\nimport { DeveloperExitFinanceLoanInputDTO } from \"@js/DTO/DevelopmentExitFinance/DeveloperExitFinanceLoanInputDTO.cs.d\";\r\nimport { DeveloperExitFinanceDevelopmentInputService } from \"@js/services/DevExitFinance/DeveloperExitFinanceDevelopmentInputService\";\r\nimport { DeveloperExitFinanceDevScheduleInputService } from \"@js/services/DevExitFinance/DeveloperExitFinanceDevScheduleInputService\";\r\nimport { DeveloperExitFinanceLoanInputService } from \"@js/services/DevExitFinance/DeveloperExitFinanceLoanInputService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\n\r\nexport class DeveloperExitFinanceDevScheduleInputController {\r\n selectedSection: string;\r\n\r\n objects: DeveloperExitFinanceDevScheduleInputDTO[];\r\n selectedObject: DeveloperExitFinanceDevScheduleInputDTO;\r\n\r\n devInputs: DeveloperExitFinanceDevelopmentInputDTO;\r\n loanInputs: DeveloperExitFinanceLoanInputDTO;\r\n exitLoanCriteria: DeveloperExitFinanceInputSetDTO;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n totalUnitRentalPrice: number;\r\n totalUnitPrice: number;\r\n\r\n developerexitfinancedevscheduleinputForm: ng.IFormController;\r\n\r\n locationOptions = [];\r\n\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$location\",\r\n \"$routeParams\",\r\n \"DeveloperExitFinanceDevScheduleInputService\",\r\n \"DeveloperExitFinanceDevelopmentInputService\",\r\n \"DeveloperExitFinanceLoanInputService\",\r\n \"SelectListService\",\r\n ];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $developerexitfinancedevscheduleinputservice: DeveloperExitFinanceDevScheduleInputService,\r\n private $developerexitfinancedevelopmentinputservice: DeveloperExitFinanceDevelopmentInputService,\r\n private $developerexitfinanceloaninputservice: DeveloperExitFinanceLoanInputService,\r\n private selectListService: SelectListService,\r\n ) {\r\n this.updateObjects();\r\n\r\n this.locationOptions = this.selectListService.GetLocations();\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n if ((this.$rootScope as any).exitLoanCriteria) {\r\n this.exitLoanCriteria = (this.$rootScope as any).exitLoanCriteria;\r\n this.objects =\r\n this.exitLoanCriteria.DevelopmentInput.DevelopmentSchedules;\r\n } else {\r\n this.exitLoanCriteria = {} as DeveloperExitFinanceInputSetDTO;\r\n this.objects = [];\r\n this.addUnit();\r\n }\r\n //this.$developerexitfinancedevscheduleinputservice.fetchAll().then((response) => {\r\n // this.objects = response;\r\n // this.preSelectedItem();\r\n //}).finally(() => {\r\n // this.fetchingObjects = false;\r\n //});\r\n }\r\n\r\n private preSelectedItem() {\r\n if (this.$routeParams.Id) {\r\n let selectedObject = this.objects.find((value, index) => {\r\n return value.Id === parseInt(this.$routeParams.objectId);\r\n });\r\n\r\n this.selectObject(selectedObject);\r\n }\r\n }\r\n\r\n calcTotalUnitPrice() {\r\n var res: number = 0;\r\n this.objects.forEach((item) => {\r\n if (item.SalesPrice) {\r\n res += Number(item.SalesPrice);\r\n }\r\n });\r\n this.totalUnitPrice = res;\r\n }\r\n calcTotalUnitRentalPrice() {\r\n var res: number = 0;\r\n this.objects.forEach((item) => {\r\n if (item.MonthlyRent) {\r\n res += Number(item.MonthlyRent);\r\n }\r\n });\r\n this.totalUnitRentalPrice = res;\r\n }\r\n\r\n selectObject(object: DeveloperExitFinanceDevScheduleInputDTO) {\r\n this.selectedObject = object;\r\n\r\n this.selectedSection = \"details\";\r\n }\r\n\r\n createObject() {\r\n this.selectedSection = \"details\";\r\n this.selectedObject = {} as DeveloperExitFinanceDevScheduleInputDTO;\r\n }\r\n\r\n addUnit() {\r\n this.selectedObject = {} as DeveloperExitFinanceDevScheduleInputDTO;\r\n this.objects.push(this.selectedObject);\r\n }\r\n\r\n save() {\r\n this.$developerexitfinancedevscheduleinputservice\r\n .addUpdatelist(this.objects)\r\n .then((response) => {\r\n //this.selectedObject.Id = response;\r\n if (!this.objects) {\r\n this.objects = [];\r\n }\r\n\r\n this.developerexitfinancedevscheduleinputForm.$setPristine();\r\n this.updateObjects();\r\n });\r\n }\r\n\r\n deleteUnit(item: DeveloperExitFinanceDevScheduleInputDTO) {\r\n //this.$developerexitfinancedevscheduleinputservice.delete(item.Id).then((response) => {\r\n // if (response) {\r\n this.objects.splice(this.objects.indexOf(item), 1);\r\n this.developerexitfinancedevscheduleinputForm.$setPristine();\r\n // }\r\n //});\r\n }\r\n\r\n delete() {\r\n this.$developerexitfinancedevscheduleinputservice\r\n .delete(this.selectedObject.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.developerexitfinancedevscheduleinputForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n });\r\n }\r\n\r\n fetchResults() {\r\n this.exitLoanCriteria.DevelopmentInput.DevelopmentSchedules = this.objects;\r\n this.exitLoanCriteria.DevelopmentInput.HowManyUnits =\r\n this.exitLoanCriteria.DevelopmentInput.DevelopmentSchedules.length;\r\n (this.$rootScope as any).exitLoanCriteria = this.exitLoanCriteria;\r\n this.$location.path(\"/exitloanresults\");\r\n }\r\n}\r\n","import { DeveloperExitFinanceLoanInputDTO } from \"@js/DTO/DevelopmentExitFinance/DeveloperExitFinanceLoanInputDTO.cs.d\";\r\nimport { DeveloperExitFinanceLoanInputService } from \"@js/services/DevExitFinance/DeveloperExitFinanceLoanInputService\";\r\n\r\nexport class DeveloperExitFinanceLoanInputController {\r\n selectedSection: string;\r\n\r\n objects: DeveloperExitFinanceLoanInputDTO[];\r\n selectedObject: DeveloperExitFinanceLoanInputDTO;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n //addingSubobject: boolean;\r\n\r\n //subobjects: SubobjectDTO[];\r\n //selectedSubobject: SubobjectDTO;\r\n\r\n //fetchingSubobjects: boolean;\r\n //fetchingSubobject: boolean;\r\n\r\n developerexitfinanceloaninputForm: ng.IFormController;\r\n //subdeveloperexitfinanceloaninputForm: ng.IFormController;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"DeveloperExitFinanceLoanInputService\",\r\n\r\n //'SubobjectService',\r\n ];\r\n //private $subobjectservice: App.Services.SubobjectService\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $developerexitfinanceloaninputservice: DeveloperExitFinanceLoanInputService,\r\n ) {\r\n this.updateObjects();\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n\r\n // Fetch all objects.\r\n this.$developerexitfinanceloaninputservice\r\n .fetchAll()\r\n .then((response) => {\r\n this.objects = response;\r\n this.preSelectedItem();\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n });\r\n }\r\n\r\n private preSelectedItem() {\r\n if (this.$routeParams.Id) {\r\n let selectedObject = this.objects.find((value, index) => {\r\n return value.Id === parseInt(this.$routeParams.objectId);\r\n });\r\n\r\n this.selectObject(selectedObject);\r\n }\r\n }\r\n\r\n selectObject(object: DeveloperExitFinanceLoanInputDTO) {\r\n this.selectedObject = object;\r\n\r\n //this.fetchingSubobjects = true;\r\n //this.$subobjectservice.fetchSubobjectsForObject(object.Id).then((response) => {\r\n // this.subobjects = response;\r\n // this.fetchingSubobjects = false;\r\n //}).catch((response) => {\r\n // this.fetchingSubobjects = false;\r\n //});\r\n\r\n this.selectedSection = \"details\";\r\n }\r\n\r\n createObject() {\r\n this.selectedSection = \"details\";\r\n this.selectedObject = {} as DeveloperExitFinanceLoanInputDTO;\r\n }\r\n\r\n save() {\r\n this.$developerexitfinanceloaninputservice\r\n .addUpdatereturnonlyid(this.selectedObject)\r\n .then((response) => {\r\n this.selectedObject.Id = response;\r\n if (!this.objects) {\r\n this.objects = [];\r\n }\r\n\r\n let matches: DeveloperExitFinanceLoanInputDTO[] = this.objects.filter(\r\n (value, index) => {\r\n return value.Id == response;\r\n },\r\n );\r\n\r\n if (!matches || matches.length === 0) {\r\n this.objects.push(this.selectedObject);\r\n }\r\n\r\n this.developerexitfinanceloaninputForm.$setPristine();\r\n this.updateObjects();\r\n });\r\n }\r\n\r\n delete() {\r\n this.$developerexitfinanceloaninputservice\r\n .delete(this.selectedObject.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.developerexitfinanceloaninputForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n });\r\n }\r\n\r\n //addSubobject() {\r\n // this.selectedSubobject = {\r\n // AssociatedObjectId: this.selectedObject.Id,\r\n // AssociatedObjectName: this.selectedObject.Name\r\n // } as SubobjectDTO;\r\n //}\r\n\r\n //removeSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.deleteSubobject(subobject.Id).then((response) => {\r\n // this.subobjects.splice(this.subobjects.indexOf(this.selectedSubobject), 1);\r\n // delete this.selectedSubobject;\r\n // });\r\n //}\r\n\r\n //cancelUpdateSubobject() {\r\n // delete this.selectedSubobject;\r\n //}\r\n\r\n //updateSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.addUpdateSubobject(subobject).then((response) => {\r\n // if (this.subobjects.indexOf(subobject) === -1) {\r\n // this.subobjects.push(subobject);\r\n // }\r\n // delete this.selectedSubobject;\r\n // }).catch((response) => {\r\n // delete this.selectedSubobject;\r\n // });\r\n\r\n //}\r\n}\r\n","import { DeveloperExitFinanceInputSetDTO } from \"@js/DTO/DevelopmentExitFinance/DeveloperExitFinanceInputSetDTO.cs.d\";\r\nimport { DeveloperExitFinanceResultDTO } from \"@js/DTO/DevelopmentExitFinance/DeveloperExitFinanceResultDTO.cs.d\";\r\nimport { DeveloperExitFinanceResultSetDTO } from \"@js/DTO/DevelopmentExitFinance/DeveloperExitFinanceResultSetDTO.cs.d\";\r\nimport { LenderResultDTO } from \"@js/DTO/DevelopmentFinance/LenderResultDTO.cs.d\";\r\nimport { DeveloperExitFinanceResultService } from \"@js/services/DevExitFinance/DeveloperExitFinanceResultService\";\r\n\r\nexport class DeveloperExitFinanceResultController {\r\n selectedSection: string;\r\n\r\n //objects: DeveloperExitFinanceResultDTO[];\r\n selectedObject: DeveloperExitFinanceResultDTO;\r\n\r\n exitLoanCriteria: DeveloperExitFinanceInputSetDTO;\r\n\r\n results: DeveloperExitFinanceResultSetDTO;\r\n\r\n matchingResults: DeveloperExitFinanceResultDTO[];\r\n largestResults: DeveloperExitFinanceResultDTO[];\r\n\r\n comparisonList: DeveloperExitFinanceResultDTO[] = [];\r\n\r\n selectedResult: DeveloperExitFinanceResultDTO;\r\n\r\n warningOff: boolean = false;\r\n\r\n enquiryOpen: boolean;\r\n enquiryEmail: string;\r\n enquiryBody: string;\r\n enquiryTelephone: string;\r\n sentmessage: boolean = false;\r\n sendingmessage: boolean = false;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n developerexitfinanceresultForm: ng.IFormController;\r\n\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$location\",\r\n \"$routeParams\",\r\n \"DeveloperExitFinanceResultService\",\r\n ];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n $routeParams: ng.route.IRouteParamsService,\r\n private $developerexitfinanceresultservice: DeveloperExitFinanceResultService,\r\n ) {\r\n this.updateObjects();\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n this.exitLoanCriteria = (this.$rootScope as any).exitLoanCriteria;\r\n this.updateResults();\r\n }\r\n\r\n updateResults() {\r\n this.$developerexitfinanceresultservice\r\n .fetchMatchingResults(\r\n this.exitLoanCriteria,\r\n true,\r\n true,\r\n 20,\r\n false,\r\n \"\",\r\n \"\",\r\n \"\",\r\n \"\",\r\n )\r\n .then((results) => {\r\n this.results = results;\r\n this.matchingResults = results.MatchingResults;\r\n this.largestResults = results.LargestLoanResults;\r\n })\r\n .catch((error) => {\r\n this.matchingResults = [];\r\n })\r\n .finally(() => {});\r\n }\r\n\r\n sendEnquiry(): void {\r\n this.sendingmessage = true;\r\n this.sentmessage = false;\r\n\r\n this.$developerexitfinanceresultservice\r\n .fetchMatchingResults(\r\n this.exitLoanCriteria,\r\n true,\r\n true,\r\n 20,\r\n true,\r\n this.enquiryBody,\r\n this.enquiryEmail,\r\n this.enquiryTelephone,\r\n this.GetSelectedLabel(),\r\n )\r\n .then((response2) => {\r\n this.sendingmessage = false;\r\n this.sentmessage = true;\r\n });\r\n }\r\n\r\n private GetSelectedLabel() {\r\n var selectedlabel = \"\";\r\n if (this.selectedResult && this.selectedResult.LoanLabel) {\r\n selectedlabel = this.selectedResult.LoanLabel;\r\n }\r\n return selectedlabel;\r\n }\r\n\r\n comparisonContains(item: DeveloperExitFinanceResultDTO) {\r\n let found = !!this.comparisonList.find((result, index) => {\r\n return result === item;\r\n });\r\n\r\n if (found) {\r\n }\r\n\r\n return found;\r\n }\r\n\r\n toggleLenderComparisonSelection(item: DeveloperExitFinanceResultDTO) {\r\n let match: DeveloperExitFinanceResultDTO = this.comparisonList.find(\r\n (result, index) => {\r\n return result === item;\r\n },\r\n );\r\n\r\n if (!match && this.comparisonList.length < 3) {\r\n this.comparisonList.push(item);\r\n } else {\r\n this.comparisonList.splice(this.comparisonList.indexOf(match), 1);\r\n }\r\n }\r\n\r\n viewOffer(offer: LenderResultDTO) {\r\n this.selectedResult = offer;\r\n }\r\n\r\n goCompare() {\r\n this.warningOff = true;\r\n (this.$rootScope as any).comparisonList = this.comparisonList;\r\n\r\n // temporarily put all results into saved results so the comparison controller can use them.\r\n\r\n let allResults: DeveloperExitFinanceResultDTO[] = [];\r\n this.matchingResults.forEach((result) => {\r\n allResults.push(result);\r\n });\r\n this.largestResults.forEach((result) => {\r\n allResults.push(result);\r\n });\r\n\r\n (this.$rootScope as any).tempSavedResults = allResults;\r\n\r\n this.$location.path(\"exitloancompare\");\r\n }\r\n\r\n viewSingleLoan(item: LenderResultDTO) {\r\n this.warningOff = true;\r\n this.comparisonList = [];\r\n this.comparisonList.push(item);\r\n this.goCompare();\r\n }\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n\r\n applyForLoan(offer: DeveloperExitFinanceResultDTO, index) {\r\n this.selectedResult = offer;\r\n this.enquiryBody = \"Please call me about loan: \" + offer.LoanLabel;\r\n this.enquiryOpen = true;\r\n }\r\n}\r\n","import { AddressLookupDTO } from \"@js/DTO/AddressLookupDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { PostalAddress } from \"@js/models/PostalAddress.cs.d\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { LenderResultService } from \"@js/services/LenderResultService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { StreetAddressService } from \"@js/services/StreetAddressService\";\r\n\r\nexport class DevelopmentAppraisalScreenController {\r\n isLoggedInUser: boolean = false;\r\n\r\n fileUpload: FileAttachmentDTO[];\r\n uploadingFiles: FileUploadProgressDTO[];\r\n case: CaseDTO;\r\n caseTitle: string;\r\n openModal: boolean = false;\r\n thisModuleSection: ModuleEnum = ModuleEnum.DevelopmentAppraisal;\r\n total: number = 0;\r\n\r\n dataLoading: boolean = false;\r\n\r\n loanCriteria: DevelopmentInputDTO;\r\n step: number = 1;\r\n dateOfOrigPurchMonth: number;\r\n dateOfOrigPurchYear: number;\r\n DevelopmentInputForm: ng.IFormController;\r\n caseid: number;\r\n searchid: number;\r\n totalPurchaseCostsOwning: number;\r\n additionalBuild: number;\r\n totalBuild: number;\r\n totalSales: number;\r\n totalPurchaseCostsNotOwning: number;\r\n totalNDV: number;\r\n contingencyCost: number;\r\n\r\n searchterm: string;\r\n PostCodeOptions: PostalAddress[] = [];\r\n searchingForAddress: boolean = false;\r\n searchresults: string;\r\n\r\n criteriaPropertyForm: ng.IFormController;\r\n criteriaBorrowingForm: ng.IFormController;\r\n criteriaCostsForm: ng.IFormController;\r\n criteriaSalesForm: ng.IFormController;\r\n\r\n guidanceCheckbox: boolean = true;\r\n\r\n pageLoading: boolean = true;\r\n\r\n contingencyTotal: number;\r\n\r\n seeFiles: boolean = false;\r\n\r\n //array describing form sections\r\n formSectionNames = [\r\n {\r\n label: \"Property\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Build Costs\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Borrowing\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Sales\",\r\n visible: true,\r\n },\r\n ];\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"DevelopmentInputService\",\r\n \"$location\",\r\n \"LenderResultService\",\r\n \"StreetAddressService\",\r\n \"$cookies\",\r\n \"CaseService\",\r\n \"FileAttachmentService\",\r\n \"$window\",\r\n \"RoleService\",\r\n ];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $rootScope: ng.IRootScopeService,\r\n protected $q: ng.IQService,\r\n private $DevelopmentInputservice: DevelopmentInputService,\r\n private $location: ng.ILocationService,\r\n private $lenderresultservice: LenderResultService,\r\n private $streetAddressService: StreetAddressService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $caseService: CaseService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private $window: ng.IWindowService,\r\n private roleService: RoleService,\r\n ) {\r\n if ($cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n }\r\n\r\n //Init\r\n if (this.$routeParams.CaseId && this.$routeParams.SearchId) {\r\n this.caseid = this.$routeParams.CaseId;\r\n this.searchid = this.$routeParams.SearchId;\r\n } else {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n\r\n this.$caseService.fetch(this.$routeParams.CaseId).then((response) => {\r\n if (response == null) {\r\n if (this.isLoggedInUser) {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n } else {\r\n this.fileUpload = response.Attachments;\r\n this.case = response;\r\n this.$caseService.updateCaseState(this.case.Id, this.case.CaseStatus);\r\n this.caseTitle = response.DevelopmentInput.SearchName;\r\n }\r\n });\r\n\r\n // Look up the existing search - must exist prior in order to have a case.\r\n\r\n this.$DevelopmentInputservice\r\n .fetch(this.searchid)\r\n .then((response) => {\r\n if (response == null) {\r\n if (this.isLoggedInUser) {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n } else {\r\n this.loanCriteria = response;\r\n if (this.loanCriteria) {\r\n this.calcContingencyCost();\r\n if (this.loanCriteria.CI_Dev_DateOfOrigPurch) {\r\n this.dateOfOrigPurchMonth =\r\n this.loanCriteria.CI_Dev_DateOfOrigPurch.getMonth() + 1;\r\n this.dateOfOrigPurchYear =\r\n this.loanCriteria.CI_Dev_DateOfOrigPurch.getFullYear() % 100;\r\n }\r\n if (!this.loanCriteria.DI_PurchaseAgentFees) {\r\n this.loanCriteria.DI_PurchaseAgentFees = 0;\r\n }\r\n if (!this.loanCriteria.DI_PurchaseLegalFees) {\r\n this.loanCriteria.DI_PurchaseLegalFees = 0;\r\n }\r\n if (!this.loanCriteria.DI_PurchaseOtherFees) {\r\n this.loanCriteria.DI_PurchaseOtherFees = 0;\r\n }\r\n this.recalcContingencyTotal();\r\n }\r\n }\r\n })\r\n .catch((error) => {\r\n this.$location.path(\"/dashboard\");\r\n })\r\n .finally(() => {\r\n this.pageLoading = false;\r\n });\r\n\r\n if (this.$routeParams.StepNumber) {\r\n this.step =\r\n this.$routeParams.StepNumber > 4 || this.$routeParams.StepNumber < 1\r\n ? 1\r\n : this.$routeParams.StepNumber;\r\n } else {\r\n if (this.isLoggedInUser) {\r\n this.go(\r\n \"/criteriaappraisal/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.searchid +\r\n \"/\" +\r\n this.step,\r\n );\r\n }\r\n }\r\n\r\n this.updateGuidanceState();\r\n\r\n $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n this.updateGuidanceState();\r\n });\r\n }\r\n\r\n updateVatOnLandPurchase(value: number): void {\r\n if (value === 1) {\r\n //if yes, show vat amount question prepopulated with 20% of purchase price\r\n this.loanCriteria.LandPurchaseVatAmount =\r\n this.loanCriteria.CI_Dev_OrigPP * 0.2;\r\n }\r\n this.loanCriteria.PayingVATOnLandPurchase = value;\r\n this.CalcTotalPurchaseCostsOwning();\r\n this.CalcTotalPurchaseCostsOwning();\r\n }\r\n\r\n indexPopup(methodName: string) {\r\n this.$rootScope.$broadcast(methodName);\r\n }\r\n\r\n updateGuidanceState() {\r\n this.guidanceCheckbox =\r\n this.$cookies.get(\"guidance\") === \"on\" ||\r\n this.$cookies.get(\"guidance\") === undefined;\r\n }\r\n\r\n getGuidanceSwitchState() {\r\n if (!this.$cookies.get(\"guidance\")) {\r\n this.guidanceCheckbox = true;\r\n } else if (this.$cookies.get(\"guidance\") === \"on\") {\r\n this.guidanceCheckbox = true;\r\n } else if (this.$cookies.get(\"guidance\") === \"off\") {\r\n this.guidanceCheckbox = false;\r\n } else {\r\n this.guidanceCheckbox = true;\r\n }\r\n return this.guidanceCheckbox;\r\n }\r\n\r\n recordGuidanceCookie() {\r\n var guidanceSwitchState: string;\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 365);\r\n if (this.guidanceCheckbox == true) {\r\n guidanceSwitchState = \"on\";\r\n } else {\r\n guidanceSwitchState = \"off\";\r\n }\r\n this.$cookies.put(\"guidance\", guidanceSwitchState, { expires: expiryDate });\r\n this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n }\r\n\r\n setAllFormsPristine(): void {\r\n if (this.criteriaPropertyForm) {\r\n this.criteriaPropertyForm.$setPristine();\r\n }\r\n if (this.criteriaBorrowingForm) {\r\n this.criteriaBorrowingForm.$setPristine();\r\n }\r\n if (this.criteriaCostsForm) {\r\n this.criteriaCostsForm.$setPristine();\r\n }\r\n if (this.criteriaSalesForm) {\r\n this.criteriaSalesForm.$setPristine();\r\n }\r\n }\r\n\r\n back(): void {\r\n this.save().then(() => {\r\n if (this.step > 0) {\r\n this.step--;\r\n }\r\n\r\n this.go(\r\n \"/criteriaappraisal/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.searchid +\r\n \"/\" +\r\n this.step,\r\n );\r\n });\r\n }\r\n\r\n next(): void {\r\n this.save().then(() => {\r\n this.goToNextStep();\r\n });\r\n }\r\n\r\n /** Go to the next step */\r\n goToNextStep() {\r\n if (this.step == 6) {\r\n // Store the search on rootScope.\r\n //(this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n //this.$location.path(\"/results\");\r\n }\r\n this.step++;\r\n this.go(\r\n \"/criteriaappraisal/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.searchid +\r\n \"/\" +\r\n this.step,\r\n );\r\n }\r\n\r\n goToCaseDashboard(save: boolean = false): void {\r\n if (!this.roleService.IsLender) {\r\n this.save();\r\n (this.$rootScope as any).formSaved = true;\r\n }\r\n\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n }\r\n go(path): void {\r\n if (!this.roleService.IsLender) {\r\n this.save().then((response) => {\r\n this.$location.path(path);\r\n });\r\n } else {\r\n this.$location.path(path);\r\n }\r\n }\r\n\r\n setDate(dateToUpdate: Date, month: number, year: number) {\r\n // Two digit years!\r\n var fullYear: number;\r\n var today = new Date();\r\n if (today.getFullYear() < 2000 + year) {\r\n // If it's after this year, we probably mean 19xx.\r\n fullYear = 1900 + year;\r\n } else {\r\n // Otherwise it's probably in the 2000s.\r\n fullYear = 2000 + year;\r\n }\r\n dateToUpdate.setUTCFullYear(fullYear);\r\n // Note: Months are 0 based.\r\n dateToUpdate.setUTCMonth(month - 1);\r\n }\r\n\r\n calcContingencyCost(): number {\r\n if (this.pageLoading === false) {\r\n var res: number = 0;\r\n if (this.contingencyTotal == 0) {\r\n if (\r\n this.loanCriteria.CI_Dev_Contingency &&\r\n this.loanCriteria.CI_Dev_BuildCosts\r\n ) {\r\n res =\r\n this.loanCriteria.CI_Dev_Contingency *\r\n this.loanCriteria.CI_Dev_BuildCosts;\r\n this.contingencyTotal = res;\r\n return res;\r\n }\r\n }\r\n\r\n return this.contingencyTotal;\r\n }\r\n }\r\n\r\n recalcContingencyTotal(): void {\r\n let res: number = 0;\r\n //Case 1 - recalc Build costs\r\n if (\r\n this.loanCriteria.CI_Dev_Contingency &&\r\n this.loanCriteria.CI_Dev_BuildCosts\r\n ) {\r\n res =\r\n this.loanCriteria.CI_Dev_Contingency *\r\n this.loanCriteria.CI_Dev_BuildCosts;\r\n this.contingencyTotal = res;\r\n }\r\n }\r\n\r\n CalcTotalPurchaseCostsNotOwning(): number {\r\n if (this.pageLoading === false) {\r\n var res: number = 0;\r\n if (this.loanCriteria.CI_Dev_OrigPP) {\r\n res += Number(this.loanCriteria.CI_Dev_OrigPP);\r\n }\r\n if (this.loanCriteria.CI_Dev_SDLT) {\r\n res += Number(this.loanCriteria.CI_Dev_SDLT);\r\n }\r\n //if (this.loanCriteria.CI_Land_Total_other_Costs) {\r\n // res += Number(this.loanCriteria.CI_Land_Total_other_Costs)\r\n //}\r\n if (this.loanCriteria.DI_PurchaseAgentFees) {\r\n res += Number(this.loanCriteria.DI_PurchaseAgentFees);\r\n }\r\n if (this.loanCriteria.DI_PurchaseLegalFees) {\r\n res += Number(this.loanCriteria.DI_PurchaseLegalFees);\r\n }\r\n if (this.loanCriteria.DI_PurchaseOtherFees) {\r\n res += Number(this.loanCriteria.DI_PurchaseOtherFees);\r\n }\r\n if (this.loanCriteria.PayingVATOnLandPurchase === 1) {\r\n res += Number(this.loanCriteria.LandPurchaseVatAmount);\r\n }\r\n //this.loanCriteria.Dev_TotLndCostAdj = res;\r\n this.totalPurchaseCostsNotOwning = res;\r\n return res;\r\n }\r\n }\r\n\r\n CalcTotalPurchaseCostsOwning(): number {\r\n if (this.pageLoading === false) {\r\n var res: number = 0;\r\n if (this.loanCriteria.CI_Dev_OrigPP) {\r\n res += Number(this.loanCriteria.CI_Dev_OrigPP);\r\n }\r\n if (this.loanCriteria.CI_Dev_SDLT) {\r\n res += Number(this.loanCriteria.CI_Dev_SDLT);\r\n }\r\n if (this.loanCriteria.DI_PurchaseAgentFees) {\r\n res += Number(this.loanCriteria.DI_PurchaseAgentFees);\r\n }\r\n if (this.loanCriteria.DI_PurchaseLegalFees) {\r\n res += Number(this.loanCriteria.DI_PurchaseLegalFees);\r\n }\r\n if (this.loanCriteria.DI_PurchaseOtherFees) {\r\n res += Number(this.loanCriteria.DI_PurchaseOtherFees);\r\n }\r\n if (this.loanCriteria.PayingVATOnLandPurchase === 1) {\r\n res += Number(this.loanCriteria.LandPurchaseVatAmount);\r\n }\r\n //this.loanCriteria.Dev_TotLndCostAdj = res;\r\n this.totalPurchaseCostsOwning = res;\r\n return res;\r\n }\r\n }\r\n CalcTotalBuild(): number {\r\n if (this.pageLoading === false) {\r\n var res: number = this.CalcAdditionalBuild();\r\n if (this.loanCriteria.CI_Dev_BuildCosts) {\r\n res += Number(this.loanCriteria.CI_Dev_BuildCosts);\r\n }\r\n if (this.contingencyTotal) {\r\n res += Number(this.contingencyTotal);\r\n }\r\n //this.loanCriteria.Dev_TotBuildCostsAdj = res;\r\n //this.loanCriteria.CI_Dev_BuildCosts = res;\r\n this.totalBuild = res;\r\n return res;\r\n }\r\n }\r\n CalcTotalSales(): number {\r\n if (this.pageLoading === false) {\r\n var res: number = 0;\r\n if (this.loanCriteria.DI_Sales_Dressing) {\r\n res += Number(this.loanCriteria.DI_Sales_Dressing);\r\n }\r\n if (this.loanCriteria.DC_SalesAgentFees) {\r\n res += Number(this.loanCriteria.DC_SalesAgentFees);\r\n }\r\n if (this.loanCriteria.DC_SalesLegalFeesPercent) {\r\n res += Number(this.loanCriteria.DC_SalesLegalFeesPercent);\r\n }\r\n this.totalSales = res;\r\n return res;\r\n }\r\n }\r\n\r\n CalcNDV(): number {\r\n if (this.pageLoading === false) {\r\n var gdv: number = 0;\r\n var sales: number = 0;\r\n if (\r\n this.loanCriteria.CI_UseGDVCalculated === false &&\r\n this.loanCriteria.CI_GDV\r\n ) {\r\n gdv = Number(this.loanCriteria.CI_GDV);\r\n }\r\n if (\r\n this.loanCriteria.CI_UseGDVCalculated === true &&\r\n this.loanCriteria.CI_GDVCalculated\r\n ) {\r\n gdv = Number(this.loanCriteria.CI_GDVCalculated);\r\n }\r\n if (this.totalSales) {\r\n sales = Number(this.totalSales);\r\n }\r\n var ndv: number = Number(gdv - sales);\r\n if (ndv <= 0) {\r\n ndv = Number(0);\r\n }\r\n this.totalNDV = ndv;\r\n return ndv;\r\n }\r\n }\r\n\r\n CalcAdditionalBuild(): number {\r\n if (this.pageLoading === false) {\r\n var res: number = 0;\r\n if (this.loanCriteria.DI_BreakDownBuildCosts) {\r\n if (this.loanCriteria.CI_Dev_ProfPlanning) {\r\n res += Number(this.loanCriteria.CI_Dev_ProfPlanning);\r\n }\r\n if (this.loanCriteria.CI_Dev_ProfQS) {\r\n res += Number(this.loanCriteria.CI_Dev_ProfQS);\r\n }\r\n if (this.loanCriteria.DI_BuildProjectManag) {\r\n res += Number(this.loanCriteria.DI_BuildProjectManag);\r\n }\r\n if (this.loanCriteria.CI_Dev_S106CIL) {\r\n res += Number(this.loanCriteria.CI_Dev_S106CIL);\r\n }\r\n if (this.loanCriteria.DI_BuildMechEng) {\r\n res += Number(this.loanCriteria.DI_BuildMechEng);\r\n }\r\n if (this.loanCriteria.DI_BuildStrucEng) {\r\n res += Number(this.loanCriteria.DI_BuildStrucEng);\r\n }\r\n if (this.loanCriteria.DI_BuildPartyWall) {\r\n res += Number(this.loanCriteria.DI_BuildPartyWall);\r\n }\r\n if (this.loanCriteria.DI_BuildLandscaping) {\r\n res += Number(this.loanCriteria.DI_BuildLandscaping);\r\n }\r\n if (this.loanCriteria.DI_BuildWarranty) {\r\n res += Number(this.loanCriteria.DI_BuildWarranty);\r\n }\r\n if (this.loanCriteria.DI_BuildDemolition) {\r\n res += Number(this.loanCriteria.DI_BuildDemolition);\r\n }\r\n if (this.loanCriteria.DI_BuildOtherCosts) {\r\n res += Number(this.loanCriteria.DI_BuildOtherCosts);\r\n }\r\n } else {\r\n if (this.loanCriteria.CI_Dev_AdditionalOngoingCosts) {\r\n res += Number(this.loanCriteria.CI_Dev_AdditionalOngoingCosts);\r\n }\r\n }\r\n this.additionalBuild = res;\r\n return res;\r\n }\r\n }\r\n save(): ng.IPromise {\r\n //this.loanCriteria.SaveQueryAndResults = true;\r\n let defer = this.$q.defer();\r\n if (!this.loanCriteria) {\r\n return defer.promise;\r\n }\r\n this.$DevelopmentInputservice\r\n .addUpdatereturnonlyid(this.loanCriteria)\r\n .then((response) => {\r\n this.$lenderresultservice\r\n .fetchMatchingResults(\r\n this.loanCriteria,\r\n true,\r\n true,\r\n 20,\r\n false,\r\n \"\",\r\n \"\",\r\n \"\",\r\n this.loanCriteria.SearchName,\r\n )\r\n .then((results) => {\r\n this.setAllFormsPristine();\r\n })\r\n .catch((error) => {})\r\n .finally(() => {});\r\n defer.resolve(response as number);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n formChanged(): void {\r\n (this.$rootScope as any).formSaved = false;\r\n }\r\n\r\n getAddressList(app, searchTerm: string) {\r\n let foundMatch = false;\r\n\r\n if (\r\n this.PostCodeOptions &&\r\n this.PostCodeOptions &&\r\n this.PostCodeOptions.length > 0\r\n ) {\r\n let addressLookup = this.PostCodeOptions.find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n\r\n // We've selected an address!\r\n this.$streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n app.DI_StreetAddress = address;\r\n this.searchterm = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n this.loanCriteria.DI_StreetAddress.AddressLine1 =\r\n addressLookup.AddressLine2;\r\n this.loanCriteria.DI_StreetAddress.AddressLine2 =\r\n addressLookup.AddressLine3;\r\n this.loanCriteria.DI_StreetAddress.AddressLine3 =\r\n addressLookup.AddressLine4;\r\n this.loanCriteria.DI_StreetAddress.AddressLine4 =\r\n addressLookup.PostCode;\r\n this.loanCriteria.DI_StreetAddress.PostCode =\r\n addressLookup.AddressLine1;\r\n this.searchterm = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n // Initial search term\r\n this.PostCodeOptions = [];\r\n\r\n this.$streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.PostCodeOptions = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n sum(a: number, b: number): number {\r\n return a + b;\r\n }\r\n\r\n //File upload\r\n\r\n onFileSelect(files: FileAttachmentDTO[], module: ModuleEnum) {\r\n if (files.length > 0) {\r\n //if case has no id it must be saved first\r\n if (this.case.Id < 1) {\r\n this.$caseService\r\n .addUpdate(this.case)\r\n .then((response) => {\r\n this.case = response;\r\n this.onFileSelect(files, module); //call itself and then exit as should now be saved so should be able to run\r\n return;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n return;\r\n }\r\n this.fileAttachmentService\r\n .UploadFileLstInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.case.Id,\r\n this.fileUpload,\r\n module,\r\n )\r\n .then((result) => {\r\n this.openModal = false;\r\n });\r\n }\r\n }\r\n\r\n downloadFile(file: FileAttachmentDTO) {\r\n this.fileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n this.$window.open(uri);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n deleteFile(file: FileAttachmentDTO) {\r\n this.fileUpload.splice(this.fileUpload.indexOf(file), 1);\r\n this.fileAttachmentService.markasdeleted(file.Id).then((result) => {});\r\n }\r\n\r\n calculateTotalFiles(filter: number) {\r\n if (this.fileUpload) {\r\n this.total = this.fileUpload.filter(\r\n (item) => item.Module === filter,\r\n ).length;\r\n }\r\n return this.total;\r\n }\r\n\r\n viewResults(loanCriteria: DevelopmentInputDTO) {\r\n if (!this.roleService.IsLender) {\r\n this.save();\r\n (this.$rootScope as any).formSaved = true;\r\n }\r\n this.$location.path(\r\n \"/results/\" + this.case.DevelopmentInputID + \"/\" + this.case.Id,\r\n );\r\n }\r\n}\r\n","export const enum OwnerOrEmployeeEnum {\r\n None = 0,\r\n Owner = 1,\r\n Employee = 2,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { CaseMemberDTO } from \"@js/DTO/CaseMemberDTO.cs.d\";\r\nimport { DevelopmentTrackRecordDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentTrackRecordDTO.cs.d\";\r\nimport { ProjectOwnershipDTO } from \"@js/DTO/DevelopmentFinance/ProjectOwnershipDTO.cs.d\";\r\nimport { AreaUnitEnum } from \"@js/models/enum/AreaUnitEnum.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs.d\";\r\nimport { OwnerOrEmployeeEnum } from \"@js/models/enum/OwnerOrEmployeeEnum.cs.d\";\r\nimport { OwnNewDevelopmentEnum } from \"@js/models/enum/OwnNewDevelopmentEnum.cs.d\";\r\nimport { PostalAddress } from \"@js/models/PostalAddress.cs.d\";\r\nimport { ApplicantService } from \"@js/services/ApplicantService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DevelopmentExperienceService } from \"@js/services/DevelopmentExperienceService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class DevelopmentExperienceController {\r\n isLoggedInUser: boolean = false;\r\n\r\n case: CaseDTO;\r\n caseTitle: string;\r\n\r\n message: string = \"\";\r\n modal: boolean = false;\r\n\r\n //Check if shareholder is Admin or current user\r\n isAdmin: boolean = false;\r\n shareholder: CaseMemberDTO;\r\n selectedUser: ApplicationUserDTO;\r\n isPrimaryApplicant: boolean;\r\n\r\n //share shareholder\r\n shareContext: number = null;\r\n shareSuplId: number = null;\r\n userFirstName: string;\r\n shareNote: string;\r\n shareFirstName: string;\r\n shareSurname: string;\r\n shareEmail: string;\r\n showShare: boolean = false;\r\n\r\n dataLoading: boolean = false;\r\n selectedObject: ProjectOwnershipDTO;\r\n maxDateOfBirth: Date = new Date();\r\n minDateOfBirth: Date = new Date(\"Jan 01 1900\");\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n show: boolean[] = [];\r\n showAutofill: boolean = false;\r\n\r\n step: number = 1;\r\n caseid: number;\r\n\r\n formattedAcquisitionDate: any[] = [];\r\n\r\n error: boolean = false;\r\n saving: boolean = false;\r\n saved: boolean = false;\r\n\r\n devexperienceId: number;\r\n\r\n multiPartForm1: ng.IFormController;\r\n assetform: ng.IFormController;\r\n\r\n //array describing form sections\r\n formSectionNames = [\r\n {\r\n label: \"Ownership\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Shareholders\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Track Record\",\r\n visible: true,\r\n },\r\n ];\r\n\r\n applicantNo: number = 0;\r\n\r\n guidanceCheckbox: boolean = true;\r\n\r\n applicantForm: ng.IFormController;\r\n showDelete: boolean = false;\r\n confirmDeleteApplicant: CaseMemberDTO;\r\n tempApplicant: CaseMemberDTO;\r\n showQuickEditModal: boolean = false;\r\n addEditApplicant: CaseMemberDTO;\r\n disableQuickEditSave: boolean = false;\r\n isAddShareholder: boolean;\r\n\r\n showAdd: boolean = false;\r\n showEdit: boolean = false;\r\n editApplicant: CaseMemberDTO;\r\n newApplicant: CaseMemberDTO;\r\n\r\n owners: CaseMemberDTO[];\r\n IsBroker: boolean = false;\r\n maxDateForDateField: Date = new Date(\"Jan 01 3000\");\r\n\r\n howWillYouOwnNewDevelopmentOptions = [\r\n { label: \"UK Limited Company\", value: 1 },\r\n { label: \"UK Limited Liability Partnership\", value: 2 },\r\n { label: \"Personal Names\", value: 3 },\r\n { label: \"Overseas Limited Company\", value: 4 },\r\n { label: \"Pension Fund\", value: 5 },\r\n { label: \"Other(Please Specify)\", value: 6 },\r\n ];\r\n\r\n static $inject = [\r\n \"$window\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$routeParams\",\r\n \"DevelopmentExperienceService\",\r\n \"ApplicantService\",\r\n \"$location\",\r\n \"CaseService\",\r\n \"$cookies\",\r\n \"CaseMemberService\",\r\n \"RoleService\",\r\n \"UserService\",\r\n \"AuthService\",\r\n ];\r\n\r\n //private $subobjectservice: App.Services.SubobjectService\r\n constructor(\r\n private $window: ng.IWindowService,\r\n private $rootScope: ng.IRootScopeService,\r\n protected $q: ng.IQService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $developmentexperienceservice: DevelopmentExperienceService,\r\n private $applicantservice: ApplicantService,\r\n private $location: ng.ILocationService,\r\n private $caseService: CaseService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $caseMemberService: CaseMemberService,\r\n private roleService: RoleService,\r\n private userService: UserService,\r\n private $auth: AuthService,\r\n ) {\r\n if ($cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n\r\n this.userService.getUserAutofill().then((response) => {\r\n this.showAutofill = response;\r\n });\r\n }\r\n\r\n //Get step number\r\n if (this.$routeParams.StepNumber) {\r\n this.step =\r\n this.$routeParams.StepNumber > 8 || this.$routeParams.StepNumber < 1\r\n ? 1\r\n : this.$routeParams.StepNumber;\r\n }\r\n\r\n if (this.$routeParams.CaseId) {\r\n this.caseid = this.$routeParams.CaseId;\r\n }\r\n\r\n //existing devexperience\r\n if (this.$routeParams.Id && this.$routeParams.Id > 0) {\r\n this.devexperienceId = this.$routeParams.Id;\r\n\r\n this.userService.getcurentuserrecord().then((result) => {\r\n this.selectedUser = result;\r\n });\r\n\r\n //if (!this.selectedObject) {\r\n this.$developmentexperienceservice\r\n .fetch(this.$routeParams.Id)\r\n .then((response) => {\r\n if (response == null) {\r\n if (this.isLoggedInUser) {\r\n this.$location.path(\"/userdashboard\");\r\n } else {\r\n this.$location.path(\"/landing\");\r\n }\r\n } else {\r\n this.selectedObject = response;\r\n if (this.selectedObject.HowWillYouOwnNewDevelopment <= 0) {\r\n this.selectedObject.HowWillYouOwnNewDevelopment = 1;\r\n }\r\n\r\n this.$caseMemberService\r\n .fetchByCaseId(this.caseid)\r\n .then((response) => {\r\n this.owners = response;\r\n\r\n this.selectedObject.HowManyOwnersShareholdersOrPartners =\r\n this.owners.length;\r\n });\r\n\r\n this.selectedObject.DevelopmentTrackRecords.forEach((d, index) => {\r\n if (d.AcquistionDate != null) {\r\n this.formattedAcquisitionDate[index] = new Date(\r\n d.AcquistionDate.toString(),\r\n );\r\n }\r\n });\r\n }\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n });\r\n } else if (this.caseid) {\r\n //assoicate the case with it so when it is saved the server attaches it to the case\r\n this.selectedObject = {\r\n parentCaseToAssoicateWithOnCreation: this.caseid,\r\n } as ProjectOwnershipDTO;\r\n } else {\r\n this.selectedObject = {} as ProjectOwnershipDTO;\r\n }\r\n\r\n this.$caseService.fetch(this.$routeParams.CaseId).then((response) => {\r\n this.case = response;\r\n this.caseTitle = response.DevelopmentInput.SearchName;\r\n this.checkForPrimaryUser();\r\n });\r\n\r\n if (this.$routeParams.Id < 1) {\r\n // no develoment experience id\r\n this.save(false).then((response) => {\r\n this.devexperienceId = response;\r\n this.go(\r\n \"/devexperience/\" + this.caseid + \"/\" + this.devexperienceId + \"/1\",\r\n );\r\n });\r\n } else if (!this.$routeParams.StepNumber) {\r\n this.go(\r\n \"/devexperience/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.devexperienceId +\r\n \"/\" +\r\n this.step,\r\n );\r\n }\r\n\r\n if (this.$routeParams.ApplicantNo) {\r\n this.applicantNo = this.$routeParams.ApplicantNo;\r\n }\r\n\r\n this.updateGuidanceState();\r\n this.checkForAdmin();\r\n this.checkIfOnlyBroker();\r\n\r\n $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n this.updateGuidanceState();\r\n });\r\n }\r\n\r\n checkForAdmin(): void {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isAdminUser()\r\n .then((response) => {\r\n this.isAdmin = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkIfOnlyBroker() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isBroker()\r\n .then((response) => {\r\n this.IsBroker = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkForPrimaryUser(): boolean {\r\n if (\r\n (this.$rootScope as any).selectedUser &&\r\n this.case &&\r\n (this.$rootScope as any).selectedUser.UserName == this.case.OwnerUser\r\n ) {\r\n this.isPrimaryApplicant = true;\r\n return true;\r\n }\r\n\r\n this.isPrimaryApplicant = false;\r\n return false;\r\n }\r\n\r\n clientAccountAccessCheck(shareholder: CaseMemberDTO): boolean {\r\n if (this.owners) {\r\n this.shareholder = this.owners.find(\r\n (x) => x.UserId == shareholder.UserId,\r\n );\r\n }\r\n\r\n if (this.shareholder.UserId == (this.$rootScope as any).selectedUser.Id) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n updateGuidanceState() {\r\n this.guidanceCheckbox =\r\n this.$cookies.get(\"guidance\") === \"on\" ||\r\n this.$cookies.get(\"guidance\") === undefined;\r\n }\r\n\r\n getGuidanceSwitchState() {\r\n if (!this.$cookies.get(\"guidance\")) {\r\n this.guidanceCheckbox = true;\r\n } else if (this.$cookies.get(\"guidance\") === \"on\") {\r\n this.guidanceCheckbox = true;\r\n } else if (this.$cookies.get(\"guidance\") === \"off\") {\r\n this.guidanceCheckbox = false;\r\n } else {\r\n this.guidanceCheckbox = true;\r\n }\r\n return this.guidanceCheckbox;\r\n }\r\n\r\n addApplicantPopUp() {\r\n delete this.newApplicant;\r\n this.showAdd = true;\r\n }\r\n\r\n resetApplicant() {\r\n this.applicantForm.$setPristine();\r\n this.applicantForm.$setUntouched();\r\n this.newApplicant = {} as CaseMemberDTO;\r\n this.showAdd = false;\r\n }\r\n\r\n updateApplicant(applicant: CaseMemberDTO): void {\r\n this.editApplicant = applicant;\r\n this.tempApplicant = { ...this.editApplicant };\r\n this.showEdit = true;\r\n }\r\n\r\n saveUpdatedApplicant(applicant: CaseMemberDTO): void {\r\n this.disableQuickEditSave = true; // this is just because sometimes the save takes a little while and the user could click the save button again\r\n applicant.CaseId = this.case.Id;\r\n\r\n if (!applicant.StreetAddress) {\r\n applicant.StreetAddress = {\r\n AddressLine1: \"\",\r\n AddressLine2: \"\",\r\n AddressLine3: \"\",\r\n AddressLine4: \"\",\r\n PostCode: \"\",\r\n } as PostalAddress;\r\n }\r\n\r\n this.$applicantservice\r\n .addOrUpdateCaseMember(applicant, this.isAddShareholder)\r\n .then((response) => {\r\n response.DateOfBirth = applicant.DateOfBirth;\r\n const existingShareholder = this.owners.find(\r\n (s) => s.Id == response.Id,\r\n );\r\n\r\n // If found then we're updating\r\n if (existingShareholder) {\r\n this.owners = this.owners.filter(\r\n (member) => member.Id != applicant.Id,\r\n );\r\n this.owners.push(response);\r\n } else {\r\n this.owners.push(response);\r\n }\r\n })\r\n .finally(() => {\r\n delete this.newApplicant;\r\n this.showEdit = false;\r\n this.showAdd = false;\r\n this.disableQuickEditSave = false;\r\n });\r\n }\r\n\r\n cancelUpdateApplicant() {\r\n this.showEdit = false;\r\n this.owners = this.owners.filter(\r\n (applicant) => applicant.Id != this.tempApplicant.Id,\r\n );\r\n this.owners.push(this.tempApplicant); // Resets anything that is changed using the original data object\r\n }\r\n\r\n recordGuidanceCookie() {\r\n var guidanceSwitchState: string;\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 365);\r\n if (this.guidanceCheckbox == true) {\r\n guidanceSwitchState = \"on\";\r\n } else {\r\n guidanceSwitchState = \"off\";\r\n }\r\n this.$cookies.put(\"guidance\", guidanceSwitchState, { expires: expiryDate });\r\n this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n }\r\n\r\n formChanged(): void {\r\n (this.$rootScope as any).formSaved = false;\r\n }\r\n\r\n save(isFormComplete: boolean): ng.IPromise {\r\n let defer = this.$q.defer();\r\n if (!this.selectedObject) {\r\n return defer.promise;\r\n }\r\n\r\n if (!this.roleService.IsLender) {\r\n this.saving = true;\r\n\r\n this.formattedAcquisitionDate.forEach((d, index) => {\r\n this.selectedObject.DevelopmentTrackRecords[index].AcquistionDate = d;\r\n });\r\n\r\n var saveRequest = this.$developmentexperienceservice\r\n .addUpdatereturnonlyid(this.selectedObject)\r\n .then((response) => {\r\n //set ID of selectedobject\r\n this.selectedObject.Id = response;\r\n //after save take out saving assoication each time\r\n this.selectedObject.parentCaseToAssoicateWithOnCreation = null;\r\n this.setAllFormsPristine();\r\n this.saved = true;\r\n if (isFormComplete) {\r\n var markComplete = {\r\n Id: this.caseid,\r\n DevelopmentAppraisalComplete: true,\r\n } as CaseDTO;\r\n this.$caseService\r\n .addUpdatereturnonlyid(markComplete)\r\n .then((response) => {\r\n this.goToCaseDashboard(true);\r\n });\r\n }\r\n defer.resolve(response as number);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n this.error = true;\r\n })\r\n .finally(() => {\r\n this.saving = false;\r\n });\r\n }\r\n return defer.promise;\r\n }\r\n\r\n next(): void {\r\n //go to next screen\r\n this.step++;\r\n if (this.step > 1 && this.step <= 3) {\r\n this.go(\r\n \"/devexperience/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.devexperienceId +\r\n \"/\" +\r\n this.step,\r\n );\r\n (this.$rootScope as any).formSaved = this.roleService.IsLender;\r\n } else {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n }\r\n }\r\n\r\n back(): void {\r\n if (this.step > 1) {\r\n this.step--;\r\n this.go(\r\n \"/devexperience/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.devexperienceId +\r\n \"/\" +\r\n this.step,\r\n );\r\n (this.$rootScope as any).formSaved = this.roleService.IsLender;\r\n } else if (this.step <= 1) {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n }\r\n }\r\n\r\n goToCaseDashboard(blockSave?: boolean): void {\r\n if (this.roleService.IsLender == true) {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n } else {\r\n if (blockSave) {\r\n this.save(true).then((response) => {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n (this.$rootScope as any).formSaved = true;\r\n });\r\n } else {\r\n this.save(false).then(() => {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n });\r\n }\r\n }\r\n }\r\n\r\n setAllFormsPristine(): void {\r\n if (this.multiPartForm1) {\r\n this.multiPartForm1.$setPristine();\r\n }\r\n }\r\n\r\n updateComparable(index) {\r\n this.show[index] = true;\r\n }\r\n\r\n ShowCompanyOrPartnershipName(): boolean {\r\n if (\r\n this.selectedObject &&\r\n this.selectedObject.HowWillYouOwnNewDevelopment !=\r\n OwnNewDevelopmentEnum.PersonalNames &&\r\n this.selectedObject.HasTheCompanyOrPensionBeenFormedYet\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n ShowCompanyOrPartnershipNumber(): boolean {\r\n if (\r\n this.selectedObject &&\r\n this.selectedObject.HowWillYouOwnNewDevelopment !=\r\n OwnNewDevelopmentEnum.PersonalNames &&\r\n this.selectedObject.HasTheCompanyOrPensionBeenFormedYet\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n ShowPensionType(): boolean {\r\n if (\r\n this.selectedObject &&\r\n this.selectedObject.HowWillYouOwnNewDevelopment ==\r\n OwnNewDevelopmentEnum.PensionFund &&\r\n this.selectedObject.HasTheCompanyOrPensionBeenFormedYet\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n go(path): void {\r\n // Only need to save if user is NOT a lender (everything is in read-only mode for lender)\r\n if (this.roleService.IsLender == true) {\r\n this.$location.path(path);\r\n } else {\r\n this.save(false).then((response) => {\r\n this.devexperienceId = response;\r\n this.$location.path(path);\r\n });\r\n }\r\n }\r\n\r\n sum(a: number, b: number): number {\r\n return a + b;\r\n }\r\n\r\n getMethodOwningText(): string {\r\n var methodofowningnewdevelopmenttext;\r\n var nameOfSubParts;\r\n if (\r\n this.selectedObject &&\r\n this.selectedObject.HowWillYouOwnNewDevelopment\r\n ) {\r\n this.formSectionNames.forEach((s) => (s.visible = true));\r\n switch (this.selectedObject.HowWillYouOwnNewDevelopment) {\r\n case OwnNewDevelopmentEnum.UKLimitedCompany:\r\n methodofowningnewdevelopmenttext = \"UK Limited Company\";\r\n nameOfSubParts = \"Shareholders\";\r\n break;\r\n case OwnNewDevelopmentEnum.OverseasLimitedCompany:\r\n methodofowningnewdevelopmenttext = \"Overseas Limited Company\";\r\n nameOfSubParts = \"Shareholders\";\r\n break;\r\n case OwnNewDevelopmentEnum.Other:\r\n methodofowningnewdevelopmenttext =\r\n this.selectedObject.HowWillYouOwnNewDevelopmentOther;\r\n nameOfSubParts = \"Owners\";\r\n this.formSectionNames[1].visible = false;\r\n //step = 2;\r\n break;\r\n case OwnNewDevelopmentEnum.PensionFund:\r\n methodofowningnewdevelopmenttext = \"Pension Fund\";\r\n nameOfSubParts = \"beneficiaries\";\r\n break;\r\n case OwnNewDevelopmentEnum.PersonalNames:\r\n methodofowningnewdevelopmenttext = \"Personal Names\";\r\n nameOfSubParts = \"Owners\";\r\n this.formSectionNames[1].visible = false;\r\n //step = 2;\r\n break;\r\n case OwnNewDevelopmentEnum.UKLimitedLiabilityPartnership:\r\n methodofowningnewdevelopmenttext = \"UK Limited Liability Partnership\";\r\n nameOfSubParts = \"Partners\";\r\n break;\r\n default:\r\n }\r\n return methodofowningnewdevelopmenttext;\r\n }\r\n return \"\";\r\n }\r\n\r\n /** Initialise the CaseMemberDTO for adding a new Shareholder/Applicant */\r\n initialiseNewApplicant() {\r\n this.addEditApplicant = {\r\n AccessLevel: CaseAccessLevelEnum.Hidden,\r\n CaseId: this.$routeParams.CaseId,\r\n IsApplicant: true,\r\n Order: this.owners && this.owners.length > 0 ? this.owners.length + 1 : 1,\r\n StreetAddress: {\r\n AddressLine1: \"\",\r\n AddressLine2: \"\",\r\n AddressLine3: \"\",\r\n AddressLine4: \"\",\r\n PostCode: \"\",\r\n } as PostalAddress,\r\n } as CaseMemberDTO;\r\n }\r\n\r\n /**\r\n * Open the Shareholder/Applicant quick edit\r\n * @param applicant\r\n */\r\n openShareholderQuickEdit(applicant: CaseMemberDTO) {\r\n if (applicant) {\r\n this.isAddShareholder = false;\r\n this.addEditApplicant = applicant;\r\n this.tempApplicant = { ...this.addEditApplicant };\r\n } else {\r\n this.isAddShareholder = true;\r\n if (this.applicantForm) {\r\n this.applicantForm.$setPristine();\r\n this.applicantForm.$setUntouched();\r\n }\r\n\r\n this.initialiseNewApplicant();\r\n }\r\n\r\n this.showQuickEditModal = true;\r\n }\r\n\r\n /** Cancel any adding or editing of a Shareholder/Applicant */\r\n cancelShareholderQuickEdit() {\r\n if (this.tempApplicant && this.tempApplicant.Id > 0) {\r\n this.owners = this.owners.filter(\r\n (applicant) => applicant.Id != this.tempApplicant.Id,\r\n );\r\n this.owners.push(this.tempApplicant);\r\n }\r\n\r\n this.closeShareholderQuickEdit();\r\n }\r\n\r\n /** Save a new or updated Shareholder/Applicant on quick add/edit */\r\n saveApplicant(): void {\r\n this.disableQuickEditSave = true; // this is just because sometimes the save takes a little while and the user could click the save button again\r\n\r\n this.$applicantservice\r\n .addOrUpdateCaseMember(this.addEditApplicant, true)\r\n .then((response) => {\r\n const existingShareholder = this.owners.find(\r\n (s) => s.Id == response.Id,\r\n );\r\n\r\n // If found then we're updating\r\n if (existingShareholder) {\r\n this.owners = this.owners.filter(\r\n (member) => member.Id != this.addEditApplicant.Id,\r\n );\r\n this.owners.push(response);\r\n } else {\r\n this.owners.push(response);\r\n }\r\n })\r\n .finally(() => {\r\n this.showQuickEditModal = false;\r\n this.applicantForm.$setPristine();\r\n this.applicantForm.$setUntouched();\r\n this.tempApplicant = {} as CaseMemberDTO;\r\n this.addEditApplicant = {} as CaseMemberDTO;\r\n this.disableQuickEditSave = false;\r\n });\r\n }\r\n\r\n deleteApplicant(): void {\r\n var id = this.confirmDeleteApplicant.Id;\r\n\r\n this.$caseMemberService\r\n .markAsDeleteAndSetNextCaseMenmberAsPrimary(\r\n this.caseid,\r\n this.confirmDeleteApplicant.Id,\r\n )\r\n .then((response) => {\r\n this.owners = response;\r\n });\r\n this.confirmDeleteApplicant = {} as CaseMemberDTO;\r\n this.showDelete = false;\r\n }\r\n\r\n deleteConfirmApplicant(applicant: CaseMemberDTO) {\r\n this.showDelete = true;\r\n this.confirmDeleteApplicant = { ...applicant };\r\n }\r\n\r\n /** Processing that should be done each time the modal closes - on cancel or save */\r\n closeShareholderQuickEdit() {\r\n this.showQuickEditModal = false;\r\n this.applicantForm.$setPristine();\r\n this.applicantForm.$setUntouched();\r\n this.tempApplicant = {} as CaseMemberDTO;\r\n this.addEditApplicant = {} as CaseMemberDTO;\r\n }\r\n\r\n isInvalid() {\r\n if (this.selectedObject) {\r\n if (!this.selectedObject.HasTheCompanyOrPensionBeenFormedYet) {\r\n return false;\r\n }\r\n if (\r\n this.selectedObject.CompanyPensionOrPartnershipName &&\r\n this.selectedObject.CompanyOrPartnershipNumber\r\n ) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n }\r\n\r\n goToApplicantDetails(applicant: CaseMemberDTO): void {\r\n //change applicant.id to index (use a for loop to iterate through dto)\r\n var applicantId;\r\n\r\n for (let i = 0; i <= this.owners.length - 1; i++) {\r\n if (this.owners[i].Id == applicant.Id) {\r\n applicantId = i;\r\n }\r\n }\r\n if (applicantId || applicantId == 0) {\r\n this.go(\r\n \"/applicantdetails/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.devexperienceId +\r\n \"/\" +\r\n applicant.Id +\r\n \"/1\",\r\n );\r\n }\r\n }\r\n\r\n invite(applicant: CaseMemberDTO) {\r\n this.$caseMemberService\r\n .inviteApplicant(applicant.UniqueRef)\r\n .then((i) => {\r\n this.modal = true;\r\n this.message =\r\n \"A request has been sent to \" +\r\n applicant.FirstName +\r\n \" \" +\r\n applicant.Surname +\r\n \" complete their shareholder profile.\";\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem sending the invite request to \" +\r\n applicant.FirstName +\r\n \" \" +\r\n applicant.Surname +\r\n \". Please try again later.\";\r\n });\r\n }\r\n\r\n /**\r\n * Determines when to show/hide the Invite button\r\n * @param shareholder\r\n */\r\n showInviteButton(shareholder: CaseMemberDTO) {\r\n // If the shareholder has already been verified then don't show the button\r\n if (shareholder.IsVerified) {\r\n return false;\r\n }\r\n\r\n // At least 2 of the security questions should be answered\r\n var count = 0;\r\n\r\n if (shareholder.PhoneNumber) {\r\n count++;\r\n }\r\n\r\n if (shareholder.StreetAddress.PostCode) {\r\n count++;\r\n }\r\n\r\n if (shareholder.DateOfBirth) {\r\n count++;\r\n }\r\n\r\n if (count >= 2) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n openSendToBorrower(shareholder: CaseMemberDTO, shareContext: number) {\r\n this.shareContext = shareContext;\r\n this.shareSuplId = shareholder.Id;\r\n if (this.selectedUser.UserName !== this.case.DevelopmentInput.OwnerUser) {\r\n this.userFirstName = \"\";\r\n } else {\r\n this.userFirstName = this.selectedUser.FirstName;\r\n }\r\n\r\n var message =\r\n `Please take a look and complete the information for ` +\r\n shareholder.FirstName +\r\n `\\n\\nIf you need my help or want me to complete this information with you on a call, then please contact me as soon as possible.`;\r\n\r\n this.shareNote = message;\r\n\r\n this.shareEmail = shareholder.Email;\r\n this.shareFirstName = shareholder.FirstName;\r\n this.shareSurname = shareholder.Surname;\r\n\r\n //if (this.$cookies.get('access_token')) {\r\n // this.userService.getcurentuserrecord().then((result) => {\r\n\r\n // if (this.selectedUser.UserName !== this.case.DevelopmentInput.OwnerUser) {\r\n // this.shareEmail = this.case.DevelopmentInput.OwnerUser;\r\n // this.shareFirstName = \"\";\r\n // this.shareSurname = \"\";\r\n // }\r\n // else {\r\n // this.shareEmail = result.Email;\r\n // this.shareFirstName = result.FirstName;\r\n // this.shareSurname = result.LastName;\r\n // }\r\n // });\r\n //}\r\n\r\n this.showShare = true;\r\n }\r\n\r\n sendToBorrower() {\r\n this.dataLoading = true;\r\n this.$caseService\r\n .sendNoteToBorrower(\r\n this.shareFirstName,\r\n this.shareSurname,\r\n this.shareEmail,\r\n this.shareNote,\r\n this.case.Id,\r\n this.shareContext,\r\n this.shareSuplId,\r\n this.case.DevelopmentExperienceID,\r\n )\r\n .then((success) => {\r\n this.showShare = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n autoFillOwnershipDetails() {\r\n this.selectedObject.HowWillYouOwnNewDevelopment =\r\n OwnNewDevelopmentEnum.UKLimitedCompany;\r\n this.selectedObject.HasTheCompanyOrPensionBeenFormedYet = true;\r\n this.selectedObject.CompanyPensionOrPartnershipName =\r\n \"Globe Results Limited\";\r\n this.selectedObject.CompanyOrPartnershipNumber = \"12322370\";\r\n this.selectedObject.ExcludedLenders = \"Example Lender\";\r\n\r\n this.selectedObject.DevelopmentTrackRecords = [];\r\n\r\n let newDevelopmentTrackRecord = {\r\n DevelopmentTrackRecordNumber: 1,\r\n DevelopmentExperienceId: this.selectedObject.Id,\r\n AreaUnit: 1,\r\n DevelopmentTrackRecordType: null,\r\n StreetAddress: {\r\n AddressLine1: \"\",\r\n AddressLine2: \"\",\r\n AddressLine3: \"\",\r\n AddressLine4: \"\",\r\n PostCode: \"\",\r\n } as PostalAddress,\r\n } as DevelopmentTrackRecordDTO;\r\n\r\n this.selectedObject.DevelopmentTrackRecords.push(newDevelopmentTrackRecord);\r\n\r\n newDevelopmentTrackRecord = {\r\n DevelopmentTrackRecordNumber: 2,\r\n DevelopmentExperienceId: this.selectedObject.Id,\r\n AreaUnit: 1,\r\n DevelopmentTrackRecordType: null,\r\n StreetAddress: {\r\n AddressLine1: \"\",\r\n AddressLine2: \"\",\r\n AddressLine3: \"\",\r\n AddressLine4: \"\",\r\n PostCode: \"\",\r\n } as PostalAddress,\r\n } as DevelopmentTrackRecordDTO;\r\n\r\n this.selectedObject.DevelopmentTrackRecords.push(newDevelopmentTrackRecord);\r\n this.selectedObject.DevelopmentTrackRecords[0].OwnerOrEmployee =\r\n OwnerOrEmployeeEnum.Owner;\r\n this.selectedObject.DevelopmentTrackRecords[0].StreetAddress.AddressLine1 =\r\n \"32 Brookside Road\";\r\n this.selectedObject.DevelopmentTrackRecords[0].StreetAddress.AddressLine2 =\r\n \"Istead Rise\";\r\n this.selectedObject.DevelopmentTrackRecords[0].StreetAddress.AddressLine3 =\r\n \"Gravesend\";\r\n this.selectedObject.DevelopmentTrackRecords[0].StreetAddress.AddressLine4 =\r\n \"Kent\";\r\n this.selectedObject.DevelopmentTrackRecords[0].StreetAddress.PostCode =\r\n \"DA13 9JJ\";\r\n const maxDate = Date.now();\r\n const timestamp = Math.floor(Math.random() * maxDate);\r\n this.selectedObject.DevelopmentTrackRecords[0].AcquistionDate = new Date(\r\n timestamp,\r\n );\r\n this.selectedObject.DevelopmentTrackRecords[0].AcquistionCosts =\r\n this.getRandomIntInclusive(1000, 3000);\r\n this.selectedObject.DevelopmentTrackRecords[0].DidYouUseDevelopmentFinance =\r\n true;\r\n this.selectedObject.DevelopmentTrackRecords[0].DevelopmentFinanceLenderName =\r\n \"Masthaven\";\r\n this.selectedObject.DevelopmentTrackRecords[0].DevelopmentAreas =\r\n this.getRandomIntInclusive(2000, 3000).toString();\r\n this.selectedObject.DevelopmentTrackRecords[0].BuildCosts =\r\n this.getRandomIntInclusive(1000000, 2000000);\r\n this.selectedObject.DevelopmentTrackRecords[0].BuildTime =\r\n this.getRandomIntInclusive(5, 12);\r\n this.selectedObject.DevelopmentTrackRecords[0].GDV =\r\n this.getRandomIntInclusive(10000000, 20000000);\r\n this.selectedObject.DevelopmentTrackRecords[0].DescriptionOfWorks =\r\n \"Knock down and rebuild of main residence\";\r\n\r\n this.selectedObject.DevelopmentTrackRecords[1].OwnerOrEmployee =\r\n OwnerOrEmployeeEnum.Owner;\r\n this.selectedObject.DevelopmentTrackRecords[1].StreetAddress.AddressLine1 =\r\n \"7 Soho Square\";\r\n this.selectedObject.DevelopmentTrackRecords[1].StreetAddress.AddressLine2 =\r\n \"\";\r\n this.selectedObject.DevelopmentTrackRecords[1].StreetAddress.AddressLine3 =\r\n \"London\";\r\n this.selectedObject.DevelopmentTrackRecords[1].StreetAddress.AddressLine4 =\r\n \"\";\r\n this.selectedObject.DevelopmentTrackRecords[1].StreetAddress.PostCode =\r\n \"W1D 3QB\";\r\n this.selectedObject.DevelopmentTrackRecords[1].AcquistionDate = new Date(\r\n timestamp,\r\n );\r\n this.selectedObject.DevelopmentTrackRecords[1].AcquistionCosts =\r\n this.getRandomIntInclusive(1000, 3000);\r\n this.selectedObject.DevelopmentTrackRecords[1].DidYouUseDevelopmentFinance =\r\n true;\r\n this.selectedObject.DevelopmentTrackRecords[1].DevelopmentFinanceLenderName =\r\n \"Masthaven\";\r\n (this.selectedObject.DevelopmentTrackRecords[1].AreaUnit =\r\n AreaUnitEnum.SquareMeters),\r\n (this.selectedObject.DevelopmentTrackRecords[1].DevelopmentAreas =\r\n this.getRandomIntInclusive(2000, 3000).toString());\r\n this.selectedObject.DevelopmentTrackRecords[1].BuildCosts =\r\n this.getRandomIntInclusive(1000000, 2000000);\r\n this.selectedObject.DevelopmentTrackRecords[1].BuildTime =\r\n this.getRandomIntInclusive(12, 24);\r\n this.selectedObject.DevelopmentTrackRecords[1].GDV =\r\n this.getRandomIntInclusive(10000000, 20000000);\r\n this.selectedObject.DevelopmentTrackRecords[1].DescriptionOfWorks =\r\n \"Office to residential conversion on upper floors, and retention of the downstairs commercial - included a basement dig and 2 storey extension\";\r\n }\r\n\r\n getRandomIntInclusive(min, max) {\r\n min = Math.ceil(min);\r\n max = Math.floor(max);\r\n return Math.floor(Math.random() * (max - min + 1) + min);\r\n }\r\n\r\n hasMinSecurityQuestionsBeenAnswered(shareholder: CaseMemberDTO) {\r\n var answers = 0;\r\n\r\n if (shareholder.DateOfBirth) {\r\n answers++;\r\n }\r\n\r\n if (shareholder.PhoneNumber) {\r\n answers++;\r\n }\r\n\r\n if (shareholder.StreetAddress.PostCode) {\r\n answers++;\r\n }\r\n\r\n if (answers >= 2 || shareholder.IsVerified) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class DevelopmentInputController {\r\n selectedSection: string;\r\n\r\n objects: DevelopmentInputDTO[];\r\n selectedObject: DevelopmentInputDTO = {} as DevelopmentInputDTO;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n userRecords: ApplicationUserDTO[];\r\n\r\n DevelopmentInputForm: ng.IFormController;\r\n //subDevelopmentInputForm: ng.IFormController;\r\n\r\n static $inject = [\"$routeParams\", \"DevelopmentInputService\", \"UserService\"];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $DevelopmentInputservice: DevelopmentInputService,\r\n private $applicationuserservice: UserService,\r\n ) {\r\n //Is search related to a saved search?\r\n\r\n if (this.$routeParams.searchId) {\r\n this.$DevelopmentInputservice\r\n .fetch(parseInt(this.$routeParams.searchId))\r\n .then((object) => {\r\n this.selectedObject = object;\r\n });\r\n } else {\r\n //Unsaved search. Use $rootScope\r\n }\r\n }\r\n\r\n save() {\r\n this.$DevelopmentInputservice\r\n .addUpdatereturnonlyid(this.selectedObject)\r\n .then((response) => {\r\n this.selectedObject.Id = response;\r\n if (!this.objects) {\r\n this.objects = [];\r\n }\r\n\r\n let matches: DevelopmentInputDTO[] = this.objects.filter(\r\n (value, index) => {\r\n return value.Id == response;\r\n },\r\n );\r\n\r\n if (!matches || matches.length === 0) {\r\n this.objects.push(this.selectedObject);\r\n }\r\n\r\n this.DevelopmentInputForm.$setPristine();\r\n });\r\n }\r\n\r\n delete() {\r\n this.$DevelopmentInputservice\r\n .delete(this.selectedObject.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.DevelopmentInputForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n });\r\n }\r\n}\r\n","export const enum ScheduleTypeEnum {\r\n House = 0,\r\n Flat = 1,\r\n Parking = 2,\r\n Commercial = 3,\r\n Communal = 4,\r\n}\r\n","import { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { DevelopmentInputScheduleDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputScheduleDTO.cs.d\";\r\nimport { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { ScheduleTypeEnum } from \"@js/models/enum/ScheduleTypeEnum.cs.d\";\r\nimport { TenureEnum } from \"@js/models/enum/TenureEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DevelopmentInputScheduleService } from \"@js/services/DevelopmentInputScheduleService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class DevelopmentInputScheduleController {\r\n isLoggedInUser: boolean = false;\r\n dataLoading: boolean = false;\r\n\r\n saving: boolean = false;\r\n saved: boolean = false;\r\n error: boolean = false;\r\n selectedSection: string;\r\n developmentInput: DevelopmentInputDTO;\r\n developmentInputid: number;\r\n objects: DevelopmentInputScheduleDTO[]; // This is a full list of houses, flats, commercial units and parking spaces in the dev schedule\r\n objectsMarkedForDeletion: DevelopmentInputScheduleDTO[];\r\n houses: DevelopmentInputScheduleDTO[];\r\n flats: DevelopmentInputScheduleDTO[];\r\n communalAreas: DevelopmentInputScheduleDTO[];\r\n commercialUnits: DevelopmentInputScheduleDTO[];\r\n parkingSpaces: DevelopmentInputScheduleDTO[];\r\n selectedObject: DevelopmentInputScheduleDTO;\r\n OverallGDVLocal: number;\r\n OverallSQft: number = 0;\r\n sqlUnmatch: boolean = false;\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n fileUpload: FileAttachmentDTO[];\r\n uploadingFiles: FileUploadProgressDTO[];\r\n case: CaseDTO;\r\n file: FileAttachmentDTO;\r\n caseTitle: string;\r\n thisModuleSection: ModuleEnum = ModuleEnum.DevelopmentSchedule;\r\n openModal: boolean = false;\r\n seeFiles: boolean = false;\r\n seeInfo: boolean = false;\r\n\r\n showInformationMessage: boolean = false;\r\n messageContent: string;\r\n savingInProgress: boolean = false;\r\n showAutofill: boolean = false;\r\n\r\n GDVmismatch: boolean = false;\r\n OverallFlats: number = 0;\r\n OverallHouses: number = 0;\r\n OverallCommercial: number = 0;\r\n OverallCommunal: number = 0;\r\n\r\n parkingSoldSeparately: boolean;\r\n\r\n currentCaseNumber: number;\r\n\r\n developmentScheduleForm: ng.IFormController;\r\n\r\n //addingSubobject: boolean;\r\n\r\n //subobjects: SubobjectDTO[];\r\n //selectedSubobject: SubobjectDTO;\r\n\r\n //fetchingSubobjects: boolean;\r\n //fetchingSubobject: boolean;\r\n\r\n DevelopmentInputscheduleForm: ng.IFormController;\r\n DevelopmentScheduleFormUnitsDetailForm: ng.IFormController;\r\n //subDevelopmentInputscheduleForm: ng.IFormController;\r\n\r\n previousHouseNumber: number = 0;\r\n previousFlatNumber: number = 0;\r\n previousCommunalNumber: number = 0;\r\n previousParkingNumber: number = 0;\r\n previousCommercialNumber: number = 0;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$rootScope\",\r\n \"DevelopmentInputScheduleService\",\r\n \"DevelopmentInputService\",\r\n \"$location\",\r\n \"$q\",\r\n \"CaseService\",\r\n \"FileAttachmentService\",\r\n \"RoleService\",\r\n \"$window\",\r\n \"$cookies\",\r\n \"AuthService\",\r\n \"UserService\",\r\n\r\n //'SubobjectService',\r\n ];\r\n //private $subobjectservice: App.Services.SubobjectService\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $DevelopmentInputscheduleservice: DevelopmentInputScheduleService,\r\n private $DevelopmentInputService: DevelopmentInputService,\r\n private $location: ng.ILocationService,\r\n protected $q: ng.IQService,\r\n private $caseService: CaseService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private roleService: RoleService,\r\n private $window: ng.IWindowService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private authService: AuthService,\r\n private userService: UserService,\r\n ) {\r\n if ($cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n\r\n this.userService.getUserAutofill().then((response) => {\r\n this.showAutofill = response;\r\n });\r\n }\r\n\r\n this.objects = [{} as DevelopmentInputScheduleDTO];\r\n\r\n if (this.$routeParams.CaseId) {\r\n this.currentCaseNumber = this.$routeParams.CaseId;\r\n }\r\n\r\n this.$caseService.fetch(this.$routeParams.CaseId).then((response) => {\r\n if (response == null) {\r\n if (this.isLoggedInUser) {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n } else {\r\n this.case = response;\r\n this.fileUpload = response.Attachments;\r\n this.caseTitle = response.DevelopmentInput.SearchName;\r\n this.calculateFilesForThisModule();\r\n }\r\n });\r\n\r\n if (\r\n this.$routeParams.DevelopmentId &&\r\n this.$routeParams.DevelopmentId != \"null\"\r\n ) {\r\n this.developmentInputid = this.$routeParams.DevelopmentId;\r\n this.$DevelopmentInputService\r\n .fetch(this.developmentInputid)\r\n .then((response) => {\r\n if (response == null) {\r\n if (this.isLoggedInUser) {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n } else {\r\n this.developmentInput = response;\r\n\r\n this.updateObjects();\r\n\r\n if (this.developmentInput) {\r\n this.CalcAll();\r\n }\r\n }\r\n });\r\n }\r\n }\r\n formChanged(): void {\r\n (this.$rootScope as any).formSaved = false;\r\n }\r\n //ReduceOrInceaseRecordsOfType(rectype:ScheduleTypeEnum) {\r\n\r\n //}\r\n\r\n //SingleUnitChanged() {\r\n // this.developmentInput.HowManyUnits = 1;\r\n // this.developmentInput.HowManyHouses = 0;\r\n // this.developmentInput.HowManyParkingSpaces = 0;\r\n // this.developmentInput.HowManyFlats = 0;\r\n\r\n //}\r\n setAllFormsPristine(): void {\r\n if (this.developmentScheduleForm) {\r\n this.developmentScheduleForm.$setPristine();\r\n }\r\n if (this.DevelopmentScheduleFormUnitsDetailForm) {\r\n this.DevelopmentScheduleFormUnitsDetailForm.$setPristine();\r\n }\r\n }\r\n\r\n NumberCommercialChanged() {\r\n if (this.developmentInput.HowManyUnits == undefined) {\r\n this.developmentInput.HowManyUnits = 0;\r\n }\r\n\r\n (this.developmentInput.HowManyUnits ||\r\n this.developmentInput.HowManyUnits == 0) &&\r\n this.NumberChanged(\r\n ScheduleTypeEnum.Commercial,\r\n this.developmentInput.HowManyUnits,\r\n );\r\n\r\n this.commercialUnits.length = this.developmentInput.HowManyUnits;\r\n\r\n this.CalcGDVCorporateUnitsSpaces();\r\n this.previousCommercialNumber = this.developmentInput.HowManyUnits;\r\n }\r\n\r\n NumberHousesChanged() {\r\n if (this.developmentInput.HowManyHouses == undefined) {\r\n this.developmentInput.HowManyHouses = 0;\r\n }\r\n\r\n (this.developmentInput.HowManyHouses ||\r\n this.developmentInput.HowManyHouses == 0) &&\r\n this.NumberChanged(\r\n ScheduleTypeEnum.House,\r\n this.developmentInput.HowManyHouses,\r\n );\r\n\r\n this.houses.length = this.developmentInput.HowManyHouses;\r\n\r\n this.CalcGDVHouses();\r\n this.previousHouseNumber = this.developmentInput.HowManyHouses;\r\n }\r\n\r\n NumberFlatsChanged() {\r\n if (this.developmentInput.HowManyFlats == undefined) {\r\n this.developmentInput.HowManyFlats = 0;\r\n }\r\n\r\n (this.developmentInput.HowManyFlats ||\r\n this.developmentInput.HowManyFlats == 0) &&\r\n this.NumberChanged(\r\n ScheduleTypeEnum.Flat,\r\n this.developmentInput.HowManyFlats,\r\n );\r\n\r\n this.flats.length = this.developmentInput.HowManyFlats;\r\n this.CalcGDVFlats();\r\n\r\n this.previousFlatNumber = this.developmentInput.HowManyFlats;\r\n }\r\n\r\n NumberCommunalAreas() {\r\n if (this.developmentInput.HowManyCommunalAreas === undefined) {\r\n this.developmentInput.HowManyCommunalAreas = 0;\r\n }\r\n\r\n (this.developmentInput.HowManyCommunalAreas ||\r\n this.developmentInput.HowManyCommunalAreas == 0) &&\r\n this.NumberChanged(\r\n ScheduleTypeEnum.Communal,\r\n this.developmentInput.HowManyCommunalAreas,\r\n );\r\n\r\n this.communalAreas.length = this.developmentInput.HowManyCommunalAreas;\r\n }\r\n\r\n SetParkingSpacesToZero() {\r\n if (this.developmentInput.ParkingSoldSeparately === true) {\r\n this.NumberChanged(ScheduleTypeEnum.Parking, 0);\r\n this.CalcGDVParkingSpaces();\r\n }\r\n }\r\n\r\n NumberParkingSpacesChanged() {\r\n if (this.developmentInput.HowManyParkingSpaces == undefined) {\r\n this.developmentInput.HowManyParkingSpaces = 0;\r\n }\r\n\r\n (this.developmentInput.HowManyParkingSpaces ||\r\n this.developmentInput.HowManyParkingSpaces == 0) &&\r\n this.NumberChanged(\r\n ScheduleTypeEnum.Parking,\r\n this.developmentInput.HowManyParkingSpaces,\r\n );\r\n\r\n this.parkingSpaces.length = this.developmentInput.HowManyParkingSpaces;\r\n\r\n this.CalcGDVParkingSpaces();\r\n\r\n this.previousParkingNumber = this.developmentInput.HowManyParkingSpaces;\r\n }\r\n CalcTotalForListOfSalesPrices(\r\n salesprices: DevelopmentInputScheduleDTO[],\r\n ): number {\r\n var total: number = 0;\r\n salesprices.forEach((x) => {\r\n if (x.SalesPrice && x.SalesPrice > 0) {\r\n total = total + Number(x.SalesPrice);\r\n }\r\n });\r\n return total;\r\n }\r\n CalcTotalForListOfSalesPricesMultQuanity(\r\n salesprices: DevelopmentInputScheduleDTO[],\r\n ): number {\r\n var total: number = 0;\r\n salesprices.forEach((x) => {\r\n if (\r\n x.SalesPrice &&\r\n x.SalesPrice > 0 &&\r\n x.NumberOfUnits &&\r\n x.NumberOfUnits > 0\r\n ) {\r\n total = total + Number(x.SalesPrice) * x.NumberOfUnits;\r\n }\r\n });\r\n return total;\r\n }\r\n CalcGDVHouses() {\r\n this.developmentInput.Houses_GDV = this.CalcTotalForListOfSalesPrices(\r\n this.houses,\r\n );\r\n this.CalcOverallTotal();\r\n }\r\n CalcGDVFlats() {\r\n this.developmentInput.Flats_GDV = this.CalcTotalForListOfSalesPrices(\r\n this.flats,\r\n );\r\n this.CalcOverallTotal();\r\n }\r\n CalcGDVParkingSpaces() {\r\n this.developmentInput.Parking_GDV =\r\n this.CalcTotalForListOfSalesPricesMultQuanity(this.parkingSpaces);\r\n this.CalcOverallTotal();\r\n }\r\n CalcGDVCorporateUnitsSpaces() {\r\n this.developmentInput.Commercial_GDV = this.CalcTotalForListOfSalesPrices(\r\n this.commercialUnits,\r\n );\r\n this.CalcOverallTotal();\r\n }\r\n CalcOverallTotal() {\r\n this.OverallGDVLocal = 0;\r\n\r\n if (\r\n this.developmentInput.CI_EndPropType == 1 ||\r\n this.developmentInput.CI_EndPropType == 2\r\n ) {\r\n this.OverallGDVLocal +=\r\n this.developmentInput.Houses_GDV +\r\n this.developmentInput.Flats_GDV +\r\n this.developmentInput.Parking_GDV;\r\n }\r\n\r\n if (this.developmentInput.CI_EndPropType != 1) {\r\n this.OverallGDVLocal += this.developmentInput.Commercial_GDV;\r\n }\r\n\r\n if (\r\n this.OverallGDVLocal > 0 &&\r\n this.OverallGDVLocal !== this.developmentInput.CI_GDV\r\n ) {\r\n this.GDVmismatch = true;\r\n } else {\r\n this.GDVmismatch = false;\r\n }\r\n }\r\n\r\n CalcOverallSQft() {\r\n this.OverallSQft = 0;\r\n this.OverallHouses = 0;\r\n this.OverallFlats = 0;\r\n this.OverallCommercial = 0;\r\n this.OverallCommunal = 0;\r\n\r\n if (this.houses && this.houses.length > 0) {\r\n var tempHouseArray = this.houses.filter((house) => house.Area > 0);\r\n\r\n tempHouseArray.forEach(\r\n (i) => (i.AreaUnit = this.developmentInput.DI_AreaUnit),\r\n );\r\n\r\n if (tempHouseArray && tempHouseArray.length > 0) {\r\n this.OverallHouses = tempHouseArray\r\n .map((i) => i.Area)\r\n .reduce((a, b) => a + b);\r\n }\r\n }\r\n\r\n if (this.flats && this.flats.length > 0) {\r\n var tempFlatArray = this.flats.filter((flat) => flat.Area > 0);\r\n\r\n tempFlatArray.forEach(\r\n (i) => (i.AreaUnit = this.developmentInput.DI_AreaUnit),\r\n );\r\n\r\n if (tempFlatArray && tempFlatArray.length > 0) {\r\n this.OverallFlats = tempFlatArray\r\n .map((i) => i.Area)\r\n .reduce((a, b) => a + b);\r\n }\r\n }\r\n\r\n if (this.commercialUnits && this.commercialUnits.length > 0) {\r\n var tempCMUArray = this.commercialUnits.filter(\r\n (commercialUnit) => commercialUnit.Area > 0,\r\n );\r\n tempCMUArray.forEach(\r\n (i) => (i.AreaUnit = this.developmentInput.DI_AreaUnit),\r\n );\r\n\r\n if (tempCMUArray && tempCMUArray.length > 0) {\r\n this.OverallCommercial = tempCMUArray\r\n .map((i) => i.Area)\r\n .reduce((a, b) => a + b);\r\n }\r\n }\r\n\r\n if (this.communalAreas && this.communalAreas.length > 0) {\r\n this.communalAreas = this.checkIfAreaisNull(this.communalAreas);\r\n this.communalAreas = this.checkIfDescriptionIsNull(this.communalAreas);\r\n var tempCAArray = this.communalAreas.filter(\r\n (communalArea) => communalArea.Area > 0,\r\n );\r\n\r\n tempCAArray.forEach(\r\n (i) => (i.AreaUnit = this.developmentInput.DI_AreaUnit),\r\n );\r\n\r\n if (tempCAArray && tempCAArray.length > 0) {\r\n this.OverallCommunal = tempCAArray\r\n .map((i) => i.Area)\r\n .reduce((a, b) => a + b);\r\n }\r\n }\r\n\r\n if (\r\n this.developmentInput.CI_EndPropType == 1 ||\r\n this.developmentInput.CI_EndPropType == 2\r\n ) {\r\n this.OverallSQft +=\r\n this.OverallHouses + this.OverallFlats + this.OverallCommunal;\r\n }\r\n\r\n if (this.developmentInput.CI_EndPropType != 1) {\r\n this.OverallSQft += this.OverallCommercial;\r\n }\r\n\r\n if (\r\n this.OverallSQft !== this.developmentInput.DI_AreaSalesAreaResidential\r\n ) {\r\n this.sqlUnmatch = true;\r\n } else {\r\n this.sqlUnmatch = false;\r\n }\r\n }\r\n\r\n checkIfAreaisNull(overallBuild: DevelopmentInputScheduleDTO[]) {\r\n return overallBuild.map((i) => {\r\n if (i.Area === undefined || i.Area === null) {\r\n i.Area = 0;\r\n } else {\r\n i.Area;\r\n }\r\n return i;\r\n });\r\n }\r\n\r\n checkIfDescriptionIsNull(overallBuild: DevelopmentInputScheduleDTO[]) {\r\n return overallBuild.map((i) => {\r\n if (i.Description === undefined || i.Description === null) {\r\n i.Description = \"Communal Areas\";\r\n }\r\n return i;\r\n });\r\n }\r\n\r\n CalcAll() {\r\n if (this.developmentInput && this.objects && this.objects.length > 0) {\r\n this.developmentInput.Houses_GDV =\r\n this.houses && this.houses.length > 0\r\n ? this.CalcTotalForListOfSalesPrices(this.houses)\r\n : null;\r\n this.developmentInput.Parking_GDV =\r\n this.parkingSpaces && this.parkingSpaces.length > 0\r\n ? this.CalcTotalForListOfSalesPricesMultQuanity(this.parkingSpaces)\r\n : null;\r\n this.developmentInput.Flats_GDV =\r\n this.flats && this.flats.length > 0\r\n ? this.CalcTotalForListOfSalesPrices(this.flats)\r\n : null;\r\n this.developmentInput.Commercial_GDV =\r\n this.commercialUnits && this.commercialUnits.length > 0\r\n ? this.CalcTotalForListOfSalesPrices(this.commercialUnits)\r\n : null;\r\n this.CalcOverallTotal();\r\n this.CalcOverallSQft();\r\n }\r\n }\r\n FilterMainObjects(recType: ScheduleTypeEnum): DevelopmentInputScheduleDTO[] {\r\n if (this.objects) {\r\n return this.objects\r\n .filter((x) => x.ScheduleType == recType)\r\n .sort(function (a, b) {\r\n return a.OrderId < b.OrderId ? -1 : 1;\r\n });\r\n }\r\n return null;\r\n }\r\n NumberChanged(recType: ScheduleTypeEnum, numberCurrently: number) {\r\n var currentObjects: DevelopmentInputScheduleDTO[];\r\n\r\n // by using = when currentObjects changes the original array will also change as it is \"copied\" by reference\r\n switch (recType) {\r\n case ScheduleTypeEnum.Commercial:\r\n currentObjects = this.commercialUnits;\r\n break;\r\n case ScheduleTypeEnum.Flat:\r\n currentObjects = this.flats;\r\n break;\r\n case ScheduleTypeEnum.House:\r\n currentObjects = this.houses;\r\n break;\r\n case ScheduleTypeEnum.Parking:\r\n currentObjects = this.parkingSpaces;\r\n break;\r\n case ScheduleTypeEnum.Communal:\r\n currentObjects = this.communalAreas;\r\n break;\r\n }\r\n\r\n //get back list related to corporate units\r\n var difference: number = numberCurrently - currentObjects.length;\r\n if (difference < 0) {\r\n difference = Math.abs(difference);\r\n //remove the latter ones\r\n\r\n for (\r\n var i = currentObjects.length - difference;\r\n i < currentObjects.length;\r\n i++\r\n ) {\r\n if (!this.objectsMarkedForDeletion) {\r\n this.objectsMarkedForDeletion = [];\r\n }\r\n this.objectsMarkedForDeletion.push(currentObjects[i]);\r\n }\r\n } else if (difference > 0) {\r\n //add new ones\r\n for (var i = 0; i < difference; i++) {\r\n var singlerec: DevelopmentInputScheduleDTO =\r\n {} as DevelopmentInputScheduleDTO;\r\n singlerec.ScheduleType = recType;\r\n singlerec.DevelopmentInputId = this.developmentInput.Id;\r\n singlerec.SalesPrice = 0;\r\n\r\n if (recType === 0) {\r\n singlerec.Tenure = TenureEnum.Freehold;\r\n }\r\n if (recType === 1) {\r\n singlerec.Tenure = TenureEnum.Leasehold;\r\n }\r\n\r\n currentObjects.push(singlerec);\r\n }\r\n }\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n\r\n // Fetch all objects.\r\n this.$DevelopmentInputscheduleservice\r\n .fetchByCaseId(this.developmentInputid)\r\n .then((response) => {\r\n this.objects = response;\r\n\r\n this.objects.forEach((o) => {\r\n o.Area != 0 ? o.Area : (o.Area = null);\r\n });\r\n\r\n this.populatePropertyArrays();\r\n\r\n this.CalcAll();\r\n this.preSelectedItem();\r\n\r\n this.NumberCommercialChanged();\r\n this.NumberCommunalAreas();\r\n this.NumberFlatsChanged();\r\n this.NumberHousesChanged();\r\n this.NumberParkingSpacesChanged();\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n });\r\n }\r\n\r\n private preSelectedItem() {\r\n if (this.$routeParams.Id) {\r\n let selectedObject = this.objects.find((value, index) => {\r\n return value.Id === parseInt(this.$routeParams.objectId);\r\n });\r\n\r\n this.selectObject(selectedObject);\r\n }\r\n }\r\n\r\n selectObject(object: DevelopmentInputScheduleDTO) {\r\n this.selectedObject = object;\r\n\r\n //this.fetchingSubobjects = true;\r\n //this.$subobjectservice.fetchSubobjectsForObject(object.Id).then((response) => {\r\n // this.subobjects = response;\r\n // this.fetchingSubobjects = false;\r\n //}).catch((response) => {\r\n // this.fetchingSubobjects = false;\r\n //});\r\n\r\n this.selectedSection = \"details\";\r\n }\r\n\r\n createObject() {\r\n this.selectedSection = \"details\";\r\n this.selectedObject = {} as DevelopmentInputScheduleDTO;\r\n }\r\n\r\n save(): ng.IPromise {\r\n this.saving = true;\r\n let defer = this.$q.defer();\r\n\r\n // Concatenate the separate arrays back into the main objects array for saving\r\n this.objects = this.houses.concat(\r\n this.flats,\r\n this.commercialUnits,\r\n this.parkingSpaces,\r\n this.communalAreas,\r\n );\r\n\r\n this.objects.forEach((o) => {\r\n o.SalesPrice > -1 ? o.SalesPrice : (o.SalesPrice = 0);\r\n });\r\n\r\n this.objects.forEach((o) => {\r\n o.Area > 0 ? o.Area : (o.Area = 0);\r\n });\r\n\r\n this.$DevelopmentInputscheduleservice\r\n .addUpdatelistreturnonlyids(this.objects)\r\n .then((response) => {\r\n this.objects.forEach((o) => {\r\n o.Area != 0 ? o.Area : (o.Area = null);\r\n });\r\n //set ids to those of response\r\n this.objects.forEach((o, i) => (o.Id = response[i]));\r\n // re-populate the individual arrays with the new data\r\n this.populatePropertyArrays();\r\n\r\n this.$DevelopmentInputService\r\n .addUpdatereturnonlyid(this.developmentInput)\r\n .then((devInputResponse) => {\r\n this.developmentInput.Id = devInputResponse;\r\n this.CalcAll();\r\n this.setAllFormsPristine();\r\n this.saved = true;\r\n defer.resolve(response as number[]);\r\n //TODO: add to architecture delete all\r\n if (this.objectsMarkedForDeletion) {\r\n for (var i = 0; i < this.objectsMarkedForDeletion.length; i++) {\r\n if (this.objectsMarkedForDeletion[i].Id) {\r\n this.$DevelopmentInputscheduleservice.delete(\r\n this.objectsMarkedForDeletion[i].Id,\r\n );\r\n }\r\n }\r\n this.objectsMarkedForDeletion = [];\r\n }\r\n\r\n return response;\r\n });\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n this.error = true;\r\n })\r\n .finally(() => {\r\n this.saving = false;\r\n });\r\n return defer.promise;\r\n }\r\n\r\n delete() {\r\n this.$DevelopmentInputscheduleservice\r\n .delete(this.selectedObject.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.DevelopmentInputscheduleForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n });\r\n }\r\n\r\n cancel(): void {\r\n this.$location.path(\"/casedashboard/\" + this.currentCaseNumber);\r\n }\r\n\r\n saveChanges(): void {\r\n this.dataLoading = true;\r\n this.save()\r\n .then((response) => {\r\n (this.$rootScope as any).formSaved = true;\r\n this.DevelopmentScheduleFormUnitsDetailForm.$setPristine();\r\n this.developmentScheduleForm.$setPristine();\r\n this.messageContent = \"Your changes have been saved.\";\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while saving. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.showInformationMessage = true;\r\n });\r\n }\r\n\r\n goToCaseDashboard(saveChanges: boolean): void {\r\n if (saveChanges && this.roleService.IsLender != true) {\r\n this.save().then((response) => {\r\n (this.$rootScope as any).formSaved = true;\r\n });\r\n }\r\n this.$location.path(\"/casedashboard/\" + this.currentCaseNumber);\r\n }\r\n\r\n closeModal(): void {\r\n this.showInformationMessage = false;\r\n this.$location.path(\"/casedashboard/\" + this.currentCaseNumber);\r\n }\r\n\r\n updateGIA() {\r\n this.developmentInput.DI_AreaSalesAreaResidential = this.OverallSQft;\r\n this.$DevelopmentInputService\r\n .addUpdatereturnonlyid(this.developmentInput)\r\n .then((devInputResponse) => {\r\n this.developmentInput.Id = devInputResponse;\r\n this.developmentInput.DI_AreaSalesAreaResidential = this.OverallSQft;\r\n this.CalcAll();\r\n this.setAllFormsPristine();\r\n this.saved = true;\r\n return devInputResponse;\r\n });\r\n this.CalcOverallSQft();\r\n }\r\n\r\n updateGDV() {\r\n this.developmentInput.CI_GDV = this.OverallGDVLocal;\r\n this.$DevelopmentInputService\r\n .addUpdatereturnonlyid(this.developmentInput)\r\n .then((devInputResponse) => {\r\n this.developmentInput.Id = devInputResponse;\r\n this.developmentInput.CI_GDV = this.OverallGDVLocal;\r\n this.CalcAll();\r\n this.setAllFormsPristine();\r\n this.saved = true;\r\n return devInputResponse;\r\n });\r\n }\r\n\r\n //File upload\r\n\r\n calculateTotalFiles(filter: number) {\r\n if (this.fileUpload) {\r\n return this.fileUpload.length;\r\n }\r\n }\r\n\r\n calculateFilesForThisModule() {\r\n this.fileUpload = this.fileUpload.filter(\r\n (file) => file.Module === this.thisModuleSection,\r\n );\r\n if (this.fileUpload.length <= 0) {\r\n this.seeInfo = true;\r\n } else {\r\n this.seeInfo = false;\r\n }\r\n }\r\n\r\n onFileSelect(files: FileAttachmentDTO[], module?: ModuleEnum) {\r\n if (files.length > 0) {\r\n //if case has no id it must be saved first\r\n if (this.case.Id < 1) {\r\n this.$caseService\r\n .addUpdate(this.case)\r\n .then((response) => {\r\n this.case = response;\r\n this.onFileSelect(files); //call itself and then exit as should now be saved so should be able to run\r\n return;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.calculateFilesForThisModule();\r\n this.openModal = false;\r\n });\r\n return;\r\n }\r\n\r\n this.fileAttachmentService\r\n .UploadFileLstInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.case.Id,\r\n this.fileUpload,\r\n module,\r\n )\r\n .then((result) => {\r\n this.calculateFilesForThisModule();\r\n this.openModal = false;\r\n });\r\n }\r\n }\r\n\r\n downloadFile(file: FileAttachmentDTO) {\r\n this.fileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n this.$window.open(uri);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n deleteFile(file: FileAttachmentDTO) {\r\n this.fileUpload.splice(this.fileUpload.indexOf(file), 1);\r\n this.fileAttachmentService.markasdeleted(file.Id).then((result) => {\r\n this.calculateFilesForThisModule();\r\n });\r\n }\r\n\r\n uploadYourOwnClicked() {\r\n event.preventDefault(); // prevents default behaviour of href\r\n this.openModal = true;\r\n }\r\n\r\n setAreaVal(area) {\r\n if (area === undefined || area === null) {\r\n return 0;\r\n } else {\r\n return area;\r\n }\r\n }\r\n\r\n populatePropertyArrays() {\r\n // First clear them:\r\n this.houses = [];\r\n this.flats = [];\r\n this.communalAreas = [];\r\n this.commercialUnits = [];\r\n this.parkingSpaces = [];\r\n\r\n // Then populate them from the main objects array\r\n this.houses = this.FilterMainObjects(ScheduleTypeEnum.House);\r\n this.flats = this.FilterMainObjects(ScheduleTypeEnum.Flat);\r\n this.communalAreas = this.FilterMainObjects(ScheduleTypeEnum.Communal);\r\n this.commercialUnits = this.FilterMainObjects(ScheduleTypeEnum.Commercial);\r\n this.parkingSpaces = this.FilterMainObjects(ScheduleTypeEnum.Parking);\r\n }\r\n\r\n //addSubobject() {\r\n // this.selectedSubobject = {\r\n // AssociatedObjectId: this.selectedObject.Id,\r\n // AssociatedObjectName: this.selectedObject.Name\r\n // } as SubobjectDTO;\r\n //}\r\n\r\n //removeSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.deleteSubobject(subobject.Id).then((response) => {\r\n // this.subobjects.splice(this.subobjects.indexOf(this.selectedSubobject), 1);\r\n // delete this.selectedSubobject;\r\n // });\r\n //}\r\n\r\n //cancelUpdateSubobject() {\r\n // delete this.selectedSubobject;\r\n //}\r\n\r\n //updateSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.addUpdateSubobject(subobject).then((response) => {\r\n // if (this.subobjects.indexOf(subobject) === -1) {\r\n // this.subobjects.push(subobject);\r\n // }\r\n // delete this.selectedSubobject;\r\n // }).catch((response) => {\r\n // delete this.selectedSubobject;\r\n // });\r\n\r\n //}\r\n\r\n autofillSchedule() {\r\n this.developmentInput.HowManyHouses = 2;\r\n this.houses = [];\r\n var house1 = {\r\n DevelopmentInputId: this.developmentInput.Id,\r\n ScheduleType: ScheduleTypeEnum.House,\r\n LocationIdentifier: \"1\",\r\n Description: \"Detached house\",\r\n NumberOfBeds: 4,\r\n NumberOfBaths: 3,\r\n Tenure: TenureEnum.Freehold,\r\n Area: 1500,\r\n SalesPrice: 1000000,\r\n } as DevelopmentInputScheduleDTO;\r\n\r\n this.houses.push(house1);\r\n\r\n var house2 = {\r\n DevelopmentInputId: this.developmentInput.Id,\r\n ScheduleType: ScheduleTypeEnum.House,\r\n LocationIdentifier: \"2\",\r\n Description: \"Semi-detached house\",\r\n NumberOfBeds: 4,\r\n NumberOfBaths: 3,\r\n Tenure: TenureEnum.Freehold,\r\n Area: 1500,\r\n SalesPrice: 1500000,\r\n } as DevelopmentInputScheduleDTO;\r\n\r\n this.houses.push(house2);\r\n\r\n this.developmentInput.Houses_GDV = 2500000;\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { DevelopmentWithNoLoginDTO } from \"@js/DTO/DevelopmentWithNoLoginDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { OrganisationLinkDTO } from \"@js/DTO/OrgnisationLinkDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { DevelopmentTrackRecordTypeEnum } from \"@js/models/enum/DevelopmentTrackRecordTypeEnum.cs.d\";\r\nimport { ExitStrategyEnum } from \"@js/models/enum/ExitStrategyEnum.cs.d\";\r\nimport { LocationEnum } from \"@js/models/enum/LocationEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { PropertyTypeDetailEnum } from \"@js/models/enum/PropertyTypeDetailEnum.cs.d\";\r\nimport { PropertyTypeEnum } from \"@js/models/enum/PropertyTypeEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { SharedCriteriaService } from \"@js/services/Deal/SharedCriteriaService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { DevelopmentInputWithNoLoginService } from \"@js/services/DevelopmentInputWithNoLoginService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationLinkService } from \"@js/services/OrganisationLinkService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { SharedDataService } from \"@js/services/SharedDataService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class DevelopmentInputScreenController {\r\n loanCriteria: DevelopmentInputDTO;\r\n snapshotLoanCriteria: DevelopmentInputDTO;\r\n step: number = 1;\r\n dateOfOrigPurchMonth: number;\r\n dateOfOrigPurchYear: number;\r\n DevelopmentInputForm: ng.IFormController;\r\n guidanceCheckbox: boolean = true;\r\n buildCostPerArea: number;\r\n searchid: number = null;\r\n caseid: number = null;\r\n existingClassUses: number = 0;\r\n classUses: {} = {};\r\n projectType: {}[] = [];\r\n totalBuild: number = 0;\r\n totalLand: number = 0;\r\n multiPartForm1: ng.IFormController;\r\n multiPartForm2: ng.IFormController;\r\n multiPartForm3: ng.IFormController;\r\n\r\n showVideo: boolean = false;\r\n\r\n //boolean to fetch largest or matcing results\r\n isMaximumLoanRequired: boolean = true;\r\n\r\n tempLoanRequired: number;\r\n\r\n //array describing form sections\r\n formSectionNames = [\r\n {\r\n label: \"Property\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Build Costs\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Borrowing\",\r\n visible: true,\r\n },\r\n ];\r\n\r\n isLoggedInUser: boolean = false;\r\n isLegacyUser: boolean = false;\r\n isAdmin: boolean = false;\r\n isBroker: boolean = false;\r\n isBorrower: boolean = false;\r\n isLender: boolean = false;\r\n brokerOrAdminUser: ApplicationUserDTO;\r\n existingUsers: UserSimpleDTO[];\r\n showShareSearchtoClientModal: boolean = false;\r\n clientFirstName: string;\r\n clientSurname: string;\r\n clientEmail: string;\r\n clientPhoneNumber: string;\r\n clientId: string = null;\r\n showClientDetails: boolean = false;\r\n existingborrower: boolean;\r\n loadingData: boolean = false;\r\n dataLoading: boolean = false;\r\n isResultScreen: boolean = false;\r\n isIntroduceronly: boolean = false;\r\n selectedBorrower: UserSimpleDTO = null;\r\n showAutofill: boolean = false;\r\n\r\n totalLenders: number = 0;\r\n brokerageOrg: OrganisationDTO;\r\n showContactBrokerModal: boolean = false;\r\n showMessageToborrower: boolean = false;\r\n messageToborrower: string = \"\";\r\n user: ApplicationUserDTO;\r\n stepName: string = \"\";\r\n moveContactBrokerBtnInMiddle: boolean = false;\r\n showActionPanel: boolean = false;\r\n userRole: string = \"\";\r\n userDetails: string = null;\r\n projectName: string = null;\r\n applicationName: string = null;\r\n\r\n organisationLink: OrganisationLinkDTO;\r\n orgCode: string = \"\";\r\n noPermissionErrorMsg: string = \"\";\r\n\r\n locationOptions = [];\r\n\r\n //Postcode properties\r\n showPostcodeErrorMessage: boolean = false;\r\n postcodeErrorMsg: string;\r\n previouslySelectedLocation: LocationEnum;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$cookies\",\r\n \"DevelopmentInputService\",\r\n \"$location\",\r\n \"$q\",\r\n \"CaseService\",\r\n \"RoleService\",\r\n \"UserService\",\r\n \"AuthService\",\r\n \"OrganisationService\",\r\n \"DevelopmentInputWithNoLoginService\",\r\n \"LenderService\",\r\n \"SharedDataService\",\r\n \"OrganisationLinkService\",\r\n \"EventLogService\",\r\n \"SelectListService\",\r\n \"SharedCriteriaService\",\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $DevelopmentInputservice: DevelopmentInputService,\r\n private $location: ng.ILocationService,\r\n protected $q: ng.IQService,\r\n private caseService: CaseService,\r\n private roleService: RoleService,\r\n private userService: UserService,\r\n private $auth: AuthService,\r\n private organisationService: OrganisationService,\r\n private $DevelopmentInputWithNoLoginService: DevelopmentInputWithNoLoginService,\r\n private lenderService: LenderService,\r\n private sharedDataService: SharedDataService,\r\n private organisationLinkService: OrganisationLinkService,\r\n private eventLogService: EventLogService,\r\n private selectListService: SelectListService,\r\n private sharedCriteriaService: SharedCriteriaService,\r\n ) {\r\n try {\r\n if (this.$location.path().startsWith(\"/e/criteria\")) {\r\n // for enterprise and unique links we should now use the new dev finance search so have commented out the code below\r\n if (this.$routeParams.linkId) {\r\n this.$location.path(\r\n `/e/devfinancecriteria/0/${this.$routeParams.linkId}`,\r\n );\r\n } else {\r\n this.$location.path(\"/e/devfinancecriteria\");\r\n }\r\n } else if (\r\n this.$location.path().startsWith(\"/criteria\") &&\r\n (!this.$routeParams.SearchId || this.$routeParams.SearchId == 0)\r\n ) {\r\n if (window.self == window.top && $cookies.get(\"access_token\")) {\r\n this.$location.path(\"/devfinancecriteria\");\r\n } else {\r\n this.$location.path(\"/e/devfinancecriteria\");\r\n }\r\n }\r\n\r\n if (window.self == window.top && $cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n\r\n this.userService.getUserAutofill().then((response) => {\r\n this.showAutofill = response;\r\n });\r\n\r\n this.roleService.GetUserRoles().then((result) => {\r\n if (result.filter((x) => x.toLowerCase() == \"admin\").length > 0) {\r\n this.isAdmin = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"broker\").length > 0) {\r\n this.isBroker = true;\r\n //This block is to navigate a broker to userdashboard when they do not have a license.\r\n if (this.isBroker) {\r\n if (sessionStorage.getItem(\"isValidLicense\") == \"false\") {\r\n this.gotoDashboard();\r\n }\r\n }\r\n }\r\n\r\n if (result.filter((x) => x.toLowerCase() == \"client\").length > 0) {\r\n this.sharedDataService.isBorrower = true;\r\n }\r\n\r\n if (\r\n result.filter((x) => x.toLowerCase() == \"lender\").length > 0 &&\r\n !this.isAdmin\r\n ) {\r\n this.isLender = true;\r\n }\r\n\r\n if (\r\n result.filter((x) => x == \"Introducer\").length > 0 &&\r\n result.filter((x) => x == \"Broker\").length == 0 &&\r\n result.filter((x) => x == \"Client\").length == 0 &&\r\n result.filter((x) => x == \"Admin\").length == 0\r\n ) {\r\n this.isIntroduceronly = true;\r\n }\r\n\r\n if (\r\n this.$routeParams.SearchId == 0 &&\r\n this.$routeParams.CaseId == 0 &&\r\n this.step == 1\r\n ) {\r\n if (this.isBroker || this.isAdmin) {\r\n if (sessionStorage.getItem(\"searchuser\")) {\r\n let data = sessionStorage.getItem(\"searchuser\");\r\n let userdetails = JSON.parse(data);\r\n this.clientFirstName = userdetails.clientFirstName;\r\n this.clientSurname = userdetails.clientSurname;\r\n this.clientEmail = userdetails.clientEmail;\r\n this.clientPhoneNumber = userdetails.clientPhoneNumber;\r\n this.clientId = userdetails.clientId;\r\n this.existingborrower = userdetails.existingborrower;\r\n this.loanCriteria.SearchName = userdetails.searchName;\r\n if (this.existingborrower) {\r\n this.showClientDetails = true;\r\n }\r\n } else {\r\n this.loanCriteria.SearchName = this.loanCriteria.SearchName\r\n ? this.loanCriteria.SearchName\r\n : null;\r\n }\r\n\r\n if (\r\n this.$DevelopmentInputservice.getHasValidStatustoShowShareSearchModal()\r\n ) {\r\n if (sessionStorage.getItem(\"skip\")) {\r\n this.showShareSearchtoClientModal = false;\r\n } else {\r\n this.showShareSearchtoClientModal = true;\r\n this.getUsersBelongToBrokerOrAdmin();\r\n }\r\n }\r\n }\r\n if (this.isLender) {\r\n if (sessionStorage.getItem(\"skip\")) {\r\n this.showShareSearchtoClientModal = false;\r\n } else {\r\n this.showShareSearchtoClientModal = true;\r\n }\r\n }\r\n }\r\n\r\n this.userService.getcurentuserrecord().then((result) => {\r\n this.brokerOrAdminUser = result;\r\n this.isLegacyUser = result.IsLegacyUser;\r\n });\r\n });\r\n }\r\n\r\n // If we have an introducer code set, let's store a cookie.\r\n if (this.$routeParams.introducercode) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"introducer_code\", this.$routeParams.introducercode, {\r\n expires: expiryDate,\r\n });\r\n } else if (this.$routeParams[\"ic\"]) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"introducer_code\", this.$routeParams[\"ic\"], {\r\n expires: expiryDate,\r\n });\r\n }\r\n\r\n // If we have an invite code set, let's store a cookie.\r\n if (this.$routeParams.invitecode) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"invite_code\", this.$routeParams.invitecode, {\r\n expires: expiryDate,\r\n });\r\n }\r\n // If we have an org code set, let's store a cookie.\r\n if (this.$routeParams[\"orgc\"]) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"org_code\", this.$routeParams[\"orgc\"], {\r\n expires: expiryDate,\r\n });\r\n }\r\n\r\n if (this.$routeParams.SearchId && this.$routeParams.SearchId > 0) {\r\n if (this.$routeParams.CaseId && this.$routeParams.CaseId > 0) {\r\n this.caseService.fetch(this.$routeParams.CaseId).then((result) => {\r\n if (result.CaseStatus == 0 || result.CaseStatus == 1) {\r\n this.caseService.updateTubeMap(CaseStatusEnum.InProgress);\r\n } else {\r\n this.caseService.updateTubeMap(result.CaseStatus);\r\n }\r\n });\r\n } else {\r\n this.caseService.updateTubeMap(null);\r\n }\r\n } else {\r\n this.caseService.updateTubeMap(CaseStatusEnum.Search);\r\n }\r\n\r\n if (this.$routeParams.SearchId > 0) {\r\n this.searchid = this.$routeParams.SearchId;\r\n } else {\r\n this.searchid = 0;\r\n }\r\n if (this.$routeParams.CaseId > 0) {\r\n this.caseid = this.$routeParams.CaseId;\r\n } else {\r\n this.caseid = 0;\r\n }\r\n if (this.$routeParams.StepNumber) {\r\n this.step =\r\n this.$routeParams.StepNumber > 3 || this.$routeParams.StepNumber < 1\r\n ? 1\r\n : this.$routeParams.StepNumber;\r\n }\r\n\r\n //redirect to full path if full path not given\r\n if (\r\n (!this.$routeParams.SearchId ||\r\n !this.$routeParams.CaseId ||\r\n !this.$routeParams.StepNumber) &&\r\n (this.$routeParams.uniqueId == undefined ||\r\n this.$routeParams.uniqueId == \"null\")\r\n ) {\r\n this.go(\r\n \"/criteria/\" + this.searchid + \"/\" + this.caseid + \"/\" + this.step,\r\n false,\r\n );\r\n }\r\n\r\n this.snapshotLoanCriteria = {\r\n ...(this.$rootScope as any).snapshotLoanCriteria,\r\n };\r\n\r\n // See if we've got an existing search in database.\r\n if (this.searchid > 0) {\r\n this.$DevelopmentInputservice.fetch(this.searchid).then((response) => {\r\n this.loanCriteria = response;\r\n this.tempLoanRequired = response.CI_Dev_LoanReq;\r\n if (response.CI_Dev_LoanReq > 0) {\r\n this.isMaximumLoanRequired = false;\r\n }\r\n if (this.loanCriteria.CI_Dev_DateOfOrigPurch) {\r\n this.dateOfOrigPurchMonth =\r\n this.loanCriteria.CI_Dev_DateOfOrigPurch.getMonth() + 1;\r\n this.dateOfOrigPurchYear =\r\n this.loanCriteria.CI_Dev_DateOfOrigPurch.getFullYear() % 100;\r\n }\r\n this.existingClassUses = this.loanCriteria.DI_Dev_ClassUses;\r\n this.initClassUses();\r\n this.initProjectTypes();\r\n });\r\n } else if (\r\n this.$routeParams.uniqueId !== undefined &&\r\n this.$routeParams.uniqueId != \"null\"\r\n ) {\r\n this.$DevelopmentInputWithNoLoginService\r\n .fetchByUniqueId(this.$routeParams.uniqueId)\r\n .then((results) => {\r\n this.loanCriteria = {} as DevelopmentInputDTO;\r\n (Object).assign(this.loanCriteria, results);\r\n this.tempLoanRequired = this.loanCriteria.CI_Dev_LoanReq;\r\n if (this.loanCriteria.CI_Dev_LoanReq > 0) {\r\n this.isMaximumLoanRequired = false;\r\n }\r\n if (this.loanCriteria.CI_Dev_DateOfOrigPurch) {\r\n this.dateOfOrigPurchMonth =\r\n this.loanCriteria.CI_Dev_DateOfOrigPurch.getMonth() + 1;\r\n this.dateOfOrigPurchYear =\r\n this.loanCriteria.CI_Dev_DateOfOrigPurch.getFullYear() % 100;\r\n }\r\n this.existingClassUses = this.loanCriteria.DI_Dev_ClassUses;\r\n this.initClassUses();\r\n this.initProjectTypes();\r\n });\r\n } else if ((this.$rootScope as any).loanCriteria) {\r\n this.loanCriteria = { ...(this.$rootScope as any).loanCriteria };\r\n this.tempLoanRequired = this.loanCriteria.CI_Dev_LoanReq;\r\n if (this.loanCriteria.CI_Dev_LoanReq > 0) {\r\n this.isMaximumLoanRequired = false;\r\n }\r\n if (this.loanCriteria.CI_Dev_DateOfOrigPurch) {\r\n this.dateOfOrigPurchMonth =\r\n this.loanCriteria.CI_Dev_DateOfOrigPurch.getMonth() + 1;\r\n this.dateOfOrigPurchYear =\r\n this.loanCriteria.CI_Dev_DateOfOrigPurch.getFullYear() % 100;\r\n }\r\n this.existingClassUses = this.loanCriteria.DI_Dev_ClassUses;\r\n this.initClassUses();\r\n this.initProjectTypes();\r\n } else {\r\n this.loanCriteria = {\r\n CI_Dev_Contingency: 0.05,\r\n CI_Dev_DateOfOrigPurch: new Date(),\r\n ShowLenderInfoBrokerOverride: true,\r\n } as DevelopmentInputDTO;\r\n this.loanCriteria.CI_Dev_Locations = LocationEnum.None;\r\n this.loanCriteria.CI_EndPropType = PropertyTypeEnum.None;\r\n this.loanCriteria.CI_Dev_ExitStrategy = ExitStrategyEnum.None;\r\n this.loanCriteria.DI_AreaUnit = 1;\r\n this.loanCriteria.hasPostcode = true;\r\n\r\n // If the current user is a broker then record the broker info on the search record (devleopmentInput)\r\n\r\n if (this.isLoggedInUser) {\r\n this.roleService.isBroker().then((isBroker: boolean) => {\r\n if (isBroker == true) {\r\n this.userService\r\n .getcurentuserrecord()\r\n .then((currentUser: ApplicationUserDTO) => {\r\n this.loanCriteria.BrokerUserId = currentUser.Id;\r\n this.loanCriteria.BrokerOrganisationId =\r\n currentUser.OrganisationId;\r\n });\r\n }\r\n });\r\n }\r\n if (!this.isLoggedInUser && this.sharedDataService.isBorrower) {\r\n //if (orgCode) {\r\n // this.organisationService.getOrganisationByOrgCode(orgCode).then((organisation: OrganisationDTO) => {\r\n // this.loanCriteria.BrokerOrganisationId = organisation.Id;\r\n // });\r\n //} else {\r\n // this.organisationService.getBrickflowBrokerOrg().then((organisation: OrganisationDTO) => {\r\n // this.loanCriteria.BrokerOrganisationId = organisation.Id;\r\n // });\r\n //}\r\n var data;\r\n\r\n //if (window.self == window.top) {\r\n // data = sessionStorage.getItem('userDetails');\r\n\r\n // if (sessionStorage.getItem('organisationLinkId')) this.loanCriteria.OrganisationLinkId = Number(sessionStorage.getItem('organisationLinkId'));\r\n\r\n // if (sessionStorage.getItem('sourceUrl')) this.loanCriteria.LeadSourceUrl = sessionStorage.getItem('sourceUrl');\r\n\r\n //} else {\r\n // data = this.sharedDataService.userDetails;\r\n\r\n // if (this.sharedDataService.organisationLinkId != null) this.loanCriteria.OrganisationLinkId = Number(this.sharedDataService.organisationLinkId);\r\n // if (this.sharedDataService.leadSourceUrl != null) this.loanCriteria.LeadSourceUrl = this.sharedDataService.leadSourceUrl;\r\n\r\n //}\r\n\r\n //if (data) {\r\n // let userdetails = JSON.parse(data);\r\n\r\n // let userFullName = userdetails.FullName;\r\n // let spaceIndex = userFullName.indexOf(' ');\r\n\r\n // let firstName = '';\r\n // let lastName = '';\r\n\r\n // // if not space has been added to the name then put the whole name in the first name field\r\n // if (spaceIndex == -1) {\r\n // firstName = userFullName;\r\n // } else {\r\n // firstName = userFullName.substring(0, userFullName.indexOf(' '));\r\n // lastName = userFullName.substring(userFullName.indexOf(' ') + 1);\r\n // }\r\n\r\n // this.loanCriteria.IntroduceeFirstName = firstName;\r\n // this.loanCriteria.IntroduceeSurname = lastName;\r\n // this.loanCriteria.IntroduceeEmail = userdetails.Email;\r\n // this.loanCriteria.IntroduceePhone = userdetails.PhoneNumber;\r\n\r\n // var currentDate = new Date();\r\n // var projectName = this.sharedDataService.projectName;\r\n // this.loanCriteria.SearchName = projectName ? projectName : firstName + ' ' + lastName + ' Loan Search ' + currentDate.getDate() + \"/\" + (currentDate.getMonth() + 1) + \"/\" + currentDate.getFullYear()\r\n //}\r\n //}).catch ((error) => {\r\n // console.error(\"Failed to get user details: \", error);\r\n //});\r\n }\r\n\r\n this.initClassUses();\r\n this.initProjectTypes();\r\n }\r\n\r\n if (window.self == window.top) {\r\n this.updateGuidanceState();\r\n\r\n $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n this.updateGuidanceState();\r\n });\r\n }\r\n } catch (e) {\r\n console.error(\"Error: \", e);\r\n }\r\n }\r\n\r\n indexPopup(methodName: string) {\r\n this.$rootScope.$broadcast(methodName);\r\n }\r\n\r\n initClassUses() {\r\n let classUses: {} = {};\r\n for (let i = 1; i >= 0; i *= 2) {\r\n if (this.loanCriteria.DI_Dev_ClassUses >= i) {\r\n //number is in enum sum, add it to object\r\n if (this.loanCriteria.DI_Dev_ClassUses & i) {\r\n classUses[i] = true;\r\n }\r\n } else {\r\n this.classUses = classUses;\r\n\r\n //watch and update classuses\r\n this.$scope.$watchCollection(\"ctrl.classUses\", (newVal: {}) => {\r\n let valuesList = Object.keys(newVal);\r\n let total: number = 0;\r\n //tot up all the numeric keys (class use enums)\r\n valuesList.forEach((v, i) => {\r\n let keyToNum = Number(v);\r\n if (newVal[keyToNum]) {\r\n total += keyToNum;\r\n }\r\n });\r\n this.loanCriteria.DI_Dev_ClassUses = total;\r\n });\r\n\r\n return;\r\n }\r\n }\r\n }\r\n\r\n initProjectTypes() {\r\n if (!this.loanCriteria.ProjectType) {\r\n this.loanCriteria.ProjectType = 0;\r\n } else {\r\n for (let i = 1; i >= 0; i *= 2) {\r\n if (this.loanCriteria.ProjectType >= i) {\r\n //number is in enum sum, add it to object\r\n if (this.loanCriteria.ProjectType & i) {\r\n this.projectType[i] = true;\r\n }\r\n } else {\r\n return;\r\n }\r\n }\r\n }\r\n }\r\n\r\n getTubeMapValue() {\r\n return this.caseService.getTubeMap();\r\n }\r\n\r\n updateProjectTypes(item: DevelopmentTrackRecordTypeEnum) {\r\n //if we are setting item to false and item exists, remove it, else add it\r\n if (\r\n this.projectType[item] === true &&\r\n !!!(this.loanCriteria.ProjectType & item)\r\n ) {\r\n this.loanCriteria.ProjectType += item;\r\n } else {\r\n this.loanCriteria.ProjectType -= item;\r\n }\r\n }\r\n\r\n back(): void {\r\n if (this.step > 1) {\r\n this.step--;\r\n if (this.$location.path().startsWith(\"/e/criteria\")) {\r\n if (this.$routeParams.linkId) {\r\n this.go(\r\n \"/e/criteria/\" +\r\n this.searchid +\r\n \"/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.step +\r\n \"/\" +\r\n this.$routeParams.linkId,\r\n );\r\n } else {\r\n this.go(\r\n \"/e/criteria/\" +\r\n this.searchid +\r\n \"/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.step,\r\n );\r\n }\r\n } else {\r\n this.go(\r\n \"/criteria/\" + this.searchid + \"/\" + this.caseid + \"/\" + this.step,\r\n );\r\n }\r\n } else if (this.step == 1 && !this.isLoggedInUser) {\r\n this.go(\"/\");\r\n }\r\n }\r\n\r\n formChanged(): void {\r\n (this.$rootScope as any).formSaved = false;\r\n }\r\n\r\n setNewSearch(): void {\r\n var criteriaChanged = true;\r\n\r\n //Store that this is a new search\r\n if (sessionStorage.getItem(\"skip\") == \"true\") {\r\n criteriaChanged = !this.shallowCompare(\r\n this.loanCriteria,\r\n this.snapshotLoanCriteria,\r\n );\r\n }\r\n\r\n if (window.self == window.top) {\r\n sessionStorage.setItem(\"newSearch\", criteriaChanged.toString());\r\n } else {\r\n this.organisationService.sendDataToParent(\r\n \"newSearch\",\r\n criteriaChanged.toString(),\r\n );\r\n }\r\n }\r\n\r\n next(): void {\r\n if (this.step >= 3) {\r\n this.setNewSearch();\r\n //go to results\r\n if (!this.loanCriteria.CI_Dev_LoanReq) {\r\n this.loanCriteria.CI_Dev_LoanReq = 0;\r\n }\r\n if (this.caseid > 0 && this.searchid > 0) {\r\n //If attached case, save changes and go to case related search results\r\n this.save().then((response) => {\r\n this.$location.path(\"/results/\" + this.searchid + \"/\" + this.caseid);\r\n });\r\n } else if (this.searchid > 0) {\r\n //If a previously saved search, save changes and go to existing search results page\r\n this.save().then((response) => {\r\n this.$location.path(\"/results/\" + this.searchid);\r\n });\r\n } else if (\r\n this.$routeParams.uniqueId !== undefined &&\r\n this.$routeParams.uniqueId != \"null\"\r\n ) {\r\n this.save().then((response) => {\r\n this.$location.path(\"/referredSearch/\" + this.$routeParams.uniqueId);\r\n });\r\n } else {\r\n // Store the search on rootScope.\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n (this.$rootScope as any).formSaved = true;\r\n\r\n if (window.self == window.top) sessionStorage.removeItem(\"skip\");\r\n\r\n if (\r\n !this.isLoggedInUser &&\r\n this.isBorrower &&\r\n this.$location.path().startsWith(\"/e/criteria\")\r\n ) {\r\n this.loanCriteria.BrokerOrganisationId = this.brokerageOrg.Id;\r\n if (this.$routeParams.linkId) {\r\n this.loanCriteria.OrganisationLinkId = Number(\r\n this.$routeParams.linkId,\r\n );\r\n }\r\n\r\n if (this.loanCriteria.UniqueRef) {\r\n var result = {} as DevelopmentWithNoLoginDTO;\r\n (Object).assign(result, this.loanCriteria);\r\n this.$DevelopmentInputWithNoLoginService\r\n .saveChangesToReferredSearch(result, this.loanCriteria.UniqueRef)\r\n .then((result) => {\r\n //Go to fresh results page\r\n this.$location.path(\"/results\");\r\n });\r\n } else {\r\n //Go to fresh results page\r\n this.$location.path(\"/results\");\r\n }\r\n } else {\r\n //Go to fresh results page\r\n this.$location.path(\"/results\");\r\n }\r\n }\r\n } else {\r\n this.step++;\r\n //go to next screen\r\n if (this.caseid > 0 && this.searchid > 0) {\r\n this.save().then((response) => {\r\n this.$location.path(\r\n \"/criteria/\" + this.searchid + \"/\" + this.caseid + \"/\" + this.step,\r\n );\r\n });\r\n } else if (this.searchid > 0) {\r\n this.save().then((response) => {\r\n this.$location.path(\r\n \"/criteria/\" + this.searchid + \"/\" + this.caseid + \"/\" + this.step,\r\n );\r\n });\r\n } else if (\r\n this.$routeParams.uniqueId !== undefined &&\r\n this.$routeParams.uniqueId != \"null\"\r\n ) {\r\n this.save().then((response) => {\r\n this.$location.path(\r\n \"/referredsearchcriteria/\" +\r\n this.$routeParams.uniqueId +\r\n \"/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.step,\r\n );\r\n });\r\n } else {\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n if (this.$location.path().startsWith(\"/e/criteria\")) {\r\n if (this.$routeParams.linkId) {\r\n this.$location.path(\r\n \"/e/criteria/\" +\r\n this.searchid +\r\n \"/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.step +\r\n \"/\" +\r\n this.$routeParams.linkId,\r\n );\r\n } else {\r\n this.$location.path(\r\n \"/e/criteria/\" +\r\n this.searchid +\r\n \"/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.step,\r\n );\r\n }\r\n } else {\r\n this.$location.path(\r\n \"/criteria/\" + this.searchid + \"/\" + this.caseid + \"/\" + this.step,\r\n );\r\n }\r\n }\r\n }\r\n }\r\n\r\n save(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n if (!this.loanCriteria) {\r\n defer.reject(\"not ready\");\r\n }\r\n\r\n //Only save if the user is not lender\r\n if (!this.roleService.IsLender) {\r\n // JNG clear selected results, as this is effectively a new query and it may have different results available.\r\n this.loanCriteria.SelectedResults = [];\r\n\r\n if (\r\n this.$routeParams.uniqueId !== undefined &&\r\n this.$routeParams.uniqueId != \"null\"\r\n ) {\r\n var result = {} as DevelopmentWithNoLoginDTO;\r\n (Object).assign(result, this.loanCriteria);\r\n this.$DevelopmentInputWithNoLoginService\r\n .saveChangesToReferredSearch(result, this.$routeParams.uniqueId)\r\n .then((response) => {\r\n defer.resolve(response);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n } else {\r\n this.$DevelopmentInputservice\r\n .addUpdatereturnonlyid(this.loanCriteria)\r\n .then((response) => {\r\n defer.resolve(response);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n }\r\n }\r\n return defer.promise;\r\n }\r\n\r\n updateGuidanceState() {\r\n this.guidanceCheckbox =\r\n this.$cookies.get(\"guidance\") === \"on\" ||\r\n this.$cookies.get(\"guidance\") === undefined;\r\n }\r\n\r\n getGuidanceSwitchState() {\r\n if (!this.$cookies.get(\"guidance\")) {\r\n this.guidanceCheckbox = true;\r\n } else if (this.$cookies.get(\"guidance\") === \"on\") {\r\n this.guidanceCheckbox = true;\r\n } else if (this.$cookies.get(\"guidance\") === \"off\") {\r\n this.guidanceCheckbox = false;\r\n } else {\r\n this.guidanceCheckbox = true;\r\n }\r\n return this.guidanceCheckbox;\r\n }\r\n\r\n recordGuidanceCookie() {\r\n var guidanceSwitchState: string;\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 365);\r\n if (this.guidanceCheckbox == true) {\r\n guidanceSwitchState = \"on\";\r\n } else {\r\n guidanceSwitchState = \"off\";\r\n }\r\n this.$cookies.put(\"guidance\", guidanceSwitchState, { expires: expiryDate });\r\n this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n }\r\n\r\n updateClassUse() {\r\n //this.loanCriteria.DI_Dev_ClassUses has now changed to the single new selection or group of selections. Subtract current set of selections from last state to get last state\r\n let newSelections: number = this.loanCriteria.DI_Dev_ClassUses;\r\n let lastState: number = this.existingClassUses;\r\n //have we re-selected any options\r\n if (!!(lastState & newSelections)) {\r\n this.loanCriteria.DI_Dev_ClassUses = lastState - newSelections;\r\n } else {\r\n this.loanCriteria.DI_Dev_ClassUses = lastState + newSelections;\r\n }\r\n this.existingClassUses = this.loanCriteria.DI_Dev_ClassUses;\r\n }\r\n\r\n go(path: string, save: boolean = true): void {\r\n if (!save) {\r\n this.$location.path(path);\r\n return;\r\n }\r\n\r\n if (this.searchid > 0) {\r\n this.save().then(() => {\r\n this.$location.path(path);\r\n });\r\n } else {\r\n if (this.loanCriteria) {\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n }\r\n this.$location.path(path);\r\n }\r\n }\r\n\r\n setDate(dateToUpdate: Date, month: number, year: number) {\r\n // Two digit years!\r\n var fullYear: number;\r\n var today = new Date();\r\n if (today.getFullYear() < 2000 + year) {\r\n // If it's after this year, we probably mean 19xx.\r\n fullYear = 1900 + year;\r\n } else {\r\n // Otherwise it's probably in the 2000s.\r\n fullYear = 2000 + year;\r\n }\r\n dateToUpdate.setUTCFullYear(fullYear);\r\n // Note: Months are 0 based.\r\n dateToUpdate.setUTCMonth(month - 1);\r\n }\r\n\r\n recalcCosts(updatedField: string): void {\r\n switch (updatedField) {\r\n case \"CI_Dev_BuildCosts\":\r\n this.recalcCostPerArea();\r\n break;\r\n case \"CI_Dev_Contingency\":\r\n this.recalcCostPerArea();\r\n break;\r\n case \"DC_AreaAcquisition\":\r\n this.recalcCostPerArea();\r\n break;\r\n }\r\n }\r\n\r\n recalcTotalBuildCost(): void {\r\n let res: number = 0;\r\n //Case 1 - recalc Build costs\r\n if (\r\n this.loanCriteria.CI_Dev_Contingency &&\r\n this.loanCriteria.DC_AreaAcquisition &&\r\n this.loanCriteria.DC_BuildCostPerArea\r\n ) {\r\n res =\r\n (this.loanCriteria.DC_BuildCostPerArea /\r\n (1 + this.loanCriteria.CI_Dev_Contingency)) *\r\n this.loanCriteria.DC_AreaAcquisition;\r\n this.loanCriteria.CI_Dev_BuildCosts = res;\r\n }\r\n }\r\n\r\n checkValidationCriteria(index: number) {\r\n if (index === 0) {\r\n if (!this.disabledPropertyScreen()) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n if (index === 1) {\r\n if (this.multiPartForm2 && this.multiPartForm2.$valid) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n if (index === 2) {\r\n if (this.multiPartForm3 && this.multiPartForm3.$valid) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n }\r\n\r\n //recalcContingency(): void {\r\n // //let res: number = 0;\r\n // ////Case 2 - recalc Contingency\r\n // //if (this.loanCriteria.CI_Dev_BuildCosts && this.loanCriteria.DC_AreaAcquisition && this.loanCriteria.DC_BuildCostPerArea) {\r\n // // res = ((this.loanCriteria.DC_BuildCostPerArea * this.loanCriteria.DC_AreaAcquisition) / this.loanCriteria.CI_Dev_BuildCosts) - 1;\r\n // // this.loanCriteria.CI_Dev_Contingency = res;\r\n // //}\r\n //}\r\n\r\n recalcGia(): void {\r\n let res: number = 0;\r\n //Case 3 - recalc GIA\r\n if (\r\n this.loanCriteria.CI_Dev_BuildCosts &&\r\n this.loanCriteria.CI_Dev_Contingency &&\r\n this.loanCriteria.DC_BuildCostPerArea\r\n ) {\r\n res =\r\n (this.loanCriteria.CI_Dev_BuildCosts *\r\n (this.loanCriteria.CI_Dev_Contingency + 1)) /\r\n this.loanCriteria.DC_BuildCostPerArea;\r\n this.loanCriteria.DC_AreaAcquisition = res;\r\n }\r\n }\r\n\r\n recalcCostPerArea(): void {\r\n let res: number = 0;\r\n //Case 4 - recalc cost per sq. m\r\n if (\r\n this.loanCriteria.CI_Dev_BuildCosts &&\r\n this.loanCriteria.CI_Dev_Contingency &&\r\n this.loanCriteria.DC_AreaAcquisition\r\n ) {\r\n res =\r\n (this.loanCriteria.CI_Dev_BuildCosts *\r\n (1 + Number(this.loanCriteria.CI_Dev_Contingency))) /\r\n this.loanCriteria.DC_AreaAcquisition;\r\n this.loanCriteria.DC_BuildCostPerArea = res;\r\n\r\n if (\r\n this.loanCriteria.CI_EndPropType === 2 ||\r\n this.loanCriteria.CI_EndPropType === 1\r\n ) {\r\n this.loanCriteria.DI_AreaSalesAreaResidential =\r\n this.loanCriteria.DC_AreaAcquisition;\r\n }\r\n if (this.loanCriteria.CI_EndPropType != 1) {\r\n this.loanCriteria.DI_AreaSalesAreaCommercial =\r\n this.loanCriteria.DC_AreaAcquisition;\r\n }\r\n }\r\n }\r\n\r\n calcTotalBuild(): number {\r\n if (!this.loanCriteria) {\r\n return 0;\r\n }\r\n\r\n let res: number = 0;\r\n\r\n // Add build costs\r\n if (this.loanCriteria.CI_Dev_BuildCosts) {\r\n res += Number(this.loanCriteria.CI_Dev_BuildCosts);\r\n }\r\n\r\n // Add contingency cost\r\n if (\r\n this.loanCriteria.CI_Dev_BuildCosts &&\r\n this.loanCriteria.CI_Dev_Contingency\r\n ) {\r\n res +=\r\n Number(this.loanCriteria.CI_Dev_BuildCosts) *\r\n Number(this.loanCriteria.CI_Dev_Contingency);\r\n }\r\n\r\n // Add Professional costs and charges\r\n if (this.loanCriteria.CI_Dev_AdditionalOngoingCosts) {\r\n res += Number(this.loanCriteria.CI_Dev_AdditionalOngoingCosts);\r\n }\r\n\r\n this.totalBuild = res;\r\n return res;\r\n }\r\n\r\n calcTotalLand(): number {\r\n if (!this.loanCriteria) {\r\n return 0;\r\n }\r\n let res: number = 0;\r\n\r\n if (this.loanCriteria.CI_Dev_OrigPP) {\r\n res += Number(this.loanCriteria.CI_Dev_OrigPP);\r\n }\r\n if (this.loanCriteria.CI_Dev_DoYouOwnTheProperty) {\r\n if (this.loanCriteria.CI_Dev_OrigPPExtra) {\r\n res += Number(this.loanCriteria.CI_Dev_OrigPPExtra);\r\n }\r\n } else {\r\n if (this.loanCriteria.CI_Land_Total_other_Costs) {\r\n res += Number(this.loanCriteria.CI_Land_Total_other_Costs);\r\n }\r\n }\r\n this.totalLand = res;\r\n return res;\r\n }\r\n\r\n totalWarningVisible(): boolean {\r\n if (!this.loanCriteria.CI_GDV) return false;\r\n this.calcTotalBuild();\r\n this.calcTotalLand();\r\n\r\n return this.totalBuild + this.totalLand > Number(this.loanCriteria.CI_GDV);\r\n }\r\n\r\n debugSearch() {\r\n const stringJSON = JSON.stringify(this.loanCriteria);\r\n navigator.clipboard\r\n .writeText(stringJSON)\r\n .then()\r\n .catch((e) => console.log(e));\r\n }\r\n\r\n sum(a: number, b: number): number {\r\n return a + b;\r\n }\r\n videotour() {\r\n this.showVideo = true;\r\n }\r\n\r\n disabledPropertyScreen() {\r\n if (this.multiPartForm1 && this.loanCriteria) {\r\n if (\r\n this.multiPartForm1.$valid &&\r\n this.loanCriteria.CI_Dev_Locations != 0 &&\r\n this.loanCriteria.CI_EndPropType != 0 &&\r\n !this.showPostcodeErrorMessage\r\n ) {\r\n if (\r\n this.loanCriteria.CI_EndPropType == 1 ||\r\n this.loanCriteria.CI_EndPropType == 2\r\n ) {\r\n if (this.loanCriteria.CI_PropTypeDetail != 0) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n return true;\r\n }\r\n }\r\n\r\n videopause(id) {\r\n this.showVideo = false;\r\n let containerElement = document.getElementById(id);\r\n let iframe_tag = containerElement.querySelector(\"iframe\");\r\n if (iframe_tag) {\r\n let iframeSrc = iframe_tag.src;\r\n iframe_tag.src = iframeSrc;\r\n }\r\n }\r\n\r\n updateLoanRequiredValue() {\r\n if (this.isMaximumLoanRequired) {\r\n this.loanCriteria.CI_Dev_LoanReq = 0;\r\n } else {\r\n this.loanCriteria.CI_Dev_LoanReq = this.tempLoanRequired;\r\n }\r\n }\r\n\r\n dummysearch() {\r\n this.loanCriteria.CI_Dev_OrigPP = this.getRandomIntInclusive(\r\n 1000000,\r\n 2000000,\r\n );\r\n this.loanCriteria.CI_Land_Total_other_Costs = this.getRandomIntInclusive(\r\n 1000,\r\n 20000,\r\n );\r\n if (this.loanCriteria.hasPostcode) {\r\n this.loanCriteria.PostcodeSearchString =\r\n this.sharedCriteriaService.getRandomPostcode();\r\n this.loanCriteria.CI_Dev_Locations =\r\n this.sharedCriteriaService.getRegionByPostcode(\r\n this.loanCriteria.PostcodeSearchString,\r\n );\r\n } else {\r\n this.loanCriteria.CI_Dev_Locations = LocationEnum.London;\r\n }\r\n\r\n this.loanCriteria.CI_EndPropType = PropertyTypeEnum.Residential;\r\n this.loanCriteria.CI_PropTypeDetail = PropertyTypeDetailEnum.Flats;\r\n this.loanCriteria.HowManyHouses = this.getRandomIntInclusive(10, 20);\r\n this.loanCriteria.CI_Dev_BuildCosts = this.getRandomIntInclusive(\r\n 1000000,\r\n 2000000,\r\n );\r\n this.loanCriteria.DC_AreaAcquisition = this.getRandomIntInclusive(\r\n 1000,\r\n 3000,\r\n );\r\n this.loanCriteria.CI_Dev_AdditionalOngoingCosts = 1000;\r\n this.loanCriteria.CI_GDV = this.getRandomIntInclusive(10000000, 20000000);\r\n this.step = 3;\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n if (this.$location.path().startsWith(\"/e/criteria\")) {\r\n if (this.$routeParams.linkId) {\r\n this.$location.path(\r\n \"/e/criteria/\" +\r\n this.searchid +\r\n \"/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.step +\r\n \"/\" +\r\n this.$routeParams.linkId,\r\n );\r\n } else {\r\n this.$location.path(\r\n \"/e/criteria/\" + this.searchid + \"/\" + this.caseid + \"/\" + this.step,\r\n );\r\n }\r\n } else {\r\n this.$location.path(\r\n \"/criteria/\" + this.searchid + \"/\" + this.caseid + \"/\" + this.step,\r\n );\r\n }\r\n }\r\n\r\n getRandomIntInclusive(min, max) {\r\n min = Math.ceil(min);\r\n max = Math.floor(max);\r\n return Math.floor(Math.random() * (max - min + 1) + min);\r\n }\r\n\r\n registerNow() {\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n this.$location.path(\"promo\");\r\n }\r\n\r\n userLookupForNewSearch(userSearchTerm: string) {\r\n this.loadingData = true;\r\n this.userService\r\n .searchByEmail(userSearchTerm)\r\n .then((response) => {\r\n if (this.isBroker) {\r\n this.existingUsers = response.filter(\r\n (x) =>\r\n x.OrganisationReferralId ==\r\n this.brokerOrAdminUser.OrganisationId &&\r\n !x.OrganisationId &&\r\n !x.IsOrganisationAdmin,\r\n );\r\n } else {\r\n this.existingUsers = response;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n viewClientsDashboardForNewSearch(userName: string) {\r\n var users = this.existingUsers.filter(\r\n (x) => x.Email.indexOf(userName) !== -1,\r\n );\r\n this.clientFirstName = users[0].FirstName;\r\n this.clientEmail = users[0].Email;\r\n this.clientSurname = users[0].LastName;\r\n this.clientPhoneNumber = users[0].PhoneNumber;\r\n this.clientId = users[0].Id;\r\n this.selectedBorrower = users[0];\r\n this.showClientDetails = true;\r\n }\r\n\r\n attachClientDatatoSearch() {\r\n this.showShareSearchtoClientModal = false;\r\n if (\r\n this.clientEmail != null &&\r\n this.clientFirstName != null &&\r\n this.clientSurname != null &&\r\n this.clientPhoneNumber != null\r\n ) {\r\n var searchuser = {\r\n clientFirstName: \"\",\r\n clientSurname: \"\",\r\n clientEmail: \"\",\r\n clientPhoneNumber: \"\",\r\n clientId: \"\",\r\n existingborrower: false,\r\n searchName: this.loanCriteria.SearchName,\r\n clientUser: null,\r\n };\r\n searchuser.clientEmail = this.clientEmail;\r\n searchuser.clientFirstName = this.clientFirstName;\r\n searchuser.clientSurname = this.clientSurname;\r\n searchuser.clientPhoneNumber = this.clientPhoneNumber;\r\n searchuser.clientId = this.clientId;\r\n searchuser.existingborrower = this.existingborrower;\r\n if (searchuser.existingborrower) {\r\n searchuser.clientUser = this.selectedBorrower;\r\n }\r\n sessionStorage.setItem(\"searchuser\", JSON.stringify(searchuser));\r\n }\r\n }\r\n\r\n clearInputFields() {\r\n this.clientFirstName = null;\r\n this.clientEmail = null;\r\n this.clientSurname = null;\r\n this.clientPhoneNumber = null;\r\n this.showClientDetails = false;\r\n }\r\n\r\n OnClickOfSkip() {\r\n this.showShareSearchtoClientModal = false;\r\n sessionStorage.setItem(\"skip\", \"true\");\r\n sessionStorage.removeItem(\"searchuser\");\r\n }\r\n\r\n gotoDashboard() {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n getUsersBelongToBrokerOrAdmin() {\r\n this.loadingData = true;\r\n this.userService\r\n .getUserSummariesForBrokerOrAdmin()\r\n .then((response) => {\r\n this.existingUsers = response;\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n getNumberOfLenders() {\r\n this.lenderService\r\n .getTotalLenders(ProductFamilyEnum.Development)\r\n .then((response: number) => {\r\n this.totalLenders = Math.floor(response);\r\n });\r\n }\r\n\r\n sendMessageToBroker(message) {\r\n this.loadingData = true;\r\n this.messageToborrower = null;\r\n this.organisationService\r\n .sendBorrowerMessageToSearchBroker(\r\n 0,\r\n message,\r\n this.loanCriteria.IntroduceeFirstName,\r\n this.loanCriteria.IntroduceeSurname,\r\n this.loanCriteria.IntroduceeEmail,\r\n ProductTypeEnum.Development,\r\n \"CRITERIA\",\r\n this.loanCriteria.UniqueRef,\r\n )\r\n .then((results) => {\r\n if (results) {\r\n this.messageToborrower = `Message has been sent successfully.`;\r\n this.showMessageToborrower = true;\r\n } else {\r\n this.messageToborrower = `There is problem sending a message, Please try later.`;\r\n this.showMessageToborrower = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n closeContactBrokerModal() {\r\n this.showContactBrokerModal = false;\r\n this.showMessageToborrower = false;\r\n this.messageToborrower = null;\r\n }\r\n\r\n getStepName(step: number): string {\r\n if (step == 1) return \"PROPERTYCRITERIA\";\r\n if (step == 2) return \"BUILDCOSTCRITERIA\";\r\n if (step == 3) return \"BORROWINGCRITERIA\";\r\n }\r\n\r\n calculateMonthsSinceOrigPurchase() {\r\n let date1 = new Date(this.loanCriteria.CI_Dev_DateOfOrigPurch);\r\n let date2 = new Date();\r\n let months;\r\n months = (date2.getFullYear() - date1.getFullYear()) * 12;\r\n months -= date1.getMonth();\r\n months += date2.getMonth();\r\n return months;\r\n }\r\n\r\n async logEvent() {\r\n var orgCode;\r\n if (window.self == window.top) {\r\n if (sessionStorage.getItem(\"clientId\")) {\r\n this.eventLogService.logPageLoad(\r\n this.getStepName(Number(this.$routeParams.StepNumber)),\r\n this.orgCode,\r\n this.loanCriteria?.IntroduceeEmail,\r\n sessionStorage.getItem(\"userRole\"),\r\n this.$routeParams.linkId ? Number(this.$routeParams.linkId) : 0,\r\n ProductTypeEnum.Development,\r\n this.loanCriteria?.UniqueRef,\r\n 0,\r\n sessionStorage.getItem(\"clientId\"),\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n this.getStepName(Number(this.$routeParams.StepNumber)),\r\n this.orgCode,\r\n this.loanCriteria?.IntroduceeEmail,\r\n sessionStorage.getItem(\"userRole\"),\r\n this.$routeParams.linkId ? Number(this.$routeParams.linkId) : 0,\r\n ProductTypeEnum.Development,\r\n this.loanCriteria?.UniqueRef,\r\n );\r\n }\r\n } else {\r\n var clientId: string = null;\r\n clientId = await this.organisationService.getData(\"clientId\");\r\n\r\n if (clientId) {\r\n this.eventLogService.logPageLoad(\r\n this.getStepName(Number(this.$routeParams.StepNumber)),\r\n this.orgCode,\r\n this.loanCriteria?.IntroduceeEmail,\r\n \"borrower\",\r\n this.$routeParams.linkId ? Number(this.$routeParams.linkId) : 0,\r\n ProductTypeEnum.Development,\r\n this.loanCriteria?.UniqueRef,\r\n 0,\r\n clientId,\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n this.getStepName(Number(this.$routeParams.StepNumber)),\r\n this.orgCode,\r\n this.loanCriteria?.IntroduceeEmail,\r\n \"borrower\",\r\n this.$routeParams.linkId ? Number(this.$routeParams.linkId) : 0,\r\n ProductTypeEnum.Development,\r\n this.loanCriteria?.UniqueRef,\r\n );\r\n }\r\n }\r\n }\r\n\r\n shallowCompare(obj1, obj2) {\r\n // Check if both are null or if one is null\r\n if (obj1 == null && obj2 == null) {\r\n return true;\r\n }\r\n if (obj1 == null || obj2 == null) {\r\n return false;\r\n }\r\n var keys1 = Object.keys(obj1);\r\n var keys2 = Object.keys(obj2);\r\n\r\n keys1 = keys1.filter((key) => key !== \"SaveQueryAndResults\");\r\n keys2 = keys2.filter((key) => key !== \"SaveQueryAndResults\");\r\n\r\n // Check if both objects have the same number of keys\r\n if (keys1.length !== keys2.length) {\r\n return false;\r\n }\r\n\r\n // Check if all keys in obj1 have corresponding equal values in obj2\r\n for (let key of keys1) {\r\n if (typeof obj1[key] === \"object\" || typeof obj2[key] === \"object\") {\r\n continue;\r\n }\r\n if (obj1[key] !== obj2[key]) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n getRegionByPostcode() {\r\n if (\r\n this.loanCriteria.PostcodeSearchString &&\r\n this.loanCriteria.PostcodeSearchString.replace(\" \", \"\").length >= 2\r\n ) {\r\n if (\r\n this.$DevelopmentInputservice.isValidPostcodeString(\r\n this.loanCriteria.PostcodeSearchString,\r\n )\r\n ) {\r\n this.dataLoading = true;\r\n this.$DevelopmentInputservice\r\n .getRegionByPostcode(this.loanCriteria.PostcodeSearchString)\r\n .then((response) => {\r\n if (response.Location != null) {\r\n this.loanCriteria.CI_Dev_Locations = response.Location;\r\n this.showPostcodeErrorMessage = false;\r\n } else {\r\n this.postcodeErrorMsg = response.PostCodeErrorMessage;\r\n this.showPostcodeErrorMessage = true;\r\n if (this.loanCriteria.CI_Dev_Locations)\r\n this.loanCriteria.CI_Dev_Locations = null;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.postcodeErrorMsg =\r\n \"At least one letter and one number must be entered e.g. SW1.\";\r\n this.showPostcodeErrorMessage = true;\r\n if (this.loanCriteria.CI_Dev_Locations)\r\n this.loanCriteria.CI_Dev_Locations = null;\r\n }\r\n } else {\r\n if (this.loanCriteria.CI_Dev_Locations)\r\n this.loanCriteria.CI_Dev_Locations = null;\r\n }\r\n }\r\n\r\n onHasPostcodeChange() {\r\n if (!this.loanCriteria.hasPostcode) {\r\n this.showPostcodeErrorMessage = false;\r\n this.loanCriteria.PostcodeSearchString = null;\r\n this.loanCriteria.CI_Dev_Locations = this.previouslySelectedLocation;\r\n } else {\r\n this.previouslySelectedLocation = this.loanCriteria.CI_Dev_Locations;\r\n this.loanCriteria.CI_Dev_Locations = null;\r\n }\r\n }\r\n}\r\n","import { DevelopmentWithNoLoginDTO } from \"@js/DTO/DevelopmentWithNoLoginDTO.cs.d\";\r\nimport { DevelopmentInputWithNoLoginService } from \"@js/services/DevelopmentInputWithNoLoginService\";\r\n\r\nexport class DevelopmentInputWithNoLoginController {\r\n selectedSection: string;\r\n\r\n objects: DevelopmentWithNoLoginDTO[];\r\n selectedObject: DevelopmentWithNoLoginDTO;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n //addingSubobject: boolean;\r\n\r\n //subobjects: SubobjectDTO[];\r\n //selectedSubobject: SubobjectDTO;\r\n\r\n //fetchingSubobjects: boolean;\r\n //fetchingSubobject: boolean;\r\n\r\n DevelopmentInputwithnologinForm: ng.IFormController;\r\n //subDevelopmentInputwithnologinForm: ng.IFormController;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"DevelopmentInputWithNoLoginService\",\r\n\r\n //'SubobjectService',\r\n ];\r\n //private $subobjectservice: App.Services.SubobjectService\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $DevelopmentInputwithnologinservice: DevelopmentInputWithNoLoginService,\r\n ) {\r\n this.updateObjects();\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n\r\n // Fetch all objects.\r\n this.$DevelopmentInputwithnologinservice\r\n .fetchAll()\r\n .then((response) => {\r\n this.objects = response;\r\n this.preSelectedItem();\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n });\r\n }\r\n\r\n private preSelectedItem() {\r\n if (this.$routeParams.Id) {\r\n let selectedObject = this.objects.find((value, index) => {\r\n return value.Id === parseInt(this.$routeParams.objectId);\r\n });\r\n\r\n this.selectObject(selectedObject);\r\n }\r\n }\r\n\r\n selectObject(object: DevelopmentWithNoLoginDTO) {\r\n this.selectedObject = object;\r\n\r\n //this.fetchingSubobjects = true;\r\n //this.$subobjectservice.fetchSubobjectsForObject(object.Id).then((response) => {\r\n // this.subobjects = response;\r\n // this.fetchingSubobjects = false;\r\n //}).catch((response) => {\r\n // this.fetchingSubobjects = false;\r\n //});\r\n\r\n this.selectedSection = \"details\";\r\n }\r\n\r\n createObject() {\r\n this.selectedSection = \"details\";\r\n this.selectedObject = {} as DevelopmentWithNoLoginDTO;\r\n }\r\n\r\n save() {\r\n this.$DevelopmentInputwithnologinservice\r\n .addUpdatereturnonlyid(this.selectedObject)\r\n .then((response) => {\r\n this.selectedObject.Id = response;\r\n if (!this.objects) {\r\n this.objects = [];\r\n }\r\n\r\n let matches: DevelopmentWithNoLoginDTO[] = this.objects.filter(\r\n (value, index) => {\r\n return value.Id == response;\r\n },\r\n );\r\n\r\n if (!matches || matches.length === 0) {\r\n this.objects.push(this.selectedObject);\r\n }\r\n\r\n this.DevelopmentInputwithnologinForm.$setPristine();\r\n this.updateObjects();\r\n });\r\n }\r\n\r\n delete() {\r\n this.$DevelopmentInputwithnologinservice\r\n .delete(this.selectedObject.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.DevelopmentInputwithnologinForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n });\r\n }\r\n\r\n //addSubobject() {\r\n // this.selectedSubobject = {\r\n // AssociatedObjectId: this.selectedObject.Id,\r\n // AssociatedObjectName: this.selectedObject.Name\r\n // } as SubobjectDTO;\r\n //}\r\n\r\n //removeSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.deleteSubobject(subobject.Id).then((response) => {\r\n // this.subobjects.splice(this.subobjects.indexOf(this.selectedSubobject), 1);\r\n // delete this.selectedSubobject;\r\n // });\r\n //}\r\n\r\n //cancelUpdateSubobject() {\r\n // delete this.selectedSubobject;\r\n //}\r\n\r\n //updateSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.addUpdateSubobject(subobject).then((response) => {\r\n // if (this.subobjects.indexOf(subobject) === -1) {\r\n // this.subobjects.push(subobject);\r\n // }\r\n // delete this.selectedSubobject;\r\n // }).catch((response) => {\r\n // delete this.selectedSubobject;\r\n // });\r\n\r\n //}\r\n}\r\n","import { DevelopmentTrackRecordDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentTrackRecordDTO.cs.d\";\r\nimport { DevelopmentTrackRecordService } from \"@js/services/DevelopmentTrackRecordService\";\r\n\r\nexport class DevelopmentTrackRecordController {\r\n selectedSection: string;\r\n\r\n objects: DevelopmentTrackRecordDTO[];\r\n selectedObject: DevelopmentTrackRecordDTO;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n //addingSubobject: boolean;\r\n\r\n //subobjects: SubobjectDTO[];\r\n //selectedSubobject: SubobjectDTO;\r\n\r\n //fetchingSubobjects: boolean;\r\n //fetchingSubobject: boolean;\r\n\r\n developmenttrackrecordForm: ng.IFormController;\r\n //subdevelopmenttrackrecordForm: ng.IFormController;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"DevelopmentTrackRecordService\",\r\n\r\n //'SubobjectService',\r\n ];\r\n //private $subobjectservice: App.Services.SubobjectService\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $developmenttrackrecordservice: DevelopmentTrackRecordService,\r\n ) {\r\n this.updateObjects();\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n\r\n // Fetch all objects.\r\n this.$developmenttrackrecordservice\r\n .fetchAll()\r\n .then((response) => {\r\n this.objects = response;\r\n this.preSelectedItem();\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n });\r\n }\r\n\r\n private preSelectedItem() {\r\n if (this.$routeParams.Id) {\r\n let selectedObject = this.objects.find((value, index) => {\r\n return value.Id === parseInt(this.$routeParams.objectId);\r\n });\r\n\r\n this.selectObject(selectedObject);\r\n }\r\n }\r\n\r\n selectObject(object: DevelopmentTrackRecordDTO) {\r\n this.selectedObject = object;\r\n\r\n //this.fetchingSubobjects = true;\r\n //this.$subobjectservice.fetchSubobjectsForObject(object.Id).then((response) => {\r\n // this.subobjects = response;\r\n // this.fetchingSubobjects = false;\r\n //}).catch((response) => {\r\n // this.fetchingSubobjects = false;\r\n //});\r\n\r\n this.selectedSection = \"details\";\r\n }\r\n\r\n createObject() {\r\n this.selectedSection = \"details\";\r\n this.selectedObject = {} as DevelopmentTrackRecordDTO;\r\n }\r\n\r\n save() {\r\n this.$developmenttrackrecordservice\r\n .addUpdatereturnonlyid(this.selectedObject)\r\n .then((response) => {\r\n this.selectedObject.Id = response;\r\n if (!this.objects) {\r\n this.objects = [];\r\n }\r\n\r\n let matches: DevelopmentTrackRecordDTO[] = this.objects.filter(\r\n (value, index) => {\r\n return value.Id == response;\r\n },\r\n );\r\n\r\n if (!matches || matches.length === 0) {\r\n this.objects.push(this.selectedObject);\r\n }\r\n\r\n this.developmenttrackrecordForm.$setPristine();\r\n this.updateObjects();\r\n });\r\n }\r\n\r\n delete() {\r\n this.$developmenttrackrecordservice\r\n .delete(this.selectedObject.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.developmenttrackrecordForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n });\r\n }\r\n\r\n //addSubobject() {\r\n // this.selectedSubobject = {\r\n // AssociatedObjectId: this.selectedObject.Id,\r\n // AssociatedObjectName: this.selectedObject.Name\r\n // } as SubobjectDTO;\r\n //}\r\n\r\n //removeSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.deleteSubobject(subobject.Id).then((response) => {\r\n // this.subobjects.splice(this.subobjects.indexOf(this.selectedSubobject), 1);\r\n // delete this.selectedSubobject;\r\n // });\r\n //}\r\n\r\n //cancelUpdateSubobject() {\r\n // delete this.selectedSubobject;\r\n //}\r\n\r\n //updateSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.addUpdateSubobject(subobject).then((response) => {\r\n // if (this.subobjects.indexOf(subobject) === -1) {\r\n // this.subobjects.push(subobject);\r\n // }\r\n // delete this.selectedSubobject;\r\n // }).catch((response) => {\r\n // delete this.selectedSubobject;\r\n // });\r\n\r\n //}\r\n}\r\n","export const enum PreAgreementEnum {\r\n None = 0,\r\n PreLet = 1,\r\n PreSold = 2,\r\n}\r\n","export const enum ScheduleDescriptionTypeEnum {\r\n DetachedHouse = 1,\r\n SemiDetachedHouse = 2,\r\n TerrancedHouse = 3,\r\n Cottage = 4,\r\n Bungalow = 5,\r\n Studio = 6,\r\n SingleStorey = 7,\r\n Duplex = 8,\r\n Triplex = 9,\r\n}\r\n","import { AddressHistoryDTO } from \"@js/DTO/AddressHistoryDTO.cs.d\";\r\nimport { AddressLookupDTO } from \"@js/DTO/AddressLookupDTO.cs.d\";\r\nimport { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CaseChangedMessageDTO } from \"@js/DTO/CaseChangedMessageDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { DealClientDTO } from \"@js/DTO/Deal/DealClientDTO.cs.d\";\r\nimport { DealFileAttachmentDTO } from \"@js/DTO/Deal/DealFileAttachmentDTO.cs.d\";\r\nimport { DealLenderDTO } from \"@js/DTO/Deal/DealLenderDTO.cs.d\";\r\nimport { DealNoteDTO } from \"@js/DTO/Deal/DealNoteDTO.cs.d\";\r\nimport { DealScheduleDTO } from \"@js/DTO/Deal/DealScheduleDTO.cs.d\";\r\nimport { DevelopmentFinanceDealDTO } from \"@js/DTO/Deal/DevelopmentFinanceDealDTO.cs.d\";\r\nimport { ExternalLinksDTO } from \"@js/DTO/ExternalLinksDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { LenderDTO } from \"@js/DTO/LenderDTO.cs.d\";\r\nimport { InvitedUserResponse } from \"@js/DTO/Messages/Deal/InvitedUserMessage.cs.d\";\r\nimport { LenderInfo } from \"@js/DTO/Messages/Deal/LendersInfoForSubmitToLenderMessage.cs.d\";\r\nimport { PromoteSearchToCaseResponse } from \"@js/DTO/Messages/Deal/PromoteSearchToCaseMessage.cs.d\";\r\nimport { SaveDevFinanceSearchRequest } from \"@js/DTO/Messages/Deal/SaveDevFinanceSearchMessage.cs.d\";\r\nimport { ShareModuleRequest } from \"@js/DTO/Messages/Deal/ShareModuleMessage.cs.d\";\r\nimport { SubmitToLendersRequest } from \"@js/DTO/Messages/Deal/SubmitToLendersMessage.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { AppraisalModuleEnum } from \"@js/models/enum/AppraisalModuleEnum.cs.d\";\r\nimport { AreaUnitEnum } from \"@js/models/enum/AreaUnitEnum.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { LenderProductTypeEnum } from \"@js/models/enum/LenderProductTypeEnum.cs.d\";\r\nimport { LicenseMasterStatusEnum } from \"@js/models/enum/LicenseMasterStatusEnum.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { OwnNewDevelopmentEnum } from \"@js/models/enum/OwnNewDevelopmentEnum.cs.d\";\r\nimport { OwnOrPurchaseEnum } from \"@js/models/enum/OwnOrPurchaseEnum.cs.d\";\r\nimport { PreAgreementEnum } from \"@js/models/enum/PreAgreementEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { PropertyTypeEnum } from \"@js/models/enum/PropertyTypeEnum.cs.d\";\r\nimport { ScheduleDescriptionTypeEnum } from \"@js/models/enum/ScheduleDescriptionTypeEnum.cs.d\";\r\nimport { ScheduleTypeEnum } from \"@js/models/enum/ScheduleTypeEnum.cs.d\";\r\nimport { TenureEnum } from \"@js/models/enum/TenureEnum.cs.d\";\r\nimport { TitleEnum } from \"@js/models/enum/TitleEnum.cs.d\";\r\nimport { PostalAddress } from \"@js/models/PostalAddress.cs.d\";\r\nimport { AccountService } from \"@js/services/AccountService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DealLenderService } from \"@js/services/Deal/DealLenderService\";\r\nimport { DealNoteService } from \"@js/services/Deal/DealNoteService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { DevFinanceDealService } from \"@js/services/Deal/DevFinanceDealService\";\r\nimport { SharedDealService } from \"@js/services/Deal/SharedDealService\";\r\nimport { DealClientService } from \"@js/services/DealClientService\";\r\nimport { DealFileAttachmentService } from \"@js/services/DealFileAttachmentService\";\r\nimport { DevFinanceScheduleService } from \"@js/services/DevFinanceScheduleService\";\r\nimport { ExternalLinksService } from \"@js/services/ExternalLinksService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { StreetAddressService } from \"@js/services/StreetAddressService\";\r\nimport { UserDashboardService } from \"@js/services/UserDashboardService\";\r\nimport angular from \"angular\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { EventLogEnum } from \"@js/models/enum/EventLogEnum.cs.d\";\r\n\r\ninterface LeaseItemDetails {\r\n TimeLeftOnLeaseYears?: number;\r\n TimeLeftOnLeaseMonths?: number;\r\n GrossMonthlyRentalIncome: \"\";\r\n}\r\n\r\nexport class DevFinanceCaseController {\r\n isCaseDashboard: boolean = true;\r\n\r\n dataLoading: boolean;\r\n currentUser: ApplicationUserDTO;\r\n dealId: number;\r\n dealDto: DevelopmentFinanceDealDTO;\r\n tempDealDto: DevelopmentFinanceDealDTO;\r\n orgName: string;\r\n orgId: number;\r\n org: OrganisationDTO;\r\n fileNamePrefix: string = \"Brickflow\";\r\n newNote: DealNoteDTO = {} as DealNoteDTO;\r\n mortgageTerm: number = 0;\r\n\r\n CaseDashboardTypeEnum = {\r\n Overview: 0,\r\n Borrower: 1,\r\n Property: 2,\r\n Loan: 3,\r\n BorrowerEdit: 4,\r\n Planning: 5,\r\n BuildProcurement: 6,\r\n FurtherInfo: 7,\r\n EquityAndMezz: 8,\r\n };\r\n\r\n selectedNavMenu: number = 0;\r\n\r\n dealForm: ng.IFormController;\r\n ownershipForm: ng.IFormController;\r\n companyDetailsForm: ng.IFormController;\r\n propertyDetailsForm: ng.IFormController;\r\n loanDetailsForm: ng.IFormController;\r\n personalDetailsForm: ng.IFormController;\r\n contactForm: ng.IFormController;\r\n occupationForm: ng.IFormController;\r\n creditForm: ng.IFormController;\r\n trackRecordForm: ng.IFormController;\r\n salesForm: ng.IFormController;\r\n depositsourceForm: ng.IFormController;\r\n developmentScheduleForm: ng.IFormController;\r\n showAddressHistoryModal: boolean = false;\r\n planningForm: ng.IFormController;\r\n buildProcurementForm: ng.IFormController;\r\n furtherInformationForm: ng.IFormController;\r\n lenderDetailsForm: ng.IFormController;\r\n\r\n tabs = {\r\n tabOpen: false,\r\n ownership: false,\r\n companyDetails: false,\r\n personalDetails: false,\r\n contactDetails: false,\r\n occupation: false,\r\n credit: false,\r\n trackRecord: false,\r\n };\r\n\r\n loanTabs = {\r\n loan: false,\r\n depositsource: false,\r\n guaranteesorrecourse: false,\r\n exitstrategy: false,\r\n completion: false,\r\n preferences: false,\r\n mezzanineandequity: false,\r\n };\r\n\r\n proprtyTabs = {\r\n property: false,\r\n buildCosts: false,\r\n sales: false,\r\n developmentSchedule: false,\r\n planning: false,\r\n buildProcurement: false,\r\n furtherInformation: false,\r\n };\r\n\r\n ownershipType: string = \"\";\r\n\r\n leaseItems: LeaseItemDetails[] = [];\r\n\r\n currentApplicant: DealClientDTO;\r\n tempApplicant: DealClientDTO;\r\n applicantList: DealClientDTO[] = [];\r\n appName: string;\r\n\r\n searchterm: string;\r\n previousAddressSearchTerm: string;\r\n PostCodeOptions: PostalAddress[] = [];\r\n previousAddressPostCodeOptions: PostalAddress[] = [];\r\n address: PostalAddress;\r\n searchingForAddress: boolean = false;\r\n searchingForPreviousAddress: boolean = false;\r\n searchresults: string = \"\";\r\n previousAddressSearchResults: string[];\r\n addressHistoryItem: AddressHistoryDTO;\r\n applicantAddressHistory: AddressHistoryDTO[] = [];\r\n\r\n propertyTypeOptions = [];\r\n tenureTypes = [];\r\n maritalStatusOptions = [];\r\n ownOrPurchaseOptions = [];\r\n ownNewDevelopmentOptions = [];\r\n yesNoOptions = [];\r\n planningOptions = [];\r\n titleOptions = [];\r\n ownershipRoleOptions = [];\r\n countryList = [];\r\n nationalityList = [];\r\n countryOfBirthList = [];\r\n countryOfResidenceList = [];\r\n loanCompletionTypeOptions = [];\r\n currentUseofBuildingOptions = [];\r\n loanRepaymentTypeOptions = [];\r\n productTypeOptions = [];\r\n fixedrateTermOptions = [];\r\n locationOptions = [];\r\n planningStatusAtEndOfDevOptions = [];\r\n planningResponsibilityOptions = [];\r\n buildProcurementTypeOptions = [];\r\n exitStrategyOptions = [];\r\n\r\n //modal\r\n message: string = \"\";\r\n modal: boolean = false;\r\n showErrorMessage: boolean = false;\r\n\r\n uploadingFiles: FileUploadProgressDTO[];\r\n fileUpload: DealFileAttachmentDTO[];\r\n applicantTrackRecordFiles: DealFileAttachmentDTO[];\r\n propertyFiles: DealFileAttachmentDTO[];\r\n total: number = 0;\r\n renamingFile: DealFileAttachmentDTO;\r\n\r\n // Number of note shown on the casedashboard\r\n maxNotes: number = 4;\r\n\r\n // Controls showing Ts & Cs when a borrower/broker submits to lenders\r\n showTsAndCs: boolean = false;\r\n showApplyTsAndCs: boolean = false;\r\n showRequestEmailForm: boolean = false;\r\n requestMessageReason: string = \"\";\r\n showTsAndCsForm: boolean = false;\r\n sendingMessage: boolean = false;\r\n messagebool: boolean = false;\r\n invalidEmail: boolean = false;\r\n\r\n isBroker: boolean = false;\r\n isAdmin: boolean = false;\r\n isLender: boolean = false;\r\n isClient: boolean = false;\r\n isSubmitted: boolean = false;\r\n\r\n isSubmittedToLenders: boolean = false;\r\n messageContent: string;\r\n dealLender: DealLenderDTO;\r\n\r\n //Boolean to enable a re-submit button\r\n hasShortlistedDealLenders: boolean = false;\r\n\r\n caseStatusOptions = [];\r\n caseStatusText: string = \"\";\r\n caseOverview: string;\r\n\r\n selectedLendersName: string = \"\";\r\n shortlistedLendersName: string = \"\";\r\n\r\n //Sharing case\r\n shareContext: AppraisalModuleEnum = null;\r\n caseMembersWithAccess: ClientDTO[];\r\n showShare: boolean = false;\r\n selectedClientToShareWith: ClientDTO;\r\n shareNote: string;\r\n showModuleShareConfirmation: boolean;\r\n\r\n //show profile view\r\n showAppraisalPermission: boolean = false;\r\n\r\n //profile\r\n newApplicant: DealClientDTO;\r\n\r\n maxDateOfBirth: Date = new Date();\r\n minDateOfBirth: Date = new Date(\"Jan 01 1900\");\r\n maxDateForDateField: Date = new Date(\"Jan 01 3000\");\r\n showAddorEdit: boolean = false;\r\n disableQuickEditSave: boolean = false;\r\n applicantForm: ng.IFormController;\r\n isAddShareholder: boolean;\r\n showDelete: boolean = false;\r\n confirmDeleteApplicant: DealClientDTO;\r\n\r\n showExport: boolean = false;\r\n updatingName: boolean = false;\r\n orginalDealName: string;\r\n\r\n showAddHistoryConfirmDelete: boolean = false;\r\n addressHistoryIdToDelete: number;\r\n\r\n isLoggedInUser: boolean = false;\r\n\r\n showBridgingDeal: boolean = true;\r\n classUses: {} = {};\r\n\r\n tinymceOptions: any;\r\n tinymceOptionsTrackRecord: any;\r\n tinymceReadonlyOptions: any;\r\n missingAddressGaps: string[];\r\n\r\n ownOrPurchase: boolean;\r\n isFamilyInResidence: boolean;\r\n\r\n dateProperties = [\"ExpiryDate\"];\r\n\r\n profileDateProperties = [\r\n \"DateOfBirth\",\r\n \"CurrentAddressFrom\",\r\n \"UkResidenceIssueDate\",\r\n \"CurrentEmploymentStartDate\",\r\n \"AddressStartDate\",\r\n ];\r\n\r\n dealDateProperties = [\"OriginalPurchaseDate\", \"CompletionDate\"];\r\n\r\n clientDateProperties = [\"DateOfBirth\"];\r\n\r\n maxPurchaseDate: string;\r\n minPurchaseDate: Date = new Date(\"Jan 01 1900\");\r\n dealProductTypeDisplayText: string;\r\n isInActiveLender: boolean = false;\r\n totalGrossMonthlyRentalIncome: number = 0;\r\n isGrossMonthlyRentalIncomeMatch: boolean = true;\r\n showDeal: boolean = true;\r\n\r\n openTrackRecordUploadModal: boolean = false;\r\n\r\n //Sales section\r\n totalSalesCost: number;\r\n totalNetDevelopmentVal: number;\r\n\r\n //Property/property\r\n totalPurchaseCosts: number;\r\n // Property/build costs\r\n hasBuildCostsChanged: boolean = false;\r\n totalBreakdownProfessionalCosts: number;\r\n totalProjectCosts: number;\r\n buildCostPerSqFt: number;\r\n buildCostPerSqM: number;\r\n buildCostIntermediary: number;\r\n areaConversionFactor: number = 10.7639;\r\n contingencyValue: number;\r\n totalBuildCosts: number;\r\n buildCostsForm: ng.IFormController;\r\n\r\n //Schedule\r\n showUnitTypeOptions: boolean = false;\r\n selectedUnitType: ScheduleTypeEnum = null;\r\n scheduleTenureOptions = [];\r\n preAgreementTypeOptions = [];\r\n flatDescriptionTypeOptions = [];\r\n houseDescriptionTypeOptions = [];\r\n newScheduleData: DealScheduleDTO;\r\n houses: DealScheduleDTO[] = [];\r\n flats: DealScheduleDTO[] = [];\r\n parking: DealScheduleDTO[] = [];\r\n commercial: DealScheduleDTO[] = [];\r\n scheduleData: DealScheduleDTO[] = [];\r\n newScheduleDataPricePerUnit: number = 0;\r\n\r\n totalScheduleUnitsGDV: number = 0;\r\n totalScheduleUnitsArea: number = 0;\r\n tempGDV: number = 0;\r\n tempAreaAcquisition: number = 0;\r\n tempScheduleData: DealScheduleDTO;\r\n showScheduleUnitDeleteConfirmation: boolean = false;\r\n showSuccessorFailureMessage: boolean = false;\r\n\r\n //Property section validity\r\n isPropertySectionInvalidToSave: boolean = false;\r\n\r\n //property for roles directive to handle referred readonly view for broker/connect broker\r\n isReadOnlyDeal: boolean = true;\r\n hasFirstLoadOccurred: boolean = false;\r\n\r\n referredPackagerText: string;\r\n\r\n properyForms = [\r\n \"ctrl.planningForm\",\r\n \"ctrl.buildProcurementForm\",\r\n \"ctrl.furtherInformationForm\",\r\n \"ctrl.salesForm\",\r\n \"ctrl.propertyDetailsForm\",\r\n \"ctrl.buildCostsForm\",\r\n ];\r\n\r\n shortListedLendersId: Number[];\r\n lendersDetailsForSubmittoLenders: LenderInfo[];\r\n\r\n //SubmitToLender modal\r\n brokerCommission: number;\r\n brokerPreferredContact: string;\r\n isBrokerPhoneNumberUpdated: boolean = false;\r\n dealBrokerUser: ApplicationUserDTO;\r\n totalUnreadDealLenderMessages: number = null;\r\n\r\n //Lender Portal Links\r\n dealLenders: DealLenderDTO[];\r\n dealLendersWithPortalLinkEnabled: DealLenderDTO[];\r\n lendersWithPortalLinkEnabled: LenderDTO[];\r\n showLenderPortalLinks: boolean = false;\r\n portalLinks: {} = {};\r\n borrowerDetails: UserSimpleDTO;\r\n applicationForm: ng.IFormController;\r\n portalLinkDetailsAdded: {} = {};\r\n\r\n isDeallockerIntegrationEnabled: boolean = false;\r\n showMaximumApplicantsMessage: boolean = false;\r\n\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$location\",\r\n \"$cookies\",\r\n \"AccountService\",\r\n \"StreetAddressService\",\r\n \"DevFinanceDealService\",\r\n \"DealNoteService\",\r\n \"AuthService\",\r\n \"SelectListService\",\r\n \"RoleService\",\r\n \"LenderService\",\r\n \"CaseService\",\r\n \"DealLenderService\",\r\n \"DealFileAttachmentService\",\r\n \"$window\",\r\n \"ExternalLinksService\",\r\n \"DealClientService\",\r\n \"OrganisationService\",\r\n \"$scope\",\r\n \"$sce\",\r\n \"DealService\",\r\n \"SharedDealService\",\r\n \"ProductService\",\r\n \"DevFinanceScheduleService\",\r\n \"UserDashboardService\",\r\n \"EventLogService\"\r\n ];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $accountservice: AccountService,\r\n private $streetAddressService: StreetAddressService,\r\n private devFinanceDealService: DevFinanceDealService,\r\n private dealNoteService: DealNoteService,\r\n private authService: AuthService,\r\n private selectListService: SelectListService,\r\n private roleService: RoleService,\r\n private $lenderService: LenderService,\r\n private caseService: CaseService,\r\n private dealLenderService: DealLenderService,\r\n private dealFileAttachmentService: DealFileAttachmentService,\r\n private $window: ng.IWindowService,\r\n private $externalLinksService: ExternalLinksService,\r\n private dealClientService: DealClientService,\r\n private organisationService: OrganisationService,\r\n private $scope: ng.IScope,\r\n private $sce: ng.ISCEService,\r\n private dealService: DealService,\r\n private sharedDealService: SharedDealService,\r\n private productService: ProductService,\r\n private devFinanceScheduleService: DevFinanceScheduleService,\r\n private userDashboardService: UserDashboardService,\r\n private eventLogService: EventLogService\r\n ) {\r\n if ($cookies.get(\"access_token\")) {\r\n this.isLoggedInUser = true;\r\n }\r\n this.maxPurchaseDate = new Date().toISOString().split(\"T\")[0];\r\n this.tinymceOptionsTrackRecord = this.tinymceOptions =\r\n this.sharedDealService.tinymceOptions;\r\n this.tinymceOptionsTrackRecord.height = undefined;\r\n this.tinymceReadonlyOptions = angular.copy(this.tinymceOptions);\r\n this.tinymceReadonlyOptions.readonly = 1;\r\n if (this.$routeParams.DealId) {\r\n this.dataLoading = true;\r\n\r\n this.dealId = this.$routeParams.DealId;\r\n if (\r\n this.$routeParams.Promote &&\r\n this.$routeParams.Promote != \"null\" &&\r\n !this.dealDto\r\n ) {\r\n var promote = this.$routeParams.Promote as boolean;\r\n this.isReadOnlyDeal = false;\r\n this.hasFirstLoadOccurred = true;\r\n if (promote) {\r\n this.promoteSearchToCase();\r\n }\r\n } else {\r\n this.dealService.fetchByDealId(this.$routeParams.DealId, ProductFamilyEnum.Development, true)\r\n .then((response) => {\r\n // The case was a pre-existing case when the broker org became a member of Connect and therefore was archived.\r\n if (response.DevFinanceDealDto.IsPreConnectArchived) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n\r\n //Below properties are very imp for view roles directive \r\n this.isReadOnlyDeal = response.IsReadOnlyDealForBroker;\r\n this.hasFirstLoadOccurred = true;\r\n this.referredPackagerText = response.ReferredPackagerText;\r\n this.dealDto = response.DevFinanceDealDto;\r\n this.shortlistedLendersName = response.ShortlistedLendersName;\r\n this.selectedLendersName = response.SelectedLendersName;\r\n this.shortListedLendersId = response.ShortlistedLendersId;\r\n this.totalUnreadDealLenderMessages =\r\n response.TotalUnreadDealLenderMessages;\r\n\r\n if (this.dealDto) {\r\n this.orgId = this.dealDto.BrokerOrganisationId;\r\n\r\n if (this.dealDto.ProjectDescription) {\r\n this.caseOverview = this.dealDto.ProjectDescription;\r\n }\r\n\r\n this.postRetrieveProcessing();\r\n\r\n var newShortlist = this.$routeParams.NewShortlist as boolean;\r\n if (newShortlist) this.getLenderPortalLinks();\r\n } else {\r\n // If no case is returned, this could be that the logged in user has been removed from the case\r\n // - only do this if there is a logged in user, otherwise let the routing sort out where the redirect should go\r\n if ((this.$rootScope as any).selectedUser) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n this.countryOfBirthList = this.countryOfResidenceList =\r\n this.selectListService.GetCountries();\r\n this.nationalityList = this.selectListService.GetNationalities();\r\n this.ownOrPurchaseOptions = this.selectListService.GetOwnOrPurchase();\r\n this.maritalStatusOptions =\r\n this.selectListService.GetMaritalStatusOptions();\r\n this.propertyTypeOptions = this.selectListService.GetPropertyType();\r\n this.ownNewDevelopmentOptions =\r\n this.selectListService.GetOwnNewDevelopmentOptions();\r\n this.yesNoOptions = this.selectListService.GetYesNoForBridging();\r\n this.titleOptions = this.selectListService.GetTitleOptions();\r\n this.loanCompletionTypeOptions =\r\n this.selectListService.GetLoanCompletionOptions();\r\n this.ownershipRoleOptions =\r\n this.selectListService.GetOwnershipRoleOptions();\r\n this.currentUseofBuildingOptions =\r\n this.selectListService.GetCurrentUseOfBuildingOptions();\r\n this.loanRepaymentTypeOptions =\r\n this.selectListService.GetLoanRepaymentTypeOptions();\r\n this.productTypeOptions = this.selectListService.GetInterestRateType();\r\n this.fixedrateTermOptions =\r\n this.selectListService.GetFixedRateTermOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n this.planningStatusAtEndOfDevOptions =\r\n this.selectListService.GetPlanningStatusAtEndOfDevelopmentOptions(\r\n ProductTypeEnum.Development,\r\n );\r\n this.planningResponsibilityOptions =\r\n this.selectListService.GetPlanningResponsibilityOptions();\r\n this.buildProcurementTypeOptions =\r\n this.selectListService.GetBuildProcurementTypeOptions();\r\n this.exitStrategyOptions =\r\n this.selectListService.GetExitStrategyDevFinanceOptions();\r\n this.scheduleTenureOptions =\r\n this.selectListService.GetSceheduleTenureTypes();\r\n this.preAgreementTypeOptions =\r\n this.selectListService.GetPreAgreementTypes();\r\n this.flatDescriptionTypeOptions =\r\n this.selectListService.GetFlatDescriptionTypes();\r\n this.houseDescriptionTypeOptions =\r\n this.selectListService.GetHouseDescriptionTypes();\r\n this.getAppName();\r\n }\r\n\r\n getRequiredRoles(isCaseDashboard: boolean) {\r\n if (isCaseDashboard) {\r\n if (this.isReadOnlyDeal) {\r\n return `['Admin', 'Client']`;\r\n } else {\r\n return `['Admin', 'Client', 'Broker', 'Introducer']`;\r\n }\r\n }\r\n return `['Admin', 'Client', 'Broker', 'Introducer', 'Lender']`;\r\n }\r\n\r\n editDealName() {\r\n var name = this.dealDto.Name;\r\n this.orginalDealName = name;\r\n this.updatingName = true;\r\n }\r\n\r\n cancelEditDealName() {\r\n this.updatingName = false;\r\n this.dealDto.Name = this.orginalDealName;\r\n }\r\n\r\n /**Gets the Case Status display text */\r\n getCaseStatusDisplayText() {\r\n var statusItem = null;\r\n\r\n if (this.isLender) {\r\n statusItem = this.caseStatusOptions.find(\r\n (statusOption) => this.dealLender.Status == statusOption.key,\r\n );\r\n } else {\r\n statusItem = this.caseStatusOptions.find(\r\n (statusOption) => this.dealDto.Status == statusOption.key,\r\n );\r\n }\r\n\r\n this.caseStatusText = statusItem.displayName;\r\n }\r\n\r\n postRetrieveProcessing() {\r\n if (this.$routeParams.selectedNavMenu) {\r\n this.selectedNavMenu = this.$routeParams.selectedNavMenu;\r\n }\r\n\r\n this.dealLenderService\r\n .fetchByDealId(this.$routeParams.DealId)\r\n .then((dls: DealLenderDTO[]) => {\r\n this.hasShortlistedDealLenders = dls.some(\r\n (dl) => dl.Status == CaseLenderStateEnum.Shortlisted,\r\n );\r\n });\r\n\r\n //These are used for directive.\r\n (this.$rootScope as any).statusRequirementId = this.dealDto.Id;\r\n this.caseService.updateCaseState(this.dealDto.Id, this.dealDto.Status);\r\n this.getCurrentUserAndRoles();\r\n this.fileUpload = this.dealDto.Attachments;\r\n this.applicantList = this.dealDto.DealClients;\r\n this.scheduleData = this.dealDto.DealSchedules;\r\n this.prepareUnitData();\r\n this.tenureTypes = this.selectListService.GetTenureTypes(\r\n this.dealDto.ProductType,\r\n );\r\n this.dealProductTypeDisplayText =\r\n this.productService.getProductTypeDisplayText(this.dealDto.ProductType);\r\n // this.CalcTotalPurchaseCosts();\r\n\r\n this.buildCostPerSqFt =\r\n this.dealDto.AreaUnit == AreaUnitEnum.SquareFeet\r\n ? this.dealDto.BuildCostPerArea\r\n : null;\r\n this.buildCostPerSqM =\r\n this.dealDto.AreaUnit == AreaUnitEnum.SquareMeters\r\n ? this.dealDto.BuildCostPerArea\r\n : null;\r\n this.buildCostIntermediary = this.dealDto.BuildCosts;\r\n this.updateBuildArea(true);\r\n this.calculateContingency();\r\n this.calculateTotalCosts();\r\n this.updateClassUses();\r\n\r\n if (this.dealDto.BrokerOrganisationId) {\r\n this.getOrganisationbyDealId();\r\n }\r\n }\r\n\r\n keyPressEvent(event) {\r\n if (event.key === \"Enter\") {\r\n this.updatingName = false;\r\n this.submitForm(this.dealForm);\r\n }\r\n if (event.key === \"Escape\") {\r\n this.updatingName = false;\r\n }\r\n }\r\n\r\n submitForm(form: ng.IFormController = null) {\r\n this.dataLoading = true;\r\n\r\n var request: SaveDevFinanceSearchRequest = {\r\n DealDto: this.dealDto,\r\n ShareDealDto: null,\r\n OrgCode: \"\",\r\n EnterpriseClientDto: null,\r\n };\r\n\r\n this.devFinanceDealService\r\n .saveDevFinanceSearchReturnsId(request)\r\n .then((response) => {\r\n if (response != null) {\r\n this.closeTabs();\r\n if (form != null) form.$setPristine();\r\n }\r\n })\r\n .finally(() => {\r\n this.hasBuildCostsChanged = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n closeModalAndGoToDasboard() {\r\n this.showTsAndCs = false;\r\n this.authService.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n closeModalAndGoToDealForum() {\r\n this.showTsAndCs = false;\r\n this.$location.path(\"/dealforum/\" + this.dealDto.Id);\r\n }\r\n\r\n closeModal(test: number) {\r\n this.messagebool = false;\r\n }\r\n\r\n closeTabs() {\r\n for (let key in this.tabs) {\r\n this.tabs[key] = false;\r\n }\r\n }\r\n\r\n closeLoanTabs() {\r\n for (let key in this.loanTabs) {\r\n this.loanTabs[key] = false;\r\n }\r\n }\r\n\r\n discardOwnership() {\r\n this.dealDto.HowWillYouOwnNewDevelopment = null;\r\n //this.companyDetails.temp = null;\r\n this.dealDto.ExcludedLenders = null;\r\n this.dealDto.HasTheCompanyOrPensionBeenFormedYet = null;\r\n }\r\n\r\n gotoApplicant(applicant?: DealClientDTO) {\r\n this.currentApplicant = applicant || null;\r\n this.PostCodeOptions = null;\r\n\r\n if (\r\n this.currentApplicant &&\r\n this.currentApplicant.Profile &&\r\n this.currentApplicant.Profile.AddressHistory &&\r\n this.currentApplicant.Profile.AddressHistory.length > 0\r\n ) {\r\n this.parseAddressHistory(this.currentApplicant.Profile.AddressHistory);\r\n } else {\r\n this.applicantAddressHistory = [];\r\n }\r\n\r\n this.selectedNavMenu = this.CaseDashboardTypeEnum.BorrowerEdit;\r\n this.closeTabs();\r\n }\r\n\r\n getOwnershipTypeText(): string {\r\n var ownershipTypeText;\r\n\r\n if (this.dealDto && this.dealDto.HowWillYouOwnNewDevelopment) {\r\n switch (this.dealDto.HowWillYouOwnNewDevelopment) {\r\n case OwnNewDevelopmentEnum.UKLimitedCompany:\r\n this.ownershipType = ownershipTypeText = \"Company\";\r\n break;\r\n case OwnNewDevelopmentEnum.OverseasLimitedCompany:\r\n this.ownershipType = ownershipTypeText = \"Overseas Company\";\r\n break;\r\n case OwnNewDevelopmentEnum.PensionFund:\r\n this.ownershipType = ownershipTypeText = \"Pension Fund\";\r\n break;\r\n case OwnNewDevelopmentEnum.UKLimitedLiabilityPartnership:\r\n ownershipTypeText = \"Limited Liability Partnership\";\r\n this.ownershipType = \"Partnership\";\r\n break;\r\n default:\r\n ownershipTypeText = \"\";\r\n }\r\n return ownershipTypeText;\r\n }\r\n return \"\";\r\n }\r\n\r\n openAddressHistoryModal(addressHistory: AddressHistoryDTO = null) {\r\n this.previousAddressSearchResults = [];\r\n this.previousAddressPostCodeOptions = [];\r\n\r\n if (addressHistory) {\r\n this.addressHistoryItem = addressHistory;\r\n } else {\r\n this.addressHistoryItem = null;\r\n }\r\n\r\n this.showAddressHistoryModal = true;\r\n }\r\n\r\n addressHistoryComplete() {\r\n return this.sharedDealService.addressHistoryComplete(\r\n this.currentApplicant,\r\n this.applicantAddressHistory,\r\n this.missingAddressGaps,\r\n );\r\n }\r\n\r\n getAddressList(searchTerm: string, postalAddress: PostalAddress) {\r\n let foundMatch = false;\r\n\r\n if (this.PostCodeOptions && this.PostCodeOptions.length > 0) {\r\n let addressLookup = this.PostCodeOptions.find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n this.$streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n for (let prop in address) {\r\n if (address.hasOwnProperty(prop)) {\r\n postalAddress[prop] = address[prop];\r\n }\r\n }\r\n this.searchterm = \"\";\r\n this.searchresults = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n postalAddress.AddressLine1 = addressLookup.AddressLine2.replace(\r\n addressLookup.AddressLine2.substring(\r\n addressLookup.AddressLine2.indexOf(\"-\") - 1,\r\n ),\r\n \"\",\r\n );\r\n postalAddress.AddressLine2 = addressLookup.AddressLine3;\r\n postalAddress.PostCode = addressLookup.AddressLine1;\r\n this.searchterm = \"\";\r\n this.searchresults = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n this.PostCodeOptions = [];\r\n\r\n this.$streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.PostCodeOptions = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n lookupPreviousAddress(searchTerm: string) {\r\n let foundMatch = false;\r\n\r\n if (\r\n this.previousAddressPostCodeOptions &&\r\n this.previousAddressPostCodeOptions &&\r\n this.previousAddressPostCodeOptions.length > 0\r\n ) {\r\n let addressLookup = this.previousAddressPostCodeOptions.find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n\r\n // We've selected an address!\r\n this.$streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n this.addressHistoryItem = {\r\n AddressLine1: address.AddressLine1,\r\n AddressLine2: address.AddressLine2,\r\n AddressLine3: address.AddressLine3,\r\n AddressLine4: address.AddressLine4,\r\n PostCode: address.PostCode,\r\n };\r\n\r\n this.previousAddressSearchTerm = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n this.addressHistoryItem = {\r\n AddressLine1: addressLookup.AddressLine2,\r\n AddressLine2: addressLookup.AddressLine3,\r\n AddressLine3: addressLookup.AddressLine4,\r\n AddressLine4: addressLookup.PostCode,\r\n PostCode: addressLookup.AddressLine1,\r\n };\r\n\r\n this.previousAddressSearchTerm = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n // Initial search term\r\n this.previousAddressPostCodeOptions = [];\r\n\r\n this.$streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.previousAddressPostCodeOptions = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n saveAddressHistory(selectedApplicant: DealClientDTO) {\r\n var id: number = 0;\r\n\r\n if (!this.applicantAddressHistory) {\r\n this.applicantAddressHistory = [];\r\n }\r\n\r\n // If the Id hasn't been set then this is a new previous address\r\n if (this.addressHistoryItem.Id == null) {\r\n id = this.getNextAddressHistoryId();\r\n this.addressHistoryItem.Id = id;\r\n this.applicantAddressHistory.push(this.addressHistoryItem);\r\n } else {\r\n var foundIndex = this.applicantAddressHistory\r\n .map(function (a) {\r\n return a.Id;\r\n })\r\n .indexOf(this.addressHistoryItem.Id);\r\n if (foundIndex > -1) {\r\n this.applicantAddressHistory.splice(\r\n foundIndex,\r\n 1,\r\n this.addressHistoryItem,\r\n ); // removed previous entry and adds the updated one in its place\r\n }\r\n }\r\n\r\n this.dealClientService\r\n .saveAddressHistory(\r\n selectedApplicant.Id,\r\n JSON.stringify(this.applicantAddressHistory),\r\n )\r\n .then((addressHistory: string) => {\r\n selectedApplicant.Profile.AddressHistory = addressHistory;\r\n this.parseAddressHistory(addressHistory);\r\n this.showAddressHistoryModal = false;\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem saving the address history. Please try again later.\";\r\n })\r\n .finally(() => {\r\n this.showAddressHistoryModal = false;\r\n });\r\n }\r\n\r\n /**\r\n * Convert addres history JSON back to an array of PostalAddress objects\r\n * @param addressHistoryJson\r\n */\r\n parseAddressHistory(addressHistoryJson: string) {\r\n // JSON doesn't understand date types so therefore user the reviver function to manually convert them back to dates as opposed to strings\r\n this.applicantAddressHistory = JSON.parse(addressHistoryJson, this.sharedDealService.reviver);\r\n\r\n // Order the address histories by the from date (ascending)\r\n this.applicantAddressHistory.sort(\r\n (a: AddressHistoryDTO, b: AddressHistoryDTO) => {\r\n return this.sharedDealService.getTime(a.FromDate) - this.sharedDealService.getTime(b.FromDate);\r\n },\r\n );\r\n }\r\n\r\n getAddressAsString(address: PostalAddress) {\r\n return this.sharedDealService.getAddressAsString(address);\r\n }\r\n\r\n showConfirmAddressDelete(addressHistoryId: number) {\r\n this.showAddHistoryConfirmDelete = true;\r\n this.addressHistoryIdToDelete = addressHistoryId;\r\n }\r\n\r\n deleteAddressHistory() {\r\n this.showAddHistoryConfirmDelete = false;\r\n\r\n var foundIndex = this.applicantAddressHistory\r\n .map(function (a) {\r\n return a.Id;\r\n })\r\n .indexOf(this.addressHistoryIdToDelete);\r\n\r\n if (foundIndex > -1) {\r\n this.applicantAddressHistory.splice(foundIndex, 1);\r\n\r\n this.dealClientService\r\n .saveAddressHistory(\r\n this.currentApplicant.Id,\r\n JSON.stringify(this.applicantAddressHistory),\r\n )\r\n .then((addressHistory: string) => {\r\n this.currentApplicant.Profile.AddressHistory = addressHistory;\r\n this.parseAddressHistory(addressHistory);\r\n this.showAddressHistoryModal = false;\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem deleting the address history item. Please try again later.\";\r\n });\r\n }\r\n }\r\n\r\n getNextAddressHistoryId(): number {\r\n return this.sharedDealService.getNextAddressHistoryId(\r\n this.applicantAddressHistory,\r\n );\r\n }\r\n\r\n /** Promotes/converts a search to a case */\r\n promoteSearchToCase() {\r\n this.dealService\r\n .promoteSearchToCase(this.dealId, ProductFamilyEnum.Development)\r\n .then((response: PromoteSearchToCaseResponse) => {\r\n if (response != null && response.DevFinanceDealDto != null) {\r\n this.dealDto = response.DevFinanceDealDto;\r\n this.shortlistedLendersName = response.ShortlistedLendersName;\r\n this.selectedLendersName = response.SelectedLendersName;\r\n this.shortListedLendersId = response.ShortlistedLendersId;\r\n this.postRetrieveProcessing();\r\n this.getCurrentUserAndRoles();\r\n } else {\r\n this.message =\r\n \"Problem while promoting a search to case, please try after some time.\";\r\n this.showErrorMessage = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.getLenderPortalLinks();\r\n });\r\n }\r\n\r\n getLenderPortalLinks() {\r\n this.dealLenderService\r\n .fetchByDealId(this.$routeParams.DealId)\r\n .then((dls: DealLenderDTO[]) => {\r\n this.dealLenders = dls;\r\n var searchChanged = this.$routeParams.SearchChanged;\r\n const lenderIds = dls\r\n .filter(\r\n (dl) =>\r\n !dl.HasAppliedInLenderPortal &&\r\n (dl.Status === CaseLenderStateEnum.Shortlisted ||\r\n searchChanged == \"true\"),\r\n )\r\n .map((dl) => dl.LenderId);\r\n return this.$lenderService.getLenderPortalLinks(lenderIds);\r\n })\r\n .then((links) => {\r\n this.portalLinks = links;\r\n })\r\n .catch((error) => {\r\n this.message = \"Error fetching lender portal links: \" + error;\r\n this.portalLinks = null;\r\n })\r\n .finally(() => {\r\n this.showLenderPortalLinks = Object.keys(this.portalLinks).length > 0;\r\n });\r\n }\r\n\r\n openPortalLink(dealLenderId: number, url: string) {\r\n if (!this.portalLinkDetailsAdded[dealLenderId]) {\r\n this.dealLenderService\r\n .addLenderPortalLinkDetails(dealLenderId, this.borrowerDetails)\r\n .then(() => {\r\n this.portalLinkDetailsAdded[dealLenderId] = true;\r\n this.openUrl(url);\r\n })\r\n .catch((error) => {\r\n console.error(\"Error adding lender portal link details:\", error);\r\n });\r\n } else {\r\n this.openUrl(url);\r\n }\r\n }\r\n\r\n private openUrl(url: string) {\r\n if (!/^https?:\\/\\//i.test(url)) {\r\n url = \"http://\" + url;\r\n }\r\n window.open(url, \"_blank\");\r\n }\r\n\r\n saveNote(): void {\r\n this.newNote.DealId = this.dealDto.Id;\r\n this.newNote.UserId = this.currentUser.Id;\r\n\r\n this.dataLoading = true;\r\n this.dealNoteService\r\n .addUpdate(this.newNote)\r\n .then((response) => {\r\n this.dealDto.DealNotes.push(response);\r\n this.newNote = {\r\n DealId: this.dealDto.Id,\r\n UserId: this.currentUser.Id,\r\n } as DealNoteDTO;\r\n this.dealForm.$setPristine();\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n saveOverview(): void {\r\n this.dealDto.ProjectDescription = this.caseOverview;\r\n this.submitForm(this.dealForm);\r\n }\r\n\r\n gotoResultpage() {\r\n this.showErrorMessage = false;\r\n this.$location.path(\"/devfinanceresults/\" + this.dealId);\r\n }\r\n\r\n onFileSelect(files: DealFileAttachmentDTO[], module: ModuleEnum) {\r\n if (!module) {\r\n module = ModuleEnum.Case;\r\n }\r\n\r\n var dealClientId =\r\n module == ModuleEnum.Track ? this.currentApplicant.Id : null;\r\n\r\n this.dealFileAttachmentService\r\n .UploadFileListInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.dealDto.Id,\r\n this.fileUpload,\r\n module,\r\n null,\r\n dealClientId,\r\n )\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n calculateTotalFiles(module: number) {\r\n if (module == ModuleEnum.Track) {\r\n this.total = this.fileUpload.filter(\r\n (item) =>\r\n item.Module === module &&\r\n item.DealClientId == this.currentApplicant.Id &&\r\n !item.IsDeleted,\r\n ).length;\r\n } else {\r\n if (this.fileUpload) {\r\n this.total = this.fileUpload.filter(\r\n (item) => item.Module === module && !item.IsDeleted,\r\n ).length;\r\n }\r\n }\r\n\r\n return this.total;\r\n }\r\n\r\n calculateTotalFilesRemoving(filter: number) {\r\n if (this.fileUpload) {\r\n this.total = this.fileUpload.filter(\r\n (item) => item.Module != filter,\r\n ).length;\r\n }\r\n return this.total;\r\n }\r\n\r\n downloadFile(file: DealFileAttachmentDTO, downloadFile: boolean = false) {\r\n this.dataLoading = true;\r\n this.dealFileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n if (downloadFile) {\r\n this.sharedDealService.downloadFile(uri, file.FileName);\r\n } else {\r\n this.$window.open(uri);\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n renameFile(file: DealFileAttachmentDTO) {\r\n if (this.renamingFile === undefined) {\r\n // if renaming this file will dirty the case, we'll want to set it back to pristine when we're done.\r\n // this.renamingFileDirties = !$scope.caseForm.$dirty;\r\n this.renamingFile = file;\r\n } else {\r\n delete this.renamingFile;\r\n }\r\n }\r\n renamingFileComplete(file: DealFileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.dealFileAttachmentService\r\n .renameFile(file)\r\n .then((response) => {\r\n file.TempURL = response.TempURL;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n delete this.renamingFile;\r\n }\r\n\r\n renamingLinkCompleted(link: ExternalLinksDTO) {\r\n this.dataLoading = true;\r\n this.$externalLinksService\r\n .addUpdate(link)\r\n .then((response) => {\r\n link.Link = response.Link;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n delete this.renamingFile;\r\n }\r\n\r\n deleteFile(file: DealFileAttachmentDTO) {\r\n this.dealDto.Attachments.splice(this.dealDto.Attachments.indexOf(file), 1);\r\n this.dealFileAttachmentService.markasdeleted(file.Id).then((result) => { }); //remove on the server\r\n }\r\n\r\n markSectionAsComplete(propertyName: string) {\r\n if (this.dataLoading == false) {\r\n this.dataLoading = true;\r\n\r\n this.dealDto.IsLoanSectionComplete;\r\n\r\n this.dealService\r\n .markSectionAsComplete(\r\n this.dealDto.Id,\r\n propertyName,\r\n ProductFamilyEnum.Development,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n this.dealDto.DealNotes.push(response.NewDealNote);\r\n this.dealDto = response.DevFinanceDealDto;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n allFormsComplete(): boolean {\r\n if (this.dealDto) {\r\n if (\r\n this.dealDto.IsBorrowerSectionComplete &&\r\n this.dealDto.IsPropertySectionComplete &&\r\n this.dealDto.IsLoanSectionComplete\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n /** Opens the Terms and Conditions popup when the Submit to Lenders button is clicked*/\r\n showTermsAndConditionsForBorrower() {\r\n this.showApplyTsAndCs = true;\r\n this.requestMessageReason = \"a review\";\r\n this.showTsAndCs = true;\r\n }\r\n\r\n /** Opens the Terms and Conditions popup when the Submit to Lenders HoT button is clicked (borrower/broker) */\r\n showTermsAndConditions() {\r\n this.dataLoading = true;\r\n this.$lenderService\r\n .getShortlistedLendersInfoForSubmitToLenders(\r\n this.shortListedLendersId,\r\n LenderProductTypeEnum.DevelopmentFinance,\r\n )\r\n .then((response) => {\r\n this.lendersDetailsForSubmittoLenders = response;\r\n })\r\n .finally(() => {\r\n this.showTsAndCs = true;\r\n this.showTsAndCsForm = true;\r\n this.dealDto.SubmitTsAndCs = false;\r\n this.invalidEmail = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n gotoLendingPage() {\r\n (this.$rootScope as any).isLender = false;\r\n this.$location.path(\"/dealforum/\" + this.dealDto.Id);\r\n }\r\n\r\n /** Submits a case to lenders */\r\n submitCaseToLenders() {\r\n this.showTsAndCsForm = false;\r\n this.sendingMessage = true;\r\n this.dataLoading = true;\r\n var isResubmitting = false;\r\n\r\n if (this.dealDto.Status == CaseStatusEnum.ReadyToReSubmit) {\r\n isResubmitting = true;\r\n }\r\n\r\n var request = {\r\n DealId: this.dealId,\r\n ProductType: this.dealDto.ProductType,\r\n ResubmitToLenders: isResubmitting,\r\n BrokerCommission: Number(this.brokerCommission),\r\n LendersInfo: this.lendersDetailsForSubmittoLenders,\r\n BrokerPhoneNumber: this.brokerPreferredContact,\r\n IsBrokerPhoneNumberUpdated: this.isBrokerPhoneNumberUpdated,\r\n } as SubmitToLendersRequest;\r\n\r\n this.dealService\r\n .submitToLenders(request)\r\n .then((response: CaseChangedMessageDTO) => {\r\n this.dealDto.Status = response.CaseState;\r\n this.caseService.updateCaseState(this.dealDto.Id, response.CaseState);\r\n this.showMessage(\r\n \"You have requested a Decision in Principle from each lender.\",\r\n );\r\n this.isSubmittedToLenders = true;\r\n })\r\n .catch((error) => {\r\n this.showMessage(\"Sorry, something went wrong. Please try again.\");\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n validateEmails() {\r\n this.invalidEmail = false;\r\n\r\n angular.forEach(\r\n this.lendersDetailsForSubmittoLenders,\r\n (lenderdetails, index) => {\r\n var emailField = this.lenderDetailsForm[\"email\" + index];\r\n\r\n if (emailField && emailField.$invalid) {\r\n this.invalidEmail = true;\r\n }\r\n },\r\n );\r\n }\r\n\r\n showMessage(message: string) {\r\n this.messageContent = message;\r\n }\r\n\r\n requestEmail(reason): void {\r\n this.showRequestEmailForm = true;\r\n this.requestMessageReason = reason;\r\n this.messagebool = true;\r\n this.messageContent = \"\";\r\n }\r\n\r\n sendRequestEmail() {\r\n this.showRequestEmailForm = false;\r\n this.sendingMessage = true;\r\n this.dataLoading = true;\r\n this.$accountservice\r\n .RequestAssistanceReview(\r\n this.requestMessageReason,\r\n this.dealDto.Id,\r\n this.dealDto.ProductFamily,\r\n )\r\n .then((response) => {\r\n this.showMessage(\r\n `${this.appName} have been notified that you require assistance and will be in touch shortly to help.`,\r\n );\r\n\r\n let dealNote = {\r\n DealId: this.dealDto.Id,\r\n UserId: this.currentUser.Id,\r\n NoteText: \"You have requested \" + this.requestMessageReason + \".\",\r\n /*ExpandNote: false*/\r\n } as DealNoteDTO;\r\n this.dealNoteService.addUpdate(dealNote).then((caseNoteResponse) => {\r\n this.dealDto.DealNotes.push(caseNoteResponse);\r\n });\r\n })\r\n .catch((error) => {\r\n this.showMessage(\r\n \"Sorry, something went wrong while sending your email. Please try again.\",\r\n );\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n getAppName() {\r\n let lsd = sessionStorage.getItem(\"applicationName\");\r\n if (lsd != null) {\r\n this.appName = lsd;\r\n } else {\r\n this.appName = \"Brickflow\";\r\n }\r\n }\r\n\r\n closeConfirmationModal() {\r\n if (this.isSubmittedToLenders) {\r\n if (this.$routeParams.Promote) {\r\n this.$location.path(\"/devfinancecasedashboard/\" + this.dealDto.Id);\r\n } else {\r\n window.location.reload();\r\n }\r\n }\r\n this.showTsAndCs = false;\r\n }\r\n\r\n viewResults() {\r\n this.$location.path(\"/devfinanceresults/\" + this.dealDto.Id);\r\n }\r\n\r\n /** Process the Heads of Terms button being clicked */\r\n headsOfTermsClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"terms\");\r\n this.$location.path(\r\n \"/devfinanceheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n /** Lender rejects the case*/\r\n rejectButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"reject\");\r\n this.$location.path(\r\n \"/devfinanceheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n withDrawButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"withdraw\");\r\n this.$location.path(\r\n \"/devfinanceheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n feedbackButtonClicked() {\r\n sessionStorage.setItem(\"lenderTask\", \"feedback\");\r\n this.$location.path(\r\n \"/devfinanceheadsofterm/\" + this.dealDto.Id + \"/\" + this.dealLender.Id,\r\n );\r\n }\r\n\r\n getCurrentUserAndRoles() {\r\n this.roleService.GetUserRoles().then((result) => {\r\n if (result.filter((x) => x.toLowerCase() == \"admin\").length > 0) {\r\n this.isAdmin = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"broker\").length > 0) {\r\n this.isBroker = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"client\").length > 0) {\r\n this.isClient = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"lender\").length > 0) {\r\n this.isLender = true;\r\n\r\n this.dealLenderService\r\n .fetchDealLender(this.dealDto.Id)\r\n .then((response) => {\r\n this.dealLender = response;\r\n this.isInActiveLender = response.IsLenderInActive;\r\n this.generateCaseStatusText();\r\n });\r\n }\r\n\r\n this.authService\r\n .getUpdatedProfile()\r\n .then((prof) => {\r\n this.currentUser = prof;\r\n })\r\n .then(() => {\r\n this.checkIfUserIsInvited();\r\n this.updateRequestAssitanceDealNoteMessage();\r\n if (!this.isLender) this.generateCaseStatusText();\r\n });\r\n\r\n /*this.$lenderService\r\n .getSelectedDealLenderNames(this.dealDto.Id)\r\n .then((response) => {\r\n this.selectedLendersText = response.LendersName;\r\n if (this.dealDto.Status == CaseStatusEnum.NewCase) {\r\n this.shortListedLendersId = response.LendersId;\r\n }\r\n });*/\r\n\r\n /*this.$lenderService\r\n .getShortlistedDealLenderNames(this.dealDto.Id)\r\n .then((response) => {\r\n this.shortlistedLendersText = response.LendersName;\r\n if (this.dealDto.Status != CaseStatusEnum.NewCase) {\r\n this.shortListedLendersId = response.LendersId;\r\n }\r\n });*/\r\n if (this.isBroker || this.isAdmin) {\r\n this.organisationService.getOrganisationProductAccess().then((response) => {\r\n this.isDeallockerIntegrationEnabled = response.IsDeallockerIntegrationEnabled;\r\n });\r\n }\r\n });\r\n }\r\n\r\n //Share module functions\r\n openShareModuleModal(contextToShare: AppraisalModuleEnum) {\r\n this.shareContext = contextToShare;\r\n this.constructShareNoteMessage();\r\n\r\n this.dealClientService\r\n .fetchDealMembersWithAccess(this.dealDto.Id)\r\n .then((response: ClientDTO[]) => {\r\n this.caseMembersWithAccess = response;\r\n\r\n this.showShare = true;\r\n });\r\n }\r\n\r\n constructShareNoteMessage() {\r\n this.shareNote = this.sharedDealService.constructShareNoteMessage(\r\n this.shareContext,\r\n this.currentUser,\r\n );\r\n }\r\n\r\n sendToBorrower() {\r\n this.dataLoading = true;\r\n\r\n var request = {\r\n ClientFirstName: this.selectedClientToShareWith.FirstName,\r\n ClientLastName: this.selectedClientToShareWith.LastName,\r\n ClientEmail: this.selectedClientToShareWith.Email,\r\n Note: this.shareNote,\r\n DealId: this.dealDto.Id,\r\n Section: this.shareContext,\r\n ProductFamily: ProductFamilyEnum.Development,\r\n } as ShareModuleRequest;\r\n\r\n this.dealService.shareModuleToBorrower(request).then((success) => {\r\n if (success) {\r\n this.showShare = false;\r\n this.dataLoading = false;\r\n this.showModuleShareConfirmation = true;\r\n this.selectedClientToShareWith = null;\r\n } else {\r\n this.showShare = false;\r\n this.showMessage(\"Sorry, something went wrong. Please try again.\");\r\n }\r\n });\r\n }\r\n\r\n isShareNoteFormComplete(): boolean {\r\n return this.selectedClientToShareWith &&\r\n this.shareNote &&\r\n this.shareNote.length > 0\r\n ? true\r\n : false;\r\n }\r\n\r\n //End of Share module functions\r\n\r\n // Profile view functions\r\n\r\n /**\r\n * Show the Add/Edit permissions profile modal\r\n * @param applicant\r\n */\r\n showPermissionsProfileModal(\r\n profile: DealClientDTO = null,\r\n isEdit: boolean = null,\r\n ): void {\r\n\r\n this.showMaximumApplicantsMessage = false;\r\n\r\n if (isEdit) {\r\n this.dealClientService.fetch(profile.Id).then((response) => {\r\n this.newApplicant = response;\r\n this.isAddShareholder = false;\r\n this.showAddorEdit = true;\r\n\r\n })\r\n\r\n } else {\r\n this.newApplicant = {} as DealClientDTO;\r\n this.isAddShareholder = true;\r\n this.newApplicant.AccessLevel = CaseAccessLevelEnum.Hidden;\r\n this.showAddorEdit = true;\r\n }\r\n }\r\n\r\n resetApplicant() {\r\n this.applicantForm.$setPristine();\r\n this.applicantForm.$setUntouched();\r\n this.newApplicant = {} as DealClientDTO;\r\n this.showAddorEdit = false;\r\n }\r\n\r\n /**\r\n * Saves the applicant being added/edited\r\n */\r\n saveApplicant(formController) {\r\n this.dataLoading = true;\r\n\r\n if (!(this.currentApplicant.Id > 0)) {\r\n this.currentApplicant.IsApplicant = true;\r\n this.currentApplicant.DealId = this.dealDto.Id;\r\n this.currentApplicant.AccessLevel = CaseAccessLevelEnum.Hidden;\r\n }\r\n\r\n this.saveUpdatedApplicant(this.currentApplicant, false, formController);\r\n }\r\n\r\n /**\r\n * Add or update a applicant\r\n * @param applicant\r\n */\r\n saveUpdatedApplicant(\r\n applicant: DealClientDTO,\r\n isPermissionsProfile: boolean = false,\r\n formController = null,\r\n ): void {\r\n this.dataLoading = true;\r\n\r\n this.disableQuickEditSave = true; // this is just because sometimes the save takes a little while and the user could click the save button again\r\n applicant.DealId = this.dealDto.Id;\r\n\r\n if (applicant) {\r\n this.dateProperties.forEach((property) => {\r\n let val = applicant[property];\r\n if (val) {\r\n applicant[property] = this.modifyDateForBackend(val);\r\n }\r\n });\r\n }\r\n\r\n if (applicant.Profile) {\r\n this.profileDateProperties.forEach((property) => {\r\n let val = applicant.Profile[property];\r\n if (val) {\r\n applicant.Profile[property] = this.modifyDateForBackend(val);\r\n }\r\n });\r\n }\r\n\r\n if (applicant.Client) {\r\n this.clientDateProperties.forEach((property) => {\r\n let val = applicant.Client[property];\r\n if (val) {\r\n applicant.Client[property] = this.modifyDateForBackend(val);\r\n }\r\n });\r\n }\r\n\r\n if (!applicant.Client.PostalAddress && isPermissionsProfile) {\r\n applicant.Client.PostalAddress = {\r\n AddressLine1: \"\",\r\n AddressLine2: \"\",\r\n AddressLine3: \"\",\r\n AddressLine4: \"\",\r\n PostCode: \"\",\r\n } as PostalAddress;\r\n }\r\n\r\n this.dealClientService\r\n .addorUpdateApplicant(applicant, this.isAddShareholder)\r\n .then((response) => {\r\n this.dataLoading = true;\r\n\r\n if (response) {\r\n this.dateProperties.forEach((property) => {\r\n let val = response[property];\r\n if (val) {\r\n response[property] = this.modifyDateForFrontend(val);\r\n }\r\n });\r\n }\r\n\r\n if (response.Profile) {\r\n this.profileDateProperties.forEach((property) => {\r\n let val = response.Profile[property];\r\n if (val) {\r\n response.Profile[property] = this.modifyDateForFrontend(val);\r\n }\r\n });\r\n }\r\n\r\n if (response.Client) {\r\n this.clientDateProperties.forEach((property) => {\r\n let val = response.Client[property];\r\n if (val) {\r\n response.Client[property] = this.modifyDateForFrontend(val);\r\n }\r\n });\r\n }\r\n\r\n const existingShareholder = this.applicantList.find(\r\n (s) => s.Id == response.Id,\r\n );\r\n\r\n // If found then we're updating\r\n if (existingShareholder) {\r\n this.applicantList = this.applicantList.filter(\r\n (member) => member.Id != applicant.Id,\r\n );\r\n this.applicantList.push(response);\r\n } else {\r\n this.applicantList.push(response);\r\n }\r\n if (!isPermissionsProfile) {\r\n this.currentApplicant = response;\r\n formController.$setPristine();\r\n }\r\n })\r\n .finally(() => {\r\n delete this.newApplicant;\r\n this.showAddorEdit = false;\r\n this.disableQuickEditSave = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n cancelUpdateApplicant() {\r\n this.showAddorEdit = false;\r\n this.applicantList = this.applicantList.filter(\r\n (applicant) => applicant.Id != this.newApplicant?.Id,\r\n );\r\n this.applicantList.push(this.newApplicant); // Resets anything that is changed using the original data object\r\n }\r\n\r\n deleteApplicant(): void {\r\n this.dataLoading = true;\r\n this.dealClientService\r\n .markAsDeleteAndSetNextApplicantAsPrimary(\r\n this.dealDto.Id,\r\n this.confirmDeleteApplicant.Id,\r\n )\r\n .then((response) => {\r\n this.applicantList = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.confirmDeleteApplicant = {} as DealClientDTO;\r\n this.showDelete = false;\r\n });\r\n }\r\n\r\n deleteConfirmApplicant(applicant: DealClientDTO) {\r\n this.showDelete = true;\r\n this.confirmDeleteApplicant = { ...applicant };\r\n }\r\n\r\n nonUkWarningVisible(): boolean {\r\n return this.sharedDealService.nonUkWarningVisible(this.currentApplicant);\r\n }\r\n\r\n showInviteButton(shareholder: DealClientDTO) {\r\n return this.sharedDealService.showInviteButton(shareholder);\r\n }\r\n\r\n invite(applicant: DealClientDTO) {\r\n this.dataLoading = true;\r\n\r\n this.dealClientService\r\n .inviteApplicant(applicant.UniqueRef)\r\n .then((i) => {\r\n this.modal = true;\r\n this.message =\r\n \"A request has been sent to \" +\r\n applicant.Client.FirstName +\r\n \" \" +\r\n applicant.Client.LastName +\r\n \" complete their shareholder profile.\";\r\n })\r\n .catch((error) => {\r\n this.modal = true;\r\n this.message =\r\n \"There was a problem sending the invite request to \" +\r\n applicant.Client.FirstName +\r\n \" \" +\r\n applicant.Client.LastName +\r\n \". Please try again later.\";\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n //End of Profile view functions\r\n\r\n /** Show and hide the export menu */\r\n showAndHideExport() {\r\n this.showExport = !this.showExport;\r\n }\r\n\r\n //loanSaveDisabled() {\r\n\r\n // var selectFields = [];\r\n // if (this.dealDto.ProductType == ProductTypeEnum.BridgingPurchaseOrRefinance) {\r\n // selectFields = [\r\n // this.dealDto.AdditionalSecurity,\r\n // this.dealDto.ExitStrategy,\r\n // this.dealDto.InterestService,\r\n // this.dealDto.LoanTermReq,\r\n // this.dealDto.LoanPurpose,\r\n // ];\r\n // } else {\r\n // selectFields = [\r\n // this.dealDto.AdditionalSecurity,\r\n // this.dealDto.ExitStrategy,\r\n // this.dealDto.InterestService,\r\n // this.dealDto.SourceOfIncome,\r\n // this.dealDto.LoanPurpose,\r\n // this.dealDto.PlanningStatusAtStartOfLoan,\r\n // this.dealDto.PlanningStatusAtEndOfLoan\r\n // ];\r\n // }\r\n\r\n // if (this.loanDetailsForm.$invalid) return true;\r\n\r\n // if (this.dealDto.LoanPurpose && this.dealDto.LoanPurpose == LoanPurposeEnum.Other && this.dealDto.ProductType == ProductTypeEnum.BridgingPreconstruction) {\r\n // if (!this.dealDto.LoanPurposeDescription || this.dealDto.LoanPurposeDescription.length == 0) {\r\n // return true;\r\n // }\r\n // }\r\n\r\n // for (let i = 0; i < selectFields.length; i++) {\r\n // if (selectFields[i] === 0 || selectFields[i] === '0') {\r\n // return true;\r\n // }\r\n // }\r\n\r\n // return false;\r\n //}\r\n\r\n checkIfUserIsInvited() {\r\n //added to scope for directive\r\n this.dealService\r\n .checkIfUserIsInvited(this.currentUser.Id, this.dealId)\r\n .then((response: InvitedUserResponse) => {\r\n // if user has no active subscription (and are not a lender or admin) then they should be redirected back to the dashboard\r\n if (\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PaidUp &&\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PreCancel &&\r\n this.currentUser.SubscriptionStatus !=\r\n LicenseMasterStatusEnum.PaymentProcessing &&\r\n !response.IsInvited &&\r\n !this.isAdmin &&\r\n !this.isLender\r\n ) {\r\n this.$location.path(\"/dashboard\");\r\n return;\r\n }\r\n\r\n (this.$rootScope as any).isInvitedToCase = response.IsInvited;\r\n\r\n if (response.IsInvited) {\r\n if (response.DealAccessLevel == CaseAccessLevelEnum.ReadOnly) {\r\n (this.$rootScope as any).isInvitedAndHasReadonlyAccess = true;\r\n }\r\n }\r\n\r\n this.$rootScope.$broadcast(\"invitedStatusChange\");\r\n });\r\n }\r\n\r\n modifyDateForBackend(property: Date) {\r\n return this.sharedDealService.modifyDateForBackend(property);\r\n }\r\n\r\n modifyDateForFrontend(property: Date) {\r\n return this.sharedDealService.modifyDateForFrontend(property);\r\n }\r\n\r\n disablePersonalDetails() {\r\n return this.sharedDealService.disablePersonalDetails(\r\n this.currentApplicant,\r\n this.personalDetailsForm,\r\n );\r\n }\r\n\r\n goToUserDashboard() {\r\n this.authService.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n // Setting the dependent data when option are changed\r\n clearSearchdata() {\r\n this.dealDto = this.devFinanceDealService.clearSearchdata(this.dealDto);\r\n }\r\n\r\n datasetupOnOwnOrPurchaseChange() {\r\n this.dealDto = this.devFinanceDealService.datasetupOnOwnOrPurchaseChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnIsTenantedBuildingChange() {\r\n if (!this.dealDto.IsTenantedBuilding) this.leaseItems = null;\r\n this.dealDto =\r\n this.devFinanceDealService.datasetupOnIsTenantedBuildingChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n datasetupOnMaxLoanRequiredChange() {\r\n this.dealDto = this.dealService.dataSetupOnMaxLoanRequiredChange(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n onPropertyTabSelection() {\r\n if (this.dealDto) {\r\n this.selectedNavMenu = this.CaseDashboardTypeEnum.Property;\r\n\r\n this.propertyFiles = this.fileUpload.filter(\r\n (item) => item.Module === ModuleEnum.Property,\r\n );\r\n\r\n this.onTabSelection();\r\n }\r\n }\r\n\r\n discardDealData(form: ng.IFormController = null) {\r\n event.stopPropagation();\r\n if (form == this.propertyDetailsForm) {\r\n this.dealDto = JSON.parse(JSON.stringify(this.tempDealDto));\r\n this.PostCodeOptions = [];\r\n this.searchterm = null;\r\n } else {\r\n this.dealDto = JSON.parse(JSON.stringify(this.tempDealDto));\r\n }\r\n\r\n if (form) {\r\n form.$setPristine();\r\n form.$setUntouched();\r\n }\r\n }\r\n\r\n onLoanTabSelection() {\r\n if (this.dealDto) {\r\n this.selectedNavMenu = this.CaseDashboardTypeEnum.Loan;\r\n this.closeLoanTabs();\r\n this.onTabSelection();\r\n }\r\n }\r\n\r\n onPlanningTabSelection() {\r\n if (this.dealDto) {\r\n this.selectedNavMenu = this.CaseDashboardTypeEnum.Planning;\r\n this.onTabSelection();\r\n }\r\n }\r\n\r\n onBuildProcurementTabSelection() {\r\n if (this.dealDto) {\r\n this.selectedNavMenu = this.CaseDashboardTypeEnum.BuildProcurement;\r\n this.onTabSelection();\r\n }\r\n }\r\n\r\n onFurtherInfoTabSelection() {\r\n if (this.dealDto) {\r\n this.selectedNavMenu = this.CaseDashboardTypeEnum.FurtherInfo;\r\n this.onTabSelection();\r\n }\r\n }\r\n\r\n onTabSelection() {\r\n this.tempDealDto = JSON.parse(JSON.stringify(this.dealDto));\r\n }\r\n\r\n discardApplicantData(form: ng.IFormController) {\r\n event.stopPropagation();\r\n this.currentApplicant = JSON.parse(JSON.stringify(this.tempApplicant));\r\n form.$setPristine();\r\n form.$setUntouched();\r\n }\r\n\r\n onApplicantTabSelection(tab) {\r\n if (\r\n tab != \"trackRecord\" ||\r\n (tab == \"trackRecord\" && this.currentApplicant)\r\n ) {\r\n const str = tab;\r\n this.tabs[str] = !this.tabs[str];\r\n\r\n this.tempApplicant = JSON.parse(JSON.stringify(this.currentApplicant));\r\n }\r\n }\r\n\r\n onPropertySubTabSelection(tab) {\r\n const str = tab;\r\n this.proprtyTabs[str] = !this.proprtyTabs[str];\r\n this.onTabSelection();\r\n }\r\n\r\n onLoanSubTabSelection(tab) {\r\n const str = tab;\r\n this.loanTabs[str] = !this.loanTabs[str];\r\n this.onTabSelection();\r\n }\r\n\r\n carriageReturnCheck(event) {\r\n if (event.key === \"Enter\") {\r\n let position = event.target.selectionStart;\r\n if (this.newNote.NoteText) {\r\n this.newNote.NoteText = [\r\n this.newNote.NoteText.slice(0, position),\r\n \"\\n\",\r\n this.newNote.NoteText.slice(position),\r\n ].join(\"\");\r\n\r\n setTimeout(() => {\r\n event.target.setSelectionRange(position + 1, position + 1);\r\n }, 0);\r\n } else {\r\n this.newNote.NoteText = \"\\n\";\r\n }\r\n }\r\n }\r\n\r\n trustedHtml(plainText) {\r\n return this.$sce.trustAsHtml(plainText);\r\n }\r\n\r\n initialiseTitleAndTitleOption() {\r\n if (this.currentApplicant?.Profile) {\r\n const { Title, TitleOption } = this.currentApplicant.Profile;\r\n\r\n // If TitleOption has a value greater than 0, set Title to null\r\n if (\r\n (TitleOption > TitleEnum.None && TitleOption != TitleEnum.Other) ||\r\n Title == null\r\n ) {\r\n this.currentApplicant.Profile.Title = \"\";\r\n }\r\n // If Title exists and TitleOption is not set, set TitleOption to Other\r\n else if (Title && !TitleOption) {\r\n this.currentApplicant.Profile.TitleOption = TitleEnum.Other;\r\n }\r\n }\r\n }\r\n\r\n onTitleOptionChange() {\r\n const { TitleOption } = this.currentApplicant.Profile;\r\n\r\n if (TitleOption > 0 && TitleOption != TitleEnum.Other) {\r\n this.currentApplicant.Profile.Title = \"\";\r\n }\r\n }\r\n\r\n onIsMortgagedChange() {\r\n if (!this.dealDto.IsMortgaged) {\r\n this.dealDto.MortgageCurrentLender = null;\r\n this.dealDto.MortgageCurrentBalance = 0;\r\n }\r\n }\r\n\r\n goToLoanTypeSelectionPage() {\r\n if (this.isLoggedInUser) {\r\n this.authService.setHasValidStatustoShowShareSearchModal(\r\n true,\r\n );\r\n }\r\n this.$location.path(\"/allloans\");\r\n\r\n }\r\n\r\n propertySaveDisabled() {\r\n var commonFields = [\r\n this.dealDto.OwnOrPurchase,\r\n this.dealDto.Locations,\r\n this.dealDto.IsFamilyInResidence,\r\n this.dealDto.PropertyAddress.AddressLine1,\r\n this.dealDto.PropertyAddress.PostCode,\r\n this.dealDto.PurchasePrice,\r\n this.dealDto.StampDutyLandTax,\r\n this.dealDto.PurchaseLegalFees,\r\n this.dealDto.PayingVATOnLandPurchase,\r\n ];\r\n\r\n if (this.dealDto.IsMortgaged) {\r\n commonFields.push(this.dealDto.MortgageCurrentLender);\r\n commonFields.push(this.dealDto.MortgageCurrentLender);\r\n }\r\n\r\n if (this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Own) {\r\n commonFields.push(this.dealDto.Currentvalue);\r\n commonFields.push(this.dealDto.LandTotalOtherCosts);\r\n }\r\n\r\n if (this.dealDto.OwnOrPurchase == OwnOrPurchaseEnum.Purchasing) {\r\n commonFields.push(this.dealDto.PurchaseCosts);\r\n }\r\n\r\n if (this.dealDto.PayingVATOnLandPurchase === 1) {\r\n commonFields.push(this.dealDto.LandPurchaseVatAmount);\r\n }\r\n\r\n if (this.propertyDetailsForm && this.propertyDetailsForm.$invalid)\r\n return true;\r\n\r\n for (let i = 0; i < commonFields.length; i++) {\r\n if (\r\n commonFields[i] == null ||\r\n commonFields[i] == \"0\" ||\r\n commonFields[i] == \"\"\r\n ) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n planningSaveDisabled() {\r\n var selectFields = [\r\n this.dealDto.PlanningStatusAtEndOfLoan,\r\n this.dealDto.PlanningResponsibility,\r\n ];\r\n\r\n if (this.planningForm.$invalid) return true;\r\n\r\n for (let i = 0; i < selectFields.length; i++) {\r\n if (selectFields[i] === 0 || selectFields[i] === \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n buildProcurementSaveDisabled() {\r\n var selectFields = [this.dealDto.BuildProcurementType];\r\n\r\n if (this.buildProcurementForm.$invalid) return true;\r\n\r\n for (let i = 0; i < selectFields.length; i++) {\r\n if (selectFields[i] === 0 || selectFields[i] === \"0\") {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Convert LeaseDeatails JSON back to an array of LeaseDeatails objects\r\n * @param leaseItemsJson\r\n */\r\n parseLeaseDetails(leaseItems: string) {\r\n if (leaseItems != null && leaseItems.length > 0) {\r\n // JSON doesn't understand date types so therefore user the reviver function to manually convert them back to dates as opposed to strings\r\n this.leaseItems = JSON.parse(leaseItems, this.sharedDealService.reviver);\r\n }\r\n }\r\n\r\n initMortgageTerm() {\r\n this.dealDto.LoanTermReq = this.dealDto.LoanTermReq || 240;\r\n this.mortgageTerm = this.dealDto.LoanTermReq / 12;\r\n }\r\n\r\n mortgageTermToLoanTerm() {\r\n this.dealDto.LoanTermReq = this.mortgageTerm * 12;\r\n }\r\n\r\n onCurrentUseOfBuilding() {\r\n this.dealDto = this.devFinanceDealService.datasetupOnCurrentUseOfBuilding(\r\n this.dealDto,\r\n );\r\n }\r\n\r\n /**\r\n * Calculates the order number of all the preferences when one is toggled\r\n * @param toggledPreference\r\n */\r\n calculatePreferenceOrder(toggledPreference: string) {\r\n const preferenceNames = [\r\n \"SearchPreferenceLoanSize\",\r\n \"SearchPreferencePricing\",\r\n \"SearchPreferenceCompletionSpeed\",\r\n \"SearchPreferenceCustomerService\",\r\n ];\r\n // Finds the highest preference order of all preferences\r\n const maxPreferenceOrder = Math.max(\r\n this.dealDto.SearchPreferenceCompletionSpeed,\r\n this.dealDto.SearchPreferenceCustomerService,\r\n this.dealDto.SearchPreferenceLoanSize,\r\n this.dealDto.SearchPreferencePricing,\r\n );\r\n\r\n // If the preference that has been toggled already has a value greater than 0 then it is being turned OFF\r\n if (this.dealDto[toggledPreference] > 0) {\r\n // Find any preferences that have a higher preference number and decrease their order number by 1\r\n for (let preference of preferenceNames) {\r\n if (preference == toggledPreference) {\r\n continue;\r\n } else {\r\n if (this.dealDto[preference] > this.dealDto[toggledPreference]) {\r\n this.dealDto[preference]--;\r\n }\r\n }\r\n }\r\n\r\n this.dealDto[toggledPreference] = 0;\r\n } else {\r\n // Preference is being turned ON\r\n // Use the highest preference order number and increase by 1\r\n this.dealDto[toggledPreference] = maxPreferenceOrder + 1;\r\n }\r\n }\r\n\r\n CalcNDV(): number {\r\n if (this.dataLoading === false) {\r\n var gdv: number = 0;\r\n var sales: number = 0;\r\n\r\n if (this.dealDto.GDV) {\r\n gdv = Number(this.dealDto.GDV);\r\n }\r\n\r\n if (this.totalSalesCost) {\r\n sales = Number(this.totalSalesCost);\r\n }\r\n\r\n var ndv: number = Number(gdv - sales);\r\n\r\n if (ndv <= 0) {\r\n ndv = 0;\r\n }\r\n\r\n this.totalNetDevelopmentVal = ndv;\r\n return ndv;\r\n }\r\n }\r\n\r\n CalcTotalSalesCost(): number {\r\n if (this.dataLoading === false) {\r\n var res: number = 0;\r\n if (this.dealDto.SalesAgentFees) {\r\n res += Number(this.dealDto.SalesAgentFees);\r\n }\r\n if (this.dealDto.SalesLegalFees) {\r\n res += Number(this.dealDto.SalesLegalFees);\r\n }\r\n this.totalSalesCost = res;\r\n return res;\r\n }\r\n }\r\n\r\n CalcTotalPurchaseCosts(): number {\r\n var res: number = 0;\r\n if (this.dealDto.PurchasePrice) {\r\n res += Number(this.dealDto.PurchasePrice);\r\n }\r\n if (this.dealDto.StampDutyLandTax) {\r\n res += Number(this.dealDto.StampDutyLandTax);\r\n }\r\n if (this.dealDto.PurchaseLegalFees) {\r\n res += Number(this.dealDto.PurchaseLegalFees);\r\n }\r\n if (this.dealDto.PurchaseCosts) {\r\n res += Number(this.dealDto.PurchaseCosts);\r\n }\r\n\r\n if (this.dealDto.PayingVATOnLandPurchase === 1) {\r\n res += Number(this.dealDto.LandPurchaseVatAmount);\r\n }\r\n\r\n this.totalPurchaseCosts = res;\r\n return res;\r\n }\r\n\r\n onOwnOrPurchaseChange(OwnOrPurchase: boolean) {\r\n this.dealDto.OwnOrPurchase = this.dealDto.HasOwnOrPurchase\r\n ? OwnOrPurchaseEnum.Own\r\n : OwnOrPurchaseEnum.Purchasing;\r\n //TODO need a review for this function\r\n this.datasetupOnOwnOrPurchaseChange();\r\n }\r\n\r\n updateVatOnLandPurchase(PayingVATOnLandPurchase): void {\r\n this.dealDto.PayingVATOnLandPurchase = PayingVATOnLandPurchase;\r\n if (this.dealDto.PayingVATOnLandPurchase === 1) {\r\n //if yes, show vat amount question prepopulated with 20% of purchase price\r\n this.dealDto.LandPurchaseVatAmount = this.dealDto.PurchasePrice * 0.2;\r\n this.CalcTotalPurchaseCosts();\r\n }\r\n }\r\n\r\n toggleHasProfessionalCostsBreakdown(hasProfessionalCostsBreakdown: boolean) {\r\n this.dealDto.HasProfessionalCostsBreakdown = hasProfessionalCostsBreakdown;\r\n\r\n if (!this.dealDto.HasProfessionalCostsBreakdown) {\r\n this.dealDto.PlanningCosts = null;\r\n this.dealDto.ProjectManagementCosts = null;\r\n this.dealDto.S106CILCosts = null;\r\n this.dealDto.ClientQSCosts = null;\r\n this.dealDto.MechanicalEngineeringCosts = null;\r\n this.dealDto.StructuralEngineeringCosts = null;\r\n this.dealDto.PartyWallCosts = null;\r\n this.dealDto.WarrantyCosts = null;\r\n this.dealDto.LandscapingCosts = null;\r\n this.dealDto.OtherProfessionalCosts = null;\r\n this.dealDto.OtherProfessionalCostsDescription = \"\";\r\n }\r\n this.calculateTotalCosts();\r\n }\r\n\r\n calculateTotalCosts() {\r\n var totalCosts: number = 0;\r\n\r\n if (this.dealDto.HasProfessionalCostsBreakdown) {\r\n if (this.dealDto.PlanningCosts) {\r\n totalCosts += Number(this.dealDto.PlanningCosts);\r\n }\r\n\r\n if (this.dealDto.ProjectManagementCosts) {\r\n totalCosts += Number(this.dealDto.ProjectManagementCosts);\r\n }\r\n\r\n if (this.dealDto.S106CILCosts) {\r\n totalCosts += Number(this.dealDto.S106CILCosts);\r\n }\r\n\r\n if (this.dealDto.ClientQSCosts) {\r\n totalCosts += Number(this.dealDto.ClientQSCosts);\r\n }\r\n\r\n if (this.dealDto.MechanicalEngineeringCosts) {\r\n totalCosts += Number(this.dealDto.MechanicalEngineeringCosts);\r\n }\r\n\r\n if (this.dealDto.StructuralEngineeringCosts) {\r\n totalCosts += Number(this.dealDto.StructuralEngineeringCosts);\r\n }\r\n\r\n if (this.dealDto.PartyWallCosts) {\r\n totalCosts += Number(this.dealDto.PartyWallCosts);\r\n }\r\n\r\n if (this.dealDto.WarrantyCosts) {\r\n totalCosts += Number(this.dealDto.WarrantyCosts);\r\n }\r\n\r\n if (this.dealDto.LandscapingCosts) {\r\n totalCosts += Number(this.dealDto.LandscapingCosts);\r\n }\r\n\r\n if (this.dealDto.OtherProfessionalCosts) {\r\n totalCosts += Number(this.dealDto.OtherProfessionalCosts);\r\n }\r\n\r\n if (this.dealDto.DemolitionCosts) {\r\n totalCosts += Number(this.dealDto.DemolitionCosts);\r\n }\r\n } else {\r\n totalCosts += Number(this.dealDto.AdditionalOngoingCosts);\r\n }\r\n\r\n if (totalCosts != 0) this.totalBreakdownProfessionalCosts = totalCosts;\r\n\r\n this.totalProjectCosts =\r\n Number(this.totalBuildCosts) +\r\n totalCosts +\r\n Number(this.dealDto.PurchasePrice);\r\n\r\n if (this.dealDto.MarketingCosts) {\r\n this.totalProjectCosts += Number(this.dealDto.MarketingCosts);\r\n }\r\n }\r\n\r\n updateBuildArea(initial: boolean = false) {\r\n if (this.dealDto.AreaUnit == AreaUnitEnum.SquareFeet) {\r\n this.dealDto.BuildCostPerArea = this.buildCostPerSqFt;\r\n this.buildCostPerSqM = Number(\r\n this.convertSqFtToSqM(this.buildCostPerSqFt).toFixed(2),\r\n );\r\n } else {\r\n this.dealDto.BuildCostPerArea = this.buildCostPerSqM;\r\n this.buildCostPerSqFt = Number(\r\n this.convertSqMToSqFt(this.buildCostPerSqM).toFixed(2),\r\n );\r\n }\r\n if (!initial) {\r\n this.calculateBuildCostIntermediary();\r\n }\r\n }\r\n\r\n convertSqMToSqFt(costPerSqM: number): number {\r\n return costPerSqM / this.areaConversionFactor;\r\n }\r\n\r\n convertSqFtToSqM(costPerSqFt: number): number {\r\n return costPerSqFt * this.areaConversionFactor;\r\n }\r\n\r\n calculateBuildCostIntermediary() {\r\n if (\r\n this.dealDto.GrossInternalAreaKnown &&\r\n this.dealDto.BuildCostPerArea > 0 &&\r\n this.dealDto.AreaAcquisition > 0\r\n ) {\r\n this.buildCostIntermediary =\r\n this.dealDto.AreaAcquisition * this.dealDto.BuildCostPerArea;\r\n }\r\n this.calculateContingency();\r\n }\r\n\r\n updateGIA() {\r\n this.calculateBuildCostIntermediary();\r\n }\r\n\r\n updateContingency() {\r\n this.calculateContingency();\r\n }\r\n\r\n toggleKnowsGIA() {\r\n this.dealDto.GrossInternalAreaKnown = !this.dealDto.GrossInternalAreaKnown;\r\n if (this.dealDto.GrossInternalAreaKnown == true) {\r\n this.dealDto.AreaUnit = AreaUnitEnum.SquareFeet;\r\n } else {\r\n this.dealDto.AreaAcquisition = null;\r\n this.dealDto.AreaUnit = null;\r\n this.buildCostPerSqFt = null;\r\n this.buildCostPerSqM = null;\r\n this.dealDto.BuildCostPerArea = null;\r\n }\r\n\r\n this.buildCostIntermediary = null;\r\n this.buildCostsForm.buildCostIntermediary.$setUntouched();\r\n this.updateContingency();\r\n }\r\n\r\n calculateContingency() {\r\n if (this.dealDto.IncludesContingency) {\r\n this.contingencyValue =\r\n this.buildCostIntermediary -\r\n this.buildCostIntermediary / (1 + Number(this.dealDto.Contingency));\r\n } else {\r\n this.contingencyValue =\r\n this.buildCostIntermediary * this.dealDto.Contingency;\r\n }\r\n this.calculateTotalBuildCost();\r\n }\r\n\r\n calculateTotalBuildCost() {\r\n if (this.dealDto.IncludesContingency) {\r\n this.totalBuildCosts = this.buildCostIntermediary;\r\n this.dealDto.BuildCosts =\r\n Number(this.buildCostIntermediary) - this.contingencyValue;\r\n } else {\r\n this.totalBuildCosts =\r\n Number(this.buildCostIntermediary) + this.contingencyValue;\r\n this.dealDto.BuildCosts = Number(this.buildCostIntermediary);\r\n }\r\n\r\n this.calculateTotalCosts();\r\n }\r\n\r\n /** Schedule */\r\n showOrHideUnitTypeOptions() {\r\n this.showUnitTypeOptions = !this.showUnitTypeOptions;\r\n }\r\n\r\n onSelectingUnitType(unitType: ScheduleTypeEnum) {\r\n this.selectedUnitType = unitType;\r\n this.showUnitTypeOptions = false;\r\n this.newScheduleData = {\r\n DealId: this.dealDto.Id,\r\n ScheduleType: this.selectedUnitType,\r\n Tenure:\r\n this.selectedUnitType == ScheduleTypeEnum.Flat\r\n ? TenureEnum.Leasehold\r\n : TenureEnum.Freehold,\r\n } as DealScheduleDTO;\r\n }\r\n\r\n addnewScheduleData() {\r\n this.devFinanceScheduleService\r\n .addUpdate(this.newScheduleData)\r\n .then((newScheduleData) => {\r\n this.scheduleData.push(newScheduleData);\r\n this.prepareUnitData();\r\n this.newScheduleData = {\r\n DealId: this.dealDto.Id,\r\n } as DealScheduleDTO;\r\n this.developmentScheduleForm.$setPristine();\r\n this.showUnitTypeOptions = false;\r\n this.selectedUnitType = null;\r\n });\r\n }\r\n\r\n updateSelectedScheduleData(scheduleRow) {\r\n this.devFinanceScheduleService\r\n .addUpdate(scheduleRow)\r\n .then((scheduleRow) => {\r\n this.calculateScheduleUnitsTotalGDVAndArea();\r\n });\r\n }\r\n\r\n deleteSelectedScheduleData() {\r\n this.dataLoading = true;\r\n this.showScheduleUnitDeleteConfirmation = false;\r\n this.devFinanceScheduleService\r\n .markasdeleted(this.tempScheduleData.Id)\r\n .then((response) => {\r\n this.scheduleData = this.scheduleData.filter(\r\n (s) => s.Id != this.tempScheduleData.Id,\r\n );\r\n this.prepareUnitData();\r\n })\r\n .catch((error) => {\r\n this.showMessage(\"Sorry, something went wrong. Please try again.\");\r\n this.showSuccessorFailureMessage = true;\r\n })\r\n .finally(() => {\r\n this.tempScheduleData = null;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n closeAddSchduleDataForm() {\r\n this.showUnitTypeOptions = false;\r\n this.selectedUnitType = null;\r\n this.newScheduleData = {\r\n DealId: this.dealDto.Id,\r\n } as DealScheduleDTO;\r\n }\r\n\r\n getTenureText(tenureValue) {\r\n var value = null;\r\n switch (tenureValue) {\r\n case TenureEnum.Freehold:\r\n value = \"Freehold\";\r\n break;\r\n case TenureEnum.Leasehold:\r\n value = \"Leasehold\";\r\n break;\r\n case TenureEnum.Other:\r\n value = \"Other\";\r\n break;\r\n default:\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n calculatePricePerUnit(scheduleRow) {\r\n if (scheduleRow.SalesPrice != null && scheduleRow.Area != null) {\r\n return Number(scheduleRow.SalesPrice) / scheduleRow.Area;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n getDescriptionText(description) {\r\n var value = null;\r\n switch (description) {\r\n case ScheduleDescriptionTypeEnum.Bungalow:\r\n value = \"Bungalow\";\r\n break;\r\n case ScheduleDescriptionTypeEnum.Cottage:\r\n value = \"Cottage\";\r\n break;\r\n case ScheduleDescriptionTypeEnum.DetachedHouse:\r\n value = \"Detached house\";\r\n break;\r\n case ScheduleDescriptionTypeEnum.SemiDetachedHouse:\r\n value = \"Semi-detached house\";\r\n break;\r\n case ScheduleDescriptionTypeEnum.TerrancedHouse:\r\n value = \"Terranced house\";\r\n break;\r\n case ScheduleDescriptionTypeEnum.Duplex:\r\n value = \"Duplex\";\r\n break;\r\n case ScheduleDescriptionTypeEnum.SingleStorey:\r\n value = \"Single storey\";\r\n break;\r\n case ScheduleDescriptionTypeEnum.Triplex:\r\n value = \"Triplex\";\r\n break;\r\n case ScheduleDescriptionTypeEnum.Studio:\r\n value = \"Studio\";\r\n break;\r\n default:\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n getSelectedUnitTypeText(scheduleUnit) {\r\n var value = null;\r\n switch (scheduleUnit) {\r\n case ScheduleTypeEnum.Commercial:\r\n value = \"Commercial\";\r\n break;\r\n case ScheduleTypeEnum.House:\r\n value = \"Houses\";\r\n break;\r\n case ScheduleTypeEnum.Flat:\r\n value = \"Flats\";\r\n break;\r\n default:\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n getPreAgreementText(preAgreementType) {\r\n var value = null;\r\n switch (preAgreementType) {\r\n case PreAgreementEnum.PreLet:\r\n value = \"Pre-let\";\r\n break;\r\n case PreAgreementEnum.PreSold:\r\n value = \"Pre-sold\";\r\n break;\r\n case PreAgreementEnum.None:\r\n value = \"None\";\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n prepareUnitData() {\r\n this.calculateScheduleUnitsTotalGDVAndArea();\r\n this.houses = this.scheduleData.filter(\r\n (s) => s.ScheduleType == ScheduleTypeEnum.House,\r\n );\r\n this.parking = this.scheduleData.filter(\r\n (s) => s.ScheduleType == ScheduleTypeEnum.Parking,\r\n );\r\n this.flats = this.scheduleData.filter(\r\n (s) => s.ScheduleType == ScheduleTypeEnum.Flat,\r\n );\r\n this.commercial = this.scheduleData.filter(\r\n (s) => s.ScheduleType == ScheduleTypeEnum.Commercial,\r\n );\r\n }\r\n\r\n getHouseOrFlatDescriptionOptions(selectedUnitType) {\r\n if (selectedUnitType == ScheduleTypeEnum.House) {\r\n return this.houseDescriptionTypeOptions;\r\n }\r\n\r\n if (selectedUnitType == ScheduleTypeEnum.Flat) {\r\n return this.flatDescriptionTypeOptions;\r\n }\r\n }\r\n\r\n calculateScheduleUnitsTotalGDVAndArea() {\r\n if (this.scheduleData.length > 0) {\r\n if (this.dealDto.EndPropertyType == PropertyTypeEnum.Residential) {\r\n this.totalScheduleUnitsGDV = this.scheduleData\r\n .filter(\r\n (s) =>\r\n s.ScheduleType == ScheduleTypeEnum.House ||\r\n s.ScheduleType == ScheduleTypeEnum.Flat,\r\n )\r\n .map((i) => Number(i.SalesPrice))\r\n .reduce((a, b) => a + b, 0);\r\n this.totalScheduleUnitsArea = this.scheduleData\r\n .filter(\r\n (s) =>\r\n s.ScheduleType == ScheduleTypeEnum.House ||\r\n s.ScheduleType == ScheduleTypeEnum.Flat,\r\n )\r\n .map((i) => Number(i.Area))\r\n .reduce((a, b) => a + b, 0);\r\n } else if (\r\n this.dealDto.EndPropertyType == PropertyTypeEnum.MixedUse ||\r\n this.dealDto.EndPropertyType == PropertyTypeEnum.HMO\r\n ) {\r\n this.totalScheduleUnitsGDV = this.scheduleData\r\n .map((i) => Number(i.SalesPrice))\r\n .reduce((a, b) => a + b, 0);\r\n this.totalScheduleUnitsArea = this.scheduleData\r\n .map((i) => Number(i.Area))\r\n .reduce((a, b) => a + b, 0);\r\n } else {\r\n this.totalScheduleUnitsGDV = this.scheduleData\r\n .filter((s) => s.ScheduleType == ScheduleTypeEnum.Commercial)\r\n .map((i) => Number(i.SalesPrice))\r\n .reduce((a, b) => a + b, 0);\r\n this.totalScheduleUnitsArea = this.scheduleData\r\n .filter((s) => s.ScheduleType == ScheduleTypeEnum.Commercial)\r\n .map((i) => Number(i.Area))\r\n .reduce((a, b) => a + b, 0);\r\n }\r\n }\r\n }\r\n\r\n onClickOfEditScheduleData(selectedRow) {\r\n this.tempScheduleData = { ...selectedRow };\r\n }\r\n\r\n onClickOfDeleteScheduleData(selectedRow) {\r\n this.tempScheduleData = { ...selectedRow };\r\n this.showScheduleUnitDeleteConfirmation = true;\r\n }\r\n\r\n getFilesByModule(module) {\r\n if (module == ModuleEnum.Track) {\r\n return this.fileUpload.filter(\r\n (item) =>\r\n item.Module === module &&\r\n item.DealClientId == this.currentApplicant.Id,\r\n );\r\n } else {\r\n return this.fileUpload.filter((item) => item.Module === module);\r\n }\r\n }\r\n\r\n isPropertySectionValid() {\r\n var message = \"\";\r\n this.isPropertySectionInvalidToSave = false;\r\n if (\r\n this.propertyDetailsForm &&\r\n this.propertyDetailsForm.$dirty &&\r\n this.propertyDetailsForm.$invalid\r\n ) {\r\n message = \"Property\";\r\n this.isPropertySectionInvalidToSave = true;\r\n }\r\n\r\n if (\r\n this.buildCostsForm &&\r\n this.buildCostsForm.$dirty &&\r\n this.buildCostsForm.$invalid\r\n ) {\r\n message = message ? `${message} , Build Costs` : \"Build Costs\";\r\n this.isPropertySectionInvalidToSave = true;\r\n }\r\n\r\n if (this.salesForm && this.salesForm.$dirty && this.salesForm.$invalid) {\r\n message = message ? `${message} , Sales` : \"Sales\";\r\n this.isPropertySectionInvalidToSave = true;\r\n }\r\n\r\n if (\r\n this.planningForm &&\r\n this.planningForm.$dirty &&\r\n this.planningForm.$invalid\r\n ) {\r\n message = message ? `${message} , Planning` : \"Planning\";\r\n this.isPropertySectionInvalidToSave = true;\r\n }\r\n\r\n if (\r\n this.buildProcurementForm &&\r\n this.buildProcurementForm.$dirty &&\r\n this.buildProcurementForm.$invalid\r\n ) {\r\n message = message\r\n ? `${message} , Build Procurement`\r\n : \"Build Procurement\";\r\n this.isPropertySectionInvalidToSave = true;\r\n }\r\n\r\n return `Please correct values in ${message} section.`;\r\n }\r\n\r\n updateGDV() {\r\n //Storing a below value so that we can revert the values on dealDto when addUpdatereturnonlyid fails.\r\n this.tempGDV = this.dealDto.GDV;\r\n this.tempAreaAcquisition = this.dealDto.AreaAcquisition;\r\n this.dealDto.GDV = this.totalScheduleUnitsGDV;\r\n this.updateDealDto(\"GDV has been updated successfully\");\r\n }\r\n\r\n updateGIAToTotalScheduleUnitsArea() {\r\n //Storing a below value so that we can revert the values on dealDto when addUpdatereturnonlyid fails.\r\n this.tempGDV = this.dealDto.GDV;\r\n this.tempAreaAcquisition = this.dealDto.AreaAcquisition;\r\n this.dealDto.AreaAcquisition = this.totalScheduleUnitsArea;\r\n this.updateDealDto(\"Area/GIA has been updated successfully\");\r\n }\r\n\r\n updateHasPropertyScheduleBreakdownVal() {\r\n this.updateDealDto();\r\n }\r\n\r\n updateDealDto(successmessage: string = \"\") {\r\n this.dataLoading = false;\r\n this.devFinanceDealService\r\n .addUpdatereturnonlyid(this.dealDto)\r\n .then((dealId) => {\r\n if (successmessage.length > 0) {\r\n this.showMessage(successmessage);\r\n this.showSuccessorFailureMessage = true;\r\n }\r\n })\r\n .catch((error) => {\r\n if (successmessage.length > 0) {\r\n this.dealDto.GDV = this.tempGDV;\r\n this.dealDto.AreaAcquisition = this.tempAreaAcquisition;\r\n }\r\n this.showMessage(\"Sorry, something went wrong. Please try again.\");\r\n this.showSuccessorFailureMessage = true;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n updateClassUses() {\r\n if (this.dealDto.ClassUses > 0) {\r\n for (let i = 1; i < this.dealDto.ClassUses; i *= 2) {\r\n if (this.dealDto.ClassUses >= i) {\r\n //number is in enum sum, add it to object\r\n if (this.dealDto.ClassUses & i) {\r\n this.classUses[i] = true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n //watch and update classuses\r\n this.$scope.$watchCollection(\"ctrl.classUses\", (newVal: {}) => {\r\n let valuesList = Object.keys(newVal);\r\n let total: number = 0;\r\n //tot up all the numeric keys (class use enums)\r\n valuesList.forEach((v, i) => {\r\n let keyToNum = Number(v);\r\n if (newVal[keyToNum]) {\r\n total += keyToNum;\r\n }\r\n });\r\n this.dealDto.ClassUses = total;\r\n });\r\n }\r\n\r\n getOrganisationbyDealId() {\r\n this.organisationService\r\n .getOrganisationAndBrokerByDealId(this.dealDto.Id)\r\n .then((response) => {\r\n this.org = response.Organisation;\r\n this.dealBrokerUser = response.Broker;\r\n this.brokerCommission =\r\n this.dealDto.Status == CaseStatusEnum.NewCase\r\n ? this.org?.CommissionPercent\r\n : this.dealDto.BrokerCommissionPercent;\r\n this.brokerPreferredContact =\r\n this.dealDto.Status == CaseStatusEnum.NewCase\r\n ? response.Broker.PhoneNumber\r\n : this.dealDto.BrokerPhoneNumber;\r\n if (this.org.IsWhiteLabelled) {\r\n this.fileNamePrefix = this.org.Name.replace(/ /g, \"_\");\r\n } else {\r\n this.fileNamePrefix = \"Brickflow\";\r\n }\r\n });\r\n }\r\n\r\n updateRequestAssitanceDealNoteMessage() {\r\n if (this.dealDto?.DealNotes != null && this.currentUser != null) {\r\n this.dealDto.DealNotes = this.dealDto.DealNotes.map((d) => {\r\n if (\r\n d.UserId != this.currentUser.Id &&\r\n (d.NoteText == \"Your have requested for assistance.\" ||\r\n d.NoteText == \"You have requested assistance.\")\r\n ) {\r\n return { ...d, NoteText: `${d.UserFullName} requested assistance.` };\r\n }\r\n\r\n return d;\r\n });\r\n }\r\n }\r\n\r\n getOwnershipPercentageText() {\r\n if (this.dealDto != null) {\r\n return this.sharedDealService.getOwnershipPercentageText(\r\n this.currentApplicant,\r\n this.dealDto.ProductType,\r\n );\r\n }\r\n return \"Shareholding\";\r\n }\r\n\r\n closeSubmitToLenderModal() {\r\n this.showTsAndCs = false;\r\n this.brokerCommission =\r\n this.dealDto.Status == CaseStatusEnum.NewCase\r\n ? this.org?.CommissionPercent\r\n : this.dealDto.BrokerCommissionPercent;\r\n this.brokerPreferredContact =\r\n this.dealDto.Status == CaseStatusEnum.NewCase\r\n ? this.dealBrokerUser?.PhoneNumber\r\n : this.dealDto.BrokerPhoneNumber;\r\n this.isBrokerPhoneNumberUpdated = false;\r\n }\r\n\r\n isCompanyAndOwnershipSaveDisabled() {\r\n return this.dealDto.HowWillYouOwnNewDevelopment == null ||\r\n this.dealDto.HowWillYouOwnNewDevelopment <= 0\r\n ? true\r\n : false;\r\n }\r\n\r\n showBasedOnMainResidence() {\r\n return this.dealService.showBasedOnMainResidence(this.dealDto);\r\n }\r\n\r\n checkBrokerDeal() {\r\n return this.dealDto?.BrokerUserId != null && this.isClient ? true : false;\r\n }\r\n\r\n goToUserDashboardEquityAndMezz() {\r\n this.userDashboardService.setGoToNavMenu(5);\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n hasMaximumApplicants() {\r\n return this.applicantList.filter(a => a.IsApplicant).length >= 4 ? true : false;;\r\n }\r\n\r\n getRequiredRolesOptions() {\r\n return this.dealService.getRequiredRolesOptions(true, this.isReadOnlyDeal);\r\n }\r\n\r\n generateCaseStatusText() {\r\n if (this.isLender) {\r\n this.caseStatusOptions = this.selectListService.GetCaseLenderStateOptionsForLenders();\r\n }\r\n else {\r\n this.caseStatusOptions = this.selectListService.GetCaseStatusOptions(this.currentUser && this.currentUser.IsConnectUser);\r\n }\r\n this.getCaseStatusDisplayText();\r\n\r\n }\r\n\r\n showEditDealNameButton() {\r\n if (!this.isReadOnlyDeal && (!this.currentUser?.IsConnectUser || (this.currentUser?.IsConnectUser && !this.dealDto.IsReferredToConnect))) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n logExportDownload(eventName) {\r\n this.eventLogService.logEvent(\r\n eventName,\r\n EventLogEnum.Export,\r\n this.dealDto.ProductType,\r\n this.dealDto.Id,\r\n );\r\n }\r\n\r\n getTinymceOptions = function () {\r\n return this.isLender || this.isReadOnlyDeal ? this.tinymceReadonlyOptions : this.tinymceOptions;\r\n };\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { DealFileAttachmentDTO } from \"@js/DTO/Deal/DealFileAttachmentDTO.cs.d\";\r\nimport { DealLenderDTO } from \"@js/DTO/Deal/DealLenderDTO.cs.d\";\r\nimport { DealLenderMessageDTO } from \"@js/DTO/Deal/DealLenderMessageDTO.cs.d\";\r\nimport { DevelopmentFinanceDealDTO } from \"@js/DTO/Deal/DevelopmentFinanceDealDTO.cs.d\";\r\nimport { FeedBackDTO } from \"@js/DTO/FeedBackDTO.cs.d\";\r\nimport { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { BridgingSubmitOfferRequest } from \"@js/DTO/Messages/Deal/BridgingSubmitOfferMessage.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { InterestRateTypeEnum } from \"@js/models/enum/InterestRateTypeEnum.cs.d\";\r\nimport { MessageRoleEnum } from \"@js/models/enum/MessageRoleEnum.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { DealLenderMessageService } from \"@js/services/Deal/DealLenderMessageService\";\r\nimport { DealLenderService } from \"@js/services/Deal/DealLenderService\";\r\nimport { DevFinanceDealService } from \"@js/services/Deal/DevFinanceDealService\";\r\nimport { SharedHeadsOfTermsService } from \"@js/services/Deal/SharedHeadsOfTermsService\";\r\nimport { DealFileAttachmentService } from \"@js/services/DealFileAttachmentService\";\r\nimport { FeedBackService } from \"@js/services/FeedBackService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class DevFinanceHeadsOfTermsController {\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"LenderService\",\r\n \"RoleService\",\r\n \"DealLenderMessageService\",\r\n \"DealFileAttachmentService\",\r\n \"$window\",\r\n \"DevFinanceDealService\",\r\n \"DealLenderService\",\r\n \"SelectListService\",\r\n \"FeedBackService\",\r\n \"UserService\",\r\n \"AuthService\",\r\n \"ProductService\",\r\n \"SharedHeadsOfTermsService\"\r\n ];\r\n\r\n dataLoading: boolean = false; // Controls showing the data loading \"spinner\"\r\n dealLenders: DealLenderDTO[];\r\n showInformationMessage: boolean = false;\r\n messageContent: string;\r\n\r\n showDirection: boolean = false;\r\n\r\n toggleFeedbackSection: boolean = false;\r\n toggleHoTDetailSection: boolean = false;\r\n toggleRejectSection: boolean = false;\r\n toggleWithdrawSection: boolean = false;\r\n currentUser: ApplicationUserDTO = {} as ApplicationUserDTO;\r\n isLender: boolean = false;\r\n isBroker: boolean = false;\r\n isAdmin: boolean = false;\r\n isClient: boolean = false;\r\n\r\n // show different sections to Lender based on which button clicked on Case Dashboard\r\n showFeedbackSectionLender: boolean = false;\r\n showHoTDetailSectionLender: boolean = false;\r\n showRejectSectionLender: boolean = false;\r\n showWithdrawSectionLender: boolean = false;\r\n\r\n showTsAndCsModal: boolean = false;\r\n showTsAndCsForm: boolean = false;\r\n sendingMessage: boolean = false;\r\n goToUserDashboard: boolean = false;\r\n\r\n currentDeal: DevelopmentFinanceDealDTO;\r\n currentCaseLender: DealLenderDTO;\r\n InterestRateTypeOptions = [];\r\n\r\n lenderTask: string = \"\";\r\n\r\n isRejectClicked: boolean = false;\r\n isWithdrawClicked: boolean = false;\r\n isConfirmClicked: boolean = false;\r\n isSubmitClicked: boolean = false;\r\n\r\n //Lender Message\r\n newChatMessage: string = \"\";\r\n showFullMessageId: number;\r\n\r\n //files\r\n fileUpload: DealFileAttachmentDTO[];\r\n uploadingFiles: FileUploadProgressDTO[];\r\n openModal: boolean = false;\r\n module = ModuleEnum.DIP;\r\n\r\n showFullLenderMessage = false;\r\n showFullBorrowerMessage = false;\r\n showAutofill: boolean = false;\r\n\r\n //Lender/Broker feedback properties\r\n showLenderFeedBackModal: boolean = false;\r\n showBrokerFeedBackModal: boolean = false;\r\n feedBackDTO: FeedBackDTO;\r\n prevPath: string;\r\n brokerName: string;\r\n brokerOrganisationName: string;\r\n lendingForm: ng.IFormController;\r\n\r\n //Deleteing a chat message\r\n selectedDealLenderMessageDto: DealLenderMessageDTO;\r\n showdeleteChatMessageModal: boolean = false;\r\n showConfirmDeleteButton: boolean = false;\r\n\r\n grossLoanCalcVal: number = 0;\r\n builLoanCalcVal: number = 0;\r\n landLoanCalcVal: number = 0;\r\n isDevFinance: boolean = true;\r\n\r\n productTypeText: string = null;\r\n noLenderOrMoreLenderError:boolean = false;\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private lenderService: LenderService,\r\n private roleService: RoleService,\r\n private dealLenderMessageService: DealLenderMessageService,\r\n private dealFileAttachmentService: DealFileAttachmentService,\r\n private $window: ng.IWindowService,\r\n private devFinanceDealService: DevFinanceDealService,\r\n private dealLenderService: DealLenderService,\r\n private selectListService: SelectListService,\r\n private feedBackService: FeedBackService,\r\n private userService: UserService,\r\n private $auth: AuthService,\r\n private productService: ProductService, \r\n private sharedHeadsOfTermsService :SharedHeadsOfTermsService\r\n ) {\r\n this.userService.getUserAutofill().then((response) => {\r\n this.showAutofill = response;\r\n });\r\n\r\n this.feedBackDTO = {} as FeedBackDTO;\r\n\r\n if (\r\n this.$routeParams.openModule &&\r\n this.$routeParams.openModule == \"withdraw\"\r\n ) {\r\n this.toggleWithdrawSection = true;\r\n } else if (\r\n this.$routeParams.openModule &&\r\n this.$routeParams.openModule == \"reject\"\r\n ) {\r\n this.toggleRejectSection = true;\r\n } else if (this.$routeParams.openModule) {\r\n this.toggleFeedbackSection = true;\r\n }\r\n\r\n if (this.$routeParams.DealId && this.$routeParams.DealLenderId) {\r\n this.dataLoading = true;\r\n\r\n this.devFinanceDealService\r\n .fetch(this.$routeParams.DealId)\r\n .then((response) => {\r\n this.currentDeal = response;\r\n if (this.currentDeal) {\r\n this.dealLenderService\r\n .fetchByDealId(\r\n this.$routeParams.DealId,\r\n this.roleService.getIsLenderVisible(),\r\n this.$routeParams.DealLenderId,\r\n )\r\n .then((response) => {\r\n this.dealLenders = response;\r\n if (this.$routeParams.DealLenderId) {\r\n if (this.dealLenders.length != 1) {\r\n this.noLenderOrMoreLenderError = true;\r\n return;\r\n }\r\n this.currentCaseLender = this.dealLenders[0];\r\n\r\n this.fileUpload = this.currentDeal.Attachments.filter((f) => {\r\n return f.DealLenderId == this.$routeParams.DealLenderId;\r\n });\r\n this.calculateGrossLoanValVal();\r\n this.calculateBuildLoadCalcVal();\r\n this.calculateLandLoanCalcVal();\r\n }\r\n }).finally(() => {\r\n this.populateLenderInformation(this.currentUser)\r\n });\r\n\r\n this.lenderTask = sessionStorage.getItem(\"lenderTask\");\r\n if (this.lenderTask != null && this.lenderTask.length > 0) {\r\n switch (this.lenderTask) {\r\n case \"reject\":\r\n this.showRejectSectionLender = true;\r\n break;\r\n case \"withdraw\":\r\n this.showWithdrawSectionLender = true;\r\n break;\r\n case \"feedback\":\r\n this.showFeedbackSectionLender = true;\r\n this.updateCaseLenderMessageReadDatetime();\r\n break;\r\n case \"terms\":\r\n this.showHoTDetailSectionLender = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n this.productTypeText = this.productService.getProductTypeFullName(\r\n this.currentDeal.ProductType,\r\n );\r\n } else {\r\n if ((this.$rootScope as any).selectedUser) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.getCurrentUserAndRoles();\r\n });\r\n }\r\n\r\n this.InterestRateTypeOptions = this.selectListService.GetInterestRateType();\r\n }\r\n\r\n /*checkingIfUserIsLender() {\r\n this.roleService.isLenderUser().then(response => {\r\n this.isLender = response;\r\n });\r\n }\r\n\r\n checkingIfUerIsBroker() {\r\n this.dataLoading = true;\r\n this.roleService.isBroker().then((response) => {\r\n this.isBroker = response;\r\n }).finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkingIfUserIsAdmin() {\r\n this.dataLoading = true;\r\n this.roleService.isAdminUser().then((response) => {\r\n this.isAdmin = response;\r\n }).finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkingIfUserIsClient() {\r\n this.dataLoading = true;\r\n this.roleService.isClientUser().then((response) => {\r\n this.isClient = response;\r\n }).finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }*/\r\n\r\n /** Redirects to the case dashboard */\r\n goToCaseDashboard() {\r\n this.showFeedbackSectionLender = false;\r\n this.showHoTDetailSectionLender = false;\r\n this.showRejectSectionLender = false;\r\n this.showWithdrawSectionLender = false;\r\n if (\r\n this.isBroker && this.currentCaseLender && \r\n !this.currentCaseLender.IsLenderReviewComplete &&\r\n (this.currentCaseLender.Status == CaseLenderStateEnum.Offered ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Rejected ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Withdrawn)\r\n ) {\r\n this.prevPath = \"devfinancecasedashboard\";\r\n this.feedBackDTO.IsLenderFeedback = true;\r\n this.showLenderFeedBackModal = true;\r\n } else {\r\n this.$location.path(\"/devfinancecasedashboard/\" + this.currentDeal.Id);\r\n }\r\n }\r\n\r\n /** Close modal after send feedback */\r\n closeModal() {\r\n this.showDirection = false;\r\n this.showTsAndCsModal = false;\r\n this.showInformationMessage = false;\r\n this.isConfirmClicked = false;\r\n this.showdeleteChatMessageModal = false;\r\n if (this.goToUserDashboard) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n this.goToUserDashboard = false;\r\n this.showFeedbackSectionLender = false;\r\n this.showHoTDetailSectionLender = false;\r\n this.showRejectSectionLender = false;\r\n this.showWithdrawSectionLender = false;\r\n }\r\n\r\n if (this.prevPath) {\r\n if (this.isLender) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n } else {\r\n this.$location.path(`/${this.prevPath}/${this.currentDeal.Id}`);\r\n }\r\n }\r\n }\r\n\r\n goToLending() {\r\n if (\r\n this.isBroker && this.currentCaseLender &&\r\n !this.currentCaseLender.IsLenderReviewComplete &&\r\n (this.currentCaseLender.Status == CaseLenderStateEnum.Offered ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Rejected ||\r\n this.currentCaseLender.Status == CaseLenderStateEnum.Withdrawn)\r\n ) {\r\n this.prevPath = \"dealforum\";\r\n this.feedBackDTO.IsLenderFeedback = true;\r\n this.showLenderFeedBackModal = true;\r\n } else {\r\n this.$location.path(\"/dealforum/\" + this.currentDeal.Id);\r\n }\r\n }\r\n\r\n saveUpdatedCaseLender(): void {\r\n this.dealLenderService\r\n .addUpdate(this.currentCaseLender)\r\n .then((response) => {\r\n this.currentCaseLender = response;\r\n this.messageContent = \"Your changes have been saved.\";\r\n this.showInformationMessage = true;\r\n });\r\n }\r\n\r\n dummyDIP() {\r\n this.dealLenderService.dummyDIP(this);\r\n }\r\n\r\n /** Process the Reject button being clicked*/\r\n rejectClicked(): void {\r\n this.isRejectClicked = true;\r\n this.dealLenderService\r\n .rejectCase(this.currentCaseLender)\r\n .then((response) => {\r\n this.currentCaseLender.Status = response.CaseLenderState;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.messageContent =\r\n \"The borrower has been notified you have rejected their application.\";\r\n })\r\n .catch((error) => {\r\n this.messageContent = \"Sorry, something went wrong. Please try again.\";\r\n this.isRejectClicked = false;\r\n })\r\n .finally(() => {\r\n this.goToUserDashboard = true;\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentDeal.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n });\r\n }\r\n\r\n ///**Process the Withdraw button being clicked */\r\n withdrawClicked(): void {\r\n this.isWithdrawClicked = true;\r\n this.dealLenderService\r\n .withdrawHoT(this.currentCaseLender)\r\n .then((response) => {\r\n this.currentCaseLender.Status = response.CaseLenderState;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.messageContent =\r\n \"The borrower has been notified you have withdrawn terms for their application.\";\r\n })\r\n .catch((error) => {\r\n this.messageContent = \"Sorry, something went wrong. Please try again.\";\r\n this.isWithdrawClicked = false;\r\n })\r\n .finally(() => {\r\n this.goToUserDashboard = true;\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentDeal.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n });\r\n }\r\n\r\n ///**Process the Submit button being clicked */\r\n submitClicked() {\r\n this.isConfirmClicked = true;\r\n this.showTsAndCsModal = true;\r\n }\r\n\r\n ///**Heads of Terms Submit button clicked event */\r\n submitHoTClicked() {\r\n // Close the Heads of Terms' Terms and Conditions modal\r\n this.showTsAndCsModal = false;\r\n this.sendingMessage = true;\r\n\r\n var request = {\r\n dealLender: this.currentCaseLender,\r\n dealLenderStatus: this.currentCaseLender.Status,\r\n } as BridgingSubmitOfferRequest;\r\n\r\n // Submit the Heads of Terms\r\n this.dealLenderService\r\n .submitOffer(request)\r\n .then((response) => {\r\n this.currentCaseLender.Status = response.dealLenderStatus;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.messageContent =\r\n \"Thank you for submitting a Decision in Principle.\";\r\n this.goToUserDashboard = true;\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while submitting your Decision in Principle. Please try again.\";\r\n this.isConfirmClicked = false;\r\n })\r\n .finally(() => {\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentDeal.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n this.sendingMessage = false;\r\n });\r\n }\r\n\r\n /**\r\n * Process the Send Feedback button being clicked\r\n * @param message\r\n */\r\n sendChatMessage() {\r\n this.dataLoading = true;\r\n let DealChatMessage = {\r\n Message: this.newChatMessage,\r\n DealId: this.$routeParams.DealId,\r\n DealLenderId: this.$routeParams.DealLenderId,\r\n SenderRole: this.getSenderMessageRole(),\r\n RecipientRoles: this.isLender ? 10 : 4,\r\n } as DealLenderMessageDTO;\r\n\r\n this.dealLenderMessageService\r\n .addUpdate(DealChatMessage)\r\n .then((dealChatMessageResponse) => {\r\n this.currentCaseLender.DealLenderMessage.push(dealChatMessageResponse);\r\n this.newChatMessage = null;\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while sending feedback. Please try again.\";\r\n }).finally(() =>{\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n showFullChatMessage(index) {\r\n this.showFullMessageId = index;\r\n }\r\n\r\n updateCaseLenderMessageReadDatetime() {\r\n this.dealLenderMessageService\r\n .updateDealLenderMessageReadDatetime(this.$routeParams.DealLenderId)\r\n .then((caseLenderMessageResponse) => { });\r\n }\r\n\r\n onFileSelect(files: FileAttachmentDTO[], module: ModuleEnum) {\r\n if (files.length > 0) {\r\n this.dealFileAttachmentService\r\n .UploadFileListInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.$routeParams.DealId,\r\n this.fileUpload,\r\n module,\r\n this.$routeParams.DealLenderId,\r\n )\r\n .then((result) => {\r\n this.openModal = false;\r\n });\r\n }\r\n }\r\n\r\n downloadFile(file: DealFileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.dealFileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n this.$window.open(uri);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n deleteFile(file: DealFileAttachmentDTO) {\r\n this.fileUpload.splice(this.fileUpload.indexOf(file), 1);\r\n this.dealFileAttachmentService.markasdeleted(file.Id).then((result) => { }); //remove on the server\r\n }\r\n\r\n showActionButtons() {\r\n if (this.currentCaseLender && (this.currentCaseLender.Status == CaseLenderStateEnum.Received || this.currentCaseLender.Status == CaseLenderStateEnum.Rejected || this.currentCaseLender.Status == CaseLenderStateEnum.Offered || this.currentCaseLender.Status == CaseLenderStateEnum.Cancelled || this.currentCaseLender.Status == CaseLenderStateEnum.Withdrawn)) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n addClass(star: number, id: string) {\r\n this.feedBackService.addClass(star, id);\r\n }\r\n\r\n removeClass(star: number, id: string, rating) {\r\n this.feedBackService.removeClass(star, id, rating);\r\n }\r\n\r\n isFeedBackFormDisabled() {\r\n return this.feedBackService.isFeedBackFormDisabled(\r\n this.isLender,\r\n this.feedBackDTO,\r\n );\r\n }\r\n\r\n updateRating(star, rating) {\r\n this.feedBackDTO = this.feedBackService.updateRating(\r\n star,\r\n rating,\r\n this.feedBackDTO,\r\n );\r\n }\r\n\r\n submitFeedBack() {\r\n if (this.isLender) {\r\n this.feedBackDTO.OrganisationId = this.currentDeal.BrokerOrganisationId;\r\n this.feedBackDTO.BrokerUserId = this.currentDeal.BrokerUserId;\r\n } else {\r\n this.feedBackDTO.LenderId = this.currentCaseLender.LenderId;\r\n }\r\n\r\n this.feedBackService\r\n .addFeedBack(this.feedBackDTO, this.currentCaseLender.Id, true)\r\n .then((response) => {\r\n if (this.isLender) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n } else {\r\n this.$location.path(`/${this.prevPath}/${this.currentDeal.Id}`);\r\n }\r\n });\r\n }\r\n\r\n showBrokerFeedBack() {\r\n this.feedBackDTO.IsBrokerFeedback = true;\r\n this.showBrokerFeedBackModal = true;\r\n }\r\n\r\n onClickDeleteMessageButton(message: DealLenderMessageDTO) {\r\n this.showdeleteChatMessageModal = true;\r\n this.messageContent = \"Are you sure you want to delete a selected message?\";\r\n this.selectedDealLenderMessageDto = message;\r\n this.showConfirmDeleteButton = true;\r\n }\r\n\r\n deleteChatMessage() {\r\n this.dataLoading = true;\r\n this.dealLenderMessageService\r\n .markasdeleted(this.selectedDealLenderMessageDto.Id)\r\n .then((response) => {\r\n this.currentCaseLender.DealLenderMessage =\r\n this.currentCaseLender.DealLenderMessage.filter(\r\n (x) => x.Id != this.selectedDealLenderMessageDto.Id,\r\n );\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while deleting message. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.showdeleteChatMessageModal = false;\r\n delete this.selectedDealLenderMessageDto;\r\n this.showConfirmDeleteButton = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n /**Calculate the Total Net Loan */\r\n calculateTotalNetLoan() {\r\n var totalNetLoan: number = 0;\r\n if (\r\n this.currentCaseLender &&\r\n this.currentCaseLender.BuildLoan &&\r\n this.currentCaseLender.LandLoan\r\n ) {\r\n totalNetLoan =\r\n +this.currentCaseLender.BuildLoan + +this.currentCaseLender.LandLoan;\r\n totalNetLoan = Math.round(totalNetLoan * 100) / 100;\r\n }\r\n return totalNetLoan;\r\n }\r\n\r\n /**Calculate total lender costs */\r\n totalLenderCosts() {\r\n var lenderCosts: number = 0;\r\n\r\n if (this.currentCaseLender) {\r\n lenderCosts =\r\n +this.currentCaseLender.LenderArrangementFee +\r\n +this.currentCaseLender.LenderExitFee +\r\n +this.currentCaseLender.InterestCoverAllocation;\r\n }\r\n return lenderCosts;\r\n }\r\n\r\n /**Calculate Arrangement Amount */\r\n recalculateArrangementAmount() {\r\n if (this.currentCaseLender && this.currentCaseLender.TotalGrossLoan) {\r\n this.currentCaseLender.LenderArrangementFeePercent =\r\n (this.currentCaseLender.LenderArrangementFee * 100) /\r\n this.currentCaseLender.TotalGrossLoan;\r\n this.currentCaseLender.LenderArrangementFeePercent = parseFloat(\r\n this.currentCaseLender.LenderArrangementFeePercent.toFixed(2),\r\n );\r\n\r\n this.totalLenderCosts();\r\n }\r\n }\r\n\r\n /**Calculate borrower equity\r\n (Puchase Price - land loan)\r\n */\r\n calculateBorrowerEquity(calcShareholderDeposit: boolean = true) {\r\n var borrowerEquity: number = 0;\r\n\r\n if (\r\n this.currentDeal &&\r\n this.currentDeal.PurchasePrice &&\r\n this.currentCaseLender &&\r\n this.currentCaseLender.LandLoan\r\n ) {\r\n borrowerEquity =\r\n this.currentDeal.PurchasePrice - this.currentCaseLender.LandLoan;\r\n }\r\n\r\n if (calcShareholderDeposit) {\r\n this.calculateMinShareholderDeposit();\r\n }\r\n return Number(borrowerEquity);\r\n }\r\n\r\n /**Calculate true cost */\r\n calculateTrueCost(): number {\r\n if (this.currentCaseLender) {\r\n var trueCost: number =\r\n +this.currentCaseLender.InterestRate / 12 +\r\n (+this.currentCaseLender.LenderArrangementFeePercent +\r\n +this.currentCaseLender.LenderExitFeePercent) /\r\n +this.currentCaseLender.LoanTerm;\r\n return trueCost;\r\n }\r\n }\r\n\r\n /**Re-calculate arrangement percent */\r\n recalculateArrangementPercent() {\r\n if (this.currentCaseLender && this.currentCaseLender.TotalGrossLoan) {\r\n this.currentCaseLender.LenderArrangementFee =\r\n (this.currentCaseLender.TotalGrossLoan *\r\n this.currentCaseLender.LenderArrangementFeePercent) /\r\n 100;\r\n this.currentCaseLender.LenderArrangementFee =\r\n Math.round(this.currentCaseLender.LenderArrangementFee * 100) / 100;\r\n this.totalLenderCosts();\r\n }\r\n }\r\n\r\n /**Recalculate Exit Amount */\r\n recalculateExitAmount() {\r\n const element = event.currentTarget as HTMLInputElement;\r\n const value = parseFloat(element.value);\r\n if (this.currentCaseLender && this.currentCaseLender.TotalGrossLoan) {\r\n this.currentCaseLender.LenderExitFee = value;\r\n this.currentCaseLender.LenderExitFeePercent =\r\n (this.currentCaseLender.LenderExitFee * 100) /\r\n this.currentCaseLender.TotalGrossLoan;\r\n this.currentCaseLender.LenderExitFeePercent =\r\n Math.round(this.currentCaseLender.LenderExitFeePercent * 100) / 100;\r\n this.totalLenderCosts();\r\n }\r\n }\r\n\r\n /**Recalculate Exit Percent */\r\n recalculateExitPercent() {\r\n if (\r\n this.currentCaseLender &&\r\n this.currentCaseLender.TotalGrossLoan &&\r\n this.currentCaseLender.LenderExitFeePercent\r\n ) {\r\n this.currentCaseLender.LenderExitFee =\r\n (this.currentCaseLender.TotalGrossLoan *\r\n this.currentCaseLender.LenderExitFeePercent) /\r\n 100;\r\n this.currentCaseLender.LenderExitFee =\r\n Math.round(this.currentCaseLender.LenderExitFee * 100) / 100;\r\n this.totalLenderCosts();\r\n }\r\n }\r\n\r\n calculatemonetaryLAFee() {\r\n if (\r\n this.currentCaseLender.LenderArrangementFeePercent != null &&\r\n this.currentCaseLender.LenderArrangementFeePercent > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderArrangementFee =\r\n Math.round(\r\n this.currentCaseLender.TotalGrossLoan *\r\n this.currentCaseLender.LenderArrangementFeePercent *\r\n 100,\r\n ) / 100;\r\n } else {\r\n this.currentCaseLender.LenderArrangementFee = 0;\r\n }\r\n }\r\n\r\n calculatemonetaryLAPercent() {\r\n if (\r\n this.currentCaseLender.LenderArrangementFee != null &&\r\n this.currentCaseLender.LenderArrangementFee > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderArrangementFeePercent =\r\n this.currentCaseLender.LenderArrangementFee /\r\n this.currentCaseLender.TotalGrossLoan;\r\n\r\n this.currentCaseLender.LenderArrangementFeePercent = parseFloat(\r\n this.currentCaseLender.LenderArrangementFeePercent.toFixed(4),\r\n );\r\n } else {\r\n this.currentCaseLender.LenderArrangementFeePercent = 0;\r\n }\r\n }\r\n\r\n calculatemonetaryLEFee() {\r\n if (\r\n this.currentCaseLender.LenderExitFeePercent != null &&\r\n this.currentCaseLender.LenderExitFeePercent > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderExitFee =\r\n Math.round(\r\n this.currentCaseLender.TotalGrossLoan *\r\n this.currentCaseLender.LenderExitFeePercent *\r\n 100,\r\n ) / 100;\r\n } else {\r\n this.currentCaseLender.LenderExitFee = 0;\r\n }\r\n }\r\n\r\n calculatemonetaryLEPercent() {\r\n if (\r\n this.currentCaseLender.LenderExitFee != null &&\r\n this.currentCaseLender.LenderExitFee > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderExitFeePercent =\r\n this.currentCaseLender.LenderExitFee /\r\n this.currentCaseLender.TotalGrossLoan;\r\n this.currentCaseLender.LenderExitFeePercent = parseFloat(\r\n this.currentCaseLender.LenderExitFeePercent.toFixed(4),\r\n );\r\n } else {\r\n this.currentCaseLender.LenderExitFeePercent = 0;\r\n }\r\n }\r\n\r\n CalcTotalBuild(): number {\r\n var res: number = this.CalcAdditionalBuild();\r\n if (this.currentDeal && this.currentDeal.BuildCosts) {\r\n res += Number(this.currentDeal.BuildCosts);\r\n }\r\n\r\n res += this.calcContingencyCost();\r\n return res;\r\n }\r\n\r\n CalcAdditionalBuild(): number {\r\n var res: number = 0;\r\n if (this.currentDeal.HasProfessionalCostsBreakdown) {\r\n if (this.currentDeal.PlanningCosts) {\r\n res += Number(this.currentDeal.PlanningCosts);\r\n }\r\n if (this.currentDeal.ProjectManagementCosts) {\r\n res += Number(this.currentDeal.ProjectManagementCosts);\r\n }\r\n if (this.currentDeal.ClientQSCosts) {\r\n res += Number(this.currentDeal.ClientQSCosts);\r\n }\r\n if (this.currentDeal.S106CILCosts) {\r\n res += Number(this.currentDeal.S106CILCosts);\r\n }\r\n if (this.currentDeal.MechanicalEngineeringCosts) {\r\n res += Number(this.currentDeal.MechanicalEngineeringCosts);\r\n }\r\n if (this.currentDeal.StructuralEngineeringCosts) {\r\n res += Number(this.currentDeal.StructuralEngineeringCosts);\r\n }\r\n if (this.currentDeal.PartyWallCosts) {\r\n res += Number(this.currentDeal.PartyWallCosts);\r\n }\r\n if (this.currentDeal.WarrantyCosts) {\r\n res += Number(this.currentDeal.WarrantyCosts);\r\n }\r\n if (this.currentDeal.LandscapingCosts) {\r\n res += Number(this.currentDeal.LandscapingCosts);\r\n }\r\n if (this.currentDeal.OtherProfessionalCosts) {\r\n res += Number(this.currentDeal.OtherProfessionalCosts);\r\n }\r\n } else {\r\n if (this.currentDeal.AdditionalOngoingCosts) {\r\n res += Number(this.currentDeal.AdditionalOngoingCosts);\r\n }\r\n }\r\n return res;\r\n }\r\n\r\n calcContingencyCost(): number {\r\n var res: number = 0;\r\n if (this.currentDeal.Contingency && this.currentDeal.BuildCosts) {\r\n res = this.currentDeal.Contingency * this.currentDeal.BuildCosts;\r\n return res;\r\n }\r\n return res;\r\n }\r\n\r\n calculateGrossLoanValVal() {\r\n if (\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan >= 0 &&\r\n this.currentDeal.GDV != null &&\r\n this.currentDeal.GDV >= 0\r\n ) {\r\n this.grossLoanCalcVal = parseFloat(\r\n (\r\n (this.currentCaseLender.TotalGrossLoan / this.currentDeal.GDV) *\r\n 100\r\n ).toFixed(2),\r\n );\r\n }\r\n\r\n if (\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n if (\r\n this.currentCaseLender.LenderArrangementFeePercent != null &&\r\n this.currentCaseLender.LenderArrangementFeePercent > 0\r\n ) {\r\n this.calculatemonetaryLAFee();\r\n } else {\r\n if (\r\n this.currentCaseLender.LenderArrangementFee != null &&\r\n this.currentCaseLender.LenderArrangementFee > 0\r\n ) {\r\n this.calculatemonetaryLAPercent();\r\n }\r\n }\r\n\r\n if (\r\n this.currentCaseLender.LenderExitFeePercent != null &&\r\n this.currentCaseLender.LenderExitFeePercent > 0\r\n ) {\r\n this.calculatemonetaryLEFee();\r\n } else {\r\n if (\r\n this.currentCaseLender.LenderExitFee != null &&\r\n this.currentCaseLender.LenderExitFee > 0\r\n ) {\r\n this.calculatemonetaryLEPercent();\r\n }\r\n }\r\n } else {\r\n this.currentCaseLender.LenderArrangementFeePercent = 0;\r\n this.currentCaseLender.LenderArrangementFee = 0;\r\n this.currentCaseLender.LenderExitFeePercent = 0;\r\n this.currentCaseLender.LenderExitFee = 0;\r\n }\r\n }\r\n\r\n calculateBuildLoadCalcVal() {\r\n if (\r\n this.currentCaseLender.BuildLoan != null &&\r\n this.currentCaseLender.BuildLoan >= 0\r\n ) {\r\n this.builLoanCalcVal = parseFloat(\r\n (\r\n (this.currentCaseLender.BuildLoan / this.CalcTotalBuild()) *\r\n 100\r\n ).toFixed(2),\r\n );\r\n }\r\n }\r\n\r\n calculateLandLoanCalcVal() {\r\n if (\r\n this.currentCaseLender.LandLoan != null &&\r\n this.currentCaseLender.LandLoan >= 0\r\n ) {\r\n this.landLoanCalcVal = parseFloat(\r\n (\r\n (this.currentCaseLender.LandLoan / this.currentDeal.PurchasePrice) *\r\n 100\r\n ).toFixed(2),\r\n );\r\n }\r\n }\r\n\r\n getRateTypeText(e: InterestRateTypeEnum) {\r\n switch (e) {\r\n case InterestRateTypeEnum.Fixed:\r\n return \"Fixed\";\r\n case InterestRateTypeEnum.Variable:\r\n return \"Variable\";\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n getCurrentUserAndRoles() {\r\n this.dataLoading = true;\r\n this.userService\r\n .getcurentuserrecord()\r\n .then((result) => {\r\n this.currentUser = result;\r\n\r\n this.roleService.isClientUser().then((response) => {\r\n this.isClient = response;\r\n });\r\n\r\n this.roleService.isAdminUser().then((response) => {\r\n this.isAdmin = response;\r\n });\r\n\r\n this.roleService.isBroker().then((response) => {\r\n this.isBroker = response;\r\n });\r\n\r\n this.roleService.isLenderUser().then((response) => {\r\n this.isLender = response;\r\n if (!this.isLender) {\r\n this.toggleFeedbackSection = true;\r\n this.updateCaseLenderMessageReadDatetime();\r\n }\r\n });\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n getSenderMessageRole() {\r\n if (this.isLender) {\r\n return MessageRoleEnum.Lender;\r\n } else if (this.isBroker) {\r\n return MessageRoleEnum.Broker;\r\n } else if (this.isAdmin) {\r\n return MessageRoleEnum.Admin;\r\n } else if (this.isClient) {\r\n return MessageRoleEnum.Client;\r\n }\r\n }\r\n\r\n populateLenderInformation(user: ApplicationUserDTO) {\r\n if (this.isLender) {\r\n this.currentCaseLender.ContactName = user.FullName;\r\n this.currentCaseLender.ContactEmail = user.Email;\r\n this.currentCaseLender.ContactMobilePhoneNumber = user.PhoneNumber;\r\n } \r\n }\r\n\r\n calculateMinShareholderDeposit() {\r\n if (this.currentCaseLender) {\r\n if (this.currentCaseLender.MinShareholderDepositPercent != null && this.currentCaseLender.MinShareholderDepositPercent > 0) {\r\n this.currentCaseLender.MinShareholderDeposit = Math.round((this.calculateBorrowerEquity(false) * this.currentCaseLender.MinShareholderDepositPercent) * 100) / 100;\r\n } else {\r\n this.currentCaseLender.MinShareholderDeposit = 0;\r\n }\r\n }\r\n }\r\n\r\n calculateMinShareholderDepositPercent() {\r\n if (this.currentCaseLender) {\r\n if (this.currentCaseLender.MinShareholderDeposit != null && this.currentCaseLender.MinShareholderDeposit > 0) {\r\n this.currentCaseLender.MinShareholderDepositPercent = parseFloat((this.currentCaseLender.MinShareholderDeposit / this.calculateBorrowerEquity(false)).toFixed(4));\r\n\r\n } else {\r\n this.currentCaseLender.MinShareholderDepositPercent = 0;\r\n }\r\n }\r\n }\r\n\r\n isCurrentUserAllowedToSendChat(){\r\n if(this.currentUser && this.currentDeal && (this.toggleFeedbackSection||this.showFeedbackSectionLender)){\r\n return this.sharedHeadsOfTermsService.isCurrentUserAllowedToSendChat(this.isBroker,this.currentDeal.Status,this.currentDeal.IsReferredToConnect,this.currentUser)\r\n }\r\n return false;\r\n }\r\n}\r\n","export const enum PersonalGuaranteeLevelEnum {\r\n None = 0,\r\n UpTo20Percent = 1,\r\n TwentyOneTo35Percent = 2,\r\n OneHundredPercent = 3,\r\n ThirtySixTo50Percent = 4,\r\n}\r\n","export const enum ShareholderDepositRequiredEnum {\r\n None = 0,\r\n UpTo25Percent = 1,\r\n TwentyFiveTo50Percent = 2,\r\n FiftyPercentPlus = 3,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { DealLenderDTO } from \"@js/DTO/Deal/DealLenderDTO.cs.d\";\r\nimport { DevelopmentFinanceDealDTO } from \"@js/DTO/Deal/DevelopmentFinanceDealDTO.cs.d\";\r\nimport { ShareDealDTO } from \"@js/DTO/Deal/SearchDealDTO.cs.d\";\r\nimport { LenderResultSummaryDTO } from \"@js/DTO/DevelopmentFinance/LenderResultSummaryDTO.cs.d\";\r\nimport { LenderProductPairDTO } from \"@js/DTO/LenderProductPairDTO.cs\";\r\nimport { SaveAsSearchRequest } from \"@js/DTO/Messages/Deal/SaveAsSearchMessage.cs.d\";\r\nimport { SaveDevFinanceSearchRequest } from \"@js/DTO/Messages/Deal/SaveDevFinanceSearchMessage.cs.d\";\r\nimport { UpdateDevFinanceSearchGetResultResponse } from \"@js/DTO/Messages/Deal/UpdateDevFinanceSearchGetResultMessage.cs.d\";\r\nimport { MakeReferralMessageRequest } from \"@js/DTO/Messages/MakeReferralMessage.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { EventLogEnum } from \"@js/models/enum/EventLogEnum.cs.d\";\r\nimport { MaxFlatUnitPriceEnum } from \"@js/models/enum/MaxFlatUnitPriceEnum.cs.d\";\r\nimport { MaxHouseSalePriceEnum } from \"@js/models/enum/MaxHouseSalePriceEnum.cs.d\";\r\nimport { MaxPercCommercialForMixedUseEnum } from \"@js/models/enum/MaxPercCommercialForMixedUseEnum.cs.d\";\r\nimport { MaxSqFtSalePriceEnum } from \"@js/models/enum/MaxSqFtSalePriceEnum.cs.d\";\r\nimport { OwnOrPurchaseEnum } from \"@js/models/enum/OwnOrPurchaseEnum.cs.d\";\r\nimport { PersonalGuaranteeLevelEnum } from \"@js/models/enum/PersonalGuaranteeLevelEnum.cs.d\";\r\nimport { PreviousDevelopmentsEnum } from \"@js/models/enum/PreviousDevelopmentsEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { ShareholderDepositRequiredEnum } from \"@js/models/enum/ShareholderDepositRequiredEnum.cs.d\";\r\nimport { SortByEnum } from \"@js/models/enum/SortByEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { DealLenderService } from \"@js/services/Deal/DealLenderService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { DevFinanceDealService } from \"@js/services/Deal/DevFinanceDealService\";\r\nimport { DevFinanceSearchResultsService } from \"@js/services/Deal/DevFinanceSearchResultsService\";\r\nimport { SharedSearchResultsService } from \"@js/services/Deal/SharedSearchResultsService\";\r\nimport { DealClientService } from \"@js/services/DealClientService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { LenderResultService } from \"@js/services/LenderResultService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationLinkService } from \"@js/services/OrganisationLinkService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { SharedDataService } from \"@js/services/SharedDataService\";\r\n\r\ndeclare const window: Window & { dataLayer: any[] };\r\n\r\nexport class DevFinanceLenderResultScreenController {\r\n loadingData: boolean = false;\r\n // tourState: any = {\r\n // tourStep: 1,\r\n // tourTotalSteps: 0,\r\n // };\r\n guidanceCheckbox: boolean = true;\r\n // tourEnabled: boolean = false;\r\n totalLender: number = 0;\r\n isSearch: boolean = true;\r\n debug1: boolean = false;\r\n loanCriteria: DevelopmentFinanceDealDTO;\r\n dealLenders: DealLenderDTO[];\r\n tempLoanCriteria = null;\r\n comparisonList: LenderResultSummaryDTO[] = [];\r\n snapshotNewSearch: boolean = false;\r\n isShortlistingMore: boolean = false;\r\n isLoggedInUser: boolean = false;\r\n showLenderNamesAndLogosOverride: boolean = false;\r\n searchid: number = null;\r\n dealUniqueRef: string = null;\r\n dealClientUniqueRef: string = null;\r\n orgCode: string;\r\n orgName: string = \"Brickflow\";\r\n mortgageTerm: number = 0;\r\n\r\n //session storage values for enterprise journey\r\n userRole: string = null;\r\n clientId: string = null;\r\n isClient: boolean = false;\r\n\r\n //Enterprise user\r\n user: ApplicationUserDTO;\r\n showEnterpriseRegistrationModal: boolean = false;\r\n projectName: string = \"\";\r\n //TODO DEV FIN commented out until we know whether there will be an org toggle for dev finance\r\n //showCommercialDeal: boolean = true;\r\n summarySearchResults: LenderResultSummaryDTO[];\r\n initialSummarySearchResults: LenderResultSummaryDTO[];\r\n productLastVerifiedDates = {};\r\n deletedDealLenders: LenderProductPairDTO[];\r\n sliderShown: boolean;\r\n isAssigned: boolean = false;\r\n inActiveDealLender: number = 0;\r\n brokerageOrg: OrganisationDTO;\r\n moveContactBrokerBtnInMiddle: boolean = false;\r\n brokerDetail: string = \"\";\r\n brokerageOrgFilename: string;\r\n selectedUser: ApplicationUserDTO = {} as ApplicationUserDTO;\r\n isAdmin: boolean = false;\r\n isLender: boolean = false;\r\n isBroker: boolean = false;\r\n\r\n //These are added for new search functinality\r\n existingUsers: UserSimpleDTO[];\r\n newSearch: boolean = false;\r\n existingborrower: boolean;\r\n showClientDetails: boolean = false;\r\n\r\n isLoggingOut: boolean = false;\r\n appName: string;\r\n shareDealDto: ShareDealDTO = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n\r\n toggleEditSearchName: boolean = false;\r\n showProductNote: boolean = false;\r\n productNote: string;\r\n offer: LenderResultSummaryDTO;\r\n loanLabel: string;\r\n displayMsg: string = null;\r\n showMsg: boolean = false;\r\n ShowdeleteSearch: boolean = false;\r\n warningOff: boolean = false;\r\n emailExistsError: boolean = false;\r\n noOfShortlistAllowed: number = 5;\r\n showMessageToborrower: boolean = false;\r\n borrowerMessage: string = \"\";\r\n showContactBrokerModal: boolean = false;\r\n\r\n borrowingEntityTypeOptions = [];\r\n interestRateTypeOptions = [];\r\n loanRepaymentTypeOptions = [];\r\n timeLeftOnLeaseOptions = [];\r\n numberOfPreviousDevelopmentsOptions = [];\r\n personalGuaranteeLevelOptions = [];\r\n maxIndividualUnitPriceOptions = [];\r\n currentUseofBuildingOptions = [];\r\n locationOptions = [];\r\n depositRequiredFromShareholdersOptions = [];\r\n maxHouseSalePriceOptions = [];\r\n maxFlatUnitPriceOptions = [];\r\n maxSqFtSalePriceOptions = [];\r\n maxPercCommercialForMixedUseOptions = [];\r\n maxCommercialFloorspaceOptions = [];\r\n\r\n shareholderDepositRequired = null;\r\n maxHouseSalesPrice = null;\r\n maxFlatUnitPrice = null;\r\n maxSqFtSalePrice = null;\r\n maxSqFtSalePriceFlats = null;\r\n maxPercCommercialForMixedUse = null;\r\n previousDevelopments = null;\r\n personalGuaranteeLevel = null;\r\n\r\n hasSearchChanged: boolean = false;\r\n showFilters: boolean = false;\r\n\r\n isProceedClicked: boolean = false;\r\n isSaveorSaveAsClicked: boolean = false;\r\n productResultList: number;\r\n isSaveAsWthOutIntroducee: boolean = false;\r\n tempSearchName: string = null;\r\n // Flag to disable or enable the Save as button depending on the click.\r\n isClicked: boolean = false;\r\n showSaveResults: number;\r\n //This boolean is used in the shareedmodal.html for all the deals\r\n isDevelopmentFinance: boolean = true;\r\n\r\n isResultScreen: boolean = true;\r\n selecteduserName: string;\r\n sharedSearch: boolean = false;\r\n searchPanelForm: ng.IFormController;\r\n\r\n //This boolean is used in the shareedmodal.html for all the deals\r\n isDeal: boolean = true;\r\n\r\n buildCostIntermediary: number;\r\n contingencyValue: number;\r\n\r\n //Postcode\r\n showPostcodeErrorMessage: boolean = false;\r\n postcodeErrorMsg: string;\r\n isPostcodeChange: boolean = false;\r\n\r\n showSortBy: boolean = false;\r\n hasAccessToDeal: boolean = true;\r\n noAccessToDealMsg: string;\r\n\r\n //LenderReferralSearch\r\n lenderReferralData: MakeReferralMessageRequest =\r\n {} as MakeReferralMessageRequest;\r\n isLenderReferredSearch: boolean = false;\r\n isLenderReferringSearch: boolean = false;\r\n hasLiveSearch: boolean = true;\r\n\r\n hasResultsProcessed: boolean = false;\r\n\r\n //SaveAs functionality\r\n isSaveAsClicked: boolean = false;\r\n saveAsSearchName: string;\r\n reloadSearch: boolean = false;\r\n\r\n //Enterprise journey\r\n showRegisterModal: boolean = false;\r\n showLoginSection: boolean = false;\r\n enterpriseClient: ApplicationUserDTO = {\r\n Id: \"\",\r\n AgreedToTermsAndPP: true,\r\n Roles: [\"Client\"],\r\n } as ApplicationUserDTO;\r\n error: string = \"\";\r\n\r\n // Previously shortlisted/submitted lenders which are not visible on current results because of criteria change\r\n HiddenDealLenderList: DealLenderDTO[] = [];\r\n showExportOptions: boolean = false;\r\n\r\n //Confirm phone number for new client, when they register through enterprise journey from results page\r\n showClientPhoneNumberConfirmationModal: boolean = false;\r\n clientUpdatedContact: string;\r\n confirmClientPhoneNumberForm: ng.IFormController;\r\n clientUpdatedContactErrorMessage: string;\r\n\r\n // Logging in/resetting password\r\n isLoginError: boolean = false;\r\n isResetPasswordSubmitted: boolean = false;\r\n registrationLoginError: string = null;\r\n \r\n filterProperties = [\r\n \"F_IsFirstTimeDeveloper\",\r\n \"F_NumberOfPreviousDevelopments\",\r\n \"F_ShareholderDepositRequired\",\r\n \"F_IsPersonalName\",\r\n \"F_IsOffshoreCompany\",\r\n \"F_IsMainShareholderOverseas\",\r\n \"F_PersonalGuaranteeLevel\",\r\n \"F_HasAdverseCredit\",\r\n \"F_MaxCommercialFloorspace\",\r\n \"F_IsModular\",\r\n \"F_IsAirRights\",\r\n \"F_IsPermittedDevelopmentScheme\",\r\n \"F_IsGradeOneListed\",\r\n \"F_IsGradeTwoListed\",\r\n \"F_MaxHouseSalesPrice\",\r\n \"F_MaxFlatUnitPrice\",\r\n \"F_MaxSqFtSalePrice\",\r\n \"F_MaxSqFtSalePriceFlats\",\r\n \"F_MaxPercCommercialForMixedUse\",\r\n \"F_IsWorkStarted\",\r\n \"F_MaxNumberOfUnits\",\r\n \"F_IsChargeOnAdditionalProperty\",\r\n \"F_IsFixedRate\"\r\n ];\r\n\r\n static $inject = [\r\n \"$route\",\r\n \"$routeParams\",\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"$cookies\",\r\n \"OrganisationService\",\r\n \"DevFinanceSearchResultsService\",\r\n \"SelectListService\",\r\n \"EventLogService\",\r\n \"LenderService\",\r\n \"DealLenderService\",\r\n \"RoleService\",\r\n \"UserService\",\r\n \"SharedSearchResultsService\",\r\n \"DevFinanceDealService\",\r\n \"DealService\",\r\n \"AuthService\",\r\n \"LenderResultService\",\r\n \"DealClientService\",\r\n \"ProductService\",\r\n 'OrganisationLinkService',\r\n 'SharedDataService'\r\n ];\r\n\r\n constructor(\r\n private $route: ng.route.IRouteService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $scope: ng.IScope,\r\n public $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private organisationService: OrganisationService,\r\n private devFinanceSearchResultsService: DevFinanceSearchResultsService,\r\n private selectListService: SelectListService,\r\n private eventLogService: EventLogService,\r\n private lenderService: LenderService,\r\n private dealLenderService: DealLenderService,\r\n private roleService: RoleService,\r\n private $user: UserService,\r\n private sharedSearchResultsService: SharedSearchResultsService,\r\n private devFinanceDealService: DevFinanceDealService,\r\n private dealService: DealService,\r\n private $auth: AuthService,\r\n private lenderResultService: LenderResultService,\r\n private dealClientService: DealClientService,\r\n private productService: ProductService,\r\n private organisationLinkService: OrganisationLinkService,\r\n private sharedDataService: SharedDataService\r\n ) {\r\n if (this.$location.path().startsWith(\"/devfinanceshortlistmore\")) {\r\n this.isShortlistingMore = true;\r\n }\r\n\r\n //Hide header banner for borrower on page header\r\n /* if (\r\n window.self == window.top &&\r\n sessionStorage.getItem(\"userRole\") &&\r\n sessionStorage.getItem(\"userRole\") == \"borrower\" &&\r\n !$cookies.get(\"access_token\")\r\n ) {\r\n document.getElementById(\"header\").style.display = \"none\";\r\n }*/\r\n\r\n if (this.$routeParams.DealId) {\r\n if (/^\\d+$/.test(this.$routeParams.DealId)) {\r\n // Treat the reference as an ID (e.g., fetch data using the ID)\r\n this.searchid = Number(this.$routeParams.DealId);\r\n } else {\r\n // Treat the reference as a unique string (e.g., fetch data using the string)\r\n this.dealUniqueRef = this.$routeParams.DealId;\r\n }\r\n }\r\n\r\n if (this.$routeParams.dealclientuniqueref) {\r\n this.dealClientUniqueRef = this.$routeParams.dealclientuniqueref;\r\n }\r\n\r\n if (window.self == window.top && $cookies.get(\"access_token\")) {\r\n //This block is to navigate a broker to userdashboard when they do not have a license.\r\n if (sessionStorage.getItem(\"isValidLicense\") == \"false\") {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n this.isLoggedInUser = true;\r\n this.loadingData = true;\r\n this.organisationService\r\n .getOrganisation()\r\n .then((organisation) => {\r\n if (organisation) {\r\n this.orgCode = organisation.IsWhiteLabelled\r\n ? organisation.OrganisationCode\r\n : \"\";\r\n this.showLenderNamesAndLogosOverride =\r\n organisation.ShowLenderNames ?? false;\r\n if (organisation.IsWhiteLabelled) {\r\n this.orgName = organisation.Name.replace(/ /g, \"_\");\r\n } else {\r\n this.orgName = \"Brickflow\";\r\n }\r\n }\r\n })\r\n .catch((error) => {\r\n this.loadingData = false;\r\n })\r\n .finally(() => {\r\n //this.loadingData = false;\r\n });\r\n } else {\r\n if (window.self == window.top) {\r\n this.userRole = sessionStorage.getItem(\"userRole\");\r\n this.isClient = this.userRole == \"borrower\";\r\n this.orgCode = this.$cookies.get(\"org_code\");\r\n this.clientId = sessionStorage.getItem(\"clientId\");\r\n this.getSearchCriteriaAndResults();\r\n } else {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n this.guidanceCheckbox = false;\r\n Promise.all([\r\n this.organisationService\r\n .getData(\"userDetails\")\r\n .then((userDetails) => {\r\n if (userDetails) {\r\n this.user = JSON.parse(userDetails);\r\n }\r\n }),\r\n this.organisationService.getData(\"userRole\").then((userRole) => {\r\n if (userRole) {\r\n this.userRole = userRole;\r\n this.isClient = this.userRole == \"borrower\";\r\n }\r\n }),\r\n this.organisationService.getData(\"clientId\").then((clientId) => {\r\n if (clientId) {\r\n this.clientId = clientId;\r\n }\r\n }),\r\n //Try get session storage if running in iframe before getting results\r\n this.organisationService.getData(\"newSearch\").then((newSearch) => {\r\n if (newSearch) {\r\n this.snapshotNewSearch = newSearch == \"true\";\r\n }\r\n }),\r\n ])\r\n .then(() => {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n this.organisationService.sendDataToParent(\"newSearch\", \"false\");\r\n this.getSearchCriteriaAndResults();\r\n })\r\n .catch((error) => {\r\n // One or both of the promises were rejected, handle the error\r\n console.error(\"Failed to get user data: \", error);\r\n });\r\n }\r\n }\r\n\r\n if (window.self == window.top) {\r\n // let cookieTourStep = this.$cookies.get(\"tourStep\");\r\n // if (cookieTourStep) {\r\n // this.tourState.tourStep = cookieTourStep;\r\n // }\r\n\r\n //if user is logged in, get profile\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.$user.getcurentuserrecord().then((result) => {\r\n this.selectedUser = result;\r\n\r\n this.roleService.isClientUser().then((response) => {\r\n this.isClient = response;\r\n });\r\n\r\n this.roleService.isAdminUser().then((response) => {\r\n this.isAdmin = response;\r\n if (this.isAdmin) {\r\n this.getUsersBelongToBrokerOrAdmin();\r\n }\r\n });\r\n\r\n this.roleService.isBroker().then((response) => {\r\n this.isBroker = response;\r\n if (this.isBroker) {\r\n this.getUsersBelongToBrokerOrAdmin();\r\n }\r\n });\r\n\r\n this.roleService.isLenderUser().then((response) => {\r\n this.isLender = response;\r\n\r\n if (this.isLender) {\r\n this.hasLiveSearch = false;\r\n this.lenderService.getUserLenderDetails().then((lender) => {\r\n if (lender.HasLiveMarketSearch) {\r\n this.hasLiveSearch = true;\r\n }\r\n });\r\n }\r\n\r\n ///Lender referred search\r\n if (sessionStorage.getItem(\"lenderReferralClient\")) {\r\n this.lenderReferralData.ClientDTO = JSON.parse(\r\n sessionStorage.getItem(\"lenderReferralClient\"),\r\n );\r\n this.isLenderReferringSearch = true;\r\n }\r\n });\r\n\r\n if (this.isShortlistingMore) {\r\n this.lenderService.getDealDeletedLenderIds(this.searchid).then(response => {\r\n this.deletedDealLenders = response;\r\n }).finally(() => {\r\n this.getSearchCriteriaAndResults();\r\n });\r\n } else {\r\n this.getSearchCriteriaAndResults();\r\n }\r\n });\r\n } else {\r\n this.isClient = true; // if the user isn't logged in then this is the enterprise journey and should be treated as a borrower/client\r\n }\r\n\r\n // this.updateGuidanceState();\r\n\r\n // $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n // this.updateGuidanceState();\r\n // });\r\n\r\n let logoutUnregister = $rootScope.$on(\r\n \"logout\",\r\n (event: ng.IAngularEvent) => {\r\n this.isLoggingOut = true;\r\n },\r\n );\r\n\r\n $scope.$on(\"$destroy\", logoutUnregister);\r\n\r\n // $rootScope.$on(\"nextTour\", (event: ng.IAngularEvent) => {\r\n // this.tourNext();\r\n // });\r\n // $rootScope.$on(\"backTour\", (event: ng.IAngularEvent) => {\r\n // this.tourBack();\r\n // });\r\n // $rootScope.$on(\"skipTour\", (event: ng.IAngularEvent) => {\r\n // this.tourSkip();\r\n // });\r\n }\r\n\r\n this.numberOfPreviousDevelopmentsOptions =\r\n this.selectListService.GetNumberOfPreviousDevelopments();\r\n this.depositRequiredFromShareholdersOptions =\r\n this.selectListService.GetShareholderDepositRequired();\r\n this.personalGuaranteeLevelOptions =\r\n this.selectListService.GetPersonalGuaranteeLevels();\r\n this.maxHouseSalePriceOptions =\r\n this.selectListService.GetMaxHouseSalePrices();\r\n this.maxFlatUnitPriceOptions =\r\n this.selectListService.GetMaxFlatUnitPrices();\r\n this.maxSqFtSalePriceOptions =\r\n this.selectListService.GetMaxSqFtSalePrices();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n this.maxCommercialFloorspaceOptions = this.selectListService.GetMaxCommercialFloorspaceOptions();\r\n }\r\n\r\n /**\r\n * Gets the search results and criteria for selected search\r\n * @param none\r\n */\r\n getSearchCriteriaAndResults() {\r\n if (window.self == window.top) {\r\n this.snapshotNewSearch = sessionStorage.getItem(\"newSearch\") == \"true\";\r\n sessionStorage.setItem(\"newSearch\", \"false\");\r\n }\r\n if (this.searchid) {\r\n this.loadingData = true;\r\n this.devFinanceSearchResultsService\r\n .getSearchCriteriaAndResultsByDealId(\r\n this.searchid,\r\n this.snapshotNewSearch,\r\n )\r\n .then((results) => {\r\n this.postResultsProcessing(results);\r\n })\r\n .then(() => {\r\n if (this.summarySearchResults != null) {\r\n const productIds = this.summarySearchResults.map((product) => product.ProductID);\r\n this.getProductLastVerifiedDates(productIds);\r\n }\r\n })\r\n .then(() => {\r\n this.getSearchLenderCount();\r\n if (this.isLoggedInUser) this.getSelectedProducts();\r\n })\r\n .catch((error) => {\r\n console.log(error);\r\n })\r\n .finally(() => {\r\n if (this.loanCriteria) {\r\n this.isSearch =\r\n this.loanCriteria &&\r\n this.loanCriteria.Status == CaseStatusEnum.Search;\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.loadingData = false;\r\n }\r\n this.hasResultsProcessed = true;\r\n });\r\n } else if (this.dealUniqueRef) {\r\n this.loadingData = true;\r\n this.devFinanceSearchResultsService\r\n .getSearchCriteriaAndResultsByDealUniqueRef(\r\n this.dealUniqueRef,\r\n this.snapshotNewSearch,\r\n )\r\n .then((results) => {\r\n this.postResultsProcessing(results);\r\n })\r\n .then(() => {\r\n if (this.summarySearchResults != null) {\r\n const productIds = this.summarySearchResults.map((product) => product.ProductID);\r\n this.getProductLastVerifiedDates(productIds);\r\n }\r\n })\r\n .then(() => {\r\n this.getSearchLenderCount();\r\n if (this.loanCriteria) this.getSelectedProducts();\r\n })\r\n .catch((error) => {\r\n console.log(error);\r\n })\r\n .finally(() => {\r\n if (this.loanCriteria) {\r\n this.isSearch =\r\n this.loanCriteria &&\r\n this.loanCriteria.Status == CaseStatusEnum.Search;\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.loadingData = false;\r\n }\r\n this.hasResultsProcessed = true;\r\n });\r\n } else if (this.dealClientUniqueRef) {\r\n this.loadingData = true;\r\n this.devFinanceSearchResultsService\r\n .getSearchCriteriaAndResultsByDealClientUniqueRef(\r\n this.dealClientUniqueRef,\r\n this.snapshotNewSearch,\r\n )\r\n .then((results) => {\r\n this.postResultsProcessing(results);\r\n })\r\n .then(() => {\r\n this.getSearchLenderCount();\r\n if (this.loanCriteria) this.getSelectedProducts();\r\n\r\n if (\r\n sessionStorage.getItem(\"LoanCriteria\") &&\r\n (this.$rootScope as any).previousRoute.startsWith(\"/compare\")\r\n ) {\r\n this.comparisonList = JSON.parse(\r\n sessionStorage.getItem(\"ComparisonList\"),\r\n );\r\n\r\n //Removing lsd data saved for compare view.\r\n sessionStorage.removeItem(\"LoanCriteria\");\r\n sessionStorage.removeItem(\"ComparisonList\");\r\n }\r\n })\r\n .catch((error) => { })\r\n .finally(() => {\r\n this.isSearch =\r\n this.loanCriteria &&\r\n this.loanCriteria.Status == CaseStatusEnum.Search;\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.loadingData = false;\r\n this.hasResultsProcessed = true;\r\n });\r\n }\r\n }\r\n\r\n checkDeletedLender(lenderId: string, productId: string): boolean {\r\n if (this.isShortlistingMore && this.deletedDealLenders) {\r\n const deletedLender = this.deletedDealLenders.find(deletedLender => deletedLender.LenderId === String(lenderId));\r\n\r\n if (deletedLender) {\r\n return deletedLender.ProductId === String(productId);\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n postResultsProcessing(results) {\r\n if (results.HasNoAccessToDeal) {\r\n this.hasAccessToDeal = false;\r\n if (this.isClient) {\r\n this.noAccessToDealMsg =\r\n \"Please contact your broker in order to access this case.\";\r\n } else {\r\n this.noAccessToDealMsg = \"Error retrieving deal.\";\r\n }\r\n } else {\r\n this.summarySearchResults = this.initialSummarySearchResults = results.Results;\r\n this.loanCriteria = results.CriteriaDto;\r\n\r\n if(this.isLoggedInUser ){\r\n this.validateAccessAndRedirect();\r\n }\r\n \r\n this.sortSummaryResults();\r\n\r\n if (this.loanCriteria.LoanTermReq && this.loanCriteria.LoanTermReq > 0) {\r\n this.mortgageTerm = this.loanCriteria.LoanTermReq / 12;\r\n }\r\n\r\n if (this.isLoggedInUser) {\r\n if (this.dealClientUniqueRef) {\r\n if (this.isClient) {\r\n this.eventLogService.logPageLoad(\r\n \"AFTER-ENTERPRISE-LEAD-REGISTRATION-USING-EMAIL-LINK\",\r\n this.orgCode,\r\n this.selectedUser.UserName,\r\n \"Client\",\r\n this.loanCriteria?.OrganisationLinkId,\r\n this.loanCriteria.ProductType,\r\n \"\",\r\n this.loanCriteria?.Id,\r\n );\r\n }\r\n } else {\r\n if (this.loanCriteria.LenderReferralLenderId)\r\n this.isLenderReferredSearch = true;\r\n\r\n // Showing confirm client phone number modal once client register through result page\r\n if (this.isClient && sessionStorage.getItem('showConfirmClientPhoneNo') == 'true') {\r\n this.showClientPhoneNumberConfirmationModal = true;\r\n this.clientUpdatedContact = this.loanCriteria?.DealClients[0].Client.PhoneNumber;\r\n }\r\n\r\n // Expanding a 'new search' panel for first time search execution\r\n if (window.self == window.top && sessionStorage.getItem(\"newSearch\")) {\r\n this.sliderShown = (this.$rootScope as any).previousRoute.startsWith(\"/compare\") || this.showClientPhoneNumberConfirmationModal ? false : true;\r\n sessionStorage.removeItem(\"newSearch\");\r\n }\r\n }\r\n } else {\r\n if (this.$location.path().startsWith(\"/e/devfinanceresults\")) {\r\n this.populateEnterpriseClientValue(\"LENDERRESULTS\");\r\n }\r\n\r\n if (this.dealClientUniqueRef) {\r\n if (this.$routeParams.showOnlyRegister == \"false\")\r\n this.isClient = true;\r\n this.populateEnterpriseClientValue(\"LENDERRESULTS-USING-EMAIL-LINK\");\r\n }\r\n }\r\n\r\n }\r\n }\r\n\r\n getSearchLenderCount() {\r\n this.lenderService\r\n .getTotalLenders(ProductFamilyEnum.Development,this.loanCriteria.BrokerOrganisationId)\r\n .then((result: number) => {\r\n this.totalLender = result;\r\n });\r\n }\r\n\r\n getSelectedProducts() {\r\n if (this.summarySearchResults && this.summarySearchResults.length > 0) {\r\n this.dealLenderService\r\n .fetchDealLendersByDealId(this.dealClientUniqueRef || this.dealUniqueRef ? this.loanCriteria.Id : this.searchid)\r\n .then((results) => {\r\n this.dealLenders = results;\r\n })\r\n .then(() => {\r\n this.comparisonList = this.summarySearchResults.filter((result) => {\r\n const isDealLender = this.dealLenders.find(\r\n (dealLender) => dealLender.ProductId === result.ProductID,\r\n );\r\n if (isDealLender) {\r\n result.DealLenderStatus = isDealLender.Status;\r\n }\r\n return (result.IsDealLender = Boolean(isDealLender));\r\n });\r\n\r\n // Previously shortlisted/submitted lenders which are not visible on current results because of criteria change\r\n this.HiddenDealLenderList = this.dealLenders.filter(l =>\r\n !this.summarySearchResults.some(s => l.ProductId === s.ProductID)\r\n );\r\n\r\n if (this.comparisonList.length > 0) {\r\n var inActiveDealLenderList = this.comparisonList.filter(\r\n (ia) =>\r\n ia.DealLenderStatus == CaseLenderStateEnum.Rejected ||\r\n ia.DealLenderStatus == CaseLenderStateEnum.Withdrawn,\r\n );\r\n this.inActiveDealLender = inActiveDealLenderList.length;\r\n }\r\n\r\n if (\r\n sessionStorage.getItem(\"LoanCriteria\") &&\r\n (this.$rootScope as any).previousRoute.startsWith(\"/compare\")\r\n ) {\r\n if (sessionStorage.getItem(\"actualcomparisonList\")) {\r\n var selectedProducts = sessionStorage.getItem(\r\n \"actualcomparisonList\",\r\n );\r\n this.comparisonList = JSON.parse(selectedProducts);\r\n sessionStorage.removeItem(\"actualcomparisonList\");\r\n } else {\r\n this.comparisonList = JSON.parse(\r\n sessionStorage.getItem(\"ComparisonList\"),\r\n );\r\n }\r\n if (this.inActiveDealLender > 0) {\r\n this.comparisonList = this.comparisonList.concat(\r\n inActiveDealLenderList,\r\n );\r\n }\r\n\r\n //Removing lsd data saved for compare view.\r\n sessionStorage.removeItem(\"LoanCriteria\");\r\n sessionStorage.removeItem(\"ComparisonList\");\r\n }\r\n });\r\n }\r\n }\r\n\r\n getOrganisationAndBrokerDetails() {\r\n if (!this.isLoggedInUser && !this.isAdmin && !this.isBroker) {\r\n this.loadingData = true;\r\n this.organisationService\r\n .getOrganisationAndBrokerByDealId(this.loanCriteria.Id)\r\n .then((response) => {\r\n if (response && response.Organisation != null) {\r\n this.brokerageOrg = response.Organisation;\r\n\r\n if (response.Organisation.IsBrickflow) {\r\n this.moveContactBrokerBtnInMiddle = true;\r\n } else {\r\n if (response.Broker != null) {\r\n this.brokerDetail = `${response.Broker.FullName} (${response.Broker.Email})`;\r\n }\r\n\r\n if (this.brokerageOrg.IsWhiteLabelled) {\r\n this.orgName = this.brokerageOrg.Name.replace(/ /g, \"_\");\r\n }\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n\r\n getUsersBelongToBrokerOrAdmin() {\r\n this.$user\r\n .getUserSummariesForBrokerOrAdmin()\r\n .then((response) => {\r\n this.existingUsers = response;\r\n });\r\n }\r\n\r\n // updateGuidanceState() {\r\n // this.tourEnabled = this.sharedSearchResultsService.updateGuidanceState(\r\n // this.guidanceCheckbox,\r\n // );\r\n // }\r\n\r\n // getGuidanceSwitchState() {\r\n // return this.sharedSearchResultsService.getGuidanceSwitchState();\r\n // }\r\n\r\n // recordGuidanceCookie() {\r\n // this.sharedSearchResultsService.recordGuidanceCookie(this.guidanceCheckbox);\r\n // this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n // }\r\n\r\n // tourNext(): void {\r\n // this.tourState.tourStep++;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // }\r\n\r\n // tourBack(): void {\r\n // this.tourState.tourStep--;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // }\r\n\r\n // tourSkip(): void {\r\n // this.tourEnabled = false;\r\n // this.$cookies.put(\"tourEnabled\", \"false\");\r\n // this.$cookies.remove(\"tourStep\");\r\n // }\r\n\r\n // startTour(): void {\r\n // this.tourState.tourStep = 1;\r\n // this.tourState.tourTotalSteps = 0;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // this.tourEnabled = true;\r\n // this.$cookies.put(\"tourEnabled\", \"true\");\r\n // }\r\n\r\n /**\r\n * Saves the new search name on the edit.\r\n * @param none\r\n */\r\n doRenameSearch() {\r\n var request: SaveDevFinanceSearchRequest = {\r\n DealDto: this.loanCriteria,\r\n ShareDealDto: this.shareDealDto,\r\n OrgCode: this.orgCode,\r\n EnterpriseClientDto: null,\r\n };\r\n\r\n if (this.searchid) {\r\n this.devFinanceDealService.saveDevFinanceSearchReturnsId(request)\r\n .then((response) => {\r\n this.toggleEditSearchName = false;\r\n });\r\n } else if (this.dealUniqueRef) {\r\n this.devFinanceDealService.saveDevFinanceSearchReturnsUniqueRef(request)\r\n .then((response) => {\r\n this.toggleEditSearchName = false;\r\n });\r\n } else {\r\n this.toggleEditSearchName = false;\r\n }\r\n }\r\n\r\n toggleLenderComparisonSelection(item: LenderResultSummaryDTO, index: number) {\r\n\r\n let comparisonMatches: LenderResultSummaryDTO[] =\r\n this.comparisonList.filter((result, index) => {\r\n return result.ProductID === item.ProductID;\r\n });\r\n\r\n if (!comparisonMatches || comparisonMatches.length === 0) {\r\n this.comparisonList.push(item);\r\n this.eventLogService.logEvent(\r\n `SHORTLISTING-RESULT`,\r\n EventLogEnum.Shortlisting,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n \"\",\r\n item.ProductID.toString(),\r\n \"\"\r\n );\r\n } else {\r\n if (this.isShortlistingMore && item.IsDealLender && (this.loanCriteria.Status != CaseStatusEnum.Search && this.loanCriteria.Status != CaseStatusEnum.NewCase))\r\n return;\r\n comparisonMatches.forEach((value, index) => {\r\n this.comparisonList.splice(this.comparisonList.indexOf(value), 1);\r\n });\r\n this.eventLogService.logEvent(\r\n `DESELECTING-SHORTLISTED-RESULT`,\r\n EventLogEnum.Shortlisting,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n \"\",\r\n item.ProductID.toString(),\r\n \"\"\r\n );\r\n }\r\n //This is user for shortlisting pdf\r\n this.prepareDataForShortlistPdf();\r\n }\r\n\r\n //This is used in shortlisting pdf\r\n prepareDataForShortlistPdf() {\r\n this.loanCriteria.ComparisonList = this.comparisonList.filter(\r\n (cl) =>\r\n cl.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n cl.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n }\r\n\r\n comparisonContains(item: LenderResultSummaryDTO): boolean {\r\n return !!this.comparisonList.find((result, index) => {\r\n return result.ProductID === item.ProductID;\r\n });\r\n }\r\n\r\n selectionOrderNumber(item: LenderResultSummaryDTO) {\r\n var activeProductList = this.comparisonList.filter(\r\n (cl) =>\r\n cl.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n cl.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n\r\n var hiddenProduct = this.HiddenDealLenderList.filter(hl => hl.Status != CaseLenderStateEnum.Rejected && hl.Status != CaseLenderStateEnum.Withdrawn);\r\n var hiddenProductLength = this.isShortlistingMore ? hiddenProduct.length : 0;\r\n\r\n var order =\r\n activeProductList.map((item) => item.ProductID).indexOf(item.ProductID) + hiddenProductLength +\r\n 1;\r\n if (order === 0) {\r\n return \" \";\r\n }\r\n\r\n return order;\r\n }\r\n\r\n /**\r\n * Processes the clicking of the \"View Eligibility\" anchor/button and index to show on the row number\r\n * @param item BridgingLenderResultSummaryDTO\r\n */\r\n viewEligibility(item: LenderResultSummaryDTO) {\r\n event.preventDefault(); // prevents default behaviour of href\r\n this.showProductNote = true;\r\n this.offer = item;\r\n this.loanLabel = item.LoanLabel;\r\n this.productNote = item.AdditionalProductInfo;\r\n }\r\n\r\n /**\r\n *Marks a selected search as a deleted\r\n * @param\r\n */\r\n deleteSearch() {\r\n if (this.$routeParams.DealId) {\r\n this.dealService\r\n .markasdeleted(this.$routeParams.DealId)\r\n .then((response) => {\r\n this.displayMsg = \"Search is successfully deleted\";\r\n this.showMsg = true;\r\n this.ShowdeleteSearch = true;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n this.showMsg = true;\r\n });\r\n }\r\n }\r\n\r\n closeDeleteModal() {\r\n this.showMsg = false;\r\n this.displayMsg = null;\r\n this.ShowdeleteSearch = false;\r\n this.warningOff = true;\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n viewSingleLoan(item: LenderResultSummaryDTO) {\r\n event.preventDefault(); // prevents default behaviour of href\r\n this.warningOff = true;\r\n //Storing the actual comparisonList to local storage so that to recover it later when we comeback to result screen from compare screen.\r\n sessionStorage.setItem(\r\n \"actualcomparisonList\",\r\n JSON.stringify(this.comparisonList),\r\n );\r\n this.comparisonList = [];\r\n\r\n this.comparisonList.push(item);\r\n this.goCompare();\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n }\r\n\r\n goCompare() {\r\n this.warningOff = true;\r\n\r\n this.sharedSearchResultsService.clearStorageDataForCompareView();\r\n\r\n let comparisonList = this.comparisonList.filter(\r\n (cl) =>\r\n cl.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n cl.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n\r\n sessionStorage.setItem(\"ComparisonList\", JSON.stringify(comparisonList));\r\n sessionStorage.setItem(\"LoanCriteria\", JSON.stringify(this.loanCriteria));\r\n\r\n if (this.dealClientUniqueRef) {\r\n if (!this.isLoggedInUser) {\r\n this.dealUniqueRef = this.loanCriteria.UniqueRef;\r\n //This property is used in compare view controller to find previous route \r\n sessionStorage.setItem(\"DealClientUniqueRef\", this.dealClientUniqueRef);\r\n } else {\r\n this.searchid = this.loanCriteria.Id;\r\n }\r\n }\r\n\r\n\r\n if (this.searchid) {\r\n this.$location.path(\"compare/\" + this.searchid + \"/\" + 0 + \"/\" + true);\r\n } else {\r\n this.$location.path(\"compare/\" + this.dealUniqueRef + \"/\" + 0 + \"/\" + true);\r\n }\r\n }\r\n\r\n showBookMeetingButton() {\r\n return (\r\n !this.isLoggedInUser &&\r\n this.isClient &&\r\n this.brokerDetail == \"\" &&\r\n this.brokerageOrg != null\r\n );\r\n }\r\n\r\n bookMeeting() {\r\n this.$auth\r\n .getHubspotDeveloperBookMeetingWithSearch()\r\n .then((hubSpotUrl: string) => {\r\n window.open(hubSpotUrl);\r\n });\r\n }\r\n\r\n sendMessageToBroker(message) {\r\n this.loadingData = true;\r\n this.borrowerMessage = null;\r\n this.organisationService\r\n .sendBorrowerMessageToSearchBroker(\r\n this.loanCriteria.Id,\r\n message,\r\n this.loanCriteria.DealClients[0].Client.FirstName,\r\n this.loanCriteria.DealClients[0].Client.LastName,\r\n this.loanCriteria.DealClients[0].Client.Email,\r\n ProductTypeEnum.Development,\r\n \"Results\",\r\n )\r\n .then((results) => {\r\n if (results) {\r\n this.displayMsg = `Message has been sent successfully.`;\r\n this.showMessageToborrower = true;\r\n } else {\r\n this.displayMsg = `There is problem sending a message, Please try later.`;\r\n this.showMessageToborrower = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n closeContactBrokerModal() {\r\n this.showContactBrokerModal = false;\r\n this.showMessageToborrower = false;\r\n this.displayMsg = null;\r\n }\r\n\r\n getTotalShortlistedLenders() {\r\n var activeDealLenders = this.comparisonList.filter(\r\n (al) =>\r\n al.DealLenderStatus != CaseLenderStateEnum.Rejected &&\r\n al.DealLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n\r\n var hiddenProduct = this.HiddenDealLenderList.filter(hl => hl.Status != CaseLenderStateEnum.Rejected && hl.Status != CaseLenderStateEnum.Withdrawn);\r\n var hiddenProductLength = this.isShortlistingMore ? hiddenProduct.length : 0;\r\n\r\n return activeDealLenders.length + hiddenProductLength;\r\n }\r\n\r\n logPdfDownload(eventName) {\r\n this.eventLogService.logEvent(\r\n eventName,\r\n EventLogEnum.Export,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n );\r\n }\r\n\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n\r\n changeSearch() {\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n this.warningOff = true;\r\n sessionStorage.setItem(\"skip\", \"true\");\r\n if (!this.isLoggedInUser && (this.dealUniqueRef || this.dealClientUniqueRef)) {\r\n if (this.dealClientUniqueRef) sessionStorage.setItem('previousRoute', 'referredsearchdeal')\r\n var url = `/e/devfinancecriteria/${this.loanCriteria.UniqueRef}`;\r\n if (this.loanCriteria.OrganisationLinkId > 0) {\r\n url = `${url}/${this.loanCriteria.OrganisationLinkId}`;\r\n }\r\n this.go(url);\r\n }\r\n else if (this.searchid) {\r\n this.go(\"/devfinancecriteria/\" + this.searchid);\r\n } else {\r\n this.go(\"/devfinancecriteria\");\r\n }\r\n }\r\n\r\n newloan() {\r\n (this.$rootScope as any).loanCriteria = null;\r\n this.$location.path(\"/devfinancecriteria/0\");\r\n }\r\n\r\n updateSearchViaSlider(isAdminDebugValueChanged: boolean = false): void {\r\n if (this.searchPanelForm.$valid && !this.showPostcodeErrorMessage) {\r\n if (this.loanCriteria.OwnOrPurchase == OwnOrPurchaseEnum.Purchasing) {\r\n if (this.loanCriteria.PurchasePrice <= 0) return;\r\n }\r\n\r\n if (this.loanCriteria.OwnOrPurchase == OwnOrPurchaseEnum.Own) {\r\n if (this.loanCriteria.Currentvalue <= 0) return;\r\n }\r\n\r\n if (this.loanCriteria.GDV <= 0) return;\r\n\r\n this.loadingData = true;\r\n this.hasSearchChanged = true;\r\n\r\n this.clearSelected();\r\n\r\n this.updateCriteriaAndGetResults(\r\n isAdminDebugValueChanged && this.isAdmin ? false : true,\r\n );\r\n }\r\n }\r\n\r\n clearSelected() {\r\n if (this.isShortlistingMore) {\r\n this.comparisonList = this.comparisonList.filter(item =>\r\n this.summarySearchResults.some(result => result.ProductID == item.ProductID)\r\n );\r\n\r\n const dealLenders = this.initialSummarySearchResults.filter(result =>\r\n result.IsDealLender && !result.IsDeleted\r\n );\r\n\r\n dealLenders.forEach(dealLender => {\r\n if (!this.comparisonList.some(item => item.ProductID === dealLender.ProductID)) {\r\n this.comparisonList.push(dealLender);\r\n }\r\n });\r\n } else {\r\n this.comparisonList = this.comparisonList.filter(item =>\r\n this.summarySearchResults.some(result => result.ProductID == item.ProductID)\r\n );\r\n }\r\n }\r\n\r\n updateCriteriaAndGetResults(criteriaChanged: boolean, updateLoanLabels: boolean = false) {\r\n this.devFinanceDealService.updateSearchCriteriaAndGetResults(this.loanCriteria, criteriaChanged, this.debug1, this.isPostcodeChange, this.isShortlistingMore).then((results: UpdateDevFinanceSearchGetResultResponse) => {\r\n if (this.isPostcodeChange) {\r\n if (results.CriteriaLocation != null) {\r\n this.loanCriteria.Locations = results.CriteriaLocation;\r\n this.summarySearchResults = results.Results;\r\n this.sortSummaryResults();\r\n\r\n } else {\r\n this.postcodeErrorMsg = results.PostCodeErrorMessage;\r\n this.showPostcodeErrorMessage = true;\r\n }\r\n } else {\r\n this.summarySearchResults = results.Results;\r\n this.sortSummaryResults();\r\n }\r\n }).catch((error) => {\r\n\r\n }).finally(() => {\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.clearSelected();\r\n this.isPostcodeChange = false;\r\n\r\n if (updateLoanLabels) {\r\n this.updateLoanLabels();\r\n }\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n getSearchResultCount() {\r\n return this.sharedSearchResultsService.getSearchResultCount(\r\n this.summarySearchResults,\r\n );\r\n }\r\n\r\n onPersonalGuaranteeLevelOptionsChange(e: PersonalGuaranteeLevelEnum) {\r\n switch (e) {\r\n case PersonalGuaranteeLevelEnum.UpTo20Percent:\r\n this.loanCriteria.F_PersonalGuaranteeLevel = 0.2;\r\n break;\r\n case PersonalGuaranteeLevelEnum.TwentyOneTo35Percent:\r\n this.loanCriteria.F_PersonalGuaranteeLevel = 0.35;\r\n break;\r\n case PersonalGuaranteeLevelEnum.ThirtySixTo50Percent:\r\n this.loanCriteria.F_PersonalGuaranteeLevel = 0.5;\r\n break;\r\n case PersonalGuaranteeLevelEnum.OneHundredPercent:\r\n this.loanCriteria.F_PersonalGuaranteeLevel = 1.0;\r\n break;\r\n default:\r\n this.loanCriteria.F_PersonalGuaranteeLevel = null;\r\n break;\r\n }\r\n }\r\n\r\n getPersonalGuaranteeLevelOptions() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_PersonalGuaranteeLevel) {\r\n case 0.2:\r\n value = PersonalGuaranteeLevelEnum.UpTo20Percent;\r\n break;\r\n case 0.35:\r\n value = PersonalGuaranteeLevelEnum.TwentyOneTo35Percent;\r\n break;\r\n case 0.5:\r\n value = PersonalGuaranteeLevelEnum.ThirtySixTo50Percent;\r\n break;\r\n case 1.0:\r\n value = PersonalGuaranteeLevelEnum.OneHundredPercent;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n applyFilters() {\r\n this.loadingData = true;\r\n this.showFilters = false;\r\n this.updateCriteriaAndGetResults(false);\r\n }\r\n\r\n clearClientFilters() {\r\n this.loanCriteria.F_IsFirstTimeDeveloper = null;\r\n this.loanCriteria.F_NumberOfPreviousDevelopments = null;\r\n this.loanCriteria.F_ShareholderDepositRequired = null;\r\n this.shareholderDepositRequired = null;\r\n this.loanCriteria.F_IsPersonalName = null;\r\n this.loanCriteria.F_IsOffshoreCompany = null;\r\n this.loanCriteria.F_IsMainShareholderOverseas = null;\r\n this.loanCriteria.F_PersonalGuaranteeLevel = null;\r\n this.personalGuaranteeLevel = null;\r\n this.loanCriteria.F_HasAdverseCredit = null;\r\n this.loanCriteria.F_MaxCommercialFloorspace = null;\r\n }\r\n\r\n showClearForClientFilters() {\r\n if (\r\n this.loanCriteria.F_IsFirstTimeDeveloper != null ||\r\n this.loanCriteria.F_NumberOfPreviousDevelopments != null ||\r\n this.loanCriteria.F_ShareholderDepositRequired != null ||\r\n this.loanCriteria.F_IsPersonalName != null ||\r\n this.loanCriteria.F_IsOffshoreCompany != null ||\r\n this.loanCriteria.F_IsMainShareholderOverseas != null ||\r\n this.loanCriteria.F_PersonalGuaranteeLevel != null ||\r\n this.loanCriteria.F_HasAdverseCredit != null ||\r\n this.loanCriteria.F_MaxCommercialFloorspace != null\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n toggleCheckbox(variableName) {\r\n if (\r\n this.loanCriteria[variableName] === null ||\r\n this.loanCriteria[variableName] === false\r\n ) {\r\n this.loanCriteria[variableName] = true;\r\n } else {\r\n this.loanCriteria[variableName] = null;\r\n }\r\n }\r\n\r\n clearPropertyFilters() {\r\n this.loanCriteria.F_IsAirRights = null;\r\n this.loanCriteria.F_IsModular = null;\r\n this.loanCriteria.F_IsPermittedDevelopmentScheme = null;\r\n this.loanCriteria.F_IsGradeOneListed = null;\r\n this.loanCriteria.F_IsGradeTwoListed = null;\r\n this.loanCriteria.F_MaxHouseSalesPrice = null;\r\n this.loanCriteria.F_MaxFlatUnitPrice = null;\r\n this.loanCriteria.F_MaxNumberOfUnits = null;\r\n this.loanCriteria.F_MaxPercCommercialForMixedUse = null;\r\n this.loanCriteria.F_MaxSqFtSalePrice = null;\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = null;\r\n this.loanCriteria.F_IsWorkStarted = null;\r\n this.maxHouseSalesPrice = null;\r\n this.maxFlatUnitPrice = null;\r\n this.maxSqFtSalePrice = null;\r\n this.maxPercCommercialForMixedUse = null;\r\n this.maxSqFtSalePriceFlats = null;\r\n this.previousDevelopments = null;\r\n }\r\n\r\n showClearForPropertyFilters() {\r\n if (\r\n this.loanCriteria.F_IsAirRights != null ||\r\n this.loanCriteria.F_IsModular != null ||\r\n this.loanCriteria.F_IsPermittedDevelopmentScheme != null ||\r\n this.loanCriteria.F_IsGradeOneListed != null ||\r\n this.loanCriteria.F_IsGradeTwoListed != null ||\r\n this.loanCriteria.F_MaxHouseSalesPrice != null ||\r\n this.loanCriteria.F_MaxFlatUnitPrice != null ||\r\n this.loanCriteria.F_MaxNumberOfUnits != null ||\r\n this.loanCriteria.F_MaxPercCommercialForMixedUse != null ||\r\n this.loanCriteria.F_MaxSqFtSalePrice != null ||\r\n this.loanCriteria.F_IsWorkStarted != null ||\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats != null\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n clearFinanceFilters() {\r\n this.loanCriteria.F_IsChargeOnAdditionalProperty = null;\r\n this.loanCriteria.F_IsFixedRate = null;\r\n }\r\n\r\n showClearForFinanceFilters() {\r\n if (\r\n this.loanCriteria.F_IsChargeOnAdditionalProperty != null ||\r\n this.loanCriteria.F_IsFixedRate != null\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n clearAllFilters() {\r\n this.clearClientFilters();\r\n this.clearPropertyFilters();\r\n this.clearFinanceFilters();\r\n }\r\n\r\n debugSearch() {\r\n const stringJSON = JSON.stringify(this.loanCriteria);\r\n navigator.clipboard\r\n .writeText(stringJSON)\r\n .then()\r\n .catch((e) => console.log(e));\r\n }\r\n\r\n onClickFilterCancel() {\r\n this.filterProperties.forEach(\r\n (e) => (this.loanCriteria[e] = this.tempLoanCriteria[e]),\r\n );\r\n\r\n this.shareholderDepositRequired = null;\r\n this.personalGuaranteeLevel = null;\r\n this.maxHouseSalesPrice = null;\r\n this.maxFlatUnitPrice = null;\r\n this.maxSqFtSalePrice = null;\r\n this.maxSqFtSalePriceFlats = null;\r\n this.maxPercCommercialForMixedUse = null;\r\n }\r\n\r\n checkFilterSelected(property: string) {\r\n return this.sharedSearchResultsService.checkFilterSelected(\r\n property,\r\n this.tempLoanCriteria,\r\n );\r\n }\r\n\r\n getDisplayTextForProperty(property) {\r\n if (property == \"F_MaxNumberOfUnits\") {\r\n return `Max ${this.loanCriteria.F_MaxNumberOfUnits} Units`;\r\n } else {\r\n return this.sharedSearchResultsService.getDisplayTextForProperty(\r\n property,\r\n );\r\n }\r\n }\r\n\r\n getPropertyValue(property) {\r\n let propertyValue = this.loanCriteria[property];\r\n switch (property) {\r\n case \"F_ShareholderDepositRequired\":\r\n return this.selectListService\r\n .GetShareholderDepositRequired()\r\n .find((item) => item.key === this.getShareholderDepositRequired())\r\n ?.displayName;\r\n case \"F_PersonalGuaranteeLevel\":\r\n return this.selectListService\r\n .GetPersonalGuaranteeLevels()\r\n .find((item) => item.key === this.getPersonalGuaranteeLevelOptions())\r\n ?.displayName;\r\n case \"F_MaxHouseSalesPrice\":\r\n return this.selectListService\r\n .GetMaxHouseSalePrices()\r\n .find((item) => item.key === this.getMaxHouseSalesPrice())\r\n ?.displayName;\r\n case \"F_MaxFlatUnitPrice\":\r\n return this.selectListService\r\n .GetMaxFlatUnitPrices()\r\n .find((item) => item.key === this.getMaxFlatUnitPrice())?.displayName;\r\n case \"F_MaxSqFtSalePrice\":\r\n return this.selectListService\r\n .GetMaxSqFtSalePrices()\r\n .find((item) => item.key === this.getMaxSqFtSalePrice())?.displayName;\r\n case \"F_MaxSqFtSalePriceFlats\":\r\n return this.selectListService\r\n .GetMaxSqFtSalePrices()\r\n .find((item) => item.key === this.getMaxSqFtSalePriceFlats())\r\n ?.displayName;\r\n case \"F_NumberOfPreviousDevelopments\":\r\n return this.selectListService\r\n .GetNumberOfPreviousDevelopments()\r\n .find((item) => item.key === this.getPreviousDevelopments())\r\n ?.displayName;\r\n case \"F_MaxNumberOfUnits\":\r\n return propertyValue;\r\n case \"F_MaxCommercialFloorspace\":\r\n return this.selectListService\r\n .GetMaxCommercialFloorspaceOptions()\r\n .find((item) => item.key === this.tempLoanCriteria.F_MaxCommercialFloorspace)\r\n ?.displayName;\r\n default:\r\n return propertyValue;\r\n }\r\n }\r\n\r\n filterPropertyToText(property: string) {\r\n if (property === \"F_MaxNumberOfUnits\") return;\r\n\r\n let value = this.tempLoanCriteria[property];\r\n if (typeof value == \"boolean\" && value == true) {\r\n return;\r\n } else if (value != null && typeof value != \"boolean\") {\r\n return `: ${this.getPropertyValue(property)}`;\r\n } else if (value == null) {\r\n return;\r\n }\r\n return false;\r\n }\r\n\r\n countFiltersSelected() {\r\n let count = 0;\r\n count = this.sharedSearchResultsService.countFiltersSelected(\r\n this.tempLoanCriteria,\r\n this.filterProperties,\r\n );\r\n return count;\r\n }\r\n\r\n /*saveEnterpriseClientAndRenameDeal() {\r\n this.loadingData = true;\r\n\r\n this.$user.checkEmailExists(this.user.Email).then((response) => {\r\n if (!response) {\r\n let userFullName = this.user.FullName;\r\n let spaceIndex = userFullName.indexOf(' ');\r\n\r\n let firstName = '';\r\n let lastName = '';\r\n\r\n // if not space has been added to the name then put the whole name in the first name field\r\n if (spaceIndex == -1) {\r\n firstName = userFullName;\r\n } else {\r\n firstName = userFullName.substring(0, userFullName.indexOf(' '));\r\n lastName = userFullName.substring(userFullName.indexOf(' ') + 1);\r\n }\r\n\r\n // Set up Client dto\r\n var clientDto = {\r\n FirstName: firstName,\r\n LastName: lastName,\r\n PhoneNumber: this.user.PhoneNumber,\r\n Email: this.user.Email,\r\n BrokerOrganisationId: this.brokerageOrg.Id,\r\n PostalAddress: {\r\n AddressLine1: '',\r\n AddressLine2: '',\r\n AddressLine3: '',\r\n AddressLine4: '',\r\n PostCode: ''\r\n } as PostalAddress\r\n } as ClientDTO;\r\n\r\n var currentDate = new Date();\r\n this.loanCriteria.Name = this.projectName ? this.projectName : firstName + ' ' + lastName + ' Loan Search ' + currentDate.getDate() + \"/\" + (currentDate.getMonth() + 1) + \"/\" + currentDate.getFullYear()\r\n\r\n var request: SaveEnterpriseClientAndRenameSearchRequest = {\r\n BridgingDealDto: null,\r\n CommercialDealDto: null,\r\n ClientDto: clientDto,\r\n ProductFamily: ProductFamilyEnum.Development,\r\n DevFinanceDealDto: this.loanCriteria\r\n }\r\n\r\n this.dealService.saveEnterpriseClientAndRenameDeal(request).then((response) => {\r\n if (response) {\r\n document.getElementById('body').style.overflow = \"auto\";\r\n this.showEnterpriseRegistrationModal = false;\r\n this.loanCriteria = response.DevFinanceDealDto;\r\n if (window.self == window.top) {\r\n sessionStorage.setItem('clientId', this.loanCriteria.DealClients[0].Client.Id.toString());\r\n } else {\r\n this.organisationService.sendDataToParent('clientId', this.loanCriteria.DealClients[0].Client.Id.toString());\r\n }\r\n\r\n this.$user.sendEventToHubspot(this.user, \"ENTERPRISE-CONTACT-REGISTERED\", false, this.orgCode, this.userRole, this.loanCriteria && this.loanCriteria.OrganisationLinkId != null ? this.loanCriteria.OrganisationLinkId : 0, this.loanCriteria.ProductType, this.loanCriteria ? this.loanCriteria.Id : 0);\r\n\r\n // For Google analytics tracking\r\n window.dataLayer = window.dataLayer || [];\r\n window.dataLayer.push({\r\n 'event': 'results_gating_form',\r\n 'loan_product_family': this.productService.getProductFamilyTextForGa(this.loanCriteria.ProductFamily),\r\n 'loan_product_type': this.productService.getProductTypeTextForGa(this.loanCriteria.ProductType, this.loanCriteria.IsFamilyInResidence)\r\n });\r\n }\r\n\r\n }).finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n this.emailExistsError = true;\r\n this.loadingData = false;\r\n }\r\n });\r\n\r\n\r\n }*/\r\n\r\n gotoSignInPage() {\r\n this.$location.path(\"/login\");\r\n }\r\n\r\n goToLink(url) {\r\n var baseUrl = window.location.href.split(\"#!\")[0] + \"#!\";\r\n var newUrl = baseUrl + url;\r\n window.open(newUrl, \"_blank\");\r\n }\r\n\r\n /**\r\n * Opens a 'share a search with client' modal if search do not have client attached to.\r\n * @param none\r\n */\r\n saveResultsForShareSearchToClient() {\r\n if (!this.isSaveAsClicked) {\r\n this.register(false, this.productResultList);\r\n } else {\r\n this.saveSaveAsSearch();\r\n }\r\n this.newSearch = false;\r\n }\r\n\r\n showShareSearchModal() {\r\n this.newSearch = true;\r\n\r\n this.shareDealDto = {\r\n DealId: this.searchid,\r\n DealName: this.isSaveAsClicked ? \"\" : this.loanCriteria?.Name,\r\n ShowLenderNamesAndLogos: this.loanCriteria?.ShowLenderInfoBrokerOverride,\r\n EmailLinkToClient: false,\r\n AccessLevel: CaseAccessLevelEnum.FullAccess,\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n\r\n this.shareDealDto.ClientDto = {\r\n FirstName: \"\",\r\n LastName: \"\",\r\n Email: \"\",\r\n PhoneNumber: \"\",\r\n } as ClientDTO;\r\n }\r\n\r\n /**\r\n * Saves the search or saves the search and create a case.\r\n * @param createCase (boolean set to true when promoting search to case)\r\n */\r\n\r\n //TODO: this functon does not need a productResultList parameter but as views have been shared with devfinance we are passing it\r\n register(createCase: boolean = false, productResultList: number) {\r\n this.loadingData = true;\r\n if (this.isShortlistingMore) {\r\n if (this.validateWithdrawnLendersUnique() == true) {\r\n this.dealLenderService.shortlistMoreLenders(this.loanCriteria.Id, this.getDealLenders(this.comparisonList), this.hasSearchChanged).then((response) => {\r\n }).then(() => {\r\n this.getSelectedProducts();\r\n }).finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n this.loadingData = false;\r\n }\r\n } else {\r\n if (\r\n this.shareDealDto &&\r\n this.shareDealDto.DealName &&\r\n this.shareDealDto.DealName.length > 0\r\n ) {\r\n this.loanCriteria.Name = this.shareDealDto.DealName;\r\n }\r\n\r\n var request: SaveDevFinanceSearchRequest = {\r\n DealDto: this.loanCriteria,\r\n ShareDealDto: null,\r\n OrgCode: \"\",\r\n EnterpriseClientDto: null,\r\n };\r\n\r\n this.devFinanceDealService\r\n .saveDevFinanceSearchReturnsId(request)\r\n .then((response) => {\r\n this.loanCriteria.Id = response as number;\r\n this.loadingData = false;\r\n\r\n // Creating the case is done on the casedashboard for deals\r\n if (createCase) {\r\n this.$location.path(\r\n \"/devfinancecasedashboard/\" + this.loanCriteria.Id + \"/\" + true,\r\n );\r\n }\r\n\r\n var shortlistDealLenders = this.getDealLenders(this.comparisonList);\r\n\r\n this.dealLenderService\r\n .addUpdatelistreturnonlyids(shortlistDealLenders)\r\n .then((response) => {\r\n if (this.dealLenders != null) {\r\n let deallenders = this.dealLenders.filter(\r\n (lender) => response.indexOf(lender.Id) === -1,\r\n );\r\n\r\n deallenders.forEach((lender) =>\r\n this.dealLenderService.markasdeleted(lender.Id),\r\n );\r\n }\r\n })\r\n .finally(() => {\r\n this.getSelectedProducts();\r\n this.isClicked = false;\r\n this.newSearch = false;\r\n this.isProceedClicked = false;\r\n this.showSaveResults = null;\r\n this.loadingData = false;\r\n });\r\n })\r\n .catch((response) => {\r\n //TODO BRIDGING - capture if an error has occurred and process it\r\n //this.isError = true;\r\n this.isProceedClicked = false;\r\n })\r\n .finally(() => { });\r\n }\r\n }\r\n\r\n /**\r\n * updates a seach with introducee details and saves it and sends emil to client if 'notifyBorrower' is set to true.\r\n * @param notifyBorrower\r\n */\r\n\r\n sendResultsToClient(notifyBorrower) {\r\n if (this.isSaveAsClicked) {\r\n this.saveSaveAsSearch(true);\r\n } else {\r\n this.loadingData = true;\r\n this.dealService\r\n .shareDealWithClient(this.shareDealDto)\r\n .then(() => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.shareDealDto.ClientDto.FirstName +\r\n \" \" +\r\n this.shareDealDto.ClientDto.LastName;\r\n //this.loanCriteria.DealClients[0] = this.shareDealDto.ClientDto;\r\n this.loanCriteria.Name = this.shareDealDto.DealName;\r\n this.newSearch = false;\r\n this.showMsg = true;\r\n this.loadingData = false;\r\n this.isAssigned = true;\r\n this.reloadSearch = true;\r\n })\r\n .finally(() => {\r\n delete this.shareDealDto;\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n\r\n getDealLenders(selectedLenders: LenderResultSummaryDTO[]) {\r\n var lendersList: DealLenderDTO[] = [];\r\n\r\n if (this.dealClientUniqueRef || this.dealUniqueRef) {\r\n this.searchid = this.loanCriteria.Id;\r\n }\r\n\r\n selectedLenders.forEach(({ ProductID, LenderID, GrossLoan }) => {\r\n var dealLender: DealLenderDTO;\r\n\r\n if (this.dealLenders) {\r\n dealLender = this.dealLenders.find(\r\n (dl) =>\r\n dl.DealId === this.searchid &&\r\n dl.ProductId === ProductID &&\r\n dl.LenderId === LenderID,\r\n );\r\n }\r\n\r\n if (!dealLender) {\r\n dealLender = {\r\n DealId: this.searchid,\r\n ProductId: ProductID,\r\n LenderId: LenderID,\r\n Status: CaseLenderStateEnum.Shortlisted,\r\n OriginalTotalGrossLoan: GrossLoan,\r\n } as DealLenderDTO;\r\n }\r\n\r\n lendersList.push(dealLender);\r\n });\r\n\r\n var unselecteLenderList = [];\r\n\r\n if (this.dealLenders) {\r\n unselecteLenderList = this.dealLenders.filter(dl => !lendersList.some(ll => ll.ProductId === dl.ProductId && ll.LenderId === dl.LenderId) && (dl.Status == CaseLenderStateEnum.Rejected || dl.Status == CaseLenderStateEnum.Withdrawn));\r\n }\r\n\r\n if (unselecteLenderList.length > 0) {\r\n unselecteLenderList.forEach((l) => {\r\n l.IsDeleted = true;\r\n lendersList.push(l);\r\n });\r\n }\r\n\r\n return lendersList;\r\n }\r\n\r\n /** closes share results modal*/\r\n cancelNewSearch() {\r\n this.newSearch = false;\r\n this.shareDealDto.ClientDto = null;\r\n this.existingborrower = null;\r\n this.showClientDetails = false;\r\n this.selecteduserName = null;\r\n this.isSaveAsClicked = false;\r\n this.sharedSearch = false;\r\n if (this.tempSearchName) {\r\n this.loanCriteria.Name = this.tempSearchName;\r\n this.tempSearchName = \"\";\r\n }\r\n }\r\n\r\n openSendResultsToBorrowerModal() {\r\n var client = this.loanCriteria.DealClients[0][\"Client\"]; // TODO Deal FUTURE- always want to assume there's one for now until there's a redesign of sharing\r\n this.shareDealDto.DealId = this.loanCriteria.Id;\r\n this.shareDealDto.DealName = this.loanCriteria.Name;\r\n this.shareDealDto.IsApplicant = true;\r\n this.shareDealDto.IsPrimary = true;\r\n this.shareDealDto.ClientDto = {\r\n FirstName: client.FirstName,\r\n LastName: client.LastName,\r\n Email: client.Email,\r\n PhoneNumber: client.PhoneNumber,\r\n ClientUserId: client.ClientUserId,\r\n } as ClientDTO;\r\n this.existingborrower = null;\r\n this.newSearch = true;\r\n this.sharedSearch = true;\r\n }\r\n\r\n viewClientsDashboardForNewSearch(userName: string) {\r\n this.loadingData = true;\r\n this.shareDealDto.IsApplicant = true;\r\n this.shareDealDto.IsPrimary = true;\r\n //Look up client's account details\r\n this.$user.searchByEmail(userName).then((users) => {\r\n this.shareDealDto.ClientDto.FirstName = users[0].FirstName;\r\n this.shareDealDto.ClientDto.Email = users[0].Email;\r\n this.shareDealDto.ClientDto.LastName = users[0].LastName;\r\n this.shareDealDto.ClientDto.PhoneNumber = users[0].PhoneNumber;\r\n this.shareDealDto.ClientDto.ClientUserId = users[0].Id;\r\n this.showClientDetails = true;\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n /**\r\n * Sends email to client attached to the search\r\n */\r\n sendShareSearchEmailToClient() {\r\n this.loadingData = true;\r\n this.shareDealDto.EmailLinkToClient = true;\r\n this.dealService\r\n .shareDealWithClient(this.shareDealDto)\r\n .then(() => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.shareDealDto.ClientDto.FirstName +\r\n \" \" +\r\n this.shareDealDto.ClientDto.LastName;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.newSearch = false;\r\n this.showMsg = true;\r\n this.loadingData = false;\r\n this.sharedSearch = false;\r\n });\r\n }\r\n\r\n applyForLoan() {\r\n this.isProceedClicked = true;\r\n this.register(true, this.productResultList);\r\n }\r\n\r\n returnToCase() {\r\n if (this.isShortlistingMore) {\r\n // copy newly selected products/lenders to caselender\r\n this.dealLenderService\r\n .shortlistMoreLenders(\r\n this.loanCriteria.Id,\r\n this.getDealLenders(this.comparisonList),\r\n this.hasSearchChanged,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n //sending 'Promote' as true if search has changed & 'NewShortlist' as true if isShortlistingMore\r\n this.$location.path(\r\n \"/devfinancecasedashboard/\" +\r\n this.loanCriteria.Id +\r\n \"/\" +\r\n null +\r\n \"/\" +\r\n true +\r\n \"/\" +\r\n this.hasSearchChanged,\r\n );\r\n }\r\n });\r\n } else {\r\n this.dealLenderService\r\n .updateShortlistedLenders(this.getDealLenders(this.comparisonList))\r\n .then((response) => {\r\n this.$location.path(\r\n \"/devfinancecasedashboard/\" + this.loanCriteria.Id,\r\n );\r\n });\r\n }\r\n }\r\n\r\n toggleShowLenderNamesBrokerOverride() {\r\n if (this.searchPanelForm.$valid && !this.showPostcodeErrorMessage) {\r\n this.updateCriteriaAndGetResults(false, true);\r\n }\r\n }\r\n\r\n mortgageTermToLoanTerm(): void {\r\n this.loanCriteria.LoanTermReq = this.mortgageTerm * 12;\r\n }\r\n\r\n /**Update the loan label in the comparison results based on the loan label returned in the results\r\n * Primary purpose is to update the loan label when the show lender names button is toggled\r\n * */\r\n updateLoanLabels() {\r\n for (var i = 0; i < this.comparisonList.length; i++) {\r\n let resultIndex = this.summarySearchResults.findIndex(\r\n (item) => item.ProductID == this.comparisonList[i].ProductID,\r\n );\r\n\r\n if (resultIndex > -1) {\r\n this.comparisonList[i].LoanLabel =\r\n this.summarySearchResults[resultIndex].LoanLabel;\r\n }\r\n }\r\n\r\n //This is used in shortlisting pdf\r\n this.prepareDataForShortlistPdf();\r\n }\r\n\r\n datasetupOnMaxLoanRequiredChange() {\r\n this.loanCriteria = this.dealService.dataSetupOnMaxLoanRequiredChange(\r\n this.loanCriteria,\r\n );\r\n this.updateSearchViaSlider();\r\n }\r\n\r\n showContactbrokerButton() {\r\n if (\r\n this.brokerageOrg != null &&\r\n this.loanCriteria != null &&\r\n this.loanCriteria.DealClients != null &&\r\n this.loanCriteria.DealClients.length > 0 &&\r\n this.loanCriteria.DealClients[0]?.Client != null &&\r\n this.loanCriteria.DealClients[0].Client.Email.length > 0\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n getPreviousDevelopments() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_NumberOfPreviousDevelopments) {\r\n case 1:\r\n value = PreviousDevelopmentsEnum.One;\r\n break;\r\n case 2:\r\n value = PreviousDevelopmentsEnum.Two;\r\n break;\r\n case 3:\r\n value = PreviousDevelopmentsEnum.Three;\r\n break;\r\n case 4:\r\n value = PreviousDevelopmentsEnum.FourOrMore;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n getShareholderDepositRequired() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_ShareholderDepositRequired) {\r\n case 0:\r\n value = ShareholderDepositRequiredEnum.None;\r\n break;\r\n case 0.25:\r\n value = ShareholderDepositRequiredEnum.UpTo25Percent;\r\n break;\r\n case 0.5:\r\n value = ShareholderDepositRequiredEnum.TwentyFiveTo50Percent;\r\n break;\r\n case 1.0:\r\n value = ShareholderDepositRequiredEnum.FiftyPercentPlus;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n onShareholderDepositRequiredChange(e: ShareholderDepositRequiredEnum) {\r\n switch (e) {\r\n case ShareholderDepositRequiredEnum.None:\r\n this.loanCriteria.F_ShareholderDepositRequired = 0;\r\n break;\r\n case ShareholderDepositRequiredEnum.UpTo25Percent:\r\n this.loanCriteria.F_ShareholderDepositRequired = 0.25;\r\n break;\r\n case ShareholderDepositRequiredEnum.TwentyFiveTo50Percent:\r\n this.loanCriteria.F_ShareholderDepositRequired = 0.5;\r\n break;\r\n case ShareholderDepositRequiredEnum.FiftyPercentPlus:\r\n this.loanCriteria.F_ShareholderDepositRequired = 1.0;\r\n break;\r\n default:\r\n this.loanCriteria.F_ShareholderDepositRequired = null;\r\n break;\r\n }\r\n }\r\n\r\n onMaxHouseSalesPriceChange(e: MaxHouseSalePriceEnum) {\r\n switch (e) {\r\n case MaxHouseSalePriceEnum.UpTo1Million:\r\n this.loanCriteria.F_MaxHouseSalesPrice = 1000000;\r\n break;\r\n case MaxHouseSalePriceEnum.UpTo2Million:\r\n this.loanCriteria.F_MaxHouseSalesPrice = 2000000;\r\n break;\r\n case MaxHouseSalePriceEnum.UpTo5Million:\r\n this.loanCriteria.F_MaxHouseSalesPrice = 5000000;\r\n break;\r\n case MaxHouseSalePriceEnum.NoMax:\r\n this.loanCriteria.F_MaxHouseSalesPrice = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxHouseSalesPrice = null;\r\n break;\r\n }\r\n }\r\n\r\n getMaxHouseSalesPrice() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_MaxHouseSalesPrice) {\r\n case 1000000:\r\n value = MaxHouseSalePriceEnum.UpTo1Million;\r\n break;\r\n case 2000000:\r\n value = MaxHouseSalePriceEnum.UpTo2Million;\r\n break;\r\n case 5000000:\r\n value = MaxHouseSalePriceEnum.UpTo5Million;\r\n break;\r\n case -999:\r\n value = MaxHouseSalePriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n onMaxFlatUnitPriceChange(e: MaxFlatUnitPriceEnum) {\r\n switch (e) {\r\n case MaxFlatUnitPriceEnum.UpTo1Million:\r\n this.loanCriteria.F_MaxFlatUnitPrice = 1000000;\r\n break;\r\n case MaxFlatUnitPriceEnum.UpTo2Million:\r\n this.loanCriteria.F_MaxFlatUnitPrice = 2000000;\r\n break;\r\n case MaxFlatUnitPriceEnum.UpTo3Million:\r\n this.loanCriteria.F_MaxFlatUnitPrice = 3000000;\r\n break;\r\n case MaxFlatUnitPriceEnum.NoMax:\r\n this.loanCriteria.F_MaxFlatUnitPrice = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxFlatUnitPrice = null;\r\n break;\r\n }\r\n }\r\n\r\n getMaxFlatUnitPrice() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_MaxFlatUnitPrice) {\r\n case 1000000:\r\n value = MaxFlatUnitPriceEnum.UpTo1Million;\r\n break;\r\n case 2000000:\r\n value = MaxFlatUnitPriceEnum.UpTo2Million;\r\n break;\r\n case 3000000:\r\n value = MaxFlatUnitPriceEnum.UpTo3Million;\r\n break;\r\n case -999:\r\n value = MaxFlatUnitPriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n onMaxSqFtSalePriceChange(e: MaxSqFtSalePriceEnum) {\r\n switch (e) {\r\n case MaxSqFtSalePriceEnum.UpTo850:\r\n this.loanCriteria.F_MaxSqFtSalePrice = 850;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1000:\r\n this.loanCriteria.F_MaxSqFtSalePrice = 1000;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1500:\r\n this.loanCriteria.F_MaxSqFtSalePrice = 1500;\r\n break;\r\n case MaxSqFtSalePriceEnum.NoMax:\r\n this.loanCriteria.F_MaxSqFtSalePrice = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxSqFtSalePrice = null;\r\n break;\r\n }\r\n }\r\n\r\n onMaxSqFtFlatsSalePriceChange(e: MaxSqFtSalePriceEnum) {\r\n switch (e) {\r\n case MaxSqFtSalePriceEnum.UpTo850:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = 850;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1000:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = 1000;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1500:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = 1500;\r\n break;\r\n case MaxSqFtSalePriceEnum.NoMax:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = null;\r\n break;\r\n }\r\n }\r\n\r\n getMaxSqFtSalePrice() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_MaxSqFtSalePrice) {\r\n case 850:\r\n value = MaxSqFtSalePriceEnum.UpTo850;\r\n break;\r\n case 1000:\r\n value = MaxSqFtSalePriceEnum.UpTo1000;\r\n break;\r\n case 1500:\r\n value = MaxSqFtSalePriceEnum.UpTo1500;\r\n break;\r\n case -999:\r\n value = MaxSqFtSalePriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n getMaxSqFtSalePriceFlats() {\r\n var value = null;\r\n switch (this.tempLoanCriteria.F_MaxSqFtSalePriceFlats) {\r\n case 850:\r\n value = MaxSqFtSalePriceEnum.UpTo850;\r\n break;\r\n case 1000:\r\n value = MaxSqFtSalePriceEnum.UpTo1000;\r\n break;\r\n case 1500:\r\n value = MaxSqFtSalePriceEnum.UpTo1500;\r\n break;\r\n case -999:\r\n value = MaxSqFtSalePriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n CalcPurchaseAdditionalCosts(): number {\r\n if (this.loanCriteria) {\r\n var res: number = 0;\r\n\r\n if (this.loanCriteria.StampDutyLandTax) {\r\n res += Number(this.loanCriteria.StampDutyLandTax);\r\n }\r\n if (this.loanCriteria.SalesAgentFees) {\r\n res += Number(this.loanCriteria.SalesAgentFees);\r\n }\r\n if (this.loanCriteria.PurchaseLegalFees) {\r\n res += Number(this.loanCriteria.PurchaseLegalFees);\r\n }\r\n\r\n if (this.loanCriteria.OwnOrPurchase == OwnOrPurchaseEnum.Own) {\r\n if (this.loanCriteria.LandTotalOtherCosts) {\r\n res += Number(this.loanCriteria.LandTotalOtherCosts);\r\n }\r\n }\r\n\r\n if (this.loanCriteria.OwnOrPurchase == OwnOrPurchaseEnum.Purchasing) {\r\n if (this.loanCriteria.PurchaseCosts) {\r\n res += Number(this.loanCriteria.PurchaseCosts);\r\n }\r\n }\r\n\r\n return res;\r\n }\r\n }\r\n\r\n isSelectedResult(offer: LenderResultSummaryDTO, index: number) {\r\n return this.comparisonContains(offer);\r\n }\r\n\r\n isResultAvailableToSelect(offer: LenderResultSummaryDTO) {\r\n return (\r\n offer.IsCaseLender &&\r\n offer.CaseLenderStatus != CaseLenderStateEnum.Shortlisted\r\n );\r\n }\r\n\r\n contingencyChanged() {\r\n this.calculateContingency();\r\n }\r\n\r\n updateLoanRequiredValue() {\r\n if (this.loanCriteria.MaxLoanRequired) {\r\n this.loanCriteria.NetLoanRequired = 0;\r\n this.updateSearchViaSlider();\r\n } else {\r\n this.updateSearchViaSlider();\r\n }\r\n }\r\n\r\n calculateContingency() {\r\n if (this.loanCriteria.IncludesContingency) {\r\n this.contingencyValue =\r\n this.loanCriteria.BuildCosts -\r\n this.loanCriteria.BuildCosts /\r\n (1 + Number(this.loanCriteria.Contingency));\r\n }\r\n this.calculateTotalBuildCost();\r\n }\r\n\r\n calculateTotalBuildCost() {\r\n if (this.loanCriteria.IncludesContingency) {\r\n this.loanCriteria.BuildCosts =\r\n Number(this.loanCriteria.BuildCosts) - this.contingencyValue;\r\n }\r\n\r\n this.updateSearchViaSlider();\r\n }\r\n\r\n getRegionByPostcode() {\r\n if (\r\n this.loanCriteria.PostcodeSearchString &&\r\n this.loanCriteria.PostcodeSearchString.replace(\" \", \"\").length >= 2\r\n ) {\r\n if (\r\n this.dealService.isValidPostcodeString(\r\n this.loanCriteria.PostcodeSearchString,\r\n )\r\n ) {\r\n this.showPostcodeErrorMessage = false;\r\n this.isPostcodeChange = true;\r\n this.updateSearchViaSlider();\r\n } else {\r\n this.postcodeErrorMsg =\r\n \"At least one letter and one number must be entered e.g. SW1.\";\r\n this.showPostcodeErrorMessage = true;\r\n }\r\n }\r\n }\r\n\r\n calculateMonthsSinceOrigPurchase() {\r\n let date1 = new Date(this.loanCriteria.OriginalPurchaseDate);\r\n let date2 = new Date();\r\n let months;\r\n months = (date2.getFullYear() - date1.getFullYear()) * 12;\r\n months -= date1.getMonth();\r\n months += date2.getMonth();\r\n return months;\r\n }\r\n\r\n sortByField(field) {\r\n this.loanCriteria.SortBy = field;\r\n this.updateCriteriaAndGetResults(false, false);\r\n this.showSortBy = !this.showSortBy;\r\n }\r\n\r\n sortSummaryResults() {\r\n switch (this.loanCriteria.SortBy) {\r\n case SortByEnum.ROCE:\r\n this.summarySearchResults.sort(\r\n (a, b) => b.ROCE - a.ROCE || a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.TrueMonthlyCost:\r\n this.summarySearchResults.sort(\r\n (a, b) => a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.NetLoanSize:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n b.NetLoan - a.NetLoan || a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.LenderName:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.LoanLabel.localeCompare(b.LoanLabel) ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.InterestRate:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.Interest - b.Interest || a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.ArrangementFee:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.ArrangementFee - b.ArrangementFee ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.DepositEquity:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.Deposit - b.Deposit || a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.LTGDV:\r\n this.lenderResultService\r\n .sortProductsByLTGDV(this.summarySearchResults)\r\n .then((sortedResults) => {\r\n this.summarySearchResults = sortedResults;\r\n })\r\n .catch((error) => {\r\n console.error(\"Error sorting by LTGDV:\", error);\r\n });\r\n break;\r\n default:\r\n this.summarySearchResults.sort((a, b) => {\r\n if (a.NetLoan < b.NetLoan) return 1;\r\n if (a.NetLoan > b.NetLoan) return -1;\r\n\r\n if (a.TrueMonthlyCost > b.TrueMonthlyCost) return 1;\r\n if (a.TrueMonthlyCost < b.TrueMonthlyCost) return -1;\r\n\r\n return 0;\r\n });\r\n this.loanCriteria.SortBy = SortByEnum.NetLoanSize;\r\n }\r\n\r\n for (var i = 0; i < this.summarySearchResults.length; i++) {\r\n this.summarySearchResults[i].SelectedRowNumber = i + 1;\r\n }\r\n }\r\n\r\n isFieldZero(fieldName) {\r\n if (this.loanCriteria) {\r\n const fieldValue = this.loanCriteria[fieldName];\r\n if (fieldValue == null || fieldValue === \"0\" || fieldValue === 0) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n submitLenderReferral() {\r\n this.loadingData = true;\r\n this.lenderReferralData.DealId = this.loanCriteria.Id;\r\n this.dealClientService\r\n .submitLenderReferral(this.lenderReferralData)\r\n .then((response) => {\r\n if (response) {\r\n this.displayMsg = \"Your referral has been submitted.\";\r\n this.showMsg = true;\r\n this.isLenderReferredSearch = true;\r\n } else {\r\n this.displayMsg = \"Error while making a referral, please try later.\";\r\n this.showMsg = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n this.lenderReferralData = null;\r\n sessionStorage.removeItem(\"lenderReferralData\");\r\n });\r\n }\r\n\r\n onClickSaveAs() {\r\n this.isSaveAsClicked = true;\r\n\r\n if (this.isAdmin || this.isBroker) {\r\n if (!this.shareDealDto) {\r\n this.shareDealDto = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n }\r\n this.shareDealDto.DealName = \"\";\r\n this.showShareSearchModal();\r\n } else {\r\n this.showSaveResults = 3;\r\n }\r\n }\r\n\r\n saveSaveAsSearch(attachClient = false) {\r\n this.loadingData = true;\r\n let newSearchName = this.isBroker || this.isAdmin ? this.shareDealDto.DealName : this.saveAsSearchName;\r\n\r\n if (newSearchName.length == 0) {\r\n newSearchName = this.loanCriteria.Name + ' (Copy)';\r\n }\r\n\r\n var request: SaveAsSearchRequest = {\r\n ShareDealDto: attachClient ? this.shareDealDto : null,\r\n ProductFamily: this.loanCriteria.ProductFamily,\r\n SearchId: this.loanCriteria.Id,\r\n NewSearchName: newSearchName,\r\n };\r\n\r\n this.dealService\r\n .saveSaveAsSearch(request)\r\n .then((result) => {\r\n this.displayMsg = `${newSearchName} search has been saved to your dashboard.`;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.cancelNewSearch();\r\n this.loadingData = false;\r\n this.isSaveAsClicked = false;\r\n this.shareDealDto = {\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n this.saveAsSearchName = \"\";\r\n this.showSaveResults = null;\r\n this.showMsg = true;\r\n });\r\n }\r\n\r\n reloadPage() {\r\n if (this.reloadSearch) {\r\n window.location.reload();\r\n }\r\n }\r\n\r\n /** Redirects to the user dashboard */\r\n goToUserDashboard() {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n\r\n // Enterprise widget\r\n openRegisterModal() {\r\n this.showRegisterModal = true;\r\n }\r\n\r\n onEditSearchNameClick() {\r\n this.toggleEditSearchName = !this.toggleEditSearchName;\r\n }\r\n\r\n /*onClickEligibleConfirm() {\r\n this.loadingData = true;\r\n this.loanCriteria.DealClients[0].Client.PhoneNumber =\r\n this.enterpriseClient.PhoneNumber;\r\n this.clientService\r\n .addUpdatereturnonlyid(this.loanCriteria.DealClients[0].Client)\r\n .then((response) => {\r\n this.showEligibleModal = false;\r\n window.scrollTo(0, 0);\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }*/\r\n\r\n onSortbyClick() {\r\n this.closeFilterOptions();\r\n this.closeExportDropdown();\r\n this.showSortBy = !this.showSortBy;\r\n }\r\n\r\n onFilterClick() {\r\n this.closeSortByDropdown();\r\n this.closeExportDropdown();\r\n this.showFilters = !this.showFilters;\r\n }\r\n\r\n onExportClick() {\r\n this.prepareDataForShortlistPdf();\r\n this.closeSortByDropdown();\r\n this.closeFilterOptions();\r\n this.showExportOptions = !this.showExportOptions;\r\n }\r\n\r\n getSelectedSortByOptionText() {\r\n if (this.loanCriteria) {\r\n switch (this.loanCriteria.SortBy) {\r\n case SortByEnum.TrueMonthlyCost:\r\n return \"True Monthly Cost\";\r\n case SortByEnum.NetLoanSize:\r\n return \"Net Loan Size\";\r\n case SortByEnum.LenderCosts:\r\n return \"Lender Costs (Est.)\";\r\n case SortByEnum.LenderName:\r\n return \"Lender Name (A-Z)\";\r\n case SortByEnum.InterestRate:\r\n return \"Interest Rate\";\r\n case SortByEnum.ArrangementFee:\r\n return \"Arrangement Fee\";\r\n case SortByEnum.DepositEquity:\r\n return \"Est. Deposit/Equity\";\r\n case SortByEnum.ROCE:\r\n return \"ROCE\";\r\n case SortByEnum.LTGDV:\r\n return \"LTGDV\";\r\n default:\r\n return \"\";\r\n }\r\n } else {\r\n return \"\";\r\n }\r\n }\r\n\r\n createAccount() {\r\n this.loadingData = true;\r\n this.enterpriseClient.OrgUniqueRef = this.brokerageOrg.UniqueRef;\r\n this.$user\r\n .registerEnterpriseUserAndSaveShortlisteResults(this.enterpriseClient, this.getDealLenders(this.comparisonList))\r\n .then((user) => {\r\n // clean up session storage\r\n if (window.self == window.top) {\r\n sessionStorage.removeItem(\"clientId\");\r\n sessionStorage.removeItem(\"userRole\");\r\n } else {\r\n this.organisationService.sendDataToParent(\"clientId\", \"\");\r\n this.organisationService.sendDataToParent(\"userRole\", \"\");\r\n }\r\n this.login(\"ENTERPRISE-LEAD-REGISTERED-FROM-RESULTS-PAGE\", EventLogEnum.EnterpriseUserRegistration);\r\n })\r\n .catch((response) => {\r\n this.error = \"Error while registering an account, please try again later.\";\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n login(eventIdentifier: string = \"ENTERPRISE-CONTACT-LOGGEDIN-FROM-RESULTS-PAGE\", eventType: EventLogEnum = EventLogEnum.EnterpriseUserLogin) {\r\n this.loadingData = true;\r\n if (!this.$cookies.get(\"access_token\")) {\r\n this.$auth\r\n .login(\r\n this.enterpriseClient.UserName,\r\n this.enterpriseClient.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n let expiry: Date = response;\r\n this.error =\"\";\r\n this.$user.getcurentuserrecord().then((response) => {\r\n this.eventLogService.logEvent(\r\n eventIdentifier,\r\n eventType,\r\n this.loanCriteria.ProductType,\r\n this.loanCriteria.Id,\r\n \"\",\r\n \"\",\r\n this.loanCriteria.DealClients[0]?.Client.Id?.toString()\r\n );\r\n\r\n (this.$rootScope as any).currentUser = response;\r\n this.$cookies.put(\"user_firstname\", response.FirstName, {\r\n expires: expiry,\r\n });\r\n (this.$rootScope as any).selectedUser = response;\r\n this.$rootScope.$broadcast(\"login\"); //tell everyone you have logged in\r\n if (eventType == EventLogEnum.EnterpriseUserRegistration) sessionStorage.setItem('showConfirmClientPhoneNo', 'true');\r\n this.$location.path(`/devfinanceresults/${this.loanCriteria.Id}`);\r\n });\r\n }).catch((response) => {\r\n this.isLoginError = true;\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n\r\n onClickLogin() {\r\n this.saveShortlistedLenders();\r\n this.login();\r\n }\r\n\r\n saveShortlistedLenders() {\r\n var shortlistDealLenders = this.getDealLenders(this.comparisonList);\r\n this.dealLenderService\r\n .updateShortlistedLenders(shortlistDealLenders)\r\n .then((response) => { });\r\n }\r\n\r\n populateEnterpriseClientValue(eventType) {\r\n if (this.loanCriteria.DealClients[0] != null) {\r\n this.enterpriseClient.FirstName =\r\n this.loanCriteria.DealClients[0].Client.FirstName;\r\n this.enterpriseClient.LastName =\r\n this.loanCriteria.DealClients[0].Client.LastName;\r\n this.enterpriseClient.Email =\r\n this.loanCriteria.DealClients[0].Client.Email;\r\n this.enterpriseClient.UserName =\r\n this.loanCriteria.DealClients[0].Client.Email;\r\n this.enterpriseClient.DealClientUniqueRef = this.loanCriteria.DealClients[0].UniqueRef;\r\n this.enterpriseClient.OrgCode = this.orgCode;\r\n this.enterpriseClient.PhoneNumber =\r\n this.loanCriteria.DealClients[0].Client.PhoneNumber;\r\n if (this.loanCriteria.DealClients[0].Client.ClientUserId) {\r\n this.showRegisterModal = true;\r\n this.showLoginSection = true;\r\n }\r\n\r\n if (this.loanCriteria.OrganisationLinkId) {\r\n this.organisationLinkService\r\n .getOrganisationLinkLogoByLinkIdAndLogPageLoadEvent(Number(this.loanCriteria.OrganisationLinkId), eventType, this.loanCriteria.Id, this.loanCriteria.ProductType, this.loanCriteria.DealClients[0]?.Client?.Email, this.loanCriteria.DealClients[0]?.Client?.Id.toString())\r\n .then((logoUrl) => {\r\n if (logoUrl) {\r\n var imgs = document.getElementsByTagName(\"img\");\r\n imgs[0].src = logoUrl\r\n }\r\n });\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n eventType,\r\n this.orgCode,\r\n this.loanCriteria.DealClients.length > 0\r\n ? this.loanCriteria.DealClients[0].Client.Email\r\n : \"\",\r\n \"Client\",\r\n this.loanCriteria.OrganisationLinkId != null\r\n ? this.loanCriteria.OrganisationLinkId\r\n : 0,\r\n this.loanCriteria?.ProductType,\r\n \"\",\r\n this.loanCriteria?.Id,\r\n this.loanCriteria.DealClients.length > 0\r\n ? this.loanCriteria.DealClients[0].Client.Id.toString()\r\n : null,\r\n );\r\n }\r\n\r\n //Todo Roopa: do we need a broker details?\r\n this.getOrganisationAndBrokerDetails();\r\n }\r\n }\r\n\r\n returnShortlistedDealLenderStatusText(item: LenderResultSummaryDTO) {\r\n if (this.checkDeletedLender(item.LenderID.toString(), item.ProductID.toString())) {\r\n return \"Previously Deleted\";\r\n }\r\n\r\n if (item.IsDealLender && (this.loanCriteria.Status != CaseStatusEnum.Search && this.loanCriteria.Status != CaseStatusEnum.NewCase && this.loanCriteria.Status != CaseStatusEnum.ReadyToSubmit)) {\r\n switch (item.DealLenderStatus) {\r\n case CaseLenderStateEnum.Shortlisted:\r\n return \"Shortlisted\";\r\n case CaseLenderStateEnum.Received:\r\n return \"Awaiting DIP\";\r\n case CaseLenderStateEnum.Offered:\r\n return \"DIP Received\";\r\n case CaseLenderStateEnum.Rejected:\r\n return \"Lender Rejected\";\r\n case CaseLenderStateEnum.Withdrawn:\r\n return \"Lender Withdrawn\";\r\n default:\r\n break\r\n }\r\n }\r\n }\r\n\r\n isProceedButtonDisabled(): boolean {\r\n\r\n if (this.isShortlistingMore) {\r\n if (this.validateWithdrawnLendersUnique() == false)\r\n return true;\r\n }\r\n\r\n const validLenders = this.comparisonList?.filter(\r\n (item) =>\r\n item.DealLenderStatus !== CaseLenderStateEnum.Rejected &&\r\n item.DealLenderStatus !== CaseLenderStateEnum.Withdrawn\r\n ) || [];\r\n \r\n if (\r\n !validLenders ||\r\n validLenders.length < 1 ||\r\n validLenders.length > this.noOfShortlistAllowed ||\r\n this.isProceedClicked == true\r\n ) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n onSaveClick() {\r\n if (this.isAssigned) {\r\n this.isSaveorSaveAsClicked = true;\r\n this.register(false, this.productResultList);\r\n } else {\r\n this.showShareSearchModal();\r\n }\r\n }\r\n\r\n getProductLastVerifiedDates(productIds: number[]) {\r\n this.productService.getLastVerifiedDates(productIds).then((response) => {\r\n productIds.forEach(id => {\r\n if (response[id] != null) {\r\n this.productLastVerifiedDates[id] = this.formatDate(response[id]);\r\n }\r\n })\r\n });\r\n }\r\n\r\n formatDate = (dateString) => {\r\n const date = new Date(dateString);\r\n return date.toLocaleDateString('en-GB');\r\n };\r\n\r\n validateWithdrawnLendersUnique(): boolean {\r\n if (this.isShortlistingMore) {\r\n const matchingHiddenDeallender = this.HiddenDealLenderList.filter(dl =>\r\n this.comparisonList.some(l => dl.LenderId === l.LenderID && dl.ProductId != l.ProductID && l.DealLenderStatus != CaseLenderStateEnum.Withdrawn) && dl.Status == CaseLenderStateEnum.Withdrawn\r\n );\r\n\r\n const matchingDeallender = this.dealLenders?.filter(dl =>\r\n this.comparisonList.some(l => dl.LenderId === l.LenderID && dl.ProductId != l.ProductID && l.DealLenderStatus != CaseLenderStateEnum.Withdrawn) && dl.Status == CaseLenderStateEnum.Withdrawn\r\n );\r\n\r\n if (matchingHiddenDeallender.length > 0 || (matchingDeallender && matchingDeallender.length > 0)) return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n closeFilterOptions() {\r\n this.showFilters = false;\r\n }\r\n\r\n closeSortByDropdown() {\r\n this.showSortBy = false;\r\n }\r\n\r\n closeExportDropdown() {\r\n this.showExportOptions = false;\r\n }\r\n\r\n goToNewSearch() {\r\n this.sharedDataService.cleanLenderReferralSessionStorage();\r\n // If the current user is a broker and doesn't have a subscription then don't allow them to create a new search\r\n if (this.isBroker && !this.selectedUser.HasActiveSubscription) {\r\n return;\r\n }\r\n\r\n if (!this.loadingData) {\r\n (this.$rootScope as any).loanCriteria = null;\r\n\r\n this.$location.path(\"/allloans\");\r\n }\r\n }\r\n\r\n updateClientContactInfoAndNotifyBroker(){\r\n if(this.loanCriteria !=null && this.loanCriteria.DealClients != null){\r\n this.dealClientService.UpdateClientContactInfoAndNotifyBroker(this.clientUpdatedContact, this.loanCriteria?.Id,this.loanCriteria.DealClients[0].Client.Id).then((response) => {\r\n this.showClientPhoneNumberConfirmationModal = false;\r\n this.sliderShown = true;\r\n }).catch((response) => {\r\n this.error = \"There was an error updating the contact. Please try again later.\"\r\n })\r\n .finally(() => {\r\n sessionStorage.removeItem('showConfirmClientPhoneNo');\r\n });\r\n } else {\r\n sessionStorage.removeItem('showConfirmClientPhoneNo');\r\n this.showClientPhoneNumberConfirmationModal = false;\r\n this.sliderShown = true;\r\n }\r\n }\r\n\r\n getOrgName(){\r\n if(this.orgName){\r\n return this.orgName.replace(/_/g, \" \");\r\n }\r\n return \"\";\r\n }\r\n\r\n /**Sends an email to the email address for the user to reset their password */\r\n sendResetPasswordEmail() {\r\n this.loadingData = true;\r\n this.$auth\r\n .resetPassword(this.enterpriseClient.Email)\r\n .then((response) => {\r\n this.isLoginError = false;\r\n this.isResetPasswordSubmitted = true;\r\n this.registrationLoginError = null;\r\n })\r\n .catch((error) => {\r\n this.registrationLoginError = \"There was an error sending the password reset email. Please try again later.\";\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n getRequiredRolesOptions(){\r\n return this.dealService.getRequiredRolesOptions();\r\n }\r\n\r\n validateAccessAndRedirect(){\r\n //Do not allow the connect user to access the deal\r\n if(this.loanCriteria.IsReferredToConnect && this.selectedUser.IsConnectUser){\r\n this.$location.path(`/devfinancecasedashboard/${this.loanCriteria.Id}`)\r\n }else{\r\n if((this.loanCriteria.Status != CaseStatusEnum.NewCase && this.loanCriteria.Status != CaseStatusEnum.Search && !this.isShortlistingMore)){\r\n this.dealLenderService\r\n .fetchDealLendersByDealId( this.loanCriteria.Id)\r\n .then((results) => {\r\n if(results && results.filter(dl => !dl.IsDeleted && dl.Status != CaseLenderStateEnum.Withdrawn && dl.Status != CaseLenderStateEnum.Rejected).length >= 5 && results.filter(dl => !dl.IsDeleted && dl.IsBidAccepted)){\r\n if (this.isAdmin || this.isBroker) {\r\n this.$location.path(\"/dealforum/\" + this.loanCriteria.Id)\r\n }\r\n else {\r\n this.$location.path(`/userdashboard`)\r\n }\r\n }else{\r\n this.$location.path(`/devfinanceshortlistmore/${this.loanCriteria.Id}`)\r\n }\r\n })\r\n }\r\n }\r\n }\r\n}\r\n","import { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { LenderResultDTO } from \"@js/DTO/DevelopmentFinance/LenderResultDTO.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\n\r\nexport class EnquiryController {\r\n registeringAccount: boolean;\r\n registrationform: FormData;\r\n error: string;\r\n\r\n loanCriteria: DevelopmentInputDTO;\r\n selectedResult: LenderResultDTO;\r\n\r\n enquireAfterRegistration: boolean;\r\n\r\n //newUser: RegistrationRequestDTO = {\r\n // Email: \"\", FirstName: \"\", LastName: \"\"\r\n //} as RegistrationRequestDTO;\r\n\r\n newUser: any = {};\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"$httpParamSerializerJQLike\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private $httpParamSerializerJQLike: ng.IHttpParamSerializer,\r\n private $auth: AuthService,\r\n private $roleService: RoleService,\r\n ) {\r\n // rootScope.title = \"Registration\";\r\n if ($cookies.get(\"access_token\")) {\r\n $location.path(\"dashboard\");\r\n }\r\n\r\n this.loanCriteria = (this.$rootScope as any).loanCriteria;\r\n this.selectedResult = (this.$rootScope as any).selectedResult;\r\n\r\n if (this.$routeParams.enquire !== undefined) {\r\n this.enquireAfterRegistration = true;\r\n }\r\n }\r\n\r\n registerAccount() {\r\n this.registeringAccount = true;\r\n if (this.newUser.ConfirmPassword !== this.newUser.Password) {\r\n this.error = \"Passwords do not match\";\r\n }\r\n // send registration\r\n this.$auth\r\n .registerAccount(this.newUser)\r\n .then((response) => {\r\n if (this.enquireAfterRegistration) {\r\n this.$location.path(\"/enquiry\");\r\n } else {\r\n this.$location.path(\"/yourresults\");\r\n }\r\n })\r\n .catch((response) => {\r\n this.error =\r\n \"It looks like there was a problem registering. Please try again in a moment.\";\r\n })\r\n .finally(() => {\r\n this.registeringAccount = false;\r\n });\r\n\r\n //if (this.selectedUser.Id == null) {\r\n // this.selectedUser.Id = \"\";\r\n // this.selectedUser.Roles = [];\r\n // this.selectedUser.Roles.push(\"Client\");\r\n //}\r\n //if (!this.selectedUser.UserName) {\r\n // this.selectedUser.UserName = this.selectedUser.Email; //set user name to be same as email address for now\r\n //}\r\n //this.loanCriteria.User = this.selectedUser;\r\n //this.loanCriteria.SaveQueryAndResults = true;\r\n //// this.$user.addUpdate(this.selectedUser).then((response) => {\r\n //this.$lenderresultservice.fetchMatchingResults(this.loanCriteria, false, false, 4).then((response) => {\r\n // this.selectedUser.Id = response.UserId;\r\n // this.showsaveinfo = false;\r\n //});\r\n }\r\n\r\n clearRegistration() {\r\n this.registeringAccount = false;\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport {\r\n SaveEnterpriseClientAndRenameSearchRequest,\r\n SaveEnterpriseClientAndRenameSearchResponse\r\n} from \"@js/DTO/Messages/Deal/SaveEnterpriseClientAndRenameSearchMessage.cs.d\";\r\nimport { LinkTypeEnum } from \"@js/models/enum/LinkTypeEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { PostalAddress } from \"@js/models/PostalAddress.cs.d\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { EnterpriseService } from \"@js/services/EnterpriseService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { ClientService } from \"@js/services/ClientService\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs\";\r\nimport { UserRoleEnum } from \"@js/models/enum/UserRoleEnum.cs.d\";\r\n\r\ndeclare const window: Window & { dataLayer: any[] };\r\n\r\nexport class EnterpriseLeadCaptureController {\r\n loadingData: boolean = false;\r\n resultsCount: Number;\r\n enterpriseClient: ApplicationUserDTO;\r\n projectName: string;\r\n errorMessage: string = \"\";\r\n emailExistsError: boolean = false;\r\n dealDetails: SaveEnterpriseClientAndRenameSearchResponse;\r\n showContactForm = false;\r\n orgCode: string;\r\n enterpriseLinkLogo: string;\r\n totalLenders: number = null;\r\n isWidget: boolean = false;\r\n isMobileView: boolean = false;\r\n iFrame: boolean = false;\r\n organisationLinkId: number = null;\r\n enterpriseLinkType: string;\r\n leadCaptureForm: ng.IFormController;\r\n showEnterpriseRegistrationModal: boolean = false;\r\n showRegisterModal: boolean = false;\r\n showLoginSection: boolean = false;\r\n\r\n // Logging in/resetting password\r\n isLoginError: boolean = false;\r\n isResetPasswordSubmitted: boolean = false;\r\n registrationLoginError: string = null;\r\n\r\n acceptTerms: boolean = false;\r\n\r\n hasEnterpriseClient:boolean = false;\r\n phoneNumber:number;\r\n newUrl: string;\r\n message: string;\r\n showMessageModal: boolean = false;\r\n organisation: OrganisationDTO;\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$location\",\r\n \"$cookies\",\r\n \"OrganisationService\",\r\n \"DealService\",\r\n \"UserService\",\r\n \"ProductService\",\r\n \"LenderService\",\r\n \"EventLogService\",\r\n \"EnterpriseService\",\r\n \"AuthService\",\r\n \"$q\",\r\n \"ClientService\"\r\n ];\r\n\r\n constructor(\r\n public $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private organisationService: OrganisationService,\r\n private dealService: DealService,\r\n private userService: UserService,\r\n private productService: ProductService,\r\n private lenderService: LenderService,\r\n private eventLogService: EventLogService,\r\n private enterpriseService: EnterpriseService,\r\n private $auth: AuthService,\r\n protected $q: ng.IQService,\r\n private clientService: ClientService\r\n ) {\r\n\r\n\r\n if (window.self == window.top) {\r\n this.orgCode = this.$cookies.get(\"org_code\");\r\n } else {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n }\r\n\r\n this.getSearchResultsCountByUniqueRefAndLogPageLoadEvent();\r\n\r\n if (window.self == window.top) {\r\n this.enterpriseLinkType = sessionStorage.getItem(\"enterpriseLinkType\");\r\n } else {\r\n this.organisationService.getData(\"enterpriseLinkType\").then((linkType) => {\r\n if (linkType) {\r\n this.enterpriseLinkType = linkType;\r\n }\r\n }).catch((error) => {\r\n console.error(\"Failed to get user data: \", error);\r\n });\r\n }\r\n\r\n if (this.$routeParams.context == 'widget' && window.self != window.top) {\r\n document.getElementById(\"footer\").style.display = \"none\";\r\n this.isWidget = true;\r\n } else if (window.innerWidth <= 480 && window.self == window.top) {\r\n this.isMobileView = true;\r\n } else if (window.self != window.top) {\r\n this.iFrame = true;\r\n }\r\n\r\n }\r\n\r\n getNumberOfLenders() {\r\n this.lenderService.getTotalLenders(ProductFamilyEnum.None, this.organisation.Id).then((totalLenders: number) => {\r\n this.totalLenders = Math.floor(totalLenders / 5) * 5;\r\n\r\n const trustboxRef = document.getElementById(\"trustbox\");\r\n\r\n if (trustboxRef && (window as any).Trustpilot) {\r\n (window as any).Trustpilot.loadFromElement(trustboxRef);\r\n }\r\n });\r\n }\r\n\r\n getSearchResultsCountByUniqueRefAndLogPageLoadEvent() {\r\n this.loadingData = true;\r\n this.errorMessage = \"\";\r\n this.dealService\r\n .getSearchResultsCountByUniqueRefAndLogPageLoadEvent(this.$routeParams.uniqueRef, this.orgCode)\r\n .then((response) => {\r\n this.resultsCount = response.TotalResultsCount;\r\n this.organisationLinkId = response.DealUniqueLinkId;\r\n var imgs = document.getElementsByTagName(\"img\");\r\n this.enterpriseLinkLogo = this.organisationLinkId != null && response.DealUniqueLinkLogoUrl? response.DealUniqueLinkLogoUrl : imgs[0].src;\r\n this.projectName = response.DealName;\r\n this.organisation = response.Organisation;\r\n this.getNumberOfLenders();\r\n\r\n if(response.EnterpriseClient){\r\n this.hasEnterpriseClient = true;\r\n this.enterpriseClient = {} as ApplicationUserDTO;\r\n this.enterpriseClient.FullName = `${response.EnterpriseClient.FirstName} ${response.EnterpriseClient.LastName}`;\r\n if(response.EnterpriseClient.PhoneNumber) this.phoneNumber = Number(response.EnterpriseClient.PhoneNumber);\r\n this.enterpriseClient.Email = response.EnterpriseClient.Email;\r\n }\r\n this.showContactForm = true;\r\n })\r\n .catch((response) => {\r\n this.errorMessage = \"Error while loading page, please try later.\";\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n onViewLoansClicked() {\r\n this.loadingData = true;\r\n this.errorMessage = \"\";\r\n this.emailExistsError = false;\r\n this.userService.checkEmailExists(this.enterpriseClient.Email).then((response) => {\r\n if (!response) {\r\n this.saveEnterpriseClientAndRenameDeal();\r\n } else {\r\n this.emailExistsError = true;\r\n this.loadingData = false;\r\n }\r\n });\r\n }\r\n\r\n\r\n saveEnterpriseClientAndRenameDeal(isLogin: boolean = false): ng.IPromise {\r\n let defer = this.$q.defer();\r\n let userFullName = this.enterpriseClient.FullName;\r\n let spaceIndex = userFullName.indexOf(\" \");\r\n\r\n let firstName = \"\";\r\n let lastName = \"\";\r\n\r\n // if not space has been added to the name then put the whole name in the first name field\r\n if (spaceIndex == -1) {\r\n firstName = userFullName;\r\n lastName = userFullName;\r\n } else {\r\n firstName = userFullName.substring(0, userFullName.indexOf(\" \"));\r\n lastName = userFullName.substring(userFullName.indexOf(\" \") + 1);\r\n }\r\n\r\n // Set up Client dto\r\n var clientDto = {\r\n FirstName: firstName,\r\n LastName: lastName,\r\n PhoneNumber: this.phoneNumber?.toString(),\r\n Email: this.enterpriseClient.Email,\r\n PostalAddress: {\r\n AddressLine1: \"\",\r\n AddressLine2: \"\",\r\n AddressLine3: \"\",\r\n AddressLine4: \"\",\r\n PostCode: \"\",\r\n } as PostalAddress,\r\n } as ClientDTO;\r\n\r\n var request: SaveEnterpriseClientAndRenameSearchRequest = {\r\n DealUniqueref: this.$routeParams.uniqueRef,\r\n DealNewName: this.projectName,\r\n ClientDto: clientDto,\r\n };\r\n\r\n this.dealService\r\n .saveEnterpriseClientAndRenameDeal(request)\r\n .then((response) => {\r\n if (response) {\r\n this.dealDetails = response;\r\n if (window.self == window.top) {\r\n sessionStorage.setItem(\r\n \"clientId\",\r\n this.dealDetails.ClientId.toString(),\r\n );\r\n } else {\r\n this.organisationService.sendDataToParent(\r\n \"clientId\",\r\n this.dealDetails.ClientId.toString(),\r\n );\r\n }\r\n\r\n // For Google analytics tracking\r\n window.dataLayer = window.dataLayer || [];\r\n window.dataLayer.push({\r\n event: \"results_gating_form\",\r\n loan_product_family:\r\n this.productService.getProductFamilyTextForGa(\r\n this.dealDetails.ProductFamily,\r\n ),\r\n loan_product_type: this.productService.getProductTypeTextForGa(\r\n this.dealDetails.ProductType,\r\n this.dealDetails.IsFamilyInResidence,\r\n ),\r\n });\r\n\r\n if (!isLogin) {\r\n this.userService.sendEventToHubspot(\r\n this.enterpriseClient,\r\n \"ENTERPRISE-LEAD-DETAILS-COLLECTED\",\r\n false,\r\n this.orgCode,\r\n UserRoleEnum.Client,\r\n this.dealDetails.OrganisationLinkId != null\r\n ? this.dealDetails.OrganisationLinkId\r\n : 0,\r\n this.dealDetails.ProductType,\r\n this.dealDetails.DealId,\r\n null,\r\n this.dealDetails.ClientId.toString()\r\n );\r\n\r\n let resultPageurl = this.getResultsPageUrl();\r\n this.goToLink(resultPageurl, true);\r\n } \r\n\r\n defer.resolve(response as SaveEnterpriseClientAndRenameSearchResponse);\r\n }\r\n }).catch((response) => {\r\n this.errorMessage = \"Error while saving details, please try later.\";\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n getResultsPageUrl() {\r\n var url = \"\";\r\n switch (this.dealDetails.ProductFamily) {\r\n case ProductFamilyEnum.Bridging:\r\n url = `/e/bridgingresults/${this.$routeParams.uniqueRef}`;\r\n break;\r\n case ProductFamilyEnum.Commercial:\r\n url = `/e/commercialresults/${this.$routeParams.uniqueRef}`;\r\n break;\r\n case ProductFamilyEnum.Development:\r\n url = `/e/devfinanceresults/${this.$routeParams.uniqueRef}`;\r\n break;\r\n default:\r\n break;\r\n }\r\n return url;\r\n }\r\n\r\n showSignInModal() {\r\n if (!this.isWidget && !this.isMobileView && !this.iFrame) {\r\n this.enterpriseClient.UserName = this.enterpriseClient.Email;\r\n this.showEnterpriseRegistrationModal = true;\r\n this.showRegisterModal = true;\r\n this.showLoginSection = true;\r\n document.getElementById(\"body\").style.overflow = \"hidden\";\r\n } else {\r\n this.saveEnterpriseClientAndRenameDeal(true).then((response) => {\r\n var redirectUrl = this.getLoginRedirectUrl();\r\n (this.$rootScope as any).loginRedirectPath = redirectUrl;\r\n this.goToLink(`/e/login/${this.dealDetails.ProductFamily}/${this.$routeParams.uniqueRef}/${this.dealDetails.ClientId}/${this.enterpriseClient.Email}`);\r\n });\r\n }\r\n }\r\n\r\n onClickLogin() {\r\n this.login();\r\n }\r\n\r\n login() {\r\n this.loadingData = true;\r\n if (!this.$cookies.get(\"access_token\")) {\r\n this.$auth\r\n .login(\r\n this.enterpriseClient.UserName,\r\n this.enterpriseClient.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n let expiry: Date = response;\r\n this.isLoginError = false;\r\n\r\n this.userService.getcurentuserrecord().then((response) => {\r\n (this.$rootScope as any).currentUser = response;\r\n this.$cookies.put(\"user_firstname\", response.FirstName, {\r\n expires: expiry,\r\n });\r\n (this.$rootScope as any).selectedUser = response;\r\n\r\n this.saveEnterpriseClientAndRenameDeal(true).then(() => {\r\n this.userService.sendEventToHubspot(\r\n this.enterpriseClient,\r\n \"ENTERPRISE-LEAD-LOGGEDIN-FROM-LEADCAPTURE-PAGE\",\r\n false,\r\n this.orgCode,\r\n UserRoleEnum.Client,\r\n this.dealDetails.OrganisationLinkId != null\r\n ? this.dealDetails.OrganisationLinkId\r\n : 0,\r\n this.dealDetails.ProductType,\r\n this.dealDetails.DealId,\r\n null,\r\n this.dealDetails.ClientId.toString()\r\n );\r\n\r\n // link user to the client record\r\n this.clientService.updateClientWithUserId(this.dealDetails.ClientId);\r\n\r\n this.$rootScope.$broadcast(\"login\"); //tell everyone you have logged in\r\n var redirectUrl = this.getLoginRedirectUrl();\r\n this.$location.path(redirectUrl);\r\n })\r\n });\r\n })\r\n .catch((response) => {\r\n this.isLoginError = true;\r\n this.enterpriseClient.Password = null;\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n // User may have logged in on a different browser/tab\r\n this.saveEnterpriseClientAndRenameDeal(true).then(() => {\r\n var redirectUrl = this.getLoginRedirectUrl();\r\n this.$location.path(redirectUrl);\r\n });\r\n }\r\n }\r\n\r\n goToLink(url, isResultsLink = false) {\r\n var baseUrl = window.location.href.split(\"#!\")[0] + \"#!\";\r\n this.newUrl = baseUrl + url;\r\n this.message = isResultsLink? 'view your results': 'sign in';\r\n\r\n if(isResultsLink) this.hasEnterpriseClient = true;\r\n\r\n var newWindow = window.open(this.newUrl, \"_blank\");\r\n\r\n if (!newWindow || newWindow.closed || typeof newWindow.closed === 'undefined') {\r\n this.showMessageModal = true;\r\n } \r\n }\r\n\r\n openLink(){\r\n window.open(this.newUrl, \"_blank\");\r\n this.showMessageModal = false;\r\n }\r\n\r\n goToPreviousEnterprisePage() {\r\n\r\n if (this.enterpriseLinkType) {\r\n if(this.isWidget){\r\n switch (Number(this.enterpriseLinkType)) {\r\n case LinkTypeEnum.Development:\r\n path = this.organisationLinkId != null? `/allloans/${this.organisationLinkId}/widget/${LinkTypeEnum.Development}`: `/allloans/0/widget/${LinkTypeEnum.Development}`;\r\n break;\r\n case LinkTypeEnum.Bridging:\r\n path = this.organisationLinkId != null? `/allloans/${this.organisationLinkId}/widget/${LinkTypeEnum.Bridging}`: `/allloans/0/widget/${LinkTypeEnum.Bridging}`;\r\n break;\r\n case LinkTypeEnum.Commercial:\r\n path = this.organisationLinkId != null? `/allloans/${this.organisationLinkId}/widget/${LinkTypeEnum.Commercial}`: `/allloans/0/widget/${LinkTypeEnum.Commercial}`;\r\n break;\r\n case LinkTypeEnum.AllLoans:\r\n path = this.organisationLinkId != null? `/allloans/${this.organisationLinkId}/widget`: `/allloans/0/widget`;\r\n break;\r\n default:\r\n break;\r\n }\r\n this.$location.path(path);\r\n\r\n }else{\r\n switch (Number(this.enterpriseLinkType)) {\r\n case LinkTypeEnum.Development:\r\n this.organisationLinkId != null ? this.$location.path(`/e/devfinancecriteria/0/${this.organisationLinkId}`) : this.$location.path(\"/e/devfinancecriteria\"); \r\n break;\r\n case LinkTypeEnum.Bridging:\r\n this.organisationLinkId != null ? this.$location.path(`/e/bridgingcriteria/0/${this.organisationLinkId}`) : this.$location.path(\"/e/bridgingcriteria\");\r\n break;\r\n case LinkTypeEnum.Commercial:\r\n this.organisationLinkId != null ? this.$location.path(`/e/commercialcriteria/0/${this.organisationLinkId}`) : this.$location.path(\"/e/commercialcriteria\")\r\n break;\r\n case LinkTypeEnum.AllLoans:\r\n var path = \"/allloans\";\r\n if (this.organisationLinkId != null) {\r\n path = `/allloans/${this.organisationLinkId}`; \r\n } \r\n this.$location.path(path);\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n getLoginRedirectUrl(): string {\r\n var redirectUrl = '';\r\n\r\n switch (Number(this.enterpriseService.getProductFamily())) {\r\n case ProductFamilyEnum.Development:\r\n redirectUrl = `/devfinanceresults/${this.$routeParams.uniqueRef}`;\r\n break;\r\n case ProductFamilyEnum.Bridging:\r\n redirectUrl = `/bridgingresults/${this.$routeParams.uniqueRef}`;\r\n break;\r\n case ProductFamilyEnum.Commercial:\r\n redirectUrl = `/commercialresults/${this.$routeParams.uniqueRef}`;\r\n break;\r\n default:\r\n redirectUrl = '/userdashboard';\r\n break;\r\n }\r\n\r\n return redirectUrl;\r\n }\r\n\r\n\r\n\r\n /**Sends an email to the email address for the user to reset their password */\r\n sendResetPasswordEmail() {\r\n this.loadingData = true;\r\n this.$auth\r\n .resetPassword(this.enterpriseClient.Email)\r\n .then((response) => {\r\n this.isLoginError = false;\r\n this.isResetPasswordSubmitted = true;\r\n this.registrationLoginError = null;\r\n })\r\n .catch((error) => {\r\n this.registrationLoginError = error;\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n footerSignInClicked(){\r\n var redirectUrl = this.getLoginRedirectUrl();\r\n if(this.projectName){\r\n this.dealService.renameDeal(this.$routeParams.uniqueRef,this.projectName).then(() => {\r\n (this.$rootScope as any).loginRedirectPath = redirectUrl;\r\n if(this.dealDetails){\r\n this.goToLink(`/e/login/${this.dealDetails.ProductFamily}/${this.$routeParams.uniqueRef}`);\r\n }else{\r\n this.goToLink(`/e/login/${Number(this.enterpriseService.getProductFamily())}/${this.$routeParams.uniqueRef}`);\r\n }\r\n });\r\n }else{\r\n (this.$rootScope as any).loginRedirectPath = redirectUrl;\r\n this.goToLink(`/e/login/${Number(this.enterpriseService.getProductFamily())}/${this.$routeParams.uniqueRef}`);\r\n }\r\n }\r\n}\r\n","import { FeaturePriceService } from \"@js/services/FeaturePriceService\";\r\n\r\nexport class FeaturePriceController {\r\n //processing: boolean = false;\r\n //selectedFeaturePriceData: FeaturePriceDTO[];\r\n //showFilter: boolean;\r\n //newFeaturePrice: FeaturePriceDTO;\r\n //tempFeaturePrice: FeaturePriceDTO;\r\n //addOrEditForm: ng.IFormController;\r\n\r\n //selectedFeature: any;\r\n //currentDate: Date = new Date();\r\n //newFeature = false;\r\n //editFeature = false;\r\n //messageDeleteModal = false;\r\n //showInvalidStartDate = false;\r\n //showInvalidEndDate = false;\r\n //showAllFeaturePrice = false;\r\n //startDateErrorMsg: string = null;\r\n //endDateErrorMsg: string = null;\r\n\r\n //features: Array<{ id: number, name: string }> = [{ id: 1, name: 'Development Finance' }, { id: 2, name: 'Bridging Finance' }];\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"FeaturePriceService\",\r\n ];\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private featurePriceService: FeaturePriceService,\r\n ) {}\r\n\r\n // getSelectedFeaturePrice() {\r\n // this.featurePriceService.getFeaturePriceByFeature(this.selectedFeature.id, this.showAllFeaturePrice).then((response) => {\r\n // this.selectedFeaturePriceData = response;\r\n // })\r\n // }\r\n\r\n // onFeatureChange(featureSelected) {\r\n // this.showAllFeaturePrice = false;\r\n // this.selectedFeature = featureSelected;\r\n // this.getSelectedFeaturePrice();\r\n // }\r\n\r\n // createFeaturePrice() {\r\n // this.newFeaturePrice = { Feature: this.selectedFeature.id } as FeaturePriceDTO;\r\n // this.newFeature = true;\r\n // }\r\n\r\n // /**\r\n // * Function to save the newly added feature price.\r\n // * @param featurePrice\r\n // */\r\n // saveFeaturePrice(featurePrice: FeaturePriceDTO) {\r\n // if (featurePrice.EndDateTime == null) {\r\n // var found = this.selectedFeaturePriceData.find(function (featurePrice) {\r\n // return featurePrice.EndDateTime == null;\r\n // });\r\n\r\n // if (found) {\r\n // this.endDateErrorMsg = \"You already have default price for this feature,Please select a end date.\"\r\n // this.showInvalidEndDate = true;\r\n // return;\r\n // }\r\n // }\r\n\r\n // featurePrice.EndDateTime == null ? featurePrice.IsDefault = true : featurePrice.IsDefault = false;\r\n // this.processing = true;\r\n // this.featurePriceService.addUpdatereturnonlyid(featurePrice).then((response) => {\r\n // this.processing = false;\r\n // this.newFeature = false;\r\n // this.editFeature = false;\r\n // this.showInvalidEndDate = false;\r\n // if (!this.newFeaturePrice.Id) {\r\n // this.selectedFeaturePriceData.push(this.newFeaturePrice);\r\n // } else {\r\n // this.selectedFeaturePriceData = this.selectedFeaturePriceData.filter(price => price.Id != this.newFeaturePrice.Id);\r\n // this.selectedFeaturePriceData.push(this.newFeaturePrice);\r\n // }\r\n // this.newFeaturePrice = undefined;\r\n // }).catch((response) => {\r\n // this.processing = false;\r\n // });\r\n // }\r\n\r\n // /**\r\n // * Function to edit the selected feature price.\r\n // * @param featurePrice\r\n // */\r\n // editFeaturePrice(featurePrice: FeaturePriceDTO) {\r\n // this.newFeaturePrice = { ...featurePrice };\r\n // this.editFeature = true;\r\n // }\r\n\r\n // /**\r\n // * Function to confirm selected feature price for deletion.\r\n // * @param featurePrice\r\n // */\r\n // confirmRemoveFeaturePrice(featurePrice: FeaturePriceDTO) {\r\n // this.tempFeaturePrice = { ...featurePrice };\r\n // this.messageDeleteModal = true;\r\n // }\r\n\r\n // /**\r\n // * Function to mark the selected feature price as deleted.\r\n // * @param featurePrice\r\n // */\r\n // removeFeaturePrice(featurePrice: FeaturePriceDTO) {\r\n // this.featurePriceService.markasdeleted(featurePrice.Id).then((response) => {\r\n // if (response) {\r\n // this.selectedFeaturePriceData = this.selectedFeaturePriceData.filter(price => price.Id != featurePrice.Id);\r\n // this.messageDeleteModal = false;\r\n // }\r\n // });\r\n // }\r\n\r\n // /**\r\n // * Function to check for valid start date..\r\n // * @param endDate\r\n // */\r\n\r\n // CheckForValidStartdate(startdate) {\r\n // var found = this.selectedFeaturePriceData.find(function (featurePrice) {\r\n // return startdate >= featurePrice.StartDateTime && startdate <= featurePrice.EndDateTime;\r\n // });\r\n // console.log(startdate == this.currentDate);\r\n // if (startdate != this.currentDate && startdate < this.currentDate) {\r\n // this.startDateErrorMsg = \"Start date should be greater or equal to today's date.\"\r\n // this.showInvalidStartDate = true\r\n // } else if (found) {\r\n // this.startDateErrorMsg = \"Start date should not fall between other feature price dates.\"\r\n // this.showInvalidStartDate = true\r\n // } else {\r\n // this.startDateErrorMsg = null;\r\n // this.showInvalidStartDate = false;\r\n // }\r\n\r\n // }\r\n\r\n // /**\r\n // * Function to check for valid end date..\r\n // * @param endDate\r\n // */\r\n\r\n // CheckForValidEnddate(enddate) {\r\n // var found = this.selectedFeaturePriceData.find(function (featurePrice) {\r\n // return enddate <= featurePrice.StartDateTime && enddate >= featurePrice.EndDateTime ;\r\n // });\r\n\r\n // if (enddate != null && enddate < this.currentDate) {\r\n // this.endDateErrorMsg = \"End date should be greater or equal to today's date.\"\r\n // this.showInvalidEndDate = true\r\n // } else if (enddate != null && enddate < this.newFeaturePrice.StartDateTime) {\r\n // this.endDateErrorMsg = \"End date should be greater or equal to start date.\"\r\n // this.showInvalidEndDate = true\r\n // } else if (found) {\r\n // this.endDateErrorMsg = \"End date should not fall between other feature price dates.\"\r\n // this.showInvalidEndDate = true;\r\n // } else {\r\n // var defaultval = this.selectedFeaturePriceData.find(function (featurePrice) {\r\n // return featurePrice.EndDateTime == null && featurePrice.Id != this.newFeaturePrice.Id;\r\n // });\r\n\r\n // if (defaultval) {\r\n // if (this.newFeaturePrice.StartDateTime >= defaultval.StartDateTime) {\r\n // this.endDateErrorMsg = \"Selected start and end date is covered in other default feature price dates.\"\r\n // this.showInvalidEndDate = true;\r\n // }\r\n\r\n // } else {\r\n // this.startDateErrorMsg = null;\r\n // this.showInvalidEndDate = false;\r\n // }\r\n // }\r\n // }\r\n\r\n // closeModal() {\r\n // this.newFeature = false;\r\n // this.editFeature = false;\r\n // this.showInvalidEndDate = false;\r\n // this.showInvalidStartDate = false;\r\n // }\r\n}\r\n","import { FeedBackDTO } from \"@js/DTO/FeedBackDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { FeedBackService } from \"@js/services/FeedBackService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\n\r\nexport class FeedBackController {\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$location\",\r\n \"FeedBackService\",\r\n \"OrganisationService\",\r\n \"FileAttachmentService\",\r\n \"RoleService\",\r\n ];\r\n\r\n feedBackDTO: FeedBackDTO;\r\n organisation: OrganisationDTO;\r\n fullAvatarUrl: string = \"\";\r\n showReplySection: boolean = false;\r\n dataLoading: boolean = false;\r\n isDeal: boolean = true;\r\n reviewerFullName: string;\r\n reviewerOrganisationName: string;\r\n reviewerOrganisationUrl: string;\r\n reviewerProfileUrl: string;\r\n reviewerInitil: string;\r\n responseUserOrgName: string;\r\n dealName: string;\r\n isLender: boolean;\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private feedBackService: FeedBackService,\r\n private organisationService: OrganisationService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private roleService: RoleService,\r\n ) {\r\n if (this.$location.path().startsWith(\"/casefeedback\")) {\r\n this.isDeal = false;\r\n }\r\n\r\n this.feedBackService\r\n .getFeedBackAndReviewerDetails(\r\n Number(this.$routeParams.FeedBackId),\r\n Number(this.$routeParams.DealLenderId),\r\n this.isDeal,\r\n )\r\n .then((response) => {\r\n this.feedBackDTO = response.feedBackDTO;\r\n this.reviewerFullName = response.ReviewerFullName;\r\n this.reviewerOrganisationName = response.ReviewerOrganisationName;\r\n this.reviewerOrganisationUrl = response.ReviewerOrganisationUrl;\r\n this.reviewerProfileUrl = response.ReviewerProfileUrl;\r\n this.reviewerInitil = response.ReviewerInitil;\r\n this.responseUserOrgName = response.ResponseUserOrgName;\r\n this.dealName = response.DealName;\r\n this.checkingIfUserIsLender();\r\n });\r\n }\r\n\r\n checkingIfUserIsLender() {\r\n this.roleService.isLenderUser().then((response) => {\r\n this.isLender = response;\r\n });\r\n }\r\n\r\n submitReplyToFeedBack() {\r\n this.dataLoading = true;\r\n this.feedBackService\r\n .sendFeedBackReply(\r\n this.feedBackDTO,\r\n Number(this.$routeParams.DealLenderId),\r\n this.isDeal,\r\n )\r\n .then((response) => {\r\n this.$location.path(\"/userdashboard\");\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n /** Redirects to the user dashboard */\r\n goToUserDashboard() {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n}\r\n","import { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\n\r\nexport class FileAttachmentController {\r\n selectedSection: string;\r\n\r\n objects: FileAttachmentDTO[];\r\n selectedObject: FileAttachmentDTO;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n //addingSubobject: boolean;\r\n\r\n //subobjects: SubobjectDTO[];\r\n //selectedSubobject: SubobjectDTO;\r\n\r\n //fetchingSubobjects: boolean;\r\n //fetchingSubobject: boolean;\r\n\r\n fileattachmentForm: ng.IFormController;\r\n //subfileattachmentForm: ng.IFormController;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"FileAttachmentService\",\r\n\r\n //'SubobjectService',\r\n ];\r\n //private $subobjectservice: App.Services.SubobjectService\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $fileattachmentservice: FileAttachmentService,\r\n ) {\r\n this.updateObjects();\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n\r\n // Fetch all objects.\r\n this.$fileattachmentservice\r\n .fetchAll()\r\n .then((response) => {\r\n this.objects = response;\r\n this.preSelectedItem();\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n });\r\n }\r\n\r\n private preSelectedItem() {\r\n if (this.$routeParams.Id) {\r\n let selectedObject = this.objects.find((value, index) => {\r\n return value.Id === parseInt(this.$routeParams.objectId);\r\n });\r\n\r\n this.selectObject(selectedObject);\r\n }\r\n }\r\n\r\n selectObject(object: FileAttachmentDTO) {\r\n this.selectedObject = object;\r\n\r\n //this.fetchingSubobjects = true;\r\n //this.$subobjectservice.fetchSubobjectsForObject(object.Id).then((response) => {\r\n // this.subobjects = response;\r\n // this.fetchingSubobjects = false;\r\n //}).catch((response) => {\r\n // this.fetchingSubobjects = false;\r\n //});\r\n\r\n this.selectedSection = \"details\";\r\n }\r\n\r\n createObject() {\r\n this.selectedSection = \"details\";\r\n this.selectedObject = {} as FileAttachmentDTO;\r\n }\r\n\r\n save() {\r\n this.$fileattachmentservice\r\n .addUpdatereturnonlyid(this.selectedObject)\r\n .then((response) => {\r\n this.selectedObject.Id = response;\r\n if (!this.objects) {\r\n this.objects = [];\r\n }\r\n\r\n let matches: FileAttachmentDTO[] = this.objects.filter(\r\n (value, index) => {\r\n return value.Id == response;\r\n },\r\n );\r\n\r\n if (!matches || matches.length === 0) {\r\n this.objects.push(this.selectedObject);\r\n }\r\n\r\n this.fileattachmentForm.$setPristine();\r\n this.updateObjects();\r\n });\r\n }\r\n\r\n delete() {\r\n this.$fileattachmentservice\r\n .delete(this.selectedObject.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.fileattachmentForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n });\r\n }\r\n\r\n //addSubobject() {\r\n // this.selectedSubobject = {\r\n // AssociatedObjectName: this.selectedObject.Name\r\n // AssociatedObjectId: this.selectedObject.Id,\r\n // } as SubobjectDTO;\r\n //}\r\n\r\n //removeSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.deleteSubobject(subobject.Id).then((response) => {\r\n // this.subobjects.splice(this.subobjects.indexOf(this.selectedSubobject), 1);\r\n // delete this.selectedSubobject;\r\n // });\r\n //}\r\n\r\n //cancelUpdateSubobject() {\r\n // delete this.selectedSubobject;\r\n //}\r\n\r\n //updateSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.addUpdateSubobject(subobject).then((response) => {\r\n // if (this.subobjects.indexOf(subobject) === -1) {\r\n // this.subobjects.push(subobject);\r\n // }\r\n // delete this.selectedSubobject;\r\n // }).catch((response) => {\r\n // delete this.selectedSubobject;\r\n // });\r\n\r\n //}\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { CaseLenderDTO } from \"@js/DTO/CaseLenderDTO.cs.d\";\r\nimport { CaseLenderMessageDTO } from \"@js/DTO/CaseLenderMessageDTO.cs.d\";\r\nimport { DealLenderMessageDTO } from \"@js/DTO/Deal/DealLenderMessageDTO.cs.d\";\r\nimport { FeedBackDTO } from \"@js/DTO/FeedBackDTO.cs.d\";\r\nimport { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { InterestRateTypeEnum } from \"@js/models/enum/InterestRateTypeEnum.cs.d\";\r\nimport { MessageRoleEnum } from \"@js/models/enum/MessageRoleEnum.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseLenderMessageService } from \"@js/services/CaseLenderMessageService\";\r\nimport { CaseLenderService } from \"@js/services/CaseLenderService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { FeedBackService } from \"@js/services/FeedBackService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class HeadsOfTermsController {\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"LenderService\",\r\n \"CaseService\",\r\n \"CaseLenderService\",\r\n \"RoleService\",\r\n \"CaseLenderMessageService\",\r\n \"FileAttachmentService\",\r\n \"$window\",\r\n \"SelectListService\",\r\n \"FeedBackService\",\r\n \"UserService\",\r\n \"AuthService\",\r\n \"ProductService\",\r\n ];\r\n\r\n isDevelopmentFinance: boolean = true;\r\n dataLoading: boolean = false; // Controls showing the data loading \"spinner\"\r\n caseLenders: CaseLenderDTO[];\r\n showInformationMessage: boolean = false;\r\n messageContent: string;\r\n feedbackMessageToLender: string;\r\n\r\n showDirection: boolean = false;\r\n\r\n toggleFeedbackSection: boolean = false;\r\n toggleHoTDetailSection: boolean = false;\r\n toggleRejectSection: boolean = false;\r\n toggleWithdrawSection: boolean = false;\r\n isLender: boolean = false;\r\n isBroker: boolean = false;\r\n isAdmin: boolean = false;\r\n isClient: boolean = false;\r\n\r\n // show different sections to Lender based on which button clicked on Case Dashboard\r\n showFeedbackSectionLender: boolean = false;\r\n showHoTDetailSectionLender: boolean = false;\r\n showRejectSectionLender: boolean = false;\r\n showWithdrawSectionLender: boolean = false;\r\n\r\n showTsAndCsModal: boolean = false;\r\n showTsAndCsForm: boolean = false;\r\n sendingMessage: boolean = false;\r\n goToUserDashboard: boolean = false;\r\n\r\n currentCase: CaseDTO;\r\n currentCaseLender: CaseLenderDTO;\r\n grossLoanCalcVal: number = 0;\r\n builLoanCalcVal: number = 0;\r\n landLoanCalcVal: number = 0;\r\n monetaryLAFee: number = 0;\r\n monetaryLEFee: number = 0;\r\n lenderTask: string = \"\";\r\n netBuildLoanCalcVal: number = 0;\r\n\r\n isRejectClicked: boolean = false;\r\n isWithdrawClicked: boolean = false;\r\n isConfirmClicked: boolean = false;\r\n isSubmitClicked: boolean = false;\r\n\r\n //Lender Message\r\n newChatMessage: string = \"\";\r\n showFullMessageId: number;\r\n\r\n //files\r\n fileUpload: FileAttachmentDTO[];\r\n uploadingFiles: FileUploadProgressDTO[];\r\n openModal: boolean = false;\r\n module = ModuleEnum.DIP;\r\n\r\n showFullLenderMessage = false;\r\n showFullBorrowerMessage = false;\r\n InterestRateTypeOptions = [];\r\n\r\n showLenderFeedBackModal: boolean = false;\r\n showBrokerFeedBackModal: boolean = false;\r\n feedBackDTO: FeedBackDTO;\r\n prevPath: string;\r\n\r\n brokerName: string;\r\n brokerOrganisationName: string;\r\n\r\n //Deleteing a chat message\r\n selectedDealLenderMessageDto: DealLenderMessageDTO;\r\n showdeleteChatMessageModal: boolean = false;\r\n showConfirmDeleteButton: boolean = false;\r\n\r\n currentUser: ApplicationUserDTO = {} as ApplicationUserDTO;\r\n productTypeText: string = null;\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private lenderService: LenderService,\r\n private caseService: CaseService,\r\n private caseLenderService: CaseLenderService,\r\n private roleService: RoleService,\r\n private caseLenderMessageService: CaseLenderMessageService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private $window: ng.IWindowService,\r\n private selectListService: SelectListService,\r\n private feedBackService: FeedBackService,\r\n private userService: UserService,\r\n private $auth: AuthService,\r\n private productService: ProductService,\r\n ) {\r\n this.feedBackDTO = {} as FeedBackDTO;\r\n if (\r\n this.$routeParams.openModule &&\r\n this.$routeParams.openModule == \"withdraw\"\r\n ) {\r\n this.toggleWithdrawSection = true;\r\n } else if (\r\n this.$routeParams.openModule &&\r\n this.$routeParams.openModule == \"reject\"\r\n ) {\r\n this.toggleRejectSection = true;\r\n } else if (this.$routeParams.openModule) {\r\n this.toggleFeedbackSection = true;\r\n }\r\n\r\n if (this.$routeParams.CaseId && this.$routeParams.CaseLenderId) {\r\n this.dataLoading = true;\r\n\r\n this.caseService\r\n .fetch(this.$routeParams.CaseId)\r\n .then((response) => {\r\n this.currentCase = response;\r\n\r\n if (this.currentCase) {\r\n this.caseLenderService\r\n .fetchByCaseId(\r\n this.$routeParams.CaseId,\r\n this.roleService.getIsLenderVisible(),\r\n this.$routeParams.CaseLenderId,\r\n )\r\n .then((response) => {\r\n this.caseLenders = response;\r\n if (this.$routeParams.CaseLenderId) {\r\n this.currentCaseLender = this.caseLenders.find(\r\n (caseLender) => {\r\n return caseLender.Id == this.$routeParams.CaseLenderId;\r\n },\r\n );\r\n this.fileUpload = this.currentCase.Attachments.filter((f) => {\r\n return f.CaseLenderId == this.$routeParams.CaseLenderId;\r\n });\r\n //this.recalculateArrangementPercent(); // this actually re-calculates the arrangement fee not the % - function name is wrong\r\n // this.recalculateExitPercent(); // this actually re-calculates the exit fee not the % - function name is wrong\r\n this.calculateGrossLoanValVal();\r\n this.calculateBuildLoadCalcVal();\r\n this.calculateLandLoanCalcVal();\r\n // this.calculatemonetaryLAFee();\r\n //this.calculatemonetaryLEFee();\r\n }\r\n });\r\n this.caseService.updateCaseState(\r\n this.currentCase.Id,\r\n this.currentCase.CaseStatus,\r\n );\r\n this.lenderTask = sessionStorage.getItem(\"lenderTask\");\r\n if (this.lenderTask != null && this.lenderTask.length > 0) {\r\n switch (this.lenderTask) {\r\n case \"reject\":\r\n this.showRejectSectionLender = true;\r\n break;\r\n case \"withdraw\":\r\n this.showWithdrawSectionLender = true;\r\n break;\r\n case \"feedback\":\r\n this.showFeedbackSectionLender = true;\r\n this.updateCaseLenderMessageReadDatetime();\r\n break;\r\n case \"terms\":\r\n this.showHoTDetailSectionLender = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n this.productTypeText = this.productService.getProductTypeFullName(\r\n ProductTypeEnum.Development,\r\n );\r\n } else {\r\n if ((this.$rootScope as any).selectedUser) {\r\n this.$location.path(\"/dashboard\");\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.getCurrentUserAndRoles();\r\n });\r\n }\r\n\r\n this.InterestRateTypeOptions = this.selectListService.GetInterestRateType();\r\n }\r\n\r\n /**Process the Send Feedback button being clicked */\r\n /* sendFeedbackClicked() {\r\n this.caseLenderService.sendFeedbackToBorrower(this.currentCaseLender, this.currentCase.DevelopmentInput.OwnerUser).then((response) => {\r\n //this.caseLenders = this.caseLenders.filter(lender => lender.Id != this.currentCaseLender.Id);\r\n //this.caseLenders.push(response);\r\n this.messageContent = 'Your feedback has been sent to the borrower.';\r\n this.goToUserDashboard = true;\r\n }).catch((error) => {\r\n this.messageContent = 'Sorry, something went wrong while sending feedback to the borrower. Please try again.';\r\n }).finally(() => {\r\n this.showInformationMessage = true;\r\n })\r\n }*/\r\n\r\n /**Calculate the Total Net Loan */\r\n calculateTotalNetLoan() {\r\n var totalNetLoan: number = 0;\r\n if (\r\n this.currentCaseLender &&\r\n this.currentCaseLender.BuildLoan &&\r\n this.currentCaseLender.LandLoan\r\n ) {\r\n totalNetLoan =\r\n +this.currentCaseLender.BuildLoan + +this.currentCaseLender.LandLoan;\r\n totalNetLoan = Math.round(totalNetLoan * 100) / 100;\r\n }\r\n return totalNetLoan;\r\n }\r\n\r\n checkingIfUserIsLender() {\r\n this.roleService.isLenderUser().then((response) => {\r\n this.isLender = response;\r\n });\r\n }\r\n\r\n checkingIfUerIsBroker() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isBroker()\r\n .then((response) => {\r\n this.isBroker = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkingIfUserIsAdmin() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isAdminUser()\r\n .then((response) => {\r\n this.isAdmin = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n checkingIfUserIsClient() {\r\n this.dataLoading = true;\r\n this.roleService\r\n .isClientUser()\r\n .then((response) => {\r\n this.isClient = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n /**Calculate total lender costs */\r\n totalLenderCosts() {\r\n var lenderCosts: number = 0;\r\n\r\n if (this.currentCaseLender) {\r\n lenderCosts =\r\n +this.currentCaseLender.LenderArrangementFee +\r\n +this.currentCaseLender.LenderExitFee +\r\n +this.currentCaseLender.InterestCoverAllocation;\r\n }\r\n return lenderCosts;\r\n }\r\n\r\n /**Calculate Arrangement Amount */\r\n recalculateArrangementAmount() {\r\n if (this.currentCaseLender && this.currentCaseLender.TotalGrossLoan) {\r\n //const element = event.currentTarget as HTMLInputElement\r\n //const value = parseFloat(element.value)\r\n\r\n //this.currentCaseLender.LenderArrangementFee = value;\r\n\r\n this.currentCaseLender.LenderArrangementFeePercent =\r\n (this.currentCaseLender.LenderArrangementFee * 100) /\r\n this.currentCaseLender.TotalGrossLoan;\r\n this.currentCaseLender.LenderArrangementFeePercent = parseFloat(\r\n this.currentCaseLender.LenderArrangementFeePercent.toFixed(2),\r\n );\r\n\r\n this.totalLenderCosts();\r\n }\r\n }\r\n\r\n /**Calculate borrower equity\r\n (Puchase Price - land loan)\r\n */\r\n calculateBorrowerEquity() {\r\n var borrowerEquity: number = 0;\r\n\r\n if (\r\n this.currentCase &&\r\n this.currentCase.DevelopmentInput.CI_Dev_OrigPP &&\r\n this.currentCaseLender &&\r\n this.currentCaseLender.LandLoan\r\n ) {\r\n borrowerEquity =\r\n this.currentCase.DevelopmentInput.CI_Dev_OrigPP -\r\n this.currentCaseLender.LandLoan;\r\n }\r\n return Number(borrowerEquity);\r\n }\r\n\r\n /**Calculate true cost */\r\n calculateTrueCost(): number {\r\n if (this.currentCaseLender) {\r\n var trueCost: number =\r\n +this.currentCaseLender.InterestRate / 12 +\r\n (+this.currentCaseLender.LenderArrangementFeePercent +\r\n +this.currentCaseLender.LenderExitFeePercent) /\r\n +this.currentCase.DevelopmentInput.CI_Dev_LoanTermReq;\r\n return trueCost;\r\n }\r\n }\r\n\r\n /**Re-calculate arrangement percent */\r\n recalculateArrangementPercent() {\r\n //const element = event.currentTarget as HTMLInputElement\r\n //const value = parseFloat(element.value)\r\n if (this.currentCaseLender && this.currentCaseLender.TotalGrossLoan) {\r\n //this.currentCaseLender.LenderArrangementFeePercent = value;\r\n this.currentCaseLender.LenderArrangementFee =\r\n (this.currentCaseLender.TotalGrossLoan *\r\n this.currentCaseLender.LenderArrangementFeePercent) /\r\n 100;\r\n this.currentCaseLender.LenderArrangementFee =\r\n Math.round(this.currentCaseLender.LenderArrangementFee * 100) / 100;\r\n this.totalLenderCosts();\r\n }\r\n }\r\n\r\n /**Recalculate Exit Amount */\r\n recalculateExitAmount() {\r\n const element = event.currentTarget as HTMLInputElement;\r\n const value = parseFloat(element.value);\r\n if (this.currentCaseLender && this.currentCaseLender.TotalGrossLoan) {\r\n this.currentCaseLender.LenderExitFee = value;\r\n\r\n this.currentCaseLender.LenderExitFeePercent =\r\n (this.currentCaseLender.LenderExitFee * 100) /\r\n this.currentCaseLender.TotalGrossLoan;\r\n /*this.currentCaseLender.LenderExitFeePercent = parseInt(this.currentCaseLender.LenderExitFeePercent.toFixed(2));*/\r\n this.currentCaseLender.LenderExitFeePercent =\r\n Math.round(this.currentCaseLender.LenderExitFeePercent * 100) / 100;\r\n this.totalLenderCosts();\r\n }\r\n }\r\n\r\n /**Recalculate Exit Percent */\r\n recalculateExitPercent() {\r\n //const element = event.currentTarget as HTMLInputElement\r\n //const value = parseFloat(element.value)\r\n if (\r\n this.currentCaseLender &&\r\n this.currentCaseLender.TotalGrossLoan &&\r\n this.currentCaseLender.LenderExitFeePercent\r\n ) {\r\n //this.currentCaseLender.LenderExitFeePercent = value;\r\n this.currentCaseLender.LenderExitFee =\r\n (this.currentCaseLender.TotalGrossLoan *\r\n this.currentCaseLender.LenderExitFeePercent) /\r\n 100;\r\n this.currentCaseLender.LenderExitFee =\r\n Math.round(this.currentCaseLender.LenderExitFee * 100) / 100;\r\n this.totalLenderCosts();\r\n }\r\n }\r\n\r\n /** Redirects to the case dashboard */\r\n goToCaseDashboard() {\r\n this.showFeedbackSectionLender = false;\r\n this.showHoTDetailSectionLender = false;\r\n this.showRejectSectionLender = false;\r\n this.showWithdrawSectionLender = false;\r\n if (\r\n this.isBroker &&\r\n !this.currentCaseLender.IsLenderReviewComplete &&\r\n (this.currentCaseLender.CaseLenderState == CaseLenderStateEnum.Offered ||\r\n this.currentCaseLender.CaseLenderState ==\r\n CaseLenderStateEnum.Rejected ||\r\n this.currentCaseLender.CaseLenderState == CaseLenderStateEnum.Withdrawn)\r\n ) {\r\n this.prevPath = \"casedashboard\";\r\n this.feedBackDTO.IsLenderFeedback = true;\r\n this.showLenderFeedBackModal = true;\r\n } else {\r\n this.$location.path(\"/casedashboard/\" + this.currentCase.Id);\r\n }\r\n }\r\n\r\n /** Close modal after send feedback */\r\n closeModal() {\r\n this.showDirection = false;\r\n this.showTsAndCsModal = false;\r\n this.showInformationMessage = false;\r\n this.isConfirmClicked = false;\r\n this.showdeleteChatMessageModal = false;\r\n if (this.goToUserDashboard) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n this.goToUserDashboard = false;\r\n this.showFeedbackSectionLender = false;\r\n this.showHoTDetailSectionLender = false;\r\n this.showRejectSectionLender = false;\r\n this.showWithdrawSectionLender = false;\r\n }\r\n\r\n if (this.prevPath) {\r\n if (this.isLender) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n } else {\r\n this.$location.path(`/${this.prevPath}/${this.currentCase.Id}`);\r\n }\r\n }\r\n }\r\n\r\n goToLending() {\r\n if (\r\n this.isBroker &&\r\n !this.currentCaseLender.IsLenderReviewComplete &&\r\n (this.currentCaseLender.CaseLenderState == CaseLenderStateEnum.Offered ||\r\n this.currentCaseLender.CaseLenderState ==\r\n CaseLenderStateEnum.Rejected ||\r\n this.currentCaseLender.CaseLenderState == CaseLenderStateEnum.Withdrawn)\r\n ) {\r\n this.prevPath = \"lending\";\r\n this.feedBackDTO.IsLenderFeedback = true;\r\n this.showLenderFeedBackModal = true;\r\n } else {\r\n this.$location.path(\"/lending/\" + this.currentCase.Id);\r\n }\r\n }\r\n\r\n saveUpdatedCaseLender(): void {\r\n //TODO JLH debug this process, seems a bit odd\r\n this.caseLenderService\r\n .addUpdate(this.currentCaseLender)\r\n .then((response) => {\r\n //TODO JLH debug this process, seems a bit odd\r\n this.caseLenders = this.caseLenders.filter(\r\n (lender) => lender.Id != this.currentCaseLender.Id,\r\n );\r\n this.caseLenders.push(response);\r\n\r\n this.messageContent = \"Your changes have been saved.\";\r\n this.showInformationMessage = true;\r\n });\r\n }\r\n\r\n /** Process the Lender button being clicked*/\r\n lenderClicked() {\r\n (this.$rootScope as any).isLender = false; // TODO JLH why is this being set to false? What if the user is a lender?\r\n this.$location.path(\"/lending/\" + this.currentCase.Id);\r\n }\r\n\r\n /** Process the Reject button being clicked*/\r\n rejectClicked(): void {\r\n this.isRejectClicked = true;\r\n this.caseLenderService\r\n .rejectCase(this.currentCaseLender)\r\n .then((response) => {\r\n this.currentCaseLender.CaseLenderState = response.CaseLenderState;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.messageContent =\r\n \"The borrower has been notified you have rejected their application.\";\r\n //TODO JLH debug this process, seems a bit odd\r\n this.caseLenders = this.caseLenders.filter(\r\n (lender) => lender.Id != this.currentCaseLender.Id,\r\n );\r\n this.caseLenders.push(this.currentCaseLender);\r\n })\r\n .catch((error) => {\r\n this.messageContent = \"Sorry, something went wrong. Please try again.\";\r\n this.isRejectClicked = false;\r\n })\r\n .finally(() => {\r\n this.goToUserDashboard = true;\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentCase.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n });\r\n }\r\n\r\n /**Process the Withdraw button being clicked */\r\n withdrawClicked(): void {\r\n this.isWithdrawClicked = true;\r\n this.caseLenderService\r\n .withdrawHoT(this.currentCaseLender)\r\n .then((response) => {\r\n //TODO JLH what is being returned here? the whole case?\r\n this.currentCaseLender.CaseLenderState = response.CaseLenderState;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.messageContent =\r\n \"The borrower has been notified you have withdrawn terms for their application.\";\r\n //TODO JLH debug this process, seems a bit odd\r\n this.caseLenders = this.caseLenders.filter(\r\n (lender) => lender.Id != this.currentCaseLender.Id,\r\n );\r\n this.caseLenders.push(this.currentCaseLender);\r\n })\r\n .catch((error) => {\r\n this.messageContent = \"Sorry, something went wrong. Please try again.\";\r\n this.isWithdrawClicked = false;\r\n })\r\n .finally(() => {\r\n this.goToUserDashboard = true;\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentCase.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n });\r\n }\r\n\r\n /**Process the Submit button being clicked */\r\n submitClicked() {\r\n this.isConfirmClicked = true;\r\n this.showTsAndCsModal = true;\r\n }\r\n\r\n /**Heads of Terms Submit button clicked event */\r\n submitHoTClicked() {\r\n // Close the Heads of Terms' Terms and Conditions modal\r\n this.showTsAndCsModal = false;\r\n this.sendingMessage = true;\r\n // Submit the Heads of Terms\r\n this.caseLenderService\r\n .submitHoT(this.currentCaseLender, this.currentCaseLender.CaseLenderState)\r\n .then((response) => {\r\n this.currentCaseLender.CaseLenderState = response.CaseLenderState;\r\n this.brokerName = response.DealBrokerName;\r\n this.brokerOrganisationName = response.DealBrokerOrganisationName;\r\n this.caseLenders = this.caseLenders.filter(\r\n (lender) => lender.Id != this.currentCaseLender.Id,\r\n );\r\n this.caseLenders.push(this.currentCaseLender);\r\n this.messageContent =\r\n \"Thank you for submitting a Decision in Principle.\";\r\n this.goToUserDashboard = true;\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while submitting your Decision in Principle. Please try again.\";\r\n this.isConfirmClicked = false;\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.currentCaseLender.IsBrokerReviewComplete ||\r\n this.currentCase.BrokerOrganisationId == null ||\r\n !this.isLender\r\n ? (this.showInformationMessage = true)\r\n : this.showBrokerFeedBack();\r\n });\r\n }\r\n\r\n showBrokerFeedBack() {\r\n this.feedBackDTO.IsBrokerFeedback = true;\r\n this.showBrokerFeedBackModal = true;\r\n }\r\n\r\n /**\r\n * Process the Send Feedback button being clicked\r\n * @param message\r\n */\r\n /* sendlenderFeedbackClicked() {\r\n this.caseLenderService.sendFeedbackToLender(this.currentCaseLender).then((response) => {\r\n this.messageContent = `Your feedback has been sent to ${this.currentCaseLender.LoanLabel != null ? this.currentCaseLender.LoanLabel:'the lender'}.`;\r\n this.feedbackMessageToLender = '';\r\n this.showInformationMessage = true;\r\n }).catch((error) => {\r\n this.messageContent = 'Sorry, something went wrong while sending feedback to lender. Please try again.';\r\n });\r\n }*/\r\n\r\n /**\r\n * Process the Apply button being clicked\r\n * @param currentCaseLender\r\n */\r\n applyClicked(selectedCaseLender: CaseLenderDTO) {\r\n // Show the Terms and Conditions modal\r\n this.showTsAndCsModal = true;\r\n }\r\n\r\n /**Process the Submit Terms and Conditions button being clicked */\r\n submitTsAndCsClicked() {\r\n this.isSubmitClicked = true;\r\n this.showTsAndCsModal = false;\r\n\r\n this.$location.path(\"/payment/\" + this.currentCase.Id);\r\n\r\n //TODO JLH need to wait for payment to be complete before actually applying ideally\r\n\r\n this.caseLenderService\r\n .applyToLender(this.currentCaseLender.CaseId, this.currentCaseLender.Id)\r\n .then((response) => {\r\n this.currentCaseLender.CaseLenderState = response.CaseLenderState;\r\n })\r\n .finally(() => {\r\n this.messageContent = `Thank you for submitting an application with ${\r\n this.currentCaseLender.LoanLabel != null\r\n ? this.currentCaseLender.LoanLabel\r\n : \"this lender\"\r\n }.`;\r\n this.showInformationMessage = true;\r\n });\r\n }\r\n\r\n calculateGrossLoanValVal() {\r\n if (\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan >= 0 &&\r\n this.currentCase.DevelopmentInput.CI_GDVCalculated != null &&\r\n this.currentCase.DevelopmentInput.CI_GDVCalculated >= 0\r\n ) {\r\n this.grossLoanCalcVal = parseFloat(\r\n (\r\n (this.currentCaseLender.TotalGrossLoan /\r\n this.currentCase.DevelopmentInput.CI_GDVCalculated) *\r\n 100\r\n ).toFixed(2),\r\n );\r\n }\r\n\r\n if (\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n if (\r\n this.currentCaseLender.LenderArrangementFeePercent != null &&\r\n this.currentCaseLender.LenderArrangementFeePercent > 0\r\n ) {\r\n this.calculatemonetaryLAFee();\r\n } else {\r\n if (\r\n this.currentCaseLender.LenderArrangementFee != null &&\r\n this.currentCaseLender.LenderArrangementFee > 0\r\n ) {\r\n this.calculatemonetaryLAPercent();\r\n }\r\n }\r\n\r\n if (\r\n this.currentCaseLender.LenderExitFeePercent != null &&\r\n this.currentCaseLender.LenderExitFeePercent > 0\r\n ) {\r\n this.calculatemonetaryLEFee();\r\n } else {\r\n if (\r\n this.currentCaseLender.LenderExitFee != null &&\r\n this.currentCaseLender.LenderExitFee > 0\r\n ) {\r\n this.calculatemonetaryLEPercent();\r\n }\r\n }\r\n } else {\r\n this.currentCaseLender.LenderArrangementFeePercent = 0;\r\n this.currentCaseLender.LenderArrangementFee = 0;\r\n this.currentCaseLender.LenderExitFeePercent = 0;\r\n this.currentCaseLender.LenderExitFee = 0;\r\n }\r\n }\r\n\r\n calculateBuildLoadCalcVal() {\r\n if (\r\n this.currentCaseLender.BuildLoan != null &&\r\n this.currentCaseLender.BuildLoan >= 0\r\n ) {\r\n this.builLoanCalcVal = parseFloat(\r\n (\r\n (this.currentCaseLender.BuildLoan / this.CalcTotalBuild()) *\r\n 100\r\n ).toFixed(2),\r\n );\r\n }\r\n }\r\n\r\n calculateLandLoanCalcVal() {\r\n if (\r\n this.currentCaseLender.LandLoan != null &&\r\n this.currentCaseLender.LandLoan >= 0\r\n ) {\r\n this.landLoanCalcVal = parseFloat(\r\n (\r\n (this.currentCaseLender.LandLoan /\r\n this.currentCase.DevelopmentInput.CI_Dev_OrigPP) *\r\n 100\r\n ).toFixed(2),\r\n );\r\n }\r\n }\r\n\r\n calculatemonetaryLAFee() {\r\n if (\r\n this.currentCaseLender.LenderArrangementFeePercent != null &&\r\n this.currentCaseLender.LenderArrangementFeePercent > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderArrangementFee =\r\n Math.round(\r\n this.currentCaseLender.TotalGrossLoan *\r\n this.currentCaseLender.LenderArrangementFeePercent *\r\n 100,\r\n ) / 100;\r\n } else {\r\n this.currentCaseLender.LenderArrangementFee = 0;\r\n }\r\n }\r\n\r\n calculatemonetaryLAPercent() {\r\n if (\r\n this.currentCaseLender.LenderArrangementFee != null &&\r\n this.currentCaseLender.LenderArrangementFee > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderArrangementFeePercent =\r\n this.currentCaseLender.LenderArrangementFee /\r\n this.currentCaseLender.TotalGrossLoan;\r\n\r\n this.currentCaseLender.LenderArrangementFeePercent = parseFloat(\r\n this.currentCaseLender.LenderArrangementFeePercent.toFixed(4),\r\n );\r\n } else {\r\n this.currentCaseLender.LenderArrangementFeePercent = 0;\r\n }\r\n }\r\n\r\n calculatemonetaryLEFee() {\r\n if (\r\n this.currentCaseLender.LenderExitFeePercent != null &&\r\n this.currentCaseLender.LenderExitFeePercent > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderExitFee =\r\n Math.round(\r\n this.currentCaseLender.TotalGrossLoan *\r\n this.currentCaseLender.LenderExitFeePercent *\r\n 100,\r\n ) / 100;\r\n } else {\r\n this.currentCaseLender.LenderExitFee = 0;\r\n }\r\n }\r\n\r\n calculatemonetaryLEPercent() {\r\n if (\r\n this.currentCaseLender.LenderExitFee != null &&\r\n this.currentCaseLender.LenderExitFee > 0 &&\r\n this.currentCaseLender.TotalGrossLoan != null &&\r\n this.currentCaseLender.TotalGrossLoan > 0\r\n ) {\r\n this.currentCaseLender.LenderExitFeePercent =\r\n this.currentCaseLender.LenderExitFee /\r\n this.currentCaseLender.TotalGrossLoan;\r\n this.currentCaseLender.LenderExitFeePercent = parseFloat(\r\n this.currentCaseLender.LenderExitFeePercent.toFixed(4),\r\n );\r\n } else {\r\n this.currentCaseLender.LenderExitFeePercent = 0;\r\n }\r\n }\r\n\r\n CalcTotalBuild(): number {\r\n var res: number = this.CalcAdditionalBuild();\r\n if (\r\n this.currentCase &&\r\n this.currentCase.DevelopmentInput.CI_Dev_BuildCosts\r\n ) {\r\n res += Number(this.currentCase.DevelopmentInput.CI_Dev_BuildCosts);\r\n }\r\n\r\n res += this.calcContingencyCost();\r\n return res;\r\n }\r\n\r\n CalcAdditionalBuild(): number {\r\n var res: number = 0;\r\n if (this.currentCase.DevelopmentInput.DI_BreakDownBuildCosts) {\r\n if (this.currentCase.DevelopmentInput.CI_Dev_ProfPlanning) {\r\n res += Number(this.currentCase.DevelopmentInput.CI_Dev_ProfPlanning);\r\n }\r\n if (this.currentCase.DevelopmentInput.CI_Dev_ProfQS) {\r\n res += Number(this.currentCase.DevelopmentInput.CI_Dev_ProfQS);\r\n }\r\n if (this.currentCase.DevelopmentInput.DI_BuildProjectManag) {\r\n res += Number(this.currentCase.DevelopmentInput.DI_BuildProjectManag);\r\n }\r\n if (this.currentCase.DevelopmentInput.CI_Dev_S106CIL) {\r\n res += Number(this.currentCase.DevelopmentInput.CI_Dev_S106CIL);\r\n }\r\n if (this.currentCase.DevelopmentInput.DI_BuildMechEng) {\r\n res += Number(this.currentCase.DevelopmentInput.DI_BuildMechEng);\r\n }\r\n if (this.currentCase.DevelopmentInput.DI_BuildStrucEng) {\r\n res += Number(this.currentCase.DevelopmentInput.DI_BuildStrucEng);\r\n }\r\n if (this.currentCase.DevelopmentInput.DI_BuildPartyWall) {\r\n res += Number(this.currentCase.DevelopmentInput.DI_BuildPartyWall);\r\n }\r\n if (this.currentCase.DevelopmentInput.DI_BuildLandscaping) {\r\n res += Number(this.currentCase.DevelopmentInput.DI_BuildLandscaping);\r\n }\r\n if (this.currentCase.DevelopmentInput.DI_BuildWarranty) {\r\n res += Number(this.currentCase.DevelopmentInput.DI_BuildWarranty);\r\n }\r\n if (this.currentCase.DevelopmentInput.DI_BuildDemolition) {\r\n res += Number(this.currentCase.DevelopmentInput.DI_BuildDemolition);\r\n }\r\n if (this.currentCase.DevelopmentInput.DI_BuildOtherCosts) {\r\n res += Number(this.currentCase.DevelopmentInput.DI_BuildOtherCosts);\r\n }\r\n } else {\r\n if (this.currentCase.DevelopmentInput.CI_Dev_AdditionalOngoingCosts) {\r\n res += Number(\r\n this.currentCase.DevelopmentInput.CI_Dev_AdditionalOngoingCosts,\r\n );\r\n }\r\n }\r\n return res;\r\n }\r\n\r\n calcContingencyCost(): number {\r\n var res: number = 0;\r\n if (\r\n this.currentCase.DevelopmentInput.CI_Dev_Contingency &&\r\n this.currentCase.DevelopmentInput.CI_Dev_BuildCosts\r\n ) {\r\n res =\r\n this.currentCase.DevelopmentInput.CI_Dev_Contingency *\r\n this.currentCase.DevelopmentInput.CI_Dev_BuildCosts;\r\n return res;\r\n }\r\n return res;\r\n }\r\n\r\n /**\r\n * Process the Send Feedback button being clicked\r\n * @param message\r\n */\r\n sendChatMessage() {\r\n this.dataLoading = true;\r\n\r\n let CaseChatMessage = {\r\n Message: this.newChatMessage,\r\n CaseId: this.$routeParams.CaseId,\r\n CaseLenderId: this.$routeParams.CaseLenderId,\r\n SenderRole: this.getSenderMessageRole(),\r\n RecipientRoles: this.isLender ? 10 : 4,\r\n } as CaseLenderMessageDTO;\r\n\r\n this.caseLenderMessageService\r\n .addUpdate(CaseChatMessage)\r\n .then((caseChatMessageResponse) => {\r\n this.currentCaseLender.CaseLenderMessage.push(caseChatMessageResponse);\r\n this.newChatMessage = null;\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while sending feedback. Please try again.\";\r\n }).finally(() =>{\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n showFullChatMessage(index) {\r\n this.showFullMessageId = index;\r\n }\r\n\r\n updateCaseLenderMessageReadDatetime() {\r\n this.caseLenderMessageService\r\n .updateCaseLenderMessageReadDatetime(this.$routeParams.CaseLenderId)\r\n .then((caseLenderMessageResponse) => {})\r\n .catch((error) => {});\r\n }\r\n\r\n onFileSelect(files: FileAttachmentDTO[], module: ModuleEnum) {\r\n if (files.length > 0) {\r\n this.fileAttachmentService\r\n .UploadFileLstInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.$routeParams.CaseId,\r\n this.fileUpload,\r\n module,\r\n this.$routeParams.CaseLenderId,\r\n )\r\n .then((result) => {\r\n this.openModal = false;\r\n });\r\n }\r\n }\r\n\r\n downloadFile(file: FileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.fileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n this.$window.open(uri);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n deleteFile(file: FileAttachmentDTO) {\r\n this.fileUpload.splice(this.fileUpload.indexOf(file), 1);\r\n this.fileAttachmentService.markasdeleted(file.Id).then((result) => {}); //remove on the server\r\n }\r\n\r\n getRateTypeText(e: InterestRateTypeEnum) {\r\n switch (e) {\r\n case InterestRateTypeEnum.Fixed:\r\n return \"Fixed\";\r\n case InterestRateTypeEnum.Variable:\r\n return \"Variable\";\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n addClass(star: number, id: string) {\r\n this.feedBackService.addClass(star, id);\r\n }\r\n\r\n removeClass(star: number, id: string, rating) {\r\n this.feedBackService.removeClass(star, id, rating);\r\n }\r\n\r\n isFeedBackFormDisabled() {\r\n return this.feedBackService.isFeedBackFormDisabled(\r\n this.isLender,\r\n this.feedBackDTO,\r\n );\r\n }\r\n\r\n updateRating(star, rating) {\r\n this.feedBackDTO = this.feedBackService.updateRating(\r\n star,\r\n rating,\r\n this.feedBackDTO,\r\n );\r\n }\r\n\r\n submitFeedBack() {\r\n if (this.isLender) {\r\n this.feedBackDTO.OrganisationId = this.currentCase.BrokerOrganisationId;\r\n this.feedBackDTO.BrokerUserId = this.currentCase.BrokerUserId;\r\n } else {\r\n this.feedBackDTO.LenderId = this.currentCaseLender.LenderId;\r\n }\r\n\r\n this.feedBackService\r\n .addFeedBack(this.feedBackDTO, this.currentCaseLender.Id, false)\r\n .then((response) => {\r\n if (this.isLender) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n } else {\r\n this.$location.path(`/${this.prevPath}/${this.currentCase.Id}`);\r\n }\r\n });\r\n }\r\n\r\n onClickDeleteMessageButton(message: DealLenderMessageDTO) {\r\n this.showdeleteChatMessageModal = true;\r\n this.messageContent = \"Are you sure you want to delete a selected message?\";\r\n this.selectedDealLenderMessageDto = message;\r\n this.showConfirmDeleteButton = true;\r\n }\r\n\r\n deleteChatMessage() {\r\n this.dataLoading = true;\r\n this.caseLenderMessageService\r\n .markasdeleted(this.selectedDealLenderMessageDto.Id)\r\n .then((response) => {\r\n this.currentCaseLender.CaseLenderMessage =\r\n this.currentCaseLender.CaseLenderMessage.filter(\r\n (x) => x.Id != this.selectedDealLenderMessageDto.Id,\r\n );\r\n })\r\n .catch((error) => {\r\n this.messageContent =\r\n \"Sorry, something went wrong while deleting message. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.showdeleteChatMessageModal = false;\r\n delete this.selectedDealLenderMessageDto;\r\n this.showConfirmDeleteButton = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n getSenderMessageRole() {\r\n if (this.isLender) {\r\n return MessageRoleEnum.Lender;\r\n } else if (this.isBroker) {\r\n return MessageRoleEnum.Broker;\r\n } else if (this.isAdmin) {\r\n return MessageRoleEnum.Admin;\r\n } else if (this.isClient) {\r\n return MessageRoleEnum.Client;\r\n }\r\n }\r\n\r\n getCurrentUserAndRoles() {\r\n this.dataLoading = true;\r\n this.userService\r\n .getcurentuserrecord()\r\n .then((result) => {\r\n this.currentUser = result;\r\n\r\n this.roleService.isClientUser().then((response) => {\r\n this.isClient = response;\r\n });\r\n\r\n this.roleService.isAdminUser().then((response) => {\r\n this.isAdmin = response;\r\n });\r\n\r\n this.roleService.isBroker().then((response) => {\r\n this.isBroker = response;\r\n });\r\n\r\n this.roleService.isLenderUser().then((response) => {\r\n this.isLender = response;\r\n if (!this.isLender) {\r\n this.toggleFeedbackSection = true;\r\n this.updateCaseLenderMessageReadDatetime();\r\n }\r\n });\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n isCurrentUserAllowedToSendChat(){\r\n if(this.toggleFeedbackSection||this.showFeedbackSectionLender){\r\n return true\r\n }\r\n return false;\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { DealCompletionDTO } from \"@js/DTO/DealCompletionDTO.cs.d\";\r\nimport { LenderDTO } from \"@js/DTO/LenderDTO.cs\";\r\nimport {\r\n BrokerAppraisal,\r\n BrokerAppraisalLender,\r\n} from \"@js/DTO/Messages/BrokerAppraisalMessage.cs.d\";\r\nimport {\r\n MakeReferralMessageRequest,\r\n LenderAppraisal,\r\n} from \"@js/DTO/Messages/MakeReferralMessage.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { WebConfigDTO } from \"@js/DTO/WebConfigDTO.cs.d\";\r\nimport { AccountService } from \"@js/services/AccountService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DealClientService } from \"@js/services/DealClientService\";\r\nimport { DealCompletionService } from \"@js/services/DealCompletionService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { LicenseService } from \"@js/services/LicenseService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class IndexController {\r\n fetchingResults: boolean = false;\r\n isPrimaryApplicant: boolean = true;\r\n\r\n user: ApplicationUserDTO;\r\n role: string;\r\n pageTitle: string;\r\n menuShrunk: boolean = false;\r\n errors: any[];\r\n copyrighttext: string;\r\n cookieMessageSeen: boolean;\r\n openShare: boolean;\r\n\r\n //Refer a friend\r\n referFriendName: string;\r\n referFriendSurname: string;\r\n referFriendEmail: string;\r\n\r\n //Generic share\r\n shareName: string;\r\n shareEmail: string;\r\n shareFriendsEmail: string;\r\n shareBody: string;\r\n\r\n //universal email send functions\r\n sendingsharemessage: boolean;\r\n sentsharemessage: boolean;\r\n\r\n //is Broker admin\r\n isAdminBroker: boolean = false;\r\n\r\n isIntroducer: boolean = false;\r\n isBroker: boolean = false;\r\n isLender: boolean = false;\r\n // is white labelling Org\r\n isWhiteLabelled: boolean = false;\r\n\r\n guidanceCheckbox: boolean = true;\r\n ShowHome: boolean = false;\r\n\r\n showMenu: boolean = false;\r\n\r\n showContactPopup: boolean = false;\r\n favIcon: HTMLLinkElement;\r\n title: HTMLLinkElement;\r\n companyWebsite: string;\r\n showContent: boolean = true;\r\n companyName: string = \"Brickflow\";\r\n companyUrlMenuIcon: string = null;\r\n footerTextFL: string;\r\n footerTextSL: string;\r\n footerTextTL: string;\r\n termsAndConditionsLink: string;\r\n privecyLink: string;\r\n cookiePolicyLink: string;\r\n productCode: string;\r\n nameInitial: string;\r\n openProfileImageSelection: boolean;\r\n brokerOrgNumber: string\r\n\r\n displayIfInactiveSubscription: boolean = false;\r\n showBanner: boolean = false;\r\n viewProfileRole: string; // the role displayed on profile menu : \"view your ___ profile\"\r\n isNormalBroker: boolean = false;\r\n orgAdminEmail: string;\r\n\r\n isAssigningBrokerToOrg: boolean = false;\r\n isLegacyUser: boolean = false;\r\n\r\n hubspotContactUsBookMeeting: string = \"\";\r\n\r\n headerBackgroundColour: string = \"\";\r\n\r\n //deal completion\r\n brokerAppraisals: BrokerAppraisal[] = [];\r\n newDealCompletion = {} as DealCompletionDTO;\r\n appraisalLenders: BrokerAppraisalLender[] = [];\r\n appraisalCompletionForm: ng.IFormController;\r\n appraisalName: string = \"\";\r\n showAppraisalNameDropdown: boolean = false;\r\n showAppraisalCompletionModal: boolean = false;\r\n filteredBrokerAppraisals: BrokerAppraisal[] = [];\r\n sendDealCompletionError: string = \"\";\r\n maxCompletionDate: Date = new Date();\r\n dataLoading: boolean = false;\r\n\r\n //Make a referral\r\n makeReferralForm: ng.IFormController;\r\n showMakeReferralModal: boolean = false;\r\n isSearchAttached?: boolean;\r\n isExistingSearch?: boolean;\r\n lenderReferralData: MakeReferralMessageRequest;\r\n lenderReferralClientFullName: string;\r\n message: string;\r\n showSubmitLenderReferralResponse: boolean = false;\r\n submitLenderReferralError: boolean = false;\r\n filteredLenderAppraisals: LenderAppraisal[] = [];\r\n lenderAppraisals: LenderAppraisal[] = [];\r\n hasLiveMarketSearch: boolean = false;\r\n isLenderReferralActive: boolean = false;\r\n contactDetails: string;\r\n\r\n loggedinUserLenderDetails: LenderDTO;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n \"AccountService\",\r\n \"CaseService\",\r\n \"OrganisationService\",\r\n \"FileAttachmentService\",\r\n \"UserService\",\r\n \"FileAttachmentService\",\r\n \"PaymentService\",\r\n \"ProductService\",\r\n \"DealCompletionService\",\r\n \"LicenseService\",\r\n \"DealClientService\",\r\n \"LenderService\"\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private $auth: AuthService,\r\n protected roleService: RoleService,\r\n private $accountservice: AccountService,\r\n private caseService: CaseService,\r\n private organisationService: OrganisationService,\r\n private fileAttachedService: FileAttachmentService,\r\n private userService: UserService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private $paymentService: PaymentService,\r\n private productService: ProductService,\r\n private dealCompletionService: DealCompletionService,\r\n private licenseService: LicenseService,\r\n private dealClientService: DealClientService,\r\n private lenderService: LenderService\r\n ) {\r\n this.setAuthorisation();\r\n\r\n // Used for test site to keep banner hidden\r\n if (localStorage.getItem(\"isTestBannerHidden\")) {\r\n if (localStorage.getItem(\"isTestBannerHidden\") == \"true\") {\r\n this.roleService.isTestBannerHidden = true;\r\n }\r\n }\r\n\r\n\r\n var d = new Date();\r\n (this.$rootScope as any).formSaved = true;\r\n this.footerTextTL =\r\n \"Copyright © Property Funding Hub Limited \" + d.getFullYear();\r\n\r\n this.$auth.getHubspotContactUsBookMeeting().then((hubSpotUrl: string) => {\r\n this.hubspotContactUsBookMeeting = hubSpotUrl;\r\n });\r\n\r\n this.$accountservice.getFooterWebConfigValue().then((val: WebConfigDTO) => {\r\n this.termsAndConditionsLink = val.TermsAndConditionsURL;\r\n this.privecyLink = val.PrivecyURL;\r\n this.cookiePolicyLink = val.CookiePolicyURL;\r\n this.headerBackgroundColour = val.HeaderBackgroundColour;\r\n });\r\n //$suppliers.fetchAll().then((response) => {\r\n // response.forEach((supplier, index) => {\r\n // if (!supplier.Coordinates) {\r\n // this.$http.get(\"https://nominatim.openstreetmap.org/search?q=\" + encodeURIComponent(supplier.Postcode) + \"&format=json\").then((response) => {\r\n // supplier.Coordinates = response.data[0].lat + \",\" + response.data[0].lon;\r\n // this.$suppliers.addUpdate(supplier);\r\n // });\r\n // }\r\n // });\r\n //});\r\n\r\n if ($scope) {\r\n $rootScope.$on(\"login\", (event: ng.IAngularEvent) => {\r\n this.roleService.IsAdminUser = false;\r\n this.roleService.IsLenderUserOrAbove = false;\r\n this.roleService.IsClientUserOrAbove = false;\r\n this.roleService.IsIntroducer = false;\r\n this.ShowHome = false;\r\n this.CalcShowHome();\r\n // this.showHubSpotChat();\r\n });\r\n\r\n $rootScope.$on(\"error\", (event: ng.IAngularEvent, data) => {\r\n if (!this.errors) {\r\n this.errors = [];\r\n }\r\n\r\n this.errors.push(data);\r\n });\r\n\r\n $rootScope.$on(\"clearerrors\", (event: ng.IAngularEvent, page: string) => {\r\n this.clearErrors(page);\r\n });\r\n\r\n if (window.self == window.top) {\r\n $scope.$on(\"$viewContentLoaded\", (event, next, current) => {\r\n this.cookieMessage();\r\n this.getGuidanceSwitchState();\r\n });\r\n\r\n $scope.$on(\"$routeChangeStart\", (event, next, current) => {\r\n this.setAuthorisation();\r\n this.getLeadGeneratorName();\r\n });\r\n }\r\n\r\n $scope.$on(\"$routeChangeSuccess\", (event, current, previous) => {\r\n if (window.self == window.top)\r\n this.isAssigningBrokerToOrg =\r\n sessionStorage.getItem(\"assignUserToOrg\") == \"true\";\r\n ($scope as any).ctrl.pageTitle = current.$$route.page;\r\n ($scope as any).ctrl.openSection = current.$$route.section;\r\n if (\r\n $location.path() === \"usermanagement\" ||\r\n $location.path() === \"rolemanagement\"\r\n ) {\r\n ($scope as any).ctrl.roleService.isAdminUser().then((isAdmin) => {\r\n if (!isAdmin) {\r\n $location.path(\"/login\");\r\n }\r\n });\r\n }\r\n\r\n this.favIcon = document.querySelector(\"#appIcon\");\r\n this.title = document.querySelector(\"#title\");\r\n this.companyUrlMenuIcon = this.favIcon ? this.favIcon.href : null;\r\n\r\n if (window.self == window.top && $cookies.get(\"access_token\")) {\r\n ($scope as any).ctrl.$auth.setIsLoggedIn(true);\r\n\r\n ($scope as any).ctrl.userService\r\n .getcurentuserrecord()\r\n .then((response) => {\r\n ($scope as any).ctrl.user = response;\r\n (this.$rootScope as any).selectedUser = response;\r\n\r\n this.nameInitial = response.FirstName.charAt(0);\r\n this.isLegacyUser = response.IsLegacyUser;\r\n\r\n if (\r\n response.ProfilePictureUrl &&\r\n response.ProfilePictureUrl.length > 0\r\n ) {\r\n this.fileAttachedService\r\n .getFileUri(response.ProfilePictureUrl)\r\n .then((result) => {\r\n ($scope as any).ctrl.user.ProfilePictureFullUrl = result;\r\n (\r\n this.$rootScope as any\r\n ).selectedUser.ProfilePictureFullUrl = result;\r\n });\r\n }\r\n\r\n this.buildFooterText(response);\r\n this.isAdminBroker = response.IsOrganisationAdmin;\r\n this.isNormalBroker =\r\n response.OrganisationId && !response.IsOrganisationAdmin;\r\n\r\n // If the user hasn't followed a whitelabelled link then \"whitelabel\" based on the user\r\n if (!$cookies.get(\"org_code\")) {\r\n organisationService\r\n .getOrganisation()\r\n .then((org: OrganisationDTO) => {\r\n this.userService.fileSelected =\r\n org.LogoURL != null &&\r\n org.LogoURL.length > 0 &&\r\n org.HasWhiteLabelAddOnPaid == true &&\r\n org.IsWhiteLabelled == true\r\n ? org.LogoURL\r\n : \"img/BrickFlow_Logo_RGB_Blue.svg\";\r\n this.isWhiteLabelled =\r\n org.HasWhiteLabelAddOnPaid && org.IsWhiteLabelled;\r\n this.companyWebsite =\r\n org.HasWhiteLabelAddOnPaid == true &&\r\n org.IsWhiteLabelled == true\r\n ? org.CompanyURL\r\n : \"https://brickflow.com\";\r\n\r\n if (\r\n org.LogoURL != null &&\r\n org.LogoURL.length > 0 &&\r\n org.HasWhiteLabelAddOnPaid &&\r\n org.IsWhiteLabelled\r\n ) {\r\n this.favIcon.href = org.FaviconURL;\r\n this.companyUrlMenuIcon = org.FaviconURL\r\n ? this.favIcon.href\r\n : null;\r\n\r\n sessionStorage.setItem(\"companyLogoUrl\", org.LogoURL);\r\n }\r\n\r\n this.companyName = org.Name;\r\n\r\n this.brokerOrgNumber = org.PhoneNumber;\r\n\r\n sessionStorage.setItem(\r\n \"companyWebsite\",\r\n this.companyWebsite,\r\n );\r\n\r\n if (!this.isWhiteLabelled) {\r\n if (\r\n !(this.$rootScope as any).selectedUser\r\n .DefaultBrokerOrganisationId\r\n ) {\r\n this.loadHubSpotChat();\r\n } else {\r\n if ((window as any).HubSpotConversations) {\r\n (window as any).HubSpotConversations.widget.remove();\r\n }\r\n }\r\n this.removeLSData();\r\n } else {\r\n if ((window as any).HubSpotConversations) {\r\n (window as any).HubSpotConversations.widget.remove();\r\n }\r\n\r\n if (\r\n org.OrganisationTermForApp != null &&\r\n org.OrganisationTermForApp.length > 0\r\n ) {\r\n sessionStorage.setItem(\r\n \"applicationName\",\r\n org.OrganisationTermForApp,\r\n );\r\n $rootScope.$broadcast(\r\n \"applicationNameChanged\",\r\n org.OrganisationTermForApp,\r\n );\r\n this.title.innerHTML = org.OrganisationTermForApp;\r\n }\r\n }\r\n });\r\n } else {\r\n if (\r\n !location.pathname.startsWith(\"/otmx\") &&\r\n !location.pathname.startsWith(\"/lnhn\")\r\n ) {\r\n if (\r\n location.pathname.replace(\"/\", \"\") != null &&\r\n location.pathname.replace(\"/\", \"\").length > 0\r\n ) {\r\n this.getOrganisationForWhiteLabelledUrl(response);\r\n }\r\n } else {\r\n this.removeLSData();\r\n }\r\n }\r\n\r\n this.roleService.GetUserRoles().then((roles) => {\r\n this.setViewProfileRole(roles);\r\n this.CalcShowHome();\r\n\r\n if (roles.find((x) => x.toLowerCase() == \"broker\")) {\r\n this.isPrimaryApplicant = false;\r\n this.isBroker = true;\r\n\r\n if (!this.isBroker || response.HasActiveSubscription) {\r\n sessionStorage.setItem(\"isValidLicense\", \"true\");\r\n } else {\r\n sessionStorage.setItem(\"isValidLicense\", \"false\");\r\n this.displayIfInactiveSubscription = this.showBanner = true;\r\n }\r\n\r\n this.organisationService\r\n .getOrganisationAdmin(this.user.OrganisationId)\r\n .then((response) => {\r\n this.orgAdminEmail = response;\r\n });\r\n }\r\n\r\n (this.$rootScope as any).userRoles = roles;\r\n\r\n //Commenting a below code as we no more using a redirectiong a legacyuser to landing page\r\n /* this.roleService.isIntroducerOnly().then((isIntroducerOnly: boolean) => {\r\n if (!this.roleService.IsAdminUser && !this.roleService.IsLender && !isIntroducerOnly && !this.roleService.IsClient) {\r\n if (response.IsLegacyUser && current.$$route.page != 'Landing' && current.$$route.page != 'Promo' && current.$$route.page != 'Broker Registration' && current.$$route.page != 'Registration' && current.$$route.page != 'Criteria' && current.$$route.page != 'Lender Results') {\r\n $location.path(\"/landing\");\r\n }\r\n } else if (sessionStorage.getItem('userOrgUniqueRef') != null && current.$$route.page != 'Broker Registration') {\r\n $location.path(\"/registerbroker\");\r\n }\r\n });*/\r\n });\r\n });\r\n } else {\r\n // default brickflow settings\r\n this.userService.fileSelected = \"img/BrickFlow_Logo_RGB_Blue.svg\";\r\n this.companyWebsite = \"https://brickflow.com\";\r\n //Below code is for displaying the application name\r\n if (\r\n !location.pathname.startsWith(\"/otmx\") &&\r\n !location.pathname.startsWith(\"/lnhn\")\r\n ) {\r\n if (\r\n location.pathname.replace(\"/\", \"\") != null &&\r\n location.pathname.replace(\"/\", \"\").length > 0\r\n ) {\r\n this.getOrganisationForWhiteLabelledUrl(null);\r\n } else {\r\n this.buildFooterText(null);\r\n this.loadHubSpotChat();\r\n if (window.self == window.top) this.removeLSData();\r\n this.favIcon.href = \"favicon.ico\";\r\n this.title.innerHTML = \"Brickflow\";\r\n }\r\n } else {\r\n this.buildFooterText(null);\r\n if (window.self == window.top) this.removeLSData();\r\n }\r\n }\r\n\r\n //keep track of last path\r\n //if (previous) {\r\n // (this.$rootScope as any).previousPath = previous.$$route.originalPath;\r\n // console.log(\"Last path: \" + previous.$$route.originalPath);\r\n //}\r\n //if (current) {\r\n // (this.$rootScope as any).currentPath = current.$$route.originalPath;\r\n // console.log(\"Currrent path: \" + current.$$route.originalPath);\r\n //}\r\n });\r\n if (window.self == window.top) {\r\n $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n this.updateGuidanceState();\r\n });\r\n $rootScope.$on(\"showContactPopup\", (event: ng.IAngularEvent) => {\r\n this.showContactPopup = !this.showContactPopup;\r\n });\r\n }\r\n\r\n /* if ($cookies.get('access_token')) {\r\n this.showHubSpotChat();\r\n }*/\r\n }\r\n }\r\n\r\n whiteLabeling(organisationId: number) {\r\n if (organisationId) {\r\n this.organisationService.fetch(organisationId).then((organisation) => {\r\n if (\r\n organisation &&\r\n organisation.IsWhiteLabelled == true &&\r\n organisation.HasWhiteLabelAddOnPaid == true &&\r\n organisation.LogoURL\r\n ) {\r\n this.fileAttachedService\r\n .getFileUri(organisation.LogoURL)\r\n .then((result) => {\r\n this.userService.fileSelected = result;\r\n });\r\n } else {\r\n this.userService.fileSelected = \"img/BrickFlow_Logo_RGB_Blue.svg\";\r\n }\r\n });\r\n }\r\n }\r\n\r\n contactPopup(): void {\r\n this.showContactPopup = !this.showContactPopup;\r\n }\r\n\r\n cookieMessage() {\r\n if (!this.$cookies.get(\"cookieMessageSeen\")) {\r\n this.cookieMessageSeen = false;\r\n } else {\r\n this.cookieMessageSeen = true;\r\n }\r\n return this.cookieMessageSeen;\r\n }\r\n cookieConsented() {\r\n this.cookieMessageSeen = true;\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 365);\r\n this.$cookies.put(\"cookieMessageSeen\", \"true\", { expires: expiryDate });\r\n }\r\n\r\n updateGuidanceState() {\r\n this.guidanceCheckbox =\r\n this.$cookies.get(\"guidance\") === \"on\" ||\r\n this.$cookies.get(\"guidance\") === undefined;\r\n }\r\n\r\n getGuidanceSwitchState() {\r\n if (!this.$cookies.get(\"guidance\")) {\r\n this.guidanceCheckbox = true;\r\n } else if (this.$cookies.get(\"guidance\") === \"on\") {\r\n this.guidanceCheckbox = true;\r\n } else if (this.$cookies.get(\"guidance\") === \"off\") {\r\n this.guidanceCheckbox = false;\r\n } else {\r\n this.guidanceCheckbox = true;\r\n }\r\n return this.guidanceCheckbox;\r\n }\r\n\r\n recordGuidanceCookie() {\r\n var guidanceSwitchState: string;\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 365);\r\n if (this.guidanceCheckbox == true) {\r\n guidanceSwitchState = \"on\";\r\n } else {\r\n guidanceSwitchState = \"off\";\r\n }\r\n this.$cookies.put(\"guidance\", guidanceSwitchState, { expires: expiryDate });\r\n this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n }\r\n\r\n setAuthorisation() {\r\n if (\r\n this.$cookies.get(\"access_token\") &&\r\n !this.$http.defaults.headers.common.Authorization\r\n ) {\r\n this.$http.defaults.headers.common.Authorization =\r\n \"Bearer \" + this.$cookies.get(\"access_token\");\r\n }\r\n }\r\n\r\n clearErrors(page: string) {\r\n if (this.errors) {\r\n this.errors = this.errors.filter((value: any, index: number) => {\r\n return value.page !== page;\r\n });\r\n }\r\n }\r\n dismissError(index: number) {\r\n this.errors.splice(index, 1);\r\n }\r\n\r\n isMobile(): boolean {\r\n return window.innerWidth <= 451;\r\n }\r\n\r\n /* displayDot() {\r\n var display = false; \r\n var hasLicense = this.user.LicenseMasterId != null;\r\n if (!this.user.LicenseMasterId && !this.user.SubscriptionStatus) {\r\n this.$paymentService.getLicense().then((response) => {\r\n var licenseData = response;\r\n if (response != null && response.Status != LicenseMasterStatusEnum.PreSubscription && response.Status != LicenseMasterStatusEnum.None) {\r\n this.user.SubscriptionStatus = licenseData.Status;\r\n var invalidLicense = this.user.SubscriptionStatus != LicenseMasterStatusEnum.PaidUp && this.user.SubscriptionStatus != LicenseMasterStatusEnum.PreCancel && this.user.SubscriptionStatus != LicenseMasterStatusEnum.PaymentProcessing;\r\n this.displayIfInactiveSubscription = this.showBanner = invalidLicense;\r\n } else {\r\n var invalidLicense = this.user.SubscriptionStatus != LicenseMasterStatusEnum.PaidUp && this.user.SubscriptionStatus != LicenseMasterStatusEnum.PreCancel && this.user.SubscriptionStatus != LicenseMasterStatusEnum.PaymentProcessing;\r\n var display = !hasLicense || invalidLicense;\r\n this.displayIfInactiveSubscription = this.showBanner = display;\r\n }\r\n });\r\n } else {\r\n var invalidLicense = this.user.SubscriptionStatus != LicenseMasterStatusEnum.PaidUp && this.user.SubscriptionStatus != LicenseMasterStatusEnum.PreCancel && this.user.SubscriptionStatus != LicenseMasterStatusEnum.PaymentProcessing;\r\n var display = !hasLicense || invalidLicense;\r\n this.displayIfInactiveSubscription = this.showBanner = display;\r\n }\r\n\r\n }*/\r\n\r\n CalcShowHome() {\r\n if ((this.$scope as any).ctrl.$auth.getIsLoggedIn() == false) {\r\n this.ShowHome = false;\r\n } else {\r\n if (\r\n (this.roleService.isAdminUser && this.pageTitle == \"Dashboard\") ||\r\n (this.roleService.isClientUser &&\r\n this.pageTitle == \"Client Dashboard\") ||\r\n (this.roleService.isLenderUser && this.pageTitle == \"Lenders\")\r\n ) {\r\n this.ShowHome = false;\r\n } else {\r\n this.ShowHome = true;\r\n }\r\n }\r\n }\r\n\r\n GoHome() {\r\n if ((this.$scope as any).ctrl.$auth.getIsLoggedIn() == false) {\r\n return false;\r\n }\r\n\r\n this.roleService.goHomeBasedOnUser();\r\n }\r\n\r\n go(path: string) {\r\n this.$location.path(path);\r\n }\r\n\r\n newloan() {\r\n (this.$rootScope as any).loanCriteria = null;\r\n this.$location.path(\"/criteria\");\r\n }\r\n\r\n sendShare(): void {\r\n this.sendingsharemessage = true;\r\n this.sentsharemessage = false;\r\n\r\n this.$accountservice\r\n .SendLoansAdvertEmail(\r\n this.shareName,\r\n this.shareEmail,\r\n this.shareFriendsEmail,\r\n this.shareBody,\r\n )\r\n .then((response2) => {\r\n this.sendingsharemessage = false;\r\n this.sentsharemessage = true;\r\n });\r\n }\r\n\r\n logout() {\r\n let broadcastResult = this.$rootScope.$broadcast(\"logout\");\r\n\r\n if (broadcastResult.defaultPrevented) return;\r\n\r\n this.displayIfInactiveSubscription = false; //hide red dot\r\n\r\n delete this.user;\r\n this.$auth.logout();\r\n // this.showHubSpotChat();\r\n }\r\n\r\n newBlankCase() {\r\n this.fetchingResults = true;\r\n this.caseService\r\n .newBlankCase(this.user, this.isPrimaryApplicant)\r\n .then((newBlankCaseDto) => {\r\n if (newBlankCaseDto && newBlankCaseDto.NewCaseId) {\r\n this.$location.path(\"/casedashboard/\" + newBlankCaseDto.NewCaseId);\r\n this.fetchingResults = false;\r\n }\r\n });\r\n }\r\n\r\n /**Main menu link clicked (3 bricks icon button) */\r\n /**todo: add else outer statement for button to work when user is not logged in (not working at the moment)\r\n * else inner statement (userdashboard one) should do something similar to showHomeDashboard() method in \"userdashboardcontroller.ts\"\r\n */\r\n mainMenuLinkClicked() {\r\n if (this.$auth.isLoggedIn) {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n\r\n if (this.roleService.IsAdminUser == true) {\r\n this.go(\"/dashboard\");\r\n } else {\r\n /*clearing a session storage in case lender has set a data while referring search*/\r\n sessionStorage.removeItem(\"lenderReferralClient\");\r\n this.go(\"/\");\r\n }\r\n } else {\r\n this.go(\"/\");\r\n }\r\n }\r\n\r\n goToNewUserDashboard() {\r\n // TODO - Temporary code JLH\r\n this.go(\"/userdashboard2\");\r\n }\r\n\r\n homePageClicked() {\r\n let broadcastResult = this.$rootScope.$broadcast(\"logout\");\r\n if (broadcastResult.defaultPrevented) return;\r\n window.location.href = this.companyWebsite;\r\n }\r\n\r\n showHubSpotChat() {\r\n this.organisationService\r\n .getOrganisation()\r\n .then((userOrganisation: OrganisationDTO) => {\r\n // Hide the hubspot chat feature if the user's organisation is white-labelled\r\n if (\r\n userOrganisation.IsWhiteLabelled == true &&\r\n userOrganisation.HasWhiteLabelAddOnPaid == true &&\r\n (window as any).HubSpotConversations\r\n ) {\r\n (window as any).HubSpotConversations.widget.remove();\r\n } else {\r\n if ((window as any).HubSpotConversations) {\r\n (window as any).HubSpotConversations.widget.load();\r\n }\r\n }\r\n });\r\n }\r\n\r\n /* Below code is to include chat script */\r\n loadHubSpotChat() {\r\n if ((window as any).HubSpotConversations) {\r\n (window as any).HubSpotConversations.widget.load();\r\n } else {\r\n const node = document.createElement(\"script\");\r\n node.src = \"//js.hs-scripts.com/7081779.js\";\r\n node.type = \"text/javascript\";\r\n document.getElementsByTagName(\"head\")[0].appendChild(node);\r\n }\r\n }\r\n\r\n removeLSData() {\r\n sessionStorage.removeItem(\"applicationName\");\r\n sessionStorage.removeItem(\"companyWebsite\");\r\n sessionStorage.removeItem(\"companyLogoUrl\");\r\n }\r\n\r\n getOrganisationForWhiteLabelledUrl(user: ApplicationUserDTO) {\r\n this.showContent = false;\r\n this.organisationService\r\n .getOrganisationByOrgCode(location.pathname.replace(\"/\", \"\"))\r\n .then((userOrganisation: OrganisationDTO) => {\r\n if (userOrganisation != null) {\r\n if (\r\n userOrganisation.HasWhiteLabelAddOnPaid == true &&\r\n userOrganisation.IsWhiteLabelled == true &&\r\n userOrganisation.OrganisationTermForApp != null &&\r\n userOrganisation.OrganisationTermForApp.length > 0\r\n ) {\r\n if (window.self == window.top) {\r\n sessionStorage.setItem(\r\n \"applicationName\",\r\n userOrganisation.OrganisationTermForApp,\r\n );\r\n } else {\r\n this.organisationService.sendDataToParent(\r\n \"applicationName\",\r\n userOrganisation.OrganisationTermForApp,\r\n );\r\n }\r\n } else {\r\n sessionStorage.removeItem(\"applicationName\");\r\n }\r\n\r\n if (window.self == window.top && userOrganisation.CompanyURL) {\r\n sessionStorage.setItem(\r\n \"companyWebsite\",\r\n userOrganisation.CompanyURL,\r\n );\r\n } else {\r\n sessionStorage.removeItem(\"companyWebsite\");\r\n }\r\n\r\n if (window.self == window.top && userOrganisation.LogoURL) {\r\n sessionStorage.setItem(\"companyLogoUrl\", userOrganisation.LogoURL);\r\n } else {\r\n sessionStorage.removeItem(\"companyLogoUrl\");\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.showContent = true;\r\n this.buildFooterText(user);\r\n });\r\n }\r\n\r\n buildShareMsg() {\r\n let lsd = sessionStorage.getItem(\"applicationName\");\r\n if (lsd != null) {\r\n this.shareBody =\r\n \"Hi,\\n\\nI've just been trying out \" +\r\n lsd +\r\n \" - it’s a comparison site for specialist property finance, its's fast and it's really useful. You should check it out.\";\r\n } else {\r\n this.shareBody =\r\n \"Hi, \\n\\nI've just been trying out Brickflow - it’s a comparison site for specialist property finance, its's fast and it's really useful. You should check it out.\";\r\n }\r\n }\r\n\r\n buildFooterText(user: ApplicationUserDTO) {\r\n var lsd;\r\n if (window.self == window.top)\r\n lsd = sessionStorage.getItem(\"applicationName\");\r\n if (!user && lsd != null) {\r\n this.footerTextFL = `${lsd} is designed to be used by brokers and property investors to source and apply for funding. It’s a collaborative project management tool, where you can store information and invite your colleagues to participate to make the application process quicker and easier.`;\r\n this.footerTextSL = null;\r\n } else {\r\n if (user && (user.IsOrganisationAdmin || user.OrganisationId > 0)) {\r\n this.footerTextFL =\r\n \"Property Funding Hub Limited (t/a Brickflow) is designed to be used by mortgage brokers to source and apply for specialist property finance for their clients.\";\r\n this.footerTextSL = null;\r\n } else if (\r\n user &&\r\n user.OrganisationReferralId != null &&\r\n user.OrganisationReferralId > 0\r\n ) {\r\n this.footerTextFL = `${lsd} is designed to be used by brokers and property investors to source and apply for funding. It’s a collaborative project management tool, where you can store information and invite your colleagues to participate to make the application process quicker and easier.`;\r\n this.footerTextSL = null;\r\n } else {\r\n this.footerTextFL =\r\n \"Property Funding Hub Limited (t/a Brickflow) is designed to be used by corporate borrowers (Limited Companies or Incorporated Partnerships) to compare and apply for specialist property finance loans.\";\r\n this.footerTextSL =\r\n \"Brickflow is not an advisory business and does not give advice. It can deal with purely factual inquiries and provide information but it will not give an opinion or recommendation in any circumstances.\";\r\n }\r\n }\r\n }\r\n\r\n isLoggedIn(): boolean {\r\n return this.$auth.getIsLoggedIn();\r\n }\r\n\r\n /**\r\n * Called when a profile picture has been selected\r\n * @param files\r\n */\r\n onFileSelect(files) {\r\n this.fileAttachmentService.uploadFileAndReturnURI(files).then((result) => {\r\n // Make a copy of the main profile object so that the main page doesn't get updated at the same time\r\n //this.user = Utils.deepCopy(this.profile);\r\n\r\n this.user.ProfilePictureUrl = result.FileLocation;\r\n\r\n this.userService.addUpdate(this.user).then((userResponse) => {\r\n // TODO - JLH - I don't like that I'm getting the profile again - but the addupdate function isn't returning the roles in the user dto which causes them to disappear if you save again.\r\n this.userService\r\n .getcurentuserrecord()\r\n .then((user: ApplicationUserDTO) => {\r\n this.user = user;\r\n\r\n this.fileAttachedService\r\n .getFileUri(this.user.ProfilePictureUrl)\r\n .then((result) => {\r\n this.user.ProfilePictureFullUrl = result;\r\n });\r\n\r\n // Update the profile cookie so that the rest of the application can be aware of the profile changes\r\n this.$auth.setProfileCookie(this.user);\r\n });\r\n\r\n this.openProfileImageSelection = false;\r\n });\r\n });\r\n }\r\n\r\n toggleBanner() {\r\n this.showBanner = !this.showBanner;\r\n }\r\n\r\n setViewProfileRole(roles: string[]) {\r\n if (roles.find((x) => x.toLowerCase() == \"admin\"))\r\n this.viewProfileRole = \"administrator\";\r\n else if (roles.find((x) => x.toLowerCase() == \"client\"))\r\n this.viewProfileRole = \"borrower\";\r\n else if (roles.find((x) => x.toLowerCase() == \"broker\"))\r\n this.viewProfileRole = \"broker\";\r\n else if (roles.find((x) => x.toLowerCase() == \"lender\")) {\r\n this.viewProfileRole = \"lender\";\r\n this.isLender = true;\r\n this.lenderService\r\n .getUserLenderDetails()\r\n .then((response) => {\r\n this.loggedinUserLenderDetails = response;\r\n this.hasLiveMarketSearch = response.HasLiveMarketSearch;\r\n this.isLenderReferralActive = response.IsLenderReferralActive;\r\n })\r\n .finally(() => {\r\n if (this.hasLiveMarketSearch && this.isLenderReferralActive) {\r\n this.$auth.getReferralContactDetails().then((response) => {\r\n this.contactDetails = response;\r\n });\r\n }\r\n });\r\n } else this.viewProfileRole = \"\";\r\n }\r\n\r\n getLeadGeneratorName() {\r\n if (!this.$cookies.get(\"leadgeneratorname\")) {\r\n const expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 1);\r\n\r\n this.productService.getLeadGeneratorName().then((response) => {\r\n this.$cookies.put(\"leadgeneratorname\", response, {\r\n expires: expiryDate,\r\n });\r\n });\r\n }\r\n }\r\n\r\n getFilteredBrokerAppraisals() {\r\n if (this.appraisalName != null && this.appraisalName.length > 0) {\r\n this.filteredBrokerAppraisals = this.brokerAppraisals.filter(\r\n (appraisal) =>\r\n appraisal.AppraisalName != null &&\r\n appraisal.AppraisalName.toLowerCase().indexOf(\r\n this.appraisalName.toLowerCase(),\r\n ) !== -1,\r\n );\r\n } else {\r\n this.filteredBrokerAppraisals = this.brokerAppraisals;\r\n }\r\n\r\n this.showAppraisalNameDropdown = true;\r\n }\r\n\r\n onSelectingAppraisalName(item: BrokerAppraisal) {\r\n this.appraisalName = item.AppraisalName;\r\n this.showAppraisalNameDropdown = false;\r\n this.newDealCompletion.AppraisalId = item.AppraisalId;\r\n this.newDealCompletion.AppraisalType = item.IsDeal ? \"Deal\" : \"Case\";\r\n this.appraisalLenders = [];\r\n this.appraisalCompletionForm.LenderId.$setPristine();\r\n this.appraisalCompletionForm.LenderId.$setUntouched();\r\n }\r\n\r\n sendDealCompletionEmail() {\r\n this.dataLoading = true;\r\n this.dealCompletionService\r\n .sendDealCompletionEmail(this.newDealCompletion)\r\n .then((response) => {\r\n if (response) {\r\n this.showAppraisalCompletionModal = false;\r\n } else {\r\n this.sendDealCompletionError =\r\n \"Your message could not be delivered. Please reach out to Brickflow so that we can investigate.\";\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n onClickOfCompletion() {\r\n var modalContent = document.getElementsByClassName(\"modal-content\");\r\n if (modalContent.length <= 0) {\r\n this.showAppraisalNameDropdown = false;\r\n this.newDealCompletion = {} as DealCompletionDTO;\r\n this.appraisalName = \"\";\r\n this.sendDealCompletionError = \"\";\r\n this.appraisalLenders = [];\r\n this.showAppraisalCompletionModal = !this.showAppraisalCompletionModal;\r\n this.dataLoading = true;\r\n this.dealCompletionService\r\n .getBrokerAppraisalDetails()\r\n .then((response) => {\r\n this.filteredBrokerAppraisals = this.brokerAppraisals =\r\n response.BrokerAppraisals;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n closeAppraisalNameListDropDown() {\r\n event.stopPropagation();\r\n if (this.showAppraisalNameDropdown && !this.dataLoading) {\r\n this.showAppraisalNameDropdown = false;\r\n }\r\n }\r\n\r\n onClickOfCaseNameElement() {\r\n event.stopPropagation();\r\n if (!this.dataLoading)\r\n this.showAppraisalNameDropdown = !this.showAppraisalNameDropdown;\r\n }\r\n\r\n populateAppraisalLenders() {\r\n if (\r\n this.appraisalName.length > 0 &&\r\n this.filteredBrokerAppraisals.length > 0\r\n ) {\r\n this.appraisalLenders = this.filteredBrokerAppraisals.find(\r\n (b) => b.AppraisalName == this.appraisalName,\r\n ).AppraisalLenders;\r\n } else {\r\n this.appraisalLenders = [];\r\n }\r\n }\r\n\r\n onClickOfMakeAReferral() {\r\n var modalContent = document.getElementsByClassName(\"modal-content\");\r\n if (modalContent.length <= 0) {\r\n this.lenderReferralData = {} as MakeReferralMessageRequest;\r\n this.appraisalName = \"\";\r\n this.showAppraisalNameDropdown = false;\r\n this.isSearchAttached = null;\r\n this.isExistingSearch = null;\r\n this.lenderReferralClientFullName = \"\";\r\n this.showSubmitLenderReferralResponse = false;\r\n this.submitLenderReferralError = false;\r\n this.showMakeReferralModal = !this.showMakeReferralModal;\r\n this.dataLoading = true;\r\n this.userService\r\n .getLenderAppraisals()\r\n .then((response) => {\r\n this.filteredLenderAppraisals = this.lenderAppraisals = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n submitLenderReferral() {\r\n this.dataLoading = true;\r\n this.populateFirstAndLastNameForClient();\r\n if (!this.isSearchAttached) this.lenderReferralData.DealId = null;\r\n this.dealClientService\r\n .submitLenderReferral(this.lenderReferralData)\r\n .then((response) => {\r\n if (response) {\r\n this.message = \"Your referral has been submitted.\";\r\n this.showSubmitLenderReferralResponse = true;\r\n } else {\r\n this.message = \"Error while making a referral, please try later.\";\r\n this.showSubmitLenderReferralResponse = true;\r\n this.submitLenderReferralError = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n goToLoanTypeSelectionPage() {\r\n this.populateFirstAndLastNameForClient();\r\n sessionStorage.setItem(\r\n \"lenderReferralClient\",\r\n JSON.stringify(this.lenderReferralData.ClientDTO),\r\n );\r\n this.$auth.setHasValidStatustoShowShareSearchModal(\r\n true,\r\n );\r\n this.showMakeReferralModal = false;\r\n this.$location.path(\"/allloans\");\r\n }\r\n\r\n populateFirstAndLastNameForClient() {\r\n let userFullName = this.lenderReferralClientFullName;\r\n let spaceIndex = userFullName.indexOf(\" \");\r\n\r\n let firstName = \"\";\r\n let lastName = \"\";\r\n\r\n // if not space has been added to the name then put the whole name in the first name field\r\n if (spaceIndex == -1) {\r\n firstName = userFullName;\r\n } else {\r\n firstName = userFullName.substring(0, userFullName.indexOf(\" \"));\r\n lastName = userFullName.substring(userFullName.indexOf(\" \") + 1);\r\n }\r\n\r\n this.lenderReferralData.ClientDTO.FirstName = firstName;\r\n this.lenderReferralData.ClientDTO.LastName = lastName;\r\n }\r\n\r\n closeLenderReferralModal() {\r\n this.showMakeReferralModal = false;\r\n if (\r\n this.$location.path().startsWith(\"/bridgingresults\") ||\r\n this.$location.path().startsWith(\"/commercialresults\") ||\r\n this.$location.path().startsWith(\"/devfinanceresults\")\r\n ) {\r\n window.location.reload();\r\n }\r\n }\r\n\r\n onLenderSelectingSearchName(item: LenderAppraisal) {\r\n this.showAppraisalNameDropdown = false;\r\n this.appraisalName = item.DealName;\r\n this.lenderReferralData.DealId = item.DealId;\r\n }\r\n\r\n getFilteredLenderAppraisals() {\r\n if (this.appraisalName != null && this.appraisalName.length > 0) {\r\n this.filteredLenderAppraisals = this.lenderAppraisals.filter(\r\n (appraisal) =>\r\n appraisal.DealName != null &&\r\n appraisal.DealName.toLowerCase().indexOf(\r\n this.appraisalName.toLowerCase(),\r\n ) !== -1,\r\n );\r\n } else {\r\n this.filteredLenderAppraisals = this.lenderAppraisals;\r\n }\r\n\r\n this.showAppraisalNameDropdown = true;\r\n }\r\n\r\n hideHeader() {\r\n if (\r\n !this.$cookies.get(\"access_token\") &&\r\n (this.$location.path().startsWith(\"/e/bridgingcriteria\") ||\r\n this.$location.path().startsWith(\"/e/commercialcriteria\") ||\r\n this.$location.path().startsWith(\"/e/devfinancecriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\") || this.$location.path().startsWith(\"/e/enterpriseleadcapture\"))\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n hideFooter() {\r\n if (!this.$cookies.get(\"access_token\") && this.$location.path().includes('widget') && window.self != window.top && \r\n (this.$location.path().startsWith(\"/e/bridgingcriteria\") ||\r\n this.$location.path().startsWith(\"/e/commercialcriteria\") ||\r\n this.$location.path().startsWith(\"/e/devfinancecriteria\") ||\r\n this.$location.path().startsWith(\"/allloans\"))) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n isResultsPage(){\r\n if (\r\n this.$location.path().startsWith(\"/referredSearch\") ||\r\n this.$location.path().startsWith(\"/resultsExternalAPI\") ||\r\n this.$location.path().startsWith(\"/exitloanresults\") ||\r\n this.$location.path().startsWith(\"/bridgingresults\") ||\r\n this.$location.path().startsWith(\"/bridgingshortlistmore\") ||\r\n this.$location.path().startsWith(\"/referredsearchdeal\") ||\r\n this.$location.path().startsWith(\"/referredsearchcommercial\") ||\r\n this.$location.path().startsWith(\"/referredsearchdevfinance\") ||\r\n this.$location.path().startsWith(\"/commercialresults\") ||\r\n this.$location.path().startsWith(\"/commercialshortlistmore\") ||\r\n this.$location.path().startsWith(\"/devfinanceresults\") ||\r\n this.$location.path().startsWith(\"/devfinanceshortlistmore\") ||\r\n this.$location.path().startsWith(\"/results\") ||\r\n this.$location.path().startsWith(\"/shortlistmore\") ||\r\n this.$location.path().startsWith(\"/e/bridgingresults\") ||\r\n this.$location.path().startsWith(\"/e/commercialresults\") ||\r\n this.$location.path().startsWith(\"/e/devfinanceresults\") \r\n ) {\r\n\r\n return true;\r\n }else{\r\n return false;\r\n }\r\n }\r\n\r\n showSignInButton(){\r\n if(this.$location.path().startsWith(\"/e/bridgingresults\") ||\r\n this.$location.path().startsWith(\"/e/commercialresults\") ||\r\n this.$location.path().startsWith(\"/e/devfinanceresults\")) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n goToNewSearch() {\r\n this.$location.path(\"/allloans\");\r\n }\r\n}\r\n\r\n","export const enum ApplicantRoleEnum {\r\n Developer = 0,\r\n Introducer = 1,\r\n Broker = 2,\r\n Lender = 3,\r\n Agent = 4,\r\n Other = 5,\r\n}\r\n","export const enum IntroducerTypeEnum {\r\n Accountant = 1,\r\n Architect = 2,\r\n Broker = 3,\r\n Builder = 4,\r\n Developer = 5,\r\n EstateOrLandAgent = 6,\r\n IFA = 7,\r\n ProjectManager = 8,\r\n PropertyManager = 9,\r\n QuantitySurveyor = 10,\r\n Solicitor = 11,\r\n Trustee = 12,\r\n Other = 13,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { OrganisationLinkDTO } from \"@js/DTO/OrgnisationLinkDTO.cs.d\";\r\nimport { ApplicantRoleEnum } from \"@js/models/enum/ApplicantRoleEnum.cs.d\";\r\nimport { IntroducerTypeEnum } from \"@js/models/enum/IntroducerTypeEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { PostalAddress } from \"@js/models/PostalAddress.cs.d\";\r\nimport { ClientService } from \"@js/services/ClientService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationLinkService } from \"@js/services/OrganisationLinkService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { UserRoleEnum } from \"@js/models/enum/UserRoleEnum.cs.d\";\r\n\r\nexport class InitialRegistrationController {\r\n selectedType: number;\r\n\r\n RoleEnum = {\r\n All: 0,\r\n DevelopmentFinance: 1,\r\n BridgingFinance: 2,\r\n Clients: 3,\r\n };\r\n\r\n user: ApplicationUserDTO;\r\n client: ClientDTO;\r\n isBroker: boolean = false;\r\n projectName: string;\r\n\r\n error: string = \"\";\r\n registrationForm: ng.IFormController;\r\n isBorrower: boolean = false;\r\n panelHeaderText: string;\r\n dataLoading: boolean = false;\r\n totalLenders: number = 0;\r\n orgLogo: string = \"\";\r\n testimonialText: string = \"\";\r\n testimonalCustomer: string = \"\";\r\n showTsAndCs: boolean = false;\r\n acceptTerms: boolean = false;\r\n acceptDataTerms: boolean = false;\r\n showPrivacyPolicy: boolean = false;\r\n orgCode: string;\r\n headingAdjustment: string;\r\n organisation: OrganisationDTO;\r\n userRole: UserRoleEnum;\r\n organisationLink: OrganisationLinkDTO;\r\n clientId: string;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$location\",\r\n \"UserService\",\r\n \"OrganisationService\",\r\n \"$rootScope\",\r\n \"LenderService\",\r\n \"$cookies\",\r\n \"EventLogService\",\r\n \"ClientService\",\r\n \"OrganisationLinkService\",\r\n ];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private userService: UserService,\r\n private organisationService: OrganisationService,\r\n public $rootScope: ng.IRootScopeService,\r\n private lenderService: LenderService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private eventLogService: EventLogService,\r\n private clientService: ClientService,\r\n private organisationLinkService: OrganisationLinkService,\r\n ) {\r\n this.setBrokerOrBorrower()\r\n .then(() => {\r\n if (this.$routeParams.isBroker == \"broker\") {\r\n this.isBroker = true;\r\n sessionStorage.setItem(\"userRole\", UserRoleEnum.Broker.toString());\r\n //TODO Change for New pricing\r\n window.location.assign(\"https://brickflow.com/pricing\");\r\n } else if (this.$routeParams.isBroker == \"borrower\") {\r\n this.$location.path(\"/borrowerinitialregistration\");\r\n } else if (\r\n this.$location.path().startsWith(\"/borrowerinitialregistration\")\r\n ) {\r\n if (this.$routeParams[\"Type\"] == \"bridging\") {\r\n this.$location.path(\"/e/bridgingcriteria\");\r\n } else {\r\n this.$location.path(\"/e/devfinancecriteria\");\r\n }\r\n } else {\r\n //TODO Change for New pricing\r\n window.location.assign(\"https://brickflow.com/pricing\");\r\n }\r\n\r\n this.getNumberOfLenders();\r\n\r\n //var orgCode;\r\n\r\n if (window.self == window.top) {\r\n this.orgCode = this.$cookies.get(\"org_code\");\r\n } else {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n }\r\n\r\n if (this.orgCode) {\r\n this.initialRegisterEventLog(this.orgCode);\r\n\r\n this.organisationService\r\n .getOrganisationByOrgCode(this.orgCode)\r\n .then((organisation: OrganisationDTO) => {\r\n this.organisation = organisation;\r\n if (this.organisation && organisation.LogoURL) {\r\n this.orgLogo = organisation.LogoURL;\r\n }\r\n });\r\n } else {\r\n this.organisationService\r\n .getBrickflowBrokerOrg()\r\n .then((organisation: OrganisationDTO) => {\r\n this.organisation = organisation;\r\n });\r\n this.initialRegisterEventLog(\"\");\r\n }\r\n\r\n if (window.self == window.top) {\r\n if (sessionStorage.getItem(\"userDetails\")) {\r\n let data = sessionStorage.getItem(\"userDetails\");\r\n this.user = JSON.parse(data);\r\n }\r\n }\r\n\r\n var applicationName = this.getApplicationName();\r\n\r\n if (this.isBroker == true) {\r\n this.panelHeaderText =\r\n \"Welcome to \" + applicationName + \" for Brokers\";\r\n if (!this.user) {\r\n this.user = {\r\n Roles: [\"Broker\", \"Introducer\"],\r\n IsOrganisationAdmin: true,\r\n ApplicantDefinedRole: ApplicantRoleEnum.Introducer,\r\n ApplicantDefinedRoleIntroducer: IntroducerTypeEnum.Broker,\r\n } as ApplicationUserDTO;\r\n }\r\n }\r\n })\r\n .catch((error) => {\r\n console.error(\"Failed to get initialize data: \", error);\r\n });\r\n }\r\n\r\n async getUserRole(): Promise {\r\n if (window.self == window.top) {\r\n this.userRole = parseInt(sessionStorage.getItem(\"userRole\")) as UserRoleEnum;\r\n } else {\r\n this.organisationService.getData(\"userRole\").then((result) => {\r\n this.userRole = parseInt(result) as UserRoleEnum;\r\n });\r\n }\r\n }\r\n\r\n async setBrokerOrBorrower() {\r\n await this.getUserRole();\r\n this.isBroker = this.userRole === UserRoleEnum.Broker;\r\n this.isBorrower = this.userRole === UserRoleEnum.Client;\r\n }\r\n\r\n async initialRegisterEventLog(orgCode, organisationLinkId = null) {\r\n if (window.self == window.top) {\r\n if (sessionStorage.getItem(\"clientId\")) {\r\n this.eventLogService.logPageLoad(\r\n \"INITIALREGISTER\",\r\n orgCode,\r\n \"\",\r\n sessionStorage.getItem(\"userRole\"),\r\n organisationLinkId,\r\n this.$routeParams[\"Type\"] == \"bridging\"\r\n ? ProductTypeEnum.Bridging\r\n : ProductTypeEnum.Development,\r\n undefined,\r\n undefined,\r\n sessionStorage.getItem(\"clientId\"),\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n \"INITIALREGISTER\",\r\n orgCode,\r\n \"\",\r\n sessionStorage.getItem(\"userRole\"),\r\n organisationLinkId,\r\n this.$routeParams[\"Type\"] == \"bridging\"\r\n ? ProductTypeEnum.Bridging\r\n : ProductTypeEnum.Development,\r\n );\r\n }\r\n } else {\r\n var userRole;\r\n userRole = await this.organisationService.getData(\"userRole\");\r\n var clientId: string = null;\r\n clientId = await this.organisationService.getData(\"clientId\");\r\n if (clientId) {\r\n this.eventLogService.logPageLoad(\r\n \"INITIALREGISTER\",\r\n orgCode,\r\n \"\",\r\n sessionStorage.getItem(\"userRole\"),\r\n organisationLinkId,\r\n this.$routeParams[\"Type\"] == \"bridging\"\r\n ? ProductTypeEnum.Bridging\r\n : ProductTypeEnum.Development,\r\n undefined,\r\n undefined,\r\n clientId,\r\n );\r\n } else {\r\n this.eventLogService.logPageLoad(\r\n \"INITIALREGISTER\",\r\n orgCode,\r\n \"\",\r\n sessionStorage.getItem(\"userRole\"),\r\n organisationLinkId,\r\n this.$routeParams[\"Type\"] == \"bridging\"\r\n ? ProductTypeEnum.Bridging\r\n : ProductTypeEnum.Development,\r\n );\r\n }\r\n }\r\n }\r\n\r\n saveUserdetails() {\r\n this.dataLoading = true;\r\n let emailExists;\r\n\r\n this.userService\r\n .checkEmailExists(this.user.Email)\r\n .then((result) => {\r\n emailExists = result;\r\n return this.organisationService.getData(\"userRole\");\r\n })\r\n .then((role) => {\r\n if (window.self === window.top) {\r\n this.userRole = parseInt(sessionStorage.getItem(\"userRole\")) as UserRoleEnum;\r\n } else {\r\n this.userRole = parseInt(role) as UserRoleEnum;\r\n }\r\n return this.organisationService.getData(\"clientId\");\r\n })\r\n .then((id) => {\r\n if (window.self === window.top) {\r\n this.clientId = sessionStorage.getItem(\"clientId\");\r\n } else {\r\n this.clientId = id;\r\n }\r\n if (emailExists == false) {\r\n this.processUserDetails(this.userRole, this.clientId);\r\n } else {\r\n this.error = \"Email address is already in use, please sign in.\";\r\n }\r\n })\r\n .catch((error) => {\r\n console.error(\"An error occurred in saveUserdetails:\", error);\r\n this.error =\r\n \"An error occurred while processing your request. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n processUserDetails(userRole, clientId) {\r\n this.error = \"\";\r\n if (this.isBroker) {\r\n this.user.Roles = [\"Broker\", \"Introducer\"];\r\n this.user.IsOrganisationAdmin = true;\r\n (this.user.ApplicantDefinedRole = ApplicantRoleEnum.Introducer),\r\n (this.user.ApplicantDefinedRoleIntroducer = IntroducerTypeEnum.Broker);\r\n } else {\r\n this.user.Roles = [\"Client\"];\r\n }\r\n if (window.self == window.top) {\r\n sessionStorage.setItem(\"userDetails\", JSON.stringify(this.user));\r\n sessionStorage.setItem(\"projectname\", this.projectName);\r\n this.userService.sendEventToHubspot(\r\n this.user,\r\n \"PREREGISTER\",\r\n false,\r\n this.orgCode,\r\n parseInt(sessionStorage.getItem(\"userRole\")) as UserRoleEnum,\r\n this.organisationLink && this.organisationLink.IsEnabled\r\n ? this.organisationLink.Id\r\n : 0,\r\n this.$routeParams[\"Type\"] == \"bridging\"\r\n ? ProductTypeEnum.Bridging\r\n : ProductTypeEnum.Development,\r\n undefined,\r\n undefined,\r\n this.clientId,\r\n );\r\n } else {\r\n this.organisationService.sendDataToParent(\r\n \"userDetails\",\r\n JSON.stringify(this.user),\r\n );\r\n this.organisationService.sendDataToParent(\r\n \"projectname\",\r\n this.projectName,\r\n );\r\n this.userService.sendEventToHubspot(\r\n this.user,\r\n \"PREREGISTER\",\r\n false,\r\n this.orgCode,\r\n this.userRole,\r\n this.organisationLink && this.organisationLink.IsEnabled\r\n ? this.organisationLink.Id\r\n : 0,\r\n this.$routeParams[\"Type\"] == \"bridging\"\r\n ? ProductTypeEnum.Bridging\r\n : ProductTypeEnum.Development,\r\n undefined,\r\n undefined,\r\n this.clientId,\r\n );\r\n }\r\n\r\n if (this.isBroker) {\r\n this.organisationService\r\n .brokerSignUpJourneyG0Email(this.user.Email, this.user.FullName)\r\n .then((response) => {});\r\n }\r\n\r\n if (this.isBroker) {\r\n this.$location.path(\"/promo/true\");\r\n } else {\r\n (this.$rootScope as any).loanCriteria = null;\r\n if (this.selectedType == 1) {\r\n this.$location.path(\"/devfinancecriteria\");\r\n } else if (this.selectedType == 0) {\r\n this.saveUserDataToClientTable().then(() => {\r\n this.$location.path(\"/newsearchselection/all\");\r\n });\r\n } else if (this.selectedType == 2) {\r\n this.saveUserDataToClientTable().then(() => {\r\n this.$location.path(\"/bridgingcriteria\");\r\n });\r\n }\r\n }\r\n }\r\n\r\n back() {\r\n this.$location.path(\"/landingV3\");\r\n }\r\n\r\n isiframe() {\r\n if (window.self == window.top) return false;\r\n return true;\r\n }\r\n\r\n getApplicationName() {\r\n if (\r\n window.self == window.top &&\r\n sessionStorage.getItem(\"applicationName\") != null\r\n ) {\r\n return sessionStorage.getItem(\"applicationName\");\r\n } else {\r\n return \"Brickflow\";\r\n }\r\n }\r\n\r\n getNumberOfLenders() {\r\n var productType = ProductFamilyEnum.None;\r\n\r\n if (this.selectedType == this.RoleEnum.BridgingFinance) {\r\n productType = ProductFamilyEnum.Bridging;\r\n } else if (this.selectedType == this.RoleEnum.DevelopmentFinance) {\r\n productType = ProductFamilyEnum.Development;\r\n }\r\n\r\n if (productType == ProductFamilyEnum.None) {\r\n this.lenderService\r\n .getTotalLenders(ProductFamilyEnum.None)\r\n .then((response: number) => {\r\n this.totalLenders = Math.floor(response);\r\n });\r\n } else {\r\n this.lenderService\r\n .getTotalLenders(productType)\r\n .then((response: number) => {\r\n this.totalLenders = Math.floor(response);\r\n });\r\n }\r\n }\r\n\r\n genUUID() {\r\n let S4 = () =>\r\n Math.floor((1 + Math.random()) * 0x10000)\r\n .toString(16)\r\n .substring(1);\r\n let guid = `${S4()}${S4()}-${S4()}-${S4()}-${S4()}-${S4()}${S4()}${S4()}`;\r\n return guid.toLowerCase();\r\n }\r\n\r\n saveUserDataToClientTable() {\r\n return new Promise(async (resolve, reject) => {\r\n let userFullName = this.user.FullName;\r\n let spaceIndex = userFullName.indexOf(\" \");\r\n\r\n let firstName = \"\";\r\n let lastName = \"\";\r\n\r\n // if not space has been added to the name then put the whole name in the first name field\r\n if (spaceIndex == -1) {\r\n firstName = userFullName;\r\n } else {\r\n firstName = userFullName.substring(0, userFullName.indexOf(\" \"));\r\n lastName = userFullName.substring(userFullName.indexOf(\" \") + 1);\r\n }\r\n\r\n var clientDto = {\r\n FirstName: firstName,\r\n LastName: lastName,\r\n PhoneNumber: this.user.PhoneNumber,\r\n Email: this.user.Email,\r\n BrokerOrganisationId: this.organisation.Id,\r\n PostalAddress: {\r\n AddressLine1: \"\",\r\n AddressLine2: \"\",\r\n AddressLine3: \"\",\r\n AddressLine4: \"\",\r\n PostCode: \"\",\r\n } as PostalAddress,\r\n } as ClientDTO;\r\n\r\n //if (localStorage.getItem('clientId')) {\r\n // clientDto.Id = Number(localStorage.getItem('clientId'));\r\n //}\r\n\r\n try {\r\n this.clientService.addUpdatereturnonlyid(clientDto).then((response) => {\r\n if (window.self == window.top) {\r\n sessionStorage.setItem(\"clientId\", response.toString());\r\n } else {\r\n this.organisationService.sendDataToParent(\r\n \"clientId\",\r\n response.toString(),\r\n );\r\n }\r\n });\r\n resolve();\r\n } catch (error) {\r\n console.error(\"An error occurred:\", error);\r\n Promise.reject(error);\r\n }\r\n });\r\n }\r\n\r\n gotoSignInPage() {\r\n this.$location.path(\"/login\");\r\n }\r\n}\r\n","import { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class IntroducerController {\r\n firstTime: boolean = false;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"DevelopmentInputService\",\r\n \"UserService\",\r\n \"CaseService\",\r\n \"RoleService\",\r\n \"AuthService\",\r\n ];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private $DevelopmentInputservice: DevelopmentInputService,\r\n private $user: UserService,\r\n private $CaseService: CaseService,\r\n private roleService: RoleService,\r\n private authService: AuthService,\r\n ) {\r\n if (this.$routeParams.status === \"new\") {\r\n this.firstTime = true;\r\n }\r\n }\r\n\r\n continueToLogin() {\r\n (this.$rootScope as any) = null;\r\n this.go(\"/login\");\r\n }\r\n\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n}\r\n","import { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\n\r\nexport class LandingController {\r\n caseId: number;\r\n case: CaseDTO;\r\n disablepayment: boolean = false;\r\n message: string = \"\";\r\n modal: boolean = false;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$scope\",\r\n \"$location\",\r\n \"PaymentService\",\r\n \"CaseService\",\r\n \"$cookies\",\r\n \"RoleService\",\r\n ];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $scope: ng.IScope,\r\n private $location: ng.ILocationService,\r\n private $paymentService: PaymentService,\r\n private caseService: CaseService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private roleService: RoleService,\r\n ) {\r\n //Check if the user is logged in\r\n if (\r\n this.$cookies.get(\"access_token\") != null ||\r\n this.$cookies.get(\"access_token\") != undefined\r\n ) {\r\n if (this.roleService.isAdminUser) {\r\n this.$location.path(\"/dashboard\");\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n }\r\n }\r\n\r\n goToLoginPage() {\r\n this.$location.path(\"/login\");\r\n }\r\n\r\n goToWelcomePage() {\r\n this.$location.path(\"/landingV3\");\r\n }\r\n\r\n goToAgentLandingPage() {\r\n this.$location.path(\"/agentlanding\");\r\n }\r\n}\r\n","import { UserRoleEnum } from \"@js/models/enum/UserRoleEnum.cs.d\";\r\n\r\nexport class LandingV3Controller {\r\n applicationName: string = \"Brickflow\";\r\n isWhiteLabelled: boolean = false;\r\n\r\n static $inject = [\"$location\", \"$cookies\", \"$routeParams\"];\r\n\r\n constructor(\r\n private $location: ng.ILocationService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n ) {\r\n // Clear out any pre-existing data\r\n //localStorage.removeItem('userRole'); //JS userRole will be set on navigation by no removing we fix BF-1866\r\n sessionStorage.removeItem(\"userDetails\");\r\n sessionStorage.removeItem(\"projectname\");\r\n sessionStorage.removeItem(\"selectedPackage\");\r\n sessionStorage.removeItem(\"addAddon\");\r\n sessionStorage.removeItem(\"productType\");\r\n sessionStorage.removeItem(\"clientId\");\r\n\r\n // Show a header if it is hidden\r\n document.getElementById(\"header\").style.display = \"flex\";\r\n //Show 'Sign/Register' button if it is hidden.\r\n document.getElementById(\"signIn\").style.display = \"flex\";\r\n\r\n if (this.$routeParams.introducercode) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"introducer_code\", this.$routeParams.introducercode, {\r\n expires: expiryDate,\r\n });\r\n }\r\n }\r\n\r\n proceedAsDeveloper() {\r\n sessionStorage.setItem(\"userRole\", UserRoleEnum.Client.toString());\r\n\r\n this.nextStep();\r\n\r\n this.$location.path(\"/allloans\");\r\n }\r\n\r\n proceedAsBroker() {\r\n //TODO Change for New pricing\r\n window.location.assign(\"https://brickflow.com/pricing\");\r\n /*sessionStorage.setItem('userRole', 'broker');\r\n\r\n this.nextStep();\r\n \r\n this.$location.path('/initialregister');*/\r\n }\r\n\r\n nextStep() {\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.$location.path(\"/promo\");\r\n }\r\n //else {\r\n // this.$location.path('/initialregister');\r\n //}\r\n }\r\n\r\n getApplicationName() {\r\n if (sessionStorage.getItem(\"applicationName\") != null) {\r\n return sessionStorage.getItem(\"applicationName\");\r\n } else {\r\n return \"Brickflow\";\r\n }\r\n }\r\n\r\n getLogo() {\r\n if (sessionStorage.getItem('companyLogoUrl') != null) {\r\n this.isWhiteLabelled = true;\r\n return sessionStorage.getItem('companyLogoUrl');\r\n } else {\r\n this.isWhiteLabelled = false;\r\n return '../../img/BrickFlow_Logo_RGB_Blue_Icon.svg';\r\n }\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { LicenseMasterStatusEnum } from \"@js/models/enum/LicenseMasterStatusEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\n\r\nexport class LeadGenPromoController {\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"AuthService\",\r\n ];\r\n\r\n licenseCount: number = 0;\r\n showAddLaterButton: boolean = true;\r\n currentUser: ApplicationUserDTO;\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private authService: AuthService,\r\n ) {\r\n if (this.$routeParams.licensecount) {\r\n this.licenseCount = this.$routeParams.licensecount;\r\n }\r\n\r\n this.authService.getUpdatedProfile().then((prof) => {\r\n this.currentUser = prof;\r\n });\r\n }\r\n\r\n addLaterClicked() {\r\n if (\r\n this.licenseCount > 1 &&\r\n (this.currentUser.SubscriptionStatus == LicenseMasterStatusEnum.PaidUp ||\r\n this.currentUser.SubscriptionStatus ==\r\n LicenseMasterStatusEnum.PaymentProcessing)\r\n ) {\r\n this.$location.path(\"/assignlicenses\");\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n }\r\n\r\n bookCall() {\r\n window.open(\r\n \"https://brickflow.com/brokers/brickflow-enterprise/book-a-demo\",\r\n );\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { LenderDTO } from \"@js/DTO/LenderDTO.cs.d\";\r\nimport { ImportProductResponse } from \"@js/DTO/Messages/ImportProductMessage.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { ProductDTO } from \"@js/DTO/ProductDTO.cs.d\";\r\nimport { LenderProductTypeEnum } from \"@js/models/enum/LenderProductTypeEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class LenderController {\r\n canSeeMultipleLenders: boolean = false;\r\n selectedSection: string;\r\n\r\n objects: LenderDTO[];\r\n selectedObject: LenderDTO;\r\n tempSelectedObject: LenderDTO;\r\n userSearchResults: ApplicationUserDTO[];\r\n //user: ApplicationUserDTO;\r\n userName: string;\r\n userSelected: string;\r\n fetchingResults: boolean;\r\n showFilter: boolean;\r\n editLogo: boolean = false;\r\n\r\n selectedObjectProduct: ProductDTO;\r\n\r\n logoURL: string = \"\";\r\n\r\n // Upload Logos\r\n\r\n fileUpload: FileAttachmentDTO[];\r\n fileUploadPlaning: FileAttachmentDTO[];\r\n fileUploadTeam: FileAttachmentDTO[];\r\n fileUploadProperties: FileAttachmentDTO[];\r\n uploadingFiles: FileUploadProgressDTO[];\r\n renamingFile: FileAttachmentDTO;\r\n\r\n newLenderPopup: boolean = false;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n lenderForm: ng.IFormController;\r\n\r\n file: Blob;\r\n\r\n step: number;\r\n\r\n editLenderName: boolean = false;\r\n updateRating: boolean = false;\r\n updatePreferredBrokers: boolean = false;\r\n\r\n timestamp: Date;\r\n\r\n multiPartForm1: ng.IFormController;\r\n multiPartForm2: ng.IFormController;\r\n multiPartForm3: ng.IFormController;\r\n multiPartForm4: ng.IFormController;\r\n multiPartForm5: ng.IFormController;\r\n multiPartForm6: ng.IFormController;\r\n multiPartForm7: ng.IFormController;\r\n\r\n totalRate: number;\r\n\r\n //array describing form sections\r\n formSectionNames = [\r\n {\r\n label: \"Lender Details\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Overview\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Location\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Development Specs\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Industry\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Liabilities\",\r\n visible: true,\r\n },\r\n {\r\n label: \"Fees\",\r\n visible: true,\r\n },\r\n ];\r\n\r\n showLenderUpload: boolean = false;\r\n addLenders: boolean = true;\r\n updateLenders: boolean = true;\r\n disableProducts: boolean = false;\r\n dataLoading: boolean = false;\r\n importFile: any = false;\r\n\r\n assignedLenderUsers: ApplicationUserDTO[];\r\n selectLenderUserId: string = null;\r\n selectedLenderUser: ApplicationUserDTO;\r\n showEditLenderUserModal: boolean = false;\r\n isEditLenderUser: boolean = false;\r\n lenderUserProductType: {}[] = [];\r\n isSavingLenderUser: boolean = false;\r\n\r\n confirmChangingLenderAdmin: boolean = false;\r\n confirmLenderAdminDeletion: boolean = false;\r\n displayMessage: string;\r\n deleteLenderUserClicked: boolean = false;\r\n lendersavemessage: string;\r\n error: string = \"\";\r\n filterType: string = \"\";\r\n\r\n showSimulatedResults = false;\r\n simulatedResponse: ImportProductResponse;\r\n productTypeOptions = [];\r\n productFamilyOptions = [];\r\n filteredProductTypeOptions = [];\r\n refurbLevelOptions = [];\r\n EPCRatingOptions = [];\r\n acceptableEWS1GradeTypeOptions = [];\r\n locationOptions = [];\r\n tradingEntityOptions = [];\r\n valuationMethodOptions = [];\r\n\r\n duplicateProductModal: boolean = false;\r\n productForDuplication: ProductDTO;\r\n duplicateProductIndex: number;\r\n productRef: string = \"\";\r\n\r\n organisations: OrganisationDTO[] = [];\r\n nonConnectOrganisations: OrganisationDTO[] = [];\r\n selectedBrokers: OrganisationDTO[] = [];\r\n isValidSelection: boolean;\r\n preferredPackagersText: string;\r\n modalTextChanged: boolean = false;\r\n\r\n portalLinkSettingChanged: boolean = false;\r\n currentPortalLinkSetting: boolean = false;\r\n\r\n showEditProductNotesAndSnapshot: boolean = false;\r\n editedLenderProductFamily: ProductFamilyEnum = null;\r\n\r\n minLastVerifiedDate: Date = new Date(\"Jan 01 1900\");\r\n maxLastVerifiedDate: Date = null;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$rootScope\",\r\n \"LenderService\",\r\n \"ProductService\",\r\n \"Upload\",\r\n \"$location\",\r\n \"RoleService\",\r\n \"UserService\",\r\n \"FileAttachmentService\",\r\n \"SelectListService\",\r\n \"OrganisationService\",\r\n \"$sce\",\r\n ];\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $lenderservice: LenderService,\r\n private $productservice: ProductService,\r\n private $uploadservice: any,\r\n private $location: ng.ILocationService,\r\n private $roleservice: RoleService,\r\n private $user: UserService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private selectListService: SelectListService,\r\n private organisationService: OrganisationService,\r\n private $sce: ng.ISCEService,\r\n ) {\r\n if (this.$roleservice.isBrokerOrABove()) {\r\n this.canSeeMultipleLenders = true;\r\n }\r\n\r\n this.organisationService.fetchAll().then((response) => {\r\n this.organisations = response;\r\n this.organisations.sort(function (a, b) {\r\n var textA = a.Name.toUpperCase();\r\n var textB = b.Name.toUpperCase();\r\n return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;\r\n });\r\n this.nonConnectOrganisations = this.organisations.filter(o => !o.IsConnectMember)\r\n });\r\n\r\n this.updateObjects();\r\n //init\r\n this.step = 1;\r\n this.updatetimestamp();\r\n this.fetchAllUsers();\r\n this.userName = \"\";\r\n this.showFilter = false;\r\n\r\n this.productTypeOptions = this.selectListService.GetProductTypeOptions();\r\n this.productFamilyOptions =\r\n this.selectListService.GetProductFamilyOptions();\r\n this.refurbLevelOptions =\r\n this.selectListService.GetRefurbishmentLevelOptions(true);\r\n this.EPCRatingOptions = this.selectListService.GetEPCRating();\r\n this.acceptableEWS1GradeTypeOptions =\r\n this.selectListService.GetEWS1GradeType();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n this.tradingEntityOptions =\r\n this.selectListService.GetBorrowingEntityTypeOptions();\r\n\r\n this.valuationMethodOptions = this.selectListService.GetValuationMethodOptions();\r\n }\r\n\r\n onFileSelect(files) {\r\n if (files.length > 0) {\r\n this.fileAttachmentService\r\n .uploadFileAndReturnURI(files)\r\n .then((result) => {\r\n this.selectedObject.LogoURL = result.FileLocation;\r\n // this.$lenderservice.addUpdate(this.selectedObject);\r\n this.getLogoURL(this.selectedObject.LogoURL);\r\n this.editLogo = true;\r\n });\r\n }\r\n }\r\n\r\n getLogoURL(url: string) {\r\n this.fileAttachmentService.getFileUri(url).then((result) => {\r\n this.logoURL = result;\r\n });\r\n }\r\n\r\n fetchAllUsers() {\r\n this.fetchingObject = true;\r\n this.$user\r\n .getLenderUsersUnassigned(\"\")\r\n .then((response) => {\r\n this.userSearchResults = response;\r\n })\r\n .finally(() => {\r\n this.fetchingObject = false;\r\n });\r\n }\r\n\r\n fetchAssignedLenderUsers() {\r\n this.fetchingObject = true;\r\n this.$user\r\n .getUsersByLenderId(this.selectedObject.Id)\r\n .then((response) => {\r\n this.assignedLenderUsers = response;\r\n })\r\n .finally(() => {\r\n this.fetchingObject = false;\r\n });\r\n }\r\n\r\n changeUser() {\r\n this.showFilter = !this.showFilter;\r\n }\r\n\r\n userLookupById(userId: string): string {\r\n const found = this.userSearchResults.find((user) => user.Id === userId);\r\n\r\n if (found) {\r\n return (this.userName = found.UserName);\r\n } else {\r\n return (this.userName = \"\");\r\n }\r\n }\r\n\r\n updatetimestamp(): void {\r\n this.timestamp = new Date();\r\n }\r\n back(): void {\r\n if (this.step > 0) {\r\n this.step--;\r\n }\r\n }\r\n\r\n next(): void {\r\n if (this.step < 7) {\r\n this.step++;\r\n }\r\n }\r\n cancel(): void {\r\n this.$location.path(\"/lenders/\");\r\n }\r\n\r\n private preSelectedItem() {\r\n if (this.$routeParams.Id) {\r\n let selectedObject = this.objects.find((value, index) => {\r\n return value.Id === parseInt(this.$routeParams.objectId);\r\n });\r\n\r\n this.selectObject(selectedObject);\r\n }\r\n }\r\n\r\n updateIsEnabled(product: ProductDTO, isEnabled) {\r\n product.IsEnabled = isEnabled;\r\n this.$productservice.addUpdatereturnonlyid(product).then((result) => { });\r\n }\r\n\r\n selectObject(object: LenderDTO) {\r\n this.selectedBrokers = [];\r\n this.selectedObject = object;\r\n this.fetchAssignedLenderUsers();\r\n this.selectedSection = \"details\";\r\n this.editLenderName = false;\r\n this.userSelected = \"\";\r\n this.userLookupById(object.UserId);\r\n this.preferredPackagersText = this.selectedObject.PreferredPackagersText;\r\n\r\n if (this.selectedObject.LogoURL) {\r\n this.getLogoURL(this.selectedObject.LogoURL);\r\n } else {\r\n this.logoURL = \"\";\r\n }\r\n\r\n this.currentPortalLinkSetting = this.selectedObject.UsePortalUrl;\r\n\r\n this.getPreferredOrgs();\r\n }\r\n\r\n createObject() {\r\n //Add new lender\r\n this.selectedObject = {\r\n Products: [] as ProductDTO[],\r\n HasLiveMarketSearch: true,\r\n HasDevelopmentFinanceSearch: true,\r\n HasBridgingSearch: true,\r\n HasCommercialSearch: true,\r\n IsLenderReferralActive: true,\r\n } as LenderDTO;\r\n this.editLenderName = true;\r\n this.currentPortalLinkSetting = false;\r\n }\r\n\r\n userLookup(userSearchTerm: string) {\r\n if (userSearchTerm === \"\") {\r\n this.fetchAllUsers();\r\n } else {\r\n this.fetchingResults = true;\r\n this.$user\r\n .getLenderUsersUnassigned(userSearchTerm)\r\n .then((response) => {\r\n this.userSearchResults = response;\r\n })\r\n .finally(() => {\r\n this.fetchingResults = false;\r\n });\r\n }\r\n }\r\n\r\n updateLenderUser(id: string) {\r\n this.selectedObject.UserId = id;\r\n this.$lenderservice\r\n .addUpdate(this.selectedObject)\r\n .then((response) => { })\r\n .finally(() => {\r\n this.showFilter = false;\r\n delete this.userSelected;\r\n });\r\n }\r\n\r\n editLender(SelectedLender: LenderDTO) {\r\n this.editLenderName = true;\r\n this.editLogo = false;\r\n this.tempSelectedObject = { ...SelectedLender };\r\n }\r\n\r\n cancelLenderUpdate(SelectedLender: LenderDTO) {\r\n this.selectedObject = this.tempSelectedObject;\r\n this.getPreferredOrgs();\r\n this.getLogoURL(this.selectedObject.LogoURL);\r\n this.preferredPackagersText = this.selectedObject.PreferredPackagersText;\r\n this.editLenderName = false;\r\n this.error = \"\";\r\n }\r\n\r\n saveLender(newLender: boolean = false) {\r\n if (\r\n this.selectedObject.UsePortalUrl &&\r\n (this.selectedObject.PortalUrl == null ||\r\n this.selectedObject.PortalUrl.length == 0)\r\n ) {\r\n this.editLenderName = true;\r\n this.error = \"If portal link is enabled, please include a portal link.\";\r\n return;\r\n }\r\n\r\n if (this.portalLinkSettingChanged) {\r\n if (!this.currentPortalLinkSetting && this.selectedObject.UsePortalUrl) {\r\n this.selectedObject.PortalUrlActiveDateTime = new Date();\r\n }\r\n if (this.currentPortalLinkSetting && !this.selectedObject.UsePortalUrl) {\r\n this.selectedObject.PortalUrlActiveDateTime = null;\r\n }\r\n }\r\n const existingSelection =\r\n this.selectedObject && this.selectedObject.Id ? true : false;\r\n const duplicateLender = this.objects.find(\r\n (x) => x.Name == this.selectedObject.Name,\r\n );\r\n if (\r\n (!duplicateLender || newLender == false) &&\r\n this.fetchingObjects == false\r\n ) {\r\n this.fetchingObjects = true;\r\n this.selectedObject.PreferredPackagersText = this.preferredPackagersText;\r\n this.$lenderservice\r\n .addUpdatereturnonlyid(this.selectedObject)\r\n .then((id) => {\r\n this.selectedObject.Id = id;\r\n //this.selectedObject.UserId = this.user.Id;\r\n if (!existingSelection) {\r\n this.objects.push(this.selectedObject);\r\n }\r\n\r\n const orgIds = this.selectedBrokers.map((broker) => broker.Id);\r\n\r\n this.currentPortalLinkSetting = this.selectedObject.UsePortalUrl;\r\n\r\n return this.$lenderservice.updatePreferredOrgs(\r\n this.selectedObject.Id,\r\n orgIds,\r\n );\r\n })\r\n .finally(() => {\r\n this.editLenderName = false;\r\n this.fetchingObjects = false;\r\n this.updateRating = false;\r\n this.updatePreferredBrokers = false;\r\n this.error = \"\";\r\n this.editedLenderProductFamily = null;\r\n this.showEditProductNotesAndSnapshot = false;\r\n this.lenderForm.$setPristine();\r\n });\r\n } else {\r\n this.editLenderName = false;\r\n this.error = \"\";\r\n this.selectedObject = duplicateLender;\r\n }\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n\r\n // Fetch all objects.\r\n this.$lenderservice\r\n .fetchAll()\r\n .then((response) => {\r\n this.objects = response;\r\n if (this.filterType != \"\") {\r\n //TODO: need to fix this to use product type instead\r\n this.objects = this.objects.filter((lender) => {\r\n return lender.Products.some((product) => {\r\n return product.LI_LoanFamily == Number(this.filterType);\r\n });\r\n });\r\n }\r\n\r\n if (!this.canSeeMultipleLenders && this.objects.length > 0) {\r\n //need to select first item as no ability to select\r\n this.selectObject(this.objects[0]);\r\n }\r\n this.preSelectedItem();\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n this.editLenderName = false;\r\n });\r\n }\r\n\r\n delete() {\r\n if (this.fetchingObjects !== true) {\r\n this.fetchingObjects = true;\r\n this.$lenderservice\r\n .markasdeleted(this.selectedObject.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.lenderForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n });\r\n }\r\n }\r\n\r\n uploadProductFile(file, isSimulated) {\r\n this.dataLoading = true;\r\n let url =\r\n \"/api/lender/importproducts?addLender=\" +\r\n this.addLenders +\r\n \"&updateLender=\" +\r\n this.updateLenders +\r\n \"&disableProducts=\" +\r\n this.disableProducts +\r\n \"&isSimulated=\" +\r\n isSimulated;\r\n this.$uploadservice\r\n .upload({\r\n url: url,\r\n data: { file: file },\r\n })\r\n .then(\r\n (response) => {\r\n if (isSimulated) {\r\n this.simulatedResponse = response.data;\r\n this.showSimulatedResults = true;\r\n } else {\r\n this.updateObjects();\r\n this.showLenderUpload = false;\r\n this.showSimulatedResults = false;\r\n }\r\n this.dataLoading = false;\r\n },\r\n (response) => {\r\n // console.log('Error status: ' + resp.status);\r\n },\r\n (event) => {\r\n // $scope.linkedInUploadProgress = 100.0 * parseFloat(evt.loaded) / parseFloat(evt.total);\r\n // console.log('progress: ' + $scope.linkedInUploadProgress + '% ' + evt.config.data.file.name);\r\n },\r\n );\r\n }\r\n\r\n formChanged(): void {\r\n (this.$rootScope as any).formSaved = false;\r\n }\r\n\r\n removeProduct(product: ProductDTO) {\r\n if (product.Id > 0) {\r\n this.$productservice.markasdeleted(product.Id).then((response) => {\r\n if (response) {\r\n this.selectedObject.Products.splice(\r\n this.selectedObject.Products.indexOf(product),\r\n 1,\r\n );\r\n this.selectObject(this.selectedObject);\r\n this.lenderForm.$setPristine();\r\n }\r\n });\r\n } else {\r\n //never saved so just remove\r\n this.selectedObject.Products.splice(\r\n this.selectedObject.Products.indexOf(product),\r\n 1,\r\n );\r\n this.selectedObjectProduct = null;\r\n this.selectObject(this.selectedObject);\r\n this.lenderForm.$setPristine();\r\n }\r\n }\r\n\r\n createProduct() {\r\n this.step = 1;\r\n this.selectedObjectProduct = {\r\n LenderId: this.selectedObject.Id,\r\n LI_LoanProduct: ProductTypeEnum.Development,\r\n } as ProductDTO;\r\n }\r\n\r\n selectProduct(productId: number) {\r\n this.step = 1;\r\n this.$productservice.fetch(productId).then((response) => {\r\n this.selectedObjectProduct = response;\r\n this.maxLastVerifiedDate = response.LastVerifiedDate;\r\n //this.totalRate = this.selectedObjectProduct.LI_Dev_TotRate * 100;\r\n // this.selectedLocations = this.selectedProduct.Location.split(\", \");\r\n });\r\n }\r\n\r\n saveProduct(product: ProductDTO) {\r\n this.$productservice\r\n .isProductRefUnique(product.ProductRef, product.Id)\r\n .then((result) => {\r\n if (!result) {\r\n this.error = \"Product Reference is not unique\";\r\n return;\r\n }\r\n this.fetchingObject = true;\r\n // product.Location = this.selectedLocations.join(\",\");\r\n if (this.selectedObject.Id) {\r\n // product.LI_Dev_TotRate = this.totalRate / 100;\r\n this.$productservice\r\n .addUpdatereturnonlyid(product)\r\n .then((response) => {\r\n product.Id = response;\r\n this.fetchingObject = false;\r\n\r\n // Find the product in the selectedObject.Products list\r\n let existingProductIndex = this.selectedObject.Products.findIndex(\r\n (p) => p.Id === product.Id,\r\n );\r\n\r\n if (existingProductIndex !== -1) {\r\n // Update the existing product if found\r\n this.selectedObject.Products[existingProductIndex] = product;\r\n } else {\r\n // Otherwise, add the new product to the list\r\n this.selectedObject.Products.push(product);\r\n }\r\n\r\n this.selectedObjectProduct = undefined;\r\n })\r\n .catch((response) => {\r\n this.fetchingObject = false;\r\n });\r\n if (!this.selectedObjectProduct.Id) {\r\n this.selectedObject.Products.push(this.selectedObjectProduct);\r\n }\r\n } else {\r\n this.fetchingObject = false;\r\n this.lenderForm.$setDirty();\r\n }\r\n });\r\n }\r\n\r\n duplicateProduct(\r\n product: ProductDTO,\r\n index: number,\r\n productRef: string = \"\",\r\n ) {\r\n let newProduct = {} as ProductDTO;\r\n (Object as any).assign(newProduct, product);\r\n\r\n delete newProduct.Id;\r\n delete newProduct.LastUpdatedDateTime;\r\n delete newProduct.CreatedDateTime;\r\n delete newProduct.IsEnabled;\r\n\r\n this.$productservice.isProductRefUnique(productRef).then((result) => {\r\n //If producRef is not unique (or error) then do not duplicate product\r\n if (!result) {\r\n this.error = \"Product Reference is not unique\";\r\n return;\r\n }\r\n\r\n newProduct.ProductRef = productRef;\r\n\r\n this.selectedObject.Products.splice(index, 0, newProduct);\r\n\r\n this.$productservice.addUpdatereturnonlyid(newProduct).then((result) => {\r\n this.selectedObject.Products[index].Id = result;\r\n });\r\n\r\n this.error = \"\";\r\n this.duplicateProductModal = false;\r\n });\r\n }\r\n\r\n sum(a: number, b: number): number {\r\n return a + b;\r\n }\r\n\r\n carriageReturnCheck(event) {\r\n if (event.key === 'Enter') {\r\n this.selectedObjectProduct.AdditionalProductInfo += '\\n';\r\n }\r\n }\r\n\r\n lenderKeyDown(event, field: string) {\r\n if (event.key === \"Enter\") {\r\n let position = event.target.selectionStart;\r\n if (this.selectedObject[field]) {\r\n this.selectedObject[field] = [this.selectedObject[field].slice(0, position), \"\\n\", this.selectedObject[field].slice(position)].join(\"\");\r\n\r\n setTimeout(() => {\r\n event.target.setSelectionRange(position + 1, position + 1);\r\n }, 0);\r\n } else {\r\n this.preferredPackagersText = \"\\n\";\r\n }\r\n }\r\n }\r\n\r\n updateCustomerServiceRating(star) {\r\n if (this.selectedObject.RatingCustomerService == 1 && star == 1) {\r\n this.selectedObject.RatingCustomerService = 0;\r\n this.updateRating = true;\r\n } else {\r\n this.selectedObject.RatingCustomerService = star;\r\n this.updateRating = true;\r\n }\r\n }\r\n\r\n updateSpeedRating(star) {\r\n if (this.selectedObject.RatingSpeed == 1 && star == 1) {\r\n this.selectedObject.RatingSpeed = 0;\r\n this.updateRating = true;\r\n } else {\r\n this.selectedObject.RatingSpeed = star;\r\n this.updateRating = true;\r\n }\r\n }\r\n\r\n updateFlexibilityRating(star) {\r\n if (this.selectedObject.RatingFlexibility == 1 && star == 1) {\r\n this.selectedObject.RatingFlexibility = 0;\r\n this.updateRating = true;\r\n } else {\r\n this.selectedObject.RatingFlexibility = star;\r\n this.updateRating = true;\r\n }\r\n }\r\n\r\n updateUserRating(star) {\r\n if (this.selectedObject.RatingUserRating == 1 && star == 1) {\r\n this.selectedObject.RatingUserRating = 0;\r\n this.updateRating = true;\r\n } else {\r\n this.selectedObject.RatingUserRating = star;\r\n this.updateRating = true;\r\n }\r\n }\r\n\r\n addClass(star: number, id: string) {\r\n let elementId = \"\";\r\n for (let i = 1; i <= star; i++) {\r\n elementId = id + i;\r\n document.getElementById(elementId).classList.add(\"selected\");\r\n }\r\n }\r\n\r\n removeClass(star: number, id: string, rating) {\r\n let elementId = \"\";\r\n if (rating == undefined) {\r\n rating = 0;\r\n }\r\n for (let i = star; i > rating; i--) {\r\n elementId = id + i;\r\n document.getElementById(elementId).classList.remove(\"selected\");\r\n }\r\n }\r\n\r\n removeLenderLogo() {\r\n this.selectedObject.LogoURL = null;\r\n this.logoURL = null;\r\n this.lenderForm.$setDirty();\r\n }\r\n\r\n //calculateTotalRate() {\r\n // this.totalRate = parseFloat(((this.selectedObjectProduct.LI_Margin * 100) + (this.selectedObjectProduct.LI_CoF * 100)).toFixed(2));\r\n //}\r\n\r\n totalRateValue() {\r\n return parseFloat(\r\n (\r\n this.selectedObjectProduct.LI_Margin * 100 +\r\n this.selectedObjectProduct.LI_CoF * 100\r\n ).toFixed(2),\r\n );\r\n }\r\n\r\n selectLenderUser(lenderUser: ApplicationUserDTO) {\r\n if (lenderUser) {\r\n this.selectedLenderUser = { ...lenderUser };\r\n this.initLenderUserProductType();\r\n\r\n this.isEditLenderUser = true;\r\n } else {\r\n this.selectedLenderUser = {} as ApplicationUserDTO;\r\n this.isEditLenderUser = false;\r\n }\r\n\r\n this.showEditLenderUserModal = true;\r\n }\r\n\r\n isLenderUserEmpty() {\r\n for (let key in this.selectedLenderUser) {\r\n if (this.selectedLenderUser.hasOwnProperty(key) && key !== \"$$hashKey\") {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n initLenderUserProductType() {\r\n if (!this.selectedLenderUser.LenderProductTypes) {\r\n this.selectedLenderUser.LenderProductTypes = 0;\r\n } else {\r\n for (let i = 1; i >= 0; i *= 2) {\r\n if (this.selectedLenderUser.LenderProductTypes >= i) {\r\n //number is in enum sum, add it to object\r\n if (this.selectedLenderUser.LenderProductTypes & i) {\r\n this.lenderUserProductType[i] = true;\r\n } else {\r\n this.lenderUserProductType[i] = false;\r\n }\r\n } else {\r\n return;\r\n }\r\n }\r\n }\r\n }\r\n\r\n updateLenderUserProductTypes(item: LenderProductTypeEnum) {\r\n this.selectedLenderUser.LenderProductTypes =\r\n this.selectedLenderUser.LenderProductTypes > 0\r\n ? this.selectedLenderUser.LenderProductTypes\r\n : 0;\r\n\r\n if (item == LenderProductTypeEnum.All) {\r\n if (this.lenderUserProductType[item] == false) {\r\n this.selectedLenderUser.LenderProductTypes -= item;\r\n } else {\r\n this.lenderUserProductType.forEach((value, index) => {\r\n this.lenderUserProductType[index] = false;\r\n });\r\n\r\n this.selectedLenderUser.LenderProductTypes = 0;\r\n\r\n this.lenderUserProductType[item] = true;\r\n this.selectedLenderUser.LenderProductTypes += item;\r\n }\r\n } else {\r\n //if we are setting item to false and item exists, remove it, else add it\r\n if (this.lenderUserProductType[item] === true) {\r\n this.selectedLenderUser.LenderProductTypes += item;\r\n } else if (this.selectedLenderUser.LenderProductTypes > 0) {\r\n this.selectedLenderUser.LenderProductTypes -= item;\r\n }\r\n }\r\n }\r\n\r\n isLenderUserProductTypeEmpty() {\r\n if (this.lenderUserProductType.length === 0) return true;\r\n\r\n for (let i = 0; i < this.lenderUserProductType.length; i++) {\r\n let value = this.lenderUserProductType[i];\r\n if (value !== undefined && value !== null && value !== false) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n saveLenderUser() {\r\n var validUser = true;\r\n this.isSavingLenderUser = true;\r\n this.selectedLenderUser.LenderId = this.selectedObject.Id;\r\n\r\n if (!this.selectedLenderUser.IsLenderAdmin) {\r\n let lenderAdmin = this.assignedLenderUsers.find(\r\n (l) => l.IsLenderAdmin && l.Id != this.selectedLenderUser.Id,\r\n );\r\n if (!lenderAdmin) {\r\n this.lendersavemessage = `Please ensure this lender has at least one admin user.`;\r\n this.isSavingLenderUser = false;\r\n validUser = false;\r\n }\r\n }\r\n\r\n if (validUser) {\r\n this.$user\r\n .saveLenderUser(this.selectedLenderUser, !this.isEditLenderUser)\r\n .then((response) => {\r\n if (response) {\r\n this.isSavingLenderUser = false;\r\n this.isEditLenderUser = false;\r\n this.lenderUserProductType = [];\r\n this.showEditLenderUserModal = false;\r\n } else {\r\n if (this.isEditLenderUser) {\r\n this.lendersavemessage = `There is problem updating ${this.selectedLenderUser.FullName} details, Please try later.`;\r\n } else {\r\n this.lendersavemessage = `There is problem adding ${this.selectedLenderUser.FullName}, Please try later.`;\r\n }\r\n }\r\n this.fetchAssignedLenderUsers();\r\n });\r\n }\r\n }\r\n\r\n cancelEditLenderUserModal() {\r\n this.selectedLenderUser = undefined;\r\n this.lenderUserProductType = [];\r\n this.showEditLenderUserModal = false;\r\n this.error = \"\";\r\n }\r\n\r\n onClickOfMakeAdimn(lenderUser: ApplicationUserDTO) {\r\n this.selectedLenderUser = lenderUser;\r\n this.displayMessage = `Are you sure you wish to make ${lenderUser.FullName} admin for this lender?`;\r\n this.confirmChangingLenderAdmin = true;\r\n }\r\n\r\n setLenderAsAdmin() {\r\n this.selectedLenderUser.IsLenderAdmin = true;\r\n this.$user.setLenderAsAdmin(this.selectedLenderUser.Id).then((response) => {\r\n if (response) {\r\n this.confirmChangingLenderAdmin = false;\r\n } else {\r\n this.lendersavemessage = `There is problem converting ${this.selectedLenderUser.FullName} to admin, Please try later`;\r\n }\r\n this.fetchAssignedLenderUsers();\r\n });\r\n }\r\n\r\n onClickOfDeleteLenderUser(lenderUser: ApplicationUserDTO) {\r\n this.selectedLenderUser = lenderUser;\r\n let lenderAdmin = this.assignedLenderUsers.find(\r\n (l) => l.IsLenderAdmin && l.Id != lenderUser.Id,\r\n );\r\n if (this.selectedLenderUser.IsLenderAdmin && !lenderAdmin) {\r\n this.displayMessage = `Please assign a new Admin User before deleting ${lenderUser.FullName}.`;\r\n } else {\r\n this.displayMessage = `Are you sure you wish to remove ${lenderUser.FullName}?`;\r\n this.deleteLenderUserClicked = true;\r\n }\r\n this.confirmLenderAdminDeletion = true;\r\n }\r\n\r\n deleteLenderUser() {\r\n if (this.deleteLenderUserClicked) {\r\n this.$user.removeLenderUser(this.selectedLenderUser.Id).then((response) => {\r\n this.fetchAssignedLenderUsers();\r\n this.confirmLenderAdminDeletion = false;\r\n this.deleteLenderUserClicked = false;\r\n })\r\n } else {\r\n this.confirmLenderAdminDeletion = false;\r\n }\r\n }\r\n\r\n closeLenderUserDeleteModal() {\r\n this.confirmChangingLenderAdmin = false;\r\n this.confirmLenderAdminDeletion = false;\r\n this.deleteLenderUserClicked = false;\r\n this.lendersavemessage = \"\";\r\n }\r\n\r\n onIsLenderAdminChange() {\r\n if (!this.selectedLenderUser.IsLenderAdmin && this.isEditLenderUser) {\r\n let selectedUserFrom = this.assignedLenderUsers.find(\r\n (l) => l.Id == this.selectedLenderUser.Id,\r\n );\r\n let lenderAdmin = this.assignedLenderUsers.find(\r\n (l) => l.IsLenderAdmin && l.Id != this.selectedLenderUser.Id,\r\n );\r\n if (selectedUserFrom?.IsLenderAdmin && !lenderAdmin) {\r\n this.error = `Please assign a new Admin User.`;\r\n }\r\n } else if (this.selectedLenderUser.IsLenderAdmin) {\r\n this.error = \"\";\r\n }\r\n }\r\n\r\n lenderUserChanged() {\r\n this.initLenderUserProductType();\r\n }\r\n\r\n getProductName(key: number): string {\r\n let names: string[] = [];\r\n let totalKey = 0;\r\n\r\n for (let item of this.productTypeOptions) {\r\n if ((key & item.key) === item.key && item.key !== 0) {\r\n names.push(item.displayName);\r\n totalKey |= item.key;\r\n }\r\n }\r\n\r\n if (totalKey === ProductTypeEnum.Bridging) {\r\n return \"Bridging\";\r\n }\r\n\r\n return names.join(\", \");\r\n }\r\n\r\n onFamilyChange(): void {\r\n this.filteredProductTypeOptions = this.productTypeOptions.filter((item) => {\r\n return this.productTypeBelongToFamily(item);\r\n });\r\n\r\n switch (this.selectedObjectProduct.LI_LoanFamily) {\r\n case ProductFamilyEnum.Bridging:\r\n this.selectedObjectProduct.LI_LoanProduct &= ProductTypeEnum.Bridging;\r\n break;\r\n case ProductFamilyEnum.Development:\r\n this.selectedObjectProduct.LI_LoanProduct &=\r\n ProductTypeEnum.Development;\r\n break;\r\n case ProductFamilyEnum.Commercial:\r\n this.selectedObjectProduct.LI_LoanProduct &=\r\n ProductTypeEnum.CommercialAll;\r\n break;\r\n case ProductFamilyEnum.None:\r\n this.selectedObjectProduct.LI_LoanProduct &= ProductTypeEnum.None;\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n if (\r\n this.selectedObjectProduct.LI_LoanProduct === 0 ||\r\n isNaN(this.selectedObjectProduct.LI_LoanProduct)\r\n ) {\r\n this.selectedObjectProduct.LI_LoanProduct = null;\r\n }\r\n }\r\n\r\n productTypeBelongToFamily(item): boolean {\r\n switch (this.selectedObjectProduct.LI_LoanFamily) {\r\n case ProductFamilyEnum.Bridging:\r\n return (item.key & ProductTypeEnum.Bridging) !== 0;\r\n case ProductFamilyEnum.Development:\r\n return item.key === ProductTypeEnum.Development;\r\n case ProductFamilyEnum.Commercial:\r\n return (item.key & ProductTypeEnum.CommercialAll) !== 0;\r\n default:\r\n return false;\r\n }\r\n }\r\n\r\n productIsValid(): boolean {\r\n const forms = [\r\n this.multiPartForm1,\r\n this.multiPartForm2,\r\n this.multiPartForm3,\r\n this.multiPartForm4,\r\n this.multiPartForm5,\r\n this.multiPartForm6,\r\n this.multiPartForm7,\r\n ];\r\n\r\n var productError;\r\n\r\n if (\r\n this.selectedObjectProduct.LI_LoanFamily == ProductFamilyEnum.Commercial || (this.selectedObjectProduct.LI_LoanFamily && (this.selectedObjectProduct.LI_LoanProduct & ProductTypeEnum.BridgingPreconstruction || this.selectedObjectProduct.LI_LoanProduct & ProductTypeEnum.BridgingDeveloperExit || this.selectedObjectProduct.LI_LoanProduct & ProductTypeEnum.BridgingPurchaseOrRefinance))\r\n ) {\r\n this.error = null;\r\n return true;\r\n }\r\n\r\n if (\r\n (this.multiPartForm6 &&\r\n this.multiPartForm6.$dirty &&\r\n !this.selectedObjectProduct.LI_Dev_ArrFeeIncBrokFee) ||\r\n Number(this.selectedObjectProduct.LI_Dev_ArrFeeIncBrokFee) <= 0\r\n ) {\r\n productError = this.error =\r\n \"Arrangement Fee total % must be greater than 0\";\r\n } else {\r\n this.error = null;\r\n }\r\n\r\n return productError == null;\r\n }\r\n\r\n validateSelection() {\r\n this.isValidSelection = this.selectedBrokers.length <= 3;\r\n this.updatePreferredBrokers = true;\r\n }\r\n\r\n getSelectedBrokersString() {\r\n if (this.selectedBrokers == null || this.selectedBrokers.length == 0) {\r\n return \"\";\r\n }\r\n return this.selectedBrokers\r\n .map(function (item) {\r\n return item.Name;\r\n })\r\n .join(\", \");\r\n }\r\n\r\n getPreferredOrgs(): void {\r\n this.selectedBrokers = [];\r\n this.$lenderservice\r\n .getSelectedLenderPreferredOrgs(this.selectedObject.Id)\r\n .then((response) => {\r\n return response.map((x) => x.Id);\r\n })\r\n .then((ids) => {\r\n this.organisations.forEach((org: OrganisationDTO) => {\r\n (org as any).ticked = false;\r\n ids.forEach((id: number) => {\r\n if (org.Id == id) {\r\n this.selectedBrokers.push(org);\r\n (org as any).ticked = true;\r\n }\r\n });\r\n });\r\n });\r\n }\r\n\r\n trustedHtml(plainText) {\r\n return this.$sce.trustAsHtml(plainText);\r\n }\r\n\r\n validatePortalLink() {\r\n if (this.selectedObject.PortalUrl) {\r\n let url = this.selectedObject.PortalUrl;\r\n if (!/^https?:\\/\\//i.test(url)) {\r\n url = 'http://' + url;\r\n }\r\n window.open(url, '_blank');\r\n }\r\n };\r\n\r\n /**\r\n * Display a modal to edit details that are specific at a product family level\r\n * @param productFamily\r\n */\r\n showEditLenderProductFamilyModal(productFamily: ProductFamilyEnum) {\r\n this.tempSelectedObject = { ...this.selectedObject };\r\n this.editedLenderProductFamily = productFamily;\r\n this.showEditProductNotesAndSnapshot = true;\r\n }\r\n\r\n /** Close the lender's product family edit modal and cancel/undo changes */\r\n cancelEditLenderProductFamilyModal() {\r\n this.selectedObject = this.tempSelectedObject;\r\n this.editedLenderProductFamily = null;\r\n this.showEditProductNotesAndSnapshot = false;\r\n this.error = \"\";\r\n }\r\n}\r\n\r\n","import { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { RegistrationRequestDTO } from \"@js/DTO/RegistrationRequestDTO.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { LenderResultService } from \"@js/services/LenderResultService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { ClientService } from \"@js/services/ClientService\"\r\nimport { DealClientService } from \"@js/services/DealClientService\"\r\n\r\n\r\nexport class LoginController {\r\n dataLoading: boolean = false;\r\n username: string;\r\n password: string;\r\n\r\n // For password reset;\r\n tempUsername: string;\r\n tempPassword: string;\r\n email: string;\r\n resetEmail: string;\r\n\r\n resetSubmitted: boolean;\r\n resettingPassword: boolean;\r\n\r\n registrationSubmitted: boolean;\r\n registeringAccount: boolean;\r\n registerAccountForm: FormData;\r\n passwordResetForm: boolean = true;\r\n loginform: FormData;\r\n error: string;\r\n newUser: RegistrationRequestDTO = {\r\n Email: \"\",\r\n FirstName: \"\",\r\n LastName: \"\",\r\n } as RegistrationRequestDTO;\r\n confirmEmailAddress: string;\r\n newPassword: string = null;\r\n verifyNewPassword: string = null;\r\n\r\n showPostRestPasswordScreen: boolean = false;\r\n\r\n loanCriteria: DevelopmentInputDTO;\r\n autoLogin: boolean = false;\r\n applicationName: string;\r\n\r\n orgUniqueRef: string;\r\n isBorrower: boolean = false;\r\n\r\n //Parameters passed from enterprise\r\n isEnterprise: boolean = false;\r\n productFamily: ProductFamilyEnum = null;\r\n dealUniqueRef: string = null;\r\n clientId: number = null;\r\n\r\n static $inject = [\r\n \"CaseService\",\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"$httpParamSerializerJQLike\",\r\n \"LenderResultService\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n \"UserService\",\r\n \"OrganisationService\",\r\n \"ClientService\",\r\n \"DealClientService\"\r\n ];\r\n\r\n static searchInProgress: boolean = false;\r\n\r\n constructor(\r\n private $CaseService: CaseService,\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private $httpParamSerializerJQLike: ng.IHttpParamSerializer,\r\n private $lenderresultservice: LenderResultService,\r\n private $auth: AuthService,\r\n private $roleService: RoleService,\r\n private $user: UserService,\r\n private organisationService: OrganisationService,\r\n private clientService: ClientService,\r\n private dealClientService: DealClientService\r\n\r\n ) {\r\n\r\n if (this.$location.path().startsWith('/e/login')) {\r\n this.isEnterprise = true;\r\n this.productFamily = Number(this.$routeParams.productFamily);\r\n this.dealUniqueRef = this.$routeParams.dealUniqueRef;\r\n if(this.$routeParams.clientId) this.clientId = Number(this.$routeParams.clientId);\r\n if(this.$routeParams.emailAddress) this.username = this.$routeParams.emailAddress;\r\n\r\n }\r\n\r\n //if (localStorage.getItem('userRole')) {\r\n // this.isBorrower = localStorage.getItem('userRole') == 'borrower';\r\n //}\r\n\r\n // // Show a header if it is hidden\r\n document.getElementById(\"header\").style.display = \"flex\";\r\n // //Hiding 'Sign/Register' button.\r\n document.getElementById(\"signIn\").style.display = \"none\";\r\n\r\n // rootScope.title = \"Login\";\r\n if (this.$routeParams.tempUser && this.$routeParams.tempPassword) {\r\n this.tempUsername = this.$routeParams.tempUser;\r\n this.tempPassword = this.$routeParams.tempPassword;\r\n if (this.$routeParams.userStatus == \"new\") {\r\n this.autoLogin = true;\r\n //If this is a half registered user, log in using details in route params\r\n this.loginThenResetPassword(this.tempPassword);\r\n } else {\r\n //Get Application name depending on the user\r\n this.organisationService\r\n .getOrgApplicationNameByUserName(this.tempUsername)\r\n .then((applicationName: string) => {\r\n this.applicationName = applicationName;\r\n if (this.applicationName != \"Brickflow\") {\r\n sessionStorage.setItem(\"applicationName\", this.applicationName);\r\n\r\n if ((window as any).HubSpotConversations) {\r\n (window as any).HubSpotConversations.widget.remove();\r\n }\r\n }\r\n this.showPostRestPasswordScreen = true;\r\n });\r\n }\r\n } else if ($cookies.get(\"access_token\")) {\r\n this.$roleService.goHomeBasedOnUser();\r\n }\r\n\r\n // If we have an introducer code set, let's store a cookie.\r\n if (this.$routeParams.introducercode) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"introducer_code\", this.$routeParams.introducercode, {\r\n expires: expiryDate,\r\n });\r\n } else if (this.$routeParams[\"ic\"]) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"introducer_code\", this.$routeParams[\"ic\"], {\r\n expires: expiryDate,\r\n });\r\n }\r\n\r\n if (this.$routeParams[\"orgc\"]) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"org_code\", this.$routeParams[\"orgc\"], {\r\n expires: expiryDate,\r\n });\r\n }\r\n\r\n if (this.$routeParams[\"orgref\"]) {\r\n this.orgUniqueRef = this.$routeParams[\"orgref\"];\r\n sessionStorage.setItem(\"assignUserToOrg\", \"true\");\r\n }\r\n\r\n this.loanCriteria = (this.$rootScope as any).loanCriteria;\r\n }\r\n\r\n login() {\r\n (this.$rootScope as any).formSaved = true;\r\n this.loginThenResetPassword(null);\r\n }\r\n\r\n goToRegister() {\r\n if (\r\n (this.$rootScope as any).loginRedirectPath &&\r\n (this.$rootScope as any).loginRedirectPath.includes(\"/securitycheck\")\r\n ) {\r\n var url = (this.$rootScope as any).loginRedirectPath;\r\n var introducerCode = url.replace(\"/securitycheck/\", \"\");\r\n\r\n if (introducerCode) {\r\n this.$location.path(\"/registershareholder/\" + introducerCode);\r\n } else {\r\n this.$location.path(\"/landingV3\");\r\n }\r\n } else {\r\n this.username = null;\r\n this.password = null;\r\n this.$location.path(\"/landingV3\");\r\n }\r\n }\r\n\r\n //this handles a normal login and a login where the password needs restting at same time\r\n private loginThenResetPassword(newPassword: string) {\r\n this.dataLoading = true;\r\n this.$auth\r\n .login(\r\n newPassword ? this.tempUsername : this.username,\r\n newPassword ? this.tempPassword : this.password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n let expiry: Date = response;\r\n //if a new password change it ie on resetpassword\r\n if (newPassword) {\r\n this.$auth.changePassword(this.tempPassword, newPassword);\r\n }\r\n this.$auth\r\n .getProfile()\r\n .then((response) => {\r\n this.$cookies.put(\"user_firstname\", response.FirstName, {\r\n expires: expiry,\r\n });\r\n\r\n (this.$rootScope as any).selectedUser = response;\r\n\r\n this.$rootScope.$broadcast(\"login\"); //tell everyone you have logged in\r\n this.$roleService.GetUserRoles(true).then((result) => {\r\n if (this.isEnterprise) { \r\n if(this.$routeParams.emailAddress && this.$routeParams.clientId){\r\n this.clientService.updateClientWithUserId(this.clientId);\r\n this.gotoResultsPage();\r\n }else{\r\n this.dealClientService.addCurrentUserToDeal(this.$routeParams.dealUniqueRef).then((response) => {\r\n this.gotoResultsPage();\r\n });\r\n }\r\n }\r\n else {\r\n //if there's a loanCriteria, create search to persist on system\r\n if (this.loanCriteria) {\r\n this.loanCriteria.UserId = response.Id;\r\n this.loanCriteria.User = response;\r\n this.loanCriteria.SaveQueryAndResults = true;\r\n\r\n this.$lenderresultservice\r\n .fetchMatchingResults(\r\n this.loanCriteria,\r\n true,\r\n true,\r\n 4,\r\n false,\r\n \"\",\r\n response.Email,\r\n response.PhoneNumber,\r\n \"\",\r\n )\r\n .then((response) => {\r\n if (this.loanCriteria.SaveCase === true) {\r\n //case creation\r\n this.$CaseService\r\n .promotesearchtocase(\r\n response.Id,\r\n (this.$rootScope as any)\r\n .selectedResultForAttachingToCase.Id,\r\n (this.$rootScope as any).productResultList,\r\n )\r\n .then((success) => {\r\n if (LoginController.searchInProgress) {\r\n this.$location.path(\"/results/\" + response.Id);\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n LoginController.searchInProgress = false;\r\n });\r\n } else {\r\n if (LoginController.searchInProgress) {\r\n this.$location.path(\"/results/\" + response.Id);\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n LoginController.searchInProgress = false;\r\n }\r\n });\r\n } else {\r\n var targeturl = this.$location.search().targeturl;\r\n\r\n if (targeturl) {\r\n this.$location.search({});\r\n this.$location.path(targeturl);\r\n }\r\n // Check to see if we should load the admin dashboard or the end user dashboard.\r\n else if (\r\n this.$location.path().startsWith(\"/loginandreturnto\")\r\n ) {\r\n //return back to the page it came from\r\n (this.$rootScope as any).back();\r\n } else if (\r\n (this.$rootScope as any).loginRedirectPath &&\r\n !(this.$rootScope as any).loginRedirectPath.includes(\"/login\")\r\n ) {\r\n const loginRedirectPath = (this.$rootScope as any)\r\n .loginRedirectPath;\r\n (this.$rootScope as any).loginRedirectPath = undefined;\r\n this.$location.path(loginRedirectPath);\r\n } else if (this.orgUniqueRef != null) {\r\n this.$location.path(\"/registerbroker/\" + this.orgUniqueRef);\r\n } else {\r\n this.$roleService.goHomeBasedOnUser();\r\n }\r\n }\r\n }\r\n\r\n });\r\n\r\n this.$user.sendEventToHubspot(response, null, true);\r\n })\r\n .catch((response) => {\r\n this.error = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n })\r\n .catch((response) => {\r\n this.error = response;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n openResetModal() {\r\n this.resetEmail = this.username;\r\n this.resettingPassword = true;\r\n }\r\n\r\n resetPassword() {\r\n this.passwordResetForm = true;\r\n this.dataLoading = true;\r\n //this.username = null;\r\n //this.password = null;\r\n //this.login();\r\n this.$auth\r\n .resetPassword(this.resetEmail)\r\n .then((response) => {\r\n this.resetSubmitted = true;\r\n this.resettingPassword = false;\r\n })\r\n .catch((error) => {\r\n this.passwordResetForm = error;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n postResetPassword() {\r\n //login thenchange the password then\r\n if (this.verifyNewPassword == this.newPassword) {\r\n this.loginThenResetPassword(this.newPassword);\r\n }\r\n }\r\n\r\n clearPasswordReset() {\r\n this.resettingPassword = false;\r\n this.resetSubmitted = false;\r\n }\r\n\r\n gotoResultsPage(){\r\n var redirectUrl = '';\r\n\r\n switch (this.productFamily) {\r\n case ProductFamilyEnum.Development:\r\n redirectUrl = `/devfinanceresults/${this.dealUniqueRef}`;\r\n break;\r\n case ProductFamilyEnum.Bridging:\r\n redirectUrl = `/bridgingresults/${this.dealUniqueRef}`;\r\n break;\r\n case ProductFamilyEnum.Commercial:\r\n redirectUrl = `/commercialresults/${this.dealUniqueRef}`;\r\n break;\r\n default:\r\n redirectUrl = '/userdashboard';\r\n break;\r\n }\r\n\r\n this.$location.path(redirectUrl);\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { CaseLenderDTO } from \"@js/DTO/CaseLenderDTO.cs.d\";\r\nimport { CaseNoteDTO } from \"@js/DTO/CaseNoteDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { ShareDealDTO } from \"@js/DTO/Deal/SearchDealDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { LenderResultDTO } from \"@js/DTO/DevelopmentFinance/LenderResultDTO.cs.d\";\r\nimport { LenderResultMinimalDTO } from \"@js/DTO/DevelopmentFinance/LenderResultMinimalDTO.cs.d\";\r\nimport { LenderResultSummaryDTO } from \"@js/DTO/DevelopmentFinance/LenderResultSummaryDTO.cs.d\";\r\nimport { DevelopmentWithNoLoginDTO } from \"@js/DTO/DevelopmentWithNoLoginDTO.cs.d\";\r\nimport { LenderResultSetDTO } from \"@js/DTO/LenderResultSet.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { SelectedResultDTO } from \"@js/DTO/SelectedResultDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { EventLogEnum } from \"@js/models/enum/EventLogEnum.cs.d\";\r\nimport { LicenseMasterStatusEnum } from \"@js/models/enum/LicenseMasterStatusEnum.cs.d\";\r\nimport { MaxFlatUnitPriceEnum } from \"@js/models/enum/MaxFlatUnitPriceEnum.cs.d\";\r\nimport { MaxHouseSalePriceEnum } from \"@js/models/enum/MaxHouseSalePriceEnum.cs.d\";\r\nimport { MaxSqFtSalePriceEnum } from \"@js/models/enum/MaxSqFtSalePriceEnum.cs.d\";\r\nimport { PersonalGuaranteeLevelEnum } from \"@js/models/enum/PersonalGuaranteeLevelEnum.cs.d\";\r\nimport { PreviousDevelopmentsEnum } from \"@js/models/enum/PreviousDevelopmentsEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { PropertyTypeEnum } from \"@js/models/enum/PropertyTypeEnum.cs.d\";\r\nimport { ShareholderDepositRequiredEnum } from \"@js/models/enum/ShareholderDepositRequiredEnum.cs.d\";\r\nimport { SortByEnum } from \"@js/models/enum/SortByEnum.cs.d\";\r\nimport { AccountService } from \"@js/services/AccountService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { BridgingSearchService } from \"@js/services/BridgingSearchService\";\r\nimport { CaseLenderService } from \"@js/services/CaseLenderService\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseNoteService } from \"@js/services/CaseNoteService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { ClientService } from \"@js/services/ClientService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { DevelopmentInputWithNoLoginService } from \"@js/services/DevelopmentInputWithNoLoginService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { IntroducerService } from \"@js/services/IntroducerService\";\r\nimport { InviteService } from \"@js/services/InviteService\";\r\nimport { LenderResultService } from \"@js/services/LenderResultService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { LoginController } from \"./LoginController\";\r\nimport { UserRoleEnum } from \"@js/models/enum/UserRoleEnum.cs.d\";\r\n\r\ninterface ResultArrayMobile {\r\n name: string;\r\n array: LenderResultMinimalDTO[];\r\n template: string;\r\n headerTemplate: string;\r\n order: number;\r\n}\r\n\r\nexport class LenderResultScreenController {\r\n loadingData: boolean = false;\r\n\r\n // tourState: any = {\r\n // tourStep: 1,\r\n // tourTotalSteps: 0,\r\n // };\r\n // tourEnabled: boolean = false;\r\n\r\n assistanceSlider: boolean = true;\r\n offer: LenderResultSummaryDTO;\r\n\r\n totalLender: number = 0;\r\n\r\n enquiryOpen: boolean;\r\n enquiryEmail: string;\r\n enquiryBody: string;\r\n enquiryTelephone: string;\r\n sentmessage: boolean = false;\r\n sendingmessage: boolean = false;\r\n firstTime: boolean = true;\r\n\r\n fetchingMatches: boolean;\r\n fetchingLargest: boolean;\r\n fetchingMezzanine: boolean;\r\n fetchingEquity: boolean;\r\n\r\n mezzanineLenders: boolean;\r\n equityLenders: boolean;\r\n guidanceCheckbox: boolean = true;\r\n showVideo: boolean = false;\r\n isSearch: boolean = true;\r\n isMaximumLoanRequired: boolean = true;\r\n tempLoanRequired: number;\r\n showHelpText: boolean = true;\r\n productIdAttachedToCase: number;\r\n\r\n loanCriteria: DevelopmentInputDTO;\r\n\r\n results: LenderResultSetDTO;\r\n\r\n matchingResults: LenderResultMinimalDTO[];\r\n largestResults: LenderResultMinimalDTO[];\r\n mezzanineResults: LenderResultDTO[];\r\n equityResults: LenderResultDTO[];\r\n allResults: ResultArrayMobile[] = [];\r\n selectedResultArray: LenderResultDTO[];\r\n\r\n summarySearchResults: LenderResultSummaryDTO[];\r\n\r\n selectedResult: LenderResultDTO;\r\n selectedResultForAttachingToCase: LenderResultMinimalDTO;\r\n\r\n comparisonList: LenderResultMinimalDTO[] = [];\r\n summaryComparisonList: LenderResultSummaryDTO[] = [];\r\n totProjCosts: number;\r\n showsaveinfo: boolean = false;\r\n selectedUser: ApplicationUserDTO = {} as ApplicationUserDTO;\r\n hideusername: boolean = true;\r\n caseid: number = null;\r\n searchid: number = null;\r\n uniqueId: string = null;\r\n\r\n hideCaseCreation: boolean = false;\r\n loanLabel: string;\r\n limitmatches: boolean = true;\r\n limitlargestmatches: boolean = true;\r\n showSaveResults: number;\r\n warningOff: boolean = false;\r\n doubleWarningOff: boolean = false;\r\n currentCase: CaseDTO;\r\n currentProductOnCase: string;\r\n caseUpdated: boolean = false;\r\n switchingProduct: boolean = false;\r\n productResultList: number;\r\n productId: number;\r\n caseLenders: CaseLenderDTO[];\r\n caseLendersNotInResults: CaseLenderDTO[];\r\n filterLenderNames: string[] = [];\r\n\r\n sliderShown: boolean;\r\n updatedResultsWithSlider: boolean = false;\r\n\r\n rowsShown: number = 4;\r\n emailJourneyStarted: boolean = true;\r\n searchNameCache: string;\r\n\r\n //Introducers\r\n clientFirstName: string;\r\n clientSurname: string;\r\n clientEmail: string;\r\n notifyBorrower: boolean = true;\r\n\r\n // confirmation before leave\r\n confirmSaving: boolean = false;\r\n prevPath: string;\r\n\r\n loanCriteriaWithoutCredentials: DevelopmentInputDTO;\r\n showProductNote: boolean = false;\r\n productNote: string;\r\n\r\n savePressed: boolean = false;\r\n\r\n //Capture name and email address & send results to unregistered searcher\r\n newUserCaptureForm: FormData;\r\n newUser: ApplicationUserDTO = {} as ApplicationUserDTO;\r\n //captureFirstName: string;\r\n //captureSurname: string;\r\n //captureEmail: string;\r\n //applicantDefinedRole: ApplicantRoleEnum;\r\n agreedToBeEmailed: boolean = false;\r\n error: string = \"\";\r\n // Flag to disable or enable the Save as button depending on the click.\r\n isClicked: boolean = false;\r\n showContactBrokerModal: boolean = false;\r\n hasAccessToDeal: boolean = true;\r\n\r\n //Carousel\r\n carouselData: string[] = [\r\n \"Brickflow is the quickest and easiest way to apply for development finance.\",\r\n \"To protect borrowers, we only work with the UK's most reputable and financially secure lenders.\",\r\n \"We work with mainstream & challenger banks, as well as specialist development lenders.\",\r\n \"The results below are estimates based on critera provided to us by our lenders.\",\r\n \"To get a Lender Approved Decision in Principle (DIP), select up to 3x loan options below and click Proceed.\",\r\n ];\r\n carouselStep: number = 0;\r\n\r\n //For admins accessing client accounts\r\n clientUsernameBeingAccessed: string;\r\n\r\n toggleEditSearchName: boolean = false;\r\n\r\n isBlankSearch: boolean = false;\r\n\r\n isAdmin: boolean = false;\r\n debug1: boolean = false;\r\n\r\n showActionPanel: boolean = false;\r\n\r\n isLoggedInUser: boolean = false;\r\n isLegacyUser: boolean = false;\r\n\r\n isProceedClicked: boolean = false;\r\n isDIPClicked: boolean = false;\r\n\r\n tempSearchName: string = null;\r\n\r\n isLoggingOut: boolean = false;\r\n\r\n //These are added for new search functinality\r\n existingUsers: UserSimpleDTO[];\r\n isNewSearch: boolean;\r\n newSearch: boolean = false;\r\n existingborrower: boolean;\r\n clientPhoneNumber: string;\r\n showClientDetails: boolean = false;\r\n isBroker: boolean = false;\r\n clientId: string = null;\r\n isreferredSearch: boolean = false;\r\n isIntroducer: boolean = false;\r\n isIntroduceronly: boolean = false;\r\n isLender: boolean = false;\r\n searchName: string = null;\r\n searchReference: string;\r\n newSearchId: number;\r\n\r\n //Accordion\r\n accordionShow: boolean[] = [];\r\n showRequestEmailForm: boolean = false;\r\n requestMessageReason: string = \"\";\r\n message: boolean = false;\r\n messageContent: string;\r\n sendingMessage: boolean = false;\r\n\r\n appName: string;\r\n\r\n guid: string = null;\r\n isSaveorSaveAsClicked: boolean = false;\r\n showOnlyRegisterButton: boolean = false;\r\n noOfShortlistAllowed: number = 5;\r\n emailClient: boolean = false;\r\n displayMsg: string = null;\r\n showMsg: boolean = false;\r\n showMsgToAdminOrBroker: boolean = false;\r\n ShowdeleteSearch: boolean = false;\r\n newLeadFirstName: string;\r\n newLeadLastName: string;\r\n newLeadEmail: string;\r\n isResultScreen: boolean = true;\r\n isSaveClientSearch: boolean = false;\r\n selecteduserName: string;\r\n\r\n isClient: boolean = false;\r\n\r\n numberOfPreviousDevelopmentsOptions = [];\r\n depositRequiredFromShareholdersOptions = [];\r\n personalGuaranteeLevelOptions = [];\r\n maxHouseSalePriceOptions = [];\r\n maxFlatUnitPriceOptions = [];\r\n maxSqFtSalePriceOptions = [];\r\n maxPercCommercialForMixedUseOptions = [];\r\n locationOptions = [];\r\n maxCommercialFloorspaceOptions\r\n\r\n shareholderDepositRequired = null;\r\n personalGuaranteeLevel = null;\r\n maxHouseSalesPrice = null;\r\n maxFlatUnitPrice = null;\r\n maxSqFtSalePrice = null;\r\n maxSqFtSalePriceFlats = null;\r\n maxPercCommercialForMixedUse = null;\r\n tempLoanCriteria = null;\r\n previousDevelopments = null;\r\n\r\n showFilters: boolean = false;\r\n isFilterUpdate: boolean = false;\r\n showSortBy: boolean = false;\r\n\r\n isShortlistingMore: boolean = false;\r\n\r\n showContactLender: boolean = false;\r\n shareForm: ng.IFormController;\r\n shareFirstName: string;\r\n shareNote: string;\r\n lenderEmail: string;\r\n shareEmailSubject: string;\r\n sharedSearch: boolean = false;\r\n dataLoading: boolean = false;\r\n isSaveAsWthOutIntroducee: boolean = false;\r\n hasSearchChanged: boolean = false;\r\n hasCriteriaChanged: boolean = false;\r\n orgCode: string;\r\n orgName: string;\r\n brokerDetail: string = \"\";\r\n reloadSearch: boolean = false;\r\n brokerageOrg: OrganisationDTO;\r\n brokerageOrgFilename: string;\r\n showMessageToborrower: boolean = false;\r\n borrowerMessage: string = \"\";\r\n user: ApplicationUserDTO;\r\n moveContactBrokerBtnInMiddle: boolean = false;\r\n clientOrganisationPhoneNumber: string;\r\n showBridgingEligibility: boolean = false;\r\n isBridging: boolean = false;\r\n isOldDevFinance: boolean = true;\r\n showLenderNamesAndLogosOverride: boolean = false;\r\n userRole: string;\r\n userDetails: string;\r\n userLenderId: number = null;\r\n\r\n //New enterprise journey\r\n showEnterpriseRegistrationModal: boolean = false;\r\n projectName: string = \"\";\r\n registrationForm: ng.IFormController;\r\n emailExistsError: boolean = false;\r\n enterpriseClientId: string = \"\";\r\n\r\n snapshotNewSearch: boolean = false;\r\n showPostcodeErrorMessage: boolean = false;\r\n postcodeErrorMsg: string;\r\n\r\n hasResultsProcessed: boolean = false;\r\n\r\n //SaveAs functionality\r\n isSaveAsClicked: boolean = false;\r\n saveAsSearchName: string;\r\n\r\n filterProperties = [\r\n \"F_IsFirstTimeDeveloper\",\r\n \"F_NumberOfPreviousDevelopments\",\r\n \"F_ShareholderDepositRequired\",\r\n \"F_IsPersonalName\",\r\n \"F_IsOffshoreCompany\",\r\n \"F_IsMainShareholderOverseas\",\r\n \"F_PersonalGuaranteeLevel\",\r\n \"F_HasAdverseCredit\",\r\n \"F_MaxCommercialFloorspace\",\r\n \"F_IsAirRights\",\r\n \"F_IsModular\",\r\n \"F_IsPermittedDevelopmentScheme\",\r\n \"F_IsGradeOneListed\",\r\n \"F_IsGradeTwoListed\",\r\n \"F_MaxHouseSalesPrice\",\r\n \"F_MaxFlatUnitPrice\",\r\n \"F_MaxNumberOfUnits\",\r\n //\"F_MaxPercCommercialForMixedUse\",\r\n \"F_MaxSqFtSalePrice\",\r\n \"F_MaxSqFtSalePriceFlats\",\r\n \"F_IsWorkStarted\",\r\n \"F_IsChargeOnAdditionalProperty\",\r\n \"F_IsFixedRate\",\r\n ];\r\n\r\n static $inject = [\r\n \"$route\",\r\n \"$routeParams\",\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"$cookies\",\r\n \"LenderResultService\",\r\n \"UserService\",\r\n \"CaseService\",\r\n \"DevelopmentInputService\",\r\n \"DevelopmentInputWithNoLoginService\",\r\n \"IntroducerService\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n \"FileAttachmentService\",\r\n \"LenderService\",\r\n \"CaseMemberService\",\r\n \"InviteService\",\r\n \"OrganisationService\",\r\n \"AccountService\",\r\n \"CaseNoteService\",\r\n \"PaymentService\",\r\n \"SelectListService\",\r\n \"CaseLenderService\",\r\n \"UserService\",\r\n \"EventLogService\",\r\n \"BridgingSearchService\",\r\n \"ClientService\",\r\n ];\r\n\r\n constructor(\r\n private $route: ng.route.IRouteService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $scope: ng.IScope,\r\n public $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $lenderresultservice: LenderResultService,\r\n private $user: UserService,\r\n private $CaseService: CaseService,\r\n private $DevelopmentInputService: DevelopmentInputService,\r\n private $DevelopmentInputWithNoLoginService: DevelopmentInputWithNoLoginService,\r\n private $IntroducerService: IntroducerService,\r\n private $auth: AuthService,\r\n private roleService: RoleService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private lenderService: LenderService,\r\n private caseMemberService: CaseMemberService,\r\n private inviteService: InviteService,\r\n private organisationService: OrganisationService,\r\n private $accountservice: AccountService,\r\n private caseNoteService: CaseNoteService,\r\n private paymentService: PaymentService,\r\n private selectListService: SelectListService,\r\n private caseLenderService: CaseLenderService,\r\n private userService: UserService,\r\n private eventLogService: EventLogService,\r\n private bridingSearchService: BridgingSearchService,\r\n private clientService: ClientService,\r\n ) {\r\n if (this.$location.path().startsWith(\"/shortlistmore\")) {\r\n this.isShortlistingMore = true;\r\n }\r\n\r\n if (\r\n window.self == window.top &&\r\n sessionStorage.getItem(\"userRole\") &&\r\n sessionStorage.getItem(\"userRole\") == \"borrower\" &&\r\n !$cookies.get(\"access_token\")\r\n ) {\r\n document.getElementById(\"header\").style.display = \"none\";\r\n } else if ($cookies.get(\"access_token\")) {\r\n document.getElementById(\"header\").style.display = \"flex\";\r\n }\r\n\r\n //Get CaseId & SearchId from route params. If the case don't have id, display the change serach menu\r\n if (this.$routeParams.CaseId) {\r\n this.caseid = Number(this.$routeParams.CaseId);\r\n this.isSearch = false;\r\n } else {\r\n this.isSearch = true;\r\n }\r\n\r\n if (this.$routeParams.SearchId) {\r\n this.searchid = Number(this.$routeParams.SearchId);\r\n } else {\r\n if (window.self == window.top && $cookies.get(\"access_token\"))\r\n // Expanding a 'new search' panel for first time search execution\r\n this.sliderShown = (this.$rootScope as any).previousRoute.startsWith(\"/compare\") ? false : true;\r\n }\r\n if (this.$routeParams.uniqueId) {\r\n this.uniqueId = this.$routeParams.uniqueId;\r\n }\r\n\r\n if (window.self == window.top && $cookies.get(\"access_token\")) {\r\n //This block is to navigate a broker to userdashboard when they do not have a license.\r\n if (sessionStorage.getItem(\"isValidLicense\") == \"false\") {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n this.isLoggedInUser = true;\r\n this.assistanceSlider = false; //assistance-slider open the fist time you access to the case\r\n this.loadingData = true;\r\n this.organisationService\r\n .getOrganisation()\r\n .then((organisation) => {\r\n if (organisation) {\r\n if (!organisation.IsBrickflow) {\r\n this.clientOrganisationPhoneNumber = organisation.PhoneNumber;\r\n }\r\n this.orgCode = organisation.IsWhiteLabelled\r\n ? organisation.OrganisationCode\r\n : \"\";\r\n this.showLenderNamesAndLogosOverride =\r\n organisation.ShowLenderNames ?? false;\r\n if (organisation.IsWhiteLabelled) {\r\n this.orgName = organisation.Name.replace(/ /g, \"_\");\r\n } else {\r\n this.orgName = \"Brickflow\";\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n //not logged in so show the agree terms box every time\r\n this.selectedUser.LenderResultsTermsAgreed = false;\r\n this.determineSearchSource();\r\n if (window.self == window.top) {\r\n this.userRole = sessionStorage.getItem(\"userRole\");\r\n this.isClient = this.userRole == \"borrower\";\r\n this.user = JSON.parse(sessionStorage.getItem(\"userDetails\"));\r\n this.orgCode = this.$cookies.get(\"org_code\");\r\n this.enterpriseClientId = sessionStorage.getItem(\"clientId\");\r\n } else {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n this.guidanceCheckbox = false;\r\n Promise.all([\r\n this.organisationService\r\n .getData(\"userDetails\")\r\n .then((userDetails) => {\r\n if (userDetails) {\r\n this.user = JSON.parse(userDetails);\r\n }\r\n }),\r\n this.organisationService.getData(\"userRole\").then((userRole) => {\r\n if (userRole) {\r\n this.userRole = userRole;\r\n this.isClient = this.userRole == \"borrower\";\r\n }\r\n }),\r\n this.organisationService.getData(\"clientId\").then((clientId) => {\r\n if (clientId) {\r\n this.enterpriseClientId = clientId;\r\n }\r\n }),\r\n this.organisationService.getData(\"newSearch\").then((newSearch) => {\r\n this.snapshotNewSearch = newSearch == \"true\";\r\n }),\r\n ])\r\n .then(() => {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n this.organisationService.sendDataToParent(\"newSearch\", \"false\");\r\n })\r\n .catch((error) => {\r\n console.error(\"Failed to get user data: \", error);\r\n });\r\n }\r\n }\r\n\r\n this.getSearchLenderCount();\r\n\r\n // if (window.self == window.top) {\r\n // let cookieTourStep = this.$cookies.get(\"tourStep\");\r\n // if (cookieTourStep) {\r\n // this.tourState.tourStep = cookieTourStep;\r\n // }\r\n // }\r\n\r\n if (this.caseid && this.caseid > 0) {\r\n this.getCase();\r\n }\r\n //else if (this.searchid) {\r\n // this.getCaseFromSearch(this.searchid);\r\n //} else {\r\n else {\r\n this.$CaseService.updateTubeMap(null);\r\n }\r\n\r\n if (window.self == window.top && sessionStorage.getItem(\"userDetails\")) {\r\n this.showOnlyRegisterButton = true;\r\n }\r\n\r\n //if user is logged in, get profile\r\n if (window.self == window.top && this.$cookies.get(\"access_token\")) {\r\n this.$user.getcurentuserrecord().then((result) => {\r\n this.selectedUser = result;\r\n\r\n this.isLegacyUser = this.selectedUser.IsLegacyUser;\r\n\r\n this.roleService.isClientUser().then((response) => {\r\n this.isClient = response;\r\n\r\n if (this.clientOrganisationPhoneNumber && !this.isClient) {\r\n this.clientOrganisationPhoneNumber = null;\r\n }\r\n });\r\n\r\n this.roleService.isAdminUser().then((response) => {\r\n this.isAdmin = response;\r\n if (this.isAdmin) {\r\n this.getUsersBelongToBrokerOrAdmin();\r\n }\r\n });\r\n\r\n this.roleService.isBroker().then((response) => {\r\n this.isBroker = response;\r\n if (this.isBroker) {\r\n this.getUsersBelongToBrokerOrAdmin();\r\n }\r\n });\r\n\r\n this.roleService.isIntroducer().then((response) => {\r\n this.isIntroducer = response;\r\n });\r\n\r\n this.roleService.isIntroducerOnly().then((response) => {\r\n this.isIntroduceronly = response;\r\n });\r\n\r\n this.roleService.isLenderUser().then((response) => {\r\n this.isLender = response;\r\n if (this.isLender) {\r\n this.$user.getCurrentUserLender().then((response) => {\r\n this.userLenderId = response;\r\n });\r\n }\r\n });\r\n\r\n this.determineSearchSource();\r\n });\r\n }\r\n\r\n // if (window.self == window.top) this.updateGuidanceState();\r\n\r\n this.checkShowBridgingEligibility();\r\n\r\n $scope.$on(\"$locationChangeStart\", (event: ng.IAngularEvent) => {\r\n /*this.paymentService.getLicense().then((response) => {\r\n var license: LicenseMasterDTO = response;\r\n\r\n if (license.Status == LicenseMasterStatusEnum.PaidUp\r\n || license.Status == LicenseMasterStatusEnum.PaymentProcessing\r\n || license.Status == LicenseMasterStatusEnum.PreCancel) {\r\n this.saveChanges(event);\r\n }\r\n });*/\r\n\r\n if (\r\n this.selectedUser.SubscriptionStatus ==\r\n LicenseMasterStatusEnum.PaidUp ||\r\n this.selectedUser.SubscriptionStatus ==\r\n LicenseMasterStatusEnum.PaymentProcessing ||\r\n this.selectedUser.SubscriptionStatus ==\r\n LicenseMasterStatusEnum.PreCancel\r\n ) {\r\n this.saveChanges(event);\r\n }\r\n });\r\n\r\n let logoutUnregister = $rootScope.$on(\r\n \"logout\",\r\n (event: ng.IAngularEvent) => {\r\n this.isLoggingOut = true;\r\n /* this.paymentService.getLicense().then((response) => {\r\n var license: LicenseMasterDTO = response;\r\n \r\n if (license.Status == LicenseMasterStatusEnum.PaidUp\r\n || license.Status == LicenseMasterStatusEnum.PaymentProcessing\r\n || license.Status == LicenseMasterStatusEnum.PreCancel) {\r\n this.saveChanges(event);\r\n }\r\n });*/\r\n\r\n if (\r\n this.selectedUser.SubscriptionStatus ==\r\n LicenseMasterStatusEnum.PaidUp ||\r\n this.selectedUser.SubscriptionStatus ==\r\n LicenseMasterStatusEnum.PaymentProcessing ||\r\n this.selectedUser.SubscriptionStatus ==\r\n LicenseMasterStatusEnum.PreCancel\r\n ) {\r\n this.saveChanges(event);\r\n }\r\n },\r\n );\r\n\r\n if (window.self == window.top) {\r\n $scope.$on(\"$destroy\", logoutUnregister);\r\n\r\n // $rootScope.$on(\"guidanceStateChanged\", (event: ng.IAngularEvent) => {\r\n // this.updateGuidanceState();\r\n // });\r\n\r\n // $rootScope.$on(\"nextTour\", (event: ng.IAngularEvent) => {\r\n // this.tourNext();\r\n // });\r\n // $rootScope.$on(\"backTour\", (event: ng.IAngularEvent) => {\r\n // this.tourBack();\r\n // });\r\n // $rootScope.$on(\"skipTour\", (event: ng.IAngularEvent) => {\r\n // this.tourSkip();\r\n // });\r\n }\r\n\r\n // Set the broker information on the new user object\r\n if (\r\n this.$routeParams.brokerOrgUniqueRef !== undefined &&\r\n this.$routeParams.brokerOrgUniqueRef != \"null\" &&\r\n this.$routeParams.brokerUserId !== undefined &&\r\n this.$routeParams.brokerUserId != \"null\"\r\n ) {\r\n this.organisationService\r\n .getOrganisationIdByUniqueRef(this.$routeParams.brokerOrgUniqueRef)\r\n .then((brokerOrgId: number) => {\r\n this.newUser.OrganisationReferralId = brokerOrgId;\r\n this.newUser.DefaultBrokerOrganisationId = brokerOrgId;\r\n });\r\n }\r\n\r\n this.getAppName();\r\n\r\n this.numberOfPreviousDevelopmentsOptions =\r\n this.selectListService.GetNumberOfPreviousDevelopments();\r\n this.depositRequiredFromShareholdersOptions =\r\n this.selectListService.GetShareholderDepositRequired();\r\n this.personalGuaranteeLevelOptions =\r\n this.selectListService.GetPersonalGuaranteeLevels();\r\n this.maxHouseSalePriceOptions =\r\n this.selectListService.GetMaxHouseSalePrices();\r\n this.maxFlatUnitPriceOptions =\r\n this.selectListService.GetMaxFlatUnitPrices();\r\n this.maxSqFtSalePriceOptions =\r\n this.selectListService.GetMaxSqFtSalePrices();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n this.maxCommercialFloorspaceOptions = this.selectListService.GetMaxCommercialFloorspaceOptions();\r\n }\r\n\r\n getRequiredRoles(isCaseDashboard: boolean) {\r\n if (isCaseDashboard) return `['Admin', 'Client', 'Broker', 'Introducer']`;\r\n return `['Admin', 'Client', 'Broker', 'Introducer', 'Lender']`;\r\n }\r\n\r\n saveChanges(event: ng.IAngularEvent) {\r\n if (!(this.isBroker && (this.$routeParams.uniqueId || this.searchid))) {\r\n if (this.warningOff) {\r\n this.warningOff = false;\r\n return;\r\n } else {\r\n if (\r\n !this.showSaveResults &&\r\n !this.searchid &&\r\n !this.doubleWarningOff &&\r\n this.isLoggedInUser\r\n ) {\r\n this.prevPath = this.$location.url();\r\n event.preventDefault();\r\n this.confirmSaving = true;\r\n //var leaveWithoutSave = confirm(\"Are you sure you want to leave this page without saving your results?\")\r\n }\r\n }\r\n }\r\n }\r\n\r\n cancelSavingResults() {\r\n event.preventDefault();\r\n this.confirmSaving = false;\r\n if (\r\n this.loanCriteria.SearchName &&\r\n !this.loanCriteria.SearchName.startsWith(\"My Development Finance Search\")\r\n ) {\r\n this.isSaveorSaveAsClicked = true;\r\n this.register(false, this.productResultList);\r\n } else {\r\n this.showSaveResults = 1;\r\n }\r\n }\r\n\r\n cancelSaving() {\r\n this.warningOff = true;\r\n this.confirmSaving = false;\r\n\r\n if (this.isLoggingOut == true) {\r\n this.isLoggingOut = false;\r\n this.$auth.logout();\r\n } else {\r\n this.$location.path(this.prevPath);\r\n }\r\n }\r\n\r\n determineSearchSource() {\r\n //if called from third party api\r\n if (this.$location.path().startsWith(\"/resultsExternalAPI\")) {\r\n if (\r\n this.$routeParams.uniqeId !== undefined &&\r\n this.$routeParams.uniqeId != \"null\"\r\n ) {\r\n //read back data using\r\n this.$lenderresultservice\r\n .fetchByUniqueRef(this.$routeParams.uniqeId, 20)\r\n .then((results) => {\r\n (this.$rootScope as any).loanCriteria = results.DevelopmentInput;\r\n this.loanCriteria = (this.$rootScope as any).loanCriteria;\r\n if (this.loanCriteria) {\r\n this.newUser.FirstName = this.loanCriteria.IntroduceeFirstName;\r\n this.newUser.LastName = this.loanCriteria.IntroduceeSurname;\r\n this.newUser.Email = this.loanCriteria.IntroduceeEmail;\r\n this.newUser.PhoneNumber = this.loanCriteria.IntroduceePhone;\r\n this.tempLoanRequired = this.loanCriteria.CI_Dev_LoanReq;\r\n if (this.loanCriteria.CI_Dev_LoanReq > 0) {\r\n this.isMaximumLoanRequired = false;\r\n }\r\n this.isDIPClicked = this.loanCriteria.IsFullCase;\r\n }\r\n //check if associated user if so makes sense to login to give full functionality\r\n if (this.loanCriteria.UserId) {\r\n if (\r\n this.$cookies.get(\"access_token\") === null ||\r\n this.$cookies.get(\"access_token\") === undefined\r\n ) {\r\n if (this.loanCriteria.UserId == \"User Not logged in\") {\r\n this.warningOff = true;\r\n this.doubleWarningOff = true;\r\n (this.$rootScope as any).loanCriteria = null;\r\n this.$location.path(\"/loginandreturnto/\");\r\n } else {\r\n this.$location.path(\"/loginandreturnto/\");\r\n }\r\n }\r\n }\r\n if (results.LenderResultSet) {\r\n this.matchingResults = results.LenderResultSet.MatchingResults;\r\n this.allResults.push({\r\n order: 1,\r\n name: \"Matching Results\",\r\n template:\r\n \"/views/partials/lender-results-mobile-table-row.html\",\r\n headerTemplate:\r\n \"/views/partials/lender-results-mobile-table-header.html\",\r\n array: this.matchingResults,\r\n });\r\n\r\n this.largestResults = results.LenderResultSet.LargestLoanResults;\r\n this.allResults.push({\r\n order: 2,\r\n name: \"Alternative Options\",\r\n template:\r\n \"/views/partials/lender-results-mobile-largest-table-row.html\",\r\n headerTemplate:\r\n \"/views/partials/lender-results-mobile-largest-table-header.html\",\r\n array: this.largestResults,\r\n });\r\n\r\n this.summarySearchResults =\r\n results.LenderResultSet.CombinedSummaryResultSet;\r\n\r\n this.sortSummaryResults();\r\n }\r\n })\r\n .finally(() => {\r\n this.fetchingLargest = false;\r\n this.fetchingMatches = false;\r\n this.hasResultsProcessed = true;\r\n });\r\n }\r\n }\r\n //if called from introduced client link\r\n else if (this.$location.path().startsWith(\"/referredSearch\")) {\r\n if (\r\n this.$routeParams.uniqueId !== undefined &&\r\n this.$routeParams.uniqueId != \"null\"\r\n ) {\r\n this.isreferredSearch = true;\r\n if (this.$routeParams.showOnlyRegister == \"true\") {\r\n this.showOnlyRegisterButton = true;\r\n sessionStorage.setItem(\"userRole\", UserRoleEnum.Broker.toString());\r\n }\r\n //Pull DevelopmentInputWithNoLogin search results\r\n this.$DevelopmentInputWithNoLoginService\r\n .fetchByUniqueId(this.$routeParams.uniqueId)\r\n .then((results) => {\r\n if (!results) {\r\n if (this.isLoggedInUser) {\r\n this.displayMsg = `Changes have been made to this search by your client, you will now be taken back to your user dashboard`;\r\n } else {\r\n this.displayMsg = `Please contact your broker in order to access this case.`;\r\n }\r\n\r\n this.showMsgToAdminOrBroker = true;\r\n } else {\r\n this.loanCriteria = {} as DevelopmentInputDTO;\r\n (Object).assign(this.loanCriteria, results);\r\n\r\n //Prefill client details for popup\r\n this.confirmSaving = false;\r\n this.newUser.FirstName = results.IntroduceeFirstName;\r\n this.newUser.LastName = results.IntroduceeSurname;\r\n this.newUser.Email = results.IntroduceeEmail;\r\n this.newUser.PhoneNumber = results.IntroduceePhone;\r\n\r\n if (this.loanCriteria) {\r\n this.isDIPClicked = this.loanCriteria.IsFullCase;\r\n this.tempLoanRequired = this.loanCriteria.CI_Dev_LoanReq;\r\n if (this.loanCriteria.CI_Dev_LoanReq > 0) {\r\n this.isMaximumLoanRequired = false;\r\n }\r\n if (this.isClient) {\r\n this.loanCriteria.UserId = this.loanCriteria.UserId\r\n ? this.loanCriteria.UserId\r\n : this.selectedUser.Id;\r\n this.loanCriteria.User = this.loanCriteria.User\r\n ? this.loanCriteria.User\r\n : this.selectedUser;\r\n this.loanCriteria.SaveQueryAndResults = true;\r\n }\r\n }\r\n\r\n if (this.$routeParams.showOnlyRegister == \"false\") {\r\n this.isClient = true;\r\n this.loanCriteria.SaveQueryAndResults = false;\r\n }\r\n\r\n if (this.isBroker || this.isAdmin) {\r\n this.loanCriteria.SaveQueryAndResults = true;\r\n }\r\n\r\n this.updateResults();\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n this.hasResultsProcessed = true;\r\n });\r\n }\r\n\r\n if (\r\n this.$routeParams.brokerOrgUniqueRef !== undefined &&\r\n this.$routeParams.brokerOrgUniqueRef != \"null\" &&\r\n this.$routeParams.brokerUserId !== undefined &&\r\n this.$routeParams.brokerUserId != \"null\"\r\n ) {\r\n if (this.selectedUser) {\r\n if (\r\n this.selectedUser.OrganisationReferralId == null &&\r\n this.selectedUser.DefaultBrokerOrganisationId == null\r\n ) {\r\n this.organisationService\r\n .getOrganisationIdByUniqueRef(\r\n this.$routeParams.brokerOrgUniqueRef,\r\n )\r\n .then((orgId: number) => {\r\n this.selectedUser.OrganisationReferralId = orgId;\r\n this.selectedUser.DefaultBrokerOrganisationId = orgId;\r\n this.$user.addUpdate(this.selectedUser);\r\n });\r\n }\r\n }\r\n }\r\n } else if (this.$location.path().startsWith(\"/securitycheck\")) {\r\n this.$location.path(\"/casedashboard/\" + this.$routeParams.caseId);\r\n }\r\n //if called with a saved entry\r\n else if (this.searchid) {\r\n this.loadingData = true;\r\n this.$DevelopmentInputService\r\n .fetch(this.searchid)\r\n .then((loanCriteria) => {\r\n if (loanCriteria.IsFullCase && this.isLoggedInUser && this.isClient) {\r\n this.$DevelopmentInputService\r\n .isUserHasAccessToCase(this.searchid)\r\n .then((response) => {\r\n if (!response) {\r\n this.hasAccessToDeal = false;\r\n this.displayMsg =\r\n \"Please contact your broker in order to access this case.\";\r\n this.showMsgToAdminOrBroker = true;\r\n } else {\r\n this.postLoanCriteriaRetrieveProcessing(loanCriteria);\r\n }\r\n });\r\n } else {\r\n this.postLoanCriteriaRetrieveProcessing(loanCriteria);\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n // We are no more storing loanCriteria as rootscope property when navigating to compare page.\r\n if (\r\n window.self == window.top &&\r\n sessionStorage.getItem(\"LoanCriteria\") &&\r\n (this.$rootScope as any).previousRoute.startsWith(\"/compare\")\r\n ) {\r\n this.loanCriteria = JSON.parse(sessionStorage.getItem(\"LoanCriteria\"));\r\n } else {\r\n // Pull our loan criteria from rootScope.\r\n this.loanCriteria = (this.$rootScope as any).loanCriteria;\r\n }\r\n\r\n // This block handles the reloading results for borrower(with out login) on refresh of page\r\n if (\r\n !this.loanCriteria &&\r\n window.self == window.top &&\r\n sessionStorage.getItem(\"loanCriteria\") &&\r\n !this.isLoggedInUser\r\n ) {\r\n this.loanCriteria = JSON.parse(sessionStorage.getItem(\"loanCriteria\"));\r\n } else if (\r\n window.self == window.top &&\r\n sessionStorage.getItem(\"loanCriteria\")\r\n ) {\r\n sessionStorage.removeItem(\"loanCriteria\");\r\n }\r\n\r\n if (this.loanCriteria) {\r\n this.tempLoanRequired = this.loanCriteria.CI_Dev_LoanReq;\r\n if (this.loanCriteria.CI_Dev_LoanReq > 0) {\r\n this.isMaximumLoanRequired = false;\r\n }\r\n this.isDIPClicked = this.loanCriteria.IsFullCase;\r\n }\r\n\r\n if (!this.loanCriteria) {\r\n this.$location.path(\"/\");\r\n } else {\r\n if (this.selectedUser) {\r\n this.loanCriteria.User = this.selectedUser;\r\n this.loanCriteria.UserId = this.selectedUser.Id;\r\n }\r\n\r\n if (\r\n !this.loanCriteria.Id &&\r\n window.self == window.top &&\r\n this.loanCriteria.SearchName &&\r\n !sessionStorage.getItem(\"searchuser\") &&\r\n (this.isAdmin || this.isBroker)\r\n ) {\r\n this.loadingData = true;\r\n this.$DevelopmentInputService\r\n .saveSearch(this.loanCriteria)\r\n .then((loanCriteria) => {\r\n this.warningOff = true;\r\n this.go(\"/results/\" + loanCriteria);\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else if (\r\n window.self == window.top &&\r\n sessionStorage.getItem(\"searchuser\")\r\n ) {\r\n let data = sessionStorage.getItem(\"searchuser\");\r\n let userdetails = JSON.parse(data);\r\n this.clientFirstName = userdetails.clientFirstName;\r\n this.clientSurname = userdetails.clientSurname;\r\n this.clientEmail = userdetails.clientEmail;\r\n this.clientPhoneNumber = userdetails.clientPhoneNumber;\r\n this.clientId = userdetails.clientId;\r\n this.existingborrower = userdetails.existingborrower;\r\n this.loanCriteria.SearchName = userdetails.searchName;\r\n if (this.existingborrower) {\r\n this.showClientDetails = true;\r\n this.loanCriteria.User = userdetails.clientUser;\r\n this.loanCriteria.UserId = this.clientId;\r\n } else {\r\n this.loanCriteria.User = this.selectedUser;\r\n this.loanCriteria.UserId = this.selectedUser.Id;\r\n }\r\n\r\n sessionStorage.removeItem(\"searchuser\");\r\n\r\n this.sendResultsToClient(false, true);\r\n }\r\n\r\n if (\r\n !this.loanCriteria.SearchName ||\r\n this.loanCriteria.SearchName.length == 0\r\n ) {\r\n this.loanCriteria.SearchName = this.defaultSearchName();\r\n }\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.updateResults();\r\n }\r\n }\r\n }\r\n\r\n assistanceSliderCall() {\r\n return this.assistanceSlider;\r\n }\r\n\r\n recalcCosts(updatedField: string): void {\r\n switch (updatedField) {\r\n case \"CI_Dev_BuildCosts\":\r\n this.recalcCostPerArea();\r\n break;\r\n case \"CI_Dev_Contingency\":\r\n this.recalcCostPerArea();\r\n break;\r\n case \"DC_AreaAcquisition\":\r\n this.recalcCostPerArea();\r\n break;\r\n }\r\n }\r\n\r\n recalcCostPerArea(): void {\r\n let res: number = 0;\r\n //Case 4 - recalc cost per sq. m\r\n if (\r\n this.loanCriteria.CI_Dev_BuildCosts &&\r\n this.loanCriteria.CI_Dev_Contingency &&\r\n this.loanCriteria.DC_AreaAcquisition\r\n ) {\r\n res =\r\n (this.loanCriteria.CI_Dev_BuildCosts *\r\n (1 + Number(this.loanCriteria.CI_Dev_Contingency))) /\r\n this.loanCriteria.DC_AreaAcquisition;\r\n this.loanCriteria.DC_BuildCostPerArea = res;\r\n\r\n if (\r\n this.loanCriteria.CI_EndPropType === PropertyTypeEnum.MixedUse ||\r\n this.loanCriteria.CI_EndPropType === PropertyTypeEnum.Residential\r\n ) {\r\n this.loanCriteria.DI_AreaSalesAreaResidential =\r\n this.loanCriteria.DC_AreaAcquisition;\r\n }\r\n if (this.loanCriteria.CI_EndPropType != PropertyTypeEnum.Residential) {\r\n this.loanCriteria.DI_AreaSalesAreaCommercial =\r\n this.loanCriteria.DC_AreaAcquisition;\r\n }\r\n }\r\n }\r\n\r\n newloan() {\r\n (this.$rootScope as any).loanCriteria = null;\r\n this.$location.path(\"/criteria/0/0/1\");\r\n }\r\n\r\n getTubeMapValue() {\r\n return this.$CaseService.getTubeMap();\r\n }\r\n\r\n updateResults(saveResults?: boolean, updateLoanLabels: boolean = false) {\r\n Promise.all([\r\n this.organisationService.getData(\"userDetails\").then((userDetails) => {\r\n if (userDetails) {\r\n this.userDetails = userDetails;\r\n this.user = JSON.parse(userDetails);\r\n }\r\n }),\r\n this.organisationService.getData(\"userRole\").then((userRole) => {\r\n if (userRole) {\r\n this.userRole = userRole;\r\n this.isClient = userRole == \"borrower\";\r\n }\r\n }),\r\n\r\n //Check if is a new search when inside iframe\r\n this.organisationService.getData(\"newSearch\").then((newSearch) => {\r\n if (newSearch) {\r\n this.snapshotNewSearch = newSearch == \"true\";\r\n }\r\n }),\r\n ])\r\n .then(() => {\r\n this.organisationService.sendDataToParent(\"newSearch\", \"false\");\r\n const originalSaveState = this.loanCriteria.SaveQueryAndResults;\r\n // If saveResults is set, override it temporarily.\r\n if (saveResults !== undefined) {\r\n this.loanCriteria.SaveQueryAndResults = false;\r\n }\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n this.fetchingLargest = true;\r\n this.fetchingMatches = true;\r\n\r\n //Determine whether we have a blank search & show message\r\n if (\r\n (this.loanCriteria.CI_Dev_OrigPP == 0 &&\r\n this.loanCriteria.CI_EndPropType == 0 &&\r\n this.loanCriteria.CI_GDV == 0 &&\r\n this.loanCriteria.CI_Dev_LoanReq == 0) ||\r\n this.loanCriteria.CI_GDV == 0 ||\r\n this.loanCriteria.CI_Dev_BuildTerm == 0 ||\r\n this.loanCriteria.CI_Dev_BuildCosts == 0 ||\r\n this.loanCriteria.CI_Dev_LoanTermReq == 0\r\n ) {\r\n this.isBlankSearch = true;\r\n this.loadingData = false;\r\n } else {\r\n this.isBlankSearch = false;\r\n let selectedResults: SelectedResultDTO[] =\r\n this.loanCriteria.SelectedResults || [];\r\n let rootScopeLoanCriteriaId = (this.$rootScope as any)?.loanCriteria\r\n ?.Id;\r\n\r\n if (\r\n window.self == window.top &&\r\n sessionStorage.getItem(\"LoanCriteria\") &&\r\n (this.$rootScope as any).previousRoute.startsWith(\"/compare\")\r\n ) {\r\n selectedResults = JSON.parse(\r\n sessionStorage.getItem(\"LoanCriteria\"),\r\n ).SelectedResults;\r\n //Removing the lsd data saved for compare view.\r\n sessionStorage.removeItem(\"LoanCriteria\");\r\n }\r\n\r\n if (\r\n !this.selectedUser.NewUserEmailJourneyStarted &&\r\n !this.searchid &&\r\n this.selectedUser.ApplicantDefinedRole == 0 &&\r\n !this.$routeParams.uniqueId\r\n ) {\r\n this.emailJourneyStarted = false;\r\n } else if (this.$routeParams.uniqueId) {\r\n this.emailJourneyStarted = true;\r\n } else {\r\n this.emailJourneyStarted = true;\r\n }\r\n\r\n var orgCode;\r\n\r\n if (window.self == window.top) {\r\n orgCode = this.$cookies.get(\"org_code\");\r\n } else {\r\n orgCode = location.pathname.replace(\"/\", \"\");\r\n }\r\n\r\n if (orgCode) {\r\n this.loanCriteria.ReferralOrgCode = orgCode;\r\n }\r\n\r\n if (window.self == window.top) {\r\n if (\r\n sessionStorage.getItem(\"userDetails\") &&\r\n sessionStorage.getItem(\"userRole\")\r\n ) {\r\n let role = sessionStorage.getItem(\"userRole\") == \"broker\";\r\n let data = sessionStorage.getItem(\"userDetails\");\r\n this.populateNewLeadInfo(role, data);\r\n }\r\n\r\n //Check if new search (not in iframe)\r\n this.snapshotNewSearch =\r\n sessionStorage.getItem(\"newSearch\") == \"true\";\r\n sessionStorage.setItem(\"newSearch\", \"false\");\r\n } else {\r\n if (this.userRole && this.userDetails) {\r\n let role = this.userRole == \"broker\";\r\n this.populateNewLeadInfo(role, this.userDetails);\r\n }\r\n }\r\n\r\n var criteriaChanged =\r\n this.hasCriteriaChanged || this.snapshotNewSearch;\r\n sessionStorage.setItem(\"newSearch\", \"false\");\r\n this.hasCriteriaChanged = false;\r\n this.snapshotNewSearch = false;\r\n\r\n this.$lenderresultservice\r\n .fetchMatchingResults(\r\n this.loanCriteria,\r\n true,\r\n true,\r\n 0,\r\n false,\r\n \"\",\r\n \"\",\r\n \"\",\r\n this.GetSelectedLabel(),\r\n this.emailJourneyStarted,\r\n this.debug1,\r\n this.roleService.getIsLenderVisible(),\r\n this.newLeadFirstName,\r\n this.newLeadEmail,\r\n this.orgCode,\r\n this.isreferredSearch,\r\n this.userRole,\r\n this.userDetails,\r\n criteriaChanged,\r\n )\r\n .then((results) => {\r\n this.results = results;\r\n if (!this.isLoggedInUser && !this.$routeParams.showOnlyRegister) {\r\n if (!this.user && !this.enterpriseClientId) {\r\n this.showEnterpriseRegistrationModal = true;\r\n document.getElementById(\"body\").style.overflow = \"hidden\";\r\n }\r\n }\r\n\r\n if (this.results.DevelopmentInputWithNoLoginUniqueRef) {\r\n this.loanCriteria.UniqueRef =\r\n this.results.DevelopmentInputWithNoLoginUniqueRef;\r\n\r\n if (!this.isLoggedInUser) {\r\n this.getOrganisationAndBrokerDetails();\r\n sessionStorage.setItem(\r\n \"loanCriteria\",\r\n JSON.stringify(this.loanCriteria),\r\n );\r\n if (!this.user && this.enterpriseClientId) {\r\n this.addClientAndRenameDeal();\r\n }\r\n }\r\n this.eventLogService.logPageLoad(\r\n \"LENDERRESULTS\",\r\n this.orgCode,\r\n this.loanCriteria?.IntroduceeEmail,\r\n \"borrower\",\r\n this.loanCriteria.OrganisationLinkId != null\r\n ? this.loanCriteria.OrganisationLinkId\r\n : 0,\r\n ProductTypeEnum.Development,\r\n this.loanCriteria?.UniqueRef,\r\n );\r\n }\r\n\r\n if (!this.isLoggedInUser && this.$routeParams.showOnlyRegister) {\r\n this.getOrganisationAndBrokerDetails();\r\n this.eventLogService.logPageLoad(\r\n \"LENDERRESULTS-USING-EMAIL-LINK\",\r\n this.orgCode,\r\n this.loanCriteria?.IntroduceeEmail,\r\n \"borrower\",\r\n this.loanCriteria.OrganisationLinkId != null\r\n ? this.loanCriteria.OrganisationLinkId\r\n : 0,\r\n ProductTypeEnum.Development,\r\n this.$routeParams.uniqueId,\r\n );\r\n }\r\n\r\n if (\r\n this.isLoggedInUser &&\r\n results.Id > 0 &&\r\n this.isClient &&\r\n this.$location.path().startsWith(\"/referredSearch\") &&\r\n this.$routeParams.uniqueId !== undefined &&\r\n this.$routeParams.uniqueId != \"null\"\r\n ) {\r\n this.eventLogService.logPageLoad(\r\n \"AFTER-BORROWER-REGISTRATION\",\r\n this.orgCode,\r\n this.selectedUser.UserName,\r\n \"borrower\",\r\n this.loanCriteria.OrganisationLinkId,\r\n ProductTypeEnum.Development,\r\n this.$routeParams.uniqueId,\r\n );\r\n this.go(\"/results/\" + results.Id);\r\n }\r\n\r\n this.matchingResults = results.MatchingResults;\r\n this.largestResults = results.LargestLoanResults;\r\n this.allResults.push({\r\n order: 1,\r\n name: \"Matching Results\",\r\n array: this.matchingResults,\r\n template:\r\n \"/views/partials/lender-results-mobile-table-row.html\",\r\n headerTemplate:\r\n \"/views/partials/lender-results-mobile-table-header.html\",\r\n });\r\n this.allResults.push({\r\n order: 2,\r\n name: \"Alternative Options\",\r\n array: this.largestResults,\r\n template:\r\n \"/views/partials/lender-results-mobile-largest-table-row.html\",\r\n headerTemplate:\r\n \"/views/partials/lender-results-mobile-largest-table-header.html\",\r\n });\r\n\r\n this.summarySearchResults = results.CombinedSummaryResultSet;\r\n\r\n this.sortSummaryResults();\r\n\r\n if (\r\n rootScopeLoanCriteriaId &&\r\n selectedResults &&\r\n selectedResults.length > 0\r\n ) {\r\n this.loanCriteria.SelectedResults = selectedResults;\r\n }\r\n\r\n if (\r\n this.searchid &&\r\n !this.selectedUser.NewUserEmailJourneyStarted &&\r\n this.selectedUser.ApplicantDefinedRole == 0\r\n ) {\r\n this.$lenderresultservice\r\n .startNewUserSearchEmail(\r\n this.loanCriteria.UniqueRef,\r\n results.MatchingResults.length,\r\n results.LargestLoanResults.length,\r\n )\r\n .then((results) => {\r\n if (results) {\r\n this.selectedUser.NewUserEmailJourneyStarted = true;\r\n }\r\n });\r\n }\r\n this.restoreSelectedItems(selectedResults);\r\n })\r\n .catch((error) => {\r\n //this.matchingResults = [];\r\n //this.largestResults = [];\r\n })\r\n .finally(() => {\r\n this.fetchingLargest = false;\r\n this.fetchingMatches = false;\r\n this.loanCriteria.SaveQueryAndResults = originalSaveState;\r\n\r\n if (updateLoanLabels) {\r\n this.updateLoanLabels();\r\n }\r\n\r\n this.loadingData = false;\r\n this.isFilterUpdate = false;\r\n });\r\n }\r\n })\r\n .catch((error) => {\r\n // One or both of the promises were rejected, handle the error\r\n console.error(\"Failed to get user data: \", error);\r\n });\r\n }\r\n\r\n /**Update the loan label in the comparison results based on the loan label returned in the results\r\n * Primary purpose is to update the loan label when the show lender names button is toggled\r\n * */\r\n updateLoanLabels() {\r\n for (var i = 0; i < this.comparisonList.length; i++) {\r\n let resultIndex = this.summarySearchResults.findIndex(\r\n (item) => item.ProductID == this.comparisonList[i].SeniorProductID,\r\n );\r\n\r\n if (resultIndex > -1) {\r\n this.comparisonList[i].LoanLabel =\r\n this.summarySearchResults[resultIndex].LoanLabel;\r\n }\r\n }\r\n\r\n //This is user for shortlisting pdf\r\n this.prepareDataForShortlistPdf();\r\n }\r\n\r\n populateNewLeadInfo(role, data) {\r\n let userdetails = JSON.parse(data);\r\n let userFullName = userdetails.FullName;\r\n let spaceIndex = userFullName.indexOf(\" \");\r\n\r\n let firstName = \"\";\r\n let lastName = \"\";\r\n\r\n // if not space has been added to the name then put the whole name in the first name field\r\n if (spaceIndex == -1) {\r\n firstName = userFullName;\r\n } else {\r\n firstName = userFullName.substring(0, userFullName.indexOf(\" \"));\r\n lastName = userFullName.substring(userFullName.indexOf(\" \") + 1);\r\n }\r\n\r\n this.newLeadFirstName = firstName;\r\n this.newLeadLastName = lastName;\r\n this.newLeadEmail = userdetails.Email;\r\n }\r\n\r\n restoreSelectedItems(selectedResults: SelectedResultDTO[]) {\r\n if (selectedResults) {\r\n selectedResults.forEach((item, index) => {\r\n let match;\r\n var found = false;\r\n // first compare whether the selectedResultDTO is already an active caseLender record, if so it MUST be kept\r\n if (this.caseLenders) {\r\n found = this.caseLenders.some((cl) => cl.ProductID == item.ProductId);\r\n }\r\n\r\n if (!found) {\r\n found = this.summarySearchResults.some(\r\n (result) =>\r\n result.ProductID === item.ProductId &&\r\n result.CaseLenderStatus != CaseLenderStateEnum.Rejected &&\r\n result.CaseLenderStatus != CaseLenderStateEnum.Withdrawn,\r\n );\r\n }\r\n // Keeping this here rather than using summarySearchResults (above) because otherwise comparison etc stops working as it relies on using LenderResultMinimalDTO\r\n if (found) {\r\n if (item.MenuId === 1) {\r\n match = this.matchingResults.find(\r\n (result) =>\r\n result.SeniorProductID === item.ProductId &&\r\n result.CalculatedBasedOnMatchingLoan === true,\r\n );\r\n } else if (item.MenuId === 2) {\r\n match = this.largestResults.find(\r\n (result) =>\r\n result.SeniorProductID === item.ProductId &&\r\n result.CalculatedBasedOnMatchingLoan === false,\r\n );\r\n }\r\n }\r\n\r\n if (match) {\r\n /* 'this.isFilterUpdate' condition is to fix the issue with wrong number display beside toggle button when using filter*/\r\n if (this.isFilterUpdate) {\r\n var comparematch = this.comparisonList.filter(\r\n (result) => result.SeniorProductID == item.ProductId,\r\n );\r\n var index = this.comparisonList.indexOf(comparematch[0]);\r\n if (index !== -1) {\r\n this.comparisonList[index] = match;\r\n } else {\r\n this.comparisonList.push(match);\r\n }\r\n } else {\r\n this.comparisonList.push(match);\r\n }\r\n\r\n if (index === 0) {\r\n this.selectedResultForAttachingToCase = match;\r\n }\r\n }\r\n });\r\n }\r\n }\r\n\r\n //Show whose account is being accessed if admin is accessing client\r\n getEmailOfClientBeingAccessed(): string {\r\n if (\r\n this.selectedUser &&\r\n this.loanCriteria &&\r\n this.selectedUser.Id !== this.loanCriteria.UserId\r\n ) {\r\n return this.loanCriteria.OwnerUser;\r\n }\r\n }\r\n\r\n indexPopup(methodName: string) {\r\n this.$rootScope.$broadcast(methodName);\r\n }\r\n\r\n agreeTerms() {\r\n if (!this.selectedUser.Id) {\r\n //new user who opted in to receiving emails, socapture details\r\n this.loadingData = true;\r\n this.newUser.UserName = this.newUser.Email;\r\n this.newUser.LenderResultsTermsAgreed = true;\r\n this.newUser.AgreedToTermsAndPP = true;\r\n this.newUser.Roles = [\"Client\"];\r\n\r\n var orgCode;\r\n if (window.self == window.top) {\r\n orgCode = this.$cookies.get(\"org_code\");\r\n } else {\r\n orgCode = location.pathname.replace(\"/\", \"\");\r\n }\r\n if (orgCode) {\r\n this.newUser.ReferralOrgCode = orgCode;\r\n }\r\n\r\n // If we have an introducer code, let's set it.\r\n if (this.$cookies.get(\"introducer_code\")) {\r\n this.newUser.IntroducerCode = this.$cookies.get(\"introducer_code\");\r\n this.createTemporalyUser();\r\n } else {\r\n if (this.$cookies.get(\"invite_code\")) {\r\n this.guid = this.$cookies.get(\"invite_code\");\r\n }\r\n this.inviteService\r\n .checkIfRegisterUserWasInvited(this.newUser.Email, this.guid)\r\n .then((result) => {\r\n this.newUser.IntroducerCode = result;\r\n this.createTemporalyUser();\r\n });\r\n }\r\n } else if (\r\n this.selectedUser.Id &&\r\n !this.selectedUser.NewUserEmailJourneyStarted &&\r\n this.selectedUser.ApplicantDefinedRole == 0\r\n ) {\r\n this.loadingData = true;\r\n this.selectedUser.LenderResultsTermsAgreed = true;\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.loadingData = true;\r\n this.$user\r\n .addUpdate(this.selectedUser)\r\n .then((response) => {\r\n this.loanCriteria.UserId = this.selectedUser.Id;\r\n this.loanCriteria.User = this.selectedUser;\r\n this.loanCriteria.SaveQueryAndResults = true;\r\n this.loanCriteria.SelectedResults = [];\r\n if (this.selectedUser.OrganisationReferralId != null) {\r\n this.loanCriteria.BrokerOrganisationId =\r\n this.selectedUser.OrganisationReferralId;\r\n }\r\n\r\n this.$DevelopmentInputService\r\n .saveSearch(this.loanCriteria)\r\n .then((savedSearchId) => {\r\n this.warningOff = true;\r\n this.go(\"/results/\" + savedSearchId);\r\n });\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n } else {\r\n //Logged in user, persist agreement to terms; persist that terms agreed.\r\n this.loadingData = true;\r\n this.selectedUser.LenderResultsTermsAgreed = true;\r\n\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.loadingData = true;\r\n this.$user\r\n .addUpdate(this.selectedUser)\r\n .then((response) => { })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n //if user is not logged in, make a note in rootScope not to show this message during this session\r\n if (!this.selectedUser.Id) {\r\n (this.$rootScope as any).lenderResultsIntroSeen = true;\r\n }\r\n }\r\n\r\n createTemporalyUser() {\r\n this.$user\r\n .createtemporaryuser(this.newUser)\r\n .then((user) => {\r\n this.newUser.ApplicantDefinedRole == 0;\r\n this.newUser.Roles = [];\r\n this.newUser.Roles.push(\"Client\");\r\n (this.$rootScope as any).selectedUser = user;\r\n this.$auth\r\n .login(\r\n this.newUser.Email,\r\n user.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n let expiry: Date = response;\r\n\r\n this.$cookies.put(\"user_firstname\", user.FirstName, {\r\n expires: expiry,\r\n });\r\n //Add loan to newly created temporary account\r\n this.loanCriteria.UserId = user.Id;\r\n this.loanCriteria.User = user;\r\n this.loanCriteria.SaveQueryAndResults = true;\r\n this.loanCriteria.SelectedResults = [];\r\n\r\n this.loanCriteria.BrokerOrganisationId =\r\n user.DefaultBrokerOrganisationId;\r\n\r\n if (\r\n this.$routeParams.brokerUserId !== undefined &&\r\n this.$routeParams.brokerUserId != \"null\"\r\n ) {\r\n this.loanCriteria.BrokerUserId = this.$routeParams.brokerUserId;\r\n }\r\n\r\n if (this.$cookies.get(\"invite_code\")) {\r\n this.inviteService.checkIfInvitedIsUser(\r\n this.$cookies.get(\"invite_code\"),\r\n user.Id,\r\n );\r\n }\r\n\r\n this.$DevelopmentInputService\r\n .saveSearch(this.loanCriteria)\r\n .then((savedSearchId) => {\r\n this.warningOff = true;\r\n this.go(\"/results/\" + savedSearchId);\r\n });\r\n });\r\n })\r\n .catch((response) => {\r\n this.error = response.data;\r\n this.newUser.LenderResultsTermsAgreed = false;\r\n this.newUser.AgreedToTermsAndPP = false;\r\n (this.$rootScope as any).lenderResultsIntroSeen = false;\r\n this.loadingData = false;\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n lenderResultsIntroSeen(): boolean {\r\n if ((this.$rootScope as any).lenderResultsIntroSeen) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n captureNewUserEmail(): void {\r\n this.loadingData = true;\r\n }\r\n\r\n getCase() {\r\n this.loadingData = true;\r\n this.$CaseService\r\n .fetch(this.$routeParams.CaseId)\r\n .then((result) => {\r\n this.currentCase = result;\r\n this.productId = result.ProductID;\r\n this.productResultList = result.ProductResultList;\r\n this.caseLenderService\r\n .fetchByCaseId(this.currentCase.Id)\r\n .then((result) => {\r\n if (result) {\r\n this.caseLenders = result.filter(\r\n (cl) =>\r\n cl.CaseLenderState != CaseLenderStateEnum.Withdrawn &&\r\n cl.CaseLenderState != CaseLenderStateEnum.Rejected,\r\n );\r\n }\r\n });\r\n if (result.CaseStatus == 0 || result.CaseStatus == 1) {\r\n this.$CaseService.updateTubeMap(CaseStatusEnum.InProgress);\r\n } else {\r\n this.$CaseService.updateTubeMap(result.CaseStatus);\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n getCaseFromSearch(searchId: number) {\r\n this.$CaseService\r\n .getcasefromsearch(searchId)\r\n .then((result) => {\r\n this.currentCase = result;\r\n this.caseid = result.Id;\r\n if (this.caseid) {\r\n this.isDIPClicked = true;\r\n }\r\n this.productId = result.ProductID;\r\n this.productResultList = result.ProductResultList;\r\n\r\n if (result.CaseStatus == 0 || result.CaseStatus == 1) {\r\n this.$CaseService.updateTubeMap(CaseStatusEnum.InProgress);\r\n } else {\r\n this.$CaseService.updateTubeMap(result.CaseStatus);\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n // updateGuidanceState() {\r\n // this.guidanceCheckbox =\r\n // this.$cookies.get(\"guidance\") === \"on\" ||\r\n // this.$cookies.get(\"guidance\") === undefined;\r\n\r\n // // Update tour settings\r\n // let tourEnabled = this.$cookies.get(\"tourEnabled\");\r\n // if (\r\n // (tourEnabled == \"true\" || tourEnabled === undefined) &&\r\n // this.guidanceCheckbox\r\n // ) {\r\n // this.tourEnabled = true;\r\n // } else {\r\n // this.tourEnabled = false;\r\n // }\r\n\r\n // //if (this.guidanceCheckbox) {\r\n // // this.startTour();\r\n // //}\r\n // }\r\n\r\n // turnOffGuidance() {\r\n // this.guidanceCheckbox = false;\r\n // var expiryDate = new Date();\r\n // expiryDate.setDate(expiryDate.getDate() + 365);\r\n // this.$cookies.put(\"guidance\", \"off\", { expires: expiryDate });\r\n // this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n // }\r\n\r\n // getGuidanceSwitchState() {\r\n // if (!this.$cookies.get(\"guidance\")) {\r\n // this.guidanceCheckbox = true;\r\n // } else if (this.$cookies.get(\"guidance\") === \"on\") {\r\n // this.guidanceCheckbox = true;\r\n // } else if (this.$cookies.get(\"guidance\") === \"off\") {\r\n // this.guidanceCheckbox = false;\r\n // } else {\r\n // this.guidanceCheckbox = true;\r\n // }\r\n // return this.guidanceCheckbox;\r\n // }\r\n\r\n // recordGuidanceCookie() {\r\n // var guidanceSwitchState: string;\r\n // var expiryDate = new Date();\r\n // expiryDate.setDate(expiryDate.getDate() + 365);\r\n // if (this.guidanceCheckbox == true) {\r\n // guidanceSwitchState = \"on\";\r\n // } else {\r\n // guidanceSwitchState = \"off\";\r\n // }\r\n // this.$cookies.put(\"guidance\", guidanceSwitchState, { expires: expiryDate });\r\n // this.$rootScope.$broadcast(\"guidanceStateChanged\");\r\n // }\r\n\r\n //updateCase(offer: LenderResultMinimalDTO, productResultList: number) {\r\n // this.switchingProduct = true;\r\n // this.selectedResultForAttachingToCase = offer;\r\n // this.caseUpdated = true;\r\n // this.loadingData = true;\r\n // this.$CaseService.setProductOnCase(this.caseid, this.selectedResultForAttachingToCase.Id, productResultList).then((response) => {\r\n // if (response === true) {\r\n // this.currentProductOnCase = this.selectedResultForAttachingToCase.LoanLabel;\r\n // this.productId = this.selectedResultForAttachingToCase.Id;\r\n // this.productResultList = productResultList;\r\n // }\r\n // }).finally(() => {\r\n // this.loadingData = false;\r\n // this.switchingProduct = false;\r\n // this.returnToCase();\r\n // });\r\n //}\r\n\r\n setSelectedItem(offer: LenderResultMinimalDTO) {\r\n this.matchingResults.forEach((item) => {\r\n item.SelectedItem = false;\r\n });\r\n this.largestResults.forEach((item) => {\r\n item.SelectedItem = false;\r\n });\r\n offer.SelectedItem = true;\r\n this.selectedResultForAttachingToCase = offer;\r\n }\r\n\r\n toggleMezzanine() {\r\n this.mezzanineLenders = !this.mezzanineLenders;\r\n this.fetchingMezzanine = true;\r\n // Do some stuff\r\n }\r\n\r\n toggleEquity() {\r\n this.equityLenders = !this.equityLenders;\r\n this.fetchingEquity = true;\r\n // Do some stuff\r\n }\r\n\r\n comparisonContains(item: LenderResultSummaryDTO): boolean {\r\n var match = this.getLenderResultMinimalDTO(item);\r\n\r\n let found = !!this.comparisonList.find((result, index) => {\r\n return result === match;\r\n });\r\n\r\n if (found) {\r\n }\r\n\r\n return found;\r\n }\r\n\r\n checkLender(item: LenderResultSummaryDTO): boolean {\r\n if (this.userLenderId == item.LenderID) return true;\r\n return false;\r\n }\r\n\r\n selectionOrderNumber(item: LenderResultSummaryDTO) {\r\n //let found = !!this.comparisonList.find((result, index) => {\r\n // return result === item;\r\n //});\r\n var match = this.getLenderResultMinimalDTO(item);\r\n var order = this.comparisonList.indexOf(match) + 1;\r\n\r\n if (order === 0) {\r\n return \" \";\r\n }\r\n\r\n /* Adds number of active applications */\r\n return (\r\n order +\r\n (this.caseLendersNotInResults ? this.caseLendersNotInResults.length : 0)\r\n );\r\n }\r\n\r\n toggleLenderComparisonSelection(item: LenderResultSummaryDTO) {\r\n /** This will check if the result shared with new user is active */\r\n var isActive = this.isResultActive();\r\n\r\n if (isActive) {\r\n // Find Lender offer within the original arrays to use on the compare view\r\n var match = this.getLenderResultMinimalDTO(item);\r\n\r\n var menuId = match.CalculatedBasedOnMatchingLoan === true ? 1 : 2;\r\n\r\n if (this.loanCriteria) {\r\n if (!this.loanCriteria.SelectedResults) {\r\n this.loanCriteria.SelectedResults = [];\r\n }\r\n let selectedResultMatches: SelectedResultDTO[] =\r\n this.loanCriteria.SelectedResults.filter((result, index) => {\r\n return (\r\n result.ProductId === match.SeniorProductID &&\r\n result.MenuId === menuId\r\n );\r\n });\r\n\r\n let comparisonMatches: LenderResultMinimalDTO[] =\r\n this.comparisonList.filter((result, index) => {\r\n return result === match;\r\n });\r\n\r\n // Handle selected results for comparison or selection.\r\n if (!selectedResultMatches || selectedResultMatches.length === 0) {\r\n this.loanCriteria.SelectedResults.push({\r\n ProductId: match.SeniorProductID,\r\n DevelopmentInputId: this.loanCriteria.Id,\r\n MenuId: menuId,\r\n } as SelectedResultDTO);\r\n // If this is the first item, let's mark it as the selectedItem\r\n if (this.loanCriteria.SelectedResults.length === 1) {\r\n this.productResultList = menuId;\r\n this.setSelectedItem(match);\r\n }\r\n } else {\r\n selectedResultMatches.forEach((value, index) => {\r\n this.loanCriteria.SelectedResults.splice(\r\n this.loanCriteria.SelectedResults.indexOf(value),\r\n 1,\r\n );\r\n });\r\n }\r\n\r\n if (!comparisonMatches || comparisonMatches.length === 0) {\r\n this.comparisonList.push(match);\r\n this.eventLogService.logEvent(\r\n `SHORTLISTING-RESULT`,\r\n EventLogEnum.Shortlisting,\r\n ProductTypeEnum.Development,\r\n this.$routeParams.uniqueId ? 0 : this.loanCriteria.Id,\r\n this.$routeParams.uniqueId ? this.$routeParams.uniqueId : \"\",\r\n item.ProductID.toString()\r\n );\r\n } else {\r\n comparisonMatches.forEach((value, index) => {\r\n this.comparisonList.splice(this.comparisonList.indexOf(value), 1);\r\n });\r\n this.eventLogService.logEvent(\r\n `DESELECTING-SHORTHLISTED-RESULT`,\r\n EventLogEnum.Shortlisting,\r\n ProductTypeEnum.Development,\r\n this.$routeParams.uniqueId ? 0 : this.loanCriteria.Id,\r\n this.$routeParams.uniqueId ? this.$routeParams.uniqueId : \"\",\r\n item.ProductID.toString()\r\n );\r\n }\r\n }\r\n }\r\n\r\n this.loanCriteria.ComparisonList = this.comparisonList;\r\n }\r\n\r\n viewOffer(offer: LenderResultDTO) {\r\n this.selectedResult = offer;\r\n }\r\n\r\n goCompare() {\r\n /** This will check if the result shared with new user is active */\r\n var isActive = this.isResultActive();\r\n if (isActive) {\r\n this.warningOff = true;\r\n //We are setting this value to avoid displaying save modal while navigating to compare screen without saving search\r\n this.doubleWarningOff = true;\r\n // Makeing sure all the old data is deleted\r\n sessionStorage.removeItem(\"LoanCriteria\");\r\n sessionStorage.removeItem(\"UniqueId\");\r\n sessionStorage.removeItem(\"ComparisonList\");\r\n sessionStorage.removeItem(\"TempSavedResults\");\r\n\r\n sessionStorage.setItem(\r\n \"ComparisonList\",\r\n JSON.stringify(this.getSummaryComparisonList()),\r\n );\r\n sessionStorage.setItem(\"LoanCriteria\", JSON.stringify(this.loanCriteria));\r\n\r\n if (this.uniqueId) {\r\n sessionStorage.setItem(\"UniqueId\", this.uniqueId);\r\n }\r\n\r\n // temporarily put all results into saved results so the comparison controller can use them.\r\n\r\n let allResults: LenderResultMinimalDTO[] = [];\r\n this.matchingResults.forEach((result) => {\r\n allResults.push(result);\r\n });\r\n this.largestResults.forEach((result) => {\r\n allResults.push(result);\r\n });\r\n\r\n sessionStorage.setItem(\"TempSavedResults\", JSON.stringify(allResults));\r\n\r\n if (this.searchid && this.caseid) {\r\n this.$location.path(\"compare/\" + this.searchid + \"/\" + this.caseid);\r\n } else if (this.searchid) {\r\n this.$location.path(\"compare/\" + this.searchid);\r\n } else {\r\n this.$location.path(\"compare/\");\r\n }\r\n }\r\n }\r\n\r\n viewSingleLoan(item: LenderResultSummaryDTO) {\r\n event.preventDefault(); // prevents default behaviour of href\r\n this.warningOff = true;\r\n\r\n //Removed in favour of summaryComparisonList\r\n //this.comparisonList = [];\r\n\r\n //// Find Lender offer within the original arrays to use on the compare view\r\n //var match = this.getLenderResultMinimalDTO(item);\r\n\r\n //this.comparisonList.push(match);\r\n\r\n this.summaryComparisonList = [];\r\n this.summaryComparisonList.push(item);\r\n\r\n this.goCompare();\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n }\r\n\r\n /**\r\n * Processes the clicking of the \"View Eligibility\" anchor/button and index to show on the row number\r\n * @param item and index\r\n */\r\n viewEligibility(item: LenderResultSummaryDTO) {\r\n event.preventDefault(); // prevents default behaviour of href\r\n this.showProductNote = true;\r\n this.offer = item;\r\n this.loanLabel = item.LoanLabel;\r\n this.productNote = item.AdditionalProductInfo;\r\n }\r\n\r\n returnToCase() {\r\n if (this.comparisonList.length > 0) {\r\n this.loadingData = true;\r\n this.loanCriteria.SaveQueryAndResults = true;\r\n this.$lenderresultservice\r\n .fetchMatchingResults(\r\n this.loanCriteria,\r\n true,\r\n true,\r\n 0,\r\n false,\r\n \"\",\r\n \"\",\r\n \"\",\r\n this.GetSelectedLabel(),\r\n )\r\n .then((response) => {\r\n if (this.isShortlistingMore) {\r\n // copy newly selected products/lenders to caselender\r\n this.$CaseService\r\n .shortlistMoreLenders(this.caseid, this.hasSearchChanged)\r\n .then((response) => {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n });\r\n } else {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n }\r\n }\r\n\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n goWarningOff(path): void {\r\n this.warningOff = true;\r\n LoginController.searchInProgress = true;\r\n (this.$rootScope as any).loginRedirectPath = this.$location.url();\r\n this.go(path);\r\n }\r\n\r\n backToClientSearches(): void {\r\n (this.$rootScope as any).clientUsernameBeingViewed =\r\n this.loanCriteria.OwnerUser;\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.go(\"/userdashboard\");\r\n }\r\n\r\n //setSelectedResultsFromComparisonList() {\r\n // this.loanCriteria.SelectedResults = this.comparisonList.map((item, index) => {\r\n // return {\r\n // DevelopmentInputId: item.DevelopmentInputID,\r\n // ProductId: item.SeniorProductID,\r\n // MenuId: null\r\n // } as SelectedResultDTO;\r\n // });\r\n //}\r\n\r\n register(\r\n createCase: boolean = false,\r\n productResultList: number,\r\n introducingAClient?: boolean,\r\n preventRedirect?: boolean,\r\n ) {\r\n this.loadingData = true;\r\n this.isProceedClicked = true;\r\n // Set the selected or \"preferred\" result.\r\n productResultList = this.productResultList;\r\n\r\n //this.setSelectedResultsFromComparisonList();\r\n (this.$rootScope as any).productResultList = productResultList;\r\n if (!this.selectedUser.Id || this.selectedUser.Id === null) {\r\n (this.$rootScope as any).selectedResultForAttachingToCase =\r\n this.selectedResultForAttachingToCase;\r\n this.loanCriteria.SaveCase = createCase;\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n var path: string = \"/register\";\r\n\r\n if (\r\n this.$routeParams.brokerOrgUniqueRef !== undefined &&\r\n this.$routeParams.brokerOrgUniqueRef != \"null\" &&\r\n this.$routeParams.brokerUserId !== undefined &&\r\n this.$routeParams.brokerUserId != \"null\"\r\n ) {\r\n path +=\r\n \"/\" +\r\n this.$routeParams.brokerOrgUniqueRef +\r\n \"/\" +\r\n this.$routeParams.brokerUserId;\r\n }\r\n\r\n this.$location.path(path);\r\n } else {\r\n this.loanCriteria.UserId = this.loanCriteria.UserId\r\n ? this.loanCriteria.UserId\r\n : this.selectedUser.Id;\r\n this.loanCriteria.User = this.loanCriteria.User\r\n ? this.loanCriteria.User\r\n : this.selectedUser;\r\n this.loanCriteria.SaveQueryAndResults = true;\r\n this.loanCriteria.SaveCase = createCase;\r\n if (this.isLender) {\r\n this.loanCriteria.LenderUserId = this.selectedUser.Id;\r\n }\r\n // if broker info has been sent to the page then set this to the search\r\n if (\r\n this.$routeParams.brokerOrgUniqueRef !== undefined &&\r\n this.$routeParams.brokerOrgUniqueRef != \"null\"\r\n ) {\r\n this.organisationService\r\n .getOrganisationIdByUniqueRef(this.$routeParams.brokerOrgUniqueRef)\r\n .then((orgId: number) => {\r\n this.loanCriteria.BrokerOrganisationId = orgId;\r\n\r\n if (\r\n this.$routeParams.brokerUserId !== undefined &&\r\n this.$routeParams.brokerUserId != \"null\"\r\n ) {\r\n this.loanCriteria.BrokerUserId = this.$routeParams.brokerUserId;\r\n } else {\r\n this.$user\r\n .GetOrganisationAdminUserId(orgId)\r\n .then((adminUserId: string) => {\r\n this.loanCriteria.BrokerUserId = adminUserId;\r\n });\r\n }\r\n\r\n // Save Search\r\n this.saveSearch(createCase, productResultList, preventRedirect);\r\n });\r\n } else {\r\n // Save Search\r\n this.saveSearch(createCase, productResultList, preventRedirect);\r\n }\r\n if (createCase == true) {\r\n this.loanCriteria.IsFullCase = true;\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n }\r\n }\r\n }\r\n\r\n saveSearch(\r\n createCase: boolean,\r\n productResultList: number,\r\n preventRedirect?: boolean,\r\n ) {\r\n if (this.selectedResultForAttachingToCase) {\r\n this.loanCriteria.SelectedProduct =\r\n this.selectedResultForAttachingToCase.LI_LoanProduct;\r\n }\r\n this.loadingData = true;\r\n // We always want to save at this point.\r\n this.loanCriteria.SaveQueryAndResults = true;\r\n if (this.searchName != null && this.searchName.length > 0) {\r\n this.loanCriteria.SearchName = this.searchName;\r\n }\r\n this.$lenderresultservice\r\n .fetchMatchingResults(\r\n this.loanCriteria,\r\n true,\r\n true,\r\n 0,\r\n false,\r\n \"\",\r\n \"\",\r\n \"\",\r\n this.GetSelectedLabel(),\r\n )\r\n .then((response) => {\r\n this.tempLoanCriteria = { ...this.loanCriteria };\r\n if (createCase === true) {\r\n //case creation\r\n //this.sendEnquiry();\r\n this.$CaseService\r\n .promoteandmigratetodeal(\r\n response.Id,\r\n this.selectedResultForAttachingToCase.LI_LoanProduct,\r\n productResultList,\r\n )\r\n .then((newCaseId) => {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 365);\r\n this.$cookies.remove(\"caseLandingDontShowAgain\");\r\n //this.$CaseService.getcasefromsearch(response.Id).then((caseobject) => {\r\n if (newCaseId) {\r\n this.$location.path(\r\n \"/devfinancecasedashboard/\" + newCaseId + \"/\" + true,\r\n );\r\n } else {\r\n this.isProceedClicked = false;\r\n }\r\n //});\r\n })\r\n .catch((response) => {\r\n this.isProceedClicked = false;\r\n });\r\n } else {\r\n //if (introducingAClient) {\r\n // this.introducerSendResultsToClient(response.Id);\r\n //} else {\r\n\r\n if (!preventRedirect) {\r\n if (\r\n (this.isSaveorSaveAsClicked || this.isSaveClientSearch) &&\r\n this.selectedUser.TemporaryAccount != true\r\n ) {\r\n this.doubleWarningOff = true;\r\n this.showSaveResults = null;\r\n\r\n if (this.prevPath) {\r\n this.$location.path(this.prevPath);\r\n } else {\r\n this.$location.path(\"/results/\" + response.Id);\r\n }\r\n } else {\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n }\r\n\r\n //}\r\n }\r\n })\r\n .catch((response) => {\r\n this.isProceedClicked = false;\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n this.isClicked = false;\r\n this.isProceedClicked = false;\r\n this.newSearch = false;\r\n });\r\n }\r\n\r\n // TODO JLH - don't think this is in use\r\n sendEnquiry(): void {\r\n this.sendingmessage = true;\r\n this.sentmessage = false;\r\n this.enquiryTelephone = this.selectedUser.PhoneNumber;\r\n this.enquiryEmail = this.selectedUser.Email;\r\n this.enquiryBody =\r\n \"Please send me more information about loan option \" +\r\n this.GetSelectedLabel();\r\n this.$lenderresultservice\r\n .fetchMatchingResults(\r\n this.loanCriteria,\r\n true,\r\n true,\r\n 0,\r\n true,\r\n this.enquiryBody,\r\n this.enquiryEmail,\r\n this.enquiryTelephone,\r\n this.GetSelectedLabel(),\r\n )\r\n .then((response2) => {\r\n this.sendingmessage = false;\r\n this.sentmessage = true;\r\n });\r\n }\r\n\r\n private GetSelectedLabel() {\r\n var selectedlabel = \"\";\r\n if (\r\n this.selectedResultForAttachingToCase &&\r\n this.selectedResultForAttachingToCase.LoanLabel\r\n ) {\r\n selectedlabel = this.selectedResultForAttachingToCase.LoanLabel;\r\n }\r\n return selectedlabel;\r\n }\r\n\r\n saveUser(): void {\r\n if (this.selectedUser.Id == null) {\r\n this.selectedUser.Id = \"\";\r\n this.selectedUser.Roles = [];\r\n this.selectedUser.Roles.push(\"Client\");\r\n }\r\n if (!this.selectedUser.UserName) {\r\n this.selectedUser.UserName = this.selectedUser.Email; //set user name to be same as email address for now\r\n }\r\n this.loanCriteria.User = this.selectedUser;\r\n this.loanCriteria.SaveQueryAndResults = true;\r\n // this.$user.addUpdate(this.selectedUser).then((response) => {\r\n this.loadingData = true;\r\n this.$lenderresultservice\r\n .fetchMatchingResults(\r\n this.loanCriteria,\r\n true,\r\n true,\r\n 0,\r\n false,\r\n \"\",\r\n \"\",\r\n \"\",\r\n this.GetSelectedLabel(),\r\n )\r\n .then((response) => {\r\n this.selectedUser.Id = response.UserId;\r\n this.showsaveinfo = false;\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n // tourNext(): void {\r\n // this.tourState.tourStep++;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // }\r\n // tourBack(): void {\r\n // this.tourState.tourStep--;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // }\r\n\r\n // tourSkip(): void {\r\n // this.tourEnabled = false;\r\n // this.$cookies.put(\"tourEnabled\", \"false\");\r\n // this.$cookies.remove(\"tourStep\");\r\n // }\r\n\r\n // startTour(): void {\r\n // this.tourState.tourStep = 1;\r\n // this.tourState.tourTotalSteps = 0;\r\n // this.$cookies.put(\"tourStep\", this.tourState.tourStep);\r\n // this.tourEnabled = true;\r\n // this.$cookies.put(\"tourEnabled\", \"true\");\r\n // }\r\n\r\n applyForLoan(offer, productResultList: number) {\r\n /** This will check if the result shared with new user is active */\r\n var isActive = this.isResultActive();\r\n if (isActive) {\r\n //this.productResultList = productResultList;\r\n //this.SetSelectedItem(offer);\r\n if (\r\n this.searchid &&\r\n this.loanCriteria.SearchName.startsWith(\"My Development Finance Search\")\r\n ) {\r\n this.showSaveResults = 2;\r\n } else if (this.searchid) {\r\n this.register(true, this.productResultList);\r\n } else {\r\n if (\r\n this.clientFirstName != null ||\r\n this.clientSurname != null ||\r\n this.clientEmail != null ||\r\n this.clientPhoneNumber != null\r\n ) {\r\n this.loanCriteria.IntroduceeFirstName = this.clientFirstName;\r\n this.loanCriteria.IntroduceeSurname = this.clientSurname;\r\n this.loanCriteria.IntroduceeEmail = this.clientEmail;\r\n this.loanCriteria.IntroduceePhone = this.clientPhoneNumber;\r\n }\r\n\r\n this.showSaveResults = 2;\r\n }\r\n }\r\n }\r\n\r\n showSaveResultsPopup() {\r\n this.showSaveResults = 1;\r\n }\r\n\r\n showSaveCasePopup() {\r\n this.showSaveResults = 2;\r\n }\r\n\r\n changeSearch() {\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n (this.$rootScope as any).snapshotLoanCriteria = this.loanCriteria;\r\n this.warningOff = true;\r\n sessionStorage.setItem(\"skip\", \"true\");\r\n if (this.caseid) {\r\n this.go(\"/criteria/\" + this.searchid + \"/\" + this.caseid);\r\n } else if (this.searchid) {\r\n this.go(\"/criteria/\" + this.searchid);\r\n } else if (this.isreferredSearch) {\r\n this.$location.path(\r\n \"/referredsearchcriteria/\" +\r\n this.$routeParams.uniqueId +\r\n \"/\" +\r\n 0 +\r\n \"/\" +\r\n 1,\r\n );\r\n } else {\r\n this.go(\"/criteria\");\r\n }\r\n }\r\n\r\n debugSearch() {\r\n const stringJSON = JSON.stringify(this.loanCriteria);\r\n navigator.clipboard\r\n .writeText(stringJSON)\r\n .then()\r\n .catch((e) => console.log(e));\r\n }\r\n\r\n /**Processing for Net Loan Required input field OnBlur */\r\n netLoanRequiredOnBlur() {\r\n //wait to the debounce to update ng-model\r\n setTimeout(() => {\r\n // When the Net Loan required amount is empty or 0 then set the Maximum Loan required toggle to TRUE\r\n if (\r\n !this.loanCriteria.CI_Dev_LoanReq ||\r\n this.loanCriteria.CI_Dev_LoanReq == 0 ||\r\n String(this.loanCriteria.CI_Dev_LoanReq) == \"\"\r\n ) {\r\n this.isMaximumLoanRequired = true;\r\n }\r\n }, 1000);\r\n }\r\n\r\n updateSearchViaSlider(isAdminDebugValueChanged: boolean = false): void {\r\n /** This will check if the result shared with new user is active */\r\n var isActive = this.isResultActive();\r\n if (isActive && !this.showPostcodeErrorMessage) {\r\n this.loadingData = true;\r\n\r\n // Set criteria properties to 0 that have been cleared by the user e.g. backspace or delete has been used\r\n if (\r\n (!this.loanCriteria.CI_Dev_LoanReq &&\r\n this.loanCriteria.CI_Dev_LoanReq != 0) ||\r\n String(this.loanCriteria.CI_Dev_LoanReq) == \"\"\r\n ) {\r\n this.loanCriteria.CI_Dev_LoanReq = 0;\r\n }\r\n\r\n if (\r\n (!this.loanCriteria.CI_Dev_LoanTermReq &&\r\n this.loanCriteria.CI_Dev_LoanTermReq != 0) ||\r\n String(this.loanCriteria.CI_Dev_LoanTermReq) == \"\"\r\n ) {\r\n this.loanCriteria.CI_Dev_LoanTermReq = 0;\r\n }\r\n\r\n if (\r\n (!this.loanCriteria.CI_Dev_BuildTerm &&\r\n this.loanCriteria.CI_Dev_BuildTerm != 0) ||\r\n String(this.loanCriteria.CI_Dev_BuildTerm) == \"\"\r\n ) {\r\n this.loanCriteria.CI_Dev_BuildTerm = 0;\r\n }\r\n\r\n if (\r\n (!this.loanCriteria.CI_GDV && this.loanCriteria.CI_GDV != 0) ||\r\n String(this.loanCriteria.CI_GDV) == \"\"\r\n ) {\r\n this.loanCriteria.CI_GDV = 0;\r\n }\r\n\r\n if (\r\n (!this.loanCriteria.CI_Dev_BuildCosts &&\r\n this.loanCriteria.CI_Dev_BuildCosts != 0) ||\r\n String(this.loanCriteria.CI_Dev_BuildCosts) == \"\"\r\n ) {\r\n this.loanCriteria.CI_Dev_BuildCosts = 0;\r\n }\r\n\r\n this.updatedResultsWithSlider =\r\n this.hasSearchChanged =\r\n this.hasCriteriaChanged =\r\n true;\r\n\r\n if (isAdminDebugValueChanged && this.isAdmin) {\r\n this.hasCriteriaChanged = false;\r\n }\r\n\r\n this.clearSelected();\r\n\r\n this.updateResults();\r\n }\r\n }\r\n\r\n clearSelected() {\r\n this.comparisonList = [];\r\n\r\n this.loanCriteria.SelectedResults = [];\r\n }\r\n\r\n cancelSavePopup() {\r\n this.showSaveResults = null;\r\n this.loanCriteria.SearchName = this.searchNameCache;\r\n }\r\n\r\n /* saveAs() {\r\n this.isClicked = true;\r\n this.isSaveorSaveAsClicked = true;\r\n delete this.loanCriteria.Id;\r\n delete this.loanCriteria.IsFullCase;\r\n delete this.loanCriteria.UniqueRef;\r\n this.register(false, this.productResultList);\r\n }*/\r\n\r\n doRenameSearch() {\r\n //this.register(false, this.productResultList, false, true);\r\n if (this.$routeParams.SearchId) {\r\n this.$DevelopmentInputService\r\n .addUpdate(this.loanCriteria)\r\n .then((response) => {\r\n this.toggleEditSearchName = false;\r\n });\r\n } else if (\r\n this.$routeParams.uniqueId !== undefined &&\r\n this.$routeParams.uniqueId != \"null\"\r\n ) {\r\n var result = {} as DevelopmentWithNoLoginDTO;\r\n (Object).assign(result, this.loanCriteria);\r\n this.$DevelopmentInputWithNoLoginService\r\n .saveChangesToReferredSearch(result, this.$routeParams.uniqueId)\r\n .then((response) => {\r\n this.toggleEditSearchName = false;\r\n });\r\n } else {\r\n this.toggleEditSearchName = false;\r\n }\r\n }\r\n\r\n emailChange() {\r\n if (this.error) {\r\n this.error = \"\";\r\n }\r\n }\r\n\r\n videotour() {\r\n this.showVideo = true;\r\n }\r\n\r\n videopause(id) {\r\n this.showVideo = false;\r\n let containerElement = document.getElementById(id);\r\n let iframe_tag = containerElement.querySelector(\"iframe\");\r\n if (iframe_tag) {\r\n let iframeSrc = iframe_tag.src;\r\n iframe_tag.src = iframeSrc;\r\n }\r\n }\r\n\r\n updateLoanRequiredValue() {\r\n if (this.isMaximumLoanRequired) {\r\n if (this.loanCriteria.CI_Dev_LoanReq) {\r\n this.tempLoanRequired = this.loanCriteria.CI_Dev_LoanReq;\r\n }\r\n this.loanCriteria.CI_Dev_LoanReq = 0;\r\n this.updateSearchViaSlider();\r\n } else {\r\n this.loanCriteria.CI_Dev_LoanReq = this.tempLoanRequired;\r\n this.updateSearchViaSlider();\r\n }\r\n }\r\n\r\n /**\r\n * Finds the product in the Summary DTO and matches it to the original LenderResultMinimalDTOs\r\n * This is needed following the resdesign of the Search Results view and to keep the other views\r\n * functioning with minimal refactoring/impact\r\n * @param summaryDTO\r\n */\r\n getLenderResultMinimalDTO(summaryDTO: LenderResultSummaryDTO) {\r\n // Find Lender offer within the original arrays to use on the compare view\r\n let match: LenderResultMinimalDTO;\r\n if (summaryDTO.IsMatching === true) {\r\n match = this.matchingResults.find(\r\n (result) => result.SeniorProductID === summaryDTO.ProductID,\r\n );\r\n } else if (summaryDTO.IsMatching === false) {\r\n match = this.largestResults.find(\r\n (result) => result.SeniorProductID === summaryDTO.ProductID,\r\n );\r\n }\r\n\r\n // Overriding the loan label with the Lender Generic name\r\n match.LoanLabel = summaryDTO.LoanLabel;\r\n\r\n return match;\r\n }\r\n\r\n CalcProfessionalCostsAndCharges(): number {\r\n if (this.loanCriteria) {\r\n var res: number = 0;\r\n if (this.loanCriteria.DI_BreakDownBuildCosts) {\r\n if (this.loanCriteria.CI_Dev_ProfPlanning) {\r\n res += Number(this.loanCriteria.CI_Dev_ProfPlanning);\r\n }\r\n if (this.loanCriteria.CI_Dev_ProfQS) {\r\n res += Number(this.loanCriteria.CI_Dev_ProfQS);\r\n }\r\n if (this.loanCriteria.DI_BuildProjectManag) {\r\n res += Number(this.loanCriteria.DI_BuildProjectManag);\r\n }\r\n if (this.loanCriteria.CI_Dev_S106CIL) {\r\n res += Number(this.loanCriteria.CI_Dev_S106CIL);\r\n }\r\n if (this.loanCriteria.DI_BuildMechEng) {\r\n res += Number(this.loanCriteria.DI_BuildMechEng);\r\n }\r\n if (this.loanCriteria.DI_BuildStrucEng) {\r\n res += Number(this.loanCriteria.DI_BuildStrucEng);\r\n }\r\n if (this.loanCriteria.DI_BuildPartyWall) {\r\n res += Number(this.loanCriteria.DI_BuildPartyWall);\r\n }\r\n if (this.loanCriteria.DI_BuildLandscaping) {\r\n res += Number(this.loanCriteria.DI_BuildLandscaping);\r\n }\r\n if (this.loanCriteria.DI_BuildWarranty) {\r\n res += Number(this.loanCriteria.DI_BuildWarranty);\r\n }\r\n if (this.loanCriteria.DI_BuildDemolition) {\r\n res += Number(this.loanCriteria.DI_BuildDemolition);\r\n }\r\n if (this.loanCriteria.DI_BuildOtherCosts) {\r\n res += Number(this.loanCriteria.DI_BuildOtherCosts);\r\n }\r\n } else {\r\n if (this.loanCriteria.CI_Dev_AdditionalOngoingCosts) {\r\n res += Number(this.loanCriteria.CI_Dev_AdditionalOngoingCosts);\r\n }\r\n }\r\n\r\n return res;\r\n }\r\n }\r\n\r\n CalcPurchaseAdditionalCosts(): number {\r\n if (this.loanCriteria) {\r\n var res: number = 0;\r\n\r\n if (this.loanCriteria.CI_Dev_SDLT) {\r\n res += Number(this.loanCriteria.CI_Dev_SDLT);\r\n }\r\n if (this.loanCriteria.DI_PurchaseAgentFees) {\r\n res += Number(this.loanCriteria.DI_PurchaseAgentFees);\r\n }\r\n if (this.loanCriteria.DI_PurchaseLegalFees) {\r\n res += Number(this.loanCriteria.DI_PurchaseLegalFees);\r\n }\r\n if (this.loanCriteria.DI_PurchaseOtherFees) {\r\n res += Number(this.loanCriteria.DI_PurchaseOtherFees);\r\n }\r\n\r\n return res;\r\n }\r\n }\r\n\r\n /**Close the search summary panel */\r\n showSearchSummary(show: boolean) {\r\n (this.$rootScope as any).hideSearchSummary = !show;\r\n this.sliderShown = show;\r\n }\r\n\r\n contingencyChanged() {\r\n this.recalcCosts(\"CI_Dev_Contingency\");\r\n this.updateSearchViaSlider();\r\n }\r\n\r\n getSearchResultCount() {\r\n if (this.summarySearchResults) {\r\n return this.summarySearchResults.length;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n getSearchLenderCount() {\r\n this.lenderService\r\n .getTotalLenders(ProductFamilyEnum.Development)\r\n .then((result) => {\r\n this.totalLender = result;\r\n });\r\n }\r\n\r\n /** user lookup for newsearch popup */\r\n userLookupForNewSearch(userSearchTerm: string) {\r\n this.loadingData = true;\r\n this.$user\r\n .searchByEmail(userSearchTerm)\r\n .then((response) => {\r\n if (this.isBroker) {\r\n this.existingUsers = response.filter(\r\n (x) =>\r\n x.OrganisationReferralId == this.selectedUser.OrganisationId &&\r\n !x.OrganisationId &&\r\n !x.IsOrganisationAdmin,\r\n );\r\n } else {\r\n this.existingUsers = response;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n /** closes new search pop up*/\r\n cancelNewSearch() {\r\n this.newSearch = false;\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.clientPhoneNumber;\r\n delete this.clientId;\r\n this.existingborrower = null;\r\n this.showClientDetails = false;\r\n this.selecteduserName = null;\r\n this.sharedSearch = false;\r\n if (this.tempSearchName) {\r\n this.loanCriteria.SearchName = this.tempSearchName;\r\n this.tempSearchName = \"\";\r\n }\r\n }\r\n\r\n sendResultsToClient(notifyBorrower, reloadSearch = false) {\r\n if (this.isSaveAsClicked) {\r\n this.saveSaveAsSearch(true);\r\n } else {\r\n this.loadingData = true;\r\n this.newSearch = false;\r\n this.existingborrower = null;\r\n this.showClientDetails = false;\r\n if (this.searchName != null && this.searchName.length > 0) {\r\n this.loanCriteria.SearchName = this.searchName;\r\n }\r\n\r\n this.userService\r\n .getUserDetailsByEmailIfExists(this.clientEmail)\r\n .then((user: ApplicationUserDTO) => {\r\n if (user == null) {\r\n this.loanCriteria.UserId = null;\r\n this.$IntroducerService\r\n .sendResultsToClient(\r\n this.loanCriteria,\r\n this.clientFirstName,\r\n this.clientSurname,\r\n this.clientEmail,\r\n notifyBorrower,\r\n this.clientPhoneNumber,\r\n )\r\n .then((success) => {\r\n this.searchReference = success;\r\n if (reloadSearch) {\r\n this.warningOff = true;\r\n this.go(\"/referredSearch/\" + this.searchReference);\r\n } else {\r\n this.showSaveResults = 6;\r\n }\r\n });\r\n } else {\r\n this.loanCriteria.User = user;\r\n this.clientId = user.Id;\r\n this.$DevelopmentInputService\r\n .sendResultsToExistingClient(\r\n this.loanCriteria,\r\n this.clientFirstName,\r\n this.clientSurname,\r\n this.clientEmail,\r\n this.clientId,\r\n notifyBorrower,\r\n this.clientPhoneNumber,\r\n )\r\n .then((success) => {\r\n this.newSearchId = success;\r\n if (reloadSearch) {\r\n this.warningOff = true;\r\n this.go(\"/results/\" + this.newSearchId);\r\n } else {\r\n this.showSaveResults = 7;\r\n }\r\n });\r\n }\r\n })\r\n .finally(() => {\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.clientPhoneNumber;\r\n delete this.clientId;\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n\r\n /* sendResultsToExistingClient(notifyBorrower: boolean = true) {\r\n\r\n this.$DevelopmentInputService.sendResultsToExistingClient(this.loanCriteria, this.clientFirstName, this.clientSurname, this.clientEmail, this.clientId, notifyBorrower, this.clientPhoneNumber).then((success) => {\r\n this.newSearchId = success;\r\n this.loadingData = false;\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.clientPhoneNumber;\r\n delete this.clientId;\r\n this.showSaveResults = 7; \r\n });\r\n }\r\n\r\n introducerSendResultsToClient(notifyBorrower: boolean = true) {\r\n // remove the user id because otherwise the client won't be able to see the search on their dashboard\r\n this.loanCriteria.UserId = null;\r\n this.$IntroducerService.sendResultsToClient(this.loanCriteria, this.clientFirstName, this.clientSurname, this.clientEmail, notifyBorrower, this.clientPhoneNumber).then((success) => {\r\n this.loadingData = false;\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.clientPhoneNumber;\r\n\r\n if (this.isBroker) {\r\n this.searchReference = success;\r\n this.showSaveResults = 6;\r\n } else {\r\n this.showSaveResults = 5;\r\n }\r\n\r\n });\r\n }\r\n */\r\n\r\n viewClientsDashboardForNewSearch(userName: string) {\r\n //Look up client's account details\r\n this.loadingData = true;\r\n this.$user.searchByEmail(userName).then((users) => {\r\n console.log(users);\r\n console.log(users[0].FirstName);\r\n this.clientFirstName = users[0].FirstName;\r\n this.clientEmail = users[0].Email;\r\n this.clientSurname = users[0].LastName;\r\n this.clientPhoneNumber = users[0].PhoneNumber;\r\n this.clientId = users[0].Id;\r\n this.showClientDetails = true;\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n clearInputFields() {\r\n this.clientFirstName = null;\r\n this.clientEmail = null;\r\n this.clientSurname = null;\r\n this.clientPhoneNumber = null;\r\n this.showClientDetails = false;\r\n this.selecteduserName = null;\r\n }\r\n\r\n // These functions are for the FAQ slider\r\n\r\n toggleAccordion(id: number) {\r\n if (!this.accordionShow[id]) {\r\n this.accordionShow[id] = true;\r\n } else {\r\n this.accordionShow[id] = !this.accordionShow[id];\r\n }\r\n }\r\n\r\n requestEmail(reason): void {\r\n this.showRequestEmailForm = true;\r\n this.requestMessageReason = reason;\r\n this.message = true;\r\n this.messageContent = \"\";\r\n }\r\n\r\n closeModal() {\r\n this.message = false;\r\n }\r\n\r\n sendRequestEmail() {\r\n this.showRequestEmailForm = false;\r\n this.loadingData = true;\r\n this.sendingMessage = true;\r\n\r\n if (this.currentCase) {\r\n this.$accountservice\r\n .RequestAssistanceReview(this.requestMessageReason, this.currentCase.Id)\r\n .then((response) => {\r\n this.showMessage(\r\n `${this.appName} have been notified that you require assistance and will be in touch shortly to help.`,\r\n );\r\n\r\n let caseNote = {\r\n CaseId: this.currentCase.Id,\r\n UserId: this.selectedUser.Id,\r\n NoteText: \"You have requested \" + this.requestMessageReason + \".\",\r\n ExpandNote: false,\r\n } as CaseNoteDTO;\r\n\r\n this.caseNoteService.addUpdate(caseNote);\r\n })\r\n .catch((error) => {\r\n this.showMessage(\r\n \"Sorry, something went wrong while sending your email. Please try again.\",\r\n );\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.loadingData = false;\r\n });\r\n } else if (this.searchid) {\r\n this.$lenderresultservice\r\n .RequestAssistance(this.requestMessageReason, this.searchid)\r\n .then((response) => {\r\n this.showMessage(\r\n `${this.appName} have been notified that you require assistance and will be in touch shortly to help.`,\r\n );\r\n })\r\n .catch((error) => {\r\n this.showMessage(\r\n \"Sorry, something went wrong while sending your email. Please try again.\",\r\n );\r\n })\r\n .finally(() => {\r\n this.sendingMessage = false;\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n\r\n showMessage(message: string) {\r\n this.messageContent = message;\r\n }\r\n\r\n hideRequestAssistance(): boolean {\r\n return !this.searchid;\r\n }\r\n\r\n // End of functions for the FAQ slider\r\n\r\n getAppName() {\r\n let lsd = null;\r\n if (window.self == window.top)\r\n lsd = sessionStorage.getItem(\"applicationName\");\r\n if (lsd != null) {\r\n this.appName = lsd;\r\n } else {\r\n this.appName = \"Brickflow\";\r\n }\r\n }\r\n\r\n defaultSearchName() {\r\n var currentdate = new Date();\r\n return (\r\n \"My Development Finance Search \" +\r\n currentdate.getDate() +\r\n \"/\" +\r\n (currentdate.getMonth() + 1) +\r\n \"/\" +\r\n currentdate.getFullYear()\r\n );\r\n }\r\n\r\n fillHalfRegisterForm() {\r\n let name = new Date().toLocaleString().replace(/ |,|:|\\/|/g, \"\");\r\n this.newUser.Email = `${name}@test.com`;\r\n this.newUser.FirstName = name;\r\n this.newUser.LastName = \"t\";\r\n this.newUser.PhoneNumber = \"12345677\";\r\n this.newUser.ApplicantDefinedRole = 0;\r\n }\r\n\r\n registerNow() {\r\n (this.$rootScope as any).loanCriteria = this.loanCriteria;\r\n this.cancelSaving();\r\n this.$location.path(\"promo\");\r\n }\r\n\r\n sendShareSearchEmailToClient() {\r\n this.dataLoading = true;\r\n if (this.$routeParams.uniqueId) {\r\n this.$DevelopmentInputWithNoLoginService\r\n .isResultActive(this.$routeParams.uniqueId)\r\n .then((results) => {\r\n if (results) {\r\n this.$DevelopmentInputWithNoLoginService\r\n .sendEmailToNewUser(\r\n this.$routeParams.uniqueId,\r\n this.loanCriteria.ShowLenderNamesToBorrower,\r\n true,\r\n )\r\n .then((response) => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.loanCriteria.IntroduceeFirstName +\r\n \" \" +\r\n this.loanCriteria.IntroduceeSurname;\r\n this.newSearch = false;\r\n this.showMsg = true;\r\n this.dataLoading = false;\r\n })\r\n .catch((error) => {\r\n this.displayMsg =\r\n \"Sorry, something went wrong. Please try again.\";\r\n this.newSearch = false;\r\n this.showMsg = true;\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.displayMsg = `Changes have been made to this search by your client, you will now be taken back to your user dashboard`;\r\n this.newSearch = false;\r\n this.showMsgToAdminOrBroker = true;\r\n this.dataLoading = false;\r\n }\r\n });\r\n } else {\r\n this.$DevelopmentInputService\r\n .sendEmailToExistingUser(\r\n this.$routeParams.SearchId,\r\n this.loanCriteria.ShowLenderNamesToBorrower,\r\n true,\r\n )\r\n .then((response) => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.loanCriteria.IntroduceeFirstName +\r\n \" \" +\r\n this.loanCriteria.IntroduceeSurname;\r\n this.newSearch = false;\r\n this.showMsg = true;\r\n this.dataLoading = false;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n this.newSearch = false;\r\n this.newSearch = false;\r\n this.showMsg = true;\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n deleteSearch() {\r\n if (this.$routeParams.SearchId) {\r\n this.$DevelopmentInputService\r\n .markasdeleted(this.$routeParams.SearchId)\r\n .then((response) => {\r\n this.displayMsg = \"Search is successfully deleted\";\r\n this.showMsg = true;\r\n this.ShowdeleteSearch = true;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n this.showMsg = true;\r\n });\r\n } else {\r\n /** This will check if the result shared with new user is active */\r\n this.$DevelopmentInputWithNoLoginService\r\n .isResultActive(this.$routeParams.uniqueId)\r\n .then((results) => {\r\n if (!results) {\r\n this.displayMsg = `Changes have been made to this search by your client, you will now be taken back to your user dashboard`;\r\n this.showMsgToAdminOrBroker = true;\r\n } else {\r\n this.$DevelopmentInputWithNoLoginService\r\n .markasdeleted(this.loanCriteria.Id)\r\n .then((response) => {\r\n this.displayMsg = \"Search is successfully deleted\";\r\n this.showMsg = true;\r\n this.ShowdeleteSearch = true;\r\n })\r\n .catch((error) => {\r\n this.displayMsg =\r\n \"Sorry, something went wrong. Please try again.\";\r\n this.showMsg = true;\r\n });\r\n }\r\n });\r\n }\r\n }\r\n\r\n closeDeleteModal() {\r\n this.showMsg = false;\r\n this.displayMsg = null;\r\n this.ShowdeleteSearch = false;\r\n this.warningOff = true;\r\n this.$auth.clearSelectedNavMenuAndFilterStorageData();\r\n this.go(\"/userdashboard\");\r\n }\r\n\r\n onDIPClick(item: LenderResultSummaryDTO) {\r\n this.isDIPClicked = true;\r\n\r\n this.toggleLenderComparisonSelection(item);\r\n\r\n if (\r\n this.searchid &&\r\n this.loanCriteria.SearchName.startsWith(\"My Loan Search\")\r\n ) {\r\n this.showSaveResults = 2;\r\n } else if (this.searchid) {\r\n this.register(true, this.productResultList);\r\n this.warningOff = false;\r\n } else if (this.loanCriteria.SearchName) {\r\n this.register(true, this.productResultList);\r\n this.doubleWarningOff = true;\r\n } else {\r\n this.showSaveResults = 2;\r\n }\r\n }\r\n\r\n /* onClickSaveAs() {\r\n this.showSaveResults = 3;\r\n this.tempSearchName = this.loanCriteria.SearchName;\r\n this.loanCriteria.SearchName = '';\r\n }*/\r\n\r\n onClickSaveAs() {\r\n this.isSaveAsClicked = true;\r\n if (this.isAdmin || this.isBroker) {\r\n this.tempSearchName = this.loanCriteria.SearchName;\r\n this.loanCriteria.SearchName = \"\";\r\n this.showShareSearchModal();\r\n } else {\r\n this.showSaveResults = 3;\r\n }\r\n }\r\n\r\n saveAsWthOutIntroducee() {\r\n this.isSaveAsWthOutIntroducee = true;\r\n this.tempSearchName = this.loanCriteria.SearchName;\r\n this.loanCriteria.SearchName = \"\";\r\n this.showShareSearchModal();\r\n }\r\n\r\n saveChangesToReferredSearch() {\r\n var result = {} as DevelopmentWithNoLoginDTO;\r\n this.loadingData = true;\r\n (Object).assign(result, this.loanCriteria);\r\n this.$DevelopmentInputWithNoLoginService\r\n .saveChangesToReferredSearch(result, this.$routeParams.uniqueId)\r\n .then((savedSearchId) => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n change() {\r\n if ((this.newUser as any).ConfirmPassword === this.newUser.Password) {\r\n this.error = \"\";\r\n } else {\r\n this.error = \"Passwords do not match\";\r\n }\r\n }\r\n\r\n getUsersBelongToBrokerOrAdmin() {\r\n this.loadingData = true;\r\n this.$user\r\n .getUserSummariesForBrokerOrAdmin()\r\n .then((response) => {\r\n this.existingUsers = response;\r\n });\r\n }\r\n\r\n saveResultsClicked() {\r\n if (this.prevPath) {\r\n this.isSaveorSaveAsClicked = false;\r\n } else {\r\n this.isSaveorSaveAsClicked = true;\r\n }\r\n this.register(false, this.productResultList);\r\n }\r\n\r\n checkShowBridgingEligibility() {\r\n return this.$auth.getShowBridgingEligibility();\r\n }\r\n\r\n showBookMeetingButton() {\r\n return (\r\n !this.isLoggedInUser &&\r\n this.isClient &&\r\n this.brokerDetail == \"\" &&\r\n this.brokerageOrg != null\r\n );\r\n }\r\n\r\n bookMeeting() {\r\n this.$auth\r\n .getHubspotDeveloperBookMeetingWithSearch()\r\n .then((hubSpotUrl: string) => {\r\n window.open(hubSpotUrl);\r\n });\r\n }\r\n\r\n onShareholderDepositRequiredChange(e: ShareholderDepositRequiredEnum) {\r\n switch (e) {\r\n case ShareholderDepositRequiredEnum.None:\r\n this.loanCriteria.F_ShareholderDepositRequired = 0;\r\n break;\r\n case ShareholderDepositRequiredEnum.UpTo25Percent:\r\n this.loanCriteria.F_ShareholderDepositRequired = 0.25;\r\n break;\r\n case ShareholderDepositRequiredEnum.TwentyFiveTo50Percent:\r\n this.loanCriteria.F_ShareholderDepositRequired = 0.5;\r\n break;\r\n case ShareholderDepositRequiredEnum.FiftyPercentPlus:\r\n this.loanCriteria.F_ShareholderDepositRequired = 1.0;\r\n break;\r\n default:\r\n this.loanCriteria.F_ShareholderDepositRequired = null;\r\n break;\r\n }\r\n }\r\n\r\n getShareholderDepositRequired() {\r\n var value = null;\r\n switch (this.loanCriteria.F_ShareholderDepositRequired) {\r\n case 0:\r\n value = ShareholderDepositRequiredEnum.None;\r\n break;\r\n case 0.25:\r\n value = ShareholderDepositRequiredEnum.UpTo25Percent;\r\n break;\r\n case 0.5:\r\n value = ShareholderDepositRequiredEnum.TwentyFiveTo50Percent;\r\n break;\r\n case 1.0:\r\n value = ShareholderDepositRequiredEnum.FiftyPercentPlus;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n getPreviousDevelopments() {\r\n var value = null;\r\n switch (this.loanCriteria.F_NumberOfPreviousDevelopments) {\r\n case 1:\r\n value = PreviousDevelopmentsEnum.One;\r\n break;\r\n case 2:\r\n value = PreviousDevelopmentsEnum.Two;\r\n break;\r\n case 3:\r\n value = PreviousDevelopmentsEnum.Three;\r\n break;\r\n case 4:\r\n value = PreviousDevelopmentsEnum.FourOrMore;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n onPersonalGuaranteeLevelOptionsChange(e: PersonalGuaranteeLevelEnum) {\r\n switch (e) {\r\n case PersonalGuaranteeLevelEnum.UpTo20Percent:\r\n this.loanCriteria.F_PersonalGuaranteeLevel = 0.2;\r\n break;\r\n case PersonalGuaranteeLevelEnum.TwentyOneTo35Percent:\r\n this.loanCriteria.F_PersonalGuaranteeLevel = 0.35;\r\n break;\r\n case PersonalGuaranteeLevelEnum.ThirtySixTo50Percent:\r\n this.loanCriteria.F_PersonalGuaranteeLevel = 0.5;\r\n break;\r\n case PersonalGuaranteeLevelEnum.OneHundredPercent:\r\n this.loanCriteria.F_PersonalGuaranteeLevel = 1.0;\r\n break;\r\n default:\r\n this.loanCriteria.F_PersonalGuaranteeLevel = null;\r\n break;\r\n }\r\n }\r\n\r\n getPersonalGuaranteeLevelOptions() {\r\n var value = null;\r\n switch (this.loanCriteria.F_PersonalGuaranteeLevel) {\r\n case 0.2:\r\n value = PersonalGuaranteeLevelEnum.UpTo20Percent;\r\n break;\r\n case 0.35:\r\n value = PersonalGuaranteeLevelEnum.TwentyOneTo35Percent;\r\n break;\r\n case 0.5:\r\n value = PersonalGuaranteeLevelEnum.ThirtySixTo50Percent;\r\n break;\r\n case 1.0:\r\n value = PersonalGuaranteeLevelEnum.OneHundredPercent;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n onMaxHouseSalesPriceChange(e: MaxHouseSalePriceEnum) {\r\n switch (e) {\r\n case MaxHouseSalePriceEnum.UpTo1Million:\r\n this.loanCriteria.F_MaxHouseSalesPrice = 1000000;\r\n break;\r\n case MaxHouseSalePriceEnum.UpTo2Million:\r\n this.loanCriteria.F_MaxHouseSalesPrice = 2000000;\r\n break;\r\n case MaxHouseSalePriceEnum.UpTo5Million:\r\n this.loanCriteria.F_MaxHouseSalesPrice = 5000000;\r\n break;\r\n case MaxHouseSalePriceEnum.NoMax:\r\n this.loanCriteria.F_MaxHouseSalesPrice = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxHouseSalesPrice = null;\r\n break;\r\n }\r\n }\r\n\r\n getMaxHouseSalesPrice() {\r\n var value = null;\r\n switch (this.loanCriteria.F_MaxHouseSalesPrice) {\r\n case 1000000:\r\n value = MaxHouseSalePriceEnum.UpTo1Million;\r\n break;\r\n case 2000000:\r\n value = MaxHouseSalePriceEnum.UpTo2Million;\r\n break;\r\n case 5000000:\r\n value = MaxHouseSalePriceEnum.UpTo5Million;\r\n break;\r\n case -999:\r\n value = MaxHouseSalePriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n onMaxFlatUnitPriceChange(e: MaxFlatUnitPriceEnum) {\r\n switch (e) {\r\n case MaxFlatUnitPriceEnum.UpTo1Million:\r\n this.loanCriteria.F_MaxFlatUnitPrice = 1000000;\r\n break;\r\n case MaxFlatUnitPriceEnum.UpTo2Million:\r\n this.loanCriteria.F_MaxFlatUnitPrice = 2000000;\r\n break;\r\n case MaxFlatUnitPriceEnum.UpTo3Million:\r\n this.loanCriteria.F_MaxFlatUnitPrice = 3000000;\r\n break;\r\n case MaxFlatUnitPriceEnum.NoMax:\r\n this.loanCriteria.F_MaxFlatUnitPrice = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxFlatUnitPrice = null;\r\n break;\r\n }\r\n }\r\n\r\n getMaxFlatUnitPrice() {\r\n var value = null;\r\n switch (this.loanCriteria.F_MaxFlatUnitPrice) {\r\n case 1000000:\r\n value = MaxFlatUnitPriceEnum.UpTo1Million;\r\n break;\r\n case 2000000:\r\n value = MaxFlatUnitPriceEnum.UpTo2Million;\r\n break;\r\n case 3000000:\r\n value = MaxFlatUnitPriceEnum.UpTo3Million;\r\n break;\r\n case -999:\r\n value = MaxFlatUnitPriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n onMaxSqFtSalePriceChange(e: MaxSqFtSalePriceEnum) {\r\n switch (e) {\r\n case MaxSqFtSalePriceEnum.UpTo850:\r\n this.loanCriteria.F_MaxSqFtSalePrice = 850;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1000:\r\n this.loanCriteria.F_MaxSqFtSalePrice = 1000;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1500:\r\n this.loanCriteria.F_MaxSqFtSalePrice = 1500;\r\n break;\r\n case MaxSqFtSalePriceEnum.NoMax:\r\n this.loanCriteria.F_MaxSqFtSalePrice = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxSqFtSalePrice = null;\r\n break;\r\n }\r\n }\r\n\r\n onMaxSqFtFlatsSalePriceChange(e: MaxSqFtSalePriceEnum) {\r\n switch (e) {\r\n case MaxSqFtSalePriceEnum.UpTo850:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = 850;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1000:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = 1000;\r\n break;\r\n case MaxSqFtSalePriceEnum.UpTo1500:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = 1500;\r\n break;\r\n case MaxSqFtSalePriceEnum.NoMax:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = -999;\r\n break;\r\n default:\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = null;\r\n break;\r\n }\r\n }\r\n\r\n getMaxSqFtSalePrice() {\r\n var value = null;\r\n switch (this.loanCriteria.F_MaxSqFtSalePrice) {\r\n case 850:\r\n value = MaxSqFtSalePriceEnum.UpTo850;\r\n break;\r\n case 1000:\r\n value = MaxSqFtSalePriceEnum.UpTo1000;\r\n break;\r\n case 1500:\r\n value = MaxSqFtSalePriceEnum.UpTo1500;\r\n break;\r\n case -999:\r\n value = MaxSqFtSalePriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n getMaxSqFtSalePriceFlats() {\r\n var value = null;\r\n switch (this.loanCriteria.F_MaxSqFtSalePriceFlats) {\r\n case 850:\r\n value = MaxSqFtSalePriceEnum.UpTo850;\r\n break;\r\n case 1000:\r\n value = MaxSqFtSalePriceEnum.UpTo1000;\r\n break;\r\n case 1500:\r\n value = MaxSqFtSalePriceEnum.UpTo1500;\r\n break;\r\n case -999:\r\n value = MaxSqFtSalePriceEnum.NoMax;\r\n break;\r\n default:\r\n value = null;\r\n break;\r\n }\r\n return value;\r\n }\r\n\r\n applyFilters() {\r\n this.loadingData = true;\r\n this.showFilters = false;\r\n this.isFilterUpdate = true;\r\n this.clearSelected();\r\n this.updateResults();\r\n\r\n if (this.loanCriteria.Id) {\r\n if (\r\n this.$routeParams.uniqueId !== undefined &&\r\n this.$routeParams.uniqueId != \"null\"\r\n ) {\r\n var result = {} as DevelopmentWithNoLoginDTO;\r\n (Object).assign(result, this.loanCriteria);\r\n this.$DevelopmentInputWithNoLoginService\r\n .saveChangesToReferredSearch(result, this.$routeParams.uniqueId)\r\n .catch((error) => {\r\n this.displayMsg =\r\n \"Sorry, something went wrong and your filters were not saved. Please try again.\";\r\n this.showMsg = true;\r\n });\r\n } else {\r\n this.$DevelopmentInputService\r\n .saveSearch(this.loanCriteria)\r\n .catch((error) => {\r\n this.displayMsg =\r\n \"Sorry, something went wrong and your filters were not saved. Please try again.\";\r\n this.showMsg = true;\r\n });\r\n }\r\n }\r\n }\r\n\r\n clearClientFilters() {\r\n this.loanCriteria.F_IsFirstTimeDeveloper = null;\r\n this.loanCriteria.F_NumberOfPreviousDevelopments = null;\r\n this.loanCriteria.F_ShareholderDepositRequired = null;\r\n this.shareholderDepositRequired = null;\r\n this.loanCriteria.F_IsPersonalName = null;\r\n this.loanCriteria.F_IsOffshoreCompany = null;\r\n this.loanCriteria.F_IsMainShareholderOverseas = null;\r\n this.loanCriteria.F_PersonalGuaranteeLevel = null;\r\n this.personalGuaranteeLevel = null;\r\n this.loanCriteria.F_HasAdverseCredit = null;\r\n this.loanCriteria.F_MaxCommercialFloorspace = null;\r\n }\r\n\r\n showClearForClientFilters() {\r\n if (\r\n this.loanCriteria.F_IsFirstTimeDeveloper != null ||\r\n this.loanCriteria.F_NumberOfPreviousDevelopments != null ||\r\n this.loanCriteria.F_ShareholderDepositRequired != null ||\r\n this.loanCriteria.F_IsPersonalName != null ||\r\n this.loanCriteria.F_IsOffshoreCompany != null ||\r\n this.loanCriteria.F_IsMainShareholderOverseas != null ||\r\n this.loanCriteria.F_PersonalGuaranteeLevel != null ||\r\n this.loanCriteria.F_HasAdverseCredit != null ||\r\n this.loanCriteria.F_MaxCommercialFloorspace != null\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n clearPropertyFilters() {\r\n this.loanCriteria.F_IsAirRights = null;\r\n this.loanCriteria.F_IsModular = null;\r\n this.loanCriteria.F_IsPermittedDevelopmentScheme = null;\r\n this.loanCriteria.F_IsGradeOneListed = null;\r\n this.loanCriteria.F_IsGradeTwoListed = null;\r\n this.loanCriteria.F_MaxHouseSalesPrice = null;\r\n this.loanCriteria.F_MaxFlatUnitPrice = null;\r\n this.loanCriteria.F_MaxNumberOfUnits = null;\r\n //this.loanCriteria.F_MaxPercCommercialForMixedUse = null;\r\n this.loanCriteria.F_MaxSqFtSalePrice = null;\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats = null;\r\n this.loanCriteria.F_IsWorkStarted = null;\r\n this.maxHouseSalesPrice = null;\r\n this.maxFlatUnitPrice = null;\r\n this.maxSqFtSalePrice = null;\r\n this.maxPercCommercialForMixedUse = null;\r\n this.maxSqFtSalePriceFlats = null;\r\n this.previousDevelopments = null;\r\n }\r\n\r\n showClearForPropertyFilters() {\r\n if (\r\n this.loanCriteria.F_IsAirRights != null ||\r\n this.loanCriteria.F_IsModular != null ||\r\n this.loanCriteria.F_IsPermittedDevelopmentScheme != null ||\r\n this.loanCriteria.F_IsGradeOneListed != null ||\r\n this.loanCriteria.F_IsGradeTwoListed != null ||\r\n this.loanCriteria.F_MaxHouseSalesPrice != null ||\r\n this.loanCriteria.F_MaxFlatUnitPrice != null ||\r\n this.loanCriteria.F_MaxNumberOfUnits != null ||\r\n //this.loanCriteria.F_MaxPercCommercialForMixedUse != null ||\r\n this.loanCriteria.F_MaxSqFtSalePrice != null ||\r\n this.loanCriteria.F_IsWorkStarted != null ||\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats != null\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n clearFinanceFilters() {\r\n this.loanCriteria.F_IsChargeOnAdditionalProperty = null;\r\n this.loanCriteria.F_IsFixedRate = null;\r\n this.loanCriteria.F_InterestRateBasis = null;\r\n this.loanCriteria.F_IsBank = null;\r\n }\r\n\r\n showClearForFinanceFilters() {\r\n if (\r\n this.loanCriteria.F_IsChargeOnAdditionalProperty != null ||\r\n this.loanCriteria.F_IsFixedRate != null ||\r\n this.loanCriteria.F_InterestRateBasis != null ||\r\n this.loanCriteria.F_IsBank != null\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n clearAllFilters() {\r\n this.clearClientFilters();\r\n this.clearPropertyFilters();\r\n this.clearFinanceFilters();\r\n }\r\n\r\n onClickFilterCancel() {\r\n this.loanCriteria.F_IsFirstTimeDeveloper =\r\n this.tempLoanCriteria.F_IsFirstTimeDeveloper;\r\n this.loanCriteria.F_NumberOfPreviousDevelopments =\r\n this.tempLoanCriteria.F_NumberOfPreviousDevelopments;\r\n this.loanCriteria.F_ShareholderDepositRequired =\r\n this.tempLoanCriteria.F_ShareholderDepositRequired;\r\n this.loanCriteria.F_IsPersonalName = this.tempLoanCriteria.F_IsPersonalName;\r\n this.loanCriteria.F_IsOffshoreCompany =\r\n this.tempLoanCriteria.F_IsOffshoreCompany;\r\n this.loanCriteria.F_IsMainShareholderOverseas =\r\n this.tempLoanCriteria.F_IsMainShareholderOverseas;\r\n this.loanCriteria.F_PersonalGuaranteeLevel =\r\n this.tempLoanCriteria.F_PersonalGuaranteeLevel;\r\n this.loanCriteria.F_IsAirRights = this.tempLoanCriteria.F_IsAirRights;\r\n this.loanCriteria.F_IsModular = this.tempLoanCriteria.F_IsModular;\r\n this.loanCriteria.F_IsPermittedDevelopmentScheme =\r\n this.tempLoanCriteria.F_IsPermittedDevelopmentScheme;\r\n this.loanCriteria.F_IsGradeOneListed =\r\n this.tempLoanCriteria.F_IsGradeOneListed;\r\n this.loanCriteria.F_IsGradeTwoListed =\r\n this.tempLoanCriteria.F_IsGradeTwoListed;\r\n this.loanCriteria.F_MaxHouseSalesPrice =\r\n this.tempLoanCriteria.F_MaxHouseSalesPrice;\r\n this.loanCriteria.F_MaxFlatUnitPrice =\r\n this.tempLoanCriteria.F_MaxFlatUnitPrice;\r\n this.loanCriteria.F_MaxNumberOfUnits =\r\n this.tempLoanCriteria.F_MaxNumberOfUnits;\r\n // this.loanCriteria.F_MaxPercCommercialForMixedUse =\r\n // this.tempLoanCriteria.F_MaxPercCommercialForMixedUse;\r\n this.loanCriteria.F_MaxSqFtSalePrice =\r\n this.tempLoanCriteria.F_MaxSqFtSalePrice;\r\n this.loanCriteria.F_MaxSqFtSalePriceFlats =\r\n this.tempLoanCriteria.F_MaxSqFtSalePriceFlats;\r\n this.loanCriteria.F_IsWorkStarted = this.tempLoanCriteria.F_IsWorkStarted;\r\n this.loanCriteria.F_IsChargeOnAdditionalProperty =\r\n this.tempLoanCriteria.F_IsChargeOnAdditionalProperty;\r\n this.loanCriteria.F_IsFixedRate = this.tempLoanCriteria.F_IsFixedRate;\r\n this.loanCriteria.F_InterestRateBasis =\r\n this.tempLoanCriteria.F_InterestRateBasis;\r\n this.loanCriteria.F_IsBank = this.tempLoanCriteria.F_IsBank;\r\n }\r\n\r\n checkFilterSelected(property: string) {\r\n let value = this.loanCriteria[property];\r\n if (typeof value === \"boolean\" && value === true) {\r\n return true;\r\n } else if (value != null && typeof value != \"boolean\") {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n filterPropertyToText(property: string) {\r\n let value = this.loanCriteria[property];\r\n if (typeof value == \"boolean\" && value == true) {\r\n return;\r\n } else if (value != null && typeof value != \"boolean\") {\r\n return `: ${this.getPropertyValue(property)}`;\r\n }\r\n return false;\r\n }\r\n\r\n getDisplayTextForProperty(property) {\r\n switch (property) {\r\n case \"F_IsFirstTimeDeveloper\":\r\n return \"1st Time Dev\";\r\n case \"F_ShareholderDepositRequired\":\r\n return \"Shareholder Deposit\";\r\n case \"F_IsPersonalName\":\r\n return \"Personal Name\";\r\n case \"F_IsOffshoreCompany\":\r\n return \"Non-UK Company\";\r\n case \"F_IsMainShareholderOverseas\":\r\n return \"Client Based Overseas\";\r\n case \"F_PersonalGuaranteeLevel\":\r\n return \"PG\";\r\n case \"F_IsAirRights\":\r\n return \"Air Rights Scheme\";\r\n case \"F_IsModular\":\r\n return \"Modular\";\r\n case \"F_IsPermittedDevelopmentScheme\":\r\n return \"PD Scheme\";\r\n case \"F_IsGradeOneListed\":\r\n return \"Grade 1 Listed\";\r\n case \"F_IsGradeTwoListed\":\r\n return \"Grade 2 Listed\";\r\n case \"F_MaxHouseSalesPrice\":\r\n return \"Max Sales Price (Houses)\";\r\n case \"F_MaxSqFtSalePrice\":\r\n return \"Max £/sq.ft (Houses)\";\r\n case \"F_MaxSqFtSalePriceFlats\":\r\n return \"Max £/sq.ft (Flats)\";\r\n case \"F_MaxFlatUnitPrice\":\r\n return \"Max Sales Price (Flats)\";\r\n // case \"F_MaxPercCommercialForMixedUse\":\r\n // return \"Max Commercial or Mixed Use\";\r\n case \"F_NumberOfPreviousDevelopments\":\r\n return \"Previous Developments\";\r\n case \"F_MaxNumberOfUnits\":\r\n return `Max Units`;\r\n case \"F_IsWorkStarted\":\r\n return \"Works Commenced\";\r\n case \"F_IsChargeOnAdditionalProperty\":\r\n return \"Additional Security\";\r\n case \"F_IsFixedRate\":\r\n return \"Fixed Rate\";\r\n case \"F_HasAdverseCredit\":\r\n return \"Adv. Credit\";\r\n case \"F_MaxCommercialFloorspace\":\r\n return \"Com. Floorspace (max %)\";\r\n default:\r\n return \"\";\r\n }\r\n }\r\n\r\n getPropertyValue(property) {\r\n let propertyValue = this.loanCriteria[property];\r\n switch (property) {\r\n case \"F_ShareholderDepositRequired\":\r\n return this.selectListService\r\n .GetShareholderDepositRequired()\r\n .find((item) => item.key === this.getShareholderDepositRequired())\r\n ?.displayName;\r\n case \"F_PersonalGuaranteeLevel\":\r\n return this.selectListService\r\n .GetPersonalGuaranteeLevels()\r\n .find((item) => item.key === this.getPersonalGuaranteeLevelOptions())\r\n ?.displayName;\r\n case \"F_MaxHouseSalesPrice\":\r\n return this.selectListService\r\n .GetMaxHouseSalePrices()\r\n .find((item) => item.key === this.getMaxHouseSalesPrice())\r\n ?.displayName;\r\n case \"F_MaxFlatUnitPrice\":\r\n return this.selectListService\r\n .GetMaxFlatUnitPrices()\r\n .find((item) => item.key === this.getMaxFlatUnitPrice())?.displayName;\r\n case \"F_MaxSqFtSalePrice\":\r\n return this.selectListService\r\n .GetMaxSqFtSalePrices()\r\n .find((item) => item.key === this.getMaxSqFtSalePrice())?.displayName;\r\n case \"F_MaxSqFtSalePriceFlats\":\r\n return this.selectListService\r\n .GetMaxSqFtSalePrices()\r\n .find((item) => item.key === this.getMaxSqFtSalePriceFlats())\r\n ?.displayName;\r\n case \"F_NumberOfPreviousDevelopments\":\r\n return this.selectListService\r\n .GetNumberOfPreviousDevelopments()\r\n .find((item) => item.key === this.getPreviousDevelopments())\r\n ?.displayName;\r\n case \"F_MaxNumberOfUnits\":\r\n return propertyValue;\r\n case \"F_MaxCommercialFloorspace\":\r\n return this.selectListService\r\n .GetMaxCommercialFloorspaceOptions()\r\n .find((item) => item.key === this.loanCriteria.F_MaxCommercialFloorspace)\r\n ?.displayName;\r\n default:\r\n return propertyValue;\r\n }\r\n }\r\n\r\n countFiltersSelected() {\r\n let count = 0;\r\n if (this.loanCriteria) {\r\n this.filterProperties.forEach((property) => {\r\n if (this.checkFilterSelected(property)) {\r\n count++;\r\n }\r\n });\r\n }\r\n return count;\r\n }\r\n\r\n splitCamelCase(str) {\r\n return str\r\n .replace(/([a-z])([A-Z])/g, \"$1 $2\")\r\n .replace(/([A-Z])([A-Z][a-z])/g, \"$1 $2\");\r\n }\r\n\r\n showShareSearchModal() {\r\n this.newSearch = true;\r\n this.loanCriteria.ShowLenderNamesToBorrower =\r\n this.loanCriteria.ShowLenderInfoBrokerOverride;\r\n }\r\n\r\n isShareNoteFormComplete(): boolean {\r\n if (\r\n this.shareEmailSubject == \"undefined\" ||\r\n this.shareEmailSubject == null ||\r\n this.shareEmailSubject.length == 0\r\n ) {\r\n return false;\r\n }\r\n if (\r\n this.shareNote == \"undefined\" ||\r\n this.shareNote == null ||\r\n this.shareNote.length == 0\r\n ) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n openSendToLender(item: LenderResultSummaryDTO) {\r\n this.shareFirstName = item.ContactUserFirstName;\r\n this.lenderEmail = item.ContactUserEmail;\r\n this.showContactLender = true;\r\n }\r\n\r\n sendToLender() {\r\n this.loadingData = true;\r\n this.$lenderresultservice\r\n .sendNoteToLender(\r\n this.lenderEmail,\r\n this.shareEmailSubject,\r\n this.shareNote,\r\n )\r\n .then((success) => {\r\n this.showContactLender = false;\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n /** This will check if the result shared with new user is active */\r\n isResultActive() {\r\n if (this.$routeParams.uniqueId && this.isBroker) {\r\n this.$DevelopmentInputWithNoLoginService\r\n .isResultActive(this.$routeParams.uniqueId)\r\n .then((results) => {\r\n if (results) {\r\n return true;\r\n } else {\r\n this.displayMsg = `Changes have been made to this search by your client, you will now be taken back to your user dashboard`;\r\n this.showMsgToAdminOrBroker = true;\r\n }\r\n });\r\n }\r\n return true;\r\n }\r\n\r\n toggleLenderContactDetails(item: LenderResultSummaryDTO) {\r\n if (item.ShowLenderUserDetails == false) {\r\n this.summarySearchResults.forEach(\r\n (offer) => (offer.ShowLenderUserDetails = false),\r\n );\r\n }\r\n item.ShowLenderUserDetails = !item.ShowLenderUserDetails;\r\n }\r\n\r\n openSendResultsToBorrowerModal() {\r\n if (this.loanCriteria.ShowLenderNamesToBorrower == null) {\r\n this.organisationService.getOrganisation().then((org) => {\r\n this.loanCriteria.ShowLenderNamesToBorrower = org.ShowLenderNames;\r\n });\r\n }\r\n\r\n this.existingborrower = null;\r\n this.clientFirstName = this.loanCriteria.IntroduceeFirstName;\r\n this.clientSurname = this.loanCriteria.IntroduceeSurname;\r\n this.clientEmail = this.loanCriteria.IntroduceeEmail;\r\n this.clientPhoneNumber = this.loanCriteria.IntroduceePhone;\r\n this.newSearch = true;\r\n this.sharedSearch = true;\r\n }\r\n\r\n saveResultsForShareSearchToClient() {\r\n if (!this.isSaveAsClicked) {\r\n this.isSaveClientSearch = true;\r\n this.register(false, this.productResultList);\r\n } else {\r\n this.saveSaveAsSearch();\r\n }\r\n }\r\n\r\n getLenderNames(): string {\r\n if (this.filterLenderNames.length === 1) {\r\n return \"lender \" + this.filterLenderNames[0];\r\n } else {\r\n return \"lenders \" + this.filterLenderNames.join(\", \");\r\n }\r\n }\r\n\r\n isLendersFiltered(): boolean {\r\n //If the search is empty return true\r\n if (!this.summarySearchResults && this.caseLenders) return true;\r\n\r\n if (!this.caseLenders) return false;\r\n\r\n //For all products that have been submitted for DIP and active, check if in the search\r\n return !this.caseLenders.every((lender) => {\r\n if (\r\n lender.CaseLenderState !== CaseLenderStateEnum.Withdrawn &&\r\n lender.CaseLenderState !== CaseLenderStateEnum.Rejected\r\n ) {\r\n const match = this.summarySearchResults.some(\r\n (summarySearchResult) =>\r\n lender.ProductID === summarySearchResult.ProductID,\r\n );\r\n if (!match) {\r\n if (this.filterLenderNames.indexOf(lender.LenderName) === -1) {\r\n this.filterLenderNames.push(lender.LenderName);\r\n }\r\n }\r\n return match;\r\n }\r\n return true;\r\n });\r\n }\r\n\r\n getTotalShortlistedLenders() {\r\n if (this.caseLenders) {\r\n this.caseLendersNotInResults = this.caseLenders.filter(\r\n (cl) =>\r\n !this.comparisonList.some(\r\n (compare) => compare.SeniorProductID == cl.ProductID,\r\n ),\r\n );\r\n\r\n return (\r\n this.comparisonList.length +\r\n (this.caseLendersNotInResults ? this.caseLendersNotInResults.length : 0)\r\n );\r\n } else {\r\n return this.comparisonList.length;\r\n }\r\n }\r\n\r\n reloadPage() {\r\n window.location.reload();\r\n }\r\n\r\n sendMessageToBroker(message) {\r\n this.loadingData = true;\r\n this.borrowerMessage = null;\r\n var newLeadFirstName = null,\r\n newLeadLastName = null,\r\n newLeadEmail = null;\r\n\r\n if (this.$location.path().startsWith(\"/referredSearch\")) {\r\n newLeadFirstName = this.newUser.FirstName;\r\n newLeadLastName = this.newUser.LastName;\r\n newLeadEmail = this.newUser.Email;\r\n } else if (this.enterpriseClientId) {\r\n newLeadFirstName = this.loanCriteria.IntroduceeFirstName;\r\n newLeadLastName = this.loanCriteria.IntroduceeSurname;\r\n newLeadEmail = this.loanCriteria.IntroduceeEmail;\r\n } else {\r\n newLeadFirstName = this.newLeadFirstName;\r\n newLeadLastName = this.newLeadLastName;\r\n newLeadEmail = this.newLeadEmail;\r\n }\r\n\r\n this.organisationService\r\n .sendBorrowerMessageToSearchBroker(\r\n 0,\r\n message,\r\n newLeadFirstName,\r\n newLeadLastName,\r\n newLeadEmail,\r\n ProductTypeEnum.Development,\r\n \"RESULTSSCREEN\",\r\n this.loanCriteria.UniqueRef,\r\n )\r\n .then((results) => {\r\n if (results) {\r\n this.displayMsg = `Message has been sent successfully.`;\r\n this.showMessageToborrower = true;\r\n } else {\r\n this.displayMsg = `There is problem sending a message, Please try later.`;\r\n this.showMessageToborrower = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n closeContactBrokerModal() {\r\n this.showContactBrokerModal = false;\r\n this.showMessageToborrower = false;\r\n this.displayMsg = null;\r\n }\r\n\r\n logPdfDownload(eventName) {\r\n this.eventLogService.logEvent(\r\n eventName,\r\n EventLogEnum.Export,\r\n ProductTypeEnum.Development,\r\n this.$routeParams.uniqueId ? 0 : this.loanCriteria.Id,\r\n this.$routeParams.uniqueId ? this.$routeParams.uniqueId : \"\",\r\n );\r\n }\r\n\r\n calculateMonthsSinceOrigPurchase() {\r\n let date1 = new Date(this.loanCriteria.CI_Dev_DateOfOrigPurch);\r\n let date2 = new Date();\r\n let months;\r\n months = (date2.getFullYear() - date1.getFullYear()) * 12;\r\n months -= date1.getMonth();\r\n months += date2.getMonth();\r\n return months;\r\n }\r\n\r\n saveEnterpriseClientAndRenameDeal() {\r\n this.loadingData = true;\r\n\r\n this.userService.checkEmailExists(this.user.Email).then((response) => {\r\n if (!response) {\r\n let userFullName = this.user.FullName;\r\n let spaceIndex = userFullName.indexOf(\" \");\r\n\r\n let firstName = \"\";\r\n let lastName = \"\";\r\n\r\n // if not space has been added to the name then put the whole name in the first name field\r\n if (spaceIndex == -1) {\r\n firstName = userFullName;\r\n } else {\r\n firstName = userFullName.substring(0, userFullName.indexOf(\" \"));\r\n lastName = userFullName.substring(userFullName.indexOf(\" \") + 1);\r\n }\r\n\r\n this.loanCriteria.IntroduceeFirstName = firstName;\r\n this.loanCriteria.IntroduceeSurname = lastName;\r\n this.loanCriteria.IntroduceeEmail = this.user.Email;\r\n this.loanCriteria.IntroduceePhone = this.user.PhoneNumber;\r\n\r\n var currentDate = new Date();\r\n this.loanCriteria.SearchName = this.projectName;\r\n\r\n var result = {} as DevelopmentWithNoLoginDTO;\r\n (Object).assign(result, this.loanCriteria);\r\n this.$DevelopmentInputWithNoLoginService\r\n .saveChangesToReferredSearch(\r\n result,\r\n this.loanCriteria.UniqueRef,\r\n true,\r\n )\r\n .then((response) => {\r\n this.showEnterpriseRegistrationModal = false;\r\n document.getElementById(\"body\").style.overflow = \"auto\";\r\n if (window.self == window.top) {\r\n sessionStorage.setItem(\"userDetails\", JSON.stringify(this.user));\r\n } else {\r\n this.organisationService.sendDataToParent(\r\n \"userDetails\",\r\n JSON.stringify(this.user),\r\n );\r\n }\r\n\r\n this.userService.sendEventToHubspot(\r\n this.user,\r\n \"ENTERPRISE-CONTACT-REGISTERED\",\r\n false,\r\n this.brokerageOrg?.OrganisationCode,\r\n UserRoleEnum.Client,\r\n this.loanCriteria && this.loanCriteria.OrganisationLinkId != null\r\n ? this.loanCriteria.OrganisationLinkId\r\n : 0,\r\n ProductTypeEnum.Development,\r\n 0,\r\n this.loanCriteria.UniqueRef,\r\n );\r\n this.populateNewLeadInfo(\"borrower\", JSON.stringify(this.user));\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n } else {\r\n this.emailExistsError = true;\r\n this.loadingData = false;\r\n }\r\n });\r\n }\r\n\r\n addClientAndRenameDeal() {\r\n this.loadingData = true;\r\n var result = {} as DevelopmentWithNoLoginDTO;\r\n (Object).assign(result, this.loanCriteria);\r\n this.$DevelopmentInputWithNoLoginService\r\n .addClientToSearch(\r\n result,\r\n this.loanCriteria.UniqueRef,\r\n Number(this.enterpriseClientId),\r\n )\r\n .then((response) => {\r\n if (response) {\r\n this.loanCriteria.IntroduceeFirstName = response.IntroduceeFirstName;\r\n this.loanCriteria.IntroduceeSurname = response.IntroduceeSurname;\r\n this.loanCriteria.IntroduceeEmail = response.IntroduceeEmail;\r\n this.loanCriteria.IntroduceePhone = response.IntroduceePhone;\r\n this.loanCriteria.SearchName = response.SearchName;\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n\r\n gotoSignInPage() {\r\n this.$location.path(\"/login\");\r\n }\r\n\r\n goToLink(url) {\r\n var baseUrl = window.location.href.split(\"#!\")[0] + \"#!\";\r\n var newUrl = baseUrl + url;\r\n window.open(newUrl, \"_blank\");\r\n }\r\n\r\n toggleShowLenderNamesBrokerOverride() {\r\n // this.loanCriteria.ShowLenderInfoBrokerOverride = !this.loanCriteria.ShowLenderInfoBrokerOverride;\r\n this.comparisonList = [];\r\n this.updateResults(undefined, true);\r\n }\r\n\r\n showContactBrokerAndExportButton() {\r\n if (\r\n this.brokerageOrg != null &&\r\n this.loanCriteria != null &&\r\n this.loanCriteria.IntroduceeEmail != null &&\r\n this.loanCriteria.IntroduceeEmail.length > 0\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n //This is used in shortlisting pdf\r\n prepareDataForShortlistPdf() {\r\n this.loanCriteria.ComparisonList = this.comparisonList;\r\n }\r\n\r\n getRegionByPostcode() {\r\n if (\r\n this.loanCriteria.PostcodeSearchString &&\r\n this.loanCriteria.PostcodeSearchString.replace(\" \", \"\").length >= 2\r\n ) {\r\n if (\r\n this.$DevelopmentInputService.isValidPostcodeString(\r\n this.loanCriteria.PostcodeSearchString,\r\n )\r\n ) {\r\n this.dataLoading = true;\r\n this.$DevelopmentInputService\r\n .getRegionByPostcode(this.loanCriteria.PostcodeSearchString)\r\n .then((response) => {\r\n if (response.Location != null) {\r\n this.loanCriteria.CI_Dev_Locations = response.Location;\r\n this.showPostcodeErrorMessage = false;\r\n this.updateSearchViaSlider();\r\n } else {\r\n this.postcodeErrorMsg = response.PostCodeErrorMessage;\r\n this.showPostcodeErrorMessage = true;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.postcodeErrorMsg =\r\n \"At least one letter and one number must be entered e.g. SW1.\";\r\n this.showPostcodeErrorMessage = true;\r\n }\r\n }\r\n }\r\n\r\n isSelectedResult(offer: LenderResultSummaryDTO, index: number) {\r\n return this.comparisonContains(offer) && !offer.IsCaseLender;\r\n }\r\n\r\n isResultAvailableToSelect(offer: LenderResultSummaryDTO) {\r\n return offer.IsCaseLender;\r\n }\r\n\r\n getOrganisationAndBrokerDetails() {\r\n if (!this.isLoggedInUser && !this.isAdmin && !this.isBroker) {\r\n this.loadingData = true;\r\n this.organisationService\r\n .getOrganisationAndBrokerByUniqueRef(this.loanCriteria.UniqueRef)\r\n .then((response) => {\r\n if (response && response.Organisation != null) {\r\n this.brokerageOrg = response.Organisation;\r\n\r\n if (response.Organisation.IsBrickflow) {\r\n this.moveContactBrokerBtnInMiddle = true;\r\n } else {\r\n if (response.Broker != null) {\r\n this.brokerDetail = `${response.Broker.FullName} (${response.Broker.Email})`;\r\n }\r\n\r\n if (this.brokerageOrg.IsWhiteLabelled) {\r\n this.orgName = this.brokerageOrg.Name.replace(/ /g, \"_\");\r\n }\r\n }\r\n }\r\n })\r\n .finally(() => {\r\n this.loadingData = false;\r\n });\r\n }\r\n }\r\n\r\n sortByField(field) {\r\n this.loanCriteria.SortBy = field;\r\n this.sortSummaryResults();\r\n this.saveSearch(false, this.productResultList, true);\r\n this.showSortBy = !this.showSortBy;\r\n }\r\n\r\n sortSummaryResults() {\r\n switch (this.loanCriteria.SortBy) {\r\n case SortByEnum.ROCE:\r\n this.summarySearchResults.sort(\r\n (a, b) => b.ROCE - a.ROCE || a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.TrueMonthlyCost:\r\n this.summarySearchResults.sort(\r\n (a, b) => a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.NetLoanSize:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n b.NetLoan - a.NetLoan || a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.LenderName:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.LoanLabel.localeCompare(b.LoanLabel) ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.InterestRate:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.Interest - b.Interest || a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.ArrangementFee:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.ArrangementFee - b.ArrangementFee ||\r\n a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.DepositEquity:\r\n this.summarySearchResults.sort(\r\n (a, b) =>\r\n a.Deposit - b.Deposit || a.TrueMonthlyCost - b.TrueMonthlyCost,\r\n );\r\n break;\r\n case SortByEnum.LTGDV:\r\n this.$lenderresultservice\r\n .sortProductsByLTGDV(this.summarySearchResults)\r\n .then((sortedResults) => {\r\n this.summarySearchResults = sortedResults;\r\n })\r\n .catch((error) => {\r\n console.error(\"Error sorting by LTGDV:\", error);\r\n });\r\n break;\r\n default:\r\n this.summarySearchResults.sort((a, b) => {\r\n if (a.NetLoan < b.NetLoan) return 1;\r\n if (a.NetLoan > b.NetLoan) return -1;\r\n\r\n if (a.TrueMonthlyCost > b.TrueMonthlyCost) return 1;\r\n if (a.TrueMonthlyCost < b.TrueMonthlyCost) return -1;\r\n\r\n return 0;\r\n });\r\n this.loanCriteria.SortBy = SortByEnum.NetLoanSize;\r\n }\r\n\r\n for (var i = 0; i < this.summarySearchResults.length; i++) {\r\n this.summarySearchResults[i].SelectedRowNumber = i + 1;\r\n }\r\n }\r\n\r\n postLoanCriteriaRetrieveProcessing(loanCriteria) {\r\n this.loanCriteria = loanCriteria;\r\n this.tempLoanRequired = this.loanCriteria.CI_Dev_LoanReq;\r\n if (this.loanCriteria.CI_Dev_LoanReq > 0) {\r\n this.isMaximumLoanRequired = false;\r\n }\r\n this.loanCriteria.SaveQueryAndResults = true;\r\n this.isDIPClicked = this.loanCriteria.IsFullCase;\r\n\r\n this.updateResults(false);\r\n }\r\n\r\n saveSaveAsSearch(attachClient = false) {\r\n this.loadingData = true;\r\n\r\n let newSearchName =\r\n this.isBroker || this.isAdmin\r\n ? this.loanCriteria.SearchName\r\n : this.saveAsSearchName;\r\n\r\n let shareDealDto = {\r\n DealId: this.searchid,\r\n DealName: newSearchName,\r\n ShowLenderNamesAndLogos:\r\n this.loanCriteria?.ShowLenderNamesToBorrower ?? false,\r\n EmailLinkToClient: this.emailClient,\r\n AccessLevel: CaseAccessLevelEnum.FullAccess,\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n\r\n shareDealDto.ClientDto = {\r\n FirstName: this.clientFirstName,\r\n LastName: this.clientSurname,\r\n Email: this.clientEmail,\r\n PhoneNumber: this.clientPhoneNumber,\r\n ClientUserId: this.clientId,\r\n } as ClientDTO;\r\n\r\n this.$CaseService\r\n .saveSaveAsSearch(this.loanCriteria.Id, shareDealDto, attachClient)\r\n .then((result) => {\r\n this.displayMsg = `${newSearchName} search has been saved to your dashboard.`;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n })\r\n .finally(() => {\r\n this.cancelNewSearch();\r\n this.loadingData = false;\r\n this.isSaveAsClicked = false;\r\n this.saveAsSearchName = \"\";\r\n this.showSaveResults = null;\r\n this.showMsg = true;\r\n });\r\n }\r\n\r\n returnShortlistedDealLenderStatusText(item: LenderResultSummaryDTO) {\r\n if (item.IsCaseLender && (this.currentCase.CaseStatus != CaseStatusEnum.Search && this.currentCase.CaseStatus != CaseStatusEnum.NewCase && this.currentCase.CaseStatus != CaseStatusEnum.ReadyToSubmit)) {\r\n switch (item.CaseLenderStatus) {\r\n case CaseLenderStateEnum.Shortlisted:\r\n return \"Shortlisted\";\r\n case CaseLenderStateEnum.Received:\r\n return \"Awaiting DIP\";\r\n case CaseLenderStateEnum.Offered:\r\n return \"DIP Received\";\r\n case CaseLenderStateEnum.Rejected:\r\n return \"Lender Rejected\";\r\n case CaseLenderStateEnum.Withdrawn:\r\n return \"Lender Withdrawn\";\r\n default:\r\n break\r\n }\r\n }\r\n }\r\n\r\n onFilterClick() {\r\n //This is added to show only applied filters on pill\r\n if (this.showFilters && !this.isLoggedInUser) {\r\n this.loanCriteria = { ...this.tempLoanCriteria };\r\n }\r\n this.showFilters = !this.showFilters;\r\n }\r\n\r\n onSortbyClick() {\r\n this.showSortBy = !this.showSortBy;\r\n }\r\n\r\n getSelectedSortByOptionText() {\r\n if (this.loanCriteria) {\r\n switch (this.loanCriteria.SortBy) {\r\n case SortByEnum.TrueMonthlyCost:\r\n return \"True Monthly Cost\";\r\n case SortByEnum.NetLoanSize:\r\n return \"Net Loan Size\";\r\n case SortByEnum.LenderCosts:\r\n return \"Lender Costs (Est.)\";\r\n case SortByEnum.LenderName:\r\n return \"Lender Name (A-Z)\";\r\n case SortByEnum.InterestRate:\r\n return \"Interest Rate\";\r\n case SortByEnum.ArrangementFee:\r\n return \"Arrangement Fee\";\r\n case SortByEnum.DepositEquity:\r\n return \"Est. Deposit/Equity\";\r\n case SortByEnum.ROCE:\r\n return \"ROCE\";\r\n case SortByEnum.LTGDV:\r\n return \"LTGDV\";\r\n default:\r\n return \"\";\r\n }\r\n } else {\r\n return \"\";\r\n }\r\n }\r\n\r\n getSummaryComparisonList() {\r\n\r\n this.summaryComparisonList = [];\r\n for (var i = 0; i < this.comparisonList.length; i++) {\r\n let resultIndex = this.summarySearchResults.findIndex(\r\n (item) => item.ProductID == this.comparisonList[i].SeniorProductID,\r\n );\r\n\r\n if (resultIndex > -1) {\r\n this.summaryComparisonList.push(this.summarySearchResults[resultIndex]);\r\n }\r\n }\r\n\r\n return this.summaryComparisonList;\r\n\r\n }\r\n\r\n isProceedButtonDisabled(): boolean {\r\n if (\r\n !this.comparisonList ||\r\n this.comparisonList.length < 1 ||\r\n this.comparisonList.length > this.noOfShortlistAllowed ||\r\n this.isProceedClicked == true\r\n ) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n onSaveClick() {\r\n if (this.loanCriteria.IntroduceeEmail) {\r\n this.isSaveorSaveAsClicked = true;\r\n this.register(false, this.productResultList);\r\n } else {\r\n this.showShareSearchModal();\r\n }\r\n }\r\n\r\n}\r\n","import { PaymentService } from \"@js/services/PaymentService\";\r\n\r\nexport class ManageLicenseController {\r\n isCancelClicked: boolean = false;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"PaymentService\",\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $paymentService: PaymentService,\r\n ) {}\r\n\r\n updatePrice() {\r\n this.$paymentService.updatePlanPrice().then((response) => {});\r\n }\r\n\r\n cancelSubscription() {\r\n this.$paymentService.cancelSubscription(\"\").then((response) => {\r\n this.isCancelClicked = true;\r\n });\r\n }\r\n\r\n gotoProfilePage() {\r\n this.$location.path(\"/profile\");\r\n }\r\n}\r\n","export const enum StatusEnum {\r\n Invited = 1,\r\n Accepted = 2,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AppPackagePricingDTO } from \"@js/DTO/AppPackagePricingDTO.cs.d\";\r\nimport { CaseMemberDTO } from \"@js/DTO/CaseMemberDTO.cs.d\";\r\nimport { CaseSummaryDTO } from \"@js/DTO/CaseSummaryDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { DevelopmentWithNoLoginDTO } from \"@js/DTO/DevelopmentWithNoLoginDTO.cs.d\";\r\nimport { IntroducerSimpleDTO } from \"@js/DTO/IntroducerSimpleDTO.cs.d\";\r\nimport { InviteDTO } from \"@js/DTO/InviteDTO.cs.d\";\r\nimport { LicenseMasterDTO } from \"@js/DTO/LicenseMasterDTO.cs.d\";\r\nimport { ModuleAppFeatureDTO } from \"@js/DTO/ModuleAppFeatureDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { LicenseMasterStatusEnum } from \"@js/models/enum/LicenseMasterStatusEnum.cs.d\";\r\nimport { StatusEnum } from \"@js/models/enum/StatusEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { CaseSummaryService } from \"@js/services/CaseSummaryService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { DevelopmentInputWithNoLoginService } from \"@js/services/DevelopmentInputWithNoLoginService\";\r\nimport { IntroducerService } from \"@js/services/IntroducerService\";\r\nimport { IntroducerSimpleService } from \"@js/services/IntroducerSimpleService\";\r\nimport { InviteService } from \"@js/services/InviteService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { LicenseService } from \"@js/services/LicenseService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class NewDashboardController {\r\n dataLoading: boolean = false;\r\n showBrokerWelcomeMessage: boolean = false;\r\n orgAdminName: string;\r\n orgAdminEmail: string;\r\n\r\n //Introducers\r\n introducerFirstLogin: boolean = false;\r\n introduceClientModal: number = null;\r\n isProcessingSend: boolean = false; // to control disabling of send button on introduce a borrower modal\r\n clientFirstName: string;\r\n clientSurname: string;\r\n clientEmail: string;\r\n clientPhoneNumber: string;\r\n notifyBorrower: boolean = true;\r\n introducedUsers: ApplicationUserDTO[];\r\n hideCaseCreation: boolean = false;\r\n fetchingResults: boolean = false;\r\n savedResults: DevelopmentInputDTO[];\r\n unsavedIntroducedSearches: DevelopmentWithNoLoginDTO[];\r\n savedIntroducedSearches: DevelopmentInputDTO[] = [];\r\n savedCases: DevelopmentInputDTO[];\r\n allResults: DevelopmentInputDTO[];\r\n selectedResult: number;\r\n caseSummaryList: CaseSummaryDTO[];\r\n /*otherUsersCaseList: CaseSummaryDTO[];*/\r\n lenderName: string;\r\n selectedUser: ApplicationUserDTO;\r\n userSearchResults: ApplicationUserDTO[];\r\n adminUser: boolean = false;\r\n isBroker: boolean = false;\r\n isLender: boolean = false;\r\n isPrimaryApplicant: boolean = true;\r\n isBorrower: boolean = false;\r\n userRolesMessage: string;\r\n currentUser: ApplicationUserDTO = null;\r\n selecteduserName: string = null;\r\n OtherUsers: string[] = null;\r\n newSearchName: string;\r\n link: string;\r\n introducerSimpleDetails: IntroducerSimpleDTO;\r\n\r\n introducerId: number;\r\n\r\n confirmName: boolean = false;\r\n copyCase: number;\r\n caseName: string;\r\n caseId: number;\r\n newShareholders: CaseMemberDTO[];\r\n seeInviteBorrower: boolean = false;\r\n\r\n clientAdminTools: boolean = false;\r\n\r\n showSetPasswordModal: boolean = false;\r\n verifyNewPassword: string;\r\n passwordSetSuccess: boolean = false;\r\n registrationForm: FormData;\r\n modal: ng.IFormController;\r\n\r\n invite: InviteDTO;\r\n invitedUsers: InviteDTO[] = [];\r\n\r\n introducerErrorDisplayed: boolean = false;\r\n applyCaseStatusFilter: boolean = false;\r\n\r\n orderColumn: string = \"LastUpdatedDateTime\";\r\n isAscButton: boolean[] = [true, true, true, true, true, true, true, true];\r\n isAsc: boolean = true;\r\n\r\n locations: Array<{ id: number; value: string }> = [\r\n { id: 0, value: \"Any\" },\r\n { id: 1, value: \"London\" },\r\n { id: 2, value: \"North West\" },\r\n { id: 4, value: \"Midlands\" },\r\n { id: 8, value: \"East of England\" },\r\n { id: 16, value: \"South East\" },\r\n { id: 32, value: \"South West\" },\r\n { id: 64, value: \"North East\" },\r\n { id: 128, value: \"Wales\" },\r\n { id: 256, value: \"Scotland\" },\r\n { id: 512, value: \"Northern Ireland\" },\r\n ];\r\n propertyTypes: Array<{ id: number; value: string }> = [\r\n { id: 0, value: \"Any\" },\r\n { id: 1, value: \"Residential\" },\r\n { id: 2, value: \"Mixed Use\" },\r\n { id: 2048, value: \"Licenced HMO\" },\r\n { id: 4, value: \"Hotel\" },\r\n { id: 8, value: \"Leisure\" },\r\n { id: 16, value: \"Care Home\" },\r\n { id: 32, value: \"Medical\" },\r\n { id: 64, value: \"Office\" },\r\n { id: 128, value: \"Retail\" },\r\n { id: 256, value: \"Light Industrial\" },\r\n { id: 512, value: \"Student\" },\r\n { id: 1024, value: \"Heavy Industrial\" },\r\n { id: 4096, value: \"Land without Planning\" },\r\n { id: 8192, value: \"Education\" },\r\n { id: 16384, value: \"Retirement\" },\r\n ];\r\n\r\n caseStatuses: Array<{ id: number; value: string; order: number }> = [\r\n { id: -1, value: \"Search\", order: 1 },\r\n { id: 0, value: \"New Case\", order: 2 },\r\n { id: 1, value: \"In Progress\", order: 3 },\r\n { id: 2, value: \"Under Review\", order: 4 },\r\n { id: 3, value: \"Ready To Submit\", order: 5 },\r\n { id: 4, value: \"Submitted To Lenders For DIP\", order: 6 },\r\n { id: 5, value: \"Applied\", order: 7 },\r\n { id: 10, value: \"Credit Approved\", order: 8 },\r\n { id: 11, value: \"With Professionals\", order: 9 },\r\n { id: 6, value: \"Completed\", order: 10 },\r\n { id: 7, value: \"Dormant\", order: 11 },\r\n { id: 9, value: \"Submitted To Lenders Pending Review\", order: 12 },\r\n ];\r\n\r\n lenderCaseStatuses: Array<{ id: number; value: string; order: number }> = [\r\n { id: 0, value: \"Shortlisted\", order: 1 },\r\n { id: 1, value: \"Received\", order: 2 },\r\n { id: 2, value: \"Offered\", order: 3 },\r\n { id: 3, value: \"Rejected\", order: 4 },\r\n { id: 4, value: \"Withdrawn\", order: 5 },\r\n { id: 10, value: \"Applied\", order: 6 },\r\n ];\r\n\r\n clientCaseNameFilter: string = null;\r\n statusFilter: CaseStatusEnum = null;\r\n\r\n isProceedClicked: boolean = false;\r\n\r\n userOrganisation: OrganisationDTO = null;\r\n\r\n isBrokerNIntroducer: boolean = false;\r\n showOrgModal: boolean = false;\r\n welcomeSetting: boolean = false;\r\n popupHeader: string;\r\n\r\n appPackagePrices: AppPackagePricingDTO[];\r\n isSelected: boolean = false;\r\n selectedProduct: AppPackagePricingDTO = null;\r\n showPaymentModal: boolean = false;\r\n moduleAppFeatures: ModuleAppFeatureDTO[];\r\n moduleFeatureCount: number = 0;\r\n selecteFeatureCount: number = 0;\r\n licenseStatus: LicenseMasterStatusEnum = LicenseMasterStatusEnum.PaidUp;\r\n selectedProductList: AppPackagePricingDTO[] = [];\r\n billingFrequency: Array<{ id: number; value: string }> = [\r\n { id: 1, value: \"Monthly\" },\r\n { id: 2, value: \"Yearly\" },\r\n ];\r\n selectedBillingFrequency: number;\r\n\r\n referrerOptions = [];\r\n\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$location\",\r\n \"DevelopmentInputService\",\r\n \"DevelopmentInputWithNoLoginService\",\r\n \"UserService\",\r\n \"CaseService\",\r\n \"RoleService\",\r\n \"AuthService\",\r\n \"IntroducerService\",\r\n \"IntroducerSimpleService\",\r\n \"CaseSummaryService\",\r\n \"LenderService\",\r\n \"$cookies\",\r\n \"CaseMemberService\",\r\n \"InviteService\",\r\n \"OrganisationService\",\r\n \"PaymentService\",\r\n \"LicenseService\",\r\n \"SelectListService\",\r\n ];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private $DevelopmentInputservice: DevelopmentInputService,\r\n private $DevelopmentInputWithNoLoginService: DevelopmentInputWithNoLoginService,\r\n private $user: UserService,\r\n private $CaseService: CaseService,\r\n private roleService: RoleService,\r\n private authService: AuthService,\r\n private $IntroducerService: IntroducerService,\r\n private $IntroducerSimpleService: IntroducerSimpleService,\r\n private $CaseSummaryService: CaseSummaryService,\r\n private $LenderService: LenderService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $applicantservice: CaseMemberService,\r\n private inviteService: InviteService,\r\n private organisationService: OrganisationService,\r\n private $paymentService: PaymentService,\r\n private licenseService: LicenseService,\r\n private selectListService: SelectListService,\r\n ) {\r\n this.initialise();\r\n\r\n if ((this.$rootScope as any).openWelcomeBrokerModal) {\r\n this.authService.getadminProfile().then((result) => {\r\n if (result) {\r\n this.orgAdminName = result.UserName;\r\n this.orgAdminEmail = result.Email;\r\n this.showBrokerWelcomeMessage = true;\r\n }\r\n });\r\n }\r\n\r\n this.referrerOptions = this.selectListService.GetReferrerOptions();\r\n }\r\n\r\n initialise() {\r\n //Introducers\r\n this.introducerFirstLogin = (this.$rootScope as any).introducerFirstLogin;\r\n\r\n //get type of user\r\n this.roleService.GetUserRoles().then((result) => {\r\n if (result.filter((x) => x.toLowerCase() == \"admin\").length > 0) {\r\n this.adminUser = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"broker\").length > 0) {\r\n this.isBroker = true;\r\n this.isPrimaryApplicant = false;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"lender\").length > 0) {\r\n this.isLender = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"client\").length > 0) {\r\n this.isBorrower = true;\r\n }\r\n\r\n //This is do hide introduced search\r\n if (\r\n this.isBroker &&\r\n result.filter((x) => x.toLowerCase() == \"introducer\").length > 0\r\n ) {\r\n this.isBrokerNIntroducer = true;\r\n }\r\n\r\n this.userRolesMessage = this.generateUserRoleString();\r\n\r\n this.authService.getUpdatedProfile().then((prof) => {\r\n this.currentUser = prof;\r\n if ((this.$rootScope as any)?.currentUser?.SubscriptionStatus) {\r\n (this.$rootScope as any).currentUser.SubscriptionStatus =\r\n this.currentUser.SubscriptionStatus;\r\n }\r\n this.organisationService.getOrganisation().then((response) => {\r\n if (response.Id != 0) {\r\n this.userOrganisation = response;\r\n }\r\n\r\n this.popupHeader = \"Customise Premium Features\";\r\n\r\n // only display the broker admin welcome modal once we've retrieved the org info, otherwise there is a delay in showing the company name\r\n if (prof.IsOrganisationAdmin) {\r\n if (\r\n prof.DisplayOrganisationAdminWelcomepage &&\r\n !sessionStorage.getItem(\"showwelcome\")\r\n ) {\r\n //temp comment to show payment engine modal\r\n // this.showOrgModal = prof.DisplayOrganisationAdminWelcomepage;\r\n this.welcomeSetting = !prof.DisplayOrganisationAdminWelcomepage;\r\n sessionStorage.setItem(\"showwelcome\", \"show\");\r\n }\r\n }\r\n });\r\n\r\n if (this.$routeParams.licensemasterId) {\r\n this.licenseService\r\n .fetch(this.$routeParams.licensemasterId)\r\n .then((license: LicenseMasterDTO) => {\r\n this.licenseStatus = license.Status;\r\n if (\r\n license.Status == LicenseMasterStatusEnum.Unpaid ||\r\n license.Status == LicenseMasterStatusEnum.PayFailure ||\r\n license.Status == LicenseMasterStatusEnum.PaidUp\r\n ) {\r\n this.showPaymentModal = true;\r\n }\r\n });\r\n }\r\n\r\n // get invited list of users\r\n this.inviteService\r\n .getInvitedBorrowers(this.currentUser.Id)\r\n .then((result) => {\r\n this.invitedUsers = result;\r\n });\r\n\r\n if (this.isLender) {\r\n //this.$LenderService.getLenderDetailsByUserId(this.currentUser.Id).then((results) => {\r\n // this.lenderName = results.Name;\r\n //});\r\n }\r\n\r\n //If half-registered user hasn't set a password, then prompt them to set one\r\n if (this.currentUser.TemporaryAccount === true) {\r\n this.showSetPasswordModal = true;\r\n }\r\n\r\n //Get my introducer's details\r\n this.$IntroducerSimpleService.getintroducerdetails().then((i) => {\r\n this.introducerSimpleDetails = i;\r\n });\r\n\r\n this.introducerId = prof.RegisteredIntroducerId;\r\n if (prof.RegisteredIntroducerId) {\r\n this.updateIntroducedSearches(prof.RegisteredIntroducerId);\r\n //this.updateIntroducedClientList(prof.RegisteredIntroducerId);\r\n }\r\n\r\n //newdashboard\r\n if ((this.$rootScope as any).clientUsernameBeingViewed) {\r\n this.updateResults();\r\n } else {\r\n //this.$CaseSummaryService.getmycasesandsearches(this.currentUser.UserName).then((results) => {\r\n // this.caseSummaryList = results;\r\n //});\r\n\r\n this.selecteduserName = this.currentUser.UserName;\r\n }\r\n });\r\n });\r\n }\r\n\r\n viewClientsDashboard(userName: string) {\r\n //Look up client's account details\r\n this.dataLoading = true;\r\n this.$user.searchByEmail(userName).then((users) => {\r\n this.selectedUser = users[0];\r\n this.selecteduserName = users[0].Email;\r\n (this.$rootScope as any).clientUsernameBeingViewed = users[0].Email;\r\n this.updateResults();\r\n this.clientAdminTools = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n exitClientView(): void {\r\n (this.$rootScope as any).clientUsernameBeingViewed = null;\r\n this.selecteduserName = this.currentUser.UserName;\r\n this.updateResults();\r\n this.clientAdminTools = true;\r\n }\r\n\r\n userLookup(userSearchTerm: string) {\r\n this.fetchingResults = true;\r\n this.$user\r\n .searchByEmail(userSearchTerm)\r\n .then((response) => {\r\n if (this.isBroker && this.currentUser.IsOrganisationAdmin) {\r\n this.userSearchResults = response.filter(\r\n (x) =>\r\n x.OrganisationReferralId == this.currentUser.OrganisationId ||\r\n x.OrganisationId == this.currentUser.OrganisationId,\r\n );\r\n } else if (this.isBroker) {\r\n this.userSearchResults = response.filter(\r\n (x) =>\r\n x.OrganisationReferralId == this.currentUser.OrganisationId &&\r\n !x.OrganisationId &&\r\n !x.IsOrganisationAdmin,\r\n );\r\n } else {\r\n this.userSearchResults = response;\r\n }\r\n })\r\n .finally(() => {\r\n this.fetchingResults = false;\r\n });\r\n }\r\n\r\n saveBlankSearch() {\r\n this.fetchingResults = true;\r\n\r\n let newDTO = {} as DevelopmentInputDTO;\r\n newDTO.OwnerUser = this.selecteduserName;\r\n newDTO.UserId = this.selectedUser.Id;\r\n newDTO.SaveQueryAndResults = true;\r\n\r\n var currentdate = new Date();\r\n newDTO.SearchName = this.newSearchName\r\n ? this.newSearchName\r\n : \"My Loan Search \" +\r\n currentdate.getDate() +\r\n \"/\" +\r\n (currentdate.getMonth() + 1) +\r\n \"/\" +\r\n currentdate.getFullYear();\r\n\r\n newDTO.CI_Dev_Contingency = 0.05;\r\n newDTO.CI_Dev_BuildTerm = 12;\r\n newDTO.CI_Dev_LoanTermReq = 18;\r\n newDTO.CI_Dev_DateOfOrigPurch = new Date();\r\n\r\n this.$DevelopmentInputservice\r\n .addBlankSearch(newDTO)\r\n .then((response) => {\r\n let newCaseSummary = {\r\n CaseName: response.SearchName,\r\n CaseStatus: CaseStatusEnum.Search,\r\n DevelopmentInputID: response.Id,\r\n Client: this.adminUser ? response.OwnerUser : \"\", // The user should always be an admin when adding a blank search but adding the check anyway\r\n PropertyType: response.CI_EndPropType,\r\n Location: response.CI_Dev_Locations,\r\n LandCost: response.Dev_TotLndCostAdj,\r\n BuildCost: response.Dev_TotBuildCostsAdj,\r\n GDV: response.CI_GDVCalculated,\r\n } as CaseSummaryDTO;\r\n this.caseSummaryList.push(newCaseSummary);\r\n })\r\n .finally(() => {\r\n this.fetchingResults = false;\r\n });\r\n }\r\n\r\n newBlankCase() {\r\n this.fetchingResults = true;\r\n this.$CaseService\r\n .newBlankCase(this.currentUser, this.isPrimaryApplicant)\r\n .then((newBlankCaseDto) => {\r\n if (newBlankCaseDto && newBlankCaseDto.NewCaseId) {\r\n this.viewCase(newBlankCaseDto.NewCaseId);\r\n this.fetchingResults = false;\r\n }\r\n });\r\n }\r\n\r\n updateResults() {\r\n this.fetchingResults = true;\r\n\r\n if (this.selecteduserName) {\r\n this.selecteduserName = this.selecteduserName;\r\n } else if ((this.$rootScope as any).clientUsernameBeingViewed) {\r\n this.selecteduserName = (\r\n this.$rootScope as any\r\n ).clientUsernameBeingViewed;\r\n } else {\r\n this.selecteduserName = this.currentUser.UserName;\r\n }\r\n\r\n if (this.selecteduserName !== this.currentUser.UserName) {\r\n this.$user.searchByEmail(this.selecteduserName).then((users) => {\r\n this.selectedUser = users[0];\r\n });\r\n }\r\n\r\n //this.$CaseSummaryService.getmycasesandsearches(this.selecteduserName, this.clientCaseNameFilter, this.statusFilter).then((results) => {\r\n // this.caseSummaryList = results;\r\n //}).catch((error) => {\r\n\r\n //}).finally(() => {\r\n // this.fetchingResults = false;\r\n //});\r\n }\r\n\r\n updateIntroducedSearches(RegisteredIntroducerId: number) {\r\n if (!RegisteredIntroducerId) {\r\n return;\r\n }\r\n this.$DevelopmentInputWithNoLoginService\r\n .fetchByIntroducerId(RegisteredIntroducerId)\r\n .then((results) => {\r\n this.unsavedIntroducedSearches = results.filter(\r\n (r) => r.IntroducedSearchStatus < 2,\r\n );\r\n let savedIntroducedSearchesIdentified = results.filter(\r\n (r) => r.IntroducedSearchStatus >= 2,\r\n );\r\n if (savedIntroducedSearchesIdentified.length > 0) {\r\n this.$DevelopmentInputservice\r\n .fetchByIntroducerId(RegisteredIntroducerId)\r\n .then((devInputResults) => {\r\n this.savedIntroducedSearches = devInputResults;\r\n });\r\n }\r\n\r\n this.updateIntroducedClientList();\r\n });\r\n }\r\n\r\n updateIntroducedClientList() {\r\n this.$user.getintroducees(this.currentUser.Id).then((introducedUsers) => {\r\n this.introducedUsers = introducedUsers;\r\n });\r\n }\r\n ApplyFilterOnUsers() {\r\n this.clientAdminTools = false;\r\n this.savedResults = this.allResults.filter(\r\n (x) => !x.IsFullCase && x.OwnerUser == this.selecteduserName,\r\n );\r\n this.savedCases = this.allResults.filter(\r\n (x) => x.IsFullCase && x.OwnerUser == this.selecteduserName,\r\n );\r\n (this.$rootScope as any).clientUsernameBeingViewed = this.selecteduserName;\r\n }\r\n\r\n makeCase(loanCriteriaId: number, isPrimaryApplicant) {\r\n this.isProceedClicked = true;\r\n this.$CaseService\r\n .promotesearchtocase(loanCriteriaId, null, null, isPrimaryApplicant)\r\n .then((newCaseId: number) => {\r\n if (newCaseId) {\r\n this.viewCase(newCaseId);\r\n } else {\r\n this.isProceedClicked = false;\r\n }\r\n })\r\n .catch((response) => {\r\n this.isProceedClicked = false;\r\n });\r\n }\r\n // changed for newcasedashboard\r\n delete(\r\n loanCriteriaId: number,\r\n loanType: number,\r\n index: number,\r\n caseId: number,\r\n ) {\r\n switch (loanType) {\r\n case 0:\r\n //Full case and Saved search\r\n this.$DevelopmentInputservice\r\n .markasdeleted(loanCriteriaId)\r\n .then((success) => {\r\n if (caseId) {\r\n this.$CaseService.markasdeleted(caseId).then((success) => {});\r\n }\r\n })\r\n .finally(() => {\r\n this.caseSummaryList = this.caseSummaryList.filter(\r\n (caseSummary) => caseSummary.DevelopmentInputID != loanCriteriaId,\r\n );\r\n });\r\n\r\n break;\r\n case 2:\r\n //Introducer: Referred search, not claimed by introducee yet\r\n this.$DevelopmentInputWithNoLoginService\r\n .markasdeleted(loanCriteriaId)\r\n .then((success) => {\r\n this.unsavedIntroducedSearches.splice(index, 1);\r\n })\r\n .finally(() => {\r\n this.caseSummaryList = this.caseSummaryList.filter(\r\n (caseSummary) => caseSummary.DevelopmentInputID != loanCriteriaId,\r\n );\r\n });\r\n break;\r\n case 3:\r\n //Introducer: Referred search, claimed by introducee\r\n this.$DevelopmentInputservice\r\n .markasdeleted(loanCriteriaId)\r\n .then((success) => {\r\n this.savedIntroducedSearches.splice(index, 1);\r\n });\r\n break;\r\n }\r\n }\r\n\r\n // changed for newcasedashboard\r\n deleteForCaseSumarry(\r\n loanCriteriaId: number,\r\n loanType: number,\r\n index: number,\r\n caseId: number,\r\n ) {\r\n switch (loanType) {\r\n case 0:\r\n //Full case and Saved search\r\n this.$DevelopmentInputservice\r\n .markasdeleted(loanCriteriaId)\r\n .then((success) => {\r\n if (caseId) {\r\n this.$CaseService.markasdeleted(caseId).then((success) => {});\r\n }\r\n })\r\n .finally(() => {\r\n this.caseSummaryList = this.caseSummaryList.filter(\r\n (caseSummary) => caseSummary.DevelopmentInputID != loanCriteriaId,\r\n );\r\n });\r\n\r\n break;\r\n case 2:\r\n //Introducer: Referred search, not claimed by introducee yet\r\n this.$DevelopmentInputWithNoLoginService\r\n .markasdeleted(loanCriteriaId)\r\n .then((success) => {})\r\n .finally(() => {\r\n this.caseSummaryList = this.caseSummaryList.filter(\r\n (caseSummary) => caseSummary.DevelopmentInputID != loanCriteriaId,\r\n );\r\n });\r\n break;\r\n }\r\n }\r\n\r\n viewCase(caseId: number) {\r\n //this.$CaseService.getcasefromsearch(developmentId).then((result) => {\r\n //if (result)\r\n this.$location.path(\"/casedashboard/\" + caseId);\r\n //});\r\n }\r\n\r\n //this is not used any more\r\n viewCaseByDIId(newCaseId: number) {\r\n this.$location.path(\"/casedashboard/\" + newCaseId);\r\n }\r\n\r\n viewResults(caseSummary: CaseSummaryDTO) {\r\n if (caseSummary.CaseStatus != CaseStatusEnum.Search && caseSummary.CaseID) {\r\n //this.$CaseService.getcasefromsearch(caseSummary.DevelopmentInputID).then((result) => {\r\n //need to tweak a bit when we have all the case status.\r\n //this.$CaseService.updateTubeMap(result.CaseStatus);\r\n this.$location.path(\r\n \"/results/\" + caseSummary.DevelopmentInputID + \"/\" + caseSummary.CaseID,\r\n );\r\n //});\r\n } else if (caseSummary.UniqueRef != null) {\r\n this.$location.path(\"/referredSearch/\" + caseSummary.UniqueRef);\r\n } else if (caseSummary.DevelopmentInputID) {\r\n this.$location.path(\"/results/\" + caseSummary.DevelopmentInputID);\r\n }\r\n }\r\n\r\n viewIntroducedResults(loanCriteria: DevelopmentWithNoLoginDTO) {\r\n this.$location.path(\"/referredSearch/\" + loanCriteria.UniqueRef);\r\n }\r\n\r\n openModal(developmentInput: CaseSummaryDTO) {\r\n this.confirmName = true;\r\n this.copyCase = developmentInput.DevelopmentInputID;\r\n this.caseId = developmentInput.CaseID;\r\n this.$DevelopmentInputservice\r\n .fetch(developmentInput.DevelopmentInputID)\r\n .then((result) => {\r\n this.caseName = result.SearchName + \" - Copy\";\r\n });\r\n }\r\n\r\n copy() {\r\n this.$DevelopmentInputservice\r\n .copyCase(this.copyCase, this.caseName)\r\n .then((response) => {\r\n let newCaseId = response;\r\n if (newCaseId) {\r\n this.$applicantservice.copyShareholder(this.caseId, newCaseId);\r\n this.viewCase(newCaseId);\r\n }\r\n })\r\n .finally(() => {\r\n this.fetchingResults = false;\r\n });\r\n }\r\n\r\n cancel() {\r\n this.confirmName = false;\r\n delete this.copyCase;\r\n }\r\n\r\n newloan() {\r\n (this.$rootScope as any).loanCriteria = null;\r\n this.$location.path(\"/criteria/0/0/1\");\r\n }\r\n\r\n registerIntroducer() {\r\n this.$location.path(\"/registerintroducer\");\r\n }\r\n\r\n introduceClient() {\r\n this.isProcessingSend = true;\r\n this.invite = {\r\n FirstName: this.clientFirstName,\r\n Email: this.clientEmail,\r\n LastName: this.clientSurname,\r\n InviteerUserId: this.currentUser.Id,\r\n UserId: null,\r\n PhoneNumber: this.clientPhoneNumber,\r\n Status: StatusEnum.Invited,\r\n } as InviteDTO;\r\n\r\n this.inviteService.addUpdate(this.invite).then((response) => {\r\n this.invitedUsers.push(response);\r\n\r\n this.$IntroducerService\r\n .introduceClient(\r\n response.FirstName,\r\n response.Email,\r\n response.LastName,\r\n response.PhoneNumber,\r\n response.guid,\r\n )\r\n .then((success) => {\r\n this.introduceClientModal = 2;\r\n this.dataLoading = false;\r\n this.isProcessingSend = false;\r\n })\r\n .finally(() => {\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.clientPhoneNumber;\r\n });\r\n });\r\n }\r\n\r\n inviteBorrower() {\r\n this.invite = {\r\n FirstName: this.clientFirstName,\r\n Email: this.clientEmail,\r\n LastName: this.clientSurname,\r\n InviteerUserId: this.currentUser.Id,\r\n UserId: null,\r\n PhoneNumber: this.clientPhoneNumber,\r\n Status: StatusEnum.Invited,\r\n } as InviteDTO;\r\n\r\n this.inviteService.addUpdate(this.invite).then((response) => {\r\n this.invitedUsers.push(response);\r\n\r\n this.$user.GetUserOrganisation().then((result) => {\r\n if (this.invite && result) {\r\n this.organisationService\r\n .inviteBorrowers(this.invite, result.UniqueRef)\r\n .then((success) => {\r\n this.introduceClientModal = 9;\r\n this.dataLoading = false;\r\n })\r\n .finally(() => {\r\n this.introduceClientModal = 9;\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.clientPhoneNumber;\r\n });\r\n }\r\n });\r\n });\r\n }\r\n\r\n sendLinkToUser() {\r\n this.$IntroducerService\r\n .sendLinkToUser(\r\n this.currentUser.FirstName,\r\n this.currentUser.Email,\r\n this.currentUser.Id,\r\n )\r\n .then((success) => {\r\n this.introduceClientModal = 6;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n copyLinkToClipboard() {\r\n this.$IntroducerService\r\n .copyLinkToClipboard(this.currentUser.Id)\r\n .then((response) => {\r\n this.link = response.toString();\r\n navigator.clipboard.writeText(this.link);\r\n this.introduceClientModal = 7;\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n close() {\r\n this.introduceClientModal = null;\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n }\r\n\r\n introducerSendResultsToClient(id: number, notifyBorrower: boolean = false) {\r\n this.dataLoading = true;\r\n this.$DevelopmentInputservice.fetch(id).then((response) => {\r\n this.$IntroducerService\r\n .sendResultsToClient(\r\n response,\r\n this.clientFirstName,\r\n this.clientSurname,\r\n this.clientEmail,\r\n notifyBorrower,\r\n )\r\n .then((success) => {\r\n this.introduceClientModal = 4;\r\n })\r\n .catch((reason) => {\r\n this.introducerErrorDisplayed = true;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n });\r\n });\r\n }\r\n\r\n introducerRefreshSearchesAndClients() {\r\n //Trigger a refresh to show results\r\n this.updateIntroducedSearches(this.introducerId);\r\n this.clientAdminTools = true;\r\n }\r\n\r\n go(path) {\r\n this.$location.path(path);\r\n }\r\n\r\n completeAccount() {\r\n this.currentUser.TemporaryAccount = false;\r\n this.currentUser.Roles = [];\r\n this.currentUser.Roles.push(\"Client\");\r\n if (this.currentUser.ApplicantDefinedRole == 0) {\r\n this.currentUser.NewUserEmailJourneyStarted = true;\r\n }\r\n this.$user.addUpdate(this.currentUser).then((response) => {\r\n this.passwordSetSuccess = true;\r\n });\r\n }\r\n\r\n afterSetPasswordContinue() {\r\n //User needs to be logged out and logged in again\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.authService.logout(false);\r\n }\r\n this.authService\r\n .login(\r\n this.currentUser.Email,\r\n this.currentUser.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n let expiry: Date = response;\r\n this.$cookies.put(\"user_firstname\", this.currentUser.FirstName, {\r\n expires: expiry,\r\n });\r\n this.showSetPasswordModal = false;\r\n this.initialise();\r\n });\r\n }\r\n\r\n /**\r\n * Order alphabetically\r\n * @param column\r\n * @param index\r\n */\r\n order(column: string, index: number) {\r\n this.isAscButton[index] = !this.isAscButton[index];\r\n this.isAsc = this.isAscButton[index];\r\n this.orderColumn = column;\r\n\r\n this.caseSummaryList.sort((rowA: CaseSummaryDTO, rowB: CaseSummaryDTO) => {\r\n let rowAValue = rowA[column];\r\n let rowBValue = rowB[column];\r\n\r\n if (rowAValue == rowBValue) {\r\n return 0;\r\n }\r\n\r\n return this.isAsc\r\n ? rowAValue < rowBValue\r\n ? -1\r\n : 1\r\n : rowAValue < rowBValue\r\n ? 1\r\n : -1;\r\n });\r\n }\r\n\r\n /**\r\n * Order numerically\r\n * @param column\r\n * @param index\r\n */\r\n orderNumber(column, index: number) {\r\n this.isAscButton[index] = !this.isAscButton[index];\r\n this.isAsc = this.isAscButton[index];\r\n this.orderColumn = column;\r\n\r\n this.caseSummaryList.sort((rowA: CaseSummaryDTO, rowB: CaseSummaryDTO) => {\r\n let rowAValue = rowA[column];\r\n let rowBValue = rowB[column];\r\n\r\n return this.isAsc ? rowAValue - rowBValue : rowBValue - rowAValue;\r\n });\r\n }\r\n\r\n /**\r\n * Order by the display value e.g. for enums\r\n * @param column\r\n * @param index\r\n */\r\n orderByDisplayValue(column: string, index: number) {\r\n this.isAscButton[index] = !this.isAscButton[index];\r\n this.isAsc = this.isAscButton[index];\r\n this.orderColumn = column;\r\n\r\n var lookup: Array<{ id: number; value: string }>;\r\n\r\n switch (column) {\r\n case \"PropertyType\": {\r\n lookup = this.propertyTypes;\r\n break;\r\n }\r\n case \"Location\": {\r\n lookup = this.locations;\r\n break;\r\n }\r\n default: {\r\n //Error - undefined sort column\r\n }\r\n }\r\n\r\n this.caseSummaryList.sort((rowA: CaseSummaryDTO, rowB: CaseSummaryDTO) => {\r\n let rowAValue = lookup.find((a) => a.id == rowA[column]).value;\r\n let rowBValue = lookup.find((b) => b.id == rowB[column]).value;\r\n\r\n if (rowAValue == rowBValue) {\r\n return 0;\r\n }\r\n\r\n return this.isAsc\r\n ? rowAValue < rowBValue\r\n ? -1\r\n : 1\r\n : rowAValue < rowBValue\r\n ? 1\r\n : -1;\r\n });\r\n }\r\n\r\n /**\r\n * Order by a specified numeric order\r\n * @param column\r\n * @param index\r\n */\r\n orderByOrderNumber(column: string, index: number) {\r\n this.isAscButton[index] = !this.isAscButton[index];\r\n this.isAsc = this.isAscButton[index];\r\n this.orderColumn = column;\r\n\r\n var lookup: Array<{ id: number; value: string; order: number }>;\r\n\r\n switch (column) {\r\n case \"CaseStatus\": {\r\n lookup = this.caseStatuses;\r\n break;\r\n }\r\n case \"CaseLenderState\": {\r\n lookup = this.lenderCaseStatuses;\r\n break;\r\n }\r\n default: {\r\n //Error - undefined sort column\r\n }\r\n }\r\n\r\n this.caseSummaryList.sort((rowA: CaseSummaryDTO, rowB: CaseSummaryDTO) => {\r\n let rowAOrder = lookup.find((a) => a.id == rowA[column]).order;\r\n let rowBOrder = lookup.find((b) => b.id == rowB[column]).order;\r\n\r\n return this.isAsc ? rowAOrder - rowBOrder : rowBOrder - rowAOrder;\r\n });\r\n }\r\n\r\n /**\r\n * Opens the Share search modal\r\n * @param item\r\n */\r\n openShareSearchModal(item: CaseSummaryDTO) {\r\n this.selectedResult = item.DevelopmentInputID;\r\n this.introduceClientModal = 3;\r\n\r\n if (\r\n this.roleService.isAdminUser &&\r\n item.ClientEmail != this.currentUser.UserName\r\n ) {\r\n this.clientFirstName = item.ClientFirstName;\r\n this.clientSurname = item.ClientSurname;\r\n this.clientEmail = item.ClientEmail;\r\n } else {\r\n this.clientFirstName = \"\";\r\n this.clientSurname = \"\";\r\n this.clientEmail = \"\";\r\n }\r\n }\r\n\r\n showResultButton(caseStatus: CaseStatusEnum) {\r\n if (\r\n caseStatus == CaseStatusEnum.SubmittedToLendersForHoT ||\r\n caseStatus == CaseStatusEnum.Applied ||\r\n caseStatus == CaseStatusEnum.CreditApproved ||\r\n caseStatus == CaseStatusEnum.Completed ||\r\n caseStatus == CaseStatusEnum.WithProfessionals\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n closeWelcomePopup() {\r\n if (\r\n this.currentUser.DisplayOrganisationAdminWelcomepage ==\r\n this.welcomeSetting\r\n ) {\r\n this.currentUser.DisplayOrganisationAdminWelcomepage =\r\n !this.welcomeSetting;\r\n this.$user.addUpdate(this.currentUser).then((userResponse) => {\r\n this.showOrgModal = false;\r\n });\r\n } else {\r\n this.showOrgModal = false;\r\n }\r\n }\r\n\r\n fillRegisterForm() {\r\n this.currentUser.Location = 1;\r\n this.currentUser.Password = \"test\";\r\n (this.currentUser as any).ConfirmPassword = \"test\";\r\n }\r\n\r\n generateUserRoleString() {\r\n var str = \"Your role: \";\r\n\r\n if (this.adminUser) {\r\n str += \"Admin \";\r\n } else if (this.isBroker) {\r\n if (this.isBrokerNIntroducer) {\r\n str += \"Broker and Introducer \";\r\n } else {\r\n str += \"Broker \";\r\n }\r\n } else if (this.isLender) {\r\n str += \"Lender \";\r\n if (this.lenderName) {\r\n str += \"(\" + this.lenderName + \")\";\r\n }\r\n } else if (this.isBorrower) {\r\n str += \"Borrower \";\r\n if (this.userOrganisation?.Name?.length > 0) {\r\n str +=\r\n \"(Your Broker Organisation: \" + this.userOrganisation?.Name + \")\";\r\n }\r\n }\r\n return str;\r\n }\r\n}\r\n","import { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseLenderService } from \"@js/services/CaseLenderService\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { CaseSummaryService } from \"@js/services/CaseSummaryService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { DevelopmentInputWithNoLoginService } from \"@js/services/DevelopmentInputWithNoLoginService\";\r\nimport { IntroducerService } from \"@js/services/IntroducerService\";\r\nimport { IntroducerSimpleService } from \"@js/services/IntroducerSimpleService\";\r\nimport { InviteService } from \"@js/services/InviteService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { LicenseService } from \"@js/services/LicenseService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { TaskItemService } from \"@js/services/TaskItemService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class NewSearchSelectionsController {\r\n selectedRole: number;\r\n\r\n RoleEnum = {\r\n All: 0,\r\n DevelopmentFinance: 1,\r\n BridgingFinance: 2,\r\n Clients: 3,\r\n };\r\n\r\n selectedNavMenu: number;\r\n brokerageOrg: OrganisationDTO;\r\n hasBridging: boolean = false;\r\n hasCommercial: boolean = false;\r\n dataLoading: boolean = false;\r\n selectedProduct: string = null;\r\n userDetails: string = null;\r\n\r\n isCommercialOwnerOccupiedActive: boolean = false;\r\n\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$location\",\r\n \"DevelopmentInputService\",\r\n \"DevelopmentInputWithNoLoginService\",\r\n \"UserService\",\r\n \"CaseService\",\r\n \"RoleService\",\r\n \"AuthService\",\r\n \"IntroducerService\",\r\n \"IntroducerSimpleService\",\r\n \"CaseSummaryService\",\r\n \"LenderService\",\r\n \"$cookies\",\r\n \"CaseMemberService\",\r\n \"InviteService\",\r\n \"OrganisationService\",\r\n \"PaymentService\",\r\n \"LicenseService\",\r\n \"CaseLenderService\",\r\n \"UserService\",\r\n \"TaskItemService\",\r\n \"SelectListService\",\r\n ];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private $DevelopmentInputService: DevelopmentInputService,\r\n private $DevelopmentInputWithNoLoginService: DevelopmentInputWithNoLoginService,\r\n private $user: UserService,\r\n private $CaseService: CaseService,\r\n private roleService: RoleService,\r\n private authService: AuthService,\r\n private $IntroducerService: IntroducerService,\r\n private $IntroducerSimpleService: IntroducerSimpleService,\r\n private $CaseSummaryService: CaseSummaryService,\r\n private $LenderService: LenderService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $applicantservice: CaseMemberService,\r\n private inviteService: InviteService,\r\n private organisationService: OrganisationService,\r\n private $paymentService: PaymentService,\r\n private licenseService: LicenseService,\r\n private caseLenderService: CaseLenderService,\r\n private userService: UserService,\r\n private taskItemService: TaskItemService,\r\n private selectListService: SelectListService,\r\n ) {\r\n this.authService.isCommercialOwnerOccupiedActive().then((response) => {\r\n this.isCommercialOwnerOccupiedActive = response;\r\n });\r\n\r\n this.getUser()\r\n .then(() => {\r\n (this.$rootScope as any).isInvitedAndHasReadonlyAccess = false;\r\n\r\n if (this.$routeParams[\"Type\"] == \"bridging\") {\r\n this.selectedRole = this.RoleEnum.BridgingFinance;\r\n this.selectedNavMenu = this.RoleEnum.BridgingFinance;\r\n } else {\r\n this.selectedRole = this.RoleEnum.All;\r\n this.selectedNavMenu = this.RoleEnum.All;\r\n }\r\n\r\n if (window.self == window.top && $cookies.get(\"access_token\")) {\r\n this.organisationService\r\n .getOrganisationProductAccess()\r\n .then((response) => {\r\n this.hasBridging = response.HasBridging;\r\n this.hasCommercial = response.HasCommercial;\r\n this.checkProductSelected();\r\n });\r\n } else {\r\n if (\r\n !location.pathname.startsWith(\"/otmx\") &&\r\n !location.pathname.startsWith(\"/lnhn\")\r\n ) {\r\n var orgCode = location.pathname.replace(\"/\", \"\");\r\n if (orgCode && orgCode.length > 0) {\r\n this.organisationService\r\n .getOrganisationByOrgCode(location.pathname.replace(\"/\", \"\"))\r\n .then((org) => {\r\n this.hasBridging = org?.HasBridging;\r\n this.hasCommercial = org?.HasCommercialMortgage;\r\n this.checkProductSelected();\r\n });\r\n } else {\r\n //This is for borrower belong to BF org\r\n this.hasBridging = true;\r\n this.hasCommercial = true;\r\n }\r\n }\r\n }\r\n })\r\n .catch((error) => {\r\n console.error(\"Failed to get initialize data: \", error);\r\n });\r\n }\r\n\r\n async getUser(): Promise {\r\n if (window.self == window.top) {\r\n this.userDetails = sessionStorage.getItem(\"userDetails\");\r\n } else {\r\n this.userDetails = await this.organisationService.getData(\"userDetails\");\r\n }\r\n }\r\n\r\n goToNewDevFinanceSearch(productSelected: boolean = false) {\r\n if (productSelected || this.userDetails) {\r\n if (this.hasBridging) {\r\n //localStorage.removeItem('selectedProduct');\r\n this.$location.path(\"/criteria\");\r\n }\r\n } else {\r\n this.selectedProduct = \"devFinance\";\r\n this.$location.path(\"/borrowerinitialregistration\");\r\n }\r\n }\r\n\r\n goToNewBridgingSearch(productSelected: boolean = false) {\r\n if (productSelected || this.userDetails) {\r\n if (this.hasBridging) {\r\n //localStorage.removeItem('selectedProduct');\r\n this.$location.path(\"/bridgingcriteria\");\r\n }\r\n } else {\r\n sessionStorage.setItem(\"selectedProduct\", \"bridging\");\r\n this.$location.path(\"/bridgingcriteria\");\r\n }\r\n }\r\n\r\n goToNewCommercialSearch() {\r\n if (this.userDetails) {\r\n if (this.hasCommercial) {\r\n this.$location.path(\"/commercialcriteria\");\r\n }\r\n }\r\n }\r\n\r\n goToNewPurchaseOrRefinanceSearch(productSelected: boolean = false) {\r\n if (productSelected || sessionStorage.getItem(\"userDetails\")) {\r\n if (this.hasBridging) {\r\n sessionStorage.removeItem(\"selectedProduct\");\r\n this.$location.path(\"/purchaserefinancecriteria\");\r\n }\r\n } else {\r\n this.selectedProduct = \"purchaseOrRefinance\";\r\n this.$location.path(\"/bridgingcriteria\");\r\n }\r\n }\r\n\r\n checkProductSelected() {\r\n switch (this.selectedProduct) {\r\n case null:\r\n break;\r\n case \"devFinance\":\r\n this.goToNewDevFinanceSearch(true);\r\n break;\r\n case \"bridging\":\r\n this.goToNewBridgingSearch(true);\r\n break;\r\n case \"purchaseOrRefinance\":\r\n this.goToNewPurchaseOrRefinanceSearch(true);\r\n break;\r\n default:\r\n return;\r\n }\r\n }\r\n}\r\n","export const enum OrganisationTypeEnum {\r\n General = 0,\r\n Broker = 1,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AppPackagePricingDTO } from \"@js/DTO/AppPackagePricingDTO.cs.d\";\r\nimport { InvitedBrokerDTO } from \"@js/DTO/InvitedBrokerDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { OrganisationLinkDTO } from \"@js/DTO/OrgnisationLinkDTO.cs.d\";\r\nimport { PageWithTotalCountDTO } from \"@js/DTO/PageWithTotalCountDTO.cs.d\";\r\nimport { BrokerNetworkEnum } from \"@js/models/enum/BrokerNetworkEnum.cs\";\r\nimport { CRMEnum } from \"@js/models/enum/CRMEnum.cs\";\r\nimport { LinkTypeEnum } from \"@js/models/enum/LinkTypeEnum.cs.d\";\r\nimport { OrganisationTypeEnum } from \"@js/models/enum/OrganisationTypeEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { ListItem, SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport angular from \"angular\";\r\nimport { OrganisationLinkService } from \"@js/services/OrganisationLinkService\"\r\n\r\nexport class OrganisationsController {\r\n organisations: PageWithTotalCountDTO;\r\n selectedOrganisation: OrganisationDTO;\r\n originalOrganisation: OrganisationDTO;\r\n currentUser: ApplicationUserDTO;\r\n\r\n //invite users\r\n newUser: InvitedBrokerDTO;\r\n users: InvitedBrokerDTO[] = [];\r\n showModal: boolean = false;\r\n\r\n //rename Email\r\n renamingItem: InvitedBrokerDTO;\r\n newName: InvitedBrokerDTO = {\r\n Email: null,\r\n FirstName: null,\r\n };\r\n tempdata: InvitedBrokerDTO;\r\n //Brokers\r\n organisationAdminId: string;\r\n organisationAdmin: ApplicationUserDTO;\r\n organisationUsers: ApplicationUserDTO[];\r\n organisationUsersExceptAdmin: ApplicationUserDTO[];\r\n licensedOrganisationUsers: ApplicationUserDTO[];\r\n // temp storing user while deleteing\r\n confirmDeleteUser: ApplicationUserDTO;\r\n\r\n uniqueLinks: OrganisationLinkDTO[];\r\n selectedUniqueLink: OrganisationLinkDTO;\r\n\r\n page: number = 1;\r\n rolepageid: any;\r\n userFilter: string = \"\";\r\n countperpage: number = 10;\r\n\r\n loadingRoles: boolean;\r\n error: boolean;\r\n isInvalidForm: boolean;\r\n\r\n logoURL: string;\r\n\r\n deleteMessage: string;\r\n\r\n deleteConfirmMessage: string;\r\n\r\n registrationForm: ng.IFormController;\r\n\r\n addEmail: ng.IFormController;\r\n\r\n deleteConfirmation: boolean;\r\n messageDeleteModal: boolean;\r\n goToUserDashboard: boolean;\r\n brokerUserDelete: boolean = false;\r\n\r\n //toggle to control the Broker user section\r\n showBrokerUsers: boolean = false;\r\n\r\n profileEdit: ApplicationUserDTO;\r\n showEdit: boolean = false;\r\n isAdmin: boolean;\r\n newname: string;\r\n // Show and hide a input field to add users.\r\n hideInput: boolean = false;\r\n showErrorMsg: boolean = false;\r\n errorMsg: string;\r\n imageErrorMsg: string;\r\n\r\n // Indicates when org is saving\r\n isProcessingOrgSave: boolean = false;\r\n\r\n // Indicates when invites are being sent\r\n isProcessingInvites: boolean = false;\r\n\r\n // Indicates when saving a broker profile\r\n isProcessingProfileSave: boolean = false;\r\n\r\n orgFilter: string = \"\";\r\n\r\n allActiveAppPackagePrices: AppPackagePricingDTO[];\r\n selectedProductList: AppPackagePricingDTO[] = [];\r\n licenseEndDate: Date;\r\n quantity = 1;\r\n\r\n ShowIsBrickflow: boolean = true;\r\n buttonColor: string = \"#304b9a\";\r\n message: string;\r\n messageTitle: string;\r\n widgetModal: boolean = false;\r\n showLeadGenLicenseActive: boolean = false;\r\n leadGeneratorName: string;\r\n\r\n teamSizeOptions = [];\r\n linkTypeOptions = [];\r\n\r\n isAddonSelected: boolean = false;\r\n licenseStatusText: string;\r\n whiteLabelledUrl: string = \"\";\r\n\r\n showTestEmailModal: boolean = false;\r\n showTestEmailSentConfirmation: boolean = false;\r\n testEmails: string;\r\n testEmailBody: string = \"This is a test email.\";\r\n testEmailSubject: string = \"Test email\";\r\n isValidOrgCode: boolean = true;\r\n validateCodeClicked: boolean = false;\r\n fetchingUniqueLinks: boolean = false;\r\n displayMessage: string = \"\";\r\n deleteUniqueLinkClicked: boolean = false;\r\n confirmUniqueLinkDeletion: boolean = false;\r\n isEditUniqueLink: boolean = false;\r\n showEditUniqueLinkModal: boolean = false;\r\n editLogo: boolean = false;\r\n isSavingUniqueLink: boolean = false;\r\n ulsavemessage: string = \"\";\r\n\r\n organisation: OrganisationDTO;\r\n orgCode: string = \"\";\r\n orgLogo: string = \"\";\r\n\r\n //Preview a registration page\r\n previewContent: boolean = true;\r\n showPreview: boolean = false;\r\n\r\n hubspotMessage: string;\r\n isHubspotValid: boolean = false;\r\n missingProperties: string[];\r\n\r\n locationOptions = [];\r\n organisationThemeColour: string;\r\n\r\n // Dropdown to select widget/ enterprise\r\n showDevFinanaceLinkOptions: boolean = false;\r\n showAllLoansLinkOptions: boolean = false;\r\n showBridgingLinkOptions: boolean = false;\r\n showCommercialLinkOptions: boolean = false;\r\n\r\n showLinkOptions: boolean[];\r\n\r\n connectNetworkOrgId: number;\r\n crms = this.selectListService.GetCRMs();\r\n brokerNetworks = this.selectListService.GetBrokerNetworks();\r\n selectedCRMs: ListItem[];\r\n selectedBrokerNetworks: ListItem[];\r\n showMarkAsConnectConfirmationModal: boolean = false;\r\n isMarkAsConnectConfirmed: boolean = false;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n \"OrganisationService\",\r\n \"FileAttachmentService\",\r\n \"PaymentService\",\r\n \"UserService\",\r\n \"$window\",\r\n \"AuthService\",\r\n \"SelectListService\",\r\n \"OrganisationLinkService\"\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private $auth: AuthService,\r\n private $role: RoleService,\r\n private $organisationService: OrganisationService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private $paymentService: PaymentService,\r\n private userService: UserService,\r\n private $window: ng.IWindowService,\r\n private authService: AuthService,\r\n private selectListService: SelectListService,\r\n private organisationLinkService: OrganisationLinkService\r\n ) {\r\n this.loadingRoles = true;\r\n this.deleteConfirmation = false;\r\n this.messageDeleteModal = false;\r\n this.isInvalidForm = true;\r\n\r\n if (sessionStorage.getItem(\"filterText\")) {\r\n this.orgFilter = sessionStorage.getItem(\"filterText\");\r\n sessionStorage.removeItem(\"filterText\");\r\n }\r\n\r\n if (sessionStorage.getItem(\"pageNo\")) {\r\n this.setPage(Number(sessionStorage.getItem(\"pageNo\")));\r\n sessionStorage.removeItem(\"pageNo\");\r\n } else {\r\n this.setPage(1);\r\n }\r\n this.checkForAdmin();\r\n this.authService.getUpdatedProfile().then((prof) => {\r\n this.currentUser = prof;\r\n });\r\n\r\n this.leadGeneratorName = this.$cookies.get(\"leadgeneratorname\");\r\n this.teamSizeOptions = this.selectListService.GetTeamSizeOptions();\r\n this.getWhiteLabelledUrl();\r\n this.getConnectNetworkOrgId();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n }\r\n\r\n onSelectingOrganisation(selectedOrganisation) {\r\n this.selectedOrganisation = selectedOrganisation;\r\n this.originalOrganisation = { ...this.selectedOrganisation };\r\n this.getOrganisationDetail();\r\n this.fetchUniqueLinks();\r\n this.initializeSelectedNetworks();\r\n this.initializeCRMs();\r\n this.ShowIsBrickflow =\r\n selectedOrganisation.IsBrickflow ||\r\n this.organisations.List.every((org) => !org.IsBrickflow);\r\n }\r\n\r\n getLogoURL(url: string) {\r\n if (url) {\r\n this.fileAttachmentService.getFileUri(url).then((result) => {\r\n this.selectedOrganisation.LogoURL = result;\r\n });\r\n }\r\n }\r\n\r\n changeCompanyLogo(files, logoUrl: number) {\r\n this.imageErrorMsg = null;\r\n const allowedExtensions = [\r\n \"jpg\",\r\n \"jpeg\",\r\n \"png\",\r\n \"gif\",\r\n \"bmp\",\r\n \"tif\",\r\n \"tiff\",\r\n \"ico\",\r\n \"jfif\",\r\n \"pjpeg\",\r\n \"pjp\",\r\n \"apng\",\r\n ];\r\n const filteredFiles = files.filter((file) => {\r\n const fileExtension = file.name.split(\".\").pop()?.toLowerCase();\r\n return fileExtension && allowedExtensions.indexOf(fileExtension) !== -1;\r\n });\r\n\r\n if (filteredFiles.length === 0 && files.length > 0) {\r\n this.imageErrorMsg =\r\n \"Invalid file type: SVG and webp formats are not supported\";\r\n return;\r\n }\r\n this.fileAttachmentService\r\n .uploadPublicImage(files, this.selectedOrganisation.OrganisationCode)\r\n .then((imageUrl) => {\r\n if (logoUrl == 1) {\r\n this.selectedOrganisation.LogoURL = imageUrl;\r\n this.orgLogo = imageUrl;\r\n } else {\r\n this.selectedOrganisation.FaviconURL = imageUrl;\r\n }\r\n\r\n this.registrationForm.$setDirty();\r\n });\r\n }\r\n\r\n removeCompanyLogo(removeLogoUrl) {\r\n if (removeLogoUrl) {\r\n this.selectedOrganisation.LogoURL = null;\r\n this.orgLogo = null;\r\n } else {\r\n this.selectedOrganisation.FaviconURL = null;\r\n }\r\n this.registrationForm.$setDirty();\r\n }\r\n\r\n setPage(newPage: number): void {\r\n this.loadingRoles = true;\r\n this.page = newPage;\r\n this.$organisationService\r\n .fetchpage(this.orgFilter, this.page, this.countperpage)\r\n .then((response) => {\r\n this.organisations = response;\r\n\r\n if (sessionStorage.getItem(\"selectedOrganisation\")) {\r\n this.selectedOrganisation = this.organisations.List.find(\r\n (organisation) =>\r\n organisation.UniqueRef ===\r\n sessionStorage.getItem(\"selectedOrganisation\"),\r\n );\r\n this.originalOrganisation = { ...this.selectedOrganisation };\r\n this.getOrganisationDetail();\r\n this.fetchUniqueLinks();\r\n sessionStorage.removeItem(\"selectedOrganisation\");\r\n } else if (this.organisations.List.length == 1) {\r\n this.selectedOrganisation = this.organisations.List[0];\r\n this.originalOrganisation = { ...this.selectedOrganisation };\r\n this.getOrganisationDetail();\r\n this.fetchUniqueLinks();\r\n }\r\n this.loadingRoles = false;\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n this.loadingRoles = false;\r\n });\r\n }\r\n\r\n displayItem(item) {\r\n this.selectedOrganisation = item;\r\n }\r\n\r\n addUser() {\r\n var temp = { ...this.newUser };\r\n this.users.push(temp);\r\n this.newUser.Email = null;\r\n this.newUser.FirstName = null;\r\n this.addEmail.$setPristine();\r\n }\r\n\r\n invite() {\r\n this.isProcessingInvites = true;\r\n\r\n this.$organisationService\r\n .inviteBrokers(this.users, this.selectedOrganisation.UniqueRef)\r\n .finally(() => {\r\n delete this.newUser;\r\n this.users = [];\r\n this.hideInput = false;\r\n this.deleteMessage = \"Invitations have been sent.\";\r\n this.messageDeleteModal = true;\r\n })\r\n .finally(() => {\r\n this.isProcessingInvites = false;\r\n });\r\n }\r\n\r\n removeEmail(item: InvitedBrokerDTO) {\r\n this.users = this.users.filter((x) => x != item);\r\n }\r\n\r\n renameItem(item: InvitedBrokerDTO) {\r\n if (this.renamingItem === undefined) {\r\n this.newName = item;\r\n this.renamingItem = item;\r\n this.tempdata = { ...this.renamingItem };\r\n } else {\r\n delete this.renamingItem;\r\n }\r\n }\r\n\r\n cancelRenaming(item: InvitedBrokerDTO) {\r\n this.users = this.users.filter((x) => x != item);\r\n this.users.push(this.tempdata);\r\n delete this.renamingItem;\r\n this.addEmail.editUserFirstName.$setUntouched();\r\n this.addEmail.editUserEmail.$setUntouched();\r\n }\r\n\r\n renamingItemComplete(item: InvitedBrokerDTO) {\r\n this.users = this.users.filter((x) => x != item);\r\n this.users.push(this.newName);\r\n this.renamingItem = null;\r\n }\r\n\r\n addNewUser() {\r\n if (this.newUser.Email != null && this.newUser.FirstName != null) {\r\n this.addUser();\r\n this.addEmail.newUserFirstName.$setUntouched();\r\n this.addEmail.newUserEmail.$setUntouched();\r\n }\r\n }\r\n\r\n cancelAddingNewUser() {\r\n this.newUser.Email = null;\r\n this.newUser.FirstName = null;\r\n this.addEmail.newUserFirstName.$setUntouched();\r\n this.addEmail.newUserEmail.$setUntouched();\r\n }\r\n\r\n getFocusToInput() {\r\n var getelement = this.$window.document.getElementById(\"newuser\");\r\n getelement.focus();\r\n }\r\n\r\n removeErrors() {\r\n delete this.error;\r\n this.orgCode = this.selectedOrganisation.OrganisationCode;\r\n }\r\n\r\n saveOrganisation(): void {\r\n delete this.error;\r\n this.isProcessingOrgSave = true;\r\n\r\n if (this.selectedOrganisation.IsConnectMember && this.originalOrganisation && !this.originalOrganisation.IsConnectMember && !this.isMarkAsConnectConfirmed) {\r\n this.showMarkAsConnectConfirmationModal = true;\r\n return;\r\n }\r\n\r\n if (this.selectedOrganisation.OrganisationThemeColour && (this.selectedOrganisation.OrganisationThemeColour == \"#304B9A\" || this.selectedOrganisation.OrganisationThemeColour == \"#304b9a\")) {\r\n this.selectedOrganisation.OrganisationThemeColour = \"\";\r\n }\r\n\r\n if (\r\n this.selectedOrganisation.CompanyURL != null &&\r\n this.selectedOrganisation.CompanyURL.replace(/^https?\\:\\/\\//g, \"\")\r\n .length > 0\r\n ) {\r\n if (!/^https?:\\/\\//i.test(this.selectedOrganisation.CompanyURL)) {\r\n this.selectedOrganisation.CompanyURL = `https://${this.selectedOrganisation.CompanyURL}`;\r\n }\r\n }\r\n\r\n if (\r\n this.selectedOrganisation.HasWhiteLabelAddOnPaid &&\r\n this.selectedOrganisation.IsWhiteLabelled\r\n ) {\r\n if (\r\n this.selectedOrganisation.TwitterUrl &&\r\n this.selectedOrganisation.TwitterUrl.length > 0\r\n ) {\r\n if (!/^https?:\\/\\//i.test(this.selectedOrganisation.TwitterUrl)) {\r\n this.selectedOrganisation.TwitterUrl = `https://${this.selectedOrganisation.TwitterUrl}`;\r\n }\r\n }\r\n if (\r\n this.selectedOrganisation.FacebookUrl &&\r\n this.selectedOrganisation.FacebookUrl.length > 0\r\n ) {\r\n if (!/^https?:\\/\\//i.test(this.selectedOrganisation.FacebookUrl)) {\r\n this.selectedOrganisation.FacebookUrl = `https://${this.selectedOrganisation.FacebookUrl}`;\r\n }\r\n }\r\n if (\r\n this.selectedOrganisation.YouTubeUrl &&\r\n this.selectedOrganisation.YouTubeUrl.length > 0\r\n ) {\r\n if (!/^https?:\\/\\//i.test(this.selectedOrganisation.YouTubeUrl)) {\r\n this.selectedOrganisation.YouTubeUrl = `https://${this.selectedOrganisation.YouTubeUrl}`;\r\n }\r\n }\r\n if (\r\n this.selectedOrganisation.LinkedInUrl &&\r\n this.selectedOrganisation.LinkedInUrl.length > 0\r\n ) {\r\n if (!/^https?:\\/\\//i.test(this.selectedOrganisation.LinkedInUrl)) {\r\n this.selectedOrganisation.LinkedInUrl = `https://${this.selectedOrganisation.LinkedInUrl}`;\r\n }\r\n }\r\n }\r\n /* }*/\r\n\r\n this.saveSelectedCRMs();\r\n this.saveSelectedNetworks();\r\n\r\n var isOrgConvertedToConnectMember = this.selectedOrganisation.IsConnectMember && this.originalOrganisation && !this.originalOrganisation.IsConnectMember;\r\n\r\n this.$organisationService\r\n .saveOrganisation(this.selectedOrganisation, isOrgConvertedToConnectMember)\r\n .then((response) => {\r\n if (\r\n this.organisationAdminId &&\r\n this.organisationAdmin.Id != this.organisationAdminId\r\n ) {\r\n this.userService.setBrokerOrgAdmin(\r\n this.selectedOrganisation.Id,\r\n this.organisationAdminId,\r\n );\r\n }\r\n\r\n (this.$rootScope as any).formSaved = true;\r\n let index = this.organisations.List.indexOf(this.selectedOrganisation);\r\n this.organisations.List.splice(index, 1);\r\n this.organisations.List.push(this.selectedOrganisation);\r\n delete this.selectedOrganisation;\r\n if (this.organisations.List.length == 1) {\r\n this.selectedOrganisation = this.organisations.List[0];\r\n }\r\n\r\n this.registrationForm.$setPristine();\r\n this.deleteMessage = \"Your changes have been saved.\";\r\n this.messageDeleteModal = true;\r\n this.goToUserDashboard = true; // When the User closes the pop-up box, they will be redirected to the User Dashboard\r\n })\r\n .catch((response) => {\r\n this.error = response.data;\r\n })\r\n .finally(() => {\r\n this.isProcessingOrgSave = false;\r\n });\r\n }\r\n\r\n validateForm() {\r\n if (this.registrationForm.$invalid) {\r\n let invalidName;\r\n angular.forEach(this.registrationForm.$error, function (field) {\r\n angular.forEach(field, function (errorfield) {\r\n errorfield.$setTouched();\r\n invalidName = errorfield.$name;\r\n });\r\n });\r\n let element = this.$window.document.getElementsByName(\r\n invalidName,\r\n )[0] as unknown as HTMLElement;\r\n element?.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n deleteOrganisation() {\r\n this.deleteConfirmation = true;\r\n this.deleteConfirmMessage =\r\n \"Are you sure you want to delete the company\" +\r\n this.selectedOrganisation.Name +\r\n \"?\";\r\n }\r\n\r\n confirmDelete(item: OrganisationDTO) {\r\n delete this.selectedOrganisation;\r\n this.deleteConfirmation = false;\r\n this.$organisationService\r\n .deleteOrganisation(item.Id)\r\n .then((response) => {\r\n this.deleteMessage =\r\n \"The company \" + item.Name + \" has been successfully deleted.\";\r\n this.messageDeleteModal = true;\r\n this.organisations.List = this.organisations.List.filter(\r\n (organisation) => organisation != item,\r\n );\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n this.deleteMessage =\r\n \"Sorry! We had an error deleting the company \" +\r\n item.Name +\r\n \". Please, try again later.\";\r\n this.messageDeleteModal = true;\r\n });\r\n }\r\n\r\n cancelDelete() {\r\n this.deleteConfirmation = false;\r\n }\r\n\r\n closeMessageSuccesfullyDeleted() {\r\n if (this.goToUserDashboard && this.isAdmin) {\r\n this.$location.path(\"/userdashboard\"); // redirects User to User Dashboard\r\n this.goToUserDashboard = false;\r\n }\r\n this.messageDeleteModal = false;\r\n }\r\n\r\n addNewOrganisation() {\r\n this.selectedOrganisation = {\r\n Name: \"\",\r\n OrganisationType: OrganisationTypeEnum.Broker,\r\n HasCommercialMortgage: true,\r\n HasBridging: true,\r\n IsDeleted: false,\r\n } as OrganisationDTO;\r\n this.ShowIsBrickflow = this.organisations.List.every(\r\n (org) => !org.IsBrickflow,\r\n );\r\n this.organisationAdminId = \"\";\r\n this.licensedOrganisationUsers = [];\r\n }\r\n\r\n formValidation(name: string, type: number) {\r\n if (!name || !type) {\r\n this.isInvalidForm = true;\r\n }\r\n\r\n this.isInvalidForm = false;\r\n }\r\n\r\n registerDisabled() {\r\n if (\r\n this.selectedOrganisation &&\r\n this.errorMsg == null &&\r\n !this.isProcessingOrgSave\r\n ) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n }\r\n\r\n getOrganisationDetail(): void {\r\n this.userService\r\n .getAllOrganisationMembers(this.selectedOrganisation.Id)\r\n .then((orgBrokers: ApplicationUserDTO[]) => {\r\n this.organisationUsers = orgBrokers;\r\n this.organisationAdmin = orgBrokers.find((x) => x.IsOrganisationAdmin);\r\n\r\n this.licensedOrganisationUsers = this.organisationUsers.filter(\r\n (x) => x.SubscriptionStatus > 0 || x.IsOrganisationAdmin,\r\n );\r\n\r\n if (this.organisationAdmin) {\r\n this.organisationAdminId = this.organisationAdmin.Id;\r\n this.organisationUsersExceptAdmin = this.organisationUsers.filter(\r\n (x) => x.Id != this.organisationAdminId,\r\n );\r\n\r\n this.getActivePackagePricingsForTrialLicense();\r\n this.isLeadGenLicenseActive();\r\n }\r\n })\r\n .then(() => {\r\n if (this.organisations.List.length > 1) this.getLicenseStatusText();\r\n });\r\n\r\n this.linkTypeOptions = this.selectListService.GetLinkTypeOptions(\r\n this.selectedOrganisation.HasBridging,\r\n this.selectedOrganisation.HasCommercialMortgage,\r\n );\r\n }\r\n\r\n isLeadGenLicenseActive(): void {\r\n this.$organisationService\r\n .isLeadGenLicenseActive(this.selectedOrganisation.Id)\r\n .then((response) => {\r\n this.showLeadGenLicenseActive = response;\r\n });\r\n }\r\n\r\n deleteBrokerUser(user: ApplicationUserDTO) {\r\n this.deleteConfirmation = true;\r\n this.brokerUserDelete = true;\r\n this.deleteConfirmMessage =\r\n \"Are you sure you want to delete the Broker User\" +\r\n user.FirstName +\r\n \" \" +\r\n user.LastName +\r\n \"?\";\r\n this.confirmDeleteUser = { ...user };\r\n }\r\n\r\n confirmBrokerDelete(item: ApplicationUserDTO) {\r\n this.deleteConfirmation = false;\r\n this.userService\r\n .markasdeleted(item.UserName)\r\n .then((response) => {\r\n this.deleteMessage =\r\n \"Your Broker\" +\r\n item.FirstName +\r\n item.LastName +\r\n \" was successfully deleted!\";\r\n this.messageDeleteModal = true;\r\n this.organisationUsersExceptAdmin =\r\n this.organisationUsersExceptAdmin.filter((user) => user != item);\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n this.deleteMessage =\r\n \"Sorry! We had an error deleting the broker user \" +\r\n item.FirstName +\r\n \" \" +\r\n item.LastName +\r\n \". Please, try again later.\";\r\n this.messageDeleteModal = true;\r\n });\r\n }\r\n\r\n cancelBrokerDelete() {\r\n this.deleteConfirmation = false;\r\n this.brokerUserDelete = false;\r\n }\r\n\r\n updateBrokerUser(user: ApplicationUserDTO): void {\r\n this.profileEdit = user;\r\n this.showEdit = true;\r\n }\r\n\r\n /** Save the user changes */\r\n saveProfile() {\r\n this.isProcessingProfileSave = true;\r\n this.showEdit = false;\r\n this.userService\r\n .addUpdate(this.profileEdit)\r\n .then((userResponse) => {\r\n this.deleteMessage =\r\n this.profileEdit.FirstName +\r\n \" \" +\r\n this.profileEdit.LastName +\r\n \"'s details have been saved\";\r\n this.messageDeleteModal = true;\r\n })\r\n .finally(() => {\r\n this.isProcessingProfileSave = false;\r\n });\r\n }\r\n\r\n closeEditModal() {\r\n this.showEdit = false;\r\n this.profileEdit = null;\r\n }\r\n\r\n checkForAdmin(): void {\r\n this.$role.isAdminUser().then((response) => {\r\n this.isAdmin = response;\r\n });\r\n }\r\n\r\n isHtml(input) {\r\n let isHtml;\r\n this.errorMsg = null;\r\n isHtml = /<[a-z]+\\d?(\\s+[\\w-]+=(\"[^\"]*\"|'[^']*'))*\\s*\\/?>|?\\w+;/i.test(\r\n input,\r\n );\r\n if (isHtml) {\r\n this.errorMsg = \"Please remove any special characters from footer text.\";\r\n }\r\n }\r\n\r\n removeNewUserEmail() {\r\n this.newUser.Email = \"\";\r\n }\r\n\r\n go(path: string) {\r\n this.$location.path(path);\r\n }\r\n\r\n goToSettingPage() {\r\n sessionStorage.setItem(\r\n \"selectedOrganisation\",\r\n this.selectedOrganisation.UniqueRef,\r\n );\r\n if (this.orgFilter.length > 0)\r\n sessionStorage.setItem(\"filterText\", this.orgFilter);\r\n if (this.page > 1) sessionStorage.setItem(\"pageNo\", this.page.toString());\r\n this.go(`/settings/${this.organisationAdmin.Id}`);\r\n }\r\n\r\n getActivePackagePricingsForTrialLicense() {\r\n this.allActiveAppPackagePrices = [];\r\n this.$paymentService\r\n .getActivePackagePricingsForTrialLicense(this.organisationAdmin.UserName)\r\n .then((response) => {\r\n this.allActiveAppPackagePrices = response;\r\n });\r\n }\r\n\r\n onChangingPackage(selectedPackage) {\r\n if (\r\n this.selectedProductList != null &&\r\n this.selectedProductList.length > 0\r\n ) {\r\n var found = this.selectedProductList.find(function (product) {\r\n return product.Id == selectedPackage.Id;\r\n });\r\n\r\n if (found) {\r\n this.selectedProductList = this.selectedProductList.filter(\r\n function (e) {\r\n return e.Id != selectedPackage.Id;\r\n },\r\n );\r\n } else {\r\n this.selectedProductList.push(selectedPackage);\r\n }\r\n } else {\r\n this.selectedProductList.push(selectedPackage);\r\n }\r\n }\r\n\r\n assignLicenseToOrganisation() {\r\n this.$organisationService\r\n .assignTrialLicenseToOrg(\r\n this.selectedProductList,\r\n this.licenseEndDate,\r\n this.organisationAdmin.Id,\r\n this.quantity,\r\n true,\r\n this.isAddonSelected,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n this.deleteMessage = `Trial license has been assigned to ${this.organisationAdmin.FullName}`;\r\n this.messageDeleteModal = true;\r\n this.allActiveAppPackagePrices = [];\r\n this.selectedOrganisation.HasWhiteLabelAddOnPaid =\r\n this.isAddonSelected;\r\n } else {\r\n this.deleteMessage = `Problem while assigning trial license, please try after some time.`;\r\n this.messageDeleteModal = true;\r\n }\r\n });\r\n }\r\n\r\n generateButtonCode() {\r\n if (this.selectedOrganisation.OrganisationCode) {\r\n //var style = `background-color:${this.buttonColor};border-radius: 4px; padding: 0.5rem 1rem;cursor: pointer;outline: none;line-height: 1.3rem;`\r\n //this.message = ``;\r\n this.message = `${this.whiteLabelledUrl}${this.selectedOrganisation.OrganisationCode}#!/e/devfinancecriteria`;\r\n this.messageTitle =\r\n \"Please copy the below URL to include in your website.\";\r\n this.widgetModal = true;\r\n } else if (this.selectedOrganisation.IsBrickflow) {\r\n this.message = `${this.whiteLabelledUrl}#!/e/devfinancecriteria`;\r\n this.messageTitle =\r\n \"Please copy the below URL to include in your website.\";\r\n this.widgetModal = true;\r\n } else {\r\n this.deleteMessage =\r\n \"To access your \" +\r\n this.leadGeneratorName +\r\n \" URL please ensure you have an active White Label add-on and you have completed the URL Company Code in your company settings (under White Label)\";\r\n this.messageDeleteModal = true;\r\n }\r\n }\r\n\r\n generateAllLoansUrl(id: number = null): string {\r\n var url = \"\";\r\n\r\n if (this.selectedOrganisation.OrganisationCode) {\r\n url = `${this.whiteLabelledUrl}${this.selectedOrganisation.OrganisationCode}#!/allloans`;\r\n } else if (this.selectedOrganisation.IsBrickflow) {\r\n url = `${this.whiteLabelledUrl}#!/allloans`;\r\n }\r\n\r\n if (id != null) {\r\n url += `/${id}`;\r\n }\r\n\r\n return url;\r\n }\r\n\r\n generateBridgingCriteriaURL(): string {\r\n if (this.selectedOrganisation.OrganisationCode) {\r\n return `${this.whiteLabelledUrl}${this.selectedOrganisation.OrganisationCode}#!/e/bridgingcriteria`;\r\n } else if (this.selectedOrganisation.IsBrickflow) {\r\n return `${this.whiteLabelledUrl}#!/e/bridgingcriteria`;\r\n }\r\n }\r\n\r\n generateCommercialCriteriaURL(): string {\r\n if (this.selectedOrganisation.OrganisationCode) {\r\n return `${this.whiteLabelledUrl}${this.selectedOrganisation.OrganisationCode}#!/e/commercialcriteria`;\r\n } else if (this.selectedOrganisation.IsBrickflow) {\r\n return `${this.whiteLabelledUrl}#!/e/commercialcriteria`;\r\n }\r\n }\r\n\r\n generateDevFinanceCriteriaURL(): string {\r\n if (this.selectedOrganisation.OrganisationCode) {\r\n return `${this.whiteLabelledUrl}${this.selectedOrganisation.OrganisationCode}#!/e/devfinancecriteria`;\r\n } else if (this.selectedOrganisation.IsBrickflow) {\r\n return `${this.whiteLabelledUrl}#!/e/devfinancecriteria`;\r\n }\r\n }\r\n\r\n generateCriteriaUrl(linkType: LinkTypeEnum, id: number = null): string {\r\n var url = \"\";\r\n\r\n if (linkType == LinkTypeEnum.Bridging) {\r\n url = this.generateBridgingCriteriaURL();\r\n } else if (linkType == LinkTypeEnum.Commercial) {\r\n url = this.generateCommercialCriteriaURL();\r\n } else if (linkType == LinkTypeEnum.Development) {\r\n url = this.generateDevFinanceCriteriaURL();\r\n }\r\n\r\n if (id != null) {\r\n url += \"/0/\" + id;\r\n }\r\n\r\n return url;\r\n }\r\n\r\n generateUniqueLinkCode(linkType: LinkTypeEnum, id: number = null, isWidgetLink: boolean = false) {\r\n if (\r\n (linkType == LinkTypeEnum.Bridging ||\r\n linkType == LinkTypeEnum.Commercial ||\r\n linkType == LinkTypeEnum.Development) && !isWidgetLink\r\n ) {\r\n this.message = this.generateCriteriaUrl(linkType, id);\r\n } else {\r\n this.message = this.generateAllLoansUrl(id);\r\n\r\n if (isWidgetLink) {\r\n this.message += id != null ? \"/widget\" : \"/0/widget\";\r\n\r\n if (linkType == LinkTypeEnum.Bridging ||\r\n linkType == LinkTypeEnum.Commercial ||\r\n linkType == LinkTypeEnum.Development) {\r\n this.message += `/${linkType}`\r\n }\r\n }\r\n }\r\n\r\n if (!isWidgetLink && (this.selectedOrganisation.OrganisationCode || this.selectedOrganisation.IsBrickflow)) {\r\n this.messageTitle =\r\n \"Please copy the below URL to include in your website.\";\r\n this.widgetModal = true;\r\n } else if (isWidgetLink) {\r\n this.messageTitle =\r\n \"Please copy the below widget URL.\";\r\n this.widgetModal = true;\r\n } else {\r\n if (isWidgetLink) {\r\n this.deleteMessage =\r\n \"To access URL please ensure company has an active White Label add-on and completed the URL Company Code in company settings (under White Label).\";\r\n } else {\r\n this.deleteMessage =\r\n \"To access your \" +\r\n this.leadGeneratorName +\r\n \" URL please ensure you have an active White Label add-on and you have completed the URL Company Code in your company settings (under White Label)\";\r\n\r\n }\r\n this.messageDeleteModal = true;\r\n }\r\n }\r\n\r\n generateWidgetURL() {\r\n navigator.clipboard.writeText(\r\n `${location.origin}/${this.selectedOrganisation.OrganisationCode}#/initialregister`,\r\n );\r\n this.message = \"Widget url has been copied to the clipboard\";\r\n this.widgetModal = true;\r\n }\r\n\r\n closeWidgetModal() {\r\n this.widgetModal = false;\r\n this.message = null;\r\n this.messageTitle = null;\r\n }\r\n\r\n copyButtonCodeToClipBoard() {\r\n navigator.clipboard.writeText(this.message);\r\n this.messageTitle = null;\r\n this.message = \"Code has been copied to the clipboard\";\r\n }\r\n\r\n bookCall() {\r\n window.open(\r\n \"https://brickflow.com/brokers/brickflow-enterprise/book-a-demo\",\r\n );\r\n }\r\n\r\n getLicenseStatusText() {\r\n this.allActiveAppPackagePrices = [];\r\n this.userService\r\n .getLicenseStatusText(this.organisationAdmin.UserName)\r\n .then((response) => {\r\n this.licenseStatusText = response;\r\n });\r\n }\r\n\r\n getWhiteLabelledUrl() {\r\n this.authService.getWhiteLabelledUrl().then((response) => {\r\n this.whiteLabelledUrl = response;\r\n });\r\n }\r\n\r\n getConnectNetworkOrgId() {\r\n this.authService.getConnectNetworkOrgId().then((response) => {\r\n this.connectNetworkOrgId = Number(response);\r\n });\r\n }\r\n\r\n\r\n sendTestEmail(): void {\r\n this.$organisationService\r\n .sendTestEmail(\r\n this.testEmails,\r\n this.testEmailSubject,\r\n this.testEmailBody,\r\n this.selectedOrganisation.Id,\r\n )\r\n .then((response: boolean) => {\r\n if (response) {\r\n this.showTestEmailModal = false;\r\n this.showTestEmailSentConfirmation = true;\r\n } else {\r\n this.error = true;\r\n }\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n });\r\n }\r\n\r\n closeTestEmailConfirmation() {\r\n this.showTestEmailSentConfirmation = false;\r\n this.testEmails = null;\r\n }\r\n\r\n validateComanyCode() {\r\n this.validateCodeClicked = true;\r\n if (/^[A-Za-z0-9]*$/.test(this.selectedOrganisation.OrganisationCode)) {\r\n this.$organisationService\r\n .isOrganisationCodeValid(this.selectedOrganisation)\r\n .then((response: boolean) => {\r\n if (response) {\r\n this.isValidOrgCode = true;\r\n } else {\r\n this.isValidOrgCode = false;\r\n }\r\n });\r\n } else {\r\n this.isValidOrgCode = false;\r\n }\r\n }\r\n\r\n fetchUniqueLinks() {\r\n this.fetchingUniqueLinks = true;\r\n this.$organisationService\r\n .getUniqueLinks(this.selectedOrganisation.Id)\r\n .then((response) => {\r\n this.uniqueLinks = response;\r\n })\r\n .finally(() => {\r\n this.fetchingUniqueLinks = false;\r\n });\r\n }\r\n\r\n selectUniqueLink(uniqueLink?: OrganisationLinkDTO) {\r\n if (uniqueLink) {\r\n this.selectedUniqueLink = { ...uniqueLink };\r\n\r\n this.isEditUniqueLink = true;\r\n } else {\r\n this.selectedUniqueLink = {} as OrganisationLinkDTO;\r\n this.selectedUniqueLink.OrganisationId = this.selectedOrganisation.Id;\r\n this.isEditUniqueLink = false;\r\n }\r\n this.showEditUniqueLinkModal = true;\r\n }\r\n\r\n onClickOfDeleteUniqueLink(uniqueLink: OrganisationLinkDTO) {\r\n this.selectedUniqueLink = uniqueLink;\r\n if (this.isAdmin && !this.organisationAdmin) {\r\n this.displayMessage = `Please assign a new Org User before deleting ${this.selectedUniqueLink.LinkName}.`;\r\n } else {\r\n this.displayMessage = `Are you sure you wish to remove ${this.selectedUniqueLink.LinkName}?`;\r\n this.deleteUniqueLinkClicked = true;\r\n }\r\n this.confirmUniqueLinkDeletion = true;\r\n }\r\n\r\n getLinkType(linkTypeEnum: LinkTypeEnum) {\r\n if (linkTypeEnum == 1) return \"Development\";\r\n if (linkTypeEnum == 2) return \"Bridging\";\r\n if (linkTypeEnum == 3) return \"All Loans\";\r\n if (linkTypeEnum == 4) return \"Commercial\";\r\n }\r\n\r\n getLinkDescription(linkDescription) {\r\n return linkDescription === null ? \"\" : linkDescription;\r\n }\r\n\r\n removeUniqueLinkLogo() {\r\n this.selectedUniqueLink.LogoUrl = null;\r\n }\r\n\r\n onFileSelect(files) {\r\n if (files.length > 0) {\r\n this.imageErrorMsg = null;\r\n const allowedExtensions = [\r\n \"jpg\",\r\n \"jpeg\",\r\n \"png\",\r\n \"gif\",\r\n \"bmp\",\r\n \"tif\",\r\n \"tiff\",\r\n \"ico\",\r\n \"jfif\",\r\n \"pjpeg\",\r\n \"pjp\",\r\n \"apng\",\r\n ];\r\n const filteredFiles = files.filter((file) => {\r\n const fileExtension = file.name.split(\".\").pop()?.toLowerCase();\r\n return fileExtension && allowedExtensions.indexOf(fileExtension) !== -1;\r\n });\r\n\r\n if (filteredFiles.length === 0) {\r\n this.imageErrorMsg =\r\n \"Invalid file type: SVG and webp formats are not supported\";\r\n return;\r\n }\r\n\r\n this.fileAttachmentService\r\n .uploadPublicImage(files, this.selectedOrganisation.OrganisationCode)\r\n .then((imageUrl) => {\r\n this.selectedUniqueLink.LogoUrl = imageUrl;\r\n this.editLogo = true;\r\n });\r\n }\r\n }\r\n\r\n isUniqueLinkEmpty() {\r\n if (\r\n this.isNullOrWhitespace(this.selectedUniqueLink.LinkName) ||\r\n this.selectedUniqueLink.LinkType == null\r\n )\r\n return true;\r\n return false;\r\n }\r\n\r\n isNullOrWhitespace(input) {\r\n return !input || !input.trim();\r\n }\r\n\r\n saveUniqueLink() {\r\n this.isSavingUniqueLink = true;\r\n\r\n this.organisationLinkService.addUpdate(this.selectedUniqueLink).then((response) => {\r\n if (response) {\r\n this.isSavingUniqueLink = false;\r\n this.isEditUniqueLink = false;\r\n this.showEditUniqueLinkModal = false;\r\n } else {\r\n this.ulsavemessage = `There is problem saving ${this.selectedUniqueLink.LinkName} details, Please try later.`;\r\n }\r\n this.fetchUniqueLinks();\r\n }).catch((error) => {\r\n this.isSavingUniqueLink = false;\r\n this.ulsavemessage = \"There is a problem. Please try later.\";\r\n console.error(\"Error saving unique link:\", error);\r\n });\r\n }\r\n\r\n deleteUniqueLink() {\r\n if (this.deleteUniqueLinkClicked) {\r\n this.isEditUniqueLink = true;\r\n this.selectedUniqueLink.IsDeleted = true;\r\n this.selectedUniqueLink.IsEnabled = false;\r\n\r\n this.organisationLinkService.addUpdate(this.selectedUniqueLink).then((response) => {\r\n this.fetchUniqueLinks();\r\n this.isEditUniqueLink = false;\r\n this.confirmUniqueLinkDeletion = false;\r\n this.deleteUniqueLinkClicked = false;\r\n });\r\n } else {\r\n this.confirmUniqueLinkDeletion = false;\r\n }\r\n }\r\n\r\n cancelUniqueLinkModal() {\r\n this.selectedUniqueLink = undefined;\r\n this.showEditUniqueLinkModal = false;\r\n this.error = false;\r\n }\r\n\r\n closeUniqueLinkDeleteModal() {\r\n this.confirmUniqueLinkDeletion = false;\r\n this.deleteUniqueLinkClicked = false;\r\n this.ulsavemessage = \"\";\r\n }\r\n\r\n validateKey() {\r\n this.hubspotMessage = null;\r\n this.missingProperties = null;\r\n this.$organisationService\r\n .validateKey(\r\n this.selectedOrganisation.HubspotAccessToken,\r\n this.selectedOrganisation.HubspotPipelineStage,\r\n )\r\n .then((response) => {\r\n this.isHubspotValid = response == \"Access token is valid.\";\r\n this.hubspotMessage = response;\r\n })\r\n .then(() => {\r\n if (this.isHubspotValid) {\r\n this.$organisationService\r\n .getMissingProperties(\r\n this.selectedOrganisation.HubspotAccessToken,\r\n this.selectedOrganisation.HubspotPipelineStage,\r\n )\r\n .then((missingProperties) => {\r\n this.missingProperties = missingProperties;\r\n })\r\n .catch((error) => {\r\n this.hubspotMessage = `Error fetching missing properties: ${error.message}`;\r\n });\r\n } else {\r\n this.missingProperties = null;\r\n }\r\n });\r\n }\r\n\r\n setDefaultOrganisationThemeColour() {\r\n this.selectedOrganisation.OrganisationThemeColour = \"#304B9A\";\r\n this.registrationForm.$setDirty();\r\n }\r\n\r\n closeOtherLinkDropDown(linkType) {\r\n\r\n if (linkType != LinkTypeEnum.Development) {\r\n this.showDevFinanaceLinkOptions = false;\r\n }\r\n\r\n if (linkType != LinkTypeEnum.Bridging) {\r\n this.showBridgingLinkOptions = false;\r\n }\r\n if (linkType != LinkTypeEnum.Commercial) {\r\n this.showCommercialLinkOptions = false;\r\n }\r\n if (linkType != LinkTypeEnum.AllLoans) {\r\n this.showAllLoansLinkOptions = false;\r\n }\r\n\r\n }\r\n\r\n closeUniqueLinkGenerateDropdown(row) {\r\n this.showLinkOptions[row] = false;\r\n }\r\n\r\n closeAllEnterpriseLinkDropdowns() {\r\n this.showDevFinanaceLinkOptions = false;\r\n this.showBridgingLinkOptions = false;\r\n this.showCommercialLinkOptions = false;\r\n this.showAllLoansLinkOptions = false;\r\n }\r\n\r\n initializeSelectedNetworks() {\r\n if (this.selectedOrganisation.BrokerNetworks) {\r\n this.selectedBrokerNetworks = this.selectListService.decodeBitwiseEnum(\r\n this.selectedOrganisation.BrokerNetworks,\r\n this.selectListService.GetBrokerNetworks()\r\n );\r\n } else {\r\n this.selectedBrokerNetworks = [];\r\n }\r\n\r\n this.brokerNetworks.forEach(item => {\r\n (item as any).ticked = false;\r\n\r\n this.selectedBrokerNetworks.forEach((br: ListItem) => {\r\n if (br.key == item.key) {\r\n (item as any).ticked = true;\r\n }\r\n });\r\n });\r\n }\r\n\r\n initializeCRMs() {\r\n if (this.selectedOrganisation.CRMs) {\r\n this.selectedCRMs = this.selectListService.decodeBitwiseEnum(\r\n this.selectedOrganisation.CRMs,\r\n this.selectListService.GetCRMs()\r\n );\r\n } else {\r\n this.selectedCRMs = [];\r\n }\r\n\r\n this.crms.forEach(item => {\r\n (item as any).ticked = false;\r\n\r\n this.selectedCRMs.forEach((crm: ListItem) => {\r\n if (crm.key == item.key) {\r\n (item as any).ticked = true;\r\n }\r\n });\r\n });\r\n }\r\n\r\n saveSelectedNetworks() {\r\n this.selectedOrganisation.BrokerNetworks = this.selectListService.encodeBitwiseEnum(this.selectedBrokerNetworks);\r\n this.registrationForm.$setDirty();\r\n }\r\n\r\n saveSelectedCRMs() {\r\n this.selectedOrganisation.CRMs = this.selectListService.encodeBitwiseEnum(this.selectedCRMs);\r\n this.registrationForm.$setDirty();\r\n }\r\n\r\n isConnectMemberChanged() {\r\n this.showMarkAsConnectConfirmationModal = this.selectedOrganisation.IsConnectMember && this.originalOrganisation && !this.originalOrganisation.IsConnectMember;\r\n }\r\n\r\n OnCancelMarkAsConnect() {\r\n this.selectedOrganisation.IsConnectMember = false;\r\n this.isProcessingOrgSave = false;\r\n this.showMarkAsConnectConfirmationModal = false;\r\n }\r\n\r\n OnConfirmMarkAsConnect() {\r\n if (this.isProcessingOrgSave) {\r\n this.isMarkAsConnectConfirmed = true;\r\n this.showMarkAsConnectConfirmationModal = false;\r\n this.saveOrganisation();\r\n } else {\r\n this.showMarkAsConnectConfirmationModal = false;\r\n }\r\n\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\n\r\nexport class PayFailController {\r\n user: ApplicationUserDTO;\r\n performingAction: boolean;\r\n\r\n static $inject = [\"$scope\", \"$rootScope\", \"$cookies\", \"$location\"];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n ) {}\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AppPackagePricingDTO } from \"@js/DTO/AppPackagePricingDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { ModuleAppFeatureDTO } from \"@js/DTO/ModuleAppFeatureDTO.cs.d\";\r\nimport { PricingFrequencyEnum } from \"@js/models/enum/PricingFrequencyEnum.cs.d\";\r\nimport { UserRoleEnum } from \"@js/models/enum/UserRoleEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class PaymentController {\r\n caseId: number;\r\n case: CaseDTO;\r\n disablepayment: boolean = false;\r\n message: string = \"\";\r\n modal: boolean = false;\r\n isLoggedInUser: boolean = false;\r\n user: ApplicationUserDTO;\r\n\r\n appPackagePrices: AppPackagePricingDTO[];\r\n selectedProduct: AppPackagePricingDTO = null;\r\n selectedProductList: AppPackagePricingDTO[] = [];\r\n productCode: string;\r\n isSelected: boolean = false;\r\n moduleAppFeatures: ModuleAppFeatureDTO[];\r\n moduleFeatureCount: number = 0;\r\n selecteFeatureCount: number = 0;\r\n isBroker: boolean = false;\r\n isBorrower: boolean = false;\r\n billingFrequency: Array<{ id: number; value: string }> = [\r\n { id: 1, value: \"Monthly\" },\r\n { id: 2, value: \"Yearly\" },\r\n ];\r\n selectedPricingFrequency: boolean = false;\r\n selectedPricingFrequencyEnum: PricingFrequencyEnum;\r\n isQuickSearchSelected: boolean = false;\r\n isBookCallSelected: boolean = false;\r\n infoPanelSubheading: string;\r\n infoPanelHeading: string;\r\n panelHeaderText: string;\r\n orderButtonText: string = \"Continue\";\r\n orderButtonDisabled: boolean = false;\r\n showOrderButton: boolean = true;\r\n totalAmountToPay: number = 0;\r\n isAddOnSelected: boolean = false;\r\n whitelabelPrice: number = 0;\r\n leadGeneratorName: string;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$location\",\r\n \"PaymentService\",\r\n \"CaseService\",\r\n \"RoleService\",\r\n \"$cookies\",\r\n \"AuthService\",\r\n \"UserService\",\r\n ];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $scope: ng.IScope,\r\n public $rootScope: ng.IRootScopeService,\r\n private $location: ng.ILocationService,\r\n private $paymentService: PaymentService,\r\n private caseService: CaseService,\r\n private roleService: RoleService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private authService: AuthService,\r\n private userService: UserService,\r\n ) {\r\n //TODO Change for New pricing\r\n window.location.assign(\"https://brickflow.com/pricing\");\r\n\r\n this.leadGeneratorName = this.$cookies.get(\"leadgeneratorname\");\r\n this.isBroker = sessionStorage.getItem(\"userRole\") == \"broker\";\r\n this.isBorrower = sessionStorage.getItem(\"userRole\") == \"borrower\";\r\n this.user = JSON.parse(sessionStorage.getItem(\"userDetails\"));\r\n\r\n if (\r\n sessionStorage.getItem(\"selectedPackage\") &&\r\n sessionStorage.getItem(\"selectedPackage\") != \"undefined\" &&\r\n sessionStorage.getItem(\"selectedPackage\") != null\r\n ) {\r\n let data = sessionStorage.getItem(\"selectedPackage\");\r\n this.selectedProduct = JSON.parse(data);\r\n this.selectedPricingFrequency =\r\n this.selectedProduct.PricingFrequency == PricingFrequencyEnum.Monthly\r\n ? false\r\n : true;\r\n this.getAddOnPrice(this.selectedProduct.PricingFrequency);\r\n }\r\n\r\n if (sessionStorage.getItem(\"addAddon\")) {\r\n let data = sessionStorage.getItem(\"addAddon\");\r\n this.isAddOnSelected = JSON.parse(data);\r\n }\r\n\r\n if (this.$routeParams.isBroker) {\r\n this.isBroker = true;\r\n }\r\n this.infoPanelHeading =\r\n this.isBroker == true\r\n ? \"Ready to get started?\"\r\n : \"Compare loans from 40+ lenders, in minutes.
Model deals to check their viability, or contact us to secure the best value loan for your next development.\";\r\n this.infoPanelSubheading =\r\n this.isBroker == true\r\n ? \"We understand speed and reliable funding are key to retaining your clients.
\" +\r\n this.getApplicationName() +\r\n \" for Brokers gives you both.\"\r\n : \"\";\r\n this.panelHeaderText =\r\n this.isBroker == true\r\n ? \"Welcome to \" + this.getApplicationName() + \" for Brokers\"\r\n : \"Welcome to \" + this.getApplicationName();\r\n\r\n //if ($cookies.get('access_token')) {\r\n // this.isLoggedInUser = true;\r\n //}\r\n this.getActivePackagePricesForFrequency();\r\n\r\n //this.roleService.GetUserRoles().then((result) => {\r\n // if (result.filter(x => x == \"Broker\").length > 0) {\r\n // this.isBroker = true;\r\n // }\r\n //});\r\n\r\n /* if (this.$routeParams.CaseId && this.$routeParams.CaseId != 'null') {\r\n this.caseId = this.$routeParams.CaseId;\r\n this.email = this.$routeParams.CaseId;\r\n this.caseService.fetch(this.caseId).then(result => {\r\n this.case = result;\r\n \r\n })\r\n }*/\r\n }\r\n\r\n getTubeMapValue() {\r\n return this.caseService.getTubeMap();\r\n }\r\n\r\n makepaymentwithpaypal(caseId: number) {\r\n this.disablepayment = true;\r\n this.$paymentService\r\n .createpayment(caseId)\r\n .then((response) => {\r\n //could be called at c# end at some stage\r\n window.location.assign(response);\r\n })\r\n .catch(() => {\r\n this.disablepayment = false;\r\n });\r\n }\r\n\r\n markAsPaid(caseId: number) {\r\n this.disablepayment = true;\r\n this.case.IsApplicationFeePaid = 1;\r\n this.case.Paid = true;\r\n\r\n this.caseService.addUpdatereturnonlyid(this.case).then((response) => {\r\n this.modal = true;\r\n this.message = \"This case has been marked as paid.\";\r\n });\r\n }\r\n\r\n backToDashboard(): void {\r\n this.$location.path(\"/casedashboard/\" + this.caseId);\r\n }\r\n\r\n getActivePackagePricesForFrequency() {\r\n this.selectedPricingFrequencyEnum = this.getPriceFrequencyEnum();\r\n\r\n this.$paymentService\r\n .getActivePackagePricesForFrequency(\r\n this.selectedPricingFrequencyEnum,\r\n this.isBroker ? UserRoleEnum.Broker : UserRoleEnum.Client,\r\n )\r\n .then((response) => {\r\n this.appPackagePrices = response;\r\n if (!sessionStorage.getItem(\"selectedPackage\")) {\r\n this.selectedProduct = response[0];\r\n }\r\n });\r\n }\r\n\r\n searchNow() {\r\n (this.$rootScope as any).loanCriteria = null;\r\n sessionStorage.setItem(\r\n \"selectedPackage\",\r\n JSON.stringify(this.selectedProduct),\r\n );\r\n this.$location.path(\"/devfinancecriteria\");\r\n }\r\n\r\n signUpNow() {\r\n sessionStorage.setItem(\r\n \"selectedPackage\",\r\n JSON.stringify(this.selectedProduct),\r\n );\r\n if (this.isBroker) {\r\n this.$location.path(\"registerbroker\");\r\n } else {\r\n this.$location.path(\"register\");\r\n }\r\n }\r\n\r\n bookCallNow() {\r\n this.authService\r\n .getHubspotDeveloperBookMeetingNoSearch()\r\n .then((hubSpotUrl: string) => {\r\n window.location.assign(hubSpotUrl);\r\n });\r\n }\r\n\r\n getPriceFrequencyEnum(): PricingFrequencyEnum {\r\n return this.selectedPricingFrequency == false\r\n ? PricingFrequencyEnum.Monthly\r\n : PricingFrequencyEnum.Yearly;\r\n }\r\n\r\n convertEnumToString(value) {\r\n switch (value) {\r\n case PricingFrequencyEnum.Monthly:\r\n return \"month\";\r\n case PricingFrequencyEnum.Yearly:\r\n return \"year\";\r\n default:\r\n return \"\";\r\n }\r\n }\r\n\r\n getApplicationName() {\r\n if (sessionStorage.getItem(\"applicationName\") != null) {\r\n return sessionStorage.getItem(\"applicationName\");\r\n } else {\r\n return \"Brickflow\";\r\n }\r\n }\r\n\r\n /* This will be used when we have multiple products\r\n onSelectingProduct(selectedProduct) {\r\n this.selectedProduct = { ...selectedProduct };\r\n\r\n this.isQuickSearchSelected = false;\r\n this.isBookCallSelected = false;\r\n if (this.isBroker) {\r\n if (this.selectedProductList != null && this.selectedProductList.length > 0) {\r\n var found = this.selectedProductList.find(function (product) {\r\n return product.AppPackageId == selectedProduct.AppPackageId;\r\n });\r\n\r\n if (found) {\r\n this.selectedProductList = this.selectedProductList.filter(function (e) { return e.AppPackageId != selectedProduct.AppPackageId });\r\n }\r\n\r\n this.selectedProductList.push(this.selectedProduct);\r\n\r\n } else {\r\n this.selectedProductList.push(this.selectedProduct);\r\n }\r\n } else {\r\n this.getModuleQuantityForAppPackage(selectedProduct.AppPackageId);\r\n this.selectedProductList = []\r\n this.selectedProductList.push(this.selectedProduct);\r\n }\r\n\r\n this.isSelected = true;\r\n this.totalAmountToPay = this.calculateTotal(this.selectedProductList);\r\n }\r\n \r\n\r\n isPackageSelected(selectedProduct) {\r\n if (this.isBroker && selectedProduct && this.selectedProductList.length > 0) {\r\n var found = this.selectedProductList.find(function (product) {\r\n return product.Id == selectedProduct.Id;\r\n });\r\n\r\n if (found) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n getModuleQuantityForAppPackage(appPackageId: number) {\r\n this.$paymentService.getModuleQuantityForAppPackage(appPackageId).then((response) => {\r\n this.moduleFeatureCount = response;\r\n if (this.moduleFeatureCount > 0) {\r\n this.$paymentService.getAllModuleAppFeatures().then((response) => {\r\n this.moduleAppFeatures = response;\r\n })\r\n }\r\n });\r\n }\r\n\r\n onSelectingModuleFeature(selectedAppFeature) {\r\n if (!selectedAppFeature.Selected) {\r\n this.selecteFeatureCount++;\r\n } else {\r\n this.selecteFeatureCount--;\r\n }\r\n\r\n selectedAppFeature.Selected = !selectedAppFeature.Selected;\r\n\r\n }\r\n \r\n onSelectingQuickSearch() {\r\n this.isQuickSearchSelected = !this.isQuickSearchSelected;\r\n this.removeSelectedProduct();\r\n }\r\n\r\n onSelectingBookCall() {\r\n this.isBookCallSelected = !this.isBookCallSelected;\r\n this.removeSelectedProduct();\r\n }\r\n\r\n removeSelectedProduct() {\r\n this.selectedProductList = [];\r\n this.selectedProduct = null;\r\n this.isSelected = false;\r\n }*/\r\n\r\n orderButton() {\r\n const currentPath = this.$location.path();\r\n\r\n if (currentPath.startsWith(\"/promo\")) {\r\n this.userService.sendEventToHubspot(\r\n this.user,\r\n \"PACKAGESELECTION\",\r\n false,\r\n this.$cookies.get(\"org_code\"),\r\n parseInt(sessionStorage.getItem(\"userRole\")) as UserRoleEnum,\r\n );\r\n sessionStorage.setItem(\r\n \"selectedPackage\",\r\n JSON.stringify(this.selectedProduct),\r\n );\r\n this.$location.path(\"/addons\");\r\n } else if (currentPath === \"/addons\") {\r\n this.userService.sendEventToHubspot(\r\n this.user,\r\n \"ADDONSELECTION\",\r\n false,\r\n this.$cookies.get(\"org_code\"),\r\n parseInt(sessionStorage.getItem(\"userRole\")) as UserRoleEnum,\r\n );\r\n this.signUpNow();\r\n }\r\n }\r\n\r\n back() {\r\n const currentPath = this.$location.path();\r\n if (currentPath.startsWith(\"/promo\")) {\r\n this.$location.path(\"/initialregister\");\r\n } else if (currentPath === \"/addons\") {\r\n this.$location.path(\"/promo/\" + (this.isBroker ? \"true\" : \"\"));\r\n }\r\n }\r\n\r\n calculateTotal(): number {\r\n return (\r\n Number(\r\n this.selectedProduct?.Quantity * this.selectedProduct?.PriceAmount,\r\n ) + Number(this.isAddOnSelected ? this.whitelabelPrice : 0)\r\n );\r\n }\r\n\r\n emptyBasket() {\r\n this.removeAddOn();\r\n //this.selectedProduct.Quantity = 0;\r\n this.selectedProduct = this.appPackagePrices[0];\r\n sessionStorage.removeItem(\"selectedPackage\");\r\n }\r\n\r\n getAddOnPrice(frequency: PricingFrequencyEnum) {\r\n this.$paymentService.getWhitelabelPrice(frequency).then((response) => {\r\n this.whitelabelPrice = response;\r\n });\r\n }\r\n\r\n addAddOn() {\r\n this.isAddOnSelected = true;\r\n sessionStorage.setItem(\"addAddon\", \"true\");\r\n }\r\n\r\n removeAddOn() {\r\n this.isAddOnSelected = false;\r\n sessionStorage.setItem(\"addAddon\", \"false\");\r\n }\r\n\r\n getContractLengthText(\r\n frequency: PricingFrequencyEnum,\r\n contractLength: number,\r\n ) {\r\n if (contractLength == 1) {\r\n return \"1 Year Plan\";\r\n } else if (contractLength == 2) {\r\n return \"2 Year Plan\";\r\n } else {\r\n return frequency == PricingFrequencyEnum.Monthly\r\n ? \"Monthly Plan\"\r\n : \"Annual Plan\";\r\n }\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\n\r\nexport class PaySucessController {\r\n user: ApplicationUserDTO;\r\n performingAction: boolean;\r\n\r\n static $inject = [\"$scope\", \"$rootScope\", \"$cookies\", \"$location\"];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n ) {}\r\n\r\n gotoDashboard() {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n}\r\n","export class PrivacyController {\r\n orgCode: string;\r\n\r\n static $inject = [\"$routeParams\", \"$scope\", \"$location\"];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $scope: ng.IScope,\r\n private $location: ng.ILocationService,\r\n ) {\r\n document.getElementById(\"header\").style.display = \"none\";\r\n\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n }\r\n}\r\n","import { LenderDTO } from \"@js/DTO/LenderDTO.cs.d\";\r\nimport { ProductDTO } from \"@js/DTO/ProductDTO.cs.d\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { ProductService } from \"@js/services/ProductService\";\r\n\r\nexport class ProductController {\r\n selectedSection: string;\r\n\r\n objects: ProductDTO[];\r\n selectedObject: ProductDTO;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n lenderRecords: LenderDTO[];\r\n\r\n //addingSubobject: boolean;\r\n\r\n //subobjects: SubobjectDTO[];\r\n //selectedSubobject: SubobjectDTO;\r\n\r\n //fetchingSubobjects: boolean;\r\n //fetchingSubobject: boolean;\r\n\r\n productForm: ng.IFormController;\r\n //subproductForm: ng.IFormController;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"ProductService\",\r\n \"LenderService\",\r\n\r\n //'SubobjectService',\r\n ];\r\n //private $subobjectservice: App.Services.SubobjectService\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $productservice: ProductService,\r\n private $lenderservice: LenderService,\r\n ) {\r\n this.updateObjects();\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n\r\n // Fetch all objects.\r\n this.$productservice\r\n .fetchAll()\r\n .then((response) => {\r\n this.objects = response;\r\n this.preSelectedItem();\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n });\r\n }\r\n\r\n private preSelectedItem() {\r\n if (this.$routeParams.Id) {\r\n let selectedObject = this.objects.find((value, index) => {\r\n return value.Id === parseInt(this.$routeParams.objectId);\r\n });\r\n\r\n this.selectObject(selectedObject);\r\n }\r\n }\r\n\r\n selectObject(object: ProductDTO) {\r\n this.selectedObject = object;\r\n\r\n //this.fetchingSubobjects = true;\r\n //this.$subobjectservice.fetchSubobjectsForObject(object.Id).then((response) => {\r\n // this.subobjects = response;\r\n // this.fetchingSubobjects = false;\r\n //}).catch((response) => {\r\n // this.fetchingSubobjects = false;\r\n //});\r\n\r\n this.selectedSection = \"details\";\r\n }\r\n\r\n createObject() {\r\n this.selectedSection = \"details\";\r\n this.selectedObject = {} as ProductDTO;\r\n }\r\n\r\n save() {\r\n this.$productservice\r\n .addUpdatereturnonlyid(this.selectedObject)\r\n .then((response) => {\r\n this.selectedObject.Id = response;\r\n if (!this.objects) {\r\n this.objects = [];\r\n }\r\n\r\n let matches: ProductDTO[] = this.objects.filter((value, index) => {\r\n return value.Id == response;\r\n });\r\n\r\n if (!matches || matches.length === 0) {\r\n this.objects.push(this.selectedObject);\r\n }\r\n\r\n this.productForm.$setPristine();\r\n this.updateObjects();\r\n });\r\n }\r\n\r\n delete() {\r\n this.$productservice.delete(this.selectedObject.Id).then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.productForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n });\r\n }\r\n\r\n getlenders() {\r\n this.$lenderservice\r\n .fetchAll()\r\n .then((response) => {\r\n this.lenderRecords = response;\r\n })\r\n .finally(() => {});\r\n }\r\n\r\n //addSubobject() {\r\n // this.selectedSubobject = {\r\n // AssociatedObjectId: this.selectedObject.Id,\r\n // AssociatedObjectName: this.selectedObject.Name\r\n // } as SubobjectDTO;\r\n //}\r\n\r\n //removeSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.deleteSubobject(subobject.Id).then((response) => {\r\n // this.subobjects.splice(this.subobjects.indexOf(this.selectedSubobject), 1);\r\n // delete this.selectedSubobject;\r\n // });\r\n //}\r\n\r\n //cancelUpdateSubobject() {\r\n // delete this.selectedSubobject;\r\n //}\r\n\r\n //updateSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.addUpdateSubobject(subobject).then((response) => {\r\n // if (this.subobjects.indexOf(subobject) === -1) {\r\n // this.subobjects.push(subobject);\r\n // }\r\n // delete this.selectedSubobject;\r\n // }).catch((response) => {\r\n // delete this.selectedSubobject;\r\n // });\r\n\r\n //}\r\n}\r\n","import { ProductStubDTO } from \"@js/DTO/ProductStubDTO.cs.d\";\r\nimport { ProductStubService } from \"@js/services/ProductStubService\";\r\n\r\nexport class ProductStubController {\r\n selectedSection: string;\r\n\r\n objects: ProductStubDTO[];\r\n selectedObject: ProductStubDTO;\r\n\r\n fetchingObjects: boolean;\r\n fetchingObject: boolean;\r\n\r\n //addingSubobject: boolean;\r\n\r\n //subobjects: SubobjectDTO[];\r\n //selectedSubobject: SubobjectDTO;\r\n\r\n //fetchingSubobjects: boolean;\r\n //fetchingSubobject: boolean;\r\n\r\n productstubForm: ng.IFormController;\r\n //subproductstubForm: ng.IFormController;\r\n\r\n static $inject = [\r\n \"$routeParams\",\r\n \"ProductStubService\",\r\n\r\n //'SubobjectService',\r\n ];\r\n //private $subobjectservice: App.Services.SubobjectService\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $productstubservice: ProductStubService,\r\n ) {\r\n this.updateObjects();\r\n }\r\n\r\n updateObjects() {\r\n this.fetchingObjects = true;\r\n\r\n // Fetch all objects.\r\n this.$productstubservice\r\n .fetchAll()\r\n .then((response) => {\r\n this.objects = response;\r\n this.preSelectedItem();\r\n })\r\n .finally(() => {\r\n this.fetchingObjects = false;\r\n });\r\n }\r\n\r\n private preSelectedItem() {\r\n if (this.$routeParams.Id) {\r\n let selectedObject = this.objects.find((value, index) => {\r\n return value.Id === parseInt(this.$routeParams.objectId);\r\n });\r\n\r\n this.selectObject(selectedObject);\r\n }\r\n }\r\n\r\n selectObject(object: ProductStubDTO) {\r\n this.selectedObject = object;\r\n\r\n //this.fetchingSubobjects = true;\r\n //this.$subobjectservice.fetchSubobjectsForObject(object.Id).then((response) => {\r\n // this.subobjects = response;\r\n // this.fetchingSubobjects = false;\r\n //}).catch((response) => {\r\n // this.fetchingSubobjects = false;\r\n //});\r\n\r\n this.selectedSection = \"details\";\r\n }\r\n\r\n createObject() {\r\n this.selectedSection = \"details\";\r\n this.selectedObject = {} as ProductStubDTO;\r\n }\r\n\r\n save() {\r\n this.$productstubservice\r\n .addUpdatereturnonlyid(this.selectedObject)\r\n .then((response) => {\r\n this.selectedObject.Id = response;\r\n if (!this.objects) {\r\n this.objects = [];\r\n }\r\n\r\n let matches: ProductStubDTO[] = this.objects.filter((value, index) => {\r\n return value.Id == response;\r\n });\r\n\r\n if (!matches || matches.length === 0) {\r\n this.objects.push(this.selectedObject);\r\n }\r\n\r\n this.productstubForm.$setPristine();\r\n this.updateObjects();\r\n });\r\n }\r\n\r\n delete() {\r\n this.$productstubservice.delete(this.selectedObject.Id).then((response) => {\r\n if (response) {\r\n this.objects.splice(this.objects.indexOf(this.selectedObject), 1);\r\n this.productstubForm.$setPristine();\r\n delete this.selectedObject;\r\n }\r\n });\r\n }\r\n\r\n //addSubobject() {\r\n // this.selectedSubobject = {\r\n // AssociatedObjectId: this.selectedObject.Id,\r\n // AssociatedObjectName: this.selectedObject.Name\r\n // } as SubobjectDTO;\r\n //}\r\n\r\n //removeSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.deleteSubobject(subobject.Id).then((response) => {\r\n // this.subobjects.splice(this.subobjects.indexOf(this.selectedSubobject), 1);\r\n // delete this.selectedSubobject;\r\n // });\r\n //}\r\n\r\n //cancelUpdateSubobject() {\r\n // delete this.selectedSubobject;\r\n //}\r\n\r\n //updateSubobject(subobject: SubobjectDTO) {\r\n // this.$subobjectservice.addUpdateSubobject(subobject).then((response) => {\r\n // if (this.subobjects.indexOf(subobject) === -1) {\r\n // this.subobjects.push(subobject);\r\n // }\r\n // delete this.selectedSubobject;\r\n // }).catch((response) => {\r\n // delete this.selectedSubobject;\r\n // });\r\n\r\n //}\r\n}\r\n","export class Utils {\r\n public static deepCopy(source: T): T {\r\n return Array.isArray(source)\r\n ? source.map((item) => this.deepCopy(item))\r\n : source instanceof Date\r\n ? new Date(source.getTime())\r\n : source && typeof source === \"object\"\r\n ? Object.getOwnPropertyNames(source).reduce(\r\n (o, prop) => {\r\n Object.defineProperty(\r\n o,\r\n prop,\r\n Object.getOwnPropertyDescriptor(source, prop)!,\r\n );\r\n o[prop] = this.deepCopy(\r\n (source as { [key: string]: any })[prop],\r\n );\r\n return o;\r\n },\r\n Object.create(Object.getPrototypeOf(source)),\r\n )\r\n : (source as T);\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { IntroducerSimpleDTO } from \"@js/DTO/IntroducerSimpleDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { LocationEnum } from \"@js/models/enum/LocationEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { IntroducerSimpleService } from \"@js/services/IntroducerSimpleService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { Utils } from \"@js/Utils\";\r\n\r\nexport class ProfileController {\r\n profile: ApplicationUserDTO = null;\r\n profileEdit: ApplicationUserDTO = null;\r\n\r\n // Booleans to control which fields to display in the edit modal\r\n showEditModal: boolean = false;\r\n isEditIntro: boolean = false;\r\n isEditMiniBio: boolean = false;\r\n isEditOrganisation: boolean = false;\r\n isEditPassword: boolean = false;\r\n isEditContactPrefs: boolean = false;\r\n isEditSystemSettings: boolean = false;\r\n\r\n // Edit password\r\n currentPassword: string;\r\n newPassword: string;\r\n repeatPassword: string;\r\n\r\n // manage errors\r\n error: boolean = false;\r\n errorMessage: string;\r\n\r\n editTitle: string = \"\";\r\n\r\n // Get all introducers\r\n introducerList: IntroducerSimpleDTO[];\r\n userIntroducer: IntroducerSimpleDTO;\r\n userHasIntroducer: boolean = false;\r\n\r\n //get all organisations\r\n organisations: OrganisationDTO[];\r\n userOrganisation: OrganisationDTO;\r\n\r\n // This is the toggle to open the file upload modal\r\n openModal: boolean = false;\r\n\r\n profileForm: FormData;\r\n\r\n fullAvatarUrl: string = \"\";\r\n\r\n loggedIn: boolean = false;\r\n\r\n tinymceOptions: any;\r\n showSystemSetting: boolean = false;\r\n\r\n referrerOptions = [];\r\n locationOptions = [];\r\n\r\n static $inject = [\r\n \"$http\",\r\n \"AuthService\",\r\n \"UserService\",\r\n \"FileAttachmentService\",\r\n \"IntroducerSimpleService\",\r\n \"OrganisationService\",\r\n \"RoleService\",\r\n \"PaymentService\",\r\n \"$location\",\r\n \"$cookies\",\r\n \"SelectListService\",\r\n \"RoleService\",\r\n ];\r\n\r\n constructor(\r\n private $http: ng.IHttpService,\r\n private authService: AuthService,\r\n private userService: UserService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private introducerSimpleService: IntroducerSimpleService,\r\n private organisationService: OrganisationService,\r\n private $roleService: RoleService,\r\n private $paymentService: PaymentService,\r\n private $location: ng.ILocationService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private selectListService: SelectListService,\r\n private roleService : RoleService\r\n ) {\r\n this.tinymceOptions = {\r\n content_style:\r\n \"body {color: #304b9a;font:300 13.33px Roboto,sans-serif;}\",\r\n menubar: false,\r\n height: 300,\r\n branding: false,\r\n statusbar: false,\r\n plugins: [\r\n \"advlist autolink lists link image charmap print preview anchor\",\r\n \"searchreplace visualblocks code fullscreen\",\r\n \"insertdatetime media table paste code help wordcount\",\r\n ],\r\n toolbar:\r\n \"undo redo | formatselect | \" +\r\n \"bold italic backcolor forecolor | alignleft aligncenter \" +\r\n \"alignright alignjustify | bullist numlist outdent indent | preview fullscreen |\" +\r\n \"removeformat | help\",\r\n };\r\n\r\n if (\r\n this.$cookies.get(\"access_token\") != null &&\r\n this.$cookies.get(\"access_token\") != undefined\r\n ) {\r\n this.loggedIn = true;\r\n\r\n this.userService\r\n .getcurentuserrecord()\r\n .then((profile: ApplicationUserDTO) => {\r\n this.profile = profile;\r\n if (this.$location.path().startsWith(\"/managepreferences\") && this.roleService.IsLender == true) {\r\n this.editContactPreferences();\r\n }\r\n this.profileEdit = Utils.deepCopy(this.profile);\r\n this.showSystemSetting = profile.IsOrganisationAdmin;\r\n this.getFileURL(this.profile.ProfilePictureUrl);\r\n // Get the introducer, if there is one\r\n this.introducerSimpleService.fetchAll().then((response) => {\r\n this.introducerList = response;\r\n if (this.profile && this.profile.IntroducerId) {\r\n this.userHasIntroducer = true;\r\n this.userIntroducer = this.introducerList.find(\r\n (x) => x.Id == this.profile.IntroducerId,\r\n );\r\n }\r\n });\r\n this.organisationService.fetchAll().then((response) => {\r\n this.organisations = response;\r\n\r\n if (this.profile && this.profile.OrganisationId) {\r\n this.userOrganisation = this.organisations.find(\r\n (x) => x.Id == this.profile.OrganisationId,\r\n );\r\n }\r\n });\r\n });\r\n }\r\n\r\n this.referrerOptions = this.selectListService.GetReferrerOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n }\r\n\r\n /** Close the edit modal */\r\n closeEditModal() {\r\n this.showEditModal = false;\r\n this.isEditIntro = false;\r\n this.isEditMiniBio = false;\r\n this.isEditPassword = false;\r\n this.isEditContactPrefs = false;\r\n this.editTitle = \"\";\r\n this.isEditOrganisation = false;\r\n this.isEditSystemSettings = false;\r\n\r\n this.profileEdit = null;\r\n delete this.currentPassword;\r\n delete this.newPassword;\r\n delete this.repeatPassword;\r\n this.error = false;\r\n }\r\n\r\n /** Save the profile changes */\r\n saveProfile() {\r\n this.userService.addUpdate(this.profileEdit).then((userResponse) => {\r\n // TODO - JLH - I don't like that I'm getting the profile again - but the addupdate function isn't returning the roles in the user dto which causes them to disappear if you save again.\r\n this.userService\r\n .getcurentuserrecord()\r\n .then((profile: ApplicationUserDTO) => {\r\n this.profile = profile;\r\n\r\n this.getFileURL(this.profile.ProfilePictureUrl);\r\n // Update the profile cookie so that the rest of the application can be aware of the profile changes\r\n this.authService.setProfileCookie(this.profile);\r\n });\r\n\r\n this.closeEditModal();\r\n });\r\n }\r\n\r\n /** Edit the mini bio */\r\n editMiniBio() {\r\n this.isEditMiniBio = true;\r\n this.editTitle = \"Edit Mini Bio\";\r\n this.openEditModal();\r\n }\r\n\r\n /** Edit the intro details */\r\n editIntro() {\r\n this.isEditIntro = true;\r\n this.editTitle = \"Edit Intro\";\r\n this.openEditModal();\r\n }\r\n\r\n /** Edit the default organisation details */\r\n editDefaultOrganisation() {\r\n this.isEditOrganisation = true;\r\n this.editTitle = \"Edit default broker details\";\r\n this.openEditModal();\r\n }\r\n\r\n /** Open the edit modal */\r\n openEditModal() {\r\n // Make a copy of the main profile object so that the main page doesn't get updated at the same time\r\n this.profileEdit = Utils.deepCopy(this.profile);\r\n this.showEditModal = true;\r\n }\r\n\r\n /** Returns the location text based on the profile's Location enum */\r\n getLocationName(): string {\r\n var locationName: string = \"\";\r\n\r\n if (this.profile) {\r\n switch (this.profile.Location) {\r\n case LocationEnum.London:\r\n locationName = \"London\";\r\n break;\r\n case LocationEnum.NorthWest:\r\n locationName = \"North West\";\r\n break;\r\n case LocationEnum.Midlands:\r\n locationName = \"Midlands\";\r\n break;\r\n case LocationEnum.EastofEngland:\r\n locationName = \"East of England\";\r\n break;\r\n case LocationEnum.SouthEast:\r\n locationName = \"South East\";\r\n break;\r\n case LocationEnum.SouthWest:\r\n locationName = \"South West\";\r\n break;\r\n case LocationEnum.NorthEast:\r\n locationName = \"North East\";\r\n break;\r\n case LocationEnum.Wales:\r\n locationName = \"Wales\";\r\n break;\r\n case LocationEnum.Scotland:\r\n locationName = \"Scotland\";\r\n break;\r\n case LocationEnum.NorthernIreland:\r\n locationName = \"Northern Ireland\";\r\n break;\r\n case LocationEnum.ChannelIsland:\r\n locationName = \"Channel Islands\";\r\n break;\r\n default:\r\n locationName = \"\";\r\n }\r\n }\r\n\r\n return locationName;\r\n }\r\n\r\n /**\r\n * Called when a profile picture has been selected\r\n * @param files\r\n */\r\n onFileSelect(files) {\r\n this.fileAttachmentService.uploadFileAndReturnURI(files).then((result) => {\r\n // Make a copy of the main profile object so that the main page doesn't get updated at the same time\r\n this.profileEdit = Utils.deepCopy(this.profile);\r\n //this.profileEdit = { ...this.profile };\r\n\r\n this.profileEdit.ProfilePictureUrl = result.FileLocation;\r\n this.saveProfile();\r\n this.getFileURL(this.profileEdit.ProfilePictureUrl);\r\n });\r\n }\r\n\r\n /**\r\n * Gets the full url for the url specified\r\n * @param url\r\n */\r\n getFileURL(url: string) {\r\n this.fileAttachmentService.getFileUri(url).then((result) => {\r\n this.fullAvatarUrl = result;\r\n });\r\n }\r\n\r\n /**\r\n * return the default organisation selected\r\n */\r\n getSelectedDefaultOrganisationName(id: number) {\r\n if (this.organisations) {\r\n var find = this.organisations.find((x) => x.Id == id);\r\n }\r\n\r\n if (find) {\r\n return find.Name;\r\n } else {\r\n return \"none\";\r\n }\r\n }\r\n\r\n /** Edit the current password */\r\n editPassword() {\r\n this.isEditPassword = true;\r\n this.editTitle = \"Edit password\";\r\n this.openEditModal();\r\n }\r\n\r\n // change passwords\r\n applyPasswordChange() {\r\n this.error = false;\r\n if (\r\n this.newPassword &&\r\n this.repeatPassword &&\r\n this.newPassword === this.repeatPassword\r\n ) {\r\n this.authService\r\n .changePassword(this.currentPassword, this.newPassword)\r\n .then((response) => {\r\n delete this.currentPassword;\r\n delete this.newPassword;\r\n delete this.repeatPassword;\r\n })\r\n .catch(() => {\r\n this.error = true;\r\n this.errorMessage = \"Current password incorrect. Please try again\";\r\n })\r\n .finally(() => {\r\n if (!this.error) {\r\n this.showEditModal = false;\r\n }\r\n });\r\n }\r\n }\r\n\r\n editContactPreferences() {\r\n this.isEditContactPrefs = true;\r\n this.editTitle = \"Edit Contact Preferences\";\r\n this.openEditModal();\r\n }\r\n\r\n editSystemSettings() {\r\n this.isEditSystemSettings = true;\r\n this.editTitle = \"Edit System settings\";\r\n this.openEditModal();\r\n }\r\n\r\n // We no loger need it as we are not useing plantype for organisation.\r\n /* isBasicMode() {\r\n if (this.userOrganisation != null) {\r\n return this.userOrganisation.PlanType == PlanTypeEnum.Basic;\r\n } else {\r\n return false;\r\n }\r\n }*/\r\n\r\n manageLicence() {\r\n this.$location.path(\"/settings\");\r\n }\r\n\r\n viewLicense() {\r\n this.$location.path(\"/license/1\"); // + this.profile.LicenseMasterId);\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AccountService } from \"@js/services/AccountService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\n\r\nexport class ReferFriendController {\r\n currentUser: ApplicationUserDTO = null;\r\n\r\n //Refer a friend\r\n referFriendName: string;\r\n referFriendSurname: string;\r\n referFriendEmail: string;\r\n referFriendBody: string;\r\n\r\n //universal email send functions\r\n sendingrefermessage: boolean;\r\n sentrefermessage: boolean;\r\n\r\n page: number = 1;\r\n referForm1: ng.IFormController;\r\n referForm2: ng.IFormController;\r\n companyWebsite: string;\r\n isBrickflowOrg: boolean = false;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n \"AccountService\",\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private $auth: AuthService,\r\n protected roleService: RoleService,\r\n private $accountservice: AccountService,\r\n ) {\r\n this.$auth.getProfile().then((profile) => {\r\n this.currentUser = profile;\r\n });\r\n this.companyWebsite = sessionStorage.getItem(\"companyWebsite\");\r\n this.isBrickflowOrg = this.companyWebsite == \"https://brickflow.com\";\r\n }\r\n\r\n next() {\r\n if (this.page === 1) {\r\n this.page = 2;\r\n }\r\n }\r\n\r\n back() {\r\n if (this.page === 2) {\r\n this.page = 1;\r\n }\r\n }\r\n\r\n go(path: string) {\r\n this.$location.path(path);\r\n }\r\n\r\n sendRefer(): void {\r\n this.sendingrefermessage = true;\r\n this.sentrefermessage = false;\r\n\r\n this.$accountservice\r\n .SendFriendReferralEmail(\r\n this.currentUser.FirstName,\r\n this.currentUser.LastName,\r\n this.currentUser.Email,\r\n this.referFriendName,\r\n this.referFriendSurname,\r\n this.referFriendEmail,\r\n this.referFriendBody,\r\n )\r\n .then((response2) => {\r\n this.sendingrefermessage = false;\r\n this.sentrefermessage = true;\r\n });\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AppPackagePricingDTO } from \"@js/DTO/AppPackagePricingDTO.cs.d\";\r\nimport { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { IntroducerDTO } from \"@js/DTO/IntroducerDTO.cs.d\";\r\nimport { InvitedBrokerDTO } from \"@js/DTO/InvitedBrokerDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { RegisterOrganisationDTO } from \"@js/DTO/RegisterOrganisationDTO.cs.d\";\r\nimport { ApplicantRoleEnum } from \"@js/models/enum/ApplicantRoleEnum.cs.d\";\r\nimport { IntroducerTypeEnum } from \"@js/models/enum/IntroducerTypeEnum.cs.d\";\r\nimport { OrganisationTypeEnum } from \"@js/models/enum/OrganisationTypeEnum.cs.d\";\r\nimport { PricingFrequencyEnum } from \"@js/models/enum/PricingFrequencyEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { IntroducerService } from \"@js/services/IntroducerService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { UserRoleEnum } from \"@js/models/enum/UserRoleEnum.cs.d\";\r\n\r\nexport class RegistrationBrokerController {\r\n bar: number = 0;\r\n formEntered: boolean[] = [\r\n false,\r\n false,\r\n false,\r\n false,\r\n false,\r\n false,\r\n false,\r\n false,\r\n false,\r\n false,\r\n false,\r\n false,\r\n false,\r\n ];\r\n step: number = 1;\r\n stepName: string = \"\";\r\n seats: number = 1;\r\n dataLoading: boolean = false;\r\n progressBar: {\r\n step: number;\r\n label: string;\r\n active: boolean;\r\n complete: boolean;\r\n }[] = [\r\n { step: 1, label: \"About you\", active: false, complete: false },\r\n { step: 2, label: \"About your business\", active: false, complete: false },\r\n {\r\n step: 3,\r\n label: \"More about your business\",\r\n active: false,\r\n complete: false,\r\n },\r\n { step: 4, label: \"Assign licenses\", active: false, complete: false },\r\n ];\r\n\r\n aboutYouSection: boolean = false;\r\n aboutYourBusinessSection: boolean = false;\r\n moreAboutYourBusinessSection: boolean = false;\r\n user: ApplicationUserDTO = {\r\n Roles: [\"Broker\", \"Introducer\"],\r\n IsOrganisationAdmin: true,\r\n ApplicantDefinedRole: ApplicantRoleEnum.Introducer,\r\n ApplicantDefinedRoleIntroducer: IntroducerTypeEnum.Broker,\r\n } as ApplicationUserDTO;\r\n\r\n selectedPackage: AppPackagePricingDTO;\r\n\r\n organization: OrganisationDTO;\r\n userEmails: InvitedBrokerDTO[] = [];\r\n newUser: InvitedBrokerDTO = {\r\n Email: null,\r\n FirstName: null,\r\n };\r\n tempdata: InvitedBrokerDTO;\r\n //tour\r\n welcomeMessage: string =\r\n \"Welcome to the Brickflow for Brokers - to setup your account we need some details on you and your company.\";\r\n tourOrder: number = 1;\r\n\r\n registrationFormStep1: ng.IFormController;\r\n registrationFormStep2: ng.IFormController;\r\n registrationFormStep3: ng.IFormController;\r\n\r\n //display Logos\r\n companyLogo: FileAttachmentDTO;\r\n profileLogo: FileAttachmentDTO;\r\n\r\n error: string;\r\n\r\n // TODO - JLH - what are these variables? can we improve the naming?\r\n //rename Email\r\n renamingItem: InvitedBrokerDTO;\r\n newName: InvitedBrokerDTO;\r\n\r\n passwordError: boolean = false;\r\n\r\n isProcessingRegister: boolean = false;\r\n\r\n // Show and hide a input field to add users.\r\n hideInput: boolean = false;\r\n showErrorMsg: boolean = false;\r\n confirmPassword: string;\r\n selectedProductList: AppPackagePricingDTO[] = [];\r\n\r\n isPayClicked: boolean = false;\r\n\r\n isConvertingExistingUser: boolean = false;\r\n\r\n orgUniqueRef: string;\r\n orgNameToAssign: string;\r\n isProceedClicked: boolean = false;\r\n confirmAssignToOrg: boolean = false;\r\n isAddonselected: boolean = false;\r\n\r\n locationOptions = [];\r\n referrerOptions = [];\r\n\r\n static $inject = [\r\n \"FileAttachmentService\",\r\n \"$routeParams\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"RoleService\",\r\n \"$rootScope\",\r\n \"OrganisationService\",\r\n \"AuthService\",\r\n \"IntroducerService\",\r\n \"$window\",\r\n \"UserService\",\r\n \"DevelopmentInputService\",\r\n \"PaymentService\",\r\n \"SelectListService\",\r\n ];\r\n\r\n constructor(\r\n private fileAttachmentService: FileAttachmentService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $roleService: RoleService,\r\n private $rootScope: ng.IRootScopeService,\r\n private $organisation: OrganisationService,\r\n private $auth: AuthService,\r\n private introduceService: IntroducerService,\r\n private $window: ng.IWindowService,\r\n private userService: UserService,\r\n private developmentInputService: DevelopmentInputService,\r\n private $paymentService: PaymentService,\r\n private selectListService: SelectListService,\r\n ) {\r\n //TODO Change for New pricing\r\n window.location.assign(\"https://brickflow.com/pricing\");\r\n\r\n // If we have an introducer code set, let's store a cookie.\r\n if (this.$routeParams[\"ic\"]) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"introducer_code\", this.$routeParams[\"ic\"], {\r\n expires: expiryDate,\r\n });\r\n }\r\n\r\n if (this.$routeParams[\"orgc\"]) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"org_code\", this.$routeParams[\"orgc\"], {\r\n expires: expiryDate,\r\n });\r\n }\r\n\r\n if (this.$routeParams[\"orguniqueref\"]) {\r\n this.orgUniqueRef = this.$routeParams[\"orguniqueref\"];\r\n this.user.IsOrganisationAdmin = false;\r\n\r\n this.$organisation\r\n .getOrganisationByUniqueRef(this.orgUniqueRef)\r\n .then((org: OrganisationDTO) => {\r\n this.orgNameToAssign = org.Name;\r\n });\r\n }\r\n\r\n /* window.onbeforeunload = function (event) {\r\n //console.log(event);\r\n //console.log(this.registrationFormStep1.$invalid);\r\n /*fetch(\"/api/organisation/brokersignupjourneyg2email?brokerEmail=\" + this.user.Email + \"&brokerFirstName=\" + this.user.FirstName + \"&brokerLastName=\" + this.user.LastName, {\r\n method: \"GET\",\r\n keepalive: true,\r\n });*/\r\n //navigator.sendBeacon(\"/api/organisation/brokersignupjourneyg2email?brokerEmail=\" + this.user.Email + \"&brokerFirstName=\" + this.user.FirstName + \"&brokerLastName=\" + this.user.LastName);\r\n /* if (this.user.Email != null && this.user.FirstName != null && this.user.LastName != null ) {\r\n this.$organisation.brokerSignUpJourneyG2Email(this.user.Email, this.user.FirstName, this.user.LastName).then((response) => {\r\n });\r\n }\r\n }*/\r\n\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.userService.getcurentuserrecord().then((result) => {\r\n this.user = result;\r\n\r\n if (this.user.IsLegacyUser || this.orgUniqueRef) {\r\n this.isConvertingExistingUser = this.user.IsLegacyUser;\r\n this.user = result;\r\n\r\n this.user.Roles = [\"Broker\", \"Introducer\"];\r\n\r\n this.user.IsOrganisationAdmin = !this.orgUniqueRef ? true : false;\r\n this.user.ApplicantDefinedRole = ApplicantRoleEnum.Introducer;\r\n this.user.ApplicantDefinedRoleIntroducer = IntroducerTypeEnum.Broker;\r\n } else {\r\n this.$roleService.goHomeBasedOnUser();\r\n }\r\n });\r\n } else {\r\n if (sessionStorage.getItem(\"userDetails\")) {\r\n let data = sessionStorage.getItem(\"userDetails\");\r\n let userdetails = JSON.parse(data);\r\n\r\n let userFullName = userdetails.FullName;\r\n let spaceIndex = userFullName.indexOf(\" \");\r\n\r\n let firstName = \"\";\r\n let lastName = \"\";\r\n\r\n // if not space has been added to the name then put the whole name in the first name field\r\n if (spaceIndex == -1) {\r\n firstName = userFullName;\r\n } else {\r\n firstName = userFullName.substring(0, userFullName.indexOf(\" \"));\r\n lastName = userFullName.substring(userFullName.indexOf(\" \") + 1);\r\n }\r\n\r\n this.user.FirstName = firstName;\r\n this.user.LastName = lastName;\r\n this.user.Email = userdetails.Email;\r\n this.user.PhoneNumber = userdetails.PhoneNumber;\r\n }\r\n }\r\n\r\n if (sessionStorage.getItem(\"selectedPackage\")) {\r\n let data = sessionStorage.getItem(\"selectedPackage\");\r\n this.selectedPackage = JSON.parse(data);\r\n }\r\n\r\n this.referrerOptions = this.selectListService.GetReferrerOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n }\r\n\r\n change() {\r\n if (this.confirmPassword) {\r\n if (this.confirmPassword !== this.user.Password) {\r\n this.error = \"Passwords do not match\";\r\n } else {\r\n delete this.error;\r\n }\r\n }\r\n }\r\n\r\n addNewUser() {\r\n if (this.newUser.Email != null && this.newUser.FirstName != null) {\r\n var temp = { ...this.newUser };\r\n this.userEmails.push(temp);\r\n this.newUser.Email = null;\r\n this.newUser.FirstName = null;\r\n // this.registrationForm.newUserFirstName.$setUntouched()\r\n // this.registrationForm.newUserEmail.$setUntouched();\r\n }\r\n }\r\n\r\n removeNewUserEmail(event) {\r\n event.preventDefault();\r\n delete this.newUser;\r\n }\r\n\r\n cancelAddingNewUser() {\r\n this.newUser.Email = null;\r\n this.newUser.FirstName = null;\r\n // this.registrationForm.newUserFirstName.$setUntouched();\r\n //this.registrationForm.newUserEmail.$setUntouched()\r\n }\r\n\r\n getFocusToInput() {\r\n var getelement = this.$window.document.getElementById(\"newuser\");\r\n getelement.focus();\r\n }\r\n\r\n changeCompanyLogo(files) {\r\n if (files.length > 0) {\r\n this.fileAttachmentService\r\n .uploadPublicImage(files, this.organization.OrganisationCode)\r\n .then((result) => {\r\n if (result) {\r\n this.organization.LogoURL = result;\r\n }\r\n });\r\n }\r\n }\r\n\r\n changeProfileLogo(files) {\r\n if (files.length > 0) {\r\n this.fileAttachmentService\r\n .uploadFileAndReturnURI(files)\r\n .then((result) => {\r\n if (result) {\r\n this.profileLogo = result;\r\n }\r\n });\r\n }\r\n }\r\n\r\n registerAccount() {\r\n this.isPayClicked = true;\r\n this.confirmAssignToOrg = false;\r\n this.dataLoading = true;\r\n this.getStepName();\r\n\r\n if (\r\n !this.orgUniqueRef &&\r\n !this.user.IsLegacyUser &&\r\n this.confirmPassword !== this.user.Password\r\n ) {\r\n this.passwordError = true;\r\n this.dataLoading = false;\r\n this.isPayClicked = false;\r\n } else {\r\n this.userService.sendEventToHubspot(\r\n this.user,\r\n this.stepName,\r\n true,\r\n this.$cookies.get(\"org_code\"),\r\n parseInt(sessionStorage.getItem(\"userRole\")) as UserRoleEnum,\r\n );\r\n this.passwordError = false;\r\n this.user.UserName = this.user.Email;\r\n this.userRegistration();\r\n }\r\n }\r\n\r\n userRegistration() {\r\n this.isProcessingRegister = true;\r\n\r\n this.user.ProfilePictureUrl = this.profileLogo\r\n ? this.profileLogo.FileLocation\r\n : null;\r\n\r\n if (this.$cookies.get(\"introducer_code\")) {\r\n this.user.IntroducerCode = this.$cookies.get(\"introducer_code\");\r\n }\r\n\r\n if (this.orgUniqueRef) {\r\n this.$organisation\r\n .registerBroker(this.user, this.orgUniqueRef)\r\n .then((convertedBrokerDto: ApplicationUserDTO) => {\r\n // clean up local storage\r\n sessionStorage.removeItem(\"userDetails\");\r\n sessionStorage.removeItem(\"userRole\");\r\n sessionStorage.removeItem(\"projectname\");\r\n\r\n (this.$rootScope as any).selectedUser = convertedBrokerDto;\r\n\r\n this.$auth\r\n .login(\r\n this.user.Email,\r\n this.user.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n let expiry: Date = response;\r\n\r\n this.$cookies.put(\"user_firstname\", this.user.FirstName, {\r\n expires: expiry,\r\n });\r\n\r\n this.cleanupAfterConversion();\r\n })\r\n .catch((response) => {\r\n this.error = response.data.Message;\r\n this.isProcessingRegister = false;\r\n });\r\n })\r\n .catch((response) => {\r\n this.error = response.data.ExceptionMessage;\r\n this.isProcessingRegister = false;\r\n this.dataLoading = false;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.organization.OrganisationType = OrganisationTypeEnum.Broker;\r\n this.organization.CommissionPercent = 0.01;\r\n\r\n this.user.Location = this.organization.Location;\r\n\r\n var registerOrgDto: RegisterOrganisationDTO = {\r\n OrganisationDTO: this.organization,\r\n OrganisationAdminUserDTO: this.user,\r\n InviteOrganisationUsers: this.userEmails,\r\n };\r\n\r\n this.$organisation\r\n .registerOrganisationAndAdmin(registerOrgDto)\r\n .then((registerOrganisationDto: RegisterOrganisationDTO) => {\r\n // clean up session storage\r\n sessionStorage.removeItem(\"userDetails\");\r\n sessionStorage.removeItem(\"userRole\");\r\n sessionStorage.removeItem(\"projectname\");\r\n\r\n (this.$rootScope as any).selectedUser =\r\n registerOrganisationDto.OrganisationAdminUserDTO;\r\n\r\n if (\r\n this.$cookies.get(\"access_token\") &&\r\n this.isConvertingExistingUser\r\n ) {\r\n this.cleanupAfterConversion();\r\n } else if (!this.$cookies.get(\"access_token\")) {\r\n // Automatically log in the broker org admin\r\n this.$auth\r\n .login(\r\n this.user.Email,\r\n this.user.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n let expiry: Date = response;\r\n\r\n this.$cookies.put(\"user_firstname\", this.user.FirstName, {\r\n expires: expiry,\r\n });\r\n\r\n this.onRegistrationComplete();\r\n })\r\n .catch((response) => {\r\n this.error = response.data.Message;\r\n this.isProcessingRegister = false;\r\n });\r\n } else {\r\n this.error = \"logged in but not converting an existing user\";\r\n this.isProcessingRegister = false;\r\n this.dataLoading = false;\r\n }\r\n })\r\n .catch((response) => {\r\n this.error = response.data.ExceptionMessage;\r\n this.isProcessingRegister = false;\r\n this.dataLoading = false;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n onRegistrationComplete() {\r\n if (this.selectedPackage) {\r\n /* this.selectedPackage.Quantity = this.seats;*/\r\n this.selectedProductList.push(this.selectedPackage);\r\n this.createCheckoutSession();\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n }\r\n\r\n cleanupAfterConversion() {\r\n // clear and reset cached data based on the new information\r\n\r\n this.$auth.getProfile().then((response) => {\r\n this.$cookies.put(\"user_firstname\", response.FirstName);\r\n (this.$rootScope as any).selectedUser = response;\r\n });\r\n\r\n (this.$rootScope as any).selectedUser = null;\r\n (this.$rootScope as any).currentUser = null;\r\n\r\n this.$roleService.GetUserRoles(true); //reset user roles\r\n\r\n sessionStorage.setItem(\"isUpgradedUser\", \"true\");\r\n\r\n this.onRegistrationComplete();\r\n }\r\n\r\n registerDisabled() {\r\n if (\r\n this.organization &&\r\n this.organization.Location &&\r\n this.organization.PhoneNumber\r\n ) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n }\r\n\r\n registerIntroducerByUserId(userId: string): void {\r\n var introducer = {\r\n UserId: userId,\r\n IsIndividual: false,\r\n IntroducerType: IntroducerTypeEnum.Broker,\r\n CompanyName: this.organization.Name,\r\n CompanyURL: this.organization?.CompanyURL,\r\n } as IntroducerDTO;\r\n\r\n this.introduceService\r\n .registerIntroducer(introducer)\r\n .then((success) => {})\r\n .catch((error) => {\r\n this.error =\r\n \"It looks like there was a problem registering you as an introducer. Please try again in a moment.\";\r\n });\r\n }\r\n\r\n removeEmail(item: InvitedBrokerDTO) {\r\n this.userEmails = this.userEmails.filter((x) => x != item);\r\n }\r\n\r\n renameItem(item: InvitedBrokerDTO) {\r\n if (this.renamingItem === undefined) {\r\n this.renamingItem = item;\r\n this.newName = item;\r\n this.tempdata = { ...this.renamingItem };\r\n } else {\r\n delete this.renamingItem;\r\n }\r\n }\r\n\r\n renamingItemComplete(item: InvitedBrokerDTO) {\r\n this.userEmails = this.userEmails.filter((x) => x != item);\r\n this.userEmails.push(this.newName);\r\n this.renamingItem = null;\r\n }\r\n\r\n cancelRenaming(item: InvitedBrokerDTO) {\r\n this.userEmails = this.userEmails.filter((x) => x != item);\r\n this.userEmails.push(this.tempdata);\r\n delete this.renamingItem;\r\n //this.registrationForm.editUserEmail.$setUntouched()\r\n //this.registrationForm.editUserFirstName.$setUntouched()\r\n }\r\n\r\n /* back() {\r\n this.tourOrder--;\r\n this.welcomeMessage = \"Welcome to the Brickflow for Brokers - to setup your account we need some details on you and your company.\";\r\n }\r\n next() {\r\n this.tourOrder++;\r\n this.welcomeMessage = \"Impress your clients with Brickflow Plus; add your company logo and profile picture, to personalise the software.\";\r\n }\r\n */\r\n\r\n fillRegisterForm() {\r\n let name = new Date().toLocaleString().replace(/ |,|:|\\/|/g, \"\");\r\n this.organization.Name = name;\r\n this.organization.CompanyURL = \"www.google.com\";\r\n this.organization.Location = 1;\r\n this.organization.PhoneNumber = \"12345677\";\r\n this.user.Email = `${name}@test.com`;\r\n this.user.FirstName = `${name}Admin`;\r\n this.user.LastName = \"t\";\r\n this.user.PhoneNumber = \"12345677\";\r\n this.user.Referrer = 1;\r\n this.user.Representative = \"None\";\r\n this.organization.FCANumber = \"12344\";\r\n this.organization.TagLine = `${name}tag`;\r\n this.user.Password = \"test\";\r\n this.confirmPassword = \"test\";\r\n }\r\n\r\n next() {\r\n this.getStepName();\r\n\r\n if (!this.user.IsLegacyUser) {\r\n this.userService\r\n .checkEmailExists(this.user.Email)\r\n .then((emailExists: boolean) => {\r\n if (emailExists == true) {\r\n this.error = \"Email address is already in use, please sign in.\";\r\n } else {\r\n this.userService.sendEventToHubspot(\r\n this.user,\r\n this.stepName,\r\n false,\r\n this.$cookies.get(\"org_code\"),\r\n parseInt(sessionStorage.getItem(\"userRole\")) as UserRoleEnum,\r\n );\r\n this.step++;\r\n }\r\n });\r\n } else {\r\n this.userService.sendEventToHubspot(\r\n this.user,\r\n this.stepName,\r\n false,\r\n this.$cookies.get(\"org_code\"),\r\n parseInt(sessionStorage.getItem(\"userRole\")) as UserRoleEnum,\r\n );\r\n this.step++;\r\n }\r\n }\r\n\r\n back() {\r\n this.step--;\r\n }\r\n\r\n proceed() {}\r\n\r\n calculateBarPercentage(index: number, value: string) {\r\n if (!this.formEntered[index] && (value || value != \"\")) {\r\n this.bar += 8;\r\n this.formEntered[index] = !this.formEntered[index];\r\n } else if (\r\n this.formEntered[index] &&\r\n (value == undefined || value == \"\" || value == null)\r\n ) {\r\n this.bar -= 8;\r\n this.formEntered[index] = !this.formEntered[index];\r\n }\r\n }\r\n\r\n isFirstStepValid() {\r\n if (\r\n !this.registrationFormStep1.$invalid &&\r\n !this.error &&\r\n !this.passwordError\r\n ) {\r\n this.progressBar[0].complete = true;\r\n return true;\r\n } else {\r\n this.progressBar[0].complete = false;\r\n return false;\r\n }\r\n }\r\n\r\n isSecondStepValid() {\r\n if (!this.registrationFormStep2.$invalid) {\r\n this.progressBar[1].complete = true;\r\n return true;\r\n } else {\r\n this.progressBar[1].complete = false;\r\n return false;\r\n }\r\n }\r\n\r\n isThirdStepValid() {\r\n if (\r\n !this.registerDisabled() &&\r\n this.user.AgreedToTermsAndPP === true &&\r\n !this.isProcessingRegister &&\r\n !this.registrationFormStep3.$invalid\r\n ) {\r\n this.progressBar[2].complete = true;\r\n return true;\r\n } else {\r\n this.progressBar[2].complete = false;\r\n return false;\r\n }\r\n }\r\n\r\n getTotalCost(): number {\r\n if (this.selectedPackage) {\r\n return this.selectedPackage.PriceAmount * this.seats;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n getPricingFrequency(): string {\r\n var frequencyText = \"Month\";\r\n if (this.selectedPackage) {\r\n switch (this.selectedPackage.PricingFrequency) {\r\n case PricingFrequencyEnum.Yearly: {\r\n frequencyText = \"Year\";\r\n break;\r\n }\r\n case PricingFrequencyEnum.Monthly:\r\n default:\r\n frequencyText = \"Month\";\r\n }\r\n }\r\n return frequencyText;\r\n }\r\n\r\n createCheckoutSession() {\r\n //this.selectedProductList[0].SelectedModuleAppFeature = this.moduleAppFeatures;\r\n // Need to save the search so we can get back to it after payment ($rootscope will lose the data)\r\n if (sessionStorage.getItem(\"addAddon\")) {\r\n this.isAddonselected =\r\n sessionStorage.getItem(\"addAddon\") == \"true\" ? true : false;\r\n }\r\n\r\n if ((this.$rootScope as any).loanCriteria != null) {\r\n (this.$rootScope as any).loanCriteria.UserId = (\r\n this.$rootScope as any\r\n ).selectedUser.Id;\r\n (this.$rootScope as any).loanCriteria.BrokerOrganisationId = (\r\n this.$rootScope as any\r\n ).selectedUser.OrganisationId;\r\n this.developmentInputService\r\n .saveSearch((this.$rootScope as any).loanCriteria)\r\n .then((developmentInputId: number) => {\r\n this.$paymentService\r\n .createCheckoutSession(\r\n this.selectedPackage,\r\n this.isAddonselected,\r\n \"\",\r\n developmentInputId,\r\n )\r\n .then((response) => {\r\n window.location.assign(response.SessionUrl);\r\n });\r\n });\r\n } else {\r\n this.$paymentService\r\n .createCheckoutSession(\r\n this.selectedPackage,\r\n this.isAddonselected,\r\n \"\",\r\n null,\r\n )\r\n .then((response) => {\r\n window.location.assign(response.SessionUrl);\r\n });\r\n }\r\n }\r\n\r\n cancelCheckout() {\r\n if ((this.$rootScope as any).loanCriteria) {\r\n this.$location.path(\"/results\");\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n }\r\n\r\n getApplicationName() {\r\n if (sessionStorage.getItem(\"applicationName\") != null) {\r\n return sessionStorage.getItem(\"applicationName\");\r\n } else {\r\n return \"Brickflow\";\r\n }\r\n }\r\n\r\n getStepName() {\r\n switch (this.step) {\r\n case 1:\r\n this.stepName = \"REGISTRATIONUSERDETAILS\";\r\n break;\r\n case 2:\r\n this.stepName = \"REGISTRATIONCOMPANYDETAILS\";\r\n break;\r\n case 3:\r\n this.stepName = \"REGISTATIONFINALSTEP\";\r\n break;\r\n }\r\n }\r\n}\r\n","export const enum ReferrerEnum {\r\n GoogleSearch = 1,\r\n OtherSearch = 2,\r\n LinkedIn = 3,\r\n Facebook = 4,\r\n Agent = 5,\r\n ExistingUser = 6,\r\n BrickflowConsultant = 7,\r\n Broker = 8,\r\n Developer = 9,\r\n Other = 10,\r\n MassReports = 11,\r\n NimbusMaps = 12,\r\n /** NotSure = 13, */\r\n PressRelease = 13,\r\n TheRodcast = 14,\r\n OTM = 15,\r\n WordOfMouth = 16,\r\n PersonalRecommendation = 17,\r\n Ad = 18,\r\n SocialMedia = 19,\r\n FIBA = 20,\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AppPackagePricingDTO } from \"@js/DTO/AppPackagePricingDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { LenderResultDTO } from \"@js/DTO/DevelopmentFinance/LenderResultDTO.cs.d\";\r\nimport { DevelopmentWithNoLoginDTO } from \"@js/DTO/DevelopmentWithNoLoginDTO.cs.d\";\r\nimport { IntroducerDTO } from \"@js/DTO/IntroducerDTO.cs.d\";\r\nimport { ApplicantRoleEnum } from \"@js/models/enum/ApplicantRoleEnum.cs.d\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\nimport { ReferrerEnum } from \"@js/models/enum/ReferrerEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { ClientService } from \"@js/services/ClientService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { DealClientService } from \"@js/services/DealClientService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { DevelopmentInputWithNoLoginService } from \"@js/services/DevelopmentInputWithNoLoginService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { InviteService } from \"@js/services/InviteService\";\r\nimport { LenderResultService } from \"@js/services/LenderResultService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class RegistrationController {\r\n dataLoading: boolean = false;\r\n\r\n openModal: boolean = false;\r\n\r\n registeringAccount: boolean;\r\n registrationFormStep1: ng.IFormController;\r\n registrationFormStep2: ng.IFormController;\r\n\r\n error: string;\r\n passworderror: string;\r\n\r\n loanCriteria: DevelopmentInputDTO;\r\n selectedResult: LenderResultDTO;\r\n loanLabel: string = \"\";\r\n\r\n enquireAfterRegistration: boolean;\r\n\r\n newIntroducer: IntroducerDTO;\r\n\r\n //newUser: RegistrationRequestDTO = {\r\n // Email: \"\", FirstName: \"\", LastName: \"\"\r\n //} as RegistrationRequestDTO;\r\n\r\n newUser: ApplicationUserDTO = {\r\n Id: \"\",\r\n Roles: [\"Client\"],\r\n } as ApplicationUserDTO;\r\n\r\n inviteGuid: string = \"\";\r\n step: number = 1;\r\n profileLogo: string;\r\n selectedPackage: AppPackagePricingDTO;\r\n selectedProductList: AppPackagePricingDTO[] = [];\r\n isPayClicked: boolean = false;\r\n\r\n isConvertingExistingUser: boolean = false;\r\n\r\n redirectToSearch: boolean = false;\r\n\r\n isShareholderRegistration: boolean = false;\r\n\r\n referrerOptions = [];\r\n locationOptions = [];\r\n\r\n showTsAndCs: boolean = false;\r\n showPrivacyPolicy: boolean = false;\r\n orgCode: string;\r\n productFamily: ProductFamilyEnum;\r\n\r\n static $inject = [\r\n \"CaseService\",\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"$httpParamSerializerJQLike\",\r\n \"LenderResultService\",\r\n \"UserService\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n \"CaseMemberService\",\r\n \"CaseService\",\r\n \"InviteService\",\r\n \"OrganisationService\",\r\n \"FileAttachmentService\",\r\n \"DevelopmentInputService\",\r\n \"PaymentService\",\r\n \"DevelopmentInputWithNoLoginService\",\r\n \"SelectListService\",\r\n \"ClientService\",\r\n \"DealClientService\",\r\n \"DealService\",\r\n ];\r\n\r\n constructor(\r\n private $CaseService: CaseService,\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private $httpParamSerializerJQLike: ng.IHttpParamSerializer,\r\n private $lenderresultservice: LenderResultService,\r\n private $user: UserService,\r\n private $auth: AuthService,\r\n private $roleService: RoleService,\r\n private caseMember: CaseMemberService,\r\n private caseService: CaseService,\r\n private inviteService: InviteService,\r\n private organizationService: OrganisationService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private developmentInputService: DevelopmentInputService,\r\n private $paymentService: PaymentService,\r\n private devInputWithNoLoginService: DevelopmentInputWithNoLoginService,\r\n private selectListService: SelectListService,\r\n private clientService: ClientService,\r\n private dealClientService: DealClientService,\r\n private dealService: DealService,\r\n ) {\r\n // If the user is from security web, prepopulate the information\r\n if (\r\n this.$location.path().startsWith(\"/registershareholder\") ||\r\n this.$routeParams.uniqueId ||\r\n this.$location.path().startsWith(\"/bridgingregistershareholder\") ||\r\n this.$location.path().startsWith(\"/dealregistershareholder\")\r\n ) {\r\n this.isShareholderRegistration = true;\r\n\r\n if (\r\n this.$location.path().startsWith(\"/bridgingregistershareholder\") ||\r\n this.$location.path().startsWith(\"/dealregistershareholder\")\r\n ) {\r\n this.dealClientService\r\n .fetchDealClientByUniqueId(this.$routeParams.uniqueId)\r\n .then((response) => {\r\n if (response.IsVerified) {\r\n this.$location.path(\"/login\");\r\n } else {\r\n this.$user\r\n .checkUserNameExists(response.Client.Email)\r\n .then((userExists: boolean) => {\r\n if (userExists) {\r\n (this.$rootScope as any).loginRedirectPath =\r\n \"/dealsecuritycheck/\" + this.$routeParams.uniqueId;\r\n this.$location.path(\"/login\");\r\n } else {\r\n this.newUser.Email = response.Client.Email;\r\n this.newUser.FirstName = response.Client.FirstName;\r\n this.newUser.LastName = response.Client.LastName;\r\n this.newUser.PhoneNumber = response.Client.PhoneNumber;\r\n this.newUser.OrgUniqueRef = this.$routeParams.brokerOrgUniqueRef;\r\n this.newUser.DealClientUniqueRef = this.$routeParams.uniqueId;\r\n\r\n }\r\n });\r\n }\r\n });\r\n } else {\r\n this.caseMember\r\n .fetchCaseMember(this.$routeParams.uniqueId)\r\n .then((response) => {\r\n if (response.IsVerified) {\r\n this.$location.path(\"/login\");\r\n } else {\r\n this.$user\r\n .checkUserNameExists(response.Email)\r\n .then((userExists: boolean) => {\r\n if (userExists) {\r\n (this.$rootScope as any).loginRedirectPath =\r\n \"/securitycheck/\" + this.$routeParams.uniqueId;\r\n this.$location.path(\"/login\");\r\n } else {\r\n this.newUser.Email = response.Email;\r\n this.newUser.FirstName = response.FirstName;\r\n this.newUser.LastName = response.Surname;\r\n this.newUser.PhoneNumber = response.PhoneNumber;\r\n this.newUser.OrgUniqueRef =\r\n this.$routeParams.brokerOrgUniqueRef;\r\n }\r\n });\r\n }\r\n });\r\n }\r\n }\r\n\r\n // if the user is coming through this path, it is a broker invited by organisation to join it.\r\n if (this.$location.path().startsWith(\"/registerbroker\")) {\r\n this.newUser.OrgUniqueRef = this.$routeParams.uniqueRef;\r\n this.newUser.Roles = [\"Broker\", \"Introducer\"];\r\n (this.$rootScope as any).openWelcomeBrokerModal = true;\r\n //console.log((this.$rootScope as any).openWelcomeBrokerModal);\r\n }\r\n\r\n // If a broker invited the user to the platform we assign this broker org on the new user Organisation Referral Id.\r\n if (this.$location.path().startsWith(\"/registerborrower\")) {\r\n this.newUser.OrgUniqueRef = this.$routeParams[\"brokerOrgUniqueRef\"];\r\n }\r\n // if the user is coming through this path, it is a borrower wanting to view a search but they must register first\r\n else if (\r\n (this.$location.path().startsWith(\"/registerwithsearch\") &&\r\n this.$routeParams[\"brokerOrgUniqueRef\"]) ||\r\n (this.$location.path().startsWith(\"/registerwithbridgingsearch\") &&\r\n this.$routeParams[\"brokerOrgUniqueRef\"]) ||\r\n (this.$location.path().startsWith(\"/registerwithdeal\") &&\r\n this.$routeParams[\"brokerOrgUniqueRef\"])\r\n ) {\r\n this.newUser.OrgUniqueRef = this.$routeParams[\"brokerOrgUniqueRef\"];\r\n }\r\n\r\n if (\r\n (this.$location.path().startsWith(\"/registerwithbridgingsearch\") &&\r\n this.$routeParams[\"dealclientuniqueref\"]) ||\r\n (this.$location.path().startsWith(\"/registerwithdeal\") &&\r\n this.$routeParams[\"dealclientuniqueref\"])\r\n ) {\r\n this.newUser.DealClientUniqueRef =\r\n this.$routeParams[\"dealclientuniqueref\"];\r\n this.dealService\r\n .fetchProductFamilyByClientUniqueRef(\r\n this.$routeParams[\"dealclientuniqueref\"],\r\n )\r\n .then((response) => {\r\n this.productFamily = response;\r\n });\r\n }\r\n\r\n // If we have an introducer code set, let's store a cookie.\r\n if (this.$routeParams.introducercode) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"introducer_code\", this.$routeParams.introducercode, {\r\n expires: expiryDate,\r\n });\r\n } else if (this.$routeParams[\"ic\"]) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"introducer_code\", this.$routeParams[\"ic\"], {\r\n expires: expiryDate,\r\n });\r\n }\r\n\r\n if (this.$routeParams[\"orgc\"]) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"org_code\", this.$routeParams[\"orgc\"], {\r\n expires: expiryDate,\r\n });\r\n }\r\n\r\n if (\r\n !location.pathname.startsWith(\"/otmx\") &&\r\n !location.pathname.startsWith(\"/lnhn\") &&\r\n location.pathname.replace(\"/\", \"\") != null &&\r\n location.pathname.replace(\"/\", \"\").length > 0\r\n ) {\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n }\r\n\r\n if (this.$routeParams[\"invite\"]) {\r\n this.inviteGuid = this.$routeParams[\"invite\"];\r\n }\r\n\r\n this.loanCriteria = (this.$rootScope as any).loanCriteria;\r\n\r\n if (this.$routeParams.enquire !== undefined) {\r\n this.enquireAfterRegistration = true;\r\n }\r\n\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.$user.getcurentuserrecord().then((result) => {\r\n this.newUser = result;\r\n\r\n if (this.newUser.IsLegacyUser) {\r\n this.isConvertingExistingUser = true;\r\n this.newUser = result;\r\n\r\n this.newUser.Roles = [\"Client\"];\r\n\r\n this.newUser.IsOrganisationAdmin = false;\r\n this.newUser.ApplicantDefinedRole = ApplicantRoleEnum.Developer;\r\n this.newUser.ApplicantDefinedRoleIntroducer = null;\r\n } else {\r\n this.$roleService.goHomeBasedOnUser();\r\n }\r\n });\r\n } else {\r\n if (this.$routeParams[\"noLoginUniqueRef\"]) {\r\n this.redirectToSearch = true;\r\n this.devInputWithNoLoginService\r\n .fetchDataByUniqueId(this.$routeParams[\"noLoginUniqueRef\"])\r\n .then((noLoginSearchDto: DevelopmentWithNoLoginDTO) => {\r\n if (noLoginSearchDto) {\r\n if (noLoginSearchDto.IsDeleted) {\r\n this.redirectToSearch = false;\r\n sessionStorage.setItem(\"returningFromdeletedSearch\", \"true\");\r\n }\r\n this.newUser.FirstName = noLoginSearchDto.IntroduceeFirstName;\r\n this.newUser.LastName = noLoginSearchDto.IntroduceeSurname;\r\n this.newUser.Email = noLoginSearchDto.IntroduceeEmail;\r\n this.newUser.PhoneNumber = noLoginSearchDto.IntroduceePhone;\r\n }\r\n });\r\n } else if (\r\n (this.$location.path().startsWith(\"/registerwithbridgingsearch\") &&\r\n this.$routeParams[\"dealclientuniqueref\"]) ||\r\n (this.$location.path().startsWith(\"/registerwithdeal\") &&\r\n this.$routeParams[\"dealclientuniqueref\"])\r\n ) {\r\n this.redirectToSearch = true;\r\n this.clientService\r\n .fetchByDealClientUniqueRef(this.$routeParams[\"dealclientuniqueref\"])\r\n .then((clientDto: ClientDTO) => {\r\n if (clientDto) {\r\n if (clientDto.IsDeleted) {\r\n this.redirectToSearch = false;\r\n sessionStorage.setItem(\"returningFromdeletedSearch\", \"true\");\r\n }\r\n this.newUser.FirstName = clientDto.FirstName;\r\n this.newUser.LastName = clientDto.LastName;\r\n this.newUser.Email = clientDto.Email;\r\n this.newUser.PhoneNumber = clientDto.PhoneNumber;\r\n }\r\n });\r\n } else {\r\n //Grab details to prefill from lender results page\r\n this.newUser.FirstName = (this.$rootScope as any).newUserFirstName;\r\n this.newUser.LastName = (this.$rootScope as any).newUserSurname;\r\n this.newUser.Email = (this.$rootScope as any).newUserEmail;\r\n }\r\n\r\n this.newUser.ApplicantDefinedRole = (this.$rootScope as any).newUserRole;\r\n\r\n if (\r\n this.$location.path().startsWith(\"/registerbroker\") &&\r\n this.$routeParams.uniqueRef !== undefined\r\n ) {\r\n this.newUser.ApplicantDefinedRole = ApplicantRoleEnum.Introducer;\r\n this.newUser.ApplicantDefinedRoleIntroducer = 3;\r\n }\r\n\r\n if (sessionStorage.getItem(\"userDetails\")) {\r\n let data = sessionStorage.getItem(\"userDetails\");\r\n let userdetails = JSON.parse(data);\r\n\r\n let userFullName = userdetails.FullName;\r\n let spaceIndex = userFullName.indexOf(\" \");\r\n\r\n let firstName = \"\";\r\n let lastName = \"\";\r\n\r\n // if not space has been added to the name then put the whole name in the first name field\r\n if (spaceIndex == -1) {\r\n firstName = userFullName;\r\n } else {\r\n firstName = userFullName.substring(0, userFullName.indexOf(\" \"));\r\n lastName = userFullName.substring(userFullName.indexOf(\" \") + 1);\r\n }\r\n\r\n this.newUser.FirstName = firstName;\r\n this.newUser.LastName = lastName;\r\n this.newUser.Email = userdetails.Email;\r\n this.newUser.PhoneNumber = userdetails.PhoneNumber;\r\n }\r\n }\r\n\r\n if (\r\n sessionStorage.getItem(\"selectedPackage\") &&\r\n sessionStorage.getItem(\"selectedPackage\") != \"undefined\"\r\n ) {\r\n let data = sessionStorage.getItem(\"selectedPackage\");\r\n this.selectedPackage = JSON.parse(data);\r\n }\r\n\r\n this.referrerOptions = this.selectListService.GetReferrerOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n }\r\n\r\n registerAccount() {\r\n this.registeringAccount = true;\r\n this.dataLoading = true;\r\n this.isPayClicked = true;\r\n if (\r\n !this.isConvertingExistingUser &&\r\n (this.newUser as any).ConfirmPassword !== this.newUser.Password\r\n ) {\r\n this.error = \"Passwords do not match\";\r\n this.dataLoading = false;\r\n this.isPayClicked = false;\r\n } else {\r\n //If has already agreed to terms, let's set this in the new user record\r\n if ((this.$rootScope as any).lenderResultsIntroSeen === true) {\r\n this.newUser.LenderResultsTermsAgreed = true;\r\n }\r\n\r\n this.newUser.UserName = this.newUser.Email; //set user name to be same as email address for now\r\n\r\n // If we have an org code, let's set it.\r\n if (this.$cookies.get(\"org_code\")) {\r\n this.newUser.OrgCode = this.$cookies.get(\"org_code\");\r\n }\r\n // If we have an introducer code, let's set it.\r\n if (this.$cookies.get(\"introducer_code\")) {\r\n this.newUser.IntroducerCode = this.$cookies.get(\"introducer_code\");\r\n this.userRegistration();\r\n } else {\r\n this.inviteService\r\n .checkIfRegisterUserWasInvited(this.newUser.Email, this.inviteGuid)\r\n .then((result) => {\r\n this.newUser.IntroducerCode = result;\r\n this.userRegistration();\r\n });\r\n }\r\n }\r\n }\r\n\r\n userRegistration() {\r\n // send registration\r\n\r\n var broker = this.newUser.Roles.filter((x) => x == \"Broker\");\r\n\r\n // Register Broker User\r\n if (broker != null && broker.length > 0) {\r\n this.organizationService\r\n .registerBroker(this.newUser, this.newUser.OrgUniqueRef)\r\n .then((user) => {\r\n this.login(user);\r\n })\r\n .catch((response) => {\r\n this.error = response.data.Message;\r\n this.registeringAccount = false;\r\n this.dataLoading = false;\r\n })\r\n .finally(() => {\r\n this.registeringAccount = false;\r\n });\r\n } else {\r\n if (this.inviteGuid != null && this.inviteGuid.length > 0) {\r\n this.newUser.InviteCode = this.inviteGuid;\r\n }\r\n\r\n // Register Client User\r\n this.$user\r\n .addUpdateWithOrgUniqueRef(this.newUser)\r\n .then((user) => {\r\n // clean up session storage\r\n sessionStorage.removeItem(\"userDetails\");\r\n sessionStorage.removeItem(\"clientId\");\r\n sessionStorage.removeItem(\"userRole\");\r\n sessionStorage.removeItem(\"projectname\");\r\n\r\n if (\r\n this.$cookies.get(\"access_token\") &&\r\n this.isConvertingExistingUser\r\n ) {\r\n // clear and reset cached data based on the new information\r\n this.$auth.getProfile().then((response) => {\r\n this.$cookies.put(\"user_firstname\", response.FirstName);\r\n (this.$rootScope as any).selectedUser = response;\r\n });\r\n\r\n (this.$rootScope as any).selectedUser = null;\r\n (this.$rootScope as any).currentUser = null;\r\n\r\n this.$roleService.GetUserRoles(true); //reset user roles\r\n\r\n sessionStorage.setItem(\"isUpgradedUser\", \"true\");\r\n\r\n this.onRegistrationComplete();\r\n } else if (!this.$cookies.get(\"access_token\")) {\r\n this.login(user);\r\n } else {\r\n this.error = \"logged in but not converting an existing user\";\r\n this.registeringAccount = false;\r\n this.dataLoading = false;\r\n }\r\n })\r\n .catch((response) => {\r\n this.error = response.data.Message;\r\n this.registeringAccount = false;\r\n this.dataLoading = false;\r\n })\r\n .finally(() => {\r\n this.registeringAccount = false;\r\n });\r\n }\r\n }\r\n\r\n login(user: ApplicationUserDTO) {\r\n (this.$rootScope as any).selectedUser = user;\r\n if (!this.$cookies.get(\"access_token\")) {\r\n this.$auth\r\n .login(\r\n this.newUser.Email,\r\n this.newUser.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n this.$user.getcurentuserrecord().then((response) => {\r\n (this.$rootScope as any).currentUser = response;\r\n });\r\n\r\n let expiry: Date = response;\r\n\r\n this.$cookies.put(\"user_firstname\", user.FirstName, {\r\n expires: expiry,\r\n });\r\n\r\n if (\r\n (this.$location.path().indexOf(\"/registerwithsearch\") !== -1 &&\r\n this.$routeParams[\"noLoginUniqueRef\"]) ||\r\n (this.$location.path().indexOf(\"/registerwithbridgingsearch\") !==\r\n -1 &&\r\n this.$routeParams[\"dealclientuniqueref\"]) ||\r\n (this.$location.path().indexOf(\"/registerwithdeal\") !== -1 &&\r\n this.$routeParams[\"dealclientuniqueref\"])\r\n ) {\r\n if (this.$routeParams[\"noLoginUniqueRef\"]) {\r\n var url =\r\n \"/referredSearch/\" + this.$routeParams[\"noLoginUniqueRef\"];\r\n if (\r\n this.$routeParams[\"brokerOrgUniqueRef\"] &&\r\n this.$routeParams[\"brokerUserId\"]\r\n ) {\r\n url +=\r\n \"/\" +\r\n this.$routeParams[\"brokerOrgUniqueRef\"] +\r\n \"/\" +\r\n this.$routeParams[\"brokerUserId\"];\r\n }\r\n } else if (this.$routeParams[\"searchId\"]) {\r\n var url = \"/bridgingresults/\" + this.$routeParams[\"searchId\"];\r\n if (\r\n this.$routeParams[\"brokerOrgUniqueRef\"] &&\r\n this.$routeParams[\"brokerUserId\"]\r\n ) {\r\n url +=\r\n \"/\" +\r\n this.$routeParams[\"brokerOrgUniqueRef\"] +\r\n \"/\" +\r\n this.$routeParams[\"brokerUserId\"];\r\n }\r\n } else if (this.$routeParams[\"dealclientuniqueref\"]) {\r\n switch (this.productFamily) {\r\n case ProductFamilyEnum.Bridging:\r\n var url =\r\n \"/referredsearchdeal/\" +\r\n this.$routeParams[\"dealclientuniqueref\"];\r\n break;\r\n case ProductFamilyEnum.Commercial:\r\n var url =\r\n \"/referredsearchcommercial/\" +\r\n this.$routeParams[\"dealclientuniqueref\"];\r\n break;\r\n case ProductFamilyEnum.Development:\r\n var url =\r\n \"/referredsearchdevfinance/\" +\r\n this.$routeParams[\"dealclientuniqueref\"];\r\n break;\r\n default:\r\n var url =\r\n \"/referredsearchdeal/\" +\r\n this.$routeParams[\"dealclientuniqueref\"];\r\n break;\r\n }\r\n //if (this.$routeParams['brokerOrgUniqueRef'] && this.$routeParams['brokerUserId']) {\r\n // url += \"/\" + this.$routeParams['brokerOrgUniqueRef'] + \"/\" + this.$routeParams['brokerUserId'];\r\n //}\r\n }\r\n\r\n if (this.redirectToSearch) {\r\n this.$location.path(url);\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n } else if (\r\n this.loanCriteria &&\r\n !(\r\n this.loanCriteria.CI_Dev_OrigPP == 0 &&\r\n this.loanCriteria.CI_EndPropType == 0 &&\r\n this.loanCriteria.CI_GDV == 0 &&\r\n this.loanCriteria.CI_Dev_LoanReq == 0\r\n )\r\n ) {\r\n if (this.selectedPackage) {\r\n this.selectedProductList.push(this.selectedPackage);\r\n this.createCheckoutSession();\r\n } else {\r\n this.loanCriteria.UserId = user.Id;\r\n this.loanCriteria.User = user;\r\n this.loanCriteria.SaveQueryAndResults = true;\r\n var lenderName: string = \"\";\r\n if (this.selectedResult != null) {\r\n lenderName = this.selectedResult.LenderName;\r\n this.loanLabel = this.selectedResult.LoanLabel;\r\n }\r\n\r\n this.$lenderresultservice\r\n .fetchMatchingResults(\r\n this.loanCriteria,\r\n true,\r\n true,\r\n 4,\r\n false,\r\n \"\",\r\n user.Email,\r\n user.PhoneNumber,\r\n lenderName,\r\n )\r\n .then((response) => {\r\n if (this.loanCriteria.SaveCase === true) {\r\n //case creation\r\n this.$CaseService\r\n .promotesearchtocase(\r\n response.Id,\r\n (this.$rootScope as any)\r\n .selectedResultForAttachingToCase.Id,\r\n (this.$rootScope as any).productResultList,\r\n )\r\n .then((response) => {\r\n this.$location.path(\"/userdashboard\");\r\n });\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n });\r\n }\r\n } else if (this.$routeParams.uniqueId) {\r\n if (\r\n this.$location\r\n .path()\r\n .startsWith(\"/bridgingregistershareholder\") ||\r\n this.$location.path().startsWith(\"/dealregistershareholder\")\r\n ) {\r\n this.$location.path(\r\n \"/dealsecuritycheck/\" + this.$routeParams.uniqueId,\r\n );\r\n } else {\r\n this.$location.path(\r\n \"/securitycheck/\" + this.$routeParams.uniqueId,\r\n );\r\n }\r\n } else if (\r\n this.$location.path().indexOf(\"/startprojectappraisal\") !== -1\r\n ) {\r\n this.createNewBlankCase();\r\n } else if (this.$location.path().indexOf(\"/applyfordevloan\") !== -1) {\r\n this.createNewBlankCase(true);\r\n } else {\r\n this.onRegistrationComplete();\r\n }\r\n\r\n if (this.enquireAfterRegistration) {\r\n // Send enquiry and pop up?\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.$auth\r\n .getProfile()\r\n .then((response) => {\r\n this.$roleService.goHomeBasedOnUser();\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n onRegistrationComplete() {\r\n if (this.selectedPackage) {\r\n this.selectedProductList.push(this.selectedPackage);\r\n this.createCheckoutSession();\r\n } else {\r\n if (this.redirectToSearch) {\r\n var url = \"/referredSearch/\" + this.$routeParams[\"noLoginUniqueRef\"];\r\n if (\r\n this.$routeParams[\"brokerOrgUniqueRef\"] &&\r\n this.$routeParams[\"brokerUserId\"]\r\n ) {\r\n url +=\r\n \"/\" +\r\n this.$routeParams[\"brokerOrgUniqueRef\"] +\r\n \"/\" +\r\n this.$routeParams[\"brokerUserId\"];\r\n }\r\n\r\n this.$location.path(url);\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n }\r\n }\r\n\r\n change() {\r\n if (!this.isConvertingExistingUser) {\r\n if ((this.newUser as any).ConfirmPassword === this.newUser.Password) {\r\n this.passworderror = \"\";\r\n } else {\r\n this.passworderror = \"Passwords do not match\";\r\n }\r\n }\r\n }\r\n\r\n emailChange() {\r\n if (this.error) {\r\n this.error = \"\";\r\n }\r\n }\r\n\r\n clearRegistration() {\r\n this.registeringAccount = false;\r\n }\r\n\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n\r\n createNewBlankCase(applyForDevLoan: boolean = false) {\r\n this.$auth.getProfile().then((prof) => {\r\n var currentUser: ApplicationUserDTO = prof;\r\n this.$roleService.GetUserRoles().then((result) => {\r\n var isPrimaryApplicant: boolean = true;\r\n\r\n if (result.filter((x) => x == \"Broker\").length > 0) {\r\n isPrimaryApplicant = false;\r\n }\r\n\r\n this.caseService\r\n .newBlankCase(currentUser, isPrimaryApplicant)\r\n .then((newBlankCaseDto) => {\r\n // If applying for a development loan then go to the case dashboard of the new case\r\n if (applyForDevLoan == true) {\r\n this.$location.path(\r\n \"/casedashboard/\" + newBlankCaseDto.NewCaseId,\r\n );\r\n } else {\r\n // If starting a project appraisal then go directly to the appraisal module of the new case\r\n this.$location.path(\r\n \"/criteriaappraisal/\" +\r\n newBlankCaseDto.NewCaseId +\r\n \"/\" +\r\n newBlankCaseDto.NewSearchId,\r\n );\r\n }\r\n });\r\n });\r\n });\r\n }\r\n\r\n fillRegisterForm() {\r\n let name = new Date().toLocaleString().replace(/ |,|:|\\/|/g, \"\");\r\n this.newUser.Email = `${name}@test.com`;\r\n this.newUser.FirstName = name;\r\n this.newUser.LastName = \"t\";\r\n this.newUser.PhoneNumber = \"12345677\";\r\n this.newUser.Location = 1;\r\n this.newUser.ApplicantDefinedRole = 0;\r\n this.newUser.Referrer = 1;\r\n this.newUser.Password = \"test\";\r\n (this.newUser as any).ConfirmPassword = \"test\";\r\n }\r\n\r\n next() {\r\n this.step++;\r\n }\r\n\r\n back() {\r\n this.step--;\r\n }\r\n\r\n changeProfileLogo(files) {\r\n if (files.length > 0) {\r\n this.fileAttachmentService\r\n .uploadFileAndReturnURI(files)\r\n .then((result) => {\r\n if (result) {\r\n this.newUser.ProfilePictureUrl = result.FileLocation;\r\n this.getLogoURL(this.newUser.ProfilePictureUrl);\r\n }\r\n });\r\n }\r\n }\r\n\r\n getLogoURL(url: string) {\r\n this.fileAttachmentService.getFileUri(url).then((result) => {\r\n this.profileLogo = result;\r\n //console.log(this.profileLogo);\r\n });\r\n }\r\n\r\n isFirstStepValid() {\r\n if (\r\n !this.registrationFormStep1.$invalid &&\r\n !(\r\n this.newUser.Referrer == ReferrerEnum.Other &&\r\n this.newUser.ReferrerOther == null\r\n )\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n isSecondStepValid() {\r\n if (\r\n !this.registrationFormStep2.$invalid &&\r\n this.newUser.AgreedToTermsAndPP === true &&\r\n !this.passworderror &&\r\n !this.registeringAccount &&\r\n !this.dataLoading\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n createCheckoutSession() {\r\n //this.selectedProductList[0].SelectedModuleAppFeature = this.moduleAppFeatures;\r\n // Need to save the search so we can get back to it after payment ($rootscope will lose the data)\r\n if ((this.$rootScope as any).loanCriteria != null) {\r\n (this.$rootScope as any).loanCriteria.UserId = (\r\n this.$rootScope as any\r\n ).selectedUser.Id;\r\n (this.$rootScope as any).loanCriteria.BrokerOrganisationId = (\r\n this.$rootScope as any\r\n ).selectedUser.OrganisationId;\r\n this.developmentInputService\r\n .saveSearch((this.$rootScope as any).loanCriteria)\r\n .then((developmentInputId: number) => {\r\n this.$paymentService\r\n .createCheckoutSession(\r\n this.selectedPackage,\r\n 1,\r\n \"\",\r\n developmentInputId,\r\n )\r\n .then((response) => {\r\n window.location.assign(response.SessionUrl);\r\n });\r\n });\r\n } else {\r\n this.$paymentService\r\n .createCheckoutSession(this.selectedPackage, 1, \"\", null)\r\n .then((response) => {\r\n window.location.assign(response.SessionUrl);\r\n });\r\n }\r\n }\r\n\r\n cancelCheckout() {\r\n if ((this.$rootScope as any).loanCriteria) {\r\n this.$location.path(\"/results\");\r\n } else {\r\n this.$location.path(\"/userdashboard\");\r\n }\r\n }\r\n\r\n getApplicationName() {\r\n if (sessionStorage.getItem(\"applicationName\") != null) {\r\n return sessionStorage.getItem(\"applicationName\");\r\n } else {\r\n return \"Brickflow\";\r\n }\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { IntroducerDTO } from \"@js/DTO/IntroducerDTO.cs.d\";\r\nimport { IntroducerSimpleDTO } from \"@js/DTO/IntroducerSimpleDTO.cs.d\";\r\nimport { ApplicantRoleEnum } from \"@js/models/enum/ApplicantRoleEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { IntroducerService } from \"@js/services/IntroducerService\";\r\nimport { IntroducerSimpleService } from \"@js/services/IntroducerSimpleService\";\r\nimport { LenderResultService } from \"@js/services/LenderResultService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class RegistrationIntroducerController {\r\n user: ApplicationUserDTO;\r\n introducerSimple: IntroducerSimpleDTO;\r\n introducer: IntroducerDTO;\r\n\r\n registeredAccount: boolean;\r\n registeringAccount: boolean;\r\n registrationForm: FormData;\r\n error: string;\r\n passworderror: string;\r\n\r\n isIntroducer: boolean = false;\r\n adminUser: boolean = false;\r\n SendNewUserEmail: boolean = false;\r\n\r\n newUser: ApplicationUserDTO = {\r\n Id: \"\",\r\n Roles: [\"Introducer\"],\r\n } as ApplicationUserDTO;\r\n\r\n newIntroducer: IntroducerDTO = {} as IntroducerDTO;\r\n\r\n referrerOptions = [];\r\n locationOptions = [];\r\n\r\n static $inject = [\r\n \"CaseService\",\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"$httpParamSerializerJQLike\",\r\n \"LenderResultService\",\r\n \"UserService\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n \"IntroducerService\",\r\n \"IntroducerSimpleService\",\r\n \"$q\",\r\n \"SelectListService\",\r\n ];\r\n\r\n constructor(\r\n private $CaseService: CaseService,\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private $httpParamSerializerJQLike: ng.IHttpParamSerializer,\r\n private $lenderresultservice: LenderResultService,\r\n private $user: UserService,\r\n private $auth: AuthService,\r\n private $roleService: RoleService,\r\n private introducerService: IntroducerService,\r\n private $introducerSimpleService: IntroducerSimpleService,\r\n private $q: ng.IQService,\r\n private selectListService: SelectListService,\r\n ) {\r\n // If we have an introducer code set, let's store a cookie.\r\n if (this.$routeParams.introducercode) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"introducer_code\", this.$routeParams.introducercode, {\r\n expires: expiryDate,\r\n });\r\n } else if (this.$routeParams[\"ic\"]) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"introducer_code\", this.$routeParams[\"ic\"], {\r\n expires: expiryDate,\r\n });\r\n }\r\n\r\n if (this.$routeParams[\"orgc\"]) {\r\n var expiryDate = new Date();\r\n expiryDate.setDate(expiryDate.getDate() + 100);\r\n this.$cookies.put(\"org_code\", this.$routeParams[\"orgc\"], {\r\n expires: expiryDate,\r\n });\r\n }\r\n // Determine whether or not the user is logged in.\r\n if ($cookies.get(\"access_token\")) {\r\n this.$auth.getProfile().then((response) => {\r\n this.newIntroducer.UserId = response.Id;\r\n this.user = response;\r\n\r\n this.$roleService.GetRolesIamAMemberOf().then((roles) => {\r\n this.user.Roles = roles;\r\n if (this.user.Roles.find((r) => r === \"Introducer\")) {\r\n this.isIntroducer = true;\r\n }\r\n });\r\n this.$roleService.isBrokerOrABove().then((response) => {\r\n this.adminUser = response;\r\n this.introducerService\r\n .getIntroducerDetailsByUserId(this.user.Id)\r\n .then((response) => {\r\n this.introducerSimple = response;\r\n this.introducer = response;\r\n });\r\n });\r\n });\r\n }\r\n\r\n this.referrerOptions = this.selectListService.GetReferrerOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n }\r\n\r\n doLogin(user: ApplicationUserDTO): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$auth\r\n .login(\r\n this.newUser.Email,\r\n this.newUser.Password,\r\n \"CC022EBE67BE0424EA2A6548B062D2D71\",\r\n )\r\n .then((response) => {\r\n let expiry: Date = response;\r\n this.$cookies.put(\"user_firstname\", user.FirstName, {\r\n expires: expiry,\r\n });\r\n (this.$rootScope as any).selectedUser = user;\r\n defer.resolve(true);\r\n })\r\n .catch((response) => {\r\n defer.reject(false);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n registerIntroducer(isRegisteringCurrentUser: boolean): void {\r\n this.registeringAccount = true;\r\n\r\n if ((this.newUser as any).ConfirmPassword !== this.newUser.Password) {\r\n this.error = \"Passwords do not match\";\r\n } else {\r\n //If we are registering a logged in user, set existing user details to go down update route\r\n if (\r\n (this.user && isRegisteringCurrentUser) ||\r\n (this.user && !this.isIntroducer && !this.adminUser)\r\n ) {\r\n this.newUser = this.user;\r\n this.registerIntroducerByUserId(this.user.Id);\r\n } else {\r\n // If we have an org code, let's set it.\r\n if (this.$cookies.get(\"org_code\")) {\r\n this.newUser.OrgCode = this.$cookies.get(\"org_code\");\r\n }\r\n var introduceeId = null;\r\n if (this.isIntroducer && !isRegisteringCurrentUser) {\r\n // Get id of introducee\r\n this.newUser.IntroducerId = this.introducerSimple.Id;\r\n this.newUser.IntroducerCode = this.introducer.IntroducerCode;\r\n introduceeId = this.user.Id;\r\n } else if (\r\n !this.user &&\r\n (isRegisteringCurrentUser == undefined ||\r\n isRegisteringCurrentUser == true)\r\n ) {\r\n // If we have an introducer code, let's set it.\r\n if (this.$cookies.get(\"introducer_code\")) {\r\n this.newUser.IntroducerCode = this.$cookies.get(\"introducer_code\");\r\n }\r\n }\r\n\r\n this.newUser.UserName = this.newUser.Email; //set user name to be same as email address for now\r\n // This is the fix for BF-1244\r\n this.newUser.ApplicantDefinedRole = ApplicantRoleEnum.Introducer;\r\n this.newUser.ApplicantDefinedRoleIntroducer =\r\n this.newIntroducer.IntroducerType;\r\n // send registration\r\n this.$user\r\n .addUpdate(this.newUser)\r\n .then((user) => {\r\n (this.$rootScope as any).selectedUser = user;\r\n\r\n //If this is a new user\r\n if (!this.user) {\r\n this.doLogin(user).then((loginSuccess) => {\r\n // Register introducer\r\n this.registerIntroducerByUserId(user.Id);\r\n });\r\n } else {\r\n // Register another person as introducer\r\n this.registerAnotherIntroducerByUserId(\r\n user.Id,\r\n introduceeId,\r\n this.SendNewUserEmail,\r\n );\r\n }\r\n })\r\n .catch((response) => {\r\n this.error =\r\n \"It looks like there was a problem registering. \" +\r\n response.data.Message;\r\n this.registeringAccount = false;\r\n })\r\n .finally(() => {});\r\n }\r\n }\r\n }\r\n\r\n registerIntroducerByUserId(userId: string): void {\r\n this.newIntroducer.UserId = userId;\r\n this.introducerService\r\n .registerIntroducer(this.newIntroducer)\r\n .then((success) => {\r\n //this.$auth.logout();\r\n //this.go(\"/introducer/new\");\r\n this.go(\"/userdashboard/0/\");\r\n })\r\n .catch((error) => {\r\n this.error =\r\n \"It looks like there was a problem registering you as an introducer. Please try again in a moment.\";\r\n })\r\n .finally(() => {\r\n this.registeringAccount = false;\r\n });\r\n }\r\n\r\n registerAnotherIntroducerByUserId(\r\n userId: string,\r\n introduceeId: string,\r\n sendNewUserEmail: boolean,\r\n ): void {\r\n this.newIntroducer.UserId = userId;\r\n var sendEmail = false;\r\n if (sendNewUserEmail) {\r\n sendEmail = true;\r\n }\r\n\r\n this.introducerService\r\n .registerAnotherIntroducer(this.newIntroducer, introduceeId, sendEmail)\r\n .then((success) => {\r\n this.go(\"/userdashboard\");\r\n })\r\n .catch((error) => {\r\n this.error =\r\n \"It looks like there was a problem registering you as an introducer. Please try again in a moment.\";\r\n })\r\n .finally(() => {\r\n this.registeringAccount = false;\r\n });\r\n }\r\n\r\n change() {\r\n if ((this.newUser as any).ConfirmPassword === this.newUser.Password) {\r\n this.passworderror = \"\";\r\n } else {\r\n this.passworderror = \"Passwords do not match\";\r\n }\r\n }\r\n\r\n go(path): void {\r\n this.$location.path(path);\r\n }\r\n\r\n emailChange() {\r\n if (this.error) {\r\n this.error = \"\";\r\n }\r\n }\r\n}\r\n","import { PageWithTotalCountDTO } from \"@js/DTO/PageWithTotalCountDTO.cs.d\";\r\nimport { RoleDTO } from \"@js/DTO/RoleDTO.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\n\r\nexport class RoleController {\r\n roles: PageWithTotalCountDTO;\r\n selectedRole: RoleDTO;\r\n\r\n page: number = 1;\r\n rolepageid: any;\r\n roleFilter: string;\r\n countperpage: number = 10;\r\n\r\n loadingRoles: boolean;\r\n error: boolean;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private $auth: AuthService,\r\n private $role: RoleService,\r\n ) {\r\n this.loadingRoles = true;\r\n this.setPage(1);\r\n }\r\n\r\n setPage(newPage: number): void {\r\n this.loadingRoles = true;\r\n this.page = newPage;\r\n this.$role\r\n .fetchpage(this.roleFilter, this.page, this.countperpage)\r\n .then((response) => {\r\n this.roles = response;\r\n this.loadingRoles = false;\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n this.loadingRoles = false;\r\n });\r\n }\r\n\r\n addNewRole(): void {\r\n this.selectedRole = {\r\n Id: \"\",\r\n Name: \"\",\r\n } as RoleDTO;\r\n }\r\n\r\n formChanged(): void {\r\n (this.$rootScope as any).formSaved = false;\r\n }\r\n\r\n saveRole(): void {\r\n this.$role\r\n .addUpdate(this.selectedRole)\r\n .then((response) => {\r\n if (response) {\r\n if (!this.selectedRole.Id) {\r\n this.setPage(this.page);\r\n }\r\n delete this.selectedRole;\r\n } else {\r\n this.error = true;\r\n }\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n });\r\n }\r\n\r\n deleteRole(): void {\r\n this.$role\r\n .delete(this.selectedRole.Name)\r\n .then((response) => {\r\n if (response) {\r\n this.roles.List.splice(this.roles.List.indexOf(this.selectedRole), 1);\r\n delete this.selectedRole;\r\n } else {\r\n this.error = true;\r\n }\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n });\r\n }\r\n}\r\n","import { SecurityQuestionEnum } from \"@js/models/enum/SecurityQuestionEnum.cs.d\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\n\r\nexport class SecurityCheckController {\r\n dateOfBirth: Date;\r\n email: string;\r\n phone: string;\r\n postcode: string;\r\n answers: number;\r\n error: boolean = false;\r\n\r\n securityValidation: ng.IFormController;\r\n maxDateOfBirth: Date = new Date();\r\n minDateOfBirth: Date = new Date(\"Jan 01 1900\");\r\n uniqueId: string;\r\n showDob: boolean = false;\r\n showPhone: boolean = false;\r\n showPostCode: boolean = false;\r\n\r\n orgUniqueRef: string;\r\n brokerUserId: string;\r\n\r\n static $inject = [\"$routeParams\", \"$location\", \"CaseMemberService\"];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private $applicantservice: CaseMemberService,\r\n ) {\r\n this.uniqueId = this.$routeParams.uniqueId;\r\n if (this.$routeParams.orgUniqueRef && this.$routeParams.brokerUserId) {\r\n this.orgUniqueRef = this.$routeParams.orgUniqueRef;\r\n this.brokerUserId = this.$routeParams.brokerUserId;\r\n }\r\n\r\n if (this.uniqueId) {\r\n this.$applicantservice\r\n .fetchCaseMemberAndReturnEmail(this.uniqueId)\r\n .then((response) => {\r\n this.email = response;\r\n });\r\n\r\n this.$applicantservice\r\n .getSecurityQuestions(this.$routeParams.uniqueId)\r\n .then((response) => {\r\n var securityQuestions = parseInt(response) as SecurityQuestionEnum;\r\n\r\n this.showDob =\r\n SecurityQuestionEnum.DateOfBirth ===\r\n (securityQuestions & SecurityQuestionEnum.DateOfBirth);\r\n this.showPostCode =\r\n SecurityQuestionEnum.PostCode ===\r\n (securityQuestions & SecurityQuestionEnum.PostCode);\r\n this.showPhone =\r\n SecurityQuestionEnum.PhoneNumber ===\r\n (securityQuestions & SecurityQuestionEnum.PhoneNumber);\r\n });\r\n }\r\n }\r\n\r\n isValidAnswer() {\r\n this.answers = 0;\r\n\r\n if (this.dateOfBirth) {\r\n this.answers++;\r\n }\r\n\r\n if (this.phone) {\r\n this.answers++;\r\n }\r\n\r\n if (this.postcode) {\r\n this.answers++;\r\n }\r\n\r\n if (\r\n this.answers >= 2 &&\r\n this.securityValidation.$valid &&\r\n !this.securityValidation.$pristine\r\n ) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n }\r\n\r\n send() {\r\n if (this.uniqueId) {\r\n this.$applicantservice\r\n .securityCheck(\r\n this.uniqueId,\r\n this.phone ? this.phone : null,\r\n this.postcode ? this.postcode : null,\r\n this.dateOfBirth ? this.dateOfBirth : null,\r\n this.orgUniqueRef,\r\n this.brokerUserId,\r\n )\r\n .then((i) => {\r\n var targeturl = this.$location.search().targeturl;\r\n\r\n if (targeturl) {\r\n this.$location.search({});\r\n this.$location.path(targeturl);\r\n } else {\r\n this.$location.path(i);\r\n }\r\n })\r\n .catch(() => {\r\n this.error = true;\r\n });\r\n }\r\n }\r\n}\r\n","export class TermsOfBusinessController {\r\n orgCode: string;\r\n\r\n static $inject = [\"$routeParams\", \"$scope\", \"$location\"];\r\n\r\n constructor(\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $scope: ng.IScope,\r\n private $location: ng.ILocationService,\r\n ) {\r\n document.getElementById(\"header\").style.display = \"none\";\r\n\r\n this.orgCode = location.pathname.replace(\"/\", \"\");\r\n }\r\n}\r\n","import { AddressHistoryDTO } from \"@js/DTO/AddressHistoryDTO.cs.d\";\r\nimport { AddressLookupDTO } from \"@js/DTO/AddressLookupDTO.cs.d\";\r\nimport { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { CaseMemberDTO } from \"@js/DTO/CaseMemberDTO.cs.d\";\r\nimport { DevelopmentTrackRecordDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentTrackRecordDTO.cs.d\";\r\nimport { ProjectOwnershipDTO } from \"@js/DTO/DevelopmentFinance/ProjectOwnershipDTO.cs.d\";\r\nimport { FileAttachmentDTO } from \"@js/DTO/FileAttachmentDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { DevelopmentTrackRecordTypeEnum } from \"@js/models/enum/DevelopmentTrackRecordTypeEnum.cs.d\";\r\nimport { ModuleEnum } from \"@js/models/enum/ModuleEnum.cs.d\";\r\nimport { PostalAddress } from \"@js/models/PostalAddress.cs.d\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DevelopmentExperienceService } from \"@js/services/DevelopmentExperienceService\";\r\nimport { DevelopmentTrackRecordService } from \"@js/services/DevelopmentTrackRecordService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { StreetAddressService } from \"@js/services/StreetAddressService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class TrackRecordController {\r\n //case id\r\n caseid: number;\r\n\r\n development: ProjectOwnershipDTO;\r\n developmentTrackRecordType: {}[] = [];\r\n\r\n //navigate for pages\r\n step: number = 3;\r\n applicantNo: number = 0;\r\n devexperienceId: number;\r\n\r\n //current case\r\n case: CaseDTO;\r\n caseTitle: string;\r\n\r\n //user\r\n selectedUser: ApplicationUserDTO;\r\n\r\n //share shareholder\r\n shareContext: number = null;\r\n shareSuplId: number = null;\r\n userFirstName: string;\r\n shareNote: string;\r\n shareFirstName: string;\r\n shareSurname: string;\r\n shareEmail: string;\r\n showShare: boolean = false;\r\n\r\n saving: boolean = false;\r\n saved: boolean = false;\r\n error: boolean = false;\r\n dataLoading: boolean = false;\r\n\r\n //calculations\r\n total: number = 0;\r\n\r\n //modal\r\n message: string = \"\";\r\n modal: boolean = false;\r\n openModal: boolean = false;\r\n\r\n owners: CaseMemberDTO[];\r\n currentApplicant: CaseMemberDTO;\r\n\r\n //files\r\n fileUpload: FileAttachmentDTO[];\r\n uploadingFiles: FileUploadProgressDTO[];\r\n thisModuleSection: ModuleEnum = ModuleEnum.ApplicantDetails;\r\n\r\n //forms\r\n multiPartForm4: ng.IFormController;\r\n multiPartForm7: ng.IFormController;\r\n\r\n //address\r\n previousAddressSearchTerm: string;\r\n searchingForPreviousAddress: boolean = false;\r\n previousAddressPostCodeOptions: PostalAddress[] = [];\r\n showAddHistoryConfirmDelete: boolean = false;\r\n addressHistoryIdToDelete: number;\r\n showAddressHistoryModal: boolean = false;\r\n shareholderAddressHistory: AddressHistoryDTO[] = [];\r\n addressHistoryItem: AddressHistoryDTO;\r\n previousAddressSearchResults: string[];\r\n searchpostcode: string[];\r\n searchterm: string[];\r\n searchresults: string[];\r\n PostCodeOptions: PostalAddress[][] = [];\r\n searchingForAddress: boolean = false;\r\n\r\n //current shareholder\r\n currentShareholder: CaseMemberDTO;\r\n\r\n formattedAcquisitionDate: any[] = [];\r\n\r\n caseMembersWithAccess: CaseMemberDTO[];\r\n selectedClientToShareWith: CaseMemberDTO;\r\n\r\n static $inject = [\r\n \"$location\",\r\n \"RoleService\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"StreetAddressService\",\r\n \"DevelopmentTrackRecordService\",\r\n \"CaseMemberService\",\r\n \"DevelopmentExperienceService\",\r\n \"$routeParams\",\r\n \"CaseService\",\r\n \"FileAttachmentService\",\r\n \"$window\",\r\n \"UserService\",\r\n \"$scope\",\r\n ];\r\n\r\n constructor(\r\n private $location: ng.ILocationService,\r\n private roleService: RoleService,\r\n private $rootScope: ng.IRootScopeService,\r\n protected $q: ng.IQService,\r\n private streetAddressService: StreetAddressService,\r\n private developmenttrackrecordservice: DevelopmentTrackRecordService,\r\n private caseMemberService: CaseMemberService,\r\n private developmentexperienceservice: DevelopmentExperienceService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private caseService: CaseService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private $window: ng.IWindowService,\r\n private userService: UserService,\r\n private $scope: ng.IScope,\r\n ) {\r\n this.developmentexperienceservice\r\n .fetch(this.$routeParams.Id)\r\n .then((response) => {\r\n this.devexperienceId = this.$routeParams.Id;\r\n this.development = response;\r\n /* if (localStorage.getItem('DevelopmentTrackRecords')) {\r\n var data = localStorage.getItem('DevelopmentTrackRecords');\r\n if (data.length > 0) {\r\n var localStorageDevelopmentTrackRecords = JSON.parse(data);\r\n var n = this.development.DevelopmentTrackRecords.length;\r\n\r\n while (n != localStorageDevelopmentTrackRecords.length && localStorageDevelopmentTrackRecords.length > 0) {\r\n this.development.DevelopmentTrackRecords.push(localStorageDevelopmentTrackRecords[n]);\r\n n = this.development.DevelopmentTrackRecords.length;\r\n }\r\n } \r\n }*/\r\n\r\n //Update track record development types#\r\n this.initDevelopmentTrackRecordTypes();\r\n });\r\n\r\n if (this.$routeParams.ApplicantNo) {\r\n this.currentApplicant = this.owners[this.$routeParams.ApplicantNo];\r\n }\r\n\r\n if (this.$routeParams.CaseId) {\r\n this.caseid = this.$routeParams.CaseId;\r\n\r\n this.caseService.fetch(this.caseid).then((result) => {\r\n this.case = result;\r\n this.caseTitle = result.DevelopmentInput.SearchName;\r\n this.fileUpload = result.Attachments;\r\n });\r\n }\r\n\r\n this.userService.getcurentuserrecord().then((result) => {\r\n this.selectedUser = result;\r\n });\r\n\r\n /* $scope.$on('$locationChangeStart', (event: ng.IAngularEvent) => {\r\n localStorage.setItem('DevelopmentTrackRecords', JSON.stringify(this.development.DevelopmentTrackRecords));\r\n });*/\r\n }\r\n\r\n onFileSelect(files: FileAttachmentDTO[], moduleSelected?: string) {\r\n var module = ModuleEnum.DeveloperProfile;\r\n\r\n if (moduleSelected === \"Ownership\") {\r\n module = ModuleEnum.DeveloperProfile;\r\n } else if (moduleSelected === \"Stack\") {\r\n module = ModuleEnum.Track;\r\n } else if (moduleSelected === \"Assets\") {\r\n module = ModuleEnum.AssetsLiabilities;\r\n } else if ((moduleSelected = \"ProofIncome\")) {\r\n module = ModuleEnum.ProofOfIncome;\r\n }\r\n\r\n if (files.length > 0) {\r\n //if case has no id it must be saved first\r\n if (this.caseid < 1) {\r\n this.caseService\r\n .addUpdate(this.case)\r\n .then((response) => {\r\n this.case = response;\r\n this.onFileSelect(files, moduleSelected); //call itself and then exit as should now be saved so should be able to run\r\n return;\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n this.openModal = false;\r\n });\r\n return;\r\n }\r\n\r\n this.dataLoading = true;\r\n this.fileAttachmentService\r\n .UploadFileLstInSync(\r\n files,\r\n this.uploadingFiles,\r\n this.case.Id,\r\n this.fileUpload,\r\n module,\r\n )\r\n .finally(() => {\r\n //this.calculateFilesForThisModule();\r\n this.openModal = false;\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n downloadFile(file: FileAttachmentDTO) {\r\n this.dataLoading = true;\r\n this.fileAttachmentService\r\n .getFileUri(file.FileLocation)\r\n .then((uri) => {\r\n this.$window.open(uri);\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n deleteFile(file: FileAttachmentDTO) {\r\n this.fileUpload.splice(this.fileUpload.indexOf(file), 1);\r\n this.fileAttachmentService.markasdeleted(file.Id).then((result) => {});\r\n }\r\n\r\n calculateTotalFiles(filter: number) {\r\n if (this.fileUpload) {\r\n this.total = this.fileUpload.filter(\r\n (item) => item.Module === filter,\r\n ).length;\r\n }\r\n return this.total;\r\n }\r\n\r\n goToCaseDashboard(blockSave?: boolean): void {\r\n if (this.roleService.IsLender == true) {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n } else {\r\n if (blockSave) {\r\n this.save(true).then((response) => {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n (this.$rootScope as any).formSaved = true;\r\n });\r\n } else {\r\n this.save(false).then(() => {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n });\r\n }\r\n }\r\n }\r\n\r\n //save\r\n save(isFormComplete: boolean): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.saving = true;\r\n\r\n this.caseMemberService\r\n .addUpdatereturnonlyid(this.currentApplicant)\r\n .then((response) => {\r\n this.setAllFormsPristine();\r\n defer.resolve(response as number);\r\n return response;\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n this.error = true;\r\n })\r\n .finally(() => {\r\n this.saving = false;\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n formatDate(unformattedDate) {\r\n if (unformattedDate) {\r\n var formattedDate = new Date(\r\n unformattedDate.getTime() - unformattedDate.getTimezoneOffset() * 60000,\r\n )\r\n .toISOString()\r\n .split(\"T\")[0];\r\n\r\n return formattedDate;\r\n }\r\n }\r\n\r\n getAddressList(app: CaseMemberDTO, index: number, searchTerm: string) {\r\n let foundMatch = false;\r\n\r\n if (\r\n this.PostCodeOptions &&\r\n this.PostCodeOptions[index] &&\r\n this.PostCodeOptions[index].length > 0\r\n ) {\r\n let addressLookup = this.PostCodeOptions[index].find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n\r\n // We've selected an address!\r\n this.streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n this.currentShareholder.StreetAddress = address;\r\n this.searchterm[index] = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n this.currentShareholder.StreetAddress.AddressLine1 =\r\n addressLookup.AddressLine2;\r\n this.currentShareholder.StreetAddress.AddressLine2 =\r\n addressLookup.AddressLine3;\r\n this.currentShareholder.StreetAddress.AddressLine3 =\r\n addressLookup.AddressLine4;\r\n this.currentShareholder.StreetAddress.AddressLine4 =\r\n addressLookup.PostCode;\r\n this.currentShareholder.StreetAddress.PostCode =\r\n addressLookup.AddressLine1;\r\n this.searchterm[index] = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n // Initial search term\r\n this.PostCodeOptions[index] = [];\r\n\r\n this.streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.PostCodeOptions[index] = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n saveDev(): void {\r\n this.saving = true;\r\n\r\n if (\r\n this.development.DevelopmentTrackRecords === null ||\r\n !this.development.DevelopmentTrackRecords\r\n ) {\r\n this.development.DevelopmentTrackRecords = [];\r\n }\r\n\r\n //add a new one\r\n\r\n let newDevelopmentTrackRecord = {\r\n DevelopmentTrackRecordNumber:\r\n this.development.DevelopmentTrackRecords.length + 1,\r\n DevelopmentExperienceId: this.development.Id,\r\n AreaUnit: 1,\r\n DevelopmentTrackRecordType: null,\r\n StreetAddress: {\r\n AddressLine1: \"\",\r\n AddressLine2: \"\",\r\n AddressLine3: \"\",\r\n AddressLine4: \"\",\r\n PostCode: \"\",\r\n } as PostalAddress,\r\n } as DevelopmentTrackRecordDTO;\r\n\r\n this.development.DevelopmentTrackRecords.push(newDevelopmentTrackRecord);\r\n\r\n this.formattedAcquisitionDate.forEach((d, index) => {\r\n this.development.DevelopmentTrackRecords[index].AcquistionDate = d;\r\n });\r\n\r\n this.developmenttrackrecordservice\r\n .addUpdatelistreturnonlyids(this.development.DevelopmentTrackRecords)\r\n .then((response) => {\r\n //update IDs\r\n this.development.DevelopmentTrackRecords.forEach((x, index) => {\r\n x.Id = response[index];\r\n });\r\n\r\n this.setAllFormsPristine();\r\n this.saved = true;\r\n })\r\n .catch((error) => {\r\n this.error = true;\r\n })\r\n .finally(() => {\r\n this.saving = false;\r\n });\r\n }\r\n\r\n //resent forms\r\n setAllFormsPristine(): void {\r\n if (this.multiPartForm4) {\r\n this.multiPartForm4.$setPristine();\r\n }\r\n if (this.multiPartForm7) {\r\n this.multiPartForm7.$setPristine();\r\n }\r\n }\r\n\r\n removeDevelopment(item: DevelopmentTrackRecordDTO) {\r\n if (item.Id > 0) {\r\n this.developmenttrackrecordservice\r\n .markasdeleted(item.Id)\r\n .then((response) => {\r\n if (response) {\r\n this.development.DevelopmentTrackRecords.splice(\r\n this.development.DevelopmentTrackRecords.indexOf(item),\r\n 1,\r\n );\r\n this.formattedAcquisitionDate.splice(\r\n this.development.DevelopmentTrackRecords.indexOf(item),\r\n 1,\r\n );\r\n }\r\n });\r\n } else {\r\n //never saved so just remove\r\n this.development.DevelopmentTrackRecords.splice(\r\n this.development.DevelopmentTrackRecords.indexOf(item),\r\n 1,\r\n );\r\n }\r\n }\r\n\r\n back(): void {\r\n if (this.step > 1) {\r\n this.step--;\r\n this.go(\r\n \"/devexperience/\" +\r\n this.caseid +\r\n \"/\" +\r\n this.devexperienceId +\r\n \"/\" +\r\n this.step,\r\n );\r\n (this.$rootScope as any).formSaved = this.roleService.IsLender;\r\n } else if (this.step <= 1) {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n }\r\n }\r\n\r\n getAddressListArray(app: CaseMemberDTO, index: number, searchTerm: string) {\r\n let foundMatch = false;\r\n\r\n if (\r\n this.PostCodeOptions &&\r\n this.PostCodeOptions[index] &&\r\n this.PostCodeOptions[index].length > 0\r\n ) {\r\n let addressLookup = this.PostCodeOptions[index].find((add) => {\r\n return add.AddressLine1 + \" \" + add.AddressLine2 === searchTerm;\r\n });\r\n\r\n if (addressLookup && !(addressLookup as AddressLookupDTO).IsPostCode) {\r\n foundMatch = true;\r\n\r\n // We've selected an address!\r\n this.streetAddressService\r\n .getFullAddress((addressLookup as AddressLookupDTO).Id)\r\n .then((address) => {\r\n app.StreetAddress = address;\r\n this.searchterm[index] = \"\";\r\n });\r\n } else if (\r\n addressLookup &&\r\n (addressLookup as AddressLookupDTO).IsPostCode\r\n ) {\r\n foundMatch = true;\r\n this.development.DevelopmentTrackRecords[\r\n index\r\n ].StreetAddress.AddressLine1 = addressLookup.AddressLine2;\r\n this.development.DevelopmentTrackRecords[\r\n index\r\n ].StreetAddress.AddressLine2 = addressLookup.AddressLine3;\r\n this.development.DevelopmentTrackRecords[\r\n index\r\n ].StreetAddress.AddressLine3 = addressLookup.AddressLine4;\r\n this.development.DevelopmentTrackRecords[\r\n index\r\n ].StreetAddress.AddressLine4 = addressLookup.PostCode;\r\n this.development.DevelopmentTrackRecords[index].StreetAddress.PostCode =\r\n addressLookup.AddressLine1;\r\n this.searchterm[index] = \"\";\r\n }\r\n }\r\n\r\n if (searchTerm.length >= 3 && !foundMatch) {\r\n this.searchingForAddress = true;\r\n // Initial search term\r\n this.PostCodeOptions[index] = [];\r\n\r\n this.streetAddressService\r\n .getAddressList(searchTerm)\r\n .then((response) => {\r\n this.PostCodeOptions[index] = response;\r\n })\r\n .finally(() => {\r\n this.searchingForAddress = false;\r\n });\r\n }\r\n }\r\n\r\n initDevelopmentTrackRecordTypes() {\r\n this.development.DevelopmentTrackRecords.forEach((r, index) => {\r\n this.developmentTrackRecordType[index] = {};\r\n for (let i = 1; i >= 0; i *= 2) {\r\n if (r.DevelopmentTrackRecordType >= i) {\r\n //number is in enum sum, add it to object\r\n if (r.DevelopmentTrackRecordType & i) {\r\n this.developmentTrackRecordType[index][i] = true;\r\n }\r\n } else {\r\n return;\r\n }\r\n }\r\n });\r\n }\r\n\r\n updateDevelopmentTrackRecordTypes(\r\n index: number,\r\n item: DevelopmentTrackRecordTypeEnum,\r\n ) {\r\n //if we are setting item to false and item exists, remove it, else add it\r\n if (\r\n this.developmentTrackRecordType[index][item] === true &&\r\n !!!(\r\n this.development.DevelopmentTrackRecords[index]\r\n .DevelopmentTrackRecordType & item\r\n )\r\n ) {\r\n this.development.DevelopmentTrackRecords[\r\n index\r\n ].DevelopmentTrackRecordType += item;\r\n } else {\r\n this.development.DevelopmentTrackRecords[\r\n index\r\n ].DevelopmentTrackRecordType -= item;\r\n }\r\n }\r\n\r\n trackRecordFinish(): void {\r\n this.developmenttrackrecordservice\r\n .addUpdatelistreturnonlyids(this.development.DevelopmentTrackRecords)\r\n .then((response) => {\r\n this.$location.path(\"/casedashboard/\" + this.caseid);\r\n (this.$rootScope as any).formSaved = true;\r\n });\r\n }\r\n\r\n go(path): void {\r\n // Only need to save if user is NOT a lender (everything is in read-only mode for lender)\r\n if (this.roleService.IsLender == true) {\r\n this.$location.path(path);\r\n } else {\r\n this.save(false).then((response) => {\r\n this.devexperienceId = response;\r\n this.$location.path(path);\r\n });\r\n }\r\n }\r\n\r\n openSendToBorrower() {\r\n this.dataLoading = false;\r\n this.shareContext = 11;\r\n this.shareSuplId = this.devexperienceId;\r\n if (this.selectedUser.UserName !== this.case.DevelopmentInput.OwnerUser) {\r\n this.userFirstName = \"\";\r\n } else {\r\n this.userFirstName = this.selectedUser.FirstName;\r\n }\r\n\r\n var message = `Please take a look to the track record. \\n\\nIf you need my help or want me to complete this information with you on a call, then please contact me as soon as possible.`;\r\n\r\n this.shareNote =\r\n `Dear ${\r\n this.shareFirstName != null ? this.shareFirstName + \",\" : \" \" + \",\"\r\n }\\n\\n` + message;\r\n\r\n this.caseMemberService\r\n .fetchcasememberswithaccess(this.case.Id)\r\n .then((response: CaseMemberDTO[]) => {\r\n this.caseMembersWithAccess = response;\r\n\r\n this.showShare = true;\r\n });\r\n }\r\n\r\n sendToBorrower() {\r\n this.dataLoading = true;\r\n this.caseService\r\n .sendNoteToBorrower(\r\n this.selectedClientToShareWith.FirstName,\r\n this.selectedClientToShareWith.Surname,\r\n this.selectedClientToShareWith.Email,\r\n this.shareNote,\r\n this.case.Id,\r\n this.shareContext,\r\n this.shareSuplId,\r\n this.case.DevelopmentExperienceID,\r\n )\r\n .then((success) => {\r\n this.showShare = false;\r\n this.dataLoading = false;\r\n this.selectedClientToShareWith = null;\r\n });\r\n }\r\n\r\n isShareNoteFormComplete(): boolean {\r\n if (!this.selectedClientToShareWith) {\r\n return false;\r\n }\r\n\r\n if (\r\n this.shareNote == \"undefined\" ||\r\n this.shareNote == null ||\r\n this.shareNote.length == 0\r\n ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AppPackagePricingDTO } from \"@js/DTO/AppPackagePricingDTO.cs.d\";\r\nimport { FileUploadProgressDTO } from \"@js/DTO/FileUploadProgressDTO.cs.d\";\r\nimport { IntroducerDTO } from \"@js/DTO/IntroducerDTO.cs.d\";\r\nimport { IntroducerSimpleDTO } from \"@js/DTO/IntroducerSimpleDTO.cs.d\";\r\nimport { LenderDTO } from \"@js/DTO/LenderDTO.cs.d\";\r\nimport { OrganisationDTO } from \"@js/DTO/OrganisationDTO.cs.d\";\r\nimport { PageWithTotalCountDTO } from \"@js/DTO/PageWithTotalCountDTO.cs.d\";\r\nimport { RoleDTO } from \"@js/DTO/RoleDTO.cs.d\";\r\nimport { LenderProductTypeEnum } from \"@js/models/enum/LenderProductTypeEnum.cs.d\";\r\nimport { AccountSettingService } from \"@js/services/AccountSettingsService\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { FileAttachmentService } from \"@js/services/FIleAttachmentService\";\r\nimport { IntroducerService } from \"@js/services/IntroducerService\";\r\nimport { IntroducerSimpleService } from \"@js/services/IntroducerSimpleService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { PaymentService } from \"@js/services/PaymentService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\n\r\nexport class UserController {\r\n users: PageWithTotalCountDTO;\r\n roles: RoleDTO[];\r\n selectedUser: ApplicationUserDTO;\r\n selectedRole: string = \"\";\r\n uploadingFiles: FileUploadProgressDTO[];\r\n imagePath: string[];\r\n organisations: OrganisationDTO[];\r\n organisationName: string;\r\n\r\n userForm: ng.IFormController;\r\n page: number = 1;\r\n pageid: any;\r\n userFilter: string = \"\";\r\n countperpage: number = 10;\r\n introduceClientModal: number = null;\r\n unique: string;\r\n isBroker: boolean = false;\r\n isLender: boolean = false;\r\n isSelectedUserAdmin: boolean = false;\r\n\r\n introducersList: IntroducerSimpleDTO[];\r\n\r\n currentItemRoleSet: RoleDTO[];\r\n newIntroducer: IntroducerDTO = {} as IntroducerDTO;\r\n\r\n loadingRoles: boolean;\r\n loadingUsers: boolean;\r\n error: boolean;\r\n errorMessage: { user: ApplicationUserDTO; deleteAllWarning: boolean } =\r\n {} as { user: ApplicationUserDTO; deleteAllWarning: boolean };\r\n allActiveAppPackagePrices: AppPackagePricingDTO[];\r\n assignLicense: boolean = true;\r\n selectedProductList: AppPackagePricingDTO[] = [];\r\n licenseEndDate: Date;\r\n message: string;\r\n licenseStatusText: string;\r\n testEmailBody: string = \"This is a test email.\";\r\n testEmailSub: string = \"Test email\";\r\n testEmails: string;\r\n showTestEmailModal: boolean = false;\r\n onSendTestEmailClick: boolean = false;\r\n\r\n referrerOptions = [];\r\n locationOptions = [];\r\n\r\n hasLenderrole: boolean = false;\r\n lenderUserProductType: {}[] = [];\r\n lenders: LenderDTO[];\r\n assignedLenderUsers: ApplicationUserDTO[];\r\n singleLenderAdminError: string = \"\";\r\n\r\n noLicenseToAssignForAdminMessage: string;\r\n\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"$http\",\r\n \"AuthService\",\r\n \"UserService\",\r\n \"RoleService\",\r\n \"DevelopmentInputService\",\r\n \"IntroducerService\",\r\n \"CaseService\",\r\n \"FileAttachmentService\",\r\n \"OrganisationService\",\r\n \"IntroducerSimpleService\",\r\n \"PaymentService\",\r\n \"SelectListService\",\r\n \"AccountSettingService\",\r\n \"LenderService\",\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private $http: ng.IHttpService,\r\n private $auth: AuthService,\r\n private $user: UserService,\r\n private $role: RoleService,\r\n private $DevelopmentInputservice: DevelopmentInputService,\r\n private introducerService: IntroducerService,\r\n private caseService: CaseService,\r\n private fileAttachmentService: FileAttachmentService,\r\n private organisationService: OrganisationService,\r\n private introducerSimpleService: IntroducerSimpleService,\r\n private $paymentService: PaymentService,\r\n private selectListService: SelectListService,\r\n private $accountSettingService: AccountSettingService,\r\n private $lenderservice: LenderService,\r\n ) {\r\n this.loadRoles();\r\n this.currentItemRoleSet = [];\r\n this.setPage(1);\r\n this.imagePath = [];\r\n $user.fileSelected = \"img/BrickFlow_Logo_RGB_Blue.svg\";\r\n\r\n //bring all organisations\r\n this.organisationService.fetchAll().then((response) => {\r\n this.organisations = response;\r\n });\r\n\r\n this.getIntroducerUser();\r\n\r\n this.referrerOptions = this.selectListService.GetReferrerOptions();\r\n this.locationOptions = this.selectListService.GetLocations();\r\n }\r\n\r\n clearIntroducer() {\r\n this.selectedUser.IntroducerId = null;\r\n }\r\n\r\n userOpportunityById(userId: number) {\r\n this.organisationService.fetchAll().then((response) => {\r\n const found = response.find((organisation) => organisation.Id === userId);\r\n if (found) {\r\n return (this.organisationName = found.Name);\r\n } else {\r\n return (this.organisationName = \"None\");\r\n }\r\n });\r\n }\r\n\r\n formChanged(): void {\r\n (this.$rootScope as any).formSaved = false;\r\n }\r\n\r\n loadRoles(): void {\r\n this.$role\r\n .fetchAll()\r\n .then((response) => {\r\n this.roles = response.filter((role) => role.Name !== \"None\");\r\n this.loadingRoles = false;\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n this.loadingRoles = false;\r\n });\r\n }\r\n getgroups(): void {\r\n this.currentItemRoleSet = [];\r\n this.roles.forEach((item: RoleDTO) => {\r\n (item as any).ticked = false;\r\n this.selectedUser.Roles.forEach((role: string) => {\r\n if (role == item.Name) {\r\n this.currentItemRoleSet.push(item); //put them in the output object in case not edited\r\n (item as any).ticked = true;\r\n }\r\n });\r\n if (this.selectedUser.IsIntroducer) {\r\n this.getIntroducerDetailsByUserId();\r\n }\r\n });\r\n }\r\n\r\n getIntroducerUser() {\r\n this.introducerSimpleService.fetchAll().then((result) => {\r\n this.introducersList = result;\r\n });\r\n }\r\n\r\n setgroups(): void {\r\n this.selectedUser.Roles = [];\r\n this.currentItemRoleSet.forEach((item: RoleDTO) => {\r\n this.selectedUser.Roles.push(item.Name);\r\n });\r\n }\r\n\r\n isUserBroker() {\r\n this.isBroker =\r\n this.selectedUser.Roles.find((role) => role === \"Broker\") !== undefined;\r\n }\r\n\r\n isUserAdmin() {\r\n this.isSelectedUserAdmin =\r\n this.selectedUser.Roles.find((role) => role === \"Admin\") !== undefined;\r\n }\r\n\r\n isUserLender() {\r\n this.isLender =\r\n this.selectedUser.Roles.find((role) => role === \"Lender\") !== undefined;\r\n }\r\n\r\n setPage(newPage: number): void {\r\n this.loadingUsers = true;\r\n this.page = newPage;\r\n this.$user\r\n .fetchpage(\r\n this.userFilter,\r\n this.page,\r\n this.countperpage,\r\n this.selectedRole,\r\n )\r\n .then((response) => {\r\n this.users = response;\r\n this.loadingUsers = false;\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n this.loadingUsers = false;\r\n });\r\n }\r\n\r\n prevPage(): void {\r\n this.setPage(this.page - 1);\r\n }\r\n\r\n nextPage(): void {\r\n this.setPage(this.page + 1);\r\n }\r\n\r\n addNewUser(): void {\r\n this.hasLenderrole = false;\r\n this.isSelectedUserAdmin = false;\r\n this.userForm.$setPristine();\r\n this.currentItemRoleSet = [];\r\n this.selectedUser = { ShowAutofill: true } as ApplicationUserDTO;\r\n this.lenderUserProductType = [];\r\n this.selectedUser.Roles = [\"Client\"];\r\n this.getgroups();\r\n }\r\n\r\n saveUser(): void {\r\n var validUser = true;\r\n this.error = false;\r\n this.singleLenderAdminError = null;\r\n\r\n if (isNaN(this.selectedUser.IntroducerId)) {\r\n this.selectedUser.IntroducerId = null;\r\n }\r\n\r\n this.setgroups();\r\n if (this.selectedUser.Id == null) {\r\n this.selectedUser.Id = \"\";\r\n }\r\n if (!this.selectedUser.UserName) {\r\n this.selectedUser.UserName = this.selectedUser.Email; //set user name to be same as email address for now\r\n }\r\n\r\n if (\r\n this.hasLenderrole &&\r\n !this.selectedUser.IsLenderAdmin &&\r\n this.selectedUser.LenderId != null\r\n ) {\r\n let lenderAdmin = this.assignedLenderUsers.find(\r\n (l) => l.IsLenderAdmin && l.Id != this.selectedUser.Id,\r\n );\r\n if (!lenderAdmin) {\r\n this.singleLenderAdminError = `Please assign a new Admin User.`;\r\n this.error = true;\r\n validUser = false;\r\n }\r\n }\r\n\r\n if (validUser) {\r\n this.$user\r\n .addUpdate(this.selectedUser)\r\n .then((response) => {\r\n if (response) {\r\n if (!this.selectedUser.Id) {\r\n this.setPage(this.page);\r\n }\r\n // Fetching a user data again to make sure to get a updated data for previous lenderAdmin.\r\n if (this.selectedUser.IsLenderAdmin) {\r\n this.setPage(1);\r\n }\r\n\r\n delete this.selectedUser;\r\n (this.$rootScope as any).formSaved = true;\r\n } else {\r\n this.error = true;\r\n }\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n if (response.data?.ExceptionMessage == \"No license to assign.\") {\r\n this.selectedUser.IsOrganisationAdmin = false;\r\n this.noLicenseToAssignForAdminMessage =\r\n \"There isn't an available license to assign to this user therefore they have not been assigned as the admin for the organisation.\";\r\n }\r\n });\r\n }\r\n }\r\n\r\n deleteUser(): void {\r\n this.$user\r\n .markasdeleted(this.selectedUser.UserName)\r\n .then((response) => {\r\n if (response) {\r\n this.users.List.splice(this.users.List.indexOf(this.selectedUser), 1);\r\n delete this.selectedUser;\r\n } else {\r\n this.error = true;\r\n }\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n });\r\n }\r\n\r\n registerIntroducerByUserId(userId: string, sendEmail: boolean = true): void {\r\n this.newIntroducer.UserId = userId;\r\n this.introducerService\r\n .registerIntroducer(this.newIntroducer, sendEmail)\r\n .then((success) => {\r\n this.selectedUser.IsIntroducer = true;\r\n this.selectedUser.IntroducerCode = success.IntroducerCode;\r\n this.message = \"Selected user has been converted to Introducer\";\r\n this.introduceClientModal = 2;\r\n this.getIntroducerUser();\r\n })\r\n .catch((error) => {\r\n this.error = true;\r\n });\r\n }\r\n\r\n sendLinkToUser() {\r\n this.introducerService\r\n .sendLinkToUser(\r\n this.selectedUser.FirstName,\r\n this.selectedUser.Email,\r\n this.selectedUser.Id,\r\n )\r\n .then((success) => {\r\n this.introduceClientModal = 4;\r\n });\r\n }\r\n\r\n copyLinkToClipboard() {\r\n this.introducerService\r\n .copyLinkToClipboard(this.selectedUser.Id)\r\n .then((response) => {\r\n this.unique = response.toString();\r\n navigator.clipboard.writeText(this.unique);\r\n this.introduceClientModal = 5;\r\n });\r\n }\r\n\r\n getIntroducerDetailsByUserId() {\r\n this.introducerService\r\n .getIntroducerDetailsByUserId(this.selectedUser.Id)\r\n .then((response) => {\r\n this.selectedUser.IntroducerCode = response.IntroducerCode;\r\n });\r\n }\r\n\r\n extrasettings = {\r\n displayProp: \"Name\",\r\n smartButtonMaxItems: 3,\r\n smartButtonTextConverter: function (itemText: string, originalItem: any) {\r\n return originalItem.Name;\r\n },\r\n scrollable: true,\r\n selectedToTop: true,\r\n enableSearch: true,\r\n };\r\n\r\n checkIntroducerrole(data) {\r\n if (data.Name == \"Introducer\" && data.ticked) {\r\n this.introduceClientModal = 6;\r\n }\r\n\r\n if (data.Name == \"Lender\") {\r\n if (data.ticked == true) {\r\n this.hasLenderrole = true;\r\n this.selectedUser.SendLenderInsightsEmail = true;\r\n this.getAllLenders();\r\n } else {\r\n this.hasLenderrole = false;\r\n this.selectedUser.LenderId = null;\r\n this.selectedUser.IsLenderAdmin = false;\r\n this.selectedUser.LenderProductTypes = 0;\r\n this.selectedUser.SendLenderInsightsEmail = false;\r\n }\r\n }\r\n\r\n if (data.Name == \"Broker\") {\r\n this.isBroker = !this.isBroker;\r\n }\r\n\r\n if (data.Name == \"Admin\") {\r\n this.isSelectedUserAdmin = !this.isSelectedUserAdmin;\r\n }\r\n }\r\n\r\n getActivePackagePricingsForTrialLicense() {\r\n this.allActiveAppPackagePrices = [];\r\n this.$paymentService\r\n .getActivePackagePricingsForTrialLicense(this.selectedUser.UserName)\r\n .then((response) => {\r\n this.allActiveAppPackagePrices = response;\r\n })\r\n .finally(() => {\r\n this.assignLicense = !this.assignLicense;\r\n });\r\n }\r\n\r\n getLicenseStatusText() {\r\n this.allActiveAppPackagePrices = [];\r\n this.$user\r\n .getLicenseStatusText(this.selectedUser.UserName)\r\n .then((response) => {\r\n this.licenseStatusText = response;\r\n });\r\n }\r\n\r\n onSelectingUser(user) {\r\n this.hasLenderrole = false;\r\n this.selectedUser = user;\r\n this.singleLenderAdminError = \"\";\r\n this.noLicenseToAssignForAdminMessage = \"\";\r\n this.hasLenderrole =\r\n this.selectedUser.Roles.find((role) => role === \"Lender\") !== undefined;\r\n if (this.hasLenderrole) {\r\n this.getAllLenders();\r\n this.initLenderUserProductType();\r\n if (this.selectedUser.LenderId) {\r\n this.fetchAllLenderUsers(this.selectedUser.LenderId);\r\n }\r\n }\r\n this.getgroups();\r\n this.isUserBroker();\r\n this.isUserAdmin();\r\n this.isUserLender();\r\n this.getLicenseStatusText();\r\n }\r\n\r\n onChangingPackage(selectedPackage) {\r\n if (\r\n this.selectedProductList != null &&\r\n this.selectedProductList.length > 0\r\n ) {\r\n var found = this.selectedProductList.find(function (product) {\r\n return product.Id == selectedPackage.Id;\r\n });\r\n\r\n if (found) {\r\n this.selectedProductList = this.selectedProductList.filter(\r\n function (e) {\r\n return e.Id != selectedPackage.Id;\r\n },\r\n );\r\n } else {\r\n this.selectedProductList.push(selectedPackage);\r\n }\r\n } else {\r\n this.selectedProductList.push(selectedPackage);\r\n }\r\n }\r\n\r\n assignLicenseToUser() {\r\n this.$user\r\n .assigTrialLicenseToUser(\r\n this.selectedProductList,\r\n this.licenseEndDate,\r\n this.selectedUser.Id,\r\n )\r\n .then((response) => {\r\n if (response) {\r\n this.message = `Trial license has been assigned to ${this.selectedUser.FullName}`;\r\n this.introduceClientModal = 2;\r\n this.allActiveAppPackagePrices = [];\r\n } else {\r\n this.message = `Problem while assigning trial license, please try after some time.`;\r\n this.introduceClientModal = 2;\r\n }\r\n });\r\n }\r\n\r\n goToSettingPage() {\r\n this.$location.path(`/settings/${this.selectedUser.Id}`);\r\n }\r\n\r\n sendTestEmail(): void {\r\n this.$user\r\n .sendTestEmail(this.selectedUser.Email, this.testEmailSub, this.testEmailBody)\r\n .then((response: boolean) => {\r\n if (response) {\r\n this.message = `Test email has been sent to ${this.selectedUser.FullName}`;\r\n this.showTestEmailModal = false;\r\n this.introduceClientModal = 2;\r\n } else {\r\n this.error = true;\r\n }\r\n })\r\n .catch((response) => {\r\n this.error = true;\r\n });\r\n }\r\n\r\n initLenderUserProductType() {\r\n if (!this.selectedUser.LenderProductTypes) {\r\n this.selectedUser.LenderProductTypes = 0;\r\n } else {\r\n for (let i = 1; i >= 0; i *= 2) {\r\n if (this.selectedUser.LenderProductTypes >= i) {\r\n //number is in enum sum, add it to object\r\n if (this.selectedUser.LenderProductTypes & i) {\r\n this.lenderUserProductType[i] = true;\r\n } else {\r\n this.lenderUserProductType[i] = false;\r\n }\r\n } else {\r\n return;\r\n }\r\n }\r\n }\r\n }\r\n\r\n updateLenderUserProductTypes(item: LenderProductTypeEnum) {\r\n this.selectedUser.LenderProductTypes =\r\n this.selectedUser.LenderProductTypes > 0\r\n ? this.selectedUser.LenderProductTypes\r\n : 0;\r\n if (item == LenderProductTypeEnum.All) {\r\n if (this.lenderUserProductType[item] == false) {\r\n this.selectedUser.LenderProductTypes -= item;\r\n } else {\r\n this.lenderUserProductType.forEach((value, index) => {\r\n this.lenderUserProductType[index] = false;\r\n });\r\n\r\n this.selectedUser.LenderProductTypes = 0;\r\n\r\n this.lenderUserProductType[item] = true;\r\n this.selectedUser.LenderProductTypes += item;\r\n }\r\n } else {\r\n //if we are setting item to false and item exists, remove it, else add it\r\n if (this.lenderUserProductType[item] === true) {\r\n this.selectedUser.LenderProductTypes += item;\r\n } else if (this.selectedUser.LenderProductTypes > 0) {\r\n this.selectedUser.LenderProductTypes -= item;\r\n }\r\n }\r\n }\r\n\r\n getAllLenders() {\r\n this.$lenderservice.fetchAll().then((response) => {\r\n this.lenders = response;\r\n });\r\n }\r\n\r\n isLenderUserProductTypeEmpty() {\r\n if (this.lenderUserProductType.length === 0) return true;\r\n\r\n for (let i = 0; i < this.lenderUserProductType.length; i++) {\r\n let value = this.lenderUserProductType[i];\r\n if (value !== undefined && value !== null && value !== false) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n fetchAllLenderUsers(lenderId) {\r\n this.$user.getUsersByLenderId(lenderId).then((response) => {\r\n this.assignedLenderUsers = response;\r\n });\r\n }\r\n\r\n onIsLenderAdminChange() {\r\n if (\r\n !this.selectedUser.IsLenderAdmin &&\r\n this.hasLenderrole &&\r\n this.selectedUser.Id\r\n ) {\r\n let selectedUserFrom = this.assignedLenderUsers.find(\r\n (l) => l.Id == this.selectedUser.Id,\r\n );\r\n let lenderAdmin = this.assignedLenderUsers.find(\r\n (l) => l.IsLenderAdmin && l.Id != this.selectedUser.Id,\r\n );\r\n if (selectedUserFrom?.IsLenderAdmin && !lenderAdmin) {\r\n this.singleLenderAdminError = `Please assign a new Admin User.`;\r\n }\r\n } else if (this.selectedUser.IsLenderAdmin) {\r\n this.singleLenderAdminError = \"\";\r\n }\r\n }\r\n\r\n onExpandingAssignTrialLicense() {\r\n if (this.assignLicense) {\r\n this.getActivePackagePricingsForTrialLicense();\r\n } else {\r\n this.assignLicense = !this.assignLicense;\r\n }\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { CaseSummaryDTO } from \"@js/DTO/CaseSummaryDTO.cs.d\";\r\nimport { ClientDTO } from \"@js/DTO/ClientDTO.cs.d\";\r\nimport { ShareDealDTO } from \"@js/DTO/Deal/SearchDealDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport { InviteDTO } from \"@js/DTO/InviteDTO.cs.d\";\r\nimport { LicenseMasterDTO } from \"@js/DTO/LicenseMasterDTO.cs.d\";\r\nimport { UserSimpleDTO } from \"@js/DTO/UserSimpleDTO.cs.d\";\r\nimport { CaseAccessLevelEnum } from \"@js/models/enum/CaseAccessLevelEnum.cs.d\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { LenderProductTypeEnum } from \"@js/models/enum/LenderProductTypeEnum.cs.d\";\r\nimport { LicenseMasterStatusEnum } from \"@js/models/enum/LicenseMasterStatusEnum.cs.d\";\r\nimport { ProductTypeEnum } from \"@js/models/enum/ProductTypeEnum.cs.d\";\r\nimport { StatusEnum } from \"@js/models/enum/StatusEnum.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseLenderService } from \"@js/services/CaseLenderService\";\r\nimport { CaseMemberService } from \"@js/services/CaseMemberService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { CaseSummaryService } from \"@js/services/CaseSummaryService\";\r\nimport { ClientService } from \"@js/services/ClientService\";\r\nimport { BridgingDealService } from \"@js/services/Deal/BridgingDealService\";\r\nimport { DealLenderMessageService } from \"@js/services/Deal/DealLenderMessageService\";\r\nimport { DealLenderService } from \"@js/services/Deal/DealLenderService\";\r\nimport { DealService } from \"@js/services/Deal/DealService\";\r\nimport { DevelopmentInputService } from \"@js/services/DevelopmentInputService\";\r\nimport { DevelopmentInputWithNoLoginService } from \"@js/services/DevelopmentInputWithNoLoginService\";\r\nimport { IntroducerService } from \"@js/services/IntroducerService\";\r\nimport { InviteService } from \"@js/services/InviteService\";\r\nimport { LenderService } from \"@js/services/LenderService\";\r\nimport { LicenseService } from \"@js/services/LicenseService\";\r\nimport { OrganisationService } from \"@js/services/OrganisationService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\nimport { SelectListService } from \"@js/services/SelectListService\";\r\nimport { TaskItemService } from \"@js/services/TaskItemService\";\r\nimport { UserDashboardService } from \"@js/services/UserDashboardService\";\r\nimport { UserService } from \"@js/services/UserService\";\r\nimport { SharedDataService } from \"@js/services/SharedDataService\";\r\nimport { EventLogService } from \"@js/services/EventLogService\";\r\nimport { EventLogEnum } from \"@js/models/enum/EventLogEnum.cs.d\";\r\n\r\n\r\nexport class UserDashboardController {\r\n isPageLoading: boolean = false;\r\n isCardView: boolean = true;\r\n\r\n cardWithOpenMenu = {\r\n id: null,\r\n };\r\n\r\n isSearchesLoading: boolean = false;\r\n searches: CaseSummaryDTO[];\r\n\r\n isDevFinanceProjectsLoading: boolean = false;\r\n isBridgingPreConProjectsLoading: boolean = false;\r\n isCommercialProjectsLoading: boolean = false;\r\n isAllProjectsLoading: boolean = false;\r\n projects: CaseSummaryDTO[];\r\n\r\n actionItem: CaseSummaryDTO;\r\n\r\n confirmSearchToDelete: boolean;\r\n confirmProjectToDelete: boolean;\r\n\r\n confirmCopyProjectName: boolean;\r\n newProjectName: string;\r\n\r\n currentUser: ApplicationUserDTO;\r\n hasEnterpriseLicense: boolean;\r\n\r\n //Share search\r\n newSearch: boolean = false;\r\n isResultScreen: boolean = true;\r\n existingborrower: number = null;\r\n showClientDetails: boolean = false;\r\n existingUsers: UserSimpleDTO[];\r\n clientId: string = null;\r\n loanCriteria: DevelopmentInputDTO;\r\n displayMsg: string;\r\n sharedSearch: boolean = false;\r\n showShareResults: number;\r\n isBridging: boolean = false;\r\n\r\n shareDealDto: ShareDealDTO;\r\n\r\n NavMenuEnum = {\r\n Home: 0,\r\n DevelopmentFinance: 1,\r\n BridgingFinance: 2,\r\n Clients: 3,\r\n CommercialMortgages: 4,\r\n EquityAndMezz: 5\r\n };\r\n\r\n selectedNavMenu: number;\r\n\r\n DashboardTypeEnum = {\r\n Home: 0,\r\n Searches: 1,\r\n Projects: 2,\r\n Introductions: 3,\r\n };\r\n\r\n selectedDashboardType: number;\r\n\r\n //isNewSearchSelect: boolean;\r\n\r\n homeScreenCount: number = 3;\r\n\r\n isAdmin: boolean = false;\r\n isBroker: boolean = false;\r\n isLender: boolean = false;\r\n isBorrower: boolean = false;\r\n isIntroducer: boolean = false;\r\n\r\n shareSearchModal: number = null;\r\n shareSearchErrorDisplayed: boolean = false;\r\n\r\n // Introducer variables\r\n introduceClientModal: number = null;\r\n clientFirstName: string;\r\n clientSurname: string;\r\n clientEmail: string;\r\n clientPhoneNumber: string;\r\n\r\n isProcessingSend: boolean = false;\r\n\r\n invite: InviteDTO;\r\n invitedUsers: InviteDTO[] = [];\r\n\r\n introducedUsers: ApplicationUserDTO[];\r\n\r\n savedIntroducedSearches: DevelopmentInputDTO[] = [];\r\n unsavedIntroducedSearches: DevelopmentInputDTO[] = [];\r\n\r\n clientAdminTools: boolean = false;\r\n userSearchResults: ApplicationUserDTO[];\r\n\r\n selectedUser: ApplicationUserDTO;\r\n selecteduserName: string;\r\n //viewAsClientUserName: string;\r\n viewAsClientFirstName: string;\r\n selectedClientName: string;\r\n //TODO - these need to be related to the enums and moved into a \"LookupService\" so that we're only defining them once\r\n locations: Array<{ id: number; value: string }> = [\r\n { id: 0, value: \"Any\" },\r\n { id: 1, value: \"London\" },\r\n { id: 2, value: \"North West\" },\r\n { id: 4, value: \"Midlands\" },\r\n { id: 8, value: \"East of England\" },\r\n { id: 16, value: \"South East\" },\r\n { id: 32, value: \"South West\" },\r\n { id: 64, value: \"North East\" },\r\n { id: 128, value: \"Wales\" },\r\n { id: 256, value: \"Scotland\" },\r\n { id: 512, value: \"Northern Ireland\" },\r\n ];\r\n propertyTypes: Array<{ id: number; value: string }> = [\r\n { id: 0, value: \"Any\" },\r\n { id: 1, value: \"Residential\" },\r\n { id: 2, value: \"Mixed Use\" },\r\n { id: 2048, value: \"Licenced HMO\" },\r\n { id: 4, value: \"Hotel\" },\r\n { id: 8, value: \"Leisure\" },\r\n { id: 16, value: \"Care Home\" },\r\n { id: 32, value: \"Medical\" },\r\n { id: 64, value: \"Office\" },\r\n { id: 128, value: \"Retail\" },\r\n { id: 256, value: \"Light Industrial\" },\r\n { id: 512, value: \"Student\" },\r\n { id: 1024, value: \"Heavy Industrial\" },\r\n { id: 4096, value: \"Land without Planning\" },\r\n { id: 8192, value: \"Education\" },\r\n { id: 16384, value: \"Retirement\" },\r\n ];\r\n\r\n // end of Introducer variables\r\n\r\n // Start of dashboard search variables\r\n\r\n //caseStatuses: Array<{ id: number, value: string, order: number }> = [{ id: 999, value: 'Search', order: 1 }, { id: 0, value: 'New Project', order: 2 }, { id: 1, value: 'DIP In Progress', order: 3 }, { id: 2, value: 'Under Review', order: 4 }, { id: 3, value: 'Ready To Submit', order: 5 }, { id: 4, value: 'Submitted To Lenders For DIP', order: 6 }, { id: 12, value: 'Ready to be Re-submitted to Lenders For DIP', order: 6 }, { id: 5, value: 'Applied', order: 7 }]; //, { id: 9, value: \"Submitted To Lenders Pending Review\", order: 12 }\r\n lenderCaseStatuses: Array<{ id: number; value: string; order: number }> = [\r\n { id: 1, value: \"Case to review\", order: 2 },\r\n { id: 2, value: \"DIP submitted\", order: 3 },\r\n { id: 3, value: \"Case rejected\", order: 4 },\r\n { id: 4, value: \"DIP withdrawn\", order: 5 },\r\n { id: 10, value: \"DIP submitted and accepted\", order: 6 },\r\n ];\r\n\r\n // Status filter for non-lenders\r\n filterStatuses: Array<{ id: number; value: string; order: number }> = [\r\n { id: 1, value: \"Search\", order: 2 },\r\n { id: 2, value: \"Case in Progress\", order: 3 },\r\n { id: 3, value: \"Submitted to Lender\", order: 4 },\r\n { id: 8, value: \"Ready to Re-Submit to Lenders\", order: 4.5 },\r\n { id: 4, value: \"DIP: Offered\", order: 5 },\r\n { id: 5, value: \"DIP: Rejected\", order: 6 },\r\n { id: 6, value: \"DIP: Withdrawn\", order: 7 },\r\n { id: 7, value: \"Applied to Lender\", order: 8 }\r\n ];\r\n\r\n clientCaseNameFilter: string = null;\r\n statusFilter: number = undefined;\r\n caseStatusFilter: CaseStatusEnum = null;\r\n dipStatusFilter: CaseLenderStateEnum = null;\r\n\r\n // end of dashboard search variables\r\n\r\n licenseStatus: LicenseMasterStatusEnum;\r\n showPaymentModal: boolean;\r\n selectedResult: number;\r\n dataLoading: boolean = false;\r\n introducerErrorDisplayed: boolean = false;\r\n\r\n isUpgradedUser: boolean = false;\r\n isAssignedUserToOrg: boolean = false;\r\n\r\n showLogOutModal: boolean = false;\r\n\r\n addToHubspot: boolean = false;\r\n\r\n selectedSearch: CaseSummaryDTO;\r\n\r\n confirmAssignBrokerSearch: boolean = false;\r\n confirmAssignLenderSearch: boolean = false;\r\n licensedOrganisationBrokers: ApplicationUserDTO[];\r\n lenderUsers: ApplicationUserDTO[];\r\n selectedBroker: ApplicationUserDTO;\r\n selectedLender: ApplicationUserDTO;\r\n lenderList: ApplicationUserDTO[] = [];\r\n showDeletedSearchMessageModal: boolean = false;\r\n borrowerMessage: string = null;\r\n showMessageToborrower: boolean = false;\r\n showContactBrokerModal: boolean = false;\r\n\r\n productTypeOptions = [];\r\n\r\n //hiding and showing briding option.\r\n hasBridging: boolean = false;\r\n\r\n //hiding and showing commercial option.\r\n hasCommercial: boolean = false;\r\n\r\n isDeallockerIntegrationEnabled: boolean = false\r\n\r\n //Hiding menus for every one.\r\n hideDevfinanceMenu: boolean = true;\r\n hideBridgingMenu: boolean = true;\r\n hideCommercialMenu: boolean = true;\r\n\r\n //Hiding search for lenders.\r\n hasLiveSearch: boolean = true;\r\n hideDevelopmentFinanceSearch: boolean = false;\r\n hideBridgingSearch: boolean = false;\r\n hideCommercialSearch: boolean = false;\r\n\r\n // Boolean to send search email to client\r\n emailClient: boolean = false;\r\n\r\n showLenderTerms: boolean = false;\r\n lenderSelectedProject: CaseSummaryDTO;\r\n\r\n isCommercialOwnerOccupiedActive: boolean = false;\r\n goToDealForumClicked: boolean = false;\r\n assignedLenders = {};\r\n\r\n bridgingTotalUnreadMessage: number = 0;\r\n commercialTotalUnreadMessage: number = 0;\r\n devfinanceTotalUnreadMessage: number = 0;\r\n deallockerTabSelected: number = 1;\r\n\r\n static $inject = [\r\n \"$rootScope\",\r\n \"$routeParams\",\r\n \"$location\",\r\n \"DevelopmentInputService\",\r\n \"DevelopmentInputWithNoLoginService\",\r\n \"UserService\",\r\n \"CaseService\",\r\n \"RoleService\",\r\n \"AuthService\",\r\n \"IntroducerService\",\r\n \"CaseSummaryService\",\r\n \"CaseMemberService\",\r\n \"InviteService\",\r\n \"OrganisationService\",\r\n \"LicenseService\",\r\n \"CaseLenderService\",\r\n \"UserService\",\r\n \"TaskItemService\",\r\n \"SelectListService\",\r\n \"ClientService\",\r\n \"DealService\",\r\n \"BridgingDealService\",\r\n \"LenderService\",\r\n \"DealLenderService\",\r\n \"DealLenderMessageService\",\r\n \"UserDashboardService\",\r\n \"SharedDataService\",\r\n \"EventLogService\"\r\n ];\r\n\r\n constructor(\r\n private $rootScope: ng.IRootScopeService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private $location: ng.ILocationService,\r\n private $DevelopmentInputService: DevelopmentInputService,\r\n private $DevelopmentInputWithNoLoginService: DevelopmentInputWithNoLoginService,\r\n private $user: UserService,\r\n private $CaseService: CaseService,\r\n private roleService: RoleService,\r\n private authService: AuthService,\r\n private $IntroducerService: IntroducerService,\r\n private $CaseSummaryService: CaseSummaryService,\r\n private $applicantservice: CaseMemberService,\r\n private inviteService: InviteService,\r\n private organisationService: OrganisationService,\r\n private licenseService: LicenseService,\r\n private caseLenderService: CaseLenderService,\r\n private userService: UserService,\r\n private taskItemService: TaskItemService,\r\n private selectListService: SelectListService,\r\n private clientService: ClientService,\r\n private dealService: DealService,\r\n private $bridgingDealService: BridgingDealService,\r\n private $lenderService: LenderService,\r\n private dealLenderService: DealLenderService,\r\n private dealLenderMessageService: DealLenderMessageService,\r\n private userDashboardService: UserDashboardService,\r\n private sharedDataService: SharedDataService,\r\n private eventLogService: EventLogService\r\n ) {\r\n (this.$rootScope as any).isInvitedAndHasReadonlyAccess = false;\r\n\r\n this.dealService.setShowSearchNameAndUserSelectionModal(true);\r\n\r\n this.authService.isCommercialOwnerOccupiedActive().then((response) => {\r\n this.isCommercialOwnerOccupiedActive = response;\r\n });\r\n\r\n if (sessionStorage.getItem(\"returningFromdeletedSearch\")) {\r\n this.showDeletedSearchMessageModal = true;\r\n }\r\n\r\n this.isUpgradedUser = sessionStorage.getItem(\"isUpgradedUser\") == \"true\";\r\n this.isAssignedUserToOrg = sessionStorage.getItem(\"assignUserToOrg\") == \"true\";\r\n\r\n\r\n //This removes most of the localstorage and session storage data.\r\n this.authService.clearStorageData();\r\n\r\n this.productTypeOptions =\r\n this.selectListService.GetProductTypeOptions(true);\r\n\r\n this.isPageLoading = true;\r\n\r\n this.roleService\r\n .GetUserRoles()\r\n .then((result) => {\r\n if (result.filter((x) => x.toLowerCase() == \"admin\").length > 0) {\r\n this.isAdmin = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"broker\").length > 0) {\r\n this.isBroker = true;\r\n }\r\n\r\n if (result.filter((x) => x.toLowerCase() == \"client\").length > 0) {\r\n this.isBorrower = true;\r\n }\r\n if (result.filter((x) => x.toLowerCase() == \"introducer\").length > 0) {\r\n this.isIntroducer = true;\r\n }\r\n\r\n if (result.filter((x) => x.toLowerCase() == \"lender\").length > 0) {\r\n this.isLender = true;\r\n }\r\n\r\n this.authService.getUpdatedProfile().then((prof) => {\r\n this.currentUser = prof;\r\n this.hasEnterpriseLicense = this.currentUser.HasActiveEnterpriseLicense;\r\n\r\n if (this.currentUser.IsConnectUser) {\r\n this.filterStatuses[this.filterStatuses.length] = { id: 10, value: \"Case to Review\", order: 9 }\r\n }\r\n\r\n\r\n if (\r\n this.currentUser != null &&\r\n this.currentUser.IsOrganisationAdmin\r\n ) {\r\n this.getBrokerBelongToOrganisation(this.currentUser.OrganisationId);\r\n }\r\n\r\n if (this.isBroker || this.isBorrower) {\r\n this.hideDevfinanceMenu = false;\r\n this.hideBridgingMenu = false;\r\n this.hideCommercialMenu = false;\r\n this.setHasBridgingAndHasCommercialValue();\r\n } else {\r\n this.hasBridging = true;\r\n this.hasCommercial = true;\r\n if (!this.isAdmin && !this.isIntroducer) {\r\n this.currentLenderProductType();\r\n } else {\r\n this.hideDevfinanceMenu = false;\r\n this.hideBridgingMenu = false;\r\n this.hideCommercialMenu = false;\r\n }\r\n }\r\n\r\n if (this.isAdmin || this.isBroker) {\r\n this.organisationService.getOrganisationProductAccess().then((response) => {\r\n if (this.isAdmin) this.isDeallockerIntegrationEnabled = response.IsDeallockerIntegrationEnabled;\r\n\r\n if ((this.isBroker && response.IsConnectMember) || this.isAdmin) {\r\n this.filterStatuses[this.filterStatuses.length] = { id: 10, value: \"Sent to Packager\", order: 9 }\r\n }\r\n\r\n });\r\n }\r\n\r\n if (this.isLender) {\r\n this.hideDevelopmentFinanceSearch = true;\r\n this.hideBridgingSearch = true;\r\n this.hideCommercialSearch = true;\r\n this.hasLiveSearch = false;\r\n\r\n this.$lenderService.getUserLenderDetails().then((lender) => {\r\n if (lender.HasLiveMarketSearch) {\r\n this.hasLiveSearch = true;\r\n\r\n if (lender.HasBridgingSearch) {\r\n this.hideBridgingMenu = false;\r\n this.hideBridgingSearch = false;\r\n }\r\n if (lender.HasDevelopmentFinanceSearch) {\r\n this.hideDevfinanceMenu = false;\r\n this.hideDevelopmentFinanceSearch = false;\r\n }\r\n if (lender.HasCommercialSearch) {\r\n this.hideCommercialMenu = false;\r\n this.hideCommercialSearch = false;\r\n }\r\n }\r\n });\r\n\r\n this.$user\r\n .getUsersByLenderId(this.currentUser.LenderId)\r\n .then((response) => {\r\n this.lenderUsers = response;\r\n });\r\n }\r\n\r\n if (this.addToHubspot) {\r\n this.userService.sendEventToHubspot(this.currentUser);\r\n }\r\n\r\n if (!(this.$rootScope as any).clientUsernameBeingViewed) {\r\n this.selecteduserName = this.currentUser.UserName;\r\n }\r\n\r\n // this is why I'm getting the update profile within the getuserroles call, I want to know if introducer is their only role\r\n if (result.length == 1 && this.isIntroducer) {\r\n this.showIntroductionsDashboard();\r\n } else {\r\n var goToNavMenu = this.userDashboardService.getGoToNavMenu();\r\n if (goToNavMenu) {\r\n if (goToNavMenu == this.userDashboardService.NavMenuEnum.EquityAndMezz) {\r\n this.showEquityAndMezzDashboard();\r\n }\r\n } else {\r\n this.showHomeDashboard();\r\n }\r\n }\r\n });\r\n })\r\n .finally(() => {\r\n this.isPageLoading = false;\r\n });\r\n\r\n // Will hit here if the user has come from the payment page\r\n if (this.$routeParams.licensemasterId) {\r\n if (this.$routeParams.licensemasterId == \"0\") {\r\n this.showPaymentModal = true;\r\n } else {\r\n this.licenseService\r\n .fetch(this.$routeParams.licensemasterId)\r\n .then((license: LicenseMasterDTO) => {\r\n this.licenseStatus = license.Status;\r\n if (\r\n license.Status == LicenseMasterStatusEnum.PreSubscription ||\r\n LicenseMasterStatusEnum.None ||\r\n LicenseMasterStatusEnum.Unpaid ||\r\n license.Status == LicenseMasterStatusEnum.PayFailure ||\r\n license.Status == LicenseMasterStatusEnum.PaidUp\r\n ) {\r\n this.showPaymentModal = true;\r\n }\r\n });\r\n }\r\n this.addToHubspot = true;\r\n } else if (this.isAssignedUserToOrg) {\r\n this.showLogOutModal = true;\r\n }\r\n }\r\n\r\n getProjectsAndSearches() {\r\n sessionStorage.setItem(\"selectedNavMenu\", this.selectedNavMenu.toString());\r\n if (\r\n this.isBorrower ||\r\n this.isBroker ||\r\n this.isAdmin ||\r\n this.isIntroducer ||\r\n this.isLender\r\n ) {\r\n //only get searches if user might have any\r\n this.getSearches(this.homeScreenCount);\r\n } else {\r\n this.homeScreenCount = 6; //for lender\r\n }\r\n this.getProjects(this.homeScreenCount);\r\n }\r\n\r\n showHomeDashboard() {\r\n this.selectedDashboardType = this.DashboardTypeEnum.Home;\r\n if (\r\n sessionStorage.getItem(\"selectedNavMenu\") &&\r\n this.isValidPreviousPath()\r\n ) {\r\n this.selectedNavMenu = parseInt(\r\n sessionStorage.getItem(\"selectedNavMenu\"),\r\n );\r\n } else {\r\n this.selectedNavMenu = this.NavMenuEnum.Home;\r\n }\r\n\r\n if (\r\n sessionStorage.getItem(\"clientCaseNameFilter\") &&\r\n this.isValidPreviousPath()\r\n ) {\r\n this.clientCaseNameFilter = sessionStorage.getItem(\r\n \"clientCaseNameFilter\",\r\n );\r\n }\r\n\r\n if (sessionStorage.getItem(\"statusFilter\") && this.isValidPreviousPath()) {\r\n this.statusFilter = parseInt(sessionStorage.getItem(\"statusFilter\"));\r\n this.mapFilterStatus();\r\n }\r\n\r\n this.getProjectsAndSearches();\r\n }\r\n\r\n showEquityAndMezzDashboard() {\r\n this.selectedNavMenu = this.NavMenuEnum.EquityAndMezz;\r\n this.selectedDashboardType = this.DashboardTypeEnum.Home;\r\n this.userDashboardService.resetGoToNavMenu();\r\n }\r\n\r\n showDevelopmentFinanceDashboard() {\r\n this.selectedNavMenu = this.NavMenuEnum.DevelopmentFinance;\r\n this.selectedDashboardType = this.DashboardTypeEnum.Home;\r\n //this.isNewSearchSelect = false;\r\n\r\n this.getProjectsAndSearches();\r\n }\r\n\r\n showBridgingDashboard() {\r\n if (this.hasBridging) {\r\n this.selectedNavMenu = this.NavMenuEnum.BridgingFinance;\r\n this.selectedDashboardType = this.DashboardTypeEnum.Home;\r\n //this.isNewSearchSelect = false;\r\n\r\n //TODO JLH remove\r\n //this.selectedDashboardType = this.DashboardTypeEnum.Home;\r\n\r\n this.getProjectsAndSearches();\r\n }\r\n }\r\n\r\n showCommercialDashboard() {\r\n if (this.hasCommercial) {\r\n this.selectedNavMenu = this.NavMenuEnum.CommercialMortgages;\r\n this.selectedDashboardType = this.DashboardTypeEnum.Home;\r\n // this.isNewSearchSelect = false;\r\n this.getProjectsAndSearches();\r\n }\r\n }\r\n\r\n showDevFinanceSearchDashboard() {\r\n this.selectedDashboardType = this.DashboardTypeEnum.Searches;\r\n //this.isNewSearchSelect = false;\r\n this.getSearches(0);\r\n }\r\n\r\n showProjectDashboard() {\r\n this.selectedDashboardType = this.DashboardTypeEnum.Projects;\r\n //this.isNewSearchSelect = false;\r\n this.getProjects(0);\r\n }\r\n\r\n showIntroductionsDashboard() {\r\n this.isPageLoading = true;\r\n\r\n this.selectedDashboardType = this.DashboardTypeEnum.Introductions;\r\n // this.isNewSearchSelect = false;\r\n\r\n if (this.isIntroducer || this.isAdmin) {\r\n this.getInvitedUsers();\r\n this.getIntroducedBorrowers();\r\n this.getIntroducedSearches(this.currentUser.RegisteredIntroducerId);\r\n }\r\n\r\n this.isPageLoading = false;\r\n }\r\n\r\n checkSearchPermission(): boolean {\r\n if (this.selectedNavMenu == this.NavMenuEnum.Home) {\r\n return true;\r\n }\r\n\r\n if (\r\n this.selectedNavMenu == this.NavMenuEnum.DevelopmentFinance &&\r\n !this.hideDevelopmentFinanceSearch\r\n ) {\r\n return true;\r\n }\r\n\r\n if (\r\n this.selectedNavMenu == this.NavMenuEnum.BridgingFinance &&\r\n !this.hideBridgingSearch\r\n ) {\r\n return true;\r\n }\r\n\r\n if (\r\n this.selectedNavMenu == this.NavMenuEnum.CommercialMortgages &&\r\n !this.hideCommercialSearch\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n getSearches(count: number) {\r\n if (this.dipStatusFilter) {\r\n this.searches = [];\r\n return;\r\n }\r\n\r\n this.isSearchesLoading = true;\r\n\r\n this.searches = [];\r\n\r\n var userName = this.currentUser.UserName;\r\n\r\n if (this.selectedNavMenu == this.NavMenuEnum.DevelopmentFinance) {\r\n this.$CaseSummaryService\r\n .getDevFinanceSearchesForUser(\r\n userName,\r\n this.clientCaseNameFilter,\r\n this.caseStatusFilter,\r\n count,\r\n )\r\n .then((results: CaseSummaryDTO[]) => {\r\n if (this.selectedNavMenu == this.NavMenuEnum.DevelopmentFinance) {\r\n this.searches = results;\r\n this.isSearchesLoading = false;\r\n }\r\n })\r\n .catch((error) => {\r\n this.searches = [];\r\n this.isSearchesLoading = false;\r\n });\r\n } else if (this.selectedNavMenu == this.NavMenuEnum.BridgingFinance) {\r\n this.$CaseSummaryService\r\n .getBridgingSearchesForUser(\r\n userName,\r\n this.clientCaseNameFilter,\r\n this.caseStatusFilter,\r\n count,\r\n )\r\n .then((results: CaseSummaryDTO[]) => {\r\n if (this.selectedNavMenu == this.NavMenuEnum.BridgingFinance) {\r\n this.searches = results;\r\n this.isSearchesLoading = false;\r\n }\r\n })\r\n .catch((error) => {\r\n this.searches = [];\r\n this.isSearchesLoading = false;\r\n });\r\n } else if (this.selectedNavMenu == this.NavMenuEnum.CommercialMortgages) {\r\n this.$CaseSummaryService\r\n .getCommercialSearchesForUser(\r\n userName,\r\n this.clientCaseNameFilter,\r\n this.caseStatusFilter,\r\n count,\r\n )\r\n .then((results: CaseSummaryDTO[]) => {\r\n if (this.selectedNavMenu == this.NavMenuEnum.CommercialMortgages) {\r\n this.searches = results;\r\n this.isSearchesLoading = false;\r\n }\r\n })\r\n .catch((error) => {\r\n this.searches = [];\r\n this.isSearchesLoading = false;\r\n });\r\n } else {\r\n this.$CaseSummaryService\r\n .getAllSearchesForUser(\r\n userName,\r\n this.clientCaseNameFilter,\r\n this.caseStatusFilter,\r\n count,\r\n )\r\n .then((results: CaseSummaryDTO[]) => {\r\n if (this.selectedNavMenu == this.NavMenuEnum.Home) {\r\n this.searches = results;\r\n this.isSearchesLoading = false;\r\n }\r\n })\r\n .catch((error) => {\r\n this.searches = [];\r\n this.isSearchesLoading = false;\r\n });\r\n }\r\n }\r\n /**\r\n * Retrieves projects (appraisals) according to which menu option has been selected\r\n * @param count\r\n */\r\n //TODO: Use this\r\n getDealproject(count: number) { }\r\n /**\r\n * Retrieves projects (appraisals) according to which menu option has been selected\r\n * @param count\r\n */\r\n getProjects(count: number) {\r\n this.projects = [];\r\n\r\n var userName = this.currentUser.UserName;\r\n\r\n if (this.selectedNavMenu == this.NavMenuEnum.DevelopmentFinance) {\r\n this.isDevFinanceProjectsLoading = true;\r\n\r\n this.$CaseSummaryService\r\n .getDevFinanceCasesForUser(\r\n userName,\r\n this.clientCaseNameFilter,\r\n this.caseStatusFilter,\r\n this.dipStatusFilter,\r\n count,\r\n )\r\n .then((results) => {\r\n if (this.selectedNavMenu == this.NavMenuEnum.DevelopmentFinance) {\r\n this.projects = results;\r\n if (this.isLender) {\r\n this.projects.forEach((project) => {\r\n if (\r\n project.ProductType == ProductTypeEnum.Development &&\r\n project.DealID == null &&\r\n project.CaseID != null\r\n ) {\r\n this.setAssignedLender(project.CaseID, true);\r\n } else {\r\n this.setAssignedLender(project.DealID);\r\n }\r\n });\r\n }\r\n this.isDevFinanceProjectsLoading = false;\r\n }\r\n })\r\n .then(() => {\r\n this.getTotalUnreadMessagesPerAppraisal();\r\n })\r\n .catch((error) => {\r\n this.projects = [];\r\n this.isDevFinanceProjectsLoading = false;\r\n });\r\n } else if (this.selectedNavMenu == this.NavMenuEnum.BridgingFinance) {\r\n this.isBridgingPreConProjectsLoading = true;\r\n\r\n this.$CaseSummaryService\r\n .getBridgingCasesForUser(\r\n userName,\r\n this.clientCaseNameFilter,\r\n this.caseStatusFilter,\r\n this.dipStatusFilter,\r\n count,\r\n )\r\n .then((results) => {\r\n if (this.selectedNavMenu == this.NavMenuEnum.BridgingFinance) {\r\n this.projects = results;\r\n if (this.isLender) {\r\n this.projects.forEach((project) => {\r\n this.setAssignedLender(project.DealID);\r\n });\r\n }\r\n this.isBridgingPreConProjectsLoading = false;\r\n }\r\n })\r\n .then(() => {\r\n this.getTotalUnreadMessagesPerAppraisal();\r\n })\r\n .catch((error) => {\r\n this.projects = [];\r\n this.isBridgingPreConProjectsLoading = false;\r\n });\r\n } else if (this.selectedNavMenu == this.NavMenuEnum.CommercialMortgages) {\r\n this.isCommercialProjectsLoading = true;\r\n\r\n this.$CaseSummaryService\r\n .getCommercialCasesForUser(\r\n userName,\r\n this.clientCaseNameFilter,\r\n this.caseStatusFilter,\r\n this.dipStatusFilter,\r\n count,\r\n )\r\n .then((results) => {\r\n if (this.selectedNavMenu == this.NavMenuEnum.CommercialMortgages) {\r\n this.projects = results;\r\n if (this.isLender) {\r\n this.projects.forEach((project) => {\r\n this.setAssignedLender(project.DealID);\r\n });\r\n }\r\n this.isCommercialProjectsLoading = false;\r\n }\r\n })\r\n .then(() => {\r\n this.getTotalUnreadMessagesPerAppraisal();\r\n })\r\n .catch((error) => {\r\n this.projects = [];\r\n this.isCommercialProjectsLoading = false;\r\n });\r\n } else {\r\n this.isAllProjectsLoading = true;\r\n\r\n this.$CaseSummaryService\r\n .getAllCasesForUser(\r\n userName,\r\n this.clientCaseNameFilter,\r\n this.caseStatusFilter,\r\n this.dipStatusFilter,\r\n count,\r\n )\r\n .then((results) => {\r\n if (this.selectedNavMenu == this.NavMenuEnum.Home) {\r\n this.projects = results;\r\n if (this.isLender) {\r\n this.projects.forEach((project) => {\r\n if (\r\n project.ProductType == ProductTypeEnum.Development &&\r\n project.DealID == null &&\r\n project.CaseID != null\r\n ) {\r\n this.setAssignedLender(project.CaseID, true);\r\n } else {\r\n this.setAssignedLender(project.DealID);\r\n }\r\n });\r\n }\r\n this.isAllProjectsLoading = false;\r\n }\r\n })\r\n .then(() => {\r\n this.getTotalUnreadMessagesPerAppraisal();\r\n })\r\n .catch((error) => {\r\n this.projects = [];\r\n this.isAllProjectsLoading = false;\r\n });\r\n }\r\n }\r\n\r\n //toggleCardTableView() {\r\n // // hide any open menus\r\n // this.closeTileMenu();\r\n\r\n // this.isCardView = !this.isCardView;\r\n //}\r\n\r\n getInvitedUsers() {\r\n this.inviteService\r\n .getInvitedBorrowers(this.currentUser.Id)\r\n .then((result) => {\r\n this.invitedUsers = result;\r\n });\r\n }\r\n\r\n getIntroducedBorrowers() {\r\n this.$user.getintroducees(this.currentUser.Id).then((introducedUsers) => {\r\n this.introducedUsers = introducedUsers;\r\n });\r\n }\r\n\r\n getIntroducedSearches(registeredIntroducerId: number) {\r\n if (!registeredIntroducerId) {\r\n return;\r\n }\r\n this.$DevelopmentInputWithNoLoginService\r\n .fetchByIntroducerId(registeredIntroducerId)\r\n .then((results) => {\r\n this.unsavedIntroducedSearches = results.filter(\r\n (r) => r.IntroducedSearchStatus < 2,\r\n );\r\n let savedIntroducedSearchesIdentified = results.filter(\r\n (r) => r.IntroducedSearchStatus >= 2,\r\n );\r\n if (savedIntroducedSearchesIdentified.length > 0) {\r\n this.$DevelopmentInputService\r\n .fetchByIntroducerId(registeredIntroducerId)\r\n .then((devInputResults) => {\r\n this.savedIntroducedSearches = devInputResults;\r\n });\r\n }\r\n\r\n this.getIntroducedBorrowers();\r\n });\r\n }\r\n\r\n filterProjectsAndSearches() {\r\n if (this.clientCaseNameFilter != null)\r\n sessionStorage.setItem(\"clientCaseNameFilter\", this.clientCaseNameFilter);\r\n if (this.statusFilter != null)\r\n sessionStorage.setItem(\"statusFilter\", this.statusFilter.toString());\r\n\r\n //TODO - what is this code doing?!\r\n if (this.selecteduserName) {\r\n this.selecteduserName = this.selecteduserName; // this is baffling!\r\n } else if ((this.$rootScope as any).clientUsernameBeingViewed) {\r\n this.selecteduserName = (\r\n this.$rootScope as any\r\n ).clientUsernameBeingViewed;\r\n } else {\r\n this.selecteduserName = this.currentUser.UserName;\r\n }\r\n\r\n if (this.selecteduserName !== this.currentUser.UserName) {\r\n this.$user.searchByEmail(this.selecteduserName).then((users) => {\r\n this.selectedUser = users[0];\r\n });\r\n }\r\n // end of todo\r\n\r\n this.mapFilterStatus();\r\n\r\n if (this.selectedDashboardType == this.DashboardTypeEnum.Home) {\r\n this.getProjectsAndSearches();\r\n } else if (this.selectedDashboardType == this.DashboardTypeEnum.Searches) {\r\n this.showDevFinanceSearchDashboard();\r\n } else if (this.selectedDashboardType == this.DashboardTypeEnum.Projects) {\r\n this.showProjectDashboard();\r\n }\r\n }\r\n\r\n /**Map the combined status filter dropdown to the correct enum filter (case/caselender) */\r\n mapFilterStatus() {\r\n if (this.statusFilter == undefined || isNaN(this.statusFilter)) {\r\n this.caseStatusFilter = null;\r\n this.dipStatusFilter = null;\r\n return;\r\n }\r\n\r\n if (this.isLender) {\r\n this.caseStatusFilter = null;\r\n this.dipStatusFilter = this.statusFilter;\r\n } else {\r\n switch (this.statusFilter) {\r\n case 1:\r\n this.caseStatusFilter = CaseStatusEnum.Search;\r\n this.dipStatusFilter = null;\r\n break;\r\n case 2:\r\n this.caseStatusFilter = CaseStatusEnum.NewCase;\r\n this.dipStatusFilter = null;\r\n break;\r\n case 3:\r\n this.caseStatusFilter = CaseStatusEnum.SubmittedToLendersForHoT;\r\n this.dipStatusFilter = null;\r\n break;\r\n case 4:\r\n this.caseStatusFilter = null;\r\n this.dipStatusFilter = CaseLenderStateEnum.Offered;\r\n break;\r\n case 5:\r\n this.caseStatusFilter = null;\r\n this.dipStatusFilter = CaseLenderStateEnum.Rejected;\r\n break;\r\n case 6:\r\n this.caseStatusFilter = null;\r\n this.dipStatusFilter = CaseLenderStateEnum.Withdrawn;\r\n break;\r\n case 7:\r\n this.caseStatusFilter = CaseStatusEnum.Applied;\r\n this.dipStatusFilter = null;\r\n break;\r\n case 8:\r\n this.caseStatusFilter = CaseStatusEnum.ReadyToReSubmit;\r\n this.dipStatusFilter = null;\r\n break;\r\n case 9:\r\n this.caseStatusFilter = CaseStatusEnum.SentToPackager;\r\n this.dipStatusFilter = null;\r\n break;\r\n case 0:\r\n default:\r\n this.caseStatusFilter = null;\r\n this.dipStatusFilter = null;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n getCaseStatusText(status: CaseStatusEnum): string {\r\n var displayText = \"\";\r\n\r\n switch (status) {\r\n case CaseStatusEnum.NewCase:\r\n displayText = \"CASE IN PROGRESS\";\r\n break;\r\n case CaseStatusEnum.UnderReview:\r\n displayText = \"UNDER ADMIN REVIEW\";\r\n break;\r\n case CaseStatusEnum.ReadyToSubmit:\r\n displayText = \"READY TO SUBMIT TO LENDERS\";\r\n break;\r\n case CaseStatusEnum.SubmittedToLendersForHoT:\r\n displayText = \"SUBMITTED TO LENDERS FOR DIP\";\r\n break;\r\n case CaseStatusEnum.Applied:\r\n displayText = \"APPLIED TO LENDER\";\r\n break;\r\n case CaseStatusEnum.Completed:\r\n displayText = \"COMPLETE\";\r\n break;\r\n case CaseStatusEnum.SubmittedToLendersPendingReview:\r\n displayText = \"SUBMITTED TO LENDERS PENDING REVIEW\";\r\n break;\r\n case CaseStatusEnum.ReadyToReSubmit:\r\n displayText = \"READY TO BE RE-SUBMITTED TO LENDERS FOR DIP\";\r\n break;\r\n case CaseStatusEnum.SentToPackager:\r\n displayText = this.currentUser == null ? \"\" : this.currentUser.IsConnectUser ? \"SENT BY AR\" : \"SENT TO PACKAGER\";\r\n break;\r\n default:\r\n case CaseStatusEnum.NewCase:\r\n displayText = \"\";\r\n break;\r\n }\r\n\r\n return displayText;\r\n }\r\n\r\n nFormatter(num: number, decimalPlaces: number) {\r\n const lookup = [\r\n { value: 1, symbol: \"\" },\r\n { value: 1e3, symbol: \"k\" },\r\n { value: 1e6, symbol: \"M\" },\r\n { value: 1e9, symbol: \"G\" },\r\n { value: 1e12, symbol: \"T\" },\r\n { value: 1e15, symbol: \"P\" },\r\n { value: 1e18, symbol: \"E\" },\r\n ];\r\n const rx = /\\.0+$|(\\.[0-9]*[1-9])0+$/;\r\n var item = lookup\r\n .slice()\r\n .reverse()\r\n .find(function (item) {\r\n return num >= item.value;\r\n });\r\n return item\r\n ? (num / item.value).toFixed(decimalPlaces).replace(rx, \"$1\") +\r\n item.symbol\r\n : \"0\";\r\n }\r\n\r\n isDateToday(date: Date) {\r\n if (date) {\r\n const today = new Date();\r\n\r\n if (\r\n today.getFullYear() === date.getFullYear() &&\r\n today.getMonth() === date.getMonth() &&\r\n today.getDate() === date.getDate()\r\n ) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n isDateYesterday(date: Date) {\r\n if (date) {\r\n var yesterday = new Date();\r\n yesterday.setDate(yesterday.getDate() - 1);\r\n\r\n if (\r\n yesterday.getFullYear() === date.getFullYear() &&\r\n yesterday.getMonth() === date.getMonth() &&\r\n yesterday.getDate() === date.getDate()\r\n ) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n getLastUpdated(date: Date): string {\r\n var displayValue: string;\r\n\r\n if (date) {\r\n if (this.isDateToday(date)) {\r\n displayValue = \"Today\";\r\n } else if (this.isDateYesterday(date)) {\r\n displayValue = \"Yesterday\";\r\n } else {\r\n displayValue = date.toLocaleDateString(\"en-GB\", {\r\n day: \"numeric\",\r\n month: \"short\",\r\n year: \"numeric\",\r\n });\r\n }\r\n }\r\n\r\n return displayValue;\r\n }\r\n\r\n goToSearchResults(caseSummary: CaseSummaryDTO) {\r\n this.sharedDataService.cleanLenderReferralSessionStorage();\r\n if (caseSummary.ProductType != ProductTypeEnum.Development) {\r\n if (this.isSearchClickable(caseSummary.isOwner)) {\r\n if (\r\n caseSummary.ProductType == ProductTypeEnum.CommercialInvestment ||\r\n caseSummary.ProductType == ProductTypeEnum.CommercialOwnerOccupied\r\n ) {\r\n this.$location.path(\"/commercialresults/\" + caseSummary.DealID);\r\n } else {\r\n this.$location.path(\"/bridgingresults/\" + caseSummary.DealID);\r\n }\r\n }\r\n } else {\r\n if (this.isSearchClickable(caseSummary.isOwner)) {\r\n if (caseSummary.UniqueRef != null) {\r\n this.$DevelopmentInputWithNoLoginService\r\n .isResultActive(caseSummary.UniqueRef)\r\n .then((results) => {\r\n if (!results) {\r\n this.displayMsg = `Changes have been made to this search by your client, your user dashboard will now refresh`;\r\n this.showShareResults = 5;\r\n } else {\r\n this.$location.path(\"/referredSearch/\" + caseSummary.UniqueRef);\r\n }\r\n });\r\n } else if (caseSummary.DevelopmentInputID) {\r\n this.$location.path(\"/results/\" + caseSummary.DevelopmentInputID);\r\n } else if (caseSummary.DealID) {\r\n this.$location.path(\"/devfinanceresults/\" + caseSummary.DealID);\r\n }\r\n }\r\n }\r\n }\r\n\r\n goToProject(project: CaseSummaryDTO) {\r\n this.sharedDataService.cleanLenderReferralSessionStorage();\r\n if (\r\n (this.roleService.IsLender && this.showLenderTerms) ||\r\n !this.roleService.IsLender\r\n ) {\r\n if (this.roleService.IsLender && this.showLenderTerms) {\r\n project = { ...this.lenderSelectedProject };\r\n }\r\n\r\n if (this.roleService.IsLender && this.goToDealForumClicked) {\r\n this.goToDealForum(project);\r\n } else {\r\n if (this.isProjectClickable(project.isInvitedToCase)) {\r\n if (project.isInvitedAndHasReadonlyAccess) {\r\n (this.$rootScope as any).isInvitedAndHasReadonlyAccess = true;\r\n this.$rootScope.$broadcast(\"invitedStatusChange\");\r\n }\r\n if (\r\n project.ProductType == ProductTypeEnum.BridgingPreconstruction ||\r\n project.ProductType ==\r\n ProductTypeEnum.BridgingPurchaseOrRefinance ||\r\n project.ProductType == ProductTypeEnum.BridgingDeveloperExit ||\r\n project.ProductType == ProductTypeEnum.BridgingRefurb\r\n ) {\r\n this.$location.path(\"/bridgingcasedashboard/\" + project.DealID);\r\n } else if (\r\n project.ProductType == ProductTypeEnum.CommercialInvestment ||\r\n project.ProductType == ProductTypeEnum.CommercialOwnerOccupied\r\n ) {\r\n this.$location.path(\"/commercialcasedashboard/\" + project.DealID);\r\n } else if (project.ProductType == ProductTypeEnum.Development) {\r\n if (project.DealID) {\r\n this.$location.path(\"/devfinancecasedashboard/\" + project.DealID);\r\n } else {\r\n this.$location.path(\"/casedashboard/\" + project.CaseID);\r\n }\r\n }\r\n }\r\n }\r\n } else if (this.roleService.IsLender && !this.showLenderTerms) {\r\n this.showLenderTerms = true;\r\n this.lenderSelectedProject = { ...project };\r\n }\r\n }\r\n\r\n goToNewSearch() {\r\n this.sharedDataService.cleanLenderReferralSessionStorage();\r\n // If the current user is a broker and doesn't have a subscription then don't allow them to create a new search\r\n if (this.isBroker && !this.currentUser.HasActiveSubscription) {\r\n return;\r\n }\r\n\r\n if (!this.isPageLoading) {\r\n (this.$rootScope as any).loanCriteria = null;\r\n\r\n if (\r\n this.isAdmin ||\r\n (this.currentUser && this.currentUser.SubscriptionStatus) ||\r\n this.isLender\r\n ) {\r\n this.authService.setHasValidStatustoShowShareSearchModal(\r\n true,\r\n );\r\n }\r\n\r\n if (\r\n this.selectedNavMenu == this.NavMenuEnum.DevelopmentFinance &&\r\n !this.hideDevelopmentFinanceSearch\r\n ) {\r\n this.goToNewDevFinanceSearch();\r\n }\r\n\r\n if (\r\n this.selectedNavMenu == this.NavMenuEnum.BridgingFinance &&\r\n !this.hideBridgingSearch\r\n ) {\r\n this.goToNewBridgingFinanceSearch();\r\n }\r\n\r\n if (\r\n this.selectedNavMenu == this.NavMenuEnum.CommercialMortgages &&\r\n !this.hideCommercialSearch\r\n ) {\r\n this.goToNewCommercialSearch();\r\n }\r\n\r\n if (this.selectedNavMenu == this.NavMenuEnum.Home || this.selectedNavMenu == this.NavMenuEnum.EquityAndMezz) {\r\n this.$location.path(\"/allloans\");\r\n }\r\n }\r\n }\r\n\r\n goToNewProject() {\r\n this.isPageLoading = true;\r\n this.roleService.isBroker().then((isBroker: boolean) => {\r\n this.$CaseService\r\n .newBlankCase(this.currentUser, !isBroker)\r\n .then((newBlankCaseDto) => {\r\n if (newBlankCaseDto && newBlankCaseDto.NewCaseId) {\r\n this.$location.path(\"/casedashboard/\" + newBlankCaseDto.NewCaseId);\r\n }\r\n\r\n this.isPageLoading = false;\r\n });\r\n });\r\n }\r\n\r\n goToNewBridgingSearch() {\r\n if (this.hasBridging) {\r\n this.$location.path(\"/bridgingcriteria/\");\r\n }\r\n }\r\n\r\n goToNewCommercialSearch() {\r\n if (this.hasCommercial) {\r\n this.$location.path(\"/commercialcriteria\");\r\n }\r\n }\r\n\r\n goToAllLoanPage() {\r\n this.$location.path(\"/allloans\");\r\n }\r\n\r\n goToPurchaseOrRefinanceSearch() {\r\n if (this.hasBridging) {\r\n this.$location.path(\"/purchaserefinancecriteria/\");\r\n }\r\n }\r\n\r\n goToNewDevFinanceSearch() {\r\n this.$location.path(\"/devfinancecriteria\");\r\n }\r\n\r\n goToNewBridgingFinanceSearch() {\r\n this.$location.path(\"/bridgingcriteria\");\r\n }\r\n\r\n deleteSearchConfirmation(dataItem) {\r\n this.closeTileMenu();\r\n event.stopPropagation();\r\n this.actionItem = dataItem;\r\n\r\n if (this.actionItem.isDevInputWithNoLogin) {\r\n this.$DevelopmentInputWithNoLoginService\r\n .isResultActive(this.actionItem.UniqueRef)\r\n .then((results) => {\r\n if (!results) {\r\n this.displayMsg = `Changes have been made to this search by your client, your user dashboard will now refresh`;\r\n this.showShareResults = 5;\r\n } else {\r\n this.confirmSearchToDelete = true;\r\n }\r\n });\r\n } else {\r\n this.confirmSearchToDelete = true;\r\n }\r\n }\r\n\r\n showAssignBrokerSearchModal(dataItem) {\r\n this.closeTileMenu();\r\n event.stopPropagation();\r\n this.actionItem = dataItem;\r\n this.confirmAssignBrokerSearch = true;\r\n this.selectedBroker = this.licensedOrganisationBrokers.find(\r\n (b) => b.Id == (this.currentUser?.IsConnectUser && this.actionItem.IsReferredToConnect ? this.actionItem.ConnectUserId : this.actionItem.BrokerUserId),\r\n );\r\n }\r\n\r\n showAssignLenderSearchModal(dataItem) {\r\n this.closeTileMenu();\r\n event.stopPropagation();\r\n this.actionItem = dataItem;\r\n this.getLenderUsersList();\r\n if (\r\n this.actionItem.ProductType == ProductTypeEnum.Development &&\r\n this.actionItem.DealID == null &&\r\n this.actionItem.CaseID != null\r\n ) {\r\n this.caseLenderService\r\n .fetchCaseLender(this.actionItem.CaseID)\r\n .then((response) => {\r\n return this.userService.getUserByUserId(\r\n response.AssignedLenderUserId,\r\n );\r\n })\r\n .then((response) => {\r\n if (response != null) {\r\n this.selectedLender = response;\r\n }\r\n })\r\n .finally(() => {\r\n this.confirmAssignLenderSearch = true;\r\n });\r\n } else {\r\n this.dealLenderService\r\n .fetchDealLender(this.actionItem.DealID)\r\n .then((response) => {\r\n return this.userService.getUserByUserId(\r\n response.AssignedLenderUserId,\r\n );\r\n })\r\n .then((response) => {\r\n if (response != null) {\r\n this.selectedLender = response;\r\n }\r\n })\r\n .finally(() => {\r\n this.confirmAssignLenderSearch = true;\r\n });\r\n }\r\n }\r\n\r\n assignBrokerToSearch(assignBrokerId) {\r\n this.confirmAssignBrokerSearch = false;\r\n this.isPageLoading = true;\r\n\r\n if (\r\n this.actionItem.ProductType == ProductTypeEnum.Development &&\r\n this.actionItem.DealID == null\r\n ) {\r\n if (this.actionItem.CaseID) {\r\n this.$CaseService\r\n .changeBrokerUser(this.actionItem.CaseID, assignBrokerId)\r\n .then((success) => {\r\n if (success) {\r\n this.getProjects(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n } else {\r\n this.displayMsg =\r\n \"We were unable to assign the broker to the case at this time, please try again later.\";\r\n this.showShareResults = 4;\r\n }\r\n })\r\n .finally(() => {\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n this.selectedBroker = null;\r\n });\r\n } else {\r\n this.$DevelopmentInputService\r\n .assignBrokerToSearch(\r\n this.actionItem.DevelopmentInputID,\r\n assignBrokerId,\r\n this.actionItem.isDevInputWithNoLogin,\r\n )\r\n .then((success) => {\r\n if (success) {\r\n this.getSearches(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n } else {\r\n this.displayMsg =\r\n \"We were unable to assign the broker to the search at this time, please try again later.\";\r\n this.showShareResults = 4;\r\n }\r\n })\r\n .finally(() => {\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n this.selectedBroker = null;\r\n });\r\n }\r\n } else {\r\n this.dealService\r\n .assignBrokerToDeal(this.actionItem.DealID, assignBrokerId)\r\n .then((success) => {\r\n if (success) {\r\n if (this.actionItem.CaseStatus == CaseStatusEnum.Search) {\r\n this.getSearches(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n } else {\r\n this.getProjects(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n }\r\n } else {\r\n this.displayMsg =\r\n \"There was a problem assigning the broker, please try later.\";\r\n this.showShareResults = 4;\r\n }\r\n })\r\n .finally(() => {\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n this.selectedBroker = null;\r\n });\r\n }\r\n }\r\n\r\n assignLenderToSearch(assignLenderId) {\r\n this.confirmAssignLenderSearch = false;\r\n this.isPageLoading = true;\r\n\r\n if (\r\n this.actionItem.ProductType == ProductTypeEnum.Development &&\r\n this.actionItem.DealID == null &&\r\n this.actionItem.CaseID != null\r\n ) {\r\n this.$CaseService\r\n .assignLenderToCase(\r\n this.actionItem.CaseID,\r\n this.currentUser.LenderId,\r\n assignLenderId,\r\n )\r\n .then((success) => {\r\n if (success) {\r\n if (this.actionItem.CaseStatus == CaseStatusEnum.Search) {\r\n this.getSearches(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n } else {\r\n this.getProjects(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n }\r\n this.setAssignedLender(this.actionItem.CaseID);\r\n } else {\r\n this.displayMsg =\r\n \"There was a problem assigning the lender, please try later.\";\r\n this.showShareResults = 4;\r\n }\r\n })\r\n .finally(() => {\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n this.selectedLender = null;\r\n this.lenderList = null;\r\n });\r\n } else {\r\n this.dealService\r\n .assignLenderToDeal(\r\n this.actionItem.DealID,\r\n this.currentUser.LenderId,\r\n assignLenderId,\r\n )\r\n .then((success) => {\r\n if (success) {\r\n if (this.actionItem.CaseStatus == CaseStatusEnum.Search) {\r\n this.getSearches(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n } else {\r\n this.getProjects(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n }\r\n this.setAssignedLender(this.actionItem.DealID);\r\n } else {\r\n this.displayMsg =\r\n \"There was a problem assigning the lender, please try later.\";\r\n this.showShareResults = 4;\r\n }\r\n })\r\n .finally(() => {\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n this.selectedLender = null;\r\n this.lenderList = null;\r\n });\r\n }\r\n }\r\n\r\n setAssignedLender(caseId: number, oldDevFinance: boolean = false) {\r\n if (oldDevFinance) {\r\n this.caseLenderService\r\n .fetchCaseLender(caseId)\r\n .then((response) => {\r\n return this.userService.getUserByUserId(\r\n response.AssignedLenderUserId,\r\n );\r\n })\r\n .then((response) => {\r\n if (response != null) {\r\n this.assignedLenders[caseId] = response.FullName;\r\n } else {\r\n this.assignedLenders[caseId] = null;\r\n }\r\n })\r\n .catch(() => {\r\n this.assignedLenders[caseId] = null;\r\n });\r\n } else {\r\n this.dealLenderService\r\n .fetchDealLender(caseId)\r\n .then((response) => {\r\n return this.userService.getUserByUserId(\r\n response.AssignedLenderUserId,\r\n );\r\n })\r\n .then((response) => {\r\n if (response != null) {\r\n this.assignedLenders[caseId] = response.FullName;\r\n } else {\r\n this.assignedLenders[caseId] = null;\r\n }\r\n })\r\n .catch(() => {\r\n this.assignedLenders[caseId] = null;\r\n });\r\n }\r\n }\r\n\r\n checkAssignedLender(selectedCase: CaseSummaryDTO) {\r\n if (\r\n selectedCase.ProductType == ProductTypeEnum.Development &&\r\n selectedCase.DealID == null &&\r\n selectedCase.CaseID != null\r\n ) {\r\n return this.assignedLenders[selectedCase.CaseID] != null;\r\n } else {\r\n return this.assignedLenders[selectedCase.DealID] != null;\r\n }\r\n }\r\n\r\n getLenderUsersList() {\r\n this.lenderList = [];\r\n this.lenderUsers?.forEach((user) => {\r\n if (user.IsLenderAdmin) {\r\n this.lenderList.push(user);\r\n } else {\r\n if (\r\n (user.LenderProductTypes & LenderProductTypeEnum.All) ==\r\n LenderProductTypeEnum.All\r\n ) {\r\n this.lenderList.push(user);\r\n }\r\n\r\n if (\r\n (user.LenderProductTypes &\r\n LenderProductTypeEnum.DevelopmentFinance) ==\r\n LenderProductTypeEnum.DevelopmentFinance &&\r\n this.actionItem.ProductType == ProductTypeEnum.Development\r\n ) {\r\n this.lenderList.push(user);\r\n }\r\n\r\n if (\r\n (user.LenderProductTypes & LenderProductTypeEnum.BridgingFinance) ==\r\n LenderProductTypeEnum.BridgingFinance &&\r\n (this.actionItem.ProductType == ProductTypeEnum.Bridging ||\r\n this.actionItem.ProductType ==\r\n ProductTypeEnum.BridgingPreconstruction ||\r\n this.actionItem.ProductType ==\r\n ProductTypeEnum.BridgingPurchaseOrRefinance ||\r\n this.actionItem.ProductType == ProductTypeEnum.BridgingRefurb ||\r\n this.actionItem.ProductType ==\r\n ProductTypeEnum.BridgingDeveloperExit)\r\n ) {\r\n this.lenderList.push(user);\r\n }\r\n\r\n if (\r\n (user.LenderProductTypes &\r\n LenderProductTypeEnum.CommercialMortgages) ==\r\n LenderProductTypeEnum.CommercialMortgages &&\r\n (this.actionItem.ProductType == ProductTypeEnum.CommercialAll ||\r\n this.actionItem.ProductType ==\r\n ProductTypeEnum.CommercialInvestment ||\r\n this.actionItem.ProductType ==\r\n ProductTypeEnum.CommercialOwnerOccupied)\r\n ) {\r\n this.lenderList.push(user);\r\n }\r\n }\r\n });\r\n }\r\n\r\n deleteSearch() {\r\n this.confirmSearchToDelete = false;\r\n this.isPageLoading = true;\r\n if (this.actionItem.isDevInputWithNoLogin) {\r\n //Introducer: Referred search, not claimed by introducee yet\r\n this.$DevelopmentInputWithNoLoginService\r\n .markasdeleted(this.actionItem.DevelopmentInputID)\r\n .then((success) => {\r\n this.getSearches(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n })\r\n .finally(() => {\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n });\r\n } else {\r\n if (\r\n this.actionItem.ProductType == ProductTypeEnum.Development &&\r\n this.actionItem.DevelopmentInputID\r\n ) {\r\n //Introducer: Referred search, claimed by introducee\r\n this.$DevelopmentInputService\r\n .markasdeleted(this.actionItem.DevelopmentInputID)\r\n .then((success) => {\r\n this.getSearches(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n })\r\n .finally(() => {\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n });\r\n } else {\r\n this.dealService\r\n .markasdeleted(this.actionItem.DealID)\r\n .then((success) => {\r\n this.getSearches(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n })\r\n .finally(() => {\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n });\r\n }\r\n }\r\n }\r\n\r\n cancelCopyProject() {\r\n this.confirmCopyProjectName = false;\r\n }\r\n\r\n copyProjectConfirmation(dataItem) {\r\n this.closeTileMenu();\r\n event.stopPropagation();\r\n this.actionItem = dataItem;\r\n\r\n this.newProjectName = this.actionItem.CaseName;\r\n\r\n // show popup input for new name\r\n this.confirmCopyProjectName = true;\r\n }\r\n\r\n copyProject() {\r\n this.confirmCopyProjectName = false;\r\n this.isPageLoading = true;\r\n\r\n if (\r\n this.actionItem.ProductType == ProductTypeEnum.Development &&\r\n this.actionItem.DevelopmentInputID\r\n ) {\r\n this.$DevelopmentInputService\r\n .copyCase(this.actionItem.DevelopmentInputID, this.newProjectName)\r\n .then((response) => {\r\n let newCaseId = response;\r\n if (newCaseId) {\r\n this.$applicantservice.copyShareholder(\r\n this.actionItem.CaseID,\r\n newCaseId,\r\n );\r\n this.getProjects(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n }\r\n })\r\n .finally(() => {\r\n this.getProjects(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n });\r\n } else {\r\n this.dealService\r\n .copyCase(\r\n this.actionItem.DealID,\r\n this.newProjectName,\r\n this.actionItem.ProductType,\r\n )\r\n .then((response) => {\r\n let newCaseId = response;\r\n if (newCaseId) {\r\n //TODO: On monday make getprojects use deal model\r\n this.getDealproject(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n }\r\n })\r\n .finally(() => {\r\n this.getProjects(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n });\r\n }\r\n }\r\n\r\n deleteProjectConfirmation(dataItem) {\r\n this.closeTileMenu();\r\n event.stopPropagation();\r\n this.actionItem = dataItem;\r\n\r\n this.confirmProjectToDelete = true;\r\n }\r\n\r\n deleteProject() {\r\n this.confirmProjectToDelete = false;\r\n\r\n if (\r\n this.actionItem.ProductType == ProductTypeEnum.Development &&\r\n this.actionItem.DevelopmentInputID\r\n ) {\r\n //Full case and Saved search\r\n this.$DevelopmentInputService\r\n .markasdeleted(this.actionItem.DevelopmentInputID)\r\n .then((success) => {\r\n if (this.actionItem.CaseID) {\r\n this.$CaseService\r\n .markasdeleted(this.actionItem.CaseID)\r\n .then((success) => { });\r\n }\r\n })\r\n .finally(() => {\r\n this.getProjects(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n });\r\n } else {\r\n this.dealService\r\n .markasdeleted(this.actionItem.DealID)\r\n .then((success) => { })\r\n .finally(() => {\r\n this.getProjects(\r\n this.selectedDashboardType == this.DashboardTypeEnum.Home\r\n ? this.homeScreenCount\r\n : 0,\r\n );\r\n this.actionItem = null;\r\n this.isPageLoading = false;\r\n });\r\n }\r\n }\r\n\r\n // START OF INTRODUCTIONS CODE - TO BE REVIEWED WHEN UI IS RE-WORKED\r\n\r\n introduceClient() {\r\n this.isProcessingSend = true;\r\n this.invite = {\r\n FirstName: this.clientFirstName,\r\n Email: this.clientEmail,\r\n LastName: this.clientSurname,\r\n InviteerUserId: this.currentUser.Id,\r\n UserId: null,\r\n PhoneNumber: this.clientPhoneNumber,\r\n Status: StatusEnum.Invited,\r\n } as InviteDTO;\r\n\r\n this.inviteService.addUpdate(this.invite).then((response) => {\r\n this.invitedUsers.push(response);\r\n\r\n this.$IntroducerService\r\n .introduceClient(\r\n response.FirstName,\r\n response.Email,\r\n response.LastName,\r\n response.PhoneNumber,\r\n response.guid,\r\n )\r\n .then((success) => {\r\n this.introduceClientModal = 2;\r\n this.isPageLoading = false;\r\n this.isProcessingSend = false;\r\n })\r\n .finally(() => {\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.clientPhoneNumber;\r\n });\r\n });\r\n }\r\n\r\n userLookup(userSearchTerm: string) {\r\n this.isPageLoading = true;\r\n this.$user\r\n .searchByEmail(userSearchTerm)\r\n .then((response) => {\r\n if (this.isBroker && this.currentUser.IsOrganisationAdmin) {\r\n this.userSearchResults = response.filter(\r\n (x) =>\r\n x.OrganisationReferralId == this.currentUser.OrganisationId ||\r\n x.OrganisationId == this.currentUser.OrganisationId,\r\n );\r\n } else if (this.isBroker) {\r\n this.userSearchResults = response.filter(\r\n (x) =>\r\n x.OrganisationReferralId == this.currentUser.OrganisationId &&\r\n !x.OrganisationId &&\r\n !x.IsOrganisationAdmin,\r\n );\r\n } else {\r\n this.userSearchResults = response;\r\n }\r\n })\r\n .finally(() => {\r\n this.isPageLoading = false;\r\n });\r\n }\r\n\r\n exitClientView() {\r\n this.selectedClientName = null;\r\n this.showHomeDashboard();\r\n }\r\n\r\n deleteUnsavedIntroducedSearch(loanCriteriaId: number, index: number) {\r\n //Introducer: Referred search, not claimed by introducee yet\r\n this.$DevelopmentInputWithNoLoginService\r\n .markasdeleted(loanCriteriaId)\r\n .then((success) => {\r\n this.unsavedIntroducedSearches.splice(index, 1);\r\n });\r\n }\r\n\r\n deleteSavedIntroducedSearch(loanCriteriaId: number, index: number) {\r\n //Introducer: Referred search, claimed by introducee\r\n this.$DevelopmentInputService\r\n .markasdeleted(loanCriteriaId)\r\n .then((success) => {\r\n this.savedIntroducedSearches.splice(index, 1);\r\n });\r\n }\r\n\r\n copyLinkToClipboard() {\r\n this.$IntroducerService\r\n .copyLinkToClipboard(this.currentUser.Id)\r\n .then((response) => {\r\n //this.link = response.toString();\r\n navigator.clipboard.writeText(response.toString());\r\n this.introduceClientModal = 7;\r\n });\r\n }\r\n\r\n sendLinkToUser() {\r\n this.$IntroducerService\r\n .sendLinkToUser(\r\n this.currentUser.FirstName,\r\n this.currentUser.Email,\r\n this.currentUser.Id,\r\n )\r\n .then((success) => {\r\n this.introduceClientModal = 6;\r\n });\r\n }\r\n\r\n registerIntroducer() {\r\n this.$location.path(\"/registerintroducer\");\r\n }\r\n\r\n inviteBorrower() {\r\n this.isProcessingSend = true;\r\n this.invite = {\r\n FirstName: this.clientFirstName,\r\n Email: this.clientEmail,\r\n LastName: this.clientSurname,\r\n InviteerUserId: this.currentUser.Id,\r\n UserId: null,\r\n PhoneNumber: this.clientPhoneNumber,\r\n Status: StatusEnum.Invited,\r\n } as InviteDTO;\r\n\r\n this.inviteService.addUpdate(this.invite).then((response) => {\r\n this.invitedUsers.push(response);\r\n\r\n this.$user.GetUserOrganisation().then((result) => {\r\n if (this.invite && result) {\r\n this.organisationService\r\n .inviteBorrowers(this.invite, result.UniqueRef)\r\n .then((success) => {\r\n this.introduceClientModal = 9;\r\n this.dataLoading = false;\r\n })\r\n .finally(() => {\r\n this.introduceClientModal = 9;\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.clientPhoneNumber;\r\n this.isProcessingSend = false;\r\n });\r\n }\r\n });\r\n });\r\n }\r\n\r\n // END OF INTRODUCTIONS CODE - ALL INTRODUCTIONS CODE TO BE REVIEWED WHEN UI IS RE-WORKED\r\n\r\n openShareSearchModal(item: CaseSummaryDTO) {\r\n event.stopPropagation();\r\n this.closeTileMenu();\r\n\r\n // Only get the broker's/admin's users if we haven't already got it\r\n if (!this.existingUsers) {\r\n this.roleService\r\n .isBrokerOrABove()\r\n .then((isBrokerOrAbove: boolean) => {\r\n if (isBrokerOrAbove) {\r\n this.getUserSummariesForBrokerOrAdmin();\r\n }\r\n });\r\n }\r\n\r\n if (\r\n item.ProductType == ProductTypeEnum.Development &&\r\n item.DevelopmentInputID\r\n ) {\r\n this.isBridging = false;\r\n if (item.isDevInputWithNoLogin) {\r\n /** This will check if the result shared with new user is active */\r\n this.$DevelopmentInputWithNoLoginService\r\n .isResultActive(item.UniqueRef)\r\n .then((results) => {\r\n if (!results) {\r\n this.displayMsg = `Changes have been made to this search by your client, your user dashboard will now refresh`;\r\n this.showShareResults = 5;\r\n } else {\r\n this.$DevelopmentInputWithNoLoginService\r\n .fetch(item.DevelopmentInputID)\r\n .then((response) => {\r\n this.selectedSearch = item;\r\n this.loanCriteria = response;\r\n this.selectedResult = item.DevelopmentInputID;\r\n this.shareSearchModal = 3;\r\n this.newSearch = true;\r\n this.sharedSearch = false;\r\n this.existingborrower = null;\r\n\r\n if (this.loanCriteria.ShowLenderNamesToBorrower == null) {\r\n this.organisationService.getOrganisation().then((org) => {\r\n this.loanCriteria.ShowLenderNamesToBorrower =\r\n org.ShowLenderNames;\r\n });\r\n }\r\n\r\n if (\r\n (this.roleService.isAdminUser || this.isBroker) &&\r\n item.ClientEmail != this.currentUser.UserName\r\n ) {\r\n this.clientFirstName = item.ClientFirstName;\r\n this.clientSurname = item.ClientSurname;\r\n this.clientEmail = item.ClientEmail;\r\n this.sharedSearch = true;\r\n } else {\r\n this.clientFirstName = \"\";\r\n this.clientSurname = \"\";\r\n this.clientEmail = \"\";\r\n this.clientPhoneNumber = \"\";\r\n }\r\n });\r\n }\r\n });\r\n } else {\r\n this.$DevelopmentInputService\r\n .fetch(item.DevelopmentInputID)\r\n .then((response) => {\r\n this.selectedSearch = item;\r\n this.loanCriteria = response;\r\n this.selectedResult = item.DevelopmentInputID;\r\n this.shareSearchModal = 3;\r\n this.newSearch = true;\r\n this.sharedSearch = false;\r\n this.existingborrower = null;\r\n\r\n if (this.loanCriteria.ShowLenderNamesToBorrower == null) {\r\n this.organisationService.getOrganisation().then((org) => {\r\n this.loanCriteria.ShowLenderNamesToBorrower =\r\n org.ShowLenderNames;\r\n });\r\n }\r\n\r\n if (\r\n (this.roleService.isAdminUser || this.isBroker) &&\r\n item.ClientEmail != this.currentUser.UserName\r\n ) {\r\n this.clientFirstName = item.ClientFirstName;\r\n this.clientSurname = item.ClientSurname;\r\n this.clientEmail = item.ClientEmail;\r\n this.sharedSearch = true;\r\n } else {\r\n this.clientFirstName = \"\";\r\n this.clientSurname = \"\";\r\n this.clientEmail = \"\";\r\n this.clientPhoneNumber = \"\";\r\n }\r\n });\r\n }\r\n } else {\r\n this.isBridging = true;\r\n this.selectedSearch = item;\r\n this.selectedResult = item.DevelopmentInputID;\r\n this.shareSearchModal = 3;\r\n this.newSearch = true;\r\n this.sharedSearch = false;\r\n this.existingborrower = null;\r\n\r\n this.clientService\r\n .fetchListByDealId(item.DealID)\r\n .then((dealClients: ClientDTO[]) => {\r\n this.shareDealDto = {\r\n DealId: item.DealID,\r\n DealName: item.CaseName,\r\n ShowLenderNamesAndLogos: false,\r\n EmailLinkToClient: false,\r\n AccessLevel: CaseAccessLevelEnum.FullAccess,\r\n IsApplicant: true,\r\n IsPrimary: true,\r\n } as ShareDealDTO;\r\n\r\n if (dealClients && dealClients.length > 0) {\r\n var client = dealClients[0]; // TODO - always want to assume there's one for now until there's a redesign of sharing\r\n\r\n this.shareDealDto.ClientDto = {\r\n FirstName: client.FirstName,\r\n LastName: client.LastName,\r\n Email: client.Email,\r\n PhoneNumber: client.PhoneNumber,\r\n ClientUserId: client.ClientUserId,\r\n } as ClientDTO;\r\n\r\n this.sharedSearch = true;\r\n } else {\r\n this.shareDealDto.ClientDto = {\r\n FirstName: \"\",\r\n LastName: \"\",\r\n Email: \"\",\r\n PhoneNumber: \"\",\r\n } as ClientDTO;\r\n }\r\n });\r\n }\r\n }\r\n\r\n /*\r\n introducerSendResultsToClient(notifyBorrower: boolean = true) {\r\n this.dataLoading = true;\r\n this.$IntroducerService.sendResultsToClient(this.selectedSearch, this.clientFirstName, this.clientSurname, this.clientEmail, notifyBorrower).then((success) => {\r\n this.shareSearchModal = 4;\r\n }).catch(reason => {\r\n this.shareSearchErrorDisplayed = true;\r\n }).finally(() => {\r\n this.dataLoading = false;\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.selectedSearch;\r\n });\r\n }*/\r\n\r\n introducerRefreshSearchesAndClients() {\r\n this.getIntroducedSearches(this.currentUser.RegisteredIntroducerId);\r\n this.clientAdminTools = true;\r\n }\r\n\r\n updateIntroducedClientList() {\r\n this.$user.getintroducees(this.currentUser.Id).then((introducedUsers) => {\r\n this.introducedUsers = introducedUsers;\r\n });\r\n }\r\n\r\n closeIntroducerClientModal() {\r\n this.introduceClientModal = null;\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n this.introducerErrorDisplayed = false;\r\n }\r\n\r\n closeSearchSearchModal() {\r\n this.shareSearchModal = null;\r\n this.shareSearchErrorDisplayed = false;\r\n delete this.selectedSearch;\r\n }\r\n\r\n isProjectClickable(isInvitedToCase: boolean) {\r\n // To be able to click on a project you must have one of the following:\r\n // 1. Paid up subcription\r\n // 2. Pre-cancel subscription i.e. it's been cancelled but it is still active until the end of the payment period\r\n // 3. subscription Payment processing i.e. they've signed up but the payment is still being processed e.g. DDs\r\n // 4. be a lender (no license required)\r\n // 5. be an admin (no license required)\r\n // 6. be invited to the case\r\n\r\n if (\r\n this.currentUser.SubscriptionStatus == LicenseMasterStatusEnum.PaidUp ||\r\n this.currentUser.SubscriptionStatus ==\r\n LicenseMasterStatusEnum.PreCancel ||\r\n this.currentUser.SubscriptionStatus ==\r\n LicenseMasterStatusEnum.PaymentProcessing ||\r\n this.roleService.IsLender ||\r\n this.roleService.IsAdminUser ||\r\n isInvitedToCase == true\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n isSearchClickable(isOwner: boolean) {\r\n // To be able to click on a project you must have one of the following:\r\n // 1. Paid up subcription\r\n // 2. Pre-cancel subscription i.e. it's been cancelled but it is still active until the end of the payment period\r\n // 3. subscription Payment processing i.e. they've signed up but the payment is still being processed e.g. DDs\r\n // 4. be a lender (no license required)\r\n // 5. be an admin (no license required)\r\n // 6. be an owner and a client user - we're assuming here this will identify an invited user. This may need re-work\r\n\r\n if (\r\n this.currentUser.SubscriptionStatus == LicenseMasterStatusEnum.PaidUp ||\r\n this.currentUser.SubscriptionStatus ==\r\n LicenseMasterStatusEnum.PreCancel ||\r\n this.currentUser.SubscriptionStatus ==\r\n LicenseMasterStatusEnum.PaymentProcessing ||\r\n this.roleService.IsLender ||\r\n this.roleService.IsAdminUser ||\r\n (isOwner == true && this.roleService.IsClient)\r\n ) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n signout() {\r\n this.authService.logout(true);\r\n }\r\n\r\n getStatusTextForLender(\r\n caseLenderState: CaseLenderStateEnum,\r\n IsBidAccepted: boolean,\r\n ): string {\r\n var statusText = this.caseLenderService.getStatusTextForLender(\r\n caseLenderState,\r\n IsBidAccepted,\r\n );\r\n return statusText;\r\n }\r\n\r\n /** closes share pop up*/\r\n cancelNewSearch() {\r\n this.newSearch = false;\r\n this.clearInputFields();\r\n }\r\n\r\n clearInputFields() {\r\n this.clientFirstName = null;\r\n this.clientEmail = null;\r\n this.clientSurname = null;\r\n this.clientPhoneNumber = null;\r\n this.showClientDetails = false;\r\n this.selecteduserName = null;\r\n }\r\n\r\n getUserSummariesForBrokerOrAdmin() {\r\n this.$user\r\n .getUserSummariesForBrokerOrAdmin()\r\n .then((response) => {\r\n this.existingUsers = response;\r\n })\r\n .finally(() => { });\r\n }\r\n\r\n getBrokerBelongToOrganisation(orgId): void {\r\n this.userService\r\n .getAllOrganisationMembers(orgId)\r\n .then((orgBrokers: ApplicationUserDTO[]) => {\r\n this.licensedOrganisationBrokers = orgBrokers.filter(\r\n (x) => x.SubscriptionStatus > 0,\r\n );\r\n });\r\n }\r\n\r\n viewClientsDashboardForNewSearch(userName: string) {\r\n //Look up client's account details\r\n this.$user.searchByEmail(userName).then((users) => {\r\n if (\r\n this.selectedSearch.ProductType == ProductTypeEnum.Development &&\r\n this.selectedSearch.DealID == null\r\n ) {\r\n this.clientFirstName = users[0].FirstName;\r\n this.clientEmail = users[0].Email;\r\n this.clientSurname = users[0].LastName;\r\n this.clientPhoneNumber = users[0].PhoneNumber;\r\n this.clientId = users[0].Id;\r\n this.showClientDetails = true;\r\n } else {\r\n this.shareDealDto.IsApplicant = true;\r\n this.shareDealDto.IsPrimary = true;\r\n this.shareDealDto.ClientDto.FirstName = users[0].FirstName;\r\n this.shareDealDto.ClientDto.Email = users[0].Email;\r\n this.shareDealDto.ClientDto.LastName = users[0].LastName;\r\n this.shareDealDto.ClientDto.PhoneNumber = users[0].PhoneNumber;\r\n this.shareDealDto.ClientDto.ClientUserId = users[0].Id;\r\n this.showClientDetails = true;\r\n }\r\n });\r\n }\r\n\r\n sendResultsToClient(notifyBorrower) {\r\n this.dataLoading = true;\r\n this.newSearch = false;\r\n this.existingborrower = null;\r\n this.showClientDetails = false;\r\n\r\n if (\r\n this.selectedSearch.ProductType == ProductTypeEnum.Development &&\r\n this.selectedSearch.DevelopmentInputID\r\n ) {\r\n this.userService\r\n .getUserDetailsByEmailIfExists(this.clientEmail)\r\n .then((user: ApplicationUserDTO) => {\r\n if (user == null) {\r\n this.loanCriteria.UserId = null;\r\n this.$IntroducerService\r\n .sendResultsToClient(\r\n this.loanCriteria,\r\n this.clientFirstName,\r\n this.clientSurname,\r\n this.clientEmail,\r\n notifyBorrower,\r\n this.clientPhoneNumber,\r\n )\r\n .then((success) => {\r\n this.showShareResults = 2;\r\n });\r\n } else {\r\n this.clientId = user.Id;\r\n this.$DevelopmentInputService\r\n .sendResultsToExistingClient(\r\n this.loanCriteria,\r\n this.clientFirstName,\r\n this.clientSurname,\r\n this.clientEmail,\r\n this.clientId,\r\n notifyBorrower,\r\n this.clientPhoneNumber,\r\n )\r\n .then((success) => {\r\n this.showShareResults = 3;\r\n });\r\n }\r\n })\r\n .finally(() => {\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.clientPhoneNumber;\r\n delete this.clientId;\r\n this.dataLoading = false;\r\n });\r\n } else {\r\n this.dealService\r\n .shareDealWithClient(this.shareDealDto)\r\n .then(() => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.shareDealDto.ClientDto.FirstName +\r\n \" \" +\r\n this.shareDealDto.ClientDto.LastName;\r\n this.showShareResults = 4;\r\n })\r\n .finally(() => {\r\n delete this.shareDealDto;\r\n this.dataLoading = false;\r\n });\r\n }\r\n }\r\n\r\n /* sendResultsToExistingClient(notifyBorrower: boolean = true, showMsgAfterResultSent: boolean = true) {\r\n this.newSearch = false;\r\n this.existingborrower = null;\r\n this.showClientDetails = false;\r\n this.$DevelopmentInputService.sendResultsToExistingClient(this.loanCriteria, this.clientFirstName, this.clientSurname, this.clientEmail, this.clientId, notifyBorrower, this.clientPhoneNumber).then((success) => {\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.clientPhoneNumber;\r\n delete this.clientId;\r\n this.showShareResults = 3;\r\n });\r\n }\r\n \r\n \r\n introducerSendResultsToClient(notifyBorrower: boolean = true) {\r\n this.newSearch = false;\r\n this.existingborrower = null;\r\n this.showClientDetails = false;\r\n \r\n // remove the user id because otherwise the client won't be able to see the search on their dashboard\r\n this.loanCriteria.UserId = null;\r\n \r\n this.$IntroducerService.sendResultsToClient(this.loanCriteria, this.clientFirstName, this.clientSurname, this.clientEmail, notifyBorrower, this.clientPhoneNumber).then((success) => {\r\n delete this.clientFirstName;\r\n delete this.clientEmail;\r\n delete this.clientSurname;\r\n delete this.clientPhoneNumber;\r\n if (this.isBroker) {\r\n this.showShareResults = 2;\r\n } else {\r\n this.showShareResults = 1;\r\n }\r\n });\r\n }\r\n */\r\n\r\n sendShareSearchEmailToClient() {\r\n this.dataLoading = true;\r\n\r\n if (\r\n this.selectedSearch.ProductType == ProductTypeEnum.Development &&\r\n this.selectedSearch.DevelopmentInputID\r\n ) {\r\n if (\r\n this.loanCriteria.IntroduceeFirstName == null ||\r\n this.loanCriteria.IntroduceeSurname == null\r\n ) {\r\n this.loanCriteria.IntroduceeFirstName = this.clientFirstName;\r\n this.loanCriteria.IntroduceeSurname = this.clientSurname;\r\n }\r\n if (this.selectedSearch.isDevInputWithNoLogin) {\r\n this.$DevelopmentInputWithNoLoginService\r\n .sendEmailToNewUser(\r\n this.loanCriteria.UniqueRef,\r\n this.loanCriteria.ShowLenderNamesToBorrower,\r\n true,\r\n )\r\n .then((response) => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.loanCriteria.IntroduceeFirstName +\r\n \" \" +\r\n this.loanCriteria.IntroduceeSurname;\r\n this.newSearch = false;\r\n this.showShareResults = 4;\r\n this.dataLoading = false;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n this.newSearch = false;\r\n this.showShareResults = 4;\r\n this.dataLoading = false;\r\n })\r\n .finally(() => {\r\n delete this.selectedSearch;\r\n delete this.loanCriteria;\r\n delete this.selectedResult;\r\n delete this.shareSearchModal;\r\n delete this.existingborrower;\r\n delete this.clientFirstName;\r\n delete this.clientSurname;\r\n delete this.clientEmail;\r\n });\r\n } else {\r\n this.$DevelopmentInputService\r\n .sendEmailToExistingUser(\r\n this.loanCriteria.Id,\r\n this.loanCriteria.ShowLenderNamesToBorrower,\r\n true,\r\n )\r\n .then((response) => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.loanCriteria.IntroduceeFirstName +\r\n \" \" +\r\n this.loanCriteria.IntroduceeSurname;\r\n this.newSearch = false;\r\n this.showShareResults = 4;\r\n this.dataLoading = false;\r\n })\r\n .catch((error) => {\r\n this.displayMsg = \"Sorry, something went wrong. Please try again.\";\r\n this.newSearch = false;\r\n this.showShareResults = 4;\r\n this.dataLoading = false;\r\n });\r\n }\r\n } else {\r\n this.shareDealDto.EmailLinkToClient = true;\r\n this.dealService\r\n .shareDealWithClient(this.shareDealDto)\r\n .then(() => {\r\n this.displayMsg =\r\n \"Search results have been sent to \" +\r\n this.shareDealDto.ClientDto.FirstName +\r\n \" \" +\r\n this.shareDealDto.ClientDto.LastName;\r\n this.newSearch = false;\r\n this.showShareResults = 4;\r\n this.dataLoading = false;\r\n })\r\n .finally(() => {\r\n delete this.selectedSearch;\r\n delete this.loanCriteria;\r\n delete this.selectedResult;\r\n delete this.shareSearchModal;\r\n delete this.existingborrower;\r\n delete this.shareDealDto;\r\n });\r\n }\r\n }\r\n\r\n reloadPage() {\r\n window.location.reload();\r\n }\r\n\r\n viewClientsDashboard(userName: string) {\r\n //Look up client's account details\r\n this.dataLoading = true;\r\n this.$user.searchByEmail(userName).then((users) => {\r\n this.showHomeDashboard();\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n sendMessageToBrokerAdmin(message) {\r\n this.dataLoading = true;\r\n this.borrowerMessage = null;\r\n this.organisationService\r\n .sendBorrowerMessageToOrganisationAdmin(\r\n this.currentUser.DefaultBrokerOrganisationId,\r\n message,\r\n this.currentUser.FirstName,\r\n this.currentUser.LastName,\r\n this.currentUser.Email,\r\n ProductTypeEnum.Development,\r\n \"USERDASHBOARD\",\r\n )\r\n .then((results) => {\r\n if (results) {\r\n this.displayMsg = `Message has been sent successfully.`;\r\n this.showMessageToborrower = true;\r\n this.showContactBrokerModal = false;\r\n } else {\r\n this.displayMsg = `There is problem sending a message, Please try later.`;\r\n this.showMessageToborrower = true;\r\n this.showContactBrokerModal = false;\r\n }\r\n })\r\n .finally(() => {\r\n this.dataLoading = false;\r\n });\r\n }\r\n\r\n closeDeletedSearchMessageModal() {\r\n this.showDeletedSearchMessageModal = false;\r\n this.showMessageToborrower = false;\r\n this.showContactBrokerModal = false;\r\n this.displayMsg = null;\r\n sessionStorage.removeItem(\"returningFromdeletedSearch\");\r\n }\r\n\r\n /**\r\n * Toggles the display of the context menu on the tile for searches/cases\r\n * @param id\r\n */\r\n toggleTileMenu(id) {\r\n event.stopPropagation();\r\n this.closeAddMenu();\r\n this.cardWithOpenMenu.id = this.cardWithOpenMenu.id == id ? null : id;\r\n }\r\n\r\n /**\r\n * Toggles the display of the Add Item menu\r\n * @param event\r\n */\r\n toggleAddMenu(event) {\r\n event.stopPropagation();\r\n\r\n if (this.isBroker && !this.currentUser.HasActiveSubscription) {\r\n return;\r\n }\r\n this.closeTileMenu();\r\n\r\n var menu = document\r\n .getElementsByClassName(\"new-item-menu\")\r\n .item(0) as HTMLElement;\r\n\r\n if (menu && (menu.style.display == \"none\" || menu.style.display == \"\")) {\r\n var boundingRect = event.target.getBoundingClientRect();\r\n var offsetHeight = event.target.offsetHeight;\r\n\r\n menu.style.display = \"flex\";\r\n menu.style.left = boundingRect.left - menu.clientWidth - 10 + \"px\";\r\n menu.style.bottom = offsetHeight + \"px\";\r\n } else {\r\n if (menu) {\r\n menu.style.display = \"none\";\r\n }\r\n }\r\n }\r\n\r\n /**Closes the context menu on search/case tiles */\r\n closeTileMenu() {\r\n this.cardWithOpenMenu.id = null;\r\n }\r\n\r\n /**Closes the Add new item menu */\r\n closeAddMenu() {\r\n var menu = document\r\n .getElementsByClassName(\"new-item-menu\")\r\n .item(0) as HTMLElement;\r\n\r\n if (menu) {\r\n menu.style.display = \"none\";\r\n }\r\n }\r\n\r\n /**Closes all context menus */\r\n closeContextMenus() {\r\n this.closeTileMenu();\r\n this.closeAddMenu();\r\n }\r\n\r\n getProductTypeText(\r\n productType: ProductTypeEnum,\r\n isRegulatedBridge: boolean = false,\r\n ) {\r\n if (isRegulatedBridge) {\r\n return \"regulated bridge\";\r\n } else {\r\n var productTypeInfo = this.productTypeOptions.find(\r\n (p) => p.key == productType,\r\n );\r\n\r\n if (productTypeInfo) {\r\n return productTypeInfo.displayName;\r\n }\r\n }\r\n\r\n return \"\";\r\n }\r\n\r\n /** Determines whether to show the \"no searches\" message on the user dashboard */\r\n showNoSearchesMessage(): boolean {\r\n return this.searches?.length == 0 && !this.isSearchesLoading;\r\n }\r\n\r\n /** Determines whether to show the \"no cases\" message on the user dashboard */\r\n showNoCasesMessage(): boolean {\r\n if (this.selectedNavMenu == this.NavMenuEnum.DevelopmentFinance) {\r\n return this.projects.length == 0 && !this.isDevFinanceProjectsLoading;\r\n } else if (this.selectedNavMenu == this.NavMenuEnum.BridgingFinance) {\r\n return this.projects.length == 0 && !this.isBridgingPreConProjectsLoading;\r\n } else if (this.selectedNavMenu == this.NavMenuEnum.CommercialMortgages) {\r\n return this.projects.length == 0 && !this.isCommercialProjectsLoading;\r\n } else if (\r\n this.selectedNavMenu == this.NavMenuEnum.Home &&\r\n !this.isAllProjectsLoading\r\n ) {\r\n return this.projects.length == 0 && !this.isAllProjectsLoading;\r\n }\r\n }\r\n\r\n /**Determines whether to show the case loading spinner */\r\n showCasesLoadingSpinner(): boolean {\r\n if (this.selectedNavMenu == this.NavMenuEnum.DevelopmentFinance) {\r\n return !this.projects || this.isDevFinanceProjectsLoading;\r\n } else if (this.selectedNavMenu == this.NavMenuEnum.BridgingFinance) {\r\n return !this.projects || this.isBridgingPreConProjectsLoading;\r\n } else if (this.selectedNavMenu == this.NavMenuEnum.CommercialMortgages) {\r\n return !this.projects || this.isCommercialProjectsLoading;\r\n } else if (this.selectedNavMenu == this.NavMenuEnum.Home) {\r\n return !this.projects || this.isAllProjectsLoading;\r\n }\r\n }\r\n\r\n /** Determines whether to show the list of Case cards*/\r\n showCaseCards(): boolean {\r\n return this.projects != null && this.projects != undefined;\r\n }\r\n\r\n returnCaseOrDealId(item: CaseSummaryDTO): number {\r\n if (item.ProductType == ProductTypeEnum.Development && item.CaseID) {\r\n return item.CaseID;\r\n } else {\r\n return item.DealID;\r\n }\r\n }\r\n\r\n returnSearchOrDealId(item: CaseSummaryDTO): number {\r\n if (\r\n item.ProductType == ProductTypeEnum.Development &&\r\n item.DevelopmentInputID\r\n ) {\r\n return item.DevelopmentInputID;\r\n } else {\r\n return item.DealID;\r\n }\r\n }\r\n\r\n setHasBridgingAndHasCommercialValue(): void {\r\n this.organisationService.getOrganisationProductAccess().then((response) => {\r\n this.hasBridging = response.HasBridging;\r\n this.hasCommercial = response.HasCommercial;\r\n this.isDeallockerIntegrationEnabled = response.IsDeallockerIntegrationEnabled;\r\n });\r\n }\r\n\r\n currentLenderProductType(): void {\r\n this.hideBridgingMenu = true;\r\n this.hideDevfinanceMenu = true;\r\n this.hideCommercialMenu = true;\r\n\r\n this.$lenderService.getLenderProductTypes().then((response) => {\r\n if (\r\n this.currentUser != null &&\r\n this.currentUser.LenderProductTypes != null\r\n ) {\r\n // When the current user is a lender admin then they should see all product types that the lender has\r\n if (this.currentUser.IsLenderAdmin) {\r\n if (response == LenderProductTypeEnum.All) {\r\n this.hideBridgingMenu = false;\r\n this.hideDevfinanceMenu = false;\r\n this.hideCommercialMenu = false;\r\n\r\n return;\r\n }\r\n\r\n if (\r\n (response & LenderProductTypeEnum.DevelopmentFinance) ==\r\n LenderProductTypeEnum.DevelopmentFinance\r\n ) {\r\n this.hideDevfinanceMenu = false;\r\n }\r\n\r\n if (\r\n (response & LenderProductTypeEnum.BridgingFinance) ==\r\n LenderProductTypeEnum.BridgingFinance\r\n ) {\r\n this.hideBridgingMenu = false;\r\n }\r\n\r\n if (\r\n (response & LenderProductTypeEnum.CommercialMortgages) ==\r\n LenderProductTypeEnum.CommercialMortgages\r\n ) {\r\n this.hideCommercialMenu = false;\r\n }\r\n\r\n return;\r\n } else {\r\n // If the lender has all product types and the lender user has been set up to see all products types\r\n if (\r\n response == LenderProductTypeEnum.All &&\r\n (this.currentUser.LenderProductTypes & LenderProductTypeEnum.All) ==\r\n LenderProductTypeEnum.All\r\n ) {\r\n this.hideBridgingMenu = false;\r\n this.hideDevfinanceMenu = false;\r\n this.hideCommercialMenu = false;\r\n\r\n return;\r\n }\r\n\r\n if (\r\n (response & LenderProductTypeEnum.DevelopmentFinance) ==\r\n LenderProductTypeEnum.DevelopmentFinance &&\r\n ((this.currentUser.LenderProductTypes &\r\n LenderProductTypeEnum.DevelopmentFinance) ==\r\n LenderProductTypeEnum.DevelopmentFinance ||\r\n (this.currentUser.LenderProductTypes &\r\n LenderProductTypeEnum.All) ==\r\n LenderProductTypeEnum.All)\r\n ) {\r\n this.hideDevfinanceMenu = false;\r\n }\r\n\r\n if (\r\n (response & LenderProductTypeEnum.BridgingFinance) ==\r\n LenderProductTypeEnum.BridgingFinance &&\r\n ((this.currentUser.LenderProductTypes &\r\n LenderProductTypeEnum.BridgingFinance) ==\r\n LenderProductTypeEnum.BridgingFinance ||\r\n (this.currentUser.LenderProductTypes &\r\n LenderProductTypeEnum.All) ==\r\n LenderProductTypeEnum.All)\r\n ) {\r\n this.hideBridgingMenu = false;\r\n }\r\n\r\n if (\r\n (response & LenderProductTypeEnum.CommercialMortgages) ==\r\n LenderProductTypeEnum.CommercialMortgages &&\r\n ((this.currentUser.LenderProductTypes &\r\n LenderProductTypeEnum.CommercialMortgages) ==\r\n LenderProductTypeEnum.CommercialMortgages ||\r\n (this.currentUser.LenderProductTypes &\r\n LenderProductTypeEnum.All) ==\r\n LenderProductTypeEnum.All)\r\n ) {\r\n this.hideCommercialMenu = false;\r\n }\r\n\r\n //if (response == LenderProductTypeEnum.All && (this.currentUser.LenderProductTypes & LenderProductTypeEnum.BridgingFinance) == LenderProductTypeEnum.BridgingFinance && (this.currentUser.LenderProductTypes & LenderProductTypeEnum.DevelopmentFinance) == LenderProductTypeEnum.DevelopmentFinance && (this.currentUser.LenderProductTypes & LenderProductTypeEnum.CommercialMortgages) == LenderProductTypeEnum.CommercialMortgages) {\r\n // this.hideBridgingMenu = false;\r\n // this.hideDevfinanceMenu = false;\r\n // this.hideCommercialMenu = false;\r\n //} else if ((response == LenderProductTypeEnum.All && (this.currentUser.LenderProductTypes & LenderProductTypeEnum.All) == LenderProductTypeEnum.All) || (response == LenderProductTypeEnum.All && this.currentUser.IsLenderAdmin)) {\r\n // this.hideBridgingMenu = false;\r\n // this.hideDevfinanceMenu = false;\r\n // this.hideCommercialMenu = false;\r\n //} else if ((response == LenderProductTypeEnum.BridgingFinance || response == LenderProductTypeEnum.All) && ((this.currentUser.LenderProductTypes & LenderProductTypeEnum.BridgingFinance) == LenderProductTypeEnum.BridgingFinance || this.currentUser.IsLenderAdmin)) {\r\n // this.hideBridgingMenu = false;\r\n //} else if ((response == LenderProductTypeEnum.DevelopmentFinance || response == LenderProductTypeEnum.All) && ((this.currentUser.LenderProductTypes & LenderProductTypeEnum.DevelopmentFinance) == LenderProductTypeEnum.DevelopmentFinance || this.currentUser.IsLenderAdmin)) {\r\n // this.hideDevfinanceMenu = false;\r\n //} else if ((response == LenderProductTypeEnum.CommercialMortgages || response == LenderProductTypeEnum.All) && ((this.currentUser.LenderProductTypes & LenderProductTypeEnum.CommercialMortgages) == LenderProductTypeEnum.CommercialMortgages || this.currentUser.IsLenderAdmin)) {\r\n // this.hideCommercialMenu = false;\r\n //}\r\n //else if (response == LenderProductTypeEnum.DevelopmentFinance && ((this.currentUser.LenderProductTypes & LenderProductTypeEnum.All) == LenderProductTypeEnum.All || this.currentUser.IsLenderAdmin)) {\r\n // this.hideDevfinanceMenu = false;\r\n //} else if (response == LenderProductTypeEnum.BridgingFinance && ((this.currentUser.LenderProductTypes & LenderProductTypeEnum.All) == LenderProductTypeEnum.All || this.currentUser.IsLenderAdmin)) {\r\n // this.hideBridgingMenu = false;\r\n //} else if (response == LenderProductTypeEnum.CommercialMortgages && ((this.currentUser.LenderProductTypes & LenderProductTypeEnum.All) == LenderProductTypeEnum.All || this.currentUser.IsLenderAdmin)) {\r\n // this.hideCommercialMenu = false;\r\n //}\r\n }\r\n }\r\n });\r\n }\r\n\r\n showViewButton(productType: ProductTypeEnum) {\r\n if (\r\n productType == ProductTypeEnum.Development ||\r\n ((productType == ProductTypeEnum.Bridging ||\r\n productType == ProductTypeEnum.BridgingPreconstruction ||\r\n productType == ProductTypeEnum.BridgingPurchaseOrRefinance ||\r\n productType == ProductTypeEnum.BridgingRefurb ||\r\n productType == ProductTypeEnum.BridgingDeveloperExit) &&\r\n this.hasBridging) ||\r\n ((productType == ProductTypeEnum.CommercialAll ||\r\n productType == ProductTypeEnum.CommercialInvestment ||\r\n productType == ProductTypeEnum.CommercialOwnerOccupied) &&\r\n this.hasCommercial)\r\n ) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n onPlusButtonHover(event) {\r\n if (this.isBroker) {\r\n event.currentTarget.children[0].style.display = \"\";\r\n }\r\n }\r\n\r\n goToDealForum(item) {\r\n if (this.isLender) {\r\n if (this.goToDealForumClicked) {\r\n sessionStorage.setItem(\"lenderTask\", \"feedback\");\r\n this.goToDealForumClicked = false;\r\n if (item.ProductType == ProductTypeEnum.Development) {\r\n if (item.DealID) {\r\n this.$location.path(\r\n \"/devfinanceheadsofterm/\" + item.DealID + \"/\" + item.DealLenderId,\r\n );\r\n } else {\r\n this.$location.path(\r\n \"/headsofterm/\" + item.CaseID + \"/\" + item.DealLenderId,\r\n );\r\n }\r\n } else if (\r\n item.ProductType == ProductTypeEnum.CommercialAll ||\r\n item.ProductType == ProductTypeEnum.CommercialInvestment ||\r\n item.ProductType == ProductTypeEnum.CommercialOwnerOccupied\r\n ) {\r\n this.$location.path(\r\n \"/commercialheadsofterm/\" + item.DealID + \"/\" + item.DealLenderId,\r\n );\r\n } else if (\r\n item.ProductType == ProductTypeEnum.BridgingPreconstruction ||\r\n item.ProductType == ProductTypeEnum.BridgingPurchaseOrRefinance ||\r\n item.ProductType == ProductTypeEnum.BridgingDeveloperExit ||\r\n item.ProductType == ProductTypeEnum.BridgingRefurb ||\r\n item.ProductType == ProductTypeEnum.Bridging\r\n ) {\r\n this.$location.path(\r\n \"/bridgingheadsofterm/\" + item.DealID + \"/\" + item.DealLenderId,\r\n );\r\n }\r\n } else {\r\n this.goToDealForumClicked = true;\r\n this.lenderSelectedProject = { ...item };\r\n this.showLenderTerms = true;\r\n }\r\n } else {\r\n if (\r\n item.ProductType == ProductTypeEnum.Development &&\r\n item.DealID == null\r\n ) {\r\n this.$location.path(\"/lending/\" + item.CaseID);\r\n } else {\r\n this.$location.path(\"/dealforum/\" + item.DealID);\r\n }\r\n }\r\n }\r\n\r\n getTotalUnreadMessagesPerAppraisal() {\r\n if (this.projects && this.projects.length > 0) {\r\n let appraisalList = this.projects.map((obj) => ({\r\n AppraisalId: obj.DealID != null ? obj.DealID : obj.CaseID,\r\n IsDeal: obj.DealID != null ? true : false,\r\n BrokerUserId: obj.BrokerUserId,\r\n }));\r\n\r\n this.dealLenderMessageService\r\n .getTotalUnreadMessagesPerAppraisal(appraisalList)\r\n .then((response) => {\r\n this.bridgingTotalUnreadMessage =\r\n response.BridgingTotalUnreadMessages;\r\n this.commercialTotalUnreadMessage =\r\n response.CommercialTotalUnreadMessages;\r\n this.devfinanceTotalUnreadMessage =\r\n response.DevFinanceTotalUnreadMessages;\r\n\r\n for (const proj of this.projects) {\r\n const matchingProj =\r\n proj.DealID != null\r\n ? response.AppraisalDataList.find(\r\n (dl) => dl.AppraisalId === proj.DealID && dl.IsDeal,\r\n )\r\n : response.AppraisalDataList.find(\r\n (dl) => dl.AppraisalId === proj.CaseID && !dl.IsDeal,\r\n );\r\n if (matchingProj) {\r\n proj.TotalUnreadMessages = matchingProj.TotalUnreadMessages;\r\n }\r\n }\r\n });\r\n }\r\n }\r\n\r\n //If previous path is any one of these then only it restore previous selected navmenu and filter\r\n isValidPreviousPath() {\r\n if (\r\n ((this.$rootScope as any).previousRoute.startsWith(\r\n \"/commercialresults\",\r\n ) ||\r\n (this.$rootScope as any).previousRoute.startsWith(\"/bridgingresults\") ||\r\n (this.$rootScope as any).previousRoute.startsWith(\r\n \"/devfinanceresults\",\r\n ) ||\r\n (this.$rootScope as any).previousRoute.startsWith(\r\n \"/commercialcasedashboard\",\r\n ) ||\r\n (this.$rootScope as any).previousRoute.startsWith(\r\n \"/bridgingcasedashboard\",\r\n ) ||\r\n (this.$rootScope as any).previousRoute.startsWith(\r\n \"/devfinancecasedashboard\",\r\n ) ||\r\n (this.$rootScope as any).previousRoute == \"/\" ||\r\n (this.$rootScope as any).previousRoute.startsWith(\r\n \"/devfinancecriteria\",\r\n ) ||\r\n (this.$rootScope as any).previousRoute.startsWith(\r\n \"/bridgingcriteria\",\r\n ) ||\r\n (this.$rootScope as any).previousRoute.startsWith(\r\n \"/commercialcriteria\",\r\n ) ||\r\n (this.$rootScope as any).previousRoute.startsWith(\"/referredSearch\") ||\r\n (this.$rootScope as any).previousRoute.startsWith(\"/casedashboard\") ||\r\n (this.$rootScope as any).previousRoute.startsWith(\"/results\") ||\r\n (this.$rootScope as any).previousRoute.startsWith(\"/dealforum\") ||\r\n (this.$rootScope as any).previousRoute.startsWith(\"/lending\")) &&\r\n (this.$rootScope as any).previousRoute != \"/\"\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n onSelectingHomeMenu() {\r\n sessionStorage.removeItem(\"selectedNavMenu\");\r\n }\r\n\r\n logExportDownload(eventName, item: CaseSummaryDTO) {\r\n this.eventLogService.logEvent(\r\n eventName,\r\n EventLogEnum.Export,\r\n item.ProductType,\r\n item.DealID ? item.DealID : item.CaseID,\r\n );\r\n }\r\n}\r\n","import { LicenseMasterDTO } from \"@js/DTO/LicenseMasterDTO.cs.d\";\r\nimport { LicenseService } from \"@js/services/LicenseService\";\r\n\r\nexport class UserLicenseController {\r\n licenseMasterId: number = null;\r\n license: LicenseMasterDTO = null;\r\n\r\n dataLoading: boolean = false;\r\n\r\n static $inject = [\"$http\", \"$routeParams\", \"LicenseService\"];\r\n\r\n constructor(\r\n private $http: ng.IHttpService,\r\n private $routeParams: ng.route.IRouteParamsService,\r\n private licenseService: LicenseService,\r\n ) {\r\n if (this.$routeParams.licensemasterid) {\r\n this.dataLoading = true;\r\n this.licenseMasterId = +this.$routeParams.licensemasterid;\r\n\r\n this.licenseService\r\n .fetch(this.$routeParams.licensemasterid)\r\n .then((license: LicenseMasterDTO) => {\r\n this.license = license;\r\n });\r\n }\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AuthService } from \"@js/services/AuthService\";\r\nimport { CaseService } from \"@js/services/CaseService\";\r\nimport { RoleService } from \"@js/services/RoleService\";\r\n\r\nexport class WelcomeController {\r\n static $inject = [\r\n \"$scope\",\r\n \"$rootScope\",\r\n \"$cookies\",\r\n \"$location\",\r\n \"CaseService\",\r\n \"AuthService\",\r\n \"RoleService\",\r\n ];\r\n\r\n constructor(\r\n private $scope: ng.IScope,\r\n private $rootScope: ng.IRootScopeService,\r\n private $cookies: ng.cookies.ICookiesService,\r\n private $location: ng.ILocationService,\r\n private caseService: CaseService,\r\n private authService: AuthService,\r\n private roleService: RoleService,\r\n ) {\r\n if (this.$cookies.get(\"access_token\")) {\r\n $location.path(\"/userdashboard\");\r\n }\r\n }\r\n\r\n quickSearch() {\r\n this.$location.path(\"/criteria/0/0/1\");\r\n }\r\n\r\n startAppraisal() {\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.createNewBlankCase();\r\n } else {\r\n // Register the user first before creating a blank case\r\n this.$location.path(\"/register/startprojectappraisal\");\r\n }\r\n }\r\n\r\n applyForDevLoan() {\r\n if (this.$cookies.get(\"access_token\")) {\r\n this.createNewBlankCase(true);\r\n } else {\r\n // Register the user first before creating a blank case\r\n this.$location.path(\"/register/applyfordevloan\");\r\n }\r\n }\r\n\r\n goToFindLoan() {\r\n this.$location.path(\"/criteria/0/0/1\");\r\n }\r\n\r\n createNewBlankCase(applyForDevLoan: boolean = false) {\r\n this.authService.getProfile().then((prof) => {\r\n var currentUser: ApplicationUserDTO = prof;\r\n this.roleService.GetUserRoles().then((result) => {\r\n var isPrimaryApplicant: boolean = true;\r\n\r\n if (result.filter((x) => x == \"Broker\").length > 0) {\r\n isPrimaryApplicant = false;\r\n }\r\n\r\n this.caseService\r\n .newBlankCase(currentUser, isPrimaryApplicant)\r\n .then((newBlankCaseDto) => {\r\n if (newBlankCaseDto && newBlankCaseDto.NewCaseId) {\r\n // If applying for a development loan then go to the case dashboard of the new case\r\n if (applyForDevLoan == true) {\r\n this.$location.path(\r\n \"/casedashboard/\" + newBlankCaseDto.NewCaseId,\r\n );\r\n } else {\r\n // If starting a project appraisal then go directly to the appraisal module of the new case\r\n this.$location.path(\r\n \"/criteriaappraisal/\" +\r\n newBlankCaseDto.NewCaseId +\r\n \"/\" +\r\n newBlankCaseDto.NewSearchId,\r\n );\r\n }\r\n }\r\n });\r\n });\r\n });\r\n }\r\n}\r\n","import { UserService } from \"@js/services/UserService\";\r\n\r\nexport class UnsubscribeEmailController {\r\n\r\n static $inject = [\r\n '$routeParams',\r\n 'UserService',\r\n ];\r\n\r\n error: boolean = false;\r\n\r\n constructor(private $routeParams: ng.route.IRouteParamsService, private userService:UserService) {\r\n\r\n\r\n if (this.$routeParams.emailCode && this.$routeParams.userId) {\r\n this.userService.unSubscribeFromEmail(this.$routeParams.emailCode, this.$routeParams.userId).then((response) => {\r\n }).catch((response) => {\r\n this.error = true;\r\n });\r\n }\r\n\r\n }\r\n\r\n}\r\n\r\n","import angular from \"angular\";\r\nimport { AccountsController } from \"./controllers/AccountsController\";\r\nimport { AccountSettingsController } from \"./controllers/AccountSettingsController\";\r\nimport { AgentLandingController } from \"./controllers/AgentLandingController\";\r\nimport { AllLoansLandingController } from \"./controllers/AllLoansLandingController\";\r\nimport { ApplicantController } from \"./controllers/ApplicantController\";\r\nimport { ApplicantDetailsController } from \"./controllers/ApplicantDetailsController\";\r\nimport { ApplicationDetailsController } from \"./controllers/ApplicationDetailsController\";\r\nimport { AssignLicensesController } from \"./controllers/AssignLicensesController\";\r\nimport { BorrowerTermsController } from \"./controllers/BorrowerTermsController\";\r\nimport { BridgingCaseController } from \"./controllers/BridgingCaseController\";\r\nimport { BridgingCriteriaController } from \"./controllers/BridgingCriteriaController\";\r\nimport { BridgingHeadsOfTermsController } from \"./controllers/BridgingHeadsOfTermsController\";\r\nimport { BridgingLenderResultScreenController } from \"./controllers/BridgingLenderResultsScreenController\";\r\nimport { CaseController } from \"./controllers/CaseController\";\r\nimport { CaseLenderController } from \"./controllers/CaseLenderController\";\r\nimport { CaseOverviewController } from \"./controllers/CaseOverviewController\";\r\nimport { ClientDashboardController } from \"./controllers/ClientDashboardController\";\r\nimport { CommercialCaseController } from \"./controllers/CommercialCaseController\";\r\nimport { CommercialComparisonController } from \"./controllers/CommercialComparisonController\";\r\nimport { CommercialCriteriaController } from \"./controllers/CommercialCriteriaController\";\r\nimport { CommercialHeadsOfTermsController } from \"./controllers/CommercialHeadsOfTermsController\";\r\nimport { CommercialLenderResultScreenController } from \"./controllers/CommercialLenderResultsScreenController\";\r\nimport { ComparisonController } from \"./controllers/ComparisonController\";\r\nimport { DashboardController } from \"./controllers/DashboardController\";\r\nimport { DealLenderController } from \"./controllers/DealLenderController\";\r\nimport { DealSecurityCheckController } from \"./controllers/DealSecurityCheckController\";\r\nimport { DeveloperExitFinanceComparisonController } from \"./controllers/DeveloperExitFinanceComparisonController\";\r\nimport { DeveloperExitFinanceDevelopmentInputController } from \"./controllers/DeveloperExitFinanceDevelopmentInputController\";\r\nimport { DeveloperExitFinanceDevScheduleInputController } from \"./controllers/DeveloperExitFinanceDevScheduleInputController\";\r\nimport { DeveloperExitFinanceLoanInputController } from \"./controllers/DeveloperExitFinanceLoanInputController\";\r\nimport { DeveloperExitFinanceResultController } from \"./controllers/DeveloperExitFinanceResultController\";\r\nimport { DevelopmentAppraisalScreenController } from \"./controllers/DevelopmentAppraisalScreenController\";\r\nimport { DevelopmentExperienceController } from \"./controllers/DevelopmentExperienceController\";\r\nimport { DevelopmentInputController } from \"./controllers/DevelopmentInputController\";\r\nimport { DevelopmentInputScheduleController } from \"./controllers/DevelopmentInputScheduleController\";\r\nimport { DevelopmentInputScreenController } from \"./controllers/DevelopmentInputScreenController\";\r\nimport { DevelopmentInputWithNoLoginController } from \"./controllers/DevelopmentInputWithNoLoginController\";\r\nimport { DevelopmentTrackRecordController } from \"./controllers/DevelopmentTrackRecordController\";\r\nimport { DevFinanceCaseController } from \"./controllers/DevFinanceCaseController\";\r\nimport { DevFinanceCriteriaController } from \"./controllers/DevFinanceCriteriaController\";\r\nimport { DevFinanceHeadsOfTermsController } from \"./controllers/DevFinanceHeadsOfTermsController\";\r\nimport { DevFinanceLenderResultScreenController } from \"./controllers/DevFinanceLenderResultsScreenController\";\r\nimport { EnquiryController } from \"./controllers/EnquiryController\";\r\nimport { EnterpriseLeadCaptureController } from \"./controllers/EnterpriseLeadCaptureController\";\r\nimport { FeaturePriceController } from \"./controllers/FeaturePriceController\";\r\nimport { FeedBackController } from \"./controllers/FeedBackController\";\r\nimport { FileAttachmentController } from \"./controllers/FileAttachmentController\";\r\nimport { HeadsOfTermsController } from \"./controllers/HeadsOfTermsController\";\r\nimport { IndexController } from \"./controllers/IndexController\";\r\nimport { InitialRegistrationController } from \"./controllers/InitialRegistrationController\";\r\nimport { IntroducerController } from \"./controllers/IntroducerController\";\r\nimport { LandingController } from \"./controllers/LandingController\";\r\nimport { LandingV3Controller } from \"./controllers/LandingV3Controller\";\r\nimport { LeadGenPromoController } from \"./controllers/LeadGenPromoController\";\r\nimport { LenderController } from \"./controllers/LenderController\";\r\nimport { LenderResultScreenController } from \"./controllers/LenderResultScreenController\";\r\nimport { LoginController } from \"./controllers/LoginController\";\r\nimport { ManageLicenseController } from \"./controllers/ManageLicenseController\";\r\nimport { NewDashboardController } from \"./controllers/NewDashboardController\";\r\nimport { NewSearchSelectionsController } from \"./controllers/NewSearchSelectionsController\";\r\nimport { OrganisationsController } from \"./controllers/OrganisationsController\";\r\nimport { PayFailController } from \"./controllers/PayFailController\";\r\nimport { PaymentController } from \"./controllers/PaymentController\";\r\nimport { PaySucessController } from \"./controllers/PaySucessController\";\r\nimport { PrivacyController } from \"./controllers/PrivacyController\";\r\nimport { ProductController } from \"./controllers/ProductController\";\r\nimport { ProductStubController } from \"./controllers/ProductStubController\";\r\nimport { ProfileController } from \"./controllers/ProfileController\";\r\nimport { ReferFriendController } from \"./controllers/ReferFriendController\";\r\nimport { RegistrationBrokerController } from \"./controllers/RegistrationBrokerController\";\r\nimport { RegistrationController } from \"./controllers/RegistrationController\";\r\nimport { RegistrationIntroducerController } from \"./controllers/RegistrationIntroducerController\";\r\nimport { RoleController } from \"./controllers/RoleController\";\r\nimport { SecurityCheckController } from \"./controllers/SecurityCheckController\";\r\nimport { TermsOfBusinessController } from \"./controllers/TermsOfBusinessController\";\r\nimport { TrackRecordController } from \"./controllers/TrackRecordController\";\r\nimport { UserController } from \"./controllers/UserController\";\r\nimport { UserDashboardController } from \"./controllers/UserDashboardController\";\r\nimport { UserLicenseController } from \"./controllers/UserLicenseController\";\r\nimport { WelcomeController } from \"./controllers/WelcomeController\";\r\nimport { UnsubscribeEmailController } from \"./controllers/UnsubscribeEmailController\";\r\n\r\nexport function registerControllers() {\r\n angular\r\n .module(\"ccqapp\")\r\n .controller(\"AccountsController\", AccountsController)\r\n .controller(\"AccountSettingsController\", AccountSettingsController)\r\n .controller(\"AgentLandingController\", AgentLandingController)\r\n .controller(\"AllLoansLandingController\", AllLoansLandingController)\r\n .controller(\"ApplicantController\", ApplicantController)\r\n .controller(\"ApplicantDetailsController\", ApplicantDetailsController)\r\n .controller(\"ApplicationDetailsController\", ApplicationDetailsController)\r\n .controller(\"AssignLicensesController\", AssignLicensesController)\r\n .controller(\"BorrowerTermsController\", BorrowerTermsController)\r\n .controller(\"BridgingCaseController\", BridgingCaseController)\r\n .controller(\"BridgingCriteriaController\", BridgingCriteriaController)\r\n .controller(\r\n \"BridgingHeadsOfTermsController\",\r\n BridgingHeadsOfTermsController,\r\n )\r\n .controller(\r\n \"BridgingLenderResultScreenController\",\r\n BridgingLenderResultScreenController,\r\n )\r\n .controller(\"CaseController\", CaseController)\r\n .controller(\"CaseLenderController\", CaseLenderController)\r\n .controller(\"CaseOverviewController\", CaseOverviewController)\r\n .controller(\"ClientDashboardController\", ClientDashboardController)\r\n .controller(\"CommercialCaseController\", CommercialCaseController)\r\n .controller(\r\n \"CommercialComparisonController\",\r\n CommercialComparisonController,\r\n )\r\n .controller(\"CommercialCriteriaController\", CommercialCriteriaController)\r\n .controller(\r\n \"CommercialHeadsOfTermsController\",\r\n CommercialHeadsOfTermsController,\r\n )\r\n .controller(\r\n \"CommercialLenderResultScreenController\",\r\n CommercialLenderResultScreenController,\r\n )\r\n .controller(\"ComparisonController\", ComparisonController)\r\n .controller(\"DashboardController\", DashboardController)\r\n .controller(\"DealLenderController\", DealLenderController)\r\n .controller(\"DealSecurityCheckController\", DealSecurityCheckController)\r\n .controller(\r\n \"DeveloperExitFinanceComparisonController\",\r\n DeveloperExitFinanceComparisonController,\r\n )\r\n .controller(\r\n \"DeveloperExitFinanceDevelopmentInputController\",\r\n DeveloperExitFinanceDevelopmentInputController,\r\n )\r\n .controller(\r\n \"DeveloperExitFinanceDevScheduleInputController\",\r\n DeveloperExitFinanceDevScheduleInputController,\r\n )\r\n .controller(\r\n \"DeveloperExitFinanceLoanInputController\",\r\n DeveloperExitFinanceLoanInputController,\r\n )\r\n .controller(\r\n \"DeveloperExitFinanceResultController\",\r\n DeveloperExitFinanceResultController,\r\n )\r\n .controller(\r\n \"DevelopmentAppraisalScreenController\",\r\n DevelopmentAppraisalScreenController,\r\n )\r\n .controller(\r\n \"DevelopmentExperienceController\",\r\n DevelopmentExperienceController,\r\n )\r\n .controller(\"DevelopmentInputController\", DevelopmentInputController)\r\n .controller(\r\n \"DevelopmentInputScheduleController\",\r\n DevelopmentInputScheduleController,\r\n )\r\n .controller(\r\n \"DevelopmentInputScreenController\",\r\n DevelopmentInputScreenController,\r\n )\r\n .controller(\r\n \"DevelopmentInputWithNoLoginController\",\r\n DevelopmentInputWithNoLoginController,\r\n )\r\n .controller(\r\n \"DevelopmentTrackRecordController\",\r\n DevelopmentTrackRecordController,\r\n )\r\n .controller(\"DevFinanceCaseController\", DevFinanceCaseController)\r\n .controller(\"DevFinanceCriteriaController\", DevFinanceCriteriaController)\r\n .controller(\r\n \"DevFinanceHeadsOfTermsController\",\r\n DevFinanceHeadsOfTermsController,\r\n )\r\n .controller(\r\n \"DevFinanceLenderResultScreenController\",\r\n DevFinanceLenderResultScreenController,\r\n )\r\n .controller(\"EnquiryController\", EnquiryController)\r\n .controller(\"FeaturePriceController\", FeaturePriceController)\r\n .controller(\"FeedBackController\", FeedBackController)\r\n .controller(\"FileAttachmentController\", FileAttachmentController)\r\n .controller(\"HeadsOfTermsController\", HeadsOfTermsController)\r\n .controller(\"IndexController\", IndexController)\r\n .controller(\"InitialRegistrationController\", InitialRegistrationController)\r\n .controller(\"IntroducerController\", IntroducerController)\r\n .controller(\"LandingController\", LandingController)\r\n .controller(\"LandingV3Controller\", LandingV3Controller)\r\n .controller(\"LeadGenPromoController\", LeadGenPromoController)\r\n .controller(\"LenderController\", LenderController)\r\n .controller(\"LenderResultScreenController\", LenderResultScreenController)\r\n .controller(\"LoginController\", LoginController)\r\n .controller(\"ManageLicenseController\", ManageLicenseController)\r\n .controller(\"NewDashboardController\", NewDashboardController)\r\n .controller(\"NewSearchSelectionsController\", NewSearchSelectionsController)\r\n // .controller(\"OrganisationLinkController\", OrganisationLinkController)\r\n .controller(\"OrganisationsController\", OrganisationsController)\r\n .controller(\"PayFailController\", PayFailController)\r\n .controller(\"PaymentController\", PaymentController)\r\n .controller(\"PaySucessController\", PaySucessController)\r\n .controller(\"PrivacyController\", PrivacyController)\r\n .controller(\"ProductController\", ProductController)\r\n .controller(\"ProductStubController\", ProductStubController)\r\n .controller(\"ProfileController\", ProfileController)\r\n .controller(\"ReferFriendController\", ReferFriendController)\r\n .controller(\"RegistrationBrokerController\", RegistrationBrokerController)\r\n .controller(\"RegistrationController\", RegistrationController)\r\n .controller(\r\n \"RegistrationIntroducerController\",\r\n RegistrationIntroducerController,\r\n )\r\n .controller(\"RoleController\", RoleController)\r\n .controller(\"SecurityCheckController\", SecurityCheckController)\r\n .controller(\"TermsOfBusinessController\", TermsOfBusinessController)\r\n .controller(\"TrackRecordController\", TrackRecordController)\r\n .controller(\"UserController\", UserController)\r\n .controller(\"UserDashboardController\", UserDashboardController)\r\n .controller(\"UserLicenseController\", UserLicenseController)\r\n .controller(\"WelcomeController\", WelcomeController)\r\n .controller(\r\n \"EnterpriseLeadCaptureController\",\r\n EnterpriseLeadCaptureController,\r\n ).controller(\"UnsubscribeEmailController\", UnsubscribeEmailController);\r\n}\r\n","/**\n * @license React\n * react-jsx-runtime.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var f=require(\"react\"),k=Symbol.for(\"react.element\"),l=Symbol.for(\"react.fragment\"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};\nfunction q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=\"\"+g);void 0!==a.key&&(e=\"\"+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","import { FC, useState } from \"react\";\r\n\r\nexport const TestComponent1: FC = () => {\r\n const [count, setCount] = useState(0);\r\n\r\n return (\r\n \r\n
\r\n
You have clicked me {count} times.
\r\n
\r\n\r\n
\r\n \r\n
\r\n
\r\n );\r\n};\r\n\r\ninterface Props {\r\n fooBar: number;\r\n baz: string;\r\n}\r\n\r\nexport const TestComponent2: FC = ({ fooBar, baz }) => {\r\n return (\r\n \r\n
FooBar: {fooBar}
\r\n
Baz: {baz}
\r\n
\r\n );\r\n};\r\n","/**\n * lodash 4.0.1 (Custom Build) \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright 2012-2016 The Dojo Foundation \n * Based on Underscore.js 1.8.3 \n * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * Available under MIT license \n */\n\n/**\n * The inverse of `_.toPairs`; this method returns an object composed\n * from key-value `pairs`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} pairs The key-value pairs.\n * @returns {Object} Returns the new object.\n * @example\n *\n * _.fromPairs([['fred', 30], ['barney', 40]]);\n * // => { 'fred': 30, 'barney': 40 }\n */\nfunction fromPairs(pairs) {\n var index = -1,\n length = pairs ? pairs.length : 0,\n result = {};\n\n while (++index < length) {\n var pair = pairs[index];\n result[pair[0]] = pair[1];\n }\n return result;\n}\n\nmodule.exports = fromPairs;\n","/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nmodule.exports = freeGlobal;\n","var freeGlobal = require('./_freeGlobal');\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nmodule.exports = root;\n","var root = require('./_root');\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nmodule.exports = Symbol;\n","var Symbol = require('./_Symbol');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nmodule.exports = getRawTag;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nmodule.exports = objectToString;\n","var Symbol = require('./_Symbol'),\n getRawTag = require('./_getRawTag'),\n objectToString = require('./_objectToString');\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nmodule.exports = baseGetTag;\n","/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nmodule.exports = isObject;\n","var baseGetTag = require('./_baseGetTag'),\n isObject = require('./isObject');\n\n/** `Object#toString` result references. */\nvar asyncTag = '[object AsyncFunction]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n proxyTag = '[object Proxy]';\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\nmodule.exports = isFunction;\n","var root = require('./_root');\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\nmodule.exports = coreJsData;\n","var coreJsData = require('./_coreJsData');\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\nmodule.exports = isMasked;\n","/** Used for built-in method references. */\nvar funcProto = Function.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\nmodule.exports = toSource;\n","var isFunction = require('./isFunction'),\n isMasked = require('./_isMasked'),\n isObject = require('./isObject'),\n toSource = require('./_toSource');\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\nmodule.exports = baseIsNative;\n","/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\nmodule.exports = getValue;\n","var baseIsNative = require('./_baseIsNative'),\n getValue = require('./_getValue');\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\nmodule.exports = getNative;\n","var getNative = require('./_getNative');\n\nvar defineProperty = (function() {\n try {\n var func = getNative(Object, 'defineProperty');\n func({}, '', {});\n return func;\n } catch (e) {}\n}());\n\nmodule.exports = defineProperty;\n","var defineProperty = require('./_defineProperty');\n\n/**\n * The base implementation of `assignValue` and `assignMergeValue` without\n * value checks.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction baseAssignValue(object, key, value) {\n if (key == '__proto__' && defineProperty) {\n defineProperty(object, key, {\n 'configurable': true,\n 'enumerable': true,\n 'value': value,\n 'writable': true\n });\n } else {\n object[key] = value;\n }\n}\n\nmodule.exports = baseAssignValue;\n","/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\nmodule.exports = eq;\n","var baseAssignValue = require('./_baseAssignValue'),\n eq = require('./eq');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Assigns `value` to `key` of `object` if the existing value is not equivalent\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction assignValue(object, key, value) {\n var objValue = object[key];\n if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||\n (value === undefined && !(key in object))) {\n baseAssignValue(object, key, value);\n }\n}\n\nmodule.exports = assignValue;\n","var assignValue = require('./_assignValue'),\n baseAssignValue = require('./_baseAssignValue');\n\n/**\n * Copies properties of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy properties from.\n * @param {Array} props The property identifiers to copy.\n * @param {Object} [object={}] The object to copy properties to.\n * @param {Function} [customizer] The function to customize copied values.\n * @returns {Object} Returns `object`.\n */\nfunction copyObject(source, props, object, customizer) {\n var isNew = !object;\n object || (object = {});\n\n var index = -1,\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n\n var newValue = customizer\n ? customizer(object[key], source[key], key, object, source)\n : undefined;\n\n if (newValue === undefined) {\n newValue = source[key];\n }\n if (isNew) {\n baseAssignValue(object, key, newValue);\n } else {\n assignValue(object, key, newValue);\n }\n }\n return object;\n}\n\nmodule.exports = copyObject;\n","/**\n * This method returns the first argument it receives.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {*} value Any value.\n * @returns {*} Returns `value`.\n * @example\n *\n * var object = { 'a': 1 };\n *\n * console.log(_.identity(object) === object);\n * // => true\n */\nfunction identity(value) {\n return value;\n}\n\nmodule.exports = identity;\n","/**\n * A faster alternative to `Function#apply`, this function invokes `func`\n * with the `this` binding of `thisArg` and the arguments of `args`.\n *\n * @private\n * @param {Function} func The function to invoke.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} args The arguments to invoke `func` with.\n * @returns {*} Returns the result of `func`.\n */\nfunction apply(func, thisArg, args) {\n switch (args.length) {\n case 0: return func.call(thisArg);\n case 1: return func.call(thisArg, args[0]);\n case 2: return func.call(thisArg, args[0], args[1]);\n case 3: return func.call(thisArg, args[0], args[1], args[2]);\n }\n return func.apply(thisArg, args);\n}\n\nmodule.exports = apply;\n","var apply = require('./_apply');\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max;\n\n/**\n * A specialized version of `baseRest` which transforms the rest array.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @param {Function} transform The rest array transform.\n * @returns {Function} Returns the new function.\n */\nfunction overRest(func, start, transform) {\n start = nativeMax(start === undefined ? (func.length - 1) : start, 0);\n return function() {\n var args = arguments,\n index = -1,\n length = nativeMax(args.length - start, 0),\n array = Array(length);\n\n while (++index < length) {\n array[index] = args[start + index];\n }\n index = -1;\n var otherArgs = Array(start + 1);\n while (++index < start) {\n otherArgs[index] = args[index];\n }\n otherArgs[start] = transform(array);\n return apply(func, this, otherArgs);\n };\n}\n\nmodule.exports = overRest;\n","/**\n * Creates a function that returns `value`.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {*} value The value to return from the new function.\n * @returns {Function} Returns the new constant function.\n * @example\n *\n * var objects = _.times(2, _.constant({ 'a': 1 }));\n *\n * console.log(objects);\n * // => [{ 'a': 1 }, { 'a': 1 }]\n *\n * console.log(objects[0] === objects[1]);\n * // => true\n */\nfunction constant(value) {\n return function() {\n return value;\n };\n}\n\nmodule.exports = constant;\n","var constant = require('./constant'),\n defineProperty = require('./_defineProperty'),\n identity = require('./identity');\n\n/**\n * The base implementation of `setToString` without support for hot loop shorting.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\nvar baseSetToString = !defineProperty ? identity : function(func, string) {\n return defineProperty(func, 'toString', {\n 'configurable': true,\n 'enumerable': false,\n 'value': constant(string),\n 'writable': true\n });\n};\n\nmodule.exports = baseSetToString;\n","/** Used to detect hot functions by number of calls within a span of milliseconds. */\nvar HOT_COUNT = 800,\n HOT_SPAN = 16;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeNow = Date.now;\n\n/**\n * Creates a function that'll short out and invoke `identity` instead\n * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`\n * milliseconds.\n *\n * @private\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new shortable function.\n */\nfunction shortOut(func) {\n var count = 0,\n lastCalled = 0;\n\n return function() {\n var stamp = nativeNow(),\n remaining = HOT_SPAN - (stamp - lastCalled);\n\n lastCalled = stamp;\n if (remaining > 0) {\n if (++count >= HOT_COUNT) {\n return arguments[0];\n }\n } else {\n count = 0;\n }\n return func.apply(undefined, arguments);\n };\n}\n\nmodule.exports = shortOut;\n","var baseSetToString = require('./_baseSetToString'),\n shortOut = require('./_shortOut');\n\n/**\n * Sets the `toString` method of `func` to return `string`.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\nvar setToString = shortOut(baseSetToString);\n\nmodule.exports = setToString;\n","var identity = require('./identity'),\n overRest = require('./_overRest'),\n setToString = require('./_setToString');\n\n/**\n * The base implementation of `_.rest` which doesn't validate or coerce arguments.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n */\nfunction baseRest(func, start) {\n return setToString(overRest(func, start, identity), func + '');\n}\n\nmodule.exports = baseRest;\n","/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\nmodule.exports = isLength;\n","var isFunction = require('./isFunction'),\n isLength = require('./isLength');\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\nmodule.exports = isArrayLike;\n","/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n var type = typeof value;\n length = length == null ? MAX_SAFE_INTEGER : length;\n\n return !!length &&\n (type == 'number' ||\n (type != 'symbol' && reIsUint.test(value))) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\nmodule.exports = isIndex;\n","var eq = require('./eq'),\n isArrayLike = require('./isArrayLike'),\n isIndex = require('./_isIndex'),\n isObject = require('./isObject');\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\nmodule.exports = isIterateeCall;\n","var baseRest = require('./_baseRest'),\n isIterateeCall = require('./_isIterateeCall');\n\n/**\n * Creates a function like `_.assign`.\n *\n * @private\n * @param {Function} assigner The function to assign values.\n * @returns {Function} Returns the new assigner function.\n */\nfunction createAssigner(assigner) {\n return baseRest(function(object, sources) {\n var index = -1,\n length = sources.length,\n customizer = length > 1 ? sources[length - 1] : undefined,\n guard = length > 2 ? sources[2] : undefined;\n\n customizer = (assigner.length > 3 && typeof customizer == 'function')\n ? (length--, customizer)\n : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n customizer = length < 3 ? undefined : customizer;\n length = 1;\n }\n object = Object(object);\n while (++index < length) {\n var source = sources[index];\n if (source) {\n assigner(object, source, index, customizer);\n }\n }\n return object;\n });\n}\n\nmodule.exports = createAssigner;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\nmodule.exports = isPrototype;\n","/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\nmodule.exports = baseTimes;\n","/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nmodule.exports = isObjectLike;\n","var baseGetTag = require('./_baseGetTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]';\n\n/**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\nfunction baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n}\n\nmodule.exports = baseIsArguments;\n","var baseIsArguments = require('./_baseIsArguments'),\n isObjectLike = require('./isObjectLike');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nvar isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n !propertyIsEnumerable.call(value, 'callee');\n};\n\nmodule.exports = isArguments;\n","/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\nmodule.exports = isArray;\n","/**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\nfunction stubFalse() {\n return false;\n}\n\nmodule.exports = stubFalse;\n","var root = require('./_root'),\n stubFalse = require('./stubFalse');\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;\n\n/**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\nvar isBuffer = nativeIsBuffer || stubFalse;\n\nmodule.exports = isBuffer;\n","var baseGetTag = require('./_baseGetTag'),\n isLength = require('./isLength'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n objectTag = '[object Object]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\ntypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\ntypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\ntypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\ntypedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] =\ntypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\ntypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\ntypedArrayTags[errorTag] = typedArrayTags[funcTag] =\ntypedArrayTags[mapTag] = typedArrayTags[numberTag] =\ntypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\ntypedArrayTags[setTag] = typedArrayTags[stringTag] =\ntypedArrayTags[weakMapTag] = false;\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n}\n\nmodule.exports = baseIsTypedArray;\n","/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\nmodule.exports = baseUnary;\n","var freeGlobal = require('./_freeGlobal');\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = (function() {\n try {\n // Use `util.types` for Node.js 10+.\n var types = freeModule && freeModule.require && freeModule.require('util').types;\n\n if (types) {\n return types;\n }\n\n // Legacy `process.binding('util')` for Node.js < 10.\n return freeProcess && freeProcess.binding && freeProcess.binding('util');\n } catch (e) {}\n}());\n\nmodule.exports = nodeUtil;\n","var baseIsTypedArray = require('./_baseIsTypedArray'),\n baseUnary = require('./_baseUnary'),\n nodeUtil = require('./_nodeUtil');\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\nmodule.exports = isTypedArray;\n","var baseTimes = require('./_baseTimes'),\n isArguments = require('./isArguments'),\n isArray = require('./isArray'),\n isBuffer = require('./isBuffer'),\n isIndex = require('./_isIndex'),\n isTypedArray = require('./isTypedArray');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n var isArr = isArray(value),\n isArg = !isArr && isArguments(value),\n isBuff = !isArr && !isArg && isBuffer(value),\n isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n skipIndexes = isArr || isArg || isBuff || isType,\n result = skipIndexes ? baseTimes(value.length, String) : [],\n length = result.length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key == 'length' ||\n // Node.js 0.10 has enumerable non-index properties on buffers.\n (isBuff && (key == 'offset' || key == 'parent')) ||\n // PhantomJS 2 has enumerable non-index properties on typed arrays.\n (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n // Skip index properties.\n isIndex(key, length)\n ))) {\n result.push(key);\n }\n }\n return result;\n}\n\nmodule.exports = arrayLikeKeys;\n","/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\nmodule.exports = overArg;\n","var overArg = require('./_overArg');\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeKeys = overArg(Object.keys, Object);\n\nmodule.exports = nativeKeys;\n","var isPrototype = require('./_isPrototype'),\n nativeKeys = require('./_nativeKeys');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n}\n\nmodule.exports = baseKeys;\n","var arrayLikeKeys = require('./_arrayLikeKeys'),\n baseKeys = require('./_baseKeys'),\n isArrayLike = require('./isArrayLike');\n\n/**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\nfunction keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n}\n\nmodule.exports = keys;\n","var assignValue = require('./_assignValue'),\n copyObject = require('./_copyObject'),\n createAssigner = require('./_createAssigner'),\n isArrayLike = require('./isArrayLike'),\n isPrototype = require('./_isPrototype'),\n keys = require('./keys');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Assigns own enumerable string keyed properties of source objects to the\n * destination object. Source objects are applied from left to right.\n * Subsequent sources overwrite property assignments of previous sources.\n *\n * **Note:** This method mutates `object` and is loosely based on\n * [`Object.assign`](https://mdn.io/Object/assign).\n *\n * @static\n * @memberOf _\n * @since 0.10.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @see _.assignIn\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * function Bar() {\n * this.c = 3;\n * }\n *\n * Foo.prototype.b = 2;\n * Bar.prototype.d = 4;\n *\n * _.assign({ 'a': 0 }, new Foo, new Bar);\n * // => { 'a': 1, 'c': 3 }\n */\nvar assign = createAssigner(function(object, source) {\n if (isPrototype(source) || isArrayLike(source)) {\n copyObject(source, keys(source), object);\n return;\n }\n for (var key in source) {\n if (hasOwnProperty.call(source, key)) {\n assignValue(object, key, source[key]);\n }\n }\n});\n\nmodule.exports = assign;\n","/**\n * Creates a base function for methods like `_.forIn` and `_.forOwn`.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\nfunction createBaseFor(fromRight) {\n return function(object, iteratee, keysFunc) {\n var index = -1,\n iterable = Object(object),\n props = keysFunc(object),\n length = props.length;\n\n while (length--) {\n var key = props[fromRight ? length : ++index];\n if (iteratee(iterable[key], key, iterable) === false) {\n break;\n }\n }\n return object;\n };\n}\n\nmodule.exports = createBaseFor;\n","var createBaseFor = require('./_createBaseFor');\n\n/**\n * The base implementation of `baseForOwn` which iterates over `object`\n * properties returned by `keysFunc` and invokes `iteratee` for each property.\n * Iteratee functions may exit iteration early by explicitly returning `false`.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @returns {Object} Returns `object`.\n */\nvar baseFor = createBaseFor();\n\nmodule.exports = baseFor;\n","var baseFor = require('./_baseFor'),\n keys = require('./keys');\n\n/**\n * The base implementation of `_.forOwn` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Object} Returns `object`.\n */\nfunction baseForOwn(object, iteratee) {\n return object && baseFor(object, iteratee, keys);\n}\n\nmodule.exports = baseForOwn;\n","/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n}\n\nmodule.exports = listCacheClear;\n","var eq = require('./eq');\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\nmodule.exports = assocIndexOf;\n","var assocIndexOf = require('./_assocIndexOf');\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype;\n\n/** Built-in value references. */\nvar splice = arrayProto.splice;\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n}\n\nmodule.exports = listCacheDelete;\n","var assocIndexOf = require('./_assocIndexOf');\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\nmodule.exports = listCacheGet;\n","var assocIndexOf = require('./_assocIndexOf');\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\nmodule.exports = listCacheHas;\n","var assocIndexOf = require('./_assocIndexOf');\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\nmodule.exports = listCacheSet;\n","var listCacheClear = require('./_listCacheClear'),\n listCacheDelete = require('./_listCacheDelete'),\n listCacheGet = require('./_listCacheGet'),\n listCacheHas = require('./_listCacheHas'),\n listCacheSet = require('./_listCacheSet');\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\nmodule.exports = ListCache;\n","var ListCache = require('./_ListCache');\n\n/**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\nfunction stackClear() {\n this.__data__ = new ListCache;\n this.size = 0;\n}\n\nmodule.exports = stackClear;\n","/**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction stackDelete(key) {\n var data = this.__data__,\n result = data['delete'](key);\n\n this.size = data.size;\n return result;\n}\n\nmodule.exports = stackDelete;\n","/**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction stackGet(key) {\n return this.__data__.get(key);\n}\n\nmodule.exports = stackGet;\n","/**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction stackHas(key) {\n return this.__data__.has(key);\n}\n\nmodule.exports = stackHas;\n","var getNative = require('./_getNative'),\n root = require('./_root');\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map');\n\nmodule.exports = Map;\n","var getNative = require('./_getNative');\n\n/* Built-in method references that are verified to be native. */\nvar nativeCreate = getNative(Object, 'create');\n\nmodule.exports = nativeCreate;\n","var nativeCreate = require('./_nativeCreate');\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n}\n\nmodule.exports = hashClear;\n","/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n}\n\nmodule.exports = hashDelete;\n","var nativeCreate = require('./_nativeCreate');\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\nmodule.exports = hashGet;\n","var nativeCreate = require('./_nativeCreate');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n}\n\nmodule.exports = hashHas;\n","var nativeCreate = require('./_nativeCreate');\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\nmodule.exports = hashSet;\n","var hashClear = require('./_hashClear'),\n hashDelete = require('./_hashDelete'),\n hashGet = require('./_hashGet'),\n hashHas = require('./_hashHas'),\n hashSet = require('./_hashSet');\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\nmodule.exports = Hash;\n","var Hash = require('./_Hash'),\n ListCache = require('./_ListCache'),\n Map = require('./_Map');\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\nmodule.exports = mapCacheClear;\n","/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\nmodule.exports = isKeyable;\n","var isKeyable = require('./_isKeyable');\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\nmodule.exports = getMapData;\n","var getMapData = require('./_getMapData');\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n}\n\nmodule.exports = mapCacheDelete;\n","var getMapData = require('./_getMapData');\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\nmodule.exports = mapCacheGet;\n","var getMapData = require('./_getMapData');\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\nmodule.exports = mapCacheHas;\n","var getMapData = require('./_getMapData');\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n}\n\nmodule.exports = mapCacheSet;\n","var mapCacheClear = require('./_mapCacheClear'),\n mapCacheDelete = require('./_mapCacheDelete'),\n mapCacheGet = require('./_mapCacheGet'),\n mapCacheHas = require('./_mapCacheHas'),\n mapCacheSet = require('./_mapCacheSet');\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\nmodule.exports = MapCache;\n","var ListCache = require('./_ListCache'),\n Map = require('./_Map'),\n MapCache = require('./_MapCache');\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\nfunction stackSet(key, value) {\n var data = this.__data__;\n if (data instanceof ListCache) {\n var pairs = data.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n}\n\nmodule.exports = stackSet;\n","var ListCache = require('./_ListCache'),\n stackClear = require('./_stackClear'),\n stackDelete = require('./_stackDelete'),\n stackGet = require('./_stackGet'),\n stackHas = require('./_stackHas'),\n stackSet = require('./_stackSet');\n\n/**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Stack(entries) {\n var data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n}\n\n// Add methods to `Stack`.\nStack.prototype.clear = stackClear;\nStack.prototype['delete'] = stackDelete;\nStack.prototype.get = stackGet;\nStack.prototype.has = stackHas;\nStack.prototype.set = stackSet;\n\nmodule.exports = Stack;\n","/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\nmodule.exports = setCacheAdd;\n","/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\nmodule.exports = setCacheHas;\n","var MapCache = require('./_MapCache'),\n setCacheAdd = require('./_setCacheAdd'),\n setCacheHas = require('./_setCacheHas');\n\n/**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\nfunction SetCache(values) {\n var index = -1,\n length = values == null ? 0 : values.length;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n}\n\n// Add methods to `SetCache`.\nSetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\nSetCache.prototype.has = setCacheHas;\n\nmodule.exports = SetCache;\n","/**\n * A specialized version of `_.some` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\nfunction arraySome(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n}\n\nmodule.exports = arraySome;\n","/**\n * Checks if a `cache` value for `key` exists.\n *\n * @private\n * @param {Object} cache The cache to query.\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction cacheHas(cache, key) {\n return cache.has(key);\n}\n\nmodule.exports = cacheHas;\n","var SetCache = require('./_SetCache'),\n arraySome = require('./_arraySome'),\n cacheHas = require('./_cacheHas');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `array` and `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\nfunction equalArrays(array, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Check that cyclic values are equal.\n var arrStacked = stack.get(array);\n var othStacked = stack.get(other);\n if (arrStacked && othStacked) {\n return arrStacked == other && othStacked == array;\n }\n var index = -1,\n result = true,\n seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, arrValue, index, other, array, stack)\n : customizer(arrValue, othValue, index, array, other, stack);\n }\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (seen) {\n if (!arraySome(other, function(othValue, othIndex) {\n if (!cacheHas(seen, othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {\n return seen.push(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, bitmask, customizer, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n}\n\nmodule.exports = equalArrays;\n","var root = require('./_root');\n\n/** Built-in value references. */\nvar Uint8Array = root.Uint8Array;\n\nmodule.exports = Uint8Array;\n","/**\n * Converts `map` to its key-value pairs.\n *\n * @private\n * @param {Object} map The map to convert.\n * @returns {Array} Returns the key-value pairs.\n */\nfunction mapToArray(map) {\n var index = -1,\n result = Array(map.size);\n\n map.forEach(function(value, key) {\n result[++index] = [key, value];\n });\n return result;\n}\n\nmodule.exports = mapToArray;\n","/**\n * Converts `set` to an array of its values.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the values.\n */\nfunction setToArray(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = value;\n });\n return result;\n}\n\nmodule.exports = setToArray;\n","var Symbol = require('./_Symbol'),\n Uint8Array = require('./_Uint8Array'),\n eq = require('./eq'),\n equalArrays = require('./_equalArrays'),\n mapToArray = require('./_mapToArray'),\n setToArray = require('./_setToArray');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/** `Object#toString` result references. */\nvar boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]';\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;\n\n/**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n\n case arrayBufferTag:\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n return false;\n }\n return true;\n\n case boolTag:\n case dateTag:\n case numberTag:\n // Coerce booleans to `1` or `0` and dates to milliseconds.\n // Invalid dates are coerced to `NaN`.\n return eq(+object, +other);\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings, primitives and objects,\n // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n // for more details.\n return object == (other + '');\n\n case mapTag:\n var convert = mapToArray;\n\n case setTag:\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG;\n convert || (convert = setToArray);\n\n if (object.size != other.size && !isPartial) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n bitmask |= COMPARE_UNORDERED_FLAG;\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);\n stack['delete'](object);\n return result;\n\n case symbolTag:\n if (symbolValueOf) {\n return symbolValueOf.call(object) == symbolValueOf.call(other);\n }\n }\n return false;\n}\n\nmodule.exports = equalByTag;\n","/**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\nfunction arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n}\n\nmodule.exports = arrayPush;\n","var arrayPush = require('./_arrayPush'),\n isArray = require('./isArray');\n\n/**\n * The base implementation of `getAllKeys` and `getAllKeysIn` which uses\n * `keysFunc` and `symbolsFunc` to get the enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @param {Function} symbolsFunc The function to get the symbols of `object`.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction baseGetAllKeys(object, keysFunc, symbolsFunc) {\n var result = keysFunc(object);\n return isArray(object) ? result : arrayPush(result, symbolsFunc(object));\n}\n\nmodule.exports = baseGetAllKeys;\n","/**\n * A specialized version of `_.filter` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\nfunction arrayFilter(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\nmodule.exports = arrayFilter;\n","/**\n * This method returns a new empty array.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Array} Returns the new empty array.\n * @example\n *\n * var arrays = _.times(2, _.stubArray);\n *\n * console.log(arrays);\n * // => [[], []]\n *\n * console.log(arrays[0] === arrays[1]);\n * // => false\n */\nfunction stubArray() {\n return [];\n}\n\nmodule.exports = stubArray;\n","var arrayFilter = require('./_arrayFilter'),\n stubArray = require('./stubArray');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeGetSymbols = Object.getOwnPropertySymbols;\n\n/**\n * Creates an array of the own enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\nvar getSymbols = !nativeGetSymbols ? stubArray : function(object) {\n if (object == null) {\n return [];\n }\n object = Object(object);\n return arrayFilter(nativeGetSymbols(object), function(symbol) {\n return propertyIsEnumerable.call(object, symbol);\n });\n};\n\nmodule.exports = getSymbols;\n","var baseGetAllKeys = require('./_baseGetAllKeys'),\n getSymbols = require('./_getSymbols'),\n keys = require('./keys');\n\n/**\n * Creates an array of own enumerable property names and symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction getAllKeys(object) {\n return baseGetAllKeys(object, keys, getSymbols);\n}\n\nmodule.exports = getAllKeys;\n","var getAllKeys = require('./_getAllKeys');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalObjects(object, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n objProps = getAllKeys(object),\n objLength = objProps.length,\n othProps = getAllKeys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isPartial) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n // Check that cyclic values are equal.\n var objStacked = stack.get(object);\n var othStacked = stack.get(other);\n if (objStacked && othStacked) {\n return objStacked == other && othStacked == object;\n }\n var result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n var skipCtor = isPartial;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, objValue, key, other, object, stack)\n : customizer(objValue, othValue, key, object, other, stack);\n }\n // Recursively compare objects (susceptible to call stack limits).\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (result && !skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n}\n\nmodule.exports = equalObjects;\n","var getNative = require('./_getNative'),\n root = require('./_root');\n\n/* Built-in method references that are verified to be native. */\nvar DataView = getNative(root, 'DataView');\n\nmodule.exports = DataView;\n","var getNative = require('./_getNative'),\n root = require('./_root');\n\n/* Built-in method references that are verified to be native. */\nvar Promise = getNative(root, 'Promise');\n\nmodule.exports = Promise;\n","var getNative = require('./_getNative'),\n root = require('./_root');\n\n/* Built-in method references that are verified to be native. */\nvar Set = getNative(root, 'Set');\n\nmodule.exports = Set;\n","var getNative = require('./_getNative'),\n root = require('./_root');\n\n/* Built-in method references that are verified to be native. */\nvar WeakMap = getNative(root, 'WeakMap');\n\nmodule.exports = WeakMap;\n","var DataView = require('./_DataView'),\n Map = require('./_Map'),\n Promise = require('./_Promise'),\n Set = require('./_Set'),\n WeakMap = require('./_WeakMap'),\n baseGetTag = require('./_baseGetTag'),\n toSource = require('./_toSource');\n\n/** `Object#toString` result references. */\nvar mapTag = '[object Map]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n setTag = '[object Set]',\n weakMapTag = '[object WeakMap]';\n\nvar dataViewTag = '[object DataView]';\n\n/** Used to detect maps, sets, and weakmaps. */\nvar dataViewCtorString = toSource(DataView),\n mapCtorString = toSource(Map),\n promiseCtorString = toSource(Promise),\n setCtorString = toSource(Set),\n weakMapCtorString = toSource(WeakMap);\n\n/**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nvar getTag = baseGetTag;\n\n// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.\nif ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n (Map && getTag(new Map) != mapTag) ||\n (Promise && getTag(Promise.resolve()) != promiseTag) ||\n (Set && getTag(new Set) != setTag) ||\n (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n getTag = function(value) {\n var result = baseGetTag(value),\n Ctor = result == objectTag ? value.constructor : undefined,\n ctorString = Ctor ? toSource(Ctor) : '';\n\n if (ctorString) {\n switch (ctorString) {\n case dataViewCtorString: return dataViewTag;\n case mapCtorString: return mapTag;\n case promiseCtorString: return promiseTag;\n case setCtorString: return setTag;\n case weakMapCtorString: return weakMapTag;\n }\n }\n return result;\n };\n}\n\nmodule.exports = getTag;\n","var Stack = require('./_Stack'),\n equalArrays = require('./_equalArrays'),\n equalByTag = require('./_equalByTag'),\n equalObjects = require('./_equalObjects'),\n getTag = require('./_getTag'),\n isArray = require('./isArray'),\n isBuffer = require('./isBuffer'),\n isTypedArray = require('./isTypedArray');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = objIsArr ? arrayTag : getTag(object),\n othTag = othIsArr ? arrayTag : getTag(other);\n\n objTag = objTag == argsTag ? objectTag : objTag;\n othTag = othTag == argsTag ? objectTag : othTag;\n\n var objIsObj = objTag == objectTag,\n othIsObj = othTag == objectTag,\n isSameTag = objTag == othTag;\n\n if (isSameTag && isBuffer(object)) {\n if (!isBuffer(other)) {\n return false;\n }\n objIsArr = true;\n objIsObj = false;\n }\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)\n : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);\n }\n if (!(bitmask & COMPARE_PARTIAL_FLAG)) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n var objUnwrapped = objIsWrapped ? object.value() : object,\n othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);\n }\n }\n if (!isSameTag) {\n return false;\n }\n stack || (stack = new Stack);\n return equalObjects(object, other, bitmask, customizer, equalFunc, stack);\n}\n\nmodule.exports = baseIsEqualDeep;\n","var baseIsEqualDeep = require('./_baseIsEqualDeep'),\n isObjectLike = require('./isObjectLike');\n\n/**\n * The base implementation of `_.isEqual` which supports partial comparisons\n * and tracks traversed objects.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Unordered comparison\n * 2 - Partial comparison\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\nfunction baseIsEqual(value, other, bitmask, customizer, stack) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);\n}\n\nmodule.exports = baseIsEqual;\n","var Stack = require('./_Stack'),\n baseIsEqual = require('./_baseIsEqual');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/**\n * The base implementation of `_.isMatch` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property values to match.\n * @param {Array} matchData The property names, values, and compare flags to match.\n * @param {Function} [customizer] The function to customize comparisons.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n */\nfunction baseIsMatch(object, source, matchData, customizer) {\n var index = matchData.length,\n length = index,\n noCustomizer = !customizer;\n\n if (object == null) {\n return !length;\n }\n object = Object(object);\n while (index--) {\n var data = matchData[index];\n if ((noCustomizer && data[2])\n ? data[1] !== object[data[0]]\n : !(data[0] in object)\n ) {\n return false;\n }\n }\n while (++index < length) {\n data = matchData[index];\n var key = data[0],\n objValue = object[key],\n srcValue = data[1];\n\n if (noCustomizer && data[2]) {\n if (objValue === undefined && !(key in object)) {\n return false;\n }\n } else {\n var stack = new Stack;\n if (customizer) {\n var result = customizer(objValue, srcValue, key, object, source, stack);\n }\n if (!(result === undefined\n ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)\n : result\n )) {\n return false;\n }\n }\n }\n return true;\n}\n\nmodule.exports = baseIsMatch;\n","var isObject = require('./isObject');\n\n/**\n * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` if suitable for strict\n * equality comparisons, else `false`.\n */\nfunction isStrictComparable(value) {\n return value === value && !isObject(value);\n}\n\nmodule.exports = isStrictComparable;\n","var isStrictComparable = require('./_isStrictComparable'),\n keys = require('./keys');\n\n/**\n * Gets the property names, values, and compare flags of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the match data of `object`.\n */\nfunction getMatchData(object) {\n var result = keys(object),\n length = result.length;\n\n while (length--) {\n var key = result[length],\n value = object[key];\n\n result[length] = [key, value, isStrictComparable(value)];\n }\n return result;\n}\n\nmodule.exports = getMatchData;\n","/**\n * A specialized version of `matchesProperty` for source values suitable\n * for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction matchesStrictComparable(key, srcValue) {\n return function(object) {\n if (object == null) {\n return false;\n }\n return object[key] === srcValue &&\n (srcValue !== undefined || (key in Object(object)));\n };\n}\n\nmodule.exports = matchesStrictComparable;\n","var baseIsMatch = require('./_baseIsMatch'),\n getMatchData = require('./_getMatchData'),\n matchesStrictComparable = require('./_matchesStrictComparable');\n\n/**\n * The base implementation of `_.matches` which doesn't clone `source`.\n *\n * @private\n * @param {Object} source The object of property values to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction baseMatches(source) {\n var matchData = getMatchData(source);\n if (matchData.length == 1 && matchData[0][2]) {\n return matchesStrictComparable(matchData[0][0], matchData[0][1]);\n }\n return function(object) {\n return object === source || baseIsMatch(object, source, matchData);\n };\n}\n\nmodule.exports = baseMatches;\n","var baseGetTag = require('./_baseGetTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nmodule.exports = isSymbol;\n","var isArray = require('./isArray'),\n isSymbol = require('./isSymbol');\n\n/** Used to match property names within property paths. */\nvar reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,\n reIsPlainProp = /^\\w*$/;\n\n/**\n * Checks if `value` is a property name and not a property path.\n *\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n */\nfunction isKey(value, object) {\n if (isArray(value)) {\n return false;\n }\n var type = typeof value;\n if (type == 'number' || type == 'symbol' || type == 'boolean' ||\n value == null || isSymbol(value)) {\n return true;\n }\n return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||\n (object != null && value in Object(object));\n}\n\nmodule.exports = isKey;\n","var MapCache = require('./_MapCache');\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * **Note:** The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `_.memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `clear`, `delete`, `get`, `has`, and `set`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n * var other = { 'c': 3, 'd': 4 };\n *\n * var values = _.memoize(_.values);\n * values(object);\n * // => [1, 2]\n *\n * values(other);\n * // => [3, 4]\n *\n * object.a = 2;\n * values(object);\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b']);\n * values(object);\n * // => ['a', 'b']\n *\n * // Replace `_.memoize.Cache`.\n * _.memoize.Cache = WeakMap;\n */\nfunction memoize(func, resolver) {\n if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var memoized = function() {\n var args = arguments,\n key = resolver ? resolver.apply(this, args) : args[0],\n cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n var result = func.apply(this, args);\n memoized.cache = cache.set(key, result) || cache;\n return result;\n };\n memoized.cache = new (memoize.Cache || MapCache);\n return memoized;\n}\n\n// Expose `MapCache`.\nmemoize.Cache = MapCache;\n\nmodule.exports = memoize;\n","var memoize = require('./memoize');\n\n/** Used as the maximum memoize cache size. */\nvar MAX_MEMOIZE_SIZE = 500;\n\n/**\n * A specialized version of `_.memoize` which clears the memoized function's\n * cache when it exceeds `MAX_MEMOIZE_SIZE`.\n *\n * @private\n * @param {Function} func The function to have its output memoized.\n * @returns {Function} Returns the new memoized function.\n */\nfunction memoizeCapped(func) {\n var result = memoize(func, function(key) {\n if (cache.size === MAX_MEMOIZE_SIZE) {\n cache.clear();\n }\n return key;\n });\n\n var cache = result.cache;\n return result;\n}\n\nmodule.exports = memoizeCapped;\n","var memoizeCapped = require('./_memoizeCapped');\n\n/** Used to match property names within property paths. */\nvar rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g;\n\n/** Used to match backslashes in property paths. */\nvar reEscapeChar = /\\\\(\\\\)?/g;\n\n/**\n * Converts `string` to a property path array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\nvar stringToPath = memoizeCapped(function(string) {\n var result = [];\n if (string.charCodeAt(0) === 46 /* . */) {\n result.push('');\n }\n string.replace(rePropName, function(match, number, quote, subString) {\n result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));\n });\n return result;\n});\n\nmodule.exports = stringToPath;\n","/**\n * A specialized version of `_.map` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\nfunction arrayMap(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n}\n\nmodule.exports = arrayMap;\n","var Symbol = require('./_Symbol'),\n arrayMap = require('./_arrayMap'),\n isArray = require('./isArray'),\n isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isArray(value)) {\n // Recursively convert values (susceptible to call stack limits).\n return arrayMap(value, baseToString) + '';\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nmodule.exports = baseToString;\n","var baseToString = require('./_baseToString');\n\n/**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\nfunction toString(value) {\n return value == null ? '' : baseToString(value);\n}\n\nmodule.exports = toString;\n","var isArray = require('./isArray'),\n isKey = require('./_isKey'),\n stringToPath = require('./_stringToPath'),\n toString = require('./toString');\n\n/**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {Object} [object] The object to query keys on.\n * @returns {Array} Returns the cast property path array.\n */\nfunction castPath(value, object) {\n if (isArray(value)) {\n return value;\n }\n return isKey(value, object) ? [value] : stringToPath(toString(value));\n}\n\nmodule.exports = castPath;\n","var isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n */\nfunction toKey(value) {\n if (typeof value == 'string' || isSymbol(value)) {\n return value;\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nmodule.exports = toKey;\n","var castPath = require('./_castPath'),\n toKey = require('./_toKey');\n\n/**\n * The base implementation of `_.get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\nfunction baseGet(object, path) {\n path = castPath(path, object);\n\n var index = 0,\n length = path.length;\n\n while (object != null && index < length) {\n object = object[toKey(path[index++])];\n }\n return (index && index == length) ? object : undefined;\n}\n\nmodule.exports = baseGet;\n","var baseGet = require('./_baseGet');\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.get(object, 'a[0].b.c');\n * // => 3\n *\n * _.get(object, ['a', '0', 'b', 'c']);\n * // => 3\n *\n * _.get(object, 'a.b.c', 'default');\n * // => 'default'\n */\nfunction get(object, path, defaultValue) {\n var result = object == null ? undefined : baseGet(object, path);\n return result === undefined ? defaultValue : result;\n}\n\nmodule.exports = get;\n","/**\n * The base implementation of `_.hasIn` without support for deep paths.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {Array|string} key The key to check.\n * @returns {boolean} Returns `true` if `key` exists, else `false`.\n */\nfunction baseHasIn(object, key) {\n return object != null && key in Object(object);\n}\n\nmodule.exports = baseHasIn;\n","var castPath = require('./_castPath'),\n isArguments = require('./isArguments'),\n isArray = require('./isArray'),\n isIndex = require('./_isIndex'),\n isLength = require('./isLength'),\n toKey = require('./_toKey');\n\n/**\n * Checks if `path` exists on `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @param {Function} hasFunc The function to check properties.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n */\nfunction hasPath(object, path, hasFunc) {\n path = castPath(path, object);\n\n var index = -1,\n length = path.length,\n result = false;\n\n while (++index < length) {\n var key = toKey(path[index]);\n if (!(result = object != null && hasFunc(object, key))) {\n break;\n }\n object = object[key];\n }\n if (result || ++index != length) {\n return result;\n }\n length = object == null ? 0 : object.length;\n return !!length && isLength(length) && isIndex(key, length) &&\n (isArray(object) || isArguments(object));\n}\n\nmodule.exports = hasPath;\n","var baseHasIn = require('./_baseHasIn'),\n hasPath = require('./_hasPath');\n\n/**\n * Checks if `path` is a direct or inherited property of `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n * @example\n *\n * var object = _.create({ 'a': _.create({ 'b': 2 }) });\n *\n * _.hasIn(object, 'a');\n * // => true\n *\n * _.hasIn(object, 'a.b');\n * // => true\n *\n * _.hasIn(object, ['a', 'b']);\n * // => true\n *\n * _.hasIn(object, 'b');\n * // => false\n */\nfunction hasIn(object, path) {\n return object != null && hasPath(object, path, baseHasIn);\n}\n\nmodule.exports = hasIn;\n","var baseIsEqual = require('./_baseIsEqual'),\n get = require('./get'),\n hasIn = require('./hasIn'),\n isKey = require('./_isKey'),\n isStrictComparable = require('./_isStrictComparable'),\n matchesStrictComparable = require('./_matchesStrictComparable'),\n toKey = require('./_toKey');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/**\n * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.\n *\n * @private\n * @param {string} path The path of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction baseMatchesProperty(path, srcValue) {\n if (isKey(path) && isStrictComparable(srcValue)) {\n return matchesStrictComparable(toKey(path), srcValue);\n }\n return function(object) {\n var objValue = get(object, path);\n return (objValue === undefined && objValue === srcValue)\n ? hasIn(object, path)\n : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);\n };\n}\n\nmodule.exports = baseMatchesProperty;\n","/**\n * The base implementation of `_.property` without support for deep paths.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\nfunction baseProperty(key) {\n return function(object) {\n return object == null ? undefined : object[key];\n };\n}\n\nmodule.exports = baseProperty;\n","var baseGet = require('./_baseGet');\n\n/**\n * A specialized version of `baseProperty` which supports deep paths.\n *\n * @private\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\nfunction basePropertyDeep(path) {\n return function(object) {\n return baseGet(object, path);\n };\n}\n\nmodule.exports = basePropertyDeep;\n","var baseProperty = require('./_baseProperty'),\n basePropertyDeep = require('./_basePropertyDeep'),\n isKey = require('./_isKey'),\n toKey = require('./_toKey');\n\n/**\n * Creates a function that returns the value at `path` of a given object.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n * @example\n *\n * var objects = [\n * { 'a': { 'b': 2 } },\n * { 'a': { 'b': 1 } }\n * ];\n *\n * _.map(objects, _.property('a.b'));\n * // => [2, 1]\n *\n * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');\n * // => [1, 2]\n */\nfunction property(path) {\n return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);\n}\n\nmodule.exports = property;\n","var baseMatches = require('./_baseMatches'),\n baseMatchesProperty = require('./_baseMatchesProperty'),\n identity = require('./identity'),\n isArray = require('./isArray'),\n property = require('./property');\n\n/**\n * The base implementation of `_.iteratee`.\n *\n * @private\n * @param {*} [value=_.identity] The value to convert to an iteratee.\n * @returns {Function} Returns the iteratee.\n */\nfunction baseIteratee(value) {\n // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.\n // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.\n if (typeof value == 'function') {\n return value;\n }\n if (value == null) {\n return identity;\n }\n if (typeof value == 'object') {\n return isArray(value)\n ? baseMatchesProperty(value[0], value[1])\n : baseMatches(value);\n }\n return property(value);\n}\n\nmodule.exports = baseIteratee;\n","var baseAssignValue = require('./_baseAssignValue'),\n baseForOwn = require('./_baseForOwn'),\n baseIteratee = require('./_baseIteratee');\n\n/**\n * Creates an object with the same keys as `object` and values generated\n * by running each own enumerable string keyed property of `object` thru\n * `iteratee`. The iteratee is invoked with three arguments:\n * (value, key, object).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns the new mapped object.\n * @see _.mapKeys\n * @example\n *\n * var users = {\n * 'fred': { 'user': 'fred', 'age': 40 },\n * 'pebbles': { 'user': 'pebbles', 'age': 1 }\n * };\n *\n * _.mapValues(users, function(o) { return o.age; });\n * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)\n *\n * // The `_.property` iteratee shorthand.\n * _.mapValues(users, 'age');\n * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)\n */\nfunction mapValues(object, iteratee) {\n var result = {};\n iteratee = baseIteratee(iteratee, 3);\n\n baseForOwn(object, function(value, key, object) {\n baseAssignValue(result, key, iteratee(value, key, object));\n });\n return result;\n}\n\nmodule.exports = mapValues;\n","var isArrayLike = require('./isArrayLike');\n\n/**\n * Creates a `baseEach` or `baseEachRight` function.\n *\n * @private\n * @param {Function} eachFunc The function to iterate over a collection.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\nfunction createBaseEach(eachFunc, fromRight) {\n return function(collection, iteratee) {\n if (collection == null) {\n return collection;\n }\n if (!isArrayLike(collection)) {\n return eachFunc(collection, iteratee);\n }\n var length = collection.length,\n index = fromRight ? length : -1,\n iterable = Object(collection);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (iteratee(iterable[index], index, iterable) === false) {\n break;\n }\n }\n return collection;\n };\n}\n\nmodule.exports = createBaseEach;\n","var baseForOwn = require('./_baseForOwn'),\n createBaseEach = require('./_createBaseEach');\n\n/**\n * The base implementation of `_.forEach` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array|Object} Returns `collection`.\n */\nvar baseEach = createBaseEach(baseForOwn);\n\nmodule.exports = baseEach;\n","var baseEach = require('./_baseEach');\n\n/**\n * The base implementation of `_.some` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\nfunction baseSome(collection, predicate) {\n var result;\n\n baseEach(collection, function(value, index, collection) {\n result = predicate(value, index, collection);\n return !result;\n });\n return !!result;\n}\n\nmodule.exports = baseSome;\n","var arraySome = require('./_arraySome'),\n baseIteratee = require('./_baseIteratee'),\n baseSome = require('./_baseSome'),\n isArray = require('./isArray'),\n isIterateeCall = require('./_isIterateeCall');\n\n/**\n * Checks if `predicate` returns truthy for **any** element of `collection`.\n * Iteration is stopped once `predicate` returns truthy. The predicate is\n * invoked with three arguments: (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n * @example\n *\n * _.some([null, 0, 'yes', false], Boolean);\n * // => true\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false }\n * ];\n *\n * // The `_.matches` iteratee shorthand.\n * _.some(users, { 'user': 'barney', 'active': false });\n * // => false\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.some(users, ['active', false]);\n * // => true\n *\n * // The `_.property` iteratee shorthand.\n * _.some(users, 'active');\n * // => true\n */\nfunction some(collection, predicate, guard) {\n var func = isArray(collection) ? arraySome : baseSome;\n if (guard && isIterateeCall(collection, predicate, guard)) {\n predicate = undefined;\n }\n return func(collection, baseIteratee(predicate, 3));\n}\n\nmodule.exports = some;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar assign = require(\"lodash/assign\");\nvar mapValues = require(\"lodash/mapValues\");\nvar some = require(\"lodash/some\");\nvar NgComponent = /** @class */ (function () {\n function NgComponent() {\n this.__isFirstRender = true;\n this.state = {};\n this.props = {};\n }\n /*\n eg. {\n as: {currentValue: [1, 2, 3], previousValue: [1, 2]},\n bs: {currentValue: 42, previousValue: undefined}\n }\n */\n // nb: this method is explicity exposed for unit testing\n NgComponent.prototype.$onChanges = function (changes) {\n var oldProps = this.props;\n // TODO: fix Lodash typings upstream\n var newProps = mapValues(changes, 'currentValue');\n // TODO: implement nextState (which also means implement this.setState)\n var nextProps = assign({}, this.props, newProps);\n if (this.__isFirstRender) {\n assign(this, { props: nextProps });\n this.componentWillMount();\n this.render();\n this.__isFirstRender = false;\n }\n else {\n if (!this.didPropsChange(newProps, oldProps))\n return;\n this.componentWillReceiveProps(nextProps);\n var shouldUpdate = this.shouldComponentUpdate(nextProps, this.state);\n assign(this, { props: nextProps });\n if (!shouldUpdate)\n return;\n this.componentWillUpdate(this.props, this.state);\n this.render();\n this.componentDidUpdate(this.props, this.state);\n }\n };\n NgComponent.prototype.$postLink = function () {\n this.componentDidMount();\n };\n NgComponent.prototype.$onDestroy = function () {\n this.componentWillUnmount();\n };\n NgComponent.prototype.didPropsChange = function (newProps, oldProps) {\n return some(newProps, function (v, k) { return v !== oldProps[k]; });\n };\n /*\n lifecycle hooks\n */\n NgComponent.prototype.componentWillMount = function () { };\n NgComponent.prototype.componentDidMount = function () { };\n NgComponent.prototype.componentWillReceiveProps = function (_props) { };\n NgComponent.prototype.shouldComponentUpdate = function (_nextProps, _nextState) { return true; };\n NgComponent.prototype.componentWillUpdate = function (_props, _state) { };\n NgComponent.prototype.componentDidUpdate = function (_props, _state) { };\n NgComponent.prototype.componentWillUnmount = function () { };\n NgComponent.prototype.render = function () { };\n return NgComponent;\n}());\nexports.default = NgComponent;\n//# sourceMappingURL=index.js.map","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar fromPairs = require(\"lodash.frompairs\");\nvar ngcomponent_1 = require(\"ngcomponent\");\nvar React = require(\"react\");\nvar react_dom_1 = require(\"react-dom\");\n/**\n * Wraps a React component in Angular. Returns a new Angular component.\n *\n * Usage:\n *\n * ```ts\n * type Props = { foo: number }\n * class ReactComponent extends React.Component {}\n * const AngularComponent = react2angular(ReactComponent, ['foo'])\n * ```\n */\nfunction react2angular(Class, bindingNames, injectNames) {\n if (bindingNames === void 0) { bindingNames = null; }\n if (injectNames === void 0) { injectNames = []; }\n var names = bindingNames\n || (Class.propTypes && Object.keys(Class.propTypes))\n || [];\n return {\n bindings: fromPairs(names.map(function (_) { return [_, '<']; })),\n controller: ['$element'].concat(injectNames, [/** @class */ (function (_super) {\n __extends(class_1, _super);\n function class_1($element) {\n var injectedProps = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n injectedProps[_i - 1] = arguments[_i];\n }\n var _this = _super.call(this) || this;\n _this.$element = $element;\n _this.isDestroyed = false;\n _this.injectedProps = {};\n injectNames.forEach(function (name, i) {\n _this.injectedProps[name] = injectedProps[i];\n });\n return _this;\n }\n Object.defineProperty(class_1, \"$$ngIsClass\", {\n get: function () {\n return true;\n },\n enumerable: true,\n configurable: true\n });\n class_1.prototype.render = function () {\n if (!this.isDestroyed) {\n react_dom_1.render(React.createElement(Class, __assign({}, this.props, this.injectedProps)), this.$element[0]);\n }\n };\n class_1.prototype.componentWillUnmount = function () {\n this.isDestroyed = true;\n react_dom_1.unmountComponentAtNode(this.$element[0]);\n };\n return class_1;\n }(ngcomponent_1.default))])\n };\n}\nexports.react2angular = react2angular;\n//# sourceMappingURL=index.js.map","import { TestComponent1, TestComponent2 } from \"@react/ReactTest\";\r\nimport angular from \"angular\";\r\nimport { react2angular } from \"react2angular\";\r\n\r\nexport function registerReactComponents() {\r\n angular\r\n .module(\"ccqapp\")\r\n .component(\"testComponent1\", react2angular(TestComponent1))\r\n .component(\r\n \"testComponent2\",\r\n react2angular(TestComponent2, [\"fooBar\", \"baz\"]),\r\n );\r\n}\r\n","import { PageWithTotalCountDTO } from \"@js/DTO/PageWithTotalCountDTO.cs.d\";\r\nimport { BroadcastService } from \"./BroadcastService\";\r\n\r\nexport class BaseService {\r\n protected $baseAddress: string; //base route\r\n protected $broadcastScreen: string;\r\n protected $broadcastBusinessNameSingular: string;\r\n protected $broadcastBusinessNamePlural: string;\r\n\r\n constructor(\r\n protected $http: ng.IHttpService,\r\n protected $cookies: ng.cookies.ICookiesService,\r\n protected $rootScope: ng.IRootScopeService,\r\n protected $q: ng.IQService,\r\n protected $timeout: ng.ITimeoutService,\r\n protected $broadcastservice: BroadcastService,\r\n ) {\r\n this.$broadcastScreen = \"NotSet\";\r\n this.$broadcastBusinessNamePlural = \"NotSet\";\r\n this.$broadcastBusinessNameSingular = \"NotSet\";\r\n }\r\n\r\n //paging with filter\r\n fetchpageneedle(\r\n needle: string,\r\n page: number,\r\n count: number,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/pagedneedle?needle=\" +\r\n needle +\r\n \"&page=\" +\r\n page +\r\n \"&Count=\" +\r\n count,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as PageWithTotalCountDTO);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n protected fetchAllInternal(\r\n screen: string,\r\n message: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(this.$baseAddress + \"/list\")\r\n .then((response) => {\r\n defer.resolve(response.data as T[]);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(screen, message);\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n fetchAll(): ng.IPromise {\r\n return this.fetchAllInternal(\r\n this.$broadcastScreen,\r\n \"Unable to get a list of \" +\r\n this.$broadcastBusinessNamePlural +\r\n \" from the Please try again shortly.\",\r\n );\r\n }\r\n\r\n protected fetchInternal(\r\n id: IDT,\r\n screen: string,\r\n message: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(this.$baseAddress + \"/fetch/\" + id.toString())\r\n .then((response) => {\r\n defer.resolve(response.data as T);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(screen, message);\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n fetch(id: IDT): ng.IPromise {\r\n return this.fetchInternal(\r\n id,\r\n this.$broadcastScreen,\r\n \"Unable to get a list of \" +\r\n this.$broadcastBusinessNamePlural +\r\n \" from the Please try again shortly.\",\r\n );\r\n }\r\n\r\n protected countInternal(\r\n screen: string,\r\n message: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(this.$baseAddress + \"/count\")\r\n .then((response) => {\r\n defer.resolve(response.data as number);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(screen, message);\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n count(): ng.IPromise {\r\n return this.countInternal(\r\n this.$broadcastScreen,\r\n \"Unable to get count of \" +\r\n this.$broadcastBusinessNamePlural +\r\n \" from the Please try again shortly.\",\r\n );\r\n }\r\n\r\n protected fetchpageInternal(\r\n needle: string,\r\n page: number,\r\n count: number,\r\n screen: string,\r\n message: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/paged?needle=\" +\r\n needle +\r\n \"&page=\" +\r\n page +\r\n \"&Count=\" +\r\n count,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as PageWithTotalCountDTO);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(screen, message);\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n fetchpage(\r\n needle: string,\r\n page: number,\r\n count: number,\r\n ): ng.IPromise {\r\n return this.fetchpageInternal(\r\n needle,\r\n page,\r\n count,\r\n this.$broadcastScreen,\r\n \"Unable to get a list of \" +\r\n this.$broadcastBusinessNamePlural +\r\n \" from the Please try again shortly.\",\r\n );\r\n }\r\n\r\n protected processDtoBeforeAddUpdate(dto: T): T {\r\n return dto;\r\n }\r\n\r\n addUpdateInternal(dto: T, screen: string, message: string): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n dto = this.processDtoBeforeAddUpdate(dto);\r\n\r\n this.$http\r\n .post(\r\n this.$baseAddress + \"/addupdate\",\r\n JSON.stringify(dto, this.jsonPropertyReplacer),\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as T);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(screen, message);\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n jsonPropertyReplacer(key: string, value: any) {\r\n return value; //can be overidden to disable properties form going up\r\n }\r\n addUpdate(dtos: T): ng.IPromise {\r\n return this.addUpdateInternal(\r\n dtos,\r\n this.$broadcastScreen,\r\n \"Unable to add update \" +\r\n this.$broadcastBusinessNamePlural +\r\n \" from the Please try again shortly.\",\r\n );\r\n }\r\n addUpdatereturnonlyidInternal(\r\n dto: T,\r\n screen: string,\r\n message: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n dto = this.processDtoBeforeAddUpdate(dto);\r\n\r\n this.$http\r\n .post(\r\n this.$baseAddress + \"/addupdatereturnonlyid\",\r\n JSON.stringify(dto, this.jsonPropertyReplacer),\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as number);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(screen, message);\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n addUpdatereturnonlyid(dtos: T): ng.IPromise {\r\n return this.addUpdatereturnonlyidInternal(\r\n dtos,\r\n this.$broadcastScreen,\r\n \"Unable to add update \" +\r\n this.$broadcastBusinessNamePlural +\r\n \" from the Please try again shortly.\",\r\n );\r\n }\r\n addUpdatelistInternal(\r\n dto: T[],\r\n screen: string,\r\n message: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .post(this.$baseAddress + \"/addupdatelist\", JSON.stringify(dto))\r\n .then((response) => {\r\n defer.resolve(response.data as T[]);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(screen, message);\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n addUpdatelist(dtos: T[]): ng.IPromise {\r\n return this.addUpdatelistInternal(\r\n dtos,\r\n this.$broadcastScreen,\r\n \"Unable to add update list \" +\r\n this.$broadcastBusinessNamePlural +\r\n \" from the Please try again shortly.\",\r\n );\r\n }\r\n\r\n addUpdatelistreturnonlyidsInternal(\r\n dto: T[],\r\n screen: string,\r\n message: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .post(\r\n this.$baseAddress + \"/addupdatelistreturnonlyid\",\r\n JSON.stringify(dto),\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as number[]);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(screen, message);\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n addUpdatelistreturnonlyids(dtos: T[]): ng.IPromise {\r\n return this.addUpdatelistreturnonlyidsInternal(\r\n dtos,\r\n this.$broadcastScreen,\r\n \"Unable to add update list \" +\r\n this.$broadcastBusinessNamePlural +\r\n \" from the Please try again shortly.\",\r\n );\r\n }\r\n\r\n deleteInternal(\r\n id: IDT,\r\n screen: string,\r\n message: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .delete(this.$baseAddress + \"/remove/\" + id)\r\n .then(() => {\r\n defer.resolve(true);\r\n })\r\n .catch(() => {\r\n this.$broadcastservice.broadcastError(screen, message);\r\n defer.reject(false);\r\n });\r\n return defer.promise;\r\n }\r\n delete(id: IDT): ng.IPromise {\r\n return this.deleteInternal(\r\n id,\r\n this.$broadcastScreen,\r\n \"Unable to delete \" +\r\n this.$broadcastBusinessNamePlural +\r\n \" from the Please try again shortly.\",\r\n );\r\n }\r\n\r\n markasdeletedInternal(\r\n id: IDT,\r\n screen: string,\r\n message: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .delete(this.$baseAddress + \"/markasdeleted/\" + id + \"/\")\r\n .then(() => {\r\n defer.resolve(true);\r\n })\r\n .catch(() => {\r\n this.$broadcastservice.broadcastError(screen, message);\r\n defer.reject(false);\r\n });\r\n return defer.promise;\r\n }\r\n markasdeleted(id: IDT): ng.IPromise {\r\n return this.markasdeletedInternal(\r\n id,\r\n this.$broadcastScreen,\r\n \"Unable to mark as deleted \" +\r\n this.$broadcastBusinessNamePlural +\r\n \" from the Please try again shortly.\",\r\n );\r\n }\r\n\r\n isSavedObject(dto: T): boolean {\r\n return dto && (dto as any).Id && (dto as any).Id > 0;\r\n }\r\n}\r\n","import { AccountDTO } from \"@js/DTO/AccountDTO.cs.d\";\r\nimport { WebConfigDTO } from \"@js/DTO/WebConfigDTO.cs.d\";\r\nimport { BaseService } from \"@js/filesfromccqbase/BaseService\";\r\nimport { BroadcastService } from \"@js/filesfromccqbase/BroadcastService\";\r\nimport { ProductFamilyEnum } from \"@js/models/enum/ProductFamilyEnum.cs.d\";\r\n\r\nexport class AccountService extends BaseService {\r\n static $inject = [\r\n \"$http\",\r\n \"$cookies\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$timeout\",\r\n \"BroadcastService\",\r\n ];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n broadcastservice: BroadcastService,\r\n ) {\r\n super(http, cookies, rootScope, q, timeout, broadcastservice);\r\n this.$baseAddress = \"/api/account\";\r\n this.$broadcastBusinessNameSingular = \"Account\";\r\n this.$broadcastBusinessNamePlural =\r\n this.$broadcastBusinessNameSingular + \"s\";\r\n this.$broadcastScreen = this.$broadcastBusinessNamePlural;\r\n }\r\n SendLoansAdvertEmail(\r\n name: string,\r\n from: string,\r\n To: string,\r\n themessage: string,\r\n ): ng.IPromise {\r\n themessage = themessage.replace(/\\n/g, \"
\");\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/sendloansadvertemail?name=\" +\r\n name +\r\n \"&from=\" +\r\n from +\r\n \"&To=\" +\r\n To +\r\n \"&themessage=\" +\r\n themessage,\r\n )\r\n .then((response) => {\r\n let results: boolean = response.data as boolean;\r\n defer.resolve(results);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n SendFriendReferralEmail(\r\n username: string,\r\n usersurname: string,\r\n useremail: string,\r\n friendname: string,\r\n friendsurname: string,\r\n friendemail: string,\r\n friendbody: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/sendfriendreferralemail?username=\" +\r\n username +\r\n \"&usersurname=\" +\r\n usersurname +\r\n \"&useremail=\" +\r\n useremail +\r\n \"&friendname=\" +\r\n friendname +\r\n \"&friendsurname=\" +\r\n friendsurname +\r\n \"&friendemail=\" +\r\n friendemail +\r\n \"&friendbody=\" +\r\n friendbody,\r\n )\r\n .then((response) => {\r\n let results: boolean = response.data as boolean;\r\n defer.resolve(results);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n RequestAssistanceReview(\r\n reason: string,\r\n caseid: number,\r\n productFamily: ProductFamilyEnum = ProductFamilyEnum.None,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/requestassistancereview?reason=\" +\r\n reason +\r\n \"&caseid=\" +\r\n caseid +\r\n \"&productFamily=\" +\r\n productFamily,\r\n )\r\n .then((response) => {\r\n let results: boolean = response.data as boolean;\r\n defer.resolve(results);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n SendIntroducerRegistrationEmail(\r\n introducerEmail: string,\r\n introducerFirstName: string,\r\n introducerCode: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n var encodeUserName = encodeURIComponent(introducerEmail);\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/sendintroducerregistrationemail?introducerEmail=\" +\r\n encodeUserName +\r\n \"&introducerFirstName=\" +\r\n introducerFirstName +\r\n \"&introducerCode=\" +\r\n introducerCode,\r\n )\r\n .then((response) => {\r\n let results: boolean = response.data as boolean;\r\n defer.resolve(results);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n getFooterWebConfigValue(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(this.$baseAddress + \"/getfooterwebconfigvalue\")\r\n .then((response) => {\r\n defer.resolve(response.data as WebConfigDTO);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"getfooterwebconfigvalue\",\r\n \"web config Value failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n}\r\n","import { AppPackagePricingDTO } from \"@js/DTO/AppPackagePricingDTO.cs.d\";\r\nimport { LicenseAppPackageDTO } from \"@js/DTO/LicenseAppPackageDTO.cs.d\";\r\nimport { PaymentSessionDTO } from \"@js/DTO/StripeSessionDTO.cs.d\";\r\n\r\nexport class AccountSettingService {\r\n $http: ng.IHttpService;\r\n $cookies: ng.cookies.ICookiesService;\r\n $rootScope: ng.IRootScopeService;\r\n $q: ng.IQService;\r\n $timeout: ng.ITimeoutService;\r\n $baseAddress: string;\r\n\r\n static $inject = [\"$http\", \"$cookies\", \"$rootScope\", \"$q\", \"$timeout\"];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n ) {\r\n this.$http = http;\r\n this.$cookies = cookies;\r\n this.$rootScope = rootScope;\r\n this.$q = q;\r\n this.$timeout = timeout;\r\n this.$baseAddress = \"/api/pay\";\r\n }\r\n\r\n createCheckoutSessionForUnpaid(\r\n products: AppPackagePricingDTO[],\r\n selectedUserName: string = \"\",\r\n isAddOnSelected: boolean,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n var encodeUserName =\r\n selectedUserName != \"\" ? encodeURIComponent(selectedUserName) : \"\";\r\n this.$http\r\n .post(\r\n this.$baseAddress +\r\n \"/createcheckoutsessionforunpaid?selectedUserName=\" +\r\n encodeUserName +\r\n \"&isAddOnSelected=\" +\r\n isAddOnSelected,\r\n products,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as PaymentSessionDTO);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n updateSubscription(\r\n products: AppPackagePricingDTO[],\r\n selectedUserName: string,\r\n isAddOnSelected: boolean,\r\n isUpdateWithPrecancel: boolean = false,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n var encodeUserName = selectedUserName\r\n ? encodeURIComponent(selectedUserName)\r\n : selectedUserName;\r\n this.$http\r\n .post(\r\n this.$baseAddress +\r\n \"/updateplanprice?selectedUserName=\" +\r\n encodeUserName +\r\n \"&isAddOnSelected=\" +\r\n isAddOnSelected +\r\n \"&isUpdateWithPrecancel=\" +\r\n isUpdateWithPrecancel,\r\n products,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n getSelectedPackagesForCurrentuser(\r\n userName: string = \"\",\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n var encodeUserName = userName ? encodeURIComponent(userName) : userName;\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/getselectedpackageforcurrentuser?userName=\" +\r\n encodeUserName,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as LicenseAppPackageDTO[]);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n assignLicense(userId: string, orgId: number): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/assignlicense?userId=\" +\r\n userId +\r\n \"&orgId=\" +\r\n orgId,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n unAssignLicense(userId: string): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(this.$baseAddress + \"/unassignlicense?userId=\" + userId)\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n updatePreCancelSubscription(\r\n products: AppPackagePricingDTO[],\r\n selectedUserName: string,\r\n isAddOnSelected: boolean,\r\n isUpdateWithPrecancel: boolean = false,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n var encodeUserName = selectedUserName\r\n ? encodeURIComponent(selectedUserName)\r\n : selectedUserName;\r\n this.$http\r\n .post(\r\n this.$baseAddress +\r\n \"/updateprecancelsubscription?selectedUserName=\" +\r\n encodeUserName +\r\n \"&isAddOnSelected=\" +\r\n isAddOnSelected +\r\n \"&isUpdateWithPrecancel=\" +\r\n isUpdateWithPrecancel,\r\n products,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n assignCustomePrice(\r\n customPrice: string,\r\n numberOfLicenses: number,\r\n orgId: number,\r\n isAddOnSelected: boolean,\r\n isMonthlySubscription: boolean,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/assigncustomprice?customPrice=\" +\r\n customPrice +\r\n \"&numberOfLicenses=\" +\r\n numberOfLicenses +\r\n \"&orgId=\" +\r\n orgId +\r\n \"&isAddOnSelected=\" +\r\n isAddOnSelected +\r\n \"&isMonthlySubscription=\" +\r\n isMonthlySubscription,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n assignStandardPrice(orgId: number): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(this.$baseAddress + \"/assignstandardprice?orgId=\" + orgId)\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n offerLeadGeneratorLicense(\r\n leadGenPackage: LicenseAppPackageDTO,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .post(this.$baseAddress + \"/offerleadgeneratorlicense\", leadGenPackage)\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n offerCustomPrice(\r\n customPrice: string,\r\n numberOfLicenses: number,\r\n orgId: number,\r\n isAddOnSelected: boolean,\r\n isMonthlySubscription: boolean,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/offercustomprice?customPrice=\" +\r\n customPrice +\r\n \"&numberOfLicenses=\" +\r\n numberOfLicenses +\r\n \"&orgId=\" +\r\n orgId +\r\n \"&isAddOnSelected=\" +\r\n isAddOnSelected +\r\n \"&isMonthlySubscription=\" +\r\n isMonthlySubscription,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n /* addAddOnToLicense(orgId: number): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http.get(this.$baseAddress + \"/addaddontolicense?orgId=\" + orgId).then((response) => {\r\n defer.resolve(response.data as boolean);\r\n }).catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n removeAddOnFromLicense(orgId: number): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http.get(this.$baseAddress + \"/removeaddonfromlicense?orgId=\" + orgId).then((response) => {\r\n defer.resolve(response.data as boolean);\r\n }).catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }*/\r\n\r\n cancelLeadGeneratorOffer(\r\n selectedleadGenPackageId: number,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/cancelleadgeneratoroffer?selectedleadGenPackageId=\" +\r\n selectedleadGenPackageId,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n}\r\n","import { CaseMemberDTO } from \"@js/DTO/CaseMemberDTO.cs.d\";\r\nimport { BaseService } from \"@js/filesfromccqbase/BaseService\";\r\nimport { BroadcastService } from \"@js/filesfromccqbase/BroadcastService\";\r\n\r\nexport class ApplicantService extends BaseService {\r\n static $inject = [\r\n \"$http\",\r\n \"$cookies\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$timeout\",\r\n \"BroadcastService\",\r\n ];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n broadcastservice: BroadcastService,\r\n ) {\r\n super(http, cookies, rootScope, q, timeout, broadcastservice);\r\n this.$baseAddress = \"/api/applicant\";\r\n this.$broadcastBusinessNameSingular = \"applicant\";\r\n this.$broadcastBusinessNamePlural =\r\n this.$broadcastBusinessNameSingular + \"s\";\r\n this.$broadcastScreen = this.$broadcastBusinessNamePlural;\r\n }\r\n\r\n addOrUpdateCaseMember(\r\n dto: CaseMemberDTO,\r\n sendInviteEmail: boolean = false,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .post(\r\n this.$baseAddress +\r\n \"/addorupdatecasemember?sendInviteEmail=\" +\r\n sendInviteEmail,\r\n dto,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as CaseMemberDTO);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"AddOrUpdateCaseMember\",\r\n \"AddOrUpdateCaseMember failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n}\r\n","import { AssetLiabilityItemDTO } from \"@js/DTO/AssetLiabilityItemDTO.cs.d\";\r\nimport { BaseService } from \"@js/filesfromccqbase/BaseService\";\r\nimport { BroadcastService } from \"@js/filesfromccqbase/BroadcastService\";\r\n\r\nexport class AssetLiabilityItemService extends BaseService<\r\n AssetLiabilityItemDTO,\r\n number\r\n> {\r\n static $inject = [\r\n \"$http\",\r\n \"$cookies\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$timeout\",\r\n \"BroadcastService\",\r\n ];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n broadcastservice: BroadcastService,\r\n ) {\r\n super(http, cookies, rootScope, q, timeout, broadcastservice);\r\n this.$baseAddress = \"/api/assetliability\";\r\n this.$broadcastBusinessNameSingular = \"assetliability\";\r\n this.$broadcastBusinessNamePlural =\r\n this.$broadcastBusinessNameSingular + \"s\";\r\n this.$broadcastScreen = this.$broadcastBusinessNamePlural;\r\n }\r\n}\r\n","import { ApplicationUserBaseDTO } from \"@js/DTO/ApplicationUserBaseDTO.cs.d\";\r\nimport { RegistrationRequestDTO } from \"@js/DTO/RegistrationRequestDTO.cs.d\";\r\n\r\nexport class AuthServiceBase {\r\n testsite: boolean = null;\r\n calledtestsite: boolean = false;\r\n isLoadingTestSite: boolean = true\r\n constructor(\r\n protected $http: ng.IHttpService,\r\n protected $cookies: ng.cookies.ICookiesService,\r\n protected $rootScope: any,\r\n protected $q: ng.IQService,\r\n protected $timeout: ng.ITimeoutService,\r\n private $httpParamSerializerJQLike: ng.IHttpParamSerializer,\r\n ) {}\r\n\r\n // #region Base64\r\n base64encode(input: string): string {\r\n var keyStr =\r\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\r\n\r\n var output: any = \"\";\r\n var chr1: any,\r\n chr2: any,\r\n chr3: any = \"\";\r\n var enc1: any,\r\n enc2: any,\r\n enc3: any,\r\n enc4: any = \"\";\r\n var i = 0;\r\n do {\r\n chr1 = input.charCodeAt(i++);\r\n chr2 = input.charCodeAt(i++);\r\n chr3 = input.charCodeAt(i++);\r\n enc1 = chr1 >> 2;\r\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\r\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\r\n enc4 = chr3 & 63;\r\n if (isNaN(chr2)) {\r\n enc3 = enc4 = 64;\r\n } else if (isNaN(chr3)) {\r\n enc4 = 64;\r\n }\r\n output =\r\n output +\r\n keyStr.charAt(enc1) +\r\n keyStr.charAt(enc2) +\r\n keyStr.charAt(enc3) +\r\n keyStr.charAt(enc4);\r\n chr1 = chr2 = chr3 = \"\";\r\n enc1 = enc2 = enc3 = enc4 = \"\";\r\n } while (i < input.length);\r\n return output;\r\n }\r\n\r\n base64decode(input: string): string {\r\n var keyStr =\r\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\r\n var output: any = \"\";\r\n var chr1: any,\r\n chr2: any,\r\n chr3: any = \"\";\r\n var enc1: any,\r\n enc2: any,\r\n enc3: any,\r\n enc4: any = \"\";\r\n var i = 0;\r\n // remove all characters that are not A-Z, a-z, 0-9, +, /, or =\r\n var base64test = /[^A-Za-z0-9\\+\\/\\=]/g;\r\n if (base64test.exec(input)) {\r\n window.alert(\r\n \"There were invalid base64 characters in the input text.\\n\" +\r\n \"Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\\n\" +\r\n \"Expect errors in decoding.\",\r\n );\r\n }\r\n input = input.replace(/[^A-Za-z0-9\\+\\/\\=]/g, \"\");\r\n do {\r\n enc1 = keyStr.indexOf(input.charAt(i++));\r\n enc2 = keyStr.indexOf(input.charAt(i++));\r\n enc3 = keyStr.indexOf(input.charAt(i++));\r\n enc4 = keyStr.indexOf(input.charAt(i++));\r\n chr1 = (enc1 << 2) | (enc2 >> 4);\r\n chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);\r\n chr3 = ((enc3 & 3) << 6) | enc4;\r\n output = output + String.fromCharCode(chr1);\r\n if (enc3 !== 64) {\r\n output = output + String.fromCharCode(chr2);\r\n }\r\n if (enc4 !== 64) {\r\n output = output + String.fromCharCode(chr3);\r\n }\r\n chr1 = chr2 = chr3 = \"\";\r\n enc1 = enc2 = enc3 = enc4 = \"\";\r\n } while (i < input.length);\r\n return output;\r\n }\r\n // #endregion\r\n\r\n login(\r\n username: string,\r\n password: string,\r\n clientid: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$cookies.remove(\"user_type\");\r\n this.$cookies.remove(\"user_firstname\");\r\n\r\n this.$http.defaults.headers.common[\"Authorization\"] =\r\n \"Basic \" + this.base64encode(username + \":\" + password);\r\n this.$http({\r\n method: \"POST\",\r\n url: \"/oauth/token\",\r\n data: this.$httpParamSerializerJQLike({\r\n grant_type: \"password\",\r\n username: username,\r\n password: password,\r\n client_id: clientid,\r\n }),\r\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\r\n })\r\n .then((response) => {\r\n let t = new Date();\r\n t.setSeconds(t.getSeconds() + (response.data as any).expires_in);\r\n\r\n this.$cookies.put(\"access_token\", (response.data as any).access_token, {\r\n expires: t,\r\n });\r\n this.$cookies.put(\"access_token_expires\", t.toISOString(), {\r\n expires: t,\r\n });\r\n this.$http.defaults.headers.common.Authorization =\r\n \"Bearer \" + (response.data as any).access_token;\r\n\r\n defer.resolve(t);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n setCredentials(username: string, password: string) {\r\n var authdata = this.base64encode(username + \":\" + password);\r\n this.$rootScope[\"globals\"] = {\r\n currentUser: {\r\n username: username,\r\n authdata: authdata,\r\n },\r\n };\r\n this.$http.defaults.headers.common[\"Authorization\"] = \"Basic \" + authdata; // jshint ignore:line\r\n this.$cookies.putObject(\"globals\", this.$rootScope[\"globals\"]);\r\n }\r\n\r\n clearCredentials() {\r\n this.$rootScope[\"globals\"] = {};\r\n this.$cookies.remove(\"globals\");\r\n this.$cookies.remove(\"profile\");\r\n this.$http.defaults.headers.common.Authorization = \"Basic \";\r\n }\r\n\r\n registerAccount(newUser: RegistrationRequestDTO): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .post(\"/api/users/addupdate\", JSON.stringify(newUser))\r\n .then((response) => {\r\n defer.resolve(true);\r\n })\r\n .catch((response) => {\r\n defer.reject(false);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n changePassword(\r\n oldPassword: string,\r\n newPassword: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\r\n \"/api/users/changepassword?oldPassword=\" +\r\n encodeURIComponent(oldPassword) +\r\n \"&newPassword=\" +\r\n encodeURIComponent(newPassword),\r\n )\r\n .then((response) => {\r\n defer.resolve(true);\r\n })\r\n .catch((response) => {\r\n defer.reject(false);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n changeEmail(newEmail: string): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\"/api/users/changeemail?email=\" + newEmail)\r\n .then((response) => {\r\n defer.resolve(true);\r\n })\r\n .catch((response) => {\r\n defer.reject(false);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n getProfile(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n if (this.$cookies.getObject(\"profile\")) {\r\n defer.resolve(this.$cookies.getObject(\"profile\") as T);\r\n } else {\r\n this.$http\r\n .get(\"/api/users/me\")\r\n .then((response) => {\r\n this.$cookies.putObject(\"profile\", response.data);\r\n defer.resolve(response.data as T);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n }\r\n return defer.promise;\r\n }\r\n getadminProfile(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n if (this.$cookies.getObject(\"profile\")) {\r\n defer.resolve(this.$cookies.getObject(\"profile\") as T);\r\n } else {\r\n this.$http\r\n .get(\"/api/users/meadminstatus\")\r\n .then((response) => {\r\n this.$cookies.putObject(\"profile\", response.data);\r\n defer.resolve(response.data as T);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n }\r\n return defer.promise;\r\n }\r\n\r\n getUserFirstname(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n if (this.$cookies.get(\"user_firstname\")) {\r\n // We have this cached. Let's return it straight away.\r\n defer.resolve(this.$cookies.get(\"user_firstname\") as string);\r\n } else {\r\n // Not cached, let's go fetch the data and cache it, then return.\r\n this.getProfile()\r\n .then((response) => {\r\n //this.$cookies.put('user_type', response.UserType);\r\n this.$cookies.put(\"user_firstname\", response.FirstName);\r\n defer.resolve(response.FirstName);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n }\r\n return defer.promise;\r\n }\r\n logout(): void {\r\n //delete headers\r\n\r\n this.$http.defaults.headers.common[\"Authorization\"] = undefined;\r\n\r\n //set to expire straight away as sometimes doesnt delete\r\n let t = new Date();\r\n t.setSeconds(t.getSeconds());\r\n\r\n this.$cookies.put(\"access_token\", \"\", {\r\n expires: t,\r\n });\r\n this.$cookies.put(\"access_token_expires\", t.toISOString(), {\r\n expires: t,\r\n });\r\n\r\n this.$cookies.remove(\"profile\");\r\n this.$cookies.remove(\"access_token\");\r\n this.$cookies.remove(\"access_token_expires\");\r\n\r\n for (var x in this.$cookies.getAll()) {\r\n this.$cookies.remove(x, { path: \"/\" });\r\n }\r\n\r\n localStorage.clear();\r\n }\r\n\r\n resetPassword(userName: string): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\"/api/users/passwordreset?userName=\" + userName)\r\n .then((response) => {\r\n defer.resolve(true);\r\n })\r\n .catch((response) => {\r\n defer.reject(false);\r\n });\r\n return defer.promise;\r\n }\r\n public AmIATestSite(force: boolean = false) {\r\n if (this.testsite == null || force) {\r\n if (!this.testsite) {\r\n if (this.calledtestsite) {\r\n return false;\r\n }\r\n this.calledtestsite = true;\r\n this.isLoadingTestSite = true;\r\n this.callamIATestSite()\r\n .then((result) => {\r\n this.testsite = result;\r\n })\r\n .catch(() => {\r\n this.testsite = false;\r\n })\r\n .finally(() => {\r\n this.calledtestsite = false;\r\n this.isLoadingTestSite = false;\r\n });\r\n }\r\n } else {\r\n return this.testsite;\r\n }\r\n }\r\n private callamIATestSite(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\"/api/static/amiatestsite\")\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(false);\r\n });\r\n return defer.promise;\r\n }\r\n}\r\n","import { ApplicationUserDTO } from \"@js/DTO/ApplicationUserDTO.cs.d\";\r\nimport { AuthServiceBase } from \"@js/filesfromccqbase/AuthServiceBase\";\r\nimport { BroadcastService } from \"@js/filesfromccqbase/BroadcastService\";\r\nimport { RoleService } from \"./RoleService\";\r\n\r\nexport class AuthService extends AuthServiceBase {\r\n\r\n isValidStatus: boolean;\r\n\r\n static $inject = [\r\n \"$http\",\r\n\r\n \"$cookies\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$timeout\",\r\n \"$httpParamSerializerJQLike\",\r\n \"BroadcastService\",\r\n \"$location\",\r\n \"RoleService\",\r\n ];\r\n\r\n isLoggedIn: boolean = false;\r\n configSettings: { [key: string]: string }[];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n httpParamSerializerJQLike: ng.IHttpParamSerializer,\r\n private $broadcastservice: BroadcastService,\r\n private $location: ng.ILocationService,\r\n protected roleService: RoleService,\r\n ) {\r\n super(http, cookies, rootScope, q, timeout, httpParamSerializerJQLike);\r\n }\r\n\r\n setProfileCookie(profile: ApplicationUserDTO) {\r\n this.$cookies.putObject(\"profile\", profile);\r\n }\r\n\r\n logout(callLogin: boolean = true) {\r\n //TODO:CHECK THIS possibly meant to be?? this.$cookies.remove(\"token\");\r\n delete (this.$cookies as any).token;\r\n delete (this.$cookies as any).loggedUser;\r\n delete (this.$cookies as any).loggedUserID;\r\n delete (this.$cookies as any).tokenValidTo;\r\n delete (this.$cookies as any).access_token;\r\n this.isLoggedIn = false;\r\n (this.$rootScope as any).selectedUser = null;\r\n (this.$rootScope as any).loanCriteria = null; //reset the loancriteria\r\n (this.$rootScope as any).currentUser = null;\r\n this.roleService.resetUserRoles(); //clear user roles\r\n super.logout();\r\n sessionStorage.clear();\r\n if (callLogin) {\r\n this.$location.path(\"#!/login\");\r\n }\r\n }\r\n\r\n getIsLoggedIn(): boolean {\r\n return this.isLoggedIn;\r\n }\r\n\r\n setIsLoggedIn(isLoggedIn: boolean) {\r\n this.isLoggedIn = isLoggedIn;\r\n }\r\n getUpdatedProfile(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\"/api/users/me\")\r\n .then((response) => {\r\n this.$cookies.putObject(\"profile\", response.data);\r\n defer.resolve(response.data as ApplicationUserDTO);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n getHubspotDeveloperBookMeetingNoSearch(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\"/api/static/gethubspotdeveloperbookmeetingnosearch\")\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n getHubspotDeveloperBookMeetingWithSearch(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\"/api/static/gethubspotdeveloperbookmeetingwithsearch\")\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n getHubspotContactUsBookMeeting(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\"/api/static/gethubspotcontactusbookmeeting\")\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n getWhiteLabelledUrl(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\"/api/static/getwhitelabelledurl\")\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n getShowBridgingLenderSnapshot(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\"/api/static/getshowbridginglendersnapshot\")\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n getShowBridgingEligibility(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\"/api/static/getshowbridgingeligibility\")\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n getCompanyContactUsEmailAddresss(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\"/api/static/getcompanycontactusemailaddress\")\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n isCommercialOwnerOccupiedActive(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\"/api/static/iscommercialowneroccupiedactive\")\r\n .then((response) => {\r\n defer.resolve((response.data as string).toLowerCase() == \"true\");\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n getReferralContactDetails(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\"/api/static/getreferralcontactdetails\")\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n clearStorageData() {\r\n sessionStorage.removeItem(\"userRole\");\r\n sessionStorage.removeItem(\"userDetails\");\r\n sessionStorage.removeItem(\"assignUserToOrg\");\r\n sessionStorage.removeItem(\"isUpgradedUser\");\r\n sessionStorage.removeItem(\"skip\");\r\n sessionStorage.removeItem(\"projectname\");\r\n sessionStorage.removeItem(\"selectedPackage\");\r\n sessionStorage.removeItem(\"returningFromdeletedSearch\");\r\n sessionStorage.removeItem(\"addAddon\");\r\n sessionStorage.removeItem(\"selectedProduct\");\r\n sessionStorage.removeItem(\"searchuser\");\r\n sessionStorage.removeItem(\"clientId\");\r\n sessionStorage.removeItem(\"lenderTask\");\r\n sessionStorage.removeItem(\"loanCriteria\");\r\n sessionStorage.removeItem(\"DealClientUniqueRef\");\r\n sessionStorage.removeItem(\"TempSavedResults\");\r\n sessionStorage.removeItem(\"SelectedUser\");\r\n sessionStorage.removeItem(\"UniqueId\");\r\n sessionStorage.removeItem(\"loanCriteria\");\r\n sessionStorage.removeItem(\"LoanCriteria\");\r\n sessionStorage.removeItem(\"ComparisonList\");\r\n sessionStorage.removeItem('previousRoute');\r\n }\r\n\r\n clearSelectedNavMenuAndFilterStorageData() {\r\n sessionStorage.removeItem(\"selectedNavMenu\");\r\n sessionStorage.removeItem(\"clientCaseNameFilter\");\r\n sessionStorage.removeItem(\"statusFilter\");\r\n // Clearing a property value which will show confirm a client phone number modal as soon as they register through enterprise journey.\r\n sessionStorage.removeItem('showConfirmClientPhoneNo');\r\n }\r\n\r\n getHasValidStatustoShowShareSearchModal() {\r\n return this.isValidStatus;\r\n }\r\n\r\n setHasValidStatustoShowShareSearchModal(isValidStatus) {\r\n this.isValidStatus = isValidStatus;\r\n }\r\n \r\n\r\n getConnectNetworkOrgId(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\"/api/static/getconnectnetworkorgid\")\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n}\r\n","//fetchByCaseId - /fetchByCaseId\r\n\r\nimport { DealDTO } from \"@js/DTO/Deal/DealDTO.cs.d\";\r\nimport { BaseService } from \"@js/filesfromccqbase/BaseService\";\r\nimport { BroadcastService } from \"@js/filesfromccqbase/BroadcastService\";\r\n\r\n//saveAddressHistory - /saveaddresshistory\r\n\r\nexport class BridgingCaseService extends BaseService {\r\n static $inject = [\r\n \"$http\",\r\n \"$cookies\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$timeout\",\r\n \"BroadcastService\",\r\n ];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n broadcastservice: BroadcastService,\r\n ) {\r\n super(http, cookies, rootScope, q, timeout, broadcastservice);\r\n this.$baseAddress = \"/api/bridgingcase\";\r\n this.$broadcastBusinessNameSingular = \"bridgingcase\";\r\n this.$broadcastBusinessNamePlural =\r\n this.$broadcastBusinessNameSingular + \"s\";\r\n this.$broadcastScreen = this.$broadcastBusinessNamePlural;\r\n }\r\n}\r\n","import { BridgingDealDTO } from \"@js/DTO/Deal/BridgingDealDTO.cs.d\";\r\nimport { BridgingSearchResultsResponse } from \"@js/DTO/Messages/BridgingSearchResultMessage.cs.d\";\r\nimport { SearchResultsRequest } from \"@js/DTO/Messages/Deal/SearchResultMessage.cs.d\";\r\nimport { BaseService } from \"@js/filesfromccqbase/BaseService\";\r\nimport { BroadcastService } from \"@js/filesfromccqbase/BroadcastService\";\r\n\r\nexport class BridgingSearchService extends BaseService<\r\n BridgingDealDTO,\r\n number\r\n> {\r\n static $inject = [\r\n \"$http\",\r\n \"$cookies\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$timeout\",\r\n \"BroadcastService\",\r\n ];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n broadcastservice: BroadcastService,\r\n ) {\r\n super(http, cookies, rootScope, q, timeout, broadcastservice);\r\n this.$baseAddress = \"/api/bridgingsearch\";\r\n this.$broadcastBusinessNameSingular = \"bridgingsearch\";\r\n this.$broadcastBusinessNamePlural =\r\n this.$broadcastBusinessNameSingular + \"s\";\r\n this.$broadcastScreen = this.$broadcastBusinessNamePlural;\r\n }\r\n\r\n /**\r\n * Gets the search criteria and the search results based on the search criteria ID passed in\r\n * @param criteriaId\r\n * @param criteriaChanged - has the search criteria chaged? Used for snapshotting.\r\n * @param limit - the number of search results to display TODO - is this needed for search results????\r\n * @param debug1\r\n * @param debug2\r\n */\r\n getSearchCriteriaAndResultsByDealId(\r\n dealId: number,\r\n criteriaChanged: boolean = false,\r\n limit: number = 0,\r\n debug1: boolean = false,\r\n debug2: boolean = false,\r\n ): ng.IPromise {\r\n var request: SearchResultsRequest = {\r\n DealId: dealId,\r\n DealClientUniqueRef: null,\r\n DealUniqueRef: null,\r\n ReturnSearchCriteriaDTO: true,\r\n CriteriaChanged: criteriaChanged,\r\n Limit: limit, // TODO is this needed for search results??\r\n Debug1: debug1,\r\n Debug2: debug2,\r\n };\r\n\r\n return this.getSearchCriteriaAndResults(request);\r\n }\r\n\r\n /**\r\n * Gets the search criteria and the search results based on the DealClient UniqueRef passed in\r\n * @param criteriaId\r\n * @param limit - the number of search results to display TODO - is this needed for search results????\r\n * @param debug1\r\n * @param debug2\r\n */\r\n getSearchCriteriaAndResultsByDealClientUniqueRef(\r\n dealClientUniqueRef: string,\r\n criteriaChanged: boolean = false,\r\n limit: number = 0,\r\n debug1: boolean = false,\r\n debug2: boolean = false,\r\n ): ng.IPromise {\r\n var request: SearchResultsRequest = {\r\n DealClientUniqueRef: dealClientUniqueRef,\r\n DealUniqueRef: null,\r\n ReturnSearchCriteriaDTO: true,\r\n CriteriaChanged: criteriaChanged,\r\n Limit: limit, // TODO is this needed for search results??\r\n Debug1: debug1,\r\n Debug2: debug2,\r\n };\r\n\r\n return this.getSearchCriteriaAndResults(request);\r\n }\r\n\r\n /**\r\n * Gets the search criteria and the search results based on the search unique ref passed in\r\n * @param dealUniqueref\r\n * @param criteriaChanged - has the search criteria chaged? Used for snapshotting.\r\n * @param limit - the number of search results to display TODO - is this needed for search results????\r\n * @param debug1\r\n * @param debug2\r\n */\r\n getSearchCriteriaAndResultsByDealUniqueRef(\r\n dealUniqueref: string,\r\n criteriaChanged: boolean = false,\r\n limit: number = 0,\r\n debug1: boolean = false,\r\n debug2: boolean = false,\r\n ): ng.IPromise {\r\n var request: SearchResultsRequest = {\r\n DealId: null,\r\n DealUniqueRef: dealUniqueref,\r\n DealClientUniqueRef: null,\r\n ReturnSearchCriteriaDTO: true,\r\n CriteriaChanged: criteriaChanged,\r\n Limit: limit, // TODO is this needed for search results??\r\n Debug1: debug1,\r\n Debug2: debug2,\r\n };\r\n\r\n return this.getSearchCriteriaAndResults(request);\r\n }\r\n\r\n /**\r\n * Fetches the Bridging Search based on the request passed in\r\n * @param request\r\n */\r\n private getSearchCriteriaAndResults(\r\n request: SearchResultsRequest,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .post(\r\n this.$baseAddress + \"/getsearchcriteriaandresults\",\r\n JSON.stringify(request),\r\n )\r\n .then((response) => {\r\n var res = response.data as BridgingSearchResultsResponse;\r\n defer.resolve(res);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n}\r\n","import { CaseLenderMessageDTO } from \"@js/DTO/CaseLenderMessageDTO.cs.d\";\r\nimport { BaseService } from \"@js/filesfromccqbase/BaseService\";\r\nimport { BroadcastService } from \"@js/filesfromccqbase/BroadcastService\";\r\n\r\nexport class CaseLenderMessageService extends BaseService<\r\n CaseLenderMessageDTO,\r\n number\r\n> {\r\n static $inject = [\r\n \"$http\",\r\n \"$cookies\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$timeout\",\r\n \"BroadcastService\",\r\n ];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n broadcastservice: BroadcastService,\r\n ) {\r\n super(http, cookies, rootScope, q, timeout, broadcastservice);\r\n this.$baseAddress = \"/api/caselendermessage\";\r\n this.$broadcastBusinessNameSingular = \"caselendermessage\";\r\n this.$broadcastBusinessNamePlural =\r\n this.$broadcastBusinessNameSingular + \"s\";\r\n this.$broadcastScreen = this.$broadcastBusinessNamePlural;\r\n }\r\n\r\n updateCaseLenderMessageReadDatetime(\r\n caseLenderId: number,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/updatecaselendermessagereaddatetime?caseLenderId=\" +\r\n caseLenderId,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"updateCaseLenderMessageReadDatetime\",\r\n \"update CaseLender Message Read Datetime failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n}\r\n","import { CaseLenderChangedMessageDTO } from \"@js/DTO/CaseLenderChangedMessageDTO.cs.d\";\r\nimport { CaseLenderDTO } from \"@js/DTO/CaseLenderDTO.cs.d\";\r\nimport { BaseService } from \"@js/filesfromccqbase/BaseService\";\r\nimport { BroadcastService } from \"@js/filesfromccqbase/BroadcastService\";\r\nimport { CaseLenderStateEnum } from \"@js/models/enum/CaseLenderStateEnum.cs.d\";\r\n\r\nexport class CaseLenderService extends BaseService {\r\n static $inject = [\r\n \"$http\",\r\n \"$cookies\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$timeout\",\r\n \"BroadcastService\",\r\n ];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n broadcastservice: BroadcastService,\r\n ) {\r\n super(http, cookies, rootScope, q, timeout, broadcastservice);\r\n this.$baseAddress = \"/api/caselender\";\r\n this.$broadcastBusinessNameSingular = \"caselender\";\r\n this.$broadcastBusinessNamePlural =\r\n this.$broadcastBusinessNameSingular + \"s\";\r\n this.$broadcastScreen = this.$broadcastBusinessNamePlural;\r\n }\r\n\r\n submitHoT(\r\n CaseLender: CaseLenderDTO,\r\n caseLenderState: CaseLenderStateEnum,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .put(\r\n this.$baseAddress + \"/submitoffer?caseLenderState=\" + caseLenderState,\r\n JSON.stringify(CaseLender),\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as CaseLenderChangedMessageDTO);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n rejectCase(\r\n CaseLender: CaseLenderDTO,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .put(this.$baseAddress + \"/reject\", JSON.stringify(CaseLender))\r\n .then((response) => {\r\n defer.resolve(response.data as CaseLenderChangedMessageDTO);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n withdrawHoT(\r\n CaseLender: CaseLenderDTO,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .put(this.$baseAddress + \"/withdraw\", JSON.stringify(CaseLender))\r\n .then((response) => {\r\n defer.resolve(response.data as CaseLenderChangedMessageDTO);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n accept(CaseLender: CaseLenderDTO): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .put(this.$baseAddress + \"/accept\", JSON.stringify(CaseLender))\r\n .then((response) => {\r\n defer.resolve(response.data as CaseLenderChangedMessageDTO);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n cancel(CaseLender: CaseLenderDTO): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .put(this.$baseAddress + \"/cancel\", JSON.stringify(CaseLender))\r\n .then((response) => {\r\n defer.resolve(response.data as CaseLenderChangedMessageDTO);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n applyToLender(\r\n CaseId: number,\r\n CaseLenderId: number,\r\n SendEmails: boolean = true,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/apply?caseId=\" +\r\n CaseId +\r\n \"&caseLenderId=\" +\r\n CaseLenderId +\r\n \"&sendEmails=\" +\r\n SendEmails,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as CaseLenderChangedMessageDTO);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n cancelApplication(\r\n caseId: number,\r\n caseLenderId: number,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/cancel?caseId=\" +\r\n caseId +\r\n \"&caseLenderId=\" +\r\n caseLenderId,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as CaseLenderChangedMessageDTO);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n sendFeedbackToBorrower(\r\n CaseLender: CaseLenderDTO,\r\n CaseOwner: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .put(\r\n this.$baseAddress + \"/sendfeedbacktoborrower?caseOwner=\" + CaseOwner,\r\n JSON.stringify(CaseLender),\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n sendFeedbackToLender(CaseLender: CaseLenderDTO): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .put(\r\n this.$baseAddress + \"/sendfeedbacktolender\",\r\n JSON.stringify(CaseLender),\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n fetchByCaseId(\r\n CaseId: number,\r\n debug2?: boolean,\r\n CaseLenderId?: number,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/fetchByCaseId?CaseId=\" +\r\n CaseId +\r\n \"&debug2=\" +\r\n debug2 +\r\n \"&CaseLenderId=\" +\r\n CaseLenderId,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as CaseLenderDTO[]);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"fetchbycaseID\",\r\n \"Fetchby case id failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n fetchCaseLender(CaseId: number): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(this.$baseAddress + \"/fetchcaselender?CaseId=\" + CaseId)\r\n .then((response) => {\r\n defer.resolve(response.data as CaseLenderDTO);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"fetchCaseLender\",\r\n \"Fetch caselender id failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n getSelectedCaseLender(\r\n Id: number,\r\n showLenderNames: boolean,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/selectedcaselender?Id=\" +\r\n Id +\r\n \"&showLenderNames?=\" +\r\n showLenderNames,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as CaseLenderDTO);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"getSelectedCaseLender\",\r\n \"get selected case lender failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n getStatusTextForLender(\r\n caseLenderState: CaseLenderStateEnum,\r\n IsBidAccepted: boolean,\r\n ): string {\r\n var statusText = \"\";\r\n switch (caseLenderState) {\r\n case CaseLenderStateEnum.Offered:\r\n case CaseLenderStateEnum.SentToPackager: {\r\n statusText = IsBidAccepted\r\n ? \"DIP submitted and accepted\"\r\n : \"DIP submitted\";\r\n break;\r\n }\r\n case CaseLenderStateEnum.Received:{\r\n statusText = \"Case to review\";\r\n break;\r\n }\r\n case CaseLenderStateEnum.Rejected: {\r\n statusText = \"Case rejected\";\r\n break;\r\n }\r\n case CaseLenderStateEnum.Withdrawn: {\r\n statusText = \"DIP withdrawn\";\r\n break;\r\n }\r\n case CaseLenderStateEnum.Cancelled: {\r\n statusText = \"Application cancelled\";\r\n break;\r\n }\r\n case CaseLenderStateEnum.Applied: {\r\n statusText = \"DIP submitted and accepted\";\r\n break;\r\n }\r\n }\r\n\r\n return statusText;\r\n }\r\n}\r\n","import { CaseMemberDTO } from \"@js/DTO/CaseMemberDTO.cs.d\";\r\nimport { SecurityCheckMessageRequest } from \"@js/DTO/Messages/SecurityCheckMessage.cs.d\";\r\nimport { BaseService } from \"@js/filesfromccqbase/BaseService\";\r\nimport { BroadcastService } from \"@js/filesfromccqbase/BroadcastService\";\r\n\r\nexport class CaseMemberService extends BaseService {\r\n static $inject = [\r\n \"$http\",\r\n \"$cookies\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$timeout\",\r\n \"BroadcastService\",\r\n ];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n broadcastservice: BroadcastService,\r\n ) {\r\n super(http, cookies, rootScope, q, timeout, broadcastservice);\r\n this.$baseAddress = \"/api/applicant\";\r\n this.$broadcastBusinessNameSingular = \"applicant\";\r\n this.$broadcastBusinessNamePlural =\r\n this.$broadcastBusinessNameSingular + \"s\";\r\n this.$broadcastScreen = this.$broadcastBusinessNamePlural;\r\n }\r\n\r\n fetchByCaseId(CaseId: number): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(this.$baseAddress + \"/fetchByCaseId?CaseId=\" + CaseId)\r\n .then((response) => {\r\n defer.resolve(response.data as CaseMemberDTO[]);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"fetchbycaseID\",\r\n \"Fetchby case id failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n inviteApplicant(uniqueId: string): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(this.$baseAddress + \"/inviteApplicant?uniqueId=\" + uniqueId)\r\n .then((response) => {\r\n defer.resolve(response.data as CaseMemberDTO);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"inviteApplicant\",\r\n \"inviteApplicant failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n securityCheck(\r\n uniqueId: string,\r\n phone?: string,\r\n postcode?: string,\r\n dob?: Date,\r\n orgUniqueRef?: string,\r\n brokerUserId?: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n var request = {\r\n UniqueId: uniqueId,\r\n PhoneNumber: phone,\r\n PostCode: postcode,\r\n DateOfBirth: dob,\r\n OrgUniqueRef: orgUniqueRef,\r\n BrokerUserId: brokerUserId,\r\n } as SecurityCheckMessageRequest;\r\n\r\n this.$http\r\n .post(this.$baseAddress + \"/securityCheck\", request)\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"securityCheck\",\r\n \"securityCheck failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n\r\n return defer.promise;\r\n }\r\n\r\n /**\r\n * Get the security questions that have been answered\r\n * @param caseMemberId\r\n */\r\n getSecurityQuestions(uniqueId: string) {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(this.$baseAddress + \"/getsecurityquestions?uniqueId=\" + uniqueId)\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"getsecurityquestions\",\r\n \"getsecurityquestions failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n /**\r\n *Get the email for the shareholder\r\n * @param caseMemberId\r\n */\r\n fetchCaseMemberAndReturnEmail(uniqueId: string) {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/fetchCaseMemberAndReturnEmail?uniqueId=\" +\r\n uniqueId,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"fetchCaseMemberAndReturnEmail\",\r\n \"fetchCaseMemberAndReturnEmail failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n /**\r\n *To copy all shareholders from a copied case\r\n * @param CaseId and DevelopmentInputId\r\n */\r\n copyShareholder(caseId: number, newCaseId: number) {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/copyShareholder?caseId=\" +\r\n caseId +\r\n \"&newCaseId=\" +\r\n newCaseId,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"copyShareholder\",\r\n \"copyShareholder failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n /**\r\n *fetch shareholder by uniqueId\r\n * @param uniqueId and DevelopmentInputId\r\n */\r\n fetchCaseMember(uniqueId: string): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/FetchCaseMemberAndReturnRegisterInformation?uniqueId=\" +\r\n uniqueId,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as CaseMemberDTO);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"FetchCaseMemberAndReturnRegisterInformation\",\r\n \"FetchCaseMemberAndReturnRegisterInformation failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n markAsDeleteAndSetNextCaseMenmberAsPrimary(\r\n caseId: number,\r\n caseMemberId: number,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/MarkAsDeleteAndSetNextCaseMemberAsPrimary?caseId=\" +\r\n caseId +\r\n \"&caseMemberId=\" +\r\n caseMemberId,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as CaseMemberDTO[]);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"fetchbycaseID\",\r\n \"Fetchby case id failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n saveAddressHistory(\r\n caseMemberId: number,\r\n addressHistory: string,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .put(\r\n this.$baseAddress + \"/saveaddresshistory?caseMemberId=\" + caseMemberId,\r\n JSON.stringify(addressHistory),\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as string);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"saveAddressHistory\",\r\n \"Save Address History failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n getWebConfigValue(): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(this.$baseAddress + \"/getWebConfigValue\")\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"getWebConfigValue\",\r\n \"web config Value failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n fetchcasememberswithaccess(caseId: number): ng.IPromise {\r\n let defer = this.$q.defer();\r\n this.$http\r\n .get(this.$baseAddress + \"/fetchcasememberswithaccess?caseId=\" + caseId)\r\n .then((response) => {\r\n defer.resolve(response.data as CaseMemberDTO[]);\r\n })\r\n .catch((response) => {\r\n this.$broadcastservice.broadcastError(\r\n \"fetchcasememberswithaccess\",\r\n \"fetchcasememberswithaccess failed\",\r\n );\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n}\r\n","import { CaseNoteDTO } from \"@js/DTO/CaseNoteDTO.cs.d\";\r\nimport { BaseService } from \"@js/filesfromccqbase/BaseService\";\r\nimport { BroadcastService } from \"@js/filesfromccqbase/BroadcastService\";\r\n\r\nexport class CaseNoteService extends BaseService {\r\n static $inject = [\r\n \"$http\",\r\n \"$cookies\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$timeout\",\r\n \"BroadcastService\",\r\n ];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n broadcastservice: BroadcastService,\r\n ) {\r\n super(http, cookies, rootScope, q, timeout, broadcastservice);\r\n this.$baseAddress = \"/api/casenote\";\r\n this.$broadcastBusinessNameSingular = \"casenote\";\r\n this.$broadcastBusinessNamePlural =\r\n this.$broadcastBusinessNameSingular + \"s\";\r\n this.$broadcastScreen = this.$broadcastBusinessNamePlural;\r\n }\r\n}\r\n","import { CaseChangedMessageDTO } from \"@js/DTO/CaseChangedMessageDTO.cs.d\";\r\nimport { CaseDTO } from \"@js/DTO/CaseDTO.cs.d\";\r\nimport { CaseNoteDTO } from \"@js/DTO/CaseNoteDTO.cs.d\";\r\nimport { DevelopmentInputDTO } from \"@js/DTO/DevelopmentFinance/DevelopmentInputDTO.cs.d\";\r\nimport {\r\n AssignLenderToDealRequest,\r\n AssignLenderToDealResponse,\r\n} from \"@js/DTO/Messages/AssignLenderToDealMessage.cs.d\";\r\nimport { LenderInfo } from \"@js/DTO/Messages/Deal/LendersInfoForSubmitToLenderMessage.cs.d\";\r\nimport { NewBlankCaseDTO } from \"@js/DTO/NewBlankCaseDTO.cs.d\";\r\nimport { BaseService } from \"@js/filesfromccqbase/BaseService\";\r\nimport { BroadcastService } from \"@js/filesfromccqbase/BroadcastService\";\r\nimport { CaseStatusEnum } from \"@js/models/enum/CaseStatusEnum.cs.d\";\r\nimport { DevelopmentInputService } from \"./DevelopmentInputService\";\r\nimport { RoleService } from \"./RoleService\";\r\nimport { UserService } from \"./UserService\";\r\nimport { ShareDealDTO } from \"@js/DTO/Deal/SearchDealDTO.cs.d\";\r\n\r\nexport class CaseService extends BaseService {\r\n private caseStatusEnum = {\r\n Search: undefined,\r\n NewCase: 0,\r\n InProgress: 1,\r\n UnderReview: 2,\r\n ReadyToSubmit: 3,\r\n SubmittedToLendersForHoT: 4,\r\n PaymentReceived: 8,\r\n ReadyToReSubmit: 12,\r\n Applied: 5,\r\n CreditApproved: 10,\r\n WithProfessionals: 11,\r\n Completed: 6,\r\n Dormant: 7,\r\n SubmittedToLendersPendingReview: 9,\r\n SentToPackager: 13,\r\n };\r\n\r\n currentLender;\r\n tubeMapStatus;\r\n isProceed: boolean;\r\n task: string;\r\n IsSupplimentInfoFilled: boolean;\r\n\r\n static $inject = [\r\n \"$http\",\r\n \"$cookies\",\r\n \"$rootScope\",\r\n \"$q\",\r\n \"$timeout\",\r\n \"BroadcastService\",\r\n \"DevelopmentInputService\",\r\n \"UserService\",\r\n \"RoleService\",\r\n ];\r\n\r\n constructor(\r\n http: ng.IHttpService,\r\n cookies: ng.cookies.ICookiesService,\r\n private rootScope: ng.IRootScopeService,\r\n q: ng.IQService,\r\n timeout: ng.ITimeoutService,\r\n broadcastservice: BroadcastService,\r\n private $DevelopmentInputservice: DevelopmentInputService,\r\n private $user: UserService,\r\n private $roleService: RoleService,\r\n ) {\r\n super(http, cookies, rootScope, q, timeout, broadcastservice);\r\n this.$baseAddress = \"/api/case\";\r\n this.$broadcastBusinessNameSingular = \"case\";\r\n this.$broadcastBusinessNamePlural =\r\n this.$broadcastBusinessNameSingular + \"s\";\r\n this.$broadcastScreen = this.$broadcastBusinessNamePlural;\r\n }\r\n\r\n promotesearchtocase(\r\n searchId: number,\r\n productId: number,\r\n productResultList: number,\r\n isPrimaryApplicant: boolean = true,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/promotesearchtocase?searchId=\" +\r\n searchId +\r\n \"&productId=\" +\r\n productId +\r\n \"&productResultList=\" +\r\n productResultList +\r\n \"&isPrimaryApplicant=\" +\r\n isPrimaryApplicant,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as number);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n promoteandmigratetodeal(\r\n searchId: number,\r\n productId: number,\r\n productResultList: number,\r\n isPrimaryApplicant: boolean = true,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/promoteandmigratetodeal?searchId=\" +\r\n searchId +\r\n \"&productId=\" +\r\n productId +\r\n \"&productResultList=\" +\r\n productResultList +\r\n \"&isPrimaryApplicant=\" +\r\n isPrimaryApplicant,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as number);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n setProductOnCase(\r\n CaseId: number,\r\n productId: number,\r\n productResultList: number,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/setproductoncase?caseId=\" +\r\n CaseId +\r\n \"&productId=\" +\r\n productId +\r\n \"&productResultList=\" +\r\n productResultList,\r\n )\r\n .then((response) => {\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n public updateCaseState(caseId: number, caseStatus: CaseStatusEnum): void {\r\n const caseStatusString: string = Object.keys(this.caseStatusEnum).find(\r\n (key) => this.caseStatusEnum[key] === caseStatus,\r\n );\r\n if (!(this.rootScope as any).caseStateChange) {\r\n (this.rootScope as any).caseStateChange = {};\r\n }\r\n (this.rootScope as any).caseStateChange[caseId] = caseStatusString;\r\n this.rootScope.$broadcast(\"caseStateChange\", {\r\n id: caseId,\r\n status: caseStatusString,\r\n });\r\n }\r\n\r\n public onStateChange(caseId, callback: (caseStatus: string) => void): void {\r\n // TODO JNG Review using a single rootscope listener with an array of callbacks per caseId.\r\n this.rootScope.$on(\r\n \"caseStateChange\",\r\n function (event, statusUpdate: { id: number; status: string }) {\r\n if (statusUpdate.id === caseId) {\r\n callback(statusUpdate.status);\r\n }\r\n },\r\n );\r\n }\r\n\r\n setStatusOnCase(\r\n caseId: number,\r\n caseStatus: CaseStatusEnum,\r\n ): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(\r\n this.$baseAddress +\r\n \"/setstatusoncase?caseId=\" +\r\n caseId +\r\n \"&caseStatus=\" +\r\n caseStatus,\r\n )\r\n .then((response) => {\r\n //TODO JLH Ideally setstatusoncase should return a CaseChangedMessageDTO and we should use teh status on that to send to updateCaseState\r\n this.updateCaseState(caseId, caseStatus);\r\n defer.resolve(response.data as boolean);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n setApplyStatus(CaseId: number): ng.IPromise {\r\n let defer = this.$q.defer();\r\n\r\n this.$http\r\n .get(this.$baseAddress + \"/setapplystatus?caseId=\" + CaseId)\r\n .then((response) => {\r\n defer.resolve(response.data as CaseStatusEnum);\r\n })\r\n .catch((response) => {\r\n defer.reject(response);\r\n });\r\n return defer.promise;\r\n }\r\n\r\n getcasefromsearch(searchId: number): ng.IPromise