From 56e8a923ed622d0ae79daca27dd7f9a815543ab9 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Tue, 25 Apr 2017 18:34:54 -0400 Subject: [PATCH 01/15] Create column headings for mortgage and liabilities. Create one row. --- .../static/financialInputs/scripts/app.js | 42 +++++++++++++++++++ .../templates/financialInputs/index.html | 3 ++ .../financialInputs/liabilities.html | 7 ++++ 3 files changed, 52 insertions(+) create mode 100644 blocnote/apps/financialInputs/templates/financialInputs/liabilities.html diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 4f042d4..196f36e 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -4,6 +4,7 @@ for (var utility_index in utilities) { } loadBillsOverview(); getCustomerPreferenceTable(); +loadLiabilitiesTable(); /** * Handle submition of the header form. Validate commissioning date is greater @@ -463,3 +464,44 @@ function getCustomerPreferenceTable() { createCustomerPreferenceTable(res.payload.instance); }); } + +function loadLiabilitiesTable() { + table = document.querySelector('#liabilities-table'); + console.log(table); + var columnHeadings = ` + + + Debt + Lender Name + Monthly Service + Remaining Terms + Input Date + + + `; + table.innerHTML = columnHeadings; + addLiabilitiesRow(table); +} + +function addLiabilitiesRow(table) { + var rowCount = table.rows.length; + var row = table.insertRow(rowCount); + var cell = row.insertCell(0); + cell.innerHTML = `${rowCount}`; + cell = row.insertCell(1); + cell.innerHTML = ` + + `; + cell = row.insertCell(2); + cell.innerHTML = ` + + `; + cell = row.insertCell(3); + cell.innerHTML = ` + + `; + cell = row.insertCell(4); + cell.innerHTML = ` + Date + `; +} diff --git a/blocnote/apps/financialInputs/templates/financialInputs/index.html b/blocnote/apps/financialInputs/templates/financialInputs/index.html index 25a35b7..83d5663 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/index.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/index.html @@ -22,6 +22,9 @@
{% include "financialInputs/billsOverview.html" %}
+
+ {% include "financialInputs/liabilities.html" %} +
{% include "financialInputs/customerPreference.html" %}
diff --git a/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html new file mode 100644 index 0000000..dc3b653 --- /dev/null +++ b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html @@ -0,0 +1,7 @@ +
+

Mortgage and Liabilities

+
+
+ +
+
-- GitLab From ebe4ded4e863a3b18fad54de0b7162c6e466c75e Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Tue, 25 Apr 2017 18:46:11 -0400 Subject: [PATCH 02/15] Add add row button and delete row button. --- .../static/financialInputs/scripts/app.js | 20 +++++++++++++++---- .../financialInputs/liabilities.html | 13 ++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 196f36e..617cdf3 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -306,7 +306,7 @@ function createCalculateButton() { /**Create button to submit the projected and input data. */ function createSubmitButton() { text = ` -
+
`; @@ -467,7 +467,6 @@ function getCustomerPreferenceTable() { function loadLiabilitiesTable() { table = document.querySelector('#liabilities-table'); - console.log(table); var columnHeadings = ` @@ -476,14 +475,16 @@ function loadLiabilitiesTable() { Monthly Service Remaining Terms Input Date + Option `; table.innerHTML = columnHeadings; - addLiabilitiesRow(table); + addLiabilitiesRow(); } -function addLiabilitiesRow(table) { +function addLiabilitiesRow() { + table = document.querySelector('#liabilities-table'); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell = row.insertCell(0); @@ -504,4 +505,15 @@ function addLiabilitiesRow(table) { cell.innerHTML = ` Date `; + cell = row.insertCell(5); + cell.innerHTML = ` +
+ +
+ `; +} + +function deleteLiabilitiesRow(rowIndex) { + console.log(rowIndex); + return false; } diff --git a/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html index dc3b653..a73fb9c 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html @@ -1,7 +1,12 @@

Mortgage and Liabilities

-
- -
-
+
+
+ +
+
+
+ +
+
-- GitLab From 692c5ad7beae6ac041d925cc7273ccc2901ae665 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Tue, 25 Apr 2017 18:50:16 -0400 Subject: [PATCH 03/15] Partially implement delete row. --- .../financialInputs/static/financialInputs/scripts/app.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 617cdf3..bb84a12 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -488,7 +488,7 @@ function addLiabilitiesRow() { var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell = row.insertCell(0); - cell.innerHTML = `${rowCount}`; + cell.innerHTML = `Debt ${rowCount}`; cell = row.insertCell(1); cell.innerHTML = ` @@ -508,12 +508,14 @@ function addLiabilitiesRow() { cell = row.insertCell(5); cell.innerHTML = `
- +
`; } function deleteLiabilitiesRow(rowIndex) { - console.log(rowIndex); + table = document.querySelector('#liabilities-table'); + table.deleteRow(rowIndex); + var rowCount = table.rows.length; return false; } -- GitLab From ae4a993dd660395f53327d8b45ef260d3ca802e5 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Tue, 25 Apr 2017 19:12:00 -0400 Subject: [PATCH 04/15] Show save button. --- .../static/financialInputs/scripts/app.js | 77 +++++++++---------- .../financialInputs/liabilities.html | 13 ++++ 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index bb84a12..2678c2c 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -1,4 +1,5 @@ utilities = ['electricity', 'gas', 'oil', 'water']; +var liabilitiesRowCounter = 0; for (var utility_index in utilities) { loadInitialBillsTable(utilities[utility_index]); } @@ -425,28 +426,29 @@ function createCustomerPreferenceTable(instance) { var expectedNetNOIDSCR = instance['expected_net_noi_dscr'] } var text = ` - - - - - - - - - - - - - - - - - - - - -
PreferenceValue
Affordable Downpayment
Expected PaybackMonths
Expected Net NOI DSCR
- ` + + + Preference + Value + + + + + Affordable Downpayment + + + + Expected Payback + Months + + + Expected Net NOI DSCR + + + + + + `; customerPreferenceForm.innerHTML = text; } @@ -467,39 +469,27 @@ function getCustomerPreferenceTable() { function loadLiabilitiesTable() { table = document.querySelector('#liabilities-table'); - var columnHeadings = ` - - - Debt - Lender Name - Monthly Service - Remaining Terms - Input Date - Option - - - `; - table.innerHTML = columnHeadings; addLiabilitiesRow(); } function addLiabilitiesRow() { - table = document.querySelector('#liabilities-table'); + liabilitiesRowCounter += 1; + table = document.querySelector('#liabilities-table-body'); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell = row.insertCell(0); cell.innerHTML = `Debt ${rowCount}`; cell = row.insertCell(1); cell.innerHTML = ` - + `; cell = row.insertCell(2); cell.innerHTML = ` - + `; cell = row.insertCell(3); cell.innerHTML = ` - + `; cell = row.insertCell(4); cell.innerHTML = ` @@ -517,5 +507,14 @@ function deleteLiabilitiesRow(rowIndex) { table = document.querySelector('#liabilities-table'); table.deleteRow(rowIndex); var rowCount = table.rows.length; + for (var rowInd = 1; rowInd < rowCount; rowInd++) { + row = table.rows.item(rowInd).cells; + row.item(0).innerHTML = `Debt ${rowInd}`; + } + return false; +} + +function liabilitiesSubmitForm(form) { + console.log(form); return false; } diff --git a/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html index a73fb9c..61c6c98 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html @@ -3,7 +3,20 @@
+ + + + + + + + + + + + +
DebtLender NameMonthly ServiceRemaining TermsInput DateOption
-- GitLab From 976b54a12358e56da773cc3786c97796c9c6a363 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Tue, 25 Apr 2017 19:24:36 -0400 Subject: [PATCH 05/15] Create submit list to send to backend. --- .../static/financialInputs/scripts/app.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 2678c2c..6340e1b 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -478,7 +478,7 @@ function addLiabilitiesRow() { var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell = row.insertCell(0); - cell.innerHTML = `Debt ${rowCount}`; + cell.innerHTML = `Debt ${rowCount + 1}`; cell = row.insertCell(1); cell.innerHTML = ` @@ -493,7 +493,7 @@ function addLiabilitiesRow() { `; cell = row.insertCell(4); cell.innerHTML = ` - Date + `; cell = row.insertCell(5); cell.innerHTML = ` @@ -515,6 +515,19 @@ function deleteLiabilitiesRow(rowIndex) { } function liabilitiesSubmitForm(form) { - console.log(form); + table = document.querySelector('#liabilities-table'); + var rowCount = table.rows.length; + var result = []; + for (rowInd = 1; rowInd < rowCount; rowInd++) { + lender = table.rows[rowInd].cells[1].children[0].value; + monthlyService = table.rows[rowInd].cells[2].children[0].value; + remainingTerm = table.rows[rowInd].cells[3].children[0].value; + record = {}; + record['lender'] = lender; + record['monthly-service'] = monthlyService; + record['remaining-term'] = remainingTerm; + result.push(record); + } + console.log(result); return false; } -- GitLab From 729db60224d2c38a30c6f08055b553faab5b2c29 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Tue, 25 Apr 2017 19:27:52 -0400 Subject: [PATCH 06/15] Remove unnecessary code. --- .../static/financialInputs/scripts/app.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 6340e1b..4867ffa 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -519,13 +519,10 @@ function liabilitiesSubmitForm(form) { var rowCount = table.rows.length; var result = []; for (rowInd = 1; rowInd < rowCount; rowInd++) { - lender = table.rows[rowInd].cells[1].children[0].value; - monthlyService = table.rows[rowInd].cells[2].children[0].value; - remainingTerm = table.rows[rowInd].cells[3].children[0].value; record = {}; - record['lender'] = lender; - record['monthly-service'] = monthlyService; - record['remaining-term'] = remainingTerm; + record['lender'] = table.rows[rowInd].cells[1].children[0].value; + record['monthly-service'] = table.rows[rowInd].cells[2].children[0].value; + record['remaining-term'] = table.rows[rowInd].cells[3].children[0].value; result.push(record); } console.log(result); -- GitLab From 4d39b95c8e0028dcdfbba46e17d9e57d07b91bab Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Wed, 26 Apr 2017 09:08:58 -0400 Subject: [PATCH 07/15] Create model liabilities. Create PUT route for liabilities. Frontend make PUT request. Backend receive PUT request, print the request body and send OK to frontend. --- blocnote/apps/financialInputs/models.py | 8 ++++++++ .../static/financialInputs/scripts/app.js | 11 +++++++++++ blocnote/apps/financialInputs/urls.py | 1 + blocnote/apps/financialInputs/views.py | 11 ++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/blocnote/apps/financialInputs/models.py b/blocnote/apps/financialInputs/models.py index 14e6398..a89a478 100644 --- a/blocnote/apps/financialInputs/models.py +++ b/blocnote/apps/financialInputs/models.py @@ -71,3 +71,11 @@ class CustomerPreference(models.Model): 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) + + +class Liabilities(models.Model): + building_id = models.IntegerField() + date = models.DateField() + lender = models.CharField(max_length=150) + monthly_service = models.DecimalField(max_digits=10, decimal_places=2) + remaining_term = models.DecimalField(max_digits=3, decimal_places=0) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 4867ffa..cf2746e 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -526,5 +526,16 @@ function liabilitiesSubmitForm(form) { result.push(record); } console.log(result); + request('liabilities/', { + method: 'PUT', + credentials: 'same-origin', + body: JSON.stringify(result), + headers: new Headers({ + 'Content-Type': 'application/json', + 'X-CSRFToken': Cookies.get('csrftoken') + }) + }).then(res => { + console.log(res); + }); return false; } diff --git a/blocnote/apps/financialInputs/urls.py b/blocnote/apps/financialInputs/urls.py index 72b7fbd..f9d4e2f 100644 --- a/blocnote/apps/financialInputs/urls.py +++ b/blocnote/apps/financialInputs/urls.py @@ -8,4 +8,5 @@ urlpatterns = [ url(r'^bills/$', views.BillsTable.as_view(), name='bills'), url(r'^bills-overview/$', views.BillsOverviewView.as_view(), name='bills_overview'), url(r'^customer-preference/$', views.CustomerPreferenceView.as_view(), name='customer_preference'), + url(r'^liabilities/$', views.LiabilitiesTable.as_view(), name='liabilities'), ] diff --git a/blocnote/apps/financialInputs/views.py b/blocnote/apps/financialInputs/views.py index f99a8b5..747c091 100644 --- a/blocnote/apps/financialInputs/views.py +++ b/blocnote/apps/financialInputs/views.py @@ -6,7 +6,7 @@ from django.views import View from bpfin.utilbills.bill_backend_call import bill_prior_proj_rough_annual -from .models import FinancingOverview, Bills, BillsOverview, CustomerPreference, EstimationAlgorithm +from .models import FinancingOverview, Bills, BillsOverview, CustomerPreference, EstimationAlgorithm, Liabilities from .forms import BlocNoteHeaderForm @@ -602,3 +602,12 @@ class CustomerPreferenceView(View): instance['status'] = False return JsonResponse({'instance': instance}) + +class LiabilitiesTable(View): + model = Liabilities + + def put(self, request, building_id): + put = json.loads(request.body.decode()) + print(put) + + return JsonResponse({'status': 'OK'}) -- GitLab From fe4a45248324f87536a111215ca3a8f41d165a9a Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Wed, 26 Apr 2017 13:47:43 -0400 Subject: [PATCH 08/15] Implement mortgage and liabilities table (both frontend and backend). Remove previous migrations files and add fresh new one. --- .../migrations/0001_initial.py | 80 +++++++++++++++++-- .../migrations/0002_auto_20170412_2043.py | 31 ------- .../migrations/0003_auto_20170412_2143.py | 21 ----- .../migrations/0004_auto_20170412_2153.py | 20 ----- .../migrations/0005_auto_20170413_1530.py | 33 -------- .../migrations/0006_auto_20170413_1533.py | 20 ----- .../financialInputs/migrations/0007_bills.py | 27 ------- .../migrations/0008_auto_20170417_2026.py | 20 ----- .../migrations/0009_billsoverview.py | 24 ------ .../migrations/0010_auto_20170417_2338.py | 20 ----- .../migrations/0011_auto_20170418_0232.py | 59 -------------- .../migrations/0012_customerpreference.py | 25 ------ .../migrations/0013_auto_20170424_2158.py | 27 ------- .../migrations/0013_cashbalance.py | 25 ------ .../migrations/0014_auto_20170421_0004.py | 20 ----- .../migrations/0015_auto_20170424_2250.py | 20 ----- blocnote/apps/financialInputs/models.py | 2 +- .../static/financialInputs/scripts/app.js | 45 ++++++++--- .../financialInputs/liabilities.html | 2 +- blocnote/apps/financialInputs/views.py | 25 ++++-- 20 files changed, 132 insertions(+), 414 deletions(-) delete mode 100644 blocnote/apps/financialInputs/migrations/0002_auto_20170412_2043.py delete mode 100644 blocnote/apps/financialInputs/migrations/0003_auto_20170412_2143.py delete mode 100644 blocnote/apps/financialInputs/migrations/0004_auto_20170412_2153.py delete mode 100644 blocnote/apps/financialInputs/migrations/0005_auto_20170413_1530.py delete mode 100644 blocnote/apps/financialInputs/migrations/0006_auto_20170413_1533.py delete mode 100644 blocnote/apps/financialInputs/migrations/0007_bills.py delete mode 100644 blocnote/apps/financialInputs/migrations/0008_auto_20170417_2026.py delete mode 100644 blocnote/apps/financialInputs/migrations/0009_billsoverview.py delete mode 100644 blocnote/apps/financialInputs/migrations/0010_auto_20170417_2338.py delete mode 100644 blocnote/apps/financialInputs/migrations/0011_auto_20170418_0232.py delete mode 100644 blocnote/apps/financialInputs/migrations/0012_customerpreference.py delete mode 100644 blocnote/apps/financialInputs/migrations/0013_auto_20170424_2158.py delete mode 100644 blocnote/apps/financialInputs/migrations/0013_cashbalance.py delete mode 100644 blocnote/apps/financialInputs/migrations/0014_auto_20170421_0004.py delete mode 100644 blocnote/apps/financialInputs/migrations/0015_auto_20170424_2250.py diff --git a/blocnote/apps/financialInputs/migrations/0001_initial.py b/blocnote/apps/financialInputs/migrations/0001_initial.py index 934afed..f73d21e 100644 --- a/blocnote/apps/financialInputs/migrations/0001_initial.py +++ b/blocnote/apps/financialInputs/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-12 15:19 +# Generated by Django 1.10.6 on 2017-04-26 14:28 from __future__ import unicode_literals from django.db import migrations, models @@ -14,16 +14,75 @@ class Migration(migrations.Migration): ] operations = [ + migrations.CreateModel( + name='Bills', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('building_id', models.IntegerField()), + ('date_from', models.DateField()), + ('date_to', models.DateField()), + ('utility_type', models.CharField(max_length=11)), + ('usage', models.DecimalField(decimal_places=2, max_digits=10)), + ('charge', models.DecimalField(decimal_places=2, max_digits=10)), + ], + ), + migrations.CreateModel( + name='BillsOverview', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('building_id', models.IntegerField()), + ('year', models.DecimalField(decimal_places=0, max_digits=4)), + ('electricity', models.DecimalField(decimal_places=2, max_digits=10)), + ('electricity_is_user_input', models.BooleanField(default=False)), + ('water', models.DecimalField(decimal_places=2, max_digits=10)), + ('water_is_user_input', models.BooleanField(default=False)), + ('oil', models.DecimalField(decimal_places=2, max_digits=10)), + ('oil_is_user_input', models.BooleanField(default=False)), + ('gas', models.DecimalField(decimal_places=2, max_digits=10)), + ('gas_is_user_input', models.BooleanField(default=False)), + ], + ), + migrations.CreateModel( + name='CashBalance', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('building_id', models.IntegerField()), + ('start_date', models.DateField()), + ('is_from_balance_sheet', models.BooleanField(default=False)), + ('balance_amount', models.DecimalField(decimal_places=2, max_digits=10)), + ], + ), + migrations.CreateModel( + name='CustomerPreference', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('building_id', models.IntegerField()), + ('downpayment', models.DecimalField(decimal_places=2, max_digits=10)), + ('expected_payback', models.DecimalField(decimal_places=0, max_digits=3)), + ('expected_net_noi_dscr', models.DecimalField(decimal_places=2, max_digits=5)), + ], + ), + migrations.CreateModel( + name='EstimationAlgorithm', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('algorithm', models.CharField(max_length=16)), + ('building_id', models.IntegerField()), + ], + ), migrations.CreateModel( name='FinancingOverview', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('building_id', models.IntegerField()), - ('required_noi_dscr', models.DecimalField(decimal_places=2, max_digits=5)), - ('requrired_cash_dscr', models.DecimalField(decimal_places=2, max_digits=5)), + ('required_noi_dscr', models.DecimalField(decimal_places=2, default=0, max_digits=5)), + ('requrired_cash_dscr', models.DecimalField(decimal_places=2, default=0, max_digits=5)), + ('pro_forma_start_date', models.DateField()), + ('pro_forma_duration', models.DecimalField(decimal_places=0, max_digits=2)), + ('analysis_date', models.DateField()), ('anticipated_construction_start_date', models.DateField()), ('anticipated_commissioning_date', models.DateField()), - ('anticipated_construction_period', models.DecimalField(decimal_places=0, max_digits=2)), + ('anticipated_construction_period', models.DecimalField(decimal_places=0, max_digits=3)), ], ), migrations.CreateModel( @@ -33,9 +92,20 @@ class Migration(migrations.Migration): ('Name', models.CharField(max_length=200)), ], ), + migrations.CreateModel( + name='Liabilities', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('building_id', models.IntegerField()), + ('input_date', models.DateField()), + ('lender', models.CharField(max_length=150)), + ('monthly_service', models.DecimalField(decimal_places=2, max_digits=10)), + ('remaining_term', models.DecimalField(decimal_places=0, max_digits=3)), + ], + ), migrations.AddField( model_name='financingoverview', name='fund', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='financialInputs.Fund'), + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='financialInputs.Fund'), ), ] diff --git a/blocnote/apps/financialInputs/migrations/0002_auto_20170412_2043.py b/blocnote/apps/financialInputs/migrations/0002_auto_20170412_2043.py deleted file mode 100644 index bb6bee6..0000000 --- a/blocnote/apps/financialInputs/migrations/0002_auto_20170412_2043.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-12 20:43 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='financingoverview', - name='fund', - field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='financialInputs.Fund'), - ), - migrations.AlterField( - model_name='financingoverview', - name='required_noi_dscr', - field=models.DecimalField(decimal_places=2, default=0, max_digits=5), - ), - migrations.AlterField( - model_name='financingoverview', - name='requrired_cash_dscr', - field=models.DecimalField(decimal_places=2, default=0, max_digits=5), - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0003_auto_20170412_2143.py b/blocnote/apps/financialInputs/migrations/0003_auto_20170412_2143.py deleted file mode 100644 index 2929542..0000000 --- a/blocnote/apps/financialInputs/migrations/0003_auto_20170412_2143.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-12 21:43 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0002_auto_20170412_2043'), - ] - - operations = [ - migrations.AlterField( - model_name='financingoverview', - name='fund', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='financialInputs.Fund'), - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0004_auto_20170412_2153.py b/blocnote/apps/financialInputs/migrations/0004_auto_20170412_2153.py deleted file mode 100644 index ca34540..0000000 --- a/blocnote/apps/financialInputs/migrations/0004_auto_20170412_2153.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-12 21:53 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0003_auto_20170412_2143'), - ] - - operations = [ - migrations.AlterField( - model_name='financingoverview', - name='anticipated_construction_period', - field=models.DecimalField(decimal_places=0, max_digits=4), - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0005_auto_20170413_1530.py b/blocnote/apps/financialInputs/migrations/0005_auto_20170413_1530.py deleted file mode 100644 index 3086180..0000000 --- a/blocnote/apps/financialInputs/migrations/0005_auto_20170413_1530.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-13 15:30 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0004_auto_20170412_2153'), - ] - - operations = [ - migrations.AddField( - model_name='financingoverview', - name='analysis_date', - field=models.DateField(default='2017-01-01'), - preserve_default=False, - ), - migrations.AddField( - model_name='financingoverview', - name='pro_forma_duration', - field=models.DecimalField(decimal_places=0, default=2, max_digits=2), - preserve_default=False, - ), - migrations.AddField( - model_name='financingoverview', - name='pro_forma_start_date', - field=models.DateField(default='2017-01-01'), - preserve_default=False, - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0006_auto_20170413_1533.py b/blocnote/apps/financialInputs/migrations/0006_auto_20170413_1533.py deleted file mode 100644 index a101685..0000000 --- a/blocnote/apps/financialInputs/migrations/0006_auto_20170413_1533.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-13 15:33 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0005_auto_20170413_1530'), - ] - - operations = [ - migrations.AlterField( - model_name='financingoverview', - name='anticipated_construction_period', - field=models.DecimalField(decimal_places=0, max_digits=3), - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0007_bills.py b/blocnote/apps/financialInputs/migrations/0007_bills.py deleted file mode 100644 index cf60028..0000000 --- a/blocnote/apps/financialInputs/migrations/0007_bills.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-17 15:04 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0006_auto_20170413_1533'), - ] - - operations = [ - migrations.CreateModel( - name='Bills', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('building_id', models.IntegerField()), - ('date_from', models.DateField()), - ('date_to', models.DateField()), - ('utility_type', models.CharField(max_length=11)), - ('usage', models.DecimalField(decimal_places=2, max_digits=6)), - ('charge', models.DecimalField(decimal_places=2, max_digits=10)), - ], - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0008_auto_20170417_2026.py b/blocnote/apps/financialInputs/migrations/0008_auto_20170417_2026.py deleted file mode 100644 index 3ecb611..0000000 --- a/blocnote/apps/financialInputs/migrations/0008_auto_20170417_2026.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-17 20:26 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0007_bills'), - ] - - operations = [ - migrations.AlterField( - model_name='bills', - name='usage', - field=models.DecimalField(decimal_places=2, max_digits=10), - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0009_billsoverview.py b/blocnote/apps/financialInputs/migrations/0009_billsoverview.py deleted file mode 100644 index 6f0b789..0000000 --- a/blocnote/apps/financialInputs/migrations/0009_billsoverview.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-17 23:20 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0008_auto_20170417_2026'), - ] - - operations = [ - migrations.CreateModel( - name='BillsOverview', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('building_id', models.IntegerField()), - ('year', models.DecimalField(decimal_places=0, max_digits=4)), - ('estimation_algorithm', models.CharField(choices=[('FR', 'Freshman'), ('SO', 'Sophomore'), ('JR', 'Junior'), ('SR', 'Senior')], max_length=100)), - ], - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0010_auto_20170417_2338.py b/blocnote/apps/financialInputs/migrations/0010_auto_20170417_2338.py deleted file mode 100644 index 5a4c4fd..0000000 --- a/blocnote/apps/financialInputs/migrations/0010_auto_20170417_2338.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-17 23:38 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0009_billsoverview'), - ] - - operations = [ - migrations.AlterField( - model_name='billsoverview', - name='estimation_algorithm', - field=models.CharField(max_length=100), - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0011_auto_20170418_0232.py b/blocnote/apps/financialInputs/migrations/0011_auto_20170418_0232.py deleted file mode 100644 index 8198ef5..0000000 --- a/blocnote/apps/financialInputs/migrations/0011_auto_20170418_0232.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-18 02:32 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0010_auto_20170417_2338'), - ] - - operations = [ - migrations.AddField( - model_name='billsoverview', - name='electricity', - field=models.DecimalField(decimal_places=2, default=0.0, max_digits=10), - preserve_default=False, - ), - migrations.AddField( - model_name='billsoverview', - name='electricity_is_user_input', - field=models.BooleanField(default=False), - ), - migrations.AddField( - model_name='billsoverview', - name='gas', - field=models.DecimalField(decimal_places=2, default=0.0, max_digits=10), - preserve_default=False, - ), - migrations.AddField( - model_name='billsoverview', - name='gas_is_user_input', - field=models.BooleanField(default=False), - ), - migrations.AddField( - model_name='billsoverview', - name='oil', - field=models.DecimalField(decimal_places=2, default=0.0, max_digits=10), - preserve_default=False, - ), - migrations.AddField( - model_name='billsoverview', - name='oil_is_user_input', - field=models.BooleanField(default=False), - ), - migrations.AddField( - model_name='billsoverview', - name='water', - field=models.DecimalField(decimal_places=2, default=0, max_digits=10), - preserve_default=False, - ), - migrations.AddField( - model_name='billsoverview', - name='water_is_user_input', - field=models.BooleanField(default=False), - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0012_customerpreference.py b/blocnote/apps/financialInputs/migrations/0012_customerpreference.py deleted file mode 100644 index 2b643cf..0000000 --- a/blocnote/apps/financialInputs/migrations/0012_customerpreference.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-19 20:58 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0011_auto_20170418_0232'), - ] - - operations = [ - migrations.CreateModel( - name='CustomerPreference', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('building_id', models.IntegerField()), - ('downpayment', models.DecimalField(decimal_places=2, max_digits=10)), - ('expected_payback', models.DecimalField(decimal_places=0, max_digits=3)), - ('expected_net_noi_dscr', models.DecimalField(decimal_places=2, max_digits=5)), - ], - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0013_auto_20170424_2158.py b/blocnote/apps/financialInputs/migrations/0013_auto_20170424_2158.py deleted file mode 100644 index 781d346..0000000 --- a/blocnote/apps/financialInputs/migrations/0013_auto_20170424_2158.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-24 21:58 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0012_customerpreference'), - ] - - operations = [ - migrations.CreateModel( - name='EstimationAlgorithm', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('building_id', models.IntegerField()), - ('algorithm', models.CharField(max_length=100)), - ], - ), - migrations.RemoveField( - model_name='billsoverview', - name='estimation_algorithm', - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0013_cashbalance.py b/blocnote/apps/financialInputs/migrations/0013_cashbalance.py deleted file mode 100644 index 7fe2952..0000000 --- a/blocnote/apps/financialInputs/migrations/0013_cashbalance.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-20 15:12 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0012_customerpreference'), - ] - - operations = [ - migrations.CreateModel( - name='CashBalance', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('building_id', models.IntegerField()), - ('date', models.DateField()), - ('is_from_balance_sheet', models.BooleanField(default=False)), - ('balance_amount', models.DecimalField(decimal_places=2, max_digits=10)), - ], - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0014_auto_20170421_0004.py b/blocnote/apps/financialInputs/migrations/0014_auto_20170421_0004.py deleted file mode 100644 index b737b51..0000000 --- a/blocnote/apps/financialInputs/migrations/0014_auto_20170421_0004.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-21 00:04 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0013_cashbalance'), - ] - - operations = [ - migrations.RenameField( - model_name='cashbalance', - old_name='date', - new_name='start_date', - ), - ] diff --git a/blocnote/apps/financialInputs/migrations/0015_auto_20170424_2250.py b/blocnote/apps/financialInputs/migrations/0015_auto_20170424_2250.py deleted file mode 100644 index e350b03..0000000 --- a/blocnote/apps/financialInputs/migrations/0015_auto_20170424_2250.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.6 on 2017-04-24 22:50 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('financialInputs', '0013_auto_20170424_2158'), - ] - - operations = [ - migrations.AlterField( - model_name='estimationalgorithm', - name='algorithm', - field=models.CharField(max_length=16), - ), - ] diff --git a/blocnote/apps/financialInputs/models.py b/blocnote/apps/financialInputs/models.py index 450f207..426d097 100644 --- a/blocnote/apps/financialInputs/models.py +++ b/blocnote/apps/financialInputs/models.py @@ -75,7 +75,7 @@ class CustomerPreference(models.Model): class Liabilities(models.Model): building_id = models.IntegerField() - date = models.DateField() + input_date = models.DateField() lender = models.CharField(max_length=150) monthly_service = models.DecimalField(max_digits=10, decimal_places=2) remaining_term = models.DecimalField(max_digits=3, decimal_places=0) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index c0f61b5..1408ebb 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -5,7 +5,7 @@ for (var utility_index in utilities) { } loadBillsOverview(); getCustomerPreferenceTable(); -loadLiabilitiesTable(); +getLiabilitiesTable(); getCashBalanceForm(); var rowCounter = 0; @@ -467,12 +467,27 @@ function getCustomerPreferenceTable() { }); } -function loadLiabilitiesTable() { +function loadLiabilitiesTable(inputList) { table = document.querySelector('#liabilities-table'); - addLiabilitiesRow(1,1,1980); + if (inputList.length === 0) { + addLiabilitiesRow('', '', '', 1, 1, 1980); + } + else { + for (index in inputList) { + record = inputList[index]; + lender = record['lender'] + service = record['monthly_service'] + term = record['remaining_term'] + date = record['input_date'].split('-'); + month = Number(date[1]); + day = Number(date[2]); + year = Number(date[0]); + addLiabilitiesRow(lender, service, term, month, day, year) + } + } } -function addLiabilitiesRow(month, day, year) { +function addLiabilitiesRow(lender, service, term, month, day, year) { liabilitiesRowCounter += 1; table = document.querySelector('#liabilities-table-body'); var rowCount = table.rows.length; @@ -481,15 +496,15 @@ function addLiabilitiesRow(month, day, year) { cell.innerHTML = `Debt ${rowCount + 1}`; cell = row.insertCell(1); cell.innerHTML = ` - + `; cell = row.insertCell(2); cell.innerHTML = ` - + `; cell = row.insertCell(3); cell.innerHTML = ` - + `; cell = row.insertCell(4); cell.innerHTML = createDateComponent(month, day, year, liabilitiesRowCounter); @@ -526,7 +541,6 @@ function liabilitiesSubmitForm(form) { record['date-year'] = table.rows[rowInd].cells[4].children[2].value; result.push(record); } - console.log(result); request('liabilities/', { method: 'PUT', credentials: 'same-origin', @@ -535,11 +549,22 @@ function liabilitiesSubmitForm(form) { 'Content-Type': 'application/json', 'X-CSRFToken': Cookies.get('csrftoken') }) - }).then(res => { - console.log(res); }); return false; } + +function getLiabilitiesTable() { + request(`liabilities/`, { + method: 'GET', + credentials: 'same-origin', + headers: { + 'Content-Type': 'application/json' + }, + }).then(res => { + loadLiabilitiesTable(res.payload.instance); + }); +} + /**Send HTTP GET request to obtain all cash balance records. */ function getCashBalanceForm() { request(`cash-balance/`, { diff --git a/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html index 61c6c98..eda6ab5 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html @@ -20,6 +20,6 @@
- +
diff --git a/blocnote/apps/financialInputs/views.py b/blocnote/apps/financialInputs/views.py index 35eb4bc..f269dd4 100644 --- a/blocnote/apps/financialInputs/views.py +++ b/blocnote/apps/financialInputs/views.py @@ -230,7 +230,7 @@ class BillsTable(View): date_to_index = index elif heading == "Usage": usage_index = index - elif heading == "Total Charges": + elif "Total Charges" in heading: charge_index = index result = [] @@ -608,17 +608,32 @@ class CustomerPreferenceView(View): class LiabilitiesTable(View): model = Liabilities + def get(self,request, building_id): + objs = self.model.objects.filter(building_id=building_id) + result = [] + if objs: + for obj in objs: + record = {} + record['lender'] = obj.lender + record['input_date'] = obj.input_date + record['monthly_service'] = obj.monthly_service + record['remaining_term'] = obj.remaining_term + result.append(record) + return JsonResponse({'instance': result}) + def put(self, request, building_id): put = json.loads(request.body.decode()) - print(put) self.model.objects.filter(building_id=building_id).delete() for record in put: + year = int(record['date-year']) + month = int(record['date-month']) + day = int(record['date-day']) self.model.objects.create( building_id=building_id, - date=date(record['date-year'], record['date-month'], record['date-day']), + input_date=date(year, month, day), lender=record['lender'], - monthly_service=record['monthly-service'], - remaining_term=record['remaining-term'], + monthly_service=float(record['monthly-service']), + remaining_term=float(record['remaining-term']), ) return JsonResponse({'status': 'OK'}) -- GitLab From 3a3508d48631efd5a3ac80ed421afdf9c872fe68 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Mon, 1 May 2017 14:26:18 -0400 Subject: [PATCH 09/15] Update based on Conrad and Jose's comments. --- blocnote/apps/financialInputs/models.py | 1 - .../static/financialInputs/scripts/app.js | 17 +++++++++++------ blocnote/apps/financialInputs/views.py | 11 ++++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/blocnote/apps/financialInputs/models.py b/blocnote/apps/financialInputs/models.py index aa70596..16d26d4 100644 --- a/blocnote/apps/financialInputs/models.py +++ b/blocnote/apps/financialInputs/models.py @@ -93,4 +93,3 @@ class CashBalance(models.Model): statement_date = models.DateField() is_from_balance_sheet = models.BooleanField(default=False) balance_amount = models.DecimalField(max_digits=10, decimal_places=2) - diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 565306c..5f301fa 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -6,10 +6,11 @@ loadBillsOverview(); getCustomerPreferenceTable(); getLiabilitiesTable(); getCashBalanceForm(); -/**nextCashBalanceRowID is used to uniquely identify the row of the cash balance table. This does NOT represent the - * actual row number. It represents the total number of rows added. This does NOT get decremented on deleting - * a row. This is so that each new row has a new number in its id so that information can be obtained and sent - * to backend. +/** + * nextCashBalanceRowID and nextLiabilitiesRowID is used to uniquely identify the row of the cash balance/liabilities + * table. This does NOT represent the actual row number. It represents the total number of rows added. This does NOT + * get decremented on deleting a row. This is so that each new row has a new number in its id so that information can + * be obtained and sent to backend. */ var nextCashBalanceRowID = 0; var nextLiabilitiesRowID = 0; @@ -471,7 +472,11 @@ function getCustomerPreferenceTable() { }); } -/**Load the Mortgage and Liabilities table. */ +/** + * Load the Mortgage and Liabilities table. + * This function loads the mortgage and liabilities table with the given inputList. If inputList is empty, it loads a + * row with empty inputs and 1/1/1980 date as default values. + */ function loadLiabilitiesTable(inputList) { table = document.querySelector('#liabilities-table'); if (inputList.length === 0) { @@ -557,7 +562,7 @@ function liabilitiesSubmitForm(form) { 'Content-Type': 'application/json', 'X-CSRFToken': Cookies.get('csrftoken') }) - }); + }); return false; } diff --git a/blocnote/apps/financialInputs/views.py b/blocnote/apps/financialInputs/views.py index 8eebda1..ea50b69 100644 --- a/blocnote/apps/financialInputs/views.py +++ b/blocnote/apps/financialInputs/views.py @@ -627,11 +627,12 @@ class LiabilitiesTable(View): result = [] if objs: for obj in objs: - record = {} - record['lender'] = obj.lender - record['input_date'] = obj.input_date - record['monthly_service'] = obj.monthly_service - record['remaining_term'] = obj.remaining_term + record = { + 'lender': obj.lender, + 'input_date': obj.input_date, + 'monthly_service': obj.monthly_service, + 'remaining_term': obj.remaining_term, + } result.append(record) return JsonResponse({'instance': result}) -- GitLab From 48d66ed5a5c9c80255b222474b9ecb5cd1c74d23 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Mon, 1 May 2017 15:17:44 -0400 Subject: [PATCH 10/15] Change url to be buildings instead of building. Remove nextCashBalanceRowID and nextLiabilitiesRowID. --- .../static/financialInputs/scripts/app.js | 31 +++++++------------ blocnote/urls.py | 2 +- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 5f301fa..97c1f1c 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -6,14 +6,7 @@ loadBillsOverview(); getCustomerPreferenceTable(); getLiabilitiesTable(); getCashBalanceForm(); -/** - * nextCashBalanceRowID and nextLiabilitiesRowID is used to uniquely identify the row of the cash balance/liabilities - * table. This does NOT represent the actual row number. It represents the total number of rows added. This does NOT - * get decremented on deleting a row. This is so that each new row has a new number in its id so that information can - * be obtained and sent to backend. - */ -var nextCashBalanceRowID = 0; -var nextLiabilitiesRowID = 0; + /** * Handle submition of the header form. Validate commissioning date is greater * than construction start date. Create result dictionary containing the form @@ -483,7 +476,7 @@ function loadLiabilitiesTable(inputList) { addLiabilitiesRow('', '', '', 1, 1, 1980); } else { - for (index in inputList) { + inputList.map(function(index) { record = inputList[index]; lender = record['lender'] service = record['monthly_service'] @@ -492,8 +485,8 @@ function loadLiabilitiesTable(inputList) { month = Number(date[1]); day = Number(date[2]); year = Number(date[0]); - addLiabilitiesRow(lender, service, term, month, day, year) - } + addLiabilitiesRow(lender, service, term, month, day, year); + }); } } @@ -506,25 +499,24 @@ function addLiabilitiesRow(lender, service, term, month, day, year) { cell.innerHTML = `Debt ${rowCount + 1}`; cell = row.insertCell(1); cell.innerHTML = ` - + `; cell = row.insertCell(2); cell.innerHTML = ` - + `; cell = row.insertCell(3); cell.innerHTML = ` - + `; cell = row.insertCell(4); - cell.innerHTML = createDateComponent(month, day, year, nextLiabilitiesRowID); + cell.innerHTML = createDateComponent(month, day, year); cell = row.insertCell(5); cell.innerHTML = `
`; - nextLiabilitiesRowID += 1; } /**Delete a row from the Mortgage and Liabilities table. */ @@ -623,7 +615,7 @@ function getCashBalanceCheckBox(isFromBalanceSheet) { } var text = ` `; return text; @@ -652,11 +644,11 @@ function addCashBalanceRow(balance, month, day, year, isFromBalanceSheet) { cell.innerHTML += `${rowCount}`; cell = row.insertCell(1); cell.innerHTML += ` - + `; cell = row.insertCell(2); cell.innerHTML += ` - ${createDateComponent(month, day, year, nextCashBalanceRowID)} + ${createDateComponent(month, day, year)} `; cell = row.insertCell(3); cell.innerHTML += getCashBalanceCheckBox(isFromBalanceSheet); @@ -664,7 +656,6 @@ function addCashBalanceRow(balance, month, day, year, isFromBalanceSheet) { cell.innerHTML += ` `; - nextCashBalanceRowID += 1; return false; } diff --git a/blocnote/urls.py b/blocnote/urls.py index 69e442f..2cefee1 100644 --- a/blocnote/urls.py +++ b/blocnote/urls.py @@ -18,6 +18,6 @@ from django.contrib import admin urlpatterns = [ url('', admin.site.urls), - url(r'^building/(?P[0-9]+)/financial-inputs/', include('blocnote.apps.financialInputs.urls')), + url(r'^buildings/(?P[0-9]+)/financial-inputs/', include('blocnote.apps.financialInputs.urls')), url(r'^admin/', admin.site.urls), ] -- GitLab From dc088b0b3952d59595cf8dc33cf994e13f401623 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Mon, 1 May 2017 16:01:02 -0400 Subject: [PATCH 11/15] Fix map function. --- .../apps/financialInputs/static/financialInputs/scripts/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 97c1f1c..d385a0a 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -476,7 +476,7 @@ function loadLiabilitiesTable(inputList) { addLiabilitiesRow('', '', '', 1, 1, 1980); } else { - inputList.map(function(index) { + inputList.map(function(record, index) { record = inputList[index]; lender = record['lender'] service = record['monthly_service'] -- GitLab From c6f9818b01a63ba758dfcfee623086f3be99f0db Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Mon, 1 May 2017 16:24:03 -0400 Subject: [PATCH 12/15] Fix table styles. --- .../static/financialInputs/scripts/app.js | 49 ++++++++++--------- .../financialInputs/cashBalance.html | 32 ++++++------ 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index d385a0a..b61d029 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -425,29 +425,32 @@ function createCustomerPreferenceTable(instance) { var expectedPayback = instance['expected_payback']; var expectedNetNOIDSCR = instance['expected_net_noi_dscr'] } - var text = ` - - - - - - - - - - - - - - - - - - - - -
PreferenceValue
Affordable Downpayment
Expected PaybackMonths
Expected Net NOI DSCR
+ var text = ` +
+ + + + + + + + + + + + + + + + + + + + + +
PreferenceValue
Affordable Downpayment
Expected PaybackMonths
Expected Net NOI DSCR
+
`; customerPreferenceForm.innerHTML = text; } @@ -637,7 +640,7 @@ function deleteCashBalanceRow(row) { * balance sheet or not. */ function addCashBalanceRow(balance, month, day, year, isFromBalanceSheet) { - table = document.querySelector('#cash-balance-table'); + table = document.querySelector('#cash-balance-body'); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell = row.insertCell(0); diff --git a/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html b/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html index c6975d9..780487c 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html @@ -1,22 +1,24 @@

Cash Balance

-
-
+
+ -
- - - - - - - - - - -
#Balance AmountDateBalance SheetOption
- + + + + + + + + + + + + +
#Balance AmountDateBalance SheetOption
+ +
-- GitLab From 5f46290ed46dfb9ed54032f6123c3b553c5175d2 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Mon, 1 May 2017 16:35:23 -0400 Subject: [PATCH 13/15] Change method to select body of table for cash balance and liabilities. --- .../financialInputs/static/financialInputs/scripts/app.js | 4 ++-- .../templates/financialInputs/cashBalance.html | 4 ++-- .../templates/financialInputs/liabilities.html | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index b61d029..868d8ce 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -495,7 +495,7 @@ function loadLiabilitiesTable(inputList) { /**Add a new row to Mortgage and Liabilities table. */ function addLiabilitiesRow(lender, service, term, month, day, year) { - table = document.querySelector('#liabilities-table-body'); + table = document.querySelector('#liabilities-table tbody'); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell = row.insertCell(0); @@ -640,7 +640,7 @@ function deleteCashBalanceRow(row) { * balance sheet or not. */ function addCashBalanceRow(balance, month, day, year, isFromBalanceSheet) { - table = document.querySelector('#cash-balance-body'); + table = document.querySelector('#cash-balance-table tbody'); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell = row.insertCell(0); diff --git a/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html b/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html index 780487c..7dee6c2 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html @@ -5,7 +5,7 @@ - + @@ -14,7 +14,7 @@ - +
# Balance AmountOption
diff --git a/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html index eda6ab5..c5735a5 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html @@ -15,7 +15,7 @@ Option - + -- GitLab From efe042820952f284886bc2ee1347cf75f4712b16 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Mon, 1 May 2017 16:57:07 -0400 Subject: [PATCH 14/15] Add card-block class to all components. --- .../static/financialInputs/scripts/app.js | 48 +++++++++---------- .../financialInputs/billsOverview.html | 2 +- .../financialInputs/cashBalance.html | 44 ++++++++--------- .../templates/financialInputs/index.html | 20 ++++++-- .../financialInputs/liabilities.html | 40 ++++++++-------- 5 files changed, 78 insertions(+), 76 deletions(-) diff --git a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js index 868d8ce..7b871ed 100644 --- a/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js +++ b/blocnote/apps/financialInputs/static/financialInputs/scripts/app.js @@ -426,31 +426,29 @@ function createCustomerPreferenceTable(instance) { var expectedNetNOIDSCR = instance['expected_net_noi_dscr'] } var text = ` -
- - - - - - - - - - - - - - - - - - - - - -
PreferenceValue
Affordable Downpayment
Expected PaybackMonths
Expected Net NOI DSCR
- -
+ + + + + + + + + + + + + + + + + + + + + +
PreferenceValue
Affordable Downpayment
Expected PaybackMonths
Expected Net NOI DSCR
+ `; customerPreferenceForm.innerHTML = text; } diff --git a/blocnote/apps/financialInputs/templates/financialInputs/billsOverview.html b/blocnote/apps/financialInputs/templates/financialInputs/billsOverview.html index c015442..a1e6de8 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/billsOverview.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/billsOverview.html @@ -1,5 +1,5 @@

Energy Bills Overview

-
+
diff --git a/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html b/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html index 7dee6c2..b328008 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/cashBalance.html @@ -1,26 +1,22 @@

Cash Balance -

-
-
- - - - - - - - - - - - - -
#Balance AmountDateBalance SheetOption
-
-
-
-
- -
-
+ +
+ + + + + + + + + + + + + +
#Balance AmountDateBalance SheetOption
+
+
+ +
diff --git a/blocnote/apps/financialInputs/templates/financialInputs/index.html b/blocnote/apps/financialInputs/templates/financialInputs/index.html index 2280a00..25174a0 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/index.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/index.html @@ -17,19 +17,29 @@
- {% include "financialInputs/bills.html" %} +
+ {% include "financialInputs/bills.html" %} +
- {% include "financialInputs/billsOverview.html" %} +
+ {% include "financialInputs/billsOverview.html" %} +
- {% include "financialInputs/cashBalance.html" %} +
+ {% include "financialInputs/cashBalance.html" %} +
- {% include "financialInputs/liabilities.html" %} +
+ {% include "financialInputs/liabilities.html" %} +
- {% include "financialInputs/customerPreference.html" %} +
+ {% include "financialInputs/customerPreference.html" %} +
{% endblock %} {% block scripts %} diff --git a/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html index c5735a5..4806244 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/liabilities.html @@ -1,25 +1,23 @@

Mortgage and Liabilities

-
-
- - - - - - - - - - - - - - -
DebtLender NameMonthly ServiceRemaining TermsInput DateOption
-
-
- -
+
+ + + + + + + + + + + + + + +
DebtLender NameMonthly ServiceRemaining TermsInput DateOption
+
+
+
-- GitLab From 75d4ec135de150de7595b1e7d4b65a79fc19a9cd Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Mon, 1 May 2017 17:01:50 -0400 Subject: [PATCH 15/15] Bills tab shows no bills available if no bills are available. --- .../financialInputs/templates/financialInputs/bills.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blocnote/apps/financialInputs/templates/financialInputs/bills.html b/blocnote/apps/financialInputs/templates/financialInputs/bills.html index b57366d..5af7c79 100644 --- a/blocnote/apps/financialInputs/templates/financialInputs/bills.html +++ b/blocnote/apps/financialInputs/templates/financialInputs/bills.html @@ -24,10 +24,10 @@
-
-
-
-
+
No Bills available
+
No Bills available
+
No Bills available
+
No Bills available
-- GitLab