diff --git a/blocnote/apps/budgetSimulator/views.py b/blocnote/apps/budgetSimulator/views.py index 2dddb394a082e27e8b5dba7ea5c444383f21e7c6..62eeb252642ef4af830f0d7896bdc43eb7bc1fcf 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) 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 0000000000000000000000000000000000000000..8bb344d120920e685b1287dfcfc946716efdc831 --- /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), + ), + ] diff --git a/blocnote/apps/financialInputs/models.py b/blocnote/apps/financialInputs/models.py index 7a994e3cd140fc005bbd8bad6e2ab529bde953fa..8f572ae749a69a8f8fd8a1fdf3d1a262bd92038e 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): diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js index d4011be5f8ef6138508be8dba8f92527603f88ac..eea84c0e9874bb37454f09df3d50539d0dae5f42 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/customerPreference.js @@ -24,7 +24,7 @@ function customerPreferenceForm(form) { const formData = new FormData(form); let result = {}; for (const [key, value] of formData.entries()) { - result[key] = value; + result[key] = value ? value : null; } request('customer-preference/', { method: 'PUT', @@ -60,9 +60,10 @@ 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) { downpayment = instance['downpayment']; @@ -74,14 +75,14 @@ function createCustomerPreferenceTable(instance) { Preference - Value + Value ${msg} Affordable Downpayment - +
@@ -89,7 +90,7 @@ function createCustomerPreferenceTable(instance) { Expected Payback - Months + Months
@@ -97,7 +98,7 @@ function createCustomerPreferenceTable(instance) { Expected Net NOI DSCR - +
diff --git a/blocnote/apps/landingPage/templates/landingPage/index.html b/blocnote/apps/landingPage/templates/landingPage/index.html index a08926827f1087c97882189b0e1394546d014634..5a3fbd392143a9c6e7a7d1d0bfb0380ba59442ab 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 @@ + {% endif %} + {% if if_completed_for_budget %} + + + Budget Simulator + + OK + + {% else %} Budget Simulator - {% endif %} + {% endif %} diff --git a/blocnote/apps/landingPage/views.py b/blocnote/apps/landingPage/views.py index 0e2608cabb7292042ecc2dd329a2c618ad917a19..9ffe828732be6c16791a0cb8b7f143080c25259f 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,27 @@ class Index(View): Display links to the inputs, budget simulation and preliminary and full analysis pages. """ - not_saved_list = self.check_inputs(building_id) - if_completed = True - if_started = False - if not_saved_list: - if_completed = False - if len(not_saved_list) < len(self.models): - if_started = True + 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 = 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, '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]) diff --git a/blocnote/lib/fetch_data.py b/blocnote/lib/fetch_data.py index b04ad2a6bee53d7d5c4575a6ae4bd17d9958c388..36f093d979fa9b45b92f566313afdbc5a5e605db 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 @@ -208,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