Skip to content

Instantly share code, notes, and snippets.

@contolini
Last active August 29, 2015 14:03
Show Gist options
  • Save contolini/7d4f8717cb0cdb1144e7 to your computer and use it in GitHub Desktop.
Save contolini/7d4f8717cb0cdb1144e7 to your computer and use it in GitHub Desktop.
jumbo loan logic
// This is extremely un-DRY pseudo code
$( loan_amount, loan_type ).on('change', function(){
// Jumbo loans
if ( loan_type == 'conf' && loan_amount >= $417,000 ) {
$( county_dropdown ).show();
$( county_dropdown ).on('change', function(){
max_gse_loan_amount_for_selected_county = $( county_dropdown ).val().data('gse');
if ( loan_amount <= max_gse_loan_amount_for_selected_county ) {
$( loan_type ).val('agency'); // Conforming Jumbo
$( message ).text('When you borrow between $417,000 and X in your county, you are eligible for a conforming jumbo loan.');
return;
}
if ( loan_amount > max_gse_loan_amount_for_selected_county ) {
$( loan_type ).val('jumbo'); // Jumbo
$( message ).text('When you borrow more than X in your county, the only loan type available to you is a jumbo (non-conforming) loan.');
return;
}
});
}
// FHA jumbo loans
if ( loan_type == 'fha' && loan_amount >= $271,050 ) {
$( county_dropdown ).show();
$( county_dropdown ).on('change', function(){
max_gse_loan_amount_for_selected_county = $( county_dropdown ).val().data('gse');
max_fha_loan_amount_for_selected_county = $( county_dropdown ).val().data('fha');
if ( loan_amount <= max_fha_loan_amount_for_selected_county ) {
$( loan_type ).val('fha-hb');
$( message ).text('When you borrow between $271,050 and X in your county, you are eligible for a high-balance FHA loan.');
return;
}
if ( loan_amount > max_fha_loan_amount_for_selected_county && loan_amount <= $417,000 ) {
$( loan_type ).val('conf');
$( message ).text('You are not eligible for an FHA loan when you borrow more than X in your county. You are eligible for a conventional loan.');
return;
}
if ( loan_amount > $417,000 && loan_amount <= max_gse_loan_amount_for_selected_county ) {
$( loan_type ).val('agency');
$( message ).text('You are not eligible for an FHA loan when you borrow more than X in your county. You are eligible for a conforming jumbo loan.');
return;
}
if ( loan_amount > $417,000 && loan_amount > max_gse_loan_amount_for_selected_county ) {
$( loan_type ).val('jumbo');
$( message ).text('You are not eligible for an FHA loan when you borrow more than X in your county. The only loan type available to you at this loan amount is a jumbo (non-conforming) loan.');
return;
}
});
}
// VA jumbo loans
if ( loan_type == 'va' && loan_amount >= $417,000 ) {
$( county_dropdown ).show();
$( message ).text('Based on your loan amount, you may not be eligible for a regular VA loan. Please enter your county so we can find the right loan type for you and get you the most accurate rates.');
$( county_dropdown ).on('change', function(){
max_gse_loan_amount_for_selected_county = $( county_dropdown ).val().data('gse');
max_va_loan_amount_for_selected_county = $( county_dropdown ).val().data('va');
if ( loan_amount > $417,000 && loan_amount < max_va_loan_amount_for_selected_county ) {
$( loan_type ).val('va-hb');
$( message ).text('When you borrow between $417,000 and X your county, you may be eligible for a high-balance VA loan.');
return;
}
if ( loan_amount > max_va_loan_amount_for_selected_county && loan_amount < max_gse_loan_amount_for_selected_county ) {
$( loan_type ).val('agency');
$( message ).text('While VA loans do not have strict loan limits, most lenders are unlikely to make a VA loan more than X in your county. Your only option may be a conforming jumbo loan.');
return;
}
if ( loan_amount > max_gse_loan_amount_for_selected_county ) {
$( loan_type ).val('jumbo');
$( message ).text('While VA loans do not have strict loan limits, most lenders are unlikely to make a VA loan more than X in your county. Your only option may be a jumbo (non-conforming) loan.');
return;
}
});
}
});
@contolini
Copy link
Author

@ascott1 here's the logic for jumbo loans. I'll modularize the code that currently exists and move it into a separate file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment