/* scope */ let durunnersys_app = {"momenttz":"America/New_York","tz":"EST","tzoffset":-5,"tzoffset_summer":-4,"tzoffset_winter":-5,"isinusa":false,"tcpa_default_docfollow":"any","docbot_testmode":"Y","adobe_viewer_pdf_key":"535854593fac4ba6adc2acba71126368","old_email_domain":"durunner.ai","email_domain":"docs.elaine.ai"}; /* no recalc */ let _loi_config={ "encompass_enabled": false, "milestones": { "en_start": { "code": "en_start", "name": "App is in Encompass", "mask": 64, "type": "pipeline", "grp": "prospects" }, "el_start": { "code": "el_start", "name": "App started", "mask": 2, "type": "pipeline", "grp": "prospects" }, "el_rev_start": { "code": "el_rev_start", "name": "App Synched from Encompass", "mask": 4, "type": "pipeline", "grp": "prospects" }, "el_com_nodoc": { "code": "el_com_nodoc", "name": "App completed (Elaine)", "mask": 8, "type": "pipeline", "grp": "prospects" }, "el_com_collecting": { "code": "el_com_collecting", "name": "Collecting Documents", "mask": 16, "type": "pipeline", "grp": "prospects" }, "el_com_initial_docs": { "code": "el_com_initial_docs", "name": "Initial Package Complete", "mask": 8589934592, "type": "pipeline", "grp": "prospects" }, "en_prequal": { "code": "en_prequal", "name": "Inquiry/Pre-Qual", "mask": 128, "type": "pipeline", "grp": "prospects" }, "en_b_prequal": { "code": "en_b_prequal", "name": "Builder Prequal", "mask": 33554432, "type": "pipeline", "grp": "prospects" }, "en_b_review": { "code": "en_b_review", "name": "Builder Review", "mask": 67108864, "type": "pipeline", "grp": "prospects" }, "en_appcomplete": { "code": "en_appcomplete", "name": "Application Completed", "mask": 256, "type": "pipeline", "grp": "prospects" }, "en_smr": { "code": "en_smr", "name": "Sales Mgr Review", "mask": 512, "type": "pipeline", "grp": "prospects" }, "en_disdesk": { "code": "en_disdesk", "name": "Disclosure Desk", "mask": 1024, "type": "pipeline", "grp": "active" }, "en_loanpack": { "code": "en_loanpack", "name": "Loan Package", "mask": 2048, "type": "pipeline", "grp": "active" }, "en_comsetup": { "code": "en_comsetup", "name": "Compliance & Set up", "mask": 4096, "type": "pipeline", "grp": "active" }, "en_procacc": { "code": "en_procacc", "name": "Processor Accepted", "mask": 8192, "type": "pipeline", "grp": "active" }, "en_b_con_p_p": { "code": "en_b_con_p_p", "name": "Construction Project Prequal", "mask": 134217728, "type": "pipeline", "grp": "active" }, "en_b_con_p_r": { "code": "en_b_con_p_r", "name": "Construction Project review", "mask": 268435456, "type": "pipeline", "grp": "active" }, "en_sub": { "code": "en_sub", "name": "Submittal", "mask": 16384, "type": "pipeline", "grp": "active" }, "en_initund": { "code": "en_initund", "name": "Initial Underwrite", "mask": 32768, "type": "pipeline", "grp": "active" }, "en_cond_sub": { "code": "en_cond_sub", "name": "Cond. Submitted", "mask": 65536, "type": "pipeline", "grp": "active" }, "en_c2c": { "code": "en_c2c", "name": "Clear to Close", "mask": 131072, "type": "pipeline", "grp": "active" }, "en_closch": { "code": "en_closch", "name": "Closing Scheduled", "mask": 262144, "type": "pipeline", "grp": "active" }, "en_docs": { "code": "en_docs", "name": "Docs Out", "mask": 524288, "type": "pipeline", "grp": "active" }, "en_b_con_fnd": { "code": "en_b_con_fnd", "name": "Construction Funding", "mask": 4294967296, "type": "pipeline", "grp": "active" }, "en_b_con_pha": { "code": "en_b_con_pha", "name": "Construction Phase", "mask": 2147483648, "type": "pipeline", "grp": "active" }, "en_b_mod": { "code": "en_b_mod", "name": "Modification", "mask": 536870912, "type": "pipeline", "grp": "active" }, "en_funding": { "code": "en_funding", "name": "Funding", "mask": 1073741824, "type": "pipeline", "grp": "active" }, "en_shipping": { "code": "en_shipping", "name": "Shipping", "mask": 2097152, "type": "pipeline", "grp": "closed" }, "en_purchasing": { "code": "en_purchasing", "name": "Purchasing", "mask": 4194304, "type": "pipeline", "grp": "closed" }, "en_completion": { "code": "en_completion", "name": "Completion", "mask": 8388608, "type": "pipeline", "grp": "closed" }, "flag_prob_credit": { "code": "flag_prob_credit", "name": "problem - credit", "mask": 2, "type": "flag", "grp": "problems" }, "flag_prob_income": { "code": "flag_prob_income", "name": "problem - income", "mask": 4, "type": "flag", "grp": "problems" }, "flag_prob_assets": { "code": "flag_prob_assets", "name": "problem - assets", "mask": 8, "type": "flag", "grp": "problems" }, "flag_prob_liabilities": { "code": "flag_prob_liabilities", "name": "problem - liabilities", "mask": 16, "type": "flag", "grp": "problems" }, "folder_test_train": { "code": "folder_test_train", "name": "Testing Training", "mask": 2, "type": "folder", "grp": "folders" }, "folder_prospects": { "code": "folder_prospects", "name": "Prospects", "mask": 4, "type": "folder", "grp": "folders" }, "folder_prop_inactive": { "code": "folder_prop_inactive", "name": "Prospects- Inactive", "mask": 8, "type": "folder", "grp": "folders" }, "folder_active": { "code": "folder_active", "name": "Active Pipeline", "mask": 16, "type": "folder", "grp": "folders" }, "folder_closed": { "code": "folder_closed", "name": "Closed Loans", "mask": 32, "type": "folder", "grp": "folders" }, "flag_tcpa_block": { "code": "flag_tcpa_block", "name": "TCPA - Block all communictions to client", "mask": 32, "type": "flag", "grp": "tcpa" }, "el_com_inactive": { "code": "el_com_inactive", "name": "App - Inactive", "mask": 32, "type": "pipeline", "grp": "inactive" }, "el_com_problem": { "code": "el_com_problem", "name": "App - Problems", "mask": 16777216, "type": "pipeline", "grp": "inactive" } }, "milestones_index": [ "en_start", "el_start", "el_rev_start", "el_com_nodoc", "el_com_collecting", "el_com_initial_docs", "en_prequal", "en_b_prequal", "en_b_review", "en_appcomplete", "en_smr", "en_disdesk", "en_loanpack", "en_comsetup", "en_procacc", "en_b_con_p_p", "en_b_con_p_r", "en_sub", "en_initund", "en_cond_sub", "en_c2c", "en_closch", "en_docs", "en_b_con_fnd", "en_b_con_pha", "en_b_mod", "en_funding", "en_shipping", "en_purchasing", "en_completion", "flag_prob_credit", "flag_prob_income", "flag_prob_assets", "flag_prob_liabilities", "folder_test_train", "folder_prospects", "folder_prop_inactive", "folder_active", "folder_closed", "flag_tcpa_block", "el_com_inactive", "el_com_problem" ] } /* file /ui/app/js/_classes.js , last updated 1683276934217*/ class GenericBlock { constructor(arg) { this.data = {}; $.extend(true, this.data, arg); } render(icon,title, textarray,click) { let h = ''; h += "
"; h += ""; h += "
"; h += "
"+title+"
"; h += "
" h += "
"; for (let i=0; i < textarray.length; i++) { h += "
"+textarray[i]+"
"; } //h += "
"; h += "
"; //end imported account holder return h; } } mar.gdrive = (function(){ let elm = false; let auth = false; function choose(ELM) { elm = ELM; gapi.auth2.authorize({ client_id: clientId, scope: scope }, handleAuthResult); } function setELM(ELM) { elm = ELM; } function setAuth(A) { auth = A; if ("session_state" in auth) { delete auth.session_state; } } function upload(fileid, fileids) { let $elm = $(elm); var bucket = "unchecked"; let _needlink = $(elm).data("need"); let _nl = (_needlink && _needlink != "") ? "/need/"+btoa(_needlink) : ""; let _rc = $(elm).data("randomclass"); let uploadurl = "/upload/"+mar.ID+"/"+btoa(bucket)+_nl; var h = ''+ "

" + "
" + "
" + "
" + "
" + '

Uploading

'; var s = document.createElement("div"); s.innerHTML = h; swal({ className : "midelinfopopupOneButton", content : s }); if (fileids && fileids.length > 0) { let $uploadingmessage = $("#uploadingmessage"); let totalfiles_start = fileids.length; let totalfiles_cnt = 0; let uploadOneFile = function() { if (fileids.length == 0) { $uploadingmessage.html("Finishing up .. "); if (_rc) { let $_rc = $("."+_rc); if ($_rc.length == 0) { debugger; } else { $uploadingmessage.html("Finishing up, Making thumbnails .. "); setTimeout(function() { swal.close(); mar.openCloseDocFolderFn($_rc,"refresh"); },3000); } } return; } totalfiles_cnt++; $uploadingmessage.html("Uploading file "+totalfiles_cnt+" of "+totalfiles_start+" . "); let _fileid = fileids.shift(); let filelink = "gd:"+_fileid+":"+btoa(JSON.stringify(auth)) $.ajax({ url: uploadurl, type: 'POST', data : { url : filelink }, success: function(response) { uploadOneFile(); } }); } uploadOneFile(); } else { let filelink = "gd:"+fileid+":"+btoa(JSON.stringify(auth)) $.ajax({ url: uploadurl, type: 'POST', data : { url : filelink }, success: function(response) { if (_rc) { let $_rc = $("."+_rc); if ($_rc.length == 0) { debugger; } else { setTimeout(function() { swal.close(); mar.openCloseDocFolderFn($_rc,"refresh"); },3000); } } } }); } } return { choose : choose, upload : upload, setAuth : setAuth, setELM : setELM } })(); /* * Class: DocFolder * Def: allows you upload, store and view info regarding a document * */ class DocFolder { constructor(arg) { this.data = {}; $.extend(true, this.data, arg); /* this.data = arg; this.data.bankname = arg.bankname; this.data.docType = arg.docType; this.data.assetName = arg.assetName; this.data.subtype = arg.subtype; this.data.num = arg.num; this.data.amount = arg.amount; this.data.icon = arg.icon; this.data.longtextTitle this.data.longtext this.data.secondarytextTitle this.data.secondarytext this.data. ?delete function? or no? //this is a empty switch use as template i guess switch(this.data.docType) { case 'paystubs': break; case 'tax returns': break; case 'w2': break; case 'bank': break; case 'general': break; case 'lox': break; default: } */ this.data.status = (this.data.status) ? this.data.status : 1; //status 1 is default or nothing //2, pending //3, action required //4, completed switch(this.data.status.hwstatus) { case 1: this.data.statusObj = {statusDisplayIndicator:''}; break; case 2: this.data.statusObj = {statusDisplayIndicator: 'pending'}; break; case 3: this.data.statusObj = {statusDisplayIndicator: "action req'd"}; break; case 4: this.data.statusObj = {statusDisplayIndicator: "completed"}; break; default: this.data.statusObj = {statusDisplayIndicator:''}; } //mini controller for the class here. switch(this.data.docType) { case 'paystubs': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_paystubs_icon_homework'; if(this.data.status === 3){ this.data.longtextTitle = (this.data.longtextTitle) ? this.data.longtextTitle : 'Attention'; //this should come from a response model this.data.longtext = (this.data.longtext) ? this.data.longtext : 'The paystubs uploaded are not legible, please re-scan or connect to your payroll institution. If you need further clarification call '+elaineui.telF(loanofficer.tel,loanofficer.tel)+' to reach me anytime!'; }else{ this.data.longtextTitle = (this.data.longtextTitle) ? this.data.longtextTitle : 'Paystubs'; this.data.longtext = (this.data.longtext) ? this.data.longtext : 'Please submit your paystubs in a perfect scanned manner.'; } this.data.secondarytextTitle = (this.data.secondarytextTitle) ? this.data.secondarytextTitle : 'Connect to payroll service'; this.data.secondarytext = (this.data.secondarytext) ? this.data.secondarytext : 'Select payroll institution, then continue.'; break; case 'action': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_paystubs_icon_homework'; this.data.longtextTitle = (this.data.longtextTitle) ? this.data.longtextTitle : 'App Data'; this.data.longtext = (this.data.longtext) ? this.data.longtext : 'Long text.'; this.data.secondarytextTitle = (this.data.secondarytextTitle) ? this.data.secondarytextTitle : '2nd titlee'; this.data.secondarytext = (this.data.secondarytext) ? this.data.secondarytext : '2nd text.'; break; case 'tax returns': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_tax_icon_homework'; this.data.longtextTitle = (this.data.longtextTitle) ? this.data.longtextTitle : 'Tax'; this.data.year = (this.data.year) ? this.data.year : '2018'; this.data.longtext = (this.data.longtext) ? this.data.longtext : 'Please submit your tax returns for '+this.data.year +'.'; this.data.secondarytextTitle = (this.data.secondarytextTitle) ? this.data.secondarytextTitle : 'Connect to payroll service'; this.data.secondarytext = (this.data.secondarytext) ? this.data.secondarytext : 'Select payroll institution, then continue.'; break; case 'w2': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_w2_icon_homework'; this.data.longtextTitle = (this.data.longtextTitle) ? this.data.longtextTitle : 'W-2'; this.data.longtext = (this.data.longtext) ? this.data.longtext : "Please submit your W-2's for "+this.data.year +"."; this.data.secondarytextTitle = (this.data.secondarytextTitle) ? this.data.secondarytextTitle : 'Connect to payroll service'; this.data.secondarytext = (this.data.secondarytext) ? this.data.secondarytext : 'Select payroll institution, then continue.'; break; case 'bank': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_account_statements_icon_homework'; this.data.longtextTitle = (this.data.longtextTitle) ? this.data.longtextTitle : 'Bank'; this.data.longtext = (this.data.longtext) ? this.data.longtext : 'Awaiting verbiage.'; this.data.secondarytextTitle = (this.data.secondarytextTitle) ? this.data.secondarytextTitle : 'Connect to payroll service'; this.data.secondarytext = (this.data.secondarytext) ? this.data.secondarytext : 'Select payroll institution, then continue.'; break; case 'general': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_account_statements_icon_homework'; this.data.longtextTitle = (this.data.longtextTitle) ? this.data.longtextTitle : 'General'; this.data.longtext = (this.data.longtext) ? this.data.longtext : 'Awaiting verbiage.'; this.data.secondarytextTitle = (this.data.secondarytextTitle) ? this.data.secondarytextTitle : 'Connect to payroll service'; this.data.secondarytext = (this.data.secondarytext) ? this.data.secondarytext : 'Select payroll institution, then continue.'; break; case 'lox': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_account_statements_icon_homework'; this.data.longtextTitle = (this.data.longtextTitle) ? this.data.longtextTitle : 'Letter of Explanation'; this.data.longtext = (this.data.longtext) ? this.data.longtext : 'Awaiting verbiage.'; this.data.secondarytextTitle = (this.data.secondarytextTitle) ? this.data.secondarytextTitle : ''; this.data.secondarytext = (this.data.secondarytext) ? this.data.secondarytext : ''; break; default: this.data.icon = (this.data.icon) ? this.data.icon : 'svg_account_statements_icon_homework'; this.data.secondarytextTitle = (this.data.secondarytextTitle) ? this.data.secondarytextTitle : 'Connect to payroll service'; this.data.secondarytext = (this.data.secondarytext) ? this.data.secondarytext : 'Select payroll institution, then continue.'; } this.createLayout = function(ftrObj){ let flatten = function(s) { s = s.replace(/'/g,"").trim(); s = s.replace(/\n/g,"").trim(); s = s.replace(/\r/g,"").trim(); s = s.replace(//g,"").trim(); s = s.replace(/"/g,"").trim(); return s; } let h = ''; h += "
"; h += "
"; h += ``; h += "
" + "
"+this.data.title+"
"; h += "
"+this.data.hwtitle+"
"; h += "
"+$("#svg_drop_down_icon").html()+"
"; h +="
";//end topbar h += "
"; h += "
"; if (this.data.status === 3){ h += "
"+$("#svg_warning_icon").html()+"
"+this.data.longtextTitle+"
"+this.data.longtext+"
"; } else { h += "
"+$("#svg_info_icon_homework").html()+"
"+this.data.longtextTitle+"
"+this.data.longtext+"
"; } if (this.data.secondarytextTitle.trim() != "") { h += "
"; h += "
"+$("#svg_connect_payroll_homework").html()+"
"+this.data.secondarytextTitle+"
"+this.data.secondarytext+"
"; } h +="
";//end dropDivInner h += " %s "; if(ftrObj){ // console.warn('ftrObj: ', ftrObj); // console.warn('ftrObj.length: '+ Object.keys(ftrObj).length); if(Object.keys(ftrObj).length === 1){ for (let _x in ftrObj) { let _title = ftrObj[_x].title; let _cls = ("cls" in ftrObj[_x]) ? ftrObj[_x].cls : ""; let upload_need = this.data.need; let loxparent = MAR.getOpt(this.data,"loxparent",""); if (loxparent !== "") { upload_need = loxparent; } let btn = "
"+_title+"
"; let extrbutton = MAR.getOpt(this.data,"loxbutton",false); if (extrbutton !== false) { let exbtn = "
"+extrbutton[0]+"
"; //h += "
DONE
"; btn = (function(){ let h = ""; h += ""; return h; })(); } let lox_allow_action = MAR.getOpt(this.data,"lox_allow_action",true); if (lox_allow_action) { h += btn; } } }else if(Object.keys(ftrObj).length === 2){ h += ""; } }else{ h += ""; } h +="
";//end docFolderBtmArea h +="
";//end holder return h; } this.createMiddle = function(){ // let h = ''; h += "
"; h += "
"; h += "
"; h += "
"; h +="
";//end docFolderSubBtmArea_row h += "
"; h += "
"; h += "
"; h +="
";//end docFolderSubBtmArea_row h +="
";//end docFolderSubBtmArea let paystubs = h; h = ''; h += "
"; h += "
"; h += "ACTION TEXT - " + this.data.action; h +="
";//end docFolderSubBtmArea_row h +="
";//end docFolderSubBtmArea let action = h; h = ""; h += "
"; h += "
"; h += "
"; h += "
"; h +="
";//end docFolderSubBtmArea_row h += "
"; h += "
"; h += "
"; h +="
";//end docFolderSubBtmArea_row h +="
";//end docFolderSubBtmArea let upload = h; // console.warn(" this.data.docType:: :"+this.data.docType); switch(this.data.docType) { case 'paystubs': //ok so place in the payroll institutions here h = paystubs; break; case 'action': //ok so place in the payroll institutions here h = action; break; case 'tax returns': h = upload; break; case 'w2': h = paystubs; break; case 'bank': h = upload; break; case 'general': //console.warn(" OK IT IS GENERAL RE WRITE IT :"); h = upload; /* * Google drive Dropbox Onedrive Box */ //ok so place in the payroll institutions here break; case 'lox': break; default: } return h; } }//end const /* * function render * take the data and renders it according to desired view. * params: string * */ render(vw){ let viewType = (vw) ? vw : this.data.docType; let h = ''; let hInnerMod = ''; let lt = ''; let elm = false; mar.gdrive = (function(){ let elm = false; let auth = false; function choose(ELM) { elm = ELM; gapi.auth2.authorize({ client_id: clientId, scope: scope }, handleAuthResult); } function setELM(ELM) { elm = ELM; } function setAuth(A) { auth = A; if ("session_state" in auth) { delete auth.session_state; } } function upload(fileid, fileids) { let $elm = $(elm); var bucket = "unchecked"; let _needlink = $(elm).data("need"); let _nl = (_needlink && _needlink != "") ? "/need/"+btoa(_needlink) : ""; let _rc = $(elm).data("randomclass"); let uploadurl = "/api/upload/"+mar.ID+"/"+btoa(bucket)+_nl; var h = ''+ "

" + "
" + "
" + "
" + "
" + '

Uploading

'; var s = document.createElement("div"); s.innerHTML = h; swal({ className : "midelinfopopupOneButton", content : s }); if (fileids && fileids.length > 0) { let $uploadingmessage = $("#uploadingmessage"); let totalfiles_start = fileids.length; let totalfiles_cnt = 0; let uploadOneFile = function() { if (fileids.length == 0) { $uploadingmessage.html("Finishing up .. "); if (_rc) { let $_rc = $("."+_rc); if ($_rc.length == 0) { debugger; } else { $uploadingmessage.html("Finishing up, Making thumbnails .. "); setTimeout(function() { swal.close(); mar.openCloseDocFolderFn($_rc,"refresh"); },3000); } } return; } totalfiles_cnt++; $uploadingmessage.html("Uploading file "+totalfiles_cnt+" of "+totalfiles_start+" . "); let _fileid = fileids.shift(); let filelink = "gd:"+_fileid+":"+btoa(JSON.stringify(auth)) $.ajax({ url: uploadurl, type: 'POST', data : { url : filelink }, success: function(response) { uploadOneFile(); } }); } uploadOneFile(); } else { let filelink = "gd:"+fileid+":"+btoa(JSON.stringify(auth)) $.ajax({ url: uploadurl, type: 'POST', data : { url : filelink }, success: function(response) { if (_rc) { let $_rc = $("."+_rc); if ($_rc.length == 0) { debugger; } else { setTimeout(function() { swal.close(); mar.openCloseDocFolderFn($_rc,"refresh"); },3000); } } } }); } } return { choose : choose, upload : upload, setAuth : setAuth, setELM : setELM } })(); mar.openCloseDocFolderDoneAndRemoveFn = function(elm, func) { // mar.openCloseDocFolderDoneFn(elm, "remove"); mar.openCloseDocFolderDoneFn(elm); } mar.openCloseDocFolderDoneFn = function(elm,func) { let $elm = $(elm); let $docFolderHolder = $elm; while ($docFolderHolder.hasClass("docFolderHolder") == false) $docFolderHolder = $docFolderHolder.parent(); let NEED = $elm.data("need"); let LINK = $elm.data("link"); let _rc = $elm.data("randomclass"); $.get(LINK+"?action=submit", function() { let $_rc = $("."+_rc); if ($_rc.length > 0) { if (func && func === "remove") { mar.removeDocFolderFn($_rc); } else { // mar.openCloseDocFolderFn($_rc,"refresh"); mar.openCloseDocFolderFn($_rc,"close-all"); } } }); } mar.openCloseDocFolderUploadMoreFn = function(elm,func) { let $elm = $(elm); let $docFolderHolder = $elm; while ($docFolderHolder.hasClass("docFolderHolder") == false) $docFolderHolder = $docFolderHolder.parent(); let NEED = $elm.data("need"); let LINK = $elm.data("link"); let _rc = $elm.data("randomclass"); $.get(LINK+"?action=client_upload_more", function() { let $_rc = $("."+_rc); if ($_rc.length > 0) { mar.openCloseDocFolderFn($_rc,"refresh"); } }); } mar.VUE = false; mar.removeDocFolderFn = function(elm) { let $elm = $(elm); let $docFolderHolder = $elm; while ($docFolderHolder.hasClass("docFolderHolder") == false) $docFolderHolder = $docFolderHolder.parent(); let $docFolderTopBar = $docFolderHolder.find(".docFolderTopBar"); let block_status = ""; if ($docFolderTopBar.hasClass("docFolderTopBarStatus_4")) block_status = "completed"; if ($docFolderTopBar.hasClass("docFolderTopBarStatus_2")) block_status = "pending"; let $tab = $("#loxdiv-tab-underline"); let tab_status = ""; if ($tab.hasClass("loxdiv-underline-type-type_pending")) tab_status = "pending"; if ($tab.hasClass("loxdiv-underline-type-type_done")) tab_status = "completed"; if (block_status !== tab_status) { let toplevel = elaineui.find_parent_class($(elm), "docFolderHolder"); $(toplevel).fadeOut("slow"); if (mar.VUE && "lox_vue" in mar && mar.lox_vue !== false) { mar.lox_vue.del(); } mar.tmp_get_condition_counters(); // $(elm).parent().parent().remove(); } return; } mar.openCloseDocFolderFn_scroll_to_bottom = function(elm) { let $elm = $(elm); let $docFolderHolder = $elm; while ($docFolderHolder.hasClass("docFolderHolder") == false) $docFolderHolder = $docFolderHolder.parent(); // $("#loxdiv").scrollTop($docFolderHolder.position().top + $docFolderHolder.height() + $("#loxdiv")[0].scrollTop - $("#loxdiv").height()); let docFolderHolder_height = $docFolderHolder.height() let $newdropzone = $docFolderHolder.find(".dropmehere"); if ($newdropzone.length > 0) { docFolderHolder_height -= 100; } $("#loxdiv").scrollTo($docFolderHolder.position().top + docFolderHolder_height + $("#loxdiv")[0].scrollTop - $("#loxdiv").height() + 50, 400); } mar.openCloseDocFolderFn = function(elm,func) { mvc.page("lox", "#lox"); let $elm = $(elm); let randomClass = ""; let _old = false; if (!$elm.data("randomclass")) { randomClass = mar.uniqueclass(); $elm.data("randomclass",randomClass); $elm.addClass(randomClass); _old = false; } else { randomClass = $elm.data("randomclass") _old = true; } // let $docFolderCaret = $elm.parent(); // let $docFolderHolder = $elm.parent().parent().parent(); let $docFolderHolder = $elm; while ($docFolderHolder.hasClass("docFolderHolder") == false) $docFolderHolder = $docFolderHolder.parent(); let $docFolderCaret = $docFolderHolder.find(".dropDownExpandCaret_svg"); let $docFolderTopBar = $docFolderHolder.find(".docFolderTopBar"); let $docFolderStatus = $docFolderTopBar.find(".docFolderStatus"); let $docFolderBtmArea = $docFolderHolder.find(".docFolderBtmArea"); let $docFolderTitle = $docFolderHolder.find(".docFolderTitle"); let $docFolderDynamicContent = $docFolderHolder.find(".docFolderDynamicContent"); // attach a vue to the page // if (func && func == "remove-if-necessary") { // mar.removeDocFolderFn(elm); // return; // } if ($docFolderBtmArea.hasClass("x-hide") || func && func == "refresh" || func && func == "refresh-closed") { /** * should we open the panel */ let open = (func && func == "refresh-closed") ? false : true; /** * close others */ let is_open = (open && ($docFolderBtmArea.hasClass("x-hide") || $docFolderBtmArea.is(":visible") === false || $docFolderBtmArea.html().trim().length === 0)) ? false : true; let docFolderBtmArea_closed = ($docFolderBtmArea.hasClass("x-hide") || $docFolderBtmArea.is(":visible") === false || $docFolderBtmArea.html().trim().length === 0); if (open) { if (docFolderBtmArea_closed === true) { // now we are opening a new one let all_open_carats = $("#loxdiv .upsideDown"); for (let i=0; i < all_open_carats.length; i++) { let $open_carat = $(all_open_carats[i]); let $done_button = $open_carat.find(".dropDivButton.done_and_close"); if ($done_button.length === 0) { mar.openCloseDocFolderFn($open_carat[0], "close"); } else { $done_button.click(); } } if (mar.tmp_show_save_and_close_bar) { mar.tmp_show_save_and_close_bar("hide"); } // let open_buttons = $(".dropDivButton.done_and_close"); // if (open_buttons.length > 0) { // for (let i=0; i < open_buttons.length; i++) { // $(open_buttons[i]).click(); // } // } } } /** * unhide bottom */ if (open) $docFolderBtmArea.removeClass("x-hide"); /** * mark row bottom */ if (open) $docFolderHolder.addClass("x-open"); /** * make carat down */ if (open) $docFolderCaret.addClass("upsideDown"); /** * get the link */ // let link = $elm.data("link"); let link = $docFolderTitle.data("link"); if (mar.VUE && open) { // h = ""; if ("lox_vue" in mar && mar.lox_vue !== false) { if (link !== mar.lox_vue.link) { mar.lox_vue.del(); if ($('.vue_doc_content').length > 0) { $('.vue_doc_content').remove(); } mar.lox_vue = false; } } if ("lox_vue" in mar === false || mar.lox_vue === false) { let vue_html = `
`; $docFolderBtmArea.html(vue_html); mar.lox_vue = new Vue({ el: '.vue_doc_content', data: { link : link, html : 'Hello Vue!', content : "--" }, methods : { del() { //this.$delete(); this.$destroy(); } } }); } } if (link && link != "") { if (_old == false) { h = ""; //h += "
"; //if(this.data.status === 3){ var TITLE = "some data ....."; var BODY = "
"; var TITLE2 = "..."; var BODY2 = $("#elm_working").html(); var NEED = ""; var _title = "UPLOADx"; var _title = "ADD"; var _cls = ""; h += "
"; h += "
"+$("#svg_warning_icon").html()+"
"+TITLE+"
"+BODY+"
"; // h += "
"; // h += "
"+$("#svg_connect_payroll_homework").html()+"
"+TITLE2+"
"+BODY2+"
"; h += "
"; h += "
"+_title+"
"; if (mar.VUE) { if (open && !is_open) mar.lox_vue.content = h; } else { if (open && !is_open) $docFolderBtmArea.html(h); } } if (open) $docFolderBtmArea.LoadingOverlay("show"); $.get(link, function(r) { var TITLE = "Data returned"; var BODY = "
"+JSON.stringify(r,null,4)+"
"; var TITLE2 = "bla"; var BODY2 = "bla bla"; var _title = "UPLOADy"; var _title = "ADD"; var _cls = ""; var old_pages = r[12] var pages = MAR.getOpt(r[6], "exdata", []); var type = r[5]; var NEED = r[2]; var NEEDDATA = r[10]; var DOC = r[26]; var INSTRUCTIONS = false; if (typeof DOC === "object" && DOC && "instructions" in DOC && DOC.instructions.trim().length > 0) { INSTRUCTIONS = DOC.instructions.trim(); if (INSTRUCTIONS.startsWith("#")) { INSTRUCTIONS = INSTRUCTIONS.substring(1) } else { INSTRUCTIONS = false; } } if (typeof r[1] === "string" && r[1].split("|").length > 1) { INSTRUCTIONS = r[1].split("|")[1] } h = ""; if (pages.length > 0 || type == "general") { h += "
"; // h += "
"+$("#svg_warning_icon").html()+"
"+TITLE+"
"+BODY+"
"; let showUpload = false; let showDone = false; let titleStatus = r[6].hwstatus; let titleMessage = r[6].hwtitle; if (INSTRUCTIONS !== false) { h += "
"+ $("#svg_connect_payroll_homework").html()+ "
"+INSTRUCTIONS+"
"; h += "
"; h += "
"; } /** * this is the preview images * * which also have a "waiting" function on them * */ if (pages.length > 0) { let CanDelete = (r[14] == "" || r[14] == "incomplete" || r[14] == "rejected") ? "Y" : "N"; let H = ""; H += "
"+ $("#svg_connect_payroll_homework").html()+ "
You have uploaded the following pages:
"; // "
You have uploaded the following pages "+r[7]+"/"+r[14]+"
"; //H += link; for (let pi=0; pi < pages.length; pi++) { let pages_split_up = pages[pi]; //.split(":"); let _sty = ""; let _status = ""; let _cls = ""; let _status_reason = ""; let _rot = ""; if (pages_split_up.length > 4 && `${pages_split_up[4]}` !== "0") { //_sty += "transform:rotate("+pages_split_up[1]+"deg);"; _rot = ",r"+pages_split_up[4]; } if (pages_split_up.length > 2 && pages_split_up[2] == "rejected") { _sty += "opacity:0.2;"; _status = pages_split_up[2]; _cls = "img_rejected_stripe"; } if (pages_split_up.length > 2 && pages_split_up[2] != "") { for (let pii=0; pii < old_pages.length; pii++) { if (old_pages[pii].startsWith(`${pages_split_up[0]}:`)) { let old_pages_split = old_pages[pii].split(":"); if (old_pages_split.length > 3 && old_pages_split[3] != "") { _status_reason = old_pages_split[3]; break; } } } } let _placeholder = "/_ui/db2/images/placeholder.png"; H += "" + "" + ""; } H += "
"; H += "
" if (r[14] == "" || r[14] == "new") { if (r[10] && "incompletereason" in r[10] && r[10].incompletereason != "") { h += "
"+ $("#svg_connect_payroll_homework").html()+ "
Attention is required. : "+r[10].incompletereason+"
"; // message here h += "
"; h += "
"; } h += H; // h += "
"+ // $("#svg_connect_payroll_homework").html()+ // "
If you have uploaded all the pages click HERE and these documents will be submitted.
"; // h += "
"; showUpload = true; showDone = true; } if (r[14] == "incomplete") { h += "
"+ $("#svg_connect_payroll_homework").html()+ "
Attention is required. : "+r[10].incompletereason+"
"; // message here h += "
"; h += "
"; h += H; showUpload = true; showDone = true; } if (r[14] == "rejected") { h += "
"+ $("#svg_connect_payroll_homework").html()+ "
Attention is required. : "+r[10].incompletereason+"
"; // message here h += "
"; h += "
"; h += H; showUpload = true; showDone = true; } if (r[14] == "received") { if (r[10] && "incompletereason" in r[10] && r[10].incompletereason != "") { h += "
"+ $("#svg_connect_payroll_homework").html()+ "
Attention is required. : "+r[10].incompletereason+"
"; // message here h += "
"; h += "
"; } h += H; h += "
"+ $("#svg_connect_payroll_homework").html()+ "
The documents have been recieved and will be processed.
"; h += "
"; showUpload = true; showDone = true; } if (r[14] == "cleared") { h += "
"+ $("#svg_connect_payroll_homework").html()+ // "
The condition have been cleared and consists of the following individual pages :
"; "
Reviewed pages :
"; h += "
"; let doc = r[19]; if (doc) { if ("json" in doc && "pages" in doc.json) { pages = doc.json.pages.split("|"); h += "
"; for (let pi=0; pi < pages.length; pi++) { let pages_split_up = pages[pi].split(":"); let _sty = ""; if (pages_split_up.length > 1 && pages_split_up[1] != "0") { _sty += "transform:rotate("+pages_split_up[1]+"deg);"; } // h += "
"+pi+":"+ pages[pi] + "
"; h += ""; } h += "
"; } } let pdf301 = r[22]; let pdfinline = r[24]; if (pdf301 && pdf301 != "") { // h += "
"; // h += "
"; // h += "
"+ // $("#svg_connect_payroll_homework").html()+ // "
This is the PDF which will be submitted to underwriting , click on the page below to view / or download a copy for your own records.
"; // h += "
"; // if (mar.state.desktop == false) { // h += "
" //// h += "
Download
" // h += "
"; // h += "
Download
"; // } else { // h += "
" //// h += "
Download
" // // h += "
"; // h += "
Download
"; // // // } } } } else { if (r[10] && "incompletereason" in r[10] && r[10].incompletereason != "") { h += "
"+ $("#svg_connect_payroll_homework").html()+ "
Attention is required. : "+r[10].incompletereason+"
"; // message here h += "
"; h += "
"; } // mar.infothis = function(ELM) { // let $elm = $(ELM); // let text = $elm.next().html(); // var s = document.createElement("div"); // s.setAttribute("class","normal-form"); // s.innerHTML = text; // // swal({ // //title : "Same line of work", // className : "midelinfopopupOneButton", // content : s, // buttons : { // cancel : "GOT IT" // // } // }); // } // //h += "
"+ // h += "
"+ // "" + // "
Help with uploading
" + // "Press 'upload' to find the requested documents directly from your phone, cloud storage or computer. You can upload as many documents as you like. " + // "
" + // "
" + // "When you are finished, press 'Done' and your processor will review your documents."+ // "
" + // ""; // h += "
"; // h += "
"; showUpload = true; } if (showUpload) { // h += "
"; // /** // * dropbox etc.. // */ // if (mar.dropbox.isAvailable()) { // h += "
"; // h += "
"; // h += "
"; // h += "
"; // h +="
";//end docFolderSubBtmArea_row // // h += "
"; // h += "
"; // // h += "
"; // // h += "
"; // // // h +="
";//end docFolderSubBtmArea_row // h +="
";//end docFolderSubBtmArea // } else { // h += "
"; // h += "
"; // h += "
"; // h += "
"; // h +="
";//end docFolderSubBtmArea_row // // } h += "
"; if (isPhone() === false || mar.WE_ARE_FROM_LOI === true) { h += "
Drop files here or click to upload.
"; setTimeout(function(){ let $newdropzone = $docFolderBtmArea.find(".dropmehere"); if ($newdropzone.length === 0) return; mar.filepupload.upload($newdropzone); },500); } if (showDone) { h += ""; } if (open) $docFolderBtmArea.LoadingOverlay("hide",true); if (mar.VUE) { if (open) mar.lox_vue.content = h; } else { if (open) $docFolderBtmArea.html(h); } //mar.filepupload.upload($docFolderBtmArea.find(".drop")); $docFolderTopBar.removeClass("docFolderTopBarStatus_1"); $docFolderTopBar.removeClass("docFolderTopBarStatus_2"); $docFolderTopBar.removeClass("docFolderTopBarStatus_3"); $docFolderTopBar.removeClass("docFolderTopBarStatus_4"); $docFolderTopBar.addClass("docFolderTopBarStatus_"+titleStatus); $docFolderHolder.removeClass("docFolderStatus_1"); $docFolderHolder.removeClass("docFolderStatus_2"); $docFolderHolder.removeClass("docFolderStatus_3"); $docFolderHolder.removeClass("docFolderStatus_4"); $docFolderHolder.addClass("docFolderStatus_"+titleStatus); $docFolderStatus.html(titleMessage) $docFolderHolder.prop("data-order",titleStatus); if (!func) { let _elm = $elm[0] setTimeout(function() { mar.openCloseDocFolderFn_scroll_to_bottom(_elm); },200); } if (func && func == "refresh") { let _elm = $elm[0] setTimeout(function() { mar.openCloseDocFolderFn_scroll_to_bottom(_elm); },2000); } return; } else if (pages.length > 0 || type.startsWith("action") ) { h += "
"; h += type.split(":")[1]; h += "
"; } else { /** * this is the real paystubs area */ h += "
"; h += "
"; h += "
"; h += "
"; h +="
";//end docFolderSubBtmArea_row h += "
"; h += "
"; h += "
"; h +="
";//end docFolderSubBtmArea_row h +="
";//end docFolderSubBtmArea if (isPhone() === false || mar.WE_ARE_FROM_LOI === true) { h += "
Drop files here or click to upload.
"; setTimeout(function(){ let $newdropzone = $docFolderBtmArea.find(".dropmehere"); if ($newdropzone.length === 0) return; mar.filepupload.upload($newdropzone); },500); } h += "
"+_title+"
"; if (open) $docFolderBtmArea.LoadingOverlay("hide",true); if (mar.VUE) { if (open) mar.lox_vue.content = h; } else { if (open) $docFolderBtmArea.html(h); } //mar.filepupload.upload($docFolderBtmArea.find(".drop")); $docFolderTopBar.removeClass("docFolderTopBarStatus_1"); $docFolderTopBar.removeClass("docFolderTopBarStatus_2"); $docFolderTopBar.removeClass("docFolderTopBarStatus_3"); $docFolderTopBar.removeClass("docFolderTopBarStatus_4"); $docFolderTopBar.addClass("docFolderTopBarStatus_"+titleStatus); $docFolderStatus.html(titleMessage) $docFolderHolder.removeClass("docFolderStatus_1"); $docFolderHolder.removeClass("docFolderStatus_2"); $docFolderHolder.removeClass("docFolderStatus_3"); $docFolderHolder.removeClass("docFolderStatus_4"); $docFolderHolder.addClass("docFolderStatus_"+titleStatus); $docFolderHolder.prop("data-order",titleStatus) return; } $docFolderBtmArea.LoadingOverlay("hide",true); if (mar.VUE) { if (open) mar.lox_vue.content = h; } else { if (open) $docFolderBtmArea.html(h); } }) // }else{ // h += "
"+$("#svg_info_icon_homework").html()+"
"+this.data.longtextTitle+"
"+this.data.longtext+"
"; // // } } //$elm.html('∧'); //let link = $elm.data("link"); } else { $docFolderBtmArea.addClass("x-hide"); $docFolderCaret.removeClass("upsideDown"); $docFolderHolder.removeClass("x-open"); if (mar.VUE) { mar.lox_vue.content = h; mar.lox_vue.del(); mar.lox_vue = false;; $docFolderBtmArea.html(h); } else { let link = $elm.data("link"); if (link && link != "") { $docFolderBtmArea.html(""); } if (!func || func !== "close") { if (mar.tmp_show_save_and_close_bar) { mar.tmp_show_save_and_close_bar("show"); } } if (func && func === "close-all") { if ($docFolderHolder.hasClass("docFolderStatus_2")) $docFolderHolder.data("order",2); if (mar.sortloxdiv_rt) mar.sortloxdiv_rt(); } // $docFolderBtmArea.html(h); } //$elm.html('∨'); } } // mar.payrollPressFn = function(e) { // // // // //console.log('pressed icon button e: ',e); // let $elm = $(e); // let goto = $elm.data("goto"); // let imgsrc = $elm.data("imgsrc"); // let displayname = $elm.data("displayname"); // //console.log('goto : '+goto); // // //mar.chosenBank = {id:goto, displayName:pagenames[goto]}; // // if (goto && goto != "") { // //mar. // //mvc.go("#assets-"+pagenames[goto]); // // // // let chosenBank = {id:goto, displayName: displayname}; // // let h = ""; // h += "
"; // // // h += "
"; // h += ""; // h += "
"; // // h += "
"; // h += "Sign In"; // h += "
"; // // h += "
"; // h += "Please enter your credentials for "+chosenBank.displayName+" "; // h += "
"; // // //note: these need to be dynamic and generated by the api // h += "
"; // h += "User name for "+chosenBank.displayName+" "; // h += "
"; // // h += "
"; // h += ""; // h += "
"; // // // // h += "
"; // h += "Password for "+chosenBank.displayName+" "; // h += "
"; // // h += "
"; // h += ""; // h += "
"; // // // h += "
Continue
"; // h += "
"; // // // h += "
";//end account verification // // // // // // //launch the overlay // // var s = document.createElement("div"); // s.setAttribute("class","normal-form"); // // /* // s.innerHTML = ""+ // frm.htitle("Please choose your bank").render()+ // "
"+ // // $("#svg_plaid_logo").html()+ // "
"+ // "
"+ // "PLAID LINK here? "+ // "
"; // */ // // s.innerHTML = h; // // // // swal({ // //title : "Same line of work", // className : "midelinfopopupOneButton", // content : s, // buttons : { // cancel : "CANCEL" // // } // }); // // // // // } // // // // // // // } // this is like a default h h = this.createLayout(); hInnerMod = ""; //this.createMiddle(); switch(viewType) { case 'paystubs': h = sprintf(h, hInnerMod); break; case 'paystubs': h = sprintf(h, hInnerMod); break; case 'tax returns': h = sprintf(h, hInnerMod); break; case 'w2': h = sprintf(h, hInnerMod); break; case 'bank': h = this.createLayout({button1:{title:'OK'}}); h = sprintf(h, hInnerMod); break; case 'general': h = this.createLayout({button1:{ title:'Upload', cls : "drop" }}); //h = sprintf(h, "
"); h = sprintf(h, hInnerMod); break; case 'lox': h = this.createLayout({button1:{ title:'Upload', cls : "drop" }}); // h = this.createLayout({button1:{title:'Sign letter'}}); h = sprintf(h, "
"); break; default: h = this.createLayout({button1:{title:'OK'}}); h = sprintf(h, hInnerMod); } return h; } updateModel(val){ $.extend(true, this.data, val); } } //end DocFolder mar.objectBlockBuilder = function(){ let h = ""; let t = ""; function title(T) { if (arguments.length == 0) return t; t = T; } function row(H) { return `
${H}
`; } function add(L,R) { if (arguments.length == 1) { h += row(`
${L}
`) } else { h += row(`
${L}
` + `
${R}
`) } } function render() { return h; } return { add : add, title : title, render : render, ____id : "object block renderer" } } // start 3 panel popup mar.three_panel_pane = (function(){ function p1() { if (arguments.length > 0) { $($(".three_panel .three_panel_pane")[0]).html(H) return; } $(".three_panel .three_panel_inner").animate({ marginLeft : "0px" },300) } function getp1() { return $(".three_panel .three_panel_pane")[0]; } function getp2() { return $(".three_panel .three_panel_pane")[1]; } function p2(H) { if (arguments.length > 0) { H = "
keyboard_backspace
" + H; $($(".three_panel .three_panel_pane")[1]).html(H) return; } $(".three_panel .three_panel_inner").animate({ marginLeft : "-100%" },300) } function init() { if ($("#three_panel_css").length == 0) { $("html").append(""); } } function getHtml(p1,p2) { let h = ""; h += "
"; h += "
"; h += "
"; h += "
"; h += p1; h += "
";//end pane h += "
"; h += p2; h += "
";//end pane h += "
";//end three pannel inner tab h += "
";//end three pannel inner h += "
";//end three pannel return h; } return { init : init, p1 : p1, p2 : p2, getp1 : getp1, getp2 : getp2, getHtml : getHtml, ___id : "threepanel" } })(); // end 3 panel popup mar.classes = {}; /* file /ui/app/js/_classes/Syncview_class.js , last updated 1562244562805*/ mar.classes.Syncview_class = function(OBJ) { // { // loanid: "ac815f59-a62d-416a-b72e-dbd2e46b86aa", // app_locked: false, // token: true, // enc_locked: - { // status: 0, // message: "not locked", // response:[], // by_me: false // }, // al:{}, // loanNumber: "90210030198", // syncstatus_rt: "001L encompass was Locked , will retry in 1 minute", // syncstatus: false, // willsyncin: 15441, // lastElaine: - { // applicant_count: 1, // ssns: [ // "121212121" // ] // } // } let obj = OBJ; function hasBeenSynced() { if (!obj) return false; if (MAR.getOpt(obj, "loanNumber", "") === "") return false; return true; } function getLoanNumber() { if (!obj) return ""; return MAR.getOpt(obj, "loanNumber", "") } function numberOfApplicants() { if (!obj) return false; if ("lastElaine" in obj === false) return false; if ("applicant_count" in obj.lastElaine === false) return false; return (obj.lastElaine.applicant_count); } function canDeleteApplicant(n) { if (hasBeenSynced() === false) return true; let noa = numberOfApplicants(); if (noa === false) return true; if (n >= noa) return true; return false; } return { loanNumber : getLoanNumber, hasBeenSynced : hasBeenSynced, canDeleteApplicant : canDeleteApplicant, ___id : "" } } /* file /ui/app/js/_classes/fingerprint2.js , last updated 1576112859902*/ !function(e,t,i){"use strict";"function"==typeof define&&define.amd?define(i):"undefined"!=typeof module&&module.exports?module.exports=i():t.exports?t.exports=i():t[e]=i()}("Fingerprint2",this,function(){"use strict";var e=function(t){if(!(this instanceof e))return new e(t);var i={swfContainerId:"fingerprintjs2",swfPath:"flash/compiled/FontList.swf",detectScreenOrientation:!0,sortPluginsFor:[/palemoon/i],userDefinedFonts:[]};this.options=this.extend(t,i),this.nativeForEach=Array.prototype.forEach,this.nativeMap=Array.prototype.map};return e.prototype={extend:function(e,t){if(null==e)return t;for(var i in e)null!=e[i]&&t[i]!==e[i]&&(t[i]=e[i]);return t},get:function(e){var t=this,i={data:[],push:function(e){var i=e.key,a=e.value;"function"==typeof t.options.preprocessor&&(a=t.options.preprocessor(i,a)),this.data.push({key:i,value:a})}};i=this.userAgentKey(i),i=this.languageKey(i),i=this.colorDepthKey(i),i=this.pixelRatioKey(i),i=this.hardwareConcurrencyKey(i),i=this.screenResolutionKey(i),i=this.availableScreenResolutionKey(i),i=this.timezoneOffsetKey(i),i=this.sessionStorageKey(i),i=this.localStorageKey(i),i=this.indexedDbKey(i),i=this.addBehaviorKey(i),i=this.openDatabaseKey(i),i=this.cpuClassKey(i),i=this.platformKey(i),i=this.doNotTrackKey(i),i=this.pluginsKey(i),i=this.canvasKey(i),i=this.webglKey(i),i=this.adBlockKey(i),i=this.hasLiedLanguagesKey(i),i=this.hasLiedResolutionKey(i),i=this.hasLiedOsKey(i),i=this.hasLiedBrowserKey(i),i=this.touchSupportKey(i),i=this.customEntropyFunction(i),this.fontsKey(i,function(i){var a=[];t.each(i.data,function(e){var t=e.value;"undefined"!=typeof e.value.join&&(t=e.value.join(";")),a.push(t)});var r=t.x64hash128(a.join("~~~"),31);return e(r,i.data)})},customEntropyFunction:function(e){return"function"==typeof this.options.customFunction&&e.push({key:"custom",value:this.options.customFunction()}),e},userAgentKey:function(e){return this.options.excludeUserAgent||e.push({key:"user_agent",value:this.getUserAgent()}),e},getUserAgent:function(){return navigator.userAgent},languageKey:function(e){return this.options.excludeLanguage||e.push({key:"language",value:navigator.language||navigator.userLanguage||navigator.browserLanguage||navigator.systemLanguage||""}),e},colorDepthKey:function(e){return this.options.excludeColorDepth||e.push({key:"color_depth",value:screen.colorDepth||-1}),e},pixelRatioKey:function(e){return this.options.excludePixelRatio||e.push({key:"pixel_ratio",value:this.getPixelRatio()}),e},getPixelRatio:function(){return window.devicePixelRatio||""},screenResolutionKey:function(e){return this.options.excludeScreenResolution?e:this.getScreenResolution(e)},getScreenResolution:function(e){var t;return t=this.options.detectScreenOrientation&&screen.height>screen.width?[screen.height,screen.width]:[screen.width,screen.height],"undefined"!=typeof t&&e.push({key:"resolution",value:t}),e},availableScreenResolutionKey:function(e){return this.options.excludeAvailableScreenResolution?e:this.getAvailableScreenResolution(e)},getAvailableScreenResolution:function(e){var t;return screen.availWidth&&screen.availHeight&&(t=this.options.detectScreenOrientation?screen.availHeight>screen.availWidth?[screen.availHeight,screen.availWidth]:[screen.availWidth,screen.availHeight]:[screen.availHeight,screen.availWidth]),"undefined"!=typeof t&&e.push({key:"available_resolution",value:t}),e},timezoneOffsetKey:function(e){return this.options.excludeTimezoneOffset||e.push({key:"timezone_offset",value:(new Date).getTimezoneOffset()}),e},sessionStorageKey:function(e){return!this.options.excludeSessionStorage&&this.hasSessionStorage()&&e.push({key:"session_storage",value:1}),e},localStorageKey:function(e){return!this.options.excludeSessionStorage&&this.hasLocalStorage()&&e.push({key:"local_storage",value:1}),e},indexedDbKey:function(e){return!this.options.excludeIndexedDB&&this.hasIndexedDB()&&e.push({key:"indexed_db",value:1}),e},addBehaviorKey:function(e){return document.body&&!this.options.excludeAddBehavior&&document.body.addBehavior&&e.push({key:"add_behavior",value:1}),e},openDatabaseKey:function(e){return!this.options.excludeOpenDatabase&&window.openDatabase&&e.push({key:"open_database",value:1}),e},cpuClassKey:function(e){return this.options.excludeCpuClass||e.push({key:"cpu_class",value:this.getNavigatorCpuClass()}),e},platformKey:function(e){return this.options.excludePlatform||e.push({key:"navigator_platform",value:this.getNavigatorPlatform()}),e},doNotTrackKey:function(e){return this.options.excludeDoNotTrack||e.push({key:"do_not_track",value:this.getDoNotTrack()}),e},canvasKey:function(e){return!this.options.excludeCanvas&&this.isCanvasSupported()&&e.push({key:"canvas",value:this.getCanvasFp()}),e},webglKey:function(e){return this.options.excludeWebGL?e:this.isWebGlSupported()?(e.push({key:"webgl",value:this.getWebglFp()}),e):e},adBlockKey:function(e){return this.options.excludeAdBlock||e.push({key:"adblock",value:this.getAdBlock()}),e},hasLiedLanguagesKey:function(e){return this.options.excludeHasLiedLanguages||e.push({key:"has_lied_languages",value:this.getHasLiedLanguages()}),e},hasLiedResolutionKey:function(e){return this.options.excludeHasLiedResolution||e.push({key:"has_lied_resolution",value:this.getHasLiedResolution()}),e},hasLiedOsKey:function(e){return this.options.excludeHasLiedOs||e.push({key:"has_lied_os",value:this.getHasLiedOs()}),e},hasLiedBrowserKey:function(e){return this.options.excludeHasLiedBrowser||e.push({key:"has_lied_browser",value:this.getHasLiedBrowser()}),e},fontsKey:function(e,t){return this.options.excludeJsFonts?this.flashFontsKey(e,t):this.jsFontsKey(e,t)},flashFontsKey:function(e,t){return this.options.excludeFlashFonts?t(e):this.hasSwfObjectLoaded()&&this.hasMinFlashInstalled()?"undefined"==typeof this.options.swfPath?t(e):void this.loadSwfAndDetectFonts(function(i){e.push({key:"swf_fonts",value:i.join(";")}),t(e)}):t(e)},jsFontsKey:function(e,t){var i=this;return setTimeout(function(){var a=["monospace","sans-serif","serif"],r=["Andale Mono","Arial","Arial Black","Arial Hebrew","Arial MT","Arial Narrow","Arial Rounded MT Bold","Arial Unicode MS","Bitstream Vera Sans Mono","Book Antiqua","Bookman Old Style","Calibri","Cambria","Cambria Math","Century","Century Gothic","Century Schoolbook","Comic Sans","Comic Sans MS","Consolas","Courier","Courier New","Garamond","Geneva","Georgia","Helvetica","Helvetica Neue","Impact","Lucida Bright","Lucida Calligraphy","Lucida Console","Lucida Fax","LUCIDA GRANDE","Lucida Handwriting","Lucida Sans","Lucida Sans Typewriter","Lucida Sans Unicode","Microsoft Sans Serif","Monaco","Monotype Corsiva","MS Gothic","MS Outlook","MS PGothic","MS Reference Sans Serif","MS Sans Serif","MS Serif","MYRIAD","MYRIAD PRO","Palatino","Palatino Linotype","Segoe Print","Segoe Script","Segoe UI","Segoe UI Light","Segoe UI Semibold","Segoe UI Symbol","Tahoma","Times","Times New Roman","Times New Roman PS","Trebuchet MS","Verdana","Wingdings","Wingdings 2","Wingdings 3"],n=["Abadi MT Condensed Light","Academy Engraved LET","ADOBE CASLON PRO","Adobe Garamond","ADOBE GARAMOND PRO","Agency FB","Aharoni","Albertus Extra Bold","Albertus Medium","Algerian","Amazone BT","American Typewriter","American Typewriter Condensed","AmerType Md BT","Andalus","Angsana New","AngsanaUPC","Antique Olive","Aparajita","Apple Chancery","Apple Color Emoji","Apple SD Gothic Neo","Arabic Typesetting","ARCHER","ARNO PRO","Arrus BT","Aurora Cn BT","AvantGarde Bk BT","AvantGarde Md BT","AVENIR","Ayuthaya","Bandy","Bangla Sangam MN","Bank Gothic","BankGothic Md BT","Baskerville","Baskerville Old Face","Batang","BatangChe","Bauer Bodoni","Bauhaus 93","Bazooka","Bell MT","Bembo","Benguiat Bk BT","Berlin Sans FB","Berlin Sans FB Demi","Bernard MT Condensed","BernhardFashion BT","BernhardMod BT","Big Caslon","BinnerD","Blackadder ITC","BlairMdITC TT","Bodoni 72","Bodoni 72 Oldstyle","Bodoni 72 Smallcaps","Bodoni MT","Bodoni MT Black","Bodoni MT Condensed","Bodoni MT Poster Compressed","Bookshelf Symbol 7","Boulder","Bradley Hand","Bradley Hand ITC","Bremen Bd BT","Britannic Bold","Broadway","Browallia New","BrowalliaUPC","Brush Script MT","Californian FB","Calisto MT","Calligrapher","Candara","CaslonOpnface BT","Castellar","Centaur","Cezanne","CG Omega","CG Times","Chalkboard","Chalkboard SE","Chalkduster","Charlesworth","Charter Bd BT","Charter BT","Chaucer","ChelthmITC Bk BT","Chiller","Clarendon","Clarendon Condensed","CloisterBlack BT","Cochin","Colonna MT","Constantia","Cooper Black","Copperplate","Copperplate Gothic","Copperplate Gothic Bold","Copperplate Gothic Light","CopperplGoth Bd BT","Corbel","Cordia New","CordiaUPC","Cornerstone","Coronet","Cuckoo","Curlz MT","DaunPenh","Dauphin","David","DB LCD Temp","DELICIOUS","Denmark","DFKai-SB","Didot","DilleniaUPC","DIN","DokChampa","Dotum","DotumChe","Ebrima","Edwardian Script ITC","Elephant","English 111 Vivace BT","Engravers MT","EngraversGothic BT","Eras Bold ITC","Eras Demi ITC","Eras Light ITC","Eras Medium ITC","EucrosiaUPC","Euphemia","Euphemia UCAS","EUROSTILE","Exotc350 Bd BT","FangSong","Felix Titling","Fixedsys","FONTIN","Footlight MT Light","Forte","FrankRuehl","Fransiscan","Freefrm721 Blk BT","FreesiaUPC","Freestyle Script","French Script MT","FrnkGothITC Bk BT","Fruitger","FRUTIGER","Futura","Futura Bk BT","Futura Lt BT","Futura Md BT","Futura ZBlk BT","FuturaBlack BT","Gabriola","Galliard BT","Gautami","Geeza Pro","Geometr231 BT","Geometr231 Hv BT","Geometr231 Lt BT","GeoSlab 703 Lt BT","GeoSlab 703 XBd BT","Gigi","Gill Sans","Gill Sans MT","Gill Sans MT Condensed","Gill Sans MT Ext Condensed Bold","Gill Sans Ultra Bold","Gill Sans Ultra Bold Condensed","Gisha","Gloucester MT Extra Condensed","GOTHAM","GOTHAM BOLD","Goudy Old Style","Goudy Stout","GoudyHandtooled BT","GoudyOLSt BT","Gujarati Sangam MN","Gulim","GulimChe","Gungsuh","GungsuhChe","Gurmukhi MN","Haettenschweiler","Harlow Solid Italic","Harrington","Heather","Heiti SC","Heiti TC","HELV","Herald","High Tower Text","Hiragino Kaku Gothic ProN","Hiragino Mincho ProN","Hoefler Text","Humanst 521 Cn BT","Humanst521 BT","Humanst521 Lt BT","Imprint MT Shadow","Incised901 Bd BT","Incised901 BT","Incised901 Lt BT","INCONSOLATA","Informal Roman","Informal011 BT","INTERSTATE","IrisUPC","Iskoola Pota","JasmineUPC","Jazz LET","Jenson","Jester","Jokerman","Juice ITC","Kabel Bk BT","Kabel Ult BT","Kailasa","KaiTi","Kalinga","Kannada Sangam MN","Kartika","Kaufmann Bd BT","Kaufmann BT","Khmer UI","KodchiangUPC","Kokila","Korinna BT","Kristen ITC","Krungthep","Kunstler Script","Lao UI","Latha","Leelawadee","Letter Gothic","Levenim MT","LilyUPC","Lithograph","Lithograph Light","Long Island","Lydian BT","Magneto","Maiandra GD","Malayalam Sangam MN","Malgun Gothic","Mangal","Marigold","Marion","Marker Felt","Market","Marlett","Matisse ITC","Matura MT Script Capitals","Meiryo","Meiryo UI","Microsoft Himalaya","Microsoft JhengHei","Microsoft New Tai Lue","Microsoft PhagsPa","Microsoft Tai Le","Microsoft Uighur","Microsoft YaHei","Microsoft Yi Baiti","MingLiU","MingLiU_HKSCS","MingLiU_HKSCS-ExtB","MingLiU-ExtB","Minion","Minion Pro","Miriam","Miriam Fixed","Mistral","Modern","Modern No. 20","Mona Lisa Solid ITC TT","Mongolian Baiti","MONO","MoolBoran","Mrs Eaves","MS LineDraw","MS Mincho","MS PMincho","MS Reference Specialty","MS UI Gothic","MT Extra","MUSEO","MV Boli","Nadeem","Narkisim","NEVIS","News Gothic","News GothicMT","NewsGoth BT","Niagara Engraved","Niagara Solid","Noteworthy","NSimSun","Nyala","OCR A Extended","Old Century","Old English Text MT","Onyx","Onyx BT","OPTIMA","Oriya Sangam MN","OSAKA","OzHandicraft BT","Palace Script MT","Papyrus","Parchment","Party LET","Pegasus","Perpetua","Perpetua Titling MT","PetitaBold","Pickwick","Plantagenet Cherokee","Playbill","PMingLiU","PMingLiU-ExtB","Poor Richard","Poster","PosterBodoni BT","PRINCETOWN LET","Pristina","PTBarnum BT","Pythagoras","Raavi","Rage Italic","Ravie","Ribbon131 Bd BT","Rockwell","Rockwell Condensed","Rockwell Extra Bold","Rod","Roman","Sakkal Majalla","Santa Fe LET","Savoye LET","Sceptre","Script","Script MT Bold","SCRIPTINA","Serifa","Serifa BT","Serifa Th BT","ShelleyVolante BT","Sherwood","Shonar Bangla","Showcard Gothic","Shruti","Signboard","SILKSCREEN","SimHei","Simplified Arabic","Simplified Arabic Fixed","SimSun","SimSun-ExtB","Sinhala Sangam MN","Sketch Rockwell","Skia","Small Fonts","Snap ITC","Snell Roundhand","Socket","Souvenir Lt BT","Staccato222 BT","Steamer","Stencil","Storybook","Styllo","Subway","Swis721 BlkEx BT","Swiss911 XCm BT","Sylfaen","Synchro LET","System","Tamil Sangam MN","Technical","Teletype","Telugu Sangam MN","Tempus Sans ITC","Terminal","Thonburi","Traditional Arabic","Trajan","TRAJAN PRO","Tristan","Tubular","Tunga","Tw Cen MT","Tw Cen MT Condensed","Tw Cen MT Condensed Extra Bold","TypoUpright BT","Unicorn","Univers","Univers CE 55 Medium","Univers Condensed","Utsaah","Vagabond","Vani","Vijaya","Viner Hand ITC","VisualUI","Vivaldi","Vladimir Script","Vrinda","Westminster","WHITNEY","Wide Latin","ZapfEllipt BT","ZapfHumnst BT","ZapfHumnst Dm BT","Zapfino","Zurich BlkEx BT","Zurich Ex BT","ZWAdobeF"];i.options.extendedJsFonts&&(r=r.concat(n)),r=r.concat(i.options.userDefinedFonts);var o="mmmmmmmmmmlli",s="72px",l=document.getElementsByTagName("body")[0],h=document.createElement("div"),u=document.createElement("div"),c={},d={},g=function(){var e=document.createElement("span");return e.style.position="absolute",e.style.left="-9999px",e.style.fontSize=s,e.style.lineHeight="normal",e.innerHTML=o,e},p=function(e,t){var i=g();return i.style.fontFamily="'"+e+"',"+t,i},f=function(){for(var e=[],t=0,i=a.length;tt.name?1:e.name=0?"Windows Phone":t.indexOf("win")>=0?"Windows":t.indexOf("android")>=0?"Android":t.indexOf("linux")>=0?"Linux":t.indexOf("iphone")>=0||t.indexOf("ipad")>=0?"iOS":t.indexOf("mac")>=0?"Mac":"Other";var r;if(r="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,r&&"Windows Phone"!==e&&"Android"!==e&&"iOS"!==e&&"Other"!==e)return!0;if("undefined"!=typeof i){if(i=i.toLowerCase(),i.indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e)return!0;if(i.indexOf("linux")>=0&&"Linux"!==e&&"Android"!==e)return!0;if(i.indexOf("mac")>=0&&"Mac"!==e&&"iOS"!==e)return!0;if(0===i.indexOf("win")&&0===i.indexOf("linux")&&i.indexOf("mac")>=0&&"other"!==e)return!0}return a.indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e||((a.indexOf("linux")>=0||a.indexOf("android")>=0||a.indexOf("pike")>=0)&&"Linux"!==e&&"Android"!==e||((a.indexOf("mac")>=0||a.indexOf("ipad")>=0||a.indexOf("ipod")>=0||a.indexOf("iphone")>=0)&&"Mac"!==e&&"iOS"!==e||(0===a.indexOf("win")&&0===a.indexOf("linux")&&a.indexOf("mac")>=0&&"other"!==e||"undefined"==typeof navigator.plugins&&"Windows"!==e&&"Windows Phone"!==e)))},getHasLiedBrowser:function(){var e,t=navigator.userAgent.toLowerCase(),i=navigator.productSub;if(e=t.indexOf("firefox")>=0?"Firefox":t.indexOf("opera")>=0||t.indexOf("opr")>=0?"Opera":t.indexOf("chrome")>=0?"Chrome":t.indexOf("safari")>=0?"Safari":t.indexOf("trident")>=0?"Internet Explorer":"Other",("Chrome"===e||"Safari"===e||"Opera"===e)&&"20030107"!==i)return!0;var a=eval.toString().length;if(37===a&&"Safari"!==e&&"Firefox"!==e&&"Other"!==e)return!0;if(39===a&&"Internet Explorer"!==e&&"Other"!==e)return!0;if(33===a&&"Chrome"!==e&&"Opera"!==e&&"Other"!==e)return!0;var r;try{throw"a"}catch(n){try{n.toSource(),r=!0}catch(o){r=!1}}return!(!r||"Firefox"===e||"Other"===e)},isCanvasSupported:function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},isWebGlSupported:function(){if(!this.isCanvasSupported())return!1;var e,t=document.createElement("canvas");try{e=t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))}catch(i){e=!1}return!!window.WebGLRenderingContext&&!!e},isIE:function(){return"Microsoft Internet Explorer"===navigator.appName||!("Netscape"!==navigator.appName||!/Trident/.test(navigator.userAgent))},hasSwfObjectLoaded:function(){return"undefined"!=typeof window.swfobject},hasMinFlashInstalled:function(){return swfobject.hasFlashPlayerVersion("9.0.0")},addFlashDivNode:function(){var e=document.createElement("div");e.setAttribute("id",this.options.swfContainerId),document.body.appendChild(e)},loadSwfAndDetectFonts:function(e){var t="___fp_swf_loaded";window[t]=function(t){e(t)};var i=this.options.swfContainerId;this.addFlashDivNode();var a={onReady:t},r={allowScriptAccess:"always",menu:"false"};swfobject.embedSWF(this.options.swfPath,i,"1","1","9.0.0",!1,a,r,{})},getWebglCanvas:function(){var e=document.createElement("canvas"),t=null;try{t=e.getContext("webgl")||e.getContext("experimental-webgl")}catch(i){}return t||(t=null),t},each:function(e,t,i){if(null!==e)if(this.nativeForEach&&e.forEach===this.nativeForEach)e.forEach(t,i);else if(e.length===+e.length){for(var a=0,r=e.length;a>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var i=[0,0,0,0];return i[3]+=e[3]+t[3],i[2]+=i[3]>>>16,i[3]&=65535,i[2]+=e[2]+t[2],i[1]+=i[2]>>>16,i[2]&=65535,i[1]+=e[1]+t[1],i[0]+=i[1]>>>16,i[1]&=65535,i[0]+=e[0]+t[0],i[0]&=65535,[i[0]<<16|i[1],i[2]<<16|i[3]]},x64Multiply:function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var i=[0,0,0,0];return i[3]+=e[3]*t[3],i[2]+=i[3]>>>16,i[3]&=65535,i[2]+=e[2]*t[3],i[1]+=i[2]>>>16,i[2]&=65535,i[2]+=e[3]*t[2],i[1]+=i[2]>>>16,i[2]&=65535,i[1]+=e[1]*t[3],i[0]+=i[1]>>>16,i[1]&=65535,i[1]+=e[2]*t[2],i[0]+=i[1]>>>16,i[1]&=65535,i[1]+=e[3]*t[1],i[0]+=i[1]>>>16,i[1]&=65535,i[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],i[0]&=65535,[i[0]<<16|i[1],i[2]<<16|i[3]]},x64Rotl:function(e,t){return t%=64,32===t?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])},x64LeftShift:function(e,t){return t%=64,0===t?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=this.x64Multiply(e,[4283543511,3981806797]),e=this.x64Xor(e,[0,e[0]>>>1]),e=this.x64Multiply(e,[3301882366,444984403]),e=this.x64Xor(e,[0,e[0]>>>1])},x64hash128:function(e,t){ e=e||"",t=t||0;for(var i=e.length%16,a=e.length-i,r=[0,t],n=[0,t],o=[0,0],s=[0,0],l=[2277735313,289559509],h=[1291169091,658871167],u=0;u>>0).toString(16)).slice(-8)+("00000000"+(r[1]>>>0).toString(16)).slice(-8)+("00000000"+(n[0]>>>0).toString(16)).slice(-8)+("00000000"+(n[1]>>>0).toString(16)).slice(-8)}},e.VERSION="1.5.1",e}); /* file /ui/app/js/_classes/access.controller.js , last updated 1643838862753*/ mar.accesscontroller = (function(){ let status = ""; function rv(status) { // if (status === "") setScenario_data("security","open"); // if (status === "warn") setScenario_data("security","submitted"); // if (status === "closed") setScenario_data("security","closed"); return status; } function get(raw) { /** * * closed -- YES -> [CLOSED] *0 (not implemented yet) * * submitted -- NO -> [OPEN] *1 * * Are we LO -- YES -> [WARN] *2 * * is page * special * and OPEN -- YES -> [OPEN] *3 * * else [CLOSED] *4 * * * */ if (typeof raw !== "boolean" || raw === false) { if (getScenario_data("over_security","") === "open") { return rv(""); } } if (MAR.appnav.loanWasSubmitted() === false) return rv(""); // *1 if (mar.WE_ARE_FROM_LOI === true) return rv("warn") // *2 if (typeof raw !== "boolean" || raw === false) { if (typeof mar.pg_accesscontrollerfn === "function") { if (mar.pg_accesscontrollerfn() === "open") return rv(""); // *3 } } return rv("closed"); } function comment() { mar.tmp_autosize = function() { autosize($("#comment-ta")); mar.tmp_autosize = function(){}; } elaineui.swalprompt({ title : "ADD INFORMATION", txt : `What information would you like to share with your Loan Officer?`, cls : "middleInfoPopup", //"midelinfopopupOneButton", ok : "send", okfn : async function() { let obj = { key : current.key, id : 0, appid : mar.ID, text : txt("#comment-ta") }; if (obj.text.trim().length > 0) { let rv = await mar.socket.send_and_receiveSync("app-comment-add",obj); load_comments(); } }, opts : { closeOnClickOutside : false, closeOnEsc : false }, cancel : "cancel", cancelfn : function() { } }); } async function loi_navigate() { } async function done(id) { let obj = { key : current.key, id : id, appid : mar.ID }; let rv = await mar.socket.send_and_receiveSync("app-comment-done",obj); load_comments(); } async function undone(id) { let obj = { key : current.key, id : id, appid : mar.ID }; let rv = await mar.socket.send_and_receiveSync("app-comment-undone",obj); load_comments(); } async function del(id) { let obj = { key : current.key, id : id, appid : mar.ID }; let rv = await mar.socket.send_and_receiveSync("app-comment-delete",obj); load_comments(); } async function get_comment_count(fn) { let obj = { key : "%", appid : mar.ID, statuses : [""] }; let rv = await mar.socket.send_and_receiveSync("app-comment-list",obj); let list = MAR.getOpt(rv, "data", []); if (fn) fn(list.length) return list.length; } let current = {}; async function load_comments() { let obj = { key : current.key, appid : mar.ID }; let rv = await mar.socket.send_and_receiveSync("app-comment-list",obj); let list = MAR.getOpt(rv, "data", []); let h = ""; for (let i=0; i < list.length; i++) { let item = list[i]; let clr = ""; let del = ""; if (mar.WE_ARE_FROM_LOI === true) { clr = `check_box_outline_blank`; if (item.status === "done") { clr = `done`; } } del = `delete`; if (mar.WE_ARE_FROM_LOI === true) { del = ""; } let classes = []; if (item.status === "done") { classes.push("done_cls"); } h += `
- ${item.data}${clr}${del}
`; } if (h !== "") { h = `Comments Entered:
${h}`; } $("#app-comments").html(h); } let hist = []; function getHist() { return hist; } function getCurrent() { if (hist.length > 0) { return hist[hist.length -1]; } return false; } function getLast() { if (hist.length > 1) { return hist[hist.length -2]; } return false; } async function blockpage(tags, pg) { hist.push(tags.join(".")); if (mar.WE_ARE_FROM_LOI === false) { if ("clpages" in mar.answers.v2.state === false) mar.answers.v2.state.clpages = {}; if (tags.join(".") in mar.answers.v2.state.clpages === false) { mar.answers.v2.state.clpages[tags.join(".")] = "Y"; } if (tags[0] in mar.answers.v2.state.clpages === false) { mar.answers.v2.state.clpages[tags[0]] = "Y"; } } let status = get(); let multiple = false; $("body").removeClass("body_dis_class"); if (status !== "") { let $container = $("#body-container"); if ($container.length === 0) { return; } let $content = $container.find("div.x_content"); if ($content.length === 0) { return; } let $er = $content.find("div.er"); if ($er.length === 0) { $er = $content.find(".accesslocked"); multiple = true; } if ($er.length === 0) { return; } current.tags = tags; current.key = tags.join("."); if (status === "closed") { if (!multiple) { $($er[0]).addClass("dis_class"); $("body").addClass("body_dis_class"); if ($(".dis_class_readonly").length === 0) { $($er[0]).before(`
This page is read only because the application has already been submitted. If the information is incorrect click here to send a message to your LO.
`); } load_comments(); } else { $($er).addClass("dis_class"); $("body").addClass("body_dis_class"); $($er).before(`
This page is read only because the application has already been submitted. If the information is incorrect click here to send a message to your LO.
`); load_comments(); } } if (status === "warn") { if ($(".dis_class_warning").length === 0) { $($er[0]).before(`
Only LO can make changes to submitted apps. Please check off the client comments.
`); } load_comments(); } } } function features() { let features = JSON.parse(JSON.stringify(mar.features)); if (mar.WE_ARE_FROM_LOI === true) { features.ratequote = true; } return features; } return { get : get, blockpage : blockpage, comment : comment, features : features, get_comment_count : get_comment_count, done : done, undone : undone, del : del, // getHist : getHist, hist : getHist, getLast : getLast, getCurrent : getCurrent, // loi_navigate : loi_navigate, ___id : "acces controller" }; })(); /* file /ui/app/js/pages.staticvars.js , last updated 1548889949244*/ mar.staticvars = { /** * progressive DB rates range */ startingrate : 4.5, rate_spread : 1.5, endingrate : (4.5 + 1.5), programmes : ["conv","fha"] } /* file /ui/app/js/pages.js , last updated 1708940763003*/ mar.pghelpers = (function(){ function callLoanOfficer() { let tel = loanofficer.tel; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.elaine("You can call me on this number: "+elaineui.telF(tel,tel),"").render()+""+ "" + "
"; swal({ className : "midelinfopopupOneButton", content : s, buttons : { ok : false, cancel : "cancel" } }); } return { callLoanOfficer : callLoanOfficer // call the loan officer } })(); mar.TODAYS_INTEREST = function() { return 0.0525; } mar.pg = {}; mar.pg["index"] = (function(){ var html = ""; function render(pg, localopts) { let hh = ""; hh += $("#page_index_video").html(); hh += ""; hh += ""; hh += " "; hh += " "; hh += ""; hh += " "; hh += " "; hh += " "; hh += " "; hh += " "; hh += " "; hh += " "; hh += " "; hh += "
About us
FAQ's
"; hh += "
"; hh += ""; hh += ""; var md = new MobileDetect(window.navigator.userAgent); var __md = (window.navigator.userAgent == "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3312.0 Safari/537.36"); var desktop = (!__md && !md.phone()); localopts.desktop = desktop; hh = Mustache.render(hh,localopts); pg.hh = hh; pg.render = true; pg.title = "Home"; pg.onrender = function() { //mar.openmenu_in_the_final_instance(); mvc.set("videointro","Y"); } } return { render : render } })() mar.pg["scenario_nav"] = (function(){ var html = ""; function render(pg, localopts) { let hh = ""; hh = "New scenario simple nav"; var md = new MobileDetect(window.navigator.userAgent); var __md = (window.navigator.userAgent == "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3312.0 Safari/537.36"); var desktop = (!__md && !md.phone()); localopts.desktop = desktop; hh = Mustache.render(hh,localopts); pg.hh = hh; pg.render = true; pg.title = "Home"; pg.onrender = function() { mvc.go("#scenario-timeframe.fromNav"); } } return { render : render } })() mar.pg["how-will-i-make-it"] = (function(){ var html = ""; function render(pg, localopts) { let h = ""; h += $("#page_index_video").html(); h += "I am not sure mate"; h += "Home"; h = Mustache.render(h,localopts); pg.hh = h; pg.render = true; pg.title = "Home" } return { render : render } })() mar.pg["500"] = (function(){ var html = ""; function render(pg, localopts) { let h = ""; h += "error 500"; h += "Home"; h = Mustache.render(h,localopts); pg.hh = h; pg.render = true; pg.title = "Home" } return { render : render } })() mar.pg["404"] = (function(){ var html = ""; function render(pg, localopts) { let h = ""; h += frm.htitle("Page not found").render(); h += "
"; h += frm.elaine("I am sorry , this page is not found or
{{p2}}.","").render(); h += "
"; // h += "

localopts

"; // h += `
${JSON.stringify(mar.ETAG,null,4)}
`; // h += "

localopts

"; // h += `
${JSON.stringify(localopts,null,4)}
`; // h += "

pg

"; // h += `
${JSON.stringify(pg,null,4)}
`; h += "
"; h += uihelpers.cbuttonbar("","","","","mar.help()"); h = Mustache.render(h,localopts); pg.hh = h; pg.render = true; pg.title = "Home" } return { render : render } })() mar.pg["404m"] = (function(){ var html = ""; function render(pg, localopts) { let h = ""; h += "
"; h += frm.elaine("
{{p2}}.","").render(); h += "
"; h += "
"; h += uihelpers.cbuttonbar("","","","","mar.help()"); h = Mustache.render(h,localopts); pg.hh = h; pg.render = true; pg.title = "Home" } return { render : render } })() mar.pg["scenario-loantype"] = (function(){ var html = ""; function render(pg, localopts) { let loan_type = getV2_data("loan_type","purchase"); let REFI = (loan_type != "purchase"); let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; let VAL = ""; let h = ""; h += frm.htitle("Loan Type").render(); h += frm.elaine("Are you looking to?","er").render(); h += "
"; VAL = loan_type; h += frm.radio("loan_type","",VAL,"","",function(){ oc(); },{ purchase : "Purchase", refinance : "Refinance" }).render(); h += "
"; h += "
"; // if from summary , then back // if not then not h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ let _v = radio("loan_type"); if (_v == "") { mar.tip(".help-button","warning","you need to select an option before continuing","top"); return false; } setScenario_data("loan_type",_v); setV2_data("loan_type",_v); setScenario_data("__scenario_loantype_passed","Y"); MAR.appnav.pageVerified("loantype","Y"); mar.fakesave(); mvc.go("#scenario-timeframe"); }),"Back",frm.addfunction(function(){ if ("scenario_summary" in mar.state) { mvc.go("#scenario-summary"); } else { mvc.go("#loanofficer"); // window.history.back(); } }),"mar.help()"); h = Mustache.render(h,localopts); mar.pg_changelistner = function() { let VAL = getScenario_data("loan_type_purchase_options",""); radio("timeframe",VAL); } let oc = function(){ let _v = radio("loan_type"); setScenario_data("loan_type",_v); setV2_data("loan_type",_v); mar.fakesave(); } let or = function(){ if (mvc.getEntryPageHash() && mvc.getEntryPageHash() != "" && mvc.entry_hash_used == false ) { mvc.entry_hash_used = true; mvc.go(mvc.getEntryPageHash()); return; } // let sp = mar.isallowed_scenario("#scenario-loantype"); // if (typeof sp === "string") { // mvc.go(sp); // return; // } // if (getScenario_data("visited_loantype","N") !== "Y") { // setScenario_data("visited_loantype","Y"); // mar.fakesave(); // mvc.go("#up-next-wishlist"); // return; // } $("#body-container").find(".xx-radio").myradio(); // var sc = getScenario_data("loan_type_purchase_options",false); // if (sc) radio("timeframe",sc); $("#body-container .xhuman").Humanize({ opts : {}, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "loantype" } })() mar.pg["scenario-timeframe"] = (function(){ var html = ""; function render(pg, localopts) { let loan_type = getV2_data("loan_type","purchase"); let loan_time = getScenario_data("loan_type_purchase_options","") let PURCHASE_AND_UNDER_CONTRACT = (loan_type == "purchase" && loan_time == "contract"); let REFI = (loan_type != "purchase"); let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; frm.reset(); let VAL = ""; let h = ""; let cd_src = getScenario_data(`est_closing_date_src`,``); let cd_by = getScenario_data(`est_closing_date_by`,``); let cd_val = getScenario_data(`est_closing_date`,``); if (cd_src === `enc`) { // just display only } if (loan_type !== "purchase") { h += frm.htitle("Purpose / Address").render(); h += frm.elaine("When do you want to close on your refi?","er").render(); h += (mar.accesscontroller.get() === "closed") ? "
" : "
"; h += frm.radio("timeframe","",VAL,"","",function(){ oc(); _set_default_closing_date(); },{ soon : "As soon as possible", three_months : "Not in a hurry", just_looking : "Just looking around" }).render(); h += "
"; if (mar.WE_ARE_FROM_LOI === true) { // est_closing_date_src can be enc for encompass // est_closing_date can be empty if (cd_src === `enc`) { h += "
"; h += `Closing date has been set at ${cd_val}`; } else if (cd_by === `clr`) { h += "
"; h += `Closing date has been set from the contract at ${cd_val}`; } else { h += (function() { let h = ""; h += "
"; VAL = getScenario_data(`est_closing_date_set`, `N`); h += frm.yn3("est_closing_date_set",`Would you like to set a closing date?`,VAL,"","",function(){ oc(); },{}).render(); h += (function() { let h = ""; h += "
"; h += "
Closing Date
"; VAL = getScenario_data(`est_closing_date`, MAR.get_estimated_closing_date()); h += frm.txt("est_closing_date","",VAL,"","",function(){ oc(); },'date').render(); h += "
"; return h; })().wrap("
","
"); return h; })().wrap("
","
"); } } else { if (cd_src === `enc`) { h += "
"; h += `Closing date has been set at ${cd_val}`; } else if (cd_by === `clr`) { h += "
"; h += `Closing date has been set from the contract at ${cd_val}`; } else if (cd_by === `lo`) { h += "
"; h += `Closing date has been set by your loan officer at ${cd_val}`; } else { h += (function() { let h = ""; h += "
"; VAL = getScenario_data(`est_closing_date_set`, `N`); h += frm.yn3("est_closing_date_set",`Would you like to set a closing date?`,VAL,"","",function(){ oc(); },{}).render(); h += (function() { let h = ""; h += "
"; h += "
Closing Date
"; VAL = getScenario_data(`est_closing_date`, MAR.get_estimated_closing_date()); h += frm.txt("est_closing_date","",VAL,"","",function(){ oc(); },'date').render(); h += "
"; return h; })().wrap("
","
"); return h; })().wrap("
","
"); } } let sp = MAR.reo.getOrCreateSubjectProperty(); let hr = frm.hr().render(); h += (function(){ let h = ""; VAL = MAR.getOpt(sp, "data.address",""); let leave_empty = (VAL === "") ? "Leave it blank if you dont want to enter the actual address right now" : ""; h += `
What is the address of the property you want to refinance? ${leave_empty}
`; h += frm.address_change("address","",VAL,"","",function(){ oc_address(); },{}).render() h += "
"; return h; })().wrap(`
${hr}`,"
"); } else { h += frm.htitle("Time frame").render(); h += frm.elaine("When are you looking to buy your home?","er").render(); h += (mar.accesscontroller.get() === "closed") ? "
" : "
"; h += frm.radio("timeframe","I am:",VAL,"","",function(){ oc(); if (mar.WE_ARE_FROM_LOI === true) { _set_default_closing_date(); } },{ contract : "Under Contract", soon : "Planning to put an offer on a property I have found", one_month : "Still looking, but want to buy fast", three_months : "Closing in the next few months", just_looking : "Just checking out my options" }).render(); h += "
"; if (mar.WE_ARE_FROM_LOI === true) { // est_closing_date_src can be enc for encompass // est_closing_date can be empty if (cd_src === `enc`) { h += "
"; h += `Closing date has been set at ${cd_val}`; } else if (cd_by === `clr`) { h += "
"; h += `Closing date has been set from the contract at ${cd_val}`; } else { h += (function() { let h = ""; h += "
"; VAL = getScenario_data(`est_closing_date_set`, `N`); h += frm.yn3("est_closing_date_set",`Would you like to set a closing date?`,VAL,"","",function(){ oc(); },{}).render(); h += (function() { let h = ""; h += "
"; h += "
Closing Date
"; VAL = getScenario_data(`est_closing_date`, MAR.get_estimated_closing_date()); h += frm.txt("est_closing_date","",VAL,"","",function(){ oc(); },'date').render(); h += "
"; return h; })().wrap("
","
"); return h; })().wrap("
","
"); } } else { if (cd_src === `enc`) { h += "
"; h += `Closing date has been set at ${cd_val}`; } else if (cd_by === `clr`) { h += "
"; h += `Closing date has been set from the contract at ${cd_val}`; } else if (cd_by === `lo`) { h += "
"; h += `Closing date has been set by your loan officer at ${cd_val}`; } else { h += (function() { let h = ""; h += "
"; VAL = getScenario_data(`est_closing_date_set`, `N`); h += frm.yn3("est_closing_date_set",`Would you like to set a closing date?`,VAL,"","",function(){ oc(); },{}).render(); h += (function() { let h = ""; h += "
"; h += "
Closing Date
"; VAL = getScenario_data(`est_closing_date`, MAR.get_estimated_closing_date()); h += frm.txt("est_closing_date","",VAL,"","",function(){ oc(); },'date').render(); h += "
"; return h; })().wrap("
","
"); return h; })().wrap("
","
"); } } } h += "
"; if (mar.WE_ARE_FROM_LOI === true) { VAL = (loan_type !== "purchase") ? "refi" : "purchase"; h += frm.radio("switchto","Switch to:",VAL,"","",function(){ let v = radio("switchto"); if (MAR.application.isPurchase() && v === "refi") { elaineui.swalprompt({ title : "Please confirm", txt : "Are you sure you want to switch this loan to a refi

", ok : "yes", okfn : function(){ MAR.application.purchase_to_refi(); frm.buttons.hide(function(){ mar.fakesave(function(rv){ if (rv === false) { swal("There is an error saving these changes, please check if your connection is good."); radio("switchto","purchase"); } else { setTimeout(function(){ location.reload(); },1000); } // mvc.go("#scenario-timeframe"); }); }); }, cls : "middleInfoPopup", cancel : "no", cancelfn : function(){ radio("switchto","purchase"); }, reverse : false }) } if (MAR.application.isRefi() && v === "purchase") { elaineui.swalprompt({ title : "Please confirm", txt : "Are you sure you want to switch this loan to a purchase

", ok : "yes", okfn : function(){ MAR.application.refi_to_purchase(); frm.buttons.hide(function(){ mar.fakesave(function(rv){ if (rv === false) { swal("There is an error saving these changes, please check if your connection is good."); radio("switchto","refi"); } else { setTimeout(function(){ location.reload(); },1000); } // mvc.go("#scenario-timeframe"); }); }); }, cls : "middleInfoPopup", cancel : "no", cancelfn : function(){ radio("switchto","refi"); }, reverse : false }) } },{ purchase : "Purchase", refi : "Refi" }).render(); } // if from summary , then back // if not then not h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ frm.buttons.hide(); setTimeout(async function(){ let _v = radio("timeframe"); if (_v == "") { mar.tip(".help-button","warning","you need to select an option before continuing","top"); frm.buttons.show(); return false; } /** * refi , look up address details! */ if (loan_type !== "purchase") { let address = txt("#address"); if (address.trim().length === 0) { // mar.tip(".help-button","warning","you need to enter the address of the subject property before continuing","top"); // frm.buttons.show(); // return false; } else { $("#body-container").LoadingOverlay("show", { image : "", custom : `
`+ `

`+ `Downloading public records data for this address
`+ `This can take up to 30 seconds.
` }); await oc_address(); $("#body-container").LoadingOverlay("hide",true); let ba = $(".bad-address"); if (ba.length > 0) { mar.tip(".help-button","warning",ba.html(),"top"); frm.buttons.show(); return false; } let adr = oc_address_selected; if (Array.isArray(adr)) { adr = adr[0]; } let sp = MAR.reo.getOrCreateSubjectProperty(); let sp_obj = {}; let over = false; (function upate_address(){ let v = MAR.getOpt(sp, "data.address",""); v = ""; if (v === "" || (over && v !== address)) { sp_obj.address = address; } })(); let skip_propogation_of_lookedup_data = false; if (MAR.appnav.loanWasImportedAndNotVerified() === true) { skip_propogation_of_lookedup_data = true; } if (skip_propogation_of_lookedup_data !== true) { (function update_purchasedate(){ let a = MAR.getOpt(adr, "purchasedate", ""); if (!a || a === "") return; let v = MAR.getOpt(sp, "data.purchasedate",""); if (v === "" || (over && v !== a)) { sp_obj.purchasedate = a; } })(); (function update_purchaseprice(){ let a = MAR.getOpt(adr, "purchaseprice", ""); if (!a || a === "" || num(a) === 0) return; let v = MAR.getOpt(sp, "data.purchaseprice",""); if (v === "" || (over && num(v) !== num(a))) { sp_obj.purchaseprice = num(a); } })(); (function update_year_built(){ let a = MAR.getOpt(adr, "year_built", ""); if (!a || a === "" || num(a) === 0) return; let v = getScenario_data("build_period",""); if (v === "" || (over && num(v) !== num(a))) { setScenario_data("build_period",num(a)); } })(); (function update_value(){ let a = MAR.getOpt(adr, "value", ""); if (!a || a === "" || num(a) === 0) return; let v = getScenario_data("refi_current_value",""); if (v === "" || (over && num(v) !== num(a))) { setScenario_data("refi_current_value",num(a)); sp_obj.value = num(a); } })(); (function update_loan_amount(){ let a = MAR.getOpt(adr, "loan_amount", ""); if (!a || a === "" || num(a) === 0) return; let v = getScenario_data("refi_current_debt",""); if (v === "" || (over && num(v) !== num(a))) { setScenario_data("refi_current_debt",num(a)); } })(); (function update_tax(){ let a = MAR.getOpt(adr, "tax", ""); if (!a || a === "" || num(a) === 0) return; let v = getScenario_data("refi_taxes",""); if (v === "" || (over && num(v) !== num(a))) { setScenario_data("refi_taxes",num(a)); } v = MAR.getOpt(sp, "data.loan_tax",""); if (v === "" || (over && num(v) !== num(a))) { sp_obj.loan_tax = num(a); } })(); (function update_type(){ let a = MAR.getOpt(adr, "type", ""); if (!a || a === "") return; let v = getScenario_data("property_type",""); if (v === "" || (over && v !== a)) { setScenario_data("property_type",a); } v = MAR.getOpt(sp, "data.property_type",""); if (v === "" || (over && v !== a)) { sp_obj.property_type = a; } })(); } MAR.reo.setByUUID(sp.data.uuid, sp_obj); await MAR.reo.makePropertyTheSubjectUnverifiedSync(); } // loan_duedate // loan_type // lender_name } if ($(`#est_closing_date_set`).length > 0) { setScenario_data("est_closing_date_set", yn3(`#est_closing_date_set`)); if (yn3(`#est_closing_date_set`) === `Y`) { setScenario_data("est_closing_date_src", `app`); setScenario_data("est_closing_set",`Y`); setScenario_data("est_closing_date",txt(`#est_closing_date`)); if (mar.WE_ARE_FROM_LOI === true) { setScenario_data("est_closing_date_by",`lo`); } else { setScenario_data("est_closing_date_by",`cli`); } } else { setScenario_data("est_closing_date_src", ``); setScenario_data("est_closing_set",`N`); setScenario_data("est_closing_date",``); setScenario_data("est_closing_date_by",``); } } setScenario_data("loan_type_purchase_options",_v); setScenario_data("__scenario_timeframe_passed","Y"); MAR.appnav.pageVerified("timeframe","Y"); mar.fakesave(function(){ let refi = (getV2_data("loan_type","purchase") !== "purchase"); let refi_addr = false; /* refi has entered an address */ if (refi) { let sp = MAR.reo.getSubjectProperty(); if (sp !== false && MAR.getOpt(sp, "data.address", "") !== "") { refi_addr = MAR.getOpt(sp, "data.address", false); } } if (refi_addr === false) { // mvc.go("#scenario-location.0"); mvc.go("#scenario-occupancy.0"); } else { // here setScenario_data("__scenario_location_passed","Y"); mvc.go("#scenario-occupancy.0"); } // mvc.go("#scenario-creditscore.0"); }); },1); }),"Back",frm.addfunction(function(){ frm.buttons.hide(); setTimeout(function(){ if ("scenario_summary" in mar.state) { mvc.go("#scenario-summary"); } else { if (getScenario_data("__scenario_timeframe_passed","N") !== "Y") { if (mar.WE_ARE_FROM_LOI === false) { mvc.go("#scenario-loantype"); return; } } mvc.go("#loanofficer"); // window.history.back(); } },1); }),"mar.help()"); h = Mustache.render(h,localopts); mar.pg_changelistner = function() { let VAL = getScenario_data("loan_type_purchase_options",""); radio("timeframe",VAL); } let oc_address_selected = false; let oc_address = async function(fn) { oc_address_selected = false; let address = txt("#address"); if (address.trim().length === 0) { return; } let da = await MAR.api.lookup_address_detailsSync(address); let $elm = $("#refi_address_error"); $elm.html(""); if (da === false) { let h = ""; h = ("There is no address matching, can you change the address please.").wrap("",""); $elm.html(h) if (fn) fn(); return; } if (da.error === true) { let h = ""; h = ("There is was an error accessing information about this property.").wrap("",""); $elm.html(h) oc_address_selected = {}; if (fn) fn(); return; } let sug_cnt = MAR.getOpt(da, "sug_cnt", false); let sugs = MAR.getOpt(da, "sug", []); if (sug_cnt !== false) { let h = ""; if (sug_cnt === 0) { // h = ("There is no address matching, can you change the address please.").wrap("",""); } else { h = ("There are multiple addresses matching this. You probably missed Apt, Suite or someting else.").wrap("",""); h += `
Suggestions include:
`; let ca = []; for (let i=0; i < sugs.length; i++) { let sug = sugs[i]; let ca_key = `${sug.street_line}_${sug.secondary}`; if (ca.indexOf(ca_key)> -1) continue; ca.push(ca_key); h += `
`; h += `${sug.street_line} `; if (sug.secondaries.length > 0) { h += sug.secondaries.join(", "); } h += `
`; } } $elm.html(h) } console.warn(da); oc_address_selected = da; if (fn) fn(); } let _set_default_closing_date = function() { // if (mar.WE_ARE_FROM_LOI === true) { let Original_val = getScenario_data(`est_closing_date_set`, `N`); let _set = yn3(`#est_closing_date_set`); if (Original_val === `N` && _set === `Y`) { txt(`#est_closing_date`,MAR.get_estimated_closing_date()); } // } } let oc = function(){ let _v = radio("timeframe"); setScenario_data("loan_type_purchase_options",_v); if (mar.WE_ARE_FROM_LOI === true) { let timeframe = radio(`timeframe`); if (timeframe === ``) { $(`#est_closing_date_div_div`).addClass(`x-hide`); } else { $(`#est_closing_date_div_div`).removeClass(`x-hide`); } } if (mar.WE_ARE_FROM_LOI === false) { let timeframe = radio(`timeframe`); if (timeframe === `contract`) { $(`#est_closing_date_div_div`).removeClass(`x-hide`); } else if (timeframe === `soon`) { $(`#est_closing_date_div_div`).removeClass(`x-hide`); } else { $(`#est_closing_date_div_div`).addClass(`x-hide`); } } let _set = yn3(`#est_closing_date_set`); if (_set !== `Y`) { $(`#est_closing_date_div`).addClass(`x-hide`); txt(`#est_closing_date`,``); } else { $(`#est_closing_date_div`).removeClass(`x-hide`); if (txt(`#est_closing_date`) === ``) { _set_default_closing_date(); } } mar.fakesave(); } let or = function(){ frm.buttons.hide(); if (mvc.getEntryPageHash() && mvc.getEntryPageHash() != "" && mvc.entry_hash_used == false ) { mvc.entry_hash_used = true; mvc.go(mvc.getEntryPageHash()); return; } let sp = mar.isallowed_scenario("#scenario-timeframe"); if (typeof sp === "string") { mvc.go(sp); return; } let visited_loantype = getScenario_data("__scenario_loantype_passed","N"); if (visited_loantype !== "Y") { if (mar.WE_ARE_FROM_LOI === false) { mvc.go("#scenario-loantype"); return; } } let use_whatsapp = getScenario_data("use_whatsapp",""); let passed_whatsapp = getScenario_data("__scenario_whatsapp_passed","N"); if (use_whatsapp === "" || passed_whatsapp !== "Y") { if (mar.WE_ARE_FROM_LOI === false) { mvc.go("#scenario-whatsapp"); return; } } if (getScenario_data("visited_timeframe","N") !== "Y") { setScenario_data("visited_timeframe","Y"); mar.fakesave(); mvc.go("#up-next-wishlist"); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check3").mycheck3(); var sc = getScenario_data("loan_type_purchase_options",false); if (sc) radio("timeframe",sc); if ($("#body-container").find("#address-disp").length > 0) { let state = getScenario_data("shotgun_state", ""); uihelpers.addresspopup_init($("#body-container").find("#address-disp"),state); } $("#body-container .xhuman").Humanize({ opts : { fn : function() { frm.buttons.show(); oc(); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "timeframe" } })() mar.pg["scenario-location"] = (function(){ var html = ""; function render(pg, localopts) { let VAL = ""; let location = getScenario_data("property_county",""); let refi = (getV2_data("loan_type","purchase") !== "purchase"); let refi_addr = false; /* refi has entered an address */ var use = getScenario_data("occupancy_type",""); if (refi) { let sp = MAR.reo.getSubjectProperty(); if (sp !== false && MAR.getOpt(sp, "data.address", "") !== "") { refi_addr = MAR.getOpt(sp, "data.address", false); } } let h = ""; h += frm.htitle("Location").render(); if (refi) { if (refi_addr !== false) { h += frm.elaine("Property address?","er").render(); } else { h += frm.elaine("In what county is your property?","er").render(); } } else { h += frm.elaine("In what county are you looking to buy?","er").render(); } h += "
"; VAL = location; if (refi) { if (refi_addr !== false) { h += `Your address is ${refi_addr}`; } else { h += frm.txt("Location","My property is in:",VAL,"e.g. Broward County","county-lookup",function(){ }).render(); } } else { h += frm.txt("Location","I'm looking for property in:",VAL,"e.g. Broward County","county-lookup",function(){ }).render(); } h += "
"; h += "
"; h += "
"; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (refi && refi_addr !== false) { mvc.go("#scenario-occupancy"); return; } let loc = txt("#Location"); if (loc == "") { mar.tip(".help-button","warning","you need to select a location before continuing","top"); return false; } setScenario_data("property_county",loc); // https://lo.durunner.ai/calc/lookup_states_FHA?county=01003 // maxloan_u1 // : // "453100" // maxloan_u2 // : // "580150" // maxloan_u3 // : // "701250" // maxloan_u4 // : // "871450" frm.buttons.hide(function(){ let cp = mvc.currentpage; // }); // // // // // $.get("/calc/lookup_states?county="+getCounty_v2(loc), function(d) { // debugger; // if (d && "outputs" in d) { // setScenario_data("property_county_limits_conv",d.outputs); // } // $.get("/calc/lookup_states_FHA?county="+getCounty_v2(loc), function(d1) { // if (d1 && "outputs" in d1) { // setScenario_data("property_county_limits_fha",d1.outputs); // } // $.get("/calc/lookup_HOI_counties?county="+getCounty_v2(loc), function(d2) { // if (d2 && "outputs" in d2) { // setScenario_data("property_county_matrix",d2.outputs); // } debugger; mar.socket.send_and_receive("api-app-lookupstates",{ county : getCounty_v2(loc) }, function(d){ if (d && "data" in d) { setScenario_data("property_county_limits_conv",d.data); } mar.socket.send_and_receive("api-app-lookupstatesFHA",{ county : getCounty_v2(loc) }, function(d1){ if (d1 && "data" in d1) { setScenario_data("property_county_limits_fha",d1.data); } mar.socket.send_and_receive("api-app-looku-hoi-counties",{ county : getCounty_v2(loc) }, function(d2){ if (d2 && "data" in d2) { setScenario_data("property_county_matrix",d2.data); } setScenario_data("__scenario_location_passed","Y"); mar.fakesave(function(){ if (mvc.currentpage === cp) { mvc.go("#scenario-property"); // mvc.go("#scenario-occupancy"); } }); },10000); },10000); },10000); }); }),"Back",frm.addfunction(function(){ mvc.go(`#scenario-occupancy`); // mvc.go(`#scenario-timeframe`); // let borrowercount = "0"; //getScenario_data("__scenario_borrowers_num","1"); // if (getScenario_data("is_there_a_second_borrower","N") === "Y") borrowercount = "1"; // if (getScenario_data("is_there_a_third_borrower","N") === "Y") borrowercount = "2"; // for (let i=0; i < MAR.MAXBORROWERS; i++) { // if (getScenario_data(`is_there_a_${MAR.th(i)}_borrower`,"N") === "Y") borrowercount = `${i}`; // } // mvc.go(`#scenario-borrowers.${borrowercount}`); }),"mar.help()"); h = Mustache.render(h,localopts); let or = function(){ let sp = mar.isallowed_scenario("#scenario-location"); if (typeof sp === "string") { mvc.go(sp); return; } if (refi && refi_addr !== false) { mvc.go("#scenario-property"); // mvc.go("#scenario-timeframe"); return; } if (getScenario_data("__scenario_location_passed","") !== "Y") { if (refi) { setScenario_data("__scenario_location_passed","Y"); if (refi_addr !== false) { mvc.go("#scenario-occupancy"); return; } } // skip for purchase also // setScenario_data("__scenario_location_passed","Y"); // mvc.go("#scenario-occupancy"); // return; } $("#body-container").find(".xx-radio").myradio(); $.get("/cfc/adminuserspublic/"+loanofficer.id+"?fmt=explode",function(data) { let licenses = MAR.getOpt(data, "0.licenses", {}); if ("FL" in licenses === false) { licenses.FL = "Y" } let state = getScenario_data("shotgun_state", ""); if (state !== "") { state = MAR.stateCode(state, true).toUpperCase(); // convert FL -> Florida } $("#body-container .county-lookup").autocomplete({ minLength : 0, appendTo : "#body-container .x_content", source : mar.counties.filter(function(a) { let state_name = a.split(":")[0].split("|")[1].trim(); // "1011|FLORIDA : Bla county" -> FLORIDA let state_code = MAR.stateCode(state_name); // "FLORIDA" -> FL if (state_code === "") { return false; // no blank state codes } if (use !== "occupancy_investment" && state_code in licenses === false) { return false; // not licensed } if (use === "occupancy_investment") { return true; } if (state === "") { return true; } return (a.indexOf(`|${state} :`) > -1); }), change: function(event, ui) { if (ui.item == null) { $("#body-container .county-lookup").val(""); $("#body-container .county-lookup").focus(); } } }).bind('focus', function(){ if (txt("#body-container .county-lookup").trim().length == 0) { $(this).autocomplete("search"); } }); // $("#body-container #other_description").autocomplete({ // change: function(event, ui) { // if (ui.item == null) { // $("#other_description").val(""); // $("#other_description").focus(); // } // } // }).bind('focus', function(){ // if (txt("#other_description").trim().length == 0) { // $(this).autocomplete("search"); // } // }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { } }, quick : false, }); }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "property" } })() mar.pg["scenario-creditscore"] = (function(){ var html = ""; function render(pg, localopts) { /* * placeholder : (optional) default: '' -- standard placeholder param for an input field * mod_val : (very very optional) is a modifier for the displayed value. Handy if you want to multiply the value by an amount * v00 : beginning 'leftmost' value * v50, v75, v100 : middle value, value at 75%, value at 100% * v50_inc, v75_inc, v100_inc : incremental value from 0-50, 50-75, and 75-100 * start_val : force slider to start at a particular value. Overridden if there is value "pushed in" from DB * maxlength : (very optional) default: 12 -- standard max length param for an input field * cellType : (very optional) default: slider-money-cell -- there are different celltypes for displaying the numbers another type is slider-smallNum-cell (usually a max of 5 characters or less) */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var sc = getScenario_data("applicant"+applicantNum+"_cscore",false); var cr = getScenario_data("applicant"+applicantNum+"_cscore_ref",""); var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let VAL = "750"; let h = ""; h += frm.htitle("Credit Score").render(); if (cr !== "" && num(sc) > 0) { if (applicantnum == 0) { h += frm.elaine(`The mid score of your credit shows the following.`,"er").render(); } else { h += frm.elaine(`The mid score of ${na} credit shows the following.`,"er").render(); } h += "
"; h += `
`; h += "
" // h += "
"; // h += sc; // h += "
" } else { if (applicantnum == 0) { h += frm.elaine("Alright, "+na+" let's make an estimate of your credit score before we start.","er").render(); } else { h += frm.elaine(n0+", can you tell us about "+na+"'s credit score?","er").render(); } if (sc) VAL = sc; //trafficlight h += "
"; if (applicantnum == 0) { h += frm.slider("cscore","My credit score is around:",VAL,"","",function(){ oc(); }, { placeholder :'eg:621', mod_val : '10', v00 : '460', v50 : '620', v50_inc : '5', v75 : '700', v75_inc : '5', v100 : '850', v100_inc : '5', start_val : (sc) ? ""+(sc/10) : '76', maxlength : '12', cellType : "slider-smallNum-cell" }).render(); } else { h += frm.slider("cscore",na+"'s credit score is around:",VAL,"","",function(){ oc(); }, { placeholder :'eg:621', mod_val : '10', v00 : '460', v50 : '620', v50_inc : '5', v75 : '700', v75_inc : '5', v100 : '850', v100_inc : '5', start_val : (sc) ? ""+(sc/10) : '76', maxlength : '12', cellType : "slider-smallNum-cell" }).render(); } h += "
"; h += "
"; h += "
"; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (cr !== "" && num(sc) > 0) { MAR.appnav.pageVerified(`creditscore.${applicantnum}`,"Y"); MAR.application.setCreditScore(applicantnum,sc); mar.fakesave(); mvc.go("#scenario-pastproperty."+applicantnum); // mvc.go("#scenario-housingbudget."+applicantnum); return; } let _v = txt("#cscore"); if (_v == "") { mar.tip(".help-button","warning","you need to enter your credit score","top"); return false; } MAR.application.setCreditScore(applicantnum,_v); MAR.appnav.pageVerified(`creditscore.${applicantnum}`,"Y"); // setScenario_data("applicant"+applicantNum+"_cscore",_v); // setScenario_data("__scenario_creditscore_"+applicantnum+"_passed","Y"); mar.fakesave(); // mvc.go("#scenario-housingbudget."+applicantnum); mvc.go("#scenario-pastproperty."+applicantnum); }),"Back",frm.addfunction(function(){ if (applicantnum > 0) { mvc.go("#scenario-borrower."+applicantnum); } else { mvc.go("#scenario-property"); } // if (applicantnum == 0) { // mvc.go("#scenario-timeframe"); // } else { // mvc.go("#scenario-borrower."+applicantnum); // // } }),"mar.help()"); h = Mustache.render(h,localopts); let drawcreditscore = function(n) { let cw = $("#_myCanvas").width(); let gw = cw * 0.65; let gr = (gw/2); // radius if ($("#myCanvas").length == 0) { $("#_myCanvas").append(``); } // thaanks to https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_canvas_arc let start = 0.9; //0.8 let end = 2.1; //2.2 let startv = 300; let endv = 850; let prc = ((n - startv)/(endv-startv)); let endx = ((end - start) * prc) + start; //$("#myCanvas").css("height",`${cw}px`); let fact = 0.69; //0.83; let spread = 0.40; //0.22 let lineW = 18; let tx = ""; if (n < 580) tx = "Very weak"; else if (n < 620) tx = "Weak"; else if (n < 670) tx = "Fair"; else if (n < 720) tx = "Good"; else tx = "Excellent"; var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); var gradient = ctx.createLinearGradient(0, 0, 170, 0); gradient.addColorStop("0", "#cccccc"); gradient.addColorStop("0.5" ,"#cdcdcd"); gradient.addColorStop("1.0", "#dcdcdc"); var gradient1 = ctx.createLinearGradient(0, 0, 170, 0); gradient1.addColorStop("0", "#90C33A"); gradient1.addColorStop("0.5" ,"#80D32A"); gradient1.addColorStop("1.0", "#90C33A"); ctx.beginPath(); ctx.arc((cw/2), 10+gr, gr, start*Math.PI, end * Math.PI); ctx.strokeStyle = gradient; ctx.lineWidth = lineW; ctx.stroke(); ctx.beginPath(); ctx.arc((cw/2), 10+gr, gr, start*Math.PI, endx * Math.PI); ctx.strokeStyle = gradient1; ctx.lineWidth = lineW; ctx.stroke(); ctx.beginPath(); ctx.fillStyle = "#ffffff" ctx.fillRect(0, gw*fact, cw, 20); ctx.font = "16px Open Sans"; ctx.fillStyle = "#333333"; ctx.textAlign = "center"; ctx.fillText(`${startv}`, (cw/2) - (gr/2) - (gr*spread), (gw*fact)+20); ctx.fillText(`${endv}`, (cw/2) + (gr/2) + (gr*spread), (gw*fact)+20); // ctx.fillText(` ${n} ${gw} ${cw} `, 10, 50); ctx.font = "56px Open Sans"; ctx.fillText(`${n}`, (cw/2), (cw*0.33)); ctx.font = "16px Open Sans"; ctx.fillText(`${tx}`, (cw/2),(gw*fact)); let X_End = (cw/2) + gr * Math.cos(endx*Math.PI); let Y_End = (10+gr) + gr * Math.sin(endx*Math.PI); ctx.beginPath(); ctx.arc(X_End, Y_End, lineW*0.7, 0, 2*Math.PI); ctx.fillStyle = "#ffffff"; ctx.fill(); ctx.lineWidth = 1; ctx.strokeStyle = "#cccccc"; ctx.stroke(); } mar.pg_changelistner = function() { let _VAL = getScenario_data("applicant"+applicantNum+"_cscore",false); txt("#cscore",_VAL); $("#cscore").change(); } let replaceborrower = function(){ mar.socket.send_and_receive("replace-first-borrower",{ appid : mar.ID }, function(retval){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Conformation").render() + "Are you sure you want to delete yourself, you won't be able to return to this application ? "; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "No", call : { text: "Delete myself", value: "del", closeModal: false } } }) .then((act) => { if (act == "del") { let url = MAR.getOpt(retval,"data.url"); document.location.href = url; } }); },10000); } let oc = function() { if (cr !== "") { return; } let _v = txt("#cscore"); if (cr !== "") _v = sc; if (_v < 580) { if ($(".er1").length == 0) { let vv = ""; vv += frm.hr().render(); if (applicantnum == 0) { h += "
"; vv += frm.elaine("With this credit score, it is very hard to get a loan approval. " + "If you were planning on adding more borrowers, " + "that have a higher score and sufficient stable income you may want to take yourself off the loan.","er1").render(); vv += "
"; vv += frm.h2("
Tip: If someone has no income or suffucient credit, there is no point in adding them to the loan. You can however add them as owners to the title.
").render(); vv += frm.but("REPLACE ME WITH A NEW APPLICANT",function(){ replaceborrower(); // swal("no function yet"); }).render(); } else { vv += frm.elaine("With this credit score it is very difficult to get "+na+" approved for the loan. " + "It may be smart to take "+na+" off the loan and replace them with someone with a better score, " + "even if they don't live there. Alternatively you can work on raising your credit score " + "and try again in a few months.","er1").render(); vv += "
"; vv += frm.h2("
Tip: If someone has no income or suffucient credit, there is no point in adding them to the loan. You can however add them as owners to the title.
").render(); vv += frm.but("REMOVE THIS APPLICANT",function(){ replaceborrower(); // swal("no function yet"); }).render(); } vv += ""; $("#repair-div").html(vv); $("#repair-div .xhuman").Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false, }); } } else if (_v < 620) { let vv = ""; if ($(".er2").length == 0) { vv += frm.hr().render(); if (applicantnum == 0) { vv += frm.elaine("With this credit score, you need compensating factors to close. " + "For example, you will need 3 months of financial reserves after closing. " + "Be aware it may be tricky to get you in your dream home, but let’s try!","er2").render(); } else { vv += frm.elaine("With this credit score, "+na+" will need compensating factors to close. " + "For example, you jointly will need three months of financial reserves after closing. " + "The underwriters always approve files based on the weakest borrower. " + "In some cases it may be favorable to remove the weakest borrowers off the loan. " + "I will have to review the actual credit report and income data, " + "to calculate what would work best for you guys.","er2").render(); vv += frm.h2("
Tip: You can be an owner of a property on the title, without being on the loan.
").render(); } vv += "
"; vv += ""; $("#repair-div").html(vv); setTimeout(function() { $("#repair-div .xhuman").Humanize({ opts : { fn : function() { } }, quick : false, }); },0); } } else { $("#repair-div").html(""); } setScenario_data("applicant"+applicantNum+"_cscore",_v); mar.fakesave(); } let or = function(){ let sp = mar.isallowed_scenario("#scenario-creditscore."+applicantnum); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { $("#body-container .xx-slider").myslider(); if (cr !== "" && num(sc) > 0) { drawcreditscore(sc); } oc(); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } function ispassed(applicantnum) { let applicantNum = applicantnum+1; let sc = getScenario_data("applicant"+applicantNum+"_cscore",false); return ( getScenario_data("applicant"+applicantNum+"_cscore",false) !== false); } return { render : render, ispassed : ispassed } })() mar.pg["scenario-property"] = (function(){ var html = ""; function render(pg, localopts) { let VAL = ""; let refi = (getV2_data("loan_type","purchase") !== "purchase"); var property_type = getScenario_data("property_type",""); var property_type_other = getScenario_data("property_type_other",""); var monthly_rent = getScenario_data("monthly_rent","0"); var householdsize = getScenario_data("householdsize",""); var householdincome = getScenario_data("householdincome",""); if (monthly_rent == "") monthly_rent = 0; let h = ""; h += frm.htitle("Property type").render(); if (refi) { h += frm.elaine("What type of property are you refinancing?","er").render(); } else { h += frm.elaine("What type of property are you looking for?","er").render(); } h += "
"; VAL = property_type; h += frm.radio("property_type","",VAL,"","",function(){ oc(); },{ sfr : mar.txt._sfr, condo : mar.txt._condo, duplex : mar.txt._duplex, triplex : mar.txt._triplex, fourplex : mar.txt._fourplex, other : mar.txt._other }).render(); VAL = property_type_other; h += "
" h += frm.txt("timeframe_other","",VAL,"e.g. Fiveplex",function(){}).render(); h += "
"; h += "
"; h += frm.hr().render(); h += frm.elaine("How much rental income do you expect from this purchase?","er1").render(); h += "
"; VAL = monthly_rent; let LBL = "Estimated monthly income:"; if (refi) { LBL = "Monthly income:" } h += frm.slider("monthly_rent",LBL,VAL,"","",function(){ oc(); }, { placeholder :'', formatting_class : "_dollars", v00 : '0', v50 : '2000', v50_inc : '100', v75 : '4000', v75_inc : '100', v100 : '25000', v100_inc : '250', start_val : '100' }).render(); h += "
"; h += "
"; h += "
"; let is_rental_income_visible = false; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var property_type = radio("property_type"); var property_type_other = txt("#property_type_other"); var monthly_rent = txt("#monthly_rent"); var use = getScenario_data("occupancy_type",""); if (is_rental_income_visible === false) { monthly_rent = 0; } if (property_type === "duplex" || property_type === "triplex" || property_type === "fourplex") { if (use === "occupancy_secondhom") { setScenario_data("occupancy_type","occupancy_investment"); } } setScenario_data("property_type",property_type); setScenario_data("property_type_other",property_type_other); setScenario_data("monthly_rent",monthly_rent); setScenario_data("__scenario_"+"property"+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-creditscore.0"); }),"Back",frm.addfunction(function(){ if (refi) { mvc.go("#scenario-location"); // back from property } else { mvc.go("#scenario-occupancy"); // back from property } }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(){ var property_type = radio("property_type"); var property_type_other = txt("#property_type_other"); var monthly_rent = txt("#monthly_rent"); var use = getScenario_data("occupancy_type",""); var occupancy_type = use; if (property_type != "") { setScenario_data("property_type",property_type); setScenario_data("property_type_other",property_type_other); setScenario_data("monthly_rent",monthly_rent); mar.fakesave(); var _monthly_rent_display = "" if ((property_type != "" && property_type != "sfr" && property_type != "condo") || occupancy_type == "occupancy_investment") { if (occupancy_type == "occupancy_investment") { /** * investment property */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("What total monthly rental income do you make from this investment property"); } else { $(".property_income").html("What total monthly rental income do you expect from this investment property"); } } else { if (property_type == "condo") { /** * non investment - condo */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("What income do you make from the 2nd unit"); } else { $(".property_income").html("What income do you expect from the 2nd unit"); } } else if (property_type == "duplex") { /** * non investment - duplex */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("What income do you make from the 2nd unit"); } else { $(".property_income").html("What income do you expect from the 2nd unit"); } } else if (property_type == "triplex") { /** * non investment - triplex */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("What income do you make from the 2nd & 3rd units combined"); } else { $(".property_income").html("What income do you expect from the 2nd & 3rd units combined"); } } else if (property_type == "fourplex") { /** * non investment - fourplex */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("What income do you make from the 2nd,3rd & 4th units combined"); } else { $(".property_income").html("What income do you expect from the 2nd,3rd & 4th units combined"); } } else { /** * non investment - other */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("If you make rental income please enter it here"); } else { $(".property_income").html("If you expect rental income please enter it here"); } } } } setTimeout(function(){ if (use != "occupancy_investment" && (property_type == "sfr" || property_type == "condo")) { $("#rental-div").css("display","none"); $("#rental-div .er1").css("display","none"); is_rental_income_visible = false; } else { if ($("#rental-div .er1").css("display") == "none") { $("#rental-div").css("display","block"); $("#mccincome-div").css("display","none"); is_rental_income_visible = true; $($("#rental-div .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false, }); } } $("#body-container").scrollTo("max",200); },1); } else { $("#rental-div").css("display","none"); $("#mccincome-div").css("display","none"); is_rental_income_visible = false; } } let or = function(){ let sp = mar.isallowed_scenario("#scenario-property"); if (typeof sp === "string") { mvc.go(sp); return; } let passed = (getScenario_data("__scenario_property_passed","") === "Y"); // if (refi) { // setScenario_data("__scenario_property_passed","Y"); // mar.fakesave(); // mvc.go("#scenario-personaldata.0"); // return; // } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container .xx-slider").myslider(); oc(); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "property" } })() mar.pg["scenario-mcc"] = (function(){ var html = ""; function render(pg, localopts) { let VAL = ""; var householdsize = getScenario_data("householdsize",""); var householdincome = getScenario_data("householdincome",""); let h = ""; h += frm.htitle("First time homebuyer").render(); h += "
"; h += frm.elaine("Looks like you may qualify for a First-Time Homebuyer Program. Please answer the questions below: ","er").render(); h += "
"; VAL = householdsize; h += frm.radio("householdsize","How many people are in your household?",VAL,"","",function(){ oc(); },{ under3 : "1 - 2", over2 : "3 or more", }).render(); h += "
"; h += frm.hr('ShrunkTwice').render(); h += frm.elaine("The annual household income limit before Uncle Sam takes his cut for this program is $.","er1").render(); VAL = householdincome; h += "
"; h += frm.radio("householdincome","Is your household income :",householdincome,"","",function(){ oc(); },{ Y : "lower than $ per year ", N : "higher than $ per year " }).render(); h += "
"; h += "
"; h += "
"; h += "
"; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var householdsize = radio("householdsize"); var householdincome = radio("householdincome"); if (householdsize.trim().length == 0) { mar.tip(".help-button","warning","you need to select a household size","top"); return false; } if (householdincome.trim().length == 0) { mar.tip(".help-button","warning","you need to select a household income","top"); return false; } setScenario_data("householdsize",householdsize); setScenario_data("householdincome",householdincome); if (householdincome == "Y") { setScenario_data("mcc_lowincome","Y"); } else { setScenario_data("mcc_lowincome","N"); } setScenario_data("__scenario_"+"mcc"+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-crossroads"); // mvc.go("#scenario-c2c"); //mvc.go("#scenario-purchaseprice"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-property"); }),"mar.help()"); h = Mustache.render(h,localopts); // mar.clear = function(){ // delScenario_data("householdsize"); // delScenario_data("householdincome"); // delScenario_data("mcc_lowincome"); // mvc.go("#scenario-mcc"); // } let oc = function(initial){ var householdsize = radio("householdsize"); var householdincome = radio("householdincome"); var ownedproperty = getScenario_data("has_any_applicant_owned_property_in_last_3_years","N"); var loan_type = getV2_data("loan_type","purchase"); var property_type = getScenario_data("property_type",""); if (householdsize != "") { // $("#body-container .er1").css("display","block"); let $elm = $("#mccresult-div"); if ($elm.hasClass("x-hide")) { $("#mccresult-div .er1").addClass("x-hide"); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $($("#mccresult-div .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false, }); $("#body-container").scrollTo("max",200); }); } } if (loan_type == "purchase" && ownedproperty == "N" && property_type != "" && (property_type == "sfr" || property_type == "condo")) { var ft = "Y"; var noc = "N" var targ = "N"; var mcc_household = radio("householdsize"); var cnty = county_number(getScenario_data("property_county","")); console.warn("doing mcc, household", mcc_household); mar.lookup_mcc(cnty,mcc_household,ft,noc,targ, function(mcc_options){ console.warn("mcc_options",mcc_options); /* mcc_loan_limit : 0, median_income : 0 */ if (mcc_options.median_income == 0) { $("#mccincome-div").css("display","none"); } else { $(".mccincome").html(mcc_options.median_income.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")); $("#mccincome").html(mcc_options.median_income.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")); $("#mcclimit").html(mcc_options.mcc_loan_limit); $("#mccincome-div").css("display","block"); // $($("#body-container .xhuman")[1]).Humanize({ // opts : { // fn : function() { // $(".mccincome").html(mcc_options.median_income.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")); // } // }, // quick : false, // }); } }); } } let or = function(){ // skip the mcc page if (typeof __durunnersys !== "undefined" && "flow" in __durunnersys && "page_mcc" in __durunnersys.flow && __durunnersys.flow.page_mcc === "N") { setScenario_data("householdsize",""); setScenario_data("householdincome","N"); setScenario_data("mcc_lowincome","N"); setScenario_data("__scenario_"+"mcc"+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-crossroads"); // mvc.go("#scenario-c2c"); return; } let sp = mar.isallowed_scenario("#scenario-mcc"); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container .xx-slider").myslider(); oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "property" } })() mar.pg["scenario-occupancy1"] = false; //mar.pg["scenario-occupancy1"] = (function(){ // var html = ""; // let loaded = false; // let chunk = false; // // function render(pg, localopts) { // // if (loaded === false) { // mar.chunks.get("scenario-occupancy", function(H) { // chunk = H; // }); // } // // mar.chunks.get("scenario-occupancy", function(H) { // // H = Mustache.render(H,localopts); // $("#chunk").html(H); // chunk = false; // or(); // }) // return; // // } // // return { // render : render, // section : "property" // } // //})() mar.pg["scenario-occupancy"] = (function(){ var html = ""; function render(pg, localopts) { let VAL = ""; var use = getScenario_data("occupancy_type",""); var otype = getScenario_data("has_applicant1_owned_property_in_last_3_years_type",""); let refi = (getV2_data("loan_type","purchase") !== "purchase"); let h = ""; h += frm.htitle("Occupancy").render(); if (refi) { h += frm.elaine("How do you use this property?","er").render(); } else { h += frm.elaine("How will you use this property?","er").render(); } h += "
"; VAL = use; if (refi) { h += frm.radio("use","This property used for?",VAL,"","",false,{ occupancy_by_me : "A primary", occupancy_secondhom : "A second home", occupancy_investment : "Investment property" }).render(); } else { h += frm.radio("use","This property be used for?",VAL,"","",false,{ occupancy_by_me : "A primary", occupancy_secondhom : "A second home", occupancy_investment : "Investment property" }).render(); } h += "
"; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ let loc = radio("use"); if (loc == "") { mar.tip(".help-button","warning","You need to select a use before continuing","top"); return false; } if (refi) { $.get("/cfc/adminuserspublic/"+loanofficer.id+"?fmt=explode",function(data) { let licenses = MAR.getOpt(data, "0.licenses", {}); if ("FL" in licenses === false) { licenses.FL = "Y" } let state = getScenario_data("shotgun_state", ""); if (state !== "") { state = MAR.stateCode(state, true).toUpperCase(); // convert FL -> Florida } let sp = MAR.reo.getOrCreateSubjectProperty(); let addr = MAR.addressFromString(MAR.getOpt(sp, "data.address","")); let stat = MAR.getOpt(addr, "state","").toUpperCase(); let lic = MAR.getOpt(licenses, stat, ""); if (loc !== `occupancy_investment`) { if (lic !== `Y`) { mar.tip(".help-button","warning","The LO is not licensed in this state, switch to an investment property to continue","top"); return false; } } debugger; // let state_name = a.split(":")[0].split("|")[1].trim(); // "1011|FLORIDA : Bla county" -> FLORIDA // let state_code = MAR.stateCode(state_name); // "FLORIDA" -> FL // if (state_code === "") { // return false; // no blank state codes // } // // if (use !== "occupancy_investment" && state_code in licenses === false) { // return false; // not licensed // } // if (use === "occupancy_investment") { // return true; // } // if (state === "") { // return true; // } // return (a.indexOf(`|${state} :`) > -1); setScenario_data("occupancy_type",loc); setScenario_data("__scenario_"+"occupancy"+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-location"); }); return; } setScenario_data("occupancy_type",loc); setScenario_data("__scenario_"+"occupancy"+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-location"); // mvc.go("#scenario-property"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-timeframe"); // back from occupancy // mvc.go("#scenario-location"); // back from occupancy }),"mar.help()"); h = Mustache.render(h,localopts); let or = function(){ let sp = mar.isallowed_scenario("#scenario-occupancy"); if (typeof sp === "string") { mvc.go(sp); return; } let passed = (getScenario_data("__scenario_occupancy_passed","") === "Y"); // if (refi) { // if (otype !== "") { // if (otype === "1") setScenario_data("occupancy_type","occupancy_by_me"); // if (otype === "2") setScenario_data("occupancy_type","occupancy_secondhom"); // if (otype === "D") setScenario_data("occupancy_type","occupancy_investment"); // } // setScenario_data("__scenario_occupancy_passed","Y"); // mar.fakesave(); // mvc.go("#scenario-property"); // return; // } // if (passed === false && getScenario_data("occupancy_type","") !== "") { /* skip for purchase */ // setScenario_data("__scenario_occupancy_passed","Y"); // mar.fakesave(); // mvc.go("#scenario-property"); // return; // } $("#body-container").find(".xx-radio").myradio(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "property" } })() mar.pg["scenario-summary"] = (function(){ var html = ""; function render(pg, localopts) { let VAL = ""; mar.state.scenario_summary = "y"; var householdsize = radio("householdsize"); var householdincome = radio("householdincome"); var ownedproperty = getScenario_data("has_any_applicant_owned_property_in_last_3_years","N"); var loan_type = getV2_data("loan_type","purchase"); var property_type = getScenario_data("property_type",""); let h = ""; h += frm.htitle("Your Scenario").render(); h += "
"; h += frm.h2("If you see incorrect informaiton please click fields below to edit.").render(); h += "
"; VAL = mar._txt(getScenario_data("loan_type_purchase_options","")); h += frm.summaryline("Time frame" ,VAL, {} , function(){ mvc.go("#scenario-timeframe"); }).render(); // done h += frm.hr("Summary").render(); var apl = getApplicants_v2(); if (apl.length == 1) { VAL = "FICO " +getScenario_data("applicant1_cscore",""); h += frm.summaryline("Credit score" ,VAL, {} , function(){ mvc.go("#scenario-timeframe"); }).render(); // done h += frm.hr("Summary").render(); VAL = "No"; if (ownedproperty == "Y") VAL = "Yes"; h += frm.summaryline("Home owner" ,VAL, {} , function(){ mvc.go("#scenario-timeframe"); }).render(); // done h += frm.hr("Summary").render(); h += frm.summaryline("Legal status" ,VAL, {} , function(){ mvc.go("#scenario-timeframe"); }).render(); h += frm.hr("Summary").render(); VAL = "No"; if (getScenario_data("has_applicant1_served_in_us_forces","") == "Y") { VAL = "Yes"; var applicantNum = 1; var served = getScenario_data("scenario_applicant"+applicantNum+"_served",false); var eligible = getScenario_data("has_applicant"+applicantNum+"_served_in_us_forces",false); var employment = getScenario_data("va_employment"+applicantNum+"",false); var firsttime = getScenario_data("vafirst_time_use"+applicantNum+"",false); var disabled = getScenario_data("va_disabled"+applicantNum+"",false); var disabled_perc = getScenario_data("va_disabled"+applicantNum+"_percentage","10"); var coe = getScenario_data("va_coe"+applicantNum+"",false); if (employment) VAL = mar._txt(employment); } h += frm.summaryline("Veteran" ,VAL, {} , function(){ mvc.go("#scenario-timeframe"); }).render(); h += frm.hr("Summary").render(); } else { var bod = []; for (let i=0; i < apl.length; i++) { var na = getApplicantsNames_v2(i).Name; VAL = "FICO " +getScenario_data("applicant"+(i+1)+"_cscore",""); bod.push({ key : na, val : VAL }) } VAL = "No"; if (ownedproperty == "Y") VAL = "Yes"; h += frm.summaryline("Home owner" ,VAL, {} , function(){ mvc.go("#scenario-timeframe"); }).render(); // done h += frm.hr("Summary").render(); h += frm.summaryline("Legal status" ,"", bod , function(){ mvc.go("#scenario-timeframe"); }).render(); h += frm.hr("Summary").render(); var bod = []; for (let i=0; i < apl.length; i++) { var na = getApplicantsNames_v2(i).Name; VAL = "No"; if (getScenario_data("has_applicant"+(i+1)+"_served_in_us_forces","") == "Y") { VAL = "Yes"; var applicantNum = (i+1); var served = getScenario_data("scenario_applicant"+applicantNum+"_served",false); var eligible = getScenario_data("has_applicant"+applicantNum+"_served_in_us_forces",false); var employment = getScenario_data("va_employment"+applicantNum+"",false); var firsttime = getScenario_data("vafirst_time_use"+applicantNum+"",false); var disabled = getScenario_data("va_disabled"+applicantNum+"",false); var disabled_perc = getScenario_data("va_disabled"+applicantNum+"_percentage","10"); var coe = getScenario_data("va_coe"+applicantNum+"",false); if (employment) VAL = mar._txt(employment); } bod.push({ key : na, val : VAL }) } h += frm.summaryline("Veteran" ,VAL, {} , function(){ mvc.go("#scenario-timeframe"); }).render(); h += frm.hr("Summary").render(); } var bod = []; for (let i=0; i < apl.length; i++) { var na = getApplicantsNames_v2(i).Name; bod.push({ key : "Borrower "+(i+1), val : na }) } h += frm.summaryline("Borrower(s) "," ", { body : bod }, false).render(); h += frm.hr("Summary").render(); VAL = county_display(getScenario_data("property_county","")); h += frm.summaryline("Location" ,VAL, {} , function(){ mvc.go("#scenario-timeframe"); }).render(); // done h += frm.hr("Summary").render(); VAL = mar._txt(getScenario_data("occupancy_type","")); h += frm.summaryline("Property use" ,VAL, {} , function(){ mvc.go("#scenario-timeframe"); }).render(); // done h += frm.hr("Summary").render(); VAL = mar._txt(getScenario_data("property_type","")); if (getScenario_data("monthly_rent",false)) { VAL += "
Est rent : $"+getScenario_data("monthly_rent","")+"
" } h += frm.summaryline("Property type" ,VAL, {} , function(){ mvc.go("#scenario-timeframe"); }).render(); // done h += frm.hr("Summary").render(); VAL = MAR.getSummaryHoi(); h += frm.summaryline("Homeowners insurance" ,VAL, {} , function(){ mvc.go("#scenario-hoi"); }).render(); // done h += frm.hr("Summary").render(); VAL = ""; h += frm.summaryline("Property taxes" ,VAL, {} , function(){ mvc.go("#scenario-tax"); }).render(); // TODO h += frm.hr("Summary").render(); VAL = MAR.getSummaryHoa(); h += frm.summaryline("HOA fees" ,VAL, {} , function(){ mvc.go("#scenario-hoa"); }).render(); // done h += frm.hr("Summary").render(); h += frm.summaryline("Wishlist "," ", { // TODO body : [ { key : "Monthly budget" , val : "$1,500"}, { key : "Target purchase price" , val : "$250,000"}, { key : "Downpayment" , val : "$20,300"} ] }, false).render(); h += frm.hr("Summary").render(); VAL = ""; h += frm.summaryline("Realtor" ,VAL, {} , function(){ mvc.go("#scenario-timeframe"); }).render(); // TODO h += frm.hr("Summary").render(); h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ mvc.go("#income-how.0"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-realtor"); }),"mar.help()"); let oc = function() { } h = Mustache.render(h,localopts); let or = function(){ $("#body-container").find(".xx-radio").myradio(); oc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })() mar.pg["scenario-borrowers"] = (function(){ var html = ""; function render(pg, localopts) { let VAL = ""; let h = ""; let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(0).Name; //let applicantnum = ("p2" in localopts && localopts.p2 !== "") ? parseInt(localopts.p2,10) : 0; //var na = getApplicantsNames_v2(applicantnum).Name; h += frm.htitle("CO-Borrower(s)").render(); //h += frm.h2("
Tip: If someone has no income or suffucient credit, there is no point in adding them to the loan. You can however add them as owners to the title.
").render(); val = 'N'; // h += frm.yn("notme",na+", do you have enough income and credit?",VAL,"","",function(){ // oc(); // },{}).render(); // h += frm.hr('ShrunkTwice').render(); VAL = ""; let upnext = false; let upnext_title = ""; let upnext_text = ""; if (applicantnum >= MAR.MAXBORROWERS) { VAL = getScenario_data("addfourth","N"); h += "
"; h += frm.elaine(`You've added ${MAR.numName(applicantnum)} borrowers. That's the max we can handle!`,"er").render(); h += '
'; h += "
"; h += frm.yn3("addfourth",`Would you like to add a ${MAR.th(applicantnum+1)}?`,VAL,"","",function(){ oc(); },{}).render(); h += "
"; h += frm.h2(`Note: More than ${MAR.numName(applicantnum)} borrowers are allowed by some lenders. the additional borrowers need to be added manually by your licensed loan originatior.`).render(); h += frm.elaine("When you are done with this application you can call your loan officer "+loanofficer.name+" at "+loanofficer.telF+" to add more borrowers","er").render(); h += '
'; h += '
'; } else { // retval.is_there_a_second_borrower = mar.answers.v2.scenario.is_there_a_second_borrower; // retval.second_applicant = mar.answers.v2.scenario.second_applicant; // retval.is_there_a_third_borrower = mar.answers.v2.scenario.is_there_a_third_borrower; // retval.third_applicant = mar.answers.v2.scenario.third_applicant; let default_answer = ""; let location = getScenario_data("property_county",""); let script_applicants = getScenario_data("script_applicants",""); let NA = ""; if (applicantnum == 0) { let is2nd = getScenario_data("is_there_a_second_borrower",""); if (is2nd === "Y") { // this is an up, next page upnext = "#scenario-borrower.1"; upnext_title = "2nd Borrower"; NA = getApplicantsNames_v2(1).Names; upnext_text = `You can enter or remove you ${NA} information on the next page.`; default_answer = "Y"; } else if (location !== "") { default_answer = "N"; } else if (script_applicants === "1") { default_answer = "N"; } } if (applicantnum == 1) { let is3rd = getScenario_data("is_there_a_third_borrower",""); if (is3rd === "Y") { // this is an up, next page upnext = "#scenario-borrower.2"; upnext_title = "3rd Borrower"; NA = getApplicantsNames_v2(2).Names; upnext_text = `You can enter or remove you ${NA} information on the next page.`; default_answer = "Y"; } else if (location !== "") { default_answer = "N"; } } if (applicantnum > 1) { let NN = (num(applicantnum)+1); let isNth = getScenario_data(`is_there_a_${MAR.th(NN+1)}_borrower`,""); if (isNth === "Y") { // this is an up, next page upnext = `#scenario-borrower.${NN}`; upnext_title = `${MAR.th(NN)} Borrower`; NA = getApplicantsNames_v2(NN).Names; upnext_text = `You can enter or remove you ${NA} information on the next page.`; default_answer = "Y"; } else if (location !== "") { default_answer = "N"; } } if (upnext !== false) { h = ""; h += "
"; h += "
"; h += "
"; h += "
"; h += "
"; h += ""; h += "
"; h += "
"; h += "
"; h += "
"; h += "
"; h += `
Up Next: ${upnext_title}
`; h += "
"; h += "
"; h += "
"; h += "
"; h += `
${upnext_text}
`; h += "
"; h += "
"; h += "
Continue
"; h += "
"; h += "
"; } if (upnext === false) { h += "
"; if (applicantnum == 0) { h += frm.elaine(na+", will it be you? Or will you use someone else's income to get qualified for this loan?","er").render(); } else { h += frm.elaine(`${na}, will you use a ${MAR.th(applicantnum+2)} borrower's income to get qualified for this loan?`,"er").render(); } h += '
'; h += "
"; if (applicantnum == 0) { getScenario_v2(); VAL = "no"; if (getApplicants_v2().length > 1) VAL = "yes"; VAL = ""; if (default_answer === "Y") VAL = "yes"; if (default_answer === "N") VAL = "no"; h += frm.radio("moreborrowers","",VAL,"","",false,{ yes : "Yes, there are more borrowers", no : "No, it will be just me" }).render(); } else { getScenario_v2(); VAL = "no"; if (getApplicants_v2().length > applicantnum) VAL = "yes"; VAL = ""; if (default_answer === "Y") VAL = "yes"; if (default_answer === "N") VAL = "no"; h += frm.radio("moreborrowers","",VAL,"","",false,{ yes : `Yes, there is a ${MAR.th(applicantnum+2)} borrower`, no : `No, it will be just the ${MAR.numName(applicantnum+1)} of us` }).render(); } h += '
'; } } /* h += frm.elaine("We will bring you to the beginning of the app, please have the main applicant fill it in this time. Leave yourself out as an applicant","").render(); h += frm.but("REDO APPLICATION",function(){ swal("sadfsadfafd"); }).render(); */ var loan_type = getV2_data("loan_type","purchase"); let refi = (loan_type !== "purchase"); if (upnext === false) { h += uihelpers.cbuttonbar("Continue",frm.addfunction(async function(){ /** * if we have passed borrower 0, then this is an addition , so go on to the personal data of that borrower directly IF it has not been filled */ let skip_through_to_complete_new_borrower = false; if (applicantnum > 0 && getScenario_data(`__scenario_personaldata_0_passed`,"") === "Y") { for (let appl_num = 1; appl_num <= applicantnum; appl_num++) { if (getScenario_data(`__scenario_personaldata_${appl_num}_passed`,"") !== "Y") { skip_through_to_complete_new_borrower = `#scenario-personaldata.${appl_num}`; break; } } } if (applicantnum >= MAR.MAXBORROWERS) { setScenario_data("__scenario_"+"borrowers"+"_"+applicantnum+"_passed","Y"); mar.fakesave(); if (refi) { setScenario_data("__scenario_end_passed","Y"); /* this is otherwise done in realtor */ mar.fakesave(); if (skip_through_to_complete_new_borrower !== false) { mvc.go(skip_through_to_complete_new_borrower); } else if (num(mar.pg_as) < num(mar.pg_pd)) { mvc.go("#assets-choice"); } else { mvc.go("#scenario-personaldata.0"); } } else { if (skip_through_to_complete_new_borrower !== false) { mvc.go(skip_through_to_complete_new_borrower); } else if (getScenario_data("crossroads","route1") == "route2") { if (MAR.isMccEligible()) { mvc.go("#scenario-mcc"); } else { mvc.go("#scenario-c2c"); } } else { mvc.go("#scenario-realtor"); } } // mvc.go("#scenario-location"); // this is the main forward to location } else { var moreborrowers = radio("moreborrowers"); if (moreborrowers == "") { mar.tip(".sc-nxt-but-1","warning","you need to select an option before continuing","top"); return false; } if (moreborrowers == "yes") { let yes_function = function() { if (applicantnum == 0) { setScenario_data("__scenario_"+"borrowers"+"_"+applicantnum+"_passed","Y"); setScenario_data("__scenario_"+"borrowers"+"_num","2"); mar.fakesave(); mvc.go("#scenario-borrower.1"); } if (applicantnum == 1) { setScenario_data("__scenario_"+"borrowers"+"_"+applicantnum+"_passed","Y"); setScenario_data("__scenario_"+"borrowers"+"_num","3"); mar.fakesave(); mvc.go("#scenario-borrower.2"); } if (applicantnum > 1) { setScenario_data("__scenario_"+"borrowers"+"_"+applicantnum+"_passed","Y"); setScenario_data("__scenario_"+"borrowers"+"_num",`${applicantnum+2}`); mar.fakesave(); mvc.go(`#scenario-borrower.${applicantnum+1}`); } } let isSynchedObj = await MAR.encompass.isSynchedSync(mar.ID); if (MAR.appnav.loanWasImportedAndNotVerified() !== true && isSynchedObj.synched === true) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ "The loan is synchronized with Encompass and this new borrower will be added to the encompass loan."+ "
"+ "
"+ "Are you sure you want to continue to add the borrower? "+ ""; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "No", call : { text: "Yes", value: "yes", closeModal: false } } }) .then((act) => { if (act == "yes") { yes_function(); } else { radio("moreborrowers","no"); } }); } else { yes_function(); } } else { setScenario_data("__scenario_"+"borrowers"+"_"+applicantnum+"_passed","Y"); mar.fakesave(); if (refi) { setScenario_data("__scenario_end_passed","Y"); /* this is otherwise done in realtor */ mar.fakesave(); if (skip_through_to_complete_new_borrower !== false) { mvc.go(skip_through_to_complete_new_borrower); } else if (num(mar.pg_as) < num(mar.pg_pd)) { mvc.go("#assets-choice"); } else { mvc.go("#scenario-personaldata.0"); } } else { if (skip_through_to_complete_new_borrower !== false) { mvc.go(skip_through_to_complete_new_borrower); } else if (getScenario_data("crossroads","route1") == "route2") { if (MAR.isMccEligible()) { mvc.go("#scenario-mcc"); } else { mvc.go("#scenario-c2c"); } } else { mvc.go("#scenario-realtor"); } } // mvc.go("#scenario-location"); // this is also the main forward to location } } }),"BACK",frm.addfunction(function(){ mvc.go("#declarations-p3."+applicantnum); // if (radio("loan_type_purchase_options") == "") { // if (N == mar.S_TIMEFRAME_1) { // mar.tip(".sc-nxt-but-1","warning","you need to select an option before continuing","top"); // return false; // } // if (N < 0) return false; // } }),"mar.help()"); } h = Mustache.render(h,localopts); let or = function(){ let sp = mar.isallowed_scenario("#scenario-borrowers."+applicantnum); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(); } }, quick : false, }); } let oc = function(){ if ($("#addfourth").length > 0) { let _addfourth = yn3("#addfourth"); if (_addfourth == "Y") { $(".er-info").css("display","block") } else { $(".er-info").css("display","none") } setScenario_data("addfourth",_addfourth); mar.fakesave(); } } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })() mar.pg["scenario-borrower"] = (function(){ // // I haveto support these warnings // // if (!mar.answers.v2.scenario.second_applicant || mar.answers.v2.scenario.second_applicant == "" || mar.answers.v2.scenario.second_applicant == "none") { // $(".third_applicant_q").addClass("x-hide"); // $(".third_applicant_q_followup").addClass("x-hide"); // } else { // if (mar.answers.v2.scenario.second_applicant == "coborrower_nonresident") { // $(".non_resident_coborrower_warning").css("display","block"); // } else { // $(".non_resident_coborrower_warning").css("display","none"); // } // if (mar.answers.v2.scenario.has_applicant1_served_in_us_forces == "Y" // && mar.answers.v2.scenario.second_applicant !== "spouse" // && mar.answers.v2.scenario.second_applicant !== "") { // // $(".va_non_spouse_warning").css("display","block"); // // } else { // $(".va_non_spouse_warning").css("display","none"); // } // // $("#second_applicant_relationship_next_button .xhuman").attr("data","scenario_simple_name_previous_ownership2_q"); // $("#second_applicant_relationship_next_button .yesPrevProp").css("display","none"); // $("#second_applicant_relationship_next_button .noPrevProp").css("display","inline"); // //console.log(" CHECK THIS mar.answers.v2.scenario.has_applicant1_owned_property_in_last_3_years-- "+mar.answers.v2.scenario.has_applicant1_owned_property_in_last_3_years); // if (mar.answers.v2.scenario.has_applicant1_owned_property_in_last_3_years == 'Y') { // //console.log(" !!!!! CEHCKING mar.answers.v2.scenario.second_applicant-- "+mar.answers.v2.scenario.second_applicant); // // // if (mar.answers.v2.scenario.second_applicant == "spouse") { // // $("#second_applicant_relationship_next_button .xhuman").attr("data","scenario_simple_name2_citizenship_q"); // $("#second_applicant_relationship_next_button .yesPrevProp").css("display","inline"); // $("#second_applicant_relationship_next_button .noPrevProp").css("display","none"); // //console.log(" $(#second_applicant_relationship_next_button .xhuman) :: ", $("#second_applicant_relationship_next_button .xhuman") ); // // } // } // // // // remeber maybe not when we are editing it !!!! $(".third_applicant_q").css("display","block"); // // if (mar.answers.v2.scenario.is_there_a_third_borrower && mar.answers.v2.scenario.is_there_a_third_borrower == "Y") { // $(".third_applicant_q_followup").removeClass("x-hide"); // } else { // $(".third_applicant_q_followup").removeClass("x-hide"); // } // } // // var html = ""; function render(pg, localopts) { let VAL = ""; let FILLED = 1; let UNFILLED = 2; let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; let initialstate = FILLED; var na = getApplicantsNames_v2(0).Name; var apl = getApplicants_v2(); if (applicantnum == 0) { var _name = getScenario_data("applicant1_name",""); var _rel = ""; var _relationship = false; } if (applicantnum == 1) { var _name = getScenario_data("applicant2_name",""); var _rel = getScenario_data("applicant2_rel",""); var _relationship = getScenario_data("second_applicant",""); } if (applicantnum > 1) { var _name = getScenario_data(`applicant${applicantNum}_name`,""); var _rel = getScenario_data(`applicant${applicantNum}_rel`,""); var _relationship = getScenario_data(`${MAR.th(applicantnum+1)}_applicant`,""); var _relationship1 = getScenario_data(`second_applicant`,""); } if (_name === "") initialstate = UNFILLED; let h = ""; // if (applicantnum == 1) { // h += frm.htitle("Second borrower").render(); // } else if (applicantnum == 1) { // h += frm.htitle("Third borrower").render(); // } else { // h += frm.htitle("Borrower(s)").render(); // } h += frm.htitle("Additional borrowers").render(); val = 'N'; h += frm.elaine(`That's great. You can add up to ${MAR.numName(MAR.MAXBORROWERS)} borrowers.`,"er").render(); let is_spouse_or_partner_already = false; let optional_people = []; for (let i=1; i < apl.length; i++) { let N = i; var _rel = getScenario_data(`${MAR.th(N+1)}_applicant`,""); if (_rel == "spouse" || _rel == "partner") { is_spouse_or_partner_already = true; break; } else { let ap = getApplicant_v2(i); if (ap && "rel" in ap && ap.rel !== "") { // already related } else { optional_people.push(i); } } } h += "
"; VAL = _name; h += "
"; h += frm.txt("name","Additional borrower's name?",VAL,"","",function(){ oc(); }).render(); h += "
"; h += "
"; h += frm.hr("Shrunk").render(); if (applicantnum > 0) { var modeofaddress = (applicantnum == 1) ? "your co-borrower" : `the ${MAR.th(applicantnum+1)} borrower`; modeofaddress = `${modeofaddress}`; if (is_spouse_or_partner_already == true && _relationship !== "spouse" && _relationship !== "partner") { VAL = _relationship; h += frm.radio("relationship","What's the relationship between you and "+modeofaddress+"?",VAL,"","",function(){ oc(); },{ coborrower : "Borrower", coborrower_nonresident : "Borrower that will not live there" }).render(); } else { VAL = _relationship; h += frm.radio("relationship","What's the relationship between you and "+modeofaddress+"?",VAL,"","",function(){ oc(); },{ spouse : "Spouse", partner : "Partner or family member
with whom you share assets and/or liabilities", coborrower : "Borrower", coborrower_nonresident : "Borrower that will not live there" }).render(); } } h += "
"; // VAL = _name; // h += "
"; // h += frm.hr("Shrunk").render(); // h += frm.txt("name","Additional borrower's name?",VAL,"","",function(){ // oc(); // // }).render(); // h += "
"; if (optional_people.length > 0) { h += "
"; h += frm.hr("Shrunk").render(); let options = {}; for (let i=0; i < optional_people.length; i++) { let n = optional_people[i]; let N = optional_people[i]+1; var _name = getScenario_data(`applicant${N}_name`,""); var _rel = getScenario_data(`${MAR.th(N+1)}_applicant`,""); options[`o${n}`] = `Partner of ${_name}` } options.N = "None of the above"; VAL = _rel; h += frm.radio("relationshipto",`Is ${_name} the partner of one of these other borrowers? `,VAL,"","",function(){ oc(); },options).render(); h += "
"; } let _remove = function(n) { let v2 = mar.answers.v2; MAR.applicants.remove(n); return; /** * old code */ // if (n == 1 && v2.applicants.length > 1) { // // applicants // v2.applicants[1] = null; // v2.applicants = v2.applicants.filter(function(item) { // return item !== null // }) // // // // income // v2.income[1] = null; // v2.income = v2.income.filter(function(item) { // return item !== null // }) // // // assets // if (typeof v2.assets === "object") { // v2.assets.items = v2.assets.items.filter(function(item) { // if (item.whose_name == "1") return false; // if (item.whose_name == "1,99") return false; // if (typeof item.whose_name === "string" && item.whose_name.indexOf("1") > -1) { // if (item.whose_name.indexOf("99") < 0) { // item.whose_name = item.whose_name.replace(/1/g,"99") // } else { // litem.whose_name = item.whose_name.split(",").filter(function(itm) { return itm != "1"; }).join(","); // } // } // return true; // }) // } // // // liabilities // if (typeof v2.liabilities === "object") { // v2.liabilities = v2.liabilities.filter(function(item) { // if (item.inomask == 2) return false; // if (item.inomask == (2+128)) return false; // return true; // }) // } // // // declarations // if (typeof v2.declarations === "object") { // v2.declarations[1] = null; // v2.declarations = v2.declarations.filter(function(item) { // return item !== null // }) // } // // // references -- mainly in needslist // setScenario_data("applicant2_name",""); // setScenario_data("second_applicant",""); // setScenario_data("is_there_a_second_borrower","N"); // // } // // if (n == 2 && v2.applicants.length > 2) { // // applicants // v2.applicants[2] = null; // v2.applicants = v2.applicants.filter(function(item) { // return item !== null // }) // // // // income // v2.income[2] = null; // v2.income = v2.income.filter(function(item) { // return item !== null // }) // // // assets // v2.assets.items = v2.assets.items.filter(function(item) { // if (item.whose_name == "2") return false; // if (item.whose_name == "2,99") return false; // if (typeof item.whose_name === "string" && item.whose_name.indexOf("2") > -1) { // if (item.whose_name.indexOf("99") < 0) { // item.whose_name = item.whose_name.replace(/2/g,"99") // } else { // litem.whose_name = item.whose_name.split(",").filter(function(itm) { return itm != "2"; }).join(","); // } // } // return true; // }) // // // // liabilities // if (typeof v2.liabilities === "object") { // v2.liabilities = v2.liabilities.filter(function(item) { // if (item.inomask == 4) return false; // if (item.inomask == (4+128)) return false; // return true; // }) // } // // // declarations // v2.declarations[2] = null; // v2.declarations = v2.declarations.filter(function(item) { // return item !== null // }) // // // references -- mainly in needslist // setScenario_data("applicant3_name",""); // setScenario_data("third_applicant",""); // setScenario_data("is_there_a_third_borrower","N"); // // } } if (_relationship !== false && _relationship !== "") { if (applicantnum > 0) { h += frm.h2("
Tip: You can however add them as owners to the title.
").render(); h += frm.but("REMOVE THIS APPLICANT",function(){ _remove(applicantnum); console.warn(mar.answers.v2) mar.fakesave(function(){ mvc.go("#scenario-borrowers."+(applicantnum-1)) }); }).render(); } } h += "
" h += "
"; let os = function() { // on slide down let $elm = $("#relationship-div"); if ($elm.hasClass("x-hide")) { $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return false; } return true; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var relationship = radio("relationship"); var relationshipto = ($("rel-div").length > 0) ? radio("relationshipto") : ""; var name = txt("#name"); var apl = getApplicants_v2(); if (applicantnum == 0) { MAR.setApplicantName(applicantnum,name); mar.fakesave(); mvc.go("#scenario-creditscore.0"); return; } if (name.trim().length == 0) { mar.tip(".help-button","warning","you need to fill in the name before continuing","top"); return false; } $("#borrower-name").html(name); if (os() === false) return false if (relationship == "") { mar.tip(".help-button","warning","you need to select an option before continuing","top"); return false; } if (applicantnum == 1) { setScenario_data("applicant2_name",name); setScenario_data(`applicant3_rel`,""); setScenario_data("second_applicant",relationship); setScenario_data("is_there_a_second_borrower","Y"); getScenario_v2(); MAR.setApplicantName(applicantnum,name); setScenario_data("__scenario_"+"borrower"+"_"+applicantnum+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-creditscore.1"); } if (applicantnum == 2) { setScenario_data("applicant3_name",name); setScenario_data(`applicant3_rel`,relationshipto); setScenario_data("third_applicant",relationship); setScenario_data("is_there_a_third_borrower","Y"); getScenario_v2(); MAR.setApplicantName(applicantnum,name); setScenario_data("__scenario_"+"borrower"+"_"+applicantnum+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-creditscore.2"); } if (applicantnum > 2) { let NN = (num(applicantnum)+1); setScenario_data(`applicant${NN}_name`,name); setScenario_data(`applicant${NN}_rel`,relationshipto); setScenario_data(`${MAR.th(NN)}_applicant`,relationship); setScenario_data(`is_there_a_${MAR.th(NN)}_borrower`,"Y"); getScenario_v2(); MAR.setApplicantName(applicantnum,name); setScenario_data("__scenario_borrower_"+applicantnum+"_passed","Y"); mar.fakesave(); mvc.go(`#scenario-creditscore.${applicantnum}`); } // if (relationship == "") { // mar.tip(".sc-nxt-but-1","warning","you need to select an option before continuing","top"); // return false; // // } // if (name == "") { // mar.tip(".sc-nxt-but-1","warning","you need to fill in the name before continuing","top"); // return false; // // } // if (radio("loan_type_purchase_options") == "") { // if (N == mar.S_TIMEFRAME_1) { // mar.tip(".sc-nxt-but-1","warning","you need to select an option before continuing","top"); // return false; // } // if (N < 0) return false; // } }),"BACK",frm.addfunction(function(){ if (applicantnum == 0) { mvc.go("#scenario-timeframe"); } if (applicantnum > 0) { mvc.go(`#declarations-p3.${(applicantnum-1)}`); } }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(){ var relationship = radio("relationship"); var name = txt("#name"); var relationshipto = ($("rel-div").length > 0) ? radio("relationshipto") : ""; if (typeof relationship !== "string") relationship = ""; if (relationship.indexOf("non") > -1) { $("#del-div .oc").addClass("x-hide"); $("#del-div .noc").removeClass("x-hide"); } else { $("#del-div .oc").removeClass("x-hide"); $("#del-div .noc").addClass("x-hide"); } if (name.trim().length > 0) { $("._name").html(name); $("#borrower-name").html(name); if (os() === false) return false } if (relationship == "" && applicantnum != 0 ) { // $("#name-div").css("display","none"); $("#rel-div").css("display","none"); } else { $("#name-div").css("display","block"); if (relationship !== "spouse" && relationship !== "partner") { $("#rel-div").css("display","block"); } else { $("#rel-div").css("display","none"); } } } // relationshipto let or = function(){ $("#body-container").find(".xx-radio").myradio(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { $(".info-relate").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ "A partner is someone that you currently share assets or liabilities with, like a spouse or a domestic partner."+ "
"+ "
"+ "Example: "+ "
"+ "
"+ "- A mother and daughter sharing a household, with a joint bank account is also considered a partner."+ "
"+ "
"+ "- A couple that intend to live together, but currently do not, are not considered partners." swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); }); if (initialstate == FILLED) { $.get(`/api/encompass/syncview?appid=${mar.ID}`, function(da) { let svo = mar.classes.Syncview_class(da); // if (svo.canDeleteApplicant(applicantnum) === true) { // // let hh = "" // hh += frm.h2("
Tip: "+ // "You can however add them as owners to the title."+ // ">Non occupent co-borrowers can own part of the property or none, ask your title company"+ // "
").render(); // hh += frm.but("REMOVE THIS APPLICANT",function(){ // // elaineui.swalprompt({ // title : false,//"delete", // txt : "Are you sure you want to delete this borrower.", // ok : "Yes", // okfn : function() { // MAR.applicants.remove(applicantnum); // mar.fakesave(function(){ // if (applicantnum == 0) { // mvc.go("#scenario-creditscore.0") // // } else { // mvc.go(`#scenario-creditscore.${applicantnum-1}`) // // } // }); // // }, // cancel : "No", // cancelfn : false // }); // // // }).render(); // $("#del-div").html(hh); // // } }); } oc(); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })() mar.pg["scenario-legalstatus"] = (function(){ var html = ""; function render(pg, localopts) { let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var n0 = getApplicantsNames_v2(0).Name; var na = getApplicantsNames_v2(applicantnum).Name; var usc = getScenario_data("scenario_applicant"+applicantNum+"_usc",false); var gch = getScenario_data("scenario_applicant"+applicantNum+"_gch",false); var visa = getScenario_data("scenario_applicant"+applicantNum+"_visa_type",false); var cntry = getScenario_data("scenario_applicant"+applicantNum+"_cntry",false); let VAL = ""; let h = ""; h += frm.htitle("Legal status").render(); if (applicantnum == 0) { h += frm.elaine("I would like to know about your legal status in the USA","er").render(); } else { h += frm.elaine("I would like to know about "+na+"'s legal status in the USA","er").render(); } let oc = function() { let _usc = yn("#usc"); let _gch = yn("#gch"); let _visa = txt("#visa_type"); let _cntry = txt("#cntry"); $("#gch-div").css("display","none"); $("#visa-div").css("display","none"); if (_usc == "Y") { yn("#gch","Y"); _gch = "Y"; txt("#visa_type",""); _visa = ""; } if (_usc == "N") { if ($("#gch-div").css("display") != "block") { $("#gch-div").css("display","block"); $("#body-container").scrollTo("max",200); } if (_gch == "N" && $("#visa-div").css("display") != "block") { $("#visa-div").css("display","block"); $("#body-container").scrollTo("max",200); } } setScenario_data("scenario_applicant"+applicantNum+"_usc",_usc); setScenario_data("scenario_applicant"+applicantNum+"_gch",_gch); setScenario_data("scenario_applicant"+applicantNum+"_visa_type",_visa); setScenario_data("scenario_applicant"+applicantNum+"_cntry",_cntry); getDeclarations_v2(); mar.fakesave(); } h += "
"; VAL = (usc) ? usc : ""; if (applicantnum == 0) { h += frm.yn3("usc",na+", are you a U.S. citizen?",VAL,"","",function(){ oc(); },{}).render(); } else { h += frm.yn3("usc",n0+", is "+na+" a U.S. citizen?",VAL,"","",function(){ oc(); },{}).render(); } VAL = (gch) ? gch : "Y"; h += "
"; h += frm.hr("Shrunk").render(); if (applicantnum == 0) { h += frm.yn3("gch","Are you a Green Card holder?",VAL,"","",function(){ oc(); },{}).render(); } else { h += frm.yn3("gch","Is "+na+" a Green Card holder?",VAL,"","",function(){ oc(); },{}).render(); } h += "
"; h += "
"; h += frm.hr().render(); if (applicantnum == 0) { VAL = (visa) ? visa : ""; h += frm.txt("visa_type","What sort of visa do you have?",VAL,"e.g. B1 - B2","",function(){ oc(); }).render(); VAL = (cntry) ? cntry : ""; h += frm.txt("cntry","What is your country of residence?",VAL,"e.g. Mexico","",function(){ oc(); }).render(); } else { VAL = (visa) ? visa : ""; h += frm.txt("visa_type","What sort of visa does "+na+" have?",VAL,"e.g. B1 - B2","",function(){ oc(); }).render(); VAL = (cntry) ? cntry : ""; h += frm.txt("cntry","What is your country of residence?",VAL,"e.g. Mexico","",function(){ oc(); }).render(); } h += "
"; h += "
"; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ let _usc = yn3("#usc"); let _gch = yn3("#gch"); let _visa = txt("#visa_type"); let _cntry = txt("#cntry"); if (_usc == "") { mar.tip(".help-button","warning","You forgot to specify your legal status","top"); return false; } if (_usc == "N") { if (_gch == "") { mar.tip(".help-button","warning","You forgot to specify your greencard status","top"); return false; } if (_gch == "N") { if (_visa == "") { mar.tip(".help-button","warning","You forgot to specify the type of visa","top"); return false; } if (_cntry == "") { mar.tip(".help-button","warning","You forgot to specify the country of residence","top"); return false; } } } setScenario_data("scenario_applicant"+applicantNum+"_usc",_usc); setScenario_data("scenario_applicant"+applicantNum+"_gch",_gch); setScenario_data("scenario_applicant"+applicantNum+"_visa_type",_visa); setScenario_data("scenario_applicant"+applicantNum+"_cntry",_cntry); setScenario_data("__scenario_legalstatus_"+applicantnum+"_passed","Y"); getDeclarations_v2(); mar.fakesave(function(){ if (mar.WE_ARE_FROM_LOI === true) { MAR.encompass.app_check_diffs_borrower_profileSync(mar.ID, applicantnum); } }); mvc.go("#scenario-veteran."+applicantnum); }),"Prev",frm.addfunction(function(){ mvc.go("#scenario-pastproperty."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let or = function(){ let sp = mar.isallowed_scenario("#scenario-legalstatus."+applicantnum); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })() mar.pg["scenario-veteran"] = (function(){ var html = ""; function render(pg, localopts) { let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var served = getScenario_data("scenario_applicant"+applicantNum+"_served",false); var active = getScenario_data("va_active"+applicantNum+"",false); var active_ed = getScenario_data("va_active_ed"+applicantNum+"",false); var eligible = getScenario_data("has_applicant"+applicantNum+"_served_in_us_forces",false); var employment = getScenario_data("va_employment"+applicantNum+"",false); var firsttime = getScenario_data("vafirst_time_use"+applicantNum+"",false); var disabled = getScenario_data("va_disabled"+applicantNum+"",false); var disabled_perc = getScenario_data("va_disabled"+applicantNum+"_percentage","5"); var nofee = getScenario_data("va_nofee"+applicantNum+"",false); var coe = getScenario_data("va_coe"+applicantNum+"",false); var target_va = getScenario_data("target_va",""); let VAL = ""; let h = ""; h += frm.htitle("Veteran").render(); if (applicantnum == 0) { if (target_va === "Y") { h += frm.elaine(n0+", please tell us more about your employment with the Armed Forces?","er").render(); } else { h += frm.elaine(n0+", have you been employed by the Armed Forces?","er").render(); } } else { h += frm.elaine(n0+", has "+na+" been employed by the Armed Forces?","er").render(); } h += "
"; VAL = (served) ? served : ""; if (applicantnum == 0) { // h += frm.yn3("served","Have you been in the U.S. Military?",VAL,"","",function(){ // oc(); // },{}).render(); VAL = `${served}${active}`.trim(); if (VAL === "") { let target_va = getScenario_data("target_va", ""); if (target_va === "Y") { VAL = "YD"; } } h += frm.radio("served_opts","Have you been in the U.S. Military?",VAL,"","",function(){ oc(); },{ YA : "I am currently serving on active duty", YD : "I am retired , discharged or seperated from service", YR : "My only duty was as a non-active member of the reserves", YS : "I am a surviving spouse", NN : "No - I have never served" }).render(); VAL = (active_ed) ? active_ed : ""; h += "
" h += frm.hr("Shrunk").render(); h += frm.txt("active_ed","Expiration date of service tour",VAL,"",function(){},"date").render(); h += "
"; } else { // h += frm.yn3("served","Has "+na+" been in the U.S. Military?",VAL,"","",function(){ // oc(); // },{}).render(); VAL = `${served}${active}`.trim(); h += frm.radio("served_opts","Has "+na+" been in the U.S. Military?",VAL,"","",function(){ oc(); },{ YA : "They are currently serving on active duty", YD : "They areretired ,discharged or seperated from service", YR : "Their only duty was as a non-active member of the reserves", YS : "They are a surviving spouse", NN : "No - they have never served" }).render(); VAL = (active_ed) ? active_ed : ""; h += "
" h += frm.hr("Shrunk").render(); h += frm.txt("active_ed","Expiration date of service tour",VAL,"",function(){},"date").render(); h += "
"; } VAL = (eligible) ? eligible : "N"; if (VAL === "") { let target_va = getScenario_data("target_va", ""); if (target_va === "Y") { VAL = "Y"; } } h += "
"; h += frm.hr("Shrunk").render(); if (applicantnum == 0) { h += frm.yn3("eligible","Are you eligible, and would like to use your VA military rights?",VAL,"","",function(){ oc(); },{}).render(); } else { h += frm.yn3("eligible",na + " is eligible, and would like to use their VA military rights?",VAL,"","",function(){ oc(); },{}).render(); } h += "
"; VAL = (employment) ? employment : ""; h += "
"; h += frm.hr().render(); if (applicantnum == 0) { h += frm.radio("employment","How were you employed?",VAL,"","",function(){ oc(); },{ ng : "National Guard", reserves : "Reserves", regular : "Regular military" }).render(); } else { h += frm.radio("employment","How was "+na+" employed?",VAL,"","",function(){ oc(); },{ ng : "National Guard", reserves : "Reserves", regular : "Regular military" }).render(); } h += "
"; VAL = (firsttime) ? firsttime : ""; h += "
"; h += frm.hr().render(); if (applicantnum == 0) { h += frm.radio("firsttime","Have you used VA before?",VAL,"","",function(){ oc(); },{ firsttime : "First time user", usedbefore : "I have used a VA loan before" }).render(); } else { h += frm.radio("firsttime","Has "+na+" used VA before?",VAL,"","",function(){ oc(); },{ firsttime : "First time user", usedbefore : "I have used a VA loan before" }).render(); } h += "
"; VAL = (disabled) ? disabled : ""; h += "
"; h += frm.hr().render(); if (applicantnum == 0) { h += frm.yn3("disabled","Are you military disabled?",VAL,"","",function(){ oc(); },{}).render(); } else { h += frm.yn3("disabled","Is "+na+" military disabled?",VAL,"","",function(){ oc(); },{}).render(); } h += "
"; VAL = disabled_perc; h += "
"; h += frm.slider("disabled_percentage","What percentage?",VAL,"","",function(){ oc(); }, { v00 : '0', v50 : '50', v50_inc : '1', v75 : '75', v75_inc : '1', v100 : '100', v100_inc : '1', start_val : '10', formatting_class : '_perc' }).render(); h += "
"; h += (function(){ let h = ""; VAL = (nofee) ? nofee : ""; h += "
"; h += frm.hr().render(); if (applicantnum == 0) { h += frm.yn3("nofee","Are you exempt from paying VA funding fee? ",VAL,"","",function(){ oc(); },{}).render(); } else { h += frm.yn3("nofee","Is "+na+" exempt from paying VA funding fee? ",VAL,"","",function(){ oc(); },{}).render(); } h += "
"; h += "
"; return h; })(); VAL = (coe) ? coe : ""; h += "
"; h += frm.hr().render(); if (applicantnum == 0) { h += frm.yn3("coe","Do you have a Certificate of Eligibility for a VA loan? ",VAL,"","",function(){ oc(); },{}).render(); } else { h += frm.yn3("coe","Does "+na+" have a Certificate of Eligibility for a VA loan? ",VAL,"","",function(){ oc(); },{}).render(); } h += "
"; h += "
"; let oc = function(){ // let served = yn3("#served"); let served_opts = radio("served_opts"); let served = (typeof served_opts === "string" && served_opts.length === 2) ? served_opts.split("")[0] : ""; let active = (typeof served_opts === "string" && served_opts.length === 2) ? served_opts.split("")[1] : ""; let active_ed = txt("#active_ed") let eligible = yn3("#eligible"); let employment = radio("employment"); let firsttime = radio("firsttime"); let disabled = yn3("#disabled"); let disabled_percentage = txt("#disabled_percentage") let coe = yn3("#coe"); let nofee = yn3("#nofee"); $("#eligible-div").css("display","none"); $("#employment-div").css("display","none"); $("#firsttime-div").css("display","none"); $("#disabled-div").css("display","none"); $("#disabled-percentage-div").css("display","none"); $("#nofee-div").css("display","none"); $("#coe-div").css("display","none"); // $("#eligible-div").slideDown(function() { // $("#body-container").scrollTo("max",200); // }); if (served != "Y") { eligible = "N"; yn("#eligible","N"); employment = ""; radio("employment",""); firsttime = ""; radio("firsttime",""); disabled = "N"; txt("#disabled","N"); disabled_percentage = "5"; txt("#disabled_percentage","5"); coe = "N"; txt("#coe",""); } else { if (eligible != "Y") { employment = ""; radio("employment",""); firsttime = ""; radio("firsttime",""); disabled = "N"; txt("#disabled","N"); disabled_percentage = "5"; txt("#disabled_percentage","5"); coe = "N"; txt("#coe",""); } else { if (employment == "") { firsttime = ""; radio("firsttime",""); disabled = "N"; txt("#disabled","N"); disabled_percentage = "5"; txt("#disabled_percentage","5"); coe = "N"; txt("#coe",""); } else { if (firsttime == "") { disabled = "N"; yn("#disabled","N"); disabled_percentage = "5"; txt("#disabled_percentage","5"); coe = "N"; txt("#coe",""); } } } } setScenario_data("scenario_applicant"+applicantNum+"_served",served); setScenario_data("va_active"+applicantNum+"",active); setScenario_data("va_active_ed"+applicantNum+"",active_ed); setScenario_data("has_applicant"+applicantNum+"_served_in_us_forces",eligible); setScenario_data("va_employment"+applicantNum+"",employment); setScenario_data("vafirst_time_use"+applicantNum+"",firsttime); setScenario_data("va_disabled"+applicantNum+"",disabled); setScenario_data("va_disabled"+applicantNum+"_percentage",disabled_percentage); setScenario_data("va_coe"+applicantNum+"",coe); setScenario_data("va_nofee"+applicantNum+"",nofee); mar.fakesave(); $("#active_ed-div").addClass("x-hide"); if (served == "Y") { $("#eligible-div").css("display","block"); if (active == "A") { $("#active_ed-div").removeClass("x-hide"); } if (eligible == "Y") { $("#employment-div").css("display","block"); if (employment != "") { $("#firsttime-div").css("display","block"); if (firsttime != "") { $("#disabled-div").css("display","block"); $("#nofee-div").css("display","block"); console.log('disabled: '+disabled); if (disabled == "Y") { $("#disabled-percentage-div").css("display","block"); } if (nofee !== "") { $("#coe-div").css("display","block"); } } } } } $("#body-container").scrollTo("max",200); } h += "
"; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ // let served = yn("#served"); let served_opts = radio("served_opts"); let served = (typeof served_opts === "string" && served_opts.length === 2) ? served_opts.split("")[0] : ""; let active = (typeof served_opts === "string" && served_opts.length === 2) ? served_opts.split("")[1] : ""; let active_ed = txt("#active_ed") let eligible = yn("#eligible"); let employment = radio("employment"); let firsttime = radio("firsttime"); let disabled = yn("#disabled"); let disabled_percentage = txt("#disabled_percentage") let coe = yn("#coe"); let nofee = yn("#nofee"); setScenario_data("scenario_applicant"+applicantNum+"_served",served); setScenario_data("va_active"+applicantNum+"",active); setScenario_data("va_active_ed"+applicantNum+"",active_ed); setScenario_data("has_applicant"+applicantNum+"_served_in_us_forces",eligible); setScenario_data("va_employment"+applicantNum+"",employment); setScenario_data("vafirst_time_use"+applicantNum+"",firsttime); setScenario_data("va_disabled"+applicantNum+"",disabled); setScenario_data("va_disabled"+applicantNum+"_percentage",disabled_percentage); setScenario_data("va_coe"+applicantNum+"",coe); setScenario_data("va_nofee"+applicantNum+"",nofee); setScenario_data("__scenario_veteran_"+applicantnum+"_passed","Y"); mar.fakesave(function(){ if (mar.WE_ARE_FROM_LOI === true) { MAR.encompass.app_check_diffs_borrower_profileSync(mar.ID, applicantnum); } }); if (applicantnum === 0) { mvc.go("#scenario-housingbudget."+applicantnum); } else { mvc.go("#declarations-p1."+applicantnum); } // if (applicantnum === 0) { //// mvc.go("#scenario-ratequote."+applicantnum); // // } else { // mvc.go("#declarations-p1."+applicantnum); // // } // mvc.go("#scenario-borrowers."+applicantnum);u }),"Prev",frm.addfunction(function(){ mvc.go("#scenario-legalstatus."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let or = function(){ let sp = mar.isallowed_scenario("#scenario-veteran."+applicantnum); if (typeof sp === "string") { mvc.go(sp); return; } let passed = (getScenario_data("__scenario_veteran_"+applicantnum+"_passed","") === "Y"); let empty = (getScenario_data("scenario_applicant"+applicantNum+"_served","") === ""); if (passed === false || empty === true) { var target_va = getScenario_data("target_va",""); if (target_va === "N") { setScenario_data("scenario_applicant"+applicantNum+"_served","N"); setScenario_data("va_active"+applicantNum+"","N"); setScenario_data("va_active_ed"+applicantNum+"",""); setScenario_data("has_applicant"+applicantNum+"_served_in_us_forces","N"); setScenario_data("va_employment"+applicantNum+"",""); setScenario_data("vafirst_time_use"+applicantNum+"",""); setScenario_data("va_disabled"+applicantNum+"",""); setScenario_data("va_disabled"+applicantNum+"_percentage",""); setScenario_data("va_coe"+applicantNum+"",""); setScenario_data("va_nofee"+applicantNum+"",""); setScenario_data("__scenario_veteran_"+applicantnum+"_passed","Y"); mar.fakesave(); mvc.go("#declarations-p1."+applicantnum); return; } } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $(".whatscoe").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "If you have been honorably discharged from the Service, " + "you will receive a DD214. With this form you can request a Certificate of Eligibility (COE) " + "that will show your lender how much VA mortgage you can get.

If you don’t have this Certificate yet, no worries. " + "We will have you DocuSign form 1880, and you send us your DD214, we do the rest."; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); // swal({ // title : "What is a COE?", // className : "fred3", // content : s, // button : "got it" // }) }); $(".whatsnofee").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "When am I exempt from paying the VA Mortgage Insurance Funding fee? , " + "

"+ "The following do NOT pay the VA funding fee: "+ "
"+ "
"+ "
    "+ "
  • "+ "Veteran receiving VA compensation for a service-connected disability; "+ "
  • "+ "
  • "+ "Veteran entitled to receive VA compensation for a service-connected disability, but receives military retirement pay in lieu of compensation or active duty pay; "+ "
  • "+ "
  • "+ "Surviving spouse of one who died in service, from a service-connected cause, or totally disabled; and receiving Dependency and Indemnity Compensation (DIC); "+ "
  • "+ "
  • "+ "Servicemember with a proposed or memorandum rating from VA, prior to loan closing, as eligible to receive compensation as a result of a pre-discharge claim; "+ "
  • "+ "
  • "+ "Servicemember on active duty who provides, on or before the date of loan closing, evidence of having been awarded the Purple Heart"+ "
  • "+ "
"+ "
"+ ""; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); // swal({ // title : "What is a COE?", // className : "fred3", // content : s, // button : "got it" // }) }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { setTimeout(function() { $("#body-container").find(".xx-slider").myslider(); $("#body-container ._perc").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, suffix : "%", rightAlign: false, autoUnmask : true }); oc(); }) } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })() mar.pg["scenario-pastproperty"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var loan_type = getV2_data("loan_type","purchase"); var owned = getScenario_data("has_applicant"+applicantNum+"_owned_property_in_last_3_years",""); var otype = getScenario_data("has_applicant"+applicantNum+"_owned_property_in_last_3_years_type",""); var ohow = getScenario_data("has_applicant"+applicantNum+"_owned_property_in_last_3_years_how",""); var owns = getScenario_data("does_applicant"+applicantNum+"_own_property",""); let refi = (loan_type !== "purchase"); let purchase = (!refi); if (purchase) { var fthb = getScenario_data("target_fthb",""); if (owned === "") { owned = fthb; } } let h = ""; if (refi) { h += frm.htitle("Refinance Property").render(); } else { h += frm.htitle("First Time Home Buyer").render(); } if (refi && applicantnum == 0) { h += frm.elaine("Tell me a bit more about the property you want to refinance","er").render(); } else if (applicantnum == 0) { h += frm.elaine("I would like to know if you have owned a property before.","er").render(); } else { h += frm.elaine("I would like to know if "+na+" has owned a property before.","er").render(); } let DOYOU = (applicantnum == 0) ? "do you" : `does ${na}`; let DoYOU = (applicantnum == 0) ? "Do you" : `Does ${na}`; if (refi && applicantnum == 0) { VAL = ""; if (VAL === "") { let entered_occupancy = getScenario_data("occupancy_type",""); if (entered_occupancy === "occupancy_by_me") VAL = "1"; if (entered_occupancy === "occupancy_secondhom") VAL = "2"; if (entered_occupancy === "occupancy_investment") VAL = "D"; } h += ""; h += ""; h += "
"; h += ``; // h += frm.radio("otype","How do you use this property?",VAL,"","",function(){ // oc(); // },{ // "1" : "Primary residence", // "2" : "Second home", // "D" : "Investment property" // }).render(); VAL = ohow; h += "
"; h += frm.hr().render(); h += frm.radio("ohow",`How ${DOYOU} hold title on this property?`,VAL,"","",function(){ oc(); }, "01:Sole (Individual),"+ "25:Joint with spouse,"+ "26:Joint with other than spouse" ).render(); h += "
"; var oc_property_type = function() { if (MAR.is_refi() === false) { return; } /* I think this is depreciated */ return; var property_type = radio("property_type"); var property_type_other = txt("#property_type_other"); var monthly_rent = txt("#monthly_rent"); var use = getScenario_data("occupancy_type",""); var occupancy_type = use; if (property_type != "") { setScenario_data("property_type",property_type); setScenario_data("property_type_other",property_type_other); setScenario_data("monthly_rent",monthly_rent); mar.fakesave(); var _monthly_rent_display = "" if ((property_type != "" && property_type != "sfr" && property_type != "condo") || occupancy_type == "occupancy_investment") { if (occupancy_type == "occupancy_investment") { /** * investment property */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("What total monthly rental income do you make from this investment property"); } else { $(".property_income").html("What total monthly rental income do you expect from this investment property"); } } else { if (property_type == "condo") { /** * non investment - condo */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("What income do you make from the 2nd unit"); } else { $(".property_income").html("What income do you expect from the 2nd unit"); } } else if (property_type == "duplex") { /** * non investment - duplex */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("What income do you make from the 2nd unit"); } else { $(".property_income").html("What income do you expect from the 2nd unit"); } } else if (property_type == "triplex") { /** * non investment - triplex */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("What income do you make from the 2nd & 3rd units combined"); } else { $(".property_income").html("What income do you expect from the 2nd & 3rd units combined"); } } else if (property_type == "fourplex") { /** * non investment - fourplex */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("What income do you make from the 2nd,3rd & 4th units combined"); } else { $(".property_income").html("What income do you expect from the 2nd,3rd & 4th units combined"); } } else { /** * non investment - other */ if (mar.answers.loan_type == "refinance") { $(".property_income").html("If you make rental income please enter it here"); } else { $(".property_income").html("If you expect rental income please enter it here"); } } } } setTimeout(function(){ if (use != "occupancy_investment" && (property_type == "sfr" || property_type == "condo")) { $("#rental-div").css("display","none"); $("#rental-div .er1").css("display","none"); is_rental_income_visible = false; } else { if ($("#rental-div .er1").css("display") == "none") { $("#rental-div").css("display","block"); $("#mccincome-div").css("display","none"); is_rental_income_visible = true; $($("#rental-div .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false, }); } } $("#body-container").scrollTo("max",200); },1); } else { $("#rental-div").css("display","none"); $("#mccincome-div").css("display","none"); is_rental_income_visible = false; } } let hr = frm.hr().render(); var property_type = getScenario_data("property_type",""); h += ``; // h += (function(){ // // let h = ""; // var property_type = getScenario_data("property_type",""); // var property_type_other = getScenario_data("property_type_other",""); // var monthly_rent = getScenario_data("monthly_rent","0"); // var householdsize = getScenario_data("householdsize",""); // var householdincome = getScenario_data("householdincome",""); // // VAL = property_type; // h += frm.radio("property_type","What type of property is it?",VAL,"","",function(){ // if (oc_property_type) oc_property_type(); // // },{ // sfr : mar.txt._sfr, // condo : mar.txt._condo, // duplex : mar.txt._duplex, // triplex : mar.txt._triplex, // fourplex : mar.txt._fourplex, // other : mar.txt._other // }).render(); // // VAL = property_type_other; // h += "
" // h += frm.txt("timeframe_other","",VAL,"e.g. Fiveplex",function(){}).render(); // h += "
"; // // // // h += "
"; // h += frm.hr().render(); // h += frm.elaine("How much rental income do you expect from this purchase?","er1").render(); // // h += "
"; // VAL = monthly_rent; // h += frm.slider("monthly_rent","Estimated monthly income:",VAL,"","",function(){ // if (oc_property_type) oc_property_type(); // }, { // placeholder :'', // formatting_class : "_dollars", // v00 : '0', // v50 : '2000', // v50_inc : '100', // v75 : '4000', // v75_inc : '100', // v100 : '8000', // v100_inc : '250', // start_val : '100' // }).render(); // h += "
"; // h += "
"; // // return h; // })().wrap(`
${hr}`,"
"); h += "
"; } else { h += "
"; VAL = owned; if (applicantnum == 0) { h += frm.yn3("owned","Do you own property now, or have you owned property in the last 3 years?",VAL,"","",function(){ oc(); },{}).render(); } else { h += frm.yn3("owned","Does "+na+" own property now, or have they owned property in the last 3 years?",VAL,"","",function(){ oc(); },{}).render(); } h += "
"; h += frm.hr().render(); h += frm.elaine("Ok, great. Tell me a bit more about this property.","er1").render(); VAL = otype; h += "
"; h += frm.radio("otype","What type of property?",VAL,"","",function(){ oc(); },{ "1" : "Primary residence", "2" : "Second home", "D" : "Investment property" }).render(); h += "
"; h += "
"; VAL = ohow; h += "
"; h += frm.hr().render(); h += frm.radio("ohow",`How did/${DOYOU} hold title on this or any property?`,VAL,"","",function(){ oc(); }, "01:Sole (Individual),"+ "25:Joint with spouse,"+ "26:Joint with other than spouse" ).render(); h += "
"; VAL = owns; h += "
"; h += frm.hr().render(); h += frm.yn3("owns",`${DoYOU} currently own this or any property?`,VAL,"","",function(){ oc(); },{}).render(); h += "
"; h += "
"; } let oc = function(quick) { var owned = yn3("#owned"); var otype = radio("otype"); var ohow = radio("ohow"); var owns = yn3("#owns"); if (owned != "Y") { otype = ""; radio("otype",""); ohow = ""; radio("ohow",""); owns = ""; yn("#owns","N"); $("#otype-div").css("display","none"); $("#firsttime-div").css("display","none"); $("#ohow-div").css("display","none"); $("#owns-div").css("display","none"); } else if (otype == "") { ohow = ""; radio("ohow",""); owns = ""; yn("#owns","N"); $("#ohow-div").css("display","none"); $("#owns-div").css("display","none"); } else if (ohow == "") { owns = ""; yn("#owns","N"); $("#owns-div").css("display","none"); } setScenario_data("has_applicant"+applicantNum+"_owned_property_in_last_3_years",owned); setScenario_data("has_applicant"+applicantNum+"_owned_property_in_last_3_years_type",otype); setScenario_data("has_applicant"+applicantNum+"_owned_property_in_last_3_years_how",ohow); setScenario_data("does_applicant"+applicantNum+"_own_property",owns); if (MAR.is_refi() && applicantnum == 0) { if (otype === "1") setScenario_data("occupancy_type","occupancy_by_me"); if (otype === "2") setScenario_data("occupancy_type","occupancy_secondhom"); if (otype === "D") setScenario_data("occupancy_type","occupancy_investment"); let sp = MAR.reo.getSubjectProperty(); if (sp !== false) { if (otype === "1") MAR.reo.setByUUID(sp.uuid, { reo_use : "primary" }); if (otype === "2") MAR.reo.setByUUID(sp.uuid, { reo_use : "secondary" }); if (otype === "D") MAR.reo.setByUUID(sp.uuid, { reo_use : "investment" }); } } mar.fakesave(); if (owned == "Y") { var ftd = $("#firsttime-div").css("display"); $("#firsttime-div").css("display","block"); $("#firsttime-div .er1").css("display","block"); if (quick || ftd != "none") { if (otype != "") { $("#ohow-div").css("display","block"); if (ohow != "") { $("#owns-div").css("display","block"); } } } else { $("#firsttime-div .er1").css("display","none"); $($("#firsttime-div .xhuman")[0]).Humanize({ opts : { fn : function() { if (otype != "") { $("#ohow-div").css("display","block"); if (ohow != "") { $("#owns-div").css("display","block"); } } } }, quick : false, }); } } $("#body-container").scrollTo("max",200); } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var owned = yn("#owned"); var otype = radio("otype"); var ohow = radio("ohow"); var owns = yn("#owns"); if (owned == "Y") { if (otype == "") { mar.tip(".help-button","warning","you need to select a type of property before continuing","top"); return false; } if (ohow == "") { mar.tip(".help-button","warning","you need to select a type of property before continuing","top"); return false; } } if (MAR.is_refi()) { if (otype === "1") setScenario_data("occupancy_type","occupancy_by_me"); if (otype === "2") setScenario_data("occupancy_type","occupancy_secondhom"); if (otype === "D") setScenario_data("occupancy_type","occupancy_investment"); } setScenario_data("has_applicant"+applicantNum+"_owned_property_in_last_3_years",owned); setScenario_data("has_applicant"+applicantNum+"_owned_property_in_last_3_years_type",otype); setScenario_data("has_applicant"+applicantNum+"_owned_property_in_last_3_years_how",ohow); setScenario_data("does_applicant"+applicantNum+"_own_property",owns); setScenario_data("__scenario_pastproperty_"+applicantnum+"_passed","Y"); mar.fakesave(function(){ if (mar.WE_ARE_FROM_LOI === true) { MAR.encompass.app_check_diffs_borrower_profileSync(mar.ID, applicantnum); } }); mvc.go("#scenario-legalstatus."+applicantnum); // mvc.go("#scenario-ratequote."+applicantnum); }),"Prev",frm.addfunction(function(){ // mvc.go("#scenario-veteran."+applicantnum); // mvc.go("#scenario-housingbudget."+applicantnum); mvc.go("#scenario-creditscore."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let or = function(){ let sp = mar.isallowed_scenario("#scenario-pastproperty."+applicantnum); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container .xx-slider").myslider(); oc(true); if (oc_property_type) oc_property_type(); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["scenario-hoi"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { var i_know = getScenario_data("scenario_i_know_my_insurance",""); var square_foot = getScenario_data("square_foot","1700"); var build_period = getScenario_data("build_period","1974"); var hoi_cost = getScenario_data("refi_home_insurance_cost","2000"); var near_water = getScenario_data("property_near_to_water",""); let has_visited = (getScenario_data("__hasvisited_hoi","N") == "Y") let revealclass = (has_visited) ? "" : "x-hide x-revealdiv"; // reveal .1 let h = ""; h += frm.htitle("Homeowners insurance").render(); h += frm.elaine("Let's try to estimate your new homeowners insurance cost.","er").render(); h += "
"; VAL = near_water; h += frm.yn3("near_water","Will your property be near water in a flood zone?",VAL,"","",function(){ oc(); },{}).render(); h += "
"; // reveal - start h += frm.hr().render(); VAL = i_know; h += frm.yn3("i_know","Can you estimate your homeowners insurance premium?",VAL,"","",function(){ oc(); },{}).render(); VAL = square_foot; h += "
"; h += frm.elaine("Estimate the square footage and the year built of the property you intend to buy.","er1").render(); h += "
"; h += frm.slider("square_foot","Square footage estimate:",VAL,"","",function(){ oc(); }, { v00 : '500', v50 : '2500', v50_inc : '100', v75 : '3700', v75_inc : '100', v100 : '5500', v100_inc : '100', start_val : '2000', formatting_class : '_sqft' }).render(); h += "
sq ft
"; VAL = build_period; h += frm.slider("build_period","Year built estimate:",VAL,"","",function(){ oc(); }, { v00 : '1700', v50 : '1925', v50_inc : '1', v75 : '1990', v75_inc : '1', v100 : '2018', v100_inc : '1', start_val : '1975', formatting_class : '_none' }).render(); h += frm.hr().render(); // h += "
"; h += "
"; h += "
"; VAL = hoi_cost; h += "
"; h += frm.slider("hoi_cost","My homeowners insurance cost annually:",VAL,"","",function(){ oc(); }, { v00 : '400', v50 : '3000', v50_inc : '100', v75 : '5500', v75_inc : '200', v100 : '15000', v100_inc : '500', start_val : '2400' }).render(); h += "
"; h += "
"; h += "
" // reveal - end h += "
"; //end er h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var val; /** * validation & reveal block start */ // let $reveals = $(".x-revealdiv"); // // if ($reveals.length > 0) { // let $elm = $($reveals[0]); // // // // $elm.slideDown(function(){ // $elm.removeClass("x-hide").removeClass("x-revealdiv"); // $("#body-container").scrollTo("max",200); // }); // return; // } /** * validation & reveal block end */ var i_know = yn3("#i_know"); var square_foot = txt("#square_foot"); var build_period = txt("#build_period"); var hoi_cost = txt("#hoi_cost"); var near_water = yn3("#near_water"); /** * warning check */ if (near_water.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if your house is in a flood zone.","top"); return; } if (i_know.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you can estimate your insurance or if you want us to do it for you.","top"); return; } if (i_know.trim() == "Y") { if (hoi_cost.trim().length == 0) { mar.tip(".help-button","warning","You need to tell give us an estimate of your insurance.","top"); return; } } if (i_know.trim() == "N") { if (square_foot.trim().length == 0) { mar.tip(".help-button","warning","You need to tell give us an estimate of your square footage.","top"); return; } if (build_period.trim().length == 0) { mar.tip(".help-button","warning","You need to tell give us an estimate of your build period.","top"); return; } } /* if (hoi_cost.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us your home owners insurance cost.","top"); return; } */ // so it shows if you have already been there setScenario_data("__hasvisited_hoi","Y"); /** * warning check end */ setScenario_data("scenario_i_know_my_insurance",i_know); setScenario_data("square_foot",square_foot); setScenario_data("build_period",build_period); setScenario_data("refi_home_insurance_cost",hoi_cost); setScenario_data("property_near_to_water",near_water); setScenario_data("__scenario_"+"hoi"+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-hoa"); }),"Prev",frm.addfunction(function(){ mvc.go("#scenario-tax"); }),"mar.help()"); h = Mustache.render(h,localopts); // mar.clear = function(){ // delScenario_data("scenario_i_know_my_insurance"); // delScenario_data("square_foot"); // delScenario_data("build_period"); // delScenario_data("refi_home_insurance_cost"); // delScenario_data("property_near_to_water"); // delScenario_data("__hasvisited_hoi"); // mvc.go("#scenario-hoi"); // } let oc = function(initial) { var i_know = yn3("#i_know"); var square_foot = txt("#square_foot"); var build_period = txt("#build_period"); var hoi_cost = txt("#hoi_cost"); var near_water = yn3("#near_water"); if (near_water == "") { $("#below-flood-div").addClass("x-hide"); } else if (i_know == "") { $("#square_foot-div").addClass("x-hide"); $("#hoi-div").addClass("x-hide"); $("._estimate").html(""); $elm = $("#below-flood-div"); if ($elm.hasClass("x-hide")) { $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); } } else if (i_know == "Y") { $("#below-flood-div").removeClass("x-hide"); $("#square_foot-div").removeClass("x-hide"); $("#hoi-div").removeClass("x-hide"); $("#hoi-div").css("display","block"); $("#square_foot-div").css("display","none"); if (near_water != "") { var incflood = (near_water == "Y") ? "Home and flood" : "Home"; var h = ""; var est1 = ""; est1 += frm.hr().render(); est1 +="
"+incflood+" insurance:
"; est1 += "
"; est1 +="
"; est1 +="
Yearly fee
$"+Math.floor(hoi_cost)+"
"; est1 +="
"; est1 +="
"; est1 +="
OR
"; est1 +="
"; est1 +="
"; est1 +="
Monthly fee
$"+Math.floor(hoi_cost/12)+"
"; est1 +="
"; est1 +="
"; $("._estimate").html(est1); } else { $("._estimate").html(""); } } else { $("#below-flood-div").removeClass("x-hide"); $("#hoi-div").css("display","none"); if (initial || $("#square_foot-div").css("display") != "block") { $("#square_foot-div").css("display","block"); $("#square_foot-div .er1").css("display","none"); $($("#square_foot-div .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200,{ axis : "y" }); } }, quick : initial, }); } // fron scenario var scenario_near_water = near_water; //var scenario_flood = txt("#scenario_flood"); // if (scenario_near_water == "Y" && (REFI || PURCHASE_AND_UNDER_CONTRACT)) { // $(".near_a_flood_zone").removeClass("x-hide"); // } else { // $(".near_a_flood_zone").addClass("x-hide"); // } // var recalc_needed = false; var sqft = square_foot; var yr = build_period; var cnty = county_number(getScenario_data("property_county","")); var ptype = getScenario_data("property_type",""); var near_water = near_water; if (!mar.answers.v2.scenario.hoi_estimate || !mar.answers.v2.scenario.property_type ) { mar.answers.v2.scenario.hoi_estimate = { square_foot : 0, build_period : 0, county_number : "", property_type : "", near_water : false, community_option : "" }; } if (mar.answers.v2.scenario.hoi_estimate.square_foot != sqft) recalc_needed = true; if (mar.answers.v2.scenario.hoi_estimate.build_period != yr) recalc_needed = true; if (mar.answers.v2.scenario.hoi_estimate.county_number != cnty) recalc_needed = true; if (mar.answers.v2.scenario.hoi_estimate.property_type != ptype) recalc_needed = true; if (mar.answers.v2.scenario.hoi_estimate.near_water != near_water) recalc_needed = true; if (!mar.answers.v2.scenario.hoi_estimate.ins_estimate) recalc_needed = true; if (!mar.answers.v2.scenario.hoi_estimate.flood_estimate) recalc_needed = true; if (recalc_needed) { mar.answers.v2.scenario.hoi_estimate.square_foot = sqft; mar.answers.v2.scenario.hoi_estimate.build_period = yr; mar.answers.v2.scenario.hoi_estimate.county_number = cnty; mar.answers.v2.scenario.hoi_estimate.property_type = ptype; mar.answers.v2.scenario.hoi_estimate.near_water = near_water; mar.answers.v2.scenario.hoi_estimate.community_option = ""; } var incflood = (near_water == "Y") ? "home and flood" : "home"; if (recalc_needed) { var _e = mar.answers.v2.scenario.hoi_estimate; $(".quoteHolder").addClass("rotating"); mar.calsHomeOwnersInsurance(_e.square_foot, _e.build_period, _e.county_number, _e.property_type, _e.near_water, _e.community_option, function(v1,v2,v3,v4) { mar.answers.v2.scenario.hoi_estimate.ins_estimate = num(v1).toFixed(0); mar.answers.v2.scenario.hoi_estimate.flood_estimate = num(v2).toFixed(0); mar.answers.v2.scenario.hoi_estimate.hoa_estimate = num(v3).toFixed(0); mar.answers.v2.scenario.hoi_estimate.prop_tax_percentage_pm = num(v4); var _estimate = (num(mar.answers.v2.scenario.hoi_estimate.ins_estimate) + num(mar.answers.v2.scenario.hoi_estimate.flood_estimate)); var h = ""; // var est = "Our estimate is $"+mar.answers.v2.scenario.hoi_estimate.ins_estimate+"/y or $"+Math.floor(mar.answers.v2.scenario.hoi_estimate.ins_estimate/12)+"/month"; var est = "
"; est +="
Estimated "+incflood+" insurance:
"; est +="
"; est +="
Yearly fee
$"+Math.floor(_estimate*12)+"
"; est +="
"; est +="
"; est +="
OR
"; est +="
"; est +="
"; est +="
Monthly fee
$"+Math.floor(_estimate)+"
"; est +="
"; est +="
"; $("._estimate").html(est); mar.fakesave(); }); } else { var h = ""; //var est = "Our estimate is $"+mar.answers.v2.scenario.hoi_estimate.ins_estimate+"/y or $"+Math.floor(mar.answers.v2.scenario.hoi_estimate.ins_estimate/12)+"/month"; var _estimate = (num(mar.answers.v2.scenario.hoi_estimate.ins_estimate) + num(mar.answers.v2.scenario.hoi_estimate.flood_estimate)); var est = "
"; est +="
Estimated "+incflood+" insurance:
"; est +="
"; est +="
Yearly fee
$"+Math.floor(_estimate*12)+"
"; est +="
"; est +="
"; est +="
OR
"; est +="
"; est +="
"; est +="
Monthly fee
$"+Math.floor(_estimate)+"
"; est +="
"; est +="
"; $("._estimate").html(est).removeClass("comein2").addClass("comein2"); } } $("#body-container").scrollTo("max",200,{ axis : "y" }); recalc_display_needed = true; } let or = function(){ let sp = mar.isallowed_scenario("#scenario-hoi"); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //console.warn ('input mask: ', $("#body-container ._sqft").inputmask); $("#body-container ._sqft").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character postfix: 'sq ft', rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "estimate" } })(); mar.pg["scenario-hoa"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { var hoa = getScenario_data("property_type_community_options",""); var property_type = getScenario_data("property_type",""); if (property_type == "condo") { var hoa_estimate = getScenario_data("hoa_estimate","300"); } else { var hoa_estimate = getScenario_data("hoa_estimate","50"); } var square_foot = getScenario_data("square_foot","1800"); let h = ""; h += frm.htitle("HOMEOWNER ASSOCIATION FEES").render(); h += frm.elaine("Let's estimate your homeowner association fees.","er").render(); h += "
"; VAL = hoa; if(VAL == ''){ VAL = 'non'; } h += frm.radio("hoa","The property I am interested in: ",VAL,"","",function(){ oc(); },{ "non" : "Has no HOA fees", "cknow" : "Has HOA fees and I know what they are", "chigh" : "Is a luxury community with high fees", "clow" : "Is a normal community with reasonable fees" }).render(); VAL = hoa_estimate; h += "
" h += frm.slider("hoa_estimate","HOA fees:",VAL,"","",function(){ oc(); }, { v00 : '5', v50 : '150', v50_inc : '5', v75 : '750', v75_inc : '25', v100 : '2500', v100_inc : '50', start_val : '5', placeholder : 'e.g. $3,000' }).render(); h += "
"; h += "
"; VAL = square_foot; h += "
"; h += frm.elaine("Estimate the square footage of the property you intend to buy.","er1").render(); h += "
"; h += frm.slider("square_foot","Square footage estimate:",VAL,"","",function(){ oc(); }, { v00 : '500', v50 : '2500', v50_inc : '100', v75 : '3700', v75_inc : '100', v100 : '5500', v100_inc : '100', start_val : '2000', formatting_class : '_sqft' }).render(); h += "
sq ft
"; h += "
"; h += "
"; h += "
"; // h += "
"; //h += "
"; h += "
"; /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var hoa = radio("hoa"); var hoa_estimate = txt("#hoa_estimate"); var square_foot = txt("#square_foot"); if (hoa == "") { mar.tip(".help-button","warning","You need to choose an option before proceeding","top"); return; } setScenario_data("property_type_community_options",hoa); setScenario_data("hoa_estimate",hoa_estimate); setScenario_data("square_foot",square_foot); setScenario_data("__scenario_"+"hoa"+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-budget1"); }),"Prev",frm.addfunction(function(){ mvc.go("#scenario-hoi"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(initial) { var hoa = radio("hoa"); var hoa_estimate = txt("#hoa_estimate"); var square_foot = txt("#square_foot"); if (hoa == "cknow") { $("#square_foot-div").css("display","none"); $("#hoa-div").css("display","block"); var h = ""; var est1 = ""; est1 += frm.hr().render(); est1 += "
"; est1 +="
"; est1 +="
Yearly fee
$"+Math.floor(hoa_estimate*12)+"
"; est1 +="
"; est1 +="
"; est1 +="
OR
"; est1 +="
"; est1 +="
"; est1 +="
Monthly fee
$"+Math.floor(hoa_estimate)+"
"; est1 +="
"; est1 +="
"; $("._estimate").html(est1); } else if (hoa == "non" || hoa == "") { $("#square_foot-div").css("display","none"); $("#hoa-div").css("display","none"); $("._estimate").html(""); } else { if ( initial || $("#square_foot-div").css("display") != "block") { $(".er1").css("display","none"); $("#square_foot-div").css("display","block"); $($("#square_foot-div .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200,{ axis : "y" }); } }, quick : initial, }); } $("#hoa-div").css("display","none"); // from scenario /** * tax */ var recalc_needed = false; var scenario_hoa = hoa; var copt = hoa; var sqft = square_foot; var cnty = county_number(getScenario_data("property_county","")); var ptype = getScenario_data("property_type",""); if (!mar.answers.v2.scenario.hoi_estimate || !mar.answers.v2.scenario.property_type ) { mar.answers.v2.scenario.hoi_estimate = { square_foot : 0, build_period : 0, county_number : "", property_type : "", near_water : false, community_option : "" }; } if (mar.answers.v2.scenario.hoi_estimate.square_foot != sqft) recalc_needed = true; if (mar.answers.v2.scenario.hoi_estimate.county_number != cnty) recalc_needed = true; if (mar.answers.v2.scenario.hoi_estimate.property_type != ptype) recalc_needed = true; if (mar.answers.v2.scenario.hoi_estimate.community_option != copt) recalc_needed = true; if (!mar.answers.v2.scenario.hoi_estimate.hoa_estimate) recalc_needed = true; if (recalc_needed) { mar.answers.v2.scenario.hoi_estimate.square_foot = sqft; mar.answers.v2.scenario.hoi_estimate.county_number = cnty; mar.answers.v2.scenario.hoi_estimate.property_type = ptype; mar.answers.v2.scenario.hoi_estimate.community_option = copt; } if (recalc_needed) { var _e = mar.answers.v2.scenario.hoi_estimate; mar.calsHomeOwnersInsurance(_e.square_foot, _e.build_period, _e.county_number, _e.property_type, _e.near_water, _e.community_option, function(v1,v2,v3,v4) { mar.answers.v2.scenario.hoi_estimate.ins_estimate = num(v1).toFixed(0); mar.answers.v2.scenario.hoi_estimate.flood_estimate = num(v2).toFixed(0); mar.answers.v2.scenario.hoi_estimate.hoa_estimate = num(v3).toFixed(0); mar.answers.v2.scenario.hoi_estimate.prop_tax_percentage_pm = num(v4); var h = ""; //var est = "Our estimate is $"+mar.answers.v2.scenario.hoi_estimate.hoa_estimate+"/y or $"+Math.floor(mar.answers.v2.scenario.hoi_estimate.hoa_estimate/12)+"/month"; var est = ""; est += frm.hr().render(); est += "
"; est +="
Estimated homeowner association fees:
"; est +="
"; est +="
Yearly fee
$"+Math.floor(mar.answers.v2.scenario.hoi_estimate.hoa_estimate*12)+"
"; est +="
"; est +="
"; est +="
OR
"; est +="
"; est +="
"; est +="
Monthly fee
$"+Math.floor(mar.answers.v2.scenario.hoi_estimate.hoa_estimate)+"
"; est +="
"; est +="
"; $("._estimate").html(est); h += est; mar.fakesave(); }); } else { var h = ""; var est1 = ""; est1 += frm.hr().render(); est1 += "
"; est1 +="
Estimated homeowner association fees:
"; est1 +="
"; est1 +="
Yearly fee
$"+Math.floor(mar.answers.v2.scenario.hoi_estimate.hoa_estimate*12)+"
"; est1 +="
"; est1 +="
"; est1 +="
OR
"; est1 +="
"; est1 +="
"; est1 +="
Monthly fee
$"+Math.floor(mar.answers.v2.scenario.hoi_estimate.hoa_estimate)+"
"; est1 +="
"; est1 +="
"; $("._estimate").html(est1); } } $("#body-container").scrollTo("max",200,{ axis : "y" }); } let or = function(){ let sp = mar.isallowed_scenario("#scenario-hoa"); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //console.warn ('input mask: ', $("#body-container ._sqft").inputmask); $("#body-container ._sqft").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character postfix: 'sq ft', rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "estimate" } })(); mar.pg["scenario-tax"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { var i_know = getScenario_data("scenario_i_know_my_tax",""); var scenario_tax = getScenario_data("scenario_tax","2500"); var goals_target_value = getScenario_data("goals_target_value","250000"); var i_know_raw = i_know; if (i_know == "") i_know = ""; if (scenario_tax == "") scenario_tax = 2500; if (goals_target_value == "") scenario_tax = 250000; mar.clear = function() { delScenario_data("scenario_i_know_my_tax"); delScenario_data("scenario_tax"); mvc.go("#scenario-tax"); } let loan_time = getScenario_data("loan_type_purchase_options",""); console.warn("loan time: ", loan_time); let h = ""; let st = ''; h += frm.htitle("taxes").render(); if(loan_time == 'contract'){ h += frm.elaine("How much will you pay in property taxes each year?","er").render(); }else{ h += frm.elaine("Let's make an estimate of how much you will be paying in property taxes each year.","er").render(); } h += "
"; // h += "
What purchase price do you have in mind?
"; // // VAL = goals_target_value; // h += frm.slider("goals_target_value","Approx.",VAL,"","",function(){ // oc(); // }, { // v00 : '50000', // v50 : '250000', // v50_inc : '5000', // v75 : '750000', // v75_inc : '50000', // v100 : '1500000', // v100_inc : '100000', // start_val : '250000' // }).render(); // // h += frm.hr().render(); VAL = i_know; if(loan_time == 'contract'){ if(i_know_raw == ''){ VAL = ''; } h += frm.yn3("i_know","I know how much my taxes are annually?",VAL,"","",function(){ oc(); },{}).render(); }else{ h += frm.yn3("i_know","I know (roughly) how much my taxes are annually?",VAL,"","",function(){ oc(); },{}).render(); } VAL = num(scenario_tax); h += "
"; h += "
My annual property tax is:
"; if(loan_time == 'contract'){ h += frm.slider("scenario_tax","",VAL,"","",function(){ oc(); }, { v00 : '700', v50 : '2000', v50_inc : '100', v75 : '8000', v75_inc : '250', v100 : '30000', v100_inc : '500', start_val : '2000', placeholder : 'e.g. $3,500' }).render(); }else{ h += frm.slider("scenario_tax","Approx:",VAL,"","",function(){ oc(); }, { v00 : '700', v50 : '2000', v50_inc : '100', v75 : '8000', v75_inc : '250', v100 : '30000', v100_inc : '500', start_val : '2000', placeholder : 'e.g. $3,500' }).render(); } h += "
"; h += frm.hr().render(); h += "
"; h += "
"; h += "
" h += "
"; /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var i_know = yn3("#i_know"); if (i_know == "") { mar.tip(".help-button","warning","You need to choose either Yes or No..","top"); return; } var scenario_tax = txt("#scenario_tax"); var goals_target_value = getScenario_data("goals_target_value","250000"); setScenario_data("scenario_i_know_my_tax",i_know); setScenario_data("scenario_tax",scenario_tax); setScenario_data("__scenario_"+"tax"+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-hoi"); }),"Prev",frm.addfunction(function(){ mvc.go("#scenario-purchaseprice"); // mvc.go("#scenario-budget"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { var i_know = yn3("#i_know"); var scenario_tax = txt("#scenario_tax"); var goals_target_value = getScenario_data("goals_target_value","250000"); setScenario_data("scenario_i_know_my_tax",i_know); setScenario_data("scenario_tax",scenario_tax); mar.fakesave(); if (i_know == "") { $("#tax-div").css("display","none"); $("#dontknow-div").css("display","none"); } else if (i_know == "Y") { $("#tax-div").css("display","block"); $("#dontknow-div").css("display","none"); var _est = num(scenario_tax); var est = "
"; if(loan_time == 'contract'){ est +="
Property taxes:
"; }else{ est +="
Estimated property taxes:
"; } est +="
"; est +="
Yearly fee
$"+Math.floor(_est)+"
"; est +="
"; est +="
"; est +="
OR
"; est +="
"; est +="
"; est +="
Monthly fee
$"+Math.floor(_est/12)+"
"; est +="
"; est +="
"; $("._estimate").html(est); } else { $("#tax-div").css("display","none"); $("#dontknow-div").css("display","block"); // from scenario /** * tax */ var recalc_needed = false; var scenario_i_know_my_tax = i_know; var sqft = "2000"; var cnty = county_number(getScenario_data("property_county","")); var ptype = getScenario_data("property_type",""); var hoiest = getScenario_data("hoi_estimate",false); // hoiest = false; // - force a test if (hoiest == false || "prop_tax_percentage_pm" in hoiest == false) { mar.socket.send_and_receive("api-app-looku-hoi-counties",{ county : cnty }, function(da){ // $.get("/calc/lookup_HOI_counties?county="+cnty, function(da){ if ( hoiest == false) mar.answers.v2.scenario.hoi_estimate = {}; if (da && "data" in da && "Property_Tax" in da.data) { mar.answers.v2.scenario.hoi_estimate.prop_tax_percentage_pm = parseFloat(da.data.Property_Tax,10); mar.fakesave(); var _est = goals_target_value * mar.answers.v2.scenario.hoi_estimate.prop_tax_percentage_pm; var est = "
"; est +="
Estimated property taxes:
"; est +="
"; est +="
Yearly fee
$"+Math.floor(_est)+"
"; est +="
"; est +="
"; est +="
OR
"; est +="
"; est +="
"; est +="
Monthly fee
$"+Math.floor(_est/12)+"
"; est +="
"; est +="
"; $("._estimate").html(est); } },5000) } else { try { var _est = goals_target_value * mar.answers.v2.scenario.hoi_estimate.prop_tax_percentage_pm; } catch (E) { var _est = 0; } var est = "
"; est +="
Estimated property taxes:
"; est +="
"; est +="
Yearly fee
$"+Math.floor(_est)+"
"; est +="
"; est +="
"; est +="
OR
"; est +="
"; est +="
"; est +="
Monthly fee
$"+Math.floor(_est/12)+"
"; est +="
"; est +="
"; $("._estimate").html(est); } // var est = goals_target_value * mar.answers.v2.scenario.hoi_estimate.prop_tax_percentage_pm; // $(".tax-estimate").html(est); // if (!mar.answers.v2.scenario.hoi_estimate || !mar.answers.v2.scenario.property_type ) { // mar.answers.v2.scenario.hoi_estimate = { // square_foot : 0, // build_period : 0, // county_number : "", // property_type : "", // near_water : false, // community_option : "" // }; // } // if (mar.answers.v2.scenario.hoi_estimate.square_foot != sqft) recalc_needed = true; // if (mar.answers.v2.scenario.hoi_estimate.county_number != cnty) recalc_needed = true; // if (mar.answers.v2.scenario.hoi_estimate.property_type != ptype) recalc_needed = true; // if (!mar.answers.v2.scenario.hoi_estimate.hoa_estimate) recalc_needed = true; // if (recalc_needed) { // mar.answers.v2.scenario.hoi_estimate.square_foot = sqft; // mar.answers.v2.scenario.hoi_estimate.county_number = cnty; // mar.answers.v2.scenario.hoi_estimate.property_type = ptype; // } // if (recalc_needed) { // var _e = mar.answers.v2.scenario.hoi_estimate; // // mar.calsHomeOwnersInsurance(_e.square_foot, _e.build_period, _e.county_number, _e.property_type, _e.near_water, _e.community_option, function(v1,v2,v3,v4) { // mar.answers.v2.scenario.hoi_estimate.ins_estimate = num(v1).toFixed(0); // mar.answers.v2.scenario.hoi_estimate.flood_estimate = num(v2).toFixed(0); // mar.answers.v2.scenario.hoi_estimate.hoa_estimate = num(v3).toFixed(0); // mar.answers.v2.scenario.hoi_estimate.prop_tax_percentage_pm = num(v4); // // var h = ""; // var est = "Est. $"+mar.answers.v2.scenario.hoi_estimate.ins_estimate; // if (mar.answers.v2.scenario.hoi_estimate.flood_estimate) est += ", flood : $"+mar.answers.v2.scenario.hoi_estimate.flood_estimate // $(".insurance_estimate").html(est); // h += est; // mar.fakesave(); // swal(h) // }); // } else { // var h = ""; // var est = "Est. $"+mar.answers.v2.scenario.hoi_estimate.ins_estimate; // if (mar.answers.v2.scenario.hoi_estimate.flood_estimate) est += ", flood : $"+mar.answers.v2.scenario.hoi_estimate.flood_estimate // $(".insurance_estimate").html(est); // h += est; // swal(h) // } } $("#body-container").scrollTo("max",200,{ axis : "y" }); } let or = function(){ let sp = mar.isallowed_scenario("#scenario-tax"); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //console.warn ('input mask: ', $("#body-container ._sqft").inputmask); $("#body-container ._sqft").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character postfix: 'sq ft', rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "estimate" } })(); mar.calculatepartfinal_fn = false; mar.calculatepartfinal = function(fn) { if (arguments.length > 0) mar.calculatepartfinal_fn = fn; for (var _m in mar.mortgagesc) { if (mar.mortgagesc[_m] == false) { mar.calculatepart1(mar.state.goals_target_value,_m); return; } } if (mar.calculatepartfinal_fn) { let tol = mar.calculatepart1_tol; elaine_adapter.mortgage.getcachelist(mar.ID, `wl_${tol}_`, function(list) { // cnt : cnt, // cnt_matched : cnt_matched, // cnt_tot : cnt_total, // txt : "cnt "+cnt+" matched "+cnt_matched +" , "+goals_target_c2c_low +"-"+goals_target_c2c_high+ " , "+goals_target_budget_low+"-"+goals_target_budget_high+" , "+goals_target_value + db mar.calculatepartfinal_fn({ cnt : 0, cnt_matched : list.cnt_matched, cnt_tot : list.cnt_total, txt : "done" }); }); } // debugger; // var goals_target_value = getScenario_data("goals_target_value","250000"); // var goals_target_budget = getScenario_data("goals_target_budget","10000"); // var goals_target_budget = getScenario_data("goals_target_budget","10000"); // var goals_target_c2c_low = getScenario_data("goals_target_c2c_low","20000"); // var goals_target_c2c_high = getScenario_data("goals_target_c2c_high","20000"); var __display = function() { console.warn(mar.mortgage); $("#budget-needed").html(""+mar.fmt.currency(parseInt(mar.mortgage.filters.budget, 10))+""); $(".sliderAmtPercentage").text(mar.mortgage.filters.down+"%"); var na = getApplicantsNames_v2(0).Name; var pbp = "
 
OUR LOAN ESTIMATE

"+na + ""+ ", we will need " + ""+ mar.fmt.currency(parseInt(mar.mortgage.filters.c2c, 10))+ "" + " to close on a purchase price of " + "" + mar.fmt.currency((mar.mortgage.filters.purchace_price))+ ""+ ". This property will cost you an estimated " + "" + mar.fmt.currency(parseInt(mar.mortgage.filters.budget, 10))+ ""+ " per month, out the door. Will this work for you?"+ "
"; $("#personal_mortgage_proposal_2").html(pbp); $("#personal_mortgage_proposal").html(pbp); var _result = ""; _result += "
Do you have access to enough cash?
"; _result += "
"; _result += "
"; _result += "
"; _result += "Est. max. loan amount"; _result += "
"; _result += "
"; _result += "" + parseInt(mar.mortgage.filters.purchase_price, 10)+""; _result += "
"; _result += "
"; _result += "
"; _result += "
"; _result += "Est. closing cost"; _result += "
"; _result += "
"; _result += "" + parseInt(mar.mortgage.filters.c2c, 10)+""; _result += "
"; _result += "
"; _result += "
"; _result += "
"; _result += "Minimum cash to close"; _result += "
"; _result += "
"; _result += ""+ parseInt(mar.mortgage.filters.budget, 10)+ ""; _result += "
"; _result += "
"; _result += "
"; $("#personal_mortgage_proposal_1 .budget_pp").html(mar.fmt.currency((mar.mortgage.filters.purchace_price))); $("#personal_mortgage_proposal_1 .budget_c2c").html(mar.fmt.currency(parseInt(mar.mortgage.filters.c2c, 10))); $("#personal_mortgage_proposal_1 .budget_monthly").html(mar.fmt.currency(parseInt(mar.mortgage.filters.budget, 10))); } $(".prev-button").css("display","block"); $(".xprev-button").html("NOPE"); $(".next-button").html("YES").css("display","block"); $("#goals_target_budget").remove(); $("#downpayment-div").html(""); return; var newslider = frm.slider("goals_target_budget","5%",Math.floor(mar.mortgage.filters.c2c),"","",function(){ let _goals_target_budget = Math.floor(txt("#goals_target_budget")); if (mar.state.override_downpayment !== false && _goals_target_budget < lowestclosing ) { mar.state.override_downpayment = false; mar.calculatepart(mar.state.goals_target_value); } if (_goals_target_budget > highestclosing ) { var _c = Math.floor(( (_goals_target_budget - mar.mortgage.filters.costs) / mar.state.goals_target_value) * 100) mar.state.override_downpayment = _c; mar.calculatepart(mar.state.goals_target_value); } var __dif = false; var __c2c = false; mar.mortgages = ""; for (let _m in mar.mortgagesc) { var rates = mar.mortgagesc[_m]; for (var i= buydown.rateid-4; i < buydown.rateid+2; i++) { var rate = rates[i]; if (rate && "master" in rate && "MI" in rate.master) { for (let x in rate.master.MI) { if ("master_return" in rate.master.MI[x]) { // this is a bpmi and a return let mr = rate.master.MI[x].master_return; var _dif = Math.abs(mr.filters.c2c - _goals_target_budget); mar.mortgages += _m + ""+i+")"+x+"="+mr.final_monthly_budget+"/"+mr.filters.c2c+"/d:"+_dif+"
"; if (__dif == false) { __dif = _dif; __c2c = mr.filters.c2c mar.mortgage = mr; mar.mortgages += "** selected 1 **
"; } else if (_dif < __dif) { mar.mortgage = mr; mar.mortgages += "** selected 2 **
"; __dif = _dif; __c2c = mr.filters.c2c } else if (_dif == __dif) { if (__c2c == false) { __c2c = mr.filters.c2c } else if (mr.filters.c2c < __c2c) { __c2c = mr.filters.c2c mar.mortgage = mr; mar.mortgages += "** selected 3 **
"; } } } } } } } __display(); //mar.pg.oc(); }, { v00 : Math.floor(lowestclosing) - ((mar.state.override_downpayment != false) ? 5000 : 0), v50 : Math.floor(lowestclosing + (highestclosing-lowestclosing)/2), v50_inc : '50', v75 : Math.floor(highestclosing), v75_inc : '250', v100 : Math.floor(highestclosing * 3), v100_inc : '1000', start_val : '2000' }).render(); $("#downpayment-div").html(newslider); $("#downpayment-div").find(".xx-slider").myslider(); setTimeout(function(){ $("#downpayment-div ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); },100) $("#goals_target_budget").click(function(){ var h = "
"; if (mar.mortgage) { let mmr = mar.mortgage.appsum1; h += mar.pg.makepopup(mmr); } h += "
"; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = h; swal({ className : "fred", content : s }) $(".swal-modal.fred").parent().css("background-color","rgba(0,0,0,.8)"); }) __display(); //swal.close(); } mar.calculatepart = function(goals_target_value, calcpart_end_function) { var loading = 'Calculating many more mortgage options than you may think...




'+ '
'+ '
'+ '
'+ '
'; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = loading; let bsarray = [ "Entering preferences", "Entering margins budget", "Entering margins cash to close", "Filtering for HPML", "Filtering for QM", "Filtering for ATR", "Checking credit score", "Checking type of property", "Checking location", "Checking use of property", "Checking VA", "Checking for FHA", "Checking for Conventional", "Checking MI borrower paid", "Checking MI split edge", "Checking MI upfront", "Checking Home Ready", "Checking MI borrower paid", "Checking MI split edge", "Checking MI upfront", "Checking for buydown", "Checking for lender credit", "Checking Jumbo", "Checking non QM", "Entering margins budget", "Entering margins cash to close", "Filtering for HPML", "Filtering for QM", "Filtering for ATR", "Checking credit score", "Checking type of property", "Checking location", "Checking use of property", "Checking VA", "Checking for FHA", "Checking for Conventional", "Checking MI borrower paid", "Checking MI split edge", "Checking MI upfront", "Checking Home Ready", "Checking MI borrower paid", "Checking MI split edge", "Checking MI upfront", "Checking for buydown", "Checking for lender credit", "Checking Jumbo", "Checking non QM", "Entering margins budget", "Entering margins cash to close", "Filtering for HPML", "Filtering for QM", "Filtering for ATR", "Checking credit score", "Checking type of property", "Checking location", "Checking use of property", "Checking VA", "Checking for FHA", "Checking for Conventional", "Checking MI borrower paid", "Checking MI split edge", "Checking MI upfront", "Checking Home Ready", "Checking MI borrower paid", "Checking MI split edge", "Checking MI upfront", "Checking for buydown", "Checking for lender credit", "Checking Jumbo", "Checking non QM", "Entering margins budget", "Entering margins cash to close", "Filtering for HPML", "Filtering for QM", "Filtering for ATR", "Checking credit score", "Checking type of property", "Checking location", "Checking use of property", "Checking VA", "Checking for FHA", "Checking for Conventional", "Checking MI borrower paid", "Checking MI split edge", "Checking MI upfront", "Checking Home Ready", "Checking MI borrower paid", "Checking MI split edge", "Checking MI upfront", "Checking for buydown", "Checking for lender credit", "Checking Jumbo", "Checking non QM" ]; let bsfn = false; let nextbs = function() { if (bsarray.length == 0) { if (bsfn) { $(".popuploadingcontainer").remove(); bsfn(); } //swal.close(); } let bst = bsarray.shift(); $("#bstext").html(bst); setTimeout(nextbs,500); } swal({ className : "midelinfopopupOneButton", xclassName : "swal-loading", content : s }) mar.mortgagesc = { conv : false, fha : false, jumbo : false } if (MAR.isVaEligible() == true) mar.mortgagesc.va = false; mar.mortgagesc = { conv : false, fha : false } mar.state.goals_target_value = goals_target_value; mar.calculatepartfinal_return_fn = function(ob) { $("#bstext-prog").html(""); var TXT = ob.cnt_tot+" loans calculated.
best match found.
"; if (bsarray.length == 0) { $(".popuploadingcontainer").remove(); $("#bstext").html(TXT); } else { //bsarray.push(TXT) $(".popuploadingcontainer").remove(); bsarray = [TXT]; } if (mar.makegridfunction) mar.makegridfunction(); if (calcpart_end_function) calcpart_end_function(); }; mar.calculatepartfinal(mar.calculatepartfinal_return_fn); nextbs(); // let calculatepartfinal_fn = function() { // var TXT = "All loans calculated"; // if (bsarray.length == 0) { // $(".popuploadingcontainer").remove(); // $("#bstext").html(TXT); // if (fn) fn() // } else { // bsarray.push(TXT) // if (fn) bsfn = fn; // } // }; // // mar.calculatepartfinal = function() { //// for (var _m in mar.mortgagesc) { //// if (mar.mortgagesc[_m] == false) { //// //// let URL = "/calc/inputs_conversion?input_json={}"; //// URL += "&cache=n"; //// URL += "&id="+loanid; //// URL += "&programme="+_m; //// URL += "&cachename="+cachename+"_"+_m; //// URL += "&input_scenario="+encodeURIComponent(JSON.stringify(input_scenario)); //// //// $("#bstext-prog").html("Calculating "+_m+" "); //// //// $.get(URL , function( data ) { //// //var rates = data.mar.rates; //// //mar.mortgagesc[data.programme] = data.mar.rates; //// mortgagesc[_m] = data.mar.rates; //// calculatepartfinal(); //// }); //// return; //// } //// } // $("#bstext-prog").html(""); // calculatepartfinal_fn(); // // } // //// calculatepartfinal(); // nextbs(); } mar.calculatepart1_tol = ""; mar.calculatepart1 = function(goals_target_value,programme, options) { $("#bstext-prog").html("calculating "+programme); /** * the column has a object with at least * resultIndex * columnIndex */ var scenario = {}; let PROGRAMME = programme; var applicationId = mar.ID; var term_of_loan = getScenario_data("term_of_loan","tol30"); mar.calculatepart1_tol = term_of_loan; let inputs_scenario = { scenario :scenario, v2 : { programme : programme } } inputs_scenario.scenario.override_qual_inc_pm = 20000; // inputs_scenario.scenario.override_dti_max_front_end = 99 // inputs_scenario.scenario.override_dti_max_back_end = 99 inputs_scenario.scenario.mybudget = 10000; /** this one remains in the error */ inputs_scenario.scenario.programme = programme; inputs_scenario.scenario.term_of_loan = term_of_loan; // if (goals_target_value > 0) { // inputs_scenario.scenario.override_required_loan = goals_target_value; // } // if (mar.state.override_downpayment !== false) { // inputs_scenario.scenario.override_downpayment = mar.state.override_downpayment; // } // if (mar.state.override_budget !== false) { // inputs_scenario.scenario.mybudget = mar.state.override_budget; // } goals_target_value = getScenario_data("goals_target_value",0); let solvefor = "max"; if (getScenario_data("goals_protect_purchase","N") == "Y") { if (goals_target_value > 0) { inputs_scenario.scenario.override_required_loan = goals_target_value; solvefor = "scenario"; } } if (getScenario_data("goals_protect_budget","N") == "Y" && getScenario_data("goals_target_budget_high",false) !== false) { // does this inputs_scenario.scenario.mybudget = num(getScenario_data("goals_target_budget_high",0))+25 } if (getScenario_data("goals_protect_c2c","N") == "Y" && getScenario_data("goals_target_c2c_high",false) !== false) { var _c = Math.floor((( getScenario_data("goals_target_c2c_high",0) - (5000)) / goals_target_value) * 100) inputs_scenario.scenario.override_downpayment = _c } inputs_scenario.goals = { target_budget_low : getScenario_data("goals_target_budget_low",false), target_budget_high : getScenario_data("goals_target_budget_high",false), target_c2c_low : getScenario_data("goals_target_c2c_low",false), target_c2c_high : getScenario_data("goals_target_c2c_high",false), target_price : getScenario_data("goals_target_value",false), protect_c2c : getScenario_data("goals_protect_c2c","N"), protect_budget : getScenario_data("goals_protect_budget","N"), protect_purchase : getScenario_data("goals_protect_purchase","N"), required_loan : goals_target_value, downpayment : mar.state.override_downpayment, budget : mar.state.override_budget, solvefor : solvefor }; var approxCosts = MAR.getApproximateClosingCosts(goals_target_value, 0).total10; // approximate closing costs let URL = "/calc/inputs_conversion?input_json={}"; URL += "&cache=n"; URL += "&id="+applicationId; URL += "&programme="+programme; /** * this is a single budget calculation only */ if (options && "budget" in options) { inputs_scenario.goals.target_budget_low = options.budget; inputs_scenario.goals.target_budget_high = options.budget; inputs_scenario.goals.budget = options.budget; inputs_scenario.scenario.mybudget = options.budget; inputs_scenario.scenario.override_max_budget = options.budget; inputs_scenario.goals.required_loan = 0; inputs_scenario.goals.target_price = 0; inputs_scenario.goals.protect_purchase = "N"; inputs_scenario.goals.protect_c2c = "Y"; inputs_scenario.goals.protect_budget = "Y"; inputs_scenario.goals.solvefor = "max"; if (options && "c2c" in options && num(options.c2c) >= 0) { inputs_scenario.goals.target_c2c_low = options.c2c; inputs_scenario.goals.target_c2c_high = options.c2c; } if (options && "hoi" in options && num(options.hoi) >= 0) { inputs_scenario.scenario.override_home_insurance_cost = options.hoi; } if (options && "hoa" in options && num(options.hoa) >= 0) { inputs_scenario.scenario.override_home_owners_association_cost = options.hoa; } if (options && "tax" in options && num(options.tax) >= 0) { inputs_scenario.scenario.override_prop_tax_percentage_pm = options.tax; } if (options && "sum" in options) { URL += `&sum=${options.sum}`; } delete inputs_scenario.scenario.override_required_loan; if (!options || "rate" in options == false) { URL += "&rate=5"; } else { URL += "&rate="+options.rate; URL += "&rateH="+(num(options.rate) + mar.staticvars.rate_spread); if ("goals_target_value" in options) { inputs_scenario.scenario.override_required_loan = options.goals_target_value; } } URL += `&cachename=`; if (options && "caf" in options) { URL += options.caf; } } else { URL += `&cachename=wl_${term_of_loan}_${programme}`; /** * lets make them all solve for scenario then */ if (goals_target_value > 0) { inputs_scenario.scenario.override_required_loan = goals_target_value; inputs_scenario.goals.solvefor = "scenario"; } } URL += "&input_scenario="+encodeURIComponent(JSON.stringify(inputs_scenario)); // inputs_scenario.goals = { // target_budget_low : getScenario_data("goals_target_budget_low",false), // target_budget_high : getScenario_data("goals_target_budget_high",false), // target_c2c_low : "10000", // target_c2c_high : "11000", // target_price : getScenario_data("goals_target_value",false), // protect_c2c : "N", // protect_budget : "Y", // protect_purchase : "Y", // required_loan : goals_target_value, // downpayment : mar.state.override_downpayment, // budget : mar.state.override_budget // }; //goals_target_value // inputs_scenario.scenario.programme = type; // inputs_scenario.scenario.term_of_loan = mar.playsolve.tol; //let URL = "/2/calc/inputs_conversion?input_json={}"; $.get(URL , function( data ) { var rates = data.mar.rates; if (options && "fn" in options) { options.fn(rates); return; } mar.mortgagesc[data.programme] = data.mar.rates; mar.calculatepartfinal(); }); } let makepopup = function(mmr) { var h = ""; for (let i=0; i < mmr.length; i++) { let mmrlin = mmr[i].split("\t"); if (mmrlin[0] == "at") { // Attention h += "
" + "
ATTN:
" + "
" + mmrlin[1] + "
" + "
"; //h += "
"; } if (mmrlin[0] == "hh") { // green rounded top h += "
" + "
" + mmrlin[1] + "
" + "
"; } if (mmrlin[0] == "hhy") { // yellow rounded top h += "
" + "
" + mmrlin[1] + "
" + "
"; } if (mmrlin[0] == "ht") { // green rounded top h += "
" + "
" + mmrlin[1] + "
" + mar.fmt.currency(mmrlin[2]) + "
" + "
" + "
"; } if (mmrlin[0] == "hc") { // green non rounded top h += "
" + "
" + mmrlin[1] + "
" + mar.fmt.currency(mmrlin[2]) + "
" + "
" + "
"; } if (mmrlin[0] == "hm") { // green non rounded top h += "
" + "
" + mmrlin[1] + "
" + mar.fmt.currency(mmrlin[2]) + "
" + "
" + "
"; } if (mmrlin[0] == "bd") { // white/green dots h += "
" + "
" + mmrlin[1] + "
"+ "
"+ "
" + mar.fmt.currency(mmrlin[2]) + "
"+ "
"; } if (mmrlin[0] == "bh") { // wh/ite/yellow heading h += "
" + "
" + "
" + mmrlin[1] + "
" + "
" + "
"; } if (mmrlin[0] == "bg") { // grey sub total h += "
" + "
" + mmrlin[1] + "
" + mar.fmt.currency(mmrlin[2]) + "
" + "
" + "
"; } if (mmrlin[0] == "bgt") { // grey sub total h += "
" + "
" + mmrlin[1] + "
" + mar.fmt.currency(mmrlin[2]) + "
" + "
" + "
"; } if (mmrlin[0] == "bgb") { // grey sub total h += "
" + "
" + mmrlin[1] + "
" + mar.fmt.currency(mmrlin[2]) + "
" + "
" + "
"; } if (mmrlin[0] == "fb") { // yellow/white rounded corners h += "
" + "
" + mmrlin[1] + "
"+ "
"+ "
" + mar.fmt.currency(mmrlin[2]) + "
"+ "
"; } if (mmrlin[0] == "fbg") { // green/white rounded corners h += "
" + "
" + mmrlin[1] + "
"+ "
"+ "
" + mar.fmt.currency(mmrlin[2]) + "
"+ "
"; } if (mmrlin[0] == "dt") { // yellow/white rounded corners h += "
" + "
" + mmrlin[1] + "
"+ "
"+ "
" + "
"+ "
"; } } return h; } mar.pg.makepopup = makepopup; mar.pg["scenario-mortgageyes3"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { let h = ""; h += frm.htitle("Yes! My wishlist pt2").render(); h += frm.elaine("To close on this loan you need to bring some cash. The final number to close is your 'out the door' number. It includes really everything we can think of.","").render(); let mortgage = getScenario_data("mortgage",false); console.warn('MORTGAGE: ',mortgage); if (mortgage !== false) { h +='
'; let mmr = mortgage.appsum5; h += makepopup(mmr); VAL = 'N'; h += frm.yn("can_afford","I can afford this:",VAL,"","",function(){ },{}).render(); h +='
'; h += frm.h2("
This is not an approval for the loan. Your application has not been reviewed by an Underwriter.
").render(); h +="
This calculation used an estimated market rate of {{4.875%}} with an APR of {{5.237%}} for a {{30}} year fully amortizing loan."; h +="Get an official quote by completing this loan application from your licensed Loan Officer {{Name}} with NMLS ID {{12344}}. Your actual rate, payment, and cost could be higher."; h +=" Get an official Loan Estimate before choosing a loan.

"; h +="Read more"; h += "
"; h += "
"; h += "The information provided above regarding Approximate Cost of Closing Fees, " + "Approximate Total Funds Needed To Close and the Approximate Total Monthly " + "Payment (collectively referred to as Approximate Loan Cost Illustration) " + "are only approximations. The actual fees, cost and monthly payment on your specific " + "loan transaction may vary and may include additional fees and cost. "; h += "
"; h +="

"; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ // mvc.go("#scenario-hoi"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-mortgage"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); oc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["scenario-mortgage"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { var goals_target_value = getScenario_data("goals_target_value","250000"); var goals_target_budget = getScenario_data("goals_target_budget","10000"); var goals_target_budget = getScenario_data("goals_target_budget","10000"); var goals_target_ltv = getScenario_data("goals_target_ltv","5"); var term_of_loan = getScenario_data("term_of_loan","tol30"); var goals_target_c2c_low = getScenario_data("goals_target_c2c_low","20000"); var goals_target_c2c_high = getScenario_data("goals_target_c2c_high","20000"); mar.state.override_downpayment = false; let h = ""; h += frm.htitle("Your mortgage").render(); h += frm.elaine("Ok, no problem. If you want to bring closing cost or your budget down, please reduce your purchase price, or bring the downpayment down if possible.","").render(); h += "
What purchase price do you have in mind?
"; VAL = goals_target_value; h += frm.slider("goals_target_value","Approx.",VAL,"","",function(){ oc(); }, { v00 : '50000', v50 : '250000', v50_inc : '5000', v75 : '750000', v75_inc : '5000', v100 : '1500000', v100_inc : '50000', start_val : '250000', trackStyling : 'trafficLight' }).render(); h += frm.hr().render(); h += "
How much do you have available for closing cost and downpayment?
"; VAL = goals_target_c2c_high; h += "
" // h += frm.slider("goals_target_budget","5%",VAL,"","",function(){ h += frm.slider("goals_target_c2c_high","Approx.",VAL,"","",function(){ oc(); }, { // v00 : '400', // v50 : '3000', // v50_inc : '50', // v75 : '10000', // v100 : '45000', // v100_inc : '1000', // start_val : '2000' v00 : '0', v50 : '20000', v50_inc : '200', v75 : '50000', v75_inc : '500', v100 : '300000', v100_inc : '1000', start_val : '20000', trackStyling : 'trafficLight' }).render(); h += "
"; // h += frm.hr().render(); //if we will use this elsewhere we could make it a class called a switch-field // h += '
'; // h += '
How fast do you want to pay the loan?
'; // var selected = (term_of_loan == "tol30") ? "checked" : ""; // h += ''; // h += ''; // var selected = (term_of_loan == "tol20") ? "checked" : ""; // h += ''; // h += ''; // var selected = (term_of_loan == "tol10") ? "checked" : ""; // h += ''; // h += ''; // h += '
'; // // h += frm.hr().render(); // // // h += frm.htitle("
Budget Needed
{{AMOUNT}}
").render(); // // h += "
"; // h += frm.h2("Note: Please do not let a house become a financial burden. Choose a purchase price and downpayment that comfortably fit your budget.").render(); // // // h += frm.htitle("
").render(); /* end modal content */ h += uihelpers.cbuttonbar("Recalculate",frm.addfunction(function(){ //setScenario_data("mortgage",mar.mortgage); mar.fakesave(); mvc.go("#scenario-magic2"); }),"Back to budget",frm.addfunction(function(){ mvc.go("#scenario-budget"); // swal("nope"); // $("#firstbubble").html("Ok, no problem. If you want to being closing cost or your budget down, please reduce your purchase price, or the downpayment down if possible ") // show_pp = true; }),"mar.help()"); h = Mustache.render(h,localopts); let show_pp = false; let calc = (function(){ function pp () { var goals_target_value = getScenario_data("goals_target_value","250000"); let loan_time = getScenario_data("loan_type_purchase_options","") var occupancy_type = getScenario_data("occupancy_type",""); var property_type = getScenario_data("property_type",""); let sh = elaineui.scenarioHelpers; var _sc = getScenario_v2(); let percA = sh.likelydownpaymentpercentage(occupancy_type, property_type, MAR.isVaEligible(), _sc.cscore, MAR.isFirstTimeBuyer(),goals_target_value); console.warn("percA",percA); let perc = percA[0] * 100 ; // (by multiplying it , it comes as 2 or 3.5) var goals_target_c2c_low = getScenario_data("goals_target_c2c_low",0); var goals_target_c2c_high = getScenario_data("goals_target_c2c_high",0); var __apcc = MAR.getApproximateClosingCosts(goals_target_value,0).total10; var loval = ((goals_target_c2c_low-__apcc)/(perc+2)) * 100; var hival = ((goals_target_c2c_high-__apcc)/(perc+2)) * 100; var hiperc = elaineui.updateRangefromVal(hival, 50000, 250000, 750000, 1500000); var loperc = elaineui.updateRangefromVal(loval, 50000, 250000, 750000, 1500000); var grad = elaineui.buildGradientR(loperc,hiperc); $("#goals_target_value_slider").css("background",grad); } return { pp : pp // purchase price } })() let oc = function() { var goal_disp = ""; var goals_target_value = _num(txt("#goals_target_value")); var goals_target_c2c_high = _num(txt("#goals_target_c2c_high")); var loan_duration = radio("loan_duration"); var occupancy_type = getScenario_data("occupancy_type",""); var property_type = getScenario_data("property_type",""); setScenario_data("goals_target_value",goals_target_value); setScenario_data("goals_target_c2c_high",goals_target_c2c_high); mar.fakesave(); calc.pp(); } mar.pg.oc = oc; let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider({ fn : function() { calc.pp(); } }); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //console.warn ('input mask: ', $("#body-container ._sqft").inputmask); $("#body-container ._sqft").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character postfix: 'sq ft', rightAlign: false, autoUnmask : true }); // $("#budget-needed").click(function(){ // var h = "
"; // if (mar.mortgage) { // let mmr = mar.mortgage.appsum2; // h += makepopup(mmr); // // } // h += "
"; // // var s = document.createElement("div"); // s.setAttribute("class","normal-form monthly-budget"); // s.innerHTML = h; // // swal({ // className : "fred", // content : s // }) // $(".swal-modal.fred").parent().css("background-color","rgba(0,0,0,.8)"); // // }); // $("#goals_target_budget").click(function(){ // var h = "
"; // if (mar.mortgage) { // let mmr = mar.mortgage.appsum1; // h += makepopup(mmr); // // } // h += "
"; // // var s = document.createElement("div"); // s.setAttribute("class","normal-form"); // s.innerHTML = h; // // swal({ // className : "fred", // content : s // }) // $(".swal-modal.fred").parent().css("background-color","rgba(0,0,0,.8)"); // // }) // $("#personal_mortgage_proposal").click(function(){ // var s = document.createElement("div"); // s.setAttribute("class","normal-form"); // s.innerHTML = mar.mortgages; // // swal({ // content : s // }) // // }); oc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["scenario-magic2"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var goals_target_value = getScenario_data("goals_target_value","250000"); var goals_target_budget_low = getScenario_data("goals_target_budget_low","10000"); var goals_target_budget_high = getScenario_data("goals_target_budget_high","10000"); var goals_target_c2c_low = getScenario_data("goals_target_c2c_low","20000"); var goals_target_c2c_high = getScenario_data("goals_target_c2c_high","20000"); var goals_protect_c2c = getScenario_data("goals_protect_c2c","N"); var goals_protect_budget = getScenario_data("goals_protect_budget","N"); var goals_protect_purchase = getScenario_data("goals_protect_purchase","N"); var calculation_priority = getScenario_data("calculation_priority","high_purchase"); var term_of_loan = getScenario_data("term_of_loan","tol30"); /// let loan_time = getScenario_data("loan_type_purchase_options","") if (loan_time == "soon") { setScenario_data("goals_protect_c2c","Y"); setScenario_data("goals_protect_budget","N"); setScenario_data("goals_protect_purchase","Y"); mar.fakesave(); } else if (loan_time == "contract") { setScenario_data("goals_protect_c2c","Y"); setScenario_data("goals_protect_budget","N"); setScenario_data("goals_protect_purchase","Y"); mar.fakesave(); } else { setScenario_data("goals_protect_c2c","Y"); setScenario_data("goals_protect_budget","Y"); setScenario_data("goals_protect_purchase","N"); mar.fakesave(); } // mar.txt.soon = "Contract soon"; // mar.txt.just_looking = "Just looking"; // mar.txt.contract = "Under contract"; // mar.txt.one_month = "1-3 months"; // mar.txt.three_months = "3-6 months"; // // // // var goals_protect_c2c = getScenario_data("goals_protect_c2c","N"); // var goals_protect_budget = getScenario_data("goals_protect_budget","N"); // var goals_protect_purchase = getScenario_data("goals_protect_purchase","N"); // // var goals_protect_c2c = ($("#goals_protect_c2c:checked").length == 0) ? "N" : "Y"; // var goals_protect_budget = ($("#goals_protect_budget:checked").length == 0) ? "N" : "Y"; // var goals_protect_purchase = ($("#goals_protect_purchase:checked").length == 0) ? "N" : "Y"; // //// swal ([goals_protect_c2c,goals_protect_budget,goals_protect_purchase].join(",")); // // if (goals_protect_c2c == "Y" && goals_protect_budget == "Y" ) { // $("#goals_protect_purchase").prop("disabled",true); // } else if (goals_protect_c2c == "Y" && goals_protect_purchase == "Y" ) { // $("#goals_protect_budget").prop("disabled",true); // } else if (goals_protect_budget == "Y" && goals_protect_purchase == "Y" ) { // $("#goals_protect_c2c").prop("disabled",true); // } else { // $("#goals_protect_purchase").prop("disabled",false); // $("#goals_protect_budget").prop("disabled",false); // $("#goals_protect_c2c").prop("disabled",false); // } // // // setScenario_data("goals_protect_c2c",goals_protect_c2c); // setScenario_data("goals_protect_budget",goals_protect_budget); // setScenario_data("goals_protect_purchase",goals_protect_purchase); mar.fakesave(); /// mar.state.override_downpayment = false; var n0 = getApplicantsNames_v2(0).Name; let h = ""; h += frm.htitle("LOAN COST ILLUSTRATION").render(); h += frm.elaine("The faster you pay off your loan, the less money you can borrow. The shorter the loan duration, the more expensive it gets, meaning we will use up your budget faster.","").render(); //if we will use this elsewhere we could make it a class called a switch-field h += '
'; h += '
How fast do you want to pay off your loan
'; var selected = (term_of_loan == "tol30") ? "checked" : ""; h += ''; h += ''; var selected = (term_of_loan == "tol20") ? "checked" : ""; h += ''; h += ''; var selected = (term_of_loan == "tol15") ? "checked" : ""; h += ''; h += ''; h += '
'; var lock = ''; var lock1 = ''; let warning = ``; var _result = ""; _result += "
"; _result += "
"; _result += "
"; _result += "Est. max. purchase price"; _result += "
"; _result += "
"; _result += ""; _result += "
"; _result += "
"; _result += "
"; _result += "
"; _result += "Est. closing cost"; _result += "
"; _result += "
"; //_result += lock; _result += ""; _result += "
"; _result += "
"; _result += "
"; _result += "
"; _result += "Est. monthly budget"; _result += "
"; _result += "
"; _result += warning; //_result += lock1; _result += ""; _result += "
"; _result += "
"; _result += "
"; h += "
"; h += "
"; h += "
"+_result+"
"; h += frm.htitle("
").render(); /* end modal content */ let next_lock = false; // h += uihelpers.cbuttonbar3("Next",frm.addfunction(function(){ h += uihelpers.cbuttonbar("Next",frm.addfunction(function(){ if (next_lock == true) return; next_lock = true; //setScenario_data("mortgage",mar.mortgage); elaine_adapter.mortgage.save(mar.ID, "1" , mar.mortgage, function() { delScenario_data("mortgage"); mar.fakesave(); mvc.go("#scenario-mortgageyes"); next_lock = false; }) // }),"Back",frm.addfunction(function(){ // mvc.go("#scenario-mortgage"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-budget1"); }),"mar.help()"); h = Mustache.render(h,localopts); let show_pp = false; let oc = function() { $(".prev-button").css("display","none"); $(".next-button").css("display","none"); var goal_disp = ""; var goals_target_value = _num(getScenario_data("goals_target_value","250000")); var goals_target_budget = _num(getScenario_data("goals_target_budget","10000")); var loan_duration = radio("loan_duration"); var occupancy_type = getScenario_data("occupancy_type",""); var property_type = getScenario_data("property_type",""); setScenario_data("term_of_loan",loan_duration); mar.fakesave(); if (show_pp == false) { $("#purchaseprice-div").css("display","none"); } else { $("#purchaseprice-div").css("display","block"); } var goals_target_downpayment = _num(txt("#goals_target_downpayment")); if (goals_target_budget > 0) { goal_disp += "
Budget : $"+goals_target_budget+"
"; } if (goals_target_value > 0) { goal_disp += "
Target : $"+goals_target_value+"
"; } if (goals_target_downpayment > 0) { goal_disp += "
Down : $"+goals_target_downpayment+"
"; } var _suggested_downpayment = 0; if (goals_target_budget !== "" && goals_target_value !== "") { //console.warn(' _suggested_downpayment!!!! target budget us nit nothing! target budget: '+goals_target_budget+' mar.answers.v2.scenario.goals_target_value: '+goals_target_value); let DEPOSIT_PERCENTAGE = 0.035 /** * add in exceptions based on marvin's strategy ! * if type is investment 25% * investment if multi family or condo * */ if (occupancy_type == mar.OCCUPANCY_INVESTMENT) { DEPOSIT_PERCENTAGE = 0.25 // investment 25% } if (occupancy_type == mar.OCCUPANCY_2ND_HOME) { if (property_type == mar.PROPERTY_TYPE_SFR) { DEPOSIT_PERCENTAGE = 0.05 // 2nd home for family 5% } else if (property_type == mar.PROPERTY_TYPE_CONDO) { DEPOSIT_PERCENTAGE = 0.05 // same as above } else { DEPOSIT_PERCENTAGE = 0.25 // 2nd home multi family is treated as investment } } _suggested_downpayment += num(mar.answers.v2.scenario.goals_target_value) * DEPOSIT_PERCENTAGE; /* 3.5 % deposit */ _suggested_downpayment += num(mar.answers.v2.scenario.goals_target_value) * 0.020; /* 2.0 % closing costs */ } // console.warn(' mar.answers.v2.scenario.goals_target_budget: '+mar.answers.v2.scenario.goals_target_budget); // console.warn(' mar.answers.v2.scenario.goals_target_value: '+mar.answers.v2.scenario.goals_target_value); // console.warn(' _suggested_dow is NOT great than zero: '+_suggested_downpayment); if (_suggested_downpayment > 0) { // console.warn(' _suggested_dow is great than zero: '+_suggested_downpayment); $(".suggestionballoon .suggested_value").html(num(mar.answers.v2.scenario.goals_target_value).toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",")); $(".suggestionballoon .suggested_downpayment").html(num(_suggested_downpayment).toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",")); } else { console.log(' _suggested_dow is NOT great than zero: '+_suggested_downpayment); $(".suggestionballoon .suggested_value").html("200000"); $(".suggestionballoon .suggested_downpayment").html("11000"); } $("#budget-needed").html(_suggested_downpayment) // console.log("!!goal_disp!!: "+goal_disp); // if (loan_type == "purchase") { // $("#_sc_goals").html(goal_disp); // if (!restricted && (mar.answers.v2.scenario.goals_target_budget == "" || mar.answers.v2.scenario.goals_target_value == "" || mar.answers.v2.scenario.goals_target_downpayment == "")) { // // toggle_restrict("scenario_simple_goals"); // restricted = true; // } // } mar.state.override_downpayment = false; mar.state.override_budget = false; var approxCosts = MAR.getApproximateClosingCosts(goals_target_value, 0).total10; // approximate closing costs var goals_target_budget_low = _num(txt("#goals_target_budget_low")); var goals_target_budget_high = _num(txt("#goals_target_budget_high")); var goals_target_c2c_low = _num(txt("#goals_target_c2c_low")); var goals_target_c2c_high = _num(txt("#goals_target_c2c_high")); var goals_protect_c2c = getScenario_data("goals_protect_c2c","N"); var goals_protect_budget = getScenario_data("goals_protect_budget","N"); var goals_protect_purchase = getScenario_data("goals_protect_purchase","N"); if (goals_protect_c2c == "Y") { if (goals_target_c2c_low > 0 && goals_target_c2c_high > 0) { var _c = Math.floor(( (_goals_target_budget - approxCosts) / mar.state.goals_target_value) * 100) mar.state.override_downpayment = _c; } } if (goals_protect_budget == "Y") { if (goals_target_budget_low > 0 && goals_target_budget_high > 0) { mar.state.override_budget = goals_target_budget_low; } } swal(JSON.stringify(mar.state)); let refresh_list = function() { let tol = radio("loan_duration") elaine_adapter.mortgage.getcachelist(mar.ID, `wl_${tol}_`, function(list) { if (list == false) { return; } if ($("#more_mortgage_options_popup_button").length == 0) { $("#personal_mortgage_proposal_1").after("") $("#personal_mortgage_proposal_1").after("") } mar.pg.__popup_list_list = list; mar.pg.__popup_list(true); }); } if (goals_protect_purchase == "Y") { mar.calculatepart(num(goals_target_value*1.02),refresh_list); } else { mar.calculatepart(0,refresh_list); } // // if (_goals_target_budget > highestclosing ) { // var _c = Math.floor(( (_goals_target_budget - mar.mortgage.filters.costs) / mar.state.goals_target_value) * 100) // mar.state.override_downpayment = _c; // } // } let __display = function() { console.warn(mar.mortgage); //alert('(mar.mortgage.filters.budget: '+parseInt(mar.mortgage.filters.budget, 10)); $("#budget-needed").html(""+mar.fmt.currency(parseInt(mar.mortgage.filters.budget, 10))+""); $(".sliderAmtPercentage").text(mar.mortgage.filters.down+"%"); // old format // var na = getApplicantsNames_v2(0).Name; // var pbp = "
 
"+na + // ", will "+ parseInt(mar.mortgage.filters.budget, 10)+ "" + // " per month with " + parseInt(mar.mortgage.filters.c2c, 10)+ ""+ // " cash to close fit your budget?"; // $("#personal_mortgage_proposal").html(pbp); var na = getApplicantsNames_v2(0).Name; var pbp = "
 
OUR LOAN ESTIMATE

"+na + ""+ ", we will need " + ""+ mar.fmt.currency(parseInt(mar.mortgage.filters.c2c, 10))+ "" + " to close on a purchase price of " + "" + mar.fmt.currency((mar.mortgage.filters.purchace_price))+ ""+ ". This property will cost you an estimated " + "" + mar.fmt.currency(parseInt(mar.mortgage.filters.budget, 10))+ ""+ " per month, out the door. Will this work for you?"+ "
"; $("#personal_mortgage_proposal_2").html(pbp); $("#personal_mortgage_proposal").html(pbp); var _result = ""; _result += "
Do you have access to enough cash?
"; _result += "
"; _result += "
"; _result += "
"; _result += "Est. max. loan amount"; _result += "
"; _result += "
"; _result += "" + parseInt(mar.mortgage.filters.purchase_price, 10)+""; _result += "
"; _result += "
"; _result += "
"; _result += "
"; _result += "Est. closing cost"; _result += "
"; _result += "
"; _result += "" + parseInt(mar.mortgage.filters.c2c, 10)+""; _result += "
"; _result += "
"; _result += "
"; _result += "
"; _result += "Minimum cash to close"; _result += "
"; _result += "
"; _result += ""+ parseInt(mar.mortgage.filters.budget, 10)+ ""; _result += "
"; _result += "
"; _result += "
"; //swal(JSON.stringify(mar.mortgage.filters)); //$("#personal_mortgage_proposal_1").html(_result); //setTimeout(function(){ $("#personal_mortgage_proposal_1 .budget_pp").html(mar.fmt.currency((mar.mortgage.filters.purchace_price))); $("#personal_mortgage_proposal_1 .budget_c2c").html(mar.fmt.currency(parseInt(mar.mortgage.filters.c2c, 10))); $("#personal_mortgage_proposal_1 .budget_monthly").html(mar.fmt.currency(parseInt(mar.mortgage.filters.budget, 10))); } mar.pg.__display = function(n,t,r,pr,mi,u) { // let icr = mvc.get("icr", false); // let list = MAR.mortgageNavigator.list_from_rates(icr) let tol = radio("loan_duration") elaine_adapter.mortgage.getcacheone(mar.ID, `wl_${tol}_${pr}`, n, r, mi, u, function(itm) { if (itm) { mar.mortgage = itm.mortgage; $("#hoa_estimate_holder_title").html(t); __display(); if ($(".swal-overlay--show-modal").length > 0) swal.close(); } }); } mar.showHideDiv = function(e, num){ e.preventDefault(); var $st = $('#hidDiv'+num); if ($st.hasClass("x-hide")) { $st.removeClass('x-hide'); //$('#dropDownExpandCaret'+num).html('∧'); $('#dropDownRadio'+num).css('border-bottom-right-radius', '0'); $('#dropDownRadio'+num).css('border-bottom-left-radius', '0'); } else { $st.addClass('x-hide'); //$('#dropDownExpandCaret'+num).html('∨'); $('#dropDownRadio'+num).css('border-bottom-right-radius', '4px'); $('#dropDownRadio'+num).css('border-bottom-left-radius', '4px'); } // console.log(' show :'+st); // console.log(' show $(st):',$(st)); $("#body-container").scrollTo("max",200); } mar.pg.__popup_list_lo_end = function() { let calc_additional_lender_credits = _num(txt("#calc_additional_lender_credits")); let calc_additional_seller_credits = _num(txt("#calc_additional_seller_credits")); let calc_additional_realtor_credits = _num(txt("#calc_additional_realtor_credits")); setScenario_data("calc_additional_lender_credits",calc_additional_lender_credits); setScenario_data("calc_additional_seller_credits",calc_additional_seller_credits); setScenario_data("calc_additional_realtor_credits",calc_additional_realtor_credits); setScenario_data("goals_target_c2c_low" , _num(txt("#goals_target_c2c_low"))); setScenario_data("goals_target_c2c_high" , _num(txt("#goals_target_c2c_low"))); setScenario_data("goals_target_value" , _num(txt("#goals_target_value"))); setScenario_data("goals_target_budget_low" , _num(txt("#goals_target_budget_low"))); setScenario_data("goals_target_budget_high" , _num(txt("#goals_target_budget_low"))); mar.fakesave(function(){ mar.pg.oc(); }); } mar.pg.__popup_list_lo = function() { mar.pg.upmy("*",mar.mortgage); return; let calc_additional_lender_credits = getScenario_data("calc_additional_lender_credits","0"); let calc_additional_seller_credits = getScenario_data("calc_additional_seller_credits","0"); let calc_additional_realtor_credits = getScenario_data("calc_additional_realtor_credits","0"); var goals_target_c2c_low = getScenario_data("goals_target_c2c_low","0"); var goals_target_value = getScenario_data("goals_target_value","0"); var goals_target_budget_low = getScenario_data("goals_target_budget_low","0"); var goals_target_budget_high = getScenario_data("goals_target_budget_high","0"); let h = ""; h += "
"; let VAL = calc_additional_lender_credits; h += frm.slider("calc_additional_lender_credits","Lender Credits (pts):",VAL,"","",function(){ }, { v00 : '0', v50 : '1', v50_inc : '0.125', v75 : '2', v75_inc : '0.125', v100 : '3', v100_inc : '0.125' }).render(); VAL = calc_additional_seller_credits; h += frm.slider("calc_additional_seller_credits","Seller Credits (pts):",VAL,"","",function(){ }, { v00 : '0', v50 : '1', v50_inc : '0.125', v75 : '2', v75_inc : '0.125', v100 : '3', v100_inc : '0.125' }).render(); VAL = calc_additional_realtor_credits; h += frm.slider("calc_additional_realtor_credits","Realtor Credits (pts):",VAL,"","",function(){ }, { v00 : '0', v50 : '1', v50_inc : '0.125', v75 : '2', v75_inc : '0.125', v100 : '3', v100_inc : '0.125' }).render(); VAL = goals_target_c2c_low; h += frm.slider("goals_target_c2c_low","Cash 2 close.",VAL,"","",function(){ }, { v00 : '0', v50 : '20000', v50_inc : '250', v75 : '50000', v75_inc : '250', v100 : '300000', v100_inc : '1000', start_val : '20000' }).render(); VAL = goals_target_value; h += frm.slider("goals_target_value","Target price.",VAL,"","",function(){ }, { v00 : '50000', v50 : '250000', v50_inc : '5000', v75 : '750000', v75_inc : '5000', v100 : '1500000', v100_inc : '100000', start_val : '250000', trackStyleValues: JSON.stringify([{"start":"0", "end":"37", "color":"#90c33a"} , {"start":"38", "end":"64", "color":"#f6bd40"}, {"start":"65", "end":"100", "color":"#e51E2B"}]) }).render(); VAL = goals_target_budget_low; h += frm.slider("goals_target_budget_low","Budget within $100 of:",VAL,"","",function(){ }, { v00 : '0 ', v50 : '2500', v50_inc : '25', v75 : '8000', v75_inc : '50', v100 : '15000', v100_inc : '250', start_val : '1800', trackStyling : 'trafficlight' }).render(); h +=""; h += "
"; mar.three_panel_pane.init(); let p2 = ""; p2 += "
"; p2 += "
";//end pane h = mar.three_panel_pane.getHtml(h,p2); //launch the overlay var s = document.createElement("div"); s.setAttribute("class","normal-form"); var s = document.createElement("div"); s.setAttribute("class","normal-form monthly-budget"); s.innerHTML = h; swal({ className : "middleInfoPopup", content : s, buttons : false }) setTimeout(function prepare_popup_radios(){ $("#magic2-popup-lo").find(".xx-radio").myradio(); $("#magic2-popup-lo #restyleMeToChekboxes div").removeClass('md-radio'); $("#magic2-popup-lo #restyleMeToChekboxes input").addClass('styled-checkbox'); $("#magic2-popup-lo .dropDownRadioHolder .md-radio label").css('width', '100%' ); $("#magic2-popup-lo").find(".xx-slider").myslider({ fn : function(id) { $(`#${id}`).change() } }); },500) } /** * this is the list */ mar.pg.__popup_list_list = false; mar.pg.__popup_list = function(firsttime, filter_type) { if (arguments < 2 || !filter_type) filter_type = 0; // 1 = conv, 2 = fha , 0 = all let list = mar.pg.__popup_list_list; let ci = 0; let _goto_card = function(m,i,t,r,pr,txt) { mar.pg.__display(i,t,r,pr,m.MI,m.uuid); } let _make_card = function(m,i,t,r,pr,txt) { ci++; // loantype purchase // county FLORIDA BROWARD // cost_per_1000 7.353637682532244 // dti 0.02 // qmpass true // MI bpmi_rad_more20 let tt = ""; tt += `
Loan
`; tt += `Purchase${elaineui.format("cur", m.purchace_price)}`; tt += `Loan${elaineui.format("cur", m.max_loan)}`; tt += `Financeable UFMI${elaineui.format("cur", m.ufmi_fin)}`; tt += `
Costs
`; tt += `downpayment${elaineui.format("cur", m.downpayment)}`; tt += `costs${elaineui.format("cur", m.costs)}`; tt += `Financeable UFMI(${elaineui.format("cur", m.ufmi_fin)})`; tt += `c2c${elaineui.format("cur", m.c2c)}`; tt += `
Monthly
`; tt += `P&I${elaineui.format("cur", m.m_pay)}`; tt += `T - tax${elaineui.format("cur", m.m_tax)}`; tt += `M - MI${elaineui.format("cur", m.mmi)}`; tt += `I - insurance${elaineui.format("cur", m.m_hoi)}`; tt += `I - flood${elaineui.format("cur", m.m_flood)}`; tt += `H - HOA${elaineui.format("cur", m.m_hoa)}`; tt += `budget${elaineui.format("cur", m.budget)}`; tt += `
Ratios
`; tt += `LTV${m.ltv}`; tt += `CLTV${m.cltv}`; tt += `Down${elaineui.format("perc", m.down)}`; tt += `apr${elaineui.format("perc2", m.apr)}`; tt += `
MI
`; tt += `MI${m.xmrate}`; tt += `mmi${elaineui.format("perc2",m.mmip)}`; tt += `mmi${elaineui.format("cur",m.mmi)}`; tt += `ufmi${elaineui.format("perc2",m.ufmip)}`; tt += `ufmi${elaineui.format("cur",m.ufmi)}`; tt += `
Buydowns
`; tt += `bd rate${elaineui.format("perc2", m.abdr)}`; tt += `rate${elaineui.format("perc2", m.rate)}`; tt += `bd/ l credit${elaineui.format("cur", m.buydown)}`; tt += `
Scenario
`; tt += `FTHB${m.FTHB}`; tt += `cscore${m.cscore}`; tt += `duration${m.duration}`; tt += `purpose${m.purpose}`; tt += `property_type${m.property_type}`; tt += `QM${m.qmpass}`; tt += `c2c_colour${m.c2c_colour}`; tt += `budget_colour${m.budget_colour}`; let popular = ""; if (m.ltv == 80 || m.ltv == 85 || m.ltv == 90 || m.ltv == 95 || m.ltv == 96.5 || m.ltv == 97 ) { if (m.abdr >= 99.5 && m.abdr <= 100.5) { if (m.xmrate.startsWith("uf") == false && m.xmrate.startsWith("split") == false) { popular = ""; } } } let h = ""; h += `
`+ `
`+ `
Purchase price ${m.ltv} ${popular}
`+ `
`+ `${ mar.fmt.currency(parseInt(m.purchase_price,10))}`+ `
`+ `
`+ `
Closing cost ${m.xmrate}
`+ `
`+ `${ mar.fmt.currency(parseInt(m.c2c,10))}
`+ `
`+ `
Budget @${m.rate}% ${m.duration}y Fixed
`+ `
`+ `${ mar.fmt.currency(parseInt(m.budget,10))}`+ `
`+ `
`+ `
`+ ``+ `
`+ ``+ `
`+ `
`+ `
`+ `
`+ `
`+ `
`+ `
`+ `This is an ${m.programme}
` + `${txt}`+ ``+ `${tt}`+ `
`+ `
`+ `
SELECT THIS OPTION
`+ `
`+ `
`+ `

`; // h += mar._txt(mortgage.input_scenario.v2.programme); // h += elaineui.format("cur", mortgage.filters.downpayment); // h += elaineui.format("cur", mortgage.filters.max_loan); // h += elaineui.format("perc2", mortgage.final_ltv); // h += mortgage.credit_score; // h += elaineui.format("perc2",mortgage.final_mi_py); // h += elaineui.format("cur",mortgage.final_mi); // h += elaineui.format("perc2",mortgage.final_ufmi_py); // h += elaineui.format("cur",mortgage.final_ufmi); return h; } // let list = MAR.mortgageNavigator.filters_from_rates(icr) let __h = ""; __h += "
"; __h += "For your desired purchase price of "+elaineui.format("cur",goals_target_value)+" with the monthly budget of "+ elaineui.format("cur",goals_target_budget_high) + " per month and available cash to close of "+ elaineui.format("cur",goals_target_c2c_high) + ", these are your options"; /** * find the highest purchase price */ let high_pp = parseInt(list.list[list.pp[0].i].filters.purchase_price,10); let reccommandationbubble = (function(){ let kv = {}; function set(k,v) { kv[k] = v; } function get(S) { // if (kv.a_c2c > kv.b_c2c) { let less_c2c = Math.floor(kv.a_c2c - kv.b_c2c); let add_bud = Math.floor(kv.b_bud - kv.a_bud); let months = Math.floor((less_c2c) / add_bud); let c2c_less_more = "less"; let c2c_disp = mar.fmt.currency(less_c2c); if (less_c2c == 0) { c2c_disp = "the same cost"; c2c_less_more = ""; } else if (less_c2c < 0) { c2c_disp = mar.fmt.currency(less_c2c*-1); c2c_less_more = "more"; } let bud_less_more = "more"; let bud_disp = mar.fmt.currency(add_bud); if (add_bud == 0) { bud_disp = "the same budget"; bud_less_more = ""; } else if (add_bud < 0) { bud_disp = mar.fmt.currency(add_bud*-1); bud_less_more = "less"; } let advice = `
`+ `${S} you can close with ${c2c_disp} ${c2c_less_more}, but you pay ${bud_disp} per month ${bud_less_more}. `+ `After ${months} months you break even. `+ // `Meaning you will save yourself ${mar.fmt.currency(add_bud)} per month from month ${months} on this proposal.`+ `
` return advice; //} } return { set : set, get : get, ____id : "recbubble" } })(); /** * todo * * logic in presenting the results * * IF base rate + N * ratehike (=1/8 of percent) < 0.375 * N rate hikes THAN dont offer it. ELSE offer it * IF 0.25 < 0.75 THAN dont do it * * */ let setofloans = { lowclosing : false, highpurchase : false, balanced : false, lowrate : false, lowmonthly : false, popular : false, backuphighloan : false, highfha : false, highconv : false, cheapfha : false, cheapconv : false } let d10 = function(n) { return Math.floor(n/10000); } let target_pp = getScenario_data("goals_target_value","250000"); if (calculation_priority != "high_purchase") { high_pp = target_pp; } //goals_target_value let d10_high_pp = d10(high_pp); if (high_pp - (d10_high_pp*10000) < 5000) { if (calculation_priority != "high_purchase") { d10_high_pp -= 1; } else { d10_high_pp -= 0.5; } } let inrange = function(N) { if (Math.abs(N - num(target_pp)) < 5000) return true; return false; if (calculation_priority == "high_purchase") { if (high_pp - num(N) < 10000) return true; return false; } else { if (Math.abs(N - num(target_pp)) < 5000) return true; return false; } } /** * find loop to find the highest PP and the highest price */ for (let i=0; i < list.pp.length; i++) { let I = list.pp[i].i; let M = list.list[I]; let P = parseInt(M.filters.purchase_price,10); if ( M.filters.c2c_colour != "red" && M.filters.budget_colour != "red") { if (M.filters.programme == "conv") { if (setofloans.highconv == false) { setofloans.highconv = [I,`high purchase conv`,P]; } } if (M.filters.programme == "fha") { if (setofloans.highfha == false) { setofloans.highfha = [I,`high purchase fha`,P]; } } if (setofloans.highfha !== false && setofloans.highconv !== false) { break; } } } /** * find loop to find the highest PP and the highest price */ for (let i=0; i < list.apr.length; i++) { let I = list.apr[i].i; let M = list.list[I]; let P = parseInt(M.filters.purchase_price,10); if ( ((goals_protect_purchase == "N" && inrange(P)) || inrange(P)) && M.filters.c2c_colour != "red" && M.filters.budget_colour != "red") { if (M.filters.programme == "conv") { if (setofloans.cheapconv == false || setofloans.cheapconv[2] == false) { setofloans.cheapconv = [I,`cheapest conv`,true]; } } if (M.filters.programme == "fha") { if (setofloans.cheapfha == false || setofloans.cheapfha[2] == false) { setofloans.cheapfha = [I,`cheapest fha`,true]; } } if (setofloans.cheapfha !== false && setofloans.cheapconv !== false && setofloans.cheapconv[2] == true && setofloans.cheapfha[2] == true) { break; } } else if ( M.filters.c2c_colour != "red" && M.filters.budget_colour != "red") { if (M.filters.programme == "conv") { if (setofloans.cheapconv == false) { setofloans.cheapconv = [I,`cheapest conv`,false]; } } if (M.filters.programme == "fha") { if (setofloans.cheapfha == false) { setofloans.cheapfha = [I,`cheapest fha`,false]; } } } } /** * find loop to find the lowest API and the highest price */ for (let i=0; i < list.apr.length; i++) { let I = list.apr[i].i; let M = list.list[I]; let P = parseInt(M.filters.purchase_price,10); if ( ((goals_protect_purchase == "N" && inrange(P)) || inrange(P)) && M.filters.c2c_colour != "red" && M.filters.budget_colour != "red") { if (filter_type > 0 && (filter_type == 1 && M.filters.programme != "conv" || filter_type == 2 && M.filters.programme != "fha")) continue; setofloans.lowrate = [I,`Low rate / high closing cost`]; break; } } /** * find loop to find the most neutral and the highest price */ for (let i=0; i < list.buydown.length; i++) { let I = list.buydown[i].i; let M = list.list[I]; let P = parseInt(M.filters.purchase_price,10); if ( ((goals_protect_purchase == "N" && inrange(P)) || inrange(P)) && M.filters.c2c_colour != "red" && M.filters.budget_colour != "red") { if (filter_type > 0 && (filter_type == 1 && M.filters.programme != "conv" || filter_type == 2 && M.filters.programme != "fha")) continue; setofloans.balanced = [I,"Most balanced"]; break; } } /** * find loop to find the most neutral and the highest price */ for (let i=0; i < list.budget.length; i++) { let I = list.budget[i].i; let M = list.list[I]; let P = parseInt(M.filters.purchase_price,10); if ( ((goals_protect_purchase == "N" && inrange(P)) || inrange(P)) && M.filters.c2c_colour != "red" && M.filters.budget_colour != "red") { if (filter_type > 0 && (filter_type == 1 && M.filters.programme != "conv" || filter_type == 2 && M.filters.programme != "fha")) continue; setofloans.lowmonthly = [I,"Lowest monthly"]; break; } } /** * find loop to find the lowest C2C and the highest price */ for (let i=0; i < list.c2c.length; i++) { let I = list.c2c[i].i; let M = list.list[I]; let P = parseInt(M.filters.purchase_price,10); if ( ((goals_protect_purchase == "N" && inrange(P)) || inrange(P)) && M.filters.c2c_colour != "red" && M.filters.budget_colour != "red") { if (filter_type > 0 && (filter_type == 1 && M.filters.programme != "conv" || filter_type == 2 && M.filters.programme != "fha")) continue; setofloans.lowclosing = [I,"Low closing cost / higher rate"]; break; } } for (let i=0; i < list.pp.length; i++) { let I = list.pp[i].i; if (setofloans.backuphighloan == false) { setofloans.backuphighloan = [I,`Highest Possible Purchase Price`]; } let M = list.list[I]; if (M.filters.c2c_colour != "red") { if (filter_type > 0 && (filter_type == 1 && M.filters.programme != "conv" || filter_type == 2 && M.filters.programme != "fha")) continue; setofloans.highpurchase = [I,`Highest Possible Purchase Price`]; break } } let popbd = false; for (let i=0; i < list.pp.length; i++) { let I = list.pp[i].i; let M = list.list[I]; let P = parseInt(M.filters.purchase_price,10); if (M.filters.c2c_colour != "red") { if (filter_type > 0 && (filter_type == 1 && M.filters.programme != "conv" || filter_type == 2 && M.filters.programme != "fha")) continue; let pop = false; let m = M.filters; if (m.ltv == 80 || m.ltv == 85 || m.ltv == 90 || m.ltv == 95 || m.ltv == 96.5 || m.ltv == 97 ) { if (m.abdr >= 99.5 && m.abdr <= 100.5) { if (m.xmrate.startsWith("uf") == false && m.xmrate.startsWith("split") == false) { pop = true; if (setofloans.popular == false) { setofloans.popular = [I,"Popular"]; popbd = m.abdr; } else { if (inrange(P)) { if (Math.abs(m.abdr-100) < Math.abs(popbd-100)) { setofloans.popular = [I,`Popular ${M.filters.purchaseprice_colour}`]; popbd = m.abdr; } } } } } } } } let _displaygoto = function(OBJ) { if (OBJ == false) return; let I = OBJ[0]; let M = list.list[I]; _goto_card(M.filters,M.i, OBJ[1],M.row,M.filters.programme,"This is your reccommended loan."); } let _displayfirst = function(OBJ) { if (OBJ == false) return; let I = OBJ[0]; let M = list.list[I]; reccommandationbubble.set("a_c2c", M.filters.c2c); reccommandationbubble.set("a_bud", M.filters.budget); __h += `
${OBJ[1]}
`; __h += _make_card(M.filters,M.i, OBJ[1],M.row,M.filters.programme,"This is your reccommended loan."); } let _displaynext = function(OBJ) { if (OBJ == false) return; let I = OBJ[0]; let M = list.list[I]; reccommandationbubble.set("b_c2c", M.filters.c2c); reccommandationbubble.set("b_bud", M.filters.budget); __h += `
${OBJ[1]}
`; __h += _make_card(M.filters,M.i, OBJ[1],M.row,M.filters.programme,reccommandationbubble.get("Compared with the reccommended loan.")); } // calculation_priority = "high_purchase"; if (1 == 1) { if (firsttime) { if (setofloans.highconv !== false && setofloans.highfha == false) { _displaygoto(setofloans.highconv); return; } if (setofloans.highconv == false && setofloans.highfha !== false) { _displaygoto(setofloans.highfha); return; } if (setofloans.highconv[2] > setofloans.highfha[2]) { _displaygoto(setofloans.highconv); return; } else { _displaygoto(setofloans.highfha); return; } } _displayfirst(setofloans.highconv); _displaynext(setofloans.highfha); _displaynext(setofloans.cheapconv); _displaynext(setofloans.cheapfha); } else if (calculation_priority == "high_purchase") { if (firsttime) { if (setofloans.highpurchase !== false) { _displaygoto(setofloans.highpurchase); } else { _displaygoto(setofloans.backuphighloan); } return; } _displayfirst(setofloans.highpurchase); _displaynext(setofloans.lowmonthly); _displaynext(setofloans.lowclosing); _displaynext(setofloans.lowrate); _displaynext(setofloans.popular); } else if (calculation_priority == "low_closing") { if (firsttime) { if (setofloans.lowclosing !== false) { _displaygoto(setofloans.lowclosing); } else { _displaygoto(setofloans.backuphighloan); } return; } _displayfirst(setofloans.lowclosing); _displaynext(setofloans.highpurchase); _displaynext(setofloans.lowmonthly); _displaynext(setofloans.lowrate); _displaynext(setofloans.popular); } else if (calculation_priority == "low_rate") { if (firsttime) { if (setofloans.lowrate !== false) { _displaygoto(setofloans.lowrate); } else { _displaygoto(setofloans.backuphighloan); } return; } _displayfirst(setofloans.lowrate); _displaynext(setofloans.highpurchase); _displaynext(setofloans.lowmonthly); _displaynext(setofloans.lowclosing); _displaynext(setofloans.popular); } else if (calculation_priority == "balanced_apr") { if (firsttime) { if (setofloans.lowmonthly !== false) { _displaygoto(setofloans.lowmonthly); } else { _displaygoto(setofloans.backuphighloan); } return; } _displayfirst(setofloans.lowmonthly); _displaynext(setofloans.highpurchase); _displaynext(setofloans.lowclosing); _displaynext(setofloans.lowrate); _displaynext(setofloans.popular); } __h += "
"; //h += "
"; let pp = -1; for (let i=0; i < list.pp.length; i++) { let I = list.pp[i].i; let M = list.list[I]; let P = parseInt(M.filters.purchase_price,10); if (filter_type > 0 && (filter_type == 1 && M.filters.programme != "conv" || filter_type == 2 && M.filters.programme != "fha")) continue; if (M.filters.c2c_colour != "red" && M.filters.budget_colour != "red") { if (pp == false || d10(pp) != d10(P)) { pp = P; h += `
Purchase Price : ${ mar.fmt.currency(parseInt(d10(pp)*10000,10))} - ${ mar.fmt.currency(parseInt(d10(pp)*10000,10)+9000)}
`; } h += _make_card(M.filters,I, `Loan @ ${ mar.fmt.currency(parseInt(pp,10))}`,M.row,M.filters.programme); // h += _make_card(list.list[list.pp[i].i].filters,list.pp[i].i, "High PURCHASE loan",list.list[list.pp[i].i].row,list.list[list.pp[i].i].filters.programme); } } h += "
"; mar.three_panel_pane.p2(h); let $p2 = $(mar.three_panel_pane.getp2()); mar.three_panel_pane.p2(); })+"'>See all Loans
" __h += "
"; __h += "
"; __h += "
"; __h += "
"; __h += "
"; __h += "
"; __h += "
"; __h += "
"; __h += "
"; __h += "
"; mar.three_panel_pane.init(); let p2 = ""; p2 += "
"; p2 += "
";//end pane __h = mar.three_panel_pane.getHtml(__h,p2); //launch the overlay var s = document.createElement("div"); s.setAttribute("class","normal-form"); var s = document.createElement("div"); s.setAttribute("class","normal-form monthly-budget"); s.innerHTML = __h; swal({ className : "middleInfoPopup", content : s, buttons : false }) setTimeout(function prepare_popup_radios(){ $("#magic2-popup").find(".xx-radio").myradio(); $("#magic2-popup #restyleMeToChekboxes div").removeClass('md-radio'); $("#magic2-popup #restyleMeToChekboxes input").addClass('styled-checkbox'); $("#magic2-popup .dropDownRadioHolder .md-radio label").css('width', '100%' ); },500) } mar.pg.oc = oc; let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //console.warn ('input mask: ', $("#body-container ._sqft").inputmask); $("#body-container ._sqft").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character postfix: 'sq ft', rightAlign: false, autoUnmask : true }); $(".budget_monthly").click(function(){ var h = "
"; if (mar.mortgage) { let mmr = mar.mortgage.appsum2; h += makepopup(mmr); } h += "
"; var s = document.createElement("div"); s.setAttribute("class","normal-form monthly-budget"); s.innerHTML = h; swal({ className : "fred", content : s }) $(".swal-modal.fred").parent().css("background-color","rgba(0,0,0,.8)"); }); $(".budget_c2c").click(function(){ var h = "
"; if (mar.mortgage) { let mmr = mar.mortgage.appsum1; h += makepopup(mmr); } h += "
"; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = h; swal({ className : "fred", content : s }) $(".swal-modal.fred").parent().css("background-color","rgba(0,0,0,.8)"); }) $("#personal_mortgage_proposal").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = mar.mortgages; swal({ content : s }) }); let tol = radio("loan_duration") elaine_adapter.mortgage.getcachelist(mar.ID, `wl_${tol}_`, function(list) { if (list == false) { oc(); return; } // $("#personal_mortgage_proposal_1").after("") $("#personal_mortgage_proposal_1").after("") // $("#personal_mortgage_proposal_1").after("") // $("#personal_mortgage_proposal_1").after("") mar.pg.__popup_list_list = list; mar.pg.__popup_list(true); }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "estimate" } })(); mar.pg["scenario-magic3"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { var goals_target_value = getScenario_data("goals_target_value","250000"); var goals_target_budget_low = getScenario_data("goals_target_budget_low","10000"); var goals_target_budget_high = getScenario_data("goals_target_budget_high","10000"); var goals_target_c2c_low = getScenario_data("goals_target_c2c_low","20000"); var goals_target_c2c_high = getScenario_data("goals_target_c2c_high","20000"); var goals_protect_c2c = getScenario_data("goals_protect_c2c","N"); var goals_protect_budget = getScenario_data("goals_protect_budget","N"); var goals_protect_purchase = getScenario_data("goals_protect_purchase","N"); var term_of_loan = getScenario_data("term_of_loan","tol30"); var arm_of_loan = getScenario_data("arm_of_loan",""); /// let loan_time = getScenario_data("loan_type_purchase_options","") if (loan_time == "soon") { setScenario_data("goals_protect_c2c","Y"); setScenario_data("goals_protect_budget","N"); setScenario_data("goals_protect_purchase","Y"); mar.fakesave(); } else if (loan_time == "contract") { setScenario_data("goals_protect_c2c","Y"); setScenario_data("goals_protect_budget","N"); setScenario_data("goals_protect_purchase","Y"); mar.fakesave(); } else { setScenario_data("goals_protect_c2c","Y"); setScenario_data("goals_protect_budget","Y"); setScenario_data("goals_protect_purchase","N"); mar.fakesave(); } // mar.txt.soon = "Contract soon"; // mar.txt.just_looking = "Just looking"; // mar.txt.contract = "Under contract"; // mar.txt.one_month = "1-3 months"; // mar.txt.three_months = "3-6 months"; // // // // var goals_protect_c2c = getScenario_data("goals_protect_c2c","N"); // var goals_protect_budget = getScenario_data("goals_protect_budget","N"); // var goals_protect_purchase = getScenario_data("goals_protect_purchase","N"); // // var goals_protect_c2c = ($("#goals_protect_c2c:checked").length == 0) ? "N" : "Y"; // var goals_protect_budget = ($("#goals_protect_budget:checked").length == 0) ? "N" : "Y"; // var goals_protect_purchase = ($("#goals_protect_purchase:checked").length == 0) ? "N" : "Y"; // //// swal ([goals_protect_c2c,goals_protect_budget,goals_protect_purchase].join(",")); // // if (goals_protect_c2c == "Y" && goals_protect_budget == "Y" ) { // $("#goals_protect_purchase").prop("disabled",true); // } else if (goals_protect_c2c == "Y" && goals_protect_purchase == "Y" ) { // $("#goals_protect_budget").prop("disabled",true); // } else if (goals_protect_budget == "Y" && goals_protect_purchase == "Y" ) { // $("#goals_protect_c2c").prop("disabled",true); // } else { // $("#goals_protect_purchase").prop("disabled",false); // $("#goals_protect_budget").prop("disabled",false); // $("#goals_protect_c2c").prop("disabled",false); // } // // // setScenario_data("goals_protect_c2c",goals_protect_c2c); // setScenario_data("goals_protect_budget",goals_protect_budget); // setScenario_data("goals_protect_purchase",goals_protect_purchase); mar.fakesave(); /// mar.state.override_downpayment = false; var n0 = getApplicantsNames_v2(0).Name; let h = ""; h += frm.htitle("LOAN COST ILLUSTRATION").render(); h += frm.elaine("We've pre-selected the best loan match for you. You can make adjustments by selecting any loan duration and loan priority below.","").render(); //if we will use this elsewhere we could make it a class called a switch-field h += '
'; h += '
Select loan duration:
'; selected = (term_of_loan == "tol30") ? "checked" : ""; h += ''; h += ''; selected = (term_of_loan == "tol20") ? "checked" : ""; h += ''; h += ''; selected = (term_of_loan == "tol15") ? "checked" : ""; h += ''; h += ''; selected = (term_of_loan == "aol101") ? "checked" : ""; h += ''; h += ''; selected = (term_of_loan == "aol71") ? "checked" : ""; h += ''; h += ''; selected = (term_of_loan == "aol51") ? "checked" : ""; h += ''; h += ''; h += '
'; var lock = ''; var lock1 = ''; var _result = ""; _result += "
"; _result += "
"; _result += "
"; _result += "Est. max. purchase price"; _result += "
"; _result += "
"; _result += ""; _result += "
"; _result += "
"; _result += "
"; _result += "
"; _result += "Est. closing cost"; _result += "
"; _result += "
"; //_result += lock; _result += ""; _result += "
"; _result += "
"; _result += "
"; _result += "
"; _result += "Est. monthly budget"; _result += "
"; _result += "
"; //_result += lock1; _result += ""; _result += "
"; _result += "
"; _result += "
"; h += "
"; h += ""; h += '
Select what's most important to you:
'; var gridDataArray = [{fc1:3, fc2:1, fc3:2, fc4:4}, {price:150000, closing:15000, monthly:1200, interest:5.00}, {price:160000, closing:32000, monthly:1100, interest:4.00}, {price:170000, closing:18000, monthly:1300, interest:4.50}, {price:165000, closing:22000, monthly:1425, interest:3.70} ]; var gNumSt = ''; var gNumSelSt = ''; for(var gNum = 0; gNum< gridDataArray.length; gNum++){ if(gNum === 0){ h += "
"; h += "
High Purchase Price
"; h += "
Low Closing Cost
"; h += "
Low Monthly Cost
"; h += "
Low Interest Rate
"; h += "
"; h += "
"; }else{ if(gNum == gridDataArray[0].fc1){ gNumSt =' selectedLoanGridHeaderCell'; gNumSelSt = 'selectedLoanGridCell'; h += "
"+gridDataArray[gNum].price+"
"; h += "
"+gridDataArray[gNum].closing+"
"; h += "
"+gridDataArray[gNum].monthly+"
"; h += "
"+gridDataArray[gNum].interest+"
"; } if(gNum == gridDataArray[0].fc2){ gNumSt ='selectedLoanGridHeaderCell'; gNumSelSt = 'selectedLoanGridCell'; h += "
"+gridDataArray[gNum].price+"
"; h += "
"+gridDataArray[gNum].closing+"
"; h += "
"+gridDataArray[gNum].monthly+"
"; h += "
"+gridDataArray[gNum].interest+"
"; }else if(gNum == gridDataArray[0].fc3){ gNumSt ='selectedLoanGridHeaderCell'; gNumSelSt = 'selectedLoanGridCell'; h += "
"+gridDataArray[gNum].price+"
"; h += "
"+gridDataArray[gNum].closing+"
"; h += "
"+gridDataArray[gNum].monthly+"
"; h += "
"+gridDataArray[gNum].interest+"
"; }else if(gNum == gridDataArray[0].fc4){ gNumSt ='selectedLoanGridHeaderCell'; gNumSelSt = 'selectedLoanGridCell'; h += "
"+gridDataArray[gNum].price+"
"; h += "
"+gridDataArray[gNum].closing+"
"; h += "
"+gridDataArray[gNum].monthly+"
"; h += "
"+gridDataArray[gNum].interest+"
"; }else{ gNumSt = ''; gNumSelSt = ''; } gNumSt = ''; gNumSelSt = ''; } } /* h += "
"; h += "
High Purchase Price
"; h += "
Low Closing Cost
"; h += "
Low Monthly Cost
"; h += "
Low Interest Rate
"; h += "
"; h += "
"; h += "
150000
"; h += "
15000
"; h += "
1200
"; h += "
5.00
"; h += "
160000
"; h += "
32000
"; h += "
1100
"; h += "
4.00
"; h += "
170000
"; h += "
18000
"; h += "
1300
"; h += "
4.50
"; h += "
165000
"; h += "
22000
"; h += "
1425
"; h += "
3.70
"; */ h += "
"; /* h += "
"; h += "
"; h += "
"; h += "
"; h += "Low Purchase Price"; h += "
";//end loan head cell h += "
"; h += "Low Closing Cost"; h += "
";//end loan head cell h += "
"; h += "Low Monthly Cost"; h += "
";//end loan head cell h += "
"; h += "Low Interest Rate"; h += "
";//end loan head cell h += "
";//end loan grid header h += "
"; h += "
"; h += "150000"; h += "
";//end loan body cell h += "
"; h += "15000"; h += "
";//end loan body cell h += "
"; h += "1200"; h += "
";//end loan body cell h += "
"; h += "5.000"; h += "
";//end loan body cell h += "
";//end loan grid row h += "
"; h += "
"; h += "150000"; h += "
";//end loan body cell h += "
"; h += "15000"; h += "
";//end loan body cell h += "
"; h += "1200"; h += "
";//end loan body cell h += "
"; h += "5.000"; h += "
";//end loan body cell h += "
";//end loan grid row h += "
"; h += "
"; h += "150000"; h += "
";//end loan body cell h += "
"; h += "15000"; h += "
";//end loan body cell h += "
"; h += "1200"; h += "
";//end loan body cell h += "
"; h += "5.000"; h += "
";//end loan body cell h += "
";//end loan grid row h += "
"; h += "
"; h += "150000"; h += "
";//end loan body cell h += "
"; h += "15000"; h += "
";//end loan body cell h += "
"; h += "1200"; h += "
";//end loan body cell h += "
"; h += "5.000"; h += "
";//end loan body cell h += "
";//end loan grid row h += "
";//end loan grid holder h += "
";//end loan grid */ h += frm.htitle("
").render(); /* end modal content */ h += uihelpers.cbuttonbar3("Next",frm.addfunction(function(){ setScenario_data("mortgage",mar.mortgage); mar.fakesave(); mvc.go("#scenario-mortgageyes"); // var property_type = radio("property_type"); // var property_type_other = txt("#property_type_other"); // var monthly_rent = txt("#monthly_rent"); // // setScenario_data("property_type",property_type); // setScenario_data("property_type_other",property_type_other); // setScenario_data("monthly_rent",monthly_rent); // mar.fakesave(); // if (property_type == "sfr" || property_type == "condo") { // mvc.go("#scenario-mcc"); // } else { // mvc.go("#scenario-hoi"); // } }),"Back",frm.addfunction(function(){ mvc.go("#scenario-mortgage"); //mvc.go("#scenario-magic1"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-budget"); //mvc.go("#scenario-magic1"); }),"mar.help()"); h = Mustache.render(h,localopts); let show_pp = false; let oc = function() { $(".prev-button").css("display","none"); $(".next-button").css("display","none"); var goal_disp = ""; var goals_target_value = _num(getScenario_data("goals_target_value","250000")); var goals_target_budget = _num(getScenario_data("goals_target_budget","10000")); var loan_duration = radio("loan_duration"); var occupancy_type = getScenario_data("occupancy_type",""); var property_type = getScenario_data("property_type",""); setScenario_data("term_of_loan",loan_duration); mar.fakesave(); if (show_pp == false) { $("#purchaseprice-div").css("display","none"); } else { $("#purchaseprice-div").css("display","block"); } var goals_target_downpayment = _num(txt("#goals_target_downpayment")); if (goals_target_budget > 0) { goal_disp += "
Budget : $"+goals_target_budget+"
"; } if (goals_target_value > 0) { goal_disp += "
Target : $"+goals_target_value+"
"; } if (goals_target_downpayment > 0) { goal_disp += "
Down : $"+goals_target_downpayment+"
"; } var _suggested_downpayment = 0; if (goals_target_budget !== "" && goals_target_value !== "") { //console.warn(' _suggested_downpayment!!!! target budget us nit nothing! target budget: '+goals_target_budget+' mar.answers.v2.scenario.goals_target_value: '+goals_target_value); let DEPOSIT_PERCENTAGE = 0.035 /** * add in exceptions based on marvin's strategy ! * if type is investment 25% * investment if multi family or condo * */ if (occupancy_type == mar.OCCUPANCY_INVESTMENT) { DEPOSIT_PERCENTAGE = 0.25 // investment 25% } if (occupancy_type == mar.OCCUPANCY_2ND_HOME) { if (property_type == mar.PROPERTY_TYPE_SFR) { DEPOSIT_PERCENTAGE = 0.05 // 2nd home for family 5% } else if (property_type == mar.PROPERTY_TYPE_CONDO) { DEPOSIT_PERCENTAGE = 0.05 // same as above } else { DEPOSIT_PERCENTAGE = 0.25 // 2nd home multi family is treated as investment } } _suggested_downpayment += num(mar.answers.v2.scenario.goals_target_value) * DEPOSIT_PERCENTAGE; /* 3.5 % deposit */ _suggested_downpayment += num(mar.answers.v2.scenario.goals_target_value) * 0.020; /* 2.0 % closing costs */ } // console.warn(' mar.answers.v2.scenario.goals_target_budget: '+mar.answers.v2.scenario.goals_target_budget); // console.warn(' mar.answers.v2.scenario.goals_target_value: '+mar.answers.v2.scenario.goals_target_value); // console.warn(' _suggested_dow is NOT great than zero: '+_suggested_downpayment); if (_suggested_downpayment > 0) { // console.warn(' _suggested_dow is great than zero: '+_suggested_downpayment); $(".suggestionballoon .suggested_value").html(num(mar.answers.v2.scenario.goals_target_value).toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",")); $(".suggestionballoon .suggested_downpayment").html(num(_suggested_downpayment).toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ",")); } else { console.log(' _suggested_dow is NOT great than zero: '+_suggested_downpayment); $(".suggestionballoon .suggested_value").html("200000"); $(".suggestionballoon .suggested_downpayment").html("11000"); } $("#budget-needed").html(_suggested_downpayment) // console.log("!!goal_disp!!: "+goal_disp); // if (loan_type == "purchase") { // $("#_sc_goals").html(goal_disp); // if (!restricted && (mar.answers.v2.scenario.goals_target_budget == "" || mar.answers.v2.scenario.goals_target_value == "" || mar.answers.v2.scenario.goals_target_downpayment == "")) { // // toggle_restrict("scenario_simple_goals"); // restricted = true; // } // } mar.state.override_downpayment = false; mar.state.override_budget = false; var approxCosts = MAR.getApproximateClosingCosts(goals_target_value, 0).total10; // approximate closing costs var goals_target_budget_low = _num(txt("#goals_target_budget_low")); var goals_target_budget_high = _num(txt("#goals_target_budget_high")); var goals_target_c2c_low = _num(txt("#goals_target_c2c_low")); var goals_target_c2c_high = _num(txt("#goals_target_c2c_high")); var goals_protect_c2c = getScenario_data("goals_protect_c2c","N"); var goals_protect_budget = getScenario_data("goals_protect_budget","N"); var goals_protect_purchase = getScenario_data("goals_protect_purchase","N"); if (goals_protect_c2c == "Y") { if (goals_target_c2c_low > 0 && goals_target_c2c_high > 0) { var _c = Math.floor(( (_goals_target_budget - approxCosts) / mar.state.goals_target_value) * 100) if (_c > 80 && _c < 85) _c = 80; else if (_c <10 && _c >85) _c = 85; else if (_c <5 && _c >90) _c = 90; else _c = 10; mar.state.override_downpayment = _c; } } if (goals_protect_budget == "Y") { if (goals_target_budget_low > 0 && goals_target_budget_high > 0) { mar.state.override_budget = goals_target_budget_low; } } swal(JSON.stringify(mar.state)); if (goals_protect_purchase == "Y") { mar.calculatepart(goals_target_value); } else { mar.calculatepart(0); } let makegridfunction = function() { if ("mortgageLowBudget" in mar && mar.mortgageLowBudget) { gridDataArray[2].price = parseInt(mar.mortgageLowBudget.filters.purchase_price,10); gridDataArray[2].closing = parseInt(mar.mortgageLowBudget.filters.c2c,10); gridDataArray[2].monthly = parseInt(mar.mortgageLowBudget.filters.budget,10); gridDataArray[2].interest = mar.mortgageLowBudget.filters.rate; } else if (mar.mortgage) { gridDataArray[2].price = parseInt(mar.mortgage.filters.purchase_price,10); gridDataArray[2].closing = parseInt(mar.mortgage.filters.c2c,10); gridDataArray[2].monthly = parseInt(mar.mortgage.filters.budget,10); gridDataArray[2].interest = mar.mortgage.filters.rate; } if ("mortgageLowCost" in mar && mar.mortgageLowCost) { gridDataArray[1].price = parseInt(mar.mortgageLowCost.filters.purchase_price,10); gridDataArray[1].closing = parseInt(mar.mortgageLowCost.filters.c2c,10); gridDataArray[1].monthly = parseInt(mar.mortgageLowCost.filters.budget,10); gridDataArray[1].interest = mar.mortgageLowCost.filters.rate; } else if (mar.mortgage) { gridDataArray[1].price = parseInt(mar.mortgage.filters.purchase_price,10); gridDataArray[1].closing = parseInt(mar.mortgage.filters.c2c,10); gridDataArray[1].monthly = parseInt(mar.mortgage.filters.budget,10); gridDataArray[1].interest = mar.mortgage.filters.rate; } if ("mortgageLowApr" in mar && mar.mortgageLowApr) { gridDataArray[4].price = parseInt(mar.mortgageLowApr.filters.purchase_price,10); gridDataArray[4].closing = parseInt(mar.mortgageLowApr.filters.c2c,10); gridDataArray[4].monthly = parseInt(mar.mortgageLowApr.filters.budget,10); gridDataArray[4].interest = mar.mortgageLowApr.filters.rate; } else if (mar.mortgage) { gridDataArray[4].price = parseInt(mar.mortgage.filters.purchase_price,10); gridDataArray[4].closing = parseInt(mar.mortgage.filters.c2c,10); gridDataArray[4].monthly = parseInt(mar.mortgage.filters.budget,10); gridDataArray[4].interest = mar.mortgage.filters.rate; } if ("mortgageHighPurchase" in mar && mar.mortgageHighPurchase) { gridDataArray[3].price = parseInt(mar.mortgageHighPurchase.filters.purchase_price,10); gridDataArray[3].closing = parseInt(mar.mortgageHighPurchase.filters.c2c,10); gridDataArray[3].monthly = parseInt(mar.mortgageHighPurchase.filters.budget,10); gridDataArray[3].interest = mar.mortgageHighPurchase.filters.rate; } else if (mar.mortgage) { gridDataArray[3].price = parseInt(mar.mortgage.filters.purchase_price,10); gridDataArray[3].closing = parseInt(mar.mortgage.filters.c2c,10); gridDataArray[3].monthly = parseInt(mar.mortgage.filters.budget,10); gridDataArray[3].interest = mar.mortgage.filters.rate; } for(var gNum = 1; gNum< gridDataArray.length; gNum++){ $(".loanGrid-cell.loanGrid-row_"+gNum+".price").html(gridDataArray[gNum].price) $(".loanGrid-cell.loanGrid-row_"+gNum+".closing").html(gridDataArray[gNum].closing) $(".loanGrid-cell.loanGrid-row_"+gNum+".monthly").html(gridDataArray[gNum].monthly) $(".loanGrid-cell.loanGrid-row_"+gNum+".interest").html(gridDataArray[gNum].interest) } if (mar.makegridfunction) delete mar.makegridfunction; } mar.makegridfunction = makegridfunction; // // if (_goals_target_budget > highestclosing ) { // var _c = Math.floor(( (_goals_target_budget - mar.mortgage.filters.costs) / mar.state.goals_target_value) * 100) // mar.state.override_downpayment = _c; // } // } mar.pg.oc = oc; let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //console.warn ('input mask: ', $("#body-container ._sqft").inputmask); $("#body-container ._sqft").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character postfix: 'sq ft', rightAlign: false, autoUnmask : true }); $("#body-container ._percent").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character postfix: '%', rightAlign: false, autoUnmask : true }); $(".loanGrid-header .loanGrid-cell").click(function(e){ //console.warn('e: ',e); //console.warn('this: ',this); //console.warn('$this: ',$(this)); let elm = $(this); let filterChoice = elm.data('filterchoice'); //console.warn('filterChoice: '+filterChoice); $(".loanGrid-header .loanGrid-cell").removeClass('selectedLoanGridHeaderCell'); elm.addClass('selectedLoanGridHeaderCell'); $(".loanGrid-cell").removeClass('selectedLoanGridCell'); $(".loanGrid-row_"+filterChoice).addClass('selectedLoanGridCell'); $(".loanGrid-header .loanGrid-cell").removeClass('selectedLoanGridHeaderCell'); elm.addClass('selectedLoanGridHeaderCell'); //$(".loanGrid-row_"+filterChoice).position().top /* $(".loanGrid-row_"+filterChoice).animate( {top: -$(".loanGrid-row_"+filterChoice).position().top}, 400, function(){ $(".loanGrid-row_"+filterChoice).prependTo( ".loanGrid-body" ); }); */ $(".loanGrid-row_"+filterChoice).animate( {opacity: 0}, 400, function(){ $(".loanGrid-row_"+filterChoice).prependTo( ".loanGrid-body" ); $(".loanGrid-row_"+filterChoice).animate( {opacity: 1}, 400, function(){ }); }); // $(".loanGrid-row_"+filterChoice).prependTo( ".loanGrid-body" ); }); $(".budget_monthly").click(function(){ var h = "
"; if (mar.mortgage) { let mmr = mar.mortgage.appsum2; h += makepopup(mmr); } h += "
"; var s = document.createElement("div"); s.setAttribute("class","normal-form monthly-budget"); s.innerHTML = h; swal({ className : "fred", content : s }) $(".swal-modal.fred").parent().css("background-color","rgba(0,0,0,.8)"); }); $(".budget_c2c").click(function(){ var h = "
"; if (mar.mortgage) { let mmr = mar.mortgage.appsum1; h += makepopup(mmr); } h += "
"; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = h; swal({ className : "fred", content : s }) $(".swal-modal.fred").parent().css("background-color","rgba(0,0,0,.8)"); }) $("#personal_mortgage_proposal").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = mar.mortgages; swal({ content : s }) }); $("#info-loanDur").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Attention").render()+ "The faster you pay off your loan the less money you can borrow "+ "
"; swal({ className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Got it" } }); }); $("#info-importantGrid").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); //VAL = (itm) ? itm.whose_name : []; s.innerHTML = ""+ frm.htitle("Filter For:").render()+ "Filter list here?"+ frm.checklist("filter_loan_by","",[],"","",function(){},['Deselect All', 'USDA', 'VA', 'FHA', 'Conventional', 'Home Ready', 'Home Possible', 'Other Programs']).render()+ "
"; swal({ className : "middleInfoPopup", content : s, buttons : { cancel : "Close", call : { text: "Filter", value: "filter", closeModal: true } } }) .then((act) => { if (act == "filter") { //mar.pghelpers.callLoanOfficer(); } }); $("#body-container .xx-checklist").mychecklist(); }); $("#body-container .xx-checklist").mychecklist(); oc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); function __testfn_epp() { var creditscore = [570,610,630,690]; var fthb = [true,false]; var va = [true,false]; var ot = [mar.OCCUPANCY_PRIMARY, mar.OCCUPANCY_2ND_HOME, mar.OCCUPANCY_INVESTMENT]; var pt = [ mar.PROPERTY_TYPE_SFR, mar.PROPERTY_TYPE_CONDO, mar.PROPERTY_TYPE_DUPLEX, mar.PROPERTY_TYPE_TRIPLEX, mar.PROPERTY_TYPE_FOURPLEX, mar.PROPERTY_TYPE_OTHER]; let sh = elaineui.scenarioHelpers; let $w = $("#body-container"); $w.html("test report
");
	$w = $("#body-container pre");

	let InsuranceApiReturn = false;
	
	creditscore.forEach(function (_cs) {
		fthb.forEach(function (_fthb) {
			va.forEach(function (_va) {
				ot.forEach(function (_ot) {
					pt.forEach(function (_pt) {
						//https://lo.durunner.ai/calc/home_owners_insurance?square_foot=2500&build_period=1990&county=01003&backend_lia_pm=800&condo=N&close_to_or_on_water=N&sfr=N&in_community=N&luxury_community=N&luxury_condo=N
						var _url = "/calc/home_owners_insurance?1" +
							"&county=" + getCounty_v2() +
							"&square_foot=1700" +
							"&build_period=1990" +
							"&backend_lia_pm=800" +
							"&condo=" + ((_pt == "condo") ? "Y" : "N") +
							"&close_to_or_on_water=N" +
							"&sfr=" + ((_pt == "sfr") ? "Y" : "N") +
							"&in_community=" + ((_pt == "sfr") ? "N" : "Y") +
							"&luxury_community=N" +
							"&luxury_condo=N";
						
						$.get(_url, function(d2) {
							
							InsuranceApiReturn = false;
							if (d2 && "outputs" in d2) InsuranceApiReturn = d2.outputs;
							let options_obj = {
								InsuranceApiReturn : InsuranceApiReturn	
							}
							
//							Needs to use the Asynch version of "getEstimatedPurchasePriceFromCash2Close" -- change before use
//							for (var cc = 500; cc < 80000; cc+=500) {
//								var hh = [];
//								var pp = sh.getEstimatedPurchasePriceFromCash2Close(_ot, _pt, _va, _cs, _fthb, cc, options_obj, hh);
//								var l = sprintf("
cs %s , fthb %s, va %s, ot %s, pt %s, cc %s [= $ %s ] (%s)",_cs,_fthb,_va,_ot,_pt,cc,pp,hh[0]); // $w.append(l) // } }); }) }) }) }) }) } mar.pg["scenario-magic1"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { var goals_protect_c2c = getScenario_data("goals_protect_c2c","N"); var goals_protect_budget = getScenario_data("goals_protect_budget","N"); var goals_protect_purchase = getScenario_data("goals_protect_purchase","N"); let h = ""; h += frm.htitle("MAGIC TRIANGLE").render(); h += frm.elaine("Purchase price, closing cost, and your monthly budget are all tied together in a Magic Triangle, where one number influences the other.","er").render(); //h += frm.h2("Note: To set up your home loan accurately we need to know your priorities.").render(); //h += frm.hr().render(); h += "
" h += "
Select the two options that are most important to you:
"; VAL = goals_protect_c2c; h += frm.scheck("goals_protect_c2c","Do not exceed the amount of cash I need to bring to closing.",VAL,"","",function(){ oc(); }, {}).render(); VAL = goals_protect_budget; h += frm.scheck("goals_protect_budget","Do not exceed my monthly maximum budget.",VAL,"","",function(){ oc(); }, {}).render(); VAL = goals_protect_purchase; h += frm.scheck("goals_protect_purchase","Do everything possible to get my to my purchase amount.",VAL,"","",function(){ oc(); }, {}).render(); h += "
"; /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var goals_protect_c2c = ($("#goals_protect_c2c:checked").length == 0) ? "N" : "Y"; var goals_protect_budget = ($("#goals_protect_budget:checked").length == 0) ? "N" : "Y"; var goals_protect_purchase = ($("#goals_protect_purchase:checked").length == 0) ? "N" : "Y"; var numberofyes = 0; if (goals_protect_c2c == "Y") numberofyes++; if (goals_protect_budget == "Y") numberofyes++; if (goals_protect_purchase == "Y") numberofyes++; if (numberofyes < 2) { mar.tip(".help-button","warning","you need to select 2 options before continuing","top"); return false; } mvc.go("#scenario-magic2"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-hoa"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { var goals_protect_c2c = ($("#goals_protect_c2c:checked").length == 0) ? "N" : "Y"; var goals_protect_budget = ($("#goals_protect_budget:checked").length == 0) ? "N" : "Y"; var goals_protect_purchase = ($("#goals_protect_purchase:checked").length == 0) ? "N" : "Y"; // swal ([goals_protect_c2c,goals_protect_budget,goals_protect_purchase].join(",")); if (goals_protect_c2c == "Y" && goals_protect_budget == "Y" ) { $("#goals_protect_purchase").prop("disabled",true); } else if (goals_protect_c2c == "Y" && goals_protect_purchase == "Y" ) { $("#goals_protect_budget").prop("disabled",true); } else if (goals_protect_budget == "Y" && goals_protect_purchase == "Y" ) { $("#goals_protect_c2c").prop("disabled",true); } else { $("#goals_protect_purchase").prop("disabled",false); $("#goals_protect_budget").prop("disabled",false); $("#goals_protect_c2c").prop("disabled",false); } setScenario_data("goals_protect_c2c",goals_protect_c2c); setScenario_data("goals_protect_budget",goals_protect_budget); setScenario_data("goals_protect_purchase",goals_protect_purchase); mar.fakesave(); } mar.pg.oc = oc; let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(); } }, quick : false, }); $(".info-prio").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "To set up your home loan accurately we need to know your priorities

" + "When your budget is low, but you still want to buy an expensive house, " + "you instinctively know that you'll have to buy it cash, or with a lot of money down. " + "The elements Purchase Price, the Closing Cost, and you Monthly Budget, are tied together.

" + "Sometimes you can't have it all, you will need to prioritize what is most important to you."; swal({ title : "Magic triangle", className : "fred3", content : s, button : "got it" }) }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["scenario-crossroads"] = (function(){ var html = ""; var VAL = ''; function render(pg, localopts) { mar.showHideDiv = function(e, num){ e.preventDefault(); var $st = $('#hidDiv'+num); if ($st.hasClass("x-hide")) { $st.removeClass('x-hide'); $('#dropDownExpandCaret'+num).html('∧'); $('#dropDownRadio'+num).css('border-bottom-right-radius', '0'); $('#dropDownRadio'+num).css('border-bottom-left-radius', '0'); } else { $st.addClass('x-hide'); $('#dropDownExpandCaret'+num).html('∨'); $('#dropDownRadio'+num).css('border-bottom-right-radius', '4px'); $('#dropDownRadio'+num).css('border-bottom-left-radius', '4px'); } // console.log(' show :'+st); // console.log(' show $(st):',$(st)); $("#body-container").scrollTo("max",200); } let has_visited = (getScenario_data("__hasvisited_crossroads","N") == "Y"); let h = ""; h += frm.htitle("Choose your route").render(); h += frm.elaine("We can give you a quick idea of what you can borrow, anonymously. Or you can just go for it, save yourself some time, and get a much more accurate calculation in just 8 minutes.","er").render(); h += "
"; //h += "
I got it, press continue
"; h += "
"; /* h += "
"; h += frm.radio("crossroads","I want:",VAL,"","",false,{ personal : "A personal loan calculation
Faster route- get a personalized well esitmated, maximum loan calculation", rough : "A rough estimate
The anonymous quick fix. Get a general idea of what you can { { buy / refinanace} } without anyone nosing in your personal business (YET)! This adds 4 minutes to your loan application." }).render(); h += "
"; //end turn into checkbox */ h += ""; //end dropDownRadioHolder h += "
"; //end er h += "
"; //end er /* end modal content */ h += uihelpers.cbuttonbar("I got it",frm.addfunction(function(){ var val; /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); $(".dr-button.next-button").html("Continue"); if ($reveals.length > 0) { $(".igotit").remove(); let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ let _v1 = radio("crossroads1"); let _v2 = radio("crossroads2"); if (_v1 == "" && _v2 == "") { mar.tip(".help-button","warning","You need to select an option before continuing.","top"); return false; } if (_v1 != "") { setScenario_data("crossroads","route1"); } else { setScenario_data("crossroads","route2"); } setScenario_data("__hasvisited_crossroads","Y"); setScenario_data("__scenario_"+"crossroads"+"_passed","Y"); mar.fakesave(); mvc.goto("#_0300",false); // router //mvc.go("#up-next-prescan"); //mvc.go("#scenario-budget"); }),"Back",frm.addfunction(function(){ if (MAR.isMccEligible()) { mvc.go("#scenario-mcc"); } else { mvc.go("#scenario-property"); } }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(type) { if(type === 1){ radio("crossroads2", ''); }else if(type === 2){ radio("crossroads1", ''); } //$('#hidDiv1').addClass('x-hide'); //$('#hidDiv2').addClass('x-hide'); // $('.dropDownExpandCaret').html('∨'); // $('.dropDownRadio').css('border-bottom-right-radius', '4px'); // $('.dropDownRadio').css('border-bottom-left-radius', '4px'); } //mar.pg.oc = oc; let or = function(){ let sp = mar.isallowed_scenario("#scenario-crossroads"); if (typeof sp === "string") { mvc.go(sp); return; } if (typeof __durunnersys !== "undefined" && "flow" in __durunnersys && "section_calc" in __durunnersys.flow && __durunnersys.flow.section_calc === "N") { setScenario_data("crossroads","route1"); setScenario_data("__hasvisited_crossroads","Y"); setScenario_data("__scenario_crossroads_passed","Y"); mar.fakesave(); mvc.goto("#_0300",false); // router } $("#body-container .xx-checklist").mychecklist(); $("#body-container").find(".xx-radio").myradio(); var sc = getScenario_data("crossroads",false); if (sc) radio("crossroads",sc); $("#body-container .xhuman").Humanize({ opts : {}, quick : false }); //call this to force radios to checkboxes $("#restyleMeToChekboxes div").removeClass('md-radio'); $("#restyleMeToChekboxes input").addClass('styled-checkbox'); $(".dropDownRadioHolder .md-radio label").css('width', '100%' ); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "property" } })(); /* file /ui/app/js/pages._functions.js , last updated 1548691858286*/ mar.pg.calcs = (function(){ function makecsttable(ct) { var h = ""; for (let i=0; i < ct.length; i++) { let lin = ct[i].split("\t"); h += "
"+lin[1]+"
"+lin[2]+"
"+parseInt(lin[3],10)+"
"; } //h = "
"+h+"
"; var costs = 0; var costs_tab = ""; costs_tab += ""; costs_tab += ""; costs_tab += sprintf(""); var dollars = function(n) { return sprintf("
$%s
",mar.fmt.DD(n," ")); } var dollarsEditable = dollars; // changed for (let i=0; i < ct.length; i++) { let lin = ct[i].split("\t"); let aprbutton = ""; let dataid = ""; if (lin.length > 6) { dataid = lin[6]; } if (lin.length > 4) { if (lin[4] == "0") { aprbutton += "A"; } if (lin[5] == "0") { aprbutton += "Q"; } } // if (lin.length > 5) { // if (lin[5] == "0") { // aprbutton += " QM "; // } // else { // aprbutton += " QM "; // } // } var newsub = function(lin,dataid,aprbutton) { var lin22 = sprintf("%s",lin[2]); var lin22 = sprintf("%s",dataid,lin[2]); return sprintf("" + "" + "" + "" + "" + "" + "" + "",lin[1],lin22,dollarsEditable(lin[3],dataid),aprbutton); } if (lin[0] == "main") { var lin22 = sprintf("%s",lin[2]); costs_tab += sprintf("" + "" + "" + "" + "" + "",lin[1],lin22,dollars(lin[3]),aprbutton); } else if (lin[0] == "maine") { dataid = lin[1].trim().substring(0,1); var lin22 = sprintf("%s",lin[2]); costs_tab += sprintf("" + "" + "" + "" + "" + "",lin[1],lin22,dollarsEditable(lin[3],dataid),aprbutton); } else if (lin[0] == "maint") { costs_tab += sprintf("" + "" + "" + "" + "" + "",lin[1],lin[2],dollars(lin[3]),aprbutton); } else if (lin[0] == "total") { costs_tab += sprintf("" + "" + "" + "" + "" + "",lin[1],lin[2],dollars(lin[3]),aprbutton); } // else if (lin[0] == "Total") { // costs_tab += sprintf("" + // "" + // "" + // "" + // "" + // "" + // "",lin[1],lin[2],dollars(lin[3])); // } else if (lin[0] == "Total") { // old costs_tab += sprintf("" + "" + "" + "" + "" + "",lin[1],lin[2],dollars(lin[3]),aprbutton); } else if (lin[0] == "subh") { costs_tab += sprintf("" + "" + "",lin[1],lin[2]); } else if (lin[0] == "subf") { // costs_tab += sprintf("" + // "" + // "",lin[1],lin[1]); } else if (lin[0] == "sub") { if (num(lin[3]) > 0) { costs_tab += newsub(lin,dataid,aprbutton); } } else if (lin[0] == "subt") { costs_tab += sprintf("" + "" + "" + "" + "" + "",lin[1],lin[2],dollars(lin[3]),aprbutton); } else { costs_tab += (""); } } costs_tab += ""; costs_tab += "
%s %s%s%s
%s %s%s%s
%s %s%s%s
%s %s%s(+/+)%s
%s %s  %s%s
%s %s  %s
%s %s  %s%s
%s %s
Add
%s %s%s(+/+)%s
 
Warnings: * Transfer taxes are usually paid for by Seller. We assume this to be true. Usually with bank owned properties and new construction the buyer pays. ** We assume Home Owners Insurance and Flood Insurance to be paid before closing. You need to close with a binded insurance on your home. This can be costly depending on where you close.
"; h = "
"+costs_tab+"
"; return h; } function ttt(m) { let tt = ""; tt += ""; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += ``; tt += "
Loan
Purchase${elaineui.format("cur", m.purchace_price)}
Loan${elaineui.format("cur", m.max_loan)}
Financeable UFMI${elaineui.format("cur", m.ufmi_fin)}
Costs
downpayment${elaineui.format("cur", m.downpayment)}
costs${elaineui.format("cur", m.costs)}
Financeable UFMI(${elaineui.format("cur", m.ufmi_fin)})
c2c${elaineui.format("cur", m.c2c)}
Monthly
P&I${elaineui.format("cur", m.m_pay)}
T - tax${elaineui.format("cur", m.m_tax)}
M - MI${elaineui.format("cur", m.mmi)}
I - insurance${elaineui.format("cur", m.m_hoi)}
I - flood${elaineui.format("cur", m.m_flood)}
H - HOA${elaineui.format("cur", m.m_hoa)}
budget${elaineui.format("cur", m.budget)}
Ratios
LTV${m.ltv}
CLTV${m.cltv}
Down${elaineui.format("perc", m.down)}
apr${elaineui.format("perc2", m.apr)}
MI
MI${m.xmrate}
mmi${elaineui.format("perc2",m.mmip)}
mmi${elaineui.format("cur",m.mmi)}
ufmi${elaineui.format("perc2",m.ufmip)}
ufmi${elaineui.format("cur",m.ufmi)}
Buydowns
bd rate${elaineui.format("perc2", m.abdr)}
rate${elaineui.format("perc2", m.rate)}
bd/ l credit${elaineui.format("cur", m.buydown)}
Scenario
FTHB${m.FTHB}
cscore${m.cscore}
duration${m.duration}
purpose${m.purpose}
property_type${m.property_type}
QM${m.qmpass}
c2c_colour${m.c2c_colour}
budget_colour${m.budget_colour}
"; return tt; } let sel_calc = false; let alt_calc = false; let sel_list = false; let sel_list_idx = 0; function set_sel_calc(sc, alt) { sel_calc = sc; alt_calc = alt; sel_list = false; sel_list_idx = 0; } function get_sel_calc() { return sel_calc; } function get_sel_calcs() { return { sel : sel_calc, alt : alt_calc } } function dis_calc_next() { sel_list_idx = 1; dis_calc(alt_calc.mortgage) return; sel_list_idx++; if (sel_list_idx >= sel_list.list.length) sel_list_idx = 0; // loop round let _uuid = `pdu_30_${sel_list.list[sel_list_idx].filters.programme}:${sel_list.list[sel_list_idx].uuid}` dis_calc(_uuid) } function dis_calc_prev() { sel_list_idx = 0; dis_calc(); return; sel_list_idx--; if (sel_list_idx < 0) sel_list_idx = sel_list.list.length -1 let _uuid = `pdu_30_${sel_list.list[sel_list_idx].filters.programme}:${sel_list.list[sel_list_idx].uuid}` dis_calc(_uuid) } function switchfield(name, options,value,onchange) { let h = ""; h += `
`; for (x in options) { var selected = (value == x) ? "checked" : ""; h += `
`; h += ``; h += ``; h += `
`; } h += '
'; return h; } function dis_calc(UUID) { console.warn("PDO",sel_calc.mortgage) let MM = sel_calc.mortgage.split(":"); let programme = ""; if (arguments.length > 0 && UUID && UUID != "") { MM = UUID.split(":") programme = MM[0].split("_").pop() } elaine_adapter.m.getcacheone(mar.ID, MM[0],"", "", "", MM[1], function(MORT){ $.ajax({ url : `/api/mortgage/explode/`, data : { pdo : JSON.stringify(MORT.mortgage) }, type : 'POST', success : function( da ) { if (da && da.status == 0) { let pdo = da.data let h = ""; h += `
${pdo.appsumtitle}
`; h += "
"; if (sel_calc.mortgage.indexOf("conv") > -1) { let sel = MM[0].split("_").pop() if (alt_calc != false && alt_calc.mortgage != false) { h += switchfield("programme",{ conv : "Conventional", fha : "FHA" },sel,frm.addfunction(function(){ let r = radio("programme"); if (r == "conv") { dis_calc(); } if (r == "fha") { dis_calc(alt_calc.mortgage); } })) } // h += ""; // h += ""; } else { let sel = MM[0].split("_").pop() if (alt_calc != false && alt_calc.mortgage != false) { h += switchfield("programme",{ fha : "FHA", conv : "Conventional" },sel,frm.addfunction(function(){ let r = radio("programme"); if (r == "conv") { dis_calc(alt_calc.mortgage); } if (r == "fha") { dis_calc(); } })) } // h += ""; // h += ""; } h += "
"; h += makepopup(pdo.appsum2); h += "
"; h += makepopup(pdo.appsum1); // h += makepopup(pdo.appsum3); // h += makepopup(pdo.appsum4); // h += makepopup(pdo.appsum4e); // h += makepopup(pdo.appsum4p); h += "
"; h += ""; h += ""; h += "
"; h += "
"; h += "
"; h = `
${h}
`+ `
Got it!
` if (programme != "") { h += `
Continue with ${programme}
` } //h += `
${JSON.stringify(pdo,null,4)}
` let filename_cache = MM[0].split("_"); filename_cache.pop(); filename_cache = filename_cache.join("_") if (sel_list == false) { elaine_adapter.m.getcachelist(mar.ID, filename_cache , function(MORT_LIST){ sel_list = MORT_LIST; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = h; swal({ className : "fred", //"midelinfopopupOneButton", content : s, buttons : { ok : null, cancel : null } }); }); } else { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = h; swal({ className : "fred", //"midelinfopopupOneButton", content : s, buttons : { ok : null, cancel : null } }); } } } }); }); } return { makecsttable : makecsttable, dis_calc : dis_calc, dis_calc_next : dis_calc_next, dis_calc_prev : dis_calc_prev, set_sel_calc : set_sel_calc, get_sel_calc : get_sel_calc, get_sel_calcs : get_sel_calcs, ____id : "calcs" } })(); /* file /ui/app/js/pages.housingbudget.js , last updated 1715170616130*/ mar.pg["scenario-housingbudget-old"] = (function(){ })(); mar.pg_tmp_am_i_the_lo = function() { // return true; return mar.WE_ARE_FROM_LOI; } mar.tmp_lo_hide_show = (function() { let hidden_at = 0; let hide_for_secs = 60 * 5; function click() { if (is_hidden()) { show(); } else { hide(); } } function is_hidden() { return (hidden_at !== 0); } function hide() { $(`#lo-hide-show-style`).html(`.lo-info { display : none !important; }`); hidden_at = new Date().getTime(); timer_start(); } function show() { $(`#lo-hide-show-style`).html(``) hidden_at = 0; } function check() { if (hidden_at === 0) return; let now = new Date().getTime(); let hidden_for = (now - hidden_at)/1000; /* secs */ if (hidden_for > hide_for_secs) { show(); } } function timer_start() { setTimeout(timer_tick, 2000); } function timer_tick() { console.error(`TICK!`); if (is_hidden()) { check(); setTimeout(timer_tick, 2000); } } return { click : click, check : check, // is_hidden : is_hidden, // ___id : `lo hide show function` } })(); mar.tmp_open_febe_link = function(lnk) { mvc.go(lnk); } mar.tmp_open_credit = function() { parent.postMessage(JSON.stringify({ from : "app", action : "window_credit", appid : mar.ID }), "*"); } mar.revert_to_last_working_version = function(appid, version) { $.get(`/api/chatbot/recalculateVersion/${mar.ID}/${version}?revert=y`, function(da){ mvc.go(location.hash); }); } mar.tmp_sel_live_rate = function(version,trk,enc,snd,existingid,saved_1,vid, _setlive = "y", endfn = false) { let extra = ""; if (typeof trk === "string") extra += `&trk=${trk}`; if (typeof enc === "string") extra += `&enc=${enc}`; if (typeof snd === "string") extra += `&snd=${snd}`; if (typeof vid === "string") extra += `&vid=${vid}`; if (typeof existingid !== "undefined" && existingid === false) { if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_"+"ratequote_0_passed_cli","Y"); } setScenario_data("__scenario_"+"ratequote2_0"+"_passed","Y"); mar.fakesave("",function(){ let role = (mar.pg_tmp_am_i_the_lo()) ? "lo" : "cli"; if (_setlive === "y") { version = (saved_1) ? "999" : "1"; extra += `&set_live=y`; } else { version = "99"; extra += `&set_live=n`; } $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/${version}?role=${role}${extra}`, function(da){ MAR.ifOpt(da, "sc_obj", function(sco){ for (x in sco) { setScenario_data(x, sco[x]); } mar.fakesave("",function(){ // if (version === "0" || version === 0 || version === "") { $.get(`/api/chatbot/delSavedRate/${mar.ID}/0`, function(){ mvc.go(`#declarations-p1.0`); }); } else { mvc.go(`#declarations-p1.0`); } }); }); }); }); } else { $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/${version}?from=${version}&set_live=${_setlive}`+extra, function(da){ MAR.ifOpt(da, "sc_obj", function(sco){ for (x in sco) { setScenario_data(x, sco[x]); } mar.fakesave("",function(){ // mar.tmp_check_rq_encompass(endfn); if (version === "0" || version === 0 || version === "") { $.get(`/api/chatbot/delSavedRate/${mar.ID}/0`, function(){ }); } }); }); }); } } mar.tmp_check_rq_encompass = function(PG, reportnone) { let continue_fn = function() { if (typeof PG === "function") { PG(); } else if (typeof PG === "string") { mvc.go(PG); } else if (PG === false) { return; } else { mvc.go(location.hash); } } if (mar.pg_tmp_am_i_the_lo() === false) { continue_fn(); return; } if (typeof reportnone !== "boolean") reportnone = false; let logo = `
`; $.get(`/api/encompass/appHelpers/has_anything_changed?appid=${mar.ID}&type=borrower-0B.MO.SHORT`, function(damo){ /** * this is in the rate quotes page */ let diffs = MAR.getOpt(damo, "diffs", []); let diff_lnk = MAR.getOpt(damo, "lnk_rel", ""); /* relative link */ if (diffs.length > 0 || reportnone === true) { let h = ``; for (let i=0; i < diffs.length; i++) { let diff = diffs[i]; // h += `
${diff.t}
`; h += ``+ ``+ ``+ ``+ ``+ ``+ ``+ ``+ `${diff.t}`+ ``+ ``; } h = `${h}
UploadSkip 


`; function ui_onebutton() { $(".swal-modal").removeClass("middleInfoPopup"); $(".swal-modal").addClass("midelinfopopupOneButton"); $(".swal-footer .swal-button-container")[1].style.setProperty('display', 'none', 'important'); } let upload_fn = function(){ let excl_arr = []; for (let i=0; i < diffs.length; i++) { let diff = diffs[i]; let exclude = $(`#diff_skip_${i}`).prop("checked"); if (exclude) { excl_arr.push(diff.exc_path) } } let url = `${diff_lnk}&exclude=${excl_arr.join("|")}`; console.error(url); // let $but = $(".swal-footer .swal-button-container"); let $but = $(".swal-footer"); $but.addClass("x-hide"); $(`#swal_enc`).html(`
`) $.get(url, function(da_up) { let status = MAR.getOpt(da_up, "upd.status", -10); if (status !== 0) { $(`#swal_enc`).html(`Error : ${MAR.getOpt(da_up, "upd.statusMsg","")} TRY AGAIN`); ui_onebutton(); $(".swal-button.swal-button--cancel").html("Cancel"); $but.removeClass("x-hide"); } else { $(`#swal_enc`).html(`Success ...`) ui_onebutton(); $but.removeClass("x-hide"); $(".swal-button.swal-button--cancel").html("OK"); continue_fn(); } }); } let cfg = { title : "Loan Data Sync", txt : `
${logo}
`+ `
The selected fields will be pushed into Encompass
${h}
`, ok : "Upload", okfn : function(opts) { opts.preventclose = true; upload_fn(); }, cancel : "Cancel", cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", cancelfn : function() { continue_fn(); }, opts : { closeOnClickOutside : false, closeOnEsc : false } }; if (diffs.length === 0) { cfg.txt = `
`+ `
There are no changes to upload
`+ `
`; cfg.ok = false; cfg.cls = `midelinfopopupOneButton`; cfg.cancel = `OK`; } elaineui.swalprompt(cfg); } else { continue_fn(); } }); } mar.tmp_febe_breakdown = function() { MAR.rq_obj.breakdown(mar.tmp_febe_breakdown_obj); return; let febe = mar.tmp_febe_breakdown_obj; let h = ``; let lin = function(x,y) { return `
${x}
${y}
`; } if (MAR.getOpt(febe, "inc_src","") === "calculated") { h += lin('Income from App',elaineui.format("cur",febe.inc)); } else if (MAR.getOpt(febe, "inc_src","") === "scenario") { h += lin('Income from Cog',elaineui.format("cur",febe.inc)); } else { h += lin('Income not entered',elaineui.format("cur",febe.inc)); } if (MAR.getOptNum(febe, "reo_inc",0) > 0) { h += lin('- from work',elaineui.format("cur",(febe.inc - febe.reo_inc))); h += lin('- from REO',elaineui.format("cur",febe.reo_inc)); } if (MAR.getOpt(febe, "lia_src","") === "answers") { h += lin('Liailities from Cog',elaineui.format("cur",febe.lia)); } else if (MAR.getOpt(febe, "lia_src","") === "scenario") { h += lin('Liailities from Cog',elaineui.format("cur",febe.lia)); } else if (MAR.getOpt(febe, "lia_src","") === "calculated") { h += lin('Liailities from App',elaineui.format("cur",febe.lia)); } else { h += lin('Liailities not entered',elaineui.format("cur",febe.lia)); } h += lin('Monthly',elaineui.format("cur",febe.__monthly_tot)); h += `
`; h += `
FE
`; h += `
=
`; h += `
${elaineui.format("cur",febe.__monthly_tot)}
${elaineui.format("cur",febe.inc)}
`; h += `
=
`; h += `
${elaineui.format("perc3",febe.__fe)}
`; h += `
`; h += `
`; h += `
BE
`; h += `
=
`; h += `
${elaineui.format("cur",febe.__monthly_tot)} + ${elaineui.format("cur",febe.lia)}
${elaineui.format("cur",febe.inc)}
`; h += `
=
`; h += `
${elaineui.format("perc3",febe.__be)}
`; h += `
`; // h += `
${JSON.stringify(febe,null,4)}
`; let $popupelm = $(`.ratequote_popup .topgrid`); if ($popupelm.length > 0) { mar.tmp_febe_breakdown_close = function() { $(`.ratequote_popup .topgrid-details`).html(``) $(`.ratequote_popup .topgrid-details`).addClass(`x-hide-imp`) } h = `
`+ `
FE / BE Breakdown
`+ `${h}`+ `
Close
`+ `
`; $(`.ratequote_popup .topgrid-details`).html(h) $(`.ratequote_popup .topgrid-details`).removeClass(`x-hide-imp`) return; } else { elaineui.swalprompt({ title : "FEBE", txt : `
${h}
`, ok : `ok` }); } } mar.tmp_rq_reload_topgrid = function(febe, parent = ".topgrid", off = {}, da = {}){ /* -- MAXIMUMS -- */ let _maxltv = MAR.getOpt(febe, "maximums.gp.max_ltv",false); let _maxln = MAR.getOpt(mar.tmp_off, "grid_outputs.max_loan", false); let _maxlno = MAR.getOpt(mar.tmp_off, "rq_maxloan", false); if (_maxlno !== false) { _maxln = _maxlno; } let _maxfe = MAR.getOptNum(mar.tmp_off, "grid_outputs.max_dti_front", 55); let _maxbe = MAR.getOptNum(mar.tmp_off, "grid_outputs.max_dti_back", 55); let __maxln = 0; if (_maxln === false || _maxln === 0) { _maxln = `$----`; } else { __maxln = num(_maxln); _maxln = elaineui.format("cur", _maxln); } /* -- FE --*/ let FE = MAR.getOpt(mar.tmp_off_da, "FE", false); if (typeof FE !== "number") FE = false; if (MAR.app.is_nodoc()) FE = false; if (_maxfe > 100) FE = false; let _fe = (FE === false) ? `--.--` : elaineui.format("perc2",FE); /* -- BE --*/ let BE = MAR.getOpt(mar.tmp_off_da, "BE", false); if (MAR.app.is_nodoc()) BE = false; if (typeof BE !== "number") BE = false; if (_maxbe > 100) BE = false; let _be = (BE === false) ? `--.--` : elaineui.format("perc2",BE); /* --ltv --*/ let _ltv = elaineui.format("perc2",MAR.getOpt(mar.tmp_off,"ltv",0)); /* --c2c --*/ let _c2c = elaineui.format("cur",MAR.getOpt(mar.tmp_off,"total_costs",0)); // $(`${parent} .xfe`).html(`FE
${_fe}`); // $(`${parent} .xbe`).html(`BE
${_be}`); let ass_tot = MAR.getOptNum(febe, "ass_tot", false); let c2c = MAR.getOptNum(febe, "c2c", false); febe.__monthly = MAR.getOpt(mar.tmp_off_da, "data.monthly", false); febe.__monthly_tot = MAR.getOpt(mar.tmp_off_da, "data.monthly_total", false); febe.__monthly_febe = MAR.getOpt(mar.tmp_off_da, "data.monthly_febe", false); febe.__monthly_tot_febe = MAR.getOpt(mar.tmp_off_da, "data.monthly_total_febe", false); febe.__fe = _fe; febe.__be = _be; mar.tmp_febe_breakdown_obj = febe; $(`${parent} .xfebe`).html(`
FE ${_fe}
BE ${_be}
`); $(`${parent} .xltv`).html(`LTV
${_ltv}`); $(`${parent} .xc2c`).html(`C2CD:${_c2c}`); $(`${parent} .xc2c_t`).html(`C2CA:${_c2c}`); $(`${parent} .xlim`).html(`LIMIT
${_maxln}`); $(`${parent} .xc2c`).html(`C2CD:${elaineui.format("cur",c2c)}`); if (c2c === 0) { $(`${parent} .xc2c`).html(`C2CD:--.--`); } $(`${parent} .xc2c_t`).html(`C2CA:${elaineui.format("cur",ass_tot)}`); if (ass_tot === 0) { $(`${parent} .xc2c_t`).html(`C2CA:--.--`); } let white = function(elm) { $(`${parent} .x${elm}`).parent().css(`background-color`,`#ffffff`); $(`${parent} .x${elm}`).parent().css(`color`,`unset`); } let green = function(elm) { $(`${parent} .x${elm}`).parent().css(`background-color`,`#00cc0033`); $(`${parent} .x${elm}`).parent().css(`color`,`unset`); } let red = function(elm) { $(`${parent} .x${elm}`).parent().css(`background-color`,`#cc000099`); $(`${parent} .x${elm}`).parent().css(`color`,`#ffffff`); } let white_e = function(elm) { $(`${parent} .x${elm}`).css(`background-color`,`#ffffff`); $(`${parent} .x${elm}`).css(`color`,`unset`); } let green_e = function(elm) { $(`${parent} .x${elm}`).css(`background-color`,`#00cc0033`); $(`${parent} .x${elm}`).css(`color`,`unset`); } let red_e = function(elm) { $(`${parent} .x${elm}`).css(`background-color`,`#cc000099`); $(`${parent} .x${elm}`).css(`color`,`#ffffff`); } green(`lim`); if (_maxln === false || _maxln === 0 || ( typeof _maxln === `string` && _maxln.indexOf(`-`) > -1)) { white(`lim`); } else if (num(__maxln) < num(mar.tmp_off.loanvalue)) { red(`lim`); } let c2c_exceded = false; green_e(`c2c`); if (c2c === false) white_e(`c2c`); if (c2c === 0 && MAR.is_refi_limited_cashout() === false) white_e(`c2c`); else { let totcost = num(mar.tmp_off.total_costs); mar.tmp_change_ltv = function(newltv) { $(`#rq_ltv`).val(newltv); $(`#rq_ltv`).trigger(`change`); mar.tmp_loiar_toggle_changed = 10 mar.tmp_loiar_toggle_changed_fn(); } if (MAR.is_refi_limited_cashout()) { if (totcost < -2000) { red_e(`c2c`); // c2c_exceded = `C2C is lower than 2000 cash back and this it not allowed with a limited cach out refi`; let delta = ~~(Math.abs(totcost) - 2000); let loanvalue = MAR.getOpt(mar.tmp_off, "loanvalue",0); let pp = MAR.getOpt(mar.tmp_off, "refi_value",0); let new_loan = (loanvalue-delta) let new_ltv = ((new_loan-50)/pp)*100 let old_ltv = MAR.getOpt(mar.tmp_off, "final_ltv",0); c2c_exceded = ``; // c2c_exceded += `
Your points changed, which changes CTC.
`; c2c_exceded += `
You’ll need to reduce your CTC with ${elaineui.format('cur',delta)} to maintain the CTC close to $2000.
`; c2c_exceded += `
If you chose to decrease the loan amount then your LTV will change from ${elaineui.format('perc3opt',old_ltv)} to ${elaineui.format('perc3opt',new_ltv)}, which may affect your LLPA pricing.
`; if (_maxltv !== false && new_ltv > _maxltv) { c2c_exceded += `
Unfortunately this excedes the Maximum LTV of ${elaineui.format('perc3opt',_maxltv)} so in this case it would be better to change to a Rate & Term Refi
`; } else { c2c_exceded += `
Decrease loan amount with ${elaineui.format('cur',delta)}
`; } } if (totcost > -1500) { red_e(`c2c`); // c2c_exceded = `C2C is higher than 1500 You need to aim for $2000`; let delta = ~~(Math.abs(-2000 - totcost)); let loanvalue = MAR.getOpt(mar.tmp_off, "loanvalue",0); let pp = MAR.getOpt(mar.tmp_off, "refi_value",0); let new_loan = (loanvalue+delta) let new_ltv = ((new_loan-50)/pp)*100 let old_ltv = MAR.getOpt(mar.tmp_off, "final_ltv",0); c2c_exceded = ``; // c2c_exceded += `
Your points changed, which changes CTC.
`; c2c_exceded += `
You’ll need to increase your CTC with ${elaineui.format('cur',delta)} to maintain the CTC close to $2000.
`; c2c_exceded += `
If you chose to increase the loan amount then your LTV will change from ${elaineui.format('perc3opt',old_ltv)} to ${elaineui.format('perc3opt',new_ltv)}, which may affect your LLPA pricing.
`; if (_maxltv !== false && new_ltv > _maxltv) { c2c_exceded += `
Unfortunately this excedes the Maximum LTV of ${elaineui.format('perc3opt',_maxltv)} so in this case it would be better to change to a Rate & Term Refi
`; } else { c2c_exceded += `
Increase loan amount with ${elaineui.format('cur',delta)}
`; } } } else if (MAR.is_refi_cashout()) { if (totcost < (c2c * 1.1)) { c2c_exceded = `C2C is giving back too much`; } if (totcost > (c2c * 0.9)) { c2c_exceded = `C2C is not giving enough back`; } } else if (MAR.is_refi_rat()) { if (c2c < totcost) { c2c_exceded = `C2C exceeds the desired value for closing`; } } else { if (c2c < totcost) { c2c_exceded = `C2C exceeds the desired value for closing`; } } } green_e(`c2c_t`); if (ass_tot === false) white_e(`c2c_t`); if (ass_tot === 0) white_e(`c2c_t`); else if (ass_tot < num(mar.tmp_off.total_costs)) red_e(`c2c_t`); green_e(`fe`); if (FE === false) white_e(`fe`); else if (FE > _maxfe) red_e(`fe`); green_e(`be`); if (BE === false) white_e(`be`); else if (BE > _maxbe) red_e(`be`); green(`ltv`); let extended_class = `${parent} .xextended_summary`; let extended_scenario = `${parent} .xextended_summary_scenario`; let ext_elm = $(extended_class); let ext_scen = $(extended_scenario); $(`#rqh_scen_div_head`).html("").addClass(`x-hide`); $(`#rqh_value_div_head`).html("").addClass(`x-hide`); if (ext_elm.length > 0) { let Max = MAR.getOpt(da,`MAXIMUMS`,false); let Dti = MAR.getOpt(da,`MAXIMUMS.dti`,false); let h = ``; let sh = `${MAR.getOpt(off,"txt_scen_only","")}

`; let sl = `${MAR.getOpt(off,"txt_scen_cog","")}

`; // sl += `
Get Pricing`+ // `Manual Pricing
`; $(`#rqh_scen_div_head`).html(`${sh}`).removeClass(`x-hide`); $(`#rqh_value_div_head`).html(`${sl}`).removeClass(`x-hide`); h += `
  • The maximum loan based on the county loan limits and grid parameters is ${_maxln}, `+ `therefore the maximum purchase price would be ${elaineui.format("cur",Max.maxpp)}
  • `; if (typeof Dti === "object") { if (Dti.no_est === true) { h += `
  • ${Dti.txt}

  • `; } else { h += `
  • The maximum loan based on ${Dti.txt} is ${elaineui.format("cur",Dti.loanvalue)} `+ `therefore the maximum purchase price would be ${elaineui.format("cur",Dti.pp)}

  • `; } } let Ltv = MAR.getOpt(da,`MAXIMUMS.ltv`,false); if (typeof Ltv === "object") { h += `
  • The maximum loan based on ${Ltv.txt} is ${elaineui.format("cur",Ltv.loanvalue)} `+ `therefore the maximum purchase price would be ${elaineui.format("cur",Ltv.pp)}

  • `; } ext_elm.html(h); ext_elm.addClass(`x-hide`); // $(`${parent} .xc2c`).html(`C2CD${_c2c}`); // green_e(`c2c`); // if (c2c === false) white_e(`c2c`); // else if (c2c < num(mar.tmp_off.total_costs)) red_e(`c2c`); // $(`${parent} .xc2c_t`).html(`C2CA${_c2c}`); // if (ass_tot === 0) { // $(`${parent} .xc2c_t`).html(`C2CA:--.--`); // } green_e(`c2c_t`); if (ass_tot === false) white_e(`c2c_t`); if (ass_tot === 0) white_e(`c2c_t`); else if (ass_tot < num(mar.tmp_off.total_costs)) red_e(`c2c_t`); // if (c2c === false) white_e(`c2c_t`); // else if (c2c < num(mar.tmp_off.total_costs)) red_e(`c2c_t`); $(`${parent} .xlim`).html(`LIMIT
    ${_maxln}`); green(`lim`); if (_maxln === false || _maxln === 0 || ( typeof _maxln === `string` && _maxln.indexOf(`-`) > -1)) { white(`lim`); } else if (num(__maxln) < num(mar.tmp_off.loanvalue)) { red(`lim`); } green(`extended_summary`); if (c2c_exceded) { mar.tmp_rq_topgrid_warning(c2c_exceded,`red`); } } } mar.tmp_rq_topgrid_warning = function(txt,col = "") { if (txt === null) { $(`.topgrid-warnings`).html(""); $(`.topgrid-warnings`).css("border","none"); $(`#c2cwarn_div`).html(``); $(`#c2cwarn_div`).addClass(`x-hide-imp`); return; } if ($(`.topgrid-warnings .inner`).length === 0) { $(`.topgrid-warnings`).html(`
    C2C Warning
    `) $(`.topgrid-warnings`).css("border","1px solid red"); } if ($(`#c2cwarn_div .inner`).length === 0) { $(`#c2cwarn_div`).html(`
    C2C Warning
    `) $(`#c2cwarn_div`).css("border","1px solid red"); } $(`.topgrid-warnings .inner`).append(`
    ${txt}
    `); $(`#c2cwarn_div .inner`).append(`
    ${txt}
    `); $(`#c2cwarn_div`).removeClass(`x-hide-imp`); } mar.tmp_rq_topgrid_html = function(cls = "", extended = false){ let h = ``; h += `
    `; // h += `
    `; // h += `
    `; h += `
    `; h += `
    `; h += `
    `; // h += `
    `; h += `
    `; h += `
    `; h += ``; h += ``; h += ``; // h += ``; // h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; if (extended) { h += `
    `; h += `
    `; h += `
    `; h += `
    `; h += `
    `; h += `
    `; } return h; } mar.tmp_context_saver = (function(){ function is_radio($field) { return $field.prop('id').startsWith(`choice`); } function is_slider($field) { return $field.hasClass(`slider-input`) } function is_yn3($field) { return $field.parent().hasClass(`threestate`); } function load() { let fields = $(`.du-var`); for (let i=0; i < fields.length; i++) { let $field = $(fields[i]); let id = $field.prop("id"); if (is_radio($field)) { $field.data(`type`,`radio`); id = $field.prop("name"); $field.data(`id`,id); $field.data(`startval`,radio(id)); } else if (is_slider($field)) { $field.data(`type`,`slider`); $field.data(`id`,id); $field.data(`startval`,txt(`#${id}`)); } else if (is_yn3($field)) { $field.data(`type`,`yn3`); $field.data(`id`,id); $field.data(`startval`,yn3(`#${id}`)); } else { $field.data(`type`,`txt`); $field.data(`id`,id); $field.data(`startval`,txt(`#${id}`)); } } let c_fields = mvc.get("tmp_context_saver"); if (typeof c_fields === "string" && c_fields !== ``) { let fields = JSON.parse(c_fields); for (let x in fields) { let field = fields[x]; let id = field.id; let type = field.type; let val = field.val; if (type === `radio`) { let cval = radio(id); if (cval !== val) { radio(id, val); console.error(`LOADED field ${x} / ${id} / ${type} / ${val}`); continue; } } else if (type === `slider`) { let cval = txt(`#${id}`); if (cval !== val) { txt(`#${id}`, val); $(`#${id}`).change(); console.error(`LOADED field ${x} / ${id} / ${type} / ${val}`); continue; } } else if (type === `yn3`) { let cval = yn3(`#${id}`); if (cval !== val) { yn3(`#${id}`, val); $(`#${id}`).change(); console.error(`LOADED field ${x} / ${id} / ${type} / ${val}`); continue; } } else { let cval = txt(`#${id}`); if (cval !== val) { txt(`#${id}`, val); console.error(`LOADED field ${x} / ${id} / ${type} / ${val}`); continue; } } console.error(`LOAD-SKIP field ${x} / ${id} / ${type} / ${val}`); } } } function save() { let cfields = {} let fields = $(`.du-var`); for (let i=0; i < fields.length; i++) { let $field = $(fields[i]); let id = $field.data("id"); let type = $field.data("type"); let startval = $field.data("startval"); let val = ``; if (type === `radio`) { val = radio(id); } else if (type === `slider`) { val = txt(`#${id}`); } else if (type === `yn3`) { val = yn3(`#${id}`); } else { val = txt(`#${id}`); } if (val !== startval) { cfields[id] = { id : id, type : type, val : val }; console.error(`SAVE field ${i} / ${id} / ${type} / '${startval}' !== '${val}' `) } else { console.error(`SAVE-SKIP field ${i} / ${id} / ${type} / ${val}`) } } mvc.set("tmp_context_saver", JSON.stringify(cfields)); } function clear() { mvc.set("tmp_context_saver", ``); } return { load : load, save : save, clear : clear, __id : "contect saver for budget" } })(); mar.pg["scenario-housingbudget"] = (function(){ var html = ""; function render(pg, localopts) { /* * placeholder : (optional) default: '' -- standard placeholder param for an input field * mod_val : (very very optional) is a modifier for the displayed value. Handy if you want to multiply the value by an amount * v00 : beginning 'leftmost' value * v50, v75, v100 : middle value, value at 75%, value at 100% * v50_inc, v75_inc, v100_inc : incremental value from 0-50, 50-75, and 75-100 * start_val : force slider to start at a particular value. Overridden if there is value "pushed in" from DB * maxlength : (very optional) default: 12 -- standard max length param for an input field * cellType : (very optional) default: slider-money-cell -- there are different celltypes for displaying the numbers another type is slider-smallNum-cell (usually a max of 5 characters or less) */ /** * rules * * * If it is impossible to continue then still allow it but mark it as an impossible situation * If it is possible but could be better (adjusted rate) then warn and ask if you want to continue or not * If it is possible always continue * * * * scenario * (submitted) Y/N * * housingbudget * hb_beenherebefore Y/N * hb_appropriate Y/N * hb_warned Y/N * hb_impossible Y/N * hb_justfine Y/N * hb_lastadvice Y/N * * (at some point this will be over ridden by encompass values) * * ratequote * rq_beenherebefore Y/N * rq_frozen Y/N * rq_recalc Y/N * rq_ * * * */ //let has_visited = (getScenario_data("__hasvisited_housingbudget","N") == "Y") let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var sc = getScenario_data("applicant"+applicantNum+"_cscore",false); var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var loan_type = getScenario_data("loan_type","purchase"); var same = getScenario_data("applicant"+applicantNum+"_samelineofwork",""); var stable = getScenario_data("applicant"+applicantNum+"_stableincome",""); var enough = getScenario_data("applicant"+applicantNum+"_enoughincome",""); var goals_target_budget_old = getScenario_data("goals_target_budget_old","0"); var goals_target_budget_low = getScenario_data("goals_target_budget_low","0"); var goals_target_budget_high = getScenario_data("goals_target_budget_high","0"); var goals_target_budget_high_ref = getScenario_data("goals_target_budget_high_ref",""); var interestonly = getScenario_data("interestonly",""); var wehavebeenherebefore = getScenario_data("__scenario_housingbudget_0_passed","N"); var app_origin = getScenario_data("origin",""); /** * New estimates */ var flood_estimate = getScenario_data("flood_estimate",""); var hoa_estimate = getScenario_data("hoa_estimate",""); var scenario_i_know_my_tax = getScenario_data("scenario_i_know_my_tax",""); var scenario_tax = getScenario_data("scenario_tax",""); var scenario_i_know_my_insurance = getScenario_data("scenario_i_know_my_insurance",""); var refi_home_insurance_cost = getScenario_data("refi_home_insurance_cost",""); var refi_home_insurance_due = getScenario_data("refi_home_insurance_due",""); var scenario_i_know_my_hoa = getScenario_data("scenario_i_know_my_hoa",""); var hoa_estimate = getScenario_data("hoa_estimate",""); var ptype = getScenario_data("property_type",""); var county = getScenario_data("property_county",""); var county_code = (county.indexOf("|") > -1) ? county.split("|")[0] : county; var state_code = MAR.county_state(county); var purchase_target = getScenario_data("purchase_target",""); var hoi_estimate = getScenario_data("hoi_estimate",false); let f_ratequote = MAR.getOpt(mar.accesscontroller.features(), "ratequote", false); let SHOW_LOANS = (f_ratequote) ? "Show Loans" : "Continue"; let SHOW_LOANS_CONTINUE = "Continue"; /** * in case it has been filled in from a script */ // if (same !== "" || stable !== "" || enough !== "") { // wehavebeenherebefore = "Y"; // } mar.reset = function() { delScenario_data("goals_target_budget_old"); delScenario_data("goals_target_budget_high"); delScenario_data("goals_target_downpayment_perc"); delScenario_data("hb_liquid_assets"); delScenario_data("purchase_target"); delScenario_data("flood_estimate"); delScenario_data("scenario_i_know_my_tax"); delScenario_data("scenario_tax"); delScenario_data("scenario_i_know_my_insurance"); delScenario_data("refi_home_insurance_cost"); delScenario_data("scenario_i_know_my_hoa"); delScenario_data("hoa_estimate"); delScenario_data("interestonly"); delScenario_data("refi_current_value"); delScenario_data("refi_current_debt"); delScenario_data("refi_options"); delScenario_data("refi_goal"); delScenario_data("refi_liquid_assets"); delScenario_data("refi_taxes"); delScenario_data("refi_home_insurance_cost"); delScenario_data("refi_home_insurance_due"); delScenario_data("hoa_estimate"); delScenario_data("interestonly"); delScenario_data("refi_current_debt_rate"); delScenario_data("refi_current_debt_terms"); delScenario_data("refi_current_pmt_includes"); delScenario_data("refi_current_pmt_includes_ins"); delScenario_data("refi_current_escrow"); delScenario_data("refi_current_debt_mdate"); delScenario_data("refi_taxes_due"); delScenario_data("__scenario_housingbudget_0_passed"); mvc.go("#scenario-housingbudget."+applicantnum); } mar.test1 = function() { setScenario_data("applicant"+applicantNum+"_samelineofwork","Y"); setScenario_data("applicant"+applicantNum+"_stableincome","N"); delScenario_data("applicant"+applicantNum+"_enoughincome"); delScenario_data("__scenario_housingbudget_0_passed"); mvc.go("#scenario-housingbudget."+applicantnum); } mar.test2 = function(){ delScenario_data("applicant"+applicantNum+"_samelineofwork"); delScenario_data("applicant"+applicantNum+"_stableincome"); setScenario_data("applicant"+applicantNum+"_samelineofwork","Y"); setScenario_data("applicant"+applicantNum+"_stableincome","N"); delScenario_data("applicant"+applicantNum+"_enoughincome"); delScenario_data("__scenario_housingbudget_0_passed"); mvc.go("#scenario-housingbudget."+applicantnum); let nextfn = function(clickfn, validatefn, continuefn){ return function(V){ mar.wfv = V; (typeof clickfn === "string") ? eval(clickfn) : clickfn(V); waitfor(function(){ return validatefn(); }, true, 1500, 0, "", function(){ setTimeout(function(){ (typeof continuefn === "string") ? eval(continuefn) : continuefn(); },500); }); } } let next1 = nextfn(`$(".next-button").click();`, function(){return ($("#same-div").is(':visible'));}, `next_same("Y")`); let next_same = nextfn(`yn3("#samelineofwork",V);$("#samelineofwork").change();`, function(){return ($("#stable-div").is(':visible'));}, `next_stable("N")`) let next_stable = nextfn(`yn3("#stableincome",V);$("#stableincome").change();`, function(){ if (mar.wfv === "N") { if ($(".swal-button.swal-button--cancel").is(':visible')) { mar.wfv = "Y"; mar.wfvc = true; setTimeout(function(){ $(".swal-button.swal-button--cancel").click(); mar.wfvc = false; },1000); } return false; } else { return (!mar.wfvc && $("#enough-div").is(':visible')); } }, `next_enough("Y")`) let next_enough = nextfn(`yn3("#enoughincome",V);$("#enoughincome").change();`, function(){return ($("#budgetslider").is(':visible'));}, `alert("end test")`); // goals_target_budget_high setTimeout(function(){ waitfor(function(){ return ($(".er").length > 0); }, true, 500, 0, "test2", function(){ next1(); }); },1500) } mar.pg_changelistner = function() { var xsame = getScenario_data("applicant"+applicantNum+"_samelineofwork",""); var xstable = getScenario_data("applicant"+applicantNum+"_stableincome",""); var xenough = getScenario_data("applicant"+applicantNum+"_enoughincome",""); if (xsame != "") { yn3("#samelineofwork",xsame) && $("#samelineofwork").change(); } if (xstable != "") { yn3("#stableincome",xstable) && $("#stableincome").change(); } if (xenough != "") { yn3("#enoughincome",xenough) && $("#enoughincome").change(); } oc(); } let VAL = "750"; let h = ""; h += frm.htitle("Your Mortgage").render(); // h += `rst`; if (applicantnum == 0) { if (loan_type !== "purchase") { let eainetext = `please find your last mortgage statement to answer the next set of questions. With accurate answers we will be able to calculate if a refinance makes sense, and how much you will gain by doing this.`; h += frm.elaine(`${na}, ${eainetext}`,"er").render(); } else { // h += frm.elaine(na+", we need to assess if you're qualified for a loan, and how much you think you can spend on your home responsibly.","er").render(); h += frm.elaine(na+", let's dive a bit deeper into your purchase plans.","er").render(); } } else { h += frm.elaine("We need to assess if "+na+"'s qualified for a loan, and how much you think they can spend on the home responsibly.","er").render(); } if (sc) VAL = sc; //trafficlight h += "
    "; if (wehavebeenherebefore == "Y") { h += "
    "; } else { h += "
    "; } // h += "
    Please answer
    "; h += (function samefn(){ let h = ""; h += ``; setScenario_data("applicant"+applicantNum+"_samelineofwork","Y"); return h; h += "
    "; VAL = same; var incSt = ''; if (applicantnum == 0) { incSt = "I have worked in the same line of business for at least two years. "; } else { incSt = na+" has worked in the same line of business for at least two years. "; } if (VAL == "") { if (getIncome_v2().years_hist[applicantnum] > 0) VAL = "Y" } h += frm.yn3("samelineofwork",incSt,VAL,"","",function(){ oc(); //if(txt("#samelineofwork") == 'Y' || txt("#samelineofwork") == 'N'){ if(txt("#samelineofwork") == 'N'){ $(".info-same").trigger('click'); } }, {}).render(); h += "
    "; return h; })(); h += (function stablefn(){ let h = ""; h += "
    "; h += ``; setScenario_data("applicant"+applicantNum+"_stableincome","Y"); h += "
    "; return h; // h += "
    "; h += "
    "; // h += frm.hr().render(); VAL = stable; if (applicantnum == 0) { incSt = "My income is stable. It has not decreased. "; if (getScenario_data("occupancy_type","") === mar.OCCUPANCY_INVESTMENT) { incSt = "Use my income to qualify (so I may get better terms)"; } } else { incSt = na+"'s income is stable. It has not decreased. "; } if (VAL == "") { // if (getIncome_v2().years_hist[applicantnum] > 0) VAL = "Y" } h += frm.yn3("stableincome",incSt,VAL,"","",function(){ oc(); if(txt("#stableincome") == 'N'){ $(".info-stable").trigger('click'); } }, {}).render(); h += "
    "; return h; })(); if (applicantnum == 0 && loan_type !== "purchase") { h += ``; var _hide = (refi_options === "cashout") ? "" : "x-hide"; var _hide2 = (wehavebeenherebefore == "Y") ? "" : "x-hide"; var refi_current_value = getScenario_data("refi_current_value","0"); if (refi_current_value === "0") { refi_current_value = MAR.getOpt(MAR.reo.getOrCreateSubjectProperty(), "data.value", "0"); } // if sp h += (function() { let h = ""; h += "
    "; h += "
    How much do you think the property you want to refinance will appraise for?
    "; VAL = refi_current_value; h += frm.slider("refi_current_value","Within $1000 of:",VAL,"","",function(){ oc_context(); }, { v00 : '0 ', v50 : '350000', v50_inc : '500', v75 : '500000', v75_inc : '1000', v100 : '2000000', v100_inc : '5000', start_val : '70000' }).render(); h += "
    "; return h; // })().wrap(`
    `,"
    "); })().wrap(`
    `,"
    "); var refi_current_debt = getScenario_data("refi_current_debt","0"); h += (function() { let h = ""; h += "
    "; h += "
    How much do you need to pay off in debt on the property?
    "; VAL = refi_current_debt; h += frm.slider("refi_current_debt","Be as exact as possible",VAL,"","",function(){ oc(); }, { v00 : '0 ', v50 : '350000', v50_inc : '500', v75 : '500000', v75_inc : '1000', v100 : '2000000', v100_inc : '5000', start_val : '70000' }).render(); h += "
    "; return h; })().wrap("
    ","
    "); /// var refi_options = getScenario_data("refi_options",""); h += (function() { let h = ""; // let bubble2_text = `Your refinance will cost money, but you will have savings too. Most likely you will not have to make the next two mortgage payments, and you will receive a refund of your escrow balance after closing. We estimate that saves you `; let bubble2_text = `Your refinance will cost money, but you will have savings too. Most likely you will not have to make the next two mortgage payments, and you will receive a refund of your escrow balance after closing.`; h += frm.elaine(`${bubble2_text}`,"er2").render(); h += "
    "; h += "
    What type of refinance do you want?
    "; VAL = refi_options; // if (VAL === "noclosing") { // VAL = "closing"; // } //I want to raise my loan balance, so that I cash out up to $ 2,000 at the closing table, and I will recieve back my estimated $ 12,800. /** * closing limit_cash_out_refi * noclosing rat_refi * cashout cash_out_refi */ h += frm.radio("refi_options","",VAL,"","",function(){ // let val = radio("refi_options"); // if (val === "cashout") { // $("#refi_goal_div").removeClass("x-hide"); // } else { // $("#refi_goal_div").addClass("x-hide"); // } oc(); },{ // noclosing : "No Cash Out - I want to keep my mortgage balance the same, or close to the same but I will receive back my estimated ", // closing : "Limited Cash Out - I want to raise my loan balance, so that I cash out up to $ 2,000 at the closing table, and I will recieve back my estimated ", noclosing : "No Cash Out - I want to keep my mortgage balance the same, or close to the same but I will receive back my escrow", closing : "Limited Cash Out - I want to raise my loan balance, so that I cash out up to $ 2,000 at the closing table, and I will recieve back my escrow", cashout : "Cash out - I want to cash out ", }).render(); //Increase your mortgage to a maximum cash out of roughly {max loan -/- current loan balance -/- 1% -/- 2000} - The additional cost to close is estimated at {percentage} points h += "
    "; return h; })().wrap("
    ","
    "); var refi_goal = getScenario_data("refi_goal","0"); h += (function() { let h = ""; h += "
    "; h += "
    How much money do you want to increase your loan balance with?
    "; VAL = refi_goal; h += frm.slider("refi_goal","Within $1000 of:",VAL,"","",function(){ // ocbudget(); oc(); // setScenario_data("goals_target_budget_low",goals_target_budget_low); // oc("low"); }, { v00 : '0 ', v50 : '25000', v50_inc : '250', v75 : '80000', v75_inc : '500', v100 : '150000', v100_inc : '2500', start_val : '70000' }).render().wrap(`
    `,"
    "); h += "
    "; return h; })().wrap(`
    `,"
    "); var refi_liquid_assets = getScenario_data("refi_liquid_assets","0"); h += (function() { let h = ""; h += "
    "; h += "
    How much money can you spend to close on this refi?
    "; VAL = refi_liquid_assets; h += frm.slider("refi_liquid_assets","Within $1000 of:",VAL,"","",function(){ oc(); }, { v00 : '0 ', v50 : '35000', v50_inc : '50', v75 : '50000', v75_inc : '100', v100 : '200000', v100_inc : '500', start_val : '5000' }).render(); h += "
    "; h += `
    ` return h; })().wrap("
    ","
    "); // var refi_goal = getScenario_data("refi_goal","0"); // h += (function() { // let h = ""; // h += "
    "; // h += "
    How much money do you want to increase your loan balance with?
    "; // // // VAL = refi_goal; // h += frm.slider("refi_goal","Within $1000 of:",VAL,"","",function(){ //// ocbudget(); // oc(); // //// setScenario_data("goals_target_budget_low",goals_target_budget_low); //// oc("low"); // }, { // v00 : '0 ', // v50 : '25000', // v50_inc : '250', // v75 : '80000', // v75_inc : '500', // v100 : '150000', // v100_inc : '2500', // start_val : '70000' // }).render().wrap(`
    `,"
    "); // // h += "
    "; // return h; // })().wrap(`
    `,"
    "); var refi_current_debt_rate = getScenario_data("refi_current_debt_rate",""); h += (function() { let h = ""; h += "
    "; h += "
    What is your current interest percentage rate?
    "; VAL = refi_current_debt_rate; h += frm.slider("refi_current_debt_rate","",VAL,"","",function(){ oc(); }, { v00 : '0 ', v50 : '6', v50_inc : '0.125', v75 : '9', v75_inc : '0.125', v100 : '12', v100_inc : '0.125', start_val : '0', formatting_class : '_percentage3' },"perc").render(); h += "
    "; return h; })().wrap("
    ","
    "); var refi_current_debt_terms = getScenario_data("refi_current_debt_terms","y30"); h += (function() { let h = ""; h += "
    "; h += "
    What is the term of of your current mortgage?
    "; VAL = refi_current_debt_terms; h += frm.radio("refi_current_debt_terms","",VAL,"","",function(){ oc(); },{ y10 : "10 years", y15 : "15 years", y20 : "20 years", y30 : "30 years", y30io : "30 years / 10 years interest only", y40 : "40 years", y40io : "40 years / 10 years interest only" }).render(); h += "
    "; return h; })().wrap("
    ","
    "); h += (function() { let h = ""; h += "
    "; h += "
    What is your total monthly mortgage payment?
    "; VAL = goals_target_budget_old; h += frm.slider("goals_target_budget_old","",VAL,"","",function(){ ocbudget(); oc_context(); // setScenario_data("goals_target_budget_low",goals_target_budget_low); // oc("low"); }, { v00 : '0 ', v50 : '2500', v50_inc : '25', v75 : '8000', v75_inc : '50', v100 : '15000', v100_inc : '250', start_val : '1800', trackStyling : 'trafficlight' }).render(); h += "
    "; h += "
    "; return h; })().wrap(`
    `,"
    "); var refi_current_pmt_includes = getScenario_data("refi_current_pmt_includes","Y"); h += (function() { let h = ""; VAL = refi_current_pmt_includes; h += frm.yn3("refi_current_pmt_includes","Total payment includes property tax escrows?",VAL,"","",function(){ oc(); }, {}).render(); return h; })().wrap(`
    `,"
    "); var refi_current_pmt_includes_ins = getScenario_data("refi_current_pmt_includes_ins","Y"); h += (function() { let h = ""; VAL = refi_current_pmt_includes_ins; h += frm.yn3("refi_current_pmt_includes_ins","Total payment includes insurance escrows?",VAL,"","",function(){ oc(); }, {}).render(); return h; })().wrap(`
    `,"
    "); // var refi_current_debt_date = getScenario_data("refi_current_debt_date",""); // h += (function() { // let h = ""; // h += "
    "; // h += "
    Date of balance?
    "; // // // VAL = refi_current_debt_date; // h += frm.txt("refi_current_debt_date","",VAL,"","",function(){ // oc(); // },'date').render(); // // h += "
    "; // return h; // })().wrap("
    ","
    "); var refi_current_escrow = getScenario_data("refi_current_escrow","0"); h += (function() { let h = ""; h += "
    "; h += "
    How much have you saved in your escrow account?
    "; VAL = refi_current_escrow; h += frm.slider("refi_current_escrow","",VAL,"","",function(){ oc(); }, { v00 : '0 ', v50 : '6000', v50_inc : '50', v75 : '12000', v75_inc : '100', v100 : '22000', v100_inc : '200', start_val : '7000' }).render(); h += "
    "; return h; })().wrap("
    ","
    "); var refi_current_debt_mdate = getScenario_data("refi_current_debt_mdate",""); h += (function() { let h = ""; h += "
    "; h += "
    When did you close on your current mortgage?
    "; VAL = refi_current_debt_mdate; h += frm.txt("refi_current_debt_mdate","",VAL,"","",function(){ oc_context(); // oc(); },'date').render(); h += "
    "; return h; })().wrap("
    ","
    "); /// var refi_taxes = getScenario_data("refi_taxes","0"); h += (function() { let h = ""; h += "
    "; h += "
    What is your annual tax bill?
    "; VAL = refi_taxes; h += frm.slider("refi_taxes","Within $100 of:",VAL,"","",function(){ oc_context(); }, { v00 : '0 ', v50 : '2500', v50_inc : '25', v75 : '8000', v75_inc : '50', v100 : '15000', v100_inc : '250', start_val : '1800', trackStyling : 'trafficlight' }).render(); h += "
    "; return h; })().wrap("
    ","
    "); var refi_taxes_due = getScenario_data("refi_taxes_due",""); h += (function() { let h = ""; h += "
    "; h += "
    What is the next date your tax is due?
    "; VAL = refi_taxes_due; h += frm.txt("refi_taxes_due","",VAL,"","",function(){ oc_context(); },'date').render(); h += "
    "; return h; })().wrap(`
    `,"
    "); h += (function() { let h = ""; h += "
    "; h += "
    Annual insurance on the property?
    "; VAL = refi_home_insurance_cost; h += frm.slider("refi_home_insurance_cost","Within $1000 of:",VAL,"","",function(){ oc_context(); }, { v00 : '0 ', v50 : '2500', v50_inc : '25', v75 : '8000', v75_inc : '50', v100 : '15000', v100_inc : '250', start_val : '1800', trackStyling : 'trafficlight' }).render(); h += "
    "; return h; })().wrap(`
    `,"
    "); h += (function() { let h = ""; h += "
    "; h += "
    What is the next date your home owners insurance premium becomes due?
    "; VAL = refi_home_insurance_due; h += frm.txt("refi_home_insurance_due","",VAL,"","",function(){ oc_context(); },'date').render(); h += "
    "; return h; })().wrap(`
    `,"
    "); h += (function() { let h = ""; h += "
    "; h += "
    Monthly HOA on the property?
    "; VAL = hoa_estimate; h += frm.slider("hoa_estimate","Within $10 of:",VAL,"","",function(){ oc_context(); }, { v00 : '0 ', v50 : '250', v50_inc : '10', v75 : '800', v75_inc : '10', v100 : '1500', v100_inc : '20', start_val : '50', trackStyling : 'trafficlight' }).render(); h += "
    "; return h; })().wrap(`
    `,"
    "); /// // var refi_options = getScenario_data("refi_options",""); // h += (function() { // let h = ""; // // let bubble2_text = `Your refinance will cost money, but you will have savings too. Most likely you will not have to make the next two mortgage payments, and you will receive a refund of your escrow balance after closing. We estimate that saves you `; // h += frm.elaine(`${bubble2_text}`,"er2").render(); // // h += "
    "; // h += "
    What type of refinance do you want?
    "; // // VAL = refi_options; // // /** // * closing limit_cash_out_refi // * noclosing rat_refi // * cashout cash_out_refi // */ // h += frm.radio("refi_options","",VAL,"","",function(){ // oc(); // },{ // noclosing : "No Cash Out - I want to keep my mortgage balance the same, or close to the same but I will receive back my estimated ", // closing : "Limited Cash Out - I want to raise my loan balance, so that I cash out up to $ 2,000 at the closing table, and I will recieve back my estimated ", // cashout : "Cash out - I want to cash out ", // }).render(); // // // //Increase your mortgage to a maximum cash out of roughly {max loan -/- current loan balance -/- 1% -/- 2000} - The additional cost to close is estimated at {percentage} points // // h += "
    "; // return h; // // })().wrap("
    ","
    "); // var refi_goal = getScenario_data("refi_goal","0"); // h += (function() { // let h = ""; // h += "
    "; // h += "
    How much money do you want to increase your loan balance with?
    "; // // // VAL = refi_goal; // h += frm.slider("refi_goal","Within $1000 of:",VAL,"","",function(){ //// ocbudget(); // oc(); // //// setScenario_data("goals_target_budget_low",goals_target_budget_low); //// oc("low"); // }, { // v00 : '0 ', // v50 : '25000', // v50_inc : '250', // v75 : '80000', // v75_inc : '500', // v100 : '150000', // v100_inc : '2500', // start_val : '70000' // }).render().wrap(`
    `,"
    "); // // h += "
    "; // return h; // })().wrap(`
    `,"
    "); // // var refi_liquid_assets = getScenario_data("refi_liquid_assets","0"); // h += (function() { // let h = ""; // h += "
    "; // h += "
    How much money can you spend to close on this refi?
    "; // // // VAL = refi_liquid_assets; // h += frm.slider("refi_liquid_assets","Within $1000 of:",VAL,"","",function(){ // oc(); // }, { // v00 : '0 ', // v50 : '35000', // v50_inc : '50', // v75 : '50000', // v75_inc : '100', // v100 : '200000', // v100_inc : '500', // start_val : '5000' // }).render(); // // h += "
    "; // h += `
    ` // return h; // })().wrap("
    ","
    "); h += (function() { let h = ""; h += `
    `; return h; })().wrap("
    ","
    "); // var refi_liquid_assets = getScenario_data("refi_liquid_assets","0"); // h += (function() { // let h = ""; // h += ``; // return h; // })(); // h += (function() { // let h = ""; // h += "
    "; //// h += "
    Total available liquid assets including gifts?
    "; // h += "
    How much money do you have available including gifts?
    "; // // // // VAL = refi_liquid_assets; // h += frm.slider("refi_liquid_assets","Within $1000 of:",VAL,"","",function(){ // }, { // v00 : '0 ', // v50 : '35000', // v50_inc : '50', // v75 : '50000', // v75_inc : '100', // v100 : '200000', // v100_inc : '500', // start_val : '5000' // }).render(); // // h += "
    "; // return h; // })().wrap("
    ","
    "); h += ``; // if (getScenario_data("occupancy_type","") !== "occupancy_investment") { // h += ``; // } else { // h += (function() { // let h = ""; // VAL = interestonly; // h += frm.yn3("interestonly","Do you want to use the interest only programme?",VAL,"","",function(){ // oc(); // }, {}).render(); // h += "
    "; // return h; // })().wrap(`
    `,"
    "); // } h += "
    "; } else if (applicantnum == 0) { var _hide2 = (wehavebeenherebefore == "Y") ? "" : "x-hide"; var purchase_target = getScenario_data("purchase_target","0"); h += (function() { let h = ""; h += "
    "; if (getScenario_data("loan_type_purchase_options", "") === "contract") { h += "
    What is your contract purchase price?
    "; } else { h += "
    What is your desired purchase price?
    "; } VAL = purchase_target; let ORIGINAL_VAL = VAL; h += frm.slider("purchase_target","Within $1000 of:",VAL,"","",function(){ let new_val = txt("#purchase_target"); if (new_val !== ORIGINAL_VAL && oc_paused !== true) { fetchDefaults(new_val, function() { ORIGINAL_VAL = new_val; oc(); }); } else { oc(); } }, { v00 : '0 ', v50 : '350000', v50_inc : '500', v75 : '500000', v75_inc : '1000', v100 : '2000000', v100_inc : '5000', start_val : '70000' }).render(); h += "
    "; h += `
    ` return h; })().wrap("
    ","
    "); // var goals_target_downpayment_perc = getScenario_data("goals_target_downpayment_perc","5"); // h += (function() { // let h = ""; // h += "
    "; // h += "
    How much do you want to put down?
    "; // // VAL = goals_target_downpayment_perc; // h += frm.slider("goals_target_downpayment_perc","",VAL,"","",function(){ // // let dpp = num(txt("#goals_target_downpayment_perc")); // let pp = num(txt("#purchase_target")); // let la = num(txt("#hb_liquid_assets")); // let liq_ass_req = ~~((dpp * (pp/100))*1.01); // // if (la < liq_ass_req) { // txt("#hb_liquid_assets", liq_ass_req); // $("#hb_liquid_assets").change(); // } // // oc(); // }, { // v00 : '0 ', // v50 : '10', // v50_inc : '0.5', // v75 : '25', // v75_inc : '1', // v100 : '100', // v100_inc : '5', // start_val : '3', // formatting_class : '_percentage' // },"perc").render(); // // h += "
    "; // h += `
    ` // return h; // // })().wrap("
    ","
    "); /** * New questions */ h += (function() { let h = ""; h += "
    "; h += "
    Estimated yearly taxes on property?
    "; VAL = scenario_tax; h += frm.slider("scenario_tax","",VAL,"","",function(){ oc(); }, { v00 : '0 ', v50 : '2500', v50_inc : '25', v75 : '8000', v75_inc : '50', v100 : '15000', v100_inc : '250', start_val : '1800', trackStyling : 'trafficlight' }).render(); h += "
    "; return h; })().wrap(`
    `,"
    "); h += (function() { let h = ""; h += "
    "; h += "
    Expected insurance cost per year?
    "; VAL = refi_home_insurance_cost; h += frm.slider("refi_home_insurance_cost","Annually",VAL,"","",function(){ oc(); }, { v00 : '0 ', v50 : '2500', v50_inc : '25', v75 : '8000', v75_inc : '50', v100 : '15000', v100_inc : '250', start_val : '1800', trackStyling : 'trafficlight' }).render(); h += "
    "; return h; })().wrap(`
    `,"
    "); h += (function() { let h = ""; h += "
    "; h += "
    Expected Home Owners Association fees per month.
    "; VAL = hoa_estimate; h += frm.slider("hoa_estimate","Montly",VAL,"","",function(){ oc(); }, { v00 : '0 ', v50 : '250', v50_inc : '10', v75 : '800', v75_inc : '10', v100 : '1500', v100_inc : '20', start_val : '50', trackStyling : 'trafficlight' }).render(); h += "
    "; return h; })().wrap(`
    `,"
    "); var hb_liquid_assets = getScenario_data("hb_liquid_assets","0"); h += (function() { let h = ""; h += "
    "; h += "
    How much money can you spend to close on this purchase including downpayment and closing costs?
    "; VAL = hb_liquid_assets; h += frm.slider("hb_liquid_assets","",VAL,"","",function(){ oc(); }, { v00 : '0 ', v50 : '35000', v50_inc : '50', v75 : '50000', v75_inc : '100', v100 : '200000', v100_inc : '500', start_val : '5000' }).render(); h += "
    "; h += `
    ` h += `
    ` return h; })().wrap("
    ","
    "); if (getScenario_data("occupancy_type","") !== "occupancy_investment") { h += ``; } else { h += ``; // h += (function() { // let h = ""; // VAL = interestonly; // h += frm.yn3("interestonly","Do you want to use the interest only programme?",VAL,"","",function(){ // oc(); // }, {}).render(); // h += "
    "; // return h; // })().wrap(`
    `,"
    "); } } h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; let buttonText = (applicantnum == 0 && wehavebeenherebefore !== "Y") ? "I got it" : SHOW_LOANS; let revealfields_purchase = async function(skip_visual_warnings = false) { if( txt("#enoughincome") == ''){ return; } if ($("#stable-div").is(':visible') == false) { return } $(".dr-button.next-button").html(SHOW_LOANS_CONTINUE); if ($("#purchase_target_div").is(':visible') == false) { $("#purchase_target_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#purchase_target_div").removeClass("x-hide"); $("#purchase_target").data("changed","N"); oc_paused = true; $("#purchase_target").change(); oc_paused = false; }) return; } if ($("#purchase_target").data("changed") === "N") { $("#purchase_target").data("changed",""); // return; } if (num(txt("#purchase_target")) === 0) { if (!skip_visual_warnings) mar.tip(".help-button","warning","The current value is not filled in","top"); return; } // if ($("#goals_target_downpayment_perc_div").is(':visible') == false) { // $("#goals_target_downpayment_perc_div").slideDown(function(){ // $("#body-container").scrollTo("max",200); // $("#goals_target_downpayment_perc_div").removeClass("x-hide"); // $("#goals_target_downpayment_perc").data("changed","N"); // $("#goals_target_downpayment_perc").change(); // }) // return; // } // (function(){ // // let purchase_target = num(txt("#purchase_target")); // let goals_target_downpayment_perc = num(txt("#goals_target_downpayment_perc")); // if (purchase_target > 0) { // let actualval = Math.round((purchase_target) * (goals_target_downpayment_perc/100)); // $(".goals_target_downpayment_perc_calc").html(`${elaineui.format("cur",actualval)}`) // } // })(); // if ($("#goals_target_downpayment_perc").data("changed") === "N") { // $("#goals_target_downpayment_perc").data("changed",""); // return; // } if ($("#scenario_tax_div").is(':visible') == false) { $("#scenario_tax_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#scenario_tax_div").removeClass("x-hide"); oc_paused = true; if (txt("#scenario_tax") === "") txt("#scenario_tax",0); $("#scenario_tax").change(); oc_paused = false; }) return; } if ($("#refi_home_insurance_cost_div").is(':visible') == false) { $("#refi_home_insurance_cost_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_home_insurance_cost_div").removeClass("x-hide"); oc_paused = true; if (txt("#refi_home_insurance_cost") === "") txt("#refi_home_insurance_cost",0); $("#refi_home_insurance_cost").change(); oc_paused = false; }) return; } if ($("#hoa_estimate_div").is(':visible') == false) { $("#hoa_estimate_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#hoa_estimate_div").removeClass("x-hide"); oc_paused = true; if (txt("#hoa_estimate") === "") txt("#hoa_estimate",0); $("#hoa_estimate").change(); oc_paused = false; }) return; } /** * here we will make the text show mortgages */ $(".dr-button.next-button").html(SHOW_LOANS); if ($("#hb_liquid_assets_div").is(':visible') == false) { $("#hb_liquid_assets_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#hb_liquid_assets_div").removeClass("x-hide"); oc_paused = true; $("#hb_liquid_assets").change(); oc_paused = false; }); return; } if (num(txt("#hb_liquid_assets")) === 0) { mar.tip(".help-button","warning","The assets estimate is not filled in","top"); return; } if ($("#interestonly_div").length > 0) { if ($("#interestonly_div").is(':visible') == false) { $("#interestonly_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#interestonly_div").removeClass("x-hide"); oc_paused = true; $("#interestonly").change(); oc_paused = false; }); return; } if (yn3("#interestonly") === "") { mar.tip(".help-button","warning","You need to let us know if you want to try the interst only option","top"); return; } } return true; } let revealfields_refi = async function(skip_visual_warnings = false) { if( txt("#enoughincome") == ''){ if (num(txt("#refi_current_value")) === 0) { if (!skip_visual_warnings) mar.tip(".help-button","warning","You need to tell us if you have a budget in mind","top"); return; } } if ($("#refi_current_value_div").is(':visible') == true) { $(".dr-button.next-button").html(SHOW_LOANS_CONTINUE); } if ($("#refi_current_value_div").is(':visible') == false) { $("#refi_current_value_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_current_value_div").removeClass("x-hide"); oc_paused = true; $("#refi_current_value").change(); oc_paused = false; }) return; } if (num(txt("#refi_current_value")) === 0) { if (!skip_visual_warnings) mar.tip(".help-button","warning","The current value is not filled in","top"); return; } if ($("#refi_current_debt_div").is(':visible') == false) { $("#refi_current_debt_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_current_debt_div").removeClass("x-hide"); oc_paused = true; $("#refi_current_debt").change(); oc_paused = false; }); return; } if (txt("#refi_current_debt") === "") { if (!skip_visual_warnings) mar.tip(".help-button","warning","The current debt is not filled in","top"); return; } // if ($("#refi_current_debt_date_div").is(':visible') == false) { // $("#refi_current_debt_date_div").slideDown(function(){ // $("#body-container").scrollTo("max",200); // $("#refi_current_debt_date_div").removeClass("x-hide"); // $("#refi_current_debt_date").change(); // oc_paused = false; // }); // return; // } // if (num(txt("#refi_current_debt")) > 0) { // if (txt("#refi_current_debt_date") === "") { // mar.tip(".help-button","warning","You need to tell us the date","top"); // return; // } // } let __refi_current_debt = num(txt("#refi_current_debt")); let refi_current_value = num(txt("#refi_current_value")); let refi_current_debt = num(txt("#refi_current_debt")); let can_cashout = (refi_current_debt === 0 || (refi_current_debt / refi_current_value) < 0.8); if (__refi_current_debt === false) { oc_paused = true; $("#refi_current_debt_rate_div").addClass("x-hide"); txt("#refi_current_debt_rate","0"); $("#refi_current_debt_terms_div").addClass("x-hide"); radio("refi_current_debt_terms","") $("#goals_target_budget_old_div").addClass("x-hide"); txt("#goals_target_budget_old","0"); $("#refi_current_pmt_includes_div").addClass("x-hide"); txt("#refi_current_pmt_includes","Y"); $("#refi_current_pmt_includes_ins_div").addClass("x-hide"); txt("#refi_current_pmt_includes_ins","Y"); $("#refi_current_escrow_div").addClass("x-hide"); txt("#refi_current_escrow","0"); $("#refi_current_debt_mdate_div").addClass("x-hide"); txt("#refi_current_debt_mdate",""); oc_paused = false; } else { if (__refi_current_debt === 0) { /** * hide rate& term and limited cachout any refi options */ $($("#refi_options_div .radiogroup .md-radio")[0]).addClass("x-hide"); $($("#refi_options_div .radiogroup .md-radio")[1]).addClass("x-hide"); if (radio("refi_options") !== "cashout") { radio("refi_options","cashout"); } $("#refi_goal_div .question").html($("#refi_goal_div .question").data("alt1")); } else { /** * Un hide any refi options */ $("#refi_options_div .radiogroup .md-radio").removeClass("x-hide"); $("#refi_goal_div .question").html($("#refi_goal_div .question").data("alt0")); } can_cashout = true; (function ensure_refi_goal_matches_value(){ let _val = num(txt("#refi_current_value")); let _debt = num(txt("#refi_current_debt")); let _key = `${_val}_${_debt}`; let $div = $("#refi_goal_div"); let key = $div.data("key"); let val = txt("#refi_goal") if (key !== _key) { /** * replace slider */ let ptype = getScenario_data("property_type",""); let otype = getScenario_data("occupancy_type",""); let limit = 0.75; if (ptype === "sfr" && otype === mar.OCCUPANCY_PRIMARY) { limit = 0.80; } let max = (((_val * limit) - _debt) - 2500 - (_debt * 0.01)); $(`.cashout_text`).html(`up to an estimated ${elaineui.format("cur", ~~(max))} maximum`) // debugger; let h = ""; VAL = val; h += frm.slider("refi_goal","Within $1000 of:",VAL,"","",function(){ oc(); }, { v00 : '0', v50 : ~~(max/4), v50_inc : '250', v75 : ~~(max/2), v75_inc : '500', v100 : ~~(max), v100_inc : '2500', start_val : '70000' }).render(); // debugger; $("#refi_goal_div_slider").html(""); setTimeout(function(){ $("#refi_goal_div_slider").html(h); $("#refi_goal_div_slider .xx-slider").myslider(); $("#refi_goal_div_slider ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); },1); $div.data("key",_key); } })(); if (can_cashout) { if ($("#refi_options_div").is(':visible') == false) { $("#refi_options_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_options_div").removeClass("x-hide"); }); return; } if (radio("refi_options") === "") { mar.tip(".help-button","warning","The option is not filled in","top"); return; } } else { $("#refi_options_div").addClass("x-hide"); $("#refi_options_div").css("display","none"); radio("refi_options", "closing"); } if (radio("refi_options") === "cashout") { /* cash out */ // oc_paused = true; // $("#refi_current_debt_rate_div").addClass("x-hide"); // txt("#refi_current_debt_rate","0"); // // $("#refi_current_debt_terms_div").addClass("x-hide"); // radio("refi_current_debt_terms","") // // $("#goals_target_budget_old_div").addClass("x-hide"); // txt("#goals_target_budget_old","0"); // // $("#refi_current_pmt_includes_div").addClass("x-hide"); // txt("#refi_current_pmt_includes","Y"); // // $("#refi_current_pmt_includes_ins_div").addClass("x-hide"); // txt("#refi_current_pmt_includes_ins","Y"); // // $("#refi_current_escrow_div").addClass("x-hide"); // txt("#refi_current_escrow","0"); // // $("#refi_current_debt_mdate_div").addClass("x-hide"); // txt("#refi_current_debt_mdate",""); oc_paused = false; $("#refi_liquid_assets_div").css("display","none"); $("#refi_liquid_assets_div").addClass("x-hide"); if ($("#refi_goal_div").is(':visible') == false) { $("#refi_goal_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_goal_div").removeClass("x-hide"); oc_paused = true; $("#refi_goal").change(); oc_paused = false; }); return; } if (num(txt("#refi_goal")) === 0) { mar.tip(".help-button","warning","The goal is not filled in","top"); return; } } else if (radio("refi_options") === "closing") { /* limited cash out */ // oc_paused = true; // $("#refi_current_debt_rate_div").addClass("x-hide"); // txt("#refi_current_debt_rate","0"); // // $("#refi_current_debt_terms_div").addClass("x-hide"); // radio("refi_current_debt_terms","") // // $("#goals_target_budget_old_div").addClass("x-hide"); // txt("#goals_target_budget_old","0"); // // $("#refi_current_pmt_includes_div").addClass("x-hide"); // txt("#refi_current_pmt_includes","Y"); // // $("#refi_current_pmt_includes_ins_div").addClass("x-hide"); // txt("#refi_current_pmt_includes_ins","Y"); // // $("#refi_current_escrow_div").addClass("x-hide"); // txt("#refi_current_escrow","0"); // // $("#refi_current_debt_mdate_div").addClass("x-hide"); // txt("#refi_current_debt_mdate",""); // oc_paused = false; txt("#refi_goal","1000") $("#refi_goal_div").css("display","none"); $("#refi_goal_div").addClass("x-hide"); $("#refi_liquid_assets_div").css("display","none"); $("#refi_liquid_assets_div").addClass("x-hide"); } else { /* rate & term i.e. noclosing */ $("#refi_goal_div").css("display","none"); $("#refi_goal_div").addClass("x-hide"); // $("#refi_liquid_assets_div").css("display","block"); // $("#refi_liquid_assets_div").removeClass("x-hide"); // oc_paused = true; // $("#refi_liquid_assets").change(); // oc_paused = false; } // if (radio("refi_options") !== "cashout") { /* rate & term */ if (radio("refi_options") !== "nothing") { /* rate & term */ if (radio("refi_options") === "nocashout") { /* rate & term */ if ($("#refi_liquid_assets_div").is(':visible') == false) { $("#refi_liquid_assets_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_liquid_assets_div").removeClass("x-hide"); oc_paused = true; $("#refi_liquid_assets").change(); oc_paused = false; }); return; } if (txt("#refi_liquid_assets") === "" || num(txt("#refi_liquid_assets")) === 0) { mar.tip(".help-button","warning","You need to tell us how much you are willing to spend on this refi","top"); return; } } if ($("#refi_current_debt_rate_div").is(':visible') == false) { $("#refi_current_debt_rate_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_current_debt_rate_div").removeClass("x-hide"); oc_paused = true; $("#refi_current_debt_rate").change(); oc_paused = false; }); return; } if (txt("#refi_current_debt_rate") === "") { mar.tip(".help-button","warning","You need to tell us the rate of your mortgage","top"); return; } if ($("#refi_current_debt_terms_div").is(':visible') == false) { $("#refi_current_debt_terms_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_current_debt_terms_div").removeClass("x-hide"); oc_paused = false; }); return; } if (radio("refi_current_debt_terms") === "") { mar.tip(".help-button","warning","You need to tell us the terms of your mortgage","top"); return; } if ($("#goals_target_budget_old_div").is(':visible') == false) { $("#goals_target_budget_old_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#goals_target_budget_old_div").removeClass("x-hide"); $("#goals_target_budget_old").change(); oc_paused = false; }); return; } if (txt("#goals_target_budget_old") === "") { mar.tip(".help-button","warning","You need to tell us the current payment","top"); return; } if ($("#refi_current_pmt_includes_div").is(':visible') == false) { $("#refi_current_pmt_includes_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_current_pmt_includes_div").removeClass("x-hide"); oc_paused = true; $("#refi_current_pmt_includes").change(); oc_paused = false; }); return; } if (yn3("#refi_current_pmt_includes") === "") { mar.tip(".help-button","warning","You need to tell us if the current payment includes taxes escrows","top"); return; } if ($("#refi_current_pmt_includes_ins_div").is(':visible') == false) { $("#refi_current_pmt_includes_ins_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_current_pmt_includes_ins_div").removeClass("x-hide"); oc_paused = true; $("#refi_current_pmt_includes_ins").change(); oc_paused = false; }); return; } if (yn3("#refi_current_pmt_includes_ins") === "") { mar.tip(".help-button","warning","You need to tell us if the current payment includes insurcane escrows","top"); return; } if (yn3("#refi_current_pmt_includes_ins") === "N" && yn3("#refi_current_pmt_includes") === "N") { // hide the excrow question because there are no escrows $("#refi_current_escrow_div").addClass("x-hide"); $("#refi_current_escrow_div").css("display", "none"); txt("#refi_current_escrow","0"); } else { if ($("#refi_current_escrow_div").is(':visible') == false) { $("#refi_current_escrow_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_current_escrow_div").removeClass("x-hide"); $("#refi_current_escrow_div").css("display", "unset"); oc_paused = true; $("#refi_current_escrow").change(); oc_paused = false; }); return; } if (txt("#refi_current_escrow") === "") { mar.tip(".help-button","warning","You need to tell us the escrow balance is","top"); return; } } if ($("#refi_current_debt_mdate_div").is(':visible') == false) { $("#refi_current_debt_mdate_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_current_debt_mdate_div").removeClass("x-hide"); oc_paused = true; $("#refi_current_debt_mdate").change(); oc_paused = false; }); return; } if (txt("#refi_current_debt_mdate") === "") { mar.tip(".help-button","warning","You need to tell us the date you closed","top"); return; } } else { /* rate & term or limited cashout */ oc_paused = true; $("#refi_current_debt_rate_div").addClass("x-hide"); txt("#refi_current_debt_rate","0"); $("#refi_current_debt_terms_div").addClass("x-hide"); radio("refi_current_debt_terms","") $("#goals_target_budget_old_div").addClass("x-hide"); txt("#goals_target_budget_old","0"); $("#refi_current_pmt_includes_div").addClass("x-hide"); txt("#refi_current_pmt_includes","Y"); $("#refi_current_pmt_includes_ins_div").addClass("x-hide"); txt("#refi_current_pmt_includes_ins","Y"); $("#refi_current_escrow_div").addClass("x-hide"); txt("#refi_current_escrow","0"); $("#refi_current_debt_mdate_div").addClass("x-hide"); txt("#refi_current_debt_mdate",""); oc_paused = false; } } /** * taxes always visible */ if ($("#refi_taxes_div").is(':visible') == false) { $("#refi_taxes_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_taxes_div").removeClass("x-hide"); oc_paused = true; if (txt("#refi_taxes") === "") txt("#refi_taxes",0); $("#refi_taxes").change(); oc_paused = false; }); return; } if (num(txt("#refi_taxes")) === 0) { mar.tip(".help-button","warning","The tax estimate is not filled in","top"); return; } if ($("#refi_taxes_due_div").is(':visible') == false) { $("#refi_taxes_due_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_taxes_due_div").removeClass("x-hide"); if (txt(`#refi_taxes_due`) === ``) { let mdate = txt(`#refi_current_debt_mdate`); /* 2010-06-01 */ let mdateA = mdate.split(`-`); let _yr = MAR.getCurrentYear(); mdateA[0] = `${_yr}`; /* (yr)-06-01 */ mdateA[1] = `01`; mdateA[2] = `01`; /** * state specific */ if (state_code === "NC") { mdateA[1] = `12`; mdateA[2] = `20`; } if (state_code === "GA") { mdateA[1] = `11`; mdateA[2] = `01`; } if (state_code === "SC") { mdateA[1] = `01`; mdateA[2] = `15`; } if (state_code === "FL") { mdateA[1] = `11`; mdateA[2] = `01`; } while (new Date(mdateA.join(`-`)).getTime() < new Date().getTime()) { _yr++; mdateA[0] = `${_yr}`; /* (yr+1)-06-01 */ } oc_paused = true; txt("#refi_taxes_due",mdateA.join(`-`)); $("#refi_taxes_due").change(); oc_paused = false; } else { oc_paused = true; $("#refi_taxes_due").change(); oc_paused = false; } }) return; } if ($("#refi_home_insurance_cost_div").is(':visible') == false) { $("#refi_home_insurance_cost_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_home_insurance_cost_div").removeClass("x-hide"); oc_paused = true; if (txt("#refi_home_insurance_cost") === "") txt("#refi_home_insurance_cost",0); $("#refi_home_insurance_cost").change(); oc_paused = false; }) return; } if ($("#refi_home_insurance_due_div").is(':visible') == false) { $("#refi_home_insurance_due_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#refi_home_insurance_due_div").removeClass("x-hide"); if (txt(`#refi_home_insurance_due`) === ``) { let mdate = txt(`#refi_current_debt_mdate`); let mdateA = mdate.split(`-`); let _yr = MAR.getCurrentYear(); mdateA[0] = `${_yr}`; while (new Date(mdateA.join(`-`)).getTime() < new Date().getTime()) { _yr++; mdateA[0] = `${_yr}`; } oc_paused = true; txt("#refi_home_insurance_due",mdateA.join(`-`)); $("#refi_home_insurance_due").change(); oc_paused = false; } else { oc_paused = true; $("#refi_home_insurance_due").change(); oc_paused = false; } }) return; } if ($("#hoa_estimate_div").is(':visible') == false) { $("#hoa_estimate_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#hoa_estimate_div").removeClass("x-hide"); oc_paused = true; if (txt("#hoa_estimate") === "") txt("#hoa_estimate",0); $("#hoa_estimate").change(); oc_paused = false; }) return; } /** * here we will make the text show mortgages */ $(".dr-button.next-button").html(SHOW_LOANS); // let refi_current_value = num(txt("#refi_current_value")); // let refi_current_debt = num(txt("#refi_current_debt")); // let can_cashout = (refi_current_debt === 0 || (refi_current_debt / refi_current_value) < 0.8); // can_cashout = true; // // (function ensure_refi_goal_matches_value(){ // let _val = num(txt("#refi_current_value")); // let _debt = num(txt("#refi_current_debt")); // let _key = `${_val}_${_debt}`; // // let $div = $("#refi_goal_div"); // let key = $div.data("key"); // let val = txt("#refi_goal") // if (key !== _key) { // /** // * replace slider // */ // let ptype = getScenario_data("property_type",""); // let otype = getScenario_data("occupancy_type",""); // let limit = 0.75; // if (ptype === "sfr" && otype === mar.OCCUPANCY_PRIMARY) { // limit = 0.80; // } // let max = (((_val * limit) - _debt) - 2500 - (_debt * 0.01)); // // $(`.cashout_text`).html(`up to an estimated ${elaineui.format("cur", ~~(max))} maximum`) //// debugger; // let h = ""; // VAL = val; // h += frm.slider("refi_goal","Within $1000 of:",VAL,"","",function(){ // oc(); // }, { // v00 : '0', // v50 : ~~(max/4), // v50_inc : '250', // v75 : ~~(max/2), // v75_inc : '500', // v100 : ~~(max), // v100_inc : '2500', // start_val : '70000' // }).render(); //// debugger; // $("#refi_goal_div_slider").html(""); // setTimeout(function(){ // $("#refi_goal_div_slider").html(h); // $("#refi_goal_div_slider .xx-slider").myslider(); // $("#refi_goal_div_slider ._dollars").inputmask("numeric", { // radixPoint: ".", // groupSeparator: ",", // digits: 2, // autoGroup: true, // prefix: '$', //No Space, this will truncate the first character // rightAlign: false, // autoUnmask : true // }); // },1); // // $div.data("key",_key); // } // })(); // // if (can_cashout) { // if ($("#refi_options_div").is(':visible') == false) { // $("#refi_options_div").slideDown(function(){ // $("#body-container").scrollTo("max",200); // $("#refi_options_div").removeClass("x-hide"); // }); // return; // } // if (radio("refi_options") === "") { // mar.tip(".help-button","warning","The option is not filled in","top"); // return; // } // } else { // $("#refi_options_div").addClass("x-hide"); // $("#refi_options_div").css("display","none"); // radio("refi_options", "closing"); // } // // if (radio("refi_options") === "cashout") { // // $("#refi_liquid_assets_div").css("display","none"); // $("#refi_liquid_assets_div").addClass("x-hide"); // // if ($("#refi_goal_div").is(':visible') == false) { // $("#refi_goal_div").slideDown(function(){ // $("#body-container").scrollTo("max",200); // $("#refi_goal_div").removeClass("x-hide"); // oc_paused = true; // $("#refi_goal").change(); // oc_paused = false; // }); // return; // } // if (num(txt("#refi_goal")) === 0) { // mar.tip(".help-button","warning","The goal is not filled in","top"); // return; // } // // } else if (radio("refi_options") === "closing") { // txt("#refi_goal","1000") // $("#refi_goal_div").css("display","none"); // $("#refi_goal_div").addClass("x-hide"); // $("#refi_liquid_assets_div").css("display","none"); // $("#refi_liquid_assets_div").addClass("x-hide"); // } else { // $("#refi_goal_div").css("display","none"); // $("#refi_goal_div").addClass("x-hide"); // $("#refi_liquid_assets_div").css("display","block"); // $("#refi_liquid_assets_div").removeClass("x-hide"); // oc_paused = true; // $("#refi_liquid_assets").change(); // oc_paused = false; // // // } if (num(txt("#refi_liquid_assets")) === 0) { // mar.tip(".help-button","warning","The assets estimate is not filled in","top"); // return; } if ($("#interestonly_div").length > 0) { if ($("#interestonly_div").is(':visible') == false) { $("#interestonly_div").slideDown(function(){ $("#body-container").scrollTo("max",200); $("#interestonly_div").removeClass("x-hide"); $("#interestonly").change(); }); return; } if (yn3("#interestonly") === "") { mar.tip(".help-button","warning","You need to let us know if you want to try the interst only option","top"); return; } } return true; } let lookup_grids = async function() { let getSync = function(url) { return new Promise(function(resolve, reject){ $.get(url, function(da){ resolve(da); }); }); } let url = `/api/chatbot/getRates?appid=${mar.ID}&return=grid`; if (loan_type !== "purchase") { let refi_options = radio("refi_options"); url += `&over_refi_options=${refi_options}` } let grid_rv = await getSync(url); (function(){ // let progs = MAR.getOpt(grid_rv, "rec_progs",[]); let progs = []; for (let x in grid_rv) { if (x === "rec_progs") continue; if (x.startsWith("is_")) continue; progs.push(x); } let min_score = 0; let min_score_p = ""; let max_loan = 0; let max_loan_p = ""; let max_ltv = 0; let max_ltv_p = ""; let minc2c = false; let FIXEDC2C = 7500; let occ = ""; let prop = ""; let fthb = ""; let trans = ""; let county = ""; let countyG = ""; let countyS = ""; let lowestdp = false; let lowestdp_p = ""; let lowestdp_sug = false; let all_options = []; let all_target_hit = false; for (let prog of progs) { let grid = MAR.getOpt(grid_rv, prog, {}); let out = MAR.getOpt(grid, "outputs", {}); let _minscore = MAR.getOptNum(out, "min_score", false); let _maxltv = MAR.getOptNum(out, "max_ltv", false); let _maxloan = MAR.getOptNum(out, "max_loan", false); let _maxpp = ~~((num(_maxloan) / num(max_ltv) ) * 100); occ = MAR.getOpt(grid, "inputs.type_of_occupancy", ""); prop = MAR.getOpt(grid, "inputs.type_of_property", ""); fthb = MAR.getOpt(grid, "inputs.first_time_buyer_option", ""); trans = MAR.getOpt(grid, "inputs.type_of_transaction", ""); county = MAR.getOpt(grid, "inputs.county", ""); countyG = MAR.getOpt(grid, "countyG", ""); countyS = MAR.getOpt(grid, "countyS", ""); if (_minscore !== false && _minscore > min_score) { min_score = _minscore; min_score_p = `${prog}`; } if (_maxltv !== false && _maxltv > max_ltv) { max_ltv = _maxltv; max_ltv_p = `${prog}`; } if (_maxloan !== false && _maxloan > max_loan) { max_loan = _maxloan; max_loan_p = `${prog}`; } let sug = {}; if (loan_type !== "purchase") { let refi_current_value = num(txt("#refi_current_value")); let refi_current_debt = num(txt("#refi_current_debt")); let refi_options = radio("refi_options"); let refi_goal = num(txt("#refi_goal")); let refi_liquid_assets = txt("#refi_liquid_assets"); let refi_taxes = txt("#refi_taxes"); let refi_current_debt_rate = txt("#refi_current_debt_rate"); let refi_current_debt_terms = radio("refi_current_debt_terms"); let refi_current_pmt_includes = yn3("#refi_current_pmt_includes"); let refi_current_pmt_includes_ins = yn3("#refi_current_pmt_includes_ins"); let refi_current_escrow = txt("#refi_current_escrow"); let refi_current_debt_mdate = txt("#refi_current_debt_mdate"); let refi_taxes_due = txt("#refi_taxes_due"); if (refi_options === "closing") refi_goal = 0; // rate and term let target_loan = refi_current_debt + refi_goal; let ltv = (target_loan / refi_current_value) * 100; let base_ltv = (refi_current_debt / refi_current_value) * 100; sug.ltv = ltv; sug.loan = target_loan; sug.goal = refi_goal; sug.adj = ""; sug.max_ltv = _maxltv; sug.max_loan = _maxloan; if (refi_current_debt > max_loan) { sug.adj += "(impossible_maxloan)"; } else if (base_ltv > max_ltv) { sug.adj += "(impossible_ltv)"; } else { if (sug.loan > max_loan) { sug.loan = (max_loan ); sug.goal = (sug.loan - refi_current_debt); sug.ltv = ((sug.loan / refi_current_value) * 100) sug.adj += "(max_loan)"; } if (sug.ltv > max_ltv) { sug.ltv = max_ltv; sug.loan = (refi_current_value * ((100 - sug.ltv)/100)); sug.goal = (sug.loan - refi_current_debt); sug.adj += "(max_ltv)"; } } // let dparray = []; // if (prog === "va") { // if (max_ltv === 100) dparray=[100,90,85,75,70]; // va loan // if (max_ltv === 90) dparray=[90,85,75,70]; // va loan // if (max_ltv === 85) dparray=[85,75,70]; // va loan // if (max_ltv === 75) dparray=[75,70]; // va loan // if (max_ltv === 70) dparray=[70]; // va loan // } // if (prog === "fha") { // if (max_ltv === 97.75) dparray=[97.75,96.5,85]; // fha loan // if (max_ltv === 96.5) dparray=[96.5,85]; // fha loan // if (max_ltv === 85) dparray=[85]; // fha loan // } // if (prog === "conv") { // if (max_ltv === 97) dparray=[97,95,90,85,80,75]; // conv loan // if (max_ltv === 95) dparray=[95,90,85,80,75]; // conv loan // if (max_ltv === 90) dparray=[90,85,80,75]; // conv loan // if (max_ltv === 85) dparray=[85,80,75]; // conv loan // if (max_ltv === 80) dparray=[80,75]; // conv loan // if (max_ltv === 75) dparray=[75]; // conv loan // } // for (let i=0; i < dparray.length; i++) { // let ltv = dparray[i]; // let loan = ~~(sug.pp * (ltv/100)); // let c2c = sug.pp - loan + FIXEDC2C; // if (loan < _maxloan && sug.c2c >= c2c) { // sug.options[`${ltv}`] = { // ltv : ltv, // loan : loan, // c2c : c2c // }; // } // } if (lowestdp === false || sug.goal < lowestdp || (lowestdp_sug.adj !== "" && sug.adj === "") ) { lowestdp = sug.goal; lowestdp_p = `${prog}`; lowestdp_sug = sug; } } else { $("#goals_target_downpayment_perc_div .warning_div").html(""); $("#purchase_target_div .warning_div").html(""); return; // end // let target_dp = num(txt("#goals_target_downpayment_perc")); let target_p = num(txt("#purchase_target")); let target_loan = ~~(target_p * ((100 - target_dp)/ 100)); let max_pp = ~~(_maxloan / (100-target_dp) ) * 100; let dp = ~~(target_p * (target_dp/100)); let c2c = num(txt("#hb_liquid_assets")); sug.ltv = (100 - target_dp); sug.loan = target_loan; sug.pp = target_p; sug.dp = ~~(target_p * ((100-sug.ltv)/100)); sug.adj = ""; sug.max_ltv = _maxltv; sug.max_loan = _maxloan; sug.c2c = c2c; sug.options = {}; sug.prog = `${prog}`; sug.empty = true; if (sug.ltv > _maxltv) { sug.ltv = _maxltv; sug.loan = (target_p * ((100 - sug.ltv)/100)); sug.dp = ~~(target_p * ((100-sug.ltv)/100)); sug.adj += "(max_ltv)"; sug.pp = target_p; } if (sug.loan > _maxloan) { sug.loan = _maxloan; sug.dp = target_p - sug.loan; sug.ltv = ((sug.loan / target_p) * 100) sug.adj += "(max_loan)"; sug.pp = target_p; } sug.c2c_needed = sug.dp + FIXEDC2C; sug.absmax = `none`; if (sug.c2c_needed > sug.c2c) { let absmax = {}; // absolut max absmax.loan = _maxloan; absmax.ltv = _maxltv; absmax.pp = ~~((_maxloan / _maxltv) * 100); absmax.dp = (absmax.pp - absmax.loan); absmax.c2c = absmax.dp + FIXEDC2C; if (absmax.pp > target_p) { /* if the absolute max is above the pp , adjust it down */ absmax.pp = target_p; absmax.loan = ~~(absmax.pp * ((_maxltv)/100)); absmax.ltv = _maxltv; absmax.dp = (absmax.pp - absmax.loan); absmax.c2c = absmax.dp + FIXEDC2C; } sug.absmax = JSON.parse(JSON.stringify(absmax)); if (absmax.c2c < sug.c2c) { // we should be able to do this ! sug.pp = ~~((absmax.loan + sug.c2c) - FIXEDC2C); sug.loan = absmax.loan; sug.dp = sug.c2c - FIXEDC2C; sug.ltv = ((sug.loan / sug.pp) * 100) sug.adj += "(low_c2c)(up)"; } else { sug.pp = ~~(((sug.c2c-FIXEDC2C) / (100 - _maxltv)) * 100); sug.loan = ~~(sug.pp * (_maxltv / 100)); sug.dp = (sug.pp - sug.loan); sug.ltv = ((sug.loan / sug.pp) * 100) sug.adj += "(low_c2c)(down)"; } let min_dp = ~~(target_p * ((100 - _maxltv)/100)); let min_dp_loan = (target_p - min_dp); if (min_dp_loan > _maxloan) { min_dp = (target_p - _maxloan); } let min_c2c = min_dp + FIXEDC2C; if (min_c2c < sug.c2c_needed) { sug.c2c_needed = min_c2c; } } else { sug.absmax = `sug.c2c_needed > sug.c2c ${sug.c2c_needed} > ${sug.c2c}`; } let dparray = []; if (prog === "va") { if (_maxltv === 100) dparray=[100,90,85,75,70]; // va loan if (_maxltv === 90) dparray=[90,85,75,70]; // va loan if (_maxltv === 85) dparray=[85,75,70]; // va loan if (_maxltv === 75) dparray=[75,70]; // va loan if (_maxltv === 70) dparray=[70]; // va loan } if (prog === "fha") { if (_maxltv === 97.75) dparray=[97.75,96.5,85]; // fha loan if (_maxltv === 96.5) dparray=[96.5,85]; // fha loan if (_maxltv === 85) dparray=[85]; // fha loan } if (prog === "conv") { if (_maxltv === 97) dparray=[97,95,90,85,80,75]; // conv loan if (_maxltv === 95) dparray=[95,90,85,80,75]; // conv loan if (_maxltv === 90) dparray=[90,85,80,75]; // conv loan if (_maxltv === 85) dparray=[85,80,75]; // conv loan if (_maxltv === 80) dparray=[80,75]; // conv loan if (_maxltv === 75) dparray=[75]; // conv loan } for (let i=0; i < dparray.length; i++) { let ltv = dparray[i]; let loan = ~~(sug.pp * (ltv/100)); if (loan > _maxloan) loan = _maxloan; let c2c = sug.pp - loan + FIXEDC2C; if (loan <= _maxloan && sug.c2c >= c2c) { sug.options[`${ltv}`] = { ltv : ltv, loan : loan, c2c : c2c, pp : sug.pp, dp : (sug.pp - loan), eff_ltv : (loan/sug.pp)*100, avail_c2c : sug.c2c, prog : sug.prog, target_hit : (sug.pp >= target_p) }; all_options.push(sug.options[`${ltv}`]); sug.empty = false; if (sug.pp >= target_p) { all_target_hit = true; } let min_dp = ~~(target_p * ((100 - ltv)/100)); let min_dp_loan = (target_p - min_dp); if (min_dp_loan > _maxloan) { min_dp = (target_p - _maxloan); } let min_c2c = min_dp + FIXEDC2C; if (minc2c === false || min_c2c < minc2c) { minc2c = min_c2c; } } else if (loan <= _maxloan) { if (sug.pp >= target_p) { if (c2c < minc2c) { minc2c = c2c; } } } } if (sug.empty === false && (lowestdp === false || lowestdp < sug.pp)) { lowestdp = sug.pp; lowestdp_p = `${prog}`; lowestdp_sug = sug; } } } if (loan_type !== "purchase") { $("#refi_warning_div .warning_div").html(""); $("#refi_warning_div").addClass("x-hide"); let refi_current_value = num(txt("#refi_current_value")); let refi_current_debt = num(txt("#refi_current_debt")); let refi_options = radio("refi_options"); let refi_goal = num(txt("#refi_goal")); let refi_liquid_assets = txt("#refi_liquid_assets"); let refi_taxes = txt("#refi_taxes"); let refi_current_debt_rate = txt("#refi_current_debt_rate"); let refi_current_debt_terms = radio("refi_current_debt_terms"); let refi_current_pmt_includes = yn3("#refi_current_pmt_includes"); let refi_current_pmt_includes_ins = yn3("#refi_current_pmt_includes_ins"); let refi_current_escrow = txt("#refi_current_escrow"); let refi_current_debt_mdate = txt("#refi_current_debt_mdate"); let refi_taxes_due = txt("#refi_taxes_due"); if (refi_options === "closing") refi_goal = 0; // rate and term let target_loan = refi_current_debt + refi_goal; let ltv = (target_loan / refi_current_value) * 100; if (refi_current_debt > refi_current_value) { $("#refi_warning_div .warning_div").html(frm.inline_warning_red("You need some equity in the property.")); $("#refi_warning_div").removeClass("x-hide"); return; } if (lowestdp_sug.adj !== "") { let scen = `for a ${mar._txt(occ)} ${mar._txt(trans)} of a ${mar._txt(prop)} in ${countyG}`; let sug = lowestdp_sug; let wrn = ``; if (refi_goal > 0) { wrn += `Your requested loan amount is too high ${scen} refinance for most popular programs. Other programs may qualify.`; } else { wrn += `Your requested loan amount is too high ${scen} refinance for most popular programs. `+ `Your requested cash out amount may be too high for some or all programs. We can adjust the cash- out to maximum per option. `+ `Other programs may qualify.`; } if (lowestdp_sug.adj === "(impossible_maxloan)") { wrn += `
  • We hit a Loan Limit, the maximum loan for ${scen} is ${elaineui.format("cur",(sug.max_loan))}. Are you sure that your debt is above this limit?
  • `; } if (lowestdp_sug.adj === "(impossible_ltv)") { wrn += `
  • We hit a LTV limit, the minimum downpayment for ${scen} is ${(100 - sug.max_ltv)} %. If your property valuation was ${elaineui.format("cur",~~((sug.loan / sug.max_ltv) * 100))} it would be possible.
  • `; } if (lowestdp_sug.adj === "(max_loan)") { wrn += `
  • We hit a Loan Limit, the maximum loan for ${scen} is ${elaineui.format("cur",sug.max_loan)}.`; wrn += `

    You would have to reduce the goal to ${elaineui.format("cur",sug.goal)} to make this work
  • `; } if (lowestdp_sug.adj === "(max_ltv)") { wrn += `
  • We hit a LTV Limit, the maximum LTV for ${scen} is ${(sug.max_ltv)} %. `; wrn += `

    You would have to reduce the goal to ${elaineui.format("cur",sug.goal)} to make this work
  • `; } wrn += `
    `; //$("#refi_warning_div .warning_div").html(frm.inline_warning_red(wrn)); //$("#refi_warning_div").removeClass("x-hide"); return; } } else { if (all_target_hit === false) { $("#goals_target_downpayment_perc_div .warning_div").html(""); $("#purchase_target_div .warning_div").html(""); let sug = lowestdp_sug; let scen = `for a ${mar._txt(occ)} ${mar._txt(trans)} of a ${mar._txt(prop)} in ${countyG}`; let target_p = num(txt("#purchase_target")); let wrn = ""; wrn += ``; wrn += `Your requested loan amount is too high ${scen} for most popular programs. Other programs may qualify.`; // * Maximum loan $ 85,000 (Loan-To-Value limited to 85% of expected appraised value of $ 100,000) [LTV issues] // * Maximum loan $ 548,250 (Conventional Broward County Loan Limit) [Loan Limit issues REFI] // * Increase downpayment to $ 100,000 or change other loan parameters (Purchase $ 200,000 -/- Loan Limit {Broward} county $ 100,000) [Loan Limit issues PURCHASE]" + // "" + // " wrn += `
  • The maximum purchase price we can achieve with these numbers is ${elaineui.format("cur",sug.loan)}
  • `; if (sug.adj.indexOf("(max_ltv)") > -1) { wrn += `
  • Maximum loan ${elaineui.format("cur",max_loan)} (Loan-To-Value limited to ${elaineui.format("perc",sug.max_ltv)} of expected appraised value of ${elaineui.format("cur",target_p)})
  • `; } if (sug.adj.indexOf("(max_loan)") > -1) { wrn += `
  • Maximum loan ${elaineui.format("cur",max_loan)} (Loan-To-Value limited to ${elaineui.format("perc",sug.max_ltv)} of expected appraised value of ${elaineui.format("cur",target_p)} )
  • `; } if (sug.adj.indexOf("(low_c2c)(up)") > -1) { wrn += `
  • Increase downpayment to ${elaineui.format("cur",minc2c)} x or change other loan parameters (Purchase ${elaineui.format("cur",target_p)} -/- Loan Limit ${countyG} county ${elaineui.format("cur",max_loan)})
  • `; } if (sug.adj.indexOf("(low_c2c)(down)") > -1) { wrn += `
  • Increase downpayment to ${elaineui.format("cur",minc2c)} x or change other loan parameters (Purchase ${elaineui.format("cur",target_p)} -/- Loan Limit ${countyG} county ${elaineui.format("cur",max_loan)})
  • `; } wrn += `
    `; $("#purchase_target_div .warning_div").html(frm.inline_warning_red(wrn)); return; } else { $("#goals_target_downpayment_perc_div .warning_div").html(""); $("#purchase_target_div .warning_div").html(""); let selected_opt = false; for (let i=0; i < all_options.length; i++) { let opt = all_options[i]; if (opt.target_hit === false) continue; if (selected_opt === false || opt.eff_ltv < selected_opt.eff_ltv) { selected_opt = opt; } } let dpp = (100-selected_opt.eff_ltv); let gdpp = num(txt("#goals_target_downpayment_perc")); if (dpp > gdpp) { txt("#goals_target_downpayment_perc",dpp); $("#goals_target_downpayment_perc").change(); setScenario_data("goals_target_downpayment_perc" , dpp); goals_target_downpayment_perc = dpp; } return; } if (lowestdp_sug.adj !== "") { $("#goals_target_downpayment_perc_div .warning_div").html(""); $("#purchase_target_div .warning_div").html(""); let target_dp = num(txt("#goals_target_downpayment_perc")); let target_p = num(txt("#purchase_target")); let target_loan = ~~(target_p * ((100 - target_dp)/ 100)); let max_pp = ~~(max_loan / (100-target_dp) ) * 100; let sug = lowestdp_sug; let scen = `for a ${mar._txt(occ)} ${mar._txt(trans)} of a ${mar._txt(prop)}`; let wrn = ``; // wrn += `Requested loan amount exceds ${mar._txt(max_loan_p)} loan limit of \$ ${max_loan} ${scen}. `+ // `

    With a downpayment of ${target_dp}% the maximum purchase price would be \$ ${max_pp}`+ if (lowestdp_sug.adj === "(max_ltv)") { wrn += `We hit an LTV limit, the minimum downpayment for ${scen} is ${(100-sug.max_ltv)}%. `; wrn += `

    To achieve the goal of ${elaineui.format("cur",target_p)} a ${(100-sug.ltv)}% downpayment of \$ ${sug.dp} Would be needed `; } if (lowestdp_sug.adj === "(max_loan)") { wrn += `We hit an maximum loan limit of ${elaineui.format("cur",sug.max_loan)} for ${scen}. `; wrn += `

    To achieve the goal of ${elaineui.format("cur",target_p)} a downpayment of \$ ${sug.dp} ,${(100-sug.ltv).toFixed(1)}% Would be needed `; } if (lowestdp_sug.adj === "(max_ltv)(max_loan)") { wrn += `The and the minium downpayment for ${scen} is ${(100-sug.max_ltv)}% and the maximum loan limit is ${elaineui.format("cur",sug.max_loan)}. `; wrn += `

    To achieve the goal of ${elaineui.format("cur",target_p)} a downpayment of ${elaineui.format("cur",sug.dp)} ,${(100-sug.ltv).toFixed(1)}% Would be needed `; } wrn += `
    `; $("#purchase_target_div .warning_div").html(frm.inline_warning_red(wrn)); return; } } if (loan_type !== "purchase") { let refi_current_value = num(txt("#refi_current_value")); let refi_current_debt = num(txt("#refi_current_debt")); let refi_options = radio("refi_options"); let refi_goal = num(txt("#refi_goal")); let refi_liquid_assets = txt("#refi_liquid_assets"); let refi_taxes = txt("#refi_taxes"); let refi_current_debt_rate = txt("#refi_current_debt_rate"); let refi_current_debt_terms = radio("refi_current_debt_terms"); let refi_current_pmt_includes = yn3("#refi_current_pmt_includes"); let refi_current_pmt_includes_ins = yn3("#refi_current_pmt_includes_ins"); let refi_current_escrow = txt("#refi_current_escrow"); let refi_current_debt_mdate = txt("#refi_current_debt_mdate"); let refi_taxes_due = txt("#refi_taxes_due"); if (refi_options === "closing") refi_goal = 0; // rate and term let target_loan = refi_current_debt + refi_goal; let ltv = (target_loan / refi_current_value) * 100; if (ltv > max_ltv) { // Requested loan amount exceeds 80% Loan to Value for Cash-out Conventional refinance loans let wrn = `Requested loan amount exceeds ${(max_ltv)}% Loan to Value for ${mar._txt(trans)} ${mar._txt(max_ltv_p)} refinance loans`; // $("#refi_warning_div .warning_div").html(frm.inline_warning_red(wrn)); return; } if (target_loan > max_loan) { // Requested loan amount exceeds {Conventional} loan limit of {amount} for a primary purchase of a single-family home. let scen = `for a ${mar._txt(occ)} ${mar._txt(trans)} of a ${mar._txt(prop)}`; let wrn = `Requested loan amount of \$ ${target_loan} exceds ${mar._txt(max_loan_p)} loan limit of \$ ${max_loan} ${scen}. `; // $("#refi_warning_div .warning_div").html(frm.inline_warning_red(wrn)); return; } } else { $("#goals_target_downpayment_perc_div .warning_div").html(""); $("#purchase_target_div .warning_div").html(""); let target_dp = num(txt("#goals_target_downpayment_perc")); if ((target_dp + max_ltv) < 100) { // Minimum downpayment for {investment} {duplex} is 25% // Investment property not allowed for {FHA / VA} let scen = `${mar._txt(occ)} ${mar._txt(trans)} of a ${mar._txt(prop)}`; let wrn = `Minimum ${mar._txt(max_ltv_p)} downpayment for ${scen} is ${(100-max_ltv)}%`; $("#goals_target_downpayment_perc_div .warning_div").html(frm.inline_warning_red(wrn)); return; } let target_p = num(txt("#purchase_target")); let target_loan = ~~(target_p * ((100 - target_dp)/ 100)); let max_pp = ~~(max_loan / (100-target_dp) ) * 100; if (target_loan > max_loan) { // Requested loan amount exceeds {Conventional} loan limit of {amount} for a primary purchase of a single-family home. let scen = `for a ${mar._txt(occ)} ${mar._txt(trans)} of a ${mar._txt(prop)}`; let wrn = `Requested loan amount exceds ${mar._txt(max_loan_p)} loan limit of \$ ${max_loan} ${scen}. `+ `

    With a downpayment of ${target_dp}% the maximum purchase price would be \$ ${max_pp}
    `; $("#purchase_target_div .warning_div").html(frm.inline_warning_red(wrn)); return; } } })(); } let _continue_fn = async function(_from){ mar.tmp_context_saver.save(); let $reveals = $(".x-revealdiv"); if (_from === `fromclick`) { if ($(".dr-button.next-button").data(`from`) !== `clickfn`) { $(".dr-button.next-button").html(SHOW_LOANS_CONTINUE); $(".dr-button.next-button").data(`from`,`clickfn`); } } if ($reveals.length > 0) { $(".igotit").remove(); let $elm = $($reveals[0]); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); oc_stable(); }); // $(".dr-button.next-button").html(buttonText); // return; } oc_stable(); let REMOVED_FIELDS = "0"; var same = txt("#samelineofwork"); var stable = txt("#stableincome"); var goals_target_budget_old = REMOVED_FIELDS; //txt("#goals_target_budget_high"); var goals_target_budget_high = REMOVED_FIELDS; //txt("#goals_target_budget_high"); var purchase_target = txt("#purchase_target"); var enough = ""; var refi_current_value = false; var refi_current_debt = false var refi_options = false var refi_goal = false; var refi_liquid_assets = false; var refi_taxes = false; var hb_liquid_assets = false; var occupancy_type = false; var property_type = false; var location = false; var va = false; var fthb = false; var scenario_tax = false; var refi_home_insurance_cost = false; var refi_home_insurance_due = false; var hoa_estimate = false; var interestonly = false; let refi_current_debt_rate = false; let refi_current_debt_terms = false; let refi_current_pmt_includes = false; let refi_current_pmt_includes_ins = false; let refi_current_escrow = false; let refi_current_debt_mdate = false; let refi_taxes_due = false; if (applicantnum == 0 && loan_type !== "purchase") { refi_current_value = txt("#refi_current_value"); refi_current_debt = txt("#refi_current_debt"); refi_options = radio("refi_options"); refi_goal = txt("#refi_goal"); goals_target_budget_old = txt("#goals_target_budget_old"); refi_liquid_assets = txt("#refi_liquid_assets"); refi_taxes = txt("#refi_taxes"); refi_home_insurance_cost = txt("#refi_home_insurance_cost"); refi_home_insurance_due = txt("#refi_home_insurance_due"); hoa_estimate = txt("#hoa_estimate"); interestonly = yn3("#interestonly"); refi_current_debt_rate = txt("#refi_current_debt_rate"); refi_current_debt_terms = radio("refi_current_debt_terms"); refi_current_pmt_includes = yn3("#refi_current_pmt_includes"); refi_current_pmt_includes_ins = yn3("#refi_current_pmt_includes_ins"); refi_current_escrow = txt("#refi_current_escrow"); refi_current_debt_mdate = txt("#refi_current_debt_mdate"); refi_taxes_due = txt("#refi_taxes_due"); // va = yn3("#va"); } else if (applicantnum == 0) { enough = txt("#enoughincome"); goals_target_downpayment_perc = "0"; //txt("#goals_target_downpayment_perc"); hb_liquid_assets = txt("#hb_liquid_assets"); scenario_tax = txt("#scenario_tax"); refi_home_insurance_cost = txt("#refi_home_insurance_cost"); hoa_estimate = txt("#hoa_estimate"); interestonly = yn3("#interestonly"); } if (same == "") { mar.tip(".help-button","warning","you need to answer yes or no","top"); return false; } var $sd = $("#stable-div"); if ($sd.is(':visible') == false) { setScenario_data("applicant"+applicantNum+"_samelineofwork",same); mar.fakesave(); $sd.slideDown(function(){ $("#body-container").scrollTo("max",200); }); return; } if (stable == "") { mar.tip(".help-button","warning","you need to answer yes or no","top"); return false; } if (applicantnum == 0) { if (loan_type !== "purchase") { var $sd = $("#refi-div"); $sd = $("#refi_current_value_div"); // changed it because we omitted the enough income for refi if ($sd.is(':visible') == false) { setScenario_data("applicant"+applicantNum+"_stableincome",stable); mar.fakesave(); $sd.slideDown(function(){ $("#body-container").scrollTo("max",200); // reveal components }); return; } if (await revealfields_refi() !== true) return; if (num(refi_current_value) === 0) { mar.tip(".help-button","warning","The current value is not filled in","top"); return false; } if (num(refi_current_debt) === 0) { if (getScenario_data("refi_current_value_zero" , "") !== "Y") { frm.areyousure("Current value", "Are you sure that you have nothing to pay off on the current mortgage, or that you own the property free from debt?", function(){ setScenario_data("refi_current_value_zero" , "Y"); _continue_fn(); },"I am sure"); return false; } } if (refi_options == "") { mar.tip(".help-button","warning","you need to let us know what type of refi you want","top"); return false; } if (num(refi_current_debt) > num(refi_current_value)) { mar.tip(".help-button","warning","You need some equity in the property","top"); return false; } if (refi_options === "cashout") { if (num(refi_goal) === 0) { mar.tip(".help-button","warning","You need to set the goal for your cash out refi","top"); return false; } setScenario_data("refi_current_value" , refi_current_value); setScenario_data("refi_current_debt" , refi_current_debt); setScenario_data("refi_options" , refi_options); setScenario_data("refi_goal" , refi_goal); setScenario_data("refi_liquid_assets" , refi_liquid_assets); setScenario_data("refi_taxes" , refi_taxes); setScenario_data("refi_home_insurance_cost" , refi_home_insurance_cost); setScenario_data("refi_home_insurance_due" , refi_home_insurance_due); setScenario_data("hoa_estimate" , hoa_estimate); setScenario_data("interestonly" , interestonly); setScenario_data("refi_current_debt_rate" , refi_current_debt_rate); setScenario_data("refi_current_debt_terms" , refi_current_debt_terms); setScenario_data("refi_current_pmt_includes" , refi_current_pmt_includes); setScenario_data("refi_current_pmt_includes_ins" , refi_current_pmt_includes_ins); setScenario_data("refi_current_escrow" , refi_current_escrow); setScenario_data("refi_current_debt_mdate" , refi_current_debt_mdate); setScenario_data("refi_taxes_due" , refi_taxes_due); let warning = MAR.scenario.cashout_ref_warning(1.0); if (warning) { mar.tip(".help-button","warning",warning,"top"); return false; } } } else { // var $sd = $("#enough-div"); // if ($sd.is(':visible') == false) { // setScenario_data("applicant"+applicantNum+"_stableincome",stable); // mar.fakesave(); // $sd.slideDown(function(){ // $("#body-container").scrollTo("max",200); // if (goals_target_budget_high_ref !== "Y") { // $("#budgetslider").removeClass("x-hide"); // $("#goals_target_budget_high").change() // } // }); // return; // } // // if (enough == "") { // mar.tip(".help-button","warning","you need to answer yes or no","top"); // return false; // // } if (await revealfields_purchase() !== true) return; } let $inp = $(`#body-container .x_panel`); $inp.LoadingOverlay("show"); await lookup_grids(); $inp.LoadingOverlay("hide",true); } if (wehavebeenherebefore !== "Y") { $("#body-container").scrollTo("max",200); } // // if (_v == "") { // mar.tip(".help-button","warning","you need to enter your credit score","top"); // return false; // } MAR.application.setHousingBudget(applicantnum,same,stable,enough); if (applicantnum == 0 && loan_type !== "purchase") { setScenario_data("refi_current_value" , refi_current_value); setScenario_data("refi_current_debt" , refi_current_debt); setScenario_data("refi_options" , refi_options); setScenario_data("refi_goal" , refi_goal); setScenario_data("refi_liquid_assets" , refi_liquid_assets); setScenario_data("refi_taxes" , refi_taxes); setScenario_data("refi_home_insurance_cost" , refi_home_insurance_cost); setScenario_data("refi_home_insurance_due" , refi_home_insurance_due); setScenario_data("hoa_estimate" , hoa_estimate); setScenario_data("interestonly" , interestonly); setScenario_data("refi_current_debt_rate" , refi_current_debt_rate); setScenario_data("refi_current_debt_terms" , refi_current_debt_terms); setScenario_data("refi_current_pmt_includes" , refi_current_pmt_includes); setScenario_data("refi_current_pmt_includes_ins" , refi_current_pmt_includes_ins); setScenario_data("refi_current_escrow" , refi_current_escrow); setScenario_data("refi_current_debt_mdate" , refi_current_debt_mdate); setScenario_data("refi_taxes_due" , refi_taxes_due); // setScenario_data("target_va" , va); setScenario_data("goals_target_budget_old" , goals_target_budget_old); //setScenario_data("goals_target_budget_high" , goals_target_budget_high); /** * reflect these in the subject property */ (function(){ let sp = MAR.reo.getSubjectProperty(); if (sp === false) { sp = MAR.reo.create({}); sp.is_subject_property = "Y"; MAR.reo.set(false, sp); sp = MAR.reo.getSubjectProperty(); } let uuid = sp.uuid; let updateobj = { value : refi_current_value } MAR.reo.setByUUID(uuid, updateobj); })(); } if (applicantnum == 0 && loan_type === "purchase") { setScenario_data("goals_target_budget_high" , goals_target_budget_high); setScenario_data("goals_target_downpayment_perc" , goals_target_downpayment_perc); setScenario_data("hb_liquid_assets" , hb_liquid_assets); setScenario_data("purchase_target" , purchase_target); setScenario_data("flood_estimate" , "0"); setScenario_data("scenario_i_know_my_tax" , "Y"); setScenario_data("scenario_tax" , scenario_tax); setScenario_data("scenario_i_know_my_insurance" , "Y"); setScenario_data("refi_home_insurance_cost" , refi_home_insurance_cost); setScenario_data("scenario_i_know_my_hoa" , "Y"); setScenario_data("hoa_estimate" , hoa_estimate); setScenario_data("interestonly" , interestonly); } let blockpopup = function(txt) { elaineui.swalprompt({ title : "Warning", txt : `
    ${txt}
    `, ok : "Continue anyway", okfn : function() { setScenario_data("__scenario_housingbudget_"+applicantnum+"_passed","Y"); mar.fakesave(function(rd,_status){ console.error(`HB 01 status was `,_status); if (applicantnum === 0) { setTimeout(function(){ mvc.go("#scenario-ratequote."+applicantnum); },300); } else { mvc.go("#declarations-p1."+applicantnum); } }); }, cancel : "adjust my numbers", cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } }) } let blocker1 = $("#purchase_target_div .blocker"); if (blocker1.length > 0) { blockpopup(blocker1.html()); return false; } let blocker = $("#goals_target_downpayment_perc_div .blocker"); if (blocker.length > 0) { blockpopup(blocker.html()); return false; } let blocker2 = $("#refi_warning_div .blocker"); if (blocker2.length > 0) { blockpopup(blocker2.html()); return false; } setScenario_data("__scenario_housingbudget_"+applicantnum+"_passed","Y"); mar.fakesave(function(rd,_status){ console.error(`HB 02 status was `,_status); mar.tmp_context_saver.clear(); if (applicantnum === 0) { setTimeout(function(){ mvc.go("#scenario-ratequote."+applicantnum); },300); } else { mvc.go("#declarations-p1."+applicantnum); } }); } h += uihelpers.cbuttonbar(buttonText,frm.addfunction(function(){ _continue_fn(`fromclick`); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-veteran."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let ocbudget = function() { var goals_target_budget_high = txt("#goals_target_budget_high"); let warning_text = false; if (num(goals_target_budget_high) > 0) { let _b = Math.floor((num(goals_target_budget_high)/43) * 100); let _gi = getIncome_v2(); if (_gi.is_empty == true) { warning_text = `The gross income of all applicants together must be at least \ ${elaineui.format("cur",_b)} per month \ `; } else { if (_gi.has_unverified_items == true) { if (_b > _gi.combined_total) { warning_text = `For the reqested budget of ${elaineui.format("cur",goals_target_budget_high)} \ you need to have ${elaineui.format("cur",_b)} in gross income \ Right now we see an income of ${elaineui.format("cur",_gi.combined_total)} \ please add income or reduce the requested budget \ `; } } else { if (_b > _gi.combined_total) { warning_text = `For the reqested budget of ${elaineui.format("cur",goals_target_budget_high)} \ you need to have ${elaineui.format("cur",_b)} in gross income \ Right now we see an income of ${elaineui.format("cur",_gi.combined_total)} \ please add income or reduce the requested budget \ `; } } } } if (warning_text !== false) { let h = `
    \ \ \ \ \ \ \ \ \ \ \ \
    ${warning_text}
    `; $(".budgetincomewarning").html(h); $(".info-enough1").click(pop1); setScenario_data("goals_target_budget_old",goals_target_budget_old); setScenario_data("goals_target_budget_low",goals_target_budget_high); setScenario_data("goals_target_budget_high",goals_target_budget_high); mar.fakesave(); } else { $(".budgetincomewarning").html(""); setScenario_data("goals_target_budget_old",goals_target_budget_old); setScenario_data("goals_target_budget_low",goals_target_budget_high); setScenario_data("goals_target_budget_high",goals_target_budget_high); mar.fakesave(); } if (wehavebeenherebefore !== "Y") { $("#body-container").scrollTo("max",200); } } let oc_stable = function(){ return; var same = txt("#samelineofwork"); var stable = txt("#stableincome"); if (same == "N" || stable == "N") { if ($(".er1").length == 0 && $("#stable-div").is(':visible') == true) { // only display if the stable div is visible let vv = ""; if (applicantnum == 0) { vv += frm.elaine("Without stable income, it is very difficult to get a loan approval. " + "if you were planning on adding more borrowers, " + "that have a higher enough credit score and stable income you may want to take yourself off the loan.","er1").render(); vv += "
    "; vv += frm.h2("
    Tip: you can be an owner of a property on the title, without being on the loan.
    ").render(); vv += frm.but("START A NEW APPLICATION",function(){ startapp(); }).render(); vv += ""; } else { vv += frm.elaine("Without stable income, it is very difficult to get a loan approval. " + "if you were planning on adding more borrowers, " + "that have a higher enough credit score and stable income you may want to take yourself off the loan.","er1").render(); vv += "
    "; vv += frm.h2("
    Tip: you can be an owner of a property on the title, without being on the loan.
    ").render(); vv += frm.but("REMOVE THIS APPLICANT",function(){ removeborrower() }).render(); vv += ""; } $("#repair-div").html(vv); $("#repair-div .xhuman").Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false, }); } } } let fetchDefaults = function(purchase_target, fn) { /** * do not overwrite defaults if this was an imported (rev webhook) loan */ if (MAR.appnav.loanWasImported()) { if (fn) fn(); return } // if (wehavebeenherebefore === "Y") return; let pp = num(purchase_target); let sqft = ~~(pp / 250); let condo = (ptype === "condo") ? "Y" : "N"; let sfr = (ptype === "sfr") ? "Y" : "N"; let $inp = $(`#body-container .x_panel`); $inp.LoadingOverlay("show"); let url = `/calc/home_owners_insurance?square_foot=${sqft}&build_period=1990&county=${county_code}&backend_lia_pm=800&condo=${condo}&close_to_or_on_water=N&sfr=${sfr}&in_community=${condo}&luxury_community=N&luxury_condo=N`; $.get(url, function(da){ $inp.LoadingOverlay("hide",true); oc_paused = true; var parsedData = da; let tax_py = ~~(pp * num(parsedData.outputs.prop_tax_percentage_pm)); txt("#scenario_tax",tax_py); $("#scenario_tax").change(); txt("#refi_home_insurance_cost",~~(num(parsedData.outputs.Home_Own_Ins_PM)*12)); $("#refi_home_insurance_cost").change(); txt("#hoa_estimate",num(parsedData.outputs.prop_hoa_result)); $("#hoa_estimate").change(); oc_paused = false; if (fn) fn(); // var fld_ins_pm = num(parsedData.outputs.fld_Ins_pm) // var prop_tax_percentage_pm = num(parsedData.outputs.prop_tax_percentage_pm); }); } let oc_paused = false; let oc_context = async function(skipReturn) { if (oc_paused) return; mar.tmp_context_saver.save(); } let oc = async function(skipReturn) { if (oc_paused) return; mar.tmp_context_saver.save(); var same = txt("#samelineofwork"); var stable = txt("#stableincome"); if (applicantnum == 0) { var enough = txt("#enoughincome"); } else { var enough = ""; } $("#repair-div").html(""); console.warn('ON CHANGE : '); console.warn('same : '+same+' stable : '+stable+' enough : '+enough); if (same.trim() != "") { let $sd = $("#stable-div"); if ($sd.is(':visible') == false) { setScenario_data("applicant"+applicantNum+"_samelineofwork",same); mar.fakesave(); setTimeout( function(){ $sd.slideDown(function(){ $("#body-container").scrollTo("max",200); }) }, 200); if(!skipReturn){ return; } } } if (applicantnum == 0) { if (stable.trim() != "") { if (loan_type !== "purchase") { let $sd = $("#refi-div"); $sd = $("#refi_current_value_div"); // changed it because we omitted the enough income for refi if ($sd.is(':visible') == false) { //$sd.removeClass('x-hide'); setScenario_data("applicant"+applicantNum+"_stableincome",stable); mar.fakesave(); setTimeout( function(){ $sd.slideDown(function(){ $("#body-container").scrollTo("max",200); }) }, 700); if(!skipReturn){ return; } } let refi_current_escrow = num(txt("#refi_current_escrow")); let refi_current_pmt = num(txt("#goals_target_budget_old")); let refi_back = refi_current_escrow + (2 * refi_current_pmt); $(".moneyback").html(elaineui.format("cur",refi_back)); $(".moneyback2").html(elaineui.format("cur",refi_back+2000)); if (await revealfields_refi(true) !== true) { if(!skipReturn){ return; } } } else { // let $sd = $("#enough-div"); // if ($sd.is(':visible') == false) { // setScenario_data("applicant"+applicantNum+"_stableincome",stable); // mar.fakesave(); // setTimeout( function(){ // $sd.slideDown(function(){ // $("#body-container").scrollTo("max",200); // }) // }, 700); // // if(!skipReturn){ // return; // } // } if (await revealfields_purchase(true) !== true) { if(!skipReturn){ return; } } } } //added to try and get reveals to work // if (loan_type !== "purchase") { // // } else { // if (enough.trim() != "") { // // var $sd = $("#enough-div"); // if ($sd.is(':visible') == false) { // $sd.removeClass('x-hide'); // setScenario_data("applicant"+applicantNum+"_enoughincome",enough); // mar.fakesave(); // setTimeout( function(){ // $sd.slideDown(function(){ // $("#body-container").scrollTo("max",200); // }) // }, 1200); // // $("#body-container").scrollTo("max",200); // // if (goals_target_budget_high_ref !== "Y") { // $("#budgetslider").removeClass("x-hide"); // $("#goals_target_budget_high").change() // // // // // } else { // // } // return; // } else { // // } // } else { // //$("#budgetslider").addClass("x-hide"); // } // } } else { /** * applicant 2 or higher */ $("#budgetslider").addClass("x-hide"); } let startapp = function(){ if (___r_id && typeof ___r_id === "string" && ___r_id.trim().length > 0) { $.get("/cfc/adminuserspublic/"+___r_id+"?fmt=explode",function(data) { let def_landingpage = data[0].def_landingpage; let url = `https://${def_landingpage}.${getParameterByName("url")}/`; document.location = url; }); } else { $.get("/cfc/adminuserspublic/"+loanofficer.id+"?fmt=explode",function(data) { let def_landingpage = data[0].code; let url = `https://${def_landingpage}.${getParameterByName("url")}/`; document.location = url; }); } } let removeborrower = function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "Are you sure?" swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "NO", call : { text: "YES", value: "call", closeModal: true } } }) .then((act) => { if (act == "call") { removeborrower2(); } }); } let removeborrower2 = function(){ if (applicantnum == 1) { setScenario_data("is_there_a_second_borrower","N"); if (mar.answers.v2.applicants.length > 1) { mar.answers.v2.applicants.pop(); } if (mar.answers.v2.declarations.length > 1) { mar.answers.v2.declarations.pop(); } setScenario_data("applicant"+applicantNum+"_samelineofwork",""); setScenario_data("applicant"+applicantNum+"_stableincome",""); setScenario_data("applicant"+applicantNum+"_enoughincome",""); setScenario_data("__scenario_housingbudget_"+applicantnum+"_passed","N"); setScenario_data("applicant2_name",""); mar.fakesave(function(){ mvc.go("#scenario-borrowers.0") }); } if (applicantnum == 2) { setScenario_data("is_there_a_third_borrower","N"); if (mar.answers.v2.applicants.length > 2) { mar.answers.v2.applicants.pop(); } if (mar.answers.v2.declarations.length > 2) { mar.answers.v2.declarations.pop(); } setScenario_data("applicant"+applicantNum+"_samelineofwork",""); setScenario_data("applicant"+applicantNum+"_stableincome",""); setScenario_data("applicant"+applicantNum+"_enoughincome",""); setScenario_data("__scenario_housingbudget_"+applicantnum+"_passed","N"); setScenario_data("applicant3_name",""); mar.fakesave(function(){ mvc.go("#scenario-borrowers.1") }); } } if (same == "N" || stable == "N") { oc_stable(); } else if (applicantnum == 0 && enough == "N") { if ($(".er1").length == 0) { let vv = ""; let warning_txt = `Rule of thumb is a maximum of about 40% of your joint income, as a budget for your house expenses. `+ `You have to consider your other payment obligations, dependents and lifestyle to determine if this maximum is responsible in your personal case.`; if (applicantnum == 0) { vv += frm.elaine(warning_txt,"er1").render(); vv += "
    "; vv += ""; } else { vv += frm.elaine(warning_txt,"er1").render(); vv += "
    "; vv += frm.h2("
    Tip: you can be an owner of a property on the title, without being on the loan.
    ").render(); vv += frm.but("REMOVE THIS APPLICANT",function(){ removeborrower() }).render(); vv += ""; } $("#repair-div").html(vv); $("#repair-div .xhuman").Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false, }); } } else if (applicantnum == 0 && enough == "Y") { if (goals_target_budget_high_ref !== "Y") { $("#budgetslider").removeClass("x-hide"); } } else if (applicantnum == 0 && enough == "N") { if (goals_target_budget_high_ref !== "Y") { $("#budgetslider").removeClass("x-hide"); } } else { $("#repair-div").html(""); } if (wehavebeenherebefore !== "Y") { $("#body-container").scrollTo("max",200); } elaineui.ifone(setScenario_data("applicant"+applicantNum+"_samelineofwork",same), setScenario_data("applicant"+applicantNum+"_stableincome",stable), setScenario_data("applicant"+applicantNum+"_enoughincome",enough), function() { mar.fakesave(); }) if (applicantnum == 0 && loan_type === "purchase") { let hb_liquid_assets = txt("#hb_liquid_assets"); let purchase_target = txt("#purchase_target"); let est_costs = ~~(purchase_target * 0.015) + 2000; /* 1.5% plus $2000 */ if (purchase_target !== "") { let _h = ``; let _0 = ~~((num(purchase_target) *0.0)+est_costs); let _5 = ~~((num(purchase_target) *0.05)+est_costs); let _3 = ~~((num(purchase_target) *0.03)+est_costs); let _35 = ~~((num(purchase_target) *0.035)+est_costs); let _10 = ~~((num(purchase_target) *0.1)+est_costs); let _20 = ~~((num(purchase_target) *0.2)+est_costs); _h += `
    Estimates:
    `; _h += `
  • 0% - ${elaineui.format("cur",_0)}
  • `; _h += `
  • 3% - ${elaineui.format("cur",_3)}
  • `; _h += `
  • 3.5% - ${elaineui.format("cur",_35)}
  • `; _h += `
  • 5% - ${elaineui.format("cur",_5)}
  • `; _h += `
  • 10% - ${elaineui.format("cur",_10)}
  • `; _h += `
  • 20% - ${elaineui.format("cur",_20)}
  • `; $(`#hb_liquid_assets_div .warning_liquid_assets_div`).html(_h); } if (purchase_target !== "" && hb_liquid_assets !== "") { // hat estimates (x%) down take off 1.5% + $2000 purchase_target = num(purchase_target); hb_liquid_assets = num(hb_liquid_assets); let est_costs = ~~(purchase_target * 0.015) + 2000; /* 1.5% plus $2000 */ let perc = 0; if (hb_liquid_assets > est_costs) { let downpay_cur = (hb_liquid_assets - est_costs); perc = ~~((num(downpay_cur) / num(purchase_target))*10000)/100; } if (perc > 0) { $("#hb_liquid_assets_div .cfc_label_title_multiple").html(`Est ${elaineui.format("perc0",~~(perc))} down`); } else { $("#hb_liquid_assets_div .cfc_label_title_multiple").html(""); } } else { $("#hb_liquid_assets_div .cfc_label_title_multiple").html(""); } } if (applicantnum == 0 && loan_type === "purchase") { let scenario_tax = txt("#scenario_tax"); let purchase_target = txt("#purchase_target"); if (purchase_target !== "" && scenario_tax !== "") { let perc = ~~((num(scenario_tax) / num(purchase_target))*10000)/100; $("#scenario_tax_div .cfc_label_title_multiple").html(`Annualy : ${elaineui.format("perc3",perc)}`); } else { $("#scenario_tax_div .cfc_label_title_multiple").html(""); } } } let pop1 = false; let or = function(){ let sp = mar.isallowed_scenario("#scenario-housingbudget."+applicantnum); if (typeof sp === "string") { mvc.go(sp); return; } $(".dr-button.next-button").addClass("_synch_once"); $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container ._percentage").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 1, autoGroup: true, prefix: '', //No Space, this will truncate the first character suffix: "%", rightAlign: false, autoUnmask : true }); $("#body-container ._percentage").prop("type","text"); $("#body-container ._percentage3").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 3, autoGroup: true, prefix: '', //No Space, this will truncate the first character suffix: "%", rightAlign: false, autoUnmask : true }); $("#body-container ._percentage3").prop("type","text"); let ac_fn = function(txt, cb) { let q = txt.term; console.warn(q, txt); if (q.length > 2) { let Q = q.toUpperCase(); let rv = mar.counties.filter(function(a){ return a.indexOf(Q) > -1 }); console.warn(rv); cb(rv); return; } //mar.counties cb([]); } if ($("#body-container .county-lookup").length > 0) { $("#body-container .county-lookup").autocomplete({ minLength : 0, appendTo : "#body-container .x_content", source : ac_fn, change: function(event, ui) { if (ui.item == null) { $("#body-container .county-lookup").val(""); $("#body-container .county-lookup").focus(); } } }).bind('focus', function(){ if (txt("#body-container .county-lookup").trim().length == 0) { $(this).autocomplete("search"); } }); } oc_paused = true; mar.tmp_context_saver.load(); oc_paused = false; $("#body-container .xhuman").Humanize({ opts : { fn : function() { $("#body-container .xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $(".info-same").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ "If you work as a car mechanic, and you switch jobs to be a car mechanic somewhere else, you are in the same line of work."+ "
    "+ "
    "+ "If you are an accountant for a car shop, and you switch to be an accountant in a hospital, you are still in the same line of work. "+ "
    "+ "
    "+ "If you however are an accountant in a hospital, and you become a car mechanic in a car shop, you are no longer in the same line of work."+ "
    "+ "
    "+ "Students studying for their current profession prior to their employment are considered in the same line of work." swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); }); $(".info-stable").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "" + // "Stable Income Examples
    >" + "Declining income is not considered stable.

    "+ "Changing jobs frequently is not considered stable.

    "+ "Self-employed income is not considered stable unless you can prove with two years tax returns that you have made the same or increasing profit.

    "+ //"If this applies to you, you may not qualify according to most lenders guidelines. Your loan officer can help out, just dail the number! "; "If this applies to you, the type of loan we offer you may be different from the standard Conventional / FHA guidelines.

    " + //", you may not qualify according to most lenders guidelines. "+ "Your loan officer "+loanofficer.name+" with "+loanofficer.telF+" can help out, just dial the number! "+ ""; swal({ className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); }); pop1 = function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "" + "
    " + $("#budget_popup").html() + "Estimated maximum housing budget per month " + "
    1500
    "+ "Don't worry, if you are not sure, just complete the application and let your loan officer figure it out! Call "+loanofficer.telF+" to reach "+loanofficer.name+" anytime!
    " + "
    " + ""; swal({ className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); $(".middleInfoPopup ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#estBdgPMonth ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $('.budget_popup .miniInput').on('input', function(){ console.log('#budget_popup input'); }); }; $(".info-enough").click(pop1); oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); //mar.pg["scenario-housingbudget"] = (function(){ // return { // stub : true // } //})(); mar.tmp_editliabilities_block = (function(){ let type = "est"; let maxlines = 20; function gettotals() { let rv = { pmt_total : 0, pmt_exmort : 0, bal_total : 0, bal_payoff : 0, bal_payoff_oc : 0 /* out side of closing */ }; if (type === "ans") { for (let j=4; j < 10; j++) { $(`#custom_Other_${j}_lbl`).val(``); $(`#custom_Other_${j}_val`).val(``); } let j = 4; let _beliabilities = getBackEndLiabilities_v2(); let list = _beliabilities.detailmatrix; let pay_amount_before = 0; for (let i=1; i < (list.length -1); i++) { let item = list[i]; let idx = item[15]; let name = item[0]; let pmt = num(item[3]); let bal = num(item[2]); let act = txt(`.adj-liab-div #r${i}_act`); if (typeof act === "string" && act.startsWith("payoff")) { if (act === "payoff" || act === "payoff_before") { rv.bal_payoff += bal; $(`#custom_Other_${j}_lbl`).val(`Pay Off liability #${i+1} ${name}`); $(`#custom_Other_${j}_val`).val(bal); j++; } else { pay_amount_before += MAR.getOptNum(item, "bal", 0) } continue; } if (typeof act === "string" && act.startsWith("omit")) { continue; } rv.pmt_total += pmt; if (!name.startsWith("mortg")) { rv.pmt_exmort += pmt; } rv.bal_total += bal; } } if (type === "est") { let grid = getScenario_data(`liability_manual_grid`, []); if (typeof grid === "string") { grid = JSON.parse(grid); } for (let j=4; j < 10; j++) { $(`#custom_Other_${j}_lbl`).val(``); $(`#custom_Other_${j}_val`).val(``); } let j = 4; let pay_amount_before = 0; for (let i=0; i < grid.length; i++) { let item = grid[i]; let act = MAR.getOpt(item, "act", ""); let bal = MAR.getOptNum(item, "bal", 0); if (typeof act === "string" && act.startsWith("payoff")) { if (act === "payoff" || act === "payoff_before") { rv.bal_payoff += bal $(`#custom_Other_${j}_lbl`).val(`Pay Off liability #${i+1} ${item.type}`); $(`#custom_Other_${j}_val`).val(bal); j++; } else { if (act.endsWith("before")) { rv.bal_payoff_oc += bal; } } continue; } if (typeof act === "string" && act.startsWith("omit")) { if (act.endsWith("less10pmts")) { rv.bal_payoff_oc += bal; } if (act.endsWith("down-to-omit")) { rv.bal_payoff_oc += bal; } if (act.endsWith("before")) { rv.bal_payoff_oc += bal; } if (act.endsWith("and-cancel")) { rv.bal_payoff_oc += bal; } if (act.endsWith("andclose")) { rv.bal_payoff_oc += bal; } continue; } rv.pmt_total += MAR.getOptNum(item, "pmt", 0); if (MAR.getOpt(item, "type", "") !== "mortgage") { rv.pmt_exmort += MAR.getOptNum(item, "pmt", 0); } rv.bal_total += MAR.getOptNum(item, "bal", 0); } } return rv; } function clean_array(grid) { grid.sort(function(a,b){ return (MAR.getOpt(a, "type","").length === 0) ? 1 : -1; }); } function populate() { if (type === "ans") { let _beliabilities = getBackEndLiabilities_v2(); let list = _beliabilities.detailmatrix; for (let i=1; i < (list.length -1); i++) { let item = list[i]; let idx = item[15]; let itm = mar.answers.v2.liabilities[idx]; let _omit = MAR.getOpt(itm, "omit",""); let _omit_opt = MAR.getOpt(itm, "omit_opt",""); if (item[11] === "OMIT") { txt(`.adj-liab-div #r${i}_act`, "omit"); if (_omit_opt === "notpaying") { txt(`.adj-liab-div #r${i}_act`, "omit_notpaying"); } if (_omit_opt === "less10pmts") { txt(`.adj-liab-div #r${i}_act`, "omit_less10pmts"); } if (_omit_opt === "down-to-omit") { txt(`.adj-liab-div #r${i}_act`, "payoff_down-to-omit"); } if (_omit_opt === "before") { txt(`.adj-liab-div #r${i}_act`, "payoff_before"); } if (_omit_opt === "and-cancel") { txt(`.adj-liab-div #r${i}_act`, "payoff_and-cancel"); } if (_omit_opt === "andclose") { txt(`.adj-liab-div #r${i}_act`, "payoff_andclose"); } } else if (item[11] === "payoff") { txt(`.adj-liab-div #r${i}_act`, "payoff"); if (_omit_opt === "andclose") { txt(`.adj-liab-div #r${i}_act`, "payoff_andclose"); } } else { txt(`.adj-liab-div #r${i}_act`, ""); } if (MAR.getOpt(itm, "paytype", "") === "def") { txt(`.adj-liab-div #r${i}_act`, "stu_5pc"); } } } if (type === "est") { let grid = getScenario_data(`liability_manual_grid`, []); if (typeof grid === "string") { grid = JSON.parse(grid); } clean_array(grid); let firstempty = false; for (let i=0; i < maxlines; i++) { if (grid.length <= i) { $(`.adj-liab-div .r${i}_row`).addClass(`x-hide-imp`); continue; } if ($(`.adj-liab-div #r${i}_type`).length == 0) { $(`.adj-liab-div .r${i}_row`).addClass(`x-hide-imp`); continue; } let item = grid[i]; txt(`.adj-liab-div #r${i}_type`, MAR.getOpt(item, `type`, ``)); txt(`.adj-liab-div #r${i}_bal`, MAR.getOpt(item, `bal`, ``)); txt(`.adj-liab-div #r${i}_pmt`, MAR.getOpt(item, `pmt`, ``)); txt(`.adj-liab-div #r${i}_act`, MAR.getOpt(item, `act`, ``)); if (MAR.getOpt(item, `type`, ``).length === 0) { $(`.adj-liab-div .r${i}_row`).addClass(`x-hide-imp`); } else { $(`.adj-liab-div .r${i}_row`).removeClass(`x-hide-imp`); } onchange(i); } add(); } if (type === "ans") { } } function del(n) { if (type === "est") { txt(`.adj-liab-div #r${n}_type`,``); txt(`.adj-liab-div #r${n}_pmt`,``); txt(`.adj-liab-div #r${n}_bal`,``); txt(`.adj-liab-div #r${n}_act`,``); mar.tmp_editliabilities_block.read(); let lia = mar.tmp_editliabilities_block.gettotals(); setScenario_data("rough_liabilities",lia.pmt_exmort); setScenario_data("rough_liabilities_po",lia.bal_payoff); setScenario_data("rough_liabilities_pooc",lia.bal_payoff_oc); mar.fakesave(function(){ mar.tmp_editliabilities_block.populate(); }) } } function add() { if (type === "est") { for (let i=0; i < maxlines; i++) { let row = $(`.adj-liab-div .r${i}_row`); if (row.hasClass(`x-hide-imp`)) { row.removeClass(`x-hide-imp`); return; } } } } function onchange(n) { let typ = txt(`.adj-liab-div #r${n}_type`); let pmt = txt(`.adj-liab-div #r${n}_pmt`); let bal = txt(`.adj-liab-div #r${n}_bal`); let act = txt(`.adj-liab-div #r${n}_act`); let value = elaineui.format("cur",num(pmt)); if (act === "stu_5pc") { value = num(bal)*0.005; value = elaineui.format("cur",value); } if (typeof act === "string" && act.startsWith("omit")) { value = elaineui.format("cur",0); } if (typeof act === "string" && act.startsWith("payo")) { value = elaineui.format("cur",0); } if (typ === "") { value = ``; } if (typ === "mortgage") { value = ``; } if (typ === "heloc") { value = ``; } $(`.body-lia #r${n}_val`).html(value); } function block(obj = {}) { let editable = MAR.getOpt(obj, "editable",false); let i = obj.i; let och = `onchange='mar.tmp_editliabilities_block.onchange(${i})'`; let dispval = function(fld) { return elaineui.format("cur",MAR.getOpt(obj,fld,""))+`` } let type = (!editable) ? MAR.getOpt(obj,"type","")+`` : ``; let name = MAR.getOpt(obj, "name", ""); let pmt = (!editable) ? dispval("pmt") : `$`; let bal = (!editable) ? dispval("bal") : `$`; let act = ``; let hide = (!editable) ? "" : "x-hide-imp"; let val = ``; let valhid = ``; // if (!editable && MAR.getOpt(obj,"can_payoff","") === "N") { if (!editable && MAR.getOpt(obj,"type","") === "child") { act = `${MAR.getOpt(obj,"act","")}`; } else if (!editable && MAR.getOpt(obj,"type","") === "alimony") { act = `${MAR.getOpt(obj,"act","")}`; } else if (!editable && MAR.getOpt(obj,"type","") === "carlease") { act = ``; } else if (!editable && MAR.getOpt(obj,"type","") === "studentloan") { act = ``; } else if (!editable) { act = ``; } if (editable) { if (MAR.getOpt(obj,"type","") === "child") { act = `${MAR.getOpt(obj,"act","")}`; } else if (MAR.getOpt(obj,"type","") === "alimony") { act = `${MAR.getOpt(obj,"act","")}`; } else if (MAR.getOpt(obj,"type","") === "carlease") { act = ``; } else if (MAR.getOpt(obj,"type","") === "studentloan") { act = ``; } else { act = ``; } } let h = ``; h += `
    `+ `
    `+ `
    `+ `
    delete
    `+ `
    `; h += `
    `+ `
    Type
    `+ `
    ${type}
    `+ `
    `+ `
    `; if (name !== "") { h += `
    `+ `
    Name
    `+ `
    ${name}
    `+ `
     
    `+ `
    `; } h += `
    `+ `
    Min Pmt.
    `+ `
    ${pmt}
    `+ `
     
    `+ `
    `; mar.tmp_rq_topgrid_warning(null); if (MAR.getOpt(obj,"type","") === "mortgage" || MAR.getOpt(obj,"type","") === "heloc") { let _h = `
    `+ `
    Balance
    `+ `
    ${bal}
    `+ `
     
    `+ `
    `; let is_attached = (function() { let item = MAR.liabilities.get("",obj.idx); if (MAR.getOpt(item,"reolink","") === "") { if (MAR.getOpt(item, "attached_llc", "") === "Y") return 1 return -1 } return 0; })(); if (is_attached > -1) { return ""; h += `
    `+ `
    `+ `Mortgages and HELOCs are counted in with REO income to come up with an overall liability or asset score for all properties.`+ `
    `+ `
    `+ `Full details are in the REO section`+ `
    `+ `
     
    `+ `
    `; } if (is_attached === -1) { h += _h; h += `
    `+ `
    `+ `Mortgages and HELOCs are counted in with REO income to come up with an overall liability or asset score for all properties.`+ `
    `+ `
    `+ `*** this is NOT connected ***`+ `
    `+ `
    `+ `Attach in REO section`+ `
    `+ `
     
    `+ `
    `; mar.tmp_rq_topgrid_warning(`A mortgage or HELOC is not connected to any property!`, "red"); } h += ``; h += valhid; } else if (MAR.getOpt(obj,"type","") === "liabilities from REO") { h += `
    `+ `
    `+ `This is the result of caombining the income and costs including mortgages and HELOCs for all the REO properties.`+ `Full details are in the REO section`+ `
    `+ `
     
    `+ `
    `; h += ``; h += valhid; } else { h += `
    `+ `
    Balance
    `+ `
    ${bal}
    `+ `
     
    `+ `
    `; h += `
    `+ `
    Action
    `+ `
    ${act}
    `+ `
     
    `+ `
    `; h += `
    `+ `
    Min Pmt Used
    `+ `
    ${val}
    `+ `
     
    `+ `
    `; } if (MAR.getOpt(obj, "signer","") === "coborrower") { h += `
    `+ `
    `+ `*** Liability paid by someone else ***`+ `
    `+ `
     
    `+ `
    `; } h = `
    ${h}
    `; h += ``; return h; } function render(){ let h = ``; if (type === "ans") { let _beliabilities = getBackEndLiabilities_v2(); let list = _beliabilities.detailmatrix; for (let i=1; i < (list.length -1); i++) { let item = list[i]; h += block({ i : i, editable : false, type : item[0].split(`:`)[0], name : MAR.getOpt(item[0].split(`:`),"1",""), pmt : item[3], bal : item[2], act : item[11], can_payoff : item[14], signer : item[16], idx : MAR.getOpt(item,"15",-1) }); } h = `
    src: from app data
    ${h}`+ `
    `; } if (type === "est") { for (let i=0; i < maxlines; i++) { h += block({ i : i, editable : true }); } h = `
    ${h}`+ `ADD ANOTHER`+ `
    `; } return h; } function read() { if (type === "ans") { let _beliabilities = getBackEndLiabilities_v2(); let list = _beliabilities.detailmatrix; let changed = false; for (let i=1; i < (list.length -1); i++) { let item = list[i]; if (item.length < 16) continue; let idx = item[15]; let itm = mar.answers.v2.liabilities[idx]; let act = txt(`.adj-liab-div #r${i}_act`); if (act === "omit" && item[11] !== "OMIT") { mar.answers.v2.liabilities[idx].omit = "Y"; mar.answers.v2.liabilities[idx].omit_opt = ""; mar.answers.v2.liabilities[idx].payoff = false; changed = true; } if (act === "payoff" && item[11] !== "payoff") { mar.answers.v2.liabilities[idx].omit = "N"; mar.answers.v2.liabilities[idx].omit_opt = ""; mar.answers.v2.liabilities[idx].payoff = true; changed = true; } if (act === "omit_less10pmts") { let _omit = MAR.getOpt(itm, "omit",""); let _omit_opt = MAR.getOpt(itm, "omit_opt",""); if (_omit !== "Y" || _omit_opt !== "less10pmts") { mar.answers.v2.liabilities[idx].omit = "Y"; mar.answers.v2.liabilities[idx].omit_opt = "less10pmts"; mar.answers.v2.liabilities[idx].payoff = false; changed = true; } } if (act === "omit_notpaying") { let _omit = MAR.getOpt(itm, "omit",""); let _omit_opt = MAR.getOpt(itm, "omit_opt",""); if (_omit !== "Y" || _omit_opt !== "notpaying") { mar.answers.v2.liabilities[idx].omit = "Y"; mar.answers.v2.liabilities[idx].omit_opt = "notpaying"; mar.answers.v2.liabilities[idx].payoff = false; changed = true; } } if (act === "payoff_before") { let _omit = MAR.getOpt(itm, "omit",""); let _omit_opt = MAR.getOpt(itm, "omit_opt",""); if (_omit !== "Y" || _omit_opt !== "before") { mar.answers.v2.liabilities[idx].omit = "Y"; mar.answers.v2.liabilities[idx].omit_opt = "before"; mar.answers.v2.liabilities[idx].payoff = false; changed = true; } } if (act === "payoff_andclose") { let _omit = MAR.getOpt(itm, "omit",""); let _omit_opt = MAR.getOpt(itm, "omit_opt",""); if (_omit !== "Y" || _omit_opt !== "before") { mar.answers.v2.liabilities[idx].omit = "N"; mar.answers.v2.liabilities[idx].omit_opt = "andclose"; mar.answers.v2.liabilities[idx].payoff = true; changed = true; } } if (act === "payoff_and-cancel") { let _omit = MAR.getOpt(itm, "omit",""); let _omit_opt = MAR.getOpt(itm, "omit_opt",""); if (_omit !== "Y" || _omit_opt !== "and-cancel") { mar.answers.v2.liabilities[idx].omit = "Y"; mar.answers.v2.liabilities[idx].omit_opt = "and-cancel"; mar.answers.v2.liabilities[idx].payoff = false; changed = true; } } if (act === "payoff_down-to-omit") { let _omit = MAR.getOpt(itm, "omit",""); let _omit_opt = MAR.getOpt(itm, "omit_opt",""); if (_omit !== "Y" || _omit_opt !== "down-to-omit") { mar.answers.v2.liabilities[idx].omit = "Y"; mar.answers.v2.liabilities[idx].omit_opt = "down-to-omit"; mar.answers.v2.liabilities[idx].payoff = false; changed = true; } } if (act === "" && item[11] !== "keep") { mar.answers.v2.liabilities[idx].omit = "N"; mar.answers.v2.liabilities[idx].omit_opt = ""; mar.answers.v2.liabilities[idx].payoff = false; changed = true; } if (act === "" && MAR.getOpt(itm, "paytype","") !== "") { mar.answers.v2.liabilities[idx].paytype = ""; changed = true; } if (act === "stu_5pc" && MAR.getOpt(itm, "paytype","") !== "def") { mar.answers.v2.liabilities[idx].paytype = "def"; mar.answers.v2.liabilities[idx].omit = "N"; mar.answers.v2.liabilities[idx].omit_opt = ""; mar.answers.v2.liabilities[idx].payoff = false; changed = true; } } if (changed === true) { mar.tmp_loiar_toggle_changed = 1; } } if (type === "est") { let rv = []; for (let i=0; i < maxlines; i++) { if ($(`.adj-liab-div #r${i}_type`).length > 0) { rv.push({ type : txt(`.adj-liab-div #r${i}_type`), bal : txt(`.adj-liab-div #r${i}_bal`), pmt : txt(`.adj-liab-div #r${i}_pmt`), act : txt(`.adj-liab-div #r${i}_act`), live : true }); } else { rv.push({ type : '', live : false }); } } clean_array(rv); setScenario_data(`liability_manual_grid` , JSON.stringify(rv)); return rv; } return false; } function get_type() { return type; } function set_type(S) { if (S === "answers") { type = `ans`; type = `est`; } else if (S === "calculated") { type = `calc`; type = `ans`; } else { type = `est`; } } return { set_type : set_type, get_type : get_type, render : render, del : del, populate : populate, onchange : onchange, read : read, add : add, gettotals : gettotals, ___id : "liab block" } })(); mar.tmp_editincome_block = (function(){ let type = "est"; let maxlines = 20; function gettotals() { let rv = { type : type, total : 0 }; if (type === "est") { let grid = getScenario_data(`income_manual_grid`, []); if (typeof grid === "string") { grid = JSON.parse(grid); } for (let i=0; i < grid.length; i++) { let item = grid[i]; let b = MAR.getOpt(item, "b", ""); let name = MAR.getOpt(item, "name", ""); let total = MAR.getOpt(item, "total", 0); if (b === "") { continue; } rv.total += num(total); } } return rv; } function clean_array(grid) { grid.sort(function(a,b){ return (MAR.getOpt(a, "b","").length === 0) ? 1 : -1; }); } function recalc() { read(); let gt = gettotals(); $(`.hdr-inc .val`).html(elaineui.format("cur_flx",gt.total)); $(`.hdr-inc .val`).html(elaineui.format("cur",gt.total,"--.--")); } function populate() { if (type === "est") { let grid = getScenario_data(`income_manual_grid`, []); if (typeof grid === "string") { grid = JSON.parse(grid); } clean_array(grid); for (let i=0; i < maxlines; i++) { if (grid.length <= i) { $(`.adj-inc-div .r${i}_row`).addClass(`x-hide-imp`); continue; } if ($(`.adj-inc-div #r${i}_b`).length == 0) { $(`.adj-inc-div .r${i}_row`).addClass(`x-hide-imp`); continue; } let item = grid[i]; txt(`.adj-inc-div #r${i}_b`, MAR.getOpt(item, `b`, ``)); txt(`.adj-inc-div #r${i}_name`, MAR.getOpt(item, `name`, ``)); txt(`.adj-inc-div #r${i}_total`, MAR.getOpt(item, `total`, ``)); if (MAR.getOpt(item, `b`, ``).length === 0) { $(`.adj-inc-div .r${i}_row`).addClass(`x-hide-imp`); } else { $(`.adj-inc-div .r${i}_row`).removeClass(`x-hide-imp`); } } add(); } } function add() { if (type === "est") { for (let i=0; i < maxlines; i++) { let row = $(`.adj-inc-div .r${i}_row`); if (row.hasClass(`x-hide-imp`)) { row.removeClass(`x-hide-imp`); return; } } } } function block(obj = {}) { let editable = MAR.getOpt(obj, "editable",false); let i = obj.i; let b = (!editable) ? MAR.getOpt(obj,"b","") : ``; let name = (!editable) ? MAR.getOpt(obj,"name","") : ``; let total = (!editable) ? MAR.getOpt(obj,"total","") : `$`; let h = ``; h += `
    `+ `
    Borrower
    `+ `
    ${b}
    `+ `
     
    `+ `
    `; h += `
    `+ `
    Job name
    `+ `
    ${name}
    `+ `
     
    `+ `
    `; h += `
    `+ `
    Monthly
    `+ `
    ${total}
    `+ `
     
    `+ `
    `; h = `
    ${h}
    `; return h; } function render(){ let h = ``; if (type === "est") { for (let i=0; i < maxlines; i++) { h += block({ i : i, editable : true }); } h = `
    ${h}`+ `ADD ANOTHER`+ `
    `; } return h; } function read() { if (type === "est") { let rv = []; for (let i=0; i < maxlines; i++) { if ($(`.adj-inc-div #r${i}_b`).length > 0) { rv.push({ b : txt(`.adj-inc-div #r${i}_b`), name : txt(`.adj-inc-div #r${i}_name`), total : txt(`.adj-inc-div #r${i}_total`), live : true }); let ob = rv[rv.length-1]; if (ob.b === ``|| ob.b === null || ob.total === ``|| ob.total === null) { ob.b = ``; ob.name = ``; ob.total = ``; } } else { rv.push({ b : '', live : false }); } } clean_array(rv); setScenario_data(`income_manual_grid` , JSON.stringify(rv)); return rv; } return false; } function set_type(S) { if (S === "calculated") { type = `calc` } else { type = `est`; } } return { set_type : set_type, render : render, populate : populate, read : read, recalc : recalc, add : add, gettotals : gettotals, ___id : "income block" } })(); mar.tmp_editreo_block = (function(){ let type = "est"; let maxlines = 20; let options = { nn : `No, New landlord`, nb : `No, Bad experience`, y1 : `Yes, On last taxes`, y2 : `Yes, over 2 years` }; function calc(pmt, inc, opt) { let prog_sel = txt("#rq_prog_sel"); console.error(`lia ${mar.tmp_off.prog} / ${prog_sel} `) let _inc = inc; let _txt = ``; if (num(inc) > 0) { _txt = `All income used`; } if (opt === ``) { _inc = 0; _txt = ``; } if (opt === `nn`) { _inc = num(inc)*0.75; if (num(inc) > 0) { _txt = `75% income used`; } } if (opt === `nb`) { _inc = num(inc)*0.75; if (num(inc) > 0) { _txt = `75% income used`; } } if (opt !== `y2` && mar.tmp_off.prog === `va`) { _inc = 0; if (num(inc) > 0) { _txt = `To use income VA requires 2 years of tax`; } } if (opt !== `y2` && mar.tmp_off.prog === `fha`) { _inc = 0; if (num(inc) > 0) { _txt = `To use income FHA requires 2 years of tax`; } } let net = ~~(_inc - num(pmt)); if (opt === `nn` && net > 0) { net = 0; txt = `Total income is capped at the value of he costs`; } return { net : net, txt : _txt, asslib : (net < 0) ? "liability" : "asset" } } function gettotals() { let rv = { type : type, total : 0 }; if (type === "est") { let grid = getScenario_data(`reo_manual_grid`, []); if (typeof grid === "string") { grid = JSON.parse(grid); } for (let i=0; i < grid.length; i++) { let item = grid[i]; let addr = MAR.getOpt(item, "addr", ""); let pmt = MAR.getOpt(item, "pmt", 0); let inc = MAR.getOpt(item, "inc", 0); let opt = MAR.getOpt(item, "opt", ``); let c = calc(pmt, inc, opt); let net = c.net; let asslib = c.asslib; if (addr === "") { continue; } rv.total += net; } } return rv; } function clean_array(grid) { grid.sort(function(a,b){ return (MAR.getOpt(a, "addr","").length === 0) ? 1 : -1; }); } function populate() { if (type === "est") { let grid = getScenario_data(`reo_manual_grid`, []); if (typeof grid === "string") { grid = JSON.parse(grid); } clean_array(grid); for (let i=0; i < maxlines; i++) { if (grid.length <= i) { $(`.adj-reo-div .r${i}_row`).addClass(`x-hide-imp`); continue; } if ($(`.adj-reo-div #r${i}_addr`).length == 0) { $(`.adj-reo-div .r${i}_row`).addClass(`x-hide-imp`); continue; } let item = grid[i]; txt(`.adj-reo-div #r${i}_addr` , MAR.getOpt(item, `addr`, ``)); txt(`.adj-reo-div #r${i}_pmt` , MAR.getOpt(item, `pmt`, ``)); txt(`.adj-reo-div #r${i}_inc` , MAR.getOpt(item, `inc`, ``)); txt(`.adj-reo-div #r${i}_opt` , MAR.getOpt(item, `opt`, ``)); txt(`.adj-reo-div #r${i}_opt1` , MAR.getOpt(item, `opt1`, `n`)); let c = calc(MAR.getOpt(item, `pmt`, 0), MAR.getOpt(item, `inc`, 0), MAR.getOpt(item, `opt`, ``)); txt(`.adj-reo-div #r${i}_net` , c.net); txt(`.adj-reo-div #r${i}_asslib`, c.asslib); txt(`.adj-reo-div #r${i}_txt` , c.txt); if (MAR.getOpt(item, `addr`, ``).length === 0) { $(`.adj-reo-div .r${i}_row`).addClass(`x-hide-imp`); } else { $(`.adj-reo-div .r${i}_row`).removeClass(`x-hide-imp`); } } add(); } } function hide_show_phe() { if ($(`.rq_phe_wrap`).hasClass(`x-hide-imp`) || is_there_an_est_primary()) { let peh = $(`#prim__eh`); let row = $(`.prim__eh_div`); peh.val(``); row.addClass(`x-hide-imp`); } else { let peh = $(`#prim__eh`); let row = $(`.prim__eh_div`); let val = $(`#rq_phe`).val(); peh.val(val); row.removeClass(`x-hide-imp`); } } function add() { if (type === "est") { for (let i=0; i < maxlines; i++) { let row = $(`.adj-reo-div .r${i}_row`); if (row.hasClass(`x-hide-imp`)) { row.removeClass(`x-hide-imp`); return; } } } } function block(obj = {}) { let editable = MAR.getOpt(obj, "editable",false); let i = obj.i; let addr = (!editable) ? MAR.getOpt(obj,"addr","") : ``; let opt = (!editable) ? MAR.getOpt(obj,"opt","") : ``; let opt1 = (!editable) ? MAR.getOpt(obj,"opt1","") : ``; let typ = (!editable) ? MAR.getOpt(obj,"typ","") : ``; let pmt = (!editable) ? MAR.getOpt(obj,"pmt","") : `$`; let inc = (!editable) ? MAR.getOpt(obj,"inc","") : `$`; let net = (!editable) ? MAR.getOpt(obj,"net","") : `$`; let asslib = (!editable) ? MAR.getOpt(obj,"asslib","") : ``; let txtfld = (!editable) ? MAR.getOpt(obj,"txt","") : ``; let h = ``; h += `
    `+ `
     Address Hint
    `+ `
    ${addr}
    `+ `
     
    `+ `
    `; // h += `
    `+ // `
     Is Primary
    `+ // `
    ${typ}
    `+ // `
     
    `+ // `
    `; h += `
    `+ `
     PMT PITIH
    `+ `
    ${pmt}
    `+ `
     
    `+ `
    `; h += `
    `+ `
     Rental inc.
    `+ `
    ${inc}
    `+ `
     
    `+ `
    `; h += `
    `+ `
     On Taxes
    `+ `
    ${opt}
    `+ `
     
    `+ `
    `; h += `
    `+ `
     Is Primary
    `+ `
    ${opt1}
    `+ `
     
    `+ `
    `; h += `
    `+ `
    ${asslib}
    `+ `
    ${net}
    `+ `
     
    `+ `
    `; h += `
    `+ `
    ${txtfld}
    `+ `
     
    `+ `
    `; h = `
    ${h}
    `; return h; } let lin_indent = function(c1,c2,c3) { return `
    `+ // `
     ${c1}
    `+ `
    ${c1}
    `+ `
    ${c2}
    `+ `
    `; } let lin_num = function(val) { let fval = elaineui.format(`cur_nodollar`,val); let rval = `$${fval}`; return rval; } let lin_editable_elm = function(id,val) { return `
    ${lin_num(val)}
    `; } function get_phe_field(){ let fld = `
    $
    `; return lin_indent(`Primary housing Espenses`,fld,`prim__eh_div`); } function change_phe_field(){ let val = $(`#prim__eh`).val(); $(`#rq_phe`).val(val); $(`#rq_phe`).change(); } function render(){ let h = ``; if (type === "est") { h += get_phe_field(); for (let i=0; i < maxlines; i++) { h += block({ i : i, editable : true }); } h = `
    ${h}`+ `ADD ANOTHER`+ `
    `; } return h; } function recalc(i) { let inc = txt(`.adj-reo-div #r${i}_inc`); let pmt = txt(`.adj-reo-div #r${i}_pmt`); let opt = txt(`.adj-reo-div #r${i}_opt`); let typ = txt(`.adj-reo-div #r${i}_typ`); if (num(inc) === 0) { $(`.adj-reo-div #r${i}_opt`).parent().parent().addClass(`x-hide-imp`); $(`.adj-reo-div #r${i}_opt`).val(``) } else { $(`.adj-reo-div #r${i}_opt`).parent().parent().removeClass(`x-hide-imp`); } let c = calc(pmt, inc, opt); txt(`.adj-reo-div #r${i}_net`, c.net); txt(`.adj-reo-div #r${i}_asslib`, c.asslib); txt(`.adj-reo-div #r${i}_txt` , c.txt); mar.tmp_editreo_block.hide_show_phe(); } function is_there_an_est_primary() { if (type === "est") { for (let i=0; i < maxlines; i++) { if (txt(`.adj-reo-div #r${i}_opt1`) === `y`) return true; } } return false; } function read() { if (type === "est") { let rv = []; for (let i=0; i < maxlines; i++) { if ($(`.adj-reo-div #r${i}_addr`).length > 0) { rv.push({ addr : txt(`.adj-reo-div #r${i}_addr`), inc : txt(`.adj-reo-div #r${i}_inc`), pmt : txt(`.adj-reo-div #r${i}_pmt`), typ : txt(`.adj-reo-div #r${i}_typ`), opt : txt(`.adj-reo-div #r${i}_opt`), opt1 : txt(`.adj-reo-div #r${i}_opt1`), live : true }); let ob = rv[rv.length-1]; let c = calc(ob.pmt, ob.inc, ob.opt); ob.net = c.net; ob.addlib = c.asslib; if (ob.opt1 === 'y') { setScenario_data(`primary_housing_expenses` , ob.pmt); $(`#rq_phe`).val(ob.pmt); } } else { rv.push({ b : '', live : false }); } } clean_array(rv); setScenario_data(`reo_manual_grid` , JSON.stringify(rv)); return rv; } return false; } function set_type(S) { if (S === "calculated") { type = `calc` } else { type = `est`; } } return { set_type : set_type, render : render, populate : populate, read : read, recalc : recalc, change_phe_field : change_phe_field, hide_show_phe : hide_show_phe, get_phe_field : get_phe_field, add : add, gettotals : gettotals, ___id : "reo block" } })(); mar.tmp_editliabilities = function(page, version, off, recalculated) { let h = mar.tmp_editliabilities_block.render(); elaineui.swalprompt({ title : "Customize liabilities", txt : `
    ${h}
    `, ok : "Apply customizations", okfn : function() { mar.tmp_editliabilities_block.read(); let lia = mar.tmp_editliabilities_block.gettotals(); setScenario_data("rough_liabilities",lia.pmt_exmort); setScenario_data("rough_liabilities_po",lia.bal_payoff); setScenario_data("rough_liabilities_pooc",lia.bal_payoff_oc); mar.fakesave(function(){ mvc.go(location.hash); }); }, cancel : "Cancel", cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } }); elaineui.waitForElementToDisplay("div.ratequote_popup", 100, function(){ mar.tmp_editliabilities_block.populate(); }); } mar.pg_loi_adjust_quote = async function(page, version, off, recalculated) { /** * note - this is the link from the cog wheel ! */ mar.pg_loi_duplcate_and_adjust = function() { $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/99?from=${version}`, function(da){ let new_version = da.version; $.get(`/api/chatbot/setRqLock/${mar.ID}/${new_version}?val=N`, function(){ // $.get(`/api/chatbot/setRqVisibility/${mar.ID}/${new_version}?val=hidden`, function(){ if (swal && swal.close) swal.close(); mar.tmp_was_recalculated = `#${page}.${new_version}.E`; if (version === "0" || version === 0 || version === "") { $.get(`/api/chatbot/delSavedRate/${mar.ID}/0`, function(){ mvc.go(`#${page}.${new_version}`); }); } else { mvc.go(`#${page}.${new_version}`); } }); }); } let RS = MAR.getRatesheet().RS; let R = MAR.getRatesheet().R; let DA = mar.tmp_off_da; if (typeof version === "undefined") version = ""; if (typeof recalculated === "undefined") recalculated = false; if (version !== "" && version !== "0" && recalculated === false) { $.get(`/api/chatbot/setRqLock/${mar.ID}/${version}`, function(da_is_locked){ let is_locked = MAR.getOpt(da_is_locked, `locked`,''); let is_visible = MAR.getOpt(da_is_locked, `visibility`,''); mar.pg_loi_adjust_quote_params = [page, version, off, recalculated]; mar.pg_loi_unlock_before_editing = function(){ $(`.ratequote_popup`).html(`Unlocking Offer...`); setTimeout(function(){ $.get(`/api/chatbot/setRqLock/${mar.ID}/${version}?val=N`, function(){ $.get(`/api/chatbot/clearRateTracking/${mar.ID}/${version}`, function(){ if (swal && swal.close) swal.close(); mar.pg_loi_adjust_quote(page, version, off, true); }); }); },500); }; mar.pg_loi_duplicate_before_editing = function(){ $(`.ratequote_popup`).html(`Duplicating Loan...`); setTimeout(function(){ $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/99?from=${version}`, function(da){ let new_version = da.version; $.get(`/api/chatbot/setRqLock/${mar.ID}/${new_version}?val=N`, function(){ if (swal && swal.close) swal.close(); mar.tmp_was_recalculated = `#${page}.${new_version}.E`; if (version === "0" || version === 0 || version === "") { $.get(`/api/chatbot/delSavedRate/${mar.ID}/0`, function(){ mvc.go(`#${page}.${new_version}`); }); } else { mvc.go(`#${page}.${new_version}`); } }); }); },500); } let lock_text = ` or you can continue and edit the offer before locking and sending to the client.`; let ok_button = `Continue`; if (is_locked === `Y`) { // lock_text = ` or you can unlock the current offer and alter it before locking and sending to the client.`; lock_text = `This proposal was sent to the client, do you want to edit this proposal, or copy it into a new proposal?

    Note: Editing will take your proposal offline until you save and resend it to the client.`; ok_button = `Edit`; } else { mar.pg_loi_adjust_quote(page, version, off, true); return; } mar.pg_loi_continue_to_editing = function() { if (swal && swal.close) swal.close(); setTimeout(function(){ if (is_locked) { mar.pg_loi_unlock_before_editing(); } else { mar.pg_loi_adjust_quote(page, version, off, true); } },20) }; let swal_config = { title : "Customize loan", txt : `
    `+ // `You are about to customize this loan.

    If you client has already seen this offer then you can also make duplicate before starting,`+ lock_text + `

    `+ `
    `+ `
    `+ `Copy Loan`+ `Edit Loan`+ ``+ `
    `+ `

    `+ ``, cancel : "Cancel", cancelfn : function() { }, ok : false, //ok_button, okfn : function() { mar.pg_loi_continue_to_editing(); }, // if (swal && swal.close) swal.close(); // setTimeout(function(){ // if (is_locked) { // mar.pg_loi_unlock_before_editing(); // } else { // mar.pg_loi_adjust_quote(page, version, off, true); // } // },20) // }, cls : "midelinfopopupOneButton", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } } if (MAR.getOpt(mar.tmp_trackdata, "opened", "") !== "") { swal_config.txt = ``+ ``+ `
    `+ `The loan has been viewed by the client. You can either make a copy , or unlock it to make adjustments to this version. `+ `Would you like to make a copy of this loan and then make adjustments to it?` + `

    Duplicate Loan

    `, `
    `; swal_config.cancel = "cancel"; swal_config.cancelfn = function(){ swal.close(); } // swal_config.ok = "duplicate"; swal_config.ok = "UnLock"; swal_config.okfn = function() { mar.pg_loi_unlock_before_editing(); // mar.pg_loi_duplicate_before_editing(); } } elaineui.swalprompt(swal_config); }); return; } let PurchasePriceText = (MAR.is_refi()) ? `Apraised value` : `Purchase Price`; function f_dollars(fld) { $(fld).inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: true, autoUnmask : true }); } function f_fulldollars(fld) { $(fld).inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 0, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: true, autoUnmask : true }); } function f_perc(elm) { $(elm).parent().addClass(`flx`); $(elm).css(`margin-right`,`0`); $(elm).after(`%`); return; } function f_perc_old(fld) { $(fld).inputmask("numeric", { radixPoint: ".", // groupSeparator: ",", digits: 3, autoGroup: true, suffix: '%', //No Space, this will truncate the first character rightAlign: true, autoUnmask : true }); } let calcmy_mo = function(i) { let field = fields[i]; let $elm = $(`#rq_${field.id}`); let val = $elm.val(); let $elm_calc = $(`#${field.id}_calc`); let h = ``; h += `
    Annual Payment Calculator
    `; h += `
    Monthly
    `; h += `
    Quarterly
    `; h += `
    Yearly
    `; h += `
     
    Update
    `; $elm_calc.html(h); f_dollars($elm_calc.find(`.monthly`)) f_dollars($elm_calc.find(`.quarterly`)) f_dollars($elm_calc.find(`.yearly`)) $elm_calc.removeClass(`x-hide`); } let calcmy = function(i) { let field = fields[i]; let $elm = $(`#rq_${field.id}`); let val = $elm.val(); let $elm_calc = $(`#${field.id}_calc`); let h = ``; h += `
    Annual Payment Calculator
    `; h += `
    Monthly
    `; h += `
    Quarterly
    `; h += `
    Yearly
    `; h += `
     
    Update
    `; $elm_calc.html(h); f_dollars($elm_calc.find(`.monthly`)) f_dollars($elm_calc.find(`.quarterly`)) f_dollars($elm_calc.find(`.yearly`)) $elm_calc.removeClass(`x-hide`); } let calcterm = function(i) { let field = fields[i]; let $elm_years = $(`#rq_years`); let val = num($elm_years.val()) * 12; let $elm_calc = $(`#${field.id}_calc`); let h = ``; h += `
    Term
    `; h += `
    Months
    `; h += `
     
    Update
    `; $elm_calc.html(h); $elm_calc.removeClass(`x-hide`); } mar.tmp_calculator_term_click = function(i, fld_id) { let field = fields[i]; let $elm_calc = $(`#${field.id}_calc`); let newval = $elm_calc.find(`.months_value`).val(); let newltv = num(newval)/12; $(`#rq_years`).val(newltv); $(`#rq_years`).trigger(`change`); $elm_calc.html(``); $elm_calc.addClass(`x-hide`); } let calcltv = function(i) { let field = fields[i]; let $elm_ltv = $(`#rq_ltv`); let $elm_pp = $(`#rq_pp`); let $elm_loanval = $(`#rq_loanval`); let val = ~~(num($elm_loanval.val())); let val_ltv = $elm_ltv.val(); let $elm_calc = $(`#${field.id}_calc`); let h = ``; h += `
    LTV / Loan Value calculator
    `; h += `
    Use
    `+ `
    `; h += `
    Loan Value
    `; h += `
    LTV
    `; h += `
     
    Update
    `; $elm_calc.html(h); $elm_calc.removeClass(`x-hide`); mar.tmp_calculator_pp_change(i,field.id,"init"); } mar.tmp_calcpricemanual_close = function(i) { let field = fields[i]; let $elm_calc = $(`#${field.id}_calc`); let $f = $("div.ratequote_popup"); $elm_calc.html(``); $elm_calc.addClass(`x-hide`); } mar.tmp_calcpricemanual_open = function(i, evt) { let field = fields[i]; let $elm_calc = $(`#${field.id}_calc`); let $f = $("div.ratequote_popup"); let notagain = $f.find(`#cog_manual_pricing_not_again`).prop(`checked`); if (notagain === true) { mvc.set(`cog_manual_pricing_not_again`,true) } $elm_calc.html(``); $elm_calc.addClass(`x-hide`); mar.tmp_manualpricing(evt) } let calcpricemanual = function(i) { if (mvc.get(`cog_manual_pricing_not_again`) === true) { mar.tmp_calcpricemanual_open(i, {}); return; } let field = fields[i]; let $elm_calc = $(`#${field.id}_calc`); let $f = $("div.ratequote_popup"); let h = ``; h += `
    Manual Pricing
    `; h += `
    Changing of the loan fields is done via the Manual Pricing window.
    .`; h += `
    `; h += `
     
    `+ `
    Close
    `; h += `
    Manual Pricing
    `; $elm_calc.html(h); $elm_calc.removeClass(`x-hide`); } let calccounty = function(i) { let field = fields[i]; let $elm_cnty = $(`#rq_county`); let county = $elm_cnty.val(); let $elm_calc = $(`#${field.id}_calc`); let $f = $("div.ratequote_popup"); let h = ``; h += `
    County
    `; h += `
    `; h += `
     

    Update
    `; $elm_calc.html(h); $elm_calc.removeClass(`x-hide`); let $elm = $elm_calc.find(`._value`); let countynum = getCounty_v2(county); let state = MAR.getOpt(mar, "tmp_scen.shotgun_state",""); if (state !== "") { state = MAR.stateCode(state, true).toUpperCase(); // convert FL -> Florida } let use = $f.find("#rq_puse").val() $elm.autocomplete({ minLength : 0, appendTo : "div.ratequote_popup", source : mar.counties.filter(function(a) { let state_name = a.split(":")[0].split("|")[1].trim(); // "1011|FLORIDA : Bla county" -> FLORIDA let state_code = MAR.stateCode(state_name); // "FLORIDA" -> FL if (state_code === "") { return false; // no blank state codes } if (use !== "i" && state_code in licenses === false) { return false; // not licensed } if (state === "") { return true; } return (a.indexOf(`|${state} :`) > -1); }), change: function(event, ui) { if (ui.item == null) { $elm.val(""); $elm.focus(); } } }).bind('focus', function(){ if ($elm.val().trim().length == 0) { $(this).autocomplete("search"); } }); } mar.tmp_calculator_cnty_change = function(i, fld_id, type) { let field = fields[i]; let $elm_calc = $(`#${field.id}_calc`); let newval = $elm_calc.find(`._value`).val(); } mar.tmp_calculator_cnty_click = function(i, fld_id) { let field = fields[i]; let $elm_calc = $(`#${field.id}_calc`); let newval = $elm_calc.find(`._value`).val(); let state_name = newval.split(":")[0].split("|")[1].trim(); // "1011|FLORIDA : Bla county" -> FLORIDA let state_code = MAR.stateCode(state_name); // "FLORIDA" -> FL $(`#rq_county`).val(newval); $(`#rq_state`).val(state_code); let countynum = getCounty_v2(newval); $("#rq_county").data("num",countynum); $(`#rq_county`).trigger(`change`); $elm_calc.html(``); $elm_calc.addClass(`x-hide`); } mar.tmp_calculator_pp_change = function(i, fld_id, type) { let field = fields[i]; let $elm_calc = $(`#${field.id}_calc`); let newval = $elm_calc.find(`.pp_value`).val(); let newval_ltv = $elm_calc.find(`.ltv_value`).val(); let newval_type = $elm_calc.find(`.pp_type`).val(); if (type === "init") { let _ltv = `${newval_ltv}`; if (_ltv.indexOf(".") < 0 || _ltv.split(".")[1].length < 3) { /** * use LTV */ $elm_calc.find(`.pp_type`).val(`ltv`); $elm_calc.find(`.pp_type`).change(); f_fulldollars($elm_calc.find(`.pp_value`)); return; } else { $elm_calc.find(`.pp_type`).val(`lv`); $elm_calc.find(`.pp_type`).change(); f_fulldollars($elm_calc.find(`.pp_value`)); return; } } if (type === "type") { if (newval_type === `ltv`) { $elm_calc.find(`.pp_row`).addClass(`x-hide-imp`); $elm_calc.find(`.ltv_row`).removeClass(`x-hide-imp`); } else { $elm_calc.find(`.pp_row`).removeClass(`x-hide-imp`); $elm_calc.find(`.ltv_row`).addClass(`x-hide-imp`); } } if (type === "ltv") { let newltv = num(newval_ltv); let pp = $(`#rq_pp`).val(); let newloanval = Math.round((num(pp) / 100) * num(newltv)); $elm_calc.find(`.pp_value`).val(newloanval); } if (type === "pp") { let pp = $(`#rq_pp`).val(); if (MAR.is_refi()) { pp = $("#rq_refipp").val(); } let newltv = (num(newval) / num(pp))*100; $elm_calc.find(`.ltv_value`).val(newltv); } } mar.tmp_calculator_pp_click = function(i, fld_id) { let field = fields[i]; let $elm_calc = $(`#${field.id}_calc`); let newval = $elm_calc.find(`.pp_value`).val(); let newval_ltv = $elm_calc.find(`.ltv_value`).val(); // let pp = $(`#rq_pp`).val(); // let ltv = $(`#rq_ltv`).val(); // let newltv = (num(newval) / num(pp))*100; let newltv = num(newval_ltv); $(`#rq_ltv`).val(newltv); $(`#rq_ltv`).trigger(`change`); $elm_calc.html(``); $elm_calc.addClass(`x-hide`); /* force change */ mar.tmp_loiar_toggle_changed = 10 mar.tmp_loiar_toggle_changed_fn(); } mar.tmp_calculator_close = function(i, fld_id) { let field = fields[i]; let $elm_calc = $(`#${field.id}_calc`); $elm_calc.html(``); $elm_calc.addClass(`x-hide`); } mar.tmp_calculator_change = function(i, fld_id, type, period='a') { let field = fields[i]; let $elm = $(`#rq_${field.id}`); let val = $elm.val(); let $elm_calc = $(`#${field.id}_calc`); if (type === "monthly") { let newval = $elm_calc.find(`.monthly`).val(); newval = Math.round(newval*12); if (period === `m`) { $elm.val(Math.round(newval/12)); } else { $elm.val(newval); } $elm_calc.find(`.quarterly`).val(Math.round(newval/4)); $elm_calc.find(`.yearly`).val(Math.round(newval)); } if (type === "quarterly") { let newval = $elm_calc.find(`.quarterly`).val(); newval = Math.round(newval*4); if (period === `m`) { $elm.val(Math.round(newval/12)); } else { $elm.val(newval); } $elm_calc.find(`.monthly`).val(Math.round(newval/12)); $elm_calc.find(`.yearly`).val(Math.round(newval)); } if (type === "yearly") { let newval = $elm_calc.find(`.yearly`).val(); newval = Math.round(newval); if (period === `m`) { $elm.val(Math.round(newval/12)); } else { $elm.val(newval); } $elm_calc.find(`.quarterly`).val(Math.round(newval/4)); $elm_calc.find(`.monthly`).val(Math.round(newval/12)); } } mar.tmp_calculator_click = function(i, fld_id) { let field = fields[i]; field.calc(i); } mar.tmp_getscenario = function() { let $f = $("div.ratequote_popup"); let rv = {}; rv.prog = $f.find("#rq_prog").val(); rv.state = $f.find("#rq_state").val(); rv.county = getCounty_v2($f.find("#rq_county").val()); rv.fthb = $f.find("#rq_fthb").val(); rv.va = $f.find("#rq_va").val(); rv.ptype = $f.find("#rq_ptype").val(); rv.puse = $f.find("#rq_puse").val(); rv.fico = $f.find("#rq_cscore").val(); rv.ltv = $f.find("#rq_ltv").val(); rv.years = $f.find("#rq_years").val(); rv.pp = $f.find("#rq_pp").val(); rv.refipp = $f.find("#rq_refipp").val(); rv.hoi = $f.find("#rq_hoi").val(); rv.hoa = $f.find("#rq_hoa").val(); rv.tax = $f.find("#rq_tax").val(); rv.commission = $f.find("#rq_comp").val(); rv.ttype = `purchase`; // purchase / refi / refi_limit / refi_cashout if (MAR.getOpt(mar, "tmp_scen.loan_type","") !== "purchase") { if (MAR.getOpt(mar, "tmp_scen.refi_options","") === "noclosing") { rv.ttype = `refi`; } if (MAR.getOpt(mar, "tmp_scen.refi_options","") === "closing") { rv.ttype = `refi_limit`; } if (MAR.getOpt(mar, "tmp_scen.refi_options","") === "cashout") { rv.ttype = `refi_cashout`; } } rv.key = [rv.prog,rv.state,rv.county,rv.fthb,rv.va,rv.ptype,rv.puse,rv.fico,rv.ltv,rv.years,rv.pp,rv.refipp,rv.commission].join("|"); rv.loan = {}; rv.loan.prog = $f.find("#rq_prog").val(); rv.loan.rate = $f.find("#rq_rate").val(); rv.loan.points = $f.find("#rq_points").val(); rv.loan.lender = $f.find("#rq_prog_var").val(); rv.loan.name = $f.find("#rq_name").val(); rv.loan.dtif = $f.find("#rq_dtif").val(); rv.loan.maxloan = $f.find("#rq_maxloan").val(); rv.loan.nonqm = $f.find("#rq_nonqm").val(); rv.loan.nodocs = $f.find("#rq_nodocs").val(); rv.loan.dtib = $f.find("#rq_dtib").val(); rv.loan.src = $f.find("#rq_src").val(); rv.loan.comp = $f.find("#rq_comp").val(); rv.loan.amort_type = $f.find("#rq_amort_type").val(); rv.loan.amort_m = $f.find("#rq_amort_m").val(); rv.loan.armfix_m = $f.find("#rq_armfix_m").val(); rv.loan.armvar = $f.find("#rq_armvar").val(); rv.loan.intfree_m = $f.find("#rq_intonly_m").val(); rv.loan.price_ts = $f.find("#rq_price_ts").val(); rv.loan.duration_m = num($f.find("#rq_years").val()) * 12; rv.loan.discount = $f.find("#rq_discount").val(); rv.loan.original_bd = mar.tmp_original_bd; // here buydown // original_bd rv.loan.mi = $f.find("#rq_mi").val(); rv.loan.ufmi = $f.find("#rq_ufmi").val(); return rv; } // mar.tmp_manualpricing(evt); mar.tmp_manualpricing = function(evt) { if (evt) { evt.preventDefault(); evt.stopPropagation(); } mar.tmp_loiar_toggle_changed_fn(function(changed) { parent.postMessage(JSON.stringify({ from : "app", action : "window_pricing_manual", appid : mar.ID, scenario : mar.tmp_getscenario() }), "*"); }); // mar.tmp_loiar_toggle_2(false,evt,"rqh_manpr") } mar.tmp_getpricing = function(evt) { if (evt) { evt.preventDefault(); evt.stopPropagation(); } mar.tmp_loiar_toggle_changed_fn(function(changed) { parent.postMessage(JSON.stringify({ from : "app", action : "window_pricing", appid : mar.ID, scenario : mar.tmp_getscenario() }), "*"); }); } mar.tmp_getrate = function() { mar.tmp_loiar_toggle_changed_fn(function(changed) { parent.postMessage(JSON.stringify({ from : "app", action : "window_pricing", appid : mar.ID, scenario : mar.tmp_getscenario() }), "*"); }); } mar.tmp_apply_rq_from_pricing_window = function(obj) { // prog : prog // rate : rate, // points : points, // lender : lender, // name : name, // dtif : dtif, // dtib : dtib, // src : src // duration_m : duration_m, // amort_type : amort_type, // amort_m : amort_m, // intfree_m : intfree_m, // armfix_m : armfix_m, let $f = $("div.ratequote_popup"); $f.find("#rq_prog").val(obj.prog); $f.find("#rq_rate").val(obj.rate); $f.find("#rq_points").val(obj.points); $f.find("#rq_prog_var").val(obj.lender); $f.find("#rq_name").val(obj.name); $f.find("#rq_dtif").val(obj.dtif); $f.find("#rq_dtib").val(obj.dtib); $f.find("#rq_src").val(obj.src); MAR.ifOpt(obj, "maxloan", function(v) { $f.find("#rq_maxloan").val(obj.maxloan); }); MAR.ifOpt(obj, "commission", function(v) { $f.find("#rq_comp").val(obj.commission); }); MAR.ifOpt(obj, "manual_grid", function(v) { $f.find("#rq_manual_grid").val(v); $f.find("#rq_manual_grid").change(); }); MAR.ifOpt(obj, "lender_c", function(v) { $f.find("#rq_discount").val(v); $f.find("#rq_discount").change(); }); MAR.ifOpt(obj, "nonqm", function(v) { $f.find("#rq_nonqm").val(v); }); MAR.ifOpt(obj, "nodocs", function(v) { $f.find("#rq_nodocs").val(v); }); MAR.ifOpt(obj, "mi", function(v) { $f.find("#rq_mi").val(v); }); MAR.ifOpt(obj, "ufmi", function(v) { $f.find("#rq_ufmi").val(v); }); $f.find("#rq_amort_type").val(obj.amort_type); // $f.find("#rq_amort_m").val(obj.amort_m); $f.find("#rq_armfix_m").val(obj.armfix_m); MAR.ifOpt(obj, "armvar", function(v) { $f.find("#rq_armvar").val(obj.armvar); }); $f.find("#rq_intonly_m").val(obj.intfree_m); $f.find("#rq_src").val(obj.src); $f.find("#rq_price_ts").val(obj.price_ts); $f.find("#rq_price_ts").trigger(`change:value`); $f.find("#rq_years").val(~~(obj.duration_m/12)); console.log(obj); mar.tmp_loiar_toggle_changed = 10 mar.tmp_loiar_toggle_changed_fn(); } let fields = [ { id : "rqh_scen", type : "head", label : `Scenario `, val : `` }, { id : "ttype", type : "scen", label : "Transaction Type" }, { id : "puse", type : "scen", label : "Property Use" }, { id : "ptype", type : "scen", label : "Property type" }, { id : "cscore", type : "scen", label : "Credit score" }, { id : "state", type : "hide", label : "State" }, { id : "county", type : "scen", label : "County" , calc : calccounty }, { id : "va", type : "scen", label : "VA Loan/Eligible" }, { id : "fthb", type : "scen", label : "FTHB" }, { id : "phe", type : "scen", label : "Primary Housing Expenses" }, // { id : "spacer1", type : "html", label : "
     
    Save
    " }, // // { id : "rqh_value", type : "head", label : `Loan `, val : ``, opt_keep_summary_open : true }, { id : "rqh_value", type : "head", label : `Loan `, val : ``, opt_keep_summary_open : false }, //{ id : "rqh_manpr", type : "head", label : ` `, val : `` }, { id : "pp", type : "scen", label : PurchasePriceText , scenario : "purchase_target" }, { id : "refipp", type : "perc", label : "Appraised Value" }, { id : "refidebt", type : "perc", label : "Payoff" }, { id : "refigoal", type : "hide", label : "Refi Goal" }, { id : "loanval", type : "none", label : "Loan Amount" ,calc : calcltv }, { id : "ltv", type : "perc", label : "LTV" }, { id : "prog", type : "prog", label : "Loan Type" }, /* rq_prog */ { id : "nonqm", type : "text", label : "Program Type" }, /* rq_nonqm */ { id : "nodocs", type : "text", label : "Income Docs" }, /* rq_nodocs */ // { id : "prog_var", type : "text", label : "Lender" , calc : calcpricemanual }, { id : "name", type : "text", label : "Loan Program" , calc : calcpricemanual }, { id : "price_ts", type : "text", label : "Pricing date" , calc : calcpricemanual }, { id : "rate", type : "perc", label : "Rate" , calc : calcpricemanual }, { id : "years", type : "perc", label : "Term in months" ,calc : calcterm }, /* rq_years */ { id : "amort_type", type : "text", label : "Rate type" }, { id : "amort_m", type : "hide", label : "Amortization (months)" }, { id : "armfix_m", type : "perc", label : "ARM fixed (months)" }, { id : "armvar", type : "text", label : "ARM Changes per year" }, { id : "intonly", type : "hide", label : "Interest only" }, { id : "intonly_m", type : "perc", label : "Int Only Months" }, { id : "points", type : "perc", label : "Price" }, { id : "points_abs", type : "hide", label : "/or/ Price cost " }, { id : "discount", type : "perc", label : "Lender Credit" }, { id : "comp", type : "perc", label : "Estimated corporate yield" }, // { id : "getrate", type : "html", label : `
    Get Pricing`+ `Price Manually
    ` }, // { id : "c2cwarn", type : "html", label : `` }, { id : "qm", type : "html", label : `` }, { id : "c2c", type : "html", label : `` }, // { id : "manual_grid", type : "text", label : "Ratios / Limits" }, { id : "limits", type : "html", label : `` }, { id : "dtif", type : "perc", label : "FE DTI Max Limit" }, { id : "dtib", type : "perc", label : "BE DTI Max Limit" }, { id : "maxloan", type : "perc", label : "Max Loan" }, { id : "src", type : "perc", label : "Source" }, { id : "ratesheet_prog",type : "hide", label : "Ratesheet" }, // { id : "rqh_pmt", type : "head", label : `Payments `, val : ``,no_expand : true }, // { id : "rqh_mi", type : "head", label : `Mortgage Ins. `, val : `` }, // { id : "mi", type : "perc", label : "MI" }, // // { id : "rqh_ufmi", type : "head", label : `Fin. UFMI `, val : `` }, // { id : "ufmi", type : "perc", label : "UFMI" }, // // { id : "rqh_hoi", type : "head", label : `Home Owners Ins. `, val : `` }, // { id : "hoi", type : "perc", label : "HOI (Annual)" , calc : calcmy}, // // { id : "rqh_tax", type : "head", label : `Property Taxes `, val : `` }, // { id : "tax", type : "perc", label : "Tax (annual)" , calc : calcmy }, // // { id : "rqh_hoa", type : "head", label : `HOA `, val : `` }, // { id : "hoa", type : "perc", label : "HOA (monthly)" , calc : calcmy }, // // { id : "rqh_other", type : "head", label : `Other `, val : `` }, { id : "ignoremaxloan", type : "hide", label : "Ignore Max Loan Y/N" }, // { id : "sintonly", type : "scen", label : "Interest only" , scenario : "interestonly"}, { id : "rqh_p_pmt", type : "head", label : `Principle and Interest`, val : false, no_save_button : true }, { id : "rqh_p_pmt_row", type : "html", label : `
    Detail
    ` }, { id : "rqh_p_mi", type : "head", label : `Mortgage Insurance`, val : false }, { id : "mi", type : "perc", label : "M.I percentage" }, { id : "ufmi", type : "perc", label : "UFMI percentage" }, { id : "rqh_p_tax", type : "head", label : `Taxes`, val : false }, { id : "tax", type : "perc", label : "Annual Taxes" , calc : calcmy }, { id : "rqh_p_ins", type : "head", label : `Home Owners Insurance` , val : false }, { id : "hoi", type : "perc", label : "Annual HOI" , calc : calcmy}, { id : "rqh_p_hoa", type : "head", label : `HOA` , val : false }, { id : "hoa", type : "perc", label : "Monthly HOA" , calc : calcmy_mo }, { id : "rqh_total", type : "head", label : `Total Payment per month` , val : false, opt_no_expand : true }, // { id : "rqh_c2c", type : "head", label : `Cash to Close`, val : false } ]; let h = ""; let scripts = []; mar.tmp_loiar_toggle_changed = false; mar.tmp_loiar_toggle_changed_onchange_fn = function(){ mar.tmp_loiar_toggle_changed = 1; } mar.tmp_loiar_toggle_changed_onstart_fn = function(){ mar.tmp_loiar_toggle_changed = false; mar.tmp_editliabilities_block.read(); mar.tmp_editincome_block.read(); mar.tmp_editreo_block.read(); mar.tmp_loiar_toggle_changed_lia = mar.tmp_editliabilities_block.gettotals(); mar.tmp_loiar_toggle_changed_incs = mar.tmp_editincome_block.gettotals(); mar.tmp_loiar_toggle_changed_reos = mar.tmp_editreo_block.gettotals(); } /** * When toggling check if there was a change so recalculate the loan and re-display * * Section v (toggle) * field [value] * * * called from mar.tmp_loiar_toggle() */ mar.tmp_loiar_toggle_changed_fn = function(fn = false){ mar.tmp_editliabilities_block.read(); mar.tmp_editincome_block.read(); mar.tmp_editreo_block.read(); let lia = mar.tmp_editliabilities_block.gettotals(); let incs = mar.tmp_editincome_block.gettotals(); let reos = mar.tmp_editreo_block.gettotals(); if (JSON.stringify(lia) !== JSON.stringify(mar.tmp_loiar_toggle_changed_lia)) { mar.tmp_loiar_toggle_changed = 2; } if (JSON.stringify(incs) !== JSON.stringify(mar.tmp_loiar_toggle_changed_incs)) { mar.tmp_loiar_toggle_changed = 3; } if (JSON.stringify(reos) !== JSON.stringify(mar.tmp_loiar_toggle_changed_reos)) { mar.tmp_loiar_toggle_changed = `4 ${reos} / ${mar.tmp_loiar_toggle_changed_reos}`; } if (mar.tmp_loiar_toggle_changed !== false) { mar.tmp_loiar_apply_fn(function(){ setTimeout(function(){ if (typeof fn === "function") { fn(mar.tmp_loiar_toggle_changed); return; } $.get(`/api/chatbot/getAgreedRate/${mar.ID}/${version}`, function(__da){ da = __da off = da.data; mar.tmp_off = off; mar.tmp_off_da = da; let trackdata = MAR.getOpt(da, "trackdata", {}); mar.tmp_trackdata = trackdata; mar.tmp_loiar_load_fn(true); }); },500); }); } else { if (typeof fn === "function") { fn(mar.tmp_loiar_toggle_changed); return; } } } /** * toggle a section, check for changes if it is a closure * * Section v (toggle) * field [value] * * */ mar.tmp_loiar_toggle = function(elm,evt) { let $elm = $(elm); let classes = $elm.prop("class").split(" "); let da_cls = $elm.data("cls"); if (typeof da_cls === "string" && da_cls !== "") { classes = [da_cls]; } let cls = classes.shift(); while (!cls.startsWith("hdr-")) { cls = classes.shift(); } if (cls.startsWith("hdr-")) { let _id = cls.split("-")[1]; if ($(`.body-${_id}`).hasClass("x-hide")) { $(`.body-${_id}`).removeClass("x-hide"); $(`.hdr-${_id} .arrow`).html(mar.tmp_arrow_down); } else { $(`.body-${_id}`).addClass("x-hide"); $(`.hdr-${_id} .arrow`).html(mar.tmp_arrow_right); mar.tmp_loiar_toggle_changed_fn(); } } } mar.tmp_loiar_toggle_2 = function(elm,evt, id, opt_keep_summary_open = false, no_change = false) { if ($(`#${id}_div`).hasClass("x-hide")) { $(`#${id}_div`).removeClass("x-hide"); if (opt_keep_summary_open !== true) { $(`#${id}_div_head`).addClass("x-hide"); } $(`.${id}_arrow`).html(mar.tmp_arrow_down); } else { $(`#${id}_div`).addClass("x-hide"); $(`#${id}_div_head`).removeClass("x-hide"); $(`.${id}_arrow`).html(mar.tmp_arrow_right); if (no_change !== true) { mar.tmp_loiar_toggle_changed_fn(); if (id === `rqh_value`) { mar.tmp_initial_scenario = 0; } } } } mar.tmp_arrow_down = `
     
    `;//`keyboard_arrow_down`; mar.tmp_arrow_right = `
     
    `;//`navigate_next`; h += mar.tmp_rq_topgrid_html(``, true); // h += `
    Loan parameters
    0
    ${mar.tmp_arrow_right}
    `; // h += `
    `; let endspacer = `
     
    `; let left_indent = `12px`; // let left_indent2 = `36px`; let left_indent2 = `12px`; let current_head = ``; let current_headOjb = {}; for (let i=0; i < fields.length; i++) { let field = fields[i]; let lbl = `${field.label}`; if (field.type === "head") { if (current_head !== ``) { let no_save_button = MAR.getOpt(current_headOjb, "no_save_button", false) h += `
    `+ `
     
    `; if (no_save_button !== true) { h += `Cancel`; h += `Save`; } else { h += `Close`; } h += `
    `; h += `

    `; } let opt_keep_summary_open = MAR.getOpt(field, "opt_keep_summary_open", false) let opt_no_expand = MAR.getOpt(field, "opt_no_expand", false) if (opt_no_expand === true) { h += `
    `; } else { h += `
    `; } if (field.val === false) { // h += `
    ${endspacer}${field.label}
    `; h += `
    ${field.label}
    `; } else { h += `
    ${field.label}
    `; // h += `
    ${mar.tmp_arrow_right}${field.label}
    `; } h += ``; h += endspacer; h += `
    `; h += `
    `; h += `
    `; h += `
    ${field.label}
    `; current_head = field.id; current_headOjb = field; } else if (field.type === "perc") { let calculator = (function(){ if (typeof field.calc !== "function") { return ""; } let h = ``; return h; })(); h += `
    `; h += `
    ${lbl} ${calculator}
    `; if (calculator !== "") { h += ``; } else { h += ``; } h += endspacer; h += `
    `; h += `
    `; h += `
    `; h += `
    `; h += endspacer; h += `
    `; } else if (field.type === "hide") { h += ``; } else if (field.type === "prog") { h += `
    `; h += `
    ${lbl}
    `; h += ``; h += ``; h += ``; h += endspacer; h += `
    `; h += `
    `; h += ``; h += `
    `; h += endspacer; h += `
    `; } else if (field.type === "scen") { let calculator = (function(){ if (typeof field.calc !== "function") { return ""; } let h = ``; return h; })(); let val = getScenario_data(field.scenario, ""); h += `
    `; h += `
    ${lbl} ${calculator}
    `; if (calculator !== "") { h += ``; } else { h += ``; } h += endspacer; h += `
    `; h += `
    `; h += `
    `; h += `
    `; // h += ``; h += endspacer; h += `
    `; } else if (field.type === "html") { /** * html field */ h += `
    ${lbl}
    `; } else { let calculator = (function(){ if (typeof field.calc !== "function") { return ""; } let h = ``; return h; })(); h += `
    `; h += `
    ${lbl} ${calculator}
    `; if (calculator !== "") { h += ``; } else { h += ``; } h += endspacer; h += `
    `; h += `
    `; h += `
    `; h += `
    `; // h += ``; h += endspacer; h += `
    `; } } if (current_head !== ``) { h += `
    `; } h += `

    `; h += `
    Cash to Close
    `+ `
    ${mar.tmp_arrow_right}
    `; h += `
    `; h += `
    `+ `
    Closing costs
    `; /** * here I need to put the switch !! */ h += `
    `+ `
    Ratesheet
    `+ ``+ `
     
    `; let mismo_sections = [`OriginationCharges`, `ServicesYouCannotShopFor`, `ServicesYouCanShopFor`, `TaxesAndOtherGovernmentFees`, `Prepaids`, `InitialEscrowPaymentAtClosing`, `Other`]; let costcats = MAR.getOpt(DA, `data._costcats`,{}); let getSync = function(url) { return new Promise(function(resolve, reject){ $.get(url, function(da){ resolve(da); }); }); } let mismo_data = await getSync(`/api/chatbot/get_mismo_options/all`); mar.tmp_rq_custom_rows_hide_show = function() { for (let mismo_sec of mismo_sections) { let rows = $(`.rq_custom_field_${mismo_sec}_group`); let first_empty_opened = false; for (let i=0; i < rows.length; i++) { let $row = $(rows[i]); let _i = $row.data(`i`); let $line = $(`.rq_custom_line_${mismo_sec}_${_i}`); let lbl = $row.find(`input.lbl`).val(); if (lbl !== ``) { $row.removeClass(`x-hide-imp`); $line.removeClass(`x-hide-imp`); } else if (first_empty_opened === false) { $row.removeClass(`x-hide-imp`); $line.removeClass(`x-hide-imp`); first_empty_opened = true; } else { $row.addClass(`x-hide-imp`); $line.addClass(`x-hide-imp`); } let calctype = $row.find(`select.calctype`).val(); if (calctype === `pla` || calctype === `ppp` || calctype === `pdi`) { $row.find(`.perc-row`).removeClass(`x-hide-imp`); $row.find(`.monthly-row`).addClass(`x-hide-imp`); $row.find(`.months-row`).addClass(`x-hide-imp`); $row.find(`.val`).addClass(`x-hide-imp`); $row.find(`.valmessage`).removeClass(`x-hide-imp`); } else if (calctype === `pp`) { $row.find(`.perc-row`).addClass(`x-hide-imp`); $row.find(`.monthly-row`).removeClass(`x-hide-imp`); $row.find(`.months-row`).removeClass(`x-hide-imp`); $row.find(`.val`).addClass(`x-hide-imp`); $row.find(`.valmessage`).removeClass(`x-hide-imp`); } else { $row.find(`.perc-row`).addClass(`x-hide-imp`); $row.find(`.monthly-row`).addClass(`x-hide-imp`); $row.find(`.months-row`).addClass(`x-hide-imp`); $row.find(`.val`).removeClass(`x-hide-imp`); $row.find(`.valmessage`).addClass(`x-hide-imp`); } } } } let mismo_headgins = { OriginationCharges : "A. Origination Charges", ServicesYouCannotShopFor : "B. Services You Cannot Shop For", ServicesYouCanShopFor : "C. Services You Can Shop For", TaxesAndOtherGovernmentFees : "E. Taxes And Other Government Fees", Prepaids : "F. Prepaids", InitialEscrowPaymentAtClosing : "G. Initial Escrow Payment At Closing", Other : "H. Other" } mar.tmp_arrow_down_ = `keyboard_arrow_down`; mar.tmp_arrow_right_ = `navigate_next`; mar.tmp_open_custom_cost = function(mismo_sec, i, type = ``) { let $group = $(`.rq_custom_field_${mismo_sec}_${i}`); let $adv = $group.find(`.advanced`); let $but = $group.find(`.toggle-but`); if ($adv.hasClass(`x-hide-imp`) || type === `open`) { $adv.removeClass(`x-hide-imp`); $but.html(mar.tmp_arrow_down_); } else { $adv.addClass(`x-hide-imp`); $but.html(mar.tmp_arrow_right_); } }; mar.tmp_select_mismo_values_autocomplete = function(mismo_sec) { let rv = []; let items = MAR.getOpt(mismo_data, `secs.${mismo_sec}`,[]); rv.push({value : `Other`, label : `Other`}); for (let j=0; j < items.length; j++) { let item = items[j]; if (item.key === `Other`) continue; rv.push({value : item.key, label : item.name}); } return rv; }; mar.tmp_add_mismo_autocomplete = function(mismo_sec, i) { console.error(`tmp_add_mismo_autocomplete ${mismo_sec} ${i}`); let $group = $(`.rq_custom_field_${mismo_sec}_${i}`); /* -- for options see https://api.jqueryui.com/autocomplete/ -- */ $group.find(".lbl").autocomplete({ minLength : 1, source : mar.tmp_select_mismo_values_autocomplete(mismo_sec), max : 5, scroll : true, appendTo : ".swal-content", _resizeMenu: function() { this.menu.element.outerWidth( 400 ); }, select: function(event, ui) { $group.find(".lbl").val(ui.item.label); $group.find(".type").val(ui.item.value); let def_qm_apr_obj = MAR.rq_obj.default_qm_apr_custom_costs(ui.item.value); MAR.ifOpt(def_qm_apr_obj, `qm`, function(v) { $group.find(".qm").val(v.toLowerCase()); }); MAR.ifOpt(def_qm_apr_obj, `apr`, function() { $group.find(".apr").val(v.toLowerCase()); }); return false; }, change: function(event, ui) { if ($group.find(".lbl").val() === ``) { $group.find(".type").val(``); $group.find(".qm").val(``); $group.find(".apr").val(``); } // if (ui.item == null) { // $group.find(".lbl").val(""); // $group.find(".lbl").focus(); // } else { // $group.find(".lbl").val(ui.item.label); // } } }).bind('focus', function(){ if ($group.find(".lbl").val().trim().length == 0) { $(this).autocomplete("search"," "); return false; } }); $group.find(".type").change(function() { let v = $group.find(".type").val(); let def_qm_apr_obj = MAR.rq_obj.default_qm_apr_custom_costs(v); MAR.ifOpt(def_qm_apr_obj, `qm`, function(v) { $group.find(".qm").val(v.toLowerCase()); }); MAR.ifOpt(def_qm_apr_obj, `apr`, function() { $group.find(".apr").val(v.toLowerCase()); }); }); } h += ``; h += ``; h += ``; for (let mismo_sec of mismo_sections) { h += `
    ${MAR.getOpt(mismo_headgins,mismo_sec,mismo_sec)}
    `; let select_opts = (function() { let opts = ``; opts += ``; let items = MAR.getOpt(mismo_data, `secs.${mismo_sec}`,[]); for (let j=0; j < items.length; j++) { let item = items[j]; if (item.key === `Other`) continue; opts += ``; } return opts; })(); let add_custom_cost = function(sec,i){ h += `
    `; h += `
    `; // top align h += `
    `; h += `
    `; h += `${mar.tmp_arrow_right_}`; h += ``; h += `
    `; h += `
    `; h += ``; h += `Calculated`; h += `
    `; h += `
    `; h += `
    `; h += `
    `; h += `
    Options
    `; h += `
     
    `; h += `
    `; h += `
    `; h += `
    Calculated
    `; h += `
    `+ ``+ `
    `; h += `
    `; h += `
    `; h += `
    Percentage
    `; h += `
    `; h += `
    `; h += `
    `; h += `
    Months
    `; h += `
    `; h += `
    `; h += `
    `; h += `
    Monthly amount
    `; h += `
    `; h += `
    `; h += `
    `; h += `
    `; h += `
    Included in QM
    `; h += `
    `; h += `
    `; // here h += `
    `; h += `
    `; h += `
    Included in APR
    `; h += `
    `; h += `
    `; h += `
    `; h += `
    `; h += `
    MISMO Type
    `; h += `
    `; h += `
    `; h += `
    `; // end advanced // h += `
    `; // h += ``; // h += `
    `; // h += `
    `; h += `
    `; h += `
    `; scripts.push([mismo_sec,i]); // h += ``; } for (x in RS) { let itm = RS[x]; let _filter = (MAR.is_refi()) ? "r" : "p"; /* -- this section filters based on the mismo category -- */ let costcat_key = (`same_as` in itm) ? itm.same_as : x; /* -- either it is an equivalent, or the raw label is the same as the cost cats -- */ let costcat_itm = MAR.getOpt(costcats, costcat_key, []); if (MAR.getOpt(costcat_itm, `8`, ``) !== mismo_sec) { continue } /* -- end section -- */ let num_lines = 0; let idx_lines = []; for (let i=0; i < itm.filter.length; i++) { if (itm.filter[i] === "") { num_lines++ idx_lines.push(i); } else if (itm.filter[i] === _filter) { num_lines++ idx_lines.push(i); } } let singleline = (num_lines === 1); for (let i=0; i < itm.cols.length; i++) { if (idx_lines.indexOf(i) < 0) { /** * make a hidden variation */ h += ``; continue; } let xtra = ``; if (itm.cols[i] !== ``) { xtra = `
     - ${itm.cols[i]}`; } h += `
    `; h += `
    ${itm.lbl}${xtra}
    `; h += ``; h += endspacer; h += `
    `; h += `
    `; h += `
    `; // h += ``; h += endspacer; h += `
    `; } // if (!singleline) { // h += `
    ${itm.lbl}
    `; // } else { // h += `
    `; // } // for (let i=0; i < itm.cols.length; i++) { // h += `
    `; // h += `
    `; // if (singleline) { // h += `${itm.lbl}`; // } else { // h += ` - ${itm.cols[i]} `; // } // h += `
    `; // h += `
    `; // h += `
    `; // h += ``; // h += `
    `; // h += `
    `; // } if (num_lines > 0) { h += `
    `; } } // h += `
    Additional ${mismo_sec}
    `; add_custom_cost(800,1); add_custom_cost(800,2); add_custom_cost(800,3); add_custom_cost(800,4); add_custom_cost(800,5); add_custom_cost(800,6); } let add_custom_cost = function(sec,i){ h += `
    `; h += `
    `; h += `
    `; h += ``; h += `
    `; h += `
    `; h += ``; h += `
    `; h += `
    `; h += `
    `; } // h += `
    Additional Lender fees
    `; // add_custom_cost(800,1); // add_custom_cost(800,2); // add_custom_cost(800,3); //// h += `
    Additional title fees
    `; //// add_custom_cost(900,1); //// add_custom_cost(900,2); //// add_custom_cost(900,3); //// h += `
    Additional reserves
    `; //// add_custom_cost(1000,1); //// add_custom_cost(1000,2); //// add_custom_cost(1000,3); // h += `
    Additional title charges
    `; // add_custom_cost(1100,1); // add_custom_cost(1100,2); // add_custom_cost(1100,3); // h += `
    Additional Gov & Transfer charges
    `; // add_custom_cost(1200,1); // add_custom_cost(1200,2); // add_custom_cost(1200,3); // h += `
    Additional charges
    `; // add_custom_cost(1300,1); // add_custom_cost(1300,2); // add_custom_cost(1300,3); // add_custom_cost(1300,4); // add_custom_cost(1300,5); // add_custom_cost(1300,6); // add_custom_cost(1300,7); // add_custom_cost(1300,8); // add_custom_cost(1300,9); // add_custom_cost(1300,10); h += `
     
    `+ `
    Clear values
    `+ `
    `; h += `
    Save
    `+ `
    `; h += `
    `; h += `
    `; h += `
    Assets
    --.--
    ${mar.tmp_arrow_right}
    `; h += `
    `; h += `
    Income
    --.--
    ${mar.tmp_arrow_right}
    `; h += `
    `; h += `
    REO
     
    ${mar.tmp_arrow_right}
    `; h += `
    `; h += `
    Liabilities
    --.--
    ${mar.tmp_arrow_right}
    `; h += `
    `; h += `
    `; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; mar.tmp_pg_loi_adjust_quote_enable_disable_mi_ufmi = function() { let ufmi = txt("#rq_ufmi"); let mi = txt("#rq_mi"); let prog_sel = txt("#rq_prog_sel"); if (prog_sel === "fha") { $(`#rq_ufmi`).val($(`#rq_ufmi`).data(`placeholder`)); $(`#rq_mi`).val($(`#rq_mi`).data(`placeholder`)); $(`#rq_ufmi`).prop(`disabled`,true); $(`#rq_mi`).prop(`disabled`,true); $(`#rq_ufmi`).css(`color`,`#00000033`); $(`#rq_mi`).css(`color`,`#00000033`); } else { $(`#rq_ufmi`).prop(`disabled`,false); $(`#rq_mi`).prop(`disabled`,false); $(`#rq_ufmi`).css(`background-color`,`unset`); $(`#rq_mi`).css(`background-color`,`unset`); } } mar.tmp_pg_loi_adjust_quote_oc = function() { $("#rq_warning").html(""); $("#rq_info").html(""); let warning = ""; let info = ""; let points = txt("#rq_points"); let ufmi = txt("#rq_ufmi"); let mi = txt("#rq_mi"); let mi_p = $("#rq_mi").data("placeholder"); let ltv = txt("#rq_ltv"); let nonqm = (txt("#rq_nonqm") === "Y"); let tot = 0; if (typeof points === "string" && points.trim().length > 0) tot += (100 - num(points)); if (typeof ufmi === "string" && ufmi.trim().length > 0) tot += num(ufmi); if (!nonqm && tot > 2.5) { // warning = `You are giving away 2.5 points and that may not pass QM, ${(100 - num(points))} points on the loan and ${ufmi} points is ufmi`; } if (!nonqm && tot <= 2.5) { // pd.Total_qm_points // info = `QM is currently as ${elaineui.format('perc3opt',(100 - num(points)))} QM points on the loan and ${elaineui.format('perc3opt',ufmi)} UFMI points totaling ${elaineui.format('perc3opt',tot)}`; } if (warning !== "") { $("#rq_warning").html(frm.inline_warning_red(warning)) } else if (info !== "") { $("#rq_info").html(info) } else { $("#rq_warning").html("") } let prog_sel = txt("#rq_prog_sel"); if (prog_sel === "") { txt("#rq_prog", ""); } else if (prog_sel === "nonqm") { txt("#rq_prog", "conv"); txt("#rq_intonly", "Y"); txt("#rq_years", ""); } else if (prog_sel === "nonqm40") { txt("#rq_prog", "conv"); txt("#rq_intonly", "Y"); txt("#rq_years", "40"); } else if (prog_sel === "conv") { txt("#rq_prog", "conv"); txt("#rq_intonly", "N"); if (num(ltv) < 80) { // if (num(mi) !== num(mi_p)) { txt("#rq_mi", ""); // } } } else { txt("#rq_prog", prog_sel); txt("#rq_intonly", ""); } mar.tmp_loiar_toggle_changed_onchange_fn(); mar.tmp_pg_loi_adjust_quote_enable_disable_mi_ufmi(); mar.tmp_pg_loi_adjust_quote_oc_hide_fields(); } mar.tmp_pg_loi_adjust_quote_oc_hide_fields = function() { let amort_type = $(`#rq_amort_type`).val(); if (amort_type !== `arm`) { $(`.rq_amort_m_wrap`).addClass(`x-hide-imp`); $(`.rq_armfix_m_wrap`).addClass(`x-hide-imp`); $(`.rq_armvar_wrap`).addClass(`x-hide-imp`); $(`.rq_intonly_m_wrap`).removeClass(`x-hide-imp`); } else { $(`.rq_amort_m_wrap`).removeClass(`x-hide-imp`); $(`.rq_armfix_m_wrap`).removeClass(`x-hide-imp`); $(`.rq_armvar_wrap`).removeClass(`x-hide-imp`); $(`.rq_intonly_m_wrap`).addClass(`x-hide-imp`); } let puse = $("#rq_puse").val(); let reos = MAR.getOpt(mar.answers, "v2.reo", []); (function() { for (let j=0; j < reos.length; j++) { if (MAR.getOpt(reos[j], "reo_use2","") === "primary" && MAR.getOpt(reos[j], "verified","") === "Y") return; } reos = []; })(); if (puse !== `p` && reos.length === 0) { $(`.rq_phe_wrap`).removeClass(`x-hide-imp`); } else { $(`.rq_phe_wrap`).addClass(`x-hide-imp`); } mar.tmp_editreo_block.hide_show_phe(); let manual_grid = $(`#rq_manual_grid`).val(); if (manual_grid === `Y`) { $(`.rq_maxloan_wrap`).removeClass(`x-hide-imp`); $(`.rq_dtif_wrap`).removeClass(`x-hide-imp`); $(`.rq_dtib_wrap`).removeClass(`x-hide-imp`); $(`#limits_div`).addClass(`x-hide-imp`); let febe = mar.tmp_cog_febe; // if ($(`#rq_dtif`).val() === ``) $(`#rq_dtif`).prop(`placeholder`,febe.maximums.dtif); // if ($(`#rq_dtib`).val() === ``) $(`#rq_dtib`).prop(`placeholder`,febe.maximums.dtib); // if ($(`#rq_maxloan`).val() === ``) $(`#rq_maxloan`).prop(`placeholder`,febe.maximums.loan); } else { $(`.rq_maxloan_wrap`).addClass(`x-hide-imp`); $(`.rq_dtif_wrap`).addClass(`x-hide-imp`); $(`.rq_dtib_wrap`).addClass(`x-hide-imp`); $(`#limits_div`).removeClass(`x-hide-imp`); (function() { let febe = mar.tmp_cog_febe; let h = ``; h += `
    FE DTI Max Limit
    ${elaineui.format('perc3opt',febe.maximums.dtif)}
    `; h += `
    BE DTI Max Limit
    ${elaineui.format('perc3opt',febe.maximums.dtib)}
    `; h += `
    Max Loan
    ${elaineui.format('cur',febe.maximums.loan)}
    `; $(`#limits_div #rq_limits_lbl`).html(h); })(); $(`#rq_dtif`).val(``); $(`#rq_dtib`).val(``); $(`#rq_maxloan`).val(``); } } mar.tmp_loiar_apply_fn = function(fn){ mar.tmp_editliabilities_block.read(); mar.tmp_editincome_block.read(); mar.tmp_editreo_block.read(); let lia = mar.tmp_editliabilities_block.gettotals(); let incs = mar.tmp_editincome_block.gettotals(); let reos = mar.tmp_editreo_block.gettotals(); setScenario_data("rough_liabilities",lia.pmt_exmort); setScenario_data("rough_liabilities_po",lia.bal_payoff); setScenario_data("rough_liabilities_pooc",lia.bal_payoff_oc); setScenario_data("rough_qual_income",incs.total); (function set_manual_grid_to_zero_if_blank() { if ($(`#rq_manual_grid`).val() === `Y`) { if ($(`#rq_dtif`).val() === ``) $(`#rq_dtif`).val(`0`) if ($(`#rq_dtib`).val() === ``) $(`#rq_dtib`).val(`0`) if ($(`#rq_maxloan`).val() === ``) $(`#rq_maxloan`).val(`0`) } })(); let obj = {}; for (x in RS) { let itm = RS[x]; let val = []; for (let i=0; i < itm.cols.length; i++) { let _val = $(`div.ratequote_popup #${x}_${i}`).val(); let _def = $(`div.ratequote_popup #${x}_${i}`).data("placeholder"); if (_def !== false && `${_def}` === `${_val}`) { _val = ""; } if (_val.trim().length === 0) { val.push(""); } else { val.push(num(_val)); } } obj[x] = val; } if (version === "" || version === false) { let vars = {}; for (let i=0; i < fields.length; i++) { let field = fields[i]; if (field.type === "head") continue; let _val = txt(`#rq_${field.id}`); let _def = $(`#rq_${field.id}`).data("placeholder"); if (_def !== false && `${_def}` === `${_val}`) { _val = ""; } if (field.type === "scen") { if (_val.trim().length === 0) { continue; } setScenario_data(`${field.scenario}` , _val); } else { setScenario_data(`rq_${field.id}` , _val); } } setScenario_data("rq_rate_table", obj); $("#body-container").LoadingOverlay("show"); mar.fakesave(function(){ setTimeout(function(){ if (swal && swal.close) swal.close(); mvc.go("#scenario-ratequote.0"); },500) }); } else { let vars = {}; for (let i=0; i < fields.length; i++) { let field = fields[i]; if (field.type === "head") continue; let _val = txt(`#rq_${field.id}`); let _def = $(`#rq_${field.id}`).data("placeholder"); if (_def !== false && `${_def}` === `${_val}`) { _val = ""; } if (field.type === "none") { continue; } else if (field.type === "scen") { if (_val.trim().length === 0) { continue; } vars[`${field.scenario}`] = _val; } else { vars[`rq_${field.id}`] = _val; } } vars.rq_rate_table = JSON.stringify(obj); vars.rq_custom_table = JSON.stringify((function(){ let rv = []; let customs = $(".rq_custom_field"); for (let i=0; i < customs.length; i++) { let $item = $(customs[i]); let sec = $item.data("sec"); let ii = $item.data("i"); let mismo_sec = $item.data("mismo_sec"); let lbl = $item.find(".rq_input.lbl").val(); let val = $item.find(".rq_input.val").val(); let type = $item.find(".rq_input.type").val(); let qm = $item.find(".rq_input.qm").val(); let apr = $item.find(".rq_input.apr").val(); let calctype = $item.find(".rq_input.calctype").val(); let perc = $item.find(".rq_input.perc").val(); let months = $item.find(".rq_input.months").val(); let monthly = $item.find(".rq_input.monthly").val(); rv.push({ sec : sec, i : ii, lbl : lbl, val : val, mismo_sec : mismo_sec, type : type, qm : qm, apr : apr, calctype : calctype, months : months, monthly : monthly, perc : perc }); } return rv; })()); /** * apply changes during the cog */ $("#body-container").LoadingOverlay("show"); vars.saved_at = 6108; $.post(`/api/chatbot/setRateOverrides/${mar.ID}/${version}`, vars, function(da){ $.get(`/api/chatbot/recalculateVersion/${mar.ID}/${version}`, function(da){ if (da.new_status !== 0) { $("#body-container").LoadingOverlay("hide",true); elaineui.swalprompt({ title : "Error", txt : `There was an error calculating this loan. you will be guided through a process to return to the last working version`, ok : "continue", okfn : function() { mar.revert_to_last_working_version(mar.ID,version); }, cancel : false, cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } }); return; } /* -- update scenario IF this is the selected offer -- */ MAR.ifOpt(da, "sc_obj", function(sco){ for (x in sco) { setScenario_data(x, sco[x]); } }); mar.fakesave(function(){ if (fn) fn(); $("#body-container").LoadingOverlay("hide",true); // setTimeout(function(){ // if (swal && swal.close) swal.close(); // mar.tmp_was_recalculated = `#${page}.${version}`; // mvc.go(`#${page}.${version}`); // },500); }); }); }); } } elaineui.swalprompt({ title : "Customize loan", txt : `
    ${h}
    `, ok : "Continue", okfn : function() { mar.tmp_loiar_apply_fn(function(){ setTimeout(function(){ if (swal && swal.close) swal.close(); mar.tmp_was_recalculated = `#${page}.${version}`; mvc.go(`#${page}.${version}`); },500); }); return; mar.tmp_editliabilities_block.read(); mar.tmp_editincome_block.read(); mar.tmp_editreo_block.read(); let lia = mar.tmp_editliabilities_block.gettotals(); let incs = mar.tmp_editincome_block.gettotals(); let reos = mar.tmp_editreo_block.gettotals(); setScenario_data("rough_liabilities",lia.pmt_exmort); setScenario_data("rough_liabilities_po",lia.bal_payoff); setScenario_data("rough_liabilities_pooc",lia.bal_payoff_oc); setScenario_data("rough_qual_income",incs.total); let obj = {}; for (x in RS) { let itm = RS[x]; let val = []; for (let i=0; i < itm.cols.length; i++) { let _val = $(`div.ratequote_popup #${x}_${i}`).val(); let _def = $(`div.ratequote_popup #${x}_${i}`).data("placeholder"); if (_def !== false && `${_def}` === `${_val}`) { _val = ""; } if (_val.trim().length === 0) { val.push(""); } else { val.push(num(_val)); } } obj[x] = val; } if (version === "" || version === false) { let vars = {}; for (let i=0; i < fields.length; i++) { let field = fields[i]; if (field.type === "head") continue; let _val = txt(`#rq_${field.id}`); let _def = $(`#rq_${field.id}`).data("placeholder"); if (_def !== false && `${_def}` === `${_val}`) { _val = ""; } if (field.type === "scen") { if (_val.trim().length === 0) { continue; } setScenario_data(`${field.scenario}` , _val); } else { setScenario_data(`rq_${field.id}` , _val); } } setScenario_data("rq_rate_table", obj); $("#body-container").LoadingOverlay("show"); mar.fakesave(function(){ setTimeout(function(){ if (swal && swal.close) swal.close(); mvc.go("#scenario-ratequote.0"); },500) }); } else { let vars = {}; for (let i=0; i < fields.length; i++) { let field = fields[i]; if (field.type === "head") continue; let _val = txt(`#rq_${field.id}`); let _def = $(`#rq_${field.id}`).data("placeholder"); if (_def !== false && `${_def}` === `${_val}`) { _val = ""; } if (field.type === "none") { continue; } else if (field.type === "scen") { if (_val.trim().length === 0) { continue; } vars[`${field.scenario}`] = _val; } else { vars[`rq_${field.id}`] = _val; } } vars.rq_rate_table = JSON.stringify(obj); vars.rq_custom_table = JSON.stringify((function(){ let rv = []; let customs = $(".rq_custom_field"); for (let i=0; i < customs.length; i++) { let $item = $(customs[i]); let sec = $item.data("sec"); let ii = $item.data("i"); let mismo_sec = $item.data("mismo_sec"); let lbl = $item.find(".rq_input.lbl").val(); let val = $item.find(".rq_input.val").val(); let type = $item.find(".rq_input.type").val(); let qm = $item.find(".rq_input.qm").val(); let apr = $item.find(".rq_input.apr").val(); let calctype = $item.find(".rq_input.calctype").val(); let perc = $item.find(".rq_input.perc").val(); let months = $item.find(".rq_input.months").val(); let monthly = $item.find(".rq_input.monthly").val(); rv.push({ sec : sec, i : ii, lbl : lbl, val : val, mismo_sec : mismo_sec, type : type, qm : qm, apr : apr, calctype : calctype, months : months, monthly : monthly, perc : perc }); } return rv; })()); /** * apply button in the cog popup */ $("#body-container").LoadingOverlay("show"); vars.saved_at = 6250; $.post(`/api/chatbot/setRateOverrides/${mar.ID}/${version}`, vars, function(da){ $.get(`/api/chatbot/recalculateVersion/${mar.ID}/${version}`, function(da){ if (da.new_status !== 0) { $("#body-container").LoadingOverlay("hide",true); elaineui.swalprompt({ title : "Error", txt : `There was an error calculating this loan. you will be guided through a process to return to the last working version`, ok : "continue", okfn : function() { mar.revert_to_last_working_version(mar.ID,version); }, cancel : false, cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } }); return; } /* -- update scenario IF this is the selected offer -- */ MAR.ifOpt(da, "sc_obj", function(sco){ for (x in sco) { setScenario_data(x, sco[x]); } }); /** * here we need to apply scenario IF it is the primary */ mar.fakesave(function(){ setTimeout(function(){ if (swal && swal.close) swal.close(); mar.tmp_was_recalculated = `#${page}.${version}`; mvc.go(`#${page}.${version}`); },500); }); }); }); } }, cancel : "Cancel", cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } }); mar.tmp_initial_scenario = 0; mar.tmp_loiar_load_fn = function(no_scroll_top = false){ let lin_indent = function(c1,c2,c3) { return `
    `+ // `
     ${c1}
    `+ `
    ${c1}
    `+ `
    ${c2}
    `+ `
    ${c3}
    `+ `
     
    `+ `
    `; } let lin_head = function(c1,c2,c3) { return `
    `+ `
    ${c1}
    `+ `
    ${c2}
    `+ `
    ${c3}
    `+ `
     
    `+ `
    `; } let lin_num = function(val) { let fval = elaineui.format(`cur_nodollar`,val); let rval = `$${fval}`; return rval; } let lin_editable_elm = function(id,val) { return `
    ${lin_num(val)}
    `; } let lin_reo = function(obj = {}) { let h = ``; h += `
    `+ `
     Address
    `+ `
    ${MAR.addressToString(obj.address)}
    `+ `
     
    `+ `
    `; h += `
    `+ `
     Value
    `+ `
    ${elaineui.format("cur_flx_l",obj.val)}
    `+ `
     
    `+ `
     
    `+ `
    `; h += `
    `+ `
     Mortgage(s)
    `+ `
    ${obj.mort}
    `+ `
     
    `+ `
    `; // h += `
    `+ // `
     DBG
    `+ // `
    ${obj.dbg}
    `+ // `
     
    `+ // `
    `; if (obj.gross_rental !== 0) { h += `
    `+ `
     Income
    `+ `
    ${elaineui.format("cur_flx_l",obj.gross_rental)}
    `+ `
     
    `+ `
     
    `+ `
    `; if (obj.income < 0) { h += `
    `+ `
     Income Used
    `+ `
     
    `+ `
    ${elaineui.format("cur_flx_l",0)}
    `+ `
     
    `+ `
    `; } else { let perc = ~~((obj.income/obj.gross_rental)*100) h += `
    `+ //`
     Income Used (${elaineui.format("perc",perc)}) ${obj.rentdec}
    `+ `
     Income Used
    - ${obj.rentdec}
    `+ `
     
    `+ `
    ${elaineui.format("cur_flx_l",obj.income)}
    `+ `
     
    `+ `
    `; } } h += `
    `+ `
     Mortgage Pmt.
    `+ `
    ${elaineui.format("cur_flx_l",obj.pmt)}
    `+ `
     
    `+ `
     
    `+ `
    `; h += `
    `+ `
     Insurance
    `+ `
    ${(typeof obj.ins === "string") ? obj.ins : elaineui.format("cur_flx_l",obj.ins)}
    `+ `
     
    `+ `
     
    `+ `
    `; h += `
    `+ `
     Tax
    `+ `
    ${(typeof obj.tax === "string") ? obj.tax : elaineui.format("cur_flx_l",obj.tax)}
    `+ `
     
    `+ `
     
    `+ `
    `; h += `
    `+ `
     hoa
    `+ `
    ${elaineui.format("cur_flx_l",obj.hoa)}
    `+ `
     
    `+ `
     
    `+ `
    `; h += `
    `+ `
     Total Outgoing
    `+ `
     
    `+ `
    ${elaineui.format("cur_flx_l",obj.totalout)}
    `+ `
     
    `+ `
    `; h += `
    `+ `
     ${obj.asslib}
    `+ `
     
    `+ `
    ${elaineui.format("cur_flx_l",obj.total)}
    `+ `
     
    `+ `
    `; // h += `
    `+ // `
     Ass/Lia
    `+ // `
    ${obj.asslib}
    `+ // `
     
    `+ // `
    `; h = `
    ${h}
    `; return h; } $.get(`/api/chatbot/getRateOverrides/${mar.ID}/${version}`, function(da){ mar.answers.v2.liabilities = da.app_lia; elaineui.waitForElementToDisplay("div.ratequote_popup", 100, function(){ $(`div.ratequote_popup`).click(function(e){ console.error(`rq popup clicked`,e.target); let $elm = $(e.target); /* clicked element within the popup */ if ($elm.data(`editable`) === `y`) { console.error(`rq popup clicked - Editable`,$elm); let $inp = $elm.find(`input`); let $e2e = $elm.find(`.elm-to-edit`); let $e2ev = $elm.find(`.elm-to-edit .val`); let $e2ei = $elm.find(`.inp`); $e2e.addClass(`x-hide-imp`); $e2ei.removeClass(`x-hide-imp`); // $inp.prop(`type`,`text`); if ($inp.hasClass(`onch`) === false) { $inp.change(function(){ $e2ev.html(elaineui.format(`cur_nodollar`,$(this).val())); }); $inp.on(`blur`,function(){ $e2ev.html(elaineui.format(`cur_nodollar`,$(this).val())); $e2e.removeClass(`x-hide-imp`); $e2ei.addClass(`x-hide-imp`); // $inp.prop(`type`,`hidden`); }); } $inp.focus(); } }); let febe = MAR.getOpt(da, "febe", {}); mar.tmp_cog_febe = febe; (function(){ let obj = { febe : febe }; let inc = MAR.getOpt(obj, "febe.inc", false); let inc_src = MAR.getOpt(obj, "febe.inc_src", false); let inc_det = MAR.getOpt(obj, "febe.inc_details", false); let lia = MAR.getOpt(obj, "febe.lia", false); let lia_src = MAR.getOpt(obj, "febe.lia_src", false); let cpull_appstatus = MAR.getOpt(obj, "febe.cpull_appstatus", ""); let c2c = MAR.getOpt(obj, "febe.c2c", false); let c2c_det = MAR.getOpt(obj, "febe._assets", false); let reo_det = MAR.getOpt(obj, "febe._reo", false); let reo_src = MAR.getOpt(obj, "febe.reo_src", false); let reo_inc = MAR.getOpt(obj, "febe.reo_inc", 0); let reo_lib = MAR.getOpt(obj, "febe.reo_lib", 0); setTimeout(function(){ mar.tmp_rq_reload_topgrid(febe, ".topgrid", off, mar.tmp_off_da); },1); mar.tmp_editincome_block.set_type(inc_src); mar.tmp_editliabilities_block.set_type(lia_src); mar.tmp_editreo_block.set_type(reo_src); (function add_c2c(){ let h = ``; let c2c_4_head = c2c; if (c2c_det.total !== 0) { let dm = c2c_det.detailmatrix; let dm_selfdec_tot = num(dm[dm.length-1][12]); let dm_cleared_tot = num(dm[dm.length-1][11]); let show_app_amount = true; if (dm_cleared_tot > 0) { show_app_amount = false; // h += `
    Assets - Verified - ${elaineui.format("cur",dm_cleared_tot)}
    `; h += lin_head(`Assets - Verified`,`Sub-total: `,elaineui.format("cur",dm_cleared_tot)); for ( let i=1; i < dm.length; i++) { let itm = dm[i]; let ass = MAR.assets.get('', itm[5]); if (itm[10] !== "Y") continue; let src = `Edit`; if (itm.length > 3 && itm[0] !== ``) { h += lin_indent(`${MAR.capitalizeFirstLetter(itm[0])} ${itm[2]} #${itm[6]}
    - ${MAR.sd.tp_disp_from_code_short(itm[13],"Verified up to ")}

    `,elaineui.format("cur_flx",itm[3]),`${src}`); } } } if (dm_selfdec_tot > 0) { show_app_amount = false; // h += `
    Assets - Self Declared - ${elaineui.format("cur",dm_selfdec_tot)}
    `; h += lin_head(`Assets - Self Declared`,`Sub-total: `,elaineui.format("cur",dm_selfdec_tot)); for ( let i=1; i < dm.length; i++) { let itm = dm[i]; let ass = MAR.assets.get('', itm[5]); if (itm[10] === "Y") continue; let src = `Edit`; if (itm.length > 3 && itm[0] !== ``) { h += lin_indent(`${MAR.capitalizeFirstLetter(itm[0])} ${itm[2]} #${itm[6]}`,elaineui.format("cur_flx",itm[3]),`${src}`); } } } c2c_4_head = dm[dm.length-1][7]; /* the total from the bottom line of the dm */ if (show_app_amount) { h += `
    Assets - Value in App - ${elaineui.format("cur",c2c)}
    `; } } else { h += lin_indent(`Self Declared`,lin_editable_elm(`available_c2c`,num(c2c)),``); } h += `

    `; $(`.hdr-c2c .val`).html(elaineui.format("cur_flx",c2c_4_head)); $(`.hdr-c2c .val`).html(elaineui.format("cur",c2c_4_head,"--.--")); h = `
    `+ `
    Assets
    ` + h + `
    Save
    `+ `
    `; $(`.body-c2c`).html(h); })(); (function add_income(){ if (inc_src === "scenario") { $(`.hdr-inc .val`).html(elaineui.format("cur_flx",inc)); $(`.hdr-inc .val`).html(elaineui.format("cur",inc,"--.--")); let h = ``; h += mar.tmp_editincome_block.render(); if (reo_inc !== 0) { h += `
    ** Income from REO ${elaineui.format("cur",reo_inc)}
    `; } h = `
    `+ `
    Income
    ${h}` + `
    Save
    `+ `
    `; $(`.body-inc`).html(h); mar.tmp_editincome_block.populate(); } else { $(`.hdr-inc .val`).html(elaineui.format("cur_flx",inc)); $(`.hdr-inc .val`).html(elaineui.format("cur",inc,"--.--")); let h = ``; let dm = inc_det.detailmatrix; let ordered_dm = []; let obj = false; for ( let i=1; i < dm.length; i++) { let itm = dm[i]; if (itm.length === 1) { obj = {}; ordered_dm.push(obj); obj.h5 = itm[0]; obj.selfdec = []; obj.cleared = []; // h += `
    ${itm[0]}
    `; } else if (itm.length > 7 && itm[0] !== ``) { let src = (itm[8] === "Y") ? "encompass": "self declared"; if (itm[9] === "Y") src = "cleared"; if (itm[10] !== "") src += `E`; if (itm[9] === "Y") { obj.cleared.push({ i : i, itm : itm }); } else { obj.selfdec.push({ i : i, itm : itm }); } // h += lin_indent(`${itm[0]}`,elaineui.format("cur_flx",itm[7]),`${src}`); } } for ( let i=0; i < ordered_dm.length; i++) { let obj = ordered_dm[i]; if (obj.selfdec.length > 0) { h += `
    ${obj.h5} - Self Declared
    `; for (let j=0; j < obj.selfdec.length; j++) { let itm = obj.selfdec[j].itm; let src = `Edit`; h += lin_indent(`${itm[0]}`,elaineui.format("cur_flx",itm[7]),`${src}`); } } if (obj.cleared.length > 0) { h += `
    ${obj.h5} - Verified
    `; for (let j=0; j < obj.cleared.length; j++) { let itm = obj.cleared[j].itm; let src = `Edit`; h += lin_indent(`${itm[0]}`,elaineui.format("cur_flx",itm[7]),`${src}`); } } } if (reo_inc !== 0) { h += `
    ** Income from REO ${elaineui.format("cur",reo_inc)}
    `; } h = `
    `+ `
    Income
    ${h}` + `
    Save
    `+ `
    `; $(`.body-inc`).html(h); mar.tmp_editincome_block.populate(); } })(); (function add_liabilities(){ $(`.hdr-lia .val`).html(elaineui.format("cur_flx",lia)); $(`.hdr-lia .val`).html(elaineui.format("cur",lia,"--.--")); let h = ``; h += mar.tmp_editliabilities_block.render(); let lia_type = mar.tmp_editliabilities_block.get_type(); if (reo_lib !== 0) { // h += `
    `; // // h += `
    `+ // `
    `+ // `Liability from REO ${elaineui.format("cur",reo_lib)}`+ // `

    `+ // `Mortgages and HELOCs are counted in with REO income to come up with an overall liability or asset score for all properties.`+ // `Full details are in the REO section.`+ // `
    `+ // `
     
    `+ // `
    `; // // h += `
    `; } if (cpull_appstatus === "") { h += `
    ** credit not requested yet**
    `; } else if (cpull_appstatus === "R" || cpull_appstatus === "P" || cpull_appstatus === "C") { h += `
    ** credit in the process of pulling **
    `; mar.tmp_rq_topgrid_warning(`Elaine is in the process of pulling credit.`,"yellow"); } else if (cpull_appstatus === "I") { h += `
    ** credit is imported **
    `; } else if (cpull_appstatus === "E") { h += `
    ** There is an error pulling credit !! **
    `; mar.tmp_rq_topgrid_warning(`There was an error pulling credit !!`,"red"); } let has_entered_dec = getScenario_data("__scenario_declarep3_0_passed",""); if (lia_type !== "ans" && has_entered_dec === "Y") { /** * only show if passed declarations 3 * * */ h += `
    `; h += `
     
    `; h += `
    Name
    `; h += `
    Ali/Child
    `; h += `
    IRS
    `; h += `
    edit
    `; h += `
    `; for (let i=0; i < MAR.applicants.count(); i++) { let appl = getApplicant_v2(i); let decl = getDeclaration_v2(i); let obl = MAR.getOpt(decl, "credit_obligated_to_pay_alimony_or_child",""); let obl_fu = MAR.getOpt(decl, "credit_obligated_to_pay_alimony_or_child_followup",""); let alm = MAR.getOpt(decl, "credit_alimony_amount",""); let irsdebt = MAR.getOpt(decl, "credit_irs_plan",""); h += `
    `; // h += `
    ${i}
    `; h += `
    ${appl.fn}
    `; h += `
    ${obl}
    `; // h += `
    ${obl_fu}
    `; // h += `
    ${alm}
    `; h += `
    ${irsdebt}
    `; h += `
    edit
    `; // h += `
    ${JSON.stringify(decl,null,4)}
    `; h += `
    `; } } if (lia_type === "ans") { h += `
    `; h += `
    Add liability manually
    `; h += `
    `; h += `
    `; h += `
    Add morgage via REO
    `; h += `
    `; } mar.tmp_rq_reload_liabilities = function() { // alert(`Reloading liabilities`); mar.tmp_loiar_toggle_changed = 10 mar.tmp_loiar_toggle_changed_fn(); } h += ``; h = `
    `+ `
    Liabilities
    ${h}` + `
    Save
    `+ `
    `; $(`.body-lia`).html(h); mar.tmp_editliabilities_block.populate(); })(); (function add_reo(){ $(`.hdr-reo .val`).html(elaineui.format('cur',0,` `)); if (reo_src === "scenario") { let h = ``; h += mar.tmp_editreo_block.render(); h = `
    `+ `
    REO
    ${h}` + `
    Save
    `+ `
    `; $(`.body-reo`).html(h); mar.tmp_editreo_block.populate(); } else { let h = ``; h += mar.tmp_editreo_block.get_phe_field(); // here is the details if (reo_det.items.length > 0) { let dm = reo_det.detailmatrix; h += `
    REO (entered data)
    `; for ( let i=1; i < dm.length; i++) { let itm = dm[i]; if (itm.length > 16 && itm[0] !== ``) { let item = MAR.reo.get(itm[11]); if (MAR.reo.isSubjectProperty(item.uuid) === true) { if (MAR.is_refi() === false) { continue; } } let mos = item.mortgageoptions.split(","); // let reo11 = ""; // let reo1c = 0; let reo11 = ""; let reocnt = 0; mos.filter(function(mo){ let loan = MAR.liabilities.getByUUID(mo); if (loan === false) return; // bal += loan.balance; // mth += loan.monthly; // esc += num(loan.escrow); // trm = num(loan.terms); // oda = loan.odate; reocnt++; if (loan.name === "") { loan.name = `Loan #${reocnt}` } // reo1c++; reo11 += ``; reo11 += `
    ${loan.name}
    `; reo11 += `Balance${elaineui.format("cur",loan.balance)}
    Pmt${elaineui.format("cur",loan.monthly)}`; reo11 += `
    Escrow${elaineui.format("cur",num(loan.escrow))}`; reo11 += `
    Term${elaineui.format("",~~(num(loan.terms)/12))}y`; reo11 += `
    Date${moment(loan.odate).format("MM/YYYY")}`; }) if (reo11 === "") { reo11 = "Mortgage Free"; } reo11 += `
    `; reo11 += `
    `; // reo11 += `
    ${itm[9]}
    `; /** * monthlybreakdown * hoa * insurance * monthly * mortgage * tax */ h += lin_reo({ address : itm[16], val : itm[12], mort : reo11, //itm[9], // pmt : itm[6], pmt : item.monthlybreakdown.o_mortgage, dbg : itm[9], rentdec : itm[29], //item.rent_dec_reason, // income : ((item.reo_use === "investment") ? item.rentalE : item.expected_rental), // total income from property after penalties income : itm[30], // gross_rental: ((item.reo_use === "investment") ? num(item.reo_rental_pm) : num(item.reo_expected_rental)), // total income from property gross_rental: itm[31], hoa : item.monthlybreakdown.hoa, // ins : item.monthlybreakdown.insurance, // tax : item.monthlybreakdown.tax, ins : item.monthlybreakdown.o_ins, tax : item.monthlybreakdown.o_tax, totalout : item.monthlybreakdown.monthly, // total outgoings inc_lib : itm[28], /* this is #13 but excluded refi subject property and purchase sold properties itm[13], */ asslib : itm[17], // "ASSSET" or "LIABILITY" total : itm[28] // total },`${itm[1]} ${itm[16]}`,elaineui.format("cur_flx",itm[15]),``); } } } h = `
    `+ `
    REO
    ${h}` + `
    Save
    `+ `
    `; $(`.body-reo`).html(h); } })(); })(); $(`.hdr-lp .val`).html(""); function set(elm, val, def) { let _val = (val === "") ? def : val; $f.find(`${elm}`).val(_val); $f.find(`${elm}`).data("placeholder",def); $f.find(`${elm}_def`).html(def); } let format_template_val_types = { rq_ltv : "perc2", rq_rate : "perc3", rq_mi : "perc3", rq_ufmi : "perc3", rq_points : "perc3", C_0 : "perc", G_0 : "perc", H_0 : "perc", rq_pp : "cur", rq_prog : "", rq_ignoremaxloan : "", rq_years : "" } function format_template_val(id, val) { return elaineui.format(MAR.getOpt(format_template_val_types, id, "cur"), val); } function f_dollars(fld) { $(fld).inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); } function f_fulldollars(fld) { $(fld).inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 0, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); } function f_perc(elm) { $(elm).css(`margin-right`,`0`); $(elm).css(`padding-right`,`20px`); $(elm).after(`%`); return; } function f_perc_old(fld) { $(fld).inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 3, autoGroup: true, suffix: '%', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); } function xpopdef(fld) { /* version of popdef without showing the difference */ let _val = $(fld).val(); let _def = $(fld).data("placeholder"); let _id = $(fld).prop("id"); if (_def === false) { $(`${fld}_def`).parent().parent().css(`display`,`none`); $(`${fld}_def`).parent().parent().addClass("x-hide-important") return; } if (_val === "" || `${_val}` === `${_def}`) { $(fld).val(_def); $(`${fld}_def`).parent().parent().css(`display`,`none`); $(`${fld}_def`).parent().parent().addClass("x-hide-important") console.error($(`${fld}_def`).parent().parent()); } else { $(`${fld}_def`).html(`- Template value "${format_template_val(_id,_def)}"`); $(`${fld}_def`).css(`color`,`#cc0000`); $(`${fld}_def`).css(`text-align`,`left`); /* -- hide instead of show -- */ $(`${fld}_def`).parent().parent().css(`display`,`none`); $(`${fld}_def`).parent().parent().addClass("x-hide-important") // $(`${fld}_def`).parent().parent().css(`display`,`unset`); // $(`${fld}_def`).parent().parent().removeClass("x-hide-important") } } mar.click_and_go = function(elm) { let $elm = $(elm); let pg = $elm.data(`pg`); if (typeof pg === "string" && pg.trim().length > 0) { try { swal.close(); } catch(E) {} mvc.go(`${pg}`); } } function popdef(fld) { let _val = $(fld).val(); let _def = $(fld).data("placeholder"); let _id = $(fld).prop("id"); if (_def === false) { // $(`${fld}_def`).css(`background-color`,`#0000cc66`); $(`${fld}_def`).parent().parent().css(`display`,`none`); $(`${fld}_def`).parent().parent().addClass("x-hide-important") return; } if (_val === "" || `${_val}` === `${_def}`) { $(fld).val(_def); // $(`${fld}_def`).html(``); $(`${fld}_def`).parent().parent().css(`display`,`none`); $(`${fld}_def`).parent().parent().addClass("x-hide-important") console.error($(`${fld}_def`).parent().parent()); } else { // $(`${fld}_def`).html(`- Template value "${_def}" (${_id}) "${format_template_val(_id,_def)}"`); $(`${fld}_def`).html(`- Template value "${format_template_val(_id,_def)}"`); $(`${fld}_def`).css(`color`,`#cc0000`); $(`${fld}_def`).css(`text-align`,`left`); $(`${fld}_def`).parent().parent().css(`display`,`unset`); $(`${fld}_def`).parent().parent().removeClass("x-hide-important") } } let $f = $("div.ratequote_popup"); /* -- make the autocompletes on the cunstom fields -- */ while (scripts.length > 0) { let script_ = scripts.shift(); mar.tmp_add_mismo_autocomplete(script_[0],script_[1]); } /** * make the scenario */ (function scenario(){ mar.tmp_scen = da.scen; let ttype = MAR.getOpt(da, "scen.loan_type",""); let refi_opt = (ttype === "purchase") ? "" : MAR.getOpt(da, "scen.refi_options",""); if ($f.find("#rq_ttype").hasClass(`x-onchange`) === false) { $f.find("#rq_ttype").replaceWith(`
    `); if ($f.find("#rq_ttype").addClass(`x-onchange`)); } $f.find("#rq_ttype").val(ttype); $f.find("#rq_ttype_disp").html(mar._txt(`${ttype}_${refi_opt}`)); /* ---- OCCUPANCY --- */ let puse = MAR.getOpt(da, "scen.occupancy_type",""); if (puse === `occupancy_by_me`) puse = `p`; if (puse === `occupancy_secondhom`) puse = `s`; if (puse === `occupancy_investment`) puse = `i`; if ($f.find("#rq_puse").hasClass(`x-onchange`) === false) { $f.find("#rq_puse").replaceWith(``); $f.find("#rq_puse").on(`change`, function(){ let _val = $f.find("#rq_puse").val(); if (_val === `p`) { setScenario_data("occupancy_type",`occupancy_by_me`); $("#body-container").LoadingOverlay("show"); mar.fakesave(function(){ setTimeout(function(){ mar.tmp_loiar_toggle_changed = true; mar.tmp_loiar_toggle_changed_fn(false); },1000); }); } if (_val === `s`) { setScenario_data("occupancy_type",`occupancy_secondhom`); $("#body-container").LoadingOverlay("show"); mar.fakesave(function(){ setTimeout(function(){ mar.tmp_loiar_toggle_changed = true; mar.tmp_loiar_toggle_changed_fn(false); },1000); }); } if (_val === `i`) { setScenario_data("occupancy_type",`occupancy_investment`); $("#body-container").LoadingOverlay("show"); mar.fakesave(function(){ setTimeout(function(){ mar.tmp_loiar_toggle_changed = true; mar.tmp_loiar_toggle_changed_fn(false); },1000); }); } }); if ($f.find("#rq_puse").addClass(`x-onchange`)); } $f.find("#rq_puse").val(puse); /* ---- PROPERTY TYPE --- */ let ptype = MAR.getOpt(da, "scen.property_type",""); let monthly_rent= MAR.getOpt(da, "scen.monthly_rent",""); if ($f.find("#rq_ptype").hasClass(`x-onchange`) === false) { $f.find("#rq_ptype").replaceWith(`
    `); $f.find("#rq_ptype").on(`change`, function(){ let _val = $f.find("#rq_ptype").val(); setScenario_data("property_type",_val); // setScenario_data("property_type_other",property_type_other); // setScenario_data("monthly_rent",monthly_rent); $("#body-container").LoadingOverlay("show"); mar.fakesave(function(){ setTimeout(function(){ mar.tmp_loiar_toggle_changed = true; mar.tmp_loiar_toggle_changed_fn(false); },1000); }); }); if ($f.find("#rq_ptype").addClass(`x-onchange`)); } $f.find("#rq_ptype").val(ptype); if (puse === `i`) { if (monthly_rent === `` || num(monthly_rent) === 0) { $(`#rq_ptype_warning`).html(`
    ${atob(frm.svg_warning_icon)}
    You need to enter a rental value for an investment property in the app. Click to go enter new data. `); $(`#rq_ptype_warning`).addClass(`rq_warning_box`); $(`#rq_ptype_warning`).data(`pg`,`#scenario-occupancy`); $(`#rq_ptype_warning`).addClass(`handy`); $(`#rq_ptype_warning`).removeClass(`x-hide`); } else { $(`#rq_ptype_warning`).html(`Rent : ${monthly_rent}`); $(`#rq_ptype_warning`).removeClass(`rq_warning_box`); $(`#rq_ptype_warning`).data(`pg`,``); $(`#rq_ptype_warning`).removeClass(`handy`); $(`#rq_ptype_warning`).removeClass(`x-hide`); } } else if (ptype === `duplex` || ptype === `triplex` || ptype === `fourplex`) { if (monthly_rent === `` || num(monthly_rent) === 0) { $(`#rq_ptype_warning`).html(`
    ${atob(frm.svg_warning_icon)}
    You need to enter a rental value for a multifamily property in the app. Click to go enter new data. `); $(`#rq_ptype_warning`).data(`pg`,`#scenario-property`); $(`#rq_ptype_warning`).addClass(`rq_warning_box`); $(`#rq_ptype_warning`).addClass(`handy`); $(`#rq_ptype_warning`).removeClass(`x-hide`); } else { $(`#rq_ptype_warning`).html(`Rent : ${monthly_rent}`); $(`#rq_ptype_warning`).removeClass(`rq_warning_box`); $(`#rq_ptype_warning`).data(`pg`,``); $(`#rq_ptype_warning`).removeClass(`handy`); $(`#rq_ptype_warning`).removeClass(`x-hide`); } } else { $(`#rq_ptype_warning`).html(``); $(`#rq_ptype_warning`).removeClass(`rq_warning_box`); $(`#rq_ptype_warning`).removeClass(`handy`); $(`#rq_ptype_warning`).data(`pg`,``); $(`#rq_ptype_warning`).addClass(`x-hide`); } /* ---- FICO --- */ let cscore = MAR.getOpt(da, "scen.applicant1_cscore",""); if ($f.find("#rq_cscore").hasClass(`x-onchange`) === false) { $f.find("#rq_cscore").on(`change`, function(){ let _val = $f.find("#rq_cscore").val(); }); if ($f.find("#rq_cscore").addClass(`x-onchange`)); } $f.find("#rq_cscore").val(cscore); /* ---- Primary Housing expenses --- */ let phe = MAR.getOpt(da, "scen.primary_housing_expenses",""); if ($f.find("#rq_phe").hasClass(`x-onchange`) === false) { $f.find("#rq_phe").on(`change`, function(){ let _val = $f.find("#rq_phe").val(); setScenario_data("primary_housing_expenses",_val); $("#body-container").LoadingOverlay("show"); mar.fakesave(function(){ setTimeout(function(){ mar.tmp_loiar_toggle_changed = true; mar.tmp_loiar_toggle_changed_fn(false); },1000); }); }); if ($f.find("#rq_phe").addClass(`x-onchange`)); } $f.find("#rq_phe").val(phe); /* ---- LOCATION --- */ let county = MAR.getOpt(da, "scen.property_county",""); let countynum = getCounty_v2(county); let state = `fl`; let state_name = county.split(":")[0].split("|")[1].trim(); // "1011|FLORIDA : Bla county" -> FLORIDA let state_code = MAR.stateCode(state_name); // "FLORIDA" -> FL // if ($f.find("#rq_state").hasClass(`x-onchange`) === false) { // // $f.find("#rq_state").on(`change`, function(){ // let _val = $f.find("#rq_state").val(); // }); // if ($f.find("#rq_state").addClass(`x-onchange`)); // } $f.find("#rq_state").val(state_code); if ($f.find("#rq_county").hasClass(`x-onchange`) === false) { $f.find("#rq_county")[0].hidden = true; $f.find("#rq_county").data("hidden",true); $f.find("#rq_county").after(``) mar.tmp_update_county = function() { let _val = $f.find("#rq_county").val(); if (typeof _val === "string" && _val.indexOf("|") > -1) { _val = MAR.county_formatted(_val); } $f.find("#rq_county_disp").html(_val); } $f.find("#rq_county").on(`change`, function(){ mar.tmp_update_county(); }); if ($f.find("#rq_county").addClass(`x-onchange`)); } $f.find("#rq_county").val(countynum); setTimeout(function(){ mar.tmp_update_county(); },1); /* ---- VA --- */ let va = MAR.getOpt(da, "scen.va_active1",""); if ($f.find("#rq_va").hasClass(`x-onchange`) === false) { $f.find("#rq_va").replaceWith(`
    `); $f.find("#rq_va").on(`change`, function(){ let _val = $f.find("#rq_va").val(); setScenario_data("va_active1",_val); $("#body-container").LoadingOverlay("show"); mar.fakesave(function(){ setTimeout(function(){ mar.tmp_loiar_toggle_changed = true; mar.tmp_loiar_toggle_changed_fn(false); },1000); }); }); if ($f.find("#rq_va").addClass(`x-onchange`)); } $f.find("#rq_va").val(va); if (va === `Y`) { let va_e = MAR.getOpt(da, "scen.va_employment1",""); if (va_e === "") { $(`#rq_va_warning`).html(`
    ${atob(frm.svg_warning_icon)}
    Use the app to determine the ufmi Click to go enter new data`); // $(`#rq_va_warning`).html(frm.inline_warning_red(`Use the app to determine the ufmi`)) $(`#rq_va_warning`).addClass(`rq_warning_box`); $(`#rq_va_warning`).data(`pg`,`#scenario-veteran.0`); $(`#rq_va_warning`).addClass(`handy`); $(`#rq_va_warning`).removeClass(`x-hide`); } else { $(`#rq_va_warning`).html(``); $(`#rq_va_warning`).removeClass(`rq_warning_box`); $(`#rq_va_warning`).data(`pg`,``); $(`#rq_va_warning`).removeClass(`handy`); $(`#rq_va_warning`).addClass(`x-hide`); } } else { $(`#rq_va_warning`).html(``); $(`#rq_va_warning`).removeClass(`rq_warning_box`); $(`#rq_va_warning`).data(`pg`,``); $(`#rq_va_warning`).removeClass(`handy`); $(`#rq_va_warning`).addClass(`x-hide`); } /* ---- FTHB --- */ let fthb = (MAR.getOpt(da, "scen.has_any_applicant_owned_property_in_last_3_years","") === "Y") ? "N" : "Y"; if ($f.find("#rq_fthb").hasClass(`x-onchange`) === false) { $f.find("#rq_fthb").replaceWith(``); $f.find("#rq_fthb").on(`change`, function(){ let _val = $f.find("#rq_fthb").val(); if (_val === `Y`) { for (let i=0; i < getApplicantsNames_v2().length; i++) { setScenario_data(`has_applicant${i+1}_owned_property_in_last_3_years`,"N"); } setScenario_data(`has_any_applicant_owned_property_in_last_3_years`,"N"); } if (_val === `N`) { setScenario_data(`has_applicant1_owned_property_in_last_3_years`,"Y"); setScenario_data(`has_any_applicant_owned_property_in_last_3_years`,"Y"); } mar.fakesave(function(){ setTimeout(function(){ mar.tmp_loiar_toggle_changed = true; mar.tmp_loiar_toggle_changed_fn(false); },1000); }); }); if ($f.find("#rq_fthb").addClass(`x-onchange`)); } $f.find("#rq_fthb").val(fthb); $f.find("#rqh_scen_div").find(".row-def").addClass("x-hide-important"); (function county() { let county = MAR.getOpt(da, "scen.property_county",""); let countynum = getCounty_v2(county); txt("#rq_county",county); $("#rq_county").data("num",countynum); })(); })(); $f.find(".row-def").addClass("x-hide-important"); // let $f = $("div.ratequote_popup"); // $f.find("#rq_pp").val(MAR.getOpt(da,"data.purchase_target",$f.find("#rq_pp").val())); // $f.find("#rq_pp").data("placeholder",$f.find("#rq_pp").val()); // $f.find("#rq_pp_def").html(elaineui.format("cur",$f.find("#rq_pp").val())); // popdef("#rq_pp"); if (MAR.is_refi()) { (function hide_pp(){ $f.find("#rq_pp").val(""); $f.find("#rq_pp").parent().parent().addClass(`x-hide-imp`); $f.find("#rq_pp_def").val(""); $f.find("#rq_pp_def").parent().parent().addClass(`x-hide-imp`); })(); $f.find("#rq_refipp").val(MAR.getOpt(da,"data.rq_refipp","")); // var def = $f.find("#rq_refipp").val(); var def = MAR.getOpt(off, "_refi_current_value_o","") $f.find("#rq_refipp").data("placeholder",def); $f.find("#rq_refipp_def").html(elaineui.format("cur",def)); xpopdef("#rq_refipp"); f_dollars("#rq_refipp"); // loan value $f.find("#rqh_value").html(elaineui.format("cur",$f.find("#rq_refipp").val())); $f.find("#rq_refidebt").val(MAR.getOpt(da,"data.rq_refidebt","")); var def = MAR.getOpt(off, "_refi_current_debt_o","") $f.find("#rq_refidebt").data("placeholder",def); $f.find("#rq_refidebt_def").html(elaineui.format("cur",def)); xpopdef("#rq_refidebt"); f_dollars("#rq_refidebt"); $f.find("#rq_refigoal").val(MAR.getOpt(da,"data.rq_refigoal","")); var def = MAR.getOpt(off, "_refi_goal_o","") $f.find("#rq_refigoal").data("placeholder",def); $f.find("#rq_refigoal_def").html(elaineui.format("cur",def)); xpopdef("#rq_refigoal"); f_dollars("#rq_refigoal"); } else { $f.find("#rq_pp").val(MAR.getOpt(da,"data.purchase_target",$f.find("#rq_pp").val())); var def = MAR.getOpt(off, "_purchase_target_o","") $f.find("#rq_pp").data("placeholder",def); $f.find("#rq_pp_def").html(elaineui.format("cur",def)); xpopdef("#rq_pp"); f_dollars("#rq_pp"); (function hide_refi(){ $f.find("#rq_refipp").val(""); $f.find("#rq_refipp").parent().parent().addClass(`x-hide-imp`); $f.find("#rq_refipp_def").val(""); $f.find("#rq_refipp_def").parent().parent().addClass(`x-hide-imp`); $f.find("#rq_refidebt").val(""); $f.find("#rq_refidebt").parent().parent().addClass(`x-hide-imp`); $f.find("#rq_refidebt_def").val(""); $f.find("#rq_refidebt_def").parent().parent().addClass(`x-hide-imp`); // $f.find("#rq_refigoal").val(""); // $f.find("#rq_refigoal").parent().parent().addClass(`x-hide-imp`); // $f.find("#rq_refigoal_def").val(""); // $f.find("#rq_refigoal_def").parent().parent().addClass(`x-hide-imp`); })(); } // $f.find("#rq_refipp").val(MAR.getOpt(da,"data.rq_refipp","")); // $f.find("#rq_refipp").data("placeholder",$f.find("#rq_refipp").val()); // $f.find("#rq_refipp_def").html(elaineui.format("cur",$f.find("#rq_refipp").val())); // popdef("#rq_refipp"); // // $f.find("#rq_refidebt").val(MAR.getOpt(da,"data.rq_refidebt","")); // $f.find("#rq_refidebt").data("placeholder",$f.find("#rq_refidebt").val()); // $f.find("#rq_refidebt_def").html(elaineui.format("cur",$f.find("#rq_refidebt").val())); // popdef("#rq_refidebt"); // // $f.find("#rq_refigoal").val(MAR.getOpt(da,"data.rq_refigoal","")); // $f.find("#rq_refigoal").data("placeholder",$f.find("#rq_refigoal").val()); // $f.find("#rq_refigoal_def").html(elaineui.format("cur",$f.find("#rq_refigoal").val())); // popdef("#rq_refigoal"); set("#rq_rate", MAR.getOpt(da,"data.rq_rate",""), MAR.getOpt(off, "base_o","")) xpopdef("#rq_rate"); f_perc("#rq_rate"); // $f.find("#rq_rate").val(MAR.getOpt(da,"data.rq_rate","")); // $f.find("#rq_rate").data("placeholder",MAR.getOpt(off, "base","")); // $f.find("#rq_rate_def").html(elaineui.format("perc3",MAR.getOpt(off, "base",""))); if ($f.find("#rq_points").hasClass(`x-onchange`) === false) { $f.find("#rq_points").after(`
    `); $f.find("#rq_points_lbl").after(`
    `); $f.find(".rq_points_wrap").css("margin-bottom","0"); mar.tmp_update_points_total = function(){ let pts = num($(`#rq_points`).val()); let val = num($(`#rq_loanval`).val()) let tot = ~~(((pts-100) * val)/ 100); let $disp_elm = $f.find("#rq_points_tot_disp"); let $disp_lbl = $f.find("#rq_points_tot_disp_lbl"); if (tot === 0) { $disp_lbl.html(``); $disp_elm.html(``); $disp_elm.data(`val`,0); } else if (tot < 0) { $disp_lbl.html(`Client to Pay`); $disp_elm.html(elaineui.format(`cur`,tot * -1)); $disp_elm.data(`val`,tot); } else { $disp_lbl.html(`Client to Recieve`); $disp_elm.html(elaineui.format(`cur`,tot)); $disp_elm.data(`val`,tot); } } $f.find("#rq_points").on(`change`, function(){ mar.tmp_update_points_total(); }); $f.find("#rq_points").addClass(`x-onchange`); // $f.find(".rq_discount_wrap").css('margin-bottom','0px'); // $f.find(".rq_discount_wrap").css('min-height','22px'); //// $f.find("#rq_discount").css('border-color','#ffffff'); $f.find("#rq_points_tot_disp").css('border-color','#ffffff'); $f.find("#rq_points_tot_disp").css('margin-left','auto'); $f.find("#rq_points_tot_disp").css('border-top','1px solid #cccccc'); } (function() { let val = MAR.getOpt(da,"data.rq_points",""); if (val === "") { val = num(100 - MAR.getOptNum(off, "points")); } $f.find("#rq_points").val(val); })(); // $f.find("#rq_points").val(MAR.getOpt(da,"data.rq_points","")); // $f.find("#rq_points").data("placeholder",num(100 - MAR.getOptNum(off, "points"))); // xpopdef("#rq_points"); // f_perc("#rq_points"); setTimeout(function(){ mar.tmp_update_points_total(); },1); /** * non qm */ if ($f.find("#rq_nonqm").is("select") === false) { $f.find("#rq_nonqm").replaceWith(``) } $f.find("#rq_nonqm").val(MAR.getOpt(da,"data.rq_nonqm","N")); /** * no docs */ if ($f.find("#rq_nodocs").is("select") === false) { $f.find("#rq_nodocs").replaceWith(``) } $f.find("#rq_nodocs").val(MAR.getOpt(da,"data.rq_nodocs","N")); // $f.find("#rq_points_def").html(elaineui.format("perc3",100 - num(MAR.getOpt(off, "target_o")))); $f.find("#rq_points_def").html(elaineui.format("perc3",num(MAR.getOpt(off, "target_o")))); $f.find("#rq_points_abs").val(MAR.getOpt(da,"data.rq_points_abs","")); (function() { let _val = MAR.getOpt(da,"data.rq_prog",""); if (_val === "") { _val = MAR.getOpt(off, "prog",""); } $f.find("#rq_prog").val(_val); $f.find("#rq_prog_sel").val(_val); })(); // $f.find("#rq_prog").val(MAR.getOpt(da,"data.rq_prog","")); // $f.find("#rq_prog").data("placeholder",MAR.getOpt(off, "opayload.over_prog","")); // $f.find("#rq_prog_def").html(MAR.getOpt(off, "prog_f","")); // xpopdef("#rq_prog"); (function() { let _ltv = MAR.getOpt(da,"data.rq_ltv",""); if (_ltv === "") { _ltv = off.final_ltv; } $f.find("#rq_ltv").val(_ltv); })(); // $f.find("#rq_ltv").val(MAR.getOpt(da,"data.rq_ltv","")); // $f.find("#rq_ltv").data("placeholder",off.final_ltv); // $f.find("#rq_ltv").data("placeholder",off.opayload.ltv); // $f.find("#rq_ltv").data("placeholder",off.gp.base_ltv); // $f.find("#rq_ltv_def").html(elaineui.format("perc2",off.final_ltv)); // $f.find("#rq_ltv_def").html(elaineui.format("perc2",off.opayload.ltv)); // $f.find("#rq_ltv_def").html(elaineui.format("perc2",off.gp.base_ltv)); // xpopdef("#rq_ltv"); (function() { let val = MAR.getOpt(da,"data.rq_years",""); if (val === "") val = off.years; $f.find("#rq_years").val(val); // $f.find("#rq_years").data("placeholder",off.years); // $f.find("#rq_years").data("placeholder",30); // $f.find("#rq_years_def").html(off.years); // xpopdef("#rq_years"); })(); // for (let x of ["rq_prog_var","rq_name","rq_intonly"]) { // if ($f.find(`#${x}`).hasClass(`x-onchange`) === false) { // $f.find(`#${x}`).click(function(evt){ // // mar.tmp_manualpricing(evt); // }); // $f.find(`#${x}`).addClass(`x-onchange`); // } // } $f.find("#rq_intonly").val(MAR.getOpt(da,"data.rq_intonly","")); $f.find("#rq_prog_var").val(MAR.getOpt(da,"data.rq_prog_var","uwm")); $f.find("#rq_name").val(MAR.getOpt(da,"data.rq_name",off.title_name )); let original_hml = MAR.getOpt(off, "opayload.over_hml"); /* bn1 */ let original_bd = MAR.getOpt(off, "dbg_rate_rv.rv.outputs.bd_original"); /* -1 */ mar.tmp_original_bd = original_bd; $f.find("#rq_intonly_m").val(MAR.getOpt(da,"data.rq_intonly_m",MAR.getOptNum(off,"interestonly_m",0))); if ($f.find("#rq_amort_type").is("select") === false) { $f.find("#rq_amort_type").replaceWith(``) } $f.find("#rq_amort_type").val(MAR.getOptEmptyString(da,"data.rq_amort_type",off.amort_type)); $f.find("#rq_amort_m").val(MAR.getOpt(da,"data.rq_amort_m","")); $f.find("#rq_armfix_m").val(MAR.getOpt(da,"data.rq_armfix_m","")); $f.find("#rq_armvar").val(MAR.getOpt(da,"data.rq_armvar","")); $f.find("#rq_ratesheet_prog").val(``); // if ($f.find("#rq_ratesheet_prog").is("select") === false) { // let rq_ratesheet_prog = MAR.getOpt(da,"data.rq_ratesheet_prog",""); // let ratesheet_prog = MAR.getOpt(off,"ratesheet_prog",""); // let ratesheet_prog_auto = MAR.getOpt(off,"ratesheet_prog_auto",""); // let table_names = MAR.getOpt(off, "configs._br.table_names", ["standard"]); // let table_data = MAR.getOpt(off, "configs._br.table_data", {}); // // let is_auto = (ratesheet_prog === ratesheet_prog_auto); // let is_over = (rq_ratesheet_prog !== `` && rq_ratesheet_prog !== ratesheet_prog_auto); // // let opts = ``; // opts += ``; // for (let x of table_names) { // opts += ``; // } // // // $f.find("#rq_ratesheet_prog").replaceWith(``); // if (is_auto) { // $f.find("#rq_ratesheet_prog").val(``); // } else { // $f.find("#rq_ratesheet_prog").val(rq_ratesheet_prog); // } // } if ($f.find("#rq_ratesheet_prog1").is("select") === false) { let rq_ratesheet_prog = MAR.getOpt(da,"data.rq_ratesheet_prog",""); let ratesheet_prog = MAR.getOpt(off,"ratesheet_prog",""); let ratesheet_prog_auto = MAR.getOpt(off,"ratesheet_prog_auto",""); let table_names = MAR.getOpt(off, "configs._br.table_names", ["standard"]); let table_data = MAR.getOpt(off, "configs._br.table_data", {}); let is_auto = (ratesheet_prog === ratesheet_prog_auto); let is_over = (rq_ratesheet_prog !== `` && rq_ratesheet_prog !== ratesheet_prog_auto); let opts = ``; opts += ``; for (let x of table_names) { opts += ``; } $f.find("#rq_ratesheet_prog1").replaceWith(``); if (is_auto) { $f.find("#rq_ratesheet_prog1").val(``); $f.find("#rq_ratesheet_prog").val(``); } else { $f.find("#rq_ratesheet_prog1").val(rq_ratesheet_prog); $f.find("#rq_ratesheet_prog").val(rq_ratesheet_prog); } $f.find("#rq_ratesheet_prog1").change(function() { let new_val = $f.find("#rq_ratesheet_prog1").val(); $f.find("#rq_ratesheet_prog").val(new_val); $f.find("#rq_ratesheet_prog").change(); let new_sheet = MAR.getOpt(off, `configs._br.tables.${new_val}._custom`, ``); if (new_sheet !== ``) { new_sheet = JSON.parse(new_sheet, []); for (let j=0; j < new_sheet.length; j++) { let item = new_sheet[j]; let $fld = $(`.rq_custom_field_${item.sec}_${item.i}`); if (MAR.getOpt(item, `mismo_sec`,``) !== ``) { $fld = $(`.rq_custom_field_${item.mismo_sec}_${item.i}`); } $fld.find(".rq_input.lbl").val(item.lbl); $fld.find(".rq_input.val").val(item.val); $fld.find(".rq_input.type").val(item.type); $fld.find(".rq_input.qm").val(item.qm); $fld.find(".rq_input.apr").val(item.apr); $fld.find(".rq_input.calctype").val(item.calctype); $fld.find(".rq_input.perc").val(item.perc); $fld.find(".rq_input.months").val(item.months); $fld.find(".rq_input.monthly").val(item.monthly); } } /* force change */ mar.tmp_loiar_toggle_changed = 10 mar.tmp_loiar_toggle_changed_fn(); }); } if ($f.find("#rq_manual_grid").hasClass(`x-onchange`) === false) { $f.find("#rq_manual_grid").replaceWith(``); $f.find("#rq_manual_grid").addClass(`x-onchange`); } let mg = MAR.getOpt(da,"data.rq_manual_grid",false); $f.find("#rq_manual_grid").val(MAR.getOpt(da,"data.rq_manual_grid","N")); $f.find("#rq_manual_grid").change(); $f.find("#rq_dtif").val(MAR.getOpt(da,"data.rq_dtif","")); $f.find("#rq_dtib").val(MAR.getOpt(da,"data.rq_dtib","")); $f.find("#rq_maxloan").val(MAR.getOpt(da,"data.rq_maxloan","")); f_perc("#rq_dtif"); f_perc("#rq_dtib"); f_dollars("#rq_maxloan"); (function() { let Total_qm_points = MAR.getOpt(off,"pd.Total_qm_points",""); let qmpass = MAR.getOpt(off,"pd.qmpass",false); let qmpass_f = (qmpass) ? `Passed` : `Failed`; $(`#qm_div`).removeClass(`x-hide-imp`); if (qmpass) { $(`#qm_div`).html(`QM is at ${elaineui.format('perc3opt',Total_qm_points)} which means that QM is ${qmpass_f}`); $(`#qm_div`).removeClass(`red`); $(`#qm_div`).removeClass(`.warn_div`); } else { $(`#qm_div`).html(`
    QM Warning
    QM is at ${elaineui.format('perc3opt',Total_qm_points)} which means that QM is ${qmpass_f}`); $(`#qm_div`).addClass(`red`); $(`#qm_div`).addClass(`.warn_div`); } })(); (function() { let c2c = MAR.getOpt(off,"total_costs",""); $(`#c2c_div`).removeClass(`x-hide-imp`); $(`#c2c_div`).html(`Cash to close is ${elaineui.format('cur',c2c)}`); })(); $f.find("#rq_price_ts").val(MAR.getOpt(da,"data.rq_price_ts",off.ts)); if (!$f.find("#rq_price_ts").data("hidden")) { $f.find("#rq_price_ts")[0].hidden = true; $f.find("#rq_price_ts").data("hidden",true); $f.find("#rq_price_ts").after(``) $f.find("#rq_price_ts").on(`change:value`, function(){ let val = $f.find("#rq_price_ts").val(); if (val === ``) { $f.find("#rq_price_ts_disp").html(``); } else { let val_ts = moment(new Date(num(val))).calendar(null,{ sameDay: '[Today]', nextDay: '[Tomorrow]', nextWeek: 'dddd', lastDay: '[Yesterday]', lastWeek: '[Last] dddd', sameElse: 'DD/MM/YYYY' }); $f.find("#rq_price_ts_disp").html(`${val_ts}`); } }); } $f.find("#rq_price_ts").trigger(`change:value`); if ($f.find("#rq_src").is("select") === false) { $f.find("#rq_src").replaceWith(``) } $f.find("#rq_src").val(MAR.getOptEmptyString(da,"data.rq_src","int")); $f.find("#rq_ignoremaxloan").val(MAR.getOpt(da,"data.rq_ignoremaxloan","")); $f.find("#rq_mi").val(MAR.getOpt(da,"data.rq_mi","")); $f.find("#rq_mi").data("placeholder",MAR.getOpt(off, "final_mi_py_o","")); $f.find("#rq_mi_def").html(elaineui.format("perc3",MAR.getOpt(off, "final_mi_py_o",""))); xpopdef("#rq_mi"); $f.find("#rqh_prog").html(MAR.getOpt(off, "prog_f","")); // $f.find("#rqh_value").html(elaineui.format("cur",MAR.getOpt(off, "loanvalue",""))); // $f.find("#rqh_value").html(elaineui.format("cur",MAR.getOpt(off, "propertyvalue",""))); // $f.find("#rqh_loanvalue").html(elaineui.format("cur",MAR.getOpt(off, "loanvalue",""))); $f.find("#rqh_rate").html(elaineui.format("cur",MAR.getOpt(off, "pd.pmt",""))); $f.find("#rqh_ufmi").html(elaineui.format("cur",MAR.getOpt(off, "final_ufmi_fin",""))); $f.find("#rqh_mi").html(elaineui.format("cur",MAR.getOpt(off, "mi_pm",""))); $f.find("#rqh_tax").html(elaineui.format("cur",MAR.getOpt(off, "pd.taxpm_int",""))); $f.find("#rqh_hoi").html(elaineui.format("cur",MAR.getOpt(off, "pd.hoipm_int",""))); $f.find("#rqh_hoa").html(elaineui.format("cur",MAR.getOpt(off, "pd.hoapm_int",""))); $f.find("#rqh_p_tax").html(elaineui.format("cur",MAR.getOpt(off, "pd.taxpm_int",""))); $f.find("#rqh_p_ins").html(elaineui.format("cur",MAR.getOpt(off, "pd.hoipm_int",""))); $f.find("#rqh_p_hoa").html(elaineui.format("cur",MAR.getOpt(off, "pd.hoapm_int",""))); $f.find("#rqh_p_mi").html(elaineui.format("cur",MAR.getOpt(off, "mi_pm",""))); $f.find("#rqh_p_pmt").html(elaineui.format("cur",MAR.getOpt(off, "pd.pmt",""))); $f.find("#rqh_total").html(elaineui.format("cur",MAR.getOpt(off, "monthly_total",""))); $f.find("#rqh_total").css(`border-top`, `1px solid #666`); $f.find("#rqh_total").css(`margin-top`, `8px`); $f.find("#rqh_c2c").html(elaineui.format("cur",MAR.getOpt(off, "total_costs",""))); $f.find(".closing-cost-template-val").html(elaineui.format("cur",MAR.getOpt(off, "total_costs",""))); /** * P& I breakdown */ (function(){ let io = MAR.getOptNum(off, "interestonly_m",0); let h = ``; h += ``; h += ``; h += ``; h += ``; h += ``; h += ``; if (io > 0) { h += ``; h += ``; } else { h += ``; } h += `
    Loan amount${elaineui.format("cur",MAR.getOpt(off, "loanvalue",""))}
    Rate${elaineui.format("perc3",MAR.getOpt(off, "base",""))}
    Duration${MAR.getOpt(off, "years",30)*12}
    I/O months${MAR.getOpt(off, "interestonly_m","")}
     
    Initial Payment ${io} months${elaineui.format("cur",MAR.getOpt(off, "m_pmt_inc",""))}
    Consecutive Payments${elaineui.format("cur",MAR.getOpt(off, "m_apr_pmt_ex",""))}
    Payment${elaineui.format("cur",MAR.getOpt(off, "pd.pmt",""))}
    `; $f.find("#rqh_p_pmt_detail").html(h); })(); f_perc("#rq_mi"); $f.find("#rq_ufmi").val(MAR.getOpt(da,"data.rq_ufmi","")); $f.find("#rq_ufmi").data("placeholder",MAR.getOpt(off, "final_ufmi_py_o")); $f.find("#rq_ufmi_def").html(elaineui.format("perc3",MAR.getOpt(off, "final_ufmi_py_o"))); xpopdef("#rq_ufmi"); f_perc("#rq_ufmi"); $f.find("#rq_tax").val(MAR.getOpt(da,"data.rq_tax","")); $f.find("#rq_tax").data("placeholder",MAR.getOpt(off, "_tax_y_o")); $f.find("#rq_tax_def").html(elaineui.format("cur",MAR.getOpt(off, "_tax_y_o"))); xpopdef("#rq_tax"); f_dollars("#rq_tax"); $f.find("#rq_hoi").val(MAR.getOpt(da,"data.rq_hoi","")); $f.find("#rq_hoi").data("placeholder",MAR.getOpt(off, "_hoi_y_o")); $f.find("#rq_hoi_def").html(elaineui.format("cur",MAR.getOpt(off, "_hoi_y_o"))); xpopdef("#rq_hoi"); f_dollars("#rq_tax"); $f.find("#rq_hoa").val(MAR.getOpt(da,"data.rq_hoa","")); $f.find("#rq_hoa").data("placeholder",MAR.getOpt(off, "_hoa_m_o")); $f.find("#rq_hoa_def").html(elaineui.format("cur",MAR.getOpt(off, "_hoa_m_o"))); xpopdef("#rq_hoa"); f_dollars("#rq_tax"); if (!$f.find("#rq_loanval").data("hidden")) { $f.find("#rq_loanval")[0].hidden = true; $f.find("#rq_loanval").data("hidden",true); $f.find("#rq_loanval").after(``) } $f.find("#rq_price_ts").trigger(`change:value`); let update_loanvalue = function() { let pp = $f.find("#rq_pp").val(); if (MAR.is_refi()) { pp = $f.find("#rq_refipp").val(); } let ltv = $f.find("#rq_ltv").val(); let lv = (num(pp) * (num(ltv)/100)); $f.find(`#rq_loanval_disp`).html(elaineui.format("cur",lv)); $f.find(`#rq_loanval_disp`).data(`val`,lv); // $f.find("#rqh_value").html(elaineui.format("cur",lv)); $f.find(`#rq_ltv_disp`).html(elaineui.format("perc",ltv)); $f.find("#rq_loanval").val(""); $f.find("#rq_loanval").data("placeholder", lv); xpopdef("#rq_loanval"); $f.find("#rq_comp").change(); } if (!$f.find("#rq_ltv").data("hidden")) { $f.find("#rq_ltv")[0].hidden = true; $f.find("#rq_ltv").data("hidden",true); $f.find("#rq_ltv").after(``) } $f.find("#rq_ltv").change(function(){ update_loanvalue(); }); $f.find("#rq_pp").change(function(){ update_loanvalue(); }); // update_loanvalue(); if (!$f.find("#rq_years").data("hidden")) { $f.find("#rq_years")[0].hidden = true; $f.find("#rq_years").data("hidden",true); $f.find("#rq_years").after(``) } let update_years = function() { let yrs = $f.find("#rq_years").val(); let mnths = num(yrs) * 12; $f.find(`#rq_years_disp`).html(`${mnths}`); // $f.find("#rq_years").data("placeholder", yrs); // xpopdef("#rq_years"); } $f.find("#rq_years").change(function(){ update_years(); }); update_years() /* -- compensation -- */ /* ---- FTHB --- */ let comp = MAR.getOpt(da,"data.rq_comp","2"); if (comp === "") comp = "2"; if ($f.find("#rq_comp").hasClass(`x-onchange`) === false) { $f.find("#rq_comp").replaceWith(`
    ${comp}%`+ `
    `+ `
    `+ `

    `+ `
    `); $f.find("#rq_comp_lbl").after(`
    -/- discounts
    `); // $f.find("#rq_comp").after(`

    `) $f.find("#rq_comp").on(`change`, function(){ let _val = $f.find("#rq_comp").val(); // let _loanval = $f.find("#rq_loanvalue").val(); let _loanval = num($f.find(`#rq_loanval_disp`).data(`val`)); let $disp_elm = $f.find("#rq_comp_disp"); let $disp_elm1 = $f.find("#rq_comp_perc_disp"); let commission = (num(_val)/100) * num(_loanval) $disp_elm1.html(`${_val}%`); $disp_elm.html(elaineui.format(`cur`,commission)); $disp_elm.data(`val`,commission); mar.tmp_update_discount_total(); }); $f.find("#rq_comp").addClass(`x-onchange`); $f.find(".rq_comp_wrap").css('margin-bottom','0px'); $f.find(".rq_comp_wrap").css('min-height','22px'); $f.find("#rq_comp_disp").css('border-color','#ffffff'); } $f.find("#rq_comp").val(comp); $f.find("#rq_comp_perc_disp").html(`${comp}%`); let discount = MAR.getOpt(da,"data.rq_discount","0"); // here if ($f.find("#rq_discount").hasClass(`x-onchange`) === false) { $f.find("#rq_discount").after(`

    `) $f.find("#rq_discount_lbl").after(`

    `); mar.tmp_update_discount_total = function(){ let alc = num($(`#additional_lender_credit_0`).val()); let com = num($(`#rq_comp_disp`).data(`val`)) let cli_com = num($(`#rq_points_tot_disp`).data(`val`)) let tot = (num(alc) + num(com)); let tot_cli = (num(alc)*-1 + num(cli_com)); let $disp_elm = $f.find("#rq_discount_tot_disp"); if (tot_cli === 0) { $(`#rq_discount_tot_disp_lbl`).html(`Net client to pay`) $disp_elm.html(elaineui.format(`cur`,tot_cli)); } else if (tot_cli < 0) { $(`#rq_discount_tot_disp_lbl`).html(`Net client to pay`) $disp_elm.html(elaineui.format(`cur`,tot_cli * -1)); } else if (tot_cli > 0) { $(`#rq_discount_tot_disp_lbl`).html(`Net client to receive`) $disp_elm.html(elaineui.format(`cur`,tot_cli)); } let $disp_elm2 = $f.find("#rq_comp_tot_disp"); $disp_elm2.html(elaineui.format(`cur`,tot)); } $f.find("#rq_discount").on(`blur`, function(){ setTimeout(function(){ mar.tmp_loiar_toggle_changed = 10 mar.tmp_loiar_toggle_changed_fn(); },100); }); $f.find("#rq_discount").on(`change`, function(){ let _val = $f.find("#rq_discount").val(); // let _loanval = num($f.find(`#rq_loanval_disp`).data(`val`)); // let $disp_elm = $f.find("#rq_discount_disp"); // let commission = (num(_val)/100) * num(_loanval) // // $disp_elm.html(elaineui.format(`cur`,commission)); // $(`#additional_lender_credit_0`).val(num(commission)*-1); $(`#additional_lender_credit_0`).val(~~(num(_val)*-1)); mar.tmp_update_discount_total(); // reload // mar.tmp_loiar_toggle_changed = 10 // mar.tmp_loiar_toggle_changed_fn(); }); $f.find("#rq_discount").addClass(`x-onchange`); $f.find(".rq_discount_wrap").css('margin-bottom','0px'); $f.find(".rq_discount_wrap").css('min-height','22px'); // $f.find("#rq_discount").css('border-color','#ffffff'); $f.find("#rq_discount_tot_disp").css('border-color','#ffffff'); $f.find("#rq_discount_tot_disp").css('margin-left','auto'); $f.find("#rq_discount_tot_disp").css('border-top','1px solid #cccccc'); f_dollars("#rq_discount"); } mar.tmp_update_discount = function() { let alc = num($(`#additional_lender_credit_0`).val()); $f.find("#rq_discount").val(num(alc*-1)); $f.find("#rq_discount").change(); mar.tmp_update_discount_total(); // let alc = num($(`#additional_lender_credit_0`).val()); // let _loanval = num($f.find(`#rq_loanval_disp`).data(`val`)); // let perc = (num(alc) / num(_loanval)) * 100 * -1; // if (perc < 0.3) perc = `0`; // else if (perc < 1.0) perc = `0.5`; // else if (perc < 1.5) perc = `1`; // else if (perc < 2.0) perc = `1.5`; // else if (perc < 2.5) perc = `2`; // else if (perc < 3.0) perc = `2.5`; // else if (perc < 3.5) perc = `3`; // // $f.find("#rq_discount").val(perc); // $f.find("#rq_discount").change(); // mar.tmp_update_discount_total(); }; setTimeout(mar.tmp_update_discount, 1); update_loanvalue(); mar.tmp_pg_loi_adjust_quote_oc_hide_fields(); (function(){ let prog = txt("#rq_prog"); let intonly = txt("#rq_intonly"); let years = txt("#rq_years"); if (prog !== "") { if (intonly === "Y") { if (years === "40") { txt("#rq_prog_sel","nonqm40"); } else { txt("#rq_prog_sel","nonqm"); } return; } txt("#rq_prog_sel",prog); } })(); /** * rates */ let table = MAR.getOpt(da,"data.rq_rate_table",{}); let ratesheet_used = MAR.getOpt(off, "ratesheet", R) for (x in RS) { let itm = RS[x]; for (let i=0; i < itm.cols.length; i++) { let defval = MAR.getOpt(table,`${x}`,""); if (typeof defval === "object" && defval.length > i) { defval = defval[i]; } // let val = R[x][i]; let val = MAR.getOpt(ratesheet_used[x],'${i}',``); $f.find(`#${x}_${i}_def`).html(val); $f.find(`#${x}_${i}`).data("placeholder",val); $f.find(`#${x}_${i}`).val(defval); popdef(`#${x}_${i}`); } } let customs = MAR.getOpt(da,"data.rq_custom_table",false); if (customs === false){ let new_sheet = MAR.getOpt(ratesheet_used, `_custom`, ``); if (new_sheet !== ``) { customs = JSON.parse(new_sheet, []); } else { customs = []; } } for (let i=0; i < customs.length; i++) { let item = customs[i]; let $fld = $(`.rq_custom_field_${item.sec}_${item.i}`); if (MAR.getOpt(item, `mismo_sec`,``) !== ``) { $fld = $(`.rq_custom_field_${item.mismo_sec}_${item.i}`); } else { let rows = $(`.rq_custom_field_Other_group`); for (let j=0; j < rows.length; j++) { $fld = $(`.rq_custom_field_Other_${j}`); if ($fld.find(".rq_input.lbl").val() === ``) break } } $fld.find(".rq_input.lbl").val(item.lbl); $fld.find(".rq_input.val").val(item.val); $fld.find(".rq_input.type").val(item.type); $fld.find(".rq_input.qm").val(item.qm); $fld.find(".rq_input.apr").val(item.apr); $fld.find(".rq_input.calctype").val(item.calctype); $fld.find(".rq_input.perc").val(item.perc); $fld.find(".rq_input.months").val(item.months); $fld.find(".rq_input.monthly").val(item.monthly); } mar.tmp_loiar_toggle_changed_onstart_fn(); mar.tmp_pg_loi_adjust_quote_enable_disable_mi_ufmi(); mar.tmp_rq_custom_rows_hide_show(); if ( mar.tmp_initial_scenario === 0) { mar.tmp_initial_scenario_key = mar.tmp_getscenario().key; } else { let _key = mar.tmp_getscenario().key; if (mar.tmp_initial_scenario_key !== _key) { let h = frm.inline_warning(`The scenario has changed - you must re-price`); // $f.find(`#rqh_value_div_head`).html(`
    ${h}
    `); } } mar.tmp_initial_scenario++; if (no_scroll_top !== true) { $(`.swal-modal`).parent().scrollTop(0) } }); }); } mar.tmp_loiar_load_fn(); } mar.pg_loi_adjust_costs = function(page, version) { let RS = MAR.getRatesheet().RS; let R = MAR.getRatesheet().R; if (typeof version === "undefined") version = ""; let h = ""; for (x in RS) { let itm = RS[x]; h += `
    ${itm.lbl}
    `; for (let i=0; i < itm.cols.length; i++) { h += `
    `; h += `
    `; h += `${itm.cols[i]} `; h += `
    `; h += `
    `; h += ``; h += `
    `; h += `
    `; } } h += `
    `+ `
    `+ `
    Clear values
    `+ `
    `; elaineui.swalprompt({ title : "2015 Itemization", txt : `
    ${h}
    `, ok : "Customize Fees", okfn : function() { let obj = {}; for (x in RS) { let itm = RS[x]; let val = []; for (let i=0; i < itm.cols.length; i++) { let _val = $(`div.ratequote_popup #${x}_${i}`).val(); if (_val.trim().length === 0) { val.push(""); } else { val.push(num(_val)); } } obj[x] = val; } if (version === "" || version === false) { /** * this is the standard */ setScenario_data("rq_rate_table", obj); $("#body-container").LoadingOverlay("show"); mar.fakesave(function(){ // recalc // rq_selected // reselect setTimeout(function(){ if (swal && swal.close) swal.close(); mvc.go(`#${page}`); // mvc.go("#scenario-ratequote.0"); },500) }); } else { $.post(`/api/chatbot/setRateOverrides/${mar.ID}/${version}`, { saved_at : 7207, rq_rate_table : JSON.stringify(obj) }, function(da){ setTimeout(function(){ if (swal && swal.close) swal.close(); mvc.go(`#${page}`); // mvc.go("#scenario-ratequote.0"); },500) }); } }, cancel : "Cancel", cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } }); $.get(`/api/chatbot/getRateOverrides/${mar.ID}/${version}`, function(da){ elaineui.waitForElementToDisplay("div.ratequote_popup", 100, function(){ let $f = $("div.ratequote_popup"); let table = MAR.getOpt(da,"data.rq_rate_table",{}); for (x in RS) { let itm = RS[x]; for (let i=0; i < itm.cols.length; i++) { let defval = MAR.getOpt(table,`${x}`,""); if (typeof defval === "object" && defval.length > i) { defval = defval[i]; } let val = R[x][i]; $f.find(`#${x}_${i}`).prop("placeholder",val); $f.find(`#${x}_${i}`).val(defval); } } // $f.find("#rq_rate").val(MAR.getOpt(da,"data.rq_rate","")); // $f.find("#rq_points").val(MAR.getOpt(da,"data.rq_points","")); // $f.find("#rq_prog").val(MAR.getOpt(da,"data.rq_prog","")); // $f.find("#rq_ltv").val(MAR.getOpt(da,"data.rq_ltv","")); // $f.find("#rq_mi").val(MAR.getOpt(da,"data.rq_mi","")); // $f.find("#rq_mi").prop("placeholder","0.93"); // $f.find("#rq_ufmi").val(MAR.getOpt(da,"data.rq_ufmi","")); // $f.find("#rq_ufmi").prop("placeholder","1.53"); // $f.find("#rq_tax").val(MAR.getOpt(da,"data.rq_tax","")); // $f.find("#rq_tax").prop("placeholder","1000"); // $f.find("#rq_hoi").val(MAR.getOpt(da,"data.rq_hoi","")); // $f.find("#rq_hoi").prop("placeholder","900"); // $f.find("#rq_hoa").val(MAR.getOpt(da,"data.rq_hoa","")); // $f.find("#rq_hoa").prop("placeholder","20"); }); }); } mar.pg["scenario-ratequote"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { mar.pg_accesscontrollerfn = function() { return "open"; } let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var loan_type = getV2_data("loan_type","purchase"); let refi = (loan_type !== "purchase"); let h = ""; if (refi) { h += frm.htitle(`Rate quote ${n0}`).render(); } else { h += frm.htitle(`Rate quote ${n0}`).render(); } h += frm.elaine("Below are our best automated options to tentatively choose from. Your loan officer will assist you with a fine tuned advice later.","er").render(); h += `
    `; h += `
    `; h += `
    `; h += `
    `; h += `
    `; let f_ratequote = MAR.getOpt(mar.accesscontroller.features(), "ratequote", false); mar.tmp_selprog_only_view = function(prog) { let prg = mar.tmp_progs[prog]; mar.fakesave(); $.get(`/api/chatbot/setRateFromRates?appid=${mar.ID}&prog=${prog}`, function(da){ if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_ratequote_0_passed_new","Y"); } mvc.go("#scenario-ratequote1.0"); }); } // mar.tmp_selprog = function(prog) { // let prg = mar.tmp_progs[prog]; // setScenario_data(`_ratequote_prog` , prog); // setScenario_data(`programme` , prog.split(`_`)[0]); // setScenario_data(`_ratequote_base` , prg._ratequote_base); // setScenario_data(`_ratequote_apr` , prg._ratequote_apr); // setScenario_data(`_ratequote_txt_co` , prg._ratequote_txt_co); // setScenario_data(`__scenario_ratequote_${applicantnum}_passed`,"Y"); // setScenario_data(`rq_selected`, prog); // mar.fakesave(); // $.get(`/api/chatbot/setRateFromRates?appid=${mar.ID}&prog=${prog}`, function(da){ // if (mar.WE_ARE_FROM_LOI === false) { // setScenario_data("__scenario_ratequote_0_passed_new","Y"); // } // mvc.go("#scenario-ratequote1.0"); // }); // // } mar.tmp_del_saved_rate = function(version) { $.get(`/api/chatbot/delSavedRate/${mar.ID}/${version}`, function(da){ mvc.go(`#scenario-ratequote`); }); } mar.tmp_delete_video = function(version) { $.get(`/api/chatbot/delSavedRateVideo/${mar.ID}/${version}`, function(da){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); } mar.tmp_show_saved_rate_again = function(prog) { $.get(`/api/chatbot/use_in_zero/${mar.ID}/${prog}`, function(da){ mar.tmp_show_saved_rate(0) }); } mar.tmp_show_saved_rate = function(version) { if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_ratequote_0_passed_new","Y"); } if (typeof version === "string" && version.startsWith("E")) { // alert("this should be a pdf"); // return; } if (mar.WE_ARE_FROM_LOI === false) { setScenario_data(`__scenario_ratequote_${applicantnum}_passed_cli`,"Y"); mar.fakesave(); } mvc.go(`#scenario-ratequote1.0.${version}`); } let button_text = ""; if (f_ratequote === false) { button_text = "Continue"; } if (mar.WE_ARE_FROM_LOI === true) { button_text = "Skip Offer"; } // h += uihelpers.cbuttonbar("Agree & continue",frm.addfunction(function(){ h += uihelpers.cbuttonbar(button_text,frm.addfunction(function(){ setScenario_data(`__scenario_ratequote_${applicantnum}_passed`,"Y"); if (mar.WE_ARE_FROM_LOI === false) { setScenario_data(`__scenario_ratequote_${applicantnum}_passed_cli`,"Y"); } if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_ratequote_0_passed_new","Y"); } mar.fakesave(); if (MAR.appnav.loanWasSubmitted()) { mvc.go("#lox"); } else { mvc.go("#declarations-p1."+applicantnum); } }),"Prev",frm.addfunction(function(){ // mvc.go("#scenario-pastproperty."+applicantnum); // mvc.go("#scenario-veteran."+applicantnum); mvc.go("#scenario-housingbudget."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or_times_run = 0; let or = function(){ let sp = mar.isallowed_scenario("#scenario-ratequote."+applicantnum); if (typeof sp === "string") { mvc.go(sp); return; } mvc.set("referrer_ratequote", `#scenario-ratequote.${applicantnum}`); if (or_times_run === 0) { $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").LoadingOverlay("show"); } else { // $("#result").html(""); // $("#result-head-lo").html(""); } console.error(`HB - getting saved rates`); $.get(`/api/chatbot/getSavedRates/${mar.ID}`, function(savedrates){ // (function(){ // let obj = {} // obj.febe = savedrates.febe; // liabilityBlock.render(obj); // $(`#liabilities-block`).html(obj.h); // })(); mar.encompass_enabled = savedrates.encompass_enabled; (async function(){ console.error(`HB - got saved rates`,savedrates); let is_there_a_saved_number_1 = (function(){ let da = MAR.getOpt(savedrates, "data", []); for (let i=0; i < da.length; i++) { let id = MAR.getOpt(da[i], "id", ""); if (id === "1") return da[i]; } return false; })(); let is_there_a_saved_0 = MAR.getOpt(savedrates, "saved_0", false); let list_of_wip = MAR.getOpt(savedrates, "wip", false); let saved_0_prog = MAR.getOpt(savedrates, "saved_0_prog", ``); let fake = ""; if (is_there_a_saved_number_1 !== false && mar.pg_tmp_am_i_the_lo() === false) { fake = "&fake=Y"; } else { if (mar.accesscontroller.getLast() === false || mar.accesscontroller.getLast().indexOf("ratequote") > -1) { fake = "&fake=Y&fetch_last=Y"; } } let test_not_possible = false; if (test_not_possible || (f_ratequote === false && is_there_a_saved_number_1 === false)) { let h = ""; // h = `Thank you for giving us the minimum info we need to work on a loan proposal. While I do that can you finish the application and document upload please? I need that to approve my proposal.`; h = `Based on this information we can give you a quote, but we cannot approve you yet. Please finish thelast part of the application, while I start working on a proposal, ok?`; $(`.mainbubble`).html(h); $("#result").html(``); $("#result-head-lo").html(""); $("#body-container").LoadingOverlay("hide",true); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); $.get(`/api/milestones/set?appid=${mar.ID}&run=y&codes=adhoc_app_trig_rq_notposs`, function(){ }); return; } let is_lo_param = (mar.pg_tmp_am_i_the_lo()) ? "&is_lo=y" : ""; console.error(`HB - getting rates`); let getSync = function(url) { return new Promise(function(resolve, reject){ $.get(url, function(da){ resolve(da); }); }); } let das = false; if (fake.indexOf("fetch_last=Y") > -1 && typeof mar.tmp_das === "object" ) { das = mar.tmp_das; } else { das = await getSync(`/api/chatbot/getRates?appid=${mar.ID}${is_lo_param}${fake}`); mar.tmp_das = das; } // $.get(`/api/chatbot/getRates?appid=${mar.ID}${is_lo_param}${fake}`, function(das){ console.error(`HB - got rates`,das); let h = ""; h += ``; let progs = []; mar.tmp_progs = {}; mar.tmp_progs_cnt = 0; mar.tmp_first_prog = false; mar.tmp_grid = []; mar.tmp_low_c2c = false; mar.tmp_progs_progs = progs; mar.tmp_grid_reasons = []; mar.tmp_grid_reasons_get = function(){ let h = ``; let qmfail = true; let c2cfail = true; let qmfail_c = 0; let c2cfail_c = 0; let otherfail_c = 0; for (let i=0; i < mar.tmp_grid_reasons.length; i++) { let reason = mar.tmp_grid_reasons[i]; let rv = mar.tmp_decide_what_is_the_most_likely_cause_of_failure_for_offer(reason); if (rv.r === `GRID-CS`) { return `${rv.m}`; } if (rv.r === `GRID`) { return `${rv.m}`; } if (rv.r !== `QM`) { qmfail = false; } if (rv.r !== `C2C`) { c2cfail = false; } if (rv.r === `QM`) { qmfail_c++; } if (rv.r === `C2C`) { c2cfail_c++; } if (rv.r === `OTHER`) { otherfail_c++; } } if (qmfail === true) { return `All Loans failed QM`; } if (c2cfail === true) { return `All Loans failed to meet the C2C target`; } h += `There were a mixture of failures: `; if (qmfail_c > 0) { h += `${qmfail_c} loans failed QM, ` } if (c2cfail_c > 0) { h += `${c2cfail_c} loans failed C2C, ` } if (otherfail_c > 0) { h += `${otherfail_c} loans failed for other reasons, ` } // h += `
    ${JSON.stringify(mar.tmp_grid_reasons, null, 4)}
    `; return h; } function addReason(descr, da) { let ob = mar.tmp_extract_reason_stub_from_loan(da); mar.tmp_grid_reasons.push(ob); } if (fake === "" || fake.indexOf("fetch_last=Y") > -1) { for (let x in das) { if (x === "rec_progs") continue; if (x.startsWith("is_")) continue; if (x.endsWith("dbg")) continue; progs.push(x); } if (list_of_wip !== false && list_of_wip.items.length > 0) { h += `
    `+ `
    Work in progress
    ` + `
    `; if (list_of_wip.items.length > 1) { h += `
    You have loans in progress , Click to view.
    `; } else { h += `
    You have a loan in progress , Click to view.
    `; } h += `
    `; list_of_wip.items.sort(function(a,b){ let an = (a.prog === saved_0_prog) ? 1 : 0; let bn = (b.prog === saved_0_prog) ? 1 : 0; return (an>bn) ? -1 : 0; }) for (let i=0; i < list_of_wip.items.length; i++) { let itm = list_of_wip.items[i]; let name = itm.name; let prog = itm.prog; if (prog === saved_0_prog) { name = `${name}`; } h += ``+ `
    `; } h += `
    `+ `
    `+ `
    `+ `
    `; h += frm.hr().render(); } // if (is_there_a_saved_0 === true) { // // // h += `
    `+ // `
    Work in progress
    ` + // `
    `+ // `
    Your loan proposal is still a work in progress, and if you have any unsaved changes, you can easily return to it by clicking this link.
    `+ // `
    ` + // ``+ // `
    `+ // `
    `+ // `
    `+ // `
    `; // } h += `
    `; h += `
    `; for (let i=0; i < progs.length; i++) { let prog_idx = progs[i]; let da = das[prog_idx]; let hml = (prog_idx.indexOf("_") > -1) ? prog_idx.split("_")[1] : ""; let hml2 = (prog_idx.split("_").length > 2) ? prog_idx.split("_")[2] : ""; let prog = prog_idx.split("_")[0]; // let cog = `settings`; let cog = ""; let Status = MAR.getOpt(da, "status",-1); if (num(Status) < 0 || MAR.getOpt(da,"calc", false) === false) { /** * we should probably re run because it can easily be a timing issue */ if (or_times_run === 0) { or_times_run++; or(); return; } /** * this one calculation must be impossible */ addReason(``,da); continue; } let status = MAR.getOpt(da, "calc.status",""); let status_c2c = MAR.getOpt(da, "calc.status_c2c",""); if (num(status) < 0) { let c2c = da.calc.total_costs; if (mar.tmp_low_c2c === false || c2c < mar.tmp_low_c2c) { mar.tmp_low_c2c = c2c; } addReason(`LOWC2C`,da); continue; /* must be cash to close */ h += `
    ${mar._txt(prog)}${cog}
    `; h += `
    `; h += `
    `; h += da.calc.txt1.join("

    "); h += `
    `; h += `
    `; h += `
    `; continue; } let markC2C_red = ""; if (num(status_c2c) < 0) { markC2C_red = "color:#cc0000;"; // let ratio = MAR.getOpt(da, "calc.c2c_ratio",""); // if (num(ratio) > 1.5) { // let c2c = da.calc.total_costs; // if (mar.tmp_low_c2c === false || c2c < mar.tmp_low_c2c) { // mar.tmp_low_c2c = c2c; // } // continue; /* must be cash to close */ // } else { // markC2C_red = "color:#cc0000;"; // } } mar.tmp_progs_cnt++; if (mar.tmp_first_prog === false) mar.tmp_first_prog = prog; let upbutton = `^`; let c2c_diff = (da.calc.total_costs - da.calc._liquid_assets); let c2c_diff_abs = Math.abs(da.calc.total_costs - da.calc._liquid_assets); let c2c_diff_und = (da.calc.total_costs < da.calc._liquid_assets) ? Math.abs(da.calc.total_costs - da.calc._liquid_assets) : 1000000; let saving = MAR.getOpt(da.calc, "_pd.saving_total",0); h += `
    `; h += `
    ${mar._txt(da.calc.prog)} (${hml} / ${hml2}) ${upbutton}${cog}
    `; // h += `
    ${upbutton}${cog}
    `; h += `
    `; h += `
    ${da.calc.txt_scen}
    `; // h += da.calc.txt1.join("

    "); h += `

    `; let c2c_lbl = (da.calc.total_costs < 0) ? "Cash to receive" : "Cash needed to Close"; h += ``; // h += ``; // h += ``; h += ``; h += ``; h += ``; h += ``; if (mar.pg_tmp_am_i_the_lo() === true) { MAR.ifOpt(savedrates, "febe", function(febe) { console.log(febe); let inc = MAR.getOpt(febe, "inc", false); let lia = MAR.getOpt(febe, "lia", false); if (inc === false || lia === false || inc === 0) return; let fe = 100 * (num(da.calc.monthly_total) / num(inc)); let be = 100 * (num(da.calc.monthly_total) / (num(inc) - num(lia))); fe = (fe > 0) ? `${elaineui.format("perc2",fe)}` : `! 100%`; be = (be > 0) ? `${elaineui.format("perc2",be)}` : `! 100%`; h += ``; }); } if (MAR.is_refi_limited_cashout() || MAR.is_refi_rat()) { h += ``; } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(da.calc, "status_qm", 0) < 0) { h += ``; } // h += ``; // h += ``; // h += ``; // h += ``; // h += ``; // h += ``; // h += ``; h += `
    Loan type${mar._txt(da.calc.prog)}
    Loan term30 years
    Total monthly payment${elaineui.format("cur",da.calc.monthly_total)}
    ${c2c_lbl}${elaineui.format("cur",da.calc.total_costs)}
    Rate (30 year fixed)${elaineui.format("perc3",da.calc.base)}
    APR${elaineui.format("perc3",da.calc.apr)}
    FE/BE${fe} / ${be}
    Lifetime savings${elaineui.format("cur",saving)}
    QM FAILED!
    Reduce points/fees below 3%
    ${elaineui.format("perc3",da.calc.status_qm_pts)}
    c2c diff${elaineui.format("cur",c2c_diff)}
    c2c diff abs value${elaineui.format("cur",c2c_diff_abs)}
    c2c diff und value${elaineui.format("cur",c2c_diff_und)}
    House value${elaineui.format("cur",da.calc.propertyvalue)}
    Loan value${elaineui.format("cur",da.calc.loanvalue)}
    Loan costs${elaineui.format("cur",da.calc.costs)}
    MI${elaineui.format("perc",da.calc.mi)}
    `; h += `
    `; // h += ``; h += ``; h += "
    "; if (1 === 2) { h += `
    `; h += da.calc.txt_co.join("

    "); h += "

    "; h += `
    ${da.calc.txt_ass.join("

    ")}
    `; h += "
    "; } h += `
    `; h += `
    `; h += `
    `; mar.tmp_grid.push({ i : i, prog : prog, prog_idx : prog_idx, ltv : da.calc.final_ltv, rate : da.calc.base, npoints : Math.abs(da.calc.points), apr : da.calc.apr, c2c : da.calc.total_costs, monthly : da.calc.monthly_total, c2c_diff : c2c_diff, c2c_diff_und : c2c_diff_und, c2c_diff_abs : c2c_diff_abs, saving : saving }); mar.tmp_progs[prog_idx] = { _prog : prog, _ratequote_base : num(parseFloat(da.calc.base,10).toFixed(2)), _ratequote_apr : da.calc.apr, _ratequote_txt_co : da.calc.txt_co }; } h += `
    `; } else { h += `
    `; } h += `
    Show more
    `; h += `
    `; h += `
    `; let saved_items = MAR.getOpt(savedrates, "data", []); if (is_there_a_saved_number_1 !== false && mar.pg_tmp_am_i_the_lo() === false) { // saved_items = [is_there_a_saved_number_1] } else if (mar.pg_tmp_am_i_the_lo() === false) { saved_items = []; } else { // nothing } saved_items.sort(function(a, b){ let as = MAR.getOpt(a, "selected", false)?1:0; let bs = MAR.getOpt(b, "selected", false)?1:0; return (as < bs || num(b.id) < num(a.id)) ? -1 : 1 }); let saved_items_dispcnt = 0; let saved_h = (function(){ let h = ``; let IDX1_key = ""; let saved_cnt = 0; for (let i=0; i < saved_items.length; i++) { let saved_item = saved_items[i]; let idx = saved_item.id; let name = ""; let selected = MAR.getOpt(saved_item, "selected", false); let title = MAR.getOpt(saved_item, "title", ""); let rq_name = MAR.getOpt(saved_item, "_name", ""); if (rq_name !== '') { title = rq_name; } if (idx === "0") continue; if (idx === "1") { // name = "Selected loan proposal"; name = `Saved offer #${idx} - ${title}`; IDX1_key = MAR.getOpt(saved_item, "off.key", "none"); } else if (idx === "2") { name = `Saved offer #${idx} - ${title}`; let IDX2_key = MAR.getOpt(saved_item, "off.key", "none"); if (IDX1_key === IDX2_key) { continue; // the IDX1 is the same as IDX2 so skip it } } else { saved_cnt++; name = `Saved offer #${idx} - ${title}`; } if (selected) { name = `Selected loan proposal #${idx} - ${title}`; } else { //continue; /* only show the selected */ } let p1 = MAR.getOpt(saved_item, "p1", false); let p2 = MAR.getOpt(saved_item, "p2", false); let video = MAR.getOpt(saved_item, "video", ""); let visibility = MAR.getOpt(saved_item, "visibility", ""); if (!mar.pg_tmp_am_i_the_lo() && !selected && visibility === "hidden") continue; let da = { calc : saved_item.off}; cog = ""; let status = MAR.getOpt(da, "calc.status",""); let upbutton = `^`; saved_items_dispcnt++; h += `
    `; h += `
    ${name}${cog}
    `; h += `
    `; h += `
    ${da.calc.txt_scen}
    `; h += `

    `; if (video) { let src = `/api/chatbot/video/${mar.ID}/${idx}`; let log = `/api/chatbot/video_log/${mar.ID}/${idx}`; h += ``; } let c2c_lbl = (da.calc.total_costs < 0) ? "Cash to receive" : "Cash needed to Close"; h += ``; h += ``; h += ``; h += ``; h += ``; if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(da.calc, "status_qm", 0) < 0) { h += ``; } h += `
    Total monthly payment${elaineui.format("cur",da.calc.monthly_total)}
    ${c2c_lbl}${elaineui.format("cur",da.calc.total_costs)}
    Rate (30 year fixed)${elaineui.format("perc3",da.calc.base)}
    APR${elaineui.format("perc3",da.calc.apr)}
    QM FAILED!
    Reduce points/fees below 3%
    ${elaineui.format("perc3",da.calc.status_qm_pts)}
    `; if (mar.pg_tmp_am_i_the_lo() === true) { h += `
    `; (function(){ let rqv = MAR.getOpt(saved_item, "trackdata.opened", ""); let rqvp = MAR.getOpt(saved_item, "trackdata.pdf", null); let rqvo = MAR.getOpt(saved_item, "trackdata.open", null); let rqvs = MAR.getOpt(saved_item, "trackdata.video", null); let rqve = MAR.getOpt(saved_item, "trackdata.video_end", null); if (rqvp === null) { if (rqv !== "") { h += `
    offer : VIEWED
    `; } } else if (rqvp === "-") { if (rqv !== "") { h += `
    offer : VIEWED
    `; } } else { h += `
    * BEING TRACKED
    `; if (rqvo === "") { h += `
    offer : not opened
    `; } else { h += `
    offer : OPENED
    `; } if (video) { if (rqvs === "") { h += `
    video : not started
    `; } else { h += `
    video : STARTED
    `; } if (rqve === "") { h += `
    video : not ended
    `; } else { h += `
    video : ENDED
    `; } } } })(); h += `
    `; } h += `
    `; if (mar.pg_tmp_am_i_the_lo() === true) { h += ``; if (!selected) { h += ``; } } h += ``; h += "
    "; h += `
    `; // if (p1 !== false) h += ``; // if (p2 !== false) h += ``; h += `
    `; h += `
    `; } if (h !== ``) { h = `${frm.htitle('Prepared Loans').render()}${h}`; $(`.dr-button.next-button`).html(`Continue`); if (mar.pg_tmp_am_i_the_lo() === true || f_ratequote === true) { h += frm.hr().render(); h += frm.htitle(`Calculated Loans`).render(); } } return h; })(); let hh = ""; h = `${hh}${h}`; /** * this is where the list of items comes */ $("#result").html(h); $("#result-saved").html(saved_h); if (mar.pg_tmp_am_i_the_lo()) { let cnt = 0; for (let i=0; i < saved_items.length; i++) { let saved_item = saved_items[i]; let idx = saved_item.id; if (idx === "0") continue; if (idx === "1") continue; cnt++; } // if (cnt > 0) { // // mar.tmp_show_results = function() { // $("#result").removeClass(`x-hide`); // } // mar.tmp_saved_offers = function() { // mvc.go("#general-ratequotes"); // } // let lh = `
    Rate QuotesPrepared Loans
    `; // // lh = frm.radio("displ_options","Show Following Loans:","","","",function(){ // let opt = radio("displ_options"); // if (opt === "rq") { // mar.tmp_show_results(); // } // if (opt === "pl") { // mar.tmp_saved_offers(); // } // },{ // rq : "Rate Quotes", // pl : "Prepared Loans" // }).render(); // // // // $("#result-head-lo").html(lh); // $("#result").addClass(`x-hide`); // $("#result-head-lo").find(".xx-radio").myradio(); // } } else { $("#result-head-lo").html("
    "); } $("#body-container").LoadingOverlay("hide",true); $("#body-container video").on("play", function(ev){ let $this = $(this); let log = $this.data('log'); $.get(`${log}?action=play`); }); $("#body-container video").on("pause", function(ev){ let $this = $(this); let log = $this.data('log'); $.get(`${log}?action=pause`); }); $("#body-container video").on("ended", function(ev){ let $this = $(this); let log = $this.data('log'); $.get(`${log}?action=ended`); }); (function(){ if (mar.tmp_grid.length === 0) { let def_prog = (mar.tmp_progs_progs.length > 0) ? mar.tmp_progs_progs[0] : ""; /* -- Create empty loan -- */ mar.tmp_create_loan_from_nothing = function() { $.get(`/api/chatbot/setRateFromRates?appid=${mar.ID}&prog=${def_prog}`, function(da){ if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_ratequote_0_passed_new","Y"); } mvc.go("#scenario-ratequote1.0"); // mvc.go("#declarations-p1."+applicantnum); }); } let but = (mar.pg_tmp_am_i_the_lo()) ? `




    ` : ``; if (def_prog === "") { but = "We cannot start a loan because there is an error and there are no non working loans."; } if (saved_items_dispcnt === 0) { if (mar.pg_tmp_am_i_the_lo()) { but += frm.inline_warning_red(`${mar.tmp_grid_reasons_get()}`); } if (MAR.is_refi_limited_cashout()) { $("#ltv-sel").html(`There are no options available. Please try a no cashout refi ${but}`); } else { if (mar.tmp_low_c2c === false) { $("#ltv-sel").html(`There are no options available. ${but}`); } else { $("#ltv-sel").html(`There are no options available. The lowest cash to close requirement is ${elaineui.format("cur",mar.tmp_low_c2c)} ${but}`); } } } return; } let ltvs = []; let fprogs = []; for (let i=0; i < mar.tmp_grid.length; i++) { let gr = mar.tmp_grid[i]; if (ltvs.indexOf(gr.ltv) < 0) ltvs.push(gr.ltv) if (fprogs.indexOf(gr.prog) < 0) fprogs.push(gr.prog) } ltvs.sort(function(a,b){ return (a < b) ? 1 : -1; }); let hh = ""; let opts = {}; opts.all = "Reccomended loans"; opts.mnr = "Most Neutral Rate"; opts.ldp = "Lowest cash to close"; opts.lmp = "Lowest overall payment"; if (ltvs.length > 0) { for (let i=0; i < ltvs.length; i++) { let ltv_key = ltvs[i]; if (~~(ltv_key) === ltv_key) { ltv_key = `${ltv_key}.0`; } if (~~(num(ltvs[i])*10) !== (num(ltvs[i])*10) ) { opts[`${ltv_key}`] = `On the loan limit ,(${elaineui.format("perc2",(100-ltvs[i]))} down)`; } else { opts[`${ltv_key}`] = `${elaineui.format("perc2",(100-ltvs[i]))} down`; } } } if (fprogs.length > 0) { for (let i=0; i < fprogs.length; i++) { opts[`prog_${fprogs[i]}`] = `${mar._txt(fprogs[i])} Loans`; } } if (mar.pg_tmp_am_i_the_lo()) { let def_prog = (mar.tmp_progs_progs.length > 0) ? mar.tmp_progs_progs[0] : ""; mar.tmp_create_loan_from_nothing = function() { $.get(`/api/chatbot/setRateFromRates?appid=${mar.ID}&prog=${def_prog}`, function(da){ if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_ratequote_0_passed_new","Y"); } mvc.go("#scenario-ratequote1.0"); // mvc.go("#declarations-p1."+applicantnum); }); } hh += `




    `; } hh += frm.hr().render(); hh += frm.radio("show_loans_with","Show Following Loans:","all","","",function(){ let val = radio("show_loans_with"); if (val === "ldp") { mar.tmp_select3(-1,"ldp"); } else if (val === "lmp") { mar.tmp_select3(-2,"lmp"); } else if (val === "mnr") { mar.tmp_select3(-3,"mnr"); } else if (val.startsWith("prog_")) { mar.tmp_select3(false,val.substring(5)); } else if (val === "all") { mar.tmp_select3(false,""); } else { mar.tmp_select3(num(val),"0"); } //oc(); },opts).render(); hh += "
    "; if (mar.pg_tmp_am_i_the_lo() === true) { $("#ltv-sel").html(hh); $("#ltv-sel").find(".xx-radio").myradio(); } })(); mar.tmp_select3_ltv = false; mar.tmp_select3_prog = ""; mar.tmp_select3 = function(ltv,selector) { $("#body-container").LoadingOverlay("show"); mar.tmp_select3_ltv = ltv; mar.tmp_select3_prog = ""; if (ltv === false && typeof selector === "string") { mar.tmp_select3_prog = selector; } $(`.x-ltv-line`).css("background-color", "unset"); $(`.x-ltv-${selector}`).css("background-color", "#cccccc"); select3(function(){ $("#body-container").LoadingOverlay("hide",true); }); } let lowest = function(arr, key, key1) { let rv = false; for (let i=0; i < arr.length; i++) { if (mar.tmp_select3_ltv !== false && mar.tmp_select3_ltv > -1 && num(arr[i].ltv) !== mar.tmp_select3_ltv) { continue; } if (mar.tmp_select3_prog !== "" && mar.tmp_select3_prog !== arr[i].prog) { continue; } if (rv === false) { rv = arr[i]; } else if (arr[i][key] < rv[key]) { rv = arr[i]; } else if (arr[i][key] === rv[key]) { if (typeof key1 === "string") { if (arr[i][key1] < rv[key1]) { rv = arr[i]; } } } } return rv; }; let lowestArray = function(arr, key, key1) { let rv = []; for (let i=0; i < arr.length; i++) { if (mar.tmp_select3_ltv !== false && mar.tmp_select3_ltv > -1 && num(arr[i].ltv) !== mar.tmp_select3_ltv) { continue; } if (mar.tmp_select3_prog !== "" && mar.tmp_select3_prog !== arr[i].prog) { continue; } if (MAR.getOpt(arr[i], "exclude", false) === true) { continue; } if (rv.length === 0) { rv = [arr[i]]; } else if (arr[i][key] < rv[0][key]) { rv = [arr[i]]; } else if (arr[i][key] === rv[0][key]) { if (typeof key1 === "string") { if (arr[i][key1] < rv[0][key1]) { rv = [arr[i]]; continue; } if (arr[i][key1] > rv[0][key1]) { continue; } } rv.push(arr[i]); } } return rv; }; let highestArray = function(arr, key, key1) { let rv = []; for (let i=0; i < arr.length; i++) { if (mar.tmp_select3_ltv !== false && mar.tmp_select3_ltv > -1 && num(arr[i].ltv) !== mar.tmp_select3_ltv) { continue; } if (mar.tmp_select3_prog !== "" && mar.tmp_select3_prog !== arr[i].prog) { continue; } if (MAR.getOpt(arr[i], "exclude", false) === true) { continue; } if (rv.length === 0) { rv = [arr[i]]; } else if (arr[i][key] > rv[0][key]) { rv = [arr[i]]; } else if (arr[i][key] === rv[0][key]) { if (typeof key1 === "string") { if (arr[i][key1] > rv[0][key1]) { rv = [arr[i]]; continue; } if (arr[i][key1] < rv[0][key1]) { continue; } } rv.push(arr[i]); } } return rv; }; let select3 = function(fn) { // $(".x-rateblock").removeClass("x-hide"); // hide all // } // let xselect3 = function(fn) { $(".x-rateblock").addClass("x-hide"); // hide all $(".x-rateblock").css("order",`9`); // set the order to 9 for all blocks $(".x-rateblock .low-rate").html(""); // hide all $(".x-rateblock .low-c2c").html(""); // hide all $(".x-rateblock .low-monthly").html(""); // hide all $(".x-rateblock .low-apr").html(""); // hide all $(".x-rateblock .low-saving").html(""); // hide all // if (!refi) { $(".x-rateblock .dropDownRadio .lbl").html(""); // hide all // } if (refi) { //$(".x-rateblock").removeClass("x-hide"); // hide all } if (MAR.is_refi_cashout()) { let goal = num(getScenario_data("refi_goal",0)); for (let i=0; i < mar.tmp_grid.length; i++) { let item = mar.tmp_grid[i]; item.exclude = false; let c2c = item.c2c; if (c2c >= 0) { item.exclude = true; } else if (Math.abs(c2c) < (goal*0.65)) { item.exclude = true; } } } let badge = ``; // let lr = lowest(mar.tmp_grid, "rate"); let lrA = lowestArray(mar.tmp_grid, "rate", "apr"); // let lc = lowest(mar.tmp_grid, "c2c"); let lcA = lowestArray(mar.tmp_grid, "c2c"); // let lm = lowest(mar.tmp_grid, "monthly"); let lmA = lowestArray(mar.tmp_grid, "monthly"); // let nr = lowest(mar.tmp_grid, "npoints"); let nrA = lowestArray(mar.tmp_grid, "npoints", "c2c_diff_abs"); let nrAU = lowestArray(mar.tmp_grid, "npoints", "c2c_diff_und"); let lmAP = lowestArray(mar.tmp_grid, "apr"); let lmSA = highestArray(mar.tmp_grid, "saving"); let $lrh = false; let lht_text = ""; let setOrder = function(elm, order) { let current_order = $(elm).css("order"); if (num(current_order) > num(order)) { $(elm).css(`order`,order); } } if (mar.tmp_select3_ltv === false || mar.tmp_select3_ltv > -1 ){ for (let lr of lrA) { $(`.x-rateblock.x-i-${lr.i}`).removeClass("x-hide").find(".low-rate").html(badge); setOrder(`.x-rateblock.x-i-${lr.i}`, 0); $lrh = $(`.x-rateblock.x-i-${lr.i} .dropDownRadio .lbl`); lrht_txt = $lrh.html(); if (lrht_txt === "") $lrh.html("Best Rate"); else $lrh.html(`${lrht_txt}, Rate`); } for (let lr of lmAP) { $(`.x-rateblock.x-i-${lr.i}`).removeClass("x-hide").find(".low-apr").html(badge); setOrder(`.x-rateblock.x-i-${lr.i}`, 0); $lrh = $(`.x-rateblock.x-i-${lr.i} .dropDownRadio .lbl`); lrht_txt = $lrh.html(); if (lrht_txt === "") $lrh.html("Best APR"); else $lrh.html(`${lrht_txt}, APR`); } if (MAR.is_refi_limited_cashout() || MAR.is_refi_rat()) { for (let lr of lmSA) { $(`.x-rateblock.x-i-${lr.i}`).removeClass("x-hide").find(".low-saving").html(badge); setOrder(`.x-rateblock.x-i-${lr.i}`, 0); $lrh = $(`.x-rateblock.x-i-${lr.i} .dropDownRadio .lbl`); lrht_txt = $lrh.html(); if (lrht_txt === "") $lrh.html("Best Saving"); else $lrh.html(`${lrht_txt}, Saving`); } } } if (mar.tmp_select3_ltv === false || mar.tmp_select3_ltv > -1 || mar.tmp_select3_ltv === -1){ for (let lc of lcA) { $(`.x-rateblock.x-i-${lc.i}`).removeClass("x-hide").find(".low-c2c").html(badge); setOrder(`.x-rateblock.x-i-${lc.i}`, 3); $lrh = $(`.x-rateblock.x-i-${lc.i} .dropDownRadio .lbl`); lrht_txt = $lrh.html(); if (lrht_txt === "") $lrh.html("Best Cash"); else $lrh.html(`${lrht_txt}, Cash`); } } if (mar.tmp_select3_ltv === false || mar.tmp_select3_ltv > -1 || mar.tmp_select3_ltv === -2){ for (let lm of lmA) { $(`.x-rateblock.x-i-${lm.i}`).removeClass("x-hide").find(".low-monthly").html(badge); setOrder(`.x-rateblock.x-i-${lm.i}`, 1); $lrh = $(`.x-rateblock.x-i-${lm.i} .dropDownRadio .lbl`); lrht_txt = $lrh.html(); if (lrht_txt === "") $lrh.html("Best Monthly"); else $lrh.html(`${lrht_txt}, Monthly`); } } if (mar.tmp_select3_ltv === false || mar.tmp_select3_ltv > -1 || mar.tmp_select3_ltv === -3){ for (let nr of nrA) { $(`.x-rateblock.x-i-${nr.i}`).removeClass("x-hide"); setOrder(`.x-rateblock.x-i-${nr.i}`, 4); $lrh = $(`.x-rateblock.x-i-${nr.i} .dropDownRadio .lbl`); lrht_txt = $lrh.html(); if (lrht_txt === "") $lrh.html("Most neutral rate"); else $lrh.html(`${lrht_txt}, Neutral rate`); } } if (mar.tmp_select3_ltv === false || mar.tmp_select3_ltv > -1 || mar.tmp_select3_ltv === -3){ for (let nr of nrAU) { $(`.x-rateblock.x-i-${nr.i}`).removeClass("x-hide"); setOrder(`.x-rateblock.x-i-${nr.i}`, 4); $lrh = $(`.x-rateblock.x-i-${nr.i} .dropDownRadio .lbl`); lrht_txt = $lrh.html(); if (lrht_txt === "") $lrh.html("Most neutral rate"); else $lrh.html(`${lrht_txt}, Neutral rate`); } } if (mar.tmp_select3_prog !== "") { for (let lr of mar.tmp_grid) { if (lr.prog !== mar.tmp_select3_prog) continue; $(`.x-rateblock.x-i-${lr.i}`).removeClass("x-hide"); setOrder(`.x-rateblock.x-i-${lr.i}`, 0); } } let $blocks = $(".x-rateblock"); // all the blocks if ($(".x-rateblock.x-hide").length === 0) { let $but = $(`#rq-showmoreloans`); $but.addClass("x-hide"); } mar.tmp_rq_showmoreloans = function(){ let $but = $(`#rq-showmoreloans`); if ($(".x-rateblock.x-hide").length > 0) { $(".x-rateblock.x-hide").addClass("x-was-hidden"); $(".x-rateblock.x-hide").removeClass("x-hide"); $but.html(`Show less loans`); } else if ($(".x-rateblock.x-was-hidden").length > 0) { $(".x-rateblock.x-was-hidden").addClass("x-hide"); $(".x-rateblock.x-was-hidden").removeClass("x-was-hidden"); $but.html(`Show more loans`); } } let labels = $(".x-rateblock .dropDownRadio .lbl"); for (let i=0; i < labels.length; i++) { let $lbl = $(labels[i]); if ($lbl.html() === "") $lbl.html($lbl.data(`txt`)); $lbl.html($lbl.data(`txt`)); } if (fn) fn(); } select3(); let _ratequote_prog = getScenario_data(`_ratequote_prog`, ""); if (_ratequote_prog === "" && mar.tmp_progs_cnt === 1) _ratequote_prog = mar.tmp_first_prog; /* if there is only one programme , select it */ radio("selectedprogram", _ratequote_prog) $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); })(); }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["scenario-ratequote0"] = (function(){ })(); mar.pg["scenario-ratequote1"] = (function(){ var VAL = 'N' var html = ""; function gettoday() { var today = new Date(); var dd = today.getDate(); var mm = today.getMonth() + 1; //January is 0! var yyyy = today.getFullYear(); if (dd < 10) { dd = '0' + dd; } if (mm < 10) { mm = '0' + mm; } var today = '('+mm + '/' + dd + '/' + yyyy+')'; return today; } function makeTable(off, version, recalculated, maximums = {}){ let h = ""; let mo = {}; let mortgage = mo; let purchace_price = MAR.getOpt(off, "propertyvalue",0); let max_loan = MAR.getOpt(off, "loanvalue",0); let final_ufmi_fin = MAR.getOpt(off, "ufmi_cost",0); let downpayment = (purchace_price - max_loan); mo.apr_rate_py = MAR.getOpt(off, "base",0); mo.rate = MAR.getOpt(off, "base",0); mo.apr = MAR.getOpt(off, "apr",0); mo.loan_duration = num(MAR.getOpt(off, "years",30)) * 12; mo.costsAA = off._costsAA; mo.costsA = off._costsA; mo.costsAA_ = off._costsAA_; mo.costsA_ = off._costsA_; mo.costATot = off._costATot mo.appsum4p = off._appsum4p; mo.appsum2 = off._appsum2; mo.appsum1c2c = (parseFloat(purchace_price,10) - parseFloat(max_loan,10)) + parseFloat(mo.costATot,10) - final_ufmi_fin; mo.pricing_price = off.points; // help mo.pricing_llpa = off.points; // help mo.buydown = 0; // help //point_cost h = ""; h += '
    '; h +='
    '; let mmr = mortgage.appsum2; console.warn("MMR!!: ",mmr); console.warn("mmr[0]: ",mmr[0]); let cog = `settings`; let rec = `tv`; cog = `${rec}${cog}`; if (mar.pg_tmp_am_i_the_lo() === false) { cog = ""; } mmr[0] = `hhy ESTIMATED MONTHLY PAYMENT ${cog}`; (function(){ let property_type = getScenario_data("property_type",""); let monthly_rent = num(getScenario_data("monthly_rent",0)); let occupancy_type = getScenario_data("occupancy_type",""); let is_primary = MAR.contains_string_ignore_case(occupancy_type, "by_me"); if (is_primary === true) { if (["duplex","triplex","fourplex"].indexOf(property_type) < 0) { /* cant rent out a sfr */ monthly_rent = 0; } } if (monthly_rent > 0) { mmr.push(`fbgm\tExpected Rental Income\t${monthly_rent}`); let net = ~~(off.monthly_total - monthly_rent) if (net < 0) { mmr.push(`fbg\tEst. Cashflow\t${Math.abs(net)}`); } else { mmr.push(`fbg\tNet Payments\t${net}`); } } })(); h += makeNewpopup(mmr, 'proposal', pieArray); //ok build new table here h += "
    "; let lin = function(lbl, val, fmt = false, cls = "", leftWidth = "") { let sty = ""; let row_sty = ""; let warning = false; if (typeof cls === "string") { if (cls === "cap") sty = "text-transform: capitalize;"; if (cls === "warn") row_sty = "background-color:#cc0000; color:#ffffff; font-weight:800;"; } h += `
    `; h += `
    `; h += lbl; h += "
    ";//end breakdown holder left h += `
    `; if (typeof fmt === "string" && fmt !== "") { h += elaineui.format(fmt,val); } else { h += val; } h += "
    ";//end breakdown holder left h += "
    ";//end rowholder } let linlo = function(lbl, val, fmt = false, cls = "", leftWidth = "") { let sty = ""; let row_sty = ""; let warning = false; if (typeof cls === "string") { if (cls === "cap") sty = "text-transform: capitalize;"; if (cls === "warn") row_sty = "background-color:#cc0000; color:#ffffff; font-weight:800;"; } h += `
    `; h += `
    `; h += lbl; h += "
    ";//end breakdown holder left h += `
    `; if (typeof fmt === "string" && fmt !== "") { h += elaineui.format(fmt,val); } else { h += val; } h += "
    ";//end breakdown holder left h += "
    ";//end rowholder } let is_refi = (off._pd.loantype.toLowerCase().indexOf("refi") > -1) || (off._pd.loantype.toLowerCase().indexOf("cashout") > -1); let is_refi_cashout = (off._pd.loantype.toLowerCase().indexOf("cashout") > -1); let is_refi_limited = (off._pd.loantype.toLowerCase().indexOf("limit") > -1); let is_refi_rat = (off._pd.loantype.toLowerCase().indexOf("rat") > -1); if (is_refi === false) { // Purpose Purchase // Property Duplex // Estimated Fico 750 // Occupancy Primary // // Purchase Price $ 390,000 // Downpayment 3.5% // Loan Amount $ 350,000 // Cash to Close $ 32,123 // // /B/Loan Information/B/ // Loan Type FHA // Rate 3.875% // APR 4.124% // Points (to pay) 0.695% // Loan term in months 360 lin(`Purpose` , "Purchase" , "", ""); lin(`Property` , off.ptype_f , "", ""); lin(`${getScenario_data("cs_state","Est.")} Fico` , off._pd.credit_score); if (off._pd.credit_score !== off._pd.o_credit_score) { lin("Credit score too low!" , off._pd.o_credit_score, "", "warn"); } lin(`Occupancy` , off.otype_f , "", ""); lin(`Purchase price` , off.propertyvalue, "cur", ""); lin(`Down payment (${elaineui.format("perc1",(100-off.ltv))})`, downpayment , "cur", "","width:70%;"); lin(`Base mortgage (${elaineui.format("perc1",off.ltv)} LTV)` , off.loanvalue, "cur", "cap","width:70%;"); if (num(off.final_ufmi_py) !== 0) { let final_ufmi_fin = num(MAR.getOpt(off, "final_ufmi_fin",0)); let total_loan = num(off.loanvalue) + num(final_ufmi_fin); lin("Financed MI" , final_ufmi_fin , "cur", ""); lin("Total Loan" , total_loan , "cur", ""); } lin((is_refi && num(off.total_costs) < 0) ? "Cash out amount" : "Cash to close" , off.total_costs , "cur", ""); h += "
    "; h += `
    Loan Information
    `; /** * here is the name of the programme */ MAR.ifOpt(off, "name", function(v) { if (v === ``) return; lin(`Loan name` ,off.name) }); MAR.ifOpt(off, "prog_var", function(v) { if (v === ``) return; lin(`Lender` ,off.prog_var) }); let amort_type = MAR.getOpt(off, "amort_type", "fixed"); if (amort_type === "arm") { lin(`Rate type` , "ARM") MAR.ifOpt(off, "armfix_m", function(v) { if (v === ``) return; lin(`ARM months Fixed` ,off.armfix_m) }); MAR.ifOpt(off, "armvar", function(v) { if (v === ``) return; lin(`ARM Yearly updates` ,off.armvar) }); } else if (amort_type === "fixed") { lin(`Rate type` , "Fixed") } else { lin(`Rate type` , amort_type) } lin(`Loan type` ,off.prog_f) lin(`Rate` , mortgage.rate , "perc3", ""); lin(`APR` , mortgage.apr , "perc3", ""); lin((num(off.po_cost) < 0)?"Points to receive":"Points" , off.po_cost , "perc3", ""); MAR.ifOpt(off, "closing_date", function(v) { if (v === ``) return; lin(`Est. closing date` , elaineui.format(`date`,off.closing_date)) }); lin(`Loan term in months` , off.years*12 , "", ""); // MAR.ifOpt(off, "rq_amort_m", function(v) { // if (v === ``) return; // lin(`Amortization (months)` ,off.rq_amort_m) // }); if (MAR.getOpt(off, "interestonly", "") === "Y") { lin("Interest only period" , `10y IO, fixed rate ${off.years}y` , "", ""); lin("Payment starting 121st month" , off.m_apr_pmt_ex , "cur", ""); lin("Prepayment penalty in first 3y" , `Max 3% of loan balance` , "", ""); } if (MAR.getOptNum(off, "interestonly_m", 0) > 0) { lin("Interest only period" , `${off.interestonly_m}m IO, fixed rate ${off.years}y` , "", ""); lin(`Payment starting ${num(off.interestonly_m)+1} month` , off.m_apr_pmt_ex , "cur", ""); } if (MAR.getOpt(off, "amort_type", "") === "arm") { lin("Rate type" , `ARM` , "", ""); lin("ARM fixed for" , `${off.armfix_m}m` , "", ""); lin("ARM annual updates" , `${off.armvar}` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "status_qm", 0) < 0) { linlo("QM Fail !" , off.status_qm_pts , "perc3", "warn"); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "rq_nonqm", "") === "Y") { linlo("QM" , `Non QM` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "rq_nodocs", "") === "Y") { linlo("Income Docs" , `Not required` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true) { if (num(off.final_mi_py) !== 0) { linlo("MI percerntage" ,off.final_mi_py ,"perc3", ""); } if (num(off.final_ufmi_py) !== 0) { linlo("Up front MI percentage" , off.final_ufmi_py , "perc2", ""); let final_ufmi_fin = num(MAR.getOpt(off, "final_ufmi_fin",0)); if (num(off.final_ufmi_py) !== 0) { linlo("Financed MI" , final_ufmi_fin , "cur", ""); } } } } else if (is_refi_rat) { // Purpose Rate and Term Refi // Property Duplex // Occupancy Primary // Estimated Fico 750 // Estimated Value $ 390,000 // Loan to Value 96.5% // Loan Amount $ 350,000 // Cash to Close $ 12,123 // // /B/Loan Information/B/ // Loan Type FHA // Rate 3.875% // APR 4.124% // Points (to pay) 0.695% // Loan term in months 360 // // /B/Net benefit calculation/B/ // // Months left on old mortgage 336 // Pmt if paid-off in 336 months $2,326 // Current loan pmt $3,000 // Savings per month $673 // Savings over duration (336 x $673) $226,346 // Est. cash out amount $ 1,840 // Expected savings due to // - Due to skipping // 2 monthly Pmt $ 6,000 // - Due to escrow rebate $ 4,000 // Total savings over // life of loan $238,686 let _h = ""; let __h = ""; lin(`Purpose` , "Rate and Term Refi" , "" , ""); lin(`Property` , off.ptype_f , "" , ""); lin(`Occupancy` , off.otype_f , "" , ""); lin(`${getScenario_data("cs_state","Est.")} Fico` , off._pd.credit_score , "" , ""); if (off._pd.credit_score !== off._pd.o_credit_score) { lin("Credit score too low!" , off._pd.o_credit_score, "", "warn"); } lin("Est. property value" , off.propertyvalue , "cur" , ""); lin("Loan to value" , off.ltv , "perc1" , ""); (function(){ let final_ufmi_fin = num(MAR.getOpt(off, "final_ufmi_fin",0)); if (num(off.final_ufmi_py) !== 0) { let total_loan_amount = num(off.loanvalue) + num(final_ufmi_fin); lin("Total Loan Amount" , total_loan_amount , "cur", ""); lin(` - Base Loan` , off.loanvalue , "cur" , "cap"); lin(" - Financed MI" , final_ufmi_fin , "cur", ""); } else { lin(`Loan Amount` , off.loanvalue , "cur" , "cap"); } })(); lin((num(off.total_costs) < 0) ? "Est. cash out amount" : "Est. cash to close (to pay)" , Math.abs(off.total_costs) , "cur" , ""); let ltv_abs = 100 - ((downpayment / off.propertyvalue) * 100); // lin(`Equity left in property (${elaineui.format("perc1",ltv_abs)} LTV)` // , downpayment , "cur" , ""); h += "
    "; h += `
    Loan information
    `; // lin(`Loan type` , mar._txt(off._pd.loantype), "", "cap"); lin(`Loan type` ,off.prog_f) lin(`Rate` , mortgage.rate , "perc3", ""); lin(`APR` , mortgage.apr , "perc3", ""); lin((num(off.po_cost) < 0)?"Points to receive":"Points" , off.po_cost , "perc3", ""); // lin((num(off.points) < 0)?"Points to receive":"Points" , off.points , "perc3", ""); MAR.ifOpt(off, "closing_date", function(v) { if (v === ``) return; lin(`Est. closing date` , elaineui.format(`date`,off.closing_date)) }); lin(`Loan term in months` , off.years*12 , "", ""); if (MAR.getOpt(off, "interestonly", "") === "Y") { lin("Interest only period" , `10y IO, fixed rate ${off.years}y` , "", ""); lin("Payment starting 121st month" , off.m_apr_pmt_ex , "cur", ""); lin("Prepayment penalty in first 3y" , `Max 3% of loan balance` , "", ""); } if (MAR.getOptNum(off, "interestonly_m", 0) > 0) { lin("Interest only period" , `${off.interestonly_m}m IO, fixed rate ${off.years}y` , "", ""); lin(`Payment starting ${num(off.interestonly_m)+1} month` , off.m_apr_pmt_ex , "cur", ""); } if (MAR.getOpt(off, "amort_type", "") === "arm") { lin("Rate type" , `ARM` , "", ""); lin("ARM fixed for" , `${off.armfix_m}m` , "", ""); lin("ARM annual updates" , `${off.armvar}` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "status_qm", 0) < 0) { linlo("QM Fail !" , off.status_qm_pts , "perc3", "warn"); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "rq_nonqm", "") === "Y") { linlo("QM" , `Non QM` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "rq_nodocs", "") === "Y") { linlo("Income Docs" , `Not required` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true) { if (num(off.final_mi_py) !== 0) { linlo("MI percerntage" ,off.final_mi_py ,"perc3", ""); } if (num(off.final_ufmi_py) !== 0) { lin("Up front MI percentage" , off.final_ufmi_py , "perc2", ""); let final_ufmi_fin = num(MAR.getOpt(off, "final_ufmi_fin",0)); if (num(off.final_ufmi_py) !== 0) { linlo("Financed MI" , final_ufmi_fin , "cur", ""); } } } h += "
    "; (function new_benefit_calc() { let pdt = off._pd.savings_txt.split("\n"); for ( let i=0; i < pdt.length; i++) { let pdtline = pdt[i].split(":"); if (pdtline.length === 1) { lin(pdtline[0] , "" ,"", ""); } if (pdtline.length === 2) { lin(pdtline[0] , pdtline[1] ,"", ""); } if (pdtline.length === 3) { lin(pdtline[0] , pdtline[1] , pdtline[2], ""); } if (pdtline.length === 4) { lin(pdtline[0] , pdtline[1] , pdtline[2], pdtline[3]); } } })(); // h += `
    Net benefit calculation
    `; // lin(`Months left on old mortgage` , off._pd.savings_pmts_left , "", ""); // if (MAR.getOptNum(off, "_pd.savings_in_io_period",0) > 0) { // lin(`- months of Interest Only` , off._pd.savings_in_io_period , "", ""); // } // lin(`Pmt if paid-off in ${off._pd.savings_pmts_left} months`, off._pd.savings_pmt_in_rem , "cur", ""); // if (MAR.getOptNum(off, "_pd.savings_pmt_in_io",0) > 0) { // lin(`- Of which in IO` , off._pd.savings_pmt_in_io , "cur", ""); // lin(`Current loan pmt` , off._pd.saving_current_pmt , "cur", ""); // lin(`Savings per month during IO` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_io) , "cur", ""); // lin(`Savings per month during Amo` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem) , "cur", ""); // lin(`Savings over duration IO (${off._pd.savings_in_io_period})` , off._pd.savings_over_dur_io , "cur", ""); // lin(`Savings over duration AMO (${off._pd.savings_pmts_left - off._pd.savings_in_io_period})` , off._pd.savings_over_dur_amo , "cur", ""); // lin(`Savings over duration` , off._pd.savings_over_dur , "cur", ""); // } else { // lin(`Current loan pmt` , off._pd.saving_current_pmt , "cur", ""); // lin(`Savings per month` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem) , "cur", ""); // lin(`Savings over duration (${off._pd.savings_pmts_left} x ${elaineui.format("cur",off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem)})` // , off._pd.savings_over_dur , "cur", ""); // // } // //// lin(`Current loan pmt` , off._pd.saving_current_pmt , "cur", ""); //// if (MAR.getOptNum(off, "_pd.savings_in_io_period",0) > 0) { //// lin(`Savings per month` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem) , "cur", ""); //// lin(`Savings over duration (${off._pd.savings_pmts_left})` //// , off._pd.savings_over_dur , "cur", ""); //// } else { //// lin(`Savings per month` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem) , "cur", ""); //// lin(`Savings over duration (${off._pd.savings_pmts_left} x ${elaineui.format("cur",off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem)})` //// , off._pd.savings_over_dur , "cur", ""); //// //// } // lin((num(off.total_costs) < 0) ? "Est. cash out amount" : "Est. cash to close (to pay)" // , Math.abs(off.total_costs) , "cur" , ""); // // _h = ""; // _h += "Expected savings due to "; // _h += "
    - Due to skipping 2 monthly Pmts"; // _h += "
    - Due to escrow rebate"; // _h += "
    Total savings over life of loan"; // // __h = ""; // __h += ""; // // __h += "
    " + elaineui.format("cur",off._pd.saving_2x_pmt); // // __h += "
    " + elaineui.format("cur",off._pd.saving_escrow); // // __h += "
    " + elaineui.format("cur",off._pd.saving_total) + ""; // // lin(_h , __h , "", ""); if (MAR.getOptNum(off, "interestonly_m", 0) > 0) { h += `

    Net benefit calculation assumes the loan will be paid off in original duration. Therefore I/O periods are not factored in.
    `; } } else if (is_refi_limited) { let _h = ""; let __h = ""; lin(`Purpose` , "Limited C/O Refi" , "" , ""); lin(`Property` , off.ptype_f , "" , ""); lin(`Occupancy` , off.otype_f , "" , ""); lin(`${getScenario_data("cs_state","Est.")} Fico` , off._pd.credit_score , "" , ""); if (off._pd.credit_score !== off._pd.o_credit_score) { lin("Credit score too low!" , off._pd.o_credit_score, "", "warn"); } lin("Est. property value" , off.propertyvalue , "cur" , ""); lin("Loan to value" , off.ltv , "perc1" , ""); // lin(`Loan Amount` , off.loanvalue , "cur" , "cap"); (function(){ let final_ufmi_fin = num(MAR.getOpt(off, "final_ufmi_fin",0)); if (num(off.final_ufmi_py) !== 0) { let total_loan_amount = num(off.loanvalue) + num(final_ufmi_fin); lin("Total Loan Amount" , total_loan_amount , "cur", ""); lin(` - Base Loan` , off.loanvalue , "cur" , "cap"); lin(" - Financed MI" , final_ufmi_fin , "cur", ""); } else { lin(`Loan Amount` , off.loanvalue , "cur" , "cap"); } })(); lin((num(off.total_costs) < 0) ? "Est. cash benefit" : "Est. cash to close (to pay)" , Math.abs(off.total_costs) , "cur" , ""); let ltv_abs = 100 - ((downpayment / off.propertyvalue) * 100); // lin(`Equity left in property (${elaineui.format("perc1",ltv_abs)} LTV)` // , downpayment , "cur" , ""); h += "
    "; h += `
    Loan information
    `; // lin(`Loan type` , mar._txt(off._pd.loantype), "", "cap"); lin(`Loan type` ,off.prog_f) lin(`Rate` , mortgage.rate , "perc3", ""); lin(`APR` , mortgage.apr , "perc3", ""); // lin((num(off.points) < 0)?"Points to receive":"Points" , off.points , "perc3", ""); lin((num(off.po_cost) < 0)?"Points to receive":"Points" , off.po_cost , "perc3", ""); MAR.ifOpt(off, "closing_date", function(v) { if (v === ``) return; lin(`Est. closing date` , elaineui.format(`date`,off.closing_date)) }); lin(`Loan term in months` , off.years*12 , "", ""); if (MAR.getOpt(off, "interestonly", "") === "Y") { lin("Interest only period" , `10y IO, fixed rate ${off.years}y` , "", ""); lin("Payment starting 121st month" , off.m_apr_pmt_ex , "cur", ""); lin("Prepayment penalty in first 3y" , `Max 3% of loan balance` , "", ""); } if (MAR.getOptNum(off, "interestonly_m", 0) > 0) { lin("Interest only period" , `${off.interestonly_m}m IO, fixed rate ${off.years}y` , "", ""); lin(`Payment starting ${num(off.interestonly_m)+1} month` , off.m_apr_pmt_ex , "cur", ""); } if (MAR.getOpt(off, "amort_type", "") === "arm") { lin("Rate type" , `ARM` , "", ""); lin("ARM fixed for" , `${off.armfix_m}m` , "", ""); lin("ARM annual updates" , `${off.armvar}` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "status_qm", 0) < 0) { linlo("QM Fail !" , off.status_qm_pts , "perc3", "warn"); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "rq_nonqm", "") === "Y") { linlo("QM" , `Non QM` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "rq_nodocs", "") === "Y") { linlo("Income Docs" , `Not required` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true) { if (num(off.final_mi_py) !== 0) { linlo("MI percerntage" ,off.final_mi_py ,"perc3", ""); } if (num(off.final_ufmi_py) !== 0) { linlo("Up front MI percentage" , off.final_ufmi_py , "perc2", ""); let final_ufmi_fin = num(MAR.getOpt(off, "final_ufmi_fin",0)); if (num(off.final_ufmi_py) !== 0) { linlo("Financed MI" , final_ufmi_fin , "cur", ""); } } } // if (mar.pg_tmp_am_i_the_lo() === true) { // lin("Max BE" , MAR.getOpt(maximums,"maxbe",0) , "perc", ""); // lin("Max FE" , MAR.getOpt(maximums,"maxfe",0) , "perc", ""); // lin("Max Loan" , MAR.getOpt(maximums,"maxloan",0) , "cur", ""); // // } h += "
    "; // h += `
    Net benefit calculation
    `; // lin(`Months left on old mortgage` , off._pd.savings_pmts_left , "", ""); // if (MAR.getOptNum(off, "_pd.savings_in_io_period",0) > 0) { // lin(`- months of Interest Only` , off._pd.savings_in_io_period , "", ""); // } // lin(`Pmt if paid-off in ${off._pd.savings_pmts_left} months`, off._pd.savings_pmt_in_rem , "cur", ""); // if (MAR.getOptNum(off, "_pd.savings_pmt_in_io",0) > 0) { // lin(`- Of which in IO` , off._pd.savings_pmt_in_io , "cur", ""); // } // lin(`Current loan pmt` , off._pd.saving_current_pmt , "cur", ""); // if (MAR.getOptNum(off, "_pd.savings_pmt_in_io",0) > 0) { // lin(`- Of which in IO` , off._pd.savings_pmt_in_io , "cur", ""); // lin(`Current loan pmt` , off._pd.saving_current_pmt , "cur", ""); // lin(`Savings per month during IO` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_io) , "cur", ""); // lin(`Savings per month during Amo` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem) , "cur", ""); // lin(`Savings over duration IO (${off._pd.savings_in_io_period})` , off._pd.savings_over_dur_io , "cur", ""); // lin(`Savings over duration AMO (${off._pd.savings_pmts_left - off._pd.savings_in_io_period})` , off._pd.savings_over_dur_amo , "cur", ""); // lin(`Savings over duration` , off._pd.savings_over_dur , "cur", ""); // // } else { // lin(`Current loan pmt` , off._pd.saving_current_pmt , "cur", ""); // lin(`Savings per month` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem) , "cur", ""); // lin(`Savings over duration (${off._pd.savings_pmts_left} x ${elaineui.format("cur",off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem)})` // , off._pd.savings_over_dur , "cur", ""); // // } (function new_benefit_calc() { let pdt = off._pd.savings_txt.split("\n"); for ( let i=0; i < pdt.length; i++) { let pdtline = pdt[i].split(":"); if (pdtline.length === 1) { lin(pdtline[0] , "" ,"", ""); } if (pdtline.length === 2) { lin(pdtline[0] , pdtline[1] ,"", ""); } if (pdtline.length === 3) { lin(pdtline[0] , pdtline[1] , pdtline[2], ""); } if (pdtline.length === 4) { lin(pdtline[0] , pdtline[1] , pdtline[2], pdtline[3]); } } })(); // h += `
    ${off._pd.savings_txt}
    `; // lin(`Savings per month` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem) , "cur", ""); // if (MAR.getOptNum(off, "_pd.savings_in_io_period",0) > 0) { // lin(`Savings over duration (${off._pd.savings_pmts_left})` // , off._pd.savings_over_dur , "cur", ""); // } else { // lin(`Savings over duration (${off._pd.savings_pmts_left} x ${elaineui.format("cur",off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem)})` // , off._pd.savings_over_dur , "cur", ""); // // } // lin((num(off.total_costs) < 0) ? "Est. cash out amount" : "Est. cash to close (to pay)" // , Math.abs(off.total_costs) , "cur" , ""); // // _h = ""; // _h += "Expected savings due to "; // _h += "
    - Due to skipping 2 monthly Pmts"; // _h += "
    - Due to escrow rebate"; // _h += "
    Total savings over life of loan"; // // __h = ""; // __h += ""; // // __h += "
    " + elaineui.format("cur",off._pd.saving_2x_pmt); // // __h += "
    " + elaineui.format("cur",off._pd.saving_escrow); // // __h += "
    " + elaineui.format("cur",off._pd.saving_total) + ""; // // lin(_h , __h , "", ""); if (MAR.getOptNum(off, "interestonly_m", 0) > 0) { h += `

    Net benefit calculation assumes the loan will be paid off in original duration. Therefore I/O periods are not factored in.
    `; } } else if (is_refi_cashout) { let _h = ""; let __h = ""; lin(`Purpose` , "Cash out Refi" , "" , ""); lin(`Property` , off.ptype_f , "" , ""); lin(`Occupancy` , off.otype_f , "" , ""); lin(`${getScenario_data("cs_state","Est.")} Fico` , off._pd.credit_score , "" , ""); if (off._pd.credit_score !== off._pd.o_credit_score) { lin("Credit score too low!" , off._pd.o_credit_score, "", "warn"); } lin("Est. property value" , off.propertyvalue , "cur" , ""); lin("Loan to value" , off.ltv , "perc1" , ""); // lin(`Loan Amount` , off.loanvalue , "cur" , "cap"); (function(){ let final_ufmi_fin = num(MAR.getOpt(off, "final_ufmi_fin",0)); if (num(off.final_ufmi_py) !== 0) { let total_loan_amount = num(off.loanvalue) + num(final_ufmi_fin); lin("Total Loan Amount" , total_loan_amount , "cur", ""); lin(` - Base Loan` , off.loanvalue , "cur" , "cap"); lin(" - Financed MI" , final_ufmi_fin , "cur", ""); } else { lin(`Loan Amount` , off.loanvalue , "cur" , "cap"); } })(); lin((num(off.total_costs) < 0) ? "Est. cash out" : "Est. cash to close (to pay)" , off.total_costs , "cur" , ""); let ltv_abs = 100 - ((downpayment / off.propertyvalue) * 100); // lin(`Equity left in property (${elaineui.format("perc1",ltv_abs)} LTV)` // , downpayment , "cur" , ""); h += "
    "; h += `
    Loan information
    `; // lin(`Loan type` , mar._txt(off._pd.loantype), "", "cap"); lin(`Loan type` ,off.prog_f) lin(`Rate` , mortgage.rate , "perc3", ""); lin(`APR` , mortgage.apr , "perc3", ""); // lin((num(off.points) < 0)?"Points to receive":"Points" , off.points , "perc3", ""); lin((num(off.po_cost) < 0)?"Points to receive":"Points" , off.po_cost , "perc3", ""); MAR.ifOpt(off, "closing_date", function(v) { if (v === ``) return; lin(`Est. closing date` , elaineui.format(`date`,off.closing_date)) }); lin(`Loan term in months` , off.years*12 , "", ""); if (MAR.getOpt(off, "interestonly", "") === "Y") { lin("Interest only period" , `10y IO, fixed rate ${off.years}y` , "", ""); lin("Payment starting 121st month" , off.m_apr_pmt_ex , "cur", ""); lin("Prepayment penalty in first 3y" , `Max 3% of loan balance` , "", ""); } if (MAR.getOptNum(off, "interestonly_m", 0) > 0) { lin("Interest only period" , `${off.interestonly_m}m IO, fixed rate ${off.years}y` , "", ""); lin(`Payment starting ${num(off.interestonly_m)+1} month` , off.m_apr_pmt_ex , "cur", ""); } if (MAR.getOpt(off, "amort_type", "") === "arm") { lin("Rate type" , `ARM` , "", ""); lin("ARM fixed for" , `${off.armfix_m}m` , "", ""); lin("ARM annual updates" , `${off.armvar}` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "status_qm", 0) < 0) { linlo("QM Fail !" , off.status_qm_pts , "perc3", "warn"); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "rq_nonqm", "") === "Y") { linlo("QM" , `Non QM` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "rq_nodocs", "") === "Y") { linlo("Income Docs" , `Not required` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true) { if (num(off.final_mi_py) !== 0) { linlo("MI percerntage" ,off.final_mi_py ,"perc3", ""); } if (num(off.final_ufmi_py) !== 0) { linlo("Up front MI percentage" , off.final_ufmi_py , "perc2", ""); let final_ufmi_fin = num(MAR.getOpt(off, "final_ufmi_fin",0)); if (num(off.final_ufmi_py) !== 0) { linlo("Financed MI" , final_ufmi_fin , "cur", ""); } } } h += "
    "; // h += `
    Net benefit calculation
    `; // lin(`Months left on old mortgage` , off._pd.savings_pmts_left , "", ""); // lin(`Pmt if paid-off in ${off._pd.savings_pmts_left} months`, off._pd.savings_pmt_in_rem , "cur", ""); // lin(`Current loan pmt` , off._pd.saving_current_pmt , "cur", ""); // lin(`Savings per month` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem) , "cur", ""); // lin(`Savings over duration (${off._pd.savings_pmts_left} x ${elaineui.format("cur",off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem)})` // , off._pd.savings_over_dur , "cur", ""); // lin((num(off.total_costs) < 0) ? "Est. cash out amount" : "Est. cash to close (to pay)" // , Math.abs(off.total_costs) , "cur" , ""); // // _h = ""; // _h += "Expected savings due to "; // _h += "
    - Due to skipping 2 monthly Pmts"; // _h += "
    - Due to escrow rebate"; // _h += "
    Total savings over life of loan"; // // __h = ""; // __h += ""; // // __h += "
    " + elaineui.format("cur",off._pd.saving_2x_pmt); // // __h += "
    " + elaineui.format("cur",off._pd.saving_escrow); // // __h += "
    " + elaineui.format("cur",off._pd.saving_total) + ""; // // lin(_h , __h , "", ""); // if (MAR.getOptNum(off, "interestonly_m", 0) > 0) { // h += `
    Net benefit calculation assumes the loan will be paid off in original duration. Therefore I/O periods are not factored in
    `; // } } else if (is_refi) { let _h = ""; let __h = ""; // lin(`Loan Amount`, off.loanvalue, "cur", "cap"); (function(){ let final_ufmi_fin = num(MAR.getOpt(off, "final_ufmi_fin",0)); if (num(off.final_ufmi_py) !== 0) { let total_loan_amount = num(off.loanvalue) + num(final_ufmi_fin); lin("Total Loan Amount" , total_loan_amount , "cur", ""); lin(` - Base Loan` , off.loanvalue , "cur" , "cap"); lin(" - Financed MI" , final_ufmi_fin , "cur", ""); } else { lin(`Loan Amount` , off.loanvalue , "cur" , "cap"); } })(); lin(`Loan type` , mar._txt(off._pd.loantype), "", "cap"); lin(`Rate` , mortgage.rate , "perc3", ""); lin(`APR` , mortgage.apr , "perc3", ""); // lin((num(off.points) < 0)?"Points to receive":"Points" , off.points , "perc3", ""); lin((num(off.po_cost) < 0)?"Points to receive":"Points" , off.po_cost , "perc3", ""); MAR.ifOpt(off, "closing_date", function(v) { if (v === ``) return; lin(`Est. closing date` , elaineui.format(`date`,off.closing_date)) }); lin(`Loan term in months` , off.years*12 , "", ""); h += "
    "; (function new_benefit_calc() { let pdt = off._pd.savings_txt.split("\n"); for ( let i=0; i < pdt.length; i++) { let pdtline = pdt[i].split(":"); if (pdtline.length === 1) { lin(pdtline[0] , "" ,"", ""); } if (pdtline.length === 2) { lin(pdtline[0] , pdtline[1] ,"", ""); } if (pdtline.length === 3) { lin(pdtline[0] , pdtline[1] , pdtline[2], ""); } if (pdtline.length === 4) { lin(pdtline[0] , pdtline[1] , pdtline[2], pdtline[3]); } } })(); // h += `
    Net benefit calculation
    `; // lin(`Months left on old mortgage` , off._pd.savings_pmts_left , "", ""); // if (MAR.getOptNum(off, "_pd.savings_in_io_period",0) > 0) { // lin(`- months of Interest Only` , off._pd.savings_in_io_period , "", ""); // } // lin(`Pmt if paid-off in ${off._pd.savings_pmts_left} months`, off._pd.savings_pmt_in_rem , "cur", ""); // if (MAR.getOptNum(off, "_pd.savings_pmt_in_io",0) > 0) { // lin(`- Of which in IO` , off._pd.savings_pmt_in_io , "cur", ""); // lin(`Current loan pmt` , off._pd.saving_current_pmt , "cur", ""); // lin(`Savings per month during IO` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_io) , "cur", ""); // lin(`Savings per month during Amo` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem) , "cur", ""); // lin(`Savings over duration IO (${off._pd.savings_in_io_period})` , off._pd.savings_over_dur_io , "cur", ""); // lin(`Savings over duration AMO (${off._pd.savings_pmts_left - off._pd.savings_in_io_period})` , off._pd.savings_over_dur_amo , "cur", ""); // lin(`Savings over duration` , off._pd.savings_over_dur , "cur", ""); // } else { // lin(`Current loan pmt` , off._pd.saving_current_pmt , "cur", ""); // lin(`Savings per month` , (off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem) , "cur", ""); // lin(`Savings over duration (${off._pd.savings_pmts_left} x ${elaineui.format("cur",off._pd.saving_current_pmt-off._pd.savings_pmt_in_rem)})` // , off._pd.savings_over_dur , "cur", ""); // // } // // lin((is_refi && num(off.total_costs) < 0)?"Est. cash out amount":"Est. cash to close (to pay)" // , off.total_costs , "cur", ""); // // _h = ""; // _h += "Expected savings due to "; // _h += "
    - Due to skipping 2 monthly Pmts"; // _h += "
    - Due to escrow rebate"; // _h += "
    Total savings over life of loan"; // // __h = ""; // __h += ""; // // __h += "
    " + elaineui.format("cur",off._pd.saving_2x_pmt); // // __h += "
    " + elaineui.format("cur",off._pd.saving_escrow); // // __h += "
    " + elaineui.format("cur",off._pd.saving_total) + ""; // // lin(_h , __h , "", ""); lin((is_refi) ? "Est. property value" : "Purchase price" , off.propertyvalue , "cur", ""); let ltv_abs = 100 - ((downpayment / off.propertyvalue) * 100); lin(`Equity left in property (${elaineui.format("perc1",ltv_abs)} LTV)` , downpayment , "cur", ""); lin((is_refi && num(off.total_costs) < 0) ? "Cash out amount" : "Cash to close" , off.total_costs , "cur", ""); lin(`${getScenario_data("cs_state","Est.")} credit score` , off._pd.credit_score) if (off._pd.credit_score !== off._pd.o_credit_score) { lin("Credit score too low!" , off._pd.o_credit_score, "", "warn"); } if (num(off.final_mi_py) !== 0) { lin("MI percerntage" ,off.final_mi_py ,"perc3", ""); } if (num(off.final_ufmi_py) !== 0) { lin("Up front MI percentage" , off.final_ufmi_py , "perc2", ""); let final_ufmi_fin = num(MAR.getOpt(off, "final_ufmi_fin",0)); if (num(off.final_ufmi_py) !== 0) { lin("Financed MI" , final_ufmi_fin , "cur", ""); } } lin(`Program` ,off.prog_f) if (MAR.getOpt(off, "interestonly", "") === "Y") { lin("Interest only period" , `10y IO, fixed rate ${off.years}y` , "", ""); lin("Payment starting 121st month" , off.m_apr_pmt_ex , "cur", ""); lin("Prepayment penalty in first 3y" , `Max 3% of loan balance` , "", ""); } if (MAR.getOptNum(off, "interestonly_m", 0) > 0) { lin("Interest only period" , `${off.interestonly_m}m IO, fixed rate ${off.years}y` , "", ""); lin(`Payment starting ${num(off.interestonly_m)+1} month` , off.m_apr_pmt_ex , "cur", ""); } if (MAR.getOpt(off, "amort_type", "") === "arm") { lin("Rate type" , `ARM` , "", ""); lin("ARM fixed for" , `${off.armfix_m}m` , "", ""); lin("ARM annual updates" , `${off.armvar}` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "status_qm", 0) < 0) { linlo("QM Fail !" , off.status_qm_pts , "perc3", "warn"); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "rq_nonqm", "") === "Y") { linlo("QM" , `Non QM` , "", ""); } if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(off, "rq_nodocs", "") === "Y") { linlo("Income Docs" , `Not required` , "", ""); } if (MAR.getOptNum(off, "interestonly_m", 0) > 0) { h += `

    Net benefit calculation assumes the loan will be paid off in original duration. Therefore I/O periods are not factored in.
    `; } } h += "
    ";//end breakdown holder console.warn("mortgage",mortgage); /* VAL = 'N'; h += frm.yn("can_afford","I can afford this:",VAL,"","",function(){ },{}).render(); */ h += "
    "; h += "
    ";//end breakdown bottom h +='
    '; return h; } var proposalDate = gettoday(); var pieArray = []; function render(pg, localopts) { /** * #scenario-ratequote1.0 - #0 * #scenario-ratequote1.0.edit - And Edit */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; if (existingid === "" || existingid === "0") existingid = false; let version = (existingid !== false) ? existingid : "0"; let recalculated = (typeof mar.tmp_was_recalculated === "string"); let edit_on_start = (typeof mar.tmp_was_recalculated === "string" && mar.tmp_was_recalculated.endsWith("E")); let recalc_on_edit = false; mar.tmp_was_recalculated = false; mar.tmp_return_hash = false; if (p3 && p3 === "edit") { edit_on_start = true; } if (MAR.getOpt(localopts, "p4","") === "edit") { edit_on_start = true; } if (p3 && p3 === "edit_recalc") { edit_on_start = true; recalc_on_edit = true; } if (MAR.getOpt(localopts, "p4","") === "edit_recalc") { edit_on_start = true; recalc_on_edit = true; } var sc = getScenario_data("applicant"+applicantNum+"_cscore",false); var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var loan_type = getScenario_data("loan_type","purchase"); var wehavebeenherebefore = getScenario_data("__scenario_ratequote1_0_passed","N"); var app_origin = getScenario_data("origin",""); function roundVal(value, decimals) { return Number(Math.round(value+'e'+decimals)+'e-'+decimals); } let h = ""; h += frm.htitle("Approx Loan Cost Illustration 1/2 ").render(); h += frm.elaine("The information provided below regarding Approximate Cost of Closing Fees, Approximate Total Funds Needed To Close and the Approximate Total Monthly Payment (collectively referred to as Approximate Loan Cost Illustration) are only approximations. The actual fees, cost and monthly payment on your specific loan transaction may vary and may include additional fees and cost.","").render(); h += "
    "; // let mortgage = getScenario_data("mortgage",false); let mortgage = false; console.warn("mortgage",mortgage); h += uihelpers.cbuttonbar("Fee Sheet",frm.addfunction(function(){ /* var val = yn("#can_afford"); if (val == 'N' ) { mar.tip(".help-button","warning","If you cannot afford this monthly budget you will need to modify your application.","top"); return; } */ setScenario_data("__scenario_"+"ratequote1_0"+"_passed","Y"); mar.fakesave("",function(){ if (mar.tmp_off.type === "en") { setScenario_data("__scenario_"+"ratequote2_0"+"_passed","Y"); mar.fakesave(function(){ mvc.go("#declarations-p1."+applicantnum); }); } else if (existingid === false) { mvc.go("#scenario-ratequote2.0"); } else { mvc.go(`#scenario-ratequote2.0.${existingid}`); } }) }),"Back",frm.addfunction(function(){ // mvc.go("#scenario-ratequote0.0"); let page_to_return_to = mvc.get("referrer_ratequote"); if (typeof page_to_return_to === "string" && page_to_return_to !== "") { mvc.go(page_to_return_to); return; } mvc.go("#scenario-ratequote.0"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ // debugger; // let sp = mar.isallowed_scenario("#scenario-housingbudget1"); // if (typeof sp === "string") { // mvc.go(sp); // return; // } if (version === "selected") { $.get(`/api/chatbot/getSelectedIndex/${mar.ID}`, function(da){ mvc.go(`#scenario-ratequote1.0.${da.index}`); }); return; } $("#body-container").LoadingOverlay("show"); $.get(`/api/chatbot/getAgreedRate/${mar.ID}/${version}`, function(da){ if (da.status !== 0 ) { let h = ""; let cog = `settings`; if (mar.pg_tmp_am_i_the_lo() === false) { cog = ""; } h += `
    This loan does not result in a valid calcualtion ${cog}
    `; if (mar.pg_tmp_am_i_the_lo()) { let reason_stub = mar.tmp_extract_reason_stub_from_agreed_rate(da); let rv = mar.tmp_decide_what_is_the_most_likely_cause_of_failure_for_offer(reason_stub); h += frm.inline_warning_red(`The likely reason is : ${rv.m}`); if (da.is_working_version) { h += frm.inline_warning_red(`Would you like to return to the last working version? Revert`); } } $(".result").html(h); $("#body-container").LoadingOverlay("hide",true); return; } if (mar.pg_tmp_am_i_the_lo() === false) { $.get(`/api/chatbot/video_log/${mar.ID}/${version}/?action=open`); } // if (mar.WE_ARE_FROM_LOI === false) { // setScenario_data("__scenario_ratequote_0_passed_new","Y"); // } let off = da.data; let maximums = MAR.getOpt(da, "MAXIMUMS",{}); mar.tmp_off = off; mar.tmp_off_da = da; let trackdata = MAR.getOpt(da, "trackdata", {}); mar.tmp_trackdata = trackdata; if ("years" in off === false) { off.years = 30; } h = ""; if (mar.pg_tmp_am_i_the_lo()) { if (MAR.getOpt(mar.tmp_trackdata, "opened", "") !== "") { h += `
    This Loan HAS been opened by the Client

    ` } } if (mar.pg_tmp_am_i_the_lo() === true) { // let saved_item = da; // let FE = MAR.getOpt(saved_item, "FE", false); // let BE = MAR.getOpt(saved_item, "BE", false); // if (FE !== false && BE !== false) { // detail = `${elaineui.format("perc2",FE)} / ${elaineui.format("perc2",BE)}` // h += `
    FE / BE
    ${detail}
    `; // } h += mar.tmp_rq_topgrid_html(`rqpage`); h += `
    `; } off.type = ("docid" in off) ? "en" : "el"; if (off.type === "en") { h += `
    `; h += frm.h2("
    This is not an approval for the loan. Your application has not been reviewed by an Underwriter.
    ").render(); $(".slideFooter .next-button").html("Continue"); } else { h += makeTable(off, version, recalculated, maximums); h += frm.h2("
    This is not an approval for the loan. Your application has not been reviewed by an Underwriter.
    ").render(); h +="
    " + MAR.getOpt(off, "txt_ass_short",[]).join("
    ") + `Your actual rate, payment, and cost could be higher. Get an official Loan Estimate before choosing a loan.` + MAR.getOpt(off, "txt_co",[]).join("
    ") + "

    " + ""; } // h +="Get an official quote by completing this loan application from your licensed Loan Officer " + // loanofficer.name + // " with NMLS ID " + // loanofficer.nmls + // ". Your actual rate, payment, and cost could be higher."; // h +=" Get an official Loan Estimate before choosing a loan.

    "; // h +="Read more"; h += "
    "; h += "The information provided above regarding Approximate Cost of Closing Fees, " + "Approximate Total Funds Needed To Close and the Approximate Total Monthly " + "Payment (collectively referred to as Approximate Loan Cost Illustration) " + "are only approximations. The actual fees, cost and monthly payment on your specific " + "loan transaction may vary and may include additional fees and cost. "; h += "
    ";//end readmore div h += "" h +="

    ";//end grey disclaimer h += "
    "; $(".result").html(h); if (mar.pg_tmp_am_i_the_lo() === true) { setTimeout(function(){ mar.tmp_rq_reload_topgrid(da.febe, ".topgrid.rqpage"); },1); } function load_pdf(){ $.get(off.pdf_link_json, function(_da){ (async function(){ let pdfraw = ""; if (typeof _da.data === "string") { pdfraw = _da.data; } else if (typeof _da.datab64 === "string") { pdfraw = atob(_da.datab64); } else { pdfraw = _da.data; } let pdfraw_fn = MAR.getOpt(_da, "filename",""); let h = ``; // h += `
    ${pdfraw_fn}
    `; h += `
    `; h += `
    Loading pdf
    `; $("#pdf-div").html(h); $("#iframe301-loading").LoadingOverlay("show"); var pdfjsLib = window['pdfjs-dist/build/pdf']; while (typeof pdfjsLib !== "object" ) { console.error(`Waiting for pdf`); await MAR.api.sleepSync(100); pdfjsLib = window['pdfjs-dist/build/pdf']; } var loadingTask = pdfjsLib.getDocument({data: pdfraw}); loadingTask.promise.then(function(pdf) { // you can now use *pdf* here var pageNumber = 0; let nextpage = function() { if (pageNumber < pdf.numPages) { pageNumber++; pdf.getPage(pageNumber).then(function(page) { var scale = 1.5; let current_rotation = MAR.getOpt(page, "_pageInfo.rotate"); // if (current_rotation === 270) current_rotation = 180; // else if (current_rotation === 0) current_rotation = 0; // else if (current_rotation === 90) current_rotation = 0; // else if (current_rotation === 180) current_rotation = 90; var viewport = page.getViewport({ scale : scale, rotation : current_rotation // dontFlip : true }); // // Prepare canvas using PDF page dimensions // var canvas = $("")[0];//document.createElementById('the-canvas'); var context = canvas.getContext('2d'); canvas.height = viewport.height; canvas.width = viewport.width; // // Render PDF page into canvas context // var task = page.render({canvasContext: context, viewport: viewport}) task.promise.then(function(){ let src = canvas.toDataURL('image/jpeg'); //$("#iframe301").append(``); $("#iframe301").append(`
    `); nextpage(); }); }); } else { $("#iframe301-loading").LoadingOverlay("hide",true); $("#iframe301-loading").html(""); $("#iframe301").append(``); let pz = $("#iframe301 .zoomHoldery img"); for (let i=0; i < pz.length; i++) { let id = pz[i].id; let elm = pz[i]; $(elm).pinchzoomer({ maxZoom : 5, scaleMode : "smart", initX : 0, initY : 0, zoomPointY : 0, // zoom at top preloaderUrl : "/assets/preloader.gif", allowZoom : false, allowDrag : false }, true); var pzo = PinchZoomer.get(id); $(elm).click(function(e){ let $elm = $(this); let id = $elm.prop("id"); let pzo = PinchZoomer.get(id); let fs = pzo.fullscreen(); if (!fs) { pzo.fullscreen(true); } }); pzo.on(PinchZoomer.FULLSCREEN_TOGGLE, function(e){ console.error(e); let fs = e.currentTarget.fullscreen(); if (fs) { e.currentTarget.vars({ allowZoom : true, allowDrag : true }); } else { e.currentTarget.resetElem(true); e.currentTarget.zoom(0.3); e.currentTarget.vars({ allowZoom : false, allowDrag : false }); } }); // pzo.on(PinchZoomer.ZOOM, function(e){ // console.error(e); // let fs = e.currentTarget.fullscreen(); // if (!fs) { // e.currentTarget.fullscreen(true); // } // debugger; // }); } } } nextpage(); }); })(); }); } function createPie(){ console.warn('check the pie arrary: ', pieArray); const svgEl = document.getElementById('budgetPieHolder'); var slices = [ { percent: 0.1, color: 'Coral' }, { percent: 0.65, color: 'CornflowerBlue' }, { percent: 0.2, color: '#00ab6b' }, ]; if(pieArray.length > 0){ slices = pieArray; } console.warn(" passed pie arrary : ", pieArray); let cumulativePercent = 0; function getCoordinatesForPercent(percent) { const x = Math.cos(2 * Math.PI * percent); const y = Math.sin(2 * Math.PI * percent); return [x, y]; } slices.forEach(slice => { // destructuring assignment sets the two variables at once const [startX, startY] = getCoordinatesForPercent(cumulativePercent); // each slice starts where the last slice ended, so keep a cumulative percent cumulativePercent += slice.percent; const [endX, endY] = getCoordinatesForPercent(cumulativePercent); // if the slice is more than 50%, take the large arc (the long way around) const largeArcFlag = slice.percent > .5 ? 1 : 0; // create an array and join it just for code readability const pathData = [ `M ${startX} ${startY}`, // Move `A 1 1 0 ${largeArcFlag} 1 ${endX} ${endY}`, // Arc `L 0 0` // Line ].join(' '); // create a and append it to the element const pathEl = document.createElementNS('http://www.w3.org/2000/svg', 'path'); pathEl.setAttribute('d', pathData); pathEl.setAttribute('fill', slice.color); svgEl.appendChild(pathEl); }); } if (off.type === "el") { createPie( ); } else { load_pdf(); } $("#body-container").LoadingOverlay("hide",true); if (recalc_on_edit) { $.get(`/api/chatbot/recalculateVersion/${mar.ID}/${version}`, function(da){ mar.pg_loi_adjust_quote("scenario-ratequote1.0",version,mar.tmp_off,true); }); } else if (edit_on_start) { mar.pg_loi_adjust_quote("scenario-ratequote1.0",version,mar.tmp_off,true); } }); $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); oc(); $("#body-container").scrollTo(0,200); // replace dollars with dollars functions $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $(".next-button").addClass("sync"); $(".next-button").addClass("synch"); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, makeTable : makeTable, // section : "estimate", section : "scenario", menuitem : "scenario-ratequote1" } })(); mar.pg["scenario-ratequote2"] = (function(){ var VAL = 'N' var html = ""; function gettoday() { var today = new Date(); var dd = today.getDate(); var mm = today.getMonth() + 1; //January is 0! var yyyy = today.getFullYear(); if (dd < 10) { dd = '0' + dd; } if (mm < 10) { mm = '0' + mm; } var today = '('+mm + '/' + dd + '/' + yyyy+')'; return today; } var proposalDate = gettoday(); function render(pg, localopts) { let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; if (existingid === "" || existingid === "0") existingid = false; let version = (existingid !== false) ? existingid : "0"; let recalculated = (typeof mar.tmp_was_recalculated === "string"); let edit_on_start = (typeof mar.tmp_was_recalculated === "string" && mar.tmp_was_recalculated.endsWith("E")); let recalc_on_edit = false; mar.tmp_was_recalculated = false; mar.tmp_return_hash = false; if (p3 && p3 === "edit") { edit_on_start = true; } if (MAR.getOpt(localopts, "p4","") === "edit") { edit_on_start = true; } if (p3 && p3 === "edit_recalc") { edit_on_start = true; recalc_on_edit = true; } if (MAR.getOpt(localopts, "p4","") === "edit_recalc") { edit_on_start = true; recalc_on_edit = true; } mar.pg_accesscontrollerfn = function() { return "open"; } var sc = getScenario_data("applicant"+applicantNum+"_cscore",false); var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var loan_type = getScenario_data("loan_type","purchase"); var wehavebeenherebefore = getScenario_data("__scenario_ratequote2_0_passed","N"); var app_origin = getScenario_data("origin",""); let h = ""; h += frm.htitle("Approx Loan Cost Illustration 2/2 ").render(); let el_txt = `Dear ${n0}, The information provided below regarding the Estimated Monthly Payment and the Estimated Cash to Close (collectively referred to as Approx Loan Cost Illustration) are only approximations. The actual fees, cost and monthly payment on your specific loan transaction may very and may included additional fees and cost.`; h += frm.elaine(el_txt,"er").render(); h += "
    "; // JC - CW - elaine added div h += "
    "; h += "
    "; h += "
    "; if ( mar.pg_tmp_am_i_the_lo() ) { } mar.tmp_setlive = function(fn) { if (existingid === false) { /* we are in a newly calculated loan */ let destination_version = (mar.tmp_saved_1) ? 999 : 1; $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/${destination_version}?&set_live=y`, function(da){ MAR.ifOpt(da, "sc_obj", function(sco){ for (x in sco) { setScenario_data(x, sco[x]); } mar.fakesave(); mar.tmp_check_rq_encompass(fn); // if (fn) fn(); // here ? }); }); } else { $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/${existingid}?from=${existingid}&set_live=y`, function(da){ MAR.ifOpt(da, "sc_obj", function(sco){ for (x in sco) { setScenario_data(x, sco[x]); } mar.fakesave(); mar.tmp_check_rq_encompass(fn); // here ? // if (fn) fn(); }); }); } } mar.tmp_saveas = function(N, fn) { if (existingid === false) { $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/${N}`, function(da){ MAR.ifOpt(da, "sc_obj", function(sco){ for (x in sco) { setScenario_data(x, sco[x]); } mar.fakesave(); if (fn) fn(); // here ? }); // mvc.go("#scenario-ratequote.0"); }); } else { $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/${N}?from=${existingid}`, function(da){ MAR.ifOpt(da, "sc_obj", function(sco){ for (x in sco) { setScenario_data(x, sco[x]); } mar.fakesave(); if (fn) fn(); // here ? }); // mvc.go("#scenario-ratequote.0"); }); } } // h += uihelpers.cbuttonbar3("Continue",frm.addfunction(function(){ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /* var val = yn("#can_afford"); if (val == 'N' ) { mar.tip(".help-button","warning","If you cannot afford your closing costs you will need to change your application.","top"); return; } */ if (tmp_hb_continue_fn !== false) { tmp_hb_continue_fn(`continue`); return; } setScenario_data("__scenario_"+"ratequote2_0"+"_passed","Y"); mar.fakesave(function(){ if (mar.tmp_we_were_forced_to_ratequote === true) { mar.tmp_we_were_forced_to_ratequote = false; mvc.go("#lox"); } else if (MAR.appnav.loanWasSubmitted()) { mvc.go("#declarations-p1."+applicantnum); } else { mvc.go("#lox"); } }); }),"Prev",frm.addfunction(function(){ if (existingid === false) { mvc.go("#scenario-ratequote1.0"); } else { mvc.go(`#scenario-ratequote1.0.${existingid}`); } }),"Proposals",frm.addfunction(function(){ if (existingid === false) { elaineui.swalprompt({ title : "Exit", txt : `
    This offer has not been saved as a finished proposal, are you sure you want to exit
    `, ok : "Exit", okfn : function(opts) { let back_to = mvc.get("referrer_ratequote") mvc.go(back_to); // opts.preventclose = true; }, cancel : "Cancel", cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", cancelfn : function() { }, opts : { closeOnClickOutside : false, closeOnEsc : false } }); return; } if (mar.tmp_is_visible === false) { elaineui.swalprompt({ title : "Exit", txt : `
    This offer is not visible for the client , are you sure you want to exit?
    `, ok : "Exit", okfn : function(opts) { let back_to = mvc.get("referrer_ratequote") mvc.go(back_to); // opts.preventclose = true; }, cancel : "Cancel", cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", cancelfn : function() { }, opts : { closeOnClickOutside : false, closeOnEsc : false } }); return; } // mar.tmp_is_selected = selected; let back_to = mvc.get("referrer_ratequote") mvc.go(back_to); }),"mar.help()"); h = Mustache.render(h,localopts); let tmp_hb_continue_fn = false; let oc = function() { } let or = function(){ // debugger; // let sp = mar.isallowed_scenario("#scenario-housingbudget2"); // if (typeof sp === "string") { // mvc.go(sp); // return; // } if (version === "selected") { $.get(`/api/chatbot/getSelectedIndex/${mar.ID}`, function(da){ mvc.go(`#scenario-ratequote2.0.${da.index}`); }); return; } $("#body-container .xprev-button").addClass("dr-button"); /* -- make the previous button blue -- */ $("#body-container").LoadingOverlay("show"); $.get(`/api/chatbot/getAgreedRate/${mar.ID}/${version}`, function(da){ //alert(mar.tmp_hb_scroll_to_bottom); let _should_scroll_to_bottom = mar.tmp_hb_scroll_to_bottom; mar.tmp_hb_scroll_to_bottom = false; if (da.status !== 0 ) { let h = ""; let cog = `settings`; if (mar.pg_tmp_am_i_the_lo() === false) { cog = ""; } h += `
    This loan does not result in a valid calcualtion ${cog}
    `; if (mar.pg_tmp_am_i_the_lo()) { let reason_stub = mar.tmp_extract_reason_stub_from_agreed_rate(da); let rv = mar.tmp_decide_what_is_the_most_likely_cause_of_failure_for_offer(reason_stub); h += frm.inline_warning_red(`The likely reason is : ${rv.m}`); if (da.is_working_version) { h += frm.inline_warning_red(`Would you like to return to the last working version? Revert`); } } $(".result").html(h); $("#body-container").LoadingOverlay("hide",true); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { } }, quick : false }); return; } if (mar.pg_tmp_am_i_the_lo() === false) { $.get(`/api/chatbot/video_log/${mar.ID}/${version}/?action=open`); } let off = da.data; let saved_1 = da.saved_1; let saved_0 = da.saved_0; let saved_idx = da.saved_idx; let trackdata = MAR.getOpt(da, "trackdata", {}); mar.tmp_trackdata = trackdata; mar.tmp_saved_1 = saved_1; mar.tmp_saved_0 = saved_0; mar.tmp_saved_idx = saved_idx; mar.tmp_selected = da.selected; mar.tmp_sel_idx = da.sel_idx; mar.tmp_idx = version; mar.tmp_tracked = da.tracked; mar.tmp_name = da.name; mar.tmp_visibiity = da.visibility; mar.tmp_locked = da.locked; mar.tmp_slot = da.slot; // next available slot mar.tmp_slots = da.slots; // slots mar.tmp_in_slot = da.in_slot; // is this in a slot if ("years" in off === false) { off.years = 30; } let mo = {}; let mortgage = mo; let purchace_price = MAR.getOpt(off, "propertyvalue",0); let max_loan = MAR.getOpt(off, "loanvalue",0); let final_ufmi_fin = num(MAR.getOpt(off, "final_ufmi_fin",0)); let ufmi_cost = (final_ufmi_fin === 0) ? MAR.getOpt(off, "ufmi_cost",0) : 0; let refi_val = MAR.getOpt(off, "refi_val",0); let refi_debt = MAR.getOpt(off, "refi_debt",0); mo.apr_rate_py = MAR.getOpt(off, "base",0); mo.apr = MAR.getOpt(off, "apr",0); mo.loan_duration = off.years*12; mo.costsAA = off._costsAA; mo.costsAA_ = off._costsAA_; mo.costsA = off._costsA; mo.costsA_ = off._costsA_; mo.costATot = off._costATot mo.appsum4p = off._appsum4p; mo.appsum1c2c = (parseFloat(purchace_price,10) - parseFloat(max_loan,10)) + parseFloat(mo.costATot,10) - final_ufmi_fin; if (off.is_refi) { mo.appsum1c2c = (parseFloat(refi_debt,10) - parseFloat(max_loan,10)) + parseFloat(mo.costATot,10) - final_ufmi_fin; } mo.aprcosts_lst = off.pd.aprcosts_lst; // "[buydwn_points=6500][......" mo.qmpass_list = off.pd.qmpass_list; // let cog = `settings`; mar.tmp_off = off; mar.tmp_off_da = da; let cog = `settings`; let rec = `tv`; cog = `${rec}${cog}`; if (mar.pg_tmp_am_i_the_lo() === false) { cog = ""; } mo.appsum4e = []; mo.appsum4e.push(["hh",`ESTIMATD CASH TO CLOSE ${cog}`].join("\t")); if (off.is_refi) { mo.appsum4e.push(["bg","*Mortgage pay off" ,refi_debt].join("\t")); if ( num(final_ufmi_fin) !== 0) { mo.appsum4e.push(["bg","*-Base Mortgage" ,max_loan].join("\t")); mo.appsum4e.push(["bg","*-Financed MI" ,(final_ufmi_fin)].join("\t")); } else { mo.appsum4e.push(["bg","*-Mortgage" ,max_loan].join("\t")); } if ((refi_debt-max_loan-final_ufmi_fin) < 0) { mo.appsum4e.push(["bd","Balance to receive" ,(refi_debt-max_loan-final_ufmi_fin)].join("\t")); } else { mo.appsum4e.push(["bd","Balance to pay" ,(refi_debt-max_loan)].join("\t")); } }else { mo.appsum4e.push(["bg","*Purchase Price" ,purchace_price].join("\t")); mo.appsum4e.push(["bg","*-Base Mortgage" ,max_loan].join("\t")); if ( num(final_ufmi_fin) !== 0) { mo.appsum4e.push(["bg","*-Financed MI" ,(final_ufmi_fin)].join("\t")); } if ((purchace_price-max_loan-final_ufmi_fin) < 0) { mo.appsum4e.push(["bd","Balance to receive" ,(purchace_price-max_loan)].join("\t")); } else { mo.appsum4e.push(["bd","Balance to pay" ,(purchace_price-max_loan-final_ufmi_fin)].join("\t")); } } mo.appsum4e.push(["bh","CLOSING COST"].join("\t")); // OriginationCharges : "A. Origination Charges", // ServicesYouCannotShopFor : "B. Services You Cannot Shop For", // ServicesYouCanShopFor : "C. Services You Can Shop For", // TaxesAndOtherGovernmentFees : "E. Taxes And Other Government Fees", // Prepaids : "F. Prepaids", // InitialEscrowPaymentAtClosing : "G. Initial Escrow Payment At Closing", // Other : "H. Other" mo.appsum4e.push(["bgh","Loan costs" ,mo.costsA_.OriginationCharges + mo.costsA_.ServicesYouCannotShopFor].join("\t")); // mo.appsum4e.push(["bgh","A. Origination Charges" ,mo.costsA_.OriginationCharges].join("\t")); for (let iijx in mo.costsAA_.OriginationCharges) { let A = (mo.aprcosts_lst.indexOf(`[${iijx}=`) > -1) ? `y` : ``; let Q = (mo.qmpass_list.indexOf(`[${iijx}=`) > -1) ? `y` : ``; mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA_.OriginationCharges[iijx] ,A ,Q].join("\t")); } // mo.appsum4e.push(["bgh","B. Services You Cannot Shop For" ,mo.costsA_.ServicesYouCannotShopFor].join("\t")); for (let iijx in mo.costsAA_.ServicesYouCannotShopFor) { let A = (mo.aprcosts_lst.indexOf(`[${iijx}=`) > -1) ? `y` : ``; let Q = (mo.qmpass_list.indexOf(`[${iijx}=`) > -1) ? `y` : ``; mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA_.ServicesYouCannotShopFor[iijx] ,A ,Q].join("\t")); } mo.appsum4e.push(["bgh","Other costs" ,mo.costsA_.ServicesYouCanShopFor].join("\t")); // mo.appsum4e.push(["bgh","C. Services You Can Shop For" ,mo.costsA_.ServicesYouCanShopFor].join("\t")); for (let iijx in mo.costsAA_.ServicesYouCanShopFor) { let A = (mo.aprcosts_lst.indexOf(`[${iijx}=`) > -1) ? `y` : ``; let Q = (mo.qmpass_list.indexOf(`[${iijx}=`) > -1) ? `y` : ``; mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA_.ServicesYouCanShopFor[iijx] ,A ,Q].join("\t")); } let total_loan_costs = num(mo.costsA_.OriginationCharges) + num(mo.costsA_.ServicesYouCannotShopFor) + num(mo.costsA_.ServicesYouCanShopFor); // mo.appsum4e.push(["bd","D. Total Loan Costs" ,total_loan_costs].join("\t")); // mo.appsum4e.push(["bgh","E. Taxes And Other Government Fees" ,mo.costsA_.TaxesAndOtherGovernmentFees].join("\t")); mo.appsum4e.push(["bgh","Taxes" ,mo.costsA_.TaxesAndOtherGovernmentFees].join("\t")); for (let iijx in mo.costsAA_.TaxesAndOtherGovernmentFees) { let A = (mo.aprcosts_lst.indexOf(`[${iijx}=`) > -1) ? `y` : ``; let Q = (mo.qmpass_list.indexOf(`[${iijx}=`) > -1) ? `y` : ``; mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA_.TaxesAndOtherGovernmentFees[iijx] ,A ,Q].join("\t")); } // mo.appsum4e.push(["bgh","F. Prepaids" ,mo.costsA_.Prepaids].join("\t")); // mo.appsum4e.push(["bgh","Prepaids" ,mo.costsA_.Prepaids].join("\t")); // for (let iijx in mo.costsAA_.Prepaids) { // mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA_.Prepaids[iijx]].join("\t")); // } // mo.appsum4e.push(["bgh","G. Initial Escrow Payment At Closing" ,mo.costsA_.InitialEscrowPaymentAtClosing].join("\t")); // mo.appsum4e.push(["bgh","Escrows" ,mo.costsA_.InitialEscrowPaymentAtClosing].join("\t")); // for (let iijx in mo.costsAA_.InitialEscrowPaymentAtClosing) { // mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA_.InitialEscrowPaymentAtClosing[iijx]].join("\t")); // } // mo.appsum4e.push(["bgh","H. Other" ,mo.costsA_.Other].join("\t")); mo.appsum4e.push(["bgh","Other" ,mo.costsA_.Other].join("\t")); for (let iijx in mo.costsAA_.Other) { let A = (mo.aprcosts_lst.indexOf(`[${iijx}=`) > -1) ? `y` : ``; let Q = (mo.qmpass_list.indexOf(`[${iijx}=`) > -1) ? `y` : ``; mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA_.Other[iijx] ,A ,Q].join("\t")); } let total_other_costs = num(mo.costsA_.TaxesAndOtherGovernmentFees) + num(mo.costsA_.Prepaids) + num(mo.costsA_.InitialEscrowPaymentAtClosing)+ num(mo.costsA_.Other); let total_closing_costs = (total_loan_costs + total_other_costs); // mo.appsum4e.push(["bd","I. Total Other Costs" ,total_other_costs].join("\t")); // mo.appsum4e.push(["bd","J. Total Closing Costs" ,total_closing_costs].join("\t")); mo.appsum4e.push(["bd","TOTAL CLOSING COST" ,total_closing_costs - mo.costsA_.Prepaids].join("\t")); mo.appsum4e.push(["bd","ESTIMATED PREPAID & ESCROWS" , mo.costsA_.Prepaids + mo.costsA_.InitialEscrowPaymentAtClosing].join("\t")); /* mo.appsum4e.push(["bgh","Lender fees" ,mo.costsA.lender_fees].join("\t")); for (let iijx in mo.costsAA.lender_fees) { mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA.lender_fees[iijx]].join("\t")); } if (num(mo.costsA.seller_credit) !== 0) { mo.appsum4e.push(["bgh","Seller credit" ,mo.costsA.seller_credit].join("\t")); } mo.appsum4e.push(["bgh","Title fees" ,mo.costsA.title_feed].join("\t")); for (let iijx in mo.costsAA.title_feed) { mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA.title_feed[iijx]].join("\t")); } mo.appsum4e.push(["bgh","Taxes" ,mo.costsA.tax].join("\t")); for (let iijx in mo.costsAA.tax) { mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA.tax[iijx]].join("\t")); } mo.appsum4e.push(["bgh","Additional" ,mo.costsA.additional].join("\t")); for (let iijx in mo.costsAA.additional) { mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA.additional[iijx]].join("\t")); } mo.appsum4e.push(["bd","TOTAL" ,(mo.costsA.lender_fees + mo.costsA.seller_credit +mo.costsA.title_feed + mo.costsA.tax + mo.costsA.additional)].join("\t")); mo.appsum4e.push(["bh","PREPAID ITEMS"].join("\t")); */ mo.appsum4e.push(["bgh","Prepaids" ,mo.costsA.prepaids].join("\t")); // for (let iijx in mo.costsAA.prepaids) { // mo.appsum4e.push(["bgs",""+iijx ,mo.costsAA.prepaids[iijx]].join("\t")); // } // mo.appsum4e.push(["bd","TOTAL" ,(mo.costsA.prepaids)].join("\t")); mo.appsum4e.push(["fb","Cash you need to close:" ,mo.appsum1c2c].join("\t")); h = ""; if (mar.pg_tmp_am_i_the_lo()) { if (MAR.getOpt(mar.tmp_trackdata, "opened", "") !== "") { h += `
    This Loan HAS been opened by the Client

    ` } } if (mar.pg_tmp_am_i_the_lo() === true) { // let saved_item = da; // let FE = MAR.getOpt(saved_item, "FE", false); // let BE = MAR.getOpt(saved_item, "BE", false); // if (FE !== false && BE !== false) { // detail = `${elaineui.format("perc2",FE)} / ${elaineui.format("perc2",BE)}` // h += `
    FE / BE
    ${detail}
    `; // } h += mar.tmp_rq_topgrid_html(`rqpage`); h += `
    `; } h += '
    '; h +='
    '; let mmr = mo.appsum4e; console.log('mortgage : ', mo); console.log('MMR : ', mmr); mmr[0] = `hhy ESTIMATED CASH TO CLOSE ${cog}`; h += makeC2Cpopup(mmr, 'c2c', mo); let cash2close_outside_closing = MAR.getOptNum(da, "febe.cash2close_outside_closing",0); if (cash2close_outside_closing !== false && cash2close_outside_closing > 0) { h += frm.h2(`
    Prior to closing, you will need to pay off ${elaineui.format("cur",cash2close_outside_closing)} in liabilities. You should budget for these cost, in addition to your closing cost.
    `).render(); } mar.appsum4details = function() { // var $e = $("#appsum4details"); // var h = ""; // for (x in mortgage.costsAA) { // var costsAA = mortgage.costsAA[x]; // h += "

    "+x+"

    "; // // for (var y in costsAA) { // if (costsAA[y] != 0) { // h += "
    "+y+":"+costsAA[y]+"
    "; // } // } // } // $e.html(h); } h +='
    '; let is_refi = (off._pd.loantype.toLowerCase().indexOf("refi") > -1) || (off._pd.loantype.toLowerCase().indexOf("cashout") > -1); if (is_refi) { let saving = off.total_costs - (off._pd.saving_escrow + off._pd.saving_2x_pmt) let tip = ""; tip += `BENEFITS BECAUSE OF REFINANCE`; tip += "

    "; tip += `The pay-off from your old lender usually includes the last mortgage payment. At closing, you will pre-pay the remainder of the current month. `+ `This means you would skip two monthly payments totaling ${elaineui.format("cur",off._pd.saving_2x_pmt)}. `+ `After closing you will be refunded your ${elaineui.format("cur",off._pd.saving_escrow)} est. escrow account from the old lender. `; if (saving < 0) { tip += `

    This means your take home is increased to ${elaineui.format("cur",(saving*-1))}.`; } else { tip += `

    This means your net closing cost are reduced to ${elaineui.format("cur",saving)}.`; } h += frm.inline_warning_green_noexclamationmark(`${tip}`); } h += frm.h2("
    This is not an approval for the loan. Your application has not been reviewed by an Underwriter.
    ").render(); // h += elaineui.format("cur",off._pd.savings_over_dur); // h += "
    ";//end breakdown holder left // h += "
    ";//end rowholder // // h += "
    "; // h += "
    "; // if (is_refi && num(off.total_costs) < 0) { // h += "Est. cash out amount"; // } else { // h += "Est. cash to close (to pay)"; // } // h += "
    ";//end breakdown holder left // h += "
    "; // h += elaineui.format("cur",off.total_costs); // h += "
    ";//end breakdown holder left // h += "
    ";//end rowholder // // h += "
    "; // h += "
    "; // h += "Expected savings due to "; // h += "
    - Due to skipping 2 monthly Pmts"; // h += "
    - Due to escrow rebate"; // h += "
    Total savings over life of loan"; // h += "
    ";//end breakdown holder left // h += "
    "; // h += ""; // // h += "
    " + elaineui.format("cur",off._pd.saving_2x_pmt); // // h += "
    " + elaineui.format("cur",off._pd.saving_escrow); // // h += "
    " + elaineui.format("cur",off._pd.saving_total) + ""; // h +="
    " + MAR.getOpt(off, "txt_ass_short",[]).join("
    ") + // "

    " + `Your actual rate, payment, and cost could be higher. Get an official Loan Estimate before choosing a loan.` + // "

    " + off.txt_co.join("
    ") + "

    " + ""; // h +="
    This calculation used an estimated market rate of " + // "" + elaineui.format("perc3",mortgage.apr_rate_py) + // " with an APR of " + // "" + elaineui.format("perc3",mortgage.apr) + // " for a " + // "" + elaineui.format("num",mortgage.loan_duration/12) + // " year fully amortizing loan."; // h +="Get an official quote by completing this loan application from your licensed Loan Officer " + // loanofficer.name + // " with NMLS ID " + // loanofficer.nmls + // ". Your actual rate, payment, and cost could be higher."; // h +=" Get an official Loan Estimate before choosing a loan.

    "; // h +="Read more"; h += "
    "; h += "
    "; h += "The information provided above regarding Approximate Cost of Closing Fees, " + "Approximate Total Funds Needed To Close and the Approximate Total Monthly " + "Payment (collectively referred to as Approximate Loan Cost Illustration) " + "are only approximations. The actual fees, cost and monthly payment on your specific " + "loan transaction may vary and may include additional fees and cost. "; h += "
    "; h +="

    ";//end grey disclaimner h += "
    "; let buttonText = ""; let popupText = ""; let _act = ""; let _goto = ""; let _more = ""; let _moreText = ""; let _more_div = ""; let _no_buton = "Cancel"; let _continueButtonText = "Continue"; let _hb_continue_skip = false; if (mar.pg_tmp_am_i_the_lo() === true) { } else { // the Client always ends up here /* -- this is only if there has not been any quotes saved -- */ if (saved_1 === false) { _act = "select send passed go"; _goto = "#declarations-p1."+applicantnum; if (mar.tmp_we_were_forced_to_ratequote === true) { _goto = "#lox"; mar.tmp_we_were_forced_to_ratequote = false; } else if (MAR.appnav.loanWasSubmitted()) { _goto = "#declarations-p1."+applicantnum; } else { _goto = "#lox"; } _continueButtonText = "Yes"; popupText = `Are you sure you would like to continue with this offer selected.`; buttonText = `Select this offer to move forward with`; $(".dr-button.next-button").html("Continue").addClass("x-hide"); } // here ? if (saved_1 === true) { _act = "send"; _goto = mvc.get("referrer_ratequote"); let page_to_return_to = mvc.get("referrer_ratequote"); if (typeof page_to_return_to === "string" && page_to_return_to !== "") { _goto = page_to_return_to; } // if not passed if (mar.WE_ARE_FROM_LOI === false) { if (mar.tmp_we_were_forced_to_ratequote === true) { _goto = "#lox"; mar.tmp_we_were_forced_to_ratequote = false; } else if (MAR.appnav.loanWasSubmitted()) { _goto = "#declarations-p1."+applicantnum; } else { _goto = "#lox"; } } _hb_continue_skip = true; $(".dr-button.next-button").html("Continue").removeClass("x-hide"); if (num(version) > 2) { _more = _goto _moreText = "Back to Options"; popupText = `Select this to move forward with instead of the current option?`; _continueButtonText = "Yes"; _act = "select send go"; $(".dr-button.next-button").html("Select1").removeClass("x-hide"); $(".dr-button.next-button").removeClass("x-hide"); _hb_continue_skip = false; } } } tmp_hb_continue_fn = function(_source){ /** * * We can use * mar.tmp_is_selectedvv * mar.tmp_is_visible * mar.tmp_is_locked * mar.tmp_is_sent * */ /** * if this is a skip * * _hb_continue_skip is always false for the LO * _hb_continue_skip is true for the client IF the client has just been sent the offer to read */ if (_hb_continue_skip && _source === `continue`) { if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_ratequote_0_passed_cli","Y"); } setScenario_data("__scenario_ratequote_0_passed","Y"); mar.fakesave(function(){ if (typeof _goto === "string" && _goto !== "") mvc.go(_goto); }); return; } /* -- if there is NOTHING saved and youare the client it definately comes here */ var s = document.createElement("div"); s.setAttribute("class","normal-form"); if (mar.pg_tmp_am_i_the_lo() === true) { if (mar.tmp_is_selected && mar.tmp_is_locked !== false) { popupText = `This proposal is not visible to the client, Are you sure you want to continue without sending to the client`; _act = "passed go"; _goto = "#declarations-p1."+applicantnum; _no_buton = "No"; _continueButtonText = "Yes"; } if (mar.tmp_is_selected && mar.tmp_is_sent === false) { popupText = `This proposal has not been sent to the client, Are you sure you want to continue without sending to the client`; _act = "passed go"; _goto = "#declarations-p1."+applicantnum; _no_buton = "No"; _continueButtonText = "Yes"; } else if (mar.tmp_is_visible === false) { popupText = `This proposal is not visible to the client, Are you sure you want to continue without sending to the client`; _act = "passed go"; _goto = "#declarations-p1."+applicantnum; _no_buton = "No"; _continueButtonText = "Yes"; } else { if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_ratequote_0_passed_cli","Y"); } setScenario_data("__scenario_ratequote_0_passed","Y"); mar.fakesave(function(){ if (typeof _goto === "string") mvc.go(_goto); }); return; } } s.innerHTML = ""+ "
    "+ "
    "+ popupText + // frm.radio("proposal_delivery_method","",'both',"","",function(){ // //oc(); // },{ // mail : "Send by mail", // text : "Send by text", // both : "Both" // }).render(); "
    "+ "
    "; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : _no_buton, call : { text: _continueButtonText, value: "print", closeModal: false } } }) .then((act) => { console.log(_act); if (act == "print") { let action_print = (_act.indexOf("print") > -1); let action_select = (_act.indexOf("select") > -1); let action_send = (_act.indexOf("send") > -1); let action_copy = (_act.indexOf("copy") > -1); let action_go = (_act.indexOf("go") > -1); let action_passed = (_act.indexOf("passed") > -1); let action_enc_sync = false; let optional_send = (_act.indexOf("optionalsend") > -1); if (optional_send) { if ($("#informclient").prop("checked") !== false) { action_send = true; } } let optional_select = (_act.indexOf("optionalselect") > -1); if (optional_select) { if ($("#makelive").prop("checked") !== false) { action_select = true; } } let customElement = $(`
    `+ `
    `+ `
    `+ `
    `+ `
    `); $("body-container").LoadingOverlay("show", { image : "", background : "#00000066", custom : customElement }); let lov = function(txt) { $(".loadingoverlaycustom .msg").html(txt); } let next = function(){ swal.close(); if (action_select) { setScenario_data("__scenario_"+"ratequote2_0"+"_passed","Y"); lov("Selecting Loan"); action_enc_sync = true; mar.fakesave("",function(){ /* -- you are never the LO in this statement -- */ // if (mar.pg_tmp_am_i_the_lo()) { // $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/2?from=${version}`, function(da){ // MAR.ifOpt(da, "sc_obj", function(sco){ // for (x in sco) { // setScenario_data(x, sco[x]); // } // mar.fakesave(); // }); // }); // } let role = (mar.pg_tmp_am_i_the_lo()) ? "lo" : "cli"; $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/1?from=${version}&role=${role}`, function(da){ MAR.ifOpt(da, "sc_obj", function(sco){ for (x in sco) { setScenario_data(x, sco[x]); } mar.fakesave(); }); action_select = false; if (version === "0" || version === 0 || version === "") { $.get(`/api/chatbot/delSavedRate/${mar.ID}/0`, function(){ version = "1"; next(); }); } else { version = "1"; next(); } }); }); return; }; // if (action_print) { // lov("Printing"); // $(".result-hidden").html(mar.pg["scenario-ratequote1"].makeTable(mar.tmp_off,version)); // $(".result").addClass("x-hide"); // $(".result-hidden").removeClass("x-hide"); // $(".du-summary-footer").prop("id","bottom_no_print"); // $(".page_x_of_2").html("1"); // action_print = false; // next(); // return; // } if (action_send) { let methods = ["email","sms"]; let from = (mar.pg_tmp_am_i_the_lo()) ? "lo" : "client"; if (methods.length > 0) { lov("Sending"); $.get(`/api/chatbot/sendSavedRate/${mar.ID}/${version}?from=${from}&methods=${methods.join(",")}`, function(da){ action_send = false; next(); }); return; } } if (action_passed) { if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_"+"ratequote_0_passed_cli","Y"); } setScenario_data("__scenario_"+"ratequote2_0"+"_passed","Y"); mar.fakesave("",function(){ action_passed = false; next(); }); return; } $("body-container").LoadingOverlay("hide",true); if (action_enc_sync === true && mar.pg_tmp_am_i_the_lo() === true) { action_enc_sync = false; mar.tmp_check_rq_encompass(function(){ next(); }); return; } if (action_go) { mar.tmp_we_were_forced_to_ratequote = false; if (typeof _goto === "string") mvc.go(_goto); } } next(); return; /* var myItems = $('#proposalToClosePrint'); var pdf = new jsPDF(); pdf.text(5, 5, 'CASH TO CLOSE CALCULATION'); pdf.text(5, 30, myItems.text()); pdf.save('proposal.pdf'); */ } }); }; /** * start block */ if (mar.pg_tmp_am_i_the_lo() === true) { h += ``; h += ``; h += ``; h += `
    `; let saved_item = da; let selected = mar.tmp_selected; let visibility = mar.tmp_visibiity; let tracked = mar.tmp_tracked; let locked = mar.tmp_locked; let idx = mar.tmp_idx; let video = da.video; let rq_name = da.name; // let trackdata = MAR.getOpt(da, "trackdata", {}); // mar.tmp_trackdata = trackdata; // mar.tmp_saved_1 = saved_1; // mar.tmp_selected = da.selected; // mar.tmp_sel_idx = da.sel_idx; // mar.tmp_tracked = da.tracked; // mar.tmp_visibiity = da.visibility; (function(){ let rqv = MAR.getOpt(saved_item, "trackdata.opened", ""); let rqvp = MAR.getOpt(saved_item, "trackdata.pdf", null); let rqvo = MAR.getOpt(saved_item, "trackdata.open", null); let rqvs = MAR.getOpt(saved_item, "trackdata.video", null); let rqve = MAR.getOpt(saved_item, "trackdata.video_end", null); let rqv_ts = MAR.getOpt(saved_item, "trackdata.opened_ts", ""); let rqvp_ts = MAR.getOpt(saved_item, "trackdata.pdf_ts", null); let rqvo_ts = MAR.getOpt(saved_item, "trackdata.open_ts", null); let rqvs_ts = MAR.getOpt(saved_item, "trackdata.video_ts", null); let rqve_ts = MAR.getOpt(saved_item, "trackdata.video_end_ts", null); let rqv_m = MAR.getOpt(saved_item, "trackdata.opened_m.txt", ""); let rqvp_m = MAR.getOpt(saved_item, "trackdata.pdf_m.txt", null); let rqvo_m = MAR.getOpt(saved_item, "trackdata.open_m.txt", null); let rqvs_m = MAR.getOpt(saved_item, "trackdata.video_m.txt", null); let rqve_m = MAR.getOpt(saved_item, "trackdata.video_end_m.txt", null); let rqst_m = MAR.getOpt(saved_item, "trackdata.start_m.txt", ""); let detail = `---`; /** * THIS IS P2 OF THE PROOOPOSAL */ h += `
    Loan Proposal Control Panel
    `; /** * if this version 0, then offer to save it as "prepared offer (1/2/3)" and nothing else. * then reload the page * * if this is another version * * offer to upload a video. * * is it (NOT) locked? * Offer to publish and send to client * * * offer to duplicate as basis of a new offer * * * * * */ // let btn_dupe = frm.yn3(`sel_duplicate_version_${idx}`,"","N","","",function(elm){ // let id = elm.id; // let idx = id.split("_").pop(); // let val = yn3(`#${id}`); // // if (val === "Y") { // $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/99?from=${version}`, function(da){ // let new_version = da.version; // // $.get(`/api/chatbot/setRqLock/${mar.ID}/${new_version}?val=N`, function(){ // mar.tmp_hb_scroll_to_bottom = true; // if (version === "0" || version === 0 || version === "") { // $.get(`/api/chatbot/delSavedRate/${mar.ID}/0`, function(){ // mvc.go(`#scenario-ratequote2.0.${new_version}`); // }); // } else { // mvc.go(`#scenario-ratequote2.0.${new_version}`); // } // }); // }); // } // // },{}).render(); mar.tmp_btn_dupe_click = function(){ elaineui.swalprompt({ title : "Duplicate this loan", txt : `Do you want to make another proposal based on this one.`, ok : "Yes", okfn : function(opts) { mar.tmp_btn_dupe_click_yes(); }, cancel : "Cancel", cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", cancelfn : function() { }, ondisplay : function() { // $("#swal_opt_form .xx-check3").mycheck3(); }, opts : { closeOnClickOutside : false, closeOnEsc : false } }); } mar.tmp_btn_dupe_click_yes = function(){ $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/99?from=${version}`, function(da){ let new_version = da.version; /** * recalc so that we get the summary texts */ $.get(`/api/chatbot/recalculateVersion/${mar.ID}/${new_version}`, function(da){ /** * set the lock */ $.get(`/api/chatbot/setRqLock/${mar.ID}/${new_version}?val=N`, function(){ mar.tmp_hb_scroll_to_bottom = true; // here ? if (version === "0" || version === 0 || version === "") { $.get(`/api/chatbot/delSavedRate/${mar.ID}/0`, function(){ mvc.go(`#scenario-ratequote2.0.${new_version}`); }); } else { mvc.go(`#scenario-ratequote2.0.${new_version}`); } }); }); }); } btn_dupe = `content_copy`; let btn_remove = frm.yn3(`sel_remove_version_${idx}`,"","N","","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); if (val === "Y") { // $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/99?from=${version}`, function(da){ // let new_version = da.version; // // $.get(`/api/chatbot/setRqLock/${mar.ID}/${new_version}?val=N`, function(){ // mar.tmp_hb_scroll_to_bottom = true; // mvc.go(`#scenario-ratequote2.0.${new_version}`); // }); // }); } },{}).render(); mar.tmp_btn_remove_click = function(){ elaineui.swalprompt({ title : "Remove proposal", txt : `Do you want to delete this proposal.`, ok : "Yes", okfn : function(opts) { mar.tmp_btn_remove_click_yes(); }, cancel : "Cancel", cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", cancelfn : function() { }, ondisplay : function() { // $("#swal_opt_form .xx-check3").mycheck3(); }, opts : { closeOnClickOutside : false, closeOnEsc : false } }); } mar.tmp_btn_remove_click_yes = function(){ } btn_remove = `delete`; if (version === "0" || version === "") { let btn_save = frm.yn3(`sel_save_as_version_${idx}`,"","N","","",async function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); if (val === "Y") { let getSync = function(url) { return new Promise(function(resolve, reject){ $.get(url, function(da){ resolve(da); }); }); } let fakeSaveSync = function() { return new Promise(function(resolve, reject){ mar.fakesave("",function(){ resolve(); }); }); } let extra = ``; extra += `&set_live=opt`; // set live - optionally if there is no selected loan // extra += `&trk=Y`; // track // extra += `&vis=Y`; // make visible extra += `&slot=Y`; // put it in a slot // extra += `&snd=Y`; // send link $("#body-container").LoadingOverlay("show"); let da = await getSync(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/99?from=0${extra}`); let new_version = da.version; let sco = MAR.getOpt(da, "sc_obj", false); if (sco !== false) { for (x in da.sco) { setScenario_data(x, sco[x]); } await fakeSaveSync(); } let da1 = await getSync(`/api/chatbot/setRqLock/${mar.ID}/${new_version}?val=Y`); let da2 = await getSync(`/api/chatbot/delSavedRate/${mar.ID}/0`); mar.tmp_hb_scroll_to_bottom = true; mvc.go(`#scenario-ratequote2.0.${new_version}`); return; // let txt = ``; // // txt += `
    In addition to saving the proposal would you also like to:
    `; // txt += `
    `; // txt += `
    Make visible to the client
    `+ // frm.yn3(`swal_opt_publish_yn3`,"", "N","","",function(elm){},{}).render()+ // `
    `; // // txt += `
    Send to client
    `+ // frm.yn3(`swal_opt_send_yn3`,"", "N","","",function(elm){},{}).render()+ // `
    `; // // txt += `
    Set as primary loan
    `+ // frm.yn3(`swal_opt_primary_yn3`,"", "N","","",function(elm){},{}).render()+ // `
    `; // // txt += `
    `; // txt = txt.wrap(`
    `,`
    `); // // elaineui.swalprompt({ // title : "Save finished proposal", // txt : txt, // ok : "Save", // okfn : async function(opts) { // let pub = yn3(`#swal_opt_publish_yn3`); // let pri = yn3(`#swal_opt_primary_yn3`); // let snd = yn3(`#swal_opt_send_yn3`); // // alert(`pub ${pub} pri ${pri} snd ${snd}`); // // let extra = ``; // if (pri === `Y`) { // extra += `&set_live=y`; // extra += `&trk=Y`; // } // if (pub === `Y`) { // extra += `&vis=Y`; // } else { // extra += `&slot=Y`; // } // if (snd === `Y`) { // extra += `&snd=Y`; // } // // let da = await getSync(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/99?from=0${extra}`); // let new_version = da.version; // // let sco = MAR.getOpt(da, "sc_obj", false); // if (sco !== false) { // for (x in da.sco) { // setScenario_data(x, sco[x]); // } // await fakeSaveSync(); // } // // let da1 = await getSync(`/api/chatbot/setRqLock/${mar.ID}/${new_version}?val=Y`); // let da2 = await getSync(`/api/chatbot/delSavedRate/${mar.ID}/0`); // // mar.tmp_hb_scroll_to_bottom = true; // mvc.go(`#scenario-ratequote2.0.${new_version}`); // // }, // cancel : "Cancel", // cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", // cancelfn : function() { // yn3(`#${id}`,`N`); // $(`#${id}`).change(); // }, // ondisplay : function() { // $("#swal_opt_form .xx-check3").mycheck3(); // }, // opts : { // closeOnClickOutside : false, // closeOnEsc : false // } // }); // let doit = function() { // $.get(`/api/chatbot/saveAgreedRateAsVersion/${mar.ID}/99?from=0`, function(da){ // let new_version = da.version; // $.get(`/api/chatbot/setRqLock/${mar.ID}/${new_version}?val=N`, function(){ //// mar.tmp_was_recalculated = `#scenario-ratequote2.0.${new_version}.E`; // $.get(`/api/chatbot/delSavedRate/${mar.ID}/0`, function(){ // mar.tmp_hb_scroll_to_bottom = true; // mvc.go(`#scenario-ratequote2.0.${new_version}`); // }); // }); // }); // } } },{}).render(); /* general ratequote P2, version = 0 or "" -- this is the main route you will see on new loans */ h += `
    Save finished proposal
    ${btn_save}
    `; _goto = "#declarations-p1."+applicantnum; $(".dr-button.next-button").html("Continue").addClass("x-hide"); $(".dr-button.next-button").html("Continue").removeClass("x-hide"); return; } /* -- NOTE THIS CAN RETURN ABOVE THE LINE -- */ _goto = "#declarations-p1."+applicantnum; $(".dr-button.next-button").html("Continue").removeClass("x-hide"); $(".dr-button.next-button").removeClass("x-hide"); mar.tmp_btn_video_dropzone_enable = function() { mar.tmp_oncomplete_video = function(){ let src = `/api/chatbot/video/${mar.ID}/${idx}`; let log = `/api/chatbot/video_log/${mar.ID}/${idx}`; let h = ``; h += `
    `; h += ``; if (mar.pg_tmp_am_i_the_lo() === true) { h += `delete_forever`; } h += `
    `; $(`.x-uploadvideo .uploadvideo`).replaceWith(h); $(`.x-uploadvideo-but`).addClass(`x-hide`); } let $newdropzone = $(`.x-uploadvideo .uploadvideo.new`); if ($newdropzone.length > 0) { $newdropzone.removeClass(`new`) mar.filepupload.upload($newdropzone,{ clickable : true, maxFilesize : 2000, appid : mar.ID, rqnum : true, //$newdropzone.data("rqnum"), oncomplete_fn : `tmp_oncomplete_video`, uid : mar.userid }); } } let btn_video = frm.yn3(`sel_live_rate_vid_${idx}`,"", "N","","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); if (val === "N") { $(`.x-uploadvideo .uploadvideo`).addClass(`x-hide-imp`); } else { mar.tmp_btn_video_dropzone_enable(); // mar.tmp_oncomplete_video = function(){ // // let src = `/api/chatbot/video/${mar.ID}/${idx}`; // let log = `/api/chatbot/video_log/${mar.ID}/${idx}`; // let h = ``; // h += `
    `; // h += ``; // if (mar.pg_tmp_am_i_the_lo() === true) { // h += `delete_forever`; // } // h += `
    `; // // // $(`.x-uploadvideo .uploadvideo`).replaceWith(h); // $(`.x-uploadvideo-but`).addClass(`x-hide`); // } // // let $newdropzone = $(`.x-uploadvideo .uploadvideo.new`); // if ($newdropzone.length > 0) { // $newdropzone.removeClass(`new`) // mar.filepupload.upload($newdropzone,{ // clickable : true, // maxFilesize : 2000, // appid : mar.ID, // rqnum : true, //$newdropzone.data("rqnum"), // oncomplete_fn : `tmp_oncomplete_video`, // uid : mar.userid // }); // } $(`.x-uploadvideo .uploadvideo`).removeClass(`x-hide-imp`); } },{}).render(); let btn_track = frm.yn3(`sel_live_rate_trk_${idx}`,"",tracked,"","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); $("#body-container").LoadingOverlay("show"); $.get(`/api/chatbot/setRqTracking/${mar.ID}/${idx}?val=${val}`, function(){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); },{}).render(); let btn_sendb = frm.but(`Send`,function(elm){ $("#body-container").LoadingOverlay("show"); $.get(`/api/chatbot/sendSavedRate/${mar.ID}/${mar.btn_send_idx}?from=lo&methods=email,sms`, function(){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); },{ style : `width: 110px;background-color: var(--green);` }).render(); let btn_send = frm.yn3(`sel_live_rate_snd_${idx}`,"","N","","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); if (val === "Y") { $("#body-container").LoadingOverlay("show"); $.get(`/api/chatbot/sendSavedRate/${mar.ID}/${idx}?from=lo&methods=email,sms`, function(){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); } },{}).render(); let btn_publish = frm.yn3(`sel_live_rate_vis_${idx}`,"",((locked === "Y") ? "Y" : "N"),"","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); if (val === "N") { $("#body-container").LoadingOverlay("show"); $.get(`/api/chatbot/setRqLock/${mar.ID}/${idx}?val=N`, function(){ $.get(`/api/chatbot/clearRateTracking/${mar.ID}/${idx}`, function(){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); }); } if (val === "Y") { $("#body-container").LoadingOverlay("show"); $.get(`/api/chatbot/setRqLock/${mar.ID}/${idx}?val=Y`, function(){ $.get(`/api/chatbot/sendSavedRate/${mar.ID}/${idx}?from=lo&methods=email,sms`, function(){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); }); } },{}).render(); let btn_select_as_primary_ro = frm.yn3(`sel_live_rate_sel_${idx}`,"","Y","","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); // swal(`You cannot change the value , select another loan amd make it primary`) yn3(`#${id}`,'Y'); $(`#${id}`).change(); },{}).render(); let btn_select_as_primary = frm.yn3(`sel_live_rate_sel_${idx}`,"","N","","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); if (val === "Y") { let enc = "N"; // yn3(`#sel_live_rate_enc_${idx}`); let trk = "Y"; // yn3(`#sel_live_rate_trk_${idx}`); let snd = "N"; // yn3(`#sel_live_rate_snd_${idx}`); let vid = "N"; // yn3(`#sel_live_rate_vid_${idx}`); let _setlive = "y"; // (val === "Y") ? "y" : "n"; console.log(idx,trk,enc,snd,existingid,saved_1,vid, _setlive); $("#body-container").LoadingOverlay("show"); mar.tmp_sel_live_rate(idx,trk,enc,snd,existingid,saved_1,vid, _setlive, function(){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); } // $.get(`/api/chatbot/setRqLock/${mar.ID}/${idx}?val=Y`, function(){ // mar.tmp_hb_scroll_to_bottom = true; // $("#body-container").LoadingOverlay("show"); // mvc.go(location.hash); // }); },{}).render(); /* general ratequote P2 */ mar.tmp_name = (function(){ let h = ``; if (rq_name === '') { rq_name = da.data.title_f; } h += `
    Proposal name
    `; return h; })(); mar.tmp_name_change = function(elm) { let id = elm.id; let idx = id.split("_").pop(); let val = txt(`#${id}`); $("#body-container").LoadingOverlay("show"); $.post(`/api/chatbot/setRqName/${mar.ID}/${idx}`,{val:`${val}`}, function(){ $("#body-container").LoadingOverlay("hide",true); }); } if (selected) { h += `
    Selected loan proposal
     
    `; } if (mar.tmp_in_slot < 0) { /** * this is very much a legacy thing , ponly if we have an old proposal , * all new proposals will be put in a slot when they are saved. * */ let btn_save = frm.yn3(`sel_save_version_${idx}`,"","N","","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); if (val === "Y") { $("#body-container").LoadingOverlay("show"); $.get(`/api/chatbot/setRqLock/${mar.ID}/${version}?val=N`, function(){ $.get(`/api/chatbot/clearRateTracking/${mar.ID}/${version}`, function(){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(`#scenario-ratequote2.0.${version}`); }); }); } },{}).render(); /* general ratequote P2 */ h += `
    Save finished proposal
    ${btn_save}
    `; _goto = "#declarations-p1."+applicantnum; $(".dr-button.next-button").html("Continue").addClass("x-hide"); return; } else { h += `
    Proposal number
    #${mar.tmp_in_slot}
    `; } h += `
    ${mar.tmp_name}
    `; h += `
    `; /* this seems to be the main on on P2 */ if (video) { h += `
    Explainer video (Max 1 per proposal)
    `; let src = `/api/chatbot/video/${mar.ID}/${idx}`; let log = `/api/chatbot/video_log/${mar.ID}/${idx}`; let hh = ``; hh += `
    `; hh += ``; if (mar.pg_tmp_am_i_the_lo() === true) { mar.tmp_delete_video = function(version) { $("#body-container").LoadingOverlay("show"); $.get(`/api/chatbot/delSavedRateVideo/${mar.ID}/${version}`, function(da){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); } hh += `delete_forever`; } hh += `
    `; h += `
    ${hh}
    `; // $(`.x-uploadvideo .uploadvideo`).replaceWith(h); let video_status = []; if (video && (rqvs !== "" && rqvs !== "-")) { detail = (!video) ? `N/A` : (rqvs !== "" && rqvs !== "-") ? rqvs_m.split(" at")[0] : `Not Yet`; // h += `
    Video Opened
    ${detail}
    `; video_status.push(`Video opened ${detail}`); } else { video_status.push(`Video not opened yet`); } if (video && (rqve !== "" && rqve !== "-")) { detail = (!video) ? `N/A` : (rqve !== "" && rqve !== "-") ? rqve_m : `Partial`; // h += `
    Video Watched
    ${detail}
    `; video_status.push(`watched ${detail}`); } else { video_status.push(`not watched`); } h += `
    ${video_status.join(", and ")}
    `; } else { h += `
    Explainer video (Max 1 per proposal)
    `; // h += `
    Upload Video for the client
    ${btn_video}
    `; h += `
    `; h += `
    Drop Video Here ${idx}
    `; h += `
    `; h += ``; } h += ``; h += `
    `; if (!selected) { h += `
    Primary loan
    ${btn_select_as_primary}
    `; h += `
    `; } else { h += `
    Primary loan
    ${btn_select_as_primary_ro}
    `; h += `
    Include tracking in Daily To-Do
    ${btn_track}
    `; h += `
    `; } let is_sent = false; if (visibility === "hidden") { h += `
    Push to the client
    ${btn_publish}
    `; h += `
    `; } else { // let _ts = MAR.getOpt(saved_item, "_ts", ""); // let _tsm = MAR.getOpt(saved_item, "_tsm.txt", ""); let _ts = MAR.getOpt(saved_item, "trackdata.sent", ""); let _tsm = MAR.getOpt(saved_item, "trackdata.sent_m.txt", ""); let _tsm_diff = MAR.getOpt(saved_item, "trackdata.sent_m.diff_mins", -1); detail = `Not Yet`; if (_ts !== "") { if (_tsm_diff > -1 && _tsm_diff < 60) { detail = `Just now`; } else { detail = _tsm.split(" at")[0]; } is_sent = true; } console.error(`saved_item`,saved_item, `detail`,detail,_ts, _tsm); mar.btn_send_idx = idx; h += `
    Send Link to client
    ${btn_sendb}
    `; h += `
    Sent to the client
    ${detail}
    `; h += `
    `; (function() { let locked = MAR.getOpt(saved_item, "_locked", ""); let in_slot = MAR.getOpt(saved_item, "_in_slot", ""); detail = (rqv !== "") ? rqv_m.split(" at")[0] : `Not Yet`; h += `
    Proposal Opened
    ${detail}
    `; })(); // let btn_unsave = frm.yn3(`sel_unsave_as_version_${idx}`,"","N","","",function(elm){ // let id = elm.id; // let idx = id.split("_").pop(); // let val = yn3(`#${id}`); // // if (val === "Y") { // $.get(`/api/chatbot/setRqLock/${mar.ID}/${version}?val=D`, function(){ // mar.tmp_hb_scroll_to_bottom = true; // mvc.go(`#scenario-ratequote2.0.${version}`); // }); // } // // },{}).render(); // // h += `
    Remove as Proposal ${mar.tmp_in_slot}
    ${btn_unsave}
    `; } mar.tmp_is_selected = selected; mar.tmp_is_visible = (visibility !== "hidden"); mar.tmp_is_locked = (locked === "Y"); mar.tmp_is_sent = is_sent; // h += `
    You can make another proposal based on this one.
    `; // h += `
    Duplicate this loan
    ${btn_dupe}
    `; h += ``; // h += `
    `; // h += `
    You can delete this loan completely.
    `; // h += `
    Remove this loan
    ${btn_remove}
    `; h += ``; return; /** * everything below here is un-reachable */ // if (locked === "Y") { // // let btn_unsave = frm.yn3(`sel_unsave_as_version_${idx}`,"","N","","",function(elm){ // let id = elm.id; // let idx = id.split("_").pop(); // let val = yn3(`#${id}`); // // if (val === "Y") { // $.get(`/api/chatbot/setRqLock/${mar.ID}/${version}?val=D`, function(){ // mar.tmp_hb_scroll_to_bottom = true; // mvc.go(`#scenario-ratequote2.0.${version}`); // }); // } // // },{}).render(); // // //// h += `
    Remove as Proposal ${mar.tmp_in_slot}
    ${btn_unsave}
    `; // // // if (selected) { // h += `
    Selected loan proposal
     
    `; // } // // h += `
    Proposal number
    #${mar.tmp_in_slot}
    `; // // // here should be if video // // if (video) { // // h += `
    Explainer video (Max 1 per proposal)
    `; // // let src = `/api/chatbot/video/${mar.ID}/${idx}`; // let log = `/api/chatbot/video_log/${mar.ID}/${idx}`; // let hh = ``; // hh += `
    `; // hh += ``; // if (mar.pg_tmp_am_i_the_lo() === true) { // mar.tmp_delete_video = function(version) { // $("#body-container").LoadingOverlay("show"); // $.get(`/api/chatbot/delSavedRateVideo/${mar.ID}/${version}`, function(da){ // mar.tmp_hb_scroll_to_bottom = true; // mvc.go(location.hash); // }); // } // hh += `delete_forever`; // } // hh += `
    `; // // // h += `
    ${hh}
    `; // // // let video_status = []; // if (video && (rqvs !== "" && rqvs !== "-")) { // detail = (!video) ? `N/A` : (rqvs !== "" && rqvs !== "-") ? rqvs_m.split(" at")[0] : `Not Yet`; //// h += `
    Video Opened
    ${detail}
    `; // video_status.push(`Video opened ${detail}`); // } else { // video_status.push(`Video not opened yet`); // } // // if (video && (rqve !== "" && rqve !== "-")) { // detail = (!video) ? `N/A` : (rqve !== "" && rqve !== "-") ? rqve_m : `Partial`; //// h += `
    Video Watched
    ${detail}
    `; // video_status.push(`watched ${detail}`); // } else { // video_status.push(`not watched`); // } // h += `
    ${video_status.join(", and ")}
    `; // // // } else { // // h += `
    Explainer video (Max 1 per proposal)
    `; //// h += `
    Upload Video for the client
    ${btn_video}
    `; // h += `
    `; // h += `
    Drop Video Here ${idx}
    `; // h += `
    `; // // h += ``; // // h += ``; // // } // // // h += `
    Push to the client
    ${btn_publish}
    `; // h += `
    `; // // // if (!selected) { // h += `
    Select this as the primary loan
    ${btn_select_as_primary}
    `; // h += `
    `; // } //// h += `
    You can make another proposal based on this one.
    `; //// h += `
    Duplicate this loan
    ${btn_dupe}
    `; //// h += `
    `; // h += ``; // //// h += `
    You can delete this loan completely.
    `; //// h += `
    Remove this loan
    ${btn_remove}
    `; // h += ``; // // return; // // } // // // // detail = (rqst_m !== "") ? rqst_m : `--`; // h += `
    Proposal Saved
    ${detail}
    `; // //// detail = `--`; //// h += `
    Shared by
    ${detail}
    `; // // detail = (rqv !== "") ? rqv_m : `Not Yet`; // h += `
    Proposal Opened
    ${detail}
    `; // // if (video) { // // detail = (!video) ? `N/A` : (rqvs !== "" && rqvs !== "-") ? rqvs_m : `Not Yet`; // h += `
    Video Opened
    ${detail}
    `; // // if (video && (rqve !== "" && rqve !== "-")) { // detail = (!video) ? `N/A` : (rqve !== "" && rqve !== "-") ? rqve_m : `Partial`; // h += `
    Video Watched
    ${detail}
    `; // } // } // // if (selected) { // // let btn1 = frm.yn3(`sel_live_rate_snd_${idx}`,"","N","","",function(elm){ // let id = elm.id; // let idx = id.split("_").pop(); // let val = yn3(`#${id}`); // if (val === "Y") { // $.get(`/api/chatbot/sendSavedRate/${mar.ID}/${idx}?from=lo&methods=email,sms`, function(){ // $.get(`/api/chatbot/setRqLock/${mar.ID}/${idx}?val=Y`, function(){ //// $.get(`/api/chatbot/setRqVisibility/${mar.ID}/${idx}?val=visible`, function(){ // swal(`The offer has been sent the client`); //// txt(`#${id}`,"N"); //// $(`#${id}`).change(); // }); // }); // } // // },{}).render(); // // let btn2 = frm.yn3(`sel_live_rate_trk_${idx}`,"",tracked,"","",function(elm){ // let id = elm.id; // let idx = id.split("_").pop(); // let val = yn3(`#${id}`); // // $("#body-container").LoadingOverlay("show"); // $.get(`/api/chatbot/setRqTracking/${mar.ID}/${idx}?val=${val}`, function(){ // mar.tmp_hb_scroll_to_bottom = true; // mvc.go(location.hash); // }); // // },{}).render(); // // let btn3 = frm.yn3(`sel_live_rate_vis_${idx}`,"",((visibility === "hidden") ? "N" : "Y"),"","",function(elm){ // let id = elm.id; // let idx = id.split("_").pop(); // let val = yn3(`#${id}`); // // if (val === "N") { // swal(`You cannot hide the selected loan`); // $(elm).val("Y").change(); // } else if (visibility === "hidden") { // val = "visible"; // $("#body-container").LoadingOverlay("show"); // $.get(`/api/chatbot/setRqVisibility/${mar.ID}/${idx}?val=${val}`, function(){ // mar.tmp_hb_scroll_to_bottom = true; // mvc.go(location.hash); // }); // } // // },{}).render(); // /* general ratequote P2 */ // // h += `
    Proposal number
    #${mar.tmp_in_slot}
    `; // h += `
    Locked
    ${locked}
    `; // h += `
    Visible to the client
    ${btn3}
    `; // h += `
    Send loan proposal to client
    ${btn1}
    `; // h += `
    Include tracking in Daily To-Do
    ${btn2}
    `; // //// if (tracked ==="Y"){ //// h += `
    Tracking in Daily To-Do
    radio_button_checked
    `; //// //// } else { //// h += `
    Tracking in Daily To-Do
    radio_button_unchecked
    `; //// } // } else { // // let btn = frm.yn3(`sel_live_rate_${idx}`,"","N","","",function(elm,b,c){ // let id = elm.id; // let idx = id.split("_").pop(); // let val = yn3(`#${id}`); // // if (val === "Y") { // $(`.sel_live_rate_enc_row_${idx}`).removeClass("x-hide-imp"); // $(`.sel_live_rate_enc_row_n_${idx}`).addClass("x-hide-imp"); // // } else { // $(`.sel_live_rate_enc_row_${idx}`).addClass("x-hide-imp"); // $(`.sel_live_rate_enc_row_n_${idx}`).removeClass("x-hide-imp"); // } // // console.log(elm,b,c); //// if(txt("#samelineofwork") == 'N'){ //// $(".info-same").trigger('click'); //// } // }, {}).render(); // // let btn1 = frm.yn3(`sel_live_rate_snd_n_${idx}`,"","N","","",function(elm){ // let id = elm.id; // let idx = id.split("_").pop(); // let val = yn3(`#${id}`); // if (val === "Y") { // $.get(`/api/chatbot/sendSavedRate/${mar.ID}/${idx}?from=lo&methods=email,sms`, function(){ // $.get(`/api/chatbot/setRqLock/${mar.ID}/${idx}?val=Y`, function(){ //// $.get(`/api/chatbot/setRqVisibility/${mar.ID}/${idx}?val=visible`, function(){ // swal(`The offer has been sent the client`); //// txt(`#${id}`,"N"); //// $(`#${id}`).change(); // }); // }); // } // // },{}).render(); // // let btn3 = frm.yn3(`sel_live_rate_vis_${idx}`,"",((visibility === "hidden") ? "N" : "Y"),"","",function(elm){ // let id = elm.id; // let idx = id.split("_").pop(); // let val = (yn3(`#${id}`) === "Y") ? "visible" : "hidden"; // // $("#body-container").LoadingOverlay("show"); // $.get(`/api/chatbot/setRqVisibility/${mar.ID}/${idx}?val=${val}`, function(){ // mar.tmp_hb_scroll_to_bottom = true; // mvc.go(location.hash); // }); // // },{}).render(); // // // mar.tmp_sel_live_rate_2 = function(idx){ // let val = yn3(`#sel_live_rate_${idx}`); // let enc = yn3(`#sel_live_rate_enc_${idx}`); // let trk = yn3(`#sel_live_rate_trk_${idx}`); // let snd = yn3(`#sel_live_rate_snd_${idx}`); // let vid = yn3(`#sel_live_rate_vid_${idx}`); // let _setlive = (val === "Y") ? "y" : "n"; // mar.tmp_sel_live_rate(idx,trk,enc,snd,existingid,saved_1,vid, _setlive); // } // // /* general ratequote P2 */ // // // h += `
    Proposal number
    #${mar.tmp_in_slot}
    `; // h += `
    Locked
    ${locked}
    `; // h += `
    Visible to the client
    ${btn3}
    `; // h += `
    Select as primary
    ${btn}
    `; // if (mar.encompass_enabled) { // h += `
    Sync loan data with Encompass
    ${frm.yn3(`sel_live_rate_enc_${idx}`,"","Y","","",function(){},{}).render()}
    `; // } // h += `
    Send loan proposal to client
    ${frm.yn3(`sel_live_rate_snd_${idx}`,"","Y","","",function(){},{}).render()}
    `; // h += `
    Include tracking in Daily To-Do
    ${frm.yn3(`sel_live_rate_trk_${idx}`,"","Y","","",function(){},{}).render()}
    `; // h += `
    Upload Video for the clientz
    ${btn_video}
    `; // h += `
    `; // h += `
    Drop Video Here ${idx}
    `; // h += `
    `; // // h += ``; // h += `
    Send loan proposal to client
    ${btn1}
    `; // // h += `
     
    Save
    `; // h += `
     
    `; // // let FE = MAR.getOpt(saved_item, "FE", false); // let BE = MAR.getOpt(saved_item, "BE", false); // if (FE !== false && BE !== false && typeof FE === "number" && typeof BE === "number") { // detail = `${elaineui.format("perc2",FE)} / ${elaineui.format("perc2",BE)}` // h += `
    FE / BE
    ${detail}
    `; // } // //// h += `
    Selected
    radio_button_unchecked
    `; //// h += `
     
    Inform Client
    `; // } // if (visibility ==="hidden"){ // h += `
    Is Hidden
    Show
    `; // } else { // h += `
    Is visible
    Hide
    `; // } })(); h += `
    `; } /** * end block */ if (_more !== "") { // h += "
    ${_moreText}
    `; } else if (buttonText !== "") { h += "
    ${buttonText}
    `; } h += "
    ";//end proposal $(".result").html(h); if (mar.pg_tmp_am_i_the_lo() === true) { setTimeout(function(){ mar.tmp_rq_reload_topgrid(da.febe, ".topgrid.rqpage"); },1); } $("#body-container .xx-check3").mycheck3(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { if (recalc_on_edit) { $.get(`/api/chatbot/recalculateVersion/${mar.ID}/${version}`, function(da){ mar.pg_loi_adjust_quote("scenario-ratequote1.0",version,mar.tmp_off,true); }); } else if (edit_on_start) { mar.pg_loi_adjust_quote("scenario-ratequote2.0",version,mar.tmp_off,true); } if (_should_scroll_to_bottom) { $("#body-container").scrollTo("max",200); } //oc(true); } }, quick : false }); $("#body-container").LoadingOverlay("hide",true); }); $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); oc(); $("#body-container").scrollTo(0,200); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, // section : "estimate", section : "scenario", menuitem : "scenario-ratequote2" } })(); let liabilityBlock = (function(){ function render(obj) { obj.rough_liabilities = getScenario_data("rough_liabilities",""); obj.rough_liabilities_po = getScenario_data("rough_liabilities_po",""); obj.rough_liabilities_pooc = getScenario_data("rough_liabilities_pooc",""); obj.rough_qual_income = getScenario_data("rough_qual_income",""); obj.h = ""; var VAL = ""; if (mar.pg_tmp_am_i_the_lo()) { let inc = MAR.getOpt(obj, "febe.inc", false); let inc_src = MAR.getOpt(obj, "febe.inc_src", false); let lia = MAR.getOpt(obj, "febe.lia", false); let lia_src = MAR.getOpt(obj, "febe.lia_src", false); obj.h += `
    `; obj.h += `
    FE / BE controls for the LO
    `; if (inc_src === "scenario") { VAL = obj.rough_qual_income; obj.h += frm.txt("rough_qual_income","LO Est. of monthly Income",VAL,"","",function(){ setScenario_data("rough_qual_income",txt("#rough_qual_income")); mar.fakesave(function(){ mvc.go(location.hash); }); },'').render(); } else { obj.h += `
    Income as calculated is ${elaineui.format("cur",inc)}
    ` } obj.h += `
    Liabilities as estimated is ${elaineui.format("cur",obj.rough_liabilities)}
    `; obj.h += `
    Liabilities payoff is ${elaineui.format("cur",obj.rough_liabilities_po)}
    `; obj.h += `
    Liabilities payoff outside of closing is ${elaineui.format("cur",obj.rough_liabilities_pooc)}
    `; // VAL = obj.rough_liabilities; // obj.h += frm.txt("rough_liabilities","LO Est of monthly liabilities",VAL,"","",function(){ // setScenario_data("rough_liabilities",txt("#rough_liabilities")); // mar.fakesave(function(){ // mvc.go(location.hash); // }); // },'').render(); obj.h += `
    Adjust Liabilities
    `; obj.h += `
    `; } return obj; } return { render : render } })(); mar.pg["general-ratequotes"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { mar.pg_accesscontrollerfn = function() { return "open"; } let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var loan_type = getV2_data("loan_type","purchase"); let refi = (loan_type !== "purchase"); let h = ""; if (refi) { h += frm.htitle("Prepared loans").render(); } else { h += frm.htitle("Prepared loans").render(); } h += frm.elaine("Here are loans we prepared for you.","er").render(); h += `
    `; h += `
    `; h += `
    `; h += `
    `; h += ``; mar.tmp_show_saved_rate = function(version) { if (typeof version === "string" && version.startsWith("E")) { // alert("this should be a pdf"); // return; } if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_ratequote_0_passed_new","Y"); mar.fakesave(function(){ mvc.go(`#scenario-ratequote1.0.${version}`); }) } else { mvc.go(`#scenario-ratequote1.0.${version}`); } } mar.tmp_show_saved_rate_p2 = function(version) { if (typeof version === "string" && version.startsWith("E")) { // alert("this should be a pdf"); // return; } if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_ratequote_0_passed_new","Y"); mar.fakesave(function(){ mvc.go(`#scenario-ratequote2.0.${version}`); }) } else { mvc.go(`#scenario-ratequote2.0.${version}`); } } mar.tmp_del_saved_rate = function(version) { $.get(`/api/chatbot/delSavedRate/${mar.ID}/${version}`, function(da){ mvc.go(`#general-ratequotes`); }); } mar.tmp_delete_video = function(version) { $.get(`/api/chatbot/delSavedRateVideo/${mar.ID}/${version}`, function(da){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); } mar.tmp_upload_video_rate = function(version) { alert("Upload Video"); } h += uihelpers.cbuttonbar("",frm.addfunction(function(){ if (mar.WE_ARE_FROM_LOI === false) { setScenario_data("__scenario_ratequote_0_passed_new","Y"); } mvc.go("#scenario-ratequote0.0"); }),"Prev",frm.addfunction(function(){ mvc.go("#scenario-housingbudget."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ mvc.set("referrer_ratequote", `#general-ratequotes`); $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").LoadingOverlay("show"); $.get(`/api/chatbot/getSavedRates/${mar.ID}`, function(savedrates){ // let obj = {} // obj.febe = savedrates.febe; // liabilityBlock.render(obj); // $(`#liabilities-block`).html(obj.h); let h = ""; if (mar.pg_tmp_am_i_the_lo() === true) { h += ``; } let saved_items = MAR.getOpt(savedrates, "data", []); saved_items.sort(function(a, b){ if (MAR.getOpt(a, "selected", false)) return -1; if (MAR.getOpt(b, "selected", false)) return 1; return (num(b.ts) < num(a.ts)) ? -1 : 1; return (num(b.id) < num(a.id)) ? -1 : 1; }); let saved_count = 0; let saved_cnt = 0; let IDX1_key = ""; for (let i=0; i < saved_items.length; i++) { let saved_item = saved_items[i]; let idx = saved_item.id; let name = ""; let selected = MAR.getOpt(saved_item, "selected", false); let key = MAR.getOpt(saved_item, "off.key", "none"); let ts = MAR.getOpt(saved_item, "ts", "none"); let title = MAR.getOpt(saved_item, "title", ""); let rq_name = MAR.getOpt(saved_item, "_name", ""); if (rq_name !== '') { title = rq_name; } let slot = (MAR.getOpt(saved_item, "_in_slot", -1) > -1) ? `[${saved_item._in_slot}]` : ``; title += slot title += `/${idx}`; if (idx === "0") continue; if (idx === "1") { // name = "Selected loan proposal"; name = `Saved offer #${idx} ${saved_cnt+1}`; name = `${title}`; IDX1_key = MAR.getOpt(saved_item, "off.key", "none"); } // else if (idx === "2" && mar.WE_ARE_FROM_LOI === true) { else if (idx === "2") { name = "LO saved offer"; name = `${title}`; let IDX2_key = MAR.getOpt(saved_item, "off.key", "none"); if (IDX1_key === IDX2_key) { continue; // the IDX1 is the same as IDX2 so skip it } } else if (idx === "2" && mar.WE_ARE_FROM_LOI === false) { continue; } else { saved_cnt++; name = `Saved offer #${idx} ${saved_cnt+1}`; name = `${title}`; } if (selected) { name = `Selected loan proposal #${idx}`; name = `Selected loan proposal
    ${title}`; } saved_count++; let p1 = MAR.getOpt(saved_item, "p1", false); let p2 = MAR.getOpt(saved_item, "p2", false); let video = MAR.getOpt(saved_item, "video", false); let visibility = MAR.getOpt(saved_item, "visibility", ""); let tracked = MAR.getOpt(saved_item, "tracked", "Y"); if (!mar.pg_tmp_am_i_the_lo() && visibility === "hidden") continue; let da = { calc : saved_item.off}; cog = `radio_button_unchecked`; cog = `radio_button_unchecked`; if (selected) { cog = `radio_button_checked`; } let status = MAR.getOpt(da, "calc.status",""); let upbutton = `^`; h += `
    `; h += `
    ${name}${cog}
    `; h += `
    `; h += `
    ${da.calc.txt_scen}
    `; if (video) { let src = `/api/chatbot/video/${mar.ID}/${idx}`; let log = `/api/chatbot/video_log/${mar.ID}/${idx}`; h += `
    `; h += ``; if (mar.pg_tmp_am_i_the_lo() === true) { h += `delete_forever`; } h += `
    `; } else { if (mar.pg_tmp_am_i_the_lo() === true) { h += `
    Drop Video Here
    `; } } h += `

    `; let c2c_lbl = (da.calc.total_costs < 0) ? "Cash to receive" : "Cash needed to Close"; h += ``; h += ``; h += ``; h += ``; h += ``; h += `
    Total monthly payment${elaineui.format("cur",da.calc.monthly_total)}
    ${c2c_lbl}${elaineui.format("cur",da.calc.total_costs)}
    Rate (30 year fixed)${elaineui.format("perc3",da.calc.base)}
    APR${elaineui.format("perc3",da.calc.apr)}
    `; if (mar.pg_tmp_am_i_the_lo() === true) { h += ``; h += ``; h += ``; h += `
    `; (function(){ let rqv = MAR.getOpt(saved_item, "trackdata.opened", ""); let rqvp = MAR.getOpt(saved_item, "trackdata.pdf", null); let rqvo = MAR.getOpt(saved_item, "trackdata.open", null); let rqvs = MAR.getOpt(saved_item, "trackdata.video", null); let rqve = MAR.getOpt(saved_item, "trackdata.video_end", null); let rqv_ts = MAR.getOpt(saved_item, "trackdata.opened_ts", ""); let rqvp_ts = MAR.getOpt(saved_item, "trackdata.pdf_ts", null); let rqvo_ts = MAR.getOpt(saved_item, "trackdata.open_ts", null); let rqvs_ts = MAR.getOpt(saved_item, "trackdata.video_ts", null); let rqve_ts = MAR.getOpt(saved_item, "trackdata.video_end_ts", null); let rqv_m = MAR.getOpt(saved_item, "trackdata.opened_m.txt", ""); let rqvp_m = MAR.getOpt(saved_item, "trackdata.pdf_m.txt", null); let rqvo_m = MAR.getOpt(saved_item, "trackdata.open_m.txt", null); let rqvs_m = MAR.getOpt(saved_item, "trackdata.video_m.txt", null); let rqve_m = MAR.getOpt(saved_item, "trackdata.video_end_m.txt", null); let rqst_m = MAR.getOpt(saved_item, "trackdata.start_m.txt", ""); let detail = `---`; let locked = MAR.getOpt(saved_item, "_locked", ""); let in_slot = MAR.getOpt(saved_item, "_in_slot", ""); let _ts = MAR.getOpt(saved_item, "_ts", ""); let _tsm = MAR.getOpt(saved_item, "_tsm.txt", ""); // list of loans // h += `
    Loan Proposal Control Panel
    `; h += `
    Loan Proposal Control Panel
    `; if (visibility === "hidden") { let btn_manage = frm.but(`Manage`,function(elm){ mar.tmp_hb_scroll_to_bottom = true; mar.tmp_show_saved_rate_p2(idx); },{ style : `width: 110px;background-color: var(--green);` }).render(); h += `
    This proposal is not visible to the client.
    `; h += `
    Manage this loan
    ${btn_manage}
    `; return; } detail = (_ts !== "") ? _tsm : `--`; h += `
    Proposal Sent
    ${detail}
    `; detail = (rqv !== "") ? rqv_m : `Not Yet`; h += `
    Proposal Opened
    ${detail}
    `; if (video) { detail = (!video) ? `N/A` : (rqvs !== "" && rqvs !== "-") ? rqvs_m : `Not Yet`; h += `
    Video Opened
    ${detail}
    `; if (video && (rqve !== "" && rqve !== "-")) { detail = (!video) ? `N/A` : (rqve !== "" && rqve !== "-") ? rqve_m : `Partial`; h += `
    Video Watched
    ${detail}
    `; } } if (selected) { let btn1 = frm.yn3(`sel_live_rate_snd_${idx}`,"","N","","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); if (val === "Y") { $.get(`/api/chatbot/sendSavedRate/${mar.ID}/${idx}?from=lo&methods=email,sms`, function(){ $.get(`/api/chatbot/setRqLock/${mar.ID}/${idx}?val=Y`, function(){ // $.get(`/api/chatbot/setRqVisibility/${mar.ID}/${idx}?val=visible`, function(){ swal(`The offer has been sent the client`); // txt(`#${id}`,"N"); // $(`#${id}`).change(); }); }); } },{}).render(); let btn2 = frm.yn3(`sel_live_rate_trk_${idx}`,"",tracked,"","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); $.get(`/api/chatbot/setRqTracking/${mar.ID}/${idx}?val=${val}`, function(){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); },{}).render(); let btn3 = frm.yn3(`sel_live_rate_vis_${idx}`,"",((visibility === "hidden") ? "N" : "Y"),"","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); if (val === "N") { swal(`You cannot hide the selected loan`); $(elm).val("Y").change(); } else if (visibility === "hidden") { val = "visible"; $.get(`/api/chatbot/setRqVisibility/${mar.ID}/${idx}?val=${val}`, function(){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); } },{}).render(); /* general ratequotes */ // h += `
    Visible to the client
    ${btn3}
    `; // h += `
    bSend loan proposal to client
    ${btn1}
    `; // h += `
    Include tracking in Daily To-Do
    ${btn2}
    `; let btn_manage = frm.but(`Manage`,function(elm){ mar.tmp_hb_scroll_to_bottom = true; mar.tmp_show_saved_rate_p2(idx); },{ style : `width: 110px;background-color: var(--green);` }).render(); h += `
    Manage this loan
    ${btn_manage}
    `; let FE = MAR.getOpt(saved_item, "FE", false); let BE = MAR.getOpt(saved_item, "BE", false); if (FE !== false && BE !== false && typeof FE === "number" && typeof BE === "number") { detail = `${elaineui.format("perc2",FE)} / ${elaineui.format("perc2",BE)}` h += `
    FE / BE
    ${detail}
    `; } // if (tracked ==="Y"){ // h += `
    Tracking in Daily To-Do
    radio_button_checked
    `; // // } else { // h += `
    Tracking in Daily To-Do
    radio_button_unchecked
    `; // } } else { let btn = frm.yn3(`sel_live_rate_${idx}`,"","N","","",function(elm,b,c){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); if (val === "Y") { $(`.sel_live_rate_enc_row_${idx}`).removeClass("x-hide-imp"); $(`.sel_live_rate_enc_row_n_${idx}`).addClass("x-hide-imp"); } else { $(`.sel_live_rate_enc_row_${idx}`).addClass("x-hide-imp"); $(`.sel_live_rate_enc_row_n_${idx}`).removeClass("x-hide-imp"); } console.log(elm,b,c); // if(txt("#samelineofwork") == 'N'){ // $(".info-same").trigger('click'); // } }, {}).render(); /** * Send to client */ let btn1 = frm.yn3(`sel_live_rate_snd_n_${idx}`,"","N","","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = yn3(`#${id}`); if (val === "Y") { $.get(`/api/chatbot/sendSavedRate/${mar.ID}/${idx}?from=lo&methods=email,sms`, function(){ $.get(`/api/chatbot/setRqLock/${mar.ID}/${idx}?val=Y`, function(){ // $.get(`/api/chatbot/setRqVisibility/${mar.ID}/${idx}?val=visible`, function(){ swal(`The offer has been sent the client`); // txt(`#${id}`,"N"); // $(`#${id}`).change(); }); }); } },{}).render(); let btn3 = frm.yn3(`sel_live_rate_vis_${idx}`,"",((visibility === "hidden") ? "N" : "Y"),"","",function(elm){ let id = elm.id; let idx = id.split("_").pop(); let val = (yn3(`#${id}`) === "Y") ? "visible" : "hidden"; $.get(`/api/chatbot/setRqVisibility/${mar.ID}/${idx}?val=${val}`, function(){ mar.tmp_hb_scroll_to_bottom = true; mvc.go(location.hash); }); },{}).render(); mar.tmp_sel_live_rate_2 = function(idx){ let val = yn3(`#sel_live_rate_${idx}`); let enc = yn3(`#sel_live_rate_enc_${idx}`); let trk = yn3(`#sel_live_rate_trk_${idx}`); let snd = yn3(`#sel_live_rate_snd_${idx}`); mar.tmp_sel_live_rate(idx,trk,enc,snd); } /* general ratequotes */ // h += `
    Visible to the client
    ${btn3}
    `; // h += `
    Select as primary
    ${btn}
    `; // if (mar.encompass_enabled) { // h += `
    Sync loan data with Encompass
    ${frm.yn3(`sel_live_rate_enc_${idx}`,"","Y","","",function(){},{}).render()}
    `; // } // h += `
    Send loan proposal to client
    ${frm.yn3(`sel_live_rate_snd_${idx}`,"","Y","","",function(){},{}).render()}
    `; // h += `
    Include tracking in Daily To-Do
    ${frm.yn3(`sel_live_rate_trk_${idx}`,"","Y","","",function(){},{}).render()}
    `; // h += `
     
    Save
    `; // h += `
     
    `; // h += `
    Send loan proposal to client
    ${btn1}
    `; let btn_manage = frm.but(`Manage`,function(elm){ mar.tmp_hb_scroll_to_bottom = true; mar.tmp_show_saved_rate_p2(idx); },{ style : `width: 110px;background-color: var(--green);` }).render(); h += `
    Manage this loan
    ${btn_manage}
    `; let FE = MAR.getOpt(saved_item, "FE", false); let BE = MAR.getOpt(saved_item, "BE", false); if (FE !== false && BE !== false && typeof FE === "number" && typeof BE === "number") { detail = `${elaineui.format("perc2",FE)} / ${elaineui.format("perc2",BE)}` h += `
    FE / BE
    ${detail}
    `; } // h += `
    Selected
    radio_button_unchecked
    `; // h += `
     
    Inform Client
    `; } // if (visibility ==="hidden"){ // h += `
    Is Hidden
    Show
    `; // } else { // h += `
    Is visible
    Hide
    `; // } })(); h += `
    `; if (mar.summary.encompass_enabled === true) { h += `
    Sync Check
    `; } } h += `
    `; if (mar.pg_tmp_am_i_the_lo() === true) { // h += ``; let btn_remove = `delete`; h += ``; // h += ``; // if (!selected) { // h += ``; // // } } h += ``; h += "
    "; h += `
    `; // if (p1 !== false) h += ``; // if (p2 !== false) h += ``; h += `
    `; h += `
    `; } if (saved_count === 0) { h = `There are no saved rate quotes in the app so far...`; $("#result").html(h); } else { let divList = $(h); // divList.sort(function(a, b){ // return ($(a).data("selected") < $(b).data("selected") || $(a).data("i") < $(b).data("i")) ? -1 : 1 // }); $("#result").html(divList); $("#body-container video").on("play", function(ev){ let $this = $(this); let log = $this.data('log'); $.get(`${log}?action=play`); }); $("#body-container video").on("pause", function(ev){ let $this = $(this); let log = $this.data('log'); $.get(`${log}?action=pause`); }); $("#body-container video").on("ended", function(ev){ let $this = $(this); let log = $this.data('log'); $.get(`${log}?action=ended`); }); $("#body-container .xx-check3").mycheck3(); let $newdropzone = $("#body-container").find(".uploadvideo"); if ($newdropzone.length > 0) { mar.filepupload.upload($newdropzone,{ clickable : true, maxFilesize : 2000, appid : $newdropzone.data("appid"), rqnum : true, //$newdropzone.data("rqnum"), uid : mar.userid }); } } $("#body-container").LoadingOverlay("hide",true); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "ratequotes" } })(); mar.pg["general-endrqphase"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { mar.pg_accesscontrollerfn = function() { return "open"; } let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var loan_type = getV2_data("loan_type","purchase"); let refi = (loan_type !== "purchase"); let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: SECURE ACCOUNT
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    In this next section, you'll secure your account with a password, and after that you'll start the application by filling in the information we need to get you approved for your loan.
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ // h += frm.htitle("End RQ Phase").render(); // // h += frm.elaine("Lets go ahead with the rest of the aplication!","er").render(); // // h += `
    `; // h += `
    You will be able to complete your appliction in 3 steps`; // h += `
    You will be asked to :`; // h += `
  • 1. Secure the appliction by choosing a password
  • `; // h += `
  • 2. Enter your personal date , employment, assets and real estate ownership
  • `; // h += `
  • 3. Upload your documentation by doing your 'homework'
  • `; // h += `
    `; // h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ // setScenario_data("phase","rq-password"); // mar.fakesave(function(){ // mvc.go("#lox"); // }); // // }),"Prev",frm.addfunction(function(){ // // mvc.go("#scenario-housingbudget."+applicantnum); // // }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "ratequotes" } })(); /* file /ui/app/js/pages.pdu.popup.js , last updated 1548946450285*/ mar.pg.upmy = function(WHAT,MORTGAGE) { let what = WHAT.split(",") let est_pp = 0; let hoi_cost_m = 0; mar.pg.upmydone = function() { let all = (what.indexOf("*") > -1); let lo = (__ROLE == "lo" || mar.loauth.islo()); if (lo || all || what.indexOf("lc") > -1) { let calc_additional_lender_credits = _num(txt("#pdu_calc_additional_lender_credits")); setScenario_data("calc_additional_lender_credits",calc_additional_lender_credits); } if (lo || all || what.indexOf("sc") > -1) { let calc_additional_seller_credits = _num(txt("#pdu_calc_additional_seller_credits")); setScenario_data("calc_additional_seller_credits",calc_additional_seller_credits); } if (lo || all || what.indexOf("rc") > -1) { let calc_additional_realtor_credits = _num(txt("#pdu_calc_additional_realtor_credits")); setScenario_data("calc_additional_realtor_credits",calc_additional_realtor_credits); } if (lo || all || what.indexOf("hoi") > -1) { // set only if different let _hoi_cost_m = _num(txt("#pdu_hoi_cost_m")); if (_hoi_cost_m != hoi_cost_m) { setScenario_data("scenario_i_know_my_insurance","Y"); setScenario_data("refi_home_insurance_cost",(_hoi_cost_m)*12) } } if (all || what.indexOf("c2c") > -1) { setScenario_data("goals_target_c2c_low" , _num(txt("#pdu_goals_target_c2c_low"))); setScenario_data("goals_target_c2c_high" , _num(txt("#pdu_goals_target_c2c_low"))); } if (all || what.indexOf("bu") > -1) { setScenario_data("goals_target_budget_low" , _num(txt("#pdu_goals_target_budget_low"))); setScenario_data("goals_target_budget_high" , _num(txt("#pdu_goals_target_budget_low"))); } if (all || what.indexOf("pp") > -1) { setScenario_data("goals_target_value" , _num(txt("#pdu_goals_target_value"))); } mar.fakesave(function(){ mar.pg.oc(); swal.close(); }); } mar.pg.upmydone_oc = function(){ let all = (what.indexOf("*") > -1); let lo = (__ROLE == "lo" || mar.loauth.islo()); //(__ROLE == "lo" ); if (lo || all || what.indexOf("lc") > -1) { let calc_additional_lender_credits = _num(txt("#pdu_calc_additional_lender_credits")); let w = "Est. $0"; if (calc_additional_lender_credits > 0) w = `Est. ${mar.fmt.currency(Math.floor((calc_additional_lender_credits * est_pp)/100))}`; $(".lc_est").html(w); } if (lo || all || what.indexOf("sc") > -1) { let calc_additional_seller_credits = _num(txt("#pdu_calc_additional_seller_credits")); let w = "Est. $0"; if (calc_additional_seller_credits > 0) w = `Est. ${mar.fmt.currency(Math.floor((calc_additional_seller_credits * est_pp)/100))}`; $(".sc_est").html(w); } if (lo || all || what.indexOf("rc") > -1) { let calc_additional_realtor_credits = _num(txt("#pdu_calc_additional_realtor_credits")); let w = "Est. $0"; if (calc_additional_realtor_credits > 0) w = `Est. ${mar.fmt.currency(Math.floor((calc_additional_realtor_credits * est_pp)/100))}`; $(".rc_est").html(w); } } function switchfield(name, options,value,onchange) { let h = ""; h += `
    `; for (x in options) { var selected = (value == x) ? "checked" : ""; h += `
    `; h += ``; h += ``; h += `
    `; } h += '
    '; return h; } function switchfieldMulti(name, options,value,onchange,wrap) { let h = ""; let Wrap = (arguments.length > 4 && wrap === true) ? "flex-wrap: wrap;" : ""; h += `
    `; for (x in options) { var selected = (value.split(",").indexOf(x) > -1) ? "checked" : ""; h += `
    `; h += ``; h += ``; h += `
    `; } h += '
    '; return h; } function switchfieldMultiTable(name, options,value,onchange) { let h = ""; h += `
    `; for (x in options) { var selected = (value.split(",").indexOf(x) > -1) ? "checked" : ""; // h += `
    `; h += ``; h += ``; // h += `
    `; } h += '
    '; return h; } let set_rates = function(PROG) { let pdu_selected_rates = getScenario_data(`pdu_selected_rates_${PROG}`,"lowtbuydown"); let _rates = pdu_selected_rates.split("|"); if (_rates[0] == "all") { for (x in _da_rates) { let r = _da_rates[x]; $(`#switch_pdu_rates_r${(x*1000)}`).prop("checked",true) } } if (_rates[0] == "neutral") { let low = 9999999; let lowr = false; for (x in _da_rates) { let r = _da_rates[x]; let p = Math.abs(r.pts); if (p < low) { low = p; lowr = x; } $(`#switch_pdu_rates_r${(x*1000)}`).prop("checked",false) } $(`#switch_pdu_rates_r${(lowr*1000)}`).prop("checked",true) } if (_rates[0] == "lowtbuydown") { for (x in _da_rates) { if (num(x) >= mar.staticvars.startingrate && num(x) <= mar.staticvars.endingrate) { $(`#switch_pdu_rates_r${(x*1000)}`).prop("checked",true); } else { $(`#switch_pdu_rates_r${(x*1000)}`).prop("checked",false); } } } if (_rates[0] == "custom") { let _rlist = (_rates.length > 1) ? _rates[1].split(",") : [] for (x in _da_rates) { let _disp = (_rlist.indexOf(x) > -1); $(`#switch_pdu_rates_r${(x*1000)}`).prop("checked",_disp); } } } let get_and_set_rates = function(PROG) { radio("pdu_selected_rates","custom"); let pdu_selected_rates = radio("pdu_selected_rates"); let _pdu_selected_rates = getScenario_data(`pdu_selected_rates_${PROG}`,"lowtbuydown"); let _pdu_selected_rates_A = _pdu_selected_rates.split("|"); if (pdu_selected_rates == "all") { _pdu_selected_rates_A[0] = "all"; setScenario_data(`pdu_selected_rates_${PROG}`,_pdu_selected_rates_A.join("|")) } if (pdu_selected_rates == "neutral") { _pdu_selected_rates_A[0] = "neutral"; setScenario_data(`pdu_selected_rates_${PROG}`,_pdu_selected_rates_A.join("|")) } if (pdu_selected_rates == "lowtbuydown") { _pdu_selected_rates_A[0] = "lowtbuydown"; setScenario_data(`pdu_selected_rates_${PROG}`,_pdu_selected_rates_A.join("|")) } if (pdu_selected_rates == "custom") { _pdu_selected_rates_A[0] = "custom"; _pdu_selected_rates_A[1] = [] for (x in _da_rates) { if ($(`#switch_pdu_rates_r${(x*1000)}`).prop("checked")) { _pdu_selected_rates_A[1].push(x) } } _pdu_selected_rates_A[1] = _pdu_selected_rates_A[1].join(","); setScenario_data(`pdu_selected_rates_${PROG}`,_pdu_selected_rates_A.join("|")) } } let _da_rates = {} let populate_rates = function(PROG){ if (PROG == "") { $(".xx_rates_selection").html(""); return; } $(".xx_rates_selection").html("Loading"); var goals_target_value = getScenario_data("goals_target_value","0"); $.get(`/api/mortgage/get_rates?val=${goals_target_value}&programme=${PROG}&appid=${mar.ID}`, function(da) { let ratechoice = {}; _da_rates = da.rates; for (x in da.rates) { let r = da.rates[x]; let color = (r.dollars > 0) ? "#cc0000" : "#00cc00"; ratechoice[`r${(x*1000)}`] = `
    `+ `${x}`+ `${num(r.val).toFixed(3)}`+ `$ ${r.dollars}`+ `
    ` } // for (let i = mar.staticvars.startingrate; i <= mar.staticvars.endingrate; i+=0.125) { // ratechoice[`r${i}`] = `${i}` // } let h = ""; h += `
    `+ `Rate`+ `Pts`+ `Estimate`+ `
    ` h += switchfieldMultiTable("pdu_rates",ratechoice,"all",frm.addfunction(function(){ get_and_set_rates(PROG); }),true) $(".xx_rates_selection").html(h); set_rates(PROG); }) } let therest = function(MORT) { let calc_additional_lender_credits = getScenario_data("calc_additional_lender_credits","0"); let calc_additional_seller_credits = getScenario_data("calc_additional_seller_credits","0"); let calc_additional_realtor_credits = getScenario_data("calc_additional_realtor_credits","0"); var goals_target_c2c_low = getScenario_data("goals_target_c2c_low","0"); var goals_target_value = getScenario_data("goals_target_value","0"); var goals_target_budget_low = getScenario_data("goals_target_budget_low","0"); var goals_target_budget_high = getScenario_data("goals_target_budget_high","0"); var i_know = getScenario_data("scenario_i_know_my_insurance",""); hoi_cost_m = MORT.filters.m_hoi; est_pp = MORT.filters.purchace_price; let h = ""; h += "
    "; let all = (what.indexOf("*") > -1); let lo = (__ROLE == "lo" || mar.loauth.islo()); //(__ROLE == "lo" ); let oc = function(field) { let pdu_selected_programmes = getScenario_data("pdu_selected_programmes",mar.staticvars.programmes.join(",")); let pdu_selected_programmes_arr = pdu_selected_programmes.split(","); let prog = radio("pdu_programme"); if (field && field == "programme") { // we changed the programme! let pdu_rate_scheme = getScenario_data(`pdu_rate_scheme_${prog}`,"fixed"); let pdu_selected_rates = getScenario_data(`pdu_selected_rates_${prog}`,"lowtbuydown"); if (pdu_selected_programmes_arr.indexOf(prog) > -1) { radio("pdu_programme_exclude" ,"include") radio("pdu_rate_scheme" ,pdu_rate_scheme) radio("pdu_selected_rates" ,pdu_selected_rates.split("|")[0]) $(".pdu_programme_details").removeClass("x-hide"); populate_rates(prog,pdu_rate_scheme); } else { radio("pdu_programme_exclude","exclude") radio("pdu_rate_scheme",pdu_rate_scheme) $(".pdu_programme_details").addClass("x-hide"); populate_rates(""); } return; } let include_exclude = radio("pdu_programme_exclude"); if (include_exclude == "exclude") { $(".pdu_programme_details").addClass("x-hide"); if (pdu_selected_programmes_arr.indexOf(prog) > -1) { let index = pdu_selected_programmes_arr.indexOf(prog); pdu_selected_programmes_arr.splice(index, 1); setScenario_data("pdu_selected_programmes",pdu_selected_programmes_arr.join(",")); } populate_rates(""); } else { $(".pdu_programme_details").removeClass("x-hide"); if (pdu_selected_programmes_arr.indexOf(prog) < 0) { pdu_selected_programmes_arr.push(prog); setScenario_data("pdu_selected_programmes",pdu_selected_programmes_arr.join(",")); } let pdu_rate_scheme = radio("pdu_rate_scheme"); setScenario_data(`pdu_rate_scheme_${prog}`,pdu_rate_scheme); if (field && field == "setrates") { let pdu_selected_rates = radio("pdu_selected_rates"); let _pdu_selected_rates = getScenario_data(`pdu_selected_rates_${prog}`,"all"); let _pdu_selected_rates_A = _pdu_selected_rates.split("|"); _pdu_selected_rates_A[0] = pdu_selected_rates; setScenario_data(`pdu_selected_rates_${prog}`,_pdu_selected_rates_A.join("|")); set_rates(prog) } if (field && field == "reload") { populate_rates(prog,pdu_rate_scheme); } } } if (lo || all) { h += "
    LO - Advanced filter options:
    "; h += "
    "; h += switchfield("duration",{ dur30 : "30 year", dur20 : "20 year", dur10 : "10 year" },"dur30",frm.addfunction(function(){ })) h += switchfield("pdu_programme",{ conv : "Conventional", fha : "FHA" },"conv",frm.addfunction(function(){ oc("programme"); })) h += switchfield("pdu_programme_exclude",{ include : "Calculate", exclude : "Don't calculate" },"conv",frm.addfunction(function(){ oc("reload"); })) h += switchfield("pdu_rate_scheme",{ fixed : "Fixed", arm10 : "10/1 arm", arm7 : "7/1 arm", arm3 : "3/1 arm" },"fixed",frm.addfunction(function(){ oc("reload"); })).wrap("
    ","
    ") h += switchfield("pdu_selected_rates",{ all : "All", neutral : "Neutral", lowtbuydown : "Buydown", custom : "Custom" },"all",frm.addfunction(function(){ oc("setrates"); })).wrap("
    ","
    ") h += "
     
    "; h += frm.hr().render(); } if (lo || all || what.indexOf("lc") > -1) { let VAL = calc_additional_lender_credits; h += "
    As LO I would like to set the lender credits to:
    "; h += frm.slider("pdu_calc_additional_lender_credits","",VAL,"","",function(){ mar.pg.upmydone_oc(); }, { v00 : '0', v50 : '1', v50_inc : '0.125', v75 : '2', v75_inc : '0.125', v100 : '3', v100_inc : '0.125', formatting_class : '_percentage' }).render(); h += frm.hr().render(); } if (lo || all || what.indexOf("sc") > -1) { VAL = calc_additional_seller_credits; h += "
    As LO I would like to set the seller credits to:
    "; h += frm.slider("pdu_calc_additional_seller_credits","",VAL,"","",function(){ mar.pg.upmydone_oc(); }, { v00 : '0', v50 : '1', v50_inc : '0.125', v75 : '2', v75_inc : '0.125', v100 : '3', v100_inc : '0.125', formatting_class : '_percentage' }).render(); h += frm.hr().render(); } if (lo || all || what.indexOf("rc") > -1) { VAL = calc_additional_realtor_credits; h += "
    As LO I would like to set the realtor credits to:
    "; h += frm.slider("pdu_calc_additional_realtor_credits","",VAL,"","",function(){ mar.pg.upmydone_oc(); }, { v00 : '0', v50 : '1', v50_inc : '0.125', v75 : '2', v75_inc : '0.125', v100 : '3', v100_inc : '0.125', formatting_class : '_percentage' }).render(); h += frm.hr().render(); } if (lo || all || what.indexOf("hoi") > -1) { h += "
    I would like to se the monthly HOI at:
    "; VAL = hoi_cost_m; h += frm.slider("pdu_hoi_cost_m","Monthly cost:",VAL,"","",function(){ }, { v00 : '40', v50 : '300', v50_inc : '10', v75 : '550', v75_inc : '20', v100 : '1500', v100_inc : '50', start_val : '240' }).render(); h += frm.hr().render(); } if (all || what.indexOf("bu") > -1) { h += "
    I would like to adjust my monthly budget to:
    "; VAL = goals_target_budget_low; h += frm.slider("pdu_goals_target_budget_low","Budget within $100 of:",VAL,"","",function(){ }, { v00 : '0 ', v50 : '2500', v50_inc : '25', v75 : '8000', v75_inc : '50', v100 : '15000', v100_inc : '250', start_val : '1800', trackStyling : 'trafficlight' }).render(); h += frm.hr().render(); } if (all || what.indexOf("c2c") > -1) { h += "
    I would like to adjust my Cash to Close limit to:
    "; VAL = goals_target_c2c_low; h += frm.slider("pdu_goals_target_c2c_low","Maximum available.",VAL,"","",function(){ }, { v00 : '0', v50 : '20000', v50_inc : '250', v75 : '50000', v75_inc : '250', v100 : '300000', v100_inc : '1000', start_val : '20000' }).render(); h += frm.hr().render(); } if (all || what.indexOf("pp") > -1) { VAL = goals_target_value; h += frm.slider("pdu_goals_target_value","Target price.",VAL,"","",function(){ }, { v00 : '50000', v50 : '250000', v50_inc : '5000', v75 : '750000', v75_inc : '5000', v100 : '1500000', v100_inc : '100000', start_val : '250000', trackStyleValues: JSON.stringify([{"start":"0", "end":"37", "color":"#90c33a"} , {"start":"38", "end":"64", "color":"#f6bd40"}, {"start":"65", "end":"100", "color":"#e51E2B"}]) }).render(); h += frm.hr().render(); } h +=""; h += "
    "; var s = document.createElement("div"); s.setAttribute("class","normal-form monthly-budget"); s.innerHTML = h; swal({ title : "Adjust loan parameters", className : "middleInfoPopup", content : s, buttons : false }) setTimeout(function prepare_popup_radios(){ // $("#magic2-popup-lo").find(".xx-radio").myradio(); // $("#magic2-popup-lo #restyleMeToChekboxes div").removeClass('md-radio'); // $("#magic2-popup-lo #restyleMeToChekboxes input").addClass('styled-checkbox'); // $("#magic2-popup-lo .dropDownRadioHolder .md-radio label").css('width', '100%' ); $("#magic2-popup-lo ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#magic2-popup-lo ._percentage").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character suffix: "%", rightAlign: false, autoUnmask : true }); $("#magic2-popup-lo").find(".xx-slider").myslider({ fn : function(id) { $(`#${id}`).change() } }); oc("programme"); },500) } if (arguments.length > 1) { therest(MORTGAGE) } else { let sel_calc = mar.pg.calcs.get_sel_calc(); let MM = sel_calc.mortgage.split(":"); elaine_adapter.m.getcacheone(mar.ID, MM[0],"", "", "", MM[1], function(MORT){ therest(MORT) }); } } /* file /ui/app/js/pages.c2c.js , last updated 1550057859679*/ mar.pg["scenario-c2c"] = (function(){ var VAL = 'N' var html = ""; /** * define * render() * oc() * makeResultBaloon() * doCalc * end_calc() * fha_calc() * conv_calc() * mar.pg.oc() * mar.pg.switch_current_advice = function(to_programme) * or() */ function render(pg, localopts) { var goals_target_c2c_original = getScenario_data("goals_target_c2c_low","0"); let has_visited = (getScenario_data("__hasvisited_c2c","N") == "Y") let revealclass = (has_visited) ? "" : "x-hide x-revealdiv"; // reveal .1 var defval = ("_suggested_downpayment" in mar.state && mar.state._suggested_downpayment && mar.state._suggested_downpayment > 0) ? Math.floor(mar.state._suggested_downpayment) : "0"; var goals_target_c2c_low = getScenario_data("goals_target_c2c_low",defval); // var goals_target_c2c_high = getScenario_data("goals_target_c2c_high",defval); var InsuranceApiReturn = false; let firsttime = true; let currentadvice = false; let h = ""; h += frm.htitle("Available Funds to Close").render(); h += frm.elaine("Let’s find out how much we have to work with.","er").render(); h += "
    "; /* h += "
    "; h += frm.h2("Note: You need to pay for down payment, but also your first years premium for homeowners insurance, taxes, escrow, and closing cost.").render(); h += "
    "; */ h += "
    How much cash do you have available to close, including gifts?
    "; //VAL = (goals_target_c2c_low) ? goals_target_c2c_low : '20000'; VAL = goals_target_c2c_low; h += frm.slider("goals_target_c2c_low","Approx.",VAL,"","",function(){ oc("low"); }, { v00 : '0', v50 : '20000', v50_inc : '250', v75 : '50000', v75_inc : '250', v100 : '300000', v100_inc : '1000', start_val : '0' }).render(); // h += "
    "; // reveal - start (with validation to previous field) // // h += frm.hr().render(); // // h += "
    How far can we stretch your available assets?
    "; // // //0 to 20k in increments of 200, than 20k t0 50 in 500, than 50 to 300k in 1000 // // // VAL = (goals_target_c2c_high) ? goals_target_c2c_high : '20000'; // //VAL = goals_target_c2c_high; // h += frm.slider("goals_target_c2c_high","Approx.",VAL,"","",function(){ // oc("high"); // }, { // v00 : '250', // v50 : '20000', // v50_inc : '250', // v75 : '50000', // v75_inc : '250', // v100 : '300000', // v100_inc : '1000', // start_val : '20000' // }).render(); // // h += "
    " // reveal - end h += "
    "; h += "
    "; h += "
    "; h += "
    "; //end er /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var val; /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "goals_target_c2c_low") { val = txt("#goals_target_c2c_low"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us how much money are you willing to spend on your purchase.","top"); return; } } oc(); } // $elm.slideDown(function(){ // $elm.removeClass("x-hide").removeClass("x-revealdiv"); // $("#body-container").scrollTo("max",200); // setTimeout(function(){ // txt("#goals_target_c2c_high",num(txt("#goals_target_c2c_high"))); // $("#goals_target_c2c_high").change(); // },500) // // }); return; } /** * validation & reveal block end */ setScenario_data("__hasvisited_c2c","Y"); setScenario_data("__scenario_"+"c2c"+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-purchaseprice"); //mvc.go("#scenario-budget"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-property"); }),"mar.help()"); h = Mustache.render(h,localopts); let octime = 0; let oc = _.debounce(function(type) { octime = new Date().getTime(); var goals_target_c2c_low = _num(txt("#goals_target_c2c_low")); var goals_target_c2c_high = _num(txt("#goals_target_c2c_low")); // var goals_target_c2c_high = _num(txt("#goals_target_c2c_high")); // if (goals_target_c2c_low > 0 && goals_target_c2c_high > 0 && goals_target_c2c_low > goals_target_c2c_high) { // setTimeout(function(){ // var goals_target_c2c_high = _num(txt("#goals_target_c2c_high")); // var goals_target_c2c_low = _num(txt("#goals_target_c2c_low")); // if (type == "high") { // goals_target_c2c_low = goals_target_c2c_high; // txt("#goals_target_c2c_low",goals_target_c2c_low) // $("#goals_target_c2c_low").change(); // } else { // goals_target_c2c_high = goals_target_c2c_low; // txt("#goals_target_c2c_high",goals_target_c2c_high) // $("#goals_target_c2c_high").change(); // } // },5) // // } else { // /* edge case if the bottom slider is not revealed and we move the top one down then we also have to move the bottom one */ // let $reveals = $(".x-revealdiv"); // let bottom_is_hidden = ($reveals.length > 0); // if (bottom_is_hidden == true) { // if (goals_target_c2c_low > 0 && goals_target_c2c_high > 0 && goals_target_c2c_low < goals_target_c2c_high) { // setTimeout(function(){ // var goals_target_c2c_high = _num(txt("#goals_target_c2c_high")); // var goals_target_c2c_low = _num(txt("#goals_target_c2c_low")); // goals_target_c2c_high = goals_target_c2c_low; // txt("#goals_target_c2c_high",goals_target_c2c_high) // $("#goals_target_c2c_high").change(); // },5) // // } // } // } setScenario_data("goals_target_c2c_low",goals_target_c2c_low); setScenario_data("goals_target_c2c_high",goals_target_c2c_high); mar.fakesave(); var _result = ""; var _suggested_maximum_pp = 0; let loan_time = getScenario_data("loan_type_purchase_options","") var occupancy_type = getScenario_data("occupancy_type",""); var property_type = getScenario_data("property_type",""); let sh = elaineui.scenarioHelpers; var _sc = getScenario_v2(); let options_obj = {} if (InsuranceApiReturn) { options_obj.InsuranceApiReturn = InsuranceApiReturn; } let makeResultBaloon = function(T1, _goals_target_value, N, M) { let goals_target_value = _goals_target_value; let __goals_target_value = getScenario_data("goals_target_c2c_high"); if (M) { let MM = M.split(":"); elaine_adapter.m.getcacheone(mar.ID, MM[0],"", "", "", MM[1], function(MORT){ let m = MORT.filters; // let m = M.filters; let warning = ``; let warning1 = ""; if ((m.c2c / num(__goals_target_value)) > 0.9 ) { warning1 = ``; } let h = ""; h += `
    Highest Possible Purchase Price
    `+ `
    `+ `
    Est. Purchase price
    `+ `
    `+ `${ mar.fmt.currency(parseInt(m.purchase_price,10))}`+ `
    `+ `
    `+ `
    Est. Closing cost
    `+ `
    ${warning1}`+ `${ mar.fmt.currency(parseInt(m.c2c,10))}
    `+ `
    `+ `
    Est. Budget
    `+ `
    ${warning}`+ ` ${ mar.fmt.currency(parseInt(m.budget,10))}`+ `
    `+ `

    `; $(`#_result`).html(h); }); // if ((c.EstC2C / num(goals_target_c2c_high)) < 0.8 ) { // let Ela = `It looks like you are hitting a budget limit and it is hurting you ability to get a higher purchase price`+ // `If you can afford to stretch your budget up from ${elaineui.format("cur",budget_calc_fha)} we can push it higher ` + // `
    Up My Budget
    `; // $("#_elaine").html(Ela); // } else { // $("#_elaine").html(""); // // } } else { _result = ""; _result += "
    "; _result += "
    "; _result += "
    "; _result += "
    "; _result += `${T1} :` _result += "
    "; _result += "
    "; _result += goals_target_value; _result += "
    "; _result += "
    "; _result += "
    "; $(`#_result`).html(_result); } } makeResultBaloon("Max Purchase Price", elaineui.working().wrap("
    ","
    "),""); $(".next-button").addClass("disabled"); // let sel_calc = false; let budget_calc_conv = num(getScenario_data("goals_target_budget_high","10000")); let budget_calc_fha = num(getScenario_data("goals_target_budget_high","10000")); var _sc = getScenario_v2(); let params = { hoi : -1, //num(_sc.final_hoi) + num(_sc.final_fld), tax : -1, //Math.round(num(_sc.final_tax)), hoa : -1, //num(_sc.final_hoa) tot : num(_sc.final_hoi) + num(_sc.final_fld) + Math.round(num(_sc.final_tax)) + num(_sc.final_hoa) } if (num(_sc.final_hoi) == 0) { params.hoi = num(InsuranceApiReturn.Home_Own_Ins_PM); params.tax = num(InsuranceApiReturn.prop_tax_percentage_pm); if (getScenario_data("property_type","") == "condo") { params.hoa = num(InsuranceApiReturn.hoa_estimate); } params.tot = params.hoi+params.hoa+params.tax; } if (getScenario_data("scenario_i_know_my_insurance","") == "Y") { params.hoi = Math.floor(num(getScenario_data("refi_home_insurance_cost","2000"))/12); } mar.pg.switch_current_advice = function(to_programme) { $.get(`/api/test/kv?appid=${mar.ID}&k=currentadvice`, function(da) { if ("data" in da == false) return; da = da.data; let current_programme = da.mis; if (current_programme == to_programme) { return; } if ("c" in da) { da.f = da.m; // primary must be conventional da.m = da.c // move to conv delete da.c; da.mis = "conv"; mar.pg.calcs.set_sel_calc(da.m,da.f); } else if ("f" in da) { da.c = da.m; // primary must be conventional da.m = da.f // move to conv delete da.f; da.mis = "fha"; mar.pg.calcs.set_sel_calc(da.m,da.c); } $.ajax({ url : "/api/test/kv", data : { appid : mar.ID, k : "currentadvice", v : JSON.stringify(da) }, type : 'POST', success : function( data ) { mar.state._suggested_purchaseprice = da.m.pp; setScenario_data("suggested_purchaseprice",da.m.pp); setScenario_data("pdu_preferred_programme",to_programme); mar.fakesave(function(){ makeResultBaloon("",da.m.pp, "",da.m.mortgage); $(".next-button").removeClass("disabled"); swal.close(); }); } }); }); } let doCalc = function() { let end_calc = function() { if (conv_calc.get().done == false) return; if (fha_calc.get().done == false) return; let f = fha_calc.get(); let c = conv_calc.get(); if (c.EstMaxPurchase == 0 && f.EstMaxPurchase == 0) { let pencil = ``; makeResultBaloon(`Max Purchase Price ${pencil}:`, "No result","","",""); $(".next-button").removeClass("disabled"); return; // no result } let prefprog = setScenario_data("pdu_preferred_programme",""); let selectprog = (c.EstMaxPP > f.EstMaxPP) ? "conv" : "fha"; if (prefprog != "") selectprog = prefprog; if (selectprog == "conv") { // sel_calc = c; mar.pg.calcs.set_sel_calc(c,f); $.ajax({ url : "/api/test/kv", data : { appid : mar.ID, k : "currentadvice", v : JSON.stringify({ budget : budget_calc_fha, c2c : goals_target_c2c_high, hoa : params.hoa, hoi : params.hoi, tax : params.tax, taxv : Math.floor((c.EstMaxPurchase * params.tax)/12), /* convert the percentage to a dollar value */ tot : (params.hoi+params.hoa + Math.floor((c.EstMaxPurchase * params.tax)/12)), /* recalc the total with the tax */ pp : Math.floor(c.EstMaxPurchase/500)*500, mis : "conv", m : c, f : f }) }, type : 'POST', success : function( data ) { mar.state._suggested_purchaseprice = Math.floor(c.EstMaxPurchase/500)*500; setScenario_data("suggested_purchaseprice",Math.floor(c.EstMaxPurchase/500)*500); mar.fakesave(function(){ makeResultBaloon(`Max Purchase Price @${c.EstMaxPurchaseRate}%
    Budget:${budget_calc_fha}`, elaineui.format("cur",Math.floor(c.EstMaxPurchase/500)*500),"",c.mortgage); $(".next-button").removeClass("disabled"); }); } }) } else { // sel_calc = f; mar.pg.calcs.set_sel_calc(f,c); $.ajax({ url : "/api/test/kv", data : { appid : mar.ID, k : "currentadvice", v : JSON.stringify({ budget : budget_calc_fha, c2c : goals_target_c2c_high, hoi : params.hoi, hoa : params.hoa, tax : params.tax, taxv : Math.floor((f.EstMaxPurchase * params.tax)/12), /* convert the percentage to a dollar value */ tot : (params.hoi+params.hoa + Math.floor((f.EstMaxPurchase * params.tax)/12)), /* recalc the total with the tax */ pp : Math.floor(f.EstMaxPurchase/500)*500, mis : "fha", m : f, c : c }) }, type : 'POST', success : function( data ) { mar.state._suggested_purchaseprice = Math.floor(f.EstMaxPurchase/500)*500; setScenario_data("suggested_purchaseprice",Math.floor(f.EstMaxPurchase/500)*500); mar.fakesave(function(){ makeResultBaloon(`Max Purchase Price @${f.EstMaxPurchaseRate}%
    Budget:${budget_calc_fha}`, elaineui.format("cur",Math.floor(f.EstMaxPurchase/500)*500),"",f.mortgage); $(".next-button").removeClass("disabled"); }); } }); } } let conv_calc = (function(){ let r = mar.staticvars.startingrate; let EstMaxPurchase = 0; let EstMaxPurchaseRate = 0; let EstC2C = 0; let EstB = 0; let EstMaxPP = 0; let EstBU = 0; let inc = 1.5; let max = mar.staticvars.startingrate; let mortgage = false; let done = false; let tim = 0; function get() { return { mortgage : mortgage, EstMaxPP : EstMaxPP, EstMaxPurchase : EstMaxPurchase, EstMaxPurchaseRate : EstMaxPurchaseRate, EstC2C : EstC2C, EstB : EstB, EstBU : EstBU, done : done } } let calcnextrate = function() { if (tim > 0 && tim == octime) { return; } tim = octime; //makeResultBaloon("Calculating Max Purchase price CONV", elaineui.working(),""); mar.calculatepart1(0,"conv", { budget : budget_calc_conv+50, c2c : goals_target_c2c_high, hoi : params.hoi, tax : params.tax, hoa : params.hoa, sum : "y", rate : r, caf : "pdu_30_conv", fn : function(rates){ // console.warn("RAW",rates); // let res = MAR.mortgageNavigator.filters_from_rates(rates); let res = rates; // console.warn("RES",res); if (res.list.length == 0) { r += 0.5; //0.125; if (r > max) { //makeResultBaloon(`Max Purchase price @${EstMaxPurchaseRate} CONV`, elaineui.format("cur",EstMaxPurchase),"",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); return; } calcnextrate(); return; } let ltvs = []; for (let i=0; i < res.pp.length; i++) { let f = res.list[res.pp[i].i].filters; ltvs.push(res.list[res.pp[i].i].filters.ltv); if (res.list[res.pp[i].i].filters.c2c < (goals_target_c2c_high *1.04)) { if (res.pp[i].pp > EstMaxPurchase && res.pp[i].pp > EstMaxPP) { if (EstMaxPurchaseRate == 0 || res.pp[i].pp > EstMaxPP || (res.pp[i].pp == EstMaxPP && res.list[res.pp[i].i].filters.rate < EstMaxPurchaseRate)) { EstMaxPurchase = res.pp[i].pp; EstMaxPP = res.pp[i].pp; EstMaxPurchaseRate = res.list[res.pp[i].i].filters.rate; EstC2C = Math.floor(res.list[res.pp[i].i].filters.c2c); EstBU = res.list[res.pp[i].i].filters.budget EstB = res.list[res.pp[i].i].filters.budget + ", ltv:"+res.list[res.pp[i].i].filters.ltv + "R:"+res.list[res.pp[i].i].filters.rate; mortgage = `pdu_30_conv:${res.list[res.pp[i].i].uuid}`; } } } } //alert(ltvs.join(",")); if (r < max) { r += inc; //0.5; //0.125; calcnextrate(); return } //makeResultBaloon(`Max Purchase price @${EstMaxPurchaseRate} CONV`, elaineui.format("cur",EstMaxPurchase),"",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); console.warn(mortgage); //makeRepairBaloon(goals_target_value, EstMaxPurchase); //setScenario_data("budget_oc_last_price_price",EstMaxPurchase); //setScenario_data("budget_oc_last_price_rate",r); //mar.fakesave(); } }) } return { calcnextrate : calcnextrate, get : get } })() conv_calc.calcnextrate(); let fha_calc = (function(){ let r = mar.staticvars.startingrate; let EstMaxPurchase = 0; let EstMaxPurchaseRate = 0; let EstC2C = 0; let EstB = 0; let EstBU = 0; let EstMaxPP = 0; let inc = 1.5; let max = mar.staticvars.startingrate; let mortgage = false; let done = false; let tim = 0; function get() { return { mortgage : mortgage, EstMaxPurchase : EstMaxPurchase, EstMaxPurchaseRate : EstMaxPurchaseRate, EstC2C : EstC2C, EstB : EstB, EstBU : EstBU, EstMaxPP : EstMaxPP, done : done } } let calcnextrate = function() { console.warn("InsuranceApiReturn",InsuranceApiReturn); if (tim > 0 && tim == octime) { return; } tim = octime; //makeResultBaloon("Calculating Max Purchase price FHA", elaineui.working(),"2"); // pp : (getScenario_data("goals_target_value_entered","n") == "y") ? _num(txt("#goals_target_value") : false; mar.calculatepart1(0,"fha", { budget : budget_calc_fha+50, c2c : goals_target_c2c_high, hoi : params.hoi, tax : params.tax, hoa : params.hoa, sum : "y", rate : r, caf : "pdu_30_fha", fn : function(rates){ //console.warn(rates); // let res = MAR.mortgageNavigator.filters_from_rates(rates); let res = rates; console.warn(res); if (res.list.length == 0) { r += inc; //0.5; //0.125; if (r > max) { //makeResultBaloon(`Max Purchase price @${EstMaxPurchaseRate} FHA`, elaineui.format("cur",EstMaxPurchase),"2",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); return; } calcnextrate(); return; } let ltvs = []; for (let i=0; i < res.pp.length; i++) { ltvs.push(res.list[res.pp[i].i].filters.ltv); if (res.list[res.pp[i].i].filters.c2c < (goals_target_c2c_high *1.04)) { if (res.pp[i].pp > EstMaxPurchase && res.pp[i].pp > EstMaxPP) { if (EstMaxPurchaseRate == 0 || res.pp[i].pp > EstMaxPP || (res.pp[i].pp > EstMaxPP && res.list[res.pp[i].i].filters.rate < EstMaxPurchaseRate)) { EstMaxPurchase = res.pp[i].pp; EstMaxPP = res.pp[i].pp; EstMaxPurchaseRate = res.list[res.pp[i].i].filters.rate; EstC2C = Math.floor(res.list[res.pp[i].i].filters.c2c); EstBU = res.list[res.pp[i].i].filters.budget EstB = res.list[res.pp[i].i].filters.budget + ", ltv:"+res.list[res.pp[i].i].filters.ltv + "R:"+res.list[res.pp[i].i].filters.rate; mortgage = `pdu_30_fha:${res.list[res.pp[i].i].uuid}`; // mortgage = res.list[res.pp[i].i].mortgage; // mortgage = MAR.mortgageNavigator.mortgage_from_rates(rates,res.pp[i].i); if (r < max) { r += inc; //0.5; //0.125; calcnextrate(); return } } } } } //alert(ltvs.join(",")); if (r < max) { r += inc; //0.5; //0.125; calcnextrate(); return } //makeResultBaloon(`Max Purchase price @${EstMaxPurchaseRate} FHA`, elaineui.format("cur",EstMaxPurchase),"2",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); //makeRepairBaloon(goals_target_value, EstMaxPurchase); //setScenario_data("budget_oc_last_price_price",EstMaxPurchase); //setScenario_data("budget_oc_last_price_rate",r); //mar.fakesave(); } }) } return { calcnextrate : calcnextrate, get : get } })() fha_calc.calcnextrate(); } /* * are we the 1st time through? */ if (firsttime == true) { if (num(goals_target_c2c_original) == 0) { goals_target_c2c_original = 100; makeResultBaloon(`Max Purchase price`, "$0","","",""); return; } $.get(`/api/test/kv?appid=${mar.ID}&k=currentadvice`, function(da) { firsttime = false; if (da.status != 0) { doCalc(); return; } if (da.data.budget != budget_calc_fha) { doCalc(); return; } if (da.data.c2c != goals_target_c2c_high) { doCalc(); return; } if (da.data.hoi != params.hoi) { doCalc(); return; } if (da.data.hoa != params.hoa) { doCalc(); return; } if (da.data.tax != params.tax) { doCalc(); return; } let c = da.data.m; let a = ("f" in da.data) ? da.data.f : da.data.c; mar.pg.calcs.set_sel_calc(c,a); mar.state._suggested_purchaseprice = Math.floor(c.EstMaxPP/500)*500; setScenario_data("suggested_purchaseprice",Math.floor(c.EstMaxPP/500)*500); mar.fakesave(function(){ makeResultBaloon(`Max Purchase Price @${c.EstMaxPurchaseRate}%
    Budget:${budget_calc_fha}`, elaineui.format("cur",Math.floor(c.EstMaxPP/500)*500),"",c.mortgage); $(".next-button").removeClass("disabled"); }); }) return; } else { doCalc(); } // sh.getEstimatedPurchasePriceFromCash2CloseAsync(occupancy_type, property_type, MAR.isVaEligible(), _sc.cscore, MAR.isFirstTimeBuyer(), goals_target_c2c_high, options_obj,function(_goals_target_value){ // // let goals_target_value = _goals_target_value; // _result += "
    "; // _result += "
    "; // _result += "
    "; // _result += "
    "; // _result += "Estimated maximum purchase price:"; // _result += "
    "; // _result += "
    "; // _result += mar.fmt.currency(goals_target_value); // _result += "
    "; // _result += "
    "; // _result += "
    "; // $("#_result").html(_result); // mar.state._suggested_purchaseprice = goals_target_value; // // }); },200); mar.pg.oc = oc; let or = function(){ let sp = mar.isallowed_scenario("#scenario-c2c"); if (typeof sp === "string") { mvc.go(sp); return; } let has_visited_crossroads = (getScenario_data("__hasvisited_crossroads","N") == "Y"); if (has_visited_crossroads == false) { mvc.go("#scenario-crossroads"); return; } let loan_time = getScenario_data("loan_type_purchase_options","") var occupancy_type = getScenario_data("occupancy_type",""); var property_type = getScenario_data("property_type",""); let sh = elaineui.scenarioHelpers; var _sc = getScenario_v2(); //https://lo.durunner.ai/calc/home_owners_insurance?square_foot=2500&build_period=1990&county=01003&backend_lia_pm=800&condo=N&close_to_or_on_water=N&sfr=N&in_community=N&luxury_community=N&luxury_condo=N var _url = "/calc/home_owners_insurance?1" + "&county="+getCounty_v2() + "&square_foot=1700" + "&build_period=1974" + "&backend_lia_pm=800" + "&condo=" + ((property_type == "condo") ? "Y" : "N") + "&close_to_or_on_water=N" + "&sfr=" + ((property_type == "sfr") ? "Y" : "N") + "&in_community=" + ((property_type == "sfr") ? "N" : "Y") + "&luxury_community=N" + "&luxury_condo=N"; $.get(_url, function(d2) { if (d2 && "outputs" in d2) InsuranceApiReturn = d2.outputs; $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(); } }, quick : false, }); $(".info-c2c").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML =frm.htitle("Note").render()+ "To close on your mortgage you need to bring cash. You need money for the downpayment, but also your first years premium for homeowners insurance, taxes, escrow, and closing cost."; swal({ className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Got It" } }); }); $(".info-c2c-high").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML =frm.htitle("Note").render()+ "The more you can show, the better. Use gifts from relatives, retirement assets, etc."; swal({ className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Got It" } }); }); }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "estimate" } })(); /* file /ui/app/js/pages.purchaseprice.js , last updated 1550057886128*/ mar.pg["scenario-purchaseprice"] = (function(){ var VAL = 'N' var html = ""; var sliderTrackTarg = {}; function roundHalf(num) { return Math.round(num*2)/2; } function render(pg, localopts) { var _default_goals_target_value = "250000"; if ("_suggested_purchaseprice" in mar.state && mar.state._suggested_purchaseprice && mar.state._suggested_purchaseprice != "" && mar.state._suggested_purchaseprice != 0) _default_goals_target_value = mar.state._suggested_purchaseprice; _default_goals_target_value = getScenario_data("suggested_purchaseprice",_default_goals_target_value); if (getScenario_data("first_suggested_purchase_price","") == "") { setScenario_data("first_suggested_purchase_price",_default_goals_target_value); mar.fakesave(); } var goals_target_value = getScenario_data("goals_target_value",_default_goals_target_value); // alert(`${goals_target_value} ${_default_goals_target_value} ${getScenario_data("suggested_purchaseprice")}`) let loan_time = getScenario_data("loan_type_purchase_options","") var occupancy_type = getScenario_data("occupancy_type",""); var property_type = getScenario_data("property_type",""); let sh = elaineui.scenarioHelpers; var _sc = getScenario_v2(); // let percA = sh.likelydownpaymentpercentage(occupancy_type, property_type, MAR.isVaEligible(), _sc.cscore, MAR.isFirstTimeBuyer(),goals_target_value ); // console.warn("percA",percA); // let perc = percA[0] * 100 ; // (by multiplying it , it comes as 2 or 3.5) var goals_target_c2c_low = getScenario_data("goals_target_c2c_low",0); var goals_target_c2c_high = getScenario_data("goals_target_c2c_high",0); // var __apcc = MAR.getApproximateClosingCosts(250000,0).total10; // let loval = ((goals_target_c2c_low-__apcc)/(perc+2)) * 100; // let hival = ((goals_target_c2c_high-__apcc)/(perc+2)) * 100; // var goals_target_c2c_low = goals_target_value * 0.9; // var goals_target_c2c_high = goals_target_value * 1.1; var loval = _default_goals_target_value * 0.6; var hival = _default_goals_target_value * 1.1; var __INT = mar.TODAYS_INTEREST(); let InsuranceApiReturn = false; //[move the purchase price to something that matches the cash to close. If they go over, make it red and pop up a balloon: “It looks like the amount of cash needed to purchase this property exceeds your available funds to close. You may want to bring your purchase price down, or increase your available cash on the previous page.”] let firsttime = true; let currentadvice = false; let h = ""; h += frm.htitle("Purchase price").render(); if (loan_time == "contract") { h += frm.elaine("Awesome, you are under contract! What is the contract purchase price?","er").render(); } else if (loan_time == "soon") { h += frm.elaine("Awesome, you have found a property! What purchase price do you want to offer?","er").render(); } else { h += frm.elaine(`Select a purchase price that fits your monthly budget and your ${elaineui.format("cur",goals_target_c2c_high)} cash available to close.`,"er").render(); } h += "
    " VAL = goals_target_value; var slidLabel = "Approx."; if (loan_time == "contract") { slidLabel = ""; } h += frm.slider("goals_target_value",slidLabel,VAL,"","",function(){ oc(); }, { v00 : '50000', v50 : '250000', v50_inc : '5000', v75 : '750000', v75_inc : '5000', v100 : '1500000', v100_inc : '100000', start_val : '250000', trackStyleValues: JSON.stringify([{"start":"0", "end":"37", "color":"#90c33a"} , {"start":"38", "end":"64", "color":"#f6bd40"}, {"start":"65", "end":"100", "color":"#e51E2B"}]) }).render(); //background: linear-gradient(to right, #e51e2b 0%,#e51e2b 49%,#f6bd40 50%,#f6bd40 74%,#90c33a 75%,#90c33a 100%); h += frm.hr().render(); h += "
    "; h += "
    "; h += "
    "; /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if ($(".stop-progress").length > 0) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); var pp = "0"; s.innerHTML = "" + "
    Warning" + "

    " + "Your cash to close will need to be increased in order to reach this purchase price. " + ".

    " + "Will you be able to show more available assets?" + "

    " + "
    " + ""; swal({ className : "middleInfoPopup", content : s, buttons : { cancel : "I will lower my purchase price", call : { text: "I can show more assets", value: "increase", closeModal: false } } }) .then((act) => { if (act == "increase") { // increase the hich c2c budget setScenario_data("goals_target_c2c_high",mar.increasebudget.to); setScenario_data("__scenario_"+"purchaseprice"+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-tax"); swal.close(); } }); // mar.tip(".help-button","warning","You can't continue if you don't have enough cash to support the purchase price","top"); return; } var goals_target_value = _num(txt("#goals_target_value")); setScenario_data("__scenario_"+"purchaseprice"+"_passed","Y"); setScenario_data("goals_target_value",goals_target_value); setScenario_data("goals_target_value_entered","y"); mar.fakesave(); mvc.go("#scenario-tax"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-c2c"); }),"mar.help()"); h = Mustache.render(h,localopts); let r250 = function(N) { return Math.round(N/250)*250 ; } let warnings = false; mar.informationpopup = function(OB) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); var pp = "0"; s.innerHTML = "" + "
    " + "The following assumptions have been used to calculate an estimated monthly housing expense: " + "" + "" + "" + "" + "" + "" + // "" + "" + "" + ""+ "" + "" + "" + "" + "" + "" + "
    Purchase Price"+mar.fmt.currency(Math.round(OB.d.pp))+"
    Down Payment of "+OB._perc51+""+mar.fmt.currency(Math.round(OB.d.down))+"
    Loan Amount"+mar.fmt.currency(Math.round(OB.d.loan))+"
    Cash needed to Close"+mar.fmt.currency(Math.round(OB._ecc.suggested_downpayment))+"
    Loan Duration30 years
    Loan Type"+mar._txt(OB._ecc.prog)+"
    Annual Interest Percentage"+(__INT*100)+"%
    Annual Mortgage Insurance Percentage"+OB.d.mip+"%
    Estimated Monthly Housing Expense
    Principle and Interest"+mar.fmt.currency(Math.round(OB.d.PI))+"
    Mortgage Insurance Premium"+mar.fmt.currency(Math.round(OB.d.M))+"
    Taxes"+mar.fmt.currency(Math.round(OB.d.T))+"
    Insurance"+mar.fmt.currency(Math.round(OB.d.I))+"
    HOA Fees"+mar.fmt.currency(Math.round(OB.d.H))+"
    Total"+mar.fmt.currency(Math.round(OB.d.total))+"
    " + "All the values above are sublect to change and can only be used as a rough indication of what your monthly expenses could look like. " + "Always consult with your Loan Originator " + ""+loanofficer.name + "" + " phone number " + ""+elaineui.telF(loanofficer.tel) + "" + ", NMLS license number " + ""+loanofficer.nmls + "" + " for a personalized advice" + // $("#budget_popup").html() + "
    " + ""; swal({ className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "Got it", closeModal: true } } }) } let makeResultBaloon = function(T1, _goals_target_value, N, M) { let goals_target_value = _goals_target_value; if (M) { let MM = M.split(":"); elaine_adapter.m.getcacheone(mar.ID, MM[0],"", "", "", MM[1], function(MORT){ let m = MORT.filters; let warning = ``; let warningbu = warning; if (_num(txt("#goals_target_value")) > (m.purchase_price*1.02) ) { warningbu = ``; } let h = ""; h += `
    Highest Possible Purchase Price
    `+ `
    `+ `
    Est. Purchase price
    `+ `
    `+ `${ mar.fmt.currency(parseInt(m.purchase_price,10))}`+ `
    `+ `
    `+ `
    Est. Closing cost
    `+ `
    ${warning}`+ ` ${ mar.fmt.currency(parseInt(m.c2c,10))}
    `+ `
    `+ `
    Est. Budget
    `+ `
    ${warningbu}`+ ` ${ mar.fmt.currency(parseInt(m.budget,10))}`+ `
    `+ `

    `; $(`#_result`).html(h); }); // if ((c.EstC2C / num(goals_target_c2c_high)) < 0.8 ) { // let Ela = `It looks like you are hitting a budget limit and it is hurting you ability to get a higher purchase price`+ // `If you can afford to stretch your budget up from ${elaineui.format("cur",budget_calc_fha)} we can push it higher ` + // `
    Up My Budget
    `; // $("#_elaine").html(Ela); // } else { // $("#_elaine").html(""); // // } } else { _result = ""; _result += "
    "; _result += "
    "; _result += "
    "; _result += "
    "; _result += `${T1} :` _result += "
    "; _result += "
    "; _result += goals_target_value; _result += "
    "; _result += "
    "; _result += "
    "; $(`#_result`).html(_result); } } mar.pg.switch_current_advice = function(to_programme) { $.get(`/api/test/kv?appid=${mar.ID}&k=currentadvice`, function(da) { if ("data" in da == false) return; da = da.data; let current_programme = da.mis; if (current_programme == to_programme) { return; } if ("c" in da) { da.f = da.m; // primary must be conventional da.m = da.c // move to conv delete da.c; da.mis = "conv"; mar.pg.calcs.set_sel_calc(da.m,da.f); } else if ("f" in da) { da.c = da.m; // primary must be conventional da.m = da.f // move to conv delete da.f; da.mis = "fha"; mar.pg.calcs.set_sel_calc(da.m,da.c); } $.ajax({ url : "/api/test/kv", data : { appid : mar.ID, k : "currentadvice", v : JSON.stringify(da) }, type : 'POST', success : function( data ) { mar.state._suggested_purchaseprice = da.m.pp; setScenario_data("suggested_purchaseprice",da.m.pp); setScenario_data("pdu_preferred_programme",to_programme); mar.fakesave(function(){ makeResultBaloon("",da.m.pp, "",da.m.mortgage); $(".next-button").removeClass("disabled"); swal.close(); }); } }); }); } let oc = _.debounce(function(e) { var goal_disp = ""; var goals_target_value = _num(txt("#goals_target_value")); var loan_duration = "tol30"; var goals_target_budget = 999999; var occupancy_type = getScenario_data("occupancy_type",""); var property_type = getScenario_data("property_type",""); setScenario_data("goals_target_value",goals_target_value); setScenario_data("goals_target_value_entered","y"); mar.fakesave(); $(".__c2c").html(elaineui.format("cur",getScenario_data("goals_target_c2c_low"))); var _suggested_downpayment = 0; if (goals_target_value !== "") { makeResultBaloon("Budget", elaineui.working().wrap("
    ","
    "),""); $(".next-button").addClass("disabled"); // let sel_calc = false; let budget_calc_conv = num(getScenario_data("goals_target_budget_high","10000")); let budget_calc_fha = num(getScenario_data("goals_target_budget_high","10000")); var _sc = getScenario_v2(); let params = { hoi : -1, //num(_sc.final_hoi) + num(_sc.final_fld), tax : -1, //Math.round(num(_sc.final_tax)), hoa : -1, //num(_sc.final_hoa) tot : num(_sc.final_hoi) + num(_sc.final_fld) + Math.round(num(_sc.final_tax)) + num(_sc.final_hoa) } if (num(_sc.final_hoi) == 0) { params.hoi = InsuranceApiReturn.Home_Own_Ins_PM; params.tax = InsuranceApiReturn.prop_tax_percentage_pm; if (getScenario_data("property_type","") == "condo") { params.hoa = num(InsuranceApiReturn.hoa_estimate); } params.tot = params.hoi+params.hoa+ Math.floor( num(goals_target_c2c_high) * num(params.tax)); } if (getScenario_data("scenario_i_know_my_insurance","") == "Y") { params.hoi = Math.floor(num(getScenario_data("refi_home_insurance_cost","2000"))/12); } let doCalc = function() { let end_calc = function() { if (conv_calc.get().done == false) return; if (fha_calc.get().done == false) return; let f = fha_calc.get(); let c = conv_calc.get(); let _maxpp = 0; if (fha_calc.get("max").EstMaxPurchase > _maxpp) _maxpp = fha_calc.get("max").EstMaxPurchase; if (conv_calc.get("max").EstMaxPurchase > _maxpp) _maxpp = conv_calc.get("max").EstMaxPurchase; var xhiperc = elaineui.updateRangefromVal(_maxpp, 50000, 250000, 750000, 1500000); var xloperc = elaineui.updateRangefromVal(_maxpp*0.7, 50000, 250000, 750000, 1500000); var grad = elaineui.buildGradientR(xloperc,xhiperc); $("#goals_target_value_slider").css("background",grad); if (c.EstMaxPurchase == 0 && f.EstMaxPurchase == 0) { // makeResultBaloon(`Max Purchase price`, "No result","","",""); let _result = ""; _result += `To get to a higher purchase price, you need more to close. Please reduce your purchase price, or increase your available cash, for example with a gift from a direct relative.` + `` + `` _result = frm.elaine(_result,"er3").render(); _result += ""; _notenoughmoney = true; $(`#_result`).html(_result); $(".next-button").removeClass("disabled"); return; // no result } let prefprog = setScenario_data("pdu_preferred_programme",""); let selectprog = (c.EstMaxPP > f.EstMaxPP) ? "conv" : "fha"; if (prefprog != "") selectprog = prefprog; if (selectprog == "conv") { mar.pg.calcs.set_sel_calc(c,f); $.ajax({ url : "/api/test/kv", data : { appid : mar.ID, k : "currentadvice", v : JSON.stringify({ budget : budget_calc_fha, c2c : goals_target_c2c_high, hoa : params.hoa, hoi : params.hoi, tax : params.tax, taxv : Math.floor((c.EstMaxPurchase * params.tax)/12), /* convert the percentage to a dollar value */ tot : (params.hoi+params.hoa + Math.floor((c.EstMaxPurchase * params.tax)/12)), /* recalc the total with the tax */ pp : goals_target_value, app : Math.floor(c.EstMaxPP/500)*500, mis : "conv", m : c, f : f }) }, type : 'POST', success : function( data ) { setScenario_data("suggested_budget",Math.floor(c.EstMaxPurchase/50)*50); mar.fakesave(function(){ makeResultBaloon(`Est. Budget
    @${c.EstMaxPurchaseRate} CONV`, elaineui.format("cur",Math.floor(c.EstBU/50)*50),"",c.mortgage,f.mortgage); $(".next-button").removeClass("disabled"); }) } }) } else { mar.pg.calcs.set_sel_calc(f,c); $.ajax({ url : "/api/test/kv", data : { appid : mar.ID, k : "currentadvice", v : JSON.stringify({ budget : budget_calc_fha, c2c : goals_target_c2c_high, hoa : params.hoa, hoi : params.hoi, tax : params.tax, taxv : Math.floor((f.EstMaxPurchase * params.tax)/12), /* convert the percentage to a dollar value */ tot : (params.hoi+params.hoa + Math.floor((f.EstMaxPurchase * params.tax)/12)), /* recalc the total with the tax */ pp : goals_target_value, app : Math.floor(f.EstMaxPP/500)*500, mis : "fha", m : f, c : c }) }, type : 'POST', success : function( data ) { setScenario_data("suggested_budget",Math.floor(f.EstMaxPurchase/50)*50); mar.fakesave(function(){ makeResultBaloon(`Est. Budget
    @${f.EstMaxPurchaseRate} FHA`, elaineui.format("cur",Math.floor(f.EstBU/50)*50),"",f.mortgage,c.mortgage); $(".next-button").removeClass("disabled"); }); } }); } } let conv_calc = (function(){ let r = mar.staticvars.startingrate; let EstMaxPP = 0; let EstMaxPurchase = 0; let EstMaxPurchaseRate = 0; let EstC2C = 0; let EstB = 0; let EstBU = 0; let mEstMaxPP = 0; let mEstMaxPurchase = 0; let mEstMaxPurchaseRate = 0; let mEstC2C = 0; let mEstB = 0; let mEstBU = 0; let mmortgage = false; let inc = 1.5; let max = mar.staticvars.startingrate; let mortgage = false; let done = false; function get(type) { if (type && type == "max" || (EstMaxPurchase == 0 && mEstMaxPurchase > 0)) { return { mortgage : mmortgage, EstMaxPurchase : mEstMaxPurchase, EstMaxPurchaseRate : mEstMaxPurchaseRate, EstC2C : mEstC2C, EstB : mEstB, EstBU : mEstBU, EstMaxPP : mEstMaxPP, done : done } } return { mortgage : mortgage, EstMaxPurchase : EstMaxPurchase, EstMaxPurchaseRate : EstMaxPurchaseRate, EstC2C : EstC2C, EstMaxPP : EstMaxPP, EstBU : EstBU, EstB : EstB, done : done } } let calcnextrate = function() { mar.calculatepart1(0,"conv", { budget : budget_calc_conv+50, c2c : goals_target_c2c_high, hoi : params.hoi, tax : params.tax, hoa : params.hoa, rate : r, sum : "y", caf : "pdu_30_conv", // goals_target_value : num(goals_target_value*1.02), goals_target_value : num(goals_target_value*1), fn : function(rates){ //console.warn(rates); let res = rates; // let res = MAR.mortgageNavigator.filters_from_rates(rates); // console.warn(res); if (res.list.length == 0) { r += 0.5; //0.125; if (r > max) { // makeResultBaloon(`Est. Budget @${EstMaxPurchaseRate} CONV`, elaineui.format("cur",EstMaxPurchase),"",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); return; } calcnextrate(); return; } for (let i=0; i < res.pp.length; i++) { let f = res.list[res.pp[i].i].filters; if (res.list[res.pp[i].i].filters.c2c < (goals_target_c2c_high *1.04)) { //debugger; if (res.pp[i].pp > (goals_target_value*0.9) && res.pp[i].pp > EstMaxPP) { if (res.list[res.pp[i].i].master_type == "scenario") { if (EstMaxPurchaseRate == 0 || res.list[res.pp[i].i].filters.rate < EstMaxPurchaseRate) { EstMaxPP = res.pp[i].pp; EstMaxPurchase = res.list[res.pp[i].i].filters.budget; EstMaxPurchaseRate = res.list[res.pp[i].i].filters.rate; EstC2C = Math.floor(res.list[res.pp[i].i].filters.c2c); EstBU = res.list[res.pp[i].i].filters.budget EstB = res.pp[i].pp + "/"+(goals_target_c2c_high*0.9)+", ltv:"+res.list[res.pp[i].i].filters.ltv + "R:"+res.list[res.pp[i].i].filters.rate; mortgage = `pdu_30_conv:${res.list[res.pp[i].i].uuid}`; // mortgage = res.list[res.pp[i].i].mortgage; // mortgage = MAR.mortgageNavigator.mortgage_from_rates(rates,res.pp[i].i); } } } /* this is the max calc from the c2c page */ if (res.pp[i].pp > mEstMaxPurchase && res.pp[i].pp > mEstMaxPP) { if (mEstMaxPurchaseRate == 0 || res.pp[i].pp > mEstMaxPP || (res.pp[i].pp > EstMaxPP && res.list[res.pp[i].i].filters.rate < mEstMaxPurchaseRate)) { mEstMaxPurchase = res.pp[i].pp; mEstMaxPP = res.pp[i].pp; mEstMaxPurchaseRate = res.list[res.pp[i].i].filters.rate; mEstC2C = Math.floor(res.list[res.pp[i].i].filters.c2c); mEstBU = res.list[res.pp[i].i].filters.budget mEstB = res.list[res.pp[i].i].filters.budget + ", ltv:"+res.list[res.pp[i].i].filters.ltv + "R:"+res.list[res.pp[i].i].filters.rate; mmortgage = `pdu_30_conv:${res.list[res.pp[i].i].uuid}`; } } } } if (r < max) { r += inc; //0.5; //0.125; calcnextrate(); return } // makeResultBaloon(`Max Purchase price @${EstMaxPurchaseRate} CONV`, elaineui.format("cur",EstMaxPurchase),"",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); //makeRepairBaloon(goals_target_value, EstMaxPurchase); //setScenario_data("budget_oc_last_price_price",EstMaxPurchase); //setScenario_data("budget_oc_last_price_rate",r); //mar.fakesave(); } }) } return { calcnextrate : calcnextrate, get : get } })() conv_calc.calcnextrate(); let fha_calc = (function(){ let r = mar.staticvars.startingrate; let EstMaxPP = 0; let EstMaxPurchase = 0; let EstMaxPurchaseRate = 0; let EstC2C = 0; let EstB = 0; let EstBU = 0; let mEstMaxPP = 0; let mEstMaxPurchase = 0; let mEstMaxPurchaseRate = 0; let mEstC2C = 0; let mEstB = 0; let mEstBU = 0; let mmortgage = false; let inc = 1.5; let max = mar.staticvars.startingrate; let mortgage = false; let done = false; function get(type) { if (type && type == "max" || (EstMaxPurchase == 0 && mEstMaxPurchase > 0)) { return { mortgage : mmortgage, EstMaxPurchase : mEstMaxPurchase, EstMaxPurchaseRate : mEstMaxPurchaseRate, EstC2C : mEstC2C, EstB : mEstB, EstBU : mEstBU, EstMaxPP : mEstMaxPP, done : done } } return { mortgage : mortgage, EstMaxPurchase : EstMaxPurchase, EstMaxPurchaseRate : EstMaxPurchaseRate, EstC2C : EstC2C, EstB : EstB, EstBU : EstBU, EstMaxPP : EstMaxPP, done : done } } let calcnextrate = function() { mar.calculatepart1(0,"fha", { budget : budget_calc_fha+50, c2c : goals_target_c2c_high, hoi : params.hoi, tax : params.tax, hoa : params.hoa, sum : "y", rate : r, caf : "pdu_30_fha", goals_target_value : num(goals_target_value*1), // goals_target_value : num(goals_target_value*1.02), fn : function(rates){ //console.warn(rates); let res = rates; // let res = MAR.mortgageNavigator.filters_from_rates(rates); // console.warn(res); if (res.list.length == 0) { r += inc; //0.5; //0.125; if (r > 6) { // makeResultBaloon(`Est Budget @${EstMaxPurchaseRate} FHA`, elaineui.format("cur",EstMaxPurchase),"2",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); return; } calcnextrate(); return; } for (let i=0; i < res.pp.length; i++) { if (res.list[res.pp[i].i].filters.c2c < (goals_target_c2c_high *1.04)) { if (res.pp[i].pp > (goals_target_value*0.9) && res.pp[i].pp > EstMaxPP) { if (res.list[res.pp[i].i].master_type == "scenario") { if (EstMaxPurchaseRate == 0 || res.list[res.pp[i].i].filters.rate < EstMaxPurchaseRate) { EstMaxPP = res.pp[i].pp; EstMaxPurchase = res.list[res.pp[i].i].filters.budget; EstMaxPurchaseRate = res.list[res.pp[i].i].filters.rate; EstC2C = Math.floor(res.list[res.pp[i].i].filters.c2c); EstBU = res.list[res.pp[i].i].filters.budget EstB = res.pp[i].pp + ", ltv:"+res.list[res.pp[i].i].filters.ltv + "R:"+res.list[res.pp[i].i].filters.rate; mortgage = `pdu_30_fha:${res.list[res.pp[i].i].uuid}`; } } } /* this is the max calc from the c2c page */ if (res.pp[i].pp > mEstMaxPurchase && res.pp[i].pp > mEstMaxPP) { if (mEstMaxPurchaseRate == 0 || res.pp[i].pp > mEstMaxPP || (res.pp[i].pp > EstMaxPP && res.list[res.pp[i].i].filters.rate < mEstMaxPurchaseRate)) { mEstMaxPurchase = res.pp[i].pp; mEstMaxPP = res.pp[i].pp; mEstMaxPurchaseRate = res.list[res.pp[i].i].filters.rate; mEstC2C = Math.floor(res.list[res.pp[i].i].filters.c2c); mEstBU = res.list[res.pp[i].i].filters.budget mEstB = res.list[res.pp[i].i].filters.budget + ", ltv:"+res.list[res.pp[i].i].filters.ltv + "R:"+res.list[res.pp[i].i].filters.rate; mmortgage = `pdu_30_fha:${res.list[res.pp[i].i].uuid}`; } } } } if (r < max) { r += inc; //0.5; //0.125; calcnextrate(); return } // makeResultBaloon(`Max Purchase price @${EstMaxPurchaseRate} FHA`, elaineui.format("cur",EstMaxPurchase),"2",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); //makeRepairBaloon(goals_target_value, EstMaxPurchase); //setScenario_data("budget_oc_last_price_price",EstMaxPurchase); //setScenario_data("budget_oc_last_price_rate",r); //mar.fakesave(); } }) } return { calcnextrate : calcnextrate, get : get } })() fha_calc.calcnextrate(); } /* * are we the 1st time through? */ if (firsttime == true) { $.get(`/api/test/kv?appid=${mar.ID}&k=currentadvice`, function(da) { firsttime = false; if (da.status != 0) { doCalc(); return; } if (da.data.budget != budget_calc_fha) { doCalc(); return; } if (da.data.c2c != goals_target_c2c_high) { doCalc(); return; } if (da.data.hoi != params.hoi) { doCalc(); return; } if (da.data.hoa != params.hoa) { doCalc(); return; } if (da.data.tax != params.tax) { doCalc(); return; } if (da.data.pp != goals_target_value) { doCalc(); return; } let c = da.data.m; let f = ("c" in da.data) ? da.data.c : da.data.f; let a = ("f" in da.data) ? da.data.f : da.data.c; mar.pg.calcs.set_sel_calc(c,a); mar.state._suggested_purchaseprice = c.EstMaxPP; setScenario_data("suggested_purchaseprice",Math.floor(c.EstMaxPP)); mar.fakesave(function(){ makeResultBaloon(`Est Budget @${c.EstMaxPurchaseRate}%`, elaineui.format("cur",c.EstBU),"",c.mortgage,f.mortgage); $(".next-button").removeClass("disabled"); }); }) return; } else { doCalc(); } } },200); // let oc_old = function(e) { // // var goal_disp = ""; // var goals_target_value = _num(txt("#goals_target_value")); // var loan_duration = "tol30"; // var goals_target_budget = 999999; // var occupancy_type = getScenario_data("occupancy_type",""); // var property_type = getScenario_data("property_type",""); // // setScenario_data("goals_target_value",goals_target_value); // mar.fakesave(); // // var _suggested_downpayment = 0; // if (goals_target_value !== "") { // //console.warn(' _suggested_downpayment!!!! target budget us nit nothing! target budget: '+goals_target_budget+' mar.answers.v2.scenario.goals_target_value: '+goals_target_value); // // // let options_obj = {} // if (InsuranceApiReturn) { // options_obj.InsuranceApiReturn = InsuranceApiReturn; // } // // var _sc = getScenario_v2(); // if (getScenario_data("scenario_i_know_my_tax","") != "") { // options_obj.tax = Math.round(num(_sc.final_tax)); // } // if (getScenario_data("scenario_i_know_my_insurance","") != "") { // options_obj.hoi = Math.round(num(_sc.final_hoi)); // options_obj.fld = Math.round(num(_sc.final_fld)); // // } // if (getScenario_data("property_type_community_options","") != "") { // options_obj.hoa = Math.round(num(_sc.final_hoa)); // var __tot = Math.round(num(_sc.final_tax) + num(_sc.final_hoi) + num(_sc.final_fld) + num(_sc.final_hoa)); // EL-10 // } // // // // var _ecc = sh.getEstimatedCash2CloseFromPurchasePrice(occupancy_type, property_type, MAR.isVaEligible(), _sc.cscore, MAR.isFirstTimeBuyer(), goals_target_value, options_obj); // var _suggested_downpayment = _ecc.total; // // /* am I satisified with the result */ // let i_am_satisfied = false; // let calcblock = { // gtv_start : goals_target_value, // gtv_current : goals_target_value, // gtv_low : goals_target_value, // upincrement : 5000, // cnt : 0, // going : "" // }; // let goals_target_c2c_high_adj = (goals_target_c2c_high * 1.05) - 250; // while (i_am_satisfied == false) { // calcblock.cnt++; // if (calcblock.cnt > 1000) { // i_am_satisfied = true; // break; // } // // if ( _suggested_downpayment >= goals_target_c2c_high_adj) { // if (calcblock.gtv_current >= calcblock.gtv_start) { // i_am_satisfied = true; // break; // /* we have to be satisfied because we have overshot */ // } // calcblock.gtv_current += calcblock.upincrement; // calcblock.upincrement = calcblock.upincrement / 2; // calcblock.going = "up"; // // } // if ( r250(_suggested_downpayment) < r250(goals_target_c2c_high_adj)) { // if (calcblock.upincrement < 100) { // i_am_satisfied = true; // break; // /* we have to be satisfied because we have overshot */ // } // // let left_over_downpayment = goals_target_c2c_high_adj - _suggested_downpayment; // // calcblock.gtv_current -= 1000; // calcblock.going = "down"; //// calcblock.gtv_current -= left_over_downpayment; // } // // _ecc = sh.getEstimatedCash2CloseFromPurchasePrice(occupancy_type, property_type, MAR.isVaEligible(), _sc.cscore, MAR.isFirstTimeBuyer(), calcblock.gtv_current, options_obj); // var _suggested_downpayment = _ecc.total + (calcblock.gtv_start - calcblock.gtv_current); // // } // // var downpayment_overige = (calcblock.gtv_start - calcblock.gtv_current); // var loan_value = calcblock.gtv_start - downpayment_overige - _ecc.down; // var ltv = (loan_value / calcblock.gtv_start) * 100; // // _ecc.suggested_downpayment = _suggested_downpayment; // _ecc.loan_value = loan_value; // _ecc.ltv = ltv; // // // console.warn("FINAL ECC", _ecc); // // // // // // // // //// let percA = sh.likelydownpaymentpercentage(occupancy_type, property_type, MAR.isVaEligible(), _sc.cscore, MAR.isFirstTimeBuyer(),goals_target_value ); //// console.warn("percA",percA); //// let DEPOSIT_PERCENTAGE = percA[0] ; // (by multiplying it , it comes as 2 or 3.5) //// let __down = percA[2]; // actual cash amount; //// var __apcc = MAR.getApproximateClosingCosts(goals_target_value,0).total; //// var __totc2c = (__down + __apcc); //// var _suggested_downpayment = __totc2c; // // //// var __tot = MAR.getApproximateClosingCosts(mar.answers.v2.scenario.goals_target_value,0).total; //// _suggested_downpayment += num(mar.answers.v2.scenario.goals_target_value) * DEPOSIT_PERCENTAGE; /* 3.5 % deposit */ //// _suggested_downpayment += num(mar.answers.v2.scenario.goals_target_value) * 0.020; /* 2.0 % closing costs */ //// _suggested_downpayment += __tot // // // // var _result = ""; // var _notenoughmoney = false; // //_result += frm.h2("Note: You appear to have enough cash to close.").render(); // let DOWNPAY_FORMATTED = mar.fmt.currency(Math.round(_suggested_downpayment/250)*250); // let DOWNPAY_MAX = mar.fmt.currency((goals_target_c2c_high * 1.05)); // let DOWNPAY_TARGET = mar.fmt.currency((goals_target_c2c_high * 1)); // // //_result += "
    Make sure you have access to enough cash!
    "; // if (r250(_suggested_downpayment) >= (r250(goals_target_c2c_high * 1.05)+500)) { //// _result += "At "+DOWNPAY_FORMATTED+", it looks like the amount of cash needed to purchase this property exceeds your available funds to close of "+DOWNPAY_MAX+". " + //// "You may want to bring your purchase price down, or increase your available cash on the previous page. " // // // let YOUR_WILL_NEED = mar.fmt.currency(Math.round((_suggested_downpayment - goals_target_c2c_high)/250)*250); // // _result += "You will need "+YOUR_WILL_NEED+" more cash to close, than your available "+DOWNPAY_TARGET+". We calculated your monthly expenses, " + // "factoring a minimum downpayment of {{downperc}}. " // // //// _result += "You will need "+YOUR_WILL_NEED+" more cash to close, than your available "+DOWNPAY_MAX+". We calculated your monthly expenses, " + //// "factoring a minimum downpayment of {{downperc}}. " // // // _result = frm.elaine(_result,"er3").render(); // _result += ""; // _notenoughmoney = true; // // mar.increasebudget = { // by : Math.round((_suggested_downpayment - goals_target_c2c_high)/250)*250, // byF : YOUR_WILL_NEED, // to : Math.round((_suggested_downpayment)/250)*250, // toF : mar.fmt.currency(Math.round((_suggested_downpayment)/250)*250), // from : Math.round((goals_target_c2c_high)/250)*250, // fromF : mar.fmt.currency(Math.round((goals_target_c2c_high)/250)*250) // } // // // } // // //// _result += "
    "; //// _result += "
    "; //// _result += "
    "; //// _result += "Estimated minimum needed cash to close:"; //// _result += "
    "; //// _result += "
    "; //// _result += mar.fmt.currency(_suggested_downpayment); //// _result += "
    "; //// _result += "
    "; //// _result += "
    "; //// $("#_result").html(_result); // mar.state._suggested_downpayment = _suggested_downpayment; // // var _downpaymentH = goals_target_c2c_high - _ecc.apcc; // var _downpaymentL = _ecc.down; // var _loan_valueH = (goals_target_value - _downpaymentH); // var _loan_valueL = (goals_target_value - _downpaymentL); // // _downpaymentH = _suggested_downpayment - _ecc.apcc; // _downpaymentL = _suggested_downpayment - _ecc.apcc; // _loan_valueH = loan_value; // _loan_valueH = loan_value; // // _loan_valueL = _ecc.loan_value // // // // let __hoipm = (InsuranceApiReturn) ? (InsuranceApiReturn.Home_Own_Ins_PM + InsuranceApiReturn.fld_Ins_pm) : 0; // let __hoapm = (InsuranceApiReturn) ? Math.round(InsuranceApiReturn.prop_hoa_result) : 0; // let __taxpm = (InsuranceApiReturn) ? Math.round((InsuranceApiReturn.prop_tax_percentage_pm * goals_target_value)/12) : 0; // // var _sc = getScenario_v2(); // if (getScenario_data("scenario_i_know_my_tax","") != "") { // __taxpm = Math.round(num(_sc.final_tax)); // } // if (getScenario_data("scenario_i_know_my_insurance","") != "") { // __hoipm = Math.round(num(_sc.final_hoi) + num(_sc.final_fld)); // } // if (getScenario_data("property_type_community_options","") != "") { // __hoapm = Math.round(num(_sc.final_hoa)); // } // // // // // sh.getEstimatedBudgetBasedOnMiniumSetOfValues( // occupancy_type, // property_type, // _sc.cscore, // _loan_valueH , // goals_target_value, // _ecc.prog, // __hoapm, // __hoipm, // __taxpm, // __INT, // (30*12), // function(d) { // console.warn("D1",d); // console.warn("LH",_loan_valueH); // mar.LVL = { // d : d, // _loan_value : _loan_valueH, // _ecc : _ecc, // end : "" // } // // let _lowerbudget = Math.round(d.total/50)*50; // // sh.getEstimatedBudgetBasedOnMiniumSetOfValues( // occupancy_type, // property_type, // _sc.cscore, // _loan_valueL , // goals_target_value, // _ecc.prog, // __hoapm, // __hoipm, // __taxpm, // __INT, // (30*12), // function(d) { // console.warn("D2",d); // console.warn("LL",_loan_valueL); // // mar.LVH = { // d : d, // _loan_value : _loan_valueL, // _ecc : _ecc, // end : "" // } // // // let _upperbudget = Math.round(d.total/50)*50; // // var __lowerbudget = Math.floor(_lowerbudget* 0.95); // var __upperbudget = Math.ceil(_upperbudget* 1.05); // // mar.LVL.p95 = __lowerbudget; // mar.LVH.p105 = __upperbudget; // // var __lowerbudget = Math.floor(_lowerbudget* 1); // var __upperbudget = Math.ceil(_upperbudget* 1); // // var _actual_downpayment = (mar.LVL.d.down + _ecc.apcc); // _actual_downpayment = _suggested_downpayment; // // //// var baloon = sprintf("Your monthly expenses will be " + //// "roughly %s to %s. Make sure this matches the " + //// "budget you have in mind.",mar.fmt.currency(__lowerbudget),mar.fmt.currency(__upperbudget)); //// //// _result += "
    "; //// _result += frm.h2("Note: "+baloon).render(); //// _result += "
    "; //// //// //// _result += "
    "; //// _result += "
    "; //// _result += "
    "; //// _result += "Estimated minimum needed cash to close:"; //// _result += "
    "; //// _result += "
    "; //// _result += mar.fmt.currency(Math.round(_suggested_downpayment/250)*250); //// _result += "
    "; //// _result += "
    "; //// _result += "
    "; //// $("#_result").html(_result); // // let DOWNPAY = mar.fmt.currency(Math.round(_actual_downpayment/250)*250); // let LO_BUDGET = mar.fmt.currency(__lowerbudget); // let HI_BUDGET = mar.fmt.currency(__upperbudget); // // let HI_C2C = mar.fmt.currency(r250(goals_target_c2c_high)); // let HI_PERC = (_ecc.percA[0]*100)+"%"; // let MIRATE = mar.LVL.d.mip+"%"; // HI_PERC = (roundHalf((mar.LVL.d.down / mar.LVL.d.pp)*100)).toFixed(1)+"%" // mar.LVL._perc = HI_PERC // mar.LVL._perc5 = HI_PERC // mar.LVL._perc51 = (((mar.LVL.d.down / mar.LVL.d.pp)*100)).toFixed(4)+"%" // // var baloon = sprintf("Your estimated minimum needed cash to close will be " + // "roughly %s. Make sure this matches the " + // "budget you have in mind.",DOWNPAY); // // /** // * baloon // */ // var DBG = ""; // //DBG += ` dn ${mar.LVL.d.down} eccdown ${_ecc.down} eccp ${_ecc.percA[0]} `; // // // // var MIN_DOWN_PERC = (_ecc.percA[0]*100)+"%"; // //MIN_DOWN_PERC = HI_PERC; // // // var baloon = sprintf("We A calculated you need about %s to close on this purchase, putting down about %s." + //// " and an Annual Mortgage Insurance Percentage rate of %s" + // " %s ",DOWNPAY,HI_PERC,DBG); // // // // _result = _result.replace(/{{downperc}}/g, MIN_DOWN_PERC+DBG); // // if (_notenoughmoney == false) { // _result += "
    "; // _result += frm.h2("Note: "+baloon).render(); // _result += "
    "; // // } // // LO_BUDGET = ""+LO_BUDGET+""; // HI_BUDGET = ""+HI_BUDGET+""; // // LO_INFO = ""; // // _result += "
    "; // _result += "
    "; // _result += "
    "; // _result += "Estimated monthly
    housing expenses "; // _result += LO_INFO; // _result += "
    "; // _result += "
    "; // _result += LO_BUDGET; // _result += "
    "; // _result += "
    "; // //// _result += "
    "; //// _result += "
    "; //// _result += "Estimated Upper budget:"; //// _result += "
    "; //// _result += "
    "; //// _result += HI_BUDGET; //// _result += "
    "; //// _result += "
    "; // // // _result += "
    "; // $("#_result").html(_result); // // // // $($("#_result .xhuman")[0]).Humanize({ // opts : { // fn : function() { // } // }, // quick : false, // }); // // } // ); // } // ); // // // //$('#goals_target_value_slider').css("background","linear-gradient(to right, #e51e2b 0%,#e51e2b 37%,#f6bd40 38%,#f6bd40 64%,#90c33a 65%,#90c33a 100%)"); // // // } // // // } mar.pg.oc = oc; let or = function(){ let sp = mar.isallowed_scenario("#scenario-purchaseprice"); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider({ fn : function() { // sh.getEstimatedPurchasePriceFromCash2CloseAsync(occupancy_type, property_type, MAR.isVaEligible(), _sc.cscore, MAR.isFirstTimeBuyer(), goals_target_c2c_low, function(_goals_target_value){ // loval = _goals_target_value; // sh.getEstimatedPurchasePriceFromCash2CloseAsync(occupancy_type, property_type, MAR.isVaEligible(), _sc.cscore, MAR.isFirstTimeBuyer(), goals_target_c2c_high, function(_goals_target_value){ var hiperc = elaineui.updateRangefromVal(hival, 50000, 250000, 750000, 1500000); var loperc = elaineui.updateRangefromVal(loval, 50000, 250000, 750000, 1500000); var grad = elaineui.buildGradientR(loperc,hiperc); $("#goals_target_value_slider").css("background",grad); // }); // }); } }); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); var _url = "/calc/home_owners_insurance?1" + "&county="+getCounty_v2() + "&square_foot=1700" + "&build_period=1974" + "&backend_lia_pm=800" + "&condo=" + ((property_type == "condo") ? "Y" : "N") + "&close_to_or_on_water=N" + "&sfr=" + ((property_type == "sfr") ? "Y" : "N") + "&in_community=" + ((property_type == "sfr") ? "N" : "Y") + "&luxury_community=N" + "&luxury_condo=N"; $.get(_url, function(d2) { if (d2 && "outputs" in d2) InsuranceApiReturn = d2.outputs; $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(); } }, quick : false, }); }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "estimate" } })(); /* file /ui/app/js/pages.budget.js , last updated 1551214553823*/ //actually budget 2 mar.pg["scenario-budget"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { mar.clear = function(){ alert(goals_target_budget_low); alert(goals_target_budget_high); delScenario_data("goals_target_budget_low"); delScenario_data("goals_target_budget_high"); delScenario_data("calculation_priority"); delScenario_data("__hasvisited_budget"); mvc.go("#scenario-budget"); } let has_visited = (getScenario_data("__hasvisited_budget","N") == "Y"); let revealclass = (has_visited) ? "" : "x-hide x-revealdiv"; // reveal .1 var goals_target_budget_low = getScenario_data("goals_target_budget_low","0"); var goals_target_budget_high = getScenario_data("goals_target_budget_high","0"); var calculation_priority = getScenario_data("calculation_priority",""); var suggested_budget = getScenario_data("suggested_budget",1800); let newvaue = false; if (goals_target_budget_low == 0) { goals_target_budget_low = 1800; newvaue = true; } if (goals_target_budget_high == 0) { goals_target_budget_high = 1800; } var _sc = getScenario_v2(); // var __tot = num(_sc.final_tax) + num(_sc.final_hoi) + num(_sc.final_fld) + num(_sc.final_hoa) var goals_target_value = getScenario_data("goals_target_value","250000"); var goals_target_c2c_low = getScenario_data("goals_target_c2c_low",0); var goals_target_c2c_high = getScenario_data("goals_target_c2c_high",0); var occupancy_type = getScenario_data("occupancy_type",""); var property_type = getScenario_data("property_type",""); let sh = elaineui.scenarioHelpers; let percA = sh.likelydownpaymentpercentage(occupancy_type, property_type, MAR.isVaEligible(), _sc.cscore, MAR.isFirstTimeBuyer(),goals_target_value); //console.warn("percA",percA); let perc = percA[0] * 100 ; // (by multiplying it , it comes as 2 or 3.5) var __apcc = MAR.getApproximateClosingCosts(goals_target_value,0).total10; var est_downpayment = goals_target_c2c_high - __apcc; /* * [calculate this as follows: * we kan the LTV based on the purchase price and cash to close. * So we can than take the purchase price -/- estimated down payment / 10,000 x 60, and add this to the $ 600 above for tax insurance hoa] * */ // var est_mbudget = Math.floor(((goals_target_value - est_downpayment) / 10000) * 60) + __tot; var est_mbudget = suggested_budget; if (newvaue) { goals_target_budget_low = (Math.round((est_mbudget*0.96)/50)*50); goals_target_budget_high =(Math.round((est_mbudget*1.02)/50)*50); } // elaineui.format("cur",Math.round((d.total*0.98)/25)*25) + " to " + elaineui.format("cur",Math.round((d.total*1.02)/25)*25); let h = ""; h += frm.htitle("Budget pt2").render(); h += frm.elaine("Let's talk about your budget for your requested target purchase price of .","er").render(); h += "
    "; let minmax = function(group,name,min,max,label) { let h = ""; h += ``+ ``+ ``+ ``+ ``+ ``+ ``+ `
    ${min} ${max}
    ...O...
    `; return h; } let tdmaxclick = function() { let e = $(this); let n = e.data("name"); let ta = $(`.tdgroup-table-${n}`); let min = ta.data("min") let max = ta.data("max") let grp = ta.data("group") } h += "
    Please select one MAX or MIN button and press NEXT:
    "; h += "
    Purchase Price:
    "; h += minmax("g1","pp",0,230000,"PurchasePrice"); h += "
    Monthly Housing Cost:
    "; h += minmax("g1","bu",0,1800,"Monthly Budget"); h += "
    Cash to Close:
    "; h += minmax("g1","c2c",0,23000,"Cash to Close"); h += "
    What is your comfortable budget per month?
    "; //100 increments to 2500 than 250 to 15.000 VAL = goals_target_budget_low; h += frm.slider("goals_target_budget_low","Within $100 of:",VAL,"","",function(){ setScenario_data("goals_target_budget_low",goals_target_budget_low); oc("low"); }, { v00 : '0 ', v50 : '2500', v50_inc : '25', v75 : '8000', v75_inc : '50', v100 : '15000', v100_inc : '250', start_val : '1800', trackStyling : 'trafficlight' }).render(); h += "
    "; // reveal - start (with validation to previous field) // h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += frm.hr().render(); // h += "
    How do you want your loan calculated?
    "; // h += "
    " h += ""; h += ""; VAL = calculation_priority; h += frm.radio("calculation_priority","How do you want your loan calculated?",VAL,"","",function(){ oc(); },{ "-" : "For my budget and available assest, I would like to see", "high_purchase" : "maximum purchase price", "--" : "
    - or -
    For my purchase price, I want the
    ", "low_closing" : "lowest closing cost ", "low_rate" : "lowest rate possible ", "balanced_apr" : "Lowest monthly" }).render().wrap("
    ","
    "); // h += "
    What is your maximum budget per month?
    "; // // // VAL = goals_target_budget_high; // h += frm.slider("goals_target_budget_high","Approx.",VAL,"","",function(){ // oc("high"); // }, { // v00 : '0 ', // v50 : '2500', // v50_inc : '25', // v75 : '8000', // v75_inc : '50', // v100 : '15000', // v100_inc : '250', // start_val : '1800' // }).render(); h += "
    " // reveal - end h += "
    "; // end er /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var val; /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "goals_target_budget_low") { val = txt("#goals_target_budget_low"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us how much you can comfortably afford to spend each month.","top"); return; } } oc(); } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ /** * warning check */ if (txt("#goals_target_budget_low").trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us how much you can comfortably afford to spend each month.","top"); return; } if (radio("calculation_priority").trim().length == 0 ) { mar.tip(".help-button","warning","Please tell what your priorities are.","top"); return; } // so it shows if you have already been there setScenario_data("__hasvisited_budget","Y"); /** * warning check end */ setScenario_data("__scenario_"+"budget"+"_passed","Y"); mar.fakesave(); mvc.go("#scenario-magic2"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-budget1"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc_last_price = getScenario_data("budget_oc_last_price_price",false); let oc_last_budget = getScenario_data("budget_oc_last_price_budget",false); let oc = function(type) { var goals_target_budget_low = _num(txt("#goals_target_budget_low")); var goals_target_budget_high = goals_target_budget_low; var calculation_priority = radio("calculation_priority"); $("#calculation_priority_pp").html(elaineui.format("cur",goals_target_value)); let r = 5; let EstMaxPurchase = 0; // let makeResultBaloon = function(T1, T2) { // let LO_INFO = ""; // _result = ""; // _result = "
    "; // _result += "
    "; // _result += "
    "; // _result += "
    "; // _result += T1; //// _result += LO_INFO; // _result += "
    "; // _result += "
    "; // _result += T2; // _result += "
    "; // _result += "
    "; // _result += "
    "; // $("#_result").html(_result); // // } let makeResultBaloon = function(T1, _goals_target_value, N, A, B) { let goals_target_value = _goals_target_value; _result = ""; _result += "
    "; _result += "
    "; _result += "
    "; _result += "
    "; _result += `${T1} :`; _result += "
    "; _result += "
    "; _result += goals_target_value; if (A || B) { _result += "
    " _result += (A)?A:""; _result += (B)?B:""; _result += ""; } _result += "
    "; _result += "
    "; _result += "
    "; $(`#_result${N}`).html(_result); mar.state._suggested_purchaseprice = goals_target_value; } let makeRepairBaloon = function(goals_target_value, EstMaxPurchase) { if (goals_target_value > EstMaxPurchase) { if ($("#repair-div .r1").length == 0) { let vv = ""; vv += frm.hr().render(); vv += frm.elaine("It is not realistic that you'll reach your desired purchase price of "+elaineui.format("cur",goals_target_value)+" with the monthly budget of "+ elaineui.format("cur",goals_target_budget_high) + " per month and available cash to close of "+ elaineui.format("cur",goals_target_c2c_high) + ". Please change your purchase amount or increase your cash to close.","").render(); vv += ""; $("#repair-div").html(vv); } } else { if ($("#repair-div .r2").length == 0) { let vv = ""; // vv += frm.hr().render(); // vv += frm.elaine("It is realistic that you'll reach your desired purchase price of "+elaineui.format("cur",goals_target_value)+" with the monthly budget of "+ // elaineui.format("cur",goals_target_budget_high) + // " per month and available cash to close of "+ // elaineui.format("cur",goals_target_c2c_high) + // "" + // "","").render(); vv += ""; $("#repair-div").html(vv); } } } let calcnextrate = function() { makeResultBaloon("Calculating Max Purchase price", elaineui.working()); $("#repair-div").html(elaineui.working()); let end_calc = function() { if (conv_calc.get().done == false) return; if (fha_calc.get().done == false) return; let f = fha_calc.get(); let c = conv_calc.get(); if (c.EstMaxPurchase == 0 && f.EstMaxPurchase == 0) { setScenario_data("budget_oc_last_price_budget",Math.floor(goals_target_budget_high)); setScenario_data("budget_oc_last_price_price",0); mar.fakesave(function(){ makeResultBaloon(`Max Purchase price @${EstMaxPurchaseRate}`, "No result","","",""); calcnextrate_final(); }); return; // no result } if (c.EstMaxPurchase > f.EstMaxPurchase) { mar.pg.calcs.set_sel_calc(c); mar.state._suggested_purchaseprice = c.EstMaxPurchase; setScenario_data("budget_oc_last_price_budget",Math.floor(goals_target_budget_high)); setScenario_data("budget_oc_last_price_price",Math.floor(c.EstMaxPurchase)); mar.fakesave(function(){ makeResultBaloon(`Max Purchase price @${c.EstMaxPurchaseRate} CONV`, elaineui.format("cur",c.EstMaxPurchase),"",`c2c:${c.EstC2C}`,`budget:${c.EstB}`); $(".next-button").removeClass("disabled"); calcnextrate_final(); }); } else { mar.pg.calcs.set_sel_calc(f); mar.state._suggested_purchaseprice = f.EstMaxPurchase; setScenario_data("budget_oc_last_price_budget",Math.floor(goals_target_budget_high)); setScenario_data("budget_oc_last_price_price",Math.floor(f.EstMaxPurchase)); mar.fakesave(function(){ makeResultBaloon(`Max Purchase price @${f.EstMaxPurchaseRate} FHA`, elaineui.format("cur",f.EstMaxPurchase),"",`c2c:${f.EstC2C}`,`budget:${f.EstB}`); $(".next-button").removeClass("disabled"); calcnextrate_final(); }); } } let conv_calc = (function(){ let r = mar.staticvars.startingrate; let EstMaxPurchase = 0; let EstMaxPurchaseRate = 0; let EstC2C = 0; let EstB = 0; let EstBU = 0; let inc = 1.5; let max = mar.staticvars.startingrate; let mortgage = false; let done = false; function get() { return { mortgage : mortgage, EstMaxPurchase : EstMaxPurchase, EstMaxPurchaseRate : EstMaxPurchaseRate, EstC2C : EstC2C, EstB : EstB, EstBU : EstBU, done : done } } let calcnextrate = function() { mar.calculatepart1(0,"conv", { budget : num(goals_target_budget_high)+100, c2c : goals_target_c2c_high, rate : r, goals_target_value : num(goals_target_value*1.02), fn : function(rates){ //console.warn(rates); let res = MAR.mortgageNavigator.filters_from_rates(rates); console.warn(res); if (res.list.length == 0) { r += 0.5; //0.125; if (r > max) { // makeResultBaloon(`Est. Budget @${EstMaxPurchaseRate} CONV`, elaineui.format("cur",EstMaxPurchase),"",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); return; } calcnextrate(); return; } for (let i=0; i < res.pp.length; i++) { let f = res.list[res.pp[i].i].filters; if (res.list[res.pp[i].i].filters.c2c < goals_target_c2c_high) { if (res.pp[i].pp > (goals_target_value*0.9)) { if (EstBU == 0 || res.list[res.pp[i].i].filters.budget < EstBU) { EstMaxPurchase =res.pp[i].pp; EstMaxPurchaseRate = res.list[res.pp[i].i].filters.rate; EstC2C = Math.floor(res.list[res.pp[i].i].filters.c2c); EstB = res.list[res.pp[i].i].filters.budget+", ltv:"+res.list[res.pp[i].i].filters.ltv + "R:"+res.list[res.pp[i].i].filters.rate; EstBU = res.list[res.pp[i].i].filters.budget mortgage = MAR.mortgageNavigator.mortgage_from_rates(rates,res.pp[i].i); } } } } if (r < max) { r += inc; //0.5; //0.125; calcnextrate(); return } // makeResultBaloon(`Max Purchase price @${EstMaxPurchaseRate} CONV`, elaineui.format("cur",EstMaxPurchase),"",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); //makeRepairBaloon(goals_target_value, EstMaxPurchase); //setScenario_data("budget_oc_last_price_price",EstMaxPurchase); //setScenario_data("budget_oc_last_price_rate",r); //mar.fakesave(); } }) } return { calcnextrate : calcnextrate, get : get } })() conv_calc.calcnextrate(); let fha_calc = (function(){ let r = mar.staticvars.startingrate; let EstMaxPurchase = 0; let EstMaxPurchaseRate = 0; let EstC2C = 0; let EstB = 0; let EstBU = 0; let inc = 1.5; let max = mar.staticvars.startingrate; let mortgage = false; let done = false; function get() { return { mortgage : mortgage, EstMaxPurchase : EstMaxPurchase, EstMaxPurchaseRate : EstMaxPurchaseRate, EstC2C : EstC2C, EstB : EstB, EstBU : EstBU, done : done } } let calcnextrate = function() { mar.calculatepart1(0,"fha", { budget : num(goals_target_budget_high)+100, c2c : goals_target_c2c_high, rate : r, goals_target_value : num(goals_target_value*1.02), fn : function(rates){ //console.warn(rates); let res = MAR.mortgageNavigator.filters_from_rates(rates); console.warn(res); if (res.list.length == 0) { r += inc; //0.5; //0.125; if (r > 6) { // makeResultBaloon(`Est Budget @${EstMaxPurchaseRate} FHA`, elaineui.format("cur",EstMaxPurchase),"2",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); return; } calcnextrate(); return; } for (let i=0; i < res.pp.length; i++) { if (res.list[res.pp[i].i].filters.c2c < goals_target_c2c_high) { if (res.pp[i].pp > (goals_target_value*0.9)) { if (EstBU == 0 || res.list[res.pp[i].i].filters.budget < EstBU) { EstMaxPurchase =res.pp[i].pp; EstMaxPurchaseRate = res.list[res.pp[i].i].filters.rate; EstC2C = Math.floor(res.list[res.pp[i].i].filters.c2c); EstBU = res.list[res.pp[i].i].filters.budget EstB = res.list[res.pp[i].i].filters.budget+", ltv:"+res.list[res.pp[i].i].filters.ltv + "R:"+res.list[res.pp[i].i].filters.rate; mortgage = MAR.mortgageNavigator.mortgage_from_rates(rates,res.pp[i].i); } } } } if (r < max) { r += inc; //0.5; //0.125; calcnextrate(); return } // makeResultBaloon(`Max Purchase price @${EstMaxPurchaseRate} FHA`, elaineui.format("cur",EstMaxPurchase),"2",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); //makeRepairBaloon(goals_target_value, EstMaxPurchase); //setScenario_data("budget_oc_last_price_price",EstMaxPurchase); //setScenario_data("budget_oc_last_price_rate",r); //mar.fakesave(); } }) } return { calcnextrate : calcnextrate, get : get } })() fha_calc.calcnextrate(); // mar.calculatepart1(0,"conv", { // budget : goals_target_budget_high, // rate : r, // fn : function(rates){ // console.warn(rates); // let res = MAR.mortgageNavigator.filters_from_rates(rates); // console.warn(res); // if (res.list.length == 0) { // r += 0.125; // if (r > 6) return; // calcnextrate(); // return; // } // if (res.pp[0].pp > EstMaxPurchase) { // EstMaxPurchase = res.pp[0].pp; // if (r < 6) { // r += 0.125; // calcnextrate(); // return // } // } // // makeResultBaloon(`Max Purchase price @${r}`, elaineui.format("cur",EstMaxPurchase)); // makeRepairBaloon(goals_target_value, EstMaxPurchase); // // setScenario_data("budget_oc_last_price_price",EstMaxPurchase); // setScenario_data("budget_oc_last_price_rate",r); // mar.fakesave(); // } // }) } let calcnextrate_final = function() { let _rate = getScenario_data("budget_oc_last_price_rate"); let _price = getScenario_data("budget_oc_last_price_price"); if (num(_price) < goals_target_value) { makeRepairBaloon(goals_target_value, _price) } else { makeResultBaloon(`Max Purchase price @${_rate}%`, elaineui.format("cur",oc_last_price)); makeRepairBaloon(goals_target_value, _price) } } if (oc_last_budget == false || num(oc_last_budget) != goals_target_budget_high) { oc_last_budget = goals_target_budget_high; setScenario_data("budget_oc_last_price_budget",oc_last_budget); calcnextrate(); } else if (oc_last_price != false) { calcnextrate(); // calcnextrate_final(); } setScenario_data("goals_target_budget_low",goals_target_budget_low); setScenario_data("goals_target_budget_high",goals_target_budget_high); setScenario_data("calculation_priority",calculation_priority); mar.fakesave(); } mar.pg.oc = oc; let or = function(){ let sp = mar.isallowed_scenario("#scenario-budget"); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); var __taxpm = num(_sc.final_tax); var __hoipm = num(_sc.final_hoi) + num(_sc.final_fld); var __hoapm = num(_sc.final_hoa); var est_downpayment = goals_target_c2c_high - __apcc; var _loan_value = goals_target_value - est_downpayment; $("#body-container").find("#goals_target_budget_low_slider.xx-slider").myslider({ fn : function() { var loperc = elaineui.updateRangefromVal(suggested_budget*0.94, 0, 2500, 8000, 15000); var hiperc = elaineui.updateRangefromVal(suggested_budget*1.02, 0, 2500, 8000, 15000); var grad = elaineui.buildGradient(loperc,hiperc); $("#goals_target_budget_low_slider").css("background",grad); } }); // sh.getEstimatedBudgetBasedOnMiniumSetOfValues( // occupancy_type, // property_type, // _sc.cscore, // _loan_value , // goals_target_value, // percA[1], // __hoapm, // __hoipm, // __taxpm, // mar.TODAYS_INTEREST(), // (30*12), // function(d) { // est_mbudget = (Math.round(d.total/50)*50); // // $("#body-container").find("#goals_target_budget_low_slider.xx-slider").myslider({ // fn : function() { // var loperc = elaineui.updateRangefromVal(est_mbudget*0.94, 0, 2500, 8000, 15000); // var hiperc = elaineui.updateRangefromVal(est_mbudget*1.02, 0, 2500, 8000, 15000); // var grad = elaineui.buildGradient(loperc,hiperc); // $("#goals_target_budget_low_slider").css("background",grad); // } // }); // // if (newvaue) { // goals_target_budget_low = (Math.round((est_mbudget*0.96 )/50)*50); // goals_target_budget_high =(Math.round((est_mbudget*1.02)/50)*50); // goals_target_budget_low = (Math.round((est_mbudget*1 )/50)*50); // goals_target_budget_high =(Math.round((est_mbudget*1)/50)*50); // txt("#goals_target_budget_low",goals_target_budget_low) // $("#goals_target_budget_low").change(); // } // // }); // $("goals_target_budget_high // $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#calculation_priority_pp").html(elaineui.format("cur",goals_target_value)); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(); } }, quick : false, }); $(".info-priority").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "" + "
    " + "
    Lowest rate possible : " + "
    Lowest closing cost possible :" + "
    Balanced APR : " + "
    Highest possible purchase price :" "
    "; swal({ className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); }); $(".info-budget").css("display","none"); $(".info-budget").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "" + "
    " + $("#budget_popup").html() + // "Take your monthly stable income before Uncle Sam takes his cut. Your job, average profit in your business per month, your rental profits.
    " + // "
    " + // "Split this income in half.
    " + // "
    " + // "- Subtract your car payment.
    " + // "- Subtract all minimum credit card payments you have.
    " + // "- Subtract one percent of your outstanding student loans.
    " + // "- Subtract your child support / alimony payments
    " + // "- Subtract all your other payment obligations from your credit report
    " + // "
    " + // "What is left is a rough estimate of your budget.
    " + // "
    " + "Estimated maximum housing budget per month " + "
    1500
    "+ "Don't worry, if you are not sure, just complete the application and let your loan officer figure it out! Call "+loanofficer.telF+" to reach "+loanofficer.name+" anytime!
    " + "
    " + ""; swal({ className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); $(".middleInfoPopup ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#estBdgPMonth ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $('.budget_popup .miniInput').on('input', function(){ console.log('#budget_popup input'); }); // var s = document.createElement("div"); // s.setAttribute("class","normal-form"); // s.innerHTML = frm.h2("" + // "What is a housing budget?
    "+ // "This is all the money combined that you are willing to spend each month on your home:
    " + // "- Principle and Interest
    " + // "- Mortgage Insurance if applicable
    " + // "- Tax Escrows
    " + // "- Insurance Escrows
    " + // "- Home Owners Association fees if applicable

    " + // "How do I estimate my max budget?
    "+ // "- Add up the before tax income of everyone on the loan.
    "+ // "- Take half of this amount
    "+ // "- Subtract your car payments, minimum credit card payment, 1% of your outstanding student loan amounts, and other liabilities you may have.

    "+ // "What's left is close to your maximum housing budget. ").render(); // // swal({ // title : "Budget", // className : "fred3", // content : s, // button : "got it" // }) }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "estimate" } })(); /* file /ui/app/js/pages.budget1.js , last updated 1550057848426*/ mar.pg["scenario-budget1"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { var goals_target_budget_low = getScenario_data("goals_target_budget_low","1800"); var goals_target_budget_high = getScenario_data("goals_target_budget_high","1800"); var _sc = getScenario_v2(); var __tot = Math.round(num(_sc.final_tax) + num(_sc.final_hoi) + num(_sc.final_fld) + num(_sc.final_hoa)); // EL-10 var goals_target_value = getScenario_data("goals_target_value","250000"); var goals_target_c2c_low = getScenario_data("goals_target_c2c_low",0); var goals_target_c2c_high = getScenario_data("goals_target_c2c_high",0); var occupancy_type = getScenario_data("occupancy_type",""); var property_type = getScenario_data("property_type",""); let sh = elaineui.scenarioHelpers; let percA = sh.likelydownpaymentpercentage(occupancy_type, property_type, MAR.isVaEligible(), _sc.cscore, MAR.isFirstTimeBuyer(),goals_target_value); console.warn("percA",percA); let perc = percA[0] * 100 ; // (by multiplying it , it comes as 2 or 3.5) var _apcc = MAR.getApproximateClosingCosts(goals_target_value,0); var __apcc = MAR.getApproximateClosingCosts(goals_target_value,0).total10; var est_downpayment = goals_target_c2c_high - __apcc; /* * [calculate this as follows: * we kan the LTV based on the purchase price and cash to close. * So we can than take the purchase price -/- estimated down payment / 10,000 x 60, and add this to the $ 600 above for tax insurance hoa] * */ // &&&&&&&& here var est_mbudget = Math.floor(((goals_target_value - est_downpayment) / 10000) * 60) + __tot; let h = ""; h += frm.htitle("Budget pt1").render(); let ltv = 95; if (ltv > 80) { // EL-10 h += frm.elaine("So we have figured out that we need at least "+elaineui.format("cur",__tot)+" per month before adding any mortgage payment, or mortgage insurance.","er").render(); } else { // EL-10 h += frm.elaine("So we have figured out that we need at least "+elaineui.format("cur",__tot)+" per month before adding any mortgage payment.","er").render(); } h += "
    " h +='
    '; let mmr = [ "at Actual rate, payment, & cost may be higher.", "hh Monthly Budget (So far)", "bg Property Taxes "+_sc.final_tax, "bg HOA fees "+_sc.final_hoa, "bg Home Insurance "+_sc.final_hoi, "bg Flood Insurance "+_sc.final_fld, "fb Budget without mortgage "+__tot ]; h += makepopup(mmr); h +='
    '; h += frm.hr().render(); h +='
    '; h +='
    '; h += "
    ";//end er /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ let $elm = $(".mortyes"); if ($elm.hasClass("x-hide")) { $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); }); return; } $elm = $(".mortyes-quote"); if ($elm.hasClass("x-hide")) { $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); }); return; } setScenario_data("__scenario_"+"budget1"+"_passed","Y"); mar.fakesave(); //mvc.go("#scenario-budget"); mvc.go("#scenario-magic2"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-hoa"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(type) { // var goals_target_budget_low = _num(txt("#goals_target_budget_low")); // var goals_target_budget_high = _num(txt("#goals_target_budget_high")); // // if (goals_target_budget_low > goals_target_budget_high) { // setTimeout(function(){ // var goals_target_budget_high = _num(txt("#goals_target_budget_high")); // var goals_target_budget_low = _num(txt("#goals_target_budget_low")); // if (type == "high") { // goals_target_budget_low = goals_target_budget_high; // txt("#goals_target_budget_low",goals_target_budget_low) // $("#goals_target_budget_low").change(); // } else { // goals_target_budget_high = goals_target_budget_low; // txt("#goals_target_budget_high",goals_target_budget_high) // $("#goals_target_budget_high").change(); // } // },5) // // } // // setScenario_data("goals_target_budget_low",goals_target_budget_low); // setScenario_data("goals_target_budget_high",goals_target_budget_high); mar.fakesave(); } mar.pg.oc = oc; let or = function(){ let sp = mar.isallowed_scenario("#scenario-budget1"); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(); } }, quick : false, }); $(".info-budget").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = frm.h2("" + "What is a housing budget?
    "+ "This is all the money combined that you are willing to spend each month on your home:
    " + "- Principle and Interest
    " + "- Mortgage Insurance if applicable
    " + "- Tax Escrows
    " + "- Insurance Escrows
    " + "- Home Owners Association fees if applicable

    " + "How do I estimate my max budget?
    "+ "- Add up the before tax income of everyone on the loan.
    "+ "- Take half of this amount
    "+ "- Subtract your car payments, minimum credit card payment, 1% of your outstanding student loan amounts, and other liabilities you may have.

    "+ "What's left is close to your maximum housing budget. ").render(); swal({ title : "Budget", className : "fred3", content : s, button : "got it" }) }); var __taxpm = num(_sc.final_tax); var __hoipm = num(_sc.final_hoi) + num(_sc.final_fld); var __hoapm = num(_sc.final_hoa); var est_downpayment = goals_target_c2c_high - __apcc; var _loan_value = goals_target_value - est_downpayment; $.get(`/api/test/kv?appid=${mar.ID}&k=currentadvice`, function(da) { //firsttime = false; if (da.status != 0) { return; } let _previously_advised_total = num(da.data.tot); let _actual_total = __taxpm + __hoipm + __hoapm; let h = ""; /** * make sure we don't complain if the margin is within 25 euro */ if (_previously_advised_total < (_actual_total - 25)) { // swal(`We previously estimated a lower cost if ${_previously_advised_total} for you and therefore xxx`); if (num(getScenario_data("goals_target_value")) < num(getScenario_data("first_suggested_purchase_price"))) { h = (`Your monthly expenses for the ${elaineui.format("cur",num(getScenario_data("goals_target_value")))} purchase price will be a bit higher, due to the increased estimates for Taxes, Insurance and HOA fees.`); } else { h = "Your maximum purchase price will be a bit higher, due to the reduced estimate for Taxes, Insurace and HOA fees."; } } else if (_previously_advised_total > (_actual_total + 25)) { // swal(`We previously estimated a higher cost if ${_previously_advised_total} for you and therefore xxx`); if (num(getScenario_data("goals_target_value")) < num(getScenario_data("first_suggested_purchase_price"))) { h = `Your monthly expenses for the ${elaineui.format("cur",num(getScenario_data("goals_target_value")))} purchase price will be a bit lower, due to the lower estimates for Taxes, Insurance and HOA fees.` } else { h = ("Your maximum purchase price will be a bit lower, due to the increased estimates for Taxes, Insurance and HOA fees."); } } else { if (num(getScenario_data("goals_target_value")) < num(getScenario_data("first_suggested_purchase_price"))) { h = ""; } else { h = ""; } } // var h = sprintf("
    For a requested purchase price of " + // "%s purchase price, you would spend roughly " + // "%s on your monthly housing expenses.
    "+ // "", elaineui.format("cur",goals_target_value), spread); $(".mortyes-quote").html(`
    ${h}
    `); }) console.warn({ percA : percA, apcc : _apcc, est_downpayment : est_downpayment, _loan_value : _loan_value }) function roundHalf(num) { return Math.round(num*2)/2; } let makeResultBaloon = function(A,B,C,D) { if (arguments.length == 3) { $(".mortyes-quote").html(B); } else { let _perc = 3; let spread = B; // var h = sprintf("
    If you put " + // "%s down on the requested " + var h = sprintf("
    For a requested purchase price of " + "%s purchase price, you would spend roughly " + "%s on your monthly housing expenses.
    "+ "", elaineui.format("cur",goals_target_value), spread); $(".mortyes-quote").html(h); // "",elaineui.format("perc3opt",_perc), elaineui.format("cur",goals_target_value), spread); } } let nextcalc = function() { makeResultBaloon("Budget", elaineui.working().wrap("
    ","
    "),""); //$(".next-button").addClass("disabled"); // let sel_calc = false; let end_calc = function() { if (conv_calc.get().done == false) return; if (fha_calc.get().done == false) return; let f = fha_calc.get(); let c = conv_calc.get(); if (c.EstMaxPurchase == 0 && f.EstMaxPurchase == 0) { // makeResultBaloon(`Max Purchase price`, "No result","","",""); let _result = ""; _result += `To get to a higher purchase price, you need more to close. Please reduce your purchase price, or increase your available cash, for example with a gift from a direct relative.`; // `You can't reach your desired purchase price of ${elaineui.format("cur",goals_target_value)} with a `+ // `cash to close budget of ${elaineui.format("cur",goals_target_c2c_high)}. Reduce your purchase price. `+ `` _result = frm.elaine(_result,"er3").render(); _result += ""; _notenoughmoney = true; $(`#_result`).html(_result); $(".next-button").removeClass("disabled"); return; // no result } let prefprog = setScenario_data("pdu_preferred_programme",""); let selectprog = (c.EstMaxPurchase > f.EstMaxPurchase) ? "conv" : "fha"; if (prefprog != "") selectprog = prefprog; if (selectprog == "conv") { mar.pg.calcs.set_sel_calc(c); setScenario_data("suggested_budget",Math.floor(c.EstMaxPurchase)); mar.fakesave(function(){ makeResultBaloon(`Est. Budget
    @${c.EstMaxPurchaseRate} CONV`, elaineui.format("cur",c.EstMaxPurchase),"",`c2c:${c.EstC2C}`,`budget:${c.EstB}`); //$(".next-button").removeClass("disabled"); }) } else { mar.pg.calcs.set_sel_calc(f); setScenario_data("suggested_budget",Math.floor(f.EstMaxPurchase)); mar.fakesave(function(){ makeResultBaloon(`Est. Budget
    @${f.EstMaxPurchaseRate} FHA`, elaineui.format("cur",f.EstMaxPurchase),"",`c2c:${f.EstC2C}`,`budget:${f.EstB}`); //$(".next-button").removeClass("disabled"); }); } } let conv_calc = (function(){ let r = mar.staticvars.startingrate; let EstMaxPurchase = 0; let EstMaxPurchaseRate = 0; let EstC2C = 0; let EstB = 0; let EstBU = 0; let inc = 1.5; let max = mar.staticvars.startingrate; let mortgage = false; let done = false; function get() { return { mortgage : mortgage, EstMaxPurchase : EstMaxPurchase, EstMaxPurchaseRate : EstMaxPurchaseRate, EstC2C : EstC2C, EstB : EstB, EstBU : EstBU, done : done } } let calcnextrate = function() { mar.calculatepart1(0,"conv", { budget : 10000, c2c : goals_target_c2c_high, rate : r, sum : "y", goals_target_value : num(goals_target_value*1.02), fn : function(rates){ //console.warn(rates); let res = rates; console.warn(res); if (res.list.length == 0) { r += 0.5; //0.125; if (r > max) { // makeResultBaloon(`Est. Budget @${EstMaxPurchaseRate} CONV`, elaineui.format("cur",EstMaxPurchase),"",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); return; } calcnextrate(); return; } for (let i=0; i < res.pp.length; i++) { let f = res.list[res.pp[i].i].filters; if (res.list[res.pp[i].i].filters.c2c < goals_target_c2c_high) { //debugger; if (res.pp[i].pp > (goals_target_value*0.9)) { if (EstBU == 0 || res.list[res.pp[i].i].filters.budget < EstBU) { EstMaxPurchase = res.list[res.pp[i].i].filters.budget; EstMaxPurchaseRate = res.list[res.pp[i].i].filters.rate; EstC2C = Math.floor(res.list[res.pp[i].i].filters.c2c); EstBU = res.list[res.pp[i].i].filters.budget EstB = res.pp[i].pp + "/"+(goals_target_c2c_high*0.9)+", ltv:"+res.list[res.pp[i].i].filters.ltv + "R:"+res.list[res.pp[i].i].filters.rate; // mortgage = `budget1_30_conv:${res.list[res.pp[i].i].uuid}`; } } } } if (r < max) { r += inc; //0.5; //0.125; calcnextrate(); return } // makeResultBaloon(`Max Purchase price @${EstMaxPurchaseRate} CONV`, elaineui.format("cur",EstMaxPurchase),"",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); //makeRepairBaloon(goals_target_value, EstMaxPurchase); //setScenario_data("budget_oc_last_price_price",EstMaxPurchase); //setScenario_data("budget_oc_last_price_rate",r); //mar.fakesave(); } }) } return { calcnextrate : calcnextrate, get : get } })() conv_calc.calcnextrate(); let fha_calc = (function(){ let r = mar.staticvars.startingrate; let EstMaxPurchase = 0; let EstMaxPurchaseRate = 0; let EstC2C = 0; let EstB = 0; let EstBU = 0; let inc = 1.5; let max = mar.staticvars.startingrate; let mortgage = false; let done = false; function get() { return { mortgage : mortgage, EstMaxPurchase : EstMaxPurchase, EstMaxPurchaseRate : EstMaxPurchaseRate, EstC2C : EstC2C, EstB : EstB, EstBU : EstBU, done : done } } let calcnextrate = function() { mar.calculatepart1(0,"fha", { budget : 10000, c2c : goals_target_c2c_high, rate : r, sum : "y", goals_target_value : num(goals_target_value*1.02), fn : function(rates){ //console.warn(rates); let res = rates; console.warn(res); if (res.list.length == 0) { r += inc; //0.5; //0.125; if (r > max) { // makeResultBaloon(`Est Budget @${EstMaxPurchaseRate} FHA`, elaineui.format("cur",EstMaxPurchase),"2",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); return; } calcnextrate(); return; } for (let i=0; i < res.pp.length; i++) { if (res.list[res.pp[i].i].filters.c2c < goals_target_c2c_high) { if (res.pp[i].pp > (goals_target_value*0.9)) { if (EstBU == 0 || res.list[res.pp[i].i].filters.budget < EstBU) { EstMaxPurchase = res.list[res.pp[i].i].filters.budget; EstMaxPurchaseRate = res.list[res.pp[i].i].filters.rate; EstC2C = Math.floor(res.list[res.pp[i].i].filters.c2c); EstBU = res.list[res.pp[i].i].filters.budget EstB = res.pp[i].pp + ", ltv:"+res.list[res.pp[i].i].filters.ltv + "R:"+res.list[res.pp[i].i].filters.rate; } } } } if (r < max) { r += inc; //0.5; //0.125; calcnextrate(); return } // makeResultBaloon(`Max Purchase price @${EstMaxPurchaseRate} FHA`, elaineui.format("cur",EstMaxPurchase),"2",`c2c:${EstC2C}`,`budget:${EstB}`); done = true; end_calc(); //makeRepairBaloon(goals_target_value, EstMaxPurchase); //setScenario_data("budget_oc_last_price_price",EstMaxPurchase); //setScenario_data("budget_oc_last_price_rate",r); //mar.fakesave(); } }) } return { calcnextrate : calcnextrate, get : get } })() fha_calc.calcnextrate(); } // nextcalc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "estimate" } })(); /* file /ui/app/js/pages.lox.js , last updated 1709195970246*/ mar.pg["lox-thanks"] = (function(){ var html = ""; function render(pg, localopts) { mar.pg_accesscontrollerfn = function() { return "open"; } let h = ""; h += frm.htitle("Application saved").render(); h += frm.elaine("Thank you for your hard work! Elaine, our digital assistant, will guide you to the finish line.
    ","").render(); h += uihelpers.cbuttonbar("Logout",frm.addfunction(function(){ mvc.set("_2FA",false, function(){ mvc.set("token","", function(){ mvc.setEntryPageHash("#lox"); mvc.go("#logged-out"); }); }); }),"Back",frm.addfunction(function(){ mvc.go("#lox"); }),"mar.help()"); $("#loxdiv").html(h); h = Mustache.render(h,localopts); let or = function(){ } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); /** * IF (DISPLAY === "EVENT") * IF (DISPLAY === "NEED") * IF (DISPLAY === "LOXLIST") * define * mar.tmp_get_inbox_counters * mar.tmp_loxrefresh // main redisplay * mar.tmp_get_condition_counters * mar.tmp_get_inbox_counters * then * call mar.tmp_loxrefresh() * ENDIF */ mar.pg["lox"] = (function(){ var html = ""; function render(pg, localopts) { mar.pg_accesscontrollerfn = function() { return "open"; } let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; try { var na = getApplicantsNames_v2(applicantnum).Name; } catch (E) { var na = "no name"; } let hh = ""; hh += frm.htitle("Letter of explanation").render(); let loxid = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let action = ("p2" in localopts && localopts.p2 != "") ? localopts.p2 : ""; mar.fromhomework(false); //// $.getJSON('https://api.ipify.org?format=json', function(data){ mar.ip = data.ip; }); mar.questionsLox = []; mar.questionnum = 0; mar.initform = function() { var qs = $(".qs"); mar.questionsLox = []; mar.questionnum = 0; for (var i=0; i < qs.length; i++) { let q = $(qs[i]).find(".q").html(); let a = $(qs[i]).find(".a").html(); let jj = $(qs[i]).data("id") mar.questionsLox.push({ q : q, a : a, i : jj, elm : qs[i] }); } mar.nextquestion(); } mar.loxformat = function(S) { var converter = new showdown.Converter() S = converter.makeHtml(S); //S = S.replace(/\n/g, "
    ") return S; } mar.nextquestion = function() { if (mar.questionnum == mar.questionsLox.length) return false; var question = mar.questionsLox[mar.questionnum]; let oquestion = loxjs.questions[question.i]; var frM = ""; frM += "
    " + ""+ "
    " + " "+localopts.Elaine+" "+mar.loxformat(question.q)+"" + ""+question.q+"" + "
    " + "
    "; var cls = ("optional" in oquestion && oquestion.optional == "y") ? " lox-optional" : ""; if ("type" in oquestion && oquestion.type == "text") { frM += "
    "; } else { frM += "
    "; } if ("hide" in oquestion && oquestion.hide == "y") { frM = "
    "; $(".questions").append(frM); mar.questionnum++; return mar.nextquestion(); } if ("admin" in oquestion && oquestion.admin == "y") { frM = "
    "; $(".questions").append(frM); mar.questionnum++; return mar.nextquestion(); } $(".questions").append(frM); $(".xhuman").Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false }); $(".xhuman").removeClass("xhuman") mar.questionnum++; return true; } mar.tmp_iframe_signing = (function() { let url = ""; function open(URL, fn) { if (typeof URL === "string") { url = URL; } let h = ""; h += ``; // h += ``; openSlider(1, "", h , function(){ if (fn) fn(); $.get(`/api/needs_server/reload/${mar.ID}`, function(){}); }) } function close() { $.get(`/api/needs_server/reload/${mar.ID}`, function(){}); closeSlider(); } function e(a,evt) { let iframe = $("#signing-iframe")[0]; console.error("iframe event",a,evt); console.error("iframe src",iframe.contentWindow.location.href); if (a === "L") { let _h = iframe.contentWindow.location.href; if (_h.indexOf("durunner.ai") > -1 || _h.indexOf("usmtg.app") > -1 || _h.indexOf(location.host) > -1) { let href = iframe.contentWindow.location.href; $("#signing-iframe").remove(); mvc.go("#lox"); $.get(`/api/needs_server/reload/${mar.ID}`, function(){}); close(); } } } return { open : open, close : close, e : e, ___id : "signing iframe" } })(); mar.docusign = function() { var qa = $(".lox-qa"); let paragraphs = [] //paragraphs.push("h2:Pertaining to application "+mar.ID); paragraphs.push(`small:${getApplicantsNames_v2(0).Fullname}\n${getApplicant_current_address_for_esign(0)}`) paragraphs.push(`tiny:ref:app-${mar.ID}/loe-1111`) for (let i=0; i < qa.length; i++) { let elm = qa[i]; if ($(elm).hasClass("lox-q")) { paragraphs.push("q:"+$(elm).html()) } if ($(elm).hasClass("lox-a")) { let ans = $(elm).val(); if (ans.trim() == "") { if ($(elm).hasClass("lox-optional") == false) { swal("You left the answer to question (n) empty. We need you to complete all the questions.") return; } } paragraphs.push("a:"+$(elm).val()) } } if (mar.nextquestion()) return; $("#continue-and-docusign-button").text("Continue and E-Sign") let questions = []; if ($("#loxtype").val() != "simple") { questions = loxjs.questions; for (let i=0; i < questions.length; i++) { if ($("#Q"+i).length > 0) { questions[i].data_original = questions[i].data; if ($("#Q"+i).length > 0) { questions[i].data = $("#Q"+i).val(); } } } } /* * paragraphs : ["","","",""] * * filename : file name * * loxid : lox id row number * * appid : appid * * sign_by : list of people to sign the evential doc * e:email,n:J carter|e:email,n:S Carter * */ var ob = { paragraphs : paragraphs, filename : $("#filename").val(), loxid : $("#loxid").val(), appid : $("#appid").val(), sign_by : $("#sign_by").val(), loxtype : $("#loxtype").val(), questions : questions, embedded : "y", ip : mar.ip, returnUrl : location.href.split("#")[0]+"#lox" } //swal(JSON.stringify(ob)); swal("Submitting answers to E-Sign",{ buttons : { ok : null, cancel : null},closeOnClickOutside: false,closeOnClickEsc: false}); mar.socket.send_and_receive("lox-docusign",ob, function(messages){ //swal("Signing - getting url " + JSON.stringify(messages)); console.warn("lox-docusign",messages); if ("data" in messages && "url" in messages.data) { mar.tmp_iframe_signing.open(messages.data.url, function(){ swal.close(); }) // swal("Redirecting."); // location.href = messages.data.url; } },20000) } //// hh = "
    "+frm.htitle("Letter of explanation").render()+"
    "; hh += "
    "; hh += "
    "; hh += ""; // hh += ""; let homework_summary = function(logo, title, count, countof, buttontext, colour) { var h = ""; h += "
    "; h += "
    "+logo+"
    "; h += "
    "+title+"
    "; h += "
    "+count+"/"+countof+"
    "; h += "
    "+buttontext+"
    "; h += "
    "; return h; } let homework_item = function(logo, title, type, colour, status) { var h = ""; h += "
    "; h += "
    "+logo+"
    "; h += "
    "+title+"
    "; h += "
    "+status+"
    "; h += "
    "; h += "
    "; return h; } hh = Mustache.render(hh,localopts); pg.hh = hh; pg.render = true; pg.title = "Home"; pg.onrender = function() { if (MAR.appnav.loanWasImportedAndNotVerified() === true) { mvc.goto("#import-encompass-upnext-submit"); return; } let UPNEXT = getScenario_data("__lox_upnext_passed","N"); if (UPNEXT !== "Y") { mvc.goto("#up-next-lox"); return; } /* * if LOI then ask before doing this and save it in a session cookie I think * */ if (getScenario_data("__application_submitted","") !== "Y") { if (mar.WE_ARE_FROM_LOI === true) { } else { mar.answers._events = ["application:submitted"]; setScenario_data("__application_submitted","Y"); mar.fakesave(); } } mar.state.before_employer = "#lox"; let DISPLAY = ""; if (location.href.indexOf("event=") > -1) DISPLAY = "EVENT"; else if (action.startsWith("need_")) DISPLAY = "NEED"; else if (!loxid || loxid == "" || action.startsWith("type_")) DISPLAY = "LOXLIST"; if (DISPLAY === "EVENT") { if (location.href.indexOf("event=signing_complete") > -1) { var h = frm.elaine("Thank you for E-Signing the Letter of explanation. The signed document will be added to your file.
    ","").render(); h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ mvc.go("#lox...#"+mar.now()); }),"Back",frm.addfunction(function(){ mvc.go("#lox...#"+mar.now()); }),"mar.help()"); $("#loxdiv").html(h); } else if (location.href.indexOf("event=cancel") > -1) { var h = frm.elaine("You can return to the E-Sign experience when you have time.


    ","").render(); h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ mvc.go("#lox...#"+mar.now()); }),"Back",frm.addfunction(function(){ mvc.go("#lox...#"+mar.now()); }),"mar.help()"); $("#loxdiv").html(h); } else { var h = frm.elaine("You can return to the E-Sign experience when you have time.


    ","").render(); h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ mvc.go("#lox...#"+mar.now()); }),"Back",frm.addfunction(function(){ mvc.go("#lox...#"+mar.now()); }),"mar.help()"); $("#loxdiv").html(h); } } else if (DISPLAY === "NEED") { $("#loxdivtitle").html(frm.htitle("Upload").render()); hh = ""; hh += frm.elaine("Upload documents to satisfy the requireements.","").render(); hh += `
    `; hh += `
    `; hh += `
    `; hh += `
    `; // status hh += `
    `; // topbar // docFolderDynamicContent hh += `
    `; hh += `
    `; // docFolderDynamicContent // docFolderBtmArea hh += `
    `; hh += `
    `; // docFolderBtmArea hh += `
    `; // docFolderHolder hh += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ mvc.go("#lox"); }),"cancel",frm.addfunction(function(){ mvc.go("#lox"); }),"mar.help()"); hh = Mustache.render(hh,localopts); $("#loxdiv").html(hh); let needid = action.substring(5); let appid = mar.ID; let randomClass = "xx-randomClass"; let link = `/cfc/needslist/get/${appid}/${needid}`; let $docFolderHolder = $("#docFolderHolder"); if (!$docFolderHolder.data("randomclass")) { $docFolderHolder.data("randomclass",randomClass); $docFolderHolder.addClass(randomClass); } let $docFolderTopBar = $docFolderHolder.find(".docFolderTopBar"); let $docFolderStatus = $docFolderTopBar.find(".docFolderStatus"); let $docFolderBtmArea = $docFolderHolder.find(".docFolderBtmArea"); let $docFolderDynamicContent = $docFolderHolder.find(".docFolderDynamicContent"); mar.openCloseDocFolderDoneFn = function(elm,func) { let NEED = $elm.data("need"); let LINK = $elm.data("link"); let _rc = $elm.data("randomclass"); $.get(LINK+"?src=app&action=submit", function() { let $_rc = $("."+_rc); if ($_rc.length > 0) { // load_content("refresh"); mar.openCloseDocFolderFn($_rc,"refresh"); } }); } mar.openCloseDocFolderUploadMoreFn = function(elm,func) { let NEED = $elm.data("need"); let LINK = $elm.data("link"); let _rc = $elm.data("randomclass"); $.get(LINK+"?src=app&action=client_upload_more", function() { let $_rc = $("."+_rc); if ($_rc.length > 0) { // load_content("refresh"); mar.openCloseDocFolderFn($_rc,"refresh"); } }); } mar.openCloseDocFolderFn = function(elm,func) { load_content(func) } let load_content = function(func) { $docFolderBtmArea.LoadingOverlay("show"); $.get(link, function(r) { var TITLE = r[1]; var BODY = "
    "+JSON.stringify(r,null,4)+"
    "; var TITLE2 = "bla"; var BODY2 = "bla bla"; var _title = "UPLOAD"; var _cls = ""; // var pages = r[12] var pages = r[6].exdata; var type = r[5]; var NEED = r[2]; var NEEDDATA = r[10]; var DOC = r[26] var INSTRUCTIONS = false; if (DOC && "instructions" in DOC && DOC.instructions.trim().length > 0) { INSTRUCTIONS = DOC.instructions.trim(); if (INSTRUCTIONS.startsWith("#")) { INSTRUCTIONS = INSTRUCTIONS.substring(1) } else { INSTRUCTIONS = false; } } if (r[1].split("|").length > 1) { INSTRUCTIONS = r[1].split("|")[1] } $("#loxdivtitle").html(frm.htitle(TITLE).render()); h = ""; if (pages.length > 0 || type == "general") { h += "
    "; // h += "
    "+$("#svg_warning_icon").html()+"
    "+TITLE+"
    "+BODY+"
    "; let showUpload = false; let showDone = false; let titleStatus = r[6].hwstatus; let titleMessage = r[6].hwtitle; if (INSTRUCTIONS !== false) { h += "
    "+ $("#svg_connect_payroll_homework").html()+ "
    "+INSTRUCTIONS+"
    "; h += "
    "; h += "
    "; } /** * this is the preview images * * which also have a "waiting" function on them * */ if (pages.length > 0) { let CanDelete = (r[14] == "" || r[14] == "incomplete" || r[14] == "rejected") ? "Y" : "N"; let H = ""; H += "
    "+ $("#svg_connect_payroll_homework").html()+ "
    You have uploaded the following pages:
    "; // "
    You have uploaded the following pages "+r[7]+"/"+r[14]+"
    "; //H += link; for (let pi=0; pi < pages.length; pi++) { // let pages_split_up = pages[pi].split(":"); let pages_split_up = pages[pi]; let _sty = ""; let _status = ""; let _cls = ""; let _status_reason = ""; let _rot = ""; let _crot = ""; if (pages_split_up.length > 1 && pages_split_up[1] != "0") { //_sty += "transform:rotate("+pages_split_up[1]+"deg);"; _rot = ",r"+pages_split_up[1]; _crot = "&rot="+pages_split_up[1]; } if (pages_split_up.length > 2 && pages_split_up[2] == "rejected") { _sty += "opacity:0.2;"; _status = pages_split_up[2]; _cls = "img_rejected_stripe"; } if (pages_split_up.length > 3 && pages_split_up[3] != "") { _status_reason = pages_split_up[3]; } // let _placeholder = "https://www.wakesmiles.org/wp-content/uploads/2017/10/placeholder-2.png"; let _placeholder = "/_ui/db2/images/placeholder.png"; H += "" + "" + ""; } H += "
    "; H += "
    " if (r[14] == "" || r[14] == "new") { if (r[10] && "incompletereason" in r[10] && r[10].incompletereason != "") { h += "
    "+ $("#svg_connect_payroll_homework").html()+ "
    Attention is required. : "+r[10].incompletereason+"
    "; // message here h += "
    "; h += "
    "; } h += H; // h += "
    "+ // $("#svg_connect_payroll_homework").html()+ // "
    If you have uploaded all the pages click HERE and these documents will be submitted.
    "; // h += "
    "; showUpload = true; showDone = true; } if (r[14] == "incomplete") { h += "
    "+ $("#svg_connect_payroll_homework").html()+ "
    Attention is required. : "+r[10].incompletereason+"
    "; // message here h += "
    "; h += "
    "; h += H; showUpload = true; showDone = true; } if (r[14] == "rejected") { h += "
    "+ $("#svg_connect_payroll_homework").html()+ "
    Attention is required. : "+r[10].incompletereason+"
    "; // message here h += "
    "; h += "
    "; h += H; showUpload = true; showDone = true; } if (r[14] == "received") { if (r[10] && "incompletereason" in r[10] && r[10].incompletereason != "") { h += "
    "+ $("#svg_connect_payroll_homework").html()+ "
    Attention is required. : "+r[10].incompletereason+"
    "; // message here h += "
    "; h += "
    "; } h += H; h += "
    "+ $("#svg_connect_payroll_homework").html()+ "
    The documents have been recieved and will be processed.
    "; h += "
    "; } if (r[14] == "cleared") { h += "
    "+ $("#svg_connect_payroll_homework").html()+ // "
    The condition have been cleared and consists of the following individual pages :
    "; "
    Reviewed pages :
    "; h += "
    "; let doc = r[19]; if (doc) { if ("json" in doc && "pages" in doc.json) { pages = doc.json.pages.split("|"); h += "
    "; for (let pi=0; pi < pages.length; pi++) { let pages_split_up = pages[pi].split(":"); let _sty = ""; if (pages_split_up.length > 1 && pages_split_up[1] != "0") { _sty += "transform:rotate("+pages_split_up[1]+"deg);"; } // h += "
    "+pi+":"+ pages[pi] + "
    "; h += ""; } h += "
    "; } } let pdf301 = r[22]; let pdfinline = r[24]; if (pdf301 && pdf301 != "") { // h += "
    "; // h += "
    "; // h += "
    "+ // $("#svg_connect_payroll_homework").html()+ // "
    This is the PDF which will be submitted to underwriting , click on the page below to view / or download a copy for your own records.
    "; // h += "
    "; // if (mar.state.desktop == false) { // h += "
    " //// h += "" // h += "
    "; // h += "
    Download
    "; // } else { // h += "
    " //// h += "" // // h += "
    "; // h += "
    Download
    "; // // // } } } } else { if (r[10] && "incompletereason" in r[10] && r[10].incompletereason != "") { h += "
    "+ $("#svg_connect_payroll_homework").html()+ "
    Attention is required. : "+r[10].incompletereason+"
    "; // message here h += "
    "; h += "
    "; } showUpload = true; } if (showUpload) { h += "
    "; if (showDone) { h += ""; } $docFolderBtmArea.LoadingOverlay("hide",true); $docFolderBtmArea.html(h); //mar.filepupload.upload($docFolderBtmArea.find(".drop")); $docFolderTopBar.removeClass("docFolderTopBarStatus_1"); $docFolderTopBar.removeClass("docFolderTopBarStatus_2"); $docFolderTopBar.removeClass("docFolderTopBarStatus_3"); $docFolderTopBar.removeClass("docFolderTopBarStatus_4"); $docFolderTopBar.addClass("docFolderTopBarStatus_"+titleStatus); $docFolderHolder.removeClass("docFolderStatus_1"); $docFolderHolder.removeClass("docFolderStatus_2"); $docFolderHolder.removeClass("docFolderStatus_3"); $docFolderHolder.removeClass("docFolderStatus_4"); $docFolderHolder.addClass("docFolderStatus_"+titleStatus); $docFolderStatus.html(titleMessage) $docFolderHolder.prop("data-order",titleStatus) return; } else if (pages.length > 0 || type.startsWith("action") ) { h += "
    "; h += type.split(":")[1]; h += "
    "; } else { /** * this is the real paystubs area */ h += "
    "; h += "
    "; h += "
    "; h += "
    "; h +="
    ";//end docFolderSubBtmArea_row h += "
    "; h += "
    "; h += "
    "; h +="
    ";//end docFolderSubBtmArea_row h +="
    ";//end docFolderSubBtmArea h += "
    "+_title+"
    "; $docFolderBtmArea.LoadingOverlay("hide",true); $docFolderBtmArea.html(h); //mar.filepupload.upload($docFolderBtmArea.find(".drop")); $docFolderTopBar.removeClass("docFolderTopBarStatus_1"); $docFolderTopBar.removeClass("docFolderTopBarStatus_2"); $docFolderTopBar.removeClass("docFolderTopBarStatus_3"); $docFolderTopBar.removeClass("docFolderTopBarStatus_4"); $docFolderTopBar.addClass("docFolderTopBarStatus_"+titleStatus); $docFolderStatus.html(titleMessage) $docFolderHolder.removeClass("docFolderStatus_1"); $docFolderHolder.removeClass("docFolderStatus_2"); $docFolderHolder.removeClass("docFolderStatus_3"); $docFolderHolder.removeClass("docFolderStatus_4"); $docFolderHolder.addClass("docFolderStatus_"+titleStatus); $docFolderHolder.prop("data-order",titleStatus) return; } $docFolderBtmArea.LoadingOverlay("hide",true); $docFolderBtmArea.html(h); }); } load_content(); mar.filepupload.upload(); mar.tmp_lox_activate_drag_on_conditions(); } else if (DISPLAY === "LOXLIST") { /** * this is the main area for the list * * * mar.tmp_loxrefresh(); gets the new list and refreshes the list * */ $("#loxdivtitle").html(frm.htitle("Homework ").render()); // here if (getScenario_data("__application_submitted","") !== "Y") { if (mar.WE_ARE_FROM_LOI === true) { mar.tmp_submit_and_lock = function() { elaineui.swalprompt({ // title : "Encompass Linked field", txt : `Would you like to Submit this application? The client will be prevented from changing the application.`, ok : "Submit", okfn : function(opts) { if (MAR.appnav.loanWasNotImportedAndNotSubmitted() === true) { mar.answers._events = ["encompass:submit_new_application","application:submitted"]; setScenario_data("__application_submitted","Y"); } if (getScenario_data("__application_submitted","") !== "Y") { mar.answers._events = ["application:submitted"]; setScenario_data("__application_submitted","Y"); } setScenario_data("__lox_upnext_passed","Y"); setScenario_data("__lox_upnext_passed","Y"); mar.fakesave(function(){ mvc.go("#lox"); }) }, cancel : "Cancel", cls : "middleInfoPopup", cancelfn : function() { }, opts : { closeOnClickOutside : false, closeOnEsc : false }, reverse : false }); } $("#loxdivwarning").html(`
    This loan is not submitted click to submit and lock
    `); } } $("#loxdiv").html("
    "+elaineui.loadinghtml+"
    "); mar.tmp_get_condition_counters = function(PREVENT_LOXREFRESH) { if (arguments.length < 1) PREVENT_LOXREFRESH = false; mar.socket.send_and_receive("condition-counters-get",{ appid : mar.ID }, function(retval){ let da = retval.data; if (da.length < 9) return; $("#loxdiv-tabs .x-homework .x-counter").html(` (${num(da[6])+num(da[8])})`); $("#loxdiv-tabs .x-pending .x-counter").html(` (${da[7]})`); $("#loxdiv-tabs .x-cleared .x-counter").html(` (${da[9]})`); let tot = (num(da[6])+num(da[7])+num(da[8])+num(da[9])); if (tot > 0) { mar.tmp_set_bubble_text(`To get your loan approved we have a total of ${tot} things to do below. ${num(da[6])+num(da[8])} things are outstanding. ${da[7]} are in review by the loan officer and ${da[9]} are in review by the underwriter.`) } /** * this will always do the loxrefresh so I commented out the part below here */ mar.tmp_get_inbox_counters(PREVENT_LOXREFRESH); // let CONDITION_OPEN = ($(".done_and_close").length > 0 || $(".docFolderHolder .dropmehere").length > 0 || $(".open-upload-button:visible").length > 0); //// let CONDITION_OPEN = ($(".done_and_close").length > 0); // if (PREVENT_LOXREFRESH === false && CONDITION_OPEN === false) { // console.error("LOX", "refresh",1) // mar.tmp_loxrefresh(); // } else { // console.error("LOX", "stop",1,PREVENT_LOXREFRESH,CONDITION_OPEN) // } }); } mar.tmp_get_inbox_counters = function(PREVENT_LOXREFRESH) { if (arguments.length < 1) PREVENT_LOXREFRESH = false; mar.socket.send_and_receive("inbox-get-count",{ appid : mar.ID }, function(retval){ let da = retval.data; let drop_txt = `Drop any file here, or click on any condition to upload directly.`; if (mar.state.phone === true) { drop_txt = `Click here to upload to the inbox, or click on any condition to upload directly.`; } function pages(n) { if (num(n) === 1) return `page`; return `pages`; } if (num(da) > 0) { drop_txt = `${drop_txt}
    You uploaded ${da} ${pages(da)}.
    `; } if (mar.state.phone === true) { $(".dropmehere.inbox").html(`Click here to upload to the inbox, or click on any condition to upload directly.
    You uploaded ${da} ${pages(da)}.
    `); } else { $(".dropmehere.inbox").html(`Drop any file here, or click on any condition to upload directly.
    You uploaded ${da} ${pages(da)}.
    `); } let CONDITION_OPEN = ($(".done_and_close").length > 0 || $(".docFolderHolder .dropmehere").length > 0 || $(".open-upload-button:visible").length > 0); // let CONDITION_OPEN = ($(".done_and_close").length > 0); CONDITION_OPEN = false; if (PREVENT_LOXREFRESH === false && CONDITION_OPEN === false) { console.error("LOX", "refresh",2) mar.tmp_loxrefresh(); } else { console.error("LOX", "stop",2,PREVENT_LOXREFRESH,CONDITION_OPEN) } }); } mar.tmp_lox_preventDefaults = function(e) { e.preventDefault() e.stopPropagation() } mar.tmp_lox_activate_drag_on_conditions = function() { let docFolderHolders = $("div.docFolderHolder"); let zone = false; let need = false; function highlight(e) { let t = $(e.target); let c = t.closest('.docFolderHolder'); // console.error("OV ",t,c, zone) if (c.length > 0) { if (zone !== c[0]) { if (zone !== false) zone.classList.remove('highlight'); zone = c[0]; zone.classList.add('highlight'); // console.error("zone",zone) } } // if (t.closest('.docFolderHolder').length === 0) { // zone = t; // zone[0].classList.add('highlight') // } // if (t.hasClass(".docFolderHolder")) { // e.target.classList.add('highlight'); // } } function unhighlight(e) { let t = $(e.target); let c = t.closest('.docFolderHolder'); // console.error("UN ",t,c, zone) if (c.length == 0 || (zone !== false && c[0] === zone)) { // console.error("zone MIN",zone) zone.classList.remove('highlight'); zone = false; } // if (t.closest('.docFolderHolder').length === 0) { // zone[0].classList.remove('highlight') // zone = false; // } // e.target.classList.remove('highlight'); } function handleDrop(e) { let t = $(e.target); let c = t.closest('.docFolderHolder'); console.error("DROP",t,c, zone); mar.openCloseDocFolderFn($(c)[0],"refresh") let n = $(c).data("needb64"); if (typeof n === "string") n = atob(n); need = (typeof n === "string") ? n : false; if (need === false) return; // if (zone === false) return; let dt = e.dataTransfer let files = dt.files handleFiles(files) } function handleFiles(files) { ([...files]).forEach(uploadFile) } function uploadFile(file){ let bucket = "unchecked"; let _needlink = need; let _nl = (_needlink && _needlink != "") ? "/need/"+btoa(_needlink) : ""; let _rc = $(zone).data("randomclass"); let url = `/api/upload/${mar.ID}/dW5jaGVja2Vk${_nl}`; let formData = new FormData() formData.append('file', file) fetch(url, { method: 'POST', body: formData }) .then(() => { /* Done. Inform the user */ //debugger; }) .catch(() => { /* Error. Inform the user */ //debugger; }) } ;['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { $("body")[0].addEventListener(eventName, mar.tmp_lox_preventDefaults, false); }); for (let i=0; i < docFolderHolders.length; i++) { let div = docFolderHolders[i]; let $div = $(div); if ($div.hasClass("handled") === false) { $div.addClass("handled"); ;['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { div.addEventListener(eventName, mar.tmp_lox_preventDefaults, false); }); ;['dragenter', 'dragover'].forEach(eventName => { div.addEventListener(eventName, highlight, false) }); ;['dragleave', 'drop'].forEach(eventName => { div.addEventListener(eventName, unhighlight, false) }); div.addEventListener('drop', handleDrop, false) } } } mar.tmp_loxrefresh = function(){ if ($("#loxdiv").length === 0) return; if ($("#loxdiv .questions").length > 0) return; mar.socket.send_and_receive("lox-list",{ appid : mar.ID }, function(retval){ console.warn(retval); mar.socket.send_and_receive("application-needs-get",{ id : mar.ID, cache : "Y", view : "homework" }, function(needs_retval){ var h = ""; //h += frm.htitle("Homework").render(); h += frm.elaine("Click on each item to begin your homework.","").render(); h += "
    "; mar.tmp_send_link_next = function() { let $elm = $(".elaine-bubble-text-2"); $elm.removeClass("x-step1"); mar.tmp_set_bubble2_text("sent"); } mar.tmp_send_link_prev = function() { let $elm = $(".elaine-bubble-text-2"); $elm.removeClass("x-step1"); mar.tmp_set_bubble2_text(); } mar.tmp_send_link = function() { let $elm = $(".elaine-bubble-text-2"); $elm.addClass("x-step1"); let h = ""; h += `Set a pincode for your application and then click send`; h += `[send]`; h += `[cancel]`; $(".elaine-bubble-text-2").html(h); } mar.tmp_set_bubble2_text = function(h) { let $elm = $(".elaine-bubble-text-2"); if ($elm.hasClass("x-step1")) return; if (typeof h === "string") { $elm.html(h); return; } if (mar.state.desktop) { $elm.html(`Here is some more dynamic content for DESKTOP`); } else { $elm.html(`Congratulation on completing the loan application! Please hop on your PC and check {}. I just send you a link to your loan-portal.`+ ` To prepare for the loan approval, simply Drag and Drop the documents {loan officer} needs onto each condition.`+ ` Click [here] to send the application link to your desktop browser.`); } } mar.tmp_send_app_link = function() { $.get(`/api/chatbot/appUploadLink/${mar.ID}`, function(r){ console.warn(r); debugger; swal("A link has been sent"); }) } mar.tmp_set_bubble_text = function() { let $elm = $(".elaine-bubble-text"); let $elm2 = $(".elaine-bubble-text-2"); let h = ""; let h2 = ""; if (mar.WE_ARE_FROM_LOI) { h = `Simply Drag and Drop the requested documents onto each condition.

    `; h2 = ""; } else if (mar.state.desktop === false) { h += `Take or upload images right from your mobile device, or use Dropbox (beta).

    Please click “Email App link” and hop on your PC to open this application on your regular browser, so you can easily "drag and drop" the requested docs in the buckets for the loan officer to review.

    `; h2 += ``; } else { h += `Simply Drag and Drop the requested documents onto each condition, so we can work on your loan approval!

    `; } let _assets = getAssets_v2(); let _warnings = "" if (_assets.has_unverified_items === true) { _warnings += `
    Click here to verify information on some updated assets.
    `; } if (_warnings !== "") { h2 += frm.inline_warning_red(_warnings); } $elm.html(h); $elm2.html(h2); return; $(".elaine-bubble-text").html(h); mar.tmp_set_bubble2_text(); } h += ""; h += ("
    " + "
    Homework
    " + "
    Pending
    " + "
    Cleared
    " + "
    " + ""+ "
    " + "
    "); if (mar.state.phone === true) { h += "
    Click here to upload to the inbox, or click on any condition to upload directly.
    "; } else { h += "
    Drop any file here, or click on any condition to upload directly.
    "; } var ar = [{title:na+"'s paystubs", docType:'paystubs', status:3}, {title:na+"'s Tax Returns 2017", docType:'tax returns', year: '2017'}, {title:na+"'s Tax Returns 2018", docType:'tax returns', year: '2018'}, {title:na+"'s W-2's 2017", docType:'w2', year: '2017'}, {title:na+"'s W-2's 2018", docType:'w2', year: '2018', status:2}, {title:na+"'s Bank of America #4650", docType:'bank'}, {title:na+"'s Bank of America #4995", docType:'bank', status:4} ]; var ar = [{title:na+"'s paystubs", docType:'paystubs', status:3}] ar = []; let homework_line_count = 0; let needs_to_match_as_parent_for_lox = {}; var df; let section_unfilled = function(Incomes, page_hash, order="") { ar.push({ title : `One or more ${Incomes} need to be validated`, need : ``, shorttitle : `<>Priority Actions`, docType : `action`, action : ``, // longtextTitle : `Some ${Incomes} need to be checked by you.

    Normally this is because an update has been made by the Loan officer and they need you to check it

    `, longtextTitle : `Normally this is because an update has been made by the Loan officer and they need you to check it.

    You will see the item(s) marked with a warning triangle.

    `, nstatus : `BLA NSTATUS`, longtext : "
    ", secondarytextTitle : " ", secondarytext : "
    ", lox_allow_action : false, status : 1, hwtitle : `BLA HW title`, meta : {}, dataLink : ``, needid : `top1/${order}`, icon : false, obj : {} }); } let tst = false; if (tst || MAR.income.getNextUnverifiedItem() !== false) { section_unfilled(`Incomes`, `#income-how.0`,0); } if (tst || MAR.assets.getNextUnverifiedItem() !== false) { section_unfilled(`Assets`, `#assets-choice`,1); } if (tst || MAR.liabilities.getNextUnverifiedItem_except_mortgages() !== false) { section_unfilled(`Liabilities`, `#liabilities-home`,2); } if (tst || MAR.reo.getNextUnverifiedItem() !== false) { section_unfilled(`Properties`, `#reo-home`,3); } if (tst || reo_has_any_unsaved_changes() === true) { ar.push({ title : `Un-saved changes to properties`, need : ``, shorttitle : `<>Priority Actions`, docType : `action`, action : ``, // longtextTitle : `Some ${Incomes} need to be checked by you.

    Normally this is because an update has been made by the Loan officer and they need you to check it

    `, longtextTitle : `Normally this is because you exited the application in the middle of making changed to your properties.

    You will see the item(s) marked with a warning triangle.

    `, nstatus : `BLA NSTATUS`, longtext : "
    ", secondarytextTitle : " ", secondarytext : "
    ", lox_allow_action : false, status : 1, hwtitle : `BLA HW title`, meta : {}, dataLink : ``, needid : `top1/4`, icon : false, obj : {} }); } if("n" in needs_retval) { for (let i=0; i < needs_retval.n.length; i++) { try { let _need = needs_retval.n[i]; // if (_need[0].indexOf("/handmade/") > -1) debugger; // if (_need[0].indexOf("EXECUTEDPURCHASECONTRACT") > -1) debugger; // if (_need[0].indexOf("4506T-PACK") > -1) debugger; // if (_need[1].indexOf("4506T") > -1) debugger; // if (_need[1].indexOf("to be ma") > -1) debugger; // if (_need[0].indexOf("uw_condition") > -1) debugger; // if (_need[0].indexOf("SHORTSALE") > -1) debugger; let need_part0 = _need[2].split("|")[0]; needs_to_match_as_parent_for_lox[need_part0] = false; // process override let meta = MAR.getOpt(_need[6], "meta", {}); let Hwstatus = _need[6].hwstatus; //Hwstatus = _need[6].meta.hwstatus; /* this would include internal items */ if (Hwstatus < 0) continue; // -1 is internal and to be excluded let RET = function(s1,s2) { //console.error(`LOX RET returning false for [${s1}] on [${s2}]`); return false; } let track = false; // track = (need_part0.indexOf("DISC-BPTCY-DISCHARGE-LOX") > -1); // track = (need_part0.indexOf("1619504162366") > -1); let IS_A_MATCH = (function(){ if (action == "type_done") { if (Hwstatus != 4) return RET("n4", need_part0); } else if (action == "type_pending") { if (Hwstatus != 2) return RET("n2", need_part0); } else { if (Hwstatus == 4) return RET("4", need_part0); if (Hwstatus == 2) return RET("2", need_part0); if (Hwstatus == 1) { if (_need[8].length > 4 && _need[8][4] != false) { if (_need[10] !== false && "manualOverride" in _need[10] && _need[10].manualOverride == "y") { //we are overriding the link } else { return RET("last", need_part0); // skip connected items in the homework page } } } } return true; })(); needs_to_match_as_parent_for_lox[need_part0] = true; let xtra = ""; //`[${_need[6].meta.pageslox_display}] [${_need[6].hwstatus}] [${_need[6].meta.pageslox_display_types.join(",")}]` let doctype = _need[5].split(":")[0]; if (_need[6].display_type === "Docusign documents") doctype = "lox"; if (_need[6].display_type === "E-Sign documents") doctype = "lox"; if (track) console.error(`LOX TRACK doctype ${doctype}`); if (doctype === "lox") { let _lox = _need[6].meta.lox; let _cname = MAR.getOpt(_need[6], "meta.cname", ""); let _client_name = MAR.getOpt(_need[6], "meta.client_title", ""); let _loxstatus = Hwstatus; let _nstatus = ""; let _loxbutton = ""; let _allow_action = true; let _loxparent = MAR.getOpt(_need[6], "n2n_rev", ""); var h1 = ""; if (_loxstatus === 2) { // h1 += ""; _loxbutton = ["Review the form","document.location.href=\"#lox."+_lox.id+"\";"]; _allow_action = false; _nstatus = "In process"; } else if (_loxstatus === 4) { // h1 += ""; _loxbutton = ["Review the form","document.location.href=\"#lox."+_lox.id+"\";"]; _nstatus = "signed"; _allow_action = false; } else { // h1 += ""; _loxbutton = ["E-Sign here","document.location.href=\"#lox."+_lox.id+"\";"]; _nstatus = "new"; _allow_action = true; } let lx = { // title : _need[1].split("|")[0] + xtra + "/"+_need[6].hwstatus_00 + "/"+_need[6].hwstatus_01 + "/"+_need[6].hwstatus + "/"+_need[6].display_type, title : _need[1].split("|")[0] + xtra , docType :'lox', need : _need[2], shorttitle : _need[6].meta.sec, // _need[6].display_sec.toLowerCase().trim(), //_need[4], longtextTitle : (_allow_action === false) ? "The Signed letter is in process" : "Chose Upload, or simply E-Sign this letter of explanation ", //
    '", longtext : " ", //"Current status : "+ _lox.status+"
    ", secondarytextTitle : h1, secondarytext : "
    ", year : '2017', status : _loxstatus, hwtitle : _nstatus, loxbutton : _loxbutton, loxparent : _loxparent, lox_allow_action : _allow_action, dataLink : false }; let rev_title = MAR.getOpt(_need[6], "n2n_rev_title",""); let rev_sec = MAR.getOpt(_need[6], "n2n_rev_display_sec",""); if (rev_title !== "") { lx.title = rev_title; lx.shorttitle = rev_sec.toLowerCase().trim(); } let sthead = `${lx.shorttitle} -`; if (lx.title.toLowerCase().trim().startsWith(sthead) === true) { lx.title = lx.title.substring(sthead.length); } // if (lx.title.toLowerCase().trim().startsWith(lx.shorttitle) === false) { // lx.title = lx.shorttitle.capitalize()+"] - " + lx.title; // } lx.title = lx.title.capitalize(); lx.title = elaineui.str2usd(lx.title); lx.title = `${lx.title} ${_cname}`.trim(); lx.title = _client_name; if (lx.title.toLowerCase().trim().startsWith(sthead) === true) { lx.title = lx.title.substring(sthead.length); } if (_allow_action === true) { lx.title = `${lx.title}
    Click here to E-Sign
    `; } lx.title += ``; //lx.title += `
    `; if (MAR.getOptNum(lx, `status`,0) === 4) { continue; } df = new DocFolder(lx); h += df.render(); } else { let _cname = MAR.getOpt(_need[6], "meta.cname", ""); let _client_name = MAR.getOpt(_need[6], "meta.client_title", ""); let _title = `${_need[4]} ${_cname}`.trim(); _title = _client_name; _title = elaineui.str2usd(_title); if (track) console.error(`LOX TRACK _need[7] ${ _need[7]}`); if (typeof _need[7] === "string" && _need[7] === "deleted") continue; let n2n = MAR.getOpt(_need[6], "n2n",""); if (track) console.error(`LOX TRACK n2n ${ n2n}`); if (typeof n2n === "string" && n2n.indexOf("docusign_stub")> -1) { if (Hwstatus < 2) continue; // allow conditions with a docusign stub IF they have had docs loaded } ar.push({ // title : _need[1].split("|")[0] + xtra + `(${_need[6].hwstatus})
    ${JSON.stringify(_need[6].meta,null,4)}
    `, // title : _need[1].split("|")[0] + xtra + "/"+_need[6].hwstatus_00 + "/"+_need[6].hwstatus_01 + "/"+_need[6].hwstatus + "/"+_need[6].display_type, // title : _need[4], //_need[1].split("|")[0] + xtra , title : _title, need : _need[2], shorttitle : _need[6].meta.sec, // _need[6].display_sec.toLowerCase().trim(), //_need[4], docType : doctype, action : (_need[5].split(":").length > 0) ? _need[5].split(":")[0] : "", longtextTitle : _need[3], nstatus : _need[14], longtext : "
    ", secondarytextTitle : " ", secondarytext : "
    ", status : Hwstatus, hwtitle : _need[6].hwtitle, meta : _need[6].meta, dataLink : _need[11], needid : _need[11].split("/").pop(), icon : false, obj : _need }) let lx = ar[ar.length-1]; let sthead = `${lx.shorttitle} -`; if (lx.title.toLowerCase().trim().startsWith(sthead) === true) { lx.title = lx.title.substring(sthead.length); } if (lx.title.toLowerCase().trim().startsWith("prop - doc - ") === true) { lx.title = lx.title.substring("prop - doc - ".length); } if (lx.title.toLowerCase().trim().startsWith("prop - calc - ") === true) { let len_to_cut = "prop - calc - ".length; if (lx.title.length > len_to_cut+3) { lx.title = lx.title.substring("prop - calc - ".length+3); } else { lx.title = lx.title.substring("prop - calc - ".length); } } // if (lx.title.toLowerCase().trim().startsWith(lx.shorttitle) === false) { // lx.title = lx.shorttitle.capitalize()+"] - " + lx.title; // } lx.title = lx.title.capitalize(); if (track) console.error(`LOX TRACK lx.title ${lx.title}`); } homework_line_count++; } catch(E) { console.error(E); } } } //DocFolder if("data" in retval) { // these are the LOX for (let i=0; i < retval.data.length; i++) { try { let _lox = retval.data[i]; let _loxstatus = 1; let _loxstatus1 = "-"; let _nstatus = ""; var h1 = ""; if (_lox.status == "new") { h1 += ""; _loxstatus = 1; _nstatus = "new"; } else if (_lox.status == "Sent") { //h1 += ""; _loxstatus = 2; _nstatus = "In process"; } else { h1 += ""; _nstatus = "signed"; _loxstatus = 4; } if ("n2n" in _lox && _lox.n2n !== false && "isinternal" in _lox.n2n && _lox.n2n.isinternal == true) { // this has a parent and the parent is internal if ("n2n" in _lox && _lox.n2n !== false && "displayasloxparent" in _lox.n2n && _lox.n2n.displayasloxparent == false) { continue; } } if ("n2n" in _lox && _lox.n2n !== false && "data" in _lox.n2n ) { let this_part0 = _lox.n2n.data.split(" ")[0]; if (this_part0 in needs_to_match_as_parent_for_lox === false) continue; } let lox_title = "Lox : "+ _lox.data.filename; if ("n2n" in _lox && _lox.n2n !== false && "k" in _lox.n2n ) { let _parent_key = _lox.n2n.k; let x_loxstatus = _loxstatus; for (let j=0; j < needs_retval.n.length; j++) { let _jneed = needs_retval.n[j]; if (_parent_key == _jneed[2]) { _loxstatus = _jneed[6].hwstatus; } } /** * jc replace with the actual title from the needs list * */ // lox_title = sup_data_title(_lox.n2n.k); // + "/" + x_loxstatus + ":" + _loxstatus; for (let _i=0; _i < needs_retval.n.length; _i++) { let __n = needs_retval.n[_i]; if (__n[2].split(" ")[0] === _lox.n2n.k.split(" ")[0]) { lox_title = __n[4]; } } } if ("n" in _lox && _lox.n !== false && "k" in _lox.n ) { let _parent_key = _lox.n.k; let x_loxstatus = _loxstatus; for (let j=0; j < needs_retval.n.length; j++) { let _jneed = needs_retval.n[j]; if (_parent_key == _jneed[2]) { _loxstatus = _jneed[6].o_hwstatus; _loxstatus1= _jneed[6].hwstatus; } } //lox_title += "["+sup_data_title(_lox.n.k)+"]"; // + "/" + x_loxstatus + ":" + _loxstatus; } // if (lox_title.indexOf("4506T") > -1) debugger; if (_loxstatus < 0) continue; if (action == "type_done") { if (_loxstatus != 4) continue; } else if (action == "type_pending") { if (_loxstatus != 2) continue; } else { if (_loxstatus == 4) continue; if (_loxstatus== 2) continue; } let lx = { title: lox_title + ``, docType:'lox', need : _lox.n2n.k, // longtextTitle : "Letter of Explanaiton to Docusign" + "
    " + JSON.stringify(_lox,null,4) + "
    ", longtextTitle : "Letter of Explanaiton to E-Sign", longtext : "Current status : "+ _lox.status+"
    ", secondarytextTitle : h1, secondarytext : "
    ", year: '2017', status : _loxstatus, hwtitle : _nstatus, dataLink : false }; } catch(E) { console.error(E); } } } let COLS = { TYPE : 5 } // ar = []; // homework_line_count = 0; // h += "HWC "+homework_line_count if (homework_line_count == 0) { h += "
    "; if (action == "type_done") { h += "
    "; h += "Nothing to show yet.

    " + "We will update you once your documents are cleared" h += "
    "; } else if (action == "type_pending") { h += "
    "; h += "Nothing to show yet.

    " + "We will update you once you have any pending documents" h += "
    "; } else { h += "
    "; h += "Nothing to show yet.

    " + "We will update you once you have homework" h += "
    "; } h += "
    "; } for (let inum= 0; inum < ar.length; inum++){ try { // h += "
    "+JSON.stringify(ar[inum])+"
    "; if (ar[inum]["docType"] == "internal") continue; if (MAR.getOptNum(ar[inum], `status`,0) === 4) { continue; } df = new DocFolder(ar[inum]); h += df.render(); } catch(E) { console.error(E) } } h += `
     
    ` h += uihelpers.cbuttonbar(`Save & Close`,frm.addfunction(function(){ setScenario_data("__application_homework_doc_save_pressed_ts",`${new Date().getTime()}`); mar.answers._events = ["application:homework_doc_save_pressed"]; mar.fakesave(function(){ mvc.go("#lox-thanks"); }) }),"Back",frm.addfunction(function(){ if (MAR.is_refi() === true || getDoOwnRealestate() == true) { mvc.go("#reo-home"); } else { mvc.go("#liabilities-home.prev"); } }),"mar.help()").wrap("
    ","
    "); h += `
    `; mar.tmp_resize_lox_height = function(src) { let height = mar.viewport.height(); let offsettop = mar.viewport.top(); console.warn('viewport listener tmp_resize_lox_height', src, height, offsettop); if (!height) return; let topbarheight = $("#body-container").offset().top; // 40 px (ish) let wrappers = $("#loxdiv").parentsUntil("#body-container"); let total_top = 0; total_top += topbarheight; for (let i=0; i < wrappers.length; i++) { let $wrapper = $(wrappers[i]); let tp = $wrapper[0].getBoundingClientRect(); total_top += $wrapper.position().top; total_top += parseInt($wrapper.css('marginTop'), 10); } total_top += $("#loxdiv").position().top; total_top += parseInt($("#loxdiv").css('marginTop'), 10); let margin_bottom = 20; $("#loxdiv").css({ overflowX : "hidden", overflowY : "auto", height : `${(height+offsettop-total_top-margin_bottom) - 20}px` }) } mar.tmp_show_save_and_close_bar = function(action) { console.warn("tmp_show_save_and_close_bar"); if (action === "hide") { $(".bar99").css("display","none"); } if (action === "show") { $(".bar99").css("display","block"); } }; mar.tmp_resize_lox_height(); mar.kloudless_picker = window.Kloudless.filePicker.picker({ // File Picker initialization options here. app_id: "7PGdlqoJ0kyPyoOvAismvl7dzDgWGyYs7_wxNTGtT0bXSoew", // Get your own at https://kloudless.com }); mar.kloudless = function() { mar.kloudless_picker.choose() } // h += `
    Kloudless
    `; h += ``; // .maxfitscreenheight_loxdiv { // padding-bottom:60px; // overflow-x:hidden; // overflow-y:auto; // } /** * virtual DOM */ let $loxdiv = $(h); console.warn("loxdiv",$loxdiv); mar.sortloxdiv = function() { $loxdiv.sort(function(a, b) { var A = $(a).data('order'); if (!A) A = 0; var B = $(b).data('order'); if (!B) B = 0; if (A == 3) A = 0.5; if (B == 3) B = 0.5; if(A < B) return -1; if(A > B) return 1; A = $(a).data('shorttitle'); if (!A) A = ""; B = $(b).data('shorttitle'); if (!B) B = ""; if(A < B) return -1; if(A > B) return 1; A = $(a).find('.title').text(); if (!A) A = ""; else A = A.trim().replace(/ /g,""); B = $(b).find('.title').text(); if (!B) B = ""; else B = B.trim().replace(/ /g,""); // console.error(`3rd part ${A} ${B}`); return A.localeCompare(B); if(A < B) return -1; if(A > B) return 1; return 0; }); } mar.sortloxdiv(); let status_by_class = function($elm) { if ($elm.hasClass("docFolderStatus_1")) return 1; if ($elm.hasClass("docFolderStatus_2")) return 2; if ($elm.hasClass("docFolderStatus_3")) return 3; if ($elm.hasClass("docFolderStatus_4")) return 4; return 0; } let status_set_class = function($elm, titleStatus) { let current_status = status_by_class($elm); $elm.removeClass(`docFolderStatus_${current_status}`); $elm.addClass("docFolderStatus_"+titleStatus); let children = $elm.find(`.docFolderTopBarStatus_${current_status}`); for (let i=0; i < children.length; i++) { $(children[i]).removeClass(`docFolderTopBarStatus_${current_status}`); $(children[i]).addClass("docFolderTopBarStatus_"+titleStatus); } } if ($("#loxdiv").html() === "" || $("#loxdiv").html().indexOf("loading-dot") > -1) { $("#loxdiv").html($loxdiv); mar.filepupload.upload(); mar.tmp_lox_activate_drag_on_conditions(); } else { let ch = $("#loxdiv").children(); let last_found_lox_div = false; let status_changes = 0; let visible_changes = 0; $("#loxdiv").find(`.docFolderHolder`).addClass(`rt-orphan`); for (let i=0; i < $loxdiv.length; i++) { let $row = $($loxdiv[i]); if ($row.hasClass("docFolderHolder") === false) continue; let id = $row.prop("id"); let existing_row = $("#loxdiv").find(`#${id}`); if (existing_row.length > 0) { existing_row.removeClass("rt-orphan"); last_found_lox_div = existing_row; let sbcn = status_by_class($row); let sbce = status_by_class(existing_row); if (sbcn === 3) { // debugger; } if (status_by_class(existing_row) !== status_by_class($row)) { status_set_class(existing_row, status_by_class($row)); status_changes++; } let replace_element = function(elm_str){ let ev = existing_row.find(elm_str); let nv = $row.find(elm_str); if (ev.length === 1 && nv.length === 1) { let _ev = ev.html(); let _nv = nv.html(); if (_ev !== _nv) { ev.html(_nv); } } }; let existig_is_open = existing_row.hasClass("x-open"); replace_element(".docFolderStatus"); replace_element(".docFolderTitle .title"); // existing_row.data("order", $row.data("order")); existing_row.data("shorttitle", $row.data("shorttitle")); existing_row.data("needb64", $row.data("needb64")); if (existig_is_open === false) { existing_row.data("order", $row.data("order")); } } else { if (last_found_lox_div === false) { $("#loxdiv").after($row); } else { $(last_found_lox_div).after($row); } } } $("#loxdiv").find(`.docFolderHolder.rt-orphan`).remove(); mar.filepupload.upload(); mar.tmp_lox_activate_drag_on_conditions(); if (status_changes > 0) { mar.sortloxdiv_rt(); } } // $("#loxdiv").addClass("maxfitscreenheight_loxdiv"); setDesktop(); setTimeout(function(){ window.getComputedStyle(document.querySelector("#loxdiv")); // maybe force a reflow }) $("#loxdiv-tabs").addClass("x-hide"); setTimeout(function(){ let $newdropzone = $("#loxdiv").find(".dropmehere.inbox"); if ($newdropzone.length === 0) return; mar.filepupload.upload($newdropzone); },500); mar.organizeloxdiv_rt = (function() { function removeHeadings() { $('#loxdiv .heading').remove(); } function addHeadings() { var rows = $('#loxdiv').children(); let st = false; let ord = false; for (let i=0; i < rows.length; i++) { $row = $(rows[i]); if ($row.hasClass("dropmehere")) { st = false; } if ($row.hasClass("docFolderHolder")) { let _st = $row.data("shorttitle"); let _ord = $row.data("order"); // if (_st !== st || num(_ord) > num(ord)) { if (_st !== st) { st = _st; ord = _ord; let key = `hw_head_${_st}`; let hval = mar._txt(key); let hVal = (hval.startsWith("hw_head")) ? mar._txt(_st) : hval; $row.before(`
    ${hVal.capitalize()}
    `); } } } } function addDropZones() { var rows = $('#loxdiv').children(); for (let i=0; i < rows.length; i++) { $row = $(rows[i]); if ($row.hasClass("docFolderHolder")) { } } // dropzonesObj } return { removeHeadings : removeHeadings, addHeadings : addHeadings, addDropZones : addDropZones } })(); mar.sortloxdiv_rt = function() { mar.organizeloxdiv_rt.removeHeadings(); var rows = $('#loxdiv').children(); rows.sort(function(a, b) { var A = $(a).data('order'); if (!A) A = 0; var B = $(b).data('order'); if (!B) B = 0; if (A == 3) A = 0.5; if (B == 3) B = 0.5; if(A < B) return -1; if(A > B) return 1; A = $(a).data('shorttitle'); if (!A) A = ""; B = $(b).data('shorttitle'); if (!B) B = ""; if(A < B) return -1; if(A > B) return 1; A = $(a).find('.title').text(); if (!A) A = ""; B = $(b).find('.title').text(); if (!B) B = ""; return A.localeCompare(B); if(A < B) return -1; if(A > B) return 1; return 0; }); $.each(rows, function(index, row) { $("#loxdiv").append(row); }); mar.organizeloxdiv_rt.addHeadings(); } mar.organizeloxdiv_rt.removeHeadings(); mar.organizeloxdiv_rt.addHeadings(); // // mar.sortloxdiv(); mar.tmp_get_condition_counters(true); },20000); },20000); }; setTimeout(mar.tmp_loxrefresh,100); } else { //alert("LOX" + __ROLE); if (__ROLE == "lo") { var hh = frm.elaine("As LO you you can't complete a LOX for a client.","").render(); hh += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ mvc.go("#lox"); }),"Back",frm.addfunction(function(){ mvc.go("#lox"); }),"mar.help()"); hh = Mustache.render(hh,localopts); console.warn("LOCALOPTS",localopts) $("#loxdiv").html(hh); return; } mar.socket.send_and_receive("lox-render",{ appid : mar.ID, loxid : loxid }, function(retval){ console.warn(retval); if (retval.data.form.trim().length == 0) { var hh = frm.elaine(retval.data.bubble,"").render(); hh += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ mvc.go("#lox"); }),"Back",frm.addfunction(function(){ mvc.go("#lox"); }),"mar.help()"); } else { var hh = retval.data.bubble + retval.data.form; } hh = Mustache.render(hh,localopts); console.warn("LOCALOPTS",localopts) $("#loxdiv").html(hh); autosize($("#loxdiv .questions textarea")) },20000) } } } return { section : "homework", render : render } })() mar.uploadpayrol = function(da,name) { swal(JSON.stringify(da)+"/"+name); } mar.payrollPressFn = function(e,importfn) { mar.three_panel_pane.init(); //console.log('pressed icon button e: ',e); let $elm = $(e); let goto = $elm.data("goto"); let imgsrc = $elm.data("imgsrc"); let displayname = $elm.data("displayname"); //console.log('goto : '+goto); //mar.chosenBank = {id:goto, displayName:pagenames[goto]}; if (goto && goto != "") { //mar. //mvc.go("#assets-"+pagenames[goto]); let chosenBank = {id:goto, displayName: displayname}; let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "Sign In"; h += "
    "; h += "
    "; h += "Please enter your credentials for "+chosenBank.displayName+" "; h += "
    "; //note: these need to be dynamic and generated by the api h += "
    "; h += "User name for "+chosenBank.displayName+" "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "Password for "+chosenBank.displayName+" "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    Wait a few seconds whilst we connect to your payrol provider","er").render(); h += frm.working().render() h += "
    "; // JC - CW - elaine added div h += "
    "; mar.three_panel_pane.p2(); mar.three_panel_pane.p2(h); let $p2 = $(mar.three_panel_pane.getp2()); let ElaineEventualText = "We will import the following job."; // mar.three_panel_pane.p2(frm.working().render()); mar.importw2_data = []; mar.importw2 = function(i) { let da = mar.importw2_data[i]; if (importfn) { importfn(da,goto); } else { mar.defaultw2 = da; mvc.go("#income-w2manual"+"."+applicantnum); swal.close(); } } setTimeout(function(){ $.get("/api/payrolsystems/get_employers", function(da) { $(".working").remove(); $("#el1").html(ElaineEventualText); var h = ""; mar.importw2_data = da; for (let i=0; i < da.length; i++) { let g = new GenericBlock(); h += g.render("svg_w2_icon_income",da[i].name,[ "$"+da[i].pay_amount + " / "+da[i].pay_freq ],"mar.importw2("+i+");"); } /* { "type": "w2", "name": "Bagles and beans Inc.", "pay_freq": "weekly", "pay_amount": 650, "bonus_ot_yn": "Y", "hr_contact": "Jane Horricks", "hr_tel": "555-122-1234", "hr_email": "jane@baglesinc.com" } */ $(".er").append(h); $(".er").append("
    IMPORT JOB
    "); $($p2.find(".xhuman")[0]).Humanize({ opts : { fn : function() { } }, quick : false }); // mar.three_panel_pane.p2(h); }); mar.three_panel_pane.p2() },1000) })+"' class='big-middle-button'>Continue
    "; h += "
    "; h += "
    ";//end account verification h += "
    ";//end pane h += "
    "; h += "
    "; h += "
    ";//end pane h += "
    ";//end pane h += "
    ";//end three pannel inner tab h += "
    ";//end three pannel inner h += "
    ";//end three pannel //launch the overlay var s = document.createElement("div"); s.setAttribute("class","normal-form"); /* s.innerHTML = ""+ frm.htitle("Please choose your bank").render()+ "
    "+ $("#svg_plaid_logo").html()+ "
    "+ "
    "+ "PLAID LINK here? "+ "
    "; */ s.innerHTML = h; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false//"CANCEL" } }); } } /* file /ui/app/js/pages.income.js , last updated 1713194755742*/ /* * Class: IncomeObj * Def: pass a income data object as the arg and you can store or create little income objects.. * Note: this handles view and model in this object. * */ class IncomeObj { constructor(arg) { this.data = {}; $.extend(true, this.data, arg); /* this.data = arg; this.data.bankname = arg.bankname; this.data.incomeType = arg.incomeType; this.data.assetName = arg.assetName; this.data.subtype = arg.subtype; this.data.num = arg.num; this.data.total = arg.amount; this.data.icon = arg.icon; ?delete function? or no? */ console.log('income object data',this.data); this.data.incomeType = (this.data.type) ? this.data.type : 'general'; this.data.Icon = ""; if (MAR.getOpt(this.data, "verified", "") == "N") { this.data.incomeType = "unverified" this.data.Icon = "!"; } //the idea here is that // -you can pass an icon directly // -or you can pass an id, (like a bank name) and it will check if we have the logo // -if we do have the logo, it will use it for the icon, // - if not it will just make it the default one below in the switch. if(this.data.icon){ this.data.icon = 'svg_'+this.data.icon+'_income'; }else{ //check if(this.data.id){ //var st = $('#svg_'+this.data.type+'_income').html(); // console.warn('is tehre an icon?? '+st); if( $('#svg_'+this.data.id+'_income').html() !== 'undefined'){ // console.warn('THERE IS an icon : '+this.data.type); this.data.icon = 'svg_'+this.data.id+'_income'; } } } //make sure there is a total this.data.total = (this.data.total) ? Math.floor(parseInt(this.data.total,10)) : '0'; switch(this.data.incomeType) { case 'w2': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_w2_icon_income'; this.data.displayName = (this.data.displayName) ? this.data.displayName : 'W-2'; break; case 'DD1099': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_self_employed_1099_icon_income'; this.data.displayName = (this.data.displayName) ? this.data.displayName : '1099 Income'; break; case 'llc': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_llc_icon_income'; this.data.displayName = (this.data.displayName) ? this.data.displayName : 'Sole proprietor / LLC'; break; case 'k1': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_corporation_icon_income'; this.data.displayName = (this.data.displayName) ? this.data.displayName : 'Corporation K1'; break; case 'pension': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_ira_and_401k_icon_assets'; this.data.displayName = (this.data.displayName) ? this.data.displayName : 'Pension'; break; case 'ssec': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_irs_tax_icon_liabilities'; this.data.displayName = (this.data.displayName) ? this.data.displayName : 'Social Security'; break; case 'child': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_child_support_icon_income'; this.data.displayName = (this.data.displayName) ? this.data.displayName : 'Child Support'; break; case 'alimony': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_alimony_icon_income'; this.data.displayName = (this.data.displayName) ? this.data.displayName : 'Alimony'; break; case 'rental': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_rental_icon_income'; this.data.displayName = (this.data.displayName) ? this.data.displayName : 'Rental income'; break; case 'general': this.data.icon = (this.data.icon) ? this.data.icon : 'svg_emd_icon_assets'; this.data.displayName = (this.data.displayName) ? this.data.displayName : 'Other Income'; break; default: this.data.icon = (this.data.icon) ? this.data.icon : 'svg_emd_icon_assets'; this.data.displayName = (this.data.displayName) ? this.data.displayName : 'Other Income'; } this.createLayout = function(ftrObj){ let h = ''; h += `
    `; if (this.data.Icon != "") { h += ""; } else { h += ""; } h += "
    "; let hd = ""; let hastotal = true; let per = ("per" in this.data) ? this.data.per : ""; if(this.data.incomeType == 'w2'){ if ("sys" in this.data && this.data.sys && this.data.sys != "") { // h += "
    "+this.data.name+"("+this.data.sys+")
    "; // h += "
    "+this.data.name+"()
    "; h += "
    "+this.data.name+"
    "; } else { h += "
    "+this.data.name+"
    "; } if(this.data.previous_type){ // h += "
    "+this.data.name+"
    "; if (this.data.previous_type == "study") { hd += "
    Previous School W2
    "; } else { if (MAR.getOpt(this.data,"selfemployed","N") === "Y") { hd += `
    Previous Employer ${MAR.getOpt(this.data,"selfemployed_type","W2")}
    `; } else { hd += "
    Previous Employer W2
    "; } } hastotal = false; }else{ // h += "
    "+this.data.name+"
    "; if (per == "") hd += "
    Current Employer W2
    "; } //h += "
    at company: "+this.data.name+"
    "; }else if (this.data.incomeType == 'DD1099'){ h += "
    "+this.data.name+"
    "; if (per == "") hd += "
    current 1099
    "; }else if (this.data.incomeType == 'llc'){ h += "
    "+this.data.name_llc+"
    "; if (per == "") hd += "
    current llc
    "; }else if (this.data.incomeType == 'k1'){ h += "
    "+this.data.name_k1+"
    "; if (per == "") hd += "
    current "+this.data.small_name+"
    "; }else if (this.data.incomeType == 'unverified'){ h += "
    "+this.data.displayName+"
    "; // h += "
    To Be Verified
    "; if (per == "") hd += "
    "+this.data.sug_text+"
    "; }else{ let ex = ("extra" in this.data) ? " "+this.data.extra : ""; h += "
    "+this.data.displayName+ex+"
    "; if (per == "") { if(this.data.other_description){ hd += "
    "+this.data.other_description+"
    "; } } } h += "
    " h += "
    "; if (hastotal == true) { h += "
    Total:
    "; h += "
    "+this.data.total+""+per+"
    "; } h += hd; h += "
    " h += "
    ×
    "; h += "
    "; //end imported account holder return h; } return this; } /* * function render for an income object * take the data and renders it according to desired view. * params: string * */ render(vw){ let viewType = (vw) ? vw : this.data.incomeType; let h = ''; mar.showIncomeItemPress = function(elm, type, appnum, idx) { mvc.go("#income-"+type+"."+appnum+"."+idx) } mar.deleteIncomeItemPress = function(elm, appnum, idx) { let $elm = $(elm); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Conformation").render() + "Are you sure you want to delete this income ? "; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "No", call : { text: "Delete", value: "del", closeModal: false } } }) .then((act) => { if (act == "del") { MAR.income.del(appnum,idx) mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mvc.go("#income-how."+appnum) swal.close(); } }); //let goto = $elm.data("goto"); } // this is like a default h h = this.createLayout(); console.log('viewType:: '+viewType); switch(viewType) { case 'w2': //h = sprintf(h, hInnerMod); break; case 'DD1099': break; case 'llc': break; case 'k1': break; case 'general': break; default: } return h; } updateModel(val){ $.extend(true, this.data, val); } } //end IncomeObj mar.pg["income-how"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { /** * standard starting block */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var _sc = getScenario_v2(); var inc = getIncome_v2(); MAR.income.init(applicantnum); var totalIncomeAmount = 0; let incm = getIncome_v2(); incm.has_unverified_items = false; let h = ""; //h += frm.htitle("Available Income: 51732").render(); //h += frm.htitle("Income").render(); let _startingitems = JSON.stringify(mar.answers.v2.income[applicantnum].items); mar.pg_changelistner = function() { if (JSON.stringify(mar.answers.v2.income[applicantnum].items) != _startingitems) { mvc.go("#income-how"+"."+applicantnum); } } if (mar.answers.v2.income[applicantnum].items.length > 0){ h += frm.htitle(`Income ${na} - per month`).render(); h += ""; let income_editors = function(t, obj) { if (t == "w2" && incomes.previous_type) { return "w2-previous"; } if (t == "ssec") return "social-security"; if (t == "w2") return "w2manual"; if (t == "child") return "child-support"; if (t == "dis") return "disability"; return t; } for (let a=0; a < mar.answers.v2.income[applicantnum].items.length; a++) { var incomes = mar.answers.v2.income[applicantnum].items[a]; if ("type" in incomes === false) { incomes.type = ""; } if (incomes.type == "w2" && incomes.previous_type) { //continue; } incomes._i = a; incomes._a = applicantnum; incomes._t = income_editors(incomes.type, incomes); incomes.sys = incomes.sys; if ("displayName" in incomes == false || incomes.displayName == ""){ if ("name" in incomes) incomes.displayName = incomes.name } if (incomes.type == "w2" && incomes.previous_type == "study") { if ("school" in incomes) incomes.name = incomes.school; if ("school" in incomes) incomes.displayName = incomes.school; } if (incomes.type == "child") { // incomes.displayName = incomes.displayName + incomes.child_name; incomes.extra = " - " + incomes.child_name; } if (incomes.type == "k1") { incomes.small_name = "C-Corp"; if ("ctype" in incomes && incomes.ctype == "s") { incomes.small_name = "S-Corp"; } if ("ctype" in incomes && incomes.ctype == "p") { incomes.small_name = "Partnership"; } } if ("verified" in incomes && incomes.verified.toLowerCase() == "n") { if ("sug_total" in incomes) { incomes.total = incomes.sug_total; if (MAR.getOpt(incomes, "over","") === "Y") { incomes.total = incomes.over_total; } } incm.has_unverified_items = true; incomes.per = " / pm"; } else { incomes.per = ""; } var io = new IncomeObj(incomes); totalIncomeAmount += parseInt(io.data.total,10); h += io.render(); //h += "
    "+JSON.stringify(incomes,null,4)+"
    "; /* * ao = new IncomeObj(assetArray[i]); totalAssetAmount += parseInt(ao.data.amount,10); h += ao.render(); */ //IncomeObj // for (let i=0; i < incomes.length; i++) { // h += frm.summaryline("applicant "+a, incomes[i].type, { // body : [ // { key : "Monthly salary", val : checkNum(incomes[i].total)} // ] // }, false).render(); // // h += "
    "; // // } } if (incm.has_unverified_items !== true) { h += "
    " + "
    " + "Add Another Income Source" + "
    " + "
    "; } if (mar.WE_ARE_FROM_LOI === true) { h += "
    " + "
    " + "Change the income docs status" + "
    " + "
    "; } h += "
    "; h += frm.elaine(na+", what other types of income do you have?","er").render(); h += "
    "; }else{ h += "
    "; h += frm.htitle("Income - "+na).render(); h += frm.elaine(na+", how do you make your income?","er").render(); h += "
    "; } //h += "
    " + JSON.stringify(mar.answers.v2.income,null,4)+"
    "; h += "
    " + "
    "+$("#svg_w2_icon_income").html()+"W2
    " + "
    "+$("#svg_llc_icon_income").html()+"Self employed
    " + "
    "+$("#svg_corporation_icon_income").html()+"Corporation
    " + // "
    "+$("#svg_corporation_icon_income").html()+"Corporation
    " + "
    "; h += "
    " + "
    "+$("#svg_ira_and_401k_icon_assets").html()+"Pension
    " + "
    "+$("#svg_emd_icon_assets").html()+"Disability
    " + "
    "+$("#svg_irs_tax_icon_liabilities").html()+"Social Security
    " + "
    "; h += "
    " + "
    "+$("#svg_child_support_icon_income").html()+"Child Support
    " + "
    "+$("#svg_alimony_icon_income").html()+"Alimony
    " + "
    "+$("#svg_rental_icon_income").html()+"Rental
    " + "
    "; h += "
    Other
    "; if (mar.WE_ARE_FROM_LOI === true) { let sc_int_only = getScenario_data("is_interestonly",""); let sc_int_only_over = getScenario_data("is_interestonly_over",""); let sc_is_nodoc = getScenario_data("is_nodoc",""); let h1 = "Set this loan to NO Document"; if (sc_int_only_over === "Y" || sc_int_only === "Y" || sc_is_nodoc === "Y") { h1 = "This application does NOT require income docs"; h += "
    " + "
    " + `${h1}` + "
    " + "
    "; } else { // h += "
    " + // "
    " + // `${h1}` + // "
    " + // "
    "; } } h += "
    "; h += "
    "; VAL = ''; /* h += frm.radio("incomehow","",VAL,"","",function(){ },{ w2 : "Salary, with pay stubs", DD1099 : "1099, with direct deposits", llc : "LLC or Sole Propriertor", corp : "Corporation", pension : "Pension", ssec : "Social Security", child : "Child", alimony : "Alimony", rental : "Rental", other : "Other" }).render(); */ /* h += "
    " h += frm.txt("incomehow_other","",VAL,"e.g. Inheritance Money","",function(){}).render(); h += "
    " */ /* end modal content */ let pagenames = { // w2 : "w2", // with wizard w2 : "w2manual", DD1099 : "DD1099", llc : "llc", k1 : "k1", pension : "pension", child : "child-support", dis : "disability", ssec : "social-security", alimony : "alimony", rental : "rental", other : "other" } let __income_2yearquestion_override = false; let continuefn = function() { debugger; if (incm.has_unverified_items == true) { elaineui.swal(`You have some un-verified incomes you need to check before you can continue

    These incomes have a triangle next to them


    `, "Income Verification"); return; } let has_2_years = MAR.income.have2Years(applicantnum); // if investment return 0; if (getScenario_data(`is_interestonly`,``) === `Y`) { has_2_years = 0; } if (getScenario_data(`is_nodoc`,``) === `Y`) { has_2_years = 0; } // if (typeof has_2_years == "string" && getScenario_data("__income_2yearquestion_override_"+applicantnum,"N") !== "Y") { if (typeof has_2_years == "string" && __income_2yearquestion_override === false) { elaineui.swalprompt({ title : false,//"delete", txt : `You have not entered 2 years of employment history\
    \
    \ The earliest date you entered is ${elaineui.format("usd",has_2_years.split("|")[0])} \
    \
    \ You have covered , in total ${~~(num(has_2_years.split("|")[2]))} months \
    \
    \ Do you want to add another previous empoyment?\
    `, ok : "Yes", okfn : function() { mvc.set("currentw2uuid",has_2_years.split("|")[1]); mvc.go(`#income-w2-previous.${applicantnum}`) }, cls :"midelinfopopupOneButton", cancel : "No", cancelfn : function() { __income_2yearquestion_override = true; // setScenario_data("__income_2yearquestion_override_"+applicantnum,"Y"); continuefn(); } }); return; } if (has_2_years === -1) { elaineui.swal(`You have not entered any income




    `, "Income Verification"); return; } if (MAR.income.has_w2_with_ownership(applicantnum) !== false) { if (MAR.income.has_business_that_generates_w2(applicantnum) === false) { let names = []; let w2s = MAR.income.has_w2_with_ownership(applicantnum); for (let i=0; i < w2s.length; i++) { names.push(w2s[i].name); } let company_choice = (function(){ let h = ""; h += ""; h += "
    " + "
    "+$("#svg_w2_icon_income").html()+"Sole Proprietor
    1099
    " + // "
    "+$("#svg_corporation_icon_income").html()+"Corporation
    " + "
    "+$("#svg_llc_icon_income").html()+"Business Owner
    LLC
    " + "
    "; h += "
    "; h += "
    " + "
    "+$("#svg_corporation_icon_income").html()+"S-CORP
    1120S
    " + "
    "+$("#svg_corporation_icon_income").html()+"C-CORP
    1120
    " + "
    "+$("#svg_llc_icon_income").html()+"PARTNERSHIP
    1065
    " + "
    "; return h; })(); elaineui.swal(`You indicated that your W2 income comes from a business that you own.` + // have full or partial ownership in ${names.join(",")} from which you draw W2 income, `+ `

    Please select a business type and enter some more company information?

    ${company_choice}
    `, "Income Verification", "I'll correct the W2",false /*"Add the company"*/,function(){ reveal_income_choice(); swal.close(); }); $(".incomeIcons_button.swal").on('click', incomeButtonClick) return; } } if ($("#body-container #maindiv").is(':visible') === false) { reveal_income_choice(); $("#body-container .next-button").html("I AM DONE"); return; } var how = radio("incomehow"); // if (how && how != "") { // mvc.go("#income-"+pagenames[how]+"."+applicantnum); // } else { setScenario_data("__income_passed_"+applicantnum,"Y"); let applicantcount = getApplicantsNames_v2().length; if (applicantnum >= (applicantcount-1)) { setScenario_data("__income_passed","Y"); } frm.buttons.hide(function(){ mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(function(){ if (applicantnum < (applicantcount-1)) { mvc.go("#up-next-income-inbetween."+(num(applicantnum)+1)); } else { mvc.go("#liabilities-home"); // mvc.go("#income-end"+"."+applicantnum); } }); }); // } } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ continuefn(); }),"Back",frm.addfunction(function(){ if (applicantnum > 0) { mvc.go("#income-how."+(applicantnum-1)); } else { if (num(mar.pg_as) < num(mar.pg_pd)) { let number_of_applicants = getApplicantsNames_v2().length; mvc.go("#scenario-addresshistory."+(number_of_applicants -1)); } else { mvc.go("#assets-choice"); } } }),"mar.help()"); h = Mustache.render(h,localopts); let reveal_income_choice = function() { if ($("#maindiv.x-hide").length > 0) { $("#maindiv.x-hide").removeClass("x-hide"); $("#body-container").scrollTo("max",200); $($("#maindiv .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false }); // navsync.sendcustomevent("assets-choice-reveal") } } let incomeButtonClick = false; let or = function(){ if (getScenario_data("__income_unin_passed_0","N") == "N") { mar.pg_silent_goto("#up-next-income.0", function(){ mvc.go("#up-next-income.0") }); return; } // let has_2_years = MAR.income.have2Years(applicantnum); // // if (typeof has_2_years == "string") { // // elaineui.swalprompt({ // title : false,//"delete", // txt : `You have not entered 2 years of employment history\ //
    \ //
    \ // The earliest date you entered is ${has_2_years.split("|")[0]} \ //
    \ //
    \ // Do you want to add another previous empoyment?\ //
    `, // ok : "Yes", // okfn : function() { // mvc.set("currentw2uuid",has_2_years.split("|")[1]); // mvc.go(`#income-w2-previous.${applicantnum}`) // // }, // cancel : "No", // cancelfn : false // }); // return; // // } // if (has_2_years === -1) { // elaineui.swal(`You have not entered any income //
    //
    //
    //
    //
    `, "Income Verification"); // return; // // } $("#body-container").find(".xx-radio").myradio(); $("#totalIncomeAmount").html(totalIncomeAmount); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); incomeButtonClick = function(e){ console.log('pressed icon button e: ',e); let $elm = $(e.currentTarget); let goto = $elm.data("goto"); if (goto === "toggleincomedocs-skip" || goto === "toggleincomedocs") { let sc_int_only = getScenario_data("is_interestonly",""); let sc_int_only_over = getScenario_data("is_interestonly_over",""); let h = "Set to NOT requiring income docs"; let sc_ans = "Y"; let sc_is_nodoc = getScenario_data("is_nodoc",""); if (sc_int_only_over === "Y" || sc_int_only === "Y" || sc_is_nodoc === "Y") { h = "Set to require income docs"; sc_ans = ""; } elaineui.swalprompt({ title : false,//"delete", txt : `${h}\
    `, ok : "Yes", okfn : function() { // setScenario_data("is_interestonly",sc_ans); setScenario_data("is_nodoc",sc_ans); // setScenario_data("is_interestonly_over",sc_ans); mar.fakesave(function(){ if (goto === "toggleincomedocs-skip") { continuefn(); } else { mvc.go(`#income-how.${applicantnum}`) } }); }, cls :"midelinfopopupOneButton", cancel : "No", cancelfn : function() { } }); return; } if (goto == "revealmore") { reveal_income_choice(); return; } if ($elm.hasClass("swal")) swal.close(); console.log('goto : '+goto); if (goto && goto == "selfemployed") { let h = ""; h += ""; h += "
    "; h += frm.htitle("Self Employed Income").render(); h += "
    How does your business file taxes?
    " // h += "Which type of Self Employed
    income are you adding?"; //h += frm.elaine("Which type of Self Employed income are you adding?","").render(); h += "
    "; h += ``; h += ``; h += "
    " + "
    "+$("#svg_w2_icon_income").html()+"Sole Proprietor
    1099
    " + // "
    "+$("#svg_corporation_icon_income").html()+"Corporation
    " + "
    "+$("#svg_llc_icon_income").html()+"Business Owner
    LLC
    " + "
    "; h += "
    " + "
    "+$("#svg_corporation_icon_income").html()+"S-CORP
    1120S
    " + "
    "+$("#svg_corporation_icon_income").html()+"C-CORP
    1120
    " + "
    "+$("#svg_llc_icon_income").html()+"PARTNERSHIP
    1065
    " + "
    "; h += "
    "; h += "
    "; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = h; swal({ //title : "Self Employed Income Type", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "BACK" } }) .then((act) => { }); $(".incomeIcons_button.swal").on('click', incomeButtonClick) return; } if (goto && goto == "corporation") { let h = ""; h += "
    "; h += frm.htitle("Corporate Income").render(); h += "
    How does your business file taxes?
    " // h += "Which type of Self Employed
    income are you adding?"; //h += frm.elaine("Which type of Self Employed income are you adding?","").render(); h += "
    "; h += ``; h += ``; h += "
    " + "
    "+$("#svg_corporation_icon_income").html()+"S-CORP
    1120S
    " + "
    "+$("#svg_corporation_icon_income").html()+"C-CORP
    1120
    " + "
    "+$("#svg_llc_icon_income").html()+"PARTNERSHIP
    1065
    " + "
    "; h += "
    " + "
    "+$("#svg_w2_icon_income").html()+"Sole Proprietor
    1099
    " + // "
    "+$("#svg_corporation_icon_income").html()+"Corporation
    " + "
    "+$("#svg_llc_icon_income").html()+"Business Owner
    LLC
    " + "
    "; h += "
    "; h += "
    "; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = h; swal({ //title : "Self Employed Income Type", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "BACK" } }) .then((act) => { }); $(".incomeIcons_button.swal").on('click', incomeButtonClick) return; } if (goto && goto == "k1") { mar._ctype = "c"; } if (goto && goto == "scorp") { mar._ctype = "s"; goto = "k1"; } if (goto && goto == "partnership") { mar._ctype = "p"; goto = "k1"; } if (goto && goto != "") { mvc.go("#income-"+pagenames[goto]+"."+applicantnum); } }; $(".incomeIcons_button").on('click', incomeButtonClick) setTimeout(function() { $("#body-container").scrollTo("0",200); reloadToUberwriterDetailsFromCache(); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { } }, quick : false, }); },500); function reloadToUberwriterDetailsFromCache() { $.get(`/api/uberwriter/qi?id=${mar.ID}`, function(res) { //debugger; let da = ("data" in res) ? res.data : res; let status = ("status" in res) ? res.status : 1; // .importedAccountHolderBtmPart ._dollars if (da.length == 0) return; if (status != 0) return; let h = ""; let qi_total = 0; for (x in da) { if (da[x] !== false) { qi_total += da[x]; } $(`.job-${x} .importedAccountHolderBtmPart`).append(" "+elaineui.format("cur",da[x])).css({ display : "block" }).fadeIn(function(){ $(`.job-${x} .importedAccountHolderBtmPart ._dollars`).css("text-decoration","line-through"); }); } $("#totalIncomeAmount").after(""+elaineui.format("cur_space",qi_total)+"").css({ }).fadeIn(function(){ $(`#totalIncomeAmount`).css("text-decoration","line-through"); }); }); } } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } function iscomplete(N) { var _sc = getScenario_v2(); var inc = getIncome_v2(); let incomes = MAR.income.get(N); for (let i=0; i < incomes.length; i++) { if ("verified" in incomes[i] && incomes[i].verified === "N") return i; } return true; } return { render : render, iscomplete : iscomplete } })(); mar.pg["income-summary"] = (function(){ var html = ""; function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } function checkNum(num){ var val = 0; if($.isNumeric( num )){ val = num } val = '$'+addCommas(Math.round(val)); return val; } function render(pg, localopts) { let VAL = ""; let h = ""; h += frm.htitle("Income source summary").render(); h += "
    "; h += frm.h2("Please review your income sources for this real estate transaction.","").render(); h += "
    "; h += frm.summaryline("current job","Walgreens", { body : [ { key : "Monthly salary", val : "$4,500"}, { key : "Starting date", val : "03/04/2018"} ] }, false).render(); h += '
    '; h += "
    ADD INCOME
    "; //h += "
    ADD
    " h += '
    '; try { getIncome_v2(); for (let a=0; a < mar.answers.v2.income.length; a++) { var incomes = mar.answers.v2.income[a].items; for (let i=0; i < incomes.length; i++) { h += frm.summaryline("applicant "+a, incomes[i].type, { body : [ { key : "Monthly salary", val : checkNum(incomes[i].total)} ] }, false).render(); h += "
    "; } } //h += "
    " + JSON.stringify(mar.answers.v2.income,null,4)+"
    "; h += "
    "; } catch(E) { } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){mvc.go("#income-how"+"."+applicantnum); }),"close",frm.addfunction(function(){mvc.go("#income-how"+"."+applicantnum);}),"mar.help()"); h = Mustache.render(h,localopts); let or = function(){ /* $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); */ // setTimeout(function(){ // $('#calendar').calendar({ // width : $(".x_content").width(), // height : $(".x_content").width(), // zIndex: 1, // weekArray: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // monthArray: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'], // data: null // }); // },500) } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-edit"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p2 = ("p2" in localopts && localopts.p2 != "" && typeof localopts.p2 != "undefined") ? localopts.p2 : false; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let uuid = false; let existingid = false; let incomeObj = false; if (typeof p2 === "string" && p2.indexOf("-") > -1) { uuid = p2; incomeObj = MAR.income.getByUUID(uuid, true); if (incomeObj !== false) { applicantnum = incomeObj.appl; existingid = `${incomeObj.idx}`; } } else { existingid = (p3 && p3 != "new" ) ? p3 : false; } let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"",existingid) : false; let pagelink = false; let h = ""; h += `
    `; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (pagelink !== false) { mvc.go(pagelink); } }),"close",frm.addfunction(function(){ }),"mar.help()"); h = Mustache.render(h,localopts); let pagenames = { // w2 : "w2", // with wizard w2 : "w2manual", "w2-previous" : "w2-previous", DD1099 : "DD1099", llc : "llc", k1 : "k1", pension : "pension", child : "child-support", dis : "disability", ssec : "social-security", alimony : "alimony", rental : "rental", other : "other" } if (itm !== false) { itm.__pagetype = MAR.getOpt(pagenames, itm.type, false); pagelink = `#income-${itm.__pagetype}.${applicantnum}.${existingid}`; } let oc = function() { } let or = function(){ if (pagelink !== false) { mvc.go(pagelink); return; } let h = ""; h += `
    applicantnum : ${applicantnum}
    `; h += `
    uuid : ${uuid}
    `; h += `
    existingid : ${existingid}
    `; h += `
    page type : ${MAR.getOpt(itm, "__pagetype","")}
    `; h += `
    itm:${JSON.stringify(itm, null,4)}
    `; h += `
    incomeObj:${JSON.stringify(incomeObj, null,4)}
    `; $("#body-container").find(".result").html(h); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let h = ""; h += frm.htitle("Income details").render(); mar.pg_accesscontrollerfn = function() { return "open"; } let a = existingid; let incomes = itm; incomes._i = a; incomes._a = applicantnum; // incomes._t = income_editors(incomes.type, incomes); incomes.sys = incomes.sys; if ("displayName" in incomes == false || incomes.displayName == ""){ if ("name" in incomes) incomes.displayName = incomes.name } h += frm.elaine("What type of income is this?","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div if ("sug_total" in itm && num(itm.total) == 0) { incomes.total = num(itm.sug_total); } incomes.per = " / month "; var io = new IncomeObj(incomes); h += io.render(); let displayed = false; let _button = false; // itm.sug_type = "w2"; // itm.sug_text = "w2 employment"; if ("sug_type" in itm) { h += "
    "; // h += `
    We think this is ${itm.sug_type} // ${itm.sug_text}
    `; h += "
    "; // h += "
    This is W2"+ // "No it is not
    "; if (itm.sug_type == "w2") { VAL = ""; h += frm.radio("suggestion_option",`Is your employment at ${itm.name} `,VAL,"","",function(){ let so = radio("suggestion_option"); if (so == "Y") incomeButtonClick(false,"w2") if (so == "N") incomeButtonClick(false,"open"); },{ Y : `W2`, N : "Other" }).render(); _button = true; } if (itm.sug_type == "alimony") { VAL = ""; h += frm.radio("suggestion_option",`Is this income `,VAL,"","",function(){ let so = radio("suggestion_option"); if (so == "Y") incomeButtonClick(false,"alimony") if (so == "N") incomeButtonClick(false,"open"); },{ Y : "Alimony", N : "Other" }).render(); _button = true; } if (itm.sug_type == "pension") { VAL = ""; h += frm.radio("suggestion_option",`Is this income `,VAL,"","",function(){ let so = radio("suggestion_option"); if (so == "Y") incomeButtonClick(false,"pension") if (so == "N") incomeButtonClick(false,"open"); },{ Y : "Pension", N : "Other" }).render(); _button = true; } if (itm.sug_type == "ssec") { VAL = ""; h += frm.radio("suggestion_option",`Is this income `,VAL,"","",function(){ let so = radio("suggestion_option"); if (so == "Y") incomeButtonClick(false,"ssec") if (so == "N") incomeButtonClick(false,"open"); },{ Y : "Social Security", N : "Other" }).render(); _button = true; } if (itm.sug_type == "other") { } if (itm.sug_type == "w2-previous") { VAL = ""; h += frm.radio("suggestion_option",`Is this employment at ${itm.name}`,VAL,"","",function(){ let so = radio("suggestion_option"); if (so == "Y") incomeButtonClick(false,"w2-previous") if (so == "N") incomeButtonClick(false,"open"); },{ Y : "A previous employment", N : "Other" }).render(); _button = true; } if (itm.sug_type == "llc") { VAL = ""; h += frm.radio("suggestion_option",`Is this employment at ${itm.name}`,VAL,"","",function(){ let so = radio("suggestion_option"); if (so == "Y") incomeButtonClick(false,"selfemployed") if (so == "N") incomeButtonClick(false,"open"); },{ Y : "Self Employed (LLC / 1099)", N : "Other" }).render(); _button = true; } if (itm.sug_type == "k1") { VAL = ""; h += frm.radio("suggestion_option",`Is this employment at ${itm.name}`,VAL,"","",function(){ let so = radio("suggestion_option"); if (so == "Y") incomeButtonClick(false,"corporation") if (so == "N") incomeButtonClick(false,"open"); },{ Y : "Corporation income", N : "Other" }).render(); _button = true; } h += "
    " // reveal - end } if (_button === true) { h += "
    "; h += `
    Please select an employment type below
    `; } else { h += "
    "; } if (displayed === false) { h += "
    " + "
    "+$("#svg_w2_icon_income").html()+"W2
    " + "
    "+$("#svg_llc_icon_income").html()+"Self Employed
    " + "
    "+$("#svg_corporation_icon_income").html()+"Corporation
    " + // "
    "+$("#svg_corporation_icon_income").html()+"Corporation
    " + "
    "; h += "
    " + "
    "+$("#svg_ira_and_401k_icon_assets").html()+"Pension
    " + "
    "+$("#svg_emd_icon_assets").html()+"Disability
    " + "
    "+$("#svg_irs_tax_icon_liabilities").html()+"Social Security
    " + "
    "; h += "
    " + "
    "+$("#svg_child_support_icon_income").html()+"Child Support
    " + "
    "+$("#svg_alimony_icon_income").html()+"Alimony
    " + "
    "+$("#svg_rental_icon_income").html()+"Rental
    " + "
    "; h += "
    Other
    "; h += "
    Previous Employment
    "; } h += "
    " h += "
    "; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ return mar.tip(".help-button","warning","Please make a choice from the options.","top"); }),"close",frm.addfunction(function(){ }),"mar.help()"); h = Mustache.render(h,localopts); let pagenames = { // w2 : "w2", // with wizard w2 : "w2manual", "w2-previous" : "w2-previous", DD1099 : "DD1099", llc : "llc", k1 : "k1", pension : "pension", child : "child-support", dis : "disability", ssec : "social-security", alimony : "alimony", rental : "rental", other : "other" } let incomeButtonClick = function(e,gto){ console.log('pressed icon button e: ',e); let goto = ""; if (arguments.length > 1) { goto = gto; } else { let $elm = $(e.currentTarget); goto = $elm.data("goto"); if ($elm.hasClass("swal")) swal.close(); } console.warn('goto : '+goto); if (goto && goto == "open") { $(".maindv").slideDown(function(){ $(".maindv").removeClass("x-hide").removeClass("x-revealdiv").css("display",""); $("#body-container").scrollTo("max",200); // $("#sug_div").fadeOut("fast",function(){ // $("#sug_div").remove(); // // }) }); // $(".maindv").removeClass("x-hide"); return; } if (goto && goto == "selfemployed") { let h = ""; h += ""; h += "
    "; h += frm.htitle("Self Employed Income").render(); h += "
    How does your business file taxes?
    " // h += "Which type of Self Employed
    income are you adding?"; //h += frm.elaine("Which type of Self Employed income are you adding?","").render(); h += "
    "; h += "
    " + "
    "+$("#svg_w2_icon_income").html()+"Sole Proprietor
    1099
    " + // "
    "+$("#svg_corporation_icon_income").html()+"Corporation
    " + "
    "+$("#svg_llc_icon_income").html()+"Business Owner
    LLC
    " + "
    "; h += "
    "; h += "
    "; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = h; swal({ //title : "Self Employed Income Type", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "BACK" } }) .then((act) => { }); $(".incomeIcons_button.swal").on('click', incomeButtonClick) return; } if (goto && goto == "corporation") { let h = ""; h += "
    "; h += frm.htitle("Corporate Income").render(); h += "
    How does your business file taxes?
    " // h += "Which type of Self Employed
    income are you adding?"; //h += frm.elaine("Which type of Self Employed income are you adding?","").render(); h += "
    "; h += "
    " + "
    "+$("#svg_corporation_icon_income").html()+"S-CORP
    1120S
    " + "
    "+$("#svg_corporation_icon_income").html()+"C-CORP
    1120
    " + "
    "+$("#svg_llc_icon_income").html()+"PARTNERSHIP
    1065
    " + "
    "; h += "
    "; h += "
    "; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = h; swal({ //title : "Self Employed Income Type", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "BACK" } }) .then((act) => { }); $(".incomeIcons_button.swal").on('click', incomeButtonClick) return; } if (goto && goto == "k1") { mar._ctype = "c"; } if (goto && goto == "scorp") { mar._ctype = "s"; goto = "k1"; } if (goto && goto == "partnership") { mar._ctype = "p"; goto = "k1"; } if (goto && goto != "") { mvc.go("#income-"+pagenames[goto]+"."+applicantnum+"."+p3); } }; let oc = function() { } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#body-container .incomeIcons_button").on('click', incomeButtonClick) $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-w2"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"w2",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let h = ""; h += frm.htitle("Connect to System").render(); h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ mvc.go("#income-w2manual"+"."+applicantnum); }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ mar.importw2_fn = function(da,name) { da.system = name; mar.defaultw2 = da; mvc.go("#income-w2manual"+"."+applicantnum); swal.close(); } // mar.three_panel_pane.init(); // // mar.payrollPressFn = function(e) { // // //console.log('pressed icon button e: ',e); // let $elm = $(e); // let goto = $elm.data("goto"); // let imgsrc = $elm.data("imgsrc"); // let displayname = $elm.data("displayname"); // //console.log('goto : '+goto); // // //mar.chosenBank = {id:goto, displayName:pagenames[goto]}; // // if (goto && goto != "") { // //mar. // //mvc.go("#assets-"+pagenames[goto]); // // // // let chosenBank = {id:goto, displayName: displayname}; // // let h = ""; // h += "
    "; // h += "
    "; // h += "
    "; // h += "
    "; // h += "
    "; // // // h += "
    "; // h += ""; // h += "
    "; // // h += "
    "; // h += "Sign In"; // h += "
    "; // // h += "
    "; // h += "Please enter your credentials for "+chosenBank.displayName+" "; // h += "
    "; // // //note: these need to be dynamic and generated by the api // h += "
    "; // h += "User name for "+chosenBank.displayName+" "; // h += "
    "; // // h += "
    "; // h += ""; // h += "
    "; // // // // h += "
    "; // h += "Password for "+chosenBank.displayName+" "; // h += "
    "; // // h += "
    "; // h += ""; // h += "
    "; // // // h += "
    Continue
    "; // h += "
    "; // // // h += "
    ";//end account verification // h += "
    ";//end pane // h += "
    "; // h += "
    "; // h += "
    ";//end pane // h += "
    ";//end pane // h += "
    ";//end three pannel inner tab // h += "
    ";//end three pannel inner // h += "
    ";//end three pannel // // // // // // //launch the overlay // // var s = document.createElement("div"); // s.setAttribute("class","normal-form"); // // /* // s.innerHTML = ""+ // frm.htitle("Please choose your bank").render()+ // "
    "+ // // $("#svg_plaid_logo").html()+ // "
    "+ // "
    "+ // "PLAID LINK here? "+ // "
    "; // */ // // s.innerHTML = h; // // // // swal({ // //title : "Same line of work", // className : "midelinfopopupOneButton", // content : s, // buttons : { // cancel : "CANCEL" // // } // }); // } // } $.get("/api/payrolsystems/list", function(d){ if (d) { let h = ""; h += "
    "; for (let i=0; i < d.length; i++) { let _d = d[i]; if (i%2 == 0) h += "
    "; h += "
    " + "
    "; if (i%2 == 1) h += "
    "; } h += "
    "; h += "
    "; h += "
    "; h += ''; h += "
    "; $(".docFolderSubBtmArea_wrapper").html(h); } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); }) } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.tmp_pg_overblock = function(itm){ let overblock = ""; let incometypes = ["w2","DD1099","llc","k1"]; let other_incometypes = ["pension","ssec","dis","child","alimony","rental","other"]; let type = MAR.getOpt(itm, "type", ""); let other = (other_incometypes.indexOf(type) > -1); overblock += ``; overblock += ``; overblock += ``; overblock += ``; mar.tmp_pg_update_encompass_sw = function(txt, end_text) { let $loc = $(".loadingoverlaycustom"); if ($loc.length > 0) { if (txt === null) { $("body").LoadingOverlay("hide",true); } else { $loc.find(".msg").html(txt); } } else { $("body").LoadingOverlay("show", { image : "", custom : $(`
    `+ `
    ${txt}
    `+ `
    `+ `
    `) }); } }; mar.tmp_pg_update_encompass_itm = itm; mar.tmp_pg_update_encompass = async function() { let itm = mar.tmp_pg_update_encompass_itm; let sw = mar.tmp_pg_update_encompass_sw; if (other) { let _itm = {}; _itm.over_base = num(txt("#over_base")); _itm.over_total = num(txt("#over_base")); _itm.over = "Y"; MAR.income.setByUUID(itm.uuid, _itm); mar.fakesave(); let A = MAR.income.getByUUID(itm.uuid, true); let ssn = MAR.applicants.getSSN(A.appl); let script = []; script.push(`applicant ${ssn}`); script.push(`set job ${itm.uuid} monthlyAmount int ${num(txt("#over_base"))}`); script.push(`save`); sw("Uploading to Encompass"); let rv = await mar.socket.send_and_receiveSync("app-execute-encompass-script", {appid:mar.ID, script:script.join("\n")}); sw("Uploaded to Encompass"); await MAR.api.sleepSync(1000); sw(null) } else { let _itm = {}; _itm.over_base = num(txt("#over_base")); _itm.over_commission = num(txt("#over_commission")); _itm.over_bonus = num(txt("#over_bonus")); _itm.over_overtime = num(txt("#over_overtime")); _itm.over_other = num(txt("#over_other")); _itm.over_total = num(txt("#over_base")) + num(txt("#over_commission")) + num(txt("#over_bonus")) + num(txt("#over_overtime")) + num(txt("#over_other"));; _itm.over = "Y"; MAR.income.setByUUID(itm.uuid, _itm); mar.fakesave(); let A = MAR.income.getByUUID(itm.uuid, true); let ssn = MAR.applicants.getSSN(A.appl); let script = []; script.push(`applicant ${ssn}`); script.push(`set job ${itm.uuid} basePayAmount int ${num(txt("#over_base"))}`); script.push(`set job ${itm.uuid} bonusAmount int ${num(txt("#over_bonus"))}`); script.push(`set job ${itm.uuid} commissionsAmount int ${num(txt("#over_commission"))}`); script.push(`set job ${itm.uuid} overtimeAmount int ${num(txt("#over_overtime"))}`); script.push(`set job ${itm.uuid} otherAmount int ${num(txt("#over_other"))}`); script.push(`save`); sw("Uploading to Encompass"); let rv = await mar.socket.send_and_receiveSync("app-execute-encompass-script", {appid:mar.ID, script:script.join("\n")}); sw("Uploaded to Encompass"); await MAR.api.sleepSync(500); sw(null) } } if (mar.WE_ARE_FROM_LOI === true) { overblock += `
    This income has been overridden with the following values
    `; if (other) { overblock += ``+ `
    `+ `
    Monthly
    `+ `
    `+ ``+ `
    `; } else { overblock += ``+ `
    `+ `
    Base
    `+ `
    `+ ``+ `
    `; overblock += ``+ `
    `+ `
    Commission
    `+ `
    `+ ``+ `
    `; overblock += ``+ `
    `+ `
    Bonus
    `+ `
    `+ ``+ `
    `; overblock += ``+ `
    `+ `
    Overtime
    `+ `
    `+ ``+ `
    `; overblock += ``+ `
    `+ `
    Other
    `+ `
    `+ ``+ `
    `; } if (MAR.appnav.loanWasSubmitted()) { overblock += ``+ `
    `+ ``+ `
    `; } overblock += "
    "; overblock += "
    "; return overblock; } overblock += `
    This income has been overridden with the following values
    `; MAR.ifOpt(itm, "over_base", function(val){ overblock += ``+ `
    `+ `
    Base
    `+ `
    `+ `${ elaineui.format("cur2_just",val)}`+ `
    `; }); MAR.ifOpt(itm, "over_commission", function(val){ if (num(val) > 0) { overblock += ``+ `
    `+ `
    Commission
    `+ `
    `+ `${ elaineui.format("cur2_just",val)}`+ `
    `; } }); MAR.ifOpt(itm, "over_bonus", function(val){ if (num(val) > 0) { overblock += ``+ `
    `+ `
    Bonus
    `+ `
    `+ `${ elaineui.format("cur2_just",val)}`+ `
    `; } }); MAR.ifOpt(itm, "over_overtime", function(val){ if (num(val) > 0) { overblock += ``+ `
    `+ `
    Overtime
    `+ `
    `+ `${ elaineui.format("cur2_just",val)}`+ `
    `; } }); MAR.ifOpt(itm, "over_other", function(val){ if (num(val) > 0) { overblock += ``+ `
    `+ `
    Other
    `+ `
    `+ `${ elaineui.format("cur2_just",val)}`+ `
    `; } }); MAR.ifOpt(itm, "over_total", function(val){ if (num(val) > 0) { overblock += ``+ `
    `+ `
    Total
    `+ `
    `+ `${ elaineui.format("cur2_just",val)}`+ `
    `; } }); overblock += "
    " overblock += "
    " // // // let h = ""; // h += `
    Highest Possible Purchase Price
    `+ // `
    `+ // `
    Est. Purchase price
    `+ // `
    `+ // `${ mar.fmt.currency(parseInt(m.purchase_price,10))}`+ // `
    `+ // `
    `+ // `
    Est. Closing cost
    `+ // `
    ${warning1}`+ // `${ mar.fmt.currency(parseInt(m.c2c,10))}
    `+ // `
    `+ // `
    Est. Budget
    `+ // `
    ${warning}`+ // ` ${ mar.fmt.currency(parseInt(m.budget,10))}`+ // `
    `+ // `

    `; return overblock } mar.pg["income-w2manual"] = (function(){ var VAL = ''; var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"w2",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let employeraddress = false; let needsVerification = false; if (itm != false) { employeraddress = MAR.getBucket("/income/address/"+itm.uuid); needsVerification = (MAR.getOpt(itm, "verified", "") === "N"); } let taxyear_c = MAR.getApplicantLastTaxYear(applicantnum); let taxyear_p = MAR.getApplicantLastTaxYear(applicantnum)-1; let taxyear_pp = MAR.getApplicantLastTaxYear(applicantnum)-2; let year_c = MAR.getCurrentYear(); let year_p = MAR.getCurrentYear()-1; let year_pp = MAR.getCurrentYear()-2; /** * standard starting block - END */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { (function(){ let tot = 0; tot += num(itm.income_w2_base) if (MAR.getOpt(itm, "salary_overtime") === "Y") tot += num(itm[`income_w2_overtime_${year_c}`]); if (MAR.getOpt(itm, "salary_commission") === "Y") tot += num(itm[`income_w2_commission_${year_c}`]); if (MAR.getOpt(itm, "salary_bonus") === "Y") tot += num(itm[`income_w2_bonus_${year_c}`]); if (MAR.getOpt(itm, "salary_other") === "Y") tot += num(itm[`income_w2_other_${year_c}`]); if (tot == 0) { itm.income_w2_base = num(itm.sug_total); } })() } let h = ""; let edit_link = ""; mar.state.after_employer = false; mar.state.before_employer = false; if (!employeraddress || needsVerification) { } else { edit_link += "Employer details"; } // h += "
    " + JSON.stringify(employeraddress)+"
    "; h += frm.htitle("Employer"+edit_link).render(); /** * block for overrides */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { mar.pg_accesscontrollerfn = function() { return "open"; } } let overridden = (itm && MAR.getOpt(itm, "over", "") === "Y"); if (overridden) { h += mar.tmp_pg_overblock(itm); } /** * end block */ // let overridden = (itm && MAR.getOpt(itm, "over", "") === "Y"); // // if (overridden) { // let overblock = ""; // overblock += `
    This income has been overridden with the following values
    `; // // MAR.ifOpt(itm, "over_base", function(val){ // overblock += ``+ // `
    `+ // `
    Base
    `+ // `
    `+ // `${ elaineui.format("cur_just",val)}`+ // `
    `; // }); // MAR.ifOpt(itm, "over_commission", function(val){ // if (num(val) > 0) { // overblock += ``+ // `
    `+ // `
    Commission
    `+ // `
    `+ // `${ elaineui.format("cur_just",val)}`+ // `
    `; // } // }); // MAR.ifOpt(itm, "over_bonus", function(val){ // if (num(val) > 0) { // overblock += ``+ // `
    `+ // `
    Bonus
    `+ // `
    `+ // `${ elaineui.format("cur_just",val)}`+ // `
    `; // } // // }); // MAR.ifOpt(itm, "over_overtime", function(val){ // if (num(val) > 0) { // overblock += ``+ // `
    `+ // `
    Overtime
    `+ // `
    `+ // `${ elaineui.format("cur_just",val)}`+ // `
    `; // } // }); // MAR.ifOpt(itm, "over_other", function(val){ // if (num(val) > 0) { // overblock += ``+ // `
    `+ // `
    Other
    `+ // `
    `+ // `${ elaineui.format("cur_just",val)}`+ // `
    `; // } // }); // MAR.ifOpt(itm, "over_total", function(val){ // if (num(val) > 0) { // overblock += ``+ // `
    `+ // `
    Total
    `+ // `
    `+ // `${ elaineui.format("cur_just",val)}`+ // `
    `; // } // }); // // overblock += "
    " // overblock += "
    " //// //// //// let h = ""; //// h += `
    Highest Possible Purchase Price
    `+ //// `
    `+ //// `
    Est. Purchase price
    `+ //// `
    `+ //// `${ mar.fmt.currency(parseInt(m.purchase_price,10))}`+ //// `
    `+ //// `
    `+ //// `
    Est. Closing cost
    `+ //// `
    ${warning1}`+ //// `${ mar.fmt.currency(parseInt(m.c2c,10))}
    `+ //// `
    `+ //// `
    Est. Budget
    `+ //// `
    ${warning}`+ //// ` ${ mar.fmt.currency(parseInt(m.budget,10))}`+ //// `
    `+ //// `

    `; // // // // // h += overblock; // // } h += frm.elaine("Tell me about your current job. Only add one job at a time.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div h += "
    What is the name of your employer?
    "; VAL = (itm) ? itm.name : ''; if (VAL == "" && "defaultw2" in mar && mar.defaultw2.name != "") VAL = mar.defaultw2.name; h += frm.txt("name","",VAL,"e.g. Walmart","",function(){}).render(); h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.salary_choice : ''; if (VAL == "" && "defaultw2" in mar && mar.defaultw2.pay_freq != "") VAL = mar.defaultw2.pay_freq; let FREQ = VAL; h += frm.radio("salary_choice","How do you get paid?",VAL,"","",function(){ oc(); reveal({ max : "income_w2_base" }); },{ hourly : "Hourly", weekly : "Weekly", biweekly : "Bi-Weekly", monthly : "Monthly", semimonthly : "Semi Monthly", yearly : "Yearly" }).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) let HIDE = ""; HIDE = (FREQ == "hourly") ? "x-hide" : ""; h += (function(){ let h = ""; VAL = (itm) ? itm.income_w2_base : ''; if (VAL == "" && "defaultw2" in mar && "pay_amount" in mar.defaultw2) VAL = mar.defaultw2.pay_amount; if (VAL == "") VAL = "10000"; h += frm.slider("income_w2_base","Your Salary:",VAL,"","",function(){ }, { v00 : '0', v50 : '30', v50_inc : '2', v75 : '100', v75_inc : '5', v100 : '500', v100_inc : '100', start_val : '50' }).render(); return h; })().wrap(`
    `,"
    "); HIDE = (FREQ == "hourly") ? "" : "x-hide"; h += (function(){ let h = ""; h += "
    "; VAL = (itm) ? Math.floor(num(itm.income_w2_base)) : '0'; h += frm.slider("dollars","Dollars:",VAL,"","",function(){ }, { v00 : '0', v50 : '30', v50_inc : '1', v75 : '100', v75_inc : '5', v100 : '500', v100_inc : '100', start_val : '50', formatting_class : '_dollars' }).render(); h += "
    "; h += "
    "; VAL = (itm) ? Math.floor((num(itm.income_w2_base) - Math.floor(num(itm.income_w2_base)))*100) : '0'; h += frm.slider("cents","Cents:",VAL,"","",function(){ }, { v00 : '0', v50 : '50', v50_inc : '1', v75 : '75', v75_inc : '1', v100 : '100', v100_inc : '1', start_val : '0', formatting_class : '_cents' }).render(); h += "
    "; return h; })().wrap(`
    `,"
    "); h += "
    " // reveal - end /////// h += "
    "; // reveal - start (with validation t h += frm.hr().render(); VAL = (itm) ? itm.salary_3yearquestion : ''; let VAL_salary_3yearquestion = VAL; h += frm.yn3("salary_3yearquestion","Have you been at this job for more than 2 years?",VAL,"","",function(){ if ($("#overtimeQuestionHolder").hasClass("x-revealdiv") == false) { if(yn3("#salary_3yearquestion") == 'Y'){ $("#overtimeQuestionHolder").removeClass('x-hide'); $("#commissionQuestionHolder").removeClass('x-hide'); $("#bonusQuestionHolder").removeClass('x-hide'); $("#otherQuestionHolder").removeClass('x-hide'); } else if(yn3("#salary_3yearquestion") == 'N'){ yn3("#salary_overtime","N"); $("#salary_overtime").change(); $("#overtimeQuestionHolder").addClass('x-hide'); $("#overtimeHolder").addClass('x-hide'); yn3("#salary_commission","N"); $("#salary_commission").change(); $("#commissionQuestionHolder").addClass('x-hide'); $("#commissionHolder").addClass('x-hide'); yn3("#salary_bonus","N"); $("#salary_bonus").change(); $("#bonusQuestionHolder").addClass('x-hide'); $("#bonusHolder").addClass('x-hide'); $("#otherQuestionHolder").addClass('x-hide'); $("#otherHolder").addClass('x-hide'); } // $("#body-container").scrollTo("max",200); } else { if(yn3("#salary_3yearquestion") == 'N'){ $("#overtimeQuestionHolder").removeClass("x-revealdiv"); $("#bonusQuestionHolder").removeClass("x-revealdiv"); $("#otherQuestionHolder").removeClass("x-revealdiv"); $("#commissionQuestionHolder").removeClass("x-revealdiv"); } } oc(); reveal({ max : "salary_overtime" }); },{}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += "
    When did you start this job?
    "; VAL = (itm) ? itm.fromd : ''; h += frm.txt("fromd","",VAL,"","",function(){}, 'date').render(); //frm.txt = function(variable, title, val, hint, Class,onchange,type) { h += "
    " // reveal - end ////// let start_month = 3; // start_month = 0; /* test */ let hideclass = (VAL_salary_3yearquestion == "N") ? "x-hide" : ""; h += (function(){ let h = ""; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.salary_overtime : ''; h += frm.yn3("salary_overtime","Do you also get overtime?",VAL,"","",function(){ if(yn3("#salary_overtime") == 'Y'){ $("#overtimeHolder").removeClass('x-hide'); } else { $("#overtimeHolder").addClass('x-hide'); } reveal({ max : "income_w2_overtime_2016" }); // $("#body-container").scrollTo("max",200); },{}).render(); h += "
    " // reveal - end if (VAL == "Y") { h += "
    "; // reveal - start (with validation to previous field) } else { h += "
    "; // reveal - start (with validation to previous field) } mar.tmp_ytd_calc_fn = function(){ let m = num(txt("#ytd_m")); let v = num(txt("#_ytd")); let t = ~~((v/m)*12); $("#ytd_total").html(elaineui.format("cur",t)); } mar.tmp_ytd_calc = function(elm){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); let m = 1; let fact = (m/12); let VAL = 0; let _slider = frm.slider(`_ytd`,`I have earned:`,VAL,"","",function(){ mar.tmp_ytd_calc_fn(); }, { v00 : '0', v50 : `${~~(20000*fact)}`, v50_inc : `${~~(200*fact)}`, v75 : `${~~(100000*fact)}`, v75_inc : `${~~(5000*fact)}`, v100 : `${~~(200000*fact)}`, v100_inc : `${~~(10000*fact)}`, start_val : '10000' }).render(); s.innerHTML = ""+ "
    "+ "
    Year to date calculator
    "+ "
    "+ "
    "+ "Up until:"+ ". "+ "
    "+ "
    "+ `
    ${_slider}
    ` + "
    "+ "
    "+ "
    Estimated total:
    "+ "
    "+ "
    "+ "
    "+ ""; setTimeout(function(){ $(".ytd_div").find(".xx-slider").myslider(); },500) swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "Cancel", call : { text: "Use", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { txt(`#${elm}`, $("#ytd_total").html()); $(`#${elm}`).change(); swal.close(); } }); }; (function(){ VAL = (itm) ? itm[`income_w2_overtime_${year_c}`] : '0'; h += ``; if (new Date().getMonth() < start_month) { return; } mar.tmp_ytd_calc__ot_fn = function() { let M = txt("#income_w2_overtime_lastpay"); if (M === "") return; let m = new Date(M).getMonth(); m += ~~((new Date(M).getDate()/31) * 4)*0.25; let v = num(txt("#income_w2_overtime_ytd")); let t = ~~((v/m)*12); txt(`#income_w2_overtime_${year_c}`,t); $(`#income_w2_overtime_${year_c}`).change(); } let m = 1; let fact = (m/12); fact = 1; VAL = (itm) ? itm[`income_w2_overtime_ytd`] : '0'; h += frm.slider(`income_w2_overtime_ytd`,`Total Year-To-Date:`,VAL,"","",function(){ mar.tmp_ytd_calc_ot_fn(); }, { v00 : '0', v50 : `${~~(20000*fact)}`, v50_inc : `${~~(200*fact)}`, v75 : `${~~(100000*fact)}`, v75_inc : `${~~(5000*fact)}`, v100 : `${~~(200000*fact)}`, v100_inc : `${~~(10000*fact)}`, start_val : '10000' }).render(); h += `
    Date of last paystub
    `; VAL = (itm) ? MAR.getOpt(itm, "income_w2_overtime_lastpay", "") : ""; h += frm.txt("income_w2_overtime_lastpay","",VAL,"","",function(){ mar.tmp_ytd_calc_ot_fn(); }, "date").render(); })(); // VAL = (itm) ? itm[`income_w2_overtime_${year_c}`] : '1000'; // h += frm.slider(`income_w2_overtime_${year_c}`,`Expected total in ${year_c} Calculate from YTD`,VAL,"","",function(){ // }, { // v00 : '0', // v50 : '20000', // v50_inc : '200', // v75 : '100000', // v75_inc : '5000', // v100 : '200000', // v100_inc : '10000', // start_val : '10000' // }).render(); VAL = (itm) ? itm[`income_w2_overtime_${year_p}`] : '1000'; h += frm.slider(`income_w2_overtime_${year_p}`,`Total in ${year_p}`,VAL,"","",function(){ }, { v00 : '0', v50 : '20000', v50_inc : '200', v75 : '100000', v75_inc : '5000', v100 : '200000', v100_inc : '10000', start_val : '10000' }).render(); VAL = (itm) ? itm[`income_w2_overtime_${year_pp}`] : '1000'; h += frm.slider(`income_w2_overtime_${year_pp}`,`Total in ${year_pp}`,VAL,"","",function(){ }, { v00 : '0', v50 : '20000', v50_inc : '200', v75 : '100000', v75_inc : '5000', v100 : '200000', v100_inc : '10000', start_val : '10000' }).render(); h += "
    " return h })() // commission h += (function(){ let h = ""; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.salary_commission : ''; h += frm.yn3("salary_commission","Do you also get commission?",VAL,"","",function(){ if(yn3("#salary_commission") == 'Y'){ $("#commissionHolder").removeClass('x-hide'); }else{ $("#commissionHolder").addClass('x-hide'); } // $("#body-container").scrollTo("max",200); reveal({ max : `income_w2_commission_${year_c}` }); },{}).render(); h += "
    " // reveal - end if (VAL == "Y") { h += "
    "; // reveal - start (with validation to previous field) } else { h += "
    "; // reveal - start (with validation to previous field) } (function(){ VAL = (itm) ? itm[`income_w2_commission_${year_c}`] : '0'; h += ``; if (new Date().getMonth() < start_month) { return; } mar.tmp_ytd_calc_com_fn = function() { let M = txt("#income_w2_commission_lastpay"); if (M === "") return; let m = new Date(M).getMonth(); m += ~~((new Date(M).getDate()/31) * 4)*0.25; let v = num(txt("#income_w2_commission_ytd")); let t = ~~((v/m)*12); txt(`#income_w2_commission_${year_c}`,t); $(`#income_w2_commission_${year_c}`).change(); } let m = 1; let fact = (m/12); fact = 1; VAL = (itm) ? itm[`income_w2_commission_ytd`] : '0'; h += frm.slider(`income_w2_commission_ytd`,`Total Year-To-Date:`,VAL,"","",function(){ mar.tmp_ytd_calc_com_fn(); }, { v00 : '0', v50 : `${~~(20000*fact)}`, v50_inc : `${~~(200*fact)}`, v75 : `${~~(100000*fact)}`, v75_inc : `${~~(5000*fact)}`, v100 : `${~~(200000*fact)}`, v100_inc : `${~~(10000*fact)}`, start_val : '10000' }).render(); h += `
    Date of last paystub
    `; VAL = (itm) ? MAR.getOpt(itm, "income_w2_commission_lastpay", "") : ""; h += frm.txt("income_w2_commission_lastpay","",VAL,"","",function(){ mar.tmp_ytd_calc_com_fn(); }, "date").render(); })(); VAL = (itm) ? itm[`income_w2_commission_${year_p}`] : '1000'; h += frm.slider(`income_w2_commission_${year_p}`,`Total in ${year_p}`,VAL,"","",function(){ }, { v00 : '0', v50 : '20000', v50_inc : '200', v75 : '100000', v75_inc : '5000', v100 : '200000', v100_inc : '10000', start_val : '10000' }).render(); VAL = (itm) ? itm[`income_w2_commission_${year_pp}`] : '1000'; h += frm.slider(`income_w2_commission_${year_pp}`,`Total in ${year_pp}`,VAL,"","",function(){ }, { v00 : '0', v50 : '20000', v50_inc : '200', v75 : '100000', v75_inc : '5000', v100 : '200000', v100_inc : '10000', start_val : '10000' }).render(); h += "
    " return h })() // bonus h += (function(){ let h = ""; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.salary_bonus : ''; h += frm.yn3("salary_bonus","Do you also get bonuses?",VAL,"","",function(){ if(yn3("#salary_bonus") == 'Y'){ $("#bonusHolder").removeClass('x-hide'); }else{ $("#bonusHolder").addClass('x-hide'); } // $("#body-container").scrollTo("max",200); reveal({ max : `income_w2_bonus_${year_c}` }); },{}).render(); h += "
    " // reveal - end if (VAL == "Y") { h += "
    "; // reveal - start (with validation to previous field) } else { h += "
    "; // reveal - start (with validation to previous field) } (function(){ VAL = (itm) ? itm[`income_w2_bonus_${year_c}`] : '0'; h += ``; if (new Date().getMonth() < start_month) { return; } mar.tmp_ytd_calc_bon_fn = function() { let M = txt("#income_w2_bonus_lastpay"); if (M === "") return; let m = new Date(M).getMonth(); m += ~~((new Date(M).getDate()/31) * 4)*0.25; let v = num(txt("#income_w2_bonus_ytd")); let t = ~~((v/m)*12); txt(`#income_w2_bonus_${year_c}`,t); $(`#income_w2_bonus_${year_c}`).change(); } let m = 1; let fact = (m/12); fact = 1; VAL = (itm) ? itm[`income_w2_bonus_ytd`] : '0'; h += frm.slider(`income_w2_bonus_ytd`,`Total Year-To-Date:`,VAL,"","",function(){ mar.tmp_ytd_calc_bon_fn(); }, { v00 : '0', v50 : `${~~(20000*fact)}`, v50_inc : `${~~(200*fact)}`, v75 : `${~~(100000*fact)}`, v75_inc : `${~~(5000*fact)}`, v100 : `${~~(200000*fact)}`, v100_inc : `${~~(10000*fact)}`, start_val : '10000' }).render(); h += `
    Date of last paystub
    `; VAL = (itm) ? MAR.getOpt(itm, "income_w2_bonus_lastpay", "") : ""; h += frm.txt("income_w2_bonus_lastpay","",VAL,"","",function(){ mar.tmp_ytd_calc_bon_fn(); }, "date").render(); })(); VAL = (itm) ? itm[`income_w2_bonus_${year_p}`] : '1000'; h += frm.slider(`income_w2_bonus_${year_p}`,`Total in ${year_p}`,VAL,"","",function(){ }, { v00 : '0', v50 : '20000', v50_inc : '200', v75 : '100000', v75_inc : '5000', v100 : '200000', v100_inc : '10000', start_val : '10000' }).render(); VAL = (itm) ? itm[`income_w2_bonus_${year_pp}`] : '1000'; h += frm.slider(`income_w2_bonus_${year_pp}`,`Total in ${year_pp}`,VAL,"","",function(){ }, { v00 : '0', v50 : '20000', v50_inc : '200', v75 : '100000', v75_inc : '5000', v100 : '200000', v100_inc : '10000', start_val : '10000' }).render(); h += "
    " return h })() // other h += (function(){ let h = ""; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.salary_other: ''; h += frm.yn3("salary_other","Do you also get other income e.g. tips?",VAL,"","",function(){ if(yn3("#salary_other") == 'Y'){ $("#otherHolder").removeClass('x-hide'); }else{ $("#otherHolder").addClass('x-hide'); } // $("#body-container").scrollTo("max",200); reveal({ max : `income_w2_other_${year_c}` }); },{}).render(); h += "
    " // reveal - end if (VAL == "Y") { h += "
    "; // reveal - start (with validation to previous field) } else { h += "
    "; // reveal - start (with validation to previous field) } (function(){ VAL = (itm) ? itm[`income_w2_other_${year_c}`] : '0'; h += ``; if (new Date().getMonth() < start_month) { return; } mar.tmp_ytd_calc_oth_fn = function() { let M = txt("#income_w2_other_lastpay"); if (M === "") return; let m = new Date(M).getMonth(); m += ~~((new Date(M).getDate()/31) * 4)*0.25; let v = num(txt("#income_w2_other_ytd")); let t = ~~((v/m)*12); txt(`#income_w2_other_${year_c}`,t); $(`#income_w2_other_${year_c}`).change(); } let m = 1; let fact = (m/12); fact = 1; VAL = (itm) ? itm[`income_w2_other_ytd`] : '0'; h += frm.slider(`income_w2_other_ytd`,`Total Year-To-Date:`,VAL,"","",function(){ mar.tmp_ytd_calc_oth_fn(); }, { v00 : '0', v50 : `${~~(20000*fact)}`, v50_inc : `${~~(200*fact)}`, v75 : `${~~(100000*fact)}`, v75_inc : `${~~(5000*fact)}`, v100 : `${~~(200000*fact)}`, v100_inc : `${~~(10000*fact)}`, start_val : '10000' }).render(); h += `
    Date of last paystub
    `; VAL = (itm) ? MAR.getOpt(itm, "income_w2_other_lastpay", "") : ""; h += frm.txt("income_w2_other_lastpay","",VAL,"","",function(){ mar.tmp_ytd_calc_oth_fn(); }, "date").render(); })(); VAL = (itm) ? itm[`income_w2_other_${year_p}`] : '1000'; h += frm.slider(`income_w2_other_${year_p}`,`Total in ${year_p}`,VAL,"","",function(){ }, { v00 : '0', v50 : '20000', v50_inc : '200', v75 : '100000', v75_inc : '5000', v100 : '200000', v100_inc : '10000', start_val : '10000' }).render(); VAL = (itm) ? itm[`income_w2_other_${year_pp}`] : '1000'; h += frm.slider(`income_w2_other_${year_pp}`,`Total in ${year_pp}`,VAL,"","",function(){ }, { v00 : '0', v50 : '20000', v50_inc : '200', v75 : '100000', v75_inc : '5000', v100 : '200000', v100_inc : '10000', start_val : '10000' }).render(); h += "
    " return h })() h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.income_full_or_part : ''; let _SVAL = VAL h += frm.radio("income_full_or_part","Do you work 36 hours per week or more?",VAL,"","",function(){ if (radio("income_full_or_part") === "parttime") { if ($("#hours_per_week_div.x-revealdiv").length > 0) { reveal({ max : "hours_per_week", fn : function(){ txt("#hours_per_week",36); setTimeout(function(){$("#hours_per_week").change();},200); } }); } else { $("#hours_per_week_div").removeClass("x-hide"); txt("#hours_per_week",36); setTimeout(function(){$("#hours_per_week").change();},200); } } else { $("#hours_per_week_div").prop("class","x-hide"); txt("#hours_per_week",40); setTimeout(function(){$("#hours_per_week").change();},200); reveal({}); } },{ fulltime : "Yes - 36 hours per week or more", parttime : "No - less than 36 hours per week" }).render(); h += "
    " // reveal - end h += (function(){ let h = ""; VAL = (itm) ? itm.hours_per_week : '40'; if (num(VAL) == 0) VAL = "40"; h += frm.slider("hours_per_week","How many hours per week do you work?",VAL,"","",function(){ }, { v00 : '0', v50 : '20', v50_inc : '0.5', v75 : '30', v75_inc : '0.5', v100 : '40', v100_inc : '0.5', start_val : '40', formatting_class : '_hours' }).render(); return h; })().wrap("
    ","
    "); h += (function(){ let h = ""; VAL = (itm) ? MAR.getOpt(itm, "own_all_or_part", "N") : ''; let _SVAL = VAL h += frm.hr().render(); h += frm.yn3("own_all_or_part","Do you own all or more than 25% of this business?",VAL,"","",function(){ oc(); reveal({}) },{}).render(); return h; })().wrap("
    ","
    "); h += (function(){ let h = ""; VAL = (itm) ? MAR.getOpt(itm, "special_rel", "") : ''; let _SVAL = VAL h += frm.hr().render(); h += frm.yn3("special_rel","Are you employed by a family member, property seller, real estate agent, or other party to the transaction?",VAL,"","",function(){ oc(); reveal({}) },{}).render(); // if (yn3("#own_all_or_part") == "") { // mar.tip(".help-button","warning","You need to tell us if you own all or part of this business.","top"); // return; // } return h; })().wrap("
    ","
    "); h += "
    " // reveal - end let edit_ta = function(elm){ let VAL = $(elm).find("textarea").val() if ($("#swal-ta-div").length == 0) { $("body").append(``) } var s = document.createElement("div"); s.setAttribute("class","normal-form"); // s.innerHTML = ` `; s.innerHTML = ` `; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Cancel", call : { text: "Save", value: "yes", closeModal: false } } }) .then((act) => { if (act == "yes") { $(elm).find("textarea").val(txt("#swal-ta")) $(elm).find("div").html(txt("#swal-ta")) swal.close(); } else { swal.close(); } }); setTimeout(function(){ // var focusTextField = function(){ // console.log("focusElement"); // }; // // var onKeypressHandler = function(){ // console.log("* * * keypress event handler") // $('#swal-ta').blur().focus(); // }; // // var onClickHandler = function() { // $('.btn_abc').trigger('keypress'); // }; // // $('#swal-ta').bind('focus', focusTextField); // $('.btn_abc').bind('click', onClickHandler); // $('.btn_abc').bind('keypress', onKeypressHandler); // // $('.btn_abc').click(); // $("#swal-ta-input").click(function(){ // $(this).focus(); // }); // $("#swal-ta-input").focus(); $("#swal-ta").click(); },1000); return false; } VAL = (itm) ? itm.comments : ''; h += ``; // h += frm.hr().render(); // h += `
    LO/LOA Comments
    ${VAL}
    `; // h += "
    "; // reveal - start (with validation t // // h += frm.hr().render(); // // VAL = (itm) ? itm.salary_3yearquestion : ''; // // h += frm.yn3("salary_3yearquestion","Have you been at this job for more than 2 years?",VAL,"","",function(){ // oc(); // },{}).render(); // h += "
    " // reveal - end // // // h += "
    "; // reveal - start (with validation to previous field) // // // h += "
    When did you start this job?
    "; // // VAL = (itm) ? itm.fromd : ''; // h += frm.txt("fromd","",VAL,"","",function(){}, 'date').render(); // // //frm.txt = function(variable, title, val, hint, Class,onchange,type) { // // // h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ let reveal = function(options){ var val; if (radio("salary_choice") == "hourly") { txt("#income_w2_base",(num(txt("#dollars")) + (num(txt("#cents"))/100))) } let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let slide = function() { $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv").css("display",""); $("#body-container").scrollTo("max",200); $('#income_w2_base').change(); $('#dollars').change(); $('#cents').change(); if (options && "fn" in options) options.fn(); }); } let validation = $elm.data("validation"); if (validation) { if (validation == "name") { val = txt("#name"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the name of your employer.","top"); return; } } if (validation == "salary_choice") { val = radio("salary_choice"); console.warn(' value from slarary choice radio: '+val); if (val == '' ) { mar.tip(".help-button","warning","You need to tell us how to add up your salary.","top"); return; } } if (validation == "income_w2_base") { val = txt("#income_w2_base"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us how much salary you make.","top"); return; } } if (arguments.length > 0 && "max" in options && options.max == "income_w2_base") { if (validation == "salary_choice") { slide(); } return; } if (validation == "salary_3yearquestion") { if (yn3("#salary_3yearquestion") == "") { mar.tip(".help-button","warning","You need to tell us If you have been working here for more than 2 years.","top"); return; } } if (validation == "salary_3yearquestion") { if (yn3("#salary_3yearquestion") == "Y") { let two_years_ago = moment().quarter(moment().quarter()).subtract(8, 'Q').startOf('quarter').format("YYYY-MM-DD"); txt("#fromd",two_years_ago); $("#fromd_div").addClass("x-hide") } } if (yn3("#salary_3yearquestion") == "N") { if (validation == "fromd") { val = txt("#fromd"); if (val.trim().length == 0 || val == 'dd/mm/yyyy') { mar.tip(".help-button","warning","Please tell us when you started this job.","top"); return; } } } if (yn3("#salary_3yearquestion") == "Y") { if (validation == "salary_overtime") { val = txt("#salary_overtime"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us whether you get overtime.","top"); return; } val = txt("#salary_commission"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us whether you get commission.","top"); return; } val = txt("#salary_bonus"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us whether you get bonus.","top"); return; } } } if (validation == "income_full_or_part") { val = radio("income_full_or_part"); console.warn(' value income_full_or_part radio: '+val); if (val == '' ) { mar.tip(".help-button","warning","You need to tell us if you work full-time or part-time.","top"); return; } } if ($("#own_all_or_part_div").is(':visible') === true) { if (yn3("#own_all_or_part") == "") { mar.tip(".help-button","warning","You need to tell us if you own all or part of this business.","top"); return; } } if ($("#special_rel_div").is(':visible') === true) { if (yn3("#special_rel") == "") { mar.tip(".help-button","warning","You need to tell us if are employed by a party to the transaction.","top"); return; } } } slide(); // $elm.slideDown(function(){ // $elm.removeClass("x-hide").removeClass("x-revealdiv"); // $("#body-container").scrollTo("max",200); // $('#income_w2_base').change(); // // }); return; } return true; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var val; /** * validation & reveal block start */ // let $reveals = $(".x-revealdiv"); // if ($reveals.length > 0) { // let $elm = $($reveals[0]); // let validation = $elm.data("validation"); // if (validation) { // // if (validation == "name") { // val = txt("#name"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us the name of your employer.","top"); // return; // } // } // // if (validation == "salary_choice") { // val = radio("salary_choice"); // console.warn(' value from slarary choice radio: '+val); // if (val == '' ) { // mar.tip(".help-button","warning","You need to tell us how to add up your salary.","top"); // return; // } // // } // // // if (validation == "income_w2_base") { // val = txt("#income_w2_base"); // // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us how much salary you make.","top"); // return; // } // } // // if (validation == "salary_overtime") { // val = txt("#salary_overtime"); // // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us whether you get overtime or commission.","top"); // return; // } // } // // // // // if (validation == "income_full_or_part") { // val = radio("income_full_or_part"); // console.warn(' value income_full_or_part radio: '+val); // if (val == '' ) { // mar.tip(".help-button","warning","You need to tell us if you work full-time or part-time.","top"); // return; // } // } // // if (validation == "salary_3yearquestion") { // if (yn3("#salary_3yearquestion") == "Y") { // let two_years_ago = moment().quarter(moment().quarter()).subtract(6, 'Q').startOf('quarter').format("YYYY-MM-DD"); // txt("#fromd",two_years_ago); // $("#fromd_div").css("display","none"); // // } // } // // // if (yn3("#salary_3yearquestion") == "N") { // if (validation == "fromd") { // val = txt("#fromd"); // if (val.trim().length == 0 || val == 'dd/mm/yyyy') { // mar.tip(".help-button","warning","Please tell us when you started this job.","top"); // return; // } // } // } // // // } // // // $elm.slideDown(function(){ // $elm.removeClass("x-hide").removeClass("x-revealdiv"); // $("#body-container").scrollTo("max",200); // $('#income_w2_base').change(); // // }); // return; // } let ok_to_continue = reveal(); if (ok_to_continue !== true) return; /** * validation & reveal block end */ if (!existingid) { itm = {}; /** * only do this on the 1st time round */ itm.sys = ("defaultw2" in mar && mar.defaultw2.system != "") ? mar.defaultw2.system : "" } itm.type = "w2"; itm.name = txt("#name"); itm.salary_choice = radio("salary_choice"); itm.income_w2_base = txt("#income_w2_base"); itm.salary_overtime = yn3("#salary_overtime"); itm[`income_w2_overtime_${year_c}`] = txt(`#income_w2_overtime_${year_c}`); itm[`income_w2_overtime_${year_p}`] = txt(`#income_w2_overtime_${year_p}`); itm[`income_w2_overtime_${year_pp}`] = txt(`#income_w2_overtime_${year_pp}`); itm[`income_w2_overtime_lastpay`] = txt(`#income_w2_overtime_lastpay`); itm[`income_w2_overtime_ytd`] = txt(`#income_w2_overtime_ytd`); itm.salary_commission = yn3("#salary_commission"); itm[`income_w2_commission_${year_c}`] = txt(`#income_w2_commission_${year_c}`); itm[`income_w2_commission_${year_p}`] = txt(`#income_w2_commission_${year_p}`); itm[`income_w2_commission_${year_pp}`] = txt(`#income_w2_commission_${year_pp}`); itm[`income_w2_commission_lastpay`] = txt(`#income_w2_commission_lastpay`); itm[`income_w2_commission_ytd`] = txt(`#income_w2_commission_ytd`); itm.salary_bonus = yn3("#salary_bonus"); itm[`income_w2_bonus_${year_c}`] = txt(`#income_w2_bonus_${year_c}`); itm[`income_w2_bonus_${year_p}`] = txt(`#income_w2_bonus_${year_p}`); itm[`income_w2_bonus_${year_pp}`] = txt(`#income_w2_bonus_${year_pp}`); itm[`income_w2_other_lastpay`] = txt(`#income_w2_other_lastpay`); itm[`income_w2_other_ytd`] = txt(`#income_w2_other_ytd`); itm.salary_other = yn3("#salary_other"); itm[`income_w2_other_${year_c}`] = txt(`#income_w2_other_${year_c}`); itm[`income_w2_other_${year_p}`] = txt(`#income_w2_other_${year_p}`); itm[`income_w2_other_${year_pp}`] = txt(`#income_w2_other_${year_pp}`); itm[`income_w2_bonus_lastpay`] = txt(`#income_w2_bonus_lastpay`); itm[`income_w2_bonus_ytd`] = txt(`#income_w2_bonus_ytd`); itm.income_full_or_part = radio("income_full_or_part"); itm.salary_3yearquestion = yn3("#salary_3yearquestion"); itm.fromd = txt("#fromd"); itm.hours_per_week = txt("#hours_per_week"); itm.own_all_or_part = yn3("#own_all_or_part"); itm.special_rel = yn3("#special_rel"); itm.verified = "Y"; if ("sys" in itm && itm.sys && itm.sys.length > 0 && itm.sys.indexOf("|") < 0) { itm.sys = "payrol|"+itm.sys; } if (itm.salary_3yearquestion == "N") { itm.salary_overtime = "N"; itm[`income_w2_overtime_${year_c}`] = 0; itm[`income_w2_overtime_${year_p}`] = 0; itm.salary_commission = "N"; itm[`income_w2_commission_${year_c}`] = 0; itm[`income_w2_commission_${year_p}`] = 0; itm.salary_bonus = "N"; itm[`income_w2_bonus_${year_c}`] = 0; itm[`income_w2_bonus_${year_p}`] = 0; itm.salary_other = "N"; itm[`income_w2_other_${year_c}`] = 0; itm[`income_w2_other_${year_p}`] = 0; } if (itm.salary_3yearquestion == "Y") { if (MAR.xsd.inc_w2(itm).is_more_2_year() !== true) { let two_years_ago = moment().quarter(moment().quarter()).subtract(8, 'Q').startOf('quarter').format("YYYY-MM-DD"); itm.fromd = two_years_ago; } } /** * validation block start (validate the "itm" values) */ if (itm.name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the name of your employer.","top"); return; } if (itm.salary_choice.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us how to add up your salary.","top"); return; } if (itm.income_w2_base.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us how much salary you make.","top"); return; } if (num(itm.income_w2_base) < 0 ) { mar.tip(".help-button","warning","Income must be positive.","top"); return; } if (itm.income_full_or_part.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you work full-time or part-time.","top"); return; } if (itm.salary_3yearquestion.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you have been in the same line of work for 2 years.","top"); return; } if (itm.own_all_or_part.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you own all or part of this company.","top"); return; } if (itm.special_rel.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if are employed by a party to the transaction.","top"); return; } if (itm.fromd.trim().length == 0 || itm.fromd == 'dd/mm/yyyy') { /** * now some catchALLs */ if ($("#fromd_div").is(':visible') === false) $("#salary_3yearquestion").change(); mar.tip(".help-button","warning","Please tell us when you started this job.","top"); return; } if (itm.fromd.trim().length > 0 && elaineui.date_is_in_future(itm.fromd.trim()) == true) { mar.tip(".help-button","warning","You entered a future date by mistake.","top"); return; } if (itm.salary_3yearquestion == "N") { if (itm.fromd.trim().length > 0 && elaineui.date_is_more_2y_ago(itm.fromd.trim()) == true) { /** * now some catchALLs */ if ($("#fromd_div").is(':visible') === false) $("#salary_3yearquestion").change(); mar.tip(".help-button","warning","You entered a date more than 2 years ago. If you have worked for more than 2 years please change the answer directly above the date.","top"); return; } } if (itm.salary_overtime.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us if you get overtime or commission.","top"); return; } // validate if < 2y and date > 2y /** * validation block end */ let _insertindex = MAR.income.set(applicantnum, itm.type, existingid, itm); // get by id, set uuid, save needprevincome in scenario, put this in income -how, also put in fromd mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); getIncome_v2(); let _uuid = MAR.income.get(applicantnum, itm.type, _insertindex).uuid; let continuerouter = function(route) { if (needsVerification) { mvc.go("#income-employer."+applicantnum+"."+_uuid) mar.state.after_employer = route; return true; } let employer_address = MAR.getBucket("/income/address/"+_uuid); if (!employer_address) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "Would you like to add the employers contact information now? "; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Later", call : { text: "Yes", value: "yes", closeModal: false } } }) .then((act) => { if (act == "yes") { mvc.go("#income-employer."+applicantnum+"."+_uuid) mar.state.after_employer = route; swal.close(); } else { mvc.go(route); } }); return false; } mvc.go(route); return true; } let _warnings = mar.answers.v2.income[applicantnum].items[_insertindex].warnings; if (_warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warning").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { if (typeof _warnings[_wi] !== "undefined") { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { let close_swal = true; if(itm.salary_3yearquestion === 'N'){ let childitem = MAR.income.getByParentUUID(_uuid); if (childitem != false) { close_swal = continuerouter("#income-w2-previous"+"."+childitem.aid+"."+childitem.jid); } else { close_swal = continuerouter("#income-w2-previous"+"."+applicantnum); mar.state.currentw2uuid = _uuid; mvc.set("currentw2uuid", _uuid); } }else{ close_swal = continuerouter("#income-how"+"."+applicantnum); } if (close_swal == true) swal.close(); } }); } else { if(itm.salary_3yearquestion === 'N'){ let childitem = MAR.income.getByParentUUID(_uuid); if (childitem != false) { continuerouter("#income-w2-previous"+"."+childitem.aid+"."+childitem.jid); } else { continuerouter("#income-w2-previous"+"."+applicantnum); mar.state.currentw2uuid = _uuid; mvc.set("currentw2uuid", _uuid); } }else{ continuerouter("#income-how"+"."+applicantnum); } } }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { //need to adjust the sliders dynamically . This code exists in the present app let _incomehow = radio("incomehow"); //income_w2_base //uncomment for dynamic slider var base_startVal = 50; var base_v00 = 0; var base_v50 = 30; var base_v50_inc = 1; var base_v75 = 100; var base_v75_inc = 5; var base_v100 = 500; var base_v100_inc = 20; var baseMod = 1; console.log("radio(salary_choice) : "+ radio("salary_choice")); console.log("$('#income_w2_base_slider') : ", $('#income_w2_base_slider')); console.log("$('#income_w2_base_slider') v50: "+ $('#income_w2_base_slider').data('v50')); console.log("$('#income_w2_base_slider') v100: "+ $('#income_w2_base_slider').data('v100')); let divisor = 1; switch(radio("salary_choice")) { case 'hourly': baseMod =1; base_v00 = 0; base_v50 = 40; base_v50_inc = 0.05; base_v75 = 100; base_v75_inc = 0.50; base_v100 = 250; base_v100_inc = 1; baseMod = 1; divisor = 10; break; case 'weekly': baseMod = 40; break; case 'biweekly': baseMod = 80; break; case 'monthly': baseMod =150; break; case 'semimonthly': baseMod =80; break; case 'yearly': baseMod =1500; break; default: } if (radio("salary_choice") == "hourly") { $(".base_single_slider").addClass("x-hide"); $(".base_double_slider").removeClass("x-hide"); } else { $(".base_single_slider").removeClass("x-hide"); $(".base_double_slider").addClass("x-hide"); } if (radio("salary_choice") === "hourly") $(`.income_w2_base-salary-type-text`).html(`Hourly Salary:`); else if (radio("salary_choice") === "weekly") $(`.income_w2_base-salary-type-text`).html(`Weekly Salary:`); else if (radio("salary_choice") === "biweekly") $(`.income_w2_base-salary-type-text`).html(`Bi-Weekly Salary:`); else if (radio("salary_choice") === "monthly") $(`.income_w2_base-salary-type-text`).html(`Monthly Salary:`); else if (radio("salary_choice") === "semimonthly") $(`.income_w2_base-salary-type-text`).html(`Semi Monthly Salary:`); else if (radio("salary_choice") === "yearly") $(`.income_w2_base-salary-type-text`).html(`Annual Salary:`); else $(`.income_w2_base-salary-type-text`).html(``); $('#income_w2_base_slider').attr("data-start-val",(base_startVal*baseMod)); $('#income_w2_base_slider').attr("data-v00",(base_v00*baseMod)); $('#income_w2_base_slider').attr("data-v50",(base_v50*baseMod)); $('#income_w2_base_slider').attr("data-v50_inc",(base_v50_inc*baseMod)); $('#income_w2_base_slider').attr("data-v75",(base_v75*baseMod)); $('#income_w2_base_slider').attr("data-v75_inc",(base_v75_inc*baseMod)); $('#income_w2_base_slider').attr("data-v100",(base_v100*baseMod)); $('#income_w2_base_slider').attr("data-v100_inc",(base_v100_inc*baseMod)); //$('#income_w2_base_slider').attr("data-snap-precision",(base_v50_inc*baseMod)); $('#income_w2_base_slider').data("start-val",(base_startVal*baseMod)); $('#income_w2_base_slider').data("v00",(base_v00*baseMod)); $('#income_w2_base_slider').data("v50",(base_v50*baseMod)); $('#income_w2_base_slider').data("v50_inc",(base_v50_inc*baseMod)); $('#income_w2_base_slider').data("v75",(base_v75*baseMod)); $('#income_w2_base_slider').data("v75_inc",(base_v75_inc*baseMod)); $('#income_w2_base_slider').data("v100",(base_v100*baseMod)); $('#income_w2_base_slider').data("v100_inc",(base_v100_inc*baseMod)); $('#income_w2_base_slider').data("snap-precision",(base_v50_inc*baseMod)); let ___val = txt("#income_w2_base"); let _pm = num(___val); if (FREQ == "weekly") _pm = (num(___val)*52)/12; if (FREQ == "biweekly") _pm = (num(___val)*26)/12; if (FREQ == "semimonthly") _pm = num(___val)*2; if (FREQ == "yearly") _pm = num(___val)/12; if (FREQ == "hourly") _pm = ((num(___val)*40)*52)/12; FREQ = radio("salary_choice"); // if (FREQ == "hourly") { // debugger; // } if (FREQ == "weekly") _pm = Math.round((_pm*12)/52) if (FREQ == "biweekly") _pm = Math.round((_pm*12)/26) if (FREQ == "semimonthly") _pm = Math.round(_pm/2) if (FREQ == "yearly") _pm = Math.round(_pm*12) if (FREQ == "hourly") _pm = (((_pm*12)/52)/40) if (FREQ == "monthly") _pm = Math.round(_pm) if (___val === "1000" && FREQ == "hourly") { _pm = 15.0; } ___val = _pm; txt("#income_w2_base",___val); $('#income_w2_base').change(); if (FREQ == "hourly") { txt("#dollars",Math.floor(___val)) $('#dollars').change(); txt("#cents",Math.floor((___val - Math.floor(___val))*100)) $('#cents').change(); } if (radio("salary_choice") == "hourly") { txt("#income_w2_base",(num(txt("#dollars")) + (num(txt("#cents"))/100))) $('#income_w2_base').change(); } if (yn3("#salary_3yearquestion") == "N") { $("#fromd_div").removeClass("x-hide") } else { let two_years_ago = moment().quarter(moment().quarter()).subtract(8, 'Q').startOf('quarter').format("YYYY-MM-DD"); txt("#fromd",two_years_ago); $("#fromd_div").addClass("x-hide").removeClass("x-revealdiv"); } //console.log("$('#income_w2_base_slider') after : ", $('#income_w2_base_slider')); } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); if ( $('[type="date"]').prop('type') != 'date' ) { $('[type="date"]').datepicker({ dateFormat: "yy-mm-dd" }); } $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#body-container ._cents").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character suffix: "c", rightAlign: false, autoUnmask : true }); $("#body-container ._hours").inputmask("currency", { radixPoint: ".", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character suffix: "h", rightAlign: false, autoUnmask : true }); $("#body-container #name").prop("maxlength",40); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-DD1099"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"DD1099",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let taxyear_c = MAR.getApplicantLastTaxYear(applicantnum); let taxyear_p = MAR.getApplicantLastTaxYear(applicantnum)-1; let year_c = MAR.getCurrentYear(); let year_p = MAR.getCurrentYear()-1; /** * standard starting block - END */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { if (num(itm[`profit_DD1099_${taxyear_c}`]) === 0) { itm[`profit_DD1099_${taxyear_c}`] = num(itm.sug_total) * 12; itm[`profit_DD1099_${taxyear_p}`] = num(itm.sug_total) * 12; } } let h = ""; h += frm.htitle("Sole proprietor / 1099 INCOME").render(); /** * block for overrides */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { mar.pg_accesscontrollerfn = function() { return "open"; } } let overridden = (itm && MAR.getOpt(itm, "over", "") === "Y"); if (overridden) { h += mar.tmp_pg_overblock(itm); } /** * end block */ h += frm.elaine("If you receive direct deposits from one or more employers, but you did not form a company, like an LLC or Corporation, fill in your income under 1099.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div h += "
    Describe or name your business
    "; VAL = (itm) ? itm.name : MAR.income.has_w2_with_ownership_first_name(applicantnum); h += frm.txt("name","",VAL,"e.g. John Smith Plumbing","",function(){}).render(); h += "
    "; // reveal - start (with validation t h += frm.hr().render(); // // VAL = (itm) ? itm.salary_3yearquestion : ''; // // h += frm.yn3("salary_3yearquestion","Have you been self employed for more than 2 years?",VAL,"","",function(){ // // },{}).render(); // h += "
    " // reveal - end h += "
    How long have you been self employed?
    "; h += "
    "; VAL = (itm) ? itm.years : '0'; h += frm.slider("years","Years:",VAL,"","",function(){ }, { v00 : '0', v50 : '10', v50_inc : '1', v75 : '30', v75_inc : '1', v100 : '60', v100_inc : '1', start_val : '2', formatting_class : '_years' }).render(); h += "
    "; h += "
    "; VAL = (itm) ? itm.months : '0'; h += frm.slider("months","Months:",VAL,"","",function(){ }, { v00 : '0', v50 : '6', v50_inc : '1', v75 : '9', v75_inc : '1', v100 : '11', v100_inc : '1', start_val : '0', formatting_class : '_months' }).render(); h += "
    "; // h += "
    "; // reveal - start (with validation to previous field) // h += frm.hr().render(); // // VAL = (itm) ? itm.last_year_filed : ''; // h += frm.radio("last_year_filed","What year did you file your taxes last?",VAL,"","",function(){ // $('#yearLast_1099').text(radio("last_year_filed")); // $('#yearBeforeLast_1099').text(parseInt(radio("last_year_filed")-1, 10)); // },{ // 2015 : "2015", // 2016 : "2016", // 2017 : "2017", // 2018 : "2018" /*yrmrk*/ // }).render(); // h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += frm.elaine('On your 1040 tax returns, we are looking for the bottom line number on schedule C. This is your "profit" from this job.',"").render(); h += `
    What was your profit last year you filed taxes in ${taxyear_c}?
    `; VAL = (itm) ? itm[`profit_DD1099_${taxyear_c}`] : '0'; h += frm.slider(`profit_DD1099_${taxyear_c}`,"Profit:",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += frm.hr().render(); h += `
    What was your profit last year you filed taxes in ${taxyear_p}?
    `; VAL = (itm) ? itm[`profit_DD1099_${taxyear_p}`] : '0'; h += frm.slider(`profit_DD1099_${taxyear_p}`,"Profit:",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += ""; let hr = frm.hr().render(); h += (function(){ let h = ""; h += "
    "; VAL = (itm && itm.address) ? itm.address : ""; h += frm.address("address","
    From what location do you operate your business?
    ",VAL,"","",function(){ // //oc(); },{}).render() return h; })().wrap("
    "+hr,"
    "); h += (function(){ let h = ""; VAL = (itm && itm.tel) ? itm.tel : ""; if (VAL == "") VAL = MAR.getApplicantPhone(applicantnum); h += frm.txt("tel","Business phone number",VAL,"___-___-____","",function(){ }).render(); h += "
    "; VAL = (itm && itm.email) ? itm.email : ""; if (VAL == "") VAL = MAR.getApplicantEmail(applicantnum); h += frm.txt("email","Business Email",VAL,"e.g. CM@KW.com","",function(){}).render(); return h; })().wrap("

    ","
    "); h += (function(){ let h = ""; VAL = (itm) ? MAR.getOpt(itm, "special_rel", "") : ''; h += frm.hr().render(); h += frm.yn3("special_rel","Are you employed by a family member, property seller, real estate agent, or other party to the transaction?",VAL,"","",function(){ oc(); },{}).render(); // itm.special_rel = yn3("#special_rel"); // if (itm.special_rel === "") { // mar.tip(".help-button","warning","You need to tell us if you are part of the transaction.","top"); // return; // } return h; })().wrap("
    ","
    "); h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var val; /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { // if (validation == "name") { // val = txt("#name"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us the name of your employer.","top"); // return; // } // } // if (validation == "last_year_filed") { // val = radio("last_year_filed"); // // if (val == '' ) { // mar.tip(".help-button","warning","You need to tell us the last year you filed.","top"); // return; // } // } if (validation == `profit_DD1099_${taxyear_c}`) { val = txt(`#profit_DD1099_${taxyear_c}`); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us how much profit you made in the last year you filed.","top"); return; } } if (validation == `profit_DD1099_${taxyear_p}`) { val = txt(`#profit_DD1099_${taxyear_p}`); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us how much profit you made in the year before the last year you filed.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "DD1099"; itm.name = txt("#name"); itm.address = txt("#address"); itm.months = txt("#months") itm.years = txt("#years") itm.tel = txt("#tel") itm.email = txt("#email") itm.special_rel = yn3("#special_rel"); itm.last_year_filed = taxyear_c; itm[`profit_DD1099_${taxyear_c}`] = frm.profit_and_loss.val(`#profit_DD1099_${taxyear_c}`); itm[`profit_DD1099_${taxyear_p}`] = frm.profit_and_loss.val(`#profit_DD1099_${taxyear_p}`); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (itm.name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the business name.","top"); return; } if ((num(itm.years.trim()) + num(itm.months.trim())) == 0 ) { mar.tip(".help-button","warning","You need to tell us how long you have been self employed.","top"); return; } if (itm.name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the name of your employer.","top"); return; } // if (itm.last_year_filed.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us the last year you filed.","top"); // return; // } // if (itm[`profit_DD1099_${taxyear_c}`].trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us how much profit you made in the last year you filed.","top"); // return; // } // // // if (itm[`profit_DD1099_${taxyear_p}`].trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us how much profit you made in the year before the last year you filed.","top"); // return; // } if (itm.address.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us what address you run your business from.","top"); return; } if (itm.tel.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the telephone number.","top"); return; } if (itm.email.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the business email.","top"); return; } if (itm.special_rel === "") { mar.tip(".help-button","warning","You need to tell us if you are part of the transaction.","top"); return; } /** * validation block end */ let _insertindex = MAR.income.set(applicantnum, itm.type, existingid, itm); mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); getIncome_v2(); let _warnings = mar.answers.v2.income[applicantnum].items[_insertindex].warnings; if (_warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warning").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { if (typeof _warnings[_wi] !== "undefined") { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mvc.go("#income-how"+"."+applicantnum); swal.close(); } }); } else { mvc.go("#income-how"+"."+applicantnum); } }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { //need to adjust the sliders dynamically . This code exists in the present app let _incomehow = radio("incomehow"); //income_w2_base //uncomment for dynamic slider var base_v00 = 0; var base_v50 = 30; var base_v50_inc = 1; var base_v75 = 100; var base_v75_inc = 5; var base_v100 = 500; var base_v100_inc = 20; var baseMod = 1; console.log("radio(salary_choice) : "+ radio("salary_choice")); console.log("$('#income_w2_base_slider') : ", $('#income_w2_base_slider')); switch(radio("salary_choice")) { case 'hourly': baseMod =1; break; case 'weekly': baseMod =40; break; case 'biweekly': baseMod =80; break; case 'monthly': baseMod =150; break; case 'semimonthly': baseMod =80; break; case 'yearly': baseMod =1500; break; default: } $('#income_w2_base_slider').attr("data-v00",(base_v00*baseMod)); $('#income_w2_base_slider').attr("data-v50",(base_v50*baseMod)); $('#income_w2_base_slider').attr("data-v50_inc",(base_v50_inc*baseMod)); $('#income_w2_base_slider').attr("data-v75",(base_v75*baseMod)); $('#income_w2_base_slider').attr("data-v75_inc",(base_v75_inc*baseMod)); $('#income_w2_base_slider').attr("data-v100",(base_v100*baseMod)); $('#income_w2_base_slider').attr("data-v100_inc",(base_v100_inc*baseMod)); console.log("$('#income_w2_base_slider') after : ", $('#income_w2_base_slider')); } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider({ fn : function(elm) { $(`#${elm}`).change(); } }); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); let labels = $(".cfc_label_title_multiple"); for (let i=0; i < labels.length; i++) { let $label = $(labels[i]); if ($label[0].id.startsWith("lbl_profit")) { frm.profit_and_loss.add($label); } } if ($("#body-container").find("#address-disp").length > 0) { uihelpers.addresspopup_init($("#body-container").find("#address-disp")); } $("#body-container #tel").inputmask("(999) - 999 - 9999", { autoUnmask: true }); $("#body-container #tel").euiInputTel(); $('#yearLast_1099').text(radio("last_year_filed")); $('#yearBeforeLast_1099').text(parseInt(radio("last_year_filed")-1, 10)); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-w2-previous"] = (function(){ var VAL = '' var html = ""; var checkForValues = false; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"w2",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let parentuuid = (existingid && itm) ? itm.parent : mvc.get("currentw2uuid"); let parent = MAR.income.getByUUID(parentuuid); let employeraddress = false; if (itm != false) { employeraddress = MAR.getBucket("/income/address/"+itm.uuid); } /** * standard starting block - END */ let h = ""; let edit_link = ""; if (employeraddress) { edit_link += "Employer details"; } h += ``; h += frm.htitle("Previous Employer" + edit_link).render(); h += frm.elaine("Your \“previous employment\” can be work or study, as long as you were studying for your current job.","er").render(); h += (function(){ let h = ""; VAL = (itm) ? itm.previous_type : ''; h += frm.radio("previous_type","Was your previous engagement work or work-related study",VAL,"","",function(){ oc(); },{ "work" : "Work", "study" : "Study", "neither" : "Other e.g. break or sabatical" }).render(); h += (function(){ let h = ""; VAL = (itm) ? itm.name : ''; h += frm.hr().render(); h += frm.txt("name","What is the name of your previous employer?",VAL,"e.g. Target","",function(){ $('.secondJob').html(txt("#name")); }).render(); h += (function(){ let h = ""; h += frm.hr().render(); VAL = (itm) ? itm.selfemployed : ''; h += frm.yn3("selfemployed","Were you self employed?",VAL,"","",function(){ oc(); },{}).render(); VAL = (itm) ? itm.selfemployed_type : ''; h += frm.radio("selfemployed_type","In which sort of business were you self employed?",VAL,"","",function(){ oc(); },{ D1099 : `1099`, LLC : `LLC`, PARTNERSHIP : `Partnership`, SCORP : `S-Corp`, CCORP : `C-Corp` }).render().wrap("
    "+frm.hr().render(),"
    "); return h; })().wrap("
    ","
    "); h += (function(){ let h = ""; h += frm.hr().render(); VAL = (itm) ? itm.jobs_the_same : ''; h += frm.yn3("jobs_the_same","Was this job in in the same line of business as your current job?",VAL,"","",function(){ oc(); },{}).render(); // h += frm.elaine("Most lenders require a track record in the same line of work. Time spent on education usually suffice as continuation.","").render(); h += frm.elaine("Most lenders require a track record in the same line of work. Time spent on education usually suffice as continuation.","").render().wrap("
    ","
    "); return h; })().wrap("
    ","
    "); h += "
    "; h += frm.hr().render(); VAL = (itm) ? itm.fromd : ''; h += frm.txt("fromd","When did you start this job?",VAL,"","",function(){ // oc(); }, "date").render(); h += "
    "; h += "
    "; VAL = (itm) ? itm.tod : ''; h += frm.txt("tod","When did you quit this job?",VAL,"","",function(){ oc(); }, "date").render(); h += "
    "; return h; })().wrap("
    ","
    "); h += (function(){ let h = ""; VAL = (itm) ? itm.name : ''; h += frm.hr().render(); h += frm.txt("other_name","What was the nature of your sabatical or break?",VAL,"e.g. Target","",function(){ $('.secondJob').html(txt("#name")); }).render(); h += "
    "; h += frm.hr().render(); VAL = (itm) ? itm.fromd : ''; h += frm.txt("other_fromd","When did you start this break?",VAL,"","",function(){ // oc(); }, "date").render(); h += "
    "; h += "
    "; VAL = (itm) ? itm.tod : ''; h += frm.txt("other_tod","When did you end this break?",VAL,"","",function(){ oc(); }, "date").render(); h += "
    "; return h; })().wrap("
    ","
    "); h += (function(){ let h = ""; h += frm.hr().render(); VAL = (itm) ? itm.education_the_same : ''; h += frm.yn3("education_the_same","Can you prove that you have been studying for your current profession prior to this employment?",VAL,"","",function(){ oc(); },{}).render(); h += "
    "; VAL = (itm) ? itm.school : ''; h += frm.txt("school","What is the name of the school?",VAL,"e.g. University of Miami","",function(){ oc(); }).render(); h += "
    "; h += frm.hr().render(); VAL = (itm) ? itm.education : ''; h += frm.txt("education","What is the name of the education or course?",VAL,"e.g. Architecture","",function(){ oc(); }).render(); h += "
    " h += "
    "; h += frm.hr().render() VAL = (itm) ? itm.education_start : ''; h += frm.txt("education_start","When did you start this education?",VAL,"date picker","",function(){ // oc(); }, "date").render(); VAL = (itm) ? itm.education_end : ''; h += frm.txt("education_end","When did you graduate from this education?",VAL,"date picker","",function(){ // oc(); }, "date").render(); h += "
    " h += "
    "; // reveal - end return h; })().wrap("
    ","
    "); h += (function(){ let h = ""; h += frm.elaine("Please explain why there was a gap between your employment at and your next job.","").render(); VAL = (itm) ? itm.gap_explain : ''; h += frm.txt("gap_explain","",VAL,"e.g. I had an injury that prevented me from working for a few months.","",function(){ oc(); }, 'area').render(); return h; })().wrap("
    ","
    "); return h; })().wrap("
    ","
    "); /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ let _ch = ch(); if (typeof _ch == "string") { mar.tip(".help-button","warning",_ch,"top"); return false; } if (_ch == false) return; // swal("ok" + JSON.stringify(_ch)); /** * validation & reveal block start */ itm = _ch; /** * validation block start (validate the "itm" values) */ /** * validation block end */ let _insertindex = MAR.income.set(applicantnum, itm.type, existingid, itm); mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); getIncome_v2(); let _uuid = MAR.income.get(applicantnum, itm.type, _insertindex).uuid; let continuerouter = function(route) { if (itm.previous_type == "neither") { mvc.go(route); return; } let employer_address = MAR.getBucket("/income/address/"+_uuid); if (!employer_address) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "Would you like to add the employers contact information now? "; if (itm.previous_type === "study") { s.innerHTML = "Would you like to add the schools contact information now? "; } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Later", call : { text: "Yes", value: "yes", closeModal: false } } }) .then((act) => { if (act == "yes") { mvc.go("#income-employer."+applicantnum+"."+_uuid) mar.state.after_employer = route; swal.close(); } else { mvc.go(route); } }); return; } mvc.go(route); } let _warnings = mar.answers.v2.income[applicantnum].items[_insertindex].warnings; if (_warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warning").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { if (typeof _warnings[_wi] !== "undefined") { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } } swal({ className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { continuerouter("#income-how"+"."+applicantnum); swal.close(); } }); } else { continuerouter("#income-how"+"."+applicantnum); } }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let unslide = function(elm) { let $elm = $(elm); if ($elm.hasClass("x-hide") == true) return false; $elm.addClass("x-hide").css("display",""); }; let slide = function(elm) { let $elm = $(elm); if ($elm.hasClass("x-hide") == false) return false; $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv") $elm.css("display",""); $("#body-container").scrollTo("max",200); }); return true; } let ch = function() { if (!existingid) { itm = {}; itm.parent = mvc.get("currentw2uuid"); } if ("parent" in itm == false || itm.parent == false) { itm.parent = mvc.get("currentw2uuid"); } itm.type = "w2"; itm.previous_type = radio("previous_type"); itm.name = txt("#name"); itm.fromd = txt("#fromd"); itm.tod = txt("#tod"); itm.gap_explain = txt("#gap_explain"); if ($("#gap_explain").is(":visible") == false) { itm.gap_explain = ""; } itm.jobs_the_same = yn3("#jobs_the_same"); itm.selfemployed = yn3("#selfemployed"); itm.selfemployed_type = radio("selfemployed_type"); itm.education_the_same = yn3("#education_the_same"); itm.school = txt("#school"); itm.education = txt("#education"); itm.education_start = txt("#education_start"); itm.education_end = txt("#education_end"); itm.other_name = txt("#other_name"); itm.other_fromd = txt("#other_fromd"); itm.other_tod = txt("#other_tod"); if (itm.previous_type == "") { unslide("#section-employed"); unslide("#section-break"); unslide("#section-study"); unslide("#section-explain"); return "You need to tell us what sort of employment you are referring to"; } if (itm.previous_type == "neither") { if (slide("#section-break")) { unslide("#section-employed"); unslide("#section-study"); unslide("#section-explain"); unslide("#other_tod-div"); unslide("#other_fromd-div"); return false; }; unslide("#section-study"); unslide("#section-employed"); unslide("#section-explain"); unslide("#education_details_holder_btm"); itm.name = txt("#other_name"); itm.fromd = txt("#other_fromd"); itm.tod = txt("#other_tod"); if(itm.name.trim().length == 0){ return "Please tell us the nature of the break."; } if (slide("#other_fromd-div")) return false; if(itm.fromd.trim().length == 0){ return "Please tell us the start date."; } if (slide("#other_tod-div")) return false; if(itm.tod.trim().length == 0){ return "Please tell us the end date."; } let m_parent_fromd = moment(parent.fromd); let m_this_tod = moment(itm.other_tod); let m_this_fromd = moment(itm.other_fromd); let diff = m_parent_fromd.diff(m_this_tod,'days'); let diffm = m_parent_fromd.diff(m_this_tod,'months'); } if (itm.previous_type == "work") { if (slide("#section-employed")) { unslide("#section-study"); unslide("#education_details_holder_btm"); unslide("#section-break"); unslide("#section-explain"); return false; } unslide("#section-study"); unslide("#section-break"); unslide("#education_details_holder_btm"); if(itm.name.trim().length == 0){ return "Please tell us the name of your previous employer."; } if (itm.name == "") { return "You need to tell us what sort of study"; } if (slide("#section-selfemployed")) return false; if (itm.selfemployed == "") { return "You need to tell us if you were self employed"; } if (itm.selfemployed == "Y") { $("#section-selfemployed .info").removeClass("x-hide"); } else { $("#section-selfemployed .info").addClass("x-hide"); } if (itm.selfemployed == "Y" && itm.selfemployed_type == "") { return "You need to tell us how you were self employed"; } if (slide("#section-sameline")) return false; if (itm.jobs_the_same == "") { return "You need to tell us if it is in the same line"; } if (itm.jobs_the_same == "Y") { $("#section-sameline .info").addClass("x-hide"); } else { $("#section-sameline .info").removeClass("x-hide"); } if (slide("#fromd-div")) return false; if (itm.fromd == "") { return "You need to tell us the start date"; } if (slide("#tod-div")) return false; if (itm.tod == "") { return "You need to tell us the end date"; } let m_parent_fromd = moment(parent.fromd); let m_this_tod = moment(itm.tod); let m_this_fromd = moment(itm.fromd); let diff = m_parent_fromd.diff(m_this_tod,'days'); let diffm = m_parent_fromd.diff(m_this_tod,'months'); //swal(m_parent_fromd.format("YYYY-MM-DD") + "/" + m_this_tod.format("YYYY-MM-DD") + " - "+diff); if (diff > 7) { let GAPTXT = "Please explain why AA there was a gap between your employment at and your next job."; let GAPPERIOD = "7 days"; if (diffm == 1) GAPPERIOD = "a month"; if (diffm > 1) GAPPERIOD = `${diffm} months`; GAPTXT = `You started employment at ${parent.name} `+ `on ${m_parent_fromd.format("YYYY-MM-DD")}-${m_parent_fromd.format("YYYY")} and you quit this `+ `job on ${m_this_tod.format("YYYY-MM-DD")}-${m_this_tod.format("YYYY")}, `+ `since this is ${diff} days can you explain what happened in between?`; //`since this is more than ${GAPPERIOD} can you explain what happened in between?`; $("#elaine_gap_explanation").html(elaineui.str2usdF(GAPTXT)); if (slide("#section-explain")) { return false; } if (itm.gap_explain == "") { return "You need to tell us why there was a gap"; } } else { unslide("#section-explain") } // name // fromd // tod // function lastq_end() { // return moment().quarter(moment().quarter()).subtract(1, 'Q').endOf('quarter').format("YYYY-MM-DD"); // } // function lastq_start() { // return moment().quarter(moment().quarter()).subtract(1, 'Q').startOf('quarter').format("YYYY-MM-DD"); // } // // months // function lastm_1_end() { // return moment().month(moment().month()).subtract(1, 'months').endOf('month').format("YYYY-MM-DD"); // } // function lastm_1_start() { // return moment().month(moment().month()).subtract(1, 'months').startOf('month').format("YYYY-MM-DD"); // } // function lastm_2_end() { // return moment().month(moment().month()).subtract(2, 'months').endOf('month').format("YYYY-MM-DD"); // } // function lastm_2_start() { // return moment().month(moment().month()).subtract(2, 'months').startOf('month').format("YYYY-MM-DD"); // } } if (itm.previous_type == "study") { if (slide("#section-study")) { unslide("#section-employed"); unslide("#section-break"); unslide("#section-explain"); unslide("#education_details_holder_btm"); return false; } unslide("#section-employed"); unslide("#section-break"); if (itm.education_the_same == "") { unslide("#education_details_holder_btm"); return "You need to tell us what sort of study"; } if (itm.education_the_same == "Y") { if (slide("#education_details_holder_btm")) { unslide("#education-div"); unslide("#educationdates-div"); return false; } if(itm.school.trim().length == 0){ return "Please tell us the name of your school."; } if (slide("#education-div")) { unslide("#educationdates-div"); return false; } if(itm.education.trim().length == 0){ return "Please tell us the name of your education or course."; } if (slide("#educationdates-div")) return false; if (itm.education_start.trim().length == 0 || itm.education_start == 'dd/mm/yyyy') { return "Please tell us when your education started."; } if (itm.education_start.trim().length > 0 && elaineui.date_is_in_future(itm.education_start.trim()) == true) { mar.tip(".help-button","warning","You entered a future date by mistake.","top"); return; } if (itm.education_end.trim().length == 0 || itm.education_end == 'dd/mm/yyyy') { return "Please tell us when your education ended."; } if (itm.education_end.trim().length > 0 && elaineui.date_is_in_future(itm.education_end.trim()) == true) { mar.tip(".help-button","warning","You entered a future date by mistake.","top"); return; } let m_parent_fromd = moment(parent.fromd); let m_this_tod = moment(itm.education_end); let m_this_fromd = moment(itm.education_start); let diff = m_parent_fromd.diff(m_this_tod,'days'); //swal(m_parent_fromd.format("YYYY-MM-DD") + "/" + m_this_tod.format("YYYY-MM-DD") + " - "+diff); if (diff > 90) { let GAPTXT = "Please explain why AA there was a gap between your employment at and your next job."; GAPTXT = `You started employment at ${parent.name} `+ `on ${m_parent_fromd.format("YYYY-MM-DD")} and you finished this education on ${m_this_tod.format("YYYY-MM-DD")}, `+ `since this is more than 3 months can you explain what happened in between?`; $("#elaine_gap_explanation").html(elaineui.str2usdF(GAPTXT)); if (slide("#section-explain")) { return false; } if (itm.gap_explain == "") { return "You need to tell us why there was a gap"; } } else { unslide("#section-explain") } }else { unslide("#education_details_holder_btm"); if (itm.education_the_same == "N") { } } } // if (yn("#education_the_same") == "Y") { // $("#education_details_holder_btm").css("display","block"); // checkForValues = true; // // }else { // $("#education_details_holder_btm").css("display","none") // //clear out any garbage data in hidden divs // $("#school").val(''); // $("#education").val(''); // $("#education_start").val(''); // $("#education_end").val(''); // checkForValues = false; // // } itm.verified = "Y"; return itm; } let oc = function() { let _ch = ch(); //need to adjust the sliders dynamically . This code exists in the present app //let _incomehow = radio("incomehow"); //let eduTheSame = yn("#education_the_same"); } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#gap_explain").addClass("autoExpand"); $("#gap_explain").prop("spellcheck","false"); let res = function(elm) { var savedValue = elm.value; elm.value = ''; elm.baseScrollHeight = elm.scrollHeight; elm.value = savedValue; var minRows = elm.getAttribute('data-min-rows')|0, rows; elm.rows = minRows; rows = Math.ceil((elm.scrollHeight - elm.baseScrollHeight) / 16); elm.rows = minRows + rows + 2; } // Applied globally on all textareas with the "autoExpand" class $("#body-container") .one('focus.autoExpand', 'textarea.autoExpand', function(){ // var savedValue = this.value; // this.value = ''; // this.baseScrollHeight = this.scrollHeight; // this.value = savedValue; }) .on('input.autoExpand', 'textarea.autoExpand', function(){ var minRows = this.getAttribute('data-min-rows')|0, rows; this.rows = minRows; rows = Math.ceil((this.scrollHeight - this.baseScrollHeight) / 16); this.rows = minRows + rows + 2; }); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); setTimeout(function(){ res($("#gap_explain")[0]); },1) } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-employer"] = (function(){ var VAL = '' var html = ""; var checkForValues = false; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm0 = (existingid) ? MAR.income.getByUUID(existingid) : false; let itm = (itm0 !== false ) ? MAR.getBucket("/income/address/"+existingid) : false; let TYPE = "employer"; let TYPH = "employer"; let TYPJ = "job"; let TYPR = "HR"; let TYPB = "Business"; let TYPC = "company"; let TYPN = itm0.name; if (itm0 && "previous_type" in itm0) { TYPE = "employer"; TYPH = "previous employer"; TYPJ = "previous job"; TYPR = "HR"; TYPB = "Business"; TYPC = "company"; TYPN = itm0.name; } if (itm0 && "previous_type" in itm0 && itm0.previous_type == "study") { TYPE = "school"; TYPH = "school"; TYPJ = "school"; TYPR = "Administrative"; TYPB = "School"; TYPC = "school"; TYPN = itm0.school; } let revealclass = (itm != null) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let h = ""; let hr = "
    ";//frm.hr().render(); h += frm.htitle(TYPH+" Details").render(); if (itm0 == false) { h += frm.elaine("oops this is not linked to an employment record.","er").render(); h += uihelpers.cbuttonbar("",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); } else { VAL = (itm) ? itm.name : ''; if (VAL == "" && TYPN.trim().length > 0) VAL = TYPN; h += frm.elaine("Tell me about "+VAL+".","er").render(); h += "
    "; h += (function(){ let h = ""; VAL = (itm) ? itm.name : ''; if (VAL == "" && TYPN.trim().length > 0) VAL = TYPN; // h += frm.txt("name","What is the name of your "+TYPH+"?",VAL,"e.g. Target","",function(){ // oc(); // }).render(); h += `` return h; })().wrap("
    "+hr,"
    "); h += (function(){ let h = ""; // h += frm.elaine("Please enter an address as accuratly as possible.","er1").render(); // h += "
    "; // JC - CW - elaine added div VAL = (itm && itm.address) ? itm.address : ""; h += frm.address("address","
    Where is your "+TYPC+" located?
    ",VAL,"","",function(){ //oc(); },{}).render() // h += "
    "; return h; })().wrap("
    "+hr,"
    "); h += `
    `; revealclass = ""; // POSITION if (TYPE == "school") { VAL = (itm && itm.position) ? itm.position : ""; h += frm.txt("position","",VAL,"","",function(){ oc(); },"hide").render(); } else { h += (function(){ let h = ""; VAL = (itm && itm.position) ? itm.position : ""; h += frm.txt("position","Position/ Title / Type of business?",VAL,"e.g.","",function(){ oc(); }).render(); return h; })().wrap("
    "+hr,"
    "); } // HR Contact h += (function(){ let h = ""; VAL = (itm && itm.hrcontact) ? itm.hrcontact : ""; h += frm.txt("hrcontact",TYPR+" Contact",VAL,"e.g.","",function(){ oc(); }).render(); return h; })().wrap("
    "+hr,"
    "); // Business phone h += (function(){ let h = ""; VAL = (itm && itm.phone) ? itm.phone : ""; h += frm.txt("phone",TYPB+" phone",VAL,"e.g.","",function(){ oc(); }).render(); return h; })().wrap("
    "+hr,"
    "); // Business phone h += (function(){ let h = ""; VAL = (itm && itm.phone_ext) ? itm.phone_ext : ""; h += frm.txt("phone_ext","Extension",VAL,"e.g. 123","",function(){ oc(); }).render(); return h; })().wrap("
    "+hr,"
    "); // Business fax h += (function(){ let h = ""; VAL = (itm && itm.fax) ? itm.fax : ""; h += frm.txt("fax",TYPB+" fax",VAL,"e.g. 555-122-1222","",function(){ oc(); }).render(); return h; })().wrap("
    "+hr,"
    "); // Business email h += (function(){ let h = ""; VAL = (itm && itm.email) ? itm.email : ""; h += frm.txt("email",TYPB+" email",VAL,"e.g. jane@employer.com","",function(){ oc(); }).render(); return h; })().wrap("
    "+hr,"
    "); h += "
    "; h += "
    "; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ let itm = oc(false,true); if (typeof itm == "string") { mar.tip(".help-button","warning",itm,"top"); return false; } if (itm == false) return; MAR.setBucket("/income/address/"+existingid, itm); mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); if (mar.is_fromhomework() === true) { mvc.go("#lox"); } else if ("after_employer" in mar.state && mar.state.after_employer) { mvc.go(mar.state.after_employer); } else { mvc.go("#income-how."+applicantnum) } }),"cancel",frm.addfunction(function(){ if (mar.is_fromhomework() === true) { mvc.go("#lox"); } else if ("before_employer" in mar.state && mar.state.before_employer) { mvc.go(mar.state.before_employer); } else { mvc.go("#income-how"+"."+applicantnum); } }),"mar.help()"); } h = Mustache.render(h,localopts); let slide = function(elm) { $elm = $(elm); if ($elm.hasClass("x-hide") == false) return false; $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return true; } let ch = function(itm) { if (itm.name.trim().length == 0) { //mar.tip(".help-button","warning","You need to let us know the neme of the employer.","top"); return "You need to let us know the neme of the employer"; //return false; } if (slide("#address_div")) return false; if (itm.address.trim().length == 0) { //mar.tip(".help-button","warning","You need to let us know the address of the employer.","top"); return "You need to let us know the address of the employer."; //return false; } if(slide("#therest")) return false; if ($("#position_div").length > 0) { if (slide("#position_div")) return false; if (itm.position.trim().length == 0) { // return "You need to let us know the Position you held."; //mar.tip(".help-button","warning","You need to let us know the Position you held.","top"); //return false; } } if (slide("#hrcontact_div")) return false; if (itm.hrcontact.trim().length == 0) { // return "You need to let us know the HR contact of the employer."; } if (slide("#phone_div")) return false; if (slide("#phone_ext_div")) return false; if (itm.phone.trim().length == 0) { // return "You need to let us know the phone number of the employer."; } if (slide("#fax_div")) return false; if (slide("#email_div")) return false; if (itm.email.trim().length == 0) { // return "You need to let us know the email address of the employer"; } if (itm.email.trim().length > 0) { if (elaineui.isEmail(itm.email.trim()) == false) { return "The email address of the employer is in the wrong format"; } } return true; // you can proceed if you like; } let oc = function(nofeedback, returnstring) { if ($("#address_div").length == 0) return; let itm = { name : txt("#name"), address : txt("#address"), position : txt("#position"), hrcontact : txt("#hrcontact"), phone : txt("#phone"), phone_ext : txt("#phone_ext"), fax : txt("#fax"), email : txt("#email") }; if (nofeedback) { return; } let retval = ch(itm); if (retval !== true) { if (returnstring) return retval; return false; } return itm; // //need to adjust the sliders dynamically . This code exists in the present app // //let _incomehow = radio("incomehow"); // // //let eduTheSame = yn("#education_the_same"); // // if (yn("#education_the_same") == "Y") { // $("#education_details_holder_btm").css("display","block"); // checkForValues = true; // // }else { // $("#education_details_holder_btm").css("display","none") // //clear out any garbage data in hidden divs // $("#school").val(''); // $("#education").val(''); // $("#education_start").val(''); // $("#education_end").val(''); // checkForValues = false; // // } // // $("#body-container").scrollTo("max",200); } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); if ($("#body-container").find("#address-disp").length > 0) { uihelpers.addresspopup_init($("#body-container").find("#address-disp")); } $("#body-container #phone").inputmask(elaineui.TEL_MASK_800); $("#body-container #fax").inputmask(elaineui.TEL_MASK_800); $("#body-container #phone").euiInputTel(); $("#body-container #fax").euiInputTel(); $("#body-container #email").euiInputEmail(); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); oc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-llc"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"llc",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let taxyear_c = MAR.getApplicantLastTaxYear(applicantnum); let taxyear_p = MAR.getApplicantLastTaxYear(applicantnum)-1; let year_c = MAR.getCurrentYear(); let year_p = MAR.getCurrentYear()-1; /** * standard starting block - END */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { if (num(itm[`income_llc_${taxyear_c}`]) === 0) { itm[`income_llc_${taxyear_c}`] = num(itm.sug_total) * 12; itm[`income_llc_${taxyear_p}`] = num(itm.sug_total) * 12; } if (typeof itm.name === "string" && itm.name.length> 0 && MAR.getOpt(itm,"name_llc","").length === 0) { itm.name_llc = itm.name; } } let h = ""; h += frm.htitle("Self employed - LLC").render(); /** * block for overrides */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { mar.pg_accesscontrollerfn = function() { return "open"; } } let overridden = (itm && MAR.getOpt(itm, "over", "") === "Y"); if (overridden) { h += mar.tmp_pg_overblock(itm); } /** * end block */ h += frm.elaine("An entrepreneur?! The backbone of the American economy. Very cool!","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div h += "
    What is the name of your LLC?
    "; VAL = (itm) ? itm.name_llc : MAR.income.has_w2_with_ownership_first_name(applicantnum); h += frm.txt("name_llc","",VAL,"e.g. John Smith Plumbing","",function(){}).render(); h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); // h += "
    What percentage of this business do you own?
    "; // // VAL = (itm) ? itm.income_llc_equity : '50'; // h += frm.slider("income_llc_equity","Equity:",VAL,"","",function(){ // }, { // v00 : '0', // v50 : '50', // v50_inc : '1', // v75 : '75', // v75_inc : '1', // v100 : '100', // v100_inc : '1', // start_val : '50', // formatting_class : '_percentage' // }).render(); // // h += "
    " // reveal - end // h += "
    "; // reveal - start (with validation to previous field) // // h += frm.hr().render(); if (itm) { if ("months" in itm == false) { if ("income_llc_duration" in itm == true) { itm.years = Math.floor(num(itm.income_llc_duration)/12); itm.months = num(itm.income_llc_duration) % 12; } } } h += "
    How long have you been self employed?
    "; h += "
    "; VAL = (itm) ? itm.years : '0'; h += frm.slider("years","Years:",VAL,"","",function(){ }, { v00 : '0', v50 : '10', v50_inc : '1', v75 : '30', v75_inc : '1', v100 : '60', v100_inc : '1', start_val : '2', formatting_class : '_years' }).render(); h += "
    "; h += "
    "; VAL = (itm) ? itm.months : '0'; h += frm.slider("months","Months:",VAL,"","",function(){ }, { v00 : '0', v50 : '6', v50_inc : '1', v75 : '9', v75_inc : '1', v100 : '11', v100_inc : '1', start_val : '0', formatting_class : '_months' }).render(); h += "
    "; // h += "
    How many months have you owned this business?
    "; // VAL = (itm) ? itm.income_llc_duration : '30'; // h += frm.slider("income_llc_duration","Months:",VAL,"","",function(){ // }, { // v00 : '0', // v50 : '30', // v50_inc : '1', // v75 : '45', // v75_inc : '1', // v100 : '60', // v100_inc : '1', // start_val : '30', // formatting_class : '_months' // }).render(); // h += "
    " // reveal - end // h += "
    "; // reveal - start (with validation to previous field) // h += frm.hr().render(); // // VAL = (itm) ? itm.llc_last_year_filed : ''; // h += frm.radio("llc_last_year_filed","What year did you file your taxes last?",VAL,"","",function(){ // $('#yearLast_llc').text(radio("llc_last_year_filed")); // $('#yearBeforeLast_llc').text(parseInt(radio("llc_last_year_filed")-1, 10)); // // },{ // 2015 : "2015", // 2016 : "2016", // 2017 : "2017", // 2018 : "2018" /*yrmrk*/ // }).render(); // h += "
    " // reveal - end let hr = frm.hr().render(); h += (function(){ let h = ""; VAL = MAR.getOpt(itm, "iscorp", ""); h += frm.yn3("iscorp","Do you file as a corporation?",VAL,"","",function(){ oc(); reveal(); },{}).render() return h; })().wrap("
    "+hr,"
    "); h += "
    "; // reveal - start (with validation to previous field) h += frm.hr('ShrunkTwice').render(); h += frm.elaine("Please fill in your profits before taxes. We’re looking for your revenue minus all of your expenses.","er").render(); // JC - CW - elaine added "er" h += `
    What was your profit in ${taxyear_c}?
    `; VAL = (itm) ? itm[`income_llc_${taxyear_c}`] : '0'; h += frm.slider(`income_llc_${taxyear_c}`,"Profit:",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += frm.hr().render(); h += `
    What was your profit in ${taxyear_p}?
    `; VAL = (itm) ? itm[`income_llc_${taxyear_p}`] : '0'; h += frm.slider(`income_llc_${taxyear_p}`,"Profit:",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += ""; h += (function(){ let h = ""; h += "
    "; VAL = (itm && itm.address) ? itm.address : ""; h += frm.address("address","
    From what location do you operate your business?
    ",VAL,"","",function(){ // //oc(); },{}).render() return h; })().wrap("
    "+hr,"
    "); h += (function(){ let h = ""; VAL = (itm && itm.tel) ? itm.tel : ""; if (VAL == "") VAL = MAR.getApplicantPhone(applicantnum); h += frm.txt("tel","Business phone number",VAL,"___-___-____","",function(){ }).render(); h += "
    "; VAL = (itm && itm.email) ? itm.email : ""; if (VAL == "") VAL = MAR.getApplicantEmail(applicantnum); h += frm.txt("email","Business Email",VAL,"e.g. CM@KW.com","",function(){}).render(); return h; })().wrap("

    ","
    "); h += (function(){ let h = ""; VAL = (itm) ? MAR.getOpt(itm, "special_rel", "") : ''; h += frm.hr().render(); h += frm.yn3("special_rel","Are you employed by a family member, property seller, real estate agent, or other party to the transaction?",VAL,"","",function(){ oc(); },{}).render(); // itm.special_rel = yn3("#special_rel"); // if (itm.special_rel === "") { // mar.tip(".help-button","warning","You need to tell us if you are part of the transaction.","top"); // return; // } return h; })().wrap("
    ","
    "); h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ let reveal = function() { let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "name_llc") { val = txt("#name_llc"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the name of your company.","top"); return; } } // if (validation == "income_llc_equity") { // val = txt("#income_llc_equity"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","Please tell us how much you own of the company.","top"); // return; // } // } if (validation == "income_llc_duration") { val = txt("#years")+txt("#months"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us how long you have owned this business.","top"); return; } } // if (validation == "llc_last_year_filed") { // val = radio("llc_last_year_filed"); // // if (val == '' ) { // mar.tip(".help-button","warning","You need to tell us the last year you filed.","top"); // return; // } // } if (validation == `income_llc_${taxyear_c}`) { val = txt(`#income_llc_${taxyear_c}`); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell the profit from last year.","top"); return; } } if (validation == `income_llc_${taxyear_p}`) { val = txt(`#income_llc_${taxyear_p}`); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell the profit from the year before last.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } return false; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ if (reveal() !== false) return; /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "llc"; itm.name_llc = txt("#name_llc"); itm.address = txt("#address"); itm.income_llc_equity = "100"; ///txt("#income_llc_equity"); itm.months = txt("#months"); itm.years = txt("#years"); itm.tel = txt("#tel"); itm.email = txt("#email"); itm.special_rel = yn3("#special_rel"); itm.iscorp = yn3("#iscorp"); itm.income_llc_duration = (num(itm.years) * 12) + num(itm.months) itm.llc_last_year_filed = taxyear_c; itm[`income_llc_${taxyear_c}`] = frm.profit_and_loss.val(`#income_llc_${taxyear_c}`); itm[`income_llc_${taxyear_p}`] = frm.profit_and_loss.val(`#income_llc_${taxyear_p}`); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if ((num(itm.years.trim()) + num(itm.months.trim())) == 0 ) { mar.tip(".help-button","warning","You need to tell us how long you have been self employed.","top"); return; } if (itm.name_llc.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the name of your company.","top"); return; } if (itm.income_llc_equity.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us how much you own of the company.","top"); return; } if (itm.income_llc_duration == 0 ) { mar.tip(".help-button","warning","Please tell us how long you have owned this business.","top"); return; } if (itm.iscorp.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us if you file as a coporation.","top"); return; } // if (itm.llc_last_year_filed.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us the last year you filed.","top"); // return; // } // if (itm[`income_llc_${taxyear_c}`].trim().length == 0 ) { // mar.tip(".help-button","warning","Please tell the profit from last year.","top"); // return; // } // // // if (itm[`income_llc_${taxyear_p}`].trim().length == 0 ) { // mar.tip(".help-button","warning","Please tell the profit from the year before last.","top"); // return; // } if (itm.address.trim().length == 0 ) { mar.tip(".help-button","warning","Please select a business address.","top"); return; } if (itm.tel.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the telephone number.","top"); return; } if (itm.email.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the business email.","top"); return; } if (itm.special_rel === "") { mar.tip(".help-button","warning","You need to tell us if you are part of the transaction.","top"); return; } /** * validation block end */ let _insertindex = MAR.income.set(applicantnum, itm.type, existingid, itm); mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); getIncome_v2(); let _warnings = mar.answers.v2.income[applicantnum].items[_insertindex].warnings; if (_warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warning").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { if (typeof _warnings[_wi] !== "undefined") { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mvc.go("#income-how"+"."+applicantnum); swal.close(); } }); } else { mvc.go("#income-how"+"."+applicantnum); } // var rv = getIncome_v2() // var numWarnings = $(".income_llc .warnings .elaine").length; // // if (rules.haswarnings("income_llc",an)) { // displayInlineWarnings (rules.getwarnings("income_llc",an) ,".income_llc"); // //mar.tip(".in-nxt-but-llc","warning",rules.getwarnings("income_llc",an),"top"); // }else{ // clearInlineWarnings(rules.getwarnings("income_llc",an)); // } // addIncome(rv); // // if (numWarnings != $(".income_llc .warnings .elaine").length) return; // clearInlineWarnings(rules.getwarnings("income_llc",an)); // document.location.href="#income_simple."+mar.state.applicantnumber; //toggle("income_llc"); // close popup }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { //JC - need to check for less tahn two years operation. Refer to the doc for info on what to say. //JC - if more than 5 years, possible freddy mac //JC - check for declining income. IF so, use and elaine to let them know let iscorp = yn3("#iscorp"); if (iscorp === "Y") { $("#body-container .k1").html("K1 "); } else { $("#body-container .k1").html(""); } } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#body-container ._percentage").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character suffix: "%", rightAlign: false, autoUnmask : true }); if ($("#body-container").find("#address-disp").length > 0) { uihelpers.addresspopup_init($("#body-container").find("#address-disp")); } $("#body-container #tel").inputmask("(999) - 999 - 9999", { autoUnmask: true }); $("#body-container #tel").euiInputTel(); $('#yearLast_llc').text(radio("llc_last_year_filed")); $('#yearBeforeLast_llc').text(parseInt(radio("llc_last_year_filed")-1, 10)); let labels = $(".cfc_label_title_multiple"); for (let i=0; i < labels.length; i++) { let $label = $(labels[i]); if ($label[0].id.startsWith("lbl_income_llc")) { frm.profit_and_loss.add($label); } } $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-k1"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"k1",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let taxyear_c = MAR.getApplicantLastTaxYear(applicantnum); let taxyear_p = MAR.getApplicantLastTaxYear(applicantnum)-1; let year_c = MAR.getCurrentYear(); let year_p = MAR.getCurrentYear()-1; /** * standard starting block - END */ let CTYPE = (itm && "ctype" in itm) ? itm.ctype : ""; if (CTYPE == "") { if ("_ctype" in mar && mar._ctype !== false) { CTYPE = mar._ctype; } else { CTYPE = "c"; } } let h = ""; let ctype_txt = ""; if (CTYPE == "p") { h += frm.htitle("Partnership").render(); ctype_txt = "Partnership"; } else if (CTYPE == "s") { h += frm.htitle("S-Corporation").render(); ctype_txt = "S-corp"; } else { h += frm.htitle("C-Corporation").render(); ctype_txt = "C-corp"; } if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { if (num(itm[`income_corp_c`]) === 0) { itm[`income_corp_c`] = num(itm.sug_total) * 12; itm[`income_corp_p`] = num(itm.sug_total) * 12; } } /** * block for overrides */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { mar.pg_accesscontrollerfn = function() { return "open"; } } let overridden = (itm && MAR.getOpt(itm, "over", "") === "Y"); if (overridden) { h += mar.tmp_pg_overblock(itm); } /** * end block */ h += frm.elaine(`You own a ${ctype_txt} that files its own tax returns? Cool!`,"er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div h += "
    What is the name of your business?
    "; VAL = (itm) ? itm.name_k1 : MAR.income.has_w2_with_ownership_first_name(applicantnum); h += frm.txt("name_k1","",VAL,"e.g. John Smith Plumbing","",function(){}).render(); h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += "
    What percentage of this business do you own?
    "; VAL = (itm) ? itm.income_k1_equity : '100'; let EQUITY_VAL = num(VAL); h += frm.slider("income_k1_equity","Equity:",VAL,"","",function(){ // if (num(txt("#income_k1_equity")) < 100) { // $(".income_k1_profitperc").removeClass("x-hide") // } else { // $(".income_k1_profitperc").addClass("x-hide") // } }, { v00 : '0', v50 : '50', v50_inc : '1', v75 : '75', v75_inc : '1', v100 : '100', v100_inc : '1', start_val : '50', formatting_class : '_percentage' }).render(); h += "
    " // reveal - end // let x_hide = (EQUITY_VAL == 100) ? "x-hide" : ""; // h += (function(){ // let h = ""; // h += "
    What percentage of profits are you entitled to?
    "; // // VAL = (itm) ? itm.income_k1_profitperc : '100'; // h += frm.slider("income_k1_profitperc","Profit:",VAL,"","",function(){ // }, { // v00 : '0', // v50 : '50', // v50_inc : '1', // v75 : '75', // v75_inc : '1', // v100 : '100', // v100_inc : '1', // start_val : '50', // formatting_class : '_percentage' // }).render(); // // h += "
    " // reveal - end // return h; // // })().wrap(`
    `,"
    "); h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += "
    How long have you owned this business?
    "; h += "
    "; VAL = (itm) ? itm.income_k1_duration_years : '0'; h += frm.slider("income_k1_duration_years","Years:",VAL,"","",function(){ }, { v00 : '0', v50 : '10', v50_inc : '1', v75 : '30', v75_inc : '1', v100 : '60', v100_inc : '1', start_val : '2', formatting_class : '_years' }).render(); h += "
    "; h += "
    "; VAL = (itm) ? itm.income_k1_duration_months : '0'; h += frm.slider("income_k1_duration_months","Months:",VAL,"","",function(){ }, { v00 : '0', v50 : '6', v50_inc : '1', v75 : '9', v75_inc : '1', v100 : '11', v100_inc : '1', start_val : '0', formatting_class : '_months' }).render(); h += "
    "; /* VAL = (itm) ? itm.income_k1_duration : '30'; h += frm.slider("income_k1_duration","Months:",VAL,"","",function(){ }, { v00 : '0', v50 : '30', v50_inc : '1', v75 : '45', v75_inc : '1', v100 : '60', v100_inc : '1', start_val : '30', formatting_class : '_months' }).render(); */ // h += "
    "; //h += frm.h2("Note: For business income to be useful for the loan calculation, we need at least 24 months in business, with two tax returns filed. This income will be subject to an underwriter approval.").render(); h += "
    "; // reveal - end if (CTYPE == "c") { h += "
    "; // reveal - start (with validation to previous field) h += frm.hr('ShrunkTwice').render(); // h += frm.elaine("Please look up your K1 income at the very end of your 1120 business taxes.","er").render(); // JC - CW - elaine added "er" if (MAR.income.has_w2_with_ownership(applicantnum) === false) { h += frm.inline_warning_red("If you also draw salary from your company, please fill this in under W2 income."); h += "
    "; } //h += ``; //h += ``; h += `
    What dividend did you pay yourself in ${taxyear_c}
    `; VAL = (itm) ? itm[`income_corp_${taxyear_c}`] : '0'; h += frm.slider(`income_corp_${taxyear_c}`,"Dividend:",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += frm.hr().render(); h += `
    What dividend did you pay yourself in ${taxyear_p}
    }`; VAL = (itm) ? itm[`income_corp_${taxyear_p}`] : '0'; h += frm.slider(`income_corp_${taxyear_p}`,"Dividend:",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += `
    How much salary did you draw in ${taxyear_c}?
    `; VAL = (itm) ? itm.income_w2_c : '0'; h += frm.slider("income_w2_c","",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += frm.hr().render(); h += `
    How much salary did you draw in ${taxyear_p}?
    `; VAL = (itm) ? itm.income_w2_p : '0'; h += frm.slider("income_w2_p","",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); } else if (CTYPE == "s") { h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.k1_last_year_filed : taxyear_c; h += frm.radio("k1_last_year_filed","What year did you file your taxes last?",VAL,"","",function(){ $('.yearLast_k1').text(radio("k1_last_year_filed")); $('.yearBeforeLast_k1').text(parseInt(radio("k1_last_year_filed")-1, 10)); },{ 2018 : "2018", /*yrmrk*/ 2019 : "2019", /*yrmrk*/ 2020 : "2020", /*yrmrk*/ 2021 : "2021", /*yrmrk*/ 2022 : "2022", /*yrmrk*/ 2023 : "2023" /*yrmrk*/ }).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr('ShrunkTwice').render(); h += frm.elaine("Please look up your K1 income at the very end of your 1120 business taxes.","er").render(); // JC - CW - elaine added "er" if (MAR.income.has_w2_with_ownership(applicantnum) === false) { h += frm.inline_warning_red("If you also draw salary from your company, please fill this in under W2 income."); h += "
    "; } h += "
    What was your K1 profit in 2017?
    "; VAL = (itm) ? itm.income_corp_c : '0'; h += frm.slider("income_corp_c","Profit:",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += frm.hr().render(); h += "
    What was your K1 profit in 2016?
    "; VAL = (itm) ? itm.income_corp_p : '0'; h += frm.slider("income_corp_p","Profit:",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += "
    "; // reveal - start (with validation to previous field) h += frm.hr('ShrunkTwice').render(); // h += frm.elaine("Please look up your K1 income at the very end of your 1120 business taxes.","er").render(); // JC - CW - elaine added "er" // if (MAR.income.has_w2_with_ownership(applicantnum) === false) { // h += frm.inline_warning_red("If you also draw salary from your company, please fill this in under W2 income."); // h += "
    "; // } h += "
    How much salary did you draw in 2017?
    "; VAL = (itm) ? itm.income_w2_c : '0'; h += frm.slider("income_w2_c","",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += frm.hr().render(); h += "
    How much salary did you draw in 2016?
    "; VAL = (itm) ? itm.income_w2_p : '0'; h += frm.slider("income_w2_p","",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); } else { h += "
    "; // reveal - start (with validation to previous field) h += frm.hr('ShrunkTwice').render(); h += frm.elaine("Please look up your K1 income at the very end of your 1120 business taxes.","er").render(); // JC - CW - elaine added "er" if (MAR.income.has_w2_with_ownership(applicantnum) === false) { h += frm.inline_warning_red("If you also draw salary from your company, please fill this in under W2 income."); h += "
    "; } h += `
    What was your K1 profit share in ${taxyear_c}?
    `; VAL = (itm) ? itm[`income_corp_${taxyear_c}`] : '0'; h += frm.slider(`income_corp_${taxyear_c}`,"Profit:",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += frm.hr().render(); h += `
    What was your K1 profit share in ${taxyear_p}?
    `; VAL = (itm) ? itm[`income_corp_${taxyear_p}`] : '0'; h += frm.slider(`income_corp_${taxyear_p}`,"Profit:",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += `
    How much salary did you draw in ${taxyear_c}?
    `; VAL = (itm) ? itm.income_w2_c : '0'; h += frm.slider("income_w2_c","",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); h += frm.hr().render(); h += `
    How much salary did you draw in ${taxyear_p}?
    `; VAL = (itm) ? itm.income_w2_p : '0'; h += frm.slider("income_w2_p","",VAL,"","",function(){ }, { v00 : '0', v50 : '15000', v50_inc : '500', v75 : '35000', v75_inc : '500', v100 : '200000', v100_inc : '1000', start_val : '0' }).render(); } h += ""; let hr = frm.hr().render(); h += (function(){ let h = ""; h += "
    "; VAL = (itm && itm.address) ? itm.address : ""; h += frm.address("address","
    From what location do you operate your business?
    ",VAL,"","",function(){ // //oc(); },{}).render() return h; })().wrap("
    "+hr,"
    "); h += (function(){ let h = ""; VAL = (itm && itm.tel) ? itm.tel : ""; if (VAL == "") VAL = MAR.getApplicantPhone(applicantnum); h += frm.txt("tel","Business phone number",VAL,"___-___-____","",function(){ }).render(); h += "
    "; VAL = (itm && itm.email) ? itm.email : ""; if (VAL == "") VAL = MAR.getApplicantEmail(applicantnum); h += frm.txt("email","Business Email",VAL,"e.g. CM@KW.com","",function(){}).render(); return h; })().wrap("

    ","
    "); h += (function(){ let h = ""; VAL = (itm) ? MAR.getOpt(itm, "special_rel", "") : ''; h += frm.hr().render(); h += frm.yn3("special_rel","Are you employed by a family member, property seller, real estate agent, or other party to the transaction?",VAL,"","",function(){ oc(); },{}).render(); // itm.special_rel = yn3("#special_rel"); // if (itm.special_rel === "") { // mar.tip(".help-button","warning","You need to tell us if you are part of the transaction.","top"); // return; // } return h; })().wrap("
    ","
    "); h += "
    "; // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "name_k1") { val = txt("#name_k1"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the name of your company.","top"); return; } } if (validation == "income_k1_equity") { val = txt("#income_k1_equity"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us what percentage you own of the company.","top"); return; } } if (validation == "income_k1_duration_months") { if(txt("#income_k1_duration_months").trim().length == 0 && txt("#income_k1_duration_years").trim().length == 0){ mar.tip(".help-button","warning","Please tell us how long you have owned the company.","top"); return; } /* val = txt("#income_k1_duration"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us how long you have owned the company.","top"); return; } */ } if (validation == "k1_last_year_filed") { val = radio("k1_last_year_filed"); if (val == '' ) { mar.tip(".help-button","warning","You need to tell us the last year you filed.","top"); return; } } // if (validation == "income_corp_2017") { // val = txt("#income_corp_2017"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us how much profit you made in the last year you filed.","top"); // return; // } // } // // if (validation == "income_corp_2017") { // val = txt("#income_corp_2016"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us how much profit you made in the year before the last year you filed.","top"); // return; // } // } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); if (!warned) { if ($(".inline-warning").is(":visible") == true) { warn(); warned = true; } } }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "k1"; itm.ctype = CTYPE; itm.name_k1 = txt("#name_k1"); itm.income_k1_equity = txt("#income_k1_equity"); itm.income_k1_profitperc = txt("#income_k1_equity"); itm.income_k1_duration_years = txt("#income_k1_duration_years"); itm.income_k1_duration_months = txt("#income_k1_duration_months"); itm.tel = txt("#tel") itm.email = txt("#email") itm.special_rel = yn3("#special_rel"); if (CTYPE == "s") { itm.k1_last_year_filed = radio("k1_last_year_filed"); itm.income_corp_c = frm.profit_and_loss.val("#income_corp_c"); itm.income_corp_p = frm.profit_and_loss.val("#income_corp_p"); itm.income_w2_c = frm.profit_and_loss.val("#income_w2_c"); itm.income_w2_p = frm.profit_and_loss.val("#income_w2_p"); let lyf = num(itm.k1_last_year_filed); itm[`income_corp_${lyf}`] = txt(`#income_corp_c`); itm[`income_corp_${lyf-1}`] = txt(`#income_corp_p`); } else { itm.k1_last_year_filed = taxyear_c; itm[`income_corp_${taxyear_c}`] = frm.profit_and_loss.val(`#income_corp_${taxyear_c}`); itm[`income_corp_${taxyear_p}`] = frm.profit_and_loss.val(`#income_corp_${taxyear_p}`); itm.income_w2_c = frm.profit_and_loss.val("#income_w2_c"); itm.income_w2_p = frm.profit_and_loss.val("#income_w2_p"); } itm.address = txt("#address"); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (itm.name_k1.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the name of your company.","top"); return; } if (itm.income_k1_equity.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us what percentage you own of the company.","top"); return; } if((num(itm.income_k1_duration_years.trim()) + num(itm.income_k1_duration_months.trim())) == 0){ mar.tip(".help-button","warning","Please tell us how long you have owned the company.","top"); return; } if (CTYPE == "s") { if (itm.k1_last_year_filed.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the last year you filed.","top"); return; } // if (itm.income_corp_c.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us how much profit you made in the last year you filed.","top"); // return; // } // // // if (itm.income_corp_p.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us how much profit you made in the year before the last year you filed.","top"); // return; // } } else { // if (itm[`income_corp_${taxyear_c}`].trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us how much profit you made in the last year you filed.","top"); // return; // } // // // if (itm[`income_corp_${taxyear_p}`].trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us how much profit you made in the year before the last year you filed.","top"); // return; // } } if (itm.address.trim().length == 0 ) { mar.tip(".help-button","warning","Please select a business address.","top"); return; } if (itm.tel.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the telephone number.","top"); return; } if (itm.email.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the business email.","top"); return; } if (itm.special_rel === "") { mar.tip(".help-button","warning","You need to tell us if you are part of the transaction.","top"); return; } /** * validation block end */ let _insertindex = MAR.income.set(applicantnum, itm.type, existingid, itm); let w2_income = ~~(MAR.getOptNum(itm,"income_w2_c",0) + MAR.getOptNum(itm,"income_w2_p",0) / 2); let w2_link = MAR.getOpt(itm,"income_w2_link",``); if (w2_link !== ``) { let linked_income = MAR.income.getByUUID(w2_link); if (linked_income === false) { w2_link = ``; // it must have been deleted } } if (w2_income > 0 && w2_link === ``) { // alert(w2_income); let two_years_ago = moment().quarter(moment().quarter()).subtract(8, 'Q').startOf('quarter').format("YYYY-MM-DD"); let itm1 = {}; itm1.type = `w2`; itm1.current = `Y`; itm1.fromd = two_years_ago; itm1.end_date = ``; itm1.hours_per_week = 40; itm1.income_full_or_part = `fulltime`; itm1.income_w2_base = w2_income; itm1.income_w2_bonus_2021 = 0; itm1.income_w2_bonus_2022 = 0; itm1.income_w2_bonus_2023 = 0; itm1.income_w2_bonus_2024 = 0; itm1.income_w2_bonus_lastpay = ``; itm1.income_w2_bonus_ytd = 0; itm1.income_w2_commission_2021 = 0; itm1.income_w2_commission_2022 = 0; itm1.income_w2_commission_2023 = 0; itm1.income_w2_commission_2024 = 0; itm1.income_w2_commission_lastpay = ``; itm1.income_w2_commission_ytd = 0; itm1.income_w2_other_2021 = 0; itm1.income_w2_other_2022 = 0; itm1.income_w2_other_2023 = 0; itm1.income_w2_other_2024 = 0; itm1.income_w2_other_lastpay = ``; itm1.income_w2_other_ytd = 0; itm1.income_w2_overtime_2021 = 0; itm1.income_w2_overtime_2022 = 0; itm1.income_w2_overtime_2023 = 0; itm1.income_w2_overtime_2024 = 0; itm1.income_w2_overtime_lastpay = ``; itm1.income_w2_overtime_ytd = 0; itm1.name = `${itm.name_k1} W2`; itm1.own_all_or_part = (num(itm.income_k1_equity) >= 25) ? `Y` : `N`; itm1.per = itm.income_k1_equity; itm1.salary_3yearquestion =`Y`; itm1.salary_bonus =`N`; itm1.salary_commission =`N`; itm1.salary_overtime =`N`; itm1.salary_other =`N`; itm1.start_date =``; itm1.salary_choice = `yearly`; itm1.start_date = two_years_ago; itm1.verified = `Y`; itm1.special_rel = itm.special_rel; let parent_item = MAR.income.get(applicantnum,``, _insertindex); itm1._parent = parent_item.uuid; let _insertindex1 = MAR.income.set(applicantnum, itm1.type, false, itm1); let _this_item = MAR.income.get(applicantnum,``, _insertindex1); itm.income_w2_link = _this_item.uuid; MAR.income.set(applicantnum, itm.type, parent_item.uuid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); getIncome_v2(); let _warnings = mar.answers.v2.income[applicantnum].items[_insertindex].warnings; console.log("_warnings", _warnings); if (_warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warning").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { if (typeof _warnings[_wi] !== "undefined") { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mvc.go("#income-how"+"."+applicantnum); swal.close(); } }); } else { mvc.go("#income-how"+"."+applicantnum); } }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let warned = false; let warn = function() { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = $(".inline-warning").html();//"If you also draw salary from your company, please fill this in under W2 income."; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { // mvc.go("#income-how"+"."+applicantnum); swal.close(); } }); } let oc = function() { //JC - need to check for less tahn two years operation. Refer to the doc for info on what to say. //JC - if more than 5 years, possible freddy mac //JC - check for declining income. IF so, use and elaine to let them know if (!warned) { if ($(".inline-warning").is(":visible") == true) { warn(); warned = true; } } } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, allowMinus: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#body-container ._percentage").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character suffix: "%", rightAlign: false, autoUnmask : true }); if ($("#body-container").find("#address-disp").length > 0) { uihelpers.addresspopup_init($("#body-container").find("#address-disp")); } $("#body-container #tel").inputmask("(999) - 999 - 9999", { autoUnmask: true }); $("#body-container #tel").euiInputTel(); $('.yearLast_k1').text(radio("k1_last_year_filed")); $('.yearBeforeLast_k1').text(parseInt(radio("k1_last_year_filed")-1, 10)); if (CTYPE == "s") { let labels = $(".cfc_label_title_multiple"); for (let i=0; i < labels.length; i++) { let $label = $(labels[i]); if ($label[0].id.startsWith("lbl_income_corp")) { frm.profit_and_loss.add($label); } } } $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-rental"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let h = ""; h += frm.htitle("Rental").render(); h += frm.elaine("If your real estate is owned by a company, then use the 'LLC' button to enter annual profits.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div h += frm.h2("Privately owned real estate is entered in the real estate section later in the application.").render(); h += "
    "; h += "
    "; h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); // &&& mar.pg["income-disability"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"disability",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { if (num(itm[`dis_income`]) === 0) { itm[`dis_income`] = num(itm.sug_total); } } let h = ""; h += frm.htitle("Disability").render(); /** * block for overrides */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { mar.pg_accesscontrollerfn = function() { return "open"; } } let overridden = (itm && MAR.getOpt(itm, "over", "") === "Y"); if (overridden) { h += mar.tmp_pg_overblock(itm); } /** * end block */ h += frm.elaine("How much disability income do you get each month?","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div VAL = (itm) ? itm.dis_income : ''; // prefill if itm is not false h += frm.slider("dis_income","Total monthly income:",VAL,"","",function(){ }, { v00 : '0', v50 : '5000', v50_inc : '100', v75 : '7500', v75_inc : '100', v100 : '10000', v100_inc : '100', start_val : '5000' }).render(); h += frm.hr().render(); h += (function(){ let h = ""; h += frm.inline_warning_red(`Sometimes Disability income is received tax free. We can see this on your tax returns. `+ `If it is received tax free, we may be able to use 25% higher income than you receive.`); h += `
    `; VAL = (itm) ? itm.dis_dont_pay_taxes : ''; // prefill if itm is not false h += frm.yn3("dis_dont_pay_taxes","I receive this income tax free?",(VAL),"","",function(){},{}).render(); h += frm.hr().render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; VAL = (itm) ? itm.dis_more_3_years : ''; // prefill if itm is not false h += frm.yn3("dis_more_3_years","Will you receive this income for at least 3 more years.",VAL,"","",function(){},{}).render(); h += frm.hr().render(); return h; })().wrap("
    ","
    ") h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "dis_income") { var val = txt("#dis_income"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know your income.","top"); return; } } if (validation == "dis_dont_pay_taxes") { var val = yn3("#dis_dont_pay_taxes"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know if you pay taxes on this income.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "dis"; itm.dis_income = txt("#dis_income"); itm.dis_more_3_years = yn3("#dis_more_3_years"); itm.dis_dont_pay_taxes = yn3("#dis_dont_pay_taxes"); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (itm.dis_income.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know your income.","top"); return; } if (num(itm.dis_income) < 0 ) { mar.tip(".help-button","warning","Income must be positive.","top"); return; } if (itm.dis_dont_pay_taxes.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know whether it is subject to tax.","top"); return; } if (itm.dis_more_3_years.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know if you will recieve this for 3 more years.","top"); return; } /** * validation block end */ let _insertindex = MAR.income.set(applicantnum, itm.type, existingid, itm); mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); getIncome_v2(); let _warnings = mar.answers.v2.income[applicantnum].items[_insertindex].warnings; if (_warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warning").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { if (typeof _warnings[_wi] !== "undefined") { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mvc.go("#income-how"+"."+applicantnum); swal.close(); } }); } else { mvc.go("#income-how"+"."+applicantnum); } }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { //JC - need to check for less tahn two years operation. Refer to the doc for info on what to say. //JC - if more than 5 years, possible freddy mac //JC - check for declining income. IF so, use and elaine to let them know } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-child-support"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"child",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { if (num(itm[`child_income`]) === 0) { itm[`child_income`] = num(itm.sug_total); } } let h = ""; h += frm.htitle("Child support").render(); /** * block for overrides */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { mar.pg_accesscontrollerfn = function() { return "open"; } } let overridden = (itm && MAR.getOpt(itm, "over", "") === "Y"); if (overridden) { h += mar.tmp_pg_overblock(itm); } /** * end block */ h += frm.elaine("Child support can only be used as income if you will receive the benefits for at least 3 more years. Besides that, you will need to proof that you have received your child support in a timely manner over the last 6 months.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div VAL = (itm) ? itm.child_questions_confirmation : 'N'; // JC : can you create a small check box object that uses this formatting? not a bad idea. h += "
    "; h += ""; h += "I understand"; h += "
    "; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += "
    What is the first name of your child?
    "; VAL = (itm) ? itm.child_name : ''; h += frm.txt("child_name","",VAL,"e.g. John","",function(){}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.child_income : ''; h += frm.slider("child_income","Total monthly income:",VAL,"","",function(){ }, { v00 : '0', v50 : '1000', v50_inc : '50', v75 : '5000', v75_inc : '100', v100 : '10000', v100_inc : '200', start_val : '1000' }).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.child_more_3_years : ''; h += frm.yn3("child_more_3_years","I will receive this income for at least 3 more years.",VAL,"","",function(){ reveal(); },{}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.child_proof : ''; h += frm.yn3("child_proof","I can prove I consistently recieved child support for the last 6 months.",VAL,"","",function(){ reveal(); },{}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.inline_warning_red(`Sometimes Child support income is received tax free. We can see this on your tax returns. `+ `If it is received tax free, we may be able to use 25% higher income than you receive.`); h += `
    `; VAL = (itm) ? itm.child_dont_pay_taxes : ''; h += frm.yn3("child_dont_pay_taxes","I receive this tax free?",(VAL),"","",function(){ reveal(); },{}).render(); h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ let reveal = function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "child_questions_confirmation") { var val = yn("#child_questions_confirmation"); if (val == 'N' ) { mvc.go("#income-how"+"."+applicantnum); return; } } if (validation == "child_name") { var val = txt("#child_name"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know your childs name.","top"); return; } } if (validation == "child_income") { var val = txt("#child_income"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know how much you receive in child support.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } return true; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (reveal() !== true) return; /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "child"; itm.child_questions_confirmation = yn("#child_questions_confirmation"); itm.child_name = txt("#child_name"); itm.child_income = txt("#child_income"); itm.child_more_3_years = yn3("#child_more_3_years"); itm.child_proof = yn3("#child_proof"); itm.child_dont_pay_taxes = yn3("#child_dont_pay_taxes"); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (itm.child_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know your childs name.","top"); return; } if (itm.child_income.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know how much you receive in child support.","top"); return; } if (num(itm.child_income) < 0 ) { mar.tip(".help-button","warning","Income must be positive.","top"); return; } if (itm.child_more_3_years.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know the duration.","top"); return; } if (itm.child_proof.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know if youn prove the payments.","top"); return; } if (itm.child_dont_pay_taxes.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know whether it is subject to tax.","top"); return; } /** * validation block end */ let _insertindex = MAR.income.set(applicantnum, itm.type, existingid, itm); mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); getIncome_v2(); let _warnings = mar.answers.v2.income[applicantnum].items[_insertindex].warnings; if (_warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warning").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { if (typeof _warnings[_wi] !== "undefined") { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mvc.go("#income-how"+"."+applicantnum); swal.close(); } }); } else { mvc.go("#income-how"+"."+applicantnum); } }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { //JC - need to check for less tahn two years operation. Refer to the doc for info on what to say. //JC - if more than 5 years, possible freddy mac //JC - check for declining income. IF so, use and elaine to let them know // JC : can you create a small check box object that uses this formatting? not a bad idea. see line 973. call it checkButton perhaps } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-alimony"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"alimony",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { if (num(itm[`alimony_income`]) === 0) { itm[`alimony_income`] = num(itm.sug_total); } } let h = ""; h += frm.htitle("Alimony").render(); /** * block for overrides */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { mar.pg_accesscontrollerfn = function() { return "open"; } } let overridden = (itm && MAR.getOpt(itm, "over", "") === "Y"); if (overridden) { h += mar.tmp_pg_overblock(itm); } /** * end block */ h += frm.elaine("Do NOT enter anything unless you can prove that you have received this consistently for the last 6 months.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div VAL = (itm) ? itm.alimony_questions_confirmation : 'N'; // JC : can you create a small check box object that uses this formatting? not a bad idea. h += "
    "; h += ""; h += "I understand"; h += "
    "; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.alimony_income : ''; h += frm.slider("alimony_income","Total monthly income:",VAL,"","",function(){ }, { v00 : '0', v50 : '1000', v50_inc : '50', v75 : '5000', v75_inc : '100', v100 : '10000', v100_inc : '200', start_val : '1000' }).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.alimony_more_3_years : ''; h += frm.yn3("alimony_more_3_years","I will receive this income for at least 3 more years.",VAL,"","",function(){ reveal(); },{}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.inline_warning_red(`Sometimes Alimony income is received tax free. We can see this on your tax returns. `+ `If it is received tax free, we may be able to use 25% higher income than you receive.`); h += `
    `; VAL = (itm) ? itm.alimony_dont_pay_taxes : ''; h += frm.yn3("alimony_dont_pay_taxes","I receive this tax free?",(VAL),"","",function(){},{}).render(); h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ let reveal = function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "alimony_questions_confirmation") { var val = yn("#alimony_questions_confirmation"); if (val == 'N' ) { mvc.go("#income-how"+"."+applicantnum); return; } } if (validation == "alimony_income") { var val = txt("#alimony_income"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know how much you receive in alimony.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } return true; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block end */ if (reveal() !== true) return; if (!existingid) { itm = {}; } itm.type = "alimony"; itm.alimony_questions_confirmation = yn("#alimony_questions_confirmation"); itm.alimony_income = txt("#alimony_income"); itm.alimony_more_3_years = yn3("#alimony_more_3_years"); itm.alimony_dont_pay_taxes = yn3("#alimony_dont_pay_taxes"); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (itm.alimony_income.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know how much you receive in alimony.","top"); return; } if (num(itm.alimony_income) < 0 ) { mar.tip(".help-button","warning","Income must be positive.","top"); return; } if (itm.alimony_more_3_years.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know the duration.","top"); return; } if (itm.alimony_dont_pay_taxes.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know whether it is subject to tax.","top"); return; } /** * validation block end */ let _insertindex = MAR.income.set(applicantnum, itm.type, existingid, itm); mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); getIncome_v2(); let _warnings = mar.answers.v2.income[applicantnum].items[_insertindex].warnings; if (_warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warning").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { if (typeof _warnings[_wi] !== "undefined") { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mvc.go("#income-how"+"."+applicantnum); swal.close(); } }); } else { mvc.go("#income-how"+"."+applicantnum); } }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { //JC - need to check for less tahn two years operation. Refer to the doc for info on what to say. //JC - if more than 5 years, possible freddy mac //JC - check for declining income. IF so, use and elaine to let them know // JC : can you create a small check box object that uses this formatting? not a bad idea. see line 973. call it checkButton perhaps } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-social-security"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"ssec",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let readonly = false; /** * standard starting block - END */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { if (num(itm[`ssec_income`]) === 0) { itm[`ssec_income`] = num(itm.sug_total); } } let h = ""; h += frm.htitle("Social security").render(); /** * block for overrides */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { mar.pg_accesscontrollerfn = function() { return "open"; } } let overridden = (itm && MAR.getOpt(itm, "over", "") === "Y"); if (overridden) { h += mar.tmp_pg_overblock(itm); } /** * end block */ h += frm.elaine("Every year you receive a social security awards letter. Aka a proof of income letter. Please fill out your monthly income.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div VAL = (itm) ? itm.ssec_income : ''; h += frm.slider("ssec_income","Total monthly income:",VAL,"","",function(){ }, { v00 : '0', v50 : '5000', v50_inc : '100', v75 : '7500', v75_inc : '100', v100 : '10000', v100_inc : '100', start_val : '5000' }).render(); h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += frm.inline_warning_red(`Mostly Social security income is received tax free. We can see this on your tax returns. `+ `If it is received tax free, we may be able to use 25% higher income than you receive.`); h += `
    `; VAL = (itm) ? itm.ssec_dont_pay_taxes : ''; h += frm.yn3("ssec_dont_pay_taxes","I receive this tax free.",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ //h += uihelpers.cbuttonbar("","","","","mar.help()"); h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "ssec_income") { var val = txt("#ssec_income"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us the amount of social security you receive.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "ssec"; itm.ssec_income = txt("#ssec_income"); itm.ssec_dont_pay_taxes = yn3("#ssec_dont_pay_taxes"); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (itm.ssec_income.trim().length == 0 ) { mar.tip(".help-button","warning","Please tell us the amount of social security you receive.","top"); return; } if (num(itm.ssec_income) < 0 ) { mar.tip(".help-button","warning","Income must be positive.","top"); return; } /** * validation block end */ let _insertindex = MAR.income.set(applicantnum, itm.type, existingid, itm); mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); getIncome_v2(); let _warnings = mar.answers.v2.income[applicantnum].items[_insertindex].warnings; if (_warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warning").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { if (typeof _warnings[_wi] !== "undefined") { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mvc.go("#income-how"+"."+applicantnum); swal.close(); } }); } else { mvc.go("#income-how"+"."+applicantnum); } }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { //JC - need to check for less tahn two years operation. Refer to the doc for info on what to say. //JC - if more than 5 years, possible freddy mac //JC - check for declining income. IF so, use and elaine to let them know } let or = function(){ let setupPage = function() { $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } let setupPageReadOnly = function(detailHtmlBlock, newElaineTitle) { // $("#body-container").find(".xx-radio").myradio(); // $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider_ro(); // // $("#body-container ._dollars").inputmask("numeric", { // radixPoint: ".", // groupSeparator: ",", // digits: 2, // autoGroup: true, // prefix: '$', //No Space, this will truncate the first character // rightAlign: false, // autoUnmask : true // }); $(".next-button").remove(); $($("#body-container .xhuman")[0]).html(newElaineTitle); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { $(".elaine").after("
    " + detailHtmlBlock + "
    You entered the following:"); oc = function(){} } }, quick : false, }); } function checkIfIncomeHasBeenQualified() { if (!itm) { setupPage(); return; } let obb = mar.objectBlockBuilder(); $.get(`/api/sync/getBorrowers?appid=${mar.ID}&view=incomesafety`, function(res) { let da = ("data" in res) ? res.data : res; if (da.length == 0) return; if ("uuid" in itm && itm.uuid in da) { let _da = da[itm.uuid]; let confidence = ("CONFIDENCE" in _da) ? _da.CONFIDENCE : 0; if (confidence < 3) { // nothing to do setupPage(); } else if (confidence < 6) { obb.title("This Income has subsequently been verified by a loan officer and you cannot any more change it here. However here we show the values you entered, and the newly calculated values:"); obb.add("Your answer:", _da.EL_TOTAL); obb.add("Observed data:", _da.CONFIDENCE_OBV); // obb.add(`${_da.CONFIDENCE_TXT2}`); $(".elaine span").append(`

    This Income has subsequently been verified by a loan office and you cannot any more change it here`+ `

    ${_da.CONFIDENCE_TXT2}`); $(".next-button").remove(); $.get(`/api/uberwriter/qi?id=${mar.ID}`, function(res) { //debugger; let da = ("data" in res) ? res.data : res; if (da.length == 0) { setupPageReadOnly(obb.render(), obb.title()); return; } let h = ""; let qi_total = 0; if (itm && "uuid" in itm && itm.uuid in da) { //$(".elaine span").append(`

    `) obb.add("Calculated data:", elaineui.format("cur",da[itm.uuid])); // obb.add(`This total has been assessed for Qualifying income by Uberwriter at ${elaineui.format("cur",da[itm.uuid])}`) setupPageReadOnly(obb.render(), obb.title()); } }); } } }); } checkIfIncomeHasBeenQualified(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); // &&& mar.pg["income-pension"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"pension",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { if (num(itm[`pension_income`]) === 0) { itm[`pension_income`] = num(itm.sug_total); } } let h = ""; h += frm.htitle("Pension").render(); /** * block for overrides */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { mar.pg_accesscontrollerfn = function() { return "open"; } } let overridden = (itm && MAR.getOpt(itm, "over", "") === "Y"); if (overridden) { h += mar.tmp_pg_overblock(itm); } /** * end block */ h += frm.elaine(na+", every year you receive a pension awards letter. Aka a proof of income letter. Please fill out the monthly income from this letter.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div VAL = (itm) ? itm.pension_income : ''; // prefill if itm is not false h += frm.slider("pension_income","Total monthly income in my awards letter:",VAL,"","",function(){ }, { v00 : '0', v50 : '5000', v50_inc : '100', v75 : '7500', v75_inc : '100', v100 : '10000', v100_inc : '100', start_val : '5000' }).render(); h += "
    "; // reveal - start h += "
    Name former employer?
    "; VAL = ''; VAL = (itm) ? itm.pension_former_employer : ''; // prefill if itm is not false h += frm.txt("pension_former_employer","",VAL,"e.g. Walmart","",function(){}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += frm.inline_warning_red(`Sometimes Pension income is received tax free. We can see this on your tax returns. `+ `If it is received tax free, we may be able to use 25% higher income than you receive.`); h += `
    `; VAL = 'N'; VAL = (itm) ? itm.pension_dont_pay_taxes : ''; // prefill if itm is not false // h += frm.yn3("pension_dont_pay_taxes","I receive this without giving a part to Uncle Sam (gross is net).",VAL,"","",function(){},{}).render(); h += frm.yn3("pension_dont_pay_taxes","My pension income is received tax free?",(VAL),"","",function(){},{}).render(); h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "pension_income") { var val = txt("#pension_income"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know your pension income.","top"); return; } } if (validation == "pension_former_employer") { var val = txt("#pension_former_employer"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know the name of your previous employer.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "pension"; itm.pension_income = txt("#pension_income"); itm.pension_former_employer = txt("#pension_former_employer"); itm.pension_dont_pay_taxes = yn3("#pension_dont_pay_taxes"); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (itm.pension_income.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know your pension income.","top"); return; } if (num(itm.pension_income) < 0 ) { mar.tip(".help-button","warning","Income must be positive.","top"); return; } if (itm.pension_former_employer.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know the name of your previous employer.","top"); return; } if (itm.pension_dont_pay_taxes.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know whether it is subject to tax.","top"); return; } /** * validation block end */ let _insertindex = MAR.income.set(applicantnum, itm.type, existingid, itm); mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); getIncome_v2(); let _warnings = mar.answers.v2.income[applicantnum].items[_insertindex].warnings; if (_warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warning").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { if (typeof _warnings[_wi] !== "undefined") { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mvc.go("#income-how"+"."+applicantnum); swal.close(); } }); } else { mvc.go("#income-how"+"."+applicantnum); } }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["income-other"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.income.get(applicantnum,"other",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { if (num(itm[`other_income`]) === 0) { itm[`other_income`] = num(itm.sug_total); } } let h = ""; h += frm.htitle("Other income").render(); /** * block for overrides */ if (itm !== false && MAR.getOpt(itm,"verified","") === "N" ) { mar.pg_accesscontrollerfn = function() { return "open"; } } let overridden = (itm && MAR.getOpt(itm, "over", "") === "Y"); if (overridden) { h += mar.tmp_pg_overblock(itm); } /** * end block */ h += frm.elaine("If you have any other income that does not fit in our categories, please enter the monthly amount with a income description.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div VAL = (itm) ? itm.other_income : ''; h += frm.slider("other_income","Total monthly income:",VAL,"","",function(){ }, { v00 : '0', v50 : '5000', v50_inc : '100', v75 : '7500', v75_inc : '100', v100 : '10000', v100_inc : '100', start_val : '5000' }).render(); h += "
    Income description?
    "; VAL = (itm) ? itm.other_description : ''; h += frm.txt("other_description","",VAL,"e.g. Stocks","",function(){}).render(); h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.other_dont_pay_taxes : 'N'; h += frm.yn("other_dont_pay_taxes","I receive this without giving a part to Uncle Sam (gross is net).",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "other_description") { var val = txt("#other_description"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please describe the income.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "other"; itm.other_income = txt("#other_income"); itm.other_description = txt("#other_description"); itm.other_dont_pay_taxes = yn("#other_dont_pay_taxes"); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (itm.other_income.trim().length == 0 || itm.other_income == '$' ) { mar.tip(".help-button","warning","You need to let us know how much other income you have.","top"); return; } if (num(itm.other_income) < 0 ) { mar.tip(".help-button","warning","Income must be positive.","top"); return; } if (itm.other_description.trim().length == 0 ) { mar.tip(".help-button","warning","Please describe the income.","top"); return; } /** * validation block end */ let _insertindex = MAR.income.set(applicantnum, itm.type, existingid, itm); mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); getIncome_v2(); let _warnings = mar.answers.v2.income[applicantnum].items[_insertindex].warnings; if (_warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warning").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { if (typeof _warnings[_wi] !== "undefined") { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mvc.go("#income-how"+"."+applicantnum); swal.close(); } }); } else { mvc.go("#income-how"+"."+applicantnum); } }),"cancel",frm.addfunction(function(){ mvc.go("#income-how"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); let othertypes = [ { "value": "AccessoryUnitIncome", "text": "Accessory Unit Income" }, { "value": "AlimonyChildSupport", "text": "Alimony/Child Support" }, { "value": "AutomobileExpenseAccount", "text": "Automobile/Expense Account" }, { "value": "CapitalGains", "text": "Capital Gains" }, { "value": "EmploymentRelatedAssets", "text": "Employment Related Assets" }, { "value": "FNMBoarderIncome", "text": "FNM Boarder Income" }, { "value": "FNMGovernmentMortgageCreditCertificate", "text": "FNM Government Mortgage Credit Certificate" }, { "value": "ForeignIncome", "text": "Foreign Income" }, { "value": "FosterCare", "text": "Foster Care" }, { "value": "Section8", "text": "Housing Choice Voucher Program (Section 8)" }, { "value": "MilitaryBasePay", "text": "Military Base Pay" }, { "value": "MilitaryClothesAllowance", "text": "Military Clothes Allowance" }, { "value": "MilitaryCombatPay", "text": "Military Combat Pay" }, { "value": "MilitaryFlightPay", "text": "Military Flight Pay" }, { "value": "MilitaryHazardPay", "text": "Military Hazard Pay" }, { "value": "MilitaryOverseasPay", "text": "Military Overseas Pay" }, { "value": "MilitaryPropPay", "text": "Military Prop Pay" }, { "value": "MilitaryQuartersAllowance", "text": "Military Quarters Allowance" }, { "value": "MilitaryRationsAllowance", "text": "Military Rations Allowance" }, { "value": "MilitaryVariableHousingAllowance", "text": "Military Variable Housing Allowance" }, { "value": "Non-borrowerHouseholdIncome", "text": "Non-borrower Household Income" }, { "value": "NotesReceivableInstallment", "text": "Notes Receivable/Installment" }, { "value": "OtherIncome", "text": "Other Types Of Income" }, { "value": "Pension", "text": "Pension/Retirement Income" }, { "value": "MortgageDifferential", "text": "Real Estate/Mortgage Differential" }, { "value": "RoyaltyPayment", "text": "Royalty Payment" }, { "value": "SeasonalIncome", "text": "Seasonal Income" }, { "value": "SocialSecurity", "text": "Social Security/iility Income" }, { "value": "TemporaryLeave", "text": "Temporary Leave" }, { "value": "TipIncome", "text": "Tip Income" }, { "value": "Trust", "text": "Trust Income" }, { "value": "Unemployment", "text": "Unemployment/Public Assistance" }, { "value": "VABenefitsNonEducational", "text": "VA Benefits NonEducational" } ]; let getOtherTypesAsArray = function() { let retval = []; for (let i=0; i < othertypes.length;i++) { retval.push(othertypes[i].text) } return retval; } $("#body-container #other_description").autocomplete({ minLength:0, appendTo: "#body-container .x_content", source: MAR.income.getOtherTypesAsArray(), change: function(event, ui) { if (ui.item == null) { $("#other_description").val(""); $("#other_description").focus(); } } }).bind('focus', function(){ if (txt("#other_description").trim().length == 0) { $(this).autocomplete("search"); } }); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); /* file /ui/app/js/pages.assets.js , last updated 1708941251179*/ /* * Class: AssetObj * Def: pass a data object as the arg and you can store or create little assets.. pass em around too * * * mar.pg_changelistner on change (non specific) * mar.pg.copilot_custom_listener * mar.pg_ticklistener on ticker * mar.pg_accesscontrollerfn * * * */ class AssetObj { constructor(arg) { this.data = {}; $.extend(true, this.data, arg); /* this.data = arg; this.data.bankname = arg.bankname; this.data.assetType = arg.assetType; this.data.assetName = arg.assetName; this.data.subtype = arg.subtype; this.data.num = arg.num; this.data.amount = arg.amount; this.data.assetIcon = arg.assetIcon; ?delete function? or no? */ if(this.data.assetIcon){ this.data.assetIcon = 'svg_'+this.data.assetIcon+'_assets'; }else{ //check if(this.data.id){ //var st = $('#svg_'+this.data.id+'_assets').html(); // console.warn('is tehre an icon?? '+st); if( $('#svg_'+this.data.id+'_assets').html() !== 'undefined'){ // console.warn('THERE IS an icon : '+this.data.id); this.data.assetIcon = 'svg_'+this.data.id+'_assets'; } } } switch(this.data.assetType) { case 'checking': this.data.assetIcon = (this.data.assetIcon) ? this.data.assetIcon : 'svg_checkings_icon_assets'; break; case 'savings': this.data.assetIcon = (this.data.assetIcon) ? this.data.assetIcon : 'svg_savings_icon_assets'; break; case 'proceedsfromsale': this.data.assetIcon = (this.data.assetIcon) ? this.data.assetIcon : 'svg_net_proceeds_icon_assets'; break; case 'emd': this.data.assetIcon = (this.data.assetIcon) ? this.data.assetIcon : 'svg_emd_icon_assets'; break; case 'ira': this.data.assetIcon = (this.data.assetIcon) ? this.data.assetIcon : 'svg_ira_and_401k_icon_assets'; break; case 'gifts': this.data.assetIcon = (this.data.assetIcon) ? this.data.assetIcon : 'svg_gift_icon_assets'; break; case 'stock': this.data.assetIcon = (this.data.assetIcon) ? this.data.assetIcon : 'svg_stocks_bonds_icon_assets'; break; case 'cash': this.data.assetIcon = (this.data.assetIcon) ? this.data.assetIcon : 'svg_cash_icon_assets'; break; case 'retirement': this.data.assetIcon = (this.data.assetIcon) ? this.data.assetIcon : 'svg_ira_and_401k_icon_assets'; break; default: this.data.assetIcon = (this.data.assetIcon) ? this.data.assetIcon : 'svg_w2_icon_income'; } } /* * function render * take the data and renders it according to desired view. * params: string * */ render(vw){ let viewType = (vw) ? vw : this.data.assetType; let h = ''; let ra = ` `; ra = ""; function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } let verified = (MAR.getOpt(this.data, "verified","").toUpperCase() === "N"); function getIcon(I) { if (verified) { return ""; } return $("#"+I).html(); } console.log('viewType:: '+viewType); switch(viewType) { case 'checking': h += "
    "; h += ""; h += "
    "; h += "
    "+this.data.bankname+"
    "; if (this.data.last4digits != "") h += "
    ***"+this.data.last4digits+"
    "; if (this.data.owner != "") h += "
    "+ra+this.data.owner+"
    "; h += "
    " h += "
    "; h += "
    "+capitalizeFirstLetter(this.data.assetType)+":
    "; h += "
    "+elaineui.format("cur",this.data.amount)+"
    "; if (this.data.business_account === "Y") h += "
    (business)
    "; h += "
    " h += "
    ×
    "; h += "
    "; //end imported account holder break; case 'savings': h += "
    "; h += ""; h += "
    "; h += "
    "+this.data.bankname+"
    "; if (this.data.last4digits != "") h += "
    ***"+this.data.last4digits+"
    "; if (this.data.owner != "") h += "
    "+ra+this.data.owner+"
    "; h += "
    " h += "
    "; h += "
    "+capitalizeFirstLetter(this.data.assetType)+":
    "; h += "
    "+elaineui.format("cur",this.data.amount)+"
    "; if (this.data.business_account === "Y") h += "
    (business)
    "; h += "
    " h += "
    ×
    "; h += "
    "; //end imported account holder break; case 'nprf': h += "
    "; h += ""; h += "
    "; h += "
    Net Proceeds
    "; if (this.data.owner != "") h += "
    "+ra+this.data.owner+"
    "; h += "
    " h += "
    "; h += "
    Total :
    "; h += "
    "+elaineui.format("cur",this.data.amount)+"
    "; h += "
    " h += "
    ×
    "; h += "
    "; //end imported account holder break; case 'proceedsfromsale': h += "
    "; h += ""; h += "
    "; h += "
    Net Proceeds From Sale
    "; if (this.data.owner != "") h += "
    "+ra+this.data.owner+"
    "; h += "
    " h += "
    "; h += "
    Total :
    "; h += "
    "+elaineui.format("cur",this.data.amount)+"
    "; h += "
    " h += "
    ×
    "; h += "
    "; //end imported account holder break; case 'emd': h += "
    "; h += ""; h += "
    "; h += "
    Earnest Money Deposit
    "; if (this.data.owner != "") h += "
    "+ra+this.data.owner+"
    "; h += "
    " h += "
    "; h += "
    Total :
    "; h += "
    "+elaineui.format("cur",this.data.amount)+"
    "; h += "
    " h += "
    ×
    "; h += "
    "; //end imported account holder break; case 'retirement': h += "
    "; h += ""; h += "
    "; h += "
    "+this.data.bankname+"
    "; if (this.data.owner != "") h += "
    "+ra+this.data.owner+"
    "; h += "
    " h += "
    "; h += "
    Retirement :
    "; h += "
    "+elaineui.format("cur",this.data.amount)+"
    "; h += "
    " h += "
    ×
    "; h += "
    "; //end imported account holder break; case 'gifts': h += "
    "; h += ""; h += "
    "; h += "
    Gift
    "; if (this.data.owner != "") h += "
    "+ra+this.data.owner+"
    "; h += "
    " h += "
    "; h += "
    Value :
    "; h += "
    "+elaineui.format("cur",this.data.amount)+"
    "; h += "
    " h += "
    ×
    "; h += "
    "; //end imported account holder break; case 'cash': h += "
    "; h += ""; h += "
    "; h += "
    Cash
    "; if (this.data.owner != "") h += "
    "+ra+this.data.owner+"
    "; h += "
    " h += "
    "; h += "
    Value :
    "; h += "
    "+elaineui.format("cur",this.data.amount)+"
    "; h += "
    " h += "
    ×
    "; h += "
    "; //end imported account holder break; case 'other': h += "
    "; h += ""; h += "
    "; h += "
    "+this.data.bankname+"
    "; if (this.data.owner != "") h += "
    "+ra+this.data.owner+"
    "; h += "
    " h += "
    "; h += "
    Other :
    "; h += "
    "+elaineui.format("cur",this.data.amount)+"
    "; h += "
    " h += "
    ×
    "; h += "
    "; //end imported account holder break; default: h += "
    "; h += ""; h += "
    "; h += "
    "+this.data.bankname+"
    "; if (this.data.bankname.trim().length == 0) { h += "
    "+this.data.assetType+"
    "; } if(this.data.num != "") h += "
    #"+this.data.num+"
    "; if (this.data.owner != "") h += "
    "+ra+this.data.owner+"
    "; h += "
    " h += "
    "; h += "
    "+capitalizeFirstLetter(this.data.assetType)+":
    "; h += "
    "+elaineui.format("cur",this.data.amount)+"
    "; h += "
    " h += "
    ×
    "; h += "
    "; //end imported account holder } return h; } updateModel(val){ $.extend(true, this.data, val); } } //end AssetObj mar.tmp_reloadAssets = function(fn,txt) { let reloadfn = async function() { let _assets = await mar.socket.send_and_receiveSync("app-answers", { appid : mar.ID, filter : "v2.assets" }); if (typeof _assets.data === "object") { mar.answers.v2.assets = _assets.data; if (typeof fn === "function") fn(); } mvc.go("#assets-choice"); } elaineui.swalprompt({ txt : (typeof txt === "string") ? txt : `There have been changes to the asset list, please reload.`, cls : "midelinfopopupOneButton", //"middleInfoPopup", ok : "Got it!", okfn : reloadfn, cancelfn : reloadfn }) } mar.pg["assets-choice"] = (function(){ var VAL = 'N' var html = ""; var pages_to_verify = []; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); getAssets_v2(); var applicantsObj = getApplicantsNames_v2(); var totalAssetAmount = 0; let itm = (existingid) ? MAR.assets.get("bank",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let revealButtomMenu = false; mar.pg_accesscontrollerfn = function() { return "open"; } if ("open_assets_choice" in mar.pg && mar.pg.open_assets_choice === true) { revealclass = ""; revealButtomMenu = true; mar.pg.open_assets_choice = false; } mar.editfn = function(N,TYP) { if (TYP =="proceedsfromsale") TYP = "nprf"; mvc.go("#assets-"+TYP+".0."+N); } mar.delfn = function(N,ELM) { let $e = $(ELM); while ($e.hasClass("importedAccountHolder") == false) { $e = $($e.parent()); } frm.areyousure("WARNING","You are about to delete this item from your asset statement.

    Are you sure?
    ", function(){ $e.css("opacity",0.2); //.remove(); MAR.assets.del(N) && mar.fakesave(); mvc.go("#assets-choice"); }) } /** * standard starting block - END */ let chosenBank = (mar.chosenBank) ? mar.chosenBank : {id:'bank_of_america', displayName: 'Bank of America'}; let assetArray = [{ id: chosenBank.id, bankname: chosenBank.displayName, assetType:'checking', assetName: 'Main Account', subtype:'', num:'4250', amount: '7232'}, {id: chosenBank.id, bankname: chosenBank.displayName, assetType:'checking', assetName: 'Main Account', subtype:'', num:'4756', amount: '531'}, {id: chosenBank.id, bankname: chosenBank.displayName, assetType:'savings', assetName: 'Main Account', subtype:'', num:'5230', amount: '12111'}, {bankname: chosenBank.displayName, assetType:'net proceeds', assetName: 'Main Account', subtype:'', num:'1223', amount: '41500'}, {bankname: chosenBank.displayName, assetType:'earnest money deposit', assetName: '', subtype:'', num:'78238', amount: '4500'}, {id:'wells_fargo', bankname: 'Wells Fargo', assetType:'k401', assetName: '', subtype:'', num:'78238', amount: '4500'}]; let sortorder_asset = function(whoa) { if (typeof whoa == "string") { whoa = whoa.split(","); } if (whoa.length == 0) { return 0; } if (whoa.length == 1) { if (whoa[0] == 0) return 0; if (whoa[0] == "0") return 0; if (whoa[0] == 1) return 1; if (whoa[0] == "1") return 1; if (whoa[0] == 2) return 2; if (whoa[0] == "2") return 2; return whoa[0]; } return 3; } let as = false; let dm = false; mar.tmp_assets_realod = function(){ as = getAssets_v2(); dm = as.detailmatrix; dm.shift(); // get rid of the heading dm.pop(); // and the footer assetArray = []; pages_to_verify = []; for (let i=0; i < dm.length; i++) { let dl = dm[i]; let sortorder = sortorder_asset(dl[1]); // retval.detailmatrix.push([ // "stock", // 0 type // "", // 1 persons // __n, // 2 name of bank / or other // __v, // 3 vlaue // __t, // 4 notes // i // 5 index in array, // __4digits // 6 lst 4 digits , if available // ]); let persons = JSON.stringify(dl[1]); // if (typeof persons !== "string") { // persons = persons.join(","); // } if (dl[0] == "") continue; let I = (dl.length > 5) ? dl[5] : "-1"; let asset_obj = MAR.assets.get(dl[0],dl[5]); console.warn("asset_obj",I,asset_obj); let last4digits = (dl.length > 6 && dl[6] != "") ? "(#"+dl[6]+")" : ""; // let bankname = dl[2]+ " " + `${last4digits}`; let bankname = `
    ${dl[2]}
    ${last4digits}
    `; assetArray.push({ assetIcon : "", // bankname: dl[2]+ " " + last4digits + "/" + persons+"/" + sortorder , bankname: bankname , assetType:dl[0], assetName: [dl[1],dl[4]].join("/") , subtype:'', last4digits : false, num:"", //dl[0], amount: dl[3], business_account : MAR.getOpt(asset_obj, "business_account", ""), sortorder : sortorder, verified : MAR.getOpt(asset_obj, "verified", ""), i : I }) if ("verified" in asset_obj == true && asset_obj.verified !== "Y") { let TYP = dl[0]; if (TYP =="checking") TYP = "bank"; if (TYP =="savings") TYP = "savings"; if (TYP =="proceedsfromsale") TYP = "nprf"; pages_to_verify.push("#assets-"+TYP+".0."+I); } } //AssetObj for list var ao; var i; let currentheading = -1; let name_heading = ""; // amount: 23044 // assetIcon: "" // assetName: "0/item 0" // assetType: "savings" // bankname: "Bank of America (#1234)" // i: 0 // last4digits: false // num: "" // sortorder: 0 // subtype: "" let h = ""; for( i=0; i","
    "); name_heading = getApplicantsNames_v2(0).Name.split(" ")[0]; } if (currentheading == 1) { //h += (getApplicantsNames_v2(1).Names + " Assets").wrap("
    ","
    ");; name_heading = getApplicantsNames_v2(1).Name.split(" ")[0]; } if (currentheading == 2) { //h += (getApplicantsNames_v2(2).Names + " Assets").wrap("
    ","
    ");; name_heading = getApplicantsNames_v2(2).Name.split(" ")[0]; } if (currentheading == 3) { //h += ("Joint Assets").wrap("
    ","
    ");; name_heading = "Joint asset"; } } assetArray[i].owner = name_heading; ao = new AssetObj(assetArray[i]); totalAssetAmount += parseInt(ao.data.amount,10); h += ao.render(); } return h; } mar.tmp_assets_realod_fn = function(){ let h = mar.tmp_assets_realod(); $(".er-table").html(h); $("#totalAssetAmount").html(totalAssetAmount); } let h = ""; h += frm.htitle("Available Assets: 51732").render(); h += "
    "; h += `
    ${mar.tmp_assets_realod()}
    `; if (assetArray.length > 0) { if (as.has_unverified_items !== true) { h += "
    " + "
    " + "Add Another Asset" + "
    " + "
    "; } } if (assetArray.length > 0 && revealButtomMenu == false) h += "
    "; if (assetArray.length > 0) h += frm.hr().render(); if(applicantsObj.length === 2){ h += frm.elaine("Do you or "+applicantsObj[1].Name+" have any other assets that can be used for this transaction?","er").render(); }else if(applicantsObj.length === 3){ h += frm.elaine("Do you or "+applicantsObj[1].Name+", or "+applicantsObj[2].Name+" have any other assets that can be used for this transaction?","er").render(); }else { h += frm.elaine("Do you have any other assets that can be used for this transaction?","er").render(); } h += "
    "; h += "
    Which of these accounts will you use for this purchase?

    "; h += "
    " + "
    "+$("#svg_w2_icon_income").html()+"Checking
    " + "
    "+$("#svg_savings_icon_assets").html()+"Savings
    " + "
    "+$("#svg_ira_and_401k_icon_assets").html()+"401K
    " + "
    "; h += "
    "+$("#svg_ira_and_401k_icon_assets").html()+"IRA
    "+$("#svg_stocks_bonds_icon_assets").html()+"Stocks / Bonds
    "+$("#svg_cash_icon_assets").html()+"Cash
    "; h += "
    " + "
    "+$("#svg_gift_icon_assets").html()+"Gifts
    " + "
    "+$("#svg_emd_icon_assets").html()+"EMD
    " + "
    "+$("#svg_net_proceeds_icon_assets").html()+"Net Proceeds
    " + "
    "; h += "
    Other
    "; h += "
    Skip Assets
    "; h += "
    "; // er if (assetArray.length > 0 && revealButtomMenu == false) h += "
    " VAL = ''; /* let h = ""; h += frm.htitle("Assets").render(); //
    You must include at least one checking account. h += frm.elaine("To pay for your closing cost, we need to account for the {{assets available for purchase}} you indicated you have available for this purchase.","").render(); VAL = ''; h += frm.radio("assetschoice","Which of these accounts will you use for this purchase?
    You must include at least one checking account.",VAL,"","",function(){ },{ checking : "Checking / savings", ira : "401K / IRA", stock : "Stock / Bonds", cash : "Cash, but not deposited", gift : "Gift to receive", emd : "Earnest Money Deposits made", estate : "Net proceeds of sold real estate", other : "Other" }).render(); h += "
    " h += frm.txt("assetschoice_other","",VAL,"e.g. Inheritance Money","",function(){}).render(); h += "
    " */ /* end modal content */ let pagenames = { bank : "checkings", //"bank", savings : "checkings.0.savings", k401 : "k401", ira : "ira", stock : "stock", cash : "cash", gifts : "gifts", emd : "emd", nprf : "nprf", other : "other" } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ //not necc /* var how = radio("assetschoice"); if (how && how != "") { mvc.go("#assets-"+pagenames[how]); } else { mvc.go("#income-summary"+"."+applicantnum); } */ let __assets = getAssets_v2(); if (__assets.has_unverified_items == true) { elaineui.swal(`You have some un-verified assets you need to check before you can continue

    These assets have a triangle next to them


    `, "Asset Verification"); return; } if (mar.accesscontroller.get() === "") { if (revealButtomMenu === true && $("#body-container #maindiv").is(':visible') === false) { mar.tmp_revealmore(); $("#body-container .next-button").html("I AM DONE"); return; } if (revealButtomMenu === false && $("#body-container .next-button").html() !== "I AM DONE") { $("#body-container .next-button").html("I AM DONE"); return; } } // if ($("#maindiv.x-hide").length > 0) { // $("#maindiv.x-hide").removeClass("x-hide"); // $("#body-container").scrollTo("max",200); // $($("#maindiv .xhuman")[0]).Humanize({ // opts : { // fn : function() { // $("#body-container").scrollTo("max",200); // } // }, // quick : false // }); // // navsync.sendcustomevent("assets-choice-reveal") // // return; // // } setScenario_data("__assets_passed","Y"); mar.fakesave(); if (num(mar.pg_as) < num(mar.pg_pd)) { mvc.go("#scenario-personaldata.0"); } else { mvc.go("#income-how.0"); } //mvc.goto("#_1300") //mvc.go("#income-summary"); //or just go straight to checking? }),"back",frm.addfunction(function(){ if (num(mar.pg_as) < num(mar.pg_pd)) { mvc.go("#scenario-realtor"); } else { // mvc.go("#scenario-personaldata.0"); mvc.go("#scenario-addresshistory."+(MAR.applicants.count()-1)); } }),"mar.help()"); h = Mustache.render(h,localopts); // mar.pg.copilot_custom_listener("assets-list-reload") mar.pg.copilot_custom_listener = function(evt) { // navsync.sendcustomevent("assets-choice-reveal") if (evt == "assets-list-reload") { mar.tmp_assets_realod_fn(); } if (evt == "assets-choice-reveal") { if ($("#maindiv.x-hide").length > 0) { $("#maindiv.x-hide").removeClass("x-hide"); $("#body-container").scrollTo("max",200); $($("#maindiv .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false }); } } } let hasSuggestions = function(skip) { let hasUnverifiedItems = false; if (hasUnverifiedItems === false) { let sug = MAR.assets.suggest(); if (sug.length > 0 && skip === true) { sug = sug.filter(function(itm) { return true; }) } if (sug.length > 0) { mvc.go(`#assets-suggestion.${sug[0].applicant}`) // swal(JSON.stringify(sug)); return true; } } return false; } let or = function(){ // if (pages_to_verify.length > 0) { // mvc.go(pages_to_verify[0]); // return; // } if (getScenario_data("authorizations-credit-ed_0_passed","N") != "Y") { mvc.go("#authorizations-credit-ed."+(MAR.applicants.count() -1)) return; } if (getScenario_data("__assets_unas_passed","N") !== "Y") { mvc.go("#up-next-assets"); return; } if (hasSuggestions() === true) { return; } $("#body-container").find(".xx-radio").myradio(); $("#totalAssetAmount").html(totalAssetAmount); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); mar.tmp_revealmore = function(){ if ($("#maindiv.x-hide").length > 0) { $("#maindiv.x-hide").removeClass("x-hide"); $("#body-container").scrollTo("max",200); $($("#maindiv .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false }); navsync.sendcustomevent("assets-choice-reveal") } } $(".incomeIcons_button").on('click', function(e){ console.log('pressed icon button e: ',e); let $elm = $(e.currentTarget); let goto = $elm.data("goto"); if (getDoOwnRealestate() == false) { if (goto == "nprf") { mar.tip(".help-button","warning","You answered that you do not own realestate so this option is un-available.","top"); return; } } if (goto == "none") { $("#body-container .next-button").html("I AM DONE"); revealButtomMenu = false; // do not reveal the menu $(`.next-button`).click(); return; } if (goto == "revealmore") { mar.tmp_revealmore(); return; } console.log('goto : '+goto); if (goto && goto != "") { mvc.go("#assets-"+pagenames[goto]); } }); if ($("#maindiv.x-hide").length == 0 && $("#body-container .xhuman").length > 0) { $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false }); } setTimeout(function() { $("#body-container").scrollTo("max",200); },1000) mar.pg_ticklistener = async function() { console.warn("PG TICK"); /** * get the enc_deletions */ let _enc_deletions = await mar.socket.send_and_receiveSync("app-answers", { appid : mar.ID, filter : {d:"v2.delbyencompass.asset.ts",u:"v2.updbyencompass.asset.ts"} }); let updated = false; if (num(_enc_deletions.data.d) !== num(MAR.getOpt(mar.answers,"v2.delbyencompass.asset.ts",0))) updated = true; if (num(_enc_deletions.data.u) !== num(MAR.getOpt(mar.answers,"v2.updbyencompass.asset.ts",0))) updated = true; if (updated) { mar.tmp_reloadAssets(function(){ mar.answers.v2.delbyencompass.asset.ts = _enc_deletions.data.d; // 2nd time prevention mar.answers.v2.updbyencompass.asset.ts = _enc_deletions.data.u; // 2nd time prevention }); } } } /* h += uihelpers.cbuttonbar("","","","","mar.help()"); h = Mustache.render(h,localopts); let or = function(){ $("#body-container").find(".xx-radio").myradio(); } */ pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } function iscomplete(N) { var _sc = getScenario_v2(); var _as = getAssets_v2(); let assets = MAR.assets.get(); for (let i=0; i < assets.length; i++) { if ("verified" in assets[i] && assets[i].verified === "N") return i; } return true; } return { render : render, iscomplete : iscomplete } })(); mar.pg["assets-edit"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p2 = ("p2" in localopts && localopts.p2 != "" && typeof localopts.p2 != "undefined") ? localopts.p2 : false; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let uuid = false; let existingid = false; let assetObj = false; if (typeof p2 === "string" && p2.indexOf("-") > -1) { uuid = p2; assetObj = MAR.assets.getByUUID(uuid, true); if (assetObj !== false) { existingid = `${assetObj.i}`; } } else { existingid = (p3 && p3 != "new" ) ? p3 : false; } let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("bank",existingid) : false; let pagelink = false; let h = ""; h += `
    `; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (pagelink !== false) { mvc.go(pagelink); } }),"close",frm.addfunction(function(){ }),"mar.help()"); h = Mustache.render(h,localopts); // let pagenames = { // w2 : "w2manual", // "w2-previous" : "w2-previous", // DD1099 : "DD1099", // llc : "llc", // k1 : "k1", // pension : "pension", // child : "child-support", // dis : "disability", // ssec : "social-security", // alimony : "alimony", // rental : "rental", // other : "other" // } if (itm !== false) { itm.__pagetype = itm.type; //MAR.getOpt(pagenames, itm.type, false); pagelink = `#assets-${itm.__pagetype}.${itm.applicantnum}.${existingid}`; } else { pagelink = `#assets-choice.0`; } let oc = function() { } let or = function(){ if (pagelink !== false) { mvc.go(pagelink); return; } let h = ""; h += `
    applicantnum : ${applicantnum}
    `; h += `
    uuid : ${uuid}
    `; h += `
    existingid : ${existingid}
    `; h += `
    page type : ${MAR.getOpt(itm, "__pagetype","")}
    `; h += `
    itm:${JSON.stringify(itm, null,4)}
    `; h += `
    assetObj:${JSON.stringify(assetObj, null,4)}
    `; $("#body-container").find(".result").html(h); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-suggestion"] = (function(){ var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "0" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let h = ""; let sugs = MAR.assets.suggest(); let hasSug = false; let sug = ""; if (sugs.length > 0) { hasSug = true; sug = sugs.shift(); if (MAR.getOpt(sug, "suggestion", "") === "notype") { h += frm.htitle("Asset Descrepency").render(); h += "
    "; h += frm.elaine(`${na}, can you help us out solve a discrepency.`,"er").render(); h += "
    "; h += `We dont know the type of this asset: `; h += "
    "; h += "
    "; h += asset_block(sug.item); h += "
    "; h += "
    "; h += frm.radio("opts","can you select one of the following:","","","",function(){ },{ bank : "Checking account", savings : "Saving account", k401 : "401k", ira : "IRA", stock : "Stock account", cash : "Cash", gift : "Gift", emd : "EMD", nprf : "Net proceeds", other : "None of the above" }).render(); h += "
    "; } else { h += `
    ${JSON.stringify(sug, false, 4)}
    `; } } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (MAR.getOpt(sug, "suggestion", "") === "notype") { let opts = radio("opts"); if (opts.length > 0) { mar.answers.v2.assets.items[sug.index].type = opts; } else { mar.tip(".help-button","warning","You need to let us know what youd like us me to do.","top"); return; } } mvc.go("#assets-choice"); }),"Back",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(skipReturn) { } let or = function(){ if (hasSug === false) { mvc.go("#assets-choice"); } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "About Us" } return { render : render, section : "general" } })(); mar.pg["assets-checkings"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { /** * standard starting block */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let action = (p3 && p3 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let refi = (getV2_data("loan_type","purchase") !== "purchase"); let h = ""; if (p3 == "savings") { h += frm.htitle("Assets: Savings").render(); h += frm.elaine("Select the financial institution you have a savings account with.","").render(); } else { h += frm.htitle("Assets: Checkings").render(); h += frm.elaine("Select the financial institution you have a checking account with.","").render(); } h += "
    "+$("#svg_bank_of_america_assets").html()+"Bank of America
    "+$("#svg_chase_assets").html()+"Chase
    "+$("#svg_citi_bank_assets").html()+"Citibank
    "; h += "
    "+$("#svg_wells_fargo_assets").html()+"Wells Fargo
    "+$("#svg_capital_one_assets").html()+"Capital One
    "+$("#svg_usaa_assets").html()+"USAA
    "; h += "
    "+$("#svg_navy_federal_credit_union_assets").html()+"Navy Federal Credit Union
    "+$("#svg_u_s_bank_assets").html()+"U.S. Bank
    "+$("#svg_sun_trust_assets").html()+"Sun Trust
    "; h += "
    Other
    "; VAL = ''; /* end modal content */ let pagenames = { bank_of_america : "Bank of America", chase : "Chase", citi_bank : "Citibank", wells_fargo : "Wells Fargo", capital_one : "Capital One", usaa : "USAA", navy_federal_credit_union : "Navy Federal Credit Union", u_s_bank : "U.S. Bank", sun_trust : "Sun Trust", other : "Other" } if (refi) { h += uihelpers.cbuttonbar("I AM DONE",frm.addfunction(function(){ setScenario_data("__assets_passed","Y"); mar.fakesave(); if (num(mar.pg_as) < num(mar.pg_pd)) { mvc.go("#scenario-personaldata.0"); } else { mvc.go("#income-how.0"); } }),"prev",frm.addfunction(function(){ mar.pg.open_assets_choice = true; mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); } else { h += uihelpers.cbuttonbar("","","prev",frm.addfunction(function(){ mar.pg.open_assets_choice = true; mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); } let openbank = function(goto) { mar.chosenBank = {id:goto, displayName:pagenames[goto]}; let chosenBank = mar.chosenBank; if (p3 == "savings") { mvc.go("#assets-savings"); } else { mvc.go("#assets-bank"); } return; /* shortcut */ if (goto && goto != "") { //mar. //mvc.go("#assets-"+pagenames[goto]); if (goto === 'other'){ //launch the overlay var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Please choose your bank").render()+ "
    "+ $("#svg_plaid_logo").html()+ "
    "+ "
    "+ "PLAID LINK here? "+ "
    "; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "CANCEL", use : { text: "USE THIS BANK", value: "use", closeModal: true } } }).then((act) => { if (act == "use") { //mar.pghelpers.callLoanOfficer(); //JC then use the selection details here to fill in the data? } }); }else{ mar.three_panel_pane.init(); let chosenBank = mar.chosenBank; let imgsrc = "svg_"+chosenBank.id+"_assets.svg"; let img = $("#svg_"+chosenBank.id+"_assets").html(); let p1 = ""; p1 += "
    "; p1 += "
    "; p1 += "";//
    "; p1 += "
    "; p1 += "
    "; p1 += "Sign In"; p1 += "
    "; p1 += "
    "; p1 += "Please enter your credentials for "+chosenBank.displayName+" "; p1 += "
    "; //note: these need to be dynamic and generated by the api p1 += "
    "; p1 += "User name for "+chosenBank.displayName+" "; p1 += "
    "; p1 += "
    "; p1 += ""; p1 += "
    "; p1 += "
    "; p1 += "Password for "+chosenBank.displayName+" "; p1 += "
    "; p1 += "
    "; p1 += ""; p1 += "
    "; p1 += "
    "; p1 += "
    "; p1 += ''; p1 += "
    "; p1 += "
    Wait a few seconds whilst we connect to your bank","er").render(); h += frm.working().render() h += "
    "; // JC - CW - elaine added div h += "
    "; mar.three_panel_pane.p2(); mar.three_panel_pane.p2(h); let $p2 = $(mar.three_panel_pane.getp2()); let ElaineEventualText = na+" we will import the following "+chosenBank.displayName+" accounts. You can always remove any accounts that you don't want to include in your application."; mar.importw2_data = []; mar.importw2 = function(i) { let da = mar.importw2_data[i]; mar.defaultw2 = da; mvc.go("#income-w2manual"+"."+applicantnum); swal.close(); } setTimeout(function(){ $.get("/api/yodlee/accounts", function(data){ $(".working").remove(); $("#el1").html(ElaineEventualText); mar.editfn = function(){} mar.delfn = function(N,ELM) { // alert(N + "/" + acdata.length); acdata[N]._del = true; let $e = $(ELM); while ($e.hasClass("importedAccountHolder") == false) { $e = $($e.parent()); } $e.css("opacity",0.2); //.remove(); } if (data && "account" in data) { let acc = data.account; acdata = []; for (let i=0; i < acc.length; i++) { let ac = acc[i]; let ty = "checking"; if (ac.accountType == "CHECKING") ty = "checking"; if (ac.accountType == "SAVINGS") ty = "savings"; if (ac.accountType == "OTHER") ty = "other"; if (ac.isAsset == false) continue; let bankObj = { i : acdata.length, id: chosenBank.id, bankname: chosenBank.displayName, assetType:ty, assetName: ac.accountName, subtype:'', num:ac.accountNumber, last4digits : ac.last4digits, verified : "", amount: ac.balance.amount }; acdata.push(bankObj); var ao = new AssetObj(bankObj); $(".er").append(ao.render()); } $(".er").append("
    Continue
    "); $($p2.find(".xhuman")[0]).Humanize({ opts : { fn : function() { } }, quick : false }); } mar.three_panel_pane.p2(); }); // $.get("/api/payrolsystems/get_employers", function(da) { // var h = ""; // mar.importw2_data = da; // for (let i=0; i < da.length; i++) { // let g = new GenericBlock(); // h += g.render("svg_w2_icon_income",da[i].name,[ // "$"+da[i].pay_amount + " / "+da[i].pay_freq // ],"mar.importw2("+i+");"); // } // /* // { // "type": "w2", // "name": "Bagles and beans Inc.", // "pay_freq": "weekly", // "pay_amount": 650, // "bonus_ot_yn": "Y", // "hr_contact": "Jane Horricks", // "hr_tel": "555-122-1234", // "hr_email": "jane@baglesinc.com" // } // */ // mar.three_panel_pane.p2(h); // mar.three_panel_pane.p2() // }); },1000) })+"' class='big-middle-button'>Continue
    "; p1 += "
    "; p1 += "
    ";//end account verification let p2 = ""; p2 += "
    "; p2 += "
    ";//end pane let h = mar.three_panel_pane.getHtml(p1,p2); //launch the overlay var s = document.createElement("div"); s.setAttribute("class","normal-form"); /* s.innerHTML = ""+ frm.htitle("Please choose your bank").render()+ "
    "+ $("#svg_plaid_logo").html()+ "
    "+ "
    "+ "PLAID LINK here? "+ "
    "; */ s.innerHTML = h; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false//"CANCEL" } }); // let fs = 0; // setScenario_data("__assets_echeck_chosenbank",goto) && fs++; // setScenario_data("__assets_echeck_chosenbank_route","") && fs++; // if (fs > 0) { // mar.fakesave(); // } // mvc.goto("#_1100") } } } mar.pg.copilot_custom_listener = function(evt) { // navsync.sendcustomevent("assets-choice-reveal") if (evt.startsWith("assets-bank-click_")) { openbank(evt.substring(18)) } } let or = function(){ if (setScenario_data("__assets_echeck_chosenbank","")) mar.fakesave(); $("#body-container").find(".xx-radio").myradio(); $(".incomeIcons_button").on('click', function(e){ console.log('pressed icon button e: ',e); let $elm = $(e.currentTarget); let goto = $elm.data("goto"); console.log('goto : '+goto); openbank(goto); navsync.sendcustomevent(`assets-bank-click_${goto}`) return; mar.chosenBank = {id:goto, displayName:pagenames[goto]}; if (goto && goto != "") { //mar. //mvc.go("#assets-"+pagenames[goto]); if (goto === 'other'){ //launch the overlay var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Please choose your bank").render()+ "
    "+ $("#svg_plaid_logo").html()+ "
    "+ "
    "+ "PLAID LINK here? "+ "
    "; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "CANCEL", use : { text: "USE THIS BANK", value: "use", closeModal: true } } }).then((act) => { if (act == "use") { //mar.pghelpers.callLoanOfficer(); //JC then use the selection details here to fill in the data? } }); }else{ mar.three_panel_pane.init(); let chosenBank = mar.chosenBank; let imgsrc = "svg_"+chosenBank.id+"_assets.svg"; let img = $("#svg_"+chosenBank.id+"_assets").html(); let p1 = ""; p1 += "
    "; p1 += "
    "; p1 += "";//
    "; p1 += "
    "; p1 += "
    "; p1 += "Sign In"; p1 += "
    "; p1 += "
    "; p1 += "Please enter your credentials for "+chosenBank.displayName+" "; p1 += "
    "; //note: these need to be dynamic and generated by the api p1 += "
    "; p1 += "User name for "+chosenBank.displayName+" "; p1 += "
    "; p1 += "
    "; p1 += ""; p1 += "
    "; p1 += "
    "; p1 += "Password for "+chosenBank.displayName+" "; p1 += "
    "; p1 += "
    "; p1 += ""; p1 += "
    "; p1 += "
    "; p1 += "
    "; p1 += ''; p1 += "
    "; p1 += "
    Wait a few seconds whilst we connect to your bank","er").render(); h += frm.working().render() h += "
    "; // JC - CW - elaine added div h += "
    "; mar.three_panel_pane.p2(); mar.three_panel_pane.p2(h); let $p2 = $(mar.three_panel_pane.getp2()); let ElaineEventualText = na+" we will import the following "+chosenBank.displayName+" accounts. You can always remove any accounts that you don't want to include in your application."; mar.importw2_data = []; mar.importw2 = function(i) { let da = mar.importw2_data[i]; mar.defaultw2 = da; mvc.go("#income-w2manual"+"."+applicantnum); swal.close(); } setTimeout(function(){ $.get("/api/yodlee/accounts", function(data){ $(".working").remove(); $("#el1").html(ElaineEventualText); mar.editfn = function(){} mar.delfn = function(N,ELM) { // alert(N + "/" + acdata.length); acdata[N]._del = true; let $e = $(ELM); while ($e.hasClass("importedAccountHolder") == false) { $e = $($e.parent()); } $e.css("opacity",0.2); //.remove(); } if (data && "account" in data) { let acc = data.account; acdata = []; for (let i=0; i < acc.length; i++) { let ac = acc[i]; let ty = "checking"; if (ac.accountType == "CHECKING") ty = "checking"; if (ac.accountType == "SAVINGS") ty = "savings"; if (ac.accountType == "OTHER") ty = "other"; if (ac.isAsset == false) continue; let bankObj = { i : acdata.length, id: chosenBank.id, bankname: chosenBank.displayName, assetType:ty, assetName: ac.accountName, subtype:'', num:ac.accountNumber, last4digits : ac.last4digits, verified : "", amount: ac.balance.amount }; acdata.push(bankObj); var ao = new AssetObj(bankObj); $(".er").append(ao.render()); } $(".er").append("
    Continue
    "); $($p2.find(".xhuman")[0]).Humanize({ opts : { fn : function() { } }, quick : false }); } mar.three_panel_pane.p2(); }); // $.get("/api/payrolsystems/get_employers", function(da) { // var h = ""; // mar.importw2_data = da; // for (let i=0; i < da.length; i++) { // let g = new GenericBlock(); // h += g.render("svg_w2_icon_income",da[i].name,[ // "$"+da[i].pay_amount + " / "+da[i].pay_freq // ],"mar.importw2("+i+");"); // } // /* // { // "type": "w2", // "name": "Bagles and beans Inc.", // "pay_freq": "weekly", // "pay_amount": 650, // "bonus_ot_yn": "Y", // "hr_contact": "Jane Horricks", // "hr_tel": "555-122-1234", // "hr_email": "jane@baglesinc.com" // } // */ // mar.three_panel_pane.p2(h); // mar.three_panel_pane.p2() // }); },1000) })+"' class='big-middle-button'>Continue
    "; p1 += "
    "; p1 += "
    ";//end account verification let p2 = ""; p2 += "
    "; p2 += "
    ";//end pane let h = mar.three_panel_pane.getHtml(p1,p2); //launch the overlay var s = document.createElement("div"); s.setAttribute("class","normal-form"); /* s.innerHTML = ""+ frm.htitle("Please choose your bank").render()+ "
    "+ $("#svg_plaid_logo").html()+ "
    "+ "
    "+ "PLAID LINK here? "+ "
    "; */ s.innerHTML = h; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false//"CANCEL" } }); // let fs = 0; // setScenario_data("__assets_echeck_chosenbank",goto) && fs++; // setScenario_data("__assets_echeck_chosenbank_route","") && fs++; // if (fs > 0) { // mar.fakesave(); // } // mvc.goto("#_1100") } } }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-bankconnect"] = (function(){ var VAL = 'N'; var html = ""; var chosenBank = {id:'bank_of_america', displayName: 'Bank of America'}; function render(pg, localopts) { /** * standard starting block */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); chosenBank = (mar.chosenBank) ? mar.chosenBank : {id:'bank_of_america', displayName: 'Bank of America'}; let h = ""; h += "
    "; h += "
    "; h += $("#svg_plaid_logo").html(); h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "Sign In"; h += "
    "; h += "
    "; h += "Please enter your credentials for "+chosenBank.displayName+" "; h += "
    "; //note: these need to be dynamic and generated by the api h += "
    "; h += "User name for "+chosenBank.displayName+" "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "Password for "+chosenBank.displayName+" "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; h += ''; h += "
    "; h += "
    ";//end account verification VAL = ''; /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ //not necc /* var how = radio("assetschoice"); if (how && how != "") { mvc.go("#assets-"+pagenames[how]); } else { mvc.go("#income-summary"+"."+applicantnum); } */ mvc.go("#income-summary"+"."+applicantnum); //or just go straight to checking? }),"prev",frm.addfunction(function(){ mvc.go("#assets-checkings"); }),"mar.help()"); h = Mustache.render(h,localopts); let or = function(){ $("#body-container").find(".xx-radio").myradio(); $(".incomeIcons_button").on('click', function(e){ console.log('pressed icon button e: ',e); let $elm = $(e.currentTarget); let goto = $elm.data("goto"); console.log('goto : '+goto); if (goto && goto != "") { //mvc.go("#assets-"+pagenames[goto]); } }); } /* h += uihelpers.cbuttonbar("","","","","mar.help()"); h = Mustache.render(h,localopts); let or = function(){ $("#body-container").find(".xx-radio").myradio(); } */ pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-importedaccounts"] = (function(){ var VAL = '' var html = ""; var chosenBank = {id:'bank_of_america', displayName: 'Bank of America'}; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("importedaccounts",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 chosenBank = (mar.chosenBank) ? mar.chosenBank : {id:'bank_of_america', displayName: 'Bank of America'}; let bankObj = {id: chosenBank.id, bankname: chosenBank.displayName, assetType:'checking', assetName: 'Main Account', subtype:'', num:'4250', amount: '7232'}; /** * standard starting block - END */ let h = ""; let ElaineEventualText = na+" we will import the following "+chosenBank.displayName+" accounts. You can always remove any accounts that you don't want to include in your application."; h += frm.htitle("Imported Accounts").render(); h += frm.elaine("Wait a few seconds whilst we connect to your bank","er").render(); h += frm.working().render(); h += "
    "; // JC - CW - elaine added div h += "
    "; // reveal - start //AssetObj // var ao = new AssetObj(bankObj); // h += ao.render(); // // // bankObj.num = "4729"; // bankObj.amount = '573'; // // ao.updateModel(bankObj); // h += ao.render(); // // // bankObj.assetType = "savings"; // bankObj.num = "5329"; // bankObj.amount = '12112'; // // ao.updateModel(bankObj); // h += ao.render('standard'); /* bankObj.amount = '43100'; ao.updateModel(bankObj); h += ao.render('netproceeds'); bankObj.amount = '4500'; ao.updateModel(bankObj); h += ao.render('emd'); */ h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } for (let i=0; i < acdata.length; i++) { let ac = acdata[i]; let itm = {}; itm.type = "bank"; itm.balance = ac.amount; itm.institution_name = chosenBank.displayName; itm.whose_name = ""; itm.other_name = ""; if (ac.assetType == "savings") itm.type = "savings"; MAR.assets.set(itm.type, false, itm); } //MAR.assets.set(itm.type, existingid, itm); //mar.fakesave(); let fs = acdata.length; setScenario_data("__assets_checkings_passed","Y") && fs++; setScenario_data("__assets_echeck_chosenbank","") && fs++; setScenario_data("__assets_echeck_chosenbank_route","") && fs++ if (fs>0) mar.fakesave(); mvc.goto("#_1100") //mvc.go("#assets-choice"); }),"cancel",frm.addfunction(function(){ mvc.go("#assets-bankconnect"); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { ///pick up here //console.log('checklist("whose_name"): '+checklist("whose_name")); } let acdata = []; let or = function(){ $.get("/api/yodlee/accounts", function(data){ $(".working").remove(); $("#el1").html(ElaineEventualText); if (data && "account" in data) { let acc = data.account; acdata = []; for (let i=0; i < acc.length; i++) { let ac = acc[i]; let ty = "checking"; if (ac.accountType == "CHECKING") ty = "checking"; if (ac.accountType == "SAVINGS") ty = "savings"; if (ac.accountType == "OTHER") ty = "other"; if (ac.isAsset == false) continue; let bankObj = { id: chosenBank.id, bankname: chosenBank.displayName, assetType:ty, assetName: ac.accountName, subtype:'', num:ac.accountNumber, amount: ac.balance.amount }; acdata.push(bankObj); var ao = new AssetObj(bankObj); var h = ao.render(); $("#accoountlist").append(h) } } $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); }) } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-bank"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("bank",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ if (MAR.getOpt(itm, "verified", "") === "N") { mar.pg_accesscontrollerfn = function() { return "open"; } } let h = ""; h += frm.htitle("Bank Account").render(); h += frm.elaine("How much money do you have in your checking account right now?","er").render(); h += "
    "; // JC - CW - elaine added div VAL = (itm) ? itm.institution_name : ''; if (VAL == "" && "chosenBank" in mar && "displayName" in mar.chosenBank) { if (mar.chosenBank.displayName !== "Other") { VAL = mar.chosenBank.displayName; } } h += frm.txt("institution_name","Checking account institution name?",VAL,"e.g.Chase","",function(){}).render(); h += "
    "; let enc_balance = false; let calc_balance = false; let dis_class = ""; let dis_balance = false; let loa_override = false; let loa_balance = false; let start_balance = 0; h += ``; h += ``; (function(){ if (MAR.appnav.loanWasSubmitted() === false) return; calc_balance = MAR.getOpt(itm, "_calcbalance", false); enc_balance = MAR.getOpt(itm, "__enc_balance", false); if (enc_balance !== false && calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { if (enc_balance !== calc_balance) { h += `
    There is a value of ${enc_balance} is submitted and has been adjusted in encompass which overrides this balance. As LO you can choose to upload and chane this value
    `; loa_override = true; loa_balance = enc_balance; } else { h += `
    The calculated value of ${enc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; loa_balance = enc_balance; } } else { h += `
    The calculated value of ${enc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } else if (calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { h += `
    The calculated value of ${calc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; } else { h += `
    The calculated value of ${calc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } })(); h += (function(){ let h = ""; VAL = (itm) ? itm.balance : '500'; if (calc_balance !== false) VAL = calc_balance; if (loa_balance !== false) VAL = loa_balance; start_balance = VAL; h += frm.slider("balance",`Total balance:`,VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000', start_val : '40000' }).render(); return h; })().wrap(`
    `,"
    ") h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.last4digits : ''; h += frm.txt("last4digits","If known, last 4 digits of the account",VAL,"e.g.1234","",function(){}).render(); h += "
    " // reveal - end VAL = (itm) ? itm.last4digits : ''; h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.business_account : ''; h += frm.yn3("business_account","Is this a business account?",VAL,"","",function(){ oc(); reveal(); }).render(); h += (function(){ let h = ""; VAL = (itm) ? itm.business_account_name : ''; h += frm.txt("business_account_name","Business name",VAL,"Name e.g. Shipping Inc","",function(){}).render(); VAL = (itm) ? itm.business_account_cpa : ''; h += frm.txt("business_account_cpa","If known, who is the CPA ",VAL,"Name e.g. Shipping Inc","",function(){}).render(); VAL = (itm) ? itm.business_account_cpa_email : ''; h += frm.txt("business_account_cpa_email","If known, CPA's Email address",VAL,"E-Mail address e.g. Nancy@Smith.com","",function(){}).render(); VAL = (itm) ? itm.business_account_cpa_permission : ''; h += frm.yn3("business_account_cpa_permission","Can we contact your CPA? ",VAL,"","",function(){}).render(); return h; })().wrap("
    ","
    "); h += frm.hr().render(); h += "
    " h += "
    "; // reveal - start (with validation to previous field) h += "
    In whose name is this account?
    Multiple answers are possible.
    "; //---- set up the applicants checklist VAL = (itm) ? itm.whose_name : ["0"]; var applicantsObj = getApplicantsNames_v2(); var slimmedObj = {}; for (let i=0; i -1) ? itm.other_name : ''; // prefill if itm is not false h += frm.txt("other_applicant_name","Name",VAL,"Name e.g. Nancy Smith","",function(){}).render(); VAL = (itm && itm.whose_name.indexOf(99)> -1) ? itm.other_email : ''; // prefill if itm is not false h += frm.txt("other_applicant_email","Email address",VAL,"E-Mail address e.g. Nancy@Smith.com","",function(){}).render(); VAL = (itm && itm.whose_name.indexOf(99)> -1) ? itm.other_permission : ''; // prefill if itm is not false h += frm.yn3("other_applicant_permission","Can we ask them to give us permission to use this account?",VAL,"","",function(){}).render(); h += "
    "; // this is the holder for the OTHER person name //---- end the applicants checklist h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ let reveal = function() { /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "balance") { var val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money is in your checking account.","top"); return false; } } if (validation == "last4digits") { var val = txt("#last4digits"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to let us know the last 4 digits of the account number.","top"); // return false; // } } if (validation == "institution_name") { var val = txt("#institution_name"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who your checking account is with.","top"); return false; } } if (validation == "business_account") { var val = yn3("#business_account"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know if this is a business account.","top"); return false; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return false; } return true; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(async function(){ if (reveal() === false) return; // /** // * validation & reveal block start // */ // let $reveals = $(".x-revealdiv"); // if ($reveals.length > 0) { // let $elm = $($reveals[0]); // let validation = $elm.data("validation"); // if (validation) { // // if (validation == "balance") { // var val = txt("#balance"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to let us know how much money is in your checking account.","top"); // return; // } // } // // if (validation == "last4digits") { // var val = txt("#last4digits"); //// if (val.trim().length == 0 ) { //// mar.tip(".help-button","warning","You need to let us know the last 4 digits of the account number.","top"); //// return; //// } // } // if (validation == "institution_name") { // var val = txt("#institution_name"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to let us know who your checking account is with.","top"); // return; // } // } // // // if (validation == "business_account") { // var val = yn3("#business_account"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to let us know if this is a business account.","top"); // return; // } // } // } // // // $elm.slideDown(function(){ // $elm.removeClass("x-hide").removeClass("x-revealdiv"); // $("#body-container").scrollTo("max",200); // }); // return; // } /** * validation & reveal block end */ if (existingid) { let is_deleted = await mar.socket.send_and_receiveSync("app-isdeletedinencompass", { appid : mar.ID, type : "asset", uuid : itm.uuid }); if (is_deleted.data > 0) { mar.tmp_reloadAssets(false, `oops this asset was deleted from encompass whilst you still had it open.`) return; } } if (!existingid) { itm = {}; } itm.type = "bank"; if (loa_override && enc_balance !== false) { itm.__enc_balance = txt("#balance"); } else { itm.balance = txt("#balance"); } itm.institution_name = txt("#institution_name"); itm.last4digits = txt("#last4digits"); itm.whose_name = checklist("whose_name"); itm.other_name = txt("#other_applicant_name"); itm.other_email = txt("#other_applicant_email"); itm.other_permission = yn3("#other_applicant_permission"); itm.business_account = yn3("#business_account"); itm.business_account_name = txt("#business_account_name"); itm.business_account_cpa = txt("#business_account_cpa"); itm.business_account_cpa_email = txt("#business_account_cpa_email"); itm.business_account_cpa_permission = yn3("#business_account_cpa_permission"); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (txt("#balance").trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money is in your checking account.","top"); return; } if (itm.institution_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who your checking account is with.","top"); return; } if (itm.whose_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who is connected to the account.","top"); return; } if (itm.whose_name.trim() == "99" ) { mar.tip(".help-button","warning","You need to have on of the borrowers connected to the account.","top"); return; } if (itm.whose_name.includes('99') && $("#other_applicant_name").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the name of the other person connected to the account.","top"); return; } // if (itm.whose_name.includes('99') && $("#other_applicant_email").val().trim().length == 0){ // $("#other_applicant_holder").removeClass('x-hide'); // mar.tip(".help-button","warning","You need to let us know the email address of the other person connected to the account.","top"); // return; // } if (itm.whose_name.includes('99') && $("#other_applicant_permission").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know whether we can contact the other person connected to the account.","top"); return; } if (itm.business_account === "") { mar.tip(".help-button","warning","You need to let us know if this is a business account.","top"); return; } if (itm.business_account === "Y") { if (itm.business_account_name === "") { mar.tip(".help-button","warning","You need to let us know the name on the business account.","top"); return; } if (itm.business_account_cpa_permission === "") { mar.tip(".help-button","warning","You need to let us know the if we have permission to contact the CPA.","top"); return; } if (itm.business_account_cpa_permission === "Y") { if (itm.business_account_cpa === "") { mar.tip(".help-button","warning","You need to let us know the name of the CPA.","top"); return; } if (itm.business_account_cpa_email === "") { mar.tip(".help-button","warning","You need to let us know the email address of the CPA.","top"); return; } } } /** * validation block end */ if (!existingid || ("ihaveanother" in mar.state && mar.state.ihaveanother == "Y")) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); VAL = "no"; s.innerHTML = "" + "
    " + frm.radio("ihaveanother",`At ${itm.institution_name}: Do you have more accounts on the SAME statement?`,VAL,"","",function(){ },{ no : "No", checking : "Checkings account", savings : "Savings account", stock : "Stock account" }).render() + "
    "; $(s).find(".xx-radio").myradio(); swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "Continue", value: "call", closeModal: false } } }) .then((act) => { let ihaveanother = radio("ihaveanother"); if (ihaveanother == "checking") { MAR.assets.set(itm.type, existingid, itm); if (!existingid) { // log ("asset uuid added") } else { // log ("asset uuid modified") } itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "bank"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-bank.0.${newid}`); swal.close(); } else if (ihaveanother == "savings") { MAR.assets.set(itm.type, existingid, itm); itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "savings"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-savings.0.${newid}`); swal.close(); } else if (ihaveanother == "stock") { MAR.assets.set(itm.type, existingid, itm); itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "stock"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; itm.can_take_freely = ""; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-stock.0.${newid}`); swal.close(); } else { setScenario_data("__assets_checkings_passed","Y"); MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mar.state.ihaveanother = ""; mvc.go("#assets-choice"); swal.close(); } // MAR.assets.set(itm.type, existingid, itm); // mar.fakesave(); // mvc.go("#assets-choice"); // swal.close(); }); } else { let lastPart = function() { setScenario_data("__assets_checkings_passed","Y"); MAR.assets.set(itm.type, existingid, itm); if (!existingid) { // log ("asset uuid added") } else { // log ("asset uuid modified") } mar.fakesave(); mvc.go("#assets-choice"); }; if (enc_balance !== false) { if (mar.WE_ARE_FROM_LOI === false) { itm.balance = start_balance; } else { if (num(itm.balance) !== num(start_balance)) { // MAR.encompass.swal({ // msg : `This will override the encompass value if you choose to proceed....`, // cancel : "cancel", // cancelfn : function() { // // }, // ok : "overwrite", // okfn : function(){ // itm.__enc_balance = null; // lastPart(); // } // }); // return; } } } lastPart(); } }),"cancel",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { ///pick up here //console.log('checklist change: '); //console.log('checklist("whose_name") and setting 1 and 2: '+checklist("whose_name", ['applicant1', 'applicant2'])); var ar = checklist("whose_name"); if (ar.includes('99')){ $("#other_applicant_holder").removeClass('x-hide'); }else{ $("#other_applicant_holder").addClass('x-hide'); $("#other_applicant_name").val(''); } $("#body-container").scrollTo("max",200); } let oc = function() { ///pick up here //console.log('checklist("whose_name"): '+checklist("whose_name")); checkListChange(); let business_account = txt("#business_account"); if (business_account === "Y") { $("#other_business_holder").removeClass('x-hide'); } else { $("#other_business_holder").addClass('x-hide'); } } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $(".info-cpa").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "" + "When we get closer to the closing date we will, at some point, need a letter from your " + "CPA stating that taking money out of your business account will not " + "jeapordize the continuation of your company

    "; swal({ className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); }); $(".info-cpa-contact").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "" + "We may have to ask your accountant if using funds from your business account "+ "will have an adverse affect on your business. "+ "We will not contact the accountant, if we do not need it to approve the loan.

    " swal({ className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-savings"] = (function(){ var VAL = '' var html = ""; var typeAccount = "savings"; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("savings",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let h = ""; h += frm.htitle("Savings Account").render(); h += frm.elaine("How much money do you have in your "+typeAccount+" account right now?","er").render(); h += "
    "; // JC - CW - elaine added div let enc_balance = false; let calc_balance = false; let dis_class = ""; let dis_balance = false; let loa_override = false; let loa_balance = false; let start_balance = 0; h += ``; h += ``; (function(){ if (MAR.appnav.loanWasSubmitted() === false) return; calc_balance = MAR.getOpt(itm, "_calcbalance", false); enc_balance = MAR.getOpt(itm, "__enc_balance", false); if (enc_balance !== false && calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { if (enc_balance !== calc_balance) { h += `
    There is a value of ${enc_balance} is submitted and has been adjusted in encompass which overrides this balance. As LO you can choose to upload and chane this value
    `; loa_override = true; loa_balance = enc_balance; } else { h += `
    The calculated value of ${enc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; loa_balance = enc_balance; } } else { h += `
    The calculated value of ${enc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } else if (calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { h += `
    The calculated value of ${calc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; } else { h += `
    The calculated value of ${calc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } })(); VAL = (itm) ? itm.balance : '40000'; start_balance = VAL; if (calc_balance !== false) VAL = calc_balance; if (loa_balance !== false) VAL = loa_balance; (function(){ h += frm.slider("balance","Total balance:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000', start_val : '40000' }).render(); })().wrap(`
    `,`
    `); h += "
    "; h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.institution_name : ''; if (VAL == "" && "chosenBank" in mar && "displayName" in mar.chosenBank) { if (mar.chosenBank.displayName !== "Other") { VAL = mar.chosenBank.displayName; } } h += frm.txt("institution_name","Checking account institution name?",VAL,"e.g.Chase","",function(){}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render() //---- set up the applicants checklist h += "
    In whose name is this account?
    Multiple answers are possible.
    "; VAL = (itm) ? itm.whose_name : ["0"]; var applicantsObj = getApplicantsNames_v2(); var slimmedObj = {}; for (let i=0; i -1) ? itm.other_name : ''; // prefill if itm is not false h += frm.txt("other_applicant_name","",VAL,"e.g. Nancy Smith","",function(){}).render(); h += "
    "; // this is the holder for the OTHER person name //---- end the applicants checklist h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(async function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "balance") { var val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money is in your "+typeAccount+" account.","top"); return; } } if (validation == "institution_name") { var val = txt("#institution_name"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who your "+typeAccount+" account is with.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (existingid) { let is_deleted = await mar.socket.send_and_receiveSync("app-isdeletedinencompass", { appid : mar.ID, type : "asset", uuid : itm.uuid }); if (is_deleted.data > 0) { mar.tmp_reloadAssets(false, `oops this asset was deleted from encompass whilst you still had it open.`) return; } } if (!existingid) { itm = {}; } itm.type = "savings"; if (loa_override && enc_balance !== false) { itm.__enc_balance = txt("#balance"); } else { itm.balance = txt("#balance"); } itm.institution_name = txt("#institution_name"); itm.whose_name = checklist("whose_name"); itm.other_name = txt("#other_applicant_name"); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (txt("#balance").trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money is in your "+typeAccount+" account.","top"); return; } if (itm.institution_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who your "+typeAccount+" account is with.","top"); return; } if (itm.whose_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who is connected to the account.","top"); return; } if (itm.whose_name.trim() == "other" ) { mar.tip(".help-button","warning","You need to have on of the borrowers connected to the account.","top"); return; } if (itm.whose_name.includes('other') && $("#other_applicant_name").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the name of the other person connected to the account.","top"); return; } /** * validation block end */ if (!existingid || ("ihaveanother" in mar.state && mar.state.ihaveanother == "Y")) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); VAL = "no"; s.innerHTML = "" + "
    " + // frm.radio("ihaveanother","Do you have more accounts on one statement at this bank?",VAL,"","",function(){ frm.radio("ihaveanother",`At ${itm.institution_name}: Do you have more accounts on the SAME statement?`,VAL,"","",function(){ },{ no : "No", checking : "Checkings account", savings : "Savings account", stock : "Stock account" }).render() + "
    "; $(s).find(".xx-radio").myradio(); swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "Continue", value: "call", closeModal: false } } }) .then((act) => { let ihaveanother = radio("ihaveanother"); if (ihaveanother == "checking") { MAR.assets.set(itm.type, existingid, itm); itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "bank"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-bank.0.${newid}`); swal.close(); } else if (ihaveanother == "savings") { MAR.assets.set(itm.type, existingid, itm); itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "savings"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-savings.0.${newid}`); swal.close(); } else if (ihaveanother == "stock") { MAR.assets.set(itm.type, existingid, itm); itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "stock"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; itm.can_take_freely = ""; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-stock.0.${newid}`); swal.close(); } else { setScenario_data("__assets_checkings_passed","Y"); MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mar.state.ihaveanother = ""; mvc.go("#assets-choice"); swal.close(); } // MAR.assets.set(itm.type, existingid, itm); // mar.fakesave(); // mvc.go("#assets-choice"); // swal.close(); }); } else { let lastPart = function() { setScenario_data("__assets_checkings_passed","Y"); MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mvc.go("#assets-choice"); }; if (enc_balance !== false) { if (mar.WE_ARE_FROM_LOI === false) { itm.balance = start_balance; } else { if (num(itm.balance) !== num(start_balance)) { // MAR.encompass.swal({ // msg : `This will override the encompass value if you choose to proceed....`, // cancel : "cancel", // cancelfn : function() { // // }, // ok : "overwrite", // okfn : function(){ // itm.__enc_balance = null; // lastPart(); // } // }); // return; } } } lastPart(); } }),"cancel",frm.addfunction(function(){ mar.pg.open_assets_choice = true; mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { var ar = checklist("whose_name"); if (ar.includes('99')){ $("#other_applicant_holder").removeClass('x-hide'); }else{ $("#other_applicant_holder").addClass('x-hide'); $("#other_applicant_name").val(''); } if (ar == "99") checklist("whose_name","0,99"); if (ar == "") checklist("whose_name","0"); $("#body-container").scrollTo("max",200); } let oc = function() { } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-savings"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("savings",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let h = ""; h += frm.htitle("Savings Account").render(); h += frm.elaine("How much money do you have in your savings account right now?","er").render(); h += "
    "; // JC - CW - elaine added div VAL = (itm) ? itm.institution_name : ''; if (VAL == "" && "chosenBank" in mar && "displayName" in mar.chosenBank) { if (mar.chosenBank.displayName !== "Other") { VAL = mar.chosenBank.displayName; } } h += frm.txt("institution_name","Savings account institution name?",VAL,"e.g.Chase","",function(){}).render(); h += "
    "; let enc_balance = false; let calc_balance = false; let dis_class = ""; let dis_balance = false; let loa_override = false; let loa_balance = false; let start_balance = 0; h += ``; h += ``; (function(){ if (MAR.appnav.loanWasSubmitted() === false) return; calc_balance = MAR.getOpt(itm, "_calcbalance", false); enc_balance = MAR.getOpt(itm, "__enc_balance", false); if (enc_balance !== false && calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { if (enc_balance !== calc_balance) { h += `
    There is a value of ${enc_balance} is submitted and has been adjusted in encompass which overrides this balance. As LO you can choose to upload and chane this value
    `; loa_override = true; loa_balance = enc_balance; } else { h += `
    The calculated value of ${enc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; loa_balance = enc_balance; } } else { h += `
    The calculated value of ${enc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } else if (calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { h += `
    The calculated value of ${calc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; } else { h += `
    The calculated value of ${calc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } })(); h += (function(){ let h = ""; VAL = (itm) ? itm.balance : '500'; if (calc_balance !== false) VAL = calc_balance; if (loa_balance !== false) VAL = loa_balance; start_balance = VAL; h += frm.slider("balance","Total balance:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000', start_val : '40000' }).render(); return h; })().wrap(`
    `,"
    ") h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.last4digits : ''; h += frm.txt("last4digits","If known, last 4 digits of the account",VAL,"e.g.1234","",function(){}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += "
    In whose name is this account?
    Multiple answers are possible.
    "; //---- set up the applicants checklist VAL = (itm) ? itm.whose_name : ["0"]; var applicantsObj = getApplicantsNames_v2(); var slimmedObj = {}; for (let i=0; i -1) ? itm.other_name : ''; // prefill if itm is not false h += frm.txt("other_applicant_name","Name",VAL,"Name e.g. Nancy Smith","",function(){}).render(); VAL = (itm && itm.whose_name.indexOf(99)> -1) ? itm.other_email : ''; // prefill if itm is not false h += frm.txt("other_applicant_email","Email address",VAL,"E-Mail address e.g. Nancy@Smith.com","",function(){}).render(); VAL = (itm && itm.whose_name.indexOf(99)> -1) ? itm.other_permission : ''; // prefill if itm is not false h += frm.yn3("other_applicant_permission","Can we ask them to give us permission to use this account?",VAL,"","",function(){}).render(); h += "
    "; // this is the holder for the OTHER person name //---- end the applicants checklist h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(async function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "balance") { var val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money is in your checking account.","top"); return; } } if (validation == "institution_name") { var val = txt("#institution_name"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who your checking account is with.","top"); return; } } if (validation == "last4digits") { var val = txt("#last4digits"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to let us know the last 4 digits of the account number.","top"); // return; // } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (existingid) { let is_deleted = await mar.socket.send_and_receiveSync("app-isdeletedinencompass", { appid : mar.ID, type : "asset", uuid : itm.uuid }); if (is_deleted.data > 0) { mar.tmp_reloadAssets(false, `oops this asset was deleted from encompass whilst you still had it open.`) return; } } if (!existingid) { itm = {}; } itm.type = "savings"; if (loa_override && enc_balance !== false) { itm.__enc_balance = txt("#balance"); } else { itm.balance = txt("#balance"); } itm.institution_name = txt("#institution_name"); itm.last4digits = txt("#last4digits"); itm.whose_name = checklist("whose_name"); itm.other_name = txt("#other_applicant_name"); itm.other_email = txt("#other_applicant_email"); itm.other_permission = yn3("#other_applicant_permission"); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (txt("#balance").trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money is in your checking account.","top"); return; } if (itm.institution_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who your checking account is with.","top"); return; } if (itm.whose_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who is connected to the account.","top"); return; } if (itm.whose_name.trim() == "99" ) { mar.tip(".help-button","warning","You need to have on of the borrowers connected to the account.","top"); return; } if (itm.whose_name.includes('99') && $("#other_applicant_name").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the name of the other person connected to the account.","top"); return; } if (itm.whose_name.includes('99') && $("#other_applicant_email").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the email address of the other person connected to the account.","top"); return; } if (itm.whose_name.includes('99') && $("#other_applicant_permission").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know whether we can contact the other person connected to the account.","top"); return; } /** * validation block end */ if (!existingid || ("ihaveanother" in mar.state && mar.state.ihaveanother == "Y")) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); VAL = "no"; s.innerHTML = "" + "
    " + // frm.radio("ihaveanother","Do you have more accounts on one statement at this bank?",VAL,"","",function(){ frm.radio("ihaveanother",`At ${itm.institution_name}: Do you have more accounts on the SAME statement?`,VAL,"","",function(){ },{ no : "No", checking : "Checkings account", savings : "Savings account", stock : "Stock account" }).render() + "
    "; $(s).find(".xx-radio").myradio(); swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "Continue", value: "call", closeModal: false } } }) .then((act) => { let ihaveanother = radio("ihaveanother"); if (ihaveanother == "checking") { MAR.assets.set(itm.type, existingid, itm); itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "bank"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-bank.0.${newid}`); swal.close(); } else if (ihaveanother == "savings") { MAR.assets.set(itm.type, existingid, itm); itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "savings"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-savings.0.${newid}`); swal.close(); } else if (ihaveanother == "stock") { MAR.assets.set(itm.type, existingid, itm); itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "stock"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; itm.can_take_freely = ""; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-stock.0.${newid}`); swal.close(); } else { setScenario_data("__assets_checkings_passed","Y"); MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mar.state.ihaveanother = ""; mvc.go("#assets-choice"); swal.close(); } // MAR.assets.set(itm.type, existingid, itm); // mar.fakesave(); // mvc.go("#assets-choice"); // swal.close(); }); } else { let lastPart = function() { setScenario_data("__assets_checkings_passed","Y"); MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mvc.go("#assets-choice"); } if (enc_balance !== false) { if (mar.WE_ARE_FROM_LOI === false) { itm.balance = start_balance; } else { if (num(itm.balance) !== num(start_balance)) { // MAR.encompass.swal({ // msg : `This will override the encompass value if you choose to proceed....`, // cancel : "cancel", // cancelfn : function() { // // }, // ok : "overwrite", // okfn : function(){ // itm.__enc_balance = null; // lastPart(); // } // }); // return; } } } lastPart(); } }),"cancel",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { ///pick up here //console.log('checklist change: '); //console.log('checklist("whose_name") and setting 1 and 2: '+checklist("whose_name", ['applicant1', 'applicant2'])); var ar = checklist("whose_name"); //debugger; if (ar.includes('99')){ $("#other_applicant_holder").removeClass('x-hide'); }else{ $("#other_applicant_holder").addClass('x-hide'); $("#other_applicant_name").val(''); } if (ar == "99") checklist("whose_name","0,99"); if (ar == "") checklist("whose_name","0"); $("#body-container").scrollTo("max",200); } let oc = function() { ///pick up here //console.log('checklist("whose_name"): '+checklist("whose_name")); checkListChange(); } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.tmp_assets_encompass_checkSync = async function(applicantnum, itm){ if (mar.WE_ARE_FROM_LOI === true) { await MAR.encompass.waitSync(100); let rv = await MAR.encompass.app_check_diffs_assetsSync(mar.ID, applicantnum); if (rv.status === 0) { if (rv.diffs.length > 0) { let uploadfn = async function() { let rv1 = await MAR.encompass.uploadNewBorrowerToEncompassTfSync(mar.ID, rv.tf); let _swal = MAR.encompass.swal; if (rv1.status !== 0) { _swal({ msg : uploadrv.upl.statusMsg }); return; } else if (uploadrv.upd.status === 0) { swal.close(); mvc.go("#assets-choice"); return; // nothing } else if (uploadrv.upd.status < 0) { _swal({ msg : uploadrv.upd.statusMsg }); return; } else { _swal({ msg : uploadrv.upd.rvstatus }); return; } } elaineui.swalprompt({ txt : `There are changes in Elaine that need to be uploaded for this borrower's assets, can I proceed to upload?
    ${rv.diffs.join("
    ")}
    `, cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", ok : "Got it!", okfn : uploadfn, cancel : "cancel", cancelfn : function() { mvc.go("#assets-choice"); } }); return; } } } mvc.go("#assets-choice"); } mar.pg["assets-k401"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("k401",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let h = ""; h += frm.htitle("401K").render(); let crosslink = ""; if (existingid) { crosslink += `If this is an IRA click here.`; } h += frm.elaine(`If you’re able to withdraw all of the funds from your 401K account, we are able to account for 100% of that money. Usually what’s in the account hasn’t yet been taxed, so the maximum you’re allowed to borrow from it is just 40% of what’s in there. ${crosslink}`,"er").render(); // JC - CW - elaine added "er" //h += frm.elaine(na+", Every year you receive a pension awards letter. Aka a proof of income letter. Please fill out your monthly income.","er").render(); // JC - CW - elaine added "er" let enc_balance = false; let calc_balance = false; let dis_class = ""; let dis_balance = false; let loa_override = false; let loa_balance = false; (function(){ if (MAR.appnav.loanWasSubmitted() === false) return; calc_balance = MAR.getOpt(itm, "_calcbalance", false); enc_balance = MAR.getOpt(itm, "__enc_balance", false); if (enc_balance !== false && calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { if (enc_balance !== calc_balance) { h += `
    There is a value of ${enc_balance} is submitted and has been adjusted in encompass which overrides this balance. As LO you can choose to upload and chane this value
    `; loa_override = true; loa_balance = enc_balance; } else { h += `
    The calculated value of ${enc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; loa_balance = enc_balance; } } else { h += `
    The calculated value of ${enc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } else if (calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { h += `
    The calculated value of ${calc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; } else { h += `
    The calculated value of ${calc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } })(); let security = getScenario_data("security","open"); if (security === "submitted" && mar.WE_ARE_FROM_LOI === false) dis_class = " dis_class"; if (security === "closed") dis_class = " dis_class"; h += `
    `; // JC - CW - elaine added div h += `
    `; VAL = (itm) ? itm.balance : '5000'; // prefill if itm is not false if (calc_balance !== false) VAL = calc_balance; if (loa_balance !== false) VAL = loa_balance; let start_balance = VAL; h += frm.slider("balance","Total retirement balances:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000', start_val : '40000' }).render(); h += "
    "; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = 'N'; VAL = (itm) ? itm.can_take_freely : 'N'; // prefill if itm is not false h += frm.yn3("can_take_freely","Can you take or borrow money from your 401k freely? ",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start h += frm.hr().render(); VAL = (itm) ? itm.institution_name : ''; h += frm.txt("institution_name","401K institution name?",VAL,"e.g. Chase","",function(){}).render(); h += "
    "; // reveal - end var applicantsObj = getApplicantsNames_v2(); if (applicantsObj.length > 1) { var slimmedObj = {}; for (let i=0; i"; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.which_appliant : ''; h += frm.radio("which_appliant","Who's pension is this?",VAL,"","",function(){ },slimmedObj).render(); h += "
    " } /* h += "
    "; // reveal - start VAL = 'N'; VAL = (itm) ? itm.dont_pay_taxes : 'N'; // prefill if itm is not false h += frm.yn("dont_pay_taxes","I receive this without giving a part to Uncle Sam (gross is net).",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end */ /* h += "
    "; // reveal - start h += frm.hr().render(); //---- set up the applicants checklist h += "
    In whose name is this account?
    Multiple answers are possible.
    "; VAL = (itm) ? itm.whose_name : []; var applicantsObj = getApplicantsNames_v2(); var slimmedObj = {}; for (let i=0; i -1) ? itm.other_name : ''; // prefill if itm is not false h += frm.txt("other_applicant_name","",VAL,"e.g. Nancy Smith","",function(){}).render(); h += "
    "; // this is the holder for the OTHER person name */ h += "
    " // reveal - end //---- end the applicants checklist h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(async function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "balance") { var val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know your pension income.","top"); return; } } if (validation == "institution_name") { var val = txt("#institution_name"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who your 401K account is with.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (existingid) { let is_deleted = await mar.socket.send_and_receiveSync("app-isdeletedinencompass", { appid : mar.ID, type : "asset", uuid : itm.uuid }); if (is_deleted.data > 0) { mar.tmp_reloadAssets(false, `oops this asset was deleted from encompass whilst you still had it open.`) return; } } if (!existingid) { itm = {}; } itm.type = "k401"; if (loa_override && enc_balance !== false) { itm.__enc_balance = txt("#balance"); } else { itm.balance = txt("#balance"); } itm.can_take_freely = yn3("#can_take_freely"); //itm.dont_pay_taxes = yn("#dont_pay_taxes"); itm.institution_name = txt("#institution_name"); if ($("#choice-which_appliant0").length > 0) { itm.whose_name = [radio("which_appliant")]; } else { itm.whose_name = [0] } itm.which_appliant = itm.whose_name[0]; itm.verified = "Y"; /* itm.whose_name = checklist("whose_name"); itm.other_name = txt("#other_applicant_name"); */ /** * validation block start (validate the "itm" values) */ if (txt("#balance").trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know your pension income.","top"); return; } if (itm.institution_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who your "+typeAccount+" account is with.","top"); return; } if (itm.can_take_freely.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know if you can take money freely from this plan.","top"); return; } if (getApplicantsNames_v2().length > 1) { if (itm.which_appliant.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who's pension this is.","top"); return; } } /* if (itm.whose_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who is connected to the account.","top"); return; } if (itm.whose_name.includes('other') && $("#other_applicant_name").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the name of the other person connected to the account.","top"); return; } */ /** * validation block end */ function lastPart() { let _insertindex = MAR.assets.set(itm.type, existingid, itm); mar.fakesave(function(){ // mar.tmp_assets_encompass_checkSync(applicantnum, itm); }); getAssets_v2(); let _warnings = mar.answers.v2.assets.items[_insertindex].warnings; if (dis_balance === false && _warnings && _warnings.length > 0) { _warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warnings").render(); for (let _wi =0; _wi < _warnings.length; _wi++) { s.innerHTML += "
    "+_warnings[_wi]+"
    "; } swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mvc.go("#assets-choice"); swal.close(); } }); } else { mvc.go("#assets-choice"); } } if (enc_balance !== false) { if (mar.WE_ARE_FROM_LOI === false) { itm.balance = start_balance; } else { if (num(itm.balance) !== num(start_balance)) { // MAR.encompass.swal({ // msg : `This will override the encompass value if you choose to proceed....`, // cancel : "cancel", // cancelfn : function() { // // }, // ok : "overwrite", // okfn : function(){ // itm.__enc_balance = null; // lastPart(); // } // }); // return; } } } lastPart(); }),"cancel",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { var ar = checklist("whose_name"); if (ar.includes('99')){ $("#other_applicant_holder").removeClass('x-hide'); }else{ $("#other_applicant_holder").addClass('x-hide'); $("#other_applicant_name").val(''); } if (ar == "99") checklist("whose_name","0,99"); if (ar == "") checklist("whose_name","0"); $("#body-container").scrollTo("max",200); } let oc = function() { } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $(".info-info").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "If you are not sure you can withdraw all your money, check with your 401K contact person, " + "please send us a copy of the terms when you have them. Fill in No if you are not sure yet. " + "
    " + "
    " + "Example of restricted withdrawal." + "
    " + "Some employers do not immediatly give full vesting rights to 401K contributions they made. " + "Is this case you can not take money from your 401K freely."; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-ira"] = (function(){ var VAL = '' var html = ""; var typeAccount = "IRA"; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("ira",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let h = ""; let crosslink = ""; if (existingid) { crosslink += `If this is an 401K click here.`; } h += frm.htitle("IRA Account").render(); h += frm.elaine(`How much money do you have in your ${typeAccount} account right now? ${crosslink}`,"er").render(); let enc_balance = false; let calc_balance = false; let dis_class = ""; let dis_balance = false; let loa_override = false; let loa_balance = false; let start_balance = 0; (function(){ if (MAR.appnav.loanWasSubmitted() === false) return; calc_balance = MAR.getOpt(itm, "_calcbalance", false); enc_balance = MAR.getOpt(itm, "__enc_balance", false); if (enc_balance !== false && calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { if (enc_balance !== calc_balance) { h += `
    There is a value of ${enc_balance} is submitted and has been adjusted in encompass which overrides this balance. As LO you can choose to upload and chane this value
    `; loa_override = true; loa_balance = enc_balance; } else { h += `
    The calculated value of ${enc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; loa_balance = enc_balance; } } else { h += `
    The calculated value of ${enc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } else if (calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { h += `
    The calculated value of ${calc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; } else { h += `
    The calculated value of ${calc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } })(); let security = getScenario_data("security","open"); if (security === "submitted" && mar.WE_ARE_FROM_LOI === false) dis_class = " dis_class"; if (security === "closed") dis_class = " dis_class"; h += `
    `; // JC - CW - elaine added div h += "
    "; VAL = (itm) ? itm.balance : '500'; if (calc_balance !== false) VAL = calc_balance; if (loa_balance !== false) VAL = loa_balance; start_balance = VAL; h += frm.slider("balance","Total balance:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000', start_val : '40000' }).render(); h += "
    "; h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.institution_name : ''; h += frm.txt("institution_name","IRA account institution name?",VAL,"e.g. Chase","",function(){}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = 'N'; VAL = (itm) ? itm.can_take_freely : 'N'; // prefill if itm is not false h += frm.yn3("can_take_freely","Are you allowed to withdraw all of the funds from this account? ",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start VAL = 'N'; VAL = (itm) ? itm.dont_pay_taxes : 'N'; // prefill if itm is not false h += frm.yn3("dont_pay_taxes","I already paid taxes on my IRA savings.",VAL,"","",function(){},{}).render(); h += "
    "; // reveal - end var applicantsObj = getApplicantsNames_v2(); if (applicantsObj.length > 1) { var slimmedObj = {}; for (let i=0; i"; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.which_appliant : ''; h += frm.radio("which_appliant","Who's IRA is this?",VAL,"","",function(){ },slimmedObj).render(); h += "
    " } /* h += "
    "; // reveal - start h += frm.hr().render() //---- set up the applicants checklist h += "
    In whose name is this account?
    Multiple answers are possible.
    "; VAL = (itm) ? itm.whose_name : []; var applicantsObj = getApplicantsNames_v2(); var slimmedObj = {}; for (let i=0; i -1) ? itm.other_name : ''; // prefill if itm is not false h += frm.txt("other_applicant_name","",VAL,"e.g. Nancy Smith","",function(){}).render(); h += "
    "; // this is the holder for the OTHER person name //---- end the applicants checklist h += "
    " // reveal - end */ h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(async function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "balance") { var val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money is in your "+typeAccount+" account.","top"); return; } } if (validation == "institution_name") { var val = txt("#institution_name"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who your "+typeAccount+" account is with.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (existingid) { let is_deleted = await mar.socket.send_and_receiveSync("app-isdeletedinencompass", { appid : mar.ID, type : "asset", uuid : itm.uuid }); if (is_deleted.data > 0) { mar.tmp_reloadAssets(false, `oops this asset was deleted from encompass whilst you still had it open.`) return; } } if (!existingid) { itm = {}; } itm.type = "ira"; if (loa_override && enc_balance !== false) { itm.__enc_balance = txt("#balance"); } else { itm.balance = txt("#balance"); } itm.institution_name = txt("#institution_name"); itm.can_take_freely = yn3("#can_take_freely"); itm.dont_pay_taxes = yn3("#dont_pay_taxes"); if ($("#choice-which_appliant0").length > 0) { itm.whose_name = [radio("which_appliant")]; } else { itm.whose_name = [0] } itm.which_appliant = itm.whose_name[0]; itm.verified = "Y"; //itm.whose_name = checklist("whose_name"); //itm.other_name = txt("#other_applicant_name"); /** * validation block start (validate the "itm" values) */ if (txt("#balance").trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money is in your "+typeAccount+" account.","top"); return; } if (itm.institution_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who your "+typeAccount+" account is with.","top"); return; } /* if (itm.whose_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who is connected to the account.","top"); return; } if (itm.whose_name.includes('other') && $("#other_applicant_name").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the name of the other person connected to the account.","top"); return; } */ /** * validation block end */ let lastPart = function() { MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mvc.go("#assets-choice"); } if (enc_balance !== false) { if (mar.WE_ARE_FROM_LOI === false) { itm.balance = start_balance; } else { if (num(itm.balance) !== num(start_balance)) { // MAR.encompass.swal({ // msg : `This will override the encompass value if you choose to proceed....`, // cancel : "cancel", // cancelfn : function() { // // }, // ok : "overwrite", // okfn : function(){ // itm.__enc_balance = null; // lastPart(); // } // }); // return; } } } lastPart(); }),"cancel",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { var ar = checklist("whose_name"); if (ar.includes('99')){ $("#other_applicant_holder").removeClass('x-hide'); }else{ $("#other_applicant_holder").addClass('x-hide'); $("#other_applicant_name").val(''); } if (ar == "99") checklist("whose_name","0,99"); if (ar == "") checklist("whose_name","0"); $("#body-container").scrollTo("max",200); } let oc = function() { } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $(".info-info").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "If you are not sure you can withdraw all your money, check with your IRA contact person, " + "please send us a copy of the terms when you have them. Fill in No if you are not sure yet. " + "
    " + "
    " + "Example of restricted withdrawal." + "
    " + "Some employers do not immediatly give full vesting rights to IRA contributions they made. " + "Is this case you can not take money from your IRA freely."; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-stock"] = (function(){ var VAL = '' var html = ""; var typeAccount = "stock"; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("stock",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let h = ""; h += frm.htitle("STOCKS and bonds").render(); h += frm.elaine("Please only list the amount that you’re able to access quickly if you were to sell your positions and transfer the cash into your checking account.","er").render(); let enc_balance = false; let calc_balance = false; let dis_class = ""; let dis_balance = false; let loa_override = false; let loa_balance = false; let start_balance = 0; (function(){ if (MAR.appnav.loanWasSubmitted() === false) return; calc_balance = MAR.getOpt(itm, "_calcbalance", false); enc_balance = MAR.getOpt(itm, "__enc_balance", false); if (enc_balance !== false && calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { if (enc_balance !== calc_balance) { h += `
    There is a value of ${enc_balance} is submitted and has been adjusted in encompass which overrides this balance. As LO you can choose to upload and chane this value
    `; loa_override = true; loa_balance = enc_balance; } else { h += `
    The calculated value of ${enc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; loa_balance = enc_balance; } } else { h += `
    The calculated value of ${enc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } else if (calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { h += `
    The calculated value of ${calc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; } else { h += `
    The calculated value of ${calc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } })(); let security = getScenario_data("security","open"); if (security === "submitted" && mar.WE_ARE_FROM_LOI === false) dis_class = " dis_class"; if (security === "closed") dis_class = " dis_class"; h += `
    `; // JC - CW - elaine added div h += "
    "; VAL = (itm) ? itm.institution_name : ''; h += frm.txt("institution_name","Account institution name?",VAL,"e.g.Chase","",function(){}).render(); h += "
    "; h += "
    "; VAL = (itm) ? itm.balance : '500'; if (calc_balance !== false) VAL = calc_balance; if (loa_balance !== false) VAL = loa_balance; start_balance = VAL; h += `
    `; h += frm.slider("balance","Total asset value that you are able to liquidate:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000', start_val : '40000' }).render(); h += "
    "; h += "
    "; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.last4digits : ''; h += frm.txt("last4digits","If known, last 4 digits of the account",VAL,"e.g.1234","",function(){}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = 'N'; VAL = (itm) ? itm.can_take_freely : 'Y'; // prefill if itm is not false h += frm.yn3("can_take_freely","Are you allowed to withdraw all of the funds from this? ",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end /* h += "
    "; // reveal - start VAL = 'N'; VAL = (itm) ? itm.dont_pay_taxes : 'N'; // prefill if itm is not false h += frm.yn("dont_pay_taxes","I receive this without giving a part to Uncle Sam (gross is net).",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end */ h += "
    "; // reveal - start h += frm.hr().render() //---- set up the applicants checklist h += "
    In whose name are these stocks?
    Multiple answers are possible.
    "; VAL = (itm) ? itm.whose_name : ["0"]; var applicantsObj = getApplicantsNames_v2(); var slimmedObj = {}; for (let i=0; i -1) ? itm.other_name : ''; // prefill if itm is not false h += frm.txt("other_applicant_name","",VAL,"e.g. Nancy Smith","",function(){}).render(); VAL = (itm && itm.whose_name.indexOf(99)> -1) ? itm.other_email : ''; // prefill if itm is not false h += frm.txt("other_applicant_email","Email address",VAL,"E-Mail address e.g. Nancy@Smith.com","",function(){}).render(); VAL = (itm && itm.whose_name.indexOf(99)> -1) ? itm.other_permission : ''; // prefill if itm is not false h += frm.yn3("other_applicant_permission","Can we ask them to give us permission to use this account?",VAL,"","",function(){}).render(); h += "
    "; // this is the holder for the OTHER person name //---- end the applicants checklist h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(async function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "institution_name") { var val = txt("#institution_name"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us the name of the institution.","top"); return; } } if (validation == "balance") { var val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money is in your stocks.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (existingid) { let is_deleted = await mar.socket.send_and_receiveSync("app-isdeletedinencompass", { appid : mar.ID, type : "asset", uuid : itm.uuid }); if (is_deleted.data > 0) { mar.tmp_reloadAssets(false, `oops this asset was deleted from encompass whilst you still had it open.`) return; } } if (!existingid) { itm = {}; } itm.type = "stock"; if (loa_override && enc_balance !== false) { itm.__enc_balance = txt("#balance"); } else { itm.balance = txt("#balance"); } itm.can_take_freely = yn3("#can_take_freely"); itm.institution_name = txt("#institution_name"); itm.last4digits = txt("#last4digits"); //itm.dont_pay_taxes = yn("#dont_pay_taxes"); itm.whose_name = checklist("whose_name"); itm.other_name = txt("#other_applicant_name"); itm.other_email = txt("#other_applicant_email"); itm.other_permission = yn3("#other_applicant_permission"); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (itm.institution_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know the name of the institution.","top"); return; } if (txt("#balance").trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money is in your stocks.","top"); return; } if (itm.can_take_freely.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know if you can take money freely from this account.","top"); return; } if (itm.whose_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who is connected to these stocks.","top"); return; } if (itm.whose_name.trim() == "99" ) { mar.tip(".help-button","warning","You need to have on of the borrowers connected to the account.","top"); return; } if (itm.whose_name.includes('other') && $("#other_applicant_name").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the name of the other person connected to these stocks.","top"); return; } if (itm.whose_name.includes('other') && $("#other_applicant_email").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the email address of the other person connected to these stocks.","top"); return; } if (itm.whose_name.includes('99') && $("#other_applicant_permission").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know whether we can contact the other person connected to the stocks.","top"); return; } /** * validation block end */ if (!existingid || ("ihaveanother" in mar.state && mar.state.ihaveanother == "Y")) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); VAL = "no"; s.innerHTML = "" + "
    " + // frm.radio("ihaveanother","Do you have more accounts on one statement at this bank?",VAL,"","",function(){ frm.radio("ihaveanother",`At ${itm.institution_name}: Do you have more accounts on the SAME statement?`,VAL,"","",function(){ },{ no : "No", checking : "Checkings account", savings : "Savings account", stock : "Stock account" }).render() + "
    "; $(s).find(".xx-radio").myradio(); swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "Continue", value: "call", closeModal: false } } }) .then((act) => { let ihaveanother = radio("ihaveanother"); if (ihaveanother == "checking") { MAR.assets.set(itm.type, existingid, itm); itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "bank"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; if ("can_take_freely" in itm) delete itm.can_take_freely; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-bank.0.${newid}`); swal.close(); } else if (ihaveanother == "savings") { MAR.assets.set(itm.type, existingid, itm); itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "savings"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; if ("can_take_freely" in itm) delete itm.can_take_freely; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-savings.0.${newid}`); swal.close(); } else if (ihaveanother == "stock") { MAR.assets.set(itm.type, existingid, itm); itm = JSON.parse(JSON.stringify(itm)) if ("uuid" in itm) delete itm.uuid; itm.type = "stock"; itm.last4digits = ""; itm.business_account = ""; itm.balance = 500; itm.can_take_freely = ""; setScenario_data("__assets_checkings_passed","Y"); let newid = MAR.assets.set(itm.type, false, itm); mar.fakesave(); mar.state.ihaveanother = "Y"; mvc.go(`#assets-stock.0.${newid}`); swal.close(); } else { setScenario_data("__assets_checkings_passed","Y"); MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mar.state.ihaveanother = ""; mvc.go("#assets-choice"); swal.close(); } // MAR.assets.set(itm.type, existingid, itm); // mar.fakesave(); // mvc.go("#assets-choice"); // swal.close(); }); } else { let lastPart = function() { setScenario_data("__assets_checkings_passed","Y"); MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mvc.go("#assets-choice"); } if (enc_balance !== false) { if (mar.WE_ARE_FROM_LOI === false) { itm.balance = start_balance; } else { if (num(itm.balance) !== num(start_balance)) { // MAR.encompass.swal({ // msg : `This will override the encompass value if you choose to proceed....`, // cancel : "cancel", // cancelfn : function() { // // }, // ok : "overwrite", // okfn : function(){ // itm.__enc_balance = null; // lastPart(); // } // }); // return; } } } lastPart(); } }),"cancel",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { var ar = checklist("whose_name"); if (ar.includes('99')){ $("#other_applicant_holder").removeClass('x-hide'); }else{ $("#other_applicant_holder").addClass('x-hide'); $("#other_applicant_name").val(''); } if (ar == "99") checklist("whose_name","0,99"); if (ar == "") checklist("whose_name","0"); $("#body-container").scrollTo("max",200); } let oc = function() { checkListChange(); } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $(".info-info").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ "When you enter stock value’s we may only use 75% of the cash value, to offset trading risks. If stocks are sold, 100% of funds may be used. " + "
    "+ "
    "+ "If you don’t know for sure if you can withdraw freely from your stock and bonds account, click No. " + "
    " + "
    " + "Example of restricted Stock and Bonds. CD’s, IRA, 401K etc." + ""; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-cash"] = (function(){ var VAL = '' var html = ""; var typeAccount = "cash"; var startingVal =''; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("cash",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let h = ""; h += frm.htitle("CASH").render(); h += frm.elaine("Please only add cash amounts from verifiable sources.","er").render(); h += "
    "; // JC - CW - elaine added div let enc_balance = false; let calc_balance = false; let dis_class = ""; let dis_balance = false; let loa_override = false; let loa_balance = false; let start_balance = 0; h += ``; h += ``; (function(){ if (MAR.appnav.loanWasSubmitted() === false) return; calc_balance = MAR.getOpt(itm, "_calcbalance", false); enc_balance = MAR.getOpt(itm, "__enc_balance", false); if (enc_balance !== false && calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { if (enc_balance !== calc_balance) { h += `
    There is a value of ${enc_balance} is submitted and has been adjusted in encompass which overrides this balance. As LO you can choose to upload and chane this value
    `; loa_override = true; loa_balance = enc_balance; } else { h += `
    The calculated value of ${enc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; loa_balance = enc_balance; } } else { h += `
    The calculated value of ${enc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } else if (calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { h += `
    The calculated value of ${calc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; } else { h += `
    The calculated value of ${calc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } })(); VAL = (itm) ? itm.balance : '0'; if (calc_balance !== false) VAL = calc_balance; if (loa_balance !== false) VAL = loa_balance; startingVal = (itm) ? itm.balance : ''; start_balance = VAL; h += frm.slider("balance","Total amount of cash that you have available:",VAL,"","",function(){ }, { v00 : '0', v50 : '3000', v50_inc : '100', v75 : '10000', v75_inc : '250', v100 : '25000', v100_inc : '500', start_val : '0' }).render().wrap(`
    `,`
    `); h += "
    "; h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.how_obtained : ''; h += frm.radio("how_obtained","How did you obtain this cash?",VAL,"","",function(){ $('#question3_choice').val(''); oc(); },{ sold : "Sold a good", gift : "Was a gift", labor : "Came from labor" }).render(); h += "
    "; // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += "
    "; VAL = (itm) ? itm.have_bill_of_sale : ''; h += frm.yn3("have_bill_of_sale","Can you provide a bill of sale with the name and phone number of buyer and a certified appraisal of the value of the sold good?",VAL,"","",function(){ if(yn("#have_bill_of_sale") == 'Y'){ $('#question3_choice').val('have_bill_of_sale'); }else{ $('#question3_choice').val('have_bill_of_sale_no'); } },{}).render(); h += "
    "; h += "
    "; VAL = (itm) ? itm.can_get_gift_letter : ''; h += frm.yn3("can_get_gift_letter","Can you provide a gift letter, and one month bank statement of the donor, proving the origins of the money?",VAL,"","",function(){ if(yn("#can_get_gift_letter") == 'Y'){ $('#question3_choice').val('can_get_gift_letter'); }else{ $('#question3_choice').val('can_get_gift_letter_no'); } oc(); }).render(); h += "
    "; h += "
    "; VAL = (itm) ? itm.can_get_gift_letter_name : ''; h += frm.txt("can_get_gift_letter_name","Name *:",VAL,"e.g. Nancy Smith","",function(){}).render(); VAL = (itm) ? itm.can_get_gift_letter_relationship : ''; h += frm.txt("can_get_gift_letter_relationship","Relationship *:",VAL,"e.g. Sister","",function(){}).render(); VAL = (itm) ? itm.can_get_gift_letter_phone_number: ''; h += frm.txt("can_get_gift_letter_phone_number","Phone Number:",VAL,"___-___-____","_phone",function(){}).render(); VAL = (itm) ? itm.can_get_gift_letter_email: ''; h += frm.txt("can_get_gift_letter_email","Email Address:",VAL,"e.g. nancy@smith.com","_email",function(){}).render(); VAL = (itm) ? itm.can_get_gift_letter_permission : ''; h += frm.yn3("can_get_gift_letter_permission","Can we ask them to give us permission to use this account?",VAL,"","",function(){ if (yn3("#can_get_gift_letter_permission") == "N") { warning_no_contact(); } }).render(); h += "
    "; h += "
    "; VAL = (itm) ? itm.can_provide_invoices : ''; h += frm.yn3("can_provide_invoices","Can you provide invoices for the performed labor?",VAL,"","",function(){ if(yn("#can_provide_invoices") == 'Y'){ $('#question3_choice').val('can_provide_invoices'); }else{ $('#question3_choice').val('can_provide_invoices_no'); } },{}).render(); h += "
    "; //VAL = (itm) ? itm.question3_choice : ''; h +=""; h += "
    "; // reveal - end /* h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = 'N'; VAL = (itm) ? itm.can_take_freely : 'N'; // prefill if itm is not false h += frm.yn("can_take_freely","Are you allowed to use all this cash?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end */ h += "
    "; // JC - CW - elaine - added end div /* end modal content */ let end_fn = async function(NOWARNINGS) { /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); val = ''; let validation = $elm.data("validation"); if (validation) { if (validation == "balance") { val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money you have access to.","top"); return; } if (val.trim() == '0' ) { mar.tip(".help-button","warning","If you have no cash to declare then please cancel.","top"); return; } } if (validation == "how_obtained") { val = radio("how_obtained"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how you obtained this money.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (existingid) { let is_deleted = await mar.socket.send_and_receiveSync("app-isdeletedinencompass", { appid : mar.ID, type : "asset", uuid : itm.uuid }); if (is_deleted.data > 0) { mar.tmp_reloadAssets(false, `oops this asset was deleted from encompass whilst you still had it open.`) return; } } if (!existingid) { itm = {}; } itm.type = "cash"; if (loa_override && enc_balance !== false) { itm.__enc_balance = txt("#balance"); } else { itm.balance = txt("#balance"); } itm.how_obtained = radio("how_obtained"); itm.have_bill_of_sale = ''; itm.can_get_gift_letter = ''; itm.can_provide_invoices =''; itm.verified = "Y"; if (itm.how_obtained == 'sold'){ itm.have_bill_of_sale = yn3("#have_bill_of_sale"); if (!NOWARNINGS && itm.have_bill_of_sale == "N") { warning(); return; } } else if(itm.how_obtained == 'gift'){ itm.can_get_gift_letter = yn3("#can_get_gift_letter"); itm.can_get_gift_letter_name = txt("#can_get_gift_letter_name"); itm.can_get_gift_letter_relationship = txt("#can_get_gift_letter_relationship"); itm.can_get_gift_letter_phone_number = txt("#can_get_gift_letter_phone_number"); itm.can_get_gift_letter_email = txt("#can_get_gift_letter_email"); itm.can_get_gift_letter_permission = yn3("#can_get_gift_letter_permission"); if (!NOWARNINGS && itm.can_get_gift_letter_permission == "N") { warning(); return; } } else if (itm.how_obtained == 'labor'){ itm.can_provide_invoices = yn3("#can_provide_invoices"); if (!NOWARNINGS && itm.can_provide_invoices == "N") { warning(); return; } } else { //well should be caught by above validation check } /* itm.can_take_freely = txt("#can_take_freely"); itm.whose_name = checklist("whose_name"); itm.other_name = txt("#other_applicant_name"); */ /** * validation block start (validate the "itm" values) */ if (txt("#balance").trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money you have access to.","top"); return; } if (itm.how_obtained.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how you obtained these funds.","top"); return; } if(itm.how_obtained == 'sold' && itm.have_bill_of_sale.trim().length == 0){ mar.tip(".help-button","warning","You need to let us know if you have a bill of sale.","top"); return; }else if(itm.how_obtained == 'gift' && itm.can_get_gift_letter.trim().length == 0){ mar.tip(".help-button","warning","You need to let us know if you have a gift letter.","top"); return; }else if(itm.how_obtained == 'gift' && itm.can_get_gift_letter.trim() == 'Y'){ //do all the checking here for name etc if (itm.can_get_gift_letter_name.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to let us know the name of the person on the gift letter.","top"); mar.tip(".help-button","warning","Can you give us the first name or nickname of the person on the gift letter.","top"); return; } if (itm.can_get_gift_letter_relationship.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know the relationship of the person on the gift letter.","top"); return; } let NOCONTACTDETAILS = false; if (itm.can_get_gift_letter_phone_number.trim().length == 0 && itm.can_get_gift_letter_email.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to let us know the email or phone number of the person on the gift letter.","top"); // return; NOCONTACTDETAILS = true; } if (itm.can_get_gift_letter_permission.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know if we can contact the person on the gift letter.","top"); return; } if (itm.can_get_gift_letter_permission.trim() === "Y" ) { if (NOCONTACTDETAILS) { mar.tip(".help-button","warning","If you want us to contact the donor, you need to let us know the email or phone number of the person on the gift letter.","top"); return; } } //return; }else if(itm.how_obtained == 'labor' && itm.can_provide_invoices.trim().length == 0){ mar.tip(".help-button","warning","You need to let us know if you can provide invoices.","top"); return; }else{ //well... should be caught by above check } /* if (itm.whose_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who is associated with this cash.","top"); return; } if (itm.whose_name.includes('other') && $("#other_applicant_name").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the name of the other person who is associated with this cash.","top"); return; } */ /** * validation block end */ let lastPart = function() { //setScenario_data("visited_assets_cash","Y"); MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mvc.go("#assets-choice"); } if (enc_balance !== false) { if (mar.WE_ARE_FROM_LOI === false) { itm.balance = start_balance; } else { if (num(itm.balance) !== num(start_balance)) { // MAR.encompass.swal({ // msg : `This will override the encompass value if you choose to proceed....`, // cancel : "cancel", // cancelfn : function() { // // }, // ok : "overwrite", // okfn : function(){ // itm.__enc_balance = null; // lastPart(); // } // }); // return; } } } lastPart(); } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ end_fn(false) }),"cancel",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let warning = function(){ end_fn(true); return; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ "This money may not be usable for this real estate transaction. We will not add the asset."+ "
    "+ ""; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); return; } end_fn(true) }); } let warning_no_contact = function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ "The source of funds needs to be proved by most loan programs, to comply with the Patriot Act, which forces lenders to scan for money laundering, drug money and terrorism. " + "
    " + "
    " + "Do we have permission to contact "+txt("#can_get_gift_letter_name")+"? " + //"This money may not be usable for this real estate transaction. We will not add the asset."+ "
    "+ ""; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "NO", call : { text: "YES", value: "yes", closeModal: false } } }) .then((act) => { if (act == "yes") { yn3("#can_get_gift_letter_permission","Y"); $("#can_get_gift_letter_permission").change(); swal.close(); } else { // addnote mar.answers.note = "We did ask the client a 2nd time about the patriot act but they still declined to allow us to contact "+txt("#can_get_gift_letter_name")+" directly about the gift" mar.fakesave(); swal.close(); } }); } let oc = function() { let val=''; val = radio("how_obtained"); $("#question3_choice1").addClass('x-hide'); $("#question3_choice2").addClass('x-hide'); $("#question3_choice3").addClass('x-hide'); $("#question3_choice2_followup").addClass('x-hide'); if(val === 'sold'){ $("#question3_choice1").removeClass('x-hide'); /* pick up here if(yn("#have_bill_of_sale") == 'Y'){ $('#question3_choice').val('have_bill_of_sale'); }else{ $('#question3_choice').val('have_bill_of_sale_no'); } */ }else if(val === 'gift'){ $("#question3_choice2").removeClass('x-hide'); if( yn("#can_get_gift_letter") == 'Y'){ $('#question3_choice').val('can_get_gift_letter'); $("#question3_choice2_followup").removeClass('x-hide'); //$("#body-container").scrollTo("max",200); } $("#body-container").scrollTo("max",200); }else if(val === 'labor'){ $("#question3_choice3").removeClass('x-hide'); } val = $("#question3_choice").val(); // console.warn('$("#question3_choice").val():'+$("#question3_choice").val()) // console.warn('can_get_gift_letter? : '+val) if(val === 'can_get_gift_letter'){ $("#question3_choice2_followup").removeClass('x-hide'); $("#body-container").scrollTo("max",200); }else if(val === 'can_get_gift_letter_no'){ //juust leave teh data, only in last check see if it is there //txt("#can_get_gift_letter_name", ''); // txt("#can_get_gift_letter_relationship", ''); //txt("#can_get_gift_letter_phone_number", ''); // yn("#can_get_gift_letter_permission", ''); $("#question3_choice2_followup").addClass('x-hide'); } /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); val = ''; let validation = $elm.data("validation"); if (validation) { if (validation == "balance") { val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money you have access to.","top"); return; } } if (validation == "how_obtained") { val = radio("how_obtained"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how you obtained this money.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-check3").mycheck3(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#question3_choice").on('change', oc); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { if (startingVal != "") { oc(true); }else{ //user has not been here yet. } } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-gifts"] = (function(){ var VAL = '' var html = ""; var typeAccount = "gifts"; var startingVal =''; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("gifts",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let h = ""; h += frm.htitle("GIFTS").render(); h += frm.elaine("Gifts from relatives are acceptable to go toward your down payment.","er").render(); h += "
    "; // JC - CW - elaine added div let enc_balance = false; let calc_balance = false; let dis_class = ""; let dis_balance = false; let loa_override = false; let loa_balance = false; let start_balance = 0; h += ``; h += ``; (function(){ if (MAR.appnav.loanWasSubmitted() === false) return; calc_balance = MAR.getOpt(itm, "_calcbalance", false); enc_balance = MAR.getOpt(itm, "__enc_balance", false); if (enc_balance !== false && calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { if (enc_balance !== calc_balance) { h += `
    There is a value of ${enc_balance} is submitted and has been adjusted in encompass which overrides this balance. As LO you can choose to upload and chane this value
    `; loa_override = true; loa_balance = enc_balance; } else { h += `
    The calculated value of ${enc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; loa_balance = enc_balance; } } else { h += `
    The calculated value of ${enc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } else if (calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { h += `
    The calculated value of ${calc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; } else { h += `
    The calculated value of ${calc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } })(); VAL = (itm) ? itm.balance : '0'; if (calc_balance !== false) VAL = calc_balance; if (loa_balance !== false) VAL = loa_balance; startingVal = (itm) ? itm.balance : ''; start_balance = VAL; h += frm.slider("balance","Amount of gift funds:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000', start_val : '0' }).render().wrap(`
    `,`
    `); h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = ''; VAL = (itm) ? itm.fromrelative : ''; // prefill if itm is not false h += frm.yn3("fromrelative","Is this gift from a relative?",VAL,"","",function(e){ //run function here changing label text below //console.warn('this fromrelative ; ',yn("#fromrelative")); /*if(yn("#fromrelative") === 'Y'){ $("#relativeOrDonerHolder").text('What is the relatives name?'); $("#relativeOrDonerHolder2").text('relative'); }else{ $("#relativeOrDonerHolder").text('What is the donors name?'); $("#relativeOrDonerHolder2").text('donor'); } */ oc(); },{}).render(); h += "
    " // reveal - end /* h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.relativename : ''; h += frm.txt("relativename","What is the relatives name?",VAL,"e.g. John Smith","",function(){}).render(); h += "
    " // reveal - end */ h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.can_get_gift_letter : ''; h += frm.yn3("can_get_gift_letter","Can you provide a gift letter, and one month bank statement of the donor, proving the origins of the money?",VAL,"","",function(){ oc(); }).render(); h += "
    "; h += "
    "; VAL = (itm) ? itm.can_get_gift_letter_name : ''; h += frm.txt("can_get_gift_letter_name","Name *:",VAL,"e.g. Nancy Smith","",function(){}).render(); VAL = (itm) ? itm.can_get_gift_letter_relationship : ''; h += frm.txt("can_get_gift_letter_relationship","Relationship *:",VAL,"e.g. Sister","",function(){}).render(); VAL = (itm) ? itm.can_get_gift_letter_phone_number: ''; h += frm.txt("can_get_gift_letter_phone_number","Phone Number:",VAL,"___-___-____","_phone",function(){}).render(); VAL = (itm) ? itm.can_get_gift_letter_email: ''; h += frm.txt("can_get_gift_letter_email","Email Address:",VAL,"nancy@smith.com","_email",function(){}).render(); VAL = (itm) ? itm.can_get_gift_letter_permission : ''; h += frm.yn3("can_get_gift_letter_permission","Can we ask them for proof of funds and to e-sign a gift letter?",VAL,"","",function(){}).render(); h += "
    "; h += "
    " // reveal - end /* h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = 'N'; VAL = (itm) ? itm.can_take_freely : 'N'; // prefill if itm is not false h += frm.yn("can_take_freely","Are you allowed to use the funds from this gift?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end */ /* h += "
    "; // reveal - start h += frm.hr().render() //---- set up the applicants checklist h += "
    Which applicants have ownership of this gift?
    Multiple answers are possible.
    "; VAL = (itm) ? itm.whose_name : []; var applicantsObj = getApplicantsNames_v2(); var slimmedObj = {}; for (let i=0; i -1) ? itm.other_name : ''; // prefill if itm is not false h += frm.txt("other_applicant_name","",VAL,"e.g. Nancy Smith","",function(){}).render(); h += "
    "; // this is the holder for the OTHER person name //---- end the applicants checklist h += "
    " // reveal - end */ h += "
    "; // JC - CW - elaine - added end div /* end modal content */ let end_fn = async function(NOWARNINGS) { if(txt("#fromrelative") === 'Y'){ //$("#relativeOrDonerHolder").text('What is the relatives name?'); $("#relativeOrDonerHolder2").text('relative'); }else{ //$("#relativeOrDonerHolder").text('What is the donors name?'); $("#relativeOrDonerHolder2").text('donor'); } /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "balance") { var val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much this gift is worth.","top"); return; } } /* if (validation == "relativename") { var val = txt("#relativename"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know the name of the person who gave you this gift.","top"); return; } } */ } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (existingid) { let is_deleted = await mar.socket.send_and_receiveSync("app-isdeletedinencompass", { appid : mar.ID, type : "asset", uuid : itm.uuid }); if (is_deleted.data > 0) { mar.tmp_reloadAssets(false, `oops this asset was deleted from encompass whilst you still had it open.`) return; } } if (!existingid) { itm = {}; } itm.type = "gifts"; if (loa_override && enc_balance !== false) { itm.__enc_balance = txt("#balance"); } else { itm.balance = txt("#balance"); } itm.fromrelative = txt("#fromrelative"); // itm.relativename = txt("#relativename"); itm.can_get_gift_letter = yn3("#can_get_gift_letter"); itm.can_get_gift_letter_name = txt("#can_get_gift_letter_name"); itm.can_get_gift_letter_relationship = txt("#can_get_gift_letter_relationship"); itm.can_get_gift_letter_phone_number = txt("#can_get_gift_letter_phone_number"); itm.can_get_gift_letter_email = txt("#can_get_gift_letter_email"); itm.can_get_gift_letter_permission = yn3("#can_get_gift_letter_permission"); //itm.can_take_freely = txt("#can_take_freely"); //itm.whose_name = checklist("whose_name"); //itm.other_name = txt("#other_applicant_name"); /** * validation block start (validate the "itm" values) */ if (txt("#balance").trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much this gift is worth.","top"); return; } /* if (itm.relativename.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know the name of the person who gave you this gift.","top"); return; } */ if(itm.can_get_gift_letter.trim().length == 0){ mar.tip(".help-button","warning","You need to let us know if you have a gift letter.","top"); return; } if( itm.can_get_gift_letter.trim() == 'Y'){ //do all the checking here for name etc if (itm.can_get_gift_letter_name.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to let us know the name of the person on the gift letter.","top"); mar.tip(".help-button","warning","Can you give us the first name or nickname of the person on the gift letter.","top"); return; } if (itm.can_get_gift_letter_relationship.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know the relationship of the person on the gift letter.","top"); return; } let NOCONTACTDETAILS = false; if (itm.can_get_gift_letter_phone_number.trim().length == 0 && itm.can_get_gift_letter_email.trim().length == 0 ) { NOCONTACTDETAILS = true; // mar.tip(".help-button","warning","You need to let us know the email or phone number of the person on the gift letter.","top"); // return; } if (itm.can_get_gift_letter_permission.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know if we can contact the person on the gift letter.","top"); return; } if (!NOWARNINGS && itm.can_get_gift_letter_permission.trim() == "N") { warning_no_contact("For some loan programs, the lender needs to verify a bank statement from the donor and they need to e-sign a gift letter.", NOCONTACTDETAILS); return; } if (!NOWARNINGS && itm.can_get_gift_letter_permission.trim() == "Y") { if (NOCONTACTDETAILS) { mar.tip(".help-button","warning","If you want us to contact the donor, you need to let us know the email or phone number of the person on the gift letter.","top"); return; } } //return; } else { if (!NOWARNINGS) { warning(); return; } } /* if (itm.whose_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who is associated with this gift.","top"); return; } if (itm.whose_name.includes('other') && $("#other_applicant_name").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the name of the other person who is associated with these gifts.","top"); return; } */ /** * validation block end */ itm.verified = "Y"; let lastPart = function() { MAR.assets.set(itm.type, existingid, itm); // if (!existingid) { // MAR.pushOpt(mar.answers, "_activity_log", `assets add ${itm.uuid}`); // } else { // MAR.pushOpt(mar.answers, "_activity_log", `assets modify ${itm.uuid}`); // } mar.fakesave(); mvc.go("#assets-choice"); } if (enc_balance !== false) { if (mar.WE_ARE_FROM_LOI === false) { itm.balance = start_balance; } else { if (num(itm.balance) !== num(start_balance)) { // MAR.encompass.swal({ // msg : `This will override the encompass value if you choose to proceed....`, // cancel : "cancel", // cancelfn : function() { // // }, // ok : "overwrite", // okfn : function(){ // itm.__enc_balance = null; // lastPart(); // } // }); // return; } } } lastPart(); } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ end_fn(false); }),"cancel",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let warning = function(TXT){ end_fn(true); return; var s = document.createElement("div"); s.setAttribute("class","normal-form"); if (arguments.length == 0) TXT = "This money may not be usable for this real estate transaction. We will not add the asset."; s.innerHTML = ""+ TXT "
    "+ ""; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "Got it", call : { text: "Call", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); return; } end_fn(true) }); } let warning_no_contact = function(TXT, NOCONTACTDETAILS){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ TXT "
    "+ ""; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "I will", givepermission : { text: "Lender will", value: "givepermission", closeModal: false } } }) .then((act) => { if (act == "givepermission") { if (NOCONTACTDETAILS === true) { yn3("#can_get_gift_letter_permission","Y"); $("#can_get_gift_letter_permission").change() swal.close(); return; } yn3("#can_get_gift_letter_permission","Y"); $("#can_get_gift_letter_permission").change() swal.close(); end_fn(true) return; } end_fn(true) }); } let oc = function() { if(txt("#fromrelative") === 'Y'){ // $("#relativeOrDonerHolder").text('What is the relatives name?'); $("#relativeOrDonerHolder2").text('relative'); }else{ //$("#relativeOrDonerHolder").text('What is the donors name?'); $("#relativeOrDonerHolder2").text('donor'); } /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "balance") { var val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much this gift is worth.","top"); return; } } /* if (validation == "relativename") { var val = txt("#relativename"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","Please let us know the name of the person who gave you this gift.","top"); return; } } */ } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if(yn("#can_get_gift_letter") == 'Y'){ $('#gifts_can_get_gift_letter').removeClass('x-hide'); $("#body-container").scrollTo("max",200); }else{ $('#gifts_can_get_gift_letter').addClass('x-hide'); $("#body-container").scrollTo("max",200); } } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-check3").mycheck3(); //$("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#body-container #can_get_gift_letter_name").autocomplete({ minLength:0, appendTo: "#body-container .x_content", source: MAR.getNames() }); $("#body-container #can_get_gift_letter_phone_number").autocomplete({ minLength:0, appendTo: "#body-container .x_content", source: MAR.getTels() }); $("#body-container #can_get_gift_letter_email").autocomplete({ minLength:0, appendTo: "#body-container .x_content", source: MAR.getEmails() }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { if (startingVal != "") { oc(true); }else{ //user has not been here yet. } } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-emd"] = (function(){ var VAL = '' var html = ""; var typeAccount = "emd"; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("emd",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let TIMEFRAME = getScenario_data("loan_type_purchase_options",""); let h = ""; h += frm.htitle("Earnest Money Deposit").render(); if (1 == 2 && itm == false && TIMEFRAME !== "contract") { h += frm.elaine("Unless you are under contract ... bla ....","er").render(); h += uihelpers.cbuttonbar("",frm.addfunction(function(){ }),"cancel",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); } else { h += frm.elaine("Please only fill this out if you have already paid an Earnest Money Deposit, aka the down payment.","er").render(); h += "
    Make sure the bank balance you filled in is the balance after the EMD has been withdrawn from your account, to prevent a double count of your available money.
    " h += "
    "; // JC - CW - elaine added div // h += "
    "; // h += ""; // h += "I understand"; // h += "
    "; // h += "
    "; // reveal - start (with validation to previous field) // h += frm.hr().render(); VAL = (itm) ? itm.emddate : ''; h += frm.txt("emddate","
    When did you make the EMD?",VAL,"","",function(){ let elm = $("#emddate") if (new Date(elm.val()) > new Date()) { elm.val(elm.prop("max")); } }, "date").render(); VAL = (itm) ? itm.balance : '2000'; // h += "
    "; // reveal - start (with validation to previous field) // h += frm.hr().render(); // VAL = (itm) ? itm.last4digits : ''; // h += frm.txt("last4digits","Last 4 digits of the account number from which it was made?",VAL,"e.g.1234","",function(){}).render(); // h += "
    "; // h += "
    "; h += (function(){ let h = ""; let accounts = MAR.assets.getLast4sItems(); let opts = {}; for (let i=0; i < accounts.length; i++) { let acc = accounts[i]; if (acc.type === "bank") acc.type = "checkings"; if (acc.last4digits !== "") acc.last4digits = `#${acc.last4digits}`; opts[acc.uuid] = `${acc.bank} - ${acc.type} ${elaineui.format("cur",acc.balance).replace(/,/g,",")} ${acc.last4digits}` } opts.add = "Add another bank account"; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render() VAL = (itm) ? itm.last4digitsuuid : ''; h += frm.radio("last4digitsuuid","Which account did you use :",VAL,"","",function(){ let val = radio("last4digitsuuid"); if (val === "add") { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warnings").render(); s.innerHTML += `
    You will be directed to the assets page or cancel to choose an existing account
    `; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "cancel", call : { text: "OK, I got it", value: "close", closeModal: false } } }) .then((act) => { if (act == "close") { mvc.go("#assets-choice"); swal.close(); } }); } else { } oc(); },opts).render(); h += `
    `; h += "
    "; // this is the holder for the OTHER person name return h; })() let enc_balance = false; let calc_balance = false; let dis_class = ""; let dis_balance = false; let loa_override = false; let loa_balance = false; let start_balance = 0; (function(){ if (MAR.appnav.loanWasSubmitted() === false) return; calc_balance = MAR.getOpt(itm, "_calcbalance", false); enc_balance = MAR.getOpt(itm, "__enc_balance", false); if (enc_balance !== false && calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { if (enc_balance !== calc_balance) { h += `
    There is a value of ${enc_balance} is submitted and has been adjusted in encompass which overrides this balance. As LO you can choose to upload and chane this value
    `; loa_override = true; loa_balance = enc_balance; } else { h += `
    The calculated value of ${enc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; loa_balance = enc_balance; } } else { h += `
    The calculated value of ${enc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } else if (calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { h += `
    The calculated value of ${calc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; } else { h += `
    The calculated value of ${calc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } })(); h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.balance : '1000'; if (calc_balance !== false) VAL = calc_balance; if (loa_balance !== false) VAL = loa_balance; start_balance = VAL; h += frm.slider("balance","Total down payment made:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000', start_val : '40000' }).render(); h += "
    "; h += "
    "; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render() VAL = (itm) ? itm.madeby : ''; h += frm.radio("madeby","The payment was made by :",VAL,"","",function(){ oc(); },{ wire : "Wire", check : "Check" }).render(); h += "
    "; // this is the holder for the OTHER person name if (MAR.isUnderContract() === false) { h += (function(){ let h = ""; h += frm.hr().render() VAL = ""; h += frm.radio("donext","You indicated you are still looking for a home, are you under contract? ",VAL,"","",function(){ oc(); },{ Y : "Yes", N : "No" }).render(); return h; })().wrap("
    ","
    "); } /* //---- set up the applicants checklist h += "
    Which applicants participated in this downpayment?
    Multiple answers are possible.
    "; VAL = (itm) ? itm.whose_name : []; var applicantsObj = getApplicantsNames_v2(); var slimmedObj = {}; for (let i=0; i -1) ? itm.other_name : ''; // prefill if itm is not false h += frm.txt("other_applicant_name","",VAL,"e.g. Nancy Smith","",function(){}).render(); h += "
    "; // this is the holder for the OTHER person name //---- end the applicants checklist h += "
    " // reveal - end */ //h += "
    "; // JC - CW - elaine - added end div h += "
    "; /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(async function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "confirmation") { var val = yn("#confirmation"); if (val == 'N' ) { return; } } if (validation == "emddate") { var val = txt("#emddate"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know when the payment was made.","top"); return; } } if (validation == "last4digit") { var val = radio("last4digitsuuid"); if (val.trim().length == 0 || val === "add" ) { mar.tip(".help-button","warning","You need to let us know when the payment was made.","top"); return; } } if (validation == "balance") { var val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money you put down.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (existingid) { let is_deleted = await mar.socket.send_and_receiveSync("app-isdeletedinencompass", { appid : mar.ID, type : "asset", uuid : itm.uuid }); if (is_deleted.data > 0) { mar.tmp_reloadAssets(false, `oops this asset was deleted from encompass whilst you still had it open.`) return; } } if (!existingid) { itm = {}; } itm.type = "emd"; itm.confirmation = yn("#confirmation"); if (loa_override && enc_balance !== false) { itm.__enc_balance = txt("#balance"); } else { itm.balance = txt("#balance"); } itm.madeby = radio("madeby"); itm.emddate = txt("#emddate"); itm.last4digitsuuid = radio("last4digitsuuid"); itm.verified = "Y"; //itm.whose_name = checklist("whose_name"); //itm.other_name = txt("#other_applicant_name"); /** * validation block start (validate the "itm" values) */ if (itm.emddate.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know when the payment was made.","top"); return; } if (itm.last4digitsuuid.trim().length == 0 || itm.last4digitsuuid.trim() === "add") { mar.tip(".help-button","warning","You need to let us know which account you made the payment from.","top"); return; } itm.last4digits = MAR.getOpt(MAR.assets.getByUUID(itm.last4digitsuuid), "last4digits",""); if (txt("#balance").trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much money you placed down.","top"); return; } if (itm.madeby.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how the payment is made.","top"); return; } if (MAR.isUnderContract() === false) { let donext = radio("donext"); if (donext === "") { mar.tip(".help-button","warning","You need to let us know if you are under contract.","top"); return; } else if (donext === "Y") { debugger; setScenario_data("loan_type_purchase_options","contract"); } } /* if (itm.whose_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who is associated with this downpayment.","top"); return; } if (itm.whose_name.includes('other') && $("#other_applicant_name").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the name of the other person who is associated with this downpayment.","top"); return; } */ /** * validation block end */ // if (MAR.assets.getLast4s().indexOf(itm.last4digits) < 0) { // // var s = document.createElement("div"); // s.setAttribute("class","normal-form"); // // // s.innerHTML = ""+ // frm.htitle("Warnings").render(); // s.innerHTML += `
    We do not recognize this account. Please make sure you list #${itm.last4digits} in your bank accounts
    `; // // swal({ // //title : "Same line of work", // className : "midelinfopopupOneButton", // content : s, // buttons : { // cancel : false, // call : { // text: "OK, I got it", // value: "close", // closeModal: false // } // } // }) // .then((act) => { // if (act == "close") { // MAR.assets.set(itm.type, existingid, itm); // mar.fakesave(); // mvc.go("#assets-choice"); // swal.close(); // } // }); // // } else { // MAR.assets.set(itm.type, existingid, itm); // mar.fakesave(); // mvc.go("#assets-choice"); // // } let lastPart = function() { MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mvc.go("#assets-choice"); } if (enc_balance !== false) { if (mar.WE_ARE_FROM_LOI === false) { itm.balance = start_balance; } else { if (num(itm.balance) !== num(start_balance)) { // MAR.encompass.swal({ // msg : `This will override the encompass value if you choose to proceed....`, // cancel : "cancel", // cancelfn : function() { // // }, // ok : "overwrite", // okfn : function(){ // itm.__enc_balance = null; // lastPart(); // } // }); // return; } } } lastPart(); }),"cancel",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); } /* let checkListChange = function(e) { var ar = checklist("whose_name"); if (ar.includes('99')){ $("#other_applicant_holder").removeClass('x-hide'); }else{ $("#other_applicant_holder").addClass('x-hide'); $("#other_applicant_name").val(''); } $("#body-container").scrollTo("max",200); } */ let oc = function() { } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); //$("#body-container .xx-checklist").mychecklist(); var now = new Date(); let maxDate = now.toISOString().substring(0,10); $('#emddate').prop('max', maxDate); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-nprf"] = (function(){ var VAL = '' var html = ""; var typeAccount = "nprf"; var continueAndNo = 0; function render(pg, localopts) { continueAndNo = 0; /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("nprf",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let h = ""; h += frm.htitle("Net Proceeds sale real estate").render(); // h += frm.elaine("Please only fill this out if you're planning on selling your home before going through with this transaction. We're looking to find out the amount that will be transferred to your checking account, so list the amount that would be there once all fees and costs have been deducted.","er").render(); h += frm.elaine("Please answer the questions below.","er").render(); h += "
    "; // JC - CW - elaine added div VAL = (itm) ? itm.sell_before_close : 'N'; h +=``; VAL = (itm) ? itm.current_situation : ''; let current_situation = VAL; h += frm.radio("current_situation","Select what applies to you:",VAL,"","",function(){ oc(); },{ cashedin : "I already sold my property and cashed in the proceeds", contract : "I am under contract to sell my house prior to this transaction", forsale : "I am not yet under contract but plan to sell my house prior to this transaction", toolate : "I will not sell my house before this transaction" }).render(); // h += "
    "; // reveal - start (with validation to previous field) // VAL = (itm) ? itm.sell_before_close : 'N'; // h += frm.yn3("sell_before_close","Will you sell your property prior to this transaction?",VAL,"","",function(){},{}).render(); // h += "
    " if (current_situation == "toolate") { h += "
    "; // reveal - start (with validation to previous field) } else { h += "
    "; // reveal - start (with validation to previous field) } let enc_balance = false; let calc_balance = false; let dis_class = ""; let dis_balance = false; let loa_override = false; let loa_balance = false; let start_balance = 0; h += ``; h += ``; (function(){ if (MAR.appnav.loanWasSubmitted() === false) return; calc_balance = MAR.getOpt(itm, "_calcbalance", false); enc_balance = MAR.getOpt(itm, "__enc_balance", false); if (enc_balance !== false && calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { if (enc_balance !== calc_balance) { h += `
    There is a value of ${enc_balance} is submitted and has been adjusted in encompass which overrides this balance. As LO you can choose to upload and chane this value
    `; loa_override = true; loa_balance = enc_balance; } else { h += `
    The calculated value of ${enc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; loa_balance = enc_balance; } } else { h += `
    The calculated value of ${enc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } else if (calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { h += `
    The calculated value of ${calc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; } else { h += `
    The calculated value of ${calc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } })(); VAL = (itm) ? itm.balance : '40000'; if (calc_balance !== false) VAL = calc_balance; if (loa_balance !== false) VAL = loa_balance; start_balance = VAL; h += frm.slider("balance","Take home profit:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000', start_val : '40000' }).render().wrap(`
    `,`
    `); h += "
    "; let accounts = MAR.assets.getBankAccounts(); let opts = {}; for (let x in accounts) { opts[x] = `${accounts[x].name} (${accounts[x].type})`; } VAL = (itm) ? itm.gid : ''; h += frm.radio("gid","which accunt will it be paid into:",VAL,"","",function(){ oc(); },opts).render(); h += "
    " // reveal - end /* h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render() //---- set up the applicants checklist h += "
    Which applicants will benefit from this sale?
    Multiple answers are possible.
    "; VAL = (itm) ? itm.whose_name : []; var applicantsObj = getApplicantsNames_v2(); var slimmedObj = {}; for (let i=0; i -1) ? itm.other_name : ''; // prefill if itm is not false h += frm.txt("other_applicant_name","",VAL,"e.g. Nancy Smith","",function(){}).render(); h += "
    "; // this is the holder for the OTHER person name //---- end the applicants checklist h += "
    " // reveal - end */ h += "
    "; // JC - CW - elaine - added end div /* end modal content */ let reveal = function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "current_situation") { if (radio("current_situation").trim().length == 0) { mar.tip(".help-button","warning","You need to let us know your current situation.","top"); return; } if (radio("current_situation").trim() == "toolate") { $elm.removeClass("x-revealdiv"); mar.tip(".help-button","warning","Sorry, we can't use these funds as assets.","top"); return; } } // if (validation == "sell_before_close" && yn("#sell_before_close").trim() == 'N') { // // if(continueAndNo >= 1){ // // mvc.go("#assets-choice"); // // return; // }else{ // mar.tip(".help-button","warning","Sorry, we can't use these funds as assets.","top"); // continueAndNo++; // return; // } // // } // // // // if (validation == "balance" && yn("#sell_before_close").trim() == 'Y') { // var val = txt("#balance"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to let us know how much profit you are expecting.","top"); // return; // } // } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv").css("display",""); $("#body-container").scrollTo("max",200); }); return; } return true; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(async function(){ if (reveal() !== true) return; /** * validation & reveal block end */ if (existingid) { let is_deleted = await mar.socket.send_and_receiveSync("app-isdeletedinencompass", { appid : mar.ID, type : "asset", uuid : itm.uuid }); if (is_deleted.data > 0) { mar.tmp_reloadAssets(false, `oops this asset was deleted from encompass whilst you still had it open.`) return; } } if (!existingid) { itm = {}; } itm.type = "nprf"; itm.current_situation = radio("current_situation"); itm.sell_before_close = (itm.current_situation == "toolate") ? "N" : "Y"; //yn3("#sell_before_close"); if (loa_override && enc_balance !== false) { itm.__enc_balance = txt("#balance"); } else { itm.balance = txt("#balance"); } itm.verified = "Y"; itm.gid = radio("gid"); //itm.whose_name = checklist("whose_name"); //itm.other_name = txt("#other_applicant_name"); /** * validation block start (validate the "itm" values) */ if(itm.current_situation.trim() == ''){ mar.tip(".help-button","warning","You need to let us know your current situation.","top"); return; } // if(itm.sell_before_close.trim() == 'N'){ // $("#balance-slider").addClass("x-hide"); // mar.tip(".help-button","warning","Sorry, we can't use these funds as assets.","top"); // return; // } if ($("#balance-slider").hasClass("x-hide")) { $("#balance-slider").removeClass("x-hide"); return; } if (itm.balance.trim().length == 0 && itm.sell_before_close.trim() == 'Y' ) { mar.tip(".help-button","warning","You need to let us know how much profit you are expecting.","top"); return; } if(itm.gid.trim() == ''){ mar.tip(".help-button","warning","You need to let us know which account it is paid into.","top"); return; } if(itm.sell_before_close.trim() == 'N'){ itm.balance ='0'; } /* if (itm.whose_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who is associated with this profit.","top"); return; } if (itm.whose_name.includes('other') && $("#other_applicant_name").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the name of the other person who is associated with this profit.","top"); return; } */ /** * validation block end */ if (itm.sell_before_close.trim() == 'N') { //_warnings = jQuery.unique(_warnings); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Warnings").render(); s.innerHTML += "
    Sorry, we can't use these funds as assets.
    "; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : false, call : { text: "OK, I got it", value: "close", closeModal: false } } }) .then((act) => { if (act == "close") { mvc.go("#assets-choice"); swal.close(); } }); return; } let lastPart = function() { MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mvc.go("#assets-choice"); } if (enc_balance !== false) { if (mar.WE_ARE_FROM_LOI === false) { itm.balance = start_balance; } else { if (num(itm.balance) !== num(start_balance)) { // MAR.encompass.swal({ // msg : `This will override the encompass value if you choose to proceed....`, // cancel : "cancel", // cancelfn : function() { // // }, // ok : "overwrite", // okfn : function(){ // itm.__enc_balance = null; // lastPart(); // } // }); // return; } } } lastPart(); }),"cancel",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { var ar = checklist("whose_name"); if (ar.includes('99')){ $("#other_applicant_holder").removeClass('x-hide'); }else{ $("#other_applicant_holder").addClass('x-hide'); $("#other_applicant_name").val(''); } if (ar == "99") checklist("whose_name","0,99"); if (ar == "") checklist("whose_name","0"); $("#body-container").scrollTo("max",200); } let oc = function() { if (radio("current_situation") == "") return; if (reveal() !== true) return; if (radio("current_situation") == "toolate") { $("#balance-slider").addClass("x-hide"); } else { if ($("#balance-slider").hasClass("x-hide")) { $elm = $("#balance-slider"); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv").css("display",""); $("#body-container").scrollTo("max",200); }); return; } } } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-other"] = (function(){ var VAL = '' var html = ""; var typeAccount = "other"; let othertypes = [ { "value": "MutualFund", "text": "Mutual Funds" }, { "value": "CertificateOfDepositTimeDeposit", "text": "Certificate Of Deposit" }, { "value": "MoneyMarketFund", "text": "Money Market Fund" }, { "value": "TrustAccount", "text": "Trust Account" }, { "value": "GiftOfEquity", "text": "Gift Of Equity" }, { "value": "BridgeLoanNotDeposited", "text": "Bridge Loan Not Deposited" }, { "value": "SecuredBorrowedFundsNotDeposited", "text": "Secured Borrowed Funds Not Deposited" }, { "value": "CashDepositOnSalesContract", "text": "Cash Deposit On Sales Contract" }, { "value": "NetWorthOfBusinessOwned", "text": "Net Worth Of Business Owned" }, { "value": "NetEquity", "text": "Net Equity" }, { "value": "Other", "text": "Other" }, { "value": "StockOptions", "text": "Stock Options" }, { "value": "Bond", "text": "Bond" }, { "value": "IndividualDevelopmentAccount", "text": "Individual Development Account" }, { "value": "LifeInsurance", "text": "Life Insurance" }, { "value": "Annuity", "text": "Annuity" }, { "value": "Automobile", "text": "Automobile" }, { "value": "Boat", "text": "Boat" }, { "value": "BorrowerPrimaryHome", "text": "Borrower Primary Home" }, { "value": "EmployerAssistedHousing", "text": "Employer Assisted Housing" }, { "value": "LeasePurchaseFund", "text": "Lease Purchase Fund" }, { "value": "ProceedsFromSecuredLoan", "text": "Proceeds From Secured Loan" }, { "value": "ProceedsFromUnsecuredLoan", "text": "Proceeds From Unsecured Loan" }, { "value": "LeasePurchaseCredit", "text": "Lease Purchase Credit" }, { "value": "RecreationalVehicle", "text": "Recreational Vehicle" }, { "value": "SeverancePackage", "text": "Severance Package" }, { "value": "SweatEquity", "text": "Sweat Equity" }, { "value": "TradeEquityFromPropertySwap", "text": "TradeEquity From Property Swap" } ]; let getOtherTypesAsArray = function() { return MAR.assets.getOtherTypesAsArray(); // let retval = []; // for (let i=0; i < othertypes.length;i++) { // retval.push(othertypes[i].text) // } // return retval; } let getOtherTypesKeyByVal = function(val) { return MAR.assets.getOtherTypeByText(val,""); // let retval = []; // for (let i=0; i < othertypes.length;i++) { // if (othertypes[i].text == val) return othertypes[i].value // } // return ""; } function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.assets.get("other",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let h = ""; h += frm.htitle("OTHER").render(); h += frm.elaine("If you have any other income that does not fit in our categories, please enter the total amount with a short description.","er").render(); h += "
    "; // JC - CW - elaine added div let enc_balance = false; let calc_balance = false; let dis_class = ""; let dis_balance = false; let loa_override = false; let loa_balance = false; let start_balance = 0; h += ``; h += ``; (function(){ if (MAR.appnav.loanWasSubmitted() === false) return; calc_balance = MAR.getOpt(itm, "_calcbalance", false); enc_balance = MAR.getOpt(itm, "__enc_balance", false); if (enc_balance !== false && calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { if (enc_balance !== calc_balance) { h += `
    There is a value of ${enc_balance} is submitted and has been adjusted in encompass which overrides this balance. As LO you can choose to upload and chane this value
    `; loa_override = true; loa_balance = enc_balance; } else { h += `
    The calculated value of ${enc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; loa_balance = enc_balance; } } else { h += `
    The calculated value of ${enc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } else if (calc_balance !== false) { if (mar.WE_ARE_FROM_LOI === true) { h += `
    The calculated value of ${calc_balance} is submitted with the application. As LO you can choose to change this value in the app and it will be uploaded to encompass
    `; loa_override = true; } else { h += `
    The calculated value of ${calc_balance} is submitted with the application and cannot be changed. Below you see the balance entered for your reference
    `; dis_class = ` dis_class`; dis_balance = true; } } })(); VAL = (itm) ? itm.balance : '40000'; if (calc_balance !== false) VAL = calc_balance; if (num(VAL) === 0 && loa_balance !== false) VAL = loa_balance; if (loa_balance !== false) VAL = loa_balance; start_balance = VAL; h += frm.slider("balance","Total other amount:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000', start_val : '40000' }).render().wrap(`
    `,`
    `); h += "
    "; h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.otherdescription : ''; h += frm.txt("otherdescription","Please enter a short description.",VAL,"e.g. a Yacht","",function(){}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.institution_name : ''; h += frm.hr().render() h += frm.txt("institution_name","Institution name?",VAL,"e.g.Betterment","",function(){}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render() //---- set up the applicants checklist h += "
    Which applicants will be a part of this other source of funds?
    Multiple answers are possible.
    "; VAL = (itm) ? itm.whose_name : ["0"]; var applicantsObj = getApplicantsNames_v2(); var slimmedObj = {}; for (let i=0; i -1) ? itm.other_name : ''; // prefill if itm is not false h += frm.txt("other_applicant_name","",VAL,"e.g. Nancy Smith","",function(){}).render(); h += "
    "; // this is the holder for the OTHER person name //---- end the applicants checklist h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div h += ``; /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(async function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "balance") { var val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much this other amount is.","top"); return; } } if (validation == "otherdescription") { var val = txt("#otherdescription"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to describe this other amount.","top"); return; } } if (validation == "institution_name") { var val = txt("#institution_name"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to provide and institutuon name.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (existingid) { let is_deleted = await mar.socket.send_and_receiveSync("app-isdeletedinencompass", { appid : mar.ID, type : "asset", uuid : itm.uuid }); if (is_deleted.data > 0) { mar.tmp_reloadAssets(false, `oops this asset was deleted from encompass whilst you still had it open.`) return; } } if (!existingid) { itm = {}; } itm.type = "other"; if (loa_override && enc_balance !== false) { itm.__enc_balance = txt("#balance"); } else { itm.balance = txt("#balance"); } itm.otherdescription = txt("#otherdescription"); itm.institution_name = txt("#institution_name"); itm.whose_name = checklist("whose_name"); itm.other_name = txt("#other_applicant_name"); itm.enc_type = getOtherTypesKeyByVal(itm.otherdescription); itm.verified = "Y"; /** * validation block start (validate the "itm" values) */ if (txt("#balance").trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know how much this other amount is.","top"); return; } if (itm.otherdescription.trim().length == 0 ) { mar.tip(".help-button","warning","You need to describe this other amount.","top"); return; } if (itm.institution_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us which institution holds this asset.","top"); return; } if (itm.whose_name.trim().length == 0 ) { mar.tip(".help-button","warning","You need to let us know who is associated with this other asset.","top"); return; } if (itm.whose_name.includes('other') && $("#other_applicant_name").val().trim().length == 0){ $("#other_applicant_holder").removeClass('x-hide'); mar.tip(".help-button","warning","You need to let us know the name of the other person who is associated with this other asset.","top"); return; } /** * validation block end */ let lastPart = function() { MAR.assets.set(itm.type, existingid, itm); mar.fakesave(); mvc.go("#assets-choice"); } if (enc_balance !== false) { if (mar.WE_ARE_FROM_LOI === false) { itm.balance = start_balance; } else { if (num(itm.balance) !== num(start_balance)) { // MAR.encompass.swal({ // msg : `This will override the encompass value if you choose to proceed....`, // cancel : "cancel", // cancelfn : function() { // // }, // ok : "overwrite", // okfn : function(){ // itm.__enc_balance = null; // lastPart(); // } // }); // return; } } } lastPart(); }),"cancel",frm.addfunction(function(){ mvc.go("#assets-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { var ar = checklist("whose_name"); if (ar.includes('99')){ $("#other_applicant_holder").removeClass('x-hide'); }else{ $("#other_applicant_holder").addClass('x-hide'); $("#other_applicant_name").val(''); } if (ar == "99") checklist("whose_name","0,99"); if (ar == "") checklist("whose_name","0"); $("#body-container").scrollTo("max",200); } let oc = function() { } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#body-container #otherdescription").autocomplete({ minLength:0, source: getOtherTypesAsArray(), max:5, scroll:true, appendTo: "#body-container .x_content", change: function(event, ui) { if (ui.item == null) { $("#otherdescription").val(""); $("#otherdescription").focus(); } } }).bind('focus', function(){ if (txt("#otherdescription").trim().length == 0) { $(this).autocomplete("search"); } }); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-summary"] = (function(){ var html = ""; function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } function checkNum(num){ var val = 0; if($.isNumeric( num )){ val = num } val = '$'+addCommas(Math.round(val)); return val; } function render(pg, localopts) { let VAL = ""; let h = ""; h += frm.htitle("Assets summary").render(); h += "
    "; h += frm.h2("Please review your stated assets for this real estate transaction.","").render(); h += "
    "; h += frm.summaryline("current job","Walgreens", { body : [ { key : "Monthly salary", val : "$4,500"}, { key : "Starting date", val : "03/04/2018"} ] }, false).render(); h += '
    '; h += "
    ADD ASSETS
    "; //h += "
    ADD
    " h += '
    '; try { getIncome_v2(); console.warn("mar.answers.v2.income: ", mar.answers.v2.income); console.warn("mar.answers.v2: ", mar.answers.v2); console.warn("mar.answers.v2.assets: ", mar.answers.v2.assets); console.warn("mar.answers.v2.assets.length: "+mar.answers.v2.assets.length); // for some reason it seems as if the actual assets are not getting into the [items] array of the particular item type. so this loop won't work // not to mention it is having an issue getting teh obj nodes uisng bracket syntax var size = Object.keys(mar.answers.v2.assets).length; console.warn("size: "+size); console.warn("size: ",size); for (let a=0; a < size; a++) { //console.warn("a"+a); //console.warn("mar.answers.v2.assets[a]", mar.answers.v2.assets[a]); var assets = mar.answers.v2.assets[a].items; if(assets){ //console.warn("ar.answers.v2.assets[a].items ", mar.answers.v2.assets[a].items); for (let i=0; i < assets.length; i++) { h += frm.summaryline("applicant "+a, assets[i].type, { body : [ { key : "Monthly salary", val : checkNum(assets[i].total)} ] }, false).render(); h += "
    "; } }else{ console.warn("no items ?"); } } //h += "
    " + JSON.stringify(mar.answers.v2.income,null,4)+"
    "; h += "
    "; } catch(E) { console.warn('error trying to draw asset list ', E); } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){mvc.go("#assets-choice"); }),"close",frm.addfunction(function(){mvc.go("#assets-choice");}),"mar.help()"); h = Mustache.render(h,localopts); let or = function(){ /* $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); */ // setTimeout(function(){ // $('#calendar').calendar({ // width : $(".x_content").width(), // height : $(".x_content").width(), // zIndex: 1, // weekArray: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // monthArray: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'], // data: null // }); // },500) } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["assets-bankOld"] = (function(){ //ok now update this one then copy over var VAL = 'N' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); //console.warn('INC: ',inc); let itm = (existingid) ? MAR.income.get(applicantnum,"checking",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ //console.warn('itm: ',itm); let h = ""; h += frm.htitle("Bank Account").render(); h += frm.elaine("How much money do you have in your {{account type}} account right now?","").render(); //h += "
    "; // JC - CW - elaine added div VAL = (itm) ? itm.balance : '40000'; h += frm.slider("balance","Total balance:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000', start_val : '40000' }).render(); h += frm.hr().render() VAL = ''; h += frm.txt("institution_name","{{account type}} institution name?",VAL,"e.g.Chase","",function(){}).render(); h += frm.hr().render() h += "
    In whose name is this account?
    Multiple answers are possible.
    "; VAL = (itm) ? itm.whose_name : ''; h += frm.radio("salary_choice","How would you want us to add up your salary?",VAL,"","",function(){ oc(); },{ hourly : "Hourly", weekly : "Weekly", biweekly : "Bi-Weekly", monthly : "Monthly", semimonthly : "Semi Monthly", yearly : "Yearly" }).render(); //h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ // do checks here mvc.go("#income-summary"+"."+applicantnum); //or just go straight to checking? }),"close",frm.addfunction(function(){ mvc.go("#income-summary"+"."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { //JC - need to check for less tahn two years operation. Refer to the doc for info on what to say. //JC - if more than 5 years, possible freddy mac //JC - check for declining income. IF so, use and elaine to let them know }; let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); /* $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false }); */ }; pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); /* file /ui/app/js/pages.personalinfo.js , last updated 1710259881503*/ mar.pg["scenario-personaldata"] = (function(){ var VAL = '' var html = ""; var checkForValues = false; function render(pg, localopts) { let h = ""; let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; let bucket = false; let refi = (getV2_data("loan_type","purchase") !== "purchase"); let createBucketIfNotThere = function() { if ("buckets" in mar.answers.v2 == false) { mar.answers.v2.buckets = {}; mar.fakesave(); } if ("bucketid" in mar.answers.v2.applicants[applicantnum] == false) { var uuid = mar.fmt.uuid() bucket = { bucketid : "/applicants/data/"+applicantnum+"/"+uuid, uuid : uuid, fn : "", ln : "", mn : "", sn : "", em : "", ph : "", db : "", ms : "", de : 0, age1 : 0, age2 : 0, age3 : 0, age4 : 0, age5 : 0, age6 : 0, ed : "", h1 : "", h2 : "", h2s1 : "", h2s1_txt : "", h3 : "", h31_txt : "", h3s1 : "", h3s1_txt : "", h3s2 : "", h3s2_txt : "", h4 : "" } mar.answers.v2.buckets[bucket.bucketid] = bucket; mar.answers.v2.applicants[applicantnum].bucketid = bucket.bucketid; } } createBucketIfNotThere(); var applicantNameObject = getApplicantsNames_v2(Number(applicantnum)); let names = applicantNameObject.Names let bucketid = mar.answers.v2.applicants[applicantnum].bucketid; bucket = mar.answers.v2.buckets[bucketid]; let has_visited = (MAR.getOpt(bucket, "ph", "").trim().length > 0) let revealclass = (has_visited) ? "" : "x-hide x-revealdiv"; // reveal .1 let hr = "
    ";//frm.hr().render(); let o_bucket = MAR.clone(bucket,{}); revealclass = ""; if (MAR.getOpt(bucket, "fn", "") === "") { bucket.fn = applicantNameObject.name; } if (MAR.getOpt(bucket,"em","") == "" && applicantnum == 0) { bucket.em = getParameterByName("email"); } if (typeof bucket.em !== "string") { bucket.em = ""; } if (MAR.getOpt(bucket,"ph","") == "" && applicantnum == 0) { bucket.ph = getParameterByName("tel"); } h += frm.htitle(names + " PERSONAL INFORMATION").render(); h += frm.elaine("Lets get acquainted, shall we?","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div VAL = bucket.fn; h += frm.txt("fn","First Name",VAL,"e.g. John or Jane","",function(){}).render(); VAL = MAR.getOpt(bucket, "mn", ""); h += frm.txt("mn","Middle Name",VAL,"","",function(){}).render().wrap("
    "+hr,"
    "); VAL = MAR.getOpt(bucket, "ln", ""); h += frm.txt("ln","Last Name (Include Jr. or Sr. if applicable)",VAL,"e.g. Smith","",function(){}).render().wrap("
    "+hr,"
    ");; VAL = MAR.getOpt(bucket, "em", ""); h += frm.txt("em","Email",VAL,"e.g. jane@gmail.com","",function(){}).render().wrap("
    "+hr,"
    ");; VAL = MAR.getOpt(bucket, "ph", ""); h += frm.txt("ph","Phone",VAL,"","",function(){}).render().wrap("
    "+hr,"
    ");; h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ // let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation == "fn" && txt("#fn").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your first name.","top"); if (validation == "ln" && txt("#ln").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your last name.","top"); if (validation == "em" && txt("#em").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your Email address.","top"); if (validation == "ph" && txt("#ph").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your phone number.","top"); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } createBucketIfNotThere(); let bucketid = mar.answers.v2.applicants[applicantnum].bucketid; bucket = mar.answers.v2.buckets[bucketid]; bucket.fn = txt("#fn"); bucket.mn = txt("#mn"); bucket.ln = txt("#ln"); bucket.em = txt("#em"); bucket.ph = txt("#ph"); if (bucket.fn == "") return mar.tip(".help-button","warning","You left your first name blank" ,"top"); if (bucket.ln == "") return mar.tip(".help-button","warning","You left your last name blank" ,"top"); if (bucket.em == "") return mar.tip(".help-button","warning","You left your email blank" ,"top"); if (bucket.ph == "") return mar.tip(".help-button","warning","You left your phone number blank" ,"top"); if (elaineui.isEmail(bucket.em) == false) return mar.tip(".help-button","warning","Your email is not in the correct format" ,"top"); setScenario_data(`__scenario_personaldata_${applicantnum}_passed`,"Y"); // mar.tip(".help-button","warning","You need to tell us if you have a realtor or not","top"); // return false; // $("#body-container").scrollTo("max",200); frm.buttons.hide(function(){ MAR.activity_log.mod("borrower", MAR.digits(bucket.sn)); mar.fakesave(function(){ (async function(){ if (mar.WE_ARE_FROM_LOI === true) { await MAR.encompass.waitSync(300); await MAR.encompass.app_check_diffs_borrower_profileSync(mar.ID, applicantnum); } mvc.go("#scenario-personaldata1."+applicantnum); })() }); }); }),"Back",frm.addfunction(function(){ if (applicantnum == 0) { if (num(mar.pg_as) < num(mar.pg_pd)) { mvc.go("#assets-choice"); } else { if (refi) { mvc.go("#scenario-property"); } else { mvc.go("#scenario-realtorinfo"); } } } else { mvc.go("#scenario-addresshistory."+(applicantnum-1)); } // mvc.go("#scenario-mortgageyes2"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(quick) { $("#body-container").scrollTo("max",200); } let prepopulate = function(fn) { /** * * if there are no linked accounts then return and just call the next function * */ if (MAR.assets.getLogins().length == 0) { /** * split up the first name of the last name is blank */ if (txt("#ln").trim() === "" && txt("#fn").trim().indexOf(" ") > -1) { let fname_split = txt("#fn").trim().split(" "); /* split it */ txt("#fn", fname_split.shift()); /* shift it */ txt("#ln", fname_split.join(" ")); /* join it */ } if (fn) fn(); return; } if (bucket.ln == "") { let _defaultaddress = false; $.get("/api/plaid/identity", function (da){ if (da && "identity" in da) { if ("names" in da.identity && da.identity.names.length > 0) { var _ns = da.identity.names[0].split(" "); if (_ns.length > 1) { txt("#ln",_ns[_ns.length-1]); } if (_ns.length > 2) { txt("#mn",_ns[_ns.length-2]); } } if ("emails" in da.identity && da.identity.emails.length > 0) { if (bucket.em === "") { txt("#em",da.identity.emails[0].data); } } if ("addresses" in da.identity && da.identity.addresses.length > 0) { for (let i=0; i < da.identity.addresses.length; i++) { if ("data" in da.identity.addresses[i]) { let _ad = da.identity.addresses[i].data; let _AD = ""; _AD += _ad.street; _AD += "|"; _AD += _ad.city; _AD += "|"; _AD += _ad.state; _AD += "|"; _AD += _ad.zip; _AD += "|"; //alert(_AD); let _ADID = MAR.addAddressBucket(_AD); if (_ADID != false && _defaultaddress == false) { _defaultaddress = _ADID; } } } if (_defaultaddress !== false) { setScenario_data("default_address_"+applicantnum,_defaultaddress); mar.fakesave(); //alert(_defaultaddress); } } } fn(); }); } else { fn(); } } let or = function(){ let sp = mar.isallowed_scenario("#scenario-realtor"); if (typeof sp === "string") { let sp_tag = `#scenario-personaldata.${applicantNum}`; let sp_exception = mvc.ispagein_encompass_allowed_list(`#scenario-personaldata.${applicantNum}`); if (sp_exception === false) { mvc.go(sp); return; } } if (getScenario_data(`__unpi_${applicantnum}_done`,"") !== "Y") { debugger; mvc.go("#up-next-personalinfonext."+applicantnum); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#ph").inputmask("(999) - 999 - 9999"); $("#body-container #fn").euiInputName(); $("#body-container #ln").euiInputName(); $("#body-container #mn").euiInputName(); $("#body-container #ph").euiInputTel(); $("#body-container #em").euiInputEmail(); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { prepopulate(function(){ oc(true); }) } }, quick : false, }); oc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "personalinfo" } })(); mar.ScrollBottom = function(fn) { $("#body-container").scrollTo("max",200); } mar.NOOP = function(fn){ if (fn) fn() } mar.pg["scenario-personaldata1"] = (function(){ var VAL = '' var html = ""; var checkForValues = false; function render(pg, localopts) { let h = ""; let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; let bucket = false; let ScrollBottom = (MAR.appnav.loanWasImportedAndNotVerified() == true) ? mar.NOOP : mar.ScrollBottom; if ("buckets" in mar.answers.v2 == false) { mar.answers.v2.buckets = {}; mar.fakesave(); } var applicantNameObject = getApplicantsNames_v2(Number(applicantnum)); let names = applicantNameObject.Names if ("bucketid" in mar.answers.v2.applicants[applicantnum] == false) { mvc.go("#scenario-personaldata"); return; } mar.reset = function(){ let bucketid = mar.answers.v2.applicants[applicantnum].bucketid; bucket = mar.answers.v2.buckets[bucketid]; bucket.db = ""; bucket.sn = ""; bucket.ed = ""; bucket.ty = ""; bucket.ms = ""; mvc.go("#scenario-personaldata1.0"); } let bucketid = mar.answers.v2.applicants[applicantnum].bucketid; bucket = mar.answers.v2.buckets[bucketid]; let has_visited = (MAR.getOpt(bucket,"ms","").trim().length > 0) let has_agreed = (getScenario_data(`applicant_${applicantNum}_has_agreed`,"N") === "Y"); let revealclass = (has_agreed && has_visited) ? "" : "x-hide x-revealdiv"; // reveal .1 let hr = "
    ";//frm.hr().render(); h += frm.htitle(names + " PERSONAL INFORMATION pt2").render(); h += frm.elaine("The information we are about to ask is used to soft pull your credit only. This will not hurt your credit in any way","er").render(); // JC - CW - elaine added "er" if (has_agreed) { h += "
    "; // JC - CW - elaine added div } else { h += "
    "; // JC - CW - elaine added div } VAL = MAR.getOpt(bucket,"db",""); h += frm.txt("db","Date of Birth",VAL,"","",function(){},"date").render(); VAL = MAR.getOpt(bucket,"sn",""); // h += frm.txt("sn","Social Security Number",VAL,"","",function(){}).render().wrap("
    "+hr,"
    "); h += frm.txt("sn","Social Security Number",VAL,"","",function(){}).render().wrap("
    "+hr,"
    "); h += ``; // VAL = ("ed" in bucket) ? bucket.ed : ""; // h += frm.radio("ed","Highest level of Education",VAL,"","",function(){ // oc(); // reveal(); // },{ // H : "High School", // C : "Bachelors", // M : "Masters", // P : "PhD" // }).render().wrap("
    "+hr,"
    ");; // VAL = ("ty" in bucket) ? bucket.ty : ""; // h += frm.radio("ty","What year did you last file your Personal Tax Returns 1040's?",VAL,"","",function(){ // //oc(); // },{ // "2015" : "2015", // "2016" : "2016", // "2017" : "2017", // "2018" : "2018" // }).render().wrap("
    "+hr,"
    ");; VAL = MAR.getOpt(bucket,"ms",""); if (VAL === "" && MAR.getApplicantsSpouse(applicantnum) !== false) { VAL = "M" } h += frm.radio("ms","Maritial Status",VAL,"","",function(){ let val = radio("ms"); if (val !== "" && MAR.getApplicantsSpouse(applicantnum) !== false && val !== "M") { mar.tip(".help-button","warning","You previously indicated that you are married, but that does not match the informaton you entered here.","top"); return; } oc(); reveal(); },{ M : "Married", U : "Unmarried", S : "Separated" }).render().wrap("
    "+hr,"
    ");; VAL = MAR.getOpt(bucket,"sr",""); h += frm.yn3("sr","Is there a person who is not your legal spouse but who currently has real property rights similar to those of a legal spouse?",VAL,"","",function(){ oc(); }, {}).render().wrap("

    ","
    "); VAL = MAR.getOpt(bucket,"dr",""); h += frm.radio("dr","Domestic Relationship Type",VAL,"","",function(){ oc(); },{ CivilUnion : "Civil Union", DomesticPartnership : "Domestic Partnership", Other : "Other", RegisteredReciprocalBeneficiaryRelationship : "Registered Reciprocal Beneficiary Relationship" }).render().wrap("

    ","
    "); VAL = MAR.getOpt(bucket,"dc",""); h += frm.txt("dc","Domestic Relationship Type",VAL,"","",function(){ oc(); }).render().wrap("
    ","
    "); VAL = ("de" in bucket && bucket.de) ? bucket.de : "0"; if (VAL === "0" && applicantnum > 0 && MAR.getApplicantsSpouse(applicantnum) !== false) { let bucketid0 = mar.answers.v2.applicants[0].bucketid; let bucket0 = mar.answers.v2.buckets[bucketid0]; VAL = bucket0.de; for (let i=1; i <= 6; i++) { let VAL0 = ("age"+i in bucket0 && bucket0["age"+i]) ? bucket0["age"+i] : "0"; bucket[`age${i}`] = VAL0; } } h += "
    " h += frm.slider("de","Dependents",VAL,"","",function(){ oc(); reveal(); }, { v00 : '0', v50 : '3', v50_inc : '1', v75 : '4', v75_inc : '4', v100 : '6', v100_inc : '1' }).render(); for (let i=1; i <= 6; i++) { VAL = ("age"+i in bucket && bucket["age"+i]) ? bucket["age"+i] : "0"; h += "
    " h += frm.slider("age"+i,"Age of dependent "+i,VAL,"","",function(){ }, { v00 : '0', v50 : '50', v50_inc : '1', v75 : '75', v75_inc : '1', v100 : '100', v100_inc : '1' }).render(); h += "
    "; } h += "
    "; // end reveal div let year_options = {} let current_tax_year = MAR.getCurrentYearForTax(); for (let y= (current_tax_year-3); y <= current_tax_year-1; y++) { year_options[y] = y; } VAL = ("ty" in bucket) ? bucket.ty : ""; h += frm.radio("ty","What year did you last file your Personal Tax Returns 1040's?",VAL,"","",function(){ //oc(); },year_options).render().wrap("
    "+hr,"
    ");; h += "
    "; // JC - CW - elaine - added end div /* end modal content */ let reveal = function() { let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation == "db" && txt("#db").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your date of birth.","top"); // if (validation == "ed" && radio("ed").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your level of education.","top"); if (validation == "ms" && radio("ms").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your maritial status.","top"); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); ScrollBottom() }); return; } } let CONTINUE = (has_agreed) ? "Continue" : "I Understand"; h += uihelpers.cbuttonbar(CONTINUE,frm.addfunction(function(){ if (has_agreed === false) { $(`button.dr-button.next-button`).html("Save & Go"); let $elm = $(".er"); oc(true); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); ScrollBottom() }); has_agreed = true; return; } // let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation == "db" && txt("#db").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your date of birth.","top"); // if (validation == "ed" && radio("ed").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your level of education.","top"); if (validation == "ms" && radio("ms").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your maritial status.","top"); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); ScrollBottom() }); return; } let bucketid = mar.answers.v2.applicants[applicantnum].bucketid; bucket = mar.answers.v2.buckets[bucketid]; bucket.db = txt("#db"); bucket.sn = $("#sn").data("value"); bucket.ed = txt("#ed"); //radio("ed"); bucket.ty = radio("ty"); bucket.ms = radio("ms"); bucket.sr = yn3("#sr"); bucket.dr = radio("dr"); bucket.de = txt("#de"); bucket.dc = txt("#dc"); bucket.age1 = txt("#age1"); bucket.age2 = txt("#age2"); bucket.age3 = txt("#age3"); bucket.age4 = txt("#age4"); bucket.age5 = txt("#age5"); bucket.age6 = txt("#age6"); let _social_security_number_checked = false; if (bucket.db.trim().length == 0) { mar.tip(".help-button","warning","You need to tell us your date of birth","top"); return false; } if (elaineui.date_is_older_18_years(bucket.db.trim()) === false) { mar.tip(".help-button","warning","You need to be older than 18 years","top"); return false; } // if (bucket.ed.trim().length == 0) { // mar.tip(".help-button","warning","You need to tell us your highest level of education","top"); // return false; // } if (bucket.ty.trim().length == 0) { mar.tip(".help-button","warning","You need to tell us the year you last filed your personal tax returns","top"); return false; } if (bucket.sn.trim().length == 0) { // mar.tip(".help-button","warning","You need to tell us your social security number","top"); // return false; } else { _social_security_number_checked = true; } var depNums = parseInt(bucket.de, 10); if (bucket.de.trim().length == 0) { bucket.de = depNums; } if (depNums > 0){ for (var i=1; i <= depNums; i++) { if (bucket['age'+i] == "") return mar.tip(".help-button","warning","You are missing an age of your dependent(s)" ,"top"); } } function final_fn(__fn) { setScenario_data(`applicant_${applicantNum}_has_agreed`,"Y"); setScenario_data(`__scenario_personaldata1_${applicantnum}_passed`,"Y"); frm.buttons.hide(function(){ MAR.activity_log.mod("borrower", MAR.digits(bucket.sn)); mar.fakesave( function(){ (async function(){ if (mar.WE_ARE_FROM_LOI === true) { await MAR.encompass.waitSync(100); await MAR.encompass.checkSync(); await MAR.encompass.app_check_diffs_borrower_profileSync(mar.ID, applicantnum); } if (typeof __fn === `function`) { __fn(); } mvc.go("#scenario-personaldata2."+applicantnum); })(); }); }); } if (_social_security_number_checked == false) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "You forgot to fill in your social security number." + "
    "+ "
    "; swal({ title : "Warning", className : "middleInfoPopup", content : s, buttons : { cancel : "I will correct it", call : { text: "I don't have it handy right now", value: "continue", closeModal: false } } }) .then((act) => { if (act == "continue") { setScenario_data(`__scenario_personaldata1_${applicantnum}_passed`,"Y"); frm.buttons.hide(function(){ mar.fakesave(function(){ mvc.go("#scenario-personaldata2."+applicantnum); }); }); swal.close(); } }) } else { let ssn_oval = $(`#sn`).data(`ovalue`); let ssn_val = bucket.sn; if (ssn_oval !== ssn_val) { // has credit been pulled // does it have an MISMO export // does it have an Encompass Number $.get(`/api/chatbot/change_ssn/${mar.ID}?from=${ssn_oval}&to=${ssn_val}`, function(rv){ if (rv.allowed === false) { alert(`ssn has changed and is not allowed ${rv.statusMsg}`); } if (rv.allowed === true) { alert(`ssn has changed and is allowed ${rv.statusMsg}`); if (rv.credit_wipe === `y`) { $.get(`/api/cpull/clear?appid=${mar.ID}`, function(da) { final_fn(function() { $.get(`/api/cpull/run?appid=${mar.ID}`, function(da) { }); }); }); } else { final_fn(); } } }); return; } final_fn(); } // mar.tip(".help-button","warning","You need to tell us if you have a realtor or not","top"); // return false; // $("#body-container").scrollTo("max",200); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-personaldata."+applicantnum); //mvc.go("#scenario-property"); // mvc.go("#scenario-mortgageyes2"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(quick) { let ms = radio("ms"); let sr = yn3("#sr"); let dr = radio("dr"); if (ms === "U") { $(".ms-followup-sr").removeClass("x-hide"); if (sr === "Y") { $(".ms-followup-dr").removeClass("x-hide"); if (dr === "Other") { $(".ms-followup-dc").removeClass("x-hide"); } else { $(".ms-followup-dc").addClass("x-hide"); } } else { radio("dr",""); $(".ms-followup-dr").addClass("x-hide"); $(".ms-followup-dc").addClass("x-hide"); } } else { yn3("sr","N"); radio("dr",""); $(".ms-followup-sr").addClass("x-hide"); $(".ms-followup-dr").addClass("x-hide"); $(".ms-followup-dc").addClass("x-hide"); } let de = parseInt(txt("#de"),10); for (let i=1; i <= 6; i++) { if (de >= i) { $(".age"+i).removeClass("x-hide"); } else { $(".age"+i).addClass("x-hide"); txt("#age"+i,"0"); $("#age"+i).change(); } } ScrollBottom() } let or = function(){ // let sp = mar.isallowed_scenario("#scenario-realtor"); // if (typeof sp === "string") { // mvc.go(sp); // return; // } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); //$("#sn").prop("type","password"); $("#sn").inputmask({ mask : "999 - 99 - 9999", definitions: { '9': { validator: "[0-9*]", casing: "lower" } } }); $("#sn").on("blur", function(){ let realval = $(this).val(); $(this).data("value",realval); // $(this).val("00000"+realval.split("-")[2]); $(this).val("*****"+realval.split("-")[2]); }) $("#sn").on("focus", function(){ let realval = $(this).data("value"); $(this).val(realval); }) $("#sn").prop("autocomplete","false"); let _realval = $("#sn").val(); $("#sn").data("value",_realval); $("#sn").data("ovalue",_realval); // $("#sn").val("00000"+_realval.split("-")[2]); $("#sn").val("*****"+_realval.split("-")[2]); if (has_agreed === true) { $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); ScrollBottom = mar.ScrollBottom; } }, quick : false, }); } else { // oc(); } } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "personalinfo" // menuitem : "scenario-personaldata" } })(); mar.pg["scenario-personaldata2"] = (function(){ var VAL = '' var html = ""; var checkForValues = false; function render(pg, localopts) { let h = ""; let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; let bucket = false; let ScrollBottom = (MAR.appnav.loanWasImportedAndNotVerified() == true) ? mar.NOOP : mar.ScrollBottom; mar.reset = function(){ bucket.h1 = ""; mvc.go("#scenario-personaldata2."+applicantnum) } if ("buckets" in mar.answers.v2 == false) { mar.answers.v2.buckets = {}; mar.fakesave(); } var applicantNameObject = getApplicantsNames_v2(Number(applicantnum)); let names = applicantNameObject.Names if ("bucketid" in mar.answers.v2.applicants[applicantnum] == false) { mvc.go("#scenario-personaldata"); return; } let bucketid = mar.answers.v2.applicants[applicantnum].bucketid; bucket = mar.answers.v2.buckets[bucketid]; let has_visited = false; if (MAR.getOpt(bucket, "h1", "").trim() === "Y") has_visited = true; let revealclass = (has_visited) ? "" : "x-hide x-revealdiv"; // reveal .1 let hr = "
    ";//frm.hr().render(); let HR = frm.hr("Shrunk").render(); h += frm.htitle(names + " HMDA disclosures").render(); h += frm.elaine("The purpose of this, is to make sure lenders don't discriminate based on race. We are happy to cooperate, are you?","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div VAL = MAR.getOpt(bucket, "h1", "Y"); if (VAL == "") VAL = "Y"; // default to Y h += frm.yn3("h1","I will cooporate with HMDA laws. ",VAL,"","",function(){ //revealTip('credit_has_judgements'); oc(); }, {}).render().wrap("
    ","
    "); h += ``; h += "
    "; /** * h4 */ h += (function(){ let h = ""; // h += ""; h += ""; h += frm.radio("h4","","","","",function(){ oc(); _continue(true); //oc(); },{ M : "Male", F : "Female" }).render(); return h; })().wrap("
    "+HR,"
    "); /** * h2 */ h += (function(){ let h = ""; h += frm.hr("Shrunk").render(); h += "
    "; // h += ""; h += ""; h += ""; h += frm.radio_option("h2","Hispanic or Latino","1","","",function(){ oc();_continue(true);}).render(); h += "
    "; h += frm.styled_checkbox("h2_secondary1","Mexican","mexican","","",function(){oc();_continue(true);}).render(); h += frm.styled_checkbox("h2_secondary1","Puerto Rican","puerto rican","","",function(){oc();_continue(true);}).render(); h += frm.styled_checkbox("h2_secondary1","Cuban","cuban","","",function(){oc();_continue(true);}).render(); h += "
    " h += frm.styled_checkbox("h2_secondary1","other_hispanic","Other Hispanic","","",function(){oc();_continue(true);}).render(); h += frm.txt("choice_hispanic_other","","","e.g. Peruvian","",function(){oc();_continue(true);}).render(); h += "
    "; h += "
    "; h += frm.radio_option("h2","Not Hispanic or Latino","2","","",function(){oc();_continue(true);}).render(); h += frm.radio_option("h2","Not Applicable","3","","",function(){oc();_continue(true);}).render(); h += frm.radio_option("h2","I don't wish to furnish this information","0","","",function(){oc();_continue(true);}).render(); return h; })().wrap("
    "+hr,"
    "); /** * h3 */ h += (function(){ let h = ""; h += frm.hr("Shrunk").render(); h += ""; h += frm.radio_option("h3","American Indian or Alaska Native","1","","",function(){ oc();}).render(); h += "
    "; h += '
    Enter name of enrolled or principal tribe:
    '; h += frm.txt("choice_native_indian_other","","","ex. Sioux","",function(){oc();}).render(); h += "
    "; h += frm.radio_option("h3","Asian","2","","",function(){ oc();}).render(); // START h += "
    "; h += frm.styled_checkbox("h3_secondary1","Asian Indian","asian indian","","",function(){oc();}).render(); h += frm.styled_checkbox("h3_secondary1","Chinese","chinese","","",function(){oc();}).render(); h += frm.styled_checkbox("h3_secondary1","Filipino","filipino","","",function(){oc();}).render(); h += frm.styled_checkbox("h3_secondary1","Japanese","japanese","","",function(){oc();}).render(); h += frm.styled_checkbox("h3_secondary1","Korean","korean","","",function(){oc();}).render(); h += frm.styled_checkbox("h3_secondary1","Vietnamese","vietnamese","","",function(){oc();}).render(); h += "
    " h += frm.styled_checkbox("h3_secondary1","Other Asian - Enter race:","Other Asian","","",function(){oc();}).render(); h += frm.txt("choice_other_asian","","","e.g. Peruvian","",function(){oc();}).render(); h += "
    "; h += "
    "; // END h += ""; h += frm.radio_option("h3","Black of African American","3","","",function(){ oc();}).render(); h += frm.radio_option("h3","Native Hawaiian or Other Pacific Islander","4","","",function(){ oc();}).render(); // START h += "
    "; h += frm.styled_checkbox("h3_secondary2","Native hawaiian","native hawaiian","","",function(){oc();}).render(); h += frm.styled_checkbox("h3_secondary2","Samoan","samoan","","",function(){oc();}).render(); h += frm.styled_checkbox("h3_secondary2","Guamanian or chorro","guamanian or chorro","","",function(){oc();}).render(); h += "
    " h += frm.styled_checkbox("h3_secondary2","Other Pacific Islander - Enter race:","Other Pacific Islander","","",function(){oc();}).render(); h += frm.txt("choice_pacific_other","","","e.g. Fijian","",function(){oc();}).render(); h += "
    "; h += "
    "; // END h += frm.radio_option("h3","White","5","","",function(){ oc();}).render(); h += frm.radio_option("h3","I don't wish to furnish this information","0","","",function(){ oc();}).render(); // h += frm.radio_option("h3","Not Applicable","6","","",function(){ oc();}).render(); return h; })().wrap("
    "+hr,"
    "); h += "
    "; // JC - CW - elaine - added end div h += "
    "; // JC - CW - elaine - added end div /* end modal content */ let _continue = function(_from){ // empty if (yn3("#h1") == "") { return mar.tip(".help-button","warning","You need to tell us whether you will or will not fill in the HMDA questions.","top"); } // will not fill in questions if (yn3("#h1") == "N") { // this is a skip let bucketid = mar.answers.v2.applicants[applicantnum].bucketid; bucket = mar.answers.v2.buckets[bucketid]; bucket.h1 = yn3("#h1"); bucket.h2 = ""; bucket.h2s1 = ""; bucket.h2s1t = ""; bucket.h3 = ""; bucket.h3a = ""; bucket.h3s1 = ""; bucket.h3s1t = ""; bucket.h3s2 = ""; bucket.h3s2t = ""; bucket.h4 = ""; setScenario_data(`__scenario_personaldata2_${applicantnum}_passed`,"Y"); frm.buttons.hide(function(){ mar.fakesave(function(){ (async function(){ if (mar.WE_ARE_FROM_LOI === true) { await MAR.encompass.waitSync(100); await MAR.encompass.app_check_diffs_borrower_profileSync(mar.ID, applicantnum); } mvc.go("#scenario-addresshistory."+applicantnum+""); })() }); }); // mvc.go("#sd.applicants.address."+applicantnum+".sup-data.address-history"); return; } // will fill questions let bucketid = mar.answers.v2.applicants[applicantnum].bucketid; bucket = mar.answers.v2.buckets[bucketid]; bucket.h1 = yn3("#h1"); bucket.h2 = radio("h2"); bucket.h2s1 = radio("h2_secondary1"); bucket.h2s1t = txt("#choice_hispanic_other"); bucket.h3 = radio("h3"); bucket.h3a = txt("#choice_native_indian_other"); bucket.h3s1 = radio("h3_secondary1"); bucket.h3s1t = txt("#choice_other_asian"); bucket.h3s2 = radio("h3_secondary2"); bucket.h3s2t = txt("#choice_pacific_other"); bucket.h4 = radio("h4"); if (typeof bucket.h2s1 === "undefined") bucket.h2s1 = ""; if (typeof bucket.h3s1 === "undefined") bucket.h3s1 = ""; if (typeof bucket.h3s2 === "undefined") bucket.h3s2 = ""; let verify_h4 = function() { if (bucket.h4 === "") return (_from) ? false : mar.tip(".help-button","warning","You need to complete the sex question.","top"); return true; } let verify_h2 = function() { if (bucket.h2 === "") return (_from) ? false : mar.tip(".help-button","warning","You need to complete the ethnicity question.","top"); if (bucket.h2 === "1" && bucket.h2s1 === "") { return (_from) ? false : mar.tip(".help-button","warning","You need to complete the ethnicity followup.","top"); } if (bucket.h2 === "1" && bucket.h2s1.toLowerCase().indexOf("other") > -1 && bucket.h2s1t.trim().length == 0) { return (_from) ? false : mar.tip(".help-button","warning","You need to complete the ethnicity other followup.","top"); } return true; } let verify_h3 = function() { if (bucket.h3 === "") return (_from) ? false : mar.tip(".help-button","warning","You need to complete the race question.","top"); if (bucket.h3 === "1" && bucket.h3a === "") { return (_from) ? false : mar.tip(".help-button","warning","You need to complete the race followup.","top"); } if (bucket.h3 === "2" && bucket.h3s1 === "") { return (_from) ? false : mar.tip(".help-button","warning","You need to complete the race followup.","top"); } if (bucket.h3 === "2" && bucket.h3s1.toLowerCase().indexOf("other") > -1 && bucket.h3s1t.trim().length == 0) { return (_from) ? false : mar.tip(".help-button","warning","You need to complete the race followup followup.","top"); } if (bucket.h3 === "4" && bucket.h3s2 === "") { return (_from) ? false : mar.tip(".help-button","warning","You need to complete the race followup.","top"); } if (bucket.h3 === "4" && bucket.h3s2.toLowerCase().indexOf("other") > -1 && bucket.h3s2t.trim().length == 0) { return (_from) ? false : mar.tip(".help-button","warning","You need to complete the race followup followup.","top"); } return true; } let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation == "h4"){ if (verify_h4() !== true) return } if (validation == "h2"){ if (verify_h2() !== true) return } if (validation == "h3") { if (verify_h3() !== true) return } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); ScrollBottom(); }); return; } if (verify_h4() !== true) return; if (verify_h2() !== true) return; if (verify_h3() !== true) return; if (typeof __ROLE !== 'undefined' && __ROLE == "cl" && Number(applicantnum) == 0) { bucket.verified_by_borrower = "Y"; } if (typeof __ROLE !== 'undefined' && __ROLE == "c2" && Number(applicantnum) == 1) { bucket.verified_by_borrower = "Y"; } if (typeof __ROLE !== 'undefined' && __ROLE == "c3" && Number(applicantnum) == 2) { bucket.verified_by_borrower = "Y"; } setScenario_data(`__scenario_personaldata2_${applicantnum}_passed`,"Y"); frm.buttons.hide(function(){ mar.fakesave(function(){ (async function(){ if (mar.WE_ARE_FROM_LOI === true) { await MAR.encompass.waitSync(100); await MAR.encompass.app_check_diffs_borrower_profileSync(mar.ID, applicantnum); } if (_from) { frm.buttons.show(); } else { mvc.go("#scenario-addresshistory."+applicantnum+""); } })() }); }); // mvc.go("#sd.applicants.address."+applicantnum+".sup-data.address-history"); // bucket.db = txt("#db"); // bucket.sn = txt("#sn"); // bucket.de = radio("de"); // mar.tip(".help-button","warning","You need to tell us if you have a realtor or not","top"); // return false; // $("#body-container").scrollTo("max",200); } h += "
    "; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ _continue(); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-personaldata1."+applicantnum); //mvc.go("#scenario-property"); // mvc.go("#scenario-mortgageyes2"); }),"mar.help()"); h = Mustache.render(h,localopts); let complete = false; let oc = function(quick) { let h1 = yn3("#h1"); let h2 = radio("h2"); let h2s1 = radio("h2_secondary1"); let h2s1t = txt("#choice_hispanic_other"); let h3 = radio("h3"); let h3a = txt("#choice_native_indian_other"); let h3s1 = radio("h3_secondary1"); let h3s1t = txt("#choice_other_asian"); let h3s2 = radio("h3_secondary2"); let h3s2t = txt("#choice_pacific_other"); let h4 = radio("h4"); if (h1 !== "Y") { $(".hmda_questions").addClass("x-hide") } else { $(".hmda_questions").removeClass("x-hide") if ($("#h4_div.x-revealdiv").length > 0) { let $elm = $("#h4_div.x-revealdiv"); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); ScrollBottom(); // $("#body-container").scrollTo("max",200); }); } h += ""; h += frm.radio_option("h2","Hispanic or Latino","1","","",function(){ oc();}).render(); h += "
    "; h += frm.styled_checkbox("h2_secondary1","Mexican","mexican","","",function(){oc();}).render(); $.fn.euShowAndScroll = function(params){ return this.each(function() { if ($(this).hasClass("x-hide")) { $(this).removeClass("x-hide"); ScrollBottom(); // $("#body-container").scrollTo("max",200); } }); } /** * switch on and off the hispanic types */ if (h2 && h2 == "1") { $(".hispanicTypes").css({ opacity : 1.0 }).euShowAndScroll(); $(".hispanicTypes .styled-checkbox").each(function () { $(this).prop("disabled",false); }); if (h2s1 == "Other Hispanic") { $("#choice_hispanic_other").prop("disabled",false); } else { $("#choice_hispanic_other").prop("disabled",true).val(""); } } else { $(".hispanicTypes").css({ opacity : 0.5 }).addClass("x-hide"); $(".hispanicTypes .styled-checkbox").each(function () { $(this).prop('checked', false).prop("disabled",true); }); $("#choice_hispanic_other").prop("disabled",true).val(""); } /** * switch on and off the hispanic types */ if (h3 && h3 == "1") { $("#choice_native_indian_other").prop("disabled",false); $("#choice_native_indian_other_type").euShowAndScroll("x-hide"); } else { $("#choice_native_indian_other").prop("disabled",true); $("#choice_native_indian_other_type").addClass("x-hide"); } if (h3 && h3 == "2") { $(".asianTypes").css({ opacity : 1.0 }).euShowAndScroll("x-hide"); $(".asianTypes .styled-checkbox").each(function () { $(this).prop("disabled",false); }); if (h3s1 == "Other Asian") { $("#choice_other_asian").prop("disabled",false); } else { $("#choice_other_asian").prop("disabled",true).val(""); } } else if (h3 && h3 == "4") { $(".pacificTypes").css({ opacity : 1.0 }).euShowAndScroll("x-hide"); $(".pacificTypes .styled-checkbox").each(function () { $(this).prop("disabled",false); }); if (h3s2 == "Other Pacific Islander") { $("#choice_pacific_other").prop("disabled",false); } else { $("#choice_pacific_other").prop("disabled",true).val(""); } } else { $(".asianTypes").css({ opacity : 0.5 }).addClass("x-hide"); $(".asianTypes .styled-checkbox").each(function () { $(this).prop('checked', false).prop("disabled",true); }); $("#choice_other_asian").prop("disabled",true).val(""); $(".pacificTypes").css({ opacity : 0.5 }).addClass("x-hide"); $(".pacificTypes .styled-checkbox").each(function () { $(this).prop('checked', false).prop("disabled",true); }); $("#choice_pacific_other").prop("disabled",true).val(""); } } // $("#body-container").scrollTo("max",200); } let or = function(){ // let sp = mar.isallowed_scenario("#scenario-realtor"); // if (typeof sp === "string") { // mvc.go(sp); // return; // } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $(".info-h1").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("HDMA LEGAL INFO").render()+ "
    "+ "

    The following information is requested by the Federal Government for certain types of loans related to a dwelling " + "in order to monitor the lenders compliance with equal credit opportunity, fair housing and home mortgage disclosure laws."+ "

    "+ "

    "+ "You are not required to furnish this information, but are encouraged to do so. The law provides that a lender may " + "not discriminate either on the basis of this information, or on whether you choose to furnish it."+ "

    "+ "

    "+ "If you furnish the information, please provide both ethnicity and race. For race, you may check more than one designation. " + "If you do not furnish ethnicity, race, or sex, under Federal regulations, this lender is required to note the information on " + "the basis of visual observation and surname if you have made this application in person."+ "

    "+ "

    "+ "If you do not wish to furnish the information, please check the box below. (Lender must review the above material to " + "assure that the disclosures satisfy all requirements to which the lender is subject under applicable state law for " + "the particular type of loan applied for.)"+ "

    "; "It's worth noting that court-ordered judgements usually must be paid off before you are able to get a mortgage. "+ "If you're on a payment plan, we have to use the payment to calculate your maximum mortgage amount."; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Got it" } }); }); $(".info-h1").css('cursor', 'pointer'); if (bucket.h1 == "Y") { yn3("#h1", "Y"); radio("h2", MAR.getOpt(bucket,"h2" ,"")); radio("h2_secondary1", MAR.getOpt(bucket,"h2s1" ,"")); txt("#choice_hispanic_other", MAR.getOpt(bucket,"h2s1t" ,"")); radio("h3", MAR.getOpt(bucket,"h3" ,"")); txt("#choice_native_indian_other", MAR.getOpt(bucket,"h3a" ,"")); radio("h3_secondary1", MAR.getOpt(bucket,"h3s1" ,"")); txt("#choice_other_asian", MAR.getOpt(bucket,"h3s1t" ,"")); radio("h3_secondary2", MAR.getOpt(bucket,"h3s2" ,"")); txt("#choice_pacific_other", MAR.getOpt(bucket,"h3s2t" ,"")); radio("h4", MAR.getOpt(bucket,"h4" ,"")); if (radio("h2") === "") $("#h2_div").addClass("x-hide").addClass("x-revealdiv") if (radio("h3") === "") $("#h3_div").addClass("x-hide").addClass("x-revealdiv") if (radio("h4") === "") $("#h4_div").addClass("x-hide").addClass("x-revealdiv") } $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); ScrollBottom = mar.ScrollBottom; } }, quick : false, }); oc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "personalinfo" } })(); mar.pg["scenario-addresshistory"] = (function(){ var VAL = '' var html = ""; var checkForValues = false; function render(pg, localopts) { let h = ""; let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; let bucket = false; let bbar = false; let redirect = false; let done = false; let list = (p3 == "list"); // alert(`p3 ${p3} p4 ${p4}`) /** * create empty address array if necessary */ if ("addresses" in mar.answers.v2.applicants[applicantnum] == false) { mar.answers.v2.applicants[applicantnum].addresses = []; } if (mar.answers.v2.applicants[applicantnum].addresses.length == 0) { // we need to enter the 1st address then } if ("buckets" in mar.answers.v2 == false) { mar.answers.v2.buckets = {}; mar.fakesave(); } var applicantNameObject = getApplicantsNames_v2(Number(applicantnum)); var items = mar.answers.v2.applicants[Number(applicantnum)].addresses; //items = []; mar.clear = function() { mar.answers.v2.applicants[Number(applicantnum)].addresses = []; mar.dontsave = true; mvc.go("#scenario-addresshistory."+applicantnum); } var type = false; if (items == 0) { type = "current"; } /** * LETS CHECK IF WE HAVE ALL THE INFORMATION */ let totalmonths = 0; let appears_on_tax_returns = 0; let appears_on_drivers_license = 0; let incomplete_pages = []; let incomplete_pages_because_data = []; let b0 = false; (function() { for (var i=0; i < items.length; i++) { var bucketid = items[i]; if (bucketid in mar.answers.v2.buckets) { var bucket = mar.answers.v2.buckets[bucketid]; var uuid = bucket.uuid; var address = bucket.address; if (typeof address === "undefined") { incomplete_pages_because_data.push([i,type]); continue; } var type = bucket.type; if (typeof type === "undefined") { incomplete_pages_because_data.push([i,type]); continue; } var years = bucket.years; if (typeof years === "undefined") { incomplete_pages_because_data.push([i,type]); continue; } var months = bucket.months; if (typeof months === "undefined") { incomplete_pages_because_data.push([i,type]); continue; } var use = bucket.use; if (typeof use === "undefined") { incomplete_pages_because_data.push([i,type]); continue; } if (bucket.appears_on_tax_returns == "Y") appears_on_tax_returns = 1; if (bucket.appears_on_drivers_license == "Y") appears_on_drivers_license = 1; if (i == 0) { b0 = bucket; } if (i == 0 && MAR.getOpt(bucket,"appears_on_tax_returns","") === "") { incomplete_pages.push([i,type]); } else if (i == 0 && MAR.getOpt(bucket,"appears_on_drivers_license","") === "") { incomplete_pages.push([i,type]); } totalmonths += (parseInt(years,10)*12)+parseInt(months); } } if (appears_on_tax_returns > 0 && appears_on_drivers_license > 0) { if (MAR.getOpt(b0,"appears_on_tax_returns","") === "") b0.appears_on_tax_returns = "N"; if (MAR.getOpt(b0,"appears_on_drivers_license","") === "") b0.appears_on_drivers_license = "N"; incomplete_pages = []; } while (incomplete_pages_because_data.length > 0) { incomplete_pages.push(incomplete_pages_because_data.pop()); } })(); let swaltext = ""; if (incomplete_pages.length > 0) { incomplete_pg = incomplete_pages.shift(); existingid = incomplete_pg[0]; type = incomplete_pg[1]; list = false; } else if (items.length > 0 && totalmonths < 24) { type = "previous"; swaltext = "In total we need 24 months of address history and so far the address(es) you entered only " + "cover "+totalmonths+" months. We ask you to fill in your previous address on this page. Or press [back] to correct your previous entry."; } else if (items.length > 0 && appears_on_tax_returns == 0) { type = "tax"; swaltext = "Great job - you have covered 24 months of address history but unfortunately you indicated " + "that none of the addresses appear on your tax filings. " + "Can you enter the address where you last filed your tax please. Or press [back] to correct your previous entry."; } else if (items.length > 0) { type = "done"; if (MAR.applicationNav.hasEnteredIncome() == true) type = "list"; /* go to list if later in the app */ if (getScenario_data(`__scenario_addresshistory_${applicantnum}_passed`,"") === "Y") type = "list"; /* go to list if if we already forwarded because of a done*/ if (type === "done") { done = true; type = "list"; } } //type = "current"; let originaltype = type; if (existingid !== false) type = "edit"; if (list) type = "list"; // h += "TYPE : " + type; let add_varient = type; let names = applicantNameObject.Names var title = "Current Address"; var TXT = names +" Current Address"; var current_prior = "current"; var elainetext = "Lets talk about your address history, so we can prepare for third party verifications. For example, with the IRS."; var howlongtext = "How long have you lived at this address?"; var DIDYOUOWNORRENT = "Did you own or rent?" let setPageTitles = function(add_varient) { if (add_varient == "current") { TXT = names +" Current Address"; elainetext = "Lets talk about your current address, so we can prepare for third party verifications. For example, with the IRS."; current_prior = "current"; howlongtext = "How long have you lived at your current address?"; DIDYOUOWNORRENT = "Do you own or rent?" } else if (add_varient == "previous " || add_varient == "former") { TXT = names +" Previous Address"; elainetext = "We need two years of address history, sorry!"; current_prior = "prior"; howlongtext = "How long did you live at your previous address?"; } else if (add_varient == "tax") { howlongtext = "How long did you live at this address?"; TXT = names + " Address where you filed taxes"; elainetext = "We need to gather an address that was used on your last tax returns. Please can you enter the address exactly as it appeared in your last tax returns."; current_prior = "prior"; } else if (add_varient == "done") { TXT = names + " Address History"; elainetext = "Great job , you have completed the address history, click continue with the application."; current_prior = ""; } else if (add_varient == "list") { TXT = names + " Address History"; elainetext = "Great job , you have completed the address history, You can edit any of the addresses you entered by clicking them."; current_prior = ""; } else { TXT = names + " Previous Address"; elainetext = "Please enter an address as accuratly as possible."; elainetext = "Since you live less than two years on your current address, please complete the address history."; current_prior = "prior"; howlongtext = "How long did you live at your previous address?"; swaltext = ""; } } if (add_varient === "edit" && (originaltype === "current" || originaltype === "previous" || originaltype === "former" || originaltype === "tax")) { setPageTitles(originaltype); } else { setPageTitles(add_varient); } let address_block = function(bucket, applicantnum, _I) { var years = bucket.years; var months = bucket.months; totalmonths += (parseInt(years,10)*12)+parseInt(months); let _address = sup_data.addressformatShort(bucket.address); var summary = `
    ${bucket.years} y ${bucket.months} m
    `; var extra = ""; if (bucket.type == "current") { extra += "Current address"; } else { extra += "Previous address" } if ( bucket.appears_on_tax_returns === "Y") { extra += "
    Appears on tax returns
    " } if (bucket.use == "rent") { extra += `
    Rent ${bucket.rent}/m
    ` } else if (bucket.use == "own") { extra += `
    Owned
    ` } else { extra += `
    Rent free
    ` } summary += extra; let triangle = `` let logo = ` `; let verified = true; let verified2 = true; let _logo = (verified && verified2) ? logo : triangle; var _block = ""; _block += `
    ${_address}
    `; _block += `
    ${summary}
    `; var btn = sprintf("
    ",`#scenario-addresshistory.${applicantnum}`,`.${i}`); let __lnk = `mvc.go('#scenario-addresshistory.${applicantnum}.${_I}')`; let __owner = ""; let __dellnk = ""; let rv = `
    ${_block}
    `; return rv; } /** * create the list */ if (type == false || list == true || type == "list") { h += frm.htitle(TXT).render(); //h += frm.elaine("Please enter an address as accuratly as possible.","er").render(); h += frm.elaine(elainetext,"er").render(); h += "
    "; // JC - CW - elaine added div h += (function() { let h = ""; for (var i=0; i < items.length; i++) { var bucketid = items[i]; if (bucketid in mar.answers.v2.buckets) { var bucket = mar.answers.v2.buckets[bucketid]; // h += "
      "; // h += "
    • " + bucket.address; // h += "
    • " + bucket.type; // h += "
    • " + bucket.years; // h += "
    • " + bucket.months; // h += "
    • " + bucket.appears_on_tax_returns; // h += "
    • " + bucket.appears_on_drivers_license; var years = bucket.years; var months = bucket.months; totalmonths += (parseInt(years,10)*12)+parseInt(months); // h += "
    • " + totalmonths; // h += "
    "; var name = sup_data.addressformatShort(bucket.address); var summary = sprintf("
    %s y %s m
    ",bucket.years,bucket.months); var extra = ""; if (bucket.type == "current") { extra += "Current address"; } else { extra += "Previous address" } if ( bucket.appears_on_tax_returns === "Y") { extra += "
    Appears on tax returns
    " } if (bucket.use == "rent") { extra += `
    Rent ${bucket.rent}/m
    ` } else if (bucket.use == "own") { extra += `
    Owned
    ` } else { extra += `
    Rent free
    ` } summary += extra; var btn = sprintf("
    ",`#scenario-addresshistory.${applicantnum}`,`.${i}`); //h += sprintf("
    %s
    %s
    %s
    ",btn,name,summary); h += address_block(bucket,applicantnum,i); } } return h; })(); h += "
    " if (done) { setScenario_data(`__scenario_addresshistory_${applicantnum}_passed`,"Y"); if ((mar.answers.v2.applicants.length - applicantnum) == 1 ) { redirect = ("#up-next-assets"); } else { redirect = ("#scenario-personaldata."+(applicantnum+1)); } } } else if (type == "done") { setScenario_data(`__scenario_addresshistory_${applicantnum}_passed`,"Y"); if ((mar.answers.v2.applicants.length - applicantnum) == 1 ) { redirect = ("#up-next-assets"); } else { redirect = ("#scenario-personaldata."+(applicantnum+1)); } // bbar = true; // h += frm.elaine(elainetext,"er").render(); // h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ // if ((mar.answers.v2.applicants.length - applicantnum) == 1 ) { // mvc.go("#up-next-income"); // } else { // mvc.go("#scenario-personaldata."+(applicantnum+1)); // } // // }),"Back",frm.addfunction(function(){ // mvc.go("#scenario-personaldata2."+applicantnum); // }),"mar.help()"); } else { let revealclass = (existingid !== false) ? "" : "x-hide x-revealdiv"; // reveal .1 let hr = "
    ";//frm.hr().render(); let is_editing = false; if (existingid !== false) { let bucketid = items[existingid]; if (bucketid in mar.answers.v2.buckets) { bucket = mar.answers.v2.buckets[bucketid]; type = bucket.type is_editing = true; setPageTitles(type); } } else { var uuid = mar.fmt.uuid() bucket = { bucketid : "/applicants/address/"+applicantnum+"/"+uuid, uuid : uuid, address : "", type : "", use : "", years : 0, months : 0, appears_on_tax_returns : "", appears_on_drivers_license : "", reason_dl_different : "" } } (function try_and_guesse_some_values(){ if (add_varient == "current") { if (applicantnum === 0) { // first applicant , current address let refi = (getV2_data("loan_type","purchase") !== "purchase"); let refi_primary = (getScenario_data("occupancy_type","") === "occupancy_by_me"); let owns_property = (getScenario_data("has_applicant1_owned_property_in_last_3_years","") === "Y"); let owns_property_how = getScenario_data("has_applicant1_owned_property_in_last_3_years_how",""); //01 - sole , 25 - with spouse, 26 with other let owns_property_type = getScenario_data("has_applicant1_owned_property_in_last_3_years_type",""); // 1 - primary 2 = secondary 3 = investment let property_type = getScenario_data("property_type",""); let refi_current_debt = getScenario_data("refi_current_debt",""); let refi_current_value = getScenario_data("refi_current_value",""); let refi_liquid_assets = getScenario_data("refi_liquid_assets",""); let sp = MAR.reo.getSubjectProperty(); refi_primary = (owns_property_type === "1") if (refi && refi_primary) { // refi , first applicant -- this must be the subject property then! if (MAR.getOpt(bucket, "years",0) === 0 && MAR.getOpt(bucket, "months",0) === 0) { let pdate = MAR.getOpt(sp, "data.purchasedate",""); if (pdate !== "") { let pdatem = moment(new Date(pdate)); let y = moment().diff(pdatem, "year") let m = moment().diff(pdatem, "month") % 12; bucket.years = y; bucket.months = m; } } if (MAR.getOpt(bucket, "use","") === "") bucket.use = "own"; if (MAR.getOpt(bucket, "address","") === "") { if (sp !== false) bucket.address = MAR.getOpt(sp, "data.address",""); } } } else if (applicantnum > 0) { // first applicant , current address if (MAR.getApplicantsSpouse(applicantnum) === 0) { let bucket0 = MAR.getOpt(MAR.getApplicantAddressCurrent(0), "0", false); MAR.ifOpt(bucket0, "years", function(v){ bucket.years = v; }); MAR.ifOpt(bucket0, "address", function(v){ bucket.address = v; }); MAR.ifOpt(bucket0, "use", function(v){ bucket.use = v; }); MAR.ifOpt(bucket0, "months", function(v){ bucket.months = v; }); MAR.ifOpt(bucket0, "rent", function(v){ bucket.rent = v; }); MAR.ifOpt(bucket0, "rentwillcontinue", function(v){ bucket.rentwillcontinue = v; }); } } } })(); h += frm.htitle(TXT).render(); //h += frm.elaine("Please enter an address as accuratly as possible.","er").render(); h += frm.elaine(elainetext,"er").render(); h += "
    "; // JC - CW - elaine added div h += (function(){ let h = ""; // jc here // get subject property purchase date and work back h += "
    "+howlongtext+"
    "; h += "
    "; VAL = bucket.years; h += frm.slider("years","Years:",VAL,"","",function(){ }, { v00 : '0', v50 : '8', v50_inc : '1', v75 : '45', v75_inc : '1', v100 : '60', v100_inc : '1', start_val : '2', formatting_class : '_years' }).render(); h += "
    "; h += "
    "; VAL = bucket.months; h += frm.slider("months","Months:",VAL,"","",function(){ }, { v00 : '0', v50 : '6', v50_inc : '1', v75 : '9', v75_inc : '1', v100 : '11', v100_inc : '1', start_val : '0', formatting_class : '_months' }).render(); h += "
    "; return h; })() VAL = bucket.use; if (VAL == "" && MAR.getApplicantDoesOwnRealestate(applicantnum) == true) VAL = "own"; h += frm.radio("use",DIDYOUOWNORRENT,VAL,"","",function(){ let ru = radio("use"); if (radio("use") == "rent") { if ($("#rent_div").length > 0) { $("#rent_div").prop("class",revealclass) $("#rentwillcontinue_div").prop("class",revealclass); $("#address_div").data("validation","rentwillcontinue"); // $("#rent_div").addClass("x-revealdiv") // $("#rentwillcontinue_div").addClass("x-revealdiv") } } else { if ($("#rent_div").length > 0) { $("#rent_div").addClass("x-hide") $("#rentwillcontinue_div").addClass("x-hide") $("#rent_div").removeClass("x-revealdiv") $("#rentwillcontinue_div").removeClass("x-revealdiv") $("#address_div").data("validation","use"); } } if (add_varient == "current") { if (radio("use") !== "") { if (MAR.applicants.scenario_owns_primary(false,applicantnum) === true && radio("use") !== "own" ) { elaineui.swalprompt({ title : "", txt : "Are you sure you are renting? You said before that you owned real estate.", ok : "YES", cancel : "NO", cancelfn : function(a){ radio("use","own"); if ($("#rent_div").length > 0) { $("#rent_div").addClass("x-hide") $("#rentwillcontinue_div").addClass("x-hide") $("#rent_div").removeClass("x-revealdiv") $("#rentwillcontinue_div").removeClass("x-revealdiv") $("#address_div").data("validation","use"); } } }) } } } //oc(); },{ "own" : "Owned", "rent" : "Rented", "free" : "Living rent free" }).render().wrap("
    "+hr,"
    ");; if (type == "current") { let hide_this_div = (VAL !== "rent") ? "x-hide" : "" VAL = ("rent" in bucket) ? bucket.rent : 0; h += frm.slider("rent","How much rent do you pay:",VAL,"","",function(){ }, { v00 : '0', v50 : '1000', v50_inc : '50', v75 : '2000', v75_inc : '50', v100 : '5000', v100_inc : '100', start_val : '0' }).render().wrap(`
    ${hr}`,`
    `); VAL = ("rentwillcontinue" in bucket) ? bucket.rentwillcontinue : ""; h += frm.yn3("rentwillcontinue","Will you continue to rent?",VAL,"","",function(){ //revealTip('credit_has_judgements'); oc(); }, {}).render().wrap(`
    ${hr}`,`
    `); } h += (function(){ let h = ""; if (is_editing) { VAL = bucket.address; // header - what is the address h += `
    What is the address?
    `; h += frm.address_warn("address","",VAL,"","",function(){ //oc(); },{}).render() } else { h += frm.elaine("Please enter an address as accuratly as possible.","er1").render(); h += "
    "; // JC - CW - elaine added div VAL = bucket.address; h += `
    What is the address?
    `; h += frm.address_warn("address","",VAL,"","",function(){ //oc(); },{}).render() h += "
    "; } return h; })().wrap(`
    ${hr}`,"","
    ");; let LASTFIELD = "address"; if (type == "current") { h += ""; } else if (type == "previous" || type == "former" || type == "tax") { h += ""; } else { VAL = bucket.type; h += frm.radio("type",`Present or former address?`,VAL,"","",function(){ //oc(); },{ "current" : "Present residence", "former" : "Former residence" }).render().wrap("
    "+hr,"
    "); LASTFIELD = "type"; } VAL = bucket.appears_on_tax_returns; if ((is_editing == true && VAL == "Y") || appears_on_tax_returns == 0) { h += frm.yn3("appears_on_tax_returns","Is this the address you used on your last tax returns?",VAL,"","",function(){ //revealTip('credit_has_judgements'); oc(); }, {}).render().wrap("
    "+hr,"
    "); LASTFIELD = "appears_on_tax_returns"; } if (type == "current" || (type == "edit" && bucket.type == "current")) { VAL = bucket.appears_on_drivers_license; h += frm.radio("appears_on_drivers_license",`Does this address appear on your drivers license? `,VAL,"","",function(){ oc(); },{ "Y" : "Yes", "N" : "No", "NA" : "My state does not display an address on my drivers license" }, {}).render().wrap("
    "+hr,"
    "); // h += frm.yn3("appears_on_drivers_license","Does this address appear on your drivers license?",VAL,"","",function(){ // //revealTip('credit_has_judgements'); // oc(); // }, {}).render().wrap("
    "+hr,"
    "); h += (function(){ let h = ""; // h += frm.elaine("Florida Law says you must change your address within 30 days after moving. " + h += frm.elaine("" + "What is the reason why the address on your drivers license is different from your current address?","er2").render(); h += "
    "; // JC - CW - elaine added div VAL = bucket.reason_dl_different; h += frm.txt("reason_dl_different","",VAL,"","",function(){}).render(); h += "
    "; return h; })().wrap("
    ","
    "); } h += "
    "; // END Elaine ER } let reveal = function(onchange) { let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation == "years" && (num(txt("#years")) == 0 && num(txt("#months")) == 0)) { if (onchange) return; return mar.tip(".help-button","warning","You need to tell us how long you lived at this address.","top"); } if (validation == "use" && radio("use") == "") { if (onchange) return; return mar.tip(".help-button","warning","You need to tell us how you used the address.","top"); } if (validation == "rent" && num(txt("#rent")) == 0) { if (onchange) return; return mar.tip(".help-button","warning","You need to tell us how much rent you pay.","top"); } if (validation == "rentwillcontinue" && yn3("#rentwillcontinue") == "") { if (onchange) return; return mar.tip(".help-button","warning","You need to tell us if you will continue to pay rent.","top"); } if (validation == "address" && txt("#address") == "") { if (onchange) return; return mar.tip(".help-button","warning","You need to fill in the address.","top"); } if (validation == "appears_on_tax_returns" && yn3("#appears_on_tax_returns").trim().length == 0) { if (onchange) return; return mar.tip(".help-button","warning","You need to let us know if it appears on your tax returns.","top"); } if (type == "current") { if (validation == "appears_on_tax_returns" && radio("appears_on_drivers_license").trim().length == 0) { if (onchange) return; return mar.tip(".help-button","warning","You need to let us know if it appears on your drivers licance.","top"); } } // if (validation == "ln" && txt("#ln").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your last name.","top"); // if (validation == "em" && txt("#em").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your Email address.","top"); // if (validation == "ph" && txt("#ph").trim().length == 0) return mar.tip(".help-button","warning","You need to tell us your phone number.","top"); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv").css("display",""); $("#body-container").scrollTo("max",200); $ela = $elm.find(".xhuman"); if ($ela.length > 0) { $($ela[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false, }); } }); return true; } return false; } if (bbar == false) { h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ // if (reveal(false) == true) return; if (type == "list") { let possible_warning = MAR.applicants.is_there_a_property_ownership_missmatch(mar.answers,applicantnum); let missmatch = MAR.getOpt(possible_warning, "missmatch"); let missmatch_type = MAR.getOpt(missmatch, "type", ""); if (missmatch_type === "adhist") { elaineui.swalprompt({ title : "Address Error", txt : `You previously said you did not own any property currently, are you sure you own this?`, ok : "Yes", cancel : "No", okfn : function(a){ mvc.go(`#scenario-pastproperty.${applicantnum}`); }, cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } }) return; } if (missmatch_type === "adhist1") { elaineui.swalprompt({ title : "Address Error", txt : `You previously said you have not owned property in the last 3 years, are you sure you own this?`, ok : "Yes", cancel : "No", okfn : function(a){ mvc.go(`#scenario-pastproperty.${applicantnum}`); }, cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } }) return; } // always assets nowardays // if (num(mar.pg_as) < num(mar.pg_pd)) { // mvc.go("#income-how.0"); // } else { // mvc.go("#assets-choice"); // } if (redirect !== false) { mvc.go(redirect); return; } mvc.go("#assets-choice"); return; } let add = false; if (existingid !== false) { let bucketid = items[existingid]; if (bucketid in mar.answers.v2.buckets) { bucket = mar.answers.v2.buckets[bucketid]; } } else { var uuid = mar.fmt.uuid() bucket = { bucketid : "/applicants/address/"+applicantnum+"/"+uuid, uuid : uuid, address : "", type : "", use : "", years : 0, months : 0, rent : 0, rentwillcontinue : "", appears_on_tax_returns : "", appears_on_drivers_license : "", reason_dl_different : "" }; add = true; } bucket.address = txt("#address"); bucket.type = ($("#type").length == 0) ? radio("type") : txt("#type"); bucket.use = radio("use"); bucket.years = txt("#years"); bucket.months = txt("#months"); bucket.appears_on_tax_returns = ($("#appears_on_tax_returns").length == 0) ? "" : yn3("#appears_on_tax_returns"); bucket.appears_on_drivers_license = ($("#appears_on_drivers_license_div").length == 0) ? "" : radio("appears_on_drivers_license"); bucket.reason_dl_different = txt("#reason_dl_different"); if (bucket.use == "rent") { bucket.rent = ($("#rent").length == 0) ? 0 : txt("#rent"); bucket.rentwillcontinue = ($("#rentwillcontinue").length == 0) ? "" : txt("#rentwillcontinue"); } if (bucket.months == "") bucket.months = "0"; if (bucket.years == "") bucket.years = "0"; if (num(bucket.months) + num(bucket.years) == 0) return mar.tip(".help-button","warning","You need to tell us how long you lived at this address.","top"); if (bucket.use.trim().length == 0) return mar.tip(".help-button","warning","You need to tell us how you used the address.","top"); if (bucket.use == "rent" && bucket.type == "current") { if (bucket.rent == 0) return mar.tip(".help-button","warning","You need to let us know what rent you currently pay.","top"); if (bucket.rentwillcontinue == "") return mar.tip(".help-button","warning","You need to let us know if you will continue to pay rent after the purchase.","top"); } if (bucket.address.trim().length == 0) return mar.tip(".help-button","warning","You need to fill in the address.","top"); if ($("#appears_on_tax_returns").length > 0) { if (bucket.appears_on_tax_returns.trim().length == 0) return mar.tip(".help-button","warning","You need to let us know if it appears on your tax returns.","top"); } if ($("#appears_on_drivers_license_div").length > 0) { if (bucket.appears_on_drivers_license.trim().length == 0) return mar.tip(".help-button","warning","You need to let us know if it appears on your drivers licance.","top"); if (bucket.appears_on_drivers_license == "N") { if (bucket.reason_dl_different.trim().length == 0) return mar.tip(".help-button","warning","You need to let us know why the address is not on your license.","top"); } } // if (parseInt(sd.bucket.months,10) == 0 && parseInt(sd.bucket.years,10) == 0) { // //return mar.tip(".sdupdate","warning","You left the duration blank" ,"top"); // } // if (bucket.use == "") return mar.tip(".sdupdate","warning","You left the own/rent blank" ,"top"); // if (sd.bucket.address == "") return mar.tip(".sdupdate","warning","You left the address blank" ,"top"); // if (sd.bucket.type == "current") { // if (sd.bucket.appears_on_drivers_license == "N") { // if (sd.bucket.reason_dl_different == "") { // return mar.tip(".sdupdate","warning","You need to give us a reason why this is not on your drivers license" ,"top"); // } // // } // } /** * only do this if we are going to add the address */ if (add === true) { if ("addresses" in mar.answers.v2.applicants[applicantnum] == false) { mar.answers.v2.applicants[applicantnum].addresses=[]; } mar.answers.v2.applicants[applicantnum].addresses.push(bucket.bucketid); } mar.answers.v2.buckets[bucket.bucketid] = bucket; if ("dontsave" in mar == false) { frm.buttons.hide(function(){ MAR.activity_log.mod("residences", bucket.uuid); mar.fakesave(function(){ mvc.go("#scenario-addresshistory."+applicantnum); }); }); } else { mvc.go("#scenario-addresshistory."+applicantnum); } }),"Back",frm.addfunction(function(){ let are_ther_more_than_one_address = (items.length > 1); let have_we_entered_income = MAR.applicationNav.hasEnteredIncome(); if (type == "list") { mvc.go("#scenario-personaldata2."+applicantnum); // hmda return; } else if (type == "current") { if (have_we_entered_income == true) { mvc.go("#scenario-addresshistory."+applicantnum); // list return; } mvc.go("#scenario-personaldata2."+applicantnum); // hmda return; } else { if (items.length > 0) { if (existingid !== false && existingid !== "new") { if (existingid == 0) { mvc.go("#scenario-addresshistory."+applicantnum); // list return; } mvc.go("#scenario-addresshistory."+applicantnum+"."+(existingid -1)); // last address return; } mvc.go("#scenario-addresshistory."+applicantnum+"."+(items.length -1)); // last address return; } mvc.go("#scenario-addresshistory."+applicantnum); // list } }),"mar.help()"); } h = Mustache.render(h,localopts); let oc = function(quick) { if (radio("appears_on_drivers_license") == "N") { let $elm = $("#reason_dl_different_div"); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); $ela = $elm.find(".xhuman"); if ($ela.length > 0) { $($ela[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false, }); } }); } else { let $elm = $("#reason_dl_different_div"); $elm.addClass("x-hide").css("display","none"); } reveal(true); $("#body-container").scrollTo("max",200); } let or = function(){ // let sp = mar.isallowed_scenario("#scenario-realtor"); // if (typeof sp === "string") { // mvc.go(sp); // return; // } // if (redirect !== false) { // // let possible_warning = MAR.applicants.is_there_a_property_ownership_missmatch(mar.answers,applicantnum); // let missmatch = MAR.getOpt(possible_warning, "missmatch"); // let missmatch_type = MAR.getOpt(missmatch, "type", ""); // if (missmatch_type === "adhist") { // // elaineui.swalprompt({ // title : "Address Error", // txt : `You previously said you did not own any property currently, are you sure you own this?`, // ok : "Yes", // cancel : "No", // okfn : function(a){ // mvc.go(redirect); // }, // cancelfn : function() { // debugger; //// mvc.go(redirect); // }, // cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", // opts : { // closeOnClickOutside : false, // closeOnEsc : false // } // }) // // return; // } // // mvc.go(redirect); // return; // } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); if (type !== false && type !== "done" && type !== "list") { uihelpers.addresspopup_init($("#body-container").find("#address-disp")); } $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); // if (redirect !== false) { // // let possible_warning = MAR.applicants.is_there_a_property_ownership_missmatch(mar.answers,applicantnum); // let missmatch = MAR.getOpt(possible_warning, "missmatch"); // let missmatch_type = MAR.getOpt(missmatch, "type", ""); // if (missmatch_type === "adhist") { // // elaineui.swalprompt({ // title : "Address Error", // txt : `You previously said you did not own any property currently, are you sure you own this?`, // ok : "Yes", // cancel : "No", // okfn : function(a){ // mvc.go(redirect); // }, // cancelfn : function() { // debugger; //// mvc.go(redirect); // }, // cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", // opts : { // closeOnClickOutside : false, // closeOnEsc : false // } // }) // // return; // } // // mvc.go(redirect); // return; // } if (swaltext != "") { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = swaltext + "
    "+ "
    "; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Got it" // call : { // text: "Yes, Please", // value: "print", // closeModal: false // } } }) } } }, quick : false, }); oc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "personalinfo", menuitem : "scenario-addresshistory" } })(); mar.pg["scenario-checkpersonaldatac1"] = (function(){ var VAL = '' var html = ""; var checkForValues = false; function render(pg, localopts) { let h = ""; let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; let bucket = false; var applicantNameObject = getApplicantsNames_v2(Number(applicantnum)); let bucketid = mar.answers.v2.applicants[applicantnum].bucketid; bucket = mar.answers.v2.buckets[bucketid]; let has_visited = (MAR.getOpt(bucket,"ph","").trim().length > 0) let revealclass = (has_visited) ? "" : "x-hide x-revealdiv"; // reveal .1 let hr = "
    ";//frm.hr().render(); h += frm.htitle("CHECK PERSONAL DATA").render(); h += frm.elaine("It's time to step out of anonymity and let's gather some personal data here, ok?","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div for (let i=0; i < getApplicantsNames_v2().length; i++) { var _applicantNameObject = getApplicantsNames_v2(i); h += "

    "+ _applicantNameObject.Names + "

    "; h += "
    Check Personal data
    "; h += "
    Check Address History
    "; h += "
    Check Consents
    "; h += "
    "; // JC - CW - elaine - added end div } /* end modal content */ h += uihelpers.cbuttonbar("",frm.addfunction(function(){}),"",frm.addfunction(function(){}),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(quick) { $("#body-container").scrollTo("max",200); } let or = function(){ let sp = mar.isallowed_scenario("#scenario-realtor"); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { prepopulate(function(){ oc(true); }) } }, quick : false, }); oc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["authorizations-credit-ed"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; applicantnum = 0; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let selected_profile = ""; let env_profile = "default"; let h = ""; h += frm.htitle("SOFT CREDIT CHECK").render(); h += frm.elaine('Great job! Now please click "continue" to consent to the formal stuff.',"er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div h += "
    "; let missing_consent = ""; let makeDisplay = function(fn){ $.ajax({ url: '/api/consents/passed', type: 'POST', data : { appid : mar.ID, role : `c${applicantNum}`, altrole : `lo`, ty : "CAED,CA,ED", }, success: function(response) { $.get(`/api/cpull/status?appid=${mar.ID}`, function(cpull_status) { let CA = false; let ED = false; if (response && (MAR.getOpt(response, "data.CAED.passed","") === "Y")) { CA = MAR.getOpt(response, "data.CAED"); ED = MAR.getOpt(response, "data.CAED"); } else { if (response && (MAR.getOpt(response, "data.CA.passed","") === "Y")) { CA = MAR.getOpt(response, "data.CA"); } if (response && (MAR.getOpt(response, "data.ED.passed","") === "Y")) { ED = MAR.getOpt(response, "data.ED"); } } let WA = frm.inline_warning(`We do not make any hard enquiry on your credit that can affect your credit score until you have spoken to your loan officer`); let WA_COMP = ""; let pull = ""; let pull_lbl =""; let creditScorePullTS = MAR.getOpt(cpull_status, "creditScorePullTS",""); if (MAR.getOpt(cpull_status, "status", "") === "complete" && MAR.getOpt(cpull_status, "creditScorePullType","") === "soft") { WA_COMP = frm.inline_warning(`We obtained a copy of your credit report on {}`); WA_COMP = (`We obtained a copy of your credit report on ${elaineui.format("date",creditScorePullTS)} and included it in this application.`); pull = "soft"; pull_lbl = "Soft"; ED = null; } if (MAR.getOpt(cpull_status, "status", "") === "complete" && MAR.getOpt(cpull_status, "creditScorePullType","") === "hard") { WA_COMP = frm.inline_warning(`We obtained a copy of your credit report on {}`); WA_COMP = (`We obtained a copy of your credit report on ${elaineui.format("date",creditScorePullTS)} and included it in this application.`); pull = "hard"; pull_lbl = "Hard"; ED = null; } if (MAR.getOpt(cpull_status, "status", "") === "complete" && MAR.getOpt(cpull_status, "creditScorePullType","") === "") { WA_COMP = frm.inline_warning(`We obtained a copy of your credit report on {}`); WA_COMP = (`We obtained a copy of your credit report on ${elaineui.format("date",creditScorePullTS)} and included it in this application.`); pull = "other"; pull_lbl = "Soft"; ED = null; } if (MAR.appnav.loanWasImportedAndNotVerified() === true) { let wa_empty = (WA_COMP === ""); let enc_creditref = (MAR.getOpt(cpull_status, "cpull_status.items.0.cscore_ref_enc", "") !== ""); if (wa_empty && enc_creditref) { WA_COMP = (`We obtained a copy of your credit report and it will be included it in this application.`); pull = "other"; pull_lbl = "Hoft"; ED = null; } } let h = ""; if (WA_COMP !== ""){ h += "
    "; h += `Credit Report`+$("#svg_pre_qualification_backend_icon").html()+``; h += "
    "; h += "
    "; h += WA_COMP; h += "
    "; let page_heading = $(`#body-container .yellow-h1`); if (page_heading.length > 0) { $(page_heading[0]).html("Credit Authorization"); } let bubble_text = $(`#body-container .xhuman`); if (bubble_text.length > 0) { $(bubble_text[0]).html("Authrorization has been given for credit."); } } else if (CA !== false) { /** * the pull was already approved */ let short = CA.texts.short; short = short.replace(/ c1/g, " "+n0) short = short.replace(/ lo/g, " your loan officer "+loanofficer.name) h += "
    "; h += 'Soft Pull Credit Authorization'+$("#svg_pre_qualification_backend_icon").html()+''; h += "
    "; // let tc = "By pressing continue, all individuals in this application authorize and consent to "+getParameterByName("local_company")+" making inquires into your credit as described under the Fair Credit Reporting Act (FCRA), 15 U.S.C. § 1681 et seq."; // let tc = "SOFT PULL CREDIT INQUIRIES DO NOT AFFECT YOUR CREDIT SCORE. By pressing “Save and Go” you authorize us to soft pull your credit."; // h +="
    " + tc + h +="
    " + `
    ${short.toUpperCase()}
    `+ WA+ "
    "; } else { h += "
    "; h += 'Soft Pull Credit Authorization'+$("#svg_pre_qualification_backend_icon").html()+''; h += "
    "; // let tc = "By pressing continue, all individuals in this application authorize and consent to "+getParameterByName("local_company")+" making inquires into your credit as described under the Fair Credit Reporting Act (FCRA), 15 U.S.C. § 1681 et seq."; let tc = "SOFT PULL CREDIT INQUIRIES DO NOT AFFECT YOUR CREDIT SCORE. By pressing “Save and Go” you authorize us to soft pull your credit."; h +="
    "+tc+"
    "; missing_consent += "CA"; } if (ED === null){ } else if (ED !== false) { let short = ED.texts.short; short = short.replace(/ c1/g, " "+n0) short = short.replace(/ lo/g, " your loan officer "+loanofficer.name) h += "
    "; h += 'Electronic Disclosures '+$("#svg_pre_qualification_backend_icon").html()+''; h += "
    "; // h +="
    By pressing continue, all individuals in this application agree to accept all applicable disclosures associated with this transaction in an electronic form, including disclosures required by the Truth in Lending Act, Real Estate Settlement Procedures Act, and Equal Credit Opportunity Act. Paper copies will be provided for certain real estate related transactions after your loan application is received." + h +="
    " + `
    ${short.toUpperCase()}
    `+ "
    "; } else { h += "
    "; h += 'Electronic Disclosures '+$("#svg_pre_qualification_backend_icon").html()+''; h += "
    "; h +="
    By pressing continue, all individuals in this application agree to accept all applicable disclosures associated with this transaction in an electronic form, including disclosures required by the Truth in Lending Act, Real Estate Settlement Procedures Act, and Equal Credit Opportunity Act. Paper copies will be provided for certain real estate related transactions after your loan application is received.
    "; missing_consent += "ED"; } $("._mainform").html(h); if (fn) fn(); }); } }); } let uploadConsent = function(fn) { $.ajax({ url: '/api/consents/upload', type: 'POST', data : { html : html, ty : missing_consent, fp : mvc.get("fingerprint") }, success: function(response) { if (fn) fn(true); } }); } let consent = function(fn) { if (missing_consent === "") { if (fn) fn(true); return; } $.ajax({ url: '/api/consents/passed', type: 'POST', data : { appid : mar.ID, role : `c${applicantNum}`, ty : `${missing_consent}`, }, success: function(response) { if (response && (MAR.getOpt(response, `data.${missing_consent}.passed`,"") === "Y")) { if (fn) fn(false); } else { uploadConsent(fn); } } }); } //h += ""; h += "
    "; // _mainform h += "
    "; if (MAR.getOpt(__durunnersys, "flow.env","") === "prod") { env_profile = "cic"; } if (MAR.getOpt(__durunnersys, "flow.env","") === "demo") { env_profile = "default"; } if (MAR.getOpt(__durunnersys, "flow.env","") === "dev") { h += ""; h += ""; h += ""; } h += "
    "; // loform h += "
    "; // JC - CW - elaine - added end div // h += "" // // h += "" /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ // //mvc.go("#up-next"); consent(function(authorized){ makeDisplay(); let tel = ___tel; let otherPerson = '{ { other person on the app } }'; let tel2 = '{ { phone number of other person on app } }'; var s = document.createElement("div"); s.setAttribute("class","normal-form"); if (getScenario_data("authorizations-credit-ed_"+applicantnum+"_passed","") !== "Y") { if (selected_profile === "") { // $.get(`/api/cpull/setprofile?appid=${mar.ID}&profile=cic`, function(da) { $.get(`/api/cpull/setprofile?appid=${mar.ID}&profile=`+env_profile, function(da) { $.get(`/api/cpull/setprofile?appid=${mar.ID}&profile=`+env_profile, function(da) { $.get(`/api/cpull/queue_pull?appid=${mar.ID}`, function(da) { }); }); }); } } setScenario_data("authorizations-credit-ed_"+applicantnum+"_passed","Y") && mar.fakesave(); mvc.go("#personaldata-end"); // s.innerHTML = ""+ // frm.htitle("CONFIRMATION").render()+ // "You can always find a record that you consented to a credit pull in the app under the menu item 'Consent'."+ // "
    "; // // swal({ // className : "midelinfopopupOneButton", // content : s, // buttons : { // cancel : false, // ok : { // text: "OK, Got It!", // value: "ok", // closeModal: true // } // } // }) // .then((act) => { // setScenario_data("authorizations-credit-ed_"+applicantnum+"_passed","Y") && mar.fakesave(); // mvc.go("#personaldata-end"); // }); }); }),"Back",frm.addfunction(function(){ MAR.applicants.count() mvc.go(`#scenario-personaldata2.${(MAR.applicants.count()-1)}`); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ //let status = MAR.getConsents(__ROLE); // if (typeof __ROLE !== 'undefined' && __ROLE == "cl") { // return __status; // } // else if (__status > 0) { // return __status; // } else { // if ("docusignrequested-by-lo" in bucket == false) return 0; // return 5; // // } makeDisplay(function(){ $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { setTimeout(function() { $("#body-container").scrollTo("max",200); },1500); //oc(true); } }, quick : false, }); }) } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "personalinfo" } })(); /* file /ui/app/js/pages.liabilities.js , last updated 1713525239744*/ /* * Class: AssetObj * Def: pass a data object as the arg and you can store or create little assets.. pass em around too * * where are the new liabilities added ?? * * */ let LiabilityObj = function(arg) { let data = {}; $.extend(true, data, arg); if (data.assetIcon) { data.assetIcon = `svg_${data.assetIcon}_assets`; } else { //check if(data.id){ if( $('#svg_'+data.id+'_assets').html() !== 'undefined'){ data.assetIcon = 'svg_'+data.id+'_assets'; } } } let types = { mortgage : ["svg_mortgage_and_heloc_icon_liabilities"], heloc : ["svg_mortgage_and_heloc_icon_liabilities"], alimony : ["svg_checkings_icon_assets"], child : ["svg_child_support_icon_liabilities"], childsupport : ["svg_child_support_icon_liabilities"], studentloan : ["svg_student_loan_icon_liabilities"], carloan : ["svg_car_loan_icon_liabilities"], carlease : ["svg_car_lease_icon_liabilities"], instalmentloan : ["svg_installment_icon_liabilities"], installmentloan : ["svg_installment_icon_liabilities"], creditcard : ["svg_credit_card_icon_liabilities"], irs : ["svg_irs_tax_icon_liabilities"], irstax : ["svg_irs_tax_icon_liabilities"] } if (!data.assetIcon && data.type in types ) { data.assetIcon = types[data.type][0]; } /* * function render * take the data and renders it according to desired view. * params: string * */ function render(vw){ let viewType = (vw) ? vw : data.type; let h = ''; function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } console.log('viewType:: '+viewType); // balance: 3400 // c2c: 0 // inomask: 1 // monthly: 120 // name: "macys" // nolate: "N" // q_balance: 3400 // q_monthly: 120 // signer: "signer" // type: "creditcard" // uuid: "c9ec8b3a-6ddb-455b-866" let icon = $("#"+data.assetIcon).html(); let triangle = ``; if (MAR.getOpt(data, "verified","") === "N") icon = triangle; switch(viewType) { case 'mortgage': h += `
    `; // h += ``; h += ``; h += `
    `; h += `
    ${data.name}
    `; h += `
    ` h += `
    `; h += `
    ${capitalizeFirstLetter(data.type)}:
    `; h += `
    ${elaineui.format("cur",data.monthly)}
    `; if (mar.WE_ARE_FROM_LOI) { MAR.ifOpt(data, "q_monthly", function(val){ h += `
    (${elaineui.format("cur",data.q_monthly)})
    `; }); } h += `
    ` h += "
    ×
    "; h += "
    "; //end imported account holder break; default: let name = data.name; if (MAR.getOpt(data,`_auto_newloan`,``) === `Y`) name = `New Line of Credit`; if (MAR.getOpt(data,`_auto_bor_dp`,``) === `Y`) name = `Borrowed Downpayment`; h += `
    `; h += ``; h += `
    `; h += `
    ${name}
    `; h += `
    ` h += `
    `; h += `
    ${capitalizeFirstLetter(data.type)}:
    `; // h += `
    ${elaineui.format("cur",data.monthly)} ${data.payoff} ${data.omit} ${data.omit_opt}
    `; h += `
    ${elaineui.format("cur",data.monthly)}
    `; if (mar.WE_ARE_FROM_LOI) { MAR.ifOpt(data, "q_monthly", function(val){ h += `
    (${elaineui.format("cur",data.q_monthly)})
    `; }); } h += `
    ` h += "
    ×
    "; h += "
    "; //end imported account holder } return h; } function updateModel(val){ $.extend(true, data, val); } return { render : render, updateModel : updateModel, ___id : "liabilities_class" } } mar.tmp_lia_return_after_manual_edit = function() { if (typeof mar.tmp_return_hash === "string" && mar.tmp_return_hash !== "") { debugger; if (mar.tmp_return_hash.endsWith(".edit_recalc")) { mvc.go(mar.tmp_return_hash); } else { mvc.go(mar.tmp_return_hash+".edit_recalc"); } } else { mvc.go("#liabilities-home"); } } mar.pg["liabilities-home-old"] = (function(){ var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "0" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let _sc = getScenario_v2(); MAR.liabilities.repair_uuids() && mar.fakesave(); /** * add any liabilities that come from declarations */ MAR.liabilities.add_unverified_from_declarations(); let h = ""; h += `
    Monthly Obligation:
    `; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (MAR.liabilities.has_unverified_items_except_mortgages() == true) { elaineui.swal(`You have some un-verified liabilities you need to check before you can continue

    These liabilities have a triangle next to them


    `, "Liabilities Verification"); return; } liabilities_simple_submit(); setScenario_data("__liabilities_passed","Y") && mar.fakesave(); mvc.go("#liabilities-end"); }),"back",frm.addfunction(function(){ mvc.go("#income-how"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(skipReturn) { } let drawcreditscore = function(n) { let cw = $("#_myCanvas").width(); let gw = cw * 0.65; let gr = (gw/2); // radius if ($("#myCanvas").length == 0) { $("#_myCanvas").append(``); } // thaanks to https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_canvas_arc let start = 0.9; //0.8 let end = 2.1; //2.2 let startv = 300; let endv = 850; let prc = ((n - startv)/(endv-startv)); let endx = ((end - start) * prc) + start; //$("#myCanvas").css("height",`${cw}px`); let fact = 0.69; //0.83; let spread = 0.40; //0.22 let lineW = 18; let tx = ""; if (n < 580) tx = "Very weak"; else if (n < 620) tx = "Weak"; else if (n < 670) tx = "Fair"; else if (n < 720) tx = "Good"; else tx = "Excellent"; var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); var gradient = ctx.createLinearGradient(0, 0, 170, 0); gradient.addColorStop("0", "#cccccc"); gradient.addColorStop("0.5" ,"#cdcdcd"); gradient.addColorStop("1.0", "#dcdcdc"); var gradient1 = ctx.createLinearGradient(0, 0, 170, 0); gradient1.addColorStop("0", "#90C33A"); gradient1.addColorStop("0.5" ,"#80D32A"); gradient1.addColorStop("1.0", "#90C33A"); ctx.beginPath(); ctx.arc((cw/2), 10+gr, gr, start*Math.PI, end * Math.PI); ctx.strokeStyle = gradient; ctx.lineWidth = lineW; ctx.stroke(); ctx.beginPath(); ctx.arc((cw/2), 10+gr, gr, start*Math.PI, endx * Math.PI); ctx.strokeStyle = gradient1; ctx.lineWidth = lineW; ctx.stroke(); ctx.beginPath(); ctx.fillStyle = "#ffffff" ctx.fillRect(0, gw*fact, cw, 20); ctx.font = "16px Open Sans"; ctx.fillStyle = "#333333"; ctx.textAlign = "center"; ctx.fillText(`${startv}`, (cw/2) - (gr/2) - (gr*spread), (gw*fact)+20); ctx.fillText(`${endv}`, (cw/2) + (gr/2) + (gr*spread), (gw*fact)+20); // ctx.fillText(` ${n} ${gw} ${cw} `, 10, 50); ctx.font = "56px Open Sans"; ctx.fillText(`${n}`, (cw/2), (cw*0.33)); ctx.font = "16px Open Sans"; ctx.fillText(`${tx}`, (cw/2),(gw*fact)); let X_End = (cw/2) + gr * Math.cos(endx*Math.PI); let Y_End = (10+gr) + gr * Math.sin(endx*Math.PI); ctx.beginPath(); ctx.arc(X_End, Y_End, lineW*0.7, 0, 2*Math.PI); ctx.fillStyle = "#ffffff"; ctx.fill(); ctx.lineWidth = 1; ctx.strokeStyle = "#cccccc"; ctx.stroke(); } let or = function(){ setTimeout(function(){ addLiabilities(); drawcreditscore(_sc.cscore); },100); // $("#body-container").find(".xx-radio").myradio(); // $("#body-container .xx-check").mycheck(); // $("#body-container .xx-check3").mycheck3(); // $("#body-container .xhuman").Humanize({ // opts : { // fn : function() { // oc(true); // } // }, // quick : false, // }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "About Us" } function iscomplete(N) { return true; } return { render : render, section : "liabilities", iscomplete : iscomplete } })() mar.pg["liabilities-home"] = (function(){ var html = ""; function render(pg, localopts) { /** * prev used if we are coming with the previous button from homework. */ let prev = (MAR.getOpt(localopts, "p2","") === "prev"); if (prev) { localopts.p2 = ""; } /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "0" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let _sc = getScenario_v2(); let _gotopage = false; mar.pg_accesscontrollerfn = function() { return "open"; } mar.tmp_return_hash = false; getLiabilities_v2(); MAR.liabilities.repair_uuids() && mar.fakesave(); // /** // * add any liabilities that come from declarations // */ // MAR.liabilities.add_unverified_from_declarations(); getBackEndLiabilities_v2(); let h = ""; h += ``; h += ``; h += ``; mar.reset = function(){ for (let i=0; i < mar.answers.v2.liabilities.length; i++) { let lia = mar.answers.v2.liabilities[i]; lia.verified = "N"; lia.cstatus = ""; if (lia.type === "studentloan") { lia.type = "instalmentloan"; } } } mar.process = function() { console.log(rs); for (let i=0; i < MAR.applicants.count(); i++) { if ($("#yn3-ask-ccards"+`-${i}`).length > 0 && yn3("#ask-ccards"+`-${i}`) === "") { mar.tip(".help-button","warning","You need to answer yes or no to all questions.","top"); return false; } if ($("#yn3-ask-carloans"+`-${i}`).length > 0 && yn3("#ask-carloans"+`-${i}`) === "") { mar.tip(".help-button","warning","You need to answer yes or no to all questions.","top"); return false; } if ($("#yn3-ask-instalmentloans"+`-${i}`).length > 0 && yn3("#ask-instalmentloans"+`-${i}`) === "") { mar.tip(".help-button","warning","You need to answer yes or no to all questions.","top"); return false; } if ($("#yn3-ask-studentloans"+`-${i}`).length > 0 && yn3("#ask-studentloans"+`-${i}`) === "") { mar.tip(".help-button","warning","You need to answer yes or no to all questions.","top"); return false; } } let rv = true; (function(){ let sl = $("#ask-studentloans-div .x-yes"); for (let i=0; i < sl.length; i++) { debugger; let _i = $(sl[i]).data("id"); mar.answers.v2.liabilities[_i].type = "studentloan"; mar.answers.v2.liabilities[_i].cstatus = "tofillin"; } for (let i=0; i < rs.q.length; i++) { let q = rs.q[i][0]; if (q == "ask-studentloans") { let arr = rs.q[i][1]; for (let j=0; j < arr.length; j++) { let item = arr[j].obj.raw(); let _i = arr[j].i; if (MAR.getOpt(mar.answers.v2.liabilities[_i], "cstatus", "") !== "tofillin") { mar.answers.v2.liabilities[_i].signer = "borrower"; mar.answers.v2.liabilities[_i].cstatus = "borrower"; mar.answers.v2.liabilities[_i].verified = "Y"; if (num(mar.answers.v2.liabilities[_i].monthly) === 0) { mar.answers.v2.liabilities[_i].paytype = "def"; } } } } } })(); if (rv === false) return false; (function(){ let sl = $(".ask-ccards-div .x-yes"); for (let i=0; i < sl.length; i++) { let _i = $(sl[i]).data("id"); mar.answers.v2.liabilities[_i].signer = "coborrower"; mar.answers.v2.liabilities[_i].cstatus = "coborrower"; mar.answers.v2.liabilities[_i].verified = "N"; mar.answers.v2.liabilities[_i].omit = "Y"; mar.answers.v2.liabilities[_i].omit_opt = "notpaying"; let innameof = txt(`#innameof_${_i}`); let paid = yn3(`#made_all_payments_${_i}`); if (innameof === "") { mar.tip(".help-button","warning","You need to complete questions.","top"); rv = false; return false; } if (paid === "") { mar.tip(".help-button","warning","You need to answer yes or no to all questions.","top"); rv = false; return false; } mar.answers.v2.liabilities[_i].innameof = innameof; mar.answers.v2.liabilities[_i].made_all_payments = paid; mar.answers.v2.liabilities[_i].verified = "Y"; } for (let i=0; i < rs.q.length; i++) { let q = rs.q[i][0]; if (q == "ask-creditcards") { let arr = rs.q[i][1]; for (let j=0; j < arr.length; j++) { let item = arr[j].obj.raw(); let _i = arr[j].i; if (MAR.getOpt(mar.answers.v2.liabilities[_i], "omit", "") !== "Y") { mar.answers.v2.liabilities[_i].signer = "borrower"; mar.answers.v2.liabilities[_i].cstatus = "borrower"; mar.answers.v2.liabilities[_i].verified = "Y"; } } } } })(); if (rv === false) return false; (function(){ let sl = $(".ask-carloans-div .x-yes"); for (let i=0; i < sl.length; i++) { let _i = $(sl[i]).data("id"); mar.answers.v2.liabilities[_i].signer = "coborrower"; mar.answers.v2.liabilities[_i].cstatus = "coborrower"; mar.answers.v2.liabilities[_i].verified = "N"; mar.answers.v2.liabilities[_i].omit = "Y"; mar.answers.v2.liabilities[_i].omit_opt = "notpaying"; let innameof = txt(`#innameof_${_i}`); let paid = yn3(`#made_all_payments_${_i}`); if (innameof === "") { mar.tip(".help-button","warning","You need to complete questions.","top"); rv = false; return false; } if (paid === "") { mar.tip(".help-button","warning","You need to answer yes or no to all questions.","top"); rv = false; return false; } mar.answers.v2.liabilities[_i].innameof = innameof; mar.answers.v2.liabilities[_i].made_all_payments = paid; mar.answers.v2.liabilities[_i].verified = "Y"; } for (let i=0; i < rs.q.length; i++) { let q = rs.q[i][0]; if (q == "ask-carloans") { let arr = rs.q[i][1]; for (let j=0; j < arr.length; j++) { let item = arr[j].obj.raw(); let _i = arr[j].i; if (MAR.getOpt(mar.answers.v2.liabilities[_i], "omit", "") !== "Y") { mar.answers.v2.liabilities[_i].signer = "borrower"; mar.answers.v2.liabilities[_i].cstatus = "borrower"; mar.answers.v2.liabilities[_i].verified = "Y"; } } } } })(); if (rv === false) return false; (function(){ let sl = $(".ask-instalmentloans-div .x-yes"); for (let i=0; i < sl.length; i++) { debugger; let _i = $(sl[i]).data("id"); mar.answers.v2.liabilities[_i].signer = "coborrower"; mar.answers.v2.liabilities[_i].cstatus = "coborrower"; mar.answers.v2.liabilities[_i].verified = "N"; mar.answers.v2.liabilities[_i].omit = "Y"; mar.answers.v2.liabilities[_i].omit_opt = "notpaying"; } for (let i=0; i < rs.q.length; i++) { let q = rs.q[i][0]; if (q == "ask-instalmentloans") { let arr = rs.q[i][1]; for (let j=0; j < arr.length; j++) { let item = arr[j].obj.raw(); let _i = arr[j].i; if (MAR.getOpt(mar.answers.v2.liabilities[_i], "omit", "") !== "Y") { mar.answers.v2.liabilities[_i].signer = "borrower"; mar.answers.v2.liabilities[_i].cstatus = "borrower"; mar.answers.v2.liabilities[_i].verified = "Y"; } } } } })(); if (rv === false) return false; for (let i=0; i < mar.answers.v2.liabilities.length; i++) { let lia = mar.answers.v2.liabilities[i]; // lia.verified = "Y"; } return true; } let lr = MAR.liabilities.liabilities_reccomendation(mar.answers.v2.liabilities); lr.init(); let _lia = lr.getForApplicant(0); let _lia1 = lr.getForApplicant(1); let _lia2 = lr.getForApplicant(2); lr.reccommend(); let rs = lr.reccommendations; let hh = "" // hh += `

    Notes for LO (will not be displayed here)

    ${rs.r.join("

    ")}


    `; if ("tmp" in mar === false) mar.tmp = {}; mar.tmp.toggle = function(elm,i) { $elm = $(`#__liab_sel_${i}`); if ($elm.data("yn") === "N") { $elm.data("yn","Y"); $elm.addClass("x-yes"); $elm.removeClass("x-no"); // $elm.find(".importedAccountLogo").css("border", "1px solid red"); $elm.find("svg").css("display","none"); $elm.find(".yesimg").removeClass("x-hide"); } else { $elm.data("yn","N"); $elm.removeClass("x-yes"); $elm.addClass("x-no"); // $elm.find(".importedAccountLogo").css("border", "1px solid white"); $elm.find("svg").css("display","block"); $elm.find(".yesimg").addClass("x-hide"); } } mar.tmp.toggle_sl = function(elm,i) { $elm = $(`#__liab_sel_sl_${i}`); $elm_inst = $(`#__liab_sel_${i}`); if ($elm.data("yn") === "N") { $elm.data("yn","Y"); $elm.addClass("x-yes"); $elm.removeClass("x-no"); // $elm.find(".importedAccountLogo").css("border", "1px solid red"); $elm.find("svg").css("display","none"); $elm.find(".yesimg").removeClass("x-hide"); $elm_inst.addClass("x-hide"); $elm_inst.addClass("x-no"); $elm_inst.removeClass("x-yes"); } else { $elm.data("yn","N"); $elm.removeClass("x-yes"); $elm.addClass("x-no"); // $elm.find(".importedAccountLogo").css("border", "1px solid white"); $elm.find("svg").css("display","block"); $elm.find(".yesimg").addClass("x-hide"); $elm_inst.removeClass("x-hide"); } } let cstatus = ""; let tot = 0; for (let i=0; i < rs.q.length; i++) { let q = rs.q[i][0]; if (q == "ask-creditcards") { let arr = rs.q[i][1]; let appl = rs.q[i][2]; let ap_nam = getApplicantsNames_v2(appl).Name; let arridx = appl; let salut = (appl === 0) ? "Do you" : `Does ${ap_nam}`; let saluti = (appl === 0) ? "you don't pay yourself" : `${ap_nam} doesn't pay themself`; hh += frm.yn3(`ask-ccards-${arridx}`,salut+" have credit cards that you are an authorized user on, or that are being paid by someone else?","","","",function(x,y){ if (txt(`#ask-ccards-${arridx}`) === "Y") { let _h = ""; _h += frm.elaine("Click the cards "+saluti+".","er").render(); for (let j=0; j < arr.length; j++) { let item = arr[j].obj.raw(); let i = arr[j].i; let inm = arr[j].obj.inomask(); let ln = `mar.tmp.toggle(this,${i});`; let _logo = addLiabilitiesFunctions.logo + ""; _h += `
    `+ addLiabilitiesFunctions.block(0, ln, item, item.signer, _logo,true,i)+ ``+ // `
    ` + // frm.txt("innameof","","","e.g. John Smith","",function(){}).render()+ // `
    `+ // `
    ` + // frm.yn3("made_all_payments","Can you prove with 12 months bank statements that has made all the payments?","","","",function(){},{}).render() + // `
    ` + "
    "; } $(`#ask-ccards-div-${arridx}`).addClass("x-hide").html(_h); $(`#ask-ccards-div-${arridx}`).slideDown(function(){ $(`#ask-ccards-div-${arridx}`).removeClass("x-hide"); }) $("#body-container .xx-check3").mycheck3(); } else { $(`#ask-ccards-div-${arridx}`).html("") } }, {}).render(); hh += `
    `; hh += frm.hr().render(); tot++; cstatus = "process"; } /** * carloans */ if (q == "ask-carloans") { let arr = rs.q[i][1]; let appl = rs.q[i][2]; let ap_nam = getApplicantsNames_v2(appl).Name; let arridx = appl; let salut = (appl === 0) ? "your" : `${ap_nam}'s`; let saluti = (appl === 0) ? "you are" : `${ap_nam} is`; hh += frm.yn3(`ask-carloans-${arridx}`,"Are any of "+salut+" car loans being paid by someone else?","","","",function(x,y){ if (txt(`#ask-carloans-${arridx}`) === "Y") { let _h = ""; _h += frm.elaine("From the list can you click on the car loans that "+saluti+" a co-borrower on:","er").render(); for (let j=0; j < arr.length; j++) { let item = arr[j].obj.raw(); let i = arr[j].i; let ln = `mar.tmp.toggle(this,${i});`; let _logo = addLiabilitiesFunctions.logo + ""; _h += `
    `+addLiabilitiesFunctions.block(0, ln, item, item.signer, _logo,true,i)+"
    "; } $(`#ask-carloans-div-${arridx}`).addClass("x-hide").html(_h); $(`#ask-carloans-div-${arridx}`).slideDown(function(){ $(`#ask-carloans-div-${arridx}`).removeClass("x-hide"); }); $("#body-container .xx-check3").mycheck3(); } else { $(`#ask-carloans-div-${arridx}`).html("") } }, {}).render(); hh += `
    `; hh += frm.hr().render(); tot++; cstatus = "process"; } /** * instalmentloans */ if (q == "ask-instalmentloans") { let arr = rs.q[i][1]; let appl = rs.q[i][2]; let ap_nam = getApplicantsNames_v2(appl).Name; let arridx = appl; let salut = (appl === 0) ? "your" : `${ap_nam}'s`; let saluti = (appl === 0) ? "you are" : `${ap_nam} is`; hh += frm.yn3(`ask-instalmentloans-${arridx}`,"Are any of "+salut+" installment loans being paid by someone else?","","","",function(x,y){ if (txt(`#ask-instalmentloans-${arridx}`) === "Y") { let _h = ""; _h += frm.elaine("From the list can you click on the instalment loans that "+saluti+" a co-borrower on:","er").render(); for (let j=0; j < arr.length; j++) { let item = arr[j].obj.raw(); let i = arr[j].i; let studentloans = $(`#__liab_sel_sl_${i}.x-yes`); let cls = `x-no`; if (studentloans.length > 0) { cls = `x-no x-hide`; } let ln = `mar.tmp.toggle(this,${i});`; let _logo = addLiabilitiesFunctions.logo + ""; _h += `
    `+addLiabilitiesFunctions.block(0, ln, item, item.signer, _logo)+"
    "; } $(`#ask-instalmentloans-div-${arridx}`).addClass("x-hide").html(_h); $(`#ask-instalmentloans-div-${arridx}`).slideDown(function(){ $(`#ask-instalmentloans-div-${arridx}`).removeClass("x-hide"); }); $("#body-container .xx-check3").mycheck3(); } else { $(`#ask-instalmentloans-div-${arridx}`).html("") } }, {}).render(); hh += `
    `; hh += frm.hr().render(); tot++; cstatus = "process"; } // if (q == "ask-studentloans") { // let arr = rs.q[i][1]; // hh += frm.yn3("ask-studentloans","Do you have a student loan?","","","",function(x,y){ // if (txt("#ask-studentloans") === "Y") { // let _h = ""; // _h += frm.elaine("From the list can you click on the loans that are student loans:","er").render(); // for (let j=0; j < arr.length; j++) { // let item = arr[j].obj.raw(); // let i = arr[j].i; // // let ln = `mar.tmp.toggle_sl(this,${i});`; // let _logo = addLiabilitiesFunctions.logo + ""; // _h += `
    `+addLiabilitiesFunctions.block(0, ln, item, item.signer, _logo)+"
    "; // // } // // $("#ask-studentloans-div").addClass("x-hide").html(_h); // $("#ask-studentloans-div").slideDown(function(){ // $("#ask-studentloans-div").removeClass("x-hide"); // }) // } else { // $("#ask-studentloans-div").html("") // } // // }, {}).render(); // hh += "
    "; // hh += frm.hr().render(); // cstatus = "process"; // tot++; // // } if (tot === 0 && q == "ask-studentloan") { let arr = rs.q[i][1]; let ari = arr[0].i; ari = MAR.getOpt(arr[0].obj.raw(), "uuid",ari); hh += `link to student loan ${ari}`; if ("tmp" in mar === false) mar.tmp = {}; mar.tmp_flex_title_prefix = "ADD INFORMATION:"; mar.tmp_flex_title = "STUDENT LOAN"; mar.tmp_flex_subtitle = "Please give us more information about the student loan."; mar.tmp_flex_url = `#liabilities-item.0.${ari}`; _gotopage = "#flow-flex"; _gotopage = mar.tmp_flex_url; } else if (tot === 0 && q == "ask-child") { let arr = rs.q[i][1]; let ari = arr[0].i; ari = MAR.getOpt(arr[0].obj.raw(), "uuid",ari); hh += `link to student loan ${ari}`; if ("tmp" in mar === false) mar.tmp = {}; mar.tmp_flex_title_prefix = "ADD INFORMATION:"; mar.tmp_flex_title = "ALIMONY/CHILD"; mar.tmp_flex_subtitle = "Please give us more information about the Alimony / Child support."; mar.tmp_flex_url = `#liabilities-child.0.${ari}`; _gotopage = "#flow-flex"; _gotopage = mar.tmp_flex_url; } else if (tot === 0 && q == "ask-irs") { let arr = rs.q[i][1]; let bor = rs.q[i][2]; let ari = arr[0].i; ari = MAR.getOpt(arr[0].obj.raw(), "uuid",ari); hh += `link to student loan ${ari}`; if ("tmp" in mar === false) mar.tmp = {}; mar.tmp_flex_title_prefix = "ADD INFORMATION:"; mar.tmp_flex_title = "IRS DEBT"; mar.tmp_flex_subtitle = "Please give us more information about the IRS Debt."; mar.tmp_bubble_explanation_irs = "You declared that you had an outstanding IRS debt."; mar.tmp_flex_url = `#liabilities-irstax.${bor}.${ari}`; _gotopage = "#flow-flex"; _gotopage = mar.tmp_flex_url; } else if (tot === 0 && q == "ask-newloan") { let arr = rs.q[i][1]; let bor = rs.q[i][2]; let ari = arr[0].i; ari = MAR.getOpt(arr[0].obj.raw(), "uuid",ari); hh += `link to student loan ${ari}`; if ("tmp" in mar === false) mar.tmp = {}; mar.tmp_flex_title_prefix = "ADD INFORMATION:"; mar.tmp_flex_title = "NEW LOAN"; mar.tmp_flex_subtitle = "Please give us more information about the new Loan."; mar.tmp_flex_url = `#liabilities-instalmentloan.${bor}.${ari}`; _gotopage = "#flow-flex"; _gotopage = mar.tmp_flex_url; } else if (tot === 0 && q == "ask-borrowed") { let arr = rs.q[i][1]; let bor = rs.q[i][2]; let ari = arr[0].i; ari = MAR.getOpt(arr[0].obj.raw(), "uuid",ari); hh += `link to student loan ${ari}`; if ("tmp" in mar === false) mar.tmp = {}; mar.tmp_flex_title_prefix = "ADD INFORMATION:"; mar.tmp_flex_title = "NEW LOAN"; mar.tmp_flex_subtitle = "Please give us more information about the borrowed downpayment."; mar.tmp_flex_url = `#liabilities-instalmentloan.${bor}.${ari}`; _gotopage = "#flow-flex"; _gotopage = mar.tmp_flex_url; } } let pagenames = { mortgage : "mortgage", heloc : "heloc", alimony : "alimony", child : "child", studentloan : "studentloan", carloan : "carloan", carlease : "carlease", instalmentloan : "instalmentloan", creditcard : "creditcard" } mar.editfn = function(N,TYP) { if (TYP === `mortgage`) { frm.warning("WARNING","You can't edit mortgages but you will be able to verify them during the realestate section which will follow.
    ", false); return; } mvc.go("#liabilities-"+TYP+".0."+N); } mar.delfn = function(N,ELM) { let $e = $(ELM); while ($e.hasClass("importedAccountHolder") == false) { $e = $($e.parent()); } let _l = MAR.liabilities.get("",N); if (MAR.getOpt(_l, "sig", "") !== "") { frm.warning("WARNING","You can't delete this because it was imported from your creditreport.
    ", false); return; } frm.areyousure("WARNING","You are about to delete this item from your liabilities statement.

    Are you sure?
    ", function(){ $e.css("opacity",0.2); //.remove(); MAR.liabilities.del(N) && mar.fakesave(); mvc.go("#liabilities-home"); }) } mar.repull_credit = function(fn) { $.get(`/api/cpull/run?appid=${mar.ID}&test=n`, function(da) { fn(); }); } let list_displayed = false; if (hh === "") { list_displayed = true; hh = (function(){ let h = ""; let items = MAR.liabilities.get(); debugger; for (let i=0; i < items.length; i++) { let item = items[i]; if (MAR.getOpt(item, "type", "") === "mortgage") continue; item.i = i; let litem = LiabilityObj(item); h += litem.render(); } return h; })(); } h += `
    Liabilities
    ${hh}
    `; //
    Monthly Obligation:
    h += ``; if (mar.WE_ARE_FROM_LOI && list_displayed) { h += ``; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * if the credit is frozen then we need to read the radio and act accordingly */ let skip_liability_check = false; if ($(`.x-pull-frozen`).length > 0 || $(`.x-pull-error`).length > 0 || $(`.x-pull-other-status`).length > 0) { let continue_options = radio(`continue_options`); if (continue_options === ``) { elaineui.swal(`You have to choose on of the options`, "Warning"); return; } if (continue_options === `continue_anyway`) { cstatus = ``; // make sure we do not process any results skip_liability_check = true; } if (continue_options === `repull`) { $("div.x_content").LoadingOverlay("show"); if ($(`.x-pull-other-status`).length > 0) { if ($(`.x-pull-status-R`).length > 0) { mvc.go("#liabilities-home"); return; } if ($(`.x-pull-status-P`).length > 0) { mvc.go("#liabilities-home"); return; } if ($(`.x-pull-status-C`).length > 0) { mvc.go("#liabilities-home"); return; } } mar.repull_credit(function(){ mvc.go("#liabilities-home"); }); return; } } if (cstatus === "process") { if (mar.process() === false) { return; } mar.fakesave(function() { setTimeout( function() { mvc.go("#liabilities-home"); },500); }); return; } if (skip_liability_check === false && MAR.liabilities.has_unverified_items_except_mortgages() == true) { let next_item = MAR.liabilities.getNextUnverifiedItem_except_mortgages(); if (next_item.link !== false) { mvc.go(next_item.link); return; } elaineui.swal(`You have some un-verified liabilities you need to check before you can continue

    These liabilities have a triangle next to them


    `, "Liabilities Verification"); return; } if (skip_liability_check === false) { liabilities_simple_submit(); } setScenario_data("__liabilities_passed","Y") && mar.fakesave(); mar.fakesave(); if (MAR.is_refi() === true || getDoOwnRealestate() == true) { mvc.go("#reo-home"); } else { mvc.go("#lox"); } }),"back",frm.addfunction(function(){ mvc.go("#income-how."+(MAR.applicants.count()-1)); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(skipReturn) { } /** * n = creditscore * src = app-soft, app-hard, encompass * rate = textual rating */ let drawcreditscore = function(n, src, rate) { if (n < 100) return; if (src === "app-soft") { let h = `Based on a soft pull of one credit bureau your credit rating is ${rate}.`; if ($("#body-container div.rowTable").length > 0) h += ` Can you tell me more about the liabiities listed below.`; h = frm.elaine(h,"").render(); $("#_myCanvas").html(h); return; } let cw = $("#_myCanvas").width(); let gw = cw * 0.65; let gr = (gw/2); // radius if ($("#myCanvas").length == 0) { $("#_myCanvas").append(``); } // thaanks to https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_canvas_arc let start = 0.9; //0.8 let end = 2.1; //2.2 let startv = 300; let endv = 850; let prc = ((n - startv)/(endv-startv)); let endx = ((end - start) * prc) + start; //$("#myCanvas").css("height",`${cw}px`); let fact = 0.69; //0.83; let spread = 0.40; //0.22 let lineW = 18; let tx = ""; if (n < 580) tx = "Very weak"; else if (n < 620) tx = "Weak"; else if (n < 670) tx = "Fair"; else if (n < 720) tx = "Good"; else tx = "Excellent"; var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); var gradient = ctx.createLinearGradient(0, 0, 170, 0); gradient.addColorStop("0", "#cccccc"); gradient.addColorStop("0.5" ,"#cdcdcd"); gradient.addColorStop("1.0", "#dcdcdc"); var gradient1 = ctx.createLinearGradient(0, 0, 170, 0); gradient1.addColorStop("0", "#90C33A"); gradient1.addColorStop("0.5" ,"#80D32A"); gradient1.addColorStop("1.0", "#90C33A"); ctx.beginPath(); ctx.arc((cw/2), 10+gr, gr, start*Math.PI, end * Math.PI); ctx.strokeStyle = gradient; ctx.lineWidth = lineW; ctx.stroke(); ctx.beginPath(); ctx.arc((cw/2), 10+gr, gr, start*Math.PI, endx * Math.PI); ctx.strokeStyle = gradient1; ctx.lineWidth = lineW; ctx.stroke(); ctx.beginPath(); ctx.fillStyle = "#ffffff" ctx.fillRect(0, gw*fact, cw, 20); ctx.font = "16px Open Sans"; ctx.fillStyle = "#333333"; ctx.textAlign = "center"; ctx.fillText(`${startv}`, (cw/2) - (gr/2) - (gr*spread), (gw*fact)+20); ctx.fillText(`${endv}`, (cw/2) + (gr/2) + (gr*spread), (gw*fact)+20); // ctx.fillText(` ${n} ${gw} ${cw} `, 10, 50); ctx.font = "56px Open Sans"; ctx.fillText(`${n}`, (cw/2), (cw*0.33)); ctx.font = "16px Open Sans"; ctx.fillText(`${tx}`, (cw/2),(gw*fact)); let X_End = (cw/2) + gr * Math.cos(endx*Math.PI); let Y_End = (10+gr) + gr * Math.sin(endx*Math.PI); ctx.beginPath(); ctx.arc(X_End, Y_End, lineW*0.7, 0, 2*Math.PI); ctx.fillStyle = "#ffffff"; ctx.fill(); ctx.lineWidth = 1; ctx.strokeStyle = "#cccccc"; ctx.stroke(); } let or = function(){ if (_gotopage !== false) { mvc.go(_gotopage); return; } let gotoSplashPage = function() { if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page","#liabilities-home"); mvc.go("#up-next-liabilities") return true; } return false; } // if (gotoSplashPage()) return; $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); let reload_liabilities = function(_fn){ console.error(`reload_liabilities - start`); let ob = { appid : mar.ID }; mar.socket.send_and_receive("get-app-liabilities",ob, function(liabilities){ console.error("doanloaded liabilities",liabilities); // mar.answers.v2.liabilities = liabilities.data.liabilities; mar.answers.v2.tlimports = liabilities.data.tlimports; for (let x in liabilities.data.scenario) { mar.answers.v2.scenario[x] = liabilities.data.scenario[x]; } if (MAR.getOpt(mar.answers.v2, "liabilities", null) === null) { mar.answers.v2.liabilities = []; } let original_length = mar.answers.v2.liabilities.length; getLiabilities_v2(); /** * add any liabilities that come from declarations */ MAR.liabilities.add_unverified_from_declarations(); let new_length = mar.answers.v2.liabilities.length; let added = (original_length !== new_length); _fn(added); },20000); } $("div.x_content").LoadingOverlay("show"); $.get(`/api/cpull/status?appid=${mar.ID}`, function(da) { let pull_status = MAR.getOpt(da, "status", ""); let pull_isCompleted = MAR.getOpt(da, "isCompleted", false); let pull_imported = MAR.getOpt(da, "imported", false); let pull_appstatus = MAR.getOpt(da, "appstatus", ""); let pull_frozen = false; let pull_error = false; console.error(`pull_status ${pull_status}, pull_isCompleted ${pull_isCompleted}, pull_appstatus ${pull_appstatus}, pull_imported ${pull_imported}`); (function() { let cpull_files = MAR.getOpt(da, `items`,[]); for (let i=0; i < cpull_files.length; i++) { let file = cpull_files[i]; if (file.frozen === true) { pull_frozen = true; } if (file.error === true) { pull_error = true; } } })(); if ([`R`,`P`,`C`].indexOf(pull_appstatus) < 0 && pull_frozen !== false) { $("div.x_content").LoadingOverlay("hide",true); $_myCanvas = $("#_myCanvas"); $_myCanvas_list = $("#_myCanvas_list"); debugger; let _h = frm.elaine(`We need to pull your credit report to continue with your mortgage application, but we have been notified that your credit is currently frozen. To proceed, please contact the credit bureau directly to request that they lift the freeze on your credit report.
    `+ `
    `+ `Once you have contacted the credit bureau, please choose the option "Retry my credit" and we will re-pull your credit report and continue with your mortgage application as quickly as possible.
    `+ `
    `+ `If you cannot contact the bureau immediately it is possible to continue without a credit report , however if you own proerty the mortgage will not be registered in the application and you will have to enter it yourself. `+ `We will also not be able to process your application before receiving the report
    `+ ``,"").render(); _h += frm.radio("continue_options",`Continue with the following option`,``,"","",function(){ },{ repull : "Retry my credit report - I have contacted the bureau", continue_anyway : "Continue without a credit report", }).render().wrap("
    ","
    "); $_myCanvas.html(_h); //$_myCanvas_list.html(``); $_myCanvas.find(".xx-radio").myradio(); return; } if ([`R`,`P`,`C`].indexOf(pull_appstatus) < 0 && pull_error !== false) { $("div.x_content").LoadingOverlay("hide",true); $_myCanvas = $("#_myCanvas"); $_myCanvas_list = $("#_myCanvas_list"); debugger; let _h = frm.elaine(`Error message`+ ``,"").render(); _h += frm.radio("continue_options",`Continue with the following option`,``,"","",function(){ },{ repull : "Retry my credit report - I have contacted the bureau", continue_anyway : "Continue without a credit report", }).render().wrap("
    ","
    "); $_myCanvas.html(_h); //$_myCanvas_list.html(``); $_myCanvas.find(".xx-radio").myradio(); return; } console.error(`Do we have another status? [${pull_appstatus}]`) // if ([`R`,`P`,`C`,`E`].indexOf(pull_appstatus) > -1) { // // $("div.x_content").LoadingOverlay("hide",true); // $_myCanvas = $("#_myCanvas"); // $_myCanvas_list = $("#_myCanvas_list"); // // console.error(`Do we have another status? YES WE DO !`) // let _h = ``+ // ``; //// if (pull_appstatus === "R") { //// _h += frm.elaine("It looks like we are waiting on a credit report to process. Press Save & Go to proceed through the application.

    We will inform you when the report has been pulled and imported to the application.","").render(); //// } //// else if (pull_appstatus === "P") { //// _h += frm.elaine("It looks like we have not imported a credit report yet for you or that your report has no liabilities. Press Save & Go to proceed through the application.

    We will inform you when the report has been pulled and imported to the application.","").render(); //// } //// else if (pull_appstatus === "C") { //// _h += frm.elaine("It looks like we have not imported a credit report yet but it is on its way. Lets wait a few minutes to see if it comes in. Press Save & Go to proceed through the application.

    We will inform you when the report has been pulled and imported to the application.","").render(); //// } else { //// _h += frm.elaine("It looks like we have not imported a credit report yet for you or that your report has no liabilities. Press Save & Go to proceed through the application.

    We will inform you when the report has been pulled and imported to the application.","").render(); //// } // // if ([`R`,`P`,`C`].indexOf(pull_appstatus) > -1) { // _h += frm.elaine("It looks like we have not imported a credit report yet but it is on its way. "+ // "Lets wait a few minutes to see if it comes in. "+ // `
    `+ // `
    `+ // "Choose the option to 'Retry my credit report' below to see if the status has changed."+ // `
    `+ // `
    `+ // "Choose the option to 'Continue without a credit report' to continue with the application and "+ // "we will inform you when the report has been pulled and imported to the application."+ // `
    `+ // `
    `+ // `We will not be able to process your application before receiving the report`+ // ` and if you own proerty the mortgage will not be registered in the application and you will have to enter it yourself. `+ // `
    `+ // ``,"").render(); // _h += frm.radio("continue_options",`Continue with the following option`,``,"","",function(){ // },{ // repull : "Retry my credit report", // continue_anyway : "Continue without a credit report", // }).render().wrap("
    ","
    "); // } else { // _h += frm.elaine("It looks like we have not imported a credit report yet because of an error. "+ // `
    `+ // "Choose the option to 'Continue without a credit report' to continue with the application and "+ // "we will inform you when the report has been pulled and imported to the application."+ // `
    `+ // `
    `+ // `We will not be able to process your application before receiving the report`+ // ` and if you own proerty the mortgage will not be registered in the application and you will have to enter it yourself. `+ // `
    `+ // ``,"").render(); // // _h += frm.radio("continue_options",`Continue with the following option`,`continue_anyway`,"","",function(){ // },{ // continue_anyway : "Continue without a credit report", // }).render().wrap("
    ","
    "); // // } // // // $_myCanvas.html(_h); // //$_myCanvas_list.html(``); // // $_myCanvas.find(".xx-radio").myradio(); // // // return; // // } // if ([`R`,`P`,`C`,`E`].indexOf(pull_appstatus) && pull_isCompleted === true && pull_imported === true) { if (1 === 1) { if (gotoSplashPage()) return; if (1 ==1 || da.creditScoreToUse < 1 || da.creditScoreToUse === 850) { $.get(`/api/cpull/parse?appid=${mar.ID}`, function() { $.get(`/api/cpull/status?appid=${mar.ID}`, function(da) { reload_liabilities(function(added) { if (added) { mvc.go("#liabilities-home") return; } $("div.x_content").LoadingOverlay("hide",true); setTimeout(function(){ addLiabilities(); drawcreditscore(da.creditScoreToUse, da.creditScoreToUse_src, da.creditScoreToUse_rate); },100); }); }) }) } else{ setTimeout(function(){ /** * add any liabilities that come from declarations */ MAR.liabilities.add_unverified_from_declarations(); setTimeout(function(){ addLiabilities(); $("div.x_content").LoadingOverlay("hide",true); drawcreditscore(da.creditScoreToUse, da.creditScoreToUse_src, da.creditScoreToUse_rate); },100); },100); } } else { $("div.x_content").LoadingOverlay("hide",true); $_myCanvas = $("#_myCanvas"); //let _h = "The credit pull has not completed and we are looking into the reason. You can skip liabilities for the moment and when the pull is successful then we'll inform you."; let _h = ""; if ($("#body-container div.rowTable").length > 0) { _h += frm.elaine("Can you tell me more about the liabiities listed below.","").render(); } else { let timer = false; // pull_appstatus = ""; if (pull_appstatus === "R") { _h += frm.elaine("It looks like we are waiting on a credit report to process. Press Save & Go to proceed through the application.

    We will inform you when the report has been pulled and imported to the application.","").render(); } else if (pull_appstatus === "P") { _h += frm.elaine("It looks like we have not imported a credit report yet for you or that your report has no liabilities. Press Save & Go to proceed through the application.

    We will inform you when the report has been pulled and imported to the application.","").render(); } else if (pull_appstatus === "C") { _h += frm.elaine("It looks like we have not imported a credit report yet but it is on its way. Lets wait a few minutes to see if it comes in. Press Save & Go to proceed through the application.

    We will inform you when the report has been pulled and imported to the application.","").render(); timer = true; } else { _h += frm.elaine("It looks like we have not imported a credit report yet for you or that your report has no liabilities. Press Save & Go to proceed through the application.

    We will inform you when the report has been pulled and imported to the application.","").render(); } if (timer === true) { } else { /** * skip if no report and we have not been through liailities before */ if (getScenario_data("__liabilities_passed","") === "Y") { /** * We have been here before */ $_myCanvas.html(_h); // $_myCanvas = $("#_myCanvas"); // let h = "The credit pull has not completed and we are looking into the reason. You can skip liabilities for the moment and when the pull is successful then we'll inform you." // $_myCanvas.html(h); return; } setScenario_data("__liabilities_passed","Y") && mar.fakesave(); mar.fakesave(); if (MAR.is_refi() === true || getDoOwnRealestate() == true) { mvc.go("#reo-home"); } else { if (prev) { mvc.go("#income-how."+(MAR.applicants.count()-1)); } else { mvc.go("#lox"); } } return; } } $_myCanvas.html(_h); return; /** * skip if no report */ setScenario_data("__liabilities_passed","Y") && mar.fakesave(); mar.fakesave(); if (MAR.is_refi() === true || getDoOwnRealestate() == true) { mvc.go("#reo-home"); } else { if (prev) { mvc.go("#income-how."+(MAR.applicants.count()-1)); } else { mvc.go("#lox"); } } return; $_myCanvas = $("#_myCanvas"); let h = "The credit pull has not completed and we are looking into the reason. You can skip liabilities for the moment and when the pull is successful then we'll inform you." $_myCanvas.html(h); } }); // $("#body-container").find(".xx-radio").myradio(); // $("#body-container .xx-check").mycheck(); // $("#body-container .xx-check3").mycheck3(); // $("#body-container .xhuman").Humanize({ // opts : { // fn : function() { // oc(true); // } // }, // quick : false, // }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "About Us" } function iscomplete(N) { return true; } return { render : render, section : "liabilities", iscomplete : iscomplete } })() mar.pg["liabilities-item"] = (function(){ var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let type = false; let item = false; let manual = false; if (existingid !== false && typeof existingid == "string" && existingid.length > 2 && existingid.indexOf(`-`) > -1) { let item_index = MAR.liabilities.getByUUID(existingid,true); if (item_index !== false) { existingid = `${item_index}`; } } if (existingid !== false && typeof existingid == "string" && existingid.length > 2) { // this is a type type = existingid; existingid = false; } if (existingid !== false) { existingid = num(existingid); item = MAR.liabilities.get("",num(existingid)); if (item !== false) { type = item.type; manual = MAR.getOpt(item, "manual", "N") } } else { manual = "Y"; } if (item === false || MAR.getOpt(item, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } //var h = "
    CREDIT CARD
    "; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 //alert(`id ${existingid} type ${type} item ${JSON.stringify(item)}`); let h = ""; let closeFn = false; let initFN = false; let chunk = false; if (type == "creditcard") { h += frm.htitle("Credit card").render(); h += "
    "; if (manual === "Y") { chunk = "liabilities_simple_card"; } else { chunk = "liabilities_simple_card_confirm"; } closeFn = liabilities_simple_card_close; initFn = liabilities_simple_card_init; } if (type == "child") { h += frm.htitle("Alimony / Child support").render(); h += "
    "; chunk = "liabilities_simple_child"; closeFn = liabilities_simple_child_close; initFn = liabilities_simple_child_init; } if (type == "alimony") { h += frm.htitle("Alimony").render(); h += "
    "; chunk = "liabilities_simple_alimony"; closeFn = liabilities_simple_alimony_close; initFn = liabilities_simple_alimony_init; } if (type == "carlease") { h += frm.htitle("Car Lease").render(); h += "
    "; if (manual === "Y") { chunk = "liabilities_simple_carlease"; } else { chunk = "liabilities_simple_carlease_confirm"; } closeFn = liabilities_simple_carlease_close; initFn = liabilities_simple_carlease_init; } if (type == "carloan") { h += frm.htitle("Car Loan").render(); h += "
    "; if (manual === "Y") { chunk = "liabilities_simple_carloan"; } else { chunk = "liabilities_simple_carloan_confirm"; } // h += $('#liabilities_simple_carloan').html(); closeFn = liabilities_simple_carloan_close; initFn = liabilities_simple_carloan_init; } if (type == "instalmentloan") { h += frm.htitle("Instalment Loan").render(); h += "
    "; if (manual === "Y") { chunk = "liabilities_simple_instalmentloan"; } else { chunk = "liabilities_simple_instalmentloan_confirm"; } closeFn = liabilities_simple_instalmentloan_close; initFn = liabilities_simple_instalmentloan_init; } if (type == "otherloan") { h += frm.htitle("Other Liability").render(); h += $('#liabilities_simple_otherloan').html(); closeFn = liabilities_simple_otherloan_close; initFn = liabilities_simple_otherloan_init; } if (type == "irstax") { h += frm.htitle("IRS debt").render(); h += $('#liabilities_simple_irstax').html(); closeFn = liabilities_simple_irstax_close; initFn = liabilities_simple_irstax_init; } if (type == "studentloan") { h += frm.htitle("Student Loan").render(); h += "
    "; if (manual === "Y") { chunk = "liabilities_simple_studentloan"; } else { chunk = "liabilities_simple_studentloan_confirm"; } closeFn = liabilities_simple_studentloan_close; initFn = liabilities_simple_studentloan_init; } if (type == "mortgage") { h += frm.htitle("Mortgage").render(); if (manual === "Y") { h += $('#liabilities_simple_mortgage').html(); } else { h += $('#liabilities_simple_mortgage_confirm').html(); } closeFn = liabilities_simple_mortgage_close; initFn = liabilities_simple_mortgage_init; localopts.t = "mortgage"; } if (type == "heloc") { h += frm.htitle("HELOC").render(); if (manual === "Y") { h += $('#liabilities_simple_mortgage').html(); } else { h += $('#liabilities_simple_mortgage_confirm').html(); } closeFn = liabilities_simple_mortgage_close; initFn = liabilities_simple_mortgage_init; localopts.t = "heloc"; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (closeFn) { let cfn = closeFn(); if (cfn !== false) { mvc.go("#liabilities-home"); } } else { mvc.go("#liabilities-home"); } }),"close",frm.addfunction(function(){ mvc.go("#liabilities-home"); }),"mar.help()"); // var localopts = JSON.parse(JSON.stringify(mar.mdata)); let N = (existingid !== false) ? (existingid+1) : false; localopts.n = (N) ? N : 0; h = Mustache.render(h,localopts); let oc = function(skipReturn) { } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } if (chunk !== false) { mar.chunks.get(chunk, function(H) { H = Mustache.render(H,localopts); $("#chunk").html(H); chunk = false; or(); }) return; } // Humanize($(".liabilities_simple_popup").find(".xhuman")[0]); // liabilities_simple_card_init(localopts.n); // $("#body-container").find(".xx-radio").myradio(); // $("#body-container .xx-check").mycheck(); // $("#body-container .xx-check3").mycheck3(); if (initFn) initFn(localopts.n); $("#body-container .xhuman").Humanize({ opts : { fn : function() { // oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "About Us" } function iscomplete(N) { return true; } return { render : render, section : "liabilities", iscomplete : iscomplete } })() /* * liabilities pages * */ mar.pg["liabilities-choice"] = (function(){ var VAL = 'N' var html = ""; var goto = "#liabilities-summary"; function render(pg, localopts) { let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; getLiabilities_v2(); var applicantsObj = getApplicantsNames_v2(); let itm = (existingid!==false) ? MAR.liabilities.get("bank",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 mar.pg_accesscontrollerfn = function() { return "open"; } let h = ""; h += frm.htitle("").render(); let pagenames = { mortgage : "mortgage", heloc : "heloc", alimony : "alimony", child : "child", studentloan : "studentloan", carloan : "carloan", carlease : "carlease", instalmentloan : "instalmentloan", creditcard : "creditcard" } let items = MAR.liabilities.get(); // for (let i=0; i < items.length; i++) { // let item = items[i]; // item.i = i; // let litem = LiabilityObj(item); // // h += litem.render(); // } h += frm.elaine("You can manually add liabilities but they may be replaced or updated later by the hard credit pull.","").render(); h += "
    "; h += "
    "; h += "
    "; h += frm.hr().render(); h += "
    "; h += "
    What type of liablity do you want to add?

    "; h += "
    "+$("#svg_credit_card_icon_liabilities").html()+"Credit Card
    "+$("#svg_student_loan_icon_liabilities").html()+"Student Loan
    "+$("#svg_car_lease_icon_liabilities").html()+"Lease
    "; h += "
    "+ "
    "+$("#svg_car_loan_icon_liabilities").html()+"Loan
    "+ "
    "+$("#svg_installment_icon_liabilities").html()+"Installment
    "+ "
    "+$("#svg_irs_tax_icon_liabilities").html()+"IRS Tax
    "+ "
    "; h += "
    "+$("#svg_child_support_icon_liabilities").html()+"Child Support
    "+$("#svg_mortgage_and_heloc_icon_liabilities").html()+"Mortgage
    "+$("#svg_mortgage_and_heloc_icon_liabilities").html()+"HELOC
    "; // h += "
    Other
    "; VAL = ''; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ //not necc /* var how = radio("assetschoice"); if (how && how != "") { mvc.go("#assets-"+pagenames[how]); } else { mvc.go("#income-summary"+"."+applicantnum); } */ mvc.go(goto); //or just go straight to checking? }),"close",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); mar.editfn = function(N,TYP) { mvc.go("#liabilities-"+TYP+".0."+N); } mar.delfn = function(N,ELM) { let $e = $(ELM); while ($e.hasClass("importedAccountHolder") == false) { $e = $($e.parent()); } frm.areyousure("WARNING","You are about to delete this item from your liabilities statement.

    Are you sure?
    ", function(){ $e.css("opacity",0.2); //.remove(); MAR.liabilities.del(N) && mar.fakesave(); mvc.go("#liabilities-home"); }) } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $(".incomeIcons_button").on('click', function(e){ let $elm = $(e.currentTarget); let type = $elm.data("goto"); if (type === "mortgage") { elaineui.swalprompt({ title : "Warning", txt : `
    `+ `Mortgages cannot be added manually in the liability section but they can be added in the REO section against the property they are liened against`+ `
    `+ `
    `, ok : false, cancel : "OK", cls : "midelinfopopupOneButton", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } }); return; } if (type === "heloc") { elaineui.swalprompt({ title : "Warning", txt : `
    `+ `Home Equity Lines of Credit cannot be added manually in the liability section but they can be added in the REO section against the property they are liened against`+ `
    `+ `
    `, ok : false, cancel : "OK", cls : "midelinfopopupOneButton", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } }); return; } goto = "#liabilities-"+$elm.data("goto"); $('.incomeIcons_button').removeClass('darkBkgWithWhiteText'); $elm.addClass('darkBkgWithWhiteText'); if (goto && goto != "") { $("#liability_items_holder_inner").html('if there is anything of this type '+$elm.data("goto")+', show in here'); $("#liability_items_holder").removeClass("x-hide"); $("#body-container").scrollTo("max",200); //mvc.go("#liabilities-"+pagenames[goto]); } }); }; /* h += uihelpers.cbuttonbar("","","","","mar.help()"); h = Mustache.render(h,localopts); let or = function(){ $("#body-container").find(".xx-radio").myradio(); } */ pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-report"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid!==false) ? MAR.liabilities.get("report",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 console.warn("localopts", localopts); console.warn("inc", inc); console.warn("itm", itm); /** * standard starting block - END */ let reportElaineText = "We have checked your credit and your mid-score is { {midscoreValue} }. This is a very weak score, and I will probably have to do something to help you get that score up."; let h = ""; h += frm.htitle("Liabilities").render(); h += "
    We will now analyze the liabilities on your credit report.
    " h += frm.elaine(reportElaineText,"er").render(); h += "
    "; // JC - CW - elaine added div h += `
    `; h += "
    Attention: Franklin First Financial will pay for your credit report repair cost at the time of closing, if you elect to work with National Credit Care.
    " h += "
    "; // reveal - start h += frm.hr().render(); //toggle here.. but like a checklist //---- set up the applicants checklist VAL = (itm) ? itm.allow_credit_analysis : []; var slimmedObj = {}; h += frm.checklist("allow_credit_analysis","",VAL,"","",function(){ checkListChange(); },{ allow : "I hearby authorize {FFF} to send my credit report to National Credit Care for free analysis." }).render(); //---- end the applicants checklist h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "report"; itm.balance = txt("#balance"); itm.allow_credit_analysis = yn("#allow_credit_analysis"); /** * validation block start (validate the "itm" values) */ /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mvc.go("#liabilities-home"); }),"cancel",frm.addfunction(function(){ mvc.go("#liabilities-home"); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { } let drawcreditscore = function(n) { let cw = $("#_myCanvas").width(); let gw = cw * 0.65; let gr = (gw/2); // radius if ($("#myCanvas").length == 0) { $("#_myCanvas").append(``); } // thaanks to https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_canvas_arc let start = 0.9; //0.8 let end = 2.1; //2.2 let startv = 300; let endv = 850; let prc = ((n - startv)/(endv-startv)); let endx = ((end - start) * prc) + start; //$("#myCanvas").css("height",`${cw}px`); let fact = 0.69; //0.83; let spread = 0.40; //0.22 let lineW = 18; let tx = ""; if (n < 580) tx = "Very weak"; else if (n < 620) tx = "Weak"; else if (n < 670) tx = "Fair"; else if (n < 720) tx = "Good"; else tx = "Excellent"; var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); var gradient = ctx.createLinearGradient(0, 0, 170, 0); gradient.addColorStop("0", "#cccccc"); gradient.addColorStop("0.5" ,"#cdcdcd"); gradient.addColorStop("1.0", "#dcdcdc"); var gradient1 = ctx.createLinearGradient(0, 0, 170, 0); gradient1.addColorStop("0", "#90C33A"); gradient1.addColorStop("0.5" ,"#80D32A"); gradient1.addColorStop("1.0", "#90C33A"); ctx.beginPath(); ctx.arc((cw/2), 10+gr, gr, start*Math.PI, end * Math.PI); ctx.strokeStyle = gradient; ctx.lineWidth = lineW; ctx.stroke(); ctx.beginPath(); ctx.arc((cw/2), 10+gr, gr, start*Math.PI, endx * Math.PI); ctx.strokeStyle = gradient1; ctx.lineWidth = lineW; ctx.stroke(); ctx.beginPath(); ctx.fillStyle = "#ffffff" ctx.fillRect(0, gw*fact, cw, 20); ctx.font = "16px Open Sans"; ctx.fillStyle = "#333333"; ctx.textAlign = "center"; ctx.fillText(`${startv}`, (cw/2) - (gr/2) - (gr*spread), (gw*fact)+20); ctx.fillText(`${endv}`, (cw/2) + (gr/2) + (gr*spread), (gw*fact)+20); // ctx.fillText(` ${n} ${gw} ${cw} `, 10, 50); ctx.font = "56px Open Sans"; ctx.fillText(`${n}`, (cw/2), (cw*0.33)); ctx.font = "16px Open Sans"; ctx.fillText(`${tx}`, (cw/2),(gw*fact)); let X_End = (cw/2) + gr * Math.cos(endx*Math.PI); let Y_End = (10+gr) + gr * Math.sin(endx*Math.PI); ctx.beginPath(); ctx.arc(X_End, Y_End, lineW*0.7, 0, 2*Math.PI); ctx.fillStyle = "#ffffff"; ctx.fill(); ctx.lineWidth = 1; ctx.strokeStyle = "#cccccc"; ctx.stroke(); } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { drawcreditscore(700); oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); // new one mar.pg["liabilities-child"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let itm = (existingid!==false) ? MAR.liabilities.get("child",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 console.warn("localopts", localopts); console.warn("itm", itm); if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } let no_cancel = false; if (MAR.getOpt(itm,`_auto_created`,``)=== `Y`) { no_cancel = (MAR.getOpt(itm,`verified`,``) !== `Y`); } /** * standard starting block - END */ let h = ""; h += frm.htitle("Alimony / Child Support").render(); if (!existingid) { h += frm.elaine(`${na}, In the declaration you indicated that you have to pay alimony and/or child support. Please let us know the details of the payment plan.`,"er").render(); } else { h += frm.elaine(`${na}, in the declaration you indicated that you have to pay alimony and/or child support. Please let us know the details of the payment plan.`,"er").render(); } h += "
    "; // JC - CW - elaine added div if (itm) { let itemObj = MAR.xsd.lia_child(itm); if ("credit_obligated_to_pay_alimony_or_child_followup" in itm === false || itm.credit_obligated_to_pay_alimony_or_child_followup === "") { if (itemObj.alimony() > 0 && itemObj.child() > 0) { itm.credit_obligated_to_pay_alimony_or_child_followup = "both"; } else if (itemObj.child() > 0) { itm.credit_obligated_to_pay_alimony_or_child_followup = "child"; } else if (itemObj.alimony() > 0) { itm.credit_obligated_to_pay_alimony_or_child_followup = "alimony"; } } if (itemObj.enc_monthly() > 0) { if (itemObj.enc_monthly() !== itemObj.monthly()) { if (itemObj.alimony() > 0 && itemObj.child() === 0) { itm.alimony_monthly = itemObj.enc_monthly() } else if (itemObj.alimony() === 0 && itemObj.child() > 0) { itm.child_monthly = itemObj.enc_monthly() } else if (itemObj.alimony() > 0 && itemObj.child() > 0) { let diff = (itemObj.enc_monthly() - itemObj.monthly()); let diffPerc = 1+(num(diff) / itemObj.monthly()); itm.child_monthly = Math.floor(itemObj.child() * diffPerc); itm.alimony_monthly = (itemObj.enc_monthly() - itemObj.child()) } else { itm.child_monthly = Math.floor(itemObj.enc_monthly()/2); itm.alimony_monthly = (itemObj.enc_monthly() - itemObj.child()) } } } } h += (function(){ let h = ""; VAL = (itm) ? itm.credit_obligated_to_pay_alimony_or_child_followup : ''; h += frm.radio("whichone",`Which is ${na} obligated to pay?`,VAL,"","",function(){ oc(`whichone`); },{ alimony : "Alimony", child : "Child support", both : "Both" }).render().wrap("
    ",""); return h; })().wrap("
    ","
    ") //})().wrap("
    ","
    ") h += (function(){ let h = ""; h += frm.hr().render(); h += "
    What is the total monthly child support payment?
    "; VAL = (itm) ? itm.child_monthly : '1000'; h += frm.slider("child_monthly","",VAL,"","",function(){ oc(); }, { v00 : '0', v50 : '1000', v50_inc : '50', v75 : '5000', v75_inc : '100', v100 : '10000', v100_inc : '200', start_val : '1000' }).render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; VAL = (itm) ? itm.child_dropoff : ''; // prefill if itm is not false h += frm.yn3("child_dropoff","Does any of the payments end within 6 months?",VAL,"","",function(){ oc(); },{}).render(); return h; })().wrap("
    ","
    "); h += (function(){ let h = ""; VAL = (itm) ? itm.child_dropoff_count : '0'; h += frm.slider("child_dropoff_count","How many children's payments will drop off?",VAL,"","",function(){ oc(); }, { v00 : '0', v50 : '4', v50_inc : '1', v75 : '6', v75_inc : '1', v100 : '8', v100_inc : '1', start_val : '0', formatting_class : `` }).render(); return h; })().wrap("
    ","
    "); for (let i=0; i < 5; i++) { h += (function(){ let h = ""; h += frm.hr().render(); VAL = (itm) ? itm[`child_dropoff_name_${i}`] : ''; h += frm.txt(`child_dropoff_name_${i}`,"Child's name",VAL,"e.g. Ben , Mary","",function(){ oc(); }).render(); VAL = (itm) ? itm[`child_dropoff_dob_${i}`] : ''; h += frm.txt(`child_dropoff_dob_${i}`,"Date of birth",VAL,"01/01/1990","",function(){ oc(); }).render(); VAL = (itm) ? itm[`child_dropoff_val_${i}`] : ''; h += frm.slider(`child_dropoff_val_${i}`,"Amount that will drop off",VAL,"","",function(){ oc(); }, { v00 : '0', v50 : '1000', v50_inc : '50', v75 : '5000', v75_inc : '100', v100 : '10000', v100_inc : '200', start_val : '1000' }).render(); return h; })().wrap(`
    `,"
    "); } h += (function(){ let h = ""; h += frm.hr().render(); h += "
    What is the total monthly alimony payment?
    "; VAL = (itm) ? itm.alimony_monthly : '1000'; h += frm.slider("alimony_monthly","",VAL,"","",function(){ oc(); }, { v00 : '0', v50 : '1000', v50_inc : '50', v75 : '5000', v75_inc : '100', v100 : '10000', v100_inc : '200', start_val : '1000' }).render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; VAL = (itm) ? itm.alimony_dropoff : ''; // prefill if itm is not false h += frm.yn3("alimony_dropoff","Does alimony end within 6 months?",VAL,"","",function(){ oc(); },{}).render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; VAL = (itm) ? itm.alimony_date : ''; // prefill if itm is not false h += frm.txt(`alimony_dropoff_date`,"End date ",VAL,"01/01/1990","",function(){ oc(); },"date").render(); return h; })().wrap("
    ","
    ") if (!itm) { h += (function(){ let h = ""; VAL = (itm) ? itm.inomask : 1; // prefill if itm is not false h += frm.hr().render(); h += "
    Who is obligated on this payment?
    "; if (itm) { h += innameofBlock(VAL, true, itm) } else { h += innameofBlock(1, true, false); } return h; })().wrap("
    ","
    "); } /* h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += frm.elaine("Since you have less that 10 payments left, we may omit this liability if you will keep { { payment x terms } } in your bank account as reserves after closing.","er").render(); VAL = (itm) ? itm.omit_payment : 'N'; h += frm.yn("omit_payment","Do you want to omit this car payment?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end */ h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ if (oc() === false) return; /** * validation & reveal block end */ if (!existingid) { itm = {}; itm.uuid = mar.fmt.uuid(); } itm.type = "child"; itm.whichone = radio("whichone"); itm.child_monthly = txt("#child_monthly"); itm.child_dropoff = txt("#child_dropoff"); itm.child_dropoff_count = txt("#child_dropoff_count"); for (let i=0; i < 8; i++) { itm[`child_dropoff_name_${i}`] = txt(`#child_dropoff_name_${i}`); itm[`child_dropoff_dob_${i}`] = txt(`#child_dropoff_dob_${i}`); itm[`child_dropoff_val_${i}`] = txt(`#child_dropoff_val_${i}`); } itm.alimony_monthly = txt("#alimony_monthly"); itm.alimony_dropoff = txt("#alimony_dropoff"); itm.alimony_dropoff_date = txt("#alimony_dropoff_date"); itm.alimony_date = txt("#alimony_dropoff_date"); itm.payment = num(MAR.getOpt(itm,"child_monthly",0)) + num(MAR.getOpt(itm,"alimony_monthly",0)); itm.enc_payment = itm.payment; itm.monthly = itm.payment; itm.enc_monthly = itm.payment; itm.enc_payment = itm.payment; if (!existingid) { itm.inomask = innameofBlock_read(); } else { itm.inomask = innameofBlock_from_number(applicantnum); //innameofBlock_read(); } itm.payup = "more10"; itm.omit = "N"; itm.verified = "Y"; itm.cstatus = "ok"; //itm.monthly = itm.payment; //itm.balance = itm.payment; /** * validation block start (validate the "itm" values) */ if (itm.whichone === "") { return mar.tip(".help-button","warning","You need to tell us which.","top"); } if (itm.whichone === "child" || itm.whichone === "both") { if (num(itm.child_monthly) === 0) { return mar.tip(".help-button","warning","You need to tell us how much the child suppot costs.","top"); } if (itm.child_dropoff === "") { return mar.tip(".help-button","warning","You need to tell us if any payments dropoff.","top"); } if (itm.child_dropoff === "Y" && num(itm.child_dropoff_count) === 0) { return mar.tip(".help-button","warning","You need to tell us how many payments dropoff.","top"); } for ( let i=0; i < num(itm.child_dropoff_count); i++) { if (itm[`child_dropoff_name_${i}`] === "") { return mar.tip(".help-button","warning","You need to tell us the names.","top"); } if (itm[`child_dropoff_dob_${i}`] === "") { return mar.tip(".help-button","warning","You need to tell us the dates.","top"); } if (num(itm[`child_dropoff_val_${i}`]) === 0) { return mar.tip(".help-button","warning","You need to tell us the values.","top"); } } } if (itm.whichone === "alimony" || itm.whichone === "both") { if (num(itm.alimony_monthly) === 0) { return mar.tip(".help-button","warning","You need to tell us how much the child suppot costs.","top"); } if (itm.alimony_dropoff === "") { return mar.tip(".help-button","warning","You need to tell us if any payments dropoff.","top"); } if (itm.alimony_dropoff === "Y" && itm.alimony_date === "" || typeof itm.alimony_date === "undefined") { return mar.tip(".help-button","warning","You need to tell us when payments dropoff.","top"); } if (itm.alimony_dropoff === "Y" && new Date(itm.alimony_date).getTime() < new Date().getTime()) { return mar.tip(".help-button","warning","The date needs to be in the future.","top"); } } /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let prevent_changes = false; let oc = function(field = "") { let retval = true; console.error(`lia child OC [${field}]`) if (prevent_changes === true) { return true; } let whichone = radio("whichone"); if (field === `whichone`) { // prevent_changes = true; } if (whichone === "") { $("#child_monthly_div").addClass("x-hide"); $("#alimony_monthly_div").addClass("x-hide"); if (field === `whichone`) { txt("#child_monthly",0); txt("#alimony_monthly",0); $("#alimony_monthly").change(); $("#child_monthly").change(); } } if (whichone === "child") { $("#child_monthly_div").removeClass("x-hide"); $("#alimony_monthly_div").addClass("x-hide"); if (field === `whichone`) { txt("#alimony_monthly",0); $("#alimony_monthly").change(); } } if (whichone === "alimony") { $("#alimony_monthly_div").removeClass("x-hide"); $("#child_monthly_div").addClass("x-hide"); if (field === `whichone`) { txt("#child_monthly",0) $("#child_monthly").change(); } } if (whichone === "both") { $("#alimony_monthly_div").removeClass("x-hide"); $("#child_monthly_div").removeClass("x-hide"); } if (num(txt("#child_monthly")) === 0) { $("#child_dropoff_div").addClass("x-hide"); $("#child_dropoff_count_div").addClass("x-hide"); for (let i=0; i < 8; i++) { $(`#child_dropoff_details_${i}_div`).addClass("x-hide"); txt("#child_dropoff_count" ,""); txt(`#child_dropoff_name_${i}` , ""); txt(`#child_dropoff_dob_${i}` , ""); txt(`#child_dropoff_val_${i}` , ""); } } else { $("#child_dropoff_div").removeClass("x-hide"); if (txt("#child_dropoff") !== "Y") { if (txt("#child_dropoff") === "") retval = false; if (txt("#child_dropoff") === "N") { txt("#child_dropoff_count",""); for (let i=0; i < 8; i++) { txt(`#child_dropoff_name_${i}`, ""); txt(`#child_dropoff_dob_${i}`, ""); txt(`#child_dropoff_val_${i}`, ""); } } $("#child_dropoff_count_div").addClass("x-hide"); for (let i=0; i < 8; i++) { $(`#child_dropoff_details_${i}_div`).addClass("x-hide"); txt(`#child_dropoff_name_${i}`, ""); txt(`#child_dropoff_dob_${i}`, ""); txt(`#child_dropoff_val_${i}`, ""); } } else { $("#child_dropoff_count_div").removeClass("x-hide"); let cnt = num(txt("#child_dropoff_count")) if (cnt === 0) retval = false; for (let i=0; i < 8; i++) { if (i < cnt) { $(`#child_dropoff_details_${i}_div`).removeClass("x-hide"); } else { $(`#child_dropoff_details_${i}_div`).addClass("x-hide"); txt(`#child_dropoff_name_${i}`, ""); txt(`#child_dropoff_dob_${i}`, ""); txt(`#child_dropoff_val_${i}`, ""); } } } } if (num(txt("#alimony_monthly")) === 0) { $("#alimony_dropoff_div").addClass("x-hide"); $("#alimony_dropoff_date_div").addClass("x-hide"); } else { $("#alimony_dropoff_div").removeClass("x-hide"); if (txt("#alimony_dropoff") !== "Y") { if (txt("#alimony_dropoff") === "") retval = false; $("#alimony_dropoff_date_div").addClass("x-hide"); } else { $("#alimony_dropoff_date_div").removeClass("x-hide"); } } prevent_changes = false; return retval; } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); if (no_cancel) { // auto generated and therefore no cancel $(`#body-container .prev-button`).addClass(`x-hide`); } //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-jre"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let itm = (existingid!==false) ? MAR.liabilities.get("jre",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 revealclass=""; console.warn("localopts", localopts); console.warn("itm", itm); if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } /** * standard starting block - END */ let h = ""; h += frm.htitle("Job Related Expense").render(); h += frm.elaine("Please let us know the details of the payment plan.","er").render(); h += "
    "; // JC - CW - elaine added div h += (function(){ let h = ""; h += "
    What is monthly payment?
    "; VAL = (itm) ? itm.monthly : '1000'; h += frm.slider("monthly","",VAL,"","",function(){ oc(); }, { v00 : '0', v50 : '1000', v50_inc : '50', v75 : '5000', v75_inc : '100', v100 : '10000', v100_inc : '200', start_val : '1000' }).render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; VAL = (itm) ? itm.name : ''; // prefill if itm is not false h += frm.txt(`name`,"Description ",VAL,"...","",function(){ oc(); }).render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; VAL = (itm) ? itm.dropoff : ''; // prefill if itm is not false h += frm.yn3("dropoff","Does payment end within 6 months?",VAL,"","",function(){ oc(); },{}).render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; VAL = (itm) ? itm.dropoff_date : ''; // prefill if itm is not false h += frm.txt(`dropoff_date`,"End date ",VAL,"01/01/1990","",function(){ oc(); },"date").render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; VAL = (itm) ? itm.inomask : 1; // prefill if itm is not false h += frm.hr().render(); h += "
    Who is obligated on this payment?
    "; if (itm) { h += innameofBlock(VAL, true, itm) } else { h += innameofBlock(1, true, false); } return h; })(); h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ if (oc() === false) return; /** * validation & reveal block end */ if (!existingid) { itm = {}; itm.uuid = mar.fmt.uuid(); } itm.type = "jre"; itm.name = txt("#name"); itm.monthly = txt("#monthly"); itm.dropoff = txt("#dropoff"); itm.dropoff_date = txt("#dropoff_date"); itm.payment = num(itm.monthly); itm.enc_payment = itm.payment; itm.monthly = itm.payment; itm.enc_monthly = itm.payment; itm.enc_payment = itm.payment; itm.inomask = innameofBlock_read(); itm.payup = "more10"; itm.omit = "N"; itm.verified = "Y"; //itm.monthly = itm.payment; //itm.balance = itm.payment; /** * validation block start (validate the "itm" values) */ /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { let retval = true; if (num(txt("#monthly")) === 0) { $("#dropoff_div").addClass("x-hide"); $("#dropoff_date_div").addClass("x-hide"); } else { $("#dropoff_div").removeClass("x-hide"); if (txt("#dropoff") !== "Y") { if (txt("#dropoff") === "") retval = false; $("#dropoff_date_div").addClass("x-hide"); } else { $("#dropoff_date_div").removeClass("x-hide"); } } return retval; } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-irstax"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let itm = (existingid!==false) ? MAR.liabilities.get("irstax",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } let no_cancel = false; if (MAR.getOpt(itm,`_auto_created`,``)=== `Y`) { no_cancel = (MAR.getOpt(itm,`verified`,``) !== `Y`); } revealclass=""; console.warn("localopts", localopts); console.warn("itm", itm); /** * standard starting block - END */ let h = ""; h += frm.htitle("IRS Debt").render(); let extra = (typeof mar.tmp_bubble_explanation_irs === "string" && mar.tmp_bubble_explanation_irs !== "") ? `

    ${mar.tmp_bubble_explanation_irs}` : ``; extra = ``; // h += frm.elaine(`${na}, please answer the questions about your IRS debt below.${extra}`,"er").render(); h += frm.elaine(`${na}, You declared you have a debt with the IRS, we need info to calculate your ability to close this loan.${extra}`,"er").render(); // h += "
    "; // JC - CW - elaine added div /** * In Name Of block */ h += (function(){ let h = ""; VAL = (itm) ? itm.inomask : 1; // prefill if itm is not false h += frm.hr().render(); h += "
    Who is obligated on this payment?
    "; if (itm) { h += innameofBlock(VAL, true, itm, {single : true}) } else { h += innameofBlock(1, true, false, {single : true}); } return h; })().wrap("
    ","
    "); h += (function(){ let h = ""; // h += "
    What is current balance?
    "; VAL = (itm) ? itm.balance : '5000'; h += frm.slider("balance","Current balance",VAL,"","",function(){ oc(); }, { v00 : '0', v50 : '1000', v50_inc : '50', v75 : '5000', v75_inc : '250', v100 : '100000', v100_inc : '200', start_val : '1000' }).render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; // h += "
    What is monthly payment?
    "; VAL = (itm) ? itm.monthly : '200'; h += frm.slider("monthly","Monthly payment",VAL,"","",function(){ oc(); }, { v00 : '0', v50 : '100', v50_inc : '5', v75 : '500', v75_inc : '10', v100 : '10000', v100_inc : '100', start_val : '1000' }).render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; // h += "
    What is monthly payment?
    "; VAL = (itm) ? itm.has_payment_plan : ''; h += frm.hr().render(); h += frm.yn3("has_payment_plan","Do you have a payment plan in place?",VAL,"","",function(){ oc(); }, { }).render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; // h += "
    What is monthly payment?
    "; VAL = (itm) ? itm.has_made_2_timely_payments : ''; h += frm.hr().render(); h += frm.yn3("has_made_2_timely_payments","Have you made 2 timely payments?",VAL,"","",function(){ oc(); }, { }).render(); return h; })().wrap("
    ","
    ") if (mar.WE_ARE_FROM_LOI) { /** * payoff options */ h += (function() { let h = ""; VAL = MAR.getOpt(itm, "omit_opt",""); h += ``; VAL = MAR.liabilities.get_payoff_omit_action(itm, "keep"); h += frm.hr().render(); h += frm.radio("omit_act",`(LO Only) What payoff option do you use (${itm.omit_opt})`,VAL,"","",function(){ oc(); },{ keep : "Keep i.e. do not omit or payoff", // omit_notpaying : "Omit - Bor. has Not Paid for over 12m", omit_less10pmts : "Omit - less than 10 payments", // "payoff_down-to-omit" : "Omit - first Pay-Down < 10 PMTs", payoff : "Pay-Off to $0 At Closing" // payoff_before : "Pay Down to $0 Before Closing" // payoff_after : "Account To Be Perm. Closed" }).render(); return h; })(); } // h += (function(){ // let h = ""; // VAL = (itm) ? itm.inomask : 1; // prefill if itm is not false // // h += frm.hr().render(); // h += "
    Who is obligated on this payment?
    "; // // if (itm) { // h += innameofBlock(VAL, true, itm) // } else { // h += innameofBlock(1, true, false); // } // // return h; // })(); h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ if (oc() === false) return; /** * validation & reveal block end */ if (existingid === false) { itm = {}; itm.uuid = mar.fmt.uuid(); } itm.type = "irstax"; itm.name = "IRS Debt"; itm.monthly = txt("#monthly"); itm.balance = txt("#balance"); itm.payment = num(itm.monthly); itm.has_payment_plan = yn3("#has_payment_plan"); itm.has_made_2_timely_payments = yn3("#has_made_2_timely_payments"); itm.enc_payment = itm.payment; itm.monthly = itm.payment; itm.enc_monthly = itm.payment; itm.enc_payment = itm.payment; itm.inomask = innameofBlock_read(); // itm.inomask = innameofBlock_from_number(applicantnum); //innameofBlock_read(); itm.payup = ((num(itm.balance) / num(itm.monthly)) > 10) ? "more10" : "less10"; itm.omit = "N"; itm.verified = "Y"; itm.cstatus = "ok"; if (mar.WE_ARE_FROM_LOI) { itm.omit_opt = txt("#omit_opt"); MAR.liabilities.set_payoff_omit_from_action(itm, radio("omit_act")); } /** * validation block start (validate the "itm" values) */ if (itm.balance === "") { mar.tip(".help-button","warning","You need to tell us the balance.","top"); return; } if (itm.monthly === "") { mar.tip(".help-button","warning","You need to tell us the monthly amount.","top"); return; } if (itm.has_payment_plan === "") { mar.tip(".help-button","warning","You need to tell us the if you have a payment plan.","top"); return; } if (itm.has_payment_plan === "Y" && itm.has_made_2_timely_payments === "") { mar.tip(".help-button","warning","You need to tell us the if you have a made 2 timely payments.","top"); return; } /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { let retval = true; let has_payment_plan = yn3("#has_payment_plan"); if (has_payment_plan === "Y") { $("#has_made_2_timely_payments_div").removeClass("x-hide"); } else { $("#has_made_2_timely_payments_div").addClass("x-hide"); } return retval; } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); if (no_cancel) { // auto generated and therefore no cancel $(`#body-container .prev-button`).addClass(`x-hide`); } //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); // super new ones! mar.pg["liabilities-creditcard"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; getLiabilities_v2(); var applicantsObj = getApplicantsNames_v2(); let itm = (existingid!==false) ? MAR.liabilities.get("creditcard",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 revealclass = ""; var thisBorrower = na; var thisMainCard = (itm !== false) ? MAR.getOpt(itm, "name", "Unknown") : ""; console.warn("localopts", localopts); console.warn("itm", itm); if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } if (MAR.getOpt(itm,`_auto_newloan`,``)=== `Y`) { // here } /** * standard starting block - END */ let h = ""; h += frm.htitle("Credit Card").render(); // h += (function(){ // let VAL = (itm) ? innoblock_2_whosname(itm.inomask) : []; // // let h = ""; // // h += frm.hr().render(); // h += "
    In whose name is this property?
    Multiple answers are possible.
    "; // // var applicantsObj = getApplicantsNames_v2(); // var slimmedObj = {}; // for (let i=0; i`; // h += `
    Borrower :
    ${applicantsObj[VAL[0]].Name}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // h += ``; // h += `
    Lending institution name :
    ${itm.name}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // h += ``; // h += `
    Balance :
    ${elaineui.format("cur",itm.q_balance)}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // // h += ``; // h += `
    Payment :
    ${elaineui.format("cur",itm.q_monthly)}
    `; // // return h; // })().wrap("
    ","
    "); h += "
    "; // JC - CW - elaine added div /** * In Name Of block */ h += (function(){ let h = ""; VAL = (itm) ? itm.inomask : 1; // prefill if itm is not false h += "
    Who is obligated on this payment?
    "; if (itm) { h += innameofBlock(VAL, true, itm) } else { h += innameofBlock(1, true, false); } return h; })().wrap("
    ","
    "); h += frm.hr().render(); VAL = (itm) ? itm.signer : ''; h += frm.radio("signer","Does somone else, not on this loan, pay this liability?",VAL,"","",function(){ oc(); },{ borrower : "I pay this liability", coborrower : "Someone else is responsible" }).render(); h += "
    "; h += frm.elaine("What is the first name of the borrower?","er").render(); VAL = (itm) ? itm.innameof : ''; h += frm.txt("innameof","",VAL,"e.g. John Smith","",function(){ thisBorrower = txt("#innameof"); $("#thisBorrower12").text(thisBorrower); }).render(); h += "
    "; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.made_all_payments : 'N'; h += frm.yn3("made_all_payments","Can you prove with 12 months bank statements that "+thisBorrower+" has made all the payments?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end // h += "
    "; // reveal - start (with validation to previous field) // // h += frm.hr().render(); // //// h += frm.elaine("Paying off this "+thisMainCard+" will likely increase your maximum loan amount from { { amount before payoff } } to { { amount after payoff } }","er").render(); // h += frm.elaine("Paying off this "+thisMainCard+" will likely increase your maximum loan amount.","er").render(); // // VAL = (itm) ? itm.pay_off_before_close : 'N'; // h += frm.yn3("pay_off_before_close","Do you want to pay this "+thisMainCard+" card off before closing?",VAL,"","",function(){},{}).render(); // // h += "
    "; // reveal - end if (mar.WE_ARE_FROM_LOI) { /** * payoff options */ h += (function() { let h = ""; VAL = MAR.getOpt(itm, "omit_opt",""); h += ``; VAL = MAR.liabilities.get_payoff_omit_action(itm, "keep"); h += frm.hr().render(); h += frm.radio("omit_act",`(LO Only) What payoff option do you use (${itm.omit_opt})`,VAL,"","",function(){ oc(); },{ keep : "Keep i.e. do not omit or payoff", omit_notpaying : "Omit - Bor. has Not Paid for over 12m", omit_less10pmts : "Omit - less than 10 payments", "payoff_down-to-omit" : "Omit - first Pay-Down < 10 PMTs", payoff : "Pay-Off to $0 At Closing", payoff_before : "Pay Down to $0 Before Closing", payoff_after : "Account To Be Perm. Closed" }).render(); return h; })(); } h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if(radio("signer") === 'coborrower'){ if (validation == "innameof") { val = txt("#innameof"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the name of the main borrower.","top"); return; } } } else if(radio("signer") === 'borrower'){ // }else{ mar.tip(".help-button","warning","You need to tell us the applicants status on this credit card.","top"); return; } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid || $(`#balance`).length > 0) { if (!existingid) itm = {}; itm.balance = txt("#balance"); itm.monthly = txt("#monthly"); itm.name = txt("#institution"); itm.verified = `Y`; if (itm.balance.trim().length == 0 || num(itm.balance) === 0) { mar.tip(".help-button","warning","Please fill in the balance","top"); return; } if (itm.monthly.trim().length == 0 || num(itm.monthly) === 0) { mar.tip(".help-button","warning","Please fill in the payment","top"); return; } if (itm.name.trim().length == 0) { mar.tip(".help-button","warning","Please tell us the name of the institution","top"); return; } } itm.type = "creditcard"; itm.signer = radio("signer"); itm.innameof = txt("#innameof"); itm.inomask = innameofBlock_read(); itm.made_all_payments = yn3("#made_all_payments"); itm.verified = `Y`; itm.pay_off_before_close = ""; // yn3("#pay_off_before_close"); if (mar.WE_ARE_FROM_LOI) { itm.omit_opt = txt("#omit_opt"); MAR.liabilities.set_payoff_omit_from_action(itm, radio("omit_act")); } /** * validation block start (validate the "itm" values) */ if (itm.innameof.trim().length == 0 && itm.signer == "coborrower") { mar.tip(".help-button","warning","Please tell us the name of the co-borrower","top"); return; } /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { //if they say it is a co-borrower then we ask teh first name of teh borrower console.warn('radio("signer"): '+radio("signer")); if( radio("signer") === 'coborrower'){ thisBorrower = txt("#innameof"); $("#thisBorrower12").text(thisBorrower); $("#signerIsNotMainHolder").removeClass("x-hide"); $("#cosigner_proof_div").removeClass("x-hide"); $("#cosigner_proof_div.xx-revealdiv").removeClass("xx-revealdiv").addClass("x-revealdiv"); }else{ $("#signerIsNotMainHolder").addClass("x-hide"); $("#cosigner_proof_div").addClass("x-hide"); $("#cosigner_proof_div.x-revealdiv").removeClass("x-revealdiv").addClass("xx-revealdiv"); $("#innameof").val(''); thisBorrower = na; $("#thisBorrower12").text(thisBorrower); } } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-studentloan"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid!==false) ? MAR.liabilities.get("studentloan",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 var thisBorrower = na; console.warn("localopts", localopts); console.warn("inc", inc); console.warn("itm", itm); if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } /** * standard starting block - END */ let h = ""; h += frm.htitle("Student Loan").render(); h += "
    "; h += frm.liabilities.header(itm); h += "

    "; // h += (function() { // let h = ""; // let VAL = (itm) ? innoblock_2_whosname(MAR.getOpt(itm, "inomask",1)) : [0]; // var applicantsObj = getApplicantsNames_v2(); // // h += ``; // h += `
    Borrower :
    ${applicantsObj[VAL[0]].Name}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // h += ``; // h += `
    Lending institution name :
    ${itm.name}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // h += ``; // h += `
    Balance :
    ${elaineui.format("cur",itm.q_balance)}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // // h += ``; // h += `
    Payment :
    ${elaineui.format("cur",itm.q_monthly)}
    `; // // return h; // })().wrap("
    ","
    "); /** * In Name Of block */ h += (function(){ let h = ""; VAL = (itm) ? itm.inomask : 1; // prefill if itm is not false h += "
    Who is obligated on this payment?
    "; if (itm) { h += innameofBlock(VAL, true, itm, { single : true }) } else { h += innameofBlock(1, true, false, { single : true }); } return h; })().wrap("
    ","
    "); h += frm.hr().render(); VAL = (itm) ? itm.to_completion_payment_schedule : 'N'; h += frm.yn3("to_completion_payment_schedule","Are you on a payment schedule that will pay off the student loan completely?",VAL,"","",function(){},{}).render(); h += '
    '; h += "
    "; // reveal - start VAL = (itm) ? itm.situation : ''; if (typeof VAL !== "string" || VAL === ``) { MAR.ifOpt(itm, "paytype",function(val){ if (val === "def") { VAL = "deferred"; } if (val === "ibr") { VAL = "incomebased"; } }); } let DEFVAL = VAL; h += frm.radio("situation","Select option that best describes your current situation:",VAL,"","",function(){ //oc(); },{ deferred : "My loan is still in deferment, I don't have to start paying yet.", incomebased : "My loan payment is based on my income, I don't pay the full amount yet." }).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); if (mar.WE_ARE_FROM_LOI) { /** * payoff options */ h += (function() { let h = ""; VAL = MAR.getOpt(itm, "omit_opt",""); if (typeof VAL !== "string" || VAL === ``) { let val = DEFVAL; if (val === "deferred") { VAL = "stu_5pc"; } } h += ``; VAL = MAR.liabilities.get_payoff_omit_action(itm, "keep"); h += frm.radio("omit_act",`(LO Only) What payoff option do you use (${itm.omit_opt})`,VAL,"","",function(){ oc(); },{ keep : "Keep i.e. do not omit or payoff", omit_notpaying : "Omit - Bor. has Not Paid for over 12m", omit_less10pmts : "Omit - less than 10 payments", "payoff_down-to-omit" : "Omit - first Pay-Down < 10 PMTs", payoff : "Pay-Off to $0 At Closing", payoff_before : "Pay Down to $0 Before Closing", payoff_after : "Account To Be Perm. Closed", stu_5pc : "EDU $0 payment - use 0.5%" }).render(); return h; })(); } //elaine // h += frm.elaine("Paying off this student loan will likely increase your maximum loan amount from { { amount before payoff } } to { { amount after payoff } }","er").render(); // h += frm.elaine("Paying off this student loan will likely increase your maximum loan amount.","er").render(); // // h += "
    "; // JC - CW - elaine added div // // // VAL = (itm) ? itm.pay_off_before_close : 'N'; // h += frm.yn3("pay_off_before_close","Do you want to pay this student loan off before closing?",VAL,"","",function(){},{}).render(); // // // h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if (validation == "situation") { val = radio("situation"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us your current situation.","top"); return; } } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid || $(`#balance`).length > 0) { if (!existingid) itm = {}; itm.balance = txt("#balance"); itm.monthly = txt("#monthly"); itm.name = txt("#institution"); itm.verified = `Y`; if (itm.balance.trim().length == 0 || num(itm.balance) === 0) { mar.tip(".help-button","warning","Please fill in the balance","top"); return; } if (itm.monthly.trim().length == 0 || num(itm.monthly) === 0) { mar.tip(".help-button","warning","Please fill in the payment","top"); return; } if (itm.name.trim().length == 0) { mar.tip(".help-button","warning","Please tell us the name of the institution","top"); return; } } itm.type = "studentloan"; itm.to_completion_payment_schedule = yn3("#to_completion_payment_schedule"); itm.situation = radio("situation"); itm.pay_off_before_close = ""; // yn3("#pay_off_before_close"); itm.inomask = innameofBlock_read(); itm.verified = "Y"; if (mar.WE_ARE_FROM_LOI) { itm.omit_opt = txt("#omit_opt"); MAR.liabilities.set_payoff_omit_from_action(itm, radio("omit_act")); } /** * validation block start (validate the "itm" values) */ if (itm.situation.trim().length == 0) { mar.tip(".help-button","warning","You need to tell us your current situation.","top"); return; } /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { //if they say it is a co-borrower then we ask teh first name of teh borrower /* console.warn('radio("signer"): '+radio("signer")); if( radio("signer") === 'coborrower'){ thisBorrower = txt("#innameof"); $("#thisBorrower12").text(thisBorrower); $("#signerIsNotMainHolder").removeClass("x-hide"); $("#cosigner_proof_div").removeClass("x-hide"); $("#cosigner_proof_div.xx-revealdiv").removeClass("xx-revealdiv").addClass("x-revealdiv"); }else{ $("#signerIsNotMainHolder").addClass("x-hide"); $("#cosigner_proof_div").addClass("x-hide"); $("#cosigner_proof_div.x-revealdiv").removeClass("x-revealdiv").addClass("xx-revealdiv"); $("#innameof").val(''); thisBorrower = na; $("#thisBorrower12").text(thisBorrower); } */ } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-carloan"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid!==false) ? MAR.liabilities.get("carloan",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 var thisBorrower = na; console.warn("localopts", localopts); console.warn("inc", inc); console.warn("itm", itm); if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } /** * standard starting block - END */ let h = ""; h += frm.htitle("Car Loan").render(); if (MAR.getOpt(itm,`_auto_newloan`,``)=== `Y`) { // here } h += "
    "; h += frm.liabilities.header(itm); h += "

    "; // h += (function() { // let h = ""; // let VAL = (itm) ? innoblock_2_whosname(MAR.getOpt(itm, "inomask",1)) : [0]; // var applicantsObj = getApplicantsNames_v2(); // // h += ``; // h += `
    Borrower :
    ${applicantsObj[VAL[0]].Name}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // h += ``; // h += `
    Lending institution name :
    ${itm.name}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // h += ``; // h += `
    Balance :
    ${elaineui.format("cur",itm.q_balance)}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // // h += ``; // h += `
    Payment :
    ${elaineui.format("cur",itm.q_monthly)}
    `; // // return h; // })().wrap("
    ","
    "); h += "
    "; // JC - CW - elaine added div /** * In Name Of block */ h += (function(){ let h = ""; VAL = (itm) ? itm.inomask : 1; // prefill if itm is not false h += "
    Who is obligated on this payment?
    "; if (itm) { h += innameofBlock(VAL, true, itm) } else { h += innameofBlock(1, true, false); } return h; })().wrap("
    ","
    "); h += frm.hr().render(); VAL = (itm) ? itm.signer : ''; let signertype = MAR.getOpt(itm, `signertype`,``); if (VAL !== `` && signertype === `b`) { VAL = `coborrower_b`; } h += frm.radio("signer","Does somone else, not on this loan, pay this liability?",VAL,"","",function(){ oc(); },{ borrower : "I pay this liability privately", coborrower : "Someone else pays this liability", coborrower_b : "It is paid through a business" }).render(); h += "
    "; h += frm.elaine("What is the first name of the borrower?","er").render(); VAL = (itm) ? itm.innameof : ''; h += frm.txt("innameof","",VAL,"e.g. John Smith","",function(){ thisBorrower = txt("#innameof"); $("#thisBorrower12").text(thisBorrower); }).render(); ; h += "
    "; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.made_all_payments : 'N'; h += frm.yn3("made_all_payments","Can you prove with 12 months bank statements that "+thisBorrower+" has made all the payments?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); // h += frm.elaine("Since you have less that 10 payments left, we may omit this liability if you will keep sufficient cash in your bank account as reserves after closing.","er").render(); // h += "
    Attention: Your maximum loan amount will likely increase.
    "; // VAL = (itm) ? itm.omit_payment : 'N'; // h += frm.yn3("omit_payment","Do you want to omit this car payment?",VAL,"","",function(){},{}).render(); // h += "
    "; // reveal - end if (mar.WE_ARE_FROM_LOI) { /** * payoff options */ h += (function() { let h = ""; VAL = MAR.getOpt(itm, "omit_opt",""); h += ``; VAL = MAR.liabilities.get_payoff_omit_action(itm, "keep"); h += frm.radio("omit_act",`(LO Only) What payoff option do you use (${itm.omit_opt})`,VAL,"","",function(){ oc(); },{ keep : "Keep i.e. do not omit or payoff", omit_notpaying : "Omit - Bor. has Not Paid for over 12m", omit_less10pmts : "Omit - less than 10 payments", "payoff_down-to-omit" : "Omit - first Pay-Down < 10 PMTs", payoff : "Pay-Off to $0 At Closing", payoff_before : "Pay Down to $0 Before Closing", payoff_after : "Account To Be Perm. Closed" }).render(); return h; })(); } h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if(radio("signer") === 'coborrower' || radio("signer") === 'coborrower_b'){ if (validation == "innameof") { val = txt("#innameof"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the name of the main borrower.","top"); return; } } } else if(radio("signer") === 'borrower'){ // }else{ mar.tip(".help-button","warning","You need to tell us the applicants status on this loan.","top"); return; } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid || $(`#balance`).length > 0) { if (!existingid) itm = {}; itm.balance = txt("#balance"); itm.monthly = txt("#monthly"); itm.name = txt("#institution"); itm.verified = `Y`; if (itm.balance.trim().length == 0 || num(itm.balance) === 0) { mar.tip(".help-button","warning","Please fill in the balance","top"); return; } if (itm.monthly.trim().length == 0 || num(itm.monthly) === 0) { mar.tip(".help-button","warning","Please fill in the payment","top"); return; } if (itm.name.trim().length == 0) { mar.tip(".help-button","warning","Please tell us the name of the institution","top"); return; } } itm.type = "carloan"; itm.signer = radio("signer"); itm.signertype = ``; if (itm.signer === `coborrower_b`) { itm.signer = `coborrower`; itm.signertype = `b`; } itm.inomask = innameofBlock_read(); itm.innameof = txt("#innameof"); itm.made_all_payments = yn3("#made_all_payments"); itm.verified = `Y`; itm.omit_payment = ""; //yn3("#omit_payment"); if (mar.WE_ARE_FROM_LOI) { itm.omit_opt = txt("#omit_opt"); MAR.liabilities.set_payoff_omit_from_action(itm, radio("omit_act")); } /** * validation block start (validate the "itm" values) */ if (itm.innameof.trim().length == 0 && itm.signer == "coborrower") { mar.tip(".help-button","warning","Please tell us the name of the co-borrower","top"); return; } /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { //if they say it is a co-borrower then we ask teh first name of teh borrower console.warn('radio("signer"): '+radio("signer")); if( radio("signer") === 'coborrower'){ thisBorrower = txt("#innameof"); // $("#thisBorrower12").text(thisBorrower); $(`#innameof_lbl`).html(`What is the first name of the borrower?`); $(`#signer_lbl`).html(`Can you prove with 12 months bank statements that ${thisBorrower} has made all the payments?`) $("#signerIsNotMainHolder").removeClass("x-hide"); $("#cosigner_proof_div").removeClass("x-hide"); $("#cosigner_proof_div.xx-revealdiv").removeClass("xx-revealdiv").addClass("x-revealdiv"); } else if( radio("signer") === 'coborrower_b'){ thisBorrower = txt("#innameof"); // $("#thisBorrower12").text(thisBorrower); $(`#innameof_lbl`).html(`What is the name of the business?`); $(`#signer_lbl`).html(`Do these parments appear on your business tax returns?`) $("#signerIsNotMainHolder").removeClass("x-hide"); $("#cosigner_proof_div").removeClass("x-hide"); $("#cosigner_proof_div.xx-revealdiv").removeClass("xx-revealdiv").addClass("x-revealdiv"); } else { $("#signerIsNotMainHolder").addClass("x-hide"); $("#cosigner_proof_div").addClass("x-hide"); $("#cosigner_proof_div.x-revealdiv").removeClass("x-revealdiv").addClass("xx-revealdiv"); $("#innameof").val(''); thisBorrower = na; $("#thisBorrower12").text(thisBorrower); } } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-carlease"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid!==false) ? MAR.liabilities.get("carlease",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 var thisBorrower = na; console.warn("localopts", localopts); console.warn("inc", inc); console.warn("itm", itm); if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } if (MAR.getOpt(itm,`_auto_newloan`,``)=== `Y`) { // here } /** * standard starting block - END */ let h = ""; h += frm.htitle("Car Lease").render(); h += "
    "; h += frm.liabilities.header(itm); h += "

    "; // h += (function() { // let h = ""; // let VAL = (itm) ? innoblock_2_whosname(MAR.getOpt(itm, "inomask",1)) : [0]; // var applicantsObj = getApplicantsNames_v2(); // // h += ``; // h += `
    Borrower :
    ${applicantsObj[VAL[0]].Name}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // h += ``; // h += `
    Lending institution name :
    ${itm.name}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // h += ``; // h += `
    Balance :
    ${elaineui.format("cur",itm.q_balance)}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // // h += ``; // h += `
    Payment :
    ${elaineui.format("cur",itm.q_monthly)}
    `; // // return h; // })().wrap("
    ","
    "); h += "
    "; // JC - CW - elaine added div /** * In Name Of block */ h += (function(){ let h = ""; VAL = (itm) ? itm.inomask : 1; // prefill if itm is not false h += "
    Who is obligated on this payment?
    "; if (itm) { h += innameofBlock(VAL, true, itm) } else { h += innameofBlock(1, true, false); } return h; })().wrap("
    ","
    "); h += frm.hr().render(); VAL = (itm) ? itm.signer : ''; h += frm.radio("signer","Does somone else, not on this loan, pay this liability?",VAL,"","",function(){ oc(); },{ borrower : "I pay this liability", coborrower : "Someone else is responsible" }).render(); h += "
    "; h += frm.elaine("What is the first name of the borrower?","er").render(); VAL = (itm) ? itm.innameof : ''; h += frm.txt("innameof","",VAL,"e.g. John Smith","",function(){ thisBorrower = txt("#innameof"); $("#thisBorrower12").text(thisBorrower); }).render(); h += "
    "; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.made_all_payments : 'N'; h += frm.yn3("made_all_payments","Can you prove with 12 months bank statements that "+thisBorrower+" has made all the payments?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) // h += frm.elaine("Since you have less that 10 payments left, we may omit this liability if you will keep sufficient cash in your bank account as reserves after closing.","er").render(); // h += "
    Attention: Your maximum loan amount will likely increase.
    "; // VAL = (itm) ? itm.omit_payment : 'N'; // h += frm.yn3("omit_payment","Do you want to omit this car payment?",VAL,"","",function(){},{}).render(); // h += "
    "; // reveal - end if (mar.WE_ARE_FROM_LOI) { /** * payoff options */ h += (function() { let h = ""; VAL = MAR.getOpt(itm, "omit_opt",""); h += ``; VAL = MAR.liabilities.get_payoff_omit_action(itm, "keep"); h += frm.hr().render(); h += frm.radio("omit_act",`(LO Only) What payoff option do you use (${itm.omit_opt})`,VAL,"","",function(){ oc(); },{ keep : "Keep i.e. do not omit or payoff", omit_notpaying : "Omit - Bor. has Not Paid for over 12m" }).render(); return h; })(); } h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if(radio("signer") === 'coborrower'){ if (validation == "innameof") { val = txt("#innameof"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the name of the main borrower.","top"); return; } } } else if(radio("signer") === 'borrower'){ // }else{ mar.tip(".help-button","warning","You need to tell us the applicants status on this loan.","top"); return; } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid || $(`#balance`).length > 0) { if (!existingid) itm = {}; itm.balance = txt("#balance"); itm.monthly = txt("#monthly"); itm.name = txt("#institution"); itm.verified = `Y`; if (itm.balance.trim().length == 0 || num(itm.balance) === 0) { mar.tip(".help-button","warning","Please fill in the balance","top"); return; } if (itm.monthly.trim().length == 0 || num(itm.monthly) === 0) { mar.tip(".help-button","warning","Please fill in the payment","top"); return; } if (itm.name.trim().length == 0) { mar.tip(".help-button","warning","Please tell us the name of the institution","top"); return; } } itm.type = "carlease"; itm.signer = radio("signer"); itm.innameof = txt("#innameof"); itm.inomask = innameofBlock_read(); itm.made_all_payments = yn3("#made_all_payments"); itm.omit_payment = ""; //yn3("#omit_payment"); if (mar.WE_ARE_FROM_LOI) { itm.omit_opt = txt("#omit_opt"); MAR.liabilities.set_payoff_omit_from_action(itm, radio("omit_act")); } /** * validation block start (validate the "itm" values) */ if (itm.innameof.trim().length == 0 && itm.signer == "coborrower") { mar.tip(".help-button","warning","Please tell us the name of the co-borrower","top"); return; } /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { //if they say it is a co-borrower then we ask teh first name of teh borrower console.warn('radio("signer"): '+radio("signer")); if( radio("signer") === 'coborrower'){ thisBorrower = txt("#innameof"); $("#thisBorrower12").text(thisBorrower); $("#signerIsNotMainHolder").removeClass("x-hide"); $("#cosigner_proof_div").removeClass("x-hide"); $("#cosigner_proof_div.xx-revealdiv").removeClass("xx-revealdiv").addClass("x-revealdiv"); //$("#body-container").scrollTo("max",600); }else{ $("#signerIsNotMainHolder").addClass("x-hide"); $("#cosigner_proof_div").addClass("x-hide"); $("#cosigner_proof_div.x-revealdiv").removeClass("x-revealdiv").addClass("xx-revealdiv"); $("#innameof").val(''); thisBorrower = na; $("#thisBorrower12").text(thisBorrower); } } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-instalmentloan"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid!==false) ? MAR.liabilities.get("instalmentloan",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 var thisBorrower = na; console.warn("localopts", localopts); console.warn("inc", inc); console.warn("itm", itm); if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } /** * standard starting block - END */ let h = ""; let bubble_text = "An installment loan is a fixed-sum borrowed amount repaid over scheduled monthly payments. For instance, a $2,000 loan with 12 monthly payments of $200, including interest."; let il_text = ``; let no_cancel = false; if (MAR.getOpt(itm,`_auto_newloan`,``)=== `Y`) { h += frm.htitle("New line of credit you will close").render(); bubble_text = `You declared you will close a new line of credit between now and closing of the loan. We need loan info to calculate your ability to close this loan.`; no_cancel = (MAR.getOpt(itm,`verified`,``) !== `Y`); // bubble_text += `

    You specified in your declarations that you would be taking a new loan that was not disclosed in thie application. Please enter the details of this new loan below.` } else if (MAR.getOpt(itm,`_auto_bor_dp`,``)=== `Y`) { h += frm.htitle("Borrowed Downpayment").render(); bubble_text = `You declared you will borrow money for this transaction. We need monthly payment info to see if you can qualify for this loan. Unlike a gift most loan programs do not allow borrowed funds to be used as a downpayment.`; il_text = `Relation to borrower`; no_cancel = (MAR.getOpt(itm,`verified`,``) !== `Y`); // bubble_text += `

    You specified in your declarations that you would be borrowing a part of the downpayment. Please enter the value and the monthly scheduled payment below.` } else { h += frm.htitle("Installment Loan").render(); } h += frm.elaine(bubble_text,"er").render(); // JC - CW - elaine added "er" if (MAR.getOpt(itm,`_auto_newloan`,``) === `Y`) { // if (MAR.getOpt(itm,`verified`,``) !== `Y`) { VAL = `instalmentloan`; h += frm.radio("action","This loan was setup based on your declaration would this be?",VAL,"","",function(){ let act = radio(`action`); elaineui.swalprompt({ title : "Warning", txt : `
    `+ `Are you sure`+ `
    `+ `
    `, ok : `Yes`, okfn : function() { if (act === `remove`) { alert(`ok removing`); } else { let pgname = MAR.getOpt(MAR.liabilities.pagenames, act, ``); if (pgname !== ``) { let page = `#liabilities-${pgname}.0.${existingid}`; mvc.go(page); } } }, cancel : "Cancel", cls : "middleInfoPopup", //"middleInfoPopup" - "midelinfopopupOneButton", opts : { closeOnClickOutside : false, closeOnEsc : false } }); },{ instalmentloan : "An Installment Loan", carloan : "A Car Loan", carlease : "A Car Lease", creditcard : "A Creditcard" // remove : "I will not be taking a new line of credit - please remove this", }).render(); // } } h += "
    "; h += frm.liabilities.header(itm, il_text); h += "

    "; // h += (function() { // let h = ""; // let VAL = (itm) ? innoblock_2_whosname(MAR.getOpt(itm, "inomask",1)) : [0]; // var applicantsObj = getApplicantsNames_v2(); // // h += ``; // h += `
    Borrower :
    ${applicantsObj[VAL[0]].Name}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // h += ``; // h += `
    Lending institution name :
    ${itm.name}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // h += ``; // h += `
    Balance :
    ${elaineui.format("cur",itm.q_balance)}
    `; // // return h; // })().wrap("
    ","
    "); // h += (function() { // let h = ""; // // h += ``; // h += `
    Payment :
    ${elaineui.format("cur",itm.q_monthly)}
    `; // // return h; // })().wrap("
    ","
    "); h += "
    "; // JC - CW - elaine added div h += "
    "; /** * In Name Of block */ h += (function(){ let h = ""; VAL = (itm) ? itm.inomask : 1; // prefill if itm is not false h += frm.hr().render(); h += "
    Who is obligated on this payment?
    "; if (itm) { h += innameofBlock(VAL, true, itm) } else { h += innameofBlock(1, true, false); } return h; })().wrap("
    ","
    "); h += frm.hr().render(); VAL = (itm) ? itm.signer : ''; h += frm.radio("signer","Does somone else, not on this loan, pay this liability?",VAL,"","",function(){ oc(); },{ borrower : "I pay this liability", coborrower : "Someone else is responsible" }).render(); h += "
    "; h += frm.elaine("What is the first name of the borrower?","er").render(); VAL = (itm) ? itm.innameof : ''; h += frm.txt("innameof","",VAL,"e.g. John Smith","",function(){ thisBorrower = txt("#innameof"); $("#thisBorrower12").text(thisBorrower); }).render(); h += "
    "; h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.made_all_payments : 'N'; h += frm.yn3("made_all_payments","Can you prove with 12 months bank statements that "+thisBorrower+" has made all the payments?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end // h += "
    "; // reveal - start (with validation to previous field) // h += frm.hr().render(); // h += frm.elaine("Since you have less that 10 payments left, we may omit this liability if you will keep sufficuent funds in your bank account as reserves after closing.","er").render(); // h += "
    Attention: Your maximum loan amount will likely increase.
    "; // VAL = (itm) ? itm.omit_payment : 'N'; // h += frm.yn3("omit_payment","Do you want to omit this installment loan?",VAL,"","",function(){},{}).render(); // h += "
    "; // reveal - end if (mar.WE_ARE_FROM_LOI) { /** * payoff options */ h += (function() { let h = ""; VAL = MAR.getOpt(itm, "omit_opt",""); h += ``; VAL = MAR.liabilities.get_payoff_omit_action(itm, "keep"); h += frm.hr().render(); h += frm.radio("omit_act",`(LO Only) What payoff option do you use (${itm.omit_opt})`,VAL,"","",function(){ oc(); },{ keep : "Keep i.e. do not omit or payoff", omit_notpaying : "Omit - Bor. has Not Paid for over 12m", omit_less10pmts : "Omit - less than 10 payments", "payoff_down-to-omit" : "Omit - first Pay-Down < 10 PMTs", payoff : "Pay-Off to $0 At Closing", payoff_before : "Pay Down to $0 Before Closing", payoff_after : "Account To Be Perm. Closed" }).render(); return h; })(); } // h += "
    "; // reveal - start (with validation to previous field) // // h += frm.hr().render(); // //// h += frm.elaine("Paying off this installment loan will likely increase your maximum loan amount from { { amount before payoff } } to { { amount after payoff } }","er").render(); // h += frm.elaine("Paying off this installment loan will likely increase your maximum loan amount.","er").render(); // // VAL = (itm) ? itm.pay_off_before_close : 'N'; // h += frm.yn3("pay_off_before_close","Do you want to pay this installment loan off before closing?",VAL,"","",function(){},{}).render(); // // // h += "
    " // reveal - end h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { if(radio("signer") === 'coborrower'){ if (validation == "innameof") { val = txt("#innameof"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the name of the main borrower.","top"); return; } } } else if(radio("signer") === 'borrower'){ // }else{ mar.tip(".help-button","warning","You need to tell us the applicants status on this loan.","top"); return; } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid || $(`#balance`).length > 0) { if (!existingid) itm = {}; itm.balance = txt("#balance"); itm.monthly = txt("#monthly"); itm.name = txt("#institution"); itm.verified = `Y`; if (itm.balance.trim().length == 0 || num(itm.balance) === 0) { mar.tip(".help-button","warning","Please fill in the balance","top"); return; } if (itm.monthly.trim().length == 0 || num(itm.monthly) === 0) { mar.tip(".help-button","warning","Please fill in the payment","top"); return; } if (itm.name.trim().length == 0) { mar.tip(".help-button","warning","Please tell us the name of the institution","top"); return; } } itm.type = "instalmentloan"; itm.signer = radio("signer"); itm.innameof = txt("#innameof"); itm.inomask = innameofBlock_read(); itm.made_all_payments = yn3("#made_all_payments"); itm.omit_payment = ""; //yn3("#omit_payment"); itm.pay_off_before_close = ""; //yn3("#pay_off_before_close"); if (mar.WE_ARE_FROM_LOI) { itm.omit_opt = txt("#omit_opt"); MAR.liabilities.set_payoff_omit_from_action(itm, radio("omit_act")); } /** * validation block start (validate the "itm" values) */ if (itm.innameof.trim().length == 0 && itm.signer == "coborrower") { mar.tip(".help-button","warning","Please tell us the name of the co-borrower","top"); return; } /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { //if they say it is a co-borrower then we ask teh first name of teh borrower console.warn('radio("signer"): '+radio("signer")); if( radio("signer") === 'coborrower'){ thisBorrower = txt("#innameof"); $("#thisBorrower12").text(thisBorrower); $("#signerIsNotMainHolder").removeClass("x-hide"); $("#cosigner_proof_div").removeClass("x-hide"); $("#cosigner_proof_div.xx-revealdiv").removeClass("xx-revealdiv").addClass("x-revealdiv"); }else{ $("#signerIsNotMainHolder").addClass("x-hide"); $("#cosigner_proof_div").addClass("x-hide"); $("#cosigner_proof_div.x-revealdiv").removeClass("x-revealdiv").addClass("xx-revealdiv"); $("#innameof").val(''); thisBorrower = na; $("#thisBorrower12").text(thisBorrower); } } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); if (no_cancel) { // auto generated and therefore no cancel $(`#body-container .prev-button`).addClass(`x-hide`); } // if (MAR.getOpt(itm,`_auto_newloan`,``)=== `Y`) { // $(`.x-lia-warning`).html("
    new loan warning
    "); // $(`.x-lia-warning`).removeClass(`x-hide`); // } // if (MAR.getOpt(itm,`_auto_bor_dp`,``)=== `Y`) { // $(`.x-lia-warning`).html("
    borrowed downpayment warning
    "); // $(`.x-lia-warning`).removeClass(`x-hide`); // } //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-childsupport"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid!==false) ? MAR.liabilities.get("childsupport",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 console.warn("localopts", localopts); console.warn("inc", inc); console.warn("itm", itm); if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } /** * standard starting block - END */ let h = ""; h += frm.htitle("Child Support").render(); h += frm.elaine("In the declaration you indicated that you have to pay child support. Please let us know the details of the payment plan.","er").render(); h += "
    "; // JC - CW - elaine added div /** * In Name Of block */ h += (function(){ let h = ""; VAL = (itm) ? itm.inomask : 1; // prefill if itm is not false h += "
    Who is obligated on this payment?
    "; if (itm) { h += innameofBlock(VAL, true, itm, {single : true }) } else { h += innameofBlock(1, true, false, {single : true }); } return h; })().wrap("
    ","
    "); h += frm.hr().render(); h += "
    Child support monthly payment:
    "; VAL = (itm) ? itm.payment : '1000'; h += frm.slider("payment","Monthly Payment:",VAL,"","",function(){ }, { v00 : '0', v50 : '1000', v50_inc : '50', v75 : '5000', v75_inc : '100', v100 : '10000', v100_inc : '200', start_val : '1000' }).render(); h += "
    "; /* h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += frm.elaine("Since you have less that 10 payments left, we may omit this liability if you will keep { { payment x terms } } in your bank account as reserves after closing.","er").render(); VAL = (itm) ? itm.omit_payment : 'N'; h += frm.yn("omit_payment","Do you want to omit this car payment?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end */ // if (mar.WE_ARE_FROM_LOI) { // // /** // * payoff options // */ // h += (function() { // let h = ""; // VAL = MAR.getOpt(itm, "omit_opt",""); // h += ``; // // VAL = MAR.liabilities.get_payoff_omit_action(itm, "keep"); // h += frm.radio("omit_act",`(LO Only) What payoff option do you use (${itm.omit_opt})`,VAL,"","",function(){ // oc(); // },{ // keep : "Keep i.e. do not omit or payoff", // omit_notpaying : "Omit - Bor. has Not Paid for over 12m", // omit_less10pmts : "Omit - less than 10 payments", // "payoff_down-to-omit" : "Omit - first Pay-Down < 10 PMTs", // payoff : "Pay-Off to $0 At Closing", // payoff_before : "Pay Down to $0 Before Closing", // payoff_after : "Account To Be Perm. Closed" // }).render(); // // return h; // })(); // } h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation == "payment") { val = txt("#payment"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the amount of monthly payment.","top"); return; } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "childsupport"; itm.name = "Child Support"; itm.payment = txt("#payment"); itm.monthly = txt("#payment"); itm.inomask = innameofBlock_read(); //itm.omit_payment = yn("#omit_payment"); itm.omit_opt = ""; itm.payoff = false; itm.omit = ""; // if (mar.WE_ARE_FROM_LOI) { // itm.omit_opt = txt("#omit_opt"); // MAR.liabilities.set_payoff_omit_from_action(itm, radio("omit_act")); // } /** * validation block start (validate the "itm" values) */ /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-alimony"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid!==false) ? MAR.liabilities.get("alimony",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 console.warn("localopts", localopts); console.warn("inc", inc); console.warn("itm", itm); if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } /** * standard starting block - END */ let h = ""; h += frm.htitle("alimony").render(); h += frm.elaine("In the declaration you indicated that you have to pay alimony. Please let us know the details of the payment plan.","er").render(); h += "
    "; // JC - CW - elaine added div h += "
    "+na+"'s alimony payment:
    "; VAL = (itm) ? itm.payment : '1000'; h += frm.slider("payment","Monthly Payment:",VAL,"","",function(){ }, { v00 : '0', v50 : '1000', v50_inc : '50', v75 : '5000', v75_inc : '100', v100 : '10000', v100_inc : '200', start_val : '1000' }).render(); h += "
    "; /* h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += frm.elaine("Since you have less that 10 payments left, we may omit this liability if you will keep { { payment x terms } } in your bank account as reserves after closing.","er").render(); VAL = (itm) ? itm.omit_payment : 'N'; h += frm.yn("omit_payment","Do you want to omit this car payment?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end */ h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation == "payment") { val = txt("#payment"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the amount of monthly payment.","top"); return; } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "alimony"; itm.payment = txt("#payment"); //itm.omit_payment = yn("#omit_payment"); /** * validation block start (validate the "itm" values) */ /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-irstax1"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid!==false) ? MAR.liabilities.get("irstax",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 console.warn("localopts", localopts); console.warn("inc", inc); console.warn("itm", itm); if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } /** * standard starting block - END */ let h = ""; h += frm.htitle("IRS Debt").render(); h += frm.elaine("In the declaration you indicated that you have an IRS debt. Please let us know the details of the payment plan.","er").render(); h += "
    "; // JC - CW - elaine added div h += "
    "+na+"'s IRS Debt:
    "; VAL = (itm) ? itm.balance : '40000'; h += frm.slider("balance","Current Balance:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000' }).render(); h += "
    "; h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.payment : '1000'; h += frm.slider("payment","Monthly Payment:",VAL,"","",function(){ }, { v00 : '0', v50 : '1000', v50_inc : '10', v75 : '5000', v75_inc : '25', v100 : '10000', v100_inc : '100', start_val : '1000' }).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.three_or_more_payments : 'N'; h += frm.yn("three_or_more_payments","Have you made three or more monthly payments on this payment plan?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end // h += "
    "; // reveal - start (with validation to previous field) // // h += frm.hr().render(); // // h += frm.elaine("Paying off this IRS Debt will likely increase your maximum loan amount from { { amount before payoff } } to { { amount after payoff } }","er").render(); // // VAL = (itm) ? itm.pay_off_before_close : 'N'; // h += frm.yn("pay_off_before_close","Do you want to pay this IRS Debt off before closing?",VAL,"","",function(){},{}).render(); // // // h += "
    " // reveal - end /* h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += frm.elaine("Since you have less that 10 payments left, we may omit this liability if you will keep { { payment x terms } } in your bank account as reserves after closing.","er").render(); VAL = (itm) ? itm.omit_payment : 'N'; h += frm.yn("omit_payment","Do you want to omit this car payment?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end */ h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation == "balance") { val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the current balance of this debt.","top"); return; } } if (validation == "payment") { val = txt("#payment"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the amount of monthly payment.","top"); return; } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "irstax"; itm.balance = txt("#balance"); itm.payment = txt("#payment"); itm.three_or_more_payments = yn("#three_or_more_payments"); itm.pay_off_before_close = ""; // yn("#pay_off_before_close"); /** * validation block start (validate the "itm" values) */ if (itm.balance.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the current balance of this debt.","top"); return; } if (itm.payment.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the amount of monthly payment.","top"); return; } /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-other"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let existinguuid = false; (function convert_uuid() { if (typeof existingid === "string" && existingid.indexOf("-") > -1) { let liability_index = MAR.liabilities.getByUUID(existingid, true); if (liability_index !== false) { existinguuid = existingid; existingid = liability_index; } else { existingid = false; } } })(); let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid!==false) ? MAR.liabilities.get("other",existingid) : false; existinguuid = MAR.getOpt(itm, "uuid", existinguuid); let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 var debt_type = 'alimony debt'; var isThereOther = false; console.warn("localopts", localopts); console.warn("inc", inc); console.warn("itm", itm); if (itm === false || MAR.getOpt(itm, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } /** * standard starting block - END */ let h = ""; h += frm.htitle("Not reported").render(); h += frm.elaine("Is there anything we may be forgetting about?","er").render(); h += "
    "; // JC - CW - elaine added div VAL = (itm) ? itm.any_other_debt : 'N'; h += frm.yn("any_other_debt","Do you have any other debt not showing on the credit report?",VAL,"","",function(){ // show the rest of the questions // if(yn('#any_other_debt') == 'Y'){ isThereOther = true; }else{ isThereOther = false; } },{}).render(); h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.other_debt_type : ''; h += frm.radio("other_debt_type","The debt not showing on my credit report is:",VAL,"","",function(){ //oc(); //set the debt_type var on change switch(radio("other_debt_type")) { case 'alimony': debt_type = 'alimony debt'; break; case 'childsupport': debt_type = 'child support debt'; break; case 'privateequityloan': debt_type = 'private equity loan debt'; break; default: } $('.debt_type_span').text(debt_type); },{ alimony : "Alimony", childsupport : "Child support", privateequityloan : "Private equity loan" }).render(); h += "
    "; // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += "
    "+na+"'s "+debt_type+":
    "; VAL = (itm) ? itm.balance : '40000'; h += frm.slider("balance","Current Balance:",VAL,"","",function(){ }, { v00 : '0', v50 : '30000', v50_inc : '500', v75 : '100000', v75_inc : '5000', v100 : '400000', v100_inc : '20000' }).render(); h += "
    "; h += "
    "; // reveal - end h += "
    "; // reveal - start (with validation to previous field) VAL = (itm) ? itm.payment : '1000'; h += frm.slider("payment","Monthly Payment:",VAL,"","",function(){ }, { v00 : '0', v50 : '1000', v50_inc : '50', v75 : '5000', v75_inc : '100', v100 : '10000', v100_inc : '200', start_val : '1000' }).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.three_or_more_payments : 'N'; h += frm.yn("three_or_more_payments","Have you made three or more timely payments on this payment plan?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end // h += "
    "; // reveal - start (with validation to previous field) // // h += frm.hr().render(); // // h += frm.elaine("Paying off this "+debt_type+" will likely increase your maximum loan amount from { { amount before payoff } } to { { amount after payoff } }","er").render(); // // VAL = (itm) ? itm.pay_off_before_close : 'N'; // h += frm.yn("pay_off_before_close","Do you want to pay this "+debt_type+" off before closing?",VAL,"","",function(){},{}).render(); // // // h += "
    " // reveal - end /* h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); h += frm.elaine("Since you have less that 10 payments left, we may omit this liability if you will keep { { payment x terms } } in your bank account as reserves after closing.","er").render(); VAL = (itm) ? itm.omit_payment : 'N'; h += frm.yn("omit_payment","Do you want to omit this car payment?",VAL,"","",function(){},{}).render(); h += "
    " // reveal - end */ h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation == "any_other_debt") { val = yn("#any_other_debt"); if (val == 'N' ) { mvc.go("#liabilities-home"); //mar.tip(".help-button","warning","You need to tell us what type of debt this is.","top"); return; } } if (validation == "other_debt_type") { val = radio("other_debt_type"); if (val.trim().length == 0 ) { mvc.go("#liabilities-home"); //mar.tip(".help-button","warning","You need to tell us what type of debt this is.","top"); return; } } if (validation == "balance") { val = txt("#balance"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the current balance of this debt.","top"); return; } } if (validation == "payment") { val = txt("#payment"); if (val.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the amount of monthly payment.","top"); return; } } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.type = "other"; itm.other_debt_type = txt("#other_debt_type"); itm.balance = txt("#balance"); itm.payment = txt("#payment"); itm.three_or_more_payments = yn("#three_or_more_payments"); itm.pay_off_before_close = ""; // yn("#pay_off_before_close"); /** * validation block start (validate the "itm" values) */ if (itm.balance.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the current balance of this debt.","top"); return; } if (itm.payment.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us the amount of monthly payment.","top"); return; } /** * validation block end */ if (existinguuid !== false) { MAR.liabilities.setByUUID(existinguuid, itm); } else { MAR.liabilities.set(itm.type, existingid, itm); } mar.answers._events = ["application:rq_recalc_selected_loan"]; mar.fakesave(); mar.tmp_lia_return_after_manual_edit(); }),"cancel",frm.addfunction(function(){ mar.tmp_lia_return_after_manual_edit(); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { } let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["liabilities-summary"] = (function(){ var html = ""; function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } function checkNum(num){ var val = 0; if($.isNumeric( num )){ val = num } val = '$'+addCommas(Math.round(val)); return val; } function render(pg, localopts) { let VAL = ""; let h = ""; h += frm.htitle("Liability summary").render(); h += "
    "; h += frm.h2("Please review your liabilities stated for this real estate transaction.","").render(); h += "Click items below to edit."; h += "
    "; try { getIncome_v2(); console.warn("mar.answers.v2.liabilities: ", mar.answers.v2.liabilities); console.warn("mar.answers.v2: ", mar.answers.v2); console.warn("mar.answers.v2.liabilities: ", mar.answers.v2.liabilities); console.warn("mar.answers.v2.liabilities.length: "+mar.answers.v2.liabilities.length); // for some reason it seems as if the actual assets are not getting into the [items] array of the particular item type. so this loop won't work // not to mention it is having an issue getting teh obj nodes uisng bracket syntax var size = Object.keys(mar.answers.v2.liabilities).length; console.warn("size: "+size); console.warn("size: ",size); for (let a=0; a < size; a++) { //console.warn("a"+a); //console.warn("mar.answers.v2.assets[a]", mar.answers.v2.assets[a]); var liabilities = mar.answers.v2.liabilities[a].items; if(liabilities){ //console.warn("ar.answers.v2.assets[a].items ", mar.answers.v2.assets[a].items); for (let i=0; i < liabilities.length; i++) { h += frm.summaryline("applicant "+a, assets[i].type, { body : [ { key : "Monthly salary", val : checkNum(liabilities[i].total)} ] }, false).render(); h += "
    "; } }else{ console.warn("no items ?"); } } //h += "
    " + JSON.stringify(mar.answers.v2.income,null,4)+"
    "; h += "
    "; } catch(E) { console.warn('error trying to draw liabilities list ', E); } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){mvc.go("#liabilities-home"); }),"close",frm.addfunction(function(){mvc.go("#liabilities-home");}),"mar.help()"); h = Mustache.render(h,localopts); let or = function(){ if (getScenario_data("__liabilities_unin_passed","N") != "Y") { setScenario_data("__liabilities_next_page",window.location.hash); mvc.go("#up-next-liabilities") return; } /* $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); */ // setTimeout(function(){ // $('#calendar').calendar({ // width : $(".x_content").width(), // height : $(".x_content").width(), // zIndex: 1, // weekArray: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // monthArray: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'], // data: null // }); // },500) } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); /* * * end liabilities pages * */ /* file /ui/app/js/pages.upnexts.js , last updated 1702252393778*/ mar.pg["up-next-employmentinfo"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { mar.pg_accesscontrollerfn = function() { return "open"; } let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: EMPLOYMENT DETAILS
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    In this section, tell us details about your employment. This way, we'll verify if your income is consistent enough to sustain payments on this loan.
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "income" } })(); /* * this is a screenfor up next popups * */ mar.pg["up-next"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; /*var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); /=let itm = (existingid) ? MAR.liabilities.get("evaluatesection",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1*/ mar.pg_accesscontrollerfn = function() { return "open"; } /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: WISHLIST
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; // h += "
    Let's gather information about you and your mortgage needs. To find out what loan options are available to you. All in under 20 mins!
    "; h += "
    No client is the same, and so no rate is the same. Find out what you are eligible for in just a few minutes, without the need for your social or date of birth.
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ //h += uihelpers.cbuttonbar("","","","","mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "scenario" } })(); mar.pg["up-next-wishlist"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; /*var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); /=let itm = (existingid) ? MAR.liabilities.get("evaluatesection",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1*/ mar.pg_accesscontrollerfn = function() { return "open"; } /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: LOAN SCENARIO
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; // h += "
    Let's gather information about you and your mortgage needs to find out what loan options are available to you. All in under 20 mins!
    "; h += "
    No client is the same, and so no rate is the same. Find out what you are eligible for in just a few minutes, without the need for your social or date of birth.
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); if (getScenario_data("visited_what_to_expect","N") === "N") { setScenario_data("visited_what_to_expect","Y"); // mar.fakesave(function(){ // mvc.go("#up-next-expect"); // }); // return; } if (getScenario_data("visited_up_next_wishlist","N") === "Y") { mvc.go("#scenario-timeframe"); return; } setScenario_data("visited_up_next_wishlist","Y"); mar.fakesave(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "scenario" } })(); mar.pg["up-next-income-inbetween"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; mar.pg_accesscontrollerfn = function() { return "open"; } /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: "+names+" INCOME
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    In this section, you'll answer questions about how you earn money, and how much you earn from each source. Let's keep things rolling!
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "income" } })(); mar.pg["up-next-income"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /*var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); /=let itm = (existingid) ? MAR.liabilities.get("evaluatesection",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1*/ mar.pg_accesscontrollerfn = function() { return "open"; } /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: "+names+" INCOME
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    In this section, you'll answer questions about how you earn money, and how much you earn from each source. Let's keep things rolling!
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); if (getScenario_data("authorizations-credit-ed_0_passed","N") != "Y") { mvc.go("#authorizations-credit-ed."+(MAR.applicants.count() -1)) return; } $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "income" } })(); mar.pg["up-next-liabilities"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /*var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); /=let itm = (existingid) ? MAR.liabilities.get("evaluatesection",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1*/ let nextpage = getScenario_data("__liabilities_next_page",""); if (nextpage === "") { nextpage = "#liabilities-home"; } mar.pg_accesscontrollerfn = function() { return "open"; } /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: "+names+" LIABILITIES
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    A few answers about your payment obligations are needed. " + "Your maximum loan amount depends on your income vs your payment obligations. " + "The less obligations, generally, the more you can borrow." + "
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "income" } })(); mar.pg["up-next-homework"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; /*var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); /=let itm = (existingid) ? MAR.liabilities.get("evaluatesection",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1*/ mar.pg_accesscontrollerfn = function() { return "open"; } /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: HOMEWORK
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Let's get started uploading your documents, you can always come back and do this later, but the sooner you complete these tasks, the faster you get the loan.
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "homework" } })(); mar.pg["up-next-prescan"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; /*var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); /=let itm = (existingid) ? MAR.liabilities.get("evaluatesection",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1*/ mar.pg_accesscontrollerfn = function() { return "open"; } /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: PRE SCAN YOUR LOAN OPTIONS
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Review actual numbers! Tweak along and recalibrate the loan to best fit your situation in a few minutes.
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); let sp = mar.isallowed_scenario("#up-next-prescan"); if (typeof sp === "string") { mvc.go(sp); return; } $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "scenario" } })(); mar.pg["up-next-personalinfo"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; mar.pg_accesscontrollerfn = function() { return "open"; } h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: PERSONAL INFO
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    In this section, we will gather your personal data, which will help us produce a home loan pre-qualification in no-time!
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); let sp = mar.isallowed_assets("#up-next-personalinfo"); if (typeof sp === "string") { mvc.go(sp); return; } $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "personalinfo" } })(); mar.pg["up-next-declarations"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; let h = ""; mar.pg_accesscontrollerfn = function() { return "open"; } h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: DECLARATIONS
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    In this next section we will drill deeper into your credit history.
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); // let sp = mar.isallowed_assets("#up-next-declarations"); // if (typeof sp === "string") { // mvc.go(sp); // return; // } $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "personalinfo" } })(); mar.pg["up-next-personalinfonext"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; /*var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); /=let itm = (existingid) ? MAR.liabilities.get("evaluatesection",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1*/ mar.pg_accesscontrollerfn = function() { return "open"; } let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: PERSONAL INFO "+na+"
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    In this section, we will gather your personal data, which will help us produce a home loan pre-qualification in no-time!
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "personalinfo" } })(); mar.pg["up-next-expect"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; /*var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); /=let itm = (existingid) ? MAR.liabilities.get("evaluatesection",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1*/ mar.pg_accesscontrollerfn = function() { return "open"; } /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    Here's WHAT TO EXPECT.
    "; h += "
    ";//row start h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    ";//leftside end h += "
    "; h += "
    GUIDED
    "; h += "
    Answer simple questions guided by your loan officer.
    "; h += "
    ";//rightside end h += "
    "; //row holder end h += "
    ";//row holder start h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    ";//leftside end h += "
    "; h += "
    EASY
    "; h += "
    Easy communication and document upload.
    "; h += "
    ";//rightside end h += "
    "; //row holder end h += "
    ";//row holder start h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    ";//leftside end h += "
    "; h += "
    SECURE
    "; h += "
    Your data is encrypted and always protected.
    "; h += "
    ";//rightside end h += "
    "; //row holder end /* h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: PRE SCAN YOUR LOAN OPTIONS
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Review actual numbers! Tweak along and recalibrate the loan to best fit your situation in a few minutes.
    "; h += "
    "; h += "
    "; */ h += "
    Get Started
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); if (mar.BACKOFFICE != null && mar.BACKOFFICE == "Y") { setTimeout(function(){ swal("Loading.."); setTimeout(function(){ //$("#body-inner").css("display","none"); $("#body-inner").css("opacity","0.8"); setTimeout(function(){ swal("Loading.."); //$("#body-inner").css("display","block") $("#body-inner").css("opacity","1"); setTimeout(function(){ swal.close(); },1) },1) },1) },500) } $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "scenario" } })(); mar.pg["up-next-assets"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { mar.pg_accesscontrollerfn = function() { return "open"; } let oc = function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("What does cash to close mean?").render()+ "It is the total amount of money you will need to close on your loan transaction. It includes your down payment (if purchasing a new home) and other costs, like: "+ "
    "+ "
    "+ "
    "+ "* Homeowners Insurance"+ "
    "+ "* Taxes"+ "
    "+ "* Title Fees"+ "
    "+ "* Lender Fees"+ "
    "+ "* Prepaid Interest"+ "
    "+ "
    "+ "Was this helpful?" swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "YES", call : { text: "CALL NOW", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); }; let oc2 = function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Which assets should I include?").render()+ "To close on this transaction we need to show that you have enough assets to pay for your down payment (if purchasing a new home) "+ "and for all other costs associated with closing on your transaction. "+ "In some loan programs it is required to have financial reserves after closing."+ "
    "+ "
    "+ frm.htitle("Common asset types include:").render()+ "
    "+ "* Cash Accounts (checking, saving, certificates of deposit, money market, etc.)"+ "
    "+ "* Investment Accounts (stocks / bonds, brokerage, etc.)"+ "
    "+ "* Retirement Accounts (IRA, 401K, 403b)"+ "
    "+ "
    "+ "Was this helpful?" swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "YES", call : { text: "CALL NOW", value: "call", closeModal: false } } }) .then((act) => { if (act == "call") { mar.pghelpers.callLoanOfficer(); } }); }; let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: ASSETS
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    We'll need to make sure we have enough cash to close for your financing. Please disclose your assets and accounts on the next page.
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); if (getScenario_data("authorizations-credit-ed_0_passed","N") != "Y") { mvc.go("#authorizations-credit-ed."+(MAR.applicants.count() -1)) return; } let sp = mar.isallowed_assets("#up-next-assets"); if (typeof sp === "string") { mvc.go(sp); return; } $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "assets" } })(); mar.pg["up-next-lox"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; MAR.appnav.loanWasNotImportedAndNotSubmitted = function() { return true;} /** * standard starting block - END */ mar.pg_accesscontrollerfn = function() { return "open"; } let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: HOMEWORK
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; if (MAR.appnav.loanWasNotImportedAndNotSubmitted() === true) { h += "
    By clicking continue you will submit your loan application. " + "

    If you want, you can check the app again. " + "Click the top left menu button, and jump to a section, " + "then come back here and click continue.
    "; } else { h += "
    Using nothing more than your cellphone you will be able to complete most tasks " + "we have for you to get approved for your home loan.

    If you can't finish it now, don't worry, " + "Elaine will schedule a new date and remind you what's needed.
    "; } h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "homework" } })(); mar.pg["logged-out"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; MAR.appnav.loanWasNotImportedAndNotSubmitted = function() { return true;} mar.pg_accesscontrollerfn = function() { return "open"; } /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    LOGGED OUT
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    You have successfully logged out your portal. Click below to log back in.
    "; h += "
    "; h += "
    "; h += "
    Log In
    "; h += "
    "; h += "
    "; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "homework" } })(); /* file /ui/app/js/pages.declarations.js , last updated 1702470014336*/ mar.pg["declarations-p1"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name.split(" ")[0]; var nas = (applicantnum === 0) ? "Your" : getApplicantsNames_v2(applicantnum).Names var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); var itm = getDeclaration_v2(applicantnum) has_visited = false; let revealclass = (has_visited) ? "" : "x-hide x-revealdiv"; // reveal .1 console.warn("localopts", localopts); console.warn("inc", inc); console.warn("itm", itm); console.warn("has_visited: "+has_visited); console.warn("revealclass: "+revealclass); let HAVEYOU = (applicantnum == 0) ? "Have you" : `${na}, have you`; let DOYOU = (applicantnum == 0) ? "Do you" : `${na}, do you`; let TELLUS = (applicantnum == 0) ? "Tell us" : `${na}, tell us`; /**I * standard starting block - END */ let h = ""; h += frm.htitle("Declarations 1/3").render(); // h += frm.elaine(TELLUS+` a bit about ${na}'s credit history, so that we can select your qualifying loan options.`,"er").render(); h += frm.elaine(`Tell us a bit about ${nas} credit history, so that we can select your qualifying loan options.`,"er").render(); h += "
    "; // JC - CW - elaine added div //h += "
    "; VAL = (itm) ? itm.credit_has_judgements : ''; h += frm.yn3("credit_has_judgements",DOYOU+" have any outstanding judgements against you? ",VAL,"","",function(){ //revealTip('credit_has_judgements'); oc(); if(txt("#credit_has_judgements") == "Y") { $(".info-credit_has_judgements").trigger("click") } }, {}).render(); h += "
    "; // h +="
    "; // h += frm.h2("LO Tip: Medical judgement up to XXXX can be excluded.").render(); h += "
    ";//end loTipBlock h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); //h += "
    Have you declared bankruptcy within the past 7 years?
    "; VAL = (itm) ? itm.credit_has_bancruptcy : ''; h += frm.yn3("credit_has_bancruptcy",HAVEYOU+" declared bankruptcy within the past 7 years?",VAL,"","",function(){ oc("#credit_has_bancruptcy_div"); }, {}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += "
    "; h +="
    "; var tipSt = `FNMA: BK 7 BK 11 4 yrs (or 2 extin) yrs from discharge / dismissal | BK 13 2 yrs from discharge / 4 yrs (or 2 extin) from dismissal. `+ `FHA: BK 7 BK: 2 yrs (or 1 extin) | BK 13: 1 yr of good pmt history since payout | extin: same but add court order. `+ `VA: BK 7 BK 11: 2 yrs from discharge (or 1 yr extin) | BK 13: 1 yr payment on time and written permission from court to enter mortgage app,`+ ` if extin underwrite manually`; // "FNMA: BK 7 BK 11 (or 2 extin) yrs from discharge / dismissal | BK 13 "+ // "2 yrs from discharge / 4 yrs (or 2 extin) from dismissal. FHA: BK 7 BK 11: 2 yrs from discharge | BK 13: 2 (1 extin) yrs from discharge | extin: "+ // "after resume normal pmts. VA: BK 7 BK 11: 2 yrs from discharge | BK: 1 yr payment on time and written permission from court to enter mortgage app."; h += frm.h2("LO Tip (Bankruptcy rules 12/23)
    "+tipSt).render(); h += "
    ";//end loTipBlock h += "
    "; h += frm.elaine("Ok sorry to hear that. What kind of bancruptcy was it?","").render(); VAL = (itm) ? itm.credit_has_bancruptcy_chapter : ''; h += frm.radio("credit_has_bancruptcy_chapter","",VAL,"","",function(){ oc(); },{ 'c7' : "Chapter 7", 'c11' : "Chapter 11", 'c13' : "Chapter 13" }).render(); VAL = (itm) ? itm.credit_has_bancruptcy_resolved : ''; if (VAL === "resolved") { /** * backwardcompatibility */ itm.credit_has_bancruptcy_resolved = "discharged"; VAL = "discharged"; } h += frm.radio("credit_has_bancruptcy_resolved","
    Is the bankruptcy resolved?",VAL,"","",function(){ oc(); },{ 'unresolved' : "No", 'dismissed' : "Dismissed", 'discharged' : "Discharged" }).render(); h += "
    "; VAL = (itm) ? itm.credit_has_bancruptcy_resolution_date : ''; h += frm.txt("credit_has_bancruptcy_resolution_date","
    What was your settlement date?",VAL,"","",function(){ let elm = $("#credit_has_bancruptcy_resolution_date") if (new Date(elm.val()) > new Date()) { elm.val(elm.prop("max")); } oc(); }, "date").render(); h += "
    " // end credit_has_bancruptcy_reveal -just an inner holder h += "
    " // end credit_has_bancruptcy_reveal -just an inner holder h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); // h += "
    In the past 7 years, have you had a property foreclosed on OR given up a title or deed in lieu thereof?
    "; VAL = (itm) ? itm.credit_has_forclosures : ''; // h += frm.yn3("credit_has_forclosures",HAVEYOU+" had property foreclosed upon or given title or deed in lieu thereof in the last 7 years?",VAL,"","",function(){ h += frm.yn3("credit_has_forclosures",HAVEYOU+" conveyed title to any property in lieu of foreclosure in the past 7 years?",VAL,"","",function(){ //revealTip('credit_has_forclosures'); oc(); }, {}).render(); h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += "
    "; VAL = (itm) ? itm.credit_has_forclosures__date : ''; h += frm.txt("credit_has_forclosures__date","
    What is the dismissal date of the foreclosure?",VAL,"","",function(){ let elm = $("#credit_has_forclosures__date") if (new Date(elm.val()) > new Date()) { elm.val(elm.prop("max")); } oc(); }, "date").render(); h += "
    "; h +="
    "; var fcStr = "FNMA: FC 7 (3 extin) yrs from completion date | extin rules: go. Freddy to avoid max 90 LTV / Limited ℅ only / primary only. "+ " FHA: 3 yrs from completion. VA: 2 yrs from completion."+ "

    "+ "(Short Sale / Deed -in-Lieu of FC)
    FNMA: SS 4 (2 extin) yrs from completion date. FHA: 3 yrs from completion. "+ "VA: 2 yrs from completion."; h += frm.h2("LO Tip (Foreclosure Rules 7/13/23)
    "+fcStr).render(); h += "
    ";//end loTipBlock h += "
    " // end credit_has_forclosures_reveal inner h += "
    " // reveal - end //let oldhtml = $("#declarations_simple").html(); //h += oldhtml; h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ if (txt("#credit_has_judgements") == "") { mar.tip(".help-button","warning","You need to tell us if you have any outstanding judgements.","top"); return; } if (txt("#credit_has_judgements") == "Y") { } if (txt("#credit_has_bancruptcy") == "") { mar.tip(".help-button","warning","You need to tell us if you have had a bancruptcy in the last 7 years.","top"); return; } if (txt("#credit_has_bancruptcy") == "Y") { var valr = radio("credit_has_bancruptcy_chapter"); if (valr == "" || valr == undefined) { mar.tip(".help-button","warning","You need to tell us what kind of bancruptcy it was.","top"); return; } var valr = radio("credit_has_bancruptcy_resolved"); if (valr == "" || valr == undefined) { mar.tip(".help-button","warning","You need to tell whether the bancruptcy is resolved.","top"); return; } if (valr == "resolved") { valr = txt("#credit_has_bancruptcy_resolution_date"); if (valr == "" || valr == undefined) { mar.tip(".help-button","warning","You need to tell us when the bancruptcy was settled. It will be impossible to get a loan if you are in the middle of a bankruptcy","top"); return; } } } if (txt("#credit_has_forclosures") == "") { mar.tip(".help-button","warning","You need to tell us if you have had a property foreclosed onor given up a title or deed in lieu thereof in the last 7 years.","top"); return; } if (txt("#credit_has_forclosures") == "Y") { var valf = txt("#credit_has_forclosures__date"); if (valf == "" || valf == undefined) { mar.tip(".help-button","warning","You need to tell us when the foreclosure was completed.","top"); return; } } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.credit_has_judgements = txt("#credit_has_judgements"); itm.credit_has_bancruptcy = txt("#credit_has_bancruptcy"); itm.credit_has_bancruptcy_chapter = radio("credit_has_bancruptcy_chapter"); itm.credit_has_bancruptcy_resolved = radio("credit_has_bancruptcy_resolved"); itm.credit_has_bancruptcy_resolution_date = txt("#credit_has_bancruptcy_resolution_date"); itm.credit_has_forclosures = txt("#credit_has_forclosures"); itm.credit_has_forclosures__date = txt("#credit_has_forclosures__date"); /** * validation block start (validate the "itm" values) */ // if (itm.credit_has_judgements.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us if you have any outstanding judgements.","top"); // return; // } // // if (itm.credit_has_bancruptcy.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us if you have had a bancruptcy in the last 7 years.","top"); // return; // } // // if (itm.credit_has_bancruptcy == 'Y' && itm.credit_has_bancruptcy_chapter.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us what kind of bancruptcy it was.","top"); // return; // } // // if (itm.credit_has_bancruptcy == 'Y' && itm.credit_has_bancruptcy_resolution_date == undefined ) { // mar.tip(".help-button","warning","You need to tell us when the bancruptcy was settled.","top"); // return; // } // // if (itm.credit_has_forclosures.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us if you have had a property foreclosed onor given up a title or deed in lieu thereof in the last 7 years.","top"); // return; // } // // if (itm.credit_has_forclosures == 'Y' && itm.credit_has_forclosures__date == undefined ) { // mar.tip(".help-button","warning","You need to tell us when the foreclosure was completed.","top"); // return; // } /** * validation block end */ for (x in itm) { MAR.declarations.set(applicantnum,x,itm[x]); } setScenario_data("__scenario_declarep1_"+applicantnum+"_passed","Y"); mar.fakesave(function(){ if (mar.WE_ARE_FROM_LOI === true) { MAR.encompass.app_check_diffs_borrower_profileSync(mar.ID, applicantnum); } }); mvc.go("#declarations-p2."+applicantnum); }),"back",frm.addfunction(function(){ if (applicantnum === 0) { let f_ratequote = MAR.getOpt(mar.accesscontroller.features(), "ratequote", false); // if (f_ratequote === false) { // mvc.go("#scenario-housingbudget."+applicantnum); // return; // } mvc.go("#scenario-ratequote."+applicantnum); } else { mvc.go("#scenario-veteran."+applicantnum); } }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let passedValidation = function(){ /** * validation & reveal block start */ // if (validation == "credit_has_bancruptcy_chapter") { // //note you check the bancruptcy first.. .if it is N then it doesnt matter. // // console.warn('checking credit_has_bancruptcy_chapter!'); // var valb = txt("#credit_has_bancruptcy"); // if (valb.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us if you have had a bancruptcy in the last 7 years.","top"); // return; // } // if(valb == 'Y'){ // var valr = radio("credit_has_bancruptcy_chapter"); // //console.warn('credit_has_bancruptcy_chapter: '+valr); // if (valr == "" || valr == undefined) { // mar.tip(".help-button","warning","You need to tell us what kind of bancruptcy it was.","top"); // return; // } // valr = txt("#credit_has_bancruptcy_resolution_date"); // //console.warn('credit_has_bancruptcy_resolution_date: '+valr); // if (valr == "" || valr == undefined) { // mar.tip(".help-button","warning","You need to tell us when the bancruptcy was settled.","top"); // return; // } // } // if (validation == "credit_has_forclosures__date") { // val = txt("#credit_has_forclosures"); // // if(val == 'Y'){ // // var valf = txt("#credit_has_forclosures__date"); // //console.warn('credit_has_forclosures__date: '+valf); // if (valf == "" || valf == undefined) { // mar.tip(".help-button","warning","You need to tell us when the foreclosure was completed.","top"); // return; // } // // } // } // } /** * validation & reveal block end */ return true; } let oc = function(__scrolltop) { let _open = function($elm,fn) { $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); if (__scrolltop && typeof __scrolltop == "string") { $("#body-container").scrollTo(__scrolltop,200); } else { $("#body-container").scrollTo("max",200); } }); } let _close = function($elm,fn) { $elm.slideUp(function(){ $elm.addClass("x-hide").addClass("x-revealdiv"); $elm.css("display","none"); }); } /** * judgements */ if (txt("#credit_has_judgements") !== "") { _open($("#credit_has_bancruptcy_div")) } else { return; } if (txt("#credit_has_judgements") == "Y") { if (__ROLE == "lo" || mar.loauth.islo()){ _open($("#credit_has_judgements_tip")) } } else { _close($("#credit_has_judgements_tip")) } /** * bankcruptcy */ if (txt("#credit_has_bancruptcy") !== "") { _open($("#credit_has_forclosures_div")) } if (txt("#credit_has_bancruptcy") == "Y") { _open($("#credit_has_bancruptcyID")) if (__ROLE == "lo" || mar.loauth.islo()){ _open($("#credit_has_bancruptcy_tip")) } _open($("#credit_has_bancruptcy_reveal")) if (radio("credit_has_bancruptcy_resolved") !== "unresolved" && radio("credit_has_bancruptcy_resolved") !== "") { if (radio("credit_has_bancruptcy_resolved") === "dismissed") { $(".settlement").html("dismissal"); } if (radio("credit_has_bancruptcy_resolved") === "discharged") { $(".settlement").html("discharge"); } _open($("#credit_has_bancruptcy_resolution_date_reveal")) } else { _close($("#credit_has_bancruptcy_resolution_date_reveal")) } } else { _close($("#credit_has_bancruptcyID")) _close($("#credit_has_bancruptcy_tip")) _close($("#credit_has_bancruptcy_reveal")) _close($("#credit_has_bancruptcy_resolution_date_reveal")) } /** * forclosures */ if (txt("#credit_has_forclosures") == "Y") { _open($("#credit_has_forclosuresID")) if (__ROLE == "lo" || mar.loauth.islo()){ _open($("#credit_has_forclosures_tip")) } _open($("#credit_has_forclosures_reveal")) } else { _close($("#credit_has_forclosuresID")) _close($("#credit_has_forclosures_tip")) _close($("#credit_has_forclosures_reveal")) } } let or = function(){ let sp = mar.isallowed_scenario("#declarations-p1."+applicantnum); if (typeof sp === "string") { mvc.go(sp); return; } if (getScenario_data("__scenario_declareupnext_"+applicantnum+"_passed","") !== `Y`) { mvc.go(`#up-next-declarations.${applicantnum}`); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); var now = new Date(); let maxDate = now.toISOString().substring(0,10); $('#credit_has_bancruptcy_resolution_date').prop('max', maxDate); $('#credit_has_forclosures__date').prop('max', maxDate); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { oc(true); } }, quick : false }); $(".info-credit_has_judgements").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Attention").render()+ "It's worth noting that court-ordered judgements usually must be paid off before you are able to get a mortgage. "+ "If you're on a payment plan, we have to use the payment to calculate your maximum mortgage amount."; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Got it" } }); }); $(".info-credit_has_judgements").css('cursor', 'pointer'); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } function isEmpty(S) { if (typeof S == "undefined") return true; if (!S) return true; if (S === "") return true; return false; } function iscomplete(N) { var itm = getDeclaration_v2(N); if (isEmpty(itm.credit_has_judgements)) return false; if (isEmpty(itm.credit_has_bancruptcy)) return false; if (isEmpty(itm.credit_has_forclosures)) return false; if (itm.credit_has_bancruptcy == "Y") { if (isEmpty(itm.credit_has_bancruptcy_chapter)) return false; if (isEmpty(itm.credit_has_bancruptcy_resolved)) return false; if (isEmpty(itm.credit_has_bancruptcy_resolution_date)) return false; } if (itm.credit_has_forclosures == "Y") { if (isEmpty(itm.credit_has_forclosures__date)) return false; } return true; } return { render : render, iscomplete : iscomplete } })(); mar.pg["declarations-p2"] = (function(){ var VAL = '' var html = ""; var yn3Label = ''; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name.split(" ")[0]; var nas = (applicantnum === 0) ? "Your" : getApplicantsNames_v2(applicantnum).Names var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); //var itm = getDeclarations_with_rules_v2()[applicantNum]; var itm = getDeclaration_v2(applicantnum) //let itm = (existingid) ? MAR.liabilities.get("childsupport",existingid) : false; let HAVEYOU = (applicantnum == 0) ? "Have you" : `${na}, have you`; let DOYOU = (applicantnum == 0) ? "Do you" : `${na}, do you`; let TELLUS = (applicantnum == 0) ? "Tell us" : `${na}, tell us`; let AREYOU = (applicantnum == 0) ? "Are you" : `${na}, are you`; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 //console.warn("localopts", localopts); //console.warn("inc", inc); //console.warn("itm", itm); //console.warn("existingid"+existingid); /** * standard starting block - END */ let h = ""; h += frm.htitle("Declarations 2/3").render(); h += frm.elaine(`Just a few more questions about ${nas} credit.`,"er").render(); h += "
    "; // JC - CW - elaine added div //h += "
    Are you involved in a lawsuit?
    "; VAL = (itm) ? itm.credit_has_lawsuit : ''; h += frm.yn3("credit_has_lawsuit",AREYOU+" party to a lawsuit in which you potentially have any personal financial liability?",VAL,"","",function(){ oc(); //revealTip('credit_has_lawsuit'); }, {}).render(); h += (function(){ let h = ""; VAL = (itm) ? itm.credit_has_lawsuit_cost_money : ''; h += frm.yn3("credit_has_lawsuit_cost_money",'Can this lawsuit end up costing you money?',VAL,"","",function(){ oc(); // revealTip('credit_has_lawsuit_cost_money'); }, {}).render(); h += "
    "; h += "
    "; h += "
    "+$("#svg_warning_icon").html()+"
    "; h += "
    Underwriters really need the full "+ "story about what is going on, because the litigation could affect your financing options.
    "; h += "
    "; h += "
    " // end credit_has_lawsuit_cost_money_reveal return h; })().wrap("
    ", "
    "); h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); yn3Label = "
    "+HAVEYOU+" directly or indirectly been a part of any loan that's resulted in a foreclosure,"+ " transfer of title instead of foreclosure, or judgement?
    "; (function() { if (!itm) return; let def = MAR.getOpt(itm, "credit_has_shortsale_or_other",""); let ss = MAR.getOpt(itm, "credit_has_shortsale",""); let ju = MAR.getOpt(itm, "credit_has_judgements",""); let fc = MAR.getOpt(itm, "credit_has_forclosures",""); let fcd = MAR.getOpt(itm, "credit_has_forclosures__date",""); let typ = MAR.getOpt(itm, "credit_has_shortsale_type",""); let types = (typ.trim().length === 0) ? [] : typ.trim().split(","); if (ju === "Y" && types.indexOf("judgement") < 0) { types.push("judgement"); } if (fc === "Y" && types.indexOf("foreclosure") < 0) { types.push("foreclosure"); } if (ss === "Y" && types.indexOf("shortsale") < 0) { types.push("shortsale"); } if (types.length > 0) { itm.credit_has_shortsale_or_other = "Y"; itm.credit_has_shortsale_type = types.join(","); } else { itm.credit_has_shortsale_or_other = def; itm.credit_has_shortsale_type = ""; } })(); VAL = (itm) ? itm.credit_has_shortsale_or_other : ''; h += frm.yn3("credit_has_shortsale_or_other",yn3Label,VAL,"","",function(){ // revealTip('credit_has_shortsale'); oc(); if(txt("#credit_has_shortsale_or_other") == "Y") { //$(".info-credit_has_shortsale").trigger("click") } }, {}).render(); h += "
    "; h += frm.hr().render(); VAL = (itm) ? itm.credit_has_shortsale_type : ''; h += frm.checklist("credit_has_shortsale_type","Which of the following was it?",VAL,"","",function(){ oc(); },{ shortsale : "Short Sale", foreclosure : "Foreclosure", transfertitle : "Transfer of title", judgement : "Judgement" }).render().wrap("
    ","
    "); h += (function(){ let h = ""; h += frm.inline_warning_red("You don't have to be on the loan to be a part of these derogatory issues. you could just be on the title."); VAL = (itm) ? itm.credit_has_shortsale_title : ''; h += frm.yn3("credit_has_shortsale_title","Were you on the title?",VAL,"","",function(){ oc(); }, {}).render(); return h; })().wrap("
    ","
    "); VAL = (itm) ? itm.credit_has_shortsale_date : ''; h += frm.txt("credit_has_shortsale_date","
    When did you sell the Short Sale?",VAL,"","",function(){ let elm = $("#credit_has_shortsale_date") if (new Date(elm.val()) > new Date()) { elm.val(elm.prop("max")); } }, "date").render().wrap("
    ","
    "); VAL = (itm) ? itm.credit_has_forclosures__date : ''; h += frm.txt("credit_has_forclosures__date","
    What is the dismissal date of the foreclosure?",VAL,"","",function(){ let elm = $("#credit_has_forclosures__date") if (new Date(elm.val()) > new Date()) { elm.val(elm.prop("max")); } }, "date").render().wrap("
    ","
    "); VAL = (itm) ? itm.credit_has_transferoftitle__date : ''; h += frm.txt("credit_has_transferoftitle__date","
    When did you transfer the title?",VAL,"","",function(){ let elm = $("#credit_has_transferoftitle__date") if (new Date(elm.val()) > new Date()) { elm.val(elm.prop("max")); } }, "date").render().wrap("
    ","
    "); h += "
    " // end credit_has_shortsale_reveal h += "
    " // reveal - end /// h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); // yn3Label = "
    "+AREYOU+" currently late or in default on a federal debt or any other loan, mortgage, "+ // "financial obligation, bond, or loan guarantee?
    "; yn3Label = "
    "+AREYOU+" currently delinquent or in default on a federal debt?
    "; VAL = (itm) ? itm.credit_delinquent_on_federal_debt : ''; h += frm.yn3("credit_delinquent_on_federal_debt",yn3Label,VAL,"","",function(){ oc(); if(yn3("#credit_delinquent_on_federal_debt") == "Y") { // $(".info-credit_delinquent_on_federal_debt").trigger("click") } // if(txt("#credit_delinquent_on_federal_debt") == "Y") { // $(".info-credit_delinquent_on_federal_debt").trigger("click") // } }, {}).render(); h += "
    " // reveal - end h += "
    "; //h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); VAL = (itm) ? itm.credit_delinquent_on_federal_debt_type : ''; h += frm.radio("credit_delinquent_on_federal_debt_type","On which are you late or in default?",VAL,"","",function(){ oc(); },{ tax : "Federal Debt", mortgage : "Mortgage or Loan", both : "Both" }).render().wrap("
    ",""); h += "
    " // reveal - end h += "
    "; yn3Label = "
    Since when are you current on your mortgage again?
    "; VAL = (itm) ? itm.credit_delinquent_on_federal_debt_date : ''; h += frm.txt("credit_delinquent_on_federal_debt_date",yn3Label,VAL,"","",function(){ let elm = $("#credit_delinquent_on_federal_debt_date") if (new Date(elm.val()) > new Date()) { elm.val(elm.prop("max")); } oc(); }, "date").render(); h += "
    " // reveal - end //let oldhtml = $("#declarations_simple").html(); //h += oldhtml; h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.credit_has_lawsuit = yn3("#credit_has_lawsuit"); itm.credit_has_lawsuit_cost_money = yn3("#credit_has_lawsuit_cost_money"); itm.credit_has_shortsale_or_other = yn3("#credit_has_shortsale_or_other"); itm.credit_has_shortsale_type = checklist("credit_has_shortsale_type"); itm.credit_has_shortsale_title = yn3("#credit_has_shortsale_title"); itm.credit_has_shortsale_date = txt("#credit_has_shortsale_date"); itm.credit_has_forclosures__date = txt("#credit_has_forclosures__date"); itm.credit_has_transferoftitle__date = txt("#credit_has_transferoftitle__date"); itm.credit_delinquent_on_federal_debt = yn3("#credit_delinquent_on_federal_debt"); itm.credit_when_current_on_federal_debt = txt("#credit_when_current_on_federal_debt"); itm.credit_delinquent_on_federal_debt_date = "";//txt("#credit_delinquent_on_federal_debt_date"); itm.credit_delinquent_on_federal_debt_type = radio("credit_delinquent_on_federal_debt_type"); if (itm.credit_has_shortsale_or_other === "N") { itm.credit_has_shortsale_type = ""; } if (itm.credit_has_shortsale_type.indexOf("shorts") > -1) { itm.credit_has_shortsale = "Y"; } else { itm.credit_has_shortsale = "N"; itm.credit_has_shortsale_date = ""; } if (itm.credit_has_shortsale_type.indexOf("forecl") > -1) { itm.credit_has_forclosures = "Y"; } else { itm.credit_has_forclosures = "N"; itm.credit_has_forclosures__date = ""; } if (itm.credit_has_shortsale_type.indexOf("judgem") > -1) { itm.credit_has_judgements = "Y"; } else { itm.credit_has_judgements = "N"; } if (itm.credit_has_shortsale_type.indexOf("transfer") > -1) { itm.credit_has_transferoftitle = "Y"; } else { itm.credit_has_transferoftitle = "N"; itm.credit_has_transferoftitle__date = ""; } /** * validation block start (validate the "itm" values) */ if (itm.credit_has_lawsuit.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you are involved in a lawsuit.","top"); return; } if (itm.credit_has_lawsuit == 'Y' && itm.credit_has_lawsuit_cost_money.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if the lawsuit will cost you money.","top"); return; } if (itm.credit_has_shortsale_or_other.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you have directly or indirectly been a part of any loan that's resulted in foreclosure, transfer of title.","top"); return; } if (itm.credit_has_shortsale_or_other == 'Y' && itm.credit_has_shortsale_type.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us what type of event this was.","top"); return; } if (itm.credit_has_shortsale_or_other == 'Y' && itm.credit_has_shortsale_title.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you were on the title.","top"); return; } if (itm.credit_has_shortsale == 'Y' && itm.credit_has_shortsale_date.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us when the Short Sale was completed.","top"); return; } if (itm.credit_has_forclosures == 'Y' && itm.credit_has_forclosures__date.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us when the foreclosure was completed.","top"); return; } if (itm.credit_has_transferoftitle == 'Y' && itm.credit_has_transferoftitle__date.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us when the transfer of title was completed.","top"); return; } if ($("#credit_delinquent_on_federal_debt-div:visible").length === 0) { _open("#credit_delinquent_on_federal_debt-div") return; } if (itm.credit_delinquent_on_federal_debt.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you are late on any loan.","top"); return; } if (itm.credit_delinquent_on_federal_debt.trim() == 'Y' ) { var valr = radio("credit_delinquent_on_federal_debt_type"); if (valr == "" || valr == undefined) { mar.tip(".help-button","warning","You need to tell us which sort of debt you have.","top"); return; } // if (valr == "mortgage" || valr == "both") { // var valr = txt("#credit_delinquent_on_federal_debt_date"); // if (valr == "" || valr == undefined) { // mar.tip(".help-button","warning","You need to tell us when you will be current on any loan.","top"); // return; // } // // } } // if (mar.answers.v2.state.has_warned_about_late_payments == false) { // if(txt("#credit_delinquent_on_federal_debt_date") != "") { // if(yn3("#credit_delinquent_on_federal_debt") == "Y") { // $(".info-credit_delinquent_on_federal_debt").trigger("click") // mar.answers.v2.state.has_warned_about_late_payments = true; // return; // } // } // } for (x in itm) { MAR.declarations.set(applicantnum,x,itm[x]); } setScenario_data("__scenario_declarep2_"+applicantnum+"_passed","Y"); mar.fakesave(function(){ if (mar.WE_ARE_FROM_LOI === true) { MAR.encompass.app_check_diffs_borrower_profileSync(mar.ID, applicantnum); } }); /** * validation block end */ mvc.go("#declarations-p3."+applicantnum); }),"back",frm.addfunction(function(){ mvc.go("#declarations-p1."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let _open = function(elm) { let $elm = $(elm); $elm.slideDown(function(){ $elm.removeClass("x-hide");//.removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); } let oc = function() { let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { if (txt("#credit_has_lawsuit") !== "") _open($reveals[0]); // if (txt("#credit_has_lawsuit_cost_money") !== "") _open($reveals[1]) // if (txt("#credit_has_shortsale") !== "") _open($reveals[1]); // if (txt("#credit_has_shortsale_or_other") !== "") _open($reveals[1]); if(txt("#credit_delinquent_on_federal_debt") == "Y") { _open($reveals[2]); //$('#when_current_holder').removeClass('x-hide'); } } let credit_has_shortsale_or_other = yn3("#credit_has_shortsale_or_other"); if (credit_has_shortsale_or_other === "Y") { $("#credit_has_shortsale_reveal").removeClass("x-hide"); } else { $("#credit_has_shortsale_reveal").addClass("x-hide"); } if (credit_has_shortsale_or_other !== "") { if ($("#credit_delinquent_on_federal_debt-div:visible").length === 0) { _open("#credit_delinquent_on_federal_debt-div") return; } } let credit_has_shortsale_type = checklist("credit_has_shortsale_type"); let credit_has_shortsale_title = yn3("#credit_has_shortsale_title"); if (credit_has_shortsale_type === "") { $("#short-sale-date-div").addClass("x-hide"); $("#foreclosure-date-div").addClass("x-hide"); $("#transferoftitle-date-div").addClass("x-hide"); $("#title-question-div").addClass("x-hide"); } else { $("#title-question-div").removeClass("x-hide"); if (yn3("#credit_has_shortsale_title") === "") { yn3("#credit_has_shortsale_title","Y"); $("#credit_has_shortsale_title").change(); } if (credit_has_shortsale_title === "") { $("#short-sale-date-div").addClass("x-hide"); $("#foreclosure-date-div").addClass("x-hide"); $("#transferoftitle-date-div").addClass("x-hide"); } else { let types = credit_has_shortsale_type; if (types.indexOf("short") > -1) { $("#short-sale-date-div").removeClass("x-hide"); } else { $("#short-sale-date-div").addClass("x-hide"); } if (types.indexOf("foreclos") > -1) { $("#foreclosure-date-div").removeClass("x-hide"); } else { $("#foreclosure-date-div").addClass("x-hide"); } if (types.indexOf("transf") > -1) { $("#transferoftitle-date-div").removeClass("x-hide"); } else { $("#transferoftitle-date-div").addClass("x-hide"); } } } revealTip('credit_has_lawsuit'); revealTip('credit_has_lawsuit_cost_money'); revealTip('credit_has_shortsale_or_other'); revealTip('credit_delinquent_on_federal_debt'); } let revealTip = function(val){ if (__ROLE == "lo" || mar.loauth.islo()){ if(txt('#'+val) == 'Y'){ $('#'+val+'_tip').removeClass('x-hide'); $("#body-container").scrollTo("max",200); }else{ $('#'+val+'_tip').addClass('x-hide'); } } switch(val) { case 'credit_has_lawsuit': if(txt('#'+val) != 'Y'){ $('#credit_has_lawsuit_reveal').addClass('x-hide'); //credit_has_bancruptcy_chapter }else{ $('#credit_has_lawsuit_reveal').removeClass('x-hide'); } break; case 'credit_has_lawsuit_cost_money': if(yn('#'+val) != 'Y'){ $('#credit_has_lawsuit_cost_money_reveal').addClass('x-hide'); //credit_has_bancruptcy_chapter }else{ $('#credit_has_lawsuit_cost_money_reveal').removeClass('x-hide'); } console.warn("'#'+val: "+txt('#'+val)); console.warn("$('#credit_has_lawsuit_cost_money_reveal'): ", $('#credit_has_lawsuit_cost_money_reveal')); break; case 'credit_has_shortsale_or_other': if(txt('#'+val) != 'Y'){ $('#credit_has_shortsale_reveal').addClass('x-hide'); checklist('credit_has_shortsale_type', ''); yn3('#credit_has_shortsale_title', ''); txt('#credit_has_shortsale_date', ''); }else{ $('#credit_has_shortsale_reveal').removeClass('x-hide'); } break; case 'credit_delinquent_on_federal_debt': if(txt('#'+val) != 'Y'){ $('#credit_delinquent_on_federal_debt_reveal').addClass('x-hide'); txt('#credit_delinquent_on_federal_debt_date', ''); radio('credit_delinquent_on_federal_debt_type', ''); }else{ $('#credit_delinquent_on_federal_debt_reveal').removeClass('x-hide'); $('#credit_delinquent_on_federal_debt_reveal2').addClass('x-hide'); txt('#credit_delinquent_on_federal_debt_date', ''); // if (radio("credit_delinquent_on_federal_debt_type") == "mortgage" || radio("credit_delinquent_on_federal_debt_type") == "both") { // $('#credit_delinquent_on_federal_debt_reveal2').removeClass('x-hide'); // } else { // $('#credit_delinquent_on_federal_debt_reveal2').addClass('x-hide'); // txt('#credit_delinquent_on_federal_debt_date', ''); // } } break; default: } } let or = function(){ let sp = mar.isallowed_scenario("#declarations-p2."+applicantnum); if (typeof sp === "string") { mvc.go(sp); return; } mar.answers.v2.state.has_warned_about_late_payments = false; $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); var now = new Date(); let maxDate = now.toISOString().substring(0,10); $('#credit_has_shortsale_date').prop('max', maxDate); $('#credit_delinquent_on_federal_debt_date').prop('max', maxDate); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); $(".info-credit_has_shortsale").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Attention").render()+ `If you were not on the loan, but on the title of the property as an owner, you are considered responsible, \ the waiting periods to qualify for a new loan also apply to you. Please let us know if this happened, so we can guide you properly.

    This would include such loans as home mortgage loans, SBA loans, home improvement loans, educational loans, manufactured (mobile) home loans, any mortgage, financial obligation, bond, or loan guarantee.

    If “Yes,” provide details, including date, name, and address of Lender, FHA or VA case number, if any, and reasons for the action.
    `; // "This is a common element that puts a bomb under the file, and if not noticed until we're all done and do our last fraud detection system runs "+ // "(which cost 100 bucks)."; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Got it" } }); }); $(".info-credit_has_shortsale").css('cursor', 'pointer'); $(".info-credit_delinquent_on_federal_debt").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Attention").render()+ "Being late on your mortgage payments is a big deal, because it says to the underwriter that you're more likely to default on your new loan. "+ "In fact, if you've made more than 1 delinquent payment in the past 12 month period, most programs will disqualify you for at least a year."; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Got it" } }); }); $(".info-credit_delinquent_on_federal_debt").css('cursor', 'pointer'); oc(); setTimeout(oc, 500); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } function isEmpty(S) { if (typeof S == "undefined") return true; if (!S) return true; if (S === "") return true; return false; } function iscomplete(N) { var itm = getDeclaration_v2(N); if (isEmpty(itm.credit_has_lawsuit)) return false; if (isEmpty(itm.credit_has_shortsale)) return false; if (isEmpty(itm.credit_delinquent_on_federal_debt)) return false; if (itm.credit_has_lawsuit == "Y") { if (isEmpty(itm.credit_has_lawsuit_cost_money)) return false; } if (itm.credit_has_shortsale == "Y") { if (isEmpty(itm.credit_has_shortsale_type)) return false; if (isEmpty(itm.credit_has_shortsale_title)) return false; if (isEmpty(itm.credit_has_shortsale_date)) return false; } if (itm.credit_delinquent_on_federal_debt == "Y") { if (isEmpty(itm.credit_when_current_on_federal_debt)) return false; // if (isEmpty(itm.credit_delinquent_on_federal_debt_date)) return false; if (isEmpty(itm.credit_delinquent_on_federal_debt_type)) return false; } return true; } return { render : render, iscomplete : iscomplete } })(); mar.pg["declarations-p3"] = (function(){ var VAL = '' var html = ""; var y3nLabel = ''; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var nas = (applicantnum === 0) ? "Your" : getApplicantsNames_v2(applicantnum).Names var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); //var itm = getDeclarations_with_rules_v2()[applicantNum]; var itm = getDeclaration_v2(applicantnum) //let itm = (existingid) ? MAR.liabilities.get("childsupport",existingid) : false; let HAVEYOU = (applicantnum == 0) ? "Have you" : `${na}, have you`; let DOYOU = (applicantnum == 0) ? "Do you" : `${na}, do you`; let TELLUS = (applicantnum == 0) ? "Tell us" : `${na}, tell us`; let AREYOU = (applicantnum == 0) ? "Are you" : `${na}, are you`; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 console.warn("localopts", localopts); console.warn("inc", inc); console.warn("itm", itm); console.warn("existingid"+existingid); /** * standard starting block - END */ let h = ""; h += frm.htitle("Declarations 3/3").render(); h += frm.elaine(`Last set of questions on the topic of ${nas} credit, great job!`,"er").render(); h += "
    "; // JC - CW - elaine added div y3nLabel = "
    "+AREYOU+" obligated to pay alimony, child support, or seperate maintenance?
    "; VAL = (itm) ? itm.credit_obligated_to_pay_alimony_or_child : ''; h += frm.yn3("credit_obligated_to_pay_alimony_or_child",y3nLabel,VAL,"","",function(){ // revealTip('credit_obligated_to_pay_alimony_or_child'); oc(); }, {}).render(); // h += "
    "; // // // VAL = (itm) ? itm.credit_obligated_to_pay_alimony_or_child_followup : ''; // h += frm.radio("credit_obligated_to_pay_alimony_or_child_followup","Which are you obligated to pay?",VAL,"","",function(){ // //oc(); // },{ // alimony : "Alimony", // child : "Child support", // both : "Both" // }).render().wrap("
    ",""); // // //// VAL = (itm) ? itm.credit_alimony_amount : '1000'; //// //// //// h += frm.slider("credit_alimony_amount","Monthly payment:",VAL,"","",function(){ //// }, { //// v00 : '0', //// v50 : '1500', //// v50_inc : '50', //// v75 : '5000', //// v75_inc : '100', //// v100 : '10000', //// v100_inc : '250' //// }).render(); // // // //// h += "
    " // end credit_alimony_amount // // h += "
    " // end credit_obligated_to_pay_alimony_or_child h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); y3nLabel = "Do you owe money to the IRS, or are you on an IRS payment plan? "; VAL = (itm) ? itm.credit_irs_plan : ''; h += frm.yn3("credit_irs_plan",y3nLabel,VAL,"","",function(x,y){ oc(); if(txt("#credit_irs_plan") == "Y") { } // revealTip('credit_downpayment_borrowed'); }, {}).render(); h += "
    " // end credit_has_lawsuit h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); // y3nLabel = "Is any part of the down payment borrowed? "; y3nLabel = "Are you borrowing any money for this real estate transaction that you have not disclosed on this loan application? "; VAL = (itm) ? itm.credit_downpayment_borrowed : ''; h += frm.yn3("credit_downpayment_borrowed",y3nLabel,VAL,"","",function(x,y){ oc(); if(txt("#credit_downpayment_borrowed") == "Y") { $(".info-credit_downpayment_borrowed").trigger("click") } // revealTip('credit_downpayment_borrowed'); }, {}).render(); h += "
    "; VAL = (itm) ? itm.credit_downpayment_borrowed_value : '0'; h += frm.slider("credit_downpayment_borrowed_value","What is the amount of this money?",VAL,"","",function(){ }, { v00 : '0', v50 : '1500', v50_inc : '50', v75 : '5000', v75_inc : '100', v100 : '100000', v100_inc : '500' }).render(); // h += frm.txt("credit_downpayment_borrowed_value","What is the amount of this money?",VAL,"","",function(){}, "").render(); h += "
    " // end credit_downpayment_borrowed_value_div /* h += "
    "; VAL = (itm) ? itm.credit_has_shortsale_date : ''; h += frm.txt("credit_has_shortsale_date","What date was your foreclosure completed?",VAL,"","",function(){}, "date").render(); h += "
    " // end credit_has_shortsale_reveal */ h += "
    " // reveal - end h += "
    "; // reveal - start (with validation to previous field) h += frm.hr().render(); y3nLabel= AREYOU+" a co-signer or garantor on any debt or loan that is not disclosed on this application?"; VAL = (itm) ? itm.credit_comaker_or_endorser : ''; h += frm.yn3("credit_comaker_or_endorser",y3nLabel,VAL,"","",function(){ oc(); // revealTip('credit_comaker_or_endorser'); }, {}).render(); h += "
    "; h += "
    "; h +="
    "; // var fcStr = "This simply means: Have you closed any loans that the lender needs to be aware of."; var fcStr = `This question is asking if you are responsible for someone else's debt or loan in a way that hasn't been mentioned in the application. Being a co-signer or guarantor means that if the primary borrower fails to make payments, you are legally obligated to pay the debt. The lender wants to know about all such obligations because they affect your ability to pay back the new loan or debt you're applying for.`; h += frm.h2("Tip: "+fcStr).render(); h += "
    ";//end loTipBlock h += "
    "; // end credit_comaker_or_endorser_reveal h += (function(){ let h = ""; VAL = (itm) ? itm.additional_mortgage : ''; y3nLabel = "Have you or will you be applying for a mortgage loan on another property (not the property securing this loan) on or before closing this transaction that is not disclosed on this loan application?"; h += frm.hr().render(); h += frm.yn3("additional_mortgage",y3nLabel,VAL,"","",function(){ oc(); }, {}).render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; VAL = (itm) ? itm.additional_loan : ''; y3nLabel = "Have you or will you be applying for any new credit (e.g., installment loan, credit card, etc.) on or before closing this loan that is not disclosed on this application?"; h += frm.hr().render(); h += frm.yn3("additional_loan",y3nLabel,VAL,"","",function(){ oc(); }, {}).render(); return h; })().wrap("
    ","
    ") h += (function(){ let h = ""; VAL = (itm) ? itm.priority_lein : ''; y3nLabel = "Will this property be subject to a lien that could take priority over the first mortgage lien, such as a clean energy lien paid through your property taxes (e.g. the Property Assessed Clean Energy Program)"; h += frm.hr().render(); h += frm.yn3("priority_lein",y3nLabel,VAL,"","",function(){ oc(); }, {}).render(); return h; })().wrap("
    ","
    "); h += (function(){ if (MAR.is_refi() === true) { return ""; } let h = ""; VAL = (itm) ? itm.special_realtionship : ''; y3nLabel = "If this is a Purchase Transaction: Do you have a family relationship or business affiliation with the seller of the property?"; h += frm.hr().render(); h += frm.yn3("special_realtionship",y3nLabel,VAL,"","",function(){ oc(); }, {}).render(); return h; })().wrap("
    ","
    "); h += "
    " // reveal - end //let oldhtml = $("#declarations_simple").html(); //h += oldhtml; h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ /** * validation & reveal block start */ // let $reveals = $(".x-revealdiv"); // if ($reveals.length > 0) { // let $elm = $($reveals[0]); // // let validation = $elm.data("validation"); // // // if (validation == "credit_obligated_to_pay_alimony_or_child") { // val = txt("#credit_obligated_to_pay_alimony_or_child"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us if you pay alimony.","top"); // return; // } // if(val == 'Y'){ // // var valr = txt("#credit_alimony_amount"); // //console.warn('credit_has_bancruptcy_resolution_date: '+valr); // if (valr == "" || valr == undefined) { // mar.tip(".help-button","warning","You need to tell us how much you pay for alimony.","top"); // return; // } // // } // } // // if (validation == "credit_downpayment_borrowed") { // val = txt("#credit_downpayment_borrowed"); // if (val.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us if any of this payment will be borrowed.","top"); // return; // } // } // // // // // // $elm.slideDown(function(){ // $elm.removeClass("x-hide").removeClass("x-revealdiv"); // $("#body-container").scrollTo("max",200); // }); // return; // } /** * validation & reveal block end */ if (!existingid) { itm = {}; } itm.credit_obligated_to_pay_alimony_or_child = txt("#credit_obligated_to_pay_alimony_or_child"); itm.credit_irs_plan = txt("#credit_irs_plan"); itm.credit_alimony_amount = "0"; //txt("#credit_alimony_amount"); itm.credit_obligated_to_pay_alimony_or_child_followup = ""; // radio("credit_obligated_to_pay_alimony_or_child_followup"); itm.credit_downpayment_borrowed = txt("#credit_downpayment_borrowed"); itm.credit_downpayment_borrowed_value = (itm.credit_downpayment_borrowed === "Y") ? txt("#credit_downpayment_borrowed_value") : "0"; itm.credit_comaker_or_endorser = txt("#credit_comaker_or_endorser"); itm.additional_mortgage = txt("#additional_mortgage"); itm.additional_loan = txt("#additional_loan"); itm.priority_lein = txt("#priority_lein"); itm.special_realtionship = txt("#special_realtionship"); /** * validation block start (validate the "itm" values) */ if (itm.credit_obligated_to_pay_alimony_or_child.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you pay alimony.","top"); return; } // if (itm.credit_obligated_to_pay_alimony_or_child == 'Y' && itm.credit_obligated_to_pay_alimony_or_child_followup.trim().length == 0 ) { // mar.tip(".help-button","warning","You need to tell us if it is alimony, child support or both.","top"); // return; // } if (itm.credit_irs_plan.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you have an IRS payment plan.","top"); return; } if (itm.credit_downpayment_borrowed.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you will borrow this payment.","top"); return; } if (itm.credit_downpayment_borrowed.trim() === "Y") { if (itm.credit_downpayment_borrowed_value.trim().length === 0) { mar.tip(".help-button","warning","You need to tell us how much you will borrow.","top"); return; } } if (itm.credit_comaker_or_endorser.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you are a co-maker or endorser on any notes.","top"); return; } if (itm.additional_mortgage.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you are applying for additional mortgages.","top"); return; } if (itm.additional_loan.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you are applying for additional loans.","top"); return; } if (itm.priority_lein.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if there is a priority lein.","top"); return; } if (itm.special_realtionship.trim().length == 0 ) { mar.tip(".help-button","warning","You need to tell us if you have a special relationship.","top"); return; } for (x in itm) { MAR.declarations.set(applicantnum,x,itm[x]); } setScenario_data("__scenario_declarep3_"+applicantnum+"_passed","Y"); mar.fakesave(function(){ if (mar.WE_ARE_FROM_LOI === true) { MAR.encompass.app_check_diffs_borrower_profileSync(mar.ID, applicantnum); } }); /** * validation block end */ mvc.go("#scenario-borrowers."+applicantnum); //mvc.go("#declarations-p3"); }),"back",frm.addfunction(function(){ mvc.go("#declarations-p2."+applicantnum); //mvc.go("#liabilities-choice"); }),"mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let _open = function(elm) { let $elm = $(elm); $elm.slideDown(function(){ $elm.removeClass("x-hide");//.removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); } let oc = function() { let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { if (txt("#credit_obligated_to_pay_alimony_or_child") !== "") _open($reveals[0]) if (txt("#credit_irs_plan") !== "") _open($reveals[1]) if (txt("#credit_downpayment_borrowed") !== "") _open($reveals[2]) if (txt("#credit_comaker_or_endorser") !== "") _open($reveals[3]); if (txt("#additional_mortgage") !== "") _open($reveals[4]); if (txt("#additional_loan") !== "") _open($reveals[5]); if (txt("#priority_lein") !== "") _open($reveals[6]); if (MAR.is_refi() === false) { if (txt("#special_realtionship") !== "") _open($reveals[7]); } } revealTip('credit_obligated_to_pay_alimony_or_child'); revealTip('credit_downpayment_borrowed'); revealTip('credit_comaker_or_endorser'); $("#body-container").scrollTo("max",200); if(txt("#credit_downpayment_borrowed") == "Y") { if ($("#credit_downpayment_borrowed_value_div").hasClass("x-hide")) { $("#credit_downpayment_borrowed_value_div").removeClass("x-hide"); setTimeout(function(){ $("#credit_downpayment_borrowed_value").change(); },500); } } else { $("#credit_downpayment_borrowed_value_div").addClass("x-hide"); } } let revealTip = function(val){ if (__ROLE == "lo" || mar.loauth.islo()){ if(txt('#'+val) == 'Y'){ $('#'+val+'_tip').removeClass('x-hide'); $("#body-container").scrollTo("max",200); }else{ $('#'+val+'_tip').addClass('x-hide'); } } switch(val) { case 'credit_obligated_to_pay_alimony_or_child': if(txt('#'+val) != 'Y'){ // $('#credit_obligated_to_pay_alimony_or_child_reveal').addClass('x-hide'); //credit_has_bancruptcy_chapter }else{ // $('#credit_obligated_to_pay_alimony_or_child_reveal').removeClass('x-hide'); } break; case 'credit_comaker_or_endorser': if(txt('#'+val) != 'Y'){ $('#credit_comaker_or_endorser_reveal').addClass('x-hide'); //credit_has_bancruptcy_chapter }else{ $('#credit_comaker_or_endorser_reveal').removeClass('x-hide'); } break; case 'credit_has_shortsale': if(txt('#'+val) != 'Y'){ $('#credit_has_shortsale_reveal').addClass('x-hide'); radio('credit_has_shortsale_type', ''); yn3('#credit_has_shortsale_title', ''); txt('#credit_has_shortsale_date', ''); }else{ $('#credit_has_shortsale_reveal').removeClass('x-hide'); } break; default: } } let or = function(){ let sp = mar.isallowed_scenario("#declarations-p3."+applicantnum); if (typeof sp === "string") { mvc.go(sp); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); $(".info-credit_downpayment_borrowed").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Attention").render()+ "A lot of loan programs won't accept borrowed funds because it means that there's a payment obligation. The only borrowed funds that are ok "+ "to use, is if the loan is secured by your own property (like a home equity line of credit or a loan against your pension), or a downpayment assistance program."; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Got it" } }); }); $(".info-credit_downpayment_borrowed").css('cursor', 'pointer'); $(".info-irsplan").click(function(){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Attention").render()+ "Any IRS debt will have to be settled at closing, or an IRS payment plan with proof that you made at least 3 timely payments."; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "Got it" } }); }); $(".info-irsplan").css('cursor', 'pointer'); oc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } function isEmpty(S) { if (typeof S == "undefined") return true; if (!S) return true; if (S === "") return true; return false; } function iscomplete(N) { var itm = getDeclaration_v2(N); if (isEmpty(itm.credit_obligated_to_pay_alimony_or_child)) return false; if (isEmpty(itm.credit_downpayment_borrowed)) return false; if (isEmpty(itm.credit_comaker_or_endorser)) return false; if (itm.credit_obligated_to_pay_alimony_or_child == "Y") { // if (isEmpty(itm.credit_alimony_amount)) return false; // if (isEmpty(itm.credit_obligated_to_pay_alimony_or_child_followup)) // return false; } return true; } return { render : render, iscomplete : iscomplete } })(); /* file /ui/app/js/pages.realtor.js , last updated 1669675272381*/ mar.pg["scenario-realtor"] = (function(){ var VAL = '' var html = ""; var checkForValues = false; function render(pg, localopts) { let h = ""; let rn = getParameterByName("rname"); let rndef = (rn == "") ? "N" : "Y" let have_own_realtor = getScenario_data("have_own_realtor",rndef); let rname = getScenario_data("realtor_name",false); if (rname === false) { rname = getParameterByName("rname"); } let rtel = getScenario_data("realtor_phone",getParameterByName("rtel")); let remail = getScenario_data("realtor_email",getParameterByName("remail")); let roffice = getScenario_data("realtor_office",getParameterByName("roffice")); h += frm.htitle("REALTOR INFORMATION").render(); let _rname = MAR.realtor.getName(rname); if (rname != "") { // h += frm.elaine("Even though you came in through the realtor page of "+_rname.fn+", You can enter your realtor's information here, on the next page you can select what we can share with them.","er").render(); // JC - CW - elaine added "er" h += frm.elaine("You can enter your realtor's information here, on the next page you can select what we can share with them.","er").render(); // JC - CW - elaine added "er" } else { h += frm.elaine("You can enter your realtor's information here, on the next page you can select what we can share with them.","er").render(); // JC - CW - elaine added "er" } h += "
    "; // JC - CW - elaine added div VAL = have_own_realtor; h += frm.radio("have_own_realtor","Do you have a realtor?",VAL,"","",function(){ oc(); },{ "N" : "I don’t have a realtor", "Y" : "I do have a realtor" }).render(); h += "
    "; h += frm.hr().render(); h += "
    REALTOR'S DETAILS
    "; VAL = _rname.fn; h += frm.txt("name_own_realtor_fn","Your realtor first name",VAL,"e.g. Clara","",function(){}).render(); VAL = _rname.ln; h += frm.txt("name_own_realtor_ln","Your realtor last name",VAL,"e.g. Mantilla","",function(){}).render(); VAL = roffice; h += frm.txt("brokerage_own_realtor","Brokerage",VAL,"e.g. Keller Williams","",function(){}).render(); VAL = rtel; h += frm.txt("phone_own_realtor","Phone number",VAL,"___-___-____","",function(){ }).render(); VAL = remail; h += frm.txt("email_own_realtor","Email",VAL,"e.g. CM@KW.com","",function(){}).render(); h += "
    "; /* VAL = 'N'; h += frm.yn("ssec_dont_pay_taxes","I receive this without giving a part to Uncle Sam (gross is net).",VAL,"","",function(){},{}).render(); */ h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ // let hasOwn = radio("have_own_realtor"); //console.warn('hasOwn: '+hasOwn); //console.warn('checkForValues: '+checkForValues); if (hasOwn == "Y") { $("#realtor_details_holder_btm").css("display","block"); if(checkForValues == true){ if($("#name_own_realtor_fn").val() === ''){ mar.tip(".help-button","warning","You need to tell us the name of your realtor","top"); return false; } // if($("#phone_own_realtor").val() === ''){ // mar.tip(".help-button","warning","You need to tell us the phone number of your realtor","top"); // return false; // } setScenario_data("have_own_realtor",radio("have_own_realtor")); MAR.realtor.setName(txt("#name_own_realtor_fn"), txt("#name_own_realtor_ln")); setScenario_data("realtor_office",txt("#brokerage_own_realtor")); setScenario_data("realtor_phone",txt("#phone_own_realtor")); setScenario_data("realtor_email",txt("#email_own_realtor")); setScenario_data("__scenario_realtor_passed","Y"); frm.buttons.hide(function(){ let cp = mvc.currentpage; mar.fakesave(function(){ if (mvc.currentpage === cp) { //console.warn('go to #scenario-realtorinfo'); mvc.go("#scenario-realtorinfo"); } }); }); } }else if(hasOwn == 'N'){ // $("#name_own_realtor").val(''); // $("#brokerage_own_realtor").val(''); // $("#phone_own_realtor").val(''); // $("#email_own_realtor").val(''); setScenario_data("have_own_realtor",radio("have_own_realtor")); setScenario_data("__scenario_realtor_verified","Y"); setScenario_data("__scenario_"+"realtor"+"_passed","Y") setScenario_data("__scenario_"+"end"+"_passed","Y"); frm.buttons.hide(function(){ let cp = mvc.currentpage; mar.fakesave(function(){ if (mvc.currentpage === cp) { mvc.go("#scenario-personaldata.0") } // mvc.go("#scenario-end"); }); }); // if (getScenario_data("visited_scenariorealtor","N") === "Y") { // setScenario_data("visited_scenariorealtor","Y"); // mar.fakesave(); // mvc.go("#income-how"+"."+applicantnum); // //mvc.go("#scenario-summary"); // } else { // setScenario_data("visited_scenariorealtor","Y"); // mar.fakesave(); // mvc.go("#up-next-income"+"."+applicantnum); // } } else{ mar.tip(".help-button","warning","You need to tell us if you have a realtor or not","top"); return false; } $("#body-container").scrollTo("max",200); }),"Back",frm.addfunction(function(){ // let borrowercount = "0"; //getScenario_data("__scenario_borrowers_num","1"); // if (getScenario_data("is_there_a_second_borrower","N") === "Y") borrowercount = "1"; // if (getScenario_data("is_there_a_third_borrower","N") === "Y") borrowercount = "2"; // for (let i=0; i < MAR.MAXBORROWERS; i++) { // if (getScenario_data(`is_there_a_${MAR.th(i)}_borrower`,"N") === "Y") borrowercount = `${i}`; // } mvc.go(`#scenario-borrowers.${(MAR.applicants.count()-1)}`); // mvc.go("#scenario-property"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(quick) { let hasOwn = radio("have_own_realtor"); if (hasOwn == "Y") { $("#realtor_details_holder_btm").css("display","block"); checkForValues = true; }else { $("#realtor_details_holder_btm").css("display","none") //clear out any garbage data in hidden divs // $("#name_own_realtor").val(''); // $("#brokerage_own_realtor").val(''); // $("#phone_own_realtor").val(''); // $("#email_own_realtor").val(''); } $("#body-container").scrollTo("max",200); } let or = function(){ let sp = mar.isallowed_scenario("#scenario-realtor"); if (typeof sp === "string") { mvc.go(sp); return; } let refi = (getScenario_data("loan_type","purchase") !== "purchase"); if (refi) { if (num(mar.pg_as) < num(mar.pg_pd)) { mvc.go("#assets-choice"); } else { mvc.goto("#scenario-personaldata.0"); } return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container #phone_own_realtor").inputmask("(999) - 999 - 9999", { autoUnmask: true }); $("#body-container #phone_own_realtor").euiInputTel(); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); //oc(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "realtorinfo" } })(); mar.pg["scenario-realtorinfo"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let _plcd = getScenario_data("realtor_permission_loan_calcs_and_docs",""); let _pdur = getScenario_data("realtor_permission_direct_underwriting_report",""); let _pai = getScenario_data("realtor_permission_appraisal_information",""); let _isallowed = true; let xhide = (_pai === "") ? "x-hide" : ""; h += frm.htitle("REALTOR INFORMATION").render(); if (typeof __ROLE !== 'undefined' && __ROLE == "cl") { h += frm.elaine("Just a few more questions about your realtor.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div h += "
    I give permission to "+getParameterByName("local_company")+" to share the following information with my realtor:
    "; VAL = _plcd; h += frm.yn3("permission_loan_calcs_and_docs","Loan calculations and list of outstanding documents",VAL,"","",function(){ oc(); },{}).render(); // h += frm.hr().render(); VAL = _pdur; h += `
    ` h += frm.hr().render(); h += frm.yn3("permission_direct_underwriting_report","Direct Underwriting report (this contains personal data, such as credit report, income and assets information)",VAL,"","",function(){ oc(); },{}).render(); h += "
    "; h += `
    ` VAL = _pai; h += frm.hr().render(); h += frm.yn3("permission_appraisal_information","Appraisal information",VAL,"","",function(){ oc(); },{}).render(); h += "
    "; h += `
    "; h += "
    "; } else { h += frm.elaine("This page can only be filled in by the client, click save and go to continue.","er").render(); // JC - CW - elaine added "er" _isallowed = false; } /* VAL = 'N'; h += frm.yn("ssec_dont_pay_taxes","I receive this without giving a part to Uncle Sam (gross is net).",VAL,"","",function(){},{}).render(); */ h += "
    "; // JC - CW - elaine - added end div /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (_isallowed === false) { mvc.go("#scenario-personaldata.0"); return; } // let _plcd = txt("#permission_loan_calcs_and_docs"); let _pdur = txt("#permission_direct_underwriting_report"); let _pai = txt("#permission_appraisal_information"); if (_plcd == "" || _pdur == "" || _pai == "") { mar.tip(".help-button","warning","You need to complete all the fields","top"); return false; } setScenario_data("realtor_permission_loan_calcs_and_docs",_plcd); setScenario_data("realtor_permission_direct_underwriting_report",_pdur); setScenario_data("realtor_permission_appraisal_information",_pai); setScenario_data("__scenario_"+"realtorinfo"+"_passed","Y"); setScenario_data("__scenario_realtor_verified","Y"); setScenario_data("__scenario_"+"end"+"_passed","Y"); frm.buttons.hide(function(){ let cp = mvc.currentpage; mar.fakesave(function(){ if (mvc.currentpage === cp) { $("#body-container").scrollTo("max",200); mvc.go("#scenario-personaldata.0"); //mvc.go("#scenario-end"); } }); }); // if (getScenario_data("visited_scenariorealtor","N") === "Y") { // setScenario_data("visited_scenariorealtor","Y"); // mar.fakesave(); // mvc.go("#income-how"+"."+applicantnum); // //mvc.go("#scenario-summary"); // } else { // setScenario_data("visited_scenariorealtor","Y"); // mar.fakesave(); // mvc.go("#up-next-income"+"."+applicantnum); // } }),"Back",frm.addfunction(function(){ mvc.go("#scenario-realtor"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { let _plcd = txt("#permission_loan_calcs_and_docs"); let _pdur = txt("#permission_direct_underwriting_report"); let _pai = txt("#permission_appraisal_information"); setScenario_data("realtor_permission_loan_calcs_and_docs",_plcd); setScenario_data("realtor_permission_direct_underwriting_report",_pdur); setScenario_data("realtor_permission_appraisal_information",_pai); frm.buttons.hide(function(){ mar.fakesave(function(){ frm.buttons.show(); }); }); if (_plcd != "" && $(".q2").hasClass("x-hide")) { $(".q2").slideDown(function(){ $("#body-container").scrollTo("max",200); $(".q2").removeClass("x-hide"); }); return } if (_pdur != "" && $(".q3").hasClass("x-hide")) { $(".q3").slideDown(function(){ $("#body-container").scrollTo("max",200); $(".q3").removeClass("x-hide"); }); return; } let st=''; if (_pai == "Y") { // unless you already have this data //st = sprintf("%s has given consent on s% on s% from IP address: %s", 'applicants name', 'toays date', 'now time', 'this IP'); //st = "{ {name} } has given consent on { {date}}{ {time} } from IP address: { {IP address} }"; $('#permission_realtor_verification_text').html(st); $("#permission_realtor_holder_btm").css("display","block"); $('#permission_appraisal_information').attr('disabled', true); $("#body-container").scrollTo("max",200); }else{ $("#permission_realtor_holder_btm").css("display","none"); } } let or = function(){ let sp = mar.isallowed_scenario("#scenario-realtorinfo"); if (typeof sp === "string") { mvc.go(sp); return; } let refi = (getScenario_data("loan_type","purchase") !== "purchase"); if (refi) { if (num(mar.pg_as) < num(mar.pg_pd)) { mvc.go("#assets-choice"); } else { mvc.goto("#scenario-personaldata.0"); } return; } $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "realtorinfo" } })(); /* file /ui/app/js/pages1.js , last updated 1670945171453*/ mar.pg["videointro2"] = (function(){ var html = ""; function render(pg, localopts) { let hh = ""; hh += $("#page_index_video2").html(); hh += ""; hh += ""; hh += " "; hh += " "; hh += ""; hh += " "; hh += " "; hh += " "; hh += " "; hh += " "; hh += " "; hh += " "; hh += " "; hh += "
    About us
    FAQ's
    "; hh += "
    "; hh += ""; hh += ""; var md = new MobileDetect(window.navigator.userAgent); var __md = (window.navigator.userAgent == "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3312.0 Safari/537.36"); var desktop = (!__md && !md.phone()); localopts.desktop = desktop; hh = Mustache.render(hh,localopts); pg.hh = hh; pg.render = true; pg.title = "Home"; pg.onrender = function() { //mar.openmenu_in_the_final_instance(); mvc.set("videointro2","Y"); //ok, handle this video pop up thing setTimeout(function(){ // var s = document.createElement("div"); // s.innerHTML = $("#page_index_video2").html(); // swal({ // content : s // }) // $("#videoHolderProto").detach().appendTo('#body-container'); // // $("#playpause").click(function(){ // $("#playpause").css("display","none"); // $('#myVideo').get(0).play(); // // }); // // // $("#videoCloser").click(function(){ // $("#videoHolderProto").css("display","none"); // // $('#myVideo').get(0).load(); // $("#videoHolderProto").remove(); // }); }, 1); } } return { render : render } })(); mar.pg["licenses"] = (function(){ var html = ""; function render(pg, localopts) { $("#body-container").scrollTo(0,200,{ axis : "y" }); let h = ""; h += $("#page_intro_licenses").html(); h += uihelpers.cbuttonbar("",false,"Back",frm.addfunction(function(){ window.history.back(); }),"mar.help()"); h = Mustache.render(h,$.extend(___cols,localopts)); pg.hh = h; pg.render = true; pg.title = "Realtor" pg.onrender = function() { } } return { render : render } })() mar.pg["privacy"] = (function(){ var html = ""; function render(pg, localopts) { let h = ""; h += "
    "; pg.hh = h; pg.render = true; pg.title = "Realtor" pg.onrender = function() { $("#body-container").scrollTo(0,200,{ axis : "y" }); h += $("#page_intro_privacy").html(); h += uihelpers.cbuttonbar("",false,"Back",frm.addfunction(function(){ window.history.back(); }),"mar.help()"); h = Mustache.render(h,$.extend(___cols,localopts)); $("#__cont").html(h); } } return { render : render } })() mar.pg["legal"] = (function(){ var html = ""; function render(pg, localopts) { $("#body-container").scrollTo(0,200,{ axis : "y" }); let h = ""; h += $("#page_intro_legal").html(); h += uihelpers.cbuttonbar("",false,"Back",frm.addfunction(function(){ window.history.back(); }),"mar.help()"); h = Mustache.render(h,$.extend(___cols,localopts)); pg.hh = h; pg.render = true; pg.title = "Realtor" pg.onrender = function() { } } return { render : render, section : "general" } })() mar.pg["nmls"] = (function(){ var html = ""; function render(pg, localopts) { let h = ""; h += ""; h += uihelpers.cbuttonbar("",false,"Back",frm.addfunction(function(){ window.history.back(); }),"mar.help()"); h = Mustache.render(h,$.extend(___cols,localopts)); pg.hh = h; pg.render = true; pg.title = "Realtor" pg.onrender = function() { } } return { render : render } })() mar.pg["index"] = (function(){ var html = ""; function render(pg, localopts) { let hh = ""; hh = "
    REPLACEMENT INDEX PAGE
    "; hh += ""; var md = new MobileDetect(window.navigator.userAgent); var __md = (window.navigator.userAgent == "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3312.0 Safari/537.36"); var desktop = (!__md && !md.phone()); localopts.desktop = desktop; hh = Mustache.render(hh,localopts); pg.hh = hh; pg.render = true; pg.title = "Home"; pg.onrender = function() { /** * it always ends up here , regardless if you ned to go through the intro sequence or not */ let highestpage = nav_get_higiest_page(); //alert(highestpage); mar.cancelpopup = "y"; if (mar.WE_ARE_FROM_LOI) { mar.toggle_menu(); return; } if (highestpage == "#scenario-timeframe") { mvc.go("#up-next-wishlist"); } else { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Continuing the app?").render()+ "We can put you back where you left off to CONTINUE the application, or you can start again at the BEGINNING"; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, closeOnClickOutside: false, closeOnEsc: false, buttons : { cancel : "BEGINNING", call : { text: "CONTINUE", value: "call", closeModal: false } } }) .then((act) => { if (mar.cancelpopup !== "y") { swal.close; return; } if (act == "call") { if (highestpage.startsWith("#scenario-magic2")) { let sp = mar.isallowed_scenario("#scenario-mortgageyes"); if (typeof sp === "string") { $("#replacementpagetext").html(frm.htitle("Awaiting co-pilot").render()+"
    We are awaiting your Loan Officer to start the session , please wait a moment."); $("#replacementpagestyle").html(""); swal.close(); //mvc.go(sp); return; } mvc.go("#scenario-mortgageyes"); } else { mvc.go(highestpage); } swal.close(); } else { mvc.go("#up-next-wishlist"); swal.close(); } }); } //mar.openmenu_in_the_final_instance(); } } return { render : render, section : "info" } })() mar.pg["scenario-end"] = (function(){ var html = ""; function render(pg, localopts) { let hh = ""; hh += frm.working().render(); var md = new MobileDetect(window.navigator.userAgent); var __md = (window.navigator.userAgent == "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3312.0 Safari/537.36"); var desktop = (!__md && !md.phone()); localopts.desktop = desktop; hh = Mustache.render(hh,localopts); pg.hh = hh; pg.render = true; pg.title = "Home"; pg.onrender = function() { let sp = mar.isallowed_scenario("#scenario-end"); if (typeof sp === "string") { mvc.go(sp); return; } setScenario_data("__scenario_end_passed","Y"); mar.fakesave(function(){ mvc.goto("#_0800",false); }); // if (getScenario_data("visited_personaldata","N") === "N") { // setScenario_data("visited_personaldata","Y"); // setScenario_data("__scenario_"+"end"+"_passed","Y"); // mar.fakesave(); // mvc.go("#up-next-personalinfo"); // return; // } // // // if (getScenario_data("visited_scenariorealtor","N") === "Y") { // setScenario_data("visited_scenariorealtor","Y"); // setScenario_data("__scenario_"+"end"+"_passed","Y"); // mar.fakesave(); // mvc.go("#income-how"+"."+applicantnum); // //mvc.go("#scenario-summary"); // } else { // setScenario_data("visited_scenariorealtor","Y"); // setScenario_data("__scenario_"+"end"+"_passed","Y"); // mar.fakesave(); // mvc.go("#up-next-income"+"."+applicantnum); // } } } return { render : render } })() /* * this is a screen to evaluate the ease of the section * */ mar.pg["evaluate-section"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; var inc = getIncome_v2(); let itm = (existingid) ? MAR.liabilities.get("evaluatesection",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 /** * standard starting block - END */ let h = ""; //h += frm.htitle("alimony").render(); //h += frm.elaine("In the declaration you indicated that you have to pay alimony. Please let us know the details of the payment plan.","er").render(); //h += "
    "; // JC - CW - elaine added div h += "
    "; //h += "
    On a scale from 1 to 5, how easy was this section to complete?
    "; VAL = ''; h += frm.radio("rating","On a scale from 1 to 5, how easy was this section to complete?",VAL,"","",function(){ },{ 1 : "1", 2 : "2", 3 : "3", 4 : "4", 5 : "5" }).render(); h += "
    Very hard
    "; h += "
    Very easy
    "; h += "
    How would you make it better?
    "; h += ""; h += "
    Submit Feedback
    '"; h += "
    "; //close evaluation section //h += "
    "; // JC - CW - elaine - added end div /* end modal content */ //h += uihelpers.cbuttonbar("","","","","mar.help()"); h = Mustache.render(h,localopts); let checkListChange = function(e) { } let oc = function() { } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); $("#body-container .xx-checklist").mychecklist(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); //$("#body-container .turnIntoCheckbox input").attr('type','checkbox'); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); /* */ mar.pg["ext-checkings"] = (function(){ var VAL = 'N' var html = ""; function render(pg, localopts) { /** * standard starting block */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let h = ""; h += frm.htitle("Checkings").render(); h += frm.elaine("Select the financial institution you have a checking account with.","").render(); h += "
    "; VAL = ''; /* end modal content */ // let pagenames = { // bank_of_america : "Bank of America", // chase : "Chase", // citi_bank : "Citibank", // wells_fargo : "Wells Fargo", // capital_one : "Capital One", // usaa : "USAA", // navy_federal_credit_union : "Navy Federal Credit Union", // u_s_bank : "U.S. Bank", // sun_trust : "Sun Trust", // other : "Other" // } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ //setScenario_data("__assets_echeck_passed","Y"); //mvc.go("#income-summary"+"."+applicantnum); }),"close",frm.addfunction(function(){ // nothing }),"mar.help()"); h = Mustache.render(h,localopts); let or = function(){ let sp = mar.isallowed_assets("#ext-checkings"); if (typeof sp === "string") { mvc.go(sp); return; } //h += "
    "+$("#svg_bank_of_america_assets").html()+"Bank of America
    "+$("#svg_chase_assets").html()+"Chase
    "+$("#svg_citi_bank_assets").html()+"Citibank
    "; $.get("/api/yodlee/providers", function(data){ if (data && "provider" in data) { var h = ""; let items = data.provider; for (let i=0; i < items.length; i++) { let item = items[i]; h += "
    " + "
    " + "" + "
    " + "" + item.name + "" + "
    " } h += ""; $("#option-grid").html(h); $(".incomeIcons_button").on('click', function(e){ console.log('pressed icon button e: ',e); let $elm = $(e.currentTarget); let goto = $elm.data("goto"); console.log('goto : '+goto); $.get("/api/yodlee/providers/"+goto, function(data){ //launch the overlay if (data && "provider" in data) { let item = data.provider[0]; var h = ""; h += "

    " + item.name + "

    " + "
    "; h += "
    "; //h += ""; for (let i=0; i < item.loginForm.row.length; i++) { let row = item.loginForm.row[i]; h += "
    "; h += row.label; h += "
    "; if ("field" in row) { let v = ("value" in row.field[0]) ? row.field[0].value : ""; let n = ("name" in row.field[0]) ? row.field[0].name : ""; h += "
    "; h += ""; h += "
    "; } } h += ""; mar.fn28 = function() { let vars = $("#loginform").serialize(); alert(vars); let vs = vars.split("&"); for (let i=0; i < vs.length; i++) { let kv = vs[i].split("="); let rowid = parseInt(kv[0].substring(1),10); item.loginForm.row[rowid].field[0].value = kv[1]; } alert(JSON.stringify(item.loginForm.row,null,4)); $.get("/api/yodlee/addaccount/"+goto+"?d="+JSON.stringify(item.loginForm.row), function(data){ }); } h += "
    Continue
    "; var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = h; // ""+ // "
    " +
    //								JSON.stringify(item.loginForm,null,4) +
    //								"
    " + // frm.htitle("Please choose your bank").render()+ // "
    "+ // // $("#svg_plaid_logo").html()+ // "
    "+ // "
    "+ // "PLAID LINK here? "+ // "
    "; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "CANCEL", use : { text: "USE THIS BANK", value: "use", closeModal: true } } }).then((act) => { if (act == "use") { //mar.pghelpers.callLoanOfficer(); //JC then use the selection details here to fill in the data? } }); } }); }); } }) // $("#body-container").find(".xx-radio").myradio(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); /* file /ui/app/js/pages2.js , last updated 1695908588143*/ function PGDBG(x) { console.error(x); } function nav_get_higiest_page() { /** * Introduction */ let nap = mar.getNextAllowablePage(); console.warn("NP1.1",nap); if (nap != false) { return nap; } /** * Scenario */ let highest_scenario_page = mar.isallowed_scenario(); // returns false if we have gone through scenario if (highest_scenario_page !== false) { return highest_scenario_page; } let route = getScenario_data("crossroads",""); if (route == "") { return "#scenario-crossroads"; } if (route == "route1") { } else { } /** * Assets */ if (getScenario_data("__assets_passed","N") == "N") { return "#assets-choice"; } /** * income */ if (getScenario_data("__income_passed","N") == "N") { return "#income-how"; } /** * reo */ if (MAR.is_refi() === true || getDoOwnRealestate() == true) { if (getScenario_data("__reo_passed_0","N") == "N") { return "#reo-home"; } } return "#lox"; } /* "Y" __assets_checkings_passed : "Y" __assets_echeck_chosenbank : "" __assets_echeck_chosenbank_route : "" __assets_passed : "Y" __assets_unas_passed : "Y" __assets_unpi_passed : "Y" __hasvisited_budget : "Y" __hasvisited_c2c : "Y" __hasvisited_crossroads : "Y" __hasvisited_hoi : "Y" __income_passed : "Y" __income_passed_0 : "Y" __income_passed_1 : "Y" __income_unin_passed_0 : "Y" __income_unin_passed_1 : "Y" __scenario_borrower_1_passed : "Y" __scenario_borrowers_0_passed : "Y" __scenario_borrowers_1_passed : "Y" __scenario_borrowers_num : "2" __scenario_budget1_passed : "Y" __scenario_c2c_passed : "Y" __scenario_creditscore_0_passed : "Y" __scenario_creditscore_1_passed : "Y" __scenario_crossroads_passed : "Y" __scenario_declarep1_0_passed : "Y" __scenario_declarep1_1_passed : "Y" __scenario_declarep2_0_passed : "Y" __scenario_declarep2_1_passed : "Y" __scenario_declarep3_0_passed : "Y" __scenario_declarep3_1_passed : "Y" __scenario_end_passed : "Y" __scenario_hoa_passed : "Y" __scenario_hoi_passed : "Y" __scenario_housingbudget_0_passed : "Y" __scenario_housingbudget_1_passed : "Y" __scenario_legalstatus_0_passed : "Y" __scenario_legalstatus_1_passed : "Y" __scenario_location_passed : "Y" __scenario_mcc_passed : "Y" __scenario_occupancy_passed : "Y" __scenario_pastproperty_0_passed : "Y" __scenario_pastproperty_1_passed : "Y" __scenario_property_passed : "Y" __scenario_purchaseprice_passed : "Y" __scenario_realtor_passed : "Y" __scenario_realtorinfo_passed : "Y" __scenario_tax_passed : "Y" __scenario_timeframe_passed : "Y" __scenario_unprescan_passed : "Y" __scenario_veteran_0_passed : "Y" __scenario_veteran_1_passed : "Y" */ mar.pg_silent_function = false; mar.pg_silent_goto = function(pg, fn) { if (mar.pg_silent_function) { mar.pg_silent_function(pg); return; } if (fn) fn(); } mar.pg["_0100x"] = (function(){ function render(pg, localopts) { let h = ""; let or = function(){ mar.pg_silent = true; mvc.goto("#_0100",false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["_0100"] = (function(){ //@ pg 100 #app route function render(pg, localopts) { let h = ""; let or = function(){ if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * app route */ if (MAR.master_router.passed(mar.answers,"0100",MAR.master_router.states.PASSED)){ mar.fakesave(); } mvc.goto("#_0200",false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["_0200"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } if (MAR.master_router.passed(mar.answers,"0100") !== MAR.master_router.states.PASSED) { mvc.goto("#_0100",false); return; } /** * intro * * Here we should select the correct page of Intro to go to otherwise go to 300 which is the scenario router */ let nap = mar.getNextAllowablePage(); console.warn("NP1",nap); if (nap != false) { mar.pg_silent_goto(nap, function(){ mar.gotoNextAvailablePage(); }); return; } if (MAR.master_router.passed(mar.answers,"0200",MAR.master_router.states.PASSED)){ mar.fakesave(); } mvc.goto("#_0300",false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.isallowed_type = "s"; mar.isallowed = function(pg,N, isallowedtype, do_not_stop_at_first = false) { if (mar.WE_ARE_FROM_LOI === true) { if (mar.WE_ARE_FROM_LOI_TAG !== false) { let _TAG = mar.WE_ARE_FROM_LOI_TAG.split(".")[0]; console.log(mar.WE_ARE_FROM_LOI_TAG); if (_TAG === pg) { return true; } } } if (arguments.length > 2 && isallowedtype && isallowedtype !== false) { mar.isallowed_type = isallowedtype; } if (MAR.appnav.loanWasSubmitted()) { setScenario_data("__scenario_ratequote_0_passed_cli" , "Y"); setScenario_data("__scenario_declareupnext_0_passed" , "Y") } let borrowercount = "1"; //getScenario_data("__scenario_borrowers_num","1"); if (getScenario_data("is_there_a_second_borrower","N") === "Y") borrowercount = "2"; if (getScenario_data("is_there_a_third_borrower","N") === "Y") borrowercount = "3"; if (getScenario_data("is_there_a_fourth_borrower","N") === "Y") borrowercount = "4"; if (getScenario_data("is_there_a_fifth_borrower","N") === "Y") borrowercount = "5"; if (getScenario_data("is_there_a_sixth_borrower","N") === "Y") borrowercount = "6"; if (getScenario_data("is_there_a_seventh_borrower","N") === "Y") borrowercount = "7"; if (getScenario_data("is_there_a_eighth_borrower","N") === "Y") borrowercount = "8"; let pages = []; if (mar.isallowed_type.startsWith("s")) { // (function(){ if (mar.WE_ARE_FROM_LOI === false) { if (getScenario_data("__scenario_ratequote_0_passed_cli" , "") === "Y") { if (getScenario_data("__scenario_ratequote_0_passed_new" , "") === "NEW") { pages.push( [ "__scenario_ratequote_0_passed_new" , "#general-ratequotes" ]); mar.tmp_we_were_forced_to_ratequote = true; // if (typeof pg === "string" && pg.indexOf("ratequote") > -1) { // /** we must be on a ratequote page */ // } else if (pg === false) { // /** we must be aking in general */ // pages.push( [ "__scenario_ratequote_0_passed_new" , "#general-ratequotes" ]); // } else { // pages.push( [ "__scenario_ratequote_0_passed_new" , "#general-ratequotes" ]); // } } } } if (mar.isallowed_type == "s" || mar.isallowed_type == "sloantype") { pages.push( [ "__scenario_loantype_passed" , "#scenario-loantype" ]); } if (mar.isallowed_type == "s" || mar.isallowed_type == "stimeframe") { pages.push( [ "__scenario_timeframe_passed" , "#scenario-timeframe" ]); } if (mar.isallowed_type == "s" || mar.isallowed_type == "sproperty") { pages.push( [ "__scenario_occupancy_passed" , "#scenario-occupancy" ]); pages.push( [ "__scenario_location_passed" , "#scenario-location" ]); pages.push( [ "__scenario_property_passed" , "#scenario-property" ]); if (MAR.isMccEligible()) { pages.push( [ "__scenario_mcc_passed" , "#scenario-mcc" ]); } pages.push( [ "__scenario_crossroads_passed" , "#scenario-crossroads" ]); } if (mar.isallowed_type == "s" || mar.isallowed_type == "scenario") { if (mar.WE_ARE_FROM_LOI === false) { pages.push( [ "__scenario_whatsapp_passed" , "#scenario-whatsapp" ]); } pages.push( [ "__scenario_creditscore_0_passed" , "#scenario-creditscore.0" ]); pages.push( [ "__scenario_pastproperty_0_passed" , "#scenario-pastproperty.0" ]); pages.push( [ "__scenario_legalstatus_0_passed" , "#scenario-legalstatus.0" ]); pages.push( [ "__scenario_veteran_0_passed" , "#scenario-veteran.0" ]); pages.push( [ "__scenario_housingbudget_0_passed" , "#scenario-housingbudget.0" ]); pages.push( [ "__scenario_housingbudget_0_passed" , "#scenario-housingbudget2.0" ]); pages.push( [ "__scenario_housingbudget_0_passed" , "#scenario-housingbudget3.0" ]); pages.push( [ "__scenario_ratequote_0_passed" , "#scenario-ratequote.0" ]); if (mar.WE_ARE_FROM_LOI === true) { pages.push( [ "__scenario_ratequote_0_passed" , "#scenario-ratequote1.0.0" ]); } if (MAR.is_phase_rq()) { pages.push( [ "__scenario_ratequote_0_passed_phaserq" , "#general-endrqphase" ]); } if (mar.WE_ARE_FROM_LOI === false) { // pages.push( [ "__scenario_ratequote_0_passed_cli" , "#scenario-ratequote.0" ]); pages.push( [ "__scenario_ratequote_0_passed_cli" , "#general-ratequotes" ]); } pages.push( [ "__scenario_declareupnext_0_passed" , "#up-next-declarations.0" ]); pages.push( [ "__scenario_declarep1_0_passed" , "#declarations-p1.0" ]); pages.push( [ "__scenario_declarep2_0_passed" , "#declarations-p2.0" ]); pages.push( [ "__scenario_declarep3_0_passed" , "#declarations-p3.0" ]); pages.push( [ "__scenario_borrowers_0_passed" , "#scenario-borrowers.0" ]); for (let i=1; i < MAR.MAXBORROWERS; i++) { if (num(borrowercount) > i) { pages.push( [ `__scenario_borrower_${i}_passed` , `#scenario-borrower.${i}` ]); pages.push( [ `__scenario_creditscore_${i}_passed` , `#scenario-creditscore.${i}` ]); pages.push( [ `__scenario_pastproperty_${i}_passed` , `#scenario-pastproperty.${i}` ]); pages.push( [ `__scenario_legalstatus_${i}_passed` , `#scenario-legalstatus.${i}` ]); pages.push( [ `__scenario_veteran_${i}_passed` , `#scenario-veteran.${i}` ]); // pages.push( [ `__scenario_housingbudget_${i}_passed` , `#scenario-housingbudget.${i}` ]); pages.push( [ `__scenario_declareupnext_${i}_passed` , `#up-next-declarations.${i}` ]); pages.push( [ `__scenario_declarep1_${i}_passed` , `#declarations-p1.${i}` ]); pages.push( [ `__scenario_declarep2_${i}_passed` , `#declarations-p2.${i}` ]); pages.push( [ `__scenario_declarep3_${i}_passed` , `#declarations-p3.${i}` ]); pages.push( [ `__scenario_borrowers_${i}_passed` , `#scenario-borrowers.${i}` ]); } } } // if (mar.isallowed_type == "s" || mar.isallowed_type == "sproperty") { // pages.push( [ "__scenario_location_passed" , "#scenario-location" ]); // pages.push( [ "__scenario_occupancy_passed" , "#scenario-occupancy" ]); // pages.push( [ "__scenario_property_passed" , "#scenario-property" ]); // // if (MAR.isMccEligible()) { // pages.push( [ "__scenario_mcc_passed" , "#scenario-mcc" ]); // } // pages.push( [ "__scenario_crossroads_passed" , "#scenario-crossroads" ]); // } if (mar.isallowed_type == "s" || mar.isallowed_type == "sestimate") { let route = getScenario_data("crossroads","route1"); if (route == "route1") { } else { pages.push( [ "__scenario_unprescan_passed" , "#up-next-prescan" ]); pages.push( [ "__scenario_c2c_passed" , "#scenario-c2c" ]); pages.push( [ "__scenario_purchaseprice_passed" , "#scenario-purchaseprice" ]); pages.push( [ "__scenario_tax_passed" , "#scenario-tax" ]); pages.push( [ "__scenario_hoi_passed" , "#scenario-hoi" ]); pages.push( [ "__scenario_hoa_passed" , "#scenario-hoa" ]); pages.push( [ "__scenario_budget1_passed" , "#scenario-budget1" ]); //pages.push( [ "__scenario_budget_passed" , "#scenario-budget" ]); pages.push( [ "__scenario_budget1_passed" , "#scenario-magic2" ]); pages.push( [ "__scenario_mortgageyes_passed" , "#scenario-mortgageyes" ]); pages.push( [ "__scenario_mortgageyes2_passed" , "#scenario-mortgageyes2" ]); } } if (mar.isallowed_type == "s" || mar.isallowed_type == "srealtor") { if (MAR.is_refi() === false) { pages.push( [ "__scenario_realtor_passed" , "#scenario-realtor" ]); if ( getScenario_data("have_own_realtor","N") == "Y") { pages.push( [ "__scenario_realtorinfo_passed" , "#scenario-realtorinfo" ]); } } } if (mar.isallowed_type == "s") { pages.push( [ "__scenario_end_passed" , "#scenario-end" ]); } } if (mar.isallowed_type == "pi") { for (let i=0; i < MAR.MAXBORROWERS; i++) { if (num(borrowercount) > i) { pages.push( [ `__scenario_personaldata_${i}_passed` , `#scenario-personaldata.${i}` ]); pages.push( [ `__scenario_personaldata1_${i}_passed` , `#scenario-personaldata1.${i}` ]); pages.push( [ `__scenario_personaldata2_${i}_passed` , `#scenario-personaldata2.${i}` ]); pages.push( [ `__scenario_addresshistory_${i}_passed` , `#scenario-addresshistory.${i}` ]); } } pages.push( [ `authorizations-credit-ed_0_passed` , `#authorizations-credit-ed.${num(borrowercount)-1}` ]); } if (mar.isallowed_type == "a") { pages.push( [ "__assets_unas_passed" , "#up-next-assets" ]); pages.push( [ "__assets_passed" , "#assets-choice" ]); for (let i=0; i < MAR.MAXBORROWERS; i++) { if (num(borrowercount) > i) { pages.push( [ `__income_passed_${i}` , `#income-how.${i}` ]); } } pages.push( [ "__liabilities_passed" , "#liabilities-home" ]); if (MAR.is_refi() === true || getDoOwnRealestate() == true) { pages.push( [ "__reo_passed_0" , "#reo-home" ]); } pages.push( [ "__application_submitted" , "#lox" ]); } if (arguments.length > 1 && N !== false && N == 1) { for (let i=0; i < pages.length; i++) { if (pg == pages[i][1]) return true; } return false; } for (let i=0; i < pages.length; i++) { let passed = getScenario_data(pages[i][0],"N"); if (passed != "Y") { // not passed if (arguments.length > 0 && pg !== false) { if (pg == pages[i][1]) { if (do_not_stop_at_first === true) { return false; } return true; } } if (do_not_stop_at_first === false) { return pages[i][1] } } else { // passed if (arguments.length > 0) { if (pg !== false && pg && typeof pg == "string") { if (pages[i][1] == pg) { return true; } } } } } return false; } mar.isallowed_scenario = function(pg,N) { mar.isallowed_type = "s"; if (arguments.length == 0) return mar.isallowed(); if (arguments.length == 1) return mar.isallowed(pg); if (arguments.length == 2) return mar.isallowed(pg,N); } mar.isallowed_assets = function(pg,N) { mar.isallowed_type = "a"; if (arguments.length == 0) return mar.isallowed(); if (arguments.length == 1) return mar.isallowed(pg); if (arguments.length == 2) return mar.isallowed(pg,N); } mar.isallowed_pi = function(pg,N) { mar.isallowed_type = "pi"; if (arguments.length == 0) return mar.isallowed(); if (arguments.length == 1) return mar.isallowed(pg); if (arguments.length == 2) return mar.isallowed(pg,N); } mar.isallowed_all = function(pg,N) { if (arguments.length == 0) { let ias = mar.isallowed_scenario() if (typeof ias == "string") return ias; if (ias === true) return true; let iap = mar.isallowed_pi(); if (typeof iap == "string") return iap; if (iap === true) return true; let iaa = mar.isallowed_assets(); if (typeof iaa == "string") return iaa; if (iaa === true) return true; return false; } else if (arguments.length == 1) { let ias = mar.isallowed_scenario(pg) if (typeof ias == "string") return ias; if (ias === true) return true; let iap = mar.isallowed_pi(pg); if (typeof iap == "string") return iap; if (iap === true) return true; let iaa = mar.isallowed_assets(pg); if (typeof iaa == "string") return iaa; if (iaa === true) return true; return false; } else { if (mar.isallowed_scenario(pg,N)) return true; if (mar.isallowed_pi()) return true; if (mar.isallowed_assets(pg,N)) return true; return false; } } mar.pg["_0300"] = (function(){ // this is called from crossroads as the "NEXT" var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * router * * firstly if there is an entry hash then we have to go to that page * */ if (mvc.getEntryPageHash() && mvc.getEntryPageHash() != "" && mvc.entry_hash_used == false ) { mar.pg_silent_goto(mvc.getEntryPageHash(), function(){ mvc.entry_hash_used = true; mvc.go(mvc.getEntryPageHash()); }); return; } /** * determine if all the pages of scenario have been passed * */ let highest_scenario_page = mar.isallowed_scenario(); // returns false if we have gone through scenario // #up-next-prescan if (highest_scenario_page !== false) { mar.pg_silent_goto(highest_scenario_page, function(){ mvc.go(highest_scenario_page); }); return; } mvc.goto("#_0400",false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["_0400"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * scenario p1 -- this is routed in 300 so we can go straight to 500 */ mvc.goto("#_0500",false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["_0500"] = (function(){ // this is the choice to go to estimate or directly past to realtor var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * choice, depending on the choice we need to go to a different page * */ let route = getScenario_data("crossroads","route1"); if (route == "route1") { /** * determine if all the pages of scenario have been passed * */ let highest_scenario_page = mar.isallowed_scenario(); // returns false if we have gone through scenario if (highest_scenario_page !== false) { mar.pg_silent_goto(highest_scenario_page, function(){ mvc.go(highest_scenario_page); }); return; } mvc.goto("#_0600",false); } else { mvc.goto("#_0700",false); } } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["_0600"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * scenario p2 */ mvc.goto("#_0700",false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["_0700"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * scenario realtor */ // if not entered realtor mvc.goto("#_0800",false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["_0800"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * scenario end, goto 1000 which is smart assets! */ mvc.goto("#_1000",false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg_as = "1"; mar.pg_pd = "2"; mar.pg_in = "3"; mar.pg_pd = "1"; mar.pg_as = "2"; mar.pg_in = "3"; mar.pg_after_pd = `#_${mar.pg_as}000`; mar.pg_after_as = `#_${mar.pg_in}000`; mar.pg[`_${mar.pg_as}000`] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; mar.pg_accesscontrollerfn = function() { return "open"; } let oc = function() { } let or = function(){ if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * scenario end, goto 1000 which is smart assets! */ let highest_page = mar.isallowed_assets(); // returns false if we have gone through scenario if (highest_page !== false) { mar.pg_silent_goto(highest_page, function(){ mvc.go(highest_page); }); return; } mvc.goto(`#_${mar.pg_as}100`,false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg[`assets-start`] = mar.pg[`_${mar.pg_as}000`]; mar.pg[`_${mar.pg_as}100`] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * scenario end, goto 1000 which is smart assets! */ let sd = ""; if (getScenario_data("__assets_checkings_passed","N") == "N") { // if (getScenario_data("__assets_echeck_chosenbank","")) { // if (getScenario_data("__assets_echeck_chosenbank_route","") == "") { // mar.pg_silent_goto("#assets-bankconnect", function(){ // mvc.go("#assets-bankconnect"); // }); // return; // } // if (getScenario_data("__assets_echeck_chosenbank_route","") == "auto") { // mar.pg_silent_goto("#assets-importedaccounts", function(){ // mvc.go("#assets-importedaccounts"); // }); // return; // } // if (getScenario_data("__assets_echeck_chosenbank_route","") == "manual") { // mar.pg_silent_goto("#assets-bank", function(){ // mvc.go("#assets-bank"); // }); // return; // } // mar.pg_silent_goto("#assets-bankconnect", function(){ // mvc.go("#assets-bankconnect"); // }); // return; // } mvc.go("#assets-checkings") return; } /** we have gone past the inital bank account question */ // if (getScenario_data("__assets_echeck_chosenbank","") === "") { // // if (getScenario_data("__assets_echeck_chosenbank_route","") == "") { // mar.pg_silent_goto("#assets-bankconnect", function(){ // mvc.go("#assets-bankconnect"); // }); // return; // } // if (getScenario_data("__assets_echeck_chosenbank_route","") == "auto") { // mar.pg_silent_goto("#assets-importedaccounts", function(){ // mvc.go("#assets-importedaccounts"); // }); // return; // } // if (getScenario_data("__assets_echeck_chosenbank_route","") == "manual") { // mar.pg_silent_goto("#assets-bank", function(){ // mvc.go("#assets-bank"); // }); // return; // } // mar.pg_silent_goto("#assets-bankconnect", function(){ // mvc.go("#assets-bankconnect"); // }); // return; // } if (getScenario_data("__assets_passed","N") == "N") { mar.pg_silent_goto("#assets-choice", function(){ mvc.go("#assets-choice"); }); return; } mvc.goto(`#_${mar.pg_as}300`,false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg[`_${mar.pg_as}300`] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * scenario end, goto 1000 which is smart assets! */ if (getScenario_data("__assets_passed","N") == "N") { mvc.goto(`#_${mar.pg_as}100`,false); return; } mvc.goto(mar.pg_after_as,false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg[`_${mar.pg_pd}000`] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ PGDBG(`_${mar.pg_pd}000`); if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * scenario end, goto 1000 which is smart assets! */ if (getScenario_data("__assets_unpi_passed","N") == "N") { mar.pg_silent_goto("#up-next-personalinfo", function(){ PGDBG("_personal info - up next"); mvc.go("#up-next-personalinfo"); }); return; } // is pd passed let sta = ""; sta = sup_data_status("/applicants/address/_0/sup-data/personal-data"); PGDBG(`_${mar.pg_pd}000 `+sta); if (sta < 1) { mar.pg_silent_goto("#up-next-personalinfo", function(){ if (getScenario_data(`__scenario_personaldata_0_passed`,"") !== "Y") { mvc.go("#scenario-personaldata.0"); } else if (getScenario_data(`__scenario_personaldata1_0_passed`,"") !== "Y") { mvc.go("#scenario-personaldata1.0"); } else { mvc.go("#scenario-personaldata2.0"); } //mvc.go("#sd.applicants.address.0.sup-data.personal-data") }); return; } sta = sup_data_status("/applicants/address/_0/sup-data/address-history"); PGDBG(`_${mar.pg_pd}000 `+sta); if (sta < 1) { mar.pg_silent_goto("#up-next-personalinfo", function(){ mvc.go("#scenario-addresshistory.0"); // mvc.go("#sd.applicants.address.0.sup-data.address-history") }); return; } let c = MAR.getConsents(__ROLE); if (getScenario_data("authorizations-credit-ed_0_passed","N") != "Y") c = 0; else c = 1; if (c == 0) { mar.pg_silent_goto("#up-next-personalinfo", function(){ mvc.go("#authorizations-credit-ed."+(MAR.applicants.count() -1)) }); return; } // debugger; // sta = sup_data_status("/applicants/address/0/sup-data/consent-soft"); // PGDBG("_2000 "+sta); // if (sta < 1) { // mvc.go("#sd.applicants.address.0.sup-data.consent-soft") // return; // } mvc.goto(mar.pg_after_pd); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["personaldata-end"] = mar.pg[`_${mar.pg_pd}000`]; mar.pg["_3000"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ PGDBG("_3000"); if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * scenario end, goto 1000 which is smart assets! */ if (getScenario_data("__income_unin_passed_0","N") == "N") { mar.pg_silent_goto("#up-next-income.0", function(){ PGDBG("_income info - up next"); mvc.go("#up-next-income.0") }); return; } // is pd passed if (getScenario_data("__income_passed_0","N") == "N") { mar.pg_silent_goto("#income-how.0", function(){ mvc.go("#income-how.0") }); return; } getScenario_v2(); for (let ai=1; ai < MAR.MAXBORROWERS; ai++) { if (getApplicants_num() > ai) { // is pd passed if (getScenario_data(`__income_passed_${ai}`,"N") == "N") { mar.pg_silent_goto(`#income-how.${ai}`, function(){ mvc.go(`#income-how.${ai}`) }); return; } } } // if (getApplicants_num() > 1) { // // // is pd passed // if (getScenario_data("__income_passed_1","N") == "N") { // mar.pg_silent_goto("#income-how.1", function(){ // mvc.go("#income-how.1") // }); // return; // } // // } // if (getApplicants_num() > 2) { //// if (getScenario_data("__income_unin_passed_2","N") == "N") { //// mar.pg_silent_goto("#up-next-income.2", function(){ //// PGDBG("_income info - up next"); //// mvc.go("#up-next-income.2") //// }); //// return; //// } // // // is pd passed // if (getScenario_data("__income_passed_2","N") == "N") { // mar.pg_silent_goto("#income-how.2", function(){ // mvc.go("#income-how.2") // }); // return; // } // // } setScenario_data("__income_passed","Y") && mar.fakesave(); mvc.goto("#_3300",false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["_3300"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ PGDBG("_3300"); if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } /** * scenario end, goto 1000 which is smart assets! */ if (getScenario_data("__income_passed","N") == "N") { mvc.goto("#_3000",false); return; } mvc.goto("#_4000",false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["income-end"] = mar.pg["_3000"]; // liabilities mar.pg["_4000"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ PGDBG("_4000"); if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } if (getScenario_data("__liabilities_passed","N") == "N") { mar.pg_silent_goto("#liabilities-home", function(){ mvc.go("#liabilities-home") }); return; } if (MAR.is_refi() === true || getDoOwnRealestate() == true) { mvc.goto("#_4500",false); } else { mvc.goto("#_5000",false); } } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["liabilities-end"] = mar.pg["_4000"]; //liabilities mar.pg["_4500"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ PGDBG("_4500"); if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } if (MAR.is_refi() === true || getDoOwnRealestate() == true) { if (getScenario_data("__reo_passed_0","N") == "N") { mar.pg_silent_goto("#reo-home.0", function(){ mvc.go("#reo-home.0") }); return; } } mvc.goto("#_5000",false); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); mar.pg["reo-end"] = mar.pg["_4500"]; mar.pg["_5000"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { let h = ""; let oc = function() { } let or = function(){ PGDBG("_5000"); if (MAR.master_router.addroutestoapp(mar.answers)) { mar.fakesave(); } mar.pg_silent_goto("#lox", function(){ mvc.go("#lox"); PGDBG("END OF THE ROAD"); }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "" } return { render : render } })(); /* file /ui/app/js/pages3.js , last updated 1707123938369*/ mar.pg["review"] = (function(){ var html = ""; function render(pg, localopts) { let hh = ""; let pages = [ "income-how", "income-w2", "income-w2-previous", "income-llc", "income-k1", "income-disability", "income-child-support", "income-social-security", "income-pension", "income-other", "income-summary", "assets-checkings", "assets-choice", "assets-bank", "assets-savings", "assets-k401", "assets-ira", "assets-stock", "assets-cash", "assets-gifts", "assets-emd", "assets-nprf", "assets-other", "scenario-realtor", "scenario-realtorinfo", "scenario-crossroads", "liabilities-choice", "liabilities-summary", "liabilities-report", "liabilities-creditcard", "liabilities-carloan", "liabilities-instalmentloan", "liabilities-childsupport", "liabilities-alimony", "liabilities-irstax", "liabilities-studentloan", "liabilities-other", "evaluate-section", "up_next", "up-next-wishlist", "up-next-income", "up-next-homework", "up-next-prescan", "up-next-expect", "authorizations-credit-ed", "up-next-employmentinfo", "up-next-personalinfo", "up-next-assets", "assets-importedaccounts", "assets-bankconnect", "ext-checkings", "scenario-magic3", "scenario-proposal-p1", "scenario-proposal-p2", "declarations-p1" ]; for (let i=0; i < pages.length; i++) { hh += "
    "+pages[i]+"
    " } hh = Mustache.render(hh,localopts); pg.hh = hh; pg.render = true; pg.title = "Home"; pg.onrender = function() { } } return { render : render } })(); mar.pg["colin"] = (function(){ var html = ""; function render(pg, localopts) { let hh = ""; var loading = 'Calculating many more mortgage options than you may think...




    '+ '
    '+ '
    '+ '
    '+ '
    '; hh += loading; hh = Mustache.render(hh,localopts); pg.hh = hh; pg.render = true; pg.title = "Home"; pg.onrender = function() { } } return { render : render } })(); //mar.pg["scenario-proposal-p1"] = (function(){ mar.pg["scenario-mortgageyes"] = (function(){ var VAL = 'N' var html = ""; function gettoday() { var today = new Date(); var dd = today.getDate(); var mm = today.getMonth() + 1; //January is 0! var yyyy = today.getFullYear(); if (dd < 10) { dd = '0' + dd; } if (mm < 10) { mm = '0' + mm; } var today = '('+mm + '/' + dd + '/' + yyyy+')'; return today; } var proposalDate = gettoday(); var pieArray = []; function render(pg, localopts) { function roundVal(value, decimals) { return Number(Math.round(value+'e'+decimals)+'e-'+decimals); } let h = ""; h += frm.htitle("Proposal 1 "+proposalDate+" PT. 1").render(); h += frm.elaine("Here is what your monthly bills roughly look like. Your actual rate, payments and cost could be higher. Make sure you get an official loan estimate before closing a loan.","").render(); h += "
    "; // let mortgage = getScenario_data("mortgage",false); let mortgage = false; console.warn("mortgage",mortgage); h += uihelpers.cbuttonbar("This Works!",frm.addfunction(function(){ /* var val = yn("#can_afford"); if (val == 'N' ) { mar.tip(".help-button","warning","If you cannot afford this monthly budget you will need to modify your application.","top"); return; } */ setScenario_data("__scenario_"+"mortgageyes"+"_passed","Y"); mar.fakesave("",function(){ mvc.go("#scenario-mortgageyes2"); }) }),"Modify",frm.addfunction(function(){ // mvc.go("#scenario-mortgage"); mvc.go("#scenario-magic2"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ let sp = mar.isallowed_scenario("#scenario-mortgageyes"); if (typeof sp === "string") { mvc.go(sp); return; } elaine_adapter.mortgage.get(mar.ID,"1", function(mortgage) { if (mortgage !== false) { h = ""; h += '
    '; h +='
    '; let mmr = mortgage.appsum2; console.warn("MMR!!: ",mmr); console.warn("mmr[0]: ",mmr[0]); mmr[0] = "hhy TOTAL ESTIMATED PAYMENT"; h += makeNewpopup(mmr, 'proposal', pieArray); //ok build new table here h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""+roundVal(mortgage.rate, 3)+"%
    Int. Rate"; h += "
    ";//end breakdown holder top cell- inner h += "
    ";//end breakdown holder top cell h += "
    "; h += "
    "; h += ""+roundVal(mortgage.apr, 3)+"%
    APR"; h += "
    ";//end breakdown holder top cell- inner h += "
    ";//end breakdown holder top cell h += "
    "; h += "
    "; // h += "$"+roundVal(mortgage.buydown, 0)+" / "+roundVal(mortgage.audit_buydown_rate-100, 3) +"%
    Loan Points"; let __buydownrate = mortgage.pricing_price - mortgage.pricing_llpa h += "$"+roundVal(mortgage.buydown, 0)+" / "+roundVal(__buydownrate-100, 3) +"%
    Loan Points"; h += "
    ";//end breakdown holder top cell- inner h += "
    ";//end breakdown holder top cell h += "
    ";//end breakdown holder top h += "
    "; h += "
    "; h += "Loan Type"; h += "
    ";//end breakdown holder left h += "
    "; h += mortgage.filters.loantype; h += "
    ";//end breakdown holder left h += "
    ";//end rowholder h += "
    "; h += "
    "; h += "Program"; h += "
    ";//end breakdown holder left h += "
    "; h += mar._txt(mortgage.input_scenario.v2.programme); h += "
    ";//end breakdown holder left h += "
    ";//end rowholder h += "
    "; h += "
    "; h += "Purchase Price"; h += "
    ";//end breakdown holder left h += "
    "; h += elaineui.format("cur", mortgage.costsB.PurchasePrice); h += "
    ";//end breakdown holder left h += "
    ";//end rowholder h += "
    "; h += "
    "; h += "Down Payment"; h += "
    ";//end breakdown holder left h += "
    "; h += elaineui.format("cur", mortgage.filters.downpayment); h += "
    ";//end breakdown holder left h += "
    ";//end rowholder h += "
    "; h += "
    "; h += "Loan Amount"; h += "
    ";//end breakdown holder left h += "
    "; h += elaineui.format("cur", mortgage.filters.max_loan); h += "
    ";//end breakdown holder left h += "
    ";//end rowholder h += "
    "; h += "
    "; h += "LTV"; h += "
    ";//end breakdown holder left h += "
    "; h += elaineui.format("perc2", mortgage.final_ltv); h += "
    ";//end breakdown holder left h += "
    ";//end rowholder h += "
    "; h += "
    "; h += getScenario_data("cs_state","Estimated"); h += " Credit Score"; h += "
    ";//end breakdown holder left h += "
    "; h += mortgage.credit_score; h += "
    ";//end breakdown holder left h += "
    ";//end rowholder h += "
    "; h += "
    "; h += " MI percerntage"; h += "
    ";//end breakdown holder left h += "
    "; h += elaineui.format("perc2",mortgage.final_mi_py); h += "
    ";//end breakdown holder left h += "
    ";//end rowholder h += "
    "; h += "
    "; h += " Monthly MI "; h += "
    ";//end breakdown holder left h += "
    "; h += elaineui.format("cur",mortgage.final_mi); h += "
    ";//end breakdown holder left h += "
    ";//end rowholder h += "
    "; h += "
    "; h += " Up front MI percentage"; h += "
    ";//end breakdown holder left h += "
    "; h += elaineui.format("perc2",mortgage.final_ufmi_py); h += "
    ";//end breakdown holder left h += "
    ";//end rowholder h += "
    "; h += "
    "; h += " Up front MI percentage"; h += "
    ";//end breakdown holder left h += "
    "; h += elaineui.format("cur",mortgage.final_ufmi); h += "
    ";//end breakdown holder left h += "
    ";//end rowholder h += "
    ";//end breakdown holder console.warn("mortgage",mortgage); /* VAL = 'N'; h += frm.yn("can_afford","I can afford this:",VAL,"","",function(){ },{}).render(); */ h += "
    "; h += "
    ";//end breakdown bottom h +='
    '; h += frm.h2("
    This is not an approval for the loan. Your application has not been reviewed by an Underwriter.
    ").render(); h +="
    " + // "This calculation used an estimated market rate of " + // "" + elaineui.format("perc3",mortgage.apr_rate_py) + // " with an APR of " + // "" + elaineui.format("perc3",mortgage.apr) + // " for a " + // "" + elaineui.format("num",mortgage.loan_duration/12) + // " year fully amortizing loan." + ""; h +="Get an official quote by completing this loan application from your licensed Loan Officer " + loanofficer.name + " with NMLS ID " + loanofficer.nmls + ". Your actual rate, payment, and cost could be higher."; h +=" Get an official Loan Estimate before choosing a loan.

    "; h +="Read more"; h += "
    "; h += "The information provided above regarding Approximate Cost of Closing Fees, " + "Approximate Total Funds Needed To Close and the Approximate Total Monthly " + "Payment (collectively referred to as Approximate Loan Cost Illustration) " + "are only approximations. The actual fees, cost and monthly payment on your specific " + "loan transaction may vary and may include additional fees and cost. "; h += "
    ";//end readmore div h +="

    ";//end grey disclaimer h += "
    "; $(".result").html(h); function createPie(){ console.warn('check the pie arrary: ', pieArray); const svgEl = document.getElementById('budgetPieHolder'); var slices = [ { percent: 0.1, color: 'Coral' }, { percent: 0.65, color: 'CornflowerBlue' }, { percent: 0.2, color: '#00ab6b' }, ]; if(pieArray.length > 0){ slices = pieArray; } console.warn(" passed pie arrary : ", pieArray); let cumulativePercent = 0; function getCoordinatesForPercent(percent) { const x = Math.cos(2 * Math.PI * percent); const y = Math.sin(2 * Math.PI * percent); return [x, y]; } slices.forEach(slice => { // destructuring assignment sets the two variables at once const [startX, startY] = getCoordinatesForPercent(cumulativePercent); // each slice starts where the last slice ended, so keep a cumulative percent cumulativePercent += slice.percent; const [endX, endY] = getCoordinatesForPercent(cumulativePercent); // if the slice is more than 50%, take the large arc (the long way around) const largeArcFlag = slice.percent > .5 ? 1 : 0; // create an array and join it just for code readability const pathData = [ `M ${startX} ${startY}`, // Move `A 1 1 0 ${largeArcFlag} 1 ${endX} ${endY}`, // Arc `L 0 0` // Line ].join(' '); // create a and append it to the element const pathEl = document.createElementNS('http://www.w3.org/2000/svg', 'path'); pathEl.setAttribute('d', pathData); pathEl.setAttribute('fill', slice.color); svgEl.appendChild(pathEl); }); } createPie( ); } }) $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); oc(); $("#body-container").scrollTo(0,200); // replace dollars with dollars functions $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $(".next-button").addClass("sync"); $(".next-button").addClass("synch"); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "estimate" } })(); //mar.pg["scenario-proposal-p2"] = (function(){ mar.pg["scenario-mortgageyes2"] = (function(){ var VAL = 'N' var html = ""; function gettoday() { var today = new Date(); var dd = today.getDate(); var mm = today.getMonth() + 1; //January is 0! var yyyy = today.getFullYear(); if (dd < 10) { dd = '0' + dd; } if (mm < 10) { mm = '0' + mm; } var today = '('+mm + '/' + dd + '/' + yyyy+')'; return today; } var proposalDate = gettoday(); function render(pg, localopts) { let h = ""; h += frm.htitle("Proposal 1 "+proposalDate+" PT. 2").render(); h += frm.elaine("Below is the estimated cash you will need for closing. This sum includes down payment, closing cost, and pre-paid items.","er").render(); h += "
    "; // JC - CW - elaine added div h += "
    "; h += "
    "; h += uihelpers.cbuttonbar("Get Me Approved!",frm.addfunction(function(){ /* var val = yn("#can_afford"); if (val == 'N' ) { mar.tip(".help-button","warning","If you cannot afford your closing costs you will need to change your application.","top"); return; } */ setScenario_data("__scenario_"+"mortgageyes2"+"_passed","Y"); mar.fakesave("",function(){ mvc.go("#scenario-realtor"); }); //mvc.go("#income-how"); }),"Back",frm.addfunction(function(){ mvc.go("#scenario-mortgageyes"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ let sp = mar.isallowed_scenario("#scenario-mortgageyes2"); if (typeof sp === "string") { mvc.go(sp); return; } elaine_adapter.mortgage.get(mar.ID,"1", function(mortgage) { if (mortgage !== false) { h = ""; h += '
    '; h +='
    '; let mmr = mortgage.appsum4e; console.log('mortgage : ', mortgage); console.log('MMR : ', mmr); mmr[0] = "hhy CASH TO CLOSE CALCULATION"; h += makeC2Cpopup(mmr, 'c2c', mortgage); //h += "
    Details
    "; mar.appsum4details = function() { var $e = $("#appsum4details"); var h = ""; for (x in mortgage.costsAA) { var costsAA = mortgage.costsAA[x]; h += "

    "+x+"

    "; for (var y in costsAA) { if (costsAA[y] != 0) { h += "
    "+y+":"+costsAA[y]+"
    "; } } } $e.html(h); } // parsedData.outputs.costsA = { // lender_fees : cattot(4,[801,800]), // title_feed : cattot(4,[1100]), // tax : cattot(4,[1200]), // additional : cattot(4,[1300]), // prepaids : cattot(4,[900,1000]) // }; // parsedData.outputs.costsAA = { // lender_fees : catarray(4,[801,800]), // title_feed : catarray(4,[1100]), // tax : catarray(4,[1200]), // additional : catarray(4,[1300]), // prepaids : catarray(4,[900,1000]) // }; /* VAL = 'N'; h += frm.yn("can_afford","I can afford this:",VAL,"","",function(){ },{}).render(); */ h +='
    '; h += frm.h2("
    This is not an approval for the loan. Your application has not been reviewed by an Underwriter.
    ").render(); h +="
    This calculation used an estimated market rate of " + "" + elaineui.format("perc3",mortgage.apr_rate_py) + " with an APR of " + "" + elaineui.format("perc3",mortgage.apr) + " for a " + "" + elaineui.format("num",mortgage.loan_duration/12) + " year fully amortizing loan."; h +="Get an official quote by completing this loan application from your licensed Loan Officer " + loanofficer.name + " with NMLS ID " + loanofficer.nmls + ". Your actual rate, payment, and cost could be higher."; h +=" Get an official Loan Estimate before choosing a loan.

    "; h +="Read more"; h += "
    "; h += "
    "; h += "The information provided above regarding Approximate Cost of Closing Fees, " + "Approximate Total Funds Needed To Close and the Approximate Total Monthly " + "Payment (collectively referred to as Approximate Loan Cost Illustration) " + "are only approximations. The actual fees, cost and monthly payment on your specific " + "loan transaction may vary and may include additional fees and cost. "; h += "
    "; h +="

    ";//end grey disclaimner h += "
    "; h += "
    "+ "
    "; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "No,Thanks", call : { text: "Yes, Please", value: "print", closeModal: false } } }) .then((act) => { if (act == "print") { let ___lnk = "/api/mortgage/pdf?appid="+mar.ID+"&v=1&action=send"; // s.innerHTML = "


    Sending ....

    "; // swal({ // //title : "Same line of work", // className : "midelinfopopupOneButton", // content : s, // buttons : { // cancel : false, // ok : false // } // }); $.get(___lnk, function() { }) s.innerHTML = "
    The proposal has been sent via text.
    "; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s }); //mar.pghelpers.callLoanOfficer(); /* var myItems = $('#proposalToClosePrint'); var pdf = new jsPDF(); pdf.text(5, 5, 'CASH TO CLOSE CALCULATION'); pdf.text(5, 30, myItems.text()); pdf.save('proposal.pdf'); */ } }); })+"' >SEND BY TEXT / EMAIL
    "; h += "
    ";//end proposal $(".result").html(h); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } }); $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-slider").myslider(); oc(); $("#body-container").scrollTo(0,200); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "estimate", menuitem : "scenario-mortgageyes" } })(); let makeNewpopup = function(mmr, renderType, ar) { var h = ""; var totalVal = parseInt(mmr[6].split("\t")[2], 10); console.warn('totalval : '+totalVal); for (let i=0; i < mmr.length; i++) { let mmrlin = mmr[i].split("\t"); if (mmrlin[0] == "at") { // Attention h += "
    " + "
    ATTN:
    " + "
    " + mmrlin[1] + "
    " + "
    "; //h += "
    "; } if (mmrlin[0] == "hh") { // green rounded top h += "
    " + "
    " + mmrlin[1] + "
    " + "
    "; } if (mmrlin[0] == "hhy") { // yellow rounded top h += "
    " + "
    " + mmrlin[1] + "
    " + "
    "; } if (mmrlin[0] == "ht") { // green rounded top h += "
    " + "
    " + mmrlin[1] + "
    " + mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; } if (mmrlin[0] == "hc") { // green non rounded top h += "
    " + "
    " + mmrlin[1] + "
    " + mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; } if (mmrlin[0] == "hm") { // green non rounded top h += "
    " + "
    " + mmrlin[1] + "
    " + mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; } if (mmrlin[0] == "bd") { // white/green dots h += "
    " + "
    " + mmrlin[1] + "
    "+ "
    "+ "
    " + mar.fmt.currency(mmrlin[2]) + "
    "+ "
    "; } if (mmrlin[0] == "bh") { // wh/ite/yellow heading h += "
    " + "
    " + "
    " + mmrlin[1] + "
    " + "
    " + "
    "; } if (mmrlin[0] == "bg") { // grey sub total h += "
    " + "
    " ; console.warn("mmrlin[2]: "+mmrlin[2]); console.warn("parseInt(mmrlin[2]/totalVal, 10): "+parseFloat(mmrlin[2]/totalVal)); if(mmrlin[1] == 'Mortgage Insurance'){ ar.push({percent: parseFloat(mmrlin[2]/totalVal), color: '#05387a'}); bgSt = '#05387a'; }else if(mmrlin[1] == 'Property Taxes'){ ar.push({percent: parseFloat(mmrlin[2]/totalVal), color: '#d09948'}); bgSt = '#d09948'; }else{ //hoa fees ar.push({percent: parseFloat(mmrlin[2]/totalVal), color: '#fec76c'}); bgSt = '#fec76c'; } h += "
    "+ mmrlin[1] + "
    " + mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; } if (mmrlin[0] == "bgt") { // grey sub total h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; bgSt = '#2572c6'; h += "
    " + "
    "; h += "
    "+ mmrlin[1] + "
    " + mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; ar.push({percent: parseFloat(mmrlin[2]/totalVal), color: '#2572c6'}); } if (mmrlin[0] == "bgb") { // grey sub total h += "
    " + "
    "; bgSt = '#815c24'; h += "
    "+ mmrlin[1] + "
    " + mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; ar.push({percent: parseFloat(mmrlin[2]/totalVal), color: '#815c24'}); h += "
    ";// end popbody holder-right h += "
    ";// end popbody holder } if (mmrlin[0] == "fb") { // yellow/white rounded corners h += "
    " + "
    " + mmrlin[1] + "
    "+ "
    "+ "
    " + mar.fmt.currency(mmrlin[2]) + "
    "+ "
    "; } if (mmrlin[0] == "fbg") { // green/white rounded corners h += "
    " + "
    " + mmrlin[1] + "
    "+ "
    "+ "
    " + mar.fmt.currency(mmrlin[2]) + "
    "+ "
    "; } if (mmrlin[0] == "fbgm") { // green/white rounded corners h += "
    " + "
    " + mmrlin[1] + "
    "+ "
    -/-
    "+ "
    " + mar.fmt.currency(mmrlin[2]) + "
    "+ "
    "; } if (mmrlin[0] == "dt") { // yellow/white rounded corners h += "
    " + "
    " + mmrlin[1] + "
    "+ "
    "+ "
    " + "
    "+ "
    "; } } return h; } mar.pg.makeNewpopup = makeNewpopup; let makeExpandingBottom = function(mmr){ console.log('mmr:: ', mmr); var strToCheck =''; var h = ""; h += "
    "; for (let i=0; i < mmr.length; i++) { let mmrlin = mmr[i].split("\t"); console.log('mmrlin: ', mmrlin); if (mmrlin[0] == "ppth") {//pp top header h += "
    "+mmrlin[1]+"
    "; } if (mmrlin[0] == "ppi") {//pp item if(mmrlin[1]){ strToCheck = mmrlin[1]; // strToCheck = strToCheck.substring(strToCheck.indexOf("-") + 1); //strToCheck = /-(.+)/.exec(strToCheck)[1]; strToCheck = strToCheck.replace(/_/g, ' '); h += "
    "+strToCheck+"
    "+elaineui.format("cur", mmrlin[2])+"
    "; } } if (mmrlin[0] == "ps") {// pp sub info h += "
    "+mmrlin[1]+"
    "; //h += "
    23.65 per day for 7 days
    "; } if (mmrlin[0] == "ppt") {// pp total h += "
    "+mmrlin[1]+"
    "+elaineui.format("cur", mmrlin[2])+"
    "; } } /* h += "
    PRE-PAID ITEMS
    "; h += "
    Pre-paid interest
    1000
    "; h += "
    23.65 per day for 7 days
    "; h += "
    Homeowners Insurance
    1000
    "; h += "
    Est. first year annual premium
    "; h += "
    TOTAL
    2000
    "; h += "
    RESERVES
    "; h += "
    Property Taxes
    500
    "; h += "
    Est. 6 months
    "; h += "
    Homeowners Insurance
    500
    "; h += "
    Est. 2 months
    "; h += "
    TOTAL
    1000
    "; */ h += "
    "; h += "
    PRE-PAID ITEMS
    "; h += "
    These costs are not fees. They are not part of your closing cost, yet. You will have to pay for these expenses before closing.
    "; h += "
    ";//end innercomment h += "
    "; return h; } let makeC2Cpopup = function(mmr, renderType, mg) { var h = ""; var ccCount =0; var strToCheck =''; for (let i=0; i < mmr.length; i++) { let mmrlin = mmr[i].split("\t"); if (mmrlin[0] == "at") { // Attention h += "
    " + "
    ATTN:
    " + "
    " + mmrlin[1] + "
    " + "
    "; //h += "
    "; } if (mmrlin[0] == "hh") { // green rounded top h += "
    " + "
    " + mmrlin[1] + "
    " + "
    "; } if (mmrlin[0] == "hhy") { // yellow rounded top h += "
    " + "
    " + mmrlin[1] + "
    " + "
    "; h += "
    "; } if (mmrlin[0] == "ht") { // green rounded top h += "
    " + "
    " + mmrlin[1] + "
    " + mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; } if (mmrlin[0] == "hc") { // green non rounded top h += "
    " + "
    " + mmrlin[1] + "
    " + mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; } if (mmrlin[0] == "hm") { // green non rounded top h += "
    " + "
    " + mmrlin[1] + "
    " + mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; } if (mmrlin[0] == "bd") { // white/green dots if(mmrlin[1] == 'TOTAL'){ h += "
    " + "
    " ; if(ccCount === 0){ h += "TOTAL CLOSING COST"; }else if(ccCount === 1){ h += "ESTIMATED PREPAID COST"; }else{ h += "TOTAL COST"; } ccCount++; }else{ h += "
    " + "
    " ; h += mmrlin[1]; } h += "
    "+ "
    "+ "
    " + mar.fmt.currency(mmrlin[2]) + "
    "+ "
    "; } if (mmrlin[0] == "bh") { // wh/ite/yellow heading if(mmrlin[1] == 'CLOSING COST'){ h += "
    " + "
    " + "
    " + mmrlin[1] + "
    " + "
    " + "
    "; } } if (mmrlin[0] == "bg") { // grey sub total if(mmrlin[1] == 'Prepaids'){ h += "
    " + "
    " + "ESTIMATED PREPAID COST " + "
    "+ "
    "+ "
    " + mar.fmt.currency(mmrlin[2]) + "
    "+ "
    "; }else{ let bold_type = (mmrlin[1].startsWith("*")); if (bold_type) mmrlin[1] = mmrlin[1].substring(1); let minus_sign = (mmrlin[1].startsWith("-")); if (minus_sign) mmrlin[1] = mmrlin[1].substring(1); if(bold_type || mmrlin[1] == 'Purchase Price' || mmrlin[1] == 'Mortgage'){ h += "
    "; h += "
    "; } else { h += "
    "; h += "
    " ; } h += mmrlin[1] ; if(mmrlin[1] == 'Purchase Price' || mmrlin[1] == 'Mortgage'){ h += "
    "; } else { h += "
    "; } h += mar.fmt.currency(mmrlin[2]); h += "
    "; h += "
    "; if (minus_sign) { h += "
    -/-
    "; } h += "
    "; } } if (mmrlin[0] == "bgh") { // green sub header if(mmrlin[1] != 'Prepaids'){ h += "
    "; h += "
    " ; h += mmrlin[1] ; h += "
    "; h += mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; } } /* -- this is the detail cost line -- */ if (mmrlin[0] == "bgs") { // grey sub indented under green headers. if(parseFloat(mmrlin[2]) != 0){ if(mmrlin[1]){ strToCheck = mar._txt(mmrlin[1]); strToCheck = strToCheck.substring(strToCheck.indexOf("-") + 1); //strToCheck = /-(.+)/.exec(strToCheck)[1]; strToCheck = strToCheck.replace(/_/g, ' '); h += "
    "; h += "
    " ; h +=strToCheck; h += "
    "; h += mar.fmt.currency(mmrlin[2]); h += "
    " + "
    "; if (mar.pg_tmp_am_i_the_lo() === true) { if (MAR.getOpt(mmrlin, `3`,``) === `y`) { h += `
    apr
    `; } if (MAR.getOpt(mmrlin, `4`,``) === `y`) { h += `
    qm
    `; } } h += "
    "; } }else{ //its zero } } if (mmrlin[0] == "bgt") { // grey sub total h += "
    " + "
    " + mmrlin[1] + "
    " + mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; } if (mmrlin[0] == "bgb") { // grey sub total h += "
    " + "
    " + mmrlin[1] + "
    " + mar.fmt.currency(mmrlin[2]) + "
    " + "
    " + "
    "; } if (mmrlin[0] == "fb") { // yellow/white rounded corners h += "
    " + "
    " + mmrlin[1] + "
    "+ "
    "+ "
    " + mar.fmt.currency(mmrlin[2]) + "
    "; h +="
    "; h += "
    "; h += "
    "; h += "What are prepaid costs?"; h += makeExpandingBottom(mg.appsum4p); h += "
    ";//end expandingPrePaidsInner h += "
    ";//end expandingPrePaids h += "
    "; h += "
    ADJUSTABLE RATE MORTGAGE DISCLOSURE
    "; h += "
    After the fixed period shown, the rate on this adjustable rate mortgage may vary and the monthly payment may increase.
    "; h += "
    ";//end popbodyPPFooter h += "
    ";//end popbody-holder } if (mmrlin[0] == "fbg") { // green/white rounded corners h += "
    " + "
    " + mmrlin[1] + "
    "+ "
    "+ "
    " + mar.fmt.currency(mmrlin[2]) + "
    "+ "
    "; } if (mmrlin[0] == "dt") { // yellow/white rounded corners h += "
    " + "
    " + mmrlin[1] + "
    "+ "
    "+ "
    " + "
    "+ "
    "; } } return h; } mar.pg.makeC2Cpopup = makeC2Cpopup; /* file /ui/app/js/pages.intro.js , last updated 1708941218105*/ mar.pg["loanofficer"] = (function(){ var html = ""; function render(pg, localopts) { let h = ""; h += "
    "; // var st = "Franklin First Financial"; // if(st === 'Franklin First Financial'){ // document.getElementById('brokerLogo').src = '/ui/landing/img/fff_logo_stacked.png'; // }else if(st === 'Keller Williams'){ // document.getElementById('brokerLogo').src = '/ui/landing/img/fff_logo_stacked.png'; // // setTimeout(function(){ // // // // $('#licenses .c9').css('color', '#ffffff'); // // $('.inputPrompt').css('color', '#ffffff'); // $('.avatar-sub-name').css('color', '#ffffff'); // $('.quoteAuthorRealtor').css('color', '#ffffff'); // $('.quoteHolder').css('color', '#ffffff'); // $('.hrHolder').css('borderBottom', '1px solid #ffffff'); // $('#contactInfo_relator .inputPrompt').css('color', '#325d31', 'important'); // $('#contactInfo_lo .inputPrompt').css('color', '#325d31', 'important'); // $('#referral .inputPrompt').css('color', '#325d31', 'important'); // // }, 500); // }else{ // document.getElementById('brokerLogo').src = '/ui/landing/img/fff_logo_stacked.png'; // } // // setTimeout(function(){ // if ("#325d31" == "#c08f2f") { // $('#licenses .c9').css('color', '#ffffff'); // $('.avatar-sub-name').css('color', '#ffffff'); // $('.hrHolder').css('borderBottom', '1px solid #ffffff'); // $('.quoteHolder').css('color', '#ffffff'); // $('.quoteAuthorRealtor').css('color', '#ffffff'); // } // },1000); mar.continueOn = function() { mvc.set("loanofficerintro",true); //mvc.go("#_0100"); let _highestallowablepage = mar.getNextAllowablePage(); if (_highestallowablepage == false) { mvc.go("#scenario-timeframe"); } else { mvc.goto("#next" , false); } } pg.hh = h; pg.render = true; pg.title = "Realtor" pg.onrender = function() { // EL-3 $.get("/cfc/adminuserspublic/"+loanofficer.id+"?fmt=explode",function(data) { var na = getApplicantsNames_v2(0).Name; localopts.json = data[0].json; localopts.jsono = JSON.parse(data[0].json); localopts.person = data[0]; localopts.type = "Loan Officer"; localopts.local_year = new Date().getFullYear(); localopts.title = localopts.jsono.title; //LO_office_holder //officename //officelocation if ("tel" in localopts.jsono) localopts.jsono.telF = elaineui.telF(localopts.jsono.tel,localopts.jsono.tel); localopts.bubble = "Hi "+na+", As your Loan Officer my goal is simple: To get you the best financing terms possible. As fast as we can. Let's get this show on the road."; if (MAR.appnav.loanWasImported()) { localopts.bubble = "Hi "+na+", lets go over the application we started together. Any errors or missing questions, please correct them." + " thank you for the oppertunity to serve you on requested home financing." + ""; } localopts.licensetext = "NMLS"; localopts.isspecialoffers = false; localopts.jsono.imagename = MAR.getOpt(localopts.jsono,"imagename",""); if (localopts.jsono.imagename.trim().length === 0) localopts.jsono.imagename = "/ui/images/person-placeholder.jpg"; if (localopts.jsono.imagename.indexOf("/") < 0) localopts.jsono.imagename = "/ui/images/"+localopts.jsono.imagename; if (localopts.jsono.imagename.indexOf("/") !== 0) localopts.jsono.imagename = "/"+localopts.jsono.imagename; localopts.jsono.aboutus = MAR.cr2br(localopts.jsono.aboutus); console.warn('localopts',localopts) let h = ""; h += $("#page_intro_realtor").html(); h = Mustache.render(h,$.extend(___cols,localopts)); $("#page_intro_realtor_div").html(h); function launchTerms(st){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); if(st ==='tcpa'){ $.get('/cfc/ui/application/'+mar.ID+'/static_tcpa', function(da) { s.innerHTML = `
    ${da}
    `; }) } else if(st ==='privacy'){ $.get('/cfc/ui/application/'+mar.ID+'/static_privacypolicy', function(da) { s.innerHTML = `
    ${da}
    `; }) }else{ $.get('/cfc/ui/application/'+mar.ID+'/static_tandc', function(da) { s.innerHTML = `
    ${da}
    `; }) } swal({ className : "midelinfopopupOneButton", content : s, buttons : { cancel : "GOT IT" } }); } let showLegal = function(lnk) { if (lnk.startsWith("http://")) { var win = window.open(lnk, '_blank'); win.focus(); return; } var s = document.createElement("div"); s.innerHTML = `
    ${elaineui.working()}
    `; swal({ title : false, content : s, className : "midelinfopopupOneButton", buttons: { cancel: "GOT IT" } }) } $("#accessibility_btn").click(function(){ console.warn('pressed legal'); showLegal(localopts.person._config.accessibility_lnk) //openpage(localopts.person._config.accessibility_lnk) //mvc.go("#legal"); }) $("#ca_btn").click(function(){ console.warn('pressed legal'); showLegal(localopts.person._config.ca_lnk) //mvc.go("#legal"); }) $("#tcpa_btn").click(function(){ console.warn('pressed legal'); launchTerms("tcpa"); //openpage("https://elaine.ai/terms/tcpa.html") //mvc.go("#legal"); }) $("#legal_btn").click(function(){ console.warn('pressed legal'); launchTerms("legal"); //openpage("https://elaine.ai/terms/legal.html") //mvc.go("#legal"); }) $("#privacy_btn").click(function(){ console.warn('pressed privacy'); launchTerms("privacy"); //openpage(localopts.person._config.privacy_lnk) // mvc.go("#privacy"); }) $("#licenses_btn").click(function(){ console.warn('pressed licenses'); showLegal(localopts.person._config.licenses_lnk) //openpage(localopts.person._config.licenses_lnk) // mvc.go("#licenses"); }) let openpage = function(lnk) { // swal(lnk); if (lnk.startsWith("http://")) { var win = window.open(lnk, '_blank'); win.focus(); return; } var s = document.createElement("div"); s.innerHTML = `
    `; swal({ title : false, content : s, className : "midelinfopopupOneButton", buttons: { cancel: "GOT IT" } }) } //ugly but should work to hide the address field if no addresses found if ("officename" in localopts.jsono) { console.warn('officename:'+localopts.jsono.officename); }else{ console.warn('no officename:'+localopts.jsono.officename); if ("officelocation" in localopts.jsono) { console.warn('officelocation:'+localopts.jsono.officelocation); }else{ console.warn(' no officelocation:'+localopts.jsono.officelocation); //dont have both.. remove $("#LO_office_holder").css("display","none"); } } mar.revealSection = function(st, dispatcher){ //console.warn('dispatcher: ', dispatcher); $("#about_realtor_btn").css( { borderRadius: "3px" } ); $("#reviews_realtor_btn").css( { borderRadius: "3px" } ); $("#special_offers_realtor_btn").css( { borderRadius: "3px" } ); if($('#'+st).css("display") == 'block'){ $("#about_realtor").css("display","none"); $("#reviews_realtor").css("display","none"); $("#special_offers_realtor").css("display","none"); }else{ $("#about_realtor").css("display","none"); $("#reviews_realtor").css("display","none"); $("#special_offers_realtor").css("display","none"); dispatcher.style.borderBottomLeftRadius="0px"; dispatcher.style.borderBottomRightRadius="0px"; // $(dispatcher).css("border-radius-bottom-right","0px"); $('#'+st).show(); } /* $('#body-container').animate({ scrollTop: $("#scrollPoint").offset().top }, 600); */ } if ("state" in mar && "restoreposition" in mar.state && mar.state.restoreposition != false) { setTimeout(function(){ $("#body-container").scrollTo(mar.state.restoreposition,0,{ axis : "y" }); },2) } }); } } return { render : render } })(); mar.pg["realtor"] = (function(){ var html = ""; function render(pg, localopts) { let h = ""; h += "
    "; // var st = "Franklin First Financial"; // if(st === 'Franklin First Financial'){ // document.getElementById('brokerLogo').src = '/ui/landing/img/fff_logo_stacked.png'; // }else if(st === 'Keller Williams'){ // document.getElementById('brokerLogo').src = '/ui/landing/img/fff_logo_stacked.png'; // // setTimeout(function(){ // // // // $('#licenses .c9').css('color', '#ffffff'); // // $('.inputPrompt').css('color', '#ffffff'); // $('.avatar-sub-name').css('color', '#ffffff'); // $('.quoteAuthorRealtor').css('color', '#ffffff'); // $('.quoteHolder').css('color', '#ffffff'); // $('.hrHolder').css('borderBottom', '1px solid #ffffff'); // $('#contactInfo_relator .inputPrompt').css('color', '#325d31', 'important'); // $('#contactInfo_lo .inputPrompt').css('color', '#325d31', 'important'); // $('#referral .inputPrompt').css('color', '#325d31', 'important'); // // }, 500); // }else{ // document.getElementById('brokerLogo').src = '/ui/landing/img/fff_logo_stacked.png'; // } // // setTimeout(function(){ // if ("#325d31" == "#c08f2f") { // $('#licenses .c9').css('color', '#ffffff'); // $('.avatar-sub-name').css('color', '#ffffff'); // $('.hrHolder').css('borderBottom', '1px solid #ffffff'); // $('.quoteHolder').css('color', '#ffffff'); // $('.quoteAuthorRealtor').css('color', '#ffffff'); // } // },1000); mar.continueOn = function() { mvc.set("realtorintro",true); mvc.goto("#next" , false); } pg.hh = h; pg.render = true; pg.title = "Realtor" pg.onrender = function() { $.get("/cfc/adminuserspublic/"+___r_id+"?fmt=explode",function(data) { var na = getApplicantsNames_v2(0).Name; localopts.json = data[0].json; localopts.jsono = JSON.parse(data[0].json); localopts.person = data[0]; if ("tel" in localopts.jsono) localopts.jsono.telF = elaineui.telF(localopts.jsono.tel,localopts.jsono.tel); localopts.type = "Realtor"; //localopts.bubble = "Hi "+na+", happy to have you on board. As your realtor, I'll be assisting you in executing this important feat. Feel free to contact me directly anytime! It's easier than you think, so let's get started!"; localopts.bubble = "Welcome "+na+", You’ve made it to the right spot to start looking for a new place to call home. Click 'continue' and my trusted and endorsed loan officer, "+loanofficer.name+", will help you get things rolling."; if ("r" in mar && "cust_bubble" in mar.r && mar.r["cust_bubble"] !== "") localopts.bubble = mar.r["cust_bubble"]; localopts.licensetext = "License"; localopts.isspecialoffers = true; localopts.title = false; var x = localopts.aboutme_realtor; var y = localopts.jsono.aboutbroker; if ("aboutme_realtor" in localopts && localopts.aboutme_realtor.indexOf("<") < 0 && localopts.aboutme_realtor.indexOf("\n") > -1) { localopts.aboutme_realtor = localopts.aboutme_realtor.replace(/\r/g, "

    ") } if ("aboutbroker" in localopts.jsono && localopts.jsono.aboutbroker.indexOf("<") < 0 && localopts.jsono.aboutbroker.indexOf("\n") > -1) { let rj = (function(){ try { return JSON.parse(data[0].compliance_realtorjson); } catch (E) { return {}; } })(); let DEFT = `Nothing is more rewarding to me than making someone happy by finding them a place they can call their home. I’m a multi-million dollar top producer who is passionate about people and real estate. Over the years, this has allowed me to build a great network, as well as a keen knowledge of the local market.`+ `\n\nWe believe that nobody should overextend themselves when it comes to purchasing real estate, hence our focus on finding you a home you'll love that’s within your budget. And that same belief is why we recommend that you work with someone we trust who has your best interests at heart.`; let DEFM = ``; localopts.jsono.movielink = MAR.getOpt(rj, "movielink",DEFM); localopts.jsono.aboutbroker = MAR.getOpt(rj, "aboutbroker",DEFT)+`[ml:${localopts.jsono.movielink}]`; localopts.jsono.aboutbroker = localopts.jsono.aboutbroker.replace(/\n/g, "
    ") // this is the about broker } localopts.isspecialoffers = false; try { localopts.jsono.isYoutube = false; localopts.jsono.isVimeo = false; if ("movielink" in localopts.jsono && localopts.jsono.movielink != null) { var movie_split = localopts.jsono.movielink.split(":"); if (movie_split.length > 1) { if (movie_split[0] == "youtube") { localopts.jsono.isYoutube = true; localopts.jsono.youtubeid = movie_split[1]; } } if (localopts.jsono.movielink.indexOf("https://vimeo.com/") === 0) { localopts.jsono.isVimeo = true; localopts.jsono.vimeoid = localopts.jsono.movielink.substring(18).split("/")[0]; localopts.jsono.vimeoclientid = localopts.jsono.movielink.substring(18).split("/")[1]; } } } catch (e) { row._json = {}; } console.warn("localopts",localopts); let h = ""; h += $("#page_intro_realtor").html(); h = Mustache.render(h,$.extend(___cols,localopts)); $("#page_intro_realtor_div").html(h); function launchTerms(st){ var s = document.createElement("div"); s.setAttribute("class","normal-form"); if(st ==='tcpa'){ $.get('/cfc/ui/application/'+mar.ID+'/static_tcpa', function(da) { s.innerHTML = `
    ${da}
    `; }) } else if(st ==='privacy'){ $.get('/cfc/ui/application/'+mar.ID+'/static_privacypolicy', function(da) { s.innerHTML = `
    ${da}
    `; }) }else{ $.get('/cfc/ui/application/'+mar.ID+'/static_tandc', function(da) { s.innerHTML = `
    ${da}
    `; }) } swal({ className : "midelinfopopupOneButton", content : s, buttons : { cancel : "GOT IT" } }); } let showLegal = function(lnk) { if (lnk.startsWith("http://")) { var win = window.open(lnk, '_blank'); win.focus(); return; } var s = document.createElement("div"); s.innerHTML = `
    ${elaineui.working()}
    `; swal({ title : false, content : s, className : "midelinfopopupOneButton", buttons: { cancel: "GOT IT" } }) } $("#accessibility_btn").click(function(){ console.warn('pressed legal'); showLegal(localopts.person._config.accessibility_lnk) //openpage(localopts.person._config.accessibility_lnk) //mvc.go("#legal"); }) $("#ca_btn").click(function(){ console.warn('pressed legal'); showLegal(localopts.person._config.ca_lnk) //mvc.go("#legal"); }) $("#tcpa_btn").click(function(){ console.warn('pressed legal'); launchTerms("tcpa"); //openpage("https://elaine.ai/terms/tcpa.html") //mvc.go("#legal"); }) $("#legal_btn").click(function(){ console.warn('pressed legal'); launchTerms("legal"); //openpage("https://elaine.ai/terms/legal.html") //mvc.go("#legal"); }) $("#privacy_btn").click(function(){ console.warn('pressed privacy'); launchTerms("privacy"); //openpage(localopts.person._config.privacy_lnk) // mvc.go("#privacy"); }) $("#licenses_btn").click(function(){ console.warn('pressed licenses'); showLegal(localopts.person._config.licenses_lnk) //openpage(localopts.person._config.licenses_lnk) // mvc.go("#licenses"); }) let openpage = function(lnk) { // swal(lnk); if (lnk.startsWith("http://")) { var win = window.open(lnk, '_blank'); win.focus(); return; } var s = document.createElement("div"); s.innerHTML = `
    `; swal({ title : false, content : s, className : "midelinfopopupOneButton", buttons: { cancel: "GOT IT" } }) } //ugly but should work to hide the address field if no addresses found if ("officename" in localopts.jsono) { console.warn('officename:'+localopts.jsono.officename); }else{ console.warn('no officename:'+localopts.jsono.officename); if ("officelocation" in localopts.jsono) { console.warn('officelocation:'+localopts.jsono.officelocation); }else{ console.warn(' no officelocation:'+localopts.jsono.officelocation); //dont have both.. remove $("#LO_office_holder").css("display","none"); } } mar.revealSection = function(st, dispatcher){ //console.warn('dispatcher: ', dispatcher); $("#about_realtor_btn").css( { borderRadius: "3px" } ); $("#reviews_realtor_btn").css( { borderRadius: "3px" } ); $("#special_offers_realtor_btn").css( { borderRadius: "3px" } ); if($('#'+st).css("display") == 'block'){ $("#about_realtor").css("display","none"); $("#reviews_realtor").css("display","none"); $("#special_offers_realtor").css("display","none"); }else{ $("#about_realtor").css("display","none"); $("#reviews_realtor").css("display","none"); $("#special_offers_realtor").css("display","none"); dispatcher.style.borderBottomLeftRadius="0px"; dispatcher.style.borderBottomRightRadius="0px"; // $(dispatcher).css("border-radius-bottom-right","0px"); $('#'+st).show(); } /* $('#body-container').animate({ scrollTop: $("#scrollPoint").offset().top }, 600); */ } if ("state" in mar && "restoreposition" in mar.state && mar.state.restoreposition != false) { setTimeout(function(){ $("#body-container").scrollTo(mar.state.restoreposition,0,{ axis : "y" }); },2) } }); } } return { render : render } })() mar.pg["intro-2fa"] = (function(){ var VAL = 'N' var html = ""; var pages_to_verify = []; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let use_whatsapp = getScenario_data("use_whatsapp","Y"); mar.tcpa_btn_click = function(e){ e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); $.get(`/cfc/ui/application/${mar.ID}/static_tcpa?`, function(txt){ var s = document.createElement("div"); s.innerHTML = `
    ${txt}
    `; swal({ content : s, className : "midelinfopopupOneButton", buttons: { ok: { text: "Got It", closeModal: true } } }) }) }; mar.contact_radio_click = function(e){ e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); let txt = `By providing your phone number, you consent and agree to being contacted by us regarding your loan inquiry and mortgage products and services at the telephone number provided. You agree that we, or one of our authorized third parties, may contact you, including through automated means, via telephone or mobile device, even if your telephone number is listed in a Do-Not-Call registry. This consent is not required to obtain our goods and services. If you prefer to be contacted by other means uncheck this box.`; var s = document.createElement("div"); s.innerHTML = `
    ${txt}
    `; swal({ content : s, title : "Consent to contact", className : "midelinfopopupOneButton", buttons: { ok: { text: "Got It", closeModal: true } } }) }; mar.term_btn_click = function(e){ e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); $.get(`/cfc/ui/application/${mar.ID}/static_elaineterms?`, function(txt){ var s = document.createElement("div"); s.innerHTML = `
    ${txt}
    `; swal({ content : s, className : "midelinfopopupOneButton", buttons: { ok: { text: "Got It", closeModal: true } } }) }) return; let txt = $(".tandc_wrapper").html(); var s = document.createElement("div"); s.innerHTML = `
    ${txt}
    `; swal({ content : s, className : "midelinfopopupOneButton", buttons: { ok: { text: "Got It", closeModal: true } } }) }; mar.priv_btn_click = function(e){ e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); $.get(`/cfc/ui/application/${mar.ID}/static_privacypolicy?`, function(txt){ var s = document.createElement("div"); s.innerHTML = `
    ${txt}
    `; swal({ content : s, className : "midelinfopopupOneButton", buttons: { ok: { text: "Got It", closeModal: true } } }) }) return; let txt = $(".tandc_wrapper").html(); var s = document.createElement("div"); s.innerHTML = `
    ${txt}
    `; swal({ content : s, className : "midelinfopopupOneButton", buttons: { ok: { text: "Got It", closeModal: true } } }) }; mar.esig_btn_click = function(e){ e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); $.get(`/cfc/ui/application/${mar.ID}/static_elecsig?`, function(txt){ var s = document.createElement("div"); s.innerHTML = `
    ${txt}
    `; swal({ content : s, className : "midelinfopopupOneButton", buttons: { ok: { text: "Got It", closeModal: true } } }) }) return; let txt = $(".tandc_wrapper").html(); var s = document.createElement("div"); s.innerHTML = `
    ${txt}
    `; swal({ content : s, className : "midelinfopopupOneButton", buttons: { ok: { text: "Got It", closeModal: true } } }) }; mar.term_radio_click = function(e){ e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); var agreetcpa = radio("menu_agree_terms"); if (agreetcpa === "") { radio("menu_agree_terms","agree"); } else { radio("menu_agree_terms",""); } }; mar.tcpa_radio_click = function(e) { e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); var agreetcpa = radio("menu_agree_tcpa"); if (agreetcpa === "") { radio("menu_agree_tcpa","agree"); } else { radio("menu_agree_tcpa",""); } }; // var hh = $('#menu_agreeterms').html(); let hh = `
    `; localopts.desktop = mar.desktop; let h = ""; /** * specific stuff */ let is_2fa_approved = mvc.get("_2FA"); // if (is_2fa_approved) { // warning("You have Already entered a valid PIN.",localopts); // return; // // } var _2fa = localStorage.getItem('2FA'); //mar.requesttokencode(); h += "
    "; h += $('#menu_2fa').html(); h += "
    "; h += "
    "; h += "
    "; h += frm.htitle("Secure Your Data").render(); let pdwhop = `
    `; h += (function(){ let h = ""; let VAL = ""; h += frm.elaine(`Next, create a password to save your progress and access your application later`,"").render(); h += frm.txt("tel","Confirm your telephone number",VAL,"","",function(){ },"").render().wrap("
    ","
    "); // h += frm.txt("otp",`Enter the reset code sent by email`,VAL,"","",function(){ h += frm.txt("otp",`Enter the reset code sent by email`,VAL,"","",function(){ },"passw").render().wrap("
    ","
    "); h += frm.txt("ssn","Confirm the last 4 digits of your SSN",VAL,"","",function(){ },"").render().wrap("
    ","
    "); h += frm.txt("pwd","Password",VAL,"","",function(){ },"passw").render(); h += pdwhop; h += (`
    I did not recieve my code
    `).wrap("

    ","
    "); h += frm.radio("otp_not_recieved","","","","",function(){ let opt = radio("otp_not_recieved"); if (opt === "byemail") { mar.passwordForgot(function(){ radio("otp_not_recieved",""); },"email"); } else if (opt === "bysms") { mar.passwordForgot(function(){ radio("otp_not_recieved",""); },"sms"); } else if (opt === "bywhatsapp") { mar.passwordForgot(function(){ radio("otp_not_recieved",""); },"whatsapp"); } },{ byemail : "Send again via email", bysms : "Send again via SMS", bywhatsapp : "Send again via WhatsAPP" }).render().wrap("

    ","
    "); return h; })().wrap("
    ","
    "); h += (function(){ let h = ""; h += "
    "; h += hh return h; })().wrap("
    ","
    "); h += (function(){ let h = ""; var VAL = use_whatsapp; h += frm.hr().render() h += frm.yn3("use_whatsapp", `I use Whatsapp
    on ${elaineui.format("tel",___tel)}`,VAL,"","",function(){ oc(); }, {}).render(); return h; })().wrap("
    ","
    "); h += "
    "; mar.passwordForgot = async function(fn,method) { let rv = await mar.socket.send_and_receiveSync("app-reset-password", { appid : mar.ID, pwd : pwd, method : (typeof method === "string") ? method : "", fingerprint : mvc.get("fingerprint"), token : mvc.get("token") }, 20000); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = `

    ${rv.statusMsg}

    `; swal({ title : "warning", content : s, className : "midelinfopopupOneButton", buttons: { cancel: "OK", } }) .then((action) => { mvc.go("#intro-2fa"); }); if (fn) fn(); return; } h += "
    "; h += frm.htitle("Enter Password").render(); h += (function(){ let h = ""; let VAL = ""; h += frm.elaine(`Enter the password you chose when you first entered the app`,"").render(); h += frm.txt("pwd","Password",VAL,"","",function(){ },"passw").render(); return h; })().wrap("
    ","
    "); h += (function(){ let h = ""; let VAL = ""; h += frm.txt("pwdcode","Please enter the security code you have been sent via Email and Text",VAL,"","",function(){ },"").render(); h += `
    Re-Send Code
    `; return h; })().wrap("
    ","
    "); h += `
    Forgot password
    `; h += "
    "; h += "
    "; h += frm.htitle("Enter One Time Password").render(); h += (function(){ let h = ""; let VAL = ""; h += frm.elaine(`Enter the one time password you recieved via email`,"").render(); h += frm.txt("otp","",VAL,"","",function(){ },"passw").render(); return h; })().wrap("
    ","
    "); h += ``; h += "
    "; h += "
    "; h += frm.htitle("Security options").render(); h += frm.elaine(`You are already logged in see your options below.`,"").render(); h += (function(){ let h = ""; let VAL = ""; h += frm.radio("security_options","Action to perform:","none","","",function(){ let opt = radio("security_options"); $("#newpasswordbox").addClass("x-hide"); if (opt === "logout") { } else if (opt === "newpassword") { $("#newpasswordbox").removeClass("x-hide"); } },{ none : "None", logout : "Log out of app", newpassword : "Set a new password" }).render(); h += "
    "; // h += `
    Log out of app
    `; // h += "
    "; // h += ``; // h += "

    "; h += (function(){ let h = ""; h += frm.txt("new_pwd","New password",VAL,"","",function(){ }).render(); h += pdwhop; return h; })().wrap("
    ","
    "); // h += ``; mar.setNewPassword = async function() { let pwd = txt("#new_pwd"); let rv = await mar.socket.send_and_receiveSync("app-set-password", { appid : mar.ID, pwd : pwd, fingerprint : mvc.get("fingerprint"), token : mvc.get("token") }, 20000); if (rv.status < 0) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = `

    ${rv.statusMsg}

    `; swal({ title : "Warning", content : s, className : "midelinfopopupOneButton", buttons: { cancel: "Let’s try again ", } }) return; } var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = `

    New password it set

    `; swal({ title : "Warning", content : s, className : "midelinfopopupOneButton", buttons: { cancel: "Let’s try again ", } }) return; } mar.logOut = async function() { let rv = await mar.socket.send_and_receiveSync("app-logout-password", { appid : mar.ID, fingerprint : mvc.get("fingerprint"), token : mvc.get("token") }, 20000); mvc.set("_2FA",false, function(){ mvc.setEntryPageHash("#index"); mvc.go("#logged-out"); }); } h += "

    "; return h; })().wrap("
    ","
    "); h += "
    "; h += ""; // debugger; mar.checkVerification_index = 0; mar.checkVerification = function(n) { if (n < 0) { if (mar.checkVerification_index > 0) { $("#verification_nums .v"+mar.checkVerification_index).html(""); $(".vn"+n).removeClass("ef1"); mar.checkVerification_index--; } return; } mar.checkVerification_index++; $("#verification_nums .v"+mar.checkVerification_index).html(n); $(".vn"+n).removeClass("ef1"); setTimeout(function(){ //$(".vn"+n).addClass("ef1"); },1) if (mar.checkVerification_index == 4) { let pass = $(".v1").text()+$(".v2").text()+$(".v3").text()+$(".v4").text(); swal ({ content : $("
    checking..."+pass+"
    "), className : "midelinfopopupOneButton", buttons : false }); mar.checktokencode(pass, function(passed){ if (passed) { //swal("Passed") swal.close(); $("#verification_nums span").html(""); mar.checkVerification_index = 0; mvc.set("_2FA",true); mvc.goto("#next",false); //mar.gotoNextAvailablePage("#needs_list"); } else { $("#verification_nums span").html(""); mar.checkVerification_index = 0; mvc.set("_2FA",false); let count_2fa = mvc.get("_2FA_count"); if (count_2fa == false || typeof count_2fa !== "number") { count_2fa = 1; } else { count_2fa++; } mvc.set("_2FA_count",count_2fa); var s = document.createElement("div"); s.setAttribute("class","normal-form"); if (count_2fa == 1) { s.innerHTML = "

    First attempt

    "; } if (count_2fa == 2) { s.innerHTML = "

    Second attempt

    "; } if (count_2fa >= 3) { s.innerHTML = "

    That was your third attempt , please request a new code

    "; } swal({ title : "invalid code", content : s, className : "midelinfopopupOneButton", buttons: { ok: { text: "Resend code", value: "RESEND", closeModal: false }, cancel: (count_2fa >= 3) ? false : "Let’s try again ", } }) .then((action) => { if (action == "RESEND") { mar.requesttokencode(); count_2fa = 0; mvc.set("_2FA_count",count_2fa); swal.close(); } }); } }) } } h += uihelpers.cbuttonbar("continue",frm.addfunction(async function(){ if ($("#setpassword").html().length > 0) { let pwd = txt("#pwd"); let second = ""; let secondval = ""; if (continue_options.otp === true) { // otp needed also second = "otp"; secondval = txt("#otp"); } else if (continue_options.tel === true) { second = "tel"; secondval = txt("#tel"); } else if ($(`#pwd_ssn_div`).hasClass("x-hide") === false) { second = "ssn"; secondval = txt("#ssn"); } if (continue_options.tandc === true) { var agree = radio("menu_agree_terms"); if (agree == "") { mar.tip(".JourneyBox .help-button","warning", "You have to agree to the terms of the website before you can continue","top"); return false; } } if (continue_options.whatsapp === true) { var use_whatsapp = yn3("#use_whatsapp"); if (use_whatsapp == "") { mar.tip(".JourneyBox .help-button","warning", "You have to tell us if you use whatsapp","top"); return false; } setScenario_data("use_whatsapp",use_whatsapp); /* also skip whatsapp */ setScenario_data("skip_whatsapp","Y"); } let rv = await mar.socket.send_and_receiveSync("app-set-password", { appid : mar.ID, pwd : pwd, second : second, secondval : secondval, fingerprint : mvc.get("fingerprint"), token : mvc.get("token") }, 20000); if (rv.status < 0) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = `

    ${rv.statusMsg}

    `; swal({ title : "Warning", content : s, className : "midelinfopopupOneButton", buttons: { cancel: "Let’s try again ", } }) return; } mvc.set("_2FA",true); if (continue_options.tandc === true) { var agreetcpa = radio("menu_agree_tcpa"); if (agreetcpa == "") { elaineui.swalprompt({ cls : "middleInfoPopup", txt : frm.popup_warning("
    Are you sure you want to continue without agreeing to the communication policy? " + "

    You will not be able to receieve updates about your application via SMS and use the advanced chat functionality.
    "), ok : "I am sure", okfn : function(){ mar.answers.v2.intro_agreetogeneral = "Y"; mar.answers.v2.intro_intro_agreetogeneral_at = new Date().getTime(); $.get(`/api/app/tcpa/disagree?appid=${mar.ID}`, function(da){ }); setScenario_data("use_whatsapp","N"); /* also skip whatsapp */ mar.fakesave(); mvc.set("intro_agreetogeneral","Y"); if (MAR.is_phase_rq_password()) { setScenario_data("phase",""); mar.fakesave(function(){ mvc.set("realtorintro",true); mvc.set("loanofficerintro",true); mvc.go("#declarations-p1.0"); }); return; } mvc.goto("#next",false); }, cancel : "I agree", cancelfn : function(){ mar.answers.v2.intro_agreetogeneral = "Y"; mar.answers.v2.intro_intro_agreetogeneral_at = new Date().getTime(); $.get(`/api/app/tcpa/agree?appid=${mar.ID}`, function(da){ }); mar.fakesave(); mvc.set("intro_agreetogeneral","Y"); if (MAR.is_phase_rq_password()) { setScenario_data("phase",""); mar.fakesave(function(){ mvc.set("realtorintro",true); mvc.set("loanofficerintro",true); mvc.go("#declarations-p1.0"); }); return; } mvc.goto("#next",false); } }); return; } else { mar.answers.v2.intro_agreetogeneral = "Y"; mar.answers.v2.intro_intro_agreetogeneral_at = new Date().getTime(); $.get(`/api/app/tcpa/agree?appid=${mar.ID}`, function(da){ }); mar.fakesave(); mvc.set("intro_agreetogeneral","Y"); if (MAR.is_phase_rq_password()) { setScenario_data("phase",""); mar.fakesave(function(){ mvc.set("realtorintro",true); mvc.set("loanofficerintro",true); mvc.go("#declarations-p1.0"); }); return; } mvc.goto("#next",false); } } mvc.set("intro_agreetogeneral","Y"); if (MAR.is_phase_rq_password()) { setScenario_data("phase",""); mar.fakesave(function(){ mvc.set("realtorintro",true); mvc.set("loanofficerintro",true); mvc.go("#declarations-p1.0"); }); return; } mvc.goto("#next",false); return; } // here if ($("#enterpassword").html().length > 0) { let pwd = txt("#pwd"); let pwdcode = txt("#pwdcode"); let rv = await mar.socket.send_and_receiveSync("app-check-password", { appid : mar.ID, pwd : pwd, pwdcode : pwdcode, fingerprint : mvc.get("fingerprint"), token : mvc.get("token") }, 20000); $("#pwd-forget-button").addClass("x-hide"); $("#pwdcode-new-button").addClass("x-hide"); if (rv.status < 0) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = `

    ${rv.statusMsg}

    `; if (rv.status === -1) { // bad password $("#pwd-forget-button").removeClass("x-hide"); $("#pwdcode-new-button").addClass("x-hide"); } if (rv.status === -2) { // bad code $("#pwd-forget-button").addClass("x-hide"); $("#pwdcode-new-button").removeClass("x-hide"); } swal({ title : "warning", content : s, className : "midelinfopopupOneButton", buttons: { cancel: "Let’s try again ", } }) return; } if (rv.status === 1 || $(`#pwdcode_div`).hasClass(`x-hide`)) { $(`#pwdcode_div`).removeClass(`x-hide`); $("#pwd-forget-button").addClass("x-hide"); return; } mvc.set("_2FA",true); mvc.set("intro_agreetogeneral","Y"); mvc.goto("#next",false); return; } if ($("#enterotp").html().length > 0) { let otp = txt("#otp"); let rv = await mar.socket.send_and_receiveSync("app-check-otp", { appid : mar.ID, otp : otp, fingerprint : mvc.get("fingerprint"), token : mvc.get("token") }, 20000); if (rv.status < 0) { var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = `

    ${rv.statusMsg}

    `; swal({ title : "warning", content : s, className : "midelinfopopupOneButton", buttons: { cancel: "Let’s try again ", } }) return; } mvc.go("#intro-2fa"); return; } if ($("#loggedin").html().length > 0) { let opt = radio("security_options"); if (opt === "logout") { mar.logOut(); return; } if (opt === "newpassword") { mar.setNewPassword(); return; } mvc.go("#scenario-timeframe"); return; } }),"",frm.addfunction(async function(){ }),"mar.help()"); h = Mustache.render(h,localopts); // hh = Mustache.render(hh,$.extend(___cols,localopts)); mar.socket.send_and_receiveSync = function(code, obj, timeout) { return new Promise(function(resolve, reject) { mar.socket.send_and_receive(code, obj, function(retval) { resolve(retval); },timeout); }); } let rv_has_password = false; let rv_has_otp = false; let rv_is_loggedin = false; let continue_options = { tandc : false, otp : false, tel : false, ssn : false, whatsapp : false }; let update_pwdhop = function() { let val = ($("#new_pwd").length > 0) ? txt("#new_pwd") : txt("#pwd"); let cls = ""; let h = ""; let stillerrors = false; h += `
    Your password must contain:
    `; h += `
    `; cls = (val.length > 7) ? "dim" : ""; if (cls === "") stillerrors = true; h += `
    7 or more characters
    `; cls = (val.length > 0 && (/[A-Z]/.test(val))) ? "dim" : ""; if (cls === "") stillerrors = true; h += `
    A upper case character
    `; cls = (val.length > 0 && (/[a-z]/.test(val))) ? "dim" : ""; if (cls === "") stillerrors = true; h += `
    A lower case character
    `; cls = (val.length > 0 && (/[0-9]/.test(val))) ? "dim" : ""; if (cls === "") stillerrors = true; h += `
    A number
    `; cls = (val.length > 0 && (/[!#\$?\^%&\(\)@]/.test(val))) ? "dim" : ""; if (cls === "") stillerrors = true; h += `
    A special character (!#$?^%&@)
    `; h += `
    `; if (val.length > 0) { if (stillerrors === false) { /** * if there are no errors then wipe the display */ $("#pwdhop").addClass("x-hide"); $("#pwdhop").html(``); return; } $("#pwdhop").removeClass("x-hide"); } $("#pwdhop").html(`${h}`); } let or = async function(){ rv_has_password = await mar.socket.send_and_receiveSync("app-has-password", { appid : mar.ID }, 20000); rv_has_otp = await mar.socket.send_and_receiveSync("app-has-otp", { appid : mar.ID }, 20000); rv_is_loggedin = await mar.checktokenSync(); rv_is_rq_phase = MAR.is_phase_rq(); if (rv_is_loggedin.auth === true) { $("#passcode").html(""); $("#setpassword").html(""); $("#enterpassword").html(""); $("#enterotp").html(""); $("#loggedin").removeClass("x-hide"); $("#new_pwd").on("keyup", function() { update_pwdhop(); }); update_pwdhop(); } else if (rv_is_rq_phase || rv_has_password.data === false) { // enter password $("#passcode").html(""); $("#setpassword").removeClass("x-hide"); $("#setpassword #tandc_div").removeClass("x-hide"); $("#enterpassword").html(""); $("#enterotp").html(""); $("#loggedin").html(""); continue_options.tandc = true; if (getScenario_data("use_whatsapp","") === "") { $("#setpassword #whatsapp_div").removeClass("x-hide"); continue_options.whatsapp = true; } else { $("#setpassword #whatsapp_div").html(""); } if (getScenario_data("loan_type_purchase_options","") !== "" || MAR.appnav.loanWasImported() === true) { $("#setpassword #pwd_tel_div").removeClass("x-hide"); continue_options.tel = true; } // $("#pwd").on("focus", function() { // mar.tip("#pwd","Your password must contain:",`
    `,"bottom"); // update_pwdhop(); // }) // $("#pwd").on("blur", function() { // mar.cleartips(); // }) $("#pwd").on("keyup", function() { update_pwdhop(); }); update_pwdhop(); } else if (rv_has_otp.data > 0) { // otp $("#passcode").html(""); $("#setpassword").removeClass("x-hide"); $("#setpassword #pwd_otp_div").removeClass("x-hide"); $("#setpassword #pwd_otp2_div").removeClass("x-hide"); $("#setpassword #tandc_div").html(""); $("#enterpassword").html(""); $("#enterotp").html(""); $("#loggedin").html(""); continue_options.otp = true; let method = MAR.getOpt(rv_has_otp, "method" , ""); if (method !== "") $(".otp-method").text(method); $(".pwd-label").text("New password"); $("#pwd").on("keyup", function() { update_pwdhop(); }); update_pwdhop(); } else if (rv_has_password.data === true) { $("#passcode").html(""); $("#setpassword").html(""); $("#enterpassword").removeClass("x-hide"); $(".dr-button.next-button").text("Login"); $("#enterotp").html(""); $("#loggedin").html(""); } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); if ($("#maindiv.x-hide").length == 0 && $("#body-container .xhuman").length > 0) { $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false }); } setTimeout(function() { // route.page_simple_init(); // //mar.openmenu_in_the_final_instance(); // mvc.page(pg.title,"#intro."+_queued_menu_option); $("#body-container").scrollTo("max",200); },1000) } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["scenario-whatsapp"] = (function(){ var VAL = 'N' var html = ""; var pages_to_verify = []; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; var n0 = getApplicantsNames_v2(0).Name; let h = ""; let use_whatsapp = getScenario_data("use_whatsapp","Y"); mar.pg_accesscontrollerfn = function() { return "open"; } h += frm.htitle("Contact through WhatsApp").render(); h += frm.elaine(`We would like to keep you informed on the progress of your loan approval using an advanced A.I. system. You can ask questions and make appointments. It is not used for advertising, or spam. Nor is your contact info shared with anyone else than the lender. Contact via WhatsApp can be stopped at anytime by replying "STOP"`,"er").render(); h += "
    "; // h += `
    `; var VAL = use_whatsapp; h += frm.yn3("use_whatsapp", `I use Whatsapp
    on ${elaineui.format("tel",___tel)}`,VAL,"","",function(){ oc(); }, {}).render(); h += "
    "; h += uihelpers.cbuttonbar("CONTINUE",frm.addfunction(function(){ let use_whatsapp = yn3("#use_whatsapp"); if (use_whatsapp === "") { mar.tip(".help-button","warning","you need to answer yes or no","top"); return false; } setScenario_data("use_whatsapp",use_whatsapp); setScenario_data("__scenario_whatsapp_passed","Y"); mar.answers._events = ["application:whatsapp_selected"]; mar.fakesave(); if (mvc.getEntryPageHashOriginal() !== false && mvc.getEntryPageHashOriginal().indexOf("rate") > -1) { mvc.go(mvc.getEntryPageHashOriginal()); mvc.clearEntryPageHashOriginal(); return; } mvc.go("#scenario-timeframe"); }),"",frm.addfunction(function(){ }),"mar.help()"); h = Mustache.render(h,localopts); // hh = Mustache.render(hh,$.extend(___cols,localopts)); let oc = function() { } let or = function(){ if (mar.WE_ARE_FROM_LOI === true) { mvc.go("#scenario-timeframe"); return; } /** * skip if this comes from whatsapp * */ // if (getScenario_data("use_whatsapp","") === "") { if (getScenario_data("origin","") === "whatsapp" || getScenario_data("skip_whatsapp","") === "Y") { setScenario_data("use_whatsapp",use_whatsapp); setScenario_data("__scenario_whatsapp_passed","Y"); mar.answers._events = ["application:whatsapp_selected"]; setScenario_data("skip_whatsapp","skipped"); mar.fakesave(); mvc.go("#scenario-timeframe"); return; } // } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { section : "general", render : render } })(); mar.pg["scenario-loantype"] = (function(){ var VAL = 'N' var html = ""; var pages_to_verify = []; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; var n0 = getApplicantsNames_v2(0).Name; let h = ""; let loan_type = getV2_data("loan_type","purchase"); mar.pg_accesscontrollerfn = function() { return "open"; } h += frm.htitle("Type of Loan").render(); h += frm.elaine(`Would you like to purchase a new property or refinance a property that you own?`,"er").render(); h += "
    "; var VAL = loan_type; let options = { purchase : "Purchase", refinance : "Refinance" } if (loan_type === "refinance") { options = { refinance : "Refinance", purchase : "Purchase" } } h += frm.radio("loan_type","Type of Loan",VAL,"","",function(){ },options).render().wrap("

    ","
    "); h += "
    "; h += uihelpers.cbuttonbar("CONTINUE",frm.addfunction(function(){ let loan_type_cur = getV2_data("loan_type","purchase"); let loan_type = radio("loan_type"); if (loan_type !== loan_type_cur) { if (loan_type == "purchase") { mar.answers.loan_type = "purchase"; mar.answers.v2.loan_type = "purchase"; mar.answers.v2.scenario.loan_type = "purchase"; setScenario_data("__scenario_loantype_passed","Y"); frm.buttons.hide(function(){ mar.fakesave(function(rv){ mvc.go("#scenario-timeframe"); }); }); } else { mar.answers.loan_type = "refinance"; mar.answers.v2.loan_type = "refinance"; mar.answers.v2.scenario.loan_type = "refinance"; setScenario_data("__scenario_loantype_passed","Y"); frm.buttons.hide(function(){ mar.fakesave(function(rv){ mvc.go("#scenario-timeframe"); }); }); } } else { setScenario_data("__scenario_loantype_passed","Y"); frm.buttons.hide(function(){ mar.fakesave(function(rv){ mvc.go("#scenario-timeframe"); }); }); } }),"",frm.addfunction(function(){ }),"mar.help()"); h = Mustache.render(h,localopts); // hh = Mustache.render(hh,$.extend(___cols,localopts)); let oc = function() { } let or = function(){ if (mar.WE_ARE_FROM_LOI === true) { setScenario_data("__scenario_loantype_passed","Y"); mar.fakesave(); mvc.go("#scenario-timeframe"); return; } if (getScenario_data("__scenario_loantype_passed","N") !== "Y") { if (getScenario_data("origin2","") === "lpdirect") { setScenario_data("__scenario_loantype_passed","Y"); mar.fakesave(); mvc.go("#scenario-timeframe"); return; } } if (getScenario_data("__scenario_timeframe_passed","N") === "Y") { /** * we have already gone too far */ setScenario_data("__scenario_loantype_passed","Y"); mar.fakesave(); mvc.go("#scenario-timeframe"); return; } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { // section : "general", section : "loantype", render : render } })(); /* file /ui/app/js/pages.loanproposals.js , last updated 1550159971736*/ mar.pg["loanproposal-home"] = (function(){ var VAL = '' var html = ""; var checkForValues = false; function render(pg, localopts) { let h = ""; h += frm.htitle("LOAN PROPOSALS").render(); h += "
    " h += "
    "; h = Mustache.render(h,localopts); let reload = function() { $("#loan-proposal-list").html("loading"); $.get(`/api/mortgage/pdf?appid=${mar.ID}&v=1&link=y`, function(da) { //document.location = da.short_url; let img = da.data.long_url; //let thumb = ``; let thumb = ``; let h = `
    \
    Loan Proposal #1
    \
    \
    ${thumb}
    \
    VIEW
    `; $(".result").html(h); }); return; elaine_adapter.mortgage.get(mar.ID,"1", function(mortgage) { if (mortgage !== false) { h = ""; h += '
    '; h +='
    '; let mmr = mortgage.appsum4e; console.log('mortgage : ', mortgage); console.log('MMR : ', mmr); h += "
    "; // https://ie-n8c.durunner.ai/api/mortgage/pdf?appid=1783&v=1&link=y h += "
    `); }); })+"' >View proposal
    "; h += "
    "+ "
    "; swal({ //title : "Same line of work", className : "middleInfoPopup", content : s, buttons : { cancel : "No,Thanks", call : { text: "Yes, Please", value: "print", closeModal: false } } }) .then((act) => { if (act == "print") { let ___lnk = "/api/mortgage/pdf?appid="+mar.ID+"&v=1&action=send"; // s.innerHTML = "


    Sending ....

    "; // swal({ // //title : "Same line of work", // className : "midelinfopopupOneButton", // content : s, // buttons : { // cancel : false, // ok : false // } // }); $.get(___lnk, function() { }) s.innerHTML = "
    The proposal has been sent via text.
    "; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s }); //mar.pghelpers.callLoanOfficer(); /* var myItems = $('#proposalToClosePrint'); var pdf = new jsPDF(); pdf.text(5, 5, 'CASH TO CLOSE CALCULATION'); pdf.text(5, 30, myItems.text()); pdf.save('proposal.pdf'); */ } }); })+"' >SEND BY TEXT / EMAIL
    "; h += "
    ";//end proposal $(".result").html(h); } }); } let oc = function(quick) { } let or = function(quick) { reload(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "proposal" } })(); /* file /ui/app/js/pages.general.js , last updated 1635175629231*/ mar.pg["general-aboutus"] = (function(){ var html = ""; function render(pg, localopts) { let h = ""; h += "
    " h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ //mvc.go("#scenario-legalstatus."+applicantnum); }),"Back",frm.addfunction(function(){ // mvc.go("#scenario-creditscore."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(skipReturn) { } let or = function(){ $.get(`/api/app/company/${mar.ID}`, function(da){ let data = da.data; let h = ""; h += frm.htitle(da.data.company).render(); h += "
    "; h += `
    ${da.data.aboutus_html}
    `; $("#content").html(h); }) $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "About Us" } return { render : render, section : "general" } })() mar.pg["general-route"] = (function(){ var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let link = MAR.getOpt(localopts, "p2", ""); let go = MAR.getOpt(localopts, "p3", ""); let h = ""; h += "
    " h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ //mvc.go("#scenario-legalstatus."+applicantnum); }),"Back",frm.addfunction(function(){ // mvc.go("#scenario-creditscore."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(skipReturn) { } let or = function(){ let h = ""; h += `LINK ${link}`; let parts = link.split("_"); let part0 = (parts.length > 0) ? parts[0] : ""; let part1 = (parts.length > 1) ? parts[1] : ""; let part2 = (parts.length > 2) ? parts[2] : ""; let _link = ""; if (part0 === "assets") { let uuid = part1; let item = MAR.assets.getByUUID(part1, true); if (item !== false) { _link = `#assets-${item.data.type}.0.${item.i}`; } h += `
    ${_link}
    `; h += `
    ${JSON.stringify(item, null, 4)}
    `; } if (part0 === "income") { let uuid = part1; let item = MAR.income.getByUUID(part1, true); if (item !== false) { _link = `#income-${item.data._t}.${item.appl}.${item.idx}`; } h += `
    ${_link}
    `; h += `
    ${JSON.stringify(item, null, 4)}
    `; } if (part0 === "residence") { let uuid = part1; for (let i=0; i < mar.answers.v2.applicants.length; i++) { let appl = mar.answers.v2.applicants[i]; let addresses = appl.addresses; for (let j=0; j < addresses.length; j++) { let address = addresses[j]; if (address.endsWith(`/${uuid}`)) { _link = `#scenario-addresshistory.${i}.${j}`; } } } h += `
    ${_link}
    `; // h += `
    ${JSON.stringify(item, null, 4)}
    `; } if (_link !== "" && go === "go") { mvc.go(_link); return; } $.get(`/api/encompass/control/${mar.ID}/links`, function(da){ let linklist = MAR.getOpt(da, "data" , []); if (linklist.length > 0) { h += `

    List of links to verify

    `; } for (let i=0; i < linklist.length; i++) { let link = linklist[i]; h += `
    ${link}
    `; } $("#content").html(h); $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); }) } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "About Us" } return { render : render, section : "general" } })(); mar.pg["general-comments"] = (function(){ var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let h = ""; h += frm.htitle("Client comments").render(); h += "
    "; h += "
    " h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ //mvc.go("#scenario-legalstatus."+applicantnum); }),"Back",frm.addfunction(function(){ // mvc.go("#scenario-creditscore."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(skipReturn) { } let or = function(){ let reload = async function(){ let obj = { key : "%", appid : mar.ID }; let rv = await mar.socket.send_and_receiveSync("app-comment-list",obj); let list = MAR.getOpt(rv, "data", []); let h = ""; let sec = ""; for (let i=0; i < list.length; i++) { let item = list[i]; let classes = []; if (item.status === "done") { classes.push("done_cls"); continue; } let _sec = item.k.split(" ")[0]; if (_sec !== sec) { let SEC = MAR.master_router.pages.name(_sec); h += `
    Page : ${SEC.txt}
    `; sec = _sec } h += `
    - ${item.data}
    `; } if (h !== "") { h = `Comments Entered:
    ${h}`; } else { h = `There are not comments entered at the moment`; } $("#content").html(h); } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); reload(); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "About Us" } return { render : render, section : "general" } })() mar.pg["general-faq"] = (function(){ var html = ""; function render(pg, localopts) { let h = ""; h += frm.htitle("FAQ").render(); h += "
    "; h += $("#faqs").html(); h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ //mvc.go("#scenario-legalstatus."+applicantnum); }),"Back",frm.addfunction(function(){ // mvc.go("#scenario-creditscore."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(skipReturn) { } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "FAQ" } return { render : render, section : "general" } })() mar.pg["general-comms"] = (function(){ var html = ""; function render(pg, localopts) { mar.pg_accesscontrollerfn = function() { return "open"; } let h = ""; h += frm.htitle("Communication Settings").render(); h += "
    "; let VAL = ""; let intro = "How often can we send you:"; // "automated updates on missing documentation? [] never [] 1x a week [] 2x a week [] As frequent as necessary | - " + // "automated updates on loan proposals? [] never [] 1x a week [] 2x a week [] As frequent as necessary | - " + // "automated updates on other items related to your loan application? [] never [] 1x a week [] 2x a week [] As frequent as necessary | - " + // "automated other commercial messages? [] never [] 1x a week [] 2x a week [] As frequent as necessary ---> " + // "above the checkboxes, have on for text and one for email, this way they can choose what to opt out for."; h += frm.elaine(intro,"er").render(); h += "
    "; VAL = "any"; //VAL = (itm) ? itm.whose_name : ''; h += frm.radio("com_freq_doc_updates","Automated updates on missing documentation?",VAL,"","",function(){ oc(); },{ never : "Never", // weekly : "Once a week", // biweekly : "Twice a week", any : "As frequently as necessary", // fast : "Every 2 mins / test setting" }).render(); h += frm.hr().render() // h += frm.radio("com_freq_loan_proposals","Automated updates on loan proposals?",VAL,"","",function(){ // oc(); // },{ // never : "Never", // weekly : "Once a week", // biweekly : "Twice a week", // any : "As frequently as necessary" // }).render(); // // h += frm.hr().render() h += frm.radio("com_freq_loan_other","Automated updates other items related to your loan application?",VAL,"","",function(){ oc(); },{ never : "Never", // weekly : "Once a week", // biweekly : "Twice a week", any : "As frequently as necessary" }).render(); h += frm.hr().render() // h += frm.radio("com_freq_commercial","Automated commercial messages?",VAL,"","",function(){ // oc(); // },{ // never : "Never", // weekly : "Once a week", // biweekly : "Twice a week", // any : "As frequently as necessary" // }).render(); // // h += frm.hr().render() h += "
    How can we send you messages?

    "; VAL = "Y"; h += frm.yn3("com_method_email","Do we have permission to contact you by Email?",VAL,"","",function(){ oc(); }).render(); h += frm.hr().render() h += frm.yn3("com_method_sms","Do we have permission to contact you by SMS?",VAL,"","",function(){ oc(); }).render(); h += frm.hr().render() VAL = getScenario_data("use_whatsapp",""); h += frm.yn3("use_whatsapp", `Permission to use Whatsapp
    on ${elaineui.format("tel",___tel)}`,VAL,"","",function(){ oc(); }, {}).render(); h += frm.hr().render() let raw_sec = mar.accesscontroller.get(true); if (raw_sec === "closed" || raw_sec === "warn") { VAL = getScenario_data("over_security","def"); if (VAL === "open") { h += `The current level of security is Open for edit only by LO but opened manually for the client`; } else { h += `The current level of security is Open for edit only by LO`; } if (mar.WE_ARE_FROM_LOI === true) { h += frm.radio("over_security","Is the APP?",VAL,"","",function(){ oc_sec(); },{ def : "Use the default level", open : "Open for edit by the client" // submitted : "Open for edit only by LO", // closed : "Closed" }).render(); h += frm.hr().render() } } // h += "
    Do we have your permission for?

    "; // VAL = "Y"; // // // h += frm.yn3("TCPA1","Do we have permission TCPA 1?",VAL,"","",function(){}).render(); // h += frm.hr().render() // h += frm.yn3("TCPA2","Do we have permission TCPA 2?",VAL,"","",function(){}).render(); // h += frm.hr().render() // h += frm.yn3("TCPA3","Do we have permission TCPA 3?",VAL,"","",function(){}).render(); h += "
    "; // er h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ //mvc.go("#scenario-legalstatus."+applicantnum); mvc.go("#_0100"); // mvc.go("#lox"); }),"Back",frm.addfunction(function(){ if (mar.state.desktop) { mvc.go("#lox"); } else { $("#hamburger").click(); } // mvc.go("#scenario-creditscore."+applicantnum); }),"mar.help()"); h = Mustache.render(h,localopts); let noupdate = false; let fast = false; let oc_sec = function() { let over_security = radio("over_security"); if (setScenario_data("over_security",over_security)) { mar.fakesave(); } } let downloaded_tcpa = false; let oc = function(skipReturn) { let tcpa = { com_freq_doc_updates : radio("com_freq_doc_updates"), com_freq_loan_proposals : "never", //radio("com_freq_loan_proposals"), com_freq_loan_other : radio("com_freq_loan_other"), com_freq_commercial : "never", //radio("com_freq_commercial"), com_method_email : yn3("#com_method_email"), com_method_sms : yn3("#com_method_sms") } if (noupdate === true) return; let set_fast = fast; if (tcpa.com_freq_doc_updates === "fast") { set_fast = true; tcpa.com_freq_doc_updates = "any" } else { set_fast = false; } (function(){ let VAL = getScenario_data("use_whatsapp",""); let use_whatsapp = yn3("#use_whatsapp"); if (VAL !== use_whatsapp) { setScenario_data("use_whatsapp",use_whatsapp); mar.fakesave(); } })() $.get(`/api/app/tcpa/put?appid=${mar.ID}&json=${encodeURIComponent(JSON.stringify(tcpa))}`, function(da){ if (set_fast !== fast) { if (set_fast === true) { $.get(`/api/chatbot/test_on/${mar.ID}`, function(da1){ swal(" TEST MODE IS ON"); }); } else { $.get(`/api/chatbot/test_off/${mar.ID}`, function(da1){ swal(" TEST MODE IS OFF"); }); } fast = set_fast; } $.post(`/api/chatbot/update_tcpa/${mar.ID}`, { _old : downloaded_tcpa, _new : tcpa },function(da1){ downloaded_tcpa = tcpa; }); }); } h += ""; mar.tmp_reload = function(){ $.get(`/api/app/tcpa/get?appid=${mar.ID}`, function(da){ noupdate = true; let _data = MAR.getOpt(da, "data", {}); downloaded_tcpa = _data; radio("com_freq_doc_updates", MAR.getOpt(_data, "com_freq_doc_updates", "any")); //radio("com_freq_loan_proposals", MAR.getOpt(_data, "com_freq_loan_proposals", "any")); radio("com_freq_loan_other", MAR.getOpt(_data, "com_freq_loan_other", "any")); // radio("com_freq_commercial", MAR.getOpt(_data, "com_freq_commercial", "any")); yn3("#com_method_email", MAR.getOpt(_data, "com_method_email", "Y")); yn3("#com_method_sms", MAR.getOpt(_data, "com_method_sms", "Y")); $("#com_method_email").change(); $("#com_method_sms").change(); if (fast) { radio("com_freq_doc_updates", "fast"); } noupdate = false; }); } let or = function(){ $.get(`/api/app/tcpa/get?appid=${mar.ID}`, function(da){ noupdate = true; let _data = MAR.getOpt(da, "data", {}); downloaded_tcpa = _data; radio("com_freq_doc_updates", MAR.getOpt(_data, "com_freq_doc_updates", "any")); //radio("com_freq_loan_proposals", MAR.getOpt(_data, "com_freq_loan_proposals", "any")); radio("com_freq_loan_other", MAR.getOpt(_data, "com_freq_loan_other", "any")); // radio("com_freq_commercial", MAR.getOpt(_data, "com_freq_commercial", "any")); yn3("#com_method_email", MAR.getOpt(_data, "com_method_email", "Y")); yn3("#com_method_sms", MAR.getOpt(_data, "com_method_sms", "Y")); $("#com_method_email").change(); $("#com_method_sms").change(); $.get(`/api/chatbot/getsession/${mar.ID}`, function(da1){ if (da1.active === true) { if (MAR.getOpt(da1, "data.isTest", false) === true) { fast = true; } //fast = true; if (fast) { radio("com_freq_doc_updates", "fast"); } noupdate = false; } else { $("#choice-com_freq_doc_updates5").parent().css({ pointerEvents : "none", opacity : 0.3 }) noupdate = false; } }); }); $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Communication Settings" } return { render : render, section : "commsettings" } })() /* file /ui/app/js/pages.reo.js , last updated 1702560617356*/ mar.pg["reo-home"] = (function(){ var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "0" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let hasUnverifiedItems = false; let hasUnverifiedItems_i = false; let hasUnSavedItems = false; MAR.reo.suggest(); mar.pg_accesscontrollerfn = function() { return "open"; } let h = ""; h += frm.htitle("Real Estate Owned").render(); h += "
    "; //h += frm.elaine("Every property you own can be a source of income or a source of liabilities. You will be able to calculate what your situation is in this section and find out how this affects your ability to borrow money.","er").render(); h += frm.elaine("Every property you own can be a source of income or a source of liabilities.","er").render(); h += "
    "; var list = ""; if (!mar.answers.v2.reo) mar.answers.v2.reo = []; (function(){ let refi = (getV2_data("loan_type","purchase") !== "purchase"); if (refi === false) return; let refi_primary = (getScenario_data("occupancy_type","") === "occupancy_by_me"); let owns_property = (getScenario_data("has_applicant1_owned_property_in_last_3_years","") === "Y"); let owns_property_how = getScenario_data("has_applicant1_owned_property_in_last_3_years_how",""); //01 - sole , 25 - with spouse, 26 with other let owns_property_type = getScenario_data("has_applicant1_owned_property_in_last_3_years_type",""); // 1 - primary 2 = secondary 3 = investment let property_type = getScenario_data("property_type",""); let refi_current_debt = getScenario_data("refi_current_debt",""); let refi_current_value = getScenario_data("refi_current_value",""); let refi_liquid_assets = getScenario_data("refi_liquid_assets",""); let goals_target_budget = getScenario_data("goals_target_budget_old",""); let refi_current_escrow = getScenario_data("refi_current_escrow",""); let refi_current_debt_mdate = getScenario_data("refi_current_debt_mdate",""); let refi_taxes = getScenario_data("refi_taxes",""); let refi_home_insurance_cost= getScenario_data("refi_home_insurance_cost",""); let hoa_estimate = getScenario_data("hoa_estimate",""); let sp = MAR.reo.getOrCreateSubjectProperty(); // return if the property is already verified if (sp.data.verified === "Y") return; // ensure liabilities exists let li = getLiabilities_v2(); // get the mortgages let mos = []; for (let i=0; i < li.length; i++) { if (li[i].type === "mortgage") { mos.push({ i : i, data : li[i] }); } } if (mos.length === 0) { if (refi_current_debt !== "" && num(refi_current_debt) > 0) { let lia_mortgage = MAR.liabilities.create("mortgage",0,"mortgage to refinance"); lia_mortgage.balance = num(refi_current_debt); lia_mortgage.escrow = refi_current_escrow; lia_mortgage.m_type = ""; // missing lia_mortgage.monthly = num(goals_target_budget); // missing lia_mortgage.odate = refi_current_debt_mdate; // missing lia_mortgage.reolink = ""; lia_mortgage.terms = "360"; if (MAR.is_refi()) { (function(){ let v = getScenario_data("refi_current_debt_terms",""); if (v !== "") { lia_mortgage.terms = num(v.substring(1,3))*12; } })(); (function(){ let v = getScenario_data("refi_current_escrow",""); if (v !== "") { lia_mortgage.escrow = v; } })(); (function(){ let v = getScenario_data("goals_target_budget_old",""); if (v !== "") { lia_mortgage.monthly = num(v); } })(); (function(){ let v = getScenario_data("refi_current_debt_mdate",""); if (v !== "") { lia_mortgage.odate = v; } })(); } let lia_mortgage_added = MAR.liabilities.set("mortgage", false, lia_mortgage); MAR.liabilities.setLoanLinkByUUID(`${lia_mortgage_added.uuid}`,sp.data.uuid); // balance: 77900 // escrow: "" // i: 0 // m_type: "conv" // monthly: 1000 // name: "" // odate: "2000-01-01" // reolink: "7e15cb7d-ec8e-4621-82bc-f7d661dac062" // terms: "360" // type: "mortgage" // uuid: "31a0afde-8de7-40c4-8969-1a68fbfe3300" } } else { let lia_mortgage_added = mos[0].data; MAR.liabilities.setLoanLinkByUUID(`${lia_mortgage_added.uuid}`,sp.data.uuid); } let uuid = sp.uuid; let updateobj = {} if (MAR.is_refi()) { (function(){ let v = getScenario_data("refi_current_pmt_includes",""); if (v !== "") { updateobj.monthly_includes_taxes = v; } })(); (function(){ let v = getScenario_data("refi_current_pmt_includes_ins",""); if (v !== "") { updateobj.monthly_includes_insurance = v; } })(); (function(){ let v = getScenario_data("refi_taxes",""); if (v !== "") { updateobj.loan_tax = v; } })(); (function(){ let v = getScenario_data("refi_home_insurance_cost",""); let vd = getScenario_data("refi_home_insurance_due",""); let vi = getScenario_data("refi_current_pmt_includes_ins",""); if (v !== "" && v !== "0") { updateobj.has_insurance = "Y"; updateobj.monthly_includes_insurance = vi; updateobj.loan_insurance = v; updateobj.loan_insurance_dd = vd } })(); (function(){ let v = getScenario_data("hoa_estimate",""); if (v !== "" && v !== "0") { updateobj.has_hoa = "Y"; updateobj.loan_hoa = num(v)*12; } })(); (function(){ let v = getScenario_data("refi_current_debt_mdate",""); if (v !== "") { updateobj.purchasedate = v; } })(); // setScenario_data("refi_taxes_due" , refi_taxes_due); } MAR.reo.setByUUID(uuid, updateobj); })(); var reoo = getReo_v2(getProgramme_v2()); MAR.reo.will_display_list(); var reoo = getReo_v2(getProgramme_v2()); // skip line 0 , this is headings let length_or_reo_list = 0; for (var i=1; i < reoo.detailmatrix.length; i++) { var item = reoo.detailmatrix[i]; if (item[16] == "") continue; // list += "
    "; let _I = (item[11]+1); // list += `
    `; var _address = item[16]; if (_address && _address != "") { _address = uihelpers.addressformatShortAbbreviated(_address); } else { _address = item[0]; } if (_address == "") continue; var usage = item[10].replace(/>/g, " ") let triangle = `` let logo = ` `; let verified = (item[22] !== "N"); let verified2 = (item[23] !== "N"); let is_subject = (item[24] === "Y"); let _logo = (verified && verified2) ? logo : triangle; var _block = ""; var _block_top = ""; _block_top += sprintf("
    %s
    ",_address); if (verified) { _block += sprintf("
    %s
    ",usage); _block += sprintf("
    %s : $%s
    ",item[17],item[13]); // if (item[29] !== "") { // _block += `
    Income used:
    - ${item[29]}
    `; // } if (is_subject) { _block += "
    Subject property
    "; } else { //_block += "
     
    "; } if (item[33].length > 0) { // is [array] // _block += `
    Notes on Income:
    - ${item[33].join("
    - ")}
    `; _block += `
    Income remarks:
    ${item[33].join("")}
    `; } } else { //_block += "
     
    "; //_block += "
     
    "; if (is_subject) { _block += "
    Subject property
    "; } else { //_block += "
     
    "; } hasUnverifiedItems = true; if (hasUnverifiedItems_i === false) { hasUnverifiedItems_i = _I; } } if (!verified || !verified2) { hasUnverifiedItems = true; if (hasUnverifiedItems_i === false) { hasUnverifiedItems_i = _I; } } // list += sprintf("
    %s
    ",_block); // list += "
    "; let __lnk = `mvc.go('#reo-property.0.${_I}')`; let __dellnk = `mar.deleteReoItemPress(this,${_I})`; let __owner = (function(){ let owner = item[32]; /** * if a number , assume it is the applicant number */ if (typeof owner === "number" && owner < 99) { return getApplicantsNames_v2(owner).Name; } /** * if it is not a string or it is empty return n0 */ if (typeof owner !== "string" || owner.trim() === "") { return n0; } let owners = owner.split(","); let rv = []; for (let i=0; i < owners.length; i++) { if (num(owners[i]) < 99) { rv.push(getApplicantsNames_v2(num(owners[i])).Name); } else { rv.push("Other"); } } return rv.join(","); })(); let __unsaved = ""; if (reo_has_unsaved_changes(item[21])) { __unsaved = frm.inline_warning_red(`Property has Un-Saved edits`); _logo = triangle; hasUnSavedItems = true; } list += `
    ${_block_top}
    ${__owner}
    ×

    ${_block}
    ${__unsaved}
    `; length_or_reo_list++; } mar.deleteReoItemPress = function(elm, idx) { let $elm = $(elm); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Conformation").render() + "Are you sure you want to delete this property ? "; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "No", call : { text: "Delete", value: "del", closeModal: false } } }) .then((act) => { if (act == "del") { MAR.reo.del((idx-1)) frm.buttons.hide(function(){ let cp = mvc.currentpage; mar.fakesave(function(){ swal.close(); if (mvc.currentpage === cp) { mvc.go("#reo-home") } }); }); } }); //let goto = $elm.data("goto"); } let addwarning = ""; let add_text = (length_or_reo_list === 0) ? "Add a Property" : "Add Another Property"; /** * are you working on a new property and left it */ if (reo_has_unsaved_changes("new")) { addwarning = frm.inline_warning_red(`You are in the middle of adding a new property, click below to continue`); add_text = `Continue adding a property`; hasUnSavedItems = true; } let addbutton = ""+ "
    " + "
    " + `${add_text}` + "
    " + "
    "; if (hasUnverifiedItems == false) { h += `
    ${list}
    ${addwarning}
    ${addbutton}
    `; } else { h += `
    ${list}
    `; } h += "
    "; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (hasUnverifiedItems == true) { let __lnk = `#reo-property.0.${hasUnverifiedItems_i}`; mvc.go(__lnk); return; elaineui.swal(`You have some un-verified assets you need to check before you can continue

    These properties have a triangle next to them


    `, "Property Verification"); return; } if (hasUnSavedItems == true) { elaineui.swal(`You have some un-saved edits you need to clear before you can continue

    These properties have a triangle next to them


    `, "Property Verification"); return; } if (hasSuggestions() === true) { return; } var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = "Are you sure you have entered all the Real estate that you own? "; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "No", call : { text: "Yes", value: "yes", closeModal: false } } }) .then((act) => { if (act == "yes") { setScenario_data("__reo_passed_0","Y") && mar.fakesave(); mvc.go("#lox"); swal.close(); } else { swal.close(); } }); }),"Back",frm.addfunction(function(){ mvc.go("#liabilities-home.prev"); }),"mar.help()"); h = Mustache.render(h,localopts); let hasSuggestions = function(skip) { if (hasUnverifiedItems === false && hasUnSavedItems === false) { let sug = MAR.reo.suggest(); if (sug.length > 0 && skip === true) { sug = sug.filter(function(itm) { if (itm.suggestion === "noproperty") return false; if (itm.suggestion === "unconnectedmortgage") return false; return true; }) } if (sug.length > 0) { let cp = mvc.currentpage; if (typeof cp === "string" && cp.startsWith("#reo-home")) { mvc.go(`#reo-suggestion.${sug[0].applicant}`) } // swal(JSON.stringify(sug)); return true; } } return false; } let oc = function(skipReturn) { let cp = mvc.currentpage; if (cp === "#reo-home") { hasSuggestions(skipReturn); } } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "About Us" } function iscomplete(N) { var _sc = getScenario_v2(); var _as = getAssets_v2(); let reo = MAR.reo.get(); for (let i=0; i < reo.length; i++) { if ("verified" in reo[i] && reo[i].verified === "N") return i; } return true; } return { render : render, section : "general", iscomplete : iscomplete } })() mar.pg["reo-suggestion"] = (function(){ var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "0" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 mar.pm_reoSuggestion_tmp_mortgage_to_add = false; mar.pg_accesscontrollerfn = function() { return "open"; } let h = ""; let sugs = MAR.reo.suggest(); let hasSug = false; let sug = ""; if (sugs.length > 0) { hasSug = true; sug = sugs.shift(); if (MAR.getOpt(sug, "suggestion", "") === "check") { h += frm.htitle("Real Estate Descrepency").render(); h += "
    "; h += frm.elaine(`${na}, can you help us out solve a discrepency.`,"er").render(); h += "
    "; h += `You answered that your current primary address is`; h += `
    ${uihelpers.addressformatShortAbbreviated(sug.ad1)}
    `; h += `However in the REO section you stated that this property is your primary with a different address`; h += `
    ${uihelpers.addressformatShortAbbreviated(sug.ad2)}
    `; h += frm.radio("opts","Which of the following would you like me to do?","","","",function(){ },{ use1 : "Change the property addresses to "+uihelpers.addressformatOneLine(sug.ad1), use2 : "Change my primary to "+uihelpers.addressformatOneLine(sug.ad2), c2investment : uihelpers.addressformatOneLine(sug.ad2)+" is not my primary but an investment", c2notowner : "I am not the owner of "+uihelpers.addressformatOneLine(sug.ad2) }).render(); h += "
    "; } else if (MAR.getOpt(sug, "suggestion", "") === "check2") { h += frm.htitle("Real Estate Descrepency").render(); h += "
    "; h += frm.elaine(`${na}, can you help us out solve a discrepency.`,"er").render(); h += "
    "; h += `You answered that you do not own your primary residence`; h += `
    ${uihelpers.addressformatShortAbbreviated(sug.ad1)}
    `; h += `However in the REO section you stated that this property is your primary`; h += `
    ${uihelpers.addressformatShortAbbreviated(sug.ad2)}
    `; h += frm.radio("opts","Which of the following would you like me to do?","","","",function(){ },{ owner : "I do own my Primary and it is "+uihelpers.addressformatOneLine(sug.ad2), edit : "Let me edit the property data for "+uihelpers.addressformatOneLine(sug.ad2) + " because it is not my primary" }).render(); h += "
    "; } else if (MAR.getOpt(sug, "suggestion", "") === "noproperty") { h += frm.htitle("Real Estate Descrepency").render(); h += "
    "; h += frm.elaine(`${na}, can you help us out solve a discrepency.`,"er").render(); h += "
    "; h += `You answered that you own property but there is nothing in the REO list`; h += frm.radio("opts","Which of the following would you like me to do?","","","",function(){ },{ add : "Add a new property", noown : "Change my declaration because I don't own any property" }).render(); h += "
    "; } else if (MAR.getOpt(sug, "suggestion", "") === "unconnectedmortgage") { h += frm.htitle("Real Estate Descrepency").render(); h += "
    "; h += frm.elaine(`${na}, can you help us out solve a discrepency.`,"er").render(); h += "
    "; let m = sug.mortgages[Object.keys(sug.mortgages)[0]]; mar.pm_reoSuggestion_tmp_mortgage_to_add = JSON.parse(JSON.stringify(m)); // h += `
    ${JSON.stringify(sug, false, 4)}
    `; //h += `A mortgage with a balance of ${elaineui.format("cur",m.balance)} and a monthly payment of ${elaineui.format("cur",m.monthly)} in your list of liabilities list but is not connected to a property.`; h += `The following mortgage is not connected to either of your REO properties.` h += "

    "; h += liability_block(m); let _opts = { add : "Add a new property", remove : "Remove that mortgage", llc : "This mortgage is attached to a LLC" } let reolist = mar.answers.v2.reo; for (let i=0; i < reolist.length; i++) { _opts[`con_${i+1}`] = "Connect it to "+uihelpers.addressformatOneLine(reolist[i].address) } h += frm.radio("opts","Which of the following would you like me to do?","","","",function(){ },_opts).render(); h += "

    "; h += "
    "; } else if (MAR.getOpt(sug, "suggestion", "") === "add") { h += frm.htitle("Real Estate Addition").render(); h += "
    "; h += frm.elaine(`${na}, can you verify this information for me please.`,"er").render(); h += "
    "; h += `You answered that you own your current primary address `; h += `
    ${uihelpers.addressformatShortAbbreviated(sug.address)}
    `; h += frm.radio("opts","Which of the following should we do?","","","",function(){ },{ add : "Add this as an REO property ", noown : "I made a mistake and I don't own my current primary", }).render(); h += "
    "; } else if (MAR.getOpt(sug, "suggestion", "") === "no_nprf") { h += frm.htitle("Net proceeds").render(); h += "
    "; h += frm.elaine(`${na}, can you verify this information for me please.`,"er").render(); h += "
    "; h += `Your current primary address is marked for sale before the transaction but we do not have a matching entry in assets.`; h += `
    ${uihelpers.addressformatShortAbbreviated(sug.ad)}
    `; h += frm.radio("opts","Which of the following should we do?","","","",function(){ },{ // keep_nprf : `Keep ${elaineui.format("cur",sug.entered_nprf).replace(/,/g,",")} as the take home sales profit `, add_nprf : `Add net proceeds of sale of ${elaineui.format("cur",sug.calculated_nprf).replace(/,/g,",")}`, edit : "Let me change my property information" }).render(); h += "
    "; } else if (MAR.getOpt(sug, "suggestion", "") === "diff_nprf") { h += frm.htitle("Net proceeds").render(); h += "
    "; h += frm.elaine(`${na}, we found a possible error in your sales profit from your property.`,"er").render(); h += "
    "; h += `You filled in that you expect your net proceeds of the sale of your property to be ${elaineui.format("cur",sug.entered_nprf)} but, based on the expected sales price of ${elaineui.format("cur",sug.salesprice)}, closing cost of ${elaineui.format("perc",sug.salesperc)}, and mortgages totalling ${elaineui.format("cur",sug.loanbalance)} we calculated your proceeds to be ${elaineui.format("cur",sug.calculated_nprf)}.`; // h += `
    ${uihelpers.addressformatShortAbbreviated(sug.ad)}
    `; // h += `
    Calculated value ${elaineui.format("cur",sug.calculated_nprf)}
    `; // h += `
    Entered value ${elaineui.format("cur",sug.entered_nprf)}
    `; h += "
    "; h += "
    "; h += frm.radio("opts","Which of the following should we do?","","","",function(){ },{ keep_nprf : `Keep ${elaineui.format("cur",sug.entered_nprf).replace(/,/g,",")} as the take home sales profit `, copy_nprf : `Change net proceeds of sale to ${elaineui.format("cur",sug.calculated_nprf).replace(/,/g,",")}`, edit : "Let me change my property information" }).render(); h += "
    "; } else { h += `
    ${JSON.stringify(sug, false, 4)}
    `; } } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ let fs = false; if (MAR.getOpt(sug, "suggestion", "") === "check") { let opts = radio("opts"); if (opts === "use1") { MAR.reo.getByIndex(sug.reo_primary_index).address = sug.ad1; fs = true; } else if (opts === "use2") { let a_current = MAR.getApplicantAddressCurrent(sug.applicant); if (a_current && a_current.length > 0) { a_current[0].address = sug.ad2 fs = true; } } else if (opts === "c2investment") { reo_add_unsaved_edit(MAR.reo.getByIndex(sug.reo_primary_index).uuid, "reo_use", "investment"); // MAR.reo.getByIndex(sug.reo_primary_index).verified = "N"; fs = true; } else if (opts === "c2notowner") { MAR.reo.getByIndex(sug.reo_primary_index).verified = "N"; fs = true; } else { mar.tip(".help-button","warning","You need to let us know what youd like us me to do.","top"); return; } } if (MAR.getOpt(sug, "suggestion", "") === "check2") { let opts = radio("opts"); if (opts === "owner") { let a_current = MAR.getApplicantAddressCurrent(sug.applicant); if (a_current && a_current.length > 0) { a_current[0].use = "own" fs = true; } } else if (opts === "edit") { MAR.reo.getByIndex(sug.reo_primary_index).verified = "N"; fs = true; } else { mar.tip(".help-button","warning","You need to let us know what youd like us me to do.","top"); return; } } if (MAR.getOpt(sug, "suggestion", "") === "noproperty") { let opts = radio("opts"); if (opts === "add") { mvc.go("#reo-property.0.0"); return; } else if (opts === "noown") { setScenario_data(`does_applicant${sug.applicant+1}_own_property`,"N"); fs = true; } else { mar.tip(".help-button","warning","You need to let us know what youd like us me to do.","top"); return; } } if (MAR.getOpt(sug, "suggestion", "") === "unconnectedmortgage") { let opts = radio("opts"); if (opts === "add") { mvc.go("#reo-property.0.0"); return; } if (opts === "llc") { let m = sug.mortgages[Object.keys(sug.mortgages)[0]]; MAR.liabilities.set_from_object({ uuid : m.uuid, attached_llc : "Y" }); mar.fakesave(); mvc.go("#reo-home"); return; } if (opts === "remove") { let m = sug.mortgages[Object.keys(sug.mortgages)[0]]; let liadel = getScenario_data("deleted_liabilities",[]); liadel.push(m.sig); liadel.push(m.uuid); setScenario_data("deleted_liabilities",liadel); MAR.liabilities.delByUUID(m.uuid); mvc.go("#reo-home"); } else if (opts.startsWith("con_")) { mvc.go(`#reo-property.0.${opts.substring(4)}`); return; } else { mar.tip(".help-button","warning","You need to let us know what youd like us me to do.","top"); return; } } if (MAR.getOpt(sug, "suggestion", "") === "add") { let opts = radio("opts"); if (opts === "add") { let a_current = MAR.getApplicantAddressCurrent(sug.applicant); if (a_current && a_current.length > 0) { let newproperty = MAR.reo.create({ type : "primary", owner : sug.applicant, address : { address : a_current[0].address }, verified : "N" }); MAR.reo.set(false, newproperty); fs = true; } } else if (opts === "noown") { let a_current = MAR.getApplicantAddressCurrent(sug.applicant); if (a_current && a_current.length > 0) { a_current[0].use = "rent" fs = true; } } else { mar.tip(".help-button","warning","You need to let us know what youd like us me to do.","top"); return; } } if (MAR.getOpt(sug, "suggestion", "") === "no_nprf") { let opts = radio("opts"); if (opts === "keep_nprf") { mar.answers.v2.reo[sug.reo_primary_index].reo_override_nprf = "Y"; fs = true; } else if (opts === "add_nprf") { let asset = {} asset.type = "nprf"; asset.balance = sug.calculated_nprf; asset.current_situation = "forsale"; asset.verified = "Y"; asset.sell_before_close = "Y"; MAR.assets.set("nprf", false ,asset); getAssets_v2(); fs = true; } else if (opts === "edit") { MAR.reo.getByIndex(sug.reo_primary_index).verified = "N"; } else { mar.tip(".help-button","warning","You need to let us know what youd like us me to do.","top"); return; } } if (MAR.getOpt(sug, "suggestion", "") === "diff_nprf") { let opts = radio("opts"); if (opts === "keep_nprf") { mar.answers.v2.reo[sug.reo_primary_index].reo_override_nprf = "Y"; fs = true; } else if (opts === "copy_nprf") { let asset = MAR.assets.get("nprf",sug.assetIndex); asset.balance = sug.calculated_nprf; MAR.assets.set("nprf",sug.assetIndex,asset); getAssets_v2(); fs = true; } else if (opts === "edit") { MAR.reo.getByIndex(sug.reo_primary_index).verified = "N"; } else { mar.tip(".help-button","warning","You need to let us know what youd like us me to do.","top"); return; } } if (fs) { frm.buttons.hide(function(){ let cp = mvc.currentpage; mar.fakesave(function(){ mvc.go("#reo-home") }); }); } else { mvc.go("#reo-home"); } }),"Back",frm.addfunction(function(){ mvc.go("#reo-home"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(skipReturn) { } let or = function(){ if (hasSug === false) { mvc.go("#reo-home"); } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "About Us" } return { render : render, section : "general" } })(); mar.pg["reo-property"] = (function(){ var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "0" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 MAR.liabilities.repair_uuids() && mar.fakesave(); let N = num(existingid); let h = ""; h += (function(){ let h = ""; h += frm.htitle("Real Estate Owned").render(); h += "
    "; return h; })().wrap("
    ","
    "); h += "
    "; h += $("#reo_simple_property_pg").html(); h += "
    "; // h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ // }),"Back",frm.addfunction(function(){ // }),"mar.help()"); /** * * START * * this makes the data for on an already completed REO page * */ var mo = ""; var comma = ""; var val = ""; let __reo_uuid = "" /** * we need to display the linked item if there is one */ var loanlink = -1; var n = (N) ? N : 0; let __reo = false; if (num(N) > 0) { __reo = getReo_v2(getProgramme_v2()).items[N-1]; __reo_uuid = __reo.uuid; if (__reo && __reo.loanlink && __reo.loanlink != "") loanlink = __reo.loanlink; if (MAR.getOpt(__reo, "verified","") !== "Y") { mar.pg_accesscontrollerfn = function() { return "open"; } } } else { /* see if there was a pre selected mortgage to link to */ if (typeof mar.pm_reoSuggestion_tmp_mortgage_to_add === "object") { let preselected_loan_uuid = MAR.getOpt(mar.pm_reoSuggestion_tmp_mortgage_to_add, "uuid", false); if (preselected_loan_uuid !== false) { loanlink = preselected_loan_uuid; } } } if (MAR.reo.suggest().length > 0) { mar.pg_accesscontrollerfn = function() { return "open"; } } for (var i=0; i < mar.answers.v2.liabilities.length; i++) { var item = mar.answers.v2.liabilities[i]; if (!item || item == null) continue; if (item.type == "mortgage" || item.type == "heloc") { if(!("reolink" in item) || item.uuid == loanlink || num(loanlink) === i) { // no relink , or reolink is this one mo += sprintf("%s%s:
    %s%s%s
    ",comma,item.uuid,item.name, mar.fmt.currency(item.balance).replace(/\,/g,","), mar.fmt.currency(item.monthly).replace(/\,/g,",")); comma = ","; if (item.uuid == loanlink || num(loanlink) === i) val = item.uuid; } } } if (comma == "") { mo += "nl:Has a mortgage,free:Is mortgage free"; } else { mo += comma; mo += "nl:Has a mortgage but is not listed above,free:Is mortgage free"; } let checkListChange = function() { let whosname = checklist("whose_name"); if (whosname.indexOf("99") > -1) { $("#other_applicant_holder").removeClass("x-hide") } else { $("#other_applicant_holder").addClass("x-hide") } } /** * preino - warning before */ let preino = frm.inline_warning_red("Make sure you connect all mortgages for this property, including Home Equity Lines of Credit"); /** * ino = in the name of */ let ino = (function(){ // VAL = (itm) ? itm.whose_name : ["0"]; let VAL = []; let h = ""; h += frm.hr().render(); h += "
    In whose name is this property?
    Multiple answers are possible.
    "; var applicantsObj = getApplicantsNames_v2(); var slimmedObj = {}; for (let i=0; i","
    "); /** * ino = in the name of */ let ino1 = (function(){ tidyUpReoMortgageLinks(); let h = ""; var slimmedObj = {}; let mortgages = mar.answers.v2.liabilities.filter(function(item){ if (item.type === "mortgage") { return ("reolink" in item === false || item.reolink == __reo_uuid); } if (item.type === "heloc") { return ("reolink" in item === false || item.reolink == __reo_uuid); } return false; }) for (let i=0; i < mortgages.length; i++) { slimmedObj[`${mortgages[i].uuid}`] = `${mortgages[i].name} balance \$${mortgages[i].balance} monthly \$${mortgages[i].monthly}` } // if (mortgages.length === 0) { // slimmedObj["nl"] = "Has a mortgage"; // } else { // slimmedObj["nl"] = "Has a mortgage but is not listed above"; // } slimmedObj["free"] = "Is mortgage free"; let VAL = []; if (loanlink !== false) VAL=[loanlink]; let _cm = false; mar.tmp_reo_mortgage_onchange = function(){ let cm = checklist("connectedmortgage"); console.warn("mar.tmp_reo_mortgage_onchange"); if (_cm === "nl" && cm.split(",").length > 1) { cm = cm.split(",").filter(function(itm){return (itm !== "nl")}).join(","); checklist("connectedmortgage",cm,true); } if (_cm === "free" && cm.split(",").length > 1) { cm = cm.split(",").filter(function(itm){return (itm !== "free")}).join(","); checklist("connectedmortgage",cm,true); } if (_cm !== "nl" && cm.split(",").indexOf("nl") > -1 && cm.split(",").length > 1) { checklist("connectedmortgage","nl",true); $("#connectedmortgage").change(); cm = "nl"; mar.tmp_reo_edit_mortgage("new"); } if (_cm !== "free" && cm.split(",").indexOf("free") > -1 && cm.split(",").length > 1) { checklist("connectedmortgage","free",true); $("#connectedmortgage").change(); cm = "free"; } _cm = cm; } h += frm.checklist("connectedmortgage","",VAL,"","",function(){ mar.tmp_reo_mortgage_onchange(); },slimmedObj).render(); h += ``; h += `Add a mortgage that is not listed above`; return h; })(); let triangle = ``; let logo = ` `; let getIcon = function(I) { return $("#"+I).html(); } mar.tmp_reo_logo = logo; mar.tmp_reo_triangle = triangle; var localopts = JSON.parse(JSON.stringify(mar.mdata)); localopts.n = (N) ? N : 0; localopts.address = ""; //$("#address").html(); localopts.mortgageoptions = mo; localopts.mortgageoptionsval = val; localopts.ino = ino; localopts.preino = preino; localopts.ino1 = ino1; localopts.subjectproperty = subjectproperty; localopts.syncnote = (__reo !== false) ? MAR.getOpt(__reo, "syncnote","") : ""; localopts.last_rental_year = MAR.getCurrentYearForReoRental(); localopts.prev_rental_year = MAR.getCurrentYearForReoRental()-1; console.warn("syncnote",localopts.syncnote); let syncsecs = (__reo !== false) ? MAR.getOpt(__reo, "syncsecs","").split(",") : []; if (localopts.syncnote === "") { syncsecs = []; } localopts.arrow = ``; localopts.arrow0 = (syncsecs.indexOf("0") > -1) ? triangle : getIcon("svg_mortgage_and_heloc_icon_liabilities"); localopts.arrow1 = (syncsecs.indexOf("1") > -1) ? triangle : getIcon("svg_emd_icon_assets"); localopts.arrow2 = (syncsecs.indexOf("2") > -1) ? triangle : getIcon("svg_rental_icon_income"); localopts.arrow3 = (syncsecs.indexOf("3") > -1) ? triangle : logo; localopts.arrow4 = (syncsecs.indexOf("4") > -1) ? triangle : getIcon("svg_emd_icon_assets"); localopts.arrow5 = (syncsecs.indexOf("5") > -1) ? triangle : getIcon("svg_net_proceeds_icon_assets"); localopts.yellow = ___cols.yellow; localopts.green = ___cols.green; mar.tmp_reo_edit_insert_mortgage = function(m_uuid, m_bal, m_pmt, m_type, m_name, new_uuid) { let options = $(".reo-mortgage-checkboxes .radiogroup .styled-checklist"); let opt = options[0]; let last = options[options.length-1]; let $inp = $(opt).find("input"); let $lbl = $(opt).find("label"); let onc = $inp.prop("onchange"); let nam = $inp.prop("name"); let selected = (new_uuid && m_uuid === new_uuid) ? "checked" : ""; let lnk = `edit`; let N = (options.length+1); let inp = ``; let lbl = `` let elm = `
    ${inp}${lbl}${lnk}
    `; // format : Chase Mtg PMT: $ 1,249 BAL: $ 263,456 $(last).before(elm); } let tri = ""; mar.tmp_reo_edit_update_or_insert_mortgage = function(m_uuid, m_bal, m_pmt, m_type, m_name, new_uuid, warning, editable) { let options = $(".reo-mortgage-checkboxes .radiogroup .styled-checklist"); for (let i=0; i < options.length; i++) { let opt = options[i]; let $inp = $(opt).find("input"); let $lbl = $(opt).find("label"); let $spn = $(opt).find("span"); let val = $inp.prop("value"); if (`${m_uuid}` === val) { $lbl.html(`${mar.capitalize(m_name)} PMT: ${elaineui.format("cur",m_pmt)} BAL: ${elaineui.format("cur",m_bal)} (${mar._txt(m_type)})`); let lnk = ""; lnk = `view`; if (editable) { lnk = `edit`; } if (warning) { lnk = `${tri}`; lnk = `edit`; } if ($spn.length === 0) { $lbl.after(lnk); $(opt).css("display","flex"); } else { $spn.replaceWith(lnk); } return; } } mar.tmp_reo_edit_insert_mortgage(m_uuid, m_bal, m_pmt, m_type, m_name, new_uuid); } mar.tmp_reo_update_mortgage_list = function(obj){ let mortgages = mar.answers.v2.liabilities.filter(function(item){ if (item.type === "mortgage") { return ("reolink" in item === false || item.reolink == __reo_uuid); } if (item.type === "heloc") { return ("reolink" in item === false || item.reolink == __reo_uuid); } return false; }) let new_uuid = (arguments === 0) ? false : MAR.getOpt(obj, "new_uuid",false); for (let i=0; i < mortgages.length; i++) { let m_type = MAR.getOpt(mortgages[i], "m_type", ""); let m_name = MAR.getOpt(mortgages[i], "name", ""); let editable = (MAR.getOpt(mortgages[i], "sig", "") === ""); let warning = (m_type === ""); mar.tmp_reo_edit_update_or_insert_mortgage(mortgages[i].uuid, mortgages[i].balance, mortgages[i].monthly, m_type, m_name,new_uuid, warning, editable); } } mar.tmp_reo_edit_mortgage_contine_fn = false; mar.tmp_reo_edit_mortgage_back = function(){ toggler("scenario_simple_reo1"); mar.tmp_reo_edit_mortgage_contine_fn = false; } mar.tmp_reo_edit_mortgage_contine = function(){ toggler("scenario_simple_reo1"); let m_name = txt(".scenario_simple_reo0 #m_name"); let m_bal = txt(".scenario_simple_reo0 #loanamount"); let m_pmt = txt(".scenario_simple_reo0 #monthlypayment"); let m_esc = txt(".scenario_simple_reo0 #escrowamount"); let m_type = radio("m_type"); let m_terms = txt("#m_terms"); let m_odate = txt("#m_odate"); let m_uuid = mar.tmp_reo_edit_mortgage_uuid; if (m_type === "") { mar.tip(".help-button","warning","You need to let us what type of loan it is.","top"); return; } if (mar.tmp_reo_edit_mortgage_uuid === "new") { if (!mar.answers.v2.liabilities) mar.answers.v2.liabilities = []; var linkid = mar.answers.v2.liabilities.length; let new_uuid = mar.fmt.uuid(); mar.answers.v2.liabilities.push({ uuid : new_uuid, type : "mortgage", name : m_name, balance : num(m_bal), monthly : num(m_pmt), escrow : m_esc, terms : m_terms, odate : m_odate, m_type : m_type }); mar.fakesave(); mar.tmp_reo_update_mortgage_list({ new_uuid : new_uuid }); } else { let mi = MAR.liabilities.getByUUID(m_uuid,true); let m = mar.answers.v2.liabilities[mi]; m.balance = num(m_bal); m.monthly = num(m_pmt); m.m_type = m_type; m.name = m_name; m.escrow = m_esc; m.terms = m_terms; m.odate = m_odate; mar.answers.v2.liabilities[mi] = m; mar.fakesave(); mar.tmp_reo_update_mortgage_list(); } if (mar.tmp_reo_edit_mortgage_contine_fn) { mar.tmp_reo_edit_mortgage_contine_fn(); } mar.tmp_reo_edit_mortgage_contine_fn = false; } mar.tmp_reo_edit_mortgage_uuid = false; mar.tmp_reo_edit_mortgage_click = function(elm,event,m_uuid) { mar.tmp_reo_edit_mortgage(m_uuid); } mar.tmp_reo_edit_mortgage = function(m_uuid) { mar.tmp_reo_edit_mortgage_uuid = m_uuid; var m_loanamount = "100000" var m_monthly = "1000" var m_type = ""; var m_name = ""; var m_odate = ""; var m_terms = "360"; var m_acnum = ""; var m_esc = ""; var VAL = ""; if (yn3("#is_subject_property") === "Y") { m_loanamount = getScenario_data("refi_current_debt",m_loanamount); m_monthly = getScenario_data("goals_target_budget_high",m_monthly); if (txt("#reo_purchasedate") !== "") { m_odate = txt("#reo_purchasedate"); let m_now = moment(); let m_m_odate = moment(m_odate); let diff = m_now.diff(m_m_odate,'months'); let _terms = num(m_terms); if (diff < _terms) { let months_left = (_terms - diff); let _loanamount = ~~((num(m_loanamount)/months_left) * _terms); let _purchase_pr = num(txt("#reo_purchase_price")); let _loanamount2 = ~~(_purchase_pr * 0.95); m_loanamount = (_loanamount2 > _loanamount) ? _loanamount2 : _loanamount; } } } let m_readonly = false; if (m_uuid !== "new") { let m = MAR.liabilities.getByUUID(m_uuid); if (m !== false) { m_loanamount = MAR.getOpt(m, "balance","100000"); m_monthly = MAR.getOpt(m, "monthly","100000"); m_type = MAR.getOpt(m, "m_type",""); m_name = MAR.getOpt(m, "name",""); m_readonly = (MAR.getOpt(m, "sig", "") !== ""); m_odate = MAR.getOpt(m, "odate",""); m_terms = MAR.getOpt(m, "terms","360"); m_acnum = MAR.getOpt(m, "acnum",""); m_esc = MAR.getOpt(m, "escrow",""); } } toggler("scenario_simple_reo0"); let el = frm.elaine("Please let me know about the loan/heloc.","er1").render(); VAL = m_name; let mn = frm.txt("m_name","Lending institution name?",VAL,"e.g.Chase","",function(){}).render(); if (m_readonly) { mn = (function() { let h = ""; h += ``; h += `
    Lending institution name :
    ${m_name}
    `; return h; })().wrap("
    ","
    "); } let sl1 = (function() { let h = ""; h += "
    "; h += "
    Loan amount
    "; VAL = m_loanamount; h += frm.slider("loanamount","Within $1000 of:",VAL,"","",function(){ }, { v00 : '0 ', v50 : '25000', v50_inc : '250', v75 : '80000', v75_inc : '500', v100 : '500000', v100_inc : '2500', start_val : '70000' }).render(); h += "
    "; return h; })().wrap("
    ","
    "); if (m_readonly) { sl1 = (function() { let h = ""; h += ``; h += `
    Balance :
    ${elaineui.format("cur",m_loanamount)}
    `; return h; })().wrap("
    ","
    "); } let sl2 = (function() { let h = ""; h += "
    "; h += "
    Monthly payment
    "; VAL = m_monthly; h += frm.slider("monthlypayment","Within $1000 of:",VAL,"","",function(){ }, { v00 : '0 ', v50 : '200', v50_inc : '25', v75 : '1800', v75_inc : '100', v100 : '11500', v100_inc : '250', start_val : '700' }).render(); h += "
    "; return h; })().wrap("
    ","
    "); if (m_readonly) { sl2 = (function() { let h = ""; h += ``; h += `
    Payment :
    ${elaineui.format("cur",m_monthly)}
    `; return h; })().wrap("
    ","
    "); } // VAL = m_terms; // let fl1 = frm.txt("m_terms","Terms?",VAL,"e.g.360","",function(){}).render(); let fl1 = (function() { let h = ""; h += "
    "; h += "
    Terms
    "; VAL = m_terms; h += frm.slider("m_terms","In months:",VAL,"","",function(){ }, { v00 : '0', v50 : '180', v50_inc : '1', v75 : '240', v75_inc : '1', v100 : '360', v100_inc : '1', start_val : '360', formatting_class : '_months' }).render(); h += "
    "; return h; })().wrap("
    ","
    "); if (m_readonly) { fl1 = (function() { let h = ""; h += ``; h += `
    Terms :
    ${m_terms}
    `; return h; })().wrap("
    ","
    "); } VAL = m_odate; let fl2 = frm.txt("m_odate","Start date mortgage?",VAL,"e.g.01/01/2010","",function(){},"date").render(); if (m_readonly) { fl2 = (function() { let h = ""; h += ``; h += `
    Opening date :
    ${m_odate}
    `; return h; })().wrap("
    ","
    "); } let sl3 = (function() { let h = ""; h += "
    "; h += "
    Your current escrow balance
    "; VAL = m_esc; h += frm.slider("escrowamount","Within $1000 of:",VAL,"","",function(){ }, { v00 : '0 ', v50 : '7000', v50_inc : '100', v75 : '15000', v75_inc : '250', v100 : '30000', v100_inc : '1000', start_val : '7000' }).render(); h += "
    "; return h; })().wrap("
    ","
    "); if (yn3("#is_subject_property") !== "Y") { sl3 = ``; } let r1 = (function() { let h = ""; h += "
    "; h += "
    What type of loan is this?
    "; h += `
    `; return h; })().wrap("
    ","
    "); let title = (m_uuid === "new") ? "ADD A MORTGAGE/HELOC" : "EDIT MORTGAGE/HELOC" let newpg = `
    ${title}
    \
    \ ${el} \
    \ ${mn} \ ${sl1} \ ${sl2} \ ${fl1} \ ${fl2} \ ${sl3} \ ${r1}
    `; $(".scenario_simple_reo0").html(newpg); (function(){ $(".scenario_simple_reo0").find(".xx-radio").myradio(); $(".scenario_simple_reo0 .xx-check").mycheck(); $(".scenario_simple_reo0 .xx-check3").mycheck3(); $(".scenario_simple_reo0 .xx-checklist").mychecklist(); $(".scenario_simple_reo0").find(".xx-slider").myslider(); $(".scenario_simple_reo0 ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $(".scenario_simple_reo0 ._percentage").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character suffix: "%", rightAlign: false, autoUnmask : true }); $(".scenario_simple_reo0 .xhuman").Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); })() } mar.toggler_will_toggle = function() { let mortgages = mar.answers.v2.liabilities.filter(function(item){ if (item.type === "mortgage") { return ("reolink" in item === false || item.reolink == __reo_uuid); } if (item.type === "heloc") { return ("reolink" in item === false || item.reolink == __reo_uuid); } return false; }) // toggler_additionals=[]; // $(".toggler_additionals").html(""); // $(".toggler_additionals_tr").html(""); for (let i=0; i < mortgages.length; i++) { let m_uuid = mortgages[i].uuid; let elm = `.scenario_simple_reo_m_${m_uuid}`; let elmname = `scenario_simple_reo_m_${m_uuid}`; let elmlink = `.scenario_simple_reo_m_${m_uuid}_link`; if ($(elm).length === 0) { let newpg = `
    Connected Loan
    `; $(".toggler_additionals").append(newpg); } if ($(elmlink).length === 0) { $(".toggler_additionals_tr").append(`
    LOAN ${i}
    `); } if (toggler_additionals.indexOf(elmname) < 0) { toggler_additionals.push(`scenario_simple_reo_m_${m_uuid}`); } } } mar.deleteReoItemPress = function(elm, idx) { let $elm = $(elm); var s = document.createElement("div"); s.setAttribute("class","normal-form"); s.innerHTML = ""+ frm.htitle("Conformation").render() + "Are you sure you want to delete this property ? "; swal({ //title : "Same line of work", className : "midelinfopopupOneButton", content : s, buttons : { cancel : "No", call : { text: "Delete", value: "del", closeModal: false } } }) .then((act) => { if (act == "del") { MAR.reo.del((idx-1)) frm.buttons.hide(function(){ let cp = mvc.currentpage; mar.fakesave(function(){ swal.close(); if (mvc.currentpage === cp) { mvc.go("#reo-home"); } }); }); } }); } var buttons = ""; if (localopts.n == 0) { buttons += ""; } else { buttons += ""; buttons += ""; } buttons += ""; //h += buttons; localopts.buttons = buttons; /// END (function(){ let dtToday = new Date(); let month = dtToday.getMonth() + 1; let day = dtToday.getDate(); let year = dtToday.getFullYear(); if (month < 10) month = '0' + month.toString(); if (day < 10) day = '0' + day.toString(); let maxDate = year + '-' + month + '-' + day; localopts._date_today = maxDate; })(); h = Mustache.render(h,localopts); let oc = function(skipReturn) { } let load = function(n) { reo_simple_property_initr(n); } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xx-checklist").mychecklist(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); $("#body-container ._percentage").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '', //No Space, this will truncate the first character suffix: "%", rightAlign: false, autoUnmask : true }); mar.tmp_reo_update_mortgage_list(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); load(N); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "About Us" } return { render : render, section : "general" } })() mar.pg["reo-property-connectedloan"] = (function(){ var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "0" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let N = num(existingid); var _reo = (N > 0) ? mar.answers.v2.reo[N-1] : false; let h = ""; h += frm.htitle("Real Estate Owned").render(); h += "
    "; h += "
    "; var VAL = ""; var options = {} for (var i=0; i < mar.answers.v2.liabilities.length; i++) { var item = mar.answers.v2.liabilities[i]; if (!item || item == null) continue; if (item.type == "mortgage" || item.type == "heloc") { if (_reo !== false) { if(!("reolink" in item) || item.reolink == _reo.uuid || num(item.reolink) == (N-1)) { let mo = sprintf("
    %s%s%s
    ",item.name, mar.fmt.currency(item.balance).replace(/\,/g,","), mar.fmt.currency(item.monthly).replace(/\,/g,",")); options[item.uuid] = mo; if (item.reolink == _reo.uuid || num(item.reolink) == (N-1)) VAL = item.uuid; } } } } if (options.length == 0) { options.nl = "Has a mortgage"; options.free = "Is mortgage free"; } else { options.nl = "Has a mortgage but is not listed above"; options.free = "Is mortgage free"; } h += frm.radio("reo_mortgageoptions","What mortgage is outstanding on this property?",VAL,"","",function(){ },options).render(); h += "
    "; h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ let reo_mortgageoptions = radio("reo_mortgageoptions"); if (reo_mortgageoptions == "") { } //mvc.go("#scenario-legalstatus."+applicantnum); }),"Back",frm.addfunction(function(){ // mvc.go("#scenario-creditscore."+applicantnum); }),"mar.help()"); /** * we need to display the linked item if there is one */ var loanlink = -1; var localopts = JSON.parse(JSON.stringify(mar.mdata)); localopts.n = (N) ? N : 0; /// END h = Mustache.render(h,localopts); let oc = function(skipReturn) { } let load = function(n) { reo_simple_property_init(n); } let or = function(){ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container .xhuman").Humanize({ opts : { fn : function() { oc(true); } }, quick : false, }); load(N); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "About Us" } return { render : render, section : "general" } })() /* file /ui/app/js/pages.encompass.import.js , last updated 1671116545178*/ mar.pg["import-encompass-intro"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: CHECK APPLICATION
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Let's go over the loan application. Every question that was asked is pre-filled so no double work!
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += ""; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["import-encompass-upnext-submit"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; mar.pg_accesscontrollerfn = function() { return "open"; } /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    CONGRATULATIONS: You have completed your application.
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; // h += "
    Continuet to Submit your application.
    "; h += "
     
    "; h += "
    "; h += "
    "; h += "
    SUBMIT
    "; h += "
    "; h += ""; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ debugger; elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "homework" } })(); mar.pg["submit"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    CONGRATULATIONS: You have completed your application.
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; // h += "
    Continuet to Submit your application.
    "; h += "
     
    "; h += "
    "; h += "
    "; h += "
    SUBMIT
    "; h += "
    "; h += ""; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "homework" } })(); mar.pg["import-encompass-unverfied-income-change"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let VAL = ""; let h = ""; let hr = "
    ";//frm.hr().render(); h += frm.htitle("Income Change").render(); h += frm.elaine("We are missing some essential information about your application. Can you answer the following questions please.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div h += "
    " h += "
    ";
    		
    		let changes = {};
    		
    		for (let x in mar.answers.v2.scenario) {
    			if (x.startsWith("__enc_income")) {
    				h += `
    ${x}
    `; h += `
    ${mar.answers.v2.scenario[x]}
    `; } if (x.startsWith("__enc_over")) { h += `
    ${x}
    `; h += `
    ${mar.answers.v2.scenario[x]}
    `; } if (x.startsWith("__enc_incomechange")) { if (mar.answers.v2.scenario[x] === false) continue; // h += `
    ${x}
    `; // h += `
    ${mar.answers.v2.scenario[x]}
    `; try { let ch = JSON.parse(mar.answers.v2.scenario[x]); for (let y in ch) { let applicant = MAR.applicants.getBySSN(y); if (applicant === false) continue; if (applicant in changes === false) changes[applicant] = {}; changes[applicant].sn = MAR.digits(y); for (let z in ch[y]) { let _val = ch[y][z]; if (z in changes[applicant] === false) changes[applicant][z] = 0; if (z.endsWith("D")) { changes[applicant][z] += num(_val); } else { changes[applicant][z] = num(_val); } } } } catch(E) { } } } //h += `
    ${JSON.stringify(changes,null,4)}
    `; h += "
    "; let candidates = []; mar.tmp_select_income_changes_obj = false; for (let x in changes) { let items = mar.answers.v2.income[num(x)].items; mar.tmp_select_income_changes_obj = x; h += "
    "; h += `

    We need to adjust up the income income of ${getApplicantsNames_v2(num(x)).Name} :

    `; if (num(MAR.getOpt(changes[x], "baseD", "0")) !== 0) { h += `
  • Base income by ${elaineui.format('cur',num(MAR.getOpt(changes[x], "baseD", "0")))} to ${elaineui.format('cur',num(MAR.getOpt(changes[x], "base", "0")))} pm
  • `; } if (num(MAR.getOpt(changes[x], "commissionD", "0")) !== 0) { h += `
  • Commission income by ${elaineui.format('cur',num(MAR.getOpt(changes[x], "commissionD", "0")))} to ${elaineui.format('cur',num(MAR.getOpt(changes[x], "commission", "0")))} pm
  • `; } if (num(MAR.getOpt(changes[x], "bonusD", "0")) !== 0) { h += `
  • Bonus income by ${elaineui.format('cur',num(MAR.getOpt(changes[x], "bonusD", "0")))} to ${elaineui.format('cur',num(MAR.getOpt(changes[x], "bonus", "0")))} pm
  • `; } if (num(MAR.getOpt(changes[x], "overtimeD", "0")) !== 0) { h += `
  • Overtime income by ${elaineui.format('cur',num(MAR.getOpt(changes[x], "overtimeD", "0")))} to ${elaineui.format('cur',num(MAR.getOpt(changes[x], "overtime", "0")))} pm
  • `; } h += "
    "; for (let i=0; i < items.length; i++) { let job = items[i]; if (MAR.getOpt(job, "_t", "") === "w2-previous") continue; if (MAR.getOpt(job, "type", "") === "w2") { candidates.push(i); continue; } if (num(MAR.getOpt(changes[x], "commissionD", "0")) !== 0) continue; if (num(MAR.getOpt(changes[x], "bonusD", "0")) !== 0) continue; if (num(MAR.getOpt(changes[x], "overtimeD", "0")) !== 0) continue; if (MAR.getOpt(job, "type", "") === "llc") { candidates.push(i); continue; } if (MAR.getOpt(job, "type", "") === "corp") { candidates.push(i); continue; } // h += "
    ";
    //				h 				+= JSON.stringify(job,null,4);
    //				h += "
    "; } if (candidates.length === 0) { // create a W2 job } else if (candidates.length === 1) { // add to the only candidate if (mar.answers.v2.income[num(x)].items[candidates[0]].type === "w2") { h += `

    We are going to adjust the income on the income and then ask you to verify the numbers.

    `; h += `
  • ${job.name}
  • `; } else { } } else { h += `

    Please select from the following jobs to adjust the income and we'll add it in and ask you to verify the numbers.

    `; for (let i=0; i < candidates.length; i++) { let job = mar.answers.v2.income[num(x)].items[candidates[i]]; h += `
  • ${job.name}
  • `; } } } mar.tmp_select_income = function(candidatenum) { let x = num(mar.tmp_select_income_changes_obj); let change_item = changes[mar.tmp_select_income_changes_obj]; let jobnum = candidatenum; let job = mar.answers.v2.income[x].items[jobnum]; if (job.type === "w2") { debugger; if (num(MAR.getOpt(change_item, "baseD", "0")) !== 0) { if (job.salary_choice === "hourly") { job.income_w2_base = num(job.income_w2_base) + (( num(MAR.getOpt(change_item, "baseD", "0")) * 12) / (52 * num(job.hours_per_week))); } if (job.salary_choice === "monthly") { job.income_w2_base = num(job.income_w2_base) + num(MAR.getOpt(change_item, "baseD", "0")); } } if (num(MAR.getOpt(change_item, "bonusD", "0")) !== 0) { job.salary_bonus = "Y"; job.salary_3yearquestion = "Y"; job.income_w2_bonus_2020 += num(MAR.getOpt(change_item, "bonusD", "0")); job.income_w2_bonus_2019 += num(MAR.getOpt(change_item, "bonusD", "0")); job.income_w2_bonus_2018 += num(MAR.getOpt(change_item, "bonusD", "0")); } if (num(MAR.getOpt(change_item, "overtimeD", "0")) !== 0) { job.salary_overtime = "Y"; job.salary_3yearquestion = "Y"; job.income_w2_overtime_2020 += num(MAR.getOpt(change_item, "overtimeD", "0")); job.income_w2_overtime_2019 += num(MAR.getOpt(change_item, "overtimeD", "0")); job.income_w2_overtime_2018 += num(MAR.getOpt(change_item, "overtimeD", "0")); } if (num(MAR.getOpt(change_item, "commissionD", "0")) !== 0) { job.salary_commission = "Y"; job.salary_3yearquestion = "Y"; job.income_w2_commission_2020 += num(MAR.getOpt(change_item, "commissionD", "0")); job.income_w2_commission_2019 += num(MAR.getOpt(change_item, "commissionD", "0")); job.income_w2_commission_2018 += num(MAR.getOpt(change_item, "commissionD", "0")); } mvc.go(`#income-w2manual.${x}.${jobnum}`) } else { debugger; } } // `__enc_incomechange_${new Date().getTime()} h += "" let reveal = function(){ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } return true; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (reveal() !== true) return; mar.fakesave(function(){ mvc.go("#import-encompass"); }) }),"close",frm.addfunction(function(){ }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function() { } let or = function(){ // if (missingfields.length == 0 && missingPages == false) { // setScenario_data("__application_imported_from_encompass_needs_verification","N"); // setScenario_data("__application_imported_from_encompass_allowed_page",""); // mar.fakesave(function(){ // mvc.go("#lox"); // }) // return; // } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["import-encompass"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let VAL = ""; let h = ""; let hr = "
    ";//frm.hr().render(); h += frm.htitle("Missing Info").render(); h += frm.elaine("We are missing some essential information about your application. Can you answer the following questions please.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div let applicantLength = getApplicants_v2().length; let missingfields = []; for (let i=0; i < applicantLength; i++) { var _na = getApplicantsNames_v2(i).Name; VAL = getApplicantBucket(i).ty; if (typeof VAL == "undefined" || VAL == "") { h += (function(){ let h = ""; h += `
    Information about ${_na}
    `; missingfields.push(`ty_${i}`); h += frm.radio(`ty_${i}`,"What year did you last file your Personal Tax Returns 1040's?",VAL,"","",function(){ reveal(); //oc(); },{ "2015" : "2015", "2016" : "2016", "2017" : "2017", "2018" : "2018" }).render(); return h; })().wrap("
    "+hr,"
    ");; } let adc = MAR.getApplicantAddressCurrent(i)[0]; VAL = adc.appears_on_drivers_license; if (typeof VAL == "undefined" || VAL == "") { h += (function(){ let h = ""; // h += `
    ${JSON.stringify(adc,null,4)}
    `; h += MAR.addressToString(adc.address); missingfields.push(`dl_${i}`); h += frm.radio(`dl_${i}`,`Does this address appear on your drivers license? `,VAL,"","",function(){ reveal(); oc(); },{ "Y" : "Yes", "N" : "No", "NA" : "My state does not display an address on my drivers license" }, {}).render() return h; })().wrap("
    "+hr,"
    ");; } VAL = adc.appears_on_tax_returns; if (typeof VAL == "undefined" || VAL == "") { h += (function(){ let h = ""; // h += `
    ${JSON.stringify(adc,null,4)}
    `; h += MAR.addressToString(adc.address); missingfields.push(`tr_${i}`); h += frm.yn3(`tr_${i}`,"Is this the address you used on your last tax returns?",VAL,"","",function(){ reveal(); },{}).render() return h; })().wrap("
    "+hr,"
    ");; } if ("years" in adc == false || "months" in adc == false || adc.years == "" || adc.months == "") { h += (function(){ let h = ""; h += MAR.addressToString(adc.address); missingfields.push(`years_${i}`); h += "
    How long have you been living at this address
    "; h += "
    "; VAL = adc.years; h += frm.slider(`years_${i}`,"Years:",VAL,"","",function(){ }, { v00 : '0', v50 : '8', v50_inc : '1', v75 : '45', v75_inc : '1', v100 : '60', v100_inc : '1', start_val : '2', formatting_class : '_years' }).render(); h += "
    "; h += "
    "; VAL = adc.months; h += frm.slider(`months_${i}`,"Months:",VAL,"","",function(){ }, { v00 : '0', v50 : '6', v50_inc : '1', v75 : '9', v75_inc : '1', v100 : '11', v100_inc : '1', start_val : '0', formatting_class : '_months' }).render(); h += "
    "; return h; })().wrap("
    "+hr,"
    "); } } let missingPages = false; let where_to_go = false; if ( missingfields.length == 0) { revealclass = ""; // if (missingPages == false &&mar.pg["reo-home"].iscomplete(i) !== true) { // h += (function(){ // let h = ""; // h += "I'd like you to press continue to review the details of a property that you own."; // return h; // })().wrap("
    "+hr,"
    "); // let idx = mar.pg["reo-home"].iscomplete(i); // missingPages = [`#reo-property.0.${(idx+1)}`]; // } if (missingPages == false) { for (let i=0; i < applicantLength; i++) { var _na = getApplicantsNames_v2(i).Name; if (mar.pg["declarations-p1"].iscomplete(i) === false) { h += (function(){ let h = ""; h += "Declarations Page1 is incomplete, press continue to fill the information"; return h; })().wrap("
    "+hr,"
    "); missingPages = ["#declarations-p1.0.0"]; break; } if (mar.pg["declarations-p2"].iscomplete(i) === false) { h += (function(){ let h = ""; h += "Declarations Page2 is incomplete, press continue to fill the information"; return h; })().wrap("
    "+hr,"
    "); missingPages = ["#declarations-p2.0.0"]; break; } if (mar.pg["declarations-p3"].iscomplete(i) === false) { h += (function(){ let h = ""; h += "Declarations Page3 is incomplete, press continue to fill the information"; return h; })().wrap("
    "+hr,"
    "); missingPages = ["#declarations-p3.0.0"]; break; } // if (i == 0 && mar.pg["assets-choice"].iscomplete(i) !== true) { // h += (function(){ // let h = ""; // h += "I'd like you to press continue to review the details of an asset. Please be sure to check the details and also whether there are additional names on the asset."; // return h; // })().wrap("
    "+hr,"
    "); // let idx = mar.pg["assets-choice"].iscomplete(i); // let as = MAR.assets.get("",idx); // missingPages = [`#assets-${MAR.assets.type_to_editor(as.type)}.${i}.${idx}`]; // break; // // } if (mar.pg["income-how"].iscomplete(i) !== true) { h += (function(){ let h = ""; h += "I'd like you to press continue to review the details of an income source. You'll first be asked what type of income it is and then to review the details."; return h; })().wrap("
    "+hr,"
    "); let idx = mar.pg["income-how"].iscomplete(i); missingPages = [ `#income-.${i}.${idx}` ,`#income-w2manual.${i}.${idx}` , `#income-w2-previous.${i}.${idx}` ,`#income-other.${i}.${idx}` , `#income-DD1099.${i}.${idx}` ,`#income-llc.${i}.${idx}` , `#income-k1.${i}.${idx}` ,`#income-alimony.${i}.${idx}` , `#income-dis.${i}.${idx}` ,`#income-pension.${i}.${idx}` , `#income-child-support.${i}.${idx}` , `#income-social-security.${i}.${idx}`]; break; } } } if (missingPages == false && getScenario_data("__scenario_realtor_verified","Y") === "N") { h += (function(){ let h = ""; h += "Can you please review the details of your realtor."; return h; })().wrap("
    "+hr,"
    ");; missingPages = ["#scenario-realtor","#scenario-realtorinfo"]; } if (missingPages == false &&mar.pg["reo-home"].iscomplete(i) !== true) { h += (function(){ let h = ""; h += "I'd like you to press continue to review the details of a property that you own."; return h; })().wrap("
    "+hr,"
    "); let idx = mar.pg["reo-home"].iscomplete(i); missingPages = [`#reo-property.0.${(idx+1)}`]; // missingPages = [`#reo_simple`]; } if (missingPages == false) { h += (function(){ let h = ""; h += "Well done, you have filled in all the basic info we need, Do you want to START at the beginning or go straight to Homework "; h += frm.radio(`where_to_go`,`I would like to start go to:`,VAL,"","",function(){ oc(); },{ "homework" : "HOMEWORK", "start" : "BEGINNING" }, {}).render() return h; })().wrap("
    "+hr,"
    "); where_to_go = true; } } h += "
    " let reveal = function(){ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } return true; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (reveal() !== true) return; if (missingPages !== false) { setScenario_data("__application_imported_from_encompass_allowed_page",missingPages); mar.fakesave(function(){ mvc.go(missingPages[0]); }); return; } if (where_to_go !== false) { let where_to_go = radio("where_to_go"); if (where_to_go == "") { return mar.tip(".help-button","warning","You need to tell us how to proceed.","top"); } if (where_to_go == "homework") { setScenario_data("__application_imported_from_encompass_needs_verification","N"); setScenario_data("__application_imported_from_encompass_allowed_page",""); mar.fakesave(function(){ mvc.go("#lox"); }) } else { setScenario_data("__application_imported_from_encompass_needs_verification","N"); setScenario_data("__application_imported_from_encompass_allowed_page",""); mar.fakesave(function(){ mvc.go("#scenario-timeframe"); }) } return; } // if (missingfields.length == 0) { // setScenario_data("__application_imported_from_encompass_needs_verification","N"); // setScenario_data("__application_imported_from_encompass_allowed_page",""); // mar.fakesave(function(){ // mvc.go("#import-encompass"); // }) // } for (let i=0; i < applicantLength; i++) { if (missingfields.indexOf(`ty_${i}`) > -1) { let val = radio(`ty_${i}`); if (val == "") { return mar.tip(".help-button","warning","You need to tell us the year you filed taxes.","top"); } MAR.application.setBorrower(mar.answers, i, { TY : val }); } let adc = MAR.getApplicantAddressCurrent(i)[0]; if (missingfields.indexOf(`dl_${i}`) > -1) { let val = radio(`dl_${i}`); if (val == "") { return mar.tip(".help-button","warning","You need to tell us if the address appears on your Drivers License.","top"); } mar.answers.v2.buckets[adc.bucketid].appears_on_drivers_license = val; } if (missingfields.indexOf(`tr_${i}`) > -1) { let val = yn3(`#tr_${i}`); if (val == "") { return mar.tip(".help-button","warning","You need to tell us if the address appears on your Tax Returns.","top"); } mar.answers.v2.buckets[adc.bucketid].appears_on_tax_returns = val; } if (missingfields.indexOf(`years_${i}`) > -1) { let y = txt(`#years_${i}`); if (y == "") { return mar.tip(".help-button","warning","You need to tell us the amount of years you lived at the current address.","top"); } let m = txt(`#months_${i}`); if (m == "") { return mar.tip(".help-button","warning","You need to tell us the amount of months you lived at the current address.","top"); } mar.answers.v2.buckets[adc.bucketid].years = y; mar.answers.v2.buckets[adc.bucketid].months = m; } } mar.fakesave(function(){ mvc.go("#import-encompass"); }) }),"close",frm.addfunction(function(){ }),"mar.help()"); h = Mustache.render(h,localopts); // let incomeButtonClick = function(e){ // console.log('pressed icon button e: ',e); // let $elm = $(e.currentTarget); // let goto = $elm.data("goto"); // if ($elm.hasClass("swal")) swal.close(); // console.warn('goto : '+goto); // // if (goto && goto == "selfemployed") { // // let h = ""; // // h += ""; // // h += "
    "; // h += frm.htitle("Self Employed Income").render(); // h += "
    Type of business?
    " //// h += "Which type of Self Employed
    income are you adding?"; // //h += frm.elaine("Which type of Self Employed income are you adding?","").render(); // h += "
    "; // // // h += "
    " + // "
    "+$("#svg_w2_icon_income").html()+"Sole Proprietor
    1099
    " + //// "
    "+$("#svg_corporation_icon_income").html()+"Corporation
    " + // "
    "+$("#svg_llc_icon_income").html()+"Business Owner
    LLC
    " + // "
    "; // h += "
    "; // h += "
    "; // // var s = document.createElement("div"); // s.setAttribute("class","normal-form"); // s.innerHTML = h; // // swal({ // //title : "Self Employed Income Type", // className : "midelinfopopupOneButton", // content : s, // buttons : { // cancel : "BACK" // } // }) // .then((act) => { // }); // $(".incomeIcons_button.swal").on('click', incomeButtonClick) // // // return; // } // // mvc.go("#income-"+pagenames[goto]+"."+applicantnum+"."+p3); // }; let oc = function() { } let or = function(){ // if (missingfields.length == 0 && missingPages == false) { // setScenario_data("__application_imported_from_encompass_needs_verification","N"); // setScenario_data("__application_imported_from_encompass_allowed_page",""); // mar.fakesave(function(){ // mvc.go("#lox"); // }) // return; // } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["update-encompass"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let VAL = ""; let h = ""; let hr = "
    ";//frm.hr().render(); h += frm.htitle("Missing Info").render(); h += frm.elaine("We are missing some essential information about your application. Can you answer the following questions please.","er").render(); // JC - CW - elaine added "er" h += "
    "; // JC - CW - elaine added div let applicantLength = getApplicants_v2().length; let missingfields = []; for (let i=0; i < applicantLength; i++) { var _na = getApplicantsNames_v2(i).Name; VAL = getApplicantBucket(i).ty; if (typeof VAL == "undefined" || VAL == "") { h += (function(){ let h = ""; h += `
    Information about ${_na}
    `; missingfields.push(`ty_${i}`); h += frm.radio(`ty_${i}`,"What year did you last file your Personal Tax Returns 1040's?",VAL,"","",function(){ reveal(); //oc(); },{ "2015" : "2015", "2016" : "2016", "2017" : "2017", "2018" : "2018" }).render(); return h; })().wrap("
    "+hr,"
    ");; } let adc = MAR.getApplicantAddressCurrent(i)[0]; VAL = adc.appears_on_drivers_license; if (typeof VAL == "undefined" || VAL == "") { h += (function(){ let h = ""; // h += `
    ${JSON.stringify(adc,null,4)}
    `; h += MAR.addressToString(adc.address); missingfields.push(`dl_${i}`); h += frm.radio(`dl_${i}`,`Does this address appear on your drivers license? `,VAL,"","",function(){ reveal(); oc(); },{ "Y" : "Yes", "N" : "No", "NA" : "My state does not display an address on my drivers license" }, {}).render() return h; })().wrap("
    "+hr,"
    ");; } VAL = adc.appears_on_tax_returns; if (typeof VAL == "undefined" || VAL == "") { h += (function(){ let h = ""; // h += `
    ${JSON.stringify(adc,null,4)}
    `; h += MAR.addressToString(adc.address); missingfields.push(`tr_${i}`); h += frm.yn3(`tr_${i}`,"Is this the address you used on your last tax returns?",VAL,"","",function(){ reveal(); },{}).render() return h; })().wrap("
    "+hr,"
    ");; } if ("years" in adc == false || "months" in adc == false || adc.years == "" || adc.months == "") { h += (function(){ let h = ""; h += MAR.addressToString(adc.address); missingfields.push(`years_${i}`); h += "
    How long have you been living at this address
    "; h += "
    "; VAL = adc.years; h += frm.slider(`years_${i}`,"Years:",VAL,"","",function(){ }, { v00 : '0', v50 : '8', v50_inc : '1', v75 : '45', v75_inc : '1', v100 : '60', v100_inc : '1', start_val : '2', formatting_class : '_years' }).render(); h += "
    "; h += "
    "; VAL = adc.months; h += frm.slider(`months_${i}`,"Months:",VAL,"","",function(){ }, { v00 : '0', v50 : '6', v50_inc : '1', v75 : '9', v75_inc : '1', v100 : '11', v100_inc : '1', start_val : '0', formatting_class : '_months' }).render(); h += "
    "; return h; })().wrap("
    "+hr,"
    "); } } let missingPages = false; let where_to_go = false; if ( missingfields.length == 0) { revealclass = ""; // if (missingPages == false &&mar.pg["reo-home"].iscomplete(i) !== true) { // h += (function(){ // let h = ""; // h += "I'd like you to press continue to review the details of a property that you own."; // return h; // })().wrap("
    "+hr,"
    "); // let idx = mar.pg["reo-home"].iscomplete(i); // missingPages = [`#reo-property.0.${(idx+1)}`]; // } if (missingPages == false) { for (let i=0; i < applicantLength; i++) { var _na = getApplicantsNames_v2(i).Name; if (mar.pg["declarations-p1"].iscomplete(i) === false) { h += (function(){ let h = ""; h += "Declarations Page1 is incomplete, press continue to fill the information"; return h; })().wrap("
    "+hr,"
    "); missingPages = ["#declarations-p1.0.0"]; break; } if (mar.pg["declarations-p2"].iscomplete(i) === false) { h += (function(){ let h = ""; h += "Declarations Page2 is incomplete, press continue to fill the information"; return h; })().wrap("
    "+hr,"
    "); missingPages = ["#declarations-p2.0.0"]; break; } if (mar.pg["declarations-p3"].iscomplete(i) === false) { h += (function(){ let h = ""; h += "Declarations Page3 is incomplete, press continue to fill the information"; return h; })().wrap("
    "+hr,"
    "); missingPages = ["#declarations-p3.0.0"]; break; } // if (i == 0 && mar.pg["assets-choice"].iscomplete(i) !== true) { // h += (function(){ // let h = ""; // h += "I'd like you to press continue to review the details of an asset. Please be sure to check the details and also whether there are additional names on the asset."; // return h; // })().wrap("
    "+hr,"
    "); // let idx = mar.pg["assets-choice"].iscomplete(i); // let as = MAR.assets.get("",idx); // missingPages = [`#assets-${MAR.assets.type_to_editor(as.type)}.${i}.${idx}`]; // break; // // } if (mar.pg["income-how"].iscomplete(i) !== true) { h += (function(){ let h = ""; h += "I'd like you to press continue to review the details of an income source. You'll first be asked what type of income it is and then to review the details."; return h; })().wrap("
    "+hr,"
    "); let idx = mar.pg["income-how"].iscomplete(i); missingPages = [ `#income-.${i}.${idx}` ,`#income-w2manual.${i}.${idx}` , `#income-w2-previous.${i}.${idx}` ,`#income-other.${i}.${idx}` , `#income-DD1099.${i}.${idx}` ,`#income-llc.${i}.${idx}` , `#income-k1.${i}.${idx}` ,`#income-alimony.${i}.${idx}` , `#income-dis.${i}.${idx}` ,`#income-pension.${i}.${idx}` , `#income-child-support.${i}.${idx}` , `#income-social-security.${i}.${idx}`]; break; } } } if (missingPages == false && getScenario_data("__scenario_realtor_verified","Y") === "N") { h += (function(){ let h = ""; h += "Can you please review the details of your realtor."; return h; })().wrap("
    "+hr,"
    ");; missingPages = ["#scenario-realtor","#scenario-realtorinfo"]; } if (missingPages == false &&mar.pg["reo-home"].iscomplete(i) !== true) { h += (function(){ let h = ""; h += "I'd like you to press continue to review the details of a property that you own."; return h; })().wrap("
    "+hr,"
    "); let idx = mar.pg["reo-home"].iscomplete(i); missingPages = [`#reo-property.0.${(idx+1)}`]; // missingPages = [`#reo_simple`]; } if (missingPages == false) { h += (function(){ let h = ""; h += "Well done, you have filled in all the basic info we need, Do you want to START at the beginning or go straight to Homework "; h += frm.radio(`where_to_go`,`I would like to start go to:`,VAL,"","",function(){ oc(); },{ "homework" : "HOMEWORK", "start" : "BEGINNING" }, {}).render() return h; })().wrap("
    "+hr,"
    "); where_to_go = true; } } h += "
    " let reveal = function(){ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } return true; } h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ if (reveal() !== true) return; if (missingPages !== false) { setScenario_data("__application_imported_from_encompass_allowed_page",missingPages); mar.fakesave(function(){ mvc.go(missingPages[0]); }); return; } if (where_to_go !== false) { let where_to_go = radio("where_to_go"); if (where_to_go == "") { return mar.tip(".help-button","warning","You need to tell us how to proceed.","top"); } if (where_to_go == "homework") { setScenario_data("__application_imported_from_encompass_needs_verification","N"); setScenario_data("__application_imported_from_encompass_allowed_page",""); mar.fakesave(function(){ mvc.go("#lox"); }) } else { setScenario_data("__application_imported_from_encompass_needs_verification","N"); setScenario_data("__application_imported_from_encompass_allowed_page",""); mar.fakesave(function(){ mvc.go("#scenario-timeframe"); }) } return; } // if (missingfields.length == 0) { // setScenario_data("__application_imported_from_encompass_needs_verification","N"); // setScenario_data("__application_imported_from_encompass_allowed_page",""); // mar.fakesave(function(){ // mvc.go("#import-encompass"); // }) // } for (let i=0; i < applicantLength; i++) { if (missingfields.indexOf(`ty_${i}`) > -1) { let val = radio(`ty_${i}`); if (val == "") { return mar.tip(".help-button","warning","You need to tell us the year you filed taxes.","top"); } MAR.application.setBorrower(mar.answers, i, { TY : val }); } let adc = MAR.getApplicantAddressCurrent(i)[0]; if (missingfields.indexOf(`dl_${i}`) > -1) { let val = radio(`dl_${i}`); if (val == "") { return mar.tip(".help-button","warning","You need to tell us if the address appears on your Drivers License.","top"); } mar.answers.v2.buckets[adc.bucketid].appears_on_drivers_license = val; } if (missingfields.indexOf(`tr_${i}`) > -1) { let val = yn3(`#tr_${i}`); if (val == "") { return mar.tip(".help-button","warning","You need to tell us if the address appears on your Tax Returns.","top"); } mar.answers.v2.buckets[adc.bucketid].appears_on_tax_returns = val; } if (missingfields.indexOf(`years_${i}`) > -1) { let y = txt(`#years_${i}`); if (y == "") { return mar.tip(".help-button","warning","You need to tell us the amount of years you lived at the current address.","top"); } let m = txt(`#months_${i}`); if (m == "") { return mar.tip(".help-button","warning","You need to tell us the amount of months you lived at the current address.","top"); } mar.answers.v2.buckets[adc.bucketid].years = y; mar.answers.v2.buckets[adc.bucketid].months = m; } } mar.fakesave(function(){ mvc.go("#import-encompass"); }) }),"close",frm.addfunction(function(){ }),"mar.help()"); h = Mustache.render(h,localopts); // let incomeButtonClick = function(e){ // console.log('pressed icon button e: ',e); // let $elm = $(e.currentTarget); // let goto = $elm.data("goto"); // if ($elm.hasClass("swal")) swal.close(); // console.warn('goto : '+goto); // // if (goto && goto == "selfemployed") { // // let h = ""; // // h += ""; // // h += "
    "; // h += frm.htitle("Self Employed Income").render(); // h += "
    Type of business?
    " //// h += "Which type of Self Employed
    income are you adding?"; // //h += frm.elaine("Which type of Self Employed income are you adding?","").render(); // h += "
    "; // // // h += "
    " + // "
    "+$("#svg_w2_icon_income").html()+"Sole Proprietor
    1099
    " + //// "
    "+$("#svg_corporation_icon_income").html()+"Corporation
    " + // "
    "+$("#svg_llc_icon_income").html()+"Business Owner
    LLC
    " + // "
    "; // h += "
    "; // h += "
    "; // // var s = document.createElement("div"); // s.setAttribute("class","normal-form"); // s.innerHTML = h; // // swal({ // //title : "Self Employed Income Type", // className : "midelinfopopupOneButton", // content : s, // buttons : { // cancel : "BACK" // } // }) // .then((act) => { // }); // $(".incomeIcons_button.swal").on('click', incomeButtonClick) // // // return; // } // // mvc.go("#income-"+pagenames[goto]+"."+applicantnum+"."+p3); // }; let oc = function() { } let or = function(){ // if (missingfields.length == 0 && missingPages == false) { // setScenario_data("__application_imported_from_encompass_needs_verification","N"); // setScenario_data("__application_imported_from_encompass_allowed_page",""); // mar.fakesave(function(){ // mvc.go("#lox"); // }) // return; // } $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $($("#body-container .xhuman")[0]).Humanize({ // JC - CW - elaine opts : { fn : function() { oc(true); } }, quick : false, }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); /* file /ui/app/js/pages.flow.js , last updated 1565675433895*/ mar.pg["flow-confirmtakeover"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: TAKE OVER APPLICATION
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    You have been asked to take over this application!
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += ""; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["flow-reconfirm"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Up Next: NEW BORROWER
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    There is a new borrower on the loan, in homework you'll see instructions how to verify the data!
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += ""; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["flow-reconfirm-assets"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += `
    Up Next: ${names} ASSETS
    `; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    There is a new borrower on the loan, in homework you'll see instructions how to verify the data!
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += ""; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["flow-reconfirm-personaldata"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += `
    Up Next: ${names} Personal Data
    `; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    There is a new borrower on the loan, in homework you'll see instructions how to verify the data!
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += ""; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["flow-reconfirm-income"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += `
    Up Next: ${names} Income
    `; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    There is a new borrower on the loan, in homework you'll see instructions how to verify the data!
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += ""; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["flow-reconfirm-applicnatconfirmed"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += `
    All Done: ${names} INFO CONFIRMED!
    `; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    Well done!
    "; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += ""; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["flow-test"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    + confirm app 1
    "; h += "
    + confirm app 2
    "; h += "
    + confirm app 3
    "; h += "
    - confirm
    "; h += "
    + takeover
    "; h += "
    - takeover
    "; h += "
    "; h += ""; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); mar.pg["flow-flex"] = (function(){ var VAL = '' var html = ""; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var names = getApplicantsNames_v2(applicantnum).Names; /** * standard starting block - END */ let h = ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += ""; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += `
    ${MAR.getOpt(mar,"tmp_flex_title_prefix","")}${MAR.getOpt(mar,"tmp_flex_title","")}
    `; h += "
    "; h += "
    "; h += "
    "; h += "
    "; h += `
    ${MAR.getOpt(mar,"tmp_flex_subtitle","")}
    `; h += "
    "; h += "
    "; h += "
    Continue
    "; h += "
    "; h += ""; /* end modal content */ h = Mustache.render(h,localopts); let or = function(){ elaineui.upnext_icon_fix(); $($("#body-container .xhuman")[0]).Humanize({ opts : { fn : function() { //oc(true); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render } })(); /* file /ui/app/js/pages.subjectproperty.js , last updated 1571229742293*/ let models = {}; models.subjectproperty = (function(data){ let da = data; function _new() { da = { "closing_date": "", // "listed_price": "0", // "selling_price": "0", // "addr" : "3426 Market Street|Philadelphia|PA|19104|", // "address_street": "", // "address_city": "", // "address_state": "", "address_zip": "", // "first_deposit": "750", "first_deposit_date_due": "2018-02-02", "second_deposit": "750", "second_deposit_date_due": "2018-02-02", // "eff_date_of_contract": "", "inspection_period_ends": "48 days", "fin_contin_date_ends": "49 days", "seller_concession": "1900", "selling_agent_contributions": "3800", "buying_agent_contributions": "2100", "annual_taxes": "", "cma_comp_value": "65000", "type_of_sale": "1", "for_sale_by_owner_YN": "on", "escrow_agent": "Hobb Burster", "contact_person": "123123", "contact_person_email": "312321312312", "contact_person_phone": "123312312312312", "escrow_is_closing_agent_YN": "on", "closing_agent": "Ricky Parnassus", "closing_agent_contact_person": "Jen Trager", "closing_agent_contact_person_email": "jt@hotamil.com", "closing_agent_contact_person_phone": "2325553737", "hoa_fees_YN": "on", "hoa_term_value": "3", "hoa_fees": "10800", "hoa_approval_duration": "30 days", "hoa_ages_old_enough_YN": "N", "realtor_at_appraisal_YN": "N", "realtor_made_supportive_CMA_YN": "Y", "realtor_has_copy_CMA_report_YN": "Y", "realtor_confirms_utilities_on_YN": "N", "realtor_will_provide_copy_old_survey_YN": "N", "realtor_will_inform_lender_sellers_abscence_YN": "N", "realtor_confirms_last_title_trans_gt_90_days_YN": "N", "realtor_confirms_seller_pay_trans_tax_YN": "Y", "realtor_confirms_seller_pay_pick_title_YN": "Y", "realtor_confirms_lenders_no_control_apprs_YN": "N", "sa_realtor_at_appraisal_YN": "N", "sa_realtor_made_supportive_CMA_YN": "Y", "sa_realtor_has_copy_CMA_report_YN": "Y", "sa_realtor_confirms_utilities_on_YN": "Y", "sa_realtor_will_provide_copy_old_survey_YN": "N", "sa_realtor_will_inform_lender_sellers_abscence_YN": "N", "sa_realtor_confirms_last_title_trans_gt_90_days_YN": "N", "sa_realtor_confirms_seller_pay_trans_tax_YN": "N", "sa_realtor_confirms_seller_pay_pick_title_YN": "N", "sa_realtor_confirms_lenders_no_control_apprs_YN": "N", "seller_name": "", "seller_email": "", "seller_phone": "", "seller_address_street": "", "seller_address_city": "", "seller_address_state": "", "seller_address_zip": "", "listing_agent": "", "broker_license_number": "", "listing_agent_email": "", "listing_agent_phone": "", "broker_name": "", "broker_address_street": "", "broker_address_city": "", "broker_address_state": "", "broker_address_zip": "", "agent_create_account_YN": "on", "buying_agent": "Danny LaGuardia", "buying_agent_license_number": "", "buying_agent_email": "dla@htomail.com", "buying_agent_phone": "23434232233", "buying_agent_address_street": "", "buying_agent_address_city": "", "buying_agent_address_state": "", "buying_agent_address_zip": "", "new_account_password": "", "broker_dob": "" } } let structure = { pages : { p1 : { title : "Page1", fields : [{ id : "addr", label : "Address", type : "address", },{ id : "closing_date", label : "Closing Date", type : "date", },{ id : "listed_price", label : "Listed price", type : "num" },{ id : "selling_price", label : "Selling price", type : "num" }] }, p2 : { title : "Page2", fields : [{ id : "first_deposit", label : "First deposit", type : "num" },{ id : "first_deposit_date_due", label : "First deposit due date", type : "date" },{ id : "second_deposit", label : "Second deposit", type : "num" },{ id : "second_deposit_date_due", label : "Second deposit due date", type : "date" }] }, } } let opts = { page : "" }; function _get(k,def) { return MAR.getOpt(da, k , def) } function _set(k,val) { return da[k] = val; } function init() { _new(); setPageByindex(0); } function getPageByField(FIELD) { for (let x in structure.pages) { for (let i=0; i < structure.pages[x].fields.length; i++) { let fld = structure.pages[x].fields[i]; if (fld.id === FIELD) { return x; } } } return false; } function getPageData() { let content = MAR.getOpt(structure.pages, opts.page, false); return content; } function arrayOfPages() { let pages = []; for (let x in structure.pages) pages.push(x); return pages; } function setPageByindex(idx) { let pages = arrayOfPages() if (idx < pages.length) setPage(pages[idx]); } function setPage(p) { if (p in structure.pages) { opts.page = p; } } function getPage() { return opts.page; } function getNextPage() { let pages = arrayOfPages() let idx = pages.indexOf(opts.page); if (idx > -1) idx++; if (idx < pages.length) return pages[idx]; return -1; } function getPreviousPage() { let pages = arrayOfPages() let idx = pages.indexOf(opts.page); if (idx > 0) return pages[idx-1]; return -1; } return { get : _get, set : _set, create : _new, _new : _new, init : init, struct : structure, // getPageData : getPageData, // setPage : setPage, getPage : getPage, getNextPage : getNextPage, getPreviousPage : getPreviousPage, // getPageByField : getPageByField, // ___id : "subject property model" } }) mar.pg["scenario-subjectproperty"] = (function(){ var html = ""; var VAL = ''; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; let existingid = (p3 && p3 != "new" ) ? p3 : false; let action = (p4 && p4 != "" ) ? p4 : ""; let applicantNum = applicantnum+1; var na = getApplicantsNames_v2(applicantnum).Name; var n0 = getApplicantsNames_v2(0).Name; // let itm = (existingid) ? MAR.income.get(applicantnum,"w2",existingid) : false; let revealclass = (existingid) ? "" : "x-hide x-revealdiv"; // reveal .1 let sp = models.subjectproperty(); sp.init(); let type = "index"; let page = ""; let field = ""; if (p3 && p3.length < 4 && p3.startsWith("p")) { page = p3; type = "page"; } if (p3 && p3.length > 3) { let _p = sp.getPageByField(p3); if (_p !== false) { page = _p; type = "page"; field = p3; } } let dbg = `type ${type}, page ${page}, field ${field}`; let h = ""; h += frm.htitle("
    ").render(); h += frm.elaine(`bla bla. ${dbg}`,"er").render(); h += "
    "; h += "
    "; // h += "
    "; // // h += "
    "; //end er h += "
    "; //end er /* end modal content */ h += uihelpers.cbuttonbar("Continue",frm.addfunction(function(){ var val; /** * validation & reveal block start */ let $reveals = $(".x-revealdiv"); if ($reveals.length > 0) { let $elm = $($reveals[0]); let validation = $elm.data("validation"); if (validation) { } $elm.slideDown(function(){ $elm.removeClass("x-hide").removeClass("x-revealdiv"); $("#body-container").scrollTo("max",200); }); return; } /** * validation & reveal block end */ // setScenario_data("__hasvisited_crossroads","Y"); // setScenario_data("__scenario_"+"crossroads"+"_passed","Y"); // mar.fakesave(); // // mvc.goto("#_0300",false); // router }),"Back",frm.addfunction(function(){ // mvc.go("#scenario-mcc"); }),"mar.help()"); h = Mustache.render(h,localopts); let oc = function(type) { } //mar.pg.oc = oc; let or = function(){ // let sp = mar.isallowed_scenario("#scenario-crossroads"); // if (typeof sp === "string") { // mvc.go(sp); // return; // } let $spc = $("#body-container .spcontent"); let $spct = $(".spcontent_title"); if (type === "index") { } else if (type === "page") { sp.setPage(page); let pd = sp.getPageData(); $spct.html(pd.title); if (pd !== false) { let h = ""; let fields = pd.fields; for (let i=0; i < fields.length; i++) { let field = fields[i]; let val = sp.get(field.id) if (field.type === "date") { VAL = val; h += `
    `; if (i > 0) h += frm.hr().render(); h += frm.txt(field.id,field.label,VAL,"","",function(){ oc(); }, "date").render(); h += "
    "; } else if (field.type === "num") { VAL = val; h += `
    `; if (i > 0) h += frm.hr().render(); h += frm.slider(field.id,field.label,VAL,"","",function(){ oc(); }, { v00 : '0', v50 : '200000', v50_inc : '100', v75 : '550000', v75_inc : '2000', v100 : '1500000', v100_inc : '5000', start_val : '2400' }).render(); h += "
    "; } else if (field.type === "address") { h += ""; h += `
    `; if (i > 0) h += frm.hr().render(); h += (function(){ let h = ""; h += "
    "; VAL = val; h += frm.address(field.id,`
    ${field.label}
    `,VAL,"","",function(){ // //oc(); },{}).render() return h; })() h += "
    "; } else { h += `
    `; if (i > 0) h += frm.hr().render(); h += `
  • ${field.id}
  • `; h += `
  • ${field.type}
  • `; h += "
    "; } } $spc.html(h); } } else { } $("#body-container").find(".xx-radio").myradio(); $("#body-container").find(".xx-check").mycheck(); $("#body-container").find(".xx-check3").mycheck3(); $("#body-container").find(".xx-slider").myslider(); $("#body-container ._dollars").inputmask("numeric", { radixPoint: ".", groupSeparator: ",", digits: 2, autoGroup: true, prefix: '$', //No Space, this will truncate the first character rightAlign: false, autoUnmask : true }); if ($("#body-container").find("#addr-disp").length > 0) { uihelpers.addresspopup_init($("#body-container").find("#addr-disp")); } $("#body-container #tel").inputmask("(999) - 999 - 9999", { autoUnmask: true }); $("#body-container #tel").euiInputTel(); $("#body-container .xhuman").Humanize({ opts : {}, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { render : render, section : "property" } })(); /* file /ui/app/js/frederik/pages.finicity.js , last updated 1684764465739*/ mar.pg["scenario-finicity-menu"] = (function(){ var VAL = 'N' var html = ""; var pages_to_verify = []; function render(pg, localopts) { /** * standard starting block - START */ let applicantnum = ("p2" in localopts && localopts.p2 != "") ? parseInt(localopts.p2,10) : 0; let p3 = ("p3" in localopts && localopts.p3 != "" && typeof localopts.p3 != "undefined") ? localopts.p3 : false; let p4 = ("p4" in localopts && localopts.p4 != "" && typeof localopts.p4 != "undefined") ? localopts.p4 : false; let p5 = ("p5" in localopts && localopts.p5 != "" && typeof localopts.p5 != "undefined") ? localopts.p5 : false; var n0 = getApplicantsNames_v2(0).Name; let h = ""; /** this gets data from the app **/ // let use_whatsapp = getScenario_data("use_whatsapp","Y"); /** this allows access even if the app is submitted **/ mar.pg_accesscontrollerfn = function() { return "open"; } /** this is the title */ h += frm.htitle("Connect Accounts").render(); /** this is the Loan officer speach bubble */ h += frm.elaine(`We would like to Connect your accounts`,"er").render(); h += "
    "; /** * Here you can build up the page, or make a div if you want it to dynamically reload */ h += `
    `; h += `
    `; let names = getApplicantsNames_v2(); for (let i=0; i < names.length; i++) { let applicant = names[i]; h += `
    `; h += `
    ${applicant.Name}
    `; h += `
    `; h += `
    `; h += `
    `; } h += `
    `; h += ``; // var VAL = use_whatsapp; // h += frm.yn3("use_whatsapp", `I use Whatsapp
    on ${elaineui.format("tel",___tel)}`,VAL,"","",function(){ // // oc(); // // }, {}).render(); h += "
    "; /** this is the continue button **/ h += uihelpers.cbuttonbar("CONTINUE",frm.addfunction(function(){ // let use_whatsapp = yn3("#use_whatsapp"); // if (use_whatsapp === "") { // mar.tip(".help-button","warning","you need to answer yes or no","top"); // return false; // } // setScenario_data("use_whatsapp",use_whatsapp); // setScenario_data("__scenario_whatsapp_passed","Y"); // mar.answers._events = ["application:whatsapp_selected"]; // mar.fakesave(); // mvc.go("#scenario-timeframe"); /** for the moment lets just reload this page **/ mvc.go("#scenario-finicity-menu"); }),"",frm.addfunction(function(){ }),"mar.help()"); h = Mustache.render(h,localopts); /** on change **/ let oc = function() { } let request_link = function() { } let finicity_send_link_click_fn = function(evt) { } let finicity_click_fn = function(evt) { let $button = $(this); let type = $button.data('type'); let i = $button.data('i'); let ssn = $button.data('ssn'); if (type === "reload") { reload_data(); return; } alert(`click for ${i} , type ${type}, ssn ${ssn}`); } /** reload the data , for instance **/ let reload_data = function() { $("#body-container").LoadingOverlay("show"); /** lets call it via http **/ $.get(`/api/finicity/summary/${mar.ID}`, function(da){ /** and then cal the same thing again via sockets **/ mar.socket.send_and_receive(`/api/finicity/summary/${mar.ID}`, { }, function(da1) { console.error(da,da1); debugger; $(`#finicity-header-div`).html(new Date()); let data = MAR.getOpt(da1, "data"); let names = MAR.getOpt(da1, "data.people"); for (let i=0; i < names.length; i++) { let applicant = names[i]; let $div = $(`#applicant-${i}-div`); let $ssn_div = $div.find(`.x-ssn`); let $name_div = $div.find(`.x-name`); let $action_div = $div.find(`.x-action`); $ssn_div.html(applicant.ssn); $name_div.css({ color : `#00cc00` }); if (applicant.has_oauth === true) { $action_div.html(``) } if (applicant.has_oauth === false) { $action_div.html(` `) } } // $(`#finicity-footer-div`).html(``) $("#body-container").find(`.x-finicity-button`).click(finicity_click_fn) $("#body-container").find(`.x-finicity-button-connect`).click(finicity_send_link_click_fn) $("#body-container").LoadingOverlay("hide",true); }, 20000); }); } /** make a realtime event **/ /** * mosquitto_pub -t "/ps2/app/3838/reload_finicity_data" -m "{\"applicationid\":3838}" * * or * * mqt.send(`/ps2/app/${appid}/reload_finicity_data`, { applicationid : appid, }); */ mar.rt_events.app_reload_finicity_data = function(data) { /** only execute if this page is actually displayed **/ if ($(`#finicity-header-div`).length === 0) return; if (`${MAR.getOpt(data, "applicationid","")}` === `${mar.ID}`) { reload_data(); } } /** on render page **/ let or = function(){ /** are we from the LOI **/ if (mar.WE_ARE_FROM_LOI === true) { // mvc.go("#scenario-timeframe"); // return; } /** make all the elements come to life **/ $("#body-container").find(".xx-radio").myradio(); $("#body-container .xx-check").mycheck(); $("#body-container .xx-check3").mycheck3(); /** animate the speech bubble **/ $("#body-container .xhuman").Humanize({ opts : { fn : function() { $("#body-container").scrollTo("max",200); /** now we can start **/ reload_data(); } }, quick : false }); } pg.hh = h; pg.render = true; pg.onrender = or; pg.title = "Home" } return { section : "general", render : render } })(); /* file /ui/app/js/utils.screenshots.js , last updated 1550182297797*/ if ("utils" in mar == false) mar.utils = {}; mar.utils.screenshots = (function(){ function getScreenshotOfElement(element, posX, posY, width, height, callback) { html2canvas(element, { onrendered: function (canvas) { var context = canvas.getContext('2d'); var imageData = context.getImageData(posX, posY, width, height).data; var outputCanvas = document.createElement('canvas'); var outputContext = outputCanvas.getContext('2d'); outputCanvas.width = width; outputCanvas.height = height; var idata = outputContext.createImageData(width, height); idata.data.set(imageData); outputContext.putImageData(idata, 0, 0); callback(outputCanvas.toDataURL().replace("data:image/png;base64,", "")); }, width: width, height: height, useCORS: true, taintTest: false, allowTaint: false }); } function take(elm,fn) { // html2canvas($(elm),{logging : true}).then(function(canvas) { // theCanvas = canvas; // canvas.toBlob(function(blob) { // $.ajax({ // url: '/api/consents/upload', // type: 'POST', // data : { // sc : blob // }, // success: function(response) { // fn(blob); // } // }); //// saveAs(blob, "Dashboard.png"); // }); // }); // return; // debugger; html2canvas($(elm)[0], { onrendered: function(canvas) { theCanvas = canvas; canvas.toBlob(function(blob) { $.ajax({ url: '/api/consents/upload', type: 'POST', data : { sc : blob }, success: function(response) { fn(blob); } }); // saveAs(blob, "Dashboard.png"); }); } }); } return { getScreenshotOfElement : getScreenshotOfElement, take : take, ____id : "screenshots" } })() /* file /ui/js/inc/100_pinch_zoom.js , last updated 1705971526770*/ mar.pinch_zoom = (function(){ function addCSS() { if ($(`#pinch_zoomer_css`).length > 0) return; $("body").append(``); } function add(elm) { let elms = $(elm); for (let i=0; i < elms.length; i++) { let elm = elms[i]; addto($(elm)); } } function addto($elm) { /** * prevent double calling */ console.error("JC docwin_mid_pinch_zoom add - START"); if ($elm.hasClass(`x-pinchzoom-added`)) return; $elm.addClass(`x-pinchzoom-added`); mar.pinch_zoom /** * make the wrapper */ $elm.wrap(`
    `); /** * add the css if not there */ addCSS(); /** * Add an ID if there is none */ let id = $elm.prop("id"); if (id === "") { id = `pz_gen_${new Date().getTime()}`; $elm.prop("id",id); } /** * Add pinch zoomer */ $elm.on('inview', function(event, isInView) { console.error(`JC docwin_mid_pinch_zoom add - INVIEW ${id}`); if ($elm === false) return; while ( PinchZoomer.get(id) !== null) { PinchZoomer.remove(id); } $elm.pinchzoomer({ maxZoom : 5, minZoom : 0.5, scaleMode : "smart", //"smart", //"widthOnly", initX : 0, initY : 0, zoomPointY : 0, // zoom at top preloaderUrl : "/assets/preloader.gif", appendControlHolder : true, appendControls : true, allowMouseWheelScroll : true, allowMouseWheelZoom : false, allowZoom : true, allowDrag : true }, true); /** * click */ // $elm.click(mar.pinch_zoom.click_fn); /** * zoom */ var pzo = PinchZoomer.get(id); pzo.on(PinchZoomer.FULLSCREEN_TOGGLE, mar.pinch_zoom.click_fn); pzo.on(PinchZoomer.ELEM_CHANGE, mar.pinch_zoom.event_fn); pzo.on(PinchZoomer.LOAD_COMPLETE, mar.pinch_zoom.event_fn); pzo.on(PinchZoomer.ZOOM, mar.pinch_zoom.event_fn); $elm.addClass(`x-pinchzoom-added-fully`); $elm.on("load",function(a,b){ // debugger; resize_one(this) // resize(); }) $elm = false; }); console.error("JC docwin_mid_pinch_zoom add - END"); } let resize_one = function(elm) { let $elm = $(elm); let $parent = $elm.parent(); let h = $parent.height(); let w = $parent.width(); let nat_w = $elm[0].naturalWidth; let nat_h = $elm[0].naturalHeight; let echo = $elm.data("echo"); let rotated = (typeof echo === "string" && (echo.indexOf("r270") > -1 || echo.indexOf("r90") > -1)); if (rotated) { // nat_h = $elm[0].naturalWidth; // nat_w = $elm[0].naturalHeight; } let new_h = (num(w) / num(nat_w)) * num(nat_h) let id = $elm[0].id; $parent.css({ // maxHeight : `${h}px`, height : `${~~(new_h)+20}px` }); let pzo = PinchZoomer.get(id); // pzo.resetElem(); pzo.zoom(1); pzo.zoomToCenter(); console.error(`pzo resized ONE ${id}`); } let resize = _.throttle(function(nosecond = false) { let elms = $(`.x-pinchzoom-added-fully`); for (let i=0; i < elms.length; i++) { let $elm = $(elms[i]); let $parent = $elm.parent(); let h = $parent.height(); let w = $parent.width(); let nat_w = $elm[0].naturalWidth; let nat_h = $elm[0].naturalHeight; let echo = $elm.data("echo"); let rotated = (typeof echo === "string" && (echo.indexOf("r270") > -1 || echo.indexOf("r90") > -1)); if (rotated) { // nat_h = $elm[0].naturalWidth; // nat_w = $elm[0].naturalHeight; } let new_h = (num(w) / num(nat_w)) * num(nat_h) let id = $elm[0].id; $parent.css({ // maxHeight : `${h}px`, height : `${~~(new_h)+20}px` }); let pzo = PinchZoomer.get(id); //pzo.resetElem(); pzo.zoom(1); pzo.zoomToCenter(); console.error(`pzo resized ${i} ${id} ${nosecond}`) if (!nosecond) { setTimeout(function(){ resize(true); },200); } } },500, { leading : true, trailing : true }); /** * click handler */ function click_fn(e){ let $elm = $(this); let id = $elm.prop("id"); let pzo = PinchZoomer.get(id); let fs = pzo.fullscreen(); if (!fs) { pzo.fullscreen(true); } } /** * event handler */ function event_fn(e){ if (e.type === "loadcomplete") { resize(); } if (e.type === "resize") { console.error(`pzo resized`,e) } //console.error(`PZO event ${e.type}`,e); } /** * zoom handler */ function fullscreen_fn(e) { //console.error(e); let fs = e.currentTarget.fullscreen(); if (fs) { e.currentTarget.vars({ allowZoom : true, allowDrag : true }); } else { e.currentTarget.resetElem(true); e.currentTarget.zoom(0.3); e.currentTarget.vars({ allowZoom : false, allowDrag : false }); } } return { add : add, addto : addto, click_fn : click_fn, event_fn : event_fn, fullscreen_fn : fullscreen_fn, resize : resize, ___id : "100_pinch_zoom" } })(); /* file /ui/app/js/inc/100.rq.js , last updated 1701297372162*/ mar.tmp_extract_reason_stub_from_loan = function(da) { let ob = {}; ob.status = MAR.getOpt(da, "status"); ob.statusM = MAR.getOpt(da, "statusMsg"); ob.c_status = MAR.getOpt(da, "calc.status"); ob.c_status_c2c = MAR.getOpt(da, "calc.status_c2c"); ob.c_status_qm = MAR.getOpt(da, "calc.status_qm"); ob.c_txt1 = MAR.getOpt(da, "calc.txt1"); ob.c_max_loan = MAR.getOpt(da, "calc.max_loan"); ob.c_grid_max_loan = MAR.getOpt(da, "calc.grid_max_loan"); ob.d_status = MAR.getOpt(da, "data.status"); ob.d_statusM = MAR.getOpt(da, "data.statusMsg"); return ob; } mar.tmp_extract_reason_stub_from_agreed_rate = function(da) { let ob = {}; ob.status = MAR.getOpt(da, "status"); ob.statusM = MAR.getOpt(da, "statusMsg"); ob.c_status = MAR.getOpt(da, "data.status"); ob.c_status_c2c = MAR.getOpt(da, "data.status_c2c"); ob.c_status_qm = MAR.getOpt(da, "data.status_qm"); ob.c_txt1 = MAR.getOpt(da, "data.txt1"); ob.c_max_loan = MAR.getOpt(da, "data.max_loan"); ob.c_grid_max_loan = MAR.getOpt(da, "data.grid_max_loan"); ob.d_status = MAR.getOpt(da, "data.gp.status"); ob.d_statusM = MAR.getOpt(da, "data.gp.statusMsg"); return ob; } /** * We start with a structure like this * { "status": -1, "statusM": "Error - cannot calculate the rate", "c_status": -10, "c_status_c2c": 0, "c_status_qm": 0, "c_txt1": [ "We could not reach 2000 cash back for this, the best we could do was $0 " ], "c_max_loan": 0, "c_grid_max_loan": false, "d_status": -1, "d_statusM": "The credit score of 567 is below the minimum creditscore of 580" } */ mar.tmp_decide_what_is_the_most_likely_cause_of_failure_for_offer = function(da) { if (da.c_grid_max_loan === false) { /** * we did not get a response fro the grid */ if (typeof da.d_statusM === `string` && da.d_statusM.indexOf(`credit score`) > -1) { return { r : `GRID-CS`, m : da.d_statusM }; } return { r : `GRID`, m : da.d_statusM }; } if (da.c_status_qm < 0) { return { r : `QM`, m : `QM Failure` }; } if (da.c_status_c2c < 0) { return { r : `C2C`, m : da.c_txt1.join(`, `) }; } if (da.c_status === -10 ) { return { r : `C2C`, m : da.c_txt1.join(`, `) }; } if (typeof da.c_txt1 !== 'undefined') { return { r : `OTHER`, m : da.c_txt1.join(`, `) }; } return { r : `OTHER`, m : da.statusM }; } /* end */