diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 83a9488399e1b7f15a5e93c3e1af4590e2e51349..e4aa613f378f98d83e83042c39d177f8dca1bdc3 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -1,4 +1,10 @@ -utilities = ['electricity', 'gas', 'oil', 'water']; +const utilities = ['electricity', 'gas', 'oil', 'water']; +var today = new Date(); +const todaysDate = { + 'day': today.getDate(), + 'month': today.getMonth()+1, + 'year': today.getFullYear(), +} for (var utility_index in utilities) { loadInitialBillsTable(utilities[utility_index]); } @@ -8,6 +14,17 @@ getCustomerPreferenceTable(); getLiabilitiesTable(); getCashBalanceForm(); +var fund = document.querySelector('#id_fund'); +fund.onmouseenter = function() { + var errorDiv = document.querySelector('#show-error'); + errorDiv.innerHTML = `Changing fund will affect loan options`; +} + +fund.onmouseleave = function() { + var errorDiv = document.querySelector('#show-error'); + errorDiv.innerHTML = ""; +} + /** * Handle submition of the header form. Validate commissioning date is greater * than construction start date. Create result dictionary containing the form @@ -17,7 +34,23 @@ getCashBalanceForm(); */ function billProjectionDatesForm(form) { const formData = new FormData(form); - var validDate = validateDate(formData); + var anticipatedConstructionStartYear = formData.get('anticipated_construction_start_date_year'); + var anticipatedConstructionStartMonth = formData.get('anticipated_construction_start_date_month'); + var anticipatedConstructionStartDay = formData.get('anticipated_construction_start_date_day'); + var anticipatedCommissioningStartYear = formData.get('anticipated_commissioning_date_year'); + var anticipatedCommissioningStartMonth = formData.get('anticipated_commissioning_date_month'); + var anticipatedCommissioningStartDay = formData.get('anticipated_commissioning_date_day'); + var anticipatedConstructionStarDate = { + 'day': anticipatedConstructionStartDay, + 'month': anticipatedConstructionStartMonth, + 'year': anticipatedConstructionStartYear, + } + var anticipatedCommissioningDate = { + 'day': anticipatedCommissioningStartDay, + 'month': anticipatedCommissioningStartMonth, + 'year': anticipatedCommissioningStartYear, + } + var validDate = validateDate(anticipatedConstructionStarDate, anticipatedCommissioningDate); if (!validDate) { alert("Anticipated Commissioning date has to be after Anticipated Construction start date"); } @@ -40,13 +73,13 @@ function billProjectionDatesForm(form) { } /** Validate that commissioning date is after the construction start date. */ -function validateDate(data) { - var startDateYear = data.get('anticipated_construction_start_date_year'); - var startDateMonth = data.get('anticipated_construction_start_date_month'); - var startDateDay = data.get('anticipated_construction_start_date_day'); - var endDateYear = data.get('anticipated_commissioning_date_year'); - var endDateMonth = data.get('anticipated_commissioning_date_month'); - var endDateDay = data.get('anticipated_commissioning_date_day'); +function validateDate(startDate, endDate) { + var startDateYear = startDate.year; + var startDateMonth = startDate.month; + var startDateDay = startDate.day; + var endDateYear = endDate.year + var endDateMonth = endDate.month; + var endDateDay = endDate.day; if (endDateYear < startDateYear) { return false; } @@ -170,12 +203,6 @@ function createEstimateModelForm() { return estimateModelForm; } -/** Create form tag Energy Bills Overview */ -function startBillsOverviewForm() { - var text = `