From 6a298239e08f8bd8fd4567c42233a58e393cba9a Mon Sep 17 00:00:00 2001 From: Adarsh Date: Tue, 27 Jun 2017 14:43:07 -0400 Subject: [PATCH 01/13] Make fields in customer preference blank and null is true. --- blocnote/apps/financialInputs/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blocnote/apps/financialInputs/models.py b/blocnote/apps/financialInputs/models.py index 7a994e3..8f572ae 100644 --- a/blocnote/apps/financialInputs/models.py +++ b/blocnote/apps/financialInputs/models.py @@ -68,9 +68,9 @@ class CustomerPreference(models.Model): """Store customer preferences on payment.""" building_id = models.IntegerField() - downpayment = models.DecimalField(max_digits=10, decimal_places=2) - expected_payback = models.DecimalField(max_digits=3, decimal_places=0) - expected_net_noi_dscr = models.DecimalField(max_digits=5, decimal_places=2) + downpayment = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True) + expected_payback = models.DecimalField(max_digits=3, decimal_places=0, blank=True, null=True) + expected_net_noi_dscr = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True) class Liabilities(models.Model): -- GitLab From bd4e9904fb145b8fa553b0c655fa4626519371d9 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Tue, 27 Jun 2017 14:43:41 -0400 Subject: [PATCH 02/13] Make fields of customer preference not required fields. --- .../static/financialInputs/scripts/customerPreference.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js index d4011be..da5a38f 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js @@ -81,7 +81,7 @@ function createCustomerPreferenceTable(instance) { Affordable Downpayment - +
@@ -89,7 +89,7 @@ function createCustomerPreferenceTable(instance) { Expected Payback - Months + Months
@@ -97,7 +97,7 @@ function createCustomerPreferenceTable(instance) { Expected Net NOI DSCR - +
-- GitLab From 81992ff27ecd2dc5d4e79588651cdb582135143f Mon Sep 17 00:00:00 2001 From: Adarsh Date: Tue, 27 Jun 2017 15:01:12 -0400 Subject: [PATCH 03/13] Display message about leaving field blank if not available. --- .../static/financialInputs/scripts/customerPreference.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js index da5a38f..aaea099 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js @@ -63,6 +63,7 @@ function createCustomerPreferenceTable(instance) { let downpayment = 0; let expectedPayback = 999; let expectedNetNOIDSCR = 1.15; + const msg = '(If value is not known, please leave it blank)'; if (instance) { downpayment = instance['downpayment']; @@ -74,7 +75,7 @@ function createCustomerPreferenceTable(instance) { Preference - Value + Value ${msg} -- GitLab From d902812005b684b399a6b86fee3e765fbb776211 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Tue, 27 Jun 2017 15:07:33 -0400 Subject: [PATCH 04/13] Make sure that in the frontend empty string is replayed with null before sending request to the backend. --- .../static/financialInputs/scripts/customerPreference.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js index aaea099..aabf0a8 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js @@ -24,7 +24,11 @@ function customerPreferenceForm(form) { const formData = new FormData(form); let result = {}; for (const [key, value] of formData.entries()) { - result[key] = value; + if (value == '') { + result[key] = null; + } else { + result[key] = value; + } } request('customer-preference/', { method: 'PUT', -- GitLab From 56a58c393df1fd3749e833e0b01c3d46d96cd423 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Tue, 27 Jun 2017 15:08:24 -0400 Subject: [PATCH 05/13] Add migration file that modifies customer preference model fields to be allowed blank and null or both. --- .../migrations/0006_auto_20170627_1902.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 blocnote/apps/financialInputs/migrations/0006_auto_20170627_1902.py diff --git a/blocnote/apps/financialInputs/migrations/0006_auto_20170627_1902.py b/blocnote/apps/financialInputs/migrations/0006_auto_20170627_1902.py new file mode 100644 index 0000000..8bb344d --- /dev/null +++ b/blocnote/apps/financialInputs/migrations/0006_auto_20170627_1902.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.6 on 2017-06-27 19:02 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('financialInputs', '0005_auto_20170522_1842'), + ] + + operations = [ + migrations.AlterField( + model_name='customerpreference', + name='downpayment', + field=models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True), + ), + migrations.AlterField( + model_name='customerpreference', + name='expected_net_noi_dscr', + field=models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True), + ), + migrations.AlterField( + model_name='customerpreference', + name='expected_payback', + field=models.DecimalField(blank=True, decimal_places=0, max_digits=3, null=True), + ), + ] -- GitLab From ef9a342d5868e20ec9e0621e2658e5fedd1bd7e1 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Tue, 27 Jun 2017 17:15:02 -0400 Subject: [PATCH 06/13] Modify get_customer_preference function to have None as values is no values is present in the database. --- blocnote/lib/fetch_data.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/blocnote/lib/fetch_data.py b/blocnote/lib/fetch_data.py index b04ad2a..eddd173 100644 --- a/blocnote/lib/fetch_data.py +++ b/blocnote/lib/fetch_data.py @@ -124,9 +124,12 @@ def get_customer_preference(building_id): customer_preference_object = CustomerPreference.objects.filter(building_id=building_id) if customer_preference_object: customer_preference = { - 'downpayment_max': float(customer_preference_object[0].downpayment), - 'expected_payback': int(customer_preference_object[0].expected_payback), - 'cust_saving_dscr': float(customer_preference_object[0].expected_net_noi_dscr), + 'downpayment_max': (float(customer_preference_object[0].downpayment) if + customer_preference_object[0].downpayment else None), + 'expected_payback': (int(customer_preference_object[0].expected_payback) if + customer_preference_object[0].expected_payback else None), + 'cust_saving_dscr': (float(customer_preference_object[0].expected_net_noi_dscr) if + customer_preference_object[0].expected_net_noi_dscr else None), } return customer_preference -- GitLab From 47499fce4db10d0cce1afd645dd58411bbebf312 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Thu, 29 Jun 2017 11:15:48 -0400 Subject: [PATCH 07/13] Remove unnecessary conditions for budget simulator . --- blocnote/apps/budgetSimulator/views.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/blocnote/apps/budgetSimulator/views.py b/blocnote/apps/budgetSimulator/views.py index 2dddb39..62eeb25 100644 --- a/blocnote/apps/budgetSimulator/views.py +++ b/blocnote/apps/budgetSimulator/views.py @@ -67,14 +67,8 @@ class Budget(View): err_var_list.append('Anticipated commissioning date') if not customer_preference: err_var_list.append('Customer preference') - if not raw_income_statement: - err_var_list.append('Income statements') if not growth_rate: err_var_list.append('Growth rate') - if not cash_balance: - err_var_list.append('Cash balance') - if not loan_options: - err_var_list.append('Loan options') if err_var_list: err_var = ",".join(err_var_list) return JsonResponse({'error': err_var + 'not filled.'}, status=400) -- GitLab From 3efdd4b71cdfef6f46d72207b7b2313a0f29d3c6 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Thu, 29 Jun 2017 11:16:50 -0400 Subject: [PATCH 08/13] Update index to show different conditions for preliminary finance and budget simulator. --- .../templates/landingPage/index.html | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/blocnote/apps/landingPage/templates/landingPage/index.html b/blocnote/apps/landingPage/templates/landingPage/index.html index a089268..5a3fbd3 100644 --- a/blocnote/apps/landingPage/templates/landingPage/index.html +++ b/blocnote/apps/landingPage/templates/landingPage/index.html @@ -27,13 +27,7 @@ OK - - - Budget Simulator - - OK - - {% else %} + {% else %} Financial Inputs @@ -52,25 +46,34 @@
    - {% for item in not_saved_list %} + {% for item in not_saved_list_for_prelim %}
  • Please fill {{ item }}
  • {% endfor %}
+ {% endif %} + {% if if_completed_for_budget %} + + + Budget Simulator + + OK + + {% else %} Budget Simulator
    - {% for item in not_saved_list %} + {% for item in not_saved_list_for_budget %}
  • Please fill {{ item }}
  • {% endfor %}
- {% endif %} + {% endif %} -- GitLab From 56767e1b63d3eed4a902defb5c0fa1a9cede235e Mon Sep 17 00:00:00 2001 From: Adarsh Date: Thu, 29 Jun 2017 11:18:19 -0400 Subject: [PATCH 09/13] Update landing page backend to check for different set of inputs for budget and preliminary analysis. --- blocnote/apps/landingPage/views.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/blocnote/apps/landingPage/views.py b/blocnote/apps/landingPage/views.py index 0e2608c..668120b 100644 --- a/blocnote/apps/landingPage/views.py +++ b/blocnote/apps/landingPage/views.py @@ -13,7 +13,7 @@ from blocnote.apps.financialInputs.models import LoanOptions class Index(View): """Show the page with the urls for other apps.""" - models = [ + models_for_prelim = [ FinancingOverview, BillsOverview, CustomerPreference, @@ -22,6 +22,11 @@ class Index(View): LoanOptions, ] + models_for_budget = [ + FinancingOverview, + CustomerPreference, + ] + model_names_map = { FinancingOverview: 'Proforma Inputs', BillsOverview: 'Bills Overview', @@ -36,25 +41,35 @@ class Index(View): Display links to the inputs, budget simulation and preliminary and full analysis pages. """ - not_saved_list = self.check_inputs(building_id) + not_saved_list_for_prelim = self.check_inputs(building_id, self.models_for_prelim) + not_saved_list_for_budget = self.check_inputs(building_id, self.models_for_budget) if_completed = True if_started = False - if not_saved_list: + if_completed_for_budget = True + if_started_for_budget = False + if not_saved_list_for_prelim: if_completed = False - if len(not_saved_list) < len(self.models): + if len(not_saved_list_for_prelim) < len(self.models_for_prelim): if_started = True + if not_saved_list_for_budget: + if_completed_for_budget = False + if len(not_saved_list_for_budget) < len(self.models_for_budget): + if_started_for_budget = True context = { 'building_id': building_id, 'if_started': if_started, 'if_completed': if_completed, - 'not_saved_list': not_saved_list, + 'not_saved_list_for_prelim': not_saved_list_for_prelim, + 'not_saved_list_for_budget': not_saved_list_for_budget, + 'if_completed_for_budget': if_completed_for_budget, + 'if_started_for_budget': if_started_for_budget, } return render(request, 'landingPage/index.html', context=context) - def check_inputs(self, building_id): + def check_inputs(self, building_id, model_list): """Check if all inputs have been filled out.""" not_saved = [] - for model in self.models: + for model in model_list: model_object = model.objects.filter(building_id=building_id) if not model_object: not_saved.append(self.model_names_map[model]) -- GitLab From 79f572e1dff9aa21f185de898c564fadb543a76a Mon Sep 17 00:00:00 2001 From: Adarsh Date: Thu, 29 Jun 2017 11:19:00 -0400 Subject: [PATCH 10/13] Update fetch data to return growth rate as -2 as default if no growth rate is present. --- blocnote/lib/fetch_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blocnote/lib/fetch_data.py b/blocnote/lib/fetch_data.py index eddd173..36f093d 100644 --- a/blocnote/lib/fetch_data.py +++ b/blocnote/lib/fetch_data.py @@ -211,7 +211,7 @@ def get_growth_rate(building_id): growth_rate (float): growth rate selected for the building id to project income statement. """ growth_rate_object = GrowthRate.objects.filter(building_id=building_id) - growth_rate = None + growth_rate = -2 if growth_rate_object: growth_rate = float(growth_rate_object[0].growth_rate) - return growth_rate + return growth_rate -- GitLab From 2f34686a181ded0a12687d8bb1b2b7514b66cbe1 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Thu, 29 Jun 2017 16:33:48 -0400 Subject: [PATCH 11/13] Change logic to store customer preference value as null or value. --- .../static/financialInputs/scripts/customerPreference.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js index aabf0a8..d8982a4 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js @@ -24,11 +24,7 @@ function customerPreferenceForm(form) { const formData = new FormData(form); let result = {}; for (const [key, value] of formData.entries()) { - if (value == '') { - result[key] = null; - } else { - result[key] = value; - } + result[key] = value ? value : null; } request('customer-preference/', { method: 'PUT', -- GitLab From 9ce9a5035c2253e7699a757d8b4816d7a3aa6cd5 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Thu, 29 Jun 2017 16:41:37 -0400 Subject: [PATCH 12/13] Update logic in landing page backend to have fewer lines. --- blocnote/apps/landingPage/views.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/blocnote/apps/landingPage/views.py b/blocnote/apps/landingPage/views.py index 668120b..9ffe828 100644 --- a/blocnote/apps/landingPage/views.py +++ b/blocnote/apps/landingPage/views.py @@ -43,18 +43,10 @@ class Index(View): """ not_saved_list_for_prelim = self.check_inputs(building_id, self.models_for_prelim) not_saved_list_for_budget = self.check_inputs(building_id, self.models_for_budget) - if_completed = True - if_started = False - if_completed_for_budget = True - if_started_for_budget = False - if not_saved_list_for_prelim: - if_completed = False - if len(not_saved_list_for_prelim) < len(self.models_for_prelim): - if_started = True - if not_saved_list_for_budget: - if_completed_for_budget = False - if len(not_saved_list_for_budget) < len(self.models_for_budget): - if_started_for_budget = True + if_completed = not not_saved_list_for_prelim + if_started = len(not_saved_list_for_prelim) < len(self.models_for_prelim) + if_completed_for_budget = not not_saved_list_for_budget + if_started_for_budget = len(not_saved_list_for_budget) < len(self.models_for_budget) context = { 'building_id': building_id, 'if_started': if_started, -- GitLab From 4249d40d4292b88cd30b7fa047fd7ba3cc8b9232 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Thu, 6 Jul 2017 09:24:08 -0400 Subject: [PATCH 13/13] Remove default values from customer service forms. --- .../static/financialInputs/scripts/customerPreference.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js index d8982a4..eea84c0 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js @@ -60,9 +60,9 @@ function customerPreferenceForm(form) { */ function createCustomerPreferenceTable(instance) { let customerPreferenceForm = document.querySelector('#Customer-Preference'); - let downpayment = 0; - let expectedPayback = 999; - let expectedNetNOIDSCR = 1.15; + let downpayment = ''; + let expectedPayback = ''; + let expectedNetNOIDSCR = ''; const msg = '(If value is not known, please leave it blank)'; if (instance) { -- GitLab