";
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 += `
`+$("#"+this.data.icon).html()+`
`;
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+"
";
//
//
// }
}
}
} 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 += `
";
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 += "
";
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(`
";
}
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 += "
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 += "
";
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 = 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 += "
"; //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 += "
";
/* 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 += "
";
$("._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 += "
";
/* 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 += "
";
$("#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 += "";
}
if (mmrlin[0] == "fbg") { // green/white rounded corners
h += "";
}
if (mmrlin[0] == "dt") { // yellow/white rounded corners
h += "";
}
}
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 += "
";
// 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 += "
";
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 += "
`;
// 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 += `
";
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 += "
";//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 += "
";
h += frm.radio("crossroads1","I want:",VAL,"","",function(){
oc(1);
},{
personal : "A personal loan calculation ∨"
}).render();
h +="
Faster route: get a personalized well estimated, maximum loan calculation. Still unclear?
CALL NOW
";
h += frm.radio("crossroads2","",VAL,"","",function(){
oc(2);
},{
rough : "A rough estimate ∨"
}).render();
h +="
The anonymous quick fix. Get a general idea of what you can buy without anyone nosing in your personal business (YET)! This adds 4 minutes to your loan application. Still unclear?
CALL NOW
";
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("
" +
"" +
"" +
"
%s %s
" +
"
%s
" +
"
" +
"
%s
" +
"
",lin[1],lin22,dollarsEditable(lin[3],dataid),aprbutton);
}
if (lin[0] == "main") {
var lin22 = sprintf("%s",lin[2]);
costs_tab += sprintf("
" +
"
%s %s
" +
"
%s
" +
"
" +
"
%s
" +
"
",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("
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.
";
costs_tab += "
";
h = "
"+costs_tab+"
";
return h;
}
function ttt(m) {
let tt = "";
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}
`;
tt += "
";
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 += makecsttable(pdo.coststab);
h += " ";
h += " ";
h += " ";
h += ttt(pdo.filters);
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 = `
Upload
Skip
 
${h}
`;
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 : `
`;
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 += `
`,
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.
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.
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)}
`);
$(`#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?
");
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?
");
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 += "
");
///
// 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?
");
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?
");
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 += "
");
// 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 += "
");
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.
";
}
$("#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 += `
`;
}
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 +
`
`+
`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 = `
`;//`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 += 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 += `
`;
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 += `
`;
/**
* 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 += `
`)
$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 += ``;
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 += `
Total monthly payment
${elaineui.format("cur",da.calc.monthly_total)}
`;
h += `
${c2c_lbl}
${elaineui.format("cur",da.calc.total_costs)}
`;
h += `
Rate (30 year fixed)
${elaineui.format("perc3",da.calc.base)}
`;
h += `
APR
${elaineui.format("perc3",da.calc.apr)}
`;
if (mar.pg_tmp_am_i_the_lo() === true && MAR.getOpt(da.calc, "status_qm", 0) < 0) {
h += `
QM FAILED! Reduce points/fees below 3%
${elaineui.format("perc3",da.calc.status_qm_pts)}
`;
}
h += `
`;
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 += "
`;
// 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
";//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 +="
" +
`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:
`);
//
// 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 += `
`;
//
// 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 += `
Total monthly payment
${elaineui.format("cur",da.calc.monthly_total)}
`;
h += `
${c2c_lbl}
${elaineui.format("cur",da.calc.total_costs)}
`;
h += `
Rate (30 year fixed)
${elaineui.format("perc3",da.calc.base)}
`;
h += `
APR
${elaineui.format("perc3",da.calc.apr)}
`;
h += `
`;
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 += `
`;
}
}
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 += `
`;
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)}`] = `
`
}
// 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 += "
";
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?
"; // 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 += `
`;
$(`#_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 ` +
// `
";
// $("#_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 += "
";
/* 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: " +
"
" +
"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 += `
`;
$(`#_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 ` +
// `
";
$(`#_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").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",
"--" : "
"; // 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 += "
" +
$("#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.
";
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 += `
`; // 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+"
";
//
//
// }
}
}
} 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 += ``;
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("
";//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 += "
"+$("#"+this.data.icon).html()+"
";
}
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 += `
"+$("#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 += "
";
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 += "
";
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 += "
";
} 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 += "
"+$("#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 += "
";
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 += 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 += "
"; // 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 += `
"
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 += `
"
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 += `
"
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 += `
"; // 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 += "
"; // 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 - 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}?
");
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 += "
"; // 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 += `
");
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 += "
";
/*
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}
"; // 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 += "
"; // 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 += "
"; // 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 += (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 - 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 += "
"; // 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 += "
"; // 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 += "
";
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 += "
"+getIcon(this.data.assetIcon)+"
";
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 += "
"+getIcon(this.data.assetIcon)+"
";
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 += "
"+getIcon(this.data.assetIcon)+"
";
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 += "
"+getIcon(this.data.assetIcon)+"
";
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 += "
"+getIcon(this.data.assetIcon)+"
";
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 += "
"+getIcon(this.data.assetIcon)+"
";
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 += "
"+getIcon(this.data.assetIcon)+"
";
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 += "
"+getIcon(this.data.assetIcon)+"
";
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 += "
"+getIcon(this.data.assetIcon)+"
";
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 += "
"+getIcon(this.data.assetIcon)+"
";
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 = "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?
"; // 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_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 += "
"+img+"
";//
";
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("
";//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 += "
"+img+"
";//
";
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("
";//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 += "
"+$("#svg_"+chosenBank.id+"_assets").html()+"
";
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
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
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";
VAL = (itm && itm.whose_name.indexOf(99)> -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
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
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
"; // 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";
VAL = (itm && VAL.indexOf(99)> -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
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
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";
VAL = (itm && itm.whose_name.indexOf(99)> -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
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
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";
VAL = (itm && VAL.indexOf(99)> -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
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
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";
VAL = (itm && VAL.indexOf(99)> -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
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
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";
VAL = (itm && VAL.indexOf(99)> -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
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
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
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
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";
VAL = (itm && VAL.indexOf(99)> -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
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
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
"; // 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";
VAL = (itm && VAL.indexOf(99)> -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
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
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";
VAL = (itm && VAL.indexOf(99)> -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
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
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";
VAL = (itm && VAL.indexOf(99)> -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 += "
";
} 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 += "
"; // 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 += "
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 = `
${_logo}
${_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 += "
";
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 += `
${$("#"+data.assetIcon).html()}
`;
h += `
${icon}
`;
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 += `
`;
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(`
";
/* 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: "+
" "+
" "+
"
"+
" "+
"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()+
"
"+
" "+
"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?
"; // 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 += "
" // 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 += "
About us
";
hh += "
";
hh += "
";
hh += "
";
hh += "
";
hh += "
FAQ's
";
hh += "
";
hh += "
";
hh += " ";
hh += "
";
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 += "